function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
import classNames from "clsx";
import React, { createElement } from "react";
import { Node } from "slate";
import { debugInfo } from "../../../../Utils/debugUtils";
import { slugify } from "../../utils/dom";
/**
 * ReadonlyHead 组件 - 只读标题预览组件
 *
 * 专门针对 readonly 模式优化的标题组件，移除了拖拽功能，保留标题样式和锚点。
 * 简化渲染逻辑，提升预览模式性能。
 *
 * @component
 * @description 只读标题预览组件，用于预览模式下的标题渲染
 * @param {ElementProps<HeadNode>} props - 组件属性
 * @param {HeadNode} props.element - 标题节点元素
 * @param {React.ReactNode} props.children - 子组件内容
 * @param {Object} props.attributes - 元素属性
 *
 * @example
 * ```tsx
 * <ReadonlyHead
 *   element={headNode}
 *   attributes={attributes}
 * >
 *   标题内容
 * </ReadonlyHead>
 * ```
 *
 * @returns {React.ReactElement} 渲染的只读标题组件
 *
 * @remarks
 * - 移除拖拽手柄（DragHandle）
 * - 移除拖拽相关事件处理
 * - 保留锚点功能（id 属性）
 * - 使用 React.memo 优化性能
 * - 保持预览模式的视觉效果
 */ export var ReadonlyHead = /*#__PURE__*/ React.memo(function(param) {
    var element = param.element, attributes = param.attributes, children = param.children;
    var _Node_string;
    debugInfo('ReadonlyHead - 渲染只读标题', {
        level: element.level,
        text: (_Node_string = Node.string(element)) === null || _Node_string === void 0 ? void 0 : _Node_string.substring(0, 50),
        align: element.align
    });
    var str = Node.string(element);
    var _obj;
    return /*#__PURE__*/ createElement("h".concat(element.level), _object_spread_props(_object_spread({}, attributes), (_obj = {
        id: slugify(str)
    }, _define_property(_obj, 'data-be', 'head'), _define_property(_obj, 'data-head', slugify(Node.string(element) || '')), _define_property(_obj, 'data-title', true), _define_property(_obj, 'data-align', element.align), _define_property(_obj, "style", {
        textAlign: element.align
    }), _define_property(_obj, "className", classNames({
        empty: !str
    })), _obj)), children);
});
ReadonlyHead.displayName = 'ReadonlyHead';
