import { defineComponent as le, inject as X, ref as Q, resolveComponent as oe, openBlock as J, createElementBlock as P, Fragment as ae, renderList as ue, createElementVNode as V, withModifiers as xe, normalizeClass as re, createVNode as se, createBlock as ne, createCommentVNode as Y, reactive as ce, computed as te, watch as z, onMounted as ie, nextTick as Z, normalizeStyle as ge, toDisplayString as fe, unref as Se, withDirectives as Ee, vShow as be, provide as ye, renderSlot as pe, useSlots as we, withCtx as de, mergeProps as me } from "vue";
import { C as e } from "../Shared/base-PQGakkrl.js";
import { _ as _e } from "../Shared/List.vue_vue_type_script_setup_true_lang-DzmylhZ6.js";
import { C as ve } from "../Shared/index-BnerInzC.js";
import { u as Ce } from "../Shared/language-DxTlvFs2.js";
const Te = ["onClick"], ke = ["innerHTML"], De = /* @__PURE__ */ le({
  name: "ClSelectmoveSearchUl",
  __name: "SearchTree",
  props: {
    list: {
      type: Array,
      default: () => []
    }
  },
  emits: ["onClick"],
  setup(g, { emit: W }) {
    const l = W, d = X("$SelectmoveTop"), y = Q(`selectmove-search-tree-${d.keyIndex}`), K = (a) => {
      l("onClick", a.toString());
    }, n = (a) => {
      K(a);
    }, T = (a) => {
      K(a);
    };
    return (a, b) => {
      const I = oe("cl-checkbox-one"), L = oe("ClSelectmoveSearchUl");
      return J(), P("ul", null, [
        (J(!0), P(ae, null, ue(g.list, (M, j) => (J(), P("li", {
          key: `${y.value}-${j}`
        }, [
          V("a", {
            href: "javascript:",
            tabindex: "-1",
            class: re({ "tree-hig": M.isHig, "tree-active": M.isSelected }),
            onClick: xe((H) => n(M.id), ["prevent", "stop"])
          }, [
            se(I, {
              value: M.isSelected,
              indeterminate: M.isIndeterminate
            }, null, 8, ["value", "indeterminate"]),
            V("span", {
              class: "tree-text",
              innerHTML: M.showTextLabel
            }, null, 8, ke)
          ], 10, Te),
          M.list.length > 0 ? (J(), ne(L, {
            key: 0,
            list: M.list,
            onOnClick: T
          }, null, 8, ["list"])) : Y("", !0)
        ]))), 128))
      ]);
    };
  }
}), Je = { class: "selectmove-search-list" }, Le = { key: 1 }, Me = { class: "selectmove-search-empty" }, Ae = /* @__PURE__ */ le({
  name: "ClSelectmoveSearch",
  __name: "Search",
  props: {
    isDisabled: Boolean,
    placeholder: String,
    width: Number,
    searchKey: {
      type: Array,
      default: () => ["name"]
    },
    searchKeyType: {
      type: String,
      default: "||"
    },
    searchIsMultiple: {
      type: Boolean,
      default: !1
    },
    searchMultipleJoin: {
      type: String,
      default: ","
    },
    searchTextFormat: [String, Array],
    selectId: {
      type: Array,
      default: () => []
    },
    parentKey: {
      type: String,
      default: "parentId"
    },
    topParentValue: {
      type: String,
      default: "0"
    }
  },
  emits: ["onChange"],
  setup(g, { emit: W }) {
    const l = g, d = W, { optPageLanguage: y, getPageLanguage: K } = Ce();
    K("common");
    const n = X("$SelectmoveTop"), T = X("$SelectmoveBase"), a = ce({
      keyIndex: `selectmove-search-${n.keyIndex}`,
      isOpen: !1,
      isInitSelect: !1
    }), b = Q([]), I = Q([]), L = {
      jsonSelectIds: {},
      jsonSelectHalfIds: []
    }, M = te(() => ({
      "selectmove-search-input": !0,
      "selectmove-search-open": a.isOpen
    })), j = te(() => ({
      "selectmove-search-dropdown": !0,
      "selectmove-search-open": a.isOpen
    })), H = te(() => {
      const r = {};
      return l.width && l.width > 0 && (r.width = `${l.width}px`), r;
    }), N = () => {
      d("onChange", I.value.join(","));
    }, u = () => {
      a.isOpen = !1, b.value = [];
    }, c = (r) => {
      const i = T.convertSelectHalf(r);
      I.value = r, L.jsonSelectHalfIds = e.getArrConvertJson(i), L.jsonSelectIds = e.getArrConvertJson(r);
    }, S = (r) => {
      const i = [], x = r.toLowerCase(), E = l.searchIsMultiple ? x.split(l.searchMultipleJoin) : [x], _ = l.searchKey.length, D = l.searchKey;
      return n.getDataList().forEach((w) => {
        const R = w.id.toString(), $ = [];
        for (let q = 0; q < _; q++) {
          const t = w[D[q]].toLowerCase();
          for (let h = 0; h < E.length; h++)
            E[h].length > 0 && t.indexOf(E[h]) > -1 && $.push(!0);
        }
        if ($.length > 0)
          switch (l.searchKeyType) {
            case "||":
              i.push(R);
              break;
            case "&&":
              $.length === _ && i.push(R);
              break;
          }
      }), i;
    }, m = (r, i, x, E) => {
      const _ = [];
      return e.isExistJsonKey(i, r) && i[r].forEach((D) => {
        const w = e.getJsonClone(n.getDataInfo(D));
        let R = w.name;
        const $ = l.searchTextFormat;
        if ($ && $.length > 0) {
          let h = "";
          e.isArray($) ? $.length > x && (h = $[x]) : e.isString($) && (h = $), e.isEmpty(h) || (R = e.convertStringFormat(h, w));
        }
        w.showTextLabel = R;
        let q = !1, t = e.isExistJsonKey(i, D);
        t ? w.list = m(D, i, ++x, E) : (q = !0, w.list = [], n.getDataGroup(D).length > 0 && (t = !0, q = !1)), w.isIndeterminate = e.isExistJsonKey(L.jsonSelectHalfIds, D), w.isSelected = e.isExistJsonKey(L.jsonSelectIds, D), w.isChild = t, w.isLast = q, w.treeLevel = x, w.isHig = e.isExistJsonKey(E, D), _.push(w);
      }), _;
    }, v = (r) => {
      const { parentKey: i, topParentValue: x } = l, E = {};
      let _ = [];
      r.forEach((w) => {
        E[w] = !0;
        const R = T.getParentIds(w);
        _.push(...R), _.push(w);
      }), _ = e.getArrUnique(_);
      const D = {};
      return _.forEach((w) => {
        const R = n.getDataInfo(w)[i].toString(), $ = R === x ? n.getTopParentValue() : R;
        e.isExistJsonKey(D, $) || (D[$] = []), D[$].push(w);
      }), m(n.getTopParentValue(), D, 0, E);
    }, s = (r) => {
      if (e.isEmpty(r))
        u();
      else {
        if (a.isInitSelect && (a.isInitSelect = !1, !e.isEqualArr(l.selectId, I.value))) {
          const _ = T.convertSelectedValue(l.selectId, !0, []);
          c(_);
        }
        const i = S(r), x = v(i);
        b.value = x, a.isOpen = !0;
      }
    }, o = (r) => {
      const i = [];
      return r.forEach((x) => {
        const E = e.getJsonClone(x), _ = E.id.toString();
        E.isIndeterminate = e.isExistJsonKey(L.jsonSelectHalfIds, _), E.isSelected = e.isExistJsonKey(L.jsonSelectIds, _), E.list && E.list.length > 0 && (E.list = o(E.list)), i.push(E);
      }), i;
    }, f = (r) => {
      if (a.isOpen) {
        const i = ve.getParent(r.target, ".selectmove-search");
        e.isUndefined(i) && (a.isOpen = !1);
      }
    };
    z(
      () => a.isOpen,
      (r) => {
        r ? document.body.addEventListener("click", f) : document.body.removeEventListener("click", f);
      }
    ), z(
      () => l.selectId,
      () => {
        a.isInitSelect = !0;
      }
    ), ie(() => {
      Z(() => {
      });
    });
    const p = (r) => {
      s(r);
    }, k = (r) => {
      a.isOpen || s(r);
    }, C = (r) => {
      const i = e.isExistJsonKey(L.jsonSelectIds, r), x = T.convertSelectedValue(r, !i, I.value);
      c(x);
      const E = o(b.value);
      b.value = [], Z(() => {
        b.value = E;
      }), N();
    };
    return (r, i) => {
      const x = oe("cl-input-search");
      return J(), P("div", {
        class: "selectmove-search",
        style: ge(H.value)
      }, [
        V("div", {
          class: re(M.value)
        }, [
          se(x, {
            placeholder: g.placeholder,
            disabled: g.isDisabled,
            changDelayTime: 1e3,
            onOnChange: p,
            onOnFocus: k
          }, null, 8, ["placeholder", "disabled"])
        ], 2),
        a.isOpen ? (J(), P("div", {
          key: 0,
          class: re(j.value)
        }, [
          V("div", Je, [
            b.value.length > 0 ? (J(), ne(De, {
              key: 0,
              list: b.value,
              onOnClick: C
            }, null, 8, ["list"])) : (J(), P("ul", Le, [
              V("li", Me, fe(Se(y).noResultsText), 1)
            ]))
          ])
        ], 2)) : Y("", !0)
      ], 4);
    };
  }
}), Ve = { class: "selectmove-tree" }, Ke = { class: "selectmove-tree-head" }, Pe = { class: "selectmove-tree-head-title" }, $e = { class: "selectmove-tree-body" }, Fe = ["onClick"], Oe = ["innerHTML"], Be = {
  key: 0,
  class: "clIconFont clIcon-angle-right sub-icon"
}, Re = /* @__PURE__ */ le({
  name: "ClSelectmoveTree",
  __name: "Tree",
  props: {
    isDisabled: Boolean,
    maxWidth: Number,
    width: Number,
    treeTitle: {
      type: Array,
      default: () => []
    },
    treeShowMinLevel: {
      type: Number,
      default: 1
    },
    treeTextFormat: [String, Array],
    selectId: {
      type: Array,
      default: () => []
    },
    dataRefreshIndex: Number
  },
  emits: ["onChange"],
  setup(g, { emit: W }) {
    const l = g, d = W, y = X("$SelectmoveTop"), K = X("$SelectmoveBase"), n = ce({
      keyIndex: `selectmove-tree-${y.keyIndex}`,
      selectIds: [],
      HalfSelectIds: [],
      openActiveId: []
    }), T = Q([]), a = () => {
      d("onChange", n.selectIds.join(","));
    }, b = (s) => {
      let o = 0;
      const f = y.getDataGroup(s);
      if (f.length > 0) {
        const p = [], k = [];
        f.forEach((C) => {
          const r = C.id.toString();
          e.isExistValue(n.selectIds, r) && p.push(r), e.isExistValue(n.HalfSelectIds, r) && k.push(r);
        }), (k.length > 0 || p.length > 0) && (o = 2), p.length > 0 && p.length === f.length && (o = 1);
      }
      return o;
    }, I = (s, o, f) => {
      const p = {
        idx: s,
        pId: o,
        title: l.treeTitle.length > s ? l.treeTitle[s] : f,
        list: [],
        checkAll: 0,
        sty: {}
      };
      if (l.width && l.maxWidth && l.width > 0) {
        let k = l.width - 3;
        const C = l.maxWidth / l.width;
        s + 1 >= C && (k += 3), p.sty.width = `${k}px`;
      }
      if (!e.isEmpty(o)) {
        const k = y.getDataGroup(o);
        k.length > 0 && (p.list = k.map((C) => {
          const r = C.id.toString(), i = e.getJsonClone(C);
          i.selected = e.isExistValue(n.selectIds, r), i.indeterminate = e.isExistValue(n.HalfSelectIds, r), i.isActive = e.isExistValue(n.openActiveId, r);
          const x = y.getDataGroup(r);
          i._childCount = x.length, i.isSub = i._childCount > 0;
          let E = C.name;
          const _ = l.treeTextFormat;
          if (_ && _.length > 0) {
            let D = "";
            e.isArray(_) ? _.length > s && (D = _[s]) : e.isString(_) && (D = _), e.isEmpty(D) || (E = e.convertStringFormat(D, i));
          }
          return i.showTextLabel = E, i;
        })), p.checkAll = b(o);
      }
      return p;
    }, L = (s) => {
      const o = K.convertSelectedValue(s, !0, []), f = K.convertSelectHalf(o);
      n.selectIds = o, n.HalfSelectIds = f;
    }, M = (s, o) => {
      const f = [];
      T.value.forEach((p, k) => {
        k <= s && f.push(I(p.idx, p.pId, p.title));
      }), y.getDataGroup(o).length > 0 && f.push(I(s + 1, o, y.getDataInfo(o).name)), T.value = f;
    }, j = (s, o) => {
      const f = s.id.toString(), p = e.getArrClone(n.openActiveId);
      p.splice(o), p.push(f), n.openActiveId = p, M(o, f);
    }, H = (s, o) => {
      const f = K.convertSelectedValue(s, o, n.selectIds), p = K.convertSelectHalf(f);
      n.selectIds = f, n.HalfSelectIds = p, T.value = T.value.map((k) => I(k.idx, k.pId, k.title)), a();
    }, N = () => {
      const s = T.value.length;
      if (s > 0 && n.selectIds.length > 0) {
        let o;
        T.value[s - 1].list.some((f) => {
          if (f.selected || f.indeterminate)
            return o = f, !0;
        }), e.isUndefined(o) || o.isSub && (j(o, s - 1), N());
      }
    }, u = () => {
      const s = [];
      return s.push(I(0, y.getTopParentValue(), "")), s;
    }, c = () => {
      e.isEmpty(l.selectId) || (n.selectIds = e.getArrClone(l.selectId), L(l.selectId)), T.value = u(), N(), l.treeShowMinLevel > 1 && n.selectIds.length === 0 && Z(() => {
        const s = T.value.length;
        if (l.treeShowMinLevel > s) {
          const o = [];
          for (let f = s; f < l.treeShowMinLevel; f++)
            o.push(I(f, "", ""));
          T.value = T.value.concat(o);
        }
      });
    };
    z(
      () => l.dataRefreshIndex,
      () => {
        n.selectIds = e.getArrClone(l.selectId), c();
      }
    ), z(
      () => l.selectId,
      (s) => {
        e.isEqualArr(s, n.selectIds) || (L(s), T.value = T.value.map(
          (f) => I(f.idx, f.pId, f.title)
        ));
      }
    ), ie(() => {
      Z(() => {
        c();
      });
    });
    const S = (s, o) => {
      const f = y.getDataGroup(o.toString()).map((p) => p.id.toString());
      H(f, s.value);
    }, m = (s, o) => {
      H(o.toString(), s.value);
    }, v = (s, o, f) => {
      const p = o.id.toString();
      e.isEmpty(y.getDataGroup(p)) && (ve.getParent(s.target, ".selectmove-option-checkbox", ".selectmove-option") || H(p.toString(), !e.isExistValue(n.selectIds, p)));
      const k = e.getArrClone(n.openActiveId);
      k.splice(f), k.push(p), n.openActiveId = k, M(f, p);
    };
    return (s, o) => {
      const f = oe("cl-checkbox-one");
      return J(), P("div", Ve, [
        (J(!0), P(ae, null, ue(T.value, (p, k) => (J(), P("div", {
          key: `${n.keyIndex}-tree-${k}`,
          class: "selectmove-tree-item",
          style: ge(p.sty)
        }, [
          V("div", Ke, [
            Ee(se(f, {
              disabled: g.isDisabled,
              value: p.checkAll === 1,
              indeterminate: p.checkAll === 2,
              valueData: p.pId,
              onOnChange: (C) => S(C, p.pId)
            }, null, 8, ["disabled", "value", "indeterminate", "valueData", "onOnChange"]), [
              [be, p.list.length > 0]
            ]),
            V("div", Pe, fe(p.title), 1)
          ]),
          V("div", $e, [
            V("ul", null, [
              (J(!0), P(ae, null, ue(p.list, (C, r) => (J(), P("li", {
                key: `${n.keyIndex}-option-${r}`,
                class: re({ "selectmove-option": !0, active: C.isActive }),
                onClick: (i) => v(i, C, k)
              }, [
                V("div", null, [
                  se(f, {
                    className: "selectmove-option-checkbox",
                    disabled: g.isDisabled,
                    value: C.selected,
                    indeterminate: C.indeterminate,
                    onOnChange: (i) => m(i, C.id)
                  }, null, 8, ["disabled", "value", "indeterminate", "onOnChange"]),
                  V("div", {
                    class: "selectmove-option-text",
                    innerHTML: C.showTextLabel
                  }, null, 8, Oe),
                  C.isSub ? (J(), P("i", Be)) : Y("", !0)
                ])
              ], 10, Fe))), 128))
            ])
          ])
        ], 4))), 128))
      ]);
    };
  }
}), je = { class: "selectmove-result" }, He = { class: "selectmove-result-head" }, Ne = ["innerHTML"], Ue = { class: "selectmove-result-body" }, We = ["innerHTML"], qe = ["onClick"], Ge = /* @__PURE__ */ le({
  name: "ClSelectmoveResult",
  __name: "Result",
  props: {
    isDisabled: Boolean,
    width: Number,
    resultCountFormat: String,
    resultTextFormat: String,
    resultMergeParent: Boolean,
    selectId: {
      type: Array,
      default: () => []
    },
    dataRefreshIndex: Number
  },
  emits: ["onChange"],
  setup(g, { emit: W }) {
    const l = g, d = W, { optPageLanguage: y, getPageLanguage: K } = Ce();
    K("common");
    const n = X("$SelectmoveTop"), T = X("$SelectmoveBase"), a = ce({
      keyIndex: `selectmove-result-${n.keyIndex}`,
      totalCount: 0
    }), b = Q([]), I = te(() => l.resultCountFormat && !e.isEmpty(l.resultCountFormat) ? e.convertStringFormat(l.resultCountFormat, { _count: a.totalCount }) : `${y.value.selected} ${a.totalCount} ${y.value.count}`), L = te(() => {
      const c = {};
      return l.width && l.width > 0 && (c.width = `${l.width}px`), c;
    }), M = (c) => {
      d("onChange", c.join(","));
    }, j = (c) => e.isEmpty(c) ? [] : (l.resultMergeParent ? T.getValueMergeParent(c) : T.getValueSplitChild(c)).map((m) => {
      const v = e.getJsonClone(n.getDataInfo(m)), s = l.resultTextFormat;
      return v.showTextLabel = s && s.length > 0 ? e.convertStringFormat(s, v) : v.name, v;
    }), H = () => {
      e.isEmpty(l.selectId) || (b.value = j(l.selectId), a.totalCount = b.value.length);
    };
    z(
      () => l.selectId,
      (c) => {
        const S = b.value.map((v) => v.id.toString());
        e.isEqualArr(c, S) || (b.value = j(c), a.totalCount = b.value.length);
      }
    ), z(
      () => l.dataRefreshIndex,
      () => {
        b.value = j(l.selectId), a.totalCount = b.value.length;
      }
    ), ie(() => {
      Z(() => {
        H();
      });
    });
    const N = () => {
      b.value = [], a.totalCount = 0, M([]);
    }, u = (c) => {
      const S = [], m = [], v = c.id.toString();
      b.value.forEach((s) => {
        const o = s.id.toString();
        o !== v && (m.push(e.getJsonClone(s)), S.push(o));
      }), b.value = m, a.totalCount = m.length, M(S);
    };
    return (c, S) => (J(), P("div", je, [
      V("div", {
        class: "selectmove-result-container",
        style: ge(L.value)
      }, [
        V("div", He, [
          V("span", null, [
            g.isDisabled ? Y("", !0) : (J(), P("button", {
              key: 0,
              class: "btn btn-cleanAll",
              type: "button",
              onClick: N
            }, fe(Se(y).deleteAll), 1))
          ]),
          V("span", { innerHTML: I.value }, null, 8, Ne)
        ]),
        V("div", Ue, [
          V("ul", null, [
            (J(!0), P(ae, null, ue(b.value, (m, v) => (J(), P("li", {
              key: `${a.keyIndex}-${v}-${m.id}`
            }, [
              V("div", null, [
                V("div", {
                  innerHTML: m.showTextLabel
                }, null, 8, We),
                g.isDisabled ? Y("", !0) : (J(), P("i", {
                  key: 0,
                  class: "clIconFont clIcon-close btn-clean",
                  onClick: (s) => u(m)
                }, null, 8, qe))
              ])
            ]))), 128))
          ])
        ])
      ], 4)
    ]));
  }
}), ze = { class: "selectmove-body" }, Qe = {
  key: 0,
  class: "selectmove-result"
}, Ie = /* @__PURE__ */ le({
  name: "ClSelectmoveContainer",
  __name: "Container",
  props: {
    isDisabled: Boolean,
    width: Number,
    isSearch: {
      type: Boolean,
      default: !0
    },
    searchPlaceholder: String,
    searchKey: {
      type: Array,
      default: () => ["name"]
    },
    searchKeyType: {
      type: String,
      default: "||"
    },
    searchIsMultiple: {
      type: Boolean,
      default: !1
    },
    searchMultipleJoin: {
      type: String,
      default: ","
    },
    searchTextFormat: [String, Array],
    treeTitle: {
      type: Array,
      default: () => []
    },
    treeShowMinLevel: {
      type: Number,
      default: 1
    },
    treeTextFormat: [String, Array],
    resultIsShowSlot: Boolean,
    resultIsShowSubUnit: Boolean,
    resultTextFormat: String,
    resultCountFormat: String,
    resultMergeParent: {
      type: Boolean,
      default: !0
    },
    dataRefreshIndex: {
      type: Number,
      default: 0
    },
    selectId: {
      type: Array,
      default: () => []
    },
    parentKey: {
      type: String,
      default: "parentId"
    },
    topParentValue: {
      type: String,
      default: "0"
    }
  },
  emits: ["onSelectValue", "onInitComplete"],
  setup(g, { emit: W }) {
    const l = g, d = W, y = X("$SelectmoveTop"), K = ce({
      searchWidth: 0,
      treeWidth: 0,
      resultWidth: 0
    }), n = {
      parentIdsJson: {},
      childIdJson: {},
      childIdsJson: {}
    }, T = (u) => {
      d("onSelectValue", u);
    }, a = () => {
      Z(() => {
        d("onInitComplete");
      });
    }, b = (u) => {
      let c = [];
      return e.isExistJsonKey(n.childIdJson, u) ? c = n.childIdJson[u] : y.isCheckChildren(u) && (y.getDataGroup(u).forEach((S) => {
        c.push(S.id.toString());
      }), c.length > 0 && (n.childIdJson[u] = c)), c;
    }, I = (u) => {
      let c = [];
      return e.isExistJsonKey(n.childIdsJson, u) && n.childIdsJson[u].length > 0 ? c = n.childIdsJson[u] : (y.isCheckChildren(u) && y.getDataGroup(u).forEach((S) => {
        const m = S.id.toString();
        c.push(m);
        const v = I(m);
        v.length > 0 && (c = c.concat(v));
      }), n.childIdsJson[u] = c), c;
    }, L = (u) => {
      const { parentKey: c, topParentValue: S } = l;
      let m = [];
      if (e.isExistJsonKey(n.parentIdsJson, u) && n.parentIdsJson[u].length > 0)
        m = n.parentIdsJson[u];
      else {
        const v = y.getDataInfo(u);
        if (!e.isUndefined(v)) {
          const s = v[c].toString();
          if (s !== S && !e.isUndefined(y.getDataInfo(s))) {
            m.push(s);
            const o = L(s);
            o.length > 0 && (m = m.concat(o));
          }
        }
        n.parentIdsJson[u] = m;
      }
      return m;
    }, M = (u, c, S) => {
      const m = e.isObject(u) ? u : [u], v = e.getArrConvertJson(S), s = {}, o = [], f = [];
      m.forEach((k) => {
        const C = [], r = [], i = k.toString();
        if (c) {
          if (!(e.isExistJsonKey(v, i) || e.isExistJsonKey(s, i))) {
            C.push(i);
            const E = I(i);
            E && E.length > 0 && C.push(...E);
            const _ = L(i);
            for (let D = 0; D < _.length; D++) {
              const w = _[D].toString();
              if (e.isExistJsonKey(v, w) || e.isExistJsonKey(s, w))
                break;
              const R = b(w), $ = [];
              if (R.forEach((q) => {
                const t = q.toString();
                (e.isExistJsonKey(v, t) || e.isExistJsonKey(s, t) || C.indexOf(t) > -1) && $.push(t);
              }), R.length === $.length)
                C.push(w);
              else
                break;
            }
          }
        } else {
          r.push(i);
          const x = I(i);
          x && x.length > 0 && r.push(...x);
          const E = L(i);
          r.push(...E);
        }
        C.length > 0 && C.forEach((x) => {
          o.push(x), s[x] = !0;
        }), r.length > 0 && r.forEach((x) => {
          f.push(x);
        });
      });
      let p = e.getArrClone(S);
      return p.push(...o), p = e.getArrUnique(p), p = e.getArrRemoveById(p, f), p;
    }, j = (u) => {
      const c = [], S = {};
      u.forEach((s) => {
        S[s] = !0;
        const o = L(s);
        c.push(...o);
      });
      const m = [], v = {};
      return c.forEach((s) => {
        !e.isExistJsonKey(v, s) && !e.isExistJsonKey(S, s) && (v[s] = !0, m.push(s));
      }), m;
    }, H = () => {
      const u = l.width;
      if (u && u > 350) {
        const c = parseInt((u / 175).toString()), S = u / c;
        K.searchWidth = u, K.treeWidth = S, K.resultWidth = S;
      }
    };
    z(
      () => l.dataRefreshIndex,
      () => {
        n.parentIdsJson = {}, n.childIdJson = {}, n.childIdsJson = {};
      }
    ), ie(() => {
      H(), Z(() => {
        a();
      });
    });
    const N = (u) => {
      T(u);
    };
    return ye("$SelectmoveBase", {
      convertSelectedValue: (u, c, S) => {
        let m = !1;
        if (c && e.isObject(u) && u.length > 100 && (m = !0), m) {
          const v = y.getValueMergeParent(u);
          return M(v, c, S);
        } else
          return M(u, c, S);
      },
      convertSelectHalf: j,
      getChildIds: I,
      getParentIds: L,
      getLastChildIds: y.getLastChildIds,
      getValueMergeParent: y.getValueMergeParent,
      getValueSplitChild: y.getValueSplitChild
    }), (u, c) => (J(), P(ae, null, [
      g.isSearch ? (J(), ne(Ae, {
        key: 0,
        isDisabled: g.isDisabled,
        width: K.searchWidth,
        placeholder: g.searchPlaceholder,
        searchKey: g.searchKey,
        searchKeyType: g.searchKeyType,
        searchIsMultiple: g.searchIsMultiple,
        searchMultipleJoin: g.searchMultipleJoin,
        searchTextFormat: g.searchTextFormat,
        selectId: g.selectId,
        parentKey: g.parentKey,
        topParentValue: g.topParentValue,
        onOnChange: N
      }, null, 8, ["isDisabled", "width", "placeholder", "searchKey", "searchKeyType", "searchIsMultiple", "searchMultipleJoin", "searchTextFormat", "selectId", "parentKey", "topParentValue"])) : Y("", !0),
      V("div", ze, [
        se(Re, {
          isDisabled: g.isDisabled,
          maxWidth: K.searchWidth,
          width: K.treeWidth,
          treeTitle: g.treeTitle,
          treeShowMinLevel: g.treeShowMinLevel,
          treeTextFormat: g.treeTextFormat,
          selectId: g.selectId,
          dataRefreshIndex: g.dataRefreshIndex,
          onOnChange: N
        }, null, 8, ["isDisabled", "maxWidth", "width", "treeTitle", "treeShowMinLevel", "treeTextFormat", "selectId", "dataRefreshIndex"]),
        g.resultIsShowSlot ? (J(), P("div", Qe, [
          pe(u.$slots, "resultSelect")
        ])) : g.resultIsShowSubUnit ? (J(), ne(Ge, {
          key: 1,
          isDisabled: g.isDisabled,
          width: K.resultWidth,
          resultTextFormat: g.resultTextFormat,
          resultCountFormat: g.resultCountFormat,
          resultMergeParent: g.resultMergeParent,
          selectId: g.selectId,
          dataRefreshIndex: g.dataRefreshIndex,
          onOnChange: N
        }, null, 8, ["isDisabled", "width", "resultTextFormat", "resultCountFormat", "resultMergeParent", "selectId", "dataRefreshIndex"])) : Y("", !0)
      ])
    ], 64));
  }
}), Xe = { className: "selectmove-text-num" }, Ye = { class: "selectmove-container" }, lt = /* @__PURE__ */ le({
  name: "ClSelectmove",
  __name: "Index",
  props: {
    value: String,
    list: {
      type: Array,
      default: () => []
    },
    className: String,
    isDropdown: {
      type: Boolean,
      default: !1
    },
    placeholder: String,
    disabled: {
      type: Boolean,
      default: !1
    },
    isClear: {
      type: Boolean,
      default: !1
    },
    containerWidth: {
      type: Number,
      default: 350
    },
    isSearch: {
      type: Boolean,
      default: !0
    },
    searchPlaceholder: String,
    searchKey: {
      type: Array,
      default: () => ["name"]
    },
    searchKeyType: {
      type: String,
      default: "||"
    },
    searchIsMultiple: {
      type: Boolean,
      default: !1
    },
    searchMultipleJoin: {
      type: String,
      default: ","
    },
    searchTextFormat: [String, Array],
    treeTitle: {
      type: Array,
      default: () => []
    },
    treeShowMinLevel: {
      type: Number,
      default: 1
    },
    treeTextFormat: [String, Array],
    resultIsShow: {
      type: Boolean,
      default: !0
    },
    resultTextFormat: String,
    resultCountFormat: String,
    resultMergeParent: {
      type: Boolean,
      default: !0
    },
    isOutMerge: {
      type: Boolean,
      default: !0
    },
    parentKey: {
      type: String,
      default: "parentId"
    },
    topParentValue: {
      type: String,
      default: "0"
    }
  },
  emits: ["update:value", "onChange", "onInit"],
  setup(g, { expose: W, emit: l }) {
    const d = g, y = l, K = we(), n = Q(null), T = Q(null), a = ce({
      keyIndex: `selectmove-${e.getRandom(8)}`,
      isShowPopup: d.isDropdown,
      dataRefreshIndex: 0,
      selectedIds: [],
      IsShowResultSlot: !e.isUndefined(K.resultSelect)
    }), b = Q([]), I = {
      dataJson: {},
      dataGroup: {},
      childLastIdsJson: {},
      lastSelectedIds: []
    }, L = te(() => ({
      isDisabled: d.disabled,
      width: d.containerWidth,
      isSearch: d.isSearch,
      searchPlaceholder: d.searchPlaceholder,
      searchKey: d.searchKey,
      searchIsMultiple: d.searchIsMultiple,
      searchMultipleJoin: d.searchMultipleJoin,
      searchTextFormat: d.searchTextFormat,
      treeTitle: d.treeTitle,
      treeShowMinLevel: d.treeShowMinLevel,
      treeTextFormat: d.treeTextFormat,
      resultIsShowSubUnit: d.resultIsShow,
      resultIsShowSlot: a.IsShowResultSlot,
      resultTextFormat: d.resultTextFormat,
      resultCountFormat: d.resultCountFormat,
      resultMergeParent: d.resultMergeParent,
      parentKey: d.parentKey,
      topParentValue: d.topParentValue
    })), M = te(() => {
      let t = "panel-selectmove ";
      return d.className && !e.isEmpty(d.className) && (t += d.className), d.isDropdown || d.disabled && (t += " selectmove-disabled "), t;
    }), j = (t) => {
      y("update:value", t);
    }, H = (t, h) => {
      j(t), y("onChange", t, h);
    }, N = () => {
      y("onInit");
    }, u = () => d.list, c = (t) => e.isExistJsonKey(I.dataGroup, t.toString()), S = (t) => {
      const h = t.toString();
      return c(h) ? I.dataGroup[h] : [];
    }, m = (t) => {
      const h = t.toString();
      return e.isExistJsonKey(I.dataJson, h) ? I.dataJson[h] : null;
    }, v = () => `top_${d.topParentValue}`, s = (t) => {
      const { parentKey: h, topParentValue: A } = d, F = {}, B = {};
      e.isEmpty(t) || t.forEach((U) => {
        const O = e.getJsonClone(U), G = O.id.toString(), ee = O[h].toString();
        F[G] = O;
        const he = ee === A ? v() : ee;
        e.isExistJsonKey(B, he) || (B[he] = []), B[he].push(O);
      }), I.dataJson = F, I.dataGroup = B, I.childLastIdsJson = {};
    }, o = (t) => {
      let h = [];
      return e.isExistJsonKey(I.childLastIdsJson, t) && I.childLastIdsJson[t].length > 0 ? h = I.childLastIdsJson[t] : (c(t) ? S(t).forEach((A) => {
        const F = o(A.id.toString());
        F.length > 0 && (h = h.concat(F));
      }) : h.push(t), I.childLastIdsJson[t] = h), h;
    }, f = (t) => {
      const { parentKey: h, topParentValue: A } = d, F = {}, B = [];
      let U = [];
      if (t.forEach((O) => {
        const G = m(O);
        if (!e.isUndefined(G)) {
          const ee = G[h].toString();
          ee === A ? U.push(O) : (e.isExistJsonKey(F, ee) || (F[ee] = []), F[ee].push(O));
        }
      }), !e.isEmpty(F))
        for (const [O, G] of Object.entries(F))
          G.length === S(O).length ? B.push(O) : U = U.concat(G);
      if (B.length > 0) {
        U.push(...B);
        const O = e.getArrUnique(U);
        return f(O);
      } else
        return U;
    }, p = (t) => {
      const h = [], A = e.getArrConvertJson(t);
      return t.forEach((B) => {
        const U = S(B);
        if (e.isEmpty(U))
          h.push(B);
        else {
          const O = [];
          U.forEach((G) => {
            e.isExistJsonKey(A, G.id.toString()) && O.push(G.id);
          }), U.length !== O.length && h.push(B);
        }
      }), f(h);
    }, k = (t) => {
      let h = [];
      return t.forEach((A) => {
        const F = o(A);
        h.push(...F);
      }), h = e.getArrUnique(h), h;
    }, C = (t, h) => (e.isBoolean(h) ? h : d.isOutMerge) ? p(t) : k(t), r = (t) => {
      const h = [], A = [];
      return t.forEach((F) => {
        const B = m(F);
        h.push(B), A.push(B.name);
      }), { list: h, label: A };
    }, i = () => {
      if (d.isDropdown)
        if (e.isEmpty(a.selectedIds))
          b.value = [];
        else {
          const t = C(a.selectedIds, d.resultMergeParent);
          b.value = r(t).label;
        }
    }, x = () => {
      if (s(d.list), !e.isEmpty(d.value) && d.value) {
        const t = d.value.split(",");
        a.selectedIds = t;
      }
    };
    z(
      () => d.value,
      (t, h) => {
        if (t !== h && !e.isUndefined(t)) {
          const A = t && !e.isEmpty(t) ? t.split(",") : [];
          e.isEqualArr(A, a.selectedIds) || (a.selectedIds = e.isEmpty(A) ? [] : A, i());
        }
      }
    ), z(
      () => d.list,
      (t) => {
        t && (s(t), a.dataRefreshIndex++, i());
      }
    ), ie(() => {
      Z(() => {
        x();
      });
    });
    const E = (t) => {
      d.disabled || t && (I.lastSelectedIds = a.selectedIds);
    }, _ = () => {
      d.disabled || (a.selectedIds = [], H("", []));
    }, D = () => {
      a.isShowPopup ? (i(), n.value && (n.value.checkCurrentIsOpen() || n.value.initCompleteOpen())) : N();
    }, w = (t) => {
      const h = e.isEmpty(t) ? [] : t.split(",");
      a.selectedIds = h;
      const A = C(h), F = r(A);
      i(), H(A.join(","), F.list);
    };
    return ye("$SelectmoveTop", {
      keyIndex: a.keyIndex,
      isCheckChildren: c,
      getDataGroup: S,
      getDataInfo: m,
      getDataList: u,
      getLastChildIds: o,
      getValueMergeParent: p,
      getValueSplitChild: k,
      getTopParentValue: v
    }), W({
      getValue: () => C(a.selectedIds).join(","),
      getValueData: () => {
        const t = C(a.selectedIds);
        return r(t).list;
      },
      setValue: (t) => {
        a.selectedIds = e.isEmpty(t) ? [] : t.split(","), i();
      }
    }), (t, h) => {
      const A = oe("cl-badge");
      return g.isDropdown ? (J(), ne(_e, {
        key: 0,
        ref_key: "refElDropdownLayer",
        ref: n,
        classParent: M.value,
        classText: "selectmove-text",
        classDropDown: "selectmove-dropdown",
        placeholder: g.placeholder,
        isDisabled: g.disabled,
        isClear: g.isClear,
        textLabel: b.value.join(","),
        textArrowDirection: "right",
        isUseDropdownArrow: !0,
        onOnChangeOpen: E,
        onOnClear: _
      }, {
        textExtend: de(() => [
          V("span", Xe, [
            b.value.length > 1 ? (J(), ne(A, {
              key: 0,
              num: b.value.length
            }, null, 8, ["num"])) : Y("", !0)
          ])
        ]),
        dropdown: de(() => [
          V("div", Ye, [
            se(Ie, me({
              ref_key: "refElSelectMove",
              ref: T
            }, L.value, {
              dataRefreshIndex: a.dataRefreshIndex,
              selectId: a.selectedIds,
              onOnSelectValue: w,
              onOnInitComplete: D
            }), {
              resultSelect: de(() => [
                pe(t.$slots, "resultSelect")
              ]),
              _: 3
            }, 16, ["dataRefreshIndex", "selectId"])
          ])
        ]),
        _: 3
      }, 8, ["classParent", "placeholder", "isDisabled", "isClear", "textLabel"])) : (J(), P("div", {
        key: 1,
        class: re(M.value)
      }, [
        se(Ie, me({
          ref_key: "refElSelectMove",
          ref: T
        }, L.value, {
          dataRefreshIndex: a.dataRefreshIndex,
          selectId: a.selectedIds,
          onOnSelectValue: w,
          onOnInitComplete: D
        }), {
          resultSelect: de(() => [
            pe(t.$slots, "resultSelect")
          ]),
          _: 3
        }, 16, ["dataRefreshIndex", "selectId"])
      ], 2));
    };
  }
});
export {
  lt as default
};
//# sourceMappingURL=ClSelectmove.js.map
