"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeItemOldValue = void 0;
var react_1 = __importDefault(require("react"));
var ramda_1 = require("ramda");
var East_1 = __importDefault(require("@mui/icons-material/East"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var common_1 = require("../../../../helpers/common");
var DataTypeValue_1 = require("../../../../../../DataTypeValue");
var ChangeItemLabel_1 = require("../../ChangeItemLabel");
var editors_module_css_1 = __importDefault(require("../editors.module.css"));
var ChangeItemOldValue_module_css_1 = __importDefault(require("./ChangeItemOldValue.module.css"));
var ChangeItemOldValue = function (_a) {
    var change = _a.change;
    var isUpdateOperation = change.operation === mdm_sdk_1.DCROperationTypes.EDITED;
    var oldValue = (0, mdm_sdk_1.getAttributeValue)(change.oldValue);
    var newValue = (0, mdm_sdk_1.getAttributeValue)(change.newValue);
    var dataTypeDefinition = change.attributeType && (0, common_1.getDataTypeDefinition)(change.attributeType, newValue !== null && newValue !== void 0 ? newValue : oldValue);
    var hasOldValue = !(0, ramda_1.isNil)(oldValue);
    return (react_1.default.createElement("div", { className: editors_module_css_1.default.attributeRow },
        react_1.default.createElement(ChangeItemLabel_1.ChangeItemLabel, { change: change, className: editors_module_css_1.default.labelColumn }),
        react_1.default.createElement("div", { className: editors_module_css_1.default.valueColumn }, isUpdateOperation && hasOldValue && (react_1.default.createElement("div", { className: ChangeItemOldValue_module_css_1.default.previousValue },
            react_1.default.createElement("span", { className: ChangeItemOldValue_module_css_1.default.previousValueText },
                react_1.default.createElement(DataTypeValue_1.DataTypeValue, { value: oldValue, dataTypeDefinition: dataTypeDefinition })),
            react_1.default.createElement("span", { className: ChangeItemOldValue_module_css_1.default.arrow },
                react_1.default.createElement(East_1.default, null))))),
        react_1.default.createElement("div", { className: editors_module_css_1.default.revertColumn }),
        react_1.default.createElement("div", { className: editors_module_css_1.default.operationColumn })));
};
exports.ChangeItemOldValue = ChangeItemOldValue;
