/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var isFunction = require('lodash/isFunction');
var isString = require('lodash/isString');

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

var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);

function getTargetElm(elm) {
  if (elm) {
    var _process, _process$env;
    var targetElement = null;
    if (isString__default["default"](elm)) targetElement = document.querySelector(elm);else if (isFunction__default["default"](elm)) targetElement = elm();else throw new Error("elm should be string or function");
    if (targetElement) return targetElement;
    if (((_process = process) === null || _process === void 0 ? void 0 : (_process$env = _process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) !== "test") throw new Error("There is no element with given.");
  } else {
    return document.body;
  }
}

exports["default"] = getTargetElm;
//# sourceMappingURL=getTargetElm.js.map
