{"version":3,"file":"hoisted.eHKD8MZo.js","sources":["../../../src/components/pagination.astro?astro&type=script&index=0&lang.ts"],"sourcesContent":[" class AstroPagination extends HTMLElement {\n constructor() {\n super();\n\n if (!this.dataset.games) return;\n\n const games = JSON.parse(this.dataset.games);\n\n let state = {\n games,\n page: 1,\n numOfGames: 6,\n window: 5,\n };\n\n function pagination(games: any, page: number, numOfGames: number) {\n const trimStart = (page - 1) * numOfGames;\n const trimEnd = trimStart + numOfGames;\n\n const trimmedData = games.slice(trimStart, trimEnd);\n\n const pages = Math.ceil(games.length / numOfGames);\n\n return {\n items: trimmedData,\n pages: pages,\n };\n }\n\n function paginationController(pages: number) {\n const wrapper = document.getElementById(\"pagination\");\n\n if (!wrapper) return;\n\n wrapper.innerHTML = ``;\n\n let maxLeft = state.page - Math.floor(state.window / 2);\n let maxRight = state.page + Math.floor(state.window / 2);\n\n if (maxLeft < 1) {\n maxLeft = 1;\n maxRight = state.window;\n }\n\n if (maxRight > pages) {\n maxLeft = pages - (state.window - 1);\n\n if (maxLeft < 1) {\n maxLeft = 1;\n }\n maxRight = pages;\n }\n\n const prev = `
\n ${game.short_description}\n
\n