import { useEffect as G, useRef as L } from "react";
const d = (r) => r != null && typeof r == "object" && Number.isFinite(r.lat) && Number.isFinite(r.lng);
var M = Object.getOwnPropertyNames, B = Object.getOwnPropertySymbols, D = Object.prototype.hasOwnProperty;
function A(r, e) {
  return function(a, n, u) {
    return r(a, n, u) && e(a, n, u);
  };
}
function m(r) {
  return function(t, a, n) {
    if (!t || !a || typeof t != "object" || typeof a != "object")
      return r(t, a, n);
    var u = n.cache, c = u.get(t), l = u.get(a);
    if (c && l)
      return c === a && l === t;
    u.set(t, a), u.set(a, t);
    var f = r(t, a, n);
    return u.delete(t), u.delete(a), f;
  };
}
function j(r) {
  return M(r).concat(B(r));
}
var $ = Object.hasOwn || function(r, e) {
  return D.call(r, e);
};
function y(r, e) {
  return r || e ? r === e : r === e || r !== r && e !== e;
}
var P = "_owner", w = Object.getOwnPropertyDescriptor, C = Object.keys;
function N(r, e, t) {
  var a = r.length;
  if (e.length !== a)
    return !1;
  for (; a-- > 0; )
    if (!t.equals(r[a], e[a], a, a, r, e, t))
      return !1;
  return !0;
}
function k(r, e) {
  return y(r.getTime(), e.getTime());
}
function S(r, e, t) {
  if (r.size !== e.size)
    return !1;
  for (var a = {}, n = r.entries(), u = 0, c, l; (c = n.next()) && !c.done; ) {
    for (var f = e.entries(), p = !1, i = 0; (l = f.next()) && !l.done; ) {
      var o = c.value, s = o[0], E = o[1], v = l.value, O = v[0], x = v[1];
      !p && !a[i] && (p = t.equals(s, O, u, i, r, e, t) && t.equals(E, x, s, O, r, e, t)) && (a[i] = !0), i++;
    }
    if (!p)
      return !1;
    u++;
  }
  return !0;
}
function I(r, e, t) {
  var a = C(r), n = a.length;
  if (C(e).length !== n)
    return !1;
  for (var u; n-- > 0; )
    if (u = a[n], u === P && (r.$$typeof || e.$$typeof) && r.$$typeof !== e.$$typeof || !$(e, u) || !t.equals(r[u], e[u], u, u, r, e, t))
      return !1;
  return !0;
}
function g(r, e, t) {
  var a = j(r), n = a.length;
  if (j(e).length !== n)
    return !1;
  for (var u, c, l; n-- > 0; )
    if (u = a[n], u === P && (r.$$typeof || e.$$typeof) && r.$$typeof !== e.$$typeof || !$(e, u) || !t.equals(r[u], e[u], u, u, r, e, t) || (c = w(r, u), l = w(e, u), (c || l) && (!c || !l || c.configurable !== l.configurable || c.enumerable !== l.enumerable || c.writable !== l.writable)))
      return !1;
  return !0;
}
function W(r, e) {
  return y(r.valueOf(), e.valueOf());
}
function z(r, e) {
  return r.source === e.source && r.flags === e.flags;
}
function T(r, e, t) {
  if (r.size !== e.size)
    return !1;
  for (var a = {}, n = r.values(), u, c; (u = n.next()) && !u.done; ) {
    for (var l = e.values(), f = !1, p = 0; (c = l.next()) && !c.done; )
      !f && !a[p] && (f = t.equals(u.value, c.value, u.value, c.value, r, e, t)) && (a[p] = !0), p++;
    if (!f)
      return !1;
  }
  return !0;
}
function F(r, e) {
  var t = r.length;
  if (e.length !== t)
    return !1;
  for (; t-- > 0; )
    if (r[t] !== e[t])
      return !1;
  return !0;
}
var _ = "[object Arguments]", V = "[object Boolean]", U = "[object Date]", J = "[object Map]", X = "[object Number]", Z = "[object Object]", H = "[object RegExp]", K = "[object Set]", Q = "[object String]", Y = Array.isArray, h = typeof ArrayBuffer == "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null, R = Object.assign, b = Object.prototype.toString.call.bind(Object.prototype.toString);
function rr(r) {
  var e = r.areArraysEqual, t = r.areDatesEqual, a = r.areMapsEqual, n = r.areObjectsEqual, u = r.arePrimitiveWrappersEqual, c = r.areRegExpsEqual, l = r.areSetsEqual, f = r.areTypedArraysEqual;
  return function(i, o, s) {
    if (i === o)
      return !0;
    if (i == null || o == null || typeof i != "object" || typeof o != "object")
      return i !== i && o !== o;
    var E = i.constructor;
    if (E !== o.constructor)
      return !1;
    if (E === Object)
      return n(i, o, s);
    if (Y(i))
      return e(i, o, s);
    if (h != null && h(i))
      return f(i, o, s);
    if (E === Date)
      return t(i, o, s);
    if (E === RegExp)
      return c(i, o, s);
    if (E === Map)
      return a(i, o, s);
    if (E === Set)
      return l(i, o, s);
    var v = b(i);
    return v === U ? t(i, o, s) : v === H ? c(i, o, s) : v === J ? a(i, o, s) : v === K ? l(i, o, s) : v === Z ? typeof i.then != "function" && typeof o.then != "function" && n(i, o, s) : v === _ ? n(i, o, s) : v === V || v === X || v === Q ? u(i, o, s) : !1;
  };
}
function er(r) {
  var e = r.circular, t = r.createCustomConfig, a = r.strict, n = {
    areArraysEqual: a ? g : N,
    areDatesEqual: k,
    areMapsEqual: a ? A(S, g) : S,
    areObjectsEqual: a ? g : I,
    arePrimitiveWrappersEqual: W,
    areRegExpsEqual: z,
    areSetsEqual: a ? A(T, g) : T,
    areTypedArraysEqual: a ? g : F
  };
  if (t && (n = R({}, n, t(n))), e) {
    var u = m(n.areArraysEqual), c = m(n.areMapsEqual), l = m(n.areObjectsEqual), f = m(n.areSetsEqual);
    n = R({}, n, {
      areArraysEqual: u,
      areMapsEqual: c,
      areObjectsEqual: l,
      areSetsEqual: f
    });
  }
  return n;
}
function tr(r) {
  return function(e, t, a, n, u, c, l) {
    return r(e, t, l);
  };
}
function ar(r) {
  var e = r.circular, t = r.comparator, a = r.createState, n = r.equals, u = r.strict;
  if (a)
    return function(f, p) {
      var i = a(), o = i.cache, s = o === void 0 ? e ? /* @__PURE__ */ new WeakMap() : void 0 : o, E = i.meta;
      return t(f, p, {
        cache: s,
        equals: n,
        meta: E,
        strict: u
      });
    };
  if (e)
    return function(f, p) {
      return t(f, p, {
        cache: /* @__PURE__ */ new WeakMap(),
        equals: n,
        meta: void 0,
        strict: u
      });
    };
  var c = {
    cache: void 0,
    equals: n,
    meta: void 0,
    strict: u
  };
  return function(f, p) {
    return t(f, p, c);
  };
}
q();
q({ strict: !0 });
q({ circular: !0 });
q({
  circular: !0,
  strict: !0
});
q({
  createInternalComparator: function() {
    return y;
  }
});
q({
  strict: !0,
  createInternalComparator: function() {
    return y;
  }
});
q({
  circular: !0,
  createInternalComparator: function() {
    return y;
  }
});
q({
  circular: !0,
  createInternalComparator: function() {
    return y;
  },
  strict: !0
});
function q(r) {
  r === void 0 && (r = {});
  var e = r.circular, t = e === void 0 ? !1 : e, a = r.createInternalComparator, n = r.createState, u = r.strict, c = u === void 0 ? !1 : u, l = er(r), f = rr(l), p = a ? a(f) : tr(f);
  return ar({ circular: t, comparator: f, createState: n, equals: p, strict: c });
}
const ur = q(
  //@ts-ignore
  (r) => (e, t) => d(e) || e instanceof google.maps.LatLng || d(t) || t instanceof google.maps.LatLng ? new google.maps.LatLng(e).equals(new google.maps.LatLng(t)) : r(e, t)
);
function nr(r) {
  const e = L();
  return ur(r, e.current) || (e.current = r), e.current;
}
function cr(r, e) {
  G(r, e.map(nr));
}
export {
  cr as useDeepCompareEffectForMaps
};
