LATENCY = {
    ME : {description: "ME", style: "latency-me", min: -1, max: -1},
    GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
    MEDIUM : {description: "FAIR", style: "latency-fair", min: 40.0, max: 70.0},
    HIGH : {description: "HIGH", style: "latency-poor", min: 70.0, max: 10000000},
    #UNACCEPTABLE: {description: "UNACCEPTABLE", style: "latency-unacceptable", min: 100, max: 10000000},
    UNKNOWN: {description: "UNKNOWN", style: "latency-unknown", min: -2, max: -2},
    FAILED: {description: "N/A", style: "latency-failed", min: -3, max: -3}
  }

@LatencyBadge = React.createClass({
    
  render: () ->

    if @props.latency
      latency         = @props.latency
      full_score      = latency.ars.total_latency
      internet_score  = parseInt(latency.internet_score);
      audio_latency   = parseInt(latency.audio_latency);
    
      latencyDescription  = ""
      latencyStyle        = ""
      
      if !full_score || full_score <= LATENCY.UNKNOWN.max
        latencyDescription = LATENCY.UNKNOWN.description
        latencyStyle = LATENCY.UNKNOWN.style
      
      else if full_score <= LATENCY.GOOD.max
        latencyDescription = LATENCY.GOOD.description
        latencyStyle = LATENCY.GOOD.style;
      
      else if full_score <= LATENCY.MEDIUM.max
        latencyDescription = LATENCY.MEDIUM.description
        latencyStyle = LATENCY.MEDIUM.style
        
      else if full_score <= LATENCY.HIGH.max
        latencyDescription = LATENCY.HIGH.description
        latencyStyle = LATENCY.HIGH.style
        
    else if @props.failed
      latencyDescription = LATENCY.FAILED.description
      latencyStyle = LATENCY.FAILED.style
      
    else
      latencyDescription = LATENCY.UNKNOWN.description
      latencyStyle = LATENCY.UNKNOWN.style
      

    `<span className={latencyStyle}>{latencyDescription}</span>`

})
