<commit_before>var tabs = (function() {

  function bind() {
    _bind_tabGroup();
    _bind_tabArrow();
  };

  function _bind_tabGroup() {
    var all_tabGroup = helper.eA(".js-tab-group");
    for (var i = 0; i < all_tabGroup.length; i++) {
      var all_tabItem = all_tabGroup[i].querySelectorAll(".js-tab-item");
      for (var j = 0; j < all_tabItem.length; j++) {
        all_tabItem[j].addEventListener("click", function() {
          _switchTabPanel(this);
        }, false);
      };
    };
  };

  function _bind_tabArrow() {
    var all_tabArrow = helper.eA(".js-tab-arrow");
    for (var i = 0; i < all_tabArrow.length; i++) {
      all_tabArrow[i].addEventListener("click", function() {
        _tabArrow(this);
      }, false);
    };
  };

  function _tabArrow(button) {
    var options = helper.makeObject(button.dataset.tabArrowOptions);
    var tabGroup = helper.getClosest(button, ".js-tab-group");
    var tabRow = tabGroup.querySelector(".js-tab-row");
    var all_tabItem = tabGroup.querySelectorAll(".js-tab-item");
    var currentIndex;
    var newIndex;
    for (var i = 0; i < all_tabItem.length; i++) {
      if (all_tabItem[i].dataset.tabState == "true") {
        currentIndex = i;
      };
      helper.removeClass(all_tabItem[i], "is-active");
      all_tabItem[i].dataset.tabState = false;
    };
    if (options.action == "right") {
      newIndex = currentIndex + 1;
      if (newIndex > all_tabItem.length - 1) {
        newIndex = 0;
      };
    } else if (options.action == "left") {
      newIndex = currentIndex - 1;
      if (newIndex < 0) {
        newIndex = all_tabItem.length - 1;
      };
    };
    helper.addClass(all_tabItem[newIndex], "is-active");
    all_tabItem[newIndex].dataset.tabState = true;
    _scrollTabInToView(tabRow, all_tabItem[newIndex]);
    _switchTabPanel(all_tabItem[newIndex]);
  };

  function _scrollTabInToView(tabRow, tab) {
    var tabIndicator = tabRow.querySelector(".m-tab-indicator");
    var tabRowArea = tabRow.getBoundingClientRect();
    var tabArea = tab.getBoundingClientRect();
    var left = Math.ceil(tab.offsetLeft - (tabRowArea.width / 2) + (tabArea.width / 2), 10);
    tabRow.scroll({
      top: 0,
      left: left,
      behavior: 'smooth'
    });
    tabIndicator.setAttribute("style", "width:" + (tabArea.width - 10) + "px;left:" + (tab.offsetLeft + 5) + "px;");
  };<commit_msg>[bug] fix tab scrolling on safari<commit_after>var tabs = (function() {

  function bind() {
    _bind_tabGroup();
    _bind_tabArrow();
  };

  function _bind_tabGroup() {
    var all_tabGroup = helper.eA(".js-tab-group");
    for (var i = 0; i < all_tabGroup.length; i++) {
      var all_tabItem = all_tabGroup[i].querySelectorAll(".js-tab-item");
      for (var j = 0; j < all_tabItem.length; j++) {
        all_tabItem[j].addEventListener("click", function() {
          _switchTabPanel(this);
        }, false);
      };
    };
  };

  function _bind_tabArrow() {
    var all_tabArrow = helper.eA(".js-tab-arrow");
    for (var i = 0; i < all_tabArrow.length; i++) {
      all_tabArrow[i].addEventListener("click", function() {
        _tabArrow(this);
      }, false);
    };
  };

  function _tabArrow(button) {
    var options = helper.makeObject(button.dataset.tabArrowOptions);
    var tabGroup = helper.getClosest(button, ".js-tab-group");
    var tabRow = tabGroup.querySelector(".js-tab-row");
    var all_tabItem = tabGroup.querySelectorAll(".js-tab-item");
    var currentIndex;
    var newIndex;
    for (var i = 0; i < all_tabItem.length; i++) {
      if (all_tabItem[i].dataset.tabState == "true") {
        currentIndex = i;
      };
      helper.removeClass(all_tabItem[i], "is-active");
      all_tabItem[i].dataset.tabState = false;
    };
    if (options.action == "right") {
      newIndex = currentIndex + 1;
      if (newIndex > all_tabItem.length - 1) {
        newIndex = 0;
      };
    } else if (options.action == "left") {
      newIndex = currentIndex - 1;
      if (newIndex < 0) {
        newIndex = all_tabItem.length - 1;
      };
    };
    helper.addClass(all_tabItem[newIndex], "is-active");
    all_tabItem[newIndex].dataset.tabState = true;
    _scrollTabInToView(tabRow, all_tabItem[newIndex]);
    _switchTabPanel(all_tabItem[newIndex]);
  };

  function _scrollTabInToView(tabRow, tab) {
    var tabIndicator = tabRow.querySelector(".m-tab-indicator");
    var tabRowArea = tabRow.getBoundingClientRect();
    var tabArea = tab.getBoundingClientRect();
    var left = Math.ceil(tab.offsetLeft - (tabRowArea.width / 2) + (tabArea.width / 2), 10);
    tabIndicator.setAttribute("style", "width:" + (tabArea.width - 10) + "px;left:" + (tab.offsetLeft + 5) + "px;");
    if (tabRow.scroll) {
      tabRow.scroll({
        top: 0,
        left: left,
        behavior: 'smooth'
      });
    } else {
      if (tabArea.left < tabRowArea.left) {
        var left = tab.offsetLeft;
        tabRow.scrollLeft = left;
      } else if (tabArea.right > tabRowArea.right) {
        var right = Math.ceil(tab.offsetLeft - tabRowArea.width + tabArea.width, 10);
        tabRow.scrollLeft = right;
      };
    };
  };
{'fraction_non_alphanumeric': 0.15551219512195122, 'fraction_numerical': 0.007414634146341463, 'mean_word_length': 2.8026706231454006, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 6, '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': '5473123', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1739, 'n_words': 330}