import { canonicalWorkbookAddress } from './workbook-range-records.js';
export const preservedWorkbookMetadataKeys = [
    'documentPropertyArtifacts',
    'externalWorkbookReferences',
    'unsupportedFormulaDependencies',
    'unsupportedPivots',
    'formulaAudit',
    'externalConnections',
    'pivotArtifacts',
    'chartArtifacts',
    'chartSheetArtifacts',
    'dataModelArtifacts',
    'slicerConnectionArtifacts',
    'viewState',
    'styleArtifacts',
];
export const preservedSheetMetadataKeys = ['styleArtifacts', 'pivotArtifacts', 'viewState'];
export function createWorkbookMetadataRecord() {
    return {
        properties: new Map(),
        workbookProtection: undefined,
        macroPayloads: new Map(),
        definedNames: new Map(),
        tables: new Map(),
        spills: new Map(),
        pivots: new Map(),
        charts: new Map(),
        images: new Map(),
        shapes: new Map(),
        drawingArtifacts: undefined,
        controlArtifacts: undefined,
        externalLinkArtifacts: undefined,
        threadedCommentArtifacts: undefined,
        cellMetadata: undefined,
        preservedWorkbookMetadata: {},
        preservedSheetMetadata: new Map(),
        sheetThreadedCommentArtifacts: new Map(),
        sheetLegacyCommentVml: new Map(),
        sheetDrawingArtifacts: new Map(),
        rowMetadata: new Map(),
        columnMetadata: new Map(),
        calculationSettings: { mode: 'automatic', compatibilityMode: 'excel-modern' },
        volatileContext: { recalcEpoch: 0 },
        freezePanes: new Map(),
        sheetTabColors: new Map(),
        merges: new Map(),
        sheetProtections: new Map(),
        filters: new Map(),
        sorts: new Map(),
        dataValidations: new Map(),
        conditionalFormats: new Map(),
        conditionalFormatArtifacts: new Map(),
        rangeProtections: new Map(),
        commentThreads: new Map(),
        notes: new Map(),
        hyperlinks: new Map(),
    };
}
export function normalizeDefinedName(name) {
    return normalizeWorkbookObjectName(name, 'Defined names');
}
export function normalizeDefinedNameScope(scopeSheetName) {
    const scope = scopeSheetName?.trim();
    return scope && scope.length > 0 ? scope : undefined;
}
export function definedNameKey(name, scopeSheetName) {
    return `${normalizeDefinedNameScope(scopeSheetName) ?? '<workbook>'}\u0000${normalizeDefinedName(name)}`;
}
export function compareDefinedNameRecords(left, right) {
    return (normalizeDefinedName(left.name).localeCompare(normalizeDefinedName(right.name)) ||
        (left.scopeSheetName ?? '').localeCompare(right.scopeSheetName ?? ''));
}
export function normalizeWorkbookObjectName(name, label = 'Workbook object') {
    const normalized = name.trim().toUpperCase();
    if (normalized.length === 0) {
        throw new Error(`${label} must be non-empty`);
    }
    return normalized;
}
export function macroPayloadKey(kind) {
    return normalizeWorkbookObjectName(kind, 'Macro payloads');
}
export function pivotKey(sheetName, address) {
    return `${sheetName}!${canonicalWorkbookAddress(sheetName, address)}`;
}
export function chartKey(id) {
    return normalizeWorkbookObjectName(id, 'Charts');
}
export function imageKey(id) {
    return normalizeWorkbookObjectName(id, 'Images');
}
export function shapeKey(id) {
    return normalizeWorkbookObjectName(id, 'Shapes');
}
//# sourceMappingURL=workbook-metadata-types.js.map