@zk-email/sdk 3.0.0-nightly.6 → 3.0.0-nightly.7
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/{ccip-ze7m7ypZ.js → ccip-BUlcHpUw.js} +2 -2
- package/dist/{ccip-uc3ESW_5.mjs → ccip-rh9bDDVT.mjs} +2 -2
- package/dist/{index-Ce3WSald.mjs → index-DBnuqGzN.mjs} +11015 -11015
- package/dist/{index-Doq5gv_O.js → index-DmHKy5qt.js} +67 -67
- package/dist/zk-email-sdk.index.cjs.js +1 -1
- package/dist/zk-email-sdk.index.es.js +1 -1
- package/package.json +2 -2
- package/dist/localProverWorker/localProverWorker-bundled.js +0 -142
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
var Bi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function nl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function xi(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ao={exports:{}};/*!
|
|
2
|
-
localForage -- Offline Storage, Improved
|
|
3
|
-
Version 1.10.0
|
|
4
|
-
https://localforage.github.io/localForage
|
|
5
|
-
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
6
|
-
*/var Ba;function il(){return Ba||(Ba=1,function(n,t){(function(e){n.exports=e()})(function(){return function e(i,o,a){function u(l,s){if(!o[l]){if(!i[l]){var m=typeof xi=="function"&ξif(!s&&m)return m(l,!0);if(r)return r(l,!0);var C=new Error("Cannot find module '"+l+"'");throw C.code="MODULE_NOT_FOUND",C}var g=o[l]={exports:{}};i[l][0].call(g.exports,function(M){var $=i[l][1][M];return u($||M)},g,g.exports,e,i,o,a)}return o[l].exports}for(var r=typeof xi=="function"&&xi,I=0;I<a.length;I++)u(a[I]);return u}({1:[function(e,i,o){(function(a){var u=a.MutationObserver||a.WebKitMutationObserver,r;if(u){var I=0,l=new u(M),s=a.document.createTextNode("");l.observe(s,{characterData:!0}),r=function(){s.data=I=++I%2}}else if(!a.setImmediate&&typeof a.MessageChannel<"u"){var m=new a.MessageChannel;m.port1.onmessage=M,r=function(){m.port2.postMessage(0)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?r=function(){var F=a.document.createElement("script");F.onreadystatechange=function(){M(),F.onreadystatechange=null,F.parentNode.removeChild(F),F=null},a.document.documentElement.appendChild(F)}:r=function(){setTimeout(M,0)};var C,g=[];function M(){C=!0;for(var F,R,x=g.length;x;){for(R=g,g=[],F=-1;++F<x;)R[F]();x=g.length}C=!1}i.exports=$;function $(F){g.push(F)===1&&!C&&r()}}).call(this,typeof Bi<"u"?Bi:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(e,i,o){var a=e(1);function u(){}var r={},I=["REJECTED"],l=["FULFILLED"],s=["PENDING"];i.exports=m;function m(K){if(typeof K!="function")throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,K!==u&&$(this,K)}m.prototype.catch=function(K){return this.then(null,K)},m.prototype.then=function(K,v){if(typeof K!="function"&&this.state===l||typeof v!="function"&&this.state===I)return this;var f=new this.constructor(u);if(this.state!==s){var L=this.state===l?K:v;g(f,L,this.outcome)}else this.queue.push(new C(f,K,v));return f};function C(K,v,f){this.promise=K,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof f=="function"&&(this.onRejected=f,this.callRejected=this.otherCallRejected)}C.prototype.callFulfilled=function(K){r.resolve(this.promise,K)},C.prototype.otherCallFulfilled=function(K){g(this.promise,this.onFulfilled,K)},C.prototype.callRejected=function(K){r.reject(this.promise,K)},C.prototype.otherCallRejected=function(K){g(this.promise,this.onRejected,K)};function g(K,v,f){a(function(){var L;try{L=v(f)}catch(V){return r.reject(K,V)}L===K?r.reject(K,new TypeError("Cannot resolve promise with itself")):r.resolve(K,L)})}r.resolve=function(K,v){var f=F(M,v);if(f.status==="error")return r.reject(K,f.value);var L=f.value;if(L)$(K,L);else{K.state=l,K.outcome=v;for(var V=-1,X=K.queue.length;++V<X;)K.queue[V].callFulfilled(v)}return K},r.reject=function(K,v){K.state=I,K.outcome=v;for(var f=-1,L=K.queue.length;++f<L;)K.queue[f].callRejected(v);return K};function M(K){var v=K&&K.then;if(K&&(typeof K=="object"||typeof K=="function")&&typeof v=="function")return function(){v.apply(K,arguments)}}function $(K,v){var f=!1;function L(N){f||(f=!0,r.reject(K,N))}function V(N){f||(f=!0,r.resolve(K,N))}function X(){v(V,L)}var et=F(X);et.status==="error"&&L(et.value)}function F(K,v){var f={};try{f.value=K(v),f.status="success"}catch(L){f.status="error",f.value=L}return f}m.resolve=R;function R(K){return K instanceof this?K:r.resolve(new this(u),K)}m.reject=x;function x(K){var v=new this(u);return r.reject(v,K)}m.all=it;function it(K){var v=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=K.length,L=!1;if(!f)return this.resolve([]);for(var V=new Array(f),X=0,et=-1,N=new this(u);++et<f;)w(K[et],et);return N;function w(T,at){v.resolve(T).then(Lt,function(_t){L||(L=!0,r.reject(N,_t))});function Lt(_t){V[at]=_t,++X===f&&!L&&(L=!0,r.resolve(N,V))}}}m.race=z;function z(K){var v=this;if(Object.prototype.toString.call(K)!=="[object Array]")return this.reject(new TypeError("must be an array"));var f=K.length,L=!1;if(!f)return this.resolve([]);for(var V=-1,X=new this(u);++V<f;)et(K[V]);return X;function et(N){v.resolve(N).then(function(w){L||(L=!0,r.resolve(X,w))},function(w){L||(L=!0,r.reject(X,w))})}}},{1:1}],3:[function(e,i,o){(function(a){typeof a.Promise!="function"&&(a.Promise=e(2))}).call(this,typeof Bi<"u"?Bi:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(e,i,o){var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S};function u(S,q){if(!(S instanceof q))throw new TypeError("Cannot call a class as a function")}function r(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var I=r();function l(){try{if(!I||!I.open)return!1;var S=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),q=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!S||q)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function s(S,q){S=S||[],q=q||{};try{return new Blob(S,q)}catch(Y){if(Y.name!=="TypeError")throw Y;for(var P=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,j=new P,tt=0;tt<S.length;tt+=1)j.append(S[tt]);return j.getBlob(q.type)}}typeof Promise>"u"&&e(3);var m=Promise;function C(S,q){q&&S.then(function(P){q(null,P)},function(P){q(P)})}function g(S,q,P){typeof q=="function"&&S.then(q),typeof P=="function"&&S.catch(P)}function M(S){return typeof S!="string"&&(console.warn(S+" used as a key, but it is not a string."),S=String(S)),S}function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var F="local-forage-detect-blob-support",R=void 0,x={},it=Object.prototype.toString,z="readonly",K="readwrite";function v(S){for(var q=S.length,P=new ArrayBuffer(q),j=new Uint8Array(P),tt=0;tt<q;tt++)j[tt]=S.charCodeAt(tt);return P}function f(S){return new m(function(q){var P=S.transaction(F,K),j=s([""]);P.objectStore(F).put(j,"key"),P.onabort=function(tt){tt.preventDefault(),tt.stopPropagation(),q(!1)},P.oncomplete=function(){var tt=navigator.userAgent.match(/Chrome\/(\d+)/),Y=navigator.userAgent.match(/Edge\//);q(Y||!tt||parseInt(tt[1],10)>=43)}}).catch(function(){return!1})}function L(S){return typeof R=="boolean"?m.resolve(R):f(S).then(function(q){return R=q,R})}function V(S){var q=x[S.name],P={};P.promise=new m(function(j,tt){P.resolve=j,P.reject=tt}),q.deferredOperations.push(P),q.dbReady?q.dbReady=q.dbReady.then(function(){return P.promise}):q.dbReady=P.promise}function X(S){var q=x[S.name],P=q.deferredOperations.pop();if(P)return P.resolve(),P.promise}function et(S,q){var P=x[S.name],j=P.deferredOperations.pop();if(j)return j.reject(q),j.promise}function N(S,q){return new m(function(P,j){if(x[S.name]=x[S.name]||Ft(),S.db)if(q)V(S),S.db.close();else return P(S.db);var tt=[S.name];q&&tt.push(S.version);var Y=I.open.apply(I,tt);q&&(Y.onupgradeneeded=function(gt){var bt=Y.result;try{bt.createObjectStore(S.storeName),gt.oldVersion<=1&&bt.createObjectStore(F)}catch(mt){if(mt.name==="ConstraintError")console.warn('The database "'+S.name+'" has been upgraded from version '+gt.oldVersion+" to version "+gt.newVersion+', but the storage "'+S.storeName+'" already exists.');else throw mt}}),Y.onerror=function(gt){gt.preventDefault(),j(Y.error)},Y.onsuccess=function(){var gt=Y.result;gt.onversionchange=function(bt){bt.target.close()},P(gt),X(S)}})}function w(S){return N(S,!1)}function T(S){return N(S,!0)}function at(S,q){if(!S.db)return!0;var P=!S.db.objectStoreNames.contains(S.storeName),j=S.version<S.db.version,tt=S.version>S.db.version;if(j&&(S.version!==q&&console.warn('The database "'+S.name+`" can't be downgraded from version `+S.db.version+" to version "+S.version+"."),S.version=S.db.version),tt||P){if(P){var Y=S.db.version+1;Y>S.version&&(S.version=Y)}return!0}return!1}function Lt(S){return new m(function(q,P){var j=new FileReader;j.onerror=P,j.onloadend=function(tt){var Y=btoa(tt.target.result||"");q({__local_forage_encoded_blob:!0,data:Y,type:S.type})},j.readAsBinaryString(S)})}function _t(S){var q=v(atob(S.data));return s([q],{type:S.type})}function ct(S){return S&&S.__local_forage_encoded_blob}function yt(S){var q=this,P=q._initReady().then(function(){var j=x[q._dbInfo.name];if(j&&j.dbReady)return j.dbReady});return g(P,S,S),P}function ft(S){V(S);for(var q=x[S.name],P=q.forages,j=0;j<P.length;j++){var tt=P[j];tt._dbInfo.db&&(tt._dbInfo.db.close(),tt._dbInfo.db=null)}return S.db=null,w(S).then(function(Y){return S.db=Y,at(S)?T(S):Y}).then(function(Y){S.db=q.db=Y;for(var gt=0;gt<P.length;gt++)P[gt]._dbInfo.db=Y}).catch(function(Y){throw et(S,Y),Y})}function ht(S,q,P,j){j===void 0&&(j=1);try{var tt=S.db.transaction(S.storeName,q);P(null,tt)}catch(Y){if(j>0&&(!S.db||Y.name==="InvalidStateError"||Y.name==="NotFoundError"))return m.resolve().then(function(){if(!S.db||Y.name==="NotFoundError"&&!S.db.objectStoreNames.contains(S.storeName)&&S.version<=S.db.version)return S.db&&(S.version=S.db.version+1),T(S)}).then(function(){return ft(S).then(function(){ht(S,q,P,j-1)})}).catch(P);P(Y)}}function Ft(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Nt(S){var q=this,P={db:null};if(S)for(var j in S)P[j]=S[j];var tt=x[P.name];tt||(tt=Ft(),x[P.name]=tt),tt.forages.push(q),q._initReady||(q._initReady=q.ready,q.ready=yt);var Y=[];function gt(){return m.resolve()}for(var bt=0;bt<tt.forages.length;bt++){var mt=tt.forages[bt];mt!==q&&Y.push(mt._initReady().catch(gt))}var Ct=tt.forages.slice(0);return m.all(Y).then(function(){return P.db=tt.db,w(P)}).then(function(Bt){return P.db=Bt,at(P,q._defaultConfig.version)?T(P):Bt}).then(function(Bt){P.db=tt.db=Bt,q._dbInfo=P;for(var Tt=0;Tt<Ct.length;Tt++){var Vt=Ct[Tt];Vt!==q&&(Vt._dbInfo.db=P.db,Vt._dbInfo.version=P.version)}})}function kt(S,q){var P=this;S=M(S);var j=new m(function(tt,Y){P.ready().then(function(){ht(P._dbInfo,z,function(gt,bt){if(gt)return Y(gt);try{var mt=bt.objectStore(P._dbInfo.storeName),Ct=mt.get(S);Ct.onsuccess=function(){var Bt=Ct.result;Bt===void 0&&(Bt=null),ct(Bt)&&(Bt=_t(Bt)),tt(Bt)},Ct.onerror=function(){Y(Ct.error)}}catch(Bt){Y(Bt)}})}).catch(Y)});return C(j,q),j}function A(S,q){var P=this,j=new m(function(tt,Y){P.ready().then(function(){ht(P._dbInfo,z,function(gt,bt){if(gt)return Y(gt);try{var mt=bt.objectStore(P._dbInfo.storeName),Ct=mt.openCursor(),Bt=1;Ct.onsuccess=function(){var Tt=Ct.result;if(Tt){var Vt=Tt.value;ct(Vt)&&(Vt=_t(Vt));var te=S(Vt,Tt.key,Bt++);te!==void 0?tt(te):Tt.continue()}else tt()},Ct.onerror=function(){Y(Ct.error)}}catch(Tt){Y(Tt)}})}).catch(Y)});return C(j,q),j}function c(S,q,P){var j=this;S=M(S);var tt=new m(function(Y,gt){var bt;j.ready().then(function(){return bt=j._dbInfo,it.call(q)==="[object Blob]"?L(bt.db).then(function(mt){return mt?q:Lt(q)}):q}).then(function(mt){ht(j._dbInfo,K,function(Ct,Bt){if(Ct)return gt(Ct);try{var Tt=Bt.objectStore(j._dbInfo.storeName);mt===null&&(mt=void 0);var Vt=Tt.put(mt,S);Bt.oncomplete=function(){mt===void 0&&(mt=null),Y(mt)},Bt.onabort=Bt.onerror=function(){var te=Vt.error?Vt.error:Vt.transaction.error;gt(te)}}catch(te){gt(te)}})}).catch(gt)});return C(tt,P),tt}function E(S,q){var P=this;S=M(S);var j=new m(function(tt,Y){P.ready().then(function(){ht(P._dbInfo,K,function(gt,bt){if(gt)return Y(gt);try{var mt=bt.objectStore(P._dbInfo.storeName),Ct=mt.delete(S);bt.oncomplete=function(){tt()},bt.onerror=function(){Y(Ct.error)},bt.onabort=function(){var Bt=Ct.error?Ct.error:Ct.transaction.error;Y(Bt)}}catch(Bt){Y(Bt)}})}).catch(Y)});return C(j,q),j}function d(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){ht(q._dbInfo,K,function(Y,gt){if(Y)return tt(Y);try{var bt=gt.objectStore(q._dbInfo.storeName),mt=bt.clear();gt.oncomplete=function(){j()},gt.onabort=gt.onerror=function(){var Ct=mt.error?mt.error:mt.transaction.error;tt(Ct)}}catch(Ct){tt(Ct)}})}).catch(tt)});return C(P,S),P}function G(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){ht(q._dbInfo,z,function(Y,gt){if(Y)return tt(Y);try{var bt=gt.objectStore(q._dbInfo.storeName),mt=bt.count();mt.onsuccess=function(){j(mt.result)},mt.onerror=function(){tt(mt.error)}}catch(Ct){tt(Ct)}})}).catch(tt)});return C(P,S),P}function U(S,q){var P=this,j=new m(function(tt,Y){if(S<0){tt(null);return}P.ready().then(function(){ht(P._dbInfo,z,function(gt,bt){if(gt)return Y(gt);try{var mt=bt.objectStore(P._dbInfo.storeName),Ct=!1,Bt=mt.openKeyCursor();Bt.onsuccess=function(){var Tt=Bt.result;if(!Tt){tt(null);return}S===0||Ct?tt(Tt.key):(Ct=!0,Tt.advance(S))},Bt.onerror=function(){Y(Bt.error)}}catch(Tt){Y(Tt)}})}).catch(Y)});return C(j,q),j}function b(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){ht(q._dbInfo,z,function(Y,gt){if(Y)return tt(Y);try{var bt=gt.objectStore(q._dbInfo.storeName),mt=bt.openKeyCursor(),Ct=[];mt.onsuccess=function(){var Bt=mt.result;if(!Bt){j(Ct);return}Ct.push(Bt.key),Bt.continue()},mt.onerror=function(){tt(mt.error)}}catch(Bt){tt(Bt)}})}).catch(tt)});return C(P,S),P}function J(S,q){q=$.apply(this,arguments);var P=this.config();S=typeof S!="function"&&S||{},S.name||(S.name=S.name||P.name,S.storeName=S.storeName||P.storeName);var j=this,tt;if(!S.name)tt=m.reject("Invalid arguments");else{var Y=S.name===P.name&&j._dbInfo.db,gt=Y?m.resolve(j._dbInfo.db):w(S).then(function(bt){var mt=x[S.name],Ct=mt.forages;mt.db=bt;for(var Bt=0;Bt<Ct.length;Bt++)Ct[Bt]._dbInfo.db=bt;return bt});S.storeName?tt=gt.then(function(bt){if(bt.objectStoreNames.contains(S.storeName)){var mt=bt.version+1;V(S);var Ct=x[S.name],Bt=Ct.forages;bt.close();for(var Tt=0;Tt<Bt.length;Tt++){var Vt=Bt[Tt];Vt._dbInfo.db=null,Vt._dbInfo.version=mt}var te=new m(function(ee,le){var re=I.open(S.name,mt);re.onerror=function(Ee){var Hn=re.result;Hn.close(),le(Ee)},re.onupgradeneeded=function(){var Ee=re.result;Ee.deleteObjectStore(S.storeName)},re.onsuccess=function(){var Ee=re.result;Ee.close(),ee(Ee)}});return te.then(function(ee){Ct.db=ee;for(var le=0;le<Bt.length;le++){var re=Bt[le];re._dbInfo.db=ee,X(re._dbInfo)}}).catch(function(ee){throw(et(S,ee)||m.resolve()).catch(function(){}),ee})}}):tt=gt.then(function(bt){V(S);var mt=x[S.name],Ct=mt.forages;bt.close();for(var Bt=0;Bt<Ct.length;Bt++){var Tt=Ct[Bt];Tt._dbInfo.db=null}var Vt=new m(function(te,ee){var le=I.deleteDatabase(S.name);le.onerror=function(){var re=le.result;re&&re.close(),ee(le.error)},le.onblocked=function(){console.warn('dropInstance blocked for database "'+S.name+'" until all open connections are closed')},le.onsuccess=function(){var re=le.result;re&&re.close(),te(re)}});return Vt.then(function(te){mt.db=te;for(var ee=0;ee<Ct.length;ee++){var le=Ct[ee];X(le._dbInfo)}}).catch(function(te){throw(et(S,te)||m.resolve()).catch(function(){}),te})})}return C(tt,q),tt}var It={_driver:"asyncStorage",_initStorage:Nt,_support:l(),iterate:A,getItem:kt,setItem:c,removeItem:E,clear:d,length:G,key:U,keys:b,dropInstance:J};function lt(){return typeof openDatabase=="function"}var At="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zt="~~local_forage_type~",xt=/^~~local_forage_type~([^~]+)~/,Mt="__lfsc__:",Gt=Mt.length,vt="arbf",Et="blob",Ot="si08",$t="ui08",Jt="uic8",ie="si16",ae="si32",B="ur16",p="ui32",y="fl32",O="fl64",H=Gt+vt.length,nt=Object.prototype.toString;function k(S){var q=S.length*.75,P=S.length,j,tt=0,Y,gt,bt,mt;S[S.length-1]==="="&&(q--,S[S.length-2]==="="&&q--);var Ct=new ArrayBuffer(q),Bt=new Uint8Array(Ct);for(j=0;j<P;j+=4)Y=At.indexOf(S[j]),gt=At.indexOf(S[j+1]),bt=At.indexOf(S[j+2]),mt=At.indexOf(S[j+3]),Bt[tt++]=Y<<2|gt>>4,Bt[tt++]=(gt&15)<<4|bt>>2,Bt[tt++]=(bt&3)<<6|mt&63;return Ct}function _(S){var q=new Uint8Array(S),P="",j;for(j=0;j<q.length;j+=3)P+=At[q[j]>>2],P+=At[(q[j]&3)<<4|q[j+1]>>4],P+=At[(q[j+1]&15)<<2|q[j+2]>>6],P+=At[q[j+2]&63];return q.length%3===2?P=P.substring(0,P.length-1)+"=":q.length%3===1&&(P=P.substring(0,P.length-2)+"=="),P}function h(S,q){var P="";if(S&&(P=nt.call(S)),S&&(P==="[object ArrayBuffer]"||S.buffer&&nt.call(S.buffer)==="[object ArrayBuffer]")){var j,tt=Mt;S instanceof ArrayBuffer?(j=S,tt+=vt):(j=S.buffer,P==="[object Int8Array]"?tt+=Ot:P==="[object Uint8Array]"?tt+=$t:P==="[object Uint8ClampedArray]"?tt+=Jt:P==="[object Int16Array]"?tt+=ie:P==="[object Uint16Array]"?tt+=B:P==="[object Int32Array]"?tt+=ae:P==="[object Uint32Array]"?tt+=p:P==="[object Float32Array]"?tt+=y:P==="[object Float64Array]"?tt+=O:q(new Error("Failed to get type for BinaryArray"))),q(tt+_(j))}else if(P==="[object Blob]"){var Y=new FileReader;Y.onload=function(){var gt=zt+S.type+"~"+_(this.result);q(Mt+Et+gt)},Y.readAsArrayBuffer(S)}else try{q(JSON.stringify(S))}catch(gt){console.error("Couldn't convert value into a JSON string: ",S),q(null,gt)}}function D(S){if(S.substring(0,Gt)!==Mt)return JSON.parse(S);var q=S.substring(H),P=S.substring(Gt,H),j;if(P===Et&&xt.test(q)){var tt=q.match(xt);j=tt[1],q=q.substring(tt[0].length)}var Y=k(q);switch(P){case vt:return Y;case Et:return s([Y],{type:j});case Ot:return new Int8Array(Y);case $t:return new Uint8Array(Y);case Jt:return new Uint8ClampedArray(Y);case ie:return new Int16Array(Y);case B:return new Uint16Array(Y);case ae:return new Int32Array(Y);case p:return new Uint32Array(Y);case y:return new Float32Array(Y);case O:return new Float64Array(Y);default:throw new Error("Unkown type: "+P)}}var Z={serialize:h,deserialize:D,stringToBuffer:k,bufferToString:_};function Q(S,q,P,j){S.executeSql("CREATE TABLE IF NOT EXISTS "+q.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],P,j)}function ot(S){var q=this,P={db:null};if(S)for(var j in S)P[j]=typeof S[j]!="string"?S[j].toString():S[j];var tt=new m(function(Y,gt){try{P.db=openDatabase(P.name,String(P.version),P.description,P.size)}catch(bt){return gt(bt)}P.db.transaction(function(bt){Q(bt,P,function(){q._dbInfo=P,Y()},function(mt,Ct){gt(Ct)})},gt)});return P.serializer=Z,tt}function W(S,q,P,j,tt,Y){S.executeSql(P,j,tt,function(gt,bt){bt.code===bt.SYNTAX_ERR?gt.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[q.storeName],function(mt,Ct){Ct.rows.length?Y(mt,bt):Q(mt,q,function(){mt.executeSql(P,j,tt,Y)},Y)},Y):Y(gt,bt)},Y)}function st(S,q){var P=this;S=M(S);var j=new m(function(tt,Y){P.ready().then(function(){var gt=P._dbInfo;gt.db.transaction(function(bt){W(bt,gt,"SELECT * FROM "+gt.storeName+" WHERE key = ? LIMIT 1",[S],function(mt,Ct){var Bt=Ct.rows.length?Ct.rows.item(0).value:null;Bt&&(Bt=gt.serializer.deserialize(Bt)),tt(Bt)},function(mt,Ct){Y(Ct)})})}).catch(Y)});return C(j,q),j}function ut(S,q){var P=this,j=new m(function(tt,Y){P.ready().then(function(){var gt=P._dbInfo;gt.db.transaction(function(bt){W(bt,gt,"SELECT * FROM "+gt.storeName,[],function(mt,Ct){for(var Bt=Ct.rows,Tt=Bt.length,Vt=0;Vt<Tt;Vt++){var te=Bt.item(Vt),ee=te.value;if(ee&&(ee=gt.serializer.deserialize(ee)),ee=S(ee,te.key,Vt+1),ee!==void 0){tt(ee);return}}tt()},function(mt,Ct){Y(Ct)})})}).catch(Y)});return C(j,q),j}function dt(S,q,P,j){var tt=this;S=M(S);var Y=new m(function(gt,bt){tt.ready().then(function(){q===void 0&&(q=null);var mt=q,Ct=tt._dbInfo;Ct.serializer.serialize(q,function(Bt,Tt){Tt?bt(Tt):Ct.db.transaction(function(Vt){W(Vt,Ct,"INSERT OR REPLACE INTO "+Ct.storeName+" (key, value) VALUES (?, ?)",[S,Bt],function(){gt(mt)},function(te,ee){bt(ee)})},function(Vt){if(Vt.code===Vt.QUOTA_ERR){if(j>0){gt(dt.apply(tt,[S,mt,P,j-1]));return}bt(Vt)}})})}).catch(bt)});return C(Y,P),Y}function rt(S,q,P){return dt.apply(this,[S,q,P,1])}function pt(S,q){var P=this;S=M(S);var j=new m(function(tt,Y){P.ready().then(function(){var gt=P._dbInfo;gt.db.transaction(function(bt){W(bt,gt,"DELETE FROM "+gt.storeName+" WHERE key = ?",[S],function(){tt()},function(mt,Ct){Y(Ct)})})}).catch(Y)});return C(j,q),j}function Ut(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){var Y=q._dbInfo;Y.db.transaction(function(gt){W(gt,Y,"DELETE FROM "+Y.storeName,[],function(){j()},function(bt,mt){tt(mt)})})}).catch(tt)});return C(P,S),P}function St(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){var Y=q._dbInfo;Y.db.transaction(function(gt){W(gt,Y,"SELECT COUNT(key) as c FROM "+Y.storeName,[],function(bt,mt){var Ct=mt.rows.item(0).c;j(Ct)},function(bt,mt){tt(mt)})})}).catch(tt)});return C(P,S),P}function wt(S,q){var P=this,j=new m(function(tt,Y){P.ready().then(function(){var gt=P._dbInfo;gt.db.transaction(function(bt){W(bt,gt,"SELECT key FROM "+gt.storeName+" WHERE id = ? LIMIT 1",[S+1],function(mt,Ct){var Bt=Ct.rows.length?Ct.rows.item(0).key:null;tt(Bt)},function(mt,Ct){Y(Ct)})})}).catch(Y)});return C(j,q),j}function Rt(S){var q=this,P=new m(function(j,tt){q.ready().then(function(){var Y=q._dbInfo;Y.db.transaction(function(gt){W(gt,Y,"SELECT key FROM "+Y.storeName,[],function(bt,mt){for(var Ct=[],Bt=0;Bt<mt.rows.length;Bt++)Ct.push(mt.rows.item(Bt).key);j(Ct)},function(bt,mt){tt(mt)})})}).catch(tt)});return C(P,S),P}function Dt(S){return new m(function(q,P){S.transaction(function(j){j.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(tt,Y){for(var gt=[],bt=0;bt<Y.rows.length;bt++)gt.push(Y.rows.item(bt).name);q({db:S,storeNames:gt})},function(tt,Y){P(Y)})},function(j){P(j)})})}function Yt(S,q){q=$.apply(this,arguments);var P=this.config();S=typeof S!="function"&&S||{},S.name||(S.name=S.name||P.name,S.storeName=S.storeName||P.storeName);var j=this,tt;return S.name?tt=new m(function(Y){var gt;S.name===P.name?gt=j._dbInfo.db:gt=openDatabase(S.name,"","",0),S.storeName?Y({db:gt,storeNames:[S.storeName]}):Y(Dt(gt))}).then(function(Y){return new m(function(gt,bt){Y.db.transaction(function(mt){function Ct(te){return new m(function(ee,le){mt.executeSql("DROP TABLE IF EXISTS "+te,[],function(){ee()},function(re,Ee){le(Ee)})})}for(var Bt=[],Tt=0,Vt=Y.storeNames.length;Tt<Vt;Tt++)Bt.push(Ct(Y.storeNames[Tt]));m.all(Bt).then(function(){gt()}).catch(function(te){bt(te)})},function(mt){bt(mt)})})}):tt=m.reject("Invalid arguments"),C(tt,q),tt}var Qt={_driver:"webSQLStorage",_initStorage:ot,_support:lt(),iterate:ut,getItem:st,setItem:rt,removeItem:pt,clear:Ut,length:St,key:wt,keys:Rt,dropInstance:Yt};function qt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Pt(S,q){var P=S.name+"/";return S.storeName!==q.storeName&&(P+=S.storeName+"/"),P}function jt(){var S="_localforage_support_test";try{return localStorage.setItem(S,!0),localStorage.removeItem(S),!1}catch{return!0}}function ue(){return!jt()||localStorage.length>0}function ge(S){var q=this,P={};if(S)for(var j in S)P[j]=S[j];return P.keyPrefix=Pt(S,q._defaultConfig),ue()?(q._dbInfo=P,P.serializer=Z,m.resolve()):m.reject()}function je(S){var q=this,P=q.ready().then(function(){for(var j=q._dbInfo.keyPrefix,tt=localStorage.length-1;tt>=0;tt--){var Y=localStorage.key(tt);Y.indexOf(j)===0&&localStorage.removeItem(Y)}});return C(P,S),P}function Se(S,q){var P=this;S=M(S);var j=P.ready().then(function(){var tt=P._dbInfo,Y=localStorage.getItem(tt.keyPrefix+S);return Y&&(Y=tt.serializer.deserialize(Y)),Y});return C(j,q),j}function Oe(S,q){var P=this,j=P.ready().then(function(){for(var tt=P._dbInfo,Y=tt.keyPrefix,gt=Y.length,bt=localStorage.length,mt=1,Ct=0;Ct<bt;Ct++){var Bt=localStorage.key(Ct);if(Bt.indexOf(Y)===0){var Tt=localStorage.getItem(Bt);if(Tt&&(Tt=tt.serializer.deserialize(Tt)),Tt=S(Tt,Bt.substring(gt),mt++),Tt!==void 0)return Tt}}});return C(j,q),j}function We(S,q){var P=this,j=P.ready().then(function(){var tt=P._dbInfo,Y;try{Y=localStorage.key(S)}catch{Y=null}return Y&&(Y=Y.substring(tt.keyPrefix.length)),Y});return C(j,q),j}function Ue(S){var q=this,P=q.ready().then(function(){for(var j=q._dbInfo,tt=localStorage.length,Y=[],gt=0;gt<tt;gt++){var bt=localStorage.key(gt);bt.indexOf(j.keyPrefix)===0&&Y.push(bt.substring(j.keyPrefix.length))}return Y});return C(P,S),P}function Pe(S){var q=this,P=q.keys().then(function(j){return j.length});return C(P,S),P}function Xe(S,q){var P=this;S=M(S);var j=P.ready().then(function(){var tt=P._dbInfo;localStorage.removeItem(tt.keyPrefix+S)});return C(j,q),j}function Fe(S,q,P){var j=this;S=M(S);var tt=j.ready().then(function(){q===void 0&&(q=null);var Y=q;return new m(function(gt,bt){var mt=j._dbInfo;mt.serializer.serialize(q,function(Ct,Bt){if(Bt)bt(Bt);else try{localStorage.setItem(mt.keyPrefix+S,Ct),gt(Y)}catch(Tt){(Tt.name==="QuotaExceededError"||Tt.name==="NS_ERROR_DOM_QUOTA_REACHED")&&bt(Tt),bt(Tt)}})})});return C(tt,P),tt}function Ce(S,q){if(q=$.apply(this,arguments),S=typeof S!="function"&&S||{},!S.name){var P=this.config();S.name=S.name||P.name,S.storeName=S.storeName||P.storeName}var j=this,tt;return S.name?tt=new m(function(Y){S.storeName?Y(Pt(S,j._defaultConfig)):Y(S.name+"/")}).then(function(Y){for(var gt=localStorage.length-1;gt>=0;gt--){var bt=localStorage.key(gt);bt.indexOf(Y)===0&&localStorage.removeItem(bt)}}):tt=m.reject("Invalid arguments"),C(tt,q),tt}var Qe={_driver:"localStorageWrapper",_initStorage:ge,_support:qt(),iterate:Oe,getItem:Se,setItem:Fe,removeItem:Xe,clear:je,length:Pe,key:We,keys:Ue,dropInstance:Ce},Bn=function(q,P){return q===P||typeof q=="number"&&typeof P=="number"&&isNaN(q)&&isNaN(P)},Zs=function(q,P){for(var j=q.length,tt=0;tt<j;){if(Bn(q[tt],P))return!0;tt++}return!1},ma=Array.isArray||function(S){return Object.prototype.toString.call(S)==="[object Array]"},Kn={},Ca={},xn={INDEXEDDB:It,WEBSQL:Qt,LOCALSTORAGE:Qe},Ys=[xn.INDEXEDDB._driver,xn.WEBSQL._driver,xn.LOCALSTORAGE._driver],Ei=["dropInstance"],eo=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Ei),Vs={description:"",driver:Ys.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function js(S,q){S[q]=function(){var P=arguments;return S.ready().then(function(){return S[q].apply(S,P)})}}function no(){for(var S=1;S<arguments.length;S++){var q=arguments[S];if(q)for(var P in q)q.hasOwnProperty(P)&&(ma(q[P])?arguments[0][P]=q[P].slice():arguments[0][P]=q[P])}return arguments[0]}var Ws=function(){function S(q){u(this,S);for(var P in xn)if(xn.hasOwnProperty(P)){var j=xn[P],tt=j._driver;this[P]=tt,Kn[tt]||this.defineDriver(j)}this._defaultConfig=no({},Vs),this._config=no({},this._defaultConfig,q),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return S.prototype.config=function(P){if((typeof P>"u"?"undefined":a(P))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var j in P){if(j==="storeName"&&(P[j]=P[j].replace(/\W/g,"_")),j==="version"&&typeof P[j]!="number")return new Error("Database version must be a number.");this._config[j]=P[j]}return"driver"in P&&P.driver?this.setDriver(this._config.driver):!0}else return typeof P=="string"?this._config[P]:this._config},S.prototype.defineDriver=function(P,j,tt){var Y=new m(function(gt,bt){try{var mt=P._driver,Ct=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!P._driver){bt(Ct);return}for(var Bt=eo.concat("_initStorage"),Tt=0,Vt=Bt.length;Tt<Vt;Tt++){var te=Bt[Tt],ee=!Zs(Ei,te);if((ee||P[te])&&typeof P[te]!="function"){bt(Ct);return}}var le=function(){for(var Hn=function(tl){return function(){var el=new Error("Method "+tl+" is not implemented by the current driver"),Ea=m.reject(el);return C(Ea,arguments[arguments.length-1]),Ea}},io=0,Js=Ei.length;io<Js;io++){var oo=Ei[io];P[oo]||(P[oo]=Hn(oo))}};le();var re=function(Hn){Kn[mt]&&console.info("Redefining LocalForage driver: "+mt),Kn[mt]=P,Ca[mt]=Hn,gt()};"_support"in P?P._support&&typeof P._support=="function"?P._support().then(re,bt):re(!!P._support):re(!0)}catch(Ee){bt(Ee)}});return g(Y,j,tt),Y},S.prototype.driver=function(){return this._driver||null},S.prototype.getDriver=function(P,j,tt){var Y=Kn[P]?m.resolve(Kn[P]):m.reject(new Error("Driver not found."));return g(Y,j,tt),Y},S.prototype.getSerializer=function(P){var j=m.resolve(Z);return g(j,P),j},S.prototype.ready=function(P){var j=this,tt=j._driverSet.then(function(){return j._ready===null&&(j._ready=j._initDriver()),j._ready});return g(tt,P,P),tt},S.prototype.setDriver=function(P,j,tt){var Y=this;ma(P)||(P=[P]);var gt=this._getSupportedDrivers(P);function bt(){Y._config.driver=Y.driver()}function mt(Tt){return Y._extend(Tt),bt(),Y._ready=Y._initStorage(Y._config),Y._ready}function Ct(Tt){return function(){var Vt=0;function te(){for(;Vt<Tt.length;){var ee=Tt[Vt];return Vt++,Y._dbInfo=null,Y._ready=null,Y.getDriver(ee).then(mt).catch(te)}bt();var le=new Error("No available storage method found.");return Y._driverSet=m.reject(le),Y._driverSet}return te()}}var Bt=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=Bt.then(function(){var Tt=gt[0];return Y._dbInfo=null,Y._ready=null,Y.getDriver(Tt).then(function(Vt){Y._driver=Vt._driver,bt(),Y._wrapLibraryMethodsWithReady(),Y._initDriver=Ct(gt)})}).catch(function(){bt();var Tt=new Error("No available storage method found.");return Y._driverSet=m.reject(Tt),Y._driverSet}),g(this._driverSet,j,tt),this._driverSet},S.prototype.supports=function(P){return!!Ca[P]},S.prototype._extend=function(P){no(this,P)},S.prototype._getSupportedDrivers=function(P){for(var j=[],tt=0,Y=P.length;tt<Y;tt++){var gt=P[tt];this.supports(gt)&&j.push(gt)}return j},S.prototype._wrapLibraryMethodsWithReady=function(){for(var P=0,j=eo.length;P<j;P++)js(this,eo[P])},S.prototype.createInstance=function(P){return new S(P)},S}(),Xs=new Ws;i.exports=Xs},{3:3}]},{},[4])(4)})}(ao)),ao.exports}var ol=il();const _n=nl(ol),ci=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{};var co={},Zn={},xa;function al(){if(xa)return Zn;xa=1,Zn.byteLength=r,Zn.toByteArray=l,Zn.fromByteArray=C;for(var n=[],t=[],e=typeof Uint8Array<"u"?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=i.length;o<a;++o)n[o]=i[o],t[i.charCodeAt(o)]=o;t[45]=62,t[95]=63;function u(g){var M=g.length;if(M%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var $=g.indexOf("=");$===-1&&($=M);var F=$===M?0:4-$%4;return[$,F]}function r(g){var M=u(g),$=M[0],F=M[1];return($+F)*3/4-F}function I(g,M,$){return(M+$)*3/4-$}function l(g){var M,$=u(g),F=$[0],R=$[1],x=new e(I(g,F,R)),it=0,z=R>0?F-4:F,K;for(K=0;K<z;K+=4)M=t[g.charCodeAt(K)]<<18|t[g.charCodeAt(K+1)]<<12|t[g.charCodeAt(K+2)]<<6|t[g.charCodeAt(K+3)],x[it++]=M>>16&255,x[it++]=M>>8&255,x[it++]=M&255;return R===2&&(M=t[g.charCodeAt(K)]<<2|t[g.charCodeAt(K+1)]>>4,x[it++]=M&255),R===1&&(M=t[g.charCodeAt(K)]<<10|t[g.charCodeAt(K+1)]<<4|t[g.charCodeAt(K+2)]>>2,x[it++]=M>>8&255,x[it++]=M&255),x}function s(g){return n[g>>18&63]+n[g>>12&63]+n[g>>6&63]+n[g&63]}function m(g,M,$){for(var F,R=[],x=M;x<$;x+=3)F=(g[x]<<16&16711680)+(g[x+1]<<8&65280)+(g[x+2]&255),R.push(s(F));return R.join("")}function C(g){for(var M,$=g.length,F=$%3,R=[],x=16383,it=0,z=$-F;it<z;it+=x)R.push(m(g,it,it+x>z?z:it+x));return F===1?(M=g[$-1],R.push(n[M>>2]+n[M<<4&63]+"==")):F===2&&(M=(g[$-2]<<8)+g[$-1],R.push(n[M>>10]+n[M>>4&63]+n[M<<2&63]+"=")),R.join("")}return Zn}var Fi={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Fa;function cl(){return Fa||(Fa=1,Fi.read=function(n,t,e,i,o){var a,u,r=o*8-i-1,I=(1<<r)-1,l=I>>1,s=-7,m=e?o-1:0,C=e?-1:1,g=n[t+m];for(m+=C,a=g&(1<<-s)-1,g>>=-s,s+=r;s>0;a=a*256+n[t+m],m+=C,s-=8);for(u=a&(1<<-s)-1,a>>=-s,s+=i;s>0;u=u*256+n[t+m],m+=C,s-=8);if(a===0)a=1-l;else{if(a===I)return u?NaN:(g?-1:1)*(1/0);u=u+Math.pow(2,i),a=a-l}return(g?-1:1)*u*Math.pow(2,a-i)},Fi.write=function(n,t,e,i,o,a){var u,r,I,l=a*8-o-1,s=(1<<l)-1,m=s>>1,C=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=i?0:a-1,M=i?1:-1,$=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(r=isNaN(t)?1:0,u=s):(u=Math.floor(Math.log(t)/Math.LN2),t*(I=Math.pow(2,-u))<1&&(u--,I*=2),u+m>=1?t+=C/I:t+=C*Math.pow(2,1-m),t*I>=2&&(u++,I/=2),u+m>=s?(r=0,u=s):u+m>=1?(r=(t*I-1)*Math.pow(2,o),u=u+m):(r=t*Math.pow(2,m-1)*Math.pow(2,o),u=0));o>=8;n[e+g]=r&255,g+=M,r/=256,o-=8);for(u=u<<o|r,l+=o;l>0;n[e+g]=u&255,g+=M,u/=256,l-=8);n[e+g-M]|=$*128}),Fi}/*!
|
|
7
|
-
* The buffer module from node.js, for the browser.
|
|
8
|
-
*
|
|
9
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
10
|
-
* @license MIT
|
|
11
|
-
*/var va;function rl(){return va||(va=1,function(n){const t=al(),e=cl(),i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=r,n.SlowBuffer=x,n.INSPECT_MAX_BYTES=50;const o=2147483647;n.kMaxLength=o,r.TYPED_ARRAY_SUPPORT=a(),!r.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const B=new Uint8Array(1),p={foo:function(){return 42}};return Object.setPrototypeOf(p,Uint8Array.prototype),Object.setPrototypeOf(B,p),B.foo()===42}catch{return!1}}Object.defineProperty(r.prototype,"parent",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.buffer}}),Object.defineProperty(r.prototype,"offset",{enumerable:!0,get:function(){if(r.isBuffer(this))return this.byteOffset}});function u(B){if(B>o)throw new RangeError('The value "'+B+'" is invalid for option "size"');const p=new Uint8Array(B);return Object.setPrototypeOf(p,r.prototype),p}function r(B,p,y){if(typeof B=="number"){if(typeof p=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(B)}return I(B,p,y)}r.poolSize=8192;function I(B,p,y){if(typeof B=="string")return C(B,p);if(ArrayBuffer.isView(B))return M(B);if(B==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof B);if(Ot(B,ArrayBuffer)||B&&Ot(B.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ot(B,SharedArrayBuffer)||B&&Ot(B.buffer,SharedArrayBuffer)))return $(B,p,y);if(typeof B=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const O=B.valueOf&&B.valueOf();if(O!=null&&O!==B)return r.from(O,p,y);const H=F(B);if(H)return H;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof B[Symbol.toPrimitive]=="function")return r.from(B[Symbol.toPrimitive]("string"),p,y);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof B)}r.from=function(B,p,y){return I(B,p,y)},Object.setPrototypeOf(r.prototype,Uint8Array.prototype),Object.setPrototypeOf(r,Uint8Array);function l(B){if(typeof B!="number")throw new TypeError('"size" argument must be of type number');if(B<0)throw new RangeError('The value "'+B+'" is invalid for option "size"')}function s(B,p,y){return l(B),B<=0?u(B):p!==void 0?typeof y=="string"?u(B).fill(p,y):u(B).fill(p):u(B)}r.alloc=function(B,p,y){return s(B,p,y)};function m(B){return l(B),u(B<0?0:R(B)|0)}r.allocUnsafe=function(B){return m(B)},r.allocUnsafeSlow=function(B){return m(B)};function C(B,p){if((typeof p!="string"||p==="")&&(p="utf8"),!r.isEncoding(p))throw new TypeError("Unknown encoding: "+p);const y=it(B,p)|0;let O=u(y);const H=O.write(B,p);return H!==y&&(O=O.slice(0,H)),O}function g(B){const p=B.length<0?0:R(B.length)|0,y=u(p);for(let O=0;O<p;O+=1)y[O]=B[O]&255;return y}function M(B){if(Ot(B,Uint8Array)){const p=new Uint8Array(B);return $(p.buffer,p.byteOffset,p.byteLength)}return g(B)}function $(B,p,y){if(p<0||B.byteLength<p)throw new RangeError('"offset" is outside of buffer bounds');if(B.byteLength<p+(y||0))throw new RangeError('"length" is outside of buffer bounds');let O;return p===void 0&&y===void 0?O=new Uint8Array(B):y===void 0?O=new Uint8Array(B,p):O=new Uint8Array(B,p,y),Object.setPrototypeOf(O,r.prototype),O}function F(B){if(r.isBuffer(B)){const p=R(B.length)|0,y=u(p);return y.length===0||B.copy(y,0,0,p),y}if(B.length!==void 0)return typeof B.length!="number"||$t(B.length)?u(0):g(B);if(B.type==="Buffer"&&Array.isArray(B.data))return g(B.data)}function R(B){if(B>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return B|0}function x(B){return+B!=B&&(B=0),r.alloc(+B)}r.isBuffer=function(p){return p!=null&&p._isBuffer===!0&&p!==r.prototype},r.compare=function(p,y){if(Ot(p,Uint8Array)&&(p=r.from(p,p.offset,p.byteLength)),Ot(y,Uint8Array)&&(y=r.from(y,y.offset,y.byteLength)),!r.isBuffer(p)||!r.isBuffer(y))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(p===y)return 0;let O=p.length,H=y.length;for(let nt=0,k=Math.min(O,H);nt<k;++nt)if(p[nt]!==y[nt]){O=p[nt],H=y[nt];break}return O<H?-1:H<O?1:0},r.isEncoding=function(p){switch(String(p).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.concat=function(p,y){if(!Array.isArray(p))throw new TypeError('"list" argument must be an Array of Buffers');if(p.length===0)return r.alloc(0);let O;if(y===void 0)for(y=0,O=0;O<p.length;++O)y+=p[O].length;const H=r.allocUnsafe(y);let nt=0;for(O=0;O<p.length;++O){let k=p[O];if(Ot(k,Uint8Array))nt+k.length>H.length?(r.isBuffer(k)||(k=r.from(k)),k.copy(H,nt)):Uint8Array.prototype.set.call(H,k,nt);else if(r.isBuffer(k))k.copy(H,nt);else throw new TypeError('"list" argument must be an Array of Buffers');nt+=k.length}return H};function it(B,p){if(r.isBuffer(B))return B.length;if(ArrayBuffer.isView(B)||Ot(B,ArrayBuffer))return B.byteLength;if(typeof B!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof B);const y=B.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&y===0)return 0;let H=!1;for(;;)switch(p){case"ascii":case"latin1":case"binary":return y;case"utf8":case"utf-8":return xt(B).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y*2;case"hex":return y>>>1;case"base64":return vt(B).length;default:if(H)return O?-1:xt(B).length;p=(""+p).toLowerCase(),H=!0}}r.byteLength=it;function z(B,p,y){let O=!1;if((p===void 0||p<0)&&(p=0),p>this.length||((y===void 0||y>this.length)&&(y=this.length),y<=0)||(y>>>=0,p>>>=0,y<=p))return"";for(B||(B="utf8");;)switch(B){case"hex":return yt(this,p,y);case"utf8":case"utf-8":return T(this,p,y);case"ascii":return _t(this,p,y);case"latin1":case"binary":return ct(this,p,y);case"base64":return w(this,p,y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ft(this,p,y);default:if(O)throw new TypeError("Unknown encoding: "+B);B=(B+"").toLowerCase(),O=!0}}r.prototype._isBuffer=!0;function K(B,p,y){const O=B[p];B[p]=B[y],B[y]=O}r.prototype.swap16=function(){const p=this.length;if(p%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let y=0;y<p;y+=2)K(this,y,y+1);return this},r.prototype.swap32=function(){const p=this.length;if(p%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let y=0;y<p;y+=4)K(this,y,y+3),K(this,y+1,y+2);return this},r.prototype.swap64=function(){const p=this.length;if(p%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let y=0;y<p;y+=8)K(this,y,y+7),K(this,y+1,y+6),K(this,y+2,y+5),K(this,y+3,y+4);return this},r.prototype.toString=function(){const p=this.length;return p===0?"":arguments.length===0?T(this,0,p):z.apply(this,arguments)},r.prototype.toLocaleString=r.prototype.toString,r.prototype.equals=function(p){if(!r.isBuffer(p))throw new TypeError("Argument must be a Buffer");return this===p?!0:r.compare(this,p)===0},r.prototype.inspect=function(){let p="";const y=n.INSPECT_MAX_BYTES;return p=this.toString("hex",0,y).replace(/(.{2})/g,"$1 ").trim(),this.length>y&&(p+=" ... "),"<Buffer "+p+">"},i&&(r.prototype[i]=r.prototype.inspect),r.prototype.compare=function(p,y,O,H,nt){if(Ot(p,Uint8Array)&&(p=r.from(p,p.offset,p.byteLength)),!r.isBuffer(p))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof p);if(y===void 0&&(y=0),O===void 0&&(O=p?p.length:0),H===void 0&&(H=0),nt===void 0&&(nt=this.length),y<0||O>p.length||H<0||nt>this.length)throw new RangeError("out of range index");if(H>=nt&&y>=O)return 0;if(H>=nt)return-1;if(y>=O)return 1;if(y>>>=0,O>>>=0,H>>>=0,nt>>>=0,this===p)return 0;let k=nt-H,_=O-y;const h=Math.min(k,_),D=this.slice(H,nt),Z=p.slice(y,O);for(let Q=0;Q<h;++Q)if(D[Q]!==Z[Q]){k=D[Q],_=Z[Q];break}return k<_?-1:_<k?1:0};function v(B,p,y,O,H){if(B.length===0)return-1;if(typeof y=="string"?(O=y,y=0):y>2147483647?y=2147483647:y<-2147483648&&(y=-2147483648),y=+y,$t(y)&&(y=H?0:B.length-1),y<0&&(y=B.length+y),y>=B.length){if(H)return-1;y=B.length-1}else if(y<0)if(H)y=0;else return-1;if(typeof p=="string"&&(p=r.from(p,O)),r.isBuffer(p))return p.length===0?-1:f(B,p,y,O,H);if(typeof p=="number")return p=p&255,typeof Uint8Array.prototype.indexOf=="function"?H?Uint8Array.prototype.indexOf.call(B,p,y):Uint8Array.prototype.lastIndexOf.call(B,p,y):f(B,[p],y,O,H);throw new TypeError("val must be string, number or Buffer")}function f(B,p,y,O,H){let nt=1,k=B.length,_=p.length;if(O!==void 0&&(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le")){if(B.length<2||p.length<2)return-1;nt=2,k/=2,_/=2,y/=2}function h(Z,Q){return nt===1?Z[Q]:Z.readUInt16BE(Q*nt)}let D;if(H){let Z=-1;for(D=y;D<k;D++)if(h(B,D)===h(p,Z===-1?0:D-Z)){if(Z===-1&&(Z=D),D-Z+1===_)return Z*nt}else Z!==-1&&(D-=D-Z),Z=-1}else for(y+_>k&&(y=k-_),D=y;D>=0;D--){let Z=!0;for(let Q=0;Q<_;Q++)if(h(B,D+Q)!==h(p,Q)){Z=!1;break}if(Z)return D}return-1}r.prototype.includes=function(p,y,O){return this.indexOf(p,y,O)!==-1},r.prototype.indexOf=function(p,y,O){return v(this,p,y,O,!0)},r.prototype.lastIndexOf=function(p,y,O){return v(this,p,y,O,!1)};function L(B,p,y,O){y=Number(y)||0;const H=B.length-y;O?(O=Number(O),O>H&&(O=H)):O=H;const nt=p.length;O>nt/2&&(O=nt/2);let k;for(k=0;k<O;++k){const _=parseInt(p.substr(k*2,2),16);if($t(_))return k;B[y+k]=_}return k}function V(B,p,y,O){return Et(xt(p,B.length-y),B,y,O)}function X(B,p,y,O){return Et(Mt(p),B,y,O)}function et(B,p,y,O){return Et(vt(p),B,y,O)}function N(B,p,y,O){return Et(Gt(p,B.length-y),B,y,O)}r.prototype.write=function(p,y,O,H){if(y===void 0)H="utf8",O=this.length,y=0;else if(O===void 0&&typeof y=="string")H=y,O=this.length,y=0;else if(isFinite(y))y=y>>>0,isFinite(O)?(O=O>>>0,H===void 0&&(H="utf8")):(H=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const nt=this.length-y;if((O===void 0||O>nt)&&(O=nt),p.length>0&&(O<0||y<0)||y>this.length)throw new RangeError("Attempt to write outside buffer bounds");H||(H="utf8");let k=!1;for(;;)switch(H){case"hex":return L(this,p,y,O);case"utf8":case"utf-8":return V(this,p,y,O);case"ascii":case"latin1":case"binary":return X(this,p,y,O);case"base64":return et(this,p,y,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,p,y,O);default:if(k)throw new TypeError("Unknown encoding: "+H);H=(""+H).toLowerCase(),k=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(B,p,y){return p===0&&y===B.length?t.fromByteArray(B):t.fromByteArray(B.slice(p,y))}function T(B,p,y){y=Math.min(B.length,y);const O=[];let H=p;for(;H<y;){const nt=B[H];let k=null,_=nt>239?4:nt>223?3:nt>191?2:1;if(H+_<=y){let h,D,Z,Q;switch(_){case 1:nt<128&&(k=nt);break;case 2:h=B[H+1],(h&192)===128&&(Q=(nt&31)<<6|h&63,Q>127&&(k=Q));break;case 3:h=B[H+1],D=B[H+2],(h&192)===128&&(D&192)===128&&(Q=(nt&15)<<12|(h&63)<<6|D&63,Q>2047&&(Q<55296||Q>57343)&&(k=Q));break;case 4:h=B[H+1],D=B[H+2],Z=B[H+3],(h&192)===128&&(D&192)===128&&(Z&192)===128&&(Q=(nt&15)<<18|(h&63)<<12|(D&63)<<6|Z&63,Q>65535&&Q<1114112&&(k=Q))}}k===null?(k=65533,_=1):k>65535&&(k-=65536,O.push(k>>>10&1023|55296),k=56320|k&1023),O.push(k),H+=_}return Lt(O)}const at=4096;function Lt(B){const p=B.length;if(p<=at)return String.fromCharCode.apply(String,B);let y="",O=0;for(;O<p;)y+=String.fromCharCode.apply(String,B.slice(O,O+=at));return y}function _t(B,p,y){let O="";y=Math.min(B.length,y);for(let H=p;H<y;++H)O+=String.fromCharCode(B[H]&127);return O}function ct(B,p,y){let O="";y=Math.min(B.length,y);for(let H=p;H<y;++H)O+=String.fromCharCode(B[H]);return O}function yt(B,p,y){const O=B.length;(!p||p<0)&&(p=0),(!y||y<0||y>O)&&(y=O);let H="";for(let nt=p;nt<y;++nt)H+=Jt[B[nt]];return H}function ft(B,p,y){const O=B.slice(p,y);let H="";for(let nt=0;nt<O.length-1;nt+=2)H+=String.fromCharCode(O[nt]+O[nt+1]*256);return H}r.prototype.slice=function(p,y){const O=this.length;p=~~p,y=y===void 0?O:~~y,p<0?(p+=O,p<0&&(p=0)):p>O&&(p=O),y<0?(y+=O,y<0&&(y=0)):y>O&&(y=O),y<p&&(y=p);const H=this.subarray(p,y);return Object.setPrototypeOf(H,r.prototype),H};function ht(B,p,y){if(B%1!==0||B<0)throw new RangeError("offset is not uint");if(B+p>y)throw new RangeError("Trying to access beyond buffer length")}r.prototype.readUintLE=r.prototype.readUIntLE=function(p,y,O){p=p>>>0,y=y>>>0,O||ht(p,y,this.length);let H=this[p],nt=1,k=0;for(;++k<y&&(nt*=256);)H+=this[p+k]*nt;return H},r.prototype.readUintBE=r.prototype.readUIntBE=function(p,y,O){p=p>>>0,y=y>>>0,O||ht(p,y,this.length);let H=this[p+--y],nt=1;for(;y>0&&(nt*=256);)H+=this[p+--y]*nt;return H},r.prototype.readUint8=r.prototype.readUInt8=function(p,y){return p=p>>>0,y||ht(p,1,this.length),this[p]},r.prototype.readUint16LE=r.prototype.readUInt16LE=function(p,y){return p=p>>>0,y||ht(p,2,this.length),this[p]|this[p+1]<<8},r.prototype.readUint16BE=r.prototype.readUInt16BE=function(p,y){return p=p>>>0,y||ht(p,2,this.length),this[p]<<8|this[p+1]},r.prototype.readUint32LE=r.prototype.readUInt32LE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),(this[p]|this[p+1]<<8|this[p+2]<<16)+this[p+3]*16777216},r.prototype.readUint32BE=r.prototype.readUInt32BE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),this[p]*16777216+(this[p+1]<<16|this[p+2]<<8|this[p+3])},r.prototype.readBigUInt64LE=ie(function(p){p=p>>>0,It(p,"offset");const y=this[p],O=this[p+7];(y===void 0||O===void 0)&<(p,this.length-8);const H=y+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24,nt=this[++p]+this[++p]*2**8+this[++p]*2**16+O*2**24;return BigInt(H)+(BigInt(nt)<<BigInt(32))}),r.prototype.readBigUInt64BE=ie(function(p){p=p>>>0,It(p,"offset");const y=this[p],O=this[p+7];(y===void 0||O===void 0)&<(p,this.length-8);const H=y*2**24+this[++p]*2**16+this[++p]*2**8+this[++p],nt=this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+O;return(BigInt(H)<<BigInt(32))+BigInt(nt)}),r.prototype.readIntLE=function(p,y,O){p=p>>>0,y=y>>>0,O||ht(p,y,this.length);let H=this[p],nt=1,k=0;for(;++k<y&&(nt*=256);)H+=this[p+k]*nt;return nt*=128,H>=nt&&(H-=Math.pow(2,8*y)),H},r.prototype.readIntBE=function(p,y,O){p=p>>>0,y=y>>>0,O||ht(p,y,this.length);let H=y,nt=1,k=this[p+--H];for(;H>0&&(nt*=256);)k+=this[p+--H]*nt;return nt*=128,k>=nt&&(k-=Math.pow(2,8*y)),k},r.prototype.readInt8=function(p,y){return p=p>>>0,y||ht(p,1,this.length),this[p]&128?(255-this[p]+1)*-1:this[p]},r.prototype.readInt16LE=function(p,y){p=p>>>0,y||ht(p,2,this.length);const O=this[p]|this[p+1]<<8;return O&32768?O|4294901760:O},r.prototype.readInt16BE=function(p,y){p=p>>>0,y||ht(p,2,this.length);const O=this[p+1]|this[p]<<8;return O&32768?O|4294901760:O},r.prototype.readInt32LE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),this[p]|this[p+1]<<8|this[p+2]<<16|this[p+3]<<24},r.prototype.readInt32BE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),this[p]<<24|this[p+1]<<16|this[p+2]<<8|this[p+3]},r.prototype.readBigInt64LE=ie(function(p){p=p>>>0,It(p,"offset");const y=this[p],O=this[p+7];(y===void 0||O===void 0)&<(p,this.length-8);const H=this[p+4]+this[p+5]*2**8+this[p+6]*2**16+(O<<24);return(BigInt(H)<<BigInt(32))+BigInt(y+this[++p]*2**8+this[++p]*2**16+this[++p]*2**24)}),r.prototype.readBigInt64BE=ie(function(p){p=p>>>0,It(p,"offset");const y=this[p],O=this[p+7];(y===void 0||O===void 0)&<(p,this.length-8);const H=(y<<24)+this[++p]*2**16+this[++p]*2**8+this[++p];return(BigInt(H)<<BigInt(32))+BigInt(this[++p]*2**24+this[++p]*2**16+this[++p]*2**8+O)}),r.prototype.readFloatLE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),e.read(this,p,!0,23,4)},r.prototype.readFloatBE=function(p,y){return p=p>>>0,y||ht(p,4,this.length),e.read(this,p,!1,23,4)},r.prototype.readDoubleLE=function(p,y){return p=p>>>0,y||ht(p,8,this.length),e.read(this,p,!0,52,8)},r.prototype.readDoubleBE=function(p,y){return p=p>>>0,y||ht(p,8,this.length),e.read(this,p,!1,52,8)};function Ft(B,p,y,O,H,nt){if(!r.isBuffer(B))throw new TypeError('"buffer" argument must be a Buffer instance');if(p>H||p<nt)throw new RangeError('"value" argument is out of bounds');if(y+O>B.length)throw new RangeError("Index out of range")}r.prototype.writeUintLE=r.prototype.writeUIntLE=function(p,y,O,H){if(p=+p,y=y>>>0,O=O>>>0,!H){const _=Math.pow(2,8*O)-1;Ft(this,p,y,O,_,0)}let nt=1,k=0;for(this[y]=p&255;++k<O&&(nt*=256);)this[y+k]=p/nt&255;return y+O},r.prototype.writeUintBE=r.prototype.writeUIntBE=function(p,y,O,H){if(p=+p,y=y>>>0,O=O>>>0,!H){const _=Math.pow(2,8*O)-1;Ft(this,p,y,O,_,0)}let nt=O-1,k=1;for(this[y+nt]=p&255;--nt>=0&&(k*=256);)this[y+nt]=p/k&255;return y+O},r.prototype.writeUint8=r.prototype.writeUInt8=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,1,255,0),this[y]=p&255,y+1},r.prototype.writeUint16LE=r.prototype.writeUInt16LE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,2,65535,0),this[y]=p&255,this[y+1]=p>>>8,y+2},r.prototype.writeUint16BE=r.prototype.writeUInt16BE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,2,65535,0),this[y]=p>>>8,this[y+1]=p&255,y+2},r.prototype.writeUint32LE=r.prototype.writeUInt32LE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,4,4294967295,0),this[y+3]=p>>>24,this[y+2]=p>>>16,this[y+1]=p>>>8,this[y]=p&255,y+4},r.prototype.writeUint32BE=r.prototype.writeUInt32BE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,4,4294967295,0),this[y]=p>>>24,this[y+1]=p>>>16,this[y+2]=p>>>8,this[y+3]=p&255,y+4};function Nt(B,p,y,O,H){J(p,O,H,B,y,7);let nt=Number(p&BigInt(4294967295));B[y++]=nt,nt=nt>>8,B[y++]=nt,nt=nt>>8,B[y++]=nt,nt=nt>>8,B[y++]=nt;let k=Number(p>>BigInt(32)&BigInt(4294967295));return B[y++]=k,k=k>>8,B[y++]=k,k=k>>8,B[y++]=k,k=k>>8,B[y++]=k,y}function kt(B,p,y,O,H){J(p,O,H,B,y,7);let nt=Number(p&BigInt(4294967295));B[y+7]=nt,nt=nt>>8,B[y+6]=nt,nt=nt>>8,B[y+5]=nt,nt=nt>>8,B[y+4]=nt;let k=Number(p>>BigInt(32)&BigInt(4294967295));return B[y+3]=k,k=k>>8,B[y+2]=k,k=k>>8,B[y+1]=k,k=k>>8,B[y]=k,y+8}r.prototype.writeBigUInt64LE=ie(function(p,y=0){return Nt(this,p,y,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeBigUInt64BE=ie(function(p,y=0){return kt(this,p,y,BigInt(0),BigInt("0xffffffffffffffff"))}),r.prototype.writeIntLE=function(p,y,O,H){if(p=+p,y=y>>>0,!H){const h=Math.pow(2,8*O-1);Ft(this,p,y,O,h-1,-h)}let nt=0,k=1,_=0;for(this[y]=p&255;++nt<O&&(k*=256);)p<0&&_===0&&this[y+nt-1]!==0&&(_=1),this[y+nt]=(p/k>>0)-_&255;return y+O},r.prototype.writeIntBE=function(p,y,O,H){if(p=+p,y=y>>>0,!H){const h=Math.pow(2,8*O-1);Ft(this,p,y,O,h-1,-h)}let nt=O-1,k=1,_=0;for(this[y+nt]=p&255;--nt>=0&&(k*=256);)p<0&&_===0&&this[y+nt+1]!==0&&(_=1),this[y+nt]=(p/k>>0)-_&255;return y+O},r.prototype.writeInt8=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,1,127,-128),p<0&&(p=255+p+1),this[y]=p&255,y+1},r.prototype.writeInt16LE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,2,32767,-32768),this[y]=p&255,this[y+1]=p>>>8,y+2},r.prototype.writeInt16BE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,2,32767,-32768),this[y]=p>>>8,this[y+1]=p&255,y+2},r.prototype.writeInt32LE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,4,2147483647,-2147483648),this[y]=p&255,this[y+1]=p>>>8,this[y+2]=p>>>16,this[y+3]=p>>>24,y+4},r.prototype.writeInt32BE=function(p,y,O){return p=+p,y=y>>>0,O||Ft(this,p,y,4,2147483647,-2147483648),p<0&&(p=4294967295+p+1),this[y]=p>>>24,this[y+1]=p>>>16,this[y+2]=p>>>8,this[y+3]=p&255,y+4},r.prototype.writeBigInt64LE=ie(function(p,y=0){return Nt(this,p,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),r.prototype.writeBigInt64BE=ie(function(p,y=0){return kt(this,p,y,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function A(B,p,y,O,H,nt){if(y+O>B.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("Index out of range")}function c(B,p,y,O,H){return p=+p,y=y>>>0,H||A(B,p,y,4),e.write(B,p,y,O,23,4),y+4}r.prototype.writeFloatLE=function(p,y,O){return c(this,p,y,!0,O)},r.prototype.writeFloatBE=function(p,y,O){return c(this,p,y,!1,O)};function E(B,p,y,O,H){return p=+p,y=y>>>0,H||A(B,p,y,8),e.write(B,p,y,O,52,8),y+8}r.prototype.writeDoubleLE=function(p,y,O){return E(this,p,y,!0,O)},r.prototype.writeDoubleBE=function(p,y,O){return E(this,p,y,!1,O)},r.prototype.copy=function(p,y,O,H){if(!r.isBuffer(p))throw new TypeError("argument should be a Buffer");if(O||(O=0),!H&&H!==0&&(H=this.length),y>=p.length&&(y=p.length),y||(y=0),H>0&&H<O&&(H=O),H===O||p.length===0||this.length===0)return 0;if(y<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(H<0)throw new RangeError("sourceEnd out of bounds");H>this.length&&(H=this.length),p.length-y<H-O&&(H=p.length-y+O);const nt=H-O;return this===p&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(y,O,H):Uint8Array.prototype.set.call(p,this.subarray(O,H),y),nt},r.prototype.fill=function(p,y,O,H){if(typeof p=="string"){if(typeof y=="string"?(H=y,y=0,O=this.length):typeof O=="string"&&(H=O,O=this.length),H!==void 0&&typeof H!="string")throw new TypeError("encoding must be a string");if(typeof H=="string"&&!r.isEncoding(H))throw new TypeError("Unknown encoding: "+H);if(p.length===1){const k=p.charCodeAt(0);(H==="utf8"&&k<128||H==="latin1")&&(p=k)}}else typeof p=="number"?p=p&255:typeof p=="boolean"&&(p=Number(p));if(y<0||this.length<y||this.length<O)throw new RangeError("Out of range index");if(O<=y)return this;y=y>>>0,O=O===void 0?this.length:O>>>0,p||(p=0);let nt;if(typeof p=="number")for(nt=y;nt<O;++nt)this[nt]=p;else{const k=r.isBuffer(p)?p:r.from(p,H),_=k.length;if(_===0)throw new TypeError('The value "'+p+'" is invalid for argument "value"');for(nt=0;nt<O-y;++nt)this[nt+y]=k[nt%_]}return this};const d={};function G(B,p,y){d[B]=class extends y{constructor(){super(),Object.defineProperty(this,"message",{value:p.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${B}]`,this.stack,delete this.name}get code(){return B}set code(H){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:H,writable:!0})}toString(){return`${this.name} [${B}]: ${this.message}`}}}G("ERR_BUFFER_OUT_OF_BOUNDS",function(B){return B?`${B} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),G("ERR_INVALID_ARG_TYPE",function(B,p){return`The "${B}" argument must be of type number. Received type ${typeof p}`},TypeError),G("ERR_OUT_OF_RANGE",function(B,p,y){let O=`The value of "${B}" is out of range.`,H=y;return Number.isInteger(y)&&Math.abs(y)>2**32?H=U(String(y)):typeof y=="bigint"&&(H=String(y),(y>BigInt(2)**BigInt(32)||y<-(BigInt(2)**BigInt(32)))&&(H=U(H)),H+="n"),O+=` It must be ${p}. Received ${H}`,O},RangeError);function U(B){let p="",y=B.length;const O=B[0]==="-"?1:0;for(;y>=O+4;y-=3)p=`_${B.slice(y-3,y)}${p}`;return`${B.slice(0,y)}${p}`}function b(B,p,y){It(p,"offset"),(B[p]===void 0||B[p+y]===void 0)&<(p,B.length-(y+1))}function J(B,p,y,O,H,nt){if(B>y||B<p){const k=typeof p=="bigint"?"n":"";let _;throw p===0||p===BigInt(0)?_=`>= 0${k} and < 2${k} ** ${(nt+1)*8}${k}`:_=`>= -(2${k} ** ${(nt+1)*8-1}${k}) and < 2 ** ${(nt+1)*8-1}${k}`,new d.ERR_OUT_OF_RANGE("value",_,B)}b(O,H,nt)}function It(B,p){if(typeof B!="number")throw new d.ERR_INVALID_ARG_TYPE(p,"number",B)}function lt(B,p,y){throw Math.floor(B)!==B?(It(B,y),new d.ERR_OUT_OF_RANGE("offset","an integer",B)):p<0?new d.ERR_BUFFER_OUT_OF_BOUNDS:new d.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${p}`,B)}const At=/[^+/0-9A-Za-z-_]/g;function zt(B){if(B=B.split("=")[0],B=B.trim().replace(At,""),B.length<2)return"";for(;B.length%4!==0;)B=B+"=";return B}function xt(B,p){p=p||1/0;let y;const O=B.length;let H=null;const nt=[];for(let k=0;k<O;++k){if(y=B.charCodeAt(k),y>55295&&y<57344){if(!H){if(y>56319){(p-=3)>-1&&nt.push(239,191,189);continue}else if(k+1===O){(p-=3)>-1&&nt.push(239,191,189);continue}H=y;continue}if(y<56320){(p-=3)>-1&&nt.push(239,191,189),H=y;continue}y=(H-55296<<10|y-56320)+65536}else H&&(p-=3)>-1&&nt.push(239,191,189);if(H=null,y<128){if((p-=1)<0)break;nt.push(y)}else if(y<2048){if((p-=2)<0)break;nt.push(y>>6|192,y&63|128)}else if(y<65536){if((p-=3)<0)break;nt.push(y>>12|224,y>>6&63|128,y&63|128)}else if(y<1114112){if((p-=4)<0)break;nt.push(y>>18|240,y>>12&63|128,y>>6&63|128,y&63|128)}else throw new Error("Invalid code point")}return nt}function Mt(B){const p=[];for(let y=0;y<B.length;++y)p.push(B.charCodeAt(y)&255);return p}function Gt(B,p){let y,O,H;const nt=[];for(let k=0;k<B.length&&!((p-=2)<0);++k)y=B.charCodeAt(k),O=y>>8,H=y%256,nt.push(H),nt.push(O);return nt}function vt(B){return t.toByteArray(zt(B))}function Et(B,p,y,O){let H;for(H=0;H<O&&!(H+y>=p.length||H>=B.length);++H)p[H+y]=B[H];return H}function Ot(B,p){return B instanceof p||B!=null&&B.constructor!=null&&B.constructor.name!=null&&B.constructor.name===p.name}function $t(B){return B!==B}const Jt=function(){const B="0123456789abcdef",p=new Array(256);for(let y=0;y<16;++y){const O=y*16;for(let H=0;H<16;++H)p[O+H]=B[y]+B[H]}return p}();function ie(B){return typeof BigInt>"u"?ae:B}function ae(){throw new Error("BigInt not supported")}}(co)),co}rl();function ar(){throw new Error("setTimeout has not been defined")}function cr(){throw new Error("clearTimeout has not been defined")}var tn=ar,en=cr;typeof ci.setTimeout=="function"&&(tn=setTimeout);typeof ci.clearTimeout=="function"&&(en=clearTimeout);function rr(n){if(tn===setTimeout)return setTimeout(n,0);if((tn===ar||!tn)&&setTimeout)return tn=setTimeout,setTimeout(n,0);try{return tn(n,0)}catch{try{return tn.call(null,n,0)}catch{return tn.call(this,n,0)}}}function sl(n){if(en===clearTimeout)return clearTimeout(n);if((en===cr||!en)&&clearTimeout)return en=clearTimeout,clearTimeout(n);try{return en(n)}catch{try{return en.call(null,n)}catch{return en.call(this,n)}}}var He=[],Pn=!1,hn,Ti=-1;function ll(){!Pn||!hn||(Pn=!1,hn.length?He=hn.concat(He):Ti=-1,He.length&&sr())}function sr(){if(!Pn){var n=rr(ll);Pn=!0;for(var t=He.length;t;){for(hn=He,He=[];++Ti<t;)hn&&hn[Ti].run();Ti=-1,t=He.length}hn=null,Pn=!1,sl(n)}}function dl(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];He.push(new lr(n,t)),He.length===1&&!Pn&&rr(sr)}function lr(n,t){this.fun=n,this.array=t}lr.prototype.run=function(){this.fun.apply(null,this.array)};var ul="browser",fl="browser",_l=!0,hl={},gl=[],pl="",Ll={},Al={},bl={};function mn(){}var yl=mn,Il=mn,wl=mn,ml=mn,Cl=mn,El=mn,Bl=mn;function xl(n){throw new Error("process.binding is not supported")}function Fl(){return"/"}function vl(n){throw new Error("process.chdir is not supported")}function Sl(){return 0}var On=ci.performance||{},Ol=On.now||On.mozNow||On.msNow||On.oNow||On.webkitNow||function(){return new Date().getTime()};function Ul(n){var t=Ol.call(On)*.001,e=Math.floor(t),i=Math.floor(t%1*1e9);return n&&(e=e-n[0],i=i-n[1],i<0&&(e--,i+=1e9)),[e,i]}var Pl=new Date;function Ml(){var n=new Date,t=n-Pl;return t/1e3}var ro={nextTick:dl,title:ul,browser:_l,env:hl,argv:gl,version:pl,versions:Ll,on:yl,addListener:Il,once:wl,off:ml,removeListener:Cl,removeAllListeners:El,emit:Bl,binding:xl,cwd:Fl,chdir:vl,umask:Sl,hrtime:Ul,platform:fl,release:Al,config:bl,uptime:Ml};const kl=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function Zi(n,t){if(!t||t==10)return BigInt(n);if(t==16)return n.slice(0,2)=="0x"?BigInt(n):BigInt("0x"+n)}const se=Zi;function Tl(n,t){let e=BigInt(0);t=BigInt(t);for(let i=0;i<n.length;i++)e=e*t+BigInt(n[i]);return e}function Ai(n){const t=n.toString(16);return(t.length-1)*4+kl[parseInt(t[0],16)]}function dr(n){return BigInt(n)<BigInt(0)}function ur(n){return!n}function Di(n,t){return BigInt(n)<<BigInt(t)}function Mn(n,t){return BigInt(n)>>BigInt(t)}const zl=Di,Rl=Mn;function oa(n){return(BigInt(n)&BigInt(1))==BigInt(1)}function Ql(n){let t=BigInt(n);const e=[];for(;t;){if(t&BigInt(1)){const i=2-Number(t%BigInt(4));e.push(i),t=t-BigInt(i)}else e.push(0);t=t>>BigInt(1)}return e}function fr(n){let t=BigInt(n);const e=[];for(;t;)t&BigInt(1)?e.push(1):e.push(0),t=t>>BigInt(1);return e}function _r(n){if(n>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(n)}function Dl(n,t){const e=[];let i=BigInt(n);for(t=BigInt(t);i;)e.unshift(Number(i%t)),i=i/t;return e}function aa(n,t){return BigInt(n)+BigInt(t)}function Ze(n,t){return BigInt(n)-BigInt(t)}function hr(n){return-BigInt(n)}function gr(n,t){return BigInt(n)*BigInt(t)}function ql(n){return BigInt(n)*BigInt(n)}function bi(n,t){return BigInt(n)**BigInt(t)}function Nl(n,t){return BigInt(n)**BigInt(t)}function Gl(n){return BigInt(n)>=0?BigInt(n):-BigInt(n)}function Tn(n,t){return BigInt(n)/BigInt(t)}function ke(n,t){return BigInt(n)%BigInt(t)}function un(n,t){return BigInt(n)==BigInt(t)}function $l(n,t){return BigInt(n)!=BigInt(t)}function Kl(n,t){return BigInt(n)<BigInt(t)}function To(n,t){return BigInt(n)>BigInt(t)}function Hl(n,t){return BigInt(n)<=BigInt(t)}function pr(n,t){return BigInt(n)>=BigInt(t)}function ca(n,t){return BigInt(n)&BigInt(t)}function Zl(n,t){return BigInt(n)|BigInt(t)}function Yl(n,t){return BigInt(n)^BigInt(t)}function Vl(n,t){return BigInt(n)&&BigInt(t)}function jl(n,t){return BigInt(n)||BigInt(t)}function Wl(n){return!BigInt(n)}function ri(n,t,e,i){const o="0000000"+e.toString(16),a=new Uint32Array(n.buffer,n.byteOffset+t,i/4),u=((o.length-7)*4-1>>5)+1;for(let r=0;r<u;r++)a[r]=parseInt(o.substring(o.length-8*r-8,o.length-8*r),16);for(let r=u;r<a.length;r++)a[r]=0;for(let r=a.length*4;r<i;r++)n[r]=_r(ca(Mn(e,r*8),255))}function Lr(n,t,e,i){const o="0000000"+e.toString(16),a=new DataView(n.buffer,n.byteOffset+t,i),u=((o.length-7)*4-1>>5)+1;for(let r=0;r<u;r++)a.setUint32(i-r*4-4,parseInt(o.substring(o.length-8*r-8,o.length-8*r),16),!1);for(let r=0;r<i/4-u;r++)a[r]=0}function si(n,t,e){e=e||n.byteLength,t=t||0;const i=new Uint32Array(n.buffer,n.byteOffset+t,e/4),o=new Array(e/4);return i.forEach((a,u)=>o[o.length-u-1]=a.toString(16).padStart(8,"0")),Zi(o.join(""),16)}function Ar(n,t,e){e=e||n.byteLength,t=t||0;const i=new DataView(n.buffer,n.byteOffset+t,e),o=new Array(e/4);for(let a=0;a<e/4;a++)o[a]=i.getUint32(a*4,!1).toString(16).padStart(8,"0");return Zi(o.join(""),16)}function br(n,t){return n.toString(t)}function zn(n){const t=new Uint8Array(Math.floor((Ai(n)-1)/8)+1);return ri(t,0,n,t.byteLength),t}const yr=se(0),fn=se(1);var Xl=Object.freeze({__proto__:null,abs:Gl,add:aa,band:ca,bitLength:Ai,bits:fr,bor:Zl,bxor:Yl,div:Tn,e:se,eq:un,exp:Nl,fromArray:Tl,fromRprBE:Ar,fromRprLE:si,fromString:Zi,geq:pr,gt:To,isNegative:dr,isOdd:oa,isZero:ur,land:Vl,leq:Hl,lnot:Wl,lor:jl,lt:Kl,mod:ke,mul:gr,naf:Ql,neg:hr,neq:$l,one:fn,pow:bi,shiftLeft:Di,shiftRight:Mn,shl:zl,shr:Rl,square:ql,sub:Ze,toArray:Dl,toLEBuff:zn,toNumber:_r,toRprBE:Lr,toRprLE:ri,toString:br,zero:yr});function Sa(n,t,e){if(ur(e))return n.one;const i=fr(e);if(i.length==0)return n.one;let o=t;for(let a=i.length-2;a>=0;a--)o=n.square(o),i[a]&&(o=n.mul(o,t));return o}function Jl(n){if(n.m%2==1)if(un(ke(n.p,4),1))if(un(ke(n.p,8),1))if(un(ke(n.p,16),1))td(n);else if(un(ke(n.p,16),9))ed(n);else throw new Error("Field withot sqrt");else if(un(ke(n.p,8),5))nd(n);else throw new Error("Field withot sqrt");else un(ke(n.p,4),3)&&id(n);else{const t=ke(bi(n.p,n.m/2),4);t==1?od(n):t==3?ad(n):cd(n)}}function td(n){for(n.sqrt_q=bi(n.p,n.m),n.sqrt_s=0,n.sqrt_t=Ze(n.sqrt_q,1);!oa(n.sqrt_t);)n.sqrt_s=n.sqrt_s+1,n.sqrt_t=Tn(n.sqrt_t,2);let t=n.one;for(;n.eq(t,n.one);){const e=n.random();n.sqrt_z=n.pow(e,n.sqrt_t),t=n.pow(n.sqrt_z,2**(n.sqrt_s-1))}n.sqrt_tm1d2=Tn(Ze(n.sqrt_t,1),2),n.sqrt=function(e){const i=this;if(i.isZero(e))return i.zero;let o=i.pow(e,i.sqrt_tm1d2);const a=i.pow(i.mul(i.square(o),e),2**(i.sqrt_s-1));if(i.eq(a,i.negone))return null;let u=i.sqrt_s,r=i.mul(e,o),I=i.mul(r,o),l=i.sqrt_z;for(;!i.eq(I,i.one);){let s=i.square(I),m=1;for(;!i.eq(s,i.one);)s=i.square(s),m++;o=l;for(let C=0;C<u-m-1;C++)o=i.square(o);l=i.square(o),I=i.mul(I,l),r=i.mul(r,o),u=m}return i.geq(r,i.zero)?r:i.neg(r)}}function ed(n){n.sqrt=function(){throw new Error("Sqrt alg 4 not implemented")}}function nd(n){n.sqrt=function(){throw new Error("Sqrt alg 3 not implemented")}}function id(n){n.sqrt_q=bi(n.p,n.m),n.sqrt_e1=Tn(Ze(n.sqrt_q,3),4),n.sqrt=function(t){if(this.isZero(t))return this.zero;const e=this.pow(t,this.sqrt_e1),i=this.mul(this.square(e),t);if(this.eq(i,this.negone))return null;const o=this.mul(e,t);return n.geq(o,n.zero)?o:n.neg(o)}}function od(n){n.sqrt=function(){throw new Error("Sqrt alg 10 not implemented")}}function ad(n){n.sqrt_q=bi(n.p,n.m/2),n.sqrt_e34=Tn(Ze(n.sqrt_q,3),4),n.sqrt_e12=Tn(Ze(n.sqrt_q,1),2),n.frobenius=function(t,e){return t%2==1?n.conjugate(e):e},n.sqrt=function(t){const e=this,i=e.pow(t,e.sqrt_e34),o=e.mul(e.square(i),t),a=e.mul(e.frobenius(1,o),o);if(e.eq(a,e.negone))return null;const u=e.mul(i,t);let r;if(e.eq(o,e.negone))r=e.mul(u,[e.F.zero,e.F.one]);else{const I=e.pow(e.add(e.one,o),e.sqrt_e12);r=e.mul(I,u)}return e.geq(r,e.zero)?r:e.neg(r)}}function cd(n){n.sqrt=function(){throw new Error("Sqrt alg 8 not implemented")}}function Je(n,t,e,i,o){n[t]=n[t]+n[e]>>>0,n[o]=(n[o]^n[t])>>>0,n[o]=(n[o]<<16|n[o]>>>16&65535)>>>0,n[i]=n[i]+n[o]>>>0,n[e]=(n[e]^n[i])>>>0,n[e]=(n[e]<<12|n[e]>>>20&4095)>>>0,n[t]=n[t]+n[e]>>>0,n[o]=(n[o]^n[t])>>>0,n[o]=(n[o]<<8|n[o]>>>24&255)>>>0,n[i]=n[i]+n[o]>>>0,n[e]=(n[e]^n[i])>>>0,n[e]=(n[e]<<7|n[e]>>>25&127)>>>0}function rd(n){Je(n,0,4,8,12),Je(n,1,5,9,13),Je(n,2,6,10,14),Je(n,3,7,11,15),Je(n,0,5,10,15),Je(n,1,6,11,12),Je(n,2,7,8,13),Je(n,3,4,9,14)}class sd{constructor(t){t=t||[0,0,0,0,0,0,0,0],this.state=[1634760805,857760878,2036477234,1797285236,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],0,0,0,0],this.idx=16,this.buff=new Array(16)}nextU32(){return this.idx==16&&this.update(),this.buff[this.idx++]}nextU64(){return aa(gr(this.nextU32(),4294967296),this.nextU32())}nextBool(){return(this.nextU32()&1)==1}update(){for(let t=0;t<16;t++)this.buff[t]=this.state[t];for(let t=0;t<10;t++)rd(this.buff);for(let t=0;t<16;t++)this.buff[t]=this.buff[t]+this.state[t]>>>0;this.idx=0,this.state[12]=this.state[12]+1>>>0,this.state[12]==0&&(this.state[13]=this.state[13]+1>>>0,this.state[13]==0&&(this.state[14]=this.state[14]+1>>>0,this.state[14]==0&&(this.state[15]=this.state[15]+1>>>0)))}}function Ir(n){let t=new Uint8Array(n);if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(t);else for(let e=0;e<n;e++)t[e]=Math.random()*4294967296>>>0;return t}function ld(){const n=Ir(32),t=new Uint32Array(n.buffer),e=[];for(let i=0;i<8;i++)e.push(t[i]);return e}let vi=null;function ra(){return vi||(vi=new sd(ld()),vi)}class dd{constructor(t,e,i){this.F=e,this.G=t,this.opMulGF=i;let o=e.sqrt_t||e.t,a=e.sqrt_s||e.s,u=e.one;for(;e.eq(e.pow(u,e.half),e.one);)u=e.add(u,e.one);this.w=new Array(a+1),this.wi=new Array(a+1),this.w[a]=this.F.pow(u,o),this.wi[a]=this.F.inv(this.w[a]);let r=a-1;for(;r>=0;)this.w[r]=this.F.square(this.w[r+1]),this.wi[r]=this.F.square(this.wi[r+1]),r--;this.roots=[],this._setRoots(Math.min(a,15))}_setRoots(t){for(let e=t;e>=0&&!this.roots[e];e--){let i=this.F.one;const o=1<<e,a=new Array(o);for(let u=0;u<o;u++)a[u]=i,i=this.F.mul(i,this.w[e]);this.roots[e]=a}}fft(t){if(t.length<=1)return t;const e=Oa(t.length-1)+1;this._setRoots(e);const i=1<<e;if(t.length!=i)throw new Error("Size must be multiple of 2");return qi(this,t,e,0,1)}ifft(t){if(t.length<=1)return t;const e=Oa(t.length-1)+1;this._setRoots(e);const i=1<<e;if(t.length!=i)throw new Error("Size must be multiple of 2");const o=qi(this,t,e,0,1),a=this.F.inv(this.F.mulScalar(this.F.one,i)),u=new Array(i);for(let r=0;r<i;r++)u[r]=this.opMulGF(o[(i-r)%i],a);return u}}function Oa(n){return(n&4294901760?(n&=4294901760,16):0)|(n&4278255360?(n&=4278255360,8):0)|(n&4042322160?(n&=4042322160,4):0)|(n&3435973836?(n&=3435973836,2):0)|(n&2863311530)!==0}function qi(n,t,e,i,o){const a=1<<e;if(a==1)return[t[i]];if(a==2)return[n.G.add(t[i],t[i+o]),n.G.sub(t[i],t[i+o])];const u=a>>1,r=qi(n,t,e-1,i,o*2),I=qi(n,t,e-1,i+o,o*2),l=new Array(a);for(let s=0;s<u;s++)l[s]=n.G.add(r[s],n.opMulGF(I[s],n.roots[e][s])),l[s+u]=n.G.sub(r[s],n.opMulGF(I[s],n.roots[e][s]));return l}class ud{constructor(t){this.type="F1",this.one=BigInt(1),this.zero=BigInt(0),this.p=BigInt(t),this.m=1,this.negone=this.p-this.one,this.two=BigInt(2),this.half=this.p>>this.one,this.bitLength=Ai(this.p),this.mask=(this.one<<BigInt(this.bitLength))-this.one,this.n64=Math.floor((this.bitLength-1)/64)+1,this.n32=this.n64*2,this.n8=this.n64*8,this.R=this.e(this.one<<BigInt(this.n64*64)),this.Ri=this.inv(this.R);const e=this.negone>>this.one;this.nqr=this.two;let i=this.pow(this.nqr,e);for(;!this.eq(i,this.negone);)this.nqr=this.nqr+this.one,i=this.pow(this.nqr,e);for(this.s=0,this.t=this.negone;(this.t&this.one)==this.zero;)this.s=this.s+1,this.t=this.t>>this.one;this.nqr_to_t=this.pow(this.nqr,this.t),Jl(this),this.FFT=new dd(this,this,this.mul.bind(this)),this.fft=this.FFT.fft.bind(this.FFT),this.ifft=this.FFT.ifft.bind(this.FFT),this.w=this.FFT.w,this.wi=this.FFT.wi,this.shift=this.square(this.nqr),this.k=this.exp(this.nqr,2**this.s)}e(t,e){let i;if(e?e==16&&(i=BigInt("0x"+t)):i=BigInt(t),i<0){let o=-i;return o>=this.p&&(o=o%this.p),this.p-o}else return i>=this.p?i%this.p:i}add(t,e){const i=t+e;return i>=this.p?i-this.p:i}sub(t,e){return t>=e?t-e:this.p-e+t}neg(t){return t&&this.p-t}mul(t,e){return t*e%this.p}mulScalar(t,e){return t*this.e(e)%this.p}square(t){return t*t%this.p}eq(t,e){return t==e}neq(t,e){return t!=e}lt(t,e){const i=t>this.half?t-this.p:t,o=e>this.half?e-this.p:e;return i<o}gt(t,e){const i=t>this.half?t-this.p:t,o=e>this.half?e-this.p:e;return i>o}leq(t,e){const i=t>this.half?t-this.p:t,o=e>this.half?e-this.p:e;return i<=o}geq(t,e){const i=t>this.half?t-this.p:t,o=e>this.half?e-this.p:e;return i>=o}div(t,e){return this.mul(t,this.inv(e))}idiv(t,e){if(!e)throw new Error("Division by zero");return t/e}inv(t){if(!t)throw new Error("Division by zero");let e=this.zero,i=this.p,o=this.one,a=t%this.p;for(;a;){let u=i/a;[e,o]=[o,e-u*o],[i,a]=[a,i-u*a]}return e<this.zero&&(e+=this.p),e}mod(t,e){return t%e}pow(t,e){return Sa(this,t,e)}exp(t,e){return Sa(this,t,e)}band(t,e){const i=t&e&this.mask;return i>=this.p?i-this.p:i}bor(t,e){const i=(t|e)&this.mask;return i>=this.p?i-this.p:i}bxor(t,e){const i=(t^e)&this.mask;return i>=this.p?i-this.p:i}bnot(t){const e=t^this.mask;return e>=this.p?e-this.p:e}shl(t,e){if(Number(e)<this.bitLength){const i=t<<e&this.mask;return i>=this.p?i-this.p:i}else{const i=this.p-e;return Number(i)<this.bitLength?t>>i:this.zero}}shr(t,e){if(Number(e)<this.bitLength)return t>>e;{const i=this.p-e;if(Number(i)<this.bitLength){const o=t<<i&this.mask;return o>=this.p?o-this.p:o}else return 0}}land(t,e){return t&&e?this.one:this.zero}lor(t,e){return t||e?this.one:this.zero}lnot(t){return t?this.zero:this.one}sqrt_old(t){if(t==this.zero)return this.zero;if(this.pow(t,this.negone>>this.one)!=this.one)return null;let i=this.s,o=this.nqr_to_t,a=this.pow(t,this.t),u=this.pow(t,this.add(this.t,this.one)>>this.one);for(;a!=this.one;){let r=this.square(a),I=1;for(;r!=this.one;)I++,r=this.square(r);let l=o;for(let s=0;s<i-I-1;s++)l=this.square(l);i=I,o=this.square(l),a=this.mul(a,o),u=this.mul(u,l)}return u>this.p>>this.one&&(u=this.neg(u)),u}normalize(t,e){if(t=BigInt(t,e),t<0){let i=-t;return i>=this.p&&(i=i%this.p),this.p-i}else return t>=this.p?t%this.p:t}random(){const t=this.bitLength*2/8;let e=this.zero;for(let i=0;i<t;i++)e=(e<<BigInt(8))+BigInt(Ir(1)[0]);return e%this.p}toString(t,e){e=e||10;let i;return t>this.half&&e==10?i="-"+(this.p-t).toString(e):i=t.toString(e),i}isZero(t){return t==this.zero}fromRng(t){let e;do{e=this.zero;for(let i=0;i<this.n64;i++)e+=t.nextU64()<<BigInt(64*i);e&=this.mask}while(e>=this.p);return e=e*this.Ri%this.p,e}fft(t){return this.FFT.fft(t)}ifft(t){return this.FFT.ifft(t)}toRprLE(t,e,i){ri(t,e,i,this.n64*8)}toRprBE(t,e,i){Lr(t,e,i,this.n64*8)}toRprBEM(t,e,i){return this.toRprBE(t,e,this.mul(this.R,i))}toRprLEM(t,e,i){return this.toRprLE(t,e,this.mul(this.R,i))}fromRprLE(t,e){return si(t,e,this.n8)}fromRprBE(t,e){return Ar(t,e,this.n8)}fromRprLEM(t,e){return this.mul(this.fromRprLE(t,e),this.Ri)}fromRprBEM(t,e){return this.mul(this.fromRprBE(t,e),this.Ri)}toObject(t){return t}}var ln={};ln.bigInt2BytesLE=function(t,e){const i=Array(e);let o=BigInt(t);for(let a=0;a<e;a++)i[a]=Number(o&0xFFn),o=o>>8n;return i};ln.bigInt2U32LE=function(t,e){const i=Array(e);let o=BigInt(t);for(let a=0;a<e;a++)i[a]=Number(o&0xFFFFFFFFn),o=o>>32n;return i};ln.isOcamNum=function(n){return!(!Array.isArray(n)||n.length!=3||typeof n[0]!="number"||typeof n[1]!="number"||!Array.isArray(n[2]))};var fd=function(t,e,i){const o=i||"int";if(t.modules[o])return o;t.modules[o]={};const a=e*2,u=e*8;function r(){const v=t.addFunction(o+"_copy");v.addParam("px","i32"),v.addParam("pr","i32");const f=v.getCodeBuilder();for(let L=0;L<e;L++)v.addCode(f.i64_store(f.getLocal("pr"),L*8,f.i64_load(f.getLocal("px"),L*8)))}function I(){const v=t.addFunction(o+"_zero");v.addParam("pr","i32");const f=v.getCodeBuilder();for(let L=0;L<e;L++)v.addCode(f.i64_store(f.getLocal("pr"),L*8,f.i64_const(0)))}function l(){const v=t.addFunction(o+"_one");v.addParam("pr","i32");const f=v.getCodeBuilder();v.addCode(f.i64_store(f.getLocal("pr"),0,f.i64_const(1)));for(let L=1;L<e;L++)v.addCode(f.i64_store(f.getLocal("pr"),L*8,f.i64_const(0)))}function s(){const v=t.addFunction(o+"_isZero");v.addParam("px","i32"),v.setReturnType("i32");const f=v.getCodeBuilder();function L(V){return V==0?f.ret(f.i64_eqz(f.i64_load(f.getLocal("px")))):f.if(f.i64_eqz(f.i64_load(f.getLocal("px"),V*8)),L(V-1),f.ret(f.i32_const(0)))}v.addCode(L(e-1)),v.addCode(f.ret(f.i32_const(0)))}function m(){const v=t.addFunction(o+"_eq");v.addParam("px","i32"),v.addParam("py","i32"),v.setReturnType("i32");const f=v.getCodeBuilder();function L(V){return V==0?f.ret(f.i64_eq(f.i64_load(f.getLocal("px")),f.i64_load(f.getLocal("py")))):f.if(f.i64_eq(f.i64_load(f.getLocal("px"),V*8),f.i64_load(f.getLocal("py"),V*8)),L(V-1),f.ret(f.i32_const(0)))}v.addCode(L(e-1)),v.addCode(f.ret(f.i32_const(0)))}function C(){const v=t.addFunction(o+"_gte");v.addParam("px","i32"),v.addParam("py","i32"),v.setReturnType("i32");const f=v.getCodeBuilder();function L(V){return V==0?f.ret(f.i64_ge_u(f.i64_load(f.getLocal("px")),f.i64_load(f.getLocal("py")))):f.if(f.i64_lt_u(f.i64_load(f.getLocal("px"),V*8),f.i64_load(f.getLocal("py"),V*8)),f.ret(f.i32_const(0)),f.if(f.i64_gt_u(f.i64_load(f.getLocal("px"),V*8),f.i64_load(f.getLocal("py"),V*8)),f.ret(f.i32_const(1)),L(V-1)))}v.addCode(L(e-1)),v.addCode(f.ret(f.i32_const(0)))}function g(){const v=t.addFunction(o+"_add");v.addParam("x","i32"),v.addParam("y","i32"),v.addParam("r","i32"),v.setReturnType("i32"),v.addLocal("c","i64");const f=v.getCodeBuilder();v.addCode(f.setLocal("c",f.i64_add(f.i64_load32_u(f.getLocal("x")),f.i64_load32_u(f.getLocal("y"))))),v.addCode(f.i64_store32(f.getLocal("r"),f.getLocal("c")));for(let L=1;L<a;L++)v.addCode(f.setLocal("c",f.i64_add(f.i64_add(f.i64_load32_u(f.getLocal("x"),4*L),f.i64_load32_u(f.getLocal("y"),4*L)),f.i64_shr_u(f.getLocal("c"),f.i64_const(32))))),v.addCode(f.i64_store32(f.getLocal("r"),L*4,f.getLocal("c")));v.addCode(f.i32_wrap_i64(f.i64_shr_u(f.getLocal("c"),f.i64_const(32))))}function M(){const v=t.addFunction(o+"_sub");v.addParam("x","i32"),v.addParam("y","i32"),v.addParam("r","i32"),v.setReturnType("i32"),v.addLocal("c","i64");const f=v.getCodeBuilder();v.addCode(f.setLocal("c",f.i64_sub(f.i64_load32_u(f.getLocal("x")),f.i64_load32_u(f.getLocal("y"))))),v.addCode(f.i64_store32(f.getLocal("r"),f.i64_and(f.getLocal("c"),f.i64_const("0xFFFFFFFF"))));for(let L=1;L<a;L++)v.addCode(f.setLocal("c",f.i64_add(f.i64_sub(f.i64_load32_u(f.getLocal("x"),4*L),f.i64_load32_u(f.getLocal("y"),4*L)),f.i64_shr_s(f.getLocal("c"),f.i64_const(32))))),v.addCode(f.i64_store32(f.getLocal("r"),L*4,f.i64_and(f.getLocal("c"),f.i64_const("0xFFFFFFFF"))));v.addCode(f.i32_wrap_i64(f.i64_shr_s(f.getLocal("c"),f.i64_const(32))))}function $(){const v=t.addFunction(o+"_mul");v.addParam("x","i32"),v.addParam("y","i32"),v.addParam("r","i32"),v.addLocal("c0","i64"),v.addLocal("c1","i64");for(let w=0;w<a;w++)v.addLocal("x"+w,"i64"),v.addLocal("y"+w,"i64");const f=v.getCodeBuilder(),L=[],V=[];function X(w,T){let at,Lt;return L[w]?at=f.getLocal("x"+w):(at=f.teeLocal("x"+w,f.i64_load32_u(f.getLocal("x"),w*4)),L[w]=!0),V[T]?Lt=f.getLocal("y"+T):(Lt=f.teeLocal("y"+T,f.i64_load32_u(f.getLocal("y"),T*4)),V[T]=!0),f.i64_mul(at,Lt)}let et="c0",N="c1";for(let w=0;w<a*2-1;w++){for(let T=Math.max(0,w-a+1);T<=w&&T<a;T++){const at=w-T;v.addCode(f.setLocal(et,f.i64_add(f.i64_and(f.getLocal(et),f.i64_const(4294967295)),X(T,at)))),v.addCode(f.setLocal(N,f.i64_add(f.getLocal(N),f.i64_shr_u(f.getLocal(et),f.i64_const(32)))))}v.addCode(f.i64_store32(f.getLocal("r"),w*4,f.getLocal(et))),[et,N]=[N,et],v.addCode(f.setLocal(N,f.i64_shr_u(f.getLocal(et),f.i64_const(32))))}v.addCode(f.i64_store32(f.getLocal("r"),a*4*2-4,f.getLocal(et)))}function F(){const v=t.addFunction(o+"_square");v.addParam("x","i32"),v.addParam("r","i32"),v.addLocal("c0","i64"),v.addLocal("c1","i64"),v.addLocal("c0_old","i64"),v.addLocal("c1_old","i64");for(let T=0;T<a;T++)v.addLocal("x"+T,"i64");const f=v.getCodeBuilder(),L=[];function V(T,at){let Lt,_t;return L[T]?Lt=f.getLocal("x"+T):(Lt=f.teeLocal("x"+T,f.i64_load32_u(f.getLocal("x"),T*4)),L[T]=!0),L[at]?_t=f.getLocal("x"+at):(_t=f.teeLocal("x"+at,f.i64_load32_u(f.getLocal("x"),at*4)),L[at]=!0),f.i64_mul(Lt,_t)}let X="c0",et="c1",N="c0_old",w="c1_old";for(let T=0;T<a*2-1;T++){v.addCode(f.setLocal(X,f.i64_const(0)),f.setLocal(et,f.i64_const(0)));for(let at=Math.max(0,T-a+1);at<T+1>>1&&at<a;at++){const Lt=T-at;v.addCode(f.setLocal(X,f.i64_add(f.i64_and(f.getLocal(X),f.i64_const(4294967295)),V(at,Lt)))),v.addCode(f.setLocal(et,f.i64_add(f.getLocal(et),f.i64_shr_u(f.getLocal(X),f.i64_const(32)))))}v.addCode(f.setLocal(X,f.i64_shl(f.i64_and(f.getLocal(X),f.i64_const(4294967295)),f.i64_const(1)))),v.addCode(f.setLocal(et,f.i64_add(f.i64_shl(f.getLocal(et),f.i64_const(1)),f.i64_shr_u(f.getLocal(X),f.i64_const(32))))),T%2==0&&(v.addCode(f.setLocal(X,f.i64_add(f.i64_and(f.getLocal(X),f.i64_const(4294967295)),V(T>>1,T>>1)))),v.addCode(f.setLocal(et,f.i64_add(f.getLocal(et),f.i64_shr_u(f.getLocal(X),f.i64_const(32)))))),T>0&&(v.addCode(f.setLocal(X,f.i64_add(f.i64_and(f.getLocal(X),f.i64_const(4294967295)),f.i64_and(f.getLocal(N),f.i64_const(4294967295))))),v.addCode(f.setLocal(et,f.i64_add(f.i64_add(f.getLocal(et),f.i64_shr_u(f.getLocal(X),f.i64_const(32))),f.getLocal(w))))),v.addCode(f.i64_store32(f.getLocal("r"),T*4,f.getLocal(X))),v.addCode(f.setLocal(N,f.getLocal(et)),f.setLocal(w,f.i64_shr_u(f.getLocal(N),f.i64_const(32))))}v.addCode(f.i64_store32(f.getLocal("r"),a*4*2-4,f.getLocal(N)))}function R(){const v=t.addFunction(o+"_squareOld");v.addParam("x","i32"),v.addParam("r","i32");const f=v.getCodeBuilder();v.addCode(f.call(o+"_mul",f.getLocal("x"),f.getLocal("x"),f.getLocal("r")))}function x(){const v=t.addFunction(o+"__mul1");v.addParam("px","i32"),v.addParam("y","i64"),v.addParam("pr","i32"),v.addLocal("c","i64");const f=v.getCodeBuilder();v.addCode(f.setLocal("c",f.i64_mul(f.i64_load32_u(f.getLocal("px"),0,0),f.getLocal("y")))),v.addCode(f.i64_store32(f.getLocal("pr"),0,0,f.getLocal("c")));for(let L=1;L<a;L++)v.addCode(f.setLocal("c",f.i64_add(f.i64_mul(f.i64_load32_u(f.getLocal("px"),4*L,0),f.getLocal("y")),f.i64_shr_u(f.getLocal("c"),f.i64_const(32))))),v.addCode(f.i64_store32(f.getLocal("pr"),L*4,0,f.getLocal("c")))}function it(){const v=t.addFunction(o+"__add1");v.addParam("x","i32"),v.addParam("y","i64"),v.addLocal("c","i64"),v.addLocal("px","i32");const f=v.getCodeBuilder();v.addCode(f.setLocal("px",f.getLocal("x"))),v.addCode(f.setLocal("c",f.i64_add(f.i64_load32_u(f.getLocal("px"),0,0),f.getLocal("y")))),v.addCode(f.i64_store32(f.getLocal("px"),0,0,f.getLocal("c"))),v.addCode(f.setLocal("c",f.i64_shr_u(f.getLocal("c"),f.i64_const(32)))),v.addCode(f.block(f.loop(f.br_if(1,f.i64_eqz(f.getLocal("c"))),f.setLocal("px",f.i32_add(f.getLocal("px"),f.i32_const(4))),f.setLocal("c",f.i64_add(f.i64_load32_u(f.getLocal("px"),0,0),f.getLocal("c"))),f.i64_store32(f.getLocal("px"),0,0,f.getLocal("c")),f.setLocal("c",f.i64_shr_u(f.getLocal("c"),f.i64_const(32))),f.br(0))))}function z(){x(),it();const v=t.addFunction(o+"_div");v.addParam("x","i32"),v.addParam("y","i32"),v.addParam("c","i32"),v.addParam("r","i32"),v.addLocal("rr","i32"),v.addLocal("cc","i32"),v.addLocal("eX","i32"),v.addLocal("eY","i32"),v.addLocal("sy","i64"),v.addLocal("sx","i64"),v.addLocal("ec","i32");const f=v.getCodeBuilder(),L=f.i32_const(t.alloc(u)),V=f.i32_const(t.alloc(u)),X=f.i32_const(t.alloc(u)),et=f.getLocal("cc"),N=f.getLocal("rr"),w=t.alloc(u*2),T=f.i32_const(w),at=f.i32_const(w+u);v.addCode(f.if(f.getLocal("c"),f.setLocal("cc",f.getLocal("c")),f.setLocal("cc",V))),v.addCode(f.if(f.getLocal("r"),f.setLocal("rr",f.getLocal("r")),f.setLocal("rr",X))),v.addCode(f.call(o+"_copy",f.getLocal("x"),N)),v.addCode(f.call(o+"_copy",f.getLocal("y"),L)),v.addCode(f.call(o+"_zero",et)),v.addCode(f.call(o+"_zero",T)),v.addCode(f.setLocal("eX",f.i32_const(u-1))),v.addCode(f.setLocal("eY",f.i32_const(u-1))),v.addCode(f.block(f.loop(f.br_if(1,f.i32_or(f.i32_load8_u(f.i32_add(L,f.getLocal("eY")),0,0),f.i32_eq(f.getLocal("eY"),f.i32_const(3)))),f.setLocal("eY",f.i32_sub(f.getLocal("eY"),f.i32_const(1))),f.br(0)))),v.addCode(f.setLocal("sy",f.i64_add(f.i64_load32_u(f.i32_sub(f.i32_add(L,f.getLocal("eY")),f.i32_const(3)),0,0),f.i64_const(1)))),v.addCode(f.if(f.i64_eq(f.getLocal("sy"),f.i64_const(1)),f.drop(f.i64_div_u(f.i64_const(0),f.i64_const(0))))),v.addCode(f.block(f.loop(f.block(f.loop(f.br_if(1,f.i32_or(f.i32_load8_u(f.i32_add(N,f.getLocal("eX")),0,0),f.i32_eq(f.getLocal("eX"),f.i32_const(7)))),f.setLocal("eX",f.i32_sub(f.getLocal("eX"),f.i32_const(1))),f.br(0))),f.setLocal("sx",f.i64_load(f.i32_sub(f.i32_add(N,f.getLocal("eX")),f.i32_const(7)),0,0)),f.setLocal("sx",f.i64_div_u(f.getLocal("sx"),f.getLocal("sy"))),f.setLocal("ec",f.i32_sub(f.i32_sub(f.getLocal("eX"),f.getLocal("eY")),f.i32_const(4))),f.block(f.loop(f.br_if(1,f.i32_and(f.i64_eqz(f.i64_and(f.getLocal("sx"),f.i64_const("0xFFFFFFFF00000000"))),f.i32_ge_s(f.getLocal("ec"),f.i32_const(0)))),f.setLocal("sx",f.i64_shr_u(f.getLocal("sx"),f.i64_const(8))),f.setLocal("ec",f.i32_add(f.getLocal("ec"),f.i32_const(1))),f.br(0))),f.if(f.i64_eqz(f.getLocal("sx")),[...f.br_if(2,f.i32_eqz(f.call(o+"_gte",N,L))),...f.setLocal("sx",f.i64_const(1)),...f.setLocal("ec",f.i32_const(0))]),f.call(o+"__mul1",L,f.getLocal("sx"),at),f.drop(f.call(o+"_sub",N,f.i32_sub(at,f.getLocal("ec")),N)),f.call(o+"__add1",f.i32_add(et,f.getLocal("ec")),f.getLocal("sx")),f.br(0))))}function K(){const v=t.addFunction(o+"_inverseMod");v.addParam("px","i32"),v.addParam("pm","i32"),v.addParam("pr","i32"),v.addLocal("t","i32"),v.addLocal("newt","i32"),v.addLocal("r","i32"),v.addLocal("qq","i32"),v.addLocal("qr","i32"),v.addLocal("newr","i32"),v.addLocal("swp","i32"),v.addLocal("x","i32"),v.addLocal("signt","i32"),v.addLocal("signnewt","i32"),v.addLocal("signx","i32");const f=v.getCodeBuilder(),L=f.i32_const(t.alloc(u)),V=f.i32_const(t.alloc(u)),X=f.i32_const(t.alloc(u)),et=f.i32_const(t.alloc(u)),N=f.i32_const(t.alloc(u)),w=f.i32_const(t.alloc(u)),T=f.i32_const(t.alloc(u*2)),at=f.i32_const(t.alloc(u));v.addCode(f.setLocal("t",L),f.call(o+"_zero",L),f.setLocal("signt",f.i32_const(0))),v.addCode(f.setLocal("r",V),f.call(o+"_copy",f.getLocal("pm"),V)),v.addCode(f.setLocal("newt",X),f.call(o+"_one",X),f.setLocal("signnewt",f.i32_const(0))),v.addCode(f.setLocal("newr",et),f.call(o+"_copy",f.getLocal("px"),et)),v.addCode(f.setLocal("qq",N)),v.addCode(f.setLocal("qr",w)),v.addCode(f.setLocal("x",at)),v.addCode(f.block(f.loop(f.br_if(1,f.call(o+"_isZero",f.getLocal("newr"))),f.call(o+"_div",f.getLocal("r"),f.getLocal("newr"),f.getLocal("qq"),f.getLocal("qr")),f.call(o+"_mul",f.getLocal("qq"),f.getLocal("newt"),T),f.if(f.getLocal("signt"),f.if(f.getLocal("signnewt"),f.if(f.call(o+"_gte",T,f.getLocal("t")),[...f.drop(f.call(o+"_sub",T,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],[...f.drop(f.call(o+"_sub",f.getLocal("t"),T,f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]),[...f.drop(f.call(o+"_add",T,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]),f.if(f.getLocal("signnewt"),[...f.drop(f.call(o+"_add",T,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],f.if(f.call(o+"_gte",f.getLocal("t"),T),[...f.drop(f.call(o+"_sub",f.getLocal("t"),T,f.getLocal("x"))),...f.setLocal("signx",f.i32_const(0))],[...f.drop(f.call(o+"_sub",T,f.getLocal("t"),f.getLocal("x"))),...f.setLocal("signx",f.i32_const(1))]))),f.setLocal("swp",f.getLocal("t")),f.setLocal("t",f.getLocal("newt")),f.setLocal("newt",f.getLocal("x")),f.setLocal("x",f.getLocal("swp")),f.setLocal("signt",f.getLocal("signnewt")),f.setLocal("signnewt",f.getLocal("signx")),f.setLocal("swp",f.getLocal("r")),f.setLocal("r",f.getLocal("newr")),f.setLocal("newr",f.getLocal("qr")),f.setLocal("qr",f.getLocal("swp")),f.br(0)))),v.addCode(f.if(f.getLocal("signt"),f.drop(f.call(o+"_sub",f.getLocal("pm"),f.getLocal("t"),f.getLocal("pr"))),f.call(o+"_copy",f.getLocal("t"),f.getLocal("pr"))))}return r(),I(),s(),l(),m(),C(),g(),M(),$(),F(),R(),z(),K(),t.exportFunction(o+"_copy"),t.exportFunction(o+"_zero"),t.exportFunction(o+"_one"),t.exportFunction(o+"_isZero"),t.exportFunction(o+"_eq"),t.exportFunction(o+"_gte"),t.exportFunction(o+"_add"),t.exportFunction(o+"_sub"),t.exportFunction(o+"_mul"),t.exportFunction(o+"_square"),t.exportFunction(o+"_squareOld"),t.exportFunction(o+"_div"),t.exportFunction(o+"_inverseMod"),o},sa=function(t,e,i,o,a,u,r){const I=t.addFunction(e);I.addParam("base","i32"),I.addParam("scalar","i32"),I.addParam("scalarLength","i32"),I.addParam("r","i32"),I.addLocal("i","i32"),I.addLocal("b","i32");const l=I.getCodeBuilder(),s=l.i32_const(t.alloc(i));I.addCode(l.if(l.i32_eqz(l.getLocal("scalarLength")),[...l.call(r,l.getLocal("r")),...l.ret([])])),I.addCode(l.call(u,l.getLocal("base"),s)),I.addCode(l.call(r,l.getLocal("r"))),I.addCode(l.setLocal("i",l.getLocal("scalarLength"))),I.addCode(l.block(l.loop(l.setLocal("i",l.i32_sub(l.getLocal("i"),l.i32_const(1))),l.setLocal("b",l.i32_load8_u(l.i32_add(l.getLocal("scalar"),l.getLocal("i")))),...m(),l.br_if(1,l.i32_eqz(l.getLocal("i"))),l.br(0))));function m(){const C=[];for(let g=0;g<8;g++)C.push(...l.call(a,l.getLocal("r"),l.getLocal("r")),...l.if(l.i32_ge_u(l.getLocal("b"),l.i32_const(128>>g)),[...l.setLocal("b",l.i32_sub(l.getLocal("b"),l.i32_const(128>>g))),...l.call(o,l.getLocal("r"),s,l.getLocal("r"))]));return C}},la=_d;function _d(n,t){const e=n.modules[t].n64*8,i=n.addFunction(t+"_batchInverse");i.addParam("pIn","i32"),i.addParam("inStep","i32"),i.addParam("n","i32"),i.addParam("pOut","i32"),i.addParam("outStep","i32"),i.addLocal("itAux","i32"),i.addLocal("itIn","i32"),i.addLocal("itOut","i32"),i.addLocal("i","i32");const o=i.getCodeBuilder(),a=o.i32_const(n.alloc(e));i.addCode(o.setLocal("itAux",o.i32_load(o.i32_const(0))),o.i32_store(o.i32_const(0),o.i32_add(o.getLocal("itAux"),o.i32_mul(o.i32_add(o.getLocal("n"),o.i32_const(1)),o.i32_const(e))))),i.addCode(o.call(t+"_one",o.getLocal("itAux")),o.setLocal("itIn",o.getLocal("pIn")),o.setLocal("itAux",o.i32_add(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_const(0)),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("i"),o.getLocal("n"))),o.if(o.call(t+"_isZero",o.getLocal("itIn")),o.call(t+"_copy",o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),o.getLocal("itAux")),o.call(t+"_mul",o.getLocal("itIn"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),o.getLocal("itAux"))),o.setLocal("itIn",o.i32_add(o.getLocal("itIn"),o.getLocal("inStep"))),o.setLocal("itAux",o.i32_add(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_add(o.getLocal("i"),o.i32_const(1))),o.br(0))),o.setLocal("itIn",o.i32_sub(o.getLocal("itIn"),o.getLocal("inStep"))),o.setLocal("itAux",o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("itOut",o.i32_add(o.getLocal("pOut"),o.i32_mul(o.i32_sub(o.getLocal("n"),o.i32_const(1)),o.getLocal("outStep")))),o.call(t+"_inverse",o.getLocal("itAux"),o.getLocal("itAux")),o.block(o.loop(o.br_if(1,o.i32_eqz(o.getLocal("i"))),o.if(o.call(t+"_isZero",o.getLocal("itIn")),[...o.call(t+"_copy",o.getLocal("itAux"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),...o.call(t+"_zero",o.getLocal("itOut"))],[...o.call(t+"_copy",o.i32_sub(o.getLocal("itAux"),o.i32_const(e)),a),...o.call(t+"_mul",o.getLocal("itAux"),o.getLocal("itIn"),o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),...o.call(t+"_mul",o.getLocal("itAux"),a,o.getLocal("itOut"))]),o.setLocal("itIn",o.i32_sub(o.getLocal("itIn"),o.getLocal("inStep"))),o.setLocal("itOut",o.i32_sub(o.getLocal("itOut"),o.getLocal("outStep"))),o.setLocal("itAux",o.i32_sub(o.getLocal("itAux"),o.i32_const(e))),o.setLocal("i",o.i32_sub(o.getLocal("i"),o.i32_const(1))),o.br(0)))),i.addCode(o.i32_store(o.i32_const(0),o.getLocal("itAux")))}var wr=hd;function hd(n,t,e,i,o,a){typeof a>"u"&&(i<o?a=!0:a=!1);const u=n.addFunction(t);u.addParam("pIn","i32"),u.addParam("n","i32"),u.addParam("pOut","i32"),u.addLocal("i","i32"),u.addLocal("itIn","i32"),u.addLocal("itOut","i32");const r=u.getCodeBuilder();a?u.addCode(r.setLocal("itIn",r.i32_add(r.getLocal("pIn"),r.i32_mul(r.i32_sub(r.getLocal("n"),r.i32_const(1)),r.i32_const(i)))),r.setLocal("itOut",r.i32_add(r.getLocal("pOut"),r.i32_mul(r.i32_sub(r.getLocal("n"),r.i32_const(1)),r.i32_const(o)))),r.setLocal("i",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("n"))),r.call(e,r.getLocal("itIn"),r.getLocal("itOut")),r.setLocal("itIn",r.i32_sub(r.getLocal("itIn"),r.i32_const(i))),r.setLocal("itOut",r.i32_sub(r.getLocal("itOut"),r.i32_const(o))),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0)))):u.addCode(r.setLocal("itIn",r.getLocal("pIn")),r.setLocal("itOut",r.getLocal("pOut")),r.setLocal("i",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("n"))),r.call(e,r.getLocal("itIn"),r.getLocal("itOut")),r.setLocal("itIn",r.i32_add(r.getLocal("itIn"),r.i32_const(i))),r.setLocal("itOut",r.i32_add(r.getLocal("itOut"),r.i32_const(o))),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0))))}var gd=pd;function pd(n,t,e,i,o,a){typeof a>"u"&&(i<o?a=!0:a=!1);const u=n.addFunction(t);u.addParam("pIn1","i32"),u.addParam("pIn2","i32"),u.addParam("n","i32"),u.addParam("pOut","i32"),u.addLocal("i","i32"),u.addLocal("itIn1","i32"),u.addLocal("itIn2","i32"),u.addLocal("itOut","i32");const r=u.getCodeBuilder();a?u.addCode(r.setLocal("itIn1",r.i32_add(r.getLocal("pIn1"),r.i32_mul(r.i32_sub(r.getLocal("n"),r.i32_const(1)),r.i32_const(i)))),r.setLocal("itIn2",r.i32_add(r.getLocal("pIn2"),r.i32_mul(r.i32_sub(r.getLocal("n"),r.i32_const(1)),r.i32_const(i)))),r.setLocal("itOut",r.i32_add(r.getLocal("pOut"),r.i32_mul(r.i32_sub(r.getLocal("n"),r.i32_const(1)),r.i32_const(o)))),r.setLocal("i",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("n"))),r.call(e,r.getLocal("itIn1"),r.getLocal("itIn2"),r.getLocal("itOut")),r.setLocal("itIn1",r.i32_sub(r.getLocal("itIn1"),r.i32_const(i))),r.setLocal("itIn2",r.i32_sub(r.getLocal("itIn2"),r.i32_const(i))),r.setLocal("itOut",r.i32_sub(r.getLocal("itOut"),r.i32_const(o))),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0)))):u.addCode(r.setLocal("itIn1",r.getLocal("pIn1")),r.setLocal("itIn2",r.getLocal("pIn2")),r.setLocal("itOut",r.getLocal("pOut")),r.setLocal("i",r.i32_const(0)),r.block(r.loop(r.br_if(1,r.i32_eq(r.getLocal("i"),r.getLocal("n"))),r.call(e,r.getLocal("itIn1"),r.getLocal("itIn2"),r.getLocal("itOut")),r.setLocal("itIn1",r.i32_add(r.getLocal("itIn1"),r.i32_const(i))),r.setLocal("itIn2",r.i32_add(r.getLocal("itIn2"),r.i32_const(i))),r.setLocal("itOut",r.i32_add(r.getLocal("itOut"),r.i32_const(o))),r.setLocal("i",r.i32_add(r.getLocal("i"),r.i32_const(1))),r.br(0))))}var Ae={};function mr(n,t){return n===t?0:n>t?1:-1}function da(n){return n*n}function Cr(n){return n%2n!==0n}function ua(n){return n%2n===0n}function Yi(n){return n<0n}function Ld(n){return n>0n}function Er(n){return Yi(n)?n.toString(2).length-1:n.toString(2).length}function yi(n){return n<0n?-n:n}function Rn(n){return yi(n)===1n}function Br(n,t){for(var e=0n,i=1n,o=t,a=yi(n),u,r,I;a!==0n;)u=o/a,r=e,I=o,e=i,o=a,i=r-u*i,a=I-u*a;if(!Rn(o))throw new Error(n.toString()+" and "+t.toString()+" are not co-prime");return mr(e,0n)===-1&&(e=e+t),Yi(n)?-e:e}function xr(n,t,e){if(e===0n)throw new Error("Cannot take modPow with modulus 0");var i=1n,o=n%e;for(Yi(t)&&(t=t*-1n,o=Br(o,e));Ld(t);){if(o===0n)return 0n;Cr(t)&&(i=i*o%e),t=t/2n,o=da(o)%e}return i}function Ad(n,t){return n=n>=0n?n:-n,t=t>=0n?t:-t,n===t?0:n>t?1:-1}function Ua(n,t){return t===0n?!1:Rn(t)?!0:Ad(t,2n)===0?ua(n):n%t===0n}function bd(n){var t=yi(n);if(Rn(t))return!1;if(t===2n||t===3n||t===5n)return!0;if(ua(t)||Ua(t,3n)||Ua(t,5n))return!1;if(t<49n)return!0}function yd(n){return n-1n}function Pa(n,t){for(var e=yd(n),i=e,o=0,a,u,r;ua(i);)i=i/2n,o++;t:for(u=0;u<t.length;u++)if(!(n<t[u])&&(r=xr(BigInt(t[u]),i,n),!(Rn(r)||r===e))){for(a=o-1;a!=0;a--){if(r=da(r)%n,Rn(r))return!1;if(r===e)continue t}return!1}return!0}function Id(n){var t=bd(n);if(t!==void 0)return t;var e=yi(n),i=Er(e);if(i<=64)return Pa(e,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var o=Math.log(2)*Number(i),a=Math.ceil(o),u=[],r=0;r<a;r++)u.push(BigInt(r+2));return Pa(e,u)}Ae.bitLength=Er;Ae.isOdd=Cr;Ae.isNegative=Yi;Ae.abs=yi;Ae.isUnit=Rn;Ae.compare=mr;Ae.modInv=Br;Ae.modPow=xr;Ae.isPrime=Id;Ae.square=da;const wd=fd,De=ln,md=sa,Cd=la,so=wr,lo=gd,{bitLength:Ed,modInv:uo,modPow:Ma,isPrime:ka,isOdd:Bd,square:xd}=Ae;var fa=function(t,e,i,o){const a=BigInt(e),u=Math.floor((Ed(a-1n)-1)/64)+1,r=u*2,I=u*8,l=i||"f1m";if(t.modules[l])return l;const s=wd(t,u,o),m=t.alloc(I,De.bigInt2BytesLE(a,I)),C=t.alloc(De.bigInt2BytesLE(xd(1n<<BigInt(u*64))%a,I)),g=t.alloc(De.bigInt2BytesLE((1n<<BigInt(u*64))%a,I)),M=t.alloc(De.bigInt2BytesLE(0n,I)),$=a-1n,F=$>>1n,R=t.alloc(I,De.bigInt2BytesLE(F,I)),x=F+1n,it=t.alloc(I,De.bigInt2BytesLE(x,I));t.modules[l]={pq:m,pR2:C,n64:u,q:a,pOne:g,pZero:M,pePlusOne:it};function z(){const U=t.addFunction(l+"_one");U.addParam("pr","i32");const b=U.getCodeBuilder();U.addCode(b.call(s+"_copy",b.i32_const(g),b.getLocal("pr")))}function K(){const U=t.addFunction(l+"_add");U.addParam("x","i32"),U.addParam("y","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.if(b.call(s+"_add",b.getLocal("x"),b.getLocal("y"),b.getLocal("r")),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))),b.if(b.call(s+"_gte",b.getLocal("r"),b.i32_const(m)),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))))))}function v(){const U=t.addFunction(l+"_sub");U.addParam("x","i32"),U.addParam("y","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.if(b.call(s+"_sub",b.getLocal("x"),b.getLocal("y"),b.getLocal("r")),b.drop(b.call(s+"_add",b.getLocal("r"),b.i32_const(m),b.getLocal("r")))))}function f(){const U=t.addFunction(l+"_neg");U.addParam("x","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.call(l+"_sub",b.i32_const(M),b.getLocal("x"),b.getLocal("r")))}function L(){const U=t.addFunction(l+"_isNegative");U.addParam("x","i32"),U.setReturnType("i32");const b=U.getCodeBuilder(),J=b.i32_const(t.alloc(I));U.addCode(b.call(l+"_fromMontgomery",b.getLocal("x"),J),b.call(s+"_gte",J,b.i32_const(it)))}function V(){const U=t.addFunction(l+"_sign");U.addParam("x","i32"),U.setReturnType("i32");const b=U.getCodeBuilder(),J=b.i32_const(t.alloc(I));U.addCode(b.if(b.call(s+"_isZero",b.getLocal("x")),b.ret(b.i32_const(0))),b.call(l+"_fromMontgomery",b.getLocal("x"),J),b.if(b.call(s+"_gte",J,b.i32_const(it)),b.ret(b.i32_const(-1))),b.ret(b.i32_const(1)))}function X(){const U=t.alloc(r*r*8),b=t.addFunction(l+"_mReduct");b.addParam("t","i32"),b.addParam("r","i32"),b.addLocal("np32","i64"),b.addLocal("c","i64"),b.addLocal("m","i64");const J=b.getCodeBuilder(),It=Number(0x100000000n-uo(a,0x100000000n));b.addCode(J.setLocal("np32",J.i64_const(It)));for(let lt=0;lt<r;lt++){b.addCode(J.setLocal("c",J.i64_const(0))),b.addCode(J.setLocal("m",J.i64_and(J.i64_mul(J.i64_load32_u(J.getLocal("t"),lt*4),J.getLocal("np32")),J.i64_const("0xFFFFFFFF"))));for(let At=0;At<r;At++)b.addCode(J.setLocal("c",J.i64_add(J.i64_add(J.i64_load32_u(J.getLocal("t"),(lt+At)*4),J.i64_shr_u(J.getLocal("c"),J.i64_const(32))),J.i64_mul(J.i64_load32_u(J.i32_const(m),At*4),J.getLocal("m"))))),b.addCode(J.i64_store32(J.getLocal("t"),(lt+At)*4,J.getLocal("c")));b.addCode(J.i64_store32(J.i32_const(U),lt*4,J.i64_shr_u(J.getLocal("c"),J.i64_const(32))))}b.addCode(J.call(l+"_add",J.i32_const(U),J.i32_add(J.getLocal("t"),J.i32_const(r*4)),J.getLocal("r")))}function et(){const U=t.addFunction(l+"_mul");U.addParam("x","i32"),U.addParam("y","i32"),U.addParam("r","i32"),U.addLocal("c0","i64"),U.addLocal("c1","i64"),U.addLocal("np32","i64");for(let vt=0;vt<r;vt++)U.addLocal("x"+vt,"i64"),U.addLocal("y"+vt,"i64"),U.addLocal("m"+vt,"i64"),U.addLocal("q"+vt,"i64");const b=U.getCodeBuilder(),J=Number(0x100000000n-uo(a,0x100000000n));U.addCode(b.setLocal("np32",b.i64_const(J)));const It=[],lt=[],At=[];function zt(vt,Et){let Ot,$t;return It[vt]?Ot=b.getLocal("x"+vt):(Ot=b.teeLocal("x"+vt,b.i64_load32_u(b.getLocal("x"),vt*4)),It[vt]=!0),lt[Et]?$t=b.getLocal("y"+Et):($t=b.teeLocal("y"+Et,b.i64_load32_u(b.getLocal("y"),Et*4)),lt[Et]=!0),b.i64_mul(Ot,$t)}function xt(vt,Et){let Ot,$t;return At[vt]?Ot=b.getLocal("q"+vt):(Ot=b.teeLocal("q"+vt,b.i64_load32_u(b.i32_const(0),m+vt*4)),At[vt]=!0),$t=b.getLocal("m"+Et),b.i64_mul(Ot,$t)}let Mt="c0",Gt="c1";for(let vt=0;vt<r*2-1;vt++){for(let Et=Math.max(0,vt-r+1);Et<=vt&&Et<r;Et++){const Ot=vt-Et;U.addCode(b.setLocal(Mt,b.i64_add(b.i64_and(b.getLocal(Mt),b.i64_const(4294967295)),zt(Et,Ot)))),U.addCode(b.setLocal(Gt,b.i64_add(b.getLocal(Gt),b.i64_shr_u(b.getLocal(Mt),b.i64_const(32)))))}for(let Et=Math.max(1,vt-r+1);Et<=vt&&Et<r;Et++){const Ot=vt-Et;U.addCode(b.setLocal(Mt,b.i64_add(b.i64_and(b.getLocal(Mt),b.i64_const(4294967295)),xt(Et,Ot)))),U.addCode(b.setLocal(Gt,b.i64_add(b.getLocal(Gt),b.i64_shr_u(b.getLocal(Mt),b.i64_const(32)))))}vt<r&&(U.addCode(b.setLocal("m"+vt,b.i64_and(b.i64_mul(b.i64_and(b.getLocal(Mt),b.i64_const(4294967295)),b.getLocal("np32")),b.i64_const("0xFFFFFFFF")))),U.addCode(b.setLocal(Mt,b.i64_add(b.i64_and(b.getLocal(Mt),b.i64_const(4294967295)),xt(0,vt)))),U.addCode(b.setLocal(Gt,b.i64_add(b.getLocal(Gt),b.i64_shr_u(b.getLocal(Mt),b.i64_const(32)))))),vt>=r&&U.addCode(b.i64_store32(b.getLocal("r"),(vt-r)*4,b.getLocal(Mt))),[Mt,Gt]=[Gt,Mt],U.addCode(b.setLocal(Gt,b.i64_shr_u(b.getLocal(Mt),b.i64_const(32))))}U.addCode(b.i64_store32(b.getLocal("r"),r*4-4,b.getLocal(Mt))),U.addCode(b.if(b.i32_wrap_i64(b.getLocal(Gt)),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))),b.if(b.call(s+"_gte",b.getLocal("r"),b.i32_const(m)),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))))))}function N(){const U=t.addFunction(l+"_square");U.addParam("x","i32"),U.addParam("r","i32"),U.addLocal("c0","i64"),U.addLocal("c1","i64"),U.addLocal("c0_old","i64"),U.addLocal("c1_old","i64"),U.addLocal("np32","i64");for(let Et=0;Et<r;Et++)U.addLocal("x"+Et,"i64"),U.addLocal("m"+Et,"i64"),U.addLocal("q"+Et,"i64");const b=U.getCodeBuilder(),J=Number(0x100000000n-uo(a,0x100000000n));U.addCode(b.setLocal("np32",b.i64_const(J)));const It=[],lt=[];function At(Et,Ot){let $t,Jt;return It[Et]?$t=b.getLocal("x"+Et):($t=b.teeLocal("x"+Et,b.i64_load32_u(b.getLocal("x"),Et*4)),It[Et]=!0),It[Ot]?Jt=b.getLocal("x"+Ot):(Jt=b.teeLocal("x"+Ot,b.i64_load32_u(b.getLocal("x"),Ot*4)),It[Ot]=!0),b.i64_mul($t,Jt)}function zt(Et,Ot){let $t,Jt;return lt[Et]?$t=b.getLocal("q"+Et):($t=b.teeLocal("q"+Et,b.i64_load32_u(b.i32_const(0),m+Et*4)),lt[Et]=!0),Jt=b.getLocal("m"+Ot),b.i64_mul($t,Jt)}let xt="c0",Mt="c1",Gt="c0_old",vt="c1_old";for(let Et=0;Et<r*2-1;Et++){U.addCode(b.setLocal(xt,b.i64_const(0)),b.setLocal(Mt,b.i64_const(0)));for(let Ot=Math.max(0,Et-r+1);Ot<Et+1>>1&&Ot<r;Ot++){const $t=Et-Ot;U.addCode(b.setLocal(xt,b.i64_add(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),At(Ot,$t)))),U.addCode(b.setLocal(Mt,b.i64_add(b.getLocal(Mt),b.i64_shr_u(b.getLocal(xt),b.i64_const(32)))))}U.addCode(b.setLocal(xt,b.i64_shl(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),b.i64_const(1)))),U.addCode(b.setLocal(Mt,b.i64_add(b.i64_shl(b.getLocal(Mt),b.i64_const(1)),b.i64_shr_u(b.getLocal(xt),b.i64_const(32))))),Et%2==0&&(U.addCode(b.setLocal(xt,b.i64_add(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),At(Et>>1,Et>>1)))),U.addCode(b.setLocal(Mt,b.i64_add(b.getLocal(Mt),b.i64_shr_u(b.getLocal(xt),b.i64_const(32)))))),Et>0&&(U.addCode(b.setLocal(xt,b.i64_add(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),b.i64_and(b.getLocal(Gt),b.i64_const(4294967295))))),U.addCode(b.setLocal(Mt,b.i64_add(b.i64_add(b.getLocal(Mt),b.i64_shr_u(b.getLocal(xt),b.i64_const(32))),b.getLocal(vt)))));for(let Ot=Math.max(1,Et-r+1);Ot<=Et&&Ot<r;Ot++){const $t=Et-Ot;U.addCode(b.setLocal(xt,b.i64_add(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),zt(Ot,$t)))),U.addCode(b.setLocal(Mt,b.i64_add(b.getLocal(Mt),b.i64_shr_u(b.getLocal(xt),b.i64_const(32)))))}Et<r&&(U.addCode(b.setLocal("m"+Et,b.i64_and(b.i64_mul(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),b.getLocal("np32")),b.i64_const("0xFFFFFFFF")))),U.addCode(b.setLocal(xt,b.i64_add(b.i64_and(b.getLocal(xt),b.i64_const(4294967295)),zt(0,Et)))),U.addCode(b.setLocal(Mt,b.i64_add(b.getLocal(Mt),b.i64_shr_u(b.getLocal(xt),b.i64_const(32)))))),Et>=r&&U.addCode(b.i64_store32(b.getLocal("r"),(Et-r)*4,b.getLocal(xt))),U.addCode(b.setLocal(Gt,b.getLocal(Mt)),b.setLocal(vt,b.i64_shr_u(b.getLocal(Gt),b.i64_const(32))))}U.addCode(b.i64_store32(b.getLocal("r"),r*4-4,b.getLocal(Gt))),U.addCode(b.if(b.i32_wrap_i64(b.getLocal(vt)),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))),b.if(b.call(s+"_gte",b.getLocal("r"),b.i32_const(m)),b.drop(b.call(s+"_sub",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))))))}function w(){const U=t.addFunction(l+"_squareOld");U.addParam("x","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.call(l+"_mul",b.getLocal("x"),b.getLocal("x"),b.getLocal("r")))}function T(){const U=t.addFunction(l+"_toMontgomery");U.addParam("x","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.call(l+"_mul",b.getLocal("x"),b.i32_const(C),b.getLocal("r")))}function at(){const U=t.alloc(I*2),b=t.addFunction(l+"_fromMontgomery");b.addParam("x","i32"),b.addParam("r","i32");const J=b.getCodeBuilder();b.addCode(J.call(s+"_copy",J.getLocal("x"),J.i32_const(U))),b.addCode(J.call(s+"_zero",J.i32_const(U+I))),b.addCode(J.call(l+"_mReduct",J.i32_const(U),J.getLocal("r")))}function Lt(){const U=t.addFunction(l+"_inverse");U.addParam("x","i32"),U.addParam("r","i32");const b=U.getCodeBuilder();U.addCode(b.call(l+"_fromMontgomery",b.getLocal("x"),b.getLocal("r"))),U.addCode(b.call(s+"_inverseMod",b.getLocal("r"),b.i32_const(m),b.getLocal("r"))),U.addCode(b.call(l+"_toMontgomery",b.getLocal("r"),b.getLocal("r")))}let _t=2n;if(ka(a))for(;Ma(_t,F,a)!==$;)_t=_t+1n;let ct=0,yt=$;for(;!Bd(yt)&&yt!==0n;)ct++,yt=yt>>1n;const ft=t.alloc(I,De.bigInt2BytesLE(yt,I)),ht=Ma(_t,yt,a),Ft=t.alloc(De.bigInt2BytesLE((ht<<BigInt(u*64))%a,I)),Nt=yt+1n>>1n,kt=t.alloc(I,De.bigInt2BytesLE(Nt,I));function A(){const U=t.addFunction(l+"_sqrt");U.addParam("n","i32"),U.addParam("r","i32"),U.addLocal("m","i32"),U.addLocal("i","i32"),U.addLocal("j","i32");const b=U.getCodeBuilder(),J=b.i32_const(g),It=b.i32_const(t.alloc(I)),lt=b.i32_const(t.alloc(I)),At=b.i32_const(t.alloc(I)),zt=b.i32_const(t.alloc(I)),xt=b.i32_const(t.alloc(I));U.addCode(b.if(b.call(l+"_isZero",b.getLocal("n")),b.ret(b.call(l+"_zero",b.getLocal("r")))),b.setLocal("m",b.i32_const(ct)),b.call(l+"_copy",b.i32_const(Ft),It),b.call(l+"_exp",b.getLocal("n"),b.i32_const(ft),b.i32_const(I),lt),b.call(l+"_exp",b.getLocal("n"),b.i32_const(kt),b.i32_const(I),At),b.block(b.loop(b.br_if(1,b.call(l+"_eq",lt,J)),b.call(l+"_square",lt,zt),b.setLocal("i",b.i32_const(1)),b.block(b.loop(b.br_if(1,b.call(l+"_eq",zt,J)),b.call(l+"_square",zt,zt),b.setLocal("i",b.i32_add(b.getLocal("i"),b.i32_const(1))),b.br(0))),b.call(l+"_copy",It,xt),b.setLocal("j",b.i32_sub(b.i32_sub(b.getLocal("m"),b.getLocal("i")),b.i32_const(1))),b.block(b.loop(b.br_if(1,b.i32_eqz(b.getLocal("j"))),b.call(l+"_square",xt,xt),b.setLocal("j",b.i32_sub(b.getLocal("j"),b.i32_const(1))),b.br(0))),b.setLocal("m",b.getLocal("i")),b.call(l+"_square",xt,It),b.call(l+"_mul",lt,It,lt),b.call(l+"_mul",At,xt,At),b.br(0))),b.if(b.call(l+"_isNegative",At),b.call(l+"_neg",At,b.getLocal("r")),b.call(l+"_copy",At,b.getLocal("r"))))}function c(){const U=t.addFunction(l+"_isSquare");U.addParam("n","i32"),U.setReturnType("i32");const b=U.getCodeBuilder(),J=b.i32_const(g),It=b.i32_const(t.alloc(I));U.addCode(b.if(b.call(l+"_isZero",b.getLocal("n")),b.ret(b.i32_const(1))),b.call(l+"_exp",b.getLocal("n"),b.i32_const(R),b.i32_const(I),It),b.call(l+"_eq",It,J))}function E(){const U=t.addFunction(l+"_load");U.addParam("scalar","i32"),U.addParam("scalarLen","i32"),U.addParam("r","i32"),U.addLocal("p","i32"),U.addLocal("l","i32"),U.addLocal("i","i32"),U.addLocal("j","i32");const b=U.getCodeBuilder(),J=b.i32_const(t.alloc(I)),It=t.alloc(I),lt=b.i32_const(It);U.addCode(b.call(s+"_zero",b.getLocal("r")),b.setLocal("i",b.i32_const(I)),b.setLocal("p",b.getLocal("scalar")),b.block(b.loop(b.br_if(1,b.i32_gt_u(b.getLocal("i"),b.getLocal("scalarLen"))),b.if(b.i32_eq(b.getLocal("i"),b.i32_const(I)),b.call(l+"_one",J),b.call(l+"_mul",J,b.i32_const(C),J)),b.call(l+"_mul",b.getLocal("p"),J,lt),b.call(l+"_add",b.getLocal("r"),lt,b.getLocal("r")),b.setLocal("p",b.i32_add(b.getLocal("p"),b.i32_const(I))),b.setLocal("i",b.i32_add(b.getLocal("i"),b.i32_const(I))),b.br(0))),b.setLocal("l",b.i32_rem_u(b.getLocal("scalarLen"),b.i32_const(I))),b.if(b.i32_eqz(b.getLocal("l")),b.ret([])),b.call(s+"_zero",lt),b.setLocal("j",b.i32_const(0)),b.block(b.loop(b.br_if(1,b.i32_eq(b.getLocal("j"),b.getLocal("l"))),b.i32_store8(b.getLocal("j"),It,b.i32_load8_u(b.getLocal("p"))),b.setLocal("p",b.i32_add(b.getLocal("p"),b.i32_const(1))),b.setLocal("j",b.i32_add(b.getLocal("j"),b.i32_const(1))),b.br(0))),b.if(b.i32_eq(b.getLocal("i"),b.i32_const(I)),b.call(l+"_one",J),b.call(l+"_mul",J,b.i32_const(C),J)),b.call(l+"_mul",lt,J,lt),b.call(l+"_add",b.getLocal("r"),lt,b.getLocal("r")))}function d(){const U=t.addFunction(l+"_timesScalar");U.addParam("x","i32"),U.addParam("scalar","i32"),U.addParam("scalarLen","i32"),U.addParam("r","i32");const b=U.getCodeBuilder(),J=b.i32_const(t.alloc(I));U.addCode(b.call(l+"_load",b.getLocal("scalar"),b.getLocal("scalarLen"),J),b.call(l+"_toMontgomery",J,J),b.call(l+"_mul",b.getLocal("x"),J,b.getLocal("r")))}function G(){const U=t.addFunction(l+"_isOne");U.addParam("x","i32"),U.setReturnType("i32");const b=U.getCodeBuilder();U.addCode(b.ret(b.call(s+"_eq",b.getLocal("x"),b.i32_const(g))))}return t.exportFunction(s+"_copy",l+"_copy"),t.exportFunction(s+"_zero",l+"_zero"),t.exportFunction(s+"_isZero",l+"_isZero"),t.exportFunction(s+"_eq",l+"_eq"),G(),K(),v(),f(),X(),et(),N(),w(),T(),at(),L(),V(),Lt(),z(),E(),d(),Cd(t,l),so(t,l+"_batchToMontgomery",l+"_toMontgomery",I,I),so(t,l+"_batchFromMontgomery",l+"_fromMontgomery",I,I),so(t,l+"_batchNeg",l+"_neg",I,I),lo(t,l+"_batchAdd",l+"_add",I,I),lo(t,l+"_batchSub",l+"_sub",I,I),lo(t,l+"_batchMul",l+"_mul",I,I),t.exportFunction(l+"_add"),t.exportFunction(l+"_sub"),t.exportFunction(l+"_neg"),t.exportFunction(l+"_isNegative"),t.exportFunction(l+"_isOne"),t.exportFunction(l+"_sign"),t.exportFunction(l+"_mReduct"),t.exportFunction(l+"_mul"),t.exportFunction(l+"_square"),t.exportFunction(l+"_squareOld"),t.exportFunction(l+"_fromMontgomery"),t.exportFunction(l+"_toMontgomery"),t.exportFunction(l+"_inverse"),t.exportFunction(l+"_one"),t.exportFunction(l+"_load"),t.exportFunction(l+"_timesScalar"),md(t,l+"_exp",I,l+"_mul",l+"_square",s+"_copy",l+"_one"),t.exportFunction(l+"_exp"),t.exportFunction(l+"_batchInverse"),ka(a)&&(A(),c(),t.exportFunction(l+"_sqrt"),t.exportFunction(l+"_isSquare")),t.exportFunction(l+"_batchToMontgomery"),t.exportFunction(l+"_batchFromMontgomery"),l};const Fd=fa,{bitLength:vd}=Ae;var Fr=function(t,e,i,o,a){const u=BigInt(e),r=Math.floor((vd(u-1n)-1)/64)+1,I=r*8,l=i||"f1";if(t.modules[l])return l;t.modules[l]={n64:r};const s=a||"int",m=Fd(t,u,o,s),C=t.modules[m].pR2,g=t.modules[m].pq,M=t.modules[m].pePlusOne;function $(){const it=t.alloc(I),z=t.addFunction(l+"_mul");z.addParam("x","i32"),z.addParam("y","i32"),z.addParam("r","i32");const K=z.getCodeBuilder();z.addCode(K.call(m+"_mul",K.getLocal("x"),K.getLocal("y"),K.i32_const(it))),z.addCode(K.call(m+"_mul",K.i32_const(it),K.i32_const(C),K.getLocal("r")))}function F(){const it=t.addFunction(l+"_square");it.addParam("x","i32"),it.addParam("r","i32");const z=it.getCodeBuilder();it.addCode(z.call(l+"_mul",z.getLocal("x"),z.getLocal("x"),z.getLocal("r")))}function R(){const it=t.addFunction(l+"_inverse");it.addParam("x","i32"),it.addParam("r","i32");const z=it.getCodeBuilder();it.addCode(z.call(s+"_inverseMod",z.getLocal("x"),z.i32_const(g),z.getLocal("r")))}function x(){const it=t.addFunction(l+"_isNegative");it.addParam("x","i32"),it.setReturnType("i32");const z=it.getCodeBuilder();it.addCode(z.call(s+"_gte",z.getLocal("x"),z.i32_const(M)))}return $(),F(),R(),x(),t.exportFunction(m+"_add",l+"_add"),t.exportFunction(m+"_sub",l+"_sub"),t.exportFunction(m+"_neg",l+"_neg"),t.exportFunction(l+"_mul"),t.exportFunction(l+"_square"),t.exportFunction(l+"_inverse"),t.exportFunction(l+"_isNegative"),t.exportFunction(m+"_copy",l+"_copy"),t.exportFunction(m+"_zero",l+"_zero"),t.exportFunction(m+"_one",l+"_one"),t.exportFunction(m+"_isZero",l+"_isZero"),t.exportFunction(m+"_eq",l+"_eq"),l};const Sd=sa,Od=la,fo=ln;var vr=function(t,e,i,o){if(t.modules[i])return i;const a=t.modules[o].n64*8,u=t.modules[o].q;t.modules[i]={n64:t.modules[o].n64*2};function r(){const N=t.addFunction(i+"_add");N.addParam("x","i32"),N.addParam("y","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("y"),_t=w.i32_add(w.getLocal("y"),w.i32_const(a)),ct=w.getLocal("r"),yt=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_add",T,Lt,ct),w.call(o+"_add",at,_t,yt))}function I(){const N=t.addFunction(i+"_timesScalar");N.addParam("x","i32"),N.addParam("scalar","i32"),N.addParam("scalarLen","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_timesScalar",T,w.getLocal("scalar"),w.getLocal("scalarLen"),Lt),w.call(o+"_timesScalar",at,w.getLocal("scalar"),w.getLocal("scalarLen"),_t))}function l(){const N=t.addFunction(i+"_sub");N.addParam("x","i32"),N.addParam("y","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("y"),_t=w.i32_add(w.getLocal("y"),w.i32_const(a)),ct=w.getLocal("r"),yt=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_sub",T,Lt,ct),w.call(o+"_sub",at,_t,yt))}function s(){const N=t.addFunction(i+"_neg");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_neg",T,Lt),w.call(o+"_neg",at,_t))}function m(){const N=t.addFunction(i+"_conjugate");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_copy",T,Lt),w.call(o+"_neg",at,_t))}function C(){const N=t.addFunction(i+"_isNegative");N.addParam("x","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.if(w.call(o+"_isZero",at),w.ret(w.call(o+"_isNegative",T))),w.ret(w.call(o+"_isNegative",at)))}function g(){const N=t.addFunction(i+"_mul");N.addParam("x","i32"),N.addParam("y","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("y"),_t=w.i32_add(w.getLocal("y"),w.i32_const(a)),ct=w.getLocal("r"),yt=w.i32_add(w.getLocal("r"),w.i32_const(a)),ft=w.i32_const(t.alloc(a)),ht=w.i32_const(t.alloc(a)),Ft=w.i32_const(t.alloc(a)),Nt=w.i32_const(t.alloc(a));N.addCode(w.call(o+"_mul",T,Lt,ft),w.call(o+"_mul",at,_t,ht),w.call(o+"_add",T,at,Ft),w.call(o+"_add",Lt,_t,Nt),w.call(o+"_mul",Ft,Nt,Ft),w.call(e,ht,ct),w.call(o+"_add",ft,ct,ct),w.call(o+"_add",ft,ht,yt),w.call(o+"_sub",Ft,yt,yt))}function M(){const N=t.addFunction(i+"_mul1");N.addParam("x","i32"),N.addParam("y","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("y"),_t=w.getLocal("r"),ct=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_mul",T,Lt,_t),w.call(o+"_mul",at,Lt,ct))}function $(){const N=t.addFunction(i+"_square");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a)),ct=w.i32_const(t.alloc(a)),yt=w.i32_const(t.alloc(a)),ft=w.i32_const(t.alloc(a)),ht=w.i32_const(t.alloc(a));N.addCode(w.call(o+"_mul",T,at,ct),w.call(o+"_add",T,at,yt),w.call(e,at,ft),w.call(o+"_add",T,ft,ft),w.call(e,ct,ht),w.call(o+"_add",ht,ct,ht),w.call(o+"_mul",yt,ft,Lt),w.call(o+"_sub",Lt,ht,Lt),w.call(o+"_add",ct,ct,_t))}function F(){const N=t.addFunction(i+"_toMontgomery");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_toMontgomery",T,Lt),w.call(o+"_toMontgomery",at,_t))}function R(){const N=t.addFunction(i+"_fromMontgomery");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_fromMontgomery",T,Lt),w.call(o+"_fromMontgomery",at,_t))}function x(){const N=t.addFunction(i+"_copy");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a));N.addCode(w.call(o+"_copy",T,Lt),w.call(o+"_copy",at,_t))}function it(){const N=t.addFunction(i+"_zero");N.addParam("x","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.call(o+"_zero",T),w.call(o+"_zero",at))}function z(){const N=t.addFunction(i+"_one");N.addParam("x","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.call(o+"_one",T),w.call(o+"_zero",at))}function K(){const N=t.addFunction(i+"_eq");N.addParam("x","i32"),N.addParam("y","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("y"),_t=w.i32_add(w.getLocal("y"),w.i32_const(a));N.addCode(w.i32_and(w.call(o+"_eq",T,Lt),w.call(o+"_eq",at,_t)))}function v(){const N=t.addFunction(i+"_isZero");N.addParam("x","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.i32_and(w.call(o+"_isZero",T),w.call(o+"_isZero",at)))}function f(){const N=t.addFunction(i+"_inverse");N.addParam("x","i32"),N.addParam("r","i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a)),Lt=w.getLocal("r"),_t=w.i32_add(w.getLocal("r"),w.i32_const(a)),ct=w.i32_const(t.alloc(a)),yt=w.i32_const(t.alloc(a)),ft=w.i32_const(t.alloc(a)),ht=w.i32_const(t.alloc(a));N.addCode(w.call(o+"_square",T,ct),w.call(o+"_square",at,yt),w.call(e,yt,ft),w.call(o+"_sub",ct,ft,ft),w.call(o+"_inverse",ft,ht),w.call(o+"_mul",T,ht,Lt),w.call(o+"_mul",at,ht,_t),w.call(o+"_neg",_t,_t))}function L(){const N=t.addFunction(i+"_sign");N.addParam("x","i32"),N.addLocal("s","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.setLocal("s",w.call(o+"_sign",at)),w.if(w.getLocal("s"),w.ret(w.getLocal("s"))),w.ret(w.call(o+"_sign",T)))}function V(){const N=t.addFunction(i+"_isOne");N.addParam("x","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.getLocal("x"),at=w.i32_add(w.getLocal("x"),w.i32_const(a));N.addCode(w.ret(w.i32_and(w.call(o+"_isOne",T),w.call(o+"_isZero",at))))}function X(){const N=t.addFunction(i+"_sqrt");N.addParam("a","i32"),N.addParam("pr","i32");const w=N.getCodeBuilder(),T=w.i32_const(t.alloc(fo.bigInt2BytesLE((BigInt(u||0)-3n)/4n,a))),at=w.i32_const(t.alloc(fo.bigInt2BytesLE((BigInt(u||0)-1n)/2n,a))),Lt=w.getLocal("a"),_t=w.i32_const(t.alloc(a*2)),ct=w.i32_const(t.alloc(a*2)),yt=w.i32_const(t.alloc(a*2)),ft=t.alloc(a*2),ht=w.i32_const(ft),Ft=w.i32_const(ft),Nt=w.i32_const(ft+a),kt=w.i32_const(t.alloc(a*2)),A=w.i32_const(t.alloc(a*2));N.addCode(w.call(i+"_one",ht),w.call(i+"_neg",ht,ht),w.call(i+"_exp",Lt,T,w.i32_const(a),_t),w.call(i+"_square",_t,ct),w.call(i+"_mul",Lt,ct,ct),w.call(i+"_conjugate",ct,yt),w.call(i+"_mul",yt,ct,yt),w.if(w.call(i+"_eq",yt,ht),w.unreachable()),w.call(i+"_mul",_t,Lt,kt),w.if(w.call(i+"_eq",ct,ht),[...w.call(o+"_zero",Ft),...w.call(o+"_one",Nt),...w.call(i+"_mul",ht,kt,w.getLocal("pr"))],[...w.call(i+"_one",A),...w.call(i+"_add",A,ct,A),...w.call(i+"_exp",A,at,w.i32_const(a),A),...w.call(i+"_mul",A,kt,w.getLocal("pr"))]))}function et(){const N=t.addFunction(i+"_isSquare");N.addParam("a","i32"),N.setReturnType("i32");const w=N.getCodeBuilder(),T=w.i32_const(t.alloc(fo.bigInt2BytesLE((BigInt(u||0)-3n)/4n,a))),at=w.getLocal("a"),Lt=w.i32_const(t.alloc(a*2)),_t=w.i32_const(t.alloc(a*2)),ct=w.i32_const(t.alloc(a*2)),yt=t.alloc(a*2),ft=w.i32_const(yt);N.addCode(w.call(i+"_one",ft),w.call(i+"_neg",ft,ft),w.call(i+"_exp",at,T,w.i32_const(a),Lt),w.call(i+"_square",Lt,_t),w.call(i+"_mul",at,_t,_t),w.call(i+"_conjugate",_t,ct),w.call(i+"_mul",ct,_t,ct),w.if(w.call(i+"_eq",ct,ft),w.ret(w.i32_const(0))),w.ret(w.i32_const(1)))}return v(),V(),it(),z(),x(),g(),M(),$(),r(),l(),s(),m(),F(),R(),K(),f(),I(),L(),C(),t.exportFunction(i+"_isZero"),t.exportFunction(i+"_isOne"),t.exportFunction(i+"_zero"),t.exportFunction(i+"_one"),t.exportFunction(i+"_copy"),t.exportFunction(i+"_mul"),t.exportFunction(i+"_mul1"),t.exportFunction(i+"_square"),t.exportFunction(i+"_add"),t.exportFunction(i+"_sub"),t.exportFunction(i+"_neg"),t.exportFunction(i+"_sign"),t.exportFunction(i+"_conjugate"),t.exportFunction(i+"_fromMontgomery"),t.exportFunction(i+"_toMontgomery"),t.exportFunction(i+"_eq"),t.exportFunction(i+"_inverse"),Od(t,i),Sd(t,i+"_exp",a*2,i+"_mul",i+"_square",i+"_copy",i+"_one"),X(),et(),t.exportFunction(i+"_exp"),t.exportFunction(i+"_timesScalar"),t.exportFunction(i+"_batchInverse"),t.exportFunction(i+"_sqrt"),t.exportFunction(i+"_isSquare"),t.exportFunction(i+"_isNegative"),i};const Ud=sa,Pd=la;var Sr=function(t,e,i,o){if(t.modules[i])return i;const a=t.modules[o].n64*8;t.modules[i]={n64:t.modules[o].n64*3};function u(){const f=t.addFunction(i+"_add");f.addParam("x","i32"),f.addParam("y","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("y"),w=L.i32_add(L.getLocal("y"),L.i32_const(a)),T=L.i32_add(L.getLocal("y"),L.i32_const(2*a)),at=L.getLocal("r"),Lt=L.i32_add(L.getLocal("r"),L.i32_const(a)),_t=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_add",V,N,at),L.call(o+"_add",X,w,Lt),L.call(o+"_add",et,T,_t))}function r(){const f=t.addFunction(i+"_timesScalar");f.addParam("x","i32"),f.addParam("scalar","i32"),f.addParam("scalarLen","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_timesScalar",V,L.getLocal("scalar"),L.getLocal("scalarLen"),N),L.call(o+"_timesScalar",X,L.getLocal("scalar"),L.getLocal("scalarLen"),w),L.call(o+"_timesScalar",et,L.getLocal("scalar"),L.getLocal("scalarLen"),T))}function I(){const f=t.addFunction(i+"_sub");f.addParam("x","i32"),f.addParam("y","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("y"),w=L.i32_add(L.getLocal("y"),L.i32_const(a)),T=L.i32_add(L.getLocal("y"),L.i32_const(2*a)),at=L.getLocal("r"),Lt=L.i32_add(L.getLocal("r"),L.i32_const(a)),_t=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_sub",V,N,at),L.call(o+"_sub",X,w,Lt),L.call(o+"_sub",et,T,_t))}function l(){const f=t.addFunction(i+"_neg");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_neg",V,N),L.call(o+"_neg",X,w),L.call(o+"_neg",et,T))}function s(){const f=t.addFunction(i+"_isNegative");f.addParam("x","i32"),f.setReturnType("i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a));f.addCode(L.if(L.call(o+"_isZero",et),L.if(L.call(o+"_isZero",X),L.ret(L.call(o+"_isNegative",V)),L.ret(L.call(o+"_isNegative",X)))),L.ret(L.call(o+"_isNegative",et)))}function m(){const f=t.addFunction(i+"_mul");f.addParam("x","i32"),f.addParam("y","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("y"),w=L.i32_add(L.getLocal("y"),L.i32_const(a)),T=L.i32_add(L.getLocal("y"),L.i32_const(2*a)),at=L.getLocal("r"),Lt=L.i32_add(L.getLocal("r"),L.i32_const(a)),_t=L.i32_add(L.getLocal("r"),L.i32_const(2*a)),ct=L.i32_const(t.alloc(a)),yt=L.i32_const(t.alloc(a)),ft=L.i32_const(t.alloc(a)),ht=L.i32_const(t.alloc(a)),Ft=L.i32_const(t.alloc(a)),Nt=L.i32_const(t.alloc(a)),kt=L.i32_const(t.alloc(a)),A=L.i32_const(t.alloc(a)),c=L.i32_const(t.alloc(a)),E=L.i32_const(t.alloc(a)),d=L.i32_const(t.alloc(a)),G=L.i32_const(t.alloc(a)),U=L.i32_const(t.alloc(a));f.addCode(L.call(o+"_mul",V,N,ct),L.call(o+"_mul",X,w,yt),L.call(o+"_mul",et,T,ft),L.call(o+"_add",V,X,ht),L.call(o+"_add",N,w,Ft),L.call(o+"_add",V,et,Nt),L.call(o+"_add",N,T,kt),L.call(o+"_add",X,et,A),L.call(o+"_add",w,T,c),L.call(o+"_add",ct,yt,E),L.call(o+"_add",ct,ft,d),L.call(o+"_add",yt,ft,G),L.call(o+"_mul",A,c,at),L.call(o+"_sub",at,G,at),L.call(e,at,at),L.call(o+"_add",ct,at,at),L.call(o+"_mul",ht,Ft,Lt),L.call(o+"_sub",Lt,E,Lt),L.call(e,ft,U),L.call(o+"_add",Lt,U,Lt),L.call(o+"_mul",Nt,kt,_t),L.call(o+"_sub",_t,d,_t),L.call(o+"_add",_t,yt,_t))}function C(){const f=t.addFunction(i+"_square");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a)),at=L.i32_const(t.alloc(a)),Lt=L.i32_const(t.alloc(a)),_t=L.i32_const(t.alloc(a)),ct=L.i32_const(t.alloc(a)),yt=L.i32_const(t.alloc(a)),ft=L.i32_const(t.alloc(a)),ht=L.i32_const(t.alloc(a));f.addCode(L.call(o+"_square",V,at),L.call(o+"_mul",V,X,Lt),L.call(o+"_add",Lt,Lt,_t),L.call(o+"_sub",V,X,ct),L.call(o+"_add",ct,et,ct),L.call(o+"_square",ct,ct),L.call(o+"_mul",X,et,yt),L.call(o+"_add",yt,yt,ft),L.call(o+"_square",et,ht),L.call(e,ft,N),L.call(o+"_add",at,N,N),L.call(e,ht,w),L.call(o+"_add",_t,w,w),L.call(o+"_add",at,ht,T),L.call(o+"_sub",ft,T,T),L.call(o+"_add",ct,T,T),L.call(o+"_add",_t,T,T))}function g(){const f=t.addFunction(i+"_toMontgomery");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_toMontgomery",V,N),L.call(o+"_toMontgomery",X,w),L.call(o+"_toMontgomery",et,T))}function M(){const f=t.addFunction(i+"_fromMontgomery");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_fromMontgomery",V,N),L.call(o+"_fromMontgomery",X,w),L.call(o+"_fromMontgomery",et,T))}function $(){const f=t.addFunction(i+"_copy");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a));f.addCode(L.call(o+"_copy",V,N),L.call(o+"_copy",X,w),L.call(o+"_copy",et,T))}function F(){const f=t.addFunction(i+"_zero");f.addParam("x","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a));f.addCode(L.call(o+"_zero",V),L.call(o+"_zero",X),L.call(o+"_zero",et))}function R(){const f=t.addFunction(i+"_one");f.addParam("x","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a));f.addCode(L.call(o+"_one",V),L.call(o+"_zero",X),L.call(o+"_zero",et))}function x(){const f=t.addFunction(i+"_eq");f.addParam("x","i32"),f.addParam("y","i32"),f.setReturnType("i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("y"),w=L.i32_add(L.getLocal("y"),L.i32_const(a)),T=L.i32_add(L.getLocal("y"),L.i32_const(2*a));f.addCode(L.i32_and(L.i32_and(L.call(o+"_eq",V,N),L.call(o+"_eq",X,w)),L.call(o+"_eq",et,T)))}function it(){const f=t.addFunction(i+"_isZero");f.addParam("x","i32"),f.setReturnType("i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a));f.addCode(L.i32_and(L.i32_and(L.call(o+"_isZero",V),L.call(o+"_isZero",X)),L.call(o+"_isZero",et)))}function z(){const f=t.addFunction(i+"_inverse");f.addParam("x","i32"),f.addParam("r","i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a)),N=L.getLocal("r"),w=L.i32_add(L.getLocal("r"),L.i32_const(a)),T=L.i32_add(L.getLocal("r"),L.i32_const(2*a)),at=L.i32_const(t.alloc(a)),Lt=L.i32_const(t.alloc(a)),_t=L.i32_const(t.alloc(a)),ct=L.i32_const(t.alloc(a)),yt=L.i32_const(t.alloc(a)),ft=L.i32_const(t.alloc(a)),ht=L.i32_const(t.alloc(a)),Ft=L.i32_const(t.alloc(a)),Nt=L.i32_const(t.alloc(a)),kt=L.i32_const(t.alloc(a)),A=L.i32_const(t.alloc(a));f.addCode(L.call(o+"_square",V,at),L.call(o+"_square",X,Lt),L.call(o+"_square",et,_t),L.call(o+"_mul",V,X,ct),L.call(o+"_mul",V,et,yt),L.call(o+"_mul",X,et,ft),L.call(e,ft,ht),L.call(o+"_sub",at,ht,ht),L.call(e,_t,Ft),L.call(o+"_sub",Ft,ct,Ft),L.call(o+"_sub",Lt,yt,Nt),L.call(o+"_mul",et,Ft,kt),L.call(o+"_mul",X,Nt,A),L.call(o+"_add",kt,A,kt),L.call(e,kt,kt),L.call(o+"_mul",V,ht,A),L.call(o+"_add",A,kt,kt),L.call(o+"_inverse",kt,kt),L.call(o+"_mul",kt,ht,N),L.call(o+"_mul",kt,Ft,w),L.call(o+"_mul",kt,Nt,T))}function K(){const f=t.addFunction(i+"_sign");f.addParam("x","i32"),f.addLocal("s","i32"),f.setReturnType("i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(2*a));f.addCode(L.setLocal("s",L.call(o+"_sign",et)),L.if(L.getLocal("s"),L.ret(L.getLocal("s"))),L.setLocal("s",L.call(o+"_sign",X)),L.if(L.getLocal("s"),L.ret(L.getLocal("s"))),L.ret(L.call(o+"_sign",V)))}function v(){const f=t.addFunction(i+"_isOne");f.addParam("x","i32"),f.setReturnType("i32");const L=f.getCodeBuilder(),V=L.getLocal("x"),X=L.i32_add(L.getLocal("x"),L.i32_const(a)),et=L.i32_add(L.getLocal("x"),L.i32_const(a*2));f.addCode(L.ret(L.i32_and(L.i32_and(L.call(o+"_isOne",V),L.call(o+"_isZero",X)),L.call(o+"_isZero",et))))}return it(),v(),F(),R(),$(),m(),C(),u(),I(),l(),K(),g(),M(),x(),z(),r(),s(),t.exportFunction(i+"_isZero"),t.exportFunction(i+"_isOne"),t.exportFunction(i+"_zero"),t.exportFunction(i+"_one"),t.exportFunction(i+"_copy"),t.exportFunction(i+"_mul"),t.exportFunction(i+"_square"),t.exportFunction(i+"_add"),t.exportFunction(i+"_sub"),t.exportFunction(i+"_neg"),t.exportFunction(i+"_sign"),t.exportFunction(i+"_fromMontgomery"),t.exportFunction(i+"_toMontgomery"),t.exportFunction(i+"_eq"),t.exportFunction(i+"_inverse"),Pd(t,i),Ud(t,i+"_exp",a*3,i+"_mul",i+"_square",i+"_copy",i+"_one"),t.exportFunction(i+"_exp"),t.exportFunction(i+"_timesScalar"),t.exportFunction(i+"_batchInverse"),t.exportFunction(i+"_isNegative"),i},Md=function(t,e,i,o,a,u,r,I){const l=t.addFunction(e);l.addParam("base","i32"),l.addParam("scalar","i32"),l.addParam("scalarLength","i32"),l.addParam("r","i32"),l.addLocal("old0","i32"),l.addLocal("nbits","i32"),l.addLocal("i","i32"),l.addLocal("last","i32"),l.addLocal("cur","i32"),l.addLocal("carry","i32"),l.addLocal("p","i32");const s=l.getCodeBuilder(),m=s.i32_const(t.alloc(i));function C(M){return s.i32_and(s.i32_shr_u(s.i32_load(s.i32_add(s.getLocal("scalar"),s.i32_and(s.i32_shr_u(M,s.i32_const(3)),s.i32_const(4294967292)))),s.i32_and(M,s.i32_const(31))),s.i32_const(1))}function g(M){return[...s.i32_store8(s.getLocal("p"),s.i32_const(M)),...s.setLocal("p",s.i32_add(s.getLocal("p"),s.i32_const(1)))]}l.addCode(s.if(s.i32_eqz(s.getLocal("scalarLength")),[...s.call(I,s.getLocal("r")),...s.ret([])]),s.setLocal("nbits",s.i32_shl(s.getLocal("scalarLength"),s.i32_const(3))),s.setLocal("old0",s.i32_load(s.i32_const(0))),s.setLocal("p",s.getLocal("old0")),s.i32_store(s.i32_const(0),s.i32_and(s.i32_add(s.i32_add(s.getLocal("old0"),s.i32_const(32)),s.getLocal("nbits")),s.i32_const(4294967288))),s.setLocal("i",s.i32_const(1)),s.setLocal("last",C(s.i32_const(0))),s.setLocal("carry",s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("i"),s.getLocal("nbits"))),s.setLocal("cur",C(s.getLocal("i"))),s.if(s.getLocal("last"),s.if(s.getLocal("cur"),s.if(s.getLocal("carry"),[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(1)),...g(1)],[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(1)),...g(255)]),s.if(s.getLocal("carry"),[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(1)),...g(255)],[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(0)),...g(1)])),s.if(s.getLocal("cur"),s.if(s.getLocal("carry"),[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(1)),...g(0)],[...s.setLocal("last",s.i32_const(1)),...s.setLocal("carry",s.i32_const(0)),...g(0)]),s.if(s.getLocal("carry"),[...s.setLocal("last",s.i32_const(1)),...s.setLocal("carry",s.i32_const(0)),...g(0)],[...s.setLocal("last",s.i32_const(0)),...s.setLocal("carry",s.i32_const(0)),...g(0)]))),s.setLocal("i",s.i32_add(s.getLocal("i"),s.i32_const(1))),s.br(0))),s.if(s.getLocal("last"),s.if(s.getLocal("carry"),[...g(255),...g(0),...g(1)],[...g(1)]),s.if(s.getLocal("carry"),[...g(0),...g(1)])),s.setLocal("p",s.i32_sub(s.getLocal("p"),s.i32_const(1))),s.call(r,s.getLocal("base"),m),s.call(I,s.getLocal("r")),s.block(s.loop(s.call(a,s.getLocal("r"),s.getLocal("r")),s.setLocal("cur",s.i32_load8_u(s.getLocal("p"))),s.if(s.getLocal("cur"),s.if(s.i32_eq(s.getLocal("cur"),s.i32_const(1)),s.call(o,s.getLocal("r"),m,s.getLocal("r")),s.call(u,s.getLocal("r"),m,s.getLocal("r")))),s.br_if(1,s.i32_eq(s.getLocal("old0"),s.getLocal("p"))),s.setLocal("p",s.i32_sub(s.getLocal("p"),s.i32_const(1))),s.br(0))),s.i32_store(s.i32_const(0),s.getLocal("old0")))},kd=function(t,e,i,o,a){const r=t.modules[e].n64*8;function I(){const C=t.addFunction(i+"_getChunk");C.addParam("pScalar","i32"),C.addParam("scalarSize","i32"),C.addParam("startBit","i32"),C.addParam("chunkSize","i32"),C.addLocal("bitsToEnd","i32"),C.addLocal("mask","i32"),C.setReturnType("i32");const g=C.getCodeBuilder();C.addCode(g.setLocal("bitsToEnd",g.i32_sub(g.i32_mul(g.getLocal("scalarSize"),g.i32_const(8)),g.getLocal("startBit"))),g.if(g.i32_gt_s(g.getLocal("chunkSize"),g.getLocal("bitsToEnd")),g.setLocal("mask",g.i32_sub(g.i32_shl(g.i32_const(1),g.getLocal("bitsToEnd")),g.i32_const(1))),g.setLocal("mask",g.i32_sub(g.i32_shl(g.i32_const(1),g.getLocal("chunkSize")),g.i32_const(1)))),g.i32_and(g.i32_shr_u(g.i32_load(g.i32_add(g.getLocal("pScalar"),g.i32_shr_u(g.getLocal("startBit"),g.i32_const(3))),0,0),g.i32_and(g.getLocal("startBit"),g.i32_const(7))),g.getLocal("mask")))}function l(){const C=t.addFunction(i+"_chunk");C.addParam("pBases","i32"),C.addParam("pScalars","i32"),C.addParam("scalarSize","i32"),C.addParam("n","i32"),C.addParam("startBit","i32"),C.addParam("chunkSize","i32"),C.addParam("pr","i32"),C.addLocal("nChunks","i32"),C.addLocal("itScalar","i32"),C.addLocal("endScalar","i32"),C.addLocal("itBase","i32"),C.addLocal("i","i32"),C.addLocal("j","i32"),C.addLocal("nTable","i32"),C.addLocal("pTable","i32"),C.addLocal("idx","i32"),C.addLocal("pIdxTable","i32");const g=C.getCodeBuilder();C.addCode(g.if(g.i32_eqz(g.getLocal("n")),[...g.call(e+"_zero",g.getLocal("pr")),...g.ret([])]),g.setLocal("nTable",g.i32_shl(g.i32_const(1),g.getLocal("chunkSize"))),g.setLocal("pTable",g.i32_load(g.i32_const(0))),g.i32_store(g.i32_const(0),g.i32_add(g.getLocal("pTable"),g.i32_mul(g.getLocal("nTable"),g.i32_const(r)))),g.setLocal("j",g.i32_const(0)),g.block(g.loop(g.br_if(1,g.i32_eq(g.getLocal("j"),g.getLocal("nTable"))),g.call(e+"_zero",g.i32_add(g.getLocal("pTable"),g.i32_mul(g.getLocal("j"),g.i32_const(r)))),g.setLocal("j",g.i32_add(g.getLocal("j"),g.i32_const(1))),g.br(0))),g.setLocal("itBase",g.getLocal("pBases")),g.setLocal("itScalar",g.getLocal("pScalars")),g.setLocal("endScalar",g.i32_add(g.getLocal("pScalars"),g.i32_mul(g.getLocal("n"),g.getLocal("scalarSize")))),g.block(g.loop(g.br_if(1,g.i32_eq(g.getLocal("itScalar"),g.getLocal("endScalar"))),g.setLocal("idx",g.call(i+"_getChunk",g.getLocal("itScalar"),g.getLocal("scalarSize"),g.getLocal("startBit"),g.getLocal("chunkSize"))),g.if(g.getLocal("idx"),[...g.setLocal("pIdxTable",g.i32_add(g.getLocal("pTable"),g.i32_mul(g.i32_sub(g.getLocal("idx"),g.i32_const(1)),g.i32_const(r)))),...g.call(o,g.getLocal("pIdxTable"),g.getLocal("itBase"),g.getLocal("pIdxTable"))]),g.setLocal("itScalar",g.i32_add(g.getLocal("itScalar"),g.getLocal("scalarSize"))),g.setLocal("itBase",g.i32_add(g.getLocal("itBase"),g.i32_const(a))),g.br(0))),g.call(i+"_reduceTable",g.getLocal("pTable"),g.getLocal("chunkSize")),g.call(e+"_copy",g.getLocal("pTable"),g.getLocal("pr")),g.i32_store(g.i32_const(0),g.getLocal("pTable")))}function s(){const C=t.addFunction(i);C.addParam("pBases","i32"),C.addParam("pScalars","i32"),C.addParam("scalarSize","i32"),C.addParam("n","i32"),C.addParam("pr","i32"),C.addLocal("chunkSize","i32"),C.addLocal("nChunks","i32"),C.addLocal("itScalar","i32"),C.addLocal("endScalar","i32"),C.addLocal("itBase","i32"),C.addLocal("itBit","i32"),C.addLocal("i","i32"),C.addLocal("j","i32"),C.addLocal("nTable","i32"),C.addLocal("pTable","i32"),C.addLocal("idx","i32"),C.addLocal("pIdxTable","i32");const g=C.getCodeBuilder(),M=g.i32_const(t.alloc(r)),$=t.alloc([17,17,17,17,17,17,17,17,17,17,16,16,15,14,13,13,12,11,10,9,8,7,7,6,5,4,3,2,1,1,1,1]);C.addCode(g.call(e+"_zero",g.getLocal("pr")),g.if(g.i32_eqz(g.getLocal("n")),g.ret([])),g.setLocal("chunkSize",g.i32_load8_u(g.i32_clz(g.getLocal("n")),$)),g.setLocal("nChunks",g.i32_add(g.i32_div_u(g.i32_sub(g.i32_shl(g.getLocal("scalarSize"),g.i32_const(3)),g.i32_const(1)),g.getLocal("chunkSize")),g.i32_const(1))),g.setLocal("itBit",g.i32_mul(g.i32_sub(g.getLocal("nChunks"),g.i32_const(1)),g.getLocal("chunkSize"))),g.block(g.loop(g.br_if(1,g.i32_lt_s(g.getLocal("itBit"),g.i32_const(0))),g.if(g.i32_eqz(g.call(e+"_isZero",g.getLocal("pr"))),[...g.setLocal("j",g.i32_const(0)),...g.block(g.loop(g.br_if(1,g.i32_eq(g.getLocal("j"),g.getLocal("chunkSize"))),g.call(e+"_double",g.getLocal("pr"),g.getLocal("pr")),g.setLocal("j",g.i32_add(g.getLocal("j"),g.i32_const(1))),g.br(0)))]),g.call(i+"_chunk",g.getLocal("pBases"),g.getLocal("pScalars"),g.getLocal("scalarSize"),g.getLocal("n"),g.getLocal("itBit"),g.getLocal("chunkSize"),M),g.call(e+"_add",g.getLocal("pr"),M,g.getLocal("pr")),g.setLocal("itBit",g.i32_sub(g.getLocal("itBit"),g.getLocal("chunkSize"))),g.br(0))))}function m(){const C=t.addFunction(i+"_reduceTable");C.addParam("pTable","i32"),C.addParam("p","i32"),C.addLocal("half","i32"),C.addLocal("it1","i32"),C.addLocal("it2","i32"),C.addLocal("pAcc","i32");const g=C.getCodeBuilder();C.addCode(g.if(g.i32_eq(g.getLocal("p"),g.i32_const(1)),g.ret([])),g.setLocal("half",g.i32_shl(g.i32_const(1),g.i32_sub(g.getLocal("p"),g.i32_const(1)))),g.setLocal("it1",g.getLocal("pTable")),g.setLocal("it2",g.i32_add(g.getLocal("pTable"),g.i32_mul(g.getLocal("half"),g.i32_const(r)))),g.setLocal("pAcc",g.i32_sub(g.getLocal("it2"),g.i32_const(r))),g.block(g.loop(g.br_if(1,g.i32_eq(g.getLocal("it1"),g.getLocal("pAcc"))),g.call(e+"_add",g.getLocal("it1"),g.getLocal("it2"),g.getLocal("it1")),g.call(e+"_add",g.getLocal("pAcc"),g.getLocal("it2"),g.getLocal("pAcc")),g.setLocal("it1",g.i32_add(g.getLocal("it1"),g.i32_const(r))),g.setLocal("it2",g.i32_add(g.getLocal("it2"),g.i32_const(r))),g.br(0))),g.call(i+"_reduceTable",g.getLocal("pTable"),g.i32_sub(g.getLocal("p"),g.i32_const(1))),g.setLocal("p",g.i32_sub(g.getLocal("p"),g.i32_const(1))),g.block(g.loop(g.br_if(1,g.i32_eqz(g.getLocal("p"))),g.call(e+"_double",g.getLocal("pAcc"),g.getLocal("pAcc")),g.setLocal("p",g.i32_sub(g.getLocal("p"),g.i32_const(1))),g.br(0))),g.call(e+"_add",g.getLocal("pTable"),g.getLocal("pAcc"),g.getLocal("pTable")))}I(),m(),l(),s(),t.exportFunction(i),t.exportFunction(i+"_chunk")};const Ta=Md,Yn=wr,za=kd;var Or=function(t,e,i,o){const a=t.modules[i].n64,u=a*8;if(t.modules[e])return e;t.modules[e]={n64:a*3};function r(){const A=t.addFunction(e+"_isZero");A.addParam("p1","i32"),A.setReturnType("i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_isZero",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))))}function I(){const A=t.addFunction(e+"_isZeroAffine");A.addParam("p1","i32"),A.setReturnType("i32");const c=A.getCodeBuilder();A.addCode(c.i32_and(c.call(i+"_isZero",c.getLocal("p1")),c.call(i+"_isZero",c.i32_add(c.getLocal("p1"),c.i32_const(u)))))}function l(){const A=t.addFunction(e+"_copy");A.addParam("ps","i32"),A.addParam("pd","i32");const c=A.getCodeBuilder();for(let E=0;E<a*3;E++)A.addCode(c.i64_store(c.getLocal("pd"),E*8,c.i64_load(c.getLocal("ps"),E*8)))}function s(){const A=t.addFunction(e+"_copyAffine");A.addParam("ps","i32"),A.addParam("pd","i32");const c=A.getCodeBuilder();for(let E=0;E<a*2;E++)A.addCode(c.i64_store(c.getLocal("pd"),E*8,c.i64_load(c.getLocal("ps"),E*8)))}function m(){const A=t.addFunction(e+"_zero");A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_zero",c.getLocal("pr"))),A.addCode(c.call(i+"_one",c.i32_add(c.getLocal("pr"),c.i32_const(u)))),A.addCode(c.call(i+"_zero",c.i32_add(c.getLocal("pr"),c.i32_const(u*2))))}function C(){const A=t.addFunction(e+"_zeroAffine");A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_zero",c.getLocal("pr"))),A.addCode(c.call(i+"_zero",c.i32_add(c.getLocal("pr"),c.i32_const(u))))}function g(){const A=t.addFunction(e+"_eq");A.addParam("p1","i32"),A.addParam("p2","i32"),A.setReturnType("i32"),A.addLocal("z1","i32"),A.addLocal("z2","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u));A.addCode(c.setLocal("z1",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))));const G=c.getLocal("z1"),U=c.getLocal("p2"),b=c.i32_add(c.getLocal("p2"),c.i32_const(u));A.addCode(c.setLocal("z2",c.i32_add(c.getLocal("p2"),c.i32_const(u*2))));const J=c.getLocal("z2"),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u)),Mt=c.i32_const(t.alloc(u)),Gt=c.i32_const(t.alloc(u)),vt=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),c.ret(c.call(e+"_isZero",c.getLocal("p2")))),c.if(c.call(e+"_isZero",c.getLocal("p2")),c.ret(c.i32_const(0))),c.if(c.call(i+"_isOne",G),c.ret(c.call(e+"_eqMixed",c.getLocal("p2"),c.getLocal("p1")))),c.if(c.call(i+"_isOne",J),c.ret(c.call(e+"_eqMixed",c.getLocal("p1"),c.getLocal("p2")))),c.call(i+"_square",G,It),c.call(i+"_square",J,lt),c.call(i+"_mul",E,lt,At),c.call(i+"_mul",U,It,zt),c.call(i+"_mul",G,It,xt),c.call(i+"_mul",J,lt,Mt),c.call(i+"_mul",d,Mt,Gt),c.call(i+"_mul",b,xt,vt),c.if(c.call(i+"_eq",At,zt),c.if(c.call(i+"_eq",Gt,vt),c.ret(c.i32_const(1)))),c.ret(c.i32_const(0)))}function M(){const A=t.addFunction(e+"_eqMixed");A.addParam("p1","i32"),A.addParam("p2","i32"),A.setReturnType("i32"),A.addLocal("z1","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u));A.addCode(c.setLocal("z1",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))));const G=c.getLocal("z1"),U=c.getLocal("p2"),b=c.i32_add(c.getLocal("p2"),c.i32_const(u)),J=c.i32_const(t.alloc(u)),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),c.ret(c.call(e+"_isZeroAffine",c.getLocal("p2")))),c.if(c.call(e+"_isZeroAffine",c.getLocal("p2")),c.ret(c.i32_const(0))),c.if(c.call(i+"_isOne",G),c.ret(c.call(e+"_eqAffine",c.getLocal("p1"),c.getLocal("p2")))),c.call(i+"_square",G,J),c.call(i+"_mul",U,J,It),c.call(i+"_mul",G,J,lt),c.call(i+"_mul",b,lt,At),c.if(c.call(i+"_eq",E,It),c.if(c.call(i+"_eq",d,At),c.ret(c.i32_const(1)))),c.ret(c.i32_const(0)))}function $(){const A=t.addFunction(e+"_double");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.i32_add(c.getLocal("p1"),c.i32_const(u*2)),U=c.getLocal("pr"),b=c.i32_add(c.getLocal("pr"),c.i32_const(u)),J=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u)),Mt=c.i32_const(t.alloc(u)),Gt=c.i32_const(t.alloc(u)),vt=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),[...c.call(e+"_copy",c.getLocal("p1"),c.getLocal("pr")),...c.ret([])]),c.if(c.call(i+"_isOne",G),[...c.ret(c.call(e+"_doubleAffine",c.getLocal("p1"),c.getLocal("pr"))),...c.ret([])]),c.call(i+"_square",E,It),c.call(i+"_square",d,lt),c.call(i+"_square",lt,At),c.call(i+"_add",E,lt,zt),c.call(i+"_square",zt,zt),c.call(i+"_sub",zt,It,zt),c.call(i+"_sub",zt,At,zt),c.call(i+"_add",zt,zt,zt),c.call(i+"_add",It,It,xt),c.call(i+"_add",xt,It,xt),c.call(i+"_square",xt,Mt),c.call(i+"_mul",d,G,Gt),c.call(i+"_add",zt,zt,U),c.call(i+"_sub",Mt,U,U),c.call(i+"_add",At,At,vt),c.call(i+"_add",vt,vt,vt),c.call(i+"_add",vt,vt,vt),c.call(i+"_sub",zt,U,b),c.call(i+"_mul",b,xt,b),c.call(i+"_sub",b,vt,b),c.call(i+"_add",Gt,Gt,J))}function F(){const A=t.addFunction(e+"_doubleAffine");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.getLocal("pr"),U=c.i32_add(c.getLocal("pr"),c.i32_const(u)),b=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),J=c.i32_const(t.alloc(u)),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZeroAffine",c.getLocal("p1")),[...c.call(e+"_toJacobian",c.getLocal("p1"),c.getLocal("pr")),...c.ret([])]),c.call(i+"_square",E,J),c.call(i+"_square",d,It),c.call(i+"_square",It,lt),c.call(i+"_add",E,It,At),c.call(i+"_square",At,At),c.call(i+"_sub",At,J,At),c.call(i+"_sub",At,lt,At),c.call(i+"_add",At,At,At),c.call(i+"_add",J,J,zt),c.call(i+"_add",zt,J,zt),c.call(i+"_add",d,d,b),c.call(i+"_square",zt,G),c.call(i+"_sub",G,At,G),c.call(i+"_sub",G,At,G),c.call(i+"_add",lt,lt,xt),c.call(i+"_add",xt,xt,xt),c.call(i+"_add",xt,xt,xt),c.call(i+"_sub",At,G,U),c.call(i+"_mul",U,zt,U),c.call(i+"_sub",U,xt,U))}function R(){const A=t.addFunction(e+"_eqAffine");A.addParam("p1","i32"),A.addParam("p2","i32"),A.setReturnType("i32"),A.addLocal("z1","i32");const c=A.getCodeBuilder();A.addCode(c.ret(c.i32_and(c.call(i+"_eq",c.getLocal("p1"),c.getLocal("p2")),c.call(i+"_eq",c.i32_add(c.getLocal("p1"),c.i32_const(u)),c.i32_add(c.getLocal("p2"),c.i32_const(u))))))}function x(){const A=t.addFunction(e+"_toMontgomery");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_toMontgomery",c.getLocal("p1"),c.getLocal("pr")));for(let E=1;E<3;E++)A.addCode(c.call(i+"_toMontgomery",c.i32_add(c.getLocal("p1"),c.i32_const(E*u)),c.i32_add(c.getLocal("pr"),c.i32_const(E*u))))}function it(){const A=t.addFunction(e+"_toMontgomeryAffine");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_toMontgomery",c.getLocal("p1"),c.getLocal("pr")));for(let E=1;E<2;E++)A.addCode(c.call(i+"_toMontgomery",c.i32_add(c.getLocal("p1"),c.i32_const(E*u)),c.i32_add(c.getLocal("pr"),c.i32_const(E*u))))}function z(){const A=t.addFunction(e+"_fromMontgomery");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_fromMontgomery",c.getLocal("p1"),c.getLocal("pr")));for(let E=1;E<3;E++)A.addCode(c.call(i+"_fromMontgomery",c.i32_add(c.getLocal("p1"),c.i32_const(E*u)),c.i32_add(c.getLocal("pr"),c.i32_const(E*u))))}function K(){const A=t.addFunction(e+"_fromMontgomeryAffine");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder();A.addCode(c.call(i+"_fromMontgomery",c.getLocal("p1"),c.getLocal("pr")));for(let E=1;E<2;E++)A.addCode(c.call(i+"_fromMontgomery",c.i32_add(c.getLocal("p1"),c.i32_const(E*u)),c.i32_add(c.getLocal("pr"),c.i32_const(E*u))))}function v(){const A=t.addFunction(e+"_add");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32"),A.addLocal("z1","i32"),A.addLocal("z2","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u));A.addCode(c.setLocal("z1",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))));const G=c.getLocal("z1"),U=c.getLocal("p2"),b=c.i32_add(c.getLocal("p2"),c.i32_const(u));A.addCode(c.setLocal("z2",c.i32_add(c.getLocal("p2"),c.i32_const(u*2))));const J=c.getLocal("z2"),It=c.getLocal("pr"),lt=c.i32_add(c.getLocal("pr"),c.i32_const(u)),At=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u)),Mt=c.i32_const(t.alloc(u)),Gt=c.i32_const(t.alloc(u)),vt=c.i32_const(t.alloc(u)),Et=c.i32_const(t.alloc(u)),Ot=c.i32_const(t.alloc(u)),$t=c.i32_const(t.alloc(u)),Jt=c.i32_const(t.alloc(u)),ie=c.i32_const(t.alloc(u)),ae=c.i32_const(t.alloc(u)),B=c.i32_const(t.alloc(u)),p=c.i32_const(t.alloc(u)),y=c.i32_const(t.alloc(u)),O=c.i32_const(t.alloc(u)),H=c.i32_const(t.alloc(u)),nt=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),[...c.call(e+"_copy",c.getLocal("p2"),c.getLocal("pr")),...c.ret([])]),c.if(c.call(e+"_isZero",c.getLocal("p2")),[...c.call(e+"_copy",c.getLocal("p1"),c.getLocal("pr")),...c.ret([])]),c.if(c.call(i+"_isOne",G),[...c.call(e+"_addMixed",U,E,It),...c.ret([])]),c.if(c.call(i+"_isOne",J),[...c.call(e+"_addMixed",E,U,It),...c.ret([])]),c.call(i+"_square",G,zt),c.call(i+"_square",J,xt),c.call(i+"_mul",E,xt,Mt),c.call(i+"_mul",U,zt,Gt),c.call(i+"_mul",G,zt,vt),c.call(i+"_mul",J,xt,Et),c.call(i+"_mul",d,Et,Ot),c.call(i+"_mul",b,vt,$t),c.if(c.call(i+"_eq",Mt,Gt),c.if(c.call(i+"_eq",Ot,$t),[...c.call(e+"_double",c.getLocal("p1"),c.getLocal("pr")),...c.ret([])])),c.call(i+"_sub",Gt,Mt,Jt),c.call(i+"_sub",$t,Ot,ie),c.call(i+"_add",Jt,Jt,ae),c.call(i+"_square",ae,ae),c.call(i+"_mul",Jt,ae,B),c.call(i+"_add",ie,ie,p),c.call(i+"_mul",Mt,ae,O),c.call(i+"_square",p,y),c.call(i+"_add",O,O,H),c.call(i+"_sub",y,B,It),c.call(i+"_sub",It,H,It),c.call(i+"_mul",Ot,B,nt),c.call(i+"_add",nt,nt,nt),c.call(i+"_sub",O,It,lt),c.call(i+"_mul",lt,p,lt),c.call(i+"_sub",lt,nt,lt),c.call(i+"_add",G,J,At),c.call(i+"_square",At,At),c.call(i+"_sub",At,zt,At),c.call(i+"_sub",At,xt,At),c.call(i+"_mul",At,Jt,At))}function f(){const A=t.addFunction(e+"_addMixed");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32"),A.addLocal("z1","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u));A.addCode(c.setLocal("z1",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))));const G=c.getLocal("z1"),U=c.getLocal("p2"),b=c.i32_add(c.getLocal("p2"),c.i32_const(u)),J=c.getLocal("pr"),It=c.i32_add(c.getLocal("pr"),c.i32_const(u)),lt=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),At=c.i32_const(t.alloc(u)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u)),Mt=c.i32_const(t.alloc(u)),Gt=c.i32_const(t.alloc(u)),vt=c.i32_const(t.alloc(u)),Et=c.i32_const(t.alloc(u)),Ot=c.i32_const(t.alloc(u)),$t=c.i32_const(t.alloc(u)),Jt=c.i32_const(t.alloc(u)),ie=c.i32_const(t.alloc(u)),ae=c.i32_const(t.alloc(u)),B=c.i32_const(t.alloc(u)),p=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),[...c.call(e+"_copyAffine",c.getLocal("p2"),c.getLocal("pr")),...c.call(i+"_one",c.i32_add(c.getLocal("pr"),c.i32_const(u*2))),...c.ret([])]),c.if(c.call(e+"_isZeroAffine",c.getLocal("p2")),[...c.call(e+"_copy",c.getLocal("p1"),c.getLocal("pr")),...c.ret([])]),c.if(c.call(i+"_isOne",G),[...c.call(e+"_addAffine",E,U,J),...c.ret([])]),c.call(i+"_square",G,At),c.call(i+"_mul",U,At,zt),c.call(i+"_mul",G,At,xt),c.call(i+"_mul",b,xt,Mt),c.if(c.call(i+"_eq",E,zt),c.if(c.call(i+"_eq",d,Mt),[...c.call(e+"_doubleAffine",c.getLocal("p2"),c.getLocal("pr")),...c.ret([])])),c.call(i+"_sub",zt,E,Gt),c.call(i+"_sub",Mt,d,Et),c.call(i+"_square",Gt,vt),c.call(i+"_add",vt,vt,Ot),c.call(i+"_add",Ot,Ot,Ot),c.call(i+"_mul",Gt,Ot,$t),c.call(i+"_add",Et,Et,Jt),c.call(i+"_mul",E,Ot,ae),c.call(i+"_square",Jt,ie),c.call(i+"_add",ae,ae,B),c.call(i+"_sub",ie,$t,J),c.call(i+"_sub",J,B,J),c.call(i+"_mul",d,$t,p),c.call(i+"_add",p,p,p),c.call(i+"_sub",ae,J,It),c.call(i+"_mul",It,Jt,It),c.call(i+"_sub",It,p,It),c.call(i+"_add",G,Gt,lt),c.call(i+"_square",lt,lt),c.call(i+"_sub",lt,At,lt),c.call(i+"_sub",lt,vt,lt))}function L(){const A=t.addFunction(e+"_addAffine");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32"),A.addLocal("z1","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u));A.addCode(c.setLocal("z1",c.i32_add(c.getLocal("p1"),c.i32_const(u*2))));const G=c.getLocal("p2"),U=c.i32_add(c.getLocal("p2"),c.i32_const(u)),b=c.getLocal("pr"),J=c.i32_add(c.getLocal("pr"),c.i32_const(u)),It=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u)),zt=c.i32_const(t.alloc(u)),xt=c.i32_const(t.alloc(u)),Mt=c.i32_const(t.alloc(u)),Gt=c.i32_const(t.alloc(u)),vt=c.i32_const(t.alloc(u)),Et=c.i32_const(t.alloc(u)),Ot=c.i32_const(t.alloc(u)),$t=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZeroAffine",c.getLocal("p1")),[...c.call(e+"_copyAffine",c.getLocal("p2"),c.getLocal("pr")),...c.call(i+"_one",c.i32_add(c.getLocal("pr"),c.i32_const(u*2))),...c.ret([])]),c.if(c.call(e+"_isZeroAffine",c.getLocal("p2")),[...c.call(e+"_copyAffine",c.getLocal("p1"),c.getLocal("pr")),...c.call(i+"_one",c.i32_add(c.getLocal("pr"),c.i32_const(u*2))),...c.ret([])]),c.if(c.call(i+"_eq",E,G),c.if(c.call(i+"_eq",d,U),[...c.call(e+"_doubleAffine",c.getLocal("p2"),c.getLocal("pr")),...c.ret([])])),c.call(i+"_sub",G,E,lt),c.call(i+"_sub",U,d,zt),c.call(i+"_square",lt,At),c.call(i+"_add",At,At,xt),c.call(i+"_add",xt,xt,xt),c.call(i+"_mul",lt,xt,Mt),c.call(i+"_add",zt,zt,Gt),c.call(i+"_mul",E,xt,Et),c.call(i+"_square",Gt,vt),c.call(i+"_add",Et,Et,Ot),c.call(i+"_sub",vt,Mt,b),c.call(i+"_sub",b,Ot,b),c.call(i+"_mul",d,Mt,$t),c.call(i+"_add",$t,$t,$t),c.call(i+"_sub",Et,b,J),c.call(i+"_mul",J,Gt,J),c.call(i+"_sub",J,$t,J),c.call(i+"_add",lt,lt,It))}function V(){const A=t.addFunction(e+"_neg");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.i32_add(c.getLocal("p1"),c.i32_const(u*2)),U=c.getLocal("pr"),b=c.i32_add(c.getLocal("pr"),c.i32_const(u)),J=c.i32_add(c.getLocal("pr"),c.i32_const(u*2));A.addCode(c.call(i+"_copy",E,U),c.call(i+"_neg",d,b),c.call(i+"_copy",G,J))}function X(){const A=t.addFunction(e+"_negAffine");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.getLocal("pr"),U=c.i32_add(c.getLocal("pr"),c.i32_const(u));A.addCode(c.call(i+"_copy",E,G),c.call(i+"_neg",d,U))}function et(){const A=t.addFunction(e+"_sub");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u*3));A.addCode(c.call(e+"_neg",c.getLocal("p2"),E),c.call(e+"_add",c.getLocal("p1"),E,c.getLocal("pr")))}function N(){const A=t.addFunction(e+"_subMixed");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u*3));A.addCode(c.call(e+"_negAffine",c.getLocal("p2"),E),c.call(e+"_addMixed",c.getLocal("p1"),E,c.getLocal("pr")))}function w(){const A=t.addFunction(e+"_subAffine");A.addParam("p1","i32"),A.addParam("p2","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u*3));A.addCode(c.call(e+"_negAffine",c.getLocal("p2"),E),c.call(e+"_addAffine",c.getLocal("p1"),E,c.getLocal("pr")))}function T(){const A=t.addFunction(e+"_normalize");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.i32_add(c.getLocal("p1"),c.i32_const(u*2)),U=c.getLocal("pr"),b=c.i32_add(c.getLocal("pr"),c.i32_const(u)),J=c.i32_add(c.getLocal("pr"),c.i32_const(u*2)),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u)),At=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),c.call(e+"_zero",c.getLocal("pr")),[...c.call(i+"_inverse",G,It),...c.call(i+"_square",It,lt),...c.call(i+"_mul",It,lt,At),...c.call(i+"_mul",E,lt,U),...c.call(i+"_mul",d,At,b),...c.call(i+"_one",J)]))}function at(){const A=t.addFunction(e+"_toAffine");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.i32_add(c.getLocal("p1"),c.i32_const(u*2)),U=c.getLocal("pr"),b=c.i32_add(c.getLocal("pr"),c.i32_const(u)),J=c.i32_const(t.alloc(u)),It=c.i32_const(t.alloc(u)),lt=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZero",c.getLocal("p1")),[...c.call(i+"_zero",U),...c.call(i+"_zero",b)],[...c.call(i+"_inverse",G,J),...c.call(i+"_square",J,It),...c.call(i+"_mul",J,It,lt),...c.call(i+"_mul",E,It,U),...c.call(i+"_mul",d,lt,b)]))}function Lt(){const A=t.addFunction(e+"_toJacobian");A.addParam("p1","i32"),A.addParam("pr","i32");const c=A.getCodeBuilder(),E=c.getLocal("p1"),d=c.i32_add(c.getLocal("p1"),c.i32_const(u)),G=c.getLocal("pr"),U=c.i32_add(c.getLocal("pr"),c.i32_const(u)),b=c.i32_add(c.getLocal("pr"),c.i32_const(u*2));A.addCode(c.if(c.call(e+"_isZeroAffine",c.getLocal("p1")),c.call(e+"_zero",c.getLocal("pr")),[...c.call(i+"_one",b),...c.call(i+"_copy",d,U),...c.call(i+"_copy",E,G)]))}function _t(){const A=t.addFunction(e+"_batchToAffine");A.addParam("pIn","i32"),A.addParam("n","i32"),A.addParam("pOut","i32"),A.addLocal("pAux","i32"),A.addLocal("itIn","i32"),A.addLocal("itAux","i32"),A.addLocal("itOut","i32"),A.addLocal("i","i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u));A.addCode(c.setLocal("pAux",c.i32_load(c.i32_const(0))),c.i32_store(c.i32_const(0),c.i32_add(c.getLocal("pAux"),c.i32_mul(c.getLocal("n"),c.i32_const(u)))),c.call(i+"_batchInverse",c.i32_add(c.getLocal("pIn"),c.i32_const(u*2)),c.i32_const(u*3),c.getLocal("n"),c.getLocal("pAux"),c.i32_const(u)),c.setLocal("itIn",c.getLocal("pIn")),c.setLocal("itAux",c.getLocal("pAux")),c.setLocal("itOut",c.getLocal("pOut")),c.setLocal("i",c.i32_const(0)),c.block(c.loop(c.br_if(1,c.i32_eq(c.getLocal("i"),c.getLocal("n"))),c.if(c.call(i+"_isZero",c.getLocal("itAux")),[...c.call(i+"_zero",c.getLocal("itOut")),...c.call(i+"_zero",c.i32_add(c.getLocal("itOut"),c.i32_const(u)))],[...c.call(i+"_mul",c.getLocal("itAux"),c.i32_add(c.getLocal("itIn"),c.i32_const(u)),E),...c.call(i+"_square",c.getLocal("itAux"),c.getLocal("itAux")),...c.call(i+"_mul",c.getLocal("itAux"),c.getLocal("itIn"),c.getLocal("itOut")),...c.call(i+"_mul",c.getLocal("itAux"),E,c.i32_add(c.getLocal("itOut"),c.i32_const(u)))]),c.setLocal("itIn",c.i32_add(c.getLocal("itIn"),c.i32_const(u*3))),c.setLocal("itOut",c.i32_add(c.getLocal("itOut"),c.i32_const(u*2))),c.setLocal("itAux",c.i32_add(c.getLocal("itAux"),c.i32_const(u))),c.setLocal("i",c.i32_add(c.getLocal("i"),c.i32_const(1))),c.br(0))),c.i32_store(c.i32_const(0),c.getLocal("pAux")))}function ct(){const A=t.addFunction(e+"__reverseBytes");A.addParam("pIn","i32"),A.addParam("n","i32"),A.addParam("pOut","i32"),A.addLocal("itOut","i32"),A.addLocal("itIn","i32");const c=A.getCodeBuilder();A.addCode(c.setLocal("itOut",c.i32_sub(c.i32_add(c.getLocal("pOut"),c.getLocal("n")),c.i32_const(1))),c.setLocal("itIn",c.getLocal("pIn")),c.block(c.loop(c.br_if(1,c.i32_lt_s(c.getLocal("itOut"),c.getLocal("pOut"))),c.i32_store8(c.getLocal("itOut"),c.i32_load8_u(c.getLocal("itIn"))),c.setLocal("itOut",c.i32_sub(c.getLocal("itOut"),c.i32_const(1))),c.setLocal("itIn",c.i32_add(c.getLocal("itIn"),c.i32_const(1))),c.br(0))))}function yt(){const A=t.addFunction(e+"_LEMtoC");A.addParam("pIn","i32"),A.addParam("pOut","i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u));A.addCode(c.if(c.call(e+"_isZeroAffine",c.getLocal("pIn")),[...c.call(i+"_zero",c.getLocal("pOut")),...c.i32_store8(c.getLocal("pOut"),c.i32_const(64)),...c.ret([])]),c.call(i+"_fromMontgomery",c.getLocal("pIn"),E),c.call(e+"__reverseBytes",E,c.i32_const(u),c.getLocal("pOut")),c.if(c.i32_eq(c.call(i+"_sign",c.i32_add(c.getLocal("pIn"),c.i32_const(u))),c.i32_const(-1)),c.i32_store8(c.getLocal("pOut"),c.i32_or(c.i32_load8_u(c.getLocal("pOut")),c.i32_const(128)))))}function ft(){const A=t.addFunction(e+"_LEMtoU");A.addParam("pIn","i32"),A.addParam("pOut","i32");const c=A.getCodeBuilder(),E=t.alloc(u*2),d=c.i32_const(E),G=c.i32_const(E),U=c.i32_const(E+u);A.addCode(c.if(c.call(e+"_isZeroAffine",c.getLocal("pIn")),[...c.call(e+"_zeroAffine",c.getLocal("pOut")),...c.ret([])]),c.call(e+"_fromMontgomeryAffine",c.getLocal("pIn"),d),c.call(e+"__reverseBytes",G,c.i32_const(u),c.getLocal("pOut")),c.call(e+"__reverseBytes",U,c.i32_const(u),c.i32_add(c.getLocal("pOut"),c.i32_const(u))))}function ht(){const A=t.addFunction(e+"_UtoLEM");A.addParam("pIn","i32"),A.addParam("pOut","i32");const c=A.getCodeBuilder(),E=t.alloc(u*2),d=c.i32_const(E),G=c.i32_const(E),U=c.i32_const(E+u);A.addCode(c.if(c.i32_and(c.i32_load8_u(c.getLocal("pIn")),c.i32_const(64)),[...c.call(e+"_zeroAffine",c.getLocal("pOut")),...c.ret([])]),c.call(e+"__reverseBytes",c.getLocal("pIn"),c.i32_const(u),G),c.call(e+"__reverseBytes",c.i32_add(c.getLocal("pIn"),c.i32_const(u)),c.i32_const(u),U),c.call(e+"_toMontgomeryAffine",d,c.getLocal("pOut")))}function Ft(){const A=t.addFunction(e+"_CtoLEM");A.addParam("pIn","i32"),A.addParam("pOut","i32"),A.addLocal("firstByte","i32"),A.addLocal("greatest","i32");const c=A.getCodeBuilder(),E=t.alloc(u*2),d=c.i32_const(E),G=c.i32_const(E+u);A.addCode(c.setLocal("firstByte",c.i32_load8_u(c.getLocal("pIn"))),c.if(c.i32_and(c.getLocal("firstByte"),c.i32_const(64)),[...c.call(e+"_zeroAffine",c.getLocal("pOut")),...c.ret([])]),c.setLocal("greatest",c.i32_and(c.getLocal("firstByte"),c.i32_const(128))),c.call(i+"_copy",c.getLocal("pIn"),G),c.i32_store8(G,c.i32_and(c.getLocal("firstByte"),c.i32_const(63))),c.call(e+"__reverseBytes",G,c.i32_const(u),d),c.call(i+"_toMontgomery",d,c.getLocal("pOut")),c.call(i+"_square",c.getLocal("pOut"),G),c.call(i+"_mul",c.getLocal("pOut"),G,G),c.call(i+"_add",G,c.i32_const(o),G),c.call(i+"_sqrt",G,G),c.call(i+"_neg",G,d),c.if(c.i32_eq(c.call(i+"_sign",G),c.i32_const(-1)),c.if(c.getLocal("greatest"),c.call(i+"_copy",G,c.i32_add(c.getLocal("pOut"),c.i32_const(u))),c.call(i+"_neg",G,c.i32_add(c.getLocal("pOut"),c.i32_const(u)))),c.if(c.getLocal("greatest"),c.call(i+"_neg",G,c.i32_add(c.getLocal("pOut"),c.i32_const(u))),c.call(i+"_copy",G,c.i32_add(c.getLocal("pOut"),c.i32_const(u))))))}function Nt(){const A=t.addFunction(e+"_inCurveAffine");A.addParam("pIn","i32"),A.setReturnType("i32");const c=A.getCodeBuilder(),E=c.getLocal("pIn"),d=c.i32_add(c.getLocal("pIn"),c.i32_const(u)),G=c.i32_const(t.alloc(u)),U=c.i32_const(t.alloc(u));A.addCode(c.call(i+"_square",d,G),c.call(i+"_square",E,U),c.call(i+"_mul",E,U,U),c.call(i+"_add",U,c.i32_const(o),U),c.ret(c.call(i+"_eq",G,U)))}function kt(){const A=t.addFunction(e+"_inCurve");A.addParam("pIn","i32"),A.setReturnType("i32");const c=A.getCodeBuilder(),E=c.i32_const(t.alloc(u*2));A.addCode(c.call(e+"_toAffine",c.getLocal("pIn"),E),c.ret(c.call(e+"_inCurveAffine",E)))}return I(),r(),C(),m(),s(),l(),Lt(),R(),M(),g(),F(),$(),L(),f(),v(),X(),V(),w(),N(),et(),K(),z(),it(),x(),at(),Nt(),kt(),_t(),T(),ct(),ft(),yt(),ht(),Ft(),Yn(t,e+"_batchLEMtoU",e+"_LEMtoU",u*2,u*2),Yn(t,e+"_batchLEMtoC",e+"_LEMtoC",u*2,u),Yn(t,e+"_batchUtoLEM",e+"_UtoLEM",u*2,u*2),Yn(t,e+"_batchCtoLEM",e+"_CtoLEM",u,u*2,!0),Yn(t,e+"_batchToJacobian",e+"_toJacobian",u*2,u*3,!0),za(t,e,e+"_multiexp",e+"_add",u*3),za(t,e,e+"_multiexpAffine",e+"_addMixed",u*2),Ta(t,e+"_timesScalar",u*3,e+"_add",e+"_double",e+"_sub",e+"_copy",e+"_zero"),Ta(t,e+"_timesScalarAffine",u*2,e+"_addMixed",e+"_double",e+"_subMixed",e+"_copyAffine",e+"_zero"),t.exportFunction(e+"_isZero"),t.exportFunction(e+"_isZeroAffine"),t.exportFunction(e+"_eq"),t.exportFunction(e+"_eqMixed"),t.exportFunction(e+"_eqAffine"),t.exportFunction(e+"_copy"),t.exportFunction(e+"_copyAffine"),t.exportFunction(e+"_zero"),t.exportFunction(e+"_zeroAffine"),t.exportFunction(e+"_double"),t.exportFunction(e+"_doubleAffine"),t.exportFunction(e+"_add"),t.exportFunction(e+"_addMixed"),t.exportFunction(e+"_addAffine"),t.exportFunction(e+"_neg"),t.exportFunction(e+"_negAffine"),t.exportFunction(e+"_sub"),t.exportFunction(e+"_subMixed"),t.exportFunction(e+"_subAffine"),t.exportFunction(e+"_fromMontgomery"),t.exportFunction(e+"_fromMontgomeryAffine"),t.exportFunction(e+"_toMontgomery"),t.exportFunction(e+"_toMontgomeryAffine"),t.exportFunction(e+"_timesScalar"),t.exportFunction(e+"_timesScalarAffine"),t.exportFunction(e+"_normalize"),t.exportFunction(e+"_LEMtoU"),t.exportFunction(e+"_LEMtoC"),t.exportFunction(e+"_UtoLEM"),t.exportFunction(e+"_CtoLEM"),t.exportFunction(e+"_batchLEMtoU"),t.exportFunction(e+"_batchLEMtoC"),t.exportFunction(e+"_batchUtoLEM"),t.exportFunction(e+"_batchCtoLEM"),t.exportFunction(e+"_toAffine"),t.exportFunction(e+"_toJacobian"),t.exportFunction(e+"_batchToAffine"),t.exportFunction(e+"_batchToJacobian"),t.exportFunction(e+"_inCurve"),t.exportFunction(e+"_inCurveAffine"),e};const{isOdd:Td,modInv:Ra,modPow:Vn}=Ae,Si=ln;var Ur=function(t,e,i,o,a){const r=t.modules[o].n64*8,l=t.modules[i].n64*8,s=t.modules[o].q;let m=s-1n,C=0;for(;!Td(m);)C++,m=m>>1n;let g=2n;for(;Vn(g,s>>1n,s)===1n;)g=g+1n;const M=new Array(C+1);M[C]=Vn(g,m,s);let $=C-1;for(;$>=0;)M[$]=Vn(M[$+1],2n,s),$--;const F=[],R=(1n<<BigInt(r*8))%s;for(let E=0;E<M.length;E++){const d=M[E]*R%s;F.push(...Si.bigInt2BytesLE(d,r))}const x=t.alloc(F),it=new Array(C+1);it[0]=1n;for(let E=1;E<=C;E++)it[E]=it[E-1]*2n;const z=[];for(let E=0;E<=C;E++){const d=Ra(it[E],s)*R%s;z.push(...Si.bigInt2BytesLE(d,r))}const K=t.alloc(z),v=Vn(g,2n,s),f=[],L=[];for(let E=0;E<=C;E++){const d=Vn(v,2n**BigInt(E),s),G=Ra(s+1n-d,s);f.push(...Si.bigInt2BytesLE(d*R%s,r)),L.push(...Si.bigInt2BytesLE(G*R%s,r))}const V=t.alloc(f),X=t.alloc(L);function et(E){let d=0;for(let G=0;G<8;G++)E&1<<G&&(d=d|128>>G);return d}const N=Array(256);for(let E=0;E<256;E++)N[E]=et(E);const w=t.alloc(N);function T(){const E=t.addFunction(e+"__log2");E.addParam("n","i32"),E.setReturnType("i32"),E.addLocal("bits","i32"),E.addLocal("aux","i32");const d=E.getCodeBuilder();E.addCode(d.setLocal("aux",d.i32_shr_u(d.getLocal("n"),d.i32_const(1)))),E.addCode(d.setLocal("bits",d.i32_const(0))),E.addCode(d.block(d.loop(d.br_if(1,d.i32_eqz(d.getLocal("aux"))),d.setLocal("aux",d.i32_shr_u(d.getLocal("aux"),d.i32_const(1))),d.setLocal("bits",d.i32_add(d.getLocal("bits"),d.i32_const(1))),d.br(0)))),E.addCode(d.if(d.i32_ne(d.getLocal("n"),d.i32_shl(d.i32_const(1),d.getLocal("bits"))),d.unreachable())),E.addCode(d.if(d.i32_gt_u(d.getLocal("bits"),d.i32_const(C)),d.unreachable())),E.addCode(d.getLocal("bits"))}function at(){const E=t.addFunction(e+"_fft");E.addParam("px","i32"),E.addParam("n","i32"),E.addLocal("bits","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r));E.addCode(d.setLocal("bits",d.call(e+"__log2",d.getLocal("n"))),d.call(o+"_one",G),d.call(e+"_rawfft",d.getLocal("px"),d.getLocal("bits"),d.i32_const(0),G))}function Lt(){const E=t.addFunction(e+"_ifft");E.addParam("px","i32"),E.addParam("n","i32"),E.addLocal("bits","i32"),E.addLocal("pInv2","i32");const d=E.getCodeBuilder();E.addCode(d.setLocal("bits",d.call(e+"__log2",d.getLocal("n"))),d.setLocal("pInv2",d.i32_add(d.i32_const(K),d.i32_mul(d.getLocal("bits"),d.i32_const(r)))),d.call(e+"_rawfft",d.getLocal("px"),d.getLocal("bits"),d.i32_const(1),d.getLocal("pInv2")))}function _t(){const E=t.addFunction(e+"_rawfft");E.addParam("px","i32"),E.addParam("bits","i32"),E.addParam("reverse","i32"),E.addParam("mulFactor","i32"),E.addLocal("s","i32"),E.addLocal("k","i32"),E.addLocal("j","i32"),E.addLocal("m","i32"),E.addLocal("mdiv2","i32"),E.addLocal("n","i32"),E.addLocal("pwm","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l)),b=d.i32_const(t.alloc(l));E.addCode(d.call(e+"__reversePermutation",d.getLocal("px"),d.getLocal("bits")),d.setLocal("n",d.i32_shl(d.i32_const(1),d.getLocal("bits"))),d.setLocal("s",d.i32_const(1)),d.block(d.loop(d.br_if(1,d.i32_gt_u(d.getLocal("s"),d.getLocal("bits"))),d.setLocal("m",d.i32_shl(d.i32_const(1),d.getLocal("s"))),d.setLocal("pwm",d.i32_add(d.i32_const(x),d.i32_mul(d.getLocal("s"),d.i32_const(r)))),d.setLocal("k",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_ge_u(d.getLocal("k"),d.getLocal("n"))),d.call(o+"_one",G),d.setLocal("mdiv2",d.i32_shr_u(d.getLocal("m"),d.i32_const(1))),d.setLocal("j",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_ge_u(d.getLocal("j"),d.getLocal("mdiv2"))),d.setLocal("idx1",d.i32_add(d.getLocal("px"),d.i32_mul(d.i32_add(d.getLocal("k"),d.getLocal("j")),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("idx1"),d.i32_mul(d.getLocal("mdiv2"),d.i32_const(l)))),d.call(a,d.getLocal("idx2"),G,U),d.call(i+"_copy",d.getLocal("idx1"),b),d.call(i+"_add",b,U,d.getLocal("idx1")),d.call(i+"_sub",b,U,d.getLocal("idx2")),d.call(o+"_mul",G,d.getLocal("pwm"),G),d.setLocal("j",d.i32_add(d.getLocal("j"),d.i32_const(1))),d.br(0))),d.setLocal("k",d.i32_add(d.getLocal("k"),d.getLocal("m"))),d.br(0))),d.setLocal("s",d.i32_add(d.getLocal("s"),d.i32_const(1))),d.br(0))),d.call(e+"__fftFinal",d.getLocal("px"),d.getLocal("bits"),d.getLocal("reverse"),d.getLocal("mulFactor")))}function ct(){const E=t.addFunction(e+"__fftFinal");E.addParam("px","i32"),E.addParam("bits","i32"),E.addParam("reverse","i32"),E.addParam("mulFactor","i32"),E.addLocal("n","i32"),E.addLocal("ndiv2","i32"),E.addLocal("pInv2","i32"),E.addLocal("i","i32"),E.addLocal("mask","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(l));E.addCode(d.if(d.i32_and(d.i32_eqz(d.getLocal("reverse")),d.call(o+"_isOne",d.getLocal("mulFactor"))),d.ret([])),d.setLocal("n",d.i32_shl(d.i32_const(1),d.getLocal("bits"))),d.setLocal("mask",d.i32_sub(d.getLocal("n"),d.i32_const(1))),d.setLocal("i",d.i32_const(1)),d.setLocal("ndiv2",d.i32_shr_u(d.getLocal("n"),d.i32_const(1))),d.block(d.loop(d.br_if(1,d.i32_ge_u(d.getLocal("i"),d.getLocal("ndiv2"))),d.setLocal("idx1",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("px"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.getLocal("i")),d.i32_const(l)))),d.if(d.getLocal("reverse"),d.if(d.call(o+"_isOne",d.getLocal("mulFactor")),[...d.call(i+"_copy",d.getLocal("idx1"),G),...d.call(i+"_copy",d.getLocal("idx2"),d.getLocal("idx1")),...d.call(i+"_copy",G,d.getLocal("idx2"))],[...d.call(i+"_copy",d.getLocal("idx1"),G),...d.call(a,d.getLocal("idx2"),d.getLocal("mulFactor"),d.getLocal("idx1")),...d.call(a,G,d.getLocal("mulFactor"),d.getLocal("idx2"))]),d.if(d.call(o+"_isOne",d.getLocal("mulFactor")),[],[...d.call(a,d.getLocal("idx1"),d.getLocal("mulFactor"),d.getLocal("idx1")),...d.call(a,d.getLocal("idx2"),d.getLocal("mulFactor"),d.getLocal("idx2"))])),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))),d.if(d.call(o+"_isOne",d.getLocal("mulFactor")),[],[...d.call(a,d.getLocal("px"),d.getLocal("mulFactor"),d.getLocal("px")),...d.setLocal("idx2",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("ndiv2"),d.i32_const(l)))),...d.call(a,d.getLocal("idx2"),d.getLocal("mulFactor"),d.getLocal("idx2"))]))}function yt(){const E=t.addFunction(e+"__reversePermutation");E.addParam("px","i32"),E.addParam("bits","i32"),E.addLocal("n","i32"),E.addLocal("i","i32"),E.addLocal("ri","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(l));E.addCode(d.setLocal("n",d.i32_shl(d.i32_const(1),d.getLocal("bits"))),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("ri",d.call(e+"__rev",d.getLocal("i"),d.getLocal("bits"))),d.setLocal("idx2",d.i32_add(d.getLocal("px"),d.i32_mul(d.getLocal("ri"),d.i32_const(l)))),d.if(d.i32_lt_u(d.getLocal("i"),d.getLocal("ri")),[...d.call(i+"_copy",d.getLocal("idx1"),G),...d.call(i+"_copy",d.getLocal("idx2"),d.getLocal("idx1")),...d.call(i+"_copy",G,d.getLocal("idx2"))]),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function ft(){const E=t.addFunction(e+"__rev");E.addParam("x","i32"),E.addParam("bits","i32"),E.setReturnType("i32");const d=E.getCodeBuilder();E.addCode(d.i32_rotl(d.i32_add(d.i32_add(d.i32_shl(d.i32_load8_u(d.i32_and(d.getLocal("x"),d.i32_const(255)),w,0),d.i32_const(24)),d.i32_shl(d.i32_load8_u(d.i32_and(d.i32_shr_u(d.getLocal("x"),d.i32_const(8)),d.i32_const(255)),w,0),d.i32_const(16))),d.i32_add(d.i32_shl(d.i32_load8_u(d.i32_and(d.i32_shr_u(d.getLocal("x"),d.i32_const(16)),d.i32_const(255)),w,0),d.i32_const(8)),d.i32_load8_u(d.i32_and(d.i32_shr_u(d.getLocal("x"),d.i32_const(24)),d.i32_const(255)),w,0))),d.getLocal("bits")))}function ht(){const E=t.addFunction(e+"_fftJoin");E.addParam("pBuff1","i32"),E.addParam("pBuff2","i32"),E.addParam("n","i32"),E.addParam("first","i32"),E.addParam("inc","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l)),b=d.i32_const(t.alloc(l));E.addCode(d.call(o+"_copy",d.getLocal("first"),G),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff1"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("pBuff2"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.call(a,d.getLocal("idx2"),G,U),d.call(i+"_copy",d.getLocal("idx1"),b),d.call(i+"_add",b,U,d.getLocal("idx1")),d.call(i+"_sub",b,U,d.getLocal("idx2")),d.call(o+"_mul",G,d.getLocal("inc"),G),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function Ft(){const E=t.addFunction(e+"_fftJoinExt");E.addParam("pBuff1","i32"),E.addParam("pBuff2","i32"),E.addParam("n","i32"),E.addParam("first","i32"),E.addParam("inc","i32"),E.addParam("totalBits","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32"),E.addLocal("pShiftToM","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l));E.addCode(d.setLocal("pShiftToM",d.i32_add(d.i32_const(V),d.i32_mul(d.getLocal("totalBits"),d.i32_const(r)))),d.call(o+"_copy",d.getLocal("first"),G),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff1"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("pBuff2"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.call(i+"_add",d.getLocal("idx1"),d.getLocal("idx2"),U),d.call(a,d.getLocal("idx2"),d.getLocal("pShiftToM"),d.getLocal("idx2")),d.call(i+"_add",d.getLocal("idx1"),d.getLocal("idx2"),d.getLocal("idx2")),d.call(a,d.getLocal("idx2"),G,d.getLocal("idx2")),d.call(i+"_copy",U,d.getLocal("idx1")),d.call(o+"_mul",G,d.getLocal("inc"),G),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function Nt(){const E=t.addFunction(e+"_fftJoinExtInv");E.addParam("pBuff1","i32"),E.addParam("pBuff2","i32"),E.addParam("n","i32"),E.addParam("first","i32"),E.addParam("inc","i32"),E.addParam("totalBits","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32"),E.addLocal("pShiftToM","i32"),E.addLocal("pSConst","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l));E.addCode(d.setLocal("pShiftToM",d.i32_add(d.i32_const(V),d.i32_mul(d.getLocal("totalBits"),d.i32_const(r)))),d.setLocal("pSConst",d.i32_add(d.i32_const(X),d.i32_mul(d.getLocal("totalBits"),d.i32_const(r)))),d.call(o+"_copy",d.getLocal("first"),G),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff1"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("pBuff2"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.call(a,d.getLocal("idx2"),G,U),d.call(i+"_sub",d.getLocal("idx1"),U,d.getLocal("idx2")),d.call(a,d.getLocal("idx2"),d.getLocal("pSConst"),d.getLocal("idx2")),d.call(a,d.getLocal("idx1"),d.getLocal("pShiftToM"),d.getLocal("idx1")),d.call(i+"_sub",U,d.getLocal("idx1"),d.getLocal("idx1")),d.call(a,d.getLocal("idx1"),d.getLocal("pSConst"),d.getLocal("idx1")),d.call(o+"_mul",G,d.getLocal("inc"),G),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function kt(){const E=t.addFunction(e+"_prepareLagrangeEvaluation");E.addParam("pBuff1","i32"),E.addParam("pBuff2","i32"),E.addParam("n","i32"),E.addParam("first","i32"),E.addParam("inc","i32"),E.addParam("totalBits","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32"),E.addLocal("pShiftToM","i32"),E.addLocal("pSConst","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l));E.addCode(d.setLocal("pShiftToM",d.i32_add(d.i32_const(V),d.i32_mul(d.getLocal("totalBits"),d.i32_const(r)))),d.setLocal("pSConst",d.i32_add(d.i32_const(X),d.i32_mul(d.getLocal("totalBits"),d.i32_const(r)))),d.call(o+"_copy",d.getLocal("first"),G),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("n"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff1"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("pBuff2"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.call(a,d.getLocal("idx1"),d.getLocal("pShiftToM"),U),d.call(i+"_sub",d.getLocal("idx2"),U,U),d.call(i+"_sub",d.getLocal("idx1"),d.getLocal("idx2"),d.getLocal("idx2")),d.call(a,U,d.getLocal("pSConst"),d.getLocal("idx1")),d.call(a,d.getLocal("idx2"),G,d.getLocal("idx2")),d.call(o+"_mul",G,d.getLocal("inc"),G),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function A(){const E=t.addFunction(e+"_fftMix");E.addParam("pBuff","i32"),E.addParam("n","i32"),E.addParam("exp","i32"),E.addLocal("nGroups","i32"),E.addLocal("nPerGroup","i32"),E.addLocal("nPerGroupDiv2","i32"),E.addLocal("pairOffset","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32"),E.addLocal("j","i32"),E.addLocal("pwm","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(r)),U=d.i32_const(t.alloc(l)),b=d.i32_const(t.alloc(l));E.addCode(d.setLocal("nPerGroup",d.i32_shl(d.i32_const(1),d.getLocal("exp"))),d.setLocal("nPerGroupDiv2",d.i32_shr_u(d.getLocal("nPerGroup"),d.i32_const(1))),d.setLocal("nGroups",d.i32_shr_u(d.getLocal("n"),d.getLocal("exp"))),d.setLocal("pairOffset",d.i32_mul(d.getLocal("nPerGroupDiv2"),d.i32_const(l))),d.setLocal("pwm",d.i32_add(d.i32_const(x),d.i32_mul(d.getLocal("exp"),d.i32_const(r)))),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("i"),d.getLocal("nGroups"))),d.call(o+"_one",G),d.setLocal("j",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_eq(d.getLocal("j"),d.getLocal("nPerGroupDiv2"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff"),d.i32_mul(d.i32_add(d.i32_mul(d.getLocal("i"),d.getLocal("nPerGroup")),d.getLocal("j")),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("idx1"),d.getLocal("pairOffset"))),d.call(a,d.getLocal("idx2"),G,U),d.call(i+"_copy",d.getLocal("idx1"),b),d.call(i+"_add",b,U,d.getLocal("idx1")),d.call(i+"_sub",b,U,d.getLocal("idx2")),d.call(o+"_mul",G,d.getLocal("pwm"),G),d.setLocal("j",d.i32_add(d.getLocal("j"),d.i32_const(1))),d.br(0))),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}function c(){const E=t.addFunction(e+"_fftFinal");E.addParam("pBuff","i32"),E.addParam("n","i32"),E.addParam("factor","i32"),E.addLocal("idx1","i32"),E.addLocal("idx2","i32"),E.addLocal("i","i32"),E.addLocal("ndiv2","i32");const d=E.getCodeBuilder(),G=d.i32_const(t.alloc(l));E.addCode(d.setLocal("ndiv2",d.i32_shr_u(d.getLocal("n"),d.i32_const(1))),d.if(d.i32_and(d.getLocal("n"),d.i32_const(1)),d.call(a,d.i32_add(d.getLocal("pBuff"),d.i32_mul(d.getLocal("ndiv2"),d.i32_const(l))),d.getLocal("factor"),d.i32_add(d.getLocal("pBuff"),d.i32_mul(d.getLocal("ndiv2"),d.i32_const(l))))),d.setLocal("i",d.i32_const(0)),d.block(d.loop(d.br_if(1,d.i32_ge_u(d.getLocal("i"),d.getLocal("ndiv2"))),d.setLocal("idx1",d.i32_add(d.getLocal("pBuff"),d.i32_mul(d.getLocal("i"),d.i32_const(l)))),d.setLocal("idx2",d.i32_add(d.getLocal("pBuff"),d.i32_mul(d.i32_sub(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.getLocal("i")),d.i32_const(l)))),d.call(a,d.getLocal("idx2"),d.getLocal("factor"),G),d.call(a,d.getLocal("idx1"),d.getLocal("factor"),d.getLocal("idx2")),d.call(i+"_copy",G,d.getLocal("idx1")),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}ft(),yt(),ct(),_t(),T(),at(),Lt(),ht(),Ft(),Nt(),A(),c(),kt(),t.exportFunction(e+"_fft"),t.exportFunction(e+"_ifft"),t.exportFunction(e+"_rawfft"),t.exportFunction(e+"_fftJoin"),t.exportFunction(e+"_fftJoinExt"),t.exportFunction(e+"_fftJoinExtInv"),t.exportFunction(e+"_fftMix"),t.exportFunction(e+"_fftFinal"),t.exportFunction(e+"_prepareLagrangeEvaluation")},Pr=function(t,e,i){const a=t.modules[i].n64*8;function u(){const I=t.addFunction(e+"_zero");I.addParam("px","i32"),I.addParam("n","i32"),I.addLocal("lastp","i32"),I.addLocal("p","i32");const l=I.getCodeBuilder();I.addCode(l.setLocal("p",l.getLocal("px")),l.setLocal("lastp",l.i32_add(l.getLocal("px"),l.i32_mul(l.getLocal("n"),l.i32_const(a)))),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal("p"),l.getLocal("lastp"))),l.call(i+"_zero",l.getLocal("p")),l.setLocal("p",l.i32_add(l.getLocal("p"),l.i32_const(a))),l.br(0))))}function r(){const I=t.addFunction(e+"_constructLC");I.addParam("ppolynomials","i32"),I.addParam("psignals","i32"),I.addParam("nSignals","i32"),I.addParam("pres","i32"),I.addLocal("i","i32"),I.addLocal("j","i32"),I.addLocal("pp","i32"),I.addLocal("ps","i32"),I.addLocal("pd","i32"),I.addLocal("ncoefs","i32");const l=I.getCodeBuilder(),s=l.i32_const(t.alloc(a));I.addCode(l.setLocal("i",l.i32_const(0)),l.setLocal("pp",l.getLocal("ppolynomials")),l.setLocal("ps",l.getLocal("psignals")),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal("i"),l.getLocal("nSignals"))),l.setLocal("ncoefs",l.i32_load(l.getLocal("pp"))),l.setLocal("pp",l.i32_add(l.getLocal("pp"),l.i32_const(4))),l.setLocal("j",l.i32_const(0)),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal("j"),l.getLocal("ncoefs"))),l.setLocal("pd",l.i32_add(l.getLocal("pres"),l.i32_mul(l.i32_load(l.getLocal("pp")),l.i32_const(a)))),l.setLocal("pp",l.i32_add(l.getLocal("pp"),l.i32_const(4))),l.call(i+"_mul",l.getLocal("ps"),l.getLocal("pp"),s),l.call(i+"_add",s,l.getLocal("pd"),l.getLocal("pd")),l.setLocal("pp",l.i32_add(l.getLocal("pp"),l.i32_const(a))),l.setLocal("j",l.i32_add(l.getLocal("j"),l.i32_const(1))),l.br(0))),l.setLocal("ps",l.i32_add(l.getLocal("ps"),l.i32_const(a))),l.setLocal("i",l.i32_add(l.getLocal("i"),l.i32_const(1))),l.br(0))))}return u(),r(),t.exportFunction(e+"_zero"),t.exportFunction(e+"_constructLC"),e},Mr=function(t,e,i){const a=t.modules[i].n64*8;function u(){const l=t.addFunction(e+"_buildABC");l.addParam("pCoefs","i32"),l.addParam("nCoefs","i32"),l.addParam("pWitness","i32"),l.addParam("pA","i32"),l.addParam("pB","i32"),l.addParam("pC","i32"),l.addParam("offsetOut","i32"),l.addParam("nOut","i32"),l.addParam("offsetWitness","i32"),l.addParam("nWitness","i32"),l.addLocal("it","i32"),l.addLocal("ita","i32"),l.addLocal("itb","i32"),l.addLocal("last","i32"),l.addLocal("m","i32"),l.addLocal("c","i32"),l.addLocal("s","i32"),l.addLocal("pOut","i32");const s=l.getCodeBuilder(),m=s.i32_const(t.alloc(a));l.addCode(s.setLocal("ita",s.getLocal("pA")),s.setLocal("itb",s.getLocal("pB")),s.setLocal("last",s.i32_add(s.getLocal("pA"),s.i32_mul(s.getLocal("nOut"),s.i32_const(a)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("ita"),s.getLocal("last"))),s.call(i+"_zero",s.getLocal("ita")),s.call(i+"_zero",s.getLocal("itb")),s.setLocal("ita",s.i32_add(s.getLocal("ita"),s.i32_const(a))),s.setLocal("itb",s.i32_add(s.getLocal("itb"),s.i32_const(a))),s.br(0))),s.setLocal("it",s.getLocal("pCoefs")),s.setLocal("last",s.i32_add(s.getLocal("pCoefs"),s.i32_mul(s.getLocal("nCoefs"),s.i32_const(a+12)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("it"),s.getLocal("last"))),s.setLocal("s",s.i32_load(s.getLocal("it"),8)),s.if(s.i32_or(s.i32_lt_u(s.getLocal("s"),s.getLocal("offsetWitness")),s.i32_ge_u(s.getLocal("s"),s.i32_add(s.getLocal("offsetWitness"),s.getLocal("nWitness")))),[...s.setLocal("it",s.i32_add(s.getLocal("it"),s.i32_const(a+12))),...s.br(1)]),s.setLocal("m",s.i32_load(s.getLocal("it"))),s.if(s.i32_eq(s.getLocal("m"),s.i32_const(0)),s.setLocal("pOut",s.getLocal("pA")),s.if(s.i32_eq(s.getLocal("m"),s.i32_const(1)),s.setLocal("pOut",s.getLocal("pB")),[...s.setLocal("it",s.i32_add(s.getLocal("it"),s.i32_const(a+12))),...s.br(1)])),s.setLocal("c",s.i32_load(s.getLocal("it"),4)),s.if(s.i32_or(s.i32_lt_u(s.getLocal("c"),s.getLocal("offsetOut")),s.i32_ge_u(s.getLocal("c"),s.i32_add(s.getLocal("offsetOut"),s.getLocal("nOut")))),[...s.setLocal("it",s.i32_add(s.getLocal("it"),s.i32_const(a+12))),...s.br(1)]),s.setLocal("pOut",s.i32_add(s.getLocal("pOut"),s.i32_mul(s.i32_sub(s.getLocal("c"),s.getLocal("offsetOut")),s.i32_const(a)))),s.call(i+"_mul",s.i32_add(s.getLocal("pWitness"),s.i32_mul(s.i32_sub(s.getLocal("s"),s.getLocal("offsetWitness")),s.i32_const(a))),s.i32_add(s.getLocal("it"),s.i32_const(12)),m),s.call(i+"_add",s.getLocal("pOut"),m,s.getLocal("pOut")),s.setLocal("it",s.i32_add(s.getLocal("it"),s.i32_const(a+12))),s.br(0))),s.setLocal("ita",s.getLocal("pA")),s.setLocal("itb",s.getLocal("pB")),s.setLocal("it",s.getLocal("pC")),s.setLocal("last",s.i32_add(s.getLocal("pA"),s.i32_mul(s.getLocal("nOut"),s.i32_const(a)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("ita"),s.getLocal("last"))),s.call(i+"_mul",s.getLocal("ita"),s.getLocal("itb"),s.getLocal("it")),s.setLocal("ita",s.i32_add(s.getLocal("ita"),s.i32_const(a))),s.setLocal("itb",s.i32_add(s.getLocal("itb"),s.i32_const(a))),s.setLocal("it",s.i32_add(s.getLocal("it"),s.i32_const(a))),s.br(0))))}function r(){const l=t.addFunction(e+"_joinABC");l.addParam("pA","i32"),l.addParam("pB","i32"),l.addParam("pC","i32"),l.addParam("n","i32"),l.addParam("pP","i32"),l.addLocal("ita","i32"),l.addLocal("itb","i32"),l.addLocal("itc","i32"),l.addLocal("itp","i32"),l.addLocal("last","i32");const s=l.getCodeBuilder(),m=s.i32_const(t.alloc(a));l.addCode(s.setLocal("ita",s.getLocal("pA")),s.setLocal("itb",s.getLocal("pB")),s.setLocal("itc",s.getLocal("pC")),s.setLocal("itp",s.getLocal("pP")),s.setLocal("last",s.i32_add(s.getLocal("pA"),s.i32_mul(s.getLocal("n"),s.i32_const(a)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("ita"),s.getLocal("last"))),s.call(i+"_mul",s.getLocal("ita"),s.getLocal("itb"),m),s.call(i+"_sub",m,s.getLocal("itc"),s.getLocal("itp")),s.setLocal("ita",s.i32_add(s.getLocal("ita"),s.i32_const(a))),s.setLocal("itb",s.i32_add(s.getLocal("itb"),s.i32_const(a))),s.setLocal("itc",s.i32_add(s.getLocal("itc"),s.i32_const(a))),s.setLocal("itp",s.i32_add(s.getLocal("itp"),s.i32_const(a))),s.br(0))))}function I(){const l=t.addFunction(e+"_batchAdd");l.addParam("pa","i32"),l.addParam("pb","i32"),l.addParam("n","i32"),l.addParam("pr","i32"),l.addLocal("ita","i32"),l.addLocal("itb","i32"),l.addLocal("itr","i32"),l.addLocal("last","i32");const s=l.getCodeBuilder();l.addCode(s.setLocal("ita",s.getLocal("pa")),s.setLocal("itb",s.getLocal("pb")),s.setLocal("itr",s.getLocal("pr")),s.setLocal("last",s.i32_add(s.getLocal("pa"),s.i32_mul(s.getLocal("n"),s.i32_const(a)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("ita"),s.getLocal("last"))),s.call(i+"_add",s.getLocal("ita"),s.getLocal("itb"),s.getLocal("itr")),s.setLocal("ita",s.i32_add(s.getLocal("ita"),s.i32_const(a))),s.setLocal("itb",s.i32_add(s.getLocal("itb"),s.i32_const(a))),s.setLocal("itr",s.i32_add(s.getLocal("itr"),s.i32_const(a))),s.br(0))))}return u(),r(),I(),t.exportFunction(e+"_buildABC"),t.exportFunction(e+"_joinABC"),t.exportFunction(e+"_batchAdd"),e},kr=function(t,e,i,o,a,u,r,I){const l=t.addFunction(e);l.addParam("pIn","i32"),l.addParam("n","i32"),l.addParam("pFirst","i32"),l.addParam("pInc","i32"),l.addParam("pOut","i32"),l.addLocal("pOldFree","i32"),l.addLocal("i","i32"),l.addLocal("pFrom","i32"),l.addLocal("pTo","i32");const s=l.getCodeBuilder(),m=s.i32_const(t.alloc(r));l.addCode(s.setLocal("pFrom",s.getLocal("pIn")),s.setLocal("pTo",s.getLocal("pOut"))),l.addCode(s.call(o+"_copy",s.getLocal("pFirst"),m)),l.addCode(s.setLocal("i",s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal("i"),s.getLocal("n"))),s.call(I,s.getLocal("pFrom"),m,s.getLocal("pTo")),s.setLocal("pFrom",s.i32_add(s.getLocal("pFrom"),s.i32_const(a))),s.setLocal("pTo",s.i32_add(s.getLocal("pTo"),s.i32_const(u))),s.call(o+"_mul",m,s.getLocal("pInc"),m),s.setLocal("i",s.i32_add(s.getLocal("i"),s.i32_const(1))),s.br(0)))),t.exportFunction(e)};const Zt=ln,zd=fa,Rd=Fr,Qa=vr,Qd=Sr,Da=Or,_o=Ur,Dd=Pr,qd=Mr,jn=kr,{bitLength:Nd,modInv:Gd,isOdd:qa,isNegative:$d}=Ae;var Kd=function(t,e){const i=e||"bn128";if(t.modules[i])return i;const o=21888242871839275222246405745257275088696311157297823662689037894645226208583n,a=21888242871839275222246405745257275088548364400416034343698204186575808495617n,u=Math.floor((Nd(o-1n)-1)/64)+1,r=u*8,I=r,l=r,s=l*2,m=l*12,C=t.alloc(Zt.bigInt2BytesLE(a,I)),g=zd(t,o,"f1m");Rd(t,a,"fr","frm");const M=t.alloc(Zt.bigInt2BytesLE(z(3n),l)),$=Da(t,"g1m","f1m",M);_o(t,"frm","frm","frm","frm_mul"),Dd(t,"pol","frm"),qd(t,"qap","frm");const F=Qa(t,"f1m_neg","f2m","f1m"),R=t.alloc([...Zt.bigInt2BytesLE(z(19485874751759354771024239261021720505790618469301721065564631296452457478373n),l),...Zt.bigInt2BytesLE(z(266929791119991161246907387137283842545076965332900288569378510910307636690n),l)]),x=Da(t,"g2m","f2m",R);function it(k,_){const h=t.addFunction(k);h.addParam("pG","i32"),h.addParam("pFr","i32"),h.addParam("pr","i32");const D=h.getCodeBuilder(),Z=D.i32_const(t.alloc(r));h.addCode(D.call("frm_fromMontgomery",D.getLocal("pFr"),Z),D.call(_,D.getLocal("pG"),Z,D.i32_const(r),D.getLocal("pr"))),t.exportFunction(k)}it("g1m_timesFr","g1m_timesScalar"),_o(t,"g1m","g1m","frm","g1m_timesFr"),it("g2m_timesFr","g2m_timesScalar"),_o(t,"g2m","g2m","frm","g2m_timesFr"),it("g1m_timesFrAffine","g1m_timesScalarAffine"),it("g2m_timesFrAffine","g2m_timesScalarAffine"),jn(t,"frm_batchApplyKey","fmr","frm",r,r,r,"frm_mul"),jn(t,"g1m_batchApplyKey","g1m","frm",r*3,r*3,r,"g1m_timesFr"),jn(t,"g1m_batchApplyKeyMixed","g1m","frm",r*2,r*3,r,"g1m_timesFrAffine"),jn(t,"g2m_batchApplyKey","g2m","frm",r*2*3,r*3*2,r,"g2m_timesFr"),jn(t,"g2m_batchApplyKeyMixed","g2m","frm",r*2*2,r*3*2,r,"g2m_timesFrAffine");function z(k){return BigInt(k)*(1n<<BigInt(l*8))%o}const K=[1n,2n,1n],v=t.alloc([...Zt.bigInt2BytesLE(z(K[0]),l),...Zt.bigInt2BytesLE(z(K[1]),l),...Zt.bigInt2BytesLE(z(K[2]),l)]),f=[0n,1n,0n],L=t.alloc([...Zt.bigInt2BytesLE(z(f[0]),l),...Zt.bigInt2BytesLE(z(f[1]),l),...Zt.bigInt2BytesLE(z(f[2]),l)]),V=[[10857046999023057135944570762232829481370756359578518086990519993285655852781n,11559732032986387107991004021392285783925812861821192530917403151452391805634n],[8495653923123431417604973247489272438418190587263600148770280649306958101930n,4082367875863433681332203403145435568316851327593401208105741076214120093531n],[1n,0n]],X=t.alloc([...Zt.bigInt2BytesLE(z(V[0][0]),l),...Zt.bigInt2BytesLE(z(V[0][1]),l),...Zt.bigInt2BytesLE(z(V[1][0]),l),...Zt.bigInt2BytesLE(z(V[1][1]),l),...Zt.bigInt2BytesLE(z(V[2][0]),l),...Zt.bigInt2BytesLE(z(V[2][1]),l)]),et=[[0n,0n],[1n,0n],[0n,0n]],N=t.alloc([...Zt.bigInt2BytesLE(z(et[0][0]),l),...Zt.bigInt2BytesLE(z(et[0][1]),l),...Zt.bigInt2BytesLE(z(et[1][0]),l),...Zt.bigInt2BytesLE(z(et[1][1]),l),...Zt.bigInt2BytesLE(z(et[2][0]),l),...Zt.bigInt2BytesLE(z(et[2][1]),l)]),w=t.alloc([...Zt.bigInt2BytesLE(z(1),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l),...Zt.bigInt2BytesLE(z(0),l)]),T=t.alloc([...Zt.bigInt2BytesLE(z(9),l),...Zt.bigInt2BytesLE(z(1),l)]),at=t.alloc([...Zt.bigInt2BytesLE(z(Gd(2n,o)),l),...Zt.bigInt2BytesLE(0n,l)]),Lt=T,_t=t.alloc([...Zt.bigInt2BytesLE(z(19485874751759354771024239261021720505790618469301721065564631296452457478373n),l),...Zt.bigInt2BytesLE(z(266929791119991161246907387137283842545076965332900288569378510910307636690n),l)]);function ct(){const k=t.addFunction(i+"_mulNR6");k.addParam("x","i32"),k.addParam("pr","i32");const _=k.getCodeBuilder();k.addCode(_.call(F+"_mul",_.i32_const(T),_.getLocal("x"),_.getLocal("pr")))}ct();const yt=Qd(t,i+"_mulNR6","f6m","f2m");function ft(){const k=t.addFunction(i+"_mulNR12");k.addParam("x","i32"),k.addParam("pr","i32");const _=k.getCodeBuilder();k.addCode(_.call(F+"_mul",_.i32_const(T),_.i32_add(_.getLocal("x"),_.i32_const(r*4)),_.getLocal("pr")),_.call(F+"_copy",_.getLocal("x"),_.i32_add(_.getLocal("pr"),_.i32_const(r*2))),_.call(F+"_copy",_.i32_add(_.getLocal("x"),_.i32_const(r*2)),_.i32_add(_.getLocal("pr"),_.i32_const(r*4))))}ft();const ht=Qa(t,i+"_mulNR12","ftm",yt),Nt=It(29793968203157093288n),kt=t.alloc(Nt),A=3*s,c=Nt.length-1,d=Nt.reduce((k,_)=>k+(_!=0?1:0),0)+c+1,G=3*2*r,U=3*r*2+d*A;t.modules[i]={n64:u,pG1gen:v,pG1zero:L,pG1b:M,pG2gen:X,pG2zero:N,pG2b:R,pq:t.modules.f1m.pq,pr:C,pOneT:w,prePSize:G,preQSize:U,r:a.toString(),q:o.toString()};const b=4965661367192848881n;function J(k){let _=k;const h=[];for(;_>0n;){if(qa(_)){const D=2-Number(_%4n);h.push(D),_=_-BigInt(D)}else h.push(0);_=_>>1n}return h}function It(k){let _=k;const h=[];for(;_>0n;)qa(_)?h.push(1):h.push(0),_=_>>1n;return h}function lt(){const k=t.addFunction(i+"_prepareG1");k.addParam("pP","i32"),k.addParam("ppreP","i32");const _=k.getCodeBuilder();k.addCode(_.call($+"_normalize",_.getLocal("pP"),_.getLocal("ppreP")))}function At(){const k=t.addFunction(i+"_prepAddStep");k.addParam("pQ","i32"),k.addParam("pR","i32"),k.addParam("pCoef","i32");const _=k.getCodeBuilder(),h=_.getLocal("pQ"),D=_.i32_add(_.getLocal("pQ"),_.i32_const(s)),Z=_.getLocal("pR"),Q=_.i32_add(_.getLocal("pR"),_.i32_const(s)),ot=_.i32_add(_.getLocal("pR"),_.i32_const(2*s)),W=_.getLocal("pCoef"),st=_.i32_add(_.getLocal("pCoef"),_.i32_const(s)),ut=_.i32_add(_.getLocal("pCoef"),_.i32_const(2*s)),dt=st,rt=_.i32_const(t.alloc(s)),pt=_.i32_const(t.alloc(s)),Ut=_.i32_const(t.alloc(s)),St=_.i32_const(t.alloc(s)),wt=_.i32_const(t.alloc(s)),Rt=_.i32_const(t.alloc(s)),Dt=_.i32_const(t.alloc(s));k.addCode(_.call(F+"_mul",h,ot,dt),_.call(F+"_sub",Z,dt,dt),_.call(F+"_mul",D,ot,rt),_.call(F+"_sub",Q,rt,rt),_.call(F+"_square",dt,pt),_.call(F+"_square",rt,Ut),_.call(F+"_mul",dt,pt,St),_.call(F+"_mul",Z,pt,wt),_.call(F+"_add",wt,wt,Dt),_.call(F+"_mul",ot,Ut,Rt),_.call(F+"_add",St,Rt,Rt),_.call(F+"_sub",Rt,Dt,Rt),_.call(F+"_mul",dt,Rt,Z),_.call(F+"_mul",St,Q,Q),_.call(F+"_sub",wt,Rt,Dt),_.call(F+"_mul",rt,Dt,Dt),_.call(F+"_sub",Dt,Q,Q),_.call(F+"_mul",ot,St,ot),_.call(F+"_mul",dt,D,Dt),_.call(F+"_mul",rt,h,W),_.call(F+"_sub",W,Dt,W),_.call(F+"_mul",W,_.i32_const(Lt),W),_.call(F+"_neg",rt,ut))}function zt(){const k=t.addFunction(i+"_prepDblStep");k.addParam("pR","i32"),k.addParam("pCoef","i32");const _=k.getCodeBuilder(),h=_.getLocal("pR"),D=_.i32_add(_.getLocal("pR"),_.i32_const(s)),Z=_.i32_add(_.getLocal("pR"),_.i32_const(2*s)),Q=_.getLocal("pCoef"),ot=_.i32_add(_.getLocal("pCoef"),_.i32_const(s)),W=_.i32_add(_.getLocal("pCoef"),_.i32_const(2*s)),st=_.i32_const(t.alloc(s)),ut=_.i32_const(t.alloc(s)),dt=_.i32_const(t.alloc(s)),rt=_.i32_const(t.alloc(s)),pt=_.i32_const(t.alloc(s)),Ut=_.i32_const(t.alloc(s)),St=_.i32_const(t.alloc(s)),wt=_.i32_const(t.alloc(s)),Rt=_.i32_const(t.alloc(s)),Dt=_.i32_const(t.alloc(s)),Yt=_.i32_const(t.alloc(s)),Qt=_.i32_const(t.alloc(s));k.addCode(_.call(F+"_mul",D,_.i32_const(at),st),_.call(F+"_mul",h,st,st),_.call(F+"_square",D,ut),_.call(F+"_square",Z,dt),_.call(F+"_add",dt,dt,rt),_.call(F+"_add",rt,dt,rt),_.call(F+"_mul",_.i32_const(_t),rt,pt),_.call(F+"_add",pt,pt,Ut),_.call(F+"_add",pt,Ut,Ut),_.call(F+"_add",ut,Ut,St),_.call(F+"_mul",St,_.i32_const(at),St),_.call(F+"_add",ut,dt,Qt),_.call(F+"_add",D,Z,wt),_.call(F+"_square",wt,wt),_.call(F+"_sub",wt,Qt,wt),_.call(F+"_sub",pt,ut,Rt),_.call(F+"_square",h,Dt),_.call(F+"_square",pt,Yt),_.call(F+"_sub",ut,Ut,Qt),_.call(F+"_mul",st,Qt,h),_.call(F+"_add",Yt,Yt,Qt),_.call(F+"_add",Yt,Qt,Qt),_.call(F+"_square",St,D),_.call(F+"_sub",D,Qt,D),_.call(F+"_mul",ut,wt,Z),_.call(F+"_mul",_.i32_const(Lt),Rt,Q),_.call(F+"_neg",wt,ot),_.call(F+"_add",Dt,Dt,W),_.call(F+"_add",Dt,W,W))}function xt(){const k=t.addFunction(i+"_mulByQ");k.addParam("p1","i32"),k.addParam("pr","i32");const _=k.getCodeBuilder(),h=_.getLocal("p1"),D=_.i32_add(_.getLocal("p1"),_.i32_const(s)),Z=_.i32_add(_.getLocal("p1"),_.i32_const(s*2)),Q=_.getLocal("pr"),ot=_.i32_add(_.getLocal("pr"),_.i32_const(s)),W=_.i32_add(_.getLocal("pr"),_.i32_const(s*2)),st=_.i32_const(t.alloc([...Zt.bigInt2BytesLE(z("21575463638280843010398324269430826099269044274347216827212613867836435027261"),l),...Zt.bigInt2BytesLE(z("10307601595873709700152284273816112264069230130616436755625194854815875713954"),l)])),ut=_.i32_const(t.alloc([...Zt.bigInt2BytesLE(z("2821565182194536844548159561693502659359617185244120367078079554186484126554"),l),...Zt.bigInt2BytesLE(z("3505843767911556378687030309984248845540243509899259641013678093033130930403"),l)]));k.addCode(_.call(F+"_conjugate",h,Q),_.call(F+"_mul",st,Q,Q),_.call(F+"_conjugate",D,ot),_.call(F+"_mul",ut,ot,ot),_.call(F+"_conjugate",Z,W))}function Mt(){xt();const k=t.addFunction(i+"_prepareG2");k.addParam("pQ","i32"),k.addParam("ppreQ","i32"),k.addLocal("pCoef","i32"),k.addLocal("i","i32");const _=k.getCodeBuilder(),h=_.getLocal("pQ"),D=t.alloc(s*3),Z=_.i32_const(D),Q=_.i32_const(D),ot=_.i32_const(D+s),W=_.i32_const(D+2*s),st=_.i32_add(_.getLocal("ppreQ"),_.i32_const(0)),ut=_.i32_add(_.getLocal("ppreQ"),_.i32_const(s)),dt=t.alloc(s*3),rt=_.i32_const(dt),pt=t.alloc(s*3),Ut=_.i32_const(pt),St=_.i32_const(pt+s);k.addCode(_.call(x+"_normalize",h,st),_.call(F+"_copy",st,Q),_.call(F+"_copy",ut,ot),_.call(F+"_one",W)),k.addCode(_.setLocal("pCoef",_.i32_add(_.getLocal("ppreQ"),_.i32_const(s*3))),_.setLocal("i",_.i32_const(Nt.length-2)),_.block(_.loop(_.call(i+"_prepDblStep",Z,_.getLocal("pCoef")),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))),_.if(_.i32_load8_s(_.getLocal("i"),kt),[..._.call(i+"_prepAddStep",st,Z,_.getLocal("pCoef")),..._.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A)))]),_.br_if(1,_.i32_eqz(_.getLocal("i"))),_.setLocal("i",_.i32_sub(_.getLocal("i"),_.i32_const(1))),_.br(0)))),k.addCode(_.call(i+"_mulByQ",st,rt),_.call(i+"_mulByQ",rt,Ut)),k.addCode(_.call(F+"_neg",St,St),_.call(i+"_prepAddStep",rt,Z,_.getLocal("pCoef")),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))),_.call(i+"_prepAddStep",Ut,Z,_.getLocal("pCoef")),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))))}function Gt(){const k=t.addFunction(i+"__mulBy024Old");k.addParam("pEll0","i32"),k.addParam("pEllVW","i32"),k.addParam("pEllVV","i32"),k.addParam("pR","i32");const _=k.getCodeBuilder(),h=_.getLocal("pEll0"),D=_.getLocal("pEllVV"),Z=_.getLocal("pEllVW"),Q=_.getLocal("pR"),ot=t.alloc(m),W=_.i32_const(ot),st=_.i32_const(ot),ut=_.i32_const(ot+s),dt=_.i32_const(ot+s*2),rt=_.i32_const(ot+s*3),pt=_.i32_const(ot+s*4),Ut=_.i32_const(ot+s*5);k.addCode(_.call(F+"_copy",h,st),_.call(F+"_zero",ut),_.call(F+"_copy",D,dt),_.call(F+"_zero",rt),_.call(F+"_copy",Z,pt),_.call(F+"_zero",Ut),_.call(ht+"_mul",W,Q,Q))}function vt(){const k=t.addFunction(i+"__mulBy024");k.addParam("pEll0","i32"),k.addParam("pEllVW","i32"),k.addParam("pEllVV","i32"),k.addParam("pR","i32");const _=k.getCodeBuilder(),h=_.getLocal("pEll0"),D=_.getLocal("pEllVV"),Z=_.getLocal("pEllVW"),Q=_.getLocal("pR"),ot=_.i32_add(_.getLocal("pR"),_.i32_const(2*r)),W=_.i32_add(_.getLocal("pR"),_.i32_const(4*r)),st=_.i32_add(_.getLocal("pR"),_.i32_const(6*r)),ut=_.i32_add(_.getLocal("pR"),_.i32_const(8*r)),dt=_.i32_add(_.getLocal("pR"),_.i32_const(10*r)),rt=_.i32_const(t.alloc(s)),pt=_.i32_const(t.alloc(s)),Ut=_.i32_const(t.alloc(s)),St=_.i32_const(t.alloc(s)),wt=_.i32_const(t.alloc(s)),Rt=_.i32_const(t.alloc(s)),Dt=_.i32_const(t.alloc(s)),Yt=_.i32_const(t.alloc(s)),Qt=_.i32_const(t.alloc(s)),qt=_.i32_const(t.alloc(s)),Pt=_.i32_const(t.alloc(s));k.addCode(_.call(F+"_mul",Q,h,Dt),_.call(F+"_mul",W,D,Yt),_.call(F+"_mul",ut,Z,Qt),_.call(F+"_add",Q,ut,Ut),_.call(F+"_add",Q,W,pt),_.call(F+"_add",ot,st,St),_.call(F+"_add",St,dt,St),_.call(F+"_mul",ot,D,qt),_.call(F+"_add",qt,Qt,wt),_.call(F+"_mul",_.i32_const(T),wt,Rt),_.call(F+"_add",Rt,Dt,Q),_.call(F+"_mul",dt,Z,wt),_.call(F+"_add",qt,wt,qt),_.call(F+"_add",wt,Yt,wt),_.call(F+"_mul",_.i32_const(T),wt,Rt),_.call(F+"_mul",ot,h,wt),_.call(F+"_add",qt,wt,qt),_.call(F+"_add",Rt,wt,ot),_.call(F+"_add",h,D,rt),_.call(F+"_mul",pt,rt,wt),_.call(F+"_add",Dt,Yt,Pt),_.call(F+"_sub",wt,Pt,wt),_.call(F+"_mul",st,Z,Rt),_.call(F+"_add",qt,Rt,qt),_.call(F+"_add",W,ut,rt),_.call(F+"_add",wt,Rt,W),_.call(F+"_add",D,Z,pt),_.call(F+"_mul",pt,rt,wt),_.call(F+"_add",Yt,Qt,Pt),_.call(F+"_sub",wt,Pt,wt),_.call(F+"_mul",_.i32_const(T),wt,Rt),_.call(F+"_mul",st,h,wt),_.call(F+"_add",qt,wt,qt),_.call(F+"_add",Rt,wt,st),_.call(F+"_mul",dt,D,wt),_.call(F+"_add",qt,wt,qt),_.call(F+"_mul",_.i32_const(T),wt,Rt),_.call(F+"_add",h,Z,rt),_.call(F+"_mul",Ut,rt,wt),_.call(F+"_add",Dt,Qt,Pt),_.call(F+"_sub",wt,Pt,wt),_.call(F+"_add",Rt,wt,ut),_.call(F+"_add",h,D,rt),_.call(F+"_add",rt,Z,rt),_.call(F+"_mul",St,rt,wt),_.call(F+"_sub",wt,qt,dt))}function Et(){const k=t.addFunction(i+"_millerLoop");k.addParam("ppreP","i32"),k.addParam("ppreQ","i32"),k.addParam("r","i32"),k.addLocal("pCoef","i32"),k.addLocal("i","i32");const _=k.getCodeBuilder(),h=_.getLocal("ppreP"),D=_.i32_add(_.getLocal("ppreP"),_.i32_const(l)),Z=_.getLocal("pCoef"),Q=_.i32_add(_.getLocal("pCoef"),_.i32_const(s)),ot=_.i32_add(_.getLocal("pCoef"),_.i32_const(2*s)),W=t.alloc(s),st=_.i32_const(W),ut=t.alloc(s),dt=_.i32_const(ut),rt=_.getLocal("r");k.addCode(_.call(ht+"_one",rt),_.setLocal("pCoef",_.i32_add(_.getLocal("ppreQ"),_.i32_const(s*3))),_.setLocal("i",_.i32_const(Nt.length-2)),_.block(_.loop(_.call(ht+"_square",rt,rt),_.call(F+"_mul1",Q,D,st),_.call(F+"_mul1",ot,h,dt),_.call(i+"__mulBy024",Z,st,dt,rt),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))),_.if(_.i32_load8_s(_.getLocal("i"),kt),[..._.call(F+"_mul1",Q,D,st),..._.call(F+"_mul1",ot,h,dt),..._.call(i+"__mulBy024",Z,st,dt,rt),..._.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A)))]),_.br_if(1,_.i32_eqz(_.getLocal("i"))),_.setLocal("i",_.i32_sub(_.getLocal("i"),_.i32_const(1))),_.br(0)))),k.addCode(_.call(F+"_mul1",Q,D,st),_.call(F+"_mul1",ot,h,dt),_.call(i+"__mulBy024",Z,st,dt,rt),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))),_.call(F+"_mul1",Q,D,st),_.call(F+"_mul1",ot,h,dt),_.call(i+"__mulBy024",Z,st,dt,rt),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(A))))}function Ot(k){const _=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[8376118865763821496583973867626364092589906065868298776909617916018768340080n,16469823323077808223889137241176536799009286646108169935659301613961712198316n],[21888242871839275220042445260109153167277707414472061641714758635765020556617n,0n],[11697423496358154304825782922584725312912383441159505038794027105778954184319n,303847389135065887422783454877609941456349188919719272345083954437860409601n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[3321304630594332808241809054958361220322477375291206261884409189760185844239n,5722266937896532885780051958958348231143373700109372999374820235121374419868n],[21888242871839275222246405745257275088696311157297823662689037894645226208582n,0n],[13512124006075453725662431877630910996106405091429524885779419978626457868503n,5418419548761466998357268504080738289687024511189653727029736280683514010267n],[2203960485148121921418603742825762020974279258880205651966n,0n],[10190819375481120917420622822672549775783927716138318623895010788866272024264n,21584395482704209334823622290379665147239961968378104390343953940207365798982n],[2203960485148121921418603742825762020974279258880205651967n,0n],[18566938241244942414004596690298913868373833782006617400804628704885040364344n,16165975933942742336466353786298926857552937457188450663314217659523851788715n]]],h=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[21575463638280843010398324269430826099269044274347216827212613867836435027261n,10307601595873709700152284273816112264069230130616436755625194854815875713954n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[3772000881919853776433695186713858239009073593817195771773381919316419345261n,2236595495967245188281701248203181795121068902605861227855261137820944008926n],[2203960485148121921418603742825762020974279258880205651966n,0n],[18429021223477853657660792034369865839114504446431234726392080002137598044644n,9344045779998320333812420223237981029506012124075525679208581902008406485703n]],[[1n,0n],[2581911344467009335267311115468803099551665605076196740867805258568234346338n,19937756971775647987995932169929341994314640652964949448313374472400716661030n],[2203960485148121921418603742825762020974279258880205651966n,0n],[5324479202449903542726783395506214481928257762400643279780343368557297135718n,16208900380737693084919495127334387981393726419856888799917914180988844123039n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[13981852324922362344252311234282257507216387789820983642040889267519694726527n,7629828391165209371577384193250820201684255241773809077146787135900891633097n]]],D=t.addFunction(i+"__frobeniusMap"+k);D.addParam("x","i32"),D.addParam("r","i32");const Z=D.getCodeBuilder();for(let ot=0;ot<6;ot++){const W=ot==0?Z.getLocal("x"):Z.i32_add(Z.getLocal("x"),Z.i32_const(ot*s)),st=W,ut=Z.i32_add(Z.getLocal("x"),Z.i32_const(ot*s+l)),dt=ot==0?Z.getLocal("r"):Z.i32_add(Z.getLocal("r"),Z.i32_const(ot*s)),rt=dt,pt=Z.i32_add(Z.getLocal("r"),Z.i32_const(ot*s+l)),Ut=Q(_[Math.floor(ot/3)][k%12],h[ot%3][k%6]),St=t.alloc([...Zt.bigInt2BytesLE(z(Ut[0]),32),...Zt.bigInt2BytesLE(z(Ut[1]),32)]);k%2==1?D.addCode(Z.call(g+"_copy",st,rt),Z.call(g+"_neg",ut,pt),Z.call(F+"_mul",dt,Z.i32_const(St),dt)):D.addCode(Z.call(F+"_mul",W,Z.i32_const(St),dt))}function Q(ot,W){const st=BigInt(ot[0]),ut=BigInt(ot[1]),dt=BigInt(W[0]),rt=BigInt(W[1]),pt=[(st*dt-ut*rt)%o,(st*rt+ut*dt)%o];return $d(pt[0])&&(pt[0]=pt[0]+o),pt}}function $t(){const k=t.addFunction(i+"__finalExponentiationFirstChunk");k.addParam("x","i32"),k.addParam("r","i32");const _=k.getCodeBuilder(),h=_.getLocal("x"),D=h,Z=_.i32_add(h,_.i32_const(r*6)),Q=_.getLocal("r"),ot=t.alloc(m),W=_.i32_const(ot),st=W,ut=_.i32_const(ot+r*6),dt=_.i32_const(t.alloc(m)),rt=_.i32_const(t.alloc(m)),pt=_.i32_const(t.alloc(m));k.addCode(_.call(yt+"_copy",D,st),_.call(yt+"_neg",Z,ut),_.call(ht+"_inverse",h,dt),_.call(ht+"_mul",W,dt,rt),_.call(i+"__frobeniusMap2",rt,pt),_.call(ht+"_mul",rt,pt,Q))}function Jt(){const k=t.addFunction(i+"__cyclotomicSquare");k.addParam("x","i32"),k.addParam("r","i32");const _=k.getCodeBuilder(),h=_.getLocal("x"),D=_.i32_add(_.getLocal("x"),_.i32_const(s)),Z=_.i32_add(_.getLocal("x"),_.i32_const(2*s)),Q=_.i32_add(_.getLocal("x"),_.i32_const(3*s)),ot=_.i32_add(_.getLocal("x"),_.i32_const(4*s)),W=_.i32_add(_.getLocal("x"),_.i32_const(5*s)),st=_.getLocal("r"),ut=_.i32_add(_.getLocal("r"),_.i32_const(s)),dt=_.i32_add(_.getLocal("r"),_.i32_const(2*s)),rt=_.i32_add(_.getLocal("r"),_.i32_const(3*s)),pt=_.i32_add(_.getLocal("r"),_.i32_const(4*s)),Ut=_.i32_add(_.getLocal("r"),_.i32_const(5*s)),St=_.i32_const(t.alloc(s)),wt=_.i32_const(t.alloc(s)),Rt=_.i32_const(t.alloc(s)),Dt=_.i32_const(t.alloc(s)),Yt=_.i32_const(t.alloc(s)),Qt=_.i32_const(t.alloc(s)),qt=_.i32_const(t.alloc(s)),Pt=_.i32_const(t.alloc(s));k.addCode(_.call(F+"_mul",h,ot,qt),_.call(F+"_mul",ot,_.i32_const(T),St),_.call(F+"_add",h,St,St),_.call(F+"_add",h,ot,Pt),_.call(F+"_mul",Pt,St,St),_.call(F+"_mul",_.i32_const(T),qt,Pt),_.call(F+"_add",qt,Pt,Pt),_.call(F+"_sub",St,Pt,St),_.call(F+"_add",qt,qt,wt),_.call(F+"_mul",Q,Z,qt),_.call(F+"_mul",Z,_.i32_const(T),Rt),_.call(F+"_add",Q,Rt,Rt),_.call(F+"_add",Q,Z,Pt),_.call(F+"_mul",Pt,Rt,Rt),_.call(F+"_mul",_.i32_const(T),qt,Pt),_.call(F+"_add",qt,Pt,Pt),_.call(F+"_sub",Rt,Pt,Rt),_.call(F+"_add",qt,qt,Dt),_.call(F+"_mul",D,W,qt),_.call(F+"_mul",W,_.i32_const(T),Yt),_.call(F+"_add",D,Yt,Yt),_.call(F+"_add",D,W,Pt),_.call(F+"_mul",Pt,Yt,Yt),_.call(F+"_mul",_.i32_const(T),qt,Pt),_.call(F+"_add",qt,Pt,Pt),_.call(F+"_sub",Yt,Pt,Yt),_.call(F+"_add",qt,qt,Qt),_.call(F+"_sub",St,h,st),_.call(F+"_add",st,st,st),_.call(F+"_add",St,st,st),_.call(F+"_add",wt,ot,pt),_.call(F+"_add",pt,pt,pt),_.call(F+"_add",wt,pt,pt),_.call(F+"_mul",Qt,_.i32_const(Lt),Pt),_.call(F+"_add",Pt,Q,rt),_.call(F+"_add",rt,rt,rt),_.call(F+"_add",Pt,rt,rt),_.call(F+"_sub",Yt,Z,dt),_.call(F+"_add",dt,dt,dt),_.call(F+"_add",Yt,dt,dt),_.call(F+"_sub",Rt,D,ut),_.call(F+"_add",ut,ut,ut),_.call(F+"_add",Rt,ut,ut),_.call(F+"_add",Dt,W,Ut),_.call(F+"_add",Ut,Ut,Ut),_.call(F+"_add",Dt,Ut,Ut))}function ie(k,_){const h=J(k).map(ut=>ut==-1?255:ut),D=t.alloc(h),Z=t.addFunction(i+"__cyclotomicExp_"+_);Z.addParam("x","i32"),Z.addParam("r","i32"),Z.addLocal("bit","i32"),Z.addLocal("i","i32");const Q=Z.getCodeBuilder(),ot=Q.getLocal("x"),W=Q.getLocal("r"),st=Q.i32_const(t.alloc(m));Z.addCode(Q.call(ht+"_conjugate",ot,st),Q.call(ht+"_one",W),Q.if(Q.teeLocal("bit",Q.i32_load8_s(Q.i32_const(h.length-1),D)),Q.if(Q.i32_eq(Q.getLocal("bit"),Q.i32_const(1)),Q.call(ht+"_mul",W,ot,W),Q.call(ht+"_mul",W,st,W))),Q.setLocal("i",Q.i32_const(h.length-2)),Q.block(Q.loop(Q.call(i+"__cyclotomicSquare",W,W),Q.if(Q.teeLocal("bit",Q.i32_load8_s(Q.getLocal("i"),D)),Q.if(Q.i32_eq(Q.getLocal("bit"),Q.i32_const(1)),Q.call(ht+"_mul",W,ot,W),Q.call(ht+"_mul",W,st,W))),Q.br_if(1,Q.i32_eqz(Q.getLocal("i"))),Q.setLocal("i",Q.i32_sub(Q.getLocal("i"),Q.i32_const(1))),Q.br(0))))}function ae(){Jt(),ie(b,"w0");const k=t.addFunction(i+"__finalExponentiationLastChunk");k.addParam("x","i32"),k.addParam("r","i32");const _=k.getCodeBuilder(),h=_.getLocal("x"),D=_.getLocal("r"),Z=_.i32_const(t.alloc(m)),Q=_.i32_const(t.alloc(m)),ot=_.i32_const(t.alloc(m)),W=_.i32_const(t.alloc(m)),st=_.i32_const(t.alloc(m)),ut=_.i32_const(t.alloc(m)),dt=_.i32_const(t.alloc(m)),rt=_.i32_const(t.alloc(m)),pt=_.i32_const(t.alloc(m)),Ut=_.i32_const(t.alloc(m)),St=_.i32_const(t.alloc(m)),wt=_.i32_const(t.alloc(m)),Rt=_.i32_const(t.alloc(m)),Dt=_.i32_const(t.alloc(m)),Yt=_.i32_const(t.alloc(m)),Qt=_.i32_const(t.alloc(m)),qt=_.i32_const(t.alloc(m)),Pt=_.i32_const(t.alloc(m)),jt=_.i32_const(t.alloc(m)),ue=_.i32_const(t.alloc(m)),ge=_.i32_const(t.alloc(m));k.addCode(_.call(i+"__cyclotomicExp_w0",h,Z),_.call(ht+"_conjugate",Z,Z),_.call(i+"__cyclotomicSquare",Z,Q),_.call(i+"__cyclotomicSquare",Q,ot),_.call(ht+"_mul",ot,Q,W),_.call(i+"__cyclotomicExp_w0",W,st),_.call(ht+"_conjugate",st,st),_.call(i+"__cyclotomicSquare",st,ut),_.call(i+"__cyclotomicExp_w0",ut,dt),_.call(ht+"_conjugate",dt,dt),_.call(ht+"_conjugate",W,rt),_.call(ht+"_conjugate",dt,pt),_.call(ht+"_mul",pt,st,Ut),_.call(ht+"_mul",Ut,rt,St),_.call(ht+"_mul",St,Q,wt),_.call(ht+"_mul",St,st,Rt),_.call(ht+"_mul",Rt,h,Dt),_.call(i+"__frobeniusMap1",wt,Yt),_.call(ht+"_mul",Yt,Dt,Qt),_.call(i+"__frobeniusMap2",St,qt),_.call(ht+"_mul",qt,Qt,Pt),_.call(ht+"_conjugate",h,jt),_.call(ht+"_mul",jt,wt,ue),_.call(i+"__frobeniusMap3",ue,ge),_.call(ht+"_mul",ge,Pt,D))}function B(){$t(),ae();const k=t.addFunction(i+"_finalExponentiation");k.addParam("x","i32"),k.addParam("r","i32");const _=k.getCodeBuilder(),h=_.getLocal("x"),D=_.getLocal("r"),Z=_.i32_const(t.alloc(m));k.addCode(_.call(i+"__finalExponentiationFirstChunk",h,Z),_.call(i+"__finalExponentiationLastChunk",Z,D))}function p(){const k=t.addFunction(i+"_finalExponentiationOld");k.addParam("x","i32"),k.addParam("r","i32");const h=t.alloc(Zt.bigInt2BytesLE(552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480n,352)),D=k.getCodeBuilder();k.addCode(D.call(ht+"_exp",D.getLocal("x"),D.i32_const(h),D.i32_const(352),D.getLocal("r")))}const y=t.alloc(G),O=t.alloc(U);function H(k){const _=t.addFunction(i+"_pairingEq"+k);for(let Q=0;Q<k;Q++)_.addParam("p_"+Q,"i32"),_.addParam("q_"+Q,"i32");_.addParam("c","i32"),_.setReturnType("i32");const h=_.getCodeBuilder(),D=h.i32_const(t.alloc(m)),Z=h.i32_const(t.alloc(m));_.addCode(h.call(ht+"_one",D));for(let Q=0;Q<k;Q++)_.addCode(h.call(i+"_prepareG1",h.getLocal("p_"+Q),h.i32_const(y))),_.addCode(h.call(i+"_prepareG2",h.getLocal("q_"+Q),h.i32_const(O))),_.addCode(h.call(i+"_millerLoop",h.i32_const(y),h.i32_const(O),Z)),_.addCode(h.call(ht+"_mul",D,Z,D));_.addCode(h.call(i+"_finalExponentiation",D,D)),_.addCode(h.call(ht+"_eq",D,h.getLocal("c")))}function nt(){const k=t.addFunction(i+"_pairing");k.addParam("p","i32"),k.addParam("q","i32"),k.addParam("r","i32");const _=k.getCodeBuilder(),h=_.i32_const(t.alloc(m));k.addCode(_.call(i+"_prepareG1",_.getLocal("p"),_.i32_const(y))),k.addCode(_.call(i+"_prepareG2",_.getLocal("q"),_.i32_const(O))),k.addCode(_.call(i+"_millerLoop",_.i32_const(y),_.i32_const(O),h)),k.addCode(_.call(i+"_finalExponentiation",h,_.getLocal("r")))}At(),zt(),lt(),Mt(),vt(),Gt(),Et();for(let k=0;k<10;k++)Ot(k),t.exportFunction(i+"__frobeniusMap"+k);p(),B();for(let k=1;k<=5;k++)H(k),t.exportFunction(i+"_pairingEq"+k);nt(),t.exportFunction(i+"_pairing"),t.exportFunction(i+"_prepareG1"),t.exportFunction(i+"_prepareG2"),t.exportFunction(i+"_millerLoop"),t.exportFunction(i+"_finalExponentiation"),t.exportFunction(i+"_finalExponentiationOld"),t.exportFunction(i+"__mulBy024"),t.exportFunction(i+"__mulBy024Old"),t.exportFunction(i+"__cyclotomicSquare"),t.exportFunction(i+"__cyclotomicExp_w0")};const Kt=ln,Hd=fa,Zd=Fr,Na=vr,Yd=Sr,Ga=Or,ho=Ur,Vd=Pr,jd=Mr,Wn=kr,{bitLength:$a,isOdd:Ka,isNegative:Wd}=Ae;var Xd=function(t,e){const i=e||"bls12381";if(t.modules[i])return i;const o=0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn,a=0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n,u=Math.floor(($a(o-1n)-1)/64)+1,r=u*8,I=r,l=I*2,s=I*12,m=Math.floor(($a(a-1n)-1)/64)+1,C=m*8,g=C,M=t.alloc(Kt.bigInt2BytesLE(a,g)),$=Hd(t,o,"f1m","intq");Zd(t,a,"fr","frm","intr");const F=t.alloc(Kt.bigInt2BytesLE(v(4n),I)),R=Ga(t,"g1m","f1m",F);ho(t,"frm","frm","frm","frm_mul"),Vd(t,"pol","frm"),jd(t,"qap","frm");const x=Na(t,"f1m_neg","f2m","f1m"),it=t.alloc([...Kt.bigInt2BytesLE(v(4n),I),...Kt.bigInt2BytesLE(v(4n),I)]),z=Ga(t,"g2m","f2m",it);function K(_,h){const D=t.addFunction(_);D.addParam("pG","i32"),D.addParam("pFr","i32"),D.addParam("pr","i32");const Z=D.getCodeBuilder(),Q=Z.i32_const(t.alloc(C));D.addCode(Z.call("frm_fromMontgomery",Z.getLocal("pFr"),Q),Z.call(h,Z.getLocal("pG"),Q,Z.i32_const(C),Z.getLocal("pr"))),t.exportFunction(_)}K("g1m_timesFr","g1m_timesScalar"),ho(t,"g1m","g1m","frm","g1m_timesFr"),K("g2m_timesFr","g2m_timesScalar"),ho(t,"g2m","g2m","frm","g2m_timesFr"),K("g1m_timesFrAffine","g1m_timesScalarAffine"),K("g2m_timesFrAffine","g2m_timesScalarAffine"),Wn(t,"frm_batchApplyKey","fmr","frm",C,C,C,"frm_mul"),Wn(t,"g1m_batchApplyKey","g1m","frm",r*3,r*3,C,"g1m_timesFr"),Wn(t,"g1m_batchApplyKeyMixed","g1m","frm",r*2,r*3,C,"g1m_timesFrAffine"),Wn(t,"g2m_batchApplyKey","g2m","frm",r*2*3,r*3*2,C,"g2m_timesFr"),Wn(t,"g2m_batchApplyKeyMixed","g2m","frm",r*2*2,r*3*2,C,"g2m_timesFrAffine");function v(_){return BigInt(_)*(1n<<BigInt(I*8))%o}const f=[3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507n,1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569n,1n],L=t.alloc([...Kt.bigInt2BytesLE(v(f[0]),I),...Kt.bigInt2BytesLE(v(f[1]),I),...Kt.bigInt2BytesLE(v(f[2]),I)]),V=[0n,1n,0n],X=t.alloc([...Kt.bigInt2BytesLE(v(V[0]),I),...Kt.bigInt2BytesLE(v(V[1]),I),...Kt.bigInt2BytesLE(v(V[2]),I)]),et=[[352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160n,3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758n],[1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905n,927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582n],[1n,0n]],N=t.alloc([...Kt.bigInt2BytesLE(v(et[0][0]),I),...Kt.bigInt2BytesLE(v(et[0][1]),I),...Kt.bigInt2BytesLE(v(et[1][0]),I),...Kt.bigInt2BytesLE(v(et[1][1]),I),...Kt.bigInt2BytesLE(v(et[2][0]),I),...Kt.bigInt2BytesLE(v(et[2][1]),I)]),w=[[0n,0n],[1n,0n],[0n,0n]],T=t.alloc([...Kt.bigInt2BytesLE(v(w[0][0]),I),...Kt.bigInt2BytesLE(v(w[0][1]),I),...Kt.bigInt2BytesLE(v(w[1][0]),I),...Kt.bigInt2BytesLE(v(w[1][1]),I),...Kt.bigInt2BytesLE(v(w[2][0]),I),...Kt.bigInt2BytesLE(v(w[2][1]),I)]),at=t.alloc([...Kt.bigInt2BytesLE(v(1n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I),...Kt.bigInt2BytesLE(v(0n),I)]),Lt=t.alloc([...Kt.bigInt2BytesLE(v(1n),I),...Kt.bigInt2BytesLE(v(1n),I)]);function _t(){const _=t.addFunction(x+"_mulNR");_.addParam("x","i32"),_.addParam("pr","i32");const h=_.getCodeBuilder(),D=h.i32_const(t.alloc(I)),Z=h.getLocal("x"),Q=h.i32_add(h.getLocal("x"),h.i32_const(I)),ot=h.getLocal("pr"),W=h.i32_add(h.getLocal("pr"),h.i32_const(I));_.addCode(h.call($+"_copy",Z,D),h.call($+"_sub",Z,Q,ot),h.call($+"_add",D,Q,W))}_t();const ct=Yd(t,x+"_mulNR","f6m","f2m");function yt(){const _=t.addFunction(ct+"_mulNR");_.addParam("x","i32"),_.addParam("pr","i32");const h=_.getCodeBuilder(),D=h.i32_const(t.alloc(I*2));_.addCode(h.call(x+"_copy",h.getLocal("x"),D),h.call(x+"_mulNR",h.i32_add(h.getLocal("x"),h.i32_const(r*4)),h.getLocal("pr")),h.call(x+"_copy",h.i32_add(h.getLocal("x"),h.i32_const(r*2)),h.i32_add(h.getLocal("pr"),h.i32_const(r*4))),h.call(x+"_copy",D,h.i32_add(h.getLocal("pr"),h.i32_const(r*2))))}yt();const ft=Na(t,ct+"_mulNR","ftm",ct),Ft=It(0xd201000000010000n),Nt=t.alloc(Ft),kt=3*l,A=Ft.length-1,E=Ft.reduce((_,h)=>_+(h!=0?1:0),0)+A+1,d=3*2*r,G=3*r*2+E*kt,U=!0,b=15132376222941642752n;t.modules[i]={n64q:u,n64r:m,n8q:r,n8r:C,pG1gen:L,pG1zero:X,pG1b:F,pG2gen:N,pG2zero:T,pG2b:it,pq:t.modules.f1m.pq,pr:M,pOneT:at,r:a,q:o,prePSize:d,preQSize:G};function J(_){let h=_;const D=[];for(;h>0n;){if(Ka(h)){const Z=2-Number(h%4n);D.push(Z),h=h-BigInt(Z)}else D.push(0);h=h>>1n}return D}function It(_){let h=_;const D=[];for(;h>0n;)Ka(h)?D.push(1):D.push(0),h=h>>1n;return D}function lt(){const _=t.addFunction(i+"_prepareG1");_.addParam("pP","i32"),_.addParam("ppreP","i32");const h=_.getCodeBuilder();_.addCode(h.call(R+"_normalize",h.getLocal("pP"),h.getLocal("ppreP")))}function At(){const _=t.addFunction(i+"_prepDblStep");_.addParam("R","i32"),_.addParam("r","i32");const h=_.getCodeBuilder(),D=h.getLocal("R"),Z=h.i32_add(h.getLocal("R"),h.i32_const(2*r)),Q=h.i32_add(h.getLocal("R"),h.i32_const(4*r)),ot=h.getLocal("r"),W=h.i32_add(h.getLocal("r"),h.i32_const(2*r)),st=h.i32_add(h.getLocal("r"),h.i32_const(4*r)),ut=h.i32_const(t.alloc(l)),dt=h.i32_const(t.alloc(l)),rt=h.i32_const(t.alloc(l)),pt=h.i32_const(t.alloc(l)),Ut=h.i32_const(t.alloc(l));_.addCode(h.call(x+"_square",D,ot),h.call(x+"_square",Z,dt),h.call(x+"_square",dt,rt),h.call(x+"_add",dt,D,W),h.call(x+"_square",W,W),h.call(x+"_sub",W,ot,W),h.call(x+"_sub",W,rt,W),h.call(x+"_add",W,W,W),h.call(x+"_add",ot,ot,pt),h.call(x+"_add",pt,ot,pt),h.call(x+"_add",D,pt,st),h.call(x+"_square",pt,Ut),h.call(x+"_square",Q,ut),h.call(x+"_sub",Ut,W,D),h.call(x+"_sub",D,W,D),h.call(x+"_add",Q,Z,Q),h.call(x+"_square",Q,Q),h.call(x+"_sub",Q,dt,Q),h.call(x+"_sub",Q,ut,Q),h.call(x+"_sub",W,D,Z),h.call(x+"_mul",Z,pt,Z),h.call(x+"_add",rt,rt,rt),h.call(x+"_add",rt,rt,rt),h.call(x+"_add",rt,rt,rt),h.call(x+"_sub",Z,rt,Z),h.call(x+"_mul",pt,ut,W),h.call(x+"_add",W,W,W),h.call(x+"_neg",W,W),h.call(x+"_square",st,st),h.call(x+"_sub",st,ot,st),h.call(x+"_sub",st,Ut,st),h.call(x+"_add",dt,dt,dt),h.call(x+"_add",dt,dt,dt),h.call(x+"_sub",st,dt,st),h.call(x+"_mul",Q,ut,ot),h.call(x+"_add",ot,ot,ot))}function zt(){const _=t.addFunction(i+"_prepAddStep");_.addParam("R","i32"),_.addParam("Q","i32"),_.addParam("r","i32");const h=_.getCodeBuilder(),D=h.getLocal("R"),Z=h.i32_add(h.getLocal("R"),h.i32_const(2*r)),Q=h.i32_add(h.getLocal("R"),h.i32_const(4*r)),ot=h.getLocal("Q"),W=h.i32_add(h.getLocal("Q"),h.i32_const(2*r)),st=h.getLocal("r"),ut=h.i32_add(h.getLocal("r"),h.i32_const(2*r)),dt=h.i32_add(h.getLocal("r"),h.i32_const(4*r)),rt=h.i32_const(t.alloc(l)),pt=h.i32_const(t.alloc(l)),Ut=h.i32_const(t.alloc(l)),St=h.i32_const(t.alloc(l)),wt=h.i32_const(t.alloc(l)),Rt=h.i32_const(t.alloc(l)),Dt=h.i32_const(t.alloc(l)),Yt=h.i32_const(t.alloc(l)),Qt=h.i32_const(t.alloc(l)),qt=h.i32_const(t.alloc(l)),Pt=h.i32_const(t.alloc(l));_.addCode(h.call(x+"_square",Q,rt),h.call(x+"_square",W,pt),h.call(x+"_mul",rt,ot,St),h.call(x+"_add",W,Q,ut),h.call(x+"_square",ut,ut),h.call(x+"_sub",ut,pt,ut),h.call(x+"_sub",ut,rt,ut),h.call(x+"_mul",ut,rt,ut),h.call(x+"_sub",St,D,wt),h.call(x+"_square",wt,Rt),h.call(x+"_add",Rt,Rt,Dt),h.call(x+"_add",Dt,Dt,Dt),h.call(x+"_mul",Dt,wt,Yt),h.call(x+"_sub",ut,Z,Qt),h.call(x+"_sub",Qt,Z,Qt),h.call(x+"_mul",Qt,ot,dt),h.call(x+"_mul",Dt,D,qt),h.call(x+"_square",Qt,D),h.call(x+"_sub",D,Yt,D),h.call(x+"_sub",D,qt,D),h.call(x+"_sub",D,qt,D),h.call(x+"_add",Q,wt,Q),h.call(x+"_square",Q,Q),h.call(x+"_sub",Q,rt,Q),h.call(x+"_sub",Q,Rt,Q),h.call(x+"_add",W,Q,st),h.call(x+"_sub",qt,D,Pt),h.call(x+"_mul",Pt,Qt,Pt),h.call(x+"_mul",Z,Yt,St),h.call(x+"_add",St,St,St),h.call(x+"_sub",Pt,St,Z),h.call(x+"_square",st,st),h.call(x+"_sub",st,pt,st),h.call(x+"_square",Q,Ut),h.call(x+"_sub",st,Ut,st),h.call(x+"_add",dt,dt,dt),h.call(x+"_sub",dt,st,dt),h.call(x+"_add",Q,Q,st),h.call(x+"_neg",Qt,Qt),h.call(x+"_add",Qt,Qt,ut))}function xt(){const _=t.addFunction(i+"_prepareG2");_.addParam("pQ","i32"),_.addParam("ppreQ","i32"),_.addLocal("pCoef","i32"),_.addLocal("i","i32");const h=_.getCodeBuilder(),D=h.getLocal("pQ"),Z=t.alloc(l*3),Q=h.i32_const(Z),ot=h.getLocal("ppreQ");_.addCode(h.call(z+"_normalize",D,ot),h.if(h.call(z+"_isZero",ot),h.ret([])),h.call(z+"_copy",ot,Q),h.setLocal("pCoef",h.i32_add(h.getLocal("ppreQ"),h.i32_const(l*3)))),_.addCode(h.setLocal("i",h.i32_const(Ft.length-2)),h.block(h.loop(h.call(i+"_prepDblStep",Q,h.getLocal("pCoef")),h.setLocal("pCoef",h.i32_add(h.getLocal("pCoef"),h.i32_const(kt))),h.if(h.i32_load8_s(h.getLocal("i"),Nt),[...h.call(i+"_prepAddStep",Q,ot,h.getLocal("pCoef")),...h.setLocal("pCoef",h.i32_add(h.getLocal("pCoef"),h.i32_const(kt)))]),h.br_if(1,h.i32_eqz(h.getLocal("i"))),h.setLocal("i",h.i32_sub(h.getLocal("i"),h.i32_const(1))),h.br(0))))}function Mt(){const _=t.addFunction(ct+"_mul1");_.addParam("pA","i32"),_.addParam("pC1","i32"),_.addParam("pR","i32");const h=_.getCodeBuilder(),D=h.getLocal("pA"),Z=h.i32_add(h.getLocal("pA"),h.i32_const(I*2)),Q=h.i32_add(h.getLocal("pA"),h.i32_const(I*4)),ot=h.getLocal("pC1"),W=h.getLocal("pR"),st=h.i32_add(h.getLocal("pR"),h.i32_const(I*2)),ut=h.i32_add(h.getLocal("pR"),h.i32_const(I*4)),dt=h.i32_const(t.alloc(I*2)),rt=h.i32_const(t.alloc(I*2));_.addCode(h.call(x+"_add",D,Z,dt),h.call(x+"_add",Z,Q,rt),h.call(x+"_mul",Z,ot,ut),h.call(x+"_mul",rt,ot,W),h.call(x+"_sub",W,ut,W),h.call(x+"_mulNR",W,W),h.call(x+"_mul",dt,ot,st),h.call(x+"_sub",st,ut,st))}Mt();function Gt(){const _=t.addFunction(ct+"_mul01");_.addParam("pA","i32"),_.addParam("pC0","i32"),_.addParam("pC1","i32"),_.addParam("pR","i32");const h=_.getCodeBuilder(),D=h.getLocal("pA"),Z=h.i32_add(h.getLocal("pA"),h.i32_const(I*2)),Q=h.i32_add(h.getLocal("pA"),h.i32_const(I*4)),ot=h.getLocal("pC0"),W=h.getLocal("pC1"),st=h.getLocal("pR"),ut=h.i32_add(h.getLocal("pR"),h.i32_const(I*2)),dt=h.i32_add(h.getLocal("pR"),h.i32_const(I*4)),rt=h.i32_const(t.alloc(I*2)),pt=h.i32_const(t.alloc(I*2)),Ut=h.i32_const(t.alloc(I*2)),St=h.i32_const(t.alloc(I*2));_.addCode(h.call(x+"_mul",D,ot,rt),h.call(x+"_mul",Z,W,pt),h.call(x+"_add",D,Z,Ut),h.call(x+"_add",D,Q,St),h.call(x+"_add",Z,Q,st),h.call(x+"_mul",st,W,st),h.call(x+"_sub",st,pt,st),h.call(x+"_mulNR",st,st),h.call(x+"_add",st,rt,st),h.call(x+"_add",ot,W,ut),h.call(x+"_mul",ut,Ut,ut),h.call(x+"_sub",ut,rt,ut),h.call(x+"_sub",ut,pt,ut),h.call(x+"_mul",St,ot,dt),h.call(x+"_sub",dt,rt,dt),h.call(x+"_add",dt,pt,dt))}Gt();function vt(){const _=t.addFunction(ft+"_mul014");_.addParam("pA","i32"),_.addParam("pC0","i32"),_.addParam("pC1","i32"),_.addParam("pC4","i32"),_.addParam("pR","i32");const h=_.getCodeBuilder(),D=h.getLocal("pA"),Z=h.i32_add(h.getLocal("pA"),h.i32_const(I*6)),Q=h.getLocal("pC0"),ot=h.getLocal("pC1"),W=h.getLocal("pC4"),st=h.i32_const(t.alloc(I*6)),ut=h.i32_const(t.alloc(I*6)),dt=h.i32_const(t.alloc(I*2)),rt=h.getLocal("pR"),pt=h.i32_add(h.getLocal("pR"),h.i32_const(I*6));_.addCode(h.call(ct+"_mul01",D,Q,ot,st),h.call(ct+"_mul1",Z,W,ut),h.call(x+"_add",ot,W,dt),h.call(ct+"_add",Z,D,pt),h.call(ct+"_mul01",pt,Q,dt,pt),h.call(ct+"_sub",pt,st,pt),h.call(ct+"_sub",pt,ut,pt),h.call(ct+"_copy",ut,rt),h.call(ct+"_mulNR",rt,rt),h.call(ct+"_add",rt,st,rt))}vt();function Et(){const _=t.addFunction(i+"_ell");_.addParam("pP","i32"),_.addParam("pCoefs","i32"),_.addParam("pF","i32");const h=_.getCodeBuilder(),D=h.getLocal("pP"),Z=h.i32_add(h.getLocal("pP"),h.i32_const(r)),Q=h.getLocal("pF"),ot=h.getLocal("pCoefs"),W=h.i32_add(h.getLocal("pCoefs"),h.i32_const(I)),st=h.i32_add(h.getLocal("pCoefs"),h.i32_const(I*2)),ut=h.i32_add(h.getLocal("pCoefs"),h.i32_const(I*3)),dt=h.i32_add(h.getLocal("pCoefs"),h.i32_const(I*4)),rt=t.alloc(I*2),pt=h.i32_const(rt),Ut=h.i32_const(rt),St=h.i32_const(rt+I),wt=t.alloc(I*2),Rt=h.i32_const(wt),Dt=h.i32_const(wt),Yt=h.i32_const(wt+I);_.addCode(h.call($+"_mul",ot,Z,Ut),h.call($+"_mul",W,Z,St),h.call($+"_mul",st,D,Dt),h.call($+"_mul",ut,D,Yt),h.call(ft+"_mul014",Q,dt,Rt,pt,Q))}Et();function Ot(){const _=t.addFunction(i+"_millerLoop");_.addParam("ppreP","i32"),_.addParam("ppreQ","i32"),_.addParam("r","i32"),_.addLocal("pCoef","i32"),_.addLocal("i","i32");const h=_.getCodeBuilder(),D=h.getLocal("ppreP"),Z=h.getLocal("pCoef"),Q=h.getLocal("r");_.addCode(h.call(ft+"_one",Q),h.if(h.call(R+"_isZero",D),h.ret([])),h.if(h.call(R+"_isZero",h.getLocal("ppreQ")),h.ret([])),h.setLocal("pCoef",h.i32_add(h.getLocal("ppreQ"),h.i32_const(l*3))),h.setLocal("i",h.i32_const(Ft.length-2)),h.block(h.loop(h.call(i+"_ell",D,Z,Q),h.setLocal("pCoef",h.i32_add(h.getLocal("pCoef"),h.i32_const(kt))),h.if(h.i32_load8_s(h.getLocal("i"),Nt),[...h.call(i+"_ell",D,Z,Q),...h.setLocal("pCoef",h.i32_add(h.getLocal("pCoef"),h.i32_const(kt)))]),h.call(ft+"_square",Q,Q),h.br_if(1,h.i32_eq(h.getLocal("i"),h.i32_const(1))),h.setLocal("i",h.i32_sub(h.getLocal("i"),h.i32_const(1))),h.br(0))),h.call(i+"_ell",D,Z,Q)),_.addCode(h.call(ft+"_conjugate",Q,Q))}function $t(_){const h=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n,151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351n,0n],[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n,877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n],[4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786n,0n],[151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n,3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n,0n],[877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n,3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n]]],D=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0n,4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[0n,1n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[0n,793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n]],[[1n,0n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n,0n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786n,0n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351n,0n]]],Z=t.addFunction(ft+"_frobeniusMap"+_);Z.addParam("x","i32"),Z.addParam("r","i32");const Q=Z.getCodeBuilder();for(let W=0;W<6;W++){const st=W==0?Q.getLocal("x"):Q.i32_add(Q.getLocal("x"),Q.i32_const(W*l)),ut=st,dt=Q.i32_add(Q.getLocal("x"),Q.i32_const(W*l+I)),rt=W==0?Q.getLocal("r"):Q.i32_add(Q.getLocal("r"),Q.i32_const(W*l)),pt=rt,Ut=Q.i32_add(Q.getLocal("r"),Q.i32_const(W*l+I)),St=ot(h[Math.floor(W/3)][_%12],D[W%3][_%6]),wt=t.alloc([...Kt.bigInt2BytesLE(v(St[0]),r),...Kt.bigInt2BytesLE(v(St[1]),r)]);_%2==1?Z.addCode(Q.call($+"_copy",ut,pt),Q.call($+"_neg",dt,Ut),Q.call(x+"_mul",rt,Q.i32_const(wt),rt)):Z.addCode(Q.call(x+"_mul",st,Q.i32_const(wt),rt))}function ot(W,st){const ut=W[0],dt=W[1],rt=st[0],pt=st[1],Ut=[(ut*rt-dt*pt)%o,(ut*pt+dt*rt)%o];return Wd(Ut[0])&&(Ut[0]=Ut[0]+o),Ut}}function Jt(){const _=t.addFunction(i+"__cyclotomicSquare");_.addParam("x","i32"),_.addParam("r","i32");const h=_.getCodeBuilder(),D=h.getLocal("x"),Z=h.i32_add(h.getLocal("x"),h.i32_const(l)),Q=h.i32_add(h.getLocal("x"),h.i32_const(2*l)),ot=h.i32_add(h.getLocal("x"),h.i32_const(3*l)),W=h.i32_add(h.getLocal("x"),h.i32_const(4*l)),st=h.i32_add(h.getLocal("x"),h.i32_const(5*l)),ut=h.getLocal("r"),dt=h.i32_add(h.getLocal("r"),h.i32_const(l)),rt=h.i32_add(h.getLocal("r"),h.i32_const(2*l)),pt=h.i32_add(h.getLocal("r"),h.i32_const(3*l)),Ut=h.i32_add(h.getLocal("r"),h.i32_const(4*l)),St=h.i32_add(h.getLocal("r"),h.i32_const(5*l)),wt=h.i32_const(t.alloc(l)),Rt=h.i32_const(t.alloc(l)),Dt=h.i32_const(t.alloc(l)),Yt=h.i32_const(t.alloc(l)),Qt=h.i32_const(t.alloc(l)),qt=h.i32_const(t.alloc(l)),Pt=h.i32_const(t.alloc(l)),jt=h.i32_const(t.alloc(l));_.addCode(h.call(x+"_mul",D,W,Pt),h.call(x+"_mulNR",W,wt),h.call(x+"_add",D,wt,wt),h.call(x+"_add",D,W,jt),h.call(x+"_mul",jt,wt,wt),h.call(x+"_mulNR",Pt,jt),h.call(x+"_add",Pt,jt,jt),h.call(x+"_sub",wt,jt,wt),h.call(x+"_add",Pt,Pt,Rt),h.call(x+"_mul",ot,Q,Pt),h.call(x+"_mulNR",Q,Dt),h.call(x+"_add",ot,Dt,Dt),h.call(x+"_add",ot,Q,jt),h.call(x+"_mul",jt,Dt,Dt),h.call(x+"_mulNR",Pt,jt),h.call(x+"_add",Pt,jt,jt),h.call(x+"_sub",Dt,jt,Dt),h.call(x+"_add",Pt,Pt,Yt),h.call(x+"_mul",Z,st,Pt),h.call(x+"_mulNR",st,Qt),h.call(x+"_add",Z,Qt,Qt),h.call(x+"_add",Z,st,jt),h.call(x+"_mul",jt,Qt,Qt),h.call(x+"_mulNR",Pt,jt),h.call(x+"_add",Pt,jt,jt),h.call(x+"_sub",Qt,jt,Qt),h.call(x+"_add",Pt,Pt,qt),h.call(x+"_sub",wt,D,ut),h.call(x+"_add",ut,ut,ut),h.call(x+"_add",wt,ut,ut),h.call(x+"_add",Rt,W,Ut),h.call(x+"_add",Ut,Ut,Ut),h.call(x+"_add",Rt,Ut,Ut),h.call(x+"_mul",qt,h.i32_const(Lt),jt),h.call(x+"_add",jt,ot,pt),h.call(x+"_add",pt,pt,pt),h.call(x+"_add",jt,pt,pt),h.call(x+"_sub",Qt,Q,rt),h.call(x+"_add",rt,rt,rt),h.call(x+"_add",Qt,rt,rt),h.call(x+"_sub",Dt,Z,dt),h.call(x+"_add",dt,dt,dt),h.call(x+"_add",Dt,dt,dt),h.call(x+"_add",Yt,st,St),h.call(x+"_add",St,St,St),h.call(x+"_add",Yt,St,St))}function ie(_,h,D){const Z=J(_).map(rt=>rt==-1?255:rt),Q=t.alloc(Z),ot=t.addFunction(i+"__cyclotomicExp_"+D);ot.addParam("x","i32"),ot.addParam("r","i32"),ot.addLocal("bit","i32"),ot.addLocal("i","i32");const W=ot.getCodeBuilder(),st=W.getLocal("x"),ut=W.getLocal("r"),dt=W.i32_const(t.alloc(s));ot.addCode(W.call(ft+"_conjugate",st,dt),W.call(ft+"_one",ut),W.if(W.teeLocal("bit",W.i32_load8_s(W.i32_const(Z.length-1),Q)),W.if(W.i32_eq(W.getLocal("bit"),W.i32_const(1)),W.call(ft+"_mul",ut,st,ut),W.call(ft+"_mul",ut,dt,ut))),W.setLocal("i",W.i32_const(Z.length-2)),W.block(W.loop(W.call(i+"__cyclotomicSquare",ut,ut),W.if(W.teeLocal("bit",W.i32_load8_s(W.getLocal("i"),Q)),W.if(W.i32_eq(W.getLocal("bit"),W.i32_const(1)),W.call(ft+"_mul",ut,st,ut),W.call(ft+"_mul",ut,dt,ut))),W.br_if(1,W.i32_eqz(W.getLocal("i"))),W.setLocal("i",W.i32_sub(W.getLocal("i"),W.i32_const(1))),W.br(0)))),ot.addCode(W.call(ft+"_conjugate",ut,ut))}function ae(){Jt(),ie(b,U,"w0");const _=t.addFunction(i+"_finalExponentiation");_.addParam("x","i32"),_.addParam("r","i32");const h=_.getCodeBuilder(),D=h.getLocal("x"),Z=h.getLocal("r"),Q=h.i32_const(t.alloc(s)),ot=h.i32_const(t.alloc(s)),W=h.i32_const(t.alloc(s)),st=h.i32_const(t.alloc(s)),ut=h.i32_const(t.alloc(s)),dt=h.i32_const(t.alloc(s)),rt=h.i32_const(t.alloc(s));_.addCode(h.call(ft+"_frobeniusMap6",D,Q),h.call(ft+"_inverse",D,ot),h.call(ft+"_mul",Q,ot,W),h.call(ft+"_copy",W,ot),h.call(ft+"_frobeniusMap2",W,W),h.call(ft+"_mul",W,ot,W),h.call(i+"__cyclotomicSquare",W,ot),h.call(ft+"_conjugate",ot,ot),h.call(i+"__cyclotomicExp_w0",W,st),h.call(i+"__cyclotomicSquare",st,ut),h.call(ft+"_mul",ot,st,dt),h.call(i+"__cyclotomicExp_w0",dt,ot),h.call(i+"__cyclotomicExp_w0",ot,Q),h.call(i+"__cyclotomicExp_w0",Q,rt),h.call(ft+"_mul",rt,ut,rt),h.call(i+"__cyclotomicExp_w0",rt,ut),h.call(ft+"_conjugate",dt,dt),h.call(ft+"_mul",ut,dt,ut),h.call(ft+"_mul",ut,W,ut),h.call(ft+"_conjugate",W,dt),h.call(ft+"_mul",ot,W,ot),h.call(ft+"_frobeniusMap3",ot,ot),h.call(ft+"_mul",rt,dt,rt),h.call(ft+"_frobeniusMap1",rt,rt),h.call(ft+"_mul",st,Q,st),h.call(ft+"_frobeniusMap2",st,st),h.call(ft+"_mul",st,ot,st),h.call(ft+"_mul",st,rt,st),h.call(ft+"_mul",st,ut,Z))}function B(){const _=t.addFunction(i+"_finalExponentiationOld");_.addParam("x","i32"),_.addParam("r","i32");const D=t.alloc(Kt.bigInt2BytesLE(322277361516934140462891564586510139908379969514828494218366688025288661041104682794998680497580008899973249814104447692778988208376779573819485263026159588510513834876303014016798809919343532899164848730280942609956670917565618115867287399623286813270357901731510188149934363360381614501334086825442271920079363289954510565375378443704372994881406797882676971082200626541916413184642520269678897559532260949334760604962086348898118982248842634379637598665468817769075878555493752214492790122785850202957575200176084204422751485957336465472324810982833638490904279282696134323072515220044451592646885410572234451732790590013479358343841220074174848221722017083597872017638514103174122784843925578370430843522959600095676285723737049438346544753168912974976791528535276317256904336520179281145394686565050419250614107803233314658825463117900250701199181529205942363159325765991819433914303908860460720581408201373164047773794825411011922305820065611121544561808414055302212057471395719432072209245600258134364584636810093520285711072578721435517884103526483832733289802426157301542744476740008494780363354305116978805620671467071400711358839553375340724899735460480144599782014906586543813292157922220645089192130209334926661588737007768565838519456601560804957985667880395221049249803753582637708560n,544)),Z=_.getCodeBuilder();_.addCode(Z.call(ft+"_exp",Z.getLocal("x"),Z.i32_const(D),Z.i32_const(544),Z.getLocal("r")))}const p=t.alloc(d),y=t.alloc(G);function O(_){const h=t.addFunction(i+"_pairingEq"+_);for(let ot=0;ot<_;ot++)h.addParam("p_"+ot,"i32"),h.addParam("q_"+ot,"i32");h.addParam("c","i32"),h.setReturnType("i32");const D=h.getCodeBuilder(),Z=D.i32_const(t.alloc(s)),Q=D.i32_const(t.alloc(s));h.addCode(D.call(ft+"_one",Z));for(let ot=0;ot<_;ot++)h.addCode(D.call(i+"_prepareG1",D.getLocal("p_"+ot),D.i32_const(p))),h.addCode(D.call(i+"_prepareG2",D.getLocal("q_"+ot),D.i32_const(y))),h.addCode(D.if(D.i32_eqz(D.call(R+"_inGroupAffine",D.i32_const(p))),D.ret(D.i32_const(0))),D.if(D.i32_eqz(D.call(z+"_inGroupAffine",D.i32_const(y))),D.ret(D.i32_const(0)))),h.addCode(D.call(i+"_millerLoop",D.i32_const(p),D.i32_const(y),Q)),h.addCode(D.call(ft+"_mul",Z,Q,Z));h.addCode(D.call(i+"_finalExponentiation",Z,Z)),h.addCode(D.call(ft+"_eq",Z,D.getLocal("c")))}function H(){const _=t.addFunction(i+"_pairing");_.addParam("p","i32"),_.addParam("q","i32"),_.addParam("r","i32");const h=_.getCodeBuilder(),D=h.i32_const(t.alloc(s));_.addCode(h.call(i+"_prepareG1",h.getLocal("p"),h.i32_const(p))),_.addCode(h.call(i+"_prepareG2",h.getLocal("q"),h.i32_const(y))),_.addCode(h.call(i+"_millerLoop",h.i32_const(p),h.i32_const(y),D)),_.addCode(h.call(i+"_finalExponentiation",D,h.getLocal("r")))}function nt(){const _=t.addFunction(z+"_inGroupAffine");_.addParam("p","i32"),_.setReturnType("i32");const h=_.getCodeBuilder(),D=[2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279894n,2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279893n],Z=4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,Q=[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],ot=h.i32_const(t.alloc([...Kt.bigInt2BytesLE(v(D[0]),r),...Kt.bigInt2BytesLE(v(D[1]),r)])),W=h.i32_const(t.alloc(Kt.bigInt2BytesLE(v(Z),r))),st=h.i32_const(t.alloc([...Kt.bigInt2BytesLE(v(Q[0]),r),...Kt.bigInt2BytesLE(v(Q[1]),r)])),ut=h.i32_const(t.alloc(Kt.bigInt2BytesLE(b,8))),dt=h.getLocal("p"),rt=h.i32_add(h.getLocal("p"),h.i32_const(l)),pt=h.i32_const(t.alloc(I)),Ut=h.i32_const(t.alloc(l)),St=h.i32_const(t.alloc(l)),wt=t.alloc(l*2),Rt=h.i32_const(wt),Dt=h.i32_const(wt),Yt=h.i32_const(wt),Qt=h.i32_const(wt+I),qt=h.i32_const(wt+l),Pt=h.i32_const(wt+l),jt=h.i32_const(wt+l+I),ue=t.alloc(l*3),ge=h.i32_const(ue),je=h.i32_const(ue),Se=h.i32_const(ue),Oe=h.i32_const(ue+I),We=h.i32_const(ue+l),Ue=h.i32_const(ue+l),Pe=h.i32_const(ue+l+I),Xe=h.i32_const(ue+l*2);_.addCode(h.if(h.call(z+"_isZeroAffine",h.getLocal("p")),h.ret(h.i32_const(1))),h.if(h.i32_eqz(h.call(z+"_inCurveAffine",h.getLocal("p"))),h.ret(h.i32_const(0))),h.call(x+"_mul",dt,ot,Ut),h.call(x+"_mul",rt,ot,St),h.call(x+"_mul1",Ut,W,Dt),h.call(x+"_neg",St,qt),h.call(x+"_neg",Ut,je),h.call(x+"_mul",St,st,We),h.call($+"_sub",Yt,Qt,pt),h.call($+"_add",Yt,Qt,Qt),h.call($+"_copy",pt,Yt),h.call($+"_sub",Pt,jt,pt),h.call($+"_add",Pt,jt,jt),h.call($+"_copy",pt,Pt),h.call($+"_add",Se,Oe,pt),h.call($+"_sub",Se,Oe,Oe),h.call($+"_copy",pt,Se),h.call($+"_sub",Pe,Ue,pt),h.call($+"_add",Ue,Pe,Pe),h.call($+"_copy",pt,Ue),h.call(x+"_one",Xe),h.call(z+"_timesScalar",ge,ut,h.i32_const(8),ge),h.call(z+"_addMixed",ge,Rt,ge),h.ret(h.call(z+"_eqMixed",ge,h.getLocal("p"))));const Fe=t.addFunction(z+"_inGroup");Fe.addParam("pIn","i32"),Fe.setReturnType("i32");const Ce=Fe.getCodeBuilder(),Qe=Ce.i32_const(t.alloc(l*2));Fe.addCode(Ce.call(z+"_toAffine",Ce.getLocal("pIn"),Qe),Ce.ret(Ce.call(z+"_inGroupAffine",Qe)))}function k(){const _=t.addFunction(R+"_inGroupAffine");_.addParam("p","i32"),_.setReturnType("i32");const h=_.getCodeBuilder(),D=4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,Z=793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,Q=(b*b-1n)/3n,ot=h.i32_const(t.alloc(Kt.bigInt2BytesLE(v(D),r))),W=h.i32_const(t.alloc(Kt.bigInt2BytesLE(v(Z),r))),st=h.i32_const(t.alloc(Kt.bigInt2BytesLE(Q,16))),ut=h.getLocal("p"),dt=h.i32_add(h.getLocal("p"),h.i32_const(I)),rt=t.alloc(I*3),pt=h.i32_const(rt),Ut=h.i32_const(rt),St=h.i32_const(rt+I),wt=t.alloc(I*2),Rt=h.i32_const(wt),Dt=h.i32_const(wt),Yt=h.i32_const(wt+I);_.addCode(h.if(h.call(R+"_isZeroAffine",h.getLocal("p")),h.ret(h.i32_const(1))),h.if(h.i32_eqz(h.call(R+"_inCurveAffine",h.getLocal("p"))),h.ret(h.i32_const(0))),h.call($+"_mul",ut,ot,Ut),h.call($+"_copy",dt,St),h.call($+"_mul",ut,W,Dt),h.call($+"_copy",dt,Yt),h.call(R+"_doubleAffine",pt,pt),h.call(R+"_subMixed",pt,h.getLocal("p"),pt),h.call(R+"_subMixed",pt,Rt,pt),h.call(R+"_timesScalar",pt,st,h.i32_const(16),pt),h.ret(h.call(R+"_eqMixed",pt,Rt)));const Qt=t.addFunction(R+"_inGroup");Qt.addParam("pIn","i32"),Qt.setReturnType("i32");const qt=Qt.getCodeBuilder(),Pt=qt.i32_const(t.alloc(I*2));Qt.addCode(qt.call(R+"_toAffine",qt.getLocal("pIn"),Pt),qt.ret(qt.call(R+"_inGroupAffine",Pt)))}for(let _=0;_<10;_++)$t(_),t.exportFunction(ft+"_frobeniusMap"+_);k(),nt(),zt(),At(),lt(),xt(),Ot(),B(),ae();for(let _=1;_<=5;_++)O(_),t.exportFunction(i+"_pairingEq"+_);H(),t.exportFunction(i+"_pairing"),t.exportFunction(i+"_prepareG1"),t.exportFunction(i+"_prepareG2"),t.exportFunction(i+"_millerLoop"),t.exportFunction(i+"_finalExponentiation"),t.exportFunction(i+"_finalExponentiationOld"),t.exportFunction(i+"__cyclotomicSquare"),t.exportFunction(i+"__cyclotomicExp_w0"),t.exportFunction(ct+"_mul1"),t.exportFunction(ct+"_mul01"),t.exportFunction(ft+"_mul014"),t.exportFunction(R+"_inGroupAffine"),t.exportFunction(R+"_inGroup"),t.exportFunction(z+"_inGroupAffine"),t.exportFunction(z+"_inGroup")},Jd=Kd,t2=Xd;function zo(n){if(typeof n=="bigint"||n.eq!==void 0)return n.toString(10);if(n instanceof Uint8Array)return si(n,0);if(Array.isArray(n))return n.map(zo);if(typeof n=="object"){const t={};return Object.keys(n).forEach(i=>{t[i]=zo(n[i])}),t}else return n}function Ro(n){if(typeof n=="string"&&/^[0-9]+$/.test(n))return BigInt(n);if(typeof n=="string"&&/^0x[0-9a-fA-F]+$/.test(n))return BigInt(n);if(Array.isArray(n))return n.map(Ro);if(typeof n=="object"){if(n===null)return null;const t={};return Object.keys(n).forEach(i=>{t[i]=Ro(n[i])}),t}else return n}function e2(n){let t=BigInt(0),e=n.length,i=0;const o=new DataView(n.buffer,n.byteOffset,n.byteLength);for(;e>0;)e>=4?(e-=4,t+=BigInt(o.getUint32(e))<<BigInt(i*8),i+=4):e>=2?(e-=2,t+=BigInt(o.getUint16(e))<<BigInt(i*8),i+=2):(e-=1,t+=BigInt(o.getUint8(e))<<BigInt(i*8),i+=1);return t}function n2(n,t){let e=n;const i=new Uint8Array(t),o=new DataView(i.buffer);let a=t;for(;a>0;)a-4>=0?(a-=4,o.setUint32(a,Number(e&BigInt(4294967295))),e=e>>BigInt(32)):a-2>=0?(a-=2,o.setUint16(a,Number(e&BigInt(65535))),e=e>>BigInt(16)):(a-=1,o.setUint8(a,Number(e&BigInt(255))),e=e>>BigInt(8));if(e)throw new Error("Number does not fit in this length");return i}function i2(n){let t=BigInt(0),e=0;const i=new DataView(n.buffer,n.byteOffset,n.byteLength);for(;e<n.length;)e+4<=n.length?(t+=BigInt(i.getUint32(e,!0))<<BigInt(e*8),e+=4):e+2<=n.length?(t+=BigInt(i.getUint16(e,!0))<<BigInt(e*8),e+=2):(t+=BigInt(i.getUint8(e,!0))<<BigInt(e*8),e+=1);return t}function Tr(n,t){let e=n;typeof t>"u"&&(t=Math.floor((Ai(n)-1)/8)+1,t==0&&(t=1));const i=new Uint8Array(t),o=new DataView(i.buffer);let a=0;for(;a<t;)a+4<=t?(o.setUint32(a,Number(e&BigInt(4294967295)),!0),a+=4,e=e>>BigInt(32)):a+2<=t?(o.setUint16(a,Number(e&BigInt(65535)),!0),a+=2,e=e>>BigInt(16)):(o.setUint8(a,Number(e&BigInt(255)),!0),a+=1,e=e>>BigInt(8));if(e)throw new Error("Number does not fit in this length");return i}function Qo(n,t){if(typeof t=="bigint"||t.eq!==void 0)return t.toString(10);if(t instanceof Uint8Array)return n.toString(n.e(t));if(Array.isArray(t))return t.map(Qo.bind(this,n));if(typeof t=="object"){const e={};return Object.keys(t).forEach(o=>{e[o]=Qo(n,t[o])}),e}else return t}function Do(n,t){if(typeof t=="string"&&/^[0-9]+$/.test(t))return n.e(t);if(typeof t=="string"&&/^0x[0-9a-fA-F]+$/.test(t))return n.e(t);if(Array.isArray(t))return t.map(Do.bind(this,n));if(typeof t=="object"){if(t===null)return null;const e={};return Object.keys(t).forEach(o=>{e[o]=Do(n,t[o])}),e}else return t}const ti=[];for(let n=0;n<256;n++)ti[n]=o2(n,8);function o2(n,t){let e=0,i=n;for(let o=0;o<t;o++)e<<=1,e=e|i&1,i>>=1;return e}function zr(n,t){return(ti[n>>>24]|ti[n>>>16&255]<<8|ti[n>>>8&255]<<16|ti[n&255]<<24)>>>32-t}function be(n){return(n&4294901760?(n&=4294901760,16):0)|(n&4278255360?(n&=4278255360,8):0)|(n&4042322160?(n&=4042322160,4):0)|(n&3435973836?(n&=3435973836,2):0)|(n&2863311530)!==0}function Rr(n,t){const e=n.byteLength/t,i=be(e);if(e!=1<<i)throw new Error("Invalid number of pointers");for(let o=0;o<e;o++){const a=zr(o,i);if(o>a){const u=n.slice(o*t,(o+1)*t);n.set(n.slice(a*t,(a+1)*t),o*t),n.set(u,a*t)}}}function _a(n,t){const e=new Uint8Array(t*n.length);for(let i=0;i<n.length;i++)e.set(n[i],i*t);return e}function Ni(n,t){const e=n.byteLength/t,i=new Array(e);for(let o=0;o<e;o++)i[o]=n.slice(o*t,o*t+t);return i}var a2=Object.freeze({__proto__:null,array2buffer:_a,beBuff2int:e2,beInt2Buff:n2,bitReverse:zr,buffReverseBits:Rr,buffer2array:Ni,leBuff2int:i2,leInt2Buff:Tr,log2:be,stringifyBigInts:zo,stringifyFElements:Qo,unstringifyBigInts:Ro,unstringifyFElements:Do});const _e=1<<30;class ne{constructor(t){this.buffers=[],this.byteLength=t;for(let e=0;e<t;e+=_e){const i=Math.min(t-e,_e);this.buffers.push(new Uint8Array(i))}}slice(t,e){e===void 0&&(e=this.byteLength),t===void 0&&(t=0);const i=e-t,o=Math.floor(t/_e),a=Math.floor((t+i-1)/_e);if(o==a||i==0)return this.buffers[o].slice(t%_e,t%_e+i);let u,r=o,I=t%_e,l=i;for(;l>0;){const s=I+l>_e?_e-I:l,m=new Uint8Array(this.buffers[r].buffer,this.buffers[r].byteOffset+I,s);if(s==i)return m.slice();u||(i<=_e?u=new Uint8Array(i):u=new ne(i)),u.set(m,i-l),l=l-s,r++,I=0}return u}set(t,e){e===void 0&&(e=0);const i=t.byteLength;if(i==0)return;const o=Math.floor(e/_e),a=Math.floor((e+i-1)/_e);if(o==a)return t instanceof ne&&t.buffers.length==1?this.buffers[o].set(t.buffers[0],e%_e):this.buffers[o].set(t,e%_e);let u=o,r=e%_e,I=i;for(;I>0;){const l=r+I>_e?_e-r:I,s=t.slice(i-I,i-I+l);new Uint8Array(this.buffers[u].buffer,this.buffers[u].byteOffset+r,l).set(s),I=I-l,u++,r=0}}}function nn(n,t,e,i){return async function(a){const u=Math.floor(a.byteLength/e);if(u*e!==a.byteLength)throw new Error("Invalid buffer size");const r=Math.floor(u/n.concurrency),I=[];for(let C=0;C<n.concurrency;C++){let g;if(C<n.concurrency-1?g=r:g=u-C*r,g==0)continue;const $=[{cmd:"ALLOCSET",var:0,buff:a.slice(C*r*e,C*r*e+g*e)},{cmd:"ALLOC",var:1,len:i*g},{cmd:"CALL",fnName:t,params:[{var:0},{val:g},{var:1}]},{cmd:"GET",out:0,var:1,len:i*g}];I.push(n.queueAction($))}const l=await Promise.all(I);let s;a instanceof ne?s=new ne(u*i):s=new Uint8Array(u*i);let m=0;for(let C=0;C<l.length;C++)s.set(l[C][0],m),m+=l[C][0].byteLength;return s}}class Ha{constructor(t,e,i,o){if(this.tm=t,this.prefix=e,this.p=o,this.n8=i,this.type="F1",this.m=1,this.half=Mn(o,fn),this.bitLength=Ai(o),this.mask=Ze(Di(fn,this.bitLength),fn),this.pOp1=t.alloc(i),this.pOp2=t.alloc(i),this.pOp3=t.alloc(i),this.tm.instance.exports[e+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,this.n8),this.tm.instance.exports[e+"_one"](this.pOp1),this.one=this.tm.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.n64=Math.floor(i/8),this.n32=Math.floor(i/4),this.n64*8!=this.n8)throw new Error("n8 must be a multiple of 8");this.half=Mn(this.p,fn),this.nqr=this.two;let a=this.exp(this.nqr,this.half);for(;!this.eq(a,this.negone);)this.nqr=this.add(this.nqr,this.one),a=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let u=Ze(this.p,fn);for(;!oa(u);)this.s=this.s+1,u=Mn(u,fn);this.w=[],this.w[this.s]=this.exp(this.nqr,u);for(let r=this.s-1;r>=0;r--)this.w[r]=this.square(this.w[r+1]);if(!this.eq(this.w[0],this.one))throw new Error("Error calculating roots of unity");this.batchToMontgomery=nn(t,e+"_batchToMontgomery",this.n8,this.n8),this.batchFromMontgomery=nn(t,e+"_batchFromMontgomery",this.n8,this.n8)}op2(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,e){return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,e){return this.tm.setBuff(this.pOp1,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,e){return this.op2("_add",t,e)}eq(t,e){return this.op2Bool("_eq",t,e)}isZero(t){return this.op1Bool("_isZero",t)}sub(t,e){return this.op2("_sub",t,e)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,e){return this.op2("_mul",t,e)}div(t,e){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,e){return e instanceof Uint8Array||(e=zn(se(e))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,e.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}isNegative(t){return this.op1Bool("_isNegative",t)}e(t,e){if(t instanceof Uint8Array)return t;let i=se(t,e);dr(i)?(i=hr(i),To(i,this.p)&&(i=ke(i,this.p)),i=Ze(this.p,i)):To(i,this.p)&&(i=ke(i,this.p));const o=Tr(i,this.n8);return this.toMontgomery(o)}toString(t,e){const i=this.fromMontgomery(t),o=si(i,0);return br(o,e)}fromRng(t){let e;const i=new Uint8Array(this.n8);do{e=yr;for(let o=0;o<this.n64;o++)e=aa(e,Di(t.nextU64(),64*o));e=ca(e,this.mask)}while(pr(e,this.p));return ri(i,0,e,this.n8),i}random(){return this.fromRng(ra())}toObject(t){const e=this.fromMontgomery(t);return si(e,0)}fromObject(t){const e=new Uint8Array(this.n8);return ri(e,0,t,this.n8),this.toMontgomery(e)}toRprLE(t,e,i){t.set(this.fromMontgomery(i),e)}toRprBE(t,e,i){const o=this.fromMontgomery(i);for(let a=0;a<this.n8/2;a++){const u=o[a];o[a]=o[this.n8-1-a],o[this.n8-1-a]=u}t.set(o,e)}fromRprLE(t,e){e=e||0;const i=t.slice(e,e+this.n8);return this.toMontgomery(i)}async batchInverse(t){let e=!1;const i=this.n8,o=this.n8;Array.isArray(t)?(t=_a(t,i),e=!0):t=t.slice(0,t.byteLength);const a=Math.floor(t.byteLength/i);if(a*i!==t.byteLength)throw new Error("Invalid buffer size");const u=Math.floor(a/this.tm.concurrency),r=[];for(let m=0;m<this.tm.concurrency;m++){let C;if(m<this.tm.concurrency-1?C=u:C=a-m*u,C==0)continue;const M=[{cmd:"ALLOCSET",var:0,buff:t.slice(m*u*i,m*u*i+C*i)},{cmd:"ALLOC",var:1,len:o*C},{cmd:"CALL",fnName:this.prefix+"_batchInverse",params:[{var:0},{val:i},{val:C},{var:1},{val:o}]},{cmd:"GET",out:0,var:1,len:o*C}];r.push(this.tm.queueAction(M))}const I=await Promise.all(r);let l;t instanceof ne?l=new ne(a*o):l=new Uint8Array(a*o);let s=0;for(let m=0;m<I.length;m++)l.set(I[m][0],s),s+=I[m][0].byteLength;return e?Ni(l,o):l}}class Za{constructor(t,e,i){this.tm=t,this.prefix=e,this.F=i,this.type="F2",this.m=i.m*2,this.n8=this.F.n8*2,this.n32=this.F.n32*2,this.n64=this.F.n64*2,this.pOp1=t.alloc(i.n8*2),this.pOp2=t.alloc(i.n8*2),this.pOp3=t.alloc(i.n8*2),this.tm.instance.exports[e+"_zero"](this.pOp1),this.zero=t.getBuff(this.pOp1,this.n8),this.tm.instance.exports[e+"_one"](this.pOp1),this.one=t.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,e){return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,e){return this.tm.setBuff(this.pOp1,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,e){return this.op2("_add",t,e)}eq(t,e){return this.op2Bool("_eq",t,e)}isZero(t){return this.op1Bool("_isZero",t)}sub(t,e){return this.op2("_sub",t,e)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}isNegative(t){return this.op1Bool("_isNegative",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,e){return this.op2("_mul",t,e)}mul1(t,e){return this.op2("_mul1",t,e)}div(t,e){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,e){return e instanceof Uint8Array||(e=zn(se(e))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,e.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}e(t,e){if(t instanceof Uint8Array)return t;if(Array.isArray(t)&&t.length==2){const i=this.F.e(t[0],e),o=this.F.e(t[1],e),a=new Uint8Array(this.F.n8*2);return a.set(i),a.set(o,this.F.n8*2),a}else throw new Error("invalid F2")}toString(t,e){const i=this.F.toString(t.slice(0,this.F.n8),e),o=this.F.toString(t.slice(this.F.n8),e);return`[${i}, ${o}]`}fromRng(t){const e=this.F.fromRng(t),i=this.F.fromRng(t),o=new Uint8Array(this.F.n8*2);return o.set(e),o.set(i,this.F.n8),o}random(){return this.fromRng(ra())}toObject(t){const e=this.F.toObject(t.slice(0,this.F.n8)),i=this.F.toObject(t.slice(this.F.n8,this.F.n8*2));return[e,i]}fromObject(t){const e=new Uint8Array(this.F.n8*2),i=this.F.fromObject(t[0]),o=this.F.fromObject(t[1]);return e.set(i),e.set(o,this.F.n8),e}c1(t){return t.slice(0,this.F.n8)}c2(t){return t.slice(this.F.n8)}}class c2{constructor(t,e,i){this.tm=t,this.prefix=e,this.F=i,this.type="F3",this.m=i.m*3,this.n8=this.F.n8*3,this.n32=this.F.n32*3,this.n64=this.F.n64*3,this.pOp1=t.alloc(i.n8*3),this.pOp2=t.alloc(i.n8*3),this.pOp3=t.alloc(i.n8*3),this.tm.instance.exports[e+"_zero"](this.pOp1),this.zero=t.getBuff(this.pOp1,this.n8),this.tm.instance.exports[e+"_one"](this.pOp1),this.one=t.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2)}op1(t,e){return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(t,e){return this.tm.setBuff(this.pOp1,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}eq(t,e){return this.op2Bool("_eq",t,e)}isZero(t){return this.op1Bool("_isZero",t)}add(t,e){return this.op2("_add",t,e)}sub(t,e){return this.op2("_sub",t,e)}neg(t){return this.op1("_neg",t)}inv(t){return this.op1("_inverse",t)}isNegative(t){return this.op1Bool("_isNegative",t)}toMontgomery(t){return this.op1("_toMontgomery",t)}fromMontgomery(t){return this.op1("_fromMontgomery",t)}mul(t,e){return this.op2("_mul",t,e)}div(t,e){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_inverse"](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+"_mul"](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(t){return this.op1("_square",t)}isSquare(t){return this.op1Bool("_isSquare",t)}sqrt(t){return this.op1("_sqrt",t)}exp(t,e){return e instanceof Uint8Array||(e=zn(se(e))),this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[this.prefix+"_exp"](this.pOp1,this.pOp2,e.byteLength,this.pOp3),this.getBuff(this.pOp3,this.n8)}e(t,e){if(t instanceof Uint8Array)return t;if(Array.isArray(t)&&t.length==3){const i=this.F.e(t[0],e),o=this.F.e(t[1],e),a=this.F.e(t[2],e),u=new Uint8Array(this.F.n8*3);return u.set(i),u.set(o,this.F.n8),u.set(a,this.F.n8*2),u}else throw new Error("invalid F3")}toString(t,e){const i=this.F.toString(t.slice(0,this.F.n8),e),o=this.F.toString(t.slice(this.F.n8,this.F.n8*2),e),a=this.F.toString(t.slice(this.F.n8*2),e);return`[${i}, ${o}, ${a}]`}fromRng(t){const e=this.F.fromRng(t),i=this.F.fromRng(t),o=this.F.fromRng(t),a=new Uint8Array(this.F.n8*3);return a.set(e),a.set(i,this.F.n8),a.set(o,this.F.n8*2),a}random(){return this.fromRng(ra())}toObject(t){const e=this.F.toObject(t.slice(0,this.F.n8)),i=this.F.toObject(t.slice(this.F.n8,this.F.n8*2)),o=this.F.toObject(t.slice(this.F.n8*2,this.F.n8*3));return[e,i,o]}fromObject(t){const e=new Uint8Array(this.F.n8*3),i=this.F.fromObject(t[0]),o=this.F.fromObject(t[1]),a=this.F.fromObject(t[2]);return e.set(i),e.set(o,this.F.n8),e.set(a,this.F.n8*2),e}c1(t){return t.slice(0,this.F.n8)}c2(t){return t.slice(this.F.n8,this.F.n8*2)}c3(t){return t.slice(this.F.n8*2)}}class Ya{constructor(t,e,i,o,a,u){this.tm=t,this.prefix=e,this.F=i,this.pOp1=t.alloc(i.n8*3),this.pOp2=t.alloc(i.n8*3),this.pOp3=t.alloc(i.n8*3),this.tm.instance.exports[e+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,i.n8*3),this.tm.instance.exports[e+"_zeroAffine"](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,i.n8*2),this.one=this.tm.getBuff(o,i.n8*3),this.g=this.one,this.oneAffine=this.tm.getBuff(o,i.n8*2),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(a,i.n8),u&&(this.cofactor=zn(u)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=nn(t,e+"_batchLEMtoC",i.n8*2,i.n8),this.batchLEMtoU=nn(t,e+"_batchLEMtoU",i.n8*2,i.n8*2),this.batchCtoLEM=nn(t,e+"_batchCtoLEM",i.n8,i.n8*2),this.batchUtoLEM=nn(t,e+"_batchUtoLEM",i.n8*2,i.n8*2),this.batchToJacobian=nn(t,e+"_batchToJacobian",i.n8*2,i.n8*3),this.batchToAffine=nn(t,e+"_batchToAffine",i.n8*3,i.n8*2)}op2(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op2bool(t,e,i){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,i),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3)}op1(t,e){return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op1Affine(t,e){return this.tm.setBuff(this.pOp1,e),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*2)}op1Bool(t,e){return this.tm.setBuff(this.pOp1,e),!!this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp3)}add(t,e){if(t.byteLength==this.F.n8*3){if(e.byteLength==this.F.n8*3)return this.op2("_add",t,e);if(e.byteLength==this.F.n8*2)return this.op2("_addMixed",t,e);throw new Error("invalid point size")}else if(t.byteLength==this.F.n8*2){if(e.byteLength==this.F.n8*3)return this.op2("_addMixed",e,t);if(e.byteLength==this.F.n8*2)return this.op2("_addAffine",t,e);throw new Error("invalid point size")}else throw new Error("invalid point size")}sub(t,e){if(t.byteLength==this.F.n8*3){if(e.byteLength==this.F.n8*3)return this.op2("_sub",t,e);if(e.byteLength==this.F.n8*2)return this.op2("_subMixed",t,e);throw new Error("invalid point size")}else if(t.byteLength==this.F.n8*2){if(e.byteLength==this.F.n8*3)return this.op2("_subMixed",e,t);if(e.byteLength==this.F.n8*2)return this.op2("_subAffine",t,e);throw new Error("invalid point size")}else throw new Error("invalid point size")}neg(t){if(t.byteLength==this.F.n8*3)return this.op1("_neg",t);if(t.byteLength==this.F.n8*2)return this.op1Affine("_negAffine",t);throw new Error("invalid point size")}double(t){if(t.byteLength==this.F.n8*3)return this.op1("_double",t);if(t.byteLength==this.F.n8*2)return this.op1("_doubleAffine",t);throw new Error("invalid point size")}isZero(t){if(t.byteLength==this.F.n8*3)return this.op1Bool("_isZero",t);if(t.byteLength==this.F.n8*2)return this.op1Bool("_isZeroAffine",t);throw new Error("invalid point size")}timesScalar(t,e){e instanceof Uint8Array||(e=zn(se(e)));let i;if(t.byteLength==this.F.n8*3)i=this.prefix+"_timesScalar";else if(t.byteLength==this.F.n8*2)i=this.prefix+"_timesScalarAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[i](this.pOp1,this.pOp2,e.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}timesFr(t,e){let i;if(t.byteLength==this.F.n8*3)i=this.prefix+"_timesFr";else if(t.byteLength==this.F.n8*2)i=this.prefix+"_timesFrAffine";else throw new Error("invalid point size");return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,e),this.tm.instance.exports[i](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}eq(t,e){if(t.byteLength==this.F.n8*3){if(e.byteLength==this.F.n8*3)return this.op2bool("_eq",t,e);if(e.byteLength==this.F.n8*2)return this.op2bool("_eqMixed",t,e);throw new Error("invalid point size")}else if(t.byteLength==this.F.n8*2){if(e.byteLength==this.F.n8*3)return this.op2bool("_eqMixed",e,t);if(e.byteLength==this.F.n8*2)return this.op2bool("_eqAffine",t,e);throw new Error("invalid point size")}else throw new Error("invalid point size")}toAffine(t){if(t.byteLength==this.F.n8*3)return this.op1Affine("_toAffine",t);if(t.byteLength==this.F.n8*2)return t;throw new Error("invalid point size")}toJacobian(t){if(t.byteLength==this.F.n8*3)return t;if(t.byteLength==this.F.n8*2)return this.op1("_toJacobian",t);throw new Error("invalid point size")}toRprUncompressed(t,e,i){if(this.tm.setBuff(this.pOp1,i),i.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(i.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoU"](this.pOp1,this.pOp1);const o=this.tm.getBuff(this.pOp1,this.F.n8*2);t.set(o,e)}fromRprUncompressed(t,e){const i=t.slice(e,e+this.F.n8*2);return this.tm.setBuff(this.pOp1,i),this.tm.instance.exports[this.prefix+"_UtoLEM"](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,this.F.n8*2)}toRprCompressed(t,e,i){if(this.tm.setBuff(this.pOp1,i),i.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(i.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoC"](this.pOp1,this.pOp1);const o=this.tm.getBuff(this.pOp1,this.F.n8);t.set(o,e)}fromRprCompressed(t,e){const i=t.slice(e,e+this.F.n8);return this.tm.setBuff(this.pOp1,i),this.tm.instance.exports[this.prefix+"_CtoLEM"](this.pOp1,this.pOp2),this.tm.getBuff(this.pOp2,this.F.n8*2)}toUncompressed(t){const e=new Uint8Array(this.F.n8*2);return this.toRprUncompressed(e,0,t),e}toRprLEM(t,e,i){if(i.byteLength==this.F.n8*2){t.set(i,e);return}else if(i.byteLength==this.F.n8*3){this.tm.setBuff(this.pOp1,i),this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);const o=this.tm.getBuff(this.pOp1,this.F.n8*2);t.set(o,e)}else throw new Error("invalid point size")}fromRprLEM(t,e){return e=e||0,t.slice(e,e+this.F.n8*2)}toString(t,e){if(t.byteLength==this.F.n8*3){const i=this.F.toString(t.slice(0,this.F.n8),e),o=this.F.toString(t.slice(this.F.n8,this.F.n8*2),e),a=this.F.toString(t.slice(this.F.n8*2),e);return`[ ${i}, ${o}, ${a} ]`}else if(t.byteLength==this.F.n8*2){const i=this.F.toString(t.slice(0,this.F.n8),e),o=this.F.toString(t.slice(this.F.n8),e);return`[ ${i}, ${o} ]`}else throw new Error("invalid point size")}isValid(t){if(this.isZero(t))return!0;const e=this.F,i=this.toAffine(t),o=i.slice(0,this.F.n8),a=i.slice(this.F.n8,this.F.n8*2),u=e.add(e.mul(e.square(o),o),this.b),r=e.square(a);return e.eq(u,r)}fromRng(t){const e=this.F;let i=[],o,a;do i[0]=e.fromRng(t),o=t.nextBool(),a=e.add(e.mul(e.square(i[0]),i[0]),this.b);while(!e.isSquare(a));i[1]=e.sqrt(a);const u=e.isNegative(i[1]);o^u&&(i[1]=e.neg(i[1]));let r=new Uint8Array(this.F.n8*2);return r.set(i[0]),r.set(i[1],this.F.n8),this.cofactor&&(r=this.timesScalar(r,this.cofactor)),r}toObject(t){if(this.isZero(t))return[this.F.toObject(this.F.zero),this.F.toObject(this.F.one),this.F.toObject(this.F.zero)];const e=this.F.toObject(t.slice(0,this.F.n8)),i=this.F.toObject(t.slice(this.F.n8,this.F.n8*2));let o;return t.byteLength==this.F.n8*3?o=this.F.toObject(t.slice(this.F.n8*2,this.F.n8*3)):o=this.F.toObject(this.F.one),[e,i,o]}fromObject(t){const e=this.F.fromObject(t[0]),i=this.F.fromObject(t[1]);let o;if(t.length==3?o=this.F.fromObject(t[2]):o=this.F.one,this.F.isZero(o,this.F.one))return this.zeroAffine;if(this.F.eq(o,this.F.one)){const a=new Uint8Array(this.F.n8*2);return a.set(e),a.set(i,this.F.n8),a}else{const a=new Uint8Array(this.F.n8*3);return a.set(e),a.set(i,this.F.n8),a.set(o,this.F.n8*2),a}}e(t){return t instanceof Uint8Array?t:this.fromObject(t)}x(t){return this.toAffine(t).slice(0,this.F.n8)}y(t){return this.toAffine(t).slice(this.F.n8)}}function r2(n){let e,i;async function o(s){const m=new Uint8Array(s.code),C=await WebAssembly.compile(m);i=new WebAssembly.Memory({initial:s.init,maximum:32767}),e=await WebAssembly.instantiate(C,{env:{memory:i}})}function a(s){const m=new Uint32Array(i.buffer,0,1);for(;m[0]&3;)m[0]++;const C=m[0];if(m[0]+=s,m[0]+s>i.buffer.byteLength){const g=i.buffer.byteLength/65536;let M=Math.floor((m[0]+s)/65536)+1;M>32767&&(M=32767),i.grow(M-g)}return C}function u(s){const m=a(s.byteLength);return I(m,s),m}function r(s,m){const C=new Uint8Array(i.buffer);return new Uint8Array(C.buffer,C.byteOffset+s,m)}function I(s,m){new Uint8Array(i.buffer).set(new Uint8Array(m),s)}function l(s){if(s[0].cmd=="INIT")return o(s[0]);const m={vars:[],out:[]},g=new Uint32Array(i.buffer,0,1)[0];for(let $=0;$<s.length;$++)switch(s[$].cmd){case"ALLOCSET":m.vars[s[$].var]=u(s[$].buff);break;case"ALLOC":m.vars[s[$].var]=a(s[$].len);break;case"SET":I(m.vars[s[$].var],s[$].buff);break;case"CALL":{const F=[];for(let R=0;R<s[$].params.length;R++){const x=s[$].params[R];typeof x.var<"u"?F.push(m.vars[x.var]+(x.offset||0)):typeof x.val<"u"&&F.push(x.val)}e.exports[s[$].fnName](...F);break}case"GET":m.out[s[$].out]=r(m.vars[s[$].var],s[$].len).slice();break;default:throw new Error("Invalid cmd")}const M=new Uint32Array(i.buffer,0,1);return M[0]=g,m.out}return l}const go=25;class Va{constructor(){this.promise=new Promise((t,e)=>{this.reject=e,this.resolve=t})}}function s2(n){return new Promise(t=>setTimeout(t,n))}let qo;const ja=`(function thread(self) {
|
|
12
|
-
const MAXMEM = 32767;
|
|
13
|
-
let instance;
|
|
14
|
-
let memory;
|
|
15
|
-
|
|
16
|
-
if (self) {
|
|
17
|
-
self.onmessage = function(e) {
|
|
18
|
-
let data;
|
|
19
|
-
if (e.data) {
|
|
20
|
-
data = e.data;
|
|
21
|
-
} else {
|
|
22
|
-
data = e;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (data[0].cmd == "INIT") {
|
|
26
|
-
init(data[0]).then(function() {
|
|
27
|
-
self.postMessage(data.result);
|
|
28
|
-
});
|
|
29
|
-
} else if (data[0].cmd == "TERMINATE") {
|
|
30
|
-
self.close();
|
|
31
|
-
} else {
|
|
32
|
-
const res = runTask(data);
|
|
33
|
-
self.postMessage(res);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function init(data) {
|
|
39
|
-
const code = new Uint8Array(data.code);
|
|
40
|
-
const wasmModule = await WebAssembly.compile(code);
|
|
41
|
-
memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM});
|
|
42
|
-
|
|
43
|
-
instance = await WebAssembly.instantiate(wasmModule, {
|
|
44
|
-
env: {
|
|
45
|
-
"memory": memory
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function alloc(length) {
|
|
53
|
-
const u32 = new Uint32Array(memory.buffer, 0, 1);
|
|
54
|
-
while (u32[0] & 3) u32[0]++; // Return always aligned pointers
|
|
55
|
-
const res = u32[0];
|
|
56
|
-
u32[0] += length;
|
|
57
|
-
if (u32[0] + length > memory.buffer.byteLength) {
|
|
58
|
-
const currentPages = memory.buffer.byteLength / 0x10000;
|
|
59
|
-
let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1;
|
|
60
|
-
if (requiredPages>MAXMEM) requiredPages=MAXMEM;
|
|
61
|
-
memory.grow(requiredPages-currentPages);
|
|
62
|
-
}
|
|
63
|
-
return res;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function allocBuffer(buffer) {
|
|
67
|
-
const p = alloc(buffer.byteLength);
|
|
68
|
-
setBuffer(p, buffer);
|
|
69
|
-
return p;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getBuffer(pointer, length) {
|
|
73
|
-
const u8 = new Uint8Array(memory.buffer);
|
|
74
|
-
return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function setBuffer(pointer, buffer) {
|
|
78
|
-
const u8 = new Uint8Array(memory.buffer);
|
|
79
|
-
u8.set(new Uint8Array(buffer), pointer);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function runTask(task) {
|
|
83
|
-
if (task[0].cmd == "INIT") {
|
|
84
|
-
return init(task[0]);
|
|
85
|
-
}
|
|
86
|
-
const ctx = {
|
|
87
|
-
vars: [],
|
|
88
|
-
out: []
|
|
89
|
-
};
|
|
90
|
-
const u32a = new Uint32Array(memory.buffer, 0, 1);
|
|
91
|
-
const oldAlloc = u32a[0];
|
|
92
|
-
for (let i=0; i<task.length; i++) {
|
|
93
|
-
switch (task[i].cmd) {
|
|
94
|
-
case "ALLOCSET":
|
|
95
|
-
ctx.vars[task[i].var] = allocBuffer(task[i].buff);
|
|
96
|
-
break;
|
|
97
|
-
case "ALLOC":
|
|
98
|
-
ctx.vars[task[i].var] = alloc(task[i].len);
|
|
99
|
-
break;
|
|
100
|
-
case "SET":
|
|
101
|
-
setBuffer(ctx.vars[task[i].var], task[i].buff);
|
|
102
|
-
break;
|
|
103
|
-
case "CALL": {
|
|
104
|
-
const params = [];
|
|
105
|
-
for (let j=0; j<task[i].params.length; j++) {
|
|
106
|
-
const p = task[i].params[j];
|
|
107
|
-
if (typeof p.var !== "undefined") {
|
|
108
|
-
params.push(ctx.vars[p.var] + (p.offset || 0));
|
|
109
|
-
} else if (typeof p.val != "undefined") {
|
|
110
|
-
params.push(p.val);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
instance.exports[task[i].fnName](...params);
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
case "GET":
|
|
117
|
-
ctx.out[task[i].out] = getBuffer(ctx.vars[task[i].var], task[i].len).slice();
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
throw new Error("Invalid cmd");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const u32b = new Uint32Array(memory.buffer, 0, 1);
|
|
124
|
-
u32b[0] = oldAlloc;
|
|
125
|
-
return ctx.out;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return runTask;
|
|
130
|
-
})(self)`;if(globalThis!=null&&globalThis.Blob){const n=new TextEncoder().encode(ja),t=new Blob([n],{type:"application/javascript"});qo=URL.createObjectURL(t)}else qo="data:application/javascript;base64,"+globalThis.btoa(ja);async function l2(n,t){const e=new d2;e.memory=new WebAssembly.Memory({initial:go}),e.u8=new Uint8Array(e.memory.buffer),e.u32=new Uint32Array(e.memory.buffer);const i=await WebAssembly.compile(n.code);if(e.instance=await WebAssembly.instantiate(i,{env:{memory:e.memory}}),globalThis!=null&&globalThis.Worker||(t=!0),e.singleThread=t,e.initalPFree=e.u32[0],e.pq=n.pq,e.pr=n.pr,e.pG1gen=n.pG1gen,e.pG1zero=n.pG1zero,e.pG2gen=n.pG2gen,e.pG2zero=n.pG2zero,e.pOneT=n.pOneT,t)e.code=n.code,e.taskManager=r2(),await e.taskManager([{cmd:"INIT",init:go,code:e.code.slice()}]),e.concurrency=1;else{e.workers=[],e.pendingDeferreds=[],e.working=[];let a=2;typeof navigator=="object"&&navigator.hardwareConcurrency&&(a=navigator.hardwareConcurrency),a==0&&(a=2),a>64&&(a=64),e.concurrency=a;for(let r=0;r<a;r++)e.workers[r]=new Worker(qo),e.workers[r].addEventListener("message",o(r)),e.working[r]=!1;const u=[];for(let r=0;r<e.workers.length;r++){const I=n.code.slice();u.push(e.postAction(r,[{cmd:"INIT",init:go,code:I}],[I.buffer]))}await Promise.all(u)}return e;function o(a){return function(u){let r;u&&u.data?r=u.data:r=u,e.working[a]=!1,e.pendingDeferreds[a].resolve(r),e.processWorks()}}}class d2{constructor(){this.actionQueue=[],this.oldPFree=0}startSyncOp(){if(this.oldPFree!=0)throw new Error("Sync operation in progress");this.oldPFree=this.u32[0]}endSyncOp(){if(this.oldPFree==0)throw new Error("No sync operation in progress");this.u32[0]=this.oldPFree,this.oldPFree=0}postAction(t,e,i,o){if(this.working[t])throw new Error("Posting a job t a working worker");return this.working[t]=!0,this.pendingDeferreds[t]=o||new Va,this.workers[t].postMessage(e,i),this.pendingDeferreds[t].promise}processWorks(){for(let t=0;t<this.workers.length&&this.actionQueue.length>0;t++)if(this.working[t]==!1){const e=this.actionQueue.shift();this.postAction(t,e.data,e.transfers,e.deferred)}}queueAction(t,e){const i=new Va;if(this.singleThread){const o=this.taskManager(t);i.resolve(o)}else this.actionQueue.push({data:t,transfers:e,deferred:i}),this.processWorks();return i.promise}resetMemory(){this.u32[0]=this.initalPFree}allocBuff(t){const e=this.alloc(t.byteLength);return this.setBuff(e,t),e}getBuff(t,e){return this.u8.slice(t,t+e)}setBuff(t,e){this.u8.set(new Uint8Array(e),t)}alloc(t){for(;this.u32[0]&3;)this.u32[0]++;const e=this.u32[0];return this.u32[0]+=t,e}async terminate(){for(let t=0;t<this.workers.length;t++)this.workers[t].postMessage([{cmd:"TERMINATE"}]);await s2(200)}}function po(n,t){const e=n[t],i=n.Fr,o=n.tm;n[t].batchApplyKey=async function(a,u,r,I,l){I=I||"affine",l=l||"affine";let s,m,C,g,M;if(t=="G1")I=="jacobian"?(C=e.F.n8*3,s="g1m_batchApplyKey"):(C=e.F.n8*2,s="g1m_batchApplyKeyMixed"),g=e.F.n8*3,l=="jacobian"?M=e.F.n8*3:(m="g1m_batchToAffine",M=e.F.n8*2);else if(t=="G2")I=="jacobian"?(C=e.F.n8*3,s="g2m_batchApplyKey"):(C=e.F.n8*2,s="g2m_batchApplyKeyMixed"),g=e.F.n8*3,l=="jacobian"?M=e.F.n8*3:(m="g2m_batchToAffine",M=e.F.n8*2);else if(t=="Fr")s="frm_batchApplyKey",C=e.n8,g=e.n8,M=e.n8;else throw new Error("Invalid group: "+t);const $=Math.floor(a.byteLength/C),F=Math.floor($/o.concurrency),R=[];r=i.e(r);let x=i.e(u);for(let v=0;v<o.concurrency;v++){let f;if(v<o.concurrency-1?f=F:f=$-v*F,f==0)continue;const L=[];L.push({cmd:"ALLOCSET",var:0,buff:a.slice(v*F*C,v*F*C+f*C)}),L.push({cmd:"ALLOCSET",var:1,buff:x}),L.push({cmd:"ALLOCSET",var:2,buff:r}),L.push({cmd:"ALLOC",var:3,len:f*Math.max(g,M)}),L.push({cmd:"CALL",fnName:s,params:[{var:0},{val:f},{var:1},{var:2},{var:3}]}),m&&L.push({cmd:"CALL",fnName:m,params:[{var:3},{val:f},{var:3}]}),L.push({cmd:"GET",out:0,var:3,len:f*M}),R.push(o.queueAction(L)),x=i.mul(x,i.exp(r,f))}const it=await Promise.all(R);let z;a instanceof ne?z=new ne($*M):z=new Uint8Array($*M);let K=0;for(let v=0;v<it.length;v++)z.set(it[v][0],K),K+=it[v][0].byteLength;return z}}function u2(n){const t=n.tm;n.pairing=function(i,o){t.startSyncOp();const a=t.allocBuff(n.G1.toJacobian(i)),u=t.allocBuff(n.G2.toJacobian(o)),r=t.alloc(n.Gt.n8);t.instance.exports[n.name+"_pairing"](a,u,r);const I=t.getBuff(r,n.Gt.n8);return t.endSyncOp(),I},n.pairingEq=async function(){let i,o;arguments.length%2==1?(i=arguments[arguments.length-1],o=(arguments.length-1)/2):(i=n.Gt.one,o=arguments.length/2);const a=[];for(let s=0;s<o;s++){const m=[],C=n.G1.toJacobian(arguments[s*2]);m.push({cmd:"ALLOCSET",var:0,buff:C}),m.push({cmd:"ALLOC",var:1,len:n.prePSize});const g=n.G2.toJacobian(arguments[s*2+1]);m.push({cmd:"ALLOCSET",var:2,buff:g}),m.push({cmd:"ALLOC",var:3,len:n.preQSize}),m.push({cmd:"ALLOC",var:4,len:n.Gt.n8}),m.push({cmd:"CALL",fnName:n.name+"_prepareG1",params:[{var:0},{var:1}]}),m.push({cmd:"CALL",fnName:n.name+"_prepareG2",params:[{var:2},{var:3}]}),m.push({cmd:"CALL",fnName:n.name+"_millerLoop",params:[{var:1},{var:3},{var:4}]}),m.push({cmd:"GET",out:0,var:4,len:n.Gt.n8}),a.push(t.queueAction(m))}const u=await Promise.all(a);t.startSyncOp();const r=t.alloc(n.Gt.n8);t.instance.exports.ftm_one(r);for(let s=0;s<u.length;s++){const m=t.allocBuff(u[s][0]);t.instance.exports.ftm_mul(r,m,r)}t.instance.exports[n.name+"_finalExponentiation"](r,r);const I=t.allocBuff(i),l=!!t.instance.exports.ftm_eq(r,I);return t.endSyncOp(),l},n.prepareG1=function(e){this.tm.startSyncOp();const i=this.tm.allocBuff(e),o=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+"_prepareG1"](i,o);const a=this.tm.getBuff(o,this.prePSize);return this.tm.endSyncOp(),a},n.prepareG2=function(e){this.tm.startSyncOp();const i=this.tm.allocBuff(e),o=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+"_prepareG2"](i,o);const a=this.tm.getBuff(o,this.preQSize);return this.tm.endSyncOp(),a},n.millerLoop=function(e,i){this.tm.startSyncOp();const o=this.tm.allocBuff(e),a=this.tm.allocBuff(i),u=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_millerLoop"](o,a,u);const r=this.tm.getBuff(u,this.Gt.n8);return this.tm.endSyncOp(),r},n.finalExponentiation=function(e){this.tm.startSyncOp();const i=this.tm.allocBuff(e),o=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_finalExponentiation"](i,o);const a=this.tm.getBuff(o,this.Gt.n8);return this.tm.endSyncOp(),a}}const Wa=[1,1,1,1,2,3,4,5,6,7,7,8,9,10,11,12,13,13,14,15,16,16,17,17,17,17,17,17,17,17,17,17];function Xa(n,t){const e=n[t],i=e.tm;async function o(u,r,I,l,s){if(!(u instanceof Uint8Array))throw l&&l.error(`${s} _multiExpChunk buffBases is not Uint8Array`),new Error(`${s} _multiExpChunk buffBases is not Uint8Array`);if(!(r instanceof Uint8Array))throw l&&l.error(`${s} _multiExpChunk buffScalars is not Uint8Array`),new Error(`${s} _multiExpChunk buffScalars is not Uint8Array`);I=I||"affine";let m,C;if(t=="G1")I=="affine"?(C="g1m_multiexpAffine_chunk",m=e.F.n8*2):(C="g1m_multiexp_chunk",m=e.F.n8*3);else if(t=="G2")I=="affine"?(C="g2m_multiexpAffine_chunk",m=e.F.n8*2):(C="g2m_multiexp_chunk",m=e.F.n8*3);else throw new Error("Invalid group");const g=Math.floor(u.byteLength/m);if(g==0)return e.zero;const M=Math.floor(r.byteLength/g);if(M*g!=r.byteLength)throw new Error("Scalar size does not match");const $=Wa[be(g)],F=Math.floor((M*8-1)/$)+1,R=[];for(let z=0;z<F;z++){const K=[{cmd:"ALLOCSET",var:0,buff:u},{cmd:"ALLOCSET",var:1,buff:r},{cmd:"ALLOC",var:2,len:e.F.n8*3},{cmd:"CALL",fnName:C,params:[{var:0},{var:1},{val:M},{val:g},{val:z*$},{val:Math.min(M*8-z*$,$)},{var:2}]},{cmd:"GET",out:0,var:2,len:e.F.n8*3}];R.push(e.tm.queueAction(K))}const x=await Promise.all(R);let it=e.zero;for(let z=x.length-1;z>=0;z--){if(!e.isZero(it))for(let K=0;K<$;K++)it=e.double(it);it=e.add(it,x[z][0])}return it}async function a(u,r,I,l,s){let g;if(t=="G1")I=="affine"?g=e.F.n8*2:g=e.F.n8*3;else if(t=="G2")I=="affine"?g=e.F.n8*2:g=e.F.n8*3;else throw new Error("Invalid group");const M=Math.floor(u.byteLength/g);if(M==0)return e.zero;const $=Math.floor(r.byteLength/M);if($*M!=r.byteLength)throw new Error("Scalar size does not match");const F=Wa[be(M)],R=Math.floor(($*8-1)/F)+1;let x;x=Math.floor(M/(i.concurrency/R)),x>4194304&&(x=4194304),x<1024&&(x=1024);const it=[];for(let v=0;v<M;v+=x){l&&l.debug(`Multiexp start: ${s}: ${v}/${M}`);const f=Math.min(M-v,x),L=u.slice(v*g,(v+f)*g),V=r.slice(v*$,(v+f)*$);it.push(o(L,V,I,l,s).then(X=>(l&&l.debug(`Multiexp end: ${s}: ${v}/${M}`),X)))}const z=await Promise.all(it);let K=e.zero;for(let v=z.length-1;v>=0;v--)K=e.add(K,z[v]);return K}e.multiExp=async function(r,I,l,s){return await a(r,I,"jacobian",l,s)},e.multiExpAffine=async function(r,I,l,s){return await a(r,I,"affine",l,s)}}function Lo(n,t){const e=n[t],i=n.Fr,o=e.tm;async function a(l,s,m,C,g,M){m=m||"affine",C=C||"affine";const $=14;let F,R,x,it,z,K,v,f;t=="G1"?(m=="affine"?(F=e.F.n8*2,it="g1m_batchToJacobian"):F=e.F.n8*3,R=e.F.n8*3,s&&(f="g1m_fftFinal"),v="g1m_fftJoin",K="g1m_fftMix",C=="affine"?(x=e.F.n8*2,z="g1m_batchToAffine"):x=e.F.n8*3):t=="G2"?(m=="affine"?(F=e.F.n8*2,it="g2m_batchToJacobian"):F=e.F.n8*3,R=e.F.n8*3,s&&(f="g2m_fftFinal"),v="g2m_fftJoin",K="g2m_fftMix",C=="affine"?(x=e.F.n8*2,z="g2m_batchToAffine"):x=e.F.n8*3):t=="Fr"&&(F=e.n8,R=e.n8,x=e.n8,s&&(f="frm_fftFinal"),K="frm_fftMix",v="frm_fftJoin");let L=!1;Array.isArray(l)?(l=_a(l,F),L=!0):l=l.slice(0,l.byteLength);const V=l.byteLength/F,X=be(V);if(1<<X!=V)throw new Error("fft must be multiple of 2");if(X==i.s+1){let ct;return s?ct=await r(l,m,C,g,M):ct=await u(l,m,C,g,M),L?Ni(ct,x):ct}let et;s&&(et=i.inv(i.e(V)));let N;Rr(l,F);let w,T=Math.min(1<<$,V),at=V/T;for(;at<o.concurrency&&T>=16;)at*=2,T/=2;const Lt=be(T),_t=[];for(let ct=0;ct<at;ct++){g&&g.debug(`${M}: fft ${X} mix start: ${ct}/${at}`);const yt=[];yt.push({cmd:"ALLOC",var:0,len:R*T});const ft=l.slice(T*ct*F,T*(ct+1)*F);yt.push({cmd:"SET",var:0,buff:ft}),it&&yt.push({cmd:"CALL",fnName:it,params:[{var:0},{val:T},{var:0}]});for(let ht=1;ht<=Lt;ht++)yt.push({cmd:"CALL",fnName:K,params:[{var:0},{val:T},{val:ht}]});Lt==X?(f&&(yt.push({cmd:"ALLOCSET",var:1,buff:et}),yt.push({cmd:"CALL",fnName:f,params:[{var:0},{val:T},{var:1}]})),z&&yt.push({cmd:"CALL",fnName:z,params:[{var:0},{val:T},{var:0}]}),yt.push({cmd:"GET",out:0,var:0,len:T*x})):yt.push({cmd:"GET",out:0,var:0,len:R*T}),_t.push(o.queueAction(yt).then(ht=>(g&&g.debug(`${M}: fft ${X} mix end: ${ct}/${at}`),ht)))}w=await Promise.all(_t);for(let ct=0;ct<at;ct++)w[ct]=w[ct][0];for(let ct=Lt+1;ct<=X;ct++){g&&g.debug(`${M}: fft ${X} join: ${ct}/${X}`);const yt=1<<X-ct,ft=at/yt,ht=[];for(let Nt=0;Nt<yt;Nt++)for(let kt=0;kt<ft/2;kt++){const A=i.exp(i.w[ct],kt*T),c=i.w[ct],E=Nt*ft+kt,d=Nt*ft+kt+ft/2,G=[];G.push({cmd:"ALLOCSET",var:0,buff:w[E]}),G.push({cmd:"ALLOCSET",var:1,buff:w[d]}),G.push({cmd:"ALLOCSET",var:2,buff:A}),G.push({cmd:"ALLOCSET",var:3,buff:c}),G.push({cmd:"CALL",fnName:v,params:[{var:0},{var:1},{val:T},{var:2},{var:3}]}),ct==X?(f&&(G.push({cmd:"ALLOCSET",var:4,buff:et}),G.push({cmd:"CALL",fnName:f,params:[{var:0},{val:T},{var:4}]}),G.push({cmd:"CALL",fnName:f,params:[{var:1},{val:T},{var:4}]})),z&&(G.push({cmd:"CALL",fnName:z,params:[{var:0},{val:T},{var:0}]}),G.push({cmd:"CALL",fnName:z,params:[{var:1},{val:T},{var:1}]})),G.push({cmd:"GET",out:0,var:0,len:T*x}),G.push({cmd:"GET",out:1,var:1,len:T*x})):(G.push({cmd:"GET",out:0,var:0,len:T*R}),G.push({cmd:"GET",out:1,var:1,len:T*R})),ht.push(o.queueAction(G).then(U=>(g&&g.debug(`${M}: fft ${X} join ${ct}/${X} ${Nt+1}/${yt} ${kt}/${ft/2}`),U)))}const Ft=await Promise.all(ht);for(let Nt=0;Nt<yt;Nt++)for(let kt=0;kt<ft/2;kt++){const A=Nt*ft+kt,c=Nt*ft+kt+ft/2,E=Ft.shift();w[A]=E[0],w[c]=E[1]}}if(l instanceof ne?N=new ne(V*x):N=new Uint8Array(V*x),s){N.set(w[0].slice((T-1)*x));let ct=x;for(let yt=at-1;yt>0;yt--)N.set(w[yt],ct),ct+=T*x,delete w[yt];N.set(w[0].slice(0,(T-1)*x),ct),delete w[0]}else for(let ct=0;ct<at;ct++)N.set(w[ct],T*x*ct),delete w[ct];return L?Ni(N,x):N}async function u(l,s,m,C,g){let M,$;M=l.slice(0,l.byteLength/2),$=l.slice(l.byteLength/2,l.byteLength);const F=[];[M,$]=await I(M,$,"fftJoinExt",i.one,i.shift,s,"jacobian",C,g),F.push(a(M,!1,"jacobian",m,C,g)),F.push(a($,!1,"jacobian",m,C,g));const R=await Promise.all(F);let x;return R[0].byteLength>1<<28?x=new ne(R[0].byteLength*2):x=new Uint8Array(R[0].byteLength*2),x.set(R[0]),x.set(R[1],R[0].byteLength),x}async function r(l,s,m,C,g){let M,$;M=l.slice(0,l.byteLength/2),$=l.slice(l.byteLength/2,l.byteLength);const F=[];F.push(a(M,!0,s,"jacobian",C,g)),F.push(a($,!0,s,"jacobian",C,g)),[M,$]=await Promise.all(F);const R=await I(M,$,"fftJoinExtInv",i.one,i.shiftInv,"jacobian",m,C,g);let x;return R[0].byteLength>1<<28?x=new ne(R[0].byteLength*2):x=new Uint8Array(R[0].byteLength*2),x.set(R[0]),x.set(R[1],R[0].byteLength),x}async function I(l,s,m,C,g,M,$,F,R){let z,K,v,f,L,V;if(t=="G1")M=="affine"?(L=e.F.n8*2,K="g1m_batchToJacobian"):L=e.F.n8*3,V=e.F.n8*3,z="g1m_"+m,$=="affine"?(v="g1m_batchToAffine",f=e.F.n8*2):f=e.F.n8*3;else if(t=="G2")M=="affine"?(L=e.F.n8*2,K="g2m_batchToJacobian"):L=e.F.n8*3,z="g2m_"+m,V=e.F.n8*3,$=="affine"?(v="g2m_batchToAffine",f=e.F.n8*2):f=e.F.n8*3;else if(t=="Fr")L=i.n8,f=i.n8,V=i.n8,z="frm_"+m;else throw new Error("Invalid group");if(l.byteLength!=s.byteLength)throw new Error("Invalid buffer size");const X=Math.floor(l.byteLength/L);if(X!=1<<be(X))throw new Error("Invalid number of points");let et=Math.floor(X/o.concurrency);et<16&&(et=16),et>65536&&(et=65536);const N=[];for(let _t=0;_t<X;_t+=et){F&&F.debug(`${R}: fftJoinExt Start: ${_t}/${X}`);const ct=Math.min(X-_t,et),yt=i.mul(C,i.exp(g,_t)),ft=[],ht=l.slice(_t*L,(_t+ct)*L),Ft=s.slice(_t*L,(_t+ct)*L);ft.push({cmd:"ALLOC",var:0,len:V*ct}),ft.push({cmd:"SET",var:0,buff:ht}),ft.push({cmd:"ALLOC",var:1,len:V*ct}),ft.push({cmd:"SET",var:1,buff:Ft}),ft.push({cmd:"ALLOCSET",var:2,buff:yt}),ft.push({cmd:"ALLOCSET",var:3,buff:g}),K&&(ft.push({cmd:"CALL",fnName:K,params:[{var:0},{val:ct},{var:0}]}),ft.push({cmd:"CALL",fnName:K,params:[{var:1},{val:ct},{var:1}]})),ft.push({cmd:"CALL",fnName:z,params:[{var:0},{var:1},{val:ct},{var:2},{var:3},{val:i.s}]}),v&&(ft.push({cmd:"CALL",fnName:v,params:[{var:0},{val:ct},{var:0}]}),ft.push({cmd:"CALL",fnName:v,params:[{var:1},{val:ct},{var:1}]})),ft.push({cmd:"GET",out:0,var:0,len:ct*f}),ft.push({cmd:"GET",out:1,var:1,len:ct*f}),N.push(o.queueAction(ft).then(Nt=>(F&&F.debug(`${R}: fftJoinExt End: ${_t}/${X}`),Nt)))}const w=await Promise.all(N);let T,at;X*f>1<<28?(T=new ne(X*f),at=new ne(X*f)):(T=new Uint8Array(X*f),at=new Uint8Array(X*f));let Lt=0;for(let _t=0;_t<w.length;_t++)T.set(w[_t][0],Lt),at.set(w[_t][1],Lt),Lt+=w[_t][0].byteLength;return[T,at]}e.fft=async function(l,s,m,C,g){return await a(l,!1,s,m,C,g)},e.ifft=async function(l,s,m,C,g){return await a(l,!0,s,m,C,g)},e.lagrangeEvaluations=async function(l,s,m,C,g){s=s||"affine",m=m||"affine";let M;if(t=="G1")s=="affine"?M=e.F.n8*2:M=e.F.n8*3;else if(t=="G2")s=="affine"?M=e.F.n8*2:M=e.F.n8*3;else if(t=="Fr")M=i.n8;else throw new Error("Invalid group");const $=l.byteLength/M,F=be($);if(2**F*M!=l.byteLength)throw C&&C.error("lagrangeEvaluations iinvalid input size"),new Error("lagrangeEvaluations invalid Input size");if(F<=i.s)return await e.ifft(l,s,m,C,g);if(F>i.s+1)throw C&&C.error("lagrangeEvaluations input too big"),new Error("lagrangeEvaluations input too big");let R=l.slice(0,l.byteLength/2),x=l.slice(l.byteLength/2,l.byteLength);const it=i.exp(i.shift,$/2),z=i.inv(i.sub(i.one,it));[R,x]=await I(R,x,"prepareLagrangeEvaluation",z,i.shiftInv,s,"jacobian",C,g+" prep");const K=[];K.push(a(R,!0,"jacobian",m,C,g+" t0")),K.push(a(x,!0,"jacobian",m,C,g+" t1")),[R,x]=await Promise.all(K);let v;return R.byteLength>1<<28?v=new ne(R.byteLength*2):v=new Uint8Array(R.byteLength*2),v.set(R),v.set(x,R.byteLength),v},e.fftMix=async function(s){const m=e.F.n8*3;let C,g;if(t=="G1")C="g1m_fftMix",g="g1m_fftJoin";else if(t=="G2")C="g2m_fftMix",g="g2m_fftJoin";else if(t=="Fr")C="frm_fftMix",g="frm_fftJoin";else throw new Error("Invalid group");const M=Math.floor(s.byteLength/m),$=be(M);let F=1<<be(o.concurrency);M<=F*2&&(F=1);const R=M/F,x=be(R),it=[];for(let L=0;L<F;L++){const V=[],X=s.slice(L*R*m,(L+1)*R*m);V.push({cmd:"ALLOCSET",var:0,buff:X});for(let et=1;et<=x;et++)V.push({cmd:"CALL",fnName:C,params:[{var:0},{val:R},{val:et}]});V.push({cmd:"GET",out:0,var:0,len:R*m}),it.push(o.queueAction(V))}const z=await Promise.all(it),K=[];for(let L=0;L<z.length;L++)K[L]=z[L][0];for(let L=x+1;L<=$;L++){const V=1<<$-L,X=F/V,et=[];for(let w=0;w<V;w++)for(let T=0;T<X/2;T++){const at=i.exp(i.w[L],T*R),Lt=i.w[L],_t=w*X+T,ct=w*X+T+X/2,yt=[];yt.push({cmd:"ALLOCSET",var:0,buff:K[_t]}),yt.push({cmd:"ALLOCSET",var:1,buff:K[ct]}),yt.push({cmd:"ALLOCSET",var:2,buff:at}),yt.push({cmd:"ALLOCSET",var:3,buff:Lt}),yt.push({cmd:"CALL",fnName:g,params:[{var:0},{var:1},{val:R},{var:2},{var:3}]}),yt.push({cmd:"GET",out:0,var:0,len:R*m}),yt.push({cmd:"GET",out:1,var:1,len:R*m}),et.push(o.queueAction(yt))}const N=await Promise.all(et);for(let w=0;w<V;w++)for(let T=0;T<X/2;T++){const at=w*X+T,Lt=w*X+T+X/2,_t=N.shift();K[at]=_t[0],K[Lt]=_t[1]}}let v;s instanceof ne?v=new ne(M*m):v=new Uint8Array(M*m);let f=0;for(let L=0;L<F;L++)v.set(K[L],f),f+=K[L].byteLength;return v},e.fftJoin=async function(s,m,C,g){const M=e.F.n8*3;let $;if(t=="G1")$="g1m_fftJoin";else if(t=="G2")$="g2m_fftJoin";else if(t=="Fr")$="frm_fftJoin";else throw new Error("Invalid group");if(s.byteLength!=m.byteLength)throw new Error("Invalid buffer size");const F=Math.floor(s.byteLength/M);if(F!=1<<be(F))throw new Error("Invalid number of points");let R=1<<be(o.concurrency);F<=R*2&&(R=1);const x=F/R,it=[];for(let L=0;L<R;L++){const V=[],X=i.mul(C,i.exp(g,L*x)),et=s.slice(L*x*M,(L+1)*x*M),N=m.slice(L*x*M,(L+1)*x*M);V.push({cmd:"ALLOCSET",var:0,buff:et}),V.push({cmd:"ALLOCSET",var:1,buff:N}),V.push({cmd:"ALLOCSET",var:2,buff:X}),V.push({cmd:"ALLOCSET",var:3,buff:g}),V.push({cmd:"CALL",fnName:$,params:[{var:0},{var:1},{val:x},{var:2},{var:3}]}),V.push({cmd:"GET",out:0,var:0,len:x*M}),V.push({cmd:"GET",out:1,var:1,len:x*M}),it.push(o.queueAction(V))}const z=await Promise.all(it);let K,v;s instanceof ne?(K=new ne(F*M),v=new ne(F*M)):(K=new Uint8Array(F*M),v=new Uint8Array(F*M));let f=0;for(let L=0;L<z.length;L++)K.set(z[L][0],f),v.set(z[L][1],f),f+=z[L][0].byteLength;return[K,v]},e.fftFinal=async function(s,m){const C=e.F.n8*3,g=e.F.n8*2;let M,$;if(t=="G1")M="g1m_fftFinal",$="g1m_batchToAffine";else if(t=="G2")M="g2m_fftFinal",$="g2m_batchToAffine";else throw new Error("Invalid group");const F=Math.floor(s.byteLength/C);if(F!=1<<be(F))throw new Error("Invalid number of points");const R=Math.floor(F/o.concurrency),x=[];for(let v=0;v<o.concurrency;v++){let f;if(v<o.concurrency-1?f=R:f=F-v*R,f==0)continue;const L=[],V=s.slice(v*R*C,(v*R+f)*C);L.push({cmd:"ALLOCSET",var:0,buff:V}),L.push({cmd:"ALLOCSET",var:1,buff:m}),L.push({cmd:"CALL",fnName:M,params:[{var:0},{val:f},{var:1}]}),L.push({cmd:"CALL",fnName:$,params:[{var:0},{val:f},{var:0}]}),L.push({cmd:"GET",out:0,var:0,len:f*g}),x.push(o.queueAction(L))}const it=await Promise.all(x);let z;s instanceof ne?z=new ne(F*g):z=new Uint8Array(F*g);let K=0;for(let v=it.length-1;v>=0;v--)z.set(it[v][0],K),K+=it[v][0].byteLength;return z}}async function Qr(n){const t=await l2(n.wasm,n.singleThread),e={};return e.q=se(n.wasm.q.toString()),e.r=se(n.wasm.r.toString()),e.name=n.name,e.tm=t,e.prePSize=n.wasm.prePSize,e.preQSize=n.wasm.preQSize,e.Fr=new Ha(t,"frm",n.n8r,n.r),e.F1=new Ha(t,"f1m",n.n8q,n.q),e.F2=new Za(t,"f2m",e.F1),e.G1=new Ya(t,"g1m",e.F1,n.wasm.pG1gen,n.wasm.pG1b,n.cofactorG1),e.G2=new Ya(t,"g2m",e.F2,n.wasm.pG2gen,n.wasm.pG2b,n.cofactorG2),e.F6=new c2(t,"f6m",e.F2),e.F12=new Za(t,"ftm",e.F6),e.Gt=e.F12,po(e,"G1"),po(e,"G2"),po(e,"Fr"),Xa(e,"G1"),Xa(e,"G2"),Lo(e,"G1"),Lo(e,"G2"),Lo(e,"Fr"),u2(e),e.array2buffer=function(i,o){const a=new Uint8Array(o*i.length);for(let u=0;u<i.length;u++)a.set(i[u],u*o);return a},e.buffer2array=function(i,o){const a=i.byteLength/o,u=new Array(a);for(let r=0;r<a;r++)u[r]=i.slice(r*o,r*o+o);return u},e}function qn(n){return BigInt(n)}function Dr(n){return n<0n}function f2(n){return n===0n}function _2(n){return Dr(n)?n.toString(2).length-1:n.toString(2).length}function Ao(n){const t=[],e=qn(n);return t.push(Number(e&0xFFn)),t.push(Number(e>>8n&0xFFn)),t.push(Number(e>>16n&0xFFn)),t.push(Number(e>>24n&0xFFn)),t}function h2(n){for(var t=[],e=0;e<n.length;e++){var i=n.charCodeAt(e);i<128?t.push(i):i<2048?t.push(192|i>>6,128|i&63):i<55296||i>=57344?t.push(224|i>>12,128|i>>6&63,128|i&63):(e++,i=65536+((i&1023)<<10|n.charCodeAt(e)&1023),t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return t}function Xn(n){const t=h2(n);return[...Ht(t.length),...t]}function qr(n){const t=[];let e=qn(n);if(Dr(e))throw new Error("Number cannot be negative");for(;!f2(e);)t.push(Number(e&0x7Fn)),e=e>>7n;t.length==0&&t.push(0);for(let i=0;i<t.length-1;i++)t[i]=t[i]|128;return t}function Nr(n){let t,e;const i=_2(n);n<0?(e=!0,t=(1n<<BigInt(i))+n):(e=!1,t=qn(n));const o=7-i%7,a=(1n<<BigInt(o))-1n<<BigInt(i),u=(1<<7-o)-1|128,r=qr(t+a);return e||(r[r.length-1]=r[r.length-1]&u),r}function No(n){let t=qn(n);if(t>0xFFFFFFFFn)throw new Error("Number too big");if(t>0x7FFFFFFFn&&(t=t-0x100000000n),t<-2147483648n)throw new Error("Number too small");return Nr(t)}function g2(n){let t=qn(n);if(t>0xFFFFFFFFFFFFFFFFn)throw new Error("Number too big");if(t>0x7FFFFFFFFFFFFFFFn&&(t=t-0x10000000000000000n),t<-9223372036854775808n)throw new Error("Number too small");return Nr(t)}function Ht(n){let t=qn(n);if(t>0xFFFFFFFFn)throw new Error("Number too big");return qr(t)}function Ja(n){return Array.from(n,function(t){return("0"+(t&255).toString(16)).slice(-2)}).join("")}class p2{constructor(t){this.func=t,this.functionName=t.functionName,this.module=t.module}setLocal(t,e){const i=this.func.localIdxByName[t];if(i===void 0)throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...e,33,...Ht(i)]}teeLocal(t,e){const i=this.func.localIdxByName[t];if(i===void 0)throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...e,34,...Ht(i)]}getLocal(t){const e=this.func.localIdxByName[t];if(e===void 0)throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[32,...Ht(e)]}i64_load8_s(t,e,i){const o=e||0,a=i===void 0?0:i;return[...t,48,a,...Ht(o)]}i64_load8_u(t,e,i){const o=e||0,a=i===void 0?0:i;return[...t,49,a,...Ht(o)]}i64_load16_s(t,e,i){const o=e||0,a=i===void 0?1:i;return[...t,50,a,...Ht(o)]}i64_load16_u(t,e,i){const o=e||0,a=i===void 0?1:i;return[...t,51,a,...Ht(o)]}i64_load32_s(t,e,i){const o=e||0,a=i===void 0?2:i;return[...t,52,a,...Ht(o)]}i64_load32_u(t,e,i){const o=e||0,a=i===void 0?2:i;return[...t,53,a,...Ht(o)]}i64_load(t,e,i){const o=e||0,a=i===void 0?3:i;return[...t,41,a,...Ht(o)]}i64_store(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=3,r=e):Array.isArray(i)?(a=e,u=3,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,55,u,...Ht(a)]}i64_store32(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=2,r=e):Array.isArray(i)?(a=e,u=2,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,62,u,...Ht(a)]}i64_store16(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=1,r=e):Array.isArray(i)?(a=e,u=1,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,61,u,...Ht(a)]}i64_store8(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=0,r=e):Array.isArray(i)?(a=e,u=0,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,60,u,...Ht(a)]}i32_load8_s(t,e,i){const o=e||0,a=i===void 0?0:i;return[...t,44,a,...Ht(o)]}i32_load8_u(t,e,i){const o=e||0,a=i===void 0?0:i;return[...t,45,a,...Ht(o)]}i32_load16_s(t,e,i){const o=e||0,a=i===void 0?1:i;return[...t,46,a,...Ht(o)]}i32_load16_u(t,e,i){const o=e||0,a=i===void 0?1:i;return[...t,47,a,...Ht(o)]}i32_load(t,e,i){const o=e||0,a=i===void 0?2:i;return[...t,40,a,...Ht(o)]}i32_store(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=2,r=e):Array.isArray(i)?(a=e,u=2,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,54,u,...Ht(a)]}i32_store16(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=1,r=e):Array.isArray(i)?(a=e,u=1,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,59,u,...Ht(a)]}i32_store8(t,e,i,o){let a,u,r;return Array.isArray(e)?(a=0,u=0,r=e):Array.isArray(i)?(a=e,u=0,r=i):Array.isArray(o)&&(a=e,u=i,r=o),[...t,...r,58,u,...Ht(a)]}call(t,...e){const i=this.module.functionIdxByName[t];if(i===void 0)throw new Error(`Function not defined: Function: ${t}`);return[...[].concat(...e),16,...Ht(i)]}call_indirect(t,...e){return[...[].concat(...e),...t,17,0,0]}if(t,e,i){return i?[...t,4,64,...e,5,...i,11]:[...t,4,64,...e,11]}block(t){return[2,64,...t,11]}loop(...t){return[3,64,...[].concat(...t),11]}br_if(t,e){return[...e,13,...Ht(t)]}br(t){return[12,...Ht(t)]}ret(t){return[...t,15]}drop(t){return[...t,26]}i64_const(t){return[66,...g2(t)]}i32_const(t){return[65,...No(t)]}i64_eqz(t){return[...t,80]}i64_eq(t,e){return[...t,...e,81]}i64_ne(t,e){return[...t,...e,82]}i64_lt_s(t,e){return[...t,...e,83]}i64_lt_u(t,e){return[...t,...e,84]}i64_gt_s(t,e){return[...t,...e,85]}i64_gt_u(t,e){return[...t,...e,86]}i64_le_s(t,e){return[...t,...e,87]}i64_le_u(t,e){return[...t,...e,88]}i64_ge_s(t,e){return[...t,...e,89]}i64_ge_u(t,e){return[...t,...e,90]}i64_add(t,e){return[...t,...e,124]}i64_sub(t,e){return[...t,...e,125]}i64_mul(t,e){return[...t,...e,126]}i64_div_s(t,e){return[...t,...e,127]}i64_div_u(t,e){return[...t,...e,128]}i64_rem_s(t,e){return[...t,...e,129]}i64_rem_u(t,e){return[...t,...e,130]}i64_and(t,e){return[...t,...e,131]}i64_or(t,e){return[...t,...e,132]}i64_xor(t,e){return[...t,...e,133]}i64_shl(t,e){return[...t,...e,134]}i64_shr_s(t,e){return[...t,...e,135]}i64_shr_u(t,e){return[...t,...e,136]}i64_extend_i32_s(t){return[...t,172]}i64_extend_i32_u(t){return[...t,173]}i64_clz(t){return[...t,121]}i64_ctz(t){return[...t,122]}i32_eqz(t){return[...t,69]}i32_eq(t,e){return[...t,...e,70]}i32_ne(t,e){return[...t,...e,71]}i32_lt_s(t,e){return[...t,...e,72]}i32_lt_u(t,e){return[...t,...e,73]}i32_gt_s(t,e){return[...t,...e,74]}i32_gt_u(t,e){return[...t,...e,75]}i32_le_s(t,e){return[...t,...e,76]}i32_le_u(t,e){return[...t,...e,77]}i32_ge_s(t,e){return[...t,...e,78]}i32_ge_u(t,e){return[...t,...e,79]}i32_add(t,e){return[...t,...e,106]}i32_sub(t,e){return[...t,...e,107]}i32_mul(t,e){return[...t,...e,108]}i32_div_s(t,e){return[...t,...e,109]}i32_div_u(t,e){return[...t,...e,110]}i32_rem_s(t,e){return[...t,...e,111]}i32_rem_u(t,e){return[...t,...e,112]}i32_and(t,e){return[...t,...e,113]}i32_or(t,e){return[...t,...e,114]}i32_xor(t,e){return[...t,...e,115]}i32_shl(t,e){return[...t,...e,116]}i32_shr_s(t,e){return[...t,...e,117]}i32_shr_u(t,e){return[...t,...e,118]}i32_rotl(t,e){return[...t,...e,119]}i32_rotr(t,e){return[...t,...e,120]}i32_wrap_i64(t){return[...t,167]}i32_clz(t){return[...t,103]}i32_ctz(t){return[...t,104]}unreachable(){return[0]}current_memory(){return[63,0]}comment(){return[]}}const bo={i32:127,i64:126,f32:125,f64:124,anyfunc:112,func:96,emptyblock:64};class tc{constructor(t,e,i,o,a){if(i=="import")this.fnType="import",this.moduleName=o,this.fieldName=a;else if(i=="internal")this.fnType="internal";else throw new Error("Invalid function fnType: "+i);this.module=t,this.fnName=e,this.params=[],this.locals=[],this.localIdxByName={},this.code=[],this.returnType=null,this.nextLocal=0}addParam(t,e){if(this.localIdxByName[t])throw new Error(`param already exists. Function: ${this.fnName}, Param: ${t} `);const i=this.nextLocal++;this.localIdxByName[t]=i,this.params.push({type:e})}addLocal(t,e,i){const o=i||1;if(this.localIdxByName[t])throw new Error(`local already exists. Function: ${this.fnName}, Param: ${t} `);const a=this.nextLocal++;this.localIdxByName[t]=a,this.locals.push({type:e,length:o})}setReturnType(t){if(this.returnType)throw new Error(`returnType already defined. Function: ${this.fnName}`);this.returnType=t}getSignature(){const t=[...Ht(this.params.length),...this.params.map(i=>bo[i.type])],e=this.returnType?[1,bo[this.returnType]]:[0];return[96,...t,...e]}getBody(){const t=this.locals.map(i=>[...Ht(i.length),bo[i.type]]),e=[...Ht(this.locals.length),...[].concat(...t),...this.code,11];return[...Ht(e.length),...e]}addCode(...t){this.code.push(...[].concat(...t))}getCodeBuilder(){return new p2(this)}}class Gr{constructor(){this.functions=[],this.functionIdxByName={},this.nImportFunctions=0,this.nInternalFunctions=0,this.memory={pagesSize:1,moduleName:"env",fieldName:"memory"},this.free=8,this.datas=[],this.modules={},this.exports=[],this.functionsTable=[]}build(){return this._setSignatures(),new Uint8Array([...Ao(1836278016),...Ao(1),...this._buildType(),...this._buildImport(),...this._buildFunctionDeclarations(),...this._buildFunctionsTable(),...this._buildExports(),...this._buildElements(),...this._buildCode(),...this._buildData()])}addFunction(t){if(typeof this.functionIdxByName[t]<"u")throw new Error(`Function already defined: ${t}`);const e=this.functions.length;return this.functionIdxByName[t]=e,this.functions.push(new tc(this,t,"internal")),this.nInternalFunctions++,this.functions[e]}addIimportFunction(t,e,i){if(typeof this.functionIdxByName[t]<"u")throw new Error(`Function already defined: ${t}`);if(this.functions.length>0&&this.functions[this.functions.length-1].type=="internal")throw new Error(`Import functions must be declared before internal: ${t}`);let o=i||t;const a=this.functions.length;return this.functionIdxByName[t]=a,this.functions.push(new tc(this,t,"import",e,o)),this.nImportFunctions++,this.functions[a]}setMemory(t,e,i){this.memory={pagesSize:t,moduleName:e||"env",fieldName:i||"memory"}}exportFunction(t,e){const i=e||t;if(typeof this.functionIdxByName[t]>"u")throw new Error(`Function not defined: ${t}`);const o=this.functionIdxByName[t];i!=t&&(this.functionIdxByName[i]=o),this.exports.push({exportName:i,idx:o})}addFunctionToTable(t){const e=this.functionIdxByName[t];this.functionsTable.push(e)}addData(t,e){this.datas.push({offset:t,bytes:e})}alloc(t,e){let i,o;(Array.isArray(t)||ArrayBuffer.isView(t))&&typeof e>"u"?(i=t.length,o=t):(i=t,o=e),i=(i-1>>3)+1<<3;const a=this.free;return this.free+=i,o&&this.addData(a,o),a}allocString(t){const i=new globalThis.TextEncoder().encode(t);return this.alloc([...i,0])}_setSignatures(){this.signatures=[];const t={};if(this.functionsTable.length>0){const e=this.functions[this.functionsTable[0]].getSignature(),i="s_"+Ja(e);t[i]=0,this.signatures.push(e)}for(let e=0;e<this.functions.length;e++){const i=this.functions[e].getSignature(),o="s_"+Ja(i);typeof t[o]>"u"&&(t[o]=this.signatures.length,this.signatures.push(i)),this.functions[e].signatureIdx=t[o]}}_buildSection(t,e){return[t,...Ht(e.length),...e]}_buildType(){return this._buildSection(1,[...Ht(this.signatures.length),...[].concat(...this.signatures)])}_buildImport(){const t=[];t.push([...Xn(this.memory.moduleName),...Xn(this.memory.fieldName),2,0,...Ht(this.memory.pagesSize)]);for(let e=0;e<this.nImportFunctions;e++)t.push([...Xn(this.functions[e].moduleName),...Xn(this.functions[e].fieldName),0,...Ht(this.functions[e].signatureIdx)]);return this._buildSection(2,Ht(t.length).concat(...t))}_buildFunctionDeclarations(){const t=[];for(let e=this.nImportFunctions;e<this.nImportFunctions+this.nInternalFunctions;e++)t.push(...Ht(this.functions[e].signatureIdx));return this._buildSection(3,[...Ht(t.length),...t])}_buildFunctionsTable(){return this.functionsTable.length==0?[]:this._buildSection(4,[...Ht(1),112,0,...Ht(this.functionsTable.length)])}_buildElements(){if(this.functionsTable.length==0)return[];const t=[];for(let e=0;e<this.functionsTable.length;e++)t.push(...Ht(this.functionsTable[e]));return this._buildSection(9,[...Ht(1),...Ht(0),65,...No(0),11,...Ht(this.functionsTable.length),...t])}_buildExports(){const t=[];for(let e=0;e<this.exports.length;e++)t.push([...Xn(this.exports[e].exportName),0,...Ht(this.exports[e].idx)]);return this._buildSection(7,Ht(t.length).concat(...t))}_buildCode(){const t=[];for(let e=this.nImportFunctions;e<this.nImportFunctions+this.nInternalFunctions;e++)t.push(this.functions[e].getBody());return this._buildSection(10,Ht(t.length).concat(...t))}_buildData(){const t=[];t.push([0,65,0,11,4,...Ao(this.free)]);for(let e=0;e<this.datas.length;e++)t.push([0,65,...No(this.datas[e].offset),11,...Ht(this.datas[e].bytes.length),...this.datas[e].bytes]);return this._buildSection(11,Ht(t.length).concat(...t))}}globalThis.curve_bn128=null;async function $r(n,t){if(globalThis.curve_bn128)return globalThis.curve_bn128;const e=new Gr;e.setMemory(25),Jd(e);const i={};i.code=e.build(),i.pq=e.modules.f1m.pq,i.pr=e.modules.frm.pq,i.pG1gen=e.modules.bn128.pG1gen,i.pG1zero=e.modules.bn128.pG1zero,i.pG1b=e.modules.bn128.pG1b,i.pG2gen=e.modules.bn128.pG2gen,i.pG2zero=e.modules.bn128.pG2zero,i.pG2b=e.modules.bn128.pG2b,i.pOneT=e.modules.bn128.pOneT,i.prePSize=e.modules.bn128.prePSize,i.preQSize=e.modules.bn128.preQSize,i.n8q=32,i.n8r=32,i.q=e.modules.bn128.q,i.r=e.modules.bn128.r;const o={name:"bn128",wasm:i,q:se("21888242871839275222246405745257275088696311157297823662689037894645226208583"),r:se("21888242871839275222246405745257275088548364400416034343698204186575808495617"),n8q:32,n8r:32,cofactorG2:se("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d",16),singleThread:!1},a=await Qr(o);return a.terminate=async function(){o.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},globalThis.curve_bn128=a,a}globalThis.curve_bls12381=null;async function Kr(n,t){if(globalThis.curve_bls12381)return globalThis.curve_bls12381;const e=new Gr;e.setMemory(25),t2(e);const i={};i.code=e.build(),i.pq=e.modules.f1m.pq,i.pr=e.modules.frm.pq,i.pG1gen=e.modules.bls12381.pG1gen,i.pG1zero=e.modules.bls12381.pG1zero,i.pG1b=e.modules.bls12381.pG1b,i.pG2gen=e.modules.bls12381.pG2gen,i.pG2zero=e.modules.bls12381.pG2zero,i.pG2b=e.modules.bls12381.pG2b,i.pOneT=e.modules.bls12381.pOneT,i.prePSize=e.modules.bls12381.prePSize,i.preQSize=e.modules.bls12381.preQSize,i.n8q=48,i.n8r=32,i.q=e.modules.bls12381.q,i.r=e.modules.bls12381.r;const o={name:"bls12381",wasm:i,q:se("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),r:se("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),n8q:48,n8r:32,cofactorG1:se("0x396c8c005555e1568c00aaab0000aaab",16),cofactorG2:se("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5",16),singleThread:!1},a=await Qr(o);return a.terminate=async function(){o.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},globalThis.curve_bls12381=a,a}se("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);se("21888242871839275222246405745257275088548364400416034343698204186575808495617");se("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16);se("21888242871839275222246405745257275088696311157297823662689037894645226208583");const oe=Xl,Hr=a2;var Zr={};async function Yr(n,t,e,i){if(e=e||4096*64,typeof t!="number"&&["w+","wx+","r","ax+","a+"].indexOf(t)<0)throw new Error("Invalid open option");const o=await Zr.promises.open(n,t),a=await o.stat();return new L2(o,a,e,i,n)}class L2{constructor(t,e,i,o,a){for(this.fileName=a,this.fd=t,this.pos=0,this.pageSize=o||256;this.pageSize<e.blksize;)this.pageSize*=2;this.totalSize=e.size,this.totalPages=Math.floor((e.size-1)/this.pageSize)+1,this.maxPagesLoaded=Math.floor(i/this.pageSize)+1,this.pages={},this.pendingLoads=[],this.writing=!1,this.reading=!1,this.avBuffs=[],this.history={}}_loadPage(t){const e=this,i=new Promise((o,a)=>{e.pendingLoads.push({page:t,resolve:o,reject:a})});return e.__statusPage("After Load request: ",t),i}__statusPage(t,e){const i=[],o=this;if(!o.logHistory)return;i.push("=="+t+" "+e);let a="";for(let u=0;u<o.pendingLoads.length;u++)o.pendingLoads[u].page==e&&(a=a+" "+u);if(a&&i.push("Pending loads:"+a),typeof o.pages[e]<"u"){const u=o.pages[e];i.push("Loaded"),i.push("pendingOps: "+u.pendingOps),u.loading&&i.push("loading: "+u.loading),u.writing&&i.push("writing"),u.dirty&&i.push("dirty")}i.push("=="),o.history[e]||(o.history[e]=[]),o.history[e].push(i)}__printHistory(t){const e=this;e.history[t]||console.log("Empty History ",t),console.log("History "+t);for(let i=0;i<e.history[t].length;i++)for(let o=0;o<e.history[t][i].length;o++)console.log("-> "+e.history[t][i][o])}_triggerLoad(){const t=this;if(t.reading||t.pendingLoads.length==0)return;const e=Object.keys(t.pages),i=[];for(let r=0;r<e.length;r++){const I=t.pages[parseInt(e[r])];I.dirty==!1&&I.pendingOps==0&&!I.writing&&!I.loading&&i.push(parseInt(e[r]))}let o=t.maxPagesLoaded-e.length;const a=[];for(;t.pendingLoads.length>0&&(typeof t.pages[t.pendingLoads[0].page]<"u"||o>0||i.length>0);){const r=t.pendingLoads.shift();if(typeof t.pages[r.page]<"u"){t.pages[r.page].pendingOps++;const I=i.indexOf(r.page);I>=0&&i.splice(I,1),t.pages[r.page].loading?t.pages[r.page].loading.push(r):r.resolve(),t.__statusPage("After Load (cached): ",r.page)}else{if(o)o--;else{const I=i.shift();t.__statusPage("Before Unload: ",I),t.avBuffs.unshift(t.pages[I]),delete t.pages[I],t.__statusPage("After Unload: ",I)}r.page>=t.totalPages?(t.pages[r.page]=u(),r.resolve(),t.__statusPage("After Load (new): ",r.page)):(t.reading=!0,t.pages[r.page]=u(),t.pages[r.page].loading=[r],a.push(t.fd.read(t.pages[r.page].buff,0,t.pageSize,r.page*t.pageSize).then(I=>{t.pages[r.page].size=I.bytesRead;const l=t.pages[r.page].loading;delete t.pages[r.page].loading;for(let s=0;s<l.length;s++)l[s].resolve();return t.__statusPage("After Load (loaded): ",r.page),I},I=>{r.reject(I)})),t.__statusPage("After Load (loading): ",r.page))}}Promise.all(a).then(()=>{t.reading=!1,t.pendingLoads.length>0&&setImmediate(t._triggerLoad.bind(t)),t._tryClose()});function u(){if(t.avBuffs.length>0){const r=t.avBuffs.shift();return r.dirty=!1,r.pendingOps=1,r.size=0,r}else return{dirty:!1,buff:new Uint8Array(t.pageSize),pendingOps:1,size:0}}}_triggerWrite(){const t=this;if(t.writing)return;const e=Object.keys(t.pages),i=[];for(let o=0;o<e.length;o++){const a=t.pages[parseInt(e[o])];a.dirty&&(a.dirty=!1,a.writing=!0,t.writing=!0,i.push(t.fd.write(a.buff,0,a.size,parseInt(e[o])*t.pageSize).then(()=>{a.writing=!1},u=>{console.log("ERROR Writing: "+u),t.error=u,t._tryClose()})))}t.writing&&Promise.all(i).then(()=>{t.writing=!1,setImmediate(t._triggerWrite.bind(t)),t._tryClose(),t.pendingLoads.length>0&&setImmediate(t._triggerLoad.bind(t))})}_getDirtyPage(){for(let t in this.pages)if(this.pages[t].dirty)return t;return-1}async write(t,e){if(t.byteLength==0)return;const i=this;if(typeof e>"u"&&(e=i.pos),i.pos=e+t.byteLength,i.totalSize<e+t.byteLength&&(i.totalSize=e+t.byteLength),i.pendingClose)throw new Error("Writing a closing file");const o=Math.floor(e/i.pageSize),a=Math.floor((e+t.byteLength-1)/i.pageSize),u=[];for(let s=o;s<=a;s++)u.push(i._loadPage(s));i._triggerLoad();let r=o,I=e%i.pageSize,l=t.byteLength;for(;l>0;){await u[r-o];const s=I+l>i.pageSize?i.pageSize-I:l,m=t.slice(t.byteLength-l,t.byteLength-l+s);new Uint8Array(i.pages[r].buff.buffer,I,s).set(m),i.pages[r].dirty=!0,i.pages[r].pendingOps--,i.pages[r].size=Math.max(I+s,i.pages[r].size),r>=i.totalPages&&(i.totalPages=r+1),l=l-s,r++,I=0,i.writing||setImmediate(i._triggerWrite.bind(i))}}async read(t,e){const i=this;let o=new Uint8Array(t);return await i.readToBuffer(o,0,t,e),o}async readToBuffer(t,e,i,o){if(i==0)return;const a=this;if(i>a.pageSize*a.maxPagesLoaded*.8){const C=Math.floor(i*1.1);this.maxPagesLoaded=Math.floor(C/a.pageSize)+1}if(typeof o>"u"&&(o=a.pos),a.pos=o+i,a.pendingClose)throw new Error("Reading a closing file");const u=Math.floor(o/a.pageSize),r=Math.floor((o+i-1)/a.pageSize),I=[];for(let C=u;C<=r;C++)I.push(a._loadPage(C));a._triggerLoad();let l=u,s=o%a.pageSize,m=o+i>a.totalSize?i-(o+i-a.totalSize):i;for(;m>0;){await I[l-u],a.__statusPage("After Await (read): ",l);const C=s+m>a.pageSize?a.pageSize-s:m,g=new Uint8Array(a.pages[l].buff.buffer,a.pages[l].buff.byteOffset+s,C);t.set(g,e+i-m),a.pages[l].pendingOps--,a.__statusPage("After Op done: ",l),m=m-C,l++,s=0,a.pendingLoads.length>0&&setImmediate(a._triggerLoad.bind(a))}this.pos=o+i}_tryClose(){const t=this;!t.pendingClose||(t.error&&t.pendingCloseReject(t.error),t._getDirtyPage()>=0||t.writing||t.reading||t.pendingLoads.length>0)||t.pendingClose()}close(){const t=this;if(t.pendingClose)throw new Error("Closing the file twice");return new Promise((e,i)=>{t.pendingClose=e,t.pendingCloseReject=i,t._tryClose()}).then(()=>{t.fd.close()},e=>{throw t.fd.close(),e})}async discard(){await this.close(),await Zr.promises.unlink(this.fileName)}async writeULE32(t,e){const i=this,o=new Uint8Array(4);new DataView(o.buffer).setUint32(0,t,!0),await i.write(o,e)}async writeUBE32(t,e){const i=this,o=new Uint8Array(4);new DataView(o.buffer).setUint32(0,t,!1),await i.write(o,e)}async writeULE64(t,e){const i=this,o=new Uint8Array(8),a=new DataView(o.buffer);a.setUint32(0,t&4294967295,!0),a.setUint32(4,Math.floor(t/4294967296),!0),await i.write(o,e)}async readULE32(t){const i=await this.read(4,t);return new Uint32Array(i.buffer)[0]}async readUBE32(t){const i=await this.read(4,t);return new DataView(i.buffer).getUint32(0,!1)}async readULE64(t){const i=await this.read(8,t),o=new Uint32Array(i.buffer);return o[1]*4294967296+o[0]}async readString(t){const e=this;if(e.pendingClose)throw new Error("Reading a closing file");let i=typeof t>"u"?e.pos:t,o=Math.floor(i/e.pageSize),a=!1,u="";for(;!a;){let r=e._loadPage(o);e._triggerLoad(),await r,e.__statusPage("After Await (read): ",o);let I=i%e.pageSize;const l=new Uint8Array(e.pages[o].buff.buffer,e.pages[o].buff.byteOffset+I,e.pageSize-I);let s=l.findIndex(m=>m===0);a=s!==-1,a?(u+=new TextDecoder().decode(l.slice(0,s)),e.pos=o*this.pageSize+I+s+1):(u+=new TextDecoder().decode(l),e.pos=o*this.pageSize+I+l.length),e.pages[o].pendingOps--,e.__statusPage("After Op done: ",o),i=e.pos,o++,e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e))}return u}}function A2(n){const t=n.initialSize||1048576,e=new jr;return e.o=n,e.o.data=new Uint8Array(t),e.allocSize=t,e.totalSize=0,e.readOnly=!1,e.pos=0,e}function b2(n){const t=new jr;return t.o=n,t.allocSize=n.data.byteLength,t.totalSize=n.data.byteLength,t.readOnly=!0,t.pos=0,t}const Go=new Uint8Array(4),ec=new DataView(Go.buffer),Vr=new Uint8Array(8),nc=new DataView(Vr.buffer);class jr{constructor(){this.pageSize=16384}_resizeIfNeeded(t){if(t>this.allocSize){const e=Math.max(this.allocSize+1048576,Math.floor(this.allocSize*1.1),t),i=new Uint8Array(e);i.set(this.o.data),this.o.data=i,this.allocSize=e}}async write(t,e){if(typeof e>"u"&&(e=this.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(e+t.byteLength),this.o.data.set(t.slice(),e),e+t.byteLength>this.totalSize&&(this.totalSize=e+t.byteLength),this.pos=e+t.byteLength}async readToBuffer(t,e,i,o){if(typeof o>"u"&&(o=this.pos),this.readOnly&&o+i>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(o+i);const u=new Uint8Array(this.o.data.buffer,this.o.data.byteOffset+o,i);t.set(u,e),this.pos=o+i}async read(t,e){const i=this,o=new Uint8Array(t);return await i.readToBuffer(o,0,t,e),o}close(){this.o.data.byteLength!=this.totalSize&&(this.o.data=this.o.data.slice(0,this.totalSize))}async discard(){}async writeULE32(t,e){const i=this;ec.setUint32(0,t,!0),await i.write(Go,e)}async writeUBE32(t,e){const i=this;ec.setUint32(0,t,!1),await i.write(Go,e)}async writeULE64(t,e){const i=this;nc.setUint32(0,t&4294967295,!0),nc.setUint32(4,Math.floor(t/4294967296),!0),await i.write(Vr,e)}async readULE32(t){const i=await this.read(4,t);return new Uint32Array(i.buffer)[0]}async readUBE32(t){const i=await this.read(4,t);return new DataView(i.buffer).getUint32(0,!1)}async readULE64(t){const i=await this.read(8,t),o=new Uint32Array(i.buffer);return o[1]*4294967296+o[0]}async readString(t){const e=this;let i=typeof t>"u"?e.pos:t;if(i>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(t)}const o=new Uint8Array(e.o.data.buffer,i,this.totalSize-i);let a=o.findIndex(I=>I===0),u=a!==-1,r="";return u?(r=new TextDecoder().decode(o.slice(0,a)),e.pos=i+a+1):e.pos=i,r}}const de=1<<22;function y2(n){const t=n.initialSize||0,e=new Xr;e.o=n;const i=t?Math.floor((t-1)/de)+1:0;e.o.data=[];for(let o=0;o<i-1;o++)e.o.data.push(new Uint8Array(de));return i&&e.o.data.push(new Uint8Array(t-de*(i-1))),e.totalSize=0,e.readOnly=!1,e.pos=0,e}function I2(n){const t=new Xr;return t.o=n,t.totalSize=(n.data.length-1)*de+n.data[n.data.length-1].byteLength,t.readOnly=!0,t.pos=0,t}const $o=new Uint8Array(4),ic=new DataView($o.buffer),Wr=new Uint8Array(8),oc=new DataView(Wr.buffer);class Xr{constructor(){this.pageSize=16384}_resizeIfNeeded(t){if(t<=this.totalSize)return;if(this.readOnly)throw new Error("Reading out of file bounds");const e=Math.floor((t-1)/de)+1;for(let i=Math.max(this.o.data.length-1,0);i<e;i++){const o=i<e-1?de:t-(e-1)*de,a=new Uint8Array(o);i==this.o.data.length-1&&a.set(this.o.data[i]),this.o.data[i]=a}this.totalSize=t}async write(t,e){const i=this;if(typeof e>"u"&&(e=i.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(e+t.byteLength);let a=Math.floor(e/de),u=e%de,r=t.byteLength;for(;r>0;){const I=u+r>de?de-u:r,l=t.slice(t.byteLength-r,t.byteLength-r+I);new Uint8Array(i.o.data[a].buffer,u,I).set(l),r=r-I,a++,u=0}this.pos=e+t.byteLength}async readToBuffer(t,e,i,o){const a=this;if(typeof o>"u"&&(o=a.pos),this.readOnly&&o+i>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(o+i);let r=Math.floor(o/de),I=o%de,l=i;for(;l>0;){const s=I+l>de?de-I:l,m=new Uint8Array(a.o.data[r].buffer,I,s);t.set(m,e+i-l),l=l-s,r++,I=0}this.pos=o+i}async read(t,e){const i=this,o=new Uint8Array(t);return await i.readToBuffer(o,0,t,e),o}close(){}async discard(){}async writeULE32(t,e){const i=this;ic.setUint32(0,t,!0),await i.write($o,e)}async writeUBE32(t,e){const i=this;ic.setUint32(0,t,!1),await i.write($o,e)}async writeULE64(t,e){const i=this;oc.setUint32(0,t&4294967295,!0),oc.setUint32(4,Math.floor(t/4294967296),!0),await i.write(Wr,e)}async readULE32(t){const i=await this.read(4,t);return new Uint32Array(i.buffer)[0]}async readUBE32(t){const i=await this.read(4,t);return new DataView(i.buffer).getUint32(0,!1)}async readULE64(t){const i=await this.read(8,t),o=new Uint32Array(i.buffer);return o[1]*4294967296+o[0]}async readString(t){const e=this,i=2048;let o=typeof t>"u"?e.pos:t;if(o>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(t)}let a=!1,u="";for(;!a;){let r=Math.floor(o/de),I=o%de;if(e.o.data[r]===void 0)throw new Error("ERROR");let l=Math.min(i,e.o.data[r].length-I);const s=new Uint8Array(e.o.data[r].buffer,I,l);let m=s.findIndex(C=>C===0);a=m!==-1,a?(u+=new TextDecoder().decode(s.slice(0,m)),e.pos=r*de+I+m+1):(u+=new TextDecoder().decode(s),e.pos=r*de+I+s.length),o=e.pos}return u}}const w2=1024,m2=512,C2=2,E2=0,B2=65536,x2=8192;async function Jr(n,t,e){if(typeof n=="string"&&(n={type:"file",fileName:n,cacheSize:B2,pageSize:x2}),n.type=="file")return await Yr(n.fileName,w2|m2|C2,n.cacheSize,n.pageSize);if(n.type=="mem")return A2(n);if(n.type=="bigMem")return y2(n);throw new Error("Invalid FastFile type: "+n.type)}async function ts(n,t,e){if(n instanceof Uint8Array&&(n={type:"mem",data:n}),typeof n=="string"&&(n={type:"mem",data:await fetch(n).then(function(o){return o.arrayBuffer()}).then(function(o){return new Uint8Array(o)})}),n.type=="file")return await Yr(n.fileName,E2,n.cacheSize,n.pageSize);if(n.type=="mem")return await b2(n);if(n.type=="bigMem")return await I2(n);throw new Error("Invalid FastFile type: "+n.type)}async function ac(n,t,e,i,o){const a=await ts(n),u=await a.read(4);let r="";for(let m=0;m<4;m++)r+=String.fromCharCode(u[m]);if(r!=t)throw new Error(n+": Invalid File format");if(await a.readULE32()>e)throw new Error("Version not supported");const l=await a.readULE32();let s=[];for(let m=0;m<l;m++){let C=await a.readULE32(),g=await a.readULE64();typeof s[C]>"u"&&(s[C]=[]),s[C].push({p:a.pos,size:g}),a.pos+=g}return{fd:a,sections:s}}async function F2(n,t,e,i,o,a){const u=await Jr(n),r=new Uint8Array(4);for(let I=0;I<4;I++)r[I]=t.charCodeAt(I);return await u.write(r,0),await u.writeULE32(e),await u.writeULE32(i),u}async function cc(n,t){if(typeof n.writingSection<"u")throw new Error("Already writing a section");await n.writeULE32(t),n.writingSection={pSectionSize:n.pos},await n.writeULE64(0)}async function rc(n){if(typeof n.writingSection>"u")throw new Error("Not writing a section");const t=n.pos-n.writingSection.pSectionSize-8,e=n.pos;n.pos=n.writingSection.pSectionSize,await n.writeULE64(t),n.pos=e,delete n.writingSection}async function Vi(n,t,e){if(typeof n.readingSection<"u")throw new Error("Already reading a section");if(!t[e])throw new Error(n.fileName+": Missing section "+e);if(t[e].length>1)throw new Error(n.fileName+": Section Duplicated "+e);n.pos=t[e][0].p,n.readingSection=t[e][0]}async function ji(n,t){if(typeof n.readingSection>"u")throw new Error("Not reading a section");if(n.pos-n.readingSection.p!=n.readingSection.size)throw new Error("Invalid section size reading");delete n.readingSection}async function v2(n,t,e,i){const o=new Uint8Array(e);oe.toRprLE(o,0,t,e),await n.write(o,i)}async function li(n,t,e){const i=await n.read(t,e);return oe.fromRprLE(i,0,t)}async function dn(n,t,e,i,o){if(i=typeof i>"u"?0:i,o=typeof o>"u"?t[e][0].size-i:o,i+o>t[e][0].size)throw new Error("Reading out of the range of the section");let a;return o<1<<30?a=new Uint8Array(o):a=new ne(o),await n.readToBuffer(a,0,o,t[e][0].p+i),a}oe.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);oe.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");const S2=oe.e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),O2=oe.e("21888242871839275222246405745257275088696311157297823662689037894645226208583");async function ha(n){let t;if(oe.eq(n,O2))t=await $r();else if(oe.eq(n,S2))t=await Kr();else throw new Error(`Curve not supported: ${oe.toString(n)}`);return t}async function U2(n){let t;const e=i(n);if(["BN128","BN254","ALTBN128"].indexOf(e)>=0)t=await $r();else if(["BLS12381"].indexOf(e)>=0)t=await Kr();else throw new Error(`Curve not supported: ${n}`);return t;function i(o){return o.toUpperCase().match(/[A-Za-z0-9]+/g).join("")}}var P2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof ci<"u"?ci:typeof self<"u"?self:{},Ve={exports:{}},M2=ns;class es extends Error{}es.prototype.name="AssertionError";function ns(n,t){if(!n){var e=new es(t);throw Error.captureStackTrace&&Error.captureStackTrace(e,ns),e}}function is(n){return n.length}function k2(n){const t=n.byteLength;let e="";for(let i=0;i<t;i++)e+=String.fromCharCode(n[i]);return e}function T2(n,t,e=0,i=is(t)){const o=Math.min(i,n.byteLength-e);for(let a=0;a<o;a++)n[e+a]=t.charCodeAt(a);return o}var z2={byteLength:is,toString:k2,write:T2};const Un="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gn=new Uint8Array(256);for(let n=0;n<Un.length;n++)gn[Un.charCodeAt(n)]=n;gn[45]=62;gn[95]=63;function os(n){let t=n.length;return n.charCodeAt(t-1)===61&&t--,t>1&&n.charCodeAt(t-1)===61&&t--,t*3>>>2}function R2(n){const t=n.byteLength;let e="";for(let i=0;i<t;i+=3)e+=Un[n[i]>>2]+Un[(n[i]&3)<<4|n[i+1]>>4]+Un[(n[i+1]&15)<<2|n[i+2]>>6]+Un[n[i+2]&63];return t%3===2?e=e.substring(0,e.length-1)+"=":t%3===1&&(e=e.substring(0,e.length-2)+"=="),e}function Q2(n,t,e=0,i=os(t)){const o=Math.min(i,n.byteLength-e);for(let a=0,u=0;a<o;a+=4){const r=gn[t.charCodeAt(a)],I=gn[t.charCodeAt(a+1)],l=gn[t.charCodeAt(a+2)],s=gn[t.charCodeAt(a+3)];n[u++]=r<<2|I>>4,n[u++]=(I&15)<<4|l>>2,n[u++]=(l&3)<<6|s&63}return o}var D2={byteLength:os,toString:R2,write:Q2};function as(n){return n.length>>>1}function q2(n){const t=n.byteLength;n=new DataView(n.buffer,n.byteOffset,t);let e="",i=0;for(let o=t-t%4;i<o;i+=4)e+=n.getUint32(i).toString(16).padStart(8,"0");for(;i<t;i++)e+=n.getUint8(i).toString(16).padStart(2,"0");return e}function N2(n,t,e=0,i=as(t)){const o=Math.min(i,n.byteLength-e);for(let a=0;a<o;a++){const u=sc(t.charCodeAt(a*2)),r=sc(t.charCodeAt(a*2+1));if(u===void 0||r===void 0)return n.subarray(0,a);n[e+a]=u<<4|r}return o}var G2={byteLength:as,toString:q2,write:N2};function sc(n){if(n>=48&&n<=57)return n-48;if(n>=65&&n<=70)return n-65+10;if(n>=97&&n<=102)return n-97+10}function Ko(n){let t=0;for(let e=0,i=n.length;e<i;e++){const o=n.charCodeAt(e);if(o>=55296&&o<=56319&&e+1<i){const a=n.charCodeAt(e+1);if(a>=56320&&a<=57343){t+=4,e++;continue}}o<=127?t+=1:o<=2047?t+=2:t+=3}return t}let Ho;if(typeof TextDecoder<"u"){const n=new TextDecoder;Ho=function(e){return n.decode(e)}}else Ho=function(t){const e=t.byteLength;let i="",o=0;for(;o<e;){let a=t[o];if(a<=127){i+=String.fromCharCode(a),o++;continue}let u=0,r=0;if(a<=223?(u=1,r=a&31):a<=239?(u=2,r=a&15):a<=244&&(u=3,r=a&7),e-o-u>0){let I=0;for(;I<u;)a=t[o+I+1],r=r<<6|a&63,I+=1}else r=65533,u=e-o;i+=String.fromCodePoint(r),o+=u+1}return i};let Zo;if(typeof TextEncoder<"u"){const n=new TextEncoder;Zo=function(e,i,o=0,a=Ko(i)){const u=Math.min(a,e.byteLength-o);return n.encodeInto(i,e.subarray(o,o+u)),u}}else Zo=function(t,e,i=0,o=Ko(e)){const a=Math.min(o,t.byteLength-i);t=t.subarray(i,i+a);let u=0,r=0;for(;u<e.length;){const I=e.codePointAt(u);if(I<=127){t[r++]=I,u++;continue}let l=0,s=0;for(I<=2047?(l=6,s=192):I<=65535?(l=12,s=224):I<=2097151&&(l=18,s=240),t[r++]=s|I>>l,l-=6;l>=0;)t[r++]=128|I>>l&63,l-=6;u+=I>=65536?2:1}return a};var $2={byteLength:Ko,toString:Ho,write:Zo};function cs(n){return n.length*2}function K2(n){const t=n.byteLength;let e="";for(let i=0;i<t-1;i+=2)e+=String.fromCharCode(n[i]+n[i+1]*256);return e}function H2(n,t,e=0,i=cs(t)){const o=Math.min(i,n.byteLength-e);let a=o;for(let u=0;u<t.length&&!((a-=2)<0);++u){const r=t.charCodeAt(u),I=r>>8,l=r%256;n[e+u*2]=l,n[e+u*2+1]=I}return o}var Z2={byteLength:cs,toString:K2,write:H2};const Y2=z2,V2=D2,j2=G2,W2=$2,X2=Z2;function Wi(n){switch(n){case"ascii":return Y2;case"base64":return V2;case"hex":return j2;case"utf8":case"utf-8":case void 0:return W2;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return X2;default:throw new Error(`Unknown encoding: ${n}`)}}function rs(n){return n instanceof Uint8Array}function J2(n,t,e){const i=new Uint8Array(n);return t!==void 0&&t(i,t,0,i.byteLength,e),i}function tu(n){return new Uint8Array(n)}function eu(n){return new Uint8Array(n)}function nu(n,t){return Wi(t).byteLength(n)}function iu(n,t){if(n===t)return 0;const e=Math.min(n.byteLength,t.byteLength);n=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(let o=e-e%4;i<o;i+=4){const a=n.getUint32(i),u=t.getUint32(i);if(a<u)return-1;if(a>u)return 1}for(;i<e;i++){const o=n.getUint8(i),a=t.getUint8(i);if(o<a)return-1;if(o>a)return 1}return n.byteLength>t.byteLength?1:n.byteLength<t.byteLength?-1:0}function ou(n,t){t===void 0&&(t=n.reduce((i,o)=>i+o.byteLength,0));const e=new Uint8Array(t);return n.reduce((i,o)=>(e.set(o,i),i+o.byteLength),0),e}function au(n,t,e=0,i=0,o=n.byteLength){if(o>0&&o<i||o===i||n.byteLength===0||t.byteLength===0)return 0;if(e<0)throw new RangeError("targetStart is out of range");if(i<0||i>=n.byteLength)throw new RangeError("sourceStart is out of range");if(o<0)throw new RangeError("sourceEnd is out of range");e>=t.byteLength&&(e=t.byteLength),o>n.byteLength&&(o=n.byteLength),t.byteLength-e<o-i&&(o=t.length-e+i);const a=o-i;return n===t?t.copyWithin(e,i,o):t.set(n.subarray(i,o),e),a}function cu(n,t){if(n===t)return!0;if(n.byteLength!==t.byteLength)return!1;const e=n.byteLength;n=new DataView(n.buffer,n.byteOffset,n.byteLength),t=new DataView(t.buffer,t.byteOffset,t.byteLength);let i=0;for(let o=e-e%4;i<o;i+=4)if(n.getUint32(i)!==t.getUint32(i))return!1;for(;i<e;i++)if(n.getUint8(i)!==t.getUint8(i))return!1;return!0}function ru(n,t,e,i,o){if(typeof t=="string"?typeof e=="string"?(o=e,e=0,i=n.byteLength):typeof i=="string"&&(o=i,i=n.byteLength):typeof val=="number"?t=t&255:typeof val=="boolean"&&(t=+t),e<0||n.byteLength<e||n.byteLength<i)throw new RangeError("Out of range index");if(e===void 0&&(e=0),i===void 0&&(i=n.byteLength),i<=e)return n;if(t||(t=0),typeof t=="number")for(let a=e;a<i;++a)n[a]=t;else{t=rs(t)?t:ss(t,o);const a=t.byteLength;for(let u=0;u<i-e;++u)n[u+e]=t[u%a]}return n}function ss(n,t,e){return typeof n=="string"?su(n,t):Array.isArray(n)?lu(n):ArrayBuffer.isView(n)?du(n):uu(n,t,e)}function su(n,t){const e=Wi(t),i=new Uint8Array(e.byteLength(n));return e.write(i,n,0,i.byteLength),i}function lu(n){const t=new Uint8Array(n.length);return t.set(n),t}function du(n){const t=new Uint8Array(n.byteLength);return t.set(n),t}function uu(n,t,e){return new Uint8Array(n,t,e)}function pn(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function fu(n){const t=n.byteLength;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)pn(n,e,e+1);return n}function _u(n){const t=n.byteLength;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)pn(n,e,e+3),pn(n,e+1,e+2);return n}function hu(n){const t=n.byteLength;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)pn(n,e,e+7),pn(n,e+1,e+6),pn(n,e+2,e+5),pn(n,e+3,e+4);return n}function gu(n){return n}function pu(n,t,e=0,i=n.byteLength){const o=n.byteLength;return e>=o||i<=e?"":(e<0&&(e=0),i>o&&(i=o),(e!==0||i<o)&&(n=n.subarray(e,i)),Wi(t).toString(n))}function Lu(n,t,e,i,o){return e===void 0?o="utf8":i===void 0&&typeof e=="string"?(o=e,e=void 0):o===void 0&&typeof i=="string"&&(o=i,i=void 0),Wi(o).write(n,t,e,i)}var Au={isBuffer:rs,alloc:J2,allocUnsafe:tu,allocUnsafeSlow:eu,byteLength:nu,compare:iu,concat:ou,copy:au,equals:cu,fill:ru,from:ss,swap16:fu,swap32:_u,swap64:hu,toBuffer:gu,toString:pu,write:Lu},yo,lc;function bu(){if(lc)return yo;lc=1;var n=(a,u)=>function(){return u||(0,a[Object.keys(a)[0]])((u={exports:{}}).exports,u),u.exports},t=(()=>{for(var a=new Uint8Array(128),u=0;u<64;u++)a[u<26?u+65:u<52?u+71:u<62?u-4:u*4-205]=u;return r=>{for(var I=r.length,l=new Uint8Array((I-(r[I-1]=="=")-(r[I-2]=="="))*3/4|0),s=0,m=0;s<I;){var C=a[r.charCodeAt(s++)],g=a[r.charCodeAt(s++)],M=a[r.charCodeAt(s++)],$=a[r.charCodeAt(s++)];l[m++]=C<<2|g>>4,l[m++]=g<<4|M>>2,l[m++]=M<<6|$}return l}})(),e=n({"wasm-binary:./blake2b.wat"(a,u){u.exports=t("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMKvz8EwAIAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCAAQgA3AyAgAEIANwMoIABCADcDMCAAQgA3AzggAEIANwNAIABCADcDSCAAQgA3A1AgAEIANwNYIABCADcDYCAAQgA3A2ggAEIANwNwIABCADcDeCAAQoiS853/zPmE6gBBACkDAIU3A4ABIABCu86qptjQ67O7f0EIKQMAhTcDiAEgAEKr8NP0r+68tzxBECkDAIU3A5ABIABC8e30+KWn/aelf0EYKQMAhTcDmAEgAELRhZrv+s+Uh9EAQSApAwCFNwOgASAAQp/Y+dnCkdqCm39BKCkDAIU3A6gBIABC6/qG2r+19sEfQTApAwCFNwOwASAAQvnC+JuRo7Pw2wBBOCkDAIU3A7gBIABCADcDwAEgAEIANwPIASAAQgA3A9ABC20BA38gAEHAAWohAyAAQcgBaiEEIAQpAwCnIQUCQANAIAEgAkYNASAFQYABRgRAIAMgAykDACAFrXw3AwBBACEFIAAQAwsgACAFaiABLQAAOgAAIAVBAWohBSABQQFqIQEMAAsLIAQgBa03AwALYQEDfyAAQcABaiEBIABByAFqIQIgASABKQMAIAIpAwB8NwMAIABCfzcD0AEgAikDAKchAwJAA0AgA0GAAUYNASAAIANqQQA6AAAgA0EBaiEDDAALCyACIAOtNwMAIAAQAwuqOwIgfgl/IABBgAFqISEgAEGIAWohIiAAQZABaiEjIABBmAFqISQgAEGgAWohJSAAQagBaiEmIABBsAFqIScgAEG4AWohKCAhKQMAIQEgIikDACECICMpAwAhAyAkKQMAIQQgJSkDACEFICYpAwAhBiAnKQMAIQcgKCkDACEIQoiS853/zPmE6gAhCUK7zqqm2NDrs7t/IQpCq/DT9K/uvLc8IQtC8e30+KWn/aelfyEMQtGFmu/6z5SH0QAhDUKf2PnZwpHagpt/IQ5C6/qG2r+19sEfIQ9C+cL4m5Gjs/DbACEQIAApAwAhESAAKQMIIRIgACkDECETIAApAxghFCAAKQMgIRUgACkDKCEWIAApAzAhFyAAKQM4IRggACkDQCEZIAApA0ghGiAAKQNQIRsgACkDWCEcIAApA2AhHSAAKQNoIR4gACkDcCEfIAApA3ghICANIAApA8ABhSENIA8gACkD0AGFIQ8gASAFIBF8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSASfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgE3x8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBR8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAVfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgFnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBd8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAYfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgGXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBp8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAbfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgHHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIB18fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAefHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgH3x8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFICB8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAffHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgG3x8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBV8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAZfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgGnx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHICB8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAefHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggF3x8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBJ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAdfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgEXx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBN8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAcfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGHx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBZ8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAUfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgHHx8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBl8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAdfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgEXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBZ8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByATfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggIHx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIB58fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAbfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgH3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBR8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAXfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggGHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBJ8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAafHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFXx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBh8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAafHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgFHx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBJ8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAefHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHXx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBx8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAffHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgE3x8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBd8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAWfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgG3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBV8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCARfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgIHx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBl8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAafHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEXx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBZ8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAYfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgE3x8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBV8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAbfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggIHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIB98fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiASfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgHHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIB18fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAXfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGXx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBR8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAefHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgE3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIB18fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAXfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgG3x8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBF8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAcfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggGXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBR8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAVfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHnx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBh8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAWfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggIHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIB98fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSASfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgGnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIB18fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAWfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgEnx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGICB8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAffHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBV8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAbfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgEXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBh8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAXfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgFHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBp8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCATfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgGXx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBx8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAefHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgHHx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBh8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAffHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgHXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBJ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAUfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGnx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBZ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiARfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgIHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBV8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAZfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggF3x8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBN8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAbfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgF3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFICB8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAffHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGnx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBx8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAUfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggEXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBl8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAdfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgE3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIB58fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAYfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggEnx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBV8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAbfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBt8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSATfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgGXx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBV8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAYfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgF3x8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBJ8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAWfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgIHx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBx8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAafHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgH3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBR8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAdfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgHnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBF8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSARfHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEnx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBN8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAUfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgFXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBZ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAXfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBl8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAafHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgG3x8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBx8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAdfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggHnx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIB98fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAgfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgH3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBt8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAVfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBp8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAgfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggHnx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBd8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiASfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHXx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBF8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByATfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggHHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBh8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAWfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFHx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgISAhKQMAIAEgCYWFNwMAICIgIikDACACIAqFhTcDACAjICMpAwAgAyALhYU3AwAgJCAkKQMAIAQgDIWFNwMAICUgJSkDACAFIA2FhTcDACAmICYpAwAgBiAOhYU3AwAgJyAnKQMAIAcgD4WFNwMAICggKCkDACAIIBCFhTcDAAs=")}}),i=e(),o=WebAssembly.compile(i);return yo=async a=>(await WebAssembly.instantiate(await o,a)).exports,yo}var we=M2,yu=Au,Ye=null,dc=typeof WebAssembly<"u"&&bu()().then(n=>{Ye=n}),Ke=64,zi=[];Ve.exports=Le;var uc=Ve.exports.BYTES_MIN=16,fc=Ve.exports.BYTES_MAX=64;Ve.exports.BYTES=32;var _c=Ve.exports.KEYBYTES_MIN=16,hc=Ve.exports.KEYBYTES_MAX=64;Ve.exports.KEYBYTES=32;var gc=Ve.exports.SALTBYTES=16,pc=Ve.exports.PERSONALBYTES=16;function Le(n,t,e,i,o){if(!(this instanceof Le))return new Le(n,t,e,i,o);if(!Ye)throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");n||(n=32),o!==!0&&(we(n>=uc,"digestLength must be at least "+uc+", was given "+n),we(n<=fc,"digestLength must be at most "+fc+", was given "+n),t!=null&&(we(t instanceof Uint8Array,"key must be Uint8Array or Buffer"),we(t.length>=_c,"key must be at least "+_c+", was given "+t.length),we(t.length<=hc,"key must be at least "+hc+", was given "+t.length)),e!=null&&(we(e instanceof Uint8Array,"salt must be Uint8Array or Buffer"),we(e.length===gc,"salt must be exactly "+gc+", was given "+e.length)),i!=null&&(we(i instanceof Uint8Array,"personal must be Uint8Array or Buffer"),we(i.length===pc,"personal must be exactly "+pc+", was given "+i.length))),zi.length||(zi.push(Ke),Ke+=216),this.digestLength=n,this.finalized=!1,this.pointer=zi.pop(),this._memory=new Uint8Array(Ye.memory.buffer),this._memory.fill(0,0,64),this._memory[0]=this.digestLength,this._memory[1]=t?t.length:0,this._memory[2]=1,this._memory[3]=1,e&&this._memory.set(e,32),i&&this._memory.set(i,48),this.pointer+216>this._memory.length&&this._realloc(this.pointer+216),Ye.blake2b_init(this.pointer,this.digestLength),t&&(this.update(t),this._memory.fill(0,Ke,Ke+t.length),this._memory[this.pointer+200]=128)}Le.prototype._realloc=function(n){Ye.memory.grow(Math.max(0,Math.ceil(Math.abs(n-this._memory.length)/65536))),this._memory=new Uint8Array(Ye.memory.buffer)};Le.prototype.update=function(n){return we(this.finalized===!1,"Hash instance finalized"),we(n instanceof Uint8Array,"input must be Uint8Array or Buffer"),Ke+n.length>this._memory.length&&this._realloc(Ke+n.length),this._memory.set(n,Ke),Ye.blake2b_update(this.pointer,Ke,Ke+n.length),this};Le.prototype.digest=function(n){if(we(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,zi.push(this.pointer),Ye.blake2b_final(this.pointer),!n||n==="binary")return this._memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(typeof n=="string")return yu.toString(this._memory,n,this.pointer+128,this.pointer+128+this.digestLength);we(n instanceof Uint8Array&&n.length>=this.digestLength,"input must be Uint8Array or Buffer");for(var t=0;t<this.digestLength;t++)n[t]=this._memory[this.pointer+128+t];return n};Le.prototype.final=Le.prototype.digest;Le.WASM=Ye;Le.SUPPORTED=typeof WebAssembly<"u";Le.ready=function(n){return n||(n=Iu),dc?dc.then(()=>n(),n):n(new Error("WebAssembly not supported"))};Le.prototype.ready=Le.ready;Le.prototype.getPartialHash=function(){return this._memory.slice(this.pointer,this.pointer+216)};Le.prototype.setPartialHash=function(n){this._memory.set(n,this.pointer)};function Iu(){}function ga(n){return(n&4294901760?(n&=4294901760,16):0)|(n&4278255360?(n&=4278255360,8):0)|(n&4042322160?(n&=4042322160,4):0)|(n&3435973836?(n&=3435973836,2):0)|(n&2863311530)!==0}async function ve(n,t,e){const i=await n.read(t.G1.F.n8*2),o=t.G1.fromRprLEM(i,0);return e?t.G1.toObject(o):o}async function Ri(n,t,e){const i=await n.read(t.G2.F.n8*2),o=t.G2.fromRprLEM(i,0);return e?t.G2.toObject(o):o}async function wu(n,t,e){await Vi(n,t,1);const i=await n.readULE32();if(await ji(n),i==1)return await mu(n,t,e);if(i==2)return await Cu(n,t);throw new Error("Protocol not supported: ")}async function mu(n,t,e){const i={};i.protocol="groth16",await Vi(n,t,2);const o=await n.readULE32();i.n8q=o,i.q=await li(n,o);const a=await n.readULE32();i.n8r=a,i.r=await li(n,a);let u=await ha(i.q);return i.nVars=await n.readULE32(),i.nPublic=await n.readULE32(),i.domainSize=await n.readULE32(),i.power=ga(i.domainSize),i.vk_alpha_1=await ve(n,u,e),i.vk_beta_1=await ve(n,u,e),i.vk_beta_2=await Ri(n,u,e),i.vk_gamma_2=await Ri(n,u,e),i.vk_delta_1=await ve(n,u,e),i.vk_delta_2=await Ri(n,u,e),await ji(n),i}async function Cu(n,t,e,i){const o={};o.protocol="plonk",await Vi(n,t,2);const a=await n.readULE32();o.n8q=a,o.q=await li(n,a);const u=await n.readULE32();o.n8r=u,o.r=await li(n,u);let r=await ha(o.q);return o.nVars=await n.readULE32(),o.nPublic=await n.readULE32(),o.domainSize=await n.readULE32(),o.power=ga(o.domainSize),o.nAdditions=await n.readULE32(),o.nConstrains=await n.readULE32(),o.k1=await n.read(u),o.k2=await n.read(u),o.Qm=await ve(n,r,i),o.Ql=await ve(n,r,i),o.Qr=await ve(n,r,i),o.Qo=await ve(n,r,i),o.Qc=await ve(n,r,i),o.S1=await ve(n,r,i),o.S2=await ve(n,r,i),o.S3=await ve(n,r,i),o.X_2=await Ri(n,r,i),await ji(n),o}async function Eu(n,t,e){await cc(n,1);const i=(Math.floor((oe.bitLength(e)-1)/64)+1)*8;if(await n.writeULE32(i),await v2(n,e,i),t.byteLength%i!=0)throw new Error("Invalid witness length");await n.writeULE32(t.byteLength/i),await rc(n),await cc(n,2),await n.write(t),await rc(n)}async function Bu(n,t){await Vi(n,t,1);const e=await n.readULE32(),i=await li(n,e),o=await n.readULE32();return await ji(n),{n8:e,q:i,nWitness:o}}const{stringifyBigInts:Lc}=Hr;async function ls(n,t,e){const{fd:i,sections:o}=await ac(t,"wtns",2),a=await Bu(i,o),{fd:u,sections:r}=await ac(n,"zkey",2),I=await wu(u,r);if(I.protocol!="groth16")throw new Error("zkey file is not groth16");if(!oe.eq(I.r,a.q))throw new Error("Curve of the witness does not match the curve of the proving key");if(a.nWitness!=I.nVars)throw new Error(`Invalid witness length. Circuit: ${I.nVars}, witness: ${a.nWitness}`);const l=await ha(I.q),s=l.Fr,m=l.G1,C=l.G2,g=ga(I.domainSize);e&&e.debug("Reading Wtns");const M=await dn(i,o,2);e&&e.debug("Reading Coeffs");const $=await dn(u,r,4);e&&e.debug("Building ABC");const[F,R,x]=await xu(l,I,M,$,e),it=g==s.s?l.Fr.shift:l.Fr.w[g+1],z=await s.ifft(F,"","",e,"IFFT_A"),K=await s.batchApplyKey(z,s.e(1),it),v=await s.fft(K,"","",e,"FFT_A"),f=await s.ifft(R,"","",e,"IFFT_B"),L=await s.batchApplyKey(f,s.e(1),it),V=await s.fft(L,"","",e,"FFT_B"),X=await s.ifft(x,"","",e,"IFFT_C"),et=await s.batchApplyKey(X,s.e(1),it),N=await s.fft(et,"","",e,"FFT_C");e&&e.debug("Join ABC");const w=await Fu(l,I,v,V,N,e);let T={};e&&e.debug("Reading A Points");const at=await dn(u,r,5);T.pi_a=await l.G1.multiExpAffine(at,M,e,"multiexp A"),e&&e.debug("Reading B1 Points");const Lt=await dn(u,r,6);let _t=await l.G1.multiExpAffine(Lt,M,e,"multiexp B1");e&&e.debug("Reading B2 Points");const ct=await dn(u,r,7);T.pi_b=await l.G2.multiExpAffine(ct,M,e,"multiexp B2"),e&&e.debug("Reading C Points");const yt=await dn(u,r,8);T.pi_c=await l.G1.multiExpAffine(yt,M.slice((I.nPublic+1)*l.Fr.n8),e,"multiexp C"),e&&e.debug("Reading H Points");const ft=await dn(u,r,9),ht=await l.G1.multiExpAffine(ft,w,e,"multiexp H"),Ft=l.Fr.random(),Nt=l.Fr.random();T.pi_a=m.add(T.pi_a,I.vk_alpha_1),T.pi_a=m.add(T.pi_a,m.timesFr(I.vk_delta_1,Ft)),T.pi_b=C.add(T.pi_b,I.vk_beta_2),T.pi_b=C.add(T.pi_b,C.timesFr(I.vk_delta_2,Nt)),_t=m.add(_t,I.vk_beta_1),_t=m.add(_t,m.timesFr(I.vk_delta_1,Nt)),T.pi_c=m.add(T.pi_c,ht),T.pi_c=m.add(T.pi_c,m.timesFr(T.pi_a,Nt)),T.pi_c=m.add(T.pi_c,m.timesFr(_t,Ft)),T.pi_c=m.add(T.pi_c,m.timesFr(I.vk_delta_1,s.neg(s.mul(Ft,Nt))));let kt=[];for(let A=1;A<=I.nPublic;A++){const c=M.slice(A*s.n8,A*s.n8+s.n8);kt.push(oe.fromRprLE(c))}return T.pi_a=m.toObject(m.toAffine(T.pi_a)),T.pi_b=C.toObject(C.toAffine(T.pi_b)),T.pi_c=m.toObject(m.toAffine(T.pi_c)),T.protocol="groth16",T.curve=l.name,await u.close(),await i.close(),T=Lc(T),kt=Lc(kt),{proof:T,publicSignals:kt}}async function xu(n,t,e,i,o){const a=n.Fr.n8,u=4*3+t.n8r,r=(i.byteLength-4)/u,I=new ne(t.domainSize*a),l=new ne(t.domainSize*a),s=new ne(t.domainSize*a),m=[I,l];for(let C=0;C<r;C++){o&&C%1e6==0&&o.debug(`QAP AB: ${C}/${r}`);const g=i.slice(4+C*u,4+C*u+u),M=new DataView(g.buffer),$=M.getUint32(0,!0),F=M.getUint32(4,!0),R=M.getUint32(8,!0),x=g.slice(12,12+a);m[$].set(n.Fr.add(m[$].slice(F*a,F*a+a),n.Fr.mul(x,e.slice(R*a,R*a+a))),F*a)}for(let C=0;C<t.domainSize;C++)o&&C%1e6==0&&o.debug(`QAP C: ${C}/${t.domainSize}`),s.set(n.Fr.mul(I.slice(C*a,C*a+a),l.slice(C*a,C*a+a)),C*a);return[I,l,s]}async function Fu(n,t,e,i,o,a){const r=n.Fr.n8,I=Math.floor(e.byteLength/n.Fr.n8),l=[];for(let g=0;g<I;g+=4194304){a&&a.debug(`JoinABC: ${g}/${I}`);const M=Math.min(I-g,4194304),$=[],F=e.slice(g*r,(g+M)*r),R=i.slice(g*r,(g+M)*r),x=o.slice(g*r,(g+M)*r);$.push({cmd:"ALLOCSET",var:0,buff:F}),$.push({cmd:"ALLOCSET",var:1,buff:R}),$.push({cmd:"ALLOCSET",var:2,buff:x}),$.push({cmd:"ALLOC",var:3,len:M*r}),$.push({cmd:"CALL",fnName:"qap_joinABC",params:[{var:0},{var:1},{var:2},{val:M},{var:3}]}),$.push({cmd:"CALL",fnName:"frm_batchFromMontgomery",params:[{var:3},{val:M},{var:3}]}),$.push({cmd:"GET",out:0,var:3,len:M*r}),l.push(n.tm.queueAction($))}const s=await Promise.all(l);let m;e instanceof ne?m=new ne(e.byteLength):m=new Uint8Array(e.byteLength);let C=0;for(let g=0;g<s.length;g++)m.set(s[g][0],C),C+=s[g][0].byteLength;return m}function ds(n){let t=[];return e(t,n),t;function e(i,o){if(Array.isArray(o))for(let a=0;a<o.length;a++)e(i,o[a]);else i.push(o)}}function vu(n,t){let e=BigInt(n)%t;return e<0&&(e+=t),e}function us(n){const t=BigInt(2)**BigInt(64);let e=BigInt("0xCBF29CE484222325");for(let a=0;a<n.length;a++)e^=BigInt(n[a].charCodeAt(0)),e*=BigInt(1099511628211),e%=t;let i=e.toString(16),o=16-i.length;return i="0".repeat(o).concat(i),i}function Su(n,t){const e=[];let i=BigInt(n);const o=BigInt(4294967296);for(;i;)e.unshift(Number(i%o)),i=i/o;if(t){let a=t-e.length;for(;a>0;)e.unshift(0),a--}return e}async function Ou(n,t){let e,i,o;t=t||{};let a=1,u=0,r=0,I=!1;if(n instanceof WebAssembly.Instance)e=n,I=!0;else{let C=32767;if(t.memorySize&&(C=parseInt(t.memorySize),C<0))throw new Error("Invalid memory size");let g=!1;for(;!g;)try{o=new WebAssembly.Memory({initial:C}),g=!0}catch(R){if(C<=1)throw R;console.warn("Could not allocate "+C*1024*64+" bytes. This may cause severe instability. Trying with "+C*1024*64/2+" bytes"),C=Math.floor(C/2)}const M=await WebAssembly.compile(n);let $="",F="";e=await WebAssembly.instantiate(M,{env:{memory:o},runtime:{printDebug:function(R){console.log("printDebug:",R)},exceptionHandler:function(R){let x;throw R===1?x="Signal not found. ":R===2?x="Too many signals set. ":R===3?x="Signal already set. ":R===4?x="Assert Failed. ":R===5?x="Not enough memory. ":R===6?x="Input signal array access exceeds the size. ":x="Unknown error. ",console.error("ERROR: ",R,$),new Error(x+$)},printErrorMessage:function(){$+=s()+`
|
|
131
|
-
`},writeBufferMessage:function(){const R=s();R===`
|
|
132
|
-
`?(console.log(F),F=""):(F!==""&&(F+=" "),F+=R)},showSharedRWMemory:function(){const R=e.exports.getFieldNumLen32(),x=new Uint32Array(R);for(let it=0;it<R;it++)x[R-1-it]=e.exports.readSharedRWMemory(it);if(a>=2&&(u>=1||r>=7)){F!==""&&(F+=" ");const it=oe.fromArray(x,4294967296).toString();F+=it}else console.log(oe.fromArray(x,4294967296))},error:function(R,x,it,z,K,v){let f;throw R===7?f=m(x)+" "+i.getFr(z).toString()+" != "+i.getFr(K).toString()+" "+m(v):R===9?f=m(x)+" "+i.getFr(z).toString()+" "+m(K):R===5&&t.sym?f=m(x)+" "+t.sym.labelIdx2Name[K]:f=m(x)+" "+it+" "+z+" "+K+" "+v,console.log("ERROR: ",R,f),new Error(f)},log:function(R){console.log(i.getFr(R).toString())},logGetSignal:function(R,x){t.logGetSignal&&t.logGetSignal(R,i.getFr(x))},logSetSignal:function(R,x){t.logSetSignal&&t.logSetSignal(R,i.getFr(x))},logStartComponent:function(R){t.logStartComponent&&t.logStartComponent(R)},logFinishComponent:function(R){t.logFinishComponent&&t.logFinishComponent(R)}}})}typeof e.exports.getVersion=="function"&&(a=e.exports.getVersion()),typeof e.exports.getMinorVersion=="function"&&(u=e.exports.getMinorVersion()),typeof e.exports.getPatchVersion=="function"&&(r=e.exports.getPatchVersion());const l=t&&(t.sanityCheck||t.logGetSignal||t.logSetSignal||t.logStartComponent||t.logFinishComponent);if(a===2)i=new Pu(e,l);else if(a===1){if(I)throw new Error("Loading code from WebAssembly instance is not supported for circom version 1");i=new Uu(o,e,l)}else throw new Error(`Unsupported circom version: ${a}`);return i;function s(){let C="",g=e.exports.getMessageChar();for(;g!==0;)C+=String.fromCharCode(g),g=e.exports.getMessageChar();return C}function m(C){const g=new Uint8Array(o.buffer),M=[];for(let $=0;g[C+$]>0;$++)M.push(g[C+$]);return String.fromCharCode.apply(null,M)}}class Uu{constructor(t,e,i){this.memory=t,this.i32=new Uint32Array(t.buffer),this.instance=e,this.n32=(this.instance.exports.getFrLen()>>2)-2;const o=this.instance.exports.getPRawPrime(),a=new Array(this.n32);for(let u=0;u<this.n32;u++)a[this.n32-1-u]=this.i32[(o>>2)+u];this.prime=oe.fromArray(a,4294967296),this.Fr=new ud(this.prime),this.mask32=oe.fromString("FFFFFFFF",16),this.NVars=this.instance.exports.getNVars(),this.n64=Math.floor((this.Fr.bitLength-1)/64)+1,this.R=this.Fr.e(oe.shiftLeft(1,this.n64*64)),this.RInv=this.Fr.inv(this.R),this.sanityCheck=i}circom_version(){return 1}async _doCalculateWitness(t,e){this.instance.exports.init(this.sanityCheck||e?1:0);const i=this.allocInt(),o=this.allocFr();Object.keys(t).forEach(u=>{const r=us(u),I=parseInt(r.slice(0,8),16),l=parseInt(r.slice(8,16),16);try{this.instance.exports.getSignalOffset32(i,0,I,l)}catch{throw new Error(`Signal ${u} is not an input of the circuit.`)}const s=this.getInt(i),m=ds(t[u]);for(let C=0;C<m.length;C++)this.setFr(o,m[C]),this.instance.exports.setSignal(0,0,s+C,o)})}async calculateWitness(t,e){const i=this,o=i.i32[0],a=[];await i._doCalculateWitness(t,e);for(let u=0;u<i.NVars;u++){const r=i.instance.exports.getPWitness(u);a.push(i.getFr(r))}return i.i32[0]=o,a}async calculateBinWitness(t,e){const i=this,o=i.i32[0];await i._doCalculateWitness(t,e);const a=i.instance.exports.getWitnessBuffer();i.i32[0]=o;const u=i.memory.buffer.slice(a,a+i.NVars*i.n64*8);return new Uint8Array(u)}allocInt(){const t=this.i32[0];return this.i32[0]=t+8,t}allocFr(){const t=this.i32[0];return this.i32[0]=t+this.n32*4+8,t}getInt(t){return this.i32[t>>2]}setInt(t,e){this.i32[t>>2]=e}getFr(t){const e=this,i=t>>2;if(e.i32[i+1]&2147483648){const a=new Array(e.n32);for(let r=0;r<e.n32;r++)a[e.n32-1-r]=e.i32[i+2+r];const u=e.Fr.e(oe.fromArray(a,4294967296));return e.i32[i+1]&1073741824?o(u):u}else return e.i32[i]&2147483648?e.Fr.e(e.i32[i]-4294967296):e.Fr.e(e.i32[i]);function o(a){return e.Fr.mul(e.RInv,a)}}setFr(t,e){const i=this;e=i.Fr.e(e);const o=i.Fr.neg(i.Fr.e("80000000",16)),a=i.Fr.e("7FFFFFFF",16);if(i.Fr.geq(e,o)&&i.Fr.leq(e,a)){let r;i.Fr.geq(e,i.Fr.zero)?r=oe.toNumber(e):(r=oe.toNumber(i.Fr.sub(e,o)),r=r-2147483648,r=4294967296+r),i.i32[t>>2]=r,i.i32[(t>>2)+1]=0;return}i.i32[t>>2]=0,i.i32[(t>>2)+1]=2147483648;const u=oe.toArray(e,4294967296);for(let r=0;r<i.n32;r++){const I=u.length-1-r;I>=0?i.i32[(t>>2)+2+r]=u[I]:i.i32[(t>>2)+2+r]=0}}}class Pu{constructor(t,e){this.instance=t,this.version=this.instance.exports.getVersion(),this.n32=this.instance.exports.getFieldNumLen32(),this.instance.exports.getRawPrime();const i=new Uint32Array(this.n32);for(let o=0;o<this.n32;o++)i[this.n32-1-o]=this.instance.exports.readSharedRWMemory(o);this.prime=oe.fromArray(i,4294967296),this.witnessSize=this.instance.exports.getWitnessSize(),this.sanityCheck=e}circom_version(){return this.instance.exports.getVersion()}async _doCalculateWitness(t,e){this.instance.exports.init(this.sanityCheck||e?1:0);const i=Object.keys(t);let o=0;if(i.forEach(a=>{const u=us(a),r=parseInt(u.slice(0,8),16),I=parseInt(u.slice(8,16),16),l=ds(t[a]);if(typeof this.instance.exports.getInputSignalSize=="function"){let s=this.instance.exports.getInputSignalSize(r,I);if(s<0)throw new Error(`Signal ${a} not found
|
|
133
|
-
`);if(l.length<s)throw new Error(`Not enough values for input signal ${a}
|
|
134
|
-
`);if(l.length>s)throw new Error(`Too many values for input signal ${a}
|
|
135
|
-
`)}for(let s=0;s<l.length;s++){const m=Su(vu(l[s],this.prime),this.n32);for(let C=0;C<this.n32;C++)this.instance.exports.writeSharedRWMemory(C,m[this.n32-1-C]);try{this.instance.exports.setInputSignal(r,I,s),o++}catch(C){throw new Error(C)}}}),o<this.instance.exports.getInputSize())throw new Error(`Not all inputs have been set. Only ${o} out of ${this.instance.exports.getInputSize()}`)}async calculateWitness(t,e){const i=[];await this._doCalculateWitness(t,e);for(let o=0;o<this.witnessSize;o++){this.instance.exports.getWitness(o);const a=new Uint32Array(this.n32);for(let u=0;u<this.n32;u++)a[this.n32-1-u]=this.instance.exports.readSharedRWMemory(u);i.push(oe.fromArray(a,4294967296))}return i}async calculateWTNSBin(t,e){const i=new Uint32Array(this.witnessSize*this.n32+this.n32+11),o=new Uint8Array(i.buffer);await this._doCalculateWitness(t,e),o[0]=119,o[1]=116,o[2]=110,o[3]=115,i[1]=2,i[2]=2,i[3]=1;const a=this.n32*4,r=(8+a).toString(16);i[4]=parseInt(r.slice(0,8),16),i[5]=parseInt(r.slice(8,16),16),i[6]=a,this.instance.exports.getRawPrime();let I=7;for(let m=0;m<this.n32;m++)i[I+m]=this.instance.exports.readSharedRWMemory(m);I+=this.n32,i[I]=this.witnessSize,I++,i[I]=2,I++;const s=(a*this.witnessSize).toString(16);i[I]=parseInt(s.slice(0,8),16),i[I+1]=parseInt(s.slice(8,16),16),I+=2;for(let m=0;m<this.witnessSize;m++){this.instance.exports.getWitness(m);for(let C=0;C<this.n32;C++)i[I+C]=this.instance.exports.readSharedRWMemory(C);I+=this.n32}return o}}async function Mu(n,t,e,i){const o=await ts(t),a=await o.read(o.totalSize);await o.close();const u=await Ou(a);if(u.circom_version()==1){const r=await u.calculateBinWitness(n),I=await F2(e,"wtns",2,2);await Eu(I,r,u.prime),await I.close()}else{const r=await Jr(e),I=await u.calculateWTNSBin(n);await r.write(I),await r.close()}}async function ku(n,t,e,i){const o={type:"mem"};return await Mu(n,t,o),await ls(e,o,i)}const{unstringifyBigInts:Io}=Hr;async function Tu(n,t,e,i){n=Io(n),e=Io(e),t=Io(t);const o=await U2(n.curve),a=o.G1.fromObject(n.IC[0]),u=new Uint8Array(o.G1.F.n8*2*t.length),r=new Uint8Array(o.Fr.n8*t.length);for(let R=0;R<t.length;R++){const x=o.G1.fromObject(n.IC[R+1]);u.set(x,R*o.G1.F.n8*2),oe.toRprLE(r,o.Fr.n8*R,t[R],o.Fr.n8)}let I=await o.G1.multiExpAffine(u,r);I=o.G1.add(I,a);const l=o.G1.fromObject(e.pi_a),s=o.G2.fromObject(e.pi_b),m=o.G1.fromObject(e.pi_c),C=o.G2.fromObject(n.vk_gamma_2),g=o.G2.fromObject(n.vk_delta_2),M=o.G1.fromObject(n.vk_alpha_1),$=o.G2.fromObject(n.vk_beta_2);return await o.pairingEq(o.G1.neg(l),s,I,C,m,g,M,$)?(i&&i.info("OK!"),!0):(i&&i.error("Invalid proof"),!1)}function qe(n){let t=n.toString(16);for(;t.length<64;)t="0"+t;return t=`"0x${t}"`,t}async function zu(n,t){let e="";for(let o=0;o<t.length;o++)e!=""&&(e=e+","),e=e+qe(t[o]);let i;return i=`[${qe(n.pi_a[0])}, ${qe(n.pi_a[1])}],[[${qe(n.pi_b[0][1])}, ${qe(n.pi_b[0][0])}],[${qe(n.pi_b[1][1])}, ${qe(n.pi_b[1][0])}]],[${qe(n.pi_c[0])}, ${qe(n.pi_c[1])}],[${e}]`,i}var Ru=Object.freeze({__proto__:null,fullProve:ku,prove:ls,verify:Tu,exportSolidityCallData:zu});oe.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);oe.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");var Qu={exports:{}};/**
|
|
136
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
137
|
-
*
|
|
138
|
-
* @version 0.8.0
|
|
139
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
140
|
-
* @copyright Chen, Yi-Cyuan 2015-2018
|
|
141
|
-
* @license MIT
|
|
142
|
-
*/(function(n){(function(){var t="input is invalid type",e="finalize already called",i=typeof window=="object",o=i?window:{};o.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&typeof self=="object",u=!o.JS_SHA3_NO_NODE_JS&&typeof ro=="object"&&ro.versions&&ro.versions.node;u?o=P2:a&&(o=self);var r=!o.JS_SHA3_NO_COMMON_JS&&!0&&n.exports,I=!o.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),s=[31,7936,2031616,520093696],m=[4,1024,262144,67108864],C=[1,256,65536,16777216],g=[6,1536,393216,100663296],M=[0,8,16,24],$=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],F=[224,256,384,512],R=[128,256],x=["hex","buffer","arrayBuffer","array","digest"],it={128:168,256:136};(o.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(A){return Object.prototype.toString.call(A)==="[object Array]"}),I&&(o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(A){return typeof A=="object"&&A.buffer&&A.buffer.constructor===ArrayBuffer});for(var z=function(A,c,E){return function(d){return new Ft(A,c,A).update(d)[E]()}},K=function(A,c,E){return function(d,G){return new Ft(A,c,G).update(d)[E]()}},v=function(A,c,E){return function(d,G,U,b){return T["cshake"+A].update(d,G,U,b)[E]()}},f=function(A,c,E){return function(d,G,U,b){return T["kmac"+A].update(d,G,U,b)[E]()}},L=function(A,c,E,d){for(var G=0;G<x.length;++G){var U=x[G];A[U]=c(E,d,U)}return A},V=function(A,c){var E=z(A,c,"hex");return E.create=function(){return new Ft(A,c,A)},E.update=function(d){return E.create().update(d)},L(E,z,A,c)},X=function(A,c){var E=K(A,c,"hex");return E.create=function(d){return new Ft(A,c,d)},E.update=function(d,G){return E.create(G).update(d)},L(E,K,A,c)},et=function(A,c){var E=it[A],d=v(A,c,"hex");return d.create=function(G,U,b){return!U&&!b?T["shake"+A].create(G):new Ft(A,c,G).bytepad([U,b],E)},d.update=function(G,U,b,J){return d.create(U,b,J).update(G)},L(d,v,A,c)},N=function(A,c){var E=it[A],d=f(A,c,"hex");return d.create=function(G,U,b){return new Nt(A,c,U).bytepad(["KMAC",b],E).bytepad([G],E)},d.update=function(G,U,b,J){return d.create(G,b,J).update(U)},L(d,f,A,c)},w=[{name:"keccak",padding:C,bits:F,createMethod:V},{name:"sha3",padding:g,bits:F,createMethod:V},{name:"shake",padding:s,bits:R,createMethod:X},{name:"cshake",padding:m,bits:R,createMethod:et},{name:"kmac",padding:m,bits:R,createMethod:N}],T={},at=[],Lt=0;Lt<w.length;++Lt)for(var _t=w[Lt],ct=_t.bits,yt=0;yt<ct.length;++yt){var ft=_t.name+"_"+ct[yt];if(at.push(ft),T[ft]=_t.createMethod(ct[yt],_t.padding),_t.name!=="sha3"){var ht=_t.name+ct[yt];at.push(ht),T[ht]=T[ft]}}function Ft(A,c,E){this.blocks=[],this.s=[],this.padding=c,this.outputBits=E,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(A<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=E>>5,this.extraBytes=(E&31)>>3;for(var d=0;d<50;++d)this.s[d]=0}Ft.prototype.update=function(A){if(this.finalized)throw new Error(e);var c,E=typeof A;if(E!=="string"){if(E==="object"){if(A===null)throw new Error(t);if(I&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!I||!ArrayBuffer.isView(A)))throw new Error(t)}else throw new Error(t);c=!0}for(var d=this.blocks,G=this.byteCount,U=A.length,b=this.blockCount,J=0,It=this.s,lt,At;J<U;){if(this.reset)for(this.reset=!1,d[0]=this.block,lt=1;lt<b+1;++lt)d[lt]=0;if(c)for(lt=this.start;J<U&<<G;++J)d[lt>>2]|=A[J]<<M[lt++&3];else for(lt=this.start;J<U&<<G;++J)At=A.charCodeAt(J),At<128?d[lt>>2]|=At<<M[lt++&3]:At<2048?(d[lt>>2]|=(192|At>>6)<<M[lt++&3],d[lt>>2]|=(128|At&63)<<M[lt++&3]):At<55296||At>=57344?(d[lt>>2]|=(224|At>>12)<<M[lt++&3],d[lt>>2]|=(128|At>>6&63)<<M[lt++&3],d[lt>>2]|=(128|At&63)<<M[lt++&3]):(At=65536+((At&1023)<<10|A.charCodeAt(++J)&1023),d[lt>>2]|=(240|At>>18)<<M[lt++&3],d[lt>>2]|=(128|At>>12&63)<<M[lt++&3],d[lt>>2]|=(128|At>>6&63)<<M[lt++&3],d[lt>>2]|=(128|At&63)<<M[lt++&3]);if(this.lastByteIndex=lt,lt>=G){for(this.start=lt-G,this.block=d[b],lt=0;lt<b;++lt)It[lt]^=d[lt];kt(It),this.reset=!0}else this.start=lt}return this},Ft.prototype.encode=function(A,c){var E=A&255,d=1,G=[E];for(A=A>>8,E=A&255;E>0;)G.unshift(E),A=A>>8,E=A&255,++d;return c?G.push(d):G.unshift(d),this.update(G),G.length},Ft.prototype.encodeString=function(A){var c,E=typeof A;if(E!=="string"){if(E==="object"){if(A===null)throw new Error(t);if(I&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!Array.isArray(A)&&(!I||!ArrayBuffer.isView(A)))throw new Error(t)}else throw new Error(t);c=!0}var d=0,G=A.length;if(c)d=G;else for(var U=0;U<A.length;++U){var b=A.charCodeAt(U);b<128?d+=1:b<2048?d+=2:b<55296||b>=57344?d+=3:(b=65536+((b&1023)<<10|A.charCodeAt(++U)&1023),d+=4)}return d+=this.encode(d*8),this.update(A),d},Ft.prototype.bytepad=function(A,c){for(var E=this.encode(c),d=0;d<A.length;++d)E+=this.encodeString(A[d]);var G=c-E%c,U=[];return U.length=G,this.update(U),this},Ft.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,c=this.lastByteIndex,E=this.blockCount,d=this.s;if(A[c>>2]|=this.padding[c&3],this.lastByteIndex===this.byteCount)for(A[0]=A[E],c=1;c<E+1;++c)A[c]=0;for(A[E-1]|=2147483648,c=0;c<E;++c)d[c]^=A[c];kt(d)}},Ft.prototype.toString=Ft.prototype.hex=function(){this.finalize();for(var A=this.blockCount,c=this.s,E=this.outputBlocks,d=this.extraBytes,G=0,U=0,b="",J;U<E;){for(G=0;G<A&&U<E;++G,++U)J=c[G],b+=l[J>>4&15]+l[J&15]+l[J>>12&15]+l[J>>8&15]+l[J>>20&15]+l[J>>16&15]+l[J>>28&15]+l[J>>24&15];U%A===0&&(kt(c),G=0)}return d&&(J=c[G],b+=l[J>>4&15]+l[J&15],d>1&&(b+=l[J>>12&15]+l[J>>8&15]),d>2&&(b+=l[J>>20&15]+l[J>>16&15])),b},Ft.prototype.arrayBuffer=function(){this.finalize();var A=this.blockCount,c=this.s,E=this.outputBlocks,d=this.extraBytes,G=0,U=0,b=this.outputBits>>3,J;d?J=new ArrayBuffer(E+1<<2):J=new ArrayBuffer(b);for(var It=new Uint32Array(J);U<E;){for(G=0;G<A&&U<E;++G,++U)It[U]=c[G];U%A===0&&kt(c)}return d&&(It[G]=c[G],J=J.slice(0,b)),J},Ft.prototype.buffer=Ft.prototype.arrayBuffer,Ft.prototype.digest=Ft.prototype.array=function(){this.finalize();for(var A=this.blockCount,c=this.s,E=this.outputBlocks,d=this.extraBytes,G=0,U=0,b=[],J,It;U<E;){for(G=0;G<A&&U<E;++G,++U)J=U<<2,It=c[G],b[J]=It&255,b[J+1]=It>>8&255,b[J+2]=It>>16&255,b[J+3]=It>>24&255;U%A===0&&kt(c)}return d&&(J=U<<2,It=c[G],b[J]=It&255,d>1&&(b[J+1]=It>>8&255),d>2&&(b[J+2]=It>>16&255)),b};function Nt(A,c,E){Ft.call(this,A,c,E)}Nt.prototype=new Ft,Nt.prototype.finalize=function(){return this.encode(this.outputBits,!0),Ft.prototype.finalize.call(this)};var kt=function(A){var c,E,d,G,U,b,J,It,lt,At,zt,xt,Mt,Gt,vt,Et,Ot,$t,Jt,ie,ae,B,p,y,O,H,nt,k,_,h,D,Z,Q,ot,W,st,ut,dt,rt,pt,Ut,St,wt,Rt,Dt,Yt,Qt,qt,Pt,jt,ue,ge,je,Se,Oe,We,Ue,Pe,Xe,Fe,Ce,Qe,Bn;for(d=0;d<48;d+=2)G=A[0]^A[10]^A[20]^A[30]^A[40],U=A[1]^A[11]^A[21]^A[31]^A[41],b=A[2]^A[12]^A[22]^A[32]^A[42],J=A[3]^A[13]^A[23]^A[33]^A[43],It=A[4]^A[14]^A[24]^A[34]^A[44],lt=A[5]^A[15]^A[25]^A[35]^A[45],At=A[6]^A[16]^A[26]^A[36]^A[46],zt=A[7]^A[17]^A[27]^A[37]^A[47],xt=A[8]^A[18]^A[28]^A[38]^A[48],Mt=A[9]^A[19]^A[29]^A[39]^A[49],c=xt^(b<<1|J>>>31),E=Mt^(J<<1|b>>>31),A[0]^=c,A[1]^=E,A[10]^=c,A[11]^=E,A[20]^=c,A[21]^=E,A[30]^=c,A[31]^=E,A[40]^=c,A[41]^=E,c=G^(It<<1|lt>>>31),E=U^(lt<<1|It>>>31),A[2]^=c,A[3]^=E,A[12]^=c,A[13]^=E,A[22]^=c,A[23]^=E,A[32]^=c,A[33]^=E,A[42]^=c,A[43]^=E,c=b^(At<<1|zt>>>31),E=J^(zt<<1|At>>>31),A[4]^=c,A[5]^=E,A[14]^=c,A[15]^=E,A[24]^=c,A[25]^=E,A[34]^=c,A[35]^=E,A[44]^=c,A[45]^=E,c=It^(xt<<1|Mt>>>31),E=lt^(Mt<<1|xt>>>31),A[6]^=c,A[7]^=E,A[16]^=c,A[17]^=E,A[26]^=c,A[27]^=E,A[36]^=c,A[37]^=E,A[46]^=c,A[47]^=E,c=At^(G<<1|U>>>31),E=zt^(U<<1|G>>>31),A[8]^=c,A[9]^=E,A[18]^=c,A[19]^=E,A[28]^=c,A[29]^=E,A[38]^=c,A[39]^=E,A[48]^=c,A[49]^=E,Gt=A[0],vt=A[1],Yt=A[11]<<4|A[10]>>>28,Qt=A[10]<<4|A[11]>>>28,k=A[20]<<3|A[21]>>>29,_=A[21]<<3|A[20]>>>29,Fe=A[31]<<9|A[30]>>>23,Ce=A[30]<<9|A[31]>>>23,St=A[40]<<18|A[41]>>>14,wt=A[41]<<18|A[40]>>>14,ot=A[2]<<1|A[3]>>>31,W=A[3]<<1|A[2]>>>31,Et=A[13]<<12|A[12]>>>20,Ot=A[12]<<12|A[13]>>>20,qt=A[22]<<10|A[23]>>>22,Pt=A[23]<<10|A[22]>>>22,h=A[33]<<13|A[32]>>>19,D=A[32]<<13|A[33]>>>19,Qe=A[42]<<2|A[43]>>>30,Bn=A[43]<<2|A[42]>>>30,Se=A[5]<<30|A[4]>>>2,Oe=A[4]<<30|A[5]>>>2,st=A[14]<<6|A[15]>>>26,ut=A[15]<<6|A[14]>>>26,$t=A[25]<<11|A[24]>>>21,Jt=A[24]<<11|A[25]>>>21,jt=A[34]<<15|A[35]>>>17,ue=A[35]<<15|A[34]>>>17,Z=A[45]<<29|A[44]>>>3,Q=A[44]<<29|A[45]>>>3,y=A[6]<<28|A[7]>>>4,O=A[7]<<28|A[6]>>>4,We=A[17]<<23|A[16]>>>9,Ue=A[16]<<23|A[17]>>>9,dt=A[26]<<25|A[27]>>>7,rt=A[27]<<25|A[26]>>>7,ie=A[36]<<21|A[37]>>>11,ae=A[37]<<21|A[36]>>>11,ge=A[47]<<24|A[46]>>>8,je=A[46]<<24|A[47]>>>8,Rt=A[8]<<27|A[9]>>>5,Dt=A[9]<<27|A[8]>>>5,H=A[18]<<20|A[19]>>>12,nt=A[19]<<20|A[18]>>>12,Pe=A[29]<<7|A[28]>>>25,Xe=A[28]<<7|A[29]>>>25,pt=A[38]<<8|A[39]>>>24,Ut=A[39]<<8|A[38]>>>24,B=A[48]<<14|A[49]>>>18,p=A[49]<<14|A[48]>>>18,A[0]=Gt^~Et&$t,A[1]=vt^~Ot&Jt,A[10]=y^~H&k,A[11]=O^~nt&_,A[20]=ot^~st&dt,A[21]=W^~ut&rt,A[30]=Rt^~Yt&qt,A[31]=Dt^~Qt&Pt,A[40]=Se^~We&Pe,A[41]=Oe^~Ue&Xe,A[2]=Et^~$t&ie,A[3]=Ot^~Jt&ae,A[12]=H^~k&h,A[13]=nt^~_&D,A[22]=st^~dt&pt,A[23]=ut^~rt&Ut,A[32]=Yt^~qt&jt,A[33]=Qt^~Pt&ue,A[42]=We^~Pe&Fe,A[43]=Ue^~Xe&Ce,A[4]=$t^~ie&B,A[5]=Jt^~ae&p,A[14]=k^~h&Z,A[15]=_^~D&Q,A[24]=dt^~pt&St,A[25]=rt^~Ut&wt,A[34]=qt^~jt&ge,A[35]=Pt^~ue&je,A[44]=Pe^~Fe&Qe,A[45]=Xe^~Ce&Bn,A[6]=ie^~B&Gt,A[7]=ae^~p&vt,A[16]=h^~Z&y,A[17]=D^~Q&O,A[26]=pt^~St&ot,A[27]=Ut^~wt&W,A[36]=jt^~ge&Rt,A[37]=ue^~je&Dt,A[46]=Fe^~Qe&Se,A[47]=Ce^~Bn&Oe,A[8]=B^~Gt&Et,A[9]=p^~vt&Ot,A[18]=Z^~y&H,A[19]=Q^~O&nt,A[28]=St^~ot&st,A[29]=wt^~W&ut,A[38]=ge^~Rt&Yt,A[39]=je^~Dt&Qt,A[48]=Qe^~Se&We,A[49]=Bn^~Oe&Ue,A[0]^=$[d],A[1]^=$[d+1]};if(r)n.exports=T;else for(Lt=0;Lt<at.length;++Lt)o[at[Lt]]=T[at[Lt]]})()})(Qu);/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */const Du=4,Ac=0,bc=1,qu=2;function Nn(n){let t=n.length;for(;--t>=0;)n[t]=0}const Nu=0,fs=1,Gu=2,$u=3,Ku=258,pa=29,Ii=256,di=Ii+1+pa,kn=30,La=19,_s=2*di+1,Ln=15,wo=16,Hu=7,Aa=256,hs=16,gs=17,ps=18,Yo=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Qi=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Zu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ls=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yu=512,Ge=new Array((di+2)*2);Nn(Ge);const ii=new Array(kn*2);Nn(ii);const ui=new Array(Yu);Nn(ui);const fi=new Array(Ku-$u+1);Nn(fi);const ba=new Array(pa);Nn(ba);const Gi=new Array(kn);Nn(Gi);function mo(n,t,e,i,o){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=i,this.max_length=o,this.has_stree=n&&n.length}let As,bs,ys;function Co(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const Is=n=>n<256?ui[n]:ui[256+(n>>>7)],_i=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},ye=(n,t,e)=>{n.bi_valid>wo-e?(n.bi_buf|=t<<n.bi_valid&65535,_i(n,n.bi_buf),n.bi_buf=t>>wo-n.bi_valid,n.bi_valid+=e-wo):(n.bi_buf|=t<<n.bi_valid&65535,n.bi_valid+=e)},Te=(n,t,e)=>{ye(n,e[t*2],e[t*2+1])},ws=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},Vu=n=>{n.bi_valid===16?(_i(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},ju=(n,t)=>{const e=t.dyn_tree,i=t.max_code,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,u=t.stat_desc.extra_bits,r=t.stat_desc.extra_base,I=t.stat_desc.max_length;let l,s,m,C,g,M,$=0;for(C=0;C<=Ln;C++)n.bl_count[C]=0;for(e[n.heap[n.heap_max]*2+1]=0,l=n.heap_max+1;l<_s;l++)s=n.heap[l],C=e[e[s*2+1]*2+1]+1,C>I&&(C=I,$++),e[s*2+1]=C,!(s>i)&&(n.bl_count[C]++,g=0,s>=r&&(g=u[s-r]),M=e[s*2],n.opt_len+=M*(C+g),a&&(n.static_len+=M*(o[s*2+1]+g)));if($!==0){do{for(C=I-1;n.bl_count[C]===0;)C--;n.bl_count[C]--,n.bl_count[C+1]+=2,n.bl_count[I]--,$-=2}while($>0);for(C=I;C!==0;C--)for(s=n.bl_count[C];s!==0;)m=n.heap[--l],!(m>i)&&(e[m*2+1]!==C&&(n.opt_len+=(C-e[m*2+1])*e[m*2],e[m*2+1]=C),s--)}},ms=(n,t,e)=>{const i=new Array(Ln+1);let o=0,a,u;for(a=1;a<=Ln;a++)o=o+e[a-1]<<1,i[a]=o;for(u=0;u<=t;u++){let r=n[u*2+1];r!==0&&(n[u*2]=ws(i[r]++,r))}},Wu=()=>{let n,t,e,i,o;const a=new Array(Ln+1);for(e=0,i=0;i<pa-1;i++)for(ba[i]=e,n=0;n<1<<Yo[i];n++)fi[e++]=i;for(fi[e-1]=i,o=0,i=0;i<16;i++)for(Gi[i]=o,n=0;n<1<<Qi[i];n++)ui[o++]=i;for(o>>=7;i<kn;i++)for(Gi[i]=o<<7,n=0;n<1<<Qi[i]-7;n++)ui[256+o++]=i;for(t=0;t<=Ln;t++)a[t]=0;for(n=0;n<=143;)Ge[n*2+1]=8,n++,a[8]++;for(;n<=255;)Ge[n*2+1]=9,n++,a[9]++;for(;n<=279;)Ge[n*2+1]=7,n++,a[7]++;for(;n<=287;)Ge[n*2+1]=8,n++,a[8]++;for(ms(Ge,di+1,a),n=0;n<kn;n++)ii[n*2+1]=5,ii[n*2]=ws(n,5);As=new mo(Ge,Yo,Ii+1,di,Ln),bs=new mo(ii,Qi,0,kn,Ln),ys=new mo(new Array(0),Zu,0,La,Hu)},Cs=n=>{let t;for(t=0;t<di;t++)n.dyn_ltree[t*2]=0;for(t=0;t<kn;t++)n.dyn_dtree[t*2]=0;for(t=0;t<La;t++)n.bl_tree[t*2]=0;n.dyn_ltree[Aa*2]=1,n.opt_len=n.static_len=0,n.sym_next=n.matches=0},Es=n=>{n.bi_valid>8?_i(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},yc=(n,t,e,i)=>{const o=t*2,a=e*2;return n[o]<n[a]||n[o]===n[a]&&i[t]<=i[e]},Eo=(n,t,e)=>{const i=n.heap[e];let o=e<<1;for(;o<=n.heap_len&&(o<n.heap_len&&yc(t,n.heap[o+1],n.heap[o],n.depth)&&o++,!yc(t,i,n.heap[o],n.depth));)n.heap[e]=n.heap[o],e=o,o<<=1;n.heap[e]=i},Ic=(n,t,e)=>{let i,o,a=0,u,r;if(n.sym_next!==0)do i=n.pending_buf[n.sym_buf+a++]&255,i+=(n.pending_buf[n.sym_buf+a++]&255)<<8,o=n.pending_buf[n.sym_buf+a++],i===0?Te(n,o,t):(u=fi[o],Te(n,u+Ii+1,t),r=Yo[u],r!==0&&(o-=ba[u],ye(n,o,r)),i--,u=Is(i),Te(n,u,e),r=Qi[u],r!==0&&(i-=Gi[u],ye(n,i,r)));while(a<n.sym_next);Te(n,Aa,t)},Vo=(n,t)=>{const e=t.dyn_tree,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,a=t.stat_desc.elems;let u,r,I=-1,l;for(n.heap_len=0,n.heap_max=_s,u=0;u<a;u++)e[u*2]!==0?(n.heap[++n.heap_len]=I=u,n.depth[u]=0):e[u*2+1]=0;for(;n.heap_len<2;)l=n.heap[++n.heap_len]=I<2?++I:0,e[l*2]=1,n.depth[l]=0,n.opt_len--,o&&(n.static_len-=i[l*2+1]);for(t.max_code=I,u=n.heap_len>>1;u>=1;u--)Eo(n,e,u);l=a;do u=n.heap[1],n.heap[1]=n.heap[n.heap_len--],Eo(n,e,1),r=n.heap[1],n.heap[--n.heap_max]=u,n.heap[--n.heap_max]=r,e[l*2]=e[u*2]+e[r*2],n.depth[l]=(n.depth[u]>=n.depth[r]?n.depth[u]:n.depth[r])+1,e[u*2+1]=e[r*2+1]=l,n.heap[1]=l++,Eo(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],ju(n,t),ms(e,I,n.bl_count)},wc=(n,t,e)=>{let i,o=-1,a,u=t[0*2+1],r=0,I=7,l=4;for(u===0&&(I=138,l=3),t[(e+1)*2+1]=65535,i=0;i<=e;i++)a=u,u=t[(i+1)*2+1],!(++r<I&&a===u)&&(r<l?n.bl_tree[a*2]+=r:a!==0?(a!==o&&n.bl_tree[a*2]++,n.bl_tree[hs*2]++):r<=10?n.bl_tree[gs*2]++:n.bl_tree[ps*2]++,r=0,o=a,u===0?(I=138,l=3):a===u?(I=6,l=3):(I=7,l=4))},mc=(n,t,e)=>{let i,o=-1,a,u=t[0*2+1],r=0,I=7,l=4;for(u===0&&(I=138,l=3),i=0;i<=e;i++)if(a=u,u=t[(i+1)*2+1],!(++r<I&&a===u)){if(r<l)do Te(n,a,n.bl_tree);while(--r!==0);else a!==0?(a!==o&&(Te(n,a,n.bl_tree),r--),Te(n,hs,n.bl_tree),ye(n,r-3,2)):r<=10?(Te(n,gs,n.bl_tree),ye(n,r-3,3)):(Te(n,ps,n.bl_tree),ye(n,r-11,7));r=0,o=a,u===0?(I=138,l=3):a===u?(I=6,l=3):(I=7,l=4)}},Xu=n=>{let t;for(wc(n,n.dyn_ltree,n.l_desc.max_code),wc(n,n.dyn_dtree,n.d_desc.max_code),Vo(n,n.bl_desc),t=La-1;t>=3&&n.bl_tree[Ls[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},Ju=(n,t,e,i)=>{let o;for(ye(n,t-257,5),ye(n,e-1,5),ye(n,i-4,4),o=0;o<i;o++)ye(n,n.bl_tree[Ls[o]*2+1],3);mc(n,n.dyn_ltree,t-1),mc(n,n.dyn_dtree,e-1)},tf=n=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return Ac;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return bc;for(e=32;e<Ii;e++)if(n.dyn_ltree[e*2]!==0)return bc;return Ac};let Cc=!1;const ef=n=>{Cc||(Wu(),Cc=!0),n.l_desc=new Co(n.dyn_ltree,As),n.d_desc=new Co(n.dyn_dtree,bs),n.bl_desc=new Co(n.bl_tree,ys),n.bi_buf=0,n.bi_valid=0,Cs(n)},Bs=(n,t,e,i)=>{ye(n,(Nu<<1)+(i?1:0),3),Es(n),_i(n,e),_i(n,~e),e&&n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},nf=n=>{ye(n,fs<<1,3),Te(n,Aa,Ge),Vu(n)},of=(n,t,e,i)=>{let o,a,u=0;n.level>0?(n.strm.data_type===qu&&(n.strm.data_type=tf(n)),Vo(n,n.l_desc),Vo(n,n.d_desc),u=Xu(n),o=n.opt_len+3+7>>>3,a=n.static_len+3+7>>>3,a<=o&&(o=a)):o=a=e+5,e+4<=o&&t!==-1?Bs(n,t,e,i):n.strategy===Du||a===o?(ye(n,(fs<<1)+(i?1:0),3),Ic(n,Ge,ii)):(ye(n,(Gu<<1)+(i?1:0),3),Ju(n,n.l_desc.max_code+1,n.d_desc.max_code+1,u+1),Ic(n,n.dyn_ltree,n.dyn_dtree)),Cs(n),i&&Es(n)},af=(n,t,e)=>(n.pending_buf[n.sym_buf+n.sym_next++]=t,n.pending_buf[n.sym_buf+n.sym_next++]=t>>8,n.pending_buf[n.sym_buf+n.sym_next++]=e,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(fi[e]+Ii+1)*2]++,n.dyn_dtree[Is(t)*2]++),n.sym_next===n.sym_end);var cf=ef,rf=Bs,sf=of,lf=af,df=nf,uf={_tr_init:cf,_tr_stored_block:rf,_tr_flush_block:sf,_tr_tally:lf,_tr_align:df};const ff=(n,t,e,i)=>{let o=n&65535|0,a=n>>>16&65535|0,u=0;for(;e!==0;){u=e>2e3?2e3:e,e-=u;do o=o+t[i++]|0,a=a+o|0;while(--u);o%=65521,a%=65521}return o|a<<16|0};var hi=ff;const _f=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},hf=new Uint32Array(_f()),gf=(n,t,e,i)=>{const o=hf,a=i+e;n^=-1;for(let u=i;u<a;u++)n=n>>>8^o[(n^t[u])&255];return n^-1};var fe=gf,yn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Cn={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:pf,_tr_stored_block:jo,_tr_flush_block:Lf,_tr_tally:cn,_tr_align:Af}=uf,{Z_NO_FLUSH:rn,Z_PARTIAL_FLUSH:bf,Z_FULL_FLUSH:yf,Z_FINISH:Be,Z_BLOCK:Ec,Z_OK:he,Z_STREAM_END:Bc,Z_STREAM_ERROR:ze,Z_DATA_ERROR:If,Z_BUF_ERROR:Bo,Z_DEFAULT_COMPRESSION:wf,Z_FILTERED:mf,Z_HUFFMAN_ONLY:Oi,Z_RLE:Cf,Z_FIXED:Ef,Z_DEFAULT_STRATEGY:Bf,Z_UNKNOWN:xf,Z_DEFLATED:Xi}=Cn,Ff=9,vf=15,Sf=8,Of=29,Uf=256,Wo=Uf+1+Of,Pf=30,Mf=19,kf=2*Wo+1,Tf=15,Wt=3,an=258,Re=an+Wt+1,zf=32,Qn=42,ya=57,Xo=69,Jo=73,ta=91,ea=103,An=113,ei=666,pe=1,Gn=2,In=3,$n=4,Rf=3,bn=(n,t)=>(n.msg=yn[t],t),xc=n=>n*2-(n>4?9:0),on=n=>{let t=n.length;for(;--t>=0;)n[t]=0},Qf=n=>{let t,e,i,o=n.w_size;t=n.hash_size,i=t;do e=n.head[--i],n.head[i]=e>=o?e-o:0;while(--t);t=o,i=t;do e=n.prev[--i],n.prev[i]=e>=o?e-o:0;while(--t)};let Df=(n,t,e)=>(t<<n.hash_shift^e)&n.hash_mask,sn=Df;const Ie=n=>{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},me=(n,t)=>{Lf(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,Ie(n.strm)},Xt=(n,t)=>{n.pending_buf[n.pending++]=t},Jn=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},na=(n,t,e,i)=>{let o=n.avail_in;return o>i&&(o=i),o===0?0:(n.avail_in-=o,t.set(n.input.subarray(n.next_in,n.next_in+o),e),n.state.wrap===1?n.adler=hi(n.adler,t,o,e):n.state.wrap===2&&(n.adler=fe(n.adler,t,o,e)),n.next_in+=o,n.total_in+=o,o)},xs=(n,t)=>{let e=n.max_chain_length,i=n.strstart,o,a,u=n.prev_length,r=n.nice_match;const I=n.strstart>n.w_size-Re?n.strstart-(n.w_size-Re):0,l=n.window,s=n.w_mask,m=n.prev,C=n.strstart+an;let g=l[i+u-1],M=l[i+u];n.prev_length>=n.good_match&&(e>>=2),r>n.lookahead&&(r=n.lookahead);do if(o=t,!(l[o+u]!==M||l[o+u-1]!==g||l[o]!==l[i]||l[++o]!==l[i+1])){i+=2,o++;do;while(l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&l[++i]===l[++o]&&i<C);if(a=an-(C-i),i=C-an,a>u){if(n.match_start=t,u=a,a>=r)break;g=l[i+u-1],M=l[i+u]}}while((t=m[t&s])>I&&--e!==0);return u<=n.lookahead?u:n.lookahead},Dn=n=>{const t=n.w_size;let e,i,o;do{if(i=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-Re)&&(n.window.set(n.window.subarray(t,t+t-i),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,n.insert>n.strstart&&(n.insert=n.strstart),Qf(n),i+=t),n.strm.avail_in===0)break;if(e=na(n.strm,n.window,n.strstart+n.lookahead,i),n.lookahead+=e,n.lookahead+n.insert>=Wt)for(o=n.strstart-n.insert,n.ins_h=n.window[o],n.ins_h=sn(n,n.ins_h,n.window[o+1]);n.insert&&(n.ins_h=sn(n,n.ins_h,n.window[o+Wt-1]),n.prev[o&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=o,o++,n.insert--,!(n.lookahead+n.insert<Wt)););}while(n.lookahead<Re&&n.strm.avail_in!==0)},Fs=(n,t)=>{let e=n.pending_buf_size-5>n.w_size?n.w_size:n.pending_buf_size-5,i,o,a,u=0,r=n.strm.avail_in;do{if(i=65535,a=n.bi_valid+42>>3,n.strm.avail_out<a||(a=n.strm.avail_out-a,o=n.strstart-n.block_start,i>o+n.strm.avail_in&&(i=o+n.strm.avail_in),i>a&&(i=a),i<e&&(i===0&&t!==Be||t===rn||i!==o+n.strm.avail_in)))break;u=t===Be&&i===o+n.strm.avail_in?1:0,jo(n,0,0,u),n.pending_buf[n.pending-4]=i,n.pending_buf[n.pending-3]=i>>8,n.pending_buf[n.pending-2]=~i,n.pending_buf[n.pending-1]=~i>>8,Ie(n.strm),o&&(o>i&&(o=i),n.strm.output.set(n.window.subarray(n.block_start,n.block_start+o),n.strm.next_out),n.strm.next_out+=o,n.strm.avail_out-=o,n.strm.total_out+=o,n.block_start+=o,i-=o),i&&(na(n.strm,n.strm.output,n.strm.next_out,i),n.strm.next_out+=i,n.strm.avail_out-=i,n.strm.total_out+=i)}while(u===0);return r-=n.strm.avail_in,r&&(r>=n.w_size?(n.matches=2,n.window.set(n.strm.input.subarray(n.strm.next_in-n.w_size,n.strm.next_in),0),n.strstart=n.w_size,n.insert=n.strstart):(n.window_size-n.strstart<=r&&(n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,n.insert>n.strstart&&(n.insert=n.strstart)),n.window.set(n.strm.input.subarray(n.strm.next_in-r,n.strm.next_in),n.strstart),n.strstart+=r,n.insert+=r>n.w_size-n.insert?n.w_size-n.insert:r),n.block_start=n.strstart),n.high_water<n.strstart&&(n.high_water=n.strstart),u?$n:t!==rn&&t!==Be&&n.strm.avail_in===0&&n.strstart===n.block_start?Gn:(a=n.window_size-n.strstart,n.strm.avail_in>a&&n.block_start>=n.w_size&&(n.block_start-=n.w_size,n.strstart-=n.w_size,n.window.set(n.window.subarray(n.w_size,n.w_size+n.strstart),0),n.matches<2&&n.matches++,a+=n.w_size,n.insert>n.strstart&&(n.insert=n.strstart)),a>n.strm.avail_in&&(a=n.strm.avail_in),a&&(na(n.strm,n.window,n.strstart,a),n.strstart+=a,n.insert+=a>n.w_size-n.insert?n.w_size-n.insert:a),n.high_water<n.strstart&&(n.high_water=n.strstart),a=n.bi_valid+42>>3,a=n.pending_buf_size-a>65535?65535:n.pending_buf_size-a,e=a>n.w_size?n.w_size:a,o=n.strstart-n.block_start,(o>=e||(o||t===Be)&&t!==rn&&n.strm.avail_in===0&&o<=a)&&(i=o>a?a:o,u=t===Be&&n.strm.avail_in===0&&i===o?1:0,jo(n,n.block_start,i,u),n.block_start+=i,Ie(n.strm)),u?In:pe)},xo=(n,t)=>{let e,i;for(;;){if(n.lookahead<Re){if(Dn(n),n.lookahead<Re&&t===rn)return pe;if(n.lookahead===0)break}if(e=0,n.lookahead>=Wt&&(n.ins_h=sn(n,n.ins_h,n.window[n.strstart+Wt-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-Re&&(n.match_length=xs(n,e)),n.match_length>=Wt)if(i=cn(n,n.strstart-n.match_start,n.match_length-Wt),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=Wt){n.match_length--;do n.strstart++,n.ins_h=sn(n,n.ins_h,n.window[n.strstart+Wt-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=sn(n,n.ins_h,n.window[n.strstart+1]);else i=cn(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(i&&(me(n,!1),n.strm.avail_out===0))return pe}return n.insert=n.strstart<Wt-1?n.strstart:Wt-1,t===Be?(me(n,!0),n.strm.avail_out===0?In:$n):n.sym_next&&(me(n,!1),n.strm.avail_out===0)?pe:Gn},Fn=(n,t)=>{let e,i,o;for(;;){if(n.lookahead<Re){if(Dn(n),n.lookahead<Re&&t===rn)return pe;if(n.lookahead===0)break}if(e=0,n.lookahead>=Wt&&(n.ins_h=sn(n,n.ins_h,n.window[n.strstart+Wt-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=Wt-1,e!==0&&n.prev_length<n.max_lazy_match&&n.strstart-e<=n.w_size-Re&&(n.match_length=xs(n,e),n.match_length<=5&&(n.strategy===mf||n.match_length===Wt&&n.strstart-n.match_start>4096)&&(n.match_length=Wt-1)),n.prev_length>=Wt&&n.match_length<=n.prev_length){o=n.strstart+n.lookahead-Wt,i=cn(n,n.strstart-1-n.prev_match,n.prev_length-Wt),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=o&&(n.ins_h=sn(n,n.ins_h,n.window[n.strstart+Wt-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=Wt-1,n.strstart++,i&&(me(n,!1),n.strm.avail_out===0))return pe}else if(n.match_available){if(i=cn(n,0,n.window[n.strstart-1]),i&&me(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return pe}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(i=cn(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart<Wt-1?n.strstart:Wt-1,t===Be?(me(n,!0),n.strm.avail_out===0?In:$n):n.sym_next&&(me(n,!1),n.strm.avail_out===0)?pe:Gn},qf=(n,t)=>{let e,i,o,a;const u=n.window;for(;;){if(n.lookahead<=an){if(Dn(n),n.lookahead<=an&&t===rn)return pe;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=Wt&&n.strstart>0&&(o=n.strstart-1,i=u[o],i===u[++o]&&i===u[++o]&&i===u[++o])){a=n.strstart+an;do;while(i===u[++o]&&i===u[++o]&&i===u[++o]&&i===u[++o]&&i===u[++o]&&i===u[++o]&&i===u[++o]&&i===u[++o]&&o<a);n.match_length=an-(a-o),n.match_length>n.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=Wt?(e=cn(n,1,n.match_length-Wt),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=cn(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(me(n,!1),n.strm.avail_out===0))return pe}return n.insert=0,t===Be?(me(n,!0),n.strm.avail_out===0?In:$n):n.sym_next&&(me(n,!1),n.strm.avail_out===0)?pe:Gn},Nf=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(Dn(n),n.lookahead===0)){if(t===rn)return pe;break}if(n.match_length=0,e=cn(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(me(n,!1),n.strm.avail_out===0))return pe}return n.insert=0,t===Be?(me(n,!0),n.strm.avail_out===0?In:$n):n.sym_next&&(me(n,!1),n.strm.avail_out===0)?pe:Gn};function Me(n,t,e,i,o){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=i,this.func=o}const ni=[new Me(0,0,0,0,Fs),new Me(4,4,8,4,xo),new Me(4,5,16,8,xo),new Me(4,6,32,32,xo),new Me(4,4,16,16,Fn),new Me(8,16,32,32,Fn),new Me(8,16,128,128,Fn),new Me(8,32,128,256,Fn),new Me(32,128,258,1024,Fn),new Me(32,258,258,4096,Fn)],Gf=n=>{n.window_size=2*n.w_size,on(n.head),n.max_lazy_match=ni[n.level].max_lazy,n.good_match=ni[n.level].good_length,n.nice_match=ni[n.level].nice_length,n.max_chain_length=ni[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=Wt-1,n.match_available=0,n.ins_h=0};function $f(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Xi,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(kf*2),this.dyn_dtree=new Uint16Array((2*Pf+1)*2),this.bl_tree=new Uint16Array((2*Mf+1)*2),on(this.dyn_ltree),on(this.dyn_dtree),on(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Tf+1),this.heap=new Uint16Array(2*Wo+1),on(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Wo+1),on(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const wi=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.status!==Qn&&t.status!==ya&&t.status!==Xo&&t.status!==Jo&&t.status!==ta&&t.status!==ea&&t.status!==An&&t.status!==ei?1:0},vs=n=>{if(wi(n))return bn(n,ze);n.total_in=n.total_out=0,n.data_type=xf;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?ya:t.wrap?Qn:An,n.adler=t.wrap===2?0:1,t.last_flush=-2,pf(t),he},Ss=n=>{const t=vs(n);return t===he&&Gf(n.state),t},Kf=(n,t)=>wi(n)||n.state.wrap!==2?ze:(n.state.gzhead=t,he),Os=(n,t,e,i,o,a)=>{if(!n)return ze;let u=1;if(t===wf&&(t=6),i<0?(u=0,i=-i):i>15&&(u=2,i-=16),o<1||o>Ff||e!==Xi||i<8||i>15||t<0||t>9||a<0||a>Ef||i===8&&u!==1)return bn(n,ze);i===8&&(i=9);const r=new $f;return n.state=r,r.strm=n,r.status=Qn,r.wrap=u,r.gzhead=null,r.w_bits=i,r.w_size=1<<r.w_bits,r.w_mask=r.w_size-1,r.hash_bits=o+7,r.hash_size=1<<r.hash_bits,r.hash_mask=r.hash_size-1,r.hash_shift=~~((r.hash_bits+Wt-1)/Wt),r.window=new Uint8Array(r.w_size*2),r.head=new Uint16Array(r.hash_size),r.prev=new Uint16Array(r.w_size),r.lit_bufsize=1<<o+6,r.pending_buf_size=r.lit_bufsize*4,r.pending_buf=new Uint8Array(r.pending_buf_size),r.sym_buf=r.lit_bufsize,r.sym_end=(r.lit_bufsize-1)*3,r.level=t,r.strategy=a,r.method=e,Ss(n)},Hf=(n,t)=>Os(n,t,Xi,vf,Sf,Bf),Zf=(n,t)=>{if(wi(n)||t>Ec||t<0)return n?bn(n,ze):ze;const e=n.state;if(!n.output||n.avail_in!==0&&!n.input||e.status===ei&&t!==Be)return bn(n,n.avail_out===0?Bo:ze);const i=e.last_flush;if(e.last_flush=t,e.pending!==0){if(Ie(n),n.avail_out===0)return e.last_flush=-1,he}else if(n.avail_in===0&&xc(t)<=xc(i)&&t!==Be)return bn(n,Bo);if(e.status===ei&&n.avail_in!==0)return bn(n,Bo);if(e.status===Qn&&e.wrap===0&&(e.status=An),e.status===Qn){let o=Xi+(e.w_bits-8<<4)<<8,a=-1;if(e.strategy>=Oi||e.level<2?a=0:e.level<6?a=1:e.level===6?a=2:a=3,o|=a<<6,e.strstart!==0&&(o|=zf),o+=31-o%31,Jn(e,o),e.strstart!==0&&(Jn(e,n.adler>>>16),Jn(e,n.adler&65535)),n.adler=1,e.status=An,Ie(n),e.pending!==0)return e.last_flush=-1,he}if(e.status===ya){if(n.adler=0,Xt(e,31),Xt(e,139),Xt(e,8),e.gzhead)Xt(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),Xt(e,e.gzhead.time&255),Xt(e,e.gzhead.time>>8&255),Xt(e,e.gzhead.time>>16&255),Xt(e,e.gzhead.time>>24&255),Xt(e,e.level===9?2:e.strategy>=Oi||e.level<2?4:0),Xt(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(Xt(e,e.gzhead.extra.length&255),Xt(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(n.adler=fe(n.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=Xo;else if(Xt(e,0),Xt(e,0),Xt(e,0),Xt(e,0),Xt(e,0),Xt(e,e.level===9?2:e.strategy>=Oi||e.level<2?4:0),Xt(e,Rf),e.status=An,Ie(n),e.pending!==0)return e.last_flush=-1,he}if(e.status===Xo){if(e.gzhead.extra){let o=e.pending,a=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+a>e.pending_buf_size;){let r=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+r),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o)),e.gzindex+=r,Ie(n),e.pending!==0)return e.last_flush=-1,he;o=0,a-=r}let u=new Uint8Array(e.gzhead.extra);e.pending_buf.set(u.subarray(e.gzindex,e.gzindex+a),e.pending),e.pending+=a,e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o)),e.gzindex=0}e.status=Jo}if(e.status===Jo){if(e.gzhead.name){let o=e.pending,a;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o)),Ie(n),e.pending!==0)return e.last_flush=-1,he;o=0}e.gzindex<e.gzhead.name.length?a=e.gzhead.name.charCodeAt(e.gzindex++)&255:a=0,Xt(e,a)}while(a!==0);e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o)),e.gzindex=0}e.status=ta}if(e.status===ta){if(e.gzhead.comment){let o=e.pending,a;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o)),Ie(n),e.pending!==0)return e.last_flush=-1,he;o=0}e.gzindex<e.gzhead.comment.length?a=e.gzhead.comment.charCodeAt(e.gzindex++)&255:a=0,Xt(e,a)}while(a!==0);e.gzhead.hcrc&&e.pending>o&&(n.adler=fe(n.adler,e.pending_buf,e.pending-o,o))}e.status=ea}if(e.status===ea){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(Ie(n),e.pending!==0))return e.last_flush=-1,he;Xt(e,n.adler&255),Xt(e,n.adler>>8&255),n.adler=0}if(e.status=An,Ie(n),e.pending!==0)return e.last_flush=-1,he}if(n.avail_in!==0||e.lookahead!==0||t!==rn&&e.status!==ei){let o=e.level===0?Fs(e,t):e.strategy===Oi?Nf(e,t):e.strategy===Cf?qf(e,t):ni[e.level].func(e,t);if((o===In||o===$n)&&(e.status=ei),o===pe||o===In)return n.avail_out===0&&(e.last_flush=-1),he;if(o===Gn&&(t===bf?Af(e):t!==Ec&&(jo(e,0,0,!1),t===yf&&(on(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),Ie(n),n.avail_out===0))return e.last_flush=-1,he}return t!==Be?he:e.wrap<=0?Bc:(e.wrap===2?(Xt(e,n.adler&255),Xt(e,n.adler>>8&255),Xt(e,n.adler>>16&255),Xt(e,n.adler>>24&255),Xt(e,n.total_in&255),Xt(e,n.total_in>>8&255),Xt(e,n.total_in>>16&255),Xt(e,n.total_in>>24&255)):(Jn(e,n.adler>>>16),Jn(e,n.adler&65535)),Ie(n),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?he:Bc)},Yf=n=>{if(wi(n))return ze;const t=n.state.status;return n.state=null,t===An?bn(n,If):he},Vf=(n,t)=>{let e=t.length;if(wi(n))return ze;const i=n.state,o=i.wrap;if(o===2||o===1&&i.status!==Qn||i.lookahead)return ze;if(o===1&&(n.adler=hi(n.adler,t,e,0)),i.wrap=0,e>=i.w_size){o===0&&(on(i.head),i.strstart=0,i.block_start=0,i.insert=0);let I=new Uint8Array(i.w_size);I.set(t.subarray(e-i.w_size,e),0),t=I,e=i.w_size}const a=n.avail_in,u=n.next_in,r=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,Dn(i);i.lookahead>=Wt;){let I=i.strstart,l=i.lookahead-(Wt-1);do i.ins_h=sn(i,i.ins_h,i.window[I+Wt-1]),i.prev[I&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=I,I++;while(--l);i.strstart=I,i.lookahead=Wt-1,Dn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=Wt-1,i.match_available=0,n.next_in=u,n.input=r,n.avail_in=a,i.wrap=o,he};var jf=Hf,Wf=Os,Xf=Ss,Jf=vs,t_=Kf,e_=Zf,n_=Yf,i_=Vf,o_="pako deflate (from Nodeca project)",oi={deflateInit:jf,deflateInit2:Wf,deflateReset:Xf,deflateResetKeep:Jf,deflateSetHeader:t_,deflate:e_,deflateEnd:n_,deflateSetDictionary:i_,deflateInfo:o_};const a_=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var c_=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const i in e)a_(e,i)&&(n[i]=e[i])}}return n},r_=n=>{let t=0;for(let i=0,o=n.length;i<o;i++)t+=n[i].length;const e=new Uint8Array(t);for(let i=0,o=0,a=n.length;i<a;i++){let u=n[i];e.set(u,o),o+=u.length}return e},Ji={assign:c_,flattenChunks:r_};let Us=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Us=!1}const gi=new Uint8Array(256);for(let n=0;n<256;n++)gi[n]=n>=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;gi[254]=gi[254]=1;var s_=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,i,o,a,u=n.length,r=0;for(o=0;o<u;o++)e=n.charCodeAt(o),(e&64512)===55296&&o+1<u&&(i=n.charCodeAt(o+1),(i&64512)===56320&&(e=65536+(e-55296<<10)+(i-56320),o++)),r+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(r),a=0,o=0;a<r;o++)e=n.charCodeAt(o),(e&64512)===55296&&o+1<u&&(i=n.charCodeAt(o+1),(i&64512)===56320&&(e=65536+(e-55296<<10)+(i-56320),o++)),e<128?t[a++]=e:e<2048?(t[a++]=192|e>>>6,t[a++]=128|e&63):e<65536?(t[a++]=224|e>>>12,t[a++]=128|e>>>6&63,t[a++]=128|e&63):(t[a++]=240|e>>>18,t[a++]=128|e>>>12&63,t[a++]=128|e>>>6&63,t[a++]=128|e&63);return t};const l_=(n,t)=>{if(t<65534&&n.subarray&&Us)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let i=0;i<t;i++)e+=String.fromCharCode(n[i]);return e};var d_=(n,t)=>{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let i,o;const a=new Array(e*2);for(o=0,i=0;i<e;){let u=n[i++];if(u<128){a[o++]=u;continue}let r=gi[u];if(r>4){a[o++]=65533,i+=r-1;continue}for(u&=r===2?31:r===3?15:7;r>1&&i<e;)u=u<<6|n[i++]&63,r--;if(r>1){a[o++]=65533;continue}u<65536?a[o++]=u:(u-=65536,a[o++]=55296|u>>10&1023,a[o++]=56320|u&1023)}return l_(a,o)},u_=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+gi[n[e]]>t?e:t},pi={string2buf:s_,buf2string:d_,utf8border:u_};function f_(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Ps=f_;const Ms=Object.prototype.toString,{Z_NO_FLUSH:__,Z_SYNC_FLUSH:h_,Z_FULL_FLUSH:g_,Z_FINISH:p_,Z_OK:$i,Z_STREAM_END:L_,Z_DEFAULT_COMPRESSION:A_,Z_DEFAULT_STRATEGY:b_,Z_DEFLATED:y_}=Cn;function mi(n){this.options=Ji.assign({level:A_,method:y_,chunkSize:16384,windowBits:15,memLevel:8,strategy:b_},n||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ps,this.strm.avail_out=0;let e=oi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==$i)throw new Error(yn[e]);if(t.header&&oi.deflateSetHeader(this.strm,t.header),t.dictionary){let i;if(typeof t.dictionary=="string"?i=pi.string2buf(t.dictionary):Ms.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,e=oi.deflateSetDictionary(this.strm,i),e!==$i)throw new Error(yn[e]);this._dict_set=!0}}mi.prototype.push=function(n,t){const e=this.strm,i=this.options.chunkSize;let o,a;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?p_:__,typeof n=="string"?e.input=pi.string2buf(n):Ms.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(i),e.next_out=0,e.avail_out=i),(a===h_||a===g_)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(o=oi.deflate(e,a),o===L_)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),o=oi.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===$i;if(e.avail_out===0){this.onData(e.output);continue}if(a>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0};mi.prototype.onData=function(n){this.chunks.push(n)};mi.prototype.onEnd=function(n){n===$i&&(this.result=Ji.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Ia(n,t){const e=new mi(t);if(e.push(n,!0),e.err)throw e.msg||yn[e.err];return e.result}function I_(n,t){return t=t||{},t.raw=!0,Ia(n,t)}function w_(n,t){return t=t||{},t.gzip=!0,Ia(n,t)}var m_=mi,C_=Ia,E_=I_,B_=w_,x_=Cn,F_={Deflate:m_,deflate:C_,deflateRaw:E_,gzip:B_,constants:x_};const Ui=16209,v_=16191;var S_=function(t,e){let i,o,a,u,r,I,l,s,m,C,g,M,$,F,R,x,it,z,K,v,f,L,V,X;const et=t.state;i=t.next_in,V=t.input,o=i+(t.avail_in-5),a=t.next_out,X=t.output,u=a-(e-t.avail_out),r=a+(t.avail_out-257),I=et.dmax,l=et.wsize,s=et.whave,m=et.wnext,C=et.window,g=et.hold,M=et.bits,$=et.lencode,F=et.distcode,R=(1<<et.lenbits)-1,x=(1<<et.distbits)-1;t:do{M<15&&(g+=V[i++]<<M,M+=8,g+=V[i++]<<M,M+=8),it=$[g&R];e:for(;;){if(z=it>>>24,g>>>=z,M-=z,z=it>>>16&255,z===0)X[a++]=it&65535;else if(z&16){K=it&65535,z&=15,z&&(M<z&&(g+=V[i++]<<M,M+=8),K+=g&(1<<z)-1,g>>>=z,M-=z),M<15&&(g+=V[i++]<<M,M+=8,g+=V[i++]<<M,M+=8),it=F[g&x];n:for(;;){if(z=it>>>24,g>>>=z,M-=z,z=it>>>16&255,z&16){if(v=it&65535,z&=15,M<z&&(g+=V[i++]<<M,M+=8,M<z&&(g+=V[i++]<<M,M+=8)),v+=g&(1<<z)-1,v>I){t.msg="invalid distance too far back",et.mode=Ui;break t}if(g>>>=z,M-=z,z=a-u,v>z){if(z=v-z,z>s&&et.sane){t.msg="invalid distance too far back",et.mode=Ui;break t}if(f=0,L=C,m===0){if(f+=l-z,z<K){K-=z;do X[a++]=C[f++];while(--z);f=a-v,L=X}}else if(m<z){if(f+=l+m-z,z-=m,z<K){K-=z;do X[a++]=C[f++];while(--z);if(f=0,m<K){z=m,K-=z;do X[a++]=C[f++];while(--z);f=a-v,L=X}}}else if(f+=m-z,z<K){K-=z;do X[a++]=C[f++];while(--z);f=a-v,L=X}for(;K>2;)X[a++]=L[f++],X[a++]=L[f++],X[a++]=L[f++],K-=3;K&&(X[a++]=L[f++],K>1&&(X[a++]=L[f++]))}else{f=a-v;do X[a++]=X[f++],X[a++]=X[f++],X[a++]=X[f++],K-=3;while(K>2);K&&(X[a++]=X[f++],K>1&&(X[a++]=X[f++]))}}else if(z&64){t.msg="invalid distance code",et.mode=Ui;break t}else{it=F[(it&65535)+(g&(1<<z)-1)];continue n}break}}else if(z&64)if(z&32){et.mode=v_;break t}else{t.msg="invalid literal/length code",et.mode=Ui;break t}else{it=$[(it&65535)+(g&(1<<z)-1)];continue e}break}}while(i<o&&a<r);K=M>>3,i-=K,M-=K<<3,g&=(1<<M)-1,t.next_in=i,t.next_out=a,t.avail_in=i<o?5+(o-i):5-(i-o),t.avail_out=a<r?257+(r-a):257-(a-r),et.hold=g,et.bits=M};const vn=15,Fc=852,vc=592,Sc=0,Fo=1,Oc=2,O_=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),U_=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),P_=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),M_=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),k_=(n,t,e,i,o,a,u,r)=>{const I=r.bits;let l=0,s=0,m=0,C=0,g=0,M=0,$=0,F=0,R=0,x=0,it,z,K,v,f,L=null,V;const X=new Uint16Array(vn+1),et=new Uint16Array(vn+1);let N=null,w,T,at;for(l=0;l<=vn;l++)X[l]=0;for(s=0;s<i;s++)X[t[e+s]]++;for(g=I,C=vn;C>=1&&X[C]===0;C--);if(g>C&&(g=C),C===0)return o[a++]=1<<24|64<<16|0,o[a++]=1<<24|64<<16|0,r.bits=1,0;for(m=1;m<C&&X[m]===0;m++);for(g<m&&(g=m),F=1,l=1;l<=vn;l++)if(F<<=1,F-=X[l],F<0)return-1;if(F>0&&(n===Sc||C!==1))return-1;for(et[1]=0,l=1;l<vn;l++)et[l+1]=et[l]+X[l];for(s=0;s<i;s++)t[e+s]!==0&&(u[et[t[e+s]]++]=s);if(n===Sc?(L=N=u,V=20):n===Fo?(L=O_,N=U_,V=257):(L=P_,N=M_,V=0),x=0,s=0,l=m,f=a,M=g,$=0,K=-1,R=1<<g,v=R-1,n===Fo&&R>Fc||n===Oc&&R>vc)return 1;for(;;){w=l-$,u[s]+1<V?(T=0,at=u[s]):u[s]>=V?(T=N[u[s]-V],at=L[u[s]-V]):(T=96,at=0),it=1<<l-$,z=1<<M,m=z;do z-=it,o[f+(x>>$)+z]=w<<24|T<<16|at|0;while(z!==0);for(it=1<<l-1;x⁢)it>>=1;if(it!==0?(x&=it-1,x+=it):x=0,s++,--X[l]===0){if(l===C)break;l=t[e+u[s]]}if(l>g&&(x&v)!==K){for($===0&&($=g),f+=m,M=l-$,F=1<<M;M+$<C&&(F-=X[M+$],!(F<=0));)M++,F<<=1;if(R+=1<<M,n===Fo&&R>Fc||n===Oc&&R>vc)return 1;K=x&v,o[K]=g<<24|M<<16|f-a|0}}return x!==0&&(o[f+x]=l-$<<24|64<<16|0),r.bits=g,0};var ai=k_;const T_=0,ks=1,Ts=2,{Z_FINISH:Uc,Z_BLOCK:z_,Z_TREES:Pi,Z_OK:wn,Z_STREAM_END:R_,Z_NEED_DICT:Q_,Z_STREAM_ERROR:xe,Z_DATA_ERROR:zs,Z_MEM_ERROR:Rs,Z_BUF_ERROR:D_,Z_DEFLATED:Pc}=Cn,to=16180,Mc=16181,kc=16182,Tc=16183,zc=16184,Rc=16185,Qc=16186,Dc=16187,qc=16188,Nc=16189,Ki=16190,Ne=16191,vo=16192,Gc=16193,So=16194,$c=16195,Kc=16196,Hc=16197,Zc=16198,Mi=16199,ki=16200,Yc=16201,Vc=16202,jc=16203,Wc=16204,Xc=16205,Oo=16206,Jc=16207,tr=16208,ce=16209,Qs=16210,Ds=16211,q_=852,N_=592,G_=15,$_=G_,er=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function K_(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const En=n=>{if(!n)return 1;const t=n.state;return!t||t.strm!==n||t.mode<to||t.mode>Ds?1:0},qs=n=>{if(En(n))return xe;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=to,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(q_),t.distcode=t.distdyn=new Int32Array(N_),t.sane=1,t.back=-1,wn},Ns=n=>{if(En(n))return xe;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,qs(n)},Gs=(n,t)=>{let e;if(En(n))return xe;const i=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?xe:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=e,i.wbits=t,Ns(n))},$s=(n,t)=>{if(!n)return xe;const e=new K_;n.state=e,e.strm=n,e.window=null,e.mode=to;const i=Gs(n,t);return i!==wn&&(n.state=null),i},H_=n=>$s(n,$_);let nr=!0,Uo,Po;const Z_=n=>{if(nr){Uo=new Int32Array(512),Po=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(ai(ks,n.lens,0,288,Uo,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;ai(Ts,n.lens,0,32,Po,0,n.work,{bits:5}),nr=!1}n.lencode=Uo,n.lenbits=9,n.distcode=Po,n.distbits=5},Ks=(n,t,e,i)=>{let o;const a=n.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),i>=a.wsize?(a.window.set(t.subarray(e-a.wsize,e),0),a.wnext=0,a.whave=a.wsize):(o=a.wsize-a.wnext,o>i&&(o=i),a.window.set(t.subarray(e-i,e-i+o),a.wnext),i-=o,i?(a.window.set(t.subarray(e-i,e),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0},Y_=(n,t)=>{let e,i,o,a,u,r,I,l,s,m,C,g,M,$,F=0,R,x,it,z,K,v,f,L;const V=new Uint8Array(4);let X,et;const N=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(En(n)||!n.output||!n.input&&n.avail_in!==0)return xe;e=n.state,e.mode===Ne&&(e.mode=vo),u=n.next_out,o=n.output,I=n.avail_out,a=n.next_in,i=n.input,r=n.avail_in,l=e.hold,s=e.bits,m=r,C=I,L=wn;t:for(;;)switch(e.mode){case to:if(e.wrap===0){e.mode=vo;break}for(;s<16;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(e.wrap&2&&l===35615){e.wbits===0&&(e.wbits=15),e.check=0,V[0]=l&255,V[1]=l>>>8&255,e.check=fe(e.check,V,2,0),l=0,s=0,e.mode=Mc;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((l&255)<<8)+(l>>8))%31){n.msg="incorrect header check",e.mode=ce;break}if((l&15)!==Pc){n.msg="unknown compression method",e.mode=ce;break}if(l>>>=4,s-=4,f=(l&15)+8,e.wbits===0&&(e.wbits=f),f>15||f>e.wbits){n.msg="invalid window size",e.mode=ce;break}e.dmax=1<<e.wbits,e.flags=0,n.adler=e.check=1,e.mode=l&512?Nc:Ne,l=0,s=0;break;case Mc:for(;s<16;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(e.flags=l,(e.flags&255)!==Pc){n.msg="unknown compression method",e.mode=ce;break}if(e.flags&57344){n.msg="unknown header flags set",e.mode=ce;break}e.head&&(e.head.text=l>>8&1),e.flags&512&&e.wrap&4&&(V[0]=l&255,V[1]=l>>>8&255,e.check=fe(e.check,V,2,0)),l=0,s=0,e.mode=kc;case kc:for(;s<32;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.head&&(e.head.time=l),e.flags&512&&e.wrap&4&&(V[0]=l&255,V[1]=l>>>8&255,V[2]=l>>>16&255,V[3]=l>>>24&255,e.check=fe(e.check,V,4,0)),l=0,s=0,e.mode=Tc;case Tc:for(;s<16;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.head&&(e.head.xflags=l&255,e.head.os=l>>8),e.flags&512&&e.wrap&4&&(V[0]=l&255,V[1]=l>>>8&255,e.check=fe(e.check,V,2,0)),l=0,s=0,e.mode=zc;case zc:if(e.flags&1024){for(;s<16;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.length=l,e.head&&(e.head.extra_len=l),e.flags&512&&e.wrap&4&&(V[0]=l&255,V[1]=l>>>8&255,e.check=fe(e.check,V,2,0)),l=0,s=0}else e.head&&(e.head.extra=null);e.mode=Rc;case Rc:if(e.flags&1024&&(g=e.length,g>r&&(g=r),g&&(e.head&&(f=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(i.subarray(a,a+g),f)),e.flags&512&&e.wrap&4&&(e.check=fe(e.check,i,g,a)),r-=g,a+=g,e.length-=g),e.length))break t;e.length=0,e.mode=Qc;case Qc:if(e.flags&2048){if(r===0)break t;g=0;do f=i[a+g++],e.head&&f&&e.length<65536&&(e.head.name+=String.fromCharCode(f));while(f&&g<r);if(e.flags&512&&e.wrap&4&&(e.check=fe(e.check,i,g,a)),r-=g,a+=g,f)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=Dc;case Dc:if(e.flags&4096){if(r===0)break t;g=0;do f=i[a+g++],e.head&&f&&e.length<65536&&(e.head.comment+=String.fromCharCode(f));while(f&&g<r);if(e.flags&512&&e.wrap&4&&(e.check=fe(e.check,i,g,a)),r-=g,a+=g,f)break t}else e.head&&(e.head.comment=null);e.mode=qc;case qc:if(e.flags&512){for(;s<16;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(e.wrap&4&&l!==(e.check&65535)){n.msg="header crc mismatch",e.mode=ce;break}l=0,s=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=Ne;break;case Nc:for(;s<32;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}n.adler=e.check=er(l),l=0,s=0,e.mode=Ki;case Ki:if(e.havedict===0)return n.next_out=u,n.avail_out=I,n.next_in=a,n.avail_in=r,e.hold=l,e.bits=s,Q_;n.adler=e.check=1,e.mode=Ne;case Ne:if(t===z_||t===Pi)break t;case vo:if(e.last){l>>>=s&7,s-=s&7,e.mode=Oo;break}for(;s<3;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}switch(e.last=l&1,l>>>=1,s-=1,l&3){case 0:e.mode=Gc;break;case 1:if(Z_(e),e.mode=Mi,t===Pi){l>>>=2,s-=2;break t}break;case 2:e.mode=Kc;break;case 3:n.msg="invalid block type",e.mode=ce}l>>>=2,s-=2;break;case Gc:for(l>>>=s&7,s-=s&7;s<32;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if((l&65535)!==(l>>>16^65535)){n.msg="invalid stored block lengths",e.mode=ce;break}if(e.length=l&65535,l=0,s=0,e.mode=So,t===Pi)break t;case So:e.mode=$c;case $c:if(g=e.length,g){if(g>r&&(g=r),g>I&&(g=I),g===0)break t;o.set(i.subarray(a,a+g),u),r-=g,a+=g,I-=g,u+=g,e.length-=g;break}e.mode=Ne;break;case Kc:for(;s<14;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(e.nlen=(l&31)+257,l>>>=5,s-=5,e.ndist=(l&31)+1,l>>>=5,s-=5,e.ncode=(l&15)+4,l>>>=4,s-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=ce;break}e.have=0,e.mode=Hc;case Hc:for(;e.have<e.ncode;){for(;s<3;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.lens[N[e.have++]]=l&7,l>>>=3,s-=3}for(;e.have<19;)e.lens[N[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,X={bits:e.lenbits},L=ai(T_,e.lens,0,19,e.lencode,0,e.work,X),e.lenbits=X.bits,L){n.msg="invalid code lengths set",e.mode=ce;break}e.have=0,e.mode=Zc;case Zc:for(;e.have<e.nlen+e.ndist;){for(;F=e.lencode[l&(1<<e.lenbits)-1],R=F>>>24,x=F>>>16&255,it=F&65535,!(R<=s);){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(it<16)l>>>=R,s-=R,e.lens[e.have++]=it;else{if(it===16){for(et=R+2;s<et;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(l>>>=R,s-=R,e.have===0){n.msg="invalid bit length repeat",e.mode=ce;break}f=e.lens[e.have-1],g=3+(l&3),l>>>=2,s-=2}else if(it===17){for(et=R+3;s<et;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}l>>>=R,s-=R,f=0,g=3+(l&7),l>>>=3,s-=3}else{for(et=R+7;s<et;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}l>>>=R,s-=R,f=0,g=11+(l&127),l>>>=7,s-=7}if(e.have+g>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=ce;break}for(;g--;)e.lens[e.have++]=f}}if(e.mode===ce)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=ce;break}if(e.lenbits=9,X={bits:e.lenbits},L=ai(ks,e.lens,0,e.nlen,e.lencode,0,e.work,X),e.lenbits=X.bits,L){n.msg="invalid literal/lengths set",e.mode=ce;break}if(e.distbits=6,e.distcode=e.distdyn,X={bits:e.distbits},L=ai(Ts,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,X),e.distbits=X.bits,L){n.msg="invalid distances set",e.mode=ce;break}if(e.mode=Mi,t===Pi)break t;case Mi:e.mode=ki;case ki:if(r>=6&&I>=258){n.next_out=u,n.avail_out=I,n.next_in=a,n.avail_in=r,e.hold=l,e.bits=s,S_(n,C),u=n.next_out,o=n.output,I=n.avail_out,a=n.next_in,i=n.input,r=n.avail_in,l=e.hold,s=e.bits,e.mode===Ne&&(e.back=-1);break}for(e.back=0;F=e.lencode[l&(1<<e.lenbits)-1],R=F>>>24,x=F>>>16&255,it=F&65535,!(R<=s);){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(x&&!(x&240)){for(z=R,K=x,v=it;F=e.lencode[v+((l&(1<<z+K)-1)>>z)],R=F>>>24,x=F>>>16&255,it=F&65535,!(z+R<=s);){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}l>>>=z,s-=z,e.back+=z}if(l>>>=R,s-=R,e.back+=R,e.length=it,x===0){e.mode=Xc;break}if(x&32){e.back=-1,e.mode=Ne;break}if(x&64){n.msg="invalid literal/length code",e.mode=ce;break}e.extra=x&15,e.mode=Yc;case Yc:if(e.extra){for(et=e.extra;s<et;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.length+=l&(1<<e.extra)-1,l>>>=e.extra,s-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=Vc;case Vc:for(;F=e.distcode[l&(1<<e.distbits)-1],R=F>>>24,x=F>>>16&255,it=F&65535,!(R<=s);){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(!(x&240)){for(z=R,K=x,v=it;F=e.distcode[v+((l&(1<<z+K)-1)>>z)],R=F>>>24,x=F>>>16&255,it=F&65535,!(z+R<=s);){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}l>>>=z,s-=z,e.back+=z}if(l>>>=R,s-=R,e.back+=R,x&64){n.msg="invalid distance code",e.mode=ce;break}e.offset=it,e.extra=x&15,e.mode=jc;case jc:if(e.extra){for(et=e.extra;s<et;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}e.offset+=l&(1<<e.extra)-1,l>>>=e.extra,s-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=ce;break}e.mode=Wc;case Wc:if(I===0)break t;if(g=C-I,e.offset>g){if(g=e.offset-g,g>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=ce;break}g>e.wnext?(g-=e.wnext,M=e.wsize-g):M=e.wnext-g,g>e.length&&(g=e.length),$=e.window}else $=o,M=u-e.offset,g=e.length;g>I&&(g=I),I-=g,e.length-=g;do o[u++]=$[M++];while(--g);e.length===0&&(e.mode=ki);break;case Xc:if(I===0)break t;o[u++]=e.length,I--,e.mode=ki;break;case Oo:if(e.wrap){for(;s<32;){if(r===0)break t;r--,l|=i[a++]<<s,s+=8}if(C-=I,n.total_out+=C,e.total+=C,e.wrap&4&&C&&(n.adler=e.check=e.flags?fe(e.check,o,C,u-C):hi(e.check,o,C,u-C)),C=I,e.wrap&4&&(e.flags?l:er(l))!==e.check){n.msg="incorrect data check",e.mode=ce;break}l=0,s=0}e.mode=Jc;case Jc:if(e.wrap&&e.flags){for(;s<32;){if(r===0)break t;r--,l+=i[a++]<<s,s+=8}if(e.wrap&4&&l!==(e.total&4294967295)){n.msg="incorrect length check",e.mode=ce;break}l=0,s=0}e.mode=tr;case tr:L=R_;break t;case ce:L=zs;break t;case Qs:return Rs;case Ds:default:return xe}return n.next_out=u,n.avail_out=I,n.next_in=a,n.avail_in=r,e.hold=l,e.bits=s,(e.wsize||C!==n.avail_out&&e.mode<ce&&(e.mode<Oo||t!==Uc))&&Ks(n,n.output,n.next_out,C-n.avail_out),m-=n.avail_in,C-=n.avail_out,n.total_in+=m,n.total_out+=C,e.total+=C,e.wrap&4&&C&&(n.adler=e.check=e.flags?fe(e.check,o,C,n.next_out-C):hi(e.check,o,C,n.next_out-C)),n.data_type=e.bits+(e.last?64:0)+(e.mode===Ne?128:0)+(e.mode===Mi||e.mode===So?256:0),(m===0&&C===0||t===Uc)&&L===wn&&(L=D_),L},V_=n=>{if(En(n))return xe;let t=n.state;return t.window&&(t.window=null),n.state=null,wn},j_=(n,t)=>{if(En(n))return xe;const e=n.state;return e.wrap&2?(e.head=t,t.done=!1,wn):xe},W_=(n,t)=>{const e=t.length;let i,o,a;return En(n)||(i=n.state,i.wrap!==0&&i.mode!==Ki)?xe:i.mode===Ki&&(o=1,o=hi(o,t,e,0),o!==i.check)?zs:(a=Ks(n,t,e,e),a?(i.mode=Qs,Rs):(i.havedict=1,wn))};var X_=Ns,J_=Gs,th=qs,eh=H_,nh=$s,ih=Y_,oh=V_,ah=j_,ch=W_,rh="pako inflate (from Nodeca project)",$e={inflateReset:X_,inflateReset2:J_,inflateResetKeep:th,inflateInit:eh,inflateInit2:nh,inflate:ih,inflateEnd:oh,inflateGetHeader:ah,inflateSetDictionary:ch,inflateInfo:rh};function sh(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var lh=sh;const Hs=Object.prototype.toString,{Z_NO_FLUSH:dh,Z_FINISH:uh,Z_OK:Li,Z_STREAM_END:Mo,Z_NEED_DICT:ko,Z_STREAM_ERROR:fh,Z_DATA_ERROR:ir,Z_MEM_ERROR:_h}=Cn;function Ci(n){this.options=Ji.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(n&&n.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ps,this.strm.avail_out=0;let e=$e.inflateInit2(this.strm,t.windowBits);if(e!==Li)throw new Error(yn[e]);if(this.header=new lh,$e.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=pi.string2buf(t.dictionary):Hs.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=$e.inflateSetDictionary(this.strm,t.dictionary),e!==Li)))throw new Error(yn[e])}Ci.prototype.push=function(n,t){const e=this.strm,i=this.options.chunkSize,o=this.options.dictionary;let a,u,r;if(this.ended)return!1;for(t===~~t?u=t:u=t===!0?uh:dh,Hs.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(i),e.next_out=0,e.avail_out=i),a=$e.inflate(e,u),a===ko&&o&&(a=$e.inflateSetDictionary(e,o),a===Li?a=$e.inflate(e,u):a===ir&&(a=ko));e.avail_in>0&&a===Mo&&e.state.wrap>0&&n[e.next_in]!==0;)$e.inflateReset(e),a=$e.inflate(e,u);switch(a){case fh:case ir:case ko:case _h:return this.onEnd(a),this.ended=!0,!1}if(r=e.avail_out,e.next_out&&(e.avail_out===0||a===Mo))if(this.options.to==="string"){let I=pi.utf8border(e.output,e.next_out),l=e.next_out-I,s=pi.buf2string(e.output,I);e.next_out=l,e.avail_out=i-l,l&&e.output.set(e.output.subarray(I,I+l),0),this.onData(s)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(a===Li&&r===0)){if(a===Mo)return a=$e.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};Ci.prototype.onData=function(n){this.chunks.push(n)};Ci.prototype.onEnd=function(n){n===Li&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ji.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function wa(n,t){const e=new Ci(t);if(e.push(n),e.err)throw e.msg||yn[e.err];return e.result}function hh(n,t){return t=t||{},t.raw=!0,wa(n,t)}var gh=Ci,ph=wa,Lh=hh,Ah=wa,bh=Cn,yh={Inflate:gh,inflate:ph,inflateRaw:Lh,ungzip:Ah,constants:bh};const{Deflate:Ih,deflate:wh,deflateRaw:mh,gzip:Ch}=F_,{Inflate:Eh,inflate:Bh,inflateRaw:xh,ungzip:Fh}=yh;var vh=Ih,Sh=wh,Oh=mh,Uh=Ch,Ph=Eh,Mh=Bh,kh=xh,Th=Fh,zh=Cn,Rh={Deflate:vh,deflate:Sh,deflateRaw:Oh,gzip:Uh,Inflate:Ph,inflate:Mh,inflateRaw:kh,ungzip:Th,constants:zh};const Sn="circuit";let ia=!1;const Hi={info:(...n)=>{ia&&console.log(...n)},debug:(...n)=>{ia&&console.log(...n)}};async function Qh(n,t){for(let e=1;e<=t;e++){Hi.debug(`download attempt ${e} for ${n}`);const i=await fetch(n,{method:"GET"});if(i.status===200)return i}throw new Error(`Error downloading ${n} after ${t} retries`)}const Dh=async n=>Rh.ungzip(n).buffer;async function or(n,t,e=!1){const o=await(await Qh(n,3)).arrayBuffer();if(!e)await _n.setItem(t,o);else{const a=await Dh(o);await _n.setItem(t,a),Hi.debug("stored file in localforage",t)}Hi.info(`Storage of ${t} successful!`)}self.onmessage=async function(n){const{chunkedZkeyUrls:t,inputs:e,wasmUrl:i,loggingConfig:o}=n.data;o&&(ia=o.enabled&&o.level!=="silent"),self.postMessage({type:"message",message:"Worker started"}),self.postMessage({type:"progress",message:"Downloading zkeys"}),await Promise.all(t.map(async({suffix:l,url:s})=>{await or(s,`${Sn}.zkey${l}`,!0)})),self.postMessage({type:"progress",message:"Downloading the wasm file"}),await or(i,`${Sn}.wasm`,!1),self.postMessage({type:"message",message:"Download complete"}),self.postMessage({type:"progress",message:"Preparing circuit files"});const a=[];for(const{suffix:l}of t){const s=await _n.getItem(`${Sn}.zkey${l}`);s&&a.push(new Uint8Array(s))}let u;if(a.length>0){const l=a.reduce((m,C)=>m+C.length,0);u=new Uint8Array(l);let s=0;for(const m of a)u.set(m,s),s+=m.length;await _n.setItem(`${Sn}.zkey`,u)}let r=await _n.getItem(`${Sn}.zkey`);if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!r)throw new Error("ZKey file not found - no chunks were downloaded successfully");let I=await _n.getItem(`${Sn}.wasm`);if(I instanceof ArrayBuffer&&(I=new Uint8Array(I)),!I)throw new Error("WASM file not found - download may have failed");try{self.postMessage({type:"progress",message:"Proving"});const{proof:l,publicSignals:s}=await Ru.fullProve(JSON.parse(e),I,r);await _n.clear(),self.postMessage({type:"result",message:{proof:l,publicSignals:s}}),Hi.info("shutting down worker"),self.close()}catch(l){self.postMessage({type:"error",error:l.message}),self.close()}};
|