var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { Language, Markdown } from '@signatu/common-lib';
import { withStyles } from '@signatu/styles';
import PropTypes from 'prop-types';
import React from 'react';
import { CONSENT_BASE_PROPTYPES } from '../lib/consentBase';
import { ConsentRequest } from './consentRequest';
var uppercaseFirstCharacter = function (s) {
    return s.charAt(0).toUpperCase() + s.slice(1);
};
var styles = function (theme) { return ({
    root: {
        fontFamily: theme.typography.fontFamily,
        fontWeight: theme.typography.fontWeight,
        fontSize: theme.typography.fontSize,
    },
    /** nbsp; before each of these */
    action: {
        '&:before': {
            content: '"\\00a0"'
        }
    },
    controller: {},
    subject: {
        '&:before': {
            content: '"\\00a0"'
        }
    },
    data: {
        '&:before': {
            content: '"\\00a0"'
        }
    },
    purpose: {
        '&:before': {
            content: '"\\00a0"'
        }
    },
}); };
var DataProcessingConsent = /** @class */ (function (_super) {
    __extends(DataProcessingConsent, _super);
    function DataProcessingConsent(props) {
        var _this = _super.call(this, props) || this;
        _this.markdown = new Markdown();
        return _this;
    }
    DataProcessingConsent.prototype.render = function () {
        var _this = this;
        var _a = this.props, classes = _a.classes, type = _a.type, dataprocessing = _a.dataprocessing, config = _a.config, subject = _a.subject, issuer = _a.issuer, target = _a.target, scope = _a.scope, delegate = _a.delegate;
        var isoLang = this.props.language || 'en';
        var language = new Language(isoLang);
        var consentContent = (React.createElement("div", { className: classes.root },
            React.createElement("span", { className: classes.controller }, uppercaseFirstCharacter(dataprocessing.controllerText(language))),
            React.createElement("span", { title: "The type of processing", className: classes.action },
                " ",
                dataprocessing.actionText(language)),
            React.createElement("span", { className: classes.subject }, dataprocessing.subjectText(language)),
            React.createElement("span", { title: "Personal data we process", className: classes.data },
                dataprocessing.data,
                " "),
            React.createElement("span", { className: classes.purpose }, dataprocessing.purposeText(language)),
            React.createElement("span", { title: "The purpose of the processing", className: classes.purpose, dangerouslySetInnerHTML: { __html: this.markdown.html(dataprocessing.purpose) } })));
        /** If the element has content for the language, use that instead */
        var content = dataprocessing.getContentForLanguage(language);
        if (content.length > 0) {
            consentContent = (React.createElement("div", { className: classes.root }, content.map(function (c, idx) { return React.createElement("div", { key: idx, dangerouslySetInnerHTML: { __html: _this.markdown.html(c.value) } }); })));
        }
        return (React.createElement("div", { "data-type": "DataProcessingConsent" },
            React.createElement(ConsentRequest, { config: config, language: isoLang, type: type, subject: subject, issuer: issuer, target: target, scope: scope, delegate: delegate, optOut: this.props.optOut },
                consentContent,
                this.props.children)));
    };
    DataProcessingConsent.displayName = "DataProcessingConsent";
    /** PropTypes for non-Typescript environments */
    DataProcessingConsent.propTypes = __assign({}, CONSENT_BASE_PROPTYPES, { dataprocessing: PropTypes.object, type: PropTypes.string, classes: PropTypes.object });
    return DataProcessingConsent;
}(React.Component));
var styled = withStyles(styles)(DataProcessingConsent);
export { styled as DataProcessingConsent };
//# sourceMappingURL=dataProcessingConsent.js.map