// components/portal/LaserToolkitSwitcher.tsx "use client"; import { useMemo } from "react"; import { useSearchParams, useRouter } from "next/navigation"; import { cn } from "@/lib/utils"; import { TOOLKIT_TABS } from "@/components/utilities/laser-toolkit/registry"; export default function LaserToolkitSwitcher() { const sp = useSearchParams(); const router = useRouter(); const activeKey = useMemo(() => { const def = TOOLKIT_TABS[0]?.key ?? "beam-spot-size"; const t = (sp.get("lt") || def).toLowerCase(); return TOOLKIT_TABS.some(x => x.key === t) ? t : def; }, [sp]); const active = useMemo( () => TOOLKIT_TABS.find(x => x.key === activeKey) ?? TOOLKIT_TABS[0], [activeKey] ); function setTab(k: string) { const q = new URLSearchParams(sp.toString()); q.set("lt", k); router.replace(`/portal/utilities?${q.toString()}`, { scroll: false }); } if (!active) { return