import { computed as y, shallowRef as Te, ref as X, watchEffect as ie, provide as We, inject as je, watch as be, createVNode as T, defineComponent as xe, onMounted as He, toRef as pe, toRefs as Be, openBlock as ze, createElementBlock as Xe, unref as Ue } from "vue";
import { d as k, n as Ge, p as qe, q as Se, v as we, x as Je, K as J, _ as Z, i as De, y as Qe, z as Ve, h as oe, o as Ie, B as Ye, A as Ze, f as et, P as ye, g as tt, C as nt, t as lt, D as at, b as ot, E as st, F as it, G as rt, u as ct, H as ut, I as dt, J as vt, c as pt, L as ht, M as ft, N as gt, O as mt, Q as Ct, S as ke, T as St } from "./index2.js";
import { c as yt, u as bt, a as Ce } from "./useMaxLevel.js";
const Oe = "__RC_CASCADER_SPLIT__", $e = "SHOW_PARENT", Ne = "SHOW_CHILD";
function ee(e) {
  return e.join(Oe);
}
function se(e) {
  return e.map(ee);
}
function xt(e) {
  return e.split(Oe);
}
function wt(e) {
  const {
    label: a,
    value: t,
    children: n
  } = e || {}, l = t || "value";
  return {
    label: a || "label",
    value: l,
    key: l,
    children: n || "children"
  };
}
function ce(e, a) {
  var t, n;
  return (t = e.isLeaf) !== null && t !== void 0 ? t : !(!((n = e[a.children]) === null || n === void 0) && n.length);
}
function It(e) {
  const a = e.parentElement;
  if (!a)
    return;
  const t = e.offsetTop - a.offsetTop;
  t - a.scrollTop < 0 ? a.scrollTo({
    top: t
  }) : t + e.offsetHeight - a.scrollTop > a.offsetHeight && a.scrollTo({
    top: t + e.offsetHeight - a.offsetHeight
  });
}
const Ot = (e, a) => y(() => yt(e.value, {
  fieldNames: a.value,
  initWrapper: (n) => k(k({}, n), {
    pathKeyEntities: {}
  }),
  processEntity: (n, l) => {
    const i = n.nodes.map((r) => r[a.value.value]).join(Oe);
    l.pathKeyEntities[i] = n, n.key = i;
  }
}).pathKeyEntities);
function Pt(e) {
  const a = Te(!1), t = X({});
  return ie(() => {
    if (!e.value) {
      a.value = !1, t.value = {};
      return;
    }
    let n = {
      matchInputWidth: !0,
      limit: 50
    };
    e.value && typeof e.value == "object" && (n = k(k({}, n), e.value)), n.limit <= 0 && (delete n.limit, process.env.NODE_ENV !== "production" && Ge(!1, "'limit' of showSearch should be positive number or false.")), a.value = !0, t.value = n;
  }), {
    showSearch: a,
    searchConfig: t
  };
}
const ue = "__rc_cascader_search_mark__", Vt = (e, a, t) => {
  let {
    label: n
  } = t;
  return a.some((l) => String(l[n]).toLowerCase().includes(e.toLowerCase()));
}, kt = (e) => {
  let {
    path: a,
    fieldNames: t
  } = e;
  return a.map((n) => n[t.label]).join(" / ");
}, _t = (e, a, t, n, l, i) => y(() => {
  const {
    filter: r = Vt,
    render: d = kt,
    limit: v = 50,
    sort: c
  } = l.value, o = [];
  if (!e.value)
    return [];
  function C(O, b) {
    O.forEach((D) => {
      if (!c && v > 0 && o.length >= v)
        return;
      const g = [...b, D], x = D[t.value.children];
      // If is leaf option
      (!x || x.length === 0 || // If is changeOnSelect
      i.value) && r(e.value, g, {
        label: t.value.label
      }) && o.push(k(k({}, D), {
        [t.value.label]: d({
          inputValue: e.value,
          path: g,
          prefixCls: n.value,
          fieldNames: t.value
        }),
        [ue]: g
      })), x && C(D[t.value.children], g);
    });
  }
  return C(a.value, []), c && o.sort((O, b) => c(O[ue], b[ue], e.value, t.value)), v > 0 ? o.slice(0, v) : o;
});
function _e(e, a, t) {
  const n = new Set(e);
  return e.filter((l) => {
    const i = a[l], r = i ? i.parent : null, d = i ? i.children : null;
    return t === Ne ? !(d && d.some((v) => v.key && n.has(v.key))) : !(r && !r.node.disabled && n.has(r.key));
  });
}
function de(e, a, t) {
  let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  var l;
  let i = a;
  const r = [];
  for (let d = 0; d < e.length; d += 1) {
    const v = e[d], c = i == null ? void 0 : i.findIndex((C) => {
      const O = C[t.value];
      return n ? String(O) === String(v) : O === v;
    }), o = c !== -1 ? i == null ? void 0 : i[c] : null;
    r.push({
      value: (l = o == null ? void 0 : o[t.value]) !== null && l !== void 0 ? l : v,
      index: c,
      option: o
    }), i = o == null ? void 0 : o[t.children];
  }
  return r;
}
const At = (e, a, t) => y(() => {
  const n = [], l = [];
  return t.value.forEach((i) => {
    de(i, e.value, a.value).every((d) => d.option) ? l.push(i) : n.push(i);
  }), [l, n];
}), Et = (e, a, t, n, l) => y(() => {
  const i = l.value || // Default displayRender
  ((r) => {
    let {
      labels: d
    } = r;
    const v = n.value ? d.slice(-1) : d, c = " / ";
    return v.every((o) => ["string", "number"].includes(typeof o)) ? v.join(c) : v.reduce((o, C, O) => {
      const b = qe(C) ? Se(C, {
        key: O
      }) : C;
      return O === 0 ? [b] : [...o, c, b];
    }, []);
  });
  return e.value.map((r) => {
    const d = de(r, a.value, t.value), v = i({
      labels: d.map((o) => {
        let {
          option: C,
          value: O
        } = o;
        var b;
        return (b = C == null ? void 0 : C[t.value.label]) !== null && b !== void 0 ? b : O;
      }),
      selectedOptions: d.map((o) => {
        let {
          option: C
        } = o;
        return C;
      })
    }), c = ee(r);
    return {
      label: v,
      value: c,
      key: c,
      valueCells: r
    };
  });
}), Re = Symbol("CascaderContextKey"), Tt = (e) => {
  We(Re, e);
}, he = () => je(Re), Dt = () => {
  const e = we(), {
    values: a
  } = he(), [t, n] = Je([]);
  return be(() => e.open, () => {
    if (e.open && !e.multiple) {
      const l = a.value[0];
      n(l || []);
    }
  }, {
    immediate: !0
  }), [t, n];
}, $t = (e, a, t, n, l, i) => {
  const r = we(), d = y(() => r.direction === "rtl"), [v, c, o] = [X([]), X(), X([])];
  ie(() => {
    let g = -1, x = a.value;
    const p = [], w = [], E = n.value.length;
    for (let _ = 0; _ < E && x; _ += 1) {
      const N = x.findIndex(($) => $[t.value.value] === n.value[_]);
      if (N === -1)
        break;
      g = N, p.push(g), w.push(n.value[_]), x = x[g][t.value.children];
    }
    let P = a.value;
    for (let _ = 0; _ < p.length - 1; _ += 1)
      P = P[p[_]][t.value.children];
    [v.value, c.value, o.value] = [w, g, P];
  });
  const C = (g) => {
    l(g);
  }, O = (g) => {
    const x = o.value.length;
    let p = c.value;
    p === -1 && g < 0 && (p = x);
    for (let w = 0; w < x; w += 1) {
      p = (p + g + x) % x;
      const E = o.value[p];
      if (E && !E.disabled) {
        const P = E[t.value.value], _ = v.value.slice(0, -1).concat(P);
        C(_);
        return;
      }
    }
  }, b = () => {
    if (v.value.length > 1) {
      const g = v.value.slice(0, -1);
      C(g);
    } else
      r.toggleOpen(!1);
  }, D = () => {
    var g;
    const p = (((g = o.value[c.value]) === null || g === void 0 ? void 0 : g[t.value.children]) || []).find((w) => !w.disabled);
    if (p) {
      const w = [...v.value, p[t.value.value]];
      C(w);
    }
  };
  e.expose({
    // scrollTo: treeRef.current?.scrollTo,
    onKeydown: (g) => {
      const {
        which: x
      } = g;
      switch (x) {
        case J.UP:
        case J.DOWN: {
          let p = 0;
          x === J.UP ? p = -1 : x === J.DOWN && (p = 1), p !== 0 && O(p);
          break;
        }
        case J.LEFT: {
          d.value ? D() : b();
          break;
        }
        case J.RIGHT: {
          d.value ? b() : D();
          break;
        }
        case J.BACKSPACE: {
          r.searchValue || b();
          break;
        }
        case J.ENTER: {
          if (v.value.length) {
            const p = o.value[c.value], w = (p == null ? void 0 : p[ue]) || [];
            w.length ? i(w.map((E) => E[t.value.value]), w[w.length - 1]) : i(v.value, p);
          }
          break;
        }
        case J.ESC:
          r.toggleOpen(!1), open && g.stopPropagation();
      }
    },
    onKeyup: () => {
    }
  });
};
function fe(e) {
  let {
    prefixCls: a,
    checked: t,
    halfChecked: n,
    disabled: l,
    onClick: i
  } = e;
  const {
    customSlots: r,
    checkable: d
  } = he(), v = d.value !== !1 ? r.value.checkable : d.value, c = typeof v == "function" ? v() : typeof v == "boolean" ? null : v;
  return T("span", {
    class: {
      [a]: !0,
      [`${a}-checked`]: t,
      [`${a}-indeterminate`]: !t && n,
      [`${a}-disabled`]: l
    },
    onClick: i
  }, [c]);
}
fe.props = ["prefixCls", "checked", "halfChecked", "disabled", "onClick"];
fe.displayName = "Checkbox";
fe.inheritAttrs = !1;
const Le = "__cascader_fix_label__";
function ge(e) {
  let {
    prefixCls: a,
    multiple: t,
    options: n,
    activeValue: l,
    prevValuePath: i,
    onToggleOpen: r,
    onSelect: d,
    onActive: v,
    checkedSet: c,
    halfCheckedSet: o,
    loadingKeys: C,
    isSelectable: O
  } = e;
  var b, D, g, x, p, w;
  const E = `${a}-menu`, P = `${a}-menu-item`, {
    fieldNames: _,
    changeOnSelect: N,
    expandTrigger: $,
    expandIcon: U,
    loadingIcon: Q,
    dropdownMenuColumnStyle: G,
    customSlots: M
  } = he(), F = (b = U.value) !== null && b !== void 0 ? b : (g = (D = M.value).expandIcon) === null || g === void 0 ? void 0 : g.call(D), W = (x = Q.value) !== null && x !== void 0 ? x : (w = (p = M.value).loadingIcon) === null || w === void 0 ? void 0 : w.call(p), te = $.value === "hover";
  return T("ul", {
    class: E,
    role: "menu"
  }, [n.map((R) => {
    var h;
    const {
      disabled: I
    } = R, s = R[ue], S = (h = R[Le]) !== null && h !== void 0 ? h : R[_.value.label], m = R[_.value.value], V = ce(R, _.value), K = s ? s.map((u) => u[_.value.value]) : [...i, m], j = ee(K), H = C.includes(j), Y = c.has(j), ne = o.has(j), le = () => {
      !I && (!te || !V) && v(K);
    }, B = () => {
      O(R) && d(K, V);
    };
    let q;
    return typeof R.title == "string" ? q = R.title : typeof S == "string" && (q = S), T("li", {
      key: j,
      class: [P, {
        [`${P}-expand`]: !V,
        [`${P}-active`]: l === m,
        [`${P}-disabled`]: I,
        [`${P}-loading`]: H
      }],
      style: G.value,
      role: "menuitemcheckbox",
      title: q,
      "aria-checked": Y,
      "data-path-key": j,
      onClick: () => {
        le(), (!t || V) && B();
      },
      onDblclick: () => {
        N.value && r(!1);
      },
      onMouseenter: () => {
        te && le();
      },
      onMousedown: (u) => {
        u.preventDefault();
      }
    }, [t && T(fe, {
      prefixCls: `${a}-checkbox`,
      checked: Y,
      halfChecked: ne,
      disabled: I,
      onClick: (u) => {
        u.stopPropagation(), B();
      }
    }, null), T("div", {
      class: `${P}-content`
    }, [S]), !H && F && !V && T("div", {
      class: `${P}-expand-icon`
    }, [Se(F)]), H && W && T("div", {
      class: `${P}-loading-icon`
    }, [Se(W)])]);
  })]);
}
ge.props = ["prefixCls", "multiple", "options", "activeValue", "prevValuePath", "onToggleOpen", "onSelect", "onActive", "checkedSet", "halfCheckedSet", "loadingKeys", "isSelectable"];
ge.displayName = "Column";
ge.inheritAttrs = !1;
const Nt = xe({
  compatConfig: {
    MODE: 3
  },
  name: "OptionList",
  inheritAttrs: !1,
  setup(e, a) {
    const {
      attrs: t,
      slots: n
    } = a, l = we(), i = X(), r = y(() => l.direction === "rtl"), {
      options: d,
      values: v,
      halfValues: c,
      fieldNames: o,
      changeOnSelect: C,
      onSelect: O,
      searchOptions: b,
      dropdownPrefixCls: D,
      loadData: g,
      expandTrigger: x,
      customSlots: p
    } = he(), w = y(() => D.value || l.prefixCls), E = Te([]), P = (h) => {
      if (!g.value || l.searchValue)
        return;
      const s = de(h, d.value, o.value).map((m) => {
        let {
          option: V
        } = m;
        return V;
      }), S = s[s.length - 1];
      if (S && !ce(S, o.value)) {
        const m = ee(h);
        E.value = [...E.value, m], g.value(s);
      }
    };
    ie(() => {
      E.value.length && E.value.forEach((h) => {
        const I = xt(h), s = de(I, d.value, o.value, !0).map((m) => {
          let {
            option: V
          } = m;
          return V;
        }), S = s[s.length - 1];
        (!S || S[o.value.children] || ce(S, o.value)) && (E.value = E.value.filter((m) => m !== h));
      });
    });
    const _ = y(() => new Set(se(v.value))), N = y(() => new Set(se(c.value))), [$, U] = Dt(), Q = (h) => {
      U(h), P(h);
    }, G = (h) => {
      const {
        disabled: I
      } = h, s = ce(h, o.value);
      return !I && (s || C.value || l.multiple);
    }, M = function(h, I) {
      let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
      O(h), !l.multiple && (I || C.value && (x.value === "hover" || s)) && l.toggleOpen(!1);
    }, F = y(() => l.searchValue ? b.value : d.value), W = y(() => {
      const h = [{
        options: F.value
      }];
      let I = F.value;
      for (let s = 0; s < $.value.length; s += 1) {
        const S = $.value[s], m = I.find((K) => K[o.value.value] === S), V = m == null ? void 0 : m[o.value.children];
        if (!(V != null && V.length))
          break;
        I = V, h.push({
          options: V
        });
      }
      return h;
    });
    $t(a, F, o, $, Q, (h, I) => {
      G(I) && M(h, ce(I, o.value), !0);
    });
    const R = (h) => {
      h.preventDefault();
    };
    return He(() => {
      be($, (h) => {
        var I;
        for (let s = 0; s < h.length; s += 1) {
          const S = h.slice(0, s + 1), m = ee(S), V = (I = i.value) === null || I === void 0 ? void 0 : I.querySelector(`li[data-path-key="${m.replace(/\\{0,2}"/g, '\\"')}"]`);
          V && It(V);
        }
      }, {
        flush: "post",
        immediate: !0
      });
    }), () => {
      var h, I, s, S, m;
      const {
        notFoundContent: V = ((h = n.notFoundContent) === null || h === void 0 ? void 0 : h.call(n)) || ((s = (I = p.value).notFoundContent) === null || s === void 0 ? void 0 : s.call(I)),
        multiple: K,
        toggleOpen: j
      } = l, H = !(!((m = (S = W.value[0]) === null || S === void 0 ? void 0 : S.options) === null || m === void 0) && m.length), Y = [{
        [o.value.value]: "__EMPTY__",
        [Le]: V,
        disabled: !0
      }], ne = k(k({}, t), {
        multiple: !H && K,
        onSelect: M,
        onActive: Q,
        onToggleOpen: j,
        checkedSet: _.value,
        halfCheckedSet: N.value,
        loadingKeys: E.value,
        isSelectable: G
      }), B = (H ? [{
        options: Y
      }] : W.value).map((q, u) => {
        const f = $.value.slice(0, u), A = $.value[u];
        return T(ge, Z(Z({
          key: u
        }, ne), {}, {
          prefixCls: w.value,
          options: q.options,
          prevValuePath: f,
          activeValue: A
        }), null);
      });
      return T("div", {
        class: [`${w.value}-menus`, {
          [`${w.value}-menu-empty`]: H,
          [`${w.value}-rtl`]: r.value
        }],
        onMousedown: R,
        ref: i
      }, [B]);
    };
  }
});
function Rt() {
  return k(k({}, Ie(Ze(), ["tokenSeparators", "mode", "showSearch"])), {
    // MISC
    id: String,
    prefixCls: String,
    fieldNames: et(),
    children: Array,
    // Value
    value: {
      type: [String, Number, Array]
    },
    defaultValue: {
      type: [String, Number, Array]
    },
    changeOnSelect: {
      type: Boolean,
      default: void 0
    },
    displayRender: Function,
    checkable: {
      type: Boolean,
      default: void 0
    },
    showCheckedStrategy: {
      type: String,
      default: $e
    },
    // Search
    showSearch: {
      type: [Boolean, Object],
      default: void 0
    },
    searchValue: String,
    onSearch: Function,
    // Trigger
    expandTrigger: String,
    // Options
    options: Array,
    /** @private Internal usage. Do not use in your production. */
    dropdownPrefixCls: String,
    loadData: Function,
    // Open
    /** @deprecated Use `open` instead */
    popupVisible: {
      type: Boolean,
      default: void 0
    },
    dropdownClassName: String,
    dropdownMenuColumnStyle: {
      type: Object,
      default: void 0
    },
    /** @deprecated Use `dropdownStyle` instead */
    popupStyle: {
      type: Object,
      default: void 0
    },
    dropdownStyle: {
      type: Object,
      default: void 0
    },
    /** @deprecated Use `placement` instead */
    popupPlacement: String,
    placement: String,
    /** @deprecated Use `onDropdownVisibleChange` instead */
    onPopupVisibleChange: Function,
    onDropdownVisibleChange: Function,
    // Icon
    expandIcon: ye.any,
    loadingIcon: ye.any
  });
}
function Ke() {
  return k(k({}, Rt()), {
    onChange: Function,
    customSlots: Object
  });
}
function Lt(e) {
  return Array.isArray(e) && Array.isArray(e[0]);
}
function Ae(e) {
  return e ? Lt(e) ? e : (e.length === 0 ? [] : [e]).map((a) => Array.isArray(a) ? a : [a]) : [];
}
const Kt = xe({
  compatConfig: {
    MODE: 3
  },
  name: "Cascader",
  inheritAttrs: !1,
  props: De(Ke(), {}),
  setup(e, a) {
    let {
      attrs: t,
      expose: n,
      slots: l
    } = a;
    const i = Qe(pe(e, "id")), r = y(() => !!e.checkable), [d, v] = Ve(e.defaultValue, {
      value: y(() => e.value),
      postState: Ae
    }), c = y(() => wt(e.fieldNames)), o = y(() => e.options || []), C = Ot(o, c), O = (u) => {
      const f = C.value;
      return u.map((A) => {
        const {
          nodes: L
        } = f[A];
        return L.map((z) => z[c.value.value]);
      });
    }, [b, D] = Ve("", {
      value: y(() => e.searchValue),
      postState: (u) => u || ""
    }), g = (u, f) => {
      D(u), f.source !== "blur" && e.onSearch && e.onSearch(u);
    }, {
      showSearch: x,
      searchConfig: p
    } = Pt(pe(e, "showSearch")), w = _t(b, o, c, y(() => e.dropdownPrefixCls || e.prefixCls), p, pe(e, "changeOnSelect")), E = At(o, c, d), [P, _, N] = [X([]), X([]), X([])], {
      maxLevel: $,
      levelEntities: U
    } = bt(C);
    ie(() => {
      const [u, f] = E.value;
      if (!r.value || !d.value.length) {
        [P.value, _.value, N.value] = [u, [], f];
        return;
      }
      const A = se(u), L = C.value, {
        checkedKeys: z,
        halfCheckedKeys: re
      } = Ce(A, !0, L, $.value, U.value);
      [P.value, _.value, N.value] = [O(z), O(re), f];
    });
    const Q = y(() => {
      const u = se(P.value), f = _e(u, C.value, e.showCheckedStrategy);
      return [...N.value, ...O(f)];
    }), G = Et(Q, o, c, r, pe(e, "displayRender")), M = (u) => {
      if (v(u), e.onChange) {
        const f = Ae(u), A = f.map((re) => de(re, o.value, c.value).map((ve) => ve.option)), L = r.value ? f : f[0], z = r.value ? A : A[0];
        e.onChange(L, z);
      }
    }, F = (u) => {
      if (D(""), !r.value)
        M(u);
      else {
        const f = ee(u), A = se(P.value), L = se(_.value), z = A.includes(f), re = N.value.some((ae) => ee(ae) === f);
        let ve = P.value, Pe = N.value;
        if (re && !z)
          Pe = N.value.filter((ae) => ee(ae) !== f);
        else {
          const ae = z ? A.filter((Fe) => Fe !== f) : [...A, f];
          let me;
          z ? {
            checkedKeys: me
          } = Ce(ae, {
            checked: !1,
            halfCheckedKeys: L
          }, C.value, $.value, U.value) : {
            checkedKeys: me
          } = Ce(ae, !0, C.value, $.value, U.value);
          const Me = _e(me, C.value, e.showCheckedStrategy);
          ve = O(Me);
        }
        M([...Pe, ...ve]);
      }
    }, W = (u, f) => {
      if (f.type === "clear") {
        M([]);
        return;
      }
      const {
        valueCells: A
      } = f.values[0];
      F(A);
    };
    process.env.NODE_ENV !== "production" && ie(() => {
      oe(!e.onPopupVisibleChange, "Cascader", "`popupVisibleChange` is deprecated. Please use `dropdownVisibleChange` instead."), oe(e.popupVisible === void 0, "Cascader", "`popupVisible` is deprecated. Please use `open` instead."), oe(e.popupPlacement === void 0, "Cascader", "`popupPlacement` is deprecated. Please use `placement` instead."), oe(e.popupStyle === void 0, "Cascader", "`popupStyle` is deprecated. Please use `dropdownStyle` instead.");
    });
    const te = y(() => e.open !== void 0 ? e.open : e.popupVisible), R = y(() => e.dropdownStyle || e.popupStyle || {}), h = y(() => e.placement || e.popupPlacement), I = (u) => {
      var f, A;
      (f = e.onDropdownVisibleChange) === null || f === void 0 || f.call(e, u), (A = e.onPopupVisibleChange) === null || A === void 0 || A.call(e, u);
    }, {
      changeOnSelect: s,
      checkable: S,
      dropdownPrefixCls: m,
      loadData: V,
      expandTrigger: K,
      expandIcon: j,
      loadingIcon: H,
      dropdownMenuColumnStyle: Y,
      customSlots: ne,
      dropdownClassName: le
    } = Be(e);
    Tt({
      options: o,
      fieldNames: c,
      values: P,
      halfValues: _,
      changeOnSelect: s,
      onSelect: F,
      checkable: S,
      searchOptions: w,
      dropdownPrefixCls: m,
      loadData: V,
      expandTrigger: K,
      expandIcon: j,
      loadingIcon: H,
      dropdownMenuColumnStyle: Y,
      customSlots: ne
    });
    const B = X();
    n({
      focus() {
        var u;
        (u = B.value) === null || u === void 0 || u.focus();
      },
      blur() {
        var u;
        (u = B.value) === null || u === void 0 || u.blur();
      },
      scrollTo(u) {
        var f;
        (f = B.value) === null || f === void 0 || f.scrollTo(u);
      }
    });
    const q = y(() => Ie(e, [
      "id",
      "prefixCls",
      "fieldNames",
      // Value
      "defaultValue",
      "value",
      "changeOnSelect",
      "onChange",
      "displayRender",
      "checkable",
      // Search
      "searchValue",
      "onSearch",
      "showSearch",
      // Trigger
      "expandTrigger",
      // Options
      "options",
      "dropdownPrefixCls",
      "loadData",
      // Open
      "popupVisible",
      "open",
      "dropdownClassName",
      "dropdownMenuColumnStyle",
      "popupPlacement",
      "placement",
      "onDropdownVisibleChange",
      "onPopupVisibleChange",
      // Icon
      "expandIcon",
      "loadingIcon",
      "customSlots",
      "showCheckedStrategy",
      // Children
      "children"
    ]));
    return () => {
      const u = !(b.value ? w.value : o.value).length, {
        dropdownMatchSelectWidth: f = !1
      } = e, A = (
        // Search to match width
        b.value && p.value.matchInputWidth || // Empty keep the width
        u ? {} : {
          minWidth: "auto"
        }
      );
      return T(Ye, Z(Z(Z({}, q.value), t), {}, {
        ref: B,
        id: i,
        prefixCls: e.prefixCls,
        dropdownMatchSelectWidth: f,
        dropdownStyle: k(k({}, R.value), A),
        displayValues: G.value,
        onDisplayValuesChange: W,
        mode: r.value ? "multiple" : void 0,
        searchValue: b.value,
        onSearch: g,
        showSearch: x.value,
        OptionList: Nt,
        emptyOptions: u,
        open: te.value,
        dropdownClassName: le.value,
        placement: h.value,
        onDropdownVisibleChange: I,
        getRawInputElement: () => {
          var L;
          return (L = l.default) === null || L === void 0 ? void 0 : L.call(l);
        }
      }), l);
    };
  }
}), Mt = (e) => {
  const {
    prefixCls: a,
    componentCls: t,
    antCls: n
  } = e, l = `${t}-menu-item`, i = `
    &${l}-expand ${l}-expand-icon,
    ${l}-loading-icon
  `, r = Math.round((e.controlHeight - e.fontSize * e.lineHeight) / 2);
  return [
    // =====================================================
    // ==                     Control                     ==
    // =====================================================
    {
      [t]: {
        width: e.controlWidth
      }
    },
    // =====================================================
    // ==                      Popup                      ==
    // =====================================================
    {
      [`${t}-dropdown`]: [
        // ==================== Checkbox ====================
        nt(`${a}-checkbox`, e),
        {
          [`&${n}-select-dropdown`]: {
            padding: 0
          }
        },
        {
          [t]: {
            // ================== Checkbox ==================
            "&-checkbox": {
              top: 0,
              marginInlineEnd: e.paddingXS
            },
            // ==================== Menu ====================
            // >>> Menus
            "&-menus": {
              display: "flex",
              flexWrap: "nowrap",
              alignItems: "flex-start",
              [`&${t}-menu-empty`]: {
                [`${t}-menu`]: {
                  width: "100%",
                  height: "auto",
                  [l]: {
                    color: e.colorTextDisabled
                  }
                }
              }
            },
            // >>> Menu
            "&-menu": {
              flexGrow: 1,
              minWidth: e.controlItemWidth,
              height: e.dropdownHeight,
              margin: 0,
              padding: e.paddingXXS,
              overflow: "auto",
              verticalAlign: "top",
              listStyle: "none",
              "-ms-overflow-style": "-ms-autohiding-scrollbar",
              "&:not(:last-child)": {
                borderInlineEnd: `${e.lineWidth}px ${e.lineType} ${e.colorSplit}`
              },
              "&-item": k(k({}, lt), {
                display: "flex",
                flexWrap: "nowrap",
                alignItems: "center",
                padding: `${r}px ${e.paddingSM}px`,
                lineHeight: e.lineHeight,
                cursor: "pointer",
                transition: `all ${e.motionDurationMid}`,
                borderRadius: e.borderRadiusSM,
                "&:hover": {
                  background: e.controlItemBgHover
                },
                "&-disabled": {
                  color: e.colorTextDisabled,
                  cursor: "not-allowed",
                  "&:hover": {
                    background: "transparent"
                  },
                  [i]: {
                    color: e.colorTextDisabled
                  }
                },
                [`&-active:not(${l}-disabled)`]: {
                  "&, &:hover": {
                    fontWeight: e.fontWeightStrong,
                    backgroundColor: e.controlItemBgActive
                  }
                },
                "&-content": {
                  flex: "auto"
                },
                [i]: {
                  marginInlineStart: e.paddingXXS,
                  color: e.colorTextDescription,
                  fontSize: e.fontSizeIcon
                },
                "&-keyword": {
                  color: e.colorHighlight
                }
              })
            }
          }
        }
      ]
    },
    // =====================================================
    // ==                       RTL                       ==
    // =====================================================
    {
      [`${t}-dropdown-rtl`]: {
        direction: "rtl"
      }
    },
    // =====================================================
    // ==             Space Compact                       ==
    // =====================================================
    at(e)
  ];
}, Ft = tt("Cascader", (e) => [Mt(e)], {
  controlWidth: 184,
  controlItemWidth: 111,
  dropdownHeight: 180
});
var Wt = function(e, a) {
  var t = {};
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && a.indexOf(n) < 0 && (t[n] = e[n]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var l = 0, n = Object.getOwnPropertySymbols(e); l < n.length; l++)
    a.indexOf(n[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[l]) && (t[n[l]] = e[n[l]]);
  return t;
};
function jt(e, a, t) {
  const n = e.toLowerCase().split(a).reduce((r, d, v) => v === 0 ? [d] : [...r, a, d], []), l = [];
  let i = 0;
  return n.forEach((r, d) => {
    const v = i + r.length;
    let c = e.slice(i, v);
    i = v, d % 2 === 1 && (c = T("span", {
      class: `${t}-menu-item-keyword`,
      key: "seperator"
    }, [c])), l.push(c);
  }), l;
}
const Ht = (e) => {
  let {
    inputValue: a,
    path: t,
    prefixCls: n,
    fieldNames: l
  } = e;
  const i = [], r = a.toLowerCase();
  return t.forEach((d, v) => {
    v !== 0 && i.push(" / ");
    let c = d[l.label];
    const o = typeof c;
    (o === "string" || o === "number") && (c = jt(String(c), r, n)), i.push(c);
  }), i;
};
function Bt() {
  return k(k({}, Ie(Ke(), ["customSlots", "checkable", "options"])), {
    multiple: {
      type: Boolean,
      default: void 0
    },
    size: String,
    bordered: {
      type: Boolean,
      default: void 0
    },
    placement: {
      type: String
    },
    suffixIcon: ye.any,
    status: String,
    options: Array,
    popupClassName: String,
    /** @deprecated Please use `popupClassName` instead */
    dropdownClassName: String,
    "onUpdate:value": Function
  });
}
const zt = xe({
  compatConfig: {
    MODE: 3
  },
  name: "ACascader",
  inheritAttrs: !1,
  props: De(Bt(), {
    bordered: !0,
    choiceTransitionName: "",
    allowClear: !0
  }),
  setup(e, a) {
    let {
      attrs: t,
      expose: n,
      slots: l,
      emit: i
    } = a;
    process.env.NODE_ENV !== "production" && oe(!e.dropdownClassName, "Cascader", "`dropdownClassName` is deprecated. Please use `popupClassName` instead.");
    const r = st(), d = it.useInject(), v = y(() => rt(d.status, e.status)), {
      prefixCls: c,
      rootPrefixCls: o,
      getPrefixCls: C,
      direction: O,
      getPopupContainer: b,
      renderEmpty: D,
      size: g,
      disabled: x
    } = ct("cascader", e), p = y(() => C("select", e.prefixCls)), {
      compactSize: w,
      compactItemClassnames: E
    } = ut(p, O), P = y(() => w.value || g.value), _ = dt(), N = y(() => {
      var s;
      return (s = x.value) !== null && s !== void 0 ? s : _.value;
    }), [$, U] = vt(p), [Q] = Ft(c), G = y(() => O.value === "rtl");
    process.env.NODE_ENV !== "production" && ie(() => {
      oe(!e.multiple || !e.displayRender || !l.displayRender, "Cascader", "`displayRender` not work on `multiple`. Please use `tagRender` instead.");
    });
    const M = y(() => {
      if (!e.showSearch)
        return e.showSearch;
      let s = {
        render: Ht
      };
      return typeof e.showSearch == "object" && (s = k(k({}, s), e.showSearch)), s;
    }), F = y(() => pt(e.popupClassName || e.dropdownClassName, `${c.value}-dropdown`, {
      [`${c.value}-dropdown-rtl`]: G.value
    }, U.value)), W = X();
    n({
      focus() {
        var s;
        (s = W.value) === null || s === void 0 || s.focus();
      },
      blur() {
        var s;
        (s = W.value) === null || s === void 0 || s.blur();
      }
    });
    const te = function() {
      for (var s = arguments.length, S = new Array(s), m = 0; m < s; m++)
        S[m] = arguments[m];
      i("update:value", S[0]), i("change", ...S), r.onFieldChange();
    }, R = function() {
      for (var s = arguments.length, S = new Array(s), m = 0; m < s; m++)
        S[m] = arguments[m];
      i("blur", ...S), r.onFieldBlur();
    }, h = y(() => e.showArrow !== void 0 ? e.showArrow : e.loading || !e.multiple), I = y(() => e.placement !== void 0 ? e.placement : O.value === "rtl" ? "bottomRight" : "bottomLeft");
    return () => {
      var s, S;
      const {
        notFoundContent: m = (s = l.notFoundContent) === null || s === void 0 ? void 0 : s.call(l),
        expandIcon: V = (S = l.expandIcon) === null || S === void 0 ? void 0 : S.call(l),
        multiple: K,
        bordered: j,
        allowClear: H,
        choiceTransitionName: Y,
        transitionName: ne,
        id: le = r.id.value
      } = e, B = Wt(e, ["notFoundContent", "expandIcon", "multiple", "bordered", "allowClear", "choiceTransitionName", "transitionName", "id"]), q = m || D("Cascader");
      let u = V;
      V || (u = G.value ? T(ht, null, null) : T(ft, null, null));
      const f = T("span", {
        class: `${p.value}-menu-item-loading-icon`
      }, [T(gt, {
        spin: !0
      }, null)]), {
        suffixIcon: A,
        removeIcon: L,
        clearIcon: z
      } = mt(k(k({}, e), {
        hasFeedback: d.hasFeedback,
        feedbackIcon: d.feedbackIcon,
        multiple: K,
        prefixCls: p.value,
        showArrow: h.value
      }), l);
      return Q($(T(Kt, Z(Z(Z({}, B), t), {}, {
        id: le,
        prefixCls: p.value,
        class: [c.value, {
          [`${p.value}-lg`]: P.value === "large",
          [`${p.value}-sm`]: P.value === "small",
          [`${p.value}-rtl`]: G.value,
          [`${p.value}-borderless`]: !j,
          [`${p.value}-in-form-item`]: d.isFormItemInput
        }, Ct(p.value, v.value, d.hasFeedback), E.value, t.class, U.value],
        disabled: N.value,
        direction: O.value,
        placement: I.value,
        notFoundContent: q,
        allowClear: H,
        showSearch: M.value,
        expandIcon: u,
        inputIcon: A,
        removeIcon: L,
        clearIcon: z,
        loadingIcon: f,
        checkable: !!K,
        dropdownClassName: F.value,
        dropdownPrefixCls: c.value,
        choiceTransitionName: ke(o.value, "", Y),
        transitionName: ke(o.value, St(I.value), ne),
        getPopupContainer: b == null ? void 0 : b.value,
        customSlots: k(k({}, l), {
          checkable: () => T("span", {
            class: `${c.value}-checkbox-inner`
          }, null)
        }),
        tagRender: e.tagRender || l.tagRender,
        displayRender: e.displayRender || l.displayRender,
        maxTagPlaceholder: e.maxTagPlaceholder || l.maxTagPlaceholder,
        showArrow: d.hasFeedback || e.showArrow,
        onChange: te,
        onBlur: R,
        ref: W
      }), l)));
    };
  }
}), Ee = ot(k(zt, {
  SHOW_CHILD: Ne,
  SHOW_PARENT: $e
})), Xt = { class: "s-cascader-common" }, Jt = {
  __name: "SCascader",
  props: {
    // 支持清空
    clear: {
      type: Boolean,
      default: !0
    },
    // 默认选中项，支持 v-model 双向绑定
    modelValue: {
      type: [String, Array],
      default() {
        return "";
      }
    },
    // 占位符 - 文案提示
    placeholder: {
      type: String,
      default() {
        return window.$l("请选择");
      }
    },
    // 树节点数据
    options: {
      type: Array,
      default() {
        return [];
      }
    },
    // 禁用
    disabled: {
      type: Boolean,
      default: !1
    },
    // 菜单展开方式
    expandTrigger: {
      type: String,
      default: "click"
    },
    // options 配字段置项
    fieldNames: {
      type: Object,
      default() {
        return {
          label: "name",
          value: "value",
          children: "children"
        };
      }
    },
    // 显示数量
    maxTagCount: {
      type: Number,
      default: 1
    },
    // 多选
    multiple: {
      type: Boolean,
      default: !0
    }
  },
  setup(e) {
    const a = e, t = X("");
    return be(() => a.modelValue, (n) => {
      n != null && n.length && (t.value = n);
    }, { immediate: !0 }), (n, l) => {
      const i = Ee;
      return ze(), Xe("div", Xt, [
        T(i, {
          options: e.options,
          allowClear: e.clear,
          disabled: e.disabled,
          multiple: e.multiple,
          fieldNames: e.fieldNames,
          maxTagCount: e.maxTagCount,
          placeholder: e.placeholder,
          value: t.value,
          "onUpdate:value": l[0] || (l[0] = (r) => t.value = r),
          expandTrigger: e.expandTrigger,
          showCheckedStrategy: Ue(Ee).SHOW_CHILD,
          style: { width: "100%" }
        }, null, 8, ["options", "allowClear", "disabled", "multiple", "fieldNames", "maxTagCount", "placeholder", "value", "expandTrigger", "showCheckedStrategy"])
      ]);
    };
  }
};
export {
  Jt as default
};
