/**
 * 
 *     @dfsj/echarts： 专业的水文曲线组件或构造函数以及通用的echart二次封装图表
 *     版本: v3.7.0
 *     作者：yangbo <1747837358@qq.com>
 *     日期：2025-05-27 15:53:33
 *     
 *     
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { onBeforeUnmount, render, unref, defineComponent, h, toRefs, createVNode } from 'vue';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function createComponent(comp, props, target) {
  var vm = null;
  var dom = document.createElement('div');
  function createElNode() {
    var CompWrap = defineComponent({
      render: function render() {
        return h(comp, _objectSpread({}, toRefs(props)));
      }
    });
    vm = createVNode(CompWrap);
    return new Promise(function (resolve) {
      setTimeout(function () {
        render(vm, dom);
        resolve(vm);
      }, 0);
    });
  }
  function close() {
    var _vm, _vm2;
    if ((_vm = vm) !== null && _vm !== void 0 && _vm.el && (_vm2 = vm) !== null && _vm2 !== void 0 && (_vm2 = _vm2.el) !== null && _vm2 !== void 0 && _vm2.parentNode) {
      vm.el.parentNode.removeChild(vm.el);
      render(null, dom);
      vm = null;
    }
  }
  function open() {
    var oDom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : unref(target) || unref(props === null || props === void 0 ? void 0 : props.container) || document.body;
    createElNode().then(function (vm) {
      if (!vm || !(vm !== null && vm !== void 0 && vm.el)) {
        return;
      }
      oDom.appendChild(vm.el);
    });
  }
  onBeforeUnmount(close);
  return {
    vm: vm,
    close: close,
    open: open
  };
}

export { createComponent };
