export var RuleType;
(function (RuleType) {
  RuleType["comparison"] = "comparison";
  RuleType["conditionalComparison"] = "conditionalComparison";
})(RuleType || (RuleType = {}));
export var FieldType;
(function (FieldType) {
  FieldType["number"] = "number";
  FieldType["range"] = "range";
  FieldType["singleChoice"] = "single-choice";
  FieldType["multipleChoice"] = "multipleChoice";
  FieldType["text"] = "text";
})(FieldType || (FieldType = {}));
export var Comparison;
(function (Comparison) {
  Comparison["eq"] = "eq";
  Comparison["ne"] = "ne";
  Comparison["lt"] = "lt";
  Comparison["lte"] = "lte";
  Comparison["gt"] = "gt";
  Comparison["gte"] = "gte";
  Comparison["in"] = "in";
  Comparison["contain"] = "contain";
  Comparison["ncontain"] = "ncontain";
  Comparison["similar"] = "similar";
  Comparison["different"] = "different";
})(Comparison || (Comparison = {}));
export class Rule {
  constructor(comparisons, type) {
    this.comparisons = comparisons;
    this.type = type;
  }
  static decode(json) {
    return Object.assign(Object.create(Rule.prototype), json);
  }
  isValid() {
    if (this.type === RuleType.comparison) {
      // if this is a comparison rule, it should contain one
      // comparison and that should contain firstField, secondField and comparison
      return this.comparisons.length === 1
        && !!this.comparisons[0].firstField
        && !!this.comparisons[0].secondField
        && !!this.comparisons[0].comparison;
    }
    return true;
  }
}
export class PairIdHolder {
  constructor(firstUserId, secondUserId) {
    this.match = (firstUserId, secondUserId) => this.firstUserId === firstUserId && this.secondUserId === secondUserId;
    this.toTuple = () => PairIdHolder.generateTuple(this.firstUserId, this.secondUserId);
    this.firstUserId = firstUserId;
    this.secondUserId = secondUserId;
  }
}
PairIdHolder.generateTuple = (firstUserId, secondUserId) => `${firstUserId}:${secondUserId}`;
