"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 __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
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("@xstyled/styled-components"));
var Frame_1 = __importDefault(require("../Frame"));
var Tip = styled_components_1.default(Frame_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  background: radial-gradient(#ff0 20%, transparent 20%) 0 0,\n    radial-gradient(#ff0 20%, transparent 20%) 4px 4px,\n    radial-gradient(rgba(255, 255, 255, 0.1) 20%, transparent 25%) 0 1px,\n    radial-gradient(rgba(255, 255, 255, 0.1) 20%, transparent 25%) 3px 4px;\n  background-size: 7px 7px;\n  background-color: white;\n  border: 1;\n  padding: 2 2 2 4;\n  box-shadow: none;\n  position: absolute;\n  top: -20px;\n  text-align: center;\n  z-index: taskbar;\n"], ["\n  background: radial-gradient(#ff0 20%, transparent 20%) 0 0,\n    radial-gradient(#ff0 20%, transparent 20%) 4px 4px,\n    radial-gradient(rgba(255, 255, 255, 0.1) 20%, transparent 25%) 0 1px,\n    radial-gradient(rgba(255, 255, 255, 0.1) 20%, transparent 25%) 3px 4px;\n  background-size: 7px 7px;\n  background-color: white;\n  border: 1;\n  padding: 2 2 2 4;\n  box-shadow: none;\n  position: absolute;\n  top: -20px;\n  text-align: center;\n  z-index: taskbar;\n"])));
var Wrapper = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  display: inline-block;\n  position: relative;\n  cursor: default;\n  white-space: nowrap;\n"], ["\n  display: inline-block;\n  position: relative;\n  cursor: default;\n  white-space: nowrap;\n"])));
var TooltipRenderer = function (_a, ref) {
    var children = _a.children, text = _a.text, delay = _a.delay, rest = __rest(_a, ["children", "text", "delay"]);
    var _b = React.useState(false), show = _b[0], setShow = _b[1];
    var _c = React.useState(0), delayTimer = _c[0], setDelayTimer = _c[1];
    var handleEnter = function () {
        var timer = window.setTimeout(function () {
            setShow(true);
        }, delay);
        setDelayTimer(timer);
    };
    var handleLeave = function () {
        clearTimeout(delayTimer);
        setShow(false);
    };
    return (React.createElement(Wrapper, __assign({ onMouseEnter: handleEnter, onMouseLeave: handleLeave }, rest, { ref: ref }),
        show && React.createElement(Tip, null, text),
        children));
};
var Tooltip = React.forwardRef(TooltipRenderer);
function formatDate(date) {
    var monthNames = [
        'January',
        'February',
        'March',
        'April',
        'May',
        'June',
        'July',
        'August',
        'September',
        'October',
        'November',
        'December',
    ];
    var day = date.getDate();
    var monthIndex = date.getMonth();
    var year = date.getFullYear();
    return day.toString().padStart(2, '0') + " " + monthNames[monthIndex] + " " + year;
}
Tooltip.defaultProps = {
    delay: 1000,
    text: formatDate(new Date()),
};
exports.default = Tooltip;
var templateObject_1, templateObject_2;
//# sourceMappingURL=Tooltip.js.map