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,GAAG,mBAAmB,KACzBoD,EAAOC,MAAM,WAAW9E,SACpB7B,EAAE,kBAAkBnC,QACpBmC,EAAE,QAAQoB,SAAS,cAEvBV,GAAQ,EAAK,GACf,G","sources":["webpack://@sazka/web/./js/app/casino/favorite-games/casino-favorite-games.ts","webpack://@sazka/web/./js/app/casino/views/_casino-section.ts","webpack://@sazka/web/../../libs/design-system/src/loader/loader.ts","webpack://@sazka/web/../../libs/utils/document-ready.ts","webpack://@sazka/web/../../libs/utils/sazka-alert.ts"],"sourcesContent":["import { CasinoFavoriteGameDto } from \"@/casino/favorite-games/casino-favorite-game-dto\";\r\nimport { useNgSession } from \"@sazka/ng/ng-session\";\r\nimport { Loader } from \"@sazka/design-system/src/loader/loader\";\r\nimport { httpClient } from \"@sazka/utils/http-clients/http-client\";\r\nimport { useSessionStorage } from \"@sazka/utils/use-storage\";\r\nimport { watch } from \"vue\";\r\nimport { sazkaAlert } from \"@sazka/utils/sazka-alert\";\r\n\r\nexport class CasinoFavoriteGames {\r\n public static interactionsDisabled = false;\r\n private static favoriteGames: Array<number> = [];\r\n private static readonly cookieKey = \"favorite-games\";\r\n public static readonly addFavoriteEventName = \"add-favorite-game\";\r\n public static readonly removeFavoriteEventName = \"remove-favorite-game\";\r\n public static readonly removeFavoriteStartEventName = \"remove-favorite-game-start\";\r\n\r\n private static readonly ErrorTitleOnSave = \"PĹ™i ukládánĂ nastal problĂ©m\";\r\n private static readonly ErrorTextOnSave =\r\n \"PĹ™i ukládánĂ vašich oblĂbenĂ˝ch her nastal problĂ©m. Zkuste to prosĂm pozdÄ›ji.\";\r\n\r\n private static store: ReturnType<typeof useSessionStorage>;\r\n public static get Store(): ReturnType<typeof useSessionStorage> {\r\n if (!this.store) {\r\n this.store = useSessionStorage();\r\n }\r\n return this.store;\r\n }\r\n\r\n private static setFavoriteGames(games: Array<number>) {\r\n this.favoriteGames = games || [];\r\n if (!games || games.length == 0) {\r\n this.Store.removeItem(this.cookieKey);\r\n } else {\r\n this.Store.setJson(this.cookieKey, this.favoriteGames, \"essential\");\r\n }\r\n }\r\n\r\n public static addFavoriteGame(id: number, saveOnBackend = true) {\r\n this.setFavoriteGames([...this.favoriteGames, id]);\r\n this.highlight();\r\n\r\n const promise = new Promise(async (res, rej) => {\r\n if (saveOnBackend) {\r\n try {\r\n const data = await httpClient.post(`/api/casino/favorite-games/${id}`);\r\n res(data);\r\n } catch {\r\n sazkaAlert(this.ErrorTitleOnSave, this.ErrorTextOnSave);\r\n this.removeFavoriteGame(id, false);\r\n rej();\r\n }\r\n } else {\r\n res(true);\r\n }\r\n });\r\n\r\n return promise;\r\n }\r\n\r\n public static removeFavoriteGame(id: number, saveOnBackend = true) {\r\n const favorites = JSON.parse(JSON.stringify(this.favoriteGames));\r\n favorites.splice(favorites.indexOf(id), 1);\r\n this.setFavoriteGames(favorites);\r\n this.highlight();\r\n\r\n const promise = new Promise(async (res, rej) => {\r\n if (saveOnBackend) {\r\n try {\r\n const data = await httpClient.delete(`/api/casino/favorite-games/${id}`);\r\n res(data);\r\n } catch {\r\n this.addFavoriteGame(id, false);\r\n rej();\r\n }\r\n } else {\r\n res(true);\r\n }\r\n });\r\n\r\n return promise;\r\n }\r\n\r\n public static isFavoriteGame(id: number) {\r\n return this.favoriteGames.includes(id);\r\n }\r\n\r\n public static putFavoriteGames(favoriteGames: number[]) {\r\n return new Promise(async (res, rej) => {\r\n Loader.show();\r\n try {\r\n const data = await httpClient.put(\"/api/casino/favorite-games\", favoriteGames);\r\n res(data);\r\n } catch {\r\n rej();\r\n sazkaAlert(this.ErrorTitleOnSave, this.ErrorTextOnSave);\r\n }\r\n Loader.hide();\r\n });\r\n }\r\n\r\n private static loadFavoriteGames(): Promise<Array<number>> {\r\n return new Promise<Array<number>>((res, rej) => {\r\n $.getJSON(\"/api/casino/favorite-games/ids\")\r\n .done((data) => res(data?.games ?? []))\r\n .catch(() => rej());\r\n });\r\n }\r\n\r\n public static getFavoriteGames(limit?: number): Promise<Array<CasinoFavoriteGameDto>> {\r\n let data = null;\r\n if (limit) {\r\n data = {\r\n limit: limit,\r\n };\r\n }\r\n return new Promise<Array<CasinoFavoriteGameDto>>((res, rej) => {\r\n $.getJSON(\"/api/casino/favorite-games\", data)\r\n .done((data) => res(data?.games ?? []))\r\n .catch(() => rej());\r\n });\r\n }\r\n\r\n public static onLogin() {\r\n return this.loadFavoriteGames()\r\n .then((data) => {\r\n this.setFavoriteGames(data);\r\n this.highlight();\r\n return Promise.resolve(data);\r\n })\r\n .catch(() => {\r\n this.setFavoriteGames([]);\r\n this.highlight();\r\n });\r\n }\r\n\r\n public static onLogout() {\r\n this.setFavoriteGames(null);\r\n this.unHighlight();\r\n }\r\n\r\n public static loadFavoriteGamesFromSession() {\r\n const favorites = this.Store.getJson<number[]>(this.cookieKey);\r\n\r\n if (favorites) {\r\n this.setFavoriteGames(favorites);\r\n this.highlight();\r\n } else {\r\n // we have arrived to section, which requires favorite casino games\r\n this.onLogin();\r\n }\r\n\r\n return [...this.favoriteGames]; // return new array to prevent modifications\r\n }\r\n\r\n public static hasFavoriteGames() {\r\n return (this.loadFavoriteGamesFromSession()?.length ?? 0) > 0;\r\n }\r\n\r\n private static highlight() {\r\n this.unHighlight();\r\n for (const element of this.favoriteGames) {\r\n const fav = element;\r\n $(`.product-card__inner[data-game-id=\"${fav}\"]`).addClass(\"favorite\");\r\n }\r\n }\r\n\r\n private static unHighlight() {\r\n $(\".product-card__inner.favorite\").removeClass(\"favorite\");\r\n }\r\n\r\n public static animation(card: JQuery, iconClass: string, text: string) {\r\n card.append(`\r\n <div class=\"favorite-confirm\">\r\n <span class='${iconClass}'></span>\r\n ${text}\r\n </div>`);\r\n\r\n setTimeout(() => {\r\n card.find(\".favorite-confirm\").addClass(\"favorite-confirm__fade\");\r\n }, 0);\r\n\r\n const promise = new Promise<void>((res) => {\r\n setTimeout(() => {\r\n card.find(\".favorite-confirm\").removeClass(\"favorite-confirm__fade\");\r\n res();\r\n }, 3000);\r\n });\r\n\r\n setTimeout(() => {\r\n card.find(\".favorite-confirm\").remove();\r\n }, 3300);\r\n\r\n return promise;\r\n }\r\n\r\n public static triggerFavoriteAdded(gameCode: string) {\r\n dataLayer.push({\r\n event: \"action.addFavorite.hry\",\r\n action: {\r\n addFavorite: {\r\n gameCode: gameCode,\r\n },\r\n },\r\n });\r\n\r\n document.dispatchEvent(new Event(CasinoFavoriteGames.addFavoriteEventName, { bubbles: true }));\r\n }\r\n\r\n public static triggerFavoriteRemovedStart(gameCode: string) {\r\n dataLayer.push({\r\n event: \"action.removeFavorite.hry\",\r\n action: {\r\n removeFavorite: {\r\n gameCode: gameCode,\r\n },\r\n },\r\n });\r\n document.dispatchEvent(new Event(CasinoFavoriteGames.removeFavoriteStartEventName, { bubbles: true }));\r\n }\r\n\r\n public static triggerFavoriteRemoved() {\r\n document.dispatchEvent(new Event(CasinoFavoriteGames.removeFavoriteEventName, { bubbles: true }));\r\n }\r\n}\r\n\r\nexport const useCasinoFavoriteGames = () => {\r\n const { isLoggedIn } = useNgSession();\r\n if (isLoggedIn.value) {\r\n CasinoFavoriteGames.loadFavoriteGamesFromSession();\r\n }\r\n\r\n watch(isLoggedIn, (newValue) => {\r\n if (newValue) {\r\n CasinoFavoriteGames.onLogin();\r\n } else {\r\n CasinoFavoriteGames.onLogout();\r\n }\r\n });\r\n\r\n $(document).on(\"click\", \".product-card--casino .product-card__star\", (e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n\r\n if (!useNgSession().isLoggedIn.value) {\r\n return;\r\n }\r\n if (CasinoFavoriteGames.interactionsDisabled) {\r\n sazkaAlert(\r\n \"ProbĂhá Ĺ™azenĂ\",\r\n \"PĹ™idávánĂ a odebĂránĂ z oblĂbenĂ˝ch se zpĹ™ĂstupnĂ po dokonÄŤenĂ Ĺ™azenĂ vašich oblĂbenĂ˝ch her.\"\r\n );\r\n return;\r\n }\r\n\r\n const elem = $(e.currentTarget);\r\n const card = elem.closest(\".product-card__inner\");\r\n const gameId = card.data(\"game-id\");\r\n const gameCodeName = card.data(\"game-code\");\r\n\r\n if (CasinoFavoriteGames.isFavoriteGame(gameId)) {\r\n CasinoFavoriteGames.removeFavoriteGame(gameId).then(() => {\r\n CasinoFavoriteGames.triggerFavoriteRemovedStart(gameCodeName ?? gameId);\r\n CasinoFavoriteGames.animation(card, \"product-card__delete\", \"Odebráno<br/>z oblĂbenĂ˝ch her\").then(\r\n () => {\r\n CasinoFavoriteGames.triggerFavoriteRemoved();\r\n }\r\n );\r\n });\r\n } else {\r\n CasinoFavoriteGames.addFavoriteGame(gameId).then(() => {\r\n CasinoFavoriteGames.triggerFavoriteAdded(gameCodeName ?? gameId); // cannot wait for animation to finish here - floor would render last game multiple times (in case more games are marked at once)\r\n CasinoFavoriteGames.animation(card, \"product-card__star\", \"PĹ™idáno mezi<br/>oblĂbenĂ© hry\");\r\n });\r\n }\r\n });\r\n};\r\n","import { useCasinoFavoriteGames } from \"../favorite-games/casino-favorite-games\";\r\n\r\n$(() => {\r\n useCasinoFavoriteGames();\r\n});\r\n","import { documentReady } from \"@sazka/utils/document-ready\";\r\n\r\ndeclare const environment: any;\r\ntype ColorVariant = \"yellow\" | \"blue\";\r\n\r\n/**\r\n * Loader tells user, he has to wait for some ajax operation\r\n */\r\nexport class Loader {\r\n private static showTimeout: number;\r\n private static hideTimeout: number;\r\n private static lockNumber = 0;\r\n public static get isShown() {\r\n return this.lockNumber > 0;\r\n }\r\n\r\n static {\r\n // loader from backend\r\n if (document.body) {\r\n this.showLoaderFromBackend();\r\n } else {\r\n documentReady(() => {\r\n this.showLoaderFromBackend();\r\n });\r\n }\r\n }\r\n\r\n static showLoaderFromBackend() {\r\n if (document.body.classList.contains(\"loader\")) {\r\n this.lockNumber++;\r\n }\r\n }\r\n\r\n /**\r\n * Shows loader after some time in miliseconds\r\n * This is to reduce flickering when ajax actions are super-fast\r\n *\r\n * @param showLoaderIn Time in miliseconds, after which, loaded will be shown\r\n * @param text Title (waiting message) displayed in loader\r\n */\r\n static show(showLoaderIn = 30, text?: string, aboveAll = false, color: ColorVariant = \"yellow\") {\r\n this.clearTimeout();\r\n this.lockNumber++;\r\n\r\n this.showTimeout = window.setTimeout(() => {\r\n this.showNow(text, aboveAll, true, color);\r\n }, showLoaderIn);\r\n }\r\n\r\n /**\r\n * Shows loader right away\r\n * @param text Title (waiting message) displayed in loader\r\n */\r\n static showNow(text?: string, aboveAll = false, counted = false, color: ColorVariant = \"yellow\") {\r\n if (!counted) {\r\n this.lockNumber++;\r\n }\r\n\r\n if (!environment.isEditMode) {\r\n const loader = document.getElementById(\"loader\");\r\n\r\n if (!loader) return;\r\n\r\n if (aboveAll) {\r\n loader.classList.add(\"loader--above-all\");\r\n } else {\r\n loader.classList.remove(\"loader--above-all\");\r\n }\r\n if (text) {\r\n loader.querySelector(\".loader__text\").textContent = text;\r\n loader.classList.add(\"loader--with-text\");\r\n } else {\r\n loader.querySelector(\".loader__text\").textContent = \"\";\r\n loader.classList.remove(\"loader--with-text\");\r\n }\r\n\r\n if (color === \"blue\") {\r\n loader.classList.add(\"loader--blue\");\r\n }\r\n\r\n document.body.classList.add(\"loader\", \"loader--fade-in\");\r\n this.clearTimeout();\r\n }\r\n }\r\n\r\n /**\r\n * Shows loader after delay with z-index of 9999\r\n * @param text Title (waiting message) displayed in loader\r\n */\r\n static showAboveAll(showLoaderIn = 30, text?: string) {\r\n this.show(showLoaderIn, text, true);\r\n }\r\n\r\n /**\r\n * Shows loader right away with z-index of 9999\r\n * @param text Title (waiting message) displayed in loader\r\n */\r\n static showNowAboveAll(text?: string) {\r\n this.showNow(text, true);\r\n }\r\n\r\n /**\r\n * Hides loader\r\n */\r\n static hide() {\r\n this.lockNumber--;\r\n if (this.lockNumber > 0) return;\r\n\r\n this.clearTimeout();\r\n document.body.classList.remove(\"loader--fade-in\");\r\n this.hideTimeout = window.setTimeout(() => {\r\n document.body.classList.remove(\"loader\");\r\n const loader = document.getElementById(\"loader\");\r\n loader.querySelector(\".loader__text\").textContent = \"\";\r\n loader.classList.remove(\"loader--with-text\");\r\n }, 150);\r\n }\r\n\r\n private static clearTimeout() {\r\n if (this.showTimeout) {\r\n clearTimeout(this.showTimeout);\r\n this.showTimeout = null;\r\n }\r\n if (this.hideTimeout) {\r\n clearTimeout(this.hideTimeout);\r\n this.hideTimeout = null;\r\n }\r\n }\r\n}\r\n","/**\r\n * Vanila JS variant to jQuery $(() => {}).\r\n * @param {callback} callback\r\n * @example - documentReady(() => {}).\r\n * This function is binding to document.ready\r\n * */\r\nexport function documentReady(callback: () => void) {\r\n if (document.readyState !== \"loading\") {\r\n return callback();\r\n } else {\r\n document.addEventListener(\"DOMContentLoaded\", callback);\r\n }\r\n}\r\n","/**\r\n * @deprecated Use showAlert a DS component\r\n */\r\nexport const sazkaAlert = (\r\n title: string,\r\n text: string = null,\r\n linkText: string = null,\r\n link: string = null,\r\n buttonText = \"OK\",\r\n customHtml = \"\",\r\n hasExtraButton = true,\r\n errorCode?: number\r\n): Promise<boolean> => {\r\n return new Promise((resolve) => {\r\n const heading = $(\r\n `<h2 class=\"sazka-alert__title\" style=\"visibility:hidden; display:inline-block;\">${title}</h2>`\r\n );\r\n $(\"body\").append(heading);\r\n const maxWidth = Math.max(heading.width(), 300);\r\n heading.remove();\r\n\r\n const template = `\r\n <div class=\"modal fade sazka-alert\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">\r\n <div class=\"modal-dialog modal-dialog-centered\">\r\n <div class=\"modal-content modal-content--without-close\">\r\n ${errorCode ? `<span class='sazka-alert__ecode'>ecode: ${errorCode}</span>` : \"\"}\r\n <h2 class=\"sazka-alert__title\">${title}</h2>\r\n ${text ? `<p class=\"sazka-alert__text\" style=\"max-width: ${maxWidth}px;\">${text}</p>` : \"\"}\r\n <div class=\"sazka-alert__button-group\">\r\n ${linkText ? `<a class=\"btn btn-primary sazka-alert--btn\" href=\"${link}\">${linkText}</a>` : \"\"}\r\n ${\r\n hasExtraButton\r\n ? `<button type=\"button\" class=\"btn ${\r\n linkText ? \"btn-outline-primary\" : \"btn-primary\"\r\n }\" data-dismiss=\"modal\">${buttonText}</button>`\r\n : \"\"\r\n }\r\n </div>\r\n ${customHtml}\r\n </div>\r\n </div>\r\n </div>`;\r\n\r\n const $modal = $(template);\r\n $(\"body\").append($modal);\r\n $modal.modal(\"show\");\r\n $modal.find(\".sazka-alert--btn\").on(\"click\", () => {\r\n resolve(false);\r\n $modal.modal(\"hide\");\r\n });\r\n $modal.on(\"hidden.bs.modal\", () => {\r\n $modal.modal(\"dispose\").remove();\r\n if ($(\".modal:visible\").length) {\r\n $(\"body\").addClass(\"modal-open\");\r\n }\r\n resolve(true);\r\n });\r\n });\r\n};\r\n"],"names":["CasinoFavoriteGames","Store","this","store","useSessionStorage","setFavoriteGames","games","favoriteGames","length","setJson","cookieKey","removeItem","addFavoriteGame","id","saveOnBackend","highlight","promise","Promise","async","res","rej","data","httpClient","post","sazkaAlert","ErrorTitleOnSave","ErrorTextOnSave","removeFavoriteGame","favorites","JSON","parse","stringify","splice","indexOf","delete","isFavoriteGame","includes","putFavoriteGames","Loader","show","put","hide","loadFavoriteGames","$","getJSON","done","_data$games","catch","getFavoriteGames","limit","_data$games2","onLogin","then","resolve","onLogout","unHighlight","loadFavoriteGamesFromSession","getJson","hasFavoriteGames","_this$loadFavoriteGam","_this$loadFavoriteGam2","element","fav","addClass","removeClass","animation","card","iconClass","text","append","setTimeout","find","remove","triggerFavoriteAdded","gameCode","dataLayer","push","event","action","addFavorite","document","dispatchEvent","Event","addFavoriteEventName","bubbles","triggerFavoriteRemovedStart","removeFavorite","removeFavoriteStartEventName","triggerFavoriteRemoved","removeFavoriteEventName","_defineProperty","useCasinoFavoriteGames","isLoggedIn","useNgSession","value","watch","newValue","on","e","preventDefault","stopPropagation","interactionsDisabled","elem","currentTarget","closest","gameId","gameCodeName","isShown","lockNumber","showLoaderFromBackend","body","classList","contains","showLoaderIn","aboveAll","color","clearTimeout","showTimeout","window","showNow","counted","environment","isEditMode","loader","getElementById","add","querySelector","textContent","showAboveAll","showNowAboveAll","hideTimeout","_Loader","documentReady","callback","readyState","addEventListener","title","linkText","link","buttonText","customHtml","hasExtraButton","errorCode","heading","maxWidth","Math","max","width","template","$modal","modal"],"sourceRoot":""}