import { C as A, F as E, I as M, a as _, c as C, u as D, b as w, d as F, e as G } from "./Items-G25zb57I.js";
import { useCallback as u, useMemo as b } from "react";
import { h } from "./css-D6ZBcSwh.js";
import { b as d } from "./Editable-CxgdRDPb.js";
import "./Text-BzTkWLeU.js";
import "./jsx-runtime-OVHDjVDe.js";
import "./types-BNX_Jj6k.js";
import "./Box-D5Qv__kr.js";
import "./Provider--RxgAoVG.js";
import "./provider-C8In649C.js";
import { u as S } from "./useStaticData-p8sk2VCJ.js";
const I = 10, g = ({ offset: t, searchTerm: e = "", ...s }, a = I) => ({
  ...s,
  offset: (t ?? -a) + a,
  limit: a,
  searchTerm: e
}), y = (t, e, s = I) => ({
  ...t,
  searchTerm: e,
  offset: 0,
  limit: s
}), U = ({
  retrieve: t,
  pageSize: e = I
}) => {
  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]
  );
}, x = ({
  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), p = e.subscribe?.(n, m);
      return () => {
        i?.(), p?.();
      };
    },
    [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 = d(() => {
    const r = /* @__PURE__ */ new Map();
    return t == null || t.forEach((o) => r.set(o.key, o)), r;
  }), s = d(() => /* @__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 = h.toArray(r), l = o.map((f) => f.key);
    o.forEach((f) => e.current.set(f.key, f)), a(l);
  }, []), n = u((r) => {
    const o = h.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);
    }),
    []
  ), p = u((r) => e.current.has(r), []);
  return b(
    () => ({ setItem: c, deleteItem: n, subscribe: m, getItem: i, hasItem: p }),
    [c, n, m, i, p]
  );
}, Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  CoreFrame: A,
  Frame: E,
  Item: M,
  Items: _,
  createGetItem: C,
  page: g,
  search: y,
  useCombinedData: x,
  useData: D,
  useItem: w,
  useKeysData: P,
  useMapData: R,
  usePager: U,
  useScroller: F,
  useStaticData: S,
  useUtilContext: G
}, Symbol.toStringTag, { value: "Module" }));
export {
  U as a,
  Q as e,
  P as u
};
