/**
 * @fileoverview 代码编辑器容器组件
 * 负责代码编辑器的布局、样式和状态管理
 */ import classNames from "clsx";
import React, { useRef } from "react";
export function CodeContainer(param) {
    var element = param.element, showBorder = param.showBorder, hide = param.hide, onEditorClick = param.onEditorClick, children = param.children, theme = param.theme;
    var containerRef = useRef(null);
    // 处理未定义的 element
    var safeElement = element || {
        language: undefined,
        frontmatter: false
    };
    return /*#__PURE__*/ React.createElement("div", {
        contentEditable: false,
        className: "ace-el drag-el",
        "data-be": "code",
        "data-testid": "code-container",
        ref: containerRef,
        tabIndex: -1,
        onBlur: function onBlur(e) {
            return e.stopPropagation();
        },
        onClick: function onClick(e) {
            return e.stopPropagation();
        },
        "data-lang": safeElement.language
    }, /*#__PURE__*/ React.createElement("div", {
        "data-testid": "code-editor-container",
        onClick: function onClick(e) {
            e.stopPropagation();
            onEditorClick();
        },
        style: {
            padding: hide ? 1 : 1,
            marginBottom: hide ? 0 : undefined,
            boxShadow: 'var(--shadow-control-base)',
            borderRadius: 'var(--radius-card-base)',
            backgroundColor: showBorder ? 'rgba(59, 130, 246, 0.1)' : hide ? 'transparent' : theme === 'chaos' ? 'var(--color-gray-text-default)' : 'rgb(252, 252, 252)',
            color: theme === 'chaos' ? '#FFFFFF' : 'var(--color-gray-text-default)',
            height: hide ? 0 : 'auto',
            opacity: hide ? 0 : 1
        },
        "data-frontmatter": safeElement.frontmatter ? '' : undefined,
        className: classNames('ace-container', 'code-editor-container', 'drag-el')
    }, children));
}
