"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailButton = void 0;
const react_1 = __importStar(require("react"));
const server_1 = __importDefault(require("react-dom/server"));
function convertPropsToStyles(props) {
    const color = props.color || '#FFFFFF';
    const height = 42;
    return {
        fontSize: props.fontSize || 16,
        textDecoration: 'none !important',
        fontWeight: props.fontWeight || 'normal',
        fontFamily: props.fontFamily,
        lineHeight: `${height}px`,
        textAlign: 'center',
        display: 'inline-block',
        borderRadius: props.borderRadius || 5,
        color,
        backgroundColor: props.background || '#ED2939',
        width: `${props.width}px`,
        textSizeAdjust: 'none',
        letterSpacing: 0,
    };
}
class Button extends react_1.Component {
    render() {
        const buttonStyles = convertPropsToStyles(this.props);
        return (react_1.default.createElement("a", { href: this.props.href, className: "font", style: buttonStyles }, this.props.children));
    }
}
class EmailButton extends react_1.Component {
    render() {
        const buttonStyles = convertPropsToStyles(this.props);
        const button = react_1.default.createElement(Button, Object.assign({}, this.props));
        return (react_1.default.createElement("div", { dangerouslySetInnerHTML: {
                __html: `
            <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${this.props.href}" style="height:${buttonStyles.lineHeight};v-text-anchor:middle;width:${buttonStyles.width};" arcsize="10%" stroke="f" fillcolor="${buttonStyles.backgroundColor}">
              <w:anchorlock/>
              <center>
                ${server_1.default.renderToString(button)}
              </center>
            </v:roundrect>
          `,
            } }));
    }
}
exports.EmailButton = EmailButton;
