"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DesignEditorTabService = void 0;
const tslib_1 = require("tslib");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const react_1 = tslib_1.__importStar(require("react"));
const di_1 = require("@opensumi/di");
const components_1 = require("@opensumi/ide-core-browser/lib/components");
const constants_1 = require("@opensumi/ide-core-browser/lib/layout/constants");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const editor_tab_service_1 = require("@opensumi/ide-editor/lib/browser/editor.tab.service");
const design_module_less_1 = tslib_1.__importDefault(require("../style/design.module.less"));
const EditorTabCloseComponent = (props) => {
    const { children } = props;
    const [display, setDisplay] = react_1.default.useState(false);
    const uid = (0, react_1.useMemo)(() => 'editor-tab-close-' + (0, ide_core_common_1.uuid)(6), []);
    const handleClick = (0, react_1.useCallback)(() => {
        setDisplay(false);
    }, []);
    const title = (0, react_1.useMemo)(() => (0, ide_core_common_1.formatLocalize)('editor.closeTab.title', ide_core_common_1.isMacintosh ? '⌘W' : 'Ctrl+W'), []);
    return (react_1.default.createElement(components_1.Popover, { delay: 1000, position: components_1.PopoverPosition.bottom, id: uid, title: title, onClickAction: handleClick, display: display },
        react_1.default.createElement("span", { title: '' }, children)));
};
let DesignEditorTabService = class DesignEditorTabService extends editor_tab_service_1.EditorTabService {
    renderEditorTab(component, isCurrent) {
        return (react_1.default.createElement("div", { className: (0, classnames_1.default)({
                [design_module_less_1.default['design-editor_tab_block_container']]: true,
                [design_module_less_1.default.active]: isCurrent,
            }), style: {
                height: this.layoutViewSize.editorTabsHeight,
            } }, component));
    }
    renderTabCloseComponent(component) {
        return react_1.default.createElement(EditorTabCloseComponent, null, component);
    }
};
tslib_1.__decorate([
    (0, di_1.Autowired)(constants_1.LayoutViewSizeConfig),
    tslib_1.__metadata("design:type", constants_1.LayoutViewSizeConfig)
], DesignEditorTabService.prototype, "layoutViewSize", void 0);
DesignEditorTabService = tslib_1.__decorate([
    (0, di_1.Injectable)()
], DesignEditorTabService);
exports.DesignEditorTabService = DesignEditorTabService;
//# sourceMappingURL=editor-tab.service.js.map