<commit_before>OpinionIndicator = React.createBackboneClass
  displayName: 'OpinionIndicator'
  changeOptions: 'add remove reset sort' + ' change'

  _type: ->
    @model().vote_for(@props.username)?.get('type')

  _typeCss: ->
    return 'comment-unsure' unless Factlink.Global.can_haz.opinions_of_users_and_comments

    switch @_type()
      when 'believes' then 'comment-believes'
      when 'disbelieves' then 'comment-disbelieves'
      else 'comment-unsure'

  render: ->
    _span [@_typeCss()]

ReactCommentHeading = React.createBackboneClass
  displayName: 'ReactCommentHeading'

  render: ->
    _div ['comment-post-heading'],
      OpinionIndicator
        username: @model().creator().get('username')
        model: @props.votes
      _span ["comment-post-creator-avatar"],
        _img ["avatar-image", src: @model().creator().avatar_url(32)] #has to be kept in sync with the css variable: @commentCreatorAvatarSize
      _span ["comment-post-creator"],
        _a ["comment-post-creator-name", href: @model().creator().link(), rel: "backbone"],
          @model().creator().get('name')
        TimeAgo
          className: "comment-post-time"
          time: @model().get('created_at')

window.ReactComment = React.createBackboneClass
  displayName: 'ReactComment'

  getInitialState: ->
    show_subcomments: false

  _onDelete: ->
     @model().destroy wait: true

  _toggleSubcomments: ->
    @setState show_subcomments: !@state.show_subcomments

  _content: ->

    _div ["comment-content spec-comment-content",
      dangerouslySetInnerHTML: {__html: @model().get('formatted_content')}]

  _bottom: ->
    sub_comment_count = @model().get('sub_comments_count')

    [
      _span ["comment-post-bottom"], [
        if @model().can_destroy()
          _span ["comment-post-delete"],
            ReactDeleteButton
              model: @model()
              onDelete: @_onDelete
        _span ["comment-reply"],
          _a ["spec-sub-comments-link", href:"javascript:", onClick: @_toggleSubcomments],
            "(#{sub_comment_count}) Comment"
      ]
      if @state.show_subcomments
        ReactSubComments(model: @model())
    ]

  render: ->
    relevant = @model().argumentTally().relevance() >= 0

    _div ["comment-container", "spec-evidence-box", "comment-irrelevant" unless relevant],
      _div ["comment-votes-container"],
        ReactEvidenceVote model: @model().argumentTally()
      _div ["comment-content-container"],
        ReactCommentHeading
          votes: @props.votes
          model: @model()
        @_content()
        @_bottom()<commit_msg>Fixed react comment warnings about key<commit_after>OpinionIndicator = React.createBackboneClass
  displayName: 'OpinionIndicator'
  changeOptions: 'add remove reset sort' + ' change'

  _type: ->
    @model().vote_for(@props.username)?.get('type')

  _typeCss: ->
    return 'comment-unsure' unless Factlink.Global.can_haz.opinions_of_users_and_comments

    switch @_type()
      when 'believes' then 'comment-believes'
      when 'disbelieves' then 'comment-disbelieves'
      else 'comment-unsure'

  render: ->
    _span [@_typeCss()]

ReactCommentHeading = React.createBackboneClass
  displayName: 'ReactCommentHeading'

  render: ->
    _div ['comment-post-heading'],
      OpinionIndicator
        username: @model().creator().get('username')
        model: @props.votes
      _span ["comment-post-creator-avatar"],
        _img ["avatar-image", src: @model().creator().avatar_url(32)] #has to be kept in sync with the css variable: @commentCreatorAvatarSize
      _span ["comment-post-creator"],
        _a ["comment-post-creator-name", href: @model().creator().link(), rel: "backbone"],
          @model().creator().get('name')
        TimeAgo
          className: "comment-post-time"
          time: @model().get('created_at')

window.ReactComment = React.createBackboneClass
  displayName: 'ReactComment'

  getInitialState: ->
    show_subcomments: false

  _onDelete: ->
     @model().destroy wait: true

  _toggleSubcomments: ->
    @setState show_subcomments: !@state.show_subcomments

  _content: ->
    _div ["comment-content spec-comment-content",
      dangerouslySetInnerHTML: {__html: @model().get('formatted_content')}]

  _bottom: ->
    sub_comment_count = @model().get('sub_comments_count')

    [
      _span ["comment-post-bottom"],
        if @model().can_destroy()
          _span ["comment-post-delete"],
            ReactDeleteButton
              model: @model()
              onDelete: @_onDelete
        _span ["comment-reply"],
          _a ["spec-sub-comments-link", href:"javascript:", onClick: @_toggleSubcomments],
            "(#{sub_comment_count}) Comment"
      if @state.show_subcomments
        ReactSubComments(model: @model())
    ]

  render: ->
    relevant = @model().argumentTally().relevance() >= 0

    _div ["comment-container", "spec-evidence-box", "comment-irrelevant" unless relevant],
      _div ["comment-votes-container"],
        ReactEvidenceVote model: @model().argumentTally()
      _div ["comment-content-container"],
        ReactCommentHeading
          votes: @props.votes
          model: @model()
        @_content()
        @_bottom()...
{'fraction_non_alphanumeric': 0.14170351855412422, 'fraction_numerical': 0.0011536243030186503, 'mean_word_length': 3.089622641509434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '6099291', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1574, 'n_words': 300}