"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
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 __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var styled_components_1 = __importDefault(require("styled-components"));
var utils_1 = require("@joincivil/utils");
var styleConstants_1 = require("../styleConstants");
var icons_1 = require("../icons");
var StyledCountdownTimerContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  display: flex;\n  font: normal 14px/17px ", ";\n  margin: 0 0 16px;\n"], ["\n  display: flex;\n  font: normal 14px/17px ", ";\n  margin: 0 0 16px;\n"])), styleConstants_1.fonts.SANS_SERIF);
exports.StyledDurationContainer = styled_components_1.default.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  color: ", ";\n"], ["\n  color: ", ";\n"])), styleConstants_1.colors.accent.CIVIL_BLUE);
var StyledIconContainer = styled_components_1.default.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n  margin-right: 12px;\n"], ["\n  margin-right: 12px;\n"])));
exports.StyledCountdownLabel = styled_components_1.default.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n  color: ", ";\n"], ["\n  color: ", ";\n"])), styleConstants_1.colors.accent.CIVIL_BLUE);
exports.StyledCountdownLabelWarn = styled_components_1.default(exports.StyledCountdownLabel)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n  color: ", ";\n"], ["\n  color: ", ";\n"])), styleConstants_1.colors.accent.CIVIL_RED);
var StyledExpiry = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n  font-size: 14px;\n  line-height: 17px;\n  margin: 2px 0 0;\n"], ["\n  font-size: 14px;\n  line-height: 17px;\n  margin: 2px 0 0;\n"])));
var TextCountdownTimerComponent = /** @class */ (function (_super) {
    __extends(TextCountdownTimerComponent, _super);
    function TextCountdownTimerComponent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.renderExpiry = function () {
            var _a = utils_1.getLocalDateTimeStrings(_this.props.endTime), expiryDateString = _a[0], expiryTimeString = _a[1];
            return (React.createElement(StyledExpiry, null,
                expiryDateString,
                " at ",
                expiryTimeString));
        };
        _this.renderReadableTimeRemaining = function () {
            if (_this.props.warn) {
                return (React.createElement(exports.StyledCountdownLabelWarn, null,
                    React.createElement("b", null, utils_1.getReadableDuration(_this.props.secondsRemaining, ["second"]))));
            }
            return React.createElement("b", null, utils_1.getReadableDuration(_this.props.secondsRemaining, ["second"]));
        };
        return _this;
    }
    TextCountdownTimerComponent.prototype.render = function () {
        var labelText = this.props.secondsRemaining > 0 ? "Ends in " : "Ended";
        var label;
        if (this.props.warn) {
            label = React.createElement(exports.StyledCountdownLabelWarn, null, labelText);
        }
        else {
            label = React.createElement(exports.StyledCountdownLabel, null, labelText);
        }
        return (React.createElement(StyledCountdownTimerContainer, null,
            React.createElement(StyledIconContainer, null,
                React.createElement(icons_1.ClockIcon, null)),
            React.createElement("div", null,
                React.createElement(exports.StyledDurationContainer, null,
                    label,
                    " ",
                    this.renderReadableTimeRemaining()),
                this.renderExpiry())));
    };
    return TextCountdownTimerComponent;
}(React.Component));
exports.TextCountdownTimerComponent = TextCountdownTimerComponent;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
//# sourceMappingURL=TextCountdownTimer.js.map