@everymatrix/casino-tournaments-ingame-table 0.3.3 → 0.3.5

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.
@@ -0,0 +1,7 @@
1
+ import{r as t,c as i,h as e}from"./index-448538d5.js";const n="__WIDGET_GLOBAL_STYLE_CACHE__";function s(t,i){if(t){const e=document.createElement("style");e.innerHTML=i,t.appendChild(e)}}function r(t,i){if(!t||!i)return;const e=new URL(i);fetch(e.href).then((t=>t.text())).then((i=>{const e=document.createElement("style");e.innerHTML=i,t&&t.appendChild(e)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function o(t,i,e,s=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!s)return e=function(t,i){const e=document.createElement("style");return window.emMessageBus.subscribe(i,(i=>{t&&(e.innerHTML=i,t.appendChild(e))}))}(t,i),e;window[n]||(window[n]={}),e=function(t,i){return window.emMessageBus.subscribe(i,(e=>{if(!t)return;const s=t.getRootNode(),r=window[n];let o=r[i]&&r[i].sheet;o?r[i].refCount=r[i].refCount+1:(o=new CSSStyleSheet,o.replaceSync(e),r[i]={sheet:o,refCount:1});const a=s.adoptedStyleSheets||[];a.includes(o)||(s.adoptedStyleSheets=[...a,o])}))}(t,i);const r=e.unsubscribe.bind(e);return e.unsubscribe=()=>{if(window[n][i]){const t=window[n][i];t.refCount>1?t.refCount=t.refCount-1:delete window[n][i]}r()},e}const a={en:{you:"You",loading:"Loading, please wait ...",leaderboard:"Leaderboard",nowinners:"No winners for the time being. Be one of them!",noLeaderboard:"No Leaderboard yet",positionsWillShow:"Player positions will appear here once scores are recorded."}},h=t=>new Promise((i=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((i=>{a[i]||(a[i]={});for(let e in t[i])a[i][e]=t[i][e]})),i(!0)}))})),l=(t,i,e)=>{let n=a[void 0!==i&&i in a?i:"en"][t];if(void 0!==e)for(const[t,i]of Object.entries(e.values)){const e=new RegExp(`{${t}}`,"g");n=n.replace(e,i)}return n},d=()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"};var c,u,f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},v={exports:{}};
2
+ /** @license
3
+ * eventsource.js
4
+ * Available under MIT License (MIT)
5
+ * https://github.com/Yaffle/EventSource/
6
+ */
7
+ c=v,u=v.exports,function(t){var i=t.setTimeout,e=t.clearTimeout,n=t.XMLHttpRequest,s=t.XDomainRequest,r=t.ActiveXObject,o=t.EventSource,a=t.document,h=t.Promise,l=t.fetch,d=t.Response,f=t.TextDecoder,v=t.TextEncoder,p=t.AbortController;if("undefined"==typeof window||void 0===a||"readyState"in a||null!=a.body||(a.readyState="loading",window.addEventListener("load",(function(){a.readyState="complete"}),!1)),null==n&&null!=r&&(n=function(){return new r("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(t){function i(){}return i.prototype=t,new i}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==p){var g=l;l=function(t,i){var e=i.signal;return g(t,{headers:i.headers,credentials:i.credentials,cache:i.cache}).then((function(t){var i=t.body.getReader();return e._reader=i,e._aborted&&e._reader.cancel(),{status:t.status,statusText:t.statusText,headers:t.headers,body:{getReader:function(){return i}}}}))},p=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function w(){this.bitsNeeded=0,this.codePoint=0}w.prototype.decode=function(t){function i(t,i,e){if(1===e)return t>=128>>i&&t<<i<=2047;if(2===e)return t>=2048>>i&&t<<i<=55295||t>=57344>>i&&t<<i<=65535;if(3===e)return t>=65536>>i&&t<<i<=1114111;throw new Error}function e(t,i){if(6===t)return i>>6>15?3:i>31?2:1;if(12===t)return i>15?3:2;if(18===t)return 3;throw new Error}for(var n=65533,s="",r=this.bitsNeeded,o=this.codePoint,a=0;a<t.length;a+=1){var h=t[a];0!==r&&(h<128||h>191||!i(o<<6|63&h,r-6,e(r,o)))&&(r=0,o=n,s+=String.fromCharCode(o)),0===r?(h>=0&&h<=127?(r=0,o=h):h>=192&&h<=223?(r=6,o=31&h):h>=224&&h<=239?(r=12,o=15&h):h>=240&&h<=247?(r=18,o=7&h):(r=0,o=n),0===r||i(o,r,e(r,o))||(r=0,o=n)):(r-=6,o=o<<6|63&h),0===r&&(o<=65535?s+=String.fromCharCode(o):(s+=String.fromCharCode(55296+(o-65535-1>>10)),s+=String.fromCharCode(56320+(o-65535-1&1023))))}return this.bitsNeeded=r,this.codePoint=o,s},null!=f&&null!=v&&function(){try{return"test"===(new f).decode((new v).encode("test"),{stream:!0})}catch(t){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+t)}return!1}()||(f=w);var b=function(){};function m(t){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=t,this._sendTimeout=0,this._abort=b}function y(t){return t.replace(/[A-Z]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)+32)}))}function L(t){for(var i=Object.create(null),e=t.split("\r\n"),n=0;n<e.length;n+=1){var s=e[n].split(": "),r=s.shift(),o=s.join(": ");i[y(r)]=o}this._map=i}function S(){}function k(t){this._headers=t}function x(){}function T(){this._listeners=Object.create(null)}function R(t){i((function(){throw t}),0)}function C(t){this.type=t,this.target=void 0}function W(t,i){C.call(this,t),this.data=i.data,this.lastEventId=i.lastEventId}function P(t,i){C.call(this,t),this.status=i.status,this.statusText=i.statusText,this.headers=i.headers}function A(t,i){C.call(this,t),this.error=i.error}m.prototype.open=function(t,s){this._abort(!0);var r=this,o=this._xhr,a=1,h=0;this._abort=function(t){0!==r._sendTimeout&&(e(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,o.onload=b,o.onerror=b,o.onabort=b,o.onprogress=b,o.onreadystatechange=b,o.abort(),0!==h&&(e(h),h=0),t||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var l=function(){if(1===a){var t=0,i="",e=void 0;if("contentType"in o)t=200,i="OK",e=o.contentType;else try{t=o.status,i=o.statusText,e=o.getResponseHeader("Content-Type")}catch(n){t=0,i="",e=void 0}0!==t&&(a=2,r.readyState=2,r.status=t,r.statusText=i,r._contentType=e,r.onreadystatechange())}},d=function(){if(l(),2===a||3===a){a=3;var t="";try{t=o.responseText}catch(t){}r.readyState=3,r.responseText=t,r.onprogress()}},c=function(t,i){if(null!=i&&null!=i.preventDefault||(i={preventDefault:b}),d(),1===a||2===a||3===a){if(a=4,0!==h&&(e(h),h=0),r.readyState=4,"load"===t)r.onload(i);else if("error"===t)r.onerror(i);else{if("abort"!==t)throw new TypeError;r.onabort(i)}r.onreadystatechange()}},u=function(){h=i((function(){u()}),500),3===o.readyState&&d()};"onload"in o&&(o.onload=function(t){c("load",t)}),"onerror"in o&&(o.onerror=function(t){c("error",t)}),"onabort"in o&&(o.onabort=function(t){c("abort",t)}),"onprogress"in o&&(o.onprogress=d),"onreadystatechange"in o&&(o.onreadystatechange=function(t){!function(t){null!=o&&(4===o.readyState?"onload"in o&&"onerror"in o&&"onabort"in o||c(""===o.responseText?"error":"load",t):3===o.readyState?"onprogress"in o||d():2===o.readyState&&l())}(t)}),!("contentType"in o)&&"ontimeout"in n.prototype||(s+=(-1===s.indexOf("?")?"?":"&")+"padding=true"),o.open(t,s,!0),"readyState"in o&&(h=i((function(){u()}),0))},m.prototype.abort=function(){this._abort(!1)},m.prototype.getResponseHeader=function(){return this._contentType},m.prototype.setRequestHeader=function(t,i){var e=this._xhr;"setRequestHeader"in e&&e.setRequestHeader(t,i)},m.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},m.prototype.send=function(){if("ontimeout"in n.prototype&&("sendAsBinary"in n.prototype||"mozAnon"in n.prototype)||null==a||null==a.readyState||"complete"===a.readyState){var t=this._xhr;"withCredentials"in t&&(t.withCredentials=this.withCredentials);try{t.send(void 0)}catch(t){throw t}}else{var e=this;e._sendTimeout=i((function(){e._sendTimeout=0,e.send()}),4)}},L.prototype.get=function(t){return this._map[y(t)]},null!=n&&null==n.HEADERS_RECEIVED&&(n.HEADERS_RECEIVED=2),S.prototype.open=function(t,i,e,s,r,o,a){t.open("GET",r);var h=0;for(var l in t.onprogress=function(){var i=t.responseText.slice(h);h+=i.length,e(i)},t.onerror=function(t){t.preventDefault(),s(new Error("NetworkError"))},t.onload=function(){s(null)},t.onabort=function(){s(null)},t.onreadystatechange=function(){if(t.readyState===n.HEADERS_RECEIVED){var e=t.status,s=t.statusText,r=t.getResponseHeader("Content-Type"),o=t.getAllResponseHeaders();i(e,s,r,new L(o))}},t.withCredentials=o,a)Object.prototype.hasOwnProperty.call(a,l)&&t.setRequestHeader(l,a[l]);return t.send(),t},k.prototype.get=function(t){return this._headers.get(t)},x.prototype.open=function(t,i,e,n,s,r,o){var a=null,d=new p,c=d.signal,u=new f;return l(s,{headers:o,credentials:r?"include":"same-origin",signal:c,cache:"no-store"}).then((function(t){return a=t.body.getReader(),i(t.status,t.statusText,t.headers.get("Content-Type"),new k(t.headers)),new h((function(t,i){var n=function(){a.read().then((function(i){if(i.done)t(void 0);else{var s=u.decode(i.value,{stream:!0});e(s),n()}})).catch((function(t){i(t)}))};n()}))})).catch((function(t){return"AbortError"===t.name?void 0:t})).then((function(t){n(t)})),{abort:function(){null!=a&&a.cancel(),d.abort()}}},T.prototype.dispatchEvent=function(t){t.target=this;var i=this._listeners[t.type];if(null!=i)for(var e=i.length,n=0;n<e;n+=1){var s=i[n];try{"function"==typeof s.handleEvent?s.handleEvent(t):s.call(this,t)}catch(t){R(t)}}},T.prototype.addEventListener=function(t,i){t=String(t);var e=this._listeners,n=e[t];null==n&&(e[t]=n=[]);for(var s=!1,r=0;r<n.length;r+=1)n[r]===i&&(s=!0);s||n.push(i)},T.prototype.removeEventListener=function(t,i){t=String(t);var e=this._listeners,n=e[t];if(null!=n){for(var s=[],r=0;r<n.length;r+=1)n[r]!==i&&s.push(n[r]);0===s.length?delete e[t]:e[t]=s}},W.prototype=Object.create(C.prototype),P.prototype=Object.create(C.prototype),A.prototype=Object.create(C.prototype);var E=/^text\/event\-stream(;.*)?$/i,O=function(t,i){var e=null==t?i:parseInt(t,10);return e!=e&&(e=i),I(e)},I=function(t){return Math.min(Math.max(t,1e3),18e6)},N=function(t,i,e){try{"function"==typeof i&&i.call(t,e)}catch(t){R(t)}};function $(t,r){T.call(this),r=r||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(t,r,o){r=String(r);var a=Boolean(o.withCredentials),h=o.lastEventIdQueryParameterName||"lastEventId",l=I(1e3),d=O(o.heartbeatTimeout,45e3),c="",u=l,f=!1,v=0,p=o.headers||{},g=o.Transport,w=D&&null==g?void 0:new m(null!=g?new g:null!=n&&"withCredentials"in n.prototype||null==s?new n:new s),b=null!=g&&"string"!=typeof g?new g:null==w?new x:new S,y=void 0,L=0,k=-1,T="",R="",C="",$="",M=0,U=0,j=0,_=function(i,e,n,s){if(0===k)if(200===i&&null!=n&&E.test(n)){k=1,f=Date.now(),u=l,t.readyState=1;var r=new P("open",{status:i,statusText:e,headers:s});t.dispatchEvent(r),N(t,t.onopen,r)}else{var o="";200!==i?(e&&(e=e.replace(/\s+/g," ")),o="EventSource's response has a status "+i+" "+e+" that is not 200. Aborting the connection."):o="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",F(),r=new P("error",{status:i,statusText:e,headers:s}),t.dispatchEvent(r),N(t,t.onerror,r),console.error(o)}},B=function(n){if(1===k){for(var s=-1,r=0;r<n.length;r+=1)(h=n.charCodeAt(r))!=="\n".charCodeAt(0)&&h!=="\r".charCodeAt(0)||(s=r);var o=(-1!==s?$:"")+n.slice(0,s+1);$=(-1===s?$:"")+n.slice(s+1),""!==n&&(f=Date.now(),v+=n.length);for(var a=0;a<o.length;a+=1){var h=o.charCodeAt(a);if(-1===M&&h==="\n".charCodeAt(0))M=0;else if(-1===M&&(M=0),h==="\r".charCodeAt(0)||h==="\n".charCodeAt(0)){if(0!==M){1===M&&(j=a+1);var p=o.slice(U,j-1),g=o.slice(j+(j<a&&o.charCodeAt(j)===" ".charCodeAt(0)?1:0),a);"data"===p?(T+="\n",T+=g):"id"===p?R=g:"event"===p?C=g:"retry"===p?(l=O(g,l),u=l):"heartbeatTimeout"===p&&(d=O(g,d),0!==L&&(e(L),L=i((function(){H()}),d)))}if(0===M){if(""!==T){c=R,""===C&&(C="message");var w=new W(C,{data:T.slice(1),lastEventId:R});if(t.dispatchEvent(w),"open"===C?N(t,t.onopen,w):"message"===C?N(t,t.onmessage,w):"error"===C&&N(t,t.onerror,w),2===k)return}T="",C=""}M=h==="\r".charCodeAt(0)?-1:0}else 0===M&&(U=a,M=1),1===M?h===":".charCodeAt(0)&&(j=a+1,M=2):2===M&&(M=3)}}},z=function(n){if(1===k||0===k){k=-1,0!==L&&(e(L),L=0),L=i((function(){H()}),u),u=I(Math.min(16*l,2*u)),t.readyState=0;var s=new A("error",{error:n});t.dispatchEvent(s),N(t,t.onerror,s),null!=n&&console.error(n)}},F=function(){k=2,null!=y&&(y.abort(),y=void 0),0!==L&&(e(L),L=0),t.readyState=2},H=function(){if(L=0,-1===k){f=!1,v=0,L=i((function(){H()}),d),k=0,T="",C="",R=c,$="",U=0,j=0,M=0;var e=r;if("data:"!==r.slice(0,5)&&"blob:"!==r.slice(0,5)&&""!==c){var n=r.indexOf("?");e=-1===n?r:r.slice(0,n+1)+r.slice(n+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(t,i){return i===h?"":t})),e+=(-1===r.indexOf("?")?"?":"&")+h+"="+encodeURIComponent(c)}var s=t.withCredentials,o={Accept:"text/event-stream"},a=t.headers;if(null!=a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(o[l]=a[l]);try{y=b.open(w,_,B,z,e,s,o)}catch(t){throw F(),t}}else if(f||null==y){var u=Math.max((f||Date.now())+d-Date.now(),1);f=!1,L=i((function(){H()}),u)}else z(new Error("No activity within "+d+" milliseconds. "+(0===k?"No response received.":v+" chars received.")+" Reconnecting.")),null!=y&&(y.abort(),y=void 0)};t.url=r,t.readyState=0,t.withCredentials=a,t.headers=p,t._close=F,H()}(this,t,r)}var D=null!=l&&null!=d&&"body"in d.prototype;($.prototype=Object.create(T.prototype)).CONNECTING=0,$.prototype.OPEN=1,$.prototype.CLOSED=2,$.prototype.close=function(){this._close()},$.CONNECTING=0,$.OPEN=1,$.CLOSED=2,$.prototype.withCredentials=void 0;var M,U=o;null==n||null!=o&&"withCredentials"in o.prototype||(U=$),M=function(t){t.EventSourcePolyfill=$,t.NativeEventSource=o,t.EventSource=U}(u),void 0!==M&&(c.exports=M)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:f:globalThis);const p=class{constructor(e){t(this,e),this.leaderboardLoaded=i(this,"leaderboardLoaded",7),this.isCurrentOnTop=!1,this.isCurrentPlayerRanked=!1,this.timeOrder1=500,this.timeOrder2=1e3,this.isMobile=!1,this.abortController=null,this.autoLocateCurrent=!1,this.keepOnBottom=!0,this.shouldUpdateObserver=!1,this.onLeaderboardScroll=t=>{t.stopPropagation(),(this.isLoadingPrevious||this.isLoadingMore||this.isPageRendering)&&t.preventDefault()},this.updateMessageHandler=t=>{if(!t.data)return;const i=JSON.parse(t.data);if("LeaderBoardUpdate"===i.messageType){const{item:t,items:e,total:n}=i;(t||this.currentUserData)&&(this.currentUserData=t||this.currentUserData,this.currentUserData.formattedScore=this.formatScore(this.currentUserData.score)),this.leaderboardLoaded.emit({item:this.currentUserData?this.currentUserData:null,isRanked:!!t,totalRank:n}),e.forEach((t=>{const i=this.leaderboard.findIndex((i=>i.rank===t.rank));i>=0&&(this.leaderboard[i]=t),t.formattedScore=this.formatScore(t.score),i<0?this.leaderboard.push(t):this.leaderboard[i]=t})),this.leaderboard=[...this.leaderboard],this.shouldUpdateObserver=!0}},this.goToCurrentPlayerPage=()=>{this.leaderboard.findIndex((t=>t.id===this.currentUserData.id))>=0?this.scrollCurrentPlayerToMiddle():(this.offset=this.currentUserData.rank-this.limit/2||0,this.leaderboard=[],this.isLeaderboardLoading=!0,this.loadLeaderboardById().catch(console.error),this.isCurrentPlayerInview=!0)},this.handleTableListScroll=()=>{this.isCurrentPlayerInview=this.isElementInViewport()},this.isPageRendering=!1,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.tournamentId=void 0,this.endpoint=void 0,this.session=void 0,this.language="en",this.limit=40,this.theme="Dark",this.state=void 0,this.offset=0,this.currentUserData=void 0,this.leaderboard=[],this.isLeaderboardLoading=!0,this.isLoadingMore=!1,this.isCurrentPlayerInview=!0,this.isLoadingPrevious=!1,this.scorefractiondigit=2}mergeSortedArrays(t,i,e){if(!(null==t?void 0:t.length))return i;if(!(null==i?void 0:i.length))return t;const n=new Map;t.forEach(((t,i)=>{n.set(t[e],i)}));let s=[...t];const r=[];return i.forEach((t=>{const i=t[e];n.has(i)?s[n.get(i)]=t:r.push(t)})),r.length?(s=[],s=r[r.length-1][e]<t[0][e]?[...r,...t]:[...t,...r],s):t}formatScore(t){const i=Number(this.scorefractiondigit)||2;return t.toLocaleString("en-US",{minimumFractionDigits:i,maximumFractionDigits:i})}async loadLeaderboardById(){if(this.abortController&&this.abortController.abort(),this.isLoadingMore)return;this.abortController=new AbortController,this.isLoadingMore=!0;let t=new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard?language=${this.language}`);t.searchParams.set("filter","includeUnqualifiedPlayer=true"),t.searchParams.set("pagination",`offset=${this.offset},limit=${this.limit}`),t.searchParams.set("platform",d());let i={headers:{"Content-Type":"application/json","x-SessionId":this.session},method:"GET",signal:this.abortController.signal};await fetch(t,i).then((t=>t.json())).then((i=>{var e;const{item:n,items:s,total:r}=i;if(this.isCurrentPlayerRanked=!!n,this.isCurrentPlayerRanked){if(this.currentUserData=n,this.currentUserData.formattedScore=this.formatScore(this.currentUserData.score),this.isLeaderboardLoading){if(this.offset>0)this.scrollCurrentPlayerToMiddle();else if(0===this.offset&&this.autoLocateCurrent&&this.currentUserData.rank>this.limit)return this.offset=this.currentUserData.rank-this.limit/2||0,this.leaderboardLoaded.emit({item:this.currentUserData,leaderboardOffset:this.offset,isRanked:!0,totalRank:r}),void this.loadLeaderboardById().catch(console.error)}else this.isLoadingPrevious&&this.resetScrollTop();this.shouldUpdateObserver=!0}this.total=r,this.leaderboardLoaded.emit({item:this.currentUserData,leaderboardOffset:this.offset,isRanked:this.isCurrentPlayerRanked,totalRank:r}),this.leaderboard=this.mergeSortedArrays(this.leaderboard,s,"rank"),null===(e=this.leaderboard)||void 0===e||e.forEach((t=>t.formattedScore=this.formatScore(t.score))),this.startScrollObersever(),this.reStartUpSSEUpdater(t),this.isLeaderboardLoading=!1}),(t=>{this.isLeaderboardLoading=!1,"AbortError"===t.name?console.log("Request aborted because a new one started or component unmounted."):console.error("Network error",t)})).finally((()=>{this.isLoadingMore=!1}))}startScrollObersever(){this.topLastTimer&&clearTimeout(this.topLastTimer),this.topLastTimer=setTimeout((()=>{this.total<=this.limit||(1!==this.leaderboard[0].rank&&this.startTopRankObserver(),this.leaderboard[this.leaderboard.length-1].rank<this.total&&this.startLastRankObserver())}),this.timeOrder2)}scrollCurrentPlayerToMiddle(){setTimeout((()=>{if(!this.tableListEle||!this.tableListEle.querySelectorAll(".Active").length)return;const t=this.tableListEle.querySelectorAll(".Active")[0],i=this.stylingContainer.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;let n=Math.min((e-i.top)/2-t.clientHeight,4*t.clientHeight);n=Math.max(n,t.clientHeight),this.tableListEle.scrollTo({top:t.offsetTop-n,behavior:"smooth"})}),this.timeOrder1)}onStateChanged(){switch(this.state){case"Closed":case"Closing":this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler),this.leaderboardUpdater=null)}}reStartUpSSEUpdater(t){var i;if(this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler)),"Running"!==this.state)return;t.searchParams.set("pagination",`offset=${this.leaderboard.length?this.leaderboard[0].rank-1:0},limit=${(null===(i=this.leaderboard)||void 0===i?void 0:i.length)>this.limit?this.leaderboard.length:this.limit}`);let e=new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard/updates?${t.searchParams.toString()}`);this.leaderboardUpdater=new v.exports.EventSourcePolyfill(e,{headers:{accept:"text/event-stream","X-SessionId":this.session}}),this.leaderboardUpdater.addEventListener("message",this.updateMessageHandler)}startActivePlayerObserver(){this.activePlayerObserver&&this.activePlayerEle&&this.activePlayerObserver.unobserve(this.activePlayerEle),this.activePlayerObserver=new IntersectionObserver((t=>{t.forEach((t=>{if(this.isCurrentPlayerInview=t.isIntersecting,!t.isIntersecting){const t=this.activePlayerEle.getBoundingClientRect();this.keepOnBottom||(this.isCurrentOnTop=t.top<this.stylingContainer.offsetTop)}}))})),this.activePlayerEle=this.tableListEle.querySelectorAll(".Active")[0],this.activePlayerObserver.observe(this.activePlayerEle)}startTopRankObserver(){this.topRankToObserved&&(this.topMoreObserver.unobserve(this.topRankToObserved),this.topRankToObserved=null),this.topMoreObserver||(this.topMoreObserver=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(this.loadPreMore(),this.topMoreObserver.unobserve(t.target))}))}))),setTimeout((()=>{var t;this.topRankToObserved=null===(t=this.tableListEle)||void 0===t?void 0:t.querySelector("#Rank_1"),this.topRankToObserved&&this.topMoreObserver.observe(this.topRankToObserved)}),this.timeOrder2)}startLastRankObserver(){var t;this.lastRankToObserved&&(this.loadMoreObserver.unobserve(this.lastRankToObserved),this.lastRankToObserved=null),this.loadMoreObserver||(this.loadMoreObserver=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(this.loadMore(),this.loadMoreObserver.unobserve(t.target))}))}))),this.lastRankToObserved=null===(t=this.tableListEle)||void 0===t?void 0:t.querySelector("#Rank_"+(this.leaderboard.length-1)),this.lastRankToObserved&&this.loadMoreObserver.observe(this.lastRankToObserved)}resetScrollTop(){this.isLoadingPrevious=!1,setTimeout((()=>{const t=this.tableListEle;t.scrollTop=this.previousScrollTop+(t.scrollHeight-this.previousScrollHeight)}),100)}loadPreMore(){var t;if((null===(t=this.leaderboard)||void 0===t?void 0:t.length)&&1===this.leaderboard[0].rank||this.isLoadingPrevious)return;this.offset=this.leaderboard[0].rank-1-this.limit||0;const i=this.tableListEle;this.previousScrollHeight=i.scrollHeight,this.previousScrollTop=i.scrollTop,this.isLoadingPrevious=!0,this.preTopRank=this.leaderboard[0].rank,this.loadLeaderboardById().catch(console.error)}loadMore(){var t;(null===(t=this.leaderboard)||void 0===t?void 0:t.length)>=this.total||(this.offset+=this.limit,this.offset=this.offset>this.total?this.total:this.offset,this.loadLeaderboardById().catch(console.error))}isElementInViewport(){const t=this.tableListEle.querySelector(".Active");if(!t)return!1;const i=t.getBoundingClientRect();return this.isCurrentOnTop=i.top<this.stylingContainer.offsetTop,i.top>=0&&i.top>this.stylingContainer.offsetTop&&i.bottom<=this.stylingContainer.offsetTop+this.stylingContainer.offsetHeight&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)}onTournamentIdChanged(){this.disconnectedCallback(),this.endpoint&&this.session&&!(this.session.length<10)&&this.tournamentId&&(this.isLeaderboardLoading=!0,this.resetLeaderboardStatus(),this.loadLeaderboardById().catch(console.error))}resetLeaderboardStatus(){this.offset=0,this.leaderboard=[]}async componentWillLoad(){switch(this.state){case"Running":this.loadLeaderboardById().catch(console.error);break;case"Unstarted":this.isLeaderboardLoading=!1,this.resetLeaderboardStatus()}this.translationUrl.length>2&&await h(this.translationUrl)}render(){var t;return e("div",{key:"15498957cba65f21cbae5c9fddd4a35283f9848c",class:`LeaderboardWrapper ${this.theme} ${this.isMobile?"Mobile":""}`,ref:t=>this.stylingContainer=t},this.isLeaderboardLoading?e("div",{class:"Loading"}," ",l("loading",this.language)," "):[e("div",null,!this.isCurrentPlayerInview&&this.isCurrentOnTop&&this.currentUserData&&e("div",{class:"PlayerRank Active"},e("div",{class:"Rank"},0===this.currentUserData.rank?"--":this.currentUserData.rank),e("div",{class:"Name"},l("you",this.language)),e("div",{class:"Score"},this.currentUserData.formattedScore),e("div",{class:"Prize"},this.currentUserData.prizeName))),this.isLoadingPrevious&&e("div",null,"Loading"),e("div",{class:"Leaderboard",onScroll:this.onLeaderboardScroll,onTouchMove:this.onLeaderboardScroll,ref:t=>this.tableListEle=t},(null===(t=this.leaderboard)||void 0===t?void 0:t.length)?this.leaderboard.map(((t,i)=>{var n,s;return e("div",{id:`Rank_${i}`,class:`PlayerRank ${this.isLoadingPrevious&&t.rank<this.preTopRank?"Hidden":""} ${(null===(n=this.currentUserData)||void 0===n?void 0:n.id)===t.id?"Active":""}`},e("div",{class:"Rank"},0===t.rank?"":t.rank),e("div",{class:"Name"},(null===(s=this.currentUserData)||void 0===s?void 0:s.id)===t.id?l("you",this.language):t.shortName),e("div",{class:"Score"},t.formattedScore),e("div",{class:"Prize"},t.prizeName))})):e("div",{class:"NoWinners"},e("div",{class:"Title"}," ",l("noLeaderboard",this.language)," "),e("div",{class:"Info"}," ",l("positionsWillShow",this.language)," "))),this.isLoadingMore&&!this.isLoadingPrevious&&e("div",null,"Loading"),!this.isCurrentPlayerInview&&e("div",{class:this.isCurrentOnTop?"":"Bottom"},!this.isCurrentOnTop&&this.currentUserData&&e("div",{class:"PlayerRank Active",onClick:this.goToCurrentPlayerPage},e("div",{class:"Rank"},0===this.currentUserData.rank?"--":this.currentUserData.rank),e("div",{class:"Name"},l("you",this.language)),e("div",{class:"Score"},this.currentUserData.formattedScore),e("div",{class:"Prize"},this.currentUserData.prizeName)))])}handleClientStylingChange(t,i){t!=i&&s(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,i){t!=i&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,i){t!=i&&o(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillRender(){this.isPageRendering=!0}componentDidRender(){this.isPageRendering=!1,this.shouldUpdateObserver&&(this.shouldUpdateObserver=!1,this.tableListEle&&this.tableListEle.querySelector(".Active")?this.startActivePlayerObserver():this.isCurrentPlayerInview=!1)}handleNewTranslations(){h(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&o(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&s(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&r(this.stylingContainer,this.clientStylingUrl)),this.isMobile="PC"!==d(),this.stylingContainer.addEventListener("touchmove",(t=>{t.stopPropagation(),t.preventDefault()}),{passive:!1})}disconnectedCallback(){this.abortController&&this.abortController.abort("Disconnected callback"),this.stylingSubscription&&this.stylingSubscription.unsubscribe(),this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler)),this.loadMoreObserver&&this.loadMoreObserver.disconnect(),this.topMoreObserver&&this.topMoreObserver.disconnect(),this.activePlayerObserver&&this.activePlayerObserver.disconnect(),this.tableListEle&&this.tableListEle.removeEventListener("scroll",this.handleTableListScroll)}static get watchers(){return{state:["onStateChanged"],tournamentId:["onTournamentIdChanged"],endpoint:["onTournamentIdChanged"],session:["onTournamentIdChanged"],language:["onTournamentIdChanged"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"],translationUrl:["handleNewTranslations"]}}};p.style=":host{display:block;height:100%}.Dark{color:var(--emw--ingame-color-text, #f5f8f6)}.Light{color:var(--emw--ingame-color-black, #0A0A17)}.Mobile.LeaderboardWrapper .Bottom .PlayerRank.Active{padding:2px 8px}.LeaderboardWrapper{height:100%;position:relative;overflow:hidden}.LeaderboardWrapper .Loading,.LeaderboardWrapper .Leaderboard,.LeaderboardWrapper .Bottom{width:calc(100% - 30px);padding:0 15px;scrollbar-width:thin}.LeaderboardWrapper .Loading,.LeaderboardWrapper .Leaderboard{padding-bottom:0}.LeaderboardWrapper .Bottom{position:absolute;bottom:0;background:linear-gradient(90deg, var(--emw--ingame-color-gray-purple50, rgba(35, 41, 119, 0.4980392157)) 0%, var(--emw--ingame-color-dark-purple50, rgba(59, 28, 117, 0.4980392157)) 100%);border-top:1px solid;border-image-source:linear-gradient(94.32deg, var(--emw--ingame-color-pth-primary1, #9500FF) 4.41%, var(--emw--ingame-color-pth-primary2, #232EC4) 113.86%);border-image-slice:1;backdrop-filter:blur(20px);opacity:0.91}.LeaderboardWrapper .Bottom .PlayerRank.Active{border-width:0;cursor:pointer;padding-right:18px;background:transparent}.LeaderboardWrapper .PlayerRank{overflow-anchor:auto;font-weight:bold;align-items:center;height:26px;gap:16px;padding:2px 8px;display:flex}.LeaderboardWrapper .PlayerRank.Hidden{display:none !important}.LeaderboardWrapper .PlayerRank.Active{background-clip:padding-box, border-box;background-origin:padding-box, border-box;border:1px solid transparent;border-radius:10px;background-image:linear-gradient(91deg, var(--emw--ingame-color-pth-primary4, #11153E) 4.41%, var(--emw--ingame-color-pth-primary4, #11153E) 113.86%), linear-gradient(91deg, var(--emw--ingame-color-pth-primary1, #9500FF) 4.41%, var(--emw--ingame-color-pth-primary2, #232EC4) 113.86%)}.LeaderboardWrapper .PlayerRank div{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.LeaderboardWrapper .PlayerRank .Rank{flex:1}.LeaderboardWrapper .PlayerRank .Name{flex:2;text-align:left}.LeaderboardWrapper .PlayerRank .Score{flex:1;font-weight:normal;text-align:right;overflow:visible;min-width:50px}.LeaderboardWrapper .PlayerRank .Prize{flex:4;overflow:hidden}.LeaderboardWrapper .Leaderboard{height:calc(100% - 2px) !important;overflow-y:auto;overflow-anchor:auto;touch-action:pan-y}.LeaderboardWrapper .Leaderboard .NoWinners{margin:30px auto;display:flex;flex-direction:column;gap:15px}.LeaderboardWrapper .Leaderboard .NoWinners .Title{font-weight:bold;font-size:medium}.LeaderboardWrapper .Leaderboard .NoWinners .Title,.LeaderboardWrapper .Leaderboard .NoWinners .Info{display:flex;align-items:center;flex-direction:column}";export{p as C}
@@ -1 +1 @@
1
- export{C as casino_tournaments_ingame_table}from"./casino-tournaments-ingame-table-aac2043e.js";import"./index-448538d5.js";
1
+ export{C as casino_tournaments_ingame_table}from"./casino-tournaments-ingame-table-27a040da.js";import"./index-448538d5.js";
@@ -1 +1 @@
1
- export{C as CasinoTournamentsIngameTable}from"./casino-tournaments-ingame-table-aac2043e.js";import"./index-448538d5.js";
1
+ export{C as CasinoTournamentsIngameTable}from"./casino-tournaments-ingame-table-27a040da.js";import"./index-448538d5.js";
@@ -1239,6 +1239,54 @@ const CasinoTournamentsIngameTable = class {
1239
1239
  this.autoLocateCurrent = false;
1240
1240
  //Current player will not change the position when scroll current player up
1241
1241
  this.keepOnBottom = true;
1242
+ this.shouldUpdateObserver = false;
1243
+ this.onLeaderboardScroll = (event) => {
1244
+ event.stopPropagation();
1245
+ if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
1246
+ event.preventDefault();
1247
+ }
1248
+ };
1249
+ this.updateMessageHandler = (message) => {
1250
+ if (!message.data) {
1251
+ return;
1252
+ }
1253
+ const data = JSON.parse(message.data);
1254
+ if (data.messageType === 'LeaderBoardUpdate') {
1255
+ const { item, items, total } = data;
1256
+ if (item || this.currentUserData) {
1257
+ this.currentUserData = item ? item : this.currentUserData;
1258
+ this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
1259
+ }
1260
+ this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
1261
+ items.forEach(e => {
1262
+ const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
1263
+ rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
1264
+ e.formattedScore = this.formatScore(e.score);
1265
+ if (rankIdx < 0) {
1266
+ this.leaderboard.push(e);
1267
+ }
1268
+ else {
1269
+ this.leaderboard[rankIdx] = e;
1270
+ }
1271
+ });
1272
+ this.leaderboard = [...this.leaderboard];
1273
+ this.shouldUpdateObserver = true;
1274
+ }
1275
+ };
1276
+ this.goToCurrentPlayerPage = () => {
1277
+ if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
1278
+ this.scrollCurrentPlayerToMiddle();
1279
+ return;
1280
+ }
1281
+ this.offset = this.currentUserData.rank - this.limit / 2 || 0;
1282
+ this.leaderboard = [];
1283
+ this.isLeaderboardLoading = true;
1284
+ this.loadLeaderboardById().catch(console.error);
1285
+ this.isCurrentPlayerInview = true;
1286
+ };
1287
+ this.handleTableListScroll = () => {
1288
+ this.isCurrentPlayerInview = this.isElementInViewport();
1289
+ };
1242
1290
  this.isPageRendering = false;
1243
1291
  this.mbSource = undefined;
1244
1292
  this.clientStyling = undefined;
@@ -1315,12 +1363,6 @@ const CasinoTournamentsIngameTable = class {
1315
1363
  }
1316
1364
  return result;
1317
1365
  }
1318
- onLeaderboardScroll(event) {
1319
- event.stopPropagation();
1320
- if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
1321
- event.preventDefault();
1322
- }
1323
- }
1324
1366
  formatScore(score) {
1325
1367
  const _fractiondigit = Number(this.scorefractiondigit) || 2;
1326
1368
  return score.toLocaleString('en-US', {
@@ -1372,14 +1414,7 @@ const CasinoTournamentsIngameTable = class {
1372
1414
  else {
1373
1415
  this.isLoadingPrevious && this.resetScrollTop();
1374
1416
  }
1375
- setTimeout(() => {
1376
- if (this.tableListEle && this.tableListEle.querySelectorAll(`.Active`).length) {
1377
- this.startActivePlayerObserver();
1378
- }
1379
- else {
1380
- this.isCurrentPlayerInview = false;
1381
- }
1382
- }, this.timeOrder2);
1417
+ this.shouldUpdateObserver = true;
1383
1418
  }
1384
1419
  this.total = total;
1385
1420
  this.leaderboardLoaded.emit({ item: this.currentUserData, leaderboardOffset: this.offset, isRanked: this.isCurrentPlayerRanked, totalRank: total });
@@ -1457,33 +1492,7 @@ const CasinoTournamentsIngameTable = class {
1457
1492
  let endpointUrl = new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard/updates?${url.searchParams.toString()}`);
1458
1493
  const options = { headers: { 'accept': 'text/event-stream', 'X-SessionId': this.session } };
1459
1494
  this.leaderboardUpdater = new eventsource.exports.EventSourcePolyfill(endpointUrl, options);
1460
- this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler.bind(this));
1461
- }
1462
- updateMessageHandler(message) {
1463
- if (!message.data) {
1464
- return;
1465
- }
1466
- const data = JSON.parse(message.data);
1467
- if (data.messageType === 'LeaderBoardUpdate') {
1468
- const { item, items, total } = data;
1469
- if (item || this.currentUserData) {
1470
- this.currentUserData = item ? item : this.currentUserData;
1471
- this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
1472
- }
1473
- this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
1474
- items.forEach(e => {
1475
- const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
1476
- rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
1477
- e.formattedScore = this.formatScore(e.score);
1478
- if (rankIdx < 0) {
1479
- this.leaderboard.push(e);
1480
- }
1481
- else {
1482
- this.leaderboard[rankIdx] = e;
1483
- }
1484
- });
1485
- this.leaderboard = [...this.leaderboard];
1486
- }
1495
+ this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler);
1487
1496
  }
1488
1497
  startActivePlayerObserver() {
1489
1498
  if (this.activePlayerObserver && this.activePlayerEle) {
@@ -1565,17 +1574,6 @@ const CasinoTournamentsIngameTable = class {
1565
1574
  this.preTopRank = this.leaderboard[0].rank;
1566
1575
  this.loadLeaderboardById().catch(console.error);
1567
1576
  }
1568
- goToCurrentPlayerPage() {
1569
- if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
1570
- this.scrollCurrentPlayerToMiddle();
1571
- return;
1572
- }
1573
- this.offset = this.currentUserData.rank - this.limit / 2 || 0;
1574
- this.leaderboard = [];
1575
- this.isLeaderboardLoading = true;
1576
- this.loadLeaderboardById().catch(console.error);
1577
- this.isCurrentPlayerInview = true;
1578
- }
1579
1577
  loadMore() {
1580
1578
  var _a;
1581
1579
  if (((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length) >= this.total) {
@@ -1585,9 +1583,6 @@ const CasinoTournamentsIngameTable = class {
1585
1583
  this.offset = this.offset > this.total ? this.total : this.offset;
1586
1584
  this.loadLeaderboardById().catch(console.error);
1587
1585
  }
1588
- handleTableListScroll() {
1589
- this.isCurrentPlayerInview = this.isElementInViewport();
1590
- }
1591
1586
  isElementInViewport() {
1592
1587
  const activePlayerRow = this.tableListEle.querySelector(`.Active`);
1593
1588
  if (!activePlayerRow) {
@@ -1628,12 +1623,12 @@ const CasinoTournamentsIngameTable = class {
1628
1623
  }
1629
1624
  render() {
1630
1625
  var _a;
1631
- return index.h("div", { key: '26150cc5aa004ca610b2c849e2549a3f584a8d60', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? index.h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
1626
+ return index.h("div", { key: '15498957cba65f21cbae5c9fddd4a35283f9848c', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? index.h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
1632
1627
  [
1633
1628
  index.h("div", null, (!this.isCurrentPlayerInview && this.isCurrentOnTop) && this.currentUserData &&
1634
1629
  index.h("div", { class: `PlayerRank Active` }, index.h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), index.h("div", { class: 'Name' }, translate('you', this.language)), index.h("div", { class: 'Score' }, this.currentUserData.formattedScore), index.h("div", { class: 'Prize' }, this.currentUserData.prizeName))),
1635
1630
  this.isLoadingPrevious && index.h("div", null, "Loading"),
1636
- index.h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll.bind(this), onTouchMove: this.onLeaderboardScroll.bind(this), ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
1631
+ index.h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll, onTouchMove: this.onLeaderboardScroll, ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
1637
1632
  ? index.h("div", { class: 'NoWinners' }, index.h("div", { class: 'Title' }, " ", translate('noLeaderboard', this.language), " "), index.h("div", { class: 'Info' }, " ", translate('positionsWillShow', this.language), " "))
1638
1633
  : this.leaderboard.map((item, idx) => {
1639
1634
  var _a, _b;
@@ -1642,7 +1637,7 @@ const CasinoTournamentsIngameTable = class {
1642
1637
  this.isLoadingMore && !this.isLoadingPrevious && index.h("div", null, "Loading"),
1643
1638
  !this.isCurrentPlayerInview &&
1644
1639
  index.h("div", { class: !this.isCurrentOnTop ? 'Bottom' : '' }, !this.isCurrentOnTop && this.currentUserData &&
1645
- index.h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage.bind(this) }, index.h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), index.h("div", { class: 'Name' }, translate('you', this.language)), index.h("div", { class: 'Score' }, this.currentUserData.formattedScore), index.h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
1640
+ index.h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage }, index.h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), index.h("div", { class: 'Name' }, translate('you', this.language)), index.h("div", { class: 'Score' }, this.currentUserData.formattedScore), index.h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
1646
1641
  ]);
1647
1642
  }
1648
1643
  handleClientStylingChange(newValue, oldValue) {
@@ -1665,6 +1660,17 @@ const CasinoTournamentsIngameTable = class {
1665
1660
  }
1666
1661
  componentDidRender() {
1667
1662
  this.isPageRendering = false;
1663
+ // Check if we scheduled an observer update
1664
+ if (this.shouldUpdateObserver) {
1665
+ this.shouldUpdateObserver = false;
1666
+ // Ensure the DOM element actually exists before trying to observe it
1667
+ if (this.tableListEle && this.tableListEle.querySelector('.Active')) {
1668
+ this.startActivePlayerObserver();
1669
+ }
1670
+ else {
1671
+ this.isCurrentPlayerInview = false;
1672
+ }
1673
+ }
1668
1674
  }
1669
1675
  handleNewTranslations() {
1670
1676
  getTranslations(this.translationUrl);
@@ -1697,7 +1703,7 @@ const CasinoTournamentsIngameTable = class {
1697
1703
  this.topMoreObserver && this.topMoreObserver.disconnect();
1698
1704
  this.activePlayerObserver && this.activePlayerObserver.disconnect();
1699
1705
  if (this.tableListEle) {
1700
- this.tableListEle.removeEventListener('scroll', this.handleTableListScroll.bind(this));
1706
+ this.tableListEle.removeEventListener('scroll', this.handleTableListScroll);
1701
1707
  }
1702
1708
  }
1703
1709
  static get watchers() { return {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoTournamentsIngameTable = require('./casino-tournaments-ingame-table-5897b13b.js');
5
+ const casinoTournamentsIngameTable = require('./casino-tournaments-ingame-table-8e663fa2.js');
6
6
  require('./index-666544d1.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoTournamentsIngameTable = require('./casino-tournaments-ingame-table-5897b13b.js');
5
+ const casinoTournamentsIngameTable = require('./casino-tournaments-ingame-table-8e663fa2.js');
6
6
  require('./index-666544d1.js');
7
7
 
8
8
 
@@ -16,6 +16,54 @@ export class CasinoTournamentsIngameTable {
16
16
  this.autoLocateCurrent = false;
17
17
  //Current player will not change the position when scroll current player up
18
18
  this.keepOnBottom = true;
19
+ this.shouldUpdateObserver = false;
20
+ this.onLeaderboardScroll = (event) => {
21
+ event.stopPropagation();
22
+ if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
23
+ event.preventDefault();
24
+ }
25
+ };
26
+ this.updateMessageHandler = (message) => {
27
+ if (!message.data) {
28
+ return;
29
+ }
30
+ const data = JSON.parse(message.data);
31
+ if (data.messageType === 'LeaderBoardUpdate') {
32
+ const { item, items, total } = data;
33
+ if (item || this.currentUserData) {
34
+ this.currentUserData = item ? item : this.currentUserData;
35
+ this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
36
+ }
37
+ this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
38
+ items.forEach(e => {
39
+ const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
40
+ rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
41
+ e.formattedScore = this.formatScore(e.score);
42
+ if (rankIdx < 0) {
43
+ this.leaderboard.push(e);
44
+ }
45
+ else {
46
+ this.leaderboard[rankIdx] = e;
47
+ }
48
+ });
49
+ this.leaderboard = [...this.leaderboard];
50
+ this.shouldUpdateObserver = true;
51
+ }
52
+ };
53
+ this.goToCurrentPlayerPage = () => {
54
+ if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
55
+ this.scrollCurrentPlayerToMiddle();
56
+ return;
57
+ }
58
+ this.offset = this.currentUserData.rank - this.limit / 2 || 0;
59
+ this.leaderboard = [];
60
+ this.isLeaderboardLoading = true;
61
+ this.loadLeaderboardById().catch(console.error);
62
+ this.isCurrentPlayerInview = true;
63
+ };
64
+ this.handleTableListScroll = () => {
65
+ this.isCurrentPlayerInview = this.isElementInViewport();
66
+ };
19
67
  this.isPageRendering = false;
20
68
  this.mbSource = undefined;
21
69
  this.clientStyling = undefined;
@@ -92,12 +140,6 @@ export class CasinoTournamentsIngameTable {
92
140
  }
93
141
  return result;
94
142
  }
95
- onLeaderboardScroll(event) {
96
- event.stopPropagation();
97
- if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
98
- event.preventDefault();
99
- }
100
- }
101
143
  formatScore(score) {
102
144
  const _fractiondigit = Number(this.scorefractiondigit) || 2;
103
145
  return score.toLocaleString('en-US', {
@@ -149,14 +191,7 @@ export class CasinoTournamentsIngameTable {
149
191
  else {
150
192
  this.isLoadingPrevious && this.resetScrollTop();
151
193
  }
152
- setTimeout(() => {
153
- if (this.tableListEle && this.tableListEle.querySelectorAll(`.Active`).length) {
154
- this.startActivePlayerObserver();
155
- }
156
- else {
157
- this.isCurrentPlayerInview = false;
158
- }
159
- }, this.timeOrder2);
194
+ this.shouldUpdateObserver = true;
160
195
  }
161
196
  this.total = total;
162
197
  this.leaderboardLoaded.emit({ item: this.currentUserData, leaderboardOffset: this.offset, isRanked: this.isCurrentPlayerRanked, totalRank: total });
@@ -235,33 +270,7 @@ export class CasinoTournamentsIngameTable {
235
270
  let endpointUrl = new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard/updates?${url.searchParams.toString()}`);
236
271
  const options = { headers: { 'accept': 'text/event-stream', 'X-SessionId': this.session } };
237
272
  this.leaderboardUpdater = new EventSourcePolyfill(endpointUrl, options);
238
- this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler.bind(this));
239
- }
240
- updateMessageHandler(message) {
241
- if (!message.data) {
242
- return;
243
- }
244
- const data = JSON.parse(message.data);
245
- if (data.messageType === 'LeaderBoardUpdate') {
246
- const { item, items, total } = data;
247
- if (item || this.currentUserData) {
248
- this.currentUserData = item ? item : this.currentUserData;
249
- this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
250
- }
251
- this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
252
- items.forEach(e => {
253
- const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
254
- rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
255
- e.formattedScore = this.formatScore(e.score);
256
- if (rankIdx < 0) {
257
- this.leaderboard.push(e);
258
- }
259
- else {
260
- this.leaderboard[rankIdx] = e;
261
- }
262
- });
263
- this.leaderboard = [...this.leaderboard];
264
- }
273
+ this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler);
265
274
  }
266
275
  startActivePlayerObserver() {
267
276
  if (this.activePlayerObserver && this.activePlayerEle) {
@@ -343,17 +352,6 @@ export class CasinoTournamentsIngameTable {
343
352
  this.preTopRank = this.leaderboard[0].rank;
344
353
  this.loadLeaderboardById().catch(console.error);
345
354
  }
346
- goToCurrentPlayerPage() {
347
- if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
348
- this.scrollCurrentPlayerToMiddle();
349
- return;
350
- }
351
- this.offset = this.currentUserData.rank - this.limit / 2 || 0;
352
- this.leaderboard = [];
353
- this.isLeaderboardLoading = true;
354
- this.loadLeaderboardById().catch(console.error);
355
- this.isCurrentPlayerInview = true;
356
- }
357
355
  loadMore() {
358
356
  var _a;
359
357
  if (((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length) >= this.total) {
@@ -363,9 +361,6 @@ export class CasinoTournamentsIngameTable {
363
361
  this.offset = this.offset > this.total ? this.total : this.offset;
364
362
  this.loadLeaderboardById().catch(console.error);
365
363
  }
366
- handleTableListScroll() {
367
- this.isCurrentPlayerInview = this.isElementInViewport();
368
- }
369
364
  isElementInViewport() {
370
365
  const activePlayerRow = this.tableListEle.querySelector(`.Active`);
371
366
  if (!activePlayerRow) {
@@ -407,12 +402,12 @@ export class CasinoTournamentsIngameTable {
407
402
  }
408
403
  render() {
409
404
  var _a;
410
- return h("div", { key: '26150cc5aa004ca610b2c849e2549a3f584a8d60', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
405
+ return h("div", { key: '15498957cba65f21cbae5c9fddd4a35283f9848c', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
411
406
  [
412
407
  h("div", null, (!this.isCurrentPlayerInview && this.isCurrentOnTop) && this.currentUserData &&
413
408
  h("div", { class: `PlayerRank Active` }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName))),
414
409
  this.isLoadingPrevious && h("div", null, "Loading"),
415
- h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll.bind(this), onTouchMove: this.onLeaderboardScroll.bind(this), ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
410
+ h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll, onTouchMove: this.onLeaderboardScroll, ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
416
411
  ? h("div", { class: 'NoWinners' }, h("div", { class: 'Title' }, " ", translate('noLeaderboard', this.language), " "), h("div", { class: 'Info' }, " ", translate('positionsWillShow', this.language), " "))
417
412
  : this.leaderboard.map((item, idx) => {
418
413
  var _a, _b;
@@ -421,7 +416,7 @@ export class CasinoTournamentsIngameTable {
421
416
  this.isLoadingMore && !this.isLoadingPrevious && h("div", null, "Loading"),
422
417
  !this.isCurrentPlayerInview &&
423
418
  h("div", { class: !this.isCurrentOnTop ? 'Bottom' : '' }, !this.isCurrentOnTop && this.currentUserData &&
424
- h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage.bind(this) }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
419
+ h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
425
420
  ]);
426
421
  }
427
422
  handleClientStylingChange(newValue, oldValue) {
@@ -444,6 +439,17 @@ export class CasinoTournamentsIngameTable {
444
439
  }
445
440
  componentDidRender() {
446
441
  this.isPageRendering = false;
442
+ // Check if we scheduled an observer update
443
+ if (this.shouldUpdateObserver) {
444
+ this.shouldUpdateObserver = false;
445
+ // Ensure the DOM element actually exists before trying to observe it
446
+ if (this.tableListEle && this.tableListEle.querySelector('.Active')) {
447
+ this.startActivePlayerObserver();
448
+ }
449
+ else {
450
+ this.isCurrentPlayerInview = false;
451
+ }
452
+ }
447
453
  }
448
454
  handleNewTranslations() {
449
455
  getTranslations(this.translationUrl);
@@ -476,7 +482,7 @@ export class CasinoTournamentsIngameTable {
476
482
  this.topMoreObserver && this.topMoreObserver.disconnect();
477
483
  this.activePlayerObserver && this.activePlayerObserver.disconnect();
478
484
  if (this.tableListEle) {
479
- this.tableListEle.removeEventListener('scroll', this.handleTableListScroll.bind(this));
485
+ this.tableListEle.removeEventListener('scroll', this.handleTableListScroll);
480
486
  }
481
487
  }
482
488
  static get is() { return "casino-tournaments-ingame-table"; }
@@ -1237,6 +1237,54 @@ const CasinoTournamentsIngameTable = class {
1237
1237
  this.autoLocateCurrent = false;
1238
1238
  //Current player will not change the position when scroll current player up
1239
1239
  this.keepOnBottom = true;
1240
+ this.shouldUpdateObserver = false;
1241
+ this.onLeaderboardScroll = (event) => {
1242
+ event.stopPropagation();
1243
+ if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
1244
+ event.preventDefault();
1245
+ }
1246
+ };
1247
+ this.updateMessageHandler = (message) => {
1248
+ if (!message.data) {
1249
+ return;
1250
+ }
1251
+ const data = JSON.parse(message.data);
1252
+ if (data.messageType === 'LeaderBoardUpdate') {
1253
+ const { item, items, total } = data;
1254
+ if (item || this.currentUserData) {
1255
+ this.currentUserData = item ? item : this.currentUserData;
1256
+ this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
1257
+ }
1258
+ this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
1259
+ items.forEach(e => {
1260
+ const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
1261
+ rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
1262
+ e.formattedScore = this.formatScore(e.score);
1263
+ if (rankIdx < 0) {
1264
+ this.leaderboard.push(e);
1265
+ }
1266
+ else {
1267
+ this.leaderboard[rankIdx] = e;
1268
+ }
1269
+ });
1270
+ this.leaderboard = [...this.leaderboard];
1271
+ this.shouldUpdateObserver = true;
1272
+ }
1273
+ };
1274
+ this.goToCurrentPlayerPage = () => {
1275
+ if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
1276
+ this.scrollCurrentPlayerToMiddle();
1277
+ return;
1278
+ }
1279
+ this.offset = this.currentUserData.rank - this.limit / 2 || 0;
1280
+ this.leaderboard = [];
1281
+ this.isLeaderboardLoading = true;
1282
+ this.loadLeaderboardById().catch(console.error);
1283
+ this.isCurrentPlayerInview = true;
1284
+ };
1285
+ this.handleTableListScroll = () => {
1286
+ this.isCurrentPlayerInview = this.isElementInViewport();
1287
+ };
1240
1288
  this.isPageRendering = false;
1241
1289
  this.mbSource = undefined;
1242
1290
  this.clientStyling = undefined;
@@ -1313,12 +1361,6 @@ const CasinoTournamentsIngameTable = class {
1313
1361
  }
1314
1362
  return result;
1315
1363
  }
1316
- onLeaderboardScroll(event) {
1317
- event.stopPropagation();
1318
- if (this.isLoadingPrevious || this.isLoadingMore || this.isPageRendering) {
1319
- event.preventDefault();
1320
- }
1321
- }
1322
1364
  formatScore(score) {
1323
1365
  const _fractiondigit = Number(this.scorefractiondigit) || 2;
1324
1366
  return score.toLocaleString('en-US', {
@@ -1370,14 +1412,7 @@ const CasinoTournamentsIngameTable = class {
1370
1412
  else {
1371
1413
  this.isLoadingPrevious && this.resetScrollTop();
1372
1414
  }
1373
- setTimeout(() => {
1374
- if (this.tableListEle && this.tableListEle.querySelectorAll(`.Active`).length) {
1375
- this.startActivePlayerObserver();
1376
- }
1377
- else {
1378
- this.isCurrentPlayerInview = false;
1379
- }
1380
- }, this.timeOrder2);
1415
+ this.shouldUpdateObserver = true;
1381
1416
  }
1382
1417
  this.total = total;
1383
1418
  this.leaderboardLoaded.emit({ item: this.currentUserData, leaderboardOffset: this.offset, isRanked: this.isCurrentPlayerRanked, totalRank: total });
@@ -1455,33 +1490,7 @@ const CasinoTournamentsIngameTable = class {
1455
1490
  let endpointUrl = new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard/updates?${url.searchParams.toString()}`);
1456
1491
  const options = { headers: { 'accept': 'text/event-stream', 'X-SessionId': this.session } };
1457
1492
  this.leaderboardUpdater = new eventsource.exports.EventSourcePolyfill(endpointUrl, options);
1458
- this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler.bind(this));
1459
- }
1460
- updateMessageHandler(message) {
1461
- if (!message.data) {
1462
- return;
1463
- }
1464
- const data = JSON.parse(message.data);
1465
- if (data.messageType === 'LeaderBoardUpdate') {
1466
- const { item, items, total } = data;
1467
- if (item || this.currentUserData) {
1468
- this.currentUserData = item ? item : this.currentUserData;
1469
- this.currentUserData.formattedScore = this.formatScore(this.currentUserData.score);
1470
- }
1471
- this.leaderboardLoaded.emit({ item: this.currentUserData ? this.currentUserData : null, isRanked: !!item, totalRank: total });
1472
- items.forEach(e => {
1473
- const rankIdx = this.leaderboard.findIndex(rank => rank.rank === e.rank);
1474
- rankIdx >= 0 && (this.leaderboard[rankIdx] = e);
1475
- e.formattedScore = this.formatScore(e.score);
1476
- if (rankIdx < 0) {
1477
- this.leaderboard.push(e);
1478
- }
1479
- else {
1480
- this.leaderboard[rankIdx] = e;
1481
- }
1482
- });
1483
- this.leaderboard = [...this.leaderboard];
1484
- }
1493
+ this.leaderboardUpdater.addEventListener('message', this.updateMessageHandler);
1485
1494
  }
1486
1495
  startActivePlayerObserver() {
1487
1496
  if (this.activePlayerObserver && this.activePlayerEle) {
@@ -1563,17 +1572,6 @@ const CasinoTournamentsIngameTable = class {
1563
1572
  this.preTopRank = this.leaderboard[0].rank;
1564
1573
  this.loadLeaderboardById().catch(console.error);
1565
1574
  }
1566
- goToCurrentPlayerPage() {
1567
- if (this.leaderboard.findIndex(item => item.id === this.currentUserData.id) >= 0) {
1568
- this.scrollCurrentPlayerToMiddle();
1569
- return;
1570
- }
1571
- this.offset = this.currentUserData.rank - this.limit / 2 || 0;
1572
- this.leaderboard = [];
1573
- this.isLeaderboardLoading = true;
1574
- this.loadLeaderboardById().catch(console.error);
1575
- this.isCurrentPlayerInview = true;
1576
- }
1577
1575
  loadMore() {
1578
1576
  var _a;
1579
1577
  if (((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length) >= this.total) {
@@ -1583,9 +1581,6 @@ const CasinoTournamentsIngameTable = class {
1583
1581
  this.offset = this.offset > this.total ? this.total : this.offset;
1584
1582
  this.loadLeaderboardById().catch(console.error);
1585
1583
  }
1586
- handleTableListScroll() {
1587
- this.isCurrentPlayerInview = this.isElementInViewport();
1588
- }
1589
1584
  isElementInViewport() {
1590
1585
  const activePlayerRow = this.tableListEle.querySelector(`.Active`);
1591
1586
  if (!activePlayerRow) {
@@ -1626,12 +1621,12 @@ const CasinoTournamentsIngameTable = class {
1626
1621
  }
1627
1622
  render() {
1628
1623
  var _a;
1629
- return h("div", { key: '26150cc5aa004ca610b2c849e2549a3f584a8d60', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
1624
+ return h("div", { key: '15498957cba65f21cbae5c9fddd4a35283f9848c', class: `LeaderboardWrapper ${this.theme} ${this.isMobile ? 'Mobile' : ''}`, ref: (el) => (this.stylingContainer = el) }, this.isLeaderboardLoading ? h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ") :
1630
1625
  [
1631
1626
  h("div", null, (!this.isCurrentPlayerInview && this.isCurrentOnTop) && this.currentUserData &&
1632
1627
  h("div", { class: `PlayerRank Active` }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName))),
1633
1628
  this.isLoadingPrevious && h("div", null, "Loading"),
1634
- h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll.bind(this), onTouchMove: this.onLeaderboardScroll.bind(this), ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
1629
+ h("div", { class: 'Leaderboard', onScroll: this.onLeaderboardScroll, onTouchMove: this.onLeaderboardScroll, ref: (el) => (this.tableListEle = el) }, !((_a = this.leaderboard) === null || _a === void 0 ? void 0 : _a.length)
1635
1630
  ? h("div", { class: 'NoWinners' }, h("div", { class: 'Title' }, " ", translate('noLeaderboard', this.language), " "), h("div", { class: 'Info' }, " ", translate('positionsWillShow', this.language), " "))
1636
1631
  : this.leaderboard.map((item, idx) => {
1637
1632
  var _a, _b;
@@ -1640,7 +1635,7 @@ const CasinoTournamentsIngameTable = class {
1640
1635
  this.isLoadingMore && !this.isLoadingPrevious && h("div", null, "Loading"),
1641
1636
  !this.isCurrentPlayerInview &&
1642
1637
  h("div", { class: !this.isCurrentOnTop ? 'Bottom' : '' }, !this.isCurrentOnTop && this.currentUserData &&
1643
- h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage.bind(this) }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
1638
+ h("div", { class: `PlayerRank Active`, onClick: this.goToCurrentPlayerPage }, h("div", { class: 'Rank' }, this.currentUserData.rank === 0 ? '--' : this.currentUserData.rank), h("div", { class: 'Name' }, translate('you', this.language)), h("div", { class: 'Score' }, this.currentUserData.formattedScore), h("div", { class: 'Prize' }, this.currentUserData.prizeName)))
1644
1639
  ]);
1645
1640
  }
1646
1641
  handleClientStylingChange(newValue, oldValue) {
@@ -1663,6 +1658,17 @@ const CasinoTournamentsIngameTable = class {
1663
1658
  }
1664
1659
  componentDidRender() {
1665
1660
  this.isPageRendering = false;
1661
+ // Check if we scheduled an observer update
1662
+ if (this.shouldUpdateObserver) {
1663
+ this.shouldUpdateObserver = false;
1664
+ // Ensure the DOM element actually exists before trying to observe it
1665
+ if (this.tableListEle && this.tableListEle.querySelector('.Active')) {
1666
+ this.startActivePlayerObserver();
1667
+ }
1668
+ else {
1669
+ this.isCurrentPlayerInview = false;
1670
+ }
1671
+ }
1666
1672
  }
1667
1673
  handleNewTranslations() {
1668
1674
  getTranslations(this.translationUrl);
@@ -1695,7 +1701,7 @@ const CasinoTournamentsIngameTable = class {
1695
1701
  this.topMoreObserver && this.topMoreObserver.disconnect();
1696
1702
  this.activePlayerObserver && this.activePlayerObserver.disconnect();
1697
1703
  if (this.tableListEle) {
1698
- this.tableListEle.removeEventListener('scroll', this.handleTableListScroll.bind(this));
1704
+ this.tableListEle.removeEventListener('scroll', this.handleTableListScroll);
1699
1705
  }
1700
1706
  }
1701
1707
  static get watchers() { return {
@@ -1,2 +1,2 @@
1
- export { C as casino_tournaments_ingame_table } from './casino-tournaments-ingame-table-aac2043e.js';
1
+ export { C as casino_tournaments_ingame_table } from './casino-tournaments-ingame-table-27a040da.js';
2
2
  import './index-448538d5.js';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { C as CasinoTournamentsIngameTable } from './casino-tournaments-ingame-table-aac2043e.js';
1
+ export { C as CasinoTournamentsIngameTable } from './casino-tournaments-ingame-table-27a040da.js';
2
2
  import './index-448538d5.js';
@@ -44,6 +44,7 @@ export declare class CasinoTournamentsIngameTable {
44
44
  private autoLocateCurrent;
45
45
  private keepOnBottom;
46
46
  private topLastTimer;
47
+ private shouldUpdateObserver;
47
48
  /**
48
49
  * oriArr:
49
50
  * [{rank: 15, playerName: xxx, prize: xxx},
@@ -62,14 +63,14 @@ export declare class CasinoTournamentsIngameTable {
62
63
  * @param order
63
64
  */
64
65
  mergeSortedArrays(originalArray: any[], newArray: any[], order: string): any[];
65
- onLeaderboardScroll(event: Event): void;
66
+ onLeaderboardScroll: (event: Event) => void;
66
67
  formatScore(score: any): any;
67
68
  loadLeaderboardById(): Promise<void>;
68
69
  startScrollObersever(): void;
69
70
  scrollCurrentPlayerToMiddle(): void;
70
71
  onStateChanged(): void;
71
72
  reStartUpSSEUpdater(url: URL): void;
72
- updateMessageHandler(message: any): void;
73
+ updateMessageHandler: (message: any) => void;
73
74
  startActivePlayerObserver(): void;
74
75
  startTopRankObserver(): void;
75
76
  startLastRankObserver(): void;
@@ -78,9 +79,9 @@ export declare class CasinoTournamentsIngameTable {
78
79
  preTopRank: number;
79
80
  resetScrollTop(): void;
80
81
  loadPreMore(): void;
81
- goToCurrentPlayerPage(): void;
82
+ goToCurrentPlayerPage: () => void;
82
83
  loadMore(): void;
83
- handleTableListScroll(): void;
84
+ handleTableListScroll: () => void;
84
85
  isElementInViewport(): boolean;
85
86
  onTournamentIdChanged(): void;
86
87
  resetLeaderboardStatus(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-tournaments-ingame-table",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1,7 +0,0 @@
1
- import{r as t,c as i,h as e}from"./index-448538d5.js";const n="__WIDGET_GLOBAL_STYLE_CACHE__";function s(t,i){if(t){const e=document.createElement("style");e.innerHTML=i,t.appendChild(e)}}function r(t,i){if(!t||!i)return;const e=new URL(i);fetch(e.href).then((t=>t.text())).then((i=>{const e=document.createElement("style");e.innerHTML=i,t&&t.appendChild(e)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}function o(t,i,e,s=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!s)return e=function(t,i){const e=document.createElement("style");return window.emMessageBus.subscribe(i,(i=>{t&&(e.innerHTML=i,t.appendChild(e))}))}(t,i),e;window[n]||(window[n]={}),e=function(t,i){return window.emMessageBus.subscribe(i,(e=>{if(!t)return;const s=t.getRootNode(),r=window[n];let o=r[i]&&r[i].sheet;o?r[i].refCount=r[i].refCount+1:(o=new CSSStyleSheet,o.replaceSync(e),r[i]={sheet:o,refCount:1});const a=s.adoptedStyleSheets||[];a.includes(o)||(s.adoptedStyleSheets=[...a,o])}))}(t,i);const r=e.unsubscribe.bind(e);return e.unsubscribe=()=>{if(window[n][i]){const t=window[n][i];t.refCount>1?t.refCount=t.refCount-1:delete window[n][i]}r()},e}const a={en:{you:"You",loading:"Loading, please wait ...",leaderboard:"Leaderboard",nowinners:"No winners for the time being. Be one of them!",noLeaderboard:"No Leaderboard yet",positionsWillShow:"Player positions will appear here once scores are recorded."}},h=t=>new Promise((i=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((i=>{a[i]||(a[i]={});for(let e in t[i])a[i][e]=t[i][e]})),i(!0)}))})),l=(t,i,e)=>{let n=a[void 0!==i&&i in a?i:"en"][t];if(void 0!==e)for(const[t,i]of Object.entries(e.values)){const e=new RegExp(`{${t}}`,"g");n=n.replace(e,i)}return n},d=()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"};var c,u,f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},v={exports:{}};
2
- /** @license
3
- * eventsource.js
4
- * Available under MIT License (MIT)
5
- * https://github.com/Yaffle/EventSource/
6
- */
7
- c=v,u=v.exports,function(t){var i=t.setTimeout,e=t.clearTimeout,n=t.XMLHttpRequest,s=t.XDomainRequest,r=t.ActiveXObject,o=t.EventSource,a=t.document,h=t.Promise,l=t.fetch,d=t.Response,f=t.TextDecoder,v=t.TextEncoder,p=t.AbortController;if("undefined"==typeof window||void 0===a||"readyState"in a||null!=a.body||(a.readyState="loading",window.addEventListener("load",(function(){a.readyState="complete"}),!1)),null==n&&null!=r&&(n=function(){return new r("Microsoft.XMLHTTP")}),null==Object.create&&(Object.create=function(t){function i(){}return i.prototype=t,new i}),Date.now||(Date.now=function(){return(new Date).getTime()}),null==p){var g=l;l=function(t,i){var e=i.signal;return g(t,{headers:i.headers,credentials:i.credentials,cache:i.cache}).then((function(t){var i=t.body.getReader();return e._reader=i,e._aborted&&e._reader.cancel(),{status:t.status,statusText:t.statusText,headers:t.headers,body:{getReader:function(){return i}}}}))},p=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){null!=this.signal._reader&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function b(){this.bitsNeeded=0,this.codePoint=0}b.prototype.decode=function(t){function i(t,i,e){if(1===e)return t>=128>>i&&t<<i<=2047;if(2===e)return t>=2048>>i&&t<<i<=55295||t>=57344>>i&&t<<i<=65535;if(3===e)return t>=65536>>i&&t<<i<=1114111;throw new Error}function e(t,i){if(6===t)return i>>6>15?3:i>31?2:1;if(12===t)return i>15?3:2;if(18===t)return 3;throw new Error}for(var n=65533,s="",r=this.bitsNeeded,o=this.codePoint,a=0;a<t.length;a+=1){var h=t[a];0!==r&&(h<128||h>191||!i(o<<6|63&h,r-6,e(r,o)))&&(r=0,o=n,s+=String.fromCharCode(o)),0===r?(h>=0&&h<=127?(r=0,o=h):h>=192&&h<=223?(r=6,o=31&h):h>=224&&h<=239?(r=12,o=15&h):h>=240&&h<=247?(r=18,o=7&h):(r=0,o=n),0===r||i(o,r,e(r,o))||(r=0,o=n)):(r-=6,o=o<<6|63&h),0===r&&(o<=65535?s+=String.fromCharCode(o):(s+=String.fromCharCode(55296+(o-65535-1>>10)),s+=String.fromCharCode(56320+(o-65535-1&1023))))}return this.bitsNeeded=r,this.codePoint=o,s},null!=f&&null!=v&&function(){try{return"test"===(new f).decode((new v).encode("test"),{stream:!0})}catch(t){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+t)}return!1}()||(f=b);var w=function(){};function m(t){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=w,this.onload=w,this.onerror=w,this.onreadystatechange=w,this._contentType="",this._xhr=t,this._sendTimeout=0,this._abort=w}function y(t){return t.replace(/[A-Z]/g,(function(t){return String.fromCharCode(t.charCodeAt(0)+32)}))}function L(t){for(var i=Object.create(null),e=t.split("\r\n"),n=0;n<e.length;n+=1){var s=e[n].split(": "),r=s.shift(),o=s.join(": ");i[y(r)]=o}this._map=i}function S(){}function k(t){this._headers=t}function x(){}function T(){this._listeners=Object.create(null)}function C(t){i((function(){throw t}),0)}function R(t){this.type=t,this.target=void 0}function W(t,i){R.call(this,t),this.data=i.data,this.lastEventId=i.lastEventId}function P(t,i){R.call(this,t),this.status=i.status,this.statusText=i.statusText,this.headers=i.headers}function A(t,i){R.call(this,t),this.error=i.error}m.prototype.open=function(t,s){this._abort(!0);var r=this,o=this._xhr,a=1,h=0;this._abort=function(t){0!==r._sendTimeout&&(e(r._sendTimeout),r._sendTimeout=0),1!==a&&2!==a&&3!==a||(a=4,o.onload=w,o.onerror=w,o.onabort=w,o.onprogress=w,o.onreadystatechange=w,o.abort(),0!==h&&(e(h),h=0),t||(r.readyState=4,r.onabort(null),r.onreadystatechange())),a=0};var l=function(){if(1===a){var t=0,i="",e=void 0;if("contentType"in o)t=200,i="OK",e=o.contentType;else try{t=o.status,i=o.statusText,e=o.getResponseHeader("Content-Type")}catch(n){t=0,i="",e=void 0}0!==t&&(a=2,r.readyState=2,r.status=t,r.statusText=i,r._contentType=e,r.onreadystatechange())}},d=function(){if(l(),2===a||3===a){a=3;var t="";try{t=o.responseText}catch(t){}r.readyState=3,r.responseText=t,r.onprogress()}},c=function(t,i){if(null!=i&&null!=i.preventDefault||(i={preventDefault:w}),d(),1===a||2===a||3===a){if(a=4,0!==h&&(e(h),h=0),r.readyState=4,"load"===t)r.onload(i);else if("error"===t)r.onerror(i);else{if("abort"!==t)throw new TypeError;r.onabort(i)}r.onreadystatechange()}},u=function(){h=i((function(){u()}),500),3===o.readyState&&d()};"onload"in o&&(o.onload=function(t){c("load",t)}),"onerror"in o&&(o.onerror=function(t){c("error",t)}),"onabort"in o&&(o.onabort=function(t){c("abort",t)}),"onprogress"in o&&(o.onprogress=d),"onreadystatechange"in o&&(o.onreadystatechange=function(t){!function(t){null!=o&&(4===o.readyState?"onload"in o&&"onerror"in o&&"onabort"in o||c(""===o.responseText?"error":"load",t):3===o.readyState?"onprogress"in o||d():2===o.readyState&&l())}(t)}),!("contentType"in o)&&"ontimeout"in n.prototype||(s+=(-1===s.indexOf("?")?"?":"&")+"padding=true"),o.open(t,s,!0),"readyState"in o&&(h=i((function(){u()}),0))},m.prototype.abort=function(){this._abort(!1)},m.prototype.getResponseHeader=function(){return this._contentType},m.prototype.setRequestHeader=function(t,i){var e=this._xhr;"setRequestHeader"in e&&e.setRequestHeader(t,i)},m.prototype.getAllResponseHeaders=function(){return null!=this._xhr.getAllResponseHeaders&&this._xhr.getAllResponseHeaders()||""},m.prototype.send=function(){if("ontimeout"in n.prototype&&("sendAsBinary"in n.prototype||"mozAnon"in n.prototype)||null==a||null==a.readyState||"complete"===a.readyState){var t=this._xhr;"withCredentials"in t&&(t.withCredentials=this.withCredentials);try{t.send(void 0)}catch(t){throw t}}else{var e=this;e._sendTimeout=i((function(){e._sendTimeout=0,e.send()}),4)}},L.prototype.get=function(t){return this._map[y(t)]},null!=n&&null==n.HEADERS_RECEIVED&&(n.HEADERS_RECEIVED=2),S.prototype.open=function(t,i,e,s,r,o,a){t.open("GET",r);var h=0;for(var l in t.onprogress=function(){var i=t.responseText.slice(h);h+=i.length,e(i)},t.onerror=function(t){t.preventDefault(),s(new Error("NetworkError"))},t.onload=function(){s(null)},t.onabort=function(){s(null)},t.onreadystatechange=function(){if(t.readyState===n.HEADERS_RECEIVED){var e=t.status,s=t.statusText,r=t.getResponseHeader("Content-Type"),o=t.getAllResponseHeaders();i(e,s,r,new L(o))}},t.withCredentials=o,a)Object.prototype.hasOwnProperty.call(a,l)&&t.setRequestHeader(l,a[l]);return t.send(),t},k.prototype.get=function(t){return this._headers.get(t)},x.prototype.open=function(t,i,e,n,s,r,o){var a=null,d=new p,c=d.signal,u=new f;return l(s,{headers:o,credentials:r?"include":"same-origin",signal:c,cache:"no-store"}).then((function(t){return a=t.body.getReader(),i(t.status,t.statusText,t.headers.get("Content-Type"),new k(t.headers)),new h((function(t,i){var n=function(){a.read().then((function(i){if(i.done)t(void 0);else{var s=u.decode(i.value,{stream:!0});e(s),n()}})).catch((function(t){i(t)}))};n()}))})).catch((function(t){return"AbortError"===t.name?void 0:t})).then((function(t){n(t)})),{abort:function(){null!=a&&a.cancel(),d.abort()}}},T.prototype.dispatchEvent=function(t){t.target=this;var i=this._listeners[t.type];if(null!=i)for(var e=i.length,n=0;n<e;n+=1){var s=i[n];try{"function"==typeof s.handleEvent?s.handleEvent(t):s.call(this,t)}catch(t){C(t)}}},T.prototype.addEventListener=function(t,i){t=String(t);var e=this._listeners,n=e[t];null==n&&(e[t]=n=[]);for(var s=!1,r=0;r<n.length;r+=1)n[r]===i&&(s=!0);s||n.push(i)},T.prototype.removeEventListener=function(t,i){t=String(t);var e=this._listeners,n=e[t];if(null!=n){for(var s=[],r=0;r<n.length;r+=1)n[r]!==i&&s.push(n[r]);0===s.length?delete e[t]:e[t]=s}},W.prototype=Object.create(R.prototype),P.prototype=Object.create(R.prototype),A.prototype=Object.create(R.prototype);var E=/^text\/event\-stream(;.*)?$/i,O=function(t,i){var e=null==t?i:parseInt(t,10);return e!=e&&(e=i),I(e)},I=function(t){return Math.min(Math.max(t,1e3),18e6)},N=function(t,i,e){try{"function"==typeof i&&i.call(t,e)}catch(t){C(t)}};function $(t,r){T.call(this),r=r||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,function(t,r,o){r=String(r);var a=Boolean(o.withCredentials),h=o.lastEventIdQueryParameterName||"lastEventId",l=I(1e3),d=O(o.heartbeatTimeout,45e3),c="",u=l,f=!1,v=0,p=o.headers||{},g=o.Transport,b=D&&null==g?void 0:new m(null!=g?new g:null!=n&&"withCredentials"in n.prototype||null==s?new n:new s),w=null!=g&&"string"!=typeof g?new g:null==b?new x:new S,y=void 0,L=0,k=-1,T="",C="",R="",$="",M=0,U=0,j=0,_=function(i,e,n,s){if(0===k)if(200===i&&null!=n&&E.test(n)){k=1,f=Date.now(),u=l,t.readyState=1;var r=new P("open",{status:i,statusText:e,headers:s});t.dispatchEvent(r),N(t,t.onopen,r)}else{var o="";200!==i?(e&&(e=e.replace(/\s+/g," ")),o="EventSource's response has a status "+i+" "+e+" that is not 200. Aborting the connection."):o="EventSource's response has a Content-Type specifying an unsupported type: "+(null==n?"-":n.replace(/\s+/g," "))+". Aborting the connection.",F(),r=new P("error",{status:i,statusText:e,headers:s}),t.dispatchEvent(r),N(t,t.onerror,r),console.error(o)}},B=function(n){if(1===k){for(var s=-1,r=0;r<n.length;r+=1)(h=n.charCodeAt(r))!=="\n".charCodeAt(0)&&h!=="\r".charCodeAt(0)||(s=r);var o=(-1!==s?$:"")+n.slice(0,s+1);$=(-1===s?$:"")+n.slice(s+1),""!==n&&(f=Date.now(),v+=n.length);for(var a=0;a<o.length;a+=1){var h=o.charCodeAt(a);if(-1===M&&h==="\n".charCodeAt(0))M=0;else if(-1===M&&(M=0),h==="\r".charCodeAt(0)||h==="\n".charCodeAt(0)){if(0!==M){1===M&&(j=a+1);var p=o.slice(U,j-1),g=o.slice(j+(j<a&&o.charCodeAt(j)===" ".charCodeAt(0)?1:0),a);"data"===p?(T+="\n",T+=g):"id"===p?C=g:"event"===p?R=g:"retry"===p?(l=O(g,l),u=l):"heartbeatTimeout"===p&&(d=O(g,d),0!==L&&(e(L),L=i((function(){H()}),d)))}if(0===M){if(""!==T){c=C,""===R&&(R="message");var b=new W(R,{data:T.slice(1),lastEventId:C});if(t.dispatchEvent(b),"open"===R?N(t,t.onopen,b):"message"===R?N(t,t.onmessage,b):"error"===R&&N(t,t.onerror,b),2===k)return}T="",R=""}M=h==="\r".charCodeAt(0)?-1:0}else 0===M&&(U=a,M=1),1===M?h===":".charCodeAt(0)&&(j=a+1,M=2):2===M&&(M=3)}}},z=function(n){if(1===k||0===k){k=-1,0!==L&&(e(L),L=0),L=i((function(){H()}),u),u=I(Math.min(16*l,2*u)),t.readyState=0;var s=new A("error",{error:n});t.dispatchEvent(s),N(t,t.onerror,s),null!=n&&console.error(n)}},F=function(){k=2,null!=y&&(y.abort(),y=void 0),0!==L&&(e(L),L=0),t.readyState=2},H=function(){if(L=0,-1===k){f=!1,v=0,L=i((function(){H()}),d),k=0,T="",R="",C=c,$="",U=0,j=0,M=0;var e=r;if("data:"!==r.slice(0,5)&&"blob:"!==r.slice(0,5)&&""!==c){var n=r.indexOf("?");e=-1===n?r:r.slice(0,n+1)+r.slice(n+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,(function(t,i){return i===h?"":t})),e+=(-1===r.indexOf("?")?"?":"&")+h+"="+encodeURIComponent(c)}var s=t.withCredentials,o={Accept:"text/event-stream"},a=t.headers;if(null!=a)for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(o[l]=a[l]);try{y=w.open(b,_,B,z,e,s,o)}catch(t){throw F(),t}}else if(f||null==y){var u=Math.max((f||Date.now())+d-Date.now(),1);f=!1,L=i((function(){H()}),u)}else z(new Error("No activity within "+d+" milliseconds. "+(0===k?"No response received.":v+" chars received.")+" Reconnecting.")),null!=y&&(y.abort(),y=void 0)};t.url=r,t.readyState=0,t.withCredentials=a,t.headers=p,t._close=F,H()}(this,t,r)}var D=null!=l&&null!=d&&"body"in d.prototype;($.prototype=Object.create(T.prototype)).CONNECTING=0,$.prototype.OPEN=1,$.prototype.CLOSED=2,$.prototype.close=function(){this._close()},$.CONNECTING=0,$.OPEN=1,$.CLOSED=2,$.prototype.withCredentials=void 0;var M,U=o;null==n||null!=o&&"withCredentials"in o.prototype||(U=$),M=function(t){t.EventSourcePolyfill=$,t.NativeEventSource=o,t.EventSource=U}(u),void 0!==M&&(c.exports=M)}("undefined"==typeof globalThis?"undefined"!=typeof window?window:"undefined"!=typeof self?self:f:globalThis);const p=class{constructor(e){t(this,e),this.leaderboardLoaded=i(this,"leaderboardLoaded",7),this.isCurrentOnTop=!1,this.isCurrentPlayerRanked=!1,this.timeOrder1=500,this.timeOrder2=1e3,this.isMobile=!1,this.abortController=null,this.autoLocateCurrent=!1,this.keepOnBottom=!0,this.isPageRendering=!1,this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.tournamentId=void 0,this.endpoint=void 0,this.session=void 0,this.language="en",this.limit=40,this.theme="Dark",this.state=void 0,this.offset=0,this.currentUserData=void 0,this.leaderboard=[],this.isLeaderboardLoading=!0,this.isLoadingMore=!1,this.isCurrentPlayerInview=!0,this.isLoadingPrevious=!1,this.scorefractiondigit=2}mergeSortedArrays(t,i,e){if(!(null==t?void 0:t.length))return i;if(!(null==i?void 0:i.length))return t;const n=new Map;t.forEach(((t,i)=>{n.set(t[e],i)}));let s=[...t];const r=[];return i.forEach((t=>{const i=t[e];n.has(i)?s[n.get(i)]=t:r.push(t)})),r.length?(s=[],s=r[r.length-1][e]<t[0][e]?[...r,...t]:[...t,...r],s):t}onLeaderboardScroll(t){t.stopPropagation(),(this.isLoadingPrevious||this.isLoadingMore||this.isPageRendering)&&t.preventDefault()}formatScore(t){const i=Number(this.scorefractiondigit)||2;return t.toLocaleString("en-US",{minimumFractionDigits:i,maximumFractionDigits:i})}async loadLeaderboardById(){if(this.abortController&&this.abortController.abort(),this.isLoadingMore)return;this.abortController=new AbortController,this.isLoadingMore=!0;let t=new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard?language=${this.language}`);t.searchParams.set("filter","includeUnqualifiedPlayer=true"),t.searchParams.set("pagination",`offset=${this.offset},limit=${this.limit}`),t.searchParams.set("platform",d());let i={headers:{"Content-Type":"application/json","x-SessionId":this.session},method:"GET",signal:this.abortController.signal};await fetch(t,i).then((t=>t.json())).then((i=>{var e;const{item:n,items:s,total:r}=i;if(this.isCurrentPlayerRanked=!!n,this.isCurrentPlayerRanked){if(this.currentUserData=n,this.currentUserData.formattedScore=this.formatScore(this.currentUserData.score),this.isLeaderboardLoading){if(this.offset>0)this.scrollCurrentPlayerToMiddle();else if(0===this.offset&&this.autoLocateCurrent&&this.currentUserData.rank>this.limit)return this.offset=this.currentUserData.rank-this.limit/2||0,this.leaderboardLoaded.emit({item:this.currentUserData,leaderboardOffset:this.offset,isRanked:!0,totalRank:r}),void this.loadLeaderboardById().catch(console.error)}else this.isLoadingPrevious&&this.resetScrollTop();setTimeout((()=>{this.tableListEle&&this.tableListEle.querySelectorAll(".Active").length?this.startActivePlayerObserver():this.isCurrentPlayerInview=!1}),this.timeOrder2)}this.total=r,this.leaderboardLoaded.emit({item:this.currentUserData,leaderboardOffset:this.offset,isRanked:this.isCurrentPlayerRanked,totalRank:r}),this.leaderboard=this.mergeSortedArrays(this.leaderboard,s,"rank"),null===(e=this.leaderboard)||void 0===e||e.forEach((t=>t.formattedScore=this.formatScore(t.score))),this.startScrollObersever(),this.reStartUpSSEUpdater(t),this.isLeaderboardLoading=!1}),(t=>{this.isLeaderboardLoading=!1,"AbortError"===t.name?console.log("Request aborted because a new one started or component unmounted."):console.error("Network error",t)})).finally((()=>{this.isLoadingMore=!1}))}startScrollObersever(){this.topLastTimer&&clearTimeout(this.topLastTimer),this.topLastTimer=setTimeout((()=>{this.total<=this.limit||(1!==this.leaderboard[0].rank&&this.startTopRankObserver(),this.leaderboard[this.leaderboard.length-1].rank<this.total&&this.startLastRankObserver())}),this.timeOrder2)}scrollCurrentPlayerToMiddle(){setTimeout((()=>{if(!this.tableListEle||!this.tableListEle.querySelectorAll(".Active").length)return;const t=this.tableListEle.querySelectorAll(".Active")[0],i=this.stylingContainer.getBoundingClientRect(),e=window.innerHeight||document.documentElement.clientHeight;let n=Math.min((e-i.top)/2-t.clientHeight,4*t.clientHeight);n=Math.max(n,t.clientHeight),this.tableListEle.scrollTo({top:t.offsetTop-n,behavior:"smooth"})}),this.timeOrder1)}onStateChanged(){switch(this.state){case"Closed":case"Closing":this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler),this.leaderboardUpdater=null)}}reStartUpSSEUpdater(t){var i;if(this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler)),"Running"!==this.state)return;t.searchParams.set("pagination",`offset=${this.leaderboard.length?this.leaderboard[0].rank-1:0},limit=${(null===(i=this.leaderboard)||void 0===i?void 0:i.length)>this.limit?this.leaderboard.length:this.limit}`);let e=new URL(`${this.endpoint}/v1/tournaments/${this.tournamentId}/leaderboard/updates?${t.searchParams.toString()}`);this.leaderboardUpdater=new v.exports.EventSourcePolyfill(e,{headers:{accept:"text/event-stream","X-SessionId":this.session}}),this.leaderboardUpdater.addEventListener("message",this.updateMessageHandler.bind(this))}updateMessageHandler(t){if(!t.data)return;const i=JSON.parse(t.data);if("LeaderBoardUpdate"===i.messageType){const{item:t,items:e,total:n}=i;(t||this.currentUserData)&&(this.currentUserData=t||this.currentUserData,this.currentUserData.formattedScore=this.formatScore(this.currentUserData.score)),this.leaderboardLoaded.emit({item:this.currentUserData?this.currentUserData:null,isRanked:!!t,totalRank:n}),e.forEach((t=>{const i=this.leaderboard.findIndex((i=>i.rank===t.rank));i>=0&&(this.leaderboard[i]=t),t.formattedScore=this.formatScore(t.score),i<0?this.leaderboard.push(t):this.leaderboard[i]=t})),this.leaderboard=[...this.leaderboard]}}startActivePlayerObserver(){this.activePlayerObserver&&this.activePlayerEle&&this.activePlayerObserver.unobserve(this.activePlayerEle),this.activePlayerObserver=new IntersectionObserver((t=>{t.forEach((t=>{if(this.isCurrentPlayerInview=t.isIntersecting,!t.isIntersecting){const t=this.activePlayerEle.getBoundingClientRect();this.keepOnBottom||(this.isCurrentOnTop=t.top<this.stylingContainer.offsetTop)}}))})),this.activePlayerEle=this.tableListEle.querySelectorAll(".Active")[0],this.activePlayerObserver.observe(this.activePlayerEle)}startTopRankObserver(){this.topRankToObserved&&(this.topMoreObserver.unobserve(this.topRankToObserved),this.topRankToObserved=null),this.topMoreObserver||(this.topMoreObserver=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(this.loadPreMore(),this.topMoreObserver.unobserve(t.target))}))}))),setTimeout((()=>{var t;this.topRankToObserved=null===(t=this.tableListEle)||void 0===t?void 0:t.querySelector("#Rank_1"),this.topRankToObserved&&this.topMoreObserver.observe(this.topRankToObserved)}),this.timeOrder2)}startLastRankObserver(){var t;this.lastRankToObserved&&(this.loadMoreObserver.unobserve(this.lastRankToObserved),this.lastRankToObserved=null),this.loadMoreObserver||(this.loadMoreObserver=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&(this.loadMore(),this.loadMoreObserver.unobserve(t.target))}))}))),this.lastRankToObserved=null===(t=this.tableListEle)||void 0===t?void 0:t.querySelector("#Rank_"+(this.leaderboard.length-1)),this.lastRankToObserved&&this.loadMoreObserver.observe(this.lastRankToObserved)}resetScrollTop(){this.isLoadingPrevious=!1,setTimeout((()=>{const t=this.tableListEle;t.scrollTop=this.previousScrollTop+(t.scrollHeight-this.previousScrollHeight)}),100)}loadPreMore(){var t;if((null===(t=this.leaderboard)||void 0===t?void 0:t.length)&&1===this.leaderboard[0].rank||this.isLoadingPrevious)return;this.offset=this.leaderboard[0].rank-1-this.limit||0;const i=this.tableListEle;this.previousScrollHeight=i.scrollHeight,this.previousScrollTop=i.scrollTop,this.isLoadingPrevious=!0,this.preTopRank=this.leaderboard[0].rank,this.loadLeaderboardById().catch(console.error)}goToCurrentPlayerPage(){this.leaderboard.findIndex((t=>t.id===this.currentUserData.id))>=0?this.scrollCurrentPlayerToMiddle():(this.offset=this.currentUserData.rank-this.limit/2||0,this.leaderboard=[],this.isLeaderboardLoading=!0,this.loadLeaderboardById().catch(console.error),this.isCurrentPlayerInview=!0)}loadMore(){var t;(null===(t=this.leaderboard)||void 0===t?void 0:t.length)>=this.total||(this.offset+=this.limit,this.offset=this.offset>this.total?this.total:this.offset,this.loadLeaderboardById().catch(console.error))}handleTableListScroll(){this.isCurrentPlayerInview=this.isElementInViewport()}isElementInViewport(){const t=this.tableListEle.querySelector(".Active");if(!t)return!1;const i=t.getBoundingClientRect();return this.isCurrentOnTop=i.top<this.stylingContainer.offsetTop,i.top>=0&&i.top>this.stylingContainer.offsetTop&&i.bottom<=this.stylingContainer.offsetTop+this.stylingContainer.offsetHeight&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)}onTournamentIdChanged(){this.disconnectedCallback(),this.endpoint&&this.session&&!(this.session.length<10)&&this.tournamentId&&(this.isLeaderboardLoading=!0,this.resetLeaderboardStatus(),this.loadLeaderboardById().catch(console.error))}resetLeaderboardStatus(){this.offset=0,this.leaderboard=[]}async componentWillLoad(){switch(this.state){case"Running":this.loadLeaderboardById().catch(console.error);break;case"Unstarted":this.isLeaderboardLoading=!1,this.resetLeaderboardStatus()}this.translationUrl.length>2&&await h(this.translationUrl)}render(){var t;return e("div",{key:"26150cc5aa004ca610b2c849e2549a3f584a8d60",class:`LeaderboardWrapper ${this.theme} ${this.isMobile?"Mobile":""}`,ref:t=>this.stylingContainer=t},this.isLeaderboardLoading?e("div",{class:"Loading"}," ",l("loading",this.language)," "):[e("div",null,!this.isCurrentPlayerInview&&this.isCurrentOnTop&&this.currentUserData&&e("div",{class:"PlayerRank Active"},e("div",{class:"Rank"},0===this.currentUserData.rank?"--":this.currentUserData.rank),e("div",{class:"Name"},l("you",this.language)),e("div",{class:"Score"},this.currentUserData.formattedScore),e("div",{class:"Prize"},this.currentUserData.prizeName))),this.isLoadingPrevious&&e("div",null,"Loading"),e("div",{class:"Leaderboard",onScroll:this.onLeaderboardScroll.bind(this),onTouchMove:this.onLeaderboardScroll.bind(this),ref:t=>this.tableListEle=t},(null===(t=this.leaderboard)||void 0===t?void 0:t.length)?this.leaderboard.map(((t,i)=>{var n,s;return e("div",{id:`Rank_${i}`,class:`PlayerRank ${this.isLoadingPrevious&&t.rank<this.preTopRank?"Hidden":""} ${(null===(n=this.currentUserData)||void 0===n?void 0:n.id)===t.id?"Active":""}`},e("div",{class:"Rank"},0===t.rank?"":t.rank),e("div",{class:"Name"},(null===(s=this.currentUserData)||void 0===s?void 0:s.id)===t.id?l("you",this.language):t.shortName),e("div",{class:"Score"},t.formattedScore),e("div",{class:"Prize"},t.prizeName))})):e("div",{class:"NoWinners"},e("div",{class:"Title"}," ",l("noLeaderboard",this.language)," "),e("div",{class:"Info"}," ",l("positionsWillShow",this.language)," "))),this.isLoadingMore&&!this.isLoadingPrevious&&e("div",null,"Loading"),!this.isCurrentPlayerInview&&e("div",{class:this.isCurrentOnTop?"":"Bottom"},!this.isCurrentOnTop&&this.currentUserData&&e("div",{class:"PlayerRank Active",onClick:this.goToCurrentPlayerPage.bind(this)},e("div",{class:"Rank"},0===this.currentUserData.rank?"--":this.currentUserData.rank),e("div",{class:"Name"},l("you",this.language)),e("div",{class:"Score"},this.currentUserData.formattedScore),e("div",{class:"Prize"},this.currentUserData.prizeName)))])}handleClientStylingChange(t,i){t!=i&&s(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(t,i){t!=i&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(t,i){t!=i&&o(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillRender(){this.isPageRendering=!0}componentDidRender(){this.isPageRendering=!1}handleNewTranslations(){h(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&o(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&s(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&r(this.stylingContainer,this.clientStylingUrl)),this.isMobile="PC"!==d(),this.stylingContainer.addEventListener("touchmove",(t=>{t.stopPropagation(),t.preventDefault()}),{passive:!1})}disconnectedCallback(){this.abortController&&this.abortController.abort("Disconnected callback"),this.stylingSubscription&&this.stylingSubscription.unsubscribe(),this.leaderboardUpdater&&(this.leaderboardUpdater.close(),this.leaderboardUpdater.removeEventListener("message",this.updateMessageHandler)),this.loadMoreObserver&&this.loadMoreObserver.disconnect(),this.topMoreObserver&&this.topMoreObserver.disconnect(),this.activePlayerObserver&&this.activePlayerObserver.disconnect(),this.tableListEle&&this.tableListEle.removeEventListener("scroll",this.handleTableListScroll.bind(this))}static get watchers(){return{state:["onStateChanged"],tournamentId:["onTournamentIdChanged"],endpoint:["onTournamentIdChanged"],session:["onTournamentIdChanged"],language:["onTournamentIdChanged"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"],translationUrl:["handleNewTranslations"]}}};p.style=":host{display:block;height:100%}.Dark{color:var(--emw--ingame-color-text, #f5f8f6)}.Light{color:var(--emw--ingame-color-black, #0A0A17)}.Mobile.LeaderboardWrapper .Bottom .PlayerRank.Active{padding:2px 8px}.LeaderboardWrapper{height:100%;position:relative;overflow:hidden}.LeaderboardWrapper .Loading,.LeaderboardWrapper .Leaderboard,.LeaderboardWrapper .Bottom{width:calc(100% - 30px);padding:0 15px;scrollbar-width:thin}.LeaderboardWrapper .Loading,.LeaderboardWrapper .Leaderboard{padding-bottom:0}.LeaderboardWrapper .Bottom{position:absolute;bottom:0;background:linear-gradient(90deg, var(--emw--ingame-color-gray-purple50, rgba(35, 41, 119, 0.4980392157)) 0%, var(--emw--ingame-color-dark-purple50, rgba(59, 28, 117, 0.4980392157)) 100%);border-top:1px solid;border-image-source:linear-gradient(94.32deg, var(--emw--ingame-color-pth-primary1, #9500FF) 4.41%, var(--emw--ingame-color-pth-primary2, #232EC4) 113.86%);border-image-slice:1;backdrop-filter:blur(20px);opacity:0.91}.LeaderboardWrapper .Bottom .PlayerRank.Active{border-width:0;cursor:pointer;padding-right:18px;background:transparent}.LeaderboardWrapper .PlayerRank{overflow-anchor:auto;font-weight:bold;align-items:center;height:26px;gap:16px;padding:2px 8px;display:flex}.LeaderboardWrapper .PlayerRank.Hidden{display:none !important}.LeaderboardWrapper .PlayerRank.Active{background-clip:padding-box, border-box;background-origin:padding-box, border-box;border:1px solid transparent;border-radius:10px;background-image:linear-gradient(91deg, var(--emw--ingame-color-pth-primary4, #11153E) 4.41%, var(--emw--ingame-color-pth-primary4, #11153E) 113.86%), linear-gradient(91deg, var(--emw--ingame-color-pth-primary1, #9500FF) 4.41%, var(--emw--ingame-color-pth-primary2, #232EC4) 113.86%)}.LeaderboardWrapper .PlayerRank div{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.LeaderboardWrapper .PlayerRank .Rank{flex:1}.LeaderboardWrapper .PlayerRank .Name{flex:2;text-align:left}.LeaderboardWrapper .PlayerRank .Score{flex:1;font-weight:normal;text-align:right;overflow:visible;min-width:50px}.LeaderboardWrapper .PlayerRank .Prize{flex:4;overflow:hidden}.LeaderboardWrapper .Leaderboard{height:calc(100% - 2px) !important;overflow-y:auto;overflow-anchor:auto;touch-action:pan-y}.LeaderboardWrapper .Leaderboard .NoWinners{margin:30px auto;display:flex;flex-direction:column;gap:15px}.LeaderboardWrapper .Leaderboard .NoWinners .Title{font-weight:bold;font-size:medium}.LeaderboardWrapper .Leaderboard .NoWinners .Title,.LeaderboardWrapper .Leaderboard .NoWinners .Info{display:flex;align-items:center;flex-direction:column}";export{p as C}