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 { createStyleRegister } from "@ant-design/theme-token";
import { ConfigProvider as AntdConfigProvider, theme as antdTheme } from "antd";
import { useContext } from "react";
export var resetComponent = function resetComponent(token) {
    return _define_property({}, "".concat(token.componentCls), {
        boxSizing: 'border-box',
        margin: 0,
        padding: 0,
        color: token.colorText,
        fontSize: '1em',
        lineHeight: token.lineHeight,
        listStyle: 'none',
        'svg.sofa-icons-icon > g': {
            clipPath: 'none!important'
        }
    });
};
/**
 * 封装了一下 antd 的 useStyle，支持了一下antd@4
 * @param componentName {string} 组件的名字
 * @param styleFn {GenerateStyle} 生成样式的函数
 * @returns UseStyleResult
 */ export function useEditorStyleRegister(componentName, styleFn) {
    var _antdTheme_useToken;
    var _ref = (antdTheme === null || antdTheme === void 0 ? void 0 : (_antdTheme_useToken = antdTheme.useToken) === null || _antdTheme_useToken === void 0 ? void 0 : _antdTheme_useToken.call(antdTheme)) || {}, token = _ref.token, theme = _ref.theme;
    var chatToken = _object_spread_props(_object_spread({}, token), {
        chatCls: '',
        antCls: ''
    });
    var getPrefixCls = useContext(AntdConfigProvider.ConfigContext).getPrefixCls;
    chatToken.chatCls = ".".concat(getPrefixCls('agentic-ui'));
    chatToken.antCls = ".".concat(getPrefixCls());
    // 组件库默认关闭 hashId，避免与宿主页面的 antd hashId 叠加导致选择器不生效；传入 '' 后 createStyleRegister 与返回的 hashId 均为空
    var genStyles = createStyleRegister({
        hashId: '',
        token: chatToken,
        theme: theme,
        cssVariables: {}
    });
    var result = genStyles(componentName, styleFn);
    // 确保总是返回一个有效的对象，且 hashId 保持关闭
    return result ? _object_spread_props(_object_spread({}, result), {
        hashId: ''
    }) : {
        wrapSSR: function wrapSSR(node) {
            return node;
        },
        hashId: ''
    };
}
