"use strict";
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 __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 jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = __importDefault(require("react"));
var schema_1 = require("@qaing/schema");
var Button_1 = require("../../../components/Button");
var Container_1 = require("../../../components/Container");
var Icon_1 = require("../../../components/Icon");
var Input_1 = require("../../../components/Input");
var Text_1 = __importDefault(require("../../../components/Text"));
var styles_1 = require("../../../utils/styles");
exports.default = react_1.default.forwardRef(function (_a, ref) {
    var _b;
    var value = _a.value, onClose = _a.onClose, onClickDelete = _a.onClickDelete, onUpdate = _a.onUpdate, props = __rest(_a, ["value", "onClose", "onClickDelete", "onUpdate"]);
    var inputRef = react_1.default.useRef(null);
    var _c = react_1.default.useState(((_b = value === null || value === void 0 ? void 0 : value.text) === null || _b === void 0 ? void 0 : _b.toString()) || ''), name = _c[0], setName = _c[1];
    var onEnter = react_1.default.useCallback(function () {
        var result = schema_1.schemas.workspace.issueTag.name.safeParse(name);
        if (!result.success)
            return;
        onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({ name: name });
    }, [name]);
    react_1.default.useEffect(function () {
        var _a;
        setName(((_a = value === null || value === void 0 ? void 0 : value.text) === null || _a === void 0 ? void 0 : _a.toString()) || '');
    }, [value]);
    react_1.default.useEffect(function () {
        if (!inputRef.current)
            return;
        inputRef.current.focus();
    }, []);
    return ((0, jsx_runtime_1.jsxs)(Container_1.Container, __assign({ ref: ref, "$position": "absolute", "$right": "-110px", "$width": "228px", "$padding": "12px 16px", "$borderRadius": "16px", "$background": styles_1.theme.color.extra.white, "$zIndex": styles_1.theme.zIndex.dropdown, "$display": "flex", "$flexDirection": "column", "$gap": "8px", "$overflow": "auto", "$css": styles_1.theme.effect.dropdown }, props, { children: [(0, jsx_runtime_1.jsx)(Input_1.TextInput, { ref: inputRef, size: "small", schema: schema_1.schemas.workspace.issueTag.name, disabledMessageText: "\uCD5C\uB300 20\uC790\uAE4C\uC9C0 \uC785\uB825 \uAC00\uB2A5\uD569\uB2C8\uB2E4", value: name, onChangeValue: setName, onEnter: onEnter }), (0, jsx_runtime_1.jsx)(Container_1.Container, { "$display": "flex", "$gap": "20px 28px", "$paddingBottom": "24px", "$borderBottom": "1px solid ".concat(styles_1.theme.color.gray[300]), "$flexWrap": true, children: Object.entries(styles_1.theme.color.tag).map(function (_a) {
                    var colorType = _a[0], color = _a[1];
                    return ((0, jsx_runtime_1.jsx)(Container_1.ClickContainer, { onClick: function () {
                            return onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate({
                                colorType: colorType,
                            });
                        }, "$size": "28px", "$background": color.chip, "$borderRadius": "4px", "$display": "flex", "$alignItems": "center", "$justifyContent": "center", "$cursor": true, children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { type: "check", "$fill": styles_1.theme.color.extra.white, "$size": "24px", "$opacity": value.colorType === colorType ? 1 : 0, "$transition": "opacity" }) }, colorType));
                }) }), (0, jsx_runtime_1.jsx)(Container_1.Container, { "$height": "52px", "$display": "flex", "$alignItems": "center", children: value.isDefault ? ((0, jsx_runtime_1.jsx)(Text_1.default, { type: "b4", value: "\uAE30\uBCF8\uAC12\uC740 \uC0AD\uC81C \uBD88\uAC00", "$color": styles_1.theme.color.gray[700] })) : ((0, jsx_runtime_1.jsx)(Button_1.TextButton, { type: "danger", icon: "delete", text: "\uC0AD\uC81C\uD558\uAE30", onClick: onClickDelete })) })] })));
});
//# sourceMappingURL=ButtonDropdown.js.map