{"version":3,"file":"back-to-the-top.bundle.js","mappings":"mBAAO,SAASA,EAASC,EAAMC,EAAMC,GACnC,IAAIC,EAEJ,OAAO,WACL,IAAIC,EAAUC,KACVC,EAAOC,UAEPC,EAAQ,WACVL,EAAU,KACLD,GAAWF,EAAKS,MAAML,EAASE,EACtC,EAEII,EAAUR,IAAcC,EAE5BQ,aAAaR,GAEbA,EAAUS,WAAWJ,EAAOP,GAExBS,GAASV,EAAKS,MAAML,EAASE,EACnC,CACF,EClBA,WACE,IACE,IACMO,EAAqBC,SAASC,eAAe,8BAS7CC,EAAiB,WACrB,IAAMC,EAAYC,OAAOC,SAAWL,SAASM,gBAAgBC,UAE7DR,EAAmBS,UAAUC,OAAO,gCAAiCN,GAbtD,GAcjB,EAEAJ,EAAmBW,iBAAiB,SAbhB,WAClBN,OAAOO,SAAS,CACdC,IAAK,EACLC,SAAU,UAEd,IASAT,OAAOM,iBAAiB,SAAUzB,EAASiB,EAAgB,KAC3DE,OAAOM,iBAAiB,YAAazB,EAASiB,EAAgB,IAGhE,CAFE,MAAOY,GACPC,QAAQC,IAAI,2BAA6BF,EAC3C,CACD,CAxBD,E","sources":["webpack://developer.gov.sg/./apps/src/lib/communities.js","webpack://developer.gov.sg/./apps/src/communities/back-to-the-top.js"],"sourcesContent":["export function debounce(func, wait, immediate) {\n var timeout;\n\n return function executedFunction() {\n var context = this;\n var args = arguments;\n\n var later = function () {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n\n var callNow = immediate && !timeout;\n\n clearTimeout(timeout);\n\n timeout = setTimeout(later, wait);\n\n if (callNow) func.apply(context, args);\n };\n}\n\nexport function getEventStatusAndBackgroundColor(startDate, endDate, element) {\n const currentDate = new Date();\n const eventEndDateAndTime = new Date(endDate);\n const eventStartDateAndTime = new Date(startDate);\n\n switch (true) {\n case eventStartDateAndTime > currentDate:\n if (element) element.setAttribute(\"data-event-status\", \"upcoming-event\");\n return { status: \"upcoming\", backgroundColor: \"#0161AF\" };\n\n case eventStartDateAndTime <= currentDate &&\n eventEndDateAndTime >= currentDate:\n if (element) element.setAttribute(\"data-event-status\", \"upcoming-event\");\n return { status: \"now\", backgroundColor: \"#D0021B\" };\n\n case currentDate > eventEndDateAndTime:\n if (element) element.setAttribute(\"data-event-status\", \"past-event\");\n return { status: \"past\", backgroundColor: \"#323232\" };\n }\n}\n\nexport function setEventStatusAndBackgroundColor(\n element,\n status,\n backgroundColor\n) {\n [...element.querySelectorAll(\".event-status\")].forEach(item => {\n item.textContent = status.toUpperCase();\n });\n [...element.querySelectorAll(\".event-status-container\")].forEach(item => {\n item.style.backgroundColor = backgroundColor;\n });\n}\n","import { debounce } from \"../lib/communities\";\n\n(() => {\n try {\n const showOnPx = 50;\n const backToTheTopButton = document.getElementById(\"navigate-to-the-top-button\");\n\n const topFunction = () => {\n window.scrollTo({\n top: 0,\n behavior: \"smooth\",\n });\n };\n\n const scrollFunction = () => {\n const scrollVal = window.scrollY || document.documentElement.scrollTop;\n\n backToTheTopButton.classList.toggle(\"back-to-the-top-button-hidden\", scrollVal <= showOnPx);\n };\n\n backToTheTopButton.addEventListener(\"click\", topFunction);\n window.addEventListener(\"scroll\", debounce(scrollFunction, 10));\n window.addEventListener(\"touchmove\", debounce(scrollFunction, 10));\n } catch (e) {\n console.log(\"Error, back-to-the-top: \" + e);\n }\n})();\n"],"names":["debounce","func","wait","immediate","timeout","context","this","args","arguments","later","apply","callNow","clearTimeout","setTimeout","backToTheTopButton","document","getElementById","scrollFunction","scrollVal","window","scrollY","documentElement","scrollTop","classList","toggle","addEventListener","scrollTo","top","behavior","e","console","log"],"sourceRoot":""}