import { defineComponent, useModel, createElementBlock, createCommentVNode, openBlock, createVNode, unref, mergeModels } from 'vue';
import { hasOwn } from '../../../../utils/src/objects.mjs';
import { operateButtonProps } from '../operateButton/operateButton.mjs';
import TableOperateVNodeRenderer from './TableOperateVNodeRenderer.mjs';
import { getVnodesByGmName } from './tableHelper.mjs';

const _hoisted_1 = {
  key: 0,
  class: "gm-flex gm-flex-wrap gm-justify-center"
};
var _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "TableProEditSlot",
  props: /* @__PURE__ */ mergeModels({
    tableOperateVnode: { required: true },
    slotValue: { required: true },
    isInited: { type: Boolean, required: false }
  }, {
    "customBtnPropsList": { required: true },
    "customBtnPropsListModifiers": {},
    "customDefaultPropsList": { required: true },
    "customDefaultPropsListModifiers": {}
  }),
  emits: ["update:customBtnPropsList", "update:customDefaultPropsList"],
  setup(__props) {
    const props = __props;
    const customBtnPropsList = useModel(__props, "customBtnPropsList");
    const customDefaultPropsList = useModel(__props, "customDefaultPropsList");
    const getPropsList = () => {
      const defaultVnodes = props.tableOperateVnode?.children?.default?.(props.slotValue);
      const children = getVnodesByGmName(defaultVnodes, "GmOperateButton");
      const btnProps = children.map((vNode) => vNode.props) ?? [];
      btnProps.forEach((it) => {
        for (const key in operateButtonProps) {
          if (hasOwn(it, key)) {
            continue;
          }
          if (hasOwn(operateButtonProps, key)) {
            const element = operateButtonProps[key];
            if (hasOwn(element, "default")) {
              Reflect.set(it, key, Reflect.get(element, "default"));
            }
          }
        }
      });
      return btnProps;
    };
    customDefaultPropsList.value = getPropsList();
    customBtnPropsList.value = customDefaultPropsList.value;
    return (_ctx, _cache) => {
      return __props.tableOperateVnode && __props.tableOperateVnode.children && __props.isInited && __props.slotValue && customBtnPropsList.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(TableOperateVNodeRenderer), {
          vnode: __props.tableOperateVnode.children?.default(__props.slotValue),
          customPropsList: customBtnPropsList.value
        }, null, 8, ["vnode", "customPropsList"])
      ])) : createCommentVNode("v-if", true);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=TableProEditSlot.vue2.mjs.map
