{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./cartridges/app_custom_neuhaus_webshop/cartridge/client/default/js/storelocatorTile.js","webpack:///./cartridges/app_custom_neuhaus_webshop/cartridge/client/default/js/util/distance.js","webpack:///./cartridges/app_custom_neuhaus_webshop/cartridge/client/default/js/util/url.js"],"names":[],"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;;AAEb,iBAAiB,mBAAO,CAAC,mGAAY;AACrC,sBAAsB,mBAAO,CAAC,6GAAiB;;AAE/C;AACA;AACA,WAAW,IAAI;AACf,WAAW,OAAO;AAClB,aAAa,IAAI;AACjB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA,CAAC;;;;;;;;;;;;;AC3FY;;AAEb;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA,iBAAiB;AACjB,oCAAoC;AACpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,0CAA0C;AAC1C;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;;;;;;;;;;;;AC9Ca;;AAEb,kBAAkB;AAClB;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA,iDAAiD,IAAI;AACrD;AACA,qDAAqD,gCAAgC;AACrF,aAAa;AACb,0EAA0E,IAAI,GAAG,gCAAgC;AACjH;AACA,SAAS;;AAET;AACA;AACA","file":"default/js/storelocatorTile.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_neuhaus_webshop/cartridge/client/default/js/storelocatorTile.js\");\n","'use strict';\n\nconst urlUtils = require('./util/url');\nconst distanceUtils = require('./util/distance');\n\n/**\n * get the closest store near the current location of the user\n * @param {any} stores - Array of stores\n * @param {Object} position the current position of the client\n * @returns {any} minimal information about nearest store\n */\nfunction calculateNearestStore(stores, position) {\n var calculatedStores = [];\n\n stores.forEach(store => {\n var distance = distanceUtils.getDistanceFromLatLon(position, store.latitude, store.longitude);\n\n calculatedStores.push({\n ID: store.ID,\n name: store.name,\n distance: distance.mi,\n latitude: store.latitude,\n longitude: store.longitude\n });\n });\n\n calculatedStores.sort(function (a, b) {\n return a.distance - b.distance;\n });\n\n return calculatedStores[0];\n}\n\n/**\n * renders the most nearby store based on current location of the user\n */\nfunction rendersMostNearbyStore() {\n if (navigator.geolocation) {\n navigator.geolocation.getCurrentPosition((position) => {\n var url = $('.js-storelocator-tile').data('stores-json-url');\n var urlParams = {\n lat: position.coords.latitude,\n long: position.coords.longitude\n };\n url = urlUtils.addOrReplaceQueryParameters(url, urlParams);\n\n $.ajax({\n url: url,\n type: 'get',\n dataType: 'json',\n success: function (data) {\n var nearestStore = calculateNearestStore(data.stores, position);\n $('.js-storeTile-nearestshop').text(nearestStore ? nearestStore.name : '');\n\n if (nearestStore) {\n $('.js-storeTile-nearestshop').text(nearestStore.name);\n var shopUrl = $('.js-storelocator-tile').data('stores-link-url');\n shopUrl = urlUtils.addOrReplaceQueryParameters(shopUrl, {\n store: nearestStore.ID\n });\n $('.js-storeTile-nearestshop').attr('href', shopUrl);\n }\n }\n });\n });\n }\n}\n\n/**\n * handles the \"use current lcation\" button and redirects to Stores-Find with current position\n */\nfunction handleCurrentLocationButton() {\n $('.js-use-current-location').on('click', function (e) {\n e.preventDefault();\n\n navigator.geolocation.getCurrentPosition(function (position) {\n var url = $('.js-storelocator-tile').data('stores-link-url');\n var urlParams = {\n lat: position.coords.latitude,\n long: position.coords.longitude\n };\n url = urlUtils.addOrReplaceQueryParameters(url, urlParams);\n\n window.location.href = url;\n });\n });\n}\n\n$(document).ready(function () {\n rendersMostNearbyStore();\n handleCurrentLocationButton();\n});\n","'use strict';\n\n/**\n * auxiliary function to calculate the distance\n * @param {float} deg degrees\n * @returns {float} radius\n */\nfunction deg2rad(deg) {\n return deg * (Math.PI / 180);\n}\n\n/**\n *\n * @param {Object} position the current position of the client\n * @param {float} lat2 latitude of the store\n * @param {float} lon2 longitude of the store\n * @returns {float} the distance between the client and the store\n */\nfunction getDistanceFromLatLon(position, lat2, lon2) {\n var lat1 = position.coords.latitude;\n var lon1 = position.coords.longitude;\n\n var R = 6371; // Radius of the earth in km\n var dLat = deg2rad(lat2 - lat1); // deg2rad below\n var dLon = deg2rad(lon2 - lon1);\n\n /* eslint-disable no-mixed-operators */\n var a =\n Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(deg2rad(lat1)) *\n Math.cos(deg2rad(lat2)) *\n Math.sin(dLon / 2) *\n Math.sin(dLon / 2);\n var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n var d = R * c; // Distance in km\n var dmi = Math.round(d * 0.621371192); // Distance in miles\n /* eslint-enable no-mixed-operators */\n\n return {\n mi: dmi,\n km: Math.round(d)\n };\n}\n\nmodule.exports = {\n getDistanceFromLatLon: getDistanceFromLatLon\n};\n","'use strict';\n\nmodule.exports = {/**\n * Adds or replaces the parameters in the URL.\n * If the parameter was already present, it will replace the value.\n * If not, it will append this parameter and its value.\n *\n * @param {string} url - URL to transform\n * @param {Object} params - Parameters to append or replace\n * @return {string} - result URL with the appended and replaced paramters\n */\n addOrReplaceQueryParameters: function (url, params) {\n var newUrl = url;\n Object.keys(params).forEach((key) => {\n const regExp = new RegExp(`((&|\\\\?)${key}=).*?(&|$)`);\n if (newUrl.match(regExp)) {\n newUrl = newUrl.replace(regExp, `$1${encodeURIComponent(params[key])}$3`);\n } else {\n newUrl = newUrl + (newUrl.includes('?') ? '&' : '?') + `${key}=${encodeURIComponent(params[key])}`;\n }\n });\n\n return newUrl;\n }\n};\n"],"sourceRoot":""}