import { App } from 'vue'
import { render, createVNode } from 'vue'

import VComponent from './index.vue'

let exportFuncs = null

export default {

  install(app, options) {

    // let exportFuncs = {}

    app.config.globalProperties.$openVideo = (str) => {

      let domEl = document.querySelector('#video-pop')
      let vnode = null 

      if (!domEl) {
        domEl = document.createElement('div')
        domEl.id = 'video-pop'
        document.querySelector('.app-home').appendChild(domEl)
        vnode = createVNode(VComponent)
        render(vnode, domEl)

        exportFuncs = {
          ...vnode.component.exposed
        }
      }

      exportFuncs?.diaOpen(str)

    }

  }

}