import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { BaseExpression } from "../../BaseExpression";
import { ExpressionValue } from "../../ExpressionValue";
import { ExpressionValueRenderer } from "../../ExpressionValueRenderer";
import { BracketedDiv, ExpressionPiece } from "../../ExpressionStyles";
import { NumberDataDefinition } from "../../../Common/Data/Definitions/NumberDataDefinition";
export class ModExpression extends BaseExpression {
    constructor() {
        super();
        this.__type = "Mod";
        this.expressionValueType = new NumberDataDefinition();
        let dd = new NumberDataDefinition();
        this.value1 = ExpressionValue.createExpressionValue(this, "value1", dd);
        dd = new NumberDataDefinition();
        this.value2 = ExpressionValue.createExpressionValue(this, "value2", dd);
    }
    render() {
        return (_jsxs(ExpressionPiece, { children: [_jsx(BracketedDiv, { children: _jsx(ExpressionValueRenderer, { el: this.value1 }, void 0) }, void 0), "mod", _jsx(BracketedDiv, { children: _jsx(ExpressionValueRenderer, { el: this.value2 }, void 0) }, void 0)] }, void 0));
    }
    evaluate(data, testContext) {
        let divideValue = this.value1.evaluate(data, testContext);
        let divideBy = this.value2.evaluate(data, testContext);
        if (divideBy === 0) {
            throw new Error("Can not divide by zero");
        }
        return divideValue % divideBy;
    }
}
//# sourceMappingURL=ModExpression.js.map