"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const shared_esmBundler = require("../../../../../@vue/shared/dist/shared.esm-bundler.js");
const constants$1 = require("./constants.js");
const content2 = require("./content2.js");
const pluginVue_exportHelper = require("../../../_virtual/plugin-vue_export-helper.js");
const useFocusTrap = require("./composables/use-focus-trap.js");
const useContent = require("./composables/use-content.js");
const useContentDom = require("./composables/use-content-dom.js");
const constants = require("../../form/src/constants.js");
const types = require("../../../utils/types.js");
const focusTrap = require("../../focus-trap/src/focus-trap.js");
const isNil = require("../../../../../lodash-es/isNil.js");
const ie = Vue.defineComponent({
  name: "ElPopperContent"
}), ue = /* @__PURE__ */ Vue.defineComponent({
  ...ie,
  props: content2.popperContentProps,
  emits: content2.popperContentEmits,
  setup(A, { expose: b, emit: T }) {
    const t = A, {
      focusStartRef: _,
      trapped: u,
      onFocusAfterReleased: g,
      onFocusAfterTrapped: O,
      onFocusInTrap: N,
      onFocusoutPrevented: S,
      onReleaseRequested: w
    } = useFocusTrap.usePopperContentFocusTrap(t, T), { attributes: y, arrowRef: M, contentRef: a, styles: x, instanceRef: q, role: m, update: B } = useContent.usePopperContent(t), {
      ariaModal: $,
      arrowStyle: h,
      contentAttrs: k,
      contentClass: K,
      contentStyle: d,
      updateZIndex: j
    } = useContentDom.usePopperContentDOM(t, {
      styles: x,
      attributes: y,
      role: m
    }), p = Vue.inject(constants.formItemContextKey, void 0), D = Vue.ref();
    Vue.provide(constants$1.POPPER_CONTENT_INJECTION_KEY, {
      arrowStyle: h,
      arrowRef: M,
      arrowOffset: D
    }), p && (p.addInputId || p.removeInputId) && Vue.provide(constants.formItemContextKey, {
      ...p,
      addInputId: shared_esmBundler.NOOP,
      removeInputId: shared_esmBundler.NOOP
    });
    let r;
    const c = (n = true) => {
      B(), n && j();
    }, J = () => {
      c(false), t.visible && t.focusOnShow ? u.value = true : t.visible === false && (u.value = false);
    };
    return Vue.onMounted(() => {
      Vue.watch(() => t.triggerTargetEl, (n, s) => {
        r == null || r(), r = void 0;
        const o = Vue.unref(n || a.value), l = Vue.unref(s || a.value);
        types.isElement(o) && (r = Vue.watch([m, () => t.ariaLabel, $, () => t.id], (i) => {
          ["role", "aria-label", "aria-modal", "id"].forEach((v, R) => {
            isNil.default(i[R]) ? o.removeAttribute(v) : o.setAttribute(v, i[R]);
          });
        }, { immediate: true })), l !== o && types.isElement(l) && ["role", "aria-label", "aria-modal", "id"].forEach((i) => {
          l.removeAttribute(i);
        });
      }, { immediate: true }), Vue.watch(() => t.visible, J, { immediate: true });
    }), Vue.onBeforeUnmount(() => {
      r == null || r(), r = void 0;
    }), b({
      popperContentRef: a,
      popperInstanceRef: q,
      updatePopper: c,
      contentStyle: d
    }), (n, s) => (Vue.openBlock(), Vue.createElementBlock("div", Vue.mergeProps({
      ref_key: "contentRef",
      ref: a
    }, Vue.unref(k), {
      style: Vue.unref(d),
      class: Vue.unref(K),
      tabindex: "-1",
      onMouseenter: s[0] || (s[0] = (o) => n.$emit("mouseenter", o)),
      onMouseleave: s[1] || (s[1] = (o) => n.$emit("mouseleave", o))
    }), [
      Vue.createVNode(Vue.unref(focusTrap.default), {
        trapped: Vue.unref(u),
        "trap-on-focus-in": true,
        "focus-trap-el": Vue.unref(a),
        "focus-start-el": Vue.unref(_),
        onFocusAfterTrapped: Vue.unref(O),
        onFocusAfterReleased: Vue.unref(g),
        onFocusin: Vue.unref(N),
        onFocusoutPrevented: Vue.unref(S),
        onReleaseRequested: Vue.unref(w)
      }, {
        default: Vue.withCtx(() => [
          Vue.renderSlot(n.$slots, "default")
        ]),
        _: 3
      }, 8, ["trapped", "focus-trap-el", "focus-start-el", "onFocusAfterTrapped", "onFocusAfterReleased", "onFocusin", "onFocusoutPrevented", "onReleaseRequested"])
    ], 16));
  }
});
var Ae = /* @__PURE__ */ pluginVue_exportHelper.default(ue, [["__file", "content.vue"]]);
exports.default = Ae;
