import '@das-fed/upf-ui/packages/business-components/model-table-dialog/style.css';
import { defineComponent as Dt, computed as I, watch as X, ref as x, openBlock as K, createElementBlock as G, createVNode as L, unref as y, mergeProps as H, isRef as Ke, withCtx as M, createTextVNode as ft, toDisplayString as dt, createBlock as Me, createSlots as It, renderList as zt, renderSlot as ie, createCommentVNode as J, onMounted as dn, createElementVNode as pn, normalizeProps as hn, guardReactiveProps as vn, Fragment as gn, normalizeStyle as pt, nextTick as bn } from "vue";
import { withInstall as Et } from "@das-fed/upf-utils/with-install/index";
import { i18n as mn, setI18nRule as yn } from "@das-fed/upf-web/packages/i18n/index";
import { DasDialog as _n } from "@das-fed/upf-ui/packages/components/dialog/index";
import { DasButton as ht } from "@das-fed/upf-ui/packages/components/button/index";
import { DasMessage as Tn } from "@das-fed/upf-ui/packages/components/message/index";
import { DasModelTableRef as wn, DasModelTable as Sn } from "@das-fed/upf-ui/packages/business-components/model-table-dialog";
import { useModelValue as me } from "@das-fed/upf-utils/vue";
import { DasSelectList as vt } from "@das-fed/upf-ui/packages/components/select-list/index";
import { DasSplitPanel as Cn } from "@das-fed/upf-ui/packages/components/split-panel/index";
import { DasTreeRef as On, DasTree as xn } from "@das-fed/upf-ui/packages/components/tree/index";
import { DasTable as Pn, DasTableColumn as gt } from "@das-fed/upf-ui/packages/components/table/index";
import { DasSpin as bt } from "@das-fed/upf-ui/packages/components/spin/index";
import "@das-fed/upf-ui/packages/global/theme";
const Kt = () => (e) => mn(e).value, Mt = () => ({
  getServiceApi: (n) => {
    const r = new Object({ run: null, loading: !1, data: [], error: !1 });
    return typeof n == "function" && n() || r;
  },
  isEmpty: (n) => Object.keys(n).length > 0
}), jn = { class: "das-ui-business-dialog" }, $n = /* @__PURE__ */ Dt({
  __name: "Index",
  props: {
    title: { default: "" },
    modelValue: { type: Boolean, default: !1 },
    width: { default: "960px" },
    height: { default: "600px" },
    beforeConfirm: { default: () => {
    } },
    options: { default: () => ({}) },
    submitOptions: { default: () => ({}) }
  },
  emits: ["confirm", "close", "open", "update:modelValue", "treeChange", "tableChange", "update:resultTree", "update:resultTable"],
  setup(e, { expose: t, emit: n }) {
    var A;
    const r = Kt(), s = e, d = n, g = I(() => s.title || r("标题")), { getServiceApi: f, isEmpty: p } = Mt(), S = me(s, "options"), _ = me(s, "modelValue"), j = (v) => {
      _.value = v;
    };
    X(_, (v) => {
      d("update:modelValue", v), d(v ? "open" : "close");
    });
    const R = () => {
      const { left: v, content: w } = S.value, C = v == null ? void 0 : v.selectListProps, D = w == null ? void 0 : w.selectListProps, T = typeof C == "boolean" ? C : p(C || {}), re = typeof D == "boolean" ? D : p(D || {}), V = T && re ? { treeSelectList: $.value, tableSelectList: q.value } : T ? $.value : q.value, k = s == null ? void 0 : s.beforeConfirm;
      k && typeof k == "function" && !k(V) || te(V);
    }, $ = x([]), N = (v) => {
      $.value = v || {};
    }, q = x([]), Oe = (v) => {
      q.value = v || {};
    }, { run: Q, loading: ee, data: xe, error: Pe } = f((A = s.submitOptions) == null ? void 0 : A.api), te = async (v) => {
      var V;
      if (!Q) return d("confirm", v), j(!1);
      const { params: w = {}, query: C = {}, searchKey: D = "" } = s.submitOptions, T = { ...w, ...C };
      if (D && (T[D] = v), await Q(T), Pe.value) return;
      const re = xe.value;
      Tn.success(((V = s.submitOptions) == null ? void 0 : V.successText) || r("提交成功")), d("confirm", re || v), j(!1);
    }, ne = wn(), ve = () => ne.value;
    return X(
      () => s.modelValue,
      (v) => j(v)
    ), t({ getModelTableRef: ve }), (v, w) => (K(), G("div", jn, [
      L(y(_n), H({
        class: "business-dialog",
        title: g.value,
        loading: y(ee)
      }, v.$attrs, {
        width: e.width,
        height: e.height,
        modelValue: y(_),
        "onUpdate:modelValue": w[1] || (w[1] = (C) => Ke(_) ? _.value = C : null)
      }), {
        footer: M(() => [
          L(y(ht), {
            size: "middle",
            style: { "margin-right": "12px" },
            onClick: w[0] || (w[0] = (C) => j(!1))
          }, {
            default: M(() => [
              ft(
                dt(y(r)("取消")),
                1
                /* TEXT */
              )
            ]),
            _: 1
            /* STABLE */
          }),
          L(y(ht), {
            size: "middle",
            btnType: "primary",
            onClick: R
          }, {
            default: M(() => [
              ft(
                dt(y(r)("确定")),
                1
                /* TEXT */
              )
            ]),
            _: 1
            /* STABLE */
          })
        ]),
        default: M(() => [
          y(_) ? (K(), Me(
            y(Sn),
            H({
              key: 0,
              ref_key: "$modelTableRef",
              ref: ne
            }, y(S), {
              onTreeChange: N,
              onTableChange: Oe
            }),
            It({
              _: 2
              /* DYNAMIC */
            }, [
              zt(v.$slots, (C, D, T) => ({
                name: D,
                fn: M(() => [
                  ie(v.$slots, D, {}, void 0, !0)
                ])
              }))
            ]),
            1040
            /* FULL_PROPS, DYNAMIC_SLOTS */
          )) : J("v-if", !0)
        ]),
        _: 3
        /* FORWARDED */
      }, 16, ["title", "loading", "width", "height", "modelValue"]),
      v.$slots.default ? (K(), G("div", {
        key: 0,
        class: "button-slot-box",
        onClick: w[2] || (w[2] = (C) => j(!0))
      }, [
        ie(v.$slots, "default", {}, void 0, !0)
      ])) : J("v-if", !0)
    ]));
  }
}), Rt = (e, t) => {
  const n = e.__vccOpts || e;
  for (const [r, s] of t)
    n[r] = s;
  return n;
}, An = /* @__PURE__ */ Rt($n, [["__scopeId", "data-v-97746797"]]);
function Dn() {
  this.__data__ = [], this.size = 0;
}
function Te(e, t) {
  return e === t || e !== e && t !== t;
}
function we(e, t) {
  for (var n = e.length; n--; )
    if (Te(e[n][0], t))
      return n;
  return -1;
}
var In = Array.prototype, zn = In.splice;
function En(e) {
  var t = this.__data__, n = we(t, e);
  if (n < 0)
    return !1;
  var r = t.length - 1;
  return n == r ? t.pop() : zn.call(t, n, 1), --this.size, !0;
}
function Kn(e) {
  var t = this.__data__, n = we(t, e);
  return n < 0 ? void 0 : t[n][1];
}
function Mn(e) {
  return we(this.__data__, e) > -1;
}
function Rn(e, t) {
  var n = this.__data__, r = we(n, e);
  return r < 0 ? (++this.size, n.push([e, t])) : n[r][1] = t, this;
}
function F(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var r = e[t];
    this.set(r[0], r[1]);
  }
}
F.prototype.clear = Dn;
F.prototype.delete = En;
F.prototype.get = Kn;
F.prototype.has = Mn;
F.prototype.set = Rn;
function Ln() {
  this.__data__ = new F(), this.size = 0;
}
function Nn(e) {
  var t = this.__data__, n = t.delete(e);
  return this.size = t.size, n;
}
function Fn(e) {
  return this.__data__.get(e);
}
function Vn(e) {
  return this.__data__.has(e);
}
var Lt = typeof global == "object" && global && global.Object === Object && global, Un = typeof self == "object" && self && self.Object === Object && self, se = Lt || Un || Function("return this")(), ye = se.Symbol, Nt = Object.prototype, Bn = Nt.hasOwnProperty, Gn = Nt.toString, fe = ye ? ye.toStringTag : void 0;
function Hn(e) {
  var t = Bn.call(e, fe), n = e[fe];
  try {
    e[fe] = void 0;
    var r = !0;
  } catch {
  }
  var s = Gn.call(e);
  return r && (t ? e[fe] = n : delete e[fe]), s;
}
var qn = Object.prototype, kn = qn.toString;
function Wn(e) {
  return kn.call(e);
}
var Xn = "[object Null]", Jn = "[object Undefined]", mt = ye ? ye.toStringTag : void 0;
function Se(e) {
  return e == null ? e === void 0 ? Jn : Xn : mt && mt in Object(e) ? Hn(e) : Wn(e);
}
function Z(e) {
  var t = typeof e;
  return e != null && (t == "object" || t == "function");
}
var Yn = "[object AsyncFunction]", Zn = "[object Function]", Qn = "[object GeneratorFunction]", er = "[object Proxy]";
function Ve(e) {
  if (!Z(e))
    return !1;
  var t = Se(e);
  return t == Zn || t == Qn || t == Yn || t == er;
}
var Ie = se["__core-js_shared__"], yt = function() {
  var e = /[^.]+$/.exec(Ie && Ie.keys && Ie.keys.IE_PROTO || "");
  return e ? "Symbol(src)_1." + e : "";
}();
function tr(e) {
  return !!yt && yt in e;
}
var nr = Function.prototype, rr = nr.toString;
function ar(e) {
  if (e != null) {
    try {
      return rr.call(e);
    } catch {
    }
    try {
      return e + "";
    } catch {
    }
  }
  return "";
}
var or = /[\\^$.*+?()[\]{}|]/g, lr = /^\[object .+?Constructor\]$/, ir = Function.prototype, sr = Object.prototype, ur = ir.toString, cr = sr.hasOwnProperty, fr = RegExp(
  "^" + ur.call(cr).replace(or, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function dr(e) {
  if (!Z(e) || tr(e))
    return !1;
  var t = Ve(e) ? fr : lr;
  return t.test(ar(e));
}
function pr(e, t) {
  return e == null ? void 0 : e[t];
}
function Ue(e, t) {
  var n = pr(e, t);
  return dr(n) ? n : void 0;
}
var Ft = Ue(se, "Map"), pe = Ue(Object, "create");
function hr() {
  this.__data__ = pe ? pe(null) : {}, this.size = 0;
}
function vr(e) {
  var t = this.has(e) && delete this.__data__[e];
  return this.size -= t ? 1 : 0, t;
}
var gr = "__lodash_hash_undefined__", br = Object.prototype, mr = br.hasOwnProperty;
function yr(e) {
  var t = this.__data__;
  if (pe) {
    var n = t[e];
    return n === gr ? void 0 : n;
  }
  return mr.call(t, e) ? t[e] : void 0;
}
var _r = Object.prototype, Tr = _r.hasOwnProperty;
function wr(e) {
  var t = this.__data__;
  return pe ? t[e] !== void 0 : Tr.call(t, e);
}
var Sr = "__lodash_hash_undefined__";
function Cr(e, t) {
  var n = this.__data__;
  return this.size += this.has(e) ? 0 : 1, n[e] = pe && t === void 0 ? Sr : t, this;
}
function Y(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var r = e[t];
    this.set(r[0], r[1]);
  }
}
Y.prototype.clear = hr;
Y.prototype.delete = vr;
Y.prototype.get = yr;
Y.prototype.has = wr;
Y.prototype.set = Cr;
function Or() {
  this.size = 0, this.__data__ = {
    hash: new Y(),
    map: new (Ft || F)(),
    string: new Y()
  };
}
function xr(e) {
  var t = typeof e;
  return t == "string" || t == "number" || t == "symbol" || t == "boolean" ? e !== "__proto__" : e === null;
}
function Ce(e, t) {
  var n = e.__data__;
  return xr(t) ? n[typeof t == "string" ? "string" : "hash"] : n.map;
}
function Pr(e) {
  var t = Ce(this, e).delete(e);
  return this.size -= t ? 1 : 0, t;
}
function jr(e) {
  return Ce(this, e).get(e);
}
function $r(e) {
  return Ce(this, e).has(e);
}
function Ar(e, t) {
  var n = Ce(this, e), r = n.size;
  return n.set(e, t), this.size += n.size == r ? 0 : 1, this;
}
function ue(e) {
  var t = -1, n = e == null ? 0 : e.length;
  for (this.clear(); ++t < n; ) {
    var r = e[t];
    this.set(r[0], r[1]);
  }
}
ue.prototype.clear = Or;
ue.prototype.delete = Pr;
ue.prototype.get = jr;
ue.prototype.has = $r;
ue.prototype.set = Ar;
var Dr = 200;
function Ir(e, t) {
  var n = this.__data__;
  if (n instanceof F) {
    var r = n.__data__;
    if (!Ft || r.length < Dr - 1)
      return r.push([e, t]), this.size = ++n.size, this;
    n = this.__data__ = new ue(r);
  }
  return n.set(e, t), this.size = n.size, this;
}
function ce(e) {
  var t = this.__data__ = new F(e);
  this.size = t.size;
}
ce.prototype.clear = Ln;
ce.prototype.delete = Nn;
ce.prototype.get = Fn;
ce.prototype.has = Vn;
ce.prototype.set = Ir;
var _e = function() {
  try {
    var e = Ue(Object, "defineProperty");
    return e({}, "", {}), e;
  } catch {
  }
}();
function Be(e, t, n) {
  t == "__proto__" && _e ? _e(e, t, {
    configurable: !0,
    enumerable: !0,
    value: n,
    writable: !0
  }) : e[t] = n;
}
function Re(e, t, n) {
  (n !== void 0 && !Te(e[t], n) || n === void 0 && !(t in e)) && Be(e, t, n);
}
function zr(e) {
  return function(t, n, r) {
    for (var s = -1, d = Object(t), g = r(t), f = g.length; f--; ) {
      var p = g[++s];
      if (n(d[p], p, d) === !1)
        break;
    }
    return t;
  };
}
var Er = zr(), Vt = typeof exports == "object" && exports && !exports.nodeType && exports, _t = Vt && typeof module == "object" && module && !module.nodeType && module, Kr = _t && _t.exports === Vt, Tt = Kr ? se.Buffer : void 0;
Tt && Tt.allocUnsafe;
function Mr(e, t) {
  return e.slice();
}
var wt = se.Uint8Array;
function Rr(e) {
  var t = new e.constructor(e.byteLength);
  return new wt(t).set(new wt(e)), t;
}
function Lr(e, t) {
  var n = Rr(e.buffer);
  return new e.constructor(n, e.byteOffset, e.length);
}
function Nr(e, t) {
  var n = -1, r = e.length;
  for (t || (t = Array(r)); ++n < r; )
    t[n] = e[n];
  return t;
}
var St = Object.create, Fr = /* @__PURE__ */ function() {
  function e() {
  }
  return function(t) {
    if (!Z(t))
      return {};
    if (St)
      return St(t);
    e.prototype = t;
    var n = new e();
    return e.prototype = void 0, n;
  };
}();
function Vr(e, t) {
  return function(n) {
    return e(t(n));
  };
}
var Ut = Vr(Object.getPrototypeOf, Object), Ur = Object.prototype;
function Bt(e) {
  var t = e && e.constructor, n = typeof t == "function" && t.prototype || Ur;
  return e === n;
}
function Br(e) {
  return typeof e.constructor == "function" && !Bt(e) ? Fr(Ut(e)) : {};
}
function he(e) {
  return e != null && typeof e == "object";
}
var Gr = "[object Arguments]";
function Ct(e) {
  return he(e) && Se(e) == Gr;
}
var Gt = Object.prototype, Hr = Gt.hasOwnProperty, qr = Gt.propertyIsEnumerable, Le = Ct(/* @__PURE__ */ function() {
  return arguments;
}()) ? Ct : function(e) {
  return he(e) && Hr.call(e, "callee") && !qr.call(e, "callee");
}, Ne = Array.isArray, kr = 9007199254740991;
function Ht(e) {
  return typeof e == "number" && e > -1 && e % 1 == 0 && e <= kr;
}
function Ge(e) {
  return e != null && Ht(e.length) && !Ve(e);
}
function Wr(e) {
  return he(e) && Ge(e);
}
function Xr() {
  return !1;
}
var qt = typeof exports == "object" && exports && !exports.nodeType && exports, Ot = qt && typeof module == "object" && module && !module.nodeType && module, Jr = Ot && Ot.exports === qt, xt = Jr ? se.Buffer : void 0, Yr = xt ? xt.isBuffer : void 0, kt = Yr || Xr, Zr = "[object Object]", Qr = Function.prototype, ea = Object.prototype, Wt = Qr.toString, ta = ea.hasOwnProperty, na = Wt.call(Object);
function ra(e) {
  if (!he(e) || Se(e) != Zr)
    return !1;
  var t = Ut(e);
  if (t === null)
    return !0;
  var n = ta.call(t, "constructor") && t.constructor;
  return typeof n == "function" && n instanceof n && Wt.call(n) == na;
}
var aa = "[object Arguments]", oa = "[object Array]", la = "[object Boolean]", ia = "[object Date]", sa = "[object Error]", ua = "[object Function]", ca = "[object Map]", fa = "[object Number]", da = "[object Object]", pa = "[object RegExp]", ha = "[object Set]", va = "[object String]", ga = "[object WeakMap]", ba = "[object ArrayBuffer]", ma = "[object DataView]", ya = "[object Float32Array]", _a = "[object Float64Array]", Ta = "[object Int8Array]", wa = "[object Int16Array]", Sa = "[object Int32Array]", Ca = "[object Uint8Array]", Oa = "[object Uint8ClampedArray]", xa = "[object Uint16Array]", Pa = "[object Uint32Array]", m = {};
m[ya] = m[_a] = m[Ta] = m[wa] = m[Sa] = m[Ca] = m[Oa] = m[xa] = m[Pa] = !0;
m[aa] = m[oa] = m[ba] = m[la] = m[ma] = m[ia] = m[sa] = m[ua] = m[ca] = m[fa] = m[da] = m[pa] = m[ha] = m[va] = m[ga] = !1;
function ja(e) {
  return he(e) && Ht(e.length) && !!m[Se(e)];
}
function $a(e) {
  return function(t) {
    return e(t);
  };
}
var Xt = typeof exports == "object" && exports && !exports.nodeType && exports, de = Xt && typeof module == "object" && module && !module.nodeType && module, Aa = de && de.exports === Xt, ze = Aa && Lt.process, Pt = function() {
  try {
    var e = de && de.require && de.require("util").types;
    return e || ze && ze.binding && ze.binding("util");
  } catch {
  }
}(), jt = Pt && Pt.isTypedArray, Jt = jt ? $a(jt) : ja;
function Fe(e, t) {
  if (!(t === "constructor" && typeof e[t] == "function") && t != "__proto__")
    return e[t];
}
var Da = Object.prototype, Ia = Da.hasOwnProperty;
function za(e, t, n) {
  var r = e[t];
  (!(Ia.call(e, t) && Te(r, n)) || n === void 0 && !(t in e)) && Be(e, t, n);
}
function Ea(e, t, n, r) {
  var s = !n;
  n || (n = {});
  for (var d = -1, g = t.length; ++d < g; ) {
    var f = t[d], p = void 0;
    p === void 0 && (p = e[f]), s ? Be(n, f, p) : za(n, f, p);
  }
  return n;
}
function Ka(e, t) {
  for (var n = -1, r = Array(e); ++n < e; )
    r[n] = t(n);
  return r;
}
var Ma = 9007199254740991, Ra = /^(?:0|[1-9]\d*)$/;
function Yt(e, t) {
  var n = typeof e;
  return t = t ?? Ma, !!t && (n == "number" || n != "symbol" && Ra.test(e)) && e > -1 && e % 1 == 0 && e < t;
}
function La(e, t) {
  var n = Ne(e), r = !n && Le(e), s = !n && !r && kt(e), d = !n && !r && !s && Jt(e), g = n || r || s || d, f = g ? Ka(e.length, String) : [], p = f.length;
  for (var S in e)
    g && // Safari 9 has enumerable `arguments.length` in strict mode.
    (S == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
    s && (S == "offset" || S == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
    d && (S == "buffer" || S == "byteLength" || S == "byteOffset") || // Skip index properties.
    Yt(S, p)) || f.push(S);
  return f;
}
function Na(e) {
  var t = [];
  if (e != null)
    for (var n in Object(e))
      t.push(n);
  return t;
}
var Fa = Object.prototype, Va = Fa.hasOwnProperty;
function Ua(e) {
  if (!Z(e))
    return Na(e);
  var t = Bt(e), n = [];
  for (var r in e)
    r == "constructor" && (t || !Va.call(e, r)) || n.push(r);
  return n;
}
function Zt(e) {
  return Ge(e) ? La(e) : Ua(e);
}
function Ba(e) {
  return Ea(e, Zt(e));
}
function Ga(e, t, n, r, s, d, g) {
  var f = Fe(e, n), p = Fe(t, n), S = g.get(p);
  if (S) {
    Re(e, n, S);
    return;
  }
  var _ = d ? d(f, p, n + "", e, t, g) : void 0, j = _ === void 0;
  if (j) {
    var R = Ne(p), $ = !R && kt(p), N = !R && !$ && Jt(p);
    _ = p, R || $ || N ? Ne(f) ? _ = f : Wr(f) ? _ = Nr(f) : $ ? (j = !1, _ = Mr(p)) : N ? (j = !1, _ = Lr(p)) : _ = [] : ra(p) || Le(p) ? (_ = f, Le(f) ? _ = Ba(f) : (!Z(f) || Ve(f)) && (_ = Br(p))) : j = !1;
  }
  j && (g.set(p, _), s(_, p, r, d, g), g.delete(p)), Re(e, n, _);
}
function Qt(e, t, n, r, s) {
  e !== t && Er(t, function(d, g) {
    if (s || (s = new ce()), Z(d))
      Ga(e, t, g, n, Qt, r, s);
    else {
      var f = r ? r(Fe(e, g), d, g + "", e, t, s) : void 0;
      f === void 0 && (f = d), Re(e, g, f);
    }
  }, Zt);
}
function en(e) {
  return e;
}
function Ha(e, t, n) {
  switch (n.length) {
    case 0:
      return e.call(t);
    case 1:
      return e.call(t, n[0]);
    case 2:
      return e.call(t, n[0], n[1]);
    case 3:
      return e.call(t, n[0], n[1], n[2]);
  }
  return e.apply(t, n);
}
var $t = Math.max;
function qa(e, t, n) {
  return t = $t(t === void 0 ? e.length - 1 : t, 0), function() {
    for (var r = arguments, s = -1, d = $t(r.length - t, 0), g = Array(d); ++s < d; )
      g[s] = r[t + s];
    s = -1;
    for (var f = Array(t + 1); ++s < t; )
      f[s] = r[s];
    return f[t] = n(g), Ha(e, this, f);
  };
}
function ka(e) {
  return function() {
    return e;
  };
}
var Wa = _e ? function(e, t) {
  return _e(e, "toString", {
    configurable: !0,
    enumerable: !1,
    value: ka(t),
    writable: !0
  });
} : en, Xa = 800, Ja = 16, Ya = Date.now;
function Za(e) {
  var t = 0, n = 0;
  return function() {
    var r = Ya(), s = Ja - (r - n);
    if (n = r, s > 0) {
      if (++t >= Xa)
        return arguments[0];
    } else
      t = 0;
    return e.apply(void 0, arguments);
  };
}
var Qa = Za(Wa);
function eo(e, t) {
  return Qa(qa(e, t, en), e + "");
}
function to(e, t, n) {
  if (!Z(n))
    return !1;
  var r = typeof t;
  return (r == "number" ? Ge(n) && Yt(t, n.length) : r == "string" && t in n) ? Te(n[t], e) : !1;
}
function no(e) {
  return eo(function(t, n) {
    var r = -1, s = n.length, d = s > 1 ? n[s - 1] : void 0, g = s > 2 ? n[2] : void 0;
    for (d = e.length > 3 && typeof d == "function" ? (s--, d) : void 0, g && to(n[0], n[1], g) && (d = s < 3 ? void 0 : d, s = 1), t = Object(t); ++r < s; ) {
      var f = n[r];
      f && e(t, f, r, d);
    }
    return t;
  });
}
var At = no(function(e, t, n) {
  Qt(e, t, n);
});
const ro = { class: "business-dialog-content" }, ao = { class: "table-list-box" }, oo = {
  key: 1,
  class: "line"
}, lo = {
  key: 2,
  class: "table-select"
}, Ee = "-1", io = /* @__PURE__ */ Dt({
  __name: "ModelTable",
  props: {
    left: { default: () => ({}) },
    content: { default: () => ({}) },
    right: { type: Boolean, default: !0 },
    splitPanelProps: { default: {
      defaultSplit: { first: 225 }
    } }
  },
  emits: ["treeChange", "tableChange", "update:resultTree", "update:resultTable"],
  setup(e, { expose: t, emit: n }) {
    var at, ot, lt;
    const r = e, s = n, d = Kt(), { getServiceApi: g, isEmpty: f } = Mt(), p = "id" + (/* @__PURE__ */ new Date()).getTime(), S = ((at = r.left) == null ? void 0 : at.vNodeName) || d("全部"), _ = async (a) => {
      var P, z, U, B;
      const { query: o = {}, params: l = {}, api: i, searchKey: c = "id" } = ((P = r.left) == null ? void 0 : P.grandChildren) || {};
      if (!i) return [];
      const u = { ...o, ...l }, h = ((U = (z = r.left) == null ? void 0 : z.props) == null ? void 0 : U.nodeKey) || "id";
      a != null && a[h] && (u[c] = a[h]);
      const [O, b] = await ((B = i(u)) == null ? void 0 : B.run());
      return O ? {} : (nt(b.data || b), qe(b.data || b), b.data || b);
    }, j = async (a) => {
      var P, z, U, B;
      const { query: o = {}, params: l = {}, api: i, searchKey: c = "id" } = r.left;
      if (!i) return [];
      let u = { ...l, ...o };
      const h = ((z = (P = r.left) == null ? void 0 : P.props) == null ? void 0 : z.nodeKey) || "id";
      u[c] = a[h] || "";
      const [O, b] = await ((U = i(u)) == null ? void 0 : U.run());
      return O ? {} : ((B = r.left) != null && B.multiple || nt(), qe(b.data || b), b);
    }, R = I(() => {
      var o, l, i, c, u, h;
      const a = {
        nodeKey: "id",
        isFilter: !0,
        props: {
          children: "children",
          label: ((l = (o = r.left) == null ? void 0 : o.props) == null ? void 0 : l.nodeName) || "name",
          disabled: "disabled",
          isLeaf: "leaf"
        },
        inputOptions: {
          placeholder: d("请输入关键词")
        }
      };
      return (i = r.left) != null && i.multiple && Object.assign(a, {
        showCheckbox: !0,
        parentLinkChildrenStrictly: !0,
        defaultExpandedKeys: [p]
      }), (u = (c = r.left) == null ? void 0 : c.grandChildren) != null && u.api && Object.assign(a, {
        load: j,
        getGrandChildren: _,
        defaultExpandedKeys: [Ee]
      }), At(a, ((h = r.left) == null ? void 0 : h.props) || {});
    }), $ = I(() => {
      var o, l, i, c, u;
      const a = {
        data: [],
        valueKey: ((l = (o = r.left) == null ? void 0 : o.props) == null ? void 0 : l.nodeKey) || "id",
        labelKey: ((c = (i = r.left) == null ? void 0 : i.props) == null ? void 0 : c.nodeName) || "name"
      };
      return Object.assign(a, ((u = r.left) == null ? void 0 : u.selectListProps) || {}), a;
    }), N = I(() => {
      var o, l, i, c, u;
      const a = {
        data: [],
        valueKey: ((l = (o = r.content) == null ? void 0 : o.props) == null ? void 0 : l.rowKey) || "id",
        labelKey: ((c = (i = r.content) == null ? void 0 : i.props) == null ? void 0 : c.rowName) || "name"
      };
      return Object.assign(a, ((u = r.content) == null ? void 0 : u.selectListProps) || {}), a;
    }), q = I(() => ve(r.content)), Oe = I(() => {
      var o;
      const a = (o = r.left) == null ? void 0 : o.selectListProps;
      return a != null && a.height ? `height:${a == null ? void 0 : a.height}` : "flex: 1;";
    }), Q = I(() => {
      var o;
      const a = (o = r.left) == null ? void 0 : o.selectListProps;
      return typeof a == "boolean" ? a : f(a || {});
    }), ee = I(() => {
      var o;
      const a = (o = r.content) == null ? void 0 : o.selectListProps;
      return typeof a > "u" ? !0 : typeof a == "boolean" ? a : f(a || {});
    }), xe = I(() => {
      var a, o, l, i;
      return (o = (a = r.left) == null ? void 0 : a.props) != null && o.width || (i = (l = r.content) == null ? void 0 : l.props) != null && i.width ? "width:auto" : "width:250px";
    }), Pe = I(() => {
      var a;
      return (a = r.content) != null && a.searchKey && k.value || Ae.value;
    }), te = I(() => {
      var l;
      const a = {
        rowKey: "id",
        pageIndex: 1,
        pageSize: 20,
        paginationProps: { layout: "prev,next,sizes" }
      }, o = ve(r.content);
      return !o && ee.value && !r.content.multiple && Object.assign(a, {
        radioSelection: !0
      }), o && Object.assign(a, {
        selection: {
          showPageSelectBtn: !0,
          toolip: !1
        }
      }), At(a, ((l = r.content) == null ? void 0 : l.props) || {});
    }), ne = I(() => f(r.left)), ve = (a) => {
      var o;
      return (a == null ? void 0 : a.selectAll) || f(((o = a == null ? void 0 : a.props) == null ? void 0 : o.selection) || {});
    }, A = me(N.value, "data"), v = me($.value, "data"), w = x([]), C = x([]), D = x(""), T = x(null), re = On(), {
      run: V,
      loading: k,
      data: He,
      error: tn
    } = g((ot = r.left) == null ? void 0 : ot.api), je = async (a) => {
      var c, u;
      if (!V) return;
      const o = ((c = r.left) == null ? void 0 : c.params) || {};
      if (a && Object.assign(o, a), await V(o), tn.value) return;
      const l = (u = r.left) == null ? void 0 : u.handleData, i = l ? l(He.value) : He.value || [];
      s("update:resultTree", i), un((i == null ? void 0 : i.data) || i || []);
    }, qe = (a) => {
      var i, c;
      const o = [], l = ((c = (i = r.left) == null ? void 0 : i.props) == null ? void 0 : c.nodeKey) || "id";
      C.value.forEach((u) => o.push(u[l])), a.forEach((u) => !o.includes(u[l]) && C.value.push(u)), s("update:resultTree", C.value);
    }, ke = x([]), We = x([]), ae = x(te.value.pageIndex), ge = x(te.value.pageSize), Xe = x(0), oe = x([]), le = x(""), {
      run: $e,
      loading: Ae,
      data: nn,
      error: rn
    } = g((lt = r.content) == null ? void 0 : lt.api), W = async (a) => {
      var O;
      if (!$e) return;
      const { params: o = {}, searchKey: l = "", query: i = {} } = r.content, c = {
        ...o,
        ...i,
        pageIndex: ae.value,
        pageSize: ge.value
      };
      l && (c[l] = Je()), a && Object.assign(c, a);
      const u = (O = r.left) == null ? void 0 : O.handleParams;
      if (await $e(u ? u(c) : c), rn.value) return;
      const h = nn.value || [];
      Xe.value = +(h.totalCount || (h == null ? void 0 : h.length) || 0), ke.value = (h == null ? void 0 : h.data) || h, s("update:resultTable", h), sn();
    }, be = async (a) => {
      var b, P;
      if (!$e || !q.value) return;
      const { searchKey: o = "", params: l = {} } = r.content, i = {
        pageIndex: 1,
        pageSize: -1,
        ...l
      };
      o && (i[o] = Je()), a && Object.assign(i, a);
      const c = (b = r.left) == null ? void 0 : b.handleParams, [u, h] = await g((P = r.content) == null ? void 0 : P.api).run(c ? c(i) : i);
      if (u) return;
      const O = h.data || h;
      We.value = O;
    }, Je = () => {
      var l;
      const { searchKeyDataFormat: a = "string" } = r.content, o = a.toLocaleLowerCase() === "array";
      if ((l = R.value) != null && l.showCheckbox) {
        const i = (T.value || []).filter((c) => c !== p);
        return o ? i : i.join(",");
      }
      return o ? [T.value] : T.value;
    }, an = (a, o) => {
      A.value = [o];
    }, on = (a) => {
      A.value = a;
    }, Ye = (a) => {
      var o;
      (o = r.left) != null && o.multiple && bn(() => {
        var i;
        const { valueKey: l = "id" } = $.value;
        (i = re.value) == null || i.treeRef.setChecked(a[l], !1, !0);
      });
    }, Ze = () => {
      var a, o;
      (a = T.value) != null && a.length && (T.value = (o = r.left) != null && o.multiple ? [] : "");
    }, Qe = (a) => {
      var c;
      const { valueKey: o = "id" } = N.value, { rowKey: l = "id" } = te.value, i = a[o];
      if ((c = r.content) != null && c.multiple) {
        const u = oe.value.findIndex((h) => h[l] === i);
        u !== -1 && oe.value.splice(u, 1);
        return;
      }
      le.value === i && (le.value = "");
    }, De = () => {
      oe.value = [], le.value = "";
    }, ln = (a) => {
      var U, B, it, st;
      const { showCheckbox: o, nodeKey: l, props: i } = R.value, { valueKey: c } = $.value, u = (o ? a.value : [a.value]).filter((E) => E !== p), h = [], O = Array.from((B = (U = r.left) == null ? void 0 : U.grandChildren) != null && B.api ? C.value : w.value), b = [], P = !((it = r.left) != null && it.disabledSort);
      P && o && (h.push(...new Array(u.length).fill({})), (st = v.value) == null || st.forEach(
        (E) => u.includes(E[c || l]) && b.push(E[l])
      ));
      const z = [...new Set(b.concat(u))];
      for (; O.length; ) {
        const E = O.shift(), ut = z.findIndex((fn) => E[l] === fn);
        ut !== -1 && (P ? h.splice(ut, 1, E) : h.push(E));
        const ct = (E == null ? void 0 : E[(i == null ? void 0 : i.children) || "children"]) || [];
        ct.length && O.unshift(...ct);
      }
      return h;
    };
    let et = !0;
    const sn = () => {
      var a;
      if (et) {
        if ((a = r.content) != null && a.multiple)
          oe.value.push(...A.value);
        else {
          const o = A.value[0], { valueKey: l = "id" } = N.value;
          o && (le.value = o[l]);
        }
        et = !1;
      }
    };
    let tt = !0;
    const nt = (a) => {
      var o, l;
      if (tt) {
        if (a) {
          const i = ((l = (o = r.left) == null ? void 0 : o.props) == null ? void 0 : l.nodeKey) || "id", c = [Ee];
          a.forEach((u) => c.push(u[i])), T.value = [...new Set(c)];
        } else
          T.value = Ee;
        tt = !1;
      }
    };
    let rt = !0;
    const un = (a) => {
      var O;
      const { showCheckbox: o, nodeKey: l, props: i } = R.value;
      w.value = [], o && (a == null ? void 0 : a.length) > 1 ? w.value.push({
        [l]: p,
        [i.label || "label"]: d(S),
        [i.children || "children"]: a
      }) : w.value.push(...a);
      const { valueKey: c } = $.value;
      if (rt) {
        const b = [];
        (O = v.value) == null || O.forEach((P) => b.push(P[c || l])), T.value = o ? [...b] : b[0] || "", rt = !1;
      }
      if (T.value.length) return;
      const u = [], h = Array.from(a);
      for (; h.length; ) {
        const b = h.shift();
        !(typeof i.disabled == "string" ? b[i.disabled] : i.disabled(b)) && !u.includes(b[l]) && u.push(b[l]);
        const z = b[i.children || "children"] || [];
        z.length && (o ? h.unshift(...z) : h.push(...z));
      }
      o || (T.value = u[0] || ""), o && !Q.value && (T.value = (a == null ? void 0 : a.length) > 1 ? [p] : [], T.value.push(...u));
    }, cn = (a) => {
      ae.value = a == null ? void 0 : a.pageIndex, ge.value = a == null ? void 0 : a.pageSize;
    };
    return X(
      () => A,
      (a) => {
        s("tableChange", a.value);
      },
      { deep: !0, immediate: !0 }
    ), X(
      () => T,
      (a) => {
        var l;
        const o = ln(a);
        v.value = o, s("treeChange", o), (l = r.content) != null && l.searchKey && (W(), be());
      },
      { deep: !0 }
    ), X(
      () => {
        var a;
        return (a = r.content) == null ? void 0 : a.params;
      },
      () => {
        ae.value = 1, W();
      },
      { deep: !0 }
    ), X(
      () => {
        var a;
        return (a = r.content) == null ? void 0 : a.query;
      },
      () => {
        De(), A.value = [], W(), be();
      },
      { deep: !0 }
    ), X(
      () => {
        var a;
        return (a = r.left) == null ? void 0 : a.params;
      },
      () => {
        je();
      },
      { deep: !0 }
    ), dn(() => {
      var a, o;
      f(((a = r.left) == null ? void 0 : a.grandChildren) || {}) || je(), (o = r.content) != null && o.searchKey || (W(), be());
    }), t({
      getTableData: W,
      getAllTableData: be,
      getTreeData: je,
      removeTableAll: De,
      removeTreeAll: Ze,
      removeTreeItem: Ye,
      removeTableItem: Qe,
      setBaseTableConfig: cn
    }), (a, o) => (K(), G("div", ro, [
      L(y(Cn), H({
        "box-style": { border: "none" },
        canFold: ne.value
      }, ne.value ? e.splitPanelProps : { defaultSplit: { first: 0 } }), It({
        secondSlot: M(() => [
          ie(a.$slots, "table-header-search", {}, void 0, !0),
          pn("div", ao, [
            L(y(bt), { spinning: Pe.value }, {
              default: M(() => [
                L(y(Pn), H(te.value, {
                  "current-page": ae.value,
                  "onUpdate:currentPage": o[3] || (o[3] = (l) => ae.value = l),
                  "page-size": ge.value,
                  "onUpdate:pageSize": o[4] || (o[4] = (l) => ge.value = l),
                  total: Xe.value,
                  "current-rodio-selection": le.value,
                  "onUpdate:currentRodioSelection": o[5] || (o[5] = (l) => le.value = l),
                  "selection-rows": oe.value,
                  "onUpdate:selectionRows": o[6] || (o[6] = (l) => oe.value = l),
                  data: ke.value,
                  allData: q.value ? We.value : null,
                  loading: y(Ae),
                  onRadioChange: an,
                  onSelectionChange: on,
                  onCurrentPageChange: W,
                  onSizeChange: o[7] || (o[7] = (l) => {
                    ae.value = 1, W();
                  }),
                  "max-height": "100%"
                }), {
                  "pagination-left": M(() => [
                    ie(a.$slots, "pagination-left", {}, void 0, !0)
                  ]),
                  default: M((l) => {
                    var i, c;
                    return [
                      ie(a.$slots, "table-column", hn(vn(l)), void 0, !0),
                      (i = e.content) != null && i.multiple && ee.value && !q.value ? (K(), Me(y(gt), {
                        key: 0,
                        type: "selection",
                        width: "50"
                      })) : J("v-if", !0),
                      (K(!0), G(
                        gn,
                        null,
                        zt(((c = e.content) == null ? void 0 : c.columns) || [], (u) => (K(), Me(
                          y(gt),
                          H({
                            key: u,
                            ref_for: !0
                          }, u),
                          null,
                          16
                          /* FULL_PROPS */
                        ))),
                        128
                        /* KEYED_FRAGMENT */
                      ))
                    ];
                  }),
                  _: 3
                  /* FORWARDED */
                }, 16, ["current-page", "page-size", "total", "current-rodio-selection", "selection-rows", "data", "allData", "loading"])
              ]),
              _: 3
              /* FORWARDED */
            }, 8, ["spinning"])
          ])
        ]),
        _: 2
        /* DYNAMIC */
      }, [
        ne.value ? {
          name: "firstSlot",
          fn: M(() => [
            ie(a.$slots, "tree-header-search", {}, void 0, !0),
            L(y(bt), { spinning: y(k) }, {
              default: M(() => [
                L(y(xn), H({
                  ref_key: "$currentTreeRef",
                  ref: re,
                  loading: y(k)
                }, R.value, {
                  "filter-value": D.value,
                  "onUpdate:filterValue": o[0] || (o[0] = (l) => D.value = l),
                  data: w.value,
                  "onUpdate:data": o[1] || (o[1] = (l) => w.value = l),
                  modelValue: T.value,
                  "onUpdate:modelValue": o[2] || (o[2] = (l) => T.value = l)
                }), null, 16, ["loading", "filter-value", "data", "modelValue"])
              ]),
              _: 1
              /* STABLE */
            }, 8, ["spinning"])
          ]),
          key: "0"
        } : void 0
      ]), 1040, ["canFold"]),
      e.right ? (K(), G(
        "div",
        {
          key: 0,
          class: "right-box",
          style: pt(xe.value)
        },
        [
          Q.value ? (K(), G(
            "div",
            {
              key: 0,
              class: "tree-select",
              style: pt(Oe.value)
            },
            [
              L(y(vt), H({
                modelValue: y(v),
                "onUpdate:modelValue": o[8] || (o[8] = (l) => Ke(v) ? v.value = l : null)
              }, $.value, {
                onItemRemove: Ye,
                onRemoveAll: Ze
              }), null, 16, ["modelValue"])
            ],
            4
            /* STYLE */
          )) : J("v-if", !0),
          Q.value && ee.value ? (K(), G("div", oo)) : J("v-if", !0),
          ee.value ? (K(), G("div", lo, [
            L(y(vt), H({
              modelValue: y(A),
              "onUpdate:modelValue": o[9] || (o[9] = (l) => Ke(A) ? A.value = l : null),
              onItemRemove: Qe,
              onRemoveAll: De
            }, N.value), null, 16, ["modelValue"])
          ])) : J("v-if", !0)
        ],
        4
        /* STYLE */
      )) : J("v-if", !0)
    ]));
  }
}), so = /* @__PURE__ */ Rt(io, [["__scopeId", "data-v-fea4068c"]]), uo = {
  全部: { "zh-CN": "全部", en: "All", "zh-MO": "全部", _appCode: "framework" },
  请输入关键词: { "zh-CN": "请输入关键词", en: "Please enter keywords", "zh-MO": "請輸入關鍵詞", _appCode: "framework" },
  取消: { "zh-CN": "取消", en: "Cancel", "zh-MO": "取消", _appCode: "framework" },
  确定: { "zh-CN": "确定", en: "OK", "zh-MO": "確定", _appCode: "framework" },
  标题: { "zh-CN": "标题", en: "Title", "zh-MO": "標題", _appCode: "framework" },
  提交成功: { "zh-CN": "提交成功", en: "Submitted Successfully", "zh-MO": "提交成功", _appCode: "framework" }
};
yn(uo);
const Oo = () => x(null), xo = () => x(null), Po = Et(An), jo = Et(so), $o = { name: "modelTable 表格弹窗" };
export {
  jo as DasModelTable,
  Po as DasModelTableDialog,
  Oo as DasModelTableDialogRef,
  xo as DasModelTableRef,
  $o as default
};
