@rpcbase/ui 0.260.0 → 0.262.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/sha256.worker-BEf4_Y9w.js.map +1 -0
- package/dist/components/FilesUploadField/index.d.ts +19 -6
- package/dist/components/FilesUploadField/index.d.ts.map +1 -1
- package/dist/components/FilesUploadField/sha256.d.ts +5 -0
- package/dist/components/FilesUploadField/sha256.d.ts.map +1 -0
- package/dist/components/FilesUploadField/sha256.worker.d.ts +4 -0
- package/dist/components/FilesUploadField/sha256.worker.d.ts.map +1 -0
- package/dist/components/ImagesField/index.d.ts +4 -2
- package/dist/components/ImagesField/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index298.js +11 -803
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +865 -28
- package/dist/index299.js.map +1 -1
- package/dist/index300.js +26 -510
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +481 -755
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +786 -7428
- package/dist/index302.js.map +1 -1
- package/dist/index303.js +7429 -7
- package/dist/index303.js.map +1 -1
- package/dist/index304.js +6 -12
- package/dist/index304.js.map +1 -1
- package/dist/index305.js +12 -5
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +3 -3
- package/dist/index306.js.map +1 -1
- package/dist/index307.js +5 -469
- package/dist/index307.js.map +1 -1
- package/dist/index308.js +464 -32
- package/dist/index308.js.map +1 -1
- package/dist/index309.js +36 -18
- package/dist/index309.js.map +1 -1
- package/dist/index310.js +17 -28
- package/dist/index310.js.map +1 -1
- package/dist/index311.js +30 -4
- package/dist/index311.js.map +1 -1
- package/dist/index312.js +4 -59
- package/dist/index312.js.map +1 -1
- package/dist/index313.js +59 -9
- package/dist/index313.js.map +1 -1
- package/dist/index314.js +9 -5
- package/dist/index314.js.map +1 -1
- package/dist/index315.js +5 -9
- package/dist/index315.js.map +1 -1
- package/dist/index316.js +9 -12
- package/dist/index316.js.map +1 -1
- package/dist/index317.js +13 -3
- package/dist/index317.js.map +1 -1
- package/dist/index318.js +3 -17
- package/dist/index318.js.map +1 -1
- package/dist/index319.js +14 -23
- package/dist/index319.js.map +1 -1
- package/dist/index320.js +23 -39
- package/dist/index320.js.map +1 -1
- package/dist/index321.js +41 -5
- package/dist/index321.js.map +1 -1
- package/dist/index322.js +5 -25
- package/dist/index322.js.map +1 -1
- package/dist/index323.js +24 -18
- package/dist/index323.js.map +1 -1
- package/dist/index324.js +17 -32
- package/dist/index324.js.map +1 -1
- package/dist/index325.js +34 -5
- package/dist/index325.js.map +1 -1
- package/dist/index326.js +5 -9
- package/dist/index326.js.map +1 -1
- package/dist/index327.js +8 -7
- package/dist/index327.js.map +1 -1
- package/dist/index328.js +8 -9
- package/dist/index328.js.map +1 -1
- package/dist/index329.js +9 -10
- package/dist/index329.js.map +1 -1
- package/dist/index330.js +10 -7
- package/dist/index330.js.map +1 -1
- package/dist/index331.js +7 -75
- package/dist/index331.js.map +1 -1
- package/dist/index332.js +66 -153
- package/dist/index332.js.map +1 -1
- package/dist/index333.js +147 -99
- package/dist/index333.js.map +1 -1
- package/dist/index334.js +113 -13
- package/dist/index334.js.map +1 -1
- package/dist/index335.js +12 -78
- package/dist/index335.js.map +1 -1
- package/dist/index336.js +57 -23
- package/dist/index336.js.map +1 -1
- package/dist/index337.js +45 -12
- package/dist/index337.js.map +1 -1
- package/dist/index338.js +13 -16
- package/dist/index338.js.map +1 -1
- package/dist/index339.js +15 -100
- package/dist/index339.js.map +1 -1
- package/dist/index340.js +95 -50
- package/dist/index340.js.map +1 -1
- package/dist/index341.js +5 -57
- package/dist/index341.js.map +1 -1
- package/dist/index342.js +78 -41
- package/dist/index342.js.map +1 -1
- package/dist/index343.js +58 -100
- package/dist/index343.js.map +1 -1
- package/dist/index344.js +104 -46
- package/dist/index344.js.map +1 -1
- package/dist/index345.js +51 -39
- package/dist/index345.js.map +1 -1
- package/dist/index346.js +42 -142
- package/dist/index346.js.map +1 -1
- package/dist/index347.js +123 -120
- package/dist/index347.js.map +1 -1
- package/dist/index348.js +108 -224
- package/dist/index348.js.map +1 -1
- package/dist/index349.js +174 -158
- package/dist/index349.js.map +1 -1
- package/dist/index350.js +144 -213
- package/dist/index350.js.map +1 -1
- package/dist/index351.js +309 -5
- package/dist/index351.js.map +1 -1
- package/dist/index352.js +5 -6
- package/dist/index352.js.map +1 -1
- package/dist/index353.js +6 -7
- package/dist/index353.js.map +1 -1
- package/dist/index354.js +5 -4
- package/dist/index354.js.map +1 -1
- package/dist/index355.js +4 -4
- package/dist/index355.js.map +1 -1
- package/dist/index356.js +6 -21
- package/dist/index356.js.map +1 -1
- package/dist/index357.js +21 -10
- package/dist/index357.js.map +1 -1
- package/dist/index358.js +10 -128
- package/dist/index358.js.map +1 -1
- package/dist/index359.js +122 -36
- package/dist/index359.js.map +1 -1
- package/dist/index360.js +38 -64
- package/dist/index360.js.map +1 -1
- package/dist/index361.js +66 -115
- package/dist/index361.js.map +1 -1
- package/dist/index362.js +112 -485
- package/dist/index362.js.map +1 -1
- package/dist/index363.js +490 -13
- package/dist/index363.js.map +1 -1
- package/dist/index364.js +13 -4
- package/dist/index364.js.map +1 -1
- package/dist/index365.js +4 -47
- package/dist/index365.js.map +1 -1
- package/dist/index366.js +44 -15
- package/dist/index366.js.map +1 -1
- package/dist/index367.js +19 -5
- package/dist/index367.js.map +1 -1
- package/dist/index368.js +5 -27
- package/dist/index368.js.map +1 -1
- package/dist/index369.js +27 -48
- package/dist/index369.js.map +1 -1
- package/dist/index370.js +46 -27
- package/dist/index370.js.map +1 -1
- package/dist/index371.js +27 -16
- package/dist/index371.js.map +1 -1
- package/dist/index372.js +16 -41
- package/dist/index372.js.map +1 -1
- package/dist/index373.js +42 -14
- package/dist/index373.js.map +1 -1
- package/dist/index374.js +14 -10
- package/dist/index374.js.map +1 -1
- package/dist/index375.js +9 -51
- package/dist/index375.js.map +1 -1
- package/dist/index376.js +53 -43
- package/dist/index376.js.map +1 -1
- package/dist/index377.js +43 -16
- package/dist/index377.js.map +1 -1
- package/dist/index378.js +15 -4
- package/dist/index378.js.map +1 -1
- package/dist/index379.js +4 -4
- package/dist/index379.js.map +1 -1
- package/dist/index380.js +4 -9
- package/dist/index380.js.map +1 -1
- package/dist/index381.js +9 -340
- package/dist/index381.js.map +1 -1
- package/dist/index382.js +339 -4
- package/dist/index382.js.map +1 -1
- package/dist/index383.js +5 -16
- package/dist/index383.js.map +1 -1
- package/dist/index384.js +16 -111
- package/dist/index384.js.map +1 -1
- package/dist/index385.js +109 -19
- package/dist/index385.js.map +1 -1
- package/dist/index386.js +18 -18
- package/dist/index386.js.map +1 -1
- package/dist/index387.js +21 -5
- package/dist/index387.js.map +1 -1
- package/dist/index388.js +5 -20
- package/dist/index388.js.map +1 -1
- package/dist/index389.js +19 -13
- package/dist/index389.js.map +1 -1
- package/dist/index390.js +13 -84
- package/dist/index390.js.map +1 -1
- package/dist/index391.js +84 -7
- package/dist/index391.js.map +1 -1
- package/dist/index392.js +9 -29
- package/dist/index392.js.map +1 -1
- package/dist/index393.js +28 -9
- package/dist/index393.js.map +1 -1
- package/dist/index394.js +9 -5
- package/dist/index394.js.map +1 -1
- package/dist/index395.js +6 -252
- package/dist/index395.js.map +1 -1
- package/dist/index396.js +250 -10
- package/dist/index396.js.map +1 -1
- package/dist/index397.js +11 -10
- package/dist/index397.js.map +1 -1
- package/dist/index398.js +10 -6
- package/dist/index398.js.map +1 -1
- package/dist/index399.js +6 -22
- package/dist/index399.js.map +1 -1
- package/dist/index400.js +21 -21
- package/dist/index400.js.map +1 -1
- package/dist/index401.js +21 -107
- package/dist/index401.js.map +1 -1
- package/dist/index402.js +109 -15
- package/dist/index402.js.map +1 -1
- package/dist/index403.js +15 -12
- package/dist/index403.js.map +1 -1
- package/dist/index404.js +10 -8
- package/dist/index404.js.map +1 -1
- package/dist/index405.js +8 -242
- package/dist/index405.js.map +1 -1
- package/dist/index406.js +238 -25
- package/dist/index406.js.map +1 -1
- package/dist/index407.js +29 -51
- package/dist/index407.js.map +1 -1
- package/dist/index408.js +51 -10
- package/dist/index408.js.map +1 -1
- package/dist/index409.js +11 -128
- package/dist/index409.js.map +1 -1
- package/dist/index410.js +124 -35
- package/dist/index410.js.map +1 -1
- package/dist/index411.js +36 -23
- package/dist/index411.js.map +1 -1
- package/dist/index412.js +26 -11
- package/dist/index412.js.map +1 -1
- package/dist/index413.js +11 -23
- package/dist/index413.js.map +1 -1
- package/dist/index414.js +19 -13
- package/dist/index414.js.map +1 -1
- package/dist/index415.js +14 -13
- package/dist/index415.js.map +1 -1
- package/dist/index416.js +14 -322
- package/dist/index416.js.map +1 -1
- package/dist/index417.js +323 -61
- package/dist/index417.js.map +1 -1
- package/dist/index418.js +63 -4
- package/dist/index418.js.map +1 -1
- package/dist/index419.js +4 -28
- package/dist/index419.js.map +1 -1
- package/dist/index420.js +25 -468
- package/dist/index420.js.map +1 -1
- package/dist/index421.js +452 -250
- package/dist/index421.js.map +1 -1
- package/dist/index422.js +272 -0
- package/dist/index422.js.map +1 -0
- package/package.json +2 -1
package/dist/index361.js
CHANGED
|
@@ -1,121 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
//#region src/components/PhoneNumberInput/selection.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e) return !1;
|
|
4
|
+
let t = e.charCodeAt(0);
|
|
5
|
+
return t >= 48 && t <= 57;
|
|
6
|
+
}
|
|
7
|
+
function t(t, n) {
|
|
8
|
+
let r = 0, i = Math.min(n, t.length);
|
|
9
|
+
for (let n = 0; n < i; n += 1) e(t[n] ?? "") && (r += 1);
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
function n(t, n) {
|
|
13
|
+
if (n <= 0) return t.startsWith("+") ? Math.min(1, t.length) : 0;
|
|
14
|
+
let r = 0;
|
|
15
|
+
for (let i = 0; i < t.length; i += 1) if (e(t[i] ?? "") && (r += 1, r === n)) return i + 1;
|
|
16
|
+
return t.length;
|
|
17
|
+
}
|
|
18
|
+
function r(t) {
|
|
19
|
+
return !t || e(t) ? !1 : t !== "+";
|
|
13
20
|
}
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
a[4] === c?.renderOptionLabel ? m = a[5] : (m = c?.renderOptionLabel ?? p, a[4] = c?.renderOptionLabel, a[5] = m);
|
|
19
|
-
let h = m, g = n.useRef(null), { innerRef: _ } = r, v;
|
|
20
|
-
a[6] === _ ? v = a[7] : (v = (e) => {
|
|
21
|
-
g.current = e, s(_, e);
|
|
22
|
-
}, a[6] = _, a[7] = v);
|
|
23
|
-
let y = v, b;
|
|
24
|
-
a[8] !== c?.consumeScrollBehavior || a[9] !== l ? (b = () => {
|
|
25
|
-
if (!l) return;
|
|
26
|
-
let e = c?.consumeScrollBehavior, t = e ? e() : "smooth", n = g.current;
|
|
27
|
-
if (!n) return;
|
|
28
|
-
let r = n.parentElement;
|
|
29
|
-
if (!r) return;
|
|
30
|
-
let i = n.offsetTop, a = i + n.offsetHeight, o = r.scrollTop, s = o + r.clientHeight;
|
|
31
|
-
i >= o && a <= s || n.scrollIntoView({
|
|
32
|
-
block: "nearest",
|
|
33
|
-
behavior: t
|
|
34
|
-
});
|
|
35
|
-
}, a[8] = c?.consumeScrollBehavior, a[9] = l, a[10] = b) : b = a[10];
|
|
36
|
-
let x;
|
|
37
|
-
a[11] !== c || a[12] !== l ? (x = [c, l], a[11] = c, a[12] = l, a[13] = x) : x = a[13], n.useEffect(b, x);
|
|
38
|
-
let S;
|
|
39
|
-
a[14] !== c || a[15] !== u || a[16] !== r.data ? (S = (e) => {
|
|
40
|
-
u?.(e), c?.setHighlightedOption(r.data);
|
|
41
|
-
}, a[14] = c, a[15] = u, a[16] = r.data, a[17] = S) : S = a[17];
|
|
42
|
-
let C = S, w = l ? "bg-muted text-foreground" : "text-foreground hover:bg-muted", T;
|
|
43
|
-
a[18] !== d || a[19] !== w ? (T = e("flex cursor-pointer items-center justify-between gap-3 px-3 py-2 text-sm", d, w), a[18] = d, a[19] = w, a[20] = T) : T = a[20];
|
|
44
|
-
let E;
|
|
45
|
-
a[21] !== r.data || a[22] !== h ? (E = h(r.data), a[21] = r.data, a[22] = h, a[23] = E) : E = a[23];
|
|
46
|
-
let D;
|
|
47
|
-
return a[24] !== y || a[25] !== C || a[26] !== f || a[27] !== T || a[28] !== E ? (D = /* @__PURE__ */ i("div", {
|
|
48
|
-
ref: y,
|
|
49
|
-
...f,
|
|
50
|
-
onMouseMove: C,
|
|
51
|
-
className: T,
|
|
52
|
-
children: E
|
|
53
|
-
}), a[24] = y, a[25] = C, a[26] = f, a[27] = T, a[28] = E, a[29] = D) : D = a[29], D;
|
|
54
|
-
}, l = {
|
|
55
|
-
control: () => ({ display: "none" }),
|
|
56
|
-
menu: (e) => ({
|
|
57
|
-
...e,
|
|
58
|
-
marginTop: 4,
|
|
59
|
-
borderRadius: "var(--radius)",
|
|
60
|
-
boxShadow: "0 18px 36px rgba(15, 23, 42, 0.18)",
|
|
61
|
-
backgroundColor: "hsl(var(--popover))",
|
|
62
|
-
overflow: "hidden",
|
|
63
|
-
zIndex: 20
|
|
64
|
-
}),
|
|
65
|
-
menuList: (e) => ({
|
|
66
|
-
...e,
|
|
67
|
-
maxHeight: 240,
|
|
68
|
-
padding: 0
|
|
69
|
-
}),
|
|
70
|
-
option: (e, t) => ({
|
|
71
|
-
...e,
|
|
72
|
-
fontSize: "0.875rem",
|
|
73
|
-
backgroundColor: t.isFocused ? "hsl(var(--muted))" : t.isSelected ? "hsl(var(--accent))" : "transparent",
|
|
74
|
-
color: t.isSelected ? "hsl(var(--accent-foreground))" : "hsl(var(--foreground))",
|
|
75
|
-
cursor: "pointer"
|
|
76
|
-
}),
|
|
77
|
-
noOptionsMessage: (e) => ({
|
|
78
|
-
...e,
|
|
79
|
-
fontSize: "0.875rem",
|
|
80
|
-
color: "hsl(var(--muted-foreground))"
|
|
81
|
-
})
|
|
82
|
-
}, u = (e) => {
|
|
83
|
-
let n = t(5), { children: r, innerProps: a, innerRef: o } = e, s;
|
|
84
|
-
n[0] === Symbol.for("react.memo_cache_sentinel") ? (s = {
|
|
85
|
-
height: 0,
|
|
86
|
-
minHeight: 0,
|
|
87
|
-
opacity: 0,
|
|
88
|
-
overflow: "hidden",
|
|
89
|
-
pointerEvents: "none"
|
|
90
|
-
}, n[0] = s) : s = n[0];
|
|
91
|
-
let c;
|
|
92
|
-
return n[1] !== r || n[2] !== a || n[3] !== o ? (c = /* @__PURE__ */ i("div", {
|
|
93
|
-
...a,
|
|
94
|
-
ref: o,
|
|
95
|
-
style: s,
|
|
96
|
-
children: r
|
|
97
|
-
}), n[1] = r, n[2] = a, n[3] = o, n[4] = c) : c = n[4], c;
|
|
98
|
-
}, d = () => null;
|
|
99
|
-
function f(e) {
|
|
100
|
-
return /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ a("span", {
|
|
101
|
-
className: "flex min-w-0 items-center gap-2",
|
|
102
|
-
children: [e.flag ? /* @__PURE__ */ i("span", {
|
|
103
|
-
"aria-hidden": "true",
|
|
104
|
-
className: "text-lg leading-none",
|
|
105
|
-
children: e.flag
|
|
106
|
-
}) : null, /* @__PURE__ */ i("span", {
|
|
107
|
-
className: "truncate",
|
|
108
|
-
children: e.name
|
|
109
|
-
})]
|
|
110
|
-
}), /* @__PURE__ */ a("span", {
|
|
111
|
-
className: "text-xs text-muted-foreground",
|
|
112
|
-
children: ["+", e.dialCode]
|
|
113
|
-
})] });
|
|
21
|
+
function i(e, t) {
|
|
22
|
+
let n = t;
|
|
23
|
+
for (; n > 0 && r(e[n - 1] ?? "");) --n;
|
|
24
|
+
return n;
|
|
114
25
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
26
|
+
function a(e, t) {
|
|
27
|
+
let n = t;
|
|
28
|
+
for (; n < e.length && r(e[n] ?? "");) n += 1;
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
function o(e) {
|
|
32
|
+
let { value: n } = e, r = e.selectionStart ?? n.length, i = e.selectionEnd ?? r, a = r <= 1 && n.startsWith("+"), o = i <= 1 && n.startsWith("+");
|
|
33
|
+
return {
|
|
34
|
+
selectionStart: r,
|
|
35
|
+
selectionEnd: i,
|
|
36
|
+
startDigits: t(n, r),
|
|
37
|
+
endDigits: t(n, i),
|
|
38
|
+
preserveStartIndex: a,
|
|
39
|
+
preserveEndIndex: o,
|
|
40
|
+
wasAtStart: r === 0,
|
|
41
|
+
wasAtEnd: i === n.length
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function s(e, t) {
|
|
45
|
+
if (e.selectionStart === e.selectionEnd) {
|
|
46
|
+
if (e.wasAtEnd) {
|
|
47
|
+
let e = t.length;
|
|
48
|
+
return {
|
|
49
|
+
start: e,
|
|
50
|
+
end: e
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (e.wasAtStart) return {
|
|
54
|
+
start: 0,
|
|
55
|
+
end: 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let r = e.preserveStartIndex ? Math.min(e.selectionStart, t.length) : n(t, e.startDigits), i = e.preserveEndIndex ? Math.min(e.selectionEnd, t.length) : n(t, e.endDigits), a = r, o = i;
|
|
59
|
+
e.wasAtStart && (a = 0), e.wasAtEnd && (o = t.length), e.selectionStart === e.selectionEnd && (a = o);
|
|
60
|
+
let s = Math.min(Math.max(a, 0), t.length), c = Math.min(Math.max(o, 0), t.length);
|
|
61
|
+
return s > c ? {
|
|
62
|
+
start: c,
|
|
63
|
+
end: c
|
|
64
|
+
} : {
|
|
65
|
+
start: s,
|
|
66
|
+
end: c
|
|
67
|
+
};
|
|
117
68
|
}
|
|
118
69
|
//#endregion
|
|
119
|
-
export {
|
|
70
|
+
export { o as captureSelectionSnapshot, s as resolveSelection, i as skipFormattingCharactersLeft, a as skipFormattingCharactersRight };
|
|
120
71
|
|
|
121
72
|
//# sourceMappingURL=index361.js.map
|
package/dist/index361.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index361.js","names":["
|
|
1
|
+
{"version":3,"file":"index361.js","names":["isDigitCharacter","char","code","charCodeAt","countDigitsBefore","value","index","count","limit","Math","min","length","position","findIndexForDigitCount","digitCount","startsWith","seen","isFormattingCharacter","skipFormattingCharactersLeft","next","skipFormattingCharactersRight","SelectionSnapshot","selectionStart","selectionEnd","startDigits","endDigits","preserveStartIndex","preserveEndIndex","wasAtStart","wasAtEnd","captureSelectionSnapshot","input","HTMLInputElement","resolveSelection","snapshot","end","start","resolvedStart","resolvedEnd","clampedStart","max","clampedEnd"],"sources":["../src/components/PhoneNumberInput/selection.ts"],"sourcesContent":["function isDigitCharacter(char: string) {\n if (!char) {\n return false\n }\n const code = char.charCodeAt(0)\n return code >= 48 && code <= 57\n}\n\nfunction countDigitsBefore(value: string, index: number) {\n let count = 0\n const limit = Math.min(index, value.length)\n for (let position = 0; position < limit; position += 1) {\n if (isDigitCharacter(value[position] ?? \"\")) {\n count += 1\n }\n }\n return count\n}\n\nfunction findIndexForDigitCount(value: string, digitCount: number) {\n if (digitCount <= 0) {\n return value.startsWith(\"+\") ? Math.min(1, value.length) : 0\n }\n\n let seen = 0\n for (let index = 0; index < value.length; index += 1) {\n if (isDigitCharacter(value[index] ?? \"\")) {\n seen += 1\n if (seen === digitCount) {\n return index + 1\n }\n }\n }\n\n return value.length\n}\n\nfunction isFormattingCharacter(char: string) {\n if (!char) {\n return false\n }\n if (isDigitCharacter(char)) {\n return false\n }\n return char !== \"+\"\n}\n\nexport function skipFormattingCharactersLeft(value: string, index: number) {\n let position = index\n while (position > 0) {\n const next = value[position - 1] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position -= 1\n }\n return position\n}\n\nexport function skipFormattingCharactersRight(value: string, index: number) {\n let position = index\n while (position < value.length) {\n const next = value[position] ?? \"\"\n if (!isFormattingCharacter(next)) {\n break\n }\n position += 1\n }\n return position\n}\n\ntype SelectionSnapshot = {\n selectionStart: number\n selectionEnd: number\n startDigits: number\n endDigits: number\n preserveStartIndex: boolean\n preserveEndIndex: boolean\n wasAtStart: boolean\n wasAtEnd: boolean\n}\n\nexport function captureSelectionSnapshot(input: HTMLInputElement): SelectionSnapshot {\n const { value } = input\n const selectionStart = input.selectionStart ?? value.length\n const selectionEnd = input.selectionEnd ?? selectionStart\n const preserveStartIndex = selectionStart <= 1 && value.startsWith(\"+\")\n const preserveEndIndex = selectionEnd <= 1 && value.startsWith(\"+\")\n\n return {\n selectionStart,\n selectionEnd,\n startDigits: countDigitsBefore(value, selectionStart),\n endDigits: countDigitsBefore(value, selectionEnd),\n preserveStartIndex,\n preserveEndIndex,\n wasAtStart: selectionStart === 0,\n wasAtEnd: selectionEnd === value.length,\n }\n}\n\nexport function resolveSelection(snapshot: SelectionSnapshot, value: string) {\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n if (snapshot.wasAtEnd) {\n const end = value.length\n return { start: end, end }\n }\n if (snapshot.wasAtStart) {\n return { start: 0, end: 0 }\n }\n }\n\n const start = snapshot.preserveStartIndex\n ? Math.min(snapshot.selectionStart, value.length)\n : findIndexForDigitCount(value, snapshot.startDigits)\n const end = snapshot.preserveEndIndex\n ? Math.min(snapshot.selectionEnd, value.length)\n : findIndexForDigitCount(value, snapshot.endDigits)\n\n let resolvedStart = start\n let resolvedEnd = end\n\n if (snapshot.wasAtStart) {\n resolvedStart = 0\n }\n\n if (snapshot.wasAtEnd) {\n resolvedEnd = value.length\n }\n\n if (snapshot.selectionStart === snapshot.selectionEnd) {\n resolvedStart = resolvedEnd\n }\n\n const clampedStart = Math.min(Math.max(resolvedStart, 0), value.length)\n const clampedEnd = Math.min(Math.max(resolvedEnd, 0), value.length)\n\n if (clampedStart > clampedEnd) {\n return { start: clampedEnd, end: clampedEnd }\n }\n\n return { start: clampedStart, end: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