<commit_before>/**
 * All editors should extend from this class
 */
JSONEditor.AbstractEditor = Class.extend({
  onChildEditorChange: function(editor) {
    this.onChange(true);
  },
  notify: function() {
    if(this.path) this.jsoneditor.notifyWatchers(this.path);
  },
  change: function() {
    if(this.parent) this.parent.onChildEditorChange(this);
    else if(this.jsoneditor) this.jsoneditor.onChange();
  },
  onChange: function(bubble) {
    this.notify();
    if(this.watch_listener) this.watch_listener();
    if(bubble) this.change();
  },
  register: function() {
    this.jsoneditor.registerEditor(this);
    this.onChange();
  },
  unregister: function() {
    if(!this.jsoneditor) return;
    this.jsoneditor.unregisterEditor(this);
  },
  getNumColumns: function() {
    return 12;
  },
  isActive: function() {
    return this.active;
  },
  activate: function() {
    this.active = true;
    this.optInCheckbox.checked = true;
    this.enable();
    this.change();
  },
  deactivate: function() {
    // only non required properties can be deactivated.
    if (!this.isRequired()) {
      this.active = false;
      this.optInCheckbox.checked = false;
      this.disable();
      this.change();
    }
  },
  init: function(options) {
    this.jsoneditor = options.jsoneditor;

    this.theme = this.jsoneditor.theme;
    this.template_engine = this.jsoneditor.template;
    this.iconlib = this.jsoneditor.iconlib;

    this.translate = this.jsoneditor.translate || JSONEditor.defaults.translate;

    this.original_schema = options.schema;
    this.schema = this.jsoneditor.expandSchema(this.original_schema);

    this.active = true;

    this.options = $extend({}, (this.options || {}), (this.schema.options || {}), (options.schema.options || {}), options);

    if(!options.path && !this.schema.id) this.schema.id = 'root';
    this.path = options.path || 'root';
    this.formname = options.formname || this.path.replace(/\.([^.]+)/g,'[$1]');
    if(this.jsoneditor.options.form_name_root) this.formname = this.formname.replace(/^root\[/,this.jsoneditor.options.form_name_root+'[');
    this.key = this.path.split('.').pop();
    this.parent = options.parent;

    this.link_watchers = [];

    if(options.container) this.setContainer(options.container);
    this.registerDependencies();
  },
  registerDependencies: function() {
    this.dependenciesFulfilled = true;
    var deps = this.options.dependencies;
    if (!deps) {
      return;
    }

    var self = this;
    Object.keys(deps).forEach(function(dependency) {
      var path = self.path.split('.');
      path[path.length - 1] = dependency;
      path = path.join('.');
      var choices = deps[dependency];
      self.jsoneditor.watch(path, function() {
        self.checkDependency(path, choices);
      });
    });
  },
  checkDependency: function(path, choices) {
    var wrapper = this.control || this.container;
    if (this.path === path || !wrapper || this.jsoneditor === null) {   
      return;
    }

    var self = this;
    var editor = this.jsoneditor.getEditor(path);
    var value = editor ? editor.getValue() : undefined;
    var previousStatus = this.dependenciesFulfilled;
    this.dependenciesFulfilled = false;

    if (!editor || !editor.dependenciesFulfilled) {
      this.dependenciesFulfilled = false;
    } else if (Array.isArray(choices)) {
      choices.some(function(choice) {
        if (value === choice) {
          self.dependenciesFulfilled = true;
          return true;
        }
      });
    } else if (typeof choices === 'object') {
      if (typeof value !== 'object') {<commit_msg>Fix of #365<commit_after>/**
 * All editors should extend from this class
 */
JSONEditor.AbstractEditor = Class.extend({
  onChildEditorChange: function(editor) {
    this.onChange(true);
  },
  notify: function() {
    if(this.path) this.jsoneditor.notifyWatchers(this.path);
  },
  change: function() {
    if(this.parent) this.parent.onChildEditorChange(this);
    else if(this.jsoneditor) this.jsoneditor.onChange();
  },
  onChange: function(bubble) {
    this.notify();
    if(this.watch_listener) this.watch_listener();
    if(bubble) this.change();
  },
  register: function() {
    this.jsoneditor.registerEditor(this);
    this.onChange();
  },
  unregister: function() {
    if(!this.jsoneditor) return;
    this.jsoneditor.unregisterEditor(this);
  },
  getNumColumns: function() {
    return 12;
  },
  isActive: function() {
    return this.active;
  },
  activate: function() {
    this.active = true;
    this.optInCheckbox.checked = true;
    this.enable();
    this.change();
  },
  deactivate: function() {
    // only non required properties can be deactivated.
    if (!this.isRequired()) {
      this.active = false;
      this.optInCheckbox.checked = false;
      this.disable();
      this.change();
    }
  },
  init: function(options) {
    this.jsoneditor = options.jsoneditor;

    this.theme = this.jsoneditor.theme;
    this.template_engine = this.jsoneditor.template;
    this.iconlib = this.jsoneditor.iconlib;

    this.translate = this.jsoneditor.translate || JSONEditor.defaults.translate;

    this.original_schema = options.schema;
    this.schema = this.jsoneditor.expandSchema(this.original_schema);

    this.active = true;

    this.options = $extend({}, (this.options || {}), (this.schema.options || {}), (options.schema.options || {}), options);

    if(!options.path && !this.schema.id) this.schema.id = 'root';
    this.path = options.path || 'root';
    this.formname = options.formname || this.path.replace(/\.([^.]+)/g,'[$1]');
    if(this.jsoneditor.options.form_name_root) this.formname = this.formname.replace(/^root\[/,this.jsoneditor.options.form_name_root+'[');
    this.key = this.path.split('.').pop();
    this.parent = options.parent;

    this.link_watchers = [];

    if(options.container) this.setContainer(options.container);
    this.registerDependencies();
  },
  registerDependencies: function() {
    this.dependenciesFulfilled = true;
    var deps = this.options.dependencies;
    if (!deps) {
      return;
    }

    var self = this;
    Object.keys(deps).forEach(function(dependency) {
      var path = self.path.split('.');
      path[path.length - 1] = dependency;
      path = path.join('.');
      var choices = deps[dependency];
      self.jsoneditor.watch(path, function() {
        self.checkDependency(path, choices);
      });
    });
  },
  checkDependency: function(path, choices) {
    var wrapper = this.container || this.control;
    if (this.path === path || !wrapper || this.jsoneditor === null) {   
      return;
    }

    var self = this;
    var editor = this.jsoneditor.getEditor(path);
    var value = editor ? editor.getValue() : undefined;
    var previousStatus = this.dependenciesFulfilled;
    this.dependenciesFulfilled = false;

    if (!editor || !editor.dependenciesFulfilled) {
      this.dependenciesFulfilled = false;
    } else if (Array.isArray(choices)) {
      choices.some(function(choice) {
        if (value === choice) {
          self.dependenciesFulfilled = true;
          return true;
        }
      });
    } else if (typeof choices === 'object') {
      if (typeof value !== 'object') {
{'fraction_non_alphanumeric': 0.15372886054893264, 'fraction_numerical': 0.001524812863875797, 'mean_word_length': 3.1064314171883893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '599922', 'n_tokens_mistral': 2252, 'n_tokens_neox': 2207, 'n_words': 408}