"use strict";
/**
 * 行选择插件注册
 *
 * priority 10：在操作列之前执行，保证行选择状态先就绪。
 * 数据源统一读取 pipeline context 中的 visibleData（筛选后），
 * 由 NormalTableView 在 runPlugins 前注入。
 */
Object.defineProperty(exports, "__esModule", { value: true });
const pipeline_1 = require("../../pipeline");
const index_1 = require("./index");
const event_constants_1 = require("../../../../../../../cn-ai-agent/constants/event-constants");
const primary_key_1 = require("../../../../../../../cn-ai-table/view/utils/primary-key");
(0, pipeline_1.registerPlugin)('RowSelection', (props, pipeline, context) => {
    var _a, _b, _c;
    const { rowSelectionProps } = props;
    const { dataModel } = context;
    if (!(rowSelectionProps === null || rowSelectionProps === void 0 ? void 0 : rowSelectionProps.hasSelect)) {
        return;
    }
    // 优先使用调用方预注入的 visibleData（筛选后），兜底 rawData
    const visibleData = (_a = pipeline.getContext('visibleData')) !== null && _a !== void 0 ? _a : dataModel.rawData;
    const disabledRowKeys = (_b = pipeline.getContext('disabledRowKeys')) !== null && _b !== void 0 ? _b : new Set();
    const plugin = (0, index_1.rowSelectionPlugin)({
        enabled: rowSelectionProps.hasSelect,
        selectionType: rowSelectionProps.selectionType || 'multiple',
        selectedKeys: rowSelectionProps.selectKeys || [],
        primaryKey: rowSelectionProps.primaryKey || primary_key_1.DEFAULT_PRIMARY_KEY,
        dataSource: visibleData,
        setSelectKeys: rowSelectionProps.setSelectKeys,
        disabledRowKeys,
        eventNames: (_c = props.cnAiListEventNames) !== null && _c !== void 0 ? _c : event_constants_1.EVENT_NAMES,
    });
    plugin(pipeline);
}, 10);
