!function(n,t){"object"==typeofexports&&"undefined"!=typeofmodule?t(exports):"function"==typeofdefine&&define.amd?define(["exports"],t):t((n="undefined"!=typeofglobalThis?globalThis:n||self).bigintModArith={})}(this,(function(n){"use strict";functiont(n){returnn>=0?n:-n}functione(n,t){if("number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),n<=0n||t<=0n)thrownewRangeError("a and b MUST be > 0");lete=0n,r=1n,o=1n,i=0n;for(;0n!==n;){constf=t/n,u=t%n,c=e-o*f,g=r-i*f;t=n,n=u,e=o,r=i,o=c,i=g}return{g:t,x:e,y:r}}functionr(n,e){letr="number"==typeofn?BigInt(t(n)):t(n),o="number"==typeofe?BigInt(t(e)):t(e);if(0n===r)returno;if(0n===o)returnr;leti=0n;for(;0n===(1n&(r|o));)r>>=1n,o>>=1n,i++;for(;0n===(1n&r);)r>>=1n;do{for(;0n===(1n&o);)o>>=1n;if(r>o){constn=r;r=o,o=n}o-=r}while(0n!==o);returnr<<i}functiono(n,t){if("number"==typeofn&&(n=BigInt(n)),"number"==typeoft&&(t=BigInt(t)),t<=0n)returnNaN;conste=n%t;returne<0n?e+t:e}functioni(n,t){try{constr=e(o(n,t),t);return1n!==r.g?NaN:o(r.x,t)}catch(n){returnNaN}}n.abs=t,n.bitLength=function(n){if("number"==typeofn&&(n=BigInt(n)),1n===n)return1;lett=1;do{t++}while((n>>=1n)>1n);returnt},n.eGcd=e,n.gcd=r,n.lcm=function(n,e){return"number"==typeofn&&(n=BigInt(n)),"number"==typeofe&&(e=BigInt(e)),0n===n&&0n===e?BigInt(0):t(n*e)/r(n,e)},n.max=function(n,t){returnn>=t?n:t},n.min=function(n,t){returnn>=t?t:n},n.modInv=i,n.modPow=functionn(e,r,f){if("number"==typeofe&&(e=BigInt(e)),"number"==typeofr&&(r=BigInt(r)),"number"==typeoff&&(f=BigInt(f)),f<=0n)returnNaN;if(1n===f)returnBigInt(0);if(e=o(e,f),r<0n)returni(n(e,t(r),f),f);letu=1n;for(;r>0;)r%2n===1n&&(u=u*e%f),r/=2n,e=e**2n%f;returnu},n.toZn=o,Object.defineProperty(n,"__esModule",{value:!0})}));