<commit_before>import React from "react"
import Link from "gatsby-link"
import cx from 'classnames'
import ComposedDocSidebar from "../containers/DocSidebarContainer";


const Section = props => {
  let isHeader = false
  let long_title = props.id
  if (props.collapse === true) {
    isHeader = true
  }
  return (
    <div className='pad-l-1 pad-b-2'>
      <h3 className={isHeader ? ("row sidebar-cross" + (props.activeHeader.indexOf(long_title) > -1 ? ' ': ' collapsed')): ' '}
        title={long_title}
        onClick={props.toggleSection}>
        {props.title}
      </h3>
      <SectionLinks
        {...props}
        isTutorial={long_title === `Tutorial`}
      />
    </div>
  )
}


const SectionLinks = props => {

  return (
    <ul className={props.collapse ? (props.activeHeader.indexOf(props.id) > -1 ? 'display-block': 'display-none') : ' '}>
      {props.items.map((item, index) => (
        <SectionLink
          node={item}
          children={item.items}
          key={index}
          toggleSection={props.toggleSection}
          toggleMobileSidebar={props.toggleMobileSidebar}
          activeHeader={props.activeHeader}
        />
      ))}
    </ul>
  )
}


const SectionLink = props => {

  let childnodes = null
  if (props.children) {
    childnodes = props.children.map((childnode, index) => (
      <SectionLink key={index} node={childnode} children={childnode.items} isChild />
    ))
  }

  let item = props.node
  let title =  item.title
  let link = item.link
  let long_title = title

  let isHeader = false
  if (Object.keys(item).indexOf("link") === -1) {
    isHeader = true
    long_title = item.id
  } else {
    long_title = link.split('/').slice(2, -1).join('_')
  }
  const itemCx = cx({
    'row': true,
    'sidebar-item': !isHeader,
    'sidebar-header sidebar-cross': isHeader,
    'depth-2': !props.isChild,
    'depth-3': props.isChild,
  })

  return (
    <li>
      {Object.keys(item).indexOf("link") === -1 ? (
        <span className={itemCx + (props.activeHeader.indexOf(long_title) > -1 ? ' ': ' collapsed')}
          title={long_title}
          onClick={props.toggleMobileSidebar}>
          {title}
        </span>
      ) : link.charAt(0) === `#` ? (
        <a href={link} className={itemCx} onClick={props.toggleMobileSidebar}>
          {title}
        </a>
      ) : (<commit_msg>Fixed doc sidebar bug.<commit_after>import React from "react"
import Link from "gatsby-link"
import cx from 'classnames'
import ComposedDocSidebar from "../containers/DocSidebarContainer";


const Section = props => {
  let isHeader = false
  let long_title = props.id
  if (props.collapse === true) {
    isHeader = true
  }
  return (
    <div className='pad-l-1 pad-b-2'>
      <h3 className={isHeader ? ("row sidebar-cross" + (props.activeHeader.indexOf(long_title) > -1 ? ' ': ' collapsed')): ' '}
        title={long_title}
        onClick={props.toggleSection}>
        {props.title}
      </h3>
      <SectionLinks
        {...props}
        isTutorial={long_title === `Tutorial`}
      />
    </div>
  )
}


const SectionLinks = props => {

  return (
    <ul className={props.collapse ? (props.activeHeader.indexOf(props.id) > -1 ? 'display-block': 'display-none') : ' '}>
      {props.items.map((item, index) => (
        <SectionLink
          node={item}
          children={item.items}
          key={index}
          toggleSection={props.toggleSection}
          toggleMobileSidebar={props.toggleMobileSidebar}
          activeHeader={props.activeHeader}
        />
      ))}
    </ul>
  )
}


const SectionLink = props => {

  let childnodes = null
  if (props.children) {
    childnodes = props.children.map((childnode, index) => (
      <SectionLink key={index} node={childnode} children={childnode.items} isChild />
    ))
  }

  let item = props.node
  let title =  item.title
  let link = item.link
  let long_title = title

  let isHeader = false
  if (Object.keys(item).indexOf("link") === -1) {
    isHeader = true
    long_title = item.id
  } else {
    long_title = link.split('/').slice(2, -1).join('_')
  }
  const itemCx = cx({
    'row': true,
    'sidebar-item': !isHeader,
    'sidebar-header sidebar-cross': isHeader,
    'depth-2': !props.isChild,
    'depth-3': props.isChild,
  })

  return (
    <li>
      {Object.keys(item).indexOf("link") === -1 ? (
        <span className={itemCx + (props.activeHeader.indexOf(long_title) > -1 ? ' ': ' collapsed')}
          title={long_title}
          onClick={props.toggleSection}>
          {title}
        </span>
      ) : link.charAt(0) === `#` ? (
        <a href={link} className={itemCx} onClick={props.toggleMobileSidebar}>
          {title}
        </a>
      ) : (
{'fraction_non_alphanumeric': 0.16138634913884756, 'fraction_numerical': 0.005953646608547736, 'mean_word_length': 2.4973977695167284, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 47, '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': '4985682', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1524, 'n_words': 295}