import React from 'react';
import classnames from 'classnames';
import i18n from 'ui-i18n';
import { useContextSelector } from '@fluentui/react-context-selector';
import { MoreAttributesButton } from '../../../../../../MoreAttributesButton';
import { ChangeRequestEditorContext } from '../../../../contexts/ChangeRequestEditorContext';
import { extractLineIds } from '../../../../helpers/merge';
import editorStyles from '../editors.module.css';
import styles from './MoreAttributesEditor.module.css';
var emptyLineIds = [];
export var MoreAttributesEditor = function (_a) {
    var _b;
    var data = _a.data, onApply = _a.onApply, change = _a.change, parent = _a.parent;
    var lineIds = (change === null || change === void 0 ? void 0 : change.lineIds) || extractLineIds(change === null || change === void 0 ? void 0 : change.newValue) || emptyLineIds;
    var isLineRejected = useContextSelector(ChangeRequestEditorContext, function (context) {
        return context.getIsLineRejected(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
    });
    var isParentLineRejected = useContextSelector(ChangeRequestEditorContext, function (context) {
        return context.getIsParentLineRejected(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
    });
    var label = i18n.text('More attributes');
    var isRejected = isLineRejected || isParentLineRejected;
    return (React.createElement("div", { className: classnames(editorStyles.attributeRow, (_b = {}, _b[styles.rejectedRow] = isRejected, _b)), "data-reltio-id": "more-attributes-editor" },
        React.createElement("div", { className: editorStyles.labelColumn }),
        React.createElement("div", { className: classnames(editorStyles.valueColumn, styles.moreAttributesButton) },
            React.createElement(MoreAttributesButton, { label: label, popupTitle: label, data: data, parent: parent, onApply: onApply, disabled: isRejected }))));
};
