import { h } from "@stencil/core";
import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
import { getTheDay1MonthAgo, getDevice } from "../../utils/utils";
import { getTranslations, translate } from "../../utils/locale.utils";
import { EventSourcePolyfill } from "event-source-polyfill";
import DOMPurify from "dompurify";
import { TournamentState } from "../../../../../../../../libs/common/src/types/casino/tournaments";
import "../../../../../casino-tournaments-ingame-state/dist/types/index";
import "../../../../../casino-tournaments-ingame-detail-page/dist/types/index";
import BackSvg from "../../assets/Union.svg";
import TrophySvg from "../../assets/trophy.svg";
import CloseSvg from "../../assets/close.svg";
import ChevronSvg from "../../assets/chevron.svg";
import moment from "moment";
import "../../../../../ui-image/dist/types/index";
export class CasinoTournamentsIngameList {
    constructor() {
        this.minHorMove = 10;
        this.device = getDevice();
        this.insertEleBeforeActive = false;
        // isInitLeft: a flag to init the left of list position, reset it when reload the list
        this.isInitLeft = false;
        this.touchMoveDistance = 0;
        this.containerWidth = 0;
        // to avoid swift to left of left
        this.maxTranslateX = 0;
        this.updateMessageHandler = (message) => {
            if (!message.data) {
                return;
            }
            let data = JSON.parse(message.data);
            if (!message.type) {
                return;
            }
            switch (data.messageType) {
                case 'TournamentUpdate':
                    this.updateTournament(data.item);
                    break;
                default:
                //Do nothing
            }
        };
        this.isReloadingTournament = false;
        this.handleTouchStart = (e) => {
            this.touchStartX = e.touches[0].clientX;
        };
        /**
         * Handles manual dragging of the list if activeNextWhenSwipe is false.
         */
        this.handleTouchMove = (e) => {
            this.touchMoveDistance = this.touchStartX - e.touches[0].clientX;
            if (this.activeNextWhenSwipe || Math.abs(this.touchMoveDistance) < this.minHorMove) {
                return;
            }
            const style = window.getComputedStyle(this.tournamentListElement);
            const matrix = style.transform || style.webkitTransform;
            // Matrix parses into: matrix(a, b, c, d, tx, ty)
            const matrixValues = matrix.match(/matrix.*\((.+)\)/)[1].split(', ');
            const translateX = parseFloat(matrixValues[4] || '0') - this.touchMoveDistance;
            //Avoid to swipe left of left or right of right
            if (translateX > this.maxTranslateX || translateX < (this.tournamentListElement.clientWidth * -1 - 50)) {
                return;
            }
            this.tournamentListElement.style.transform = `translateX(${translateX}px)`;
        };
        /**
         * Handles swipe completion to trigger navigation if activeNextWhenSwipe is true.
         */
        this.handleTouchEnd = () => {
            if (this.activeNextWhenSwipe) {
                this.moveTo(this.touchMoveDistance < 0 ? -1 : 1);
            }
        };
        this.backToGame = () => {
            var _a;
            window.postMessage({ type: 'BackToGameFromTournaments' });
            this.reloadTournamentsHandler();
            this.currentTournamentId = ((_a = this.tournaments) === null || _a === void 0 ? void 0 : _a.length) ? this.tournaments[0].id : '';
            this.backToHomeEvent.emit({ id: this.currentTournamentId });
            if (this.removeAfterBack) {
                this.stylingContainer.remove();
            }
        };
        this.mbSource = undefined;
        this.translationUrl = '';
        this.clientStyling = undefined;
        this.clientStylingUrl = undefined;
        this.endpoint = undefined;
        this.theme = 'Dark';
        this.session = undefined;
        this.filter = 'Unstarted|Running';
        this.language = 'en';
        this.currency = 'EUR';
        this.startTimeAfter = undefined;
        this.tournamentId = undefined;
        this.limit = '20';
        this.cmsEndpoint = undefined;
        this.activeNextWhenSwipe = false;
        this.removeAfterBack = false;
        this.currentGameId = '';
        this.tournaments = undefined;
        this.currentTournamentId = undefined;
        this.tournamentListElement = undefined;
        this.touchStartX = 0;
        this.isDetailExpanded = false;
        this.isListLoading = true;
        this.showToasting = false;
        this.currentTourIdx = 0;
        this.activePeriodEnd = '';
    }
    /**
     * Fetches tournament data when dependencies change.
     */
    async loadTournamentsData() {
        if (!this.endpoint || !this.session) {
            if (this.tournamentUpdater) {
                this.tournamentUpdater.removeEventListener('message', this.updateMessageHandler);
                this.tournamentUpdater.close();
            }
            return;
        }
        const url = new URL(`${this.endpoint}/v1/tournaments`);
        let options = {
            headers: {
                'Content-Type': 'application/json',
                'x-SessionId': this.session
            },
            method: 'GET'
        };
        url.searchParams.set('language', `${this.language}`);
        url.searchParams.set('sortType', `type1`);
        url.searchParams.set('pagination', `offset=0,limit=${this.limit}`);
        url.searchParams.set('filter', `startTimeAfter=${this.startTimeAfter || this.getDefaultStartTimeFilter()},state=Unstarted|Running`);
        await fetch(url, options).then(res => res.json()).then((data) => {
            var _a;
            this.tournaments = data.items;
            this.currentTournamentId = !this.tournamentId && ((_a = this.tournaments) === null || _a === void 0 ? void 0 : _a.length) > 0
                ? this.currentTournamentId = this.tournaments[0].id
                : this.tournamentId;
            this.tournamentsEvent.emit({ type: 'InitTournaments', tournaments: this.tournaments });
            this.startUpSSEUpdate(url);
        }).finally(() => {
            this.isListLoading = false;
        });
    }
    startUpSSEUpdate(url) {
        if (!this.endpoint || !this.session) {
            return;
        }
        if (this.tournamentUpdater) {
            this.tournamentUpdater.removeEventListener('message', this.updateMessageHandler);
            this.tournamentUpdater.close();
        }
        let endpointURL = `${this.endpoint}/v1/tournaments/updates?${url.searchParams.toString()}`;
        const updateOptions = { headers: { 'accept': 'text/event-stream', 'X-SessionId': this.session } };
        this.tournamentUpdater = new EventSourcePolyfill(endpointURL, updateOptions);
        this.tournamentUpdater.addEventListener('message', this.updateMessageHandler);
    }
    updateTournament(newItem) {
        if (!newItem) {
            return;
        }
        const idx = this.tournaments.findIndex(t => t.id === newItem.id);
        if (idx >= 0) {
            this.tournaments[idx] = newItem;
            this.tournaments = [
                ...this.tournaments
            ];
            if (this.currentTournamentId === newItem.id) {
                this.tournamentUpdatedEvent.emit(newItem);
            }
            this.tournamentsEvent.emit({ type: 'InitTournaments', tournaments: this.tournaments });
        }
        else {
            /**
             *Logic to update tournaments if new
             * List of Tournaments is sorted according to the following criteria:       *
             * Ongoing enrolled/Scheduled enrolled/Ongoing not enrolled/Scheduled not enrolled
             */
            if ([TournamentState.Closing.toString(), TournamentState.Closed.toString()].includes(newItem.state)) {
                return;
            }
            const reversedTournaments = [...this.tournaments].reverse();
            let idx = reversedTournaments.findIndex(t => {
                if (newItem.playerEnrolled === t.playerEnrolled) { //check if playerEnrolled
                    if (newItem.state === t.state) {
                        return moment(newItem.startTime).isBefore(moment(t.startTime));
                    }
                    else {
                        return newItem.state === TournamentState.Ongoing;
                    }
                }
                else {
                    return false;
                }
            });
            idx = this.tournaments.length - 1 - idx;
            this.tournamentsEvent.emit({ type: 'NewTournament', id: newItem.id, idx });
            if (idx < 0) {
                if (!newItem.playerEnrolled) {
                    this.tournaments = [...this.tournaments, newItem];
                    return;
                }
            }
            const activeTournamentIdx = this.tournaments.findIndex((t) => t.id == this.currentTournamentId);
            this.insertEleBeforeActive = idx <= activeTournamentIdx;
            this.tournaments.splice(idx, 0, newItem);
            this.tournaments = [...this.tournaments];
        }
    }
    getDefaultStartTimeFilter() {
        return getTheDay1MonthAgo();
    }
    pageDetailExpandHandler(event) {
        this.isDetailExpanded = event.detail.isExpanded;
    }
    reloadTournamentsHandler() {
        this.isInitLeft = false;
        this.isListLoading = true;
        this.tournaments = [];
        this.loadTournamentsData();
    }
    tournamentUpdateHandler(event) {
        this.isDetailExpanded = event.detail.isExpanded;
        const idx = this.tournaments.findIndex(t => t.id === event.detail.tournament.id);
        if (idx < 0) {
            return;
        }
        this.tournaments[idx] = event.detail.tournament;
        this.tournaments = [...this.tournaments];
    }
    updateTournamentById(event) {
        if (this.isReloadingTournament) {
            return;
        }
        this.isReloadingTournament = true;
        let url = new URL(`${this.endpoint}/v1/tournaments/${event.detail.id}?language=${this.language}&platform=${this.device}`);
        let options = {
            headers: {
                'Content-Type': 'application/json',
                'x-SessionId': this.session
            },
            method: 'GET'
        };
        fetch(url, options).then(res => res.json()).then(data => {
            const { item: tournament } = data;
            const idx = this.tournaments.findIndex(t => t.id === event.detail.id);
            this.tournaments[idx] = tournament;
            this.tournaments = [...this.tournaments];
            if (this.currentTournamentId === tournament.id) {
                this.tournamentUpdatedEvent.emit(tournament);
            }
        }).finally(() => {
            this.isReloadingTournament = false;
        });
    }
    resetDetailPageHeight() {
        const listHeight = this.isDetailExpanded ? 0 : this.stylingContainer.querySelector('.TournamentListWrapper').clientHeight;
        const containerRect = this.stylingContainer.getBoundingClientRect();
        this.detailPageElement.style.height = Math.max(window.innerHeight, containerRect.height) - (containerRect.top + listHeight) + 'px';
    }
    /**
     * Calculates the initial position to center the active tournament.
     */
    locateActiveTournament() {
        var _a;
        if (this.isInitLeft || !((_a = this.tournaments) === null || _a === void 0 ? void 0 : _a.length)) {
            return;
        }
        this.containerWidth = this.tournamentListElement.clientWidth / this.tournaments.length;
        this.updateActiveTournament(this.tournaments.findIndex(i => i.id === this.currentTournamentId));
        setTimeout(() => {
            this.isInitLeft = true;
        });
    }
    /**
     * Updates the active tournament index, centers the view, and starts the countdown.
     */
    updateActiveTournament(curIdx) {
        var _a;
        let idx = curIdx >= 0 ? curIdx : this.tournaments.findIndex(t => t.id === this.currentTournamentId);
        idx = idx >= 0 ? idx : 0;
        const hostWidth = this.stylingContainer.clientWidth;
        const translateX = (-1) * (idx) * this.containerWidth
            + hostWidth / 2 - this.containerWidth / 2 - 5 - parseFloat(((_a = this.tournamentListElement.style.marginLeft) === null || _a === void 0 ? void 0 : _a.replace('px', '')) || "0");
        if (idx === 0) {
            this.maxTranslateX = translateX;
        }
        this.tournamentListElement.style.transform = `translateX(${translateX}px)`;
        this.activeTournamentEvent.emit(this.tournaments[idx]);
    }
    /**
     * Moves selection to previous or next tournament.
     * @param direction -1 for previous, 1 for next
     */
    moveTo(direction) {
        const idx = this.tournaments.findIndex(t => t.id === this.currentTournamentId);
        let curIdx = idx;
        if (direction < 0) { // move to pre
            if (idx == 0) {
                return;
            }
            this.currentTournamentId = this.tournaments[(idx - 1) || 0].id;
            curIdx = idx - 1;
        }
        else {
            if (idx === this.tournaments.length - 1) {
                return;
            }
            this.currentTournamentId = this.tournaments[(idx + 1)].id;
            curIdx = idx + 1;
        }
        this.currentTourIdx = curIdx;
        this.updateActiveTournament(curIdx);
    }
    // Click handler for individual tournament cards
    onTournamentClick(tournamentId) {
        this.currentTournamentId = tournamentId;
        this.updateActiveTournament(-1);
    }
    renderNewTournament(item) {
        return h("div", { id: `t_${item.id}`, onClick: this.onTournamentClick.bind(this, item.id), class: `Tournament ${item.id === this.currentTournamentId ? 'Active' : ''}` }, h("img", { class: 'TourThumbnailImg', src: item.thumbnail, alt: 'Tournament thumbnail' }), h("div", { class: `TournamentDetail ${item.state}` }, h("casino-tournaments-ingame-state", { state: item.state, language: this.language, "tournament-id": item.id, "mb-source": this.mbSource, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-url": this.clientStylingUrl, "is-status-enabled": true, "is-timer-active": item.id === this.currentTournamentId, "start-time": item.startTime, "end-time": item.endTime }), h("div", { class: "Title" }, h("div", { class: "Name" }, item.nameOrTitle), h("div", { class: "Desc" }, item.description))));
    }
    render() {
        var _a, _b, _c;
        return h("div", { key: '695d83f6a94144c2480079e924281ad720e34184', ref: (el) => (this.stylingContainer = el), class: `TournamentsInGameLobby ${this.device === 'PC' ? 'Desktop' : 'Mobile'}` }, this.device === 'PC' &&
            h("div", { key: '007a209c171a1463913641194c605c3cdbcab0a9', class: 'ListTopBar' }, h("div", { key: 'a9cc5eaff027e44590793eaa563b3816fc63de09', class: 'CloseBtn', innerHTML: CloseSvg, onClick: this.backToGame.bind(this) })), this.isListLoading
            ? h("div", { class: 'Loading' }, " ", translate('loading', this.language), " ")
            : ((_a = this.tournaments) === null || _a === void 0 ? void 0 : _a.length) ? [
                h("div", { class: `TournamentListWrapper ${this.isDetailExpanded ? 'Hidden' : ''}` }, h("div", { class: `TournamentList  ${this.theme} ${this.isInitLeft ? 'Loaded' : ''}`, onTouchStart: this.handleTouchStart, onTouchMove: this.handleTouchMove, onTouchEnd: this.handleTouchEnd, ref: el => this.tournamentListElement = el }, ((_b = this.tournaments) === null || _b === void 0 ? void 0 : _b.length) && this.tournaments.map(item => {
                    return this.renderNewTournament(item);
                })), this.device === 'PC' && [
                    h("div", { class: `Nav Left ${this.currentTourIdx <= 0 ? 'Disabled' : ''}`, innerHTML: DOMPurify.sanitize(ChevronSvg), onClick: this.moveTo.bind(this, -1) }),
                    h("div", { class: `Nav Right ${this.currentTourIdx >= this.tournaments.length - 1 ? 'Disabled' : ''}`, innerHTML: DOMPurify.sanitize(ChevronSvg), onClick: this.moveTo.bind(this, 1) })
                ], h("div", { class: `DotsWrapper` }, (this.tournaments || []).map(e => {
                    return h("div", { class: `DotItem ${this.currentTournamentId === e.id ? 'Active' : ''}` }, h("div", { class: "Dot" }));
                }))),
                h("div", { class: `TournamentPageWrapper ${this.isDetailExpanded ? 'Expanded' : ''}  ` }, ((_c = this.tournaments) === null || _c === void 0 ? void 0 : _c.length) && h("casino-tournaments-ingame-detail-page", { id: "DetailPage", ref: el => this.detailPageElement = el, endpoint: this.endpoint, session: this.session, currency: this.currency, "current-game-id": this.currentGameId, "mb-source": this.mbSource, language: this.language, "translation-url": this.translationUrl, "client-styling": this.clientStyling, "client-styling-url": this.clientStylingUrl, "tournament-id": this.currentTournamentId, "cms-endpoint": this.cmsEndpoint })),
                this.device != 'PC' && h("div", { class: 'FixedBackToHome' }, h("div", { class: 'Button', onClick: this.backToGame.bind(this) }, h("div", { class: 'Icon', innerHTML: DOMPurify.sanitize(BackSvg) }), h("span", null, translate('backToHome', this.language), " ")))
            ]
                : [h("div", { class: 'OverlayMask' }), h("div", { class: 'EmptyList NoTournamentsModal' }, h("div", { class: 'Icon Close', innerHTML: DOMPurify.sanitize(CloseSvg), onClick: this.backToGame }), h("div", { class: 'Icon', innerHTML: DOMPurify.sanitize(TrophySvg) }), h("div", { class: 'Title' }, translate('noTournamentsTitle', this.language)), h("div", { class: 'Desc' }, translate('noTournamentsContent1', this.language)), h("div", { class: 'Desc' }, translate('noTournamentsContent2', this.language)), h("div", { class: 'BackToHome', onClick: this.backToGame.bind(this) }, translate('backToHome', this.language)))]);
    }
    componentWillRender() {
        if (!this.insertEleBeforeActive) {
            return;
        }
        this.insertEleBeforeActive = false;
        const listContainer = this.stylingContainer.querySelector('.TournamentList');
        const thumbnailWidth = listContainer.clientWidth / (this.tournaments.length - 1);
        listContainer.style.marginLeft = (-1 * thumbnailWidth) + 'px'; /**/
    }
    async componentWillLoad() {
        if (this.translationUrl.length > 2) {
            await getTranslations(this.translationUrl);
        }
        this.loadTournamentsData();
    }
    componentDidLoad() {
        if (this.stylingContainer) {
            if (this.mbSource)
                setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
            if (this.clientStyling)
                setClientStyling(this.stylingContainer, this.clientStyling);
            if (this.clientStylingUrl)
                setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
        }
    }
    componentDidRender() {
        // Recalculate position after render to ensure correct centering
        this.locateActiveTournament();
    }
    disconnectedCallback() {
        this.stylingSubscription && this.stylingSubscription.unsubscribe();
        if (this.tournamentUpdater) {
            this.tournamentUpdater.close();
            this.tournamentUpdater.removeEventListener('message', this.updateMessageHandler);
            this.tournamentUpdater.removeEventListener('error', this.startUpSSEUpdate.bind(this));
        }
    }
    handleNewTranslations() {
        getTranslations(this.translationUrl);
    }
    handleClientStylingChange(newValue, oldValue) {
        if (newValue != oldValue) {
            setClientStyling(this.stylingContainer, this.clientStyling);
        }
    }
    handleClientStylingUrlChange(newValue, oldValue) {
        if (newValue != oldValue) {
            if (this.clientStylingUrl)
                setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
        }
    }
    handleMbSourceChange(newValue, oldValue) {
        if (newValue != oldValue) {
            setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
        }
    }
    static get is() { return "casino-tournaments-ingame-list"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["casino-tournaments-ingame-list.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["casino-tournaments-ingame-list.css"]
        };
    }
    static get properties() {
        return {
            "mbSource": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "mb-source",
                "reflect": true
            },
            "translationUrl": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Translation url"
                },
                "attribute": "translation-url",
                "reflect": true,
                "defaultValue": "''"
            },
            "clientStyling": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The client styling"
                },
                "attribute": "client-styling",
                "reflect": true
            },
            "clientStylingUrl": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The client styling url"
                },
                "attribute": "client-styling-url",
                "reflect": true
            },
            "endpoint": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The NWA endpoint"
                },
                "attribute": "endpoint",
                "reflect": true
            },
            "theme": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The style that widget shows, available value: Dark, Light\nDefault: Dark"
                },
                "attribute": "theme",
                "reflect": true,
                "defaultValue": "'Dark'"
            },
            "session": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The NWA session for the logged-in user"
                },
                "attribute": "session",
                "reflect": true
            },
            "filter": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The NWA session for the logged-in user"
                },
                "attribute": "filter",
                "reflect": true,
                "defaultValue": "'Unstarted|Running'"
            },
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Language of the widget"
                },
                "attribute": "language",
                "reflect": true,
                "defaultValue": "'en'"
            },
            "currency": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Currency of the widget"
                },
                "attribute": "currency",
                "reflect": true,
                "defaultValue": "'EUR'"
            },
            "startTimeAfter": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Time Filter"
                },
                "attribute": "start-time-after",
                "reflect": true
            },
            "tournamentId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Selected Tournament Id"
                },
                "attribute": "tournament-id",
                "reflect": true
            },
            "limit": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "limit",
                "reflect": true,
                "defaultValue": "'20'"
            },
            "cmsEndpoint": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | null | undefined",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "cms-endpoint",
                "reflect": true
            },
            "activeNextWhenSwipe": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "A flag when swipe left or right\ntrue: active next or pre one when swipe left or right\nfalse: not active next or pre one when swipe left or right"
                },
                "attribute": "active-next-when-swipe",
                "reflect": true,
                "defaultValue": "false"
            },
            "removeAfterBack": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "remove-after-back",
                "reflect": true,
                "defaultValue": "false"
            },
            "currentGameId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The Id of current playing game"
                },
                "attribute": "current-game-id",
                "reflect": true,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "tournaments": {},
            "currentTournamentId": {},
            "tournamentListElement": {},
            "touchStartX": {},
            "isDetailExpanded": {},
            "isListLoading": {},
            "showToasting": {},
            "currentTourIdx": {},
            "activePeriodEnd": {}
        };
    }
    static get events() {
        return [{
                "method": "activeTournamentEvent",
                "name": "activeTournamentSwitched",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "Tournament",
                    "resolved": "{ href: string; id: string; nameOrTitle?: string; description: string; termsUrl?: string; baseCurrency: string; thumbnail?: string; thumbnails?: any[]; startTime: string; endTime: string; closeTime: string; exhibitionStartTime?: string; exhibitionEndTime?: string; state: string; tags?: string; minBetCount?: number; scoreCriteria?: string; enrollCriteria?: string; prizes?: TournamentPrize[]; playerEnrolled?: boolean; overview?: { participants: number; }; metadata?: { sports?: { rules?: string; }; }; wallet?: { casino?: any; sports?: any; }; wallets?: { [key: string]: any; code: string; }[]; games?: { count: number; items: CasinoGame[]; total: number; }; presentPeriod?: { start: string; end: string; }; }",
                    "references": {
                        "Tournament": {
                            "location": "import",
                            "path": "@widgets/common/types/tournaments",
                            "id": "../../../../libs/common/src/types/casino/tournaments.ts::Tournament"
                        }
                    }
                }
            }, {
                "method": "tournamentUpdatedEvent",
                "name": "tournamentUpdated",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "Tournament",
                    "resolved": "{ href: string; id: string; nameOrTitle?: string; description: string; termsUrl?: string; baseCurrency: string; thumbnail?: string; thumbnails?: any[]; startTime: string; endTime: string; closeTime: string; exhibitionStartTime?: string; exhibitionEndTime?: string; state: string; tags?: string; minBetCount?: number; scoreCriteria?: string; enrollCriteria?: string; prizes?: TournamentPrize[]; playerEnrolled?: boolean; overview?: { participants: number; }; metadata?: { sports?: { rules?: string; }; }; wallet?: { casino?: any; sports?: any; }; wallets?: { [key: string]: any; code: string; }[]; games?: { count: number; items: CasinoGame[]; total: number; }; presentPeriod?: { start: string; end: string; }; }",
                    "references": {
                        "Tournament": {
                            "location": "import",
                            "path": "@widgets/common/types/tournaments",
                            "id": "../../../../libs/common/src/types/casino/tournaments.ts::Tournament"
                        }
                    }
                }
            }, {
                "method": "tournamentsEvent",
                "name": "tournamentsEvent",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }, {
                "method": "backToHomeEvent",
                "name": "backToHome",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get watchers() {
        return [{
                "propName": "endpoint",
                "methodName": "loadTournamentsData"
            }, {
                "propName": "session",
                "methodName": "loadTournamentsData"
            }, {
                "propName": "filter",
                "methodName": "loadTournamentsData"
            }, {
                "propName": "language",
                "methodName": "loadTournamentsData"
            }, {
                "propName": "translationUrl",
                "methodName": "handleNewTranslations"
            }, {
                "propName": "clientStyling",
                "methodName": "handleClientStylingChange"
            }, {
                "propName": "clientStylingUrl",
                "methodName": "handleClientStylingUrlChange"
            }, {
                "propName": "mbSource",
                "methodName": "handleMbSourceChange"
            }];
    }
    static get listeners() {
        return [{
                "name": "pageDetailExpand",
                "method": "pageDetailExpandHandler",
                "target": "body",
                "capture": false,
                "passive": false
            }, {
                "name": "pthReloadTournaments",
                "method": "reloadTournamentsHandler",
                "target": "body",
                "capture": false,
                "passive": false
            }, {
                "name": "tournamentUpdate",
                "method": "tournamentUpdateHandler",
                "target": "body",
                "capture": false,
                "passive": false
            }, {
                "name": "pthStateCheckEvent",
                "method": "updateTournamentById",
                "target": undefined,
                "capture": false,
                "passive": false
            }, {
                "name": "resize",
                "method": "resetDetailPageHeight",
                "target": "body",
                "capture": false,
                "passive": true
            }];
    }
}
