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

import { isVNode, h } from 'vue';
import { i as isEmpty_1 } from '../_chunks/dep-888e80c4.mjs';
import { i as isString_1 } from '../_chunks/dep-876fb3ec.mjs';
import { i as isFunction_1 } from '../_chunks/dep-5717e263.mjs';
import { i as isObject_1 } from '../_chunks/dep-a8bcacea.mjs';
import { c as camelCase_1 } from '../_chunks/dep-406cd044.mjs';
import { k as kebabCase_1 } from '../_chunks/dep-9a85dac1.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-334a4f6b.mjs';
import '../_chunks/dep-e5eb9f23.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../_chunks/dep-9fe2ef12.mjs';
import '../_chunks/dep-3da99438.mjs';
import '../_chunks/dep-672e7d1a.mjs';
import '../_chunks/dep-4d7a675b.mjs';
import '../_chunks/dep-2e7f59b1.mjs';
import '../_chunks/dep-1434aa15.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-9262ee2f.mjs';
import '../_chunks/dep-42cc3015.mjs';
import '../_chunks/dep-2bc37d52.mjs';
import '../_chunks/dep-327559e8.mjs';
import '../_chunks/dep-b2235f26.mjs';
import '../_chunks/dep-8b989474.mjs';
import '../_chunks/dep-1372b2d3.mjs';

function getDefaultNode(options) {
  var defaultNode;
  if (isObject_1(options) && "defaultNode" in options) defaultNode = options.defaultNode;else if (isVNode(options) || isString_1(options)) defaultNode = options;
  return defaultNode;
}
function getParams(options) {
  return isObject_1(options) && "params" in options ? options.params : {};
}
function handleSlots(instance, params, name) {
  var _instance$$slots$came, _instance$$slots, _instance$$slots$keba, _instance$$slots2;
  var node = (_instance$$slots$came = (_instance$$slots = instance.$slots)[camelCase_1(name)]) === null || _instance$$slots$came === void 0 ? void 0 : _instance$$slots$came.call(_instance$$slots, params);
  if (node) return node;
  node = (_instance$$slots$keba = (_instance$$slots2 = instance.$slots)[kebabCase_1(name)]) === null || _instance$$slots$keba === void 0 ? void 0 : _instance$$slots$keba.call(_instance$$slots2, params);
  if (node) return node;
  return null;
}
var renderTNodeJSX = function renderTNodeJSX(instance, name, options) {
  var params = getParams(options);
  var defaultNode = getDefaultNode(options);
  var propsNode;
  if (name in instance) propsNode = instance[name];
  if (propsNode === false) return;
  if (propsNode === true && defaultNode) return handleSlots(instance, params, name) || defaultNode;
  if (isFunction_1(propsNode)) return propsNode(h, params);
  var isPropsEmpty = [void 0, params, ""].includes(propsNode);
  if (isPropsEmpty && (instance.$slots[camelCase_1(name)] || instance.$slots[kebabCase_1(name)])) return handleSlots(instance, params, name);
  return propsNode;
};
var renderTNodeJSXDefault = function renderTNodeJSXDefault(vm, name, options) {
  var defaultNode = getDefaultNode(options);
  return renderTNodeJSX(vm, name, options) || defaultNode;
};
var renderContent = function renderContent(vm, name1, name2, options) {
  var params = getParams(options);
  var defaultNode = getDefaultNode(options);
  var toParams = params ? {
    params: params
  } : void 0;
  var node1 = renderTNodeJSX(vm, name1, toParams);
  var node2 = renderTNodeJSX(vm, name2, toParams);
  var res = isEmpty_1(node1) ? node2 : node1;
  return isEmpty_1(res) ? defaultNode : res;
};

export { getDefaultNode, getParams, handleSlots, renderContent, renderTNodeJSX, renderTNodeJSXDefault };
//# sourceMappingURL=render-tnode.mjs.map
