function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
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 _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
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;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { ConfigProvider, Tooltip } from "antd";
import classNames from "clsx";
import React, { memo, useContext, useMemo, useState } from "react";
import { AIGraphic } from "./AIGraphic";
import { AIGraphicDisabled } from "./AIGraphicDisabled";
import { prefixCls, useStyle } from "./style";
/**
 * AI Label 组件 - AI 标签标识组件
 *
 * 该组件用于明确标识 AI 生成内容，在非 AI 对话界面中，通过视觉标记、水印或标签，
 * 清晰区分人工创建与 AI 生成的内容，增强透明度并帮助用户识别内容来源，确保合规性。
 *
 * @component
 * @description AI 标签标识组件，用于标识 AI 生成的内容
 * @param {AILabelProps} props - 组件属性
 * @param {AILabelStatus} [props.status='default'] - 标签状态，控制标签的视觉样式
 * @param {[number, number]} [props.offset] - 标签偏移量，格式为 [水平偏移, 垂直偏移]
 * @param {TooltipProps} [props.tooltip] - 提示框配置，鼠标悬停时显示提示信息
 * @param {string} [props.className] - 自定义根元素的 CSS 类名
 * @param {React.CSSProperties} [props.style] - 自定义标签点的样式
 * @param {React.CSSProperties} [props.rootStyle] - 自定义根容器元素的样式
 * @param {React.ReactNode} [props.children] - 子元素，当存在时标签会显示在子元素右上角
 *
 * @example
 * ```tsx
 * // 基础用法 - 水印状态
 * <AILabel status="watermark" offset={[0, -8]} />
 *
 * // 强调状态带提示
 * <AILabel
 *   status="emphasis"
 *   offset={[0, -8]}
 *   tooltip={{
 *     title: '此内容由AI辅助生成，仅供参考。',
 *   }}
 * />
 *
 * // 带子元素
 * <AILabel status="emphasis">
 *   <span>这是一段文本内容</span>
 * </AILabel>
 * ```
 *
 * @returns {React.ReactElement} 渲染的 AI 标签组件
 *
 * @remarks
 * - 支持三种状态：默认（default）、强调（emphasis）、水印（watermark）
 * - 提供位置偏移功能，可精确控制标签位置
 * - 支持 Tooltip 提示，可自定义提示内容
 * - 当存在子元素时，标签会自动定位到子元素右上角
 * - 使用 framer-motion 提供平滑的动画效果
 * - 水印状态下，当 Tooltip 未打开时显示禁用图标
 */ var AILabelComponent = /*#__PURE__*/ React.forwardRef(function(props, ref) {
    var status = props.status, offset = props.offset, tooltip = props.tooltip, className = props.className, style = props.style, rootStyle = props.rootStyle, children = props.children, restProps = _object_without_properties(props, [
        "status",
        "offset",
        "tooltip",
        "className",
        "style",
        "rootStyle",
        "children"
    ]);
    var context = useContext(ConfigProvider.ConfigContext);
    var baseCls = context === null || context === void 0 ? void 0 : context.getPrefixCls(prefixCls);
    var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 合并样式，处理偏移量
    var mergedStyle = useMemo(function() {
        if (!offset) {
            return _object_spread({}, style);
        }
        var horizontalOffset = Number.parseInt(String(offset[0]), 10);
        var offsetStyle = {
            marginTop: offset[1],
            insetInlineEnd: -horizontalOffset
        };
        return _object_spread({}, offsetStyle, style);
    }, [
        offset,
        style
    ]);
    // Tooltip 显示状态
    var _useState = _sliced_to_array(useState(false), 2), tooltipOpen = _useState[0], setTooltipOpen = _useState[1];
    // 处理 Tooltip 状态变化
    var handleTooltipOpenChange = function handleTooltipOpenChange(open) {
        var _tooltip_onOpenChange;
        setTooltipOpen(open);
        tooltip === null || tooltip === void 0 ? void 0 : (_tooltip_onOpenChange = tooltip.onOpenChange) === null || _tooltip_onOpenChange === void 0 ? void 0 : _tooltip_onOpenChange.call(tooltip, open);
    };
    var _obj;
    // 计算类名
    var badgeClassName = classNames(baseCls, (_obj = {}, _define_property(_obj, "".concat(baseCls, "-status-").concat(status), !!status), _define_property(_obj, "".concat(baseCls, "-with-children"), !!children), _define_property(_obj, "".concat(baseCls, "-tooltip-visible"), tooltipOpen), _obj), className, hashId);
    // 渲染图标（使用提前返回优化）
    var renderIcon = function renderIcon() {
        if (status === 'watermark' && !tooltipOpen) {
            return /*#__PURE__*/ React.createElement(AIGraphicDisabled, null);
        }
        return /*#__PURE__*/ React.createElement(AIGraphic, null);
    };
    return wrapSSR(/*#__PURE__*/ React.createElement("span", _object_spread_props(_object_spread({
        ref: ref
    }, restProps), {
        className: badgeClassName,
        style: rootStyle
    }), children, /*#__PURE__*/ React.createElement(Tooltip, _object_spread_props(_object_spread({}, tooltip), {
        onOpenChange: handleTooltipOpenChange
    }), /*#__PURE__*/ React.createElement("sup", {
        className: classNames("".concat(baseCls, "-dot"), hashId),
        style: mergedStyle
    }, renderIcon()))));
});
AILabelComponent.displayName = 'AILabel';
// 使用 React.memo 优化性能，避免不必要的重新渲染
export var AILabel = /*#__PURE__*/ memo(AILabelComponent);
