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

import { isVNode, h } from 'vue';
import { i as isEmpty_1 } from '../_chunks/dep-bd03960e.mjs';
import { i as isString_1 } from '../_chunks/dep-1cf2b129.mjs';
import { i as isFunction_1 } from '../_chunks/dep-6b22dd27.mjs';
import { i as isObject_1 } from '../_chunks/dep-0f0c89ff.mjs';
import { c as camelCase_1 } from '../_chunks/dep-f6649a46.mjs';
import { k as kebabCase_1 } from '../_chunks/dep-c4e1a112.mjs';
import '../_chunks/dep-a0b4a044.mjs';
import '../_chunks/dep-44f056cd.mjs';
import '../_chunks/dep-a9c8a5d5.mjs';
import '../_chunks/dep-c959a6fb.mjs';
import '../_chunks/dep-b4041200.mjs';
import '../_chunks/dep-10085c61.mjs';
import '../_chunks/dep-c31e1d9e.mjs';
import '../_chunks/dep-1b058de3.mjs';
import '../_chunks/dep-39cc276d.mjs';
import '../_chunks/dep-8f777748.mjs';
import '../_chunks/dep-05fa17c9.mjs';
import '../_chunks/dep-e3b14d70.mjs';
import '../_chunks/dep-66d6733b.mjs';
import '../_chunks/dep-92e7085e.mjs';
import '../_chunks/dep-37ba476d.mjs';
import '../_chunks/dep-be27d184.mjs';
import '../_chunks/dep-1fe0ad42.mjs';
import '../_chunks/dep-d54f2690.mjs';
import '../_chunks/dep-59c8420d.mjs';
import '../_chunks/dep-74848b92.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
