js-randomness-predictor
Version:
Predict Math.random output in Node, Deno, Bun, Chrome, Firefox, and Safari
2 lines (1 loc) • 26.6 kB
JavaScript
"use strict";var X=require("z3-solver-jsrp");function me(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Y={},U={},K={},B={},q={},k;function V(){if(k)return q;k=1,Object.defineProperty(q,"__esModule",{value:!0}),q.UnexpectedRuntimeError=q.SymbolicStateEmptyError=q.SequenceNotFoundError=q.InsufficientSequenceLengthError=q.UnsatError=void 0;class l extends Error{constructor(d){d=d===void 0?"Cannot solve state. Unable to make accurate predictions.":d,super(d),this.name="UnsatError",Object.setPrototypeOf(this,new.target.prototype)}}q.UnsatError=l;class P extends Error{constructor(d){super(d),this.name="InsufficientSequenceLengthError",Object.setPrototypeOf(this,new.target.prototype)}}q.InsufficientSequenceLengthError=P;class R extends Error{constructor(d){super(d),this.name="SequenceNotFoundError",Object.setPrototypeOf(this,new.target.prototype)}}q.SequenceNotFoundError=R;class t extends Error{constructor(d){super(d),this.name="SymbolicStateEmptyError",Object.setPrototypeOf(this,new.target.prototype)}}q.SymbolicStateEmptyError=t;class p extends Error{constructor(d){super(d),this.name="UnexpectedRuntimeError",Object.setPrototypeOf(this,new.target.prototype)}}return q.UnexpectedRuntimeError=p,q}var W={},z={},ee;function H(){if(ee)return z;ee=1,Object.defineProperty(z,"__esModule",{value:!0}),z.default=l;function l(P){return P&0xffffffffffffffffn}return z}var te;function $(){if(te)return W;te=1;var l=W&&W.__classPrivateFieldGet||function(d,f,a,v){if(a==="a"&&!v)throw new TypeError("Private accessor was defined without a getter");if(typeof f=="function"?d!==f||!v:!f.has(d))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?v:a==="a"?v.call(d):v?v.value:f.get(d)},P=W&&W.__importDefault||function(d){return d&&d.__esModule?d:{default:d}},R,t;Object.defineProperty(W,"__esModule",{value:!0});const p=P(H());let b=class{constructor(){}static symbolic(f){let a=f[0];a=a.xor(a.shl(23)),a=a.xor(a.lshr(17)),a=a.xor(f[1]),a=a.xor(f[1].lshr(26)),f[0]=f[1],f[1]=a}static symbolicArithmeticShiftRight(f){let a=f[0];a=a.xor(a.shl(23)),a=a.xor(a.shr(17)),a=a.xor(f[1]),a=a.xor(f[1].shr(26)),f[0]=f[1],f[1]=a}static concreteBackwards(f){let a=f[1]^f[0]>>26n^f[0];a=(0,p.default)(a^a>>17n^a>>34n^a>>51n),a=(0,p.default)(a^a<<23n^a<<46n),f[1]=f[0],f[0]=a}static concrete(f){let a=f[0];a^=(0,p.default)(a<<23n),a^=(0,p.default)(a>>17n),a^=f[1],a^=(0,p.default)(f[1]>>26n),f[0]=f[1],f[1]=a}static concreteArithmeticShiftRight(f){let a=(0,p.default)(f[0]);a^=(0,p.default)(a<<23n),a^=l(this,R,"m",t).call(this,a,17n),a^=f[1],a^=l(this,R,"m",t).call(this,f[1],26n),f[0]=f[1],f[1]=(0,p.default)(a)}};return R=b,t=function(f,a){const v=(0,p.default)(f>>a);if((f&1n<<63n)===0n)return v;const g=(1n<<a)-1n<<64n-a;return v|g},W.default=b,W}var re;function we(){if(re)return B;re=1;var l=B&&B.__createBinding||(Object.create?(function(w,u,o,i){i===void 0&&(i=o);var s=Object.getOwnPropertyDescriptor(u,o);(!s||("get"in s?!u.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return u[o]}}),Object.defineProperty(w,i,s)}):(function(w,u,o,i){i===void 0&&(i=o),w[i]=u[o]})),P=B&&B.__setModuleDefault||(Object.create?(function(w,u){Object.defineProperty(w,"default",{enumerable:!0,value:u})}):function(w,u){w.default=u}),R=B&&B.__importStar||(function(){var w=function(u){return w=Object.getOwnPropertyNames||function(o){var i=[];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[i.length]=s);return i},w(u)};return function(u){if(u&&u.__esModule)return u;var o={};if(u!=null)for(var i=w(u),s=0;s<i.length;s++)i[s]!=="default"&&l(o,u,i[s]);return P(o,u),o}})(),t=B&&B.__classPrivateFieldGet||function(w,u,o,i){if(o==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof u=="function"?w!==u||!i:!u.has(w))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?i:o==="a"?i.call(w):i?i.value:u.get(w)},p=B&&B.__classPrivateFieldSet||function(w,u,o,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof u=="function"?w!==u||!s:!u.has(w))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(w,o):s?s.value=o:u.set(w,o),o},b=B&&B.__importDefault||function(w){return w&&w.__esModule?w:{default:w}},d,f,a,v,S,g;Object.defineProperty(B,"__esModule",{value:!0});const M=R(X),E=V(),j=b($());class O{constructor(u){d.add(this),f.set(this,Math.pow(2,53)),a.set(this,[0n,0n]),this.sequence=u}async predictNext(){t(this,a,"f")[0]===0n&&t(this,a,"f")[1]===0n&&await t(this,d,"m",v).call(this);const u=t(this,d,"m",g).call(this,t(this,a,"f")[0]);return j.default.concreteBackwards(t(this,a,"f")),u}}return f=new WeakMap,a=new WeakMap,d=new WeakSet,v=async function(){try{const{Context:u}=await M.init(),o=u("main"),i=new o.Solver,s=o.BitVec.const("ss0",64),m=o.BitVec.const("ss1",64),h=[s,m],c=[...this.sequence].reverse();for(const e of c){j.default.symbolic(h);const n=t(this,d,"m",S).call(this,e);i.add(h[0].lshr(11).eq(o.BitVec.val(n,64)))}if(await i.check()!=="sat")throw new E.UnsatError;const r=i.model();p(this,a,[r.get(s).value(),r.get(m).value()],"f")}catch(u){return Promise.reject(u)}},S=function(u){const o=Math.floor(u*t(this,f,"f"));return BigInt(o)},g=function(u){return Number(u>>11n)/t(this,f,"f")},B.default=O,B}var D={},ne;function Pe(){if(ne)return D;ne=1;var l=D&&D.__createBinding||(Object.create?(function(o,i,s,m){m===void 0&&(m=s);var h=Object.getOwnPropertyDescriptor(i,s);(!h||("get"in h?!i.__esModule:h.writable||h.configurable))&&(h={enumerable:!0,get:function(){return i[s]}}),Object.defineProperty(o,m,h)}):(function(o,i,s,m){m===void 0&&(m=s),o[m]=i[s]})),P=D&&D.__setModuleDefault||(Object.create?(function(o,i){Object.defineProperty(o,"default",{enumerable:!0,value:i})}):function(o,i){o.default=i}),R=D&&D.__importStar||(function(){var o=function(i){return o=Object.getOwnPropertyNames||function(s){var m=[];for(var h in s)Object.prototype.hasOwnProperty.call(s,h)&&(m[m.length]=h);return m},o(i)};return function(i){if(i&&i.__esModule)return i;var s={};if(i!=null)for(var m=o(i),h=0;h<m.length;h++)m[h]!=="default"&&l(s,i,m[h]);return P(s,i),s}})(),t=D&&D.__classPrivateFieldGet||function(o,i,s,m){if(s==="a"&&!m)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?o!==i||!m:!i.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?m:s==="a"?m.call(o):m?m.value:i.get(o)},p=D&&D.__classPrivateFieldSet||function(o,i,s,m,h){if(m==="m")throw new TypeError("Private method is not writable");if(m==="a"&&!h)throw new TypeError("Private accessor was defined without a setter");if(typeof i=="function"?o!==i||!h:!i.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return m==="a"?h.call(o,s):h?h.value=s:i.set(o,s),s},b=D&&D.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},d,f,a,v,S,g,M;Object.defineProperty(D,"__esModule",{value:!0});const E=R(X),j=V(),O=b($()),w=b(H());class u{constructor(i){d.add(this),f.set(this,0x1fffffffffffffn),a.set(this,Math.pow(2,53)),v.set(this,[0n,0n]),this.sequence=i}async predictNext(){return t(this,v,"f")[0]===0n&&t(this,v,"f")[1]===0n&&await t(this,d,"m",S).call(this),O.default.concrete(t(this,v,"f")),t(this,d,"m",M).call(this,(0,w.default)(t(this,v,"f")[0]+t(this,v,"f")[1]))}}return f=new WeakMap,a=new WeakMap,v=new WeakMap,d=new WeakSet,S=async function(){try{const{Context:i}=await E.init(),s=i("main"),m=new s.Solver,h=s.BitVec.const("ss0",64),c=s.BitVec.const("ss1",64),r=[h,c];for(const _ of this.sequence){O.default.symbolic(r);const y=t(this,d,"m",g).call(this,_),x=r[0].add(r[1]).and(s.BitVec.val(t(this,f,"f"),64));m.add(x.eq(s.BitVec.val(y,64)))}if(await m.check()!=="sat")throw new j.UnsatError;const e=m.model(),n=[e.get(h).value(),e.get(c).value()];for(const _ of this.sequence)O.default.concrete(n);p(this,v,n,"f")}catch(i){return Promise.reject(i)}},g=function(i){return BigInt(Math.floor(i*t(this,a,"f")))},M=function(i){return Number(i&t(this,f,"f"))/t(this,a,"f")},D.default=u,D}var N={},J={},oe;function Z(){if(oe)return J;oe=1,Object.defineProperty(J,"__esModule",{value:!0});const l=V();let P=class{static isDeno(){return typeof globalThis.Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno=="string"}static isBun(){return typeof globalThis.Bun<"u"&&typeof Bun.version<"u"&&typeof process.versions.bun=="string"}static isNode(){return!this.isDeno()&&!this.isBun()&&typeof process.versions.node<"u"&&typeof process.versions.node=="string"}static isFirefox(){return typeof window<"u"&&navigator.userAgent.indexOf("Firefox")>-1}static isChrome(){return typeof window!==void 0&&navigator.userAgent.indexOf("Chrome")>-1}static isSafari(){return typeof window!==void 0&&navigator.userAgent.indexOf("Safari")>-1}static type(){if(this.isNode())return"node";if(this.isDeno())return"deno";if(this.isBun())return"bun";if(this.isChrome())return"chrome";if(this.isSafari())return"safari";if(this.isFirefox())return"firefox";throw new l.UnexpectedRuntimeError}};return J.default=P,J}var ie;function pe(){if(ie)return N;ie=1;var l=N&&N.__createBinding||(Object.create?(function(c,r,e,n){n===void 0&&(n=e);var _=Object.getOwnPropertyDescriptor(r,e);(!_||("get"in _?!r.__esModule:_.writable||_.configurable))&&(_={enumerable:!0,get:function(){return r[e]}}),Object.defineProperty(c,n,_)}):(function(c,r,e,n){n===void 0&&(n=e),c[n]=r[e]})),P=N&&N.__setModuleDefault||(Object.create?(function(c,r){Object.defineProperty(c,"default",{enumerable:!0,value:r})}):function(c,r){c.default=r}),R=N&&N.__importStar||(function(){var c=function(r){return c=Object.getOwnPropertyNames||function(e){var n=[];for(var _ in e)Object.prototype.hasOwnProperty.call(e,_)&&(n[n.length]=_);return n},c(r)};return function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var n=c(r),_=0;_<n.length;_++)n[_]!=="default"&&l(e,r,n[_]);return P(e,r),e}})(),t=N&&N.__classPrivateFieldGet||function(c,r,e,n){if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?c!==r||!n:!r.has(c))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?n:e==="a"?n.call(c):n?n.value:r.get(c)},p=N&&N.__classPrivateFieldSet||function(c,r,e,n,_){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!_)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?c!==r||!_:!r.has(c))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?_.call(c,e):_?_.value=e:r.set(c,e),e},b=N&&N.__importDefault||function(c){return c&&c.__esModule?c:{default:c}},d,f,a,v,S,g,M,E,j,O,w,u;Object.defineProperty(N,"__esModule",{value:!0});const o=R(X),i=V(),s=b($()),m=b(Z());class h{constructor(r){if(d.add(this),f.set(this,64),a.set(this,4),v.set(this,0x000fffffffffffffn),S.set(this,0x3ff0000000000000n),g.set(this,Math.pow(2,53)),M.set(this,t(this,d,"m",O).call(this)),E.set(this,void 0),j.set(this,[0n,0n]),r&&r.length>=t(this,f,"f"))throw new Error(`sequence.length must be less than '${t(this,f,"f")}', got '${r.length}'`);if(!r){if(!m.default.isNode())throw new i.UnexpectedRuntimeError("Expected NodeJS runtime! Unable to auto-generate sequence, please provide one.");r=Array.from({length:t(this,a,"f")},Math.random)}this.sequence=r,p(this,E,t(this,d,"m",w).call(this),"f")}async predictNext(){t(this,j,"f")[0]===0n&&t(this,j,"f")[1]===0n&&await t(this,d,"m",u).call(this);const r=t(this,E,"f").toDouble(t(this,j,"f"));return s.default.concreteBackwards(t(this,j,"f")),r}setNodeVersion(r){p(this,M,r,"f"),p(this,E,t(this,d,"m",w).call(this),"f")}}return f=new WeakMap,a=new WeakMap,v=new WeakMap,S=new WeakMap,g=new WeakMap,M=new WeakMap,E=new WeakMap,j=new WeakMap,d=new WeakSet,O=function(){const[r,e,n]=process.versions.node.split(".").map(Number);return{major:r,minor:e,patch:n}},w=function(){const{major:r}=t(this,M,"f");return r<=11?{recoverMantissa:e=>{const n=Buffer.alloc(8);return n.writeDoubleLE(e+1,0),n.readBigUInt64LE(0)&t(this,v,"f")},toDouble:e=>{const n=e[0]+e[1],_=Buffer.alloc(8);return _.writeBigUInt64LE(n&t(this,v,"f")|t(this,S,"f"),0),_.readDoubleLE(0)-1},constrainMantissa:(e,n,_,y)=>{const x=n[0].add(n[1]).and(y.BitVec.val(t(this,v,"f"),64));_.add(x.eq(y.BitVec.val(e,64)))}}:r<=23?{recoverMantissa:e=>{const n=Buffer.alloc(8);return n.writeDoubleLE(e+1,0),n.readBigUInt64LE(0)&t(this,v,"f")},toDouble:e=>{const n=Buffer.alloc(8);return n.writeBigUInt64LE(e[0]>>12n|t(this,S,"f"),0),n.readDoubleLE(0)-1},constrainMantissa:(e,n,_,y)=>{_.add(n[0].lshr(12).eq(y.BitVec.val(e,64)))}}:{recoverMantissa:e=>{const n=Math.floor(e*t(this,g,"f"));return BigInt(n)},toDouble:e=>Number(e[0]>>11n)/t(this,g,"f"),constrainMantissa:(e,n,_,y)=>{_.add(n[0].lshr(11).eq(y.BitVec.val(e,64)))}}},u=async function(){try{const{Context:r}=await o.init(),e=r("main"),n=new e.Solver,_=e.BitVec.const("ss0",64),y=e.BitVec.const("ss1",64),x=[_,y],I=[...this.sequence].reverse();for(const L of I){s.default.symbolic(x);const G=t(this,E,"f").recoverMantissa(L);t(this,E,"f").constrainMantissa(G,x,n,e)}if(await n.check()!=="sat")throw new i.UnsatError;const A=n.model();p(this,j,[A.get(_).value(),A.get(y).value()],"f")}catch(r){return Promise.reject(r)}},N.default=h,N}var T={},ae;function ve(){if(ae)return T;ae=1;var l=T&&T.__createBinding||(Object.create?(function(h,c,r,e){e===void 0&&(e=r);var n=Object.getOwnPropertyDescriptor(c,r);(!n||("get"in n?!c.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return c[r]}}),Object.defineProperty(h,e,n)}):(function(h,c,r,e){e===void 0&&(e=r),h[e]=c[r]})),P=T&&T.__setModuleDefault||(Object.create?(function(h,c){Object.defineProperty(h,"default",{enumerable:!0,value:c})}):function(h,c){h.default=c}),R=T&&T.__importStar||(function(){var h=function(c){return h=Object.getOwnPropertyNames||function(r){var e=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[e.length]=n);return e},h(c)};return function(c){if(c&&c.__esModule)return c;var r={};if(c!=null)for(var e=h(c),n=0;n<e.length;n++)e[n]!=="default"&&l(r,c,e[n]);return P(r,c),r}})(),t=T&&T.__classPrivateFieldGet||function(h,c,r,e){if(r==="a"&&!e)throw new TypeError("Private accessor was defined without a getter");if(typeof c=="function"?h!==c||!e:!c.has(h))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?e:r==="a"?e.call(h):e?e.value:c.get(h)},p=T&&T.__classPrivateFieldSet||function(h,c,r,e,n){if(e==="m")throw new TypeError("Private method is not writable");if(e==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof c=="function"?h!==c||!n:!c.has(h))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e==="a"?n.call(h,r):n?n.value=r:c.set(h,r),r},b=T&&T.__importDefault||function(h){return h&&h.__esModule?h:{default:h}},d,f,a,v,S,g,M,E,j,O,w;Object.defineProperty(T,"__esModule",{value:!0});const u=R(X),o=V(),i=b($()),s=b(H());class m{constructor(c){if(d.add(this),f.set(this,6),a.set(this,[0n,0n]),v.set(this,void 0),S.set(this,void 0),g.set(this,0x1fffffffffffffn),M.set(this,Math.pow(2,53)),c.length<t(this,f,"f"))throw new o.InsufficientSequenceLengthError(`sequence length must be >= 6 : got ${c.length}`);p(this,v,r=>i.default.symbolicArithmeticShiftRight(r),"f"),p(this,S,r=>i.default.concreteArithmeticShiftRight(r),"f"),this.sequence=c}async predictNext(){return t(this,a,"f")[0]===0n&&t(this,a,"f")[1]===0n&&await t(this,d,"m",E).call(this,()=>t(this,d,"m",j).call(this),()=>(p(this,v,c=>i.default.symbolic(c),"f"),p(this,S,c=>i.default.concrete(c),"f"),t(this,d,"m",j).call(this))),t(this,S,"f").call(this,t(this,a,"f")),t(this,d,"m",w).call(this,(0,s.default)(t(this,a,"f")[0]+t(this,a,"f")[1]))}}return f=new WeakMap,a=new WeakMap,v=new WeakMap,S=new WeakMap,g=new WeakMap,M=new WeakMap,d=new WeakSet,E=async function(c,r){try{return await c()}catch{return await r()}},j=async function(){try{const{Context:c}=await u.init(),r=c("main"),e=new r.Solver,n=r.BitVec.const("ss0",64),_=r.BitVec.const("ss1",64),y=[n,_];for(const A of this.sequence){t(this,v,"f").call(this,y);const L=t(this,d,"m",O).call(this,A),G=y[0].add(y[1]).and(r.BitVec.val(t(this,g,"f"),64));e.add(G.eq(r.BitVec.val(L,64)))}if(await e.check()!=="sat")throw new o.UnsatError;const x=e.model(),I=[x.get(n).value(),x.get(_).value()];for(const A of this.sequence)t(this,S,"f").call(this,I);p(this,a,I,"f")}catch(c){return Promise.reject(c)}},O=function(c){return BigInt(Math.floor(c*t(this,M,"f")))},w=function(c){return Number(c&t(this,g,"f"))/t(this,M,"f")},T.default=m,T}var C={},Q={},se;function be(){if(se)return Q;se=1,Object.defineProperty(Q,"__esModule",{value:!0}),Q.default=l;function l(P=1){const R=[];for(let t=0;t<P;t++)R.push(Math.random());return R}return Q}var ce;function ye(){if(ce)return C;ce=1;var l=C&&C.__createBinding||(Object.create?(function(r,e,n,_){_===void 0&&(_=n);var y=Object.getOwnPropertyDescriptor(e,n);(!y||("get"in y?!e.__esModule:y.writable||y.configurable))&&(y={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(r,_,y)}):(function(r,e,n,_){_===void 0&&(_=n),r[_]=e[n]})),P=C&&C.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),R=C&&C.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(n){var _=[];for(var y in n)Object.prototype.hasOwnProperty.call(n,y)&&(_[_.length]=y);return _},r(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var _=r(e),y=0;y<_.length;y++)_[y]!=="default"&&l(n,e,_[y]);return P(n,e),n}})(),t=C&&C.__classPrivateFieldGet||function(r,e,n,_){if(n==="a"&&!_)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!_:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?_:n==="a"?_.call(r):_?_.value:e.get(r)},p=C&&C.__classPrivateFieldSet||function(r,e,n,_,y){if(_==="m")throw new TypeError("Private method is not writable");if(_==="a"&&!y)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!y:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return _==="a"?y.call(r,n):y?y.value=n:e.set(r,n),n},b=C&&C.__importDefault||function(r){return r&&r.__esModule?r:{default:r}},d,f,a,v,S,g,M,E,j,O,w;Object.defineProperty(C,"__esModule",{value:!0});const u=R(X),o=V(),i=b($()),s=b(H()),m=b(be()),h=b(Z());class c{constructor(e){if(d.add(this),f.set(this,6),a.set(this,[0n,0n]),v.set(this,n=>i.default.symbolic(n)),S.set(this,n=>i.default.concrete(n)),g.set(this,0x1fffffffffffffn),M.set(this,Math.pow(2,53)),e&&e.length<t(this,f,"f"))throw new o.InsufficientSequenceLengthError(`sequence length must be >= 6 : got ${e.length}`);if(!e){if(!h.default.isBun())throw new o.UnexpectedRuntimeError("Expected Bun runtime! Unable to auto-generate sequence, please provide one.");e=(0,m.default)(t(this,f,"f"))}this.sequence=e}async predictNext(){return t(this,a,"f")[0]===0n&&t(this,a,"f")[1]===0n&&await t(this,d,"m",E).call(this,()=>t(this,d,"m",j).call(this),()=>(p(this,v,e=>i.default.symbolicArithmeticShiftRight(e),"f"),p(this,S,e=>i.default.concreteArithmeticShiftRight(e),"f"),t(this,d,"m",j).call(this))),t(this,S,"f").call(this,t(this,a,"f")),t(this,d,"m",w).call(this,(0,s.default)(t(this,a,"f")[0]+t(this,a,"f")[1]))}}return f=new WeakMap,a=new WeakMap,v=new WeakMap,S=new WeakMap,g=new WeakMap,M=new WeakMap,d=new WeakSet,E=async function(e,n){try{return await e()}catch{return await n()}},j=async function(){try{const{Context:e}=await u.init(),n=e("main"),_=new n.Solver,y=n.BitVec.const("ss0",64),x=n.BitVec.const("ss1",64),I=[y,x];for(const G of this.sequence){t(this,v,"f").call(this,I);const _e=t(this,d,"m",O).call(this,G),he=I[0].add(I[1]).and(n.BitVec.val(t(this,g,"f"),64));_.add(he.eq(n.BitVec.val(_e,64)))}if(await _.check()!=="sat")throw new o.UnsatError;const A=_.model(),L=[A.get(y).value(),A.get(x).value()];for(const G of this.sequence)t(this,S,"f").call(this,L);p(this,a,L,"f")}catch(e){return Promise.reject(e)}},O=function(e){return BigInt(Math.floor(e*t(this,M,"f")))},w=function(e){return Number(e&t(this,g,"f"))/t(this,M,"f")},C.default=c,C}var F={},ue;function Re(){if(ue)return F;ue=1;var l=F&&F.__createBinding||(Object.create?(function(u,o,i,s){s===void 0&&(s=i);var m=Object.getOwnPropertyDescriptor(o,i);(!m||("get"in m?!o.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return o[i]}}),Object.defineProperty(u,s,m)}):(function(u,o,i,s){s===void 0&&(s=i),u[s]=o[i]})),P=F&&F.__setModuleDefault||(Object.create?(function(u,o){Object.defineProperty(u,"default",{enumerable:!0,value:o})}):function(u,o){u.default=o}),R=F&&F.__importStar||(function(){var u=function(o){return u=Object.getOwnPropertyNames||function(i){var s=[];for(var m in i)Object.prototype.hasOwnProperty.call(i,m)&&(s[s.length]=m);return s},u(o)};return function(o){if(o&&o.__esModule)return o;var i={};if(o!=null)for(var s=u(o),m=0;m<s.length;m++)s[m]!=="default"&&l(i,o,s[m]);return P(i,o),i}})(),t=F&&F.__classPrivateFieldGet||function(u,o,i,s){if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?u!==o||!s:!o.has(u))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?s:i==="a"?s.call(u):s?s.value:o.get(u)},p=F&&F.__classPrivateFieldSet||function(u,o,i,s,m){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!m)throw new TypeError("Private accessor was defined without a setter");if(typeof o=="function"?u!==o||!m:!o.has(u))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?m.call(u,i):m?m.value=i:o.set(u,i),i},b=F&&F.__importDefault||function(u){return u&&u.__esModule?u:{default:u}},d,f,a,v,S,g;Object.defineProperty(F,"__esModule",{value:!0});const M=R(X),E=V(),j=b($()),O=b(Z());class w{constructor(o){if(d.add(this),f.set(this,Math.pow(2,53)),a.set(this,[0n,0n]),!o){if(!O.default.isDeno())throw new E.UnexpectedRuntimeError("Expected Deno runtime! Unable to auto-generate sequence, please provide one.");o=Array.from({length:4},Math.random)}this.sequence=o}async predictNext(){t(this,a,"f")[0]===0n&&t(this,a,"f")[1]===0n&&await t(this,d,"m",v).call(this);const o=t(this,d,"m",g).call(this,t(this,a,"f")[0]);return j.default.concreteBackwards(t(this,a,"f")),o}}return f=new WeakMap,a=new WeakMap,d=new WeakSet,v=async function(){try{const{Context:o}=await M.init(),i=o("main"),s=new i.Solver,m=i.BitVec.const("ss0",64),h=i.BitVec.const("ss1",64),c=[m,h],r=[...this.sequence].reverse();for(const n of r){j.default.symbolic(c);const _=t(this,d,"m",S).call(this,n);s.add(c[0].lshr(11).eq(i.BitVec.val(_,64)))}if(await s.check()!=="sat")throw new E.UnsatError;const e=s.model();p(this,a,[e.get(m).value(),e.get(h).value()],"f")}catch(o){return Promise.reject(o)}},S=function(o){const i=Math.floor(o*t(this,f,"f"));return BigInt(i)},g=function(o){return Number(o>>11n)/t(this,f,"f")},F.default=w,F}var fe;function Se(){return fe||(fe=1,(function(l){var P=K&&K.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(l,"__esModule",{value:!0}),l.DenoRandomnessPredictor=l.BunRandomnessPredictor=l.SafariRandomnessPredictor=l.NodeRandomnessPredictor=l.FirefoxRandomnessPredictor=l.ChromeRandomnessPredictor=void 0;var R=we();Object.defineProperty(l,"ChromeRandomnessPredictor",{enumerable:!0,get:function(){return P(R).default}});var t=Pe();Object.defineProperty(l,"FirefoxRandomnessPredictor",{enumerable:!0,get:function(){return P(t).default}});var p=pe();Object.defineProperty(l,"NodeRandomnessPredictor",{enumerable:!0,get:function(){return P(p).default}});var b=ve();Object.defineProperty(l,"SafariRandomnessPredictor",{enumerable:!0,get:function(){return P(b).default}});var d=ye();Object.defineProperty(l,"BunRandomnessPredictor",{enumerable:!0,get:function(){return P(d).default}});var f=Re();Object.defineProperty(l,"DenoRandomnessPredictor",{enumerable:!0,get:function(){return P(f).default}})})(K)),K}var de;function ge(){return de||(de=1,(function(l){var P=U&&U.__createBinding||(Object.create?(function(t,p,b,d){d===void 0&&(d=b);var f=Object.getOwnPropertyDescriptor(p,b);(!f||("get"in f?!p.__esModule:f.writable||f.configurable))&&(f={enumerable:!0,get:function(){return p[b]}}),Object.defineProperty(t,d,f)}):(function(t,p,b,d){d===void 0&&(d=b),t[d]=p[b]})),R=U&&U.__exportStar||function(t,p){for(var b in t)b!=="default"&&!Object.prototype.hasOwnProperty.call(p,b)&&P(p,t,b)};Object.defineProperty(l,"__esModule",{value:!0}),R(Se(),l)})(U)),U}var le;function je(){return le||(le=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.DenoRandomnessPredictor=l.BunRandomnessPredictor=l.SafariRandomnessPredictor=l.NodeRandomnessPredictor=l.ChromeRandomnessPredictor=l.FirefoxRandomnessPredictor=l.deno=l.bun=l.safari=l.chrome=l.firefox=l.node=void 0;const P=ge();Object.defineProperty(l,"FirefoxRandomnessPredictor",{enumerable:!0,get:function(){return P.FirefoxRandomnessPredictor}}),Object.defineProperty(l,"ChromeRandomnessPredictor",{enumerable:!0,get:function(){return P.ChromeRandomnessPredictor}}),Object.defineProperty(l,"NodeRandomnessPredictor",{enumerable:!0,get:function(){return P.NodeRandomnessPredictor}}),Object.defineProperty(l,"SafariRandomnessPredictor",{enumerable:!0,get:function(){return P.SafariRandomnessPredictor}}),Object.defineProperty(l,"BunRandomnessPredictor",{enumerable:!0,get:function(){return P.BunRandomnessPredictor}}),Object.defineProperty(l,"DenoRandomnessPredictor",{enumerable:!0,get:function(){return P.DenoRandomnessPredictor}});const R={node:t=>new P.NodeRandomnessPredictor(t),firefox:t=>new P.FirefoxRandomnessPredictor(t),chrome:t=>new P.ChromeRandomnessPredictor(t),safari:t=>new P.SafariRandomnessPredictor(t),bun:t=>new P.BunRandomnessPredictor(t),deno:t=>new P.DenoRandomnessPredictor(t)};l.default=R,l.node=R.node,l.firefox=R.firefox,l.chrome=R.chrome,l.safari=R.safari,l.bun=R.bun,l.deno=R.deno})(Y)),Y}var Me=je(),Ee=me(Me);module.exports=Ee;