/**
 * Row Data Adapter - 行数据适配器
 * 将 AssetMatrix 的逐格 getCellData 逻辑前移为整行预处理
 */
import type { ITableHeader } from './columnAdapter';
/**
 * Check if performance logging is enabled.
 * Toggle in DevTools console: `window.__PERF_LOG__ = true` to enable.
 */
export declare function isPerfLogEnabled(): boolean;
/**
 * Search match result for a row
 */
export interface SearchMatchResult {
    matched: boolean;
    highlightKeys: string[];
    currentHighlightKey?: string;
}
/**
 * Preprocessed row data with computed metadata
 */
export interface PreprocessedRow {
    [key: string]: any;
    _permissions: Record<string, boolean>;
    _errors: Record<string, string>;
    _searchMatch: SearchMatchResult;
    _cellBgColors: Record<string, string>;
    _bgColor?: string;
    _isTopLevelEntity?: boolean;
    _isEmpty?: boolean;
    _isGroup?: boolean;
    _parentHasLink?: boolean;
    _pathId?: string;
    _originalPathId?: string | number;
    _tableTreeLevel?: number;
    _proxyedDataRef?: Record<string, any>;
    /** 组头行是否被搜索命中（仅 isGroup 行有效），供 GroupRow 渲染查询 */
    _groupHeaderSearchMatched?: boolean;
    /** 组头行是否是当前高亮项（需要绘制 2px 橙色 inset 边框），仅 isGroup 行有效 */
    _groupHeaderSearchCurrentHighlight?: boolean;
}
/**
 * Expand proxy row (parentHasLink or isUsePathId)
 * Extracts inner data and preserves metadata.
 *
 * 注意：AssetMatrix 的分组表格（GroupTableController）中 isUsePathId 行是 ES6 Proxy 对象，
 * 其 get handler 将非 donotProxyProp 的属性读取代理到 proxyedData 上。
 * 直接 spread Proxy 对象只会获取 target 本身的属性（id, isUsePathId, groupName 等），
 * 无法获取代理属性（name, workflow_state 等）。
 * 因此需要通过 headerKeys 显式读取每个列对应的值。
 */
export declare function expandProxyRow(row: Record<string, any>, headerKeys?: string[]): Record<string, any>;
/**
 * Calculate per-cell canEdit permissions for each column.
 *
 * This is the SINGLE source of truth for whether a cell is editable.
 * Cell.readonly in arthub-table is simply `!_permissions[key]`.
 *
 * Rules (in priority order):
 * 1. Special rows (isSeparateRow, isEmpty, isGroup, isAddTask) → all false
 * 2. When writePermissionInfo exists:
 *    - header.canEdit=false → false
 *    - parentHasLink → false
 *    - deliverable_review column → false
 *    - writePermissionInfo[key]=false or filterMatched=false → false
 *    - isLink columns → false
 *    - otherwise → !!writePermissionInfo[key]
 * 3. When writePermissionInfo does NOT exist → default true (editable)
 *    - header.canEdit=false → false
 *    - isLink columns → false
 */
export declare function calculatePermissions(row: Record<string, any>, headers: ITableHeader[], precomputed?: PrecomputedContext): Record<string, boolean>;
/**
 * Collect error info for each column
 */
export declare function collectErrors(row: Record<string, any>, headers: ITableHeader[]): Record<string, string>;
/**
 * Calculate search match state for the row
 *
 * Note: `isGroupHeader` is an opaque field used by GroupRow rendering only.
 * It is transparently ignored here (data row match semantics remain unchanged).
 */
export declare function calculateSearchMatch(row: Record<string, any>, searchMatchList: Array<{
    id: string | number;
    key: string;
    highlight?: boolean;
    isGroupHeader?: boolean;
}>): SearchMatchResult;
/**
 * Calculate background color for a cell based on highlighted properties
 */
export declare function calculateRowBgColor(row: Record<string, any>, key: string, highlightedProperties: Record<string, string>): string | undefined;
export declare function resetPerfAccum(): void;
export declare function dumpPerfAccum(): void;
/**
 * 强制使 preprocessRow 的 WeakMap 缓存全部失效。
 *
 * 当行数据被异步更新（如 getNeedGetDetailNodeDetail 完成后原地修改了 Proxy 属性），
 * 但 Proxy 对象引用未变，WeakMap 仍会命中旧缓存。调用此方法递增 propsVersion，
 * 使所有已缓存的条目过期，下次 convertToDataGridRows 会从 Proxy 重新读取最新值。
 *
 * 推荐在 refreshDataGrid 入口调用（该方法本身已有 200ms 冷却期 + 50ms 防抖，频率可控）。
 */
export declare function invalidatePreprocessRowCache(): void;
/**
 * Pre-computed context for batch processing.
 * Created once in convertToDataGridRows and reused for every row.
 */
export interface PrecomputedContext {
    headerKeys: string[];
    /** Pre-computed set of header keys that are always readonly (canEdit=false or isLink) */
    headerAlwaysReadonlyKeys?: Set<string>;
    /** Pre-computed frozen permissions object for special rows (all false) */
    specialRowPermissions?: Record<string, boolean>;
    /** Pre-computed: whether any header has a 'nested' viewer type */
    hasNestedColumn?: boolean;
    /** Pre-built Map from searchMatchList for O(1) lookup by row id */
    searchMatchMap?: Map<string | number, Array<{
        key: string;
        highlight?: boolean;
        isGroupHeader?: boolean;
    }>>;
    /**
     * Pre-filtered headers that actually need transformCellValues processing.
     * Excludes headers whose viewer types have been migrated to cellValueTransformer
     * (upstream, person, wf-state, workflow, task-node, module) and headers whose
     * editor types are handled at render time (treeDropdown, dropdown).
     * This avoids iterating over ~80% of columns that would just `continue` anyway.
     */
    headersNeedingTransform?: ITableHeader[];
    /** Current props version for WeakMap cache invalidation */
    propsVersion?: number;
}
export declare function preprocessRow(rawRow: Record<string, any>, headers: ITableHeader[], props: Record<string, any>, precomputed?: PrecomputedContext): PreprocessedRow;
/**
 * 批量将原始行数据转换为 DataGrid 预处理后的行数据
 *
 * 对每一行调用 preprocessRow 进行展开代理、权限计算、错误收集、
 * 搜索匹配、单元格值转换等预处理操作。
 *
 * @param tableDataList - 原始行数据列表
 * @param allHeaders - 所有列头配置
 * @param props - 业务 props（含 resolver、搜索列表等）
 * @returns 预处理后的行数据数组
 */
export declare function convertToDataGridRows(tableDataList: Record<string, any>[], allHeaders: ITableHeader[], props: Record<string, any>): PreprocessedRow[];
/**
 * 对指定列重新执行 transformCellValues，更新已预处理行数据中的值
 *
 * 用于增量列刷新场景：当某些列的数据或配置变化时，只需重新转换这些列的值，
 * 而不必对所有行做全量 preprocessRow。
 *
 * @param preprocessedData - 已预处理的行数据数组（会被就地修改）
 * @param rawDataList - 原始行数据列表（用于读取最新的原始值）
 * @param colKeys - 需要刷新的列 key 列表
 * @param allHeaders - 所有列头配置
 * @param props - 业务 props
 */
export declare function refreshColumnCellValues(preprocessedData: PreprocessedRow[], rawDataList: Record<string, any>[], colKeys: string[], allHeaders: ITableHeader[], props: Record<string, any>): void;
/**
 * Fast-path column value sync: only copies raw values from rawDataList to
 * preprocessedData for the specified columns. Skips permission recalculation
 * and transformCellValues entirely.
 *
 * Prerequisites:
 * - The target columns must be "simple" columns whose values are used as-is
 *   by the viewer (i.e., transformCellValues would `continue` / skip them).
 * - Value-to-display conversion is handled at render time by cellValueTransformer.
 *
 * Performance: O(totalRows) but only does a single property assignment per row
 * per column key (~0.001ms/row), compared to the full refreshSingleRowColumns
 * path which does sync + permissions + transform (~0.08ms/row).
 *
 * @param preprocessedData - The preprocessed row array (DataGrid's data source)
 * @param rawDataList - The raw row array (business layer's tableTaskList)
 * @param colKeys - Column keys to sync
 */
export declare function fastSyncColumnValues(preprocessedData: PreprocessedRow[], rawDataList: Record<string, any>[], colKeys: string[]): void;
/**
 * [Optimization B] Async time-sliced version of refreshColumnCellValues.
 * Processes rows in batches, yielding to the main thread between batches
 * to prevent long tasks from blocking UI interactions (scrolling, input).
 *
 * @param batchSize - Number of rows to process per batch (default 200)
 * @returns Promise that resolves when all rows have been processed
 */
export declare function refreshColumnCellValuesAsync(preprocessedData: PreprocessedRow[], rawDataList: Record<string, any>[], colKeys: string[], allHeaders: ITableHeader[], props: Record<string, any>, batchSize?: number): Promise<void>;
/**
 * 计算 Stage 分组标志位
 *
 * 遍历所有行，对 Stage 类型的行计算 isChildStage、isFisrtChildStage、
 * isLastChildStage 标志位，用于 Canvas 表格的父子区分显示。
 *
 * @param data - 预处理后的行数据数组（会被就地修改）
 * @param getTopParentStageByPath - 根据 path 获取顶层父 Stage 的函数
 */
export declare function computeStageFlags(data: PreprocessedRow[], getTopParentStageByPath: (path: any[]) => any): void;
/**
 * 单行预处理（含样式计算）
 *
 * 与 preprocessRow 类似，但额外执行样式预处理和序号分配，
 * 用于增量更新单行场景。
 *
 * @param rawRow - 原始行数据
 * @param allHeaders - 所有列头配置
 * @param props - 业务 props
 * @param options - 额外选项（行索引、列数、序号等）
 * @returns 预处理后的行数据
 */
export declare function preprocessSingleRow(rawRow: Record<string, any>, allHeaders: ITableHeader[], props: Record<string, any>, options: {
    rowIndex: number;
    columnsLength: number;
    controllerProps: Record<string, any>;
    tableIndex?: number;
}): PreprocessedRow;
/**
 * Rebuild _nestedData for specific nested columns on given preprocessed rows.
 *
 * This extracts the nested data construction logic from convertToDataGridRows,
 * allowing incremental rebuild of _nestedData when a child column's data changes
 * (e.g. file/image upload in a nested sub-table) without a full data refresh.
 *
 * @param rows - Preprocessed row array (same as body.data / _dataGridData)
 * @param rawRows - Raw row data array (same as tableDataList)
 * @param nestedParentKeys - Keys of the nested parent columns to rebuild
 * @param allHeaders - All column headers (including nested columns with children)
 * @param props - Controller props (pipelineViewKey, displayTaskNum, iconUrlPrefix, etc.)
 */
export declare function rebuildNestedColumnData(rows: PreprocessedRow[], rawRows: Record<string, any>[], nestedParentKeys: string[], allHeaders: ITableHeader[], props: Record<string, any>): void;
