{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_custom_basicfit/cartridge/client/default/js/splashpage.js"],"names":["SplashPage","data","$","countrySelector","localeSelector","continueButton","defaultFlagClass","updateFlag","elementClass","flagClass","newValue","removeClass","addClass","handleSplashPageLoadGtm","window","dataLayer","push","page","event","page_type","page_country","page_language","traffictype","platform","ip_address","init","length","setTimeout","change","on","e","preventDefault","$this","target","locales","val","html","each","key","append","Option","value","id","prop","toLowerCase","locale","replace","url","attr","newURL","slice","split","document","ready"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;AClFA;AAAA;AAEA,KAAM,CAAAA,UAAU,CAAG,CAAC,IAAM,CACtB,KAAM,CAAAC,IAAI,CAAGC,CAAC,CAAC,yBAAyB,CAAC,CAACD,IAAI,CAAC,MAAM,CAAC,CACtD,KAAM,CAAAE,eAAe,CAAGD,CAAC,CAAC,6BAA6B,CAAC,CACxD,KAAM,CAAAE,cAAc,CAAGF,CAAC,CAAC,4BAA4B,CAAC,CACtD,KAAM,CAAAG,cAAc,CAAGH,CAAC,CAAC,4BAA4B,CAAC,CACtD,KAAM,CAAAI,gBAAgB,CAAG,WAAW,CAEpC,Q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C,CAAC,CAE7B,CACJ,CAAC,CACL,CAAC,EAAE,CAAC,CAEW,gEAAC,IAAM,CAClBX,CAAC,CAACkD,QAAQ,CAAC,CAACC,KAAK,CAACrD,UAAU,CAACyB,IAAI,CAAC,CACtC,CAAC,EAAE,CAAC,E","file":"default/js/splashpage.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./cartridges/app_custom_basicfit/cartridge/client/default/js/splashpage.js\");\n","// splash page\n\nconst SplashPage = (() => {\n const data = $('.js-splash-page-wrapper').data('data');\n const countrySelector = $('.js-splash-country-selector');\n const localeSelector = $('.js-splash-locale-selector');\n const continueButton = $('.js-splash-continue-button');\n const defaultFlagClass = 'flag-icon';\n\n function updateFlag(elementClass, flagClass, newValue) {\n $(`.${elementClass}`).removeClass().addClass(`${elementClass} ${flagClass} flag-icon-${newValue}`);\n }\n\n /**\n * @description Function for pushing data_ready event on splash page load\n */\n function handleSplashPageLoadGtm() {\n window.dataLayer = window.dataLayer || [];\n window.dataLayer.push({ page: null });\n window.dataLayer.push({\n event: 'data_ready',\n page: {\n page_type: 'country_selection',\n page_country: 'undefined',\n page_language: 'undefined',\n },\n traffictype: {\n platform: 'web',\n ip_address: $('.js-splash-page-wrapper').data('ip'),\n },\n });\n }\n\n return {\n init() {\n if (data.length === 0 || countrySelector.length === 0) {\n return; // quit early, idk what comes after this tbh\n }\n\n // browser back hack\n setTimeout(() => {\n countrySelector.change();\n localeSelector.change();\n }, 100);\n\n // when country dropdown changes\n countrySelector.on('change', (e) => {\n e.preventDefault();\n\n const $this = $(e.target);\n // get locales of the selected country\n const locales = data[$this.val()];\n\n // clear existing list\n localeSelector.html('');\n\n // popuplate new list\n $.each(locales, (key, val) => {\n localeSelector.append(new Option(val.value, val.id));\n });\n\n // select first option as selected\n localeSelector.prop('selectedIndex', 0).change();\n\n // update country flag\n updateFlag('js-country-icon', defaultFlagClass, $this.val().toLowerCase());\n });\n\n // when locale dropdown changes\n localeSelector.on('change', (e) => {\n e.preventDefault();\n\n // get selected locale\n const locale = localeSelector.val().replace('_', '-').toLowerCase();\n const url = continueButton.attr('href');\n\n // why? because it also matches with bas'ic-fi't\n // remove 'top-navigation' from url\n const newURL = url.replace(/\\/[a-z]{2}-[a-z]{2}\\/?/, `/${locale}/`).slice(0, 7) + 'home';\n\n // update url\n continueButton.attr('href', newURL);\n\n // update language flag\n updateFlag('js-lang-icon', defaultFlagClass, locale.split('-')[0]);\n });\n\n handleSplashPageLoadGtm();\n\n },\n };\n})();\n\nexport default (() => {\n $(document).ready(SplashPage.init);\n})();\n"],"sourceRoot":""}