{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"store-locator-collection-with-svg-map-postcode-search-distance-sort-open-now-and-localbusiness-schema","type":"registry:block","title":"Store Locator with Map, Postcode Search, Open Now and Schema","description":"Free store locator code: postcode search, distance sort with the haversine formula, open now from opening hours, directions links and LocalBusiness JSON-LD.","dependencies":[],"files":[{"path":"components/we-inc/store-locator-collection-with-svg-map-postcode-search-distance-sort-open-now-and-localbusiness-schema.tsx","type":"registry:component","content":"import { useMemo, useRef, useState } from \"react\";\nimport type { FormEvent, KeyboardEvent } from \"react\";\n\n/*\n  Store locator with no map library and no plugin.\n  The map is an inline SVG of a made-up town; stores are placed on it by projecting their latitude and\n  longitude into the SVG's box. Everything else (postcode search, haversine distance sort, \"open now\"\n  from opening hours, directions links, JSON-LD) is plain code you can reuse with a real map.\n  Directions links are href=\"#\" in this demo. On a real site build them from the store's coordinates:\n    Google Maps: www.google.com/maps/dir/?api=1&destination=LAT,LNG   (prefix with the https scheme)\n    Apple Maps:  maps.apple.com/?daddr=LAT,LNG\n  All names, postcodes and coordinates below are invented.\n*/\n\ntype Day = \"su\" | \"mo\" | \"tu\" | \"we\" | \"th\" | \"fr\" | \"sa\";\ntype Store = {\n  id: string;\n  name: string;\n  street: string;\n  town: string;\n  postcode: string;\n  phone: string;\n  lat: number;\n  lng: number;\n  hours: Record<Day, string>;\n};\n\n/* ---------- data: edit this list ---------- */\nconst WEEKDAY = \"08:00-18:00\";\nconst STORES: Store[] = [\n  { id: \"quay\", name: \"Fieldstone Hardware, Kestrel Quay\", street: \"4 Ropewalk Lane\", town: \"Kestrel Quay\", postcode: \"KQ1 4RL\", phone: \"01632 960 114\", lat: 52.0412, lng: -1.0388, hours: { mo: WEEKDAY, tu: WEEKDAY, we: WEEKDAY, th: WEEKDAY, fr: \"08:00-20:00\", sa: \"09:00-17:00\", su: \"10:00-16:00\" } },\n  { id: \"market\", name: \"Fieldstone Hardware, Market Square\", street: \"21 Corn Exchange Row\", town: \"Ashby Centre\", postcode: \"AC2 1CX\", phone: \"01632 960 227\", lat: 52.0335, lng: -1.0021, hours: { mo: \"07:30-19:00\", tu: \"07:30-19:00\", we: \"07:30-19:00\", th: \"07:30-19:00\", fr: \"07:30-19:00\", sa: \"08:00-18:00\", su: \"closed\" } },\n  { id: \"millbrook\", name: \"Fieldstone Hardware, Millbrook\", street: \"88 Weir Road\", town: \"Millbrook\", postcode: \"MB4 8WR\", phone: \"01632 960 381\", lat: 52.0558, lng: -0.9702, hours: { mo: WEEKDAY, tu: WEEKDAY, we: WEEKDAY, th: WEEKDAY, fr: WEEKDAY, sa: \"09:00-16:00\", su: \"closed\" } },\n  { id: \"rise\", name: \"Fieldstone Trade Counter, Ashby Rise\", street: \"Unit 6, Larkspur Park\", town: \"Ashby Rise\", postcode: \"AR3 6LP\", phone: \"01632 960 402\", lat: 52.0178, lng: -0.9563, hours: { mo: \"06:30-17:00\", tu: \"06:30-17:00\", we: \"06:30-17:00\", th: \"06:30-17:00\", fr: \"06:30-16:00\", sa: \"07:00-12:00\", su: \"closed\" } },\n  { id: \"green\", name: \"Fieldstone Hardware, Harrow Green\", street: \"3 Chapel Parade\", town: \"Harrow Green\", postcode: \"HG5 3CP\", phone: \"01632 960 519\", lat: 52.0121, lng: -1.0296, hours: { mo: \"09:00-17:30\", tu: \"09:00-17:30\", we: \"closed\", th: \"09:00-17:30\", fr: \"09:00-17:30\", sa: \"09:00-17:00\", su: \"closed\" } },\n  { id: \"docks\", name: \"Fieldstone Garden Centre, Old Docks\", street: \"Basin Wharf\", town: \"Old Docks\", postcode: \"OD7 2BW\", phone: \"01632 960 640\", lat: 52.0467, lng: -1.0119, hours: { mo: \"09:00-18:00\", tu: \"09:00-18:00\", we: \"09:00-18:00\", th: \"09:00-21:00\", fr: \"09:00-18:00\", sa: \"08:30-18:00\", su: \"10:00-17:00\" } },\n];\n\n/* Places a visitor can search for. A real site would call a geocoder here. */\nconst PLACES: { label: string; keys: string[]; lat: number; lng: number }[] = [\n  { label: \"Ashby Centre\", keys: [\"ashby centre\", \"ac2\", \"town hall\"], lat: 52.0312, lng: -1.0055 },\n  { label: \"Kestrel Quay\", keys: [\"kestrel quay\", \"kq1\"], lat: 52.0431, lng: -1.0432 },\n  { label: \"Millbrook\", keys: [\"millbrook\", \"mb4\"], lat: 52.0581, lng: -0.9741 },\n  { label: \"Ashby Rise\", keys: [\"ashby rise\", \"ar3\"], lat: 52.0159, lng: -0.9601 },\n  { label: \"Harrow Green\", keys: [\"harrow green\", \"hg5\"], lat: 52.0102, lng: -1.0331 },\n  { label: \"Old Docks\", keys: [\"old docks\", \"od7\"], lat: 52.0489, lng: -1.0151 },\n  { label: \"Fenwick Hill\", keys: [\"fenwick hill\", \"fh6\"], lat: 52.0247, lng: -0.9858 },\n];\n\n/* ---------- logic (the same functions appear in the copyable code) ---------- */\nconst DAYS: Day[] = [\"su\", \"mo\", \"tu\", \"we\", \"th\", \"fr\", \"sa\"];\nconst DAY_NAMES = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n\nfunction distanceKm(aLat: number, aLng: number, bLat: number, bLng: number): number {\n  const R = 6371;\n  const rad = (d: number) => (d * Math.PI) / 180;\n  const dLat = rad(bLat - aLat);\n  const dLng = rad(bLng - aLng);\n  const h = Math.sin(dLat / 2) ** 2 + Math.cos(rad(aLat)) * Math.cos(rad(bLat)) * Math.sin(dLng / 2) ** 2;\n  return 2 * R * Math.asin(Math.sqrt(h));\n}\n\nconst toMin = (hhmm: string) => Number(hhmm.slice(0, 2)) * 60 + Number(hhmm.slice(3, 5));\n\nfunction openState(store: Store, at: Date): { open: boolean; text: string } {\n  const day = at.getDay();\n  const now = at.getHours() * 60 + at.getMinutes();\n  const today = store.hours[DAYS[day]];\n  if (today !== \"closed\") {\n    const [o, c] = today.split(\"-\");\n    if (now >= toMin(o) && now < toMin(c)) return { open: true, text: `Open now, closes ${c}` };\n    if (now < toMin(o)) return { open: false, text: `Closed, opens ${o} today` };\n  }\n  for (let i = 1; i <= 7; i++) {\n    const next = store.hours[DAYS[(day + i) % 7]];\n    if (next !== \"closed\") return { open: false, text: `Closed, opens ${next.split(\"-\")[0]} ${i === 1 ? \"tomorrow\" : DAY_NAMES[(day + i) % 7]}` };\n  }\n  return { open: false, text: \"Closed\" };\n}\n\nconst SCHEME = \"https:\" + \"//\";\nconst SCHEMA_DAYS: Record<Day, string> = { mo: \"Monday\", tu: \"Tuesday\", we: \"Wednesday\", th: \"Thursday\", fr: \"Friday\", sa: \"Saturday\", su: \"Sunday\" };\n\nfunction jsonLd(s: Store): string {\n  const spec = (Object.keys(SCHEMA_DAYS) as Day[])\n    .filter((d) => s.hours[d] !== \"closed\")\n    .map((d) => ({ \"@type\": \"OpeningHoursSpecification\", dayOfWeek: SCHEMA_DAYS[d], opens: s.hours[d].split(\"-\")[0], closes: s.hours[d].split(\"-\")[1] }));\n  const data = {\n    \"@context\": `${SCHEME}schema.org`,\n    \"@type\": \"HardwareStore\",\n    \"@id\": `${SCHEME}example.com/stores/${s.id}#store`,\n    name: s.name,\n    telephone: s.phone,\n    address: { \"@type\": \"PostalAddress\", streetAddress: s.street, addressLocality: s.town, postalCode: s.postcode, addressCountry: \"GB\" },\n    geo: { \"@type\": \"GeoCoordinates\", latitude: s.lat, longitude: s.lng },\n    openingHoursSpecification: spec,\n  };\n  return `<script type=\"application/ld+json\">\\n${JSON.stringify(data, null, 2)}\\n</script>\\n`;\n}\n\nconst VANILLA = `// store-locator.js: no libraries. stores is the JSON array shown in the Data tab.\nfunction distanceKm(aLat, aLng, bLat, bLng) {\n  const R = 6371; // mean Earth radius in km (use 3959 for miles)\n  const rad = (d) => (d * Math.PI) / 180;\n  const dLat = rad(bLat - aLat);\n  const dLng = rad(bLng - aLng);\n  const h = Math.sin(dLat / 2) ** 2 +\n    Math.cos(rad(aLat)) * Math.cos(rad(bLat)) * Math.sin(dLng / 2) ** 2;\n  return 2 * R * Math.asin(Math.sqrt(h)); // haversine formula\n}\n\nconst DAYS = [\"su\", \"mo\", \"tu\", \"we\", \"th\", \"fr\", \"sa\"];\nconst toMin = (t) => Number(t.slice(0, 2)) * 60 + Number(t.slice(3, 5));\n\nfunction isOpen(store, at = new Date()) {\n  // Uses the visitor's clock. If stores span time zones, convert \"at\" first.\n  const spec = store.hours[DAYS[at.getDay()]];\n  if (spec === \"closed\") return false;\n  const [open, close] = spec.split(\"-\");\n  const now = at.getHours() * 60 + at.getMinutes();\n  return now >= toMin(open) && now < toMin(close);\n}\n\nfunction directionsUrl(store) {\n  // Opens turn-by-turn directions from wherever the visitor is.\n  return \"${SCHEME}www.google.com/maps/dir/?api=1&destination=\" + store.lat + \",\" + store.lng;\n  // Apple Maps: \"${SCHEME}maps.apple.com/?daddr=\" + store.lat + \",\" + store.lng\n}\n\nfunction nearest(stores, origin, openOnly = false) {\n  return stores\n    .map((s) => ({ ...s, km: distanceKm(origin.lat, origin.lng, s.lat, s.lng) }))\n    .filter((s) => !openOnly || isOpen(s))\n    .sort((a, b) => a.km - b.km);\n}\n\nfunction render(list, el) {\n  el.replaceChildren(...list.map((s) => {\n    const li = document.createElement(\"li\");\n    const a = document.createElement(\"a\");\n    a.href = directionsUrl(s);\n    a.textContent = \"Directions\";\n    li.append(s.name + \", \" + s.km.toFixed(1) + \" km, \" + (isOpen(s) ? \"open now\" : \"closed\") + \" \");\n    li.append(a);\n    return li;\n  }));\n}\n`;\n\nconst REACT = `import { useMemo, useState } from \"react\";\n// distanceKm, isOpen and directionsUrl: paste them from the vanilla tab.\n\nexport function useStoreLocator(stores, start) {\n  const [origin, setOrigin] = useState(start); // { lat, lng, label }\n  const [openOnly, setOpenOnly] = useState(false);\n  const [selected, setSelected] = useState(null);\n\n  const results = useMemo(() => stores\n    .map((s) => ({ ...s, km: distanceKm(origin.lat, origin.lng, s.lat, s.lng), open: isOpen(s) }))\n    .filter((s) => !openOnly || s.open)\n    .sort((a, b) => a.km - b.km), [stores, origin, openOnly]);\n\n  return { results, origin, setOrigin, openOnly, setOpenOnly, selected, setSelected };\n}\n\n// Map pins and list rows both call setSelected(store.id); both read selected\n// to highlight, which keeps the list and the map in step.\n`;\n\n/* ---------- SVG map projection ---------- */\nconst W = 640;\nconst H = 440;\nconst BOUNDS = { minLat: 52.004, maxLat: 52.064, minLng: -1.052, maxLng: -0.948 };\nconst px = (lat: number, lng: number) => ({\n  x: ((lng - BOUNDS.minLng) / (BOUNDS.maxLng - BOUNDS.minLng)) * W,\n  y: ((BOUNDS.maxLat - lat) / (BOUNDS.maxLat - BOUNDS.minLat)) * H,\n});\n\ntype Tab = \"data\" | \"jsonld\" | \"vanilla\" | \"react\";\nconst TABS: { k: Tab; label: string }[] = [\n  { k: \"data\", label: \"stores.json\" },\n  { k: \"jsonld\", label: \"LocalBusiness JSON-LD\" },\n  { k: \"vanilla\", label: \"Vanilla JS\" },\n  { k: \"react\", label: \"React hook\" },\n];\n\nexport default function StoreLocatorCollection() {\n  const [query, setQuery] = useState(\"\");\n  const [origin, setOrigin] = useState(PLACES[0]);\n  const [message, setMessage] = useState(`Showing stores nearest ${PLACES[0].label}.`);\n  const [openOnly, setOpenOnly] = useState(false);\n  const [selected, setSelected] = useState<string>(\"market\");\n  const [tab, setTab] = useState<Tab>(\"jsonld\");\n  const [copied, setCopied] = useState(false);\n  const [showAll, setShowAll] = useState(false);\n  const listRef = useRef<HTMLUListElement | null>(null);\n  const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n  const now = useMemo(() => new Date(), []);\n\n  const results = useMemo(\n    () =>\n      STORES.map((s) => ({ s, km: distanceKm(origin.lat, origin.lng, s.lat, s.lng), st: openState(s, now) }))\n        .filter((r) => !openOnly || r.st.open)\n        .sort((a, b) => a.km - b.km),\n    [origin, openOnly, now],\n  );\n  const sel = STORES.find((s) => s.id === selected) ?? STORES[0];\n\n  function search(e: FormEvent) {\n    e.preventDefault();\n    const q = query.trim().toLowerCase().replace(/\\s+/g, \" \");\n    if (!q) return;\n    const hit = PLACES.find((p) => p.keys.some((k) => k.startsWith(q) || q.startsWith(k)));\n    if (!hit) {\n      setMessage(`No match for \"${query}\". Try a town such as Millbrook or a postcode start such as KQ1.`);\n      return;\n    }\n    setOrigin(hit);\n    const first = STORES.map((s) => ({ s, km: distanceKm(hit.lat, hit.lng, s.lat, s.lng) })).sort((a, b) => a.km - b.km)[0];\n    setSelected(first.s.id);\n    setMessage(`Showing stores nearest ${hit.label}. Closest is ${first.s.name.split(\", \")[1]}, ${first.km.toFixed(1)} km away.`);\n  }\n\n  function pick(id: string, fromMap: boolean) {\n    setSelected(id);\n    if (fromMap && listRef.current) {\n      const row = listRef.current.querySelector<HTMLElement>(`[data-id=\"${id}\"]`);\n      if (row) listRef.current.scrollTo({ top: row.offsetTop - listRef.current.offsetTop - 8, behavior: \"smooth\" });\n    }\n  }\n\n  function pinKey(e: KeyboardEvent<SVGGElement>, id: string) {\n    if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      pick(id, true);\n    }\n  }\n\n  function tabKey(e: KeyboardEvent<HTMLButtonElement>, i: number) {\n    const n = e.key === \"ArrowRight\" ? (i + 1) % TABS.length : e.key === \"ArrowLeft\" ? (i + TABS.length - 1) % TABS.length : -1;\n    if (n < 0) return;\n    e.preventDefault();\n    setTab(TABS[n].k);\n    tabRefs.current[n]?.focus();\n  }\n\n  const code =\n    tab === \"data\" ? JSON.stringify(STORES, null, 2) + \"\\n\" : tab === \"jsonld\" ? jsonLd(sel) : tab === \"vanilla\" ? VANILLA : REACT;\n\n  async function copy() {\n    try {\n      await navigator.clipboard.writeText(code);\n      setCopied(true);\n      setTimeout(() => setCopied(false), 1600);\n    } catch {\n      setShowAll(true);\n      setMessage(\"Copy was blocked, the full code is shown so you can select it.\");\n    }\n  }\n\n  const o = px(origin.lat, origin.lng);\n  const ring = \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-700 focus-visible:ring-offset-2\";\n\n  return (\n    <section className=\"bg-[#f6f5f1] px-4 py-12 text-stone-900 sm:px-8 sm:py-14\" style={{ fontFamily: 'Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif' }}>\n      <style>{`@media (prefers-reduced-motion: reduce) { .sl-pin { transition: none !important; } }`}</style>\n      <div className=\"mx-auto max-w-6xl\">\n        <header className=\"flex flex-col gap-4 md:flex-row md:items-end md:justify-between\">\n          <div className=\"max-w-2xl\">\n            <p className=\"font-mono text-[12px] uppercase tracking-[0.18em] text-stone-600\">Store locator · no plugin · no map library</p>\n            <h2 className=\"mt-3 text-[30px] font-semibold leading-[1.08] tracking-[-0.03em] sm:text-[40px]\">Find a Fieldstone store</h2>\n            <p className=\"mt-3 text-[15px] leading-relaxed text-stone-600\">Search a town or postcode. Results sort by straight-line distance and show which stores are open right now.</p>\n          </div>\n        </header>\n\n        <form onSubmit={search} className=\"mt-6 flex flex-col gap-3 rounded-2xl bg-white p-3 ring-1 ring-stone-200 sm:flex-row sm:items-center\">\n          <label htmlFor=\"sl-q\" className=\"sr-only\">Town or postcode</label>\n          <div className=\"relative flex-1\">\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" aria-hidden=\"true\" className=\"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-stone-500\">\n              <path d=\"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4\" />\n            </svg>\n            <input id=\"sl-q\" type=\"search\" value={query} onChange={(e) => setQuery(e.target.value)} placeholder=\"Town or postcode, e.g. Millbrook or KQ1\" autoComplete=\"postal-code\" className=\"h-11 w-full rounded-xl border border-stone-300 pl-9 pr-3 text-[15px] placeholder:text-stone-500 focus:border-emerald-700 focus:outline-none focus:ring-4 focus:ring-emerald-700/15\" />\n          </div>\n          <div className=\"flex items-center gap-3\">\n            <label htmlFor=\"sl-open\" className=\"inline-flex min-h-[44px] cursor-pointer items-center gap-2 text-[14px] text-stone-700\">\n              <input id=\"sl-open\" type=\"checkbox\" checked={openOnly} onChange={(e) => setOpenOnly(e.target.checked)} className=\"h-[18px] w-[18px] accent-emerald-700\" />\n              Open now only\n            </label>\n            <button type=\"submit\" className={`h-11 rounded-xl bg-emerald-800 px-5 text-[14px] font-semibold text-white hover:bg-emerald-900 ${ring}`}>Search</button>\n          </div>\n        </form>\n        <p className=\"mt-2 text-[13px] text-stone-600\" role=\"status\" aria-live=\"polite\">{message}</p>\n\n        <div className=\"mt-4 grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.3fr)]\">\n          <ul ref={listRef} className=\"relative order-2 max-h-[460px] space-y-2 overflow-y-auto pr-1 lg:order-1\" aria-label=\"Stores, nearest first\">\n            {results.length === 0 && <li className=\"rounded-xl border border-dashed border-stone-300 p-6 text-[14px] text-stone-600\">No store is open at this hour. Clear \"Open now only\" to see them all.</li>}\n            {results.map(({ s, km, st }, i) => {\n              const on = s.id === selected;\n              return (\n                <li key={s.id} data-id={s.id} className={`rounded-xl bg-white p-4 ring-1 transition-shadow ${on ? \"ring-2 ring-emerald-700 shadow-[0_6px_18px_-10px_rgba(6,78,59,0.5)]\" : \"ring-stone-200\"}`}>\n                  <button type=\"button\" aria-pressed={on} onClick={() => pick(s.id, false)} className={`flex w-full items-start gap-3 rounded-lg text-left ${ring}`}>\n                    <span className={`mt-0.5 grid h-7 w-7 shrink-0 place-items-center rounded-full text-[12px] font-bold ${on ? \"bg-emerald-800 text-white\" : \"bg-stone-100 text-stone-700\"}`}>{i + 1}</span>\n                    <span className=\"min-w-0 flex-1\">\n                      <span className=\"block text-[15px] font-semibold leading-snug\">{s.name.split(\", \")[1]}</span>\n                      <span className=\"block text-[13px] text-stone-600\">{s.street}, {s.postcode}</span>\n                      <span className={`mt-1 inline-flex items-center gap-1.5 text-[13px] font-medium ${st.open ? \"text-emerald-800\" : \"text-stone-600\"}`}>\n                        <span className={`h-2 w-2 rounded-full ${st.open ? \"bg-emerald-600\" : \"bg-stone-400\"}`} aria-hidden=\"true\" />\n                        {st.text}\n                      </span>\n                    </span>\n                    <span className=\"shrink-0 font-mono text-[13px] tabular-nums text-stone-700\">{km.toFixed(1)} km</span>\n                  </button>\n                  {on && (\n                    <div className=\"mt-3 flex flex-wrap gap-2 border-t border-stone-100 pt-3\">\n                      {/* Demo link. Real one: Google Maps dir/?api=1&destination=LAT,LNG or Apple Maps ?daddr=LAT,LNG */}\n                      <a href=\"#\" className={`inline-flex min-h-[40px] items-center rounded-lg bg-emerald-800 px-3.5 text-[13px] font-semibold text-white hover:bg-emerald-900 ${ring}`}>Directions</a>\n                      <a href=\"#\" className={`inline-flex min-h-[40px] items-center rounded-lg px-3.5 text-[13px] font-semibold text-stone-800 ring-1 ring-inset ring-stone-300 hover:bg-stone-50 ${ring}`}>Call {s.phone}</a>\n                    </div>\n                  )}\n                </li>\n              );\n            })}\n          </ul>\n\n          <figure className=\"order-1 overflow-hidden rounded-2xl bg-[#e9ebe4] ring-1 ring-stone-200 lg:order-2\">\n            <svg viewBox={`0 0 ${W} ${H}`} className=\"block h-auto w-full\" role=\"group\" aria-label=\"Map of stores. Use the pins or the list to choose a store.\">\n              <rect width={W} height={H} fill=\"#eceee7\" />\n              {/* parks */}\n              <path d=\"M410 250 L520 232 L548 300 L470 338 L404 312 Z\" fill=\"#d5e3cc\" />\n              <path d=\"M70 330 C110 300 170 312 190 350 C170 392 98 400 70 370 Z\" fill=\"#d5e3cc\" />\n              <path d=\"M300 40 L370 34 L380 92 L310 98 Z\" fill=\"#d5e3cc\" />\n              {/* river and docks */}\n              <path d=\"M-10 128 C80 120 140 168 230 150 S360 92 430 120 S560 190 650 170\" fill=\"none\" stroke=\"#b9d3df\" strokeWidth={26} strokeLinecap=\"round\" />\n              <rect x={232} y={118} width={40} height={22} rx={3} fill=\"#b9d3df\" />\n              {/* minor streets */}\n              <g stroke=\"#fbfbf8\" strokeWidth={5} fill=\"none\">\n                {[60, 120, 180, 240, 300, 360, 420, 480, 540, 600].map((x) => <path key={`v${x}`} d={`M${x} 170 V${H}`} opacity={0.9} />)}\n                {[200, 250, 300, 350, 400].map((y) => <path key={`h${y}`} d={`M0 ${y} H${W}`} />)}\n                {[20, 60, 100].map((y) => <path key={`n${y}`} d={`M0 ${y} H${W}`} />)}\n              </g>\n              {/* main roads */}\n              <g stroke=\"#ffffff\" strokeWidth={11} fill=\"none\" strokeLinecap=\"round\">\n                <path d=\"M0 236 C160 228 280 250 400 226 S560 200 650 214\" />\n                <path d=\"M330 -10 C320 120 350 260 318 450\" />\n                <path d=\"M120 450 C180 330 260 250 330 230\" />\n              </g>\n              <g stroke=\"#f2c97a\" strokeWidth={5} fill=\"none\" strokeLinecap=\"round\">\n                <path d=\"M0 236 C160 228 280 250 400 226 S560 200 650 214\" />\n              </g>\n              {/* labels */}\n              <g fill=\"#6b6f66\" fontSize={11} fontWeight={600} letterSpacing=\"0.08em\">\n                <text x={30} y={86}>KESTREL QUAY</text>\n                <text x={470} y={74}>MILLBROOK</text>\n                <text x={250} y={300}>ASHBY CENTRE</text>\n                <text x={470} y={372}>ASHBY RISE</text>\n                <text x={92} y={420}>HARROW GREEN</text>\n                <text x={282} y={98}>OLD DOCKS</text>\n              </g>\n              <text x={500} y={150} fill=\"#6f8f9c\" fontSize={11} fontStyle=\"italic\">River Lune</text>\n              {/* search origin */}\n              <g aria-hidden=\"true\">\n                <circle cx={o.x} cy={o.y} r={16} fill=\"#2563eb\" opacity={0.15} />\n                <circle cx={o.x} cy={o.y} r={6} fill=\"#2563eb\" stroke=\"#fff\" strokeWidth={2.5} />\n              </g>\n              {/* pins */}\n              {results.map(({ s }, i) => {\n                const p = px(s.lat, s.lng);\n                const on = s.id === selected;\n                return (\n                  <g\n                    key={s.id}\n                    role=\"button\"\n                    tabIndex={0}\n                    aria-label={`${s.name}, result ${i + 1}`}\n                    aria-pressed={on}\n                    onClick={() => pick(s.id, true)}\n                    onKeyDown={(e) => pinKey(e, s.id)}\n                    className=\"sl-pin cursor-pointer outline-none [&:focus-visible>circle.sl-focus]:opacity-100\"\n                    style={{ transform: `translate(${p.x}px, ${p.y}px)` }}\n                  >\n                    <circle className=\"sl-focus\" r={24} fill=\"none\" stroke=\"#047857\" strokeWidth={2.5} opacity={0} />\n                    <ellipse cx={0} cy={2} rx={7} ry={2.5} fill=\"#000\" opacity={0.18} />\n                    <path d=\"M0 0 C-3 -8 -13 -14 -13 -24 A13 13 0 1 1 13 -24 C13 -14 3 -8 0 0 Z\" fill={on ? \"#065f46\" : \"#ffffff\"} stroke={on ? \"#022c22\" : \"#57534e\"} strokeWidth={1.5} />\n                    <text y={-20} textAnchor=\"middle\" fontSize={12} fontWeight={700} fill={on ? \"#ffffff\" : \"#1c1917\"}>{i + 1}</text>\n                  </g>\n                );\n              })}\n            </svg>\n            <figcaption className=\"flex flex-wrap items-center justify-between gap-2 border-t border-stone-200 bg-white px-4 py-2.5 text-[12.5px] text-stone-600\">\n              <span className=\"inline-flex items-center gap-2\"><span className=\"h-2.5 w-2.5 rounded-full bg-blue-600\" aria-hidden=\"true\" />Searched from {origin.label}</span>\n              <span>Illustrated map of an invented town, drawn in SVG</span>\n            </figcaption>\n          </figure>\n        </div>\n\n        <div className=\"mt-6 rounded-2xl bg-white ring-1 ring-stone-200\">\n          <div className=\"flex flex-wrap items-center justify-between gap-2 border-b border-stone-200 px-3 pt-3\">\n            <div role=\"tablist\" aria-label=\"Code\" className=\"flex gap-1 overflow-x-auto\">\n              {TABS.map((t, i) => (\n                <button\n                  key={t.k}\n                  ref={(el) => { tabRefs.current[i] = el; }}\n                  type=\"button\"\n                  role=\"tab\"\n                  id={`sl-tab-${t.k}`}\n                  aria-selected={tab === t.k}\n                  aria-controls=\"sl-code\"\n                  tabIndex={tab === t.k ? 0 : -1}\n                  onClick={() => setTab(t.k)}\n                  onKeyDown={(e) => tabKey(e, i)}\n                  className={`min-h-[40px] shrink-0 border-b-2 px-3 text-[13px] font-medium ${ring} ${tab === t.k ? \"border-emerald-700 text-stone-900\" : \"border-transparent text-stone-600 hover:text-stone-900\"}`}\n                >\n                  {t.label}\n                </button>\n              ))}\n            </div>\n            <div className=\"mb-2 flex gap-2\">\n              <button type=\"button\" aria-expanded={showAll} aria-controls=\"sl-code\" onClick={() => setShowAll(!showAll)} className={`min-h-[40px] rounded-lg px-3 text-[13px] font-medium text-stone-700 ring-1 ring-inset ring-stone-300 hover:bg-stone-50 ${ring}`}>{showAll ? \"Shorter\" : \"Show all\"}</button>\n              <button type=\"button\" onClick={copy} className={`min-h-[40px] rounded-lg px-3 text-[13px] font-semibold text-white ${ring} ${copied ? \"bg-emerald-700\" : \"bg-stone-900 hover:bg-stone-700\"}`}>{copied ? \"Copied\" : \"Copy\"}</button>\n            </div>\n          </div>\n          <div role=\"tabpanel\" id=\"sl-code\" aria-labelledby={`sl-tab-${tab}`} className=\"p-3\">\n            {tab === \"jsonld\" && <p className=\"mb-2 px-1 text-[13px] text-stone-600\">Structured data for the selected store, {sel.name.split(\", \")[1]}. Put one block on each store's own page.</p>}\n            <pre tabIndex={0} className={`overflow-auto rounded-xl bg-[#14161a] p-4 font-mono text-[11.5px] leading-[1.6] text-stone-100 ${showAll ? \"max-h-[640px]\" : \"max-h-[260px]\"}`}>\n              <code>{code}</code>\n            </pre>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
