import { j as E } from "./jsx-runtime-BbD0H88J.js";
import { B as P } from "./Button-DLtxKGH5.js";
import { I as U, C as b } from "./css-BkBrZtKZ.js";
import { u as $, d as H, c as q } from "./Animated-C4xrEVd-.js";
import * as w from "react";
import { memo as A, useRef as C, useCallback as S, useMemo as M, useSyncExternalStore as K } from "react";
import { p as X, a as G } from "./Box-DLO7l9hM.js";
import { flushSync as Y } from "react-dom";
import { c as V } from "./Text-XeD58Fq8.js";
import { f as J, c as j, g as Q } from "./Editable-DjQORuR1.js";
import "./types-B5-Tni3G.js";
import "./Provider-BkxUzTWS.js";
function O(n, l, e) {
  let s = e.initialDeps ?? [], t;
  function i() {
    var o, r, a, h;
    let c;
    e.key && ((o = e.debug) != null && o.call(e)) && (c = Date.now());
    const u = n();
    if (!(u.length !== s.length || u.some((f, m) => s[m] !== f)))
      return t;
    s = u;
    let g;
    if (e.key && ((r = e.debug) != null && r.call(e)) && (g = Date.now()), t = l(...u), e.key && ((a = e.debug) != null && a.call(e))) {
      const f = Math.round((Date.now() - c) * 100) / 100, m = Math.round((Date.now() - g) * 100) / 100, v = m / 16, x = (p, I) => {
        for (p = String(p); p.length < I; )
          p = " " + p;
        return p;
      };
      console.info(
        `%c⏱ ${x(m, 5)} /${x(f, 5)} ms`,
        `
            font-size: .6rem;
            font-weight: bold;
            color: hsl(${Math.max(
          0,
          Math.min(120 - 120 * v, 120)
        )}deg 100% 31%);`,
        e?.key
      );
    }
    return (h = e?.onChange) == null || h.call(e, t), t;
  }
  return i.updateDeps = (o) => {
    s = o;
  }, i;
}
function D(n, l) {
  if (n === void 0)
    throw new Error("Unexpected undefined");
  return n;
}
const Z = (n, l) => Math.abs(n - l) < 1, ee = (n, l, e) => {
  let s;
  return function(...t) {
    n.clearTimeout(s), s = n.setTimeout(() => l.apply(this, t), e);
  };
}, te = (n) => n, se = (n) => {
  const l = Math.max(n.startIndex - n.overscan, 0), e = Math.min(n.endIndex + n.overscan, n.count - 1), s = [];
  for (let t = l; t <= e; t++)
    s.push(t);
  return s;
}, ne = (n, l) => {
  const e = n.scrollElement;
  if (!e)
    return;
  const s = n.targetWindow;
  if (!s)
    return;
  const t = (o) => {
    const { width: r, height: a } = o;
    l({ width: Math.round(r), height: Math.round(a) });
  };
  if (t(e.getBoundingClientRect()), !s.ResizeObserver)
    return () => {
    };
  const i = new s.ResizeObserver((o) => {
    const r = () => {
      const a = o[0];
      if (a?.borderBoxSize) {
        const h = a.borderBoxSize[0];
        if (h) {
          t({ width: h.inlineSize, height: h.blockSize });
          return;
        }
      }
      t(e.getBoundingClientRect());
    };
    n.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
  });
  return i.observe(e, { box: "border-box" }), () => {
    i.unobserve(e);
  };
}, _ = {
  passive: !0
}, F = typeof window > "u" ? !0 : "onscrollend" in window, ie = (n, l) => {
  const e = n.scrollElement;
  if (!e)
    return;
  const s = n.targetWindow;
  if (!s)
    return;
  let t = 0;
  const i = n.options.useScrollendEvent && F ? () => {
  } : ee(
    s,
    () => {
      l(t, !1);
    },
    n.options.isScrollingResetDelay
  ), o = (c) => () => {
    const { horizontal: u, isRtl: d } = n.options;
    t = u ? e.scrollLeft * (d && -1 || 1) : e.scrollTop, i(), l(t, c);
  }, r = o(!0), a = o(!1);
  a(), e.addEventListener("scroll", r, _);
  const h = n.options.useScrollendEvent && F;
  return h && e.addEventListener("scrollend", a, _), () => {
    e.removeEventListener("scroll", r), h && e.removeEventListener("scrollend", a);
  };
}, oe = (n, l, e) => {
  if (l?.borderBoxSize) {
    const s = l.borderBoxSize[0];
    if (s)
      return Math.round(
        s[e.options.horizontal ? "inlineSize" : "blockSize"]
      );
  }
  return Math.round(
    n.getBoundingClientRect()[e.options.horizontal ? "width" : "height"]
  );
}, re = (n, {
  adjustments: l = 0,
  behavior: e
}, s) => {
  var t, i;
  const o = n + l;
  (i = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || i.call(t, {
    [s.options.horizontal ? "left" : "top"]: o,
    behavior: e
  });
};
class le {
  constructor(l) {
    this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollToIndexTimeoutId = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
      let e = null;
      const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
        t.forEach((i) => {
          const o = () => {
            this._measureElement(i.target, i);
          };
          this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
        });
      }));
      return {
        disconnect: () => {
          var t;
          (t = s()) == null || t.disconnect(), e = null;
        },
        observe: (t) => {
          var i;
          return (i = s()) == null ? void 0 : i.observe(t, { box: "border-box" });
        },
        unobserve: (t) => {
          var i;
          return (i = s()) == null ? void 0 : i.unobserve(t);
        }
      };
    })(), this.range = null, this.setOptions = (e) => {
      Object.entries(e).forEach(([s, t]) => {
        typeof t > "u" && delete e[s];
      }), this.options = {
        debug: !1,
        initialOffset: 0,
        overscan: 1,
        paddingStart: 0,
        paddingEnd: 0,
        scrollPaddingStart: 0,
        scrollPaddingEnd: 0,
        horizontal: !1,
        getItemKey: te,
        rangeExtractor: se,
        onChange: () => {
        },
        measureElement: oe,
        initialRect: { width: 0, height: 0 },
        scrollMargin: 0,
        gap: 0,
        indexAttribute: "data-index",
        initialMeasurementsCache: [],
        lanes: 1,
        isScrollingResetDelay: 150,
        enabled: !0,
        isRtl: !1,
        useScrollendEvent: !1,
        useAnimationFrameWithResizeObserver: !1,
        ...e
      };
    }, this.notify = (e) => {
      var s, t;
      (t = (s = this.options).onChange) == null || t.call(s, this, e);
    }, this.maybeNotify = O(
      () => (this.calculateRange(), [
        this.isScrolling,
        this.range ? this.range.startIndex : null,
        this.range ? this.range.endIndex : null
      ]),
      (e) => {
        this.notify(e);
      },
      {
        key: process.env.NODE_ENV !== "production" && "maybeNotify",
        debug: () => this.options.debug,
        initialDeps: [
          this.isScrolling,
          this.range ? this.range.startIndex : null,
          this.range ? this.range.endIndex : null
        ]
      }
    ), this.cleanup = () => {
      this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
    }, this._didMount = () => () => {
      this.cleanup();
    }, this._willUpdate = () => {
      var e;
      const s = this.options.enabled ? this.options.getScrollElement() : null;
      if (this.scrollElement !== s) {
        if (this.cleanup(), !s) {
          this.maybeNotify();
          return;
        }
        this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((t) => {
          this.observer.observe(t);
        }), this._scrollToOffset(this.getScrollOffset(), {
          adjustments: void 0,
          behavior: void 0
        }), this.unsubs.push(
          this.options.observeElementRect(this, (t) => {
            this.scrollRect = t, this.maybeNotify();
          })
        ), this.unsubs.push(
          this.options.observeElementOffset(this, (t, i) => {
            this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, this.isScrolling = i, this.maybeNotify();
          })
        );
      }
    }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, s) => {
      const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
      for (let o = s - 1; o >= 0; o--) {
        const r = e[o];
        if (t.has(r.lane))
          continue;
        const a = i.get(
          r.lane
        );
        if (a == null || r.end > a.end ? i.set(r.lane, r) : r.end < a.end && t.set(r.lane, !0), t.size === this.options.lanes)
          break;
      }
      return i.size === this.options.lanes ? Array.from(i.values()).sort((o, r) => o.end === r.end ? o.index - r.index : o.end - r.end)[0] : void 0;
    }, this.getMeasurementOptions = O(
      () => [
        this.options.count,
        this.options.paddingStart,
        this.options.scrollMargin,
        this.options.getItemKey,
        this.options.enabled
      ],
      (e, s, t, i, o) => (this.pendingMeasuredCacheIndexes = [], {
        count: e,
        paddingStart: s,
        scrollMargin: t,
        getItemKey: i,
        enabled: o
      }),
      {
        key: !1
      }
    ), this.getMeasurements = O(
      () => [this.getMeasurementOptions(), this.itemSizeCache],
      ({ count: e, paddingStart: s, scrollMargin: t, getItemKey: i, enabled: o }, r) => {
        if (!o)
          return this.measurementsCache = [], this.itemSizeCache.clear(), [];
        this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
          this.itemSizeCache.set(c.key, c.size);
        }));
        const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
        this.pendingMeasuredCacheIndexes = [];
        const h = this.measurementsCache.slice(0, a);
        for (let c = a; c < e; c++) {
          const u = i(c), d = this.options.lanes === 1 ? h[c - 1] : this.getFurthestMeasurement(h, c), g = d ? d.end + this.options.gap : s + t, f = r.get(u), m = typeof f == "number" ? f : this.options.estimateSize(c), v = g + m, x = d ? d.lane : c % this.options.lanes;
          h[c] = {
            index: c,
            start: g,
            size: m,
            end: v,
            key: u,
            lane: x
          };
        }
        return this.measurementsCache = h, h;
      },
      {
        key: process.env.NODE_ENV !== "production" && "getMeasurements",
        debug: () => this.options.debug
      }
    ), this.calculateRange = O(
      () => [
        this.getMeasurements(),
        this.getSize(),
        this.getScrollOffset(),
        this.options.lanes
      ],
      (e, s, t, i) => this.range = e.length > 0 && s > 0 ? ae({
        measurements: e,
        outerSize: s,
        scrollOffset: t,
        lanes: i
      }) : null,
      {
        key: process.env.NODE_ENV !== "production" && "calculateRange",
        debug: () => this.options.debug
      }
    ), this.getVirtualIndexes = O(
      () => {
        let e = null, s = null;
        const t = this.calculateRange();
        return t && (e = t.startIndex, s = t.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
          this.options.rangeExtractor,
          this.options.overscan,
          this.options.count,
          e,
          s
        ];
      },
      (e, s, t, i, o) => i === null || o === null ? [] : e({
        startIndex: i,
        endIndex: o,
        overscan: s,
        count: t
      }),
      {
        key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
        debug: () => this.options.debug
      }
    ), this.indexFromElement = (e) => {
      const s = this.options.indexAttribute, t = e.getAttribute(s);
      return t ? parseInt(t, 10) : (console.warn(
        `Missing attribute name '${s}={index}' on measured element.`
      ), -1);
    }, this._measureElement = (e, s) => {
      const t = this.indexFromElement(e), i = this.measurementsCache[t];
      if (!i)
        return;
      const o = i.key, r = this.elementsCache.get(o);
      r !== e && (r && this.observer.unobserve(r), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
    }, this.resizeItem = (e, s) => {
      const t = this.measurementsCache[e];
      if (!t)
        return;
      const i = this.itemSizeCache.get(t.key) ?? t.size, o = s - i;
      o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, o, this) : t.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
        adjustments: this.scrollAdjustments += o,
        behavior: void 0
      })), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
    }, this.measureElement = (e) => {
      if (!e) {
        this.elementsCache.forEach((s, t) => {
          s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
        });
        return;
      }
      this._measureElement(e, void 0);
    }, this.getVirtualItems = O(
      () => [this.getVirtualIndexes(), this.getMeasurements()],
      (e, s) => {
        const t = [];
        for (let i = 0, o = e.length; i < o; i++) {
          const r = e[i], a = s[r];
          t.push(a);
        }
        return t;
      },
      {
        key: process.env.NODE_ENV !== "production" && "getVirtualItems",
        debug: () => this.options.debug
      }
    ), this.getVirtualItemForOffset = (e) => {
      const s = this.getMeasurements();
      if (s.length !== 0)
        return D(
          s[k(
            0,
            s.length - 1,
            (t) => D(s[t]).start,
            e
          )]
        );
    }, this.getOffsetForAlignment = (e, s, t = 0) => {
      const i = this.getSize(), o = this.getScrollOffset();
      s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (t - i) / 2 : s === "end" && (e -= i);
      const r = this.options.horizontal ? "scrollWidth" : "scrollHeight", h = (this.scrollElement ? "document" in this.scrollElement ? this.scrollElement.document.documentElement[r] : this.scrollElement[r] : 0) - i;
      return Math.max(Math.min(h, e), 0);
    }, this.getOffsetForIndex = (e, s = "auto") => {
      e = Math.max(0, Math.min(e, this.options.count - 1));
      const t = this.measurementsCache[e];
      if (!t)
        return;
      const i = this.getSize(), o = this.getScrollOffset();
      if (s === "auto")
        if (t.end >= o + i - this.options.scrollPaddingEnd)
          s = "end";
        else if (t.start <= o + this.options.scrollPaddingStart)
          s = "start";
        else
          return [o, s];
      const r = s === "end" ? t.end + this.options.scrollPaddingEnd : t.start - this.options.scrollPaddingStart;
      return [
        this.getOffsetForAlignment(r, s, t.size),
        s
      ];
    }, this.isDynamicMode = () => this.elementsCache.size > 0, this.cancelScrollToIndex = () => {
      this.scrollToIndexTimeoutId !== null && this.targetWindow && (this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId), this.scrollToIndexTimeoutId = null);
    }, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
      this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      ), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
        adjustments: void 0,
        behavior: t
      });
    }, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
      e = Math.max(0, Math.min(e, this.options.count - 1)), this.cancelScrollToIndex(), t === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      );
      const i = this.getOffsetForIndex(e, s);
      if (!i) return;
      const [o, r] = i;
      this._scrollToOffset(o, { adjustments: void 0, behavior: t }), t !== "smooth" && this.isDynamicMode() && this.targetWindow && (this.scrollToIndexTimeoutId = this.targetWindow.setTimeout(() => {
        if (this.scrollToIndexTimeoutId = null, this.elementsCache.has(
          this.options.getItemKey(e)
        )) {
          const [h] = D(
            this.getOffsetForIndex(e, r)
          );
          Z(h, this.getScrollOffset()) || this.scrollToIndex(e, { align: r, behavior: t });
        } else
          this.scrollToIndex(e, { align: r, behavior: t });
      }));
    }, this.scrollBy = (e, { behavior: s } = {}) => {
      this.cancelScrollToIndex(), s === "smooth" && this.isDynamicMode() && console.warn(
        "The `smooth` scroll behavior is not fully supported with dynamic size."
      ), this._scrollToOffset(this.getScrollOffset() + e, {
        adjustments: void 0,
        behavior: s
      });
    }, this.getTotalSize = () => {
      var e;
      const s = this.getMeasurements();
      let t;
      if (s.length === 0)
        t = this.options.paddingStart;
      else if (this.options.lanes === 1)
        t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
      else {
        const i = Array(this.options.lanes).fill(null);
        let o = s.length - 1;
        for (; o >= 0 && i.some((r) => r === null); ) {
          const r = s[o];
          i[r.lane] === null && (i[r.lane] = r.end), o--;
        }
        t = Math.max(...i.filter((r) => r !== null));
      }
      return Math.max(
        t - this.options.scrollMargin + this.options.paddingEnd,
        0
      );
    }, this._scrollToOffset = (e, {
      adjustments: s,
      behavior: t
    }) => {
      this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
    }, this.measure = () => {
      this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
    }, this.setOptions(l);
  }
}
const k = (n, l, e, s) => {
  for (; n <= l; ) {
    const t = (n + l) / 2 | 0, i = e(t);
    if (i < s)
      n = t + 1;
    else if (i > s)
      l = t - 1;
    else
      return t;
  }
  return n > 0 ? n - 1 : 0;
};
function ae({
  measurements: n,
  outerSize: l,
  scrollOffset: e,
  lanes: s
}) {
  const t = n.length - 1, i = (a) => n[a].start;
  if (n.length <= s)
    return {
      startIndex: 0,
      endIndex: t
    };
  let o = k(
    0,
    t,
    i,
    e
  ), r = o;
  if (s === 1)
    for (; r < t && n[r].end < e + l; )
      r++;
  else if (s > 1) {
    const a = Array(s).fill(0);
    for (; r < t && a.some((c) => c < e + l); ) {
      const c = n[r];
      a[c.lane] = c.end, r++;
    }
    const h = Array(s).fill(e + l);
    for (; o >= 0 && h.some((c) => c >= e); ) {
      const c = n[o];
      h[c.lane] = c.start, o--;
    }
    o = Math.max(0, o - o % s), r = Math.min(t, r + (s - 1 - r % s));
  }
  return { startIndex: o, endIndex: r };
}
const N = typeof document < "u" ? w.useLayoutEffect : w.useEffect;
function ce(n) {
  const l = w.useReducer(() => ({}), {})[1], e = {
    ...n,
    onChange: (t, i) => {
      var o;
      i ? Y(l) : l(), (o = n.onChange) == null || o.call(n, t, i);
    }
  }, [s] = w.useState(
    () => new le(e)
  );
  return s.setOptions(e), N(() => s._didMount(), []), N(() => s._willUpdate()), s;
}
function he(n) {
  return ce({
    observeElementRect: ne,
    observeElementOffset: ie,
    scrollToFn: re,
    ...n
  });
}
const Re = (n, l) => ((e) => Array.isArray(e) ? l(e) : n(e)), [L, ue] = V({
  displayName: "List.DataContext",
  providerName: "List.Frame"
}), [B, T] = V({
  displayName: "List.UtilContext",
  providerName: "List.Frame"
}), De = () => T("List.useUtilContext"), _e = () => {
  const { scrollToIndex: n } = T("List.useScroller");
  return M(() => ({ scrollToIndex: n }), [n]);
}, Fe = (n) => {
  const { getItem: l, subscribe: e } = T(
    "List.useItem"
  );
  return K(
    S(
      (s) => e == null ? () => {
      } : e(s, n),
      [n, e]
    ),
    S(() => l?.(n), [l, n]),
    () => {
    }
  );
}, de = () => {
  const { data: n, getItems: l, getTotalSize: e, itemHeight: s, sentinelRef: t } = ue(
    "List.useData"
  ), { ref: i, getItem: o, scrollToIndex: r, subscribe: a } = T(
    "List.useData"
  );
  return M(
    () => ({
      data: n,
      getItems: l,
      getTotalSize: e,
      ref: i,
      getItem: o,
      scrollToIndex: r,
      subscribe: a,
      itemHeight: s,
      sentinelRef: t
    }),
    [
      n,
      l,
      e,
      i,
      o,
      r,
      a,
      s,
      t
    ]
  );
}, W = (n, l, e) => {
  const s = j(e), { visible: t } = $(), i = C(!1);
  return S(
    (o) => {
      n.current = o, !(n.current == null || i.current) && (i.current = !0, s.current?.());
    },
    [s, t, l]
  );
}, fe = 100, me = (n, l) => {
  const e = j(n), s = C(!1), t = C(null), i = C(null), o = C(null), r = Q(l);
  r !== void 0 && l !== r && (s.current = !1);
  const a = S(() => {
    t.current?.disconnect(), t.current = null;
    const u = i.current, d = o.current;
    u == null || d == null || (t.current = new IntersectionObserver(
      (g) => {
        g[0].isIntersecting && !s.current && (s.current = !0, e.current?.());
      },
      {
        root: u,
        rootMargin: `0px 0px ${fe}px 0px`,
        threshold: 0
      }
    ), t.current.observe(d));
  }, [e]), h = S(
    (u) => {
      i.current = u, a();
    },
    [a]
  ), c = S(
    (u) => {
      o.current = u, a();
    },
    [a]
  );
  return { containerRef: h, sentinelRef: c };
}, ge = ({
  data: n,
  getItem: l,
  subscribe: e,
  children: s,
  onFetchMore: t,
  overscan: i = 10,
  itemHeight: o = 36
}) => {
  const r = C(null), a = n.length > 0, h = W(r, a, t), c = he({
    count: n.length,
    getScrollElement: () => r.current,
    estimateSize: () => o,
    overscan: i,
    onChange: S(
      (f) => {
        const m = f.getVirtualItems();
        m.length > 0 && m[m.length - 1].index === n.length - 1 && t?.();
      },
      [n.length, t]
    )
  }), u = c.getVirtualItems(), d = M(
    () => ({
      ref: h,
      getItem: l,
      data: n,
      subscribe: e,
      getTotalSize: () => c.getTotalSize(),
      getItems: () => u.map(({ index: f, start: m }) => ({
        key: n[f],
        index: f,
        translate: m
      })),
      itemHeight: o
    }),
    [h, c, n, l, o, u]
  ), g = M(
    () => ({
      ref: h,
      getItem: l,
      scrollToIndex: (f) => c.scrollToIndex(f),
      subscribe: e
    }),
    [h, c, l, e]
  );
  return /* @__PURE__ */ E.jsx(L, { value: d, children: /* @__PURE__ */ E.jsx(B, { value: g, children: s }) });
}, pe = ({
  data: n,
  getItem: l,
  subscribe: e,
  children: s,
  onFetchMore: t,
  itemHeight: i
}) => {
  const o = C(null), r = n.length > 0, a = S((v, x) => {
    const p = o.current?.children[0];
    if (p == null) return;
    const I = x === "top" ? 1 : -1;
    let z;
    const R = v + I;
    U.contains({ lower: 0, upper: p.children.length }, R) ? z = v + I : z = v;
    const y = p.children[z];
    y?.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
  }, []), h = W(o, r, t), { containerRef: c, sentinelRef: u } = me(t, n.length), d = J(h, c), g = M(() => n.map((v, x) => ({ key: v, index: x })), [n]), f = M(
    () => ({
      ref: d,
      getItem: l,
      data: n,
      subscribe: e,
      getTotalSize: () => {
      },
      getItems: () => g,
      itemHeight: i,
      sentinelRef: u
    }),
    [d, n, l, e, i, u, g]
  ), m = M(
    () => ({
      ref: d,
      getItem: l,
      scrollToIndex: a,
      subscribe: e
    }),
    [d, l, e, a]
  );
  return /* @__PURE__ */ E.jsx(L, { value: f, children: /* @__PURE__ */ E.jsx(B, { value: m, children: s }) });
}, ve = ({
  virtual: n = !1,
  ...l
}) => n ? /* @__PURE__ */ E.jsx(ge, { ...l }) : /* @__PURE__ */ E.jsx(pe, { ...l }), Ne = A(ve), Ae = ({
  itemKey: n,
  className: l,
  index: e,
  el: s,
  draggingOver: t = !1,
  rightAligned: i = !1,
  highlightHovered: o = !1,
  selected: r = !1,
  translate: a,
  onSelect: h,
  onClick: c,
  hovered: u,
  style: d,
  ...g
}) => /* @__PURE__ */ E.jsx(
  P,
  {
    el: s,
    defaultEl: "div",
    id: n.toString(),
    variant: "text",
    onClick: (f) => {
      h?.(n), c?.(f);
    },
    className: b(
      l,
      H,
      r && q,
      u && b.M("hovered"),
      i && b.M("right-aligned"),
      o && b.M("highlight-hover"),
      t && b.M("dragging-over"),
      b.BE("list", "item"),
      b.selected(r)
    ),
    style: {
      position: a != null ? "absolute" : "relative",
      transform: `translateY(${a}px)`,
      ...d
    },
    square: !1,
    ...g
  }
), xe = ({
  className: n,
  children: l,
  emptyContent: e,
  displayItems: s,
  style: t,
  direction: i,
  x: o,
  y: r,
  ...a
}) => {
  const { ref: h, getItems: c, getTotalSize: u, data: d, itemHeight: g, sentinelRef: f } = de(), m = c();
  let v = e;
  const x = d.length > 0;
  x && (v = /* @__PURE__ */ E.jsxs(
    "div",
    {
      className: b.BE("list", "virtualizer"),
      style: { minHeight: u() },
      children: [
        m.map(
          ({ key: z, index: R, translate: y }) => l({ key: z, index: R, itemKey: z, translate: y })
        ),
        f != null && /* @__PURE__ */ E.jsx(
          "div",
          {
            ref: f,
            className: b.BE("list", "sentinel"),
            "aria-hidden": "true"
          }
        )
      ]
    }
  ));
  let p;
  g != null && s != null && isFinite(s) && x && (p = Math.min(s, m.length) * g + 1);
  const I = X(i, o, r);
  return /* @__PURE__ */ E.jsx(
    G,
    {
      gap: 0,
      ref: h,
      className: b(
        n,
        b.BE("list", "items"),
        !x && b.BEM("list", "items", "empty")
      ),
      style: { height: p, ...t },
      full: I,
      direction: I,
      ...a,
      children: v
    }
  );
}, Ve = A(xe);
export {
  ve as B,
  Ne as F,
  Ae as I,
  Ve as a,
  Fe as b,
  Re as c,
  _e as d,
  De as e,
  de as u
};
