// SPDX-License-Identifier: Apache-2.0
import { VersionRange } from '../../../../../business/utils/version-range.js';
import { SemanticVersion } from '../../../../../business/utils/semantic-version.js';
import { IllegalArgumentError } from '../../../../../business/errors/illegal-argument-error.js';
import { InvalidSchemaVersionError } from '../../api/invalid-schema-version-error.js';
export class SoloConfigV1Migration {
    get range() {
        return VersionRange.fromIntegerVersion(0);
    }
    get version() {
        return new SemanticVersion(1);
    }
    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');
        }
        const clone = structuredClone(source);
        if (clone.schemaVersion && clone.schemaVersion !== 0) {
            // this case should never happen considering the field was not present in version 0 and should default to zero
            // during this migration
            throw new InvalidSchemaVersionError(clone.schemaVersion, 0);
        }
        // Set the schema version to the new version
        clone.schemaVersion = this.version.major;
        clone.helmChart ||= this.getNewHelmChartObject();
        clone.ingressControllerHelmChart ||= this.getNewHelmChartObject();
        clone.clusterSetupHelmChart ||= this.getNewHelmChartObject();
        clone.certManagerHelmChart ||= this.getNewHelmChartObject();
        clone.tss ||= this.getNewTssObject();
        return clone;
    }
    getNewTssObject() {
        return {
            messageSizeSoftLimitBytes: 4_194_304,
            messageSizeHardLimitBytes: 37_748_736,
            timeoutAfterReadySeconds: 10,
            readyMaxAttempts: 60,
            readyBackoffSeconds: 3,
            wraps: {
                artifactsFolderName: 'wraps-v0.2.0',
                directoryName: 'wraps-v0.2.0',
                allowedKeyFiles: 'decider_pp.bin,decider_vp.bin,nova_pp.bin,nova_vp.bin',
                // IMPORTANT: libraryDownloadUrl must be kept consistent with directoryName.
                libraryDownloadUrl: 'https://builds.hedera.com/tss/hiero/wraps/v0.2/wraps-v0.2.0.tar.gz',
            },
        };
    }
    getNewHelmChartObject() {
        return {
            name: undefined,
            namespace: undefined,
            release: undefined,
            repository: undefined,
            directory: undefined,
            version: undefined,
            labelSelector: undefined,
            containerName: undefined,
            ingressClassName: undefined,
            ingressControllerName: undefined,
            ingressControllerPrefix: undefined,
        };
    }
}
//# sourceMappingURL=solo-config-v1-migration.js.map