<commit_before>Grim = require 'grim'
{find, compact, extend, last} = require 'underscore-plus'
{CompositeDisposable, Emitter} = require 'event-kit'
PaneAxis = require './pane-axis'
TextEditor = require './text-editor'
PaneElement = require './pane-element'

nextInstanceId = 1

# Extended: A container for presenting content in the center of the workspace.
# Panes can contain multiple items, one of which is *active* at a given time.
# The view corresponding to the active item is displayed in the interface. In
# the default configuration, tabs are also displayed for each item.
#
# Each pane may also contain one *pending* item. When a pending item is added
# to a pane, it will replace the currently pending item, if any, instead of
# simply being added. In the default configuration, the text in the tab for
# pending items is shown in italics.
module.exports =
class Pane
  container: undefined
  activeItem: undefined
  focused: false

  @deserialize: (state, {deserializers, applicationDelegate, config, notifications, views}) ->
    {items, activeItemIndex, activeItemURI, activeItemUri} = state
    activeItemURI ?= activeItemUri
    items = items.map (itemState) -> deserializers.deserialize(itemState)
    state.activeItem = items[activeItemIndex]
    state.items = compact(items)
    if activeItemURI?
      state.activeItem ?= find state.items, (item) ->
        if typeof item.getURI is 'function'
          itemURI = item.getURI()
        itemURI is activeItemURI
    new Pane(extend(state, {
      deserializerManager: deserializers,
      notificationManager: notifications,
      viewRegistry: views,
      config, applicationDelegate
    }))

  constructor: (params) ->
    {
      @id, @activeItem, @focused, @applicationDelegate, @notificationManager, @config,
      @deserializerManager, @viewRegistry
    } = params

    if @id?
      nextInstanceId = Math.max(nextInstanceId, @id + 1)
    else
      @id = nextInstanceId++
    @emitter = new Emitter
    @alive = true
    @subscriptionsPerItem = new WeakMap
    @items = []
    @itemStack = []

    @addItems(compact(params?.items ? []))
    @setActiveItem(@items[0]) unless @getActiveItem()?
    @addItemsToStack(params?.itemStackIndices ? [])
    @setFlexScale(params?.flexScale ? 1)

  getElement: ->
    @element ?= new PaneElement().initialize(this, {views: @viewRegistry, @applicationDelegate})

  serialize: ->
    itemsToBeSerialized = compact(@items.map((item) -> item if typeof item.serialize is 'function'))
    itemStackIndices = (itemsToBeSerialized.indexOf(item) for item in @itemStack when typeof item.serialize is 'function')
    activeItemIndex = itemsToBeSerialized.indexOf(@activeItem)

    {
      deserializer: 'Pane',
      id: @id,
      items: itemsToBeSerialized.map((item) -> item.serialize())
      itemStackIndices: itemStackIndices
      activeItemIndex: activeItemIndex
      focused: @focused
      flexScale: @flexScale
    }

  getParent: -> @parent

  setParent: (@parent) -> @parent

  getContainer: -> @container
<commit_msg>Remove Pane prototype properties<commit_after>Grim = require 'grim'
{find, compact, extend, last} = require 'underscore-plus'
{CompositeDisposable, Emitter} = require 'event-kit'
PaneAxis = require './pane-axis'
TextEditor = require './text-editor'
PaneElement = require './pane-element'

nextInstanceId = 1

# Extended: A container for presenting content in the center of the workspace.
# Panes can contain multiple items, one of which is *active* at a given time.
# The view corresponding to the active item is displayed in the interface. In
# the default configuration, tabs are also displayed for each item.
#
# Each pane may also contain one *pending* item. When a pending item is added
# to a pane, it will replace the currently pending item, if any, instead of
# simply being added. In the default configuration, the text in the tab for
# pending items is shown in italics.
module.exports =
class Pane
  @deserialize: (state, {deserializers, applicationDelegate, config, notifications, views}) ->
    {items, activeItemIndex, activeItemURI, activeItemUri} = state
    activeItemURI ?= activeItemUri
    items = items.map (itemState) -> deserializers.deserialize(itemState)
    state.activeItem = items[activeItemIndex]
    state.items = compact(items)
    if activeItemURI?
      state.activeItem ?= find state.items, (item) ->
        if typeof item.getURI is 'function'
          itemURI = item.getURI()
        itemURI is activeItemURI
    new Pane(extend(state, {
      deserializerManager: deserializers,
      notificationManager: notifications,
      viewRegistry: views,
      config, applicationDelegate
    }))

  constructor: (params) ->
    {
      @id, @activeItem, @focused, @applicationDelegate, @notificationManager, @config,
      @deserializerManager, @viewRegistry
    } = params

    if @id?
      nextInstanceId = Math.max(nextInstanceId, @id + 1)
    else
      @id = nextInstanceId++
    @emitter = new Emitter
    @alive = true
    @subscriptionsPerItem = new WeakMap
    @items = []
    @itemStack = []
    @container = null
    @activeItem ?= undefined
    @focused ?= false

    @addItems(compact(params?.items ? []))
    @setActiveItem(@items[0]) unless @getActiveItem()?
    @addItemsToStack(params?.itemStackIndices ? [])
    @setFlexScale(params?.flexScale ? 1)

  getElement: ->
    @element ?= new PaneElement().initialize(this, {views: @viewRegistry, @applicationDelegate})

  serialize: ->
    itemsToBeSerialized = compact(@items.map((item) -> item if typeof item.serialize is 'function'))
    itemStackIndices = (itemsToBeSerialized.indexOf(item) for item in @itemStack when typeof item.serialize is 'function')
    activeItemIndex = itemsToBeSerialized.indexOf(@activeItem)

    {
      deserializer: 'Pane',
      id: @id,
      items: itemsToBeSerialized.map((item) -> item.serialize())
      itemStackIndices: itemStackIndices
      activeItemIndex: activeItemIndex
      focused: @focused
      flexScale: @flexScale
    }

  getParent: -> @parent

  setParent: (@parent) -> @parent

  getContainer: -> @container

{'fraction_non_alphanumeric': 0.10477127397934087, 'fraction_numerical': 0.0013116904410559109, 'mean_word_length': 3.7360248447204967, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6047428', 'n_tokens_mistral': 1766, 'n_tokens_neox': 1713, 'n_words': 533}