"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XRuntimeWrapper = exports.ObserableData = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const ObserveState_1 = require("../../CommonUI/StateManagement/ObserveState");
const styled_components_1 = tslib_1.__importDefault(require("styled-components"));
class ObserableData {
    innerComponent;
    context;
    constructor(innerComponent, context) {
        this.innerComponent = innerComponent;
        this.context = context;
    }
}
exports.ObserableData = ObserableData;
class XRuntimeWrapper extends react_1.default.Component {
    render() {
        const valueName = Reflect.get(this.props.innerComponent, "valueName");
        const id = this.props.innerComponent.id;
        if (valueName) {
            return ((0, jsx_runtime_1.jsx)(ObserveState_1.ObserveState, { listenTo: this.props.context, control: () => this.renderControl(), properties: [valueName, id] }));
        }
        else {
            return this.props.innerComponent.render();
        }
    }
    renderControl() {
        const id = this.props.innerComponent.id;
        const hideControls = this.props.context.runtimeHideControls;
        if (hideControls.indexOf(id) >= 0)
            return null;
        const disabledControls = this.props.context.runtimeDisabledControls;
        if (disabledControls.indexOf(id) >= 0) {
            return (0, jsx_runtime_1.jsx)(StyledFieldSet, { disabled: true, children: this.props.innerComponent.render() });
        }
        return this.props.innerComponent.render();
    }
}
exports.XRuntimeWrapper = XRuntimeWrapper;
const StyledFieldSet = styled_components_1.default.fieldset `
    border: none;
    margin: 0px;
    padding: 0px;
`;
//# sourceMappingURL=XRuntimeWrapper.js.map