fansunited-sdk-esm 1.1.9 → 1.2.0

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,3 +1,3 @@
1
1
  var Uo=Object.create;var Yr=Object.defineProperty;var Do=Object.getOwnPropertyDescriptor;var Vo=Object.getOwnPropertyNames;var $o=Object.getPrototypeOf,Ho=Object.prototype.hasOwnProperty;var ko=o=>Yr(o,"__esModule",{value:!0});var h=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var qo=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Vo(e))!Ho.call(o,i)&&(t||i!=="default")&&Yr(o,i,{get:()=>e[i],enumerable:!(r=Do(e,i))||r.enumerable});return o},Fe=(o,e)=>qo(ko(Yr(o!=null?Uo($o(o)):{},"default",!e&&o&&o.__esModule?{get:()=>o.default,enumerable:!0}:{value:o,enumerable:!0})),o);var Wr=h((Ha,Ri)=>{"use strict";Ri.exports=function(e,t){return function(){for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];return e.apply(t,i)}}});var P=h((ka,Si)=>{"use strict";var jo=Wr(),Y=Object.prototype.toString;function zr(o){return Y.call(o)==="[object Array]"}function Qr(o){return typeof o=="undefined"}function Xo(o){return o!==null&&!Qr(o)&&o.constructor!==null&&!Qr(o.constructor)&&typeof o.constructor.isBuffer=="function"&&o.constructor.isBuffer(o)}function Ko(o){return Y.call(o)==="[object ArrayBuffer]"}function Yo(o){return typeof FormData!="undefined"&&o instanceof FormData}function Wo(o){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&o.buffer instanceof ArrayBuffer,e}function zo(o){return typeof o=="string"}function Qo(o){return typeof o=="number"}function Fi(o){return o!==null&&typeof o=="object"}function Ve(o){if(Y.call(o)!=="[object Object]")return!1;var e=Object.getPrototypeOf(o);return e===null||e===Object.prototype}function Jo(o){return Y.call(o)==="[object Date]"}function Zo(o){return Y.call(o)==="[object File]"}function ea(o){return Y.call(o)==="[object Blob]"}function vi(o){return Y.call(o)==="[object Function]"}function ta(o){return Fi(o)&&vi(o.pipe)}function ra(o){return typeof URLSearchParams!="undefined"&&o instanceof URLSearchParams}function ia(o){return o.trim?o.trim():o.replace(/^\s+|\s+$/g,"")}function oa(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Jr(o,e){if(!(o===null||typeof o=="undefined"))if(typeof o!="object"&&(o=[o]),zr(o))for(var t=0,r=o.length;t<r;t++)e.call(null,o[t],t,o);else for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&e.call(null,o[i],i,o)}function Zr(){var o={};function e(i,a){Ve(o[a])&&Ve(i)?o[a]=Zr(o[a],i):Ve(i)?o[a]=Zr({},i):zr(i)?o[a]=i.slice():o[a]=i}for(var t=0,r=arguments.length;t<r;t++)Jr(arguments[t],e);return o}function aa(o,e,t){return Jr(e,function(i,a){t&&typeof i=="function"?o[a]=jo(i,t):o[a]=i}),o}function na(o){return o.charCodeAt(0)===65279&&(o=o.slice(1)),o}Si.exports={isArray:zr,isArrayBuffer:Ko,isBuffer:Xo,isFormData:Yo,isArrayBufferView:Wo,isString:zo,isNumber:Qo,isObject:Fi,isPlainObject:Ve,isUndefined:Qr,isDate:Jo,isFile:Zo,isBlob:ea,isFunction:vi,isStream:ta,isURLSearchParams:ra,isStandardBrowserEnv:oa,forEach:Jr,merge:Zr,extend:aa,trim:ia,stripBOM:na}});var ei=h((qa,Ei)=>{"use strict";var Z=P();function Ti(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Ei.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(Z.isURLSearchParams(t))i=t.toString();else{var a=[];Z.forEach(t,function(p,m){p===null||typeof p=="undefined"||(Z.isArray(p)?m=m+"[]":p=[p],Z.forEach(p,function(c){Z.isDate(c)?c=c.toISOString():Z.isObject(c)&&(c=JSON.stringify(c)),a.push(Ti(m)+"="+Ti(c))}))}),i=a.join("&")}if(i){var n=e.indexOf("#");n!==-1&&(e=e.slice(0,n)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Ci=h((ja,_i)=>{"use strict";var sa=P();function $e(){this.handlers=[]}$e.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1};$e.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};$e.prototype.forEach=function(e){sa.forEach(this.handlers,function(r){r!==null&&e(r)})};_i.exports=$e});var xi=h((Xa,Oi)=>{"use strict";var la=P();Oi.exports=function(e,t){la.forEach(e,function(i,a){a!==t&&a.toUpperCase()===t.toUpperCase()&&(e[t]=i,delete e[a])})}});var ti=h((Ka,Ai)=>{"use strict";Ai.exports=function(e,t,r,i,a){return e.config=t,r&&(e.code=r),e.request=i,e.response=a,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var ri=h((Ya,Bi)=>{"use strict";var pa=ti();Bi.exports=function(e,t,r,i,a){var n=new Error(e);return pa(n,t,r,i,a)}});var Li=h((Wa,Ni)=>{"use strict";var ca=ri();Ni.exports=function(e,t,r){var i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(ca("Request failed with status code "+r.status,r.config,null,r.request,r))}});var Ui=h((za,Gi)=>{"use strict";var He=P();Gi.exports=He.isStandardBrowserEnv()?function(){return{write:function(t,r,i,a,n,s){var p=[];p.push(t+"="+encodeURIComponent(r)),He.isNumber(i)&&p.push("expires="+new Date(i).toGMTString()),He.isString(a)&&p.push("path="+a),He.isString(n)&&p.push("domain="+n),s===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(t){var r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Vi=h((Qa,Di)=>{"use strict";Di.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var Hi=h((Ja,$i)=>{"use strict";$i.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}});var qi=h((Za,ki)=>{"use strict";var ma=Vi(),ua=Hi();ki.exports=function(e,t){return e&&!ma(t)?ua(e,t):t}});var Xi=h((en,ji)=>{"use strict";var ii=P(),da=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];ji.exports=function(e){var t={},r,i,a;return e&&ii.forEach(e.split(`
2
- `),function(s){if(a=s.indexOf(":"),r=ii.trim(s.substr(0,a)).toLowerCase(),i=ii.trim(s.substr(a+1)),r){if(t[r]&&da.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var Wi=h((tn,Yi)=>{"use strict";var Ki=P();Yi.exports=Ki.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var n=a;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=i(window.location.href),function(n){var s=Ki.isString(n)?i(n):n;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}()});var ve=h((rn,zi)=>{"use strict";function oi(o){this.message=o}oi.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};oi.prototype.__CANCEL__=!0;zi.exports=oi});var ni=h((on,Qi)=>{"use strict";var ke=P(),ha=Li(),fa=Ui(),ga=ei(),ya=qi(),Ma=Xi(),wa=Wi(),ai=ri(),ba=Se(),Pa=ve();Qi.exports=function(e){return new Promise(function(r,i){var a=e.data,n=e.headers,s=e.responseType,p;function m(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}ke.isFormData(a)&&delete n["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";n.Authorization="Basic "+btoa(c+":"+f)}var L=ya(e.baseURL,e.url);l.open(e.method.toUpperCase(),ga(L,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function Pi(){if(!!l){var C="getAllResponseHeaders"in l?Ma(l.getAllResponseHeaders()):null,J=!s||s==="text"||s==="json"?l.responseText:l.response,K={data:J,status:l.status,statusText:l.statusText,headers:C,config:e,request:l};ha(function(Kr){r(Kr),m()},function(Kr){i(Kr),m()},K),l=null}}if("onloadend"in l?l.onloadend=Pi:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(Pi)},l.onabort=function(){!l||(i(ai("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(ai("Network Error",e,null,l)),l=null},l.ontimeout=function(){var J=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",K=e.transitional||ba.transitional;e.timeoutErrorMessage&&(J=e.timeoutErrorMessage),i(ai(J,e,K.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},ke.isStandardBrowserEnv()){var Ii=(e.withCredentials||wa(L))&&e.xsrfCookieName?fa.read(e.xsrfCookieName):void 0;Ii&&(n[e.xsrfHeaderName]=Ii)}"setRequestHeader"in l&&ke.forEach(n,function(J,K){typeof a=="undefined"&&K.toLowerCase()==="content-type"?delete n[K]:l.setRequestHeader(K,J)}),ke.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),s&&s!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(C){!l||(i(!C||C&&C.type?new Pa("canceled"):C),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var Se=h((an,eo)=>{"use strict";var M=P(),Ji=xi(),Ia=ti(),Ra={"Content-Type":"application/x-www-form-urlencoded"};function Zi(o,e){!M.isUndefined(o)&&M.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function Fa(){var o;return typeof XMLHttpRequest!="undefined"?o=ni():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=ni()),o}function va(o,e,t){if(M.isString(o))try{return(e||JSON.parse)(o),M.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var qe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Fa(),transformRequest:[function(e,t){return Ji(t,"Accept"),Ji(t,"Content-Type"),M.isFormData(e)||M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)?e:M.isArrayBufferView(e)?e.buffer:M.isURLSearchParams(e)?(Zi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):M.isObject(e)||t&&t["Content-Type"]==="application/json"?(Zi(t,"application/json"),va(e)):e}],transformResponse:[function(e){var t=this.transitional||qe.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&M.isString(e)&&e.length)try{return JSON.parse(e)}catch(n){if(a)throw n.name==="SyntaxError"?Ia(n,this,"E_JSON_PARSE"):n}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};M.forEach(["delete","get","head"],function(e){qe.headers[e]={}});M.forEach(["post","put","patch"],function(e){qe.headers[e]=M.merge(Ra)});eo.exports=qe});var ro=h((nn,to)=>{"use strict";var Sa=P(),Ta=Se();to.exports=function(e,t,r){var i=this||Ta;return Sa.forEach(r,function(n){e=n.call(i,e,t)}),e}});var si=h((sn,io)=>{"use strict";io.exports=function(e){return!!(e&&e.__CANCEL__)}});var no=h((ln,ao)=>{"use strict";var oo=P(),li=ro(),Ea=si(),_a=Se(),Ca=ve();function pi(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Ca("canceled")}ao.exports=function(e){pi(e),e.headers=e.headers||{},e.data=li.call(e,e.data,e.headers,e.transformRequest),e.headers=oo.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),oo.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||_a.adapter;return t(e).then(function(i){return pi(e),i.data=li.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Ea(i)||(pi(e),i&&i.response&&(i.response.data=li.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ci=h((pn,so)=>{"use strict";var R=P();so.exports=function(e,t){t=t||{};var r={};function i(l,c){return R.isPlainObject(l)&&R.isPlainObject(c)?R.merge(l,c):R.isPlainObject(c)?R.merge({},c):R.isArray(c)?c.slice():c}function a(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function n(l){if(!R.isUndefined(t[l]))return i(void 0,t[l])}function s(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var m={url:n,method:n,data:n,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:p};return R.forEach(Object.keys(e).concat(Object.keys(t)),function(c){var f=m[c]||a,L=f(c);R.isUndefined(L)&&f!==p||(r[c]=L)}),r}});var mi=h((cn,lo)=>{lo.exports={version:"0.24.0"}});var mo=h((mn,co)=>{"use strict";var Oa=mi().version,ui={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){ui[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var po={};ui.transitional=function(e,t,r){function i(a,n){return"[Axios v"+Oa+"] Transitional option '"+a+"'"+n+(r?". "+r:"")}return function(a,n,s){if(e===!1)throw new Error(i(n," has been removed"+(t?" in "+t:"")));return t&&!po[n]&&(po[n]=!0,console.warn(i(n," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,n,s):!0}};function xa(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],n=e[a];if(n){var s=o[a],p=s===void 0||n(s,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}co.exports={assertOptions:xa,validators:ui}});var Mo=h((un,yo)=>{"use strict";var uo=P(),Aa=ei(),ho=Ci(),fo=no(),je=ci(),go=mo(),ee=go.validators;function Te(o){this.defaults=o,this.interceptors={request:new ho,response:new ho}}Te.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=je(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&go.assertOptions(t,{silentJSONParsing:ee.transitional(ee.boolean),forcedJSONParsing:ee.transitional(ee.boolean),clarifyTimeoutError:ee.transitional(ee.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(i=i&&f.synchronous,r.unshift(f.fulfilled,f.rejected))});var a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});var n;if(!i){var s=[fo,void 0];for(Array.prototype.unshift.apply(s,r),s=s.concat(a),n=Promise.resolve(e);s.length;)n=n.then(s.shift(),s.shift());return n}for(var p=e;r.length;){var m=r.shift(),l=r.shift();try{p=m(p)}catch(c){l(c);break}}try{n=fo(p)}catch(c){return Promise.reject(c)}for(;a.length;)n=n.then(a.shift(),a.shift());return n};Te.prototype.getUri=function(e){return e=je(this.defaults,e),Aa(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};uo.forEach(["delete","get","head","options"],function(e){Te.prototype[e]=function(t,r){return this.request(je(r||{},{method:e,url:t,data:(r||{}).data}))}});uo.forEach(["post","put","patch"],function(e){Te.prototype[e]=function(t,r,i){return this.request(je(i||{},{method:e,url:t,data:r}))}});yo.exports=Te});var bo=h((dn,wo)=>{"use strict";var Ba=ve();function te(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(n){t.subscribe(n),i=n}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new Ba(i),e(t.reason))})}te.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};te.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};te.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};te.source=function(){var e,t=new te(function(i){e=i});return{token:t,cancel:e}};wo.exports=te});var Io=h((hn,Po)=>{"use strict";Po.exports=function(e){return function(r){return e.apply(null,r)}}});var Fo=h((fn,Ro)=>{"use strict";Ro.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var To=h((gn,di)=>{"use strict";var vo=P(),Na=Wr(),Xe=Mo(),La=ci(),Ga=Se();function So(o){var e=new Xe(o),t=Na(Xe.prototype.request,e);return vo.extend(t,Xe.prototype,e),vo.extend(t,e),t.create=function(i){return So(La(o,i))},t}var x=So(Ga);x.Axios=Xe;x.Cancel=ve();x.CancelToken=bo();x.isCancel=si();x.VERSION=mi().version;x.all=function(e){return Promise.all(e)};x.spread=Io();x.isAxiosError=Fo();di.exports=x;di.exports.default=x});var re=h((yn,Eo)=>{Eo.exports=To()});var fi=Fe(re());var hi=o=>{let e=250,t=[],r=0;return t[r]=[],o.forEach(i=>{t[r].length<=e?t[r].push(i):(r++,t[r]=[i])}),t},Ke=o=>{let e=[],t=200;for(;o.length>t;){let r=o.splice(0,t);e.push(r)}return e.push(o),e},A=(o,e)=>{let t="";return o==="prod"||o==="sandbox"?t={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"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t},D=o=>o.filter((t,r,i)=>r===i.indexOf(t));var Ye=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[]};var We=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Ye;return t.avatar=e.avatar,t.birthDate=e.birth_date,t.country=e.country,t.gender=e.gender,t.id=e.id,t.interests=e.interests,t.name=e.name,t}};var ze=class{nextPageStartsAfter=null;itemsPerPage=null};var ie=class{pagination=new ze};var g=class{meta=new ie;data=[]};var Qe=class{avatar=null;followingId=null;name=null;profileId=null};var Je=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapResponse(r)),t};remapResponse=e=>{let t=new Qe;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ze=class{avatar=null;followerId=null;name=null;profileId=null};var et=class{followersFromResponse=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapResponse(r)),t};remapResponse=e=>{let t=new Ze;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ee=class{profile_ids=[]};var Ua="/countries",T="/profile",_o="/profiles",tt=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=A(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=fi.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(r=>r,r=>{Promise.reject(r)}),this.instanceAuth.interceptors.response.use(r=>r,r=>{let i=r.config;if((r.response.status===403||r.response.status===401)&&!i._retry){i._retry=!0;let a=e.authProvider.getIdToken();return i.headers.Authorization=`Bearer ${a}`,this.instanceAuth(i)}return Promise.reject(r)}),this.instance=fi.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new We,this.followingRemapper=new Je,this.followersRemapper=new et}getCountries=async e=>{try{let t=`${Ua}${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${T}${this.apiSignInUrl}`;if(e){t=`${_o}/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let r=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn("There was a problem fetching your profile from API:",r),r.response}};getProfiles=async(e,t)=>{try{let r=`${_o}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.profileRemapper.profilesFromResponse(a.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,r),r.response}};getFollowers=async(e,t)=>{let r=`${T}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${T}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${T}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${T}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${T}/following${this.apiSignInUrl}`;if(e&&!t){r=`${T}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${T}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${T}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new Ee;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${T}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new Ee;t.profile_ids=e;try{return await this.instanceAuth.delete(`${T}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${T}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var G={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Co="FansUnited",Oo={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},V=class{idSchema="";exparationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=G[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=G[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=G[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=G[t],i={};return Object.keys(e).forEach(a=>{let n=e[a],p=this.getEntity(n,a,t).map(l=>l[r]),m=e[a].filter(l=>!p.includes(l));i[a]=n.map(l=>m.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=G[r],a=G[t],n={};return Object.keys(e).forEach(s=>{let p=e[s],m=[];this.getData().football.ids.forEach(l=>{p.forEach((c,f)=>{c===l[a]&&s===l.resource&&(m[f]=l[i])})}),n[s]=m}),n};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.exparationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData();t.football.competitions.push(...e),this.setData(t)};getExparationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Co));setData=e=>{localStorage.setItem(Co,JSON.stringify(e))}};var xo=Fe(re());var _e={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},rt=class{instance=null;apiSignInUrl="";constructor(e){let t=A(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=xo.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${_e[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((n,s)=>n.localeCompare(s));let a=hi(t).map(n=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${n.join(",")}`)}catch(s){throw console.warn(`There was a problem with id mapping request for the following ids:${n.join(",")}`,s),s.response}});return Promise.all(a).then(n=>{let s=[];return n.forEach(p=>{s.push(...p.data.data)}),s})};getEntitiesByIdObjs=async(e,t)=>{let r=[],i={},a=[];Object.keys(e).forEach(m=>{r.push.apply(r,e[m])});let n=D(r),s=hi(n);for(let m of s){let l="";if(Object.keys(e).forEach(c=>{i[c]=[];let f=m.filter(L=>e[c].includes(L));f&&f.length>0&&(i[c]=f)}),Object.keys(i).forEach(c=>{i[c].length>0&&(i[c].sort((f,L)=>f.localeCompare(L)),l+="&",l+=`${_e[c]}=${i[c].join(",")}`)}),l&&l.length>0)try{let c=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${l}`);a.push(c.data.data)}catch(c){throw console.warn("There was a problem with id mapping request",c),c.response}else a.push([])}return Array.prototype.concat.apply([],a)}};var it=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new V(e),this.https=new rt(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),n=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(n),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(n=>n.resource===a).map(n=>n[G[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var ot=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 at=class{extractedObjIds={};traverse=(e,t)=>(t=ot(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var nt=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=ot(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var E=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new it(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new at().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(n=>new nt().traverse(r,t,n))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var F=class{completed=!1;percentage;constructor(e){this.percentage=e}};var st=class{teamFollowed=new F(10);teamFavourite=new F(15);playerFollowed=new F(10);playerFavourite=new F(10);competitionFollowed=new F(10);competitionFavourite=new F(5);addedBirthdate=new F(10);addedGender=new F(10);addedCountry=new F(10);addedAvatar=new F(10)};var lt=class{totalPercentage;breakdown=new st};var Oe=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var $=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExparationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.https.getProfiles(e,t)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,r),r}};getById=async e=>{try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let r=await this.https.getCountries(e);return this.localStorage.setProfileCountries(r),r}catch(r){throw console.warn("There was a problem retrieving profile countries: ",r),r}}else try{return await this.https.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{return e&&(e=new Oe(e)),await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return e&&(e=new Oe(e)),await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new lt,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var pt=class{id=null;name=null;assets=null};var ct=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let r=await this.https.getCountries(e);return this.localStorage.setFootballCountries(r),r}catch(r){throw console.warn("There was a problem retrieving countries as football entities",r),r}}else return this.https.getCountries(e)}};var mt=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(r=>{let i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(n=>r.id===n):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var ut=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new mt(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");a.competition.length===0&&(r=!0),e.competitionIds=a.competition}if(r)return[]}let i=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(i,"competition")}catch(r){throw console.warn("There was a problem browsing all of the competitions",r),r}};getCompetitions=async(e,t)=>{if(t=t||!1,this.isBrowser){let r=this.localStorage.getCompetitions(e);if(r&&r.length>0)return r;try{let i=await this.https.getCompetitions(e,t);return this.localStorage.setCompetitions(i),this.localStorage.getCompetitions(e)}catch(i){throw console.warn("There was a problem retrieving all competitions",i),i}}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let i=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],a=await this.getCompetitionById(i,t);return await this.idMapping.remapEntities(a,"competition")}catch(r){throw console.warn(`There was a problem browsing the following competition:${e}`,r),r}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,r),r}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var dt=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var ht=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new dt(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");a.competition.length===0&&(r=!0),e.scope=a.competition}if(e.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");a.team.length===0&&(r=!0),e.teamIds=a.team}}if(r)return[];let i=await this.getTeams(e,t);return i.data=await this.idMapping.remapEntities(i.data,"team"),i}catch(r){throw console.warn("There was a problem browsing all teams",r),r}};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(r){throw console.warn("There was a problem retrieving all teams",r),r}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getTeamById(e,t);return await this.idMapping.remapEntities(i,"team")}catch(r){throw console.warn(`There was a problem browsing the following team:${e}`,r),r}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following team: ${e}`,r),r}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,r),r}};getNextMatchForTeam=async(e,t)=>{try{return t=t||!1,await this.https.getNextMatchForTeam(e,t)}catch(r){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,r),r}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,r),r}};getPrevMatchForTeam=async(e,t)=>{try{return t=t||!1,await this.https.getPrevMatchForTeam(e,t)}catch(r){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,r),r}}};var xe=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var H=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new xe(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");a.player.length===0&&(r=!0),e.playerIds=a.player}if(e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");a.competition.length===0&&(r=!0),e.scope=a.competition}if(r)return[]}let i=await this.getPlayers(e,t);return i.data=await this.idMapping.remapEntities(i.data,"player"),i}catch(r){throw console.warn("There was a problem browsing the players",r),r}};getPlayersWithNativeIds=async e=>{let t=new xe({playerIds:e}),r=await this.getPlayers(t);return r.data.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},r=D(e);r.sort((a,n)=>a.localeCompare(n));let i=await this.getPlayersWithNativeIds(r);return r.forEach((a,n)=>t[a]=i[n]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(r){throw console.warn("There was a problem retrieving the players",r),r}};getPlayerIdMapping=async(e,t)=>{try{let r=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),i=await this.getPlayerById(r.player[0],t);return await this.idMapping.remapEntities(i,"player")}catch(r){throw console.warn(`There was a problem browsing the following player:${e}`,r),r}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following player: ${e}`,r),r}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let i=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the next match for player:${e}`,r),r}};getNextMatchForPlayer=async(e,t)=>{try{return t=t||!1,await this.https.getNextMatchForPlayer(e,t)}catch(r){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,r),r}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let i=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the previous match for player:${e}`,r),r}};getPrevMatchForPlayer=async(e,t)=>{try{return t=t||!1,await this.https.getPrevMatchForPlayer(e,t)}catch(r){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,r),r}}};var Ae=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var k=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Ae(e),e.countryIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=i.country}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=i.competition}if(e.matchIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=i.match}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=i.team}}let r=await this.getMatches(e,t);return r.data=await this.idMapping.remapEntities(r.data,"match"),r}catch(r){throw console.warn("There was a problem browsing the matches",r),r}};getMatchesWithNativeIds=async e=>{let t=new Ae({matchIds:e}),r=await this.getMatches(t);return r.data.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},r=D(e);r.sort((a,n)=>a.localeCompare(n));let i=await this.getMatchesWithNativeIds(r);return r.forEach((a,n)=>t[a]=i[n]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(r){throw console.warn("There was a problem retrieving the matches",r),r}};getMatchIdMapping=async(e,t)=>{try{let r=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),i=await this.getMatchById(r.match[0],t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the following match: ${e}`,r),r}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following match: ${e}`,r),r}}};var ft=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var gt=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new ft(e),e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=i.competition}let r=await this.search(e,t);if(r.teams&&r.teams.length>0){let i=await this.idMapping.remapEntities(r.teams,"team");r.teams=i}if(r.players&&r.players.length>0){let i=await this.idMapping.remapEntities(r.players,"player");r.players=i}if(r.competitions&&r.competitions.length>0){let i=await this.idMapping.remapEntities(r.competitions,"competition");r.competitions=i}return r}catch(r){throw console.warn("There was a problem with browsing the search result",r),r}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(r){throw console.warn("There was a problem retrieving the search response",r),r}}};var q=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new ct(e,t,r),this.competitionsFacade=new ut(e,t,r),this.teamsFacade=new ht(t,r),this.playerFacade=new H(t,r),this.matchFacade=new k(t,r),this.searchFacade=new gt(t,r)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var oe=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},i={};e.forEach(s=>{r.hasOwnProperty(s.type)||(r[s.type]=[],i[s.type]=[]),r[s.type].push(s.id),i[s.type].push(s)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),n=[];for(let[s,p]of Object.entries(i))p.forEach((m,l)=>{m.id=a[s][l],n.push(m)});return n}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=n[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a.data[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a.data[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t};updateInterests=(e,t)=>{if(e.length===t.length){let r=t.filter(a=>e.some(n=>a.id===n.id&&a.type===n.type&&a.source===n.source&&a.favourite===n.favourite)),i=t.filter(a=>!e.some(n=>a.id===n.id&&a.type===n.type&&a.source===n.source&&a.favourite===n.favourite));return[...r,...i]}else return t}};var yt=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new q(e,i,r),this.interestsService=new oe(r,this.footballFacade),this.profileFacade=new $(e,t)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};extractUpdatedProps=(e,t)=>{let r={};return Object.keys(e).forEach(i=>{i==="gender"&&e[i]!==t[i]?r[i]=t[i]:i==="birthDate"?(t[i]===null||e[i]===null&&t[i]||e[i]!==t[i])&&(r.birth_date=t[i]):i==="country"?t[i]===null?r.country_id=t[i]:(e[i]===null&&t[i]||e[i].id!==t[i].id)&&(r.country_id=t[i].id):i==="interests"&&t[i]&&t[i].length>0&&(r[i]=this.interestsService.updateInterests(e[i],t[i]))}),r};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(i=>i.id!==t.id||i.type!==t.type||i.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new pt,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),r=this.extractUpdatedProps(e,t),i=await this.profileHttps.updateProfile(r);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(i),delete i.interests,i}};var Mt=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new oe(r,i),this.profileFacade=new $(e,t)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)}};var Ao=Fe(re());var wt=class{id="";alias="";countryCode="";assets=null;name=""};var y=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new wt;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var bt=class{id="";country=null;gender="";assets=null;type="";name=""};var I=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new bt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Pt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var It=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var w=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new It;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Rt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new y,this.teamBasicRemapper=new w}fromResponse(e){try{let t=new Pt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Ft=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var vt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var St=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new vt;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Tt=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new y,this.competitionRemapper=new I,this.playerRemapper=new St}fromResponse(e){try{let t=new Ft;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Et=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var _t=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var ae=class{fromResponse(e){try{let t=new _t;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Ct=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new w,this.competitionRemapper=new I,this.scoresRemapper=new ae}fromResponse(e){try{let t=new Et;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Ot=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var xt=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var At=class{fromResponse(e){try{let t=new xt;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var ne=class{homeTeam={players:[]};awayTeam={players:[]}};var Bt=class{id="";name="";position="";shirtNumber;assets=null;type=""};var se=class{fromResponse(e){try{let t=new Bt;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var Nt=class{playerRemapper=null;constructor(){this.playerRemapper=new se}fromResponse(e){try{let t=new ne;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var Lt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Gt=class{playerRemapper=null;constructor(){this.playerRemapper=new se}fromResponse(e){try{let t=new Lt;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var Ut=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new w,this.competitionsMapper=new I,this.lineupsMapper=new Nt,this.scoresMapper=new ae,this.statsMapper=new At,this.timelineMapper=new Gt}fromResponse(e){try{let t=new Ot;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new ne,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Dt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Vt=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new Dt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var $t=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var le=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new w}fromResponse(e){try{let t=new $t;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Ht=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var kt=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new w,this.competitionRemapper=new I}fromResponse(e){try{let t=new Ht;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var qt=class{teams=null;players=null;competitions=null};var jt=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new w,this.playerRemapper=new le,this.competitionremapper=new I}fromResponse(e){try{let t=new qt;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Xt=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var pe=class{pagination=new Xt};var ce=class{meta=new pe;data=[]};var Kt=class{remapMetaProp=e=>{let t=new pe;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var B=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){let t=A(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=Ao.default.create({baseURL:t}),this.countryRemapper=new y,this.competitionBasicRemapper=new I,this.competitionFullRemapper=new Rt,this.teamBasicRemapper=new w,this.teamFullRemapper=new Tt,this.matchBasicRemapper=new Ct,this.matchFullRemapper=new Ut,this.playerBasicRemapper=new le,this.playerFullRemapper=new kt,this.topPlayerRemapper=new Vt,this.searchRemapper=new jt,this.footballMetaRemapper=new Kt}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,r=Date.now();e&&(t+=`&disable_cache=${r}`);let i=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(i.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let r={},i=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let a=[],n=Ke(e.competitionIds);for(let p of n){e.competitionIds=p;let m=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`&disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.competitionBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return e&&(a+=`${e.constructFilterUrl()}`),t&&(a+=`&disable_cache=${i}`),r=await this.instance.get(a),r.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n))}}catch(r){throw console.warn("There was a problem with getCompetitions request",r),r.response}};getCompetitionById=async(e,t)=>{try{let r=`/competitions/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.competitionFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getCompetitionById request",r),r.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data.map(a=>this.competitionBasicRemapper.fromResponse(a))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let r={},i=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let a=[],n=Ke(e.teamIds);for(let p of n){e.teamIds=p;let m=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=new ce,n=`/teams${this.apiSignInUrl}`;return e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`&disable_cache=${i}`),r=await this.instance.get(n),a.meta=this.footballMetaRemapper.remapMetaProp(r.data.meta),a.data=r.data.data.map(s=>this.teamBasicRemapper.fromResponse(s)),a}}catch(r){throw console.warn("There was a problem with getTeams request",r),r.response}};getTeamById=async(e,t)=>{try{let r=`/teams/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`disable_cache=${i}`);let a=await this.instance.get(r);return this.teamFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getTeamById request",r),r.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}`,r=Date.now();e&&(t+=`$disable_cache=${r}`);let i=await this.instance.get(t);return i.data.data?i.data.data.map(a=>this.teamBasicRemapper.fromResponse(a)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let r=`/teams/${e}/next-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getNextMatchForTeam request",r),r.response}};getPrevMatchForTeam=async(e,t)=>{try{let r=`/teams/${e}/previous-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPrevMatchForTeam request",r),r.response}};getPlayers=async(e,t)=>{try{let r={},i=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let a=[],n=Ke(e.playerIds);for(let p of n){e.playerIds=p;let m=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`&disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=new ce,n=`/players${this.apiSignInUrl}`;return e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`&disable_cache=${i}`),r=await this.instance.get(n),a.meta=this.footballMetaRemapper.remapMetaProp(r.data.meta),a.data=r.data.data.map(s=>this.playerBasicRemapper.fromResponse(s)),a}}catch(r){throw console.warn("There was a problem with getPlayers request",r),r.response}};getPlayerById=async(e,t)=>{try{let r=`/players/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.playerFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPlayerById request",r),r.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data.map(a=>this.topPlayerRemapper.fromResponse(a))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let r=`/players/${e}/next-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getNextMatchForPlayer request",r),r.response}};getPrevMatchForPlayer=async(e,t)=>{try{let r=`/players/${e}/previous-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPrevMatchForPlayer request",r),r.response}};getMatchById=async(e,t)=>{try{let r=`/matches/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getMatchById request",r),r.response}};getMatches=async(e,t)=>{try{let r=new ce,i=`/matches${this.apiSignInUrl}`,a=Date.now();e&&(i+=`${e.constructFilterUrl()}`),t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return r.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),r.data=n.data.data.map(s=>this.matchBasicRemapper.fromResponse(s)),r}catch(r){throw console.warn("There was a problem with getMatches request",r),r.response}};search=async(e,t)=>{try{let r=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.searchRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with search request",r),r.response}}};var Yt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new tt(e),this.footballHttps=new B(e),this.idMapping=new E(e),this.localStorage=new V(e),this.footballFacade=new q(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new $(this.localStorage,this.profileHttps),this.ownProfileBuilder=new yt(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new Mt(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var Wt=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var zt=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Qt=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var Jt=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Ne=class{getIdToken=null;logout=null};var de=class{text=null;type=null};var Zt=class{validation=null;message=new de;getIdToken={validation:null,message:new de};logout={validation:null,message:new de}};var er=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new Ne),r=new Zt;if(e){let a=Object.keys(e).filter(n=>!t.includes(n));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new Ne).forEach(i=>{e[i]?t[i].validation="valid":t[i].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Le=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Le,logout:new Le};isValid=!1};var rr=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var ir=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new tr,r={apiKey:new Qt,environment:new zt,idSchema:new Jt,clientId:new rr,lang:new Wt,authProvider:new er};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var or=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new B(e),this.idMapping=new E(e),this.localStorage=new V(e),this.footballFacade=new q(this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var bi=Fe(re());var ar=class{value=null;playerId=null;playerModel=null};var he=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ar;result=null};var nr=class{value=!1;playerId=null};var O=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new nr,this.prediction.value=r,this.prediction.playerId=i}};var fe=class{settledAt=null;resettledAt=null;status=null;outcome=null};var v=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(v||{}),Bo=["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"],No=["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"],gi=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var sr=class{value=null};var j=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new sr,this.prediction.value=t}};var _=class{value=!1};var ge=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new _,this.prediction.value=r}};var ye=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new _,this.prediction.value=r}};var lr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r){this.matchFacade=e,this.playerFacade=t,this.predictorService=r}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof O)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ge||e instanceof ye){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=Number(r[2])}else if(e instanceof j){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=Number(r[0]),t.goals_away=Number(r[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((s,p)=>s.match_id.localeCompare(p.match_id));let t=[],r=[];for(let s of e)t.push(s.match_id),s.player_id&&!r.includes(s.player_id)&&r.push(s.player_id);let i=await this.matchFacade.getMatchesMapWithNativeIds(t),a=[];r.sort((s,p)=>s.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let n=[];for(let s of e){let p=new he;s.target?p.market=this.predictorService.convertMarketForResponseModel(s.market,s.target):p.market=s.market,p.matchId=i[s.match_id].id,p.matchType=s.match_type,p.matchModel=i?i[s.match_id]:null,s.goals_home!==void 0&&s.goals_away!==void 0?p.prediction.value=s.goals_home.toString()+":"+s.goals_away.toString():p.prediction.value=s.prediction,p.prediction.playerId=s.player_id?s.player_id:null,p.prediction.playerId&&(p.prediction.playerModel=a[s.player_id],p.prediction.playerId=a[s.player_id].id),p.result=this.remapResult(s.result),n.push(p)}return n};remapResult=e=>{let t=new fe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var Me=class{goldenGoal=null};var Ge=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Me;points=null;createdAt=null;updatedAt=null};var u=class{no=0;yes=0};var we=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new u;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new u;penaltyMatch=new u;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new u;overOnePointFiveGoals=new u;overTwoPointFiveGoals=new u;overThreePointFiveGoals=new u;overFourPointFiveGoals=new u;overFivePointFiveGoals=new u;overSixPointFiveGoals=new u;overSixPointFiveCorners=new u;overSevenPointFiveCorners=new u;overEightPointFiveCorners=new u;overNinePointFiveCorners=new u;overTenPointFiveCorners=new u;overElevenPointFiveCorners=new u;overTwelvePointFiveCorners=new u;overThirteenPointFiveCorners=new u};var yi=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(yi||{}),Mi=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(Mi||{}),wi=(m=>(m.ONE_ONE="1/1",m.ONE_X="1/x",m.ONE_TWO="1/2",m.X_ONE="x/1",m.X_X="x/x",m.X_TWO="x/2",m.TWO_ONE="2/1",m.TWO_X="2/x",m.TWO_TWO="2/2",m))(wi||{});var pr=class{value=null};var cr=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pr,this.prediction.value=t}};var mr=class{value=null};var ur=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new mr,this.prediction.value=t}};var be=class{value=null};var dr=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new be,this.prediction.value=t}};var hr=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new be,this.prediction.value=t}};var fr=class{value};var gr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new fr,this.prediction.value=t}};var yr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var Mr=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var wr=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var W=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var z=class{userId=null;points=null;results=[];tiebreaker=null};var br=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(br||{}),Ue=["WON","LOST","PARTIALLY_WON","CANCELED"];var b=class{limit=null;startAfter=null;status=null;type=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(br).some(r=>this.status.includes(r))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),e}};var De=(n=>(n.OPEN="OPEN",n.LIVE="LIVE",n.PENDING="PENDING",n.CANCELED="CANCELED",n.CLOSED="CLOSED",n.SETTLED="SETTLED",n))(De||{});var S=class{limit=null;startAfter=null;status=null;type=null;gameIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&Object.values(De).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var Q=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var U=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var N=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new B(e),this.idMapping=t,this.matchFacade=new k(this.footballHttps,t),this.playerFacade=new H(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},r=D(e),a=(await this.idMapping.getEntityIdsBySchemaId(r,"player","native")).player;return r.forEach((n,s)=>t[n]=a[s]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let n={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new we),r=Object.values(v);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(yi),n=Object.values(wi),s=Object.values(Mi);if(t==="FT_1X2"){if(a.includes(r))return new dr(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new hr(e,r)}else if(t==="HT_FT"){if(n.includes(r))return new cr(e,r)}else if(t==="DOUBLE_CHANCE"){if(s.includes(r))return new ur(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new j(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new gr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new yr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new Mr(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new wr(e,r)}else if(gi.includes(t)){if(i&&typeof r=="boolean")return new O(e,t,r,i)}else if(Bo.includes(t)){if(typeof r=="boolean")return new ye(e,t,r)}else if(No.includes(t)&&typeof r=="boolean")return new ge(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return gi.includes(t)&&r?(a[i][r]||(a[i][r]=new u),a[i][r]):a};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],r=[];return e.data.forEach(i=>{i instanceof Q||i instanceof W||i instanceof U?(i.fixtures.forEach(a=>t.push(a.matchId)),i instanceof U&&i.fixtures.forEach(a=>{a.prediction.playerId&&r.push(a.prediction.playerId)})):i instanceof z&&i.results.forEach(a=>t.push(a.matchId))}),await this.refactorResponseArrModel(e,t,r)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,r)=>{let i=[],a=await this.matchFacade.getMatchesMapWithNativeIds(t),n={};return r.length>0&&(n=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.data.forEach(s=>{s instanceof Q||s instanceof W||s instanceof U?(s.fixtures.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id,s instanceof U&&p.prediction.playerId&&(p.prediction.playerModel=n[p.prediction.playerId],p.prediction.playerId=n[p.prediction.playerId].id)}),i.push(s)):s instanceof z&&(s.results.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id}),i.push(s))}),e.data=i,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(i=>{i.matchModel=r[i.matchId],i.matchId=r[i.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let r=[];return e.data.forEach(a=>r.push(a.predictionsCutoff)),e.data.sort((a,n)=>{let[s,p]=[a.predictionsCutoff,n.predictionsCutoff].map(m=>Math.abs(new Date(m)-t));return s-p})[0].id}else return e.data[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new b(t),t};initGameFilters=(e,t,r)=>{if(t&&r)return t.type=e,t.gameIds=r,t=new S(t),t;if(t&&!r)return t.type=e,t=new S(t),t;if(!t&&r){let i={type:e,gameIds:r};return i=new S(i),i}else{let i={type:e};return i=new S(i),i}};addPredictionProp=async(e,t)=>(t.data.forEach((r,i)=>{r.id===e[i].game_instance_id&&r.fixtures.forEach((a,n)=>{e[i].fixtures[n].goals_home!==void 0&&e[i].fixtures[n].goals_away!==void 0?a.prediction.value=e[i].fixtures[n].goals_home+":"+e[i].fixtures[n].goals_away:a.prediction.value=e[i].fixtures[n].prediction,e[i].fixtures[n].player_id?a.prediction.playerId=e[i].fixtures[n].player_id:e[i].fixtures[n].target&&(a.prediction.target=e[i].fixtures[n].target),a.prediction.result=this.remapResult(e[i].fixtures[n].result)})}),await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new fe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var Pe=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new j(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Ie=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new B(e),this.matchFacade=new k(this.footballHttps,t),this.playerFacade=new H(this.footballHttps,t),this.predictorService=new N(e,t),this.fixturesRemapper=new lr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),e instanceof Pe&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{let t=[],r=[],i={},a=[];e.forEach(s=>{s.fixtures.forEach(p=>{t.push(p.match_id),p.player_id&&r.push(p.player_id)})});let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return r.length>0&&(i=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(s=>{let p=new Ge,m=[];p.id=s.id,p.gameInstanceId=s.game_instance_id,p.gameType=s.game_type,p.wager=s.wager,p.totalFixtures=s.total_fixtures,p.settledFixtures=s.settled_fixtures,p.userId=s.user_id,s.fixtures.forEach(l=>{let c=new he;l.target?c.market=this.predictorService.convertMarketForResponseModel(l.market,l.target):c.market=l.market,c.matchId=n[l.match_id].id,c.matchType=l.match_type,c.matchModel=n[l.match_id],l.goals_home!==void 0&&l.goals_away!==void 0?c.prediction.value=l.goals_home.toString()+":"+l.goals_away.toString():c.prediction.value=l.prediction,c.prediction.playerId=l.player_id?l.player_id:null,c.prediction.playerId&&(c.prediction.playerModel=i[c.prediction.playerId],c.prediction.playerId=i[c.prediction.playerId].id),c.result=this.fixturesRemapper.remapResult(l.result),m.push(c)}),p.fixtures=m,p.status=s.status,s.tiebreaker?p.tiebreaker.goldenGoal=s.tiebreaker.golden_goal:p.tiebreaker=null,p.points=s.points,p.createdAt=s.created_at,p.updatedAt=s.updated_at,a.push(p)}),a};remapResponseObjBody=async e=>{let t=new Ge;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new we;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new u,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new u,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new u,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new u,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new u,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new u,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new u,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new u,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new u,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new u,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new u,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new u,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new u,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new u,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new u,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new u,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH?e.RED_CARD_MATCH:new u,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new u,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var Pr=class{matchId=null;matchType=null;predictions=null};var Ir=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new Ie(e,t)}remapResponse=e=>{let t=new Pr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var Rr=class{matchId=null;matchType=null;market=null;matchModel=null};var Fr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var vr=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Fr};var Sr=class{value=null;result=null};var Tr=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new Sr};var Er=class{matchId=null;matchModel=null;outcome=null};var _r=class{remapPaginatedGames=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapGamesListResponse(r)),t};remapGamesListResponse=e=>{let t=new Q;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new Rr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapUserTopXEditionsResponse(r)),t};remapUserTopXEditionsResponse=e=>{let t=new W;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapTopXFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new Tr;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapPaginatedUserMathQuizEditions=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapUserMatchQuizEditionsResponse(r)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new U;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapMatchQuizFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new vr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapGameResults(r)),t};remapGameResults=e=>{let t=new z;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new Er;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new Me;return t.goldenGoal=e.golden_goal,t}};var Cr=class{remapMetaData=e=>{let t=new ie;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var X=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){let r=A(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new Ie(e,t),this.matchSummaryRemapper=new Ir(e,t),this.gamesRemapper=new _r,this.metaRemapper=new Cr,this.instanceAuth=bi.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=bi.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new g,r=`/predictions${this.apiSignInUrl}`;e&&(r+=`${e.constructFiltersUrl()}`);let i=await this.instanceAuth.get(r);return t.meta=this.metaRemapper.remapMetaData(i.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(i.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,r)=>{try{let i=new g,a=`/predictions/users/${e}${this.apiSignInUrl}`,n=Date.now();r&&(a+=`${r.constructFiltersUrl()}`),t&&(a+=`&disable_cache=${n}`);let s=await this.instance.get(a);return i.meta=this.metaRemapper.remapMetaData(s.data.meta),i.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),i}catch(i){throw console.warn(`There was a problem fetching predictions for user: ${e}`,i),i.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data.data}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async(e,t)=>{try{let r=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.gamesRemapper.remapPaginatedGames(a.data)}catch(r){throw console.warn("There was a problem fetching the games list",r),r.response}};getGameById=async(e,t)=>{try{let r=`/games/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.gamesRemapper.remapGamesListResponse(a.data)}catch(r){throw console.warn(`There was a problem fetching the following game: ${e}`,r),r.response}};getUserGameEditions=async(e,t)=>{try{let r=null,i=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,a=Date.now();t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return n.data.data.forEach(s=>{s.type==="TOP_X"?r=this.gamesRemapper.remapPaginatedUserTopXEditions(n.data):s.type==="MATCH_QUIZ"&&(r=this.gamesRemapper.remapPaginatedUserMathQuizEditions(n.data))}),r}catch(r){throw console.warn("There was a problem fetching the games list",r),r.response}};getGameResults=async(e,t,r)=>{try{let i=`/games/${e}/results/${this.apiSignInUrl}`,a=Date.now();r&&(i+=`${r.constructFiltersUrl()}`),t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return this.gamesRemapper.remapPaginatedGameResults(n.data)}catch(i){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,i),i.response}}};var Or=class{fullCoverageCompetitions=null;markets=null};var xr=class{remapConfig=e=>{let t=new Or;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var Ar=class{gameInstanceId=null;fixtures=null};var Br=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new xr,this.predictorService=new N(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),n=new Ar;if(a)if(this.idMapping.idSchema!=="native"){let s=a.matchId,p="",m=await this.predictorService.remapMatchIdToNative([s]);if(a.matchId=m[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof O&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");n.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(n);return l.fixtures.map(c=>{c.prediction.playerId&&(c.prediction.playerId=p),c.matchId=s}),l}else return n.fixtures=[a],await this.predictorHttps.makeFootballPrediction(n);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,n=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=n,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>(e&&(e=new b(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new b(e);else{let t={status:["ACTIVE"]};e=new b(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=Ue,e=new b(e);else{let t={status:Ue};e=new b(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t,r)=>(r=r||!1,t&&(t=new b(t)),await this.predictorHttps.getUserPredictions(e,r,t));getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new b(t);else{let r={status:["ACTIVE"]};t=new b(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=Ue,t=new b(t);else{let r={status:Ue};t=new b(r)}return await this.getUserPredictions(e,t)}};var Lo=Fe(re());var Re=class{instance=null;apiSignInUrl="";constructor(e){let t=A(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Lo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var Nr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.predictorHttps=new X(e,this.idMapping),this.clientHttps=new Re(e),this.predictorFacade=new Br(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getUserPredictions=async(e,t,r)=>await this.predictorFacade.getUserPredictions(e,t,r);getUserCurrentPredictions=async(e,t)=>await this.predictorFacade.getUserCurrentPredictions(e,t);getUserPastPredictions=async(e,t)=>await this.predictorFacade.getUserPastPredictions(e,t)};var Lr=class{general=[];predictor=[];topX=[]};var Gr=class{enabled=!1;rewards=null};var Ur=class{general=null;topX=null;predictor=null};var Dr=class{points=null;tiers=null;badges=null};var Vr=class{remapLoyaltyResponse=e=>{let t=new Gr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Dr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Ur;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new Lr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var $r=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new Vr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Hr=class{https=null;loyaltyFacade=null;constructor(e){this.https=new Re(e),this.loyaltyFacade=new $r(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var kr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new X(e,t),this.predictorService=new N(e,t)}getGames=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameFilters("TOP_X",e),i=await this.predictorHttps.getGames(r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGameById=async(e,t)=>{t=t||!1;let r=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameResults=async(e,t,r)=>{r=r||!1,t&&(t=new S(t));let i=await this.predictorHttps.getGameResults(e,r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new S(t);let r=await this.predictorHttps.getGames(t,e),i=this.predictorService.getCurrentGameId(r);return(await this.getGameResults(i,null,e)).data[0]};play=async e=>{let t=new Pe(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(n=>i.push(n.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(n=>n.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),i=[],a=await this.predictorHttps.getMyPredictionsNoRemap(r);if(a.length>0){a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let n=this.predictorService.initGameFilters("TOP_X",e,i),s=await this.predictorHttps.getUserGameEditions(n,t);return await this.predictorService.addPredictionProp(a,s)}else return new g};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),r=await this.predictorHttps.getMyPredictions(t);return r.data.length>0?r.data.filter(a=>a.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("TOP_X"),a=[],n=await this.predictorHttps.getUserPredictionsNoRemap(e,i);if(n.length>0){n.forEach(m=>{m.game_instance_id&&a.push(m.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",t,a),p=await this.predictorHttps.getUserGameEditions(s,r);return await this.predictorService.addPredictionProp(n,p)}else return new g};getUserGamePrediction=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(e,r,i);return a.data.length>0?a.data.filter(s=>s.gameInstanceId===t)[0]:null}};var qr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.topXFacade=new kr(e,this.idMapping)}getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGameResults=async(e,t,r)=>await this.topXFacade.getGameResults(e,t,r);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,r)=>await this.topXFacade.getUserGameEditions(e,t,r);getUserGamePrediction=async(e,t,r)=>await this.topXFacade.getUserGamePrediction(e,t,r)};var jr=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.predictorHttps=new X(e,this.idMapping),this.predictorService=new N(e,this.idMapping)}play=async e=>{let t=e.fixtures.map(r=>this.predictorService.validateFixture(r.matchId,r.market,r.prediction.value,r.prediction.playerId));if(t){if(this.idMapping.idSchema!=="native"){let r=[],i=[];t.forEach(s=>{r.push(s.matchId),s instanceof O&&i.push(s.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(r),n={};i&&i.length>0&&(n=await this.predictorService.remapPlayerIdMapToNative(i)),t.forEach((s,p)=>{s.matchId=a[p],s instanceof O&&(s.prediction.playerId=n[s.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameFilters("MATCH_QUIZ",e),i=await this.predictorHttps.getGames(r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGameById=async(e,t)=>{t=t||!1;let r=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameResults=async(e,t,r)=>{r=r||!1,t&&(t=new S(t));let i=await this.predictorHttps.getGameResults(e,r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new S(t);let r=await this.predictorHttps.getGames(t,e),i=this.predictorService.getCurrentGameId(r);return(await this.getGameResults(i,null,e)).data[0]};getMyGameEditions=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=[],a=await this.predictorHttps.getMyPredictionsNoRemap(r);if(a.length>0){a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let n=this.predictorService.initGameFilters("MATCH_QUIZ",e,i),s=await this.predictorHttps.getUserGameEditions(n,t);return await this.predictorService.addPredictionProp(a,s)}else return new g};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),r=await this.predictorHttps.getMyPredictions(t);return r.data.length>0?r.data.filter(a=>a.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=[],n=await this.predictorHttps.getUserPredictionsNoRemap(e,i);if(n.length>0){n.forEach(m=>{m.game_instance_id&&a.push(m.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",t,a),p=await this.predictorHttps.getUserGameEditions(s,r);return await this.predictorService.addPredictionProp(n,p)}else return new g};getUserGamePrediction=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(e,r,i);return a.data.length>0?a.data.filter(s=>s.gameInstanceId===t)[0]:null}};var Xr=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new jr(e)}play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGameResults=async(e,t,r)=>await this.matchQuizFacade.getGameResults(e,t,r);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,r)=>await this.matchQuizFacade.getUserGameEditions(e,t,r);getUserGamePrediction=async(e,t,r)=>await this.matchQuizFacade.getUserGamePrediction(e,t,r)};function af(o){let t=new ir().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new Yt(o),football:new or(o),predictor:new Nr(o),loyalty:new Hr(o),topX:new qr(o),matchQuiz:new Xr(o)};throw new Error("Configuration is not valid")}export{af as FansUnitedSDK};
2
+ `),function(s){if(a=s.indexOf(":"),r=ii.trim(s.substr(0,a)).toLowerCase(),i=ii.trim(s.substr(a+1)),r){if(t[r]&&da.indexOf(r)>=0)return;r==="set-cookie"?t[r]=(t[r]?t[r]:[]).concat([i]):t[r]=t[r]?t[r]+", "+i:i}}),t}});var Wi=h((tn,Yi)=>{"use strict";var Ki=P();Yi.exports=Ki.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a"),r;function i(a){var n=a;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=i(window.location.href),function(n){var s=Ki.isString(n)?i(n):n;return s.protocol===r.protocol&&s.host===r.host}}():function(){return function(){return!0}}()});var ve=h((rn,zi)=>{"use strict";function oi(o){this.message=o}oi.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};oi.prototype.__CANCEL__=!0;zi.exports=oi});var ni=h((on,Qi)=>{"use strict";var ke=P(),ha=Li(),fa=Ui(),ga=ei(),ya=qi(),Ma=Xi(),wa=Wi(),ai=ri(),ba=Se(),Pa=ve();Qi.exports=function(e){return new Promise(function(r,i){var a=e.data,n=e.headers,s=e.responseType,p;function m(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}ke.isFormData(a)&&delete n["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";n.Authorization="Basic "+btoa(c+":"+f)}var L=ya(e.baseURL,e.url);l.open(e.method.toUpperCase(),ga(L,e.params,e.paramsSerializer),!0),l.timeout=e.timeout;function Pi(){if(!!l){var C="getAllResponseHeaders"in l?Ma(l.getAllResponseHeaders()):null,J=!s||s==="text"||s==="json"?l.responseText:l.response,K={data:J,status:l.status,statusText:l.statusText,headers:C,config:e,request:l};ha(function(Kr){r(Kr),m()},function(Kr){i(Kr),m()},K),l=null}}if("onloadend"in l?l.onloadend=Pi:l.onreadystatechange=function(){!l||l.readyState!==4||l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0)||setTimeout(Pi)},l.onabort=function(){!l||(i(ai("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){i(ai("Network Error",e,null,l)),l=null},l.ontimeout=function(){var J=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",K=e.transitional||ba.transitional;e.timeoutErrorMessage&&(J=e.timeoutErrorMessage),i(ai(J,e,K.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",l)),l=null},ke.isStandardBrowserEnv()){var Ii=(e.withCredentials||wa(L))&&e.xsrfCookieName?fa.read(e.xsrfCookieName):void 0;Ii&&(n[e.xsrfHeaderName]=Ii)}"setRequestHeader"in l&&ke.forEach(n,function(J,K){typeof a=="undefined"&&K.toLowerCase()==="content-type"?delete n[K]:l.setRequestHeader(K,J)}),ke.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),s&&s!=="json"&&(l.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(C){!l||(i(!C||C&&C.type?new Pa("canceled"):C),l.abort(),l=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),a||(a=null),l.send(a)})}});var Se=h((an,eo)=>{"use strict";var M=P(),Ji=xi(),Ia=ti(),Ra={"Content-Type":"application/x-www-form-urlencoded"};function Zi(o,e){!M.isUndefined(o)&&M.isUndefined(o["Content-Type"])&&(o["Content-Type"]=e)}function Fa(){var o;return typeof XMLHttpRequest!="undefined"?o=ni():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(o=ni()),o}function va(o,e,t){if(M.isString(o))try{return(e||JSON.parse)(o),M.trim(o)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(o)}var qe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Fa(),transformRequest:[function(e,t){return Ji(t,"Accept"),Ji(t,"Content-Type"),M.isFormData(e)||M.isArrayBuffer(e)||M.isBuffer(e)||M.isStream(e)||M.isFile(e)||M.isBlob(e)?e:M.isArrayBufferView(e)?e.buffer:M.isURLSearchParams(e)?(Zi(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):M.isObject(e)||t&&t["Content-Type"]==="application/json"?(Zi(t,"application/json"),va(e)):e}],transformResponse:[function(e){var t=this.transitional||qe.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&this.responseType==="json";if(a||i&&M.isString(e)&&e.length)try{return JSON.parse(e)}catch(n){if(a)throw n.name==="SyntaxError"?Ia(n,this,"E_JSON_PARSE"):n}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};M.forEach(["delete","get","head"],function(e){qe.headers[e]={}});M.forEach(["post","put","patch"],function(e){qe.headers[e]=M.merge(Ra)});eo.exports=qe});var ro=h((nn,to)=>{"use strict";var Sa=P(),Ta=Se();to.exports=function(e,t,r){var i=this||Ta;return Sa.forEach(r,function(n){e=n.call(i,e,t)}),e}});var si=h((sn,io)=>{"use strict";io.exports=function(e){return!!(e&&e.__CANCEL__)}});var no=h((ln,ao)=>{"use strict";var oo=P(),li=ro(),Ea=si(),_a=Se(),Ca=ve();function pi(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Ca("canceled")}ao.exports=function(e){pi(e),e.headers=e.headers||{},e.data=li.call(e,e.data,e.headers,e.transformRequest),e.headers=oo.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),oo.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var t=e.adapter||_a.adapter;return t(e).then(function(i){return pi(e),i.data=li.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Ea(i)||(pi(e),i&&i.response&&(i.response.data=li.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ci=h((pn,so)=>{"use strict";var R=P();so.exports=function(e,t){t=t||{};var r={};function i(l,c){return R.isPlainObject(l)&&R.isPlainObject(c)?R.merge(l,c):R.isPlainObject(c)?R.merge({},c):R.isArray(c)?c.slice():c}function a(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(e[l],t[l])}function n(l){if(!R.isUndefined(t[l]))return i(void 0,t[l])}function s(l){if(R.isUndefined(t[l])){if(!R.isUndefined(e[l]))return i(void 0,e[l])}else return i(void 0,t[l])}function p(l){if(l in t)return i(e[l],t[l]);if(l in e)return i(void 0,e[l])}var m={url:n,method:n,data:n,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:p};return R.forEach(Object.keys(e).concat(Object.keys(t)),function(c){var f=m[c]||a,L=f(c);R.isUndefined(L)&&f!==p||(r[c]=L)}),r}});var mi=h((cn,lo)=>{lo.exports={version:"0.24.0"}});var mo=h((mn,co)=>{"use strict";var Oa=mi().version,ui={};["object","boolean","number","function","string","symbol"].forEach(function(o,e){ui[o]=function(r){return typeof r===o||"a"+(e<1?"n ":" ")+o}});var po={};ui.transitional=function(e,t,r){function i(a,n){return"[Axios v"+Oa+"] Transitional option '"+a+"'"+n+(r?". "+r:"")}return function(a,n,s){if(e===!1)throw new Error(i(n," has been removed"+(t?" in "+t:"")));return t&&!po[n]&&(po[n]=!0,console.warn(i(n," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,n,s):!0}};function xa(o,e,t){if(typeof o!="object")throw new TypeError("options must be an object");for(var r=Object.keys(o),i=r.length;i-- >0;){var a=r[i],n=e[a];if(n){var s=o[a],p=s===void 0||n(s,a,o);if(p!==!0)throw new TypeError("option "+a+" must be "+p);continue}if(t!==!0)throw Error("Unknown option "+a)}}co.exports={assertOptions:xa,validators:ui}});var Mo=h((un,yo)=>{"use strict";var uo=P(),Aa=ei(),ho=Ci(),fo=no(),je=ci(),go=mo(),ee=go.validators;function Te(o){this.defaults=o,this.interceptors={request:new ho,response:new ho}}Te.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=je(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;t!==void 0&&go.assertOptions(t,{silentJSONParsing:ee.transitional(ee.boolean),forcedJSONParsing:ee.transitional(ee.boolean),clarifyTimeoutError:ee.transitional(ee.boolean)},!1);var r=[],i=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(e)===!1||(i=i&&f.synchronous,r.unshift(f.fulfilled,f.rejected))});var a=[];this.interceptors.response.forEach(function(f){a.push(f.fulfilled,f.rejected)});var n;if(!i){var s=[fo,void 0];for(Array.prototype.unshift.apply(s,r),s=s.concat(a),n=Promise.resolve(e);s.length;)n=n.then(s.shift(),s.shift());return n}for(var p=e;r.length;){var m=r.shift(),l=r.shift();try{p=m(p)}catch(c){l(c);break}}try{n=fo(p)}catch(c){return Promise.reject(c)}for(;a.length;)n=n.then(a.shift(),a.shift());return n};Te.prototype.getUri=function(e){return e=je(this.defaults,e),Aa(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};uo.forEach(["delete","get","head","options"],function(e){Te.prototype[e]=function(t,r){return this.request(je(r||{},{method:e,url:t,data:(r||{}).data}))}});uo.forEach(["post","put","patch"],function(e){Te.prototype[e]=function(t,r,i){return this.request(je(i||{},{method:e,url:t,data:r}))}});yo.exports=Te});var bo=h((dn,wo)=>{"use strict";var Ba=ve();function te(o){if(typeof o!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var t=this;this.promise.then(function(r){if(!!t._listeners){var i,a=t._listeners.length;for(i=0;i<a;i++)t._listeners[i](r);t._listeners=null}}),this.promise.then=function(r){var i,a=new Promise(function(n){t.subscribe(n),i=n}).then(r);return a.cancel=function(){t.unsubscribe(i)},a},o(function(i){t.reason||(t.reason=new Ba(i),e(t.reason))})}te.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};te.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};te.prototype.unsubscribe=function(e){if(!!this._listeners){var t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}};te.source=function(){var e,t=new te(function(i){e=i});return{token:t,cancel:e}};wo.exports=te});var Io=h((hn,Po)=>{"use strict";Po.exports=function(e){return function(r){return e.apply(null,r)}}});var Fo=h((fn,Ro)=>{"use strict";Ro.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var To=h((gn,di)=>{"use strict";var vo=P(),Na=Wr(),Xe=Mo(),La=ci(),Ga=Se();function So(o){var e=new Xe(o),t=Na(Xe.prototype.request,e);return vo.extend(t,Xe.prototype,e),vo.extend(t,e),t.create=function(i){return So(La(o,i))},t}var x=So(Ga);x.Axios=Xe;x.Cancel=ve();x.CancelToken=bo();x.isCancel=si();x.VERSION=mi().version;x.all=function(e){return Promise.all(e)};x.spread=Io();x.isAxiosError=Fo();di.exports=x;di.exports.default=x});var re=h((yn,Eo)=>{Eo.exports=To()});var fi=Fe(re());var hi=o=>{let e=250,t=[],r=0;return t[r]=[],o.forEach(i=>{t[r].length<=e?t[r].push(i):(r++,t[r]=[i])}),t},Ke=o=>{let e=[],t=200;for(;o.length>t;){let r=o.splice(0,t);e.push(r)}return e.push(o),e},A=(o,e)=>{let t="";return o==="prod"||o==="sandbox"?t={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"}[e]:t={profile:"http://localhost:8010",football:"http://locahost:8080",idMapping:"http://localhost:8030",predictor:"http://localhost:8040",client:"http://localhost:8080"}[e],t},D=o=>o.filter((t,r,i)=>r===i.indexOf(t));var Ye=class{id=null;name=null;avatar=null;gender=null;country=null;birthDate=null;interests=[];followingCount=0;followersCount=0};var We=class{profilesFromResponse=e=>e?e.map(t=>this.fullProfileFromResponse(t)):null;fullProfileFromResponse=e=>{let t=new Ye;return t.id=e.id,t.name=e.name,t.avatar=e.avatar,t.gender=e.gender,t.country=e.country,t.birthDate=e.birth_date,t.interests=e.interests,t.followingCount=e.following_count,t.followersCount=e.followers_count,t}};var ze=class{nextPageStartsAfter=null;itemsPerPage=null};var ie=class{pagination=new ze};var g=class{meta=new ie;data=[]};var Qe=class{avatar=null;followingId=null;name=null;profileId=null};var Je=class{followResponse=e=>e.map(t=>this.remapResponse(t));followingFromResponse=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapResponse(r)),t};remapResponse=e=>{let t=new Qe;return t.avatar=e.avatar,t.followingId=e.following_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ze=class{avatar=null;followerId=null;name=null;profileId=null};var et=class{followersFromResponse=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapResponse(r)),t};remapResponse=e=>{let t=new Ze;return t.avatar=e.avatar,t.followerId=e.follower_id,t.name=e.name,t.profileId=e.profile_id,t}};var Ee=class{profile_ids=[]};var Ua="/countries",T="/profile",_o="/profiles",tt=class{instanceAuth=null;instance=null;apiSignInUrl=null;profileRemapper=null;followingRemapper=null;followersRemapper=null;constructor(e){let t=A(e.environment,"profile");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}&lang=${e.lang}`,this.instanceAuth=fi.default.create({baseURL:t,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instanceAuth.interceptors.request.use(r=>r,r=>{Promise.reject(r)}),this.instanceAuth.interceptors.response.use(r=>r,r=>{let i=r.config;if((r.response.status===403||r.response.status===401)&&!i._retry){i._retry=!0;let a=e.authProvider.getIdToken();return i.headers.Authorization=`Bearer ${a}`,this.instanceAuth(i)}return Promise.reject(r)}),this.instance=fi.default.create({baseURL:t,headers:{"Content-Type":"application/json"}}),this.profileRemapper=new We,this.followingRemapper=new Je,this.followersRemapper=new et}getCountries=async e=>{try{let t=`${Ua}${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data}catch(t){throw console.warn("There was a problem fetching the countries:",t),t.response}};getProfile=async e=>{let t=`${T}${this.apiSignInUrl}`;if(e){t=`${_o}/${e}${this.apiSignInUrl}`;try{let r=await this.instance.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profile: ${e}`,r),r.response}}else try{let r=await this.instanceAuth.get(t);return this.profileRemapper.fullProfileFromResponse(r.data.data)}catch(r){throw console.warn("There was a problem fetching your profile from API:",r),r.response}};getProfiles=async(e,t)=>{try{let r=`${_o}${this.apiSignInUrl}&profile_ids=${e.join(",")}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.profileRemapper.profilesFromResponse(a.data.data)}catch(r){throw console.warn(`There was a problem fetching the following profiles: ${e.join(",")}`,r),r.response}};getFollowers=async(e,t)=>{let r=`${T}/followers${this.apiSignInUrl}`;if(e&&!t){r=`${T}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers for own profile",i),i.response}e&&t?r=`${T}/${t}/followers${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${T}/${t}/followers${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followersRemapper.followersFromResponse(i.data)}catch(i){throw console.warn(`There was a problem fetching the followers for profile: ${t}`,i),i.response}};getFollowing=async(e,t)=>{let r=`${T}/following${this.apiSignInUrl}`;if(e&&!t){r=`${T}/following${this.apiSignInUrl}${e.constructFilterUrl()}`;try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}}else if(!e&&!t)try{let i=await this.instanceAuth.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn("There was a problem fetching the followers of own profile",i),i.response}e&&t?r=`${T}/${t}/following${this.apiSignInUrl}${e.constructFilterUrl()}`:!e&&t&&(r=`${T}/${t}/following${this.apiSignInUrl}`);try{let i=await this.instance.get(r);return this.followingRemapper.followingFromResponse(i.data)}catch(i){throw console.warn(`There was a problem fetching the followers of the following profile: ${t}`,i),i.response}};follow=async e=>{let t=new Ee;t.profile_ids=e;try{let r=await this.instanceAuth.post(`${T}/follow${this.apiSignInUrl}`,JSON.stringify(t));return this.followingRemapper.followResponse(r.data.data)}catch(r){throw console.warn(`There was a problem with POST request for profiles: ${e.join(",")} `,r),r.response}};unfollow=async e=>{let t=new Ee;t.profile_ids=e;try{return await this.instanceAuth.delete(`${T}/follow${this.apiSignInUrl}`,{data:JSON.stringify(t)}),!0}catch(r){throw console.warn(`There was a problem with DELETE request for profiles: ${e.join(",")} `,r),r.response}};updateProfile=async e=>{try{let t=await this.instanceAuth.patch(`${T}${this.apiSignInUrl}`,e);return this.profileRemapper.fullProfileFromResponse(t.data.data)}catch(t){throw console.warn("There was a problem updating the own profile:",t),t.response}}};var G={native:"id",sportradar:"sportradar_id",sportal365:"sportal365_id",enetpulse:"enetpulse_id"};var Co="FansUnited",Oo={football:{ids:[],countries:[],competitions:[]},profile:{own:{},countries:[],expireAt:0}},V=class{idSchema="";expirationTimeout=600;constructor(e){this.idSchema=e.idSchema,(this.getData()===void 0||this.getData()===null)&&this.setData(Oo)}clearData=()=>{this.setData(Oo)};getEntityById=(e="",t="")=>this.getData().football.ids.find(r=>{let i=G[this.idSchema];return r&&`${r[i]}`===t&&r.resource===e});getEntity=(e,t,r)=>Array.isArray(e)?this.getData().football.ids.filter(i=>{let a=G[r];return i&&e.includes(`${i[a]}`)&&i.resource===t}):this.getData().football.ids.find(i=>{let a=G[r];return i&&`${i[a]}`===e&&i.resource===t});getEntityByNativeId=(e="",t="")=>this.getData().football.ids.find(r=>r&&`${r.id}`===t&&r.resource===e);checkForExistingIdObjs=(e,t)=>{let r=G[t],i={};return Object.keys(e).forEach(a=>{let n=e[a],p=this.getEntity(n,a,t).map(l=>l[r]),m=e[a].filter(l=>!p.includes(l));i[a]=n.map(l=>m.includes(l)?{id:l,exists:!1}:{id:l,exists:!0})}),i};getIdsByType=(e,t,r)=>{let i=G[r],a=G[t],n={};return Object.keys(e).forEach(s=>{let p=e[s],m=[];this.getData().football.ids.forEach(l=>{p.forEach((c,f)=>{c===l[a]&&s===l.resource&&(m[f]=l[i])})}),n[s]=m}),n};addIdMapping=e=>{let t=this.getData();t.football.ids.push(e),this.setData(t)};addIdMappings=e=>{let t=this.getData(),r=t.football.ids;r=[...r,...e],t.football.ids=r,this.setData(t)};setOwnProfile=e=>{let t=this.getData();t.profile.own=e,t.profile.expireAt=Math.floor(Date.now()/1e3)+this.expirationTimeout,this.setData(t)};getOwnProfile=()=>this.getData().profile.own;getProfileCountries=()=>this.getData().profile.countries;setProfileCountries=e=>{let t=this.getData();t.profile.countries=e,this.setData(t)};getFootballCountries=()=>this.getData().football.countries;setFootballCountries=e=>{let t=this.getData();t.football.countries=e,this.setData(t)};getCompetitions=e=>{let t=this.getData();return e?e.competitionSearchFilter(t.football.competitions):t.football.competitions};setCompetitions=e=>{let t=this.getData();t.football.competitions.push(...e),this.setData(t)};getExpirationProfile=()=>this.getData().profile.expireAt;getData=()=>JSON.parse(localStorage.getItem(Co));setData=e=>{localStorage.setItem(Co,JSON.stringify(e))}};var xo=Fe(re());var _e={player:"players",team:"teams",homeTeam:"teams",awayTeam:"teams",country:"countries",competition:"competitions",match:"matches"},rt=class{instance=null;apiSignInUrl="";constructor(e){let t=A(e.environment,"idMapping");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.instance=xo.default.create({baseURL:t})}getEntityById=(e,t)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${config.idSchema}&${_e[e]}=${t}`)}catch(r){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,r),r.response}};getEntityByIdAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${t}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following id:${t}`,i),i.response}};getEntityIdsByIdsAndSchema=(e,t,r)=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${t.join(",")}`)}catch(i){throw console.warn(`There was a problem with id mapping request for the following ids:${t.join(",")}`,i),i.response}};getEntitiesByIds=(e,t,r)=>{t.sort((n,s)=>n.localeCompare(s));let a=hi(t).map(n=>{try{return this.instance.get(`/football${this.apiSignInUrl}&input_provider=${r}&${_e[e]}=${n.join(",")}`)}catch(s){throw console.warn(`There was a problem with id mapping request for the following ids:${n.join(",")}`,s),s.response}});return Promise.all(a).then(n=>{let s=[];return n.forEach(p=>{s.push(...p.data.data)}),s})};getEntitiesByIdObjs=async(e,t)=>{let r=[],i={},a=[];Object.keys(e).forEach(m=>{r.push.apply(r,e[m])});let n=D(r),s=hi(n);for(let m of s){let l="";if(Object.keys(e).forEach(c=>{i[c]=[];let f=m.filter(L=>e[c].includes(L));f&&f.length>0&&(i[c]=f)}),Object.keys(i).forEach(c=>{i[c].length>0&&(i[c].sort((f,L)=>f.localeCompare(L)),l+="&",l+=`${_e[c]}=${i[c].join(",")}`)}),l&&l.length>0)try{let c=await this.instance.get(`/football${this.apiSignInUrl}&input_provider=${t||"native"}${l}`);a.push(c.data.data)}catch(c){throw console.warn("There was a problem with id mapping request",c),c.response}else a.push([])}return Array.prototype.concat.apply([],a)}};var it=class{isBrowser=!1;localStorage=null;https=null;constructor(e){this.isBrowser=typeof window!="undefined",this.localStorage=new V(e),this.https=new rt(e)}getEntitiesByIds=async(e,t,r)=>{if(this.isBrowser)try{let i=this.localStorage.checkForExistingIdObjs(e,t),a=this.splitForRequestAndExisting(i),n=await this.https.getEntitiesByIdObjs(a.request,t);return this.localStorage.addIdMappings(n),this.localStorage.getIdsByType(e,t,r)}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}else try{let i=await this.https.getEntitiesByIdObjs(e,t);return Object.keys(e).forEach(a=>{e[a]=i.filter(n=>n.resource===a).map(n=>n[G[r]])}),e}catch(i){return console.warn("There was a problem retrieving the entity ids ",i),Promise.resolve([])}};getEntityById=async(e,t,r)=>{if(this.isBrowser){let i=this.localStorage.getEntity(e,t,r);if(i)return i;{let a=await this.requestEntity(e,t,r);return this.localStorage.addIdMappings(a),a}}else return await this.requestEntity(e,t,r)};splitForRequestAndExisting=e=>{let t={},r={};return Object.keys(e).forEach(i=>{t[i]=e[i].filter(a=>!a.exists).map(a=>a.id),r[i]=e[i].filter(a=>a.exists).map(a=>a.id)}),{existing:r,request:t}};requestEntity=async(e,t,r)=>{try{return e=Array.isArray(e)?e:[e],await this.https.getEntitiesByIds(t,e,r)}catch(i){return console.warn(`There was a problem retrieving the requested entity: ${i}`),null}}};var ot=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 at=class{extractedObjIds={};traverse=(e,t)=>(t=ot(t),Array.isArray(e)?this.traverseArrExtract(e,t):e&&typeof e=="object"&&this.traverseObjExtract(e,t),this.extractedObjIds);traverseArrExtract=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjExtract(r,t)})};traverseObjExtract=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{let i=e[r];r==="id"||r==="teamId"?(this.extractedObjIds.hasOwnProperty(t)||(this.extractedObjIds[t]=[]),this.extractedObjIds[t].push(i)):e[r]&&this.traverse(e[r],r)})}};var nt=class{replaceObjIdsIndex=null;remappedIdsObj={};traverse=(e,t,r)=>(t=ot(t),this.replaceObjIdsIndex===null&&(this.initReplaceObjIdsIndex(r),this.remappedIdsObj=r),Array.isArray(e)?this.traverseArrReplace(e,t):e&&typeof e=="object"&&this.traverseObjReplace(e,t),e);initReplaceObjIdsIndex=e=>{this.replaceObjIdsIndex={},Object.keys(e).forEach(t=>{this.replaceObjIdsIndex[t]=0})};traverseArrReplace=(e,t)=>{e&&e.length>0&&e.forEach(r=>{this.traverseObjReplace(r,t)})};traverseObjReplace=(e,t)=>{e&&Object.keys(e).length>0&&Object.keys(e).forEach(r=>{r==="id"||r==="teamId"?(e[r]=this.remappedIdsObj[t][this.replaceObjIdsIndex[t]],this.replaceObjIdsIndex[t]=this.replaceObjIdsIndex[t]+1):e[r]&&this.traverse(e[r],r,this.remappedIdsObj)})}};var E=class{idSchema="";idMappingFacade=null;constructor(e){this.idSchema=e.idSchema,this.idMappingFacade=new it(e)}getEntityIdBySchemaId=(e,t)=>this.idMappingFacade.getEntityById(e,t,this.idSchema);remapEntities=async(e,t)=>{let r=JSON.parse(JSON.stringify(e));try{if(this.idSchema!=="native"){let a=new at().traverse(r,t);return this.idMappingFacade.getEntitiesByIds(a,"native",this.idSchema).then(n=>new nt().traverse(r,t,n))}else return e}catch(i){return console.warn(`There was a problem remapping entity: ${t} with inner entity `,i),[]}};getEntityIdsBySchemaId=async(e,t,r)=>{let i={};return i[t]=e,this.idSchema!=="native"?await this.idMappingFacade.getEntitiesByIds(i,this.idSchema,r):i}};var F=class{completed=!1;percentage;constructor(e){this.percentage=e}};var st=class{teamFollowed=new F(10);teamFavourite=new F(15);playerFollowed=new F(10);playerFavourite=new F(10);competitionFollowed=new F(10);competitionFavourite=new F(5);addedBirthdate=new F(10);addedGender=new F(10);addedCountry=new F(10);addedAvatar=new F(10)};var lt=class{totalPercentage;breakdown=new st};var Oe=class{limit=0;startAfter=null;constructor(e){this.limit=e.limit?e.limit:20,this.startAfter=e.startAfter?e.startAfter:null}constructFilterUrl=()=>{let e="";return this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.startAfter&&(e=e+"&",e=e+`start_after=${this.startAfter}`),e}};var $=class{isBrowser=!1;localStorage={};https=null;constructor(e,t){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.https=t}getOwn=async()=>{if(this.isBrowser){let e=Math.floor(Date.now()/1e3),t=this.localStorage.getExpirationProfile(),r=null;if(t>e&&(r=this.localStorage.getOwnProfile()),r)return r;try{let i=await this.https.getProfile();return this.localStorage.setOwnProfile(i),i}catch(i){throw console.warn("There was a problem retrieving your profile: ",i),i}}else try{return await this.https.getProfile()}catch(e){throw console.warn("There was a problem retrieving your profile: ",e),e}};getByIds=async(e,t)=>{try{return t=t||!1,await this.https.getProfiles(e,t)}catch(r){throw console.warn(`There was a problem retrieving the selected profiles: ${e.join(",")} `,r),r}};getById=async e=>{try{return await this.https.getProfile(e)}catch(t){throw console.warn(`There was a problem retrieving the selected profile: ${e} `,t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getProfileCountries();if(t&&t.length>0)return t;try{let r=await this.https.getCountries(e);return this.localStorage.setProfileCountries(r),r}catch(r){throw console.warn("There was a problem retrieving profile countries: ",r),r}}else try{return await this.https.getCountries(e)}catch(t){throw console.warn("There was a problem retrieving profile countries: ",t),t}};getFollowers=async(e,t)=>{try{return e&&(e=new Oe(e)),await this.https.getFollowers(e,t)}catch(r){throw console.warn("There was a problem retrieving your followers: ",r),r}};getFollowing=async(e,t)=>{try{return e&&(e=new Oe(e)),await this.https.getFollowing(e,t)}catch(r){throw console.warn("There was a problem retrieving your following profiles: ",r),r}};follow=async e=>{try{return await this.https.follow(e)}catch(t){throw console.warn(`There was a problem following profiles: ${e.join(",")} `,t),t}};unfollow=async e=>{try{return await this.https.unfollow(e)}catch(t){throw console.warn(`There was a problem unfollowing profiles: ${e.join(",")} `,t),t}};showFullnessProfile=e=>{let t=new lt,r=0;return e.avatar&&(t.breakdown.addedAvatar.completed=!0,r+=t.breakdown.addedAvatar.percentage),e.birthDate&&(t.breakdown.addedBirthdate.completed=!0,r+=t.breakdown.addedBirthdate.percentage),e.country&&(t.breakdown.addedCountry.completed=!0,r+=t.breakdown.addedCountry.percentage),e.gender&&(t.breakdown.addedGender.completed=!0,r+=t.breakdown.addedGender.percentage),e.interests&&e.interests.length>0&&(e.interests.find(l=>l.type==="team"&&l.favourite)&&(t.breakdown.teamFavourite.completed=!0,r+=t.breakdown.teamFavourite.percentage),e.interests.find(l=>l.type==="team")&&(t.breakdown.teamFollowed.completed=!0,r+=t.breakdown.teamFollowed.percentage),e.interests.find(l=>l.type==="player"&&l.favourite)&&(t.breakdown.playerFavourite.completed=!0,r+=t.breakdown.playerFavourite.percentage),e.interests.find(l=>l.type==="player")&&(t.breakdown.playerFollowed.completed=!0,r+=t.breakdown.playerFollowed.percentage),e.interests.find(l=>l.type==="competition"&&l.favourite)&&(t.breakdown.competitionFavourite.completed=!0,r+=t.breakdown.competitionFavourite.percentage),e.interests.find(l=>l.type==="competition")&&(t.breakdown.competitionFollowed.completed=!0,r+=t.breakdown.competitionFollowed.percentage)),t.totalPercentage=r,t}};var pt=class{id=null;name=null;assets=null};var ct=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCountriesWithIdMapping=async e=>{try{let t=await this.getCountries(e);return this.idMapping.remapEntities(t,"country")}catch(t){throw console.warn("There was a problem browsing countries as football entities",t),t}};getCountries=async e=>{if(e=e||!1,this.isBrowser){let t=this.localStorage.getFootballCountries();if(t&&t.length>0)return t;try{let r=await this.https.getCountries(e);return this.localStorage.setFootballCountries(r),r}catch(r){throw console.warn("There was a problem retrieving countries as football entities",r),r}}else return this.https.getCountries(e)}};var mt=class{countryId=null;name=null;gender=null;type=null;sortField=null;sortOrder=null;competitionIds=null;constructor(e){this.countryId=e.countryId?`${e.countryId}`:null,this.name=e.name?e.name:null,this.gender=e.gender?e.gender:null,this.type=e.type?e.type:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.competitionIds=e.competitionIds?e.competitionIds:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.type&&(e=e+"&",e=e+`type=${this.type}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.competitionIds&&(e=e+"&",e=e+`competition_ids=${this.competitionIds.join(",")}`),e};competitionSearchFilter=e=>{try{let t=this.filter(e);return this.sortField||this.sortOrder?this.sort(t):t}catch(t){return console.warn("There was a problem filtering the local competitions",t),[]}};filter=e=>{let t=this.entitiesToSearchWith();return e.filter(r=>{let i=!0;return t.forEach(a=>{a!=="sortOrder"&&a!=="sortField"&&(a==="countryId"?i&&=r.country.id===this[a]:a==="name"?i&&=r.name.toLocaleLowerCase().includes(this[a].toLocaleLowerCase()):a==="competitionIds"?i&&=this[a].some(n=>r.id===n):i&&=r[a].toLocaleLowerCase()===this[a].toLocaleLowerCase())}),i})};entitiesToSearchWith=()=>{let e=[];return this.countryId&&e.push("countryId"),this.name&&e.push("name"),this.gender&&e.push("gender"),this.type&&e.push("type"),this.sortField&&e.push("sortField"),this.sortOrder&&e.push("sortOrder"),this.competitionIds&&e.push("competitionIds"),e};sort=e=>{let t=[];return this.sortField==="name"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.name.localeCompare(r.name):r.name.localeCompare(i.name)):this.sortField==="countryId"?t=e.sort((r,i)=>this.sortOrder&&this.sortOrder==="desc"?i.country.id.localeCompare(r.country.id):r.country.id.localeCompare(i.country.id)):this.sortField==="scope"?e.forEach(r=>t[this.competitionIds.indexOf(r.id)]=r):!this.sortField&&this.sortOrder==="desc"&&(t=e.sort((r,i)=>i.id.localeCompare(r.id))),t}};var ut=class{isBrowser=!1;localStorage={};https=null;idMapping=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t}getCompetitionsIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new mt(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.competitionIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");a.competition.length===0&&(r=!0),e.competitionIds=a.competition}if(r)return[]}let i=await this.getCompetitions(e,t);return await this.idMapping.remapEntities(i,"competition")}catch(r){throw console.warn("There was a problem browsing all of the competitions",r),r}};getCompetitions=async(e,t)=>{if(t=t||!1,this.isBrowser){let r=this.localStorage.getCompetitions(e);if(r&&r.length>0)return r;try{let i=await this.https.getCompetitions(e,t);return this.localStorage.setCompetitions(i),this.localStorage.getCompetitions(e)}catch(i){throw console.warn("There was a problem retrieving all competitions",i),i}}else return this.https.getCompetitions(e,t)};getCompetitionByIdIdMapping=async(e,t)=>{try{let i=(await this.idMapping.getEntityIdsBySchemaId([e],"competition","native")).competition[0],a=await this.getCompetitionById(i,t);return await this.idMapping.remapEntities(a,"competition")}catch(r){throw console.warn(`There was a problem browsing the following competition:${e}`,r),r}};getCompetitionById=async(e,t)=>{try{return t=t||!1,await this.https.getCompetitionById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the competition with the following id: ${e}`,r),r}};getTopCompetitionsIdMapping=async e=>{try{let t=await this.getTopCompetitions(e);return await this.idMapping.remapEntities(t,"competition")}catch(t){throw console.warn("There was a problem browsing the top competitions",t),t}};getTopCompetitions=async e=>{try{return e=e||!1,await this.https.getTopCompetitions(e)}catch(t){throw console.warn("There was a problem retrieving the top competitions",t),t}}};var dt=class{name=null;countryId=null;national=!1;gender=null;limit=null;page=null;scope=null;sortField=null;sortOrder=null;teamIds=null;constructor(e){this.name=e.name?e.name:null,this.countryId=e.countryId?`${e.countryId}`:null,this.national=e.national?e.national:!1,this.gender=e.gender?e.gender:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.scope=e.scope?e.scope:null,this.sortField=e.sortField?`${e.sortField}`:null,this.sortOrder=e.sortOrder?`${e.sortOrder}`:null,this.teamIds=e.teamIds?e.teamIds:null}constructFilterUrl=()=>{let e="";return this.name&&(e=e+"&",e=e+`name=${this.name}`),this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.national&&(e=e+"&",e=e+`national=${this.national}`),this.gender&&(e=e+"&",e=e+`gender=${this.gender}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),this.teamIds&&(e=e+"&",e=e+`team_ids=${this.teamIds.join(",")}`),e}};var ht=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getTeamsIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new dt(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([`${e.countryId}`],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");a.competition.length===0&&(r=!0),e.scope=a.competition}if(e.teamIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");a.team.length===0&&(r=!0),e.teamIds=a.team}}if(r)return[];let i=await this.getTeams(e,t);return i.data=await this.idMapping.remapEntities(i.data,"team"),i}catch(r){throw console.warn("There was a problem browsing all teams",r),r}};getTeams=async(e,t)=>{try{return t=t||!1,await this.https.getTeams(e,t)}catch(r){throw console.warn("There was a problem retrieving all teams",r),r}};getTeamByIdIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getTeamById(e,t);return await this.idMapping.remapEntities(i,"team")}catch(r){throw console.warn(`There was a problem browsing the following team:${e}`,r),r}};getTeamById=async(e,t)=>{try{return t=t||!1,await this.https.getTeamById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following team: ${e}`,r),r}};getTopTeamsIdMapping=async e=>{try{let t=await this.getTopTeams(e);return await this.idMapping.remapEntities(t,"team")}catch(t){throw console.warn("There was a problem browsing the top teams",t),t}};getTopTeams=async e=>{try{return e=e||!1,await this.https.getTopTeams(e)}catch(t){throw console.warn("There was a problem retrieving the top teams",t),t}};getNextMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getNextMatchForTeam(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the next match for the following team:${e}`,r),r}};getNextMatchForTeam=async(e,t)=>{try{return t=t||!1,await this.https.getNextMatchForTeam(e,t)}catch(r){throw console.warn(`There was a problem retrieving the next match for the following team: ${e}`,r),r}};getPrevMatchForTeamIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"team","native")).team[0];let i=await this.getPrevMatchForTeam(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the previous match for the following team:${e}`,r),r}};getPrevMatchForTeam=async(e,t)=>{try{return t=t||!1,await this.https.getPrevMatchForTeam(e,t)}catch(r){throw console.warn(`There was a problem retrieving the previous match for the following team: ${e}`,r),r}}};var xe=class{countryId=null;scope=null;name=null;playerIds=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryId=e.countryId?e.countryId:null,this.scope=e.scope?e.scope:null,this.name=e.name?e.name:null,this.playerIds=e.playerIds?e.playerIds:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryId&&(e=e+"&",e=e+`country_id=${this.countryId}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),this.name&&(e=e+"&",e=e+`name=${this.name}`),this.playerIds&&(e=e+"&",e=e+`player_ids=${this.playerIds.join(",")}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var H=class{https=null;idMapping=null;constructor(e,t){this.idMapping=t,this.https=e}getPlayersIdMapping=async(e,t)=>{try{let r=!1;if(e){if(e=new xe(e),e.countryId){let a=await this.idMapping.getEntityIdsBySchemaId([e.countryId],"country","native");a.country.length===0&&(r=!0),e.countryId=a.country[0]}if(e.playerIds){let a=await this.idMapping.getEntityIdsBySchemaId(e.playerIds,"player","native");a.player.length===0&&(r=!0),e.playerIds=a.player}if(e.scope){let a=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");a.competition.length===0&&(r=!0),e.scope=a.competition}if(r)return[]}let i=await this.getPlayers(e,t);return i.data=await this.idMapping.remapEntities(i.data,"player"),i}catch(r){throw console.warn("There was a problem browsing the players",r),r}};getPlayersWithNativeIds=async e=>{let t=new xe({playerIds:e}),r=await this.getPlayers(t);return r.data.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r.data,"player")};getPlayersMapWithNativeIds=async e=>{let t={},r=D(e);r.sort((a,n)=>a.localeCompare(n));let i=await this.getPlayersWithNativeIds(r);return r.forEach((a,n)=>t[a]=i[n]),t};getPlayers=async(e,t)=>{try{return t=t||!1,await this.https.getPlayers(e,t)}catch(r){throw console.warn("There was a problem retrieving the players",r),r}};getPlayerIdMapping=async(e,t)=>{try{let r=await this.idMapping.getEntityIdsBySchemaId([e],"player","native"),i=await this.getPlayerById(r.player[0],t);return await this.idMapping.remapEntities(i,"player")}catch(r){throw console.warn(`There was a problem browsing the following player:${e}`,r),r}};getPlayerById=async(e,t)=>{try{return t=t||!1,await this.https.getPlayerById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following player: ${e}`,r),r}};getTopPlayersIdMapping=async e=>{try{let t=await this.getTopPlayers(e);return await this.idMapping.remapEntities(t,"player")}catch(t){throw console.warn("There was a problem browsing the top players",t),t}};getTopPlayers=async e=>{try{return e=e||!1,await this.https.getTopPlayers(e)}catch(t){throw console.warn("There was a problem retrieving the top players",t),t}};getNextMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let i=await this.getNextMatchForPlayer(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the next match for player:${e}`,r),r}};getNextMatchForPlayer=async(e,t)=>{try{return t=t||!1,await this.https.getNextMatchForPlayer(e,t)}catch(r){throw console.warn(`There was a problem retrieving the next match for player: ${e}`,r),r}};getPrevMatchForPlayerIdMapping=async(e,t)=>{try{e=(await this.idMapping.getEntityIdsBySchemaId([e],"player","native")).player[0];let i=await this.getPrevMatchForPlayer(e,t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the previous match for player:${e}`,r),r}};getPrevMatchForPlayer=async(e,t)=>{try{return t=t||!1,await this.https.getPrevMatchForPlayer(e,t)}catch(r){throw console.warn(`There was a problem retrieving the previous match for player: ${e}`,r),r}}};var Ae=class{countryIds=null;competitionIds=null;matchIds=null;status=null;teamIds=null;fromDate=null;toDate=null;limit=null;page=null;sortField=null;sortOrder=null;constructor(e){this.countryIds=e.countryIds?e.countryIds:null,this.competitionIds=e.competitionIds?e.competitionIds:null,this.matchIds=e.matchIds?e.matchIds:null,this.status=e.status?e.status:null,this.teamIds=e.teamIds?e.teamIds:null,this.fromDate=e.fromDate?e.fromDate:null,this.toDate=e.toDate?e.toDate:null,this.limit=e.limit?e.limit:null,this.page=e.page?e.page:null,this.sortField=e.sortField?e.sortField:null,this.sortOrder=e.sortOrder?e.sortOrder:null}constructFilterUrl=()=>{let e="";return this.countryIds&&(e=e+"&",e=e+`countries=${this.countryIds.join(",")}`),this.competitionIds&&(e=e+"&",e=e+`competitions=${this.competitionIds.join(",")}`),this.matchIds&&(e=e+"&",e=e+`matches=${this.matchIds.join(",")}`),this.status&&(e=e+"&",e=e+`status=${this.status}`),this.teamIds&&(e=e+"&",e=e+`teams=${this.teamIds.join(",")}`),this.fromDate&&(e=e+"&",e=e+`from_date=${this.fromDate}`),this.toDate&&(e=e+"&",e=e+`to_date=${this.toDate}`),this.limit&&(e=e+"&",e=e+`limit=${this.limit}`),this.page&&(e=e+"&",e=e+`page=${this.page}`),this.sortField&&(e=e+"&",e=e+`sort_field=${this.sortField}`),this.sortOrder&&(e=e+"&",e=e+`sort_order=${this.sortOrder}`),e}};var k=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}getMatchesIdMapping=async(e,t)=>{try{if(e){if(e=new Ae(e),e.countryIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.countryIds,"country","native");e.countryIds=i.country}if(e.competitionIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.competitionIds,"competition","native");e.competitionIds=i.competition}if(e.matchIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.matchIds,"match","native");e.matchIds=i.match}if(e.teamIds){let i=await this.idMapping.getEntityIdsBySchemaId(e.teamIds,"team","native");e.teamIds=i.team}}let r=await this.getMatches(e,t);return r.data=await this.idMapping.remapEntities(r.data,"match"),r}catch(r){throw console.warn("There was a problem browsing the matches",r),r}};getMatchesWithNativeIds=async e=>{let t=new Ae({matchIds:e}),r=await this.getMatches(t);return r.data.sort((i,a)=>i.id.localeCompare(a.id)),await this.idMapping.remapEntities(r.data,"match")};getMatchesMapWithNativeIds=async e=>{let t={},r=D(e);r.sort((a,n)=>a.localeCompare(n));let i=await this.getMatchesWithNativeIds(r);return r.forEach((a,n)=>t[a]=i[n]),t};getMatches=async(e,t)=>{try{return t=t||!1,await this.https.getMatches(e,t)}catch(r){throw console.warn("There was a problem retrieving the matches",r),r}};getMatchIdMapping=async(e,t)=>{try{let r=await this.idMapping.getEntityIdsBySchemaId([e],"match","native"),i=await this.getMatchById(r.match[0],t);return await this.idMapping.remapEntities(i,"match")}catch(r){throw console.warn(`There was a problem browsing the following match: ${e}`,r),r}};getMatchById=async(e,t)=>{try{return t=t||!1,await this.https.getMatchById(e,t)}catch(r){throw console.warn(`There was a problem retrieving the following match: ${e}`,r),r}}};var ft=class{entities=null;query=null;scope=null;constructor(e){this.entities=e.entities?e.entities:null,this.query=e.query?e.query:null,this.scope=e.scope?e.scope:null}constructFilterUrl=()=>{let e="";return this.entities&&(e=e+"&",e=e+`entities=${this.entities.join(",")}`),this.query&&(e=e+"&",e=e+`q=${this.query}`),this.scope&&(e=e+"&",e=e+`scope=${this.scope.join(",")}`),e}};var gt=class{https=null;idMapping=null;constructor(e,t){this.https=e,this.idMapping=t}searchIdMapping=async(e,t)=>{try{if(e=new ft(e),e.scope){let i=await this.idMapping.getEntityIdsBySchemaId(e.scope,"competition","native");e.scope=i.competition}let r=await this.search(e,t);if(r.teams&&r.teams.length>0){let i=await this.idMapping.remapEntities(r.teams,"team");r.teams=i}if(r.players&&r.players.length>0){let i=await this.idMapping.remapEntities(r.players,"player");r.players=i}if(r.competitions&&r.competitions.length>0){let i=await this.idMapping.remapEntities(r.competitions,"competition");r.competitions=i}return r}catch(r){throw console.warn("There was a problem with browsing the search result",r),r}};search=async(e,t)=>{try{return await this.https.search(e,t)}catch(r){throw console.warn("There was a problem retrieving the search response",r),r}}};var q=class{isBrowser=!1;localStorage={};https=null;idMapping=null;countriesFacade=null;competitionsFacade=null;teamsFacade=null;playerFacade=null;matchFacade=null;searchFacade=null;constructor(e,t,r){this.isBrowser=typeof window!="undefined",this.localStorage=e,this.idMapping=r,this.https=t,this.countriesFacade=new ct(e,t,r),this.competitionsFacade=new ut(e,t,r),this.teamsFacade=new ht(t,r),this.playerFacade=new H(t,r),this.matchFacade=new k(t,r),this.searchFacade=new gt(t,r)}getCountries=async e=>this.countriesFacade.getCountriesWithIdMapping(e);getCompetitions=async(e,t)=>this.competitionsFacade.getCompetitionsIdMapping(e,t);getCompetitionById=async(e,t)=>this.competitionsFacade.getCompetitionByIdIdMapping(e,t);getTopCompetitions=async e=>this.competitionsFacade.getTopCompetitionsIdMapping(e);getTeams=async(e,t)=>this.teamsFacade.getTeamsIdMapping(e,t);getTeamById=async(e,t)=>this.teamsFacade.getTeamByIdIdMapping(e,t);getTopTeams=async e=>this.teamsFacade.getTopTeamsIdMapping(e);getNextMatchForTeam=async(e,t)=>this.teamsFacade.getNextMatchForTeamIdMapping(e,t);getPrevMatchForTeam=async(e,t)=>this.teamsFacade.getPrevMatchForTeamIdMapping(e,t);getPlayers=async(e,t)=>this.playerFacade.getPlayersIdMapping(e,t);getPlayerById=async(e,t)=>this.playerFacade.getPlayerIdMapping(e,t);getTopPlayers=async e=>this.playerFacade.getTopPlayersIdMapping(e);getNextMatchForPlayer=async(e,t)=>this.playerFacade.getNextMatchForPlayerIdMapping(e,t);getPrevMatchForPlayer=async(e,t)=>this.playerFacade.getPrevMatchForPlayerIdMapping(e,t);getMatches=async(e,t)=>this.matchFacade.getMatchesIdMapping(e,t);getMatchById=async(e,t)=>this.matchFacade.getMatchIdMapping(e,t);search=async(e,t)=>this.searchFacade.searchIdMapping(e,t)};var oe=class{idMapping=null;footballFacade=null;constructor(e,t){this.idMapping=e,this.footballFacade=t}remapInterestsToIdSchema=async e=>{let t=this.idMapping.idSchema;if(t!=="native")if(e.length>0){let r={},i={};e.forEach(s=>{r.hasOwnProperty(s.type)||(r[s.type]=[],i[s.type]=[]),r[s.type].push(s.id),i[s.type].push(s)});let a=await this.idMapping.idMappingFacade.getEntitiesByIds(r,"native",t),n=[];for(let[s,p]of Object.entries(i))p.forEach((m,l)=>{m.id=a[s][l],n.push(m)});return n}else return e;else return e};remapInterestToNative=async e=>{let t=this.idMapping.idSchema;if(t!=="native"){let r={},{id:i,type:a}=e;r[a]=[i];let n=await this.idMapping.idMappingFacade.getEntitiesByIds(r,t,"native");return e.id=n[a][0],e}return e};inquiryCustomInterests=async e=>{let t=[];if(e&&e.length>0&&(t=e.filter(r=>r.source==="custom")),t&&t.length>0){let r=e.filter(a=>a.source!=="custom"),i=await this.remapInterestsToIdSchema(r);return t.forEach(a=>i.push(a)),i}return await this.remapInterestsToIdSchema(e)};showFullInterests=async e=>{let t=[];if(e&&e.length>0)for(let r of e)if(r.source!=="custom"&&r.source==="football"){let i={};if(r.type==="team"){i.teamIds=[r.id];let a=await this.footballFacade.getTeams(i);r.model=a.data[0]}if(r.type==="player"){i.playerIds=[r.id];let a=await this.footballFacade.getPlayers(i);r.model=a.data[0]}if(r.type==="competition"){i.competitionIds=[r.id];let a=await this.footballFacade.getCompetitions(i);r.model=a[0]}r.model===void 0&&(r.model=null),t.push(r)}else t.push(r);return t};updateInterests=(e,t)=>{if(e.length===t.length){let r=t.filter(a=>e.some(n=>a.id===n.id&&a.type===n.type&&a.source===n.source&&a.favourite===n.favourite)),i=t.filter(a=>!e.some(n=>a.id===n.id&&a.type===n.type&&a.source===n.source&&a.favourite===n.favourite));return[...r,...i]}else return t}};var yt=class{profileHttps=null;footballHttps=null;localStorage=null;idMapping=null;profileFacade=null;footballFacade=null;interestsService=null;ownProfile=null;modified=!1;expireAt=0;promises=[];isFetching=!1;constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballHttps=i,this.idMapping=r,this.footballFacade=new q(e,i,r),this.interestsService=new oe(r,this.footballFacade),this.profileFacade=new $(e,t)}getOwnProfile=async()=>{for(;this.isFetching;)console.log("Another thread is fetching profile..."),await this.delay(100);if(this.modified&&this.ownProfile)return console.log("Timestamp is less than 10 minutes OR profile is modifying "),this.ownProfile;let e=Math.floor(Date.now()/1e3);if(!this.ownProfile||this.expireAt<e){this.isFetching=!0,this.expireAt=Math.floor(Date.now()/1e3)+600;try{let t=await this.profileFacade.getOwn();this.setOwnProfile(t)}catch{this.isFetching=!1}return this.modified=!1,this.isFetching=!1,this.ownProfile}return this.ownProfile};delay=e=>new Promise(t=>{setTimeout(t,e)});setOwnProfile=e=>{this.ownProfile=e};extractUpdatedProps=(e,t)=>{let r={};return Object.keys(e).forEach(i=>{i==="gender"&&e[i]!==t[i]?r[i]=t[i]:i==="birthDate"?(t[i]===null||e[i]===null&&t[i]||e[i]!==t[i])&&(r.birth_date=t[i]):i==="country"?t[i]===null?r.country_id=t[i]:(e[i]===null&&t[i]||e[i].id!==t[i].id)&&(r.country_id=t[i].id):i==="interests"&&t[i]&&t[i].length>0&&(r[i]=this.interestsService.updateInterests(e[i],t[i]))}),r};getInfo=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return delete t.interests,t};showInterests=async()=>{let e=await this.getOwnProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e);getFollowing=async e=>await this.profileFacade.getFollowing(e);follow=async e=>await this.profileFacade.follow(e);unfollow=async e=>await this.profileFacade.unfollow(e);addInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e;let r=this.ownProfile.interests.filter(i=>i.id!==t.id||i.type!==t.type||i.source!==t.source);return this.ownProfile.interests=[...r],this.ownProfile.interests.push(t),this};addInterest=e=>(this.promises.push(this.addInterestPromise(e)),this);removeInterestPromise=async e=>{this.modified=!0,await this.getOwnProfile();let t=null;return e.source!=="custom"?t=await this.interestsService.remapInterestToNative(e):t=e,this.ownProfile.interests=this.ownProfile.interests.filter(r=>r.id!==t.id||r.type!==t.type||r.source!==t.source),this};removeInterest=e=>(this.promises.push(this.removeInterestPromise(e)),this);setBirthdatePromise=async e=>(this.modified=!0,await this.getOwnProfile(),e?this.ownProfile.birthDate=e:this.ownProfile.birthDate=null,this);setBirthdate=e=>(this.promises.push(this.setBirthdatePromise(e)),this);setGenderPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e==="male"||e==="female"?this.ownProfile.gender=e:this.ownProfile.gender="unspecified",this);setGender=e=>(this.promises.push(this.setGenderPromise(e)),this);setCountryPromise=async e=>(this.modified=!0,await this.getOwnProfile(),e&&!this.ownProfile.country?(this.ownProfile.country=new pt,this.ownProfile.country.id=e):e&&this.ownProfile.country?this.ownProfile.country.id=e:this.ownProfile.country=null,this);setCountry=e=>(this.promises.push(this.setCountryPromise(e)),this);showFullnessProfile=async()=>{let e=await this.getOwnProfile(),t=JSON.parse(JSON.stringify(e));return this.profileFacade.showFullnessProfile(t)};update=async()=>{if(this.promises.length===0)return this.ownProfile;await Promise.all(this.promises);let e=await this.profileFacade.getOwn(),t=await this.getOwnProfile(),r=this.extractUpdatedProps(e,t),i=await this.profileHttps.updateProfile(r);return this.modified=!1,this.expireAt=0,this.localStorage.setOwnProfile(i),delete i.interests,i}};var Mt=class{profileHttps=null;footballFacade=null;localStorage=null;idMapping=null;profileFacade=null;interestsService=null;profileId="";constructor(e,t,r,i){this.localStorage=e,this.profileHttps=t,this.footballFacade=i,this.idMapping=r,this.interestsService=new oe(r,i),this.profileFacade=new $(e,t)}setId=e=>(this.profileId=e,this);getProfile=async()=>await this.profileFacade.getById(this.profileId);getInfo=async()=>{let e=await this.getProfile();return delete e.interests,e};showInterests=async()=>{let e=await this.getProfile(),t=[];return t=e.interests,await this.interestsService.inquiryCustomInterests(t)};showFullInterests=async()=>{let e=await this.showInterests();return await this.interestsService.showFullInterests(e)};getFollowers=async e=>await this.profileFacade.getFollowers(e,this.profileId);getFollowing=async e=>await this.profileFacade.getFollowing(e,this.profileId);showFullnessProfile=async()=>{let e=await this.getProfile();return this.profileFacade.showFullnessProfile(e)}};var Ao=Fe(re());var wt=class{id="";alias="";countryCode="";assets=null;name=""};var y=class{countriesFromResponse=e=>{if(e)return e.map(t=>this.countryFromResponse(t))};countryFromResponse=e=>{try{if(e){let t=new wt;return t.id=e.id,t.alias=e.alias,t.assets=e.assets,t.countryCode=e.country_code,t.name=e.name,t}}catch(t){throw t}return null}};var bt=class{id="";country=null;gender="";assets=null;type="";name=""};var I=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new bt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Pt=class{id="";country=null;gender="";assets=null;type="";name="";participants=[]};var It=class{id="";country=null;gender="";assets=null;name="";code="";national=!1;fullName="";shortName=""};var w=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new It;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t}catch(t){throw console.warn("There was a problem remapping teams response",t),t}}};var Rt=class{countryRemapper=null;teamBasicRemapper=null;constructor(){this.countryRemapper=new y,this.teamBasicRemapper=new w}fromResponse(e){try{let t=new Pt;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.type=e.type,t.name=e.name,t.participants=e.participants.map(r=>this.teamBasicRemapper.fromResponse(r)),t}catch(t){throw console.warn("There was a problem remapping the competition response",t),t}}};var Ft=class{id="";country=null;gender="";assets=null;name="";competitions=[];code="";national=!1;fullName="";shortName="";squad=[]};var vt=class{id="";startDate="";endDate="";shirtNumber;loan=!1;position="";country=null;name="";assets=null;birthDate=""};var St=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new vt;return t.id=e.id,t.startDate=e.start_date,t.endDate=e.end_date,t.shirtNumber=e.shirt_number,t.loan=e.loan,t.position=e.position,t.country=this.countryRemapper.countryFromResponse(e.country),t.name=e.name,t.assets=e.assets,t.birthDate=e.birth_date,t}catch(t){throw console.warn("There was a problem remapping the player from squad",t),t}}};var Tt=class{countryRemapper=null;competitionRemapper=null;playerRemapper=null;constructor(){this.countryRemapper=new y,this.competitionRemapper=new I,this.playerRemapper=new St}fromResponse(e){try{let t=new Ft;return t.id=e.id,t.country=this.countryRemapper.countryFromResponse(e.country),t.gender=e.gender,t.assets=e.assets,t.code=e.code,t.national=e.national,t.fullName=e.full_name,t.shortName=e.short_name,t.name=e.name,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t.squad=e.squad?e.squad.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping team response",t),t}}};var Et=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;context={competition:null};status={type:null,subType:null}};var _t=class{ftScore=null;htScore=null;aetScore=null;aggScore=null;penScore=null};var ae=class{fromResponse(e){try{let t=new _t;return t.ftScore=this.statEntityFromResponse(e.ft_score),t.htScore=this.statEntityFromResponse(e.ht_score),t.aetScore=this.statEntityFromResponse(e.aet_score),t.aggScore=this.statEntityFromResponse(e.agg_score),t.penScore=this.statEntityFromResponse(e.pen_score),t}catch(t){throw console.warn("There was a problem remapping the scores",t),t}}statEntityFromResponse=e=>({homeGoals:e.home_goals,awayGoals:e.away_goals})};var Ct=class{teamRemapper=null;competitionRemapper=null;scoresRemapper=null;constructor(){this.teamRemapper=new w,this.competitionRemapper=new I,this.scoresRemapper=new ae}fromResponse(e){try{let t=new Et;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=this.teamRemapper.fromResponse(e.home_team),t.awayTeam=this.teamRemapper.fromResponse(e.away_team),t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresRemapper.fromResponse(e.scores),t.context={competition:e.context.competition?this.competitionRemapper.fromResponse(e.context.competition):null},t.status={type:e.status.type,subType:e.status.sub_type},t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Ot=class{id="";kickoffAt="";finishedAt="";updatedAt="";homeTeam=null;awayTeam=null;lineupsConfirmed=!1;startedAt="";minute="";scores=null;stats=null;context={competition:null};timeline=[];status={type:null,subType:null};lineups=null};var xt=class{corners=null;crosses=null;offside=null;shotsOn=null;throwIn=null;redCards=null;shotsOff=null;goalKicks=null;possession=null;treatments=null;yellowCards=null;shotsBlocked=null;substitutions=null;counterAttacks=null;foulsCommitted=null};var At=class{fromResponse(e){try{let t=new xt;return t.corners=this.statEntityFromResponse(e.corners),t.crosses=this.statEntityFromResponse(e.crosses),t.offside=this.statEntityFromResponse(e.offside),t.shotsOn=this.statEntityFromResponse(e.shots_on),t.throwIn=this.statEntityFromResponse(e.throw_in),t.redCards=this.statEntityFromResponse(e.red_cards),t.shotsOff=this.statEntityFromResponse(e.shots_off),t.goalKicks=this.statEntityFromResponse(e.goal_kicks),t.possession=this.statEntityFromResponse(e.possession),t.treatments=this.statEntityFromResponse(e.treatments),t.yellowCards=this.statEntityFromResponse(e.yellow_cards),t.shotsBlocked=this.statEntityFromResponse(e.shots_blocked),t.substitutions=this.statEntityFromResponse(e.substitutions),t.counterAttacks=this.statEntityFromResponse(e.counter_attacks),t.foulsCommitted=this.statEntityFromResponse(e.fouls_committed),t}catch(t){throw console.warn("There was a problem remapping the stats",t),t}}statEntityFromResponse=e=>({homeTeam:e?e.home_team:null,awayTeam:e?e.away_team:null})};var ne=class{homeTeam={players:[]};awayTeam={players:[]}};var Bt=class{id="";name="";position="";shirtNumber;assets=null;type=""};var se=class{fromResponse(e){try{let t=new Bt;return t.id=e.id,t.name=e.name,t.position=e.position,t.shirtNumber=e.shirt_number,t.assets=e.assets,t.type=e.type,t}catch(t){throw console.warn("There was a problem remapping the player from timeline",t),t}}};var Nt=class{playerRemapper=null;constructor(){this.playerRemapper=new se}fromResponse(e){try{let t=new ne;return t.homeTeam.players=e.home_team&&e.home_team.players?e.home_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.awayTeam.players=e.away_team&&e.away_team.players?e.away_team.players.map(r=>this.playerRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping the lineups",t),t}}};var Lt=class{minute="";type="";teamId="";player=null;relatedPlayer=null;updatedAt=""};var Gt=class{playerRemapper=null;constructor(){this.playerRemapper=new se}fromResponse(e){try{let t=new Lt;return t.minute=e.minute,t.type=e.type,t.teamId=e.team_id,t.player=this.playerRemapper.fromResponse(e.player),t.relatedPlayer=e.related_player?this.playerRemapper.fromResponse(e.related_player):null,t.updatedAt=e.updated_at,t}catch(t){throw console.warn("There was a problem remapping timeline",t),t}}};var Ut=class{teamMapper=null;competitionsMapper=null;lineupsMapper=null;scoresMapper=null;statsMapper=null;timelineMapper=null;constructor(){this.teamMapper=new w,this.competitionsMapper=new I,this.lineupsMapper=new Nt,this.scoresMapper=new ae,this.statsMapper=new At,this.timelineMapper=new Gt}fromResponse(e){try{let t=new Ot;return t.id=e.id,t.kickoffAt=e.kickoff_at,t.finishedAt=e.finished_at,t.updatedAt=e.updated_at,t.homeTeam=e.home_team?this.teamMapper.fromResponse(e.home_team):null,t.awayTeam=e.away_team?this.teamMapper.fromResponse(e.away_team):null,t.lineupsConfirmed=e.lineups_confirmed,t.startedAt=e.started_at,t.minute=e.minute,t.scores=this.scoresMapper.fromResponse(e.scores),t.stats=this.statsMapper.fromResponse(e.stats),t.context={competition:this.competitionsMapper.fromResponse(e.context.competition)},t.timeline=e.timeline?e.timeline.map(r=>this.timelineMapper.fromResponse(r)):[],t.status={type:e.status.type,subType:e.status.sub_type},t.lineups=e.lineups?this.lineupsMapper.fromResponse(e.lineups):new ne,t}catch(t){throw console.warn("There was a problem remapping the match response",t),t}}};var Dt=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null};var Vt=class{countryRemapper=null;constructor(){this.countryRemapper=new y}fromResponse(e){try{let t=new Dt;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping top player response",t),t}}};var $t=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;teams=[]};var le=class{countryRemapper=null;teamRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new w}fromResponse(e){try{let t=new $t;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t}catch(t){throw console.warn("There was a problem remapping players response",t),t}}};var Ht=class{id="";country=null;birthDate="";firstName="";lastName="";name="";position="";assets=null;competitions=[];teams=[]};var kt=class{countryRemapper=null;teamRemapper=null;competitionRemapper=null;constructor(){this.countryRemapper=new y,this.teamRemapper=new w,this.competitionRemapper=new I}fromResponse(e){try{let t=new Ht;return t.id=e.id,t.firstName=e.first_name?e.first_name:null,t.lastName=e.last_name?e.last_name:null,t.name=e.name?e.name:null,t.birthDate=e.birth_date,t.country=this.countryRemapper.countryFromResponse(e.country),t.assets=e.assets,t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.position=e.position,t.competitions=e.competitions?e.competitions.map(r=>this.competitionRemapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping player response",t),t}}};var qt=class{teams=null;players=null;competitions=null};var jt=class{teamRemapper=null;playerRemapper=null;competitionremapper=null;constructor(){this.teamRemapper=new w,this.playerRemapper=new le,this.competitionremapper=new I}fromResponse(e){try{let t=new qt;return t.teams=e.teams?e.teams.map(r=>this.teamRemapper.fromResponse(r)):[],t.players=e.players?e.players.map(r=>this.playerRemapper.fromResponse(r)):[],t.competitions=e.competitions?e.competitions.map(r=>this.competitionremapper.fromResponse(r)):[],t}catch(t){throw console.warn("There was a problem remapping search response",t),t}}};var Xt=class{currentPage=null;itemsPerPage=null;totalItems=null;numberOfPages=null};var pe=class{pagination=new Xt};var ce=class{meta=new pe;data=[]};var Kt=class{remapMetaProp=e=>{let t=new pe;return t.pagination.currentPage=e.pagination.current_page,t.pagination.itemsPerPage=e.pagination.items_per_page,t.pagination.totalItems=e.pagination.total_items,t.pagination.numberOfPages=e.pagination.number_of_pages,t}};var B=class{instance=null;apiSignInUrl="";idSchema="";limitIds=200;countryRemapper=null;competitionBasicRemapper=null;competitionFullRemapper=null;teamBasicRemapper=null;teamFullRemapper=null;matchBasicRemapper=null;matchFullRemapper=null;playerBasicRemapper=null;playerFullRemapper=null;topPlayerRemapper=null;searchRemapper=null;footballMetaRemapper=null;constructor(e){let t=A(e.environment,"football");this.apiSignInUrl=`?key=${e.apiKey}&lang=${e.lang}&client_id=${e.clientId}`,this.idSchema=e.idSchema,this.instance=Ao.default.create({baseURL:t}),this.countryRemapper=new y,this.competitionBasicRemapper=new I,this.competitionFullRemapper=new Rt,this.teamBasicRemapper=new w,this.teamFullRemapper=new Tt,this.matchBasicRemapper=new Ct,this.matchFullRemapper=new Ut,this.playerBasicRemapper=new le,this.playerFullRemapper=new kt,this.topPlayerRemapper=new Vt,this.searchRemapper=new jt,this.footballMetaRemapper=new Kt}getCountries=async e=>{try{let t=`/countries${this.apiSignInUrl}`,r=Date.now();e&&(t+=`&disable_cache=${r}`);let i=await this.instance.get(t);return this.countryRemapper.countriesFromResponse(i.data.data)}catch(t){throw console.warn("There was a problem with the football countries request",t),t}};getCompetitions=async(e,t)=>{try{let r={},i=Date.now();if(t=t||!1,e&&e.competitionIds&&e.competitionIds.length>this.limitIds-1){let a=[],n=Ke(e.competitionIds);for(let p of n){e.competitionIds=p;let m=`/competitions${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`&disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.competitionBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=`/competitions${this.apiSignInUrl}`;return e&&(a+=`${e.constructFilterUrl()}`),t&&(a+=`&disable_cache=${i}`),r=await this.instance.get(a),r.data.data.map(n=>this.competitionBasicRemapper.fromResponse(n))}}catch(r){throw console.warn("There was a problem with getCompetitions request",r),r.response}};getCompetitionById=async(e,t)=>{try{let r=`/competitions/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.competitionFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getCompetitionById request",r),r.response}};getTopCompetitions=async e=>{try{let t=`/competitions/top${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data.map(a=>this.competitionBasicRemapper.fromResponse(a))}catch(t){throw console.warn("There was a problem with getTopCompetitions request",t),t.response}};getTeams=async(e,t)=>{try{let r={},i=Date.now();if(e&&e.teamIds&&e.teamIds.length>this.limitIds){let a=[],n=Ke(e.teamIds);for(let p of n){e.teamIds=p;let m=`/teams${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=new ce,n=`/teams${this.apiSignInUrl}`;return e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`&disable_cache=${i}`),r=await this.instance.get(n),a.meta=this.footballMetaRemapper.remapMetaProp(r.data.meta),a.data=r.data.data.map(s=>this.teamBasicRemapper.fromResponse(s)),a}}catch(r){throw console.warn("There was a problem with getTeams request",r),r.response}};getTeamById=async(e,t)=>{try{let r=`/teams/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`disable_cache=${i}`);let a=await this.instance.get(r);return this.teamFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getTeamById request",r),r.response}};getTopTeams=async e=>{try{let t=`/teams/top${this.apiSignInUrl}`,r=Date.now();e&&(t+=`$disable_cache=${r}`);let i=await this.instance.get(t);return i.data.data?i.data.data.map(a=>this.teamBasicRemapper.fromResponse(a)):[]}catch(t){throw console.warn("There was a problem with getTopTeams request",t),t.response}};getNextMatchForTeam=async(e,t)=>{try{let r=`/teams/${e}/next-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getNextMatchForTeam request",r),r.response}};getPrevMatchForTeam=async(e,t)=>{try{let r=`/teams/${e}/previous-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPrevMatchForTeam request",r),r.response}};getPlayers=async(e,t)=>{try{let r={},i=Date.now();if(e&&e.playerIds&&e.playerIds.length>this.limitIds-1){let a=[],n=Ke(e.playerIds);for(let p of n){e.playerIds=p;let m=`/players${this.apiSignInUrl}${e.constructFilterUrl()}`;t&&(m+=`&disable_cache=${i}`),r=await this.instance.get(m),a.push(r.data.data.map(l=>this.teamBasicRemapper.fromResponse(l)))}return Array.prototype.concat.apply([],a)}else{let a=new ce,n=`/players${this.apiSignInUrl}`;return e&&(n+=`${e.constructFilterUrl()}`),t&&(n+=`&disable_cache=${i}`),r=await this.instance.get(n),a.meta=this.footballMetaRemapper.remapMetaProp(r.data.meta),a.data=r.data.data.map(s=>this.playerBasicRemapper.fromResponse(s)),a}}catch(r){throw console.warn("There was a problem with getPlayers request",r),r.response}};getPlayerById=async(e,t)=>{try{let r=`/players/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.playerFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPlayerById request",r),r.response}};getTopPlayers=async e=>{try{let t=`/players/top${this.apiSignInUrl}`,r=Date.now();return e&&(t+=`&disable_cache=${r}`),(await this.instance.get(t)).data.data.map(a=>this.topPlayerRemapper.fromResponse(a))}catch(t){throw console.warn("There was a problem with getTopPlayers request",t),t.response}};getNextMatchForPlayer=async(e,t)=>{try{let r=`/players/${e}/next-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getNextMatchForPlayer request",r),r.response}};getPrevMatchForPlayer=async(e,t)=>{try{let r=`/players/${e}/previous-match${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getPrevMatchForPlayer request",r),r.response}};getMatchById=async(e,t)=>{try{let r=`/matches/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.matchFullRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with getMatchById request",r),r.response}};getMatches=async(e,t)=>{try{let r=new ce,i=`/matches${this.apiSignInUrl}`,a=Date.now();e&&(i+=`${e.constructFilterUrl()}`),t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return r.meta=this.footballMetaRemapper.remapMetaProp(n.data.meta),r.data=n.data.data.map(s=>this.matchBasicRemapper.fromResponse(s)),r}catch(r){throw console.warn("There was a problem with getMatches request",r),r.response}};search=async(e,t)=>{try{let r=`/search${this.apiSignInUrl}${e.constructFilterUrl()}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.searchRemapper.fromResponse(a.data.data)}catch(r){throw console.warn("There was a problem with search request",r),r.response}}};var Yt=class{profileHttps=null;footballHttps=null;footballFacade=null;idMapping=null;localStorage=null;profileFacade=null;ownProfileBuilder=null;profileBuilder=null;constructor(e){this.profileHttps=new tt(e),this.footballHttps=new B(e),this.idMapping=new E(e),this.localStorage=new V(e),this.footballFacade=new q(this.localStorage,this.footballHttps,this.idMapping),this.profileFacade=new $(this.localStorage,this.profileHttps),this.ownProfileBuilder=new yt(this.localStorage,this.profileHttps,this.idMapping,this.footballHttps),this.profileBuilder=new Mt(this.localStorage,this.profileHttps,this.idMapping,this.footballFacade)}getOwn=()=>this.ownProfileBuilder;getById=e=>this.profileBuilder.setId(e);getCountries=async e=>await this.profileFacade.getCountries(e);getByIds=async(e,t)=>await this.profileFacade.getByIds(e,t)};var Wt=class{validate=e=>{let t=this.validateField(e.lang),r=this.generateMessage(t);return{validation:t,message:r}};validateField=e=>{let t=["bg","ro","en"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no lang is passed the default one will be set which is: EN"),e==="invalid"&&(t="This lang value is not supported, the default one will be set which is: EN"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var zt=class{validate(e){let t=this.validateField(e.environment),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["dev","sandbox","prod"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no environment is passed the default one will be set which is: prod"),e==="invalid"&&(t="This environment value is not supported, the default one will be set which is: prod"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Qt=class{validate(e){let t=this.validateField(e.apiKey),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="error";return e==="missing"&&(t="The field apiKey with valid value must be provided to use this SDK"),e==="valid"&&(r=null),{text:t,type:r}}};var Jt=class{validate(e){let t=this.validateField(e.idSchema),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=["native","sportal365","enetpulse","sportradar"],r=null;return e!=null&&e.length>0?t.includes(e)?r="valid":r="invalid":r="missing",r};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="If no idSchema is passed the default one will be set which is: native"),e==="invalid"&&(t="This idSchema value is not supported, the default one will be set which is: native"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var Ne=class{getIdToken=null;logout=null};var de=class{text=null;type=null};var Zt=class{validation=null;message=new de;getIdToken={validation:null,message:new de};logout={validation:null,message:new de}};var er=class{validate(e){let t=this.validateAuthProvider(e.authProvider);return t.validation!=="missing"&&(t=this.validateAuthProviderConfigFields(e.authProvider,t),t=this.generateAuthProviderConfigMessages(t),t=this.checkAuthProviderConfigMessagesForErrors(t)),t}validateAuthProvider=e=>{let t=Object.keys(new Ne),r=new Zt;if(e){let a=Object.keys(e).filter(n=>!t.includes(n));a.length>0?(r.validation="invalid",r.message.type="warning",r.message.text=`${"You have passed a property which is not supported for the authentication provider:"} ${a.join(",")}`):r.validation="valid"}else r.validation="missing",r.message.type="error",r.message.text="The field authProvider must be provided to use this SDK";return r};validateAuthProviderConfigFields=(e,t)=>(Object.keys(new Ne).forEach(i=>{e[i]?t[i].validation="valid":t[i].validation="missing"}),t);generateAuthProviderConfigMessages=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{let r=e[t];r.validation==="missing"&&(r.message.text=`${"The following property is missing from the authProvider object:"} ${t}`,r.message.type="error")}),e);checkAuthProviderConfigMessagesForErrors=e=>(Object.keys(e).filter(t=>t!=="validation"&&t!=="message").forEach(t=>{e[t].validation==="missing"&&e.validation==="valid"&&(e.validation="invalid",e.message.type="error",e.message.text="The field authProvider has missing properties")}),e)};var Le=class{validation;message};var tr=class{apiKey=null;environment=null;idSchema=null;clientId=null;lang=null;authProvider={getIdToken:new Le,logout:new Le};isValid=!1};var rr=class{validate(e){let t=this.validateField(e.clientId),r=this.generateMessage(t);return{validation:t,message:r}}validateField=e=>{let t=null;return e!=null&&e.length>0?t="valid":t="missing",t};generateMessage=e=>{let t=null,r="warning";return e==="missing"&&(t="The field clientId must be provided to use this SDK"),e==="valid"&&(t=null,r=null),{text:t,type:r}}};var ir=class{validate=e=>{let t=this.checkFieldsForValues(e);return t.isValid=this.containsErrorMessage(t),t};checkFieldsForValues=e=>{let t=new tr,r={apiKey:new Qt,environment:new zt,idSchema:new Jt,clientId:new rr,lang:new Wt,authProvider:new er};for(let[i,a]of Object.entries(t))i!=="isValid"&&(a=r[i].validate(e));return Object.keys(r).forEach(i=>{t[i]=r[i].validate(e)}),t};containsErrorMessage=e=>{let t=!0;for(let[r,i]of Object.entries(e))if(r!=="authProvider"){if(r!=="isValid"&&i.message.type==="error")return t=!1,t;if(r!=="isValid"&&i.message.type==="warning")return t=!0,t}return t}};var or=class{https=null;idMapping=null;localStorage=null;footballFacade=null;constructor(e){this.https=new B(e),this.idMapping=new E(e),this.localStorage=new V(e),this.footballFacade=new q(this.localStorage,this.https,this.idMapping)}getCountries=async e=>await this.footballFacade.getCountries(e);getCompetitions=async(e,t)=>await this.footballFacade.getCompetitions(e,t);getCompetitionById=async(e,t)=>await this.footballFacade.getCompetitionById(e,t);getTopCompetitions=async e=>await this.footballFacade.getTopCompetitions(e);getTeams=async(e,t)=>await this.footballFacade.getTeams(e,t);getTeamById=async(e,t)=>await this.footballFacade.getTeamById(e,t);getTopTeams=async e=>await this.footballFacade.getTopTeams(e);getNextMatchForTeam=async(e,t)=>await this.footballFacade.getNextMatchForTeam(e,t);getPrevMatchForTeam=async(e,t)=>await this.footballFacade.getPrevMatchForTeam(e,t);getPlayers=async(e,t)=>await this.footballFacade.getPlayers(e,t);getPlayerById=async(e,t)=>await this.footballFacade.getPlayerById(e,t);getTopPlayers=async e=>await this.footballFacade.getTopPlayers(e);getNextMatchForPlayer=async(e,t)=>await this.footballFacade.getNextMatchForPlayer(e,t);getPrevMatchForPlayer=async(e,t)=>await this.footballFacade.getPrevMatchForPlayer(e,t);getMatches=async(e,t)=>await this.footballFacade.getMatches(e,t);getMatchById=async(e,t)=>await this.footballFacade.getMatchById(e,t);search=async(e,t)=>await this.footballFacade.search(e,t)};var bi=Fe(re());var ar=class{value=null;playerId=null;playerModel=null};var he=class{market=null;matchId=null;matchType=null;matchModel=null;prediction=new ar;result=null};var nr=class{value=!1;playerId=null};var O=class{matchId=null;market=null;prediction=null;constructor(e,t,r,i){this.matchId=e,this.market=t,this.prediction=new nr,this.prediction.value=r,this.prediction.playerId=i}};var fe=class{settledAt=null;resettledAt=null;status=null;outcome=null};var v=(d=>(d.FT_1X2="FT_1X2",d.HT_1X2="HT_1X2",d.BOTH_TEAMS_SCORE="BOTH_TEAMS_SCORE",d.DOUBLE_CHANCE="DOUBLE_CHANCE",d.HT_FT="HT_FT",d.PLAYER_SCORE="PLAYER_SCORE",d.PLAYER_YELLOW_CARD="PLAYER_YELLOW_CARD",d.PLAYER_RED_CARD="PLAYER_RED_CARD",d.RED_CARD_MATCH="RED_CARD_MATCH",d.PENALTY_MATCH="PENALTY_MATCH",d.PLAYER_SCORE_FIRST_GOAL="PLAYER_SCORE_FIRST_GOAL",d.CORNERS_MATCH="CORNERS_MATCH",d.CORRECT_SCORE="CORRECT_SCORE",d.PLAYER_SCORE_HATTRICK="PLAYER_SCORE_HATTRICK",d.PLAYER_SCORE_TWICE="PLAYER_SCORE_TWICE",d.OVER_GOALS_0_5="OVER_GOALS_0.5",d.OVER_GOALS_1_5="OVER_GOALS_1.5",d.OVER_GOALS_2_5="OVER_GOALS_2.5",d.OVER_GOALS_3_5="OVER_GOALS_3.5",d.OVER_GOALS_4_5="OVER_GOALS_4.5",d.OVER_GOALS_5_5="OVER_GOALS_5.5",d.OVER_GOALS_6_5="OVER_GOALS_6.5",d.OVER_CORNERS_6_5="OVER_CORNERS_6.5",d.OVER_CORNERS_7_5="OVER_CORNERS_7.5",d.OVER_CORNERS_8_5="OVER_CORNERS_8.5",d.OVER_CORNERS_9_5="OVER_CORNERS_9.5",d.OVER_CORNERS_10_5="OVER_CORNERS_10.5",d.OVER_CORNERS_11_5="OVER_CORNERS_11.5",d.OVER_CORNERS_12_5="OVER_CORNERS_12.5",d.OVER_CORNERS_13_5="OVER_CORNERS_13.5",d))(v||{}),Bo=["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"],No=["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"],gi=["PLAYER_RED_CARD","PLAYER_SCORE","PLAYER_SCORE_FIRST_GOAL","PLAYER_SCORE_HATTRICK","PLAYER_SCORE_TWICE","PLAYER_YELLOW_CARD"];var sr=class{value=null};var j=class{matchId=null;market="CORRECT_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new sr,this.prediction.value=t}};var _=class{value=!1};var ge=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new _,this.prediction.value=r}};var ye=class{matchId=null;market=null;prediction=null;constructor(e,t,r){this.matchId=e,this.market=t,this.prediction=new _,this.prediction.value=r}};var lr=class{matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t,r){this.matchFacade=e,this.playerFacade=t,this.predictorService=r}remapFixturesRequest=e=>{let t={};if(t.match_id=e.matchId,t.match_type="FOOTBALL",e instanceof O)t.market=e.market,t.prediction=e.prediction.value,t.player_id=e.prediction.playerId;else if(e instanceof ge||e instanceof ye){let r=e.market.split("_");t.market=r[0]+"_"+r[1],t.prediction=e.prediction.value,t.target=Number(r[2])}else if(e instanceof j){t.market=e.market;let r=e.prediction.value.split(":");t.goals_home=Number(r[0]),t.goals_away=Number(r[1])}else t.market=e.market,t.prediction=e.prediction.value;return t};remapFixturesResponse=async e=>{e.length>1&&e.sort((s,p)=>s.match_id.localeCompare(p.match_id));let t=[],r=[];for(let s of e)t.push(s.match_id),s.player_id&&!r.includes(s.player_id)&&r.push(s.player_id);let i=await this.matchFacade.getMatchesMapWithNativeIds(t),a=[];r.sort((s,p)=>s.localeCompare(p)),r&&r.length>0&&(a=await this.playerFacade.getPlayersMapWithNativeIds(r));let n=[];for(let s of e){let p=new he;s.target?p.market=this.predictorService.convertMarketForResponseModel(s.market,s.target):p.market=s.market,p.matchId=i[s.match_id].id,p.matchType=s.match_type,p.matchModel=i?i[s.match_id]:null,s.goals_home!==void 0&&s.goals_away!==void 0?p.prediction.value=s.goals_home.toString()+":"+s.goals_away.toString():p.prediction.value=s.prediction,p.prediction.playerId=s.player_id?s.player_id:null,p.prediction.playerId&&(p.prediction.playerModel=a[s.player_id],p.prediction.playerId=a[s.player_id].id),p.result=this.remapResult(s.result),n.push(p)}return n};remapResult=e=>{let t=new fe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var Me=class{goldenGoal=null};var Ge=class{id=null;gameInstanceId=null;gameType=null;wager=null;totalFixtures=null;settledFixtures=null;userId=null;fixtures=[];status=null;tiebreaker=new Me;points=null;createdAt=null;updatedAt=null};var u=class{no=0;yes=0};var we=class{fullTimeOneXTwo={};halfTimeOneXTwo={};bothTeamsScore=new u;doubleChance={};halfTimeFullTime={};playerScore={};playerYellowCard={};playerRedCard={};redCardMatch=new u;penaltyMatch=new u;playerScoreFirstGoal={};cornersMatch={};correctScore={};playerScoreHattrick={};playerScoreTwice={};overZeroPointFiveGoals=new u;overOnePointFiveGoals=new u;overTwoPointFiveGoals=new u;overThreePointFiveGoals=new u;overFourPointFiveGoals=new u;overFivePointFiveGoals=new u;overSixPointFiveGoals=new u;overSixPointFiveCorners=new u;overSevenPointFiveCorners=new u;overEightPointFiveCorners=new u;overNinePointFiveCorners=new u;overTenPointFiveCorners=new u;overElevenPointFiveCorners=new u;overTwelvePointFiveCorners=new u;overThirteenPointFiveCorners=new u};var yi=(r=>(r.ONE="1",r.X="x",r.TWO="2",r))(yi||{}),Mi=(r=>(r.ONE_X="1x",r.X_TWO="x2",r.ONE_TWO="12",r))(Mi||{}),wi=(m=>(m.ONE_ONE="1/1",m.ONE_X="1/x",m.ONE_TWO="1/2",m.X_ONE="x/1",m.X_X="x/x",m.X_TWO="x/2",m.TWO_ONE="2/1",m.TWO_X="2/x",m.TWO_TWO="2/2",m))(wi||{});var pr=class{value=null};var cr=class{matchId=null;market="HT_FT";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new pr,this.prediction.value=t}};var mr=class{value=null};var ur=class{matchId=null;market="DOUBLE_CHANCE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new mr,this.prediction.value=t}};var be=class{value=null};var dr=class{matchId=null;market="FT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new be,this.prediction.value=t}};var hr=class{matchId=null;market="HT_1X2";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new be,this.prediction.value=t}};var fr=class{value};var gr=class{matchId=null;market="CORNERS_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new fr,this.prediction.value=t}};var yr=class{matchId=null;market="BOTH_TEAMS_SCORE";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var Mr=class{matchId=null;market="RED_CARD_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var wr=class{matchId=null;market="PENALTY_MATCH";prediction=null;constructor(e,t){this.matchId=e,this.prediction=new _,this.prediction.value=t}};var W=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var z=class{userId=null;points=null;results=[];tiebreaker=null};var br=(a=>(a.ACTIVE="ACTIVE",a.WON="WON",a.LOST="LOST",a.PARTIALLY_WON="PARTIALLY_WON",a.CANCELED="CANCELED",a))(br||{}),Ue=["WON","LOST","PARTIALLY_WON","CANCELED"];var b=class{limit=null;startAfter=null;status=null;type=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null}constructFiltersUrl=()=>{let e="",t=!1;return this.status&&(t=Object.values(br).some(r=>this.status.includes(r))),this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&t&&(e+="&",e+=`status=${this.status.join(",")}`),this.type&&(e+="&",e+=`game_types=${this.type}`),e}};var De=(n=>(n.OPEN="OPEN",n.LIVE="LIVE",n.PENDING="PENDING",n.CANCELED="CANCELED",n.CLOSED="CLOSED",n.SETTLED="SETTLED",n))(De||{});var S=class{limit=null;startAfter=null;status=null;type=null;gameIds=null;constructor(e){this.limit=e.limit?e.limit:null,this.startAfter=e.startAfter?e.startAfter:null,this.status=e.status?e.status:null,this.type=e.type?e.type:null,this.gameIds=e.gameIds?e.gameIds:null}constructFiltersUrl=()=>{let e="";return this.limit&&(e+="&",e+=`limit=${this.limit}`),this.startAfter&&(e+="&",e+=`start_after=${this.startAfter}`),this.status&&Object.values(De).includes(this.status)&&(e+="&",e+=`status=${this.status}`),this.type&&(e+="&",e+=`type=${this.type}`),this.gameIds&&this.gameIds.length>0&&(e+="&",e+=`game_ids=${this.gameIds.join(",")}`),e}};var Q=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var U=class{id=null;title=null;description=null;type=null;status=null;predictionsCutoff=null;fixtures=[];createdAt=null;updatedAt=null};var N=class{footballHttps=null;idMapping=null;matchFacade=null;playerFacade=null;constructor(e,t){this.footballHttps=new B(e),this.idMapping=t,this.matchFacade=new k(this.footballHttps,t),this.playerFacade=new H(this.footballHttps,t)}remapMatchIdToNative=async e=>{let t=await this.idMapping.getEntityIdsBySchemaId(e,"match","native"),r=[];return t.match.forEach(i=>r.push(i)),r};remapPlayerIdToNative=async e=>(await this.idMapping.getEntityIdsBySchemaId(e,"player","native")).player[0];remapPlayerIdMapToNative=async e=>{let t={},r=D(e),a=(await this.idMapping.getEntityIdsBySchemaId(r,"player","native")).player;return r.forEach((n,s)=>t[n]=a[s]),t};remapPlayerIdToIdSchema=async e=>{let t=["playerScore","playerYellowCard","playerRedCard","playerScoreFirstGoal","playerScoreHattrick","playerScoreTwice"];for(let[r,i]of Object.entries(e))if(t.includes(r))for(let a of Object.keys(i)){let n={player:[a]},p=(await this.idMapping.idMappingFacade.getEntitiesByIds(n,"native",this.idMapping.idSchema)).player[0];i[p]=i[a],delete i[a]}return e};convertMarket=e=>{let t=Object.keys(new we),r=Object.values(v);for(let i=0;i<r.length;i++)e===r[i]&&(e=t[i]);return e};convertMarketForResponseModel=(e,t)=>{let r=t.toString();return e+"_"+r};validateFixture=(e,t,r,i)=>{let a=Object.values(yi),n=Object.values(wi),s=Object.values(Mi);if(t==="FT_1X2"){if(a.includes(r))return new dr(e,r)}else if(t==="HT_1X2"){if(a.includes(r))return new hr(e,r)}else if(t==="HT_FT"){if(n.includes(r))return new cr(e,r)}else if(t==="DOUBLE_CHANCE"){if(s.includes(r))return new ur(e,r)}else if(t==="CORRECT_SCORE"){if(typeof r=="string"&&/\d+:\d+/.test(r))return new j(e,r)}else if(t==="CORNERS_MATCH"){if(typeof r=="number")return new gr(e,r)}else if(t==="BOTH_TEAMS_SCORE"){if(typeof r=="boolean")return new yr(e,r)}else if(t==="RED_CARD_MATCH"){if(typeof r=="boolean")return new Mr(e,r)}else if(t==="PENALTY_MATCH"){if(typeof r=="boolean")return new wr(e,r)}else if(gi.includes(t)){if(i&&typeof r=="boolean")return new O(e,t,r,i)}else if(Bo.includes(t)){if(typeof r=="boolean")return new ye(e,t,r)}else if(No.includes(t)&&typeof r=="boolean")return new ge(e,t,r)};getMarketSummary=(e,t,r)=>{let i=this.convertMarket(t),a={};if(a.matchId=e.matchId,a.matchType=e.matchType,Object.keys(e.predictions).includes(i))a[i]=e.predictions[i];else throw new Error("You have passed invalid market");return gi.includes(t)&&r?(a[i][r]||(a[i][r]=new u),a[i][r]):a};remapCompetitionsFromConfig=async e=>{let t={competition:e.fullCoverageCompetitions},r=await this.idMapping.idMappingFacade.getEntitiesByIds(t,"native",this.idMapping.idSchema);return e.fullCoverageCompetitions=r.competition,e};remapMatchIdsFixtures=async e=>{if(Array.isArray(e.data))if(e.data.length>0){let t=[],r=[];return e.data.forEach(i=>{i instanceof Q||i instanceof W||i instanceof U?(i.fixtures.forEach(a=>t.push(a.matchId)),i instanceof U&&i.fixtures.forEach(a=>{a.prediction.playerId&&r.push(a.prediction.playerId)})):i instanceof z&&i.results.forEach(a=>t.push(a.matchId))}),await this.refactorResponseArrModel(e,t,r)}else return e;else return await this.refactorResponseObjModel(e)};refactorResponseArrModel=async(e,t,r)=>{let i=[],a=await this.matchFacade.getMatchesMapWithNativeIds(t),n={};return r.length>0&&(n=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.data.forEach(s=>{s instanceof Q||s instanceof W||s instanceof U?(s.fixtures.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id,s instanceof U&&p.prediction.playerId&&(p.prediction.playerModel=n[p.prediction.playerId],p.prediction.playerId=n[p.prediction.playerId].id)}),i.push(s)):s instanceof z&&(s.results.forEach(p=>{p.matchModel=a[p.matchId],p.matchId=p.matchModel.id}),i.push(s))}),e.data=i,e};refactorResponseObjModel=async e=>{let t=[];e.fixtures.forEach(i=>t.push(i.matchId));let r=await this.matchFacade.getMatchesMapWithNativeIds(t);return e.fixtures.forEach(i=>{i.matchModel=r[i.matchId],i.matchId=r[i.matchId].id}),e};getCurrentGameId=e=>{let t=new Date;if(e.data.length>1){let r=[];return e.data.forEach(a=>r.push(a.predictionsCutoff)),e.data.sort((a,n)=>{let[s,p]=[a.predictionsCutoff,n.predictionsCutoff].map(m=>Math.abs(new Date(m)-t));return s-p})[0].id}else return e.data[0].id};initGameTypePredictions=e=>{let t={type:e};return t=new b(t),t};initGameFilters=(e,t,r)=>{if(t&&r)return t.type=e,t.gameIds=r,t=new S(t),t;if(t&&!r)return t.type=e,t=new S(t),t;if(!t&&r){let i={type:e,gameIds:r};return i=new S(i),i}else{let i={type:e};return i=new S(i),i}};addPredictionProp=async(e,t)=>(t.data.forEach((r,i)=>{r.id===e[i].game_instance_id&&r.fixtures.forEach((a,n)=>{e[i].fixtures[n].goals_home!==void 0&&e[i].fixtures[n].goals_away!==void 0?a.prediction.value=e[i].fixtures[n].goals_home+":"+e[i].fixtures[n].goals_away:a.prediction.value=e[i].fixtures[n].prediction,e[i].fixtures[n].player_id?a.prediction.playerId=e[i].fixtures[n].player_id:e[i].fixtures[n].target&&(a.prediction.target=e[i].fixtures[n].target),a.prediction.result=this.remapResult(e[i].fixtures[n].result)})}),await this.remapMatchIdsFixtures(t));remapResult=e=>{let t=new fe;return t.settledAt=e.settled_at,t.resettledAt=e.resettled_at,t.status=e.status,t.outcome=e.outcome,t}};var Pe=class{gameInstanceId=null;fixtures=[];tiebreaker=null;constructor(e){this.gameInstanceId=e.gameInstanceId,e.fixtures.forEach(t=>this.fixtures.push(new j(t.matchId,t.prediction.value))),this.tiebreaker=e.tiebreaker?e.tiebreaker:null}};var Ie=class{fixturesRemapper=null;footballHttps=null;matchFacade=null;playerFacade=null;predictorService=null;constructor(e,t){this.footballHttps=new B(e),this.matchFacade=new k(this.footballHttps,t),this.playerFacade=new H(this.footballHttps,t),this.predictorService=new N(e,t),this.fixturesRemapper=new lr(this.matchFacade,this.playerFacade,this.predictorService)}remapRequestBody=e=>{let t={};return t.game_instance_id=e.gameInstanceId,t.fixtures=e.fixtures.map(r=>this.fixturesRemapper.remapFixturesRequest(r)),e instanceof Pe&&e.tiebreaker&&(t.tiebreaker={},t.tiebreaker.golden_goal=e.tiebreaker.goldenGoal?e.tiebreaker.goldenGoal:null),t};remapResponseArrayBody=async e=>{let t=[],r=[],i={},a=[];e.forEach(s=>{s.fixtures.forEach(p=>{t.push(p.match_id),p.player_id&&r.push(p.player_id)})});let n=await this.matchFacade.getMatchesMapWithNativeIds(t);return r.length>0&&(i=await this.playerFacade.getPlayersMapWithNativeIds(r)),e.forEach(s=>{let p=new Ge,m=[];p.id=s.id,p.gameInstanceId=s.game_instance_id,p.gameType=s.game_type,p.wager=s.wager,p.totalFixtures=s.total_fixtures,p.settledFixtures=s.settled_fixtures,p.userId=s.user_id,s.fixtures.forEach(l=>{let c=new he;l.target?c.market=this.predictorService.convertMarketForResponseModel(l.market,l.target):c.market=l.market,c.matchId=n[l.match_id].id,c.matchType=l.match_type,c.matchModel=n[l.match_id],l.goals_home!==void 0&&l.goals_away!==void 0?c.prediction.value=l.goals_home.toString()+":"+l.goals_away.toString():c.prediction.value=l.prediction,c.prediction.playerId=l.player_id?l.player_id:null,c.prediction.playerId&&(c.prediction.playerModel=i[c.prediction.playerId],c.prediction.playerId=i[c.prediction.playerId].id),c.result=this.fixturesRemapper.remapResult(l.result),m.push(c)}),p.fixtures=m,p.status=s.status,s.tiebreaker?p.tiebreaker.goldenGoal=s.tiebreaker.golden_goal:p.tiebreaker=null,p.points=s.points,p.createdAt=s.created_at,p.updatedAt=s.updated_at,a.push(p)}),a};remapResponseObjBody=async e=>{let t=new Ge;return t.id=e.id,t.gameInstanceId=e.game_instance_id,t.gameType=e.game_type,t.wager=e.wager,t.totalFixtures=e.total_fixtures,t.settledFixtures=e.settled_fixtures,t.userId=e.user_id,t.fixtures=await this.fixturesRemapper.remapFixturesResponse(e.fixtures),t.status=e.status,e.tiebreaker?t.tiebreaker.goldenGoal=e.tiebreaker.golden_goal:t.tiebreaker=null,t.points=e.points,t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapPredictionModel=e=>{let t=new we;return t.fullTimeOneXTwo=e.FT_1X2,t.halfTimeOneXTwo=e.HT_1X2,t.bothTeamsScore=e.BOTH_TEAMS_SCORE?e.BOTH_TEAMS_SCORE:new u,t.overZeroPointFiveGoals=e.OVER_GOALS["over:0.5"]?e.OVER_GOALS["over:0.5"]:new u,t.overOnePointFiveGoals=e.OVER_GOALS["over:1.5"]?e.OVER_GOALS["over:1.5"]:new u,t.overTwoPointFiveGoals=e.OVER_GOALS["over:2.5"]?e.OVER_GOALS["over:2.5"]:new u,t.overThreePointFiveGoals=e.OVER_GOALS["over:3.5"]?e.OVER_GOALS["over:3.5"]:new u,t.overFourPointFiveGoals=e.OVER_GOALS["over:4.5"]?e.OVER_GOALS["over:4.5"]:new u,t.overFivePointFiveGoals=e.OVER_GOALS["over:5.5"]?e.OVER_GOALS["over:5.5"]:new u,t.overSixPointFiveGoals=e.OVER_GOALS["over:6.5"]?e.OVER_GOALS["over:6.5"]:new u,t.overSixPointFiveCorners=e.OVER_CORNERS["over:6.5"]?e.OVER_CORNERS["over:6.5"]:new u,t.overSevenPointFiveCorners=e.OVER_CORNERS["over:7.5"]?e.OVER_CORNERS["over:7.5"]:new u,t.overEightPointFiveCorners=e.OVER_CORNERS["over:8.5"]?e.OVER_CORNERS["over:8.5"]:new u,t.overNinePointFiveCorners=e.OVER_CORNERS["over:9.5"]?e.OVER_CORNERS["over:9.5"]:new u,t.overTenPointFiveCorners=e.OVER_CORNERS["over:10.5"]?e.OVER_CORNERS["over:10.5"]:new u,t.overElevenPointFiveCorners=e.OVER_CORNERS["over:11.5"]?e.OVER_CORNERS["over:11.5"]:new u,t.overTwelvePointFiveCorners=e.OVER_CORNERS["over:12.5"]?e.OVER_CORNERS["over:12.5"]:new u,t.overThirteenPointFiveCorners=e.OVER_CORNERS["over:13.5"]?e.OVER_CORNERS["over:13.5"]:new u,t.doubleChance=e.DOUBLE_CHANCE,t.halfTimeFullTime=e.HT_FT,t.playerScore=e.PLAYER_SCORE,t.playerYellowCard=e.PLAYER_YELLOW_CARD,t.playerRedCard=e.PLAYER_RED_CARD,t.redCardMatch=e.RED_CARD_MATCH?e.RED_CARD_MATCH:new u,t.penaltyMatch=e.PENALTY_MATCH?e.PENALTY_MATCH:new u,t.playerScoreFirstGoal=e.PLAYER_SCORE_FIRST_GOAL,t.cornersMatch=e.CORNERS_MATCH,t.correctScore=e.CORRECT_SCORE,t.playerScoreHattrick=e.PLAYER_SCORE_HATTRICK,t.playerScoreTwice=e.PLAYER_SCORE_TWICE,t}};var Pr=class{matchId=null;matchType=null;predictions=null};var Ir=class{remapPredictions=null;constructor(e,t){this.remapPredictions=new Ie(e,t)}remapResponse=e=>{let t=new Pr;return t.matchId=e.match_id,t.matchType=e.match_type,t.predictions=this.remapPredictions.remapPredictionModel(e.predictions),t}};var Rr=class{matchId=null;matchType=null;market=null;matchModel=null};var Fr=class{value=null;target=null;playerId=null;playerModel=null;result=null};var vr=class{matchId=null;matchType=null;market=null;matchModel=null;prediction=new Fr};var Sr=class{value=null;result=null};var Tr=class{matchId=null;matchType=null;market="CORRECT_SCORE";matchModel=null;prediction=new Sr};var Er=class{matchId=null;matchModel=null;outcome=null};var _r=class{remapPaginatedGames=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapGamesListResponse(r)),t};remapGamesListResponse=e=>{let t=new Q;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapFixturesResponse=e=>{let t=new Rr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedUserTopXEditions=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapUserTopXEditionsResponse(r)),t};remapUserTopXEditionsResponse=e=>{let t=new W;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapTopXFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapTopXFixturesResponse=e=>{let t=new Tr;return t.matchId=e.match_id,t.matchType=e.match_type,t};remapPaginatedUserMathQuizEditions=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapUserMatchQuizEditionsResponse(r)),t};remapUserMatchQuizEditionsResponse=e=>{let t=new U;return t.id=e.id,t.title=e.title,t.description=e.description,t.type=e.type,t.status=e.status,t.predictionsCutoff=e.predictions_cutoff,t.fixtures=e.fixtures.map(r=>this.remapMatchQuizFixturesResponse(r)),t.createdAt=e.created_at,t.updatedAt=e.updated_at,t};remapMatchQuizFixturesResponse=e=>{let t=new vr;return t.matchId=e.match_id,t.matchType=e.match_type,t.market=e.market,t};remapPaginatedGameResults=e=>{let t=new g;return t.meta.pagination.nextPageStartsAfter=e.meta.pagination.next_page_starts_after,t.meta.pagination.itemsPerPage=e.meta.pagination.items_per_page,t.data=e.data.map(r=>this.remapGameResults(r)),t};remapGameResults=e=>{let t=new z;return t.userId=e.user_id,t.points=e.points?e.points:0,t.results=e.results.map(r=>this.remapResults(r)),t.tiebreaker=e.tiebreaker?this.remapTiebreaker(e.tiebreaker):null,t};remapResults=e=>{let t=new Er;return t.matchId=e.match_id,t.outcome=e.outcome,t};remapTiebreaker=e=>{let t=new Me;return t.goldenGoal=e.golden_goal,t}};var Cr=class{remapMetaData=e=>{let t=new ie;return t.pagination.nextPageStartsAfter=e.pagination.next_page_starts_after,t.pagination.itemsPerPage=e.pagination.items_per_page,t}};var X=class{instanceAuth=null;instance=null;apiSignInUrl=null;clientApiSignInUrl=null;predictionRemapper=null;matchSummaryRemapper=null;gamesRemapper=null;metaRemapper=null;constructor(e,t){let r=A(e.environment,"predictor");this.apiSignInUrl=`?key=${e.apiKey}&client_id=${e.clientId}`,this.predictionRemapper=new Ie(e,t),this.matchSummaryRemapper=new Ir(e,t),this.gamesRemapper=new _r,this.metaRemapper=new Cr,this.instanceAuth=bi.default.create({baseURL:r,headers:{Authorization:`Bearer ${e.authProvider.getIdToken()}`,"Content-Type":"application/json"}}),this.instance=bi.default.create({baseURL:r,headers:{"Content-Type":"application/json"}})}makeFootballPrediction=async e=>{try{let t=this.predictionRemapper.remapRequestBody(e),r=await this.instanceAuth.post(`/predictions${this.apiSignInUrl}`,JSON.stringify(t));return await this.predictionRemapper.remapResponseObjBody(r.data)}catch(t){throw console.warn("There was a problem making POST request: ",t),t.response}};getMatchSummary=async e=>{try{let t=await this.instance.get(`/predictions/summary/${e}${this.apiSignInUrl}`);return this.matchSummaryRemapper.remapResponse(t.data)}catch(t){throw console.warn(`There was a problem fetching predictions for match: ${e} `,t),t.response}};deleteFootballPrediction=async e=>{try{return await this.instanceAuth.delete(`/predictions/${e}${this.apiSignInUrl}`),!0}catch(t){throw console.warn(`There was a problem deleting your prediction: ${e}`,t),t.response}};getMyPredictions=async e=>{try{let t=new g,r=`/predictions${this.apiSignInUrl}`;e&&(r+=`${e.constructFiltersUrl()}`);let i=await this.instanceAuth.get(r);return t.meta=this.metaRemapper.remapMetaData(i.data.meta),t.data=await this.predictionRemapper.remapResponseArrayBody(i.data.data),t}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getMyPredictionsNoRemap=async e=>{try{return(await this.instanceAuth.get(`/predictions${this.apiSignInUrl}${e.constructFiltersUrl()}`)).data.data}catch(t){throw console.warn("There was a problem fetching own predictions",t),t.response}};getUserPredictions=async(e,t,r)=>{try{let i=new g,a=`/predictions/users/${e}${this.apiSignInUrl}`,n=Date.now();r&&(a+=`${r.constructFiltersUrl()}`),t&&(a+=`&disable_cache=${n}`);let s=await this.instance.get(a);return i.meta=this.metaRemapper.remapMetaData(s.data.meta),i.data=await this.predictionRemapper.remapResponseArrayBody(s.data.data),i}catch(i){throw console.warn(`There was a problem fetching predictions for user: ${e}`,i),i.response}};getUserPredictionsNoRemap=async(e,t)=>{try{return(await this.instance.get(`/predictions/users/${e}${this.apiSignInUrl}${t.constructFiltersUrl()}`)).data.data}catch(r){throw console.warn(`There was a problem fetching predictions for user: ${e}`,r),r.response}};getGames=async(e,t)=>{try{let r=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.gamesRemapper.remapPaginatedGames(a.data)}catch(r){throw console.warn("There was a problem fetching the games list",r),r.response}};getGameById=async(e,t)=>{try{let r=`/games/${e}${this.apiSignInUrl}`,i=Date.now();t&&(r+=`&disable_cache=${i}`);let a=await this.instance.get(r);return this.gamesRemapper.remapGamesListResponse(a.data)}catch(r){throw console.warn(`There was a problem fetching the following game: ${e}`,r),r.response}};getUserGameEditions=async(e,t)=>{try{let r=null,i=`/games/${this.apiSignInUrl}${e.constructFiltersUrl()}`,a=Date.now();t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return n.data.data.forEach(s=>{s.type==="TOP_X"?r=this.gamesRemapper.remapPaginatedUserTopXEditions(n.data):s.type==="MATCH_QUIZ"&&(r=this.gamesRemapper.remapPaginatedUserMathQuizEditions(n.data))}),r}catch(r){throw console.warn("There was a problem fetching the games list",r),r.response}};getGameResults=async(e,t,r)=>{try{let i=`/games/${e}/results/${this.apiSignInUrl}`,a=Date.now();r&&(i+=`${r.constructFiltersUrl()}`),t&&(i+=`&disable_cache=${a}`);let n=await this.instance.get(i);return this.gamesRemapper.remapPaginatedGameResults(n.data)}catch(i){throw console.warn(`There was a problem fetching the results for the following game: ${e}`,i),i.response}}};var Or=class{fullCoverageCompetitions=null;markets=null};var xr=class{remapConfig=e=>{let t=new Or;return t.fullCoverageCompetitions=e.full_coverage_competitions,t.markets=e.markets,t}};var Ar=class{gameInstanceId=null;fixtures=null};var Br=class{predictorHttps=null;clientHttps=null;idMapping=null;predictorConfigRemapper=null;predictorService=null;constructor(e,t,r,i){this.predictorHttps=t,this.idMapping=i,this.clientHttps=r,this.predictorConfigRemapper=new xr,this.predictorService=new N(e,i)}makeFootballPrediction=async(e,t,r,i)=>{let a=this.predictorService.validateFixture(e,t,r,i),n=new Ar;if(a)if(this.idMapping.idSchema!=="native"){let s=a.matchId,p="",m=await this.predictorService.remapMatchIdToNative([s]);if(a.matchId=m[0],!a.matchId)throw new Error("Match id is invalid!");if(a instanceof O&&(p=a.prediction.playerId,a.prediction.playerId=await this.predictorService.remapPlayerIdToNative([p]),!a.prediction.playerId))throw new Error("Player id is invalid!");n.fixtures=[a];let l=await this.predictorHttps.makeFootballPrediction(n);return l.fixtures.map(c=>{c.prediction.playerId&&(c.prediction.playerId=p),c.matchId=s}),l}else return n.fixtures=[a],await this.predictorHttps.makeFootballPrediction(n);else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model")};getMatchSummary=async e=>{if(this.idMapping.idSchema!=="native"){let r=(await this.predictorService.remapMatchIdToNative([e]))[0],i=await this.predictorHttps.getMatchSummary(r);i.matchId=e;let a=i.predictions,n=await this.predictorService.remapPlayerIdToIdSchema(a);return i.predictions=n,i}else return await this.predictorHttps.getMatchSummary(e)};getMarketSummary=async(e,t,r)=>{try{let i=await this.getMatchSummary(e);return this.predictorService.getMarketSummary(i,t,r)}catch(i){return i.message}};getConfig=async()=>{let e=await this.clientHttps.getConfig(),t=await this.predictorConfigRemapper.remapConfig(e.predictor);return this.idMapping.idSchema!=="native"?await this.predictorService.remapCompetitionsFromConfig(t):t};deleteFootballPrediction=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyPredictions=async e=>(e&&(e=new b(e)),await this.predictorHttps.getMyPredictions(e));getMyCurrentPredictions=async e=>{if(e)e.status=["ACTIVE"],e=new b(e);else{let t={status:["ACTIVE"]};e=new b(t)}return await this.getMyPredictions(e)};getMyPastPredictions=async e=>{if(e)e.status=Ue,e=new b(e);else{let t={status:Ue};e=new b(t)}return await this.getMyPredictions(e)};getUserPredictions=async(e,t,r)=>(r=r||!1,t&&(t=new b(t)),await this.predictorHttps.getUserPredictions(e,r,t));getUserCurrentPredictions=async(e,t)=>{if(t)t.status=["ACTIVE"],t=new b(t);else{let r={status:["ACTIVE"]};t=new b(r)}return await this.getUserPredictions(e,t)};getUserPastPredictions=async(e,t)=>{if(t)t.status=Ue,t=new b(t);else{let r={status:Ue};t=new b(r)}return await this.getUserPredictions(e,t)}};var Lo=Fe(re());var Re=class{instance=null;apiSignInUrl="";constructor(e){let t=A(e.environment,"client");this.apiSignInUrl=`/clients/${e.clientId}/features?key=${e.apiKey}`,this.instance=Lo.default.create({baseURL:t,headers:{"Content-Type":"application/json"}})}getConfig=async()=>{try{return(await this.instance.get(`${this.apiSignInUrl}`)).data.data}catch(e){throw console.warn("There was a problem fetching configuration from Client API",e),e.response}}};var Nr=class{predictorHttps=null;clientHttps=null;predictorFacade=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.predictorHttps=new X(e,this.idMapping),this.clientHttps=new Re(e),this.predictorFacade=new Br(e,this.predictorHttps,this.clientHttps,this.idMapping)}makeFootballPrediction=async(e,t,r,i)=>await this.predictorFacade.makeFootballPrediction(e,t,r,i);getMatchSummary=async e=>await this.predictorFacade.getMatchSummary(e);getMarketSummary=async(e,t,r)=>await this.predictorFacade.getMarketSummary(e,t,r);getConfig=async()=>await this.predictorFacade.getConfig();deleteFootballPrediction=async e=>await this.predictorFacade.deleteFootballPrediction(e);getMyPredictions=async e=>await this.predictorFacade.getMyPredictions(e);getMyCurrentPredictions=async e=>await this.predictorFacade.getMyCurrentPredictions(e);getMyPastPredictions=async e=>await this.predictorFacade.getMyPastPredictions(e);getUserPredictions=async(e,t,r)=>await this.predictorFacade.getUserPredictions(e,t,r);getUserCurrentPredictions=async(e,t)=>await this.predictorFacade.getUserCurrentPredictions(e,t);getUserPastPredictions=async(e,t)=>await this.predictorFacade.getUserPastPredictions(e,t)};var Lr=class{general=[];predictor=[];topX=[]};var Gr=class{enabled=!1;rewards=null};var Ur=class{general=null;topX=null;predictor=null};var Dr=class{points=null;tiers=null;badges=null};var Vr=class{remapLoyaltyResponse=e=>{let t=new Gr;return t.enabled=e.enabled,t.rewards=this.remapRewards(e.rewards),t};remapRewards=e=>{let t=new Dr;return t.points=this.remapPoints(e.points),t.tiers=e.tiers,t.badges=this.remapBadges(e.badges),t};remapPoints=e=>{let t=new Ur;return t.general=e.general,t.topX=e.top_x,t.predictor=e.predictor,t};remapBadges=e=>{let t=new Lr;return t.general=e.general,t.predictor=e.predictor,t.topX=e.top_x,t}};var $r=class{https=null;loyaltyRemapper=null;constructor(e){this.https=e,this.loyaltyRemapper=new Vr}getConfig=async()=>{let e=await this.https.getConfig();return this.loyaltyRemapper.remapLoyaltyResponse(e.loyalty)}};var Hr=class{https=null;loyaltyFacade=null;constructor(e){this.https=new Re(e),this.loyaltyFacade=new $r(this.https)}getConfig=async()=>await this.loyaltyFacade.getConfig()};var kr=class{idMapping=null;predictorHttps=null;predictorService=null;constructor(e,t){this.idMapping=t,this.predictorHttps=new X(e,t),this.predictorService=new N(e,t)}getGames=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameFilters("TOP_X",e),i=await this.predictorHttps.getGames(r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGameById=async(e,t)=>{t=t||!1;let r=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameResults=async(e,t,r)=>{r=r||!1,t&&(t=new S(t));let i=await this.predictorHttps.getGameResults(e,r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"TOP_X"};t=new S(t);let r=await this.predictorHttps.getGames(t,e),i=this.predictorService.getCurrentGameId(r);return(await this.getGameResults(i,null,e)).data[0]};play=async e=>{let t=new Pe(e);if(this.idMapping.idSchema!=="native"){let i=[];t.fixtures.forEach(n=>i.push(n.matchId));let a=await this.predictorService.remapMatchIdToNative(i);t.fixtures.forEach(n=>n.matchId=a.shift())}let r=await this.predictorHttps.makeFootballPrediction(t);return r.fixtures.forEach(i=>{i.matchId=i.matchModel.id}),r};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getMyGameEditions=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameTypePredictions("TOP_X"),i=[],a=await this.predictorHttps.getMyPredictionsNoRemap(r);if(a.length>0){a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let n=this.predictorService.initGameFilters("TOP_X",e,i),s=await this.predictorHttps.getUserGameEditions(n,t);return await this.predictorService.addPredictionProp(a,s)}else return new g};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("TOP_X"),r=await this.predictorHttps.getMyPredictions(t);return r.data.length>0?r.data.filter(a=>a.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("TOP_X"),a=[],n=await this.predictorHttps.getUserPredictionsNoRemap(e,i);if(n.length>0){n.forEach(m=>{m.game_instance_id&&a.push(m.game_instance_id)});let s=this.predictorService.initGameFilters("TOP_X",t,a),p=await this.predictorHttps.getUserGameEditions(s,r);return await this.predictorService.addPredictionProp(n,p)}else return new g};getUserGamePrediction=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("TOP_X"),a=await this.predictorHttps.getUserPredictions(e,r,i);return a.data.length>0?a.data.filter(s=>s.gameInstanceId===t)[0]:null}};var qr=class{topXFacade=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.topXFacade=new kr(e,this.idMapping)}getGames=async(e,t)=>await this.topXFacade.getGames(e,t);getGameById=async(e,t)=>await this.topXFacade.getGameById(e,t);getGameResults=async(e,t,r)=>await this.topXFacade.getGameResults(e,t,r);getCurrentGameResults=async e=>await this.topXFacade.getCurrentGameResults(e);play=async e=>await this.topXFacade.play(e);delete=async e=>await this.topXFacade.delete(e);getMyGameEditions=async(e,t)=>await this.topXFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.topXFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,r)=>await this.topXFacade.getUserGameEditions(e,t,r);getUserGamePrediction=async(e,t,r)=>await this.topXFacade.getUserGamePrediction(e,t,r)};var jr=class{predictorHttps=null;predictorService=null;idMapping=null;constructor(e){this.idMapping=new E(e),this.predictorHttps=new X(e,this.idMapping),this.predictorService=new N(e,this.idMapping)}play=async e=>{let t=e.fixtures.map(r=>this.predictorService.validateFixture(r.matchId,r.market,r.prediction.value,r.prediction.playerId));if(t){if(this.idMapping.idSchema!=="native"){let r=[],i=[];t.forEach(s=>{r.push(s.matchId),s instanceof O&&i.push(s.prediction.playerId)});let a=await this.predictorService.remapMatchIdToNative(r),n={};i&&i.length>0&&(n=await this.predictorService.remapPlayerIdMapToNative(i)),t.forEach((s,p)=>{s.matchId=a[p],s instanceof O&&(s.prediction.playerId=n[s.prediction.playerId])})}}else throw new Error("The prediction is invalid. Please check again have you passed appropriate prediction model");return e.fixtures=t,await this.predictorHttps.makeFootballPrediction(e)};delete=async e=>await this.predictorHttps.deleteFootballPrediction(e);getGames=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameFilters("MATCH_QUIZ",e),i=await this.predictorHttps.getGames(r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getGameById=async(e,t)=>{t=t||!1;let r=await this.predictorHttps.getGameById(e,t);return await this.predictorService.remapMatchIdsFixtures(r)};getGameResults=async(e,t,r)=>{r=r||!1,t&&(t=new S(t));let i=await this.predictorHttps.getGameResults(e,r,t);return await this.predictorService.remapMatchIdsFixtures(i)};getCurrentGameResults=async e=>{e=e||!1;let t={status:"OPEN",type:"MATCH_QUIZ"};t=new S(t);let r=await this.predictorHttps.getGames(t,e),i=this.predictorService.getCurrentGameId(r);return(await this.getGameResults(i,null,e)).data[0]};getMyGameEditions=async(e,t)=>{t=t||!1;let r=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),i=[],a=await this.predictorHttps.getMyPredictionsNoRemap(r);if(a.length>0){a.forEach(p=>{p.game_instance_id&&i.push(p.game_instance_id)});let n=this.predictorService.initGameFilters("MATCH_QUIZ",e,i),s=await this.predictorHttps.getUserGameEditions(n,t);return await this.predictorService.addPredictionProp(a,s)}else return new g};getMyGamePrediction=async e=>{let t=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),r=await this.predictorHttps.getMyPredictions(t);return r.data.length>0?r.data.filter(a=>a.gameInstanceId===e)[0]:null};getUserGameEditions=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=[],n=await this.predictorHttps.getUserPredictionsNoRemap(e,i);if(n.length>0){n.forEach(m=>{m.game_instance_id&&a.push(m.game_instance_id)});let s=this.predictorService.initGameFilters("MATCH_QUIZ",t,a),p=await this.predictorHttps.getUserGameEditions(s,r);return await this.predictorService.addPredictionProp(n,p)}else return new g};getUserGamePrediction=async(e,t,r)=>{r=r||!1;let i=this.predictorService.initGameTypePredictions("MATCH_QUIZ"),a=await this.predictorHttps.getUserPredictions(e,r,i);return a.data.length>0?a.data.filter(s=>s.gameInstanceId===t)[0]:null}};var Xr=class{matchQuizFacade=null;constructor(e){this.matchQuizFacade=new jr(e)}play=async e=>await this.matchQuizFacade.play(e);delete=async e=>await this.matchQuizFacade.delete(e);getGames=async(e,t)=>await this.matchQuizFacade.getGames(e,t);getGameById=async(e,t)=>await this.matchQuizFacade.getGameById(e,t);getGameResults=async(e,t,r)=>await this.matchQuizFacade.getGameResults(e,t,r);getCurrentGameResults=async e=>await this.matchQuizFacade.getCurrentGameResults(e);getMyGameEditions=async(e,t)=>await this.matchQuizFacade.getMyGameEditions(e,t);getMyGamePrediction=async e=>await this.matchQuizFacade.getMyGamePrediction(e);getUserGameEditions=async(e,t,r)=>await this.matchQuizFacade.getUserGameEditions(e,t,r);getUserGamePrediction=async(e,t,r)=>await this.matchQuizFacade.getUserGamePrediction(e,t,r)};function af(o){let t=new ir().validate(o);if(t.idSchema.validation==="missing"&&(console.warn(t.idSchema.message.text),o.idSchema="native"),t.environment.validation==="missing"&&(console.warn(t.environment.message.text),o.environment="prod"),t.lang.validation==="missing"&&(console.warn(t.lang.message.text),o.lang="en"),t.isValid)return{profile:new Yt(o),football:new or(o),predictor:new Nr(o),loyalty:new Hr(o),topX:new qr(o),matchQuiz:new Xr(o)};throw new Error("Configuration is not valid")}export{af as FansUnitedSDK};
3
3
  //# sourceMappingURL=index.js.map