{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "step-plan-outline",
  "title": "Step Plan Outline",
  "description": "Review an AI agent's plan before it starts: reorder steps, skip the optional ones, watch the time and cost update, then approve and follow it through.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/step-plan-outline/step-plan-outline.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PlanStep {\n  id: string;\n  title: string;\n  /** What it will do, in one line. */\n  detail: string;\n  /** Expected time, in minutes. */\n  minutes: number;\n  /** Expected cost, in dollars. */\n  cost: number;\n  /** Can't be skipped. */\n  required?: boolean;\n}\n\nexport interface StepPlanOutlineProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  title?: string;\n  /** Who wrote the plan. */\n  author?: string;\n  steps?: PlanStep[];\n  /** Milliseconds per step once it's running. */\n  stepMs?: number;\n  onApprove?: (ids: string[]) => void;\n}\n\ntype Phase = \"edit\" | \"running\" | \"done\";\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst GREEN = \"#27A644\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst ROW = 56;\n\nconst PALETTES = {\n  dark: {\n    card: \"#08090A\",\n    node: \"#161718\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n  },\n  light: {\n    card: \"#FFFFFF\",\n    node: \"#F7F8F8\",\n    border: \"rgba(8,9,10,0.08)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n  },\n};\n\nconst DEFAULT_STEPS: PlanStep[] = [\n  {\n    id: \"read\",\n    title: \"Read the billing code\",\n    detail: \"Finds every call to the old invoice API.\",\n    minutes: 2,\n    cost: 0.04,\n    required: true,\n  },\n  {\n    id: \"schema\",\n    title: \"Add the new tables\",\n    detail: \"Keeps the old ones until the move is finished.\",\n    minutes: 3,\n    cost: 0.09,\n    required: true,\n  },\n  {\n    id: \"move\",\n    title: \"Move invoice creation\",\n    detail: \"Points new invoices at the new API.\",\n    minutes: 4,\n    cost: 0.16,\n    required: true,\n  },\n  {\n    id: \"backfill\",\n    title: \"Copy old records\",\n    detail: \"Moves two years of invoices across.\",\n    minutes: 3,\n    cost: 0.11,\n  },\n  {\n    id: \"docs\",\n    title: \"Update the docs\",\n    detail: \"Rewrites the billing page and the changelog.\",\n    minutes: 2,\n    cost: 0.05,\n  },\n];\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction Arrow({ up }: { up?: boolean }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      width=\"14\"\n      height=\"14\"\n      fill=\"none\"\n      className=\"block\"\n      style={{ transform: up ? \"rotate(180deg)\" : undefined }}\n    >\n      <path\n        d=\"m4 6 4 4 4-4\"\n        stroke=\"currentColor\"\n        strokeWidth=\"1.5\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nexport function StepPlanOutline({\n  theme = \"dark\",\n  title = \"Plan: move invoices to the new API\",\n  author = \"Written by Patch. Change anything before it starts.\",\n  steps = DEFAULT_STEPS,\n  stepMs = 800,\n  onApprove,\n  className,\n  style,\n  ...rest\n}: StepPlanOutlineProps) {\n  const c = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const [order, setOrder] = React.useState(() => steps.map((s) => s.id));\n  const [skipped, setSkipped] = React.useState<string[]>([]);\n  const [phase, setPhase] = React.useState<Phase>(\"edit\");\n  const [progress, setProgress] = React.useState(0);\n\n  const byId = new Map(steps.map((s) => [s.id, s]));\n  const live = order.filter((id) => !skipped.includes(id));\n  const chosen = live.flatMap((id) => {\n    const s = byId.get(id);\n    return s ? [s] : [];\n  });\n  const minutes = chosen.reduce((sum, s) => sum + s.minutes, 0);\n  const cost = chosen.reduce((sum, s) => sum + s.cost, 0);\n  const editing = phase === \"edit\";\n\n  React.useEffect(() => {\n    if (phase !== \"running\") return;\n    if (progress >= live.length) {\n      const id = window.setTimeout(() => setPhase(\"done\"), 0);\n      return () => window.clearTimeout(id);\n    }\n    const id = window.setTimeout(\n      () => setProgress(reduce ? live.length : progress + 1),\n      reduce ? 0 : stepMs,\n    );\n    return () => window.clearTimeout(id);\n  }, [live.length, phase, progress, reduce, stepMs]);\n\n  const move = (id: string, by: number) => {\n    const from = order.indexOf(id);\n    const to = from + by;\n    if (to < 0 || to >= order.length) return;\n    const next = [...order];\n    next.splice(from, 1);\n    next.splice(to, 0, id);\n    setOrder(next);\n  };\n\n  const toggleSkip = (id: string) =>\n    setSkipped((prev) =>\n      prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id],\n    );\n\n  const approve = () => {\n    setProgress(0);\n    setPhase(\"running\");\n    onApprove?.(live);\n  };\n\n  return (\n    <section\n      aria-label={title}\n      className={`@container w-full rounded-2xl border ${className ?? \"\"}`}\n      style={{\n        background: c.card,\n        borderColor: c.border,\n        color: c.text,\n        fontFamily: FONT,\n        ...style,\n      }}\n      {...rest}\n    >\n      <div className=\"p-5 pb-4 @xl:p-6 @xl:pb-4\">\n        <div className=\"flex items-start justify-between gap-4\">\n          <header className=\"min-w-0\">\n            <h3 className=\"m-0 text-[20px] leading-[26px] font-[590] tracking-[-0.012em]\">\n              {title}\n            </h3>\n            <p\n              aria-live=\"polite\"\n              className=\"m-0 mt-1 text-[13px] leading-[20px] tracking-[-0.011em]\"\n              style={{ color: c.sub }}\n            >\n              {phase === \"edit\"\n                ? author\n                : phase === \"running\"\n                  ? \"Running the plan\"\n                  : \"All steps finished\"}\n            </p>\n          </header>\n          <div className=\"shrink-0 text-right\">\n            <p className=\"m-0 text-[32px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums\">\n              {minutes} min\n            </p>\n            <p\n              className=\"m-0 mt-1.5 text-[13px] leading-[20px] tabular-nums\"\n              style={{ color: c.sub }}\n            >\n              About ${cost.toFixed(2)}\n            </p>\n          </div>\n        </div>\n      </div>\n\n      {/* Rows sit at fixed positions, so moving a step never changes the height. */}\n      <ol\n        className=\"relative m-0 list-none border-t p-0\"\n        style={{ borderColor: c.border, height: steps.length * ROW }}\n      >\n        {steps.map((step) => {\n          const at = order.indexOf(step.id);\n          const off = skipped.includes(step.id);\n          const place = live.indexOf(step.id);\n          const finished = !off && !editing && place < progress;\n          const current = !off && phase === \"running\" && place === progress;\n          return (\n            <li\n              key={step.id}\n              data-step={step.id}\n              className=\"flex items-center gap-3 border-b px-5 motion-safe:transition-transform motion-safe:duration-200 @xl:px-6\"\n              style={{\n                position: \"absolute\",\n                top: 0,\n                left: 0,\n                right: 0,\n                height: ROW,\n                borderColor: c.border,\n                transform: `translateY(${at * ROW}px)`,\n              }}\n            >\n              <svg\n                aria-hidden=\"true\"\n                width=\"26\"\n                height=\"26\"\n                viewBox=\"0 0 26 26\"\n                className=\"block shrink-0\"\n              >\n                <circle\n                  cx=\"13\"\n                  cy=\"13\"\n                  r=\"12\"\n                  fill={finished ? ACCENT : c.node}\n                  stroke={current ? ACCENT : finished ? ACCENT : c.border}\n                  strokeWidth={current ? 1.5 : 1}\n                  className=\"motion-safe:transition-[fill,stroke] motion-safe:duration-200\"\n                />\n                {finished ? (\n                  <path\n                    d=\"m8.5 13.5 3 3 6-7\"\n                    stroke=\"#FFFFFF\"\n                    strokeWidth=\"1.75\"\n                    fill=\"none\"\n                    strokeLinecap=\"round\"\n                    strokeLinejoin=\"round\"\n                  />\n                ) : (\n                  <text\n                    x=\"13\"\n                    y=\"17\"\n                    textAnchor=\"middle\"\n                    fontSize=\"12\"\n                    fontWeight=\"510\"\n                    fill={off ? c.faint : c.soft}\n                    style={{ fontVariantNumeric: \"tabular-nums\" }}\n                  >\n                    {off ? \"–\" : place + 1}\n                  </text>\n                )}\n              </svg>\n              <span className=\"min-w-0 flex-1\">\n                <span\n                  className=\"block truncate text-[13.5px] leading-[20px] font-[510] tracking-[-0.011em]\"\n                  style={{\n                    color: off ? c.faint : c.text,\n                    textDecoration: off ? \"line-through\" : \"none\",\n                  }}\n                >\n                  {step.title}\n                </span>\n                <span\n                  className=\"block truncate text-[12px] leading-[16px] tracking-[-0.005em]\"\n                  style={{ color: c.faint }}\n                >\n                  {step.detail}\n                </span>\n              </span>\n              <span\n                className=\"hidden shrink-0 text-[12.5px] leading-[18px] tracking-[-0.008em] tabular-nums @md:block\"\n                style={{ color: c.sub }}\n              >\n                {step.minutes} min\n              </span>\n              <span\n                className=\"flex shrink-0 items-center gap-1\"\n                style={{ visibility: editing ? \"visible\" : \"hidden\" }}\n              >\n                {[true, false].map((up) => (\n                  <button\n                    key={String(up)}\n                    type=\"button\"\n                    data-move={`${step.id}-${up ? \"up\" : \"down\"}`}\n                    aria-label={`Move ${step.title} ${up ? \"up\" : \"down\"}`}\n                    disabled={up ? at === 0 : at === steps.length - 1}\n                    onClick={() => move(step.id, up ? -1 : 1)}\n                    className={`flex cursor-pointer items-center justify-center rounded-full border-0 disabled:cursor-default ${RING}`}\n                    style={{\n                      width: 26,\n                      height: 26,\n                      background: c.chip,\n                      color: (up ? at === 0 : at === steps.length - 1)\n                        ? c.faint\n                        : c.soft,\n                    }}\n                  >\n                    <Arrow up={up} />\n                  </button>\n                ))}\n                <button\n                  type=\"button\"\n                  data-skip={step.id}\n                  aria-pressed={off}\n                  disabled={step.required}\n                  onClick={() => toggleSkip(step.id)}\n                  className={`h-[26px] cursor-pointer rounded-full border-0 text-[12px] leading-[16px] font-[510] tracking-[-0.005em] disabled:cursor-default ${RING}`}\n                  style={{\n                    width: 56,\n                    background: c.chip,\n                    color: step.required ? c.faint : c.soft,\n                  }}\n                >\n                  {step.required ? \"Needed\" : off ? \"Keep\" : \"Skip\"}\n                </button>\n              </span>\n            </li>\n          );\n        })}\n      </ol>\n\n      <footer className=\"flex items-center justify-between gap-3 px-5 py-3.5 @xl:px-6\">\n        <p\n          className=\"m-0 flex min-w-0 items-center gap-2 text-[13px] leading-[20px] tracking-[-0.011em] tabular-nums\"\n          style={{ color: c.sub }}\n        >\n          <svg\n            aria-hidden=\"true\"\n            width=\"8\"\n            height=\"8\"\n            viewBox=\"0 0 8 8\"\n            className=\"block shrink-0\"\n          >\n            <circle\n              cx=\"4\"\n              cy=\"4\"\n              r=\"4\"\n              fill={phase === \"done\" ? GREEN : ACCENT}\n            />\n          </svg>\n          <span className=\"truncate\">\n            {editing\n              ? `${live.length} of ${steps.length} steps`\n              : `${Math.min(progress, live.length)} of ${live.length} done`}\n          </span>\n        </p>\n        <button\n          type=\"button\"\n          data-primary=\"\"\n          disabled={phase === \"running\"}\n          onClick={editing ? approve : () => setPhase(\"edit\")}\n          className={`h-9 shrink-0 cursor-pointer rounded-full border-0 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] disabled:cursor-default ${RING}`}\n          style={{\n            width: 124,\n            background: phase === \"running\" ? c.chip : c.btn,\n            color: phase === \"running\" ? c.faint : c.btnText,\n          }}\n        >\n          {editing\n            ? \"Approve plan\"\n            : phase === \"running\"\n              ? \"Running\"\n              : \"Edit plan\"}\n        </button>\n      </footer>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}