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 { MOBILE_BREAKPOINT, MOBILE_PADDING } from "../../../../Constants/mobile";
import { resetComponent, useEditorStyleRegister } from "../../../../Hooks/useStyle";
var genStyle = function(token) {
    var _obj;
    return _define_property({}, token.componentCls, {
        width: '100%',
        overflow: 'auto',
        flex: 1,
        minWidth: 0,
        position: 'relative',
        '--table-border-radius': '8px',
        '--table-border-color': '#E7E9E8',
        '--table-header-bg': '#f7f7f9',
        '--table-odd-row-bg': 'rgba(35,35,38,.04)',
        '--table-hover-bg': 'rgba(0, 0, 0, 0.04)',
        '--table-cell-min-width': '120px',
        '&-container': _define_property({
            display: 'flex',
            gap: 1,
            maxWidth: '100%',
            minWidth: 0,
            outline: 'none',
            position: 'relative',
            marginBottom: 12
        }, "&:hover ".concat(token.componentCls, "-readonly-table-actions"), {
            opacity: 1,
            transform: 'translateX(50%)',
            top: -24
        }),
        '&-editor-table': {
            marginTop: '1em'
        },
        '&-readonly-table-actions': {
            opacity: 0,
            position: 'absolute',
            top: 20,
            display: 'flex',
            gap: 8,
            right: '50%',
            zIndex: 1000,
            backgroundColor: 'var(--color-gray-bg-page-light)',
            borderRadius: 'var(--radius-control-base)',
            padding: '4px 8px',
            boxShadow: 'var(--shadow-control-base)',
            border: 'none',
            transform: 'translateX(50%)',
            transition: 'all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1)'
        },
        table: (_obj = {
            borderCollapse: 'separate',
            borderSpacing: 0,
            width: '100%',
            tableLayout: 'fixed',
            margin: '16px 0',
            position: 'relative',
            fontVariant: 'tabular-nums',
            borderRadius: 'var(--table-border-radius)',
            border: '1px solid var(--table-border-color)'
        }, _define_property(_obj, "&".concat(token.componentCls, "-readonly-pure"), {
            border: 'none',
            borderRadius: 'none',
            'tr:not(.config-tr) td:not(.config-td)': {
                borderLeft: 'none'
            },
            'tr:not(.config-tr):last-child td:not(.config-td)': {
                borderBottom: '1px solid var(--table-border-color)'
            },
            'tr:not(.config-tr):first-child th:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:first-child:not(.config-td):not([colspan]):not([rowspan])': {
                borderTopLeftRadius: 'unset'
            },
            'tr:not(.config-tr):first-child th:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:last-child:not(.config-td):not([colspan]):not([rowspan])': {
                borderTopRightRadius: 'unset'
            },
            'tr:not(.config-tr):last-child td:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:first-child:not(.config-td):not([colspan]):not([rowspan])': {
                borderBottomLeftRadius: 'unset'
            },
            'tr:not(.config-tr):last-child td:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:last-child:not(.config-td):not([colspan]):not([rowspan])': {
                borderBottomRightRadius: 'unset'
            }
        }), _define_property(_obj, 'th.config-th,td.config-td', {
            borderBottom: '1px solid var(--table-border-color)',
            borderLeft: '1px solid var(--table-border-color)'
        }), _define_property(_obj, 'tr td.config-td:first-child', {
            borderLeft: 'none'
        }), _define_property(_obj, 'th:not(.config-td)', {
            backgroundColor: 'var(--table-header-bg)',
            borderBottom: '1px solid var(--table-border-color)',
            textWrap: 'nowrap',
            verticalAlign: 'top',
            padding: '16px 12px',
            textAlign: 'left',
            lineHeight: '24px',
            fontSize: '1em',
            fontWeight: 600,
            borderTop: 'none',
            minWidth: 'var(--table-cell-min-width)',
            width: 'var(--table-cell-min-width)',
            whiteSpace: 'nowrap',
            overflow: 'hidden',
            textOverflow: 'ellipsis',
            zIndex: 1,
            background: 'inherit'
        }), _define_property(_obj, 'td:not(.config-td)', {
            verticalAlign: 'top',
            padding: '16px 12px',
            textAlign: 'left',
            position: 'relative',
            lineHeight: '24px',
            fontSize: '1em',
            minWidth: 'var(--table-cell-min-width)',
            width: 'var(--table-cell-min-width)',
            whiteSpace: 'nowrap',
            overflow: 'hidden',
            textOverflow: 'ellipsis',
            zIndex: 1,
            background: 'inherit',
            'div[data-be="paragraph"]': {
                margin: 0,
                textWrap: 'auto'
            }
        }), _define_property(_obj, 'tr:not(.config-tr)', {
            background: 'inherit',
            '&:first-child td:not(.config-td)': {
                borderTop: 'none'
            },
            'td:not(.config-td)': {
                borderBottom: '1px solid var(--table-border-color)',
                borderLeft: '1px solid var(--table-border-color)',
                '&:first-child': {
                    fontSize: '1em',
                    lineHeight: '24px',
                    fontWeight: 600
                }
            },
            'td:first-child:not(.config-td)': {
                borderLeft: 'none'
            },
            '&:last-child td:not(.config-td)': {
                borderBottom: 'none'
            }
        }), _define_property(_obj, 'tbody tr:not(.config-tr):hover', {
            background: 'linear-gradient(var(--table-hover-bg), var(--table-hover-bg)), linear-gradient(white, white)'
        }), // 表格圆角处理 - 重新设计逻辑
        // 1. 先为所有单元格重置圆角
        _define_property(_obj, 'th:not(.config-td), td:not(.config-td)', {
            borderRadius: '0'
        }), // 2. 为表格四个角的单元格设置圆角（仅当它们不是合并单元格时）
        _define_property(_obj, 'tr:not(.config-tr):first-child th:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:first-child:not(.config-td):not([colspan]):not([rowspan])', {
            borderTopLeftRadius: 'var(--table-border-radius)'
        }), _define_property(_obj, 'tr:not(.config-tr):first-child th:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):first-child td:last-child:not(.config-td):not([colspan]):not([rowspan])', {
            borderTopRightRadius: 'var(--table-border-radius)'
        }), _define_property(_obj, 'tr:not(.config-tr):last-child td:first-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:first-child:not(.config-td):not([colspan]):not([rowspan])', {
            borderBottomLeftRadius: 'var(--table-border-radius)'
        }), _define_property(_obj, 'tr:not(.config-tr):last-child td:last-child:not(.config-td):not([colspan]):not([rowspan]), tr:not(.config-tr):last-child th:last-child:not(.config-td):not([colspan]):not([rowspan])', {
            borderBottomRightRadius: 'var(--table-border-radius)'
        }), // 3. 处理合并单元格的圆角
        // 左上角 - 第一行第一列的合并单元格
        _define_property(_obj, 'tr:not(.config-tr):first-child th:not(.config-td)[colspan]:first-child, tr:not(.config-tr):first-child td:not(.config-td)[colspan]:first-child,tr:not(.config-tr):first-child th:not(.config-td)[rowspan]:first-child, tr:not(.config-tr):first-child td:not(.config-td)[rowspan]:first-child', {
            borderTopLeftRadius: 'var(--table-border-radius)'
        }), // 右上角 - 第一行最后一列的合并单元格
        _define_property(_obj, 'tr:not(.config-tr):first-child th:not(.config-td)[colspan]:last-child, tr:not(.config-tr):first-child td:not(.config-td)[colspan]:last-child,tr:not(.config-tr):first-child th:not(.config-td)[rowspan]:last-child, tr:not(.config-tr):first-child td:not(.config-td)[rowspan]:last-child', {
            borderTopRightRadius: 'var(--table-border-radius)'
        }), // 左下角 - 最后一行第一列的合并单元格
        _define_property(_obj, 'tr:not(.config-tr):last-child td:not(.config-td)[colspan]:first-child, tr:not(.config-tr):last-child th:not(.config-td)[colspan]:first-child,tr:not(.config-tr):last-child td:not(.config-td)[rowspan]:first-child, tr:not(.config-tr):last-child th:not(.config-td)[rowspan]:first-child', {
            borderBottomLeftRadius: 'var(--table-border-radius)'
        }), // 右下角 - 最后一行最后一列的合并单元格
        _define_property(_obj, 'tr:not(.config-tr):last-child td:not(.config-td)[colspan]:last-child, tr:not(.config-tr):last-child th:not(.config-td)[colspan]:last-child,tr:not(.config-tr):last-child td:not(.config-td)[rowspan]:last-child, tr:not(.config-tr):last-child th:not(.config-td)[rowspan]:last-child', {
            borderBottomRightRadius: 'var(--table-border-radius)'
        }), // 4. 特殊处理：如果合并单元格跨越整个表格宽度
        _define_property(_obj, 'tr:not(.config-tr):first-child:last-child th:not(.config-td)[colspan]:first-child:last-child, tr:not(.config-tr):first-child:last-child td:not(.config-td)[colspan]:first-child:last-child', {
            borderRadius: 'var(--table-border-radius)'
        }), // 5. 特殊处理：如果合并单元格跨越整个表格高度
        _define_property(_obj, 'th:not(.config-td)[rowspan]:first-child:last-child, td:not(.config-td)[rowspan]:first-child:last-child', {
            borderTopLeftRadius: 'var(--table-border-radius)',
            borderBottomLeftRadius: 'var(--table-border-radius)'
        }), _define_property(_obj, "@media (max-width: ".concat(MOBILE_BREAKPOINT, ")"), {
            'th:not(.config-td), td:not(.config-td)': {
                padding: "".concat(MOBILE_PADDING)
            }
        }), _obj),
        'table.htCore': {
            boxSizing: 'content-box',
            '*': {
                boxSizing: 'content-box'
            }
        }
    });
};
/**
 * BubbleChat
 * @param prefixCls
 * @returns
 */ export function useTableStyle(prefixCls, propsToken) {
    return useEditorStyleRegister('md-editor-table', function(token) {
        var editorToken = _object_spread_props(_object_spread({}, token, propsToken), {
            componentCls: ".".concat(prefixCls)
        });
        return [
            resetComponent(editorToken),
            genStyle(editorToken)
        ];
    });
}
