(function(){'use strict';var loading=false,getGoogleLatitudeLongitude=function(position){return new google.maps.LatLng(position.latitude,position.longitude);},gmAuthFailure=false;window.gm_authFailure=function(){gmAuthFailure=true;};window.GoogleMap=function(element,markers,additionalOptions){var options,style;if(gmAuthFailure){return;} try{style=googleMapsConfig.style?JSON.parse(googleMapsConfig.style):[];}catch(error){style=[];} options=_.extend({zoom:8,center:getGoogleLatitudeLongitude({latitude:30.2672,longitude:-97.7431}),scrollwheel:false,disableDoubleClickZoom:false,disableDefaultUI:false,mapTypeControl:true,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DEFAULT},styles:style},additionalOptions);this.map=new google.maps.Map(element,options);this.markers=[];this.onUpdate=function(newMarkers,updateOptions){this.map.setOptions(updateOptions);this.setMarkers(newMarkers);};this.setMarkers=function(newMarkers){var activeInfoWindow,latitudeLongitudeBounds=new google.maps.LatLngBounds();this.markers.forEach(function(marker){marker.setMap(null);},this);this.markers=[];this.bounds=[];if(newMarkers&&newMarkers.length){newMarkers.forEach(function(newMarker){var location=_.escape(newMarker['location_name'])||'',comment=newMarker.comment?'

'+_.escape(newMarker.comment).replace(/(?:\r\n|\r|\n)/g,'
')+'

':'',phone=newMarker.phone?'

Phone: '+_.escape(newMarker.phone)+'

':'',address=newMarker.address?_.escape(newMarker.address)+'
':'',city=_.escape(newMarker.city)||'',country=newMarker.country?_.escape(newMarker.country):'',state=newMarker.state?_.escape(newMarker.state)+' ':'',zipCode=newMarker.zipcode?_.escape(newMarker.zipcode):'',cityComma=city!==''&&(zipCode!==''||state!=='')?', ':'',lineBreak=city!==''||zipCode!==''?'
':'',contentString='
'+'

'+location+'

'+ comment+ phone+'

'+address+ city+cityComma+state+zipCode+lineBreak+ country+'

'+'
',infowindow=new google.maps.InfoWindow({content:contentString,maxWidth:350}),newCreatedMarker=new google.maps.Marker({map:this.map,position:getGoogleLatitudeLongitude(newMarker.position),title:location});if(location){newCreatedMarker.addListener('click',function(){if(activeInfoWindow){activeInfoWindow.close();} infowindow.open(this.map,newCreatedMarker);activeInfoWindow=infowindow;},this);} this.markers.push(newCreatedMarker);this.bounds.push(getGoogleLatitudeLongitude(newMarker.position));},this);} if(this.bounds.length>1){this.bounds.forEach(function(bound){latitudeLongitudeBounds.extend(bound);});this.map.fitBounds(latitudeLongitudeBounds);} if(this.bounds.length===1){this.map.setCenter(this.bounds[0]);this.map.setZoom(8);}};this.setMarkers(markers);};window.pagebuilderMapsLoad=function(){if(loading){return;} loading=true;$.loadScript(googleMapsConfig.src+'&callback=pagebuilderMapsLoaded');};window.pagebuilderMapsLoaded=function(){var maps=$.registry.get('pagebuilderMap');if(!maps){return;} $.each(maps,function(){this.initMap();});};$.widget('pagebuilderMap',{component:'Magento_PageBuilder/js/content-type/map/appearance/default/widget',create:function(){var locations=this.element.attr('data-locations'),controls,mapOptions={};if(!locations||locations==='[]'){return $(element).hide();} locations=JSON.parse(locations);locations.forEach(function(location){location.position.latitude=parseFloat(location.position.latitude);location.position.longitude=parseFloat(location.position.longitude);});this.locations=locations;controls=this.element.attr('data-show-controls');mapOptions.disableDefaultUI=controls!=='true';mapOptions.mapTypeControl=controls==='true';this.mapOptions=mapOptions;if(typeof google==='undefined'){pagebuilderMapsLoad();}else{this.initMap();}},initMap:function(){if(!this.locations){return;} new GoogleMap(this.element[0],this.locations,this.mapOptions);}});})();