<commit_before>'use strict';

(function () {

  var React = require('react');

  var originalCreateElement = React.createElement;

  // Moved if Math.abs(downX - upX) > MOVE_THRESHOLD;
  var MOVE_THRESHOLD = 8;
  var TOUCH_DELAY = 1000;

  var touchEvents = {};

  var focusAndCheck = function (event, target) {
    var myTarget = target || event.currentTarget;
    myTarget.focus();

    switch (myTarget.type) {
      case 'checkbox':
        myTarget.checked = !myTarget.checked;
        event.preventDefault();
        break;
      case 'radio':
        myTarget.checked = true;
        event.preventDefault();
        break;
    }
  };

  var handleType = {
    input: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    textarea: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    select: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    label: function (event) {
      var input;

      var forTarget = event.currentTarget.getAttribute('for');

      if (forTarget) {
        input = document.getElementById(forTarget);
      } else {
        input = event.currentTarget.querySelectorAll('input, textarea, select')[0];
      }

      if (input) {
        focusAndCheck(event, input);
      }
      event.preventDefault();
    }
  };

  var noTouchHappened = function () {
    return !touchEvents.touched || new Date().getDate() > touchEvents.lastTouchDate + TOUCH_DELAY;
  };

  var invalidateIfMoreThanOneTouch = function (event) {
    touchEvents.invalid = event.touches && event.touches.length > 1 || touchEvents.invalid;
  };

  var onMouseEvent = function (callback, event) {
    // Prevent any mouse events if we touched recently
    if (typeof callback === 'function' && noTouchHappened()) {
      callback(event);
    }
    if (event.type === 'click') {
      touchEvents.invalid = false;
      touchEvents.touched = false;
      touchEvents.moved = false;
    }
  };

  var onTouchStart = function (callback, event) {
    touchEvents.moved = false;
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    touchEvents.downPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    touchEvents.lastPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    touchEvents.invalid = false;
    invalidateIfMoreThanOneTouch(event);

    if (typeof callback === 'function') {
      callback(event);
    }
  };

  var onTouchMove = function (callback, event) {
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    touchEvents.lastPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    invalidateIfMoreThanOneTouch(event);

    if (Math.abs(touchEvents.downPos.clientX - touchEvents.lastPos.clientX) > MOVE_THRESHOLD ||
      Math.abs(touchEvents.downPos.clientY - touchEvents.lastPos.clientY) > MOVE_THRESHOLD) {
      touchEvents.moved = true;
    }

    if (typeof callback === 'function') {
      callback(event);
    }
  };

  var onTouchEnd = function (callback, onClick, type, event) {
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    invalidateIfMoreThanOneTouch(event);

    if (typeof callback === 'function') {
      callback(event);
    }

    if (!touchEvents.invalid && !touchEvents.moved) {
      var box = event.currentTarget.getBoundingClientRect();

      if (touchEvents.lastPos.clientX <= box.right &&
        touchEvents.lastPos.clientX >= box.left &&
        touchEvents.lastPos.clientY <= box.bottom &&
        touchEvents.lastPos.clientY >= box.top) {

        if (typeof onClick === 'function') {
          onClick(event);
        }

        if (!event.defaultPrevented && handleType[type]) {
          handleType[type](event);
        }
      }
    }
  };

  var propsWithFastclickEvents = function (type, props) {
    var newProps = {};

    // Loop over props
    for (var key in props) {
      // Copy props to newProps
      newProps[key] = props[key];
    }

    // Apply our wrapped mouse and touch handlers<commit_msg>Fake click event (fixes react-router issue)<commit_after>'use strict';

(function () {

  var React = require('react');

  var originalCreateElement = React.createElement;

  // Moved if Math.abs(downX - upX) > MOVE_THRESHOLD;
  var MOVE_THRESHOLD = 8;
  var TOUCH_DELAY = 1000;

  var touchEvents = {};

  var fakeClickEvent = function (event) {
    event.fastclick = true;
    event.type = 'click';
    event.button = 0;

    return event;
  };

  var focusAndCheck = function (event, target) {
    var myTarget = target || event.currentTarget;
    myTarget.focus();

    switch (myTarget.type) {
      case 'checkbox':
        myTarget.checked = !myTarget.checked;
        event.preventDefault();
        break;
      case 'radio':
        myTarget.checked = true;
        event.preventDefault();
        break;
    }
  };

  var handleType = {
    input: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    textarea: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    select: function (event) {
      focusAndCheck(event);
      event.stopPropagation();
    },
    label: function (event) {
      var input;

      var forTarget = event.currentTarget.getAttribute('for');

      if (forTarget) {
        input = document.getElementById(forTarget);
      } else {
        input = event.currentTarget.querySelectorAll('input, textarea, select')[0];
      }

      if (input) {
        focusAndCheck(event, input);
      }
      event.preventDefault();
    }
  };

  var noTouchHappened = function () {
    return !touchEvents.touched || new Date().getDate() > touchEvents.lastTouchDate + TOUCH_DELAY;
  };

  var invalidateIfMoreThanOneTouch = function (event) {
    touchEvents.invalid = event.touches && event.touches.length > 1 || touchEvents.invalid;
  };

  var onMouseEvent = function (callback, event) {
    // Prevent any mouse events if we touched recently
    if (typeof callback === 'function' && noTouchHappened()) {
      callback(event);
    }
    if (event.type === 'click') {
      touchEvents.invalid = false;
      touchEvents.touched = false;
      touchEvents.moved = false;
    }
  };

  var onTouchStart = function (callback, event) {
    touchEvents.moved = false;
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    touchEvents.downPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    touchEvents.lastPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    touchEvents.invalid = false;
    invalidateIfMoreThanOneTouch(event);

    if (typeof callback === 'function') {
      callback(event);
    }
  };

  var onTouchMove = function (callback, event) {
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    touchEvents.lastPos = {
      clientX: event.touches[0].clientX,
      clientY: event.touches[0].clientY
    };
    invalidateIfMoreThanOneTouch(event);

    if (Math.abs(touchEvents.downPos.clientX - touchEvents.lastPos.clientX) > MOVE_THRESHOLD ||
      Math.abs(touchEvents.downPos.clientY - touchEvents.lastPos.clientY) > MOVE_THRESHOLD) {
      touchEvents.moved = true;
    }

    if (typeof callback === 'function') {
      callback(event);
    }
  };

  var onTouchEnd = function (callback, onClick, type, event) {
    touchEvents.touched = true;
    touchEvents.lastTouchDate = new Date().getTime();
    invalidateIfMoreThanOneTouch(event);

    if (typeof callback === 'function') {
      callback(event);
    }

    if (!touchEvents.invalid && !touchEvents.moved) {
      var box = event.currentTarget.getBoundingClientRect();

      if (touchEvents.lastPos.clientX <= box.right &&
        touchEvents.lastPos.clientX >= box.left &&
        touchEvents.lastPos.clientY <= box.bottom &&
        touchEvents.lastPos.clientY >= box.top) {

        if (typeof onClick === 'function') {
          onClick(fakeClickEvent(event));
        }

        if (!event.defaultPrevented && handleType[type]) {
          handleType[type](event);
        }
      }
    }
  };

  var propsWithFastclickEvents = function (type, props) {
    var newProps = {};

    // Loop over props
    for (var key in props) {
      // Copy props to newProps
      newProps[key] = props[key];
    }

    // Apply our wrapped mouse and touch handlers
{'fraction_non_alphanumeric': 0.12646614795029612, 'fraction_numerical': 0.003135524329346185, 'mean_word_length': 2.696137339055794, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '5459787', 'n_tokens_mistral': 2688, 'n_tokens_neox': 2617, 'n_words': 538}