"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "@stigmer/theme";
/**
 * Compact, read-only display of workspace entries showing each
 * entry's name and source (git repository URL or local path).
 *
 * This is the display-only counterpart to {@link WorkspaceEditor},
 * designed for contexts where workspace data is shown but not edited
 * (e.g., execution detail views, session summaries).
 *
 * Renders its content without card chrome (no border, background, or
 * elevation). The consumer controls the container styling.
 *
 * All visual properties flow through `--stgm-*` tokens.
 *
 * @example
 * ```tsx
 * const { session } = useSession(sessionId);
 *
 * <WorkspaceSummary
 *   entries={session?.spec?.workspaceEntries ?? []}
 * />
 * ```
 */
export function WorkspaceSummary({ entries, className, }) {
    if (entries.length === 0)
        return null;
    return (_jsx("ul", { className: cn("space-y-1.5", className), "aria-label": "Workspace entries", children: entries.map((entry) => (_jsxs("li", { className: "text-xs", children: [_jsxs("div", { className: "flex items-center gap-1.5 font-medium", children: [_jsx(FolderIcon, {}), _jsx("span", { className: "truncate", children: entry.name })] }), _jsx(SourceLabel, { source: entry.source })] }, entry.name))) }));
}
// ---------------------------------------------------------------------------
// Internal sub-components
// ---------------------------------------------------------------------------
function SourceLabel({ source }) {
    if (!source || source.source.case === undefined)
        return null;
    if (source.source.case === "gitRepo") {
        const url = source.source.value.url;
        const short = url
            .replace(/^https?:\/\//, "")
            .replace(/\.git$/, "");
        return (_jsx("span", { className: "ml-5 block truncate text-muted-foreground", title: url, children: short }));
    }
    if (source.source.case === "localPath") {
        const path = source.source.value.path;
        return (_jsx("span", { className: "ml-5 block truncate font-mono text-muted-foreground", title: path, children: path }));
    }
    return null;
}
function FolderIcon() {
    return (_jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M1.5 3V9.5a1 1 0 001 1h7a1 1 0 001-1V4.5a1 1 0 00-1-1H6L4.5 2H2.5a1 1 0 00-1 1z" }) }));
}
//# sourceMappingURL=WorkspaceSummary.js.map