import { jsx as _jsx } from "react/jsx-runtime";
import { Alert, Block } from '@cube-dev/ui-kit';
import { useMemo } from 'react';
import { useQueryBuilderContext } from './context';
import { CopyButton } from './components/CopyButton';
import { TabPaneWithToolbar } from './components/TabPaneWithToolbar';
import { ScrollableCodeContainer } from './components/ScrollableCodeContainer';
export function QueryBuilderRest() {
    const { query, isQueryEmpty, queryHash } = useQueryBuilderContext();
    return useMemo(() => {
        const stringifiedQuery = JSON.stringify(query, null, 2);
        return !query || isQueryEmpty ? (_jsx(Block, { padding: "1x", children: _jsx(Alert, { theme: "note", children: "Compose a query to see a JSON query." }) })) : (_jsx(TabPaneWithToolbar, { actions: _jsx(CopyButton, { type: "secondary", value: stringifiedQuery || '', children: "Copy" }), children: _jsx(ScrollableCodeContainer, { value: stringifiedQuery || '' }) }));
    }, [queryHash, isQueryEmpty]);
}
//# sourceMappingURL=QueryBuilderRest.js.map