// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe-neo';
import { patchInject } from '../../dependency-injection/container-helper.js';
import { InjectTokens } from '../../dependency-injection/inject-tokens.js';
import { ComponentTypes } from './enumerations/component-types.js';
import { DeploymentPhase } from '../../../data/schema/model/remote/deployment-phase.js';
import { ComponentStateMetadataSchema } from '../../../data/schema/model/remote/state/component-state-metadata-schema.js';
import { RelayNodeStateSchema } from '../../../data/schema/model/remote/state/relay-node-state-schema.js';
import { ExplorerStateSchema } from '../../../data/schema/model/remote/state/explorer-state-schema.js';
import { MirrorNodeStateSchema } from '../../../data/schema/model/remote/state/mirror-node-state-schema.js';
import { HaProxyStateSchema } from '../../../data/schema/model/remote/state/ha-proxy-state-schema.js';
import { EnvoyProxyStateSchema } from '../../../data/schema/model/remote/state/envoy-proxy-state-schema.js';
import { ConsensusNodeStateSchema } from '../../../data/schema/model/remote/state/consensus-node-state-schema.js';
import { BlockNodeStateSchema } from '../../../data/schema/model/remote/state/block-node-state-schema.js';
import { Templates } from '../../templates.js';
let ComponentFactory = class ComponentFactory {
    remoteConfig;
    constructor(remoteConfig) {
        this.remoteConfig = remoteConfig;
        this.remoteConfig = patchInject(remoteConfig, InjectTokens.RemoteConfigRuntimeState, this.constructor.name);
    }
    createNewRelayComponent(clusterReference, namespace, nodeIds) {
        return new RelayNodeStateSchema(this.getMetadata(ComponentTypes.RelayNodes, clusterReference, namespace), nodeIds);
    }
    createNewExplorerComponent(clusterReference, namespace) {
        return new ExplorerStateSchema(this.getMetadata(ComponentTypes.Explorer, clusterReference, namespace));
    }
    createNewMirrorNodeComponent(clusterReference, namespace) {
        return new MirrorNodeStateSchema(this.getMetadata(ComponentTypes.MirrorNode, clusterReference, namespace));
    }
    createNewHaProxyComponent(clusterReference, namespace) {
        return new HaProxyStateSchema(this.getMetadata(ComponentTypes.HaProxy, clusterReference, namespace));
    }
    createNewEnvoyProxyComponent(clusterReference, namespace) {
        return new EnvoyProxyStateSchema(this.getMetadata(ComponentTypes.EnvoyProxy, clusterReference, namespace));
    }
    createNewBlockNodeComponent(clusterReference, namespace) {
        return new BlockNodeStateSchema(this.getMetadata(ComponentTypes.BlockNode, clusterReference, namespace));
    }
    createNewConsensusNodeComponent(id, clusterReference, namespace, phase, portForwardConfigs, blockNodeMap = [], externalBlockNodeMap = []) {
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase, portForwardConfigs);
        return new ConsensusNodeStateSchema(metadata, blockNodeMap, externalBlockNodeMap);
    }
    createConsensusNodeComponentsFromNodeIds(nodeIds, clusterReference, namespace, portForwardConfigs) {
        return nodeIds.map((nodeId) => this.createNewConsensusNodeComponent(Templates.renderComponentIdFromNodeId(nodeId), clusterReference, namespace, DeploymentPhase.REQUESTED, portForwardConfigs));
    }
    getMetadata(componentType, clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(componentType);
        const phase = DeploymentPhase.DEPLOYED;
        return new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
    }
};
ComponentFactory = __decorate([
    injectable(),
    __param(0, inject(InjectTokens.RemoteConfigRuntimeState)),
    __metadata("design:paramtypes", [Object])
], ComponentFactory);
export { ComponentFactory };
//# sourceMappingURL=component-factory.js.map