<commit_before>$                    = require 'jquery'
kd                   = require 'kd'
KDButtonViewWithMenu = kd.ButtonViewWithMenu
KDCustomHTMLView     = kd.CustomHTMLView
groupifyLink         = require 'app/util/groupifyLink'
ActivityItemMenuItem = require 'activity/views/activityitemmenuitem'
ReplyInputWidget     = require 'activity/views/privatemessage/replyinputwidget'
PrivateMessagePane   = require 'activity/views/privatemessage/privatemessagepane'
isMyChannel          = require 'app/util/isMyChannel'
isVideoFeatureEnabled = require 'app/util/isVideoFeatureEnabled'

CollaborationChannelParticipantsModel = require 'activity/models/collaborationchannelparticipants'
IDEChatMessageParticipantAvatar       = require './idechatmessageparticipantavatar'
IDEChatParticipantHeads               = require './idechatparticipantheads'
IDEChatParticipantSearchController    = require './idechatparticipantsearchcontroller'

module.exports = class IDEChatMessagePane extends PrivateMessagePane

  constructor: (options = {}, data)->

    options.cssClass                = 'privatemessage'

    # this is backwards compatibility related. ~Umut
    options.type                    = 'privatemessage'
    options.channelType             = 'collaboration'

    options.autoCompleteController  = IDEChatParticipantSearchController

    super options, data

    options.initialParticipantStatus = 'requestpending'

    @isInSession = options.isInSession
    @videoActive = no

    isHost = not @isInSession

    @define 'visible', => @getDelegate().visible

    @on 'AddedParticipant', @bound 'participantAdded'

    @input.input.on 'focus', @lazyBound 'handleFocus', yes

    @once 'NewParticipantButtonClicked', @bound 'removeOnboarding'


  createVideoActionButton: (action) ->

    @addSubView @videoActionButtonContainer = new kd.CustomHTMLView
      cssClass : 'ChatVideo-actionButtonContainer'

    switch action
      when 'start'
        method = 'requestStartVideo'
        tooltipTitle = 'Start Video Chat [BETA]'
      when 'join'
        method = 'requestJoinVideo'
        tooltipTitle = 'Join Video Chat [BETA]'

    @videoActionButton = new kd.ButtonView
      iconOnly : yes
      cssClass : 'ChatVideo-actionButton'
      callback : @bound method
      tooltip  : { title: tooltipTitle, placement: 'left' }

    @videoActionButtonContainer.addSubView @videoActionButton


  handleThresholdReached: ->

    return  unless @visible
    return  unless kd.singletons.windowController.focused

    @glance()
<commit_msg>Hide auto complete dropdown when the event is dispatched<commit_after>$                    = require 'jquery'
kd                   = require 'kd'
KDButtonViewWithMenu = kd.ButtonViewWithMenu
KDCustomHTMLView     = kd.CustomHTMLView
groupifyLink         = require 'app/util/groupifyLink'
ActivityItemMenuItem = require 'activity/views/activityitemmenuitem'
ReplyInputWidget     = require 'activity/views/privatemessage/replyinputwidget'
PrivateMessagePane   = require 'activity/views/privatemessage/privatemessagepane'
isMyChannel          = require 'app/util/isMyChannel'
isVideoFeatureEnabled = require 'app/util/isVideoFeatureEnabled'

CollaborationChannelParticipantsModel = require 'activity/models/collaborationchannelparticipants'
IDEChatMessageParticipantAvatar       = require './idechatmessageparticipantavatar'
IDEChatParticipantHeads               = require './idechatparticipantheads'
IDEChatParticipantSearchController    = require './idechatparticipantsearchcontroller'

module.exports = class IDEChatMessagePane extends PrivateMessagePane

  constructor: (options = {}, data)->

    options.cssClass                = 'privatemessage'

    # this is backwards compatibility related. ~Umut
    options.type                    = 'privatemessage'
    options.channelType             = 'collaboration'

    options.autoCompleteController  = IDEChatParticipantSearchController

    super options, data

    options.initialParticipantStatus = 'requestpending'

    @isInSession = options.isInSession
    @videoActive = no

    isHost = not @isInSession

    @define 'visible', => @getDelegate().visible

    @on 'AddedParticipant', @bound 'participantAdded'

    @input.input.on 'focus', @lazyBound 'handleFocus', yes

    @once 'NewParticipantButtonClicked', @bound 'removeOnboarding'

    ideApp = kd.singletons.appManager.get 'IDE'
    ideApp.on 'UserCouldNotStartVideo', =>
      @autoComplete?.hideDropdown()


  createVideoActionButton: (action) ->

    @addSubView @videoActionButtonContainer = new kd.CustomHTMLView
      cssClass : 'ChatVideo-actionButtonContainer'

    switch action
      when 'start'
        method = 'requestStartVideo'
        tooltipTitle = 'Start Video Chat [BETA]'
      when 'join'
        method = 'requestJoinVideo'
        tooltipTitle = 'Join Video Chat [BETA]'

    @videoActionButton = new kd.ButtonView
      iconOnly : yes
      cssClass : 'ChatVideo-actionButton'
      callback : @bound method
      tooltip  : { title: tooltipTitle, placement: 'left' }

    @videoActionButtonContainer.addSubView @videoActionButton


  handleThresholdReached: ->

    return  unless @visible
    return  unless kd.singletons.windowController.focused

    @glance()

{'fraction_non_alphanumeric': 0.08118433619866285, 'fraction_numerical': 0.0, 'mean_word_length': 3.557006092254134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '249532', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1370, 'n_words': 300}