import { clonePropertyRecord, cloneWorkbookProtectionRecord } from './workbook-metadata-records.js';
import { normalizeMetadataKey } from './workbook-metadata-service-helpers.js';
export function setWorkbookPropertyRecord(metadata, key, value) {
    const trimmedKey = normalizeMetadataKey(key);
    if (value === null) {
        metadata.properties.delete(trimmedKey);
        return undefined;
    }
    const record = { key: trimmedKey, value };
    metadata.properties.set(trimmedKey, record);
    return clonePropertyRecord(record);
}
export function getWorkbookPropertyRecord(metadata, key) {
    const record = metadata.properties.get(normalizeMetadataKey(key));
    return record ? clonePropertyRecord(record) : undefined;
}
export function listWorkbookPropertyRecords(metadata) {
    return [...metadata.properties.values()].toSorted((left, right) => left.key.localeCompare(right.key)).map(clonePropertyRecord);
}
export function setWorkbookProtectionRecord(metadata, record) {
    const stored = cloneWorkbookProtectionRecord(record);
    metadata.workbookProtection = stored;
    return cloneWorkbookProtectionRecord(stored);
}
export function getWorkbookProtectionRecord(metadata) {
    return metadata.workbookProtection ? cloneWorkbookProtectionRecord(metadata.workbookProtection) : undefined;
}
//# sourceMappingURL=workbook-metadata-workbook-records.js.map