{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"agent-switchboard-with-swaying-patch-cords-and-lamps-that-light-as-each-step-runs","type":"registry:component","title":"Agent Switchboard with Swaying Patch Cords and Lamps That Light as Each Step Runs","description":"Agent steps drawn on a canvas as an enamel switchboard: patch cords hang with rope physics and a lamp lights per step. React code and HTML, free to copy.","dependencies":[],"files":[{"path":"components/we-inc/agent-switchboard-with-swaying-patch-cords-and-lamps-that-light-as-each-step-runs.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\nimport type { PointerEvent as ReactPointerEvent } from \"react\";\n\n// The tools on the lower row of jacks, and what the agent does with each one.\nconst tools = [\n  { name: \"Inbox\", does: \"Reads the new order from Marigold Lane\" },\n  { name: \"Stock\", does: \"Counts the peonies left in the cooler\" },\n  { name: \"Diary\", does: \"Finds a free delivery slot on Friday\" },\n  { name: \"Reply\", does: \"Writes back with the time and the total\" },\n  { name: \"Invoice\", does: \"Sends the bill for the bouquet\" },\n];\nconst START = [0, 2, 1, 3]; // which tool each step is plugged into at the start\nconst LENGTHS = [540, 500, 452, 506]; // cord lengths in design pixels\nconst BLUE = \"#4F98FB\", INK = \"#12151c\";\nconst COLOURS = [BLUE, INK, BLUE, INK];\nconst W = 520, H = 600; // design size; everything scales with the panel\nconst AX = [116, 212, 308, 404], AY = 126; // step jacks\nconst BX = [68, 164, 260, 356, 452], BY = 280; // tool jacks\nconst STEP_TIME = 1.55; // seconds each step takes\nconst FONT = '\"Inter Tight\", \"Inter\", ui-sans-serif, system-ui, sans-serif';\n\ntype Cord = { p: number[][]; len: number; bx: number; by: number; vx: number; vy: number; tool: number; held: boolean };\ntype Api = { grab: (i: number) => void; drag: (i: number, x: number, y: number) => void; drop: (i: number) => void; hop: (i: number) => void };\n\nexport default function AgentSwitchboard() {\n  const canvas = useRef<HTMLCanvasElement>(null);\n  const api = useRef<Api | null>(null);\n  const press = useRef({ x: 0, y: 0, moved: false });\n  const [wires, setWires] = useState(START);\n  const [active, setActive] = useState(-1); // -1 waiting, 0 to 3 a step, 4 finished\n\n  useEffect(() => {\n    const cv = canvas.current;\n    if (!cv) return;\n    const ctx = cv.getContext(\"2d\");\n    if (!ctx) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const still = document.createElement(\"canvas\");\n    let k = 1; // canvas pixels per design pixel\n\n    const N = 34;\n    const cords: Cord[] = START.map((tool, i) => ({\n      p: Array.from({ length: N }, (_, j) => { const f = j / (N - 1); const x = AX[i] + (BX[tool] - AX[i]) * f, y = AY + (BY - AY) * f + Math.sin(f * Math.PI) * 190; return [x, y, x, y]; }),\n      len: LENGTHS[i % LENGTHS.length], bx: BX[tool], by: BY, vx: 0, vy: 0, tool, held: false,\n    }));\n    const lamps = tools.map(() => 0), lampTo = tools.map(() => 0), leds = START.map(() => 0);\n    const seq = { step: -1, t: 0.25, runs: 0, run: 0 };\n    let touched = -1e9, clock = 0;\n\n    // Rope: points remember where they were, gravity pulls, then the segments are pulled back to length.\n    const rope = (c: Cord, i: number, dt: number) => {\n      const seg = c.len / (N - 1);\n      for (let j = 1; j < N - 1; j++) {\n        const q = c.p[j], vx = (q[0] - q[2]) * 0.988, vy = (q[1] - q[3]) * 0.988;\n        q[2] = q[0]; q[3] = q[1];\n        q[0] += vx + Math.sin(clock * 0.9 + i * 1.9 + j * 0.3) * 46 * dt * dt;\n        q[1] += vy + 1700 * dt * dt;\n      }\n      for (let n = 0; n < 12; n++) {\n        c.p[0][0] = AX[i]; c.p[0][1] = AY; c.p[N - 1][0] = c.bx; c.p[N - 1][1] = c.by;\n        for (let j = 0; j < N - 1; j++) {\n          const a = c.p[j], b = c.p[j + 1];\n          let dx = b[0] - a[0], dy = b[1] - a[1];\n          const d = Math.hypot(dx, dy) || 0.001, pull = ((d - seg) / d) * 0.5;\n          dx *= pull; dy *= pull;\n          if (j > 0) { a[0] += dx; a[1] += dy; }\n          if (j < N - 2) { b[0] -= dx; b[1] -= dy; }\n        }\n      }\n    };\n    const settle = () => { for (let n = 0; n < 420; n++) cords.forEach((c, i) => { c.bx = BX[c.tool]; c.by = BY; rope(c, i, 1 / 60); }); };\n\n    const mix = (a: number[], b: number[], t: number) => `rgb(${a.map((v, i) => Math.round(v + (b[i] - v) * t)).join(\",\")})`;\n    const engrave = (g: CanvasRenderingContext2D, text: string, x: number, y: number, font: string, align: CanvasTextAlign = \"center\") => {\n      g.font = font; g.textAlign = align; g.textBaseline = \"middle\";\n      g.fillStyle = \"rgba(255,255,255,0.95)\"; g.fillText(text, x, y + 0.9);\n      g.fillStyle = \"rgba(11,13,18,0.78)\"; g.fillText(text, x, y);\n    };\n    const metal = (g: CanvasRenderingContext2D, x: number, y: number, r: number, flip = false) => {\n      const m = g.createLinearGradient(x - r, y - r, x + r, y + r);\n      const s = flip ? [\"#7c838f\", \"#e9ecf0\", \"#9299a5\"] : [\"#f7f8fa\", \"#8b929e\", \"#dfe2e7\"];\n      m.addColorStop(0, s[0]); m.addColorStop(0.52, s[1]); m.addColorStop(1, s[2]);\n      return m;\n    };\n    const jack = (g: CanvasRenderingContext2D, x: number, y: number, turn: number) => {\n      g.save();\n      g.shadowColor = \"rgba(11,13,18,0.38)\"; g.shadowBlur = 6 * k; g.shadowOffsetY = 3 * k;\n      g.beginPath(); for (let s = 0; s < 6; s++) { const a = turn + (s * Math.PI) / 3; g.lineTo(x + Math.cos(a) * 16, y + Math.sin(a) * 16); } g.closePath();\n      g.fillStyle = metal(g, x, y, 16); g.fill();\n      g.restore();\n      g.lineWidth = 0.8; g.strokeStyle = \"rgba(11,13,18,0.4)\"; g.stroke();\n      g.beginPath(); g.arc(x, y, 10.5, 0, Math.PI * 2); g.fillStyle = metal(g, x, y, 10.5, true); g.fill();\n      g.lineWidth = 0.7; g.strokeStyle = \"rgba(11,13,18,0.5)\"; g.stroke();\n      g.beginPath(); g.arc(x, y, 7, 0, Math.PI * 2); g.fillStyle = \"#06070a\"; g.fill();\n      g.beginPath(); g.arc(x, y, 6.2, 0.25, Math.PI - 0.25); g.lineWidth = 1.2; g.strokeStyle = \"rgba(255,255,255,0.3)\"; g.stroke();\n    };\n    const bezel = (g: CanvasRenderingContext2D, x: number, y: number, r: number) => {\n      g.beginPath(); g.arc(x, y, r + 3, 0, Math.PI * 2); g.fillStyle = metal(g, x, y, r + 3); g.fill();\n      g.lineWidth = 0.7; g.strokeStyle = \"rgba(11,13,18,0.45)\"; g.stroke();\n      g.beginPath(); g.arc(x, y, r + 0.8, 0, Math.PI * 2); g.fillStyle = \"#07080b\"; g.fill();\n    };\n    const lamp = (x: number, y: number, r: number, v: number) => {\n      if (v > 0.02) {\n        const bloom = ctx.createRadialGradient(x, y, 0, x, y, r * 5.5);\n        bloom.addColorStop(0, `rgba(79,152,251,${0.5 * v})`); bloom.addColorStop(1, \"rgba(79,152,251,0)\");\n        ctx.fillStyle = bloom; ctx.beginPath(); ctx.arc(x, y, r * 5.5, 0, Math.PI * 2); ctx.fill();\n      }\n      const dome = ctx.createRadialGradient(x - r * 0.3, y - r * 0.35, 0, x, y, r);\n      dome.addColorStop(0, mix([58, 78, 116], [240, 248, 255], v)); dome.addColorStop(0.55, mix([28, 40, 66], [79, 152, 251], v)); dome.addColorStop(1, mix([12, 18, 32], [40, 104, 205], v));\n      ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fillStyle = dome; ctx.fill();\n      ctx.beginPath(); ctx.ellipse(x - r * 0.34, y - r * 0.4, r * 0.32, r * 0.2, -0.6, 0, Math.PI * 2); ctx.fillStyle = `rgba(255,255,255,${0.45 + 0.4 * v})`; ctx.fill();\n    };\n    const cap = (x: number, y: number, lift: number) => {\n      const r = 13.5 + lift * 1.6;\n      ctx.save(); ctx.shadowColor = \"rgba(11,13,18,0.5)\"; ctx.shadowBlur = (7 + lift * 12) * k; ctx.shadowOffsetX = (2 + lift * 4) * k; ctx.shadowOffsetY = (4 + lift * 10) * k;\n      ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fillStyle = metal(ctx, x, y, r); ctx.fill(); ctx.restore();\n      const body = ctx.createRadialGradient(x - 4, y - 5, 1, x, y, r - 2);\n      body.addColorStop(0, \"#4a4f5c\"); body.addColorStop(0.5, \"#1b1e26\"); body.addColorStop(1, \"#090a0e\");\n      ctx.beginPath(); ctx.arc(x, y, r - 2.2, 0, Math.PI * 2); ctx.fillStyle = body; ctx.fill();\n      ctx.lineWidth = 0.8;\n      for (const rr of [r - 4.6, r - 6.6]) { ctx.beginPath(); ctx.arc(x, y, rr, 0, Math.PI * 2); ctx.strokeStyle = \"rgba(0,0,0,0.7)\"; ctx.stroke(); ctx.beginPath(); ctx.arc(x, y + 0.7, rr, 0.5, Math.PI - 0.5); ctx.strokeStyle = \"rgba(255,255,255,0.16)\"; ctx.stroke(); }\n    };\n    const trace = (c: Cord, ox = 0, oy = 0) => {\n      ctx.beginPath(); ctx.moveTo(c.p[0][0] + ox, c.p[0][1] + oy);\n      for (let j = 1; j < N - 1; j++) ctx.quadraticCurveTo(c.p[j][0] + ox, c.p[j][1] + oy, (c.p[j][0] + c.p[j + 1][0]) / 2 + ox, (c.p[j][1] + c.p[j + 1][1]) / 2 + oy);\n      ctx.lineTo(c.p[N - 1][0] + ox, c.p[N - 1][1] + oy);\n    };\n\n    // Everything that never moves is drawn once: engraving, screws, nuts and lamp bezels.\n    const drawStill = () => {\n      const g = still.getContext(\"2d\");\n      if (!g) return;\n      g.setTransform(k, 0, 0, k, 0, 0); g.clearRect(0, 0, W, H);\n      if (\"letterSpacing\" in g) (g as CanvasRenderingContext2D & { letterSpacing: string }).letterSpacing = \"1.6px\";\n      engrave(g, \"ORDER DESK\", 48, 40, `800 12px ${FONT}`, \"left\");\n      engrave(g, \"RUN\", W - 66, 40, \"600 9px ui-monospace, SFMono-Regular, Menlo, monospace\", \"right\");\n      bezel(g, W - 50, 40, 5);\n      g.fillStyle = \"rgba(11,13,18,0.2)\"; g.fillRect(30, 60, W - 60, 1); g.fillStyle = \"rgba(255,255,255,0.9)\"; g.fillRect(30, 61, W - 60, 1);\n      [[24, 24, 0.6], [W - 24, 24, 2.1], [24, H - 24, 1.2], [W - 24, H - 24, 0.2]].forEach(([x, y, a]) => {\n        g.save(); g.shadowColor = \"rgba(11,13,18,0.35)\"; g.shadowBlur = 3 * k; g.shadowOffsetY = 1.5 * k;\n        g.beginPath(); g.arc(x, y, 6.5, 0, Math.PI * 2); g.fillStyle = metal(g, x, y, 6.5); g.fill(); g.restore();\n        g.lineWidth = 1.6; g.strokeStyle = \"rgba(11,13,18,0.6)\"; g.beginPath(); g.moveTo(x - Math.cos(a) * 4.6, y - Math.sin(a) * 4.6); g.lineTo(x + Math.cos(a) * 4.6, y + Math.sin(a) * 4.6); g.stroke();\n      });\n      AX.forEach((x, i) => { jack(g, x, AY, 0.3 + i * 0.4); engrave(g, `0${i + 1}`, x + 7, 90, \"700 10px ui-monospace, SFMono-Regular, Menlo, monospace\"); bezel(g, x - 13, 90, 3); });\n      BX.forEach((x, i) => { jack(g, x, BY, 0.1 + i * 0.5); engrave(g, tools[i].name.toUpperCase(), x + 0.8, 206, `800 10px ${FONT}`); bezel(g, x, 236, 7); });\n    };\n\n    const draw = () => {\n      ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.clearRect(0, 0, cv.width, cv.height); ctx.drawImage(still, 0, 0);\n      ctx.setTransform(k, 0, 0, k, 0, 0);\n      lamp(W - 50, 40, 5, seq.step >= 0 && seq.step < 4 ? 0.75 + 0.25 * Math.sin(clock * 9) : seq.step === 4 ? 1 : 0.1);\n      leds.forEach((v, i) => lamp(AX[i] - 13, 90, 3, v));\n      lamps.forEach((v, i) => lamp(BX[i], 236, 7, v));\n      cords.forEach((c, i) => { cap(AX[i], AY, 0); });\n      // seated plugs first, then any plug in the hand so it passes over the others\n      const order = cords.map((_, i) => i).sort((a, b) => Number(cords[a].held) - Number(cords[b].held));\n      for (const i of order) {\n        const c = cords[i], lift = c.held ? 1 : Math.min(1, Math.hypot(c.bx - BX[c.tool], c.by - BY) / 50), blue = COLOURS[i % COLOURS.length] === BLUE;\n        cap(c.bx, c.by, lift);\n        ctx.lineCap = \"round\"; ctx.lineJoin = \"round\";\n        ctx.save(); ctx.shadowColor = \"rgba(11,13,18,0.3)\"; ctx.shadowBlur = 9 * k; ctx.shadowOffsetX = 4 * k; ctx.shadowOffsetY = 9 * k;\n        trace(c); ctx.lineWidth = 8; ctx.strokeStyle = blue ? \"#2f6fcf\" : \"#050609\"; ctx.stroke(); ctx.restore();\n        trace(c); ctx.lineWidth = 6.2; ctx.strokeStyle = COLOURS[i % COLOURS.length]; ctx.stroke();\n        ctx.save(); ctx.setLineDash([1.6, 3.2]); ctx.lineCap = \"butt\"; trace(c); ctx.lineWidth = 6.2; ctx.strokeStyle = blue ? \"rgba(11,13,18,0.14)\" : \"rgba(255,255,255,0.1)\"; ctx.stroke(); ctx.restore();\n        trace(c, -1.3, -1.5); ctx.lineWidth = 1.5; ctx.strokeStyle = blue ? \"rgba(255,255,255,0.55)\" : \"rgba(255,255,255,0.26)\"; ctx.stroke();\n        for (const [x, y] of [[AX[i], AY], [c.bx, c.by]]) {\n          ctx.beginPath(); ctx.arc(x, y, 5.6, 0, Math.PI * 2); ctx.fillStyle = blue ? \"#2f6fcf\" : \"#000\"; ctx.fill();\n          ctx.beginPath(); ctx.arc(x - 0.8, y - 1, 3.6, 0, Math.PI * 2); ctx.fillStyle = COLOURS[i % COLOURS.length]; ctx.fill();\n          ctx.beginPath(); ctx.arc(x - 1.6, y - 2, 1.2, 0, Math.PI * 2); ctx.fillStyle = \"rgba(255,255,255,0.6)\"; ctx.fill();\n        }\n        if (i === seq.step && seq.t > 0.12 && seq.t < 0.95) {\n          // the signal: a bead of light that runs down the cord from the step to its tool\n          const f = Math.min(0.999, (seq.t - 0.12) / 0.78), e = f * f * (3 - 2 * f) * (N - 1), j = Math.floor(e), u = e - j;\n          const x = c.p[j][0] + (c.p[j + 1][0] - c.p[j][0]) * u, y = c.p[j][1] + (c.p[j + 1][1] - c.p[j][1]) * u;\n          const glow = ctx.createRadialGradient(x, y, 0, x, y, 26);\n          glow.addColorStop(0, \"rgba(255,255,255,0.95)\"); glow.addColorStop(0.16, \"rgba(190,222,255,0.85)\"); glow.addColorStop(0.45, \"rgba(79,152,251,0.4)\"); glow.addColorStop(1, \"rgba(79,152,251,0)\");\n          ctx.fillStyle = glow; ctx.beginPath(); ctx.arc(x, y, 26, 0, Math.PI * 2); ctx.fill();\n        }\n      }\n    };\n\n    const show = (n: number) => setActive((a) => (a === n ? a : n));\n    const free = () => tools.findIndex((_, t) => !cords.some((c) => c.tool === t));\n    const plug = (i: number, tool: number) => { cords[i].tool = tool; setWires(cords.map((c) => c.tool)); lampTo.fill(0); seq.step = -1; seq.t = 0.5; show(-1); };\n\n    let raf = 0, last = 0, seen = true, acc = 0;\n    const frame = (now: number) => {\n      raf = 0;\n      if (!last) last = now;\n      const dt = Math.min(0.05, (now - last) / 1000); last = now; clock += dt;\n      // the agent runs its steps in order, one cord at a time\n      seq.t += dt;\n      if (seq.step === -1 && seq.t > 1) { seq.step = 0; seq.t = 0; show(0); }\n      else if (seq.step >= 0 && seq.step < 4) {\n        if (seq.t > 0.9) lampTo[cords[seq.step].tool] = 1;\n        if (seq.t > STEP_TIME) { seq.step += 1; seq.t = 0; show(seq.step); }\n      } else if (seq.step === 4 && seq.t > 2.1) {\n        lampTo.fill(0); seq.step = -1; seq.t = 0; seq.runs += 1; show(-1);\n        // left alone, the last cord moves itself to the spare jack before the next run\n        if (now - touched > 7000) { const spare = free(); if (spare >= 0) { cords[cords.length - 1].tool = spare; setWires(cords.map((c) => c.tool)); } }\n      }\n      lamps.forEach((v, i) => { lamps[i] = v + (lampTo[i] - v) * Math.min(1, dt * (lampTo[i] ? 16 : 4)); });\n      leds.forEach((v, i) => { const to = seq.step === 4 || i < seq.step ? 0.7 : i === seq.step ? 1 : 0; leds[i] = v + (to - v) * Math.min(1, dt * 12); });\n      acc = Math.min(0.05, acc + dt);\n      while (acc >= 1 / 120) {\n        cords.forEach((c, i) => {\n          if (!c.held) { c.vx += (300 * (BX[c.tool] - c.bx) - 26 * c.vx) / 120; c.vy += (300 * (BY - c.by) - 26 * c.vy) / 120; c.bx += c.vx / 120; c.by += c.vy / 120; }\n          rope(c, i, 1 / 120);\n        });\n        acc -= 1 / 120;\n      }\n      draw();\n      if (seen && !document.hidden) raf = requestAnimationFrame(frame);\n    };\n    const wake = () => { if (!raf && !reduce) { last = 0; raf = requestAnimationFrame(frame); } };\n    const freeze = () => { settle(); cords.forEach((c) => { lamps[c.tool] = 1; }); leds.fill(0.7); seq.step = 4; draw(); };\n\n    api.current = {\n      grab: (i) => { touched = performance.now(); if (!reduce) { cords[i].held = true; cords[i].vx = 0; cords[i].vy = 0; } },\n      drag: (i, x, y) => {\n        const c = cords[i];\n        if (!c.held) return;\n        let dx = x - AX[i], dy = y - AY; const d = Math.hypot(dx, dy), max = c.len * 0.96;\n        if (d > max) { dx *= max / d; dy *= max / d; }\n        c.bx = Math.max(18, Math.min(W - 18, AX[i] + dx)); c.by = Math.max(18, Math.min(H - 18, AY + dy));\n      },\n      drop: (i) => {\n        const c = cords[i];\n        if (!c.held) return;\n        c.held = false; touched = performance.now();\n        let best = c.tool, near = 58;\n        BX.forEach((x, t) => { const d = Math.hypot(x - c.bx, BY - c.by); if (d < near && (t === c.tool || !cords.some((o) => o.tool === t))) { near = d; best = t; } });\n        if (best !== c.tool) plug(i, best);\n      },\n      hop: (i) => { touched = performance.now(); const spare = free(); if (spare < 0) return; plug(i, spare); if (reduce) { lamps.fill(0); freeze(); show(4); } },\n    };\n\n    const fit = () => {\n      const b = cv.getBoundingClientRect();\n      if (!b.width) return;\n      const dpr = Math.min(2, window.devicePixelRatio || 1);\n      cv.width = still.width = Math.round(b.width * dpr); cv.height = still.height = Math.round((b.width * dpr * H) / W);\n      k = cv.width / W;\n      drawStill(); draw();\n    };\n    settle();\n    fit();\n    if (reduce) { freeze(); setActive(4); } else wake();\n    const ro = new ResizeObserver(fit);\n    ro.observe(cv);\n    const io = new IntersectionObserver(([entry]) => { seen = entry.isIntersecting; if (seen) wake(); });\n    io.observe(cv);\n    const onVis = () => { if (!document.hidden) wake(); };\n    document.addEventListener(\"visibilitychange\", onVis);\n    return () => { cancelAnimationFrame(raf); api.current = null; ro.disconnect(); io.disconnect(); document.removeEventListener(\"visibilitychange\", onVis); };\n  }, []);\n\n  const point = (e: ReactPointerEvent<HTMLButtonElement>) => {\n    const b = canvas.current?.getBoundingClientRect();\n    return b ? { x: ((e.clientX - b.left) / b.width) * W, y: ((e.clientY - b.top) / b.height) * H } : { x: 0, y: 0 };\n  };\n  const step = active >= 0 && active < 4 ? active : -1;\n  const line = step >= 0 ? tools[wires[step]].does : active === 4 ? \"Order handled. Waiting for the next one\" : \"Listening for a new order\";\n\n  return (\n    <div style={{ fontFamily: FONT }} className=\"flex min-h-[640px] w-full items-center justify-center bg-[#D9D5CB] bg-[radial-gradient(80%_70%_at_50%_36%,#eeebe4_0%,#D9D5CB_55%,#c4bfb3_100%)] px-4 py-10 sm:min-h-[800px]\">\n      <div className=\"relative aspect-[520/600] w-full max-w-[520px] rounded-[30px] bg-[#F6F4EF] bg-[linear-gradient(165deg,#ffffff_0%,#F6F4EF_42%,#ebe8e0_100%)] shadow-[inset_0_1.5px_0_#ffffff,inset_0_-2px_1px_rgba(11,13,18,0.1),inset_0_0_0_1px_rgba(255,255,255,0.6),0_1px_0_#cbc6ba,0_3px_0_#c1bcb0,0_5px_0_#b7b2a6,0_7px_0_#aeA99d,0_22px_26px_-8px_rgba(11,13,18,0.35),0_60px_70px_-30px_rgba(11,13,18,0.5)] sm:max-w-[590px]\">\n        <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 rounded-[30px] bg-[linear-gradient(118deg,rgba(255,255,255,0)_18%,rgba(255,255,255,0.75)_30%,rgba(255,255,255,0)_44%,rgba(255,255,255,0)_70%,rgba(255,255,255,0.35)_78%,rgba(255,255,255,0)_88%)]\" />\n        <div className=\"absolute inset-x-[5.4%] bottom-[4.4%] flex h-[11%] flex-col justify-center overflow-hidden rounded-[12px] bg-[#0B0D12] px-[4%] shadow-[inset_0_3px_6px_rgba(0,0,0,0.9),inset_0_0_0_1px_#000,0_1px_0_rgba(255,255,255,0.95),0_-1px_0_rgba(11,13,18,0.12)]\">\n          <span className=\"font-mono text-[9px] font-semibold uppercase leading-4 tracking-[0.22em] text-[#4F98FB] sm:text-[10px]\">\n            {step >= 0 ? `Step 0${step + 1} / ${tools[wires[step]].name}` : active === 4 ? \"Done\" : \"Ready\"}\n          </span>\n          <span className=\"truncate text-[13px] font-bold leading-5 tracking-[-0.01em] text-[#F6F4EF] [text-shadow:0_0_12px_rgba(79,152,251,0.55)] sm:text-[16px] sm:leading-6\">{line}</span>\n          <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 bg-[linear-gradient(180deg,rgba(255,255,255,0.07)_0%,rgba(255,255,255,0)_45%)]\" />\n        </div>\n        <canvas ref={canvas} aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 h-full w-full\" />\n        <ul aria-label=\"Which tool each step uses\" className=\"absolute inset-0 m-0 list-none p-0\">\n          {wires.map((tool, i) => (\n            <li key={i}>\n              <button\n                type=\"button\"\n                aria-label={`Step ${i + 1} uses ${tools[tool].name}. Move this cord to the spare jack`}\n                style={{ left: `${(BX[tool] / W) * 100}%`, top: `${(BY / H) * 100}%` }}\n                onPointerDown={(e) => { e.currentTarget.setPointerCapture(e.pointerId); press.current = { x: e.clientX, y: e.clientY, moved: false }; api.current?.grab(i); }}\n                onPointerMove={(e) => {\n                  if (!e.currentTarget.hasPointerCapture(e.pointerId)) return;\n                  if (Math.hypot(e.clientX - press.current.x, e.clientY - press.current.y) > 5) press.current.moved = true;\n                  if (press.current.moved) { const p = point(e); api.current?.drag(i, p.x, p.y); }\n                }}\n                onPointerUp={() => { api.current?.drop(i); }}\n                onPointerCancel={() => { api.current?.drop(i); }}\n                onClick={() => { if (!press.current.moved) api.current?.hop(i); press.current.moved = false; }}\n                className=\"absolute h-11 w-11 -translate-x-1/2 -translate-y-1/2 cursor-grab touch-none rounded-full outline-none focus-visible:ring-2 focus-visible:ring-[#4F98FB] focus-visible:ring-offset-2 focus-visible:ring-offset-[#F6F4EF] active:cursor-grabbing\"\n              />\n            </li>\n          ))}\n        </ul>\n      </div>\n    </div>\n  );\n}\n"}]}
