 
 import INST from 'browser-sniffer'
 import {useScope as useI18nScope} from '@canvas/i18n'
+import ready from '@instructure/ready'
 import $ from 'jquery'
 import '@canvas/jquery/jquery.ajaxJSON'
 import '@canvas/forms/jquery/jquery.instructure_forms'

    $.flashError I18n.t("users_adding_failed", "Failed to enroll users")

  showTextarea: ->
    $form.find(".add_users_button, .go_back_button, #user_list_parsed").hide()
    $form.find(".verify_syntax_button, .cancel_button, #user_list_textarea_container").show().removeAttr "disabled"
    $form.find(".verify_syntax_button").attr("disabled", false).text I18n.t("buttons.continue", "Continue...")
    $user_list = $form.find(".user_list").removeAttr('disabled').loadingImage('remove').focus()
    $user_list.select() if $user_list.is(':visible') # .select() blows up in IE9 + jQuery 1.7.2 on invisible elements

  showProcessing: ->
    $form.find(".verify_syntax_button").attr("disabled", true).text I18n.t("messages.processing", "Processing...")
    $form.find(".user_list").attr("disabled", true).loadingImage()

  showResults: (userList) ->
    $form.find(".add_users_button, .go_back_button, #user_list_parsed").show()
    $form.find(".add_users_button").attr("disabled", false).focus().text I18n.t("add_n_users",
      one: "OK Looks Good, Add This 1 User"
      other: "OK Looks Good, Add These %{count} Users"
    ,
      count: userList.users.length
    )
    $form.find(".verify_syntax_button, .cancel_button, #user_list_textarea_container").hide()
    $form.find(".user_list").removeAttr("disabled").loadingImage "remove"
    $user_lists_processed_people.html("").show()
    if not userList or not userList.users or not userList.users.length
      $user_list_no_valid_users.appendTo $user_lists_processed_people
      $form.find(".add_users_button").hide()
    else
      if userList.errored_users and userList.errored_users.length
        $user_list_with_errors.appendTo($user_lists_processed_people).find(".message_content").text I18n.t("user_parsing_errors",
          one: "There was 1 error parsing that list of users."
          other: "There were %{count} errors parsing that list of users."
        ,

          count: userList.users.length
        )
      if userList.duplicates and userList.duplicates.length
        UL.$user_list_duplicates_found.appendTo($user_lists_processed_people).find(".message_content").text I18n.t("duplicate_users",
          one: "1 duplicate user found, duplicates have been removed."
          other: "%{count} duplicate user found, duplicates have been removed."
        ,
          count: userList.duplicates.length
        )
      $.each userList.users, ->
        userDiv = UL.$user_lists_processed_person_template.clone(true).fillTemplateData(data: this).appendTo($user_lists_processed_people)
        userDiv.addClass("existing-user").attr "title", I18n.t("titles.existing_user", "Existing user")  if @user_id
        userDiv.show()

