@tktb-tess/util-fns 0.12.1 → 0.12.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){let e=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},t=(t,n,r)=>{if(r<1n)throw RangeError("`mod` must be positive");if(n<0n)throw RangeError("`power` must not be negative");if(t=e(t,r),r===1n)return 0n;if(t%r===1n||t%r===0n)return t;if(t===r-1n)return n&1n?r-1n:1n;let i=1n;for(;n>0n;)n&1n&&(i=i*t%r),t=t*t%r,n>>=1n;return i},n=(e,t)=>{if(t<1n||t%2n==0n)throw RangeError("`n` is out of range");for(;e<0n;)e+=t;e%=t;let n=1n;for(;e!==0n;){for(;e%2n==0n;){e/=2n;let r=t%8n;(r===3n||r===5n)&&(n*=-1n)}[e,t]=[t,e],e%4n==3n&&t%4n==3n&&(n*=-1n),e%=t}return t===1n?n:0n},r=e=>{if(e<0n)return!1;if(e===0n)return!0;let t=1n,n=e;for(;t+1n<n;){let r=(t+n)/2n;r*r<e?t=r:n=r}return e===t**2n||e===(t+1n)**2n},i=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,a=(e,t)=>{if(!i())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},o=(e,t)=>{if(!i())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},s=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;let n=e-1n,r=0n;for(;n%2n==0n;)n>>=1n,r+=1n;let[i,a]=[n,r],o=t(2n,i,e);if(o===1n)return!0;for(let t=0n;t<a;t++){if(o===e-1n)return!0;o=o*o%e}return!1},c=e=>{let t=5n,i=n(t,e);for(;i>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&r(e))return[0n,0n];i=n(t,e)}return[t,i]},l=(t,n)=>(t&1n)==1n?e(t+n>>1n,n):e(t>>1n,n),u=(t,n,r,i)=>{let a=1n,o=r,s=t.toString(2).slice(1);for(let t of s)[a,o]=[e(a*o,n),l(o*o+i*a*a,n)],t===`1`&&([a,o]=[l(r*a+o,n),l(i*a+r*o,n)]);return[a,o]},d=(n,r,i,a)=>{if(n%2n!=1n)throw RangeError("`n` must be odd");let o=n+1n,s=0n;for(;o%2n==0n;)o>>=1n,s+=1n;let[c,l]=u(o,n,i,r),d=l;if(c===0n)return!0;a=t(a,o,n);for(let r=0n;r<s;r++){if(d===0n)return!0;d=e(d*d-2n*a,n),a=t(a,2n,n)}return!1},f=
|
|
1
|
+
(function(){let e=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},t=(t,n,r)=>{if(r<1n)throw RangeError("`mod` must be positive");if(n<0n)throw RangeError("`power` must not be negative");if(t=e(t,r),r===1n)return 0n;if(t%r===1n||t%r===0n)return t;if(t===r-1n)return n&1n?r-1n:1n;let i=1n;for(;n>0n;)n&1n&&(i=i*t%r),t=t*t%r,n>>=1n;return i},n=(e,t)=>{if(t<1n||t%2n==0n)throw RangeError("`n` is out of range");for(;e<0n;)e+=t;e%=t;let n=1n;for(;e!==0n;){for(;e%2n==0n;){e/=2n;let r=t%8n;(r===3n||r===5n)&&(n*=-1n)}[e,t]=[t,e],e%4n==3n&&t%4n==3n&&(n*=-1n),e%=t}return t===1n?n:0n},r=e=>{if(e<0n)return!1;if(e===0n)return!0;let t=1n,n=e;for(;t+1n<n;){let r=(t+n)/2n;r*r<e?t=r:n=r}return e===t**2n||e===(t+1n)**2n},i=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,a=(e,t)=>{if(!i())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},o=(e,t)=>{if(!i())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},s=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;let n=e-1n,r=0n;for(;n%2n==0n;)n>>=1n,r+=1n;let[i,a]=[n,r],o=t(2n,i,e);if(o===1n)return!0;for(let t=0n;t<a;t++){if(o===e-1n)return!0;o=o*o%e}return!1},c=e=>{let t=5n,i=n(t,e);for(;i>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&r(e))return[0n,0n];i=n(t,e)}return[t,i]},l=(t,n)=>(t&1n)==1n?e(t+n>>1n,n):e(t>>1n,n),u=(t,n,r,i)=>{let a=1n,o=r,s=t.toString(2).slice(1);for(let t of s)[a,o]=[e(a*o,n),l(o*o+i*a*a,n)],t===`1`&&([a,o]=[l(r*a+o,n),l(i*a+r*o,n)]);return[a,o]},d=(n,r,i,a)=>{if(n%2n!=1n)throw RangeError("`n` must be odd");let o=n+1n,s=0n;for(;o%2n==0n;)o>>=1n,s+=1n;let[c,l]=u(o,n,i,r),d=l;if(c===0n)return!0;a=t(a,o,n);for(let r=0n;r<s;r++){if(d===0n)return!0;d=e(d*d-2n*a,n),a=t(a,2n,n)}return!1},f=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n],p=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of f)if(e%t===0n)return e===t;if(!s(e))return!1;let[t,n]=c(e);return n===0n?!1:d(e,t,1n,(1n-t)/4n)};globalThis.onmessage=e=>{let{value:t,id:n}=e.data;try{a(p(t),n)}catch(e){o(e,n)}}})();
|
package/dist/baillie_psw.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export declare const getRandPrimeByRange: (min: bigint, max: bigint) => bigint;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const getRandPrimeByBitLength: (bitLength: number, fixed?: boolean) => bigint;
|
|
21
21
|
/**
|
|
22
|
-
* worker async version of `bailliePSW()`
|
|
22
|
+
* worker async version of `bailliePSW()` \
|
|
23
|
+
* only available in esm context
|
|
23
24
|
* @param n
|
|
24
25
|
*/
|
|
25
26
|
export declare const bailliePSWAsync: (n: bigint) => Promise<boolean>;
|
package/dist/bundle.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
//#region lib/u8arr_ext.ts
|
|
2
|
+
var e = (e) => {
|
|
2
3
|
let t = Array.from(e, (e) => String.fromCharCode(e));
|
|
3
4
|
return btoa(t.join(""));
|
|
4
|
-
},
|
|
5
|
+
}, t = (e) => {
|
|
5
6
|
let t = atob(e);
|
|
6
7
|
return Uint8Array.from(t, (e) => e.charCodeAt(0));
|
|
7
|
-
},
|
|
8
|
-
let
|
|
9
|
-
return
|
|
10
|
-
},
|
|
8
|
+
}, n = (t) => e(t).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, ""), r = (e) => {
|
|
9
|
+
let n = 4 - (e.length & 3) & 3;
|
|
10
|
+
return t(e.concat("=".repeat(n)).replaceAll("-", "+").replaceAll("_", "/"));
|
|
11
|
+
}, i = (e) => {
|
|
11
12
|
let t = Array.from(e, (e) => e.toString(16).padStart(2, "0")).join(""), n = (6 - t.length % 6) % 6, r = "0".repeat(n).concat(t).matchAll(/.{6}/g);
|
|
12
13
|
return Array.from(r, (e) => Number.parseInt(e[0], 16).toString(8).padStart(8, "0")).join("").replace(/^0+/, "");
|
|
13
|
-
},
|
|
14
|
+
}, a = (e) => {
|
|
14
15
|
let t = 8 - (e.length & 7) & 7, n = "0".repeat(t).concat(e).matchAll(/.{8}/g), r = Array.from(n, (e) => Number.parseInt(e[0], 8).toString(16).padStart(6, "0")).join("").matchAll(/.{2}/g);
|
|
15
16
|
return Uint8Array.from(r, (e) => Number.parseInt(e[0], 16));
|
|
16
|
-
},
|
|
17
|
+
}, o = (e, t) => [e].includes(t), s = (e, t) => {
|
|
17
18
|
if (typeof e != typeof t) return !1;
|
|
18
19
|
let n = Object.prototype.toString.call(e);
|
|
19
20
|
if (n !== Object.prototype.toString.call(t)) return !1;
|
|
@@ -22,23 +23,23 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
22
23
|
if (typeof e == "function") return !1;
|
|
23
24
|
if (Array.isArray(e) && Array.isArray(t)) {
|
|
24
25
|
if (e.length !== t.length) return !1;
|
|
25
|
-
for (let n = 0; n < e.length; n++) if (!
|
|
26
|
+
for (let n = 0; n < e.length; n++) if (!s(e[n], t[n])) return !1;
|
|
26
27
|
return !0;
|
|
27
28
|
}
|
|
28
|
-
if (e instanceof Set && t instanceof Set) return !!
|
|
29
|
-
if (e instanceof Map && t instanceof Map) return !(!
|
|
29
|
+
if (e instanceof Set && t instanceof Set) return !!s([...e.values()], [...t.values()]);
|
|
30
|
+
if (e instanceof Map && t instanceof Map) return !(!s([...e.keys()], [...t.keys()]) || !s([...e.values()], [...t.values()]));
|
|
30
31
|
if (n === "[object Object]") {
|
|
31
32
|
let n = e, r = t, i = Object.keys(n), a = Object.keys(r);
|
|
32
33
|
for (let e of i) {
|
|
33
34
|
let t = a.find((t) => t === e);
|
|
34
35
|
if (t === void 0) return !1;
|
|
35
36
|
let [i, o] = [n[e], r[t]];
|
|
36
|
-
if (!
|
|
37
|
+
if (!s(i, o)) return !1;
|
|
37
38
|
}
|
|
38
39
|
return !0;
|
|
39
40
|
}
|
|
40
41
|
throw TypeError(`comparing these objects is unavailable: ${e}, ${t}`, { cause: [e, t] });
|
|
41
|
-
},
|
|
42
|
+
}, c = () => {
|
|
42
43
|
let e, t;
|
|
43
44
|
return {
|
|
44
45
|
promise: new Promise((n, r) => {
|
|
@@ -47,32 +48,32 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
47
48
|
resolve: e,
|
|
48
49
|
reject: t
|
|
49
50
|
};
|
|
50
|
-
},
|
|
51
|
+
}, l = (e) => new Promise((t) => setTimeout(t, e)), ee = (e) => Object.prototype.toString.call(e).slice(8, -1), te = (e) => (...t) => () => e(...t), u = (e) => {
|
|
51
52
|
let t = [], n = [], r = "", i = !1;
|
|
52
53
|
for (let a = 0; a < e.length; a++) {
|
|
53
54
|
let o = e[a];
|
|
54
55
|
o === "\"" && (a === 0 || e[a - 1] !== "\\") ? i = !i : o === "," && !i ? (n.push(r.trim()), r = "") : o === "\n" && !i ? (n.push(r.trim()), t.push(n), n = [], r = "") : r += o;
|
|
55
56
|
}
|
|
56
57
|
return n.push(r.trim()), t.push(n), t;
|
|
57
|
-
},
|
|
58
|
+
}, d = async (e, t) => {
|
|
58
59
|
let n = new TextEncoder().encode(e), r = await crypto.subtle.digest(t, n);
|
|
59
60
|
return new Uint8Array(r);
|
|
60
|
-
},
|
|
61
|
+
}, ne = (e) => encodeURIComponent(e).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`), re = (e) => {
|
|
61
62
|
if (e.includes("+")) throw URIError("an input string must not include `+`");
|
|
62
63
|
return decodeURIComponent(e);
|
|
63
64
|
}, ie = (e, t) => {
|
|
64
65
|
let n = new Blob([e]).stream().pipeThrough(new CompressionStream(t));
|
|
65
66
|
return new Response(n).bytes();
|
|
66
|
-
},
|
|
67
|
+
}, f = (e, t) => {
|
|
67
68
|
let n = new Blob([e]).stream().pipeThrough(new DecompressionStream(t));
|
|
68
69
|
return new Response(n).bytes();
|
|
69
|
-
},
|
|
70
|
-
let
|
|
71
|
-
return
|
|
72
|
-
},
|
|
73
|
-
let n =
|
|
74
|
-
return new Response(
|
|
75
|
-
},
|
|
70
|
+
}, p = async (e, t) => {
|
|
71
|
+
let r = new Blob([e]).stream().pipeThrough(new CompressionStream(t));
|
|
72
|
+
return n(await new Response(r).bytes());
|
|
73
|
+
}, m = (e, t) => {
|
|
74
|
+
let n = r(e), i = new Blob([n]).stream().pipeThrough(new DecompressionStream(t));
|
|
75
|
+
return new Response(i).text();
|
|
76
|
+
}, h = (e, t) => new Promise((n, r) => {
|
|
76
77
|
setTimeout(async () => {
|
|
77
78
|
try {
|
|
78
79
|
n(await e());
|
|
@@ -80,42 +81,42 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
80
81
|
r(e);
|
|
81
82
|
}
|
|
82
83
|
}, t);
|
|
83
|
-
}),
|
|
84
|
+
}), g = (e, t) => {
|
|
84
85
|
if (t < -e.length || t >= e.length) throw RangeError("`index` is out of range");
|
|
85
86
|
return e.at(t);
|
|
86
87
|
}, ae = (e, t) => {
|
|
87
|
-
let n =
|
|
88
|
+
let n = g(e, t);
|
|
88
89
|
if (n == null) throw TypeError("value is nullable");
|
|
89
90
|
return n;
|
|
90
|
-
},
|
|
91
|
+
}, _ = (e, t) => Math.floor(Math.random() * (t - e) + e), v = (e, t) => {
|
|
91
92
|
t < 0n && (t *= -1n);
|
|
92
93
|
let n = e % t;
|
|
93
94
|
return n < 0n ? n + t : n;
|
|
94
|
-
},
|
|
95
|
+
}, y = (e, t = !1) => {
|
|
95
96
|
if (!Number.isFinite(e)) throw RangeError("`length` is not a valid number");
|
|
96
97
|
if (e <= 0) throw RangeError("`length` must be positive");
|
|
97
98
|
let n = Math.ceil(e / 8), r = crypto.getRandomValues(new Uint8Array(n)), i = Array.from(r, (e) => e.toString(2).padStart(8, "0")).join("").slice(0, e);
|
|
98
99
|
return t && (i = i.replace(/^\d/, "1")), BigInt("0b" + i);
|
|
99
|
-
},
|
|
100
|
+
}, b = (e, t) => {
|
|
100
101
|
if (e >= t) throw RangeError("`min` must be smaller than `max`");
|
|
101
102
|
let n = t - e, r = n.toString(2).length;
|
|
102
103
|
return e + (() => {
|
|
103
104
|
for (let e = 0; e < 1e5; e++) {
|
|
104
|
-
let e =
|
|
105
|
-
if (e >=
|
|
105
|
+
let e = y(r);
|
|
106
|
+
if (e >= x(2n, BigInt(r), n)) return e % n;
|
|
106
107
|
}
|
|
107
108
|
throw Error("Failed to generate a random bigint");
|
|
108
109
|
})();
|
|
109
|
-
},
|
|
110
|
+
}, x = (e, t, n) => {
|
|
110
111
|
if (n < 1n) throw RangeError("`mod` must be positive");
|
|
111
112
|
if (t < 0n) throw RangeError("`power` must not be negative");
|
|
112
|
-
if (e =
|
|
113
|
+
if (e = v(e, n), n === 1n) return 0n;
|
|
113
114
|
if (e % n === 1n || e % n === 0n) return e;
|
|
114
115
|
if (e === n - 1n) return t & 1n ? n - 1n : 1n;
|
|
115
116
|
let r = 1n;
|
|
116
117
|
for (; t > 0n;) t & 1n && (r = r * e % n), e = e * e % n, t >>= 1n;
|
|
117
118
|
return r;
|
|
118
|
-
},
|
|
119
|
+
}, S = (e, t) => {
|
|
119
120
|
if (e === 0n && t === 0n) return {
|
|
120
121
|
x: 0n,
|
|
121
122
|
y: 0n,
|
|
@@ -158,7 +159,7 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
158
159
|
y: o,
|
|
159
160
|
gcd: s
|
|
160
161
|
};
|
|
161
|
-
},
|
|
162
|
+
}, C = (e, t) => {
|
|
162
163
|
if (e >= t) return 1n;
|
|
163
164
|
let n = BigInt((t - 2n).toString(2).length), r = (t - e) / 2n;
|
|
164
165
|
if (n * r < 63n) {
|
|
@@ -167,20 +168,20 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
167
168
|
return n;
|
|
168
169
|
}
|
|
169
170
|
let i = e + r | 1n;
|
|
170
|
-
return
|
|
171
|
-
},
|
|
171
|
+
return C(e, i) * C(i, t);
|
|
172
|
+
}, oe = (e) => {
|
|
172
173
|
let t = 3n, n = 1n, r = 1n, i = BigInt(e.toString(2).length) - 1n;
|
|
173
174
|
for (let a = i - 1n; a > -1n; --a) {
|
|
174
175
|
let i = (e >> a) + 1n | 1n;
|
|
175
|
-
r *=
|
|
176
|
+
r *= C(t, i), t = i, n *= r;
|
|
176
177
|
}
|
|
177
178
|
return n;
|
|
178
|
-
},
|
|
179
|
+
}, se = (e) => {
|
|
179
180
|
if (e < 0n) throw RangeError("'n' must be non-negative");
|
|
180
181
|
if (e === 0n) return 1n;
|
|
181
182
|
let t = e - BigInt(e.toString(2).match(/1/g)?.length ?? 0);
|
|
182
|
-
return
|
|
183
|
-
},
|
|
183
|
+
return oe(e) << t;
|
|
184
|
+
}, w = (e, t) => (e >>> (t & 31) | e << (-t & 31)) >>> 0, T = (e, t) => BigInt.asUintN(64, e >> (t & 63n) | e << (-t & 63n)), E = (e, t) => {
|
|
184
185
|
if (t < 1n || t % 2n == 0n) throw RangeError("`n` is out of range");
|
|
185
186
|
for (; e < 0n;) e += t;
|
|
186
187
|
e %= t;
|
|
@@ -194,7 +195,7 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
194
195
|
[e, t] = [t, e], e % 4n == 3n && t % 4n == 3n && (n *= -1n), e %= t;
|
|
195
196
|
}
|
|
196
197
|
return t === 1n ? n : 0n;
|
|
197
|
-
},
|
|
198
|
+
}, D = (e) => {
|
|
198
199
|
if (e < 0n) return !1;
|
|
199
200
|
if (e === 0n) return !0;
|
|
200
201
|
let t = 1n, n = e;
|
|
@@ -203,7 +204,7 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
203
204
|
r * r < e ? t = r : n = r;
|
|
204
205
|
}
|
|
205
206
|
return e === t ** 2n || e === (t + 1n) ** 2n;
|
|
206
|
-
},
|
|
207
|
+
}, O = class {
|
|
207
208
|
#e;
|
|
208
209
|
constructor(e) {
|
|
209
210
|
this.#e = e;
|
|
@@ -222,178 +223,178 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
222
223
|
};
|
|
223
224
|
this.#e.postMessage(s, t);
|
|
224
225
|
});
|
|
225
|
-
},
|
|
226
|
-
if (!
|
|
226
|
+
}, k = () => typeof window > "u" && typeof self < "u" && "importScripts" in self, A = (e, t) => {
|
|
227
|
+
if (!k()) throw Error("this function must be used in Worker");
|
|
227
228
|
let n = {
|
|
228
229
|
success: !0,
|
|
229
230
|
value: e,
|
|
230
231
|
id: t
|
|
231
232
|
};
|
|
232
233
|
self.postMessage(n);
|
|
233
|
-
},
|
|
234
|
-
if (!
|
|
234
|
+
}, j = (e, t) => {
|
|
235
|
+
if (!k()) throw Error("this function must be used in Worker");
|
|
235
236
|
let n = {
|
|
236
237
|
success: !1,
|
|
237
238
|
error: e,
|
|
238
239
|
id: t
|
|
239
240
|
};
|
|
240
241
|
self.postMessage(n);
|
|
241
|
-
},
|
|
242
|
+
}, M = (e) => {
|
|
242
243
|
if (e <= 1n) return !1;
|
|
243
244
|
if (e % 2n == 0n) return e === 2n;
|
|
244
245
|
let t = e - 1n, n = 0n;
|
|
245
246
|
for (; t % 2n == 0n;) t >>= 1n, n += 1n;
|
|
246
|
-
let [r, i] = [t, n], a =
|
|
247
|
+
let [r, i] = [t, n], a = x(2n, r, e);
|
|
247
248
|
if (a === 1n) return !0;
|
|
248
249
|
for (let t = 0n; t < i; t++) {
|
|
249
250
|
if (a === e - 1n) return !0;
|
|
250
251
|
a = a * a % e;
|
|
251
252
|
}
|
|
252
253
|
return !1;
|
|
253
|
-
},
|
|
254
|
-
let t = 5n, n =
|
|
254
|
+
}, N = (e) => {
|
|
255
|
+
let t = 5n, n = E(t, e);
|
|
255
256
|
for (; n > 0n;) {
|
|
256
|
-
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n &&
|
|
257
|
-
n =
|
|
257
|
+
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n && D(e)) return [0n, 0n];
|
|
258
|
+
n = E(t, e);
|
|
258
259
|
}
|
|
259
260
|
return [t, n];
|
|
260
|
-
},
|
|
261
|
+
}, P = (e, t) => (e & 1n) == 1n ? v(e + t >> 1n, t) : v(e >> 1n, t), F = (e, t, n, r) => {
|
|
261
262
|
let i = 1n, a = n, o = e.toString(2).slice(1);
|
|
262
|
-
for (let e of o) [i, a] = [
|
|
263
|
+
for (let e of o) [i, a] = [v(i * a, t), P(a * a + r * i * i, t)], e === "1" && ([i, a] = [P(n * i + a, t), P(r * i + n * a, t)]);
|
|
263
264
|
return [i, a];
|
|
264
|
-
},
|
|
265
|
+
}, I = (e, t, n, r) => {
|
|
265
266
|
if (e % 2n != 1n) throw RangeError("`n` must be odd");
|
|
266
267
|
let i = e + 1n, a = 0n;
|
|
267
268
|
for (; i % 2n == 0n;) i >>= 1n, a += 1n;
|
|
268
|
-
let [o, s] =
|
|
269
|
+
let [o, s] = F(i, e, n, t), c = s;
|
|
269
270
|
if (o === 0n) return !0;
|
|
270
|
-
r =
|
|
271
|
+
r = x(r, i, e);
|
|
271
272
|
for (let t = 0n; t < a; t++) {
|
|
272
273
|
if (c === 0n) return !0;
|
|
273
|
-
c =
|
|
274
|
+
c = v(c * c - 2n * r, e), r = x(r, 2n, e);
|
|
274
275
|
}
|
|
275
276
|
return !1;
|
|
276
|
-
},
|
|
277
|
+
}, L = [
|
|
278
|
+
2n,
|
|
279
|
+
3n,
|
|
280
|
+
5n,
|
|
281
|
+
7n,
|
|
282
|
+
11n,
|
|
283
|
+
13n,
|
|
284
|
+
17n,
|
|
285
|
+
19n,
|
|
286
|
+
23n,
|
|
287
|
+
29n,
|
|
288
|
+
31n,
|
|
289
|
+
37n,
|
|
290
|
+
41n,
|
|
291
|
+
43n,
|
|
292
|
+
47n,
|
|
293
|
+
53n,
|
|
294
|
+
59n,
|
|
295
|
+
61n,
|
|
296
|
+
67n,
|
|
297
|
+
71n,
|
|
298
|
+
73n,
|
|
299
|
+
79n,
|
|
300
|
+
83n,
|
|
301
|
+
89n,
|
|
302
|
+
97n,
|
|
303
|
+
101n,
|
|
304
|
+
103n,
|
|
305
|
+
107n,
|
|
306
|
+
109n,
|
|
307
|
+
113n,
|
|
308
|
+
127n,
|
|
309
|
+
131n,
|
|
310
|
+
137n,
|
|
311
|
+
139n,
|
|
312
|
+
149n,
|
|
313
|
+
151n,
|
|
314
|
+
157n,
|
|
315
|
+
163n,
|
|
316
|
+
167n,
|
|
317
|
+
173n,
|
|
318
|
+
179n,
|
|
319
|
+
181n,
|
|
320
|
+
191n,
|
|
321
|
+
193n,
|
|
322
|
+
197n,
|
|
323
|
+
199n,
|
|
324
|
+
211n,
|
|
325
|
+
223n,
|
|
326
|
+
227n,
|
|
327
|
+
229n,
|
|
328
|
+
233n,
|
|
329
|
+
239n,
|
|
330
|
+
241n,
|
|
331
|
+
251n,
|
|
332
|
+
257n,
|
|
333
|
+
263n,
|
|
334
|
+
269n,
|
|
335
|
+
271n,
|
|
336
|
+
277n,
|
|
337
|
+
281n,
|
|
338
|
+
283n,
|
|
339
|
+
293n,
|
|
340
|
+
307n,
|
|
341
|
+
311n,
|
|
342
|
+
313n,
|
|
343
|
+
317n,
|
|
344
|
+
331n,
|
|
345
|
+
337n,
|
|
346
|
+
347n,
|
|
347
|
+
349n,
|
|
348
|
+
353n,
|
|
349
|
+
359n,
|
|
350
|
+
367n,
|
|
351
|
+
373n,
|
|
352
|
+
379n,
|
|
353
|
+
383n,
|
|
354
|
+
389n,
|
|
355
|
+
397n,
|
|
356
|
+
401n,
|
|
357
|
+
409n,
|
|
358
|
+
419n,
|
|
359
|
+
421n,
|
|
360
|
+
431n,
|
|
361
|
+
433n,
|
|
362
|
+
439n,
|
|
363
|
+
443n,
|
|
364
|
+
449n,
|
|
365
|
+
457n,
|
|
366
|
+
461n,
|
|
367
|
+
463n,
|
|
368
|
+
467n,
|
|
369
|
+
479n,
|
|
370
|
+
487n,
|
|
371
|
+
491n,
|
|
372
|
+
499n
|
|
373
|
+
], R = (e) => {
|
|
277
374
|
if (e <= 1n) return !1;
|
|
278
375
|
if (e % 2n == 0n) return e === 2n;
|
|
279
|
-
for (let t of
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
7n,
|
|
284
|
-
11n,
|
|
285
|
-
13n,
|
|
286
|
-
17n,
|
|
287
|
-
19n,
|
|
288
|
-
23n,
|
|
289
|
-
29n,
|
|
290
|
-
31n,
|
|
291
|
-
37n,
|
|
292
|
-
41n,
|
|
293
|
-
43n,
|
|
294
|
-
47n,
|
|
295
|
-
53n,
|
|
296
|
-
59n,
|
|
297
|
-
61n,
|
|
298
|
-
67n,
|
|
299
|
-
71n,
|
|
300
|
-
73n,
|
|
301
|
-
79n,
|
|
302
|
-
83n,
|
|
303
|
-
89n,
|
|
304
|
-
97n,
|
|
305
|
-
101n,
|
|
306
|
-
103n,
|
|
307
|
-
107n,
|
|
308
|
-
109n,
|
|
309
|
-
113n,
|
|
310
|
-
127n,
|
|
311
|
-
131n,
|
|
312
|
-
137n,
|
|
313
|
-
139n,
|
|
314
|
-
149n,
|
|
315
|
-
151n,
|
|
316
|
-
157n,
|
|
317
|
-
163n,
|
|
318
|
-
167n,
|
|
319
|
-
173n,
|
|
320
|
-
179n,
|
|
321
|
-
181n,
|
|
322
|
-
191n,
|
|
323
|
-
193n,
|
|
324
|
-
197n,
|
|
325
|
-
199n,
|
|
326
|
-
211n,
|
|
327
|
-
223n,
|
|
328
|
-
227n,
|
|
329
|
-
229n,
|
|
330
|
-
233n,
|
|
331
|
-
239n,
|
|
332
|
-
241n,
|
|
333
|
-
251n,
|
|
334
|
-
257n,
|
|
335
|
-
263n,
|
|
336
|
-
269n,
|
|
337
|
-
271n,
|
|
338
|
-
277n,
|
|
339
|
-
281n,
|
|
340
|
-
283n,
|
|
341
|
-
293n,
|
|
342
|
-
307n,
|
|
343
|
-
311n,
|
|
344
|
-
313n,
|
|
345
|
-
317n,
|
|
346
|
-
331n,
|
|
347
|
-
337n,
|
|
348
|
-
347n,
|
|
349
|
-
349n,
|
|
350
|
-
353n,
|
|
351
|
-
359n,
|
|
352
|
-
367n,
|
|
353
|
-
373n,
|
|
354
|
-
379n,
|
|
355
|
-
383n,
|
|
356
|
-
389n,
|
|
357
|
-
397n,
|
|
358
|
-
401n,
|
|
359
|
-
409n,
|
|
360
|
-
419n,
|
|
361
|
-
421n,
|
|
362
|
-
431n,
|
|
363
|
-
433n,
|
|
364
|
-
439n,
|
|
365
|
-
443n,
|
|
366
|
-
449n,
|
|
367
|
-
457n,
|
|
368
|
-
461n,
|
|
369
|
-
463n,
|
|
370
|
-
467n,
|
|
371
|
-
479n,
|
|
372
|
-
487n,
|
|
373
|
-
491n,
|
|
374
|
-
499n
|
|
375
|
-
]) if (e % t === 0n) return e === t;
|
|
376
|
-
if (!N(e)) return !1;
|
|
377
|
-
let [t, n] = P(e);
|
|
378
|
-
return n === 0n ? !1 : L(e, t, 1n, (1n - t) / 4n);
|
|
376
|
+
for (let t of L) if (e % t === 0n) return e === t;
|
|
377
|
+
if (!M(e)) return !1;
|
|
378
|
+
let [t, n] = N(e);
|
|
379
|
+
return n === 0n ? !1 : I(e, t, 1n, (1n - t) / 4n);
|
|
379
380
|
}, z = (e, t) => {
|
|
380
381
|
if (t < 2n) throw RangeError("`max` must be 2 or larger");
|
|
381
382
|
for (let n = 0; n < 1e5; n++) {
|
|
382
|
-
let n =
|
|
383
|
+
let n = b(e, t);
|
|
383
384
|
if (R(n)) return n;
|
|
384
385
|
}
|
|
385
386
|
throw Error("no primes were found");
|
|
386
387
|
}, B = (e, t = !1) => {
|
|
387
388
|
if (e < 2) throw RangeError("`bitLength` must be 2 or larger");
|
|
388
389
|
for (let n = 0; n < 1e5; n++) {
|
|
389
|
-
let n =
|
|
390
|
+
let n = y(e, t);
|
|
390
391
|
if (R(n)) return n;
|
|
391
392
|
}
|
|
392
393
|
throw Error("no primes were found");
|
|
393
|
-
}, V, H = () => (V ||= new
|
|
394
|
+
}, V, H = () => (V ||= new O(new Worker(new URL(
|
|
394
395
|
/* @vite-ignore */
|
|
395
|
-
"/assets/bpsw_worker-
|
|
396
|
-
"" +
|
|
396
|
+
"/assets/bpsw_worker-nJV3KnVo.js",
|
|
397
|
+
"" + import.meta.url
|
|
397
398
|
), { type: "module" })), V), U = (e) => H().postMessage(e), W = "Rational", G = class e {
|
|
398
399
|
#e;
|
|
399
400
|
#t;
|
|
@@ -418,7 +419,7 @@ var e = typeof document < "u" ? document.currentScript : null, t = e && e.tagNam
|
|
|
418
419
|
return new e(r ? -o : o, c);
|
|
419
420
|
}
|
|
420
421
|
#n() {
|
|
421
|
-
let { gcd: e } =
|
|
422
|
+
let { gcd: e } = S(this.#e, this.#t);
|
|
422
423
|
e !== 0n && (this.#e /= e, this.#t /= e);
|
|
423
424
|
}
|
|
424
425
|
minus = () => new e(-this.#e, this.#t);
|
|
@@ -497,7 +498,7 @@ var J = (e) => {
|
|
|
497
498
|
if (i -= 64n, i < n) return n;
|
|
498
499
|
}
|
|
499
500
|
throw Error("loop exceeded limit");
|
|
500
|
-
},
|
|
501
|
+
}, ce = (e) => {
|
|
501
502
|
let t = () => BigInt.asUintN(64, e()), n = () => {
|
|
502
503
|
let e = t(), n = BigInt.asUintN(52, e >> 11n), r = n === 0n && e >> 63n == 1n ? Y(e, t) + 1n : Y(e, t), { buffer: i } = BigUint64Array.from([r << 52n | n]), a = new Float64Array(i)[0];
|
|
503
504
|
if (a == null) throw Error("unexpected");
|
|
@@ -510,23 +511,23 @@ var J = (e) => {
|
|
|
510
511
|
}
|
|
511
512
|
throw Error("Loop limit exceeded");
|
|
512
513
|
};
|
|
513
|
-
},
|
|
514
|
+
}, le = [9600629759793949339n, 15726070495360670683n], ue = 6364136223846793005n, X = "PCGMinimal", Z = class {
|
|
514
515
|
#e;
|
|
515
516
|
static name = X;
|
|
516
517
|
constructor(e) {
|
|
517
518
|
if (e && e[0] != null && e[1] != null) {
|
|
518
519
|
if (this.#e = new BigUint64Array(2), this.#e[0] == null || this.#e[1] == null) throw TypeError("unexpected");
|
|
519
520
|
this.#e[1] = e[1] << 1n | 1n, this.#t(), this.#e[0] += e[0], this.#t();
|
|
520
|
-
} else this.#e = BigUint64Array.from(
|
|
521
|
+
} else this.#e = BigUint64Array.from(le);
|
|
521
522
|
}
|
|
522
523
|
#t() {
|
|
523
524
|
if (this.#e[0] == null || this.#e[1] == null) throw TypeError("unexpected");
|
|
524
|
-
this.#e[0] = this.#e[0] *
|
|
525
|
+
this.#e[0] = this.#e[0] * ue + this.#e[1];
|
|
525
526
|
}
|
|
526
527
|
get #n() {
|
|
527
528
|
if (this.#e[0] == null || this.#e[1] == null) throw TypeError("unexpected");
|
|
528
529
|
let e = this.#e[0], t = Number(e >> 59n);
|
|
529
|
-
return
|
|
530
|
+
return w(Number(BigInt.asUintN(32, (e ^ e >> 18n) >> 27n)), t);
|
|
530
531
|
}
|
|
531
532
|
getRandU32 = () => (this.#t(), this.#n);
|
|
532
533
|
getBoundedRandU32 = (e) => {
|
|
@@ -548,7 +549,7 @@ var J = (e) => {
|
|
|
548
549
|
Object.defineProperty(Z.prototype, Symbol.toStringTag, { value: X });
|
|
549
550
|
//#endregion
|
|
550
551
|
//#region lib/xoshiro_minimal.ts
|
|
551
|
-
var
|
|
552
|
+
var de = [
|
|
552
553
|
13715198867125970446n,
|
|
553
554
|
3333371893450545919n,
|
|
554
555
|
5627726498316411518n,
|
|
@@ -561,16 +562,16 @@ var fe = [
|
|
|
561
562
|
if (e && e[0] != null && e[1] != null && e[2] != null && e[3] != null) {
|
|
562
563
|
if (this.#e = new BigUint64Array(4), this.#e[0] = e[0], this.#e[1] = e[1], this.#t(), this.#e[2] == null || this.#e[3] == null) throw TypeError("unexpected");
|
|
563
564
|
this.#e[2] += e[2], this.#e[3] += e[3];
|
|
564
|
-
} else this.#e = BigUint64Array.from(
|
|
565
|
+
} else this.#e = BigUint64Array.from(de);
|
|
565
566
|
}
|
|
566
567
|
#t() {
|
|
567
568
|
if (this.#e[0] == null || this.#e[1] == null || this.#e[2] == null || this.#e[3] == null) throw TypeError("unexpected");
|
|
568
569
|
let e = this.#e[1] << 17n;
|
|
569
|
-
this.#e[2] ^= this.#e[0], this.#e[3] ^= this.#e[1], this.#e[1] ^= this.#e[2], this.#e[0] ^= this.#e[3], this.#e[2] ^= e, this.#e[3] =
|
|
570
|
+
this.#e[2] ^= this.#e[0], this.#e[3] ^= this.#e[1], this.#e[1] ^= this.#e[2], this.#e[0] ^= this.#e[3], this.#e[2] ^= e, this.#e[3] = T(this.#e[3], 45n);
|
|
570
571
|
}
|
|
571
572
|
get value() {
|
|
572
573
|
if (this.#e[0] == null || this.#e[3] == null) throw TypeError("unexpected");
|
|
573
|
-
let e =
|
|
574
|
+
let e = T(this.#e[0] + this.#e[3], 23n) + this.#e[0];
|
|
574
575
|
return BigInt.asUintN(64, e);
|
|
575
576
|
}
|
|
576
577
|
getRandU64 = () => {
|
|
@@ -610,19 +611,19 @@ var fe = [
|
|
|
610
611
|
Object.defineProperty($.prototype, Symbol.toStringTag, { value: Q });
|
|
611
612
|
//#endregion
|
|
612
613
|
//#region lib/leb128.ts
|
|
613
|
-
var
|
|
614
|
+
var fe = (e) => {
|
|
614
615
|
let t = e < 0n;
|
|
615
616
|
t && (e *= -1n);
|
|
616
617
|
let n = e.toString(2).length, r = e === 1n << BigInt(n - 1) && !(n % 7) && t, i = Math.floor(n / 7) + 1;
|
|
617
618
|
return r ? i - 1 : i;
|
|
618
|
-
},
|
|
619
|
-
let t =
|
|
619
|
+
}, pe = (e) => {
|
|
620
|
+
let t = fe(e);
|
|
620
621
|
e = BigInt.asUintN(t * 7, e);
|
|
621
622
|
let n = new Uint8Array(t);
|
|
622
623
|
for (let r = 0; r < t - 1; ++r) n[r] = Number(e & 127n) | 128, e >>= 7n;
|
|
623
624
|
let r = Number(e & 127n);
|
|
624
625
|
return n[t - 1] = r, e >>= 7n, n;
|
|
625
|
-
},
|
|
626
|
+
}, me = (e) => {
|
|
626
627
|
let t = e.length, n = 0n;
|
|
627
628
|
for (let [t, r] of e.entries()) {
|
|
628
629
|
let e = BigInt(r & 127);
|
|
@@ -631,4 +632,4 @@ var pe = (e) => {
|
|
|
631
632
|
return BigInt.asIntN(7 * t, n);
|
|
632
633
|
};
|
|
633
634
|
//#endregion
|
|
634
|
-
export {
|
|
635
|
+
export { O as AsyncWorker, q as NamedError, Z as PCGMinimal, G as Rational, $ as XoshiroMinimal, R as bailliePSW, U as bailliePSWAsync, ie as compress, p as compressString, me as decodeLEB128, re as decodeRFC3986URIComponent, f as decompress, m as decompressString, pe as encodeLEB128, ne as encodeRFC3986URIComponent, S as exEuclidean, se as factorial, ce as floatRng, t as fromBase64, r as fromBase64URL, a as fromOct, d as getHash, y as getRandBIByBitLength, b as getRandBIByRange, B as getRandPrimeByBitLength, z as getRandPrimeByRange, _ as getRndInt, ee as getStringTag, s as isDeepStrictEqual, D as isSquare, E as jacobiSymbol, te as lazify, x as modPow, g as nullableStrictAt, u as parseCSV, j as postFailed, A as postSuccess, v as residue, w as rot32, T as rot64, o as sameValueZero, h as setTimeoutPromise, l as sleep, ae as strictAt, e as toBase64, n as toBase64URL, i as toOct, c as withResolvers };
|
package/dist/bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var UtilFns=(function(e){
|
|
2
|
-
`&&!i?(n.push(r.trim()),t.push(n),n=[],r=``):r+=o}return n.push(r.trim()),t.push(n),t},p=async(e,t)=>{let n=new TextEncoder().encode(e),r=await crypto.subtle.digest(t,n);return new Uint8Array(r)},re=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ie=e=>{if(e.includes(`+`))throw URIError("an input string must not include `+`");return decodeURIComponent(e)},m=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return new Response(n).bytes()},h=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new DecompressionStream(t));return new Response(n).bytes()},g=async(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return a(await new Response(n).bytes())},ae=(e,t)=>{let n=o(e),r=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(r).text()},oe=(e,t)=>new Promise((n,r)=>{setTimeout(async()=>{try{n(await e())}catch(e){r(e)}},t)}),_=(e,t)=>{if(t<-e.length||t>=e.length)throw RangeError("`index` is out of range");return e.at(t)},se=(e,t)=>{let n=_(e,t);if(n==null)throw TypeError(`value is nullable`);return n},v=(e,t)=>Math.floor(Math.random()*(t-e)+e),y=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},b=(e,t=!1)=>{if(!Number.isFinite(e))throw RangeError("`length` is not a valid number");if(e<=0)throw RangeError("`length` must be positive");let n=Math.ceil(e/8),r=crypto.getRandomValues(new Uint8Array(n)),i=Array.from(r,e=>e.toString(2).padStart(8,`0`)).join(``).slice(0,e);return t&&(i=i.replace(/^\d/,`1`)),BigInt(`0b`+i)},x=(e,t)=>{if(e>=t)throw RangeError("`min` must be smaller than `max`");let n=t-e,r=n.toString(2).length;return e+(()=>{for(let e=0;e<1e5;e++){let e=b(r);if(e>=S(2n,BigInt(r),n))return e%n}throw Error(`Failed to generate a random bigint`)})()},S=(e,t,n)=>{if(n<1n)throw RangeError("`mod` must be positive");if(t<0n)throw RangeError("`power` must not be negative");if(e=y(e,n),n===1n)return 0n;if(e%n===1n||e%n===0n)return e;if(e===n-1n)return t&1n?n-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*e%n),e=e*e%n,t>>=1n;return r},C=(e,t)=>{if(e===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(e===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return e>0n?{x:1n,y:0n,gcd:e}:{x:-1n,y:0n,gcd:-e};let[n,r,i]=[1n,0n,e],[a,o,s]=[0n,-1n,t];for(;;){let e=i/s,t=i-e*s;if(t===0n)break;[n,a]=[a,n-e*a],[r,o]=[o,r-e*o],[i,s]=[s,t]}return s<0n&&(a*=-1n,o*=-1n,s*=-1n),{x:a,y:o,gcd:s}},w=(e,t)=>{if(e>=t)return 1n;let n=BigInt((t-2n).toString(2).length),r=(t-e)/2n;if(n*r<63n){let n=e;for(let r=e+2n;r<t;r+=2n)n*=r;return n}let i=e+r|1n;return w(e,i)*w(i,t)},ce=e=>{let t=3n,n=1n,r=1n,i=BigInt(e.toString(2).length)-1n;for(let a=i-1n;a>-1n;--a){let i=(e>>a)+1n|1n;r*=w(t,i),t=i,n*=r}return n},le=e=>{if(e<0n)throw RangeError(`'n' must be non-negative`);if(e===0n)return 1n;let t=e-BigInt(e.toString(2).match(/1/g)?.length??0);return ce(e)<<t},T=(e,t)=>(e>>>(t&31)|e<<(-t&31))>>>0,E=(e,t)=>BigInt.asUintN(64,e>>(t&63n)|e<<(-t&63n)),D=(e,t)=>{if(t<1n||t%2n==0n)throw RangeError("`n` is out of range");for(;e<0n;)e+=t;e%=t;let n=1n;for(;e!==0n;){for(;e%2n==0n;){e/=2n;let r=t%8n;(r===3n||r===5n)&&(n*=-1n)}[e,t]=[t,e],e%4n==3n&&t%4n==3n&&(n*=-1n),e%=t}return t===1n?n:0n},O=e=>{if(e<0n)return!1;if(e===0n)return!0;let t=1n,n=e;for(;t+1n<n;){let r=(t+n)/2n;r*r<e?t=r:n=r}return e===t**2n||e===(t+1n)**2n},k=class{#e;constructor(e){this.#e=e}postMessage=(e,t)=>new Promise((n,r)=>{let i=crypto.randomUUID(),a=e=>{let t=e.data;t.id===i&&(this.#e.removeEventListener(`message`,a),this.#e.removeEventListener(`error`,o),t.success?n(t.value):r(t.error))},o=e=>{this.#e.removeEventListener(`message`,a),this.#e.removeEventListener(`error`,o),r(e.error)};this.#e.addEventListener(`message`,a),this.#e.addEventListener(`error`,o);let s={value:e,id:i};this.#e.postMessage(s,t)})},A=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,j=(e,t)=>{if(!A())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},M=(e,t)=>{if(!A())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},N=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;let t=e-1n,n=0n;for(;t%2n==0n;)t>>=1n,n+=1n;let[r,i]=[t,n],a=S(2n,r,e);if(a===1n)return!0;for(let t=0n;t<i;t++){if(a===e-1n)return!0;a=a*a%e}return!1},P=e=>{let t=5n,n=D(t,e);for(;n>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&O(e))return[0n,0n];n=D(t,e)}return[t,n]},F=(e,t)=>(e&1n)==1n?y(e+t>>1n,t):y(e>>1n,t),I=(e,t,n,r)=>{let i=1n,a=n,o=e.toString(2).slice(1);for(let e of o)[i,a]=[y(i*a,t),F(a*a+r*i*i,t)],e===`1`&&([i,a]=[F(n*i+a,t),F(r*i+n*a,t)]);return[i,a]},L=(e,t,n,r)=>{if(e%2n!=1n)throw RangeError("`n` must be odd");let i=e+1n,a=0n;for(;i%2n==0n;)i>>=1n,a+=1n;let[o,s]=I(i,e,n,t),c=s;if(o===0n)return!0;r=S(r,i,e);for(let t=0n;t<a;t++){if(c===0n)return!0;c=y(c*c-2n*r,e),r=S(r,2n,e)}return!1},R=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n])if(e%t===0n)return e===t;if(!N(e))return!1;let[t,n]=P(e);return n===0n?!1:L(e,t,1n,(1n-t)/4n)},z=(e,t)=>{if(t<2n)throw RangeError("`max` must be 2 or larger");for(let n=0;n<1e5;n++){let n=x(e,t);if(R(n))return n}throw Error(`no primes were found`)},B=(e,t=!1)=>{if(e<2)throw RangeError("`bitLength` must be 2 or larger");for(let n=0;n<1e5;n++){let n=b(e,t);if(R(n))return n}throw Error(`no primes were found`)},V,H=()=>(V||=new k(new Worker(new URL(`/assets/bpsw_worker-B1aaSJNb.js`,``+n.url),{type:`module`})),V),U=e=>H().postMessage(e),W=`Rational`,G=class e{#e;#t;static name=W;constructor(e,t){t===0n?(this.#t=0n,this.#e=e===0n?0n:e>0n?1n:-1n):t>0n?(this.#e=e,this.#t=t):(this.#e=-e,this.#t=-t),this.#n()}static fromDecimal(t,n=5){if(Number.isNaN(t))return new e(0n,0n);if(Math.abs(t)===1/0)return new e(t>0?1n:-1n,0n);let r=t<0;r&&(t*=-1);let i=BigInt(Math.floor(t)),a=t-Number(i);if(a===0)return new e(r?-i:i,1n);t=1/a;let[o,s]=[1n,i],[c,l]=[0n,1n];for(;`${l}`.length<=n;){let n=BigInt(Math.floor(t)),i=t-Number(n);if([o,s]=[s,n*s+o],[c,l]=[l,n*l+c],i===0)return new e(r?-s:s,l);t=1/i}return new e(r?-o:o,c)}#n(){let{gcd:e}=C(this.#e,this.#t);e!==0n&&(this.#e/=e,this.#t/=e)}minus=()=>new e(-this.#e,this.#t);inverse=()=>new e(this.#t,this.#e);add=t=>{let n=this.#t*t.#t;return new e(this.#e*t.#t+t.#e*this.#t,n)};substr=e=>this.add(e.minus());multiply=t=>{let n=this.#t*t.#t;return new e(this.#e*t.#e,n)};divide=e=>this.multiply(e.inverse());mediant=t=>{let n=this.#t+t.#t;return new e(this.#e+t.#e,n)};toDecimal=()=>Number(this.#e)/Number(this.#t);toString=()=>this.#e===0n&&this.#t===0n?`NaN`:this.#e===0n?`0`:this.#t===0n?this.#e<0n?`-Infinity`:`Infinity`:this.#t===1n?`${this.#e}`:`${this.#e}/${this.#t}`;valueOf=()=>this.toDecimal();toJSON=()=>({type:`Rational`,value:[`0x`+this.#e.toString(16),`0x`+this.#t.toString(16)]});static fromData(t){return new e(BigInt(t.value[0]),BigInt(t.value[1]))}static parse(t){let n=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!n)throw Error(`cannot parse`);let r=n.at(1),i=n.at(2);if(!r||!i)throw Error(`cannot parse`);return new e(BigInt(r),BigInt(i))}};Object.defineProperty(G.prototype,Symbol.toStringTag,{value:W});var K=`NamedError`,q=class extends Error{static name=K;errName;constructor(e,t,n){super(t,n),this.errName=e}toJSON=()=>{let e=(()=>{let e=this.cause;if(e==null)return e;let t=e.toString();return t===`[object Object]`?JSON.stringify(e):t})(),{errName:t,message:n,stack:r}=this;return{name:t,message:n,stack:r,cause:e}}};Object.defineProperty(q.prototype,Symbol.toStringTag,{value:K});var J=e=>{if(e===0n)return 64n;let t=0n;for(;e>0n&&!(e&1n);)++t,e>>=1n;return BigInt.asUintN(64,t)},Y=(e,t)=>{let n=0n,r=e&2047n,i=1023n-1n;if(r>0n)return i-=J(r),i;i-=11n;for(let e=0;e<1e5;++e){let e=t();if(e>0n)return i-=J(e),i;if(i-=64n,i<n)return n}throw Error(`loop exceeded limit`)},ue=e=>{let t=()=>BigInt.asUintN(64,e()),n=()=>{let e=t(),n=BigInt.asUintN(52,e>>11n),r=n===0n&&e>>63n==1n?Y(e,t)+1n:Y(e,t),{buffer:i}=BigUint64Array.from([r<<52n|n]),a=new Float64Array(i)[0];if(a==null)throw Error(`unexpected`);return a};return()=>{for(let e=0;e<1e5;++e){let e=n();if(e<1)return e}throw Error(`Loop limit exceeded`)}},de=[9600629759793949339n,15726070495360670683n],fe=6364136223846793005n,X=`PCGMinimal`,Z=class{#e;static name=X;constructor(e){if(e&&e[0]!=null&&e[1]!=null){if(this.#e=new BigUint64Array(2),this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[1]=e[1]<<1n|1n,this.#t(),this.#e[0]+=e[0],this.#t()}else this.#e=BigUint64Array.from(de)}#t(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[0]=this.#e[0]*fe+this.#e[1]}get#n(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);let e=this.#e[0],t=Number(e>>59n);return T(Number(BigInt.asUintN(32,(e^e>>18n)>>27n)),t)}getRandU32=()=>(this.#t(),this.#n);getBoundedRandU32=e=>{let t=4294967296;if(e>t)throw RangeError("`bound` exceeded limit (2^32)");if(e<=0)throw RangeError(`'bound' must be positive`);let n=t%e;for(let t=0;t<1e5;++t){let t=this.getRandU32();if(t>=n)return t%e}throw Error(`exceeded loop limit`)};*genRandU32s(e,t){if(e<=0)throw RangeError(`'step' must be positive`);for(let n=0;n<e;n++)yield typeof t==`number`?this.getBoundedRandU32(t):this.getRandU32()}};Object.defineProperty(Z.prototype,Symbol.toStringTag,{value:X});var pe=[13715198867125970446n,3333371893450545919n,5627726498316411518n,8467276975966080893n],Q=`XoshiroMinimal`,$=class{bits=64;#e;static name=Q;constructor(e){if(e&&e[0]!=null&&e[1]!=null&&e[2]!=null&&e[3]!=null){if(this.#e=new BigUint64Array(4),this.#e[0]=e[0],this.#e[1]=e[1],this.#t(),this.#e[2]==null||this.#e[3]==null)throw TypeError(`unexpected`);this.#e[2]+=e[2],this.#e[3]+=e[3]}else this.#e=BigUint64Array.from(pe)}#t(){if(this.#e[0]==null||this.#e[1]==null||this.#e[2]==null||this.#e[3]==null)throw TypeError(`unexpected`);let e=this.#e[1]<<17n;this.#e[2]^=this.#e[0],this.#e[3]^=this.#e[1],this.#e[1]^=this.#e[2],this.#e[0]^=this.#e[3],this.#e[2]^=e,this.#e[3]=E(this.#e[3],45n)}get value(){if(this.#e[0]==null||this.#e[3]==null)throw TypeError(`unexpected`);let e=E(this.#e[0]+this.#e[3],23n)+this.#e[0];return BigInt.asUintN(64,e)}getRandU64=()=>{let e=this.value;return this.#t(),e};getRandU32=()=>{let e=BigInt.asUintN(32,this.getRandU64());return Number(e)};getBoundedRandU64=e=>{let t=1n<<64n;if(e>t)throw RangeError("`bound` exceeded limit");if(e<=0n)throw RangeError("`bound` must be positive");let n=t%e;for(let t=0;t<1e5;++t){let t=this.getRandU64();if(t>=n)return t%e}throw Error(`exceeded loop limit`)};getBoundedRandU32=e=>{if(e>2**32)throw RangeError("`bound` exceeded limit");if(e<=0n)throw RangeError("`bound` must be positive");let t=this.getBoundedRandU64(BigInt(e));return Number(t)};*genRandU64s(e,t){if(e<=0)throw RangeError("`step` must be positive");for(let n=0;n<e;++n)yield t===void 0?this.getRandU64():this.getBoundedRandU64(t)}*genRandU32s(e,t){if(e<=0)throw RangeError("`step` must be positive");for(let n=0;n<e;++n)yield t===void 0?this.getRandU32():this.getBoundedRandU32(t)}};Object.defineProperty($.prototype,Symbol.toStringTag,{value:Q});var me=e=>{let t=e<0n;t&&(e*=-1n);let n=e.toString(2).length,r=e===1n<<BigInt(n-1)&&!(n%7)&&t,i=Math.floor(n/7)+1;return r?i-1:i};return e.AsyncWorker=k,e.NamedError=q,e.PCGMinimal=Z,e.Rational=G,e.XoshiroMinimal=$,e.bailliePSW=R,e.bailliePSWAsync=U,e.compress=m,e.compressString=g,e.decodeLEB128=e=>{let t=e.length,n=0n;for(let[t,r]of e.entries()){let e=BigInt(r&127);n+=e<<BigInt(7*t)}return BigInt.asIntN(7*t,n)},e.decodeRFC3986URIComponent=ie,e.decompress=h,e.decompressString=ae,e.encodeLEB128=e=>{let t=me(e);e=BigInt.asUintN(t*7,e);let n=new Uint8Array(t);for(let r=0;r<t-1;++r)n[r]=Number(e&127n)|128,e>>=7n;let r=Number(e&127n);return n[t-1]=r,e>>=7n,n},e.encodeRFC3986URIComponent=re,e.exEuclidean=C,e.factorial=le,e.floatRng=ue,e.fromBase64=i,e.fromBase64URL=o,e.fromOct=c,e.getHash=p,e.getRandBIByBitLength=b,e.getRandBIByRange=x,e.getRandPrimeByBitLength=B,e.getRandPrimeByRange=z,e.getRndInt=v,e.getStringTag=te,e.isDeepStrictEqual=u,e.isSquare=O,e.jacobiSymbol=D,e.lazify=ne,e.modPow=S,e.nullableStrictAt=_,e.parseCSV=f,e.postFailed=M,e.postSuccess=j,e.residue=y,e.rot32=T,e.rot64=E,e.sameValueZero=l,e.setTimeoutPromise=oe,e.sleep=ee,e.strictAt=se,e.toBase64=r,e.toBase64URL=a,e.toOct=s,e.withResolvers=d,e})({});
|
|
1
|
+
var UtilFns=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=e=>{let t=Array.from(e,e=>String.fromCharCode(e));return btoa(t.join(``))},n=e=>{let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))},r=e=>t(e).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``),i=e=>{let t=4-(e.length&3)&3;return n(e.concat(`=`.repeat(t)).replaceAll(`-`,`+`).replaceAll(`_`,`/`))},a=e=>{let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``),n=(6-t.length%6)%6,r=`0`.repeat(n).concat(t).matchAll(/.{6}/g);return Array.from(r,e=>Number.parseInt(e[0],16).toString(8).padStart(8,`0`)).join(``).replace(/^0+/,``)},o=e=>{let t=8-(e.length&7)&7,n=`0`.repeat(t).concat(e).matchAll(/.{8}/g),r=Array.from(n,e=>Number.parseInt(e[0],8).toString(16).padStart(6,`0`)).join(``).matchAll(/.{2}/g);return Uint8Array.from(r,e=>Number.parseInt(e[0],16))},s=(e,t)=>[e].includes(t),c=(e,t)=>{if(typeof e!=typeof t)return!1;let n=Object.prototype.toString.call(e);if(n!==Object.prototype.toString.call(t))return!1;if(typeof e==`string`||typeof e==`bigint`||typeof e==`boolean`||typeof e==`symbol`||e==null)return e===t;if(typeof e==`number`)return e!==e&&t!==t||e===t;if(typeof e==`function`)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!c(e[n],t[n]))return!1;return!0}if(e instanceof Set&&t instanceof Set)return!!c([...e.values()],[...t.values()]);if(e instanceof Map&&t instanceof Map)return!(!c([...e.keys()],[...t.keys()])||!c([...e.values()],[...t.values()]));if(n===`[object Object]`){let n=e,r=t,i=Object.keys(n),a=Object.keys(r);for(let e of i){let t=a.find(t=>t===e);if(t===void 0)return!1;let[i,o]=[n[e],r[t]];if(!c(i,o))return!1}return!0}throw TypeError(`comparing these objects is unavailable: ${e}, ${t}`,{cause:[e,t]})},l=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},ee=e=>new Promise(t=>setTimeout(t,e)),te=e=>Object.prototype.toString.call(e).slice(8,-1),u=e=>(...t)=>()=>e(...t),ne=e=>{let t=[],n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a];o===`"`&&(a===0||e[a-1]!==`\\`)?i=!i:o===`,`&&!i?(n.push(r.trim()),r=``):o===`
|
|
2
|
+
`&&!i?(n.push(r.trim()),t.push(n),n=[],r=``):r+=o}return n.push(r.trim()),t.push(n),t},re=async(e,t)=>{let n=new TextEncoder().encode(e),r=await crypto.subtle.digest(t,n);return new Uint8Array(r)},ie=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),d=e=>{if(e.includes(`+`))throw URIError("an input string must not include `+`");return decodeURIComponent(e)},f=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return new Response(n).bytes()},ae=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new DecompressionStream(t));return new Response(n).bytes()},p=async(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return r(await new Response(n).bytes())},m=(e,t)=>{let n=i(e),r=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(r).text()},h=(e,t)=>new Promise((n,r)=>{setTimeout(async()=>{try{n(await e())}catch(e){r(e)}},t)}),g=(e,t)=>{if(t<-e.length||t>=e.length)throw RangeError("`index` is out of range");return e.at(t)},_=(e,t)=>{let n=g(e,t);if(n==null)throw TypeError(`value is nullable`);return n},oe=(e,t)=>Math.floor(Math.random()*(t-e)+e),v=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},y=(e,t=!1)=>{if(!Number.isFinite(e))throw RangeError("`length` is not a valid number");if(e<=0)throw RangeError("`length` must be positive");let n=Math.ceil(e/8),r=crypto.getRandomValues(new Uint8Array(n)),i=Array.from(r,e=>e.toString(2).padStart(8,`0`)).join(``).slice(0,e);return t&&(i=i.replace(/^\d/,`1`)),BigInt(`0b`+i)},b=(e,t)=>{if(e>=t)throw RangeError("`min` must be smaller than `max`");let n=t-e,r=n.toString(2).length;return e+(()=>{for(let e=0;e<1e5;e++){let e=y(r);if(e>=x(2n,BigInt(r),n))return e%n}throw Error(`Failed to generate a random bigint`)})()},x=(e,t,n)=>{if(n<1n)throw RangeError("`mod` must be positive");if(t<0n)throw RangeError("`power` must not be negative");if(e=v(e,n),n===1n)return 0n;if(e%n===1n||e%n===0n)return e;if(e===n-1n)return t&1n?n-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*e%n),e=e*e%n,t>>=1n;return r},S=(e,t)=>{if(e===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(e===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return e>0n?{x:1n,y:0n,gcd:e}:{x:-1n,y:0n,gcd:-e};let[n,r,i]=[1n,0n,e],[a,o,s]=[0n,-1n,t];for(;;){let e=i/s,t=i-e*s;if(t===0n)break;[n,a]=[a,n-e*a],[r,o]=[o,r-e*o],[i,s]=[s,t]}return s<0n&&(a*=-1n,o*=-1n,s*=-1n),{x:a,y:o,gcd:s}},C=(e,t)=>{if(e>=t)return 1n;let n=BigInt((t-2n).toString(2).length),r=(t-e)/2n;if(n*r<63n){let n=e;for(let r=e+2n;r<t;r+=2n)n*=r;return n}let i=e+r|1n;return C(e,i)*C(i,t)},se=e=>{let t=3n,n=1n,r=1n,i=BigInt(e.toString(2).length)-1n;for(let a=i-1n;a>-1n;--a){let i=(e>>a)+1n|1n;r*=C(t,i),t=i,n*=r}return n},ce=e=>{if(e<0n)throw RangeError(`'n' must be non-negative`);if(e===0n)return 1n;let t=e-BigInt(e.toString(2).match(/1/g)?.length??0);return se(e)<<t},w=(e,t)=>(e>>>(t&31)|e<<(-t&31))>>>0,T=(e,t)=>BigInt.asUintN(64,e>>(t&63n)|e<<(-t&63n)),E=(e,t)=>{if(t<1n||t%2n==0n)throw RangeError("`n` is out of range");for(;e<0n;)e+=t;e%=t;let n=1n;for(;e!==0n;){for(;e%2n==0n;){e/=2n;let r=t%8n;(r===3n||r===5n)&&(n*=-1n)}[e,t]=[t,e],e%4n==3n&&t%4n==3n&&(n*=-1n),e%=t}return t===1n?n:0n},D=e=>{if(e<0n)return!1;if(e===0n)return!0;let t=1n,n=e;for(;t+1n<n;){let r=(t+n)/2n;r*r<e?t=r:n=r}return e===t**2n||e===(t+1n)**2n},O=class{#e;constructor(e){this.#e=e}postMessage=(e,t)=>new Promise((n,r)=>{let i=crypto.randomUUID(),a=e=>{let t=e.data;t.id===i&&(this.#e.removeEventListener(`message`,a),this.#e.removeEventListener(`error`,o),t.success?n(t.value):r(t.error))},o=e=>{this.#e.removeEventListener(`message`,a),this.#e.removeEventListener(`error`,o),r(e.error)};this.#e.addEventListener(`message`,a),this.#e.addEventListener(`error`,o);let s={value:e,id:i};this.#e.postMessage(s,t)})},k=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,A=(e,t)=>{if(!k())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},j=(e,t)=>{if(!k())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},M=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;let t=e-1n,n=0n;for(;t%2n==0n;)t>>=1n,n+=1n;let[r,i]=[t,n],a=x(2n,r,e);if(a===1n)return!0;for(let t=0n;t<i;t++){if(a===e-1n)return!0;a=a*a%e}return!1},N=e=>{let t=5n,n=E(t,e);for(;n>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&D(e))return[0n,0n];n=E(t,e)}return[t,n]},P=(e,t)=>(e&1n)==1n?v(e+t>>1n,t):v(e>>1n,t),F=(e,t,n,r)=>{let i=1n,a=n,o=e.toString(2).slice(1);for(let e of o)[i,a]=[v(i*a,t),P(a*a+r*i*i,t)],e===`1`&&([i,a]=[P(n*i+a,t),P(r*i+n*a,t)]);return[i,a]},I=(e,t,n,r)=>{if(e%2n!=1n)throw RangeError("`n` must be odd");let i=e+1n,a=0n;for(;i%2n==0n;)i>>=1n,a+=1n;let[o,s]=F(i,e,n,t),c=s;if(o===0n)return!0;r=x(r,i,e);for(let t=0n;t<a;t++){if(c===0n)return!0;c=v(c*c-2n*r,e),r=x(r,2n,e)}return!1},L=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n],R=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of L)if(e%t===0n)return e===t;if(!M(e))return!1;let[t,n]=N(e);return n===0n?!1:I(e,t,1n,(1n-t)/4n)},z=(e,t)=>{if(t<2n)throw RangeError("`max` must be 2 or larger");for(let n=0;n<1e5;n++){let n=b(e,t);if(R(n))return n}throw Error(`no primes were found`)},B=(e,t=!1)=>{if(e<2)throw RangeError("`bitLength` must be 2 or larger");for(let n=0;n<1e5;n++){let n=y(e,t);if(R(n))return n}throw Error(`no primes were found`)},V,H=()=>(V||=new O(new Worker(new URL(`/assets/bpsw_worker-nJV3KnVo.js`,``+{}.url),{type:`module`})),V),U=e=>H().postMessage(e),W=`Rational`,G=class e{#e;#t;static name=W;constructor(e,t){t===0n?(this.#t=0n,this.#e=e===0n?0n:e>0n?1n:-1n):t>0n?(this.#e=e,this.#t=t):(this.#e=-e,this.#t=-t),this.#n()}static fromDecimal(t,n=5){if(Number.isNaN(t))return new e(0n,0n);if(Math.abs(t)===1/0)return new e(t>0?1n:-1n,0n);let r=t<0;r&&(t*=-1);let i=BigInt(Math.floor(t)),a=t-Number(i);if(a===0)return new e(r?-i:i,1n);t=1/a;let[o,s]=[1n,i],[c,l]=[0n,1n];for(;`${l}`.length<=n;){let n=BigInt(Math.floor(t)),i=t-Number(n);if([o,s]=[s,n*s+o],[c,l]=[l,n*l+c],i===0)return new e(r?-s:s,l);t=1/i}return new e(r?-o:o,c)}#n(){let{gcd:e}=S(this.#e,this.#t);e!==0n&&(this.#e/=e,this.#t/=e)}minus=()=>new e(-this.#e,this.#t);inverse=()=>new e(this.#t,this.#e);add=t=>{let n=this.#t*t.#t;return new e(this.#e*t.#t+t.#e*this.#t,n)};substr=e=>this.add(e.minus());multiply=t=>{let n=this.#t*t.#t;return new e(this.#e*t.#e,n)};divide=e=>this.multiply(e.inverse());mediant=t=>{let n=this.#t+t.#t;return new e(this.#e+t.#e,n)};toDecimal=()=>Number(this.#e)/Number(this.#t);toString=()=>this.#e===0n&&this.#t===0n?`NaN`:this.#e===0n?`0`:this.#t===0n?this.#e<0n?`-Infinity`:`Infinity`:this.#t===1n?`${this.#e}`:`${this.#e}/${this.#t}`;valueOf=()=>this.toDecimal();toJSON=()=>({type:`Rational`,value:[`0x`+this.#e.toString(16),`0x`+this.#t.toString(16)]});static fromData(t){return new e(BigInt(t.value[0]),BigInt(t.value[1]))}static parse(t){let n=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!n)throw Error(`cannot parse`);let r=n.at(1),i=n.at(2);if(!r||!i)throw Error(`cannot parse`);return new e(BigInt(r),BigInt(i))}};Object.defineProperty(G.prototype,Symbol.toStringTag,{value:W});var K=`NamedError`,q=class extends Error{static name=K;errName;constructor(e,t,n){super(t,n),this.errName=e}toJSON=()=>{let e=(()=>{let e=this.cause;if(e==null)return e;let t=e.toString();return t===`[object Object]`?JSON.stringify(e):t})(),{errName:t,message:n,stack:r}=this;return{name:t,message:n,stack:r,cause:e}}};Object.defineProperty(q.prototype,Symbol.toStringTag,{value:K});var J=e=>{if(e===0n)return 64n;let t=0n;for(;e>0n&&!(e&1n);)++t,e>>=1n;return BigInt.asUintN(64,t)},Y=(e,t)=>{let n=0n,r=e&2047n,i=1023n-1n;if(r>0n)return i-=J(r),i;i-=11n;for(let e=0;e<1e5;++e){let e=t();if(e>0n)return i-=J(e),i;if(i-=64n,i<n)return n}throw Error(`loop exceeded limit`)},le=e=>{let t=()=>BigInt.asUintN(64,e()),n=()=>{let e=t(),n=BigInt.asUintN(52,e>>11n),r=n===0n&&e>>63n==1n?Y(e,t)+1n:Y(e,t),{buffer:i}=BigUint64Array.from([r<<52n|n]),a=new Float64Array(i)[0];if(a==null)throw Error(`unexpected`);return a};return()=>{for(let e=0;e<1e5;++e){let e=n();if(e<1)return e}throw Error(`Loop limit exceeded`)}},ue=[9600629759793949339n,15726070495360670683n],de=6364136223846793005n,X=`PCGMinimal`,Z=class{#e;static name=X;constructor(e){if(e&&e[0]!=null&&e[1]!=null){if(this.#e=new BigUint64Array(2),this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[1]=e[1]<<1n|1n,this.#t(),this.#e[0]+=e[0],this.#t()}else this.#e=BigUint64Array.from(ue)}#t(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[0]=this.#e[0]*de+this.#e[1]}get#n(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);let e=this.#e[0],t=Number(e>>59n);return w(Number(BigInt.asUintN(32,(e^e>>18n)>>27n)),t)}getRandU32=()=>(this.#t(),this.#n);getBoundedRandU32=e=>{let t=4294967296;if(e>t)throw RangeError("`bound` exceeded limit (2^32)");if(e<=0)throw RangeError(`'bound' must be positive`);let n=t%e;for(let t=0;t<1e5;++t){let t=this.getRandU32();if(t>=n)return t%e}throw Error(`exceeded loop limit`)};*genRandU32s(e,t){if(e<=0)throw RangeError(`'step' must be positive`);for(let n=0;n<e;n++)yield typeof t==`number`?this.getBoundedRandU32(t):this.getRandU32()}};Object.defineProperty(Z.prototype,Symbol.toStringTag,{value:X});var fe=[13715198867125970446n,3333371893450545919n,5627726498316411518n,8467276975966080893n],Q=`XoshiroMinimal`,$=class{bits=64;#e;static name=Q;constructor(e){if(e&&e[0]!=null&&e[1]!=null&&e[2]!=null&&e[3]!=null){if(this.#e=new BigUint64Array(4),this.#e[0]=e[0],this.#e[1]=e[1],this.#t(),this.#e[2]==null||this.#e[3]==null)throw TypeError(`unexpected`);this.#e[2]+=e[2],this.#e[3]+=e[3]}else this.#e=BigUint64Array.from(fe)}#t(){if(this.#e[0]==null||this.#e[1]==null||this.#e[2]==null||this.#e[3]==null)throw TypeError(`unexpected`);let e=this.#e[1]<<17n;this.#e[2]^=this.#e[0],this.#e[3]^=this.#e[1],this.#e[1]^=this.#e[2],this.#e[0]^=this.#e[3],this.#e[2]^=e,this.#e[3]=T(this.#e[3],45n)}get value(){if(this.#e[0]==null||this.#e[3]==null)throw TypeError(`unexpected`);let e=T(this.#e[0]+this.#e[3],23n)+this.#e[0];return BigInt.asUintN(64,e)}getRandU64=()=>{let e=this.value;return this.#t(),e};getRandU32=()=>{let e=BigInt.asUintN(32,this.getRandU64());return Number(e)};getBoundedRandU64=e=>{let t=1n<<64n;if(e>t)throw RangeError("`bound` exceeded limit");if(e<=0n)throw RangeError("`bound` must be positive");let n=t%e;for(let t=0;t<1e5;++t){let t=this.getRandU64();if(t>=n)return t%e}throw Error(`exceeded loop limit`)};getBoundedRandU32=e=>{if(e>2**32)throw RangeError("`bound` exceeded limit");if(e<=0n)throw RangeError("`bound` must be positive");let t=this.getBoundedRandU64(BigInt(e));return Number(t)};*genRandU64s(e,t){if(e<=0)throw RangeError("`step` must be positive");for(let n=0;n<e;++n)yield t===void 0?this.getRandU64():this.getBoundedRandU64(t)}*genRandU32s(e,t){if(e<=0)throw RangeError("`step` must be positive");for(let n=0;n<e;++n)yield t===void 0?this.getRandU32():this.getBoundedRandU32(t)}};Object.defineProperty($.prototype,Symbol.toStringTag,{value:Q});var pe=e=>{let t=e<0n;t&&(e*=-1n);let n=e.toString(2).length,r=e===1n<<BigInt(n-1)&&!(n%7)&&t,i=Math.floor(n/7)+1;return r?i-1:i};return e.AsyncWorker=O,e.NamedError=q,e.PCGMinimal=Z,e.Rational=G,e.XoshiroMinimal=$,e.bailliePSW=R,e.bailliePSWAsync=U,e.compress=f,e.compressString=p,e.decodeLEB128=e=>{let t=e.length,n=0n;for(let[t,r]of e.entries()){let e=BigInt(r&127);n+=e<<BigInt(7*t)}return BigInt.asIntN(7*t,n)},e.decodeRFC3986URIComponent=d,e.decompress=ae,e.decompressString=m,e.encodeLEB128=e=>{let t=pe(e);e=BigInt.asUintN(t*7,e);let n=new Uint8Array(t);for(let r=0;r<t-1;++r)n[r]=Number(e&127n)|128,e>>=7n;let r=Number(e&127n);return n[t-1]=r,e>>=7n,n},e.encodeRFC3986URIComponent=ie,e.exEuclidean=S,e.factorial=ce,e.floatRng=le,e.fromBase64=n,e.fromBase64URL=i,e.fromOct=o,e.getHash=re,e.getRandBIByBitLength=y,e.getRandBIByRange=b,e.getRandPrimeByBitLength=B,e.getRandPrimeByRange=z,e.getRndInt=oe,e.getStringTag=te,e.isDeepStrictEqual=c,e.isSquare=D,e.jacobiSymbol=E,e.lazify=u,e.modPow=x,e.nullableStrictAt=g,e.parseCSV=ne,e.postFailed=j,e.postSuccess=A,e.residue=v,e.rot32=w,e.rot64=T,e.sameValueZero=s,e.setTimeoutPromise=h,e.sleep=ee,e.strictAt=_,e.toBase64=t,e.toBase64URL=r,e.toOct=a,e.withResolvers=l,e})({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tktb-tess/util-fns",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Utility functions for personal use",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@types/node": "^25.5.2",
|
|
30
30
|
"typescript": "^6.0.2",
|
|
31
31
|
"unplugin-dts": "1.0.0-beta.6",
|
|
32
|
-
"vite": "^8.0.
|
|
33
|
-
"vitest": "^4.1.
|
|
32
|
+
"vite": "^8.0.8",
|
|
33
|
+
"vitest": "^4.1.4"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "vite",
|