1var e=Object.defineProperty,t=(t,a,s)=>((t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s)(t,"symbol"!=typeof a?a+"":a,s),a=(e,t,a)=>new Promise((s,l)=>{var i=e=>{try{r(a.next(e))}catch(t){l(t)}},n=e=>{try{r(a.throw(e))}catch(t){l(t)}},r=e=>e.done?s(e.value):Promise.resolve(e.value).then(i,n);r((a=a.apply(e,t)).next())});import{f as s,A as l}from"./index.cz83wh4sws6slzdm.js";import{a as i,A as n}from"./index.fwy4myo0zwt1lnjt.js";import{a as r}from"./feefo-template.gtt8oisukmrhee1q.js";const o=e=>{var t,s,l,i="The Google Maps JavaScript API",n="google",r="importLibrary",o="__ib__",d=document,h=window,m=h[n]||(h[n]={}),c=m.maps||(m.maps={}),p=new Set,f=new URLSearchParams;c[r]?console.warn(i+" only loads once. Ignoring:",e):c[r]=(h,...m)=>p.add(h)&&(t||(t=new Promise((r,h)=>a(null,null,function*(){var a;for(l in yield s=d.createElement("script"),f.set("libraries",[...p]+""),e)f.set(l.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[l]);f.set("callback",n+".maps."+o),function(e,t){e.src=t}(s,"https://maps.googleapis.com/maps/api/js?"+f),c[o]=r,s.onerror=()=>t=h(Error(i+" could not load.")),s.nonce=(null==(a=d.querySelector("script[nonce]"))?void 0:a.nonce)||"",d.head.append(s)})))).then(()=>c[r](h,...m))};let d=!1;function h(e){d?(e=>{JSON.stringify(e)})(e):(!function(e){var t,a;const s=Boolean(null==(a=null==(t=window.google)?void 0:t.maps)?void 0:a.importLibrary);s&&(e=>{JSON.stringify(e)})(e);s||o(e)}(e),d=!0)}class m extends i{init(){}fillData(e){const t=[e.componentStylesSpacingTop,e.componentStylesSpacingBottom,e.componentStylesSpacingLeftAndRight].filter(Boolean);t.length&&this.elements.self.classList.add(...t);const a=e.alt||`Map for ${e.latitude},${e.longitude}`;if(e.isInteractive)this.fillOrRemoveElement(void 0,this.elements.mapImage),this.elements.self.dataset.hmeLatitude=String(e.latitude),this.elements.self.dataset.hmeLongitude=String(e.longitude),this.elements.self.dataset.hmeGoogleMapsKey=e.googleMapsKey,this.elements.self.dataset.hmeMapAlt=a,this.elements.self.dataset.hmeIsInteractive="true";else{this.fillOrRemoveElement(void 0,this.elements.mapIframe);const t=`https://maps.googleapis.com/maps/api/staticmap?size=${640}x${Math.round(360)}&maptype=roadmap&markers=color:red|${e.latitude},${e.longitude}&key=${e.googleMapsKey}`;this.elements.mapImage.dataset.src=t,this.elements.mapImage.alt=a}}}t(m,"NS","hme"),t(m,"IS","map");const c=class e extends i{init(){}fillData(t){const a=e.formatServices(t.services),s=e.formatAward(t.award);this.fillElement(t.distance,this.elements.distance),this.fillElement(t.name,this.elements.name),this.fillElement(t.address,this.elements.address),this.fillOrRemoveElement(t.isNearestDealer?t.nearestDealerLabel:"",this.elements.nearestDealerLabel),this.fillOrRemoveElement(t.state,this.elements.state),this.injectOrRemoveElement(a,this.elements.services),this.injectOrRemoveElement(s,this.elements.award),this.fillDealerLink(t),this.fillDirectionUrl(t),this.fillMapImage(t),this.fillFeefo(t)}fillDealerLink(e){this.elements.dealerLink&&e.url&&this.elements.dealerLinkLabel&&e.urlLabel&&(this.elements.dealerLink.href=e.url,this.elements.dealerLinkLabel.textContent=e.urlLabel)}fillDirectionUrl(e){this.elements.directionsLink&&this.elements.directionsLabel&&e.directionUrl&&e.directionLabel&&(this.elements.directionsLink.href=e.directionUrl,this.elements.directionsLabel.textContent=e.directionLabel)}fillMapImage(e){if(!e.googleMapsKey||!this.elements.mapImage)return;const t={latitude:e.latitude,longitude:e.longitude,googleMapsKey:e.googleMapsKey,isInteractive:e.useInteractiveMap,alt:e.name},a=s(m,'<div class="hme-component hme-map" data-hme-is="map" data-hme-latitude="" data-hme-longitude=""\n data-hme-google-maps-key="" data-hme-map-alt="">\n <div class="hme-map__wrapper" data-hme-hook-template-map="wrapper">\n <img class="hme-map__image hme-lazy" data-hme-hook-template-map="mapImage" data-src="" alt="" width="640"\n height="360" />\n <iframe class="hme-map__iframe hme-lazy" data-hme-hook-map="mapIframe" data-hme-hook-template-map="mapIframe" data-src="" width="640" height="360"\n referrerpolicy="no-referrer-when-downgrade" allowfullscreen="false" title="..."></iframe>\n </div>\n</div>\n');a.fillData(t),this.elements.mapImage.appendChild(a.elements.self)}fillFeefo(e){var t;if(!this.elements.feefo||!e.feefoBranchId||!e.feefoJs)return void(null==(t=this.elements.feefo)||t.remove());const a=["aftersales","car"];for(const l of a){const t={type:"pop-up",feefoJs:e.feefoJs,branchId:e.feefoBranchId,campaign:l},a=s(r,'<div class="hme-component hme-feefo" data-hme-is="feefo" data-hme-js="">\n\n <feefo-product-stars data-hme-hook-template-feefo="productStars" sku=""></feefo-product-stars>\n\n <feefo-product-stars data-hme-hook-template-feefo="parentProductStars" parent-product-sku=""></feefo-product-stars>\n\n <feefo-product-reviews data-hme-hook-template-feefo="productReviews" sku=""></feefo-product-reviews>\n\n <feefo-product-reviews data-hme-hook-template-feefo="parentProductReviews"\n parent-product-sku=""></feefo-product-reviews>\n\n <feefo-on-page-stars data-hme-hook-template-feefo="onPageStars"></feefo-on-page-stars>\n\n <feefo-product-pop-up data-hme-hook-template-feefo="productPopUp" sku=""></feefo-product-pop-up>\n\n <feefo-product-pop-up data-hme-hook-template-feefo="parentProductPopUp" parent-product-sku=""></feefo-product-pop-up>\n\n <feefo-pop-up data-hme-hook-template-feefo="popUp" tags=""></feefo-pop-up>\n\n <feefo-reviewable-badge data-hme-hook-template-feefo="reviewableBadge" class="hme-feefo__badge" sku=""\n version="20"></feefo-reviewable-badge>\n\n <feefo-reviewable-badge data-hme-hook-template-feefo="parentReviewableBadge" class="hme-feefo__badge"\n parent-product-sku="" version="20"></feefo-reviewable-badge>\n\n <img data-hme-hook-template-feefo="serviceStars150" class="hme-feefo__stars" src="" width="150" height="150" alt="" />\n\n <img data-hme-hook-template-feefo="serviceStars200" class="hme-feefo__stars" src="" width="200" height="200" alt="" />\n\n</div>\n');a.fillData(t),this.elements.feefo.appendChild(a.elements.self)}}static formatAward(e){var t;if(!(null==e?void 0:e.link)||!(null==e?void 0:e.imageLandscape))return;const a=document.createElement("a"),s=document.createElement("img");return a.href=e.link,s.src=e.imageLandscape,s.alt=null!=(t=e.imgAlt)?t:"",a.appendChild(s),a}static formatServices(e){if(!e||0===e.length)return;const t=[];
1return e.forEach(e=>{const a=document.createElement("span");a.textContent=e,t.push(a)}),t}};t(c,"NS","hme"),t(c,"IS","find-a-dealer");let p=c;const f='\x3c!-- Should this be a stand alone element? --\x3e\n<li class="hme-dealer-item" data-hme-hook-template-find-a-dealer="self">\n <div class="hme-dealer-item__dealer-info-container">\n <div class="hme-dealer-item__nearest-label"\n data-hme-hook-template-find-a-dealer="nearestDealerLabel"></div>\n <div class="hme-dealer-item__distance" data-hme-hook-template-find-a-dealer="distance">\n </div>\n <div class="hme-dealer-item__name" data-hme-hook-template-find-a-dealer="name"></div>\n <div class="hme-dealer-item__state" data-hme-hook-template-find-a-dealer="state"></div>\n <div class="hme-dealer-item__address">\n <i class="hme-dealer-item__address-icon" aria-hidden="true"></i>\n <span class="hme-dealer-item__address-text"\n data-hme-hook-template-find-a-dealer="address"></span>\n </div>\n <div class="hme-dealer-item__services" data-hme-hook-template-find-a-dealer="services">\n </div>\n <div class="hme-dealer-item__award-wrapper" data-hme-hook-template-find-a-dealer="award"></div>\n <div class="hme-dealer-item__feefo-wrapper" data-hme-hook-template-find-a-dealer="feefo"></div>\n <div class="hme-dealer-item__buttons-wrapper">\n <a class="hme-dealer-item__directions-link"\n data-hme-hook-template-find-a-dealer="directionsLink" target="_blank" rel="noopener noreferrer">\n <span data-hme-hook-template-find-a-dealer="directionsLabel">​</span>\n <i class="hme-dealer-item__directions-icon" role="img" aria-hidden="true"></i>\n </a>\n <a class="hme-dealer-item__link" data-hme-hook-template-find-a-dealer="dealerLink">\n <span data-hme-hook-template-find-a-dealer="dealerLinkLabel">​</span>\n <i class="hme-dealer-item__link-icon" role="img" aria-hidden="true"></i>\n </a>\n </div>\n </div>\n <div class="hme-dealer-item__map-container">\n <div class="hme-dealer-item__map" data-hme-hook-template-find-a-dealer="mapImage"></div>\n </div>\n</li>\n',u="find-a-dealer",g=`[data-hme-is="${u}"]`,v="find-a-dealer--is-loading",w="find-a-dealer--no-search-performed",L="find-a-dealer--has-no-dealers",k="find-a-dealer--has-dealers-list",b="find-a-dealer--has-no-exact-matches",y="find-a-dealer--show-last-dealer",S="find-a-dealer--has-search-error",D="find-a-dealer--has-search-form-error",_="find-a-dealer--has-more-dealers",I="find-a-dealer--has-filters",E="find-a-dealer--show-filters-required-message";class C extends n{constructor(){super(...arguments),t(this,"allDealers",[]),t(this,"currentPage",0),t(this,"abortController",null)}init(){this.addEventHandlers(),this.applyUrlParams(),this.checkLastViewedDealer()}addEventHandlers(){this.elements.searchForm.addEventListener("submit",e=>{this.onFormSubmit(e)}),this.elements.searchFormGeo.addEventListener("click",()=>{this.onSearchFormGeoClick()}),this.elements.searchInput.addEventListener("input",()=>{this.elements.self.classList.remove(D)}),this.elements.showMoreButton.addEventListener("click",()=>{this.onShowMoreClick()}),this.elements.clearFiltersButton.addEventListener("click",()=>{this.onClearFiltersClick()}),!0===this.options.hasGoogleAutocomplete&&this.initGoogleAutocomplete(),this.options.useOneServiceMinimum&&this.elements.searchForm.addEventListener("change",e=>{this.onFormChange(e)})}applyUrlParams(){const e=new URLSearchParams(window.location.search),t=e.get("query"),a=e.get("filters");if(a){const e=a.split(",");this.elements.filters.forEach(t=>{e.includes(t.value)&&(t.checked=!0)})}t&&(this.elements.searchInput.value=t,this.onFormSubmit())}setResultHeader(e,t){const a=null==e?void 0:e.includes("{0}"),s=(null==e?void 0:e.replace("{0}",""))||"";if(this.elements.resultsHeader.textContent=s,a&&t){const e=document.createElement("b");e.textContent=t,this.elements.resultsHeader.appendChild(e)}}renderDealersResults(e,t){this.allDealers=e,this.currentPage=0,this.elements.self.classList.remove(v),1===e.length&&!0===e[0].aboveSearchRadius?(this.setResultHeader(this.options.noExactMatchesLabel,t),this.elements.self.classList.add(b)):this.setResultHeader(this.options.resultsLabel,t),this.elements.self.classList.add(k),this.elements.dealerList.innerHTML="",this.renderDealersPage()}renderDealersPage(){const e=3*this.currentPage,t=e+3;this.allDealers.slice(e,t).forEach((t,a)=>{const l=this.mapDealerDataToTemplateData(t,e+a),i=s(p,f);i.fillData(l),this.elements.dealerList.appendChild(i.elements.self)}),t<this.allDealers.length?this.elements.self.classList.add(_):this.elements.self.classList.remove(_)}onFormChange(e){var t;"checkbox"===(null==(t=e.target)?void 0:t.type)&&this.elements.self.classList.remove(E)}onShowMoreClick(){this.currentPage++,this.renderDealersPage()}
1onClearFiltersClick(){this.elements.filters.forEach(e=>{e.checked=!1}),this.onFormSubmit()}renderNoResults(e,t){this.elements.self.classList.remove(v),this.elements.self.classList.add(L),this.setResultHeader(null!=e?e:"",t),this.checkLastViewedDealer()}clearSearchClasses(){this.elements.self.classList.remove(v,w,L,k,b,y,S,D,_)}updateUrlParams(e,t){const a=new URLSearchParams(window.location.search);e?a.set("query",e):a.delete("query"),t.length>0?a.set("filters",t.join(",")):a.delete("filters"),history.replaceState(null,"",`${window.location.pathname}?${a.toString()}`)}handleSearchError(){this.elements.self.classList.add(S),this.renderNoResults(this.options.searchErrorMessage)}handleSearchFormError(e){this.elements.self.classList.add(D),this.elements.searchFormErrorBarText.textContent=e}validateSearch(e,t){return e.trim()?!(this.options.useOneServiceMinimum&&!t.length)||(this.elements.self.classList.add(E),!1):(this.handleSearchFormError(this.options.emptyQueryErrorMessage||""),!1)}onFormSubmit(e){return a(this,null,function*(){null==e||e.preventDefault(),this.abortController&&this.abortController.abort();const t=new FormData(this.elements.searchForm),a=t.get("q"),s=t.getAll("filters").map(e=>String(e));if(this.validateSearch(a,s)){this.updateUrlParams(a,s),this.abortController=new AbortController,this.elements.self.classList.add(v),s.length?this.elements.self.classList.add(I):this.elements.self.classList.remove(I),this.elements.searchInput.offsetTop-window.scrollY<0&&this.elements.searchForm.scrollIntoView({behavior:"smooth"});try{const e=yield this.getDealersData(a,s,this.abortController.signal);this.clearSearchClasses(),e.length>0?this.renderDealersResults(e,a):this.renderNoResults(this.options.noResultsLabel,a)}catch(l){if(this.clearSearchClasses(),l instanceof Error&&"AbortError"===l.name)return;console.error("Dealer search failed",l),this.handleSearchError()}}})}onSearchFormGeoClick(){navigator.geolocation.getCurrentPosition(e=>{const{latitude:t,longitude:a}=e.coords;this.elements.searchInput.value=`${t} ${a}`,this.onFormSubmit()},e=>{console.warn("Geolocation failed",e),this.handleSearchFormError(this.options.geoSearchErrorMessage||"")})}initGoogleAutocomplete(){return a(this,null,function*(){try{if(!this.options.googleMapsKey)throw new Error("Google Maps API key is required");h({key:this.options.googleMapsKey,v:"weekly"});const{Autocomplete:e}=yield function(e){return a(this,null,function*(){var t,a;if(!(null==(a=null==(t=null==window?void 0:window.google)?void 0:t.maps)?void 0:a.importLibrary))throw new Error("google.maps.importLibrary is not installed.");return yield google.maps.importLibrary(e)})}("places");new e(this.elements.searchInput,{types:["geocode","establishment"],componentRestrictions:{country:[this.options.region||""]}})}catch(e){console.warn("Google Autocomplete failed to initialize. Input field will work without autocomplete.",e)}})}checkLastViewedDealer(){return a(this,null,function*(){const e=yield this.getLastViewedDealerData();e&&this.renderLastViewedDealer(e)})}getLastViewedDealerData(){return a(this,null,function*(){var e;if(!this.options.lastViewedDealerId||!this.options.dealerApiUrl)return null;const t=null!=(e=sessionStorage.getItem(this.options.lastViewedDealerId))?e:localStorage.getItem(this.options.lastViewedDealerId);if(!t)return null;const a=new FormData;a.set("dealer",t);const s=yield fetch(this.options.dealerApiUrl,{method:"POST",body:a});return s.ok?yield s.json():null})}renderLastViewedDealer(e){this.elements.self.classList.add(y);const t=this.mapDealerDataToTemplateData(e),a=s(p,f);a.fillData(t),this.elements.lastViewedDealer.innerHTML="",this.elements.lastViewedDealer.appendChild(a.elements.self)}getDealersData(e,t,s){return a(this,null,function*(){if(!this.options.searchApiUrl)throw new Error("Search API URL not configured");const a=new FormData;a.set("q",e),t.length>0&&a.set("filters",t.join(","));const l=yield fetch(this.options.searchApiUrl,{method:"POST",body:a,signal:s});return l.ok||this.handleSearchError(),yield l.json()})}mapDealerDataToTemplateData(e,t){var a,s,i,n,r,o,d;const{dealer:h}=e,m=[h.address.addressLine1,h.address.addressLine2,h.address.city,h.address.postalcode].filter(
1Boolean).join(", "),c=null==(a=h.additionalInfo)?void 0:a.award,p=h.address.lat,f=h.address.lng,u=`${h.name} ${h.address.city}`;let g;g=l()?`maps://?q=${u}&ll=${p},${f}`:`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(u)}&query=${p},${f}`;const v=c?{imagePortrait:null!=(s=c.imagePortrait)?s:"",imageLandscape:null!=(i=c.imageLandscape)?i:"",imgAlt:null!=(n=c.imgAlt)?n:"",link:null!=(r=c.link)?r:""}:void 0,w=h.productServices.map(e=>{var t;return null==(t=e.content)?void 0:t.name}).filter(Boolean);return{latitude:h.address.lat,longitude:h.address.lng,googleMapsKey:this.options.googleMapsKey,distance:this.getDistanceLabel(e),isNearestDealer:0===t,nearestDealerLabel:this.options.nearestDealerLabel,name:h.name,state:h.address.state||void 0,address:m,services:w.length>0?w:void 0,award:v,feefoJs:this.options.feefoJs,feefoBranchId:h.uri,directionUrl:g,directionLabel:this.options.directionsLabel,url:h.alias,urlLabel:null!=(o=this.options.chooseDealerLabel)?o:"",useInteractiveMap:null!=(d=this.options.useInteractiveMap)&&d}}getDistanceLabel(e){var t;const a=null!=(t=this.options.distanceConfig)?t:"both",s=void 0!==e.distanceInMiles&&"0"!==e.distanceInMiles,l=void 0!==e.distanceInKm&&"0"!==e.distanceInKm,i=[];return"miles"!==a&&"both"!==a||!s||i.push(`${e.distanceInMiles} miles`),"km"!==a&&"both"!==a||!l||i.push(`${e.distanceInKm} km`),this.options.distanceLabel&&i.length>0?this.options.distanceLabel.replace("{0}",i.join(" / ")):i.join(" / ")}}t(C,"SELF",g),t(C,"NS","hme"),t(C,"IS",u);export{C as default};
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.