import { B as A, F as E, I as M, a as _, c as D, u as w, b as F, d as G, e as S } from "./Items-CX11yLMf.js";
import { useCallback as u, useMemo as b } from "react";
import { d } from "./css-BkBrZtKZ.js";
import { b as h } from "./Editable-DjQORuR1.js";
import "./Text-XeD58Fq8.js";
import "./jsx-runtime-BbD0H88J.js";
import "./types-B5-Tni3G.js";
import "./Box-DLO7l9hM.js";
import "./Provider-BkxUzTWS.js";
import { u as U } from "./useStaticData-p8sk2VCJ.js";
const p = 10, g = ({ offset: t, searchTerm: e = "", ...s }, a = p) => ({
  ...s,
  offset: (t ?? -a) + a,
  limit: a,
  searchTerm: e
}), y = (t, e, s = p) => ({
  ...t,
  searchTerm: e,
  offset: 0,
  limit: s
}), x = ({
  retrieve: t,
  pageSize: e = p
}) => {
  const s = u(() => {
    t((c) => g(c, e), { mode: "append" });
  }, [t, e]), a = u(
    (c) => t((n) => y(n, c, e)),
    [t, e]
  );
  return b(
    () => ({ fetchMore: s, search: a }),
    [s, a]
  );
}, C = ({
  first: t,
  second: e
}) => {
  const s = b(
    () => [...t.data, ...e.data],
    [t.data, e.data]
  ), a = u(
    (n) => {
      if (Array.isArray(n)) {
        const m = t.getItem?.(n) ?? [], i = e.getItem?.(n) ?? [];
        return [...m, ...i];
      }
      return t.getItem?.(n) ?? e.getItem?.(n);
    },
    [t.getItem, e.getItem]
  ), c = u(
    (n, m) => {
      const i = t.subscribe?.(n, m), I = e.subscribe?.(n, m);
      return () => {
        i?.(), I?.();
      };
    },
    [t.subscribe, e.subscribe]
  );
  return b(() => ({ data: s, getItem: a, subscribe: c }), [s, a, c]);
}, P = (t) => {
  const e = u(
    ((s) => {
      if (Array.isArray(s)) {
        const c = new Set(s);
        return t.filter((n) => c.has(n)).map((n) => ({ key: n }));
      }
      const a = t.find((c) => c === s);
      return a ? { key: a } : void 0;
    }),
    [t]
  );
  return b(() => ({ data: t, getItem: e }), [t, e]);
}, R = ({ initialData: t } = {}) => {
  const e = h(() => {
    const r = /* @__PURE__ */ new Map();
    return t == null || t.forEach((o) => r.set(o.key, o)), r;
  }), s = h(() => /* @__PURE__ */ new Map()), a = u((r) => {
    const o = new Set(r);
    s.current.forEach((l, f) => {
      o.has(l) && f();
    });
  }, []), c = u((r) => {
    const o = d.toArray(r), l = o.map((f) => f.key);
    o.forEach((f) => e.current.set(f.key, f)), a(l);
  }, []), n = u((r) => {
    const o = d.toArray(r);
    o.forEach((l) => e.current.delete(l)), a(o);
  }, []), m = u(
    (r, o) => o == null ? () => {
    } : (s.current.set(r, o), () => {
      s.current.delete(r);
    }),
    [s]
  ), i = u(
    ((r) => {
      if (r != null)
        return Array.isArray(r) ? r.map((o) => e.current.get(o)).filter((o) => o != null) : e.current.get(r);
    }),
    []
  ), I = u((r) => e.current.has(r), []);
  return b(
    () => ({ setItem: c, deleteItem: n, subscribe: m, getItem: i, hasItem: I }),
    [c, n, m, i, I]
  );
}, N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  BaseFrame: A,
  Frame: E,
  Item: M,
  Items: _,
  createGetItem: D,
  page: g,
  search: y,
  useCombinedData: C,
  useData: w,
  useItem: F,
  useKeysData: P,
  useMapData: R,
  usePager: x,
  useScroller: G,
  useStaticData: U,
  useUtilContext: S
}, Symbol.toStringTag, { value: "Module" }));
export {
  x as a,
  N as e,
  P as u
};
