// SPDX-License-Identifier: Apache-2.0
import { VersionRange } from '../../../../../business/utils/version-range.js';
import { Version } from '../../../../../business/utils/version.js';
import { IllegalArgumentError } from '../../../../../business/errors/illegal-argument-error.js';
export class RemoteConfigV4Migration {
    get range() {
        return VersionRange.fromIntegerVersion(3);
    }
    get version() {
        return new Version(4);
    }
    async migrate(source) {
        if (!source) {
            // We should never pass null or undefined to this method, if this happens we should throw an error
            throw new IllegalArgumentError('source must not be null or undefined');
        }
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        const clone = structuredClone(source);
        const state = clone.state;
        for (const node of state.consensusNodes) {
            node.blockNodeMap = state.blockNodes.map((node) => [node.metadata.id, 1]);
        }
        // Set the schema version to the new version
        clone.schemaVersion = this.version.value;
        return clone;
    }
}
//# sourceMappingURL=remote-config-v4-migration.js.map