 {find, compact, extend, last} = require 'underscore-plus'
-{Model, Sequence} = require 'theorist'
+{Model} = require 'theorist'
 {Emitter} = require 'event-kit'
 Serializable = require 'serializable'
 PaneAxis = require './pane-axis'

    super

    @emitter = new Emitter

    @items = Sequence.fromArray(compact(params?.items ? []))
    @setActiveItem(@items[0]) unless @getActiveItem()?

    @subscribe @items.onEach (item) =>
      if typeof item.on is 'function'
        @subscribe item, 'destroyed', => @removeItem(item, true)

    @subscribe @items.onRemoval (item, index) =>
      @unsubscribe item if typeof item.on is 'function'

  # Called by the Serializable mixin during serialization.
  serializeParams: ->

  addItem: (item, index=@getActiveItemIndex() + 1) ->
    return if item in @items

    if typeof item.on is 'function'
      @subscribe item, 'destroyed', => @removeItem(item, true)

    @items.splice(index, 0, item)
    @emit 'item-added', item, index
    @emitter.emit 'did-add-item', {item, index}
