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 Lottie from "lottie-react";
import React, { useMemo } from "react";
import { useAsyncLottieData } from "../useAsyncLottieData";
/**
 * ThreeThinkingLottie 组件 - 支持按需加载的思考动画组件
 *
 * 该组件使用动态 import 实现 lottie JSON 文件的按需加载，
 * 避免将动画数据打包进主包，减少首屏加载体积。
 *
 * @component
 * @description 支持按需加载的 Lottie 思考动画组件
 * @param {ThreeThinkingLottieProps} props - 组件属性
 * @param {boolean} [props.autoplay=true] - 是否自动播放动画
 * @param {boolean} [props.loop=true] - 是否循环播放动画
 * @param {string} [props.className] - 动画容器类名
 * @param {React.CSSProperties} [props.style] - 动画容器样式
 * @param {number} [props.size=32] - 动画尺寸
 * @param {React.ReactNode} [props.fallback] - 加载占位符
 *
 * @example
 * ```tsx
 * // 基础用法
 * <ThreeThinkingLottie />
 *
 * // 自定义尺寸
 * <ThreeThinkingLottie size={48} />
 *
 * // 自定义加载占位符
 * <ThreeThinkingLottie fallback={<Spin />} />
 * ```
 *
 * @returns {React.ReactElement} 渲染的 Lottie 思考动画组件
 *
 * @remarks
 * - 使用动态 import 按需加载 lottie JSON 文件
 * - 减少首屏加载体积
 * - 支持自定义加载占位符
 * - 支持自定义尺寸和样式
 */ export var ThreeThinkingLottie = function ThreeThinkingLottie(param) {
    var _param_autoplay = param.autoplay, autoplay = _param_autoplay === void 0 ? true : _param_autoplay, _param_loop = param.loop, loop = _param_loop === void 0 ? true : _param_loop, className = param.className, style = param.style, _param_size = param.size, size = _param_size === void 0 ? 32 : _param_size, fallback = param.fallback;
    var loadJson = useMemo(function() {
        return function() {
            return import("./three-thinking.json");
        };
    }, []);
    var animationData = useAsyncLottieData(loadJson);
    var containerStyle = _object_spread({
        width: size,
        height: size,
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center'
    }, style);
    // 默认占位符
    var defaultFallback = /*#__PURE__*/ React.createElement("div", {
        style: containerStyle,
        className: className
    }, /*#__PURE__*/ React.createElement("span", {
        style: {
            opacity: 0.3
        }
    }, "..."));
    if (!animationData) {
        return fallback !== undefined ? /*#__PURE__*/ React.createElement(React.Fragment, null, fallback) : defaultFallback;
    }
    return /*#__PURE__*/ React.createElement(Lottie, {
        style: containerStyle,
        className: className,
        "aria-hidden": "true",
        animationData: animationData,
        loop: loop,
        autoplay: autoplay
    });
};
export default ThreeThinkingLottie;
