"use client";
import { useState, type ReactNode } from "react";
import { CopyButton } from "../feedback/CopyButton.tsx";
export function DiffView({
before,
after,
beforeLabel = "Before",
afterLabel = "After",
className = "",
}: {
before: string;
after: string;
beforeLabel?: string;
afterLabel?: string;
className?: string;
}) {
const a = before.split("\n"),
b = after.split("\n");
// ponytail: aligned-line comparison, use a diff engine when moved-line matching matters.
return (
{beforeLabel}
{a.map((line, i) => (
{i + 1}
{line || " "}
{"\n"}
))}
{afterLabel}
{b.map((line, i) => (
{i + 1}
{line || " "}
{"\n"}
))}
);
}
function JsonNode({
value,
name,
depth,
ancestors,
}: {
value: unknown;
name: string;
depth: number;
ancestors: ReadonlySet