export class ColumnConfigManager {
    constructor() {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        this.map = new Map();
    }
    getColumn(type) {
        const column = this.map.get(type);
        if (!column) {
            throw new Error(`${type} is not exist`);
        }
        return column;
    }
    register(type, ops) {
        const config = new ColumnConfig(type, ops);
        this.map.set(type, config);
        return config;
    }
}
export class ColumnConfig {
    constructor(type, ops) {
        this.type = type;
        this.ops = ops;
        this.convertMap = new Map();
    }
    create(name, data) {
        return {
            type: this.type,
            name,
            data: data ?? this.ops.defaultData(),
        };
    }
    defaultData() {
        return this.ops.defaultData();
    }
    createWithId(id, name, data) {
        return {
            id,
            type: this.type,
            name,
            data: data ?? this.ops.defaultData(),
        };
    }
    dataType(data) {
        return this.ops.type(data);
    }
    toString(cellData, colData) {
        return this.ops.cellToString(cellData, colData);
    }
    toJson(cellData, colData) {
        return this.ops.cellToJson(cellData, colData);
    }
    formatValue(cellData, colData) {
        return cellData === undefined
            ? undefined
            : this.ops.formatValue?.(cellData, colData) ?? cellData;
    }
    fromString(cellData, colData) {
        return this.ops.cellFromString(cellData, colData);
    }
    convertCell(to, column, cells) {
        return this.convertMap.get(to)?.(column, cells);
    }
    registerConvert(to, 
    // @ts-expect-error
    convert) {
        this.convertMap.set(to, convert);
    }
    get name() {
        return this.ops.name;
    }
}
export const columnManager = new ColumnConfigManager();
//# sourceMappingURL=manager.js.map