"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NamedQueryEditor = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const AdaptableContext_1 = require("../../View/AdaptableContext");
const CheckBox_1 = require("../CheckBox");
const EditorButton_1 = tslib_1.__importDefault(require("./EditorButton"));
const NamedQueryEditor = (props) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const [showColumnIds, setShowColumnIds] = React.useState(false);
    const [inlineQuery, setInlineQuery] = React.useState(false);
    return (React.createElement(rebass_1.Flex, { flexDirection: "column", alignItems: "start", style: { marginTop: 2 } },
        React.createElement(CheckBox_1.CheckBox, { checked: showColumnIds, onChange: (checked) => setShowColumnIds(checked) }, "Show Column IDs"),
        React.createElement(CheckBox_1.CheckBox, { checked: inlineQuery, onChange: (checked) => setInlineQuery(checked) }, "Inline Query"),
        props.namedQueries.map((namedQuery) => (React.createElement(rebass_1.Flex, { key: namedQuery.Uuid, flexDirection: "column", alignItems: "start", style: {
                padding: 3,
                marginTop: 'var(--ab-space-2)',
                marginBottom: 'var(--ab-space-2)',
                width: '100%',
            }, backgroundColor: "primarylight" },
            ' ',
            React.createElement(EditorButton_1.default, { width: "100%", height: "100%", style: {
                    background: 'var(--ab-color-primary)',
                    cursor: 'grab',
                }, data: inlineQuery ? namedQuery.BooleanExpression : `QUERY("${namedQuery.Name}")`, "data-name": "column", icon: "drag" },
                React.createElement(rebass_1.Flex, { flexDirection: "column", alignItems: "start" }, namedQuery.Name)),
            React.createElement(rebass_1.Flex, { alignItems: "start", style: {
                    padding: 5,
                } }, showColumnIds
                ? namedQuery.BooleanExpression
                : adaptable.api.expressionApi.getAdaptableQueryExpressionWithColumnFriendlyNames(namedQuery)))))));
};
exports.NamedQueryEditor = NamedQueryEditor;
