import $i18n from '../../locales/i18n.js';
import * as React from 'react';
import { CnSender } from '../../cn-sender';
import { useInsertFieldTag } from '../../hooks/use-insert-field-tag.js';
import { FieldTagPopupWrapper } from '../../field-tag-popup-wrapper/FieldTagPopupWrapper';
import { CnTooltip, CnMessage, CnIcon, CnPopup, formilyCore } from '@cainiaofe/cn-ui';
import { fetchFieldTransform } from './api';
import { convertSlotConfigToInternalTokens } from '../../utils/index.js';
import copy from 'copy-to-clipboard';
import { getLanguage } from './utils/transform-params';
import { cleanSchemaData } from './utils/get-filter-meta-data';
import { useCommonQuery } from './hooks/use-common-query';
import { convertLanguageCode } from '../utils/convert-language-code';
import { convertTokensToSlotConfigs, tokensToSearchParams } from '../utils/token-utils';
import { CommonQueryList } from './components/common-query-list';
import './cn-ai-filter.scss';
import { event as eventBus } from '@ice/stark-data';
import { CnAiListEventProvider, useCnAiListEventNames, useCnAiListInstanceKey, } from '../../cn-ai-agent/context/cn-ai-list-event-context';
import { CN_AI_LIST_INSTANCE_KEY_DATA_ATTR } from '../../cn-ai-agent/constants/event-constants';
import { convertDataDict } from './utils/convert-data-dict';
import { convertInternalTokensToApiTokens } from './utils/convert-internal-tokens-to-api-tokens';
import { normalizeTokenValue } from '../utils/normalize/normalize-token-value';
import { getDateFilterValueType, getDateShortcutLabel } from '../utils/constants/date-shortcuts';
import { parseDynamicDateOption, formatTimestampToDateStringArray, } from '../utils/display/datetime-picker-display-utils';
import { armsHottagLog } from '../../utils/arms/arms-hot-tag-log.js';
import { cnPopupFloatingLayerOverlayProps, FLOATING_LAYER_Z_INDEX, getPopupContainer, } from '../../utils/floating-layer.js';
import { isEditor } from '../../utils/env/index.js';
import { useFilterAgentToggle } from './hooks/use-filter-agent-toggle';
import { getOperator } from '../utils/get-operator';
import { useBrandAssets } from '../../theme/context.js';
import { useFieldIcon } from '../../cn-ai-table/view/utils/field-icon-utils';
import { buildLookupJoinSearchPayload, mergeLookupSchemaPropertiesToJoinTableParams, normalizeLookupSearchConfigs, } from '../utils/lookup-field-config-utils';
const { createForm } = formilyCore;
/**
 * 按字段路径读取 formValue，兼容：
 * - 扁平字段：`formValue[path]`
 * - 嵌套字段：`formValue.a.b.c`
 *
 * @param formValue 当前表单值
 * @param path 字段路径（可能是点路径）
 * @returns 字段数据对象或原始值；未命中返回 undefined
 */
function getFieldDataByPath(formValue, path) {
    if (!formValue || !path)
        return undefined;
    if (formValue[path] !== undefined)
        return formValue[path];
    return path.split('.').reduce((acc, key) => {
        if (!acc || typeof acc !== 'object')
            return undefined;
        return acc[key];
    }, formValue);
}
const CnAiFilterView = (props) => {
    var _a, _b;
    const eventNames = useCnAiListEventNames();
    const listInstanceKey = useCnAiListInstanceKey();
    const { onSearch, popupTriggerKey = '/', // 可以自定义触发键，默认为 "/"
    customPopupProps, // 自定义弹窗配置
    schema, customFieldTransformApi, operator: operatorProp, id, showAgentIcon = true, onLastSearchParamsChange, bizRequestConfig, lookupFieldConfigs, ...restProps } = props;
    const operator = operatorProp !== null && operatorProp !== void 0 ? operatorProp : getOperator();
    const pageId = id !== null && id !== void 0 ? id : '';
    const brandAssets = useBrandAssets();
    const getFieldIcon = useFieldIcon();
    // 从 restProps 中提取 form 和 formProps（这些是 SenderProps 的一部分）
    const { form: formFromProps, formProps } = restProps;
    /** 筛选内字段弹层共用一个 Formily 实例（x-reactions）；tag 删除时 Sender 会同步清对应 form 字段，避免再插入同字段遗留值 */
    const filterFormRef = React.useRef(null);
    if (!filterFormRef.current) {
        filterFormRef.current = createForm({ ...(formProps || {}) });
    }
    const form = formFromProps !== null && formFromProps !== void 0 ? formFromProps : filterFormRef.current;
    // 创建 ref 来访问 CnSender 的 insert 方法
    const senderRef = React.useRef(null);
    // 数据字典 ref，用于承载转换后的字段数据
    const dataDictRef = React.useRef([]);
    // 加载状态：是否正在调用翻译 API
    const [isLoading, setIsLoading] = React.useState(false);
    // 上一次的搜索参数
    const [lastSearchParams, setLastSearchParams] = React.useState('');
    const [lookupConfigMap, setLookupConfigMap] = React.useState(() => normalizeLookupSearchConfigs(lookupFieldConfigs));
    /** 始终指向最新 map，避免 translate 回调链里闭包仍用「增列前」的 lookupConfigMap，导致 joinTableColumns 少列 */
    const lookupConfigMapRef = React.useRef(lookupConfigMap);
    lookupConfigMapRef.current = lookupConfigMap;
    const { enableAIAgent, agentVisible, handleToggleAgent } = useFilterAgentToggle(showAgentIcon);
    const agentToggleTitle = React.useMemo(() => agentVisible
        ? $i18n.get({ id: 'HiddenAIAssistant', dm: '隐藏AI助理' })
        : $i18n.get({ id: 'ShowAIAssistant', dm: '显示AI助理' }), [agentVisible]);
    React.useEffect(() => {
        onLastSearchParamsChange === null || onLastSearchParamsChange === void 0 ? void 0 : onLastSearchParamsChange(lastSearchParams);
    }, [lastSearchParams, onLastSearchParamsChange]);
    /** 仅同步宿主显式传入的 lookup 列表；undefined 表示未受控，不要用 {} 覆盖总线事件已下发的全量配置 */
    React.useEffect(() => {
        if (lookupFieldConfigs == null)
            return;
        setLookupConfigMap(normalizeLookupSearchConfigs(lookupFieldConfigs));
    }, [lookupFieldConfigs]);
    React.useEffect(() => {
        const handleLookupConfigUpdate = (payload) => {
            const nextLookupConfigMap = normalizeLookupSearchConfigs(payload === null || payload === void 0 ? void 0 : payload.lookupSearchConfigs);
            setLookupConfigMap(nextLookupConfigMap);
        };
        eventBus.on(eventNames.LOOKUP_FIELD_SEARCH_CONFIG_UPDATE, handleLookupConfigUpdate);
        return () => {
            eventBus.off(eventNames.LOOKUP_FIELD_SEARCH_CONFIG_UPDATE, handleLookupConfigUpdate);
        };
    }, [eventNames.LOOKUP_FIELD_SEARCH_CONFIG_UPDATE]);
    // AbortController 引用，用于取消正在进行的请求
    const abortControllerRef = React.useRef(null);
    const mergedSchema = React.useMemo(() => mergeLookupSchemaPropertiesToJoinTableParams(schema, lookupConfigMap), [schema, lookupConfigMap]);
    React.useEffect(() => {
        // eslint-disable-next-line no-console -- 调试 mergeLookupSchema（mergeLookupSchemaPropertiesToJoinTableParams）结果
        console.log('[CnAiFilter] mergedSchema', mergedSchema);
    }, [mergedSchema]);
    // 清洗 schema 数据，提取字段元数据并转换为数据字典格式
    React.useEffect(() => {
        if (mergedSchema) {
            const cleanedData = cleanSchemaData(mergedSchema);
            const dataDict = convertDataDict(cleanedData);
            dataDictRef.current = dataDict;
        }
    }, [mergedSchema]);
    // formMap 现在在 SlotTextArea 中管理，不再需要在这里定义
    // 获取语言代码
    const language = getLanguage();
    const dispatchSearch = React.useCallback((searchParams, formValue) => {
        if (!onSearch)
            return;
        const finalSearchParams = buildLookupJoinSearchPayload({
            lookupConfigMap: lookupConfigMapRef.current,
            searchParams,
            formValue,
        });
        onSearch(finalSearchParams);
        eventBus.emit(eventNames.PAGINATION_CHANGE);
    }, [onSearch, eventNames.PAGINATION_CHANGE]);
    // 常用查询条件相关逻辑（包含钉住功能）
    const { commonQueryVisible, setCommonQueryVisible, commonQueriesLoading, handleCommonQueryClick, pinnedQueries, unpinnedQueries, handlePinCommonQuery, handleUnpinCommonQuery, } = useCommonQuery({
        senderRef,
        schema: mergedSchema === null || mergedSchema === void 0 ? void 0 : mergedSchema.properties,
        onSearch: (params) => dispatchSearch(params),
        setLastSearchParams,
        operator,
        code: pageId,
        language,
        customFieldTransformApi: ((_a = bizRequestConfig === null || bizRequestConfig === void 0 ? void 0 : bizRequestConfig.filter) === null || _a === void 0 ? void 0 : _a.fieldTransformUrl) || customFieldTransformApi,
        customSuggestApi: (_b = bizRequestConfig === null || bizRequestConfig === void 0 ? void 0 : bizRequestConfig.filter) === null || _b === void 0 ? void 0 : _b.suggestionUrl,
        dataDict: dataDictRef.current,
    });
    // 组件卸载时清理 AbortController
    React.useEffect(() => {
        return () => {
            if (abortControllerRef.current) {
                abortControllerRef.current.abort();
                abortControllerRef.current = null;
            }
        };
    }, []);
    // 使用公共 API 插入字段 tag
    const insertFieldTag = useInsertFieldTag(senderRef, popupTriggerKey, (value, onValueChange, renderProps, item, formMapRef, onFormMapUpdate) => {
        return (React.createElement(FieldTagPopupWrapper, { value: value, onValueChange: onValueChange, renderProps: renderProps, item: item, formMapRef: formMapRef, onFormMapUpdate: onFormMapUpdate }));
    });
    // 创建增强的 customPopupProps，将 onFieldSelect 集成到 asyncSelectProps.onChange 中
    const enhancedCustomPopupProps = React.useMemo(() => {
        const { onFieldSelect, asyncSelectProps, ...rest } = customPopupProps || {};
        // 如果提供了 onFieldSelect，使用它；否则使用内部的 insertFieldTag
        const fieldSelectHandler = onFieldSelect || insertFieldTag;
        return {
            ...rest,
            onFieldSelect: fieldSelectHandler,
            asyncSelectProps: {
                ...asyncSelectProps,
                placeholder: $i18n.get({
                    id: 'SelectTheFieldsThatNeedToBeIntro_2004559010',
                    dm: '选择需要引入的字段',
                }),
                itemRender: (item) => {
                    var _a;
                    return (React.createElement(React.Fragment, null,
                        React.createElement("div", { className: `cn-sender-schema-menu-option-content` },
                            React.createElement("img", { src: getFieldIcon((_a = item.fieldConfig) === null || _a === void 0 ? void 0 : _a['x-component']), alt: item.label, className: `cn-sender-schema-menu-option-icon`, style: { width: '16px', height: '16px' } }),
                            React.createElement("span", { className: `cn-sender-schema-menu-option-label` }, item.label))));
                },
                onChange: (value, actionType, item) => {
                    // 先调用自定义的 onChange（如果存在）
                    if (asyncSelectProps === null || asyncSelectProps === void 0 ? void 0 : asyncSelectProps.onChange) {
                        asyncSelectProps.onChange(value, actionType, item);
                    }
                    // 然后调用 onFieldSelect 回调
                    const fieldConfig = item === null || item === void 0 ? void 0 : item.fieldConfig;
                    if (value && fieldConfig) {
                        armsHottagLog({
                            hottag: 'cn-ai-filter.selectField',
                            name: $i18n.get({ id: 'SelectField', dm: '选择字段' }),
                            c6: value,
                        });
                        if (onFieldSelect) {
                            // 如果提供了自定义的 onFieldSelect，调用它
                            onFieldSelect({
                                fieldKey: value,
                                fieldConfig,
                            });
                        }
                        else {
                            // 否则使用内部的 insertFieldTag
                            insertFieldTag(value, fieldConfig);
                        }
                    }
                },
            },
        };
    }, [customPopupProps, insertFieldTag, getFieldIcon]);
    // 停止加载：取消正在进行的请求
    const handleStopLoading = React.useCallback(() => {
        armsHottagLog({
            hottag: 'cn-ai-filter.stopLoading',
            name: $i18n.get({ id: 'StopLoading', dm: '停止加载' }),
        });
        if (abortControllerRef.current) {
            abortControllerRef.current.abort();
            abortControllerRef.current = null;
        }
        setIsLoading(false);
    }, []);
    // 包装 onSearch，点击发送按钮时首先会向翻译 API 发起请求
    const handleSubmit = React.useCallback(async (value, slotConfig, skill, formValue) => {
        var _a, _b, _c, _d, _e, _f;
        // 如果查询的 value 为空，表示查询全部数据，直接调用 onSearch
        if (!value || !value.trim()) {
            armsHottagLog({
                hottag: 'cn-ai-filter.search',
                name: $i18n.get({ id: 'Search', dm: '搜索' }),
                c6: $i18n.get({ id: 'AllData', dm: '全部数据' }),
            });
            // 用户未输入任何内容，不展示「已为您查询」提示
            setLastSearchParams('');
            dispatchSearch({});
            return;
        }
        armsHottagLog({
            hottag: 'cn-ai-filter.search',
            name: $i18n.get({ id: 'Search', dm: '搜索' }),
            c6: value,
            c7: JSON.stringify(slotConfig),
            c8: JSON.stringify(formValue),
        });
        // 点击发送按钮时，首先会向翻译 API 发起请求
        try {
            // 创建新的 AbortController
            const abortController = new AbortController();
            abortControllerRef.current = abortController;
            setIsLoading(true);
            const finalSlotConfig = slotConfig || [];
            const finalFormValue = formValue || {};
            const internalTokens = finalSlotConfig.length > 0
                ? convertSlotConfigToInternalTokens(finalSlotConfig, finalFormValue)
                : [];
            // 检查必要参数
            if (!operator) {
                // eslint-disable-next-line no-console
                console.error('Operator is required for field transform API');
                setIsLoading(false);
                return;
            }
            // 转换语言代码（zh-CN -> zh_CN）
            const languageCode = convertLanguageCode(language);
            // 将内部 tokens 转换为 API tokens 格式
            const apiTokens = convertInternalTokensToApiTokens(internalTokens, value, mergedSchema === null || mergedSchema === void 0 ? void 0 : mergedSchema.properties);
            // 获取 columns（从 dataDictRef）
            const columns = dataDictRef.current.map((item) => ({
                displayName: item.displayName,
                columnName: item.columnName,
                columnType: item.columnType,
                ...(item.options && { options: item.options }),
            }));
            // 1. 调用翻译接口
            const transformResult = await fetchFieldTransform({
                customFieldTransformApi: ((_a = bizRequestConfig === null || bizRequestConfig === void 0 ? void 0 : bizRequestConfig.filter) === null || _a === void 0 ? void 0 : _a.fieldTransformUrl) || customFieldTransformApi,
                operator,
                code: pageId,
                languageCode,
                tokens: apiTokens,
                columns,
                signal: abortController.signal, // 传递 signal 用于取消请求
            });
            // 2. 处理接口响应数据
            // 新接口响应结构: { success: true, data: { tokens: [...] } }
            const responseData = transformResult === null || transformResult === void 0 ? void 0 : transformResult.data;
            // 检查响应是否成功
            const isSuccess = (transformResult === null || transformResult === void 0 ? void 0 : transformResult.success) && (responseData === null || responseData === void 0 ? void 0 : responseData.tokens);
            // 检查请求是否被取消
            if ((_b = abortControllerRef.current) === null || _b === void 0 ? void 0 : _b.signal.aborted) {
                return;
            }
            if (isSuccess && (responseData === null || responseData === void 0 ? void 0 : responseData.tokens)) {
                // 标准化 tokens 的 value，确保符合组件预期格式
                const normalizedTokens = responseData.tokens.map((token) => normalizeTokenValue(token, (mergedSchema === null || mergedSchema === void 0 ? void 0 : mergedSchema.properties) || {}));
                // 检查是否有结构化数据
                const hasStructuredTokensInResponse = normalizedTokens.some((token) => token.queryType === 'STRUCTURED');
                // 如果有结构化数据，将输入框中的自然语言转换为 tags
                if (hasStructuredTokensInResponse && senderRef.current) {
                    // 清空输入框
                    (_d = (_c = senderRef.current).clear) === null || _d === void 0 ? void 0 : _d.call(_c);
                    // 转换 tokens 为 slotConfigs
                    const customRenderForTag = (tagValue, onValueChange, renderProps, item, formMapRef, onFormMapUpdate) => {
                        return (React.createElement(FieldTagPopupWrapper, { value: tagValue, onValueChange: onValueChange, renderProps: renderProps, item: item, formMapRef: formMapRef, onFormMapUpdate: onFormMapUpdate }));
                    };
                    // 将后端返回的 tokens 与原始 formValue 合并，以便恢复日期快捷选项值
                    const tokensWithOriginalValues = normalizedTokens.map((token) => {
                        if (token.queryType !== 'STRUCTURED' || !token.columnName)
                            return token;
                        const originalFieldData = getFieldDataByPath(finalFormValue, token.columnName);
                        let originalValue;
                        if (originalFieldData === null || originalFieldData === void 0 ? void 0 : originalFieldData.values) {
                            originalValue = Array.isArray(originalFieldData.values)
                                ? originalFieldData.values[0]
                                : originalFieldData.values;
                        }
                        if (typeof originalValue !== 'string')
                            return token;
                        const valueType = getDateFilterValueType(originalValue);
                        if (valueType === 'dateRange') {
                            const labels = formatTimestampToDateStringArray(originalValue);
                            return {
                                ...token,
                                _originalDateShortcutValue: originalValue,
                                naturalLanguage: labels[0],
                            };
                        }
                        if (valueType === 'dynamic') {
                            const chineseLabel = parseDynamicDateOption(originalValue) || '';
                            return {
                                ...token,
                                value: Array.isArray(token.value) && token.value.length > 0 ? token.value : [],
                                naturalLanguage: chineseLabel,
                                _originalDateShortcutValue: originalValue,
                            };
                        }
                        if (valueType === 'shortcut' &&
                            Array.isArray(token.value) &&
                            token.value.length > 0) {
                            return {
                                ...token,
                                naturalLanguage: getDateShortcutLabel(originalValue),
                                _originalDateShortcutValue: originalValue,
                            };
                        }
                        return token;
                    });
                    const { slotConfigs, displayTexts } = convertTokensToSlotConfigs(tokensWithOriginalValues, (mergedSchema === null || mergedSchema === void 0 ? void 0 : mergedSchema.properties) || {}, customRenderForTag);
                    if (slotConfigs.length > 0) {
                        (_f = (_e = senderRef.current).insert) === null || _f === void 0 ? void 0 : _f.call(_e, slotConfigs);
                    }
                    const displayText = displayTexts.join(' ') || value || $i18n.get({ id: 'AllData', dm: '全部数据' });
                    setLastSearchParams(displayText);
                }
                else {
                    // 如果没有结构化数据，使用原始输入值
                    setLastSearchParams(value || $i18n.get({ id: 'AllData', dm: '全部数据' }));
                }
                // 3. 处理响应数据：将 tokens 转换为查询参数格式
                const searchParams = tokensToSearchParams(normalizedTokens);
                // 4. 统一在 CnAiFilter 内清洗 lookup join 协议并触发查询
                dispatchSearch(searchParams, finalFormValue);
            }
            else {
                // 转换失败，显示错误信息（如果需要）
                const errorMsg = (responseData === null || responseData === void 0 ? void 0 : responseData.errorMsg) || (transformResult === null || transformResult === void 0 ? void 0 : transformResult.errorMsg);
                if (errorMsg) {
                    // eslint-disable-next-line no-console
                    console.error('Field transform failed:', errorMsg);
                }
            }
        }
        catch (error) {
            // 如果请求被取消，不显示错误
            if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError') {
                // eslint-disable-next-line no-console
                console.log('Request aborted by user');
                return;
            }
            // eslint-disable-next-line no-console
            console.error('Field transform API failed:', error);
        }
        finally {
            // 清理状态
            abortControllerRef.current = null;
            setIsLoading(false);
        }
    }, [
        dispatchSearch,
        customFieldTransformApi,
        language,
        operator,
        pageId,
        dataDictRef,
        mergedSchema,
        bizRequestConfig,
    ]);
    const filterSender = (React.createElement(CnSender, { ref: senderRef, placeholder: $i18n.get({
            id: 'AIQuerySupportsNaturalLanguageQu_233901144',
            dm: "AI查询支持自然语言查询,支持键入'/'引入字段精确查询,基于用户维度的查询习惯总结,让查询越用越智能~",
        }), className: "cn-ai-filter__sender", ...restProps, onSubmit: handleSubmit, popupTriggerKey: popupTriggerKey, customPopupProps: enhancedCustomPopupProps, schema: mergedSchema, form: form, formProps: formProps, prefix: (() => {
            const prefixDiv = (React.createElement("div", { className: "cn-ai-filter__prefix", onClick: (e) => {
                    e.stopPropagation();
                    const willOpen = !commonQueryVisible;
                    if (willOpen) {
                        armsHottagLog({
                            hottag: 'cn-ai-filter.openCommonQuery',
                            name: $i18n.get({ id: 'OpenCommonQuery', dm: '打开常用查询' }),
                        });
                    }
                    setCommonQueryVisible(willOpen);
                }, style: { cursor: 'pointer' } },
                React.createElement(CnIcon, { type: "time", className: "cn-ai-filter__prefix-icon-clock" }),
                React.createElement(CnIcon, { type: "triangle-down-fill", className: "cn-ai-filter__prefix-icon-arrow" })));
            const tooltipTrigger = (React.createElement(CnTooltip, { triggerType: "hover", align: "b", trigger: prefixDiv, popupProps: {
                    ...(commonQueryVisible ? { visible: false } : {}),
                    style: { zIndex: FLOATING_LAYER_Z_INDEX },
                } }, $i18n.get({ id: 'CommonQueryCondition', dm: '常用查询条件' })));
            return (React.createElement(CnPopup, { v2: true, visible: commonQueryVisible, onVisibleChange: setCommonQueryVisible, trigger: tooltipTrigger, placement: "bl", offset: [0, 8], container: getPopupContainer, ...cnPopupFloatingLayerOverlayProps },
                React.createElement("div", { className: "cn-ai-filter__common-query-popup" },
                    React.createElement("div", { className: "cn-ai-filter__common-query-list" },
                        React.createElement(CommonQueryList, { loading: commonQueriesLoading, pinnedQueries: pinnedQueries, unpinnedQueries: unpinnedQueries, onQueryClick: handleCommonQueryClick, onPinQuery: handlePinCommonQuery, onUnpinQuery: handleUnpinCommonQuery, onClose: () => setCommonQueryVisible(false), schema: mergedSchema })))));
        })(), sendButtonProps: {
            icon: React.createElement("img", { src: brandAssets.filter.sendButtonIconUrl, alt: "search" }),
            className: 'cn-ai-filter__send-button',
            ...(isEditor ? { disabled: true } : {}),
        }, allowRecord: true, suffix: (actionNode) => {
            return React.createElement("div", { className: "cn-ai-filter__footer" }, actionNode);
        }, loading: isLoading, onCancel: handleStopLoading, autoSize: { minRows: 1, maxRows: 2 }, canEmptySubmit: true }));
    return (React.createElement("div", { className: "cn-ai-filter", id: id, [CN_AI_LIST_INSTANCE_KEY_DATA_ATTR]: listInstanceKey },
        showAgentIcon ? (React.createElement("div", { className: "cn-ai-filter__agent-row" },
            enableAIAgent && (React.createElement(CnTooltip, { triggerType: "hover", align: "b", trigger: React.createElement("div", { className: "cn-ai-filter__agent-toggle", onClick: (e) => {
                        e.stopPropagation();
                        handleToggleAgent();
                    } },
                    React.createElement("img", { src: "https://img.alicdn.com/imgextra/i1/O1CN01b1jDbz1WdwqxSTQbR_!!6000000002812-55-tps-22-22.svg", alt: "AI Assistant" })) }, agentToggleTitle)),
            React.createElement("div", { className: "cn-ai-filter__agent-row-body" }, filterSender))) : (filterSender),
        lastSearchParams && (React.createElement("div", { className: "translate-tags-container" },
            React.createElement("div", { className: "translate-tags-title" },
                React.createElement("div", { className: "success-icon" },
                    React.createElement(CnIcon, { type: "complete", size: "small" })),
                React.createElement("div", { className: "success-label" }, $i18n.get({ id: 'HasBeenQueriedForYou', dm: '已为您查询：' }))),
            React.createElement("div", { className: "translate-tags-content" },
                React.createElement("span", { className: "translate-tag-word", title: lastSearchParams }, `"${lastSearchParams}"`),
                React.createElement(CnIcon, { className: "translate-tag-copy", type: "copy-fill", size: "medium", onClick: () => {
                        armsHottagLog({
                            hottag: 'cn-ai-filter.copySearchParams',
                            name: $i18n.get({ id: 'CopyQueryCriteria', dm: '复制查询条件' }),
                            c6: lastSearchParams,
                        });
                        copy(lastSearchParams);
                        CnMessage.notice($i18n.get({ id: 'CopiedToClipboard', dm: '已复制到剪切板' }));
                    } }))))));
};
CnAiFilterView.displayName = 'CnAiFilter';
export const CnAiFilter = (props) => (React.createElement(CnAiListEventProvider, { instanceId: props.id },
    React.createElement(CnAiFilterView, { ...props })));
