{"version":3,"sources":["webpack:///./cartridges/app_rna_core/cartridge/client/default/js/modules/module.store-locator.js","webpack:///./node_modules/load-google-maps-api/index.js"],"names":["INITIAL_LAT","INITIAL_LNG","storeIDInputName","APIConfig","key","window","SFRA","SitePreferences","mapsAPIKey","init","elements","options","arguments","length","undefined","loadGoogleMapsAPI","then","mapsAPI","callbackOnElements","_setupLocator","bind","updateStoresResults","response","payload","locatorSettings","resultsEl","locatorEl","querySelector","hasResults","stores","_storeSelectionHandler","_toggleNoResults","textContent","_renderMap","storesResultsHtml","insertAdjacentHTML","_storeSelectionListener","initModules","publish","Denali","boutiqueSelect","forEach","call","store","add","Option","name","ID","focus","classList","requestStoreSearch","url","_shouldRequestSearch","progress","$","ajax","Urls","storeLocatorFindStores","type","data","dataType","success","prompt","_openLocatorModal","Deferred","resolve","noRequest","promise","removeTargetFormData","selectedStoreIDInput","getSelectedStoreInput","targetFormEl","selectedStoreDisplayEl","locatorReviewed","locatorStoreSelected","value","updateTargetFormData","storeData","displaySelection","createElWithAttrs","selectedStoreRemoveEl","storeID","displayStoreSelection","addEventListener","storeInfo","remove","populateAddressSummary","concat","hasCustomSettings","getAttribute","locatorElIsForm","tagName","objectAssign","JSON","parse","targetFormSelector","document","evt","preventDefault","_submitTargetForm","_setUIElements","locatorForm","_setupEventListeners","removeAttribute","availabilityCTA","querySelectorAll","currentItem","storeId","storeListItem","getElementById","_getMarkerIcon","path","fillColor","fillOpacity","scale","strokeColor","strokeWeight","anchor","Point","labelOrigin","show","noResultsEl","_toggleNoAPI","noAPIEl","mapTargetEl","hasAttribute","mapLocations","locations","infowindow","InfoWindow","latlng","LatLng","lat","long","mapOptions","zoom","center","streetViewControl","mapObject","Map","mapBounds","LatLngBounds","Object","keys","locationItem","locationLabel","parseInt","storeLocation","latitude","longitude","markerObject","Marker","position","map","title","icon","label","text","toString","color","fontSize","addListener","setOptions","content","infoWindowHtml","open","extend","fitBounds","_storeSearchHandler","getQueryStringParams","find","serialize","postalCode","locality","geocoder","Geocoder","searchObject","address","componentRestrictions","country","geocode","results","resultsLocation","geometry","location","lng","promptURL","storeLocatorModal","dialogSettings","modalID","modalClass","overlayOthers","keepAlive","afterCloseCallback","_storeSelectionClosed","callback","modal","updatedLocatorSettings","html","appendParamsToURL","dialog","_getSelectedStoreData","selectedStore","searchRadius","radiusEl","searchPostalCode","searchEl","event","_detectLocationHandler","navigator","geolocation","getCurrentPosition","urlParams","radius","coords","_ignoreSelectionHandler","_targetFormHandler","_confirmSelectionHandler","confirmSelectionAction","disabled","submitOnConfirm","ajaxForm","processAjaxForm","dispatchEvent","addEventListenerList","submitEl","localityEl","detectLocationEl","ignoreSelectionAction","allowSearchAfterSelection"],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAa;;AAE6B;AACK;AACI;AACA;AACE;AACa;AACkC;AACpB;AACA;;AAGhF;AACA,IACIA,WAAW,GAAG,QAAQ;EACtBC,WAAW,GAAG,CAAC,SAAS;EACxBC,gBAAgB,GAAG,SAAS;EAC5BC,SAAS,GAAG;IACRC,GAAG,EAAEC,MAAM,CAACC,IAAI,CAACC,eAAe,CAACC;EACrC,CAAC;AAEE,SAASC,IAAIA,CAACC,QAAQ,EAAgB;EAAA,IAAdC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACvCG,2DAAiB,CAACZ,SAAS,CAAC,CAACa,IAAI,CAAC,UAASC,OAAO,EAAE;IAChDN,OAAO,CAACM,OAAO,GAAGA,OAAO;IAEzBC,oFAAkB,CAACR,QAAQ,EAAES,aAAa,CAACC,IAAI,CAAC,IAAI,EAAET,OAAO,CAAC,CAAC;EACnE,CAAC,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACO,SAASU,mBAAmBA,CAACC,QAAQ,EAAEC,OAA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AAe,CAAC,CAAC;EAClI,CAAC,MAAM;IACHA,eAAe,CAACyM,QAAQ,CAAC9I,gBAAgB,CAAC,OAAO,EAAEqF,mBAAmB,CAACpJ,IAAI,CAACI,eAAe,CAACyM,QAAQ,EAAEzM,eAAe,CAAC,CAAC;EAC3H;EAEAY,uBAAuB,CAACZ,eAAe,CAAC;EAExC,IAAIA,eAAe,CAACkM,sBAAsB,EAAE;IACxClM,eAAe,CAACkM,sBAAsB,CAACvI,gBAAgB,CAAC,OAAO,EAAEsI,wBAAwB,CAACrM,IAAI,CAACI,eAAe,CAACkM,sBAAsB,EAAElM,eAAe,CAAC,CAAC;EAC5J;EAEA,IAAIA,eAAe,CAAC4M,qBAAqB,EAAE;IACvC5M,eAAe,CAAC4M,qBAAqB,CAACjJ,gBAAgB,CAAC,OAAO,EAAEoI,uBAAuB,CAACnM,IAAI,CAACI,eAAe,CAAC4M,qBAAqB,EAAE5M,eAAe,CAAC,CAAC;EACzJ;AACJ;;AAEA;AACA;AACA;AACA;AACA,SAAS4B,oBAAoBA,CAAC5B,eAAe,EAAE;EAC3C,IAAI6C,oBAAoB,GAAGC,qBAAqB,CAAC9C,eAAe,CAAC+C,YAAY,CAAC;EAE9E,OAAO,CAACF,oBAAoB,IAAI,CAACA,oBAAoB,CAACM,KAAK,IAAInD,eAAe,CAAC6M,yBAAyB;AAC5G,C;;;;;;;;;;;ACljBA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA,OAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;;AAEA;AACA","file":"module-store-locator.js","sourcesContent":["'use strict';\n\nimport {publish} from '../helpers/pubSub';\nimport * as dialog from '../components/dialog';\nimport * as progress from '../components/progress';\nimport {processAjaxForm} from './module.ajax-form';\nimport loadGoogleMapsAPI from 'load-google-maps-api';\nimport {populateAddressSummary} from '../checkout/summaryHelpers';\nimport {addEventListenerList, dispatchEvent, objectAssign, initModules} from '../helpers/utilities';\nimport {callbackOnElements, createElWithAttrs} from '@borngroup/born-utilities';\nimport {appendParamsToURL, getQueryStringParams} from '../helpers/urlUtilities';\n\n\n//U.S. Map in the center of the viewport\nconst\n INITIAL_LAT = 37.09024,\n INITIAL_LNG = -95.712891,\n storeIDInputName = 'storeId',\n APIConfig = {\n key: window.SFRA.SitePreferences.mapsAPIKey,\n };\n\nexport function init(elements, options = {}) {\n loadGoogleMapsAPI(APIConfig).then(function(mapsAPI) {\n options.mapsAPI = mapsAPI;\n\n callbackOnElements(elements, _setupLocator.bind(this, options));\n });\n}\n\n/**\n * Renders the results of the search and updates the map\n * @param {Object} data - Response from the server\n */\nexport function updateStoresResults(response, payload, locatorSettings) {\n let resultsEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"result-list\"]'),\n hasResults = response.stores.length;\n\n _storeSelectionHandler(locatorSettings);\n\n _toggleNoResults(!hasResults);\n\n resultsEl.textContent = '';\n\n _renderMap(response, payload, locatorSettings);\n\n if (response.storesResultsHtml) {\n resultsEl.insertAdjacentHTML('afterbegin', response.storesResultsHtml);\n\n _storeSelectionListener(locatorSettings);\n }\n\n initModules(resultsEl);\n\n publish('storeLocator:updateRendered', {response, payload, locatorSettings});\n\n // Override for Denali\n if (window.SFRA.Denali) {\n let boutiqueSelect = locatorSettings.locatorEl.querySelector('[data-denali-boutique-select]');\n\n boutiqueSelect.options.length = 1;\n\n [].forEach.call(response.stores, function(store) {\n boutiqueSelect.add(new Option(store.name, store.ID));\n });\n\n boutiqueSelect.focus();\n locatorSettings.locatorEl.querySelector('[data-denali-boutique-action]').classList.add('disabled');\n locatorSettings.locatorEl.querySelector('[data-focusout-element]').focus();\n }\n}\n\n/**\n * Sends a request to check if there are any stores within the specified search query + radius.\n */\nexport function requestStoreSearch(url, payload, locatorSettings) {\n if (_shouldRequestSearch(locatorSettings)) {\n progress.showLoader();\n\n return $.ajax({\n url: url || window.SFRA.Urls.storeLocatorFindStores,\n type: 'GET',\n data: payload,\n dataType: 'json',\n success: function(response) {\n if (locatorSettings.prompt) {\n _openLocatorModal(response, payload, locatorSettings);\n } else {\n updateStoresResults(response, payload, locatorSettings);\n }\n\n publish('storeLocator:updateRequested', {response, payload, locatorSettings});\n\n progress.hideLoader();\n }\n });\n } else {\n return $.Deferred().resolve({noRequest: true}).promise();\n }\n}\n\nexport function removeTargetFormData(locatorSettings) {\n let selectedStoreIDInput = getSelectedStoreInput(locatorSettings.targetFormEl),\n selectedStoreDisplayEl = locatorSettings.targetFormEl.querySelector('[data-locator-component=\"selected-store-display\"]');\n\n delete locatorSettings.locatorReviewed;\n delete locatorSettings.locatorStoreSelected;\n\n if (selectedStoreIDInput) {\n selectedStoreIDInput.value = '';\n }\n\n if (selectedStoreDisplayEl) {\n selectedStoreDisplayEl.classList.add('hidden');\n }\n}\n\nexport function updateTargetFormData(locatorSettings, storeData = {}, displaySelection) {\n let selectedStoreIDInput = getSelectedStoreInput(locatorSettings.targetFormEl) || createElWithAttrs(locatorSettings.targetFormEl, {'type': 'hidden', 'data-locator-component': 'selected-store-id', 'name': storeIDInputName}, 'input'),\n selectedStoreRemoveEl = locatorSettings.targetFormEl.querySelector('[data-locator-component=\"selected-store-remove\"]');\n\n selectedStoreIDInput.value = storeData.storeID || selectedStoreIDInput.value;\n\n locatorSettings.locatorReviewed = true;\n\n if (selectedStoreIDInput.value) {\n locatorSettings.locatorStoreSelected = true;\n }\n\n if (displaySelection) {\n displayStoreSelection(locatorSettings, storeData);\n }\n\n if (selectedStoreRemoveEl) {\n selectedStoreRemoveEl.addEventListener('click', removeTargetFormData.bind(this, locatorSettings));\n }\n}\n\nexport function displayStoreSelection(locatorSettings, storeData) {\n let selectedStoreDisplayEl = locatorSettings.targetFormEl.querySelector('[data-locator-component=\"selected-store-display\"]');\n\n if (selectedStoreDisplayEl && storeData.storeInfo) {\n selectedStoreDisplayEl.classList.remove('hidden');\n\n populateAddressSummary(selectedStoreDisplayEl, storeData.storeInfo);\n }\n}\n\nexport function getSelectedStoreInput(targetFormEl) {\n return targetFormEl ? targetFormEl.querySelector(`[data-locator-component=\"selected-store-id\"], [name=\"${storeIDInputName}\"]`) : null;\n}\n\n\nfunction _setupLocator(locatorSettings = {}, locatorEl) {\n let hasCustomSettings = locatorEl.getAttribute('data-locator'),\n locatorElIsForm = locatorEl.tagName === 'FORM';\n\n locatorSettings = objectAssign({}, locatorSettings, hasCustomSettings ? JSON.parse(hasCustomSettings) : {});\n\n locatorSettings.locatorEl = locatorEl;\n locatorSettings.targetFormEl = locatorSettings.targetFormEl || (locatorSettings.targetFormSelector ? document.querySelector(locatorSettings.targetFormSelector) : (locatorElIsForm ? locatorEl : null));\n\n //If locator is configured as a prompt, display and configure only after an event happens.\n if (locatorSettings.prompt) {\n locatorSettings.locatorEl.addEventListener('submit', function(evt) {\n //Set this since the flag was removed when opening the modal.\n locatorSettings.prompt = true;\n\n evt.preventDefault();\n\n if (_shouldRequestSearch(locatorSettings)) {\n requestStoreSearch('', {}, locatorSettings);\n } else {\n _submitTargetForm(locatorSettings);\n }\n });\n } else {\n //Otherwise just setup the current locator.\n _renderMap({}, {}, locatorSettings);\n _setUIElements(locatorSettings);\n\n if (locatorSettings.locatorForm) {\n _setupEventListeners(locatorSettings);\n }\n }\n\n locatorEl.removeAttribute('data-locator');\n\n // Override for Denali\n if (window.SFRA.Denali) {\n let boutiqueSelect = locatorEl.querySelector('[data-denali-boutique-select]'),\n availabilityCTA = locatorEl.querySelector('[data-denali-boutique-action]');\n\n if (boutiqueSelect && availabilityCTA) {\n boutiqueSelect.addEventListener('change', function() {\n [].forEach.call(locatorEl.querySelectorAll('[data-denali-boutique-list-item]'), function(currentItem) {\n currentItem.classList.add('hidden');\n });\n\n if (this.value) {\n availabilityCTA.classList.remove('disabled');\n } else {\n availabilityCTA.classList.add('disabled');\n }\n });\n\n availabilityCTA.addEventListener('click', function() {\n let storeId = boutiqueSelect.value,\n storeListItem = document.getElementById(storeId);\n\n if (storeListItem) {\n storeListItem.classList.remove('hidden');\n }\n });\n }\n }\n\n return locatorSettings;\n}\n\n/**\n * Customized google map marker icon with svg format\n */\nfunction _getMarkerIcon(locatorSettings) {\n return {\n path: 'M13.5,30.1460153 L16.8554555,25.5 L20.0024287,25.5 C23.039087,25.5 25.5,' +\n '23.0388955 25.5,20.0024287 L25.5,5.99757128 C25.5,2.96091298 23.0388955,0.5 ' +\n '20.0024287,0.5 L5.99757128,0.5 C2.96091298,0.5 0.5,2.96110446 0.5,5.99757128 ' +\n 'L0.5,20.0024287 C0.5,23.039087 2.96110446,25.5 5.99757128,25.5 L10.1445445,' +\n '25.5 L13.5,30.1460153 Z',\n fillColor: '#0070d2',\n fillOpacity: 1,\n scale: 1.1,\n strokeColor: 'white',\n strokeWeight: 1,\n anchor: new locatorSettings.mapsAPI.Point(13, 30),\n labelOrigin: new locatorSettings.mapsAPI.Point(12, 12)\n };\n}\n\nfunction _toggleNoResults(show) {\n let noResultsEl = document.querySelector('[data-locator-component=\"no-results\"]');\n\n if (show) {\n noResultsEl.classList.remove('hidden');\n } else {\n noResultsEl.classList.add('hidden');\n }\n}\n\nfunction _toggleNoAPI(show) {\n let noAPIEl = document.querySelector('[data-locator-component=\"no-api\"]');\n\n if (show) {\n noAPIEl.classList.remove('hidden');\n } else {\n noAPIEl.classList.add('hidden');\n }\n}\n\n/**\n * Uses google maps api to render a map\n */\nfunction _renderMap(response = {}, payload = {}, locatorSettings) {\n let mapTargetEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"map\"]');\n\n if (!mapTargetEl) {\n return false;\n }\n\n if (mapTargetEl.hasAttribute('data-has-google-api')) {\n let mapLocations = JSON.parse(response && response.locations ? response.locations : mapTargetEl.getAttribute('data-locations')),\n infowindow = new locatorSettings.mapsAPI.InfoWindow(),\n latlng = new locatorSettings.mapsAPI.LatLng(payload.lat || INITIAL_LAT, payload.long || INITIAL_LNG),\n mapOptions = {\n zoom: payload.lat ? 12 : 4,\n center: latlng,\n streetViewControl: false\n },\n mapObject = new locatorSettings.mapsAPI.Map(mapTargetEl, mapOptions),\n mapBounds = new locatorSettings.mapsAPI.LatLngBounds();\n\n Object.keys(mapLocations).forEach(function(key) {\n let locationItem = mapLocations[key],\n locationLabel = parseInt(key, 10) + 1,\n storeLocation = new locatorSettings.mapsAPI.LatLng(locationItem.latitude, locationItem.longitude),\n markerObject = new locatorSettings.mapsAPI.Marker({\n position: storeLocation,\n map: mapObject,\n title: locationItem.name,\n icon: _getMarkerIcon(locatorSettings),\n label: { text: locationLabel.toString(), color: 'white', fontSize: '16px' }\n });\n\n markerObject.addListener('click', function() {\n infowindow.setOptions({\n content: locationItem.infoWindowHtml\n });\n\n infowindow.open(mapObject, markerObject);\n });\n\n // Create a minimum bound based on a set of storeLocations\n mapBounds.extend(markerObject.position);\n });\n\n // Fit the all the store marks in the center of a minimum bounds when any store has been found.\n if (mapLocations && mapLocations.length) {\n mapObject.fitBounds(mapBounds);\n }\n } else {\n _toggleNoAPI(true);\n }\n}\n\n/**\n * Search for stores with new search terms\n * @param {HTMLElement} element - the target html element\n * @returns {boolean} false to prevent default event\n */\nfunction _storeSearchHandler(locatorSettings, evt) {\n let payload = getQueryStringParams($(locatorSettings.locatorForm).find(':input').serialize());\n\n if (evt) {\n evt.preventDefault();\n }\n\n if (payload.postalCode || payload.locality) {\n let geocoder = new locatorSettings.mapsAPI.Geocoder(),\n searchObject = {\n address: payload.postalCode || payload.locality,\n componentRestrictions: {}\n };\n\n progress.showLoader();\n\n if (payload.locality) {\n searchObject.componentRestrictions.locality = payload.locality;\n }\n\n if (payload.country) {\n searchObject.componentRestrictions.country = payload.country;\n }\n\n //Support for determining the location from the input address.\n geocoder.geocode(searchObject, function(results) {\n //Only attempt to access the lat/lang properties if there are any matching results.\n if (results.length) {\n let resultsLocation = results[0].geometry.location;\n\n delete payload.postalCode;\n\n payload.lat = resultsLocation.lat();\n payload.long = resultsLocation.lng();\n }\n\n requestStoreSearch(locatorSettings.locatorForm.getAttribute('action'), payload, locatorSettings);\n });\n }\n\n return false;\n}\n\nfunction _openLocatorModal(response, payload, locatorSettings) {\n let promptURL = typeof locatorSettings.prompt === 'string' ? locatorSettings.prompt : window.SFRA.Urls.storeLocatorModal;\n\n //Remove these properties once the modal is open to avoid re-opening the same modal results.\n delete locatorSettings.prompt;\n\n loadGoogleMapsAPI(APIConfig).then(function(mapsAPI) {\n let dialogSettings;\n\n locatorSettings.mapsAPI = mapsAPI;\n\n dialogSettings = {\n options: {\n modalID: 'storeLocator',\n modalClass: 'modal--flex modal--store-locator modal--small-full',\n overlayOthers: true,\n keepAlive: false,\n afterCloseCallback: _storeSelectionClosed.bind(this, locatorSettings)\n },\n callback: function(modal) {\n let updatedLocatorSettings = _setupLocator(locatorSettings, modal);\n\n publish('storeLocator:updateRendered', {response, payload, locatorSettings: updatedLocatorSettings});\n }\n };\n\n if (response.storesResultsHtml) {\n dialogSettings.html = response.storesResultsHtml;\n } else {\n dialogSettings.url = appendParamsToURL(promptURL, payload);\n dialogSettings.type = 'html';\n }\n\n dialog.open(dialogSettings);\n });\n}\n\nfunction _getSelectedStoreData(locatorSettings, evt) {\n let selectedStore = locatorSettings.locatorEl.querySelector('[data-locator-component=\"result-list\"] :checked');\n\n return selectedStore ? {\n storeID: selectedStore.value,\n searchRadius: locatorSettings.radiusEl.value,\n searchPostalCode: locatorSettings.searchEl.value,\n storeInfo: JSON.parse(selectedStore.getAttribute('data-store-info')),\n event: evt\n } : {};\n}\n\nfunction _detectLocationHandler(locatorSettings) {\n progress.showLoader();\n\n if (!navigator.geolocation) {\n progress.hideLoader();\n\n return;\n }\n\n navigator.geolocation.getCurrentPosition(function(position) {\n let locatorForm = locatorSettings.locatorForm,\n searchEl = locatorSettings.searchEl,\n urlParams = {\n radius: locatorSettings.radiusEl.value,\n lat: position.coords.latitude,\n long: position.coords.longitude\n };\n\n searchEl.value = `${position.coords.latitude}, ${position.coords.longitude}`;\n\n requestStoreSearch(locatorForm.getAttribute('action'), urlParams, locatorSettings);\n });\n}\n\n/**\n * Handle clicking on the \"Cancel\" option when presented with a store list.\n * @param {[type]} evt [description]\n * @return {[type]} [description]\n */\nfunction _ignoreSelectionHandler(locatorSettings, evt) {\n evt.preventDefault();\n\n _targetFormHandler(locatorSettings);\n\n publish('storeLocator:ignored', {locatorSettings});\n\n publish('storeLocator:reviewed', {locatorSettings});\n}\n\nfunction _confirmSelectionHandler(locatorSettings, evt) {\n let storeData = _getSelectedStoreData(locatorSettings, evt);\n\n evt.preventDefault();\n\n _targetFormHandler(locatorSettings, storeData);\n\n publish('storeLocator:confirmed', {locatorSettings, storeData});\n\n publish('storeLocator:reviewed', {locatorSettings, storeData});\n}\n\nfunction _storeSelectionHandler(locatorSettings, evt) {\n let storeData = _getSelectedStoreData(locatorSettings, evt);\n\n if (locatorSettings.confirmSelectionAction) {\n locatorSettings.confirmSelectionAction.disabled = !evt;\n }\n\n publish('storeLocator:selected', {locatorSettings, storeData});\n}\n\n/**\n * Fires an event when the store selection modal is closed.\n */\nfunction _storeSelectionClosed(locatorSettings) {\n publish('storeLocator:closed', {locatorSettings});\n}\n\nfunction _targetFormHandler(locatorSettings, storeData) {\n if (locatorSettings.targetFormEl) {\n updateTargetFormData(locatorSettings, storeData, true);\n\n _submitTargetForm(locatorSettings);\n }\n}\n\n/**\n * Submits the targetForm. Process the form through module.ajax-form if the `ajaxForm` option is provided.\n */\nfunction _submitTargetForm(locatorSettings) {\n if (locatorSettings.submitOnConfirm) {\n if (locatorSettings.ajaxForm) {\n processAjaxForm(locatorSettings.targetFormEl);\n } else {\n //TODO: Some browsers do not allow to fire certain default events, such as a form's \"submit\", through JS.\n //Dispatch a custom \"storeSelected\" for now.\n dispatchEvent(locatorSettings.targetFormEl, 'storeSelected');\n }\n }\n}\n\n/**\n * Listens for changes on the store results list. i.e. when a store is clicked the map changes, etc.\n */\nfunction _storeSelectionListener(locatorSettings) {\n addEventListenerList('[data-locator-component=\"store-info\"]', 'change', _storeSelectionHandler.bind(this, locatorSettings));\n}\n\nfunction _setUIElements(locatorSettings) {\n locatorSettings.locatorForm = locatorSettings.locatorEl.querySelector('[data-locator-component=\"form\"]');\n\n locatorSettings.searchEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"search-field\"]')\n locatorSettings.submitEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"submit\"]');\n locatorSettings.radiusEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"radius-field\"]');\n locatorSettings.localityEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"locality-field\"]');\n locatorSettings.detectLocationEl = locatorSettings.locatorEl.querySelector('[data-locator-component=\"detect-location\"]');\n\n locatorSettings.confirmSelectionAction = locatorSettings.locatorEl.querySelector('[data-locator-component=\"confirm-selection\"]');\n locatorSettings.ignoreSelectionAction = locatorSettings.locatorEl.querySelector('[data-locator-component=\"ignore-selection\"]');\n}\n\nfunction _setupEventListeners(locatorSettings) {\n // clicking on detect location.\n if (locatorSettings.detectLocationEl) {\n locatorSettings.detectLocationEl.addEventListener('click', _detectLocationHandler.bind(locatorSettings.detectLocationEl, locatorSettings));\n }\n\n if (locatorSettings.radiusEl) {\n locatorSettings.radiusEl.addEventListener('change', _storeSearchHandler.bind(locatorSettings.radiusEl, locatorSettings));\n }\n\n if (locatorSettings.localityEl) {\n locatorSettings.localityEl.addEventListener('change', _storeSearchHandler.bind(locatorSettings.localityEl, locatorSettings));\n }\n\n if (locatorSettings.locatorForm.tagName === 'FORM') {\n locatorSettings.locatorForm.addEventListener('submit', _storeSearchHandler.bind(locatorSettings.locatorForm, locatorSettings));\n } else {\n locatorSettings.submitEl.addEventListener('click', _storeSearchHandler.bind(locatorSettings.submitEl, locatorSettings));\n }\n\n _storeSelectionListener(locatorSettings);\n\n if (locatorSettings.confirmSelectionAction) {\n locatorSettings.confirmSelectionAction.addEventListener('click', _confirmSelectionHandler.bind(locatorSettings.confirmSelectionAction, locatorSettings));\n }\n\n if (locatorSettings.ignoreSelectionAction) {\n locatorSettings.ignoreSelectionAction.addEventListener('click', _ignoreSelectionHandler.bind(locatorSettings.ignoreSelectionAction, locatorSettings));\n }\n}\n\n/**\n * Checks if the current `locatorSettings.targetFormEl` already has selected a store,\n * by checking if it can find a `[data-locator-component=\"selected-store-id\"]` with a value in it.\n */\nfunction _shouldRequestSearch(locatorSettings) {\n let selectedStoreIDInput = getSelectedStoreInput(locatorSettings.targetFormEl);\n\n return !selectedStoreIDInput || !selectedStoreIDInput.value || locatorSettings.allowSearchAfterSelection;\n}\n","var CALLBACK_NAME = '__googleMapsApiOnLoadCallback'\n\nvar OPTIONS_KEYS = ['channel', 'client', 'key', 'language', 'region', 'v']\n\nvar promise = null\n\nmodule.exports = function (options) {\n options = options || {}\n\n if (!promise) {\n promise = new Promise(function (resolve, reject) {\n // Reject the promise after a timeout\n var timeoutId = setTimeout(function () {\n window[CALLBACK_NAME] = function () {} // Set the on load callback to a no-op\n reject(new Error('Could not load the Google Maps API'))\n }, options.timeout || 10000)\n\n // Hook up the on load callback\n window[CALLBACK_NAME] = function () {\n if (timeoutId !== null) {\n clearTimeout(timeoutId)\n }\n resolve(window.google.maps)\n delete window[CALLBACK_NAME]\n }\n\n // Prepare the `script` tag to be inserted into the page\n var scriptElement = document.createElement('script')\n var params = ['callback=' + CALLBACK_NAME]\n OPTIONS_KEYS.forEach(function (key) {\n if (options[key]) {\n params.push(key + '=' + options[key])\n }\n })\n if (options.libraries && options.libraries.length) {\n params.push('libraries=' + options.libraries.join(','))\n }\n scriptElement.src =\n 'https://maps.googleapis.com/maps/api/js?' + params.join('&')\n\n // Insert the `script` tag\n document.body.appendChild(scriptElement)\n })\n }\n\n return promise\n}\n"],"sourceRoot":""}