import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback, useContext, useMemo } from 'react';
import cx from 'classnames';
import PanelFooter from '../../components/PanelFooter';
import Button from '../../../button';
import PickerContext from '../../context/PickerContext';
import PanelContext from '../../context/PanelContext';
import { formatDate } from '../../utils/index';
var TimePickerFooter = function (_a) {
    var onSelected = _a.onSelected, selected = _a.selected, format = _a.format;
    var i18n = useContext(PickerContext).i18n;
    var _b = useContext(PanelContext), confirmStatus = _b.confirmStatus, isDisabledCurrent = _b.isDisabledCurrent;
    var onClickCurrent = useCallback(function () {
        if (isDisabledCurrent)
            return;
        onSelected(formatDate(format, new Date()), true);
    }, [format, isDisabledCurrent, onSelected]);
    var renderToday = useMemo(function () {
        var _a;
        return (_jsx("a", __assign({ className: cx((_a = {},
                _a['zent-datepicker-panel-footer-current_disabled'] = isDisabledCurrent,
                _a)), onClick: onClickCurrent, "data-zv": 'v10.0.11' }, { children: i18n.current.time }), void 0));
    }, [i18n, isDisabledCurrent, onClickCurrent]);
    var confirmNode = useMemo(function () { return (_jsx(Button, __assign({ type: "primary", className: "zent-datepicker-panel-footer-btn", disabled: confirmStatus, onClick: function () { return onSelected(selected, true); } }, { children: i18n.confirm }), void 0)); }, [i18n, confirmStatus, selected, onSelected]);
    return _jsx(PanelFooter, { leftNode: renderToday, rightNode: confirmNode }, void 0);
};
export default TimePickerFooter;
