export var MetricPipelineRuleFilterCheckOn;
(function (MetricPipelineRuleFilterCheckOn) {
    MetricPipelineRuleFilterCheckOn["MetricName"] = "Metric Name";
    MetricPipelineRuleFilterCheckOn["Attribute"] = "Attribute";
})(MetricPipelineRuleFilterCheckOn || (MetricPipelineRuleFilterCheckOn = {}));
export var MetricPipelineRuleFilterConditionType;
(function (MetricPipelineRuleFilterConditionType) {
    MetricPipelineRuleFilterConditionType["EqualTo"] = "Equal To";
    MetricPipelineRuleFilterConditionType["NotEqualTo"] = "Not Equal To";
    MetricPipelineRuleFilterConditionType["Contains"] = "Contains";
    MetricPipelineRuleFilterConditionType["NotContains"] = "Not Contains";
    MetricPipelineRuleFilterConditionType["StartsWith"] = "Starts With";
    MetricPipelineRuleFilterConditionType["EndsWith"] = "Ends With";
    MetricPipelineRuleFilterConditionType["MatchesRegex"] = "Matches Regex";
    MetricPipelineRuleFilterConditionType["DoesNotMatchRegex"] = "Does Not Match Regex";
    MetricPipelineRuleFilterConditionType["IsPresent"] = "Is Present";
    MetricPipelineRuleFilterConditionType["IsNotPresent"] = "Is Not Present";
    MetricPipelineRuleFilterConditionType["IsEmpty"] = "Is Empty";
    MetricPipelineRuleFilterConditionType["IsNotEmpty"] = "Is Not Empty";
})(MetricPipelineRuleFilterConditionType || (MetricPipelineRuleFilterConditionType = {}));
export class MetricPipelineRuleFilterConditionUtil {
    static getCheckOnOptions() {
        return [
            MetricPipelineRuleFilterCheckOn.MetricName,
            MetricPipelineRuleFilterCheckOn.Attribute,
        ];
    }
    static getConditionTypesByCheckOn(checkOn) {
        switch (checkOn) {
            case MetricPipelineRuleFilterCheckOn.MetricName:
                return [
                    MetricPipelineRuleFilterConditionType.EqualTo,
                    MetricPipelineRuleFilterConditionType.NotEqualTo,
                    MetricPipelineRuleFilterConditionType.Contains,
                    MetricPipelineRuleFilterConditionType.NotContains,
                    MetricPipelineRuleFilterConditionType.StartsWith,
                    MetricPipelineRuleFilterConditionType.EndsWith,
                    MetricPipelineRuleFilterConditionType.MatchesRegex,
                    MetricPipelineRuleFilterConditionType.DoesNotMatchRegex,
                ];
            case MetricPipelineRuleFilterCheckOn.Attribute:
                return [
                    MetricPipelineRuleFilterConditionType.IsPresent,
                    MetricPipelineRuleFilterConditionType.IsNotPresent,
                    MetricPipelineRuleFilterConditionType.IsEmpty,
                    MetricPipelineRuleFilterConditionType.IsNotEmpty,
                    MetricPipelineRuleFilterConditionType.EqualTo,
                    MetricPipelineRuleFilterConditionType.NotEqualTo,
                    MetricPipelineRuleFilterConditionType.Contains,
                    MetricPipelineRuleFilterConditionType.NotContains,
                    MetricPipelineRuleFilterConditionType.StartsWith,
                    MetricPipelineRuleFilterConditionType.EndsWith,
                    MetricPipelineRuleFilterConditionType.MatchesRegex,
                    MetricPipelineRuleFilterConditionType.DoesNotMatchRegex,
                ];
            default:
                return [];
        }
    }
    static hasAttributeKeyField(checkOn) {
        return checkOn === MetricPipelineRuleFilterCheckOn.Attribute;
    }
    static hasValueField(conditionType) {
        if (!conditionType) {
            return false;
        }
        switch (conditionType) {
            case MetricPipelineRuleFilterConditionType.IsPresent:
            case MetricPipelineRuleFilterConditionType.IsNotPresent:
            case MetricPipelineRuleFilterConditionType.IsEmpty:
            case MetricPipelineRuleFilterConditionType.IsNotEmpty:
                return false;
            default:
                return true;
        }
    }
    static getValidationError(filters) {
        var _a, _b;
        if (!filters || filters.length === 0) {
            return null;
        }
        for (let i = 0; i < filters.length; i++) {
            const filter = filters[i];
            const prefix = `Filter #${i + 1}: `;
            if (!filter.checkOn) {
                return `${prefix}Filter type is required.`;
            }
            if (!filter.conditionType) {
                return `${prefix}Condition is required.`;
            }
            if (MetricPipelineRuleFilterConditionUtil.hasAttributeKeyField(filter.checkOn) &&
                !((_a = filter.attributeKey) === null || _a === void 0 ? void 0 : _a.trim())) {
                return `${prefix}Attribute key is required.`;
            }
            if (MetricPipelineRuleFilterConditionUtil.hasValueField(filter.conditionType) &&
                !((_b = filter.value) === null || _b === void 0 ? void 0 : _b.toString().trim())) {
                return `${prefix}Value is required.`;
            }
        }
        return null;
    }
}
//# sourceMappingURL=MetricPipelineRuleFilterCondition.js.map