import { defineComponent, ref, watch, resolveComponent, createBlock, openBlock, unref, withCtx, createVNode, withModifiers, createElementVNode } from 'vue';
import '../../../utils/index.mjs';
import { advancedFilteringEmits, advancedFilteringProps } from './advanced-filtering.mjs';
import '../../index.mjs';
import './components/advanced-filtering-params.vue.mjs';
import './components/advanced-filtering-tags.vue.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';
import { LlButton } from '../../button/index.mjs';
import { LlIcon } from '../../icon/index.mjs';
import _sfc_main$1 from './components/advanced-filtering-tags.vue2.mjs';
import _sfc_main$2 from './components/advanced-filtering-params.vue2.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlAdvancedFiltering" },
  __name: "advanced-filtering",
  props: advancedFilteringProps,
  emits: advancedFilteringEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const bem = createNamespace("advanced-filtering");
    const filterValue = ref(props.value);
    const showSelectBox = ref(false);
    const showValueBox = ref(false);
    const handleHoverChange = (visible) => {
      if (showSelectBox.value) return;
      showValueBox.value = visible;
    };
    const handleClickChange = () => {
      showSelectBox.value = !showSelectBox.value;
      showValueBox.value = false;
    };
    const handleClose = () => {
      showSelectBox.value = false;
      showValueBox.value = false;
    };
    const handleChange = (val) => {
      filterValue.value = val;
    };
    watch(
      filterValue,
      (n) => {
        emits("update:value", n);
        emits("change", n);
      },
      {
        deep: true
      }
    );
    return (_ctx, _cache) => {
      const _component_a_popover = resolveComponent("a-popover");
      return openBlock(), createBlock(_component_a_popover, {
        "overlay-class-name": unref(bem).b(),
        placement: "bottomRight",
        "overlay-style": props.overlayStyle,
        open: showSelectBox.value
      }, {
        content: withCtx(() => [
          createVNode(_sfc_main$2, {
            value: filterValue.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => filterValue.value = $event),
            "filter-columns": props.filterColumns,
            "form-options": props.formOptions,
            onClose: handleClose
          }, null, 8, ["value", "filter-columns", "form-options"])
        ]),
        default: withCtx(() => [
          createVNode(_component_a_popover, {
            "overlay-class-name": unref(bem).b(),
            trigger: "hover",
            placement: "bottomRight",
            open: showValueBox.value,
            "overlay-style": props.overlayStyle,
            onOpenChange: handleHoverChange
          }, {
            content: withCtx(() => [
              createVNode(_sfc_main$1, {
                value: filterValue.value,
                "filter-columns": props.filterColumns,
                onChange: handleChange
              }, null, 8, ["value", "filter-columns"])
            ]),
            default: withCtx(() => [
              createVNode(unref(LlButton), {
                onClick: withModifiers(handleClickChange, ["stop"])
              }, {
                default: withCtx(() => [
                  createVNode(unref(LlIcon), {
                    "icon-name": "icon-a-shaixuan1x",
                    style: { "margin-right": "10px" }
                  }),
                  _cache[1] || (_cache[1] = createElementVNode(
                    "span",
                    null,
                    "\u9AD8\u7EA7\u7B5B\u9009",
                    -1
                    /* CACHED */
                  ))
                ]),
                _: 1
                /* STABLE */
              })
            ]),
            _: 1
            /* STABLE */
          }, 8, ["overlay-class-name", "open", "overlay-style"])
        ]),
        _: 1
        /* STABLE */
      }, 8, ["overlay-class-name", "overlay-style", "open"]);
    };
  }
});

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