'use strict';

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

var vue = require('vue');
require('../../index.js');
var antDesignVue = require('ant-design-vue');
require('../../../hooks/index.js');
require('../../../utils/index.js');
var lodashEs = require('lodash-es');
var modal = require('./modal.js');
var index = require('../../../hooks/use-scroll/index.js');
var createNamespace = require('../../../utils/create-namespace.js');
var index$1 = require('../../button/index.js');

"use strict";
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  ...{ name: "LlNewModal" },
  __name: "modal",
  props: modal.newModalProps,
  emits: modal.newModalEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const attrs = vue.useAttrs();
    const { scrollPosition, isHasScrollBar, scrollRef } = index.useScroll();
    const modal$1 = vue.ref();
    const currentClass = vue.ref("");
    const getBindValue = vue.computed(() => {
      const result = {
        ...lodashEs.omit({ ...attrs }, [...Object.keys(modal.newModalProps), "wrapClassName"])
      };
      if (!props.showFooter) result.footer = null;
      return result;
    });
    const isShowContentBottomBox = vue.computed(() => {
      if (props.footerShadowPlacement === "inner") {
        return props.isShowFooterShadow && isHasScrollBar.value && scrollPosition.value !== "bottom";
      } else {
        return props.isShowFooterShadow;
      }
    });
    const bem = createNamespace.createNamespace("new-modal");
    const handleCancel = () => {
      emits("cancel");
      emits("update:open");
    };
    const handleOk = () => {
      emits("ok");
    };
    const scrollTop = () => {
      if (scrollRef && scrollRef.value) {
        scrollRef.value.scrollTop = 0;
        scrollPosition.value = "top";
      }
    };
    __expose({
      scrollTop
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createBlock(vue.unref(antDesignVue.Modal), vue.mergeProps(getBindValue.value, {
        ref_key: "modal",
        ref: modal$1,
        keyboard: _ctx.keyboard,
        open: _ctx.open,
        "wrap-class-name": `${vue.unref(bem).b()} ${_ctx.wrapClassName} ${currentClass.value}`,
        onCancel: handleCancel,
        onOk: handleOk
      }), vue.createSlots({
        title: vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "title", {}, () => [
            vue.createElementVNode(
              "span",
              null,
              vue.toDisplayString(_ctx.title),
              1
              /* TEXT */
            )
          ])
        ]),
        default: vue.withCtx(() => [
          vue.createElementVNode(
            "div",
            {
              ref_key: "scrollRef",
              ref: scrollRef,
              class: vue.normalizeClass([vue.unref(bem).e("container")])
            },
            [
              vue.renderSlot(_ctx.$slots, "default")
            ],
            2
            /* CLASS */
          )
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        _ctx.$slots["closeIcon"] ? {
          name: "closeIcon",
          fn: vue.withCtx(() => [
            vue.renderSlot(_ctx.$slots, "closeIcon")
          ]),
          key: "0"
        } : void 0,
        _ctx.showFooter ? {
          name: "footer",
          fn: vue.withCtx(() => [
            vue.createElementVNode(
              "div",
              {
                class: vue.normalizeClass(`${vue.unref(bem).e("footer")} ${isShowContentBottomBox.value ? vue.unref(bem).e("footer-shadow") : ""}`)
              },
              [
                vue.renderSlot(_ctx.$slots, "footer", {}, () => [
                  _ctx.type !== "confirm" ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.LlButton), vue.mergeProps({
                    key: 0,
                    label: _ctx.cancelText,
                    size: "middle"
                  }, _ctx.cancelButtonProps, { onClick: handleCancel }), null, 16, ["label"])) : vue.createCommentVNode("v-if", true),
                  vue.createVNode(vue.unref(index$1.LlButton), vue.mergeProps({
                    type: "primary",
                    loading: props.confirmLoading,
                    size: "middle",
                    label: props.confirmText ? props.confirmText : props.type === "confirm" ? "\u77E5\u9053\u4E86" : "\u786E\u8BA4"
                  }, _ctx.okButtonProps, { onClick: handleOk }), null, 16, ["loading", "label"])
                ])
              ],
              2
              /* CLASS */
            )
          ]),
          key: "1"
        } : void 0
      ]), 1040, ["keyboard", "open", "wrap-class-name"]);
    };
  }
});

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