{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///../storefront-reference-architecture/cartridges/app_storefront_base/cartridge/client/default/js/util.js","webpack:///./cartridges/app_custom_core/cartridge/client/default/js/storeLocator.js","webpack:///./cartridges/app_custom_core/cartridge/client/default/js/storeLocator/storeLocator.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;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;;;;;;;;;;;;;ACZa;;AAEb,qBAAqB,mBAAO,CAAC,0HAAW;;AAExC;AACA,mBAAmB,mBAAO,CAAC,0HAA6B;AACxD,CAAC;;;;;;;;;;;;;ACND;;AAEa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;;AAEA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA,aAAa,MAAM;AACnB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA","file":"default/js/storeLocator.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_core/cartridge/client/default/js/storeLocator.js\");\n","'use strict';\n\nmodule.exports = function (include) {\n if (typeof include === 'function') {\n include();\n } else if (typeof include === 'object') {\n Object.keys(include).forEach(function (key) {\n if (typeof include[key] === 'function') {\n include[key]();\n }\n });\n }\n};\n","'use strict';\n\nvar processInclude = require('base/util');\n\n$(document).ready(function () {\n processInclude(require('./storeLocator/storeLocator'));\n});\n","/* globals google */\n\n'use strict';\n\nvar markers = [];\nvar stores = [];\nvar map = null;\nvar geocoder;\nvar mapdiv = null;\nvar bounds;\nvar DEFAULT_RADIUS_TO_SEARCH_LOCATIONS = 120;\nvar DEFAULT_LAT = 40.4033981;\nvar DEFAULT_LNG = -3.7094777;\nvar searchBox = null;\nvar numStoresOfficial = 0;\nvar numStoresUnOfficial = 0;\n\n/**\n * appends params to a url\n * @param {string} url - Original url\n * @param {Object} params - Parameters to append\n * @returns {string} result url with appended parameters\n */\nfunction appendToUrl(url, params) {\n var newUrl = url;\n newUrl += (newUrl.indexOf('?') !== -1 ? '&' : '?') + Object.keys(params).map(function (key) {\n return key + '=' + encodeURIComponent(params[key]);\n }).join('&');\n\n return newUrl;\n}\n\nfunction clearMarkers() {\n for (var i = 0; i < markers.length; i++) {\n markers[i].setMap(null);\n }\n}\n\nfunction deleteMarkers() {\n clearMarkers();\n markers = [];\n}\n\n/**\n * Prints marker in map\n */\nfunction displayMarkers(filters) {\n numStoresOfficial = 0;\n numStoresUnOfficial = 0;\n\n bounds = new google.maps.LatLngBounds();\n\n Object.keys(mapdiv).forEach(function (key) {\n var store = mapdiv[key];\n var storeLocation = new google.maps.LatLng(store.latitude, store.longitude);\n\n // A marker with a custom SVG glyph.\n var glyphImg = document.createElement('img');\n glyphImg.src = $('#markerOfficialStore').prop('src');\n\n var glyphSvgPinElement;\n var MAX_ZINDEX = 1000;\n var borderColor;\n var background;\n\n function setColor(border, back) {\n borderColor = border;\n background = back;\n }\n\n if (store.omegaOfficialStore && store.name.includes('Pikolinos')) {\n setColor('#EA4235', '#EA4235');\n } else if (store.omegaOfficialStore || store.ID.includes('PK')) {\n setColor('#848281', '#848281');\n } else {\n setColor('#BBBBBB', '#BBBBBB');\n }\n\n glyphSvgPinElement = new google.maps.marker.PinElement({\n scale : store.omegaOfficialStore ? 1.5 : 1.0,\n glyph : glyphImg,\n borderColor : borderColor,\n background : background\n });\n\n var marker = new google.maps.marker.AdvancedMarkerElement({\n map : map,\n position : storeLocation,\n content : glyphSvgPinElement.element,\n title : store.name\n });\n\n store.omegaOfficialStore ? marker.zIndex = MAX_ZINDEX + 1 : marker.zIndex = MAX_ZINDEX;\n\n store.marker = marker;\n stores.push(store);\n markers.push(marker);\n marker.addListener('click', function () {\n var id = '#viewStore' + store.ID;\n var modal = $(id);\n var body = modal.find('div.modal-body').html();\n $('#viewStore div.modal-body').empty().html(body);\n $('#viewStore').modal('show');\n });\n\n if (store.omegaOfficialStore) {\n numStoresOfficial += 1;\n } else {\n numStoresUnOfficial += 1;\n }\n\n // Create a minimum bound based on a set of storeLocations\n bounds.extend(marker.position);\n });\n\n if (!filters) {\n if (numStoresOfficial === 0) {\n $('#stores').prop('checked', false);\n $('#stores').attr('disabled', true);\n $('#stores').parent().addClass('disabled');\n } else {\n $('#stores').prop('checked', true);\n $('#stores').attr('disabled', false);\n $('#stores').parent().removeClass('disabled');\n }\n if (numStoresUnOfficial === 0) {\n $('#otherStores').prop('checked', false);\n $('#otherStores').attr('disabled', true);\n $('#otherStores').parent().addClass('disabled');\n } else {\n $('#otherStores').prop('checked', true);\n $('#otherStores').attr('disabled', false);\n $('#otherStores').parent().removeClass('disabled');\n }\n }\n\n // Fit the all the store marks in the center of a minimum bounds when any store has been found.\n if (mapdiv && mapdiv.length !== 0) {\n map.fitBounds(bounds);\n } else {\n $('.modal-no-results').modal('show');\n }\n}\n\n/**\n * Update results of the map\n */\nfunction updateStores(obj, filters) {\n mapdiv = obj;\n deleteMarkers();\n stores = [];\n displayMarkers(filters);\n}\n\n/**\n * Get addres by latitude and longitude using google maps api\n * * @param {float} lat - latitude\n * * @param {float} lng - longitude\n */\nfunction getAddressFromLatLang(lat, lng) {\n var latlng = {\n lat : lat,\n lng : lng\n };\n geocoder.geocode({\n location: latlng\n }, function (results, status) {\n if (status === google.maps.GeocoderStatus.OK) {\n if (results.length > 0) {\n var locality;\n var country;\n var countryCode;\n var distanceUnit;\n var arrAddress = results[0].address_components;\n Object.keys(arrAddress).forEach(function (key) {\n var address_component = arrAddress[key];\n if (address_component.types[0] == 'locality') {\n locality = address_component.long_name;\n } else if (address_component.types[0] == 'country') {\n country = address_component.long_name;\n countryCode = address_component.short_name;\n }\n if (locality && country) {\n $('#storeLocator-Location').empty().html(locality + ', ' + country);\n if ($('#storeLocator-Radius').is(':empty')) {\n distanceUnit = countryCode === 'US' ? 'mi' : 'km';\n $('#storeLocator-Radius').html(DEFAULT_RADIUS_TO_SEARCH_LOCATIONS + ' ' + distanceUnit);\n }\n $('.store-search-resuls').removeClass('d-none');\n return false;\n }\n });\n }\n }\n });\n}\n\n/**\n * Renders the results of the search and updates the map\n * @param {Object} data - Response from the server\n * @param {Boolean} filters - true if search with click checks\n */\nfunction updateStoresResults(data, filters) {\n var $resultsDiv = $('.results');\n var $mapDiv = $('.map-canvas');\n var hasResults = data.stores.length > 0;\n\n if (!hasResults) {\n $('.store-locator-no-results').show();\n } else {\n $('.store-locator-no-results').hide();\n }\n\n $resultsDiv.empty()\n .data('has-results', hasResults)\n .data('radius', data.radius)\n .data('search-key', data.searchKey);\n\n $mapDiv.attr('data-locations', data.locations);\n\n if ($mapDiv.data('has-google-api')) {\n var obj = $('.map-canvas').attr('data-locations');\n if (obj !== null && obj !== 'null') {\n obj = JSON.parse(obj);\n }\n updateStores(obj, filters);\n } else {\n $('.store-locator-no-apiKey').show();\n }\n\n if (data.storesResultsHtml) {\n $resultsDiv.append(data.storesResultsHtml);\n }\n}\n\nfunction findStores(latitude, longitude) {\n var $detectLocationButton = $('.detect-location');\n var url = $detectLocationButton.data('action');\n var radius = DEFAULT_RADIUS_TO_SEARCH_LOCATIONS;\n $('#otherStores').prop('checked', true);\n $('#stores').prop('checked', true);\n var urlParams = {\n radius : radius,\n lat : latitude,\n long : longitude\n };\n\n getAddressFromLatLang(latitude, longitude);\n $.spinner().start();\n url = appendToUrl(url, urlParams);\n $.ajax({\n url : url,\n type : 'get',\n dataType : 'json',\n success : function (data) {\n $.spinner().stop();\n updateStoresResults(data);\n $('.select-store').prop('disabled', true);\n },\n error: function () {\n $.spinner().stop();\n }\n });\n}\n\n/**\n * Search stores by latitude and longitude\n * If have params, search with these, else search wit geolocation\n * * @param {float} latitude\n * * @param {float} longitude\n */\nfunction searchStores(latitude, longitude) {\n if (latitude && longitude) {\n findStores(latitude, longitude);\n } else {\n if (!navigator.geolocation) {\n $.spinner().stop();\n return;\n }\n var geoSettings = {\n enableHighAccuracy : false,\n maximumAge : 30000,\n timeout : 20000\n };\n navigator.geolocation.getCurrentPosition(function (position) {\n var lat = position.coords.latitude;\n var lng = position.coords.longitude;\n findStores(lat, lng);\n }, function () {\n $.spinner().stop();\n }, geoSettings);\n }\n}\n\n/**\n * Search latitud and longitud using value of postal code (address)\n * If have params, search with these, else search wit geolocation\n * * @param {String} value - address\n */\nfunction geoCode(value) {\n geocoder.geocode({\n address: value\n }, function (results, status) {\n if (status === google.maps.GeocoderStatus.OK) {\n map.setCenter(results[0].geometry.location);\n var lat = results[0].geometry.location.lat();\n var lng = results[0].geometry.location.lng();\n getAddressFromLatLang(lat, lng);\n searchStores(lat, lng);\n }\n });\n}\n\nfunction getSearchboxElement() {\n var searchBoxElement = document.getElementById('store-postal-code');\n return searchBoxElement;\n}\n\n/**\n * Get address using geolocation\n */\nfunction geoUserLocation() {\n if (!navigator.geolocation) {\n $.spinner().stop();\n return;\n }\n navigator.geolocation.getCurrentPosition((function (position) {\n map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));\n getAddressFromLatLang(position.coords.latitude, position.coords.longitude);\n }));\n}\n\n/**\n * Event to search locations when change postal code (address)\n */\nfunction placesChanged() {\n geoCode(getSearchboxElement().value);\n}\n\n/**\n * Uses google maps api to render a map\n */\nfunction maps() {\n var latlng = new google.maps.LatLng(DEFAULT_LAT, DEFAULT_LNG);\n var mapOptions = {\n mapId : 'MAP_ID', // Map ID is required for advanced markers.\n center : latlng,\n zoom : 4,\n maxZoom : 20,\n disableDefaultUI : true,\n zoomControl : true\n };\n\n map = new google.maps.Map($('.map-canvas')[0], mapOptions);\n geocoder = new google.maps.Geocoder();\n searchBox = new google.maps.places.SearchBox(getSearchboxElement());\n searchBox.addListener('places_changed', function () {\n placesChanged();\n });\n\n mapdiv = $('.map-canvas').attr('data-locations');\n if (mapdiv !== null && mapdiv !== 'null') {\n mapdiv = JSON.parse(mapdiv);\n displayMarkers(false);\n }\n\n geoUserLocation();\n}\n\nfunction getUrlParams() {\n var storesChecked = $('#stores').is(':checked');\n var otherStoresChecked = $('#otherStores').is(':checked');\n var searchKeys = $('.results').data('search-key');\n var urlParams = {};\n var radius = DEFAULT_RADIUS_TO_SEARCH_LOCATIONS;\n if (searchKeys.postalCode) {\n urlParams = {\n radius : radius,\n postalCode : searchKeys.postalCode,\n storesChecked : storesChecked,\n otherStoresChecked : otherStoresChecked\n };\n } else if (searchKeys.lat && searchKeys.long) {\n urlParams = {\n radius : radius,\n lat : searchKeys.lat,\n long : searchKeys.long,\n storesChecked : storesChecked,\n otherStoresChecked : otherStoresChecked\n };\n }\n return urlParams;\n}\n\nmodule.exports = {\n init: function () {\n if ($('.map-canvas').data('has-google-api')) {\n maps();\n } else {\n $('.store-locator-no-apiKey').show();\n }\n $('.store-locator-no-results').hide();\n if (!$('.results').data('has-results')) {\n $('.store-locator-no-results').show();\n }\n searchStores();\n },\n\n detectLocation: function () {\n // clicking on detect location.\n $('.detect-location').on('touchstart click', function () {\n searchStores();\n });\n },\n\n search: function () {\n $('.store-locator-container div.store-locator').submit(function (e) {\n e.preventDefault();\n });\n $('.store-locator-container .btn-storelocator-search[type=\"button\"]').click(function (e) {\n e.preventDefault();\n placesChanged();\n });\n },\n\n selectStore: function () {\n $('.store-locator-container').on('touchstart click', '.select-store', (function (e) {\n e.preventDefault();\n var selectedStore = $(':checked', '.results-card .results');\n var data = {\n storeID : selectedStore.val(),\n searchRadius : $('#radius').val(),\n searchPostalCode : $('.results').data('search-key').postalCode,\n storeDetailsHtml : selectedStore.siblings('label').find('.store-details').html(),\n event : e\n };\n\n $('body').trigger('store:selected', data);\n }));\n },\n updateSelectStoreButton: function () {\n $('body').on('change', '.select-store-input', (function () {\n $('.select-store').prop('disabled', false);\n }));\n },\n selectView: function () {\n $('.store-locator-filters').on('touchstart click', '.tabs-btn', function (e) {\n e.preventDefault();\n var id = $(this).attr('rel');\n $('.tabs-btn').removeClass('active');\n $(this).addClass('active');\n $('.store-view').hide();\n $('#' + id).show();\n // Fit the all the store marks in the center of a minimum bounds when any store has been found.\n if (id === 'store-map' && mapdiv && mapdiv.length !== 0 && bounds) {\n map.fitBounds(bounds);\n }\n });\n },\n checkFilter: function () {\n $('#stores, #otherStores').change(function (e) {\n e.preventDefault();\n var url = $(this).data('action-url');\n var urlParams = getUrlParams();\n\n url = appendToUrl(url, urlParams);\n // $.spinner().start();\n $.ajax({\n url : url,\n type : 'get',\n dataType : 'json',\n success : function (data) {\n // $.spinner().stop();\n var filters = true;\n updateStoresResults(data, filters);\n $('.select-store').prop('disabled', true);\n },\n error: function () {\n $.spinner().stop();\n }\n });\n });\n }\n};\n"],"sourceRoot":""}