1import{M as R,x as B,y as W,B as $,C as u,L as c,F as a,O as _,P as y,Q as v,R as b,S as T,U as k,I as h,V as S,D as Z}from"./runtime-dom.esm-bundler.CqpSJMCm.js";import{L as J,M as H}from"./index.esm.CbbaYiiG.js";import{C as Q}from"./Combobox.AGIhGtKJ.js";import Y from"./MapResults.T7-ya0PL.js";import X from"./MapFilters.dK6n8EcE.js";import ee from"./Reveal.Cr6NVM_t.js";import{_ as te}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./_commonjsHelpers.Cpj98o6Y.js";import"./preload-helper.BcZewWem.js";import"./focus-trap.esm.CPw4bcQR.js";const se={class:"l-twoColumn l-twoColumn--leftSidebar l-twoColumn--noDivider"},oe={class:"l-twoColumn__nav stickySidebar",id:"two-column-nav"},re={class:"h4"},ae={class:"mapContainer"},ne={key:0,class:"loaderOverlay"},le={class:"searchFormContainer"},ie={key:0,role:"alert",class:"formControl__error"},ce={class:"h5"},de={class:"searchForm__controls"},pe={class:"formControl"},ue={class:"adjInputButton adjInputButton--wrap"},me=["innerHTML"],fe={class:"mapSearch__optionSubtext"},ge={key:0,role:"alert",class:"formControl__error"},he={class:"l-twoColumn__main"},we={__name:"MapSearch",props:{formTitle:String,sectionType:String,filters:Array},setup(d){const E=d,e=R({bounds:null,error:"",infoWindow:{},map:null,mapLoading:!0,placesAutocomplete:[],placeId:"",autocompleting:!1,requestedEntryIDs:[],searchAddress:"",searchError:"",showControls:!1,visibleMarkerCount:0,watershedBounds:null});let p=[],m,M,x,C;const L=B(null),P=B(null),F=new J({apiKey:"AIzaSyD2Y4BhL0V9e_1B3NW2-gw5Gc0_ixqrQAc",version:"weekly"});W(async()=>{const s={},t=["core","maps","marker","places"];(await Promise.all(t.map(l=>F.importLibrary(l)))).map((l,g)=>{const w=t[g];["marker","places","geometry"].includes(w)?s.maps[w]=l:s.maps={...s.maps||{},...l}});const r=new s.maps.LatLng({lat:36.791478,lng:-80.663211}),n=new s.maps.LatLng({lat:43.016932,lng:-74.269264}),i=new s.maps.LatLngBounds(r,n);C=new s.maps.LatLngBounds(r,n);const f={center:i.getCenter(),zoom:6};e.map=new s.maps.Map(L.value,f),M=new s.maps.places.AutocompleteService,x=new s.maps.places.PlacesService(e.map),s.maps.Map.prototype.clearMarkers=function(){for(let l=0;l<p.length;l++)p[l].setMap(null);p=[]},s.maps.event.addListenerOnce(e.map,"idle",()=>V(s)),s.maps.event.addListener(e.map,"idle",()=>A()),e.infowindow=new s.maps.InfoWindow});function V(s){I([]).then(t=>{if(Array.isArray(t.data)){p=t.data.map(n=>{let i=new s.maps.marker.Marker({position:{lat:n.l,lng:n.o},map:e.map,id:n.id});return i.addListener("click",()=>D(i,n)),i});const o=e.map,r={render({count:n,position:i},q){let f,l,g;n<25?(f="#47803A",l=36,g=36):n<100?(f="#2F7E87",l=41,g=41):n<200?(f="#38238F",l=46,g=46):(f="#961572",l=51,g=51);const w=window.btoa(` 2 <svg fill="${f}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240"> 3 <circle cx="120" cy="120" opacity="1" r="100" /> 4 <circle cx="120" cy="120" opacity="1" r="90" stroke="white" stroke-width="5" /> 5 </svg>`);let K=new s.maps.Size(l,g);return new s.maps.marker.Marker({position:i,icon:{url:`data:image/svg+xml;base64,${w}`,scaledSize:K},label:{text:String(n),color:"rgba(255,255,255,1)",fontSize:"12px"},zIndex:1e3+n,title:"This cluster contains "+String(n)+" location markers"})}};
5m=new H({map:o,markers:p,renderer:r}),m.addListener("clusteringend",()=>e.mapLoading=!1)}else e.error="Sorry, something went wrong. Please refresh the page and try again, or contact us."})}async function I(s){const t=await fetch(`/api/${E.sectionType}/markers.json?filters=${JSON.stringify(s)}`,{method:"GET",headers:{Accept:"application/json"},credentials:"same-origin"});return t.ok||(console.log(t),e.error="Sorry, something went wrong. Please refresh the page and try again, or contact us."),t.json()}function D(s,t){e.map.setZoom(15),e.map.panTo(s.position);const o=`https://www.google.com/maps?saddr=&daddr=(${t.l},+${t.o})`,r='<div class="infoWindow"><p><strong class="h5">'+t.t+'</strong></p><a href="'+o+'" class="button button--primary button--expand" target="_blank" rel="ext" rel="noreferrer">View in Google Maps</a></div>';e.infowindow.setContent(r),e.infowindow.open(e.map,s)}function A(){const s=e.map.getBounds();e.bounds=s,e.center=e.map.getCenter();let t=p.filter(r=>s.contains(r.getPosition())&&r.visible),o=[...new Set(t.map(r=>r.id))];JSON.stringify(o)!==JSON.stringify(e.requestedEntryIDs)&&(e.requestedEntryIDs=o)}function N(){if(e.searchError="",e.searchAddress===""){e.searchError="Please enter a search location.";return}if(e.searchAddress.length===5&&!isNaN(e.searchAddress)&&(e.searchAddress+=" USA"),e.placeId){G(e.placeId);return}new google.maps.Geocoder().geocode({address:e.searchAddress,bounds:e.watershedBounds,region:"US"},(t,o)=>{o==="OK"?(e.map.setZoom(13),e.map.panTo(t[0].geometry.location)):(console.log("Geocode was not successful for the following reason: "+o),e.searchError="Search unsuccessful, please try something else.")})}function O(){navigator.geolocation&&navigator.geolocation.getCurrentPosition(s=>{console.log(s),e.map.panTo({lat:s.coords.latitude,lng:s.coords.longitude}),e.map.setZoom(13)})}function j(s){M.getPlacePredictions({input:s,componentRestrictions:{country:"us"},language:"en",locationBias:C,types:["geocode"]},(t,o)=>{(t??[]).forEach(r=>r.main_text=r.structured_formatting.main_text),e.placesAutocomplete=o==="OK"?t:[]})}function G(s){let t={placeId:s};x.getDetails(t,function(o,r){r===google.maps.places.PlacesServiceStatus.OK?(e.map.setZoom(13),e.map.setCenter(o.geometry.location)):(console.log("PlacesService not successful for the following reason: "+r),e.searchError="Search unsuccessful, please try something else.")})}function U(s){e.autocompleting=!0,e.placeId=s.place_id}async function z(s){e.mapLoading=!0,s.length?await I(s).then(t=>{const o=t.data;Array.isArray(o)&&(p.forEach(r=>{let n=!!o.find(i=>i.id===r.id);r.setVisible(n),n?m.addMarker(r,!0):m.removeMarker(r,!0)}),m.render())}):(p.forEach(t=>{t.setVisible(!0),m.addMarker(t,!0)}),m.render()),A()}return $(()=>e.searchAddress,s=>{!e.autocompleting&&e.placeId!==""&&(e.placeId=""),e.autocompleting=!1,j(s)}),(s,t)=>(c(),u("div",se,[a("div",oe,[_(ee,{show:e.showControls,target:"#search-reveal-target",onToggleReveal:t[3]||(t[3]=o=>e.showControls=o),style:{"--revealMaxWidth":"500px"}},{button:y(()=>[d.sectionType==="watershedGroups"?(c(),u(S,{key:0},[h("Search groups")],64)):(c(),u(S,{key:1},[h("Search sites")],64)),t[4]||(t[4]=a("span",{class:"appendedIcon"},[h("â"),a("i",{class:"fa-solid fa-angle-right"})],-1))]),header:y(()=>[a("h2",re,[d.sectionType==="watershedGroups"?(c(),u(S,{key:0},[h("Search Groups")],64)):(c(),u(S,{key:1},[h("Search Sites")],64))])]),content:y(()=>[a("div",ae,[a("div",{class:"google-map",ref_key:"googleMap",ref:L},null,512),e.mapLoading?(c(),u("div",ne,t[5]||(t[5]=[a("div",{class:"loader"},null,-1)]))):v("",!0)]),a("div",le,[e.error?(c(),u("p",ie,b(e.error),1)):v("",!0),a("form",{class:"searchForm",id:"searchForm",onSubmit:k(N,["prevent"]),onKeydown:[t[1]||(t[1]=T(k(()=>{},["prevent"]),["down"])),t[2]||(t[2]=T(k(()=>{},["prevent"]),["up"]))]},[a("h3",ce,b(d.formTitle),1),t[9]||(t[9]=a("label",{for:"mapSearch__input",class:"searchForm__label"},"Search by name, address, city, state or zip code",-1)),a("div",de,[a("button",{onClick:O,type:"button",class:"button button--secondary searchForm__geoLocate"},t[6]||(t[6]=[a("span",{class:"fa-solid fa-location-crosshairs",title:"Use my current location"},null,-1)])),a("div",pe,[a("div",ue,[_(Q,{ref_key:"searchTextField",ref:P,class:"adjInputButton__input","filter-options":!1,"id-prefix":"mapSearch",options:e.placesAutocomplete,"options-searchable-keys":["description","main_text"],"show-input-label":!1,teleport:!0,modelValue:e.searchAddress,"onUpdate:modelValue":t[0]||(t[0]=o=>e.searchAddress=o),onSelect:U},{option:y(o=>[t[7]||(t[7]=a("i",{class:"prependedIcon mapSearch__optionIcon fas fa-location-dot fa-sm"},null,-1)),a("span",{innerHTML:o.option.main_text},null,8,me),a("span",fe,b(o.option.structured_formatting.secondary_text),1)]),_:1},8,["options","modelValue"]),t[8]||(t[8]=a("button",{type:"submit",class:"button button--primary adjInputButton__button u-noWrap"},[a("i",{class:"prependedIcon fas fa-search fa-fw"}),h("Search ")],-1))]),e.searchError?(c(),u("span",ge,b(e.searchError),1)):v("",!0)])])],32)])]),_:1},8,["show"])]),a("div",he,[d.filters&&d.filters.length?(c(),Z(X,{key:0,class:"mapFilters",filters:d.filters,onFiltersChanged:z},null,8,["filters"])):v("",!0),_(Y,{class:"results","entry-ids":e.requestedEntryIDs,bounds:e.bounds,"visible-locations":e.visibleMarkerCount,"section-type":d.sectionType,"load-more-text":"Load More Results","no-results-text":"Sorry, we couldn't find any results that match your search. Please try adjusting your search location or removing any filters you may have selected."},null,8,["entry-ids","bounds","visible-locations","section-type"])])]))}},Ie=te(we,[["__scopeId","data-v-f30725f6"]]);export{Ie as default}; 6//# sourceMappingURL=MapSearch.zeLeEcx8.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.