'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

require('vue');
var shared = require('@vue/shared');
require('lodash/isUndefined');
require('lodash/isNull');
var camelCase = require('lodash/camelCase');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);

function getParentVm(vm) {
    if (vm.$parent !== void 0 && vm.$parent !== null) {
        return vm.$parent;
    }
    vm = vm.$.parent;
    while (vm !== void 0 && vm !== null) {
        if (vm.proxy !== void 0 && vm.proxy !== null) {
            return vm.proxy;
        }
        vm = vm.parent;
    }
}
function getNormalizedVNodes(vnodes) {
    const children = new Set();
    vnodes.forEach(vnode => {
        if (typeof vnode.type === 'symbol' && Array.isArray(vnode.children) === true) {
            vnode.children.forEach(child => {
                children.add(child);
            });
        }
        else {
            children.add(vnode);
        }
    });
    return Array.from(children);
}
function vmHasRouter(vm) {
    return vm.appContext.config.globalProperties.$router !== void 0;
}
function vmHasListener(vm, listenerName) {
    return vm.vnode.props !== null && vm.vnode.props[listenerName] !== void 0;
}
function getInstanceListener(vcInstance, listenerName) {
    const props = vcInstance.vnode.props;
    if (props === null) {
        return undefined;
    }
    const listener = props[`on${shared.capitalize(listenerName)}`] || props[`on${shared.capitalize(camelCase__default['default'](listenerName))}`];
    return listener;
}
function $(ref) {
    return ref.value;
}
function getVcParentInstance(instance) {
    const parentInstance = instance.parent;
    return !parentInstance.cesiumClass && parentInstance.proxy.$options.name !== 'VcViewer'
        ? getVcParentInstance(parentInstance)
        : parentInstance;
}

exports.$ = $;
exports.getInstanceListener = getInstanceListener;
exports.getNormalizedVNodes = getNormalizedVNodes;
exports.getParentVm = getParentVm;
exports.getVcParentInstance = getVcParentInstance;
exports.vmHasListener = vmHasListener;
exports.vmHasRouter = vmHasRouter;
