import { ElSelect as g, ElOption as y } from "element-plus/es";
import { defineComponent as h, ref as _, watch as b, computed as u, createBlock as p, openBlock as i, mergeProps as v, withCtx as w, createElementBlock as B, Fragment as C, renderList as R } from "vue";
import { dictionarySettings as a } from "./config.js";
const S = {
  name: "CiDictionarySelect",
  inheritAttrs: !1
}, O = /* @__PURE__ */ h({
  ...S,
  props: {
    clearable: { type: Boolean, default: !0 },
    filterable: { type: Boolean, default: !0 },
    placeholder: { default: "请选择" },
    collapseTags: { type: Boolean, default: !0 },
    collapseTagsTooltip: { type: Boolean, default: !0 },
    maxCollapseTags: { default: 1 },
    multiple: { type: Boolean, default: !0 },
    dictionaryCode: { default: "" },
    showRange: { default: () => [] },
    noShowRange: { default: () => [] }
  },
  setup(d) {
    const t = d, r = _([]), f = {
      width: a.dictionary_selectWidth
    };
    b(
      () => t.dictionaryCode,
      async (e) => {
        var n;
        if (e) {
          const s = a.dictionary_axios;
          {
            const o = await s({
              url: a.dictionary_url,
              method: "get",
              params: {
                [a.dictionary_request_method_param_key]: e
              }
            });
            o.data = (n = o.data) == null ? void 0 : n.map((l) => ({
              ...l,
              label: l[a.dictionary_label],
              value: l[a.dictionary_value]
            })), r.value = o.data;
          }
        }
      },
      {
        immediate: !0
      }
    );
    const c = u(() => t.showRange.length !== 0 ? r.value.filter((e) => t.showRange.includes(e.value)) : r.value), m = u(() => t.noShowRange.length !== 0 ? c.value.filter((e) => !t.noShowRange.includes(e.value)) : c.value);
    return (e, n) => {
      const s = y, o = g;
      return i(), p(o, v({
        class: "CiDictionarySelect",
        clearable: e.clearable,
        filterable: e.filterable,
        "collapse-tags": e.collapseTags,
        "collapse-tags-tooltip": e.collapseTagsTooltip,
        "max-collapse-tags": e.maxCollapseTags,
        placeholder: e.placeholder,
        multiple: e.multiple
      }, e.$attrs, { style: f }), {
        default: w(() => [
          (i(!0), B(C, null, R(m.value, (l) => (i(), p(s, {
            key: l.value,
            label: l.label,
            value: l.value
          }, null, 8, ["label", "value"]))), 128))
        ]),
        _: 1
      }, 16, ["clearable", "filterable", "collapse-tags", "collapse-tags-tooltip", "max-collapse-tags", "placeholder", "multiple"]);
    };
  }
});
export {
  O as default
};
