{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "route-planner",
  "title": "Route planner",
  "description": "Choose a destination and compare the local and express routes on a line diagram.",
  "registryDependencies": [
    "https://www.cyberspec.dev/r/recipe-layout.json",
    "https://www.cyberspec.dev/r/badge.json",
    "https://www.cyberspec.dev/r/segmented-control.json",
    "https://www.cyberspec.dev/r/switch.json"
  ],
  "files": [
    {
      "path": "registry/cyber/recipes/route-planner.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport { Badge } from \"@/registry/cyber/ui/badge\"\nimport { SegmentedControl } from \"@/registry/cyber/ui/segmented-control\"\nimport { Switch } from \"@/registry/cyber/ui/switch\"\nimport \"./recipe-layout.css\"\n\nconst routes = [\n  { station: \"Museum\", local: 13, express: 8 },\n  { station: \"Harbor\", local: 22, express: 14 },\n  { station: \"Gardens\", local: 31, express: 19 },\n]\nconst localStops = [\"Central\", \"Old Mill\", \"Museum\", \"Market\", \"Harbor\", \"Birch\", \"Gardens\"]\nconst xAt = (index: number) => 12 + index * 44\nconst localColor = \"var(--cy-signal)\"\nconst expressColor = \"var(--cy-flag)\"\n\nexport default function RoutePlanner() {\n  const [destination, setDestination] = useState(\"Harbor\")\n  const [express, setExpress] = useState(false)\n  const route = routes.find(route => route.station === destination) ?? routes[0]\n  const index = localStops.indexOf(destination)\n  const stops = localStops.slice(0, index + 1).filter((_, i) => !express || i % 2 === 0)\n  const color = express ? expressColor : localColor\n  return (\n    <div className=\"sink-stack\">\n      <SegmentedControl label=\"From Central to\" options={routes.map(route => route.station)} value={destination} fill\n        onValueChange={next => next && setDestination(next)} />\n      <div style={{ border: \"1px solid var(--cy-line-deco)\", background: \"var(--cy-void)\", padding: \"10px 12px\" }}>\n        <svg viewBox=\"0 0 288 72\" aria-hidden=\"true\" style={{ display: \"block\", width: \"100%\", height: 76 }}>\n          <g fill=\"none\" stroke=\"var(--cy-line-ctl)\" opacity=\"0.6\" strokeWidth=\"2\">\n            <path d=\"M12 48H276\" />\n            <path d=\"m12 48 22-28h220l22 28M78 20l22 28m66-28 22 28\" />\n          </g>\n          <path d={express ? `M12 48l22-28H${xAt(index) - 22}l22 28` : `M12 48H${xAt(index)}`}\n            fill=\"none\" stroke={color} strokeWidth=\"5\" strokeLinejoin=\"round\" />\n          {localStops.map((station, i) => (\n            <rect key={station} x={xAt(i) - 3.5} y={express && i > 0 && i < index && i % 2 === 0 ? 16.5 : 44.5} width=\"7\" height=\"7\"\n              fill={station === destination || !i ? color : \"var(--cy-void)\"} stroke={stops.includes(station) ? color : \"var(--cy-line-ctl)\"} strokeWidth=\"2\" />\n          ))}\n        </svg>\n        <div className=\"sink-between\"><strong>Central to {destination}</strong><Badge tone={express ? \"flag\" : \"signal\"}>{express ? route.express : route.local} min</Badge></div>\n      </div>\n      <Switch label=\"Use express line\" checked={express} onCheckedChange={setExpress} />\n      <p className=\"sink-note\" role=\"status\">{stops.length - 1} {stops.length === 2 ? \"stop\" : \"stops\"} · {stops.join(\" → \")}</p>\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/recipes/route-planner.tsx"
    }
  ],
  "categories": [
    "recipe",
    "transit"
  ],
  "type": "registry:component"
}
