'use strict';

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

var vue = require('vue');
var tableColumn = require('./tableColumn.js');

var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{
    name: "GmTableColumn"
  },
  __name: "TableColumn",
  props: tableColumn.tableColumnProps,
  setup(__props) {
    const slots = vue.useSlots();
    const props = __props;
    const hasDefaultSlot = vue.computed(() => !!slots.default);
    const isColumnComponent = (vnode) => {
      if (!vnode) return false;
      if (vnode.type) {
        const typeName = typeof vnode.type === "object" ? vnode.type.name : null;
        if (typeName === "GmTableColumn" || typeName === "GmTableColumnPro" || typeName === "ElTableColumn") {
          return true;
        }
      }
      if (vnode.children) {
        const children = Array.isArray(vnode.children) ? vnode.children : [vnode.children];
        if (children.some((child) => isColumnComponent(child))) {
          return true;
        }
      }
      return false;
    };
    const isMultiLevelHeader = vue.computed(() => {
      if (!slots.default) return false;
      try {
        const vnodes = slots.default({ row: {}, column: {}, $index: -1 });
        if (!Array.isArray(vnodes)) return false;
        return vnodes.some((vnode) => isColumnComponent(vnode));
      } catch {
        return false;
      }
    });
    return (_ctx, _cache) => {
      const _component_el_table_column = vue.resolveComponent("el-table-column");
      return vue.openBlock(), vue.createElementBlock(
        vue.Fragment,
        null,
        [
          vue.createCommentVNode(" \u65E0\u81EA\u5B9A\u4E49 slot\uFF1A\u4F7F\u7528 el-table-column \u9ED8\u8BA4\u6E32\u67D3 "),
          !hasDefaultSlot.value ? (vue.openBlock(), vue.createBlock(
            _component_el_table_column,
            vue.normalizeProps(vue.mergeProps({ key: 0 }, props)),
            vue.createSlots({
              _: 2
              /* DYNAMIC */
            }, [
              vue.unref(slots).header ? {
                name: "header",
                fn: vue.withCtx((scope) => [
                  vue.renderSlot(_ctx.$slots, "header", vue.normalizeProps(vue.guardReactiveProps(scope)))
                ]),
                key: "0"
              } : void 0
            ]),
            1040
            /* FULL_PROPS, DYNAMIC_SLOTS */
          )) : (vue.openBlock(), vue.createElementBlock(
            vue.Fragment,
            { key: 1 },
            [
              vue.createCommentVNode(" \u6709\u81EA\u5B9A\u4E49 slot "),
              vue.createVNode(
                _component_el_table_column,
                vue.normalizeProps(vue.guardReactiveProps(props)),
                vue.createSlots({
                  default: vue.withCtx((scope) => [
                    vue.createCommentVNode(" \u591A\u7EA7\u8868\u5934\u59CB\u7EC8\u6E32\u67D3\uFF1B\u81EA\u5B9A\u4E49\u5185\u5BB9\u4EC5\u5728 $index !== -1 \u65F6\u6E32\u67D3\uFF08\u907F\u514D el-switch \u7B49\u89E6\u53D1\u526F\u4F5C\u7528\uFF09 "),
                    isMultiLevelHeader.value || scope.$index !== -1 ? vue.renderSlot(_ctx.$slots, "default", vue.normalizeProps(vue.mergeProps({ key: 0 }, scope))) : vue.createCommentVNode("v-if", true)
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, [
                  vue.unref(slots).header ? {
                    name: "header",
                    fn: vue.withCtx((scope) => [
                      vue.renderSlot(_ctx.$slots, "header", vue.normalizeProps(vue.guardReactiveProps(scope)))
                    ]),
                    key: "0"
                  } : void 0
                ]),
                1040
                /* FULL_PROPS, DYNAMIC_SLOTS */
              )
            ],
            2112
            /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
          ))
        ],
        2112
        /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
      );
    };
  }
});

exports.default = _sfc_main;
//# sourceMappingURL=TableColumn.vue2.js.map
