'use client';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useCallback } from 'react';
import { Code2, Terminal, FolderOpen, RefreshCw } from 'lucide-react';
import { BaseDrawer } from '../../common/base-drawer/index.js';
import { DrawerTitle, DrawerDescription } from '../../ui/drawer.js';
import { Separator } from '../../ui/separator.js';
import { ActionButton } from '../../common/action-button/index.js';
import { useRepositoryActions } from './use-repository-actions.js';
export function RepositoryDrawer({ data, onClose }) {
    const handleClose = useCallback(() => {
        onClose();
    }, [onClose]);
    const actions = useRepositoryActions(data?.repositoryPath ? { repositoryId: data.id, repositoryPath: data.repositoryPath } : null);
    return (_jsx(BaseDrawer, { open: data !== null, onClose: handleClose, size: "md", modal: false, "data-testid": "repository-drawer", deployTarget: data?.repositoryPath
            ? {
                targetId: data.repositoryPath,
                targetType: 'repository',
                repositoryPath: data.repositoryPath,
            }
            : undefined, header: data ? (_jsxs("div", { "data-testid": "repository-drawer-header", children: [_jsx(DrawerTitle, { children: data.name }), data.repositoryPath ? (_jsx(DrawerDescription, { className: "truncate font-mono text-xs", children: data.repositoryPath })) : null] })) : undefined, children: data?.repositoryPath ? (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "text-muted-foreground text-xs font-semibold tracking-wider", children: "OPEN WITH" }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(ActionButton, { label: "Open in IDE", onClick: actions.openInIde, loading: actions.ideLoading, error: !!actions.ideError, icon: Code2, variant: "outline", size: "sm" }), _jsx(ActionButton, { label: "Open in Shell", onClick: actions.openInShell, loading: actions.shellLoading, error: !!actions.shellError, icon: Terminal, variant: "outline", size: "sm" }), _jsx(ActionButton, { label: "Open Folder", onClick: actions.openFolder, loading: actions.folderLoading, error: !!actions.folderError, icon: FolderOpen, variant: "outline", size: "sm" })] })] }), data.id ? (_jsxs(_Fragment, { children: [_jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-3 p-4", children: [_jsx("div", { className: "text-muted-foreground text-xs font-semibold tracking-wider", children: "GIT OPERATIONS" }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(ActionButton, { label: "Sync Main", onClick: actions.syncMain, loading: actions.syncLoading, error: !!actions.syncError, icon: RefreshCw, variant: "outline", size: "sm" }), actions.syncError ? (_jsx("p", { className: "text-destructive text-xs", children: actions.syncError })) : null] })] })] })) : null] })) : null }));
}
