!function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=87)}({46:function(t,e,o){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=class{static async geoCodeAddress(t){const e=new google.maps.Geocoder;if("object"==typeof t)return new Promise((o,n)=>{e.geocode(t,(t,e)=>"OK"===e?o(t):n(e))});throw new Error("Location should be an object")}}},87:function(t,e,o){"use strict";var n,r=o(46),a=(n=r)&&n.__esModule?n:{default:n};(new class{constructor(){this.searchForm=document.querySelectorAll('[data-form="wpseo-local-store-locator"]'),this.locationDetectionButton=document.querySelector(".wpseo_use_current_location"),this.locationDetectionButtonImg=document.querySelector(".wpseo_use_current_location img"),this.defaultCountry=storeLocator.defaultCountry,this.latLng="",this.locationDetection=this.locationDetection.bind(this),this.getLatLng=this.getLatLng.bind(this),this.handleSubmitForm=this.handleSubmitForm.bind(this)}addEventListeners(){this.searchForm.forEach(t=>t.addEventListener("submit",this.handleSubmitForm)),document.addEventListener("click",this.locationDetection)}async locationDetection(t){if(t.target===this.locationDetectionButton||t.target===this.locationDetectionButtonImg){const e=this.locationDetectionButton.dataset.target,o=document.querySelector("#"+e),n=t.target.closest("form"),r=n.querySelector('[name="wpseo-sl-lat"'),s=n.querySelector('[name="wpseo-sl-lng"');try{this.latLng=await this.getLatLng(),r.value=this.latLng.lat,s.value=this.latLng.lng}catch(t){console.log(t)}if(!(this.latLng instanceof Error))try{const t=await a.default.geoCodeAddress({location:this.latLng});o.value=t[0].formatted_address}catch(t){console.log(t)}}}async getLatLng(){return new Promise((t,e)=>{navigator.geolocation.getCurrentPosition(e=>t({lat:parseFloat(e.coords.latitude),lng:parseFloat(e.coords.longitude)}),(function(t){return e(new Error("Location detection unsuccesfull"))}))})}async handleSubmitForm(t){t.preventDefault();const e=t.target.querySelector('[name="wpseo-sl-lat"'),o=t.target.querySelector('[name="wpseo-sl-lng"'),n=t.target.querySelector('[name="wpseo-sl-search"');if(""===e.value||""===o.value){document.removeEventListener("submit",this.handleSubmitForm);const r=new Promise(async(t,r)=>{let s=n.value;""!==this.defaultCountry&&(s+=", "+this.defaultCountry);const i=await a.default.geoCodeAddress({address:s});e.value=i[0].geometry.location.lat(),o.value=i[0].geometry.location.lng(),""!==e.value&&""!==o.value&&t("success")});"success"===await r&&t.target.submit()}else t.target.submit()}}).addEventListeners()}});