import { defineComponent, ref, inject, watch, onUnmounted, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, renderSlot, createCommentVNode, createBlock, isRef, withCtx, Fragment, renderList, createVNode } from 'vue';
import '../../../table/src/config/index.mjs';
import '../../../../utils/index.mjs';
import '../../../index.mjs';
import { createNamespace } from '../../../../utils/create-namespace.mjs';
import { menuSwitchRadioList, tableHeaderSearchEmits, tableHeaderSearchProps } from '../../../table/src/config/header-search.mjs';
import { LlIcon } from '../../../icon/index.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "TableHeaderSearch"
  },
  __name: "header-search",
  props: tableHeaderSearchProps,
  emits: tableHeaderSearchEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const headerSearchRef = ref();
    const contentType = inject("contentType");
    let observer;
    const emits = __emit;
    const bem = createNamespace("table");
    const handleMenuSwitchChange = (event) => {
      const target = event.target;
      const value = target.value;
      props.menuSwitchOptions.onChange && props.menuSwitchOptions.onChange(value);
      emits("change", value);
    };
    watch(
      headerSearchRef,
      () => {
        if (headerSearchRef.value) {
          if (!observer) {
            observer = new MutationObserver(function(mutations) {
              mutations.forEach(function() {
                const newHeight = headerSearchRef.value.getBoundingClientRect().height;
                emits("changeHeaderSearch", newHeight);
              });
            });
            const config = {
              childList: true,
              // 观察直接子节点
              subtree: true
              // 及其更低的后代节点
            };
            observer?.observe(headerSearchRef.value, config);
          }
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
    onUnmounted(() => {
      if (observer) {
        observer.disconnect();
      }
    });
    return (_ctx, _cache) => {
      const _component_a_radio_button = resolveComponent("a-radio-button");
      const _component_a_radio_group = resolveComponent("a-radio-group");
      return openBlock(), createElementBlock(
        "div",
        {
          ref_key: "headerSearchRef",
          ref: headerSearchRef,
          class: normalizeClass(`${unref(bem).e("header-wrapper")}`)
        },
        [
          createElementVNode(
            "div",
            {
              class: normalizeClass(unref(bem).e("header"))
            },
            [
              renderSlot(_ctx.$slots, "header", {}, () => [
                createCommentVNode(" \u5DE6\u8FB9\u7684\u63D2\u69FD "),
                createElementVNode(
                  "div",
                  {
                    class: normalizeClass(unref(bem).e("header-left"))
                  },
                  [
                    renderSlot(_ctx.$slots, "headerLeft")
                  ],
                  2
                  /* CLASS */
                ),
                createCommentVNode(" \u5185\u5BB9\u4E2D\u95F4\u63D2\u69FD "),
                createElementVNode(
                  "div",
                  {
                    class: normalizeClass(unref(bem).e("header-middle"))
                  },
                  [
                    renderSlot(_ctx.$slots, "headerMiddle")
                  ],
                  2
                  /* CLASS */
                ),
                createElementVNode(
                  "div",
                  {
                    class: normalizeClass(unref(bem).e("header-right"))
                  },
                  [
                    renderSlot(_ctx.$slots, "headerRight"),
                    createCommentVNode(" \u5207\u6362table\u548Clist\u83DC\u5355 "),
                    props.menuSwitchOptions?.show ? (openBlock(), createBlock(_component_a_radio_group, {
                      key: 0,
                      value: unref(contentType),
                      "onUpdate:value": _cache[0] || (_cache[0] = ($event) => isRef(contentType) ? contentType.value = $event : null),
                      class: normalizeClass(`${unref(bem).e("header-menu-radio-group")}`),
                      onChange: handleMenuSwitchChange
                    }, {
                      default: withCtx(() => [
                        (openBlock(true), createElementBlock(
                          Fragment,
                          null,
                          renderList(unref(menuSwitchRadioList), (menuItem) => {
                            return openBlock(), createBlock(_component_a_radio_button, {
                              key: menuItem.value,
                              class: normalizeClass(`${unref(bem).e("header-menu-icon")}`),
                              value: menuItem.value
                            }, {
                              default: withCtx(() => [
                                createVNode(unref(LlIcon), {
                                  "icon-name": menuItem.icon,
                                  size: 18
                                }, null, 8, ["icon-name"])
                              ]),
                              _: 2
                              /* DYNAMIC */
                            }, 1032, ["class", "value"]);
                          }),
                          128
                          /* KEYED_FRAGMENT */
                        ))
                      ]),
                      _: 1
                      /* STABLE */
                    }, 8, ["value", "class"])) : createCommentVNode("v-if", true)
                  ],
                  2
                  /* CLASS */
                )
              ])
            ],
            2
            /* CLASS */
          )
        ],
        2
        /* CLASS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=header-search.vue2.mjs.map
