"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 });
const prop_types_1 = __importDefault(require("prop-types"));
const react_1 = __importStar(require("react"));
const react_native_1 = require("react-native");
const dayjs_1 = __importDefault(require("dayjs"));
const Color_1 = __importDefault(require("./Color"));
const Constant_1 = require("./Constant");
const utils_1 = require("./utils");
const containerStyle = {
    marginLeft: 10,
    marginRight: 10,
    marginBottom: 5,
};
const textStyle = {
    fontSize: 10,
    backgroundColor: 'transparent',
    textAlign: 'right',
};
const styles = {
    left: react_native_1.StyleSheet.create({
        container: Object.assign({}, containerStyle),
        text: Object.assign({ color: Color_1.default.timeTextColor }, textStyle),
    }),
    right: react_native_1.StyleSheet.create({
        container: Object.assign({}, containerStyle),
        text: Object.assign({ color: Color_1.default.white }, textStyle),
    }),
};
class Time extends react_1.Component {
    render() {
        const { position, containerStyle, currentMessage, timeFormat, timeTextStyle, } = this.props;
        if (currentMessage) {
            return (react_1.default.createElement(react_native_1.View, { style: [
                    styles[position].container,
                    containerStyle && containerStyle[position],
                ] },
                react_1.default.createElement(react_native_1.Text, { style: [
                        styles[position].text,
                        timeTextStyle && timeTextStyle[position],
                    ] }, dayjs_1.default(currentMessage.createdAt)
                    .locale(this.context.getLocale())
                    .format(timeFormat))));
        }
        return null;
    }
}
exports.default = Time;
Time.contextTypes = {
    getLocale: prop_types_1.default.func,
};
Time.defaultProps = {
    position: 'left',
    currentMessage: {
        createdAt: null,
    },
    containerStyle: {},
    timeFormat: Constant_1.TIME_FORMAT,
    timeTextStyle: {},
};
Time.propTypes = {
    position: prop_types_1.default.oneOf(['left', 'right']),
    currentMessage: prop_types_1.default.object,
    containerStyle: prop_types_1.default.shape({
        left: utils_1.StylePropType,
        right: utils_1.StylePropType,
    }),
    timeFormat: prop_types_1.default.string,
    timeTextStyle: prop_types_1.default.shape({
        left: utils_1.StylePropType,
        right: utils_1.StylePropType,
    }),
};
//# sourceMappingURL=Time.js.map