"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CfnPipePropsMixin = void 0;
const jsiiDeprecationWarnings = require("../../../.warnings.jsii.js");
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
/* eslint-disable @stylistic/max-len, eol-last */
const cdk = __importStar(require("aws-cdk-lib/core"));
const service = __importStar(require("aws-cdk-lib/aws-pipes"));
/**
 * Specifies a pipe.
 *
 * Amazon EventBridge Pipes connect event sources to targets and reduces the need for specialized knowledge and integration code.
 *
 * > As an aid to help you jumpstart developing CloudFormation templates, the EventBridge console enables you to create templates from the existing pipes in your account. For more information, see [Generate an CloudFormation template from EventBridge Pipes](https://docs.aws.amazon.com/eventbridge/latest/userguide/pipes-generate-template.html) in the *Amazon EventBridge User Guide* .
 *
 * @cloudformationResource AWS::Pipes::Pipe
 * @mixin true
 * @stability external
 * @see http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-pipes-pipe.html
 */
class CfnPipePropsMixin extends cdk.Mixin {
    static [JSII_RTTI_SYMBOL_1] = { fqn: "@aws-cdk/cfn-property-mixins.aws_pipes.CfnPipePropsMixin", version: "2.258.1" };
    static CFN_PROPERTY_KEYS = ["description", "desiredState", "enrichment", "enrichmentParameters", "kmsKeyIdentifier", "logConfiguration", "name", "roleArn", "source", "sourceParameters", "tags", "target", "targetParameters"];
    props;
    strategy;
    /**
     * Create a mixin to apply properties to `AWS::Pipes::Pipe`.
     *
     * @param props L1 properties to apply
     * @param options Mixin options
     */
    constructor(props, options = {}) {
        super();
        try {
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_aws_pipes_CfnPipeMixinProps(props);
            jsiiDeprecationWarnings._aws_cdk_cfn_property_mixins_CfnPropertyMixinOptions(options);
        }
        catch (error) {
            if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
                Error.captureStackTrace(error, CfnPipePropsMixin);
            }
            throw error;
        }
        this.props = {
            ...props,
            ...flattenCfnPipeMixinProps(props)
        };
        this.strategy = (options.strategy ?? cdk.PropertyMergeStrategy.combine());
    }
    /**
     * Check if this mixin supports the given construct
     */
    supports(construct) {
        return (cdk.CfnResource.isCfnResource(construct) && service.CfnPipe.isCfnPipe(construct));
    }
    /**
     * Apply the mixin properties to the construct
     */
    applyTo(construct) {
        if (this.supports(construct)) {
            this.strategy.apply(construct, this.props, CfnPipePropsMixin.CFN_PROPERTY_KEYS);
        }
    }
}
exports.CfnPipePropsMixin = CfnPipePropsMixin;
// @ts-ignore TS6133
function flattenCfnPipePropsMixinDeadLetterConfigProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        arn: (!props.arn ? undefined : cdk.getRefProperty(props.arn?.queueRef, 'queueArn') ?? cdk.ensureStringOrUndefined(props.arn, "arn", "sqs.IQueueRef | string"))
    };
}
// @ts-ignore TS6133
function flattenCfnPipePropsMixinPipeSourceDynamoDBStreamParametersProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        batchSize: (!props.batchSize ? undefined : props.batchSize),
        deadLetterConfig: (!props.deadLetterConfig ? undefined : (!props.deadLetterConfig ? undefined : flattenCfnPipePropsMixinDeadLetterConfigProperty(props.deadLetterConfig))),
        maximumBatchingWindowInSeconds: (!props.maximumBatchingWindowInSeconds ? undefined : props.maximumBatchingWindowInSeconds),
        maximumRecordAgeInSeconds: (!props.maximumRecordAgeInSeconds ? undefined : props.maximumRecordAgeInSeconds),
        maximumRetryAttempts: (!props.maximumRetryAttempts ? undefined : props.maximumRetryAttempts),
        onPartialBatchItemFailure: (!props.onPartialBatchItemFailure ? undefined : props.onPartialBatchItemFailure),
        parallelizationFactor: (!props.parallelizationFactor ? undefined : props.parallelizationFactor),
        startingPosition: (!props.startingPosition ? undefined : props.startingPosition)
    };
}
// @ts-ignore TS6133
function flattenCfnPipePropsMixinPipeSourceKinesisStreamParametersProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        batchSize: (!props.batchSize ? undefined : props.batchSize),
        deadLetterConfig: (!props.deadLetterConfig ? undefined : (!props.deadLetterConfig ? undefined : flattenCfnPipePropsMixinDeadLetterConfigProperty(props.deadLetterConfig))),
        maximumBatchingWindowInSeconds: (!props.maximumBatchingWindowInSeconds ? undefined : props.maximumBatchingWindowInSeconds),
        maximumRecordAgeInSeconds: (!props.maximumRecordAgeInSeconds ? undefined : props.maximumRecordAgeInSeconds),
        maximumRetryAttempts: (!props.maximumRetryAttempts ? undefined : props.maximumRetryAttempts),
        onPartialBatchItemFailure: (!props.onPartialBatchItemFailure ? undefined : props.onPartialBatchItemFailure),
        parallelizationFactor: (!props.parallelizationFactor ? undefined : props.parallelizationFactor),
        startingPosition: (!props.startingPosition ? undefined : props.startingPosition),
        startingPositionTimestamp: (!props.startingPositionTimestamp ? undefined : props.startingPositionTimestamp)
    };
}
// @ts-ignore TS6133
function flattenCfnPipePropsMixinPipeSourceParametersProperty(props) {
    if (cdk.isResolvableObject(props))
        return props;
    return {
        activeMqBrokerParameters: (!props.activeMqBrokerParameters ? undefined : props.activeMqBrokerParameters),
        dynamoDbStreamParameters: (!props.dynamoDbStreamParameters ? undefined : (!props.dynamoDbStreamParameters ? undefined : flattenCfnPipePropsMixinPipeSourceDynamoDBStreamParametersProperty(props.dynamoDbStreamParameters))),
        filterCriteria: (!props.filterCriteria ? undefined : props.filterCriteria),
        kinesisStreamParameters: (!props.kinesisStreamParameters ? undefined : (!props.kinesisStreamParameters ? undefined : flattenCfnPipePropsMixinPipeSourceKinesisStreamParametersProperty(props.kinesisStreamParameters))),
        managedStreamingKafkaParameters: (!props.managedStreamingKafkaParameters ? undefined : props.managedStreamingKafkaParameters),
        rabbitMqBrokerParameters: (!props.rabbitMqBrokerParameters ? undefined : props.rabbitMqBrokerParameters),
        selfManagedKafkaParameters: (!props.selfManagedKafkaParameters ? undefined : props.selfManagedKafkaParameters),
        sqsQueueParameters: (!props.sqsQueueParameters ? undefined : props.sqsQueueParameters)
    };
}
// @ts-ignore TS6133
function flattenCfnPipeMixinProps(props) {
    const ret = {};
    if ((props.enrichment !== undefined))
        ret.enrichment = cdk.getRefProperty(props.enrichment?.functionRef, 'functionArn') ?? cdk.ensureStringOrUndefined(props.enrichment, "enrichment", "lambda.IFunctionRef | string");
    if ((props.roleArn !== undefined))
        ret.roleArn = cdk.getRefProperty(props.roleArn?.roleRef, 'roleArn') ?? cdk.ensureStringOrUndefined(props.roleArn, "roleArn", "iam.IRoleRef | string");
    if ((props.source !== undefined))
        ret.source = cdk.getRefProperty(props.source?.queueRef, 'queueArn') ?? cdk.getRefProperty(props.source?.streamRef, 'streamArn') ?? cdk.ensureStringOrUndefined(props.source, "source", "sqs.IQueueRef | kinesis.IStreamRef | string");
    if ((props.sourceParameters !== undefined))
        ret.sourceParameters = flattenCfnPipePropsMixinPipeSourceParametersProperty(props.sourceParameters);
    if ((props.target !== undefined))
        ret.target = cdk.getRefProperty(props.target?.logGroupRef, 'logGroupArn') ?? cdk.getRefProperty(props.target?.functionRef, 'functionArn') ?? cdk.getRefProperty(props.target?.stateMachineRef, 'stateMachineArn') ?? cdk.getRefProperty(props.target?.eventBusRef, 'eventBusArn') ?? cdk.getRefProperty(props.target?.queueRef, 'queueArn') ?? cdk.getRefProperty(props.target?.topicRef, 'topicArn') ?? cdk.ensureStringOrUndefined(props.target, "target", "logs.ILogGroupRef | lambda.IFunctionRef | stepfunctions.IStateMachineRef | events.IEventBusRef | sqs.IQueueRef | sns.ITopicRef | string");
    return ret;
}
