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 { Flex } from "antd";
import cx from "classnames";
import React from "react";
import { resetComponent, useEditorStyleRegister } from "../Hooks/useStyle";
import { formatTime } from "../Utils/formatTime";
var TITLE_GAP = 8;
var getFlexDirection = function(placement) {
    return placement === 'left' ? 'row' : 'row-reverse';
};
var genStyle = function(token) {
    return _define_property({}, token.componentCls, {
        font: 'var(--font-text-h6-base)',
        letterSpacing: [
            'var(--letter-spacing-h6-base, normal)',
            'normal'
        ],
        textAlign: 'justify',
        color: 'var(--color-gray-text-default)',
        '&-time': {
            visibility: 'hidden',
            font: 'var(--font-text-body-sm)',
            letterSpacing: 'var(--letter-spacing-body-sm, normal)',
            color: 'var(--color-gray-text-light)'
        },
        '&:hover': _define_property({}, "".concat(token.componentCls, "-time"), {
            visibility: 'visible'
        })
    });
};
var useStyle = function(prefixCls) {
    return useEditorStyleRegister('Title', function(token) {
        var titleToken = _object_spread_props(_object_spread({}, token), {
            componentCls: ".".concat(prefixCls)
        });
        return [
            resetComponent(titleToken),
            genStyle(titleToken)
        ];
    });
};
/**
 * BubbleTitle 组件
 *
 * 显示聊天气泡的标题和时间，支持左右布局
 *
 * @example
 * ```tsx
 * <BubbleTitle
 *   title="AI助手"
 *   time={new Date()}
 *   placement="left"
 * />
 * ```
 */ export var BubbleTitle = function(param) {
    var style = param.style, prefixClass = param.prefixClass, className = param.className, placement = param.placement, time = param.time, bubbleNameClassName = param.bubbleNameClassName, quote = param.quote, title = param.title;
    var _useStyle = useStyle(prefixClass), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    var flexStyle = _object_spread({
        flexDirection: getFlexDirection(placement),
        display: 'flex',
        alignItems: 'center'
    }, style);
    return wrapSSR(/*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Flex, {
        className: cx(hashId, prefixClass, className),
        style: flexStyle,
        gap: TITLE_GAP,
        "data-testid": "bubble-title"
    }, title && /*#__PURE__*/ React.createElement("span", {
        className: bubbleNameClassName
    }, title), time && /*#__PURE__*/ React.createElement("time", {
        className: cx("".concat(prefixClass, "-time"), hashId),
        "data-testid": "bubble-time"
    }, formatTime(time))), quote));
};
