@tktb-tess/util-fns 0.13.2 → 0.13.3

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/esm/index.js CHANGED
@@ -13,6 +13,6 @@ import { decodeLEB128 as j, encodeLEB128 as M } from "./leb128.js";
13
13
  import { NamedError as N } from "./named_error.js";
14
14
  import { fromOct as P, toOct as F } from "./oct.js";
15
15
  import { PCGMinimal as I } from "./pcg_minimal.js";
16
- import { decodeRFC3986URIComponent as L, encodeRFC3986URIComponent as R, getHash as z, getStringTag as B, lazify as V, nullableStrictAt as H, setTimeoutPromise as U, sleepSort as W, strictAt as G, withResolvers as K } from "./util.js";
17
- import { XoshiroMinimal as q } from "./xoshiro_minimal.js";
18
- export { e as AsyncWorker, A as FixedUint8Array, N as NamedError, I as PCGMinimal, k as Rational, q as XoshiroMinimal, h as bailliePSW, g as bailliePSWAsync, C as compress, w as compressString, j as decodeLEB128, L as decodeRFC3986URIComponent, T as decompress, E as decompressString, M as encodeLEB128, R as encodeRFC3986URIComponent, a as exEuclidean, o as factorial, d as floatRng, y as fromBase64, b as fromBase64URL, P as fromOct, z as getHash, f as getRandBIByBitLength, p as getRandBIByRange, _ as getRandPrimeByBitLength, v as getRandPrimeByRange, m as getRndInt, B as getStringTag, D as isDeepStrictEqual, s as isSquare, c as jacobiSymbol, V as lazify, i as modPow, H as nullableStrictAt, t as postFailed, n as postSuccess, r as residue, l as rot32, u as rot64, O as sameValueZero, U as setTimeoutPromise, W as sleepSort, G as strictAt, x as toBase64, S as toBase64URL, F as toOct, K as withResolvers };
16
+ import { createWorker as L, decodeRFC3986URIComponent as R, encodeRFC3986URIComponent as z, getHash as B, getStringTag as V, lazify as H, nullableStrictAt as U, setTimeoutPromise as W, sleepSort as G, strictAt as K, withResolvers as q } from "./util.js";
17
+ import { XoshiroMinimal as J } from "./xoshiro_minimal.js";
18
+ export { e as AsyncWorker, A as FixedUint8Array, N as NamedError, I as PCGMinimal, k as Rational, J as XoshiroMinimal, h as bailliePSW, g as bailliePSWAsync, C as compress, w as compressString, L as createWorker, j as decodeLEB128, R as decodeRFC3986URIComponent, T as decompress, E as decompressString, M as encodeLEB128, z as encodeRFC3986URIComponent, a as exEuclidean, o as factorial, d as floatRng, y as fromBase64, b as fromBase64URL, P as fromOct, B as getHash, f as getRandBIByBitLength, p as getRandBIByRange, _ as getRandPrimeByBitLength, v as getRandPrimeByRange, m as getRndInt, V as getStringTag, D as isDeepStrictEqual, s as isSquare, c as jacobiSymbol, H as lazify, i as modPow, U as nullableStrictAt, t as postFailed, n as postSuccess, r as residue, l as rot32, u as rot64, O as sameValueZero, W as setTimeoutPromise, G as sleepSort, K as strictAt, x as toBase64, S as toBase64URL, F as toOct, q as withResolvers };
@@ -66,3 +66,4 @@ export declare const strictAt: <T extends {}>(array: T[], index: number) => T;
66
66
  * @returns
67
67
  */
68
68
  export declare const sleepSort: (array: number[]) => Promise<number[]>;
69
+ export declare const createWorker: (onmessage: (ev: MessageEvent<unknown>) => void, onerror?: (ev: ErrorEvent) => void) => Worker;
package/dist/esm/util.js CHANGED
@@ -39,6 +39,9 @@ var e = () => {
39
39
  });
40
40
  n.push(r);
41
41
  }), await Promise.all(n), t;
42
+ }, u = (e, t) => {
43
+ let n = `data:text/javascript;charset=UTF-8,${i(`(()=>{${`self.onmessage=${e};`}${t ? `self.onerror=${t};` : ""}})();`.replace(/\s+/g, " "))}`;
44
+ return new Worker(n);
42
45
  };
43
46
  //#endregion
44
- export { a as decodeRFC3986URIComponent, i as encodeRFC3986URIComponent, r as getHash, t as getStringTag, n as lazify, s as nullableStrictAt, o as setTimeoutPromise, l as sleepSort, c as strictAt, e as withResolvers };
47
+ export { u as createWorker, a as decodeRFC3986URIComponent, i as encodeRFC3986URIComponent, r as getHash, t as getStringTag, n as lazify, s as nullableStrictAt, o as setTimeoutPromise, l as sleepSort, c as strictAt, e as withResolvers };
@@ -1 +1 @@
1
- var UtilFns=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,t)=>()=>(e&&(t=e(e=0)),t),r=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},i=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},a=e=>Object.prototype.toString.call(e).slice(8,-1),o=e=>(...t)=>()=>e(...t),s=async(e,t,n)=>{let r=(n??new TextEncoder).encode(e),i=await crypto.subtle.digest(t,r);return new Uint8Array(i)},c=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),l=e=>{if(e.includes(`+`))throw URIError("an input string must not include `+`");return decodeURIComponent(e)},u=(e,t)=>new Promise((n,r)=>{setTimeout(async()=>{try{n(await e())}catch(e){r(e)}},t)}),d=(e,t)=>{if(t<-e.length||t>=e.length)throw RangeError("`index` is out of range");return e.at(t)},ee=(e,t)=>{let n=d(e,t);if(n==null)throw TypeError(`value is nullable`);return n},te=async e=>{let t=[],n=[];return e.forEach(e=>{let r=new Promise(n=>{setTimeout(()=>{t.push(e),n()},e)});n.push(r)}),await Promise.all(n),t},f=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},p=(e,t,n)=>{if(n<1n)throw RangeError("`mod` must be positive");if(t<0n)throw RangeError("`power` must not be negative");if(e=f(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},m=(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}},h=(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 h(e,i)*h(i,t)},ne=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*=h(t,i),t=i,n*=r}return n},re=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 ne(e)<<t},g=(e,t)=>(e>>>(t&31)|e<<(-t&31))>>>0,_=(e,t)=>BigInt.asUintN(64,e>>(t&63n)|e<<(-t&63n)),v=(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},y=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},b=e=>{if(e===0n)return 64n;let t=0n;for(;e>0n&&!(e&1n);)++t,e>>=1n;return BigInt.asUintN(64,t)},x=(e,t)=>{let n=0n,r=e&2047n,i=1023n-1n;if(r>0n)return i-=b(r),i;i-=11n;for(let e=0;e<1e5;++e){let e=t();if(e>0n)return i-=b(e),i;if(i-=64n,i<n)return n}throw Error(`loop exceeded limit`)},ie=e=>{let t=()=>BigInt.asUintN(64,e()),n=()=>{let e=t(),n=BigInt.asUintN(52,e>>11n),r=n===0n&&e>>63n==1n?x(e,t)+1n:x(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`)}},S=(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)},C=(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=S(r);if(e>=p(2n,BigInt(r),n))return e%n}throw Error(`Failed to generate a random bigint`)})()},ae=(e,t)=>Math.floor(Math.random()*(t-e)+e),w,T,E,D,O,k=n((()=>{w=`AsyncWorker`,T=1n<<128n,E=0n,D=()=>{let e=`${E++}`;return E===T&&(E=0n),e},O=class{static name=w;#e;constructor(e){this.#e=e}postMessage=(e,t)=>new Promise((n,r)=>{let i=D(),a=new AbortController,{signal:o}=a;this.#e.addEventListener(`message`,e=>{let t=e.data;t.id===i&&(a.abort(),t.success?n(t.value):r(t.error))},{signal:o}),this.#e.addEventListener(`error`,e=>{a.abort(),r(e.error)},{signal:o});let s={value:e,id:i};this.#e.postMessage(s,t)})},Object.defineProperty(O.prototype,Symbol.toStringTag,{value:w,enumerable:!0})}));function oe(e){let t;try{if(t=j&&(self.URL||self.webkitURL).createObjectURL(j),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(A),{name:e?.name})}}var A,j,se=n((()=>{A='(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=[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],a=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},o=e=>{let t=5n;for(;;){let i=n(t,e);if(i===-1n)return t;if(i===0n||(t=t>0n?-(t+2n):-(t-2n),t===-15n&&r(e)))return null}},s=(t,n)=>{if((n&1n)==0n)throw Error("`n` is not odd");return(t&1n)==1n?e(t+n>>1n,n):e(t>>1n,n)},c=(t,n,r,i)=>{let a=1n,o=r,c=t.toString(2).slice(1);for(let t of c)[a,o]=[e(a*o,n),s(o*o+i*a*a,n)],t===`1`&&([a,o]=[s(r*a+o,n),s(i*a+r*o,n)]);return[a,o]},l=(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[l,u]=c(o,n,i,r),d=u;if(l===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},u=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of i)if(e%t===0n)return e===t;if(!a(e))return!1;let t=o(e);return t==null?!1:l(e,t,1n,(1n-t)/4n)},d=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,f=(e,t)=>{if(!d())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},p=(e,t)=>{if(!d())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},m=e=>{if(e==null)return;let t=`${e}`;return t===`[object Object]`?JSON.stringify(e):t};globalThis.onmessage=e=>{let{value:t,id:n}=e.data;try{f(u(t),n)}catch(e){if(e instanceof Error){let{name:t,message:r,stack:i,cause:a}=e;p({name:t,message:r,stack:i,cause:m(a)},n)}else p({name:`BPSWError`,message:`unidentified error`,cause:m(e)},n)}}})();',j=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,A],{type:`text/javascript;charset=utf-8`})})),ce=r({getWorker:()=>N}),M,N,le=n((()=>{k(),se(),N=async()=>(M||=new O(new oe({name:`bpsw_worker`})),M)})),ue=[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],de=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=p(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},fe=e=>{let t=5n;for(;;){let n=v(t,e);if(n===-1n)return t;if(n===0n||(t=t>0n?-(t+2n):-(t-2n),t===-15n&&y(e)))return null}},P=(e,t)=>{if((t&1n)==0n)throw Error("`n` is not odd");return(e&1n)==1n?f(e+t>>1n,t):f(e>>1n,t)},pe=(e,t,n,r)=>{let i=1n,a=n,o=e.toString(2).slice(1);for(let e of o)[i,a]=[f(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]},me=(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]=pe(i,e,n,t),c=s;if(o===0n)return!0;r=p(r,i,e);for(let t=0n;t<a;t++){if(c===0n)return!0;c=f(c*c-2n*r,e),r=p(r,2n,e)}return!1},F=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of ue)if(e%t===0n)return e===t;if(!de(e))return!1;let t=fe(e);return t==null?!1:me(e,t,1n,(1n-t)/4n)},I=(e,t)=>{if(t<2n)throw RangeError("`max` must be 2 or larger");for(let n=0;n<1e5;n++){let n=C(e,t);if(F(n))return n}throw Error(`no primes were found`)},L=(e,t=!1)=>{if(e<2)throw RangeError("`bitLength` must be 2 or larger");for(let n=0;n<1e5;n++){let n=S(e,t);if(F(n))return n}throw Error(`no primes were found`)},R=async e=>{let{getWorker:t}=await Promise.resolve().then(()=>(le(),ce));return(await t()).postMessage(e)},z=e=>{let t=Array.from(e,e=>String.fromCharCode(e));return btoa(t.join(``))},B=e=>{let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))},V=e=>z(e).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``),H=e=>{let t=4-(e.length&3)&3;return B(e.concat(`=`.repeat(t)).replaceAll(`-`,`+`).replaceAll(`_`,`/`))},he=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return new Response(n).bytes()},ge=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new DecompressionStream(t));return new Response(n).bytes()},_e=async(e,t,n=`base64url`)=>{let r=new Blob([e]).stream().pipeThrough(new CompressionStream(t)),i=await new Response(r).bytes();return n===`base64`?z(i):V(i)},ve=(e,t,n=`base64url`)=>{let r;r=n===`base64`?B(e):H(e);let i=new Blob([r]).stream().pipeThrough(new DecompressionStream(t));return new Response(i).text()},ye=(e,t)=>[e].includes(t),U=(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===t||e!==e&&t!==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(!U(e[n],t[n]))return!1;return!0}if(e instanceof Set&&t instanceof Set)return!!U([...e.values()],[...t.values()]);if(e instanceof Map&&t instanceof Map)return!(!U([...e.keys()],[...t.keys()])||!U([...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==null)return!1;let[i,o]=[n[e],r[t]];if(!U(i,o))return!1}return!0}throw TypeError(`comparing these objects is unavailable: ${e}, ${t}`,{cause:[e,t]})},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}=m(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 be={new:e=>new Uint8Array(e),fromBuffer:(e,t,n)=>new Uint8Array(e,t,n)},K=`NamedError`,q=class extends Error{static name=K;errName;name;constructor(e,t,n){super(t,n),this.errName=e,this.name=e}toJSON=()=>{let e=(()=>{let e=this.cause;if(e==null)return;let t=`${e}`;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 xe=e=>{if(e.length%3!=0)throw Error(`The array length of input must be multiples of 3`);let t=e.length/3,n=Array.from({length:t},(t,n)=>[0,1,2].reduce((t,r)=>t|(e[3*n+r]??0)<<16-8*r,0)),r=8*t;return n.map(e=>e.toString(8).padStart(8,`0`)).slice(0,r).join(``)},Se=e=>{if(e.length&7)throw Error(`A string length must be multiples of 8`);let t=e.matchAll(/.{8}/g),n=Array.from(t,e=>{let t=Number.parseInt(e[0],8);if(Number.isNaN(t))throw TypeError(`Invalid input`);return t}).map(e=>[0,1,2].map(t=>e>>>16-8*t&255)).flat();return Uint8Array.from(n)},Ce=[9600629759793949339n,15726070495360670683n],we=6364136223846793005n,J=`PCGMinimal`,Y=class{#e;static name=J;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(Ce)}#t(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[0]=this.#e[0]*we+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 g(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(Y.prototype,Symbol.toStringTag,{value:J});var X=[13715198867125970446n,3333371893450545919n,5627726498316411518n,8467276975966080893n],Z=`XoshiroMinimal`,Q=class{bits=64;#e;static name=Z;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(X)}#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]=_(this.#e[3],45n)}get value(){if(this.#e[0]==null||this.#e[3]==null)throw TypeError(`unexpected`);let 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(Q.prototype,Symbol.toStringTag,{value:Z});var $=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,Te=(e,t)=>{if(!$())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},Ee=(e,t)=>{if(!$())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},De=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 k(),e.AsyncWorker=O,e.FixedUint8Array=be,e.NamedError=q,e.PCGMinimal=Y,e.Rational=G,e.XoshiroMinimal=Q,e.bailliePSW=F,e.bailliePSWAsync=R,e.compress=he,e.compressString=_e,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=l,e.decompress=ge,e.decompressString=ve,e.encodeLEB128=e=>{let t=De(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=c,e.exEuclidean=m,e.factorial=re,e.floatRng=ie,e.fromBase64=B,e.fromBase64URL=H,e.fromOct=Se,e.getHash=s,e.getRandBIByBitLength=S,e.getRandBIByRange=C,e.getRandPrimeByBitLength=L,e.getRandPrimeByRange=I,e.getRndInt=ae,e.getStringTag=a,e.isDeepStrictEqual=U,e.isSquare=y,e.jacobiSymbol=v,e.lazify=o,e.modPow=p,e.nullableStrictAt=d,e.postFailed=Ee,e.postSuccess=Te,e.residue=f,e.rot32=g,e.rot64=_,e.sameValueZero=ye,e.setTimeoutPromise=u,e.sleepSort=te,e.strictAt=ee,e.toBase64=z,e.toBase64URL=V,e.toOct=xe,e.withResolvers=i,e})({});
1
+ var UtilFns=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,t)=>()=>(e&&(t=e(e=0)),t),r=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},i=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},a=e=>Object.prototype.toString.call(e).slice(8,-1),o=e=>(...t)=>()=>e(...t),s=async(e,t,n)=>{let r=(n??new TextEncoder).encode(e),i=await crypto.subtle.digest(t,r);return new Uint8Array(i)},c=e=>encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),l=e=>{if(e.includes(`+`))throw URIError("an input string must not include `+`");return decodeURIComponent(e)},ee=(e,t)=>new Promise((n,r)=>{setTimeout(async()=>{try{n(await e())}catch(e){r(e)}},t)}),u=(e,t)=>{if(t<-e.length||t>=e.length)throw RangeError("`index` is out of range");return e.at(t)},te=(e,t)=>{let n=u(e,t);if(n==null)throw TypeError(`value is nullable`);return n},ne=async e=>{let t=[],n=[];return e.forEach(e=>{let r=new Promise(n=>{setTimeout(()=>{t.push(e),n()},e)});n.push(r)}),await Promise.all(n),t},re=(e,t)=>{let n=`data:text/javascript;charset=UTF-8,${c(`(()=>{${`self.onmessage=${e};`}${t?`self.onerror=${t};`:``}})();`.replace(/\s+/g,` `))}`;return new Worker(n)},d=(e,t)=>{t<0n&&(t*=-1n);let n=e%t;return n<0n?n+t:n},f=(e,t,n)=>{if(n<1n)throw RangeError("`mod` must be positive");if(t<0n)throw RangeError("`power` must not be negative");if(e=d(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},p=(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}},m=(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 m(e,i)*m(i,t)},ie=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*=m(t,i),t=i,n*=r}return n},ae=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 ie(e)<<t},h=(e,t)=>(e>>>(t&31)|e<<(-t&31))>>>0,g=(e,t)=>BigInt.asUintN(64,e>>(t&63n)|e<<(-t&63n)),_=(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},v=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},y=e=>{if(e===0n)return 64n;let t=0n;for(;e>0n&&!(e&1n);)++t,e>>=1n;return BigInt.asUintN(64,t)},b=(e,t)=>{let n=0n,r=e&2047n,i=1023n-1n;if(r>0n)return i-=y(r),i;i-=11n;for(let e=0;e<1e5;++e){let e=t();if(e>0n)return i-=y(e),i;if(i-=64n,i<n)return n}throw Error(`loop exceeded limit`)},oe=e=>{let t=()=>BigInt.asUintN(64,e()),n=()=>{let e=t(),n=BigInt.asUintN(52,e>>11n),r=n===0n&&e>>63n==1n?b(e,t)+1n:b(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`)}},x=(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)},S=(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=x(r);if(e>=f(2n,BigInt(r),n))return e%n}throw Error(`Failed to generate a random bigint`)})()},C=(e,t)=>Math.floor(Math.random()*(t-e)+e),w,T,E,D,O,k=n((()=>{w=`AsyncWorker`,T=1n<<128n,E=0n,D=()=>{let e=`${E++}`;return E===T&&(E=0n),e},O=class{static name=w;#e;constructor(e){this.#e=e}postMessage=(e,t)=>new Promise((n,r)=>{let i=D(),a=new AbortController,{signal:o}=a;this.#e.addEventListener(`message`,e=>{let t=e.data;t.id===i&&(a.abort(),t.success?n(t.value):r(t.error))},{signal:o}),this.#e.addEventListener(`error`,e=>{a.abort(),r(e.error)},{signal:o});let s={value:e,id:i};this.#e.postMessage(s,t)})},Object.defineProperty(O.prototype,Symbol.toStringTag,{value:w,enumerable:!0})}));function se(e){let t;try{if(t=j&&(self.URL||self.webkitURL).createObjectURL(j),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(A),{name:e?.name})}}var A,j,ce=n((()=>{A='(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=[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],a=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},o=e=>{let t=5n;for(;;){let i=n(t,e);if(i===-1n)return t;if(i===0n||(t=t>0n?-(t+2n):-(t-2n),t===-15n&&r(e)))return null}},s=(t,n)=>{if((n&1n)==0n)throw Error("`n` is not odd");return(t&1n)==1n?e(t+n>>1n,n):e(t>>1n,n)},c=(t,n,r,i)=>{let a=1n,o=r,c=t.toString(2).slice(1);for(let t of c)[a,o]=[e(a*o,n),s(o*o+i*a*a,n)],t===`1`&&([a,o]=[s(r*a+o,n),s(i*a+r*o,n)]);return[a,o]},l=(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[l,u]=c(o,n,i,r),d=u;if(l===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},u=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of i)if(e%t===0n)return e===t;if(!a(e))return!1;let t=o(e);return t==null?!1:l(e,t,1n,(1n-t)/4n)},d=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,f=(e,t)=>{if(!d())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},p=(e,t)=>{if(!d())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},m=e=>{if(e==null)return;let t=`${e}`;return t===`[object Object]`?JSON.stringify(e):t};globalThis.onmessage=e=>{let{value:t,id:n}=e.data;try{f(u(t),n)}catch(e){if(e instanceof Error){let{name:t,message:r,stack:i,cause:a}=e;p({name:t,message:r,stack:i,cause:m(a)},n)}else p({name:`BPSWError`,message:`unidentified error`,cause:m(e)},n)}}})();',j=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,A],{type:`text/javascript;charset=utf-8`})})),M=r({getWorker:()=>P}),N,P,le=n((()=>{k(),ce(),P=async()=>(N||=new O(new se({name:`bpsw_worker`})),N)})),ue=[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],de=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=f(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},fe=e=>{let t=5n;for(;;){let n=_(t,e);if(n===-1n)return t;if(n===0n||(t=t>0n?-(t+2n):-(t-2n),t===-15n&&v(e)))return null}},F=(e,t)=>{if((t&1n)==0n)throw Error("`n` is not odd");return(e&1n)==1n?d(e+t>>1n,t):d(e>>1n,t)},pe=(e,t,n,r)=>{let i=1n,a=n,o=e.toString(2).slice(1);for(let e of o)[i,a]=[d(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]},me=(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]=pe(i,e,n,t),c=s;if(o===0n)return!0;r=f(r,i,e);for(let t=0n;t<a;t++){if(c===0n)return!0;c=d(c*c-2n*r,e),r=f(r,2n,e)}return!1},I=e=>{if(e<=1n)return!1;if(e%2n==0n)return e===2n;for(let t of ue)if(e%t===0n)return e===t;if(!de(e))return!1;let t=fe(e);return t==null?!1:me(e,t,1n,(1n-t)/4n)},L=(e,t)=>{if(t<2n)throw RangeError("`max` must be 2 or larger");for(let n=0;n<1e5;n++){let n=S(e,t);if(I(n))return n}throw Error(`no primes were found`)},R=(e,t=!1)=>{if(e<2)throw RangeError("`bitLength` must be 2 or larger");for(let n=0;n<1e5;n++){let n=x(e,t);if(I(n))return n}throw Error(`no primes were found`)},z=async e=>{let{getWorker:t}=await Promise.resolve().then(()=>(le(),M));return(await t()).postMessage(e)},B=e=>{let t=Array.from(e,e=>String.fromCharCode(e));return btoa(t.join(``))},V=e=>{let t=atob(e);return Uint8Array.from(t,e=>e.charCodeAt(0))},H=e=>B(e).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``),U=e=>{let t=4-(e.length&3)&3;return V(e.concat(`=`.repeat(t)).replaceAll(`-`,`+`).replaceAll(`_`,`/`))},he=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new CompressionStream(t));return new Response(n).bytes()},ge=(e,t)=>{let n=new Blob([e]).stream().pipeThrough(new DecompressionStream(t));return new Response(n).bytes()},_e=async(e,t,n=`base64url`)=>{let r=new Blob([e]).stream().pipeThrough(new CompressionStream(t)),i=await new Response(r).bytes();return n===`base64`?B(i):H(i)},ve=(e,t,n=`base64url`)=>{let r;r=n===`base64`?V(e):U(e);let i=new Blob([r]).stream().pipeThrough(new DecompressionStream(t));return new Response(i).text()},ye=(e,t)=>[e].includes(t),W=(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===t||e!==e&&t!==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(!W(e[n],t[n]))return!1;return!0}if(e instanceof Set&&t instanceof Set)return!!W([...e.values()],[...t.values()]);if(e instanceof Map&&t instanceof Map)return!(!W([...e.keys()],[...t.keys()])||!W([...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==null)return!1;let[i,o]=[n[e],r[t]];if(!W(i,o))return!1}return!0}throw TypeError(`comparing these objects is unavailable: ${e}, ${t}`,{cause:[e,t]})},G=`Rational`,K=class e{#e;#t;static name=G;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}=p(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(K.prototype,Symbol.toStringTag,{value:G});var be={new:e=>new Uint8Array(e),fromBuffer:(e,t,n)=>new Uint8Array(e,t,n)},q=`NamedError`,J=class extends Error{static name=q;errName;name;constructor(e,t,n){super(t,n),this.errName=e,this.name=e}toJSON=()=>{let e=(()=>{let e=this.cause;if(e==null)return;let t=`${e}`;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(J.prototype,Symbol.toStringTag,{value:q});var xe=e=>{if(e.length%3!=0)throw Error(`The array length of input must be multiples of 3`);let t=e.length/3,n=Array.from({length:t},(t,n)=>[0,1,2].reduce((t,r)=>t|(e[3*n+r]??0)<<16-8*r,0)),r=8*t;return n.map(e=>e.toString(8).padStart(8,`0`)).slice(0,r).join(``)},Se=e=>{if(e.length&7)throw Error(`A string length must be multiples of 8`);let t=e.matchAll(/.{8}/g),n=Array.from(t,e=>{let t=Number.parseInt(e[0],8);if(Number.isNaN(t))throw TypeError(`Invalid input`);return t}).map(e=>[0,1,2].map(t=>e>>>16-8*t&255)).flat();return Uint8Array.from(n)},Ce=[9600629759793949339n,15726070495360670683n],we=6364136223846793005n,Y=`PCGMinimal`,X=class{#e;static name=Y;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(Ce)}#t(){if(this.#e[0]==null||this.#e[1]==null)throw TypeError(`unexpected`);this.#e[0]=this.#e[0]*we+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 h(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(X.prototype,Symbol.toStringTag,{value:Y});var Te=[13715198867125970446n,3333371893450545919n,5627726498316411518n,8467276975966080893n],Z=`XoshiroMinimal`,Q=class{bits=64;#e;static name=Z;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(Te)}#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]=g(this.#e[3],45n)}get value(){if(this.#e[0]==null||this.#e[3]==null)throw TypeError(`unexpected`);let e=g(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(Q.prototype,Symbol.toStringTag,{value:Z});var $=()=>typeof window>`u`&&typeof self<`u`&&`importScripts`in self,Ee=(e,t)=>{if(!$())throw Error(`this function must be used in Worker`);let n={success:!0,value:e,id:t};self.postMessage(n)},De=(e,t)=>{if(!$())throw Error(`this function must be used in Worker`);let n={success:!1,error:e,id:t};self.postMessage(n)},Oe=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 k(),e.AsyncWorker=O,e.FixedUint8Array=be,e.NamedError=J,e.PCGMinimal=X,e.Rational=K,e.XoshiroMinimal=Q,e.bailliePSW=I,e.bailliePSWAsync=z,e.compress=he,e.compressString=_e,e.createWorker=re,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=l,e.decompress=ge,e.decompressString=ve,e.encodeLEB128=e=>{let t=Oe(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=c,e.exEuclidean=p,e.factorial=ae,e.floatRng=oe,e.fromBase64=V,e.fromBase64URL=U,e.fromOct=Se,e.getHash=s,e.getRandBIByBitLength=x,e.getRandBIByRange=S,e.getRandPrimeByBitLength=R,e.getRandPrimeByRange=L,e.getRndInt=C,e.getStringTag=a,e.isDeepStrictEqual=W,e.isSquare=v,e.jacobiSymbol=_,e.lazify=o,e.modPow=f,e.nullableStrictAt=u,e.postFailed=De,e.postSuccess=Ee,e.residue=d,e.rot32=h,e.rot64=g,e.sameValueZero=ye,e.setTimeoutPromise=ee,e.sleepSort=ne,e.strictAt=te,e.toBase64=B,e.toBase64URL=H,e.toOct=xe,e.withResolvers=i,e})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tktb-tess/util-fns",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "Utility functions for personal use",
5
5
  "files": [
6
6
  "dist"