import { s as __toESM } from "./chunk-BNovOVIE.js";
import { t as require_react } from "./react-DA-nE2FX.js";
import { t as styled_default } from "./dist-usPCDYx8.js";
var import_react = /* @__PURE__ */ __toESM(require_react());
const NumberOverlayEditorStyle = /* @__PURE__ */ styled_default("div")({
  name: "NumberOverlayEditorStyle",
  class: "gdg-n15fjm3e",
  propsAsIs: false
});
function __rest(e, t) {
  var n = {};
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
  return n;
}
var SourceType;
(function(e) {
  e.event = "event", e.props = "prop";
})(SourceType || (SourceType = {}));
function noop() {
}
function memoizeOnce(e) {
  var t, n = void 0;
  return function() {
    for (var r = [], i = arguments.length; i--; ) r[i] = arguments[i];
    return t && r.length === t.length && r.every(function(e2, n2) {
      return e2 === t[n2];
    }) ? n : (t = r, n = e.apply(void 0, r), n);
  };
}
function charIsNumber(e) {
  return !!(e || "").match(/\d/);
}
function isNil(e) {
  return e == null;
}
function isNanValue(e) {
  return typeof e == "number" && isNaN(e);
}
function isNotValidValue(e) {
  return isNil(e) || isNanValue(e) || typeof e == "number" && !isFinite(e);
}
function escapeRegExp(e) {
  return e.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
}
function getThousandsGroupRegex(e) {
  switch (e) {
    case "lakh":
      return /(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/g;
    case "wan":
      return /(\d)(?=(\d{4})+(?!\d))/g;
    case "thousand":
    default:
      return /(\d)(?=(\d{3})+(?!\d))/g;
  }
}
function applyThousandSeparator(e, t, n) {
  var r = getThousandsGroupRegex(n), i = e.search(/[1-9]/);
  return i = i === -1 ? e.length : i, e.substring(0, i) + e.substring(i, e.length).replace(r, "$1" + t);
}
function usePersistentCallback(e) {
  var t = (0, import_react.useRef)(e);
  return t.current = e, (0, import_react.useRef)(function() {
    for (var e2 = [], n = arguments.length; n--; ) e2[n] = arguments[n];
    return t.current.apply(t, e2);
  }).current;
}
function splitDecimal(e, t) {
  t === void 0 && (t = true);
  var n = e[0] === "-", r = n && t;
  e = e.replace("-", "");
  var i = e.split(".");
  return {
    beforeDecimal: i[0],
    afterDecimal: i[1] || "",
    hasNegation: n,
    addNegation: r
  };
}
function fixLeadingZero(e) {
  if (!e) return e;
  var t = e[0] === "-";
  t && (e = e.substring(1, e.length));
  var n = e.split("."), r = n[0].replace(/^0+/, "") || "0", i = n[1] || "";
  return (t ? "-" : "") + r + (i ? "." + i : "");
}
function limitToScale(e, t, n) {
  for (var r = "", i = n ? "0" : "", a = 0; a <= t - 1; a++) r += e[a] || i;
  return r;
}
function repeat(e, t) {
  return Array(t + 1).join(e);
}
function toNumericString(e) {
  var t = e + "", n = t[0] === "-" ? "-" : "";
  n && (t = t.substring(1));
  var r = t.split(/[eE]/g), i = r[0], a = r[1];
  if (a = Number(a), !a) return n + i;
  i = i.replace(".", "");
  var o = 1 + a, s = i.length;
  return o < 0 ? i = "0." + repeat("0", Math.abs(o)) + i : o >= s ? i += repeat("0", o - s) : i = (i.substring(0, o) || "0") + "." + i.substring(o), n + i;
}
function roundToPrecision(e, t, n) {
  if (["", "-"].indexOf(e) !== -1) return e;
  var r = (e.indexOf(".") !== -1 || n) && t, i = splitDecimal(e), a = i.beforeDecimal, o = i.afterDecimal, s = i.hasNegation, c = parseFloat("0." + (o || "0")), l = (o.length <= t ? "0." + o : c.toFixed(t)).split("."), u = a;
  a && Number(l[0]) && (u = a.split("").reverse().reduce(function(e2, t2, n2) {
    return e2.length > n2 ? (Number(e2[0]) + Number(t2)).toString() + e2.substring(1, e2.length) : t2 + e2;
  }, l[0]));
  var d = limitToScale(l[1] || "", t, n), f = s ? "-" : "", p = r ? "." : "";
  return "" + f + u + p + d;
}
function setCaretPosition(e, t) {
  if (e.value = e.value, e !== null) {
    if (e.createTextRange) {
      var n = e.createTextRange();
      return n.move("character", t), n.select(), true;
    }
    return e.selectionStart || e.selectionStart === 0 ? (e.focus(), e.setSelectionRange(t, t), true) : (e.focus(), false);
  }
}
var findChangeRange = memoizeOnce(function(e, t) {
  for (var n = 0, r = 0, i = e.length, a = t.length; e[n] === t[n] && n < i; ) n++;
  for (; e[i - 1 - r] === t[a - 1 - r] && a - r > n && i - r > n; ) r++;
  return {
    from: {
      start: n,
      end: i - r
    },
    to: {
      start: n,
      end: a - r
    }
  };
}), findChangedRangeFromCaretPositions = function(e, t) {
  var n = Math.min(e.selectionStart, t);
  return {
    from: {
      start: n,
      end: e.selectionEnd
    },
    to: {
      start: n,
      end: t
    }
  };
};
function clamp(e, t, n) {
  return Math.min(Math.max(e, t), n);
}
function geInputCaretPosition(e) {
  return Math.max(e.selectionStart, e.selectionEnd);
}
function addInputMode() {
  return typeof navigator < "u" && !(navigator.platform && /iPhone|iPod/.test(navigator.platform));
}
function getDefaultChangeMeta(e) {
  return {
    from: {
      start: 0,
      end: 0
    },
    to: {
      start: 0,
      end: e.length
    },
    lastValue: ""
  };
}
function defaultIsCharacterSame(e) {
  var t = e.currentValue, n = e.formattedValue, r = e.currentValueIndex, i = e.formattedValueIndex;
  return t[r] === n[i];
}
function getCaretPosition(e, t, n, r, i, a, o) {
  o === void 0 && (o = defaultIsCharacterSame);
  var s = i.findIndex(function(e2) {
    return e2;
  }), c = e.slice(0, s);
  !t && !n.startsWith(c) && (t = c, n = c + n, r += c.length);
  for (var l = n.length, u = e.length, d = {}, f = Array(l), p = 0; p < l; p++) {
    f[p] = -1;
    for (var m = 0, h = u; m < h; m++) if (o({
      currentValue: n,
      lastValue: t,
      formattedValue: e,
      currentValueIndex: p,
      formattedValueIndex: m
    }) && d[m] !== true) {
      f[p] = m, d[m] = true;
      break;
    }
  }
  for (var g = r; g < l && (f[g] === -1 || !a(n[g])); ) g++;
  var _ = g === l || f[g] === -1 ? u : f[g];
  for (g = r - 1; g > 0 && f[g] === -1; ) g--;
  var v = g === -1 || f[g] === -1 ? 0 : f[g] + 1;
  return v > _ ? _ : r - v < _ - r ? v : _;
}
function getCaretPosInBoundary(e, t, n, r) {
  var i = e.length;
  if (t = clamp(t, 0, i), r === "left") {
    for (; t >= 0 && !n[t]; ) t--;
    t === -1 && (t = n.indexOf(true));
  } else {
    for (; t <= i && !n[t]; ) t++;
    t > i && (t = n.lastIndexOf(true));
  }
  return t === -1 && (t = i), t;
}
function caretUnknownFormatBoundary(e) {
  for (var t = Array.from({ length: e.length + 1 }).map(function() {
    return true;
  }), n = 0, r = t.length; n < r; n++) t[n] = !!(charIsNumber(e[n]) || charIsNumber(e[n - 1]));
  return t;
}
function useInternalValues(e, t, n, i, a, o) {
  o === void 0 && (o = noop);
  var c = usePersistentCallback(function(e2, t2) {
    var n2, r;
    return isNotValidValue(e2) ? (r = "", n2 = "") : typeof e2 == "number" || t2 ? (r = typeof e2 == "number" ? toNumericString(e2) : e2, n2 = i(r)) : (r = a(e2, void 0), n2 = i(r)), {
      formattedValue: n2,
      numAsString: r
    };
  }), l = (0, import_react.useState)(function() {
    return c(isNil(e) ? t : e, n);
  }), d = l[0], p = l[1], m = function(e2, t2) {
    e2.formattedValue !== d.formattedValue && p({
      formattedValue: e2.formattedValue,
      numAsString: e2.value
    }), o(e2, t2);
  }, h = e, _ = n;
  isNil(e) && (h = d.numAsString, _ = true);
  var v = c(h, _);
  return (0, import_react.useMemo)(function() {
    p(v);
  }, [v.formattedValue]), [d, m];
}
function defaultRemoveFormatting(e) {
  return e.replace(/[^0-9]/g, "");
}
function defaultFormat(e) {
  return e;
}
function NumberFormatBase(e) {
  var t = e.type;
  t === void 0 && (t = "text");
  var n = e.displayType;
  n === void 0 && (n = "input");
  var i = e.customInput, c = e.renderText, u = e.getInputRef, d = e.format;
  d === void 0 && (d = defaultFormat);
  var f = e.removeFormatting;
  f === void 0 && (f = defaultRemoveFormatting);
  var p = e.defaultValue, m = e.valueIsNumericString, h = e.onValueChange, g = e.isAllowed, _ = e.onChange;
  _ === void 0 && (_ = noop);
  var v = e.onKeyDown;
  v === void 0 && (v = noop);
  var y = e.onMouseUp;
  y === void 0 && (y = noop);
  var b = e.onFocus;
  b === void 0 && (b = noop);
  var x = e.onBlur;
  x === void 0 && (x = noop);
  var S = e.value, E = e.getCaretBoundary;
  E === void 0 && (E = caretUnknownFormatBoundary);
  var k = e.isValidInputCharacter;
  k === void 0 && (k = charIsNumber);
  var A = e.isCharacterSame, I = __rest(e, [
    "type",
    "displayType",
    "customInput",
    "renderText",
    "getInputRef",
    "format",
    "removeFormatting",
    "defaultValue",
    "valueIsNumericString",
    "onValueChange",
    "isAllowed",
    "onChange",
    "onKeyDown",
    "onMouseUp",
    "onFocus",
    "onBlur",
    "value",
    "getCaretBoundary",
    "isValidInputCharacter",
    "isCharacterSame"
  ]), L = useInternalValues(S, p, !!m, d, f, h), R = L[0], z = R.formattedValue, B = R.numAsString, V = L[1], H = (0, import_react.useRef)(), U = (0, import_react.useRef)({
    formattedValue: z,
    numAsString: B
  }), W = function(e2, t2) {
    U.current = {
      formattedValue: e2.formattedValue,
      numAsString: e2.value
    }, V(e2, t2);
  }, G = (0, import_react.useState)(false), te = G[0], ne = G[1], K = (0, import_react.useRef)(null), q = (0, import_react.useRef)({
    setCaretTimeout: null,
    focusTimeout: null
  });
  (0, import_react.useEffect)(function() {
    return ne(true), function() {
      clearTimeout(q.current.setCaretTimeout), clearTimeout(q.current.focusTimeout);
    };
  }, []);
  var re = d, J = function(e2, t2) {
    var n2 = parseFloat(t2);
    return {
      formattedValue: e2,
      value: t2,
      floatValue: isNaN(n2) ? void 0 : n2
    };
  }, Y = function(e2, t2, n2) {
    e2.selectionStart === 0 && e2.selectionEnd === e2.value.length || (setCaretPosition(e2, t2), q.current.setCaretTimeout = setTimeout(function() {
      e2.value === n2 && e2.selectionStart !== t2 && setCaretPosition(e2, t2);
    }, 0));
  }, X = function(e2, t2, n2) {
    return getCaretPosInBoundary(e2, t2, E(e2), n2);
  }, Z = function(e2, t2, n2) {
    var r = E(t2), i2 = getCaretPosition(t2, z, e2, n2, r, k, A);
    return i2 = getCaretPosInBoundary(t2, i2, r), i2;
  }, ie = function(e2) {
    var t2 = e2.formattedValue;
    t2 === void 0 && (t2 = "");
    var n2 = e2.input, r = e2.source, i2 = e2.event, a = e2.numAsString, o;
    if (n2) {
      var s = e2.inputValue || n2.value, c2 = geInputCaretPosition(n2);
      n2.value = t2, o = Z(s, t2, c2), o !== void 0 && Y(n2, o, t2);
    }
    t2 !== z && W(J(t2, a), {
      event: i2,
      source: r
    });
  };
  (0, import_react.useEffect)(function() {
    var e2 = U.current, t2 = e2.formattedValue, n2 = e2.numAsString;
    (z !== t2 || B !== n2) && W(J(z, B), {
      event: void 0,
      source: SourceType.props
    });
  }, [z, B]);
  var ae = K.current ? geInputCaretPosition(K.current) : void 0;
  (typeof window < "u" ? import_react.useLayoutEffect : import_react.useEffect)(function() {
    var e2 = K.current;
    if (z !== U.current.formattedValue && e2) {
      var t2 = Z(U.current.formattedValue, z, ae);
      e2.value = z, Y(e2, t2, z);
    }
  }, [z]);
  var oe = function(e2, t2, n2) {
    var r = t2.target, i2 = H.current ? findChangedRangeFromCaretPositions(H.current, r.selectionEnd) : findChangeRange(z, e2), a = Object.assign(Object.assign({}, i2), { lastValue: z }), o = f(e2, a), s = re(o);
    if (o = f(s, void 0), g && !g(J(s, o))) {
      var c2 = t2.target, l = Z(e2, z, geInputCaretPosition(c2));
      return c2.value = z, Y(c2, l, z), false;
    }
    return ie({
      formattedValue: s,
      numAsString: o,
      inputValue: e2,
      event: t2,
      source: n2,
      input: t2.target
    }), true;
  }, Q = function(e2, t2) {
    t2 === void 0 && (t2 = 0), H.current = {
      selectionStart: e2.selectionStart,
      selectionEnd: e2.selectionEnd + t2
    };
  }, se = function(e2) {
    var t2 = e2.target.value;
    oe(t2, e2, SourceType.event) && _(e2), H.current = void 0;
  }, ce = function(e2) {
    var t2 = e2.target, n2 = e2.key, r = t2.selectionStart, i2 = t2.selectionEnd, a = t2.value;
    a === void 0 && (a = "");
    var o;
    n2 === "ArrowLeft" || n2 === "Backspace" ? o = Math.max(r - 1, 0) : n2 === "ArrowRight" ? o = Math.min(r + 1, a.length) : n2 === "Delete" && (o = r);
    var s = 0;
    n2 === "Delete" && r === i2 && (s = 1);
    var c2 = n2 === "ArrowLeft" || n2 === "ArrowRight";
    if (o === void 0 || r !== i2 && !c2) {
      v(e2), Q(t2, s);
      return;
    }
    var l = o;
    c2 ? (l = X(a, o, n2 === "ArrowLeft" ? "left" : "right"), l !== o && e2.preventDefault()) : n2 === "Delete" && !k(a[o]) ? l = X(a, o, "right") : n2 === "Backspace" && !k(a[o]) && (l = X(a, o, "left")), l !== o && Y(t2, l, a), v(e2), Q(t2, s);
  }, le = function(e2) {
    var t2 = e2.target, n2 = function() {
      var e3 = t2.selectionStart, n3 = t2.selectionEnd, r = t2.value;
      if (r === void 0 && (r = ""), e3 === n3) {
        var i2 = X(r, e3);
        i2 !== e3 && Y(t2, i2, r);
      }
    };
    n2(), requestAnimationFrame(function() {
      n2();
    }), y(e2), Q(t2);
  }, ue = function(e2) {
    e2.persist && e2.persist();
    var t2 = e2.target, n2 = e2.currentTarget;
    K.current = t2, q.current.focusTimeout = setTimeout(function() {
      var r = t2.selectionStart, i2 = t2.selectionEnd, a = t2.value;
      a === void 0 && (a = "");
      var o = X(a, r);
      o !== r && !(r === 0 && i2 === a.length) && Y(t2, o, a), b(Object.assign(Object.assign({}, e2), { currentTarget: n2 }));
    }, 0);
  }, de = function(e2) {
    K.current = null, clearTimeout(q.current.focusTimeout), clearTimeout(q.current.setCaretTimeout), x(e2);
  }, fe = te && addInputMode() ? "numeric" : void 0, $ = Object.assign({ inputMode: fe }, I, {
    type: t,
    value: z,
    onChange: se,
    onKeyDown: ce,
    onMouseUp: le,
    onFocus: ue,
    onBlur: de
  });
  if (n === "text") return c ? import_react.createElement(import_react.Fragment, null, c(z, I) || null) : import_react.createElement("span", Object.assign({}, I, { ref: u }), z);
  if (i) {
    var pe = i;
    return import_react.createElement(pe, Object.assign({}, $, { ref: u }));
  }
  return import_react.createElement("input", Object.assign({}, $, { ref: u }));
}
function format(e, t) {
  var n = t.decimalScale, r = t.fixedDecimalScale, i = t.prefix;
  i === void 0 && (i = "");
  var a = t.suffix;
  a === void 0 && (a = "");
  var o = t.allowNegative, s = t.thousandsGroupStyle;
  if (s === void 0 && (s = "thousand"), e === "" || e === "-") return e;
  var c = getSeparators(t), l = c.thousandSeparator, u = c.decimalSeparator, d = n !== 0 && e.indexOf(".") !== -1 || n && r, f = splitDecimal(e, o), p = f.beforeDecimal, m = f.afterDecimal, g = f.addNegation;
  return n !== void 0 && (m = limitToScale(m, n, !!r)), l && (p = applyThousandSeparator(p, l, s)), i && (p = i + p), a && (m += a), g && (p = "-" + p), e = p + (d && u || "") + m, e;
}
function getSeparators(e) {
  var t = e.decimalSeparator;
  t === void 0 && (t = ".");
  var n = e.thousandSeparator, r = e.allowedDecimalSeparators;
  return n === true && (n = ","), r || (r = [t, "."]), {
    decimalSeparator: t,
    thousandSeparator: n,
    allowedDecimalSeparators: r
  };
}
function handleNegation(e, t) {
  e === void 0 && (e = "");
  var n = /* @__PURE__ */ RegExp("(-)"), r = /* @__PURE__ */ RegExp("(-)(.)*(-)"), i = n.test(e), a = r.test(e);
  return e = e.replace(/-/g, ""), i && !a && t && (e = "-" + e), e;
}
function getNumberRegex(e, t) {
  return RegExp("(^-)|[0-9]|" + escapeRegExp(e), t ? "g" : void 0);
}
function isNumericString(e, t, n) {
  return e === "" ? true : !(t == null ? void 0 : t.match(/\d/)) && !(n == null ? void 0 : n.match(/\d/)) && typeof e == "string" && !isNaN(Number(e));
}
function removeFormatting(e, t, n) {
  var r;
  t === void 0 && (t = getDefaultChangeMeta(e));
  var i = n.allowNegative, a = n.prefix;
  a === void 0 && (a = "");
  var o = n.suffix;
  o === void 0 && (o = "");
  var s = n.decimalScale, c = t.from, u = t.to, d = u.start, f = u.end, m = getSeparators(n), h = m.allowedDecimalSeparators, g = m.decimalSeparator, v = e[f] === g;
  if (charIsNumber(e) && (e === a || e === o) && t.lastValue === "") return e;
  if (f - d === 1 && h.indexOf(e[d]) !== -1) {
    var y = s === 0 ? "" : g;
    e = e.substring(0, d) + y + e.substring(d + 1, e.length);
  }
  var b = function(e2, t2, n2) {
    var r2 = false, i2 = false;
    a.startsWith("-") ? r2 = false : e2.startsWith("--") ? (r2 = false, i2 = true) : o.startsWith("-") && e2.length === o.length ? r2 = false : e2[0] === "-" && (r2 = true);
    var s2 = r2 ? 1 : 0;
    return i2 && (s2 = 2), s2 && (e2 = e2.substring(s2), t2 -= s2, n2 -= s2), {
      value: e2,
      start: t2,
      end: n2,
      hasNegation: r2
    };
  }, x = b(e, d, f), S = x.hasNegation;
  r = x, e = r.value, d = r.start, f = r.end;
  var C = b(t.lastValue, c.start, c.end), w = C.start, T = C.end, E = C.value, D = e.substring(d, f);
  e.length && E.length && (w > E.length - o.length || T < a.length) && !(D && o.startsWith(D)) && (e = E);
  var O = 0;
  e.startsWith(a) ? O += a.length : d < a.length && (O = d), e = e.substring(O), f -= O;
  var A = e.length, j = e.length - o.length;
  e.endsWith(o) ? A = j : (f > j || f > e.length - o.length) && (A = f), e = e.substring(0, A), e = handleNegation(S ? "-" + e : e, i), e = (e.match(getNumberRegex(g, true)) || []).join("");
  var M = e.indexOf(g);
  e = e.replace(new RegExp(escapeRegExp(g), "g"), function(e2, t2) {
    return t2 === M ? "." : "";
  });
  var N = splitDecimal(e, i), ee = N.beforeDecimal, P = N.afterDecimal, F = N.addNegation;
  return u.end - u.start < c.end - c.start && ee === "" && v && !parseFloat(P) && (e = F ? "-" : ""), e;
}
function getCaretBoundary(e, t) {
  var n = t.prefix;
  n === void 0 && (n = "");
  var r = t.suffix;
  r === void 0 && (r = "");
  var i = Array.from({ length: e.length + 1 }).map(function() {
    return true;
  }), a = e[0] === "-";
  i.fill(false, 0, n.length + (a ? 1 : 0));
  var o = e.length;
  return i.fill(false, o - r.length + 1, o + 1), i;
}
function validateAndUpdateProps(e) {
  var t = getSeparators(e), n = t.thousandSeparator, r = t.decimalSeparator, i = e.prefix;
  i === void 0 && (i = "");
  var a = e.allowNegative;
  if (a === void 0 && (a = true), n === r) throw Error("\n        Decimal separator can't be same as thousand separator.\n        thousandSeparator: " + n + ' (thousandSeparator = {true} is same as thousandSeparator = ",")\n        decimalSeparator: ' + r + " (default value for decimalSeparator is .)\n     ");
  return i.startsWith("-") && a && (console.error("\n      Prefix can't start with '-' when allowNegative is true.\n      prefix: " + i + "\n      allowNegative: " + a + "\n    "), a = false), Object.assign(Object.assign({}, e), { allowNegative: a });
}
function useNumericFormat(e) {
  e = validateAndUpdateProps(e), e.decimalSeparator, e.allowedDecimalSeparators, e.thousandsGroupStyle;
  var t = e.suffix, n = e.allowNegative, r = e.allowLeadingZeros, i = e.onKeyDown;
  i === void 0 && (i = noop);
  var c = e.onBlur;
  c === void 0 && (c = noop);
  var d = e.thousandSeparator, p = e.decimalScale, m = e.fixedDecimalScale, h = e.prefix;
  h === void 0 && (h = "");
  var g = e.defaultValue, _ = e.value, y = e.valueIsNumericString, b = e.onValueChange, T = __rest(e, [
    "decimalSeparator",
    "allowedDecimalSeparators",
    "thousandsGroupStyle",
    "suffix",
    "allowNegative",
    "allowLeadingZeros",
    "onKeyDown",
    "onBlur",
    "thousandSeparator",
    "decimalScale",
    "fixedDecimalScale",
    "prefix",
    "defaultValue",
    "value",
    "valueIsNumericString",
    "onValueChange"
  ]), E = getSeparators(e), D = E.decimalSeparator, O = E.allowedDecimalSeparators, k = function(t2) {
    return format(t2, e);
  }, A = function(t2, n2) {
    return removeFormatting(t2, n2, e);
  }, j = isNil(_) ? g : _, M = y ?? isNumericString(j, h, t);
  isNil(_) ? isNil(g) || (M || (M = typeof g == "number")) : M || (M = typeof _ == "number");
  var N = function(e2) {
    return isNotValidValue(e2) ? e2 : (typeof e2 == "number" && (e2 = toNumericString(e2)), M && typeof p == "number" ? roundToPrecision(e2, p, !!m) : e2);
  }, P = useInternalValues(N(_), N(g), !!M, k, A, b), F = P[0], I = F.numAsString, z = F.formattedValue, B = P[1];
  return Object.assign(Object.assign({}, T), {
    value: z,
    valueIsNumericString: false,
    isValidInputCharacter: function(e2) {
      return e2 === D ? true : charIsNumber(e2);
    },
    isCharacterSame: function(e2) {
      var t2 = e2.currentValue, n2 = e2.lastValue, r2 = e2.formattedValue, i2 = e2.currentValueIndex, a = e2.formattedValueIndex, o = t2[i2], s = r2[a], c2 = findChangeRange(n2, t2).to, l = function(e3) {
        return A(e3).indexOf(".") + h.length;
      };
      return _ === 0 && m && p && t2[c2.start] === D && l(t2) < i2 && l(r2) > a ? false : i2 >= c2.start && i2 < c2.end && O && O.includes(o) && s === D ? true : o === s;
    },
    onValueChange: B,
    format: k,
    removeFormatting: A,
    getCaretBoundary: function(t2) {
      return getCaretBoundary(t2, e);
    },
    onKeyDown: function(e2) {
      var t2 = e2.target, r2 = e2.key, a = t2.selectionStart, o = t2.selectionEnd, s = t2.value;
      if (s === void 0 && (s = ""), (r2 === "Backspace" || r2 === "Delete") && o < h.length) {
        e2.preventDefault();
        return;
      }
      if (a !== o) {
        i(e2);
        return;
      }
      r2 === "Backspace" && s[0] === "-" && a === h.length + 1 && n && setCaretPosition(t2, 1), p && m && (r2 === "Backspace" && s[a - 1] === D ? (setCaretPosition(t2, a - 1), e2.preventDefault()) : r2 === "Delete" && s[a] === D && e2.preventDefault()), (O == null ? void 0 : O.includes(r2)) && s[a] === D && setCaretPosition(t2, a + 1);
      var c2 = d === true ? "," : d;
      r2 === "Backspace" && s[a - 1] === c2 && setCaretPosition(t2, a - 1), r2 === "Delete" && s[a] === c2 && setCaretPosition(t2, a + 1), i(e2);
    },
    onBlur: function(t2) {
      var n2 = I;
      n2.match(/\d/g) || (n2 = ""), r || (n2 = fixLeadingZero(n2)), m && p && (n2 = roundToPrecision(n2, p, m)), n2 !== I && B({
        formattedValue: format(n2, e),
        value: n2,
        floatValue: parseFloat(n2)
      }, {
        event: t2,
        source: SourceType.event
      }), c(t2);
    }
  });
}
function NumericFormat(e) {
  var t = useNumericFormat(e);
  return import_react.createElement(NumberFormatBase, Object.assign({}, t));
}
function getDecimalSeparator() {
  var _a, _b, _c;
  return ((_c = (_b = (_a = Intl.NumberFormat()) == null ? void 0 : _a.formatToParts(1.1)) == null ? void 0 : _b.find((e) => e.type === "decimal")) == null ? void 0 : _c.value) ?? ".";
}
function getThousandSeprator() {
  return getDecimalSeparator() === "." ? "," : ".";
}
var number_overlay_editor_default = (e) => {
  let { value: t, onChange: n, disabled: a, highlight: o, validatedSelection: s, fixedDecimals: c, allowNegative: l, thousandSeparator: u, decimalSeparator: d } = e, f = import_react.useRef();
  return import_react.useLayoutEffect(() => {
    var _a;
    if (s !== void 0) {
      let e2 = typeof s == "number" ? [s, null] : s;
      (_a = f.current) == null ? void 0 : _a.setSelectionRange(e2[0], e2[1]);
    }
  }, [s]), import_react.createElement(NumberOverlayEditorStyle, null, import_react.createElement(NumericFormat, {
    autoFocus: true,
    getInputRef: f,
    className: "gdg-input",
    onFocus: (e2) => e2.target.setSelectionRange(o ? 0 : e2.target.value.length, e2.target.value.length),
    disabled: a === true,
    decimalScale: c,
    allowNegative: l,
    thousandSeparator: u ?? getThousandSeprator(),
    decimalSeparator: d ?? getDecimalSeparator(),
    value: Object.is(t, -0) ? "-" : t ?? "",
    onValueChange: n
  }));
};
export {
  number_overlay_editor_default as default
};
