import { cloneEngineTableRecord, workbookChartsEqual, workbookImagesEqual, workbookShapesEqual, workbookTablesEqual, } from './engine-workbook-object-helpers.js';
export function buildSetTableOps(workbook, table) {
    const existing = workbook.getTable(table.name);
    if (workbookTablesEqual(existing, table)) {
        return [];
    }
    return [
        {
            kind: 'upsertTable',
            table: cloneEngineTableRecord(table),
        },
    ];
}
export function buildDeleteTableOps(workbook, name) {
    if (!workbook.getTable(name)) {
        return null;
    }
    return [{ kind: 'deleteTable', name }];
}
export function buildSetChartOps(workbook, chart) {
    const existing = workbook.getChart(chart.id);
    if (workbookChartsEqual(existing, chart)) {
        return [];
    }
    return [{ kind: 'upsertChart', chart: structuredClone(chart) }];
}
export function buildDeleteChartOps(workbook, id) {
    if (!workbook.getChart(id)) {
        return null;
    }
    return [{ kind: 'deleteChart', id }];
}
export function buildSetImageOps(workbook, image) {
    const existing = workbook.getImage(image.id);
    if (workbookImagesEqual(existing, image)) {
        return [];
    }
    return [{ kind: 'upsertImage', image: structuredClone(image) }];
}
export function buildDeleteImageOps(workbook, id) {
    if (!workbook.getImage(id)) {
        return null;
    }
    return [{ kind: 'deleteImage', id }];
}
export function buildSetShapeOps(workbook, shape) {
    const existing = workbook.getShape(shape.id);
    if (workbookShapesEqual(existing, shape)) {
        return [];
    }
    return [{ kind: 'upsertShape', shape: structuredClone(shape) }];
}
export function buildDeleteShapeOps(workbook, id) {
    if (!workbook.getShape(id)) {
        return null;
    }
    return [{ kind: 'deleteShape', id }];
}
//# sourceMappingURL=engine-workbook-object-metadata-ops.js.map