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

import VComponent from './index.vue'


export default {

  install(app, options) {

    let exportFuncs = {}

    app.config.globalProperties.$openImage = (images, str,cp) => {

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

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

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

      exportFuncs?.diaOpen(images, str,cp)

    }

  }

}