<commit_before>'use strict'

;(function (thisDoc) {
  const strftime = require('date-fns').format

  class TransactionDetailComponent extends HTMLElement {
    constructor () {
      super()

      this._debug = false
      this.debug('constructing')

      this.root = this.attachShadow({mode: 'open'})

      const template = thisDoc.querySelector('template')
      this.root.appendChild(document.importNode(template.content, true))
    }

    connectedCallback () {
      this.debug(`connected detail`)

      if (this.tx) {
        this.dataset.category = this.tx.category
        this.render()
      }

      this.$attachments = this.root.querySelector('.attachments')
      this.$scrollInner = this.$attachments.querySelector('.scroll-inner')
      this.$newAttachment = this.root.querySelector('input.new-attachment')

      this.$newAttachment.addEventListener('change', this.uploadAttachment.bind(this))
    }

    render () {
      if (!this.tx) return
      this.debug(`rendering detail`)

      this.renderCategory()
      this.renderIcon()
      this.renderLocation()
      this.renderMerchant()
      this.renderNotes()
      this.renderAttachments()
      this.renderAmount()
      this.renderBalance()
      this.renderDate()
      this.renderId()
      this.renderDescription()
    }

    renderBalance () {
      const balance = this.tx.balance.html(true, 0)
      this.root.querySelector('.balance-wrap').innerHTML = balance
    }

    renderDate () {
      const date = strftime(this.tx.created, 'h:mma - Do MMMM YYYY')
      this.root.querySelector('.date').textContent = date
    }

    renderId () {
      const id = this.tx.id
      this.root.querySelector('.id').textContent = id
    }

    renderDescription () {
      const description = this.tx.description
      this.root.querySelector('.description').textContent = description
    }

    renderAmount () {
      const $amountWrap = this.root.querySelector('.amount-wrap')

      if (!this.tx.is.metaAction) {
        $amountWrap.innerHTML = this.tx.amount.html(true, 0)

        if (this.tx.amount.foreign) {
          $amountWrap.innerHTML += this.tx.amount.exchanged.html(true, 0)
        }
      }
    }

    renderSettled () {
      const $settled = this.root.querySelector('.settled')

      if (this.tx.settled === 'Settled: Invalid Date') {
        console.warn('Invalid settled date. This may be a bug.')
        $settled.classList.add('meta')
      }

      if (this.tx.is.metaAction) {
        $settled.classList.add('meta')<commit_msg>hide amount on meta action details<commit_after>'use strict'

;(function (thisDoc) {
  const strftime = require('date-fns').format

  class TransactionDetailComponent extends HTMLElement {
    constructor () {
      super()

      this._debug = false
      this.debug('constructing')

      this.root = this.attachShadow({mode: 'open'})

      const template = thisDoc.querySelector('template')
      this.root.appendChild(document.importNode(template.content, true))
    }

    connectedCallback () {
      this.debug(`connected detail`)

      if (this.tx) {
        this.dataset.category = this.tx.category
        this.render()
      }

      this.$attachments = this.root.querySelector('.attachments')
      this.$scrollInner = this.$attachments.querySelector('.scroll-inner')
      this.$newAttachment = this.root.querySelector('input.new-attachment')

      this.$newAttachment.addEventListener('change', this.uploadAttachment.bind(this))
    }

    render () {
      if (!this.tx) return
      this.debug(`rendering detail`)

      this.renderCategory()
      this.renderIcon()
      this.renderLocation()
      this.renderMerchant()
      this.renderNotes()
      this.renderAttachments()
      this.renderAmount()
      this.renderBalance()
      this.renderDate()
      this.renderId()
      this.renderDescription()
    }

    renderBalance () {
      const balance = this.tx.balance.html(true, 0)
      this.root.querySelector('.balance-wrap').innerHTML = balance
    }

    renderDate () {
      const date = strftime(this.tx.created, 'h:mma - Do MMMM YYYY')
      this.root.querySelector('.date').textContent = date
    }

    renderId () {
      const id = this.tx.id
      this.root.querySelector('.id').textContent = id
    }

    renderDescription () {
      const description = this.tx.description
      this.root.querySelector('.description').textContent = description
    }

    renderAmount () {
      const $amountWrap = this.root.querySelector('.amount-wrap')

      if (!this.tx.is.metaAction) {
        $amountWrap.innerHTML = this.tx.amount.html(true, 0)

        if (this.tx.amount.foreign) {
          $amountWrap.innerHTML += this.tx.amount.exchanged.html(true, 0)
        }
      } else {
        $amountWrap.innerHTML = ''
      }
    }

    renderSettled () {
      const $settled = this.root.querySelector('.settled')

      if (this.tx.settled === 'Settled: Invalid Date') {
        console.warn('Invalid settled date. This may be a bug.')
        $settled.classList.add('meta')
      }

      if (this.tx.is.metaAction) {
        $settled.classList.add('meta')
{'fraction_non_alphanumeric': 0.13605309389029865, 'fraction_numerical': 0.0011711887565879367, 'mean_word_length': 2.580712788259958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6100449', 'n_tokens_mistral': 1508, 'n_tokens_neox': 1479, 'n_words': 248}