import { a as O, T as m, k as T, d as w, E as P, _ as S, A as v, f as A, w as _, F as N, b as q, e as x, P as I, q as F, g as R } from "./css-D6ZBcSwh.js";
const g = (r) => r != null && typeof r == "object" && !Array.isArray(r), $ = (r, s, o) => {
  let e = 0, n = r.length;
  const i = o ?? A(s);
  for (; e < n; ) {
    const t = Math.floor((e + n) / 2), l = i(r[t], s);
    if (l === 0) return t;
    l < 0 ? e = t + 1 : n = t;
  }
  return e;
}, G = (r, s, o) => {
  const e = $(r, s, o);
  r.splice(e, 0, s);
}, V = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  EQUAL: R,
  GREATER_THAN: F,
  LESS_THAN: I,
  insert: G,
  isEqualTo: x,
  isGreaterThan: q,
  isGreaterThanEqual: N,
  isLessThan: _,
  newF: A,
  newFieldF: v,
  order: S,
  primitiveArrays: P,
  reverseF: w,
  search: $,
  stringsWithNumbers: T,
  uniqueUnorderedPrimitiveArrays: m,
  unorderedPrimitiveArrays: O
}, Symbol.toStringTag, { value: "Module" })), p = ".", J = (r, s, o = ".") => {
  const e = r.split(o);
  return e.map((n, i) => {
    const t = s(n, i, e);
    return t == null ? null : typeof t == "string" ? t : t.join(o);
  }).filter((n) => n != null).join(o);
}, h = (r, s) => {
  if (!Array.isArray(r)) return r[s];
  const o = r[s];
  if (o != null || r.length == 0) return o;
  const e = r[0];
  if (typeof e == "object" && "key" in e)
    return r.find((n) => n.key === s);
}, L = (r, s) => {
  const o = r.split(".");
  return o.forEach((e, n) => {
    s = h(s, e), s != null && typeof s == "object" && "key" in s && (o[n] = s.key);
  }), o.join(".");
}, M = (r, s) => {
  const o = r.split(".");
  return s < 0 ? o[o.length + s] : o[s];
}, W = (r, s) => {
  if (s.length === 0) return !0;
  const o = r.split("."), e = s.split(".");
  if (e.length > o.length) return !1;
  for (let n = 0; n < e.length; n++) {
    const i = o[n], t = e[n];
    if (t !== "*" && i !== t)
      return !1;
  }
  return !0;
}, y = (r) => {
  const s = parseInt(r);
  return isNaN(s) || s < 0 || s.toString() !== r ? null : s;
}, d = (r, s) => {
  for (let o = 1; o <= s.length; o++) {
    const e = s.slice(0, o).join(".");
    if (h(r, e) != null) return [e, o];
  }
  return null;
}, k = ((r, s, o = { optional: !1 }) => {
  const { optional: e, getter: n = h } = o;
  if (s === "") return r;
  const i = s.split(".");
  if (i.length === 1) {
    const l = n(r, i[0]);
    if (l === void 0) {
      if (e) return null;
      throw new Error(`Path ${s} does not exist. ${i[0]} is undefined`);
    }
    return l;
  }
  const t = (l, f) => {
    if (f >= i.length) return l;
    for (let u = i.length - f; u >= 1; u--) {
      const a = i.slice(f, f + u).join("."), c = n(l, a);
      if (c !== void 0) {
        if (f + u === i.length) return c;
        if (c === null) {
          if (e) return null;
          throw new Error(`Path ${s} does not exist. ${a} is null`);
        }
        return t(c, f + u);
      }
    }
    if (e) return null;
    throw new Error(`Path ${s} does not exist. ${i[f]} is undefined`);
  };
  return t(r, 0);
}), z = (r, s) => k(r, s, { optional: !0 }) !== null, C = (r) => {
  try {
    return structuredClone(r);
  } catch {
    return console.warn(
      "Failed to deep copy object, falling back to JSON.parse(JSON.stringify)",
      r
    ), console.trace(), JSON.parse(JSON.stringify(r));
  }
}, H = (r, s, o = "") => {
  const e = {}, n = (i, t, l) => {
    if (typeof i != typeof t || i === null || t === null) {
      e[l] = [i, t];
      return;
    }
    if (typeof i == "object" && typeof t == "object")
      if (Array.isArray(i) && Array.isArray(t)) {
        if (i.length !== t.length) {
          e[l] = [i, t];
          return;
        }
        for (let f = 0; f < i.length; f++) n(i[f], t[f], `${l}[${f}]`);
      } else
        (/* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(t)])).forEach((f) => {
          n(
            i[f],
            t[f],
            l !== "" ? `${l}.${f}` : f
          );
        });
    else i !== t && (e[l] = [i, t]);
  };
  return n(r, s, o), e;
}, b = (r, s) => {
  const o = Array.isArray(r), e = Array.isArray(s);
  if (o !== e) return !1;
  if (o && e) {
    const t = r, l = s;
    if (t.length !== l.length) return !1;
    for (let f = 0; f < t.length; f++) if (!b(t[f], l[f])) return !1;
    return !0;
  }
  if (r == null || s == null || typeof r != "object" || typeof s != "object")
    return r === s;
  if ("equals" in r) return r.equals(s);
  const n = Object.keys(r), i = Object.keys(s);
  if (n.length !== i.length) return !1;
  for (const t of n) {
    const l = r[t], f = s[t];
    if (typeof l == "object" && typeof f == "object") {
      if (!b(l, f)) return !1;
    } else if (l !== f) return !1;
  }
  return !0;
}, E = (r, s) => {
  if (typeof r != "object" || r == null) return r === s;
  const o = Object.keys(r), e = Object.keys(s);
  if (e.length > o.length) return !1;
  for (const n of e) {
    const i = r[n], t = s[n];
    if (typeof i == "object" && typeof t == "object") {
      if (!E(i, t)) return !1;
    } else if (i !== t) return !1;
  }
  return !0;
}, j = (r, ...s) => {
  if (s.length === 0) return r;
  const o = s.shift();
  if (g(r) && g(o))
    for (const e in o)
      try {
        g(o[e]) ? (e in r || Object.assign(r, { [e]: {} }), j(r[e], o[e])) : Object.assign(r, { [e]: o[e] });
      } catch (n) {
        throw n instanceof TypeError ? new TypeError(`.${e}: ${n.message}`) : n;
      }
  return j(r, ...s);
}, U = (r, s, o) => {
  const e = (n, i, t) => {
    if (t.def?.type === "union")
      return t.def.options.reduce(
        (l, f) => e(l, i, f),
        n
      );
    if (t.def?.type === "intersection") {
      const l = e(n, i, t.def.left);
      return e(l, i, t.def.right);
    }
    for (const l in i) {
      const f = i[l];
      let u = t?.shape;
      if (u != null)
        for (; u != null; ) {
          if (u[l] != null) {
            const a = u[l].safeParse(f);
            if (a.success) {
              n[l] = a.data;
              break;
            }
          }
          u = u.def?.shape;
        }
      typeof f == "object" && !Array.isArray(f) && f !== null && t && t.shape && t.shape[l] && (n[l] ||= {}, e(n[l], f, t.shape[l]));
    }
    return n;
  };
  return e({ ...r }, s, o);
}, B = (r, s) => {
  const o = s.split(p);
  let e = r, n = 0;
  for (; n < o.length; ) {
    if (n === o.length - 1) {
      const t = o[n];
      if (Array.isArray(e)) {
        const l = parseInt(t);
        if (!isNaN(l) && l < e.length) {
          e.splice(l, 1);
          return;
        }
        const f = e[0];
        if (typeof f == "object" && "key" in f) {
          const u = e.findIndex((a) => a.key === t);
          if (u !== -1) {
            e.splice(u, 1);
            return;
          }
        }
        return;
      }
      delete e[t];
      return;
    }
    let i = !1;
    if (Array.isArray(e) && e.length > 0) {
      const t = e[0];
      if (typeof t == "object" && "key" in t)
        for (let l = o.length - n; l >= 1; l--) {
          const f = o.slice(n, n + l).join(p), u = e.find((a) => a.key === f);
          if (u != null) {
            if (n + l === o.length) {
              const a = e.findIndex((c) => c.key === f);
              a !== -1 && e.splice(a, 1);
              return;
            }
            e = u, n += l, i = !0;
            break;
          }
        }
    }
    if (!i)
      for (let t = o.length - n; t >= 1; t--) {
        const l = o.slice(n, n + t).join(p);
        if (!Array.isArray(e) && typeof e == "object" && e !== null && l in e) {
          if (n + t === o.length) {
            delete e[l];
            return;
          }
          e = e[l], n += t, i = !0;
          break;
        }
      }
    if (!i) {
      const t = h(e, o[n]);
      if (t == null) return;
      e = t, n++;
    }
  }
}, K = (r, s, o) => {
  const e = s.split(p);
  let n = r, i = 0;
  for (; i < e.length - 1; ) {
    const t = d(n, e.slice(i, e.length - 1));
    let l;
    t != null ? [l, i] = [t[0], i + t[1]] : (l = e[i], i++);
    let f = h(n, l);
    if (f == null) {
      const u = e[i];
      let a = y(u);
      a == null && u.startsWith("-") && y(u.substring(1)) != null && (a = 0), f = a != null ? [] : {}, n[l] = f;
    }
    n = f;
  }
  try {
    const t = e[e.length - 1];
    if (Array.isArray(n)) {
      let f = y(t);
      if (f == null) {
        if (t.startsWith("-")) {
          const u = y(t.substring(1));
          u != null && (f = n.length - u);
        }
        if (f == null) {
          if (n.length === 0) {
            const a = y(t);
            if (a != null) {
              n[a] = o;
              return;
            }
          }
          const u = n[0];
          if (typeof u == "object" && "key" in u) {
            const a = n.findIndex((c) => c.key === t);
            if (a !== -1) {
              n[a] = o;
              return;
            }
          }
          return;
        }
      }
      n[f] = o;
      return;
    }
    const l = d(n, [t]);
    if (l != null) {
      n[l[0]] = o;
      return;
    }
    n[t] = o;
  } catch (t) {
    throw console.error("failed to set value", o, "at path", s, "on object", r), t;
  }
}, D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  SEPARATOR: p,
  copy: C,
  defaultGetter: h,
  difference: H,
  element: M,
  equal: b,
  findBestKey: d,
  get: k,
  getIndex: y,
  has: z,
  override: j,
  overrideValidItems: U,
  partialEqual: E,
  pathsMatch: W,
  remove: B,
  resolvePath: L,
  set: K,
  transformPath: J
}, Symbol.toStringTag, { value: "Module" }));
export {
  D as T,
  J as g,
  k as h,
  V as q
};
