<commit_before><link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-icons/av-icons.html">

<dom-module id="guided-meditation-player">
  <template>
    <style>
      :host {
          display: block;
      }
      :host, .controls {
        height: 100%;
      }
      .controls {
        height: 100%;
        text-align: center;
      }
      iron-icon {
        --iron-icon-height: 100px;
        --iron-icon-width: 100px;
      }
    </style>
    <div class="controls" on-tap="handleTap">
      <iron-icon icon="av:[[icon(playing)]]" />
    </div>
    <audio id="audio" src="[[getSrc(srcset, index)]]" />
  </template>

  <script>
    Polymer({
      getSrc: function (srcset, index) {
        return srcset[index]
      },
      handleTap: function () {
        this.$.audio[this.playing ? 'pause' : 'play']()
        this.playing = !this.playing
      },
      icon: function (playing) {
        return playing ? 'pause' : 'play-arrow'
      },
      is: 'guided-meditation-player',
      listeners: {
        'audio.playing': 'onPlay',
        'audio.pause': 'onPause',
        'audio.ended': 'next'
      },
      next: function () {
        if (this.index + 1 < this.srcset.length) {
          this.index++
        } else {
          this.index = 0
        }
      },
      onPause: function () {
        this.playing = false
      },
      onPlay: function () {
        this.playing = true
      },
      properties: {
        index: {
          type: Number,
          value: 0
        },
        playing: {
          type: Boolean,
          value: false
        },
        srcset: {
          type: Array
        }
      }
    })
  </script>
</dom-module>
<commit_msg>Simplify markup and add computed properties<commit_after><link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-icons/av-icons.html">

<dom-module id="guided-meditation-player">
  <template>
    <style>
      :host {
        --iron-icon-height: 100px;
        --iron-icon-width: 100px;
        display: block;
        height: 100%;
        text-align: center;
      }
    </style>

    <iron-icon icon="av:[[icon]]" />
    <audio id="audio" src="[[currentSrc]]" />
  </template>

  <script>
    Polymer({
      getSrc: function (srcset, index) {
        return srcset[index]
      },
      handleTap: function () {
        this.$.audio[this.playing ? 'pause' : 'play']()
        this.playing = !this.playing
      },
      getIcon: function (playing) {
        return playing ? 'pause' : 'play-arrow'
      },
      is: 'guided-meditation-player',
      listeners: {
        'tap': 'handleTap',
        'audio.playing': 'onPlay',
        'audio.pause': 'onPause',
        'audio.ended': 'next'
      },
      next: function () {
        if (this.index + 1 < this.srcset.length) {
          this.index++
        } else {
          this.index = 0
        }
      },
      onPause: function () {
        this.playing = false
      },
      onPlay: function () {
        this.playing = true
      },
      properties: {
        currentSrc: {
          type: String,
          computed: 'getSrc(srcset, index)'
        },
        icon: {
          type: String,
          computed: 'getIcon(playing)'
        },
        index: {
          type: Number,
          value: 0
        },
        playing: {
          type: Boolean,
          value: false
        },
        srcset: {
          type: Array
        }
      }
    })
  </script>
</dom-module>

{'fraction_non_alphanumeric': 0.1586767591813849, 'fraction_numerical': 0.007569386038687973, 'mean_word_length': 1.5892597968069666, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, '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': '4041496', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1102, 'n_words': 215}