<commit_before>define(function (require, exports, module) {

  const $ = require('jquery');
  const _ = require('underscore');
  const sistyl = require('sistyl');
  const popoutView = require('plug/views/rooms/popout/PopoutView');

  function Style(defaults) {
    this._sistyl = sistyl(defaults);
    this._timeout = null;

    this.refresh = this.refresh.bind(this);
    this.id = _.uniqueId('eps-');

    this.el = $('<style />').addClass('extplug-style')
                            .attr('id', this.id)
                            .attr('type', 'text/css')
                            .appendTo('head');
    if (popoutView._window) {
      this.el.clone().appendTo(popoutView.$document.find('head'));
    }
    this.refresh();
  }

  Style.prototype.$ = function () {
    let el = this.el;
    if (popoutView._window) {
      el = el.add(popoutView.$document.find(`#${this.id}`));
    }
    return el;
  };

  Style.prototype.set = function (sel, props) {
    this._sistyl.set(sel, props);

    // throttle updates
    clearTimeout(this._timeout);
    this._timeout = setTimeout(this.refresh, 1);
    return this;
  };

  Style.prototype.refresh = function () {
    this.$().text(this.toString());
  };

  Style.prototype.remove = function () {
    this.$().remove();
  };

  Style.prototype.toString = function () {
    return this._sistyl.toString();
  };

  return Style;

});<commit_msg>make Style a class<commit_after>define(function (require, exports, module) {

  const $ = require('jquery');
  const _ = require('underscore');
  const sistyl = require('sistyl');
  const Class = require('plug/core/Class');
  const popoutView = require('plug/views/rooms/popout/PopoutView');

  const Style = Class.extend({
    init(defaults) {
      this._sistyl = sistyl(defaults);
      this._timeout = null;

      this.refresh = this.refresh.bind(this);
      this.id = _.uniqueId('eps-');

      this.el = $('<style />').addClass('extplug-style')
                              .attr('id', this.id)
                              .attr('type', 'text/css')
                              .appendTo('head');
      if (popoutView._window) {
        this.el.clone().appendTo(popoutView.$document.find('head'));
      }
      this.refresh();
    },

    $() {
      let el = this.el;
      if (popoutView._window) {
        el = el.add(popoutView.$document.find(`#${this.id}`));
      }
      return el;
    },

    set(sel, props) {
      this._sistyl.set(sel, props);

      // throttle updates
      clearTimeout(this._timeout);
      this._timeout = setTimeout(this.refresh, 1);
      return this;
    },

    refresh() {
      this.$().text(this.toString());
    },

    remove() {
      this.$().remove();
    },

    toString() {
      return this._sistyl.toString();
    }

  });

  module.exports = Style;

});
{'fraction_non_alphanumeric': 0.1741912548880199, 'fraction_numerical': 0.0007109847138286527, 'mean_word_length': 2.268292682926829, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4301158', 'n_tokens_mistral': 897, 'n_tokens_neox': 869, 'n_words': 147}