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;
}
import { ConfigProvider } from "antd";
import classNames from "clsx";
import Lottie from "lottie-react";
import React, { useContext, useEffect, useRef } from "react";
import { useStyle } from "./style";
/**
 * Lottie 动画基础组件
 *
 * 提供 Lottie 动画渲染的基础功能，支持自定义尺寸、样式和播放行为。
 * 该组件作为其他具体操作动画组件的抽象基类使用。
 *
 * @component
 * @example
 * // 基础用法
 * <AbstractLottie animationData={animationData} />
 *
 * @example
 * // 自定义尺寸
 * <AbstractLottie animationData={animationData} size={64} />
 *
 * @example
 * // 自定义样式
 * <AbstractLottie
 *   animationData={animationData}
 *   size={80}
 *   style={{ margin: '20px' }}
 *   className="custom-lottie"
 * />
 *
 * @example
 * // 控制播放行为
 * <AbstractLottie
 *   animationData={animationData}
 *   active={true}
 *   autoplay={true}
 *   loop={true}
 * />
 *
 * @param props - 组件属性
 * @param props.animationData - Lottie 动画数据对象
 * @param props.active - 是否激活动画，默认为 false
 * @param props.autoplay - 是否自动播放动画，默认为 false
 * @param props.loop - 是否循环播放动画，默认为 false
 * @param props.className - 动画容器类名
 * @param props.style - 动画容器自定义样式
 * @param props.size - 动画尺寸（宽度和高度），默认为 '1em'
 * @returns 渲染的 Lottie 动画组件
 */ export var AbstractLottie = function AbstractLottie(param) {
    var animationData = param.animationData, _param_active = param.active, active = _param_active === void 0 ? false : _param_active, _param_autoplay = param.autoplay, autoplay = _param_autoplay === void 0 ? false : _param_autoplay, _param_loop = param.loop, loop = _param_loop === void 0 ? false : _param_loop, className = param.className, style = param.style, _param_size = param.size, size = _param_size === void 0 ? '1em' : _param_size;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var prefixCls = getPrefixCls('bubble-actions-lottie');
    var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    var lottieRef = useRef(null);
    var containerStyle = _object_spread({
        width: size,
        height: size,
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center'
    }, style);
    useEffect(function() {
        if (active) {
            var _lottieRef_current;
            (_lottieRef_current = lottieRef.current) === null || _lottieRef_current === void 0 ? void 0 : _lottieRef_current.play();
        } else {
            var _lottieRef_current1;
            (_lottieRef_current1 = lottieRef.current) === null || _lottieRef_current1 === void 0 ? void 0 : _lottieRef_current1.stop();
        }
    }, [
        active
    ]);
    return wrapSSR(/*#__PURE__*/ React.createElement(Lottie, {
        style: containerStyle,
        lottieRef: lottieRef,
        className: classNames(prefixCls, hashId, className),
        "data-testid": "lottie-animation",
        "aria-hidden": "true",
        animationData: animationData,
        loop: loop,
        autoplay: autoplay
    }));
};
export default AbstractLottie;
