"use strict";(self.webpackChunkcliq_store_locator_dist_source=self.webpackChunkcliq_store_locator_dist_source||[]).push([[979],{55:function(e,t,n){n.d(t,["showLeafletDirections",0,(e,t,n,o={})=>{if(!(e.map&&t&&n&&e.L))return Promise.resolve(!1);const r=`https://router.project-osrm.org/route/v1/driving/${t.lng},${t.lat};${n.lng},${n.lat}?overview=full&geometries=geojson&steps=true`,a=e=>e>=1e3?`${(e/1e3).toFixed(1)} km`:`${Math.round(e)} m`;return fetch(r).then(e=>e.json()).then(t=>{const n=t?.routes?.[0],r=n?.geometry;if(!r||!Array.isArray(r.coordinates))return!1;const i=r.coordinates.map(([e,t])=>[t,e]);if(e.clearDirections(),e.routeLine=e.L.polyline(i,{color:"#3858e9",weight:5,opacity:.85}).addTo(e.map),e.map.fitBounds(e.routeLine.getBounds(),{padding:[30,30]}),o.panel){const t=t=>e.classFor(`dir__${t}`),r=(e,t,n)=>{const o=document.createElement(e);return t&&(o.className=t),void 0!==n&&(o.textContent=n),o},i=Math.round((n.duration||0)/60),s=r("ol",t("steps"));(n.legs?.[0]?.steps||[]).forEach((e,n)=>{const o=(e.maneuver?.modifier||e.maneuver?.type||"continue").replace(/_/g," "),i=e.name?` onto ${e.name}`:"",d=document.createElement("li");d.appendChild(r("span",t("n"),String(n+1))),d.appendChild(r("span",t("t"),`${o}${i}`)),d.appendChild(r("span",t("d"),a(e.distance||0))),s.appendChild(d)}),o.panel.textContent="",o.panel.appendChild(r("div",t("sum"),`${a(n.distance||0)} · ${i} min`)),o.panel.appendChild(s)}return{distance:a(n.distance||0),duration:`${Math.round((n.duration||0)/60)} min`,origin:""}}).catch(()=>!1)}])}}]);