 Backbone        = require 'backbone'
 { ARTSY_URL }   = require('sharify').data
 { Markdown }    = require 'artsy-backbone-mixins'
+analytics       = require '../../../lib/analytics.coffee'
 
 Artworks            = require '../../../collections/artworks.coffee'
 ArtworkColumnsView  = require '../../../components/artwork_columns/view.coffee'

      artworkSize: 'tall'

  postRender: ->
    @$layeredSearchResults = @$('#layered-search-results')
    # Activate the first tab
    (@$layerButtons ?= @$('.layered-search-layer-button')).
      first().click()

  render: ->
    # If only one layer is returned it will be "For sale"

    @set fair: @collection.fair if @get('type') is 'fair'
    @artworks = new Artworks
    @artworks.url = "#{ARTSY_URL}/api/v1/related/layer/#{@get('type')}/#{@id}/artworks?artwork[]=#{@get('artwork_id')}"

  label: ->
    return @id if (@get('type') is 'synthetic') and (@id is 'for-sale')
    @get 'type'

module.exports.Layers = class Layers extends Backbone.Collection
  url: "#{ARTSY_URL}/api/v1/related/layers"
