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