import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                     */
/* empty css                                                                     */
import { ref, onMounted, resolveDirective, createBlock, createCommentVNode, unref, openBlock, withCtx, createElementBlock, Fragment, renderList, withDirectives, createTextVNode, toDisplayString } from "vue";
/* empty css             */
import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElFooter } from "../../../../../../node_modules/element-plus/es/components/container/index.mjs";
import { ElButton } from "../../../../../../node_modules/element-plus/es/components/button/index.mjs";
const _sfc_main = {
  __name: "Footer",
  props: {
    pageFooterConfig: {
      type: Object,
      required: true,
      default: () => ({
        buttons: []
      })
    },
    formMode: {
      type: String,
      default: ""
    }
  },
  emits: ["cancel", "submit", "custom-button-click"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const formDetailsFooterRef = ref();
    const handleButtonClick = (button) => {
      emit("custom-button-click", button);
    };
    const showFooter = ref(true);
    onMounted(() => {
      var _a;
      const layoutDom = (_a = formDetailsFooterRef.value) == null ? void 0 : _a.$el.closest(".fec-layout-row");
      if (layoutDom && props.formMode == "query") {
        showFooter.value = false;
      }
    });
    return (_ctx, _cache) => {
      var _a;
      const _component_el_button = ElButton;
      const _component_el_footer = ElFooter;
      const _directive_fec_auth = resolveDirective("fec-auth");
      return __props.pageFooterConfig.enabled && ((_a = __props.pageFooterConfig.actions) == null ? void 0 : _a.length) && unref(showFooter) ? (openBlock(), createBlock(_component_el_footer, {
        key: 0,
        class: "form-details-footer",
        ref_key: "formDetailsFooterRef",
        ref: formDetailsFooterRef
      }, {
        default: withCtx(() => [
          (openBlock(true), createElementBlock(Fragment, null, renderList(__props.pageFooterConfig.actions, (button) => {
            return openBlock(), createElementBlock(Fragment, {
              key: button.id
            }, [
              button.btnType == "default" || button.btnType == "primary" && __props.formMode == "edit" ? withDirectives((openBlock(), createBlock(_component_el_button, {
                key: 0,
                type: button.btnType,
                onClick: ($event) => handleButtonClick(button)
              }, {
                default: withCtx(() => [
                  createTextVNode(toDisplayString(button.label), 1)
                ]),
                _: 2
              }, 1032, ["type", "onClick"])), [
                [_directive_fec_auth, button.permission]
              ]) : createCommentVNode("", true)
            ], 64);
          }), 128))
        ]),
        _: 1
      }, 512)) : createCommentVNode("", true);
    };
  }
};
const component = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-deabd2d2"]]);
export {
  component as default
};
