define [], ->

  class DevTools

    storageKey: "__#{'topsyHNReact'.toLowerCase()}__env"

    constructor: ->
      return unless window.localStorage
      @setupTools(localStorage.getItem @storageKey)

    setupTools: (env) ->
      switch env
        when 'local' then do @setupLocalTools
        when 'prod' then do @setupProdTools

    setupLocalTools: ->
        COLORS =
          purple: '#9b59b6'
          red: '#e74c3c'
          green:'#16a085'
          black: '#34495e'

        # Styler
        style = (color, bold, border='bottom') ->
          _bold = if bold then 'font-weight: bold;' else ''
          _border = switch border
            when 'bottom' then 'border-bottom: 1px solid #333;'
            when 'top' then 'border-top: 1px solid #333;'
            else ''

          """
            background-color: #ecf0f1;
            color: #{color};
            #{_bold}
            #{_border}
          """

        # Colored debug log in dev mode
        window.dlog = (msg) ->
          if typeof msg is 'string'
            console.log "%c[LOG]: %c#{msg}", style(COLORS.purple, true), style(COLORS.green)
          else
            console.log "%c[LOG]", style(COLORS.purple, true)
            console.log msg
          return 'Lahg!'

        # Colored debug log in dev mode
        window.dwarn = (msg) ->
          banner = new Array(11).join('#')
          console.log "%c#{banner}", style(COLORS.red, false, 'top')
          if typeof msg is 'string'
            console.log "%c[WARN]: %c#{msg}", style(COLORS.red, true, ''), style(COLORS.black, false, '')
          else
            console.log "%c[WARN]", style(COLORS.red, true, '')
            console.log msg
          console.log "%c#{banner}", style(COLORS.red, false, 'bottom')
          return 'Stahp!'

    setupProdTools: ->

  new DevTools

