"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const error = require("../../../utils/error.js");
const index = require("../../../hooks/use-namespace/index.js");
const constants = require("./constants.js");
const tabPane = require("./tab-pane.js");
const Vue = require("vue");
const _hoisted_1 = [
  "id",
  "aria-hidden",
  "aria-labelledby"
];
const COMPONENT_NAME = "ElTabPane";
var tab_pane_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: COMPONENT_NAME,
  __name: "tab-pane",
  props: tabPane.tabPaneProps,
  setup(__props) {
    const props = __props;
    const instance = Vue.getCurrentInstance();
    const slots = Vue.useSlots();
    const tabsRoot = Vue.inject(constants.tabsRootContextKey);
    if (!tabsRoot) error.throwError(COMPONENT_NAME, "usage: <el-tabs><el-tab-pane /></el-tabs/>");
    const ns = index.useNamespace("tab-pane");
    const paneRef = Vue.ref();
    const index$1 = Vue.ref();
    const isClosable = Vue.computed(() => props.closable ?? tabsRoot.props.closable);
    const active = Vue.computed(() => tabsRoot.currentName.value === (props.name ?? index$1.value));
    const loaded = Vue.ref(active.value);
    const paneName = Vue.computed(() => props.name ?? index$1.value);
    const shouldBeRender = Vue.computed(() => !props.lazy || loaded.value || active.value);
    const isFocusInsidePane = () => {
      var _a;
      return (_a = paneRef.value) == null ? void 0 : _a.contains(document.activeElement);
    };
    Vue.watch(active, (val) => {
      if (val) loaded.value = true;
    });
    const pane = Vue.reactive({
      uid: instance.uid,
      getVnode: () => instance.vnode,
      slots,
      props,
      paneName,
      active,
      index: index$1,
      isClosable,
      isFocusInsidePane
    });
    tabsRoot.registerPane(pane);
    Vue.onBeforeUnmount(() => {
      tabsRoot.unregisterPane(pane);
    });
    Vue.onBeforeUpdate(() => {
      var _a;
      if (slots.label) (_a = tabsRoot.nav$.value) == null ? void 0 : _a.scheduleRender();
    });
    return (_ctx, _cache) => {
      return shouldBeRender.value ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", {
        key: 0,
        id: `pane-${paneName.value}`,
        ref_key: "paneRef",
        ref: paneRef,
        class: Vue.normalizeClass(Vue.unref(ns).b()),
        role: "tabpanel",
        "aria-hidden": !active.value,
        "aria-labelledby": `tab-${paneName.value}`
      }, [Vue.renderSlot(_ctx.$slots, "default")], 10, _hoisted_1)), [[Vue.vShow, active.value]]) : Vue.createCommentVNode("v-if", true);
    };
  }
});
exports.default = tab_pane_vue_vue_type_script_setup_true_lang_default;
