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AmBC,IAAI,GACtC,CAuBQC,CAAc9C,EAAmBU,GAAQiB,EAC7C,GACJ,EAEAC,IAAEmB,UAAUC,GAAG,mBAAmB,WAC9B,IAGIC,EAAW,EAETC,EAAsB,WACF,qBAAXpC,SACPmC,EANa,GASTE,WAAWD,EAVH,MAaRE,QAAQC,MAAM,0CACdC,QAAQD,MAAM,2CAIlBzB,IAAE,mBAAmB2B,MAAK,SAAC7C,EAAOC,GAC9BF,EAAiBC,EAAOC,EAC5B,GAER,EAEAuC,GACJ,G","sources":["webpack://cwrmb/./app/javascript/packs/google-maps.js"],"sourcesContent":["/* global google:true */\n/* eslint-disable camelcase */\n/*\n * This sample uses the Autocomplete widget to help the user select a\n * place, then it retrieves the address components associated with that\n * place, and then it populates the form fields with those details.\n * This sample requires the Places library. Include the libraries=places\n * parameter when you first load the API. For example:\n * \n */\n\n/* global Rollbar */\nimport $ from 'jquery';\n\nconst autocompleteFields = [];\n\nconst componentForm = {\n subpremise: 'short_name',\n street_number: 'short_name',\n route: 'long_name',\n locality: 'long_name',\n administrative_area_level_1: 'short_name',\n country: 'long_name',\n postal_code: 'short_name'\n};\n\n/*\n * Bias the autocomplete object to the user's geographical location,\n * as supplied by the browser's 'navigator.geolocation' object.\n */\nconst geolocate = autocompleteField => {\n const geolocation = {\n lat: 49.8951,\n lng: -97.1384\n };\n const circle = new google.maps.Circle({\n center: geolocation,\n radius: 100000\n });\n autocompleteField.setBounds(circle.getBounds());\n};\n\nconst setFields = ($form, address) => {\n let street = '';\n\n if (address.subpremise) {\n street += `${address.subpremise}-`;\n }\n\n street += `${address.street_number} ${address.route}`;\n $form.find('.address_line1').val(street);\n $form.find('.address_city').val(address.locality);\n $form.find('.address_province').val(address.administrative_area_level_1);\n $form.find('.address_postal_code').val(address.postal_code);\n};\n\nconst fillInAddress = (autocompleteField, $form) => {\n // Get the place details from the autocomplete object.\n const place = autocompleteField.getPlace();\n const address = {};\n\n /*\n * Get each component of the address from the place details,\n * and then fill-in the corresponding field on the form.\n */\n for (const component of place.address_components) {\n const addressType = component.types[0];\n\n if (componentForm[addressType]) {\n address[addressType] = component[componentForm[addressType]];\n }\n }\n\n setFields($form, address);\n\n $form.find('.address_lookup').val('');\n};\n\nconst initAutocomplete = (index, field) => {\n /*\n * Create the autocomplete object, restricting the search predictions to\n * geographical location types.\n */\n autocompleteFields[index] = new google.maps.places.Autocomplete(field,\n {types: ['geocode'], strictBounds: true});\n geolocate(autocompleteFields[index]);\n\n const $fieldset = $(field).closest('fieldset');\n\n /*\n * Avoid paying for data that you don't need by restricting the set of\n * place fields that are returned to just the address components.\n */\n autocompleteFields[index].setFields(['address_component']);\n /*\n * When the user selects an address from the drop-down, populate the\n * address fields in the form.\n */\n autocompleteFields[index].addListener('place_changed', () => {\n fillInAddress(autocompleteFields[index], $fieldset);\n });\n};\n\n$(document).on('turbolinks:load', () => {\n const RETRY_DELAY = 500; // milliseconds\n const MAX_ATTEMPTS = 10; // 5 seconds / 500ms = 10 attempts\n const MAX_DELAY = RETRY_DELAY * MAX_ATTEMPTS / 1000; // seconds\n let attempts = 0;\n\n const initIfGoogleDefined = () => {\n if (typeof google === 'undefined') {\n attempts++;\n\n if (attempts < MAX_ATTEMPTS) {\n setTimeout(initIfGoogleDefined, RETRY_DELAY);\n }\n else {\n console.error(`Google API not loaded after ${MAX_DELAY} seconds.`); // eslint-disable-line no-console\n Rollbar.error(`Google API not loaded after ${MAX_DELAY} seconds.`);\n }\n }\n else {\n $('.address_lookup').each((index, field) => {\n initAutocomplete(index, field);\n });\n }\n };\n\n initIfGoogleDefined();\n});"],"names":["autocompleteFields","componentForm","subpremise","street_number","route","locality","administrative_area_level_1","country","postal_code","initAutocomplete","index","field","autocompleteField","circle","google","maps","places","Autocomplete","types","strictBounds","Circle","center","lat","lng","radius","setBounds","getBounds","$fieldset","$","closest","setFields","addListener","$form","_step","address","_iterator","_createForOfIteratorHelperLoose","getPlace","address_components","done","component","value","addressType","street","find","val","fillInAddress","document","on","attempts","initIfGoogleDefined","setTimeout","console","error","Rollbar","each"],"sourceRoot":""}