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CAAC,QAAS,GACtC,GDzOD,E","sources":["","scripts/archives.js","scripts/modules/archiveFilters.js"],"sourcesContent":["(function () {\n/* global archiveFiltersData */ /**\n * Filter and sort the archive posts.\n *\n * @param {Object} event The event object.\n * @param {number} page The page number to fetch.\n */ function $73da8bd172f1afaa$export$d0e0de50c701304c(event, page = 1) {\n event.preventDefault();\n // Update current URL with the page number.\n const url = new URL(window.location.href);\n const pathParts = url.pathname.split('/');\n const pageIndex = pathParts.findIndex((part)=>part === 'page');\n if (pageIndex !== -1 && pathParts[pageIndex + 1]) {\n // Just replace the page number.\n pathParts[pageIndex + 1] = page;\n url.pathname = pathParts.join('/');\n } else {\n // Add the whole pagination path.\n pathParts.forEach((part, index)=>{\n if (part === '') pathParts.splice(index, 1);\n });\n // Stick an extra item in to make sure there's a trailing slash.\n if (!url.pathname.endsWith('/')) pathParts.push('');\n pathParts.push('page', page);\n url.pathname = pathParts.join('/');\n }\n window.history.pushState({\n path: url.href\n }, '', url.href);\n const filterSelect = document.querySelector('#pdm-filters__year');\n const sortSelect = document.querySelector('#pdm-filters__sort');\n const committeeSelect = document.querySelector('#pdm-filters__committee');\n const cardContainer = document.querySelector('[data-filter-container]');\n const filtersForm = document.querySelector('.pdm-filters');\n const loadingOverlay = document.createElement('div');\n loadingOverlay.classList.add('pdm-filters__loading-overlay');\n loadingOverlay.innerHTML = '
';\n cardContainer.appendChild(loadingOverlay);\n const selectedYear = filterSelect.value;\n const sortOrder = sortSelect.value;\n const selectedCommittee = committeeSelect.value;\n // Disable the form and show the loading overlay.\n filtersForm.querySelectorAll('input, select, button').forEach((element)=>{\n element.disabled = true;\n });\n loadingOverlay.setAttribute('data-visible', 'true');\n // Create a new FormData object and append the form data.\n const data = new FormData();\n data.append('action', 'filter_posts');\n data.append('year', selectedYear);\n data.append('sort_order', sortOrder);\n data.append('committee', selectedCommittee);\n data.append('paged', page);\n data.append('nonce', archiveFiltersData.nonce); // Use the localized nonce.\n data.append('post_type', archiveFiltersData.post_type); // Include the localized post type.\n // Fetch the data and update the content.\n fetch(archiveFiltersData.ajaxurl, {\n method: 'POST',\n body: data\n }).then((response)=>response.text()).then((html)=>{\n $73da8bd172f1afaa$var$updateFilteredContent(html, cardContainer);\n }).catch((error)=>{\n // eslint-disable-next-line no-console\n console.error('Error:', error);\n }).finally(()=>{\n // Re-enable the form and hide the loading overlay.\n filtersForm.querySelectorAll('input, select, button').forEach((element)=>{\n element.disabled = false;\n });\n loadingOverlay.setAttribute('data-visible', 'false');\n });\n}\n/**\n * Update the container with the filtered content.\n *\n * @param {string} content the HTML content to update the container with.\n * @param {Object} container the DOM Node to update.\n */ function $73da8bd172f1afaa$var$updateFilteredContent(content, container) {\n if (!document.startViewTransition) {\n container.innerHTML = content;\n $73da8bd172f1afaa$export$909ec5aabce1b1f7();\n } else document.startViewTransition(()=>{\n container.innerHTML = content;\n $73da8bd172f1afaa$export$909ec5aabce1b1f7();\n });\n}\n/**\n * Generate pagination links to mimic the WordPress pagination.\n *\n * @param {number} currentPage The current page number.\n * @param {number} totalPages The total number of pages.\n * @return {string} The HTML for the pagination links.\n */ function $73da8bd172f1afaa$var$generatePaginationLinks(currentPage, totalPages) {\n let paginationHTML = '';\n // If there's only one page, don't show pagination.\n if (totalPages <= 1) return paginationHTML;\n // Previous link.\n if (currentPage > 1) paginationHTML += `<`;\n // First page link.\n if (currentPage > 3) {\n paginationHTML += `1`;\n if (currentPage > 4) paginationHTML += `...`;\n }\n // Middle page links\n let startPage = Math.max(1, currentPage - 2);\n let endPage = Math.min(totalPages, currentPage + 2);\n // Adjust startPage and endPage if they are too close to the boundaries\n if (currentPage <= 3) endPage = Math.min(5, totalPages);\n else if (currentPage >= totalPages - 2) startPage = Math.max(totalPages - 4, 1);\n for(let i = startPage; i <= endPage; i++)if (i === currentPage) paginationHTML += `${i}`;\n else paginationHTML += `${i}`;\n // Last page link\n if (currentPage < totalPages - 2) {\n if (currentPage < totalPages - 3) paginationHTML += `...`;\n paginationHTML += `${totalPages}`;\n }\n // Next link\n if (currentPage < totalPages) paginationHTML += `>`;\n return paginationHTML;\n}\n/**\n * Update the pagination links and event listeners.\n *\n * @return {void}\n */ function $73da8bd172f1afaa$export$909ec5aabce1b1f7() {\n const paginationData = document.querySelector('[data-total-posts]');\n const paginationContainer = document.querySelector('.pagination .nav-links');\n if (!paginationData || !paginationContainer) return;\n const currentPage = parseInt(paginationData.dataset.currentPage, 10);\n const totalPosts = parseInt(paginationData.dataset.totalPosts, 10);\n const postsPerPage = parseInt(paginationData.dataset.postsPerPage, 10);\n const totalPages = Math.ceil(totalPosts / postsPerPage);\n paginationContainer.innerHTML = $73da8bd172f1afaa$var$generatePaginationLinks(currentPage, totalPages);\n // Add event listeners to the pagination links\n paginationContainer.querySelectorAll('a[data-page]').forEach((link)=>{\n link.addEventListener('click', (event)=>{\n event.preventDefault();\n const page = parseInt(event.target.dataset.page, 10);\n $73da8bd172f1afaa$export$d0e0de50c701304c(event, page);\n });\n });\n}\n/**\n * Reset the form to its default state.\n *\n * @param {Event} event The click event.\n */ function $73da8bd172f1afaa$var$handleFormReset(event) {\n event.preventDefault();\n const yearInput = document.querySelector('#pdm-filters__year');\n const departmentSelect = document.querySelector('#pdm-filters__committee');\n const sortSelect = document.querySelector('#pdm-filters__sort');\n yearInput.value = '';\n departmentSelect.value = '';\n sortSelect.value = 'desc';\n $73da8bd172f1afaa$export$d0e0de50c701304c(event);\n}\n/**\n * Initialize the archive filters.\n *\n * Add the listener to the apply button and enable ajax pagination.\n *\n * @return {void}\n */ function $73da8bd172f1afaa$export$f31314c2e9855f99() {\n const applyButton = document.querySelector('.pdm-filters__button');\n applyButton.addEventListener('click', $73da8bd172f1afaa$export$d0e0de50c701304c);\n const resetButton = document.querySelector('.pdm-filters__button--reset');\n resetButton.addEventListener('click', $73da8bd172f1afaa$var$handleFormReset);\n $73da8bd172f1afaa$export$909ec5aabce1b1f7();\n}\n\n\n// run all functions on page load.\ndocument.addEventListener('DOMContentLoaded', function() {\n (0, $73da8bd172f1afaa$export$f31314c2e9855f99)();\n});\n\n})();\n//# sourceMappingURL=archives.js.map\n","import { archiveFilters } from './modules/archiveFilters';\n\n// run all functions on page load.\ndocument.addEventListener('DOMContentLoaded', function () {\n\tarchiveFilters();\n});\n","/* global archiveFiltersData */\n\n/**\n * Filter and sort the archive posts.\n *\n * @param {Object} event The event object.\n * @param {number} page The page number to fetch.\n */\nfunction filterAndSort(event, page = 1) {\n\tevent.preventDefault();\n\n\t// Update current URL with the page number.\n\tconst url = new URL(window.location.href);\n\tconst pathParts = url.pathname.split('/');\n\tconst pageIndex = pathParts.findIndex((part) => part === 'page');\n\tif (pageIndex !== -1 && pathParts[pageIndex + 1]) {\n\t\t// Just replace the page number.\n\t\tpathParts[pageIndex + 1] = page;\n\t\turl.pathname = pathParts.join('/');\n\t} else {\n\t\t// Add the whole pagination path.\n\t\tpathParts.forEach((part, index) => {\n\t\t\tif (part === '') {\n\t\t\t\tpathParts.splice(index, 1);\n\t\t\t}\n\t\t});\n\t\t// Stick an extra item in to make sure there's a trailing slash.\n\t\tif (!url.pathname.endsWith('/')) {\n\t\t\tpathParts.push('');\n\t\t}\n\t\tpathParts.push('page', page);\n\t\turl.pathname = pathParts.join('/');\n\t}\n\n\twindow.history.pushState({ path: url.href }, '', url.href);\n\n\tconst filterSelect = document.querySelector('#pdm-filters__year');\n\tconst sortSelect = document.querySelector('#pdm-filters__sort');\n\tconst committeeSelect = document.querySelector('#pdm-filters__committee');\n\tconst cardContainer = document.querySelector('[data-filter-container]');\n\tconst filtersForm = document.querySelector('.pdm-filters');\n\tconst loadingOverlay = document.createElement('div');\n\tloadingOverlay.classList.add('pdm-filters__loading-overlay');\n\tloadingOverlay.innerHTML =\n\t\t'
';\n\tcardContainer.appendChild(loadingOverlay);\n\n\tconst selectedYear = filterSelect.value;\n\tconst sortOrder = sortSelect.value;\n\tconst selectedCommittee = committeeSelect.value;\n\n\t// Disable the form and show the loading overlay.\n\tfiltersForm.querySelectorAll('input, select, button').forEach((element) => {\n\t\telement.disabled = true;\n\t});\n\tloadingOverlay.setAttribute('data-visible', 'true');\n\n\t// Create a new FormData object and append the form data.\n\tconst data = new FormData();\n\tdata.append('action', 'filter_posts');\n\tdata.append('year', selectedYear);\n\tdata.append('sort_order', sortOrder);\n\tdata.append('committee', selectedCommittee);\n\tdata.append('paged', page);\n\tdata.append('nonce', archiveFiltersData.nonce); // Use the localized nonce.\n\tdata.append('post_type', archiveFiltersData.post_type); // Include the localized post type.\n\n\t// Fetch the data and update the content.\n\tfetch(archiveFiltersData.ajaxurl, {\n\t\tmethod: 'POST',\n\t\tbody: data,\n\t})\n\t\t.then((response) => response.text())\n\t\t.then((html) => {\n\t\t\tupdateFilteredContent(html, cardContainer);\n\t\t})\n\t\t.catch((error) => {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error('Error:', error);\n\t\t})\n\t\t.finally(() => {\n\t\t\t// Re-enable the form and hide the loading overlay.\n\t\t\tfiltersForm\n\t\t\t\t.querySelectorAll('input, select, button')\n\t\t\t\t.forEach((element) => {\n\t\t\t\t\telement.disabled = false;\n\t\t\t\t});\n\t\t\tloadingOverlay.setAttribute('data-visible', 'false');\n\t\t});\n}\n\n/**\n * Update the container with the filtered content.\n *\n * @param {string} content the HTML content to update the container with.\n * @param {Object} container the DOM Node to update.\n */\nfunction updateFilteredContent(content, container) {\n\tif (!document.startViewTransition) {\n\t\tcontainer.innerHTML = content;\n\t\tupdatePagination();\n\t} else {\n\t\tdocument.startViewTransition(() => {\n\t\t\tcontainer.innerHTML = content;\n\t\t\tupdatePagination();\n\t\t});\n\t}\n}\n\n/**\n * Generate pagination links to mimic the WordPress pagination.\n *\n * @param {number} currentPage The current page number.\n * @param {number} totalPages The total number of pages.\n * @return {string} The HTML for the pagination links.\n */\nfunction generatePaginationLinks(currentPage, totalPages) {\n\tlet paginationHTML = '';\n\n\t// If there's only one page, don't show pagination.\n\tif (totalPages <= 1) {\n\t\treturn paginationHTML;\n\t}\n\n\t// Previous link.\n\tif (currentPage > 1) {\n\t\tpaginationHTML += `<`;\n\t}\n\n\t// First page link.\n\tif (currentPage > 3) {\n\t\tpaginationHTML += `1`;\n\t\tif (currentPage > 4) {\n\t\t\tpaginationHTML += `...`;\n\t\t}\n\t}\n\n\t// Middle page links\n\tlet startPage = Math.max(1, currentPage - 2);\n\tlet endPage = Math.min(totalPages, currentPage + 2);\n\n\t// Adjust startPage and endPage if they are too close to the boundaries\n\tif (currentPage <= 3) {\n\t\tendPage = Math.min(5, totalPages);\n\t} else if (currentPage >= totalPages - 2) {\n\t\tstartPage = Math.max(totalPages - 4, 1);\n\t}\n\n\tfor (let i = startPage; i <= endPage; i++) {\n\t\tif (i === currentPage) {\n\t\t\tpaginationHTML += `${i}`;\n\t\t} else {\n\t\t\tpaginationHTML += `${i}`;\n\t\t}\n\t}\n\n\t// Last page link\n\tif (currentPage < totalPages - 2) {\n\t\tif (currentPage < totalPages - 3) {\n\t\t\tpaginationHTML += `...`;\n\t\t}\n\t\tpaginationHTML += `${totalPages}`;\n\t}\n\n\t// Next link\n\tif (currentPage < totalPages) {\n\t\tpaginationHTML += `>`;\n\t}\n\n\treturn paginationHTML;\n}\n\n/**\n * Update the pagination links and event listeners.\n *\n * @return {void}\n */\nfunction updatePagination() {\n\tconst paginationData = document.querySelector('[data-total-posts]');\n\tconst paginationContainer = document.querySelector(\n\t\t'.pagination .nav-links'\n\t);\n\n\tif (!paginationData || !paginationContainer) {\n\t\treturn;\n\t}\n\n\tconst currentPage = parseInt(paginationData.dataset.currentPage, 10);\n\tconst totalPosts = parseInt(paginationData.dataset.totalPosts, 10);\n\tconst postsPerPage = parseInt(paginationData.dataset.postsPerPage, 10);\n\tconst totalPages = Math.ceil(totalPosts / postsPerPage);\n\n\tpaginationContainer.innerHTML = generatePaginationLinks(\n\t\tcurrentPage,\n\t\ttotalPages\n\t);\n\n\t// Add event listeners to the pagination links\n\tpaginationContainer.querySelectorAll('a[data-page]').forEach((link) => {\n\t\tlink.addEventListener('click', (event) => {\n\t\t\tevent.preventDefault();\n\t\t\tconst page = parseInt(event.target.dataset.page, 10);\n\t\t\tfilterAndSort(event, page);\n\t\t});\n\t});\n}\n\n/**\n * Reset the form to its default state.\n *\n * @param {Event} event The click event.\n */\nfunction handleFormReset(event) {\n\tevent.preventDefault();\n\n\tconst yearInput = document.querySelector('#pdm-filters__year');\n\tconst departmentSelect = document.querySelector('#pdm-filters__committee');\n\tconst sortSelect = document.querySelector('#pdm-filters__sort');\n\n\tyearInput.value = '';\n\tdepartmentSelect.value = '';\n\tsortSelect.value = 'desc';\n\n\tfilterAndSort(event);\n}\n\n/**\n * Initialize the archive filters.\n *\n * Add the listener to the apply button and enable ajax pagination.\n *\n * @return {void}\n */\nfunction archiveFilters() {\n\tconst applyButton = document.querySelector('.pdm-filters__button');\n\tapplyButton.addEventListener('click', filterAndSort);\n\tconst resetButton = document.querySelector('.pdm-filters__button--reset');\n\tresetButton.addEventListener('click', handleFormReset);\n\tupdatePagination();\n}\n\nexport { archiveFilters, filterAndSort, updatePagination };\n"],"names":["$73da8bd172f1afaa$export$d0e0de50c701304c","event","page","preventDefault","url","URL","window","location","href","pathParts","pathname","split","pageIndex","findIndex","part","forEach","index","splice","endsWith","push","join","history","pushState","path","filterSelect","document","querySelector","sortSelect","committeeSelect","cardContainer","filtersForm","loadingOverlay","createElement","classList","add","innerHTML","appendChild","selectedYear","value","sortOrder","selectedCommittee","querySelectorAll","element","disabled","setAttribute","data","FormData","append","archiveFiltersData","nonce","post_type","fetch","ajaxurl","method","body","then","response","text","html","startViewTransition","container","$73da8bd172f1afaa$export$909ec5aabce1b1f7","catch","error","console","finally","paginationData","paginationContainer","currentPage","parseInt","dataset","totalPages","Math","ceil","totalPosts","postsPerPage","$73da8bd172f1afaa$var$generatePaginationLinks","paginationHTML","startPage","max","endPage","min","i","link","addEventListener","target","$73da8bd172f1afaa$var$handleFormReset","yearInput","departmentSelect","applyButton","resetButton"],"version":3,"file":"archives.js.map"}