"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "QRCodeIDCardPrintout", {
    enumerable: true,
    get: function() {
        return QRCodeIDCardPrintout;
    }
});
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
const _renderer = require("@react-pdf/renderer");
const _patientAccessors = require("../patientAccessors");
const _languageContext = require("../pdf/languageContext");
const _withDateTimeContext = require("../pdf/withDateTimeContext");
const _Page = require("../pdf/Page");
const _Text = require("../pdf/Text");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const mmToPt = (mm)=>mm * 2.835;
const styles = _renderer.StyleSheet.create({
    mainContainer: {
        display: 'flex',
        flexDirection: 'row',
        height: '100%',
        overflow: 'hidden',
        alignItems: 'center'
    },
    qrContainer: {
        width: '25mm',
        paddingLeft: '3mm',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center'
    },
    qrImage: {
        width: '22mm',
        height: '22mm'
    },
    details: {
        display: 'flex',
        flexDirection: 'column',
        justifyContent: 'center',
        marginLeft: '5mm'
    },
    infoRow: {
        display: 'flex',
        flexDirection: 'row',
        fontSize: '2.4mm',
        marginVertical: 1.8
    },
    detailsKey: {
        width: '18mm',
        fontWeight: 700
    },
    detailsValue: {
        maxWidth: '35mm',
        overflow: 'hidden',
        fontWeight: 700
    }
});
const MainContainer = (props)=>/*#__PURE__*/ _react.default.createElement(_renderer.View, {
        style: styles.mainContainer,
        ...props
    });
const Details = (props)=>/*#__PURE__*/ _react.default.createElement(_renderer.View, {
        style: styles.details,
        ...props
    });
const InfoRow = (props)=>/*#__PURE__*/ _react.default.createElement(_renderer.View, {
        style: styles.infoRow,
        ...props
    });
const DetailsKey = (props)=>/*#__PURE__*/ _react.default.createElement(_Text.Text, {
        bold: true,
        style: styles.detailsKey,
        ...props
    });
const DetailsValue = (props)=>/*#__PURE__*/ _react.default.createElement(_Text.Text, {
        bold: true,
        style: styles.detailsValue,
        ...props
    });
const DetailsRow = ({ value, label })=>/*#__PURE__*/ _react.default.createElement(InfoRow, null, /*#__PURE__*/ _react.default.createElement(DetailsKey, null, `${label}: `), /*#__PURE__*/ _react.default.createElement(DetailsValue, null, value));
const QRCodeIDCardPrintoutComponent = ({ patient, qrCodeDataUrl, cardDimensions, measures, getTranslation })=>{
    const { formatShort } = (0, _withDateTimeContext.useDateTime)();
    const pageStyles = _renderer.StyleSheet.create({
        card: {
            width: cardDimensions.width,
            height: cardDimensions.height,
            marginTop: mmToPt(measures.cardMarginTop),
            marginLeft: mmToPt(measures.cardMarginLeft),
            display: 'flex',
            flexDirection: 'column'
        }
    });
    const Card = (props)=>/*#__PURE__*/ _react.default.createElement(_renderer.View, {
            style: pageStyles.card,
            ...props
        });
    return /*#__PURE__*/ _react.default.createElement(_renderer.Document, null, /*#__PURE__*/ _react.default.createElement(_Page.Page, {
        size: "A4",
        style: {
            paddingTop: mmToPt(10.6)
        }
    }, /*#__PURE__*/ _react.default.createElement(Card, null, /*#__PURE__*/ _react.default.createElement(MainContainer, null, /*#__PURE__*/ _react.default.createElement(_renderer.View, {
        style: styles.qrContainer
    }, /*#__PURE__*/ _react.default.createElement(_renderer.Image, {
        src: qrCodeDataUrl,
        style: styles.qrImage
    })), /*#__PURE__*/ _react.default.createElement(Details, null, /*#__PURE__*/ _react.default.createElement(DetailsRow, {
        value: patient.displayId,
        label: getTranslation('general.localisedField.displayId.label.short', 'NHN')
    }), /*#__PURE__*/ _react.default.createElement(DetailsRow, {
        value: patient.lastName,
        label: getTranslation('general.localisedField.lastName.label', 'Last name')
    }), /*#__PURE__*/ _react.default.createElement(DetailsRow, {
        value: patient.firstName,
        label: getTranslation('general.localisedField.firstName.label', 'First name')
    }), /*#__PURE__*/ _react.default.createElement(DetailsRow, {
        value: (0, _patientAccessors.getDob)(patient, {
            getTranslation,
            formatShort
        }),
        label: getTranslation('general.localisedField.dateOfBirth.label.short', 'DOB')
    }), /*#__PURE__*/ _react.default.createElement(DetailsRow, {
        value: (0, _patientAccessors.getSex)(patient),
        label: getTranslation('general.localisedField.sex.label', 'Sex')
    }))))));
};
const QRCodeIDCardPrintout = (0, _languageContext.withLanguageContext)((0, _withDateTimeContext.withDateTimeContext)(QRCodeIDCardPrintoutComponent));

//# sourceMappingURL=QRCodeIDCardPrintout.js.map