import { ref as F, watch as Y, unref as d, defineComponent as Z, reactive as tt, computed as _, onMounted as et, nextTick as nt, createVNode as R } from "vue";
import { useDebounceFn as rt, useThrottleFn as it } from "@vueuse/core";
import "lodash-es";
import "dayjs";
import "ant-design-vue";
function ot({
  el: t = window,
  name: r,
  listener: e,
  options: n,
  autoRemove: i = !0,
  isDebounce: o = !0,
  wait: u = 80
}) {
  let a = () => {
  };
  const s = F(!1);
  if (t) {
    const c = F(t), y = o ? rt(e, u) : it(e, u), N = u ? y : e, $ = (l) => {
      s.value = !0, l.removeEventListener(r, N, n);
    }, H = (l) => l.addEventListener(r, N, n), L = Y(
      c,
      (l, h, g) => {
        l && (!d(s) && H(l), g(() => {
          i && $(l);
        }));
      },
      { immediate: !0 }
    );
    a = () => {
      $(c.value), L();
    };
  }
  return { removeEvent: a };
}
const at = "G";
function st(t) {
  return typeof t == "function";
}
for (let t = 0; t <= 15; t++)
  t.toString(16);
/*!
 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
 *
 * Copyright (c) 2014-2017, Jon Schlinkert.
 * Released under the MIT License.
 */
function I(t) {
  return Object.prototype.toString.call(t) === "[object Object]";
}
function ut(t) {
  var r, e;
  return I(t) === !1 ? !1 : (r = t.constructor, r === void 0 ? !0 : (e = r.prototype, !(I(e) === !1 || e.hasOwnProperty("isPrototypeOf") === !1)));
}
function S() {
  return S = Object.assign ? Object.assign.bind() : function(t) {
    for (var r = 1; r < arguments.length; r++) {
      var e = arguments[r];
      for (var n in e)
        Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
    }
    return t;
  }, S.apply(this, arguments);
}
function J(t, r) {
  if (t == null)
    return {};
  var e, n, i = {}, o = Object.keys(t);
  for (n = 0; n < o.length; n++)
    r.indexOf(e = o[n]) >= 0 || (i[e] = t[e]);
  return i;
}
const A = { silent: !1, logLevel: "warn" }, lt = ["validator"], z = Object.prototype, G = z.toString, ct = z.hasOwnProperty, U = /^\s*function (\w+)/;
function M(t) {
  var r;
  const e = (r = t == null ? void 0 : t.type) !== null && r !== void 0 ? r : t;
  if (e) {
    const n = e.toString().match(U);
    return n ? n[1] : "";
  }
  return "";
}
const b = ut, K = (t) => t;
let f = K;
process.env.NODE_ENV !== "production" && (f = typeof console < "u" ? function(r, e = A.logLevel) {
  A.silent === !1 && console[e](`[VueTypes warn]: ${r}`);
} : K);
const j = (t, r) => ct.call(t, r), ft = Number.isInteger || function(t) {
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t;
}, T = Array.isArray || function(t) {
  return G.call(t) === "[object Array]";
}, w = (t) => G.call(t) === "[object Function]", E = (t) => b(t) && j(t, "_vueTypes_name"), Q = (t) => b(t) && (j(t, "type") || ["_vueTypes_name", "validator", "default", "required"].some((r) => j(t, r)));
function W(t, r) {
  return Object.defineProperty(t.bind(r), "__original", { value: t });
}
function O(t, r, e = !1) {
  let n, i = !0, o = "";
  n = b(t) ? t : { type: t };
  const u = E(n) ? n._vueTypes_name + " - " : "";
  if (Q(n) && n.type !== null) {
    if (n.type === void 0 || n.type === !0 || !n.required && r === void 0)
      return i;
    T(n.type) ? (i = n.type.some((a) => O(a, r, !0) === !0), o = n.type.map((a) => M(a)).join(" or ")) : (o = M(n), i = o === "Array" ? T(r) : o === "Object" ? b(r) : o === "String" || o === "Number" || o === "Boolean" || o === "Function" ? function(a) {
      if (a == null)
        return "";
      const s = a.constructor.toString().match(U);
      return s ? s[1] : "";
    }(r) === o : r instanceof n.type);
  }
  if (!i) {
    const a = `${u}value "${r}" should be of type "${o}"`;
    return e === !1 ? (f(a), !1) : a;
  }
  if (j(n, "validator") && w(n.validator)) {
    const a = f, s = [];
    if (f = (c) => {
      s.push(c);
    }, i = n.validator(r), f = a, !i) {
      const c = (s.length > 1 ? "* " : "") + s.join(`
* `);
      return s.length = 0, e === !1 ? (f(c), i) : c;
    }
  }
  return i;
}
function p(t, r) {
  const e = Object.defineProperties(r, { _vueTypes_name: { value: t, writable: !0 }, isRequired: { get() {
    return this.required = !0, this;
  } }, def: { value(i) {
    return i === void 0 ? (j(this, "default") && delete this.default, this) : w(i) || O(this, i, !0) === !0 ? (this.default = T(i) ? () => [...i] : b(i) ? () => Object.assign({}, i) : i, this) : (f(`${this._vueTypes_name} - invalid default value: "${i}"`), this);
  } } }), { validator: n } = e;
  return w(n) && (e.validator = W(n, e)), e;
}
function v(t, r) {
  const e = p(t, r);
  return Object.defineProperty(e, "validate", { value(n) {
    return w(this.validator) && f(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:
${JSON.stringify(this)}`), this.validator = W(n, this), this;
  } });
}
function B(t, r, e) {
  const n = function(s) {
    const c = {};
    return Object.getOwnPropertyNames(s).forEach((y) => {
      c[y] = Object.getOwnPropertyDescriptor(s, y);
    }), Object.defineProperties({}, c);
  }(r);
  if (n._vueTypes_name = t, !b(e))
    return n;
  const { validator: i } = e, o = J(e, lt);
  if (w(i)) {
    let { validator: s } = n;
    s && (s = (a = (u = s).__original) !== null && a !== void 0 ? a : u), n.validator = W(s ? function(c) {
      return s.call(this, c) && i.call(this, c);
    } : i, n);
  }
  var u, a;
  return Object.assign(n, o);
}
function P(t) {
  return t.replace(/^(?!\s*$)/gm, "  ");
}
const dt = () => v("any", {}), pt = () => v("function", { type: Function }), yt = () => v("boolean", { type: Boolean }), ht = () => v("string", { type: String }), vt = () => v("number", { type: Number }), gt = () => v("array", { type: Array }), mt = () => v("object", { type: Object }), bt = () => p("integer", { type: Number, validator: (t) => ft(t) }), Ot = () => p("symbol", { validator: (t) => typeof t == "symbol" });
function _t(t, r = "custom validation failed") {
  if (typeof t != "function")
    throw new TypeError("[VueTypes error]: You must provide a function as argument");
  return p(t.name || "<<anonymous function>>", { type: null, validator(e) {
    const n = t(e);
    return n || f(`${this._vueTypes_name} - ${r}`), n;
  } });
}
function jt(t) {
  if (!T(t))
    throw new TypeError("[VueTypes error]: You must provide an array as argument.");
  const r = `oneOf - value should be one of "${t.join('", "')}".`, e = t.reduce((n, i) => {
    if (i != null) {
      const o = i.constructor;
      n.indexOf(o) === -1 && n.push(o);
    }
    return n;
  }, []);
  return p("oneOf", { type: e.length > 0 ? e : void 0, validator(n) {
    const i = t.indexOf(n) !== -1;
    return i || f(r), i;
  } });
}
function Tt(t) {
  if (!T(t))
    throw new TypeError("[VueTypes error]: You must provide an array as argument");
  let r = !1, e = [];
  for (let i = 0; i < t.length; i += 1) {
    const o = t[i];
    if (Q(o)) {
      if (E(o) && o._vueTypes_name === "oneOf" && o.type) {
        e = e.concat(o.type);
        continue;
      }
      if (w(o.validator) && (r = !0), o.type === !0 || !o.type) {
        f('oneOfType - invalid usage of "true" or "null" as types.');
        continue;
      }
      e = e.concat(o.type);
    } else
      e.push(o);
  }
  e = e.filter((i, o) => e.indexOf(i) === o);
  const n = e.length > 0 ? e : null;
  return p("oneOfType", r ? { type: n, validator(i) {
    const o = [], u = t.some((a) => {
      const s = O(E(a) && a._vueTypes_name === "oneOf" ? a.type || null : a, i, !0);
      return typeof s == "string" && o.push(s), s === !0;
    });
    return u || f(`oneOfType - provided value does not match any of the ${o.length} passed-in validators:
${P(o.join(`
`))}`), u;
  } } : { type: n });
}
function wt(t) {
  return p("arrayOf", { type: Array, validator(r) {
    let e = "";
    const n = r.every((i) => (e = O(t, i, !0), e === !0));
    return n || f(`arrayOf - value validation error:
${P(e)}`), n;
  } });
}
function $t(t) {
  return p("instanceOf", { type: t });
}
function St(t) {
  return p("objectOf", { type: Object, validator(r) {
    let e = "";
    const n = Object.keys(r).every((i) => (e = O(t, r[i], !0), e === !0));
    return n || f(`objectOf - value validation error:
${P(e)}`), n;
  } });
}
function xt(t) {
  const r = Object.keys(t), e = r.filter((i) => {
    var o;
    return !((o = t[i]) === null || o === void 0 || !o.required);
  }), n = p("shape", { type: Object, validator(i) {
    if (!b(i))
      return !1;
    const o = Object.keys(i);
    if (e.length > 0 && e.some((u) => o.indexOf(u) === -1)) {
      const u = e.filter((a) => o.indexOf(a) === -1);
      return f(u.length === 1 ? `shape - required property "${u[0]}" is not defined.` : `shape - required properties "${u.join('", "')}" are not defined.`), !1;
    }
    return o.every((u) => {
      if (r.indexOf(u) === -1)
        return this._vueTypes_isLoose === !0 || (f(`shape - shape definition does not include a "${u}" property. Allowed keys: "${r.join('", "')}".`), !1);
      const a = O(t[u], i[u], !0);
      return typeof a == "string" && f(`shape - "${u}" property validation error:
 ${P(a)}`), a === !0;
    });
  } });
  return Object.defineProperty(n, "_vueTypes_isLoose", { writable: !0, value: !1 }), Object.defineProperty(n, "loose", { get() {
    return this._vueTypes_isLoose = !0, this;
  } }), n;
}
const Nt = ["name", "validate", "getter"], Et = /* @__PURE__ */ (() => {
  var t;
  return (t = class {
    static get any() {
      return dt();
    }
    static get func() {
      return pt().def(this.defaults.func);
    }
    static get bool() {
      return yt().def(this.defaults.bool);
    }
    static get string() {
      return ht().def(this.defaults.string);
    }
    static get number() {
      return vt().def(this.defaults.number);
    }
    static get array() {
      return gt().def(this.defaults.array);
    }
    static get object() {
      return mt().def(this.defaults.object);
    }
    static get integer() {
      return bt().def(this.defaults.integer);
    }
    static get symbol() {
      return Ot();
    }
    static get nullable() {
      return { type: null };
    }
    static extend(r) {
      if (T(r))
        return r.forEach((s) => this.extend(s)), this;
      const { name: e, validate: n = !1, getter: i = !1 } = r, o = J(r, Nt);
      if (j(this, e))
        throw new TypeError(`[VueTypes error]: Type "${e}" already defined`);
      const { type: u } = o;
      if (E(u))
        return delete o.type, Object.defineProperty(this, e, i ? { get: () => B(e, u, o) } : { value(...s) {
          const c = B(e, u, o);
          return c.validator && (c.validator = c.validator.bind(c, ...s)), c;
        } });
      let a;
      return a = i ? { get() {
        const s = Object.assign({}, o);
        return n ? v(e, s) : p(e, s);
      }, enumerable: !0 } : { value(...s) {
        const c = Object.assign({}, o);
        let y;
        return y = n ? v(e, c) : p(e, c), c.validator && (y.validator = c.validator.bind(y, ...s)), y;
      }, enumerable: !0 }, Object.defineProperty(this, e, a);
    }
  }).defaults = {}, t.sensibleDefaults = void 0, t.config = A, t.custom = _t, t.oneOf = jt, t.instanceOf = $t, t.oneOfType = Tt, t.arrayOf = wt, t.objectOf = St, t.shape = xt, t.utils = { validate: (r, e) => O(e, r, !0) === !0, toType: (r, e, n = !1) => n ? v(r, e) : p(r, e) }, t;
})();
function X(t = { func: () => {
}, bool: !0, string: "", number: 0, array: () => [], object: () => ({}), integer: 0 }) {
  var r;
  return (r = class extends Et {
    static get sensibleDefaults() {
      return S({}, this.defaults);
    }
    static set sensibleDefaults(e) {
      this.defaults = e !== !1 ? S({}, e !== !0 ? e : t) : {};
    }
  }).defaults = S({}, t), r;
}
class Ct extends X() {
}
const Pt = X({
  func: void 0,
  bool: void 0,
  string: void 0,
  number: void 0,
  object: void 0,
  integer: void 0
});
Pt.extend([
  {
    name: "style",
    getter: !0,
    type: [String, Object],
    default: void 0
  },
  {
    name: "VNodeChild",
    getter: !0,
    type: void 0
  }
]);
function Ht(t, r = "default", e, n) {
  if (!t || !Reflect.has(t, r))
    return null;
  if (!st(t[r]))
    return console.error(`${r} is not a function!`), null;
  const i = t[r];
  if (!i)
    return null;
  const o = {
    ...e,
    ...n
  };
  return i(o);
}
const Lt = {
  height: [Number, String],
  maxHeight: [Number, String],
  maxWidth: [Number, String],
  minHeight: [Number, String],
  minWidth: [Number, String],
  width: [Number, String],
  bench: {
    type: [Number, String],
    default: 0
  },
  itemHeight: {
    type: [Number, String],
    required: !0
  },
  items: {
    type: Array,
    default: () => []
  }
};
const V = "virtual-scroll";
function m(t, r = "px") {
  if (!(t == null || t === ""))
    return isNaN(+t) ? String(t) : `${Number(t)}${r}`;
}
const Rt = /* @__PURE__ */ Z({
  name: `${at}VirtualScroll`,
  props: Lt,
  setup(t, {
    slots: r
  }) {
    const e = F(null), n = tt({
      first: 0,
      last: 0,
      scrollTop: 0
    }), i = _(() => parseInt(t.bench, 10)), o = _(() => parseInt(t.itemHeight, 10)), u = _(() => Math.max(0, n.first - d(i))), a = _(() => Math.min((t.items || []).length, n.last + d(i))), s = _(() => ({
      height: m((t.items || []).length * d(o))
    })), c = _(() => {
      const l = {}, h = m(t.height), g = m(t.minHeight), q = m(t.minWidth), k = m(t.maxHeight), C = m(t.maxWidth), D = m(t.width);
      return h && (l.height = h), g && (l.minHeight = g), q && (l.minWidth = q), k && (l.maxHeight = k), C && (l.maxWidth = C), D && (l.width = D), l;
    });
    Y([() => t.itemHeight, () => t.height], () => {
      $();
    });
    function y(l) {
      const h = d(e);
      if (!h)
        return 0;
      const g = parseInt(t.height || 0, 10) || h.clientHeight;
      return l + Math.ceil(g / d(o));
    }
    function N() {
      return Math.floor(n.scrollTop / d(o));
    }
    function $() {
      const l = d(e);
      l && (n.scrollTop = l.scrollTop, n.first = N(), n.last = y(n.first));
    }
    function H() {
      const {
        items: l = []
      } = t;
      return l.slice(d(u), d(a)).map(L);
    }
    function L(l, h) {
      h += d(u);
      const g = m(h * d(o));
      return R("div", {
        class: `${V}__item`,
        style: {
          top: g
        },
        key: h
      }, [Ht(r, "default", {
        index: h,
        item: l
      })]);
    }
    return et(() => {
      n.last = y(0), nt(() => {
        const l = d(e);
        l && ot({
          el: l,
          name: "scroll",
          listener: $,
          wait: 0
        });
      });
    }), () => R("div", {
      class: V,
      style: d(c),
      ref: e
    }, [R("div", {
      class: `${V}__container`,
      style: d(s)
    }, [H()])]);
  }
});
const Vt = (t, r) => {
  const e = t.__vccOpts || t;
  for (const [n, i] of r)
    e[n] = i;
  return e;
}, x = /* @__PURE__ */ Vt(Rt, [["__scopeId", "data-v-65d50d5e"]]);
x.install = function(t, r) {
  t.component(r || x.name, x);
};
const Dt = {
  title: "VirtualScroll 虚拟滚动",
  category: "数据描述",
  status: "100%",
  install(t) {
    t.component(x.name, x);
  }
};
export {
  x as VirtualScroll,
  Dt as default
};
