// import Vue from 'vue'
import Charge from './charge.vue'
import i18n from '@/util/lang/lang'

Charge.install = function (Vue, store) {
  const ChargeConstructor = Vue.extend(Charge)
  let instance

  Vue.prototype.$showCharge = (amount = null) => {
    if (instance) {
      document.body.removeChild(instance.$el)
      instance = null
    }

    instance = new ChargeConstructor({
      el: document.createElement('div'),
      computed: {
        $store () { return store }
      },
      data () {
        return {
          showCharge: true,
          amount
        }
      },
      i18n
    })

    document.body.appendChild(instance.$el)
  }

  Vue.prototype.$showWallet = () => {
    if (instance) {
      document.body.removeChild(instance.$el)
      instance = null
    }

    instance = new ChargeConstructor({
      el: document.createElement('div'),
      computed: {
        $store () { return store }
      },
      data () {
        return {
          showWallet: true
        }
      },
      i18n
    })

    document.body.appendChild(instance.$el)
  }

  // Vue.prototype.hide = () =>{
  //   if(instance) {
  //     instance.showWallet = false;
  //     instance.showCharge = false;
  //   }
  // }
}

export default Charge
