"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 AdaptableContext_1 = require("../../View/AdaptableContext");
const CheckBox_1 = require("../CheckBox");
const EditorButton_1 = tslib_1.__importDefault(require("./EditorButton"));
const Flex_1 = require("../Flex");
const NamedQueryEditor = (props) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const [showColumnIds, setShowColumnIds] = React.useState(false);
    const [inlineQuery, setInlineQuery] = React.useState(false);
    return (React.createElement(Flex_1.Flex, { flexDirection: "column", alignItems: "flex-start", className: "twa:mt-[2px]" },
        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(Flex_1.Flex, { key: namedQuery.Uuid, flexDirection: "column", alignItems: "flex-start", className: "twa:p-1 twa:my-2 twa:w-full twa:bg-primarylight" },
            ' ',
            React.createElement(EditorButton_1.default, { className: "twa:w-full twa:h-full twa:bg-primary twa:cursor-grab", data: inlineQuery ? namedQuery.BooleanExpression : `QUERY("${namedQuery.Name}")`, "data-name": "column", icon: "drag" },
                React.createElement(Flex_1.Flex, { flexDirection: "column", alignItems: "flex-start" }, namedQuery.Name)),
            React.createElement(Flex_1.Flex, { alignItems: "flex-start", className: "twa:p-1" }, showColumnIds
                ? namedQuery.BooleanExpression
                : adaptable.api.expressionApi.getAdaptableQueryExpressionWithColumnFriendlyNames(namedQuery)))))));
};
exports.NamedQueryEditor = NamedQueryEditor;
