context = window
rest = context.JK.Rest()
MIX_MODES = context.JK.MIX_MODES

@SessionMasterCategoryControls = React.createClass({

  mixins: [Reflux.listenTo(@SessionMediaTracksStore,"onInputsChanged"), Reflux.listenTo(@AppStore,"onAppInit")]

  onInputsChanged: (sessionMixers) ->
    mixers = sessionMixers.mixers
    inputGroupMixers = mixers.simulatedMusicCategoryMixers[MIX_MODES.MASTER]
    chatGroupMixers = mixers.simulatedChatCategoryMixers[MIX_MODES.MASTER]

    @setState({inputGroupMixers: inputGroupMixers, chatGroupMixers: chatGroupMixers})

  render: () ->

    categoryControls = []

    if @state.inputGroupMixers?
      input =
        mixers: @state.inputGroupMixers

      categoryControls.push(`<SessionMusicMixer key={input.mixers.mixer.id} {...input} />`)

    if @state.chatGroupMixers?
      input =
        mixers: @state.chatGroupMixers

      categoryControls.push(`<SessionChatMixer key={input.mixers.mixer.id} {...input} />`)


    `<div className="session-category-controls">
      <h2>master output</h2>
      <div className="session-tracks-scroller">
        {categoryControls}
      </div>
    </div>`


  getInitialState:() ->
    {inputGroupMixers: null, chatGroupMixers: null}


  onAppInit: (app) ->
    @app = app





})
