<commit_before><polymer-element name="noflo-library" attributes="editor search">
  <script>
    Polymer('noflo-library', {
      search: '',
      editor: null,
      addNode: function (component) {
        var num = 60466176; // 36^5
        num = Math.floor(Math.random() * num);
        var id = component + '_' + num.toString(36);

        // TODO fix with pan
        var pan = this.editor.$.graph.getPan();

        this.editor.graph.addNode(id, component, {
          label: component,
          x: -pan[0] + 334,
          y: -pan[1] + 100
        });
      },
      searchChanged: function () {
        if (!this.search || typeof this.search !== 'string') {
          return;
        }
        if (!this.editor) {
          return;
        }
        Object.keys(this.editor.library).forEach(function (component) {
          if (this.search !== 'show library' && component.toLowerCase().indexOf(this.search.toLowerCase()) === -1) {
            return;
          }
          this.fire('result', {
            label: component,
            icon: this.editor.library[component].icon,
            description: this.editor.library[component].description,
            action: function () {
              this.addNode(component);
            }.bind(this)
          });
        }.bind(this));
      }
    });<commit_msg>Update to new the-graph library API<commit_after><polymer-element name="noflo-library" attributes="editor search">
  <script>
    Polymer('noflo-library', {
      search: '',
      editor: null,
      addNode: function (component) {
        var num = 60466176; // 36^5
        num = Math.floor(Math.random() * num);
        var id = component + '_' + num.toString(36);

        // TODO fix with pan
        var pan = this.editor.$.graph.getPan();

        this.editor.graph.addNode(id, component, {
          label: component,
          x: -pan[0] + 334,
          y: -pan[1] + 100
        });
      },
      searchChanged: function () {
        if (!this.search || typeof this.search !== 'string') {
          return;
        }
        if (!this.editor) {
          return;
        }
        Object.keys(this.editor.getLibrary()).forEach(function (name) {
          if (this.search !== 'show library' && name.toLowerCase().indexOf(this.search.toLowerCase()) === -1) {
            return;
          }
          var component = this.editor.getComponent(name);
          this.fire('result', {
            label: component.name,
            icon: component.icon || 'cog',
            description: component.description,
            action: function () {
              this.addNode(component.name);
            }.bind(this)
          });
        }.bind(this));
      }
    });
{'fraction_non_alphanumeric': 0.15118870728083209, 'fraction_numerical': 0.01634472511144131, 'mean_word_length': 1.745158002038736, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4524258', 'n_tokens_mistral': 789, 'n_tokens_neox': 756, 'n_words': 153}