text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const pope_1 = require("pope");
  const lodash_set_1 = __importDefault(require("lodash.set"));
  class Collector {
      constructor(formatter, _generateTree) {
          this.formatter = formatter;
          this._generateTree = _generateTree;
          this.tree = {};
          this.hasErrors = false;
      }
      setValue(pointer, value) {
          if (!this._generateTree || value === undefined || this.hasErrors) {
              return;
          }
          pointer = pointer.replace('.::tip::', '');
          lodash_set_1.default(this.tree, pointer, value);
      }
      getData() {
          return this.tree;
      }
      getErrors() {
          return this.formatter.toJSON();
      }
      setError(pointer, rule, message) {
          this.hasErrors = true;
          if (message && typeof (message) === 'string') {
              message = pope_1.pope(message, {
                  field: pointer,
                  args: rule.args,
                  validation: rule.name,
              });
          }
          message = message || `${rule.name} validation failed on ${pointer}`;
          message = typeof (message) === 'function' ? message(pointer, rule.name, rule.args) : message;
          this.formatter.addError(message, pointer, rule.name, rule.args);
      }
  }
  exports.Collector = Collector;
  