import Ember from 'ember'
import JSONFormatter from 'npm:json-formatter-js'

export default Ember.Component.extend
    classNames: ['ui', 'secondary', 'segment', 'format-json-container']
    value: {}
    nesting_level: Infinity
    top_title: 'JSON'
    didInsertElement: ->
      formatter = new JSONFormatter.default(@get('value'), @get('nesting_level'))
      v = formatter.render()
      tree = $(v)
      tree.find('.json-formatter-constructor-name:first').removeClass('json-formatter-constructor-name').addClass('json-formatter-top-node-name').text(@get('top_title'))
      @$().append(v)
