"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Bullet;
const tslib_1 = require("tslib");
const list_1 = require("@lexical/list");
const lexical_1 = require("lexical");
const react_1 = tslib_1.__importDefault(require("react"));
const types_1 = require("../../../../types");
const heading_1 = require("./heading");
function Bullet({ editor, isActive }) {
    return (react_1.default.createElement("div", { className: 'flex items-center gap-x-2' },
        react_1.default.createElement("button", { type: 'button', "data-color-button": 'true', className: (0, types_1.classNames)('p-1 rounded-md duration-200 cursor-pointer', isActive ? 'bg-gray-200' : 'hover:bg-gray-200'), onClick: () => {
                if (!isActive) {
                    const preservedHeading = (0, heading_1.preserveHeadingFontSizeForList)(editor);
                    editor.dispatchCommand(list_1.INSERT_UNORDERED_LIST_COMMAND, undefined);
                    if (preservedHeading !== null) {
                        queueMicrotask(() => {
                            editor.update(() => {
                                (0, heading_1.applyListItemFontSize)(preservedHeading.fontSize, preservedHeading.headingTag);
                            });
                        });
                    }
                }
                else {
                    const headingTag = (0, heading_1.getSelectedListHeadingTag)(editor);
                    const elementFormat = (0, heading_1.getSelectedListElementFormat)(editor);
                    editor.dispatchCommand(list_1.REMOVE_LIST_COMMAND, undefined);
                    if (headingTag !== null || elementFormat !== null) {
                        queueMicrotask(() => {
                            if (elementFormat !== null) {
                                editor.dispatchCommand(lexical_1.FORMAT_ELEMENT_COMMAND, elementFormat);
                            }
                            editor.update(() => {
                                if (headingTag !== null) {
                                    (0, heading_1.applyHeadingTypeToSelection)(headingTag);
                                }
                            });
                        });
                    }
                }
            } },
            react_1.default.createElement("span", null,
                react_1.default.createElement("svg", { width: '20', height: '20', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
                    react_1.default.createElement("path", { d: 'M4 6C4.55228 6 5 5.55228 5 5C5 4.44772 4.55228 4 4 4C3.44772 4 3 4.44772 3 5C3 5.55228 3.44772 6 4 6Z', fill: '#4A4A4A' }),
                    react_1.default.createElement("path", { d: 'M4 11C4.55228 11 5 10.5523 5 10C5 9.44772 4.55228 9 4 9C3.44772 9 3 9.44772 3 10C3 10.5523 3.44772 11 4 11Z', fill: '#4A4A4A' }),
                    react_1.default.createElement("path", { d: 'M5 15C5 15.5523 4.55228 16 4 16C3.44772 16 3 15.5523 3 15C3 14.4477 3.44772 14 4 14C4.55228 14 5 14.4477 5 15Z', fill: '#4A4A4A' }),
                    react_1.default.createElement("path", { d: 'M7.25 4.25C6.83579 4.25 6.5 4.58579 6.5 5C6.5 5.41421 6.83579 5.75 7.25 5.75H16.25C16.6642 5.75 17 5.41421 17 5C17 4.58579 16.6642 4.25 16.25 4.25H7.25Z', fill: '#4A4A4A' }),
                    react_1.default.createElement("path", { d: 'M6.5 10C6.5 9.58579 6.83579 9.25 7.25 9.25H16.25C16.6642 9.25 17 9.58579 17 10C17 10.4142 16.6642 10.75 16.25 10.75H7.25C6.83579 10.75 6.5 10.4142 6.5 10Z', fill: '#4A4A4A' }),
                    react_1.default.createElement("path", { d: 'M7.25 14.25C6.83579 14.25 6.5 14.5858 6.5 15C6.5 15.4142 6.83579 15.75 7.25 15.75H16.25C16.6642 15.75 17 15.4142 17 15C17 14.5858 16.6642 14.25 16.25 14.25H7.25Z', fill: '#4A4A4A' }))))));
}
//# sourceMappingURL=bullet.js.map