"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlusMinusRuleWizardSection = exports.PlusMinusRuleSummary = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
const EntityRulesEditor_1 = require("../../Components/EntityRulesEditor");
const CodeBlock_1 = require("../../../components/CodeBlock");
function PlusMinusRuleSummary() {
    const { data } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
    return (React.createElement(EntityRulesEditor_1.EntityRulesSummary, { data: data, renderPredicate: (contents) => {
            return (React.createElement(React.Fragment, null,
                "Apply Plus Minus on ",
                React.createElement(CodeBlock_1.CodeBlock, null, contents)));
        }, renderQueryExpression: (contents) => {
            return (React.createElement(React.Fragment, null,
                "Apply Plus Minus when",
                ' ',
                React.createElement("b", null,
                    React.createElement(CodeBlock_1.CodeBlock, null, contents))));
        } }));
}
exports.PlusMinusRuleSummary = PlusMinusRuleSummary;
function PlusMinusRuleWizardSection(props) {
    const { data, moduleInfo } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
    const plusMinusNudge = {
        ...data,
        Rule: data?.Rule ?? { BooleanExpression: '' },
    };
    return (React.createElement(EntityRulesEditor_1.EntityRulesEditor, { module: moduleInfo.ModuleName, 
        // min-height 0 so the container does not min-size from it's children
        // https://stackoverflow.com/questions/33605552/how-to-prevent-a-flex-item-height-to-overflow-due-to-its-content
        flexProps: { style: { minHeight: 0 } }, defaultPredicateId: props.defaultPredicateId, predicateDefs: [], showAggregation: false, showObservable: false, showPredicate: false, data: plusMinusNudge, 
        // the cast is to convince TS that it still a PlusMinusNudge
        // even when Rule is not optional, the type is inferred from `plusMinusNudge`
        onChange: (plusMinus) => props.onChange(plusMinus), descriptions: {
            selectPredicate: null,
            useBooleanQuery: (React.createElement(React.Fragment, null,
                "Use an BooleanQuery if ",
                React.createElement("i", null, "Scope"),
                " is 'All Columns' - so any data change may be evaluated in a complex BooleanExpression")),
            useObservableQuery: null,
            useAggregationQuery: null,
        } }));
}
exports.PlusMinusRuleWizardSection = PlusMinusRuleWizardSection;
