@hinkal/common 0.0.15 → 0.0.16
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/package.json +1 -1
- package/index-B8ePiYjC.js +0 -252
- package/index.js +0 -1
- package/snarkjsWorkerLogic-DertJLwB.js +0 -199
- package/utxoWorkerLogic-DtyjPuS3.js +0 -1
- package/viteWorkerURL.constant-B4ERp5DP.js +0 -1
- package/workerProxy-C2KnRvuH.js +0 -1
- package/zkProofWorkerLogic-C5kAcugj.js +0 -1
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const lo=require("./workerProxy-C2KnRvuH.js"),se=require("./index-B8ePiYjC.js"),uo=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function on(c,t){if(!t||t==10)return BigInt(c);if(t==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}const ve=on;function fo(c,t){let e=BigInt(0);t=BigInt(t);for(let n=0;n<c.length;n++)e=e*t+BigInt(c[n]);return e}function Ni(c){const t=c.toString(16);return(t.length-1)*4+uo[parseInt(t[0],16)]}function _o(c){return BigInt(c)<BigInt(0)}function go(c){return!c}function zi(c,t){return BigInt(c)<<BigInt(t)}function Rn(c,t){return BigInt(c)>>BigInt(t)}const po=zi,ho=Rn;function Lo(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function mo(c){let t=BigInt(c);const e=[];for(;t;){if(t&BigInt(1)){const n=2-Number(t%BigInt(4));e.push(n),t=t-BigInt(n)}else e.push(0);t=t>>BigInt(1)}return e}function bo(c){let t=BigInt(c);const e=[];for(;t;)t&BigInt(1)?e.push(1):e.push(0),t=t>>BigInt(1);return e}function Ui(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function yo(c,t){const e=[];let n=BigInt(c);for(t=BigInt(t);n;)e.unshift(Number(n%t)),n=n/t;return e}function Co(c,t){return BigInt(c)+BigInt(t)}function Ao(c,t){return BigInt(c)-BigInt(t)}function Fo(c){return-BigInt(c)}function Eo(c,t){return BigInt(c)*BigInt(t)}function wo(c){return BigInt(c)*BigInt(c)}function Bo(c,t){return BigInt(c)**BigInt(t)}function vo(c,t){return BigInt(c)**BigInt(t)}function xo(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function So(c,t){return BigInt(c)/BigInt(t)}function Io(c,t){return BigInt(c)%BigInt(t)}function Oo(c,t){return BigInt(c)==BigInt(t)}function Po(c,t){return BigInt(c)!=BigInt(t)}function ko(c,t){return BigInt(c)<BigInt(t)}function To(c,t){return BigInt(c)>BigInt(t)}function qo(c,t){return BigInt(c)<=BigInt(t)}function Mo(c,t){return BigInt(c)>=BigInt(t)}function ji(c,t){return BigInt(c)&BigInt(t)}function Do(c,t){return BigInt(c)|BigInt(t)}function Ro(c,t){return BigInt(c)^BigInt(t)}function No(c,t){return BigInt(c)&&BigInt(t)}function zo(c,t){return BigInt(c)||BigInt(t)}function Uo(c){return!BigInt(c)}function $i(c,t,e,n){const i="0000000"+e.toString(16),s=new Uint32Array(c.buffer,c.byteOffset+t,n/4),g=((i.length-7)*4-1>>5)+1;for(let d=0;d<g;d++)s[d]=parseInt(i.substring(i.length-8*d-8,i.length-8*d),16);for(let d=g;d<s.length;d++)s[d]=0;for(let d=s.length*4;d<n;d++)c[d]=Ui(ji(Rn(e,d*8),255))}function jo(c,t,e,n){const i="0000000"+e.toString(16),s=new DataView(c.buffer,c.byteOffset+t,n),g=((i.length-7)*4-1>>5)+1;for(let d=0;d<g;d++)s.setUint32(n-d*4-4,parseInt(i.substring(i.length-8*d-8,i.length-8*d),16),!1);for(let d=0;d<n/4-g;d++)s[d]=0}function $o(c,t,e){e=e||c.byteLength,t=t||0;const n=new Uint32Array(c.buffer,c.byteOffset+t,e/4),i=new Array(e/4);return n.forEach((s,g)=>i[i.length-g-1]=s.toString(16).padStart(8,"0")),on(i.join(""),16)}function Go(c,t,e){e=e||c.byteLength,t=t||0;const n=new DataView(c.buffer,c.byteOffset+t,e),i=new Array(e/4);for(let s=0;s<e/4;s++)i[s]=n.getUint32(s*4,!1).toString(16).padStart(8,"0");return on(i.join(""),16)}function Zo(c,t){return c.toString(t)}function Wo(c){const t=new Uint8Array(Math.floor((Ni(c)-1)/8)+1);return $i(t,0,c,t.byteLength),t}const Xo=ve(0),Vo=ve(1);var Ho=Object.freeze({__proto__:null,abs:xo,add:Co,band:ji,bitLength:Ni,bits:bo,bor:Do,bxor:Ro,div:So,e:ve,eq:Oo,exp:vo,fromArray:fo,fromRprBE:Go,fromRprLE:$o,fromString:on,geq:Mo,gt:To,isNegative:_o,isOdd:Lo,isZero:go,land:No,leq:qo,lnot:Uo,lor:zo,lt:ko,mod:Io,mul:Eo,naf:mo,neg:Fo,neq:Po,one:Vo,pow:Bo,shiftLeft:zi,shiftRight:Rn,shl:po,shr:ho,square:wo,sub:Ao,toArray:yo,toLEBuff:Wo,toNumber:Ui,toRprBE:jo,toRprLE:$i,toString:Zo,zero:Xo});const oe=1<<30;let Qo=class Bn{constructor(t){this.buffers=[],this.byteLength=t;for(let e=0;e<t;e+=oe){const n=Math.min(t-e,oe);this.buffers.push(new Uint8Array(n))}}slice(t,e){e===void 0&&(e=this.byteLength),t===void 0&&(t=0);const n=e-t,i=Math.floor(t/oe),s=Math.floor((t+n-1)/oe);if(i==s||n==0)return this.buffers[i].slice(t%oe,t%oe+n);let g,d=i,C=t%oe,l=n;for(;l>0;){const o=C+l>oe?oe-C:l,y=new Uint8Array(this.buffers[d].buffer,this.buffers[d].byteOffset+C,o);if(o==n)return y.slice();g||(n<=oe?g=new Uint8Array(n):g=new Bn(n)),g.set(y,n-l),l=l-o,d++,C=0}return g}set(t,e){e===void 0&&(e=0);const n=t.byteLength;if(n==0)return;const i=Math.floor(e/oe),s=Math.floor((e+n-1)/oe);if(i==s)return t instanceof Bn&&t.buffers.length==1?this.buffers[i].set(t.buffers[0],e%oe):this.buffers[i].set(t,e%oe);let g=i,d=e%oe,C=n;for(;C>0;){const l=d+C>oe?oe-d:C,o=t.slice(n-C,n-C+l);new Uint8Array(this.buffers[g].buffer,this.buffers[g].byteOffset+d,l).set(o),C=C-l,g++,d=0}}};function Jo(c){return globalThis.btoa(c)}Jo(`(function thread(self) {
|
|
2
|
-
const MAXMEM = 32767;
|
|
3
|
-
let instance;
|
|
4
|
-
let memory;
|
|
5
|
-
|
|
6
|
-
if (self) {
|
|
7
|
-
self.onmessage = function(e) {
|
|
8
|
-
let data;
|
|
9
|
-
if (e.data) {
|
|
10
|
-
data = e.data;
|
|
11
|
-
} else {
|
|
12
|
-
data = e;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (data[0].cmd == "INIT") {
|
|
16
|
-
init(data[0]).then(function() {
|
|
17
|
-
self.postMessage(data.result);
|
|
18
|
-
});
|
|
19
|
-
} else if (data[0].cmd == "TERMINATE") {
|
|
20
|
-
self.close();
|
|
21
|
-
} else {
|
|
22
|
-
const res = runTask(data);
|
|
23
|
-
self.postMessage(res);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function init(data) {
|
|
29
|
-
const code = new Uint8Array(data.code);
|
|
30
|
-
const wasmModule = await WebAssembly.compile(code);
|
|
31
|
-
memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM});
|
|
32
|
-
|
|
33
|
-
instance = await WebAssembly.instantiate(wasmModule, {
|
|
34
|
-
env: {
|
|
35
|
-
"memory": memory
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function alloc(length) {
|
|
43
|
-
const u32 = new Uint32Array(memory.buffer, 0, 1);
|
|
44
|
-
while (u32[0] & 3) u32[0]++; // Return always aligned pointers
|
|
45
|
-
const res = u32[0];
|
|
46
|
-
u32[0] += length;
|
|
47
|
-
if (u32[0] + length > memory.buffer.byteLength) {
|
|
48
|
-
const currentPages = memory.buffer.byteLength / 0x10000;
|
|
49
|
-
let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1;
|
|
50
|
-
if (requiredPages>MAXMEM) requiredPages=MAXMEM;
|
|
51
|
-
memory.grow(requiredPages-currentPages);
|
|
52
|
-
}
|
|
53
|
-
return res;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function allocBuffer(buffer) {
|
|
57
|
-
const p = alloc(buffer.byteLength);
|
|
58
|
-
setBuffer(p, buffer);
|
|
59
|
-
return p;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function getBuffer(pointer, length) {
|
|
63
|
-
const u8 = new Uint8Array(memory.buffer);
|
|
64
|
-
return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function setBuffer(pointer, buffer) {
|
|
68
|
-
const u8 = new Uint8Array(memory.buffer);
|
|
69
|
-
u8.set(new Uint8Array(buffer), pointer);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function runTask(task) {
|
|
73
|
-
if (task[0].cmd == "INIT") {
|
|
74
|
-
return init(task[0]);
|
|
75
|
-
}
|
|
76
|
-
const ctx = {
|
|
77
|
-
vars: [],
|
|
78
|
-
out: []
|
|
79
|
-
};
|
|
80
|
-
const u32a = new Uint32Array(memory.buffer, 0, 1);
|
|
81
|
-
const oldAlloc = u32a[0];
|
|
82
|
-
for (let i=0; i<task.length; i++) {
|
|
83
|
-
switch (task[i].cmd) {
|
|
84
|
-
case "ALLOCSET":
|
|
85
|
-
ctx.vars[task[i].var] = allocBuffer(task[i].buff);
|
|
86
|
-
break;
|
|
87
|
-
case "ALLOC":
|
|
88
|
-
ctx.vars[task[i].var] = alloc(task[i].len);
|
|
89
|
-
break;
|
|
90
|
-
case "SET":
|
|
91
|
-
setBuffer(ctx.vars[task[i].var], task[i].buff);
|
|
92
|
-
break;
|
|
93
|
-
case "CALL": {
|
|
94
|
-
const params = [];
|
|
95
|
-
for (let j=0; j<task[i].params.length; j++) {
|
|
96
|
-
const p = task[i].params[j];
|
|
97
|
-
if (typeof p.var !== "undefined") {
|
|
98
|
-
params.push(ctx.vars[p.var] + (p.offset || 0));
|
|
99
|
-
} else if (typeof p.val != "undefined") {
|
|
100
|
-
params.push(p.val);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
instance.exports[task[i].fnName](...params);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case "GET":
|
|
107
|
-
ctx.out[task[i].out] = getBuffer(ctx.vars[task[i].var], task[i].len).slice();
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
throw new Error("Invalid cmd");
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const u32b = new Uint32Array(memory.buffer, 0, 1);
|
|
114
|
-
u32b[0] = oldAlloc;
|
|
115
|
-
return ctx.out;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return runTask;
|
|
120
|
-
})(self)`);globalThis.curve_bn128=null;globalThis.curve_bls12381=null;ve("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);ve("21888242871839275222246405745257275088548364400416034343698204186575808495617");ve("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16);ve("21888242871839275222246405745257275088696311157297823662689037894645226208583");const Gi=Ho;async function Zi(c,t,e,n){if(e=e||4096*64,typeof t!="number"&&["w+","wx+","r","ax+","a+"].indexOf(t)<0)throw new Error("Invalid open option");const i=await se.fs.promises.open(c,t),s=await i.stat();return new Ko(i,s,e,n,c)}class Ko{constructor(t,e,n,i,s){for(this.fileName=s,this.fd=t,this.pos=0,this.pageSize=i||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(n/this.pageSize)+1,this.pages={},this.pendingLoads=[],this.writing=!1,this.reading=!1,this.avBuffs=[],this.history={}}_loadPage(t){const e=this,n=new Promise((i,s)=>{e.pendingLoads.push({page:t,resolve:i,reject:s})});return e.__statusPage("After Load request: ",t),n}__statusPage(t,e){const n=[],i=this;if(!i.logHistory)return;n.push("=="+t+" "+e);let s="";for(let g=0;g<i.pendingLoads.length;g++)i.pendingLoads[g].page==e&&(s=s+" "+g);if(s&&n.push("Pending loads:"+s),typeof i.pages[e]<"u"){const g=i.pages[e];n.push("Loaded"),n.push("pendingOps: "+g.pendingOps),g.loading&&n.push("loading: "+g.loading),g.writing&&n.push("writing"),g.dirty&&n.push("dirty")}n.push("=="),i.history[e]||(i.history[e]=[]),i.history[e].push(n)}__printHistory(t){const e=this;e.history[t]||console.log("Empty History ",t),console.log("History "+t);for(let n=0;n<e.history[t].length;n++)for(let i=0;i<e.history[t][n].length;i++)console.log("-> "+e.history[t][n][i])}_triggerLoad(){const t=this;if(t.reading||t.pendingLoads.length==0)return;const e=Object.keys(t.pages),n=[];for(let d=0;d<e.length;d++){const C=t.pages[parseInt(e[d])];C.dirty==!1&&C.pendingOps==0&&!C.writing&&!C.loading&&n.push(parseInt(e[d]))}let i=t.maxPagesLoaded-e.length;const s=[];for(;t.pendingLoads.length>0&&(typeof t.pages[t.pendingLoads[0].page]<"u"||i>0||n.length>0);){const d=t.pendingLoads.shift();if(typeof t.pages[d.page]<"u"){t.pages[d.page].pendingOps++;const C=n.indexOf(d.page);C>=0&&n.splice(C,1),t.pages[d.page].loading?t.pages[d.page].loading.push(d):d.resolve(),t.__statusPage("After Load (cached): ",d.page)}else{if(i)i--;else{const C=n.shift();t.__statusPage("Before Unload: ",C),t.avBuffs.unshift(t.pages[C]),delete t.pages[C],t.__statusPage("After Unload: ",C)}d.page>=t.totalPages?(t.pages[d.page]=g(),d.resolve(),t.__statusPage("After Load (new): ",d.page)):(t.reading=!0,t.pages[d.page]=g(),t.pages[d.page].loading=[d],s.push(t.fd.read(t.pages[d.page].buff,0,t.pageSize,d.page*t.pageSize).then(C=>{t.pages[d.page].size=C.bytesRead;const l=t.pages[d.page].loading;delete t.pages[d.page].loading;for(let o=0;o<l.length;o++)l[o].resolve();return t.__statusPage("After Load (loaded): ",d.page),C},C=>{d.reject(C)})),t.__statusPage("After Load (loading): ",d.page))}}Promise.all(s).then(()=>{t.reading=!1,t.pendingLoads.length>0&&setImmediate(t._triggerLoad.bind(t)),t._tryClose()});function g(){if(t.avBuffs.length>0){const d=t.avBuffs.shift();return d.dirty=!1,d.pendingOps=1,d.size=0,d}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),n=[];for(let i=0;i<e.length;i++){const s=t.pages[parseInt(e[i])];s.dirty&&(s.dirty=!1,s.writing=!0,t.writing=!0,n.push(t.fd.write(s.buff,0,s.size,parseInt(e[i])*t.pageSize).then(()=>{s.writing=!1},g=>{console.log("ERROR Writing: "+g),t.error=g,t._tryClose()})))}t.writing&&Promise.all(n).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 n=this;if(typeof e>"u"&&(e=n.pos),n.pos=e+t.byteLength,n.totalSize<e+t.byteLength&&(n.totalSize=e+t.byteLength),n.pendingClose)throw new Error("Writing a closing file");const i=Math.floor(e/n.pageSize),s=Math.floor((e+t.byteLength-1)/n.pageSize),g=[];for(let o=i;o<=s;o++)g.push(n._loadPage(o));n._triggerLoad();let d=i,C=e%n.pageSize,l=t.byteLength;for(;l>0;){await g[d-i];const o=C+l>n.pageSize?n.pageSize-C:l,y=t.slice(t.byteLength-l,t.byteLength-l+o);new Uint8Array(n.pages[d].buff.buffer,C,o).set(y),n.pages[d].dirty=!0,n.pages[d].pendingOps--,n.pages[d].size=Math.max(C+o,n.pages[d].size),d>=n.totalPages&&(n.totalPages=d+1),l=l-o,d++,C=0,n.writing||setImmediate(n._triggerWrite.bind(n))}}async read(t,e){const n=this;let i=new Uint8Array(t);return await n.readToBuffer(i,0,t,e),i}async readToBuffer(t,e,n,i){if(n==0)return;const s=this;if(n>s.pageSize*s.maxPagesLoaded*.8){const E=Math.floor(n*1.1);this.maxPagesLoaded=Math.floor(E/s.pageSize)+1}if(typeof i>"u"&&(i=s.pos),s.pos=i+n,s.pendingClose)throw new Error("Reading a closing file");const g=Math.floor(i/s.pageSize),d=Math.floor((i+n-1)/s.pageSize),C=[];for(let E=g;E<=d;E++)C.push(s._loadPage(E));s._triggerLoad();let l=g,o=i%s.pageSize,y=i+n>s.totalSize?n-(i+n-s.totalSize):n;for(;y>0;){await C[l-g],s.__statusPage("After Await (read): ",l);const E=o+y>s.pageSize?s.pageSize-o:y,m=new Uint8Array(s.pages[l].buff.buffer,s.pages[l].buff.byteOffset+o,E);t.set(m,e+n-y),s.pages[l].pendingOps--,s.__statusPage("After Op done: ",l),y=y-E,l++,o=0,s.pendingLoads.length>0&&setImmediate(s._triggerLoad.bind(s))}this.pos=i+n}_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,n)=>{t.pendingClose=e,t.pendingCloseReject=n,t._tryClose()}).then(()=>{t.fd.close()},e=>{throw t.fd.close(),e})}async discard(){await this.close(),await se.fs.promises.unlink(this.fileName)}async writeULE32(t,e){const n=this,i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,t,!0),await n.write(i,e)}async writeUBE32(t,e){const n=this,i=new Uint8Array(4);new DataView(i.buffer).setUint32(0,t,!1),await n.write(i,e)}async writeULE64(t,e){const n=this,i=new Uint8Array(8),s=new DataView(i.buffer);s.setUint32(0,t&4294967295,!0),s.setUint32(4,Math.floor(t/4294967296),!0),await n.write(i,e)}async readULE32(t){const n=await this.read(4,t);return new Uint32Array(n.buffer)[0]}async readUBE32(t){const n=await this.read(4,t);return new DataView(n.buffer).getUint32(0,!1)}async readULE64(t){const n=await this.read(8,t),i=new Uint32Array(n.buffer);return i[1]*4294967296+i[0]}async readString(t){const e=this;if(e.pendingClose)throw new Error("Reading a closing file");let n=typeof t>"u"?e.pos:t,i=Math.floor(n/e.pageSize),s=!1,g="";for(;!s;){let d=e._loadPage(i);e._triggerLoad(),await d,e.__statusPage("After Await (read): ",i);let C=n%e.pageSize;const l=new Uint8Array(e.pages[i].buff.buffer,e.pages[i].buff.byteOffset+C,e.pageSize-C);let o=l.findIndex(y=>y===0);s=o!==-1,s?(g+=new TextDecoder().decode(l.slice(0,o)),e.pos=i*this.pageSize+C+o+1):(g+=new TextDecoder().decode(l),e.pos=i*this.pageSize+C+l.length),e.pages[i].pendingOps--,e.__statusPage("After Op done: ",i),n=e.pos,i++,e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e))}return g}}function Yo(c){const t=c.initialSize||1048576,e=new Xi;return e.o=c,e.o.data=new Uint8Array(t),e.allocSize=t,e.totalSize=0,e.readOnly=!1,e.pos=0,e}function tc(c){const t=new Xi;return t.o=c,t.allocSize=c.data.byteLength,t.totalSize=c.data.byteLength,t.readOnly=!0,t.pos=0,t}const vn=new Uint8Array(4),ii=new DataView(vn.buffer),Wi=new Uint8Array(8),ai=new DataView(Wi.buffer);class Xi{constructor(){this.pageSize=16384}_resizeIfNeeded(t){if(t>this.allocSize){const e=Math.max(this.allocSize+1048576,Math.floor(this.allocSize*1.1),t),n=new Uint8Array(e);n.set(this.o.data),this.o.data=n,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,n,i){if(typeof i>"u"&&(i=this.pos),this.readOnly&&i+n>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(i+n);const g=new Uint8Array(this.o.data.buffer,this.o.data.byteOffset+i,n);t.set(g,e),this.pos=i+n}async read(t,e){const n=this,i=new Uint8Array(t);return await n.readToBuffer(i,0,t,e),i}close(){this.o.data.byteLength!=this.totalSize&&(this.o.data=this.o.data.slice(0,this.totalSize))}async discard(){}async writeULE32(t,e){const n=this;ii.setUint32(0,t,!0),await n.write(vn,e)}async writeUBE32(t,e){const n=this;ii.setUint32(0,t,!1),await n.write(vn,e)}async writeULE64(t,e){const n=this;ai.setUint32(0,t&4294967295,!0),ai.setUint32(4,Math.floor(t/4294967296),!0),await n.write(Wi,e)}async readULE32(t){const n=await this.read(4,t);return new Uint32Array(n.buffer)[0]}async readUBE32(t){const n=await this.read(4,t);return new DataView(n.buffer).getUint32(0,!1)}async readULE64(t){const n=await this.read(8,t),i=new Uint32Array(n.buffer);return i[1]*4294967296+i[0]}async readString(t){const e=this;let n=typeof t>"u"?e.pos:t;if(n>this.totalSize){if(this.readOnly)throw new Error("Reading out of bounds");this._resizeIfNeeded(t)}const i=new Uint8Array(e.o.data.buffer,n,this.totalSize-n);let s=i.findIndex(C=>C===0),g=s!==-1,d="";return g?(d=new TextDecoder().decode(i.slice(0,s)),e.pos=n+s+1):e.pos=n,d}}const ne=1<<22;function ec(c){const t=c.initialSize||0,e=new Hi;e.o=c;const n=t?Math.floor((t-1)/ne)+1:0;e.o.data=[];for(let i=0;i<n-1;i++)e.o.data.push(new Uint8Array(ne));return n&&e.o.data.push(new Uint8Array(t-ne*(n-1))),e.totalSize=0,e.readOnly=!1,e.pos=0,e}function nc(c){const t=new Hi;return t.o=c,t.totalSize=(c.data.length-1)*ne+c.data[c.data.length-1].byteLength,t.readOnly=!0,t.pos=0,t}const xn=new Uint8Array(4),oi=new DataView(xn.buffer),Vi=new Uint8Array(8),ci=new DataView(Vi.buffer);class Hi{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)/ne)+1;for(let n=Math.max(this.o.data.length-1,0);n<e;n++){const i=n<e-1?ne:t-(e-1)*ne,s=new Uint8Array(i);n==this.o.data.length-1&&s.set(this.o.data[n]),this.o.data[n]=s}this.totalSize=t}async write(t,e){const n=this;if(typeof e>"u"&&(e=n.pos),this.readOnly)throw new Error("Writing a read only file");this._resizeIfNeeded(e+t.byteLength);let s=Math.floor(e/ne),g=e%ne,d=t.byteLength;for(;d>0;){const C=g+d>ne?ne-g:d,l=t.slice(t.byteLength-d,t.byteLength-d+C);new Uint8Array(n.o.data[s].buffer,g,C).set(l),d=d-C,s++,g=0}this.pos=e+t.byteLength}async readToBuffer(t,e,n,i){const s=this;if(typeof i>"u"&&(i=s.pos),this.readOnly&&i+n>this.totalSize)throw new Error("Reading out of bounds");this._resizeIfNeeded(i+n);let d=Math.floor(i/ne),C=i%ne,l=n;for(;l>0;){const o=C+l>ne?ne-C:l,y=new Uint8Array(s.o.data[d].buffer,C,o);t.set(y,e+n-l),l=l-o,d++,C=0}this.pos=i+n}async read(t,e){const n=this,i=new Uint8Array(t);return await n.readToBuffer(i,0,t,e),i}close(){}async discard(){}async writeULE32(t,e){const n=this;oi.setUint32(0,t,!0),await n.write(xn,e)}async writeUBE32(t,e){const n=this;oi.setUint32(0,t,!1),await n.write(xn,e)}async writeULE64(t,e){const n=this;ci.setUint32(0,t&4294967295,!0),ci.setUint32(4,Math.floor(t/4294967296),!0),await n.write(Vi,e)}async readULE32(t){const n=await this.read(4,t);return new Uint32Array(n.buffer)[0]}async readUBE32(t){const n=await this.read(4,t);return new DataView(n.buffer).getUint32(0,!1)}async readULE64(t){const n=await this.read(8,t),i=new Uint32Array(n.buffer);return i[1]*4294967296+i[0]}async readString(t){const e=this,n=2048;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)}let s=!1,g="";for(;!s;){let d=Math.floor(i/ne),C=i%ne;if(e.o.data[d]===void 0)throw new Error("ERROR");let l=Math.min(n,e.o.data[d].length-C);const o=new Uint8Array(e.o.data[d].buffer,C,l);let y=o.findIndex(E=>E===0);s=y!==-1,s?(g+=new TextDecoder().decode(o.slice(0,y)),e.pos=d*ne+C+y+1):(g+=new TextDecoder().decode(o),e.pos=d*ne+C+o.length),i=e.pos}return g}}const ic=1024,ac=512,oc=2,cc=0,Qi=65536,Ji=8192;async function Ki(c,t,e){if(typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:t||Qi,pageSize:e||Ji}),c.type=="file")return await Zi(c.fileName,ic|ac|oc,c.cacheSize,c.pageSize);if(c.type=="mem")return Yo(c);if(c.type=="bigMem")return ec(c);throw new Error("Invalid FastFile type: "+c.type)}async function Yi(c,t,e){if(c instanceof Uint8Array&&(c={type:"mem",data:c}),process.browser?typeof c=="string"&&(c={type:"mem",data:await fetch(c).then(function(i){return i.arrayBuffer()}).then(function(i){return new Uint8Array(i)})}):typeof c=="string"&&(c={type:"file",fileName:c,cacheSize:t||Qi,pageSize:e||Ji}),c.type=="file")return await Zi(c.fileName,cc,c.cacheSize,c.pageSize);if(c.type=="mem")return await tc(c);if(c.type=="bigMem")return await nc(c);throw new Error("Invalid FastFile type: "+c.type)}async function si(c,t,e,n,i){const s=await Yi(c,n,i),g=await s.read(4);let d="";for(let y=0;y<4;y++)d+=String.fromCharCode(g[y]);if(d!=t)throw new Error(c+": Invalid File format");if(await s.readULE32()>e)throw new Error("Version not supported");const l=await s.readULE32();let o=[];for(let y=0;y<l;y++){let E=await s.readULE32(),m=await s.readULE64();typeof o[E]>"u"&&(o[E]=[]),o[E].push({p:s.pos,size:m}),s.pos+=m}return{fd:s,sections:o}}async function sc(c,t,e,n,i,s){const g=await Ki(c,i,s),d=new Uint8Array(4);for(let C=0;C<4;C++)d[C]=t.charCodeAt(C);return await g.write(d,0),await g.writeULE32(e),await g.writeULE32(n),g}async function ri(c,t){if(typeof c.writingSection<"u")throw new Error("Already writing a section");await c.writeULE32(t),c.writingSection={pSectionSize:c.pos},await c.writeULE64(0)}async function li(c){if(typeof c.writingSection>"u")throw new Error("Not writing a section");const t=c.pos-c.writingSection.pSectionSize-8,e=c.pos;c.pos=c.writingSection.pSectionSize,await c.writeULE64(t),c.pos=e,delete c.writingSection}async function Ze(c,t,e){if(typeof c.readingSection<"u")throw new Error("Already reading a section");if(!t[e])throw new Error(c.fileName+": Missing section "+e);if(t[e].length>1)throw new Error(c.fileName+": Section Duplicated "+e);c.pos=t[e][0].p,c.readingSection=t[e][0]}async function We(c,t){if(typeof c.readingSection>"u")throw new Error("Not reading a section");if(!t&&c.pos-c.readingSection.p!=c.readingSection.size)throw new Error("Invalid section size reading");delete c.readingSection}async function rc(c,t,e,n){const i=new Uint8Array(e);Gi.toRprLE(i,0,t,e),await c.write(i,n)}async function Be(c,t,e){const n=await c.read(t,e);return Gi.fromRprLE(n,0,t)}async function Fe(c,t,e,n,i){if(n=typeof n>"u"?0:n,i=typeof i>"u"?t[e][0].size-n:i,n+i>t[e][0].size)throw new Error("Reading out of the range of the section");let s;return i<1<<30?s=new Uint8Array(i):s=new Qo(i),await c.readToBuffer(s,0,i,t[e][0].p+n),s}const lc=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function cn(c,t){if(!t||t==10)return BigInt(c);if(t==16)return c.slice(0,2)=="0x"?BigInt(c):BigInt("0x"+c)}const ee=cn;function uc(c,t){let e=BigInt(0);t=BigInt(t);for(let n=0;n<c.length;n++)e=e*t+BigInt(c[n]);return e}function Xe(c){const t=c.toString(16);return(t.length-1)*4+lc[parseInt(t[0],16)]}function ta(c){return BigInt(c)<BigInt(0)}function ea(c){return!c}function tn(c,t){return BigInt(c)<<BigInt(t)}function Se(c,t){return BigInt(c)>>BigInt(t)}const dc=tn,fc=Se;function Nn(c){return(BigInt(c)&BigInt(1))==BigInt(1)}function _c(c){let t=BigInt(c);const e=[];for(;t;){if(t&BigInt(1)){const n=2-Number(t%BigInt(4));e.push(n),t=t-BigInt(n)}else e.push(0);t=t>>BigInt(1)}return e}function na(c){let t=BigInt(c);const e=[];for(;t;)t&BigInt(1)?e.push(1):e.push(0),t=t>>BigInt(1);return e}function ia(c){if(c>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(c)}function gc(c,t){const e=[];let n=BigInt(c);for(t=BigInt(t);n;)e.unshift(Number(n%t)),n=n/t;return e}function zn(c,t){return BigInt(c)+BigInt(t)}function Le(c,t){return BigInt(c)-BigInt(t)}function aa(c){return-BigInt(c)}function oa(c,t){return BigInt(c)*BigInt(t)}function pc(c){return BigInt(c)*BigInt(c)}function Ve(c,t){return BigInt(c)**BigInt(t)}function hc(c,t){return BigInt(c)**BigInt(t)}function Lc(c){return BigInt(c)>=0?BigInt(c):-BigInt(c)}function Ie(c,t){return BigInt(c)/BigInt(t)}function ge(c,t){return BigInt(c)%BigInt(t)}function Ee(c,t){return BigInt(c)==BigInt(t)}function mc(c,t){return BigInt(c)!=BigInt(t)}function bc(c,t){return BigInt(c)<BigInt(t)}function Sn(c,t){return BigInt(c)>BigInt(t)}function yc(c,t){return BigInt(c)<=BigInt(t)}function ca(c,t){return BigInt(c)>=BigInt(t)}function Un(c,t){return BigInt(c)&BigInt(t)}function Cc(c,t){return BigInt(c)|BigInt(t)}function Ac(c,t){return BigInt(c)^BigInt(t)}function Fc(c,t){return BigInt(c)&&BigInt(t)}function Ec(c,t){return BigInt(c)||BigInt(t)}function wc(c){return!BigInt(c)}function $e(c,t,e,n){const i="0000000"+e.toString(16),s=new Uint32Array(c.buffer,t,n/4),g=((i.length-7)*4-1>>5)+1;for(let d=0;d<g;d++)s[d]=parseInt(i.substring(i.length-8*d-8,i.length-8*d),16);for(let d=g;d<s.length;d++)s[d]=0;for(let d=s.length*4;d<n;d++)c[d]=ia(Un(Se(e,d*8),255))}function sa(c,t,e,n){const i="0000000"+e.toString(16),s=new DataView(c.buffer,c.byteOffset+t,n),g=((i.length-7)*4-1>>5)+1;for(let d=0;d<g;d++)s.setUint32(n-d*4-4,parseInt(i.substring(i.length-8*d-8,i.length-8*d),16),!1);for(let d=0;d<n/4-g;d++)s[d]=0}function Ge(c,t,e){e=e||c.byteLength,t=t||0;const n=new Uint32Array(c.buffer,t,e/4),i=new Array(e/4);return n.forEach((s,g)=>i[i.length-g-1]=s.toString(16).padStart(8,"0")),cn(i.join(""),16)}function ra(c,t,e){e=e||c.byteLength,t=t||0;const n=new DataView(c.buffer,c.byteOffset+t,e),i=new Array(e/4);for(let s=0;s<e/4;s++)i[s]=n.getUint32(s*4,!1).toString(16).padStart(8,"0");return cn(i.join(""),16)}function la(c,t){return c.toString(t)}function Oe(c){const t=new Uint8Array(Math.floor((Xe(c)-1)/8)+1);return $e(t,0,c,t.byteLength),t}const ua=ee(0),we=ee(1),Bc=Object.freeze(Object.defineProperty({__proto__:null,abs:Lc,add:zn,band:Un,bitLength:Xe,bits:na,bor:Cc,bxor:Ac,div:Ie,e:ee,eq:Ee,exp:hc,fromArray:uc,fromRprBE:ra,fromRprLE:Ge,fromString:cn,geq:ca,gt:Sn,isNegative:ta,isOdd:Nn,isZero:ea,land:Fc,leq:yc,lnot:wc,lor:Ec,lt:bc,mod:ge,mul:oa,naf:_c,neg:aa,neq:mc,one:we,pow:Ve,shiftLeft:tn,shiftRight:Se,shl:dc,shr:fc,square:pc,sub:Le,toArray:gc,toLEBuff:Oe,toNumber:ia,toRprBE:sa,toRprLE:$e,toString:la,zero:ua},Symbol.toStringTag,{value:"Module"}));function ui(c,t,e){if(ea(e))return c.one;const n=na(e);if(n.length==0)return c.one;let i=t;for(let s=n.length-2;s>=0;s--)i=c.square(i),n[s]&&(i=c.mul(i,t));return i}function vc(c){if(c.m%2==1)if(Ee(ge(c.p,4),1))if(Ee(ge(c.p,8),1))if(Ee(ge(c.p,16),1))xc(c);else if(Ee(ge(c.p,16),9))Sc(c);else throw new Error("Field withot sqrt");else if(Ee(ge(c.p,8),5))Ic(c);else throw new Error("Field withot sqrt");else Ee(ge(c.p,4),3)&&Oc(c);else{const t=ge(Ve(c.p,c.m/2),4);t==1?Pc(c):t==3?kc(c):Tc(c)}}function xc(c){for(c.sqrt_q=Ve(c.p,c.m),c.sqrt_s=0,c.sqrt_t=Le(c.sqrt_q,1);!Nn(c.sqrt_t);)c.sqrt_s=c.sqrt_s+1,c.sqrt_t=Ie(c.sqrt_t,2);let t=c.one;for(;c.eq(t,c.one);){const e=c.random();c.sqrt_z=c.pow(e,c.sqrt_t),t=c.pow(c.sqrt_z,2**(c.sqrt_s-1))}c.sqrt_tm1d2=Ie(Le(c.sqrt_t,1),2),c.sqrt=function(e){const n=this;if(n.isZero(e))return n.zero;let i=n.pow(e,n.sqrt_tm1d2);const s=n.pow(n.mul(n.square(i),e),2**(n.sqrt_s-1));if(n.eq(s,n.negone))return null;let g=n.sqrt_s,d=n.mul(e,i),C=n.mul(d,i),l=n.sqrt_z;for(;!n.eq(C,n.one);){let o=n.square(C),y=1;for(;!n.eq(o,n.one);)o=n.square(o),y++;i=l;for(let E=0;E<g-y-1;E++)i=n.square(i);l=n.square(i),C=n.mul(C,l),d=n.mul(d,i),g=y}return n.geq(d,n.zero)?d:n.neg(d)}}function Sc(c){c.sqrt=function(){throw new Error("Sqrt alg 4 not implemented")}}function Ic(c){c.sqrt=function(){throw new Error("Sqrt alg 3 not implemented")}}function Oc(c){c.sqrt_q=Ve(c.p,c.m),c.sqrt_e1=Ie(Le(c.sqrt_q,3),4),c.sqrt=function(t){if(this.isZero(t))return this.zero;const e=this.pow(t,this.sqrt_e1),n=this.mul(this.square(e),t);if(this.eq(n,this.negone))return null;const i=this.mul(e,t);return c.geq(i,c.zero)?i:c.neg(i)}}function Pc(c){c.sqrt=function(){throw new Error("Sqrt alg 10 not implemented")}}function kc(c){c.sqrt_q=Ve(c.p,c.m/2),c.sqrt_e34=Ie(Le(c.sqrt_q,3),4),c.sqrt_e12=Ie(Le(c.sqrt_q,1),2),c.frobenius=function(t,e){return t%2==1?c.conjugate(e):e},c.sqrt=function(t){const e=this,n=e.pow(t,e.sqrt_e34),i=e.mul(e.square(n),t),s=e.mul(e.frobenius(1,i),i);if(e.eq(s,e.negone))return null;const g=e.mul(n,t);let d;if(e.eq(i,e.negone))d=e.mul(g,[e.F.zero,e.F.one]);else{const C=e.pow(e.add(e.one,i),e.sqrt_e12);d=e.mul(C,g)}return e.geq(d,e.zero)?d:e.neg(d)}}function Tc(c){c.sqrt=function(){throw new Error("Sqrt alg 8 not implemented")}}function me(c,t,e,n,i){c[t]=c[t]+c[e]>>>0,c[i]=(c[i]^c[t])>>>0,c[i]=(c[i]<<16|c[i]>>>16&65535)>>>0,c[n]=c[n]+c[i]>>>0,c[e]=(c[e]^c[n])>>>0,c[e]=(c[e]<<12|c[e]>>>20&4095)>>>0,c[t]=c[t]+c[e]>>>0,c[i]=(c[i]^c[t])>>>0,c[i]=(c[i]<<8|c[i]>>>24&255)>>>0,c[n]=c[n]+c[i]>>>0,c[e]=(c[e]^c[n])>>>0,c[e]=(c[e]<<7|c[e]>>>25&127)>>>0}function qc(c){me(c,0,4,8,12),me(c,1,5,9,13),me(c,2,6,10,14),me(c,3,7,11,15),me(c,0,5,10,15),me(c,1,6,11,12),me(c,2,7,8,13),me(c,3,4,9,14)}class Mc{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 zn(oa(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++)qc(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 da(c){let t=new Uint8Array(c);if(process.browser)if(typeof globalThis.crypto<"u")globalThis.crypto.getRandomValues(t);else for(let e=0;e<c;e++)t[e]=Math.random()*4294967296>>>0;else se.fs.randomFillSync(t);return t}function Dc(){const c=da(32),t=new Uint32Array(c.buffer),e=[];for(let n=0;n<8;n++)e.push(t[n]);return e}let Je=null;function jn(){return Je||(Je=new Mc(Dc()),Je)}class Rc{constructor(t,e,n){this.F=e,this.G=t,this.opMulGF=n;let i=e.sqrt_t||e.t,s=e.sqrt_s||e.s,g=e.one;for(;e.eq(e.pow(g,e.half),e.one);)g=e.add(g,e.one);this.w=new Array(s+1),this.wi=new Array(s+1),this.w[s]=this.F.pow(g,i),this.wi[s]=this.F.inv(this.w[s]);let d=s-1;for(;d>=0;)this.w[d]=this.F.square(this.w[d+1]),this.wi[d]=this.F.square(this.wi[d+1]),d--;this.roots=[],this._setRoots(Math.min(s,15))}_setRoots(t){for(let e=t;e>=0&&!this.roots[e];e--){let n=this.F.one;const i=1<<e,s=new Array(i);for(let g=0;g<i;g++)s[g]=n,n=this.F.mul(n,this.w[e]);this.roots[e]=s}}fft(t){if(t.length<=1)return t;const e=di(t.length-1)+1;this._setRoots(e);const n=1<<e;if(t.length!=n)throw new Error("Size must be multiple of 2");return en(this,t,e,0,1)}ifft(t){if(t.length<=1)return t;const e=di(t.length-1)+1;this._setRoots(e);const n=1<<e;if(t.length!=n)throw new Error("Size must be multiple of 2");const i=en(this,t,e,0,1),s=this.F.inv(this.F.mulScalar(this.F.one,n)),g=new Array(n);for(let d=0;d<n;d++)g[d]=this.opMulGF(i[(n-d)%n],s);return g}}function di(c){return(c&4294901760?(c&=4294901760,16):0)|(c&4278255360?(c&=4278255360,8):0)|(c&4042322160?(c&=4042322160,4):0)|(c&3435973836?(c&=3435973836,2):0)|(c&2863311530)!==0}function en(c,t,e,n,i){const s=1<<e;if(s==1)return[t[n]];if(s==2)return[c.G.add(t[n],t[n+i]),c.G.sub(t[n],t[n+i])];const g=s>>1,d=en(c,t,e-1,n,i*2),C=en(c,t,e-1,n+i,i*2),l=new Array(s);for(let o=0;o<g;o++)l[o]=c.G.add(d[o],c.opMulGF(C[o],c.roots[e][o])),l[o+g]=c.G.sub(d[o],c.opMulGF(C[o],c.roots[e][o]));return l}class Nc{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=Xe(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 n=this.pow(this.nqr,e);for(;!this.eq(n,this.negone);)this.nqr=this.nqr+this.one,n=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),vc(this),this.FFT=new Rc(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 n;if(e?e==16&&(n=BigInt("0x"+t)):n=BigInt(t),n<0){let i=-n;return i>=this.p&&(i=i%this.p),this.p-i}else return n>=this.p?n%this.p:n}add(t,e){const n=t+e;return n>=this.p?n-this.p:n}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 n=t>this.half?t-this.p:t,i=e>this.half?e-this.p:e;return n<i}gt(t,e){const n=t>this.half?t-this.p:t,i=e>this.half?e-this.p:e;return n>i}leq(t,e){const n=t>this.half?t-this.p:t,i=e>this.half?e-this.p:e;return n<=i}geq(t,e){const n=t>this.half?t-this.p:t,i=e>this.half?e-this.p:e;return n>=i}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,n=this.p,i=this.one,s=t%this.p;for(;s;){let g=n/s;[e,i]=[i,e-g*i],[n,s]=[s,n-g*s]}return e<this.zero&&(e+=this.p),e}mod(t,e){return t%e}pow(t,e){return ui(this,t,e)}exp(t,e){return ui(this,t,e)}band(t,e){const n=t&e&this.mask;return n>=this.p?n-this.p:n}bor(t,e){const n=(t|e)&this.mask;return n>=this.p?n-this.p:n}bxor(t,e){const n=(t^e)&this.mask;return n>=this.p?n-this.p:n}bnot(t){const e=t^this.mask;return e>=this.p?e-this.p:e}shl(t,e){if(Number(e)<this.bitLength){const n=t<<e&this.mask;return n>=this.p?n-this.p:n}else{const n=this.p-e;return Number(n)<this.bitLength?t>>n:this.zero}}shr(t,e){if(Number(e)<this.bitLength)return t>>e;{const n=this.p-e;if(Number(n)<this.bitLength){const i=t<<n&this.mask;return i>=this.p?i-this.p:i}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 n=this.s,i=this.nqr_to_t,s=this.pow(t,this.t),g=this.pow(t,this.add(this.t,this.one)>>this.one);for(;s!=this.one;){let d=this.square(s),C=1;for(;d!=this.one;)C++,d=this.square(d);let l=i;for(let o=0;o<n-C-1;o++)l=this.square(l);n=C,i=this.square(l),s=this.mul(s,i),g=this.mul(g,l)}return g>this.p>>this.one&&(g=this.neg(g)),g}normalize(t,e){if(t=BigInt(t,e),t<0){let n=-t;return n>=this.p&&(n=n%this.p),this.p-n}else return t>=this.p?t%this.p:t}random(){const t=this.bitLength*2/8;let e=this.zero;for(let n=0;n<t;n++)e=(e<<BigInt(8))+BigInt(da(1)[0]);return e%this.p}toString(t,e){e=e||10;let n;return t>this.half&&e==10?n="-"+(this.p-t).toString(e):n=t.toString(e),n}isZero(t){return t==this.zero}fromRng(t){let e;do{e=this.zero;for(let n=0;n<this.n64;n++)e+=t.nextU64()<<BigInt(64*n);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,n){$e(t,e,n,this.n64*8)}toRprBE(t,e,n){sa(t,e,n,this.n64*8)}toRprBEM(t,e,n){return this.toRprBE(t,e,this.mul(this.R,n))}toRprLEM(t,e,n){return this.toRprLE(t,e,this.mul(this.R,n))}fromRprLE(t,e){return Ge(t,e,this.n8)}fromRprBE(t,e){return ra(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 ye={};ye.bigInt2BytesLE=function(t,e){const n=Array(e);let i=BigInt(t);for(let s=0;s<e;s++)n[s]=Number(i&0xFFn),i=i>>8n;return n};ye.bigInt2U32LE=function(t,e){const n=Array(e);let i=BigInt(t);for(let s=0;s<e;s++)n[s]=Number(i&0xFFFFFFFFn),i=i>>32n;return n};ye.isOcamNum=function(c){return!(!Array.isArray(c)||c.length!=3||typeof c[0]!="number"||typeof c[1]!="number"||!Array.isArray(c[2]))};var zc=function(t,e,n){const i=n||"int";if(t.modules[i])return i;t.modules[i]={};const s=e*2,g=e*8;function d(){const F=t.addFunction(i+"_copy");F.addParam("px","i32"),F.addParam("pr","i32");const r=F.getCodeBuilder();for(let h=0;h<e;h++)F.addCode(r.i64_store(r.getLocal("pr"),h*8,r.i64_load(r.getLocal("px"),h*8)))}function C(){const F=t.addFunction(i+"_zero");F.addParam("pr","i32");const r=F.getCodeBuilder();for(let h=0;h<e;h++)F.addCode(r.i64_store(r.getLocal("pr"),h*8,r.i64_const(0)))}function l(){const F=t.addFunction(i+"_one");F.addParam("pr","i32");const r=F.getCodeBuilder();F.addCode(r.i64_store(r.getLocal("pr"),0,r.i64_const(1)));for(let h=1;h<e;h++)F.addCode(r.i64_store(r.getLocal("pr"),h*8,r.i64_const(0)))}function o(){const F=t.addFunction(i+"_isZero");F.addParam("px","i32"),F.setReturnType("i32");const r=F.getCodeBuilder();function h(R){return R==0?r.ret(r.i64_eqz(r.i64_load(r.getLocal("px")))):r.if(r.i64_eqz(r.i64_load(r.getLocal("px"),R*8)),h(R-1),r.ret(r.i32_const(0)))}F.addCode(h(e-1)),F.addCode(r.ret(r.i32_const(0)))}function y(){const F=t.addFunction(i+"_eq");F.addParam("px","i32"),F.addParam("py","i32"),F.setReturnType("i32");const r=F.getCodeBuilder();function h(R){return R==0?r.ret(r.i64_eq(r.i64_load(r.getLocal("px")),r.i64_load(r.getLocal("py")))):r.if(r.i64_eq(r.i64_load(r.getLocal("px"),R*8),r.i64_load(r.getLocal("py"),R*8)),h(R-1),r.ret(r.i32_const(0)))}F.addCode(h(e-1)),F.addCode(r.ret(r.i32_const(0)))}function E(){const F=t.addFunction(i+"_gte");F.addParam("px","i32"),F.addParam("py","i32"),F.setReturnType("i32");const r=F.getCodeBuilder();function h(R){return R==0?r.ret(r.i64_ge_u(r.i64_load(r.getLocal("px")),r.i64_load(r.getLocal("py")))):r.if(r.i64_lt_u(r.i64_load(r.getLocal("px"),R*8),r.i64_load(r.getLocal("py"),R*8)),r.ret(r.i32_const(0)),r.if(r.i64_gt_u(r.i64_load(r.getLocal("px"),R*8),r.i64_load(r.getLocal("py"),R*8)),r.ret(r.i32_const(1)),h(R-1)))}F.addCode(h(e-1)),F.addCode(r.ret(r.i32_const(0)))}function m(){const F=t.addFunction(i+"_add");F.addParam("x","i32"),F.addParam("y","i32"),F.addParam("r","i32"),F.setReturnType("i32"),F.addLocal("c","i64");const r=F.getCodeBuilder();F.addCode(r.setLocal("c",r.i64_add(r.i64_load32_u(r.getLocal("x")),r.i64_load32_u(r.getLocal("y"))))),F.addCode(r.i64_store32(r.getLocal("r"),r.getLocal("c")));for(let h=1;h<s;h++)F.addCode(r.setLocal("c",r.i64_add(r.i64_add(r.i64_load32_u(r.getLocal("x"),4*h),r.i64_load32_u(r.getLocal("y"),4*h)),r.i64_shr_u(r.getLocal("c"),r.i64_const(32))))),F.addCode(r.i64_store32(r.getLocal("r"),h*4,r.getLocal("c")));F.addCode(r.i32_wrap_i64(r.i64_shr_u(r.getLocal("c"),r.i64_const(32))))}function x(){const F=t.addFunction(i+"_sub");F.addParam("x","i32"),F.addParam("y","i32"),F.addParam("r","i32"),F.setReturnType("i32"),F.addLocal("c","i64");const r=F.getCodeBuilder();F.addCode(r.setLocal("c",r.i64_sub(r.i64_load32_u(r.getLocal("x")),r.i64_load32_u(r.getLocal("y"))))),F.addCode(r.i64_store32(r.getLocal("r"),r.i64_and(r.getLocal("c"),r.i64_const("0xFFFFFFFF"))));for(let h=1;h<s;h++)F.addCode(r.setLocal("c",r.i64_add(r.i64_sub(r.i64_load32_u(r.getLocal("x"),4*h),r.i64_load32_u(r.getLocal("y"),4*h)),r.i64_shr_s(r.getLocal("c"),r.i64_const(32))))),F.addCode(r.i64_store32(r.getLocal("r"),h*4,r.i64_and(r.getLocal("c"),r.i64_const("0xFFFFFFFF"))));F.addCode(r.i32_wrap_i64(r.i64_shr_s(r.getLocal("c"),r.i64_const(32))))}function O(){const F=t.addFunction(i+"_mul");F.addParam("x","i32"),F.addParam("y","i32"),F.addParam("r","i32"),F.addLocal("c0","i64"),F.addLocal("c1","i64");for(let A=0;A<s;A++)F.addLocal("x"+A,"i64"),F.addLocal("y"+A,"i64");const r=F.getCodeBuilder(),h=[],R=[];function j(A,D){let H,ut;return h[A]?H=r.getLocal("x"+A):(H=r.teeLocal("x"+A,r.i64_load32_u(r.getLocal("x"),A*4)),h[A]=!0),R[D]?ut=r.getLocal("y"+D):(ut=r.teeLocal("y"+D,r.i64_load32_u(r.getLocal("y"),D*4)),R[D]=!0),r.i64_mul(H,ut)}let T="c0",M="c1";for(let A=0;A<s*2-1;A++){for(let D=Math.max(0,A-s+1);D<=A&&D<s;D++){const H=A-D;F.addCode(r.setLocal(T,r.i64_add(r.i64_and(r.getLocal(T),r.i64_const(4294967295)),j(D,H)))),F.addCode(r.setLocal(M,r.i64_add(r.getLocal(M),r.i64_shr_u(r.getLocal(T),r.i64_const(32)))))}F.addCode(r.i64_store32(r.getLocal("r"),A*4,r.getLocal(T))),[T,M]=[M,T],F.addCode(r.setLocal(M,r.i64_shr_u(r.getLocal(T),r.i64_const(32))))}F.addCode(r.i64_store32(r.getLocal("r"),s*4*2-4,r.getLocal(T)))}function L(){const F=t.addFunction(i+"_square");F.addParam("x","i32"),F.addParam("r","i32"),F.addLocal("c0","i64"),F.addLocal("c1","i64"),F.addLocal("c0_old","i64"),F.addLocal("c1_old","i64");for(let D=0;D<s;D++)F.addLocal("x"+D,"i64");const r=F.getCodeBuilder(),h=[];function R(D,H){let ut,nt;return h[D]?ut=r.getLocal("x"+D):(ut=r.teeLocal("x"+D,r.i64_load32_u(r.getLocal("x"),D*4)),h[D]=!0),h[H]?nt=r.getLocal("x"+H):(nt=r.teeLocal("x"+H,r.i64_load32_u(r.getLocal("x"),H*4)),h[H]=!0),r.i64_mul(ut,nt)}let j="c0",T="c1",M="c0_old",A="c1_old";for(let D=0;D<s*2-1;D++){F.addCode(r.setLocal(j,r.i64_const(0)),r.setLocal(T,r.i64_const(0)));for(let H=Math.max(0,D-s+1);H<D+1>>1&&H<s;H++){const ut=D-H;F.addCode(r.setLocal(j,r.i64_add(r.i64_and(r.getLocal(j),r.i64_const(4294967295)),R(H,ut)))),F.addCode(r.setLocal(T,r.i64_add(r.getLocal(T),r.i64_shr_u(r.getLocal(j),r.i64_const(32)))))}F.addCode(r.setLocal(j,r.i64_shl(r.i64_and(r.getLocal(j),r.i64_const(4294967295)),r.i64_const(1)))),F.addCode(r.setLocal(T,r.i64_add(r.i64_shl(r.getLocal(T),r.i64_const(1)),r.i64_shr_u(r.getLocal(j),r.i64_const(32))))),D%2==0&&(F.addCode(r.setLocal(j,r.i64_add(r.i64_and(r.getLocal(j),r.i64_const(4294967295)),R(D>>1,D>>1)))),F.addCode(r.setLocal(T,r.i64_add(r.getLocal(T),r.i64_shr_u(r.getLocal(j),r.i64_const(32)))))),D>0&&(F.addCode(r.setLocal(j,r.i64_add(r.i64_and(r.getLocal(j),r.i64_const(4294967295)),r.i64_and(r.getLocal(M),r.i64_const(4294967295))))),F.addCode(r.setLocal(T,r.i64_add(r.i64_add(r.getLocal(T),r.i64_shr_u(r.getLocal(j),r.i64_const(32))),r.getLocal(A))))),F.addCode(r.i64_store32(r.getLocal("r"),D*4,r.getLocal(j))),F.addCode(r.setLocal(M,r.getLocal(T)),r.setLocal(A,r.i64_shr_u(r.getLocal(M),r.i64_const(32))))}F.addCode(r.i64_store32(r.getLocal("r"),s*4*2-4,r.getLocal(M)))}function I(){const F=t.addFunction(i+"_squareOld");F.addParam("x","i32"),F.addParam("r","i32");const r=F.getCodeBuilder();F.addCode(r.call(i+"_mul",r.getLocal("x"),r.getLocal("x"),r.getLocal("r")))}function v(){const F=t.addFunction(i+"__mul1");F.addParam("px","i32"),F.addParam("y","i64"),F.addParam("pr","i32"),F.addLocal("c","i64");const r=F.getCodeBuilder();F.addCode(r.setLocal("c",r.i64_mul(r.i64_load32_u(r.getLocal("px"),0,0),r.getLocal("y")))),F.addCode(r.i64_store32(r.getLocal("pr"),0,0,r.getLocal("c")));for(let h=1;h<s;h++)F.addCode(r.setLocal("c",r.i64_add(r.i64_mul(r.i64_load32_u(r.getLocal("px"),4*h,0),r.getLocal("y")),r.i64_shr_u(r.getLocal("c"),r.i64_const(32))))),F.addCode(r.i64_store32(r.getLocal("pr"),h*4,0,r.getLocal("c")))}function U(){const F=t.addFunction(i+"__add1");F.addParam("x","i32"),F.addParam("y","i64"),F.addLocal("c","i64"),F.addLocal("px","i32");const r=F.getCodeBuilder();F.addCode(r.setLocal("px",r.getLocal("x"))),F.addCode(r.setLocal("c",r.i64_add(r.i64_load32_u(r.getLocal("px"),0,0),r.getLocal("y")))),F.addCode(r.i64_store32(r.getLocal("px"),0,0,r.getLocal("c"))),F.addCode(r.setLocal("c",r.i64_shr_u(r.getLocal("c"),r.i64_const(32)))),F.addCode(r.block(r.loop(r.br_if(1,r.i64_eqz(r.getLocal("c"))),r.setLocal("px",r.i32_add(r.getLocal("px"),r.i32_const(4))),r.setLocal("c",r.i64_add(r.i64_load32_u(r.getLocal("px"),0,0),r.getLocal("c"))),r.i64_store32(r.getLocal("px"),0,0,r.getLocal("c")),r.setLocal("c",r.i64_shr_u(r.getLocal("c"),r.i64_const(32))),r.br(0))))}function w(){v(),U();const F=t.addFunction(i+"_div");F.addParam("x","i32"),F.addParam("y","i32"),F.addParam("c","i32"),F.addParam("r","i32"),F.addLocal("rr","i32"),F.addLocal("cc","i32"),F.addLocal("eX","i32"),F.addLocal("eY","i32"),F.addLocal("sy","i64"),F.addLocal("sx","i64"),F.addLocal("ec","i32");const r=F.getCodeBuilder(),h=r.i32_const(t.alloc(g)),R=r.i32_const(t.alloc(g)),j=r.i32_const(t.alloc(g)),T=r.getLocal("cc"),M=r.getLocal("rr"),A=t.alloc(g*2),D=r.i32_const(A),H=r.i32_const(A+g);F.addCode(r.if(r.getLocal("c"),r.setLocal("cc",r.getLocal("c")),r.setLocal("cc",R))),F.addCode(r.if(r.getLocal("r"),r.setLocal("rr",r.getLocal("r")),r.setLocal("rr",j))),F.addCode(r.call(i+"_copy",r.getLocal("x"),M)),F.addCode(r.call(i+"_copy",r.getLocal("y"),h)),F.addCode(r.call(i+"_zero",T)),F.addCode(r.call(i+"_zero",D)),F.addCode(r.setLocal("eX",r.i32_const(g-1))),F.addCode(r.setLocal("eY",r.i32_const(g-1))),F.addCode(r.block(r.loop(r.br_if(1,r.i32_or(r.i32_load8_u(r.i32_add(h,r.getLocal("eY")),0,0),r.i32_eq(r.getLocal("eY"),r.i32_const(3)))),r.setLocal("eY",r.i32_sub(r.getLocal("eY"),r.i32_const(1))),r.br(0)))),F.addCode(r.setLocal("sy",r.i64_add(r.i64_load32_u(r.i32_sub(r.i32_add(h,r.getLocal("eY")),r.i32_const(3)),0,0),r.i64_const(1)))),F.addCode(r.if(r.i64_eq(r.getLocal("sy"),r.i64_const(1)),r.drop(r.i64_div_u(r.i64_const(0),r.i64_const(0))))),F.addCode(r.block(r.loop(r.block(r.loop(r.br_if(1,r.i32_or(r.i32_load8_u(r.i32_add(M,r.getLocal("eX")),0,0),r.i32_eq(r.getLocal("eX"),r.i32_const(7)))),r.setLocal("eX",r.i32_sub(r.getLocal("eX"),r.i32_const(1))),r.br(0))),r.setLocal("sx",r.i64_load(r.i32_sub(r.i32_add(M,r.getLocal("eX")),r.i32_const(7)),0,0)),r.setLocal("sx",r.i64_div_u(r.getLocal("sx"),r.getLocal("sy"))),r.setLocal("ec",r.i32_sub(r.i32_sub(r.getLocal("eX"),r.getLocal("eY")),r.i32_const(4))),r.block(r.loop(r.br_if(1,r.i32_and(r.i64_eqz(r.i64_and(r.getLocal("sx"),r.i64_const("0xFFFFFFFF00000000"))),r.i32_ge_s(r.getLocal("ec"),r.i32_const(0)))),r.setLocal("sx",r.i64_shr_u(r.getLocal("sx"),r.i64_const(8))),r.setLocal("ec",r.i32_add(r.getLocal("ec"),r.i32_const(1))),r.br(0))),r.if(r.i64_eqz(r.getLocal("sx")),[...r.br_if(2,r.i32_eqz(r.call(i+"_gte",M,h))),...r.setLocal("sx",r.i64_const(1)),...r.setLocal("ec",r.i32_const(0))]),r.call(i+"__mul1",h,r.getLocal("sx"),H),r.drop(r.call(i+"_sub",M,r.i32_sub(H,r.getLocal("ec")),M)),r.call(i+"__add1",r.i32_add(T,r.getLocal("ec")),r.getLocal("sx")),r.br(0))))}function S(){const F=t.addFunction(i+"_inverseMod");F.addParam("px","i32"),F.addParam("pm","i32"),F.addParam("pr","i32"),F.addLocal("t","i32"),F.addLocal("newt","i32"),F.addLocal("r","i32"),F.addLocal("qq","i32"),F.addLocal("qr","i32"),F.addLocal("newr","i32"),F.addLocal("swp","i32"),F.addLocal("x","i32"),F.addLocal("signt","i32"),F.addLocal("signnewt","i32"),F.addLocal("signx","i32");const r=F.getCodeBuilder(),h=r.i32_const(t.alloc(g)),R=r.i32_const(t.alloc(g)),j=r.i32_const(t.alloc(g)),T=r.i32_const(t.alloc(g)),M=r.i32_const(t.alloc(g)),A=r.i32_const(t.alloc(g)),D=r.i32_const(t.alloc(g*2)),H=r.i32_const(t.alloc(g));F.addCode(r.setLocal("t",h),r.call(i+"_zero",h),r.setLocal("signt",r.i32_const(0))),F.addCode(r.setLocal("r",R),r.call(i+"_copy",r.getLocal("pm"),R)),F.addCode(r.setLocal("newt",j),r.call(i+"_one",j),r.setLocal("signnewt",r.i32_const(0))),F.addCode(r.setLocal("newr",T),r.call(i+"_copy",r.getLocal("px"),T)),F.addCode(r.setLocal("qq",M)),F.addCode(r.setLocal("qr",A)),F.addCode(r.setLocal("x",H)),F.addCode(r.block(r.loop(r.br_if(1,r.call(i+"_isZero",r.getLocal("newr"))),r.call(i+"_div",r.getLocal("r"),r.getLocal("newr"),r.getLocal("qq"),r.getLocal("qr")),r.call(i+"_mul",r.getLocal("qq"),r.getLocal("newt"),D),r.if(r.getLocal("signt"),r.if(r.getLocal("signnewt"),r.if(r.call(i+"_gte",D,r.getLocal("t")),[...r.drop(r.call(i+"_sub",D,r.getLocal("t"),r.getLocal("x"))),...r.setLocal("signx",r.i32_const(0))],[...r.drop(r.call(i+"_sub",r.getLocal("t"),D,r.getLocal("x"))),...r.setLocal("signx",r.i32_const(1))]),[...r.drop(r.call(i+"_add",D,r.getLocal("t"),r.getLocal("x"))),...r.setLocal("signx",r.i32_const(1))]),r.if(r.getLocal("signnewt"),[...r.drop(r.call(i+"_add",D,r.getLocal("t"),r.getLocal("x"))),...r.setLocal("signx",r.i32_const(0))],r.if(r.call(i+"_gte",r.getLocal("t"),D),[...r.drop(r.call(i+"_sub",r.getLocal("t"),D,r.getLocal("x"))),...r.setLocal("signx",r.i32_const(0))],[...r.drop(r.call(i+"_sub",D,r.getLocal("t"),r.getLocal("x"))),...r.setLocal("signx",r.i32_const(1))]))),r.setLocal("swp",r.getLocal("t")),r.setLocal("t",r.getLocal("newt")),r.setLocal("newt",r.getLocal("x")),r.setLocal("x",r.getLocal("swp")),r.setLocal("signt",r.getLocal("signnewt")),r.setLocal("signnewt",r.getLocal("signx")),r.setLocal("swp",r.getLocal("r")),r.setLocal("r",r.getLocal("newr")),r.setLocal("newr",r.getLocal("qr")),r.setLocal("qr",r.getLocal("swp")),r.br(0)))),F.addCode(r.if(r.getLocal("signt"),r.drop(r.call(i+"_sub",r.getLocal("pm"),r.getLocal("t"),r.getLocal("pr"))),r.call(i+"_copy",r.getLocal("t"),r.getLocal("pr"))))}return d(),C(),o(),l(),y(),E(),m(),x(),O(),L(),I(),w(),S(),t.exportFunction(i+"_copy"),t.exportFunction(i+"_zero"),t.exportFunction(i+"_one"),t.exportFunction(i+"_isZero"),t.exportFunction(i+"_eq"),t.exportFunction(i+"_gte"),t.exportFunction(i+"_add"),t.exportFunction(i+"_sub"),t.exportFunction(i+"_mul"),t.exportFunction(i+"_square"),t.exportFunction(i+"_squareOld"),t.exportFunction(i+"_div"),t.exportFunction(i+"_inverseMod"),i},$n=function(t,e,n,i,s,g,d){const C=t.addFunction(e);C.addParam("base","i32"),C.addParam("scalar","i32"),C.addParam("scalarLength","i32"),C.addParam("r","i32"),C.addLocal("i","i32"),C.addLocal("b","i32");const l=C.getCodeBuilder(),o=l.i32_const(t.alloc(n));C.addCode(l.if(l.i32_eqz(l.getLocal("scalarLength")),[...l.call(d,l.getLocal("r")),...l.ret([])])),C.addCode(l.call(g,l.getLocal("base"),o)),C.addCode(l.call(d,l.getLocal("r"))),C.addCode(l.setLocal("i",l.getLocal("scalarLength"))),C.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")))),...y(),l.br_if(1,l.i32_eqz(l.getLocal("i"))),l.br(0))));function y(){const E=[];for(let m=0;m<8;m++)E.push(...l.call(s,l.getLocal("r"),l.getLocal("r")),...l.if(l.i32_ge_u(l.getLocal("b"),l.i32_const(128>>m)),[...l.setLocal("b",l.i32_sub(l.getLocal("b"),l.i32_const(128>>m))),...l.call(i,l.getLocal("r"),o,l.getLocal("r"))]));return E}},Gn=Uc;function Uc(c,t){const e=c.modules[t].n64*8,n=c.addFunction(t+"_batchInverse");n.addParam("pIn","i32"),n.addParam("inStep","i32"),n.addParam("n","i32"),n.addParam("pOut","i32"),n.addParam("outStep","i32"),n.addLocal("itAux","i32"),n.addLocal("itIn","i32"),n.addLocal("itOut","i32"),n.addLocal("i","i32");const i=n.getCodeBuilder(),s=i.i32_const(c.alloc(e));n.addCode(i.setLocal("itAux",i.i32_load(i.i32_const(0))),i.i32_store(i.i32_const(0),i.i32_add(i.getLocal("itAux"),i.i32_mul(i.i32_add(i.getLocal("n"),i.i32_const(1)),i.i32_const(e))))),n.addCode(i.call(t+"_one",i.getLocal("itAux")),i.setLocal("itIn",i.getLocal("pIn")),i.setLocal("itAux",i.i32_add(i.getLocal("itAux"),i.i32_const(e))),i.setLocal("i",i.i32_const(0)),i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal("i"),i.getLocal("n"))),i.if(i.call(t+"_isZero",i.getLocal("itIn")),i.call(t+"_copy",i.i32_sub(i.getLocal("itAux"),i.i32_const(e)),i.getLocal("itAux")),i.call(t+"_mul",i.getLocal("itIn"),i.i32_sub(i.getLocal("itAux"),i.i32_const(e)),i.getLocal("itAux"))),i.setLocal("itIn",i.i32_add(i.getLocal("itIn"),i.getLocal("inStep"))),i.setLocal("itAux",i.i32_add(i.getLocal("itAux"),i.i32_const(e))),i.setLocal("i",i.i32_add(i.getLocal("i"),i.i32_const(1))),i.br(0))),i.setLocal("itIn",i.i32_sub(i.getLocal("itIn"),i.getLocal("inStep"))),i.setLocal("itAux",i.i32_sub(i.getLocal("itAux"),i.i32_const(e))),i.setLocal("itOut",i.i32_add(i.getLocal("pOut"),i.i32_mul(i.i32_sub(i.getLocal("n"),i.i32_const(1)),i.getLocal("outStep")))),i.call(t+"_inverse",i.getLocal("itAux"),i.getLocal("itAux")),i.block(i.loop(i.br_if(1,i.i32_eqz(i.getLocal("i"))),i.if(i.call(t+"_isZero",i.getLocal("itIn")),[...i.call(t+"_copy",i.getLocal("itAux"),i.i32_sub(i.getLocal("itAux"),i.i32_const(e))),...i.call(t+"_zero",i.getLocal("itOut"))],[...i.call(t+"_copy",i.i32_sub(i.getLocal("itAux"),i.i32_const(e)),s),...i.call(t+"_mul",i.getLocal("itAux"),i.getLocal("itIn"),i.i32_sub(i.getLocal("itAux"),i.i32_const(e))),...i.call(t+"_mul",i.getLocal("itAux"),s,i.getLocal("itOut"))]),i.setLocal("itIn",i.i32_sub(i.getLocal("itIn"),i.getLocal("inStep"))),i.setLocal("itOut",i.i32_sub(i.getLocal("itOut"),i.getLocal("outStep"))),i.setLocal("itAux",i.i32_sub(i.getLocal("itAux"),i.i32_const(e))),i.setLocal("i",i.i32_sub(i.getLocal("i"),i.i32_const(1))),i.br(0)))),n.addCode(i.i32_store(i.i32_const(0),i.getLocal("itAux")))}var fa=jc;function jc(c,t,e,n,i,s){typeof s>"u"&&(n<i?s=!0:s=!1);const g=c.addFunction(t);g.addParam("pIn","i32"),g.addParam("n","i32"),g.addParam("pOut","i32"),g.addLocal("i","i32"),g.addLocal("itIn","i32"),g.addLocal("itOut","i32");const d=g.getCodeBuilder();s?g.addCode(d.setLocal("itIn",d.i32_add(d.getLocal("pIn"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.i32_const(n)))),d.setLocal("itOut",d.i32_add(d.getLocal("pOut"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.i32_const(i)))),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.call(e,d.getLocal("itIn"),d.getLocal("itOut")),d.setLocal("itIn",d.i32_sub(d.getLocal("itIn"),d.i32_const(n))),d.setLocal("itOut",d.i32_sub(d.getLocal("itOut"),d.i32_const(i))),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0)))):g.addCode(d.setLocal("itIn",d.getLocal("pIn")),d.setLocal("itOut",d.getLocal("pOut")),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.call(e,d.getLocal("itIn"),d.getLocal("itOut")),d.setLocal("itIn",d.i32_add(d.getLocal("itIn"),d.i32_const(n))),d.setLocal("itOut",d.i32_add(d.getLocal("itOut"),d.i32_const(i))),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}var $c=Gc;function Gc(c,t,e,n,i,s){typeof s>"u"&&(n<i?s=!0:s=!1);const g=c.addFunction(t);g.addParam("pIn1","i32"),g.addParam("pIn2","i32"),g.addParam("n","i32"),g.addParam("pOut","i32"),g.addLocal("i","i32"),g.addLocal("itIn1","i32"),g.addLocal("itIn2","i32"),g.addLocal("itOut","i32");const d=g.getCodeBuilder();s?g.addCode(d.setLocal("itIn1",d.i32_add(d.getLocal("pIn1"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.i32_const(n)))),d.setLocal("itIn2",d.i32_add(d.getLocal("pIn2"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.i32_const(n)))),d.setLocal("itOut",d.i32_add(d.getLocal("pOut"),d.i32_mul(d.i32_sub(d.getLocal("n"),d.i32_const(1)),d.i32_const(i)))),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.call(e,d.getLocal("itIn1"),d.getLocal("itIn2"),d.getLocal("itOut")),d.setLocal("itIn1",d.i32_sub(d.getLocal("itIn1"),d.i32_const(n))),d.setLocal("itIn2",d.i32_sub(d.getLocal("itIn2"),d.i32_const(n))),d.setLocal("itOut",d.i32_sub(d.getLocal("itOut"),d.i32_const(i))),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0)))):g.addCode(d.setLocal("itIn1",d.getLocal("pIn1")),d.setLocal("itIn2",d.getLocal("pIn2")),d.setLocal("itOut",d.getLocal("pOut")),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.call(e,d.getLocal("itIn1"),d.getLocal("itIn2"),d.getLocal("itOut")),d.setLocal("itIn1",d.i32_add(d.getLocal("itIn1"),d.i32_const(n))),d.setLocal("itIn2",d.i32_add(d.getLocal("itIn2"),d.i32_const(n))),d.setLocal("itOut",d.i32_add(d.getLocal("itOut"),d.i32_const(i))),d.setLocal("i",d.i32_add(d.getLocal("i"),d.i32_const(1))),d.br(0))))}var le={};function _a(c,t){return c===t?0:c>t?1:-1}function Zn(c){return c*c}function ga(c){return c%2n!==0n}function Wn(c){return c%2n===0n}function sn(c){return c<0n}function Zc(c){return c>0n}function pa(c){return sn(c)?c.toString(2).length-1:c.toString(2).length}function He(c){return c<0n?-c:c}function Pe(c){return He(c)===1n}function ha(c,t){for(var e=0n,n=1n,i=t,s=He(c),g,d,C;s!==0n;)g=i/s,d=e,C=i,e=n,i=s,n=d-g*n,s=C-g*s;if(!Pe(i))throw new Error(c.toString()+" and "+t.toString()+" are not co-prime");return _a(e,0n)===-1&&(e=e+t),sn(c)?-e:e}function La(c,t,e){if(e===0n)throw new Error("Cannot take modPow with modulus 0");var n=1n,i=c%e;for(sn(t)&&(t=t*-1n,i=ha(i,e));Zc(t);){if(i===0n)return 0n;ga(t)&&(n=n*i%e),t=t/2n,i=Zn(i)%e}return n}function Wc(c,t){return c=c>=0n?c:-c,t=t>=0n?t:-t,c===t?0:c>t?1:-1}function fi(c,t){return t===0n?!1:Pe(t)?!0:Wc(t,2n)===0?Wn(c):c%t===0n}function Xc(c){var t=He(c);if(Pe(t))return!1;if(t===2n||t===3n||t===5n)return!0;if(Wn(t)||fi(t,3n)||fi(t,5n))return!1;if(t<49n)return!0}function Vc(c){return c-1n}function _i(c,t){for(var e=Vc(c),n=e,i=0,s,g,d;Wn(n);)n=n/2n,i++;t:for(g=0;g<t.length;g++)if(!(c<t[g])&&(d=La(BigInt(t[g]),n,c),!(Pe(d)||d===e))){for(s=i-1;s!=0;s--){if(d=Zn(d)%c,Pe(d))return!1;if(d===e)continue t}return!1}return!0}function Hc(c){var t=Xc(c);if(t!==void 0)return t;var e=He(c),n=pa(e);if(n<=64)return _i(e,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.log(2)*Number(n),s=Math.ceil(i),g=[],d=0;d<s;d++)g.push(BigInt(d+2));return _i(e,g)}le.bitLength=pa;le.isOdd=ga;le.isNegative=sn;le.abs=He;le.isUnit=Pe;le.compare=_a;le.modInv=ha;le.modPow=La;le.isPrime=Hc;le.square=Zn;const Qc=zc,pe=ye,Jc=$n,Kc=Gn,gn=fa,pn=$c,{bitLength:Yc,modInv:hn,modPow:gi,isPrime:pi,isOdd:ts,square:es}=le;var Xn=function(t,e,n,i){const s=BigInt(e),g=Math.floor((Yc(s-1n)-1)/64)+1,d=g*2,C=g*8,l=n||"f1m";if(t.modules[l])return l;const o=Qc(t,g,i),y=t.alloc(C,pe.bigInt2BytesLE(s,C)),E=t.alloc(pe.bigInt2BytesLE(es(1n<<BigInt(g*64))%s,C)),m=t.alloc(pe.bigInt2BytesLE((1n<<BigInt(g*64))%s,C)),x=t.alloc(pe.bigInt2BytesLE(0n,C)),O=s-1n,L=O>>1n,I=t.alloc(C,pe.bigInt2BytesLE(L,C)),v=L+1n,U=t.alloc(C,pe.bigInt2BytesLE(v,C));t.modules[l]={pq:y,pR2:E,n64:g,q:s,pOne:m,pZero:x,pePlusOne:U};function w(){const z=t.addFunction(l+"_one");z.addParam("pr","i32");const b=z.getCodeBuilder();z.addCode(b.call(o+"_copy",b.i32_const(m),b.getLocal("pr")))}function S(){const z=t.addFunction(l+"_add");z.addParam("x","i32"),z.addParam("y","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.if(b.call(o+"_add",b.getLocal("x"),b.getLocal("y"),b.getLocal("r")),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))),b.if(b.call(o+"_gte",b.getLocal("r"),b.i32_const(y)),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))))))}function F(){const z=t.addFunction(l+"_sub");z.addParam("x","i32"),z.addParam("y","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.if(b.call(o+"_sub",b.getLocal("x"),b.getLocal("y"),b.getLocal("r")),b.drop(b.call(o+"_add",b.getLocal("r"),b.i32_const(y),b.getLocal("r")))))}function r(){const z=t.addFunction(l+"_neg");z.addParam("x","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.call(l+"_sub",b.i32_const(x),b.getLocal("x"),b.getLocal("r")))}function h(){const z=t.addFunction(l+"_isNegative");z.addParam("x","i32"),z.setReturnType("i32");const b=z.getCodeBuilder(),at=b.i32_const(t.alloc(C));z.addCode(b.call(l+"_fromMontgomery",b.getLocal("x"),at),b.call(o+"_gte",at,b.i32_const(U)))}function R(){const z=t.addFunction(l+"_sign");z.addParam("x","i32"),z.setReturnType("i32");const b=z.getCodeBuilder(),at=b.i32_const(t.alloc(C));z.addCode(b.if(b.call(o+"_isZero",b.getLocal("x")),b.ret(b.i32_const(0))),b.call(l+"_fromMontgomery",b.getLocal("x"),at),b.if(b.call(o+"_gte",at,b.i32_const(U)),b.ret(b.i32_const(-1))),b.ret(b.i32_const(1)))}function j(){const z=t.alloc(d*d*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 at=b.getCodeBuilder(),At=Number(0x100000000n-hn(s,0x100000000n));b.addCode(at.setLocal("np32",at.i64_const(At)));for(let Lt=0;Lt<d;Lt++){b.addCode(at.setLocal("c",at.i64_const(0))),b.addCode(at.setLocal("m",at.i64_and(at.i64_mul(at.i64_load32_u(at.getLocal("t"),Lt*4),at.getLocal("np32")),at.i64_const("0xFFFFFFFF"))));for(let yt=0;yt<d;yt++)b.addCode(at.setLocal("c",at.i64_add(at.i64_add(at.i64_load32_u(at.getLocal("t"),(Lt+yt)*4),at.i64_shr_u(at.getLocal("c"),at.i64_const(32))),at.i64_mul(at.i64_load32_u(at.i32_const(y),yt*4),at.getLocal("m"))))),b.addCode(at.i64_store32(at.getLocal("t"),(Lt+yt)*4,at.getLocal("c")));b.addCode(at.i64_store32(at.i32_const(z),Lt*4,at.i64_shr_u(at.getLocal("c"),at.i64_const(32))))}b.addCode(at.call(l+"_add",at.i32_const(z),at.i32_add(at.getLocal("t"),at.i32_const(d*4)),at.getLocal("r")))}function T(){const z=t.addFunction(l+"_mul");z.addParam("x","i32"),z.addParam("y","i32"),z.addParam("r","i32"),z.addLocal("c0","i64"),z.addLocal("c1","i64"),z.addLocal("np32","i64");for(let Et=0;Et<d;Et++)z.addLocal("x"+Et,"i64"),z.addLocal("y"+Et,"i64"),z.addLocal("m"+Et,"i64"),z.addLocal("q"+Et,"i64");const b=z.getCodeBuilder(),at=Number(0x100000000n-hn(s,0x100000000n));z.addCode(b.setLocal("np32",b.i64_const(at)));const At=[],Lt=[],yt=[];function It(Et,bt){let pt,$t;return At[Et]?pt=b.getLocal("x"+Et):(pt=b.teeLocal("x"+Et,b.i64_load32_u(b.getLocal("x"),Et*4)),At[Et]=!0),Lt[bt]?$t=b.getLocal("y"+bt):($t=b.teeLocal("y"+bt,b.i64_load32_u(b.getLocal("y"),bt*4)),Lt[bt]=!0),b.i64_mul(pt,$t)}function mt(Et,bt){let pt,$t;return yt[Et]?pt=b.getLocal("q"+Et):(pt=b.teeLocal("q"+Et,b.i64_load32_u(b.i32_const(0),y+Et*4)),yt[Et]=!0),$t=b.getLocal("m"+bt),b.i64_mul(pt,$t)}let Ot="c0",jt="c1";for(let Et=0;Et<d*2-1;Et++){for(let bt=Math.max(0,Et-d+1);bt<=Et&&bt<d;bt++){const pt=Et-bt;z.addCode(b.setLocal(Ot,b.i64_add(b.i64_and(b.getLocal(Ot),b.i64_const(4294967295)),It(bt,pt)))),z.addCode(b.setLocal(jt,b.i64_add(b.getLocal(jt),b.i64_shr_u(b.getLocal(Ot),b.i64_const(32)))))}for(let bt=Math.max(1,Et-d+1);bt<=Et&&bt<d;bt++){const pt=Et-bt;z.addCode(b.setLocal(Ot,b.i64_add(b.i64_and(b.getLocal(Ot),b.i64_const(4294967295)),mt(bt,pt)))),z.addCode(b.setLocal(jt,b.i64_add(b.getLocal(jt),b.i64_shr_u(b.getLocal(Ot),b.i64_const(32)))))}Et<d&&(z.addCode(b.setLocal("m"+Et,b.i64_and(b.i64_mul(b.i64_and(b.getLocal(Ot),b.i64_const(4294967295)),b.getLocal("np32")),b.i64_const("0xFFFFFFFF")))),z.addCode(b.setLocal(Ot,b.i64_add(b.i64_and(b.getLocal(Ot),b.i64_const(4294967295)),mt(0,Et)))),z.addCode(b.setLocal(jt,b.i64_add(b.getLocal(jt),b.i64_shr_u(b.getLocal(Ot),b.i64_const(32)))))),Et>=d&&z.addCode(b.i64_store32(b.getLocal("r"),(Et-d)*4,b.getLocal(Ot))),[Ot,jt]=[jt,Ot],z.addCode(b.setLocal(jt,b.i64_shr_u(b.getLocal(Ot),b.i64_const(32))))}z.addCode(b.i64_store32(b.getLocal("r"),d*4-4,b.getLocal(Ot))),z.addCode(b.if(b.i32_wrap_i64(b.getLocal(jt)),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))),b.if(b.call(o+"_gte",b.getLocal("r"),b.i32_const(y)),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))))))}function M(){const z=t.addFunction(l+"_square");z.addParam("x","i32"),z.addParam("r","i32"),z.addLocal("c0","i64"),z.addLocal("c1","i64"),z.addLocal("c0_old","i64"),z.addLocal("c1_old","i64"),z.addLocal("np32","i64");for(let bt=0;bt<d;bt++)z.addLocal("x"+bt,"i64"),z.addLocal("m"+bt,"i64"),z.addLocal("q"+bt,"i64");const b=z.getCodeBuilder(),at=Number(0x100000000n-hn(s,0x100000000n));z.addCode(b.setLocal("np32",b.i64_const(at)));const At=[],Lt=[];function yt(bt,pt){let $t,Jt;return At[bt]?$t=b.getLocal("x"+bt):($t=b.teeLocal("x"+bt,b.i64_load32_u(b.getLocal("x"),bt*4)),At[bt]=!0),At[pt]?Jt=b.getLocal("x"+pt):(Jt=b.teeLocal("x"+pt,b.i64_load32_u(b.getLocal("x"),pt*4)),At[pt]=!0),b.i64_mul($t,Jt)}function It(bt,pt){let $t,Jt;return Lt[bt]?$t=b.getLocal("q"+bt):($t=b.teeLocal("q"+bt,b.i64_load32_u(b.i32_const(0),y+bt*4)),Lt[bt]=!0),Jt=b.getLocal("m"+pt),b.i64_mul($t,Jt)}let mt="c0",Ot="c1",jt="c0_old",Et="c1_old";for(let bt=0;bt<d*2-1;bt++){z.addCode(b.setLocal(mt,b.i64_const(0)),b.setLocal(Ot,b.i64_const(0)));for(let pt=Math.max(0,bt-d+1);pt<bt+1>>1&&pt<d;pt++){const $t=bt-pt;z.addCode(b.setLocal(mt,b.i64_add(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),yt(pt,$t)))),z.addCode(b.setLocal(Ot,b.i64_add(b.getLocal(Ot),b.i64_shr_u(b.getLocal(mt),b.i64_const(32)))))}z.addCode(b.setLocal(mt,b.i64_shl(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),b.i64_const(1)))),z.addCode(b.setLocal(Ot,b.i64_add(b.i64_shl(b.getLocal(Ot),b.i64_const(1)),b.i64_shr_u(b.getLocal(mt),b.i64_const(32))))),bt%2==0&&(z.addCode(b.setLocal(mt,b.i64_add(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),yt(bt>>1,bt>>1)))),z.addCode(b.setLocal(Ot,b.i64_add(b.getLocal(Ot),b.i64_shr_u(b.getLocal(mt),b.i64_const(32)))))),bt>0&&(z.addCode(b.setLocal(mt,b.i64_add(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),b.i64_and(b.getLocal(jt),b.i64_const(4294967295))))),z.addCode(b.setLocal(Ot,b.i64_add(b.i64_add(b.getLocal(Ot),b.i64_shr_u(b.getLocal(mt),b.i64_const(32))),b.getLocal(Et)))));for(let pt=Math.max(1,bt-d+1);pt<=bt&&pt<d;pt++){const $t=bt-pt;z.addCode(b.setLocal(mt,b.i64_add(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),It(pt,$t)))),z.addCode(b.setLocal(Ot,b.i64_add(b.getLocal(Ot),b.i64_shr_u(b.getLocal(mt),b.i64_const(32)))))}bt<d&&(z.addCode(b.setLocal("m"+bt,b.i64_and(b.i64_mul(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),b.getLocal("np32")),b.i64_const("0xFFFFFFFF")))),z.addCode(b.setLocal(mt,b.i64_add(b.i64_and(b.getLocal(mt),b.i64_const(4294967295)),It(0,bt)))),z.addCode(b.setLocal(Ot,b.i64_add(b.getLocal(Ot),b.i64_shr_u(b.getLocal(mt),b.i64_const(32)))))),bt>=d&&z.addCode(b.i64_store32(b.getLocal("r"),(bt-d)*4,b.getLocal(mt))),z.addCode(b.setLocal(jt,b.getLocal(Ot)),b.setLocal(Et,b.i64_shr_u(b.getLocal(jt),b.i64_const(32))))}z.addCode(b.i64_store32(b.getLocal("r"),d*4-4,b.getLocal(jt))),z.addCode(b.if(b.i32_wrap_i64(b.getLocal(Et)),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))),b.if(b.call(o+"_gte",b.getLocal("r"),b.i32_const(y)),b.drop(b.call(o+"_sub",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))))))}function A(){const z=t.addFunction(l+"_squareOld");z.addParam("x","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.call(l+"_mul",b.getLocal("x"),b.getLocal("x"),b.getLocal("r")))}function D(){const z=t.addFunction(l+"_toMontgomery");z.addParam("x","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.call(l+"_mul",b.getLocal("x"),b.i32_const(E),b.getLocal("r")))}function H(){const z=t.alloc(C*2),b=t.addFunction(l+"_fromMontgomery");b.addParam("x","i32"),b.addParam("r","i32");const at=b.getCodeBuilder();b.addCode(at.call(o+"_copy",at.getLocal("x"),at.i32_const(z))),b.addCode(at.call(o+"_zero",at.i32_const(z+C))),b.addCode(at.call(l+"_mReduct",at.i32_const(z),at.getLocal("r")))}function ut(){const z=t.addFunction(l+"_inverse");z.addParam("x","i32"),z.addParam("r","i32");const b=z.getCodeBuilder();z.addCode(b.call(l+"_fromMontgomery",b.getLocal("x"),b.getLocal("r"))),z.addCode(b.call(o+"_inverseMod",b.getLocal("r"),b.i32_const(y),b.getLocal("r"))),z.addCode(b.call(l+"_toMontgomery",b.getLocal("r"),b.getLocal("r")))}let nt=2n;if(pi(s))for(;gi(nt,L,s)!==O;)nt=nt+1n;let J=0,ft=O;for(;!ts(ft)&&ft!==0n;)J++,ft=ft>>1n;const it=t.alloc(C,pe.bigInt2BytesLE(ft,C)),_t=gi(nt,ft,s),zt=t.alloc(pe.bigInt2BytesLE((_t<<BigInt(g*64))%s,C)),G=ft+1n>>1n,K=t.alloc(C,pe.bigInt2BytesLE(G,C));function P(){const z=t.addFunction(l+"_sqrt");z.addParam("n","i32"),z.addParam("r","i32"),z.addLocal("m","i32"),z.addLocal("i","i32"),z.addLocal("j","i32");const b=z.getCodeBuilder(),at=b.i32_const(m),At=b.i32_const(t.alloc(C)),Lt=b.i32_const(t.alloc(C)),yt=b.i32_const(t.alloc(C)),It=b.i32_const(t.alloc(C)),mt=b.i32_const(t.alloc(C));z.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(J)),b.call(l+"_copy",b.i32_const(zt),At),b.call(l+"_exp",b.getLocal("n"),b.i32_const(it),b.i32_const(C),Lt),b.call(l+"_exp",b.getLocal("n"),b.i32_const(K),b.i32_const(C),yt),b.block(b.loop(b.br_if(1,b.call(l+"_eq",Lt,at)),b.call(l+"_square",Lt,It),b.setLocal("i",b.i32_const(1)),b.block(b.loop(b.br_if(1,b.call(l+"_eq",It,at)),b.call(l+"_square",It,It),b.setLocal("i",b.i32_add(b.getLocal("i"),b.i32_const(1))),b.br(0))),b.call(l+"_copy",At,mt),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",mt,mt),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",mt,At),b.call(l+"_mul",Lt,At,Lt),b.call(l+"_mul",yt,mt,yt),b.br(0))),b.if(b.call(l+"_isNegative",yt),b.call(l+"_neg",yt,b.getLocal("r")),b.call(l+"_copy",yt,b.getLocal("r"))))}function a(){const z=t.addFunction(l+"_isSquare");z.addParam("n","i32"),z.setReturnType("i32");const b=z.getCodeBuilder(),at=b.i32_const(m),At=b.i32_const(t.alloc(C));z.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(I),b.i32_const(C),At),b.call(l+"_eq",At,at))}function q(){const z=t.addFunction(l+"_load");z.addParam("scalar","i32"),z.addParam("scalarLen","i32"),z.addParam("r","i32"),z.addLocal("p","i32"),z.addLocal("l","i32"),z.addLocal("i","i32"),z.addLocal("j","i32");const b=z.getCodeBuilder(),at=b.i32_const(t.alloc(C)),At=t.alloc(C),Lt=b.i32_const(At);z.addCode(b.call(o+"_zero",b.getLocal("r")),b.setLocal("i",b.i32_const(C)),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(C)),b.call(l+"_one",at),b.call(l+"_mul",at,b.i32_const(E),at)),b.call(l+"_mul",b.getLocal("p"),at,Lt),b.call(l+"_add",b.getLocal("r"),Lt,b.getLocal("r")),b.setLocal("p",b.i32_add(b.getLocal("p"),b.i32_const(C))),b.setLocal("i",b.i32_add(b.getLocal("i"),b.i32_const(C))),b.br(0))),b.setLocal("l",b.i32_rem_u(b.getLocal("scalarLen"),b.i32_const(C))),b.if(b.i32_eqz(b.getLocal("l")),b.ret([])),b.call(o+"_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"),At,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(C)),b.call(l+"_one",at),b.call(l+"_mul",at,b.i32_const(E),at)),b.call(l+"_mul",Lt,at,Lt),b.call(l+"_add",b.getLocal("r"),Lt,b.getLocal("r")))}function u(){const z=t.addFunction(l+"_timesScalar");z.addParam("x","i32"),z.addParam("scalar","i32"),z.addParam("scalarLen","i32"),z.addParam("r","i32");const b=z.getCodeBuilder(),at=b.i32_const(t.alloc(C));z.addCode(b.call(l+"_load",b.getLocal("scalar"),b.getLocal("scalarLen"),at),b.call(l+"_toMontgomery",at,at),b.call(l+"_mul",b.getLocal("x"),at,b.getLocal("r")))}function W(){const z=t.addFunction(l+"_isOne");z.addParam("x","i32"),z.setReturnType("i32");const b=z.getCodeBuilder();z.addCode(b.ret(b.call(o+"_eq",b.getLocal("x"),b.i32_const(m))))}return t.exportFunction(o+"_copy",l+"_copy"),t.exportFunction(o+"_zero",l+"_zero"),t.exportFunction(o+"_isZero",l+"_isZero"),t.exportFunction(o+"_eq",l+"_eq"),W(),S(),F(),r(),j(),T(),M(),A(),D(),H(),h(),R(),ut(),w(),q(),u(),Kc(t,l),gn(t,l+"_batchToMontgomery",l+"_toMontgomery",C,C),gn(t,l+"_batchFromMontgomery",l+"_fromMontgomery",C,C),gn(t,l+"_batchNeg",l+"_neg",C,C),pn(t,l+"_batchAdd",l+"_add",C,C),pn(t,l+"_batchSub",l+"_sub",C,C),pn(t,l+"_batchMul",l+"_mul",C,C),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"),Jc(t,l+"_exp",C,l+"_mul",l+"_square",o+"_copy",l+"_one"),t.exportFunction(l+"_exp"),t.exportFunction(l+"_batchInverse"),pi(s)&&(P(),a(),t.exportFunction(l+"_sqrt"),t.exportFunction(l+"_isSquare")),t.exportFunction(l+"_batchToMontgomery"),t.exportFunction(l+"_batchFromMontgomery"),l};const ns=Xn,{bitLength:is}=le;var ma=function(t,e,n,i,s){const g=BigInt(e),d=Math.floor((is(g-1n)-1)/64)+1,C=d*8,l=n||"f1";if(t.modules[l])return l;t.modules[l]={n64:d};const o=s||"int",y=ns(t,g,i,o),E=t.modules[y].pR2,m=t.modules[y].pq,x=t.modules[y].pePlusOne;function O(){const U=t.alloc(C),w=t.addFunction(l+"_mul");w.addParam("x","i32"),w.addParam("y","i32"),w.addParam("r","i32");const S=w.getCodeBuilder();w.addCode(S.call(y+"_mul",S.getLocal("x"),S.getLocal("y"),S.i32_const(U))),w.addCode(S.call(y+"_mul",S.i32_const(U),S.i32_const(E),S.getLocal("r")))}function L(){const U=t.addFunction(l+"_square");U.addParam("x","i32"),U.addParam("r","i32");const w=U.getCodeBuilder();U.addCode(w.call(l+"_mul",w.getLocal("x"),w.getLocal("x"),w.getLocal("r")))}function I(){const U=t.addFunction(l+"_inverse");U.addParam("x","i32"),U.addParam("r","i32");const w=U.getCodeBuilder();U.addCode(w.call(o+"_inverseMod",w.getLocal("x"),w.i32_const(m),w.getLocal("r")))}function v(){const U=t.addFunction(l+"_isNegative");U.addParam("x","i32"),U.setReturnType("i32");const w=U.getCodeBuilder();U.addCode(w.call(o+"_gte",w.getLocal("x"),w.i32_const(x)))}return O(),L(),I(),v(),t.exportFunction(y+"_add",l+"_add"),t.exportFunction(y+"_sub",l+"_sub"),t.exportFunction(y+"_neg",l+"_neg"),t.exportFunction(l+"_mul"),t.exportFunction(l+"_square"),t.exportFunction(l+"_inverse"),t.exportFunction(l+"_isNegative"),t.exportFunction(y+"_copy",l+"_copy"),t.exportFunction(y+"_zero",l+"_zero"),t.exportFunction(y+"_one",l+"_one"),t.exportFunction(y+"_isZero",l+"_isZero"),t.exportFunction(y+"_eq",l+"_eq"),l};const as=$n,os=Gn,Ln=ye;var ba=function(t,e,n,i){if(t.modules[n])return n;const s=t.modules[i].n64*8,g=t.modules[i].q;t.modules[n]={n64:t.modules[i].n64*2};function d(){const M=t.addFunction(n+"_add");M.addParam("x","i32"),M.addParam("y","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("y"),nt=A.i32_add(A.getLocal("y"),A.i32_const(s)),J=A.getLocal("r"),ft=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_add",D,ut,J),A.call(i+"_add",H,nt,ft))}function C(){const M=t.addFunction(n+"_timesScalar");M.addParam("x","i32"),M.addParam("scalar","i32"),M.addParam("scalarLen","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_timesScalar",D,A.getLocal("scalar"),A.getLocal("scalarLen"),ut),A.call(i+"_timesScalar",H,A.getLocal("scalar"),A.getLocal("scalarLen"),nt))}function l(){const M=t.addFunction(n+"_sub");M.addParam("x","i32"),M.addParam("y","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("y"),nt=A.i32_add(A.getLocal("y"),A.i32_const(s)),J=A.getLocal("r"),ft=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_sub",D,ut,J),A.call(i+"_sub",H,nt,ft))}function o(){const M=t.addFunction(n+"_neg");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_neg",D,ut),A.call(i+"_neg",H,nt))}function y(){const M=t.addFunction(n+"_conjugate");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_copy",D,ut),A.call(i+"_neg",H,nt))}function E(){const M=t.addFunction(n+"_isNegative");M.addParam("x","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.if(A.call(i+"_isZero",H),A.ret(A.call(i+"_isNegative",D))),A.ret(A.call(i+"_isNegative",H)))}function m(){const M=t.addFunction(n+"_mul");M.addParam("x","i32"),M.addParam("y","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("y"),nt=A.i32_add(A.getLocal("y"),A.i32_const(s)),J=A.getLocal("r"),ft=A.i32_add(A.getLocal("r"),A.i32_const(s)),it=A.i32_const(t.alloc(s)),_t=A.i32_const(t.alloc(s)),zt=A.i32_const(t.alloc(s)),G=A.i32_const(t.alloc(s));M.addCode(A.call(i+"_mul",D,ut,it),A.call(i+"_mul",H,nt,_t),A.call(i+"_add",D,H,zt),A.call(i+"_add",ut,nt,G),A.call(i+"_mul",zt,G,zt),A.call(e,_t,J),A.call(i+"_add",it,J,J),A.call(i+"_add",it,_t,ft),A.call(i+"_sub",zt,ft,ft))}function x(){const M=t.addFunction(n+"_mul1");M.addParam("x","i32"),M.addParam("y","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("y"),nt=A.getLocal("r"),J=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_mul",D,ut,nt),A.call(i+"_mul",H,ut,J))}function O(){const M=t.addFunction(n+"_square");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s)),J=A.i32_const(t.alloc(s)),ft=A.i32_const(t.alloc(s)),it=A.i32_const(t.alloc(s)),_t=A.i32_const(t.alloc(s));M.addCode(A.call(i+"_mul",D,H,J),A.call(i+"_add",D,H,ft),A.call(e,H,it),A.call(i+"_add",D,it,it),A.call(e,J,_t),A.call(i+"_add",_t,J,_t),A.call(i+"_mul",ft,it,ut),A.call(i+"_sub",ut,_t,ut),A.call(i+"_add",J,J,nt))}function L(){const M=t.addFunction(n+"_toMontgomery");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_toMontgomery",D,ut),A.call(i+"_toMontgomery",H,nt))}function I(){const M=t.addFunction(n+"_fromMontgomery");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_fromMontgomery",D,ut),A.call(i+"_fromMontgomery",H,nt))}function v(){const M=t.addFunction(n+"_copy");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s));M.addCode(A.call(i+"_copy",D,ut),A.call(i+"_copy",H,nt))}function U(){const M=t.addFunction(n+"_zero");M.addParam("x","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.call(i+"_zero",D),A.call(i+"_zero",H))}function w(){const M=t.addFunction(n+"_one");M.addParam("x","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.call(i+"_one",D),A.call(i+"_zero",H))}function S(){const M=t.addFunction(n+"_eq");M.addParam("x","i32"),M.addParam("y","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("y"),nt=A.i32_add(A.getLocal("y"),A.i32_const(s));M.addCode(A.i32_and(A.call(i+"_eq",D,ut),A.call(i+"_eq",H,nt)))}function F(){const M=t.addFunction(n+"_isZero");M.addParam("x","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.i32_and(A.call(i+"_isZero",D),A.call(i+"_isZero",H)))}function r(){const M=t.addFunction(n+"_inverse");M.addParam("x","i32"),M.addParam("r","i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s)),ut=A.getLocal("r"),nt=A.i32_add(A.getLocal("r"),A.i32_const(s)),J=A.i32_const(t.alloc(s)),ft=A.i32_const(t.alloc(s)),it=A.i32_const(t.alloc(s)),_t=A.i32_const(t.alloc(s));M.addCode(A.call(i+"_square",D,J),A.call(i+"_square",H,ft),A.call(e,ft,it),A.call(i+"_sub",J,it,it),A.call(i+"_inverse",it,_t),A.call(i+"_mul",D,_t,ut),A.call(i+"_mul",H,_t,nt),A.call(i+"_neg",nt,nt))}function h(){const M=t.addFunction(n+"_sign");M.addParam("x","i32"),M.addLocal("s","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.setLocal("s",A.call(i+"_sign",H)),A.if(A.getLocal("s"),A.ret(A.getLocal("s"))),A.ret(A.call(i+"_sign",D)))}function R(){const M=t.addFunction(n+"_isOne");M.addParam("x","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.getLocal("x"),H=A.i32_add(A.getLocal("x"),A.i32_const(s));M.addCode(A.ret(A.i32_and(A.call(i+"_isOne",D),A.call(i+"_isZero",H))))}function j(){const M=t.addFunction(n+"_sqrt");M.addParam("a","i32"),M.addParam("pr","i32");const A=M.getCodeBuilder(),D=A.i32_const(t.alloc(Ln.bigInt2BytesLE((BigInt(g||0)-3n)/4n,s))),H=A.i32_const(t.alloc(Ln.bigInt2BytesLE((BigInt(g||0)-1n)/2n,s))),ut=A.getLocal("a"),nt=A.i32_const(t.alloc(s*2)),J=A.i32_const(t.alloc(s*2)),ft=A.i32_const(t.alloc(s*2)),it=t.alloc(s*2),_t=A.i32_const(it),zt=A.i32_const(it),G=A.i32_const(it+s),K=A.i32_const(t.alloc(s*2)),P=A.i32_const(t.alloc(s*2));M.addCode(A.call(n+"_one",_t),A.call(n+"_neg",_t,_t),A.call(n+"_exp",ut,D,A.i32_const(s),nt),A.call(n+"_square",nt,J),A.call(n+"_mul",ut,J,J),A.call(n+"_conjugate",J,ft),A.call(n+"_mul",ft,J,ft),A.if(A.call(n+"_eq",ft,_t),A.unreachable()),A.call(n+"_mul",nt,ut,K),A.if(A.call(n+"_eq",J,_t),[...A.call(i+"_zero",zt),...A.call(i+"_one",G),...A.call(n+"_mul",_t,K,A.getLocal("pr"))],[...A.call(n+"_one",P),...A.call(n+"_add",P,J,P),...A.call(n+"_exp",P,H,A.i32_const(s),P),...A.call(n+"_mul",P,K,A.getLocal("pr"))]))}function T(){const M=t.addFunction(n+"_isSquare");M.addParam("a","i32"),M.setReturnType("i32");const A=M.getCodeBuilder(),D=A.i32_const(t.alloc(Ln.bigInt2BytesLE((BigInt(g||0)-3n)/4n,s))),H=A.getLocal("a"),ut=A.i32_const(t.alloc(s*2)),nt=A.i32_const(t.alloc(s*2)),J=A.i32_const(t.alloc(s*2)),ft=t.alloc(s*2),it=A.i32_const(ft);M.addCode(A.call(n+"_one",it),A.call(n+"_neg",it,it),A.call(n+"_exp",H,D,A.i32_const(s),ut),A.call(n+"_square",ut,nt),A.call(n+"_mul",H,nt,nt),A.call(n+"_conjugate",nt,J),A.call(n+"_mul",J,nt,J),A.if(A.call(n+"_eq",J,it),A.ret(A.i32_const(0))),A.ret(A.i32_const(1)))}return F(),R(),U(),w(),v(),m(),x(),O(),d(),l(),o(),y(),L(),I(),S(),r(),C(),h(),E(),t.exportFunction(n+"_isZero"),t.exportFunction(n+"_isOne"),t.exportFunction(n+"_zero"),t.exportFunction(n+"_one"),t.exportFunction(n+"_copy"),t.exportFunction(n+"_mul"),t.exportFunction(n+"_mul1"),t.exportFunction(n+"_square"),t.exportFunction(n+"_add"),t.exportFunction(n+"_sub"),t.exportFunction(n+"_neg"),t.exportFunction(n+"_sign"),t.exportFunction(n+"_conjugate"),t.exportFunction(n+"_fromMontgomery"),t.exportFunction(n+"_toMontgomery"),t.exportFunction(n+"_eq"),t.exportFunction(n+"_inverse"),os(t,n),as(t,n+"_exp",s*2,n+"_mul",n+"_square",n+"_copy",n+"_one"),j(),T(),t.exportFunction(n+"_exp"),t.exportFunction(n+"_timesScalar"),t.exportFunction(n+"_batchInverse"),t.exportFunction(n+"_sqrt"),t.exportFunction(n+"_isSquare"),t.exportFunction(n+"_isNegative"),n};const cs=$n,ss=Gn;var ya=function(t,e,n,i){if(t.modules[n])return n;const s=t.modules[i].n64*8;t.modules[n]={n64:t.modules[i].n64*3};function g(){const r=t.addFunction(n+"_add");r.addParam("x","i32"),r.addParam("y","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("y"),A=h.i32_add(h.getLocal("y"),h.i32_const(s)),D=h.i32_add(h.getLocal("y"),h.i32_const(2*s)),H=h.getLocal("r"),ut=h.i32_add(h.getLocal("r"),h.i32_const(s)),nt=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_add",R,M,H),h.call(i+"_add",j,A,ut),h.call(i+"_add",T,D,nt))}function d(){const r=t.addFunction(n+"_timesScalar");r.addParam("x","i32"),r.addParam("scalar","i32"),r.addParam("scalarLen","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_timesScalar",R,h.getLocal("scalar"),h.getLocal("scalarLen"),M),h.call(i+"_timesScalar",j,h.getLocal("scalar"),h.getLocal("scalarLen"),A),h.call(i+"_timesScalar",T,h.getLocal("scalar"),h.getLocal("scalarLen"),D))}function C(){const r=t.addFunction(n+"_sub");r.addParam("x","i32"),r.addParam("y","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("y"),A=h.i32_add(h.getLocal("y"),h.i32_const(s)),D=h.i32_add(h.getLocal("y"),h.i32_const(2*s)),H=h.getLocal("r"),ut=h.i32_add(h.getLocal("r"),h.i32_const(s)),nt=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_sub",R,M,H),h.call(i+"_sub",j,A,ut),h.call(i+"_sub",T,D,nt))}function l(){const r=t.addFunction(n+"_neg");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_neg",R,M),h.call(i+"_neg",j,A),h.call(i+"_neg",T,D))}function o(){const r=t.addFunction(n+"_isNegative");r.addParam("x","i32"),r.setReturnType("i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s));r.addCode(h.if(h.call(i+"_isZero",T),h.if(h.call(i+"_isZero",j),h.ret(h.call(i+"_isNegative",R)),h.ret(h.call(i+"_isNegative",j)))),h.ret(h.call(i+"_isNegative",T)))}function y(){const r=t.addFunction(n+"_mul");r.addParam("x","i32"),r.addParam("y","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("y"),A=h.i32_add(h.getLocal("y"),h.i32_const(s)),D=h.i32_add(h.getLocal("y"),h.i32_const(2*s)),H=h.getLocal("r"),ut=h.i32_add(h.getLocal("r"),h.i32_const(s)),nt=h.i32_add(h.getLocal("r"),h.i32_const(2*s)),J=h.i32_const(t.alloc(s)),ft=h.i32_const(t.alloc(s)),it=h.i32_const(t.alloc(s)),_t=h.i32_const(t.alloc(s)),zt=h.i32_const(t.alloc(s)),G=h.i32_const(t.alloc(s)),K=h.i32_const(t.alloc(s)),P=h.i32_const(t.alloc(s)),a=h.i32_const(t.alloc(s)),q=h.i32_const(t.alloc(s)),u=h.i32_const(t.alloc(s)),W=h.i32_const(t.alloc(s)),z=h.i32_const(t.alloc(s));r.addCode(h.call(i+"_mul",R,M,J),h.call(i+"_mul",j,A,ft),h.call(i+"_mul",T,D,it),h.call(i+"_add",R,j,_t),h.call(i+"_add",M,A,zt),h.call(i+"_add",R,T,G),h.call(i+"_add",M,D,K),h.call(i+"_add",j,T,P),h.call(i+"_add",A,D,a),h.call(i+"_add",J,ft,q),h.call(i+"_add",J,it,u),h.call(i+"_add",ft,it,W),h.call(i+"_mul",P,a,H),h.call(i+"_sub",H,W,H),h.call(e,H,H),h.call(i+"_add",J,H,H),h.call(i+"_mul",_t,zt,ut),h.call(i+"_sub",ut,q,ut),h.call(e,it,z),h.call(i+"_add",ut,z,ut),h.call(i+"_mul",G,K,nt),h.call(i+"_sub",nt,u,nt),h.call(i+"_add",nt,ft,nt))}function E(){const r=t.addFunction(n+"_square");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s)),H=h.i32_const(t.alloc(s)),ut=h.i32_const(t.alloc(s)),nt=h.i32_const(t.alloc(s)),J=h.i32_const(t.alloc(s)),ft=h.i32_const(t.alloc(s)),it=h.i32_const(t.alloc(s)),_t=h.i32_const(t.alloc(s));r.addCode(h.call(i+"_square",R,H),h.call(i+"_mul",R,j,ut),h.call(i+"_add",ut,ut,nt),h.call(i+"_sub",R,j,J),h.call(i+"_add",J,T,J),h.call(i+"_square",J,J),h.call(i+"_mul",j,T,ft),h.call(i+"_add",ft,ft,it),h.call(i+"_square",T,_t),h.call(e,it,M),h.call(i+"_add",H,M,M),h.call(e,_t,A),h.call(i+"_add",nt,A,A),h.call(i+"_add",H,_t,D),h.call(i+"_sub",it,D,D),h.call(i+"_add",J,D,D),h.call(i+"_add",nt,D,D))}function m(){const r=t.addFunction(n+"_toMontgomery");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_toMontgomery",R,M),h.call(i+"_toMontgomery",j,A),h.call(i+"_toMontgomery",T,D))}function x(){const r=t.addFunction(n+"_fromMontgomery");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_fromMontgomery",R,M),h.call(i+"_fromMontgomery",j,A),h.call(i+"_fromMontgomery",T,D))}function O(){const r=t.addFunction(n+"_copy");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s));r.addCode(h.call(i+"_copy",R,M),h.call(i+"_copy",j,A),h.call(i+"_copy",T,D))}function L(){const r=t.addFunction(n+"_zero");r.addParam("x","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s));r.addCode(h.call(i+"_zero",R),h.call(i+"_zero",j),h.call(i+"_zero",T))}function I(){const r=t.addFunction(n+"_one");r.addParam("x","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s));r.addCode(h.call(i+"_one",R),h.call(i+"_zero",j),h.call(i+"_zero",T))}function v(){const r=t.addFunction(n+"_eq");r.addParam("x","i32"),r.addParam("y","i32"),r.setReturnType("i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("y"),A=h.i32_add(h.getLocal("y"),h.i32_const(s)),D=h.i32_add(h.getLocal("y"),h.i32_const(2*s));r.addCode(h.i32_and(h.i32_and(h.call(i+"_eq",R,M),h.call(i+"_eq",j,A)),h.call(i+"_eq",T,D)))}function U(){const r=t.addFunction(n+"_isZero");r.addParam("x","i32"),r.setReturnType("i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s));r.addCode(h.i32_and(h.i32_and(h.call(i+"_isZero",R),h.call(i+"_isZero",j)),h.call(i+"_isZero",T)))}function w(){const r=t.addFunction(n+"_inverse");r.addParam("x","i32"),r.addParam("r","i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s)),M=h.getLocal("r"),A=h.i32_add(h.getLocal("r"),h.i32_const(s)),D=h.i32_add(h.getLocal("r"),h.i32_const(2*s)),H=h.i32_const(t.alloc(s)),ut=h.i32_const(t.alloc(s)),nt=h.i32_const(t.alloc(s)),J=h.i32_const(t.alloc(s)),ft=h.i32_const(t.alloc(s)),it=h.i32_const(t.alloc(s)),_t=h.i32_const(t.alloc(s)),zt=h.i32_const(t.alloc(s)),G=h.i32_const(t.alloc(s)),K=h.i32_const(t.alloc(s)),P=h.i32_const(t.alloc(s));r.addCode(h.call(i+"_square",R,H),h.call(i+"_square",j,ut),h.call(i+"_square",T,nt),h.call(i+"_mul",R,j,J),h.call(i+"_mul",R,T,ft),h.call(i+"_mul",j,T,it),h.call(e,it,_t),h.call(i+"_sub",H,_t,_t),h.call(e,nt,zt),h.call(i+"_sub",zt,J,zt),h.call(i+"_sub",ut,ft,G),h.call(i+"_mul",T,zt,K),h.call(i+"_mul",j,G,P),h.call(i+"_add",K,P,K),h.call(e,K,K),h.call(i+"_mul",R,_t,P),h.call(i+"_add",P,K,K),h.call(i+"_inverse",K,K),h.call(i+"_mul",K,_t,M),h.call(i+"_mul",K,zt,A),h.call(i+"_mul",K,G,D))}function S(){const r=t.addFunction(n+"_sign");r.addParam("x","i32"),r.addLocal("s","i32"),r.setReturnType("i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(2*s));r.addCode(h.setLocal("s",h.call(i+"_sign",T)),h.if(h.getLocal("s"),h.ret(h.getLocal("s"))),h.setLocal("s",h.call(i+"_sign",j)),h.if(h.getLocal("s"),h.ret(h.getLocal("s"))),h.ret(h.call(i+"_sign",R)))}function F(){const r=t.addFunction(n+"_isOne");r.addParam("x","i32"),r.setReturnType("i32");const h=r.getCodeBuilder(),R=h.getLocal("x"),j=h.i32_add(h.getLocal("x"),h.i32_const(s)),T=h.i32_add(h.getLocal("x"),h.i32_const(s*2));r.addCode(h.ret(h.i32_and(h.i32_and(h.call(i+"_isOne",R),h.call(i+"_isZero",j)),h.call(i+"_isZero",T))))}return U(),F(),L(),I(),O(),y(),E(),g(),C(),l(),S(),m(),x(),v(),w(),d(),o(),t.exportFunction(n+"_isZero"),t.exportFunction(n+"_isOne"),t.exportFunction(n+"_zero"),t.exportFunction(n+"_one"),t.exportFunction(n+"_copy"),t.exportFunction(n+"_mul"),t.exportFunction(n+"_square"),t.exportFunction(n+"_add"),t.exportFunction(n+"_sub"),t.exportFunction(n+"_neg"),t.exportFunction(n+"_sign"),t.exportFunction(n+"_fromMontgomery"),t.exportFunction(n+"_toMontgomery"),t.exportFunction(n+"_eq"),t.exportFunction(n+"_inverse"),ss(t,n),cs(t,n+"_exp",s*3,n+"_mul",n+"_square",n+"_copy",n+"_one"),t.exportFunction(n+"_exp"),t.exportFunction(n+"_timesScalar"),t.exportFunction(n+"_batchInverse"),t.exportFunction(n+"_isNegative"),n},rs=function(t,e,n,i,s,g,d,C){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 o=l.getCodeBuilder(),y=o.i32_const(t.alloc(n));function E(x){return o.i32_and(o.i32_shr_u(o.i32_load(o.i32_add(o.getLocal("scalar"),o.i32_and(o.i32_shr_u(x,o.i32_const(3)),o.i32_const(4294967292)))),o.i32_and(x,o.i32_const(31))),o.i32_const(1))}function m(x){return[...o.i32_store8(o.getLocal("p"),o.i32_const(x)),...o.setLocal("p",o.i32_add(o.getLocal("p"),o.i32_const(1)))]}l.addCode(o.if(o.i32_eqz(o.getLocal("scalarLength")),[...o.call(C,o.getLocal("r")),...o.ret([])]),o.setLocal("nbits",o.i32_shl(o.getLocal("scalarLength"),o.i32_const(3))),o.setLocal("old0",o.i32_load(o.i32_const(0))),o.setLocal("p",o.getLocal("old0")),o.i32_store(o.i32_const(0),o.i32_and(o.i32_add(o.i32_add(o.getLocal("old0"),o.i32_const(32)),o.getLocal("nbits")),o.i32_const(4294967288))),o.setLocal("i",o.i32_const(1)),o.setLocal("last",E(o.i32_const(0))),o.setLocal("carry",o.i32_const(0)),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("i"),o.getLocal("nbits"))),o.setLocal("cur",E(o.getLocal("i"))),o.if(o.getLocal("last"),o.if(o.getLocal("cur"),o.if(o.getLocal("carry"),[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(1)),...m(1)],[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(1)),...m(255)]),o.if(o.getLocal("carry"),[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(1)),...m(255)],[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(0)),...m(1)])),o.if(o.getLocal("cur"),o.if(o.getLocal("carry"),[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(1)),...m(0)],[...o.setLocal("last",o.i32_const(1)),...o.setLocal("carry",o.i32_const(0)),...m(0)]),o.if(o.getLocal("carry"),[...o.setLocal("last",o.i32_const(1)),...o.setLocal("carry",o.i32_const(0)),...m(0)],[...o.setLocal("last",o.i32_const(0)),...o.setLocal("carry",o.i32_const(0)),...m(0)]))),o.setLocal("i",o.i32_add(o.getLocal("i"),o.i32_const(1))),o.br(0))),o.if(o.getLocal("last"),o.if(o.getLocal("carry"),[...m(255),...m(0),...m(1)],[...m(1)]),o.if(o.getLocal("carry"),[...m(0),...m(1)])),o.setLocal("p",o.i32_sub(o.getLocal("p"),o.i32_const(1))),o.call(d,o.getLocal("base"),y),o.call(C,o.getLocal("r")),o.block(o.loop(o.call(s,o.getLocal("r"),o.getLocal("r")),o.setLocal("cur",o.i32_load8_u(o.getLocal("p"))),o.if(o.getLocal("cur"),o.if(o.i32_eq(o.getLocal("cur"),o.i32_const(1)),o.call(i,o.getLocal("r"),y,o.getLocal("r")),o.call(g,o.getLocal("r"),y,o.getLocal("r")))),o.br_if(1,o.i32_eq(o.getLocal("old0"),o.getLocal("p"))),o.setLocal("p",o.i32_sub(o.getLocal("p"),o.i32_const(1))),o.br(0))),o.i32_store(o.i32_const(0),o.getLocal("old0")))},ls=function(t,e,n,i,s){const d=t.modules[e].n64*8;function C(){const E=t.addFunction(n+"_getChunk");E.addParam("pScalar","i32"),E.addParam("scalarSize","i32"),E.addParam("startBit","i32"),E.addParam("chunkSize","i32"),E.addLocal("bitsToEnd","i32"),E.addLocal("mask","i32"),E.setReturnType("i32");const m=E.getCodeBuilder();E.addCode(m.setLocal("bitsToEnd",m.i32_sub(m.i32_mul(m.getLocal("scalarSize"),m.i32_const(8)),m.getLocal("startBit"))),m.if(m.i32_gt_s(m.getLocal("chunkSize"),m.getLocal("bitsToEnd")),m.setLocal("mask",m.i32_sub(m.i32_shl(m.i32_const(1),m.getLocal("bitsToEnd")),m.i32_const(1))),m.setLocal("mask",m.i32_sub(m.i32_shl(m.i32_const(1),m.getLocal("chunkSize")),m.i32_const(1)))),m.i32_and(m.i32_shr_u(m.i32_load(m.i32_add(m.getLocal("pScalar"),m.i32_shr_u(m.getLocal("startBit"),m.i32_const(3))),0,0),m.i32_and(m.getLocal("startBit"),m.i32_const(7))),m.getLocal("mask")))}function l(){const E=t.addFunction(n+"_chunk");E.addParam("pBases","i32"),E.addParam("pScalars","i32"),E.addParam("scalarSize","i32"),E.addParam("n","i32"),E.addParam("startBit","i32"),E.addParam("chunkSize","i32"),E.addParam("pr","i32"),E.addLocal("nChunks","i32"),E.addLocal("itScalar","i32"),E.addLocal("endScalar","i32"),E.addLocal("itBase","i32"),E.addLocal("i","i32"),E.addLocal("j","i32"),E.addLocal("nTable","i32"),E.addLocal("pTable","i32"),E.addLocal("idx","i32"),E.addLocal("pIdxTable","i32");const m=E.getCodeBuilder();E.addCode(m.if(m.i32_eqz(m.getLocal("n")),[...m.call(e+"_zero",m.getLocal("pr")),...m.ret([])]),m.setLocal("nTable",m.i32_shl(m.i32_const(1),m.getLocal("chunkSize"))),m.setLocal("pTable",m.i32_load(m.i32_const(0))),m.i32_store(m.i32_const(0),m.i32_add(m.getLocal("pTable"),m.i32_mul(m.getLocal("nTable"),m.i32_const(d)))),m.setLocal("j",m.i32_const(0)),m.block(m.loop(m.br_if(1,m.i32_eq(m.getLocal("j"),m.getLocal("nTable"))),m.call(e+"_zero",m.i32_add(m.getLocal("pTable"),m.i32_mul(m.getLocal("j"),m.i32_const(d)))),m.setLocal("j",m.i32_add(m.getLocal("j"),m.i32_const(1))),m.br(0))),m.setLocal("itBase",m.getLocal("pBases")),m.setLocal("itScalar",m.getLocal("pScalars")),m.setLocal("endScalar",m.i32_add(m.getLocal("pScalars"),m.i32_mul(m.getLocal("n"),m.getLocal("scalarSize")))),m.block(m.loop(m.br_if(1,m.i32_eq(m.getLocal("itScalar"),m.getLocal("endScalar"))),m.setLocal("idx",m.call(n+"_getChunk",m.getLocal("itScalar"),m.getLocal("scalarSize"),m.getLocal("startBit"),m.getLocal("chunkSize"))),m.if(m.getLocal("idx"),[...m.setLocal("pIdxTable",m.i32_add(m.getLocal("pTable"),m.i32_mul(m.i32_sub(m.getLocal("idx"),m.i32_const(1)),m.i32_const(d)))),...m.call(i,m.getLocal("pIdxTable"),m.getLocal("itBase"),m.getLocal("pIdxTable"))]),m.setLocal("itScalar",m.i32_add(m.getLocal("itScalar"),m.getLocal("scalarSize"))),m.setLocal("itBase",m.i32_add(m.getLocal("itBase"),m.i32_const(s))),m.br(0))),m.call(n+"_reduceTable",m.getLocal("pTable"),m.getLocal("chunkSize")),m.call(e+"_copy",m.getLocal("pTable"),m.getLocal("pr")),m.i32_store(m.i32_const(0),m.getLocal("pTable")))}function o(){const E=t.addFunction(n);E.addParam("pBases","i32"),E.addParam("pScalars","i32"),E.addParam("scalarSize","i32"),E.addParam("n","i32"),E.addParam("pr","i32"),E.addLocal("chunkSize","i32"),E.addLocal("nChunks","i32"),E.addLocal("itScalar","i32"),E.addLocal("endScalar","i32"),E.addLocal("itBase","i32"),E.addLocal("itBit","i32"),E.addLocal("i","i32"),E.addLocal("j","i32"),E.addLocal("nTable","i32"),E.addLocal("pTable","i32"),E.addLocal("idx","i32"),E.addLocal("pIdxTable","i32");const m=E.getCodeBuilder(),x=m.i32_const(t.alloc(d)),O=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]);E.addCode(m.call(e+"_zero",m.getLocal("pr")),m.if(m.i32_eqz(m.getLocal("n")),m.ret([])),m.setLocal("chunkSize",m.i32_load8_u(m.i32_clz(m.getLocal("n")),O)),m.setLocal("nChunks",m.i32_add(m.i32_div_u(m.i32_sub(m.i32_shl(m.getLocal("scalarSize"),m.i32_const(3)),m.i32_const(1)),m.getLocal("chunkSize")),m.i32_const(1))),m.setLocal("itBit",m.i32_mul(m.i32_sub(m.getLocal("nChunks"),m.i32_const(1)),m.getLocal("chunkSize"))),m.block(m.loop(m.br_if(1,m.i32_lt_s(m.getLocal("itBit"),m.i32_const(0))),m.if(m.i32_eqz(m.call(e+"_isZero",m.getLocal("pr"))),[...m.setLocal("j",m.i32_const(0)),...m.block(m.loop(m.br_if(1,m.i32_eq(m.getLocal("j"),m.getLocal("chunkSize"))),m.call(e+"_double",m.getLocal("pr"),m.getLocal("pr")),m.setLocal("j",m.i32_add(m.getLocal("j"),m.i32_const(1))),m.br(0)))]),m.call(n+"_chunk",m.getLocal("pBases"),m.getLocal("pScalars"),m.getLocal("scalarSize"),m.getLocal("n"),m.getLocal("itBit"),m.getLocal("chunkSize"),x),m.call(e+"_add",m.getLocal("pr"),x,m.getLocal("pr")),m.setLocal("itBit",m.i32_sub(m.getLocal("itBit"),m.getLocal("chunkSize"))),m.br(0))))}function y(){const E=t.addFunction(n+"_reduceTable");E.addParam("pTable","i32"),E.addParam("p","i32"),E.addLocal("half","i32"),E.addLocal("it1","i32"),E.addLocal("it2","i32"),E.addLocal("pAcc","i32");const m=E.getCodeBuilder();E.addCode(m.if(m.i32_eq(m.getLocal("p"),m.i32_const(1)),m.ret([])),m.setLocal("half",m.i32_shl(m.i32_const(1),m.i32_sub(m.getLocal("p"),m.i32_const(1)))),m.setLocal("it1",m.getLocal("pTable")),m.setLocal("it2",m.i32_add(m.getLocal("pTable"),m.i32_mul(m.getLocal("half"),m.i32_const(d)))),m.setLocal("pAcc",m.i32_sub(m.getLocal("it2"),m.i32_const(d))),m.block(m.loop(m.br_if(1,m.i32_eq(m.getLocal("it1"),m.getLocal("pAcc"))),m.call(e+"_add",m.getLocal("it1"),m.getLocal("it2"),m.getLocal("it1")),m.call(e+"_add",m.getLocal("pAcc"),m.getLocal("it2"),m.getLocal("pAcc")),m.setLocal("it1",m.i32_add(m.getLocal("it1"),m.i32_const(d))),m.setLocal("it2",m.i32_add(m.getLocal("it2"),m.i32_const(d))),m.br(0))),m.call(n+"_reduceTable",m.getLocal("pTable"),m.i32_sub(m.getLocal("p"),m.i32_const(1))),m.setLocal("p",m.i32_sub(m.getLocal("p"),m.i32_const(1))),m.block(m.loop(m.br_if(1,m.i32_eqz(m.getLocal("p"))),m.call(e+"_double",m.getLocal("pAcc"),m.getLocal("pAcc")),m.setLocal("p",m.i32_sub(m.getLocal("p"),m.i32_const(1))),m.br(0))),m.call(e+"_add",m.getLocal("pTable"),m.getLocal("pAcc"),m.getLocal("pTable")))}C(),y(),l(),o(),t.exportFunction(n),t.exportFunction(n+"_chunk")};const hi=rs,Me=fa,Li=ls;var Ca=function(t,e,n,i){const s=t.modules[n].n64,g=s*8;if(t.modules[e])return e;t.modules[e]={n64:s*3};function d(){const P=t.addFunction(e+"_isZero");P.addParam("p1","i32"),P.setReturnType("i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_isZero",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))))}function C(){const P=t.addFunction(e+"_isZeroAffine");P.addParam("p1","i32"),P.setReturnType("i32");const a=P.getCodeBuilder();P.addCode(a.i32_and(a.call(n+"_isZero",a.getLocal("p1")),a.call(n+"_isZero",a.i32_add(a.getLocal("p1"),a.i32_const(g)))))}function l(){const P=t.addFunction(e+"_copy");P.addParam("ps","i32"),P.addParam("pd","i32");const a=P.getCodeBuilder();for(let q=0;q<s*3;q++)P.addCode(a.i64_store(a.getLocal("pd"),q*8,a.i64_load(a.getLocal("ps"),q*8)))}function o(){const P=t.addFunction(e+"_copyAffine");P.addParam("ps","i32"),P.addParam("pd","i32");const a=P.getCodeBuilder();for(let q=0;q<s*2;q++)P.addCode(a.i64_store(a.getLocal("pd"),q*8,a.i64_load(a.getLocal("ps"),q*8)))}function y(){const P=t.addFunction(e+"_zero");P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_zero",a.getLocal("pr"))),P.addCode(a.call(n+"_one",a.i32_add(a.getLocal("pr"),a.i32_const(g)))),P.addCode(a.call(n+"_zero",a.i32_add(a.getLocal("pr"),a.i32_const(g*2))))}function E(){const P=t.addFunction(e+"_zeroAffine");P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_zero",a.getLocal("pr"))),P.addCode(a.call(n+"_zero",a.i32_add(a.getLocal("pr"),a.i32_const(g))))}function m(){const P=t.addFunction(e+"_eq");P.addParam("p1","i32"),P.addParam("p2","i32"),P.setReturnType("i32"),P.addLocal("z1","i32"),P.addLocal("z2","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g));P.addCode(a.setLocal("z1",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))));const W=a.getLocal("z1"),z=a.getLocal("p2"),b=a.i32_add(a.getLocal("p2"),a.i32_const(g));P.addCode(a.setLocal("z2",a.i32_add(a.getLocal("p2"),a.i32_const(g*2))));const at=a.getLocal("z2"),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g)),Ot=a.i32_const(t.alloc(g)),jt=a.i32_const(t.alloc(g)),Et=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),a.ret(a.call(e+"_isZero",a.getLocal("p2")))),a.if(a.call(e+"_isZero",a.getLocal("p2")),a.ret(a.i32_const(0))),a.if(a.call(n+"_isOne",W),a.ret(a.call(e+"_eqMixed",a.getLocal("p2"),a.getLocal("p1")))),a.if(a.call(n+"_isOne",at),a.ret(a.call(e+"_eqMixed",a.getLocal("p1"),a.getLocal("p2")))),a.call(n+"_square",W,At),a.call(n+"_square",at,Lt),a.call(n+"_mul",q,Lt,yt),a.call(n+"_mul",z,At,It),a.call(n+"_mul",W,At,mt),a.call(n+"_mul",at,Lt,Ot),a.call(n+"_mul",u,Ot,jt),a.call(n+"_mul",b,mt,Et),a.if(a.call(n+"_eq",yt,It),a.if(a.call(n+"_eq",jt,Et),a.ret(a.i32_const(1)))),a.ret(a.i32_const(0)))}function x(){const P=t.addFunction(e+"_eqMixed");P.addParam("p1","i32"),P.addParam("p2","i32"),P.setReturnType("i32"),P.addLocal("z1","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g));P.addCode(a.setLocal("z1",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))));const W=a.getLocal("z1"),z=a.getLocal("p2"),b=a.i32_add(a.getLocal("p2"),a.i32_const(g)),at=a.i32_const(t.alloc(g)),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),a.ret(a.call(e+"_isZeroAffine",a.getLocal("p2")))),a.if(a.call(e+"_isZeroAffine",a.getLocal("p2")),a.ret(a.i32_const(0))),a.if(a.call(n+"_isOne",W),a.ret(a.call(e+"_eqAffine",a.getLocal("p1"),a.getLocal("p2")))),a.call(n+"_square",W,at),a.call(n+"_mul",z,at,At),a.call(n+"_mul",W,at,Lt),a.call(n+"_mul",b,Lt,yt),a.if(a.call(n+"_eq",q,At),a.if(a.call(n+"_eq",u,yt),a.ret(a.i32_const(1)))),a.ret(a.i32_const(0)))}function O(){const P=t.addFunction(e+"_double");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.i32_add(a.getLocal("p1"),a.i32_const(g*2)),z=a.getLocal("pr"),b=a.i32_add(a.getLocal("pr"),a.i32_const(g)),at=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g)),Ot=a.i32_const(t.alloc(g)),jt=a.i32_const(t.alloc(g)),Et=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),[...a.call(e+"_copy",a.getLocal("p1"),a.getLocal("pr")),...a.ret([])]),a.if(a.call(n+"_isOne",W),[...a.ret(a.call(e+"_doubleAffine",a.getLocal("p1"),a.getLocal("pr"))),...a.ret([])]),a.call(n+"_square",q,At),a.call(n+"_square",u,Lt),a.call(n+"_square",Lt,yt),a.call(n+"_add",q,Lt,It),a.call(n+"_square",It,It),a.call(n+"_sub",It,At,It),a.call(n+"_sub",It,yt,It),a.call(n+"_add",It,It,It),a.call(n+"_add",At,At,mt),a.call(n+"_add",mt,At,mt),a.call(n+"_square",mt,Ot),a.call(n+"_mul",u,W,jt),a.call(n+"_add",It,It,z),a.call(n+"_sub",Ot,z,z),a.call(n+"_add",yt,yt,Et),a.call(n+"_add",Et,Et,Et),a.call(n+"_add",Et,Et,Et),a.call(n+"_sub",It,z,b),a.call(n+"_mul",b,mt,b),a.call(n+"_sub",b,Et,b),a.call(n+"_add",jt,jt,at))}function L(){const P=t.addFunction(e+"_doubleAffine");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.getLocal("pr"),z=a.i32_add(a.getLocal("pr"),a.i32_const(g)),b=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),at=a.i32_const(t.alloc(g)),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZeroAffine",a.getLocal("p1")),[...a.call(e+"_toJacobian",a.getLocal("p1"),a.getLocal("pr")),...a.ret([])]),a.call(n+"_square",q,at),a.call(n+"_square",u,At),a.call(n+"_square",At,Lt),a.call(n+"_add",q,At,yt),a.call(n+"_square",yt,yt),a.call(n+"_sub",yt,at,yt),a.call(n+"_sub",yt,Lt,yt),a.call(n+"_add",yt,yt,yt),a.call(n+"_add",at,at,It),a.call(n+"_add",It,at,It),a.call(n+"_add",u,u,b),a.call(n+"_square",It,W),a.call(n+"_sub",W,yt,W),a.call(n+"_sub",W,yt,W),a.call(n+"_add",Lt,Lt,mt),a.call(n+"_add",mt,mt,mt),a.call(n+"_add",mt,mt,mt),a.call(n+"_sub",yt,W,z),a.call(n+"_mul",z,It,z),a.call(n+"_sub",z,mt,z))}function I(){const P=t.addFunction(e+"_eqAffine");P.addParam("p1","i32"),P.addParam("p2","i32"),P.setReturnType("i32"),P.addLocal("z1","i32");const a=P.getCodeBuilder();P.addCode(a.ret(a.i32_and(a.call(n+"_eq",a.getLocal("p1"),a.getLocal("p2")),a.call(n+"_eq",a.i32_add(a.getLocal("p1"),a.i32_const(g)),a.i32_add(a.getLocal("p2"),a.i32_const(g))))))}function v(){const P=t.addFunction(e+"_toMontgomery");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_toMontgomery",a.getLocal("p1"),a.getLocal("pr")));for(let q=1;q<3;q++)P.addCode(a.call(n+"_toMontgomery",a.i32_add(a.getLocal("p1"),a.i32_const(q*g)),a.i32_add(a.getLocal("pr"),a.i32_const(q*g))))}function U(){const P=t.addFunction(e+"_toMontgomeryAffine");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_toMontgomery",a.getLocal("p1"),a.getLocal("pr")));for(let q=1;q<2;q++)P.addCode(a.call(n+"_toMontgomery",a.i32_add(a.getLocal("p1"),a.i32_const(q*g)),a.i32_add(a.getLocal("pr"),a.i32_const(q*g))))}function w(){const P=t.addFunction(e+"_fromMontgomery");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_fromMontgomery",a.getLocal("p1"),a.getLocal("pr")));for(let q=1;q<3;q++)P.addCode(a.call(n+"_fromMontgomery",a.i32_add(a.getLocal("p1"),a.i32_const(q*g)),a.i32_add(a.getLocal("pr"),a.i32_const(q*g))))}function S(){const P=t.addFunction(e+"_fromMontgomeryAffine");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder();P.addCode(a.call(n+"_fromMontgomery",a.getLocal("p1"),a.getLocal("pr")));for(let q=1;q<2;q++)P.addCode(a.call(n+"_fromMontgomery",a.i32_add(a.getLocal("p1"),a.i32_const(q*g)),a.i32_add(a.getLocal("pr"),a.i32_const(q*g))))}function F(){const P=t.addFunction(e+"_add");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32"),P.addLocal("z1","i32"),P.addLocal("z2","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g));P.addCode(a.setLocal("z1",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))));const W=a.getLocal("z1"),z=a.getLocal("p2"),b=a.i32_add(a.getLocal("p2"),a.i32_const(g));P.addCode(a.setLocal("z2",a.i32_add(a.getLocal("p2"),a.i32_const(g*2))));const at=a.getLocal("z2"),At=a.getLocal("pr"),Lt=a.i32_add(a.getLocal("pr"),a.i32_const(g)),yt=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g)),Ot=a.i32_const(t.alloc(g)),jt=a.i32_const(t.alloc(g)),Et=a.i32_const(t.alloc(g)),bt=a.i32_const(t.alloc(g)),pt=a.i32_const(t.alloc(g)),$t=a.i32_const(t.alloc(g)),Jt=a.i32_const(t.alloc(g)),re=a.i32_const(t.alloc(g)),te=a.i32_const(t.alloc(g)),Pt=a.i32_const(t.alloc(g)),Mt=a.i32_const(t.alloc(g)),Zt=a.i32_const(t.alloc(g)),vt=a.i32_const(t.alloc(g)),Wt=a.i32_const(t.alloc(g)),wt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),[...a.call(e+"_copy",a.getLocal("p2"),a.getLocal("pr")),...a.ret([])]),a.if(a.call(e+"_isZero",a.getLocal("p2")),[...a.call(e+"_copy",a.getLocal("p1"),a.getLocal("pr")),...a.ret([])]),a.if(a.call(n+"_isOne",W),[...a.call(e+"_addMixed",z,q,At),...a.ret([])]),a.if(a.call(n+"_isOne",at),[...a.call(e+"_addMixed",q,z,At),...a.ret([])]),a.call(n+"_square",W,It),a.call(n+"_square",at,mt),a.call(n+"_mul",q,mt,Ot),a.call(n+"_mul",z,It,jt),a.call(n+"_mul",W,It,Et),a.call(n+"_mul",at,mt,bt),a.call(n+"_mul",u,bt,pt),a.call(n+"_mul",b,Et,$t),a.if(a.call(n+"_eq",Ot,jt),a.if(a.call(n+"_eq",pt,$t),[...a.call(e+"_double",a.getLocal("p1"),a.getLocal("pr")),...a.ret([])])),a.call(n+"_sub",jt,Ot,Jt),a.call(n+"_sub",$t,pt,re),a.call(n+"_add",Jt,Jt,te),a.call(n+"_square",te,te),a.call(n+"_mul",Jt,te,Pt),a.call(n+"_add",re,re,Mt),a.call(n+"_mul",Ot,te,vt),a.call(n+"_square",Mt,Zt),a.call(n+"_add",vt,vt,Wt),a.call(n+"_sub",Zt,Pt,At),a.call(n+"_sub",At,Wt,At),a.call(n+"_mul",pt,Pt,wt),a.call(n+"_add",wt,wt,wt),a.call(n+"_sub",vt,At,Lt),a.call(n+"_mul",Lt,Mt,Lt),a.call(n+"_sub",Lt,wt,Lt),a.call(n+"_add",W,at,yt),a.call(n+"_square",yt,yt),a.call(n+"_sub",yt,It,yt),a.call(n+"_sub",yt,mt,yt),a.call(n+"_mul",yt,Jt,yt))}function r(){const P=t.addFunction(e+"_addMixed");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32"),P.addLocal("z1","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g));P.addCode(a.setLocal("z1",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))));const W=a.getLocal("z1"),z=a.getLocal("p2"),b=a.i32_add(a.getLocal("p2"),a.i32_const(g)),at=a.getLocal("pr"),At=a.i32_add(a.getLocal("pr"),a.i32_const(g)),Lt=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),yt=a.i32_const(t.alloc(g)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g)),Ot=a.i32_const(t.alloc(g)),jt=a.i32_const(t.alloc(g)),Et=a.i32_const(t.alloc(g)),bt=a.i32_const(t.alloc(g)),pt=a.i32_const(t.alloc(g)),$t=a.i32_const(t.alloc(g)),Jt=a.i32_const(t.alloc(g)),re=a.i32_const(t.alloc(g)),te=a.i32_const(t.alloc(g)),Pt=a.i32_const(t.alloc(g)),Mt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),[...a.call(e+"_copyAffine",a.getLocal("p2"),a.getLocal("pr")),...a.call(n+"_one",a.i32_add(a.getLocal("pr"),a.i32_const(g*2))),...a.ret([])]),a.if(a.call(e+"_isZeroAffine",a.getLocal("p2")),[...a.call(e+"_copy",a.getLocal("p1"),a.getLocal("pr")),...a.ret([])]),a.if(a.call(n+"_isOne",W),[...a.call(e+"_addAffine",q,z,at),...a.ret([])]),a.call(n+"_square",W,yt),a.call(n+"_mul",z,yt,It),a.call(n+"_mul",W,yt,mt),a.call(n+"_mul",b,mt,Ot),a.if(a.call(n+"_eq",q,It),a.if(a.call(n+"_eq",u,Ot),[...a.call(e+"_doubleAffine",a.getLocal("p2"),a.getLocal("pr")),...a.ret([])])),a.call(n+"_sub",It,q,jt),a.call(n+"_sub",Ot,u,bt),a.call(n+"_square",jt,Et),a.call(n+"_add",Et,Et,pt),a.call(n+"_add",pt,pt,pt),a.call(n+"_mul",jt,pt,$t),a.call(n+"_add",bt,bt,Jt),a.call(n+"_mul",q,pt,te),a.call(n+"_square",Jt,re),a.call(n+"_add",te,te,Pt),a.call(n+"_sub",re,$t,at),a.call(n+"_sub",at,Pt,at),a.call(n+"_mul",u,$t,Mt),a.call(n+"_add",Mt,Mt,Mt),a.call(n+"_sub",te,at,At),a.call(n+"_mul",At,Jt,At),a.call(n+"_sub",At,Mt,At),a.call(n+"_add",W,jt,Lt),a.call(n+"_square",Lt,Lt),a.call(n+"_sub",Lt,yt,Lt),a.call(n+"_sub",Lt,Et,Lt))}function h(){const P=t.addFunction(e+"_addAffine");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32"),P.addLocal("z1","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g));P.addCode(a.setLocal("z1",a.i32_add(a.getLocal("p1"),a.i32_const(g*2))));const W=a.getLocal("p2"),z=a.i32_add(a.getLocal("p2"),a.i32_const(g)),b=a.getLocal("pr"),at=a.i32_add(a.getLocal("pr"),a.i32_const(g)),At=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g)),It=a.i32_const(t.alloc(g)),mt=a.i32_const(t.alloc(g)),Ot=a.i32_const(t.alloc(g)),jt=a.i32_const(t.alloc(g)),Et=a.i32_const(t.alloc(g)),bt=a.i32_const(t.alloc(g)),pt=a.i32_const(t.alloc(g)),$t=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZeroAffine",a.getLocal("p1")),[...a.call(e+"_copyAffine",a.getLocal("p2"),a.getLocal("pr")),...a.call(n+"_one",a.i32_add(a.getLocal("pr"),a.i32_const(g*2))),...a.ret([])]),a.if(a.call(e+"_isZeroAffine",a.getLocal("p2")),[...a.call(e+"_copyAffine",a.getLocal("p1"),a.getLocal("pr")),...a.call(n+"_one",a.i32_add(a.getLocal("pr"),a.i32_const(g*2))),...a.ret([])]),a.if(a.call(n+"_eq",q,W),a.if(a.call(n+"_eq",u,z),[...a.call(e+"_doubleAffine",a.getLocal("p2"),a.getLocal("pr")),...a.ret([])])),a.call(n+"_sub",W,q,Lt),a.call(n+"_sub",z,u,It),a.call(n+"_square",Lt,yt),a.call(n+"_add",yt,yt,mt),a.call(n+"_add",mt,mt,mt),a.call(n+"_mul",Lt,mt,Ot),a.call(n+"_add",It,It,jt),a.call(n+"_mul",q,mt,bt),a.call(n+"_square",jt,Et),a.call(n+"_add",bt,bt,pt),a.call(n+"_sub",Et,Ot,b),a.call(n+"_sub",b,pt,b),a.call(n+"_mul",u,Ot,$t),a.call(n+"_add",$t,$t,$t),a.call(n+"_sub",bt,b,at),a.call(n+"_mul",at,jt,at),a.call(n+"_sub",at,$t,at),a.call(n+"_add",Lt,Lt,At))}function R(){const P=t.addFunction(e+"_neg");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.i32_add(a.getLocal("p1"),a.i32_const(g*2)),z=a.getLocal("pr"),b=a.i32_add(a.getLocal("pr"),a.i32_const(g)),at=a.i32_add(a.getLocal("pr"),a.i32_const(g*2));P.addCode(a.call(n+"_copy",q,z),a.call(n+"_neg",u,b),a.call(n+"_copy",W,at))}function j(){const P=t.addFunction(e+"_negAffine");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.getLocal("pr"),z=a.i32_add(a.getLocal("pr"),a.i32_const(g));P.addCode(a.call(n+"_copy",q,W),a.call(n+"_neg",u,z))}function T(){const P=t.addFunction(e+"_sub");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g*3));P.addCode(a.call(e+"_neg",a.getLocal("p2"),q),a.call(e+"_add",a.getLocal("p1"),q,a.getLocal("pr")))}function M(){const P=t.addFunction(e+"_subMixed");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g*3));P.addCode(a.call(e+"_negAffine",a.getLocal("p2"),q),a.call(e+"_addMixed",a.getLocal("p1"),q,a.getLocal("pr")))}function A(){const P=t.addFunction(e+"_subAffine");P.addParam("p1","i32"),P.addParam("p2","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g*3));P.addCode(a.call(e+"_negAffine",a.getLocal("p2"),q),a.call(e+"_addAffine",a.getLocal("p1"),q,a.getLocal("pr")))}function D(){const P=t.addFunction(e+"_normalize");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.i32_add(a.getLocal("p1"),a.i32_const(g*2)),z=a.getLocal("pr"),b=a.i32_add(a.getLocal("pr"),a.i32_const(g)),at=a.i32_add(a.getLocal("pr"),a.i32_const(g*2)),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g)),yt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),a.call(e+"_zero",a.getLocal("pr")),[...a.call(n+"_inverse",W,At),...a.call(n+"_square",At,Lt),...a.call(n+"_mul",At,Lt,yt),...a.call(n+"_mul",q,Lt,z),...a.call(n+"_mul",u,yt,b),...a.call(n+"_one",at)]))}function H(){const P=t.addFunction(e+"_toAffine");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.i32_add(a.getLocal("p1"),a.i32_const(g*2)),z=a.getLocal("pr"),b=a.i32_add(a.getLocal("pr"),a.i32_const(g)),at=a.i32_const(t.alloc(g)),At=a.i32_const(t.alloc(g)),Lt=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("p1")),[...a.call(n+"_zero",z),...a.call(n+"_zero",b)],[...a.call(n+"_inverse",W,at),...a.call(n+"_square",at,At),...a.call(n+"_mul",at,At,Lt),...a.call(n+"_mul",q,At,z),...a.call(n+"_mul",u,Lt,b)]))}function ut(){const P=t.addFunction(e+"_toJacobian");P.addParam("p1","i32"),P.addParam("pr","i32");const a=P.getCodeBuilder(),q=a.getLocal("p1"),u=a.i32_add(a.getLocal("p1"),a.i32_const(g)),W=a.getLocal("pr"),z=a.i32_add(a.getLocal("pr"),a.i32_const(g)),b=a.i32_add(a.getLocal("pr"),a.i32_const(g*2));P.addCode(a.if(a.call(e+"_isZeroAffine",a.getLocal("p1")),a.call(e+"_zero",a.getLocal("pr")),[...a.call(n+"_one",b),...a.call(n+"_copy",u,z),...a.call(n+"_copy",q,W)]))}function nt(){const P=t.addFunction(e+"_batchToAffine");P.addParam("pIn","i32"),P.addParam("n","i32"),P.addParam("pOut","i32"),P.addLocal("pAux","i32"),P.addLocal("itIn","i32"),P.addLocal("itAux","i32"),P.addLocal("itOut","i32"),P.addLocal("i","i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g));P.addCode(a.setLocal("pAux",a.i32_load(a.i32_const(0))),a.i32_store(a.i32_const(0),a.i32_add(a.getLocal("pAux"),a.i32_mul(a.getLocal("n"),a.i32_const(g)))),a.call(n+"_batchInverse",a.i32_add(a.getLocal("pIn"),a.i32_const(g*2)),a.i32_const(g*3),a.getLocal("n"),a.getLocal("pAux"),a.i32_const(g)),a.setLocal("itIn",a.getLocal("pIn")),a.setLocal("itAux",a.getLocal("pAux")),a.setLocal("itOut",a.getLocal("pOut")),a.setLocal("i",a.i32_const(0)),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal("i"),a.getLocal("n"))),a.if(a.call(n+"_isZero",a.getLocal("itAux")),[...a.call(n+"_zero",a.getLocal("itOut")),...a.call(n+"_zero",a.i32_add(a.getLocal("itOut"),a.i32_const(g)))],[...a.call(n+"_mul",a.getLocal("itAux"),a.i32_add(a.getLocal("itIn"),a.i32_const(g)),q),...a.call(n+"_square",a.getLocal("itAux"),a.getLocal("itAux")),...a.call(n+"_mul",a.getLocal("itAux"),a.getLocal("itIn"),a.getLocal("itOut")),...a.call(n+"_mul",a.getLocal("itAux"),q,a.i32_add(a.getLocal("itOut"),a.i32_const(g)))]),a.setLocal("itIn",a.i32_add(a.getLocal("itIn"),a.i32_const(g*3))),a.setLocal("itOut",a.i32_add(a.getLocal("itOut"),a.i32_const(g*2))),a.setLocal("itAux",a.i32_add(a.getLocal("itAux"),a.i32_const(g))),a.setLocal("i",a.i32_add(a.getLocal("i"),a.i32_const(1))),a.br(0))),a.i32_store(a.i32_const(0),a.getLocal("pAux")))}function J(){const P=t.addFunction(e+"__reverseBytes");P.addParam("pIn","i32"),P.addParam("n","i32"),P.addParam("pOut","i32"),P.addLocal("itOut","i32"),P.addLocal("itIn","i32");const a=P.getCodeBuilder();P.addCode(a.setLocal("itOut",a.i32_sub(a.i32_add(a.getLocal("pOut"),a.getLocal("n")),a.i32_const(1))),a.setLocal("itIn",a.getLocal("pIn")),a.block(a.loop(a.br_if(1,a.i32_lt_s(a.getLocal("itOut"),a.getLocal("pOut"))),a.i32_store8(a.getLocal("itOut"),a.i32_load8_u(a.getLocal("itIn"))),a.setLocal("itOut",a.i32_sub(a.getLocal("itOut"),a.i32_const(1))),a.setLocal("itIn",a.i32_add(a.getLocal("itIn"),a.i32_const(1))),a.br(0))))}function ft(){const P=t.addFunction(e+"_LEMtoC");P.addParam("pIn","i32"),P.addParam("pOut","i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g));P.addCode(a.if(a.call(e+"_isZero",a.getLocal("pIn")),[...a.call(n+"_zero",a.getLocal("pOut")),...a.i32_store8(a.getLocal("pOut"),a.i32_const(64)),...a.ret([])]),a.call(n+"_fromMontgomery",a.getLocal("pIn"),q),a.call(e+"__reverseBytes",q,a.i32_const(g),a.getLocal("pOut")),a.if(a.i32_eq(a.call(n+"_sign",a.i32_add(a.getLocal("pIn"),a.i32_const(g))),a.i32_const(-1)),a.i32_store8(a.getLocal("pOut"),a.i32_or(a.i32_load8_u(a.getLocal("pOut")),a.i32_const(128)))))}function it(){const P=t.addFunction(e+"_LEMtoU");P.addParam("pIn","i32"),P.addParam("pOut","i32");const a=P.getCodeBuilder(),q=t.alloc(g*2),u=a.i32_const(q),W=a.i32_const(q),z=a.i32_const(q+g);P.addCode(a.if(a.call(e+"_isZeroAffine",a.getLocal("pIn")),[...a.call(e+"_zeroAffine",a.getLocal("pOut")),...a.i32_store8(a.getLocal("pOut"),a.i32_const(64)),...a.ret([])]),a.call(e+"_fromMontgomeryAffine",a.getLocal("pIn"),u),a.call(e+"__reverseBytes",W,a.i32_const(g),a.getLocal("pOut")),a.call(e+"__reverseBytes",z,a.i32_const(g),a.i32_add(a.getLocal("pOut"),a.i32_const(g))))}function _t(){const P=t.addFunction(e+"_UtoLEM");P.addParam("pIn","i32"),P.addParam("pOut","i32");const a=P.getCodeBuilder(),q=t.alloc(g*2),u=a.i32_const(q),W=a.i32_const(q),z=a.i32_const(q+g);P.addCode(a.if(a.i32_and(a.i32_load8_u(a.getLocal("pIn")),a.i32_const(64)),[...a.call(e+"_zeroAffine",a.getLocal("pOut")),...a.ret([])]),a.call(e+"__reverseBytes",a.getLocal("pIn"),a.i32_const(g),W),a.call(e+"__reverseBytes",a.i32_add(a.getLocal("pIn"),a.i32_const(g)),a.i32_const(g),z),a.call(e+"_toMontgomeryAffine",u,a.getLocal("pOut")))}function zt(){const P=t.addFunction(e+"_CtoLEM");P.addParam("pIn","i32"),P.addParam("pOut","i32"),P.addLocal("firstByte","i32"),P.addLocal("greatest","i32");const a=P.getCodeBuilder(),q=t.alloc(g*2),u=a.i32_const(q),W=a.i32_const(q+g);P.addCode(a.setLocal("firstByte",a.i32_load8_u(a.getLocal("pIn"))),a.if(a.i32_and(a.getLocal("firstByte"),a.i32_const(64)),[...a.call(e+"_zeroAffine",a.getLocal("pOut")),...a.ret([])]),a.setLocal("greatest",a.i32_and(a.getLocal("firstByte"),a.i32_const(128))),a.call(n+"_copy",a.getLocal("pIn"),W),a.i32_store8(W,a.i32_and(a.getLocal("firstByte"),a.i32_const(63))),a.call(e+"__reverseBytes",W,a.i32_const(g),u),a.call(n+"_toMontgomery",u,a.getLocal("pOut")),a.call(n+"_square",a.getLocal("pOut"),W),a.call(n+"_mul",a.getLocal("pOut"),W,W),a.call(n+"_add",W,a.i32_const(i),W),a.call(n+"_sqrt",W,W),a.call(n+"_neg",W,u),a.if(a.i32_eq(a.call(n+"_sign",W),a.i32_const(-1)),a.if(a.getLocal("greatest"),a.call(n+"_copy",W,a.i32_add(a.getLocal("pOut"),a.i32_const(g))),a.call(n+"_neg",W,a.i32_add(a.getLocal("pOut"),a.i32_const(g)))),a.if(a.getLocal("greatest"),a.call(n+"_neg",W,a.i32_add(a.getLocal("pOut"),a.i32_const(g))),a.call(n+"_copy",W,a.i32_add(a.getLocal("pOut"),a.i32_const(g))))))}function G(){const P=t.addFunction(e+"_inCurveAffine");P.addParam("pIn","i32"),P.setReturnType("i32");const a=P.getCodeBuilder(),q=a.getLocal("pIn"),u=a.i32_add(a.getLocal("pIn"),a.i32_const(g)),W=a.i32_const(t.alloc(g)),z=a.i32_const(t.alloc(g));P.addCode(a.call(n+"_square",u,W),a.call(n+"_square",q,z),a.call(n+"_mul",q,z,z),a.call(n+"_add",z,a.i32_const(i),z),a.ret(a.call(n+"_eq",W,z)))}function K(){const P=t.addFunction(e+"_inCurve");P.addParam("pIn","i32"),P.setReturnType("i32");const a=P.getCodeBuilder(),q=a.i32_const(t.alloc(g*2));P.addCode(a.call(e+"_toAffine",a.getLocal("pIn"),q),a.ret(a.call(e+"_inCurveAffine",q)))}return C(),d(),E(),y(),o(),l(),ut(),I(),x(),m(),L(),O(),h(),r(),F(),j(),R(),A(),M(),T(),S(),w(),U(),v(),H(),G(),K(),nt(),D(),J(),it(),ft(),_t(),zt(),Me(t,e+"_batchLEMtoU",e+"_LEMtoU",g*2,g*2),Me(t,e+"_batchLEMtoC",e+"_LEMtoC",g*2,g),Me(t,e+"_batchUtoLEM",e+"_UtoLEM",g*2,g*2),Me(t,e+"_batchCtoLEM",e+"_CtoLEM",g,g*2,!0),Me(t,e+"_batchToJacobian",e+"_toJacobian",g*2,g*3,!0),Li(t,e,e+"_multiexp",e+"_add",g*3),Li(t,e,e+"_multiexpAffine",e+"_addMixed",g*2),hi(t,e+"_timesScalar",g*3,e+"_add",e+"_double",e+"_sub",e+"_copy",e+"_zero"),hi(t,e+"_timesScalarAffine",g*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:us,modInv:mi,modPow:De}=le,Ke=ye;var Aa=function(t,e,n,i,s){const d=t.modules[i].n64*8,l=t.modules[n].n64*8,o=t.modules[i].q;let y=o-1n,E=0;for(;!us(y);)E++,y=y>>1n;let m=2n;for(;De(m,o>>1n,o)===1n;)m=m+1n;const x=new Array(E+1);x[E]=De(m,y,o);let O=E-1;for(;O>=0;)x[O]=De(x[O+1],2n,o),O--;const L=[],I=(1n<<BigInt(d*8))%o;for(let q=0;q<x.length;q++){const u=x[q]*I%o;L.push(...Ke.bigInt2BytesLE(u,d))}const v=t.alloc(L),U=new Array(E+1);U[0]=1n;for(let q=1;q<=E;q++)U[q]=U[q-1]*2n;const w=[];for(let q=0;q<=E;q++){const u=mi(U[q],o)*I%o;w.push(...Ke.bigInt2BytesLE(u,d))}const S=t.alloc(w),F=De(m,2n,o),r=[],h=[];for(let q=0;q<=E;q++){const u=De(F,2n**BigInt(q),o),W=mi(o+1n-u,o);r.push(...Ke.bigInt2BytesLE(u*I%o,d)),h.push(...Ke.bigInt2BytesLE(W*I%o,d))}const R=t.alloc(r),j=t.alloc(h);function T(q){let u=0;for(let W=0;W<8;W++)q&1<<W&&(u=u|128>>W);return u}const M=Array(256);for(let q=0;q<256;q++)M[q]=T(q);const A=t.alloc(M);function D(){const q=t.addFunction(e+"__log2");q.addParam("n","i32"),q.setReturnType("i32"),q.addLocal("bits","i32"),q.addLocal("aux","i32");const u=q.getCodeBuilder();q.addCode(u.setLocal("aux",u.i32_shr_u(u.getLocal("n"),u.i32_const(1)))),q.addCode(u.setLocal("bits",u.i32_const(0))),q.addCode(u.block(u.loop(u.br_if(1,u.i32_eqz(u.getLocal("aux"))),u.setLocal("aux",u.i32_shr_u(u.getLocal("aux"),u.i32_const(1))),u.setLocal("bits",u.i32_add(u.getLocal("bits"),u.i32_const(1))),u.br(0)))),q.addCode(u.if(u.i32_ne(u.getLocal("n"),u.i32_shl(u.i32_const(1),u.getLocal("bits"))),u.unreachable())),q.addCode(u.if(u.i32_gt_u(u.getLocal("bits"),u.i32_const(E)),u.unreachable())),q.addCode(u.getLocal("bits"))}function H(){const q=t.addFunction(e+"_fft");q.addParam("px","i32"),q.addParam("n","i32"),q.addLocal("bits","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d));q.addCode(u.setLocal("bits",u.call(e+"__log2",u.getLocal("n"))),u.call(i+"_one",W),u.call(e+"_rawfft",u.getLocal("px"),u.getLocal("bits"),u.i32_const(0),W))}function ut(){const q=t.addFunction(e+"_ifft");q.addParam("px","i32"),q.addParam("n","i32"),q.addLocal("bits","i32"),q.addLocal("pInv2","i32");const u=q.getCodeBuilder();q.addCode(u.setLocal("bits",u.call(e+"__log2",u.getLocal("n"))),u.setLocal("pInv2",u.i32_add(u.i32_const(S),u.i32_mul(u.getLocal("bits"),u.i32_const(d)))),u.call(e+"_rawfft",u.getLocal("px"),u.getLocal("bits"),u.i32_const(1),u.getLocal("pInv2")))}function nt(){const q=t.addFunction(e+"_rawfft");q.addParam("px","i32"),q.addParam("bits","i32"),q.addParam("reverse","i32"),q.addParam("mulFactor","i32"),q.addLocal("s","i32"),q.addLocal("k","i32"),q.addLocal("j","i32"),q.addLocal("m","i32"),q.addLocal("mdiv2","i32"),q.addLocal("n","i32"),q.addLocal("pwm","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l)),b=u.i32_const(t.alloc(l));q.addCode(u.call(e+"__reversePermutation",u.getLocal("px"),u.getLocal("bits")),u.setLocal("n",u.i32_shl(u.i32_const(1),u.getLocal("bits"))),u.setLocal("s",u.i32_const(1)),u.block(u.loop(u.br_if(1,u.i32_gt_u(u.getLocal("s"),u.getLocal("bits"))),u.setLocal("m",u.i32_shl(u.i32_const(1),u.getLocal("s"))),u.setLocal("pwm",u.i32_add(u.i32_const(v),u.i32_mul(u.getLocal("s"),u.i32_const(d)))),u.setLocal("k",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_ge_u(u.getLocal("k"),u.getLocal("n"))),u.call(i+"_one",W),u.setLocal("mdiv2",u.i32_shr_u(u.getLocal("m"),u.i32_const(1))),u.setLocal("j",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_ge_u(u.getLocal("j"),u.getLocal("mdiv2"))),u.setLocal("idx1",u.i32_add(u.getLocal("px"),u.i32_mul(u.i32_add(u.getLocal("k"),u.getLocal("j")),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("idx1"),u.i32_mul(u.getLocal("mdiv2"),u.i32_const(l)))),u.call(s,u.getLocal("idx2"),W,z),u.call(n+"_copy",u.getLocal("idx1"),b),u.call(n+"_add",b,z,u.getLocal("idx1")),u.call(n+"_sub",b,z,u.getLocal("idx2")),u.call(i+"_mul",W,u.getLocal("pwm"),W),u.setLocal("j",u.i32_add(u.getLocal("j"),u.i32_const(1))),u.br(0))),u.setLocal("k",u.i32_add(u.getLocal("k"),u.getLocal("m"))),u.br(0))),u.setLocal("s",u.i32_add(u.getLocal("s"),u.i32_const(1))),u.br(0))),u.call(e+"__fftFinal",u.getLocal("px"),u.getLocal("bits"),u.getLocal("reverse"),u.getLocal("mulFactor")))}function J(){const q=t.addFunction(e+"__fftFinal");q.addParam("px","i32"),q.addParam("bits","i32"),q.addParam("reverse","i32"),q.addParam("mulFactor","i32"),q.addLocal("n","i32"),q.addLocal("ndiv2","i32"),q.addLocal("pInv2","i32"),q.addLocal("i","i32"),q.addLocal("mask","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(l));q.addCode(u.if(u.i32_and(u.i32_eqz(u.getLocal("reverse")),u.call(i+"_isOne",u.getLocal("mulFactor"))),u.ret([])),u.setLocal("n",u.i32_shl(u.i32_const(1),u.getLocal("bits"))),u.setLocal("mask",u.i32_sub(u.getLocal("n"),u.i32_const(1))),u.setLocal("i",u.i32_const(1)),u.setLocal("ndiv2",u.i32_shr_u(u.getLocal("n"),u.i32_const(1))),u.block(u.loop(u.br_if(1,u.i32_ge_u(u.getLocal("i"),u.getLocal("ndiv2"))),u.setLocal("idx1",u.i32_add(u.getLocal("px"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("px"),u.i32_mul(u.i32_sub(u.getLocal("n"),u.getLocal("i")),u.i32_const(l)))),u.if(u.getLocal("reverse"),u.if(u.call(i+"_isOne",u.getLocal("mulFactor")),[...u.call(n+"_copy",u.getLocal("idx1"),W),...u.call(n+"_copy",u.getLocal("idx2"),u.getLocal("idx1")),...u.call(n+"_copy",W,u.getLocal("idx2"))],[...u.call(n+"_copy",u.getLocal("idx1"),W),...u.call(s,u.getLocal("idx2"),u.getLocal("mulFactor"),u.getLocal("idx1")),...u.call(s,W,u.getLocal("mulFactor"),u.getLocal("idx2"))]),u.if(u.call(i+"_isOne",u.getLocal("mulFactor")),[],[...u.call(s,u.getLocal("idx1"),u.getLocal("mulFactor"),u.getLocal("idx1")),...u.call(s,u.getLocal("idx2"),u.getLocal("mulFactor"),u.getLocal("idx2"))])),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))),u.if(u.call(i+"_isOne",u.getLocal("mulFactor")),[],[...u.call(s,u.getLocal("px"),u.getLocal("mulFactor"),u.getLocal("px")),...u.setLocal("idx2",u.i32_add(u.getLocal("px"),u.i32_mul(u.getLocal("ndiv2"),u.i32_const(l)))),...u.call(s,u.getLocal("idx2"),u.getLocal("mulFactor"),u.getLocal("idx2"))]))}function ft(){const q=t.addFunction(e+"__reversePermutation");q.addParam("px","i32"),q.addParam("bits","i32"),q.addLocal("n","i32"),q.addLocal("i","i32"),q.addLocal("ri","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(l));q.addCode(u.setLocal("n",u.i32_shl(u.i32_const(1),u.getLocal("bits"))),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("n"))),u.setLocal("idx1",u.i32_add(u.getLocal("px"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("ri",u.call(e+"__rev",u.getLocal("i"),u.getLocal("bits"))),u.setLocal("idx2",u.i32_add(u.getLocal("px"),u.i32_mul(u.getLocal("ri"),u.i32_const(l)))),u.if(u.i32_lt_u(u.getLocal("i"),u.getLocal("ri")),[...u.call(n+"_copy",u.getLocal("idx1"),W),...u.call(n+"_copy",u.getLocal("idx2"),u.getLocal("idx1")),...u.call(n+"_copy",W,u.getLocal("idx2"))]),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function it(){const q=t.addFunction(e+"__rev");q.addParam("x","i32"),q.addParam("bits","i32"),q.setReturnType("i32");const u=q.getCodeBuilder();q.addCode(u.i32_rotl(u.i32_add(u.i32_add(u.i32_shl(u.i32_load8_u(u.i32_and(u.getLocal("x"),u.i32_const(255)),A,0),u.i32_const(24)),u.i32_shl(u.i32_load8_u(u.i32_and(u.i32_shr_u(u.getLocal("x"),u.i32_const(8)),u.i32_const(255)),A,0),u.i32_const(16))),u.i32_add(u.i32_shl(u.i32_load8_u(u.i32_and(u.i32_shr_u(u.getLocal("x"),u.i32_const(16)),u.i32_const(255)),A,0),u.i32_const(8)),u.i32_load8_u(u.i32_and(u.i32_shr_u(u.getLocal("x"),u.i32_const(24)),u.i32_const(255)),A,0))),u.getLocal("bits")))}function _t(){const q=t.addFunction(e+"_fftJoin");q.addParam("pBuff1","i32"),q.addParam("pBuff2","i32"),q.addParam("n","i32"),q.addParam("first","i32"),q.addParam("inc","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l)),b=u.i32_const(t.alloc(l));q.addCode(u.call(i+"_copy",u.getLocal("first"),W),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("n"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff1"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("pBuff2"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.call(s,u.getLocal("idx2"),W,z),u.call(n+"_copy",u.getLocal("idx1"),b),u.call(n+"_add",b,z,u.getLocal("idx1")),u.call(n+"_sub",b,z,u.getLocal("idx2")),u.call(i+"_mul",W,u.getLocal("inc"),W),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function zt(){const q=t.addFunction(e+"_fftJoinExt");q.addParam("pBuff1","i32"),q.addParam("pBuff2","i32"),q.addParam("n","i32"),q.addParam("first","i32"),q.addParam("inc","i32"),q.addParam("totalBits","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32"),q.addLocal("pShiftToM","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l));q.addCode(u.setLocal("pShiftToM",u.i32_add(u.i32_const(R),u.i32_mul(u.getLocal("totalBits"),u.i32_const(d)))),u.call(i+"_copy",u.getLocal("first"),W),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("n"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff1"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("pBuff2"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.call(n+"_add",u.getLocal("idx1"),u.getLocal("idx2"),z),u.call(s,u.getLocal("idx2"),u.getLocal("pShiftToM"),u.getLocal("idx2")),u.call(n+"_add",u.getLocal("idx1"),u.getLocal("idx2"),u.getLocal("idx2")),u.call(s,u.getLocal("idx2"),W,u.getLocal("idx2")),u.call(n+"_copy",z,u.getLocal("idx1")),u.call(i+"_mul",W,u.getLocal("inc"),W),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function G(){const q=t.addFunction(e+"_fftJoinExtInv");q.addParam("pBuff1","i32"),q.addParam("pBuff2","i32"),q.addParam("n","i32"),q.addParam("first","i32"),q.addParam("inc","i32"),q.addParam("totalBits","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32"),q.addLocal("pShiftToM","i32"),q.addLocal("pSConst","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l));q.addCode(u.setLocal("pShiftToM",u.i32_add(u.i32_const(R),u.i32_mul(u.getLocal("totalBits"),u.i32_const(d)))),u.setLocal("pSConst",u.i32_add(u.i32_const(j),u.i32_mul(u.getLocal("totalBits"),u.i32_const(d)))),u.call(i+"_copy",u.getLocal("first"),W),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("n"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff1"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("pBuff2"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.call(s,u.getLocal("idx2"),W,z),u.call(n+"_sub",u.getLocal("idx1"),z,u.getLocal("idx2")),u.call(s,u.getLocal("idx2"),u.getLocal("pSConst"),u.getLocal("idx2")),u.call(s,u.getLocal("idx1"),u.getLocal("pShiftToM"),u.getLocal("idx1")),u.call(n+"_sub",z,u.getLocal("idx1"),u.getLocal("idx1")),u.call(s,u.getLocal("idx1"),u.getLocal("pSConst"),u.getLocal("idx1")),u.call(i+"_mul",W,u.getLocal("inc"),W),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function K(){const q=t.addFunction(e+"_prepareLagrangeEvaluation");q.addParam("pBuff1","i32"),q.addParam("pBuff2","i32"),q.addParam("n","i32"),q.addParam("first","i32"),q.addParam("inc","i32"),q.addParam("totalBits","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32"),q.addLocal("pShiftToM","i32"),q.addLocal("pSConst","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l));q.addCode(u.setLocal("pShiftToM",u.i32_add(u.i32_const(R),u.i32_mul(u.getLocal("totalBits"),u.i32_const(d)))),u.setLocal("pSConst",u.i32_add(u.i32_const(j),u.i32_mul(u.getLocal("totalBits"),u.i32_const(d)))),u.call(i+"_copy",u.getLocal("first"),W),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("n"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff1"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("pBuff2"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.call(s,u.getLocal("idx1"),u.getLocal("pShiftToM"),z),u.call(n+"_sub",u.getLocal("idx2"),z,z),u.call(n+"_sub",u.getLocal("idx1"),u.getLocal("idx2"),u.getLocal("idx2")),u.call(s,z,u.getLocal("pSConst"),u.getLocal("idx1")),u.call(s,u.getLocal("idx2"),W,u.getLocal("idx2")),u.call(i+"_mul",W,u.getLocal("inc"),W),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function P(){const q=t.addFunction(e+"_fftMix");q.addParam("pBuff","i32"),q.addParam("n","i32"),q.addParam("exp","i32"),q.addLocal("nGroups","i32"),q.addLocal("nPerGroup","i32"),q.addLocal("nPerGroupDiv2","i32"),q.addLocal("pairOffset","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32"),q.addLocal("j","i32"),q.addLocal("pwm","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(d)),z=u.i32_const(t.alloc(l)),b=u.i32_const(t.alloc(l));q.addCode(u.setLocal("nPerGroup",u.i32_shl(u.i32_const(1),u.getLocal("exp"))),u.setLocal("nPerGroupDiv2",u.i32_shr_u(u.getLocal("nPerGroup"),u.i32_const(1))),u.setLocal("nGroups",u.i32_shr_u(u.getLocal("n"),u.getLocal("exp"))),u.setLocal("pairOffset",u.i32_mul(u.getLocal("nPerGroupDiv2"),u.i32_const(l))),u.setLocal("pwm",u.i32_add(u.i32_const(v),u.i32_mul(u.getLocal("exp"),u.i32_const(d)))),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("i"),u.getLocal("nGroups"))),u.call(i+"_one",W),u.setLocal("j",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_eq(u.getLocal("j"),u.getLocal("nPerGroupDiv2"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff"),u.i32_mul(u.i32_add(u.i32_mul(u.getLocal("i"),u.getLocal("nPerGroup")),u.getLocal("j")),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("idx1"),u.getLocal("pairOffset"))),u.call(s,u.getLocal("idx2"),W,z),u.call(n+"_copy",u.getLocal("idx1"),b),u.call(n+"_add",b,z,u.getLocal("idx1")),u.call(n+"_sub",b,z,u.getLocal("idx2")),u.call(i+"_mul",W,u.getLocal("pwm"),W),u.setLocal("j",u.i32_add(u.getLocal("j"),u.i32_const(1))),u.br(0))),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}function a(){const q=t.addFunction(e+"_fftFinal");q.addParam("pBuff","i32"),q.addParam("n","i32"),q.addParam("factor","i32"),q.addLocal("idx1","i32"),q.addLocal("idx2","i32"),q.addLocal("i","i32"),q.addLocal("ndiv2","i32");const u=q.getCodeBuilder(),W=u.i32_const(t.alloc(l));q.addCode(u.setLocal("ndiv2",u.i32_shr_u(u.getLocal("n"),u.i32_const(1))),u.if(u.i32_and(u.getLocal("n"),u.i32_const(1)),u.call(s,u.i32_add(u.getLocal("pBuff"),u.i32_mul(u.getLocal("ndiv2"),u.i32_const(l))),u.getLocal("factor"),u.i32_add(u.getLocal("pBuff"),u.i32_mul(u.getLocal("ndiv2"),u.i32_const(l))))),u.setLocal("i",u.i32_const(0)),u.block(u.loop(u.br_if(1,u.i32_ge_u(u.getLocal("i"),u.getLocal("ndiv2"))),u.setLocal("idx1",u.i32_add(u.getLocal("pBuff"),u.i32_mul(u.getLocal("i"),u.i32_const(l)))),u.setLocal("idx2",u.i32_add(u.getLocal("pBuff"),u.i32_mul(u.i32_sub(u.i32_sub(u.getLocal("n"),u.i32_const(1)),u.getLocal("i")),u.i32_const(l)))),u.call(s,u.getLocal("idx2"),u.getLocal("factor"),W),u.call(s,u.getLocal("idx1"),u.getLocal("factor"),u.getLocal("idx2")),u.call(n+"_copy",W,u.getLocal("idx1")),u.setLocal("i",u.i32_add(u.getLocal("i"),u.i32_const(1))),u.br(0))))}it(),ft(),J(),nt(),D(),H(),ut(),_t(),zt(),G(),P(),a(),K(),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")},Fa=function(t,e,n){const s=t.modules[n].n64*8;function g(){const C=t.addFunction(e+"_zero");C.addParam("px","i32"),C.addParam("n","i32"),C.addLocal("lastp","i32"),C.addLocal("p","i32");const l=C.getCodeBuilder();C.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(s)))),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal("p"),l.getLocal("lastp"))),l.call(n+"_zero",l.getLocal("p")),l.setLocal("p",l.i32_add(l.getLocal("p"),l.i32_const(s))),l.br(0))))}function d(){const C=t.addFunction(e+"_constructLC");C.addParam("ppolynomials","i32"),C.addParam("psignals","i32"),C.addParam("nSignals","i32"),C.addParam("pres","i32"),C.addLocal("i","i32"),C.addLocal("j","i32"),C.addLocal("pp","i32"),C.addLocal("ps","i32"),C.addLocal("pd","i32"),C.addLocal("ncoefs","i32");const l=C.getCodeBuilder(),o=l.i32_const(t.alloc(s));C.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(s)))),l.setLocal("pp",l.i32_add(l.getLocal("pp"),l.i32_const(4))),l.call(n+"_mul",l.getLocal("ps"),l.getLocal("pp"),o),l.call(n+"_add",o,l.getLocal("pd"),l.getLocal("pd")),l.setLocal("pp",l.i32_add(l.getLocal("pp"),l.i32_const(s))),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(s))),l.setLocal("i",l.i32_add(l.getLocal("i"),l.i32_const(1))),l.br(0))))}return g(),d(),t.exportFunction(e+"_zero"),t.exportFunction(e+"_constructLC"),e},Ea=function(t,e,n){const s=t.modules[n].n64*8;function g(){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 o=l.getCodeBuilder(),y=o.i32_const(t.alloc(s));l.addCode(o.setLocal("ita",o.getLocal("pA")),o.setLocal("itb",o.getLocal("pB")),o.setLocal("last",o.i32_add(o.getLocal("pA"),o.i32_mul(o.getLocal("nOut"),o.i32_const(s)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(n+"_zero",o.getLocal("ita")),o.call(n+"_zero",o.getLocal("itb")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(s))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(s))),o.br(0))),o.setLocal("it",o.getLocal("pCoefs")),o.setLocal("last",o.i32_add(o.getLocal("pCoefs"),o.i32_mul(o.getLocal("nCoefs"),o.i32_const(s+12)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("it"),o.getLocal("last"))),o.setLocal("s",o.i32_load(o.getLocal("it"),8)),o.if(o.i32_or(o.i32_lt_u(o.getLocal("s"),o.getLocal("offsetWitness")),o.i32_ge_u(o.getLocal("s"),o.i32_add(o.getLocal("offsetWitness"),o.getLocal("nWitness")))),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(s+12))),...o.br(1)]),o.setLocal("m",o.i32_load(o.getLocal("it"))),o.if(o.i32_eq(o.getLocal("m"),o.i32_const(0)),o.setLocal("pOut",o.getLocal("pA")),o.if(o.i32_eq(o.getLocal("m"),o.i32_const(1)),o.setLocal("pOut",o.getLocal("pB")),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(s+12))),...o.br(1)])),o.setLocal("c",o.i32_load(o.getLocal("it"),4)),o.if(o.i32_or(o.i32_lt_u(o.getLocal("c"),o.getLocal("offsetOut")),o.i32_ge_u(o.getLocal("c"),o.i32_add(o.getLocal("offsetOut"),o.getLocal("nOut")))),[...o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(s+12))),...o.br(1)]),o.setLocal("pOut",o.i32_add(o.getLocal("pOut"),o.i32_mul(o.i32_sub(o.getLocal("c"),o.getLocal("offsetOut")),o.i32_const(s)))),o.call(n+"_mul",o.i32_add(o.getLocal("pWitness"),o.i32_mul(o.i32_sub(o.getLocal("s"),o.getLocal("offsetWitness")),o.i32_const(s))),o.i32_add(o.getLocal("it"),o.i32_const(12)),y),o.call(n+"_add",o.getLocal("pOut"),y,o.getLocal("pOut")),o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(s+12))),o.br(0))),o.setLocal("ita",o.getLocal("pA")),o.setLocal("itb",o.getLocal("pB")),o.setLocal("it",o.getLocal("pC")),o.setLocal("last",o.i32_add(o.getLocal("pA"),o.i32_mul(o.getLocal("nOut"),o.i32_const(s)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(n+"_mul",o.getLocal("ita"),o.getLocal("itb"),o.getLocal("it")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(s))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(s))),o.setLocal("it",o.i32_add(o.getLocal("it"),o.i32_const(s))),o.br(0))))}function d(){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 o=l.getCodeBuilder(),y=o.i32_const(t.alloc(s));l.addCode(o.setLocal("ita",o.getLocal("pA")),o.setLocal("itb",o.getLocal("pB")),o.setLocal("itc",o.getLocal("pC")),o.setLocal("itp",o.getLocal("pP")),o.setLocal("last",o.i32_add(o.getLocal("pA"),o.i32_mul(o.getLocal("n"),o.i32_const(s)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(n+"_mul",o.getLocal("ita"),o.getLocal("itb"),y),o.call(n+"_sub",y,o.getLocal("itc"),o.getLocal("itp")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(s))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(s))),o.setLocal("itc",o.i32_add(o.getLocal("itc"),o.i32_const(s))),o.setLocal("itp",o.i32_add(o.getLocal("itp"),o.i32_const(s))),o.br(0))))}function C(){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 o=l.getCodeBuilder();l.addCode(o.setLocal("ita",o.getLocal("pa")),o.setLocal("itb",o.getLocal("pb")),o.setLocal("itr",o.getLocal("pr")),o.setLocal("last",o.i32_add(o.getLocal("pa"),o.i32_mul(o.getLocal("n"),o.i32_const(s)))),o.block(o.loop(o.br_if(1,o.i32_eq(o.getLocal("ita"),o.getLocal("last"))),o.call(n+"_add",o.getLocal("ita"),o.getLocal("itb"),o.getLocal("itr")),o.setLocal("ita",o.i32_add(o.getLocal("ita"),o.i32_const(s))),o.setLocal("itb",o.i32_add(o.getLocal("itb"),o.i32_const(s))),o.setLocal("itr",o.i32_add(o.getLocal("itr"),o.i32_const(s))),o.br(0))))}return g(),d(),C(),t.exportFunction(e+"_buildABC"),t.exportFunction(e+"_joinABC"),t.exportFunction(e+"_batchAdd"),e},wa=function(t,e,n,i,s,g,d,C){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 o=l.getCodeBuilder(),y=o.i32_const(t.alloc(d));l.addCode(o.setLocal("pFrom",o.getLocal("pIn")),o.setLocal("pTo",o.getLocal("pOut"))),l.addCode(o.call(i+"_copy",o.getLocal("pFirst"),y)),l.addCode(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.call(C,o.getLocal("pFrom"),y,o.getLocal("pTo")),o.setLocal("pFrom",o.i32_add(o.getLocal("pFrom"),o.i32_const(s))),o.setLocal("pTo",o.i32_add(o.getLocal("pTo"),o.i32_const(g))),o.call(i+"_mul",y,o.getLocal("pInc"),y),o.setLocal("i",o.i32_add(o.getLocal("i"),o.i32_const(1))),o.br(0)))),t.exportFunction(e)};const Nt=ye,ds=Xn,fs=ma,bi=ba,_s=ya,yi=Ca,mn=Aa,gs=Fa,ps=Ea,Re=wa,{bitLength:hs,modInv:Ls,isOdd:Ci,isNegative:ms}=le;var bs=function(t,e){const n=e||"bn128";if(t.modules[n])return n;const i=21888242871839275222246405745257275088696311157297823662689037894645226208583n,s=21888242871839275222246405745257275088548364400416034343698204186575808495617n,g=Math.floor((hs(i-1n)-1)/64)+1,d=g*8,C=d,l=d,o=l*2,y=l*12,E=t.alloc(Nt.bigInt2BytesLE(s,C)),m=ds(t,i,"f1m");fs(t,s,"fr","frm");const x=t.alloc(Nt.bigInt2BytesLE(w(3n),l)),O=yi(t,"g1m","f1m",x);mn(t,"frm","frm","frm","frm_mul"),gs(t,"pol","frm"),ps(t,"qap","frm");const L=bi(t,"f1m_neg","f2m","f1m"),I=t.alloc([...Nt.bigInt2BytesLE(w(19485874751759354771024239261021720505790618469301721065564631296452457478373n),l),...Nt.bigInt2BytesLE(w(266929791119991161246907387137283842545076965332900288569378510910307636690n),l)]),v=yi(t,"g2m","f2m",I);function U(Y,f){const _=t.addFunction(Y);_.addParam("pG","i32"),_.addParam("pFr","i32"),_.addParam("pr","i32");const Z=_.getCodeBuilder(),Q=Z.i32_const(t.alloc(d));_.addCode(Z.call("frm_fromMontgomery",Z.getLocal("pFr"),Q),Z.call(f,Z.getLocal("pG"),Q,Z.i32_const(d),Z.getLocal("pr"))),t.exportFunction(Y)}U("g1m_timesFr","g1m_timesScalar"),mn(t,"g1m","g1m","frm","g1m_timesFr"),U("g2m_timesFr","g2m_timesScalar"),mn(t,"g2m","g2m","frm","g2m_timesFr"),U("g1m_timesFrAffine","g1m_timesScalarAffine"),U("g2m_timesFrAffine","g2m_timesScalarAffine"),Re(t,"frm_batchApplyKey","fmr","frm",d,d,d,"frm_mul"),Re(t,"g1m_batchApplyKey","g1m","frm",d*3,d*3,d,"g1m_timesFr"),Re(t,"g1m_batchApplyKeyMixed","g1m","frm",d*2,d*3,d,"g1m_timesFrAffine"),Re(t,"g2m_batchApplyKey","g2m","frm",d*2*3,d*3*2,d,"g2m_timesFr"),Re(t,"g2m_batchApplyKeyMixed","g2m","frm",d*2*2,d*3*2,d,"g2m_timesFrAffine");function w(Y){return BigInt(Y)*(1n<<BigInt(l*8))%i}const S=[1n,2n,1n],F=t.alloc([...Nt.bigInt2BytesLE(w(S[0]),l),...Nt.bigInt2BytesLE(w(S[1]),l),...Nt.bigInt2BytesLE(w(S[2]),l)]),r=[0n,1n,0n],h=t.alloc([...Nt.bigInt2BytesLE(w(r[0]),l),...Nt.bigInt2BytesLE(w(r[1]),l),...Nt.bigInt2BytesLE(w(r[2]),l)]),R=[[10857046999023057135944570762232829481370756359578518086990519993285655852781n,11559732032986387107991004021392285783925812861821192530917403151452391805634n],[8495653923123431417604973247489272438418190587263600148770280649306958101930n,4082367875863433681332203403145435568316851327593401208105741076214120093531n],[1n,0n]],j=t.alloc([...Nt.bigInt2BytesLE(w(R[0][0]),l),...Nt.bigInt2BytesLE(w(R[0][1]),l),...Nt.bigInt2BytesLE(w(R[1][0]),l),...Nt.bigInt2BytesLE(w(R[1][1]),l),...Nt.bigInt2BytesLE(w(R[2][0]),l),...Nt.bigInt2BytesLE(w(R[2][1]),l)]),T=[[0n,0n],[1n,0n],[0n,0n]],M=t.alloc([...Nt.bigInt2BytesLE(w(T[0][0]),l),...Nt.bigInt2BytesLE(w(T[0][1]),l),...Nt.bigInt2BytesLE(w(T[1][0]),l),...Nt.bigInt2BytesLE(w(T[1][1]),l),...Nt.bigInt2BytesLE(w(T[2][0]),l),...Nt.bigInt2BytesLE(w(T[2][1]),l)]),A=t.alloc([...Nt.bigInt2BytesLE(w(1),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l),...Nt.bigInt2BytesLE(w(0),l)]),D=t.alloc([...Nt.bigInt2BytesLE(w(9),l),...Nt.bigInt2BytesLE(w(1),l)]),H=t.alloc([...Nt.bigInt2BytesLE(w(Ls(2n,i)),l),...Nt.bigInt2BytesLE(0n,l)]),ut=D,nt=t.alloc([...Nt.bigInt2BytesLE(w(19485874751759354771024239261021720505790618469301721065564631296452457478373n),l),...Nt.bigInt2BytesLE(w(266929791119991161246907387137283842545076965332900288569378510910307636690n),l)]);function J(){const Y=t.addFunction(n+"_mulNR6");Y.addParam("x","i32"),Y.addParam("pr","i32");const f=Y.getCodeBuilder();Y.addCode(f.call(L+"_mul",f.i32_const(D),f.getLocal("x"),f.getLocal("pr")))}J();const ft=_s(t,n+"_mulNR6","f6m","f2m");function it(){const Y=t.addFunction(n+"_mulNR12");Y.addParam("x","i32"),Y.addParam("pr","i32");const f=Y.getCodeBuilder();Y.addCode(f.call(L+"_mul",f.i32_const(D),f.i32_add(f.getLocal("x"),f.i32_const(d*4)),f.getLocal("pr")),f.call(L+"_copy",f.getLocal("x"),f.i32_add(f.getLocal("pr"),f.i32_const(d*2))),f.call(L+"_copy",f.i32_add(f.getLocal("x"),f.i32_const(d*2)),f.i32_add(f.getLocal("pr"),f.i32_const(d*4))))}it();const _t=bi(t,n+"_mulNR12","ftm",ft),G=At(29793968203157093288n),K=t.alloc(G),P=3*o,a=G.length-1,u=G.reduce((Y,f)=>Y+(f!=0?1:0),0)+a+1,W=3*2*d,z=3*d*2+u*P;t.modules[n]={n64:g,pG1gen:F,pG1zero:h,pG1b:x,pG2gen:j,pG2zero:M,pG2b:I,pq:t.modules.f1m.pq,pr:E,pOneT:A,prePSize:W,preQSize:z,r:s.toString(),q:i.toString()};const b=4965661367192848881n;function at(Y){let f=Y;const _=[];for(;f>0n;){if(Ci(f)){const Z=2-Number(f%4n);_.push(Z),f=f-BigInt(Z)}else _.push(0);f=f>>1n}return _}function At(Y){let f=Y;const _=[];for(;f>0n;)Ci(f)?_.push(1):_.push(0),f=f>>1n;return _}function Lt(){const Y=t.addFunction(n+"_prepareG1");Y.addParam("pP","i32"),Y.addParam("ppreP","i32");const f=Y.getCodeBuilder();Y.addCode(f.call(O+"_normalize",f.getLocal("pP"),f.getLocal("ppreP")))}function yt(){const Y=t.addFunction(n+"_prepAddStep");Y.addParam("pQ","i32"),Y.addParam("pR","i32"),Y.addParam("pCoef","i32");const f=Y.getCodeBuilder(),_=f.getLocal("pQ"),Z=f.i32_add(f.getLocal("pQ"),f.i32_const(o)),Q=f.getLocal("pR"),$=f.i32_add(f.getLocal("pR"),f.i32_const(o)),tt=f.i32_add(f.getLocal("pR"),f.i32_const(2*o)),V=f.getLocal("pCoef"),ct=f.i32_add(f.getLocal("pCoef"),f.i32_const(o)),st=f.i32_add(f.getLocal("pCoef"),f.i32_const(2*o)),rt=ct,ot=f.i32_const(t.alloc(o)),gt=f.i32_const(t.alloc(o)),Bt=f.i32_const(t.alloc(o)),Ft=f.i32_const(t.alloc(o)),ht=f.i32_const(t.alloc(o)),xt=f.i32_const(t.alloc(o)),Tt=f.i32_const(t.alloc(o));Y.addCode(f.call(L+"_mul",_,tt,rt),f.call(L+"_sub",Q,rt,rt),f.call(L+"_mul",Z,tt,ot),f.call(L+"_sub",$,ot,ot),f.call(L+"_square",rt,gt),f.call(L+"_square",ot,Bt),f.call(L+"_mul",rt,gt,Ft),f.call(L+"_mul",Q,gt,ht),f.call(L+"_add",ht,ht,Tt),f.call(L+"_mul",tt,Bt,xt),f.call(L+"_add",Ft,xt,xt),f.call(L+"_sub",xt,Tt,xt),f.call(L+"_mul",rt,xt,Q),f.call(L+"_mul",Ft,$,$),f.call(L+"_sub",ht,xt,Tt),f.call(L+"_mul",ot,Tt,Tt),f.call(L+"_sub",Tt,$,$),f.call(L+"_mul",tt,Ft,tt),f.call(L+"_mul",rt,Z,Tt),f.call(L+"_mul",ot,_,V),f.call(L+"_sub",V,Tt,V),f.call(L+"_mul",V,f.i32_const(ut),V),f.call(L+"_neg",ot,st))}function It(){const Y=t.addFunction(n+"_prepDblStep");Y.addParam("pR","i32"),Y.addParam("pCoef","i32");const f=Y.getCodeBuilder(),_=f.getLocal("pR"),Z=f.i32_add(f.getLocal("pR"),f.i32_const(o)),Q=f.i32_add(f.getLocal("pR"),f.i32_const(2*o)),$=f.getLocal("pCoef"),tt=f.i32_add(f.getLocal("pCoef"),f.i32_const(o)),V=f.i32_add(f.getLocal("pCoef"),f.i32_const(2*o)),ct=f.i32_const(t.alloc(o)),st=f.i32_const(t.alloc(o)),rt=f.i32_const(t.alloc(o)),ot=f.i32_const(t.alloc(o)),gt=f.i32_const(t.alloc(o)),Bt=f.i32_const(t.alloc(o)),Ft=f.i32_const(t.alloc(o)),ht=f.i32_const(t.alloc(o)),xt=f.i32_const(t.alloc(o)),Tt=f.i32_const(t.alloc(o)),Ut=f.i32_const(t.alloc(o)),St=f.i32_const(t.alloc(o));Y.addCode(f.call(L+"_mul",Z,f.i32_const(H),ct),f.call(L+"_mul",_,ct,ct),f.call(L+"_square",Z,st),f.call(L+"_square",Q,rt),f.call(L+"_add",rt,rt,ot),f.call(L+"_add",ot,rt,ot),f.call(L+"_mul",f.i32_const(nt),ot,gt),f.call(L+"_add",gt,gt,Bt),f.call(L+"_add",gt,Bt,Bt),f.call(L+"_add",st,Bt,Ft),f.call(L+"_mul",Ft,f.i32_const(H),Ft),f.call(L+"_add",st,rt,St),f.call(L+"_add",Z,Q,ht),f.call(L+"_square",ht,ht),f.call(L+"_sub",ht,St,ht),f.call(L+"_sub",gt,st,xt),f.call(L+"_square",_,Tt),f.call(L+"_square",gt,Ut),f.call(L+"_sub",st,Bt,St),f.call(L+"_mul",ct,St,_),f.call(L+"_add",Ut,Ut,St),f.call(L+"_add",Ut,St,St),f.call(L+"_square",Ft,Z),f.call(L+"_sub",Z,St,Z),f.call(L+"_mul",st,ht,Q),f.call(L+"_mul",f.i32_const(ut),xt,$),f.call(L+"_neg",ht,tt),f.call(L+"_add",Tt,Tt,V),f.call(L+"_add",Tt,V,V))}function mt(){const Y=t.addFunction(n+"_mulByQ");Y.addParam("p1","i32"),Y.addParam("pr","i32");const f=Y.getCodeBuilder(),_=f.getLocal("p1"),Z=f.i32_add(f.getLocal("p1"),f.i32_const(o)),Q=f.i32_add(f.getLocal("p1"),f.i32_const(o*2)),$=f.getLocal("pr"),tt=f.i32_add(f.getLocal("pr"),f.i32_const(o)),V=f.i32_add(f.getLocal("pr"),f.i32_const(o*2)),ct=f.i32_const(t.alloc([...Nt.bigInt2BytesLE(w("21575463638280843010398324269430826099269044274347216827212613867836435027261"),l),...Nt.bigInt2BytesLE(w("10307601595873709700152284273816112264069230130616436755625194854815875713954"),l)])),st=f.i32_const(t.alloc([...Nt.bigInt2BytesLE(w("2821565182194536844548159561693502659359617185244120367078079554186484126554"),l),...Nt.bigInt2BytesLE(w("3505843767911556378687030309984248845540243509899259641013678093033130930403"),l)]));Y.addCode(f.call(L+"_conjugate",_,$),f.call(L+"_mul",ct,$,$),f.call(L+"_conjugate",Z,tt),f.call(L+"_mul",st,tt,tt),f.call(L+"_conjugate",Q,V))}function Ot(){mt();const Y=t.addFunction(n+"_prepareG2");Y.addParam("pQ","i32"),Y.addParam("ppreQ","i32"),Y.addLocal("pCoef","i32"),Y.addLocal("i","i32");const f=Y.getCodeBuilder(),_=f.getLocal("pQ"),Z=t.alloc(o*3),Q=f.i32_const(Z),$=f.i32_const(Z),tt=f.i32_const(Z+o),V=f.i32_const(Z+2*o),ct=f.i32_add(f.getLocal("ppreQ"),f.i32_const(0)),st=f.i32_add(f.getLocal("ppreQ"),f.i32_const(o)),rt=t.alloc(o*3),ot=f.i32_const(rt),gt=t.alloc(o*3),Bt=f.i32_const(gt),Ft=f.i32_const(gt+o);Y.addCode(f.call(v+"_normalize",_,ct),f.call(L+"_copy",ct,$),f.call(L+"_copy",st,tt),f.call(L+"_one",V)),Y.addCode(f.setLocal("pCoef",f.i32_add(f.getLocal("ppreQ"),f.i32_const(o*3))),f.setLocal("i",f.i32_const(G.length-2)),f.block(f.loop(f.call(n+"_prepDblStep",Q,f.getLocal("pCoef")),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))),f.if(f.i32_load8_s(f.getLocal("i"),K),[...f.call(n+"_prepAddStep",ct,Q,f.getLocal("pCoef")),...f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P)))]),f.br_if(1,f.i32_eqz(f.getLocal("i"))),f.setLocal("i",f.i32_sub(f.getLocal("i"),f.i32_const(1))),f.br(0)))),Y.addCode(f.call(n+"_mulByQ",ct,ot),f.call(n+"_mulByQ",ot,Bt)),Y.addCode(f.call(L+"_neg",Ft,Ft),f.call(n+"_prepAddStep",ot,Q,f.getLocal("pCoef")),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))),f.call(n+"_prepAddStep",Bt,Q,f.getLocal("pCoef")),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))))}function jt(){const Y=t.addFunction(n+"__mulBy024Old");Y.addParam("pEll0","i32"),Y.addParam("pEllVW","i32"),Y.addParam("pEllVV","i32"),Y.addParam("pR","i32");const f=Y.getCodeBuilder(),_=f.getLocal("pEll0"),Z=f.getLocal("pEllVV"),Q=f.getLocal("pEllVW"),$=f.getLocal("pR"),tt=t.alloc(y),V=f.i32_const(tt),ct=f.i32_const(tt),st=f.i32_const(tt+o),rt=f.i32_const(tt+o*2),ot=f.i32_const(tt+o*3),gt=f.i32_const(tt+o*4),Bt=f.i32_const(tt+o*5);Y.addCode(f.call(L+"_copy",_,ct),f.call(L+"_zero",st),f.call(L+"_copy",Z,rt),f.call(L+"_zero",ot),f.call(L+"_copy",Q,gt),f.call(L+"_zero",Bt),f.call(_t+"_mul",V,$,$))}function Et(){const Y=t.addFunction(n+"__mulBy024");Y.addParam("pEll0","i32"),Y.addParam("pEllVW","i32"),Y.addParam("pEllVV","i32"),Y.addParam("pR","i32");const f=Y.getCodeBuilder(),_=f.getLocal("pEll0"),Z=f.getLocal("pEllVV"),Q=f.getLocal("pEllVW"),$=f.getLocal("pR"),tt=f.i32_add(f.getLocal("pR"),f.i32_const(2*d)),V=f.i32_add(f.getLocal("pR"),f.i32_const(4*d)),ct=f.i32_add(f.getLocal("pR"),f.i32_const(6*d)),st=f.i32_add(f.getLocal("pR"),f.i32_const(8*d)),rt=f.i32_add(f.getLocal("pR"),f.i32_const(10*d)),ot=f.i32_const(t.alloc(o)),gt=f.i32_const(t.alloc(o)),Bt=f.i32_const(t.alloc(o)),Ft=f.i32_const(t.alloc(o)),ht=f.i32_const(t.alloc(o)),xt=f.i32_const(t.alloc(o)),Tt=f.i32_const(t.alloc(o)),Ut=f.i32_const(t.alloc(o)),St=f.i32_const(t.alloc(o)),kt=f.i32_const(t.alloc(o)),k=f.i32_const(t.alloc(o));Y.addCode(f.call(L+"_mul",$,_,Tt),f.call(L+"_mul",V,Z,Ut),f.call(L+"_mul",st,Q,St),f.call(L+"_add",$,st,Bt),f.call(L+"_add",$,V,gt),f.call(L+"_add",tt,ct,Ft),f.call(L+"_add",Ft,rt,Ft),f.call(L+"_mul",tt,Z,kt),f.call(L+"_add",kt,St,ht),f.call(L+"_mul",f.i32_const(D),ht,xt),f.call(L+"_add",xt,Tt,$),f.call(L+"_mul",rt,Q,ht),f.call(L+"_add",kt,ht,kt),f.call(L+"_add",ht,Ut,ht),f.call(L+"_mul",f.i32_const(D),ht,xt),f.call(L+"_mul",tt,_,ht),f.call(L+"_add",kt,ht,kt),f.call(L+"_add",xt,ht,tt),f.call(L+"_add",_,Z,ot),f.call(L+"_mul",gt,ot,ht),f.call(L+"_add",Tt,Ut,k),f.call(L+"_sub",ht,k,ht),f.call(L+"_mul",ct,Q,xt),f.call(L+"_add",kt,xt,kt),f.call(L+"_add",V,st,ot),f.call(L+"_add",ht,xt,V),f.call(L+"_add",Z,Q,gt),f.call(L+"_mul",gt,ot,ht),f.call(L+"_add",Ut,St,k),f.call(L+"_sub",ht,k,ht),f.call(L+"_mul",f.i32_const(D),ht,xt),f.call(L+"_mul",ct,_,ht),f.call(L+"_add",kt,ht,kt),f.call(L+"_add",xt,ht,ct),f.call(L+"_mul",rt,Z,ht),f.call(L+"_add",kt,ht,kt),f.call(L+"_mul",f.i32_const(D),ht,xt),f.call(L+"_add",_,Q,ot),f.call(L+"_mul",Bt,ot,ht),f.call(L+"_add",Tt,St,k),f.call(L+"_sub",ht,k,ht),f.call(L+"_add",xt,ht,st),f.call(L+"_add",_,Z,ot),f.call(L+"_add",ot,Q,ot),f.call(L+"_mul",Ft,ot,ht),f.call(L+"_sub",ht,kt,rt))}function bt(){const Y=t.addFunction(n+"_millerLoop");Y.addParam("ppreP","i32"),Y.addParam("ppreQ","i32"),Y.addParam("r","i32"),Y.addLocal("pCoef","i32"),Y.addLocal("i","i32");const f=Y.getCodeBuilder(),_=f.getLocal("ppreP"),Z=f.i32_add(f.getLocal("ppreP"),f.i32_const(l)),Q=f.getLocal("pCoef"),$=f.i32_add(f.getLocal("pCoef"),f.i32_const(o)),tt=f.i32_add(f.getLocal("pCoef"),f.i32_const(2*o)),V=t.alloc(o),ct=f.i32_const(V),st=t.alloc(o),rt=f.i32_const(st),ot=f.getLocal("r");Y.addCode(f.call(_t+"_one",ot),f.setLocal("pCoef",f.i32_add(f.getLocal("ppreQ"),f.i32_const(o*3))),f.setLocal("i",f.i32_const(G.length-2)),f.block(f.loop(f.call(_t+"_square",ot,ot),f.call(L+"_mul1",$,Z,ct),f.call(L+"_mul1",tt,_,rt),f.call(n+"__mulBy024",Q,ct,rt,ot),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))),f.if(f.i32_load8_s(f.getLocal("i"),K),[...f.call(L+"_mul1",$,Z,ct),...f.call(L+"_mul1",tt,_,rt),...f.call(n+"__mulBy024",Q,ct,rt,ot),...f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P)))]),f.br_if(1,f.i32_eqz(f.getLocal("i"))),f.setLocal("i",f.i32_sub(f.getLocal("i"),f.i32_const(1))),f.br(0)))),Y.addCode(f.call(L+"_mul1",$,Z,ct),f.call(L+"_mul1",tt,_,rt),f.call(n+"__mulBy024",Q,ct,rt,ot),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))),f.call(L+"_mul1",$,Z,ct),f.call(L+"_mul1",tt,_,rt),f.call(n+"__mulBy024",Q,ct,rt,ot),f.setLocal("pCoef",f.i32_add(f.getLocal("pCoef"),f.i32_const(P))))}function pt(Y){const f=[[[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]]],_=[[[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]]],Z=t.addFunction(n+"__frobeniusMap"+Y);Z.addParam("x","i32"),Z.addParam("r","i32");const Q=Z.getCodeBuilder();for(let tt=0;tt<6;tt++){const V=tt==0?Q.getLocal("x"):Q.i32_add(Q.getLocal("x"),Q.i32_const(tt*o)),ct=V,st=Q.i32_add(Q.getLocal("x"),Q.i32_const(tt*o+l)),rt=tt==0?Q.getLocal("r"):Q.i32_add(Q.getLocal("r"),Q.i32_const(tt*o)),ot=rt,gt=Q.i32_add(Q.getLocal("r"),Q.i32_const(tt*o+l)),Bt=$(f[Math.floor(tt/3)][Y%12],_[tt%3][Y%6]),Ft=t.alloc([...Nt.bigInt2BytesLE(w(Bt[0]),32),...Nt.bigInt2BytesLE(w(Bt[1]),32)]);Y%2==1?Z.addCode(Q.call(m+"_copy",ct,ot),Q.call(m+"_neg",st,gt),Q.call(L+"_mul",rt,Q.i32_const(Ft),rt)):Z.addCode(Q.call(L+"_mul",V,Q.i32_const(Ft),rt))}function $(tt,V){const ct=BigInt(tt[0]),st=BigInt(tt[1]),rt=BigInt(V[0]),ot=BigInt(V[1]),gt=[(ct*rt-st*ot)%i,(ct*ot+st*rt)%i];return ms(gt[0])&&(gt[0]=gt[0]+i),gt}}function $t(){const Y=t.addFunction(n+"__finalExponentiationFirstChunk");Y.addParam("x","i32"),Y.addParam("r","i32");const f=Y.getCodeBuilder(),_=f.getLocal("x"),Z=_,Q=f.i32_add(_,f.i32_const(d*6)),$=f.getLocal("r"),tt=t.alloc(y),V=f.i32_const(tt),ct=V,st=f.i32_const(tt+d*6),rt=f.i32_const(t.alloc(y)),ot=f.i32_const(t.alloc(y)),gt=f.i32_const(t.alloc(y));Y.addCode(f.call(ft+"_copy",Z,ct),f.call(ft+"_neg",Q,st),f.call(_t+"_inverse",_,rt),f.call(_t+"_mul",V,rt,ot),f.call(n+"__frobeniusMap2",ot,gt),f.call(_t+"_mul",ot,gt,$))}function Jt(){const Y=t.addFunction(n+"__cyclotomicSquare");Y.addParam("x","i32"),Y.addParam("r","i32");const f=Y.getCodeBuilder(),_=f.getLocal("x"),Z=f.i32_add(f.getLocal("x"),f.i32_const(o)),Q=f.i32_add(f.getLocal("x"),f.i32_const(2*o)),$=f.i32_add(f.getLocal("x"),f.i32_const(3*o)),tt=f.i32_add(f.getLocal("x"),f.i32_const(4*o)),V=f.i32_add(f.getLocal("x"),f.i32_const(5*o)),ct=f.getLocal("r"),st=f.i32_add(f.getLocal("r"),f.i32_const(o)),rt=f.i32_add(f.getLocal("r"),f.i32_const(2*o)),ot=f.i32_add(f.getLocal("r"),f.i32_const(3*o)),gt=f.i32_add(f.getLocal("r"),f.i32_const(4*o)),Bt=f.i32_add(f.getLocal("r"),f.i32_const(5*o)),Ft=f.i32_const(t.alloc(o)),ht=f.i32_const(t.alloc(o)),xt=f.i32_const(t.alloc(o)),Tt=f.i32_const(t.alloc(o)),Ut=f.i32_const(t.alloc(o)),St=f.i32_const(t.alloc(o)),kt=f.i32_const(t.alloc(o)),k=f.i32_const(t.alloc(o));Y.addCode(f.call(L+"_mul",_,tt,kt),f.call(L+"_mul",tt,f.i32_const(D),Ft),f.call(L+"_add",_,Ft,Ft),f.call(L+"_add",_,tt,k),f.call(L+"_mul",k,Ft,Ft),f.call(L+"_mul",f.i32_const(D),kt,k),f.call(L+"_add",kt,k,k),f.call(L+"_sub",Ft,k,Ft),f.call(L+"_add",kt,kt,ht),f.call(L+"_mul",$,Q,kt),f.call(L+"_mul",Q,f.i32_const(D),xt),f.call(L+"_add",$,xt,xt),f.call(L+"_add",$,Q,k),f.call(L+"_mul",k,xt,xt),f.call(L+"_mul",f.i32_const(D),kt,k),f.call(L+"_add",kt,k,k),f.call(L+"_sub",xt,k,xt),f.call(L+"_add",kt,kt,Tt),f.call(L+"_mul",Z,V,kt),f.call(L+"_mul",V,f.i32_const(D),Ut),f.call(L+"_add",Z,Ut,Ut),f.call(L+"_add",Z,V,k),f.call(L+"_mul",k,Ut,Ut),f.call(L+"_mul",f.i32_const(D),kt,k),f.call(L+"_add",kt,k,k),f.call(L+"_sub",Ut,k,Ut),f.call(L+"_add",kt,kt,St),f.call(L+"_sub",Ft,_,ct),f.call(L+"_add",ct,ct,ct),f.call(L+"_add",Ft,ct,ct),f.call(L+"_add",ht,tt,gt),f.call(L+"_add",gt,gt,gt),f.call(L+"_add",ht,gt,gt),f.call(L+"_mul",St,f.i32_const(ut),k),f.call(L+"_add",k,$,ot),f.call(L+"_add",ot,ot,ot),f.call(L+"_add",k,ot,ot),f.call(L+"_sub",Ut,Q,rt),f.call(L+"_add",rt,rt,rt),f.call(L+"_add",Ut,rt,rt),f.call(L+"_sub",xt,Z,st),f.call(L+"_add",st,st,st),f.call(L+"_add",xt,st,st),f.call(L+"_add",Tt,V,Bt),f.call(L+"_add",Bt,Bt,Bt),f.call(L+"_add",Tt,Bt,Bt))}function re(Y,f){const _=at(Y).map(st=>st==-1?255:st),Z=t.alloc(_),Q=t.addFunction(n+"__cyclotomicExp_"+f);Q.addParam("x","i32"),Q.addParam("r","i32"),Q.addLocal("bit","i32"),Q.addLocal("i","i32");const $=Q.getCodeBuilder(),tt=$.getLocal("x"),V=$.getLocal("r"),ct=$.i32_const(t.alloc(y));Q.addCode($.call(_t+"_conjugate",tt,ct),$.call(_t+"_one",V),$.if($.teeLocal("bit",$.i32_load8_s($.i32_const(_.length-1),Z)),$.if($.i32_eq($.getLocal("bit"),$.i32_const(1)),$.call(_t+"_mul",V,tt,V),$.call(_t+"_mul",V,ct,V))),$.setLocal("i",$.i32_const(_.length-2)),$.block($.loop($.call(n+"__cyclotomicSquare",V,V),$.if($.teeLocal("bit",$.i32_load8_s($.getLocal("i"),Z)),$.if($.i32_eq($.getLocal("bit"),$.i32_const(1)),$.call(_t+"_mul",V,tt,V),$.call(_t+"_mul",V,ct,V))),$.br_if(1,$.i32_eqz($.getLocal("i"))),$.setLocal("i",$.i32_sub($.getLocal("i"),$.i32_const(1))),$.br(0))))}function te(){Jt(),re(b,"w0");const Y=t.addFunction(n+"__finalExponentiationLastChunk");Y.addParam("x","i32"),Y.addParam("r","i32");const f=Y.getCodeBuilder(),_=f.getLocal("x"),Z=f.getLocal("r"),Q=f.i32_const(t.alloc(y)),$=f.i32_const(t.alloc(y)),tt=f.i32_const(t.alloc(y)),V=f.i32_const(t.alloc(y)),ct=f.i32_const(t.alloc(y)),st=f.i32_const(t.alloc(y)),rt=f.i32_const(t.alloc(y)),ot=f.i32_const(t.alloc(y)),gt=f.i32_const(t.alloc(y)),Bt=f.i32_const(t.alloc(y)),Ft=f.i32_const(t.alloc(y)),ht=f.i32_const(t.alloc(y)),xt=f.i32_const(t.alloc(y)),Tt=f.i32_const(t.alloc(y)),Ut=f.i32_const(t.alloc(y)),St=f.i32_const(t.alloc(y)),kt=f.i32_const(t.alloc(y)),k=f.i32_const(t.alloc(y)),et=f.i32_const(t.alloc(y)),dt=f.i32_const(t.alloc(y)),qt=f.i32_const(t.alloc(y));Y.addCode(f.call(n+"__cyclotomicExp_w0",_,Q),f.call(_t+"_conjugate",Q,Q),f.call(n+"__cyclotomicSquare",Q,$),f.call(n+"__cyclotomicSquare",$,tt),f.call(_t+"_mul",tt,$,V),f.call(n+"__cyclotomicExp_w0",V,ct),f.call(_t+"_conjugate",ct,ct),f.call(n+"__cyclotomicSquare",ct,st),f.call(n+"__cyclotomicExp_w0",st,rt),f.call(_t+"_conjugate",rt,rt),f.call(_t+"_conjugate",V,ot),f.call(_t+"_conjugate",rt,gt),f.call(_t+"_mul",gt,ct,Bt),f.call(_t+"_mul",Bt,ot,Ft),f.call(_t+"_mul",Ft,$,ht),f.call(_t+"_mul",Ft,ct,xt),f.call(_t+"_mul",xt,_,Tt),f.call(n+"__frobeniusMap1",ht,Ut),f.call(_t+"_mul",Ut,Tt,St),f.call(n+"__frobeniusMap2",Ft,kt),f.call(_t+"_mul",kt,St,k),f.call(_t+"_conjugate",_,et),f.call(_t+"_mul",et,ht,dt),f.call(n+"__frobeniusMap3",dt,qt),f.call(_t+"_mul",qt,k,Z))}function Pt(){$t(),te();const Y=t.addFunction(n+"_finalExponentiation");Y.addParam("x","i32"),Y.addParam("r","i32");const f=Y.getCodeBuilder(),_=f.getLocal("x"),Z=f.getLocal("r"),Q=f.i32_const(t.alloc(y));Y.addCode(f.call(n+"__finalExponentiationFirstChunk",_,Q),f.call(n+"__finalExponentiationLastChunk",Q,Z))}function Mt(){const Y=t.addFunction(n+"_finalExponentiationOld");Y.addParam("x","i32"),Y.addParam("r","i32");const _=t.alloc(Nt.bigInt2BytesLE(552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480n,352)),Z=Y.getCodeBuilder();Y.addCode(Z.call(_t+"_exp",Z.getLocal("x"),Z.i32_const(_),Z.i32_const(352),Z.getLocal("r")))}const Zt=t.alloc(W),vt=t.alloc(z);function Wt(Y){const f=t.addFunction(n+"_pairingEq"+Y);for(let $=0;$<Y;$++)f.addParam("p_"+$,"i32"),f.addParam("q_"+$,"i32");f.addParam("c","i32"),f.setReturnType("i32");const _=f.getCodeBuilder(),Z=_.i32_const(t.alloc(y)),Q=_.i32_const(t.alloc(y));f.addCode(_.call(_t+"_one",Z));for(let $=0;$<Y;$++)f.addCode(_.call(n+"_prepareG1",_.getLocal("p_"+$),_.i32_const(Zt))),f.addCode(_.call(n+"_prepareG2",_.getLocal("q_"+$),_.i32_const(vt))),f.addCode(_.call(n+"_millerLoop",_.i32_const(Zt),_.i32_const(vt),Q)),f.addCode(_.call(_t+"_mul",Z,Q,Z));f.addCode(_.call(n+"_finalExponentiation",Z,Z)),f.addCode(_.call(_t+"_eq",Z,_.getLocal("c")))}function wt(){const Y=t.addFunction(n+"_pairing");Y.addParam("p","i32"),Y.addParam("q","i32"),Y.addParam("r","i32");const f=Y.getCodeBuilder(),_=f.i32_const(t.alloc(y));Y.addCode(f.call(n+"_prepareG1",f.getLocal("p"),f.i32_const(Zt))),Y.addCode(f.call(n+"_prepareG2",f.getLocal("q"),f.i32_const(vt))),Y.addCode(f.call(n+"_millerLoop",f.i32_const(Zt),f.i32_const(vt),_)),Y.addCode(f.call(n+"_finalExponentiation",_,f.getLocal("r")))}yt(),It(),Lt(),Ot(),Et(),jt(),bt();for(let Y=0;Y<10;Y++)pt(Y),t.exportFunction(n+"__frobeniusMap"+Y);Mt(),Pt();for(let Y=1;Y<=5;Y++)Wt(Y),t.exportFunction(n+"_pairingEq"+Y);wt(),t.exportFunction(n+"_pairing"),t.exportFunction(n+"_prepareG1"),t.exportFunction(n+"_prepareG2"),t.exportFunction(n+"_millerLoop"),t.exportFunction(n+"_finalExponentiation"),t.exportFunction(n+"_finalExponentiationOld"),t.exportFunction(n+"__mulBy024"),t.exportFunction(n+"__mulBy024Old"),t.exportFunction(n+"__cyclotomicSquare"),t.exportFunction(n+"__cyclotomicExp_w0")};const Dt=ye,ys=Xn,Cs=ma,Ai=ba,As=ya,Fi=Ca,bn=Aa,Fs=Fa,Es=Ea,Ne=wa,{bitLength:Ei,isOdd:wi,isNegative:ws}=le;var Bs=function(t,e){const n=e||"bls12381";if(t.modules[n])return n;const i=0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn,s=0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001n,g=Math.floor((Ei(i-1n)-1)/64)+1,d=g*8,C=d,l=C*2,o=C*12,y=Math.floor((Ei(s-1n)-1)/64)+1,E=y*8,m=E,x=t.alloc(Dt.bigInt2BytesLE(s,m)),O=ys(t,i,"f1m","intq");Cs(t,s,"fr","frm","intr");const L=t.alloc(Dt.bigInt2BytesLE(F(4n),C)),I=Fi(t,"g1m","f1m",L);bn(t,"frm","frm","frm","frm_mul"),Fs(t,"pol","frm"),Es(t,"qap","frm");const v=Ai(t,"f1m_neg","f2m","f1m"),U=t.alloc([...Dt.bigInt2BytesLE(F(4n),C),...Dt.bigInt2BytesLE(F(4n),C)]),w=Fi(t,"g2m","f2m",U);function S(f,_){const Z=t.addFunction(f);Z.addParam("pG","i32"),Z.addParam("pFr","i32"),Z.addParam("pr","i32");const Q=Z.getCodeBuilder(),$=Q.i32_const(t.alloc(E));Z.addCode(Q.call("frm_fromMontgomery",Q.getLocal("pFr"),$),Q.call(_,Q.getLocal("pG"),$,Q.i32_const(E),Q.getLocal("pr"))),t.exportFunction(f)}S("g1m_timesFr","g1m_timesScalar"),bn(t,"g1m","g1m","frm","g1m_timesFr"),S("g2m_timesFr","g2m_timesScalar"),bn(t,"g2m","g2m","frm","g2m_timesFr"),S("g1m_timesFrAffine","g1m_timesScalarAffine"),S("g2m_timesFrAffine","g2m_timesScalarAffine"),Ne(t,"frm_batchApplyKey","fmr","frm",E,E,E,"frm_mul"),Ne(t,"g1m_batchApplyKey","g1m","frm",d*3,d*3,E,"g1m_timesFr"),Ne(t,"g1m_batchApplyKeyMixed","g1m","frm",d*2,d*3,E,"g1m_timesFrAffine"),Ne(t,"g2m_batchApplyKey","g2m","frm",d*2*3,d*3*2,E,"g2m_timesFr"),Ne(t,"g2m_batchApplyKeyMixed","g2m","frm",d*2*2,d*3*2,E,"g2m_timesFrAffine");function F(f){return BigInt(f)*(1n<<BigInt(C*8))%i}const r=[3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507n,1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569n,1n],h=t.alloc([...Dt.bigInt2BytesLE(F(r[0]),C),...Dt.bigInt2BytesLE(F(r[1]),C),...Dt.bigInt2BytesLE(F(r[2]),C)]),R=[0n,1n,0n],j=t.alloc([...Dt.bigInt2BytesLE(F(R[0]),C),...Dt.bigInt2BytesLE(F(R[1]),C),...Dt.bigInt2BytesLE(F(R[2]),C)]),T=[[352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160n,3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758n],[1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905n,927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582n],[1n,0n]],M=t.alloc([...Dt.bigInt2BytesLE(F(T[0][0]),C),...Dt.bigInt2BytesLE(F(T[0][1]),C),...Dt.bigInt2BytesLE(F(T[1][0]),C),...Dt.bigInt2BytesLE(F(T[1][1]),C),...Dt.bigInt2BytesLE(F(T[2][0]),C),...Dt.bigInt2BytesLE(F(T[2][1]),C)]),A=[[0n,0n],[1n,0n],[0n,0n]],D=t.alloc([...Dt.bigInt2BytesLE(F(A[0][0]),C),...Dt.bigInt2BytesLE(F(A[0][1]),C),...Dt.bigInt2BytesLE(F(A[1][0]),C),...Dt.bigInt2BytesLE(F(A[1][1]),C),...Dt.bigInt2BytesLE(F(A[2][0]),C),...Dt.bigInt2BytesLE(F(A[2][1]),C)]),H=t.alloc([...Dt.bigInt2BytesLE(F(1n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C),...Dt.bigInt2BytesLE(F(0n),C)]),ut=t.alloc([...Dt.bigInt2BytesLE(F(1n),C),...Dt.bigInt2BytesLE(F(1n),C)]);function nt(){const f=t.addFunction(v+"_mulNR");f.addParam("x","i32"),f.addParam("pr","i32");const _=f.getCodeBuilder(),Z=_.i32_const(t.alloc(C)),Q=_.getLocal("x"),$=_.i32_add(_.getLocal("x"),_.i32_const(C)),tt=_.getLocal("pr"),V=_.i32_add(_.getLocal("pr"),_.i32_const(C));f.addCode(_.call(O+"_copy",Q,Z),_.call(O+"_sub",Q,$,tt),_.call(O+"_add",Z,$,V))}nt();const J=As(t,v+"_mulNR","f6m","f2m");function ft(){const f=t.addFunction(J+"_mulNR");f.addParam("x","i32"),f.addParam("pr","i32");const _=f.getCodeBuilder(),Z=_.i32_const(t.alloc(C*2));f.addCode(_.call(v+"_copy",_.getLocal("x"),Z),_.call(v+"_mulNR",_.i32_add(_.getLocal("x"),_.i32_const(d*4)),_.getLocal("pr")),_.call(v+"_copy",_.i32_add(_.getLocal("x"),_.i32_const(d*2)),_.i32_add(_.getLocal("pr"),_.i32_const(d*4))),_.call(v+"_copy",Z,_.i32_add(_.getLocal("pr"),_.i32_const(d*2))))}ft();const it=Ai(t,J+"_mulNR","ftm",J),zt=At(0xd201000000010000n),G=t.alloc(zt),K=3*l,P=zt.length-1,q=zt.reduce((f,_)=>f+(_!=0?1:0),0)+P+1,u=3*2*d,W=3*d*2+q*K,z=!0,b=15132376222941642752n;t.modules[n]={n64q:g,n64r:y,n8q:d,n8r:E,pG1gen:h,pG1zero:j,pG1b:L,pG2gen:M,pG2zero:D,pG2b:U,pq:t.modules.f1m.pq,pr:x,pOneT:H,r:s,q:i,prePSize:u,preQSize:W};function at(f){let _=f;const Z=[];for(;_>0n;){if(wi(_)){const Q=2-Number(_%4n);Z.push(Q),_=_-BigInt(Q)}else Z.push(0);_=_>>1n}return Z}function At(f){let _=f;const Z=[];for(;_>0n;)wi(_)?Z.push(1):Z.push(0),_=_>>1n;return Z}function Lt(){const f=t.addFunction(n+"_prepareG1");f.addParam("pP","i32"),f.addParam("ppreP","i32");const _=f.getCodeBuilder();f.addCode(_.call(I+"_normalize",_.getLocal("pP"),_.getLocal("ppreP")))}function yt(){const f=t.addFunction(n+"_prepDblStep");f.addParam("R","i32"),f.addParam("r","i32");const _=f.getCodeBuilder(),Z=_.getLocal("R"),Q=_.i32_add(_.getLocal("R"),_.i32_const(2*d)),$=_.i32_add(_.getLocal("R"),_.i32_const(4*d)),tt=_.getLocal("r"),V=_.i32_add(_.getLocal("r"),_.i32_const(2*d)),ct=_.i32_add(_.getLocal("r"),_.i32_const(4*d)),st=_.i32_const(t.alloc(l)),rt=_.i32_const(t.alloc(l)),ot=_.i32_const(t.alloc(l)),gt=_.i32_const(t.alloc(l)),Bt=_.i32_const(t.alloc(l));f.addCode(_.call(v+"_square",Z,tt),_.call(v+"_square",Q,rt),_.call(v+"_square",rt,ot),_.call(v+"_add",rt,Z,V),_.call(v+"_square",V,V),_.call(v+"_sub",V,tt,V),_.call(v+"_sub",V,ot,V),_.call(v+"_add",V,V,V),_.call(v+"_add",tt,tt,gt),_.call(v+"_add",gt,tt,gt),_.call(v+"_add",Z,gt,ct),_.call(v+"_square",gt,Bt),_.call(v+"_square",$,st),_.call(v+"_sub",Bt,V,Z),_.call(v+"_sub",Z,V,Z),_.call(v+"_add",$,Q,$),_.call(v+"_square",$,$),_.call(v+"_sub",$,rt,$),_.call(v+"_sub",$,st,$),_.call(v+"_sub",V,Z,Q),_.call(v+"_mul",Q,gt,Q),_.call(v+"_add",ot,ot,ot),_.call(v+"_add",ot,ot,ot),_.call(v+"_add",ot,ot,ot),_.call(v+"_sub",Q,ot,Q),_.call(v+"_mul",gt,st,V),_.call(v+"_add",V,V,V),_.call(v+"_neg",V,V),_.call(v+"_square",ct,ct),_.call(v+"_sub",ct,tt,ct),_.call(v+"_sub",ct,Bt,ct),_.call(v+"_add",rt,rt,rt),_.call(v+"_add",rt,rt,rt),_.call(v+"_sub",ct,rt,ct),_.call(v+"_mul",$,st,tt),_.call(v+"_add",tt,tt,tt))}function It(){const f=t.addFunction(n+"_prepAddStep");f.addParam("R","i32"),f.addParam("Q","i32"),f.addParam("r","i32");const _=f.getCodeBuilder(),Z=_.getLocal("R"),Q=_.i32_add(_.getLocal("R"),_.i32_const(2*d)),$=_.i32_add(_.getLocal("R"),_.i32_const(4*d)),tt=_.getLocal("Q"),V=_.i32_add(_.getLocal("Q"),_.i32_const(2*d)),ct=_.getLocal("r"),st=_.i32_add(_.getLocal("r"),_.i32_const(2*d)),rt=_.i32_add(_.getLocal("r"),_.i32_const(4*d)),ot=_.i32_const(t.alloc(l)),gt=_.i32_const(t.alloc(l)),Bt=_.i32_const(t.alloc(l)),Ft=_.i32_const(t.alloc(l)),ht=_.i32_const(t.alloc(l)),xt=_.i32_const(t.alloc(l)),Tt=_.i32_const(t.alloc(l)),Ut=_.i32_const(t.alloc(l)),St=_.i32_const(t.alloc(l)),kt=_.i32_const(t.alloc(l)),k=_.i32_const(t.alloc(l));f.addCode(_.call(v+"_square",$,ot),_.call(v+"_square",V,gt),_.call(v+"_mul",ot,tt,Ft),_.call(v+"_add",V,$,st),_.call(v+"_square",st,st),_.call(v+"_sub",st,gt,st),_.call(v+"_sub",st,ot,st),_.call(v+"_mul",st,ot,st),_.call(v+"_sub",Ft,Z,ht),_.call(v+"_square",ht,xt),_.call(v+"_add",xt,xt,Tt),_.call(v+"_add",Tt,Tt,Tt),_.call(v+"_mul",Tt,ht,Ut),_.call(v+"_sub",st,Q,St),_.call(v+"_sub",St,Q,St),_.call(v+"_mul",St,tt,rt),_.call(v+"_mul",Tt,Z,kt),_.call(v+"_square",St,Z),_.call(v+"_sub",Z,Ut,Z),_.call(v+"_sub",Z,kt,Z),_.call(v+"_sub",Z,kt,Z),_.call(v+"_add",$,ht,$),_.call(v+"_square",$,$),_.call(v+"_sub",$,ot,$),_.call(v+"_sub",$,xt,$),_.call(v+"_add",V,$,ct),_.call(v+"_sub",kt,Z,k),_.call(v+"_mul",k,St,k),_.call(v+"_mul",Q,Ut,Ft),_.call(v+"_add",Ft,Ft,Ft),_.call(v+"_sub",k,Ft,Q),_.call(v+"_square",ct,ct),_.call(v+"_sub",ct,gt,ct),_.call(v+"_square",$,Bt),_.call(v+"_sub",ct,Bt,ct),_.call(v+"_add",rt,rt,rt),_.call(v+"_sub",rt,ct,rt),_.call(v+"_add",$,$,ct),_.call(v+"_neg",St,St),_.call(v+"_add",St,St,st))}function mt(){const f=t.addFunction(n+"_prepareG2");f.addParam("pQ","i32"),f.addParam("ppreQ","i32"),f.addLocal("pCoef","i32"),f.addLocal("i","i32");const _=f.getCodeBuilder(),Z=_.getLocal("pQ"),Q=t.alloc(l*3),$=_.i32_const(Q),tt=_.getLocal("ppreQ");f.addCode(_.call(w+"_normalize",Z,tt),_.if(_.call(w+"_isZero",tt),_.ret([])),_.call(w+"_copy",tt,$),_.setLocal("pCoef",_.i32_add(_.getLocal("ppreQ"),_.i32_const(l*3)))),f.addCode(_.setLocal("i",_.i32_const(zt.length-2)),_.block(_.loop(_.call(n+"_prepDblStep",$,_.getLocal("pCoef")),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(K))),_.if(_.i32_load8_s(_.getLocal("i"),G),[..._.call(n+"_prepAddStep",$,tt,_.getLocal("pCoef")),..._.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(K)))]),_.br_if(1,_.i32_eqz(_.getLocal("i"))),_.setLocal("i",_.i32_sub(_.getLocal("i"),_.i32_const(1))),_.br(0))))}function Ot(){const f=t.addFunction(J+"_mul1");f.addParam("pA","i32"),f.addParam("pC1","i32"),f.addParam("pR","i32");const _=f.getCodeBuilder(),Z=_.getLocal("pA"),Q=_.i32_add(_.getLocal("pA"),_.i32_const(C*2)),$=_.i32_add(_.getLocal("pA"),_.i32_const(C*4)),tt=_.getLocal("pC1"),V=_.getLocal("pR"),ct=_.i32_add(_.getLocal("pR"),_.i32_const(C*2)),st=_.i32_add(_.getLocal("pR"),_.i32_const(C*4)),rt=_.i32_const(t.alloc(C*2)),ot=_.i32_const(t.alloc(C*2));f.addCode(_.call(v+"_add",Z,Q,rt),_.call(v+"_add",Q,$,ot),_.call(v+"_mul",Q,tt,st),_.call(v+"_mul",ot,tt,V),_.call(v+"_sub",V,st,V),_.call(v+"_mulNR",V,V),_.call(v+"_mul",rt,tt,ct),_.call(v+"_sub",ct,st,ct))}Ot();function jt(){const f=t.addFunction(J+"_mul01");f.addParam("pA","i32"),f.addParam("pC0","i32"),f.addParam("pC1","i32"),f.addParam("pR","i32");const _=f.getCodeBuilder(),Z=_.getLocal("pA"),Q=_.i32_add(_.getLocal("pA"),_.i32_const(C*2)),$=_.i32_add(_.getLocal("pA"),_.i32_const(C*4)),tt=_.getLocal("pC0"),V=_.getLocal("pC1"),ct=_.getLocal("pR"),st=_.i32_add(_.getLocal("pR"),_.i32_const(C*2)),rt=_.i32_add(_.getLocal("pR"),_.i32_const(C*4)),ot=_.i32_const(t.alloc(C*2)),gt=_.i32_const(t.alloc(C*2)),Bt=_.i32_const(t.alloc(C*2)),Ft=_.i32_const(t.alloc(C*2));f.addCode(_.call(v+"_mul",Z,tt,ot),_.call(v+"_mul",Q,V,gt),_.call(v+"_add",Z,Q,Bt),_.call(v+"_add",Z,$,Ft),_.call(v+"_add",Q,$,ct),_.call(v+"_mul",ct,V,ct),_.call(v+"_sub",ct,gt,ct),_.call(v+"_mulNR",ct,ct),_.call(v+"_add",ct,ot,ct),_.call(v+"_add",tt,V,st),_.call(v+"_mul",st,Bt,st),_.call(v+"_sub",st,ot,st),_.call(v+"_sub",st,gt,st),_.call(v+"_mul",Ft,tt,rt),_.call(v+"_sub",rt,ot,rt),_.call(v+"_add",rt,gt,rt))}jt();function Et(){const f=t.addFunction(it+"_mul014");f.addParam("pA","i32"),f.addParam("pC0","i32"),f.addParam("pC1","i32"),f.addParam("pC4","i32"),f.addParam("pR","i32");const _=f.getCodeBuilder(),Z=_.getLocal("pA"),Q=_.i32_add(_.getLocal("pA"),_.i32_const(C*6)),$=_.getLocal("pC0"),tt=_.getLocal("pC1"),V=_.getLocal("pC4"),ct=_.i32_const(t.alloc(C*6)),st=_.i32_const(t.alloc(C*6)),rt=_.i32_const(t.alloc(C*2)),ot=_.getLocal("pR"),gt=_.i32_add(_.getLocal("pR"),_.i32_const(C*6));f.addCode(_.call(J+"_mul01",Z,$,tt,ct),_.call(J+"_mul1",Q,V,st),_.call(v+"_add",tt,V,rt),_.call(J+"_add",Q,Z,gt),_.call(J+"_mul01",gt,$,rt,gt),_.call(J+"_sub",gt,ct,gt),_.call(J+"_sub",gt,st,gt),_.call(J+"_copy",st,ot),_.call(J+"_mulNR",ot,ot),_.call(J+"_add",ot,ct,ot))}Et();function bt(){const f=t.addFunction(n+"_ell");f.addParam("pP","i32"),f.addParam("pCoefs","i32"),f.addParam("pF","i32");const _=f.getCodeBuilder(),Z=_.getLocal("pP"),Q=_.i32_add(_.getLocal("pP"),_.i32_const(d)),$=_.getLocal("pF"),tt=_.getLocal("pCoefs"),V=_.i32_add(_.getLocal("pCoefs"),_.i32_const(C)),ct=_.i32_add(_.getLocal("pCoefs"),_.i32_const(C*2)),st=_.i32_add(_.getLocal("pCoefs"),_.i32_const(C*3)),rt=_.i32_add(_.getLocal("pCoefs"),_.i32_const(C*4)),ot=t.alloc(C*2),gt=_.i32_const(ot),Bt=_.i32_const(ot),Ft=_.i32_const(ot+C),ht=t.alloc(C*2),xt=_.i32_const(ht),Tt=_.i32_const(ht),Ut=_.i32_const(ht+C);f.addCode(_.call(O+"_mul",tt,Q,Bt),_.call(O+"_mul",V,Q,Ft),_.call(O+"_mul",ct,Z,Tt),_.call(O+"_mul",st,Z,Ut),_.call(it+"_mul014",$,rt,xt,gt,$))}bt();function pt(){const f=t.addFunction(n+"_millerLoop");f.addParam("ppreP","i32"),f.addParam("ppreQ","i32"),f.addParam("r","i32"),f.addLocal("pCoef","i32"),f.addLocal("i","i32");const _=f.getCodeBuilder(),Z=_.getLocal("ppreP"),Q=_.getLocal("pCoef"),$=_.getLocal("r");f.addCode(_.call(it+"_one",$),_.if(_.call(I+"_isZero",Z),_.ret([])),_.if(_.call(I+"_isZero",_.getLocal("ppreQ")),_.ret([])),_.setLocal("pCoef",_.i32_add(_.getLocal("ppreQ"),_.i32_const(l*3))),_.setLocal("i",_.i32_const(zt.length-2)),_.block(_.loop(_.call(n+"_ell",Z,Q,$),_.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(K))),_.if(_.i32_load8_s(_.getLocal("i"),G),[..._.call(n+"_ell",Z,Q,$),..._.setLocal("pCoef",_.i32_add(_.getLocal("pCoef"),_.i32_const(K)))]),_.call(it+"_square",$,$),_.br_if(1,_.i32_eq(_.getLocal("i"),_.i32_const(1))),_.setLocal("i",_.i32_sub(_.getLocal("i"),_.i32_const(1))),_.br(0))),_.call(n+"_ell",Z,Q,$)),f.addCode(_.call(it+"_conjugate",$,$))}function $t(f){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],[3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n,151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351n,0n],[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n,877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n],[4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786n,0n],[151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n,3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n,0n],[877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n,3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n]]],Z=[[[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]]],Q=t.addFunction(it+"_frobeniusMap"+f);Q.addParam("x","i32"),Q.addParam("r","i32");const $=Q.getCodeBuilder();for(let V=0;V<6;V++){const ct=V==0?$.getLocal("x"):$.i32_add($.getLocal("x"),$.i32_const(V*l)),st=ct,rt=$.i32_add($.getLocal("x"),$.i32_const(V*l+C)),ot=V==0?$.getLocal("r"):$.i32_add($.getLocal("r"),$.i32_const(V*l)),gt=ot,Bt=$.i32_add($.getLocal("r"),$.i32_const(V*l+C)),Ft=tt(_[Math.floor(V/3)][f%12],Z[V%3][f%6]),ht=t.alloc([...Dt.bigInt2BytesLE(F(Ft[0]),d),...Dt.bigInt2BytesLE(F(Ft[1]),d)]);f%2==1?Q.addCode($.call(O+"_copy",st,gt),$.call(O+"_neg",rt,Bt),$.call(v+"_mul",ot,$.i32_const(ht),ot)):Q.addCode($.call(v+"_mul",ct,$.i32_const(ht),ot))}function tt(V,ct){const st=V[0],rt=V[1],ot=ct[0],gt=ct[1],Bt=[(st*ot-rt*gt)%i,(st*gt+rt*ot)%i];return ws(Bt[0])&&(Bt[0]=Bt[0]+i),Bt}}function Jt(){const f=t.addFunction(n+"__cyclotomicSquare");f.addParam("x","i32"),f.addParam("r","i32");const _=f.getCodeBuilder(),Z=_.getLocal("x"),Q=_.i32_add(_.getLocal("x"),_.i32_const(l)),$=_.i32_add(_.getLocal("x"),_.i32_const(2*l)),tt=_.i32_add(_.getLocal("x"),_.i32_const(3*l)),V=_.i32_add(_.getLocal("x"),_.i32_const(4*l)),ct=_.i32_add(_.getLocal("x"),_.i32_const(5*l)),st=_.getLocal("r"),rt=_.i32_add(_.getLocal("r"),_.i32_const(l)),ot=_.i32_add(_.getLocal("r"),_.i32_const(2*l)),gt=_.i32_add(_.getLocal("r"),_.i32_const(3*l)),Bt=_.i32_add(_.getLocal("r"),_.i32_const(4*l)),Ft=_.i32_add(_.getLocal("r"),_.i32_const(5*l)),ht=_.i32_const(t.alloc(l)),xt=_.i32_const(t.alloc(l)),Tt=_.i32_const(t.alloc(l)),Ut=_.i32_const(t.alloc(l)),St=_.i32_const(t.alloc(l)),kt=_.i32_const(t.alloc(l)),k=_.i32_const(t.alloc(l)),et=_.i32_const(t.alloc(l));f.addCode(_.call(v+"_mul",Z,V,k),_.call(v+"_mulNR",V,ht),_.call(v+"_add",Z,ht,ht),_.call(v+"_add",Z,V,et),_.call(v+"_mul",et,ht,ht),_.call(v+"_mulNR",k,et),_.call(v+"_add",k,et,et),_.call(v+"_sub",ht,et,ht),_.call(v+"_add",k,k,xt),_.call(v+"_mul",tt,$,k),_.call(v+"_mulNR",$,Tt),_.call(v+"_add",tt,Tt,Tt),_.call(v+"_add",tt,$,et),_.call(v+"_mul",et,Tt,Tt),_.call(v+"_mulNR",k,et),_.call(v+"_add",k,et,et),_.call(v+"_sub",Tt,et,Tt),_.call(v+"_add",k,k,Ut),_.call(v+"_mul",Q,ct,k),_.call(v+"_mulNR",ct,St),_.call(v+"_add",Q,St,St),_.call(v+"_add",Q,ct,et),_.call(v+"_mul",et,St,St),_.call(v+"_mulNR",k,et),_.call(v+"_add",k,et,et),_.call(v+"_sub",St,et,St),_.call(v+"_add",k,k,kt),_.call(v+"_sub",ht,Z,st),_.call(v+"_add",st,st,st),_.call(v+"_add",ht,st,st),_.call(v+"_add",xt,V,Bt),_.call(v+"_add",Bt,Bt,Bt),_.call(v+"_add",xt,Bt,Bt),_.call(v+"_mul",kt,_.i32_const(ut),et),_.call(v+"_add",et,tt,gt),_.call(v+"_add",gt,gt,gt),_.call(v+"_add",et,gt,gt),_.call(v+"_sub",St,$,ot),_.call(v+"_add",ot,ot,ot),_.call(v+"_add",St,ot,ot),_.call(v+"_sub",Tt,Q,rt),_.call(v+"_add",rt,rt,rt),_.call(v+"_add",Tt,rt,rt),_.call(v+"_add",Ut,ct,Ft),_.call(v+"_add",Ft,Ft,Ft),_.call(v+"_add",Ut,Ft,Ft))}function re(f,_,Z){const Q=at(f).map(ot=>ot==-1?255:ot),$=t.alloc(Q),tt=t.addFunction(n+"__cyclotomicExp_"+Z);tt.addParam("x","i32"),tt.addParam("r","i32"),tt.addLocal("bit","i32"),tt.addLocal("i","i32");const V=tt.getCodeBuilder(),ct=V.getLocal("x"),st=V.getLocal("r"),rt=V.i32_const(t.alloc(o));tt.addCode(V.call(it+"_conjugate",ct,rt),V.call(it+"_one",st),V.if(V.teeLocal("bit",V.i32_load8_s(V.i32_const(Q.length-1),$)),V.if(V.i32_eq(V.getLocal("bit"),V.i32_const(1)),V.call(it+"_mul",st,ct,st),V.call(it+"_mul",st,rt,st))),V.setLocal("i",V.i32_const(Q.length-2)),V.block(V.loop(V.call(n+"__cyclotomicSquare",st,st),V.if(V.teeLocal("bit",V.i32_load8_s(V.getLocal("i"),$)),V.if(V.i32_eq(V.getLocal("bit"),V.i32_const(1)),V.call(it+"_mul",st,ct,st),V.call(it+"_mul",st,rt,st))),V.br_if(1,V.i32_eqz(V.getLocal("i"))),V.setLocal("i",V.i32_sub(V.getLocal("i"),V.i32_const(1))),V.br(0)))),_&&tt.addCode(V.call(it+"_conjugate",st,st))}function te(){Jt(),re(b,z,"w0");const f=t.addFunction(n+"_finalExponentiation");f.addParam("x","i32"),f.addParam("r","i32");const _=f.getCodeBuilder(),Z=_.getLocal("x"),Q=_.getLocal("r"),$=_.i32_const(t.alloc(o)),tt=_.i32_const(t.alloc(o)),V=_.i32_const(t.alloc(o)),ct=_.i32_const(t.alloc(o)),st=_.i32_const(t.alloc(o)),rt=_.i32_const(t.alloc(o)),ot=_.i32_const(t.alloc(o));f.addCode(_.call(it+"_frobeniusMap6",Z,$),_.call(it+"_inverse",Z,tt),_.call(it+"_mul",$,tt,V),_.call(it+"_copy",V,tt),_.call(it+"_frobeniusMap2",V,V),_.call(it+"_mul",V,tt,V),_.call(n+"__cyclotomicSquare",V,tt),_.call(it+"_conjugate",tt,tt),_.call(n+"__cyclotomicExp_w0",V,ct),_.call(n+"__cyclotomicSquare",ct,st),_.call(it+"_mul",tt,ct,rt),_.call(n+"__cyclotomicExp_w0",rt,tt),_.call(n+"__cyclotomicExp_w0",tt,$),_.call(n+"__cyclotomicExp_w0",$,ot),_.call(it+"_mul",ot,st,ot),_.call(n+"__cyclotomicExp_w0",ot,st),_.call(it+"_conjugate",rt,rt),_.call(it+"_mul",st,rt,st),_.call(it+"_mul",st,V,st),_.call(it+"_conjugate",V,rt),_.call(it+"_mul",tt,V,tt),_.call(it+"_frobeniusMap3",tt,tt),_.call(it+"_mul",ot,rt,ot),_.call(it+"_frobeniusMap1",ot,ot),_.call(it+"_mul",ct,$,ct),_.call(it+"_frobeniusMap2",ct,ct),_.call(it+"_mul",ct,tt,ct),_.call(it+"_mul",ct,ot,ct),_.call(it+"_mul",ct,st,Q))}function Pt(){const f=t.addFunction(n+"_finalExponentiationOld");f.addParam("x","i32"),f.addParam("r","i32");const Z=t.alloc(Dt.bigInt2BytesLE(322277361516934140462891564586510139908379969514828494218366688025288661041104682794998680497580008899973249814104447692778988208376779573819485263026159588510513834876303014016798809919343532899164848730280942609956670917565618115867287399623286813270357901731510188149934363360381614501334086825442271920079363289954510565375378443704372994881406797882676971082200626541916413184642520269678897559532260949334760604962086348898118982248842634379637598665468817769075878555493752214492790122785850202957575200176084204422751485957336465472324810982833638490904279282696134323072515220044451592646885410572234451732790590013479358343841220074174848221722017083597872017638514103174122784843925578370430843522959600095676285723737049438346544753168912974976791528535276317256904336520179281145394686565050419250614107803233314658825463117900250701199181529205942363159325765991819433914303908860460720581408201373164047773794825411011922305820065611121544561808414055302212057471395719432072209245600258134364584636810093520285711072578721435517884103526483832733289802426157301542744476740008494780363354305116978805620671467071400711358839553375340724899735460480144599782014906586543813292157922220645089192130209334926661588737007768565838519456601560804957985667880395221049249803753582637708560n,544)),Q=f.getCodeBuilder();f.addCode(Q.call(it+"_exp",Q.getLocal("x"),Q.i32_const(Z),Q.i32_const(544),Q.getLocal("r")))}const Mt=t.alloc(u),Zt=t.alloc(W);function vt(f){const _=t.addFunction(n+"_pairingEq"+f);for(let tt=0;tt<f;tt++)_.addParam("p_"+tt,"i32"),_.addParam("q_"+tt,"i32");_.addParam("c","i32"),_.setReturnType("i32");const Z=_.getCodeBuilder(),Q=Z.i32_const(t.alloc(o)),$=Z.i32_const(t.alloc(o));_.addCode(Z.call(it+"_one",Q));for(let tt=0;tt<f;tt++)_.addCode(Z.call(n+"_prepareG1",Z.getLocal("p_"+tt),Z.i32_const(Mt))),_.addCode(Z.call(n+"_prepareG2",Z.getLocal("q_"+tt),Z.i32_const(Zt))),_.addCode(Z.if(Z.i32_eqz(Z.call(I+"_inGroupAffine",Z.i32_const(Mt))),Z.ret(Z.i32_const(0))),Z.if(Z.i32_eqz(Z.call(w+"_inGroupAffine",Z.i32_const(Zt))),Z.ret(Z.i32_const(0)))),_.addCode(Z.call(n+"_millerLoop",Z.i32_const(Mt),Z.i32_const(Zt),$)),_.addCode(Z.call(it+"_mul",Q,$,Q));_.addCode(Z.call(n+"_finalExponentiation",Q,Q)),_.addCode(Z.call(it+"_eq",Q,Z.getLocal("c")))}function Wt(){const f=t.addFunction(n+"_pairing");f.addParam("p","i32"),f.addParam("q","i32"),f.addParam("r","i32");const _=f.getCodeBuilder(),Z=_.i32_const(t.alloc(o));f.addCode(_.call(n+"_prepareG1",_.getLocal("p"),_.i32_const(Mt))),f.addCode(_.call(n+"_prepareG2",_.getLocal("q"),_.i32_const(Zt))),f.addCode(_.call(n+"_millerLoop",_.i32_const(Mt),_.i32_const(Zt),Z)),f.addCode(_.call(n+"_finalExponentiation",Z,_.getLocal("r")))}function wt(){const f=t.addFunction(w+"_inGroupAffine");f.addParam("p","i32"),f.setReturnType("i32");const _=f.getCodeBuilder(),Z=[2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279894n,2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279893n],Q=4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,$=[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],tt=_.i32_const(t.alloc([...Dt.bigInt2BytesLE(F(Z[0]),d),...Dt.bigInt2BytesLE(F(Z[1]),d)])),V=_.i32_const(t.alloc(Dt.bigInt2BytesLE(F(Q),d))),ct=_.i32_const(t.alloc([...Dt.bigInt2BytesLE(F($[0]),d),...Dt.bigInt2BytesLE(F($[1]),d)])),st=_.i32_const(t.alloc(Dt.bigInt2BytesLE(b,8))),rt=_.getLocal("p"),ot=_.i32_add(_.getLocal("p"),_.i32_const(l)),gt=_.i32_const(t.alloc(C)),Bt=_.i32_const(t.alloc(l)),Ft=_.i32_const(t.alloc(l)),ht=t.alloc(l*2),xt=_.i32_const(ht),Tt=_.i32_const(ht),Ut=_.i32_const(ht),St=_.i32_const(ht+C),kt=_.i32_const(ht+l),k=_.i32_const(ht+l),et=_.i32_const(ht+l+C),dt=t.alloc(l*3),qt=_.i32_const(dt),Ht=_.i32_const(dt),Qt=_.i32_const(dt),Kt=_.i32_const(dt+C),fe=_.i32_const(dt+l),Ce=_.i32_const(dt+l),Te=_.i32_const(dt+l+C),fn=_.i32_const(dt+l*2);f.addCode(_.if(_.call(w+"_isZeroAffine",_.getLocal("p")),_.ret(_.i32_const(1))),_.if(_.i32_eqz(_.call(w+"_inCurveAffine",_.getLocal("p"))),_.ret(_.i32_const(0))),_.call(v+"_mul",rt,tt,Bt),_.call(v+"_mul",ot,tt,Ft),_.call(v+"_mul1",Bt,V,Tt),_.call(v+"_neg",Ft,kt),_.call(v+"_neg",Bt,Ht),_.call(v+"_mul",Ft,ct,fe),_.call(O+"_sub",Ut,St,gt),_.call(O+"_add",Ut,St,St),_.call(O+"_copy",gt,Ut),_.call(O+"_sub",k,et,gt),_.call(O+"_add",k,et,et),_.call(O+"_copy",gt,k),_.call(O+"_add",Qt,Kt,gt),_.call(O+"_sub",Qt,Kt,Kt),_.call(O+"_copy",gt,Qt),_.call(O+"_sub",Te,Ce,gt),_.call(O+"_add",Ce,Te,Te),_.call(O+"_copy",gt,Ce),_.call(v+"_one",fn),_.call(w+"_timesScalar",qt,st,_.i32_const(8),qt),_.call(w+"_addMixed",qt,xt,qt),_.ret(_.call(w+"_eqMixed",qt,_.getLocal("p"))));const xe=t.addFunction(w+"_inGroup");xe.addParam("pIn","i32"),xe.setReturnType("i32");const Ae=xe.getCodeBuilder(),Qe=Ae.i32_const(t.alloc(l*2));xe.addCode(Ae.call(w+"_toAffine",Ae.getLocal("pIn"),Qe),Ae.ret(Ae.call(w+"_inGroupAffine",Qe)))}function Y(){const f=t.addFunction(I+"_inGroupAffine");f.addParam("p","i32"),f.setReturnType("i32");const _=f.getCodeBuilder(),Z=4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,Q=793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,$=(b*b-1n)/3n,tt=_.i32_const(t.alloc(Dt.bigInt2BytesLE(F(Z),d))),V=_.i32_const(t.alloc(Dt.bigInt2BytesLE(F(Q),d))),ct=_.i32_const(t.alloc(Dt.bigInt2BytesLE($,16))),st=_.getLocal("p"),rt=_.i32_add(_.getLocal("p"),_.i32_const(C)),ot=t.alloc(C*3),gt=_.i32_const(ot),Bt=_.i32_const(ot),Ft=_.i32_const(ot+C),ht=t.alloc(C*2),xt=_.i32_const(ht),Tt=_.i32_const(ht),Ut=_.i32_const(ht+C);f.addCode(_.if(_.call(I+"_isZeroAffine",_.getLocal("p")),_.ret(_.i32_const(1))),_.if(_.i32_eqz(_.call(I+"_inCurveAffine",_.getLocal("p"))),_.ret(_.i32_const(0))),_.call(O+"_mul",st,tt,Bt),_.call(O+"_copy",rt,Ft),_.call(O+"_mul",st,V,Tt),_.call(O+"_copy",rt,Ut),_.call(I+"_doubleAffine",gt,gt),_.call(I+"_subMixed",gt,_.getLocal("p"),gt),_.call(I+"_subMixed",gt,xt,gt),_.call(I+"_timesScalar",gt,ct,_.i32_const(16),gt),_.ret(_.call(I+"_eqMixed",gt,xt)));const St=t.addFunction(I+"_inGroup");St.addParam("pIn","i32"),St.setReturnType("i32");const kt=St.getCodeBuilder(),k=kt.i32_const(t.alloc(C*2));St.addCode(kt.call(I+"_toAffine",kt.getLocal("pIn"),k),kt.ret(kt.call(I+"_inGroupAffine",k)))}for(let f=0;f<10;f++)$t(f),t.exportFunction(it+"_frobeniusMap"+f);Y(),wt(),It(),yt(),Lt(),mt(),pt(),Pt(),te();for(let f=1;f<=5;f++)vt(f),t.exportFunction(n+"_pairingEq"+f);Wt(),t.exportFunction(n+"_pairing"),t.exportFunction(n+"_prepareG1"),t.exportFunction(n+"_prepareG2"),t.exportFunction(n+"_millerLoop"),t.exportFunction(n+"_finalExponentiation"),t.exportFunction(n+"_finalExponentiationOld"),t.exportFunction(n+"__cyclotomicSquare"),t.exportFunction(n+"__cyclotomicExp_w0"),t.exportFunction(J+"_mul1"),t.exportFunction(J+"_mul01"),t.exportFunction(it+"_mul014"),t.exportFunction(I+"_inGroupAffine"),t.exportFunction(I+"_inGroup"),t.exportFunction(w+"_inGroupAffine"),t.exportFunction(w+"_inGroup")},vs=bs,xs=Bs;function In(c){if(typeof c=="bigint"||c.eq!==void 0)return c.toString(10);if(c instanceof Uint8Array)return Ge(c,0);if(Array.isArray(c))return c.map(In);if(typeof c=="object"){const t={};return Object.keys(c).forEach(n=>{t[n]=In(c[n])}),t}else return c}function On(c){if(typeof c=="string"&&/^[0-9]+$/.test(c))return BigInt(c);if(typeof c=="string"&&/^0x[0-9a-fA-F]+$/.test(c))return BigInt(c);if(Array.isArray(c))return c.map(On);if(typeof c=="object"){if(c===null)return null;const t={};return Object.keys(c).forEach(n=>{t[n]=On(c[n])}),t}else return c}function Ss(c){let t=BigInt(0),e=c.length,n=0;const i=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;e>0;)e>=4?(e-=4,t+=BigInt(i.getUint32(e))<<BigInt(n*8),n+=4):e>=2?(e-=2,t+=BigInt(i.getUint16(e))<<BigInt(n*8),n+=2):(e-=1,t+=BigInt(i.getUint8(e))<<BigInt(n*8),n+=1);return t}function Is(c,t){let e=c;const n=new Uint8Array(t),i=new DataView(n.buffer);let s=t;for(;s>0;)s-4>=0?(s-=4,i.setUint32(s,Number(e&BigInt(4294967295))),e=e>>BigInt(32)):s-2>=0?(s-=2,i.setUint16(s,Number(e&BigInt(65535))),e=e>>BigInt(16)):(s-=1,i.setUint8(s,Number(e&BigInt(255))),e=e>>BigInt(8));if(e)throw new Error("Number does not fit in this length");return n}function Os(c){let t=BigInt(0),e=0;const n=new DataView(c.buffer,c.byteOffset,c.byteLength);for(;e<c.length;)e+4<=c.length?(t+=BigInt(n.getUint32(e,!0))<<BigInt(e*8),e+=4):e+2<=c.length?(t+=BigInt(n.getUint16(e,!0))<<BigInt(e*8),e+=2):(t+=BigInt(n.getUint8(e,!0))<<BigInt(e*8),e+=1);return t}function Ba(c,t){let e=c;typeof t>"u"&&(t=Math.floor((Xe(c)-1)/8)+1,t==0&&(t=1));const n=new Uint8Array(t),i=new DataView(n.buffer);let s=0;for(;s<t;)s+4<=t?(i.setUint32(s,Number(e&BigInt(4294967295)),!0),s+=4,e=e>>BigInt(32)):s+2<=t?(i.setUint16(s,Number(e&BigInt(65535)),!0),s+=2,e=e>>BigInt(16)):(i.setUint8(s,Number(e&BigInt(255)),!0),s+=1,e=e>>BigInt(8));if(e)throw new Error("Number does not fit in this length");return n}function Pn(c,t){if(typeof t=="bigint"||t.eq!==void 0)return t.toString(10);if(t instanceof Uint8Array)return c.toString(c.e(t));if(Array.isArray(t))return t.map(Pn.bind(this,c));if(typeof t=="object"){const e={};return Object.keys(t).forEach(i=>{e[i]=Pn(c,t[i])}),e}else return t}function kn(c,t){if(typeof t=="string"&&/^[0-9]+$/.test(t))return c.e(t);if(typeof t=="string"&&/^0x[0-9a-fA-F]+$/.test(t))return c.e(t);if(Array.isArray(t))return t.map(kn.bind(this,c));if(typeof t=="object"){if(t===null)return null;const e={};return Object.keys(t).forEach(i=>{e[i]=kn(c,t[i])}),e}else return t}const Ue=[];for(let c=0;c<256;c++)Ue[c]=Ps(c,8);function Ps(c,t){let e=0,n=c;for(let i=0;i<t;i++)e<<=1,e=e|n&1,n>>=1;return e}function va(c,t){return(Ue[c>>>24]|Ue[c>>>16&255]<<8|Ue[c>>>8&255]<<16|Ue[c&255]<<24)>>>32-t}function ue(c){return(c&4294901760?(c&=4294901760,16):0)|(c&4278255360?(c&=4278255360,8):0)|(c&4042322160?(c&=4042322160,4):0)|(c&3435973836?(c&=3435973836,2):0)|(c&2863311530)!==0}function xa(c,t){const e=c.byteLength/t,n=ue(e);if(e!=1<<n)throw new Error("Invalid number of pointers");for(let i=0;i<e;i++){const s=va(i,n);if(i>s){const g=c.slice(i*t,(i+1)*t);c.set(c.slice(s*t,(s+1)*t),i*t),c.set(g,s*t)}}}function Vn(c,t){const e=new Uint8Array(t*c.length);for(let n=0;n<c.length;n++)e.set(c[n],n*t);return e}function nn(c,t){const e=c.byteLength/t,n=new Array(e);for(let i=0;i<e;i++)n[i]=c.slice(i*t,i*t+t);return n}const ks=Object.freeze(Object.defineProperty({__proto__:null,array2buffer:Vn,beBuff2int:Ss,beInt2Buff:Is,bitReverse:va,buffReverseBits:xa,buffer2array:nn,leBuff2int:Os,leInt2Buff:Ba,log2:ue,stringifyBigInts:In,stringifyFElements:Pn,unstringifyBigInts:On,unstringifyFElements:kn},Symbol.toStringTag,{value:"Module"})),ce=1<<30;class Vt{constructor(t){this.buffers=[],this.byteLength=t;for(let e=0;e<t;e+=ce){const n=Math.min(t-e,ce);this.buffers.push(new Uint8Array(n))}}slice(t,e){e===void 0&&(e=this.byteLength),t===void 0&&(t=0);const n=e-t,i=Math.floor(t/ce),s=Math.floor((t+n-1)/ce);if(i==s||n==0)return this.buffers[i].slice(t%ce,t%ce+n);let g,d=i,C=t%ce,l=n;for(;l>0;){const o=C+l>ce?ce-C:l,y=new Uint8Array(this.buffers[d].buffer,this.buffers[d].byteOffset+C,o);if(o==n)return y.slice();g||(n<=ce?g=new Uint8Array(n):g=new Vt(n)),g.set(y,n-l),l=l-o,d++,C=0}return g}set(t,e){e===void 0&&(e=0);const n=t.byteLength;if(n==0)return;const i=Math.floor(e/ce),s=Math.floor((e+n-1)/ce);if(i==s)return t instanceof Vt&&t.buffers.length==1?this.buffers[i].set(t.buffers[0],e%ce):this.buffers[i].set(t,e%ce);let g=i,d=e%ce,C=n;for(;C>0;){const l=d+C>ce?ce-d:C,o=t.slice(n-C,n-C+l);new Uint8Array(this.buffers[g].buffer,this.buffers[g].byteOffset+d,l).set(o),C=C-l,g++,d=0}}}function be(c,t,e,n){return async function(s){const g=Math.floor(s.byteLength/e);if(g*e!==s.byteLength)throw new Error("Invalid buffer size");const d=Math.floor(g/c.concurrency),C=[];for(let E=0;E<c.concurrency;E++){let m;if(E<c.concurrency-1?m=d:m=g-E*d,m==0)continue;const O=[{cmd:"ALLOCSET",var:0,buff:s.slice(E*d*e,E*d*e+m*e)},{cmd:"ALLOC",var:1,len:n*m},{cmd:"CALL",fnName:t,params:[{var:0},{val:m},{var:1}]},{cmd:"GET",out:0,var:1,len:n*m}];C.push(c.queueAction(O))}const l=await Promise.all(C);let o;s instanceof Vt?o=new Vt(g*n):o=new Uint8Array(g*n);let y=0;for(let E=0;E<l.length;E++)o.set(l[E][0],y),y+=l[E][0].byteLength;return o}}class Bi{constructor(t,e,n,i){if(this.tm=t,this.prefix=e,this.p=i,this.n8=n,this.type="F1",this.m=1,this.half=Se(i,we),this.bitLength=Xe(i),this.mask=Le(tn(we,this.bitLength),we),this.pOp1=t.alloc(n),this.pOp2=t.alloc(n),this.pOp3=t.alloc(n),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(n/8),this.n32=Math.floor(n/4),this.n64*8!=this.n8)throw new Error("n8 must be a multiple of 8");this.half=Se(this.p,we),this.nqr=this.two;let s=this.exp(this.nqr,this.half);for(;!this.eq(s,this.negone);)this.nqr=this.add(this.nqr,this.one),s=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let g=Le(this.p,we);for(;!Nn(g);)this.s=this.s+1,g=Se(g,we);this.w=[],this.w[this.s]=this.exp(this.nqr,g);for(let d=this.s-1;d>=0;d--)this.w[d]=this.square(this.w[d+1]);if(!this.eq(this.w[0],this.one))throw new Error("Error calculating roots of unity");this.batchToMontgomery=be(t,e+"_batchToMontgomery",this.n8,this.n8),this.batchFromMontgomery=be(t,e+"_batchFromMontgomery",this.n8,this.n8)}op2(t,e,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),!!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=Oe(ee(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 n=ee(t,e);ta(n)?(n=aa(n),Sn(n,this.p)&&(n=ge(n,this.p)),n=Le(this.p,n)):Sn(n,this.p)&&(n=ge(n,this.p));const i=Ba(n,this.n8);return this.toMontgomery(i)}toString(t,e){const n=this.fromMontgomery(t),i=Ge(n,0);return la(i,e)}fromRng(t){let e;const n=new Uint8Array(this.n8);do{e=ua;for(let i=0;i<this.n64;i++)e=zn(e,tn(t.nextU64(),64*i));e=Un(e,this.mask)}while(ca(e,this.p));return $e(n,0,e,this.n8),n}random(){return this.fromRng(jn())}toObject(t){const e=this.fromMontgomery(t);return Ge(e,0)}fromObject(t){const e=new Uint8Array(this.n8);return $e(e,0,t,this.n8),this.toMontgomery(e)}toRprLE(t,e,n){t.set(this.fromMontgomery(n),e)}toRprBE(t,e,n){const i=this.fromMontgomery(n);for(let s=0;s<this.n8/2;s++){const g=i[s];i[s]=i[this.n8-1-s],i[this.n8-1-s]=g}t.set(i,e)}fromRprLE(t,e){e=e||0;const n=t.slice(e,e+this.n8);return this.toMontgomery(n)}async batchInverse(t){let e=!1;const n=this.n8,i=this.n8;Array.isArray(t)?(t=Vn(t,n),e=!0):t=t.slice(0,t.byteLength);const s=Math.floor(t.byteLength/n);if(s*n!==t.byteLength)throw new Error("Invalid buffer size");const g=Math.floor(s/this.tm.concurrency),d=[];for(let y=0;y<this.tm.concurrency;y++){let E;if(y<this.tm.concurrency-1?E=g:E=s-y*g,E==0)continue;const x=[{cmd:"ALLOCSET",var:0,buff:t.slice(y*g*n,y*g*n+E*n)},{cmd:"ALLOC",var:1,len:i*E},{cmd:"CALL",fnName:this.prefix+"_batchInverse",params:[{var:0},{val:n},{val:E},{var:1},{val:i}]},{cmd:"GET",out:0,var:1,len:i*E}];d.push(this.tm.queueAction(x))}const C=await Promise.all(d);let l;t instanceof Vt?l=new Vt(s*i):l=new Uint8Array(s*i);let o=0;for(let y=0;y<C.length;y++)l.set(C[y][0],o),o+=C[y][0].byteLength;return e?nn(l,i):l}}class vi{constructor(t,e,n){this.tm=t,this.prefix=e,this.F=n,this.type="F2",this.m=n.m*2,this.n8=this.F.n8*2,this.n32=this.F.n32*2,this.n64=this.F.n64*2,this.pOp1=t.alloc(n.n8*2),this.pOp2=t.alloc(n.n8*2),this.pOp3=t.alloc(n.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,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),!!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=Oe(ee(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 n=this.F.e(t[0],e),i=this.F.e(t[1],e),s=new Uint8Array(this.F.n8*2);return s.set(n),s.set(i,this.F.n8*2),s}else throw new Error("invalid F2")}toString(t,e){const n=this.F.toString(t.slice(0,this.F.n8),e),i=this.F.toString(t.slice(this.F.n8),e);return`[${n}, ${i}]`}fromRng(t){const e=this.F.fromRng(t),n=this.F.fromRng(t),i=new Uint8Array(this.F.n8*2);return i.set(e),i.set(n,this.F.n8),i}random(){return this.fromRng(jn())}toObject(t){const e=this.F.toObject(t.slice(0,this.F.n8)),n=this.F.toObject(t.slice(this.F.n8,this.F.n8*2));return[e,n]}fromObject(t){const e=new Uint8Array(this.F.n8*2),n=this.F.fromObject(t[0]),i=this.F.fromObject(t[1]);return e.set(n),e.set(i,this.F.n8),e}c1(t){return t.slice(0,this.F.n8)}c2(t){return t.slice(this.F.n8)}}class Ts{constructor(t,e,n){this.tm=t,this.prefix=e,this.F=n,this.type="F3",this.m=n.m*3,this.n8=this.F.n8*3,this.n32=this.F.n32*3,this.n64=this.F.n64*3,this.pOp1=t.alloc(n.n8*3),this.pOp2=t.alloc(n.n8*3),this.pOp3=t.alloc(n.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,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+t](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(t,e,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),!!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=Oe(ee(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 n=this.F.e(t[0],e),i=this.F.e(t[1],e),s=this.F.e(t[2],e),g=new Uint8Array(this.F.n8*3);return g.set(n),g.set(i,this.F.n8),g.set(s,this.F.n8*2),g}else throw new Error("invalid F3")}toString(t,e){const n=this.F.toString(t.slice(0,this.F.n8),e),i=this.F.toString(t.slice(this.F.n8,this.F.n8*2),e),s=this.F.toString(t.slice(this.F.n8*2),e);return`[${n}, ${i}, ${s}]`}fromRng(t){const e=this.F.fromRng(t),n=this.F.fromRng(t),i=this.F.fromRng(t),s=new Uint8Array(this.F.n8*3);return s.set(e),s.set(n,this.F.n8),s.set(i,this.F.n8*2),s}random(){return this.fromRng(jn())}toObject(t){const e=this.F.toObject(t.slice(0,this.F.n8)),n=this.F.toObject(t.slice(this.F.n8,this.F.n8*2)),i=this.F.toObject(t.slice(this.F.n8*2,this.F.n8*3));return[e,n,i]}fromObject(t){const e=new Uint8Array(this.F.n8*3),n=this.F.fromObject(t[0]),i=this.F.fromObject(t[1]),s=this.F.fromObject(t[2]);return e.set(n),e.set(i,this.F.n8),e.set(s,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 xi{constructor(t,e,n,i,s,g){this.tm=t,this.prefix=e,this.F=n,this.pOp1=t.alloc(n.n8*3),this.pOp2=t.alloc(n.n8*3),this.pOp3=t.alloc(n.n8*3),this.tm.instance.exports[e+"_zero"](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,n.n8*3),this.tm.instance.exports[e+"_zeroAffine"](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,n.n8*2),this.one=this.tm.getBuff(i,n.n8*3),this.g=this.one,this.oneAffine=this.tm.getBuff(i,n.n8*2),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(s,n.n8),g&&(this.cofactor=Oe(g)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=be(t,e+"_batchLEMtoC",n.n8*2,n.n8),this.batchLEMtoU=be(t,e+"_batchLEMtoU",n.n8*2,n.n8*2),this.batchCtoLEM=be(t,e+"_batchCtoLEM",n.n8,n.n8*2),this.batchUtoLEM=be(t,e+"_batchUtoLEM",n.n8*2,n.n8*2),this.batchToJacobian=be(t,e+"_batchToJacobian",n.n8*2,n.n8*3),this.batchToAffine=be(t,e+"_batchToAffine",n.n8*3,n.n8*2)}op2(t,e,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),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,n){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,n),!!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=Oe(ee(e)));let n;if(t.byteLength==this.F.n8*3)n=this.prefix+"_timesScalar";else if(t.byteLength==this.F.n8*2)n=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[n](this.pOp1,this.pOp2,e.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}timesFr(t,e){let n;if(t.byteLength==this.F.n8*3)n=this.prefix+"_timesFr";else if(t.byteLength==this.F.n8*2)n=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[n](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,n){if(this.tm.setBuff(this.pOp1,n),n.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(n.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoU"](this.pOp1,this.pOp1);const i=this.tm.getBuff(this.pOp1,this.F.n8*2);t.set(i,e)}fromRprUncompressed(t,e){const n=t.slice(e,e+this.F.n8*2);return this.tm.setBuff(this.pOp1,n),this.tm.instance.exports[this.prefix+"_UtoLEM"](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,this.F.n8*2)}toRprCompressed(t,e,n){if(this.tm.setBuff(this.pOp1,n),n.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);else if(n.byteLength!=this.F.n8*2)throw new Error("invalid point size");this.tm.instance.exports[this.prefix+"_LEMtoC"](this.pOp1,this.pOp1);const i=this.tm.getBuff(this.pOp1,this.F.n8);t.set(i,e)}fromRprCompressed(t,e){const n=t.slice(e,e+this.F.n8);return this.tm.setBuff(this.pOp1,n),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,n){if(n.byteLength==this.F.n8*2){t.set(n,e);return}else if(n.byteLength==this.F.n8*3){this.tm.setBuff(this.pOp1,n),this.tm.instance.exports[this.prefix+"_toAffine"](this.pOp1,this.pOp1);const i=this.tm.getBuff(this.pOp1,this.F.n8*2);t.set(i,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 n=this.F.toString(t.slice(0,this.F.n8),e),i=this.F.toString(t.slice(this.F.n8,this.F.n8*2),e),s=this.F.toString(t.slice(this.F.n8*2),e);return`[ ${n}, ${i}, ${s} ]`}else if(t.byteLength==this.F.n8*2){const n=this.F.toString(t.slice(0,this.F.n8),e),i=this.F.toString(t.slice(this.F.n8),e);return`[ ${n}, ${i} ]`}else throw new Error("invalid point size")}isValid(t){if(this.isZero(t))return!0;const e=this.F,n=this.toAffine(t),i=n.slice(0,this.F.n8),s=n.slice(this.F.n8,this.F.n8*2),g=e.add(e.mul(e.square(i),i),this.b),d=e.square(s);return e.eq(g,d)}fromRng(t){const e=this.F;let n=[],i,s;do n[0]=e.fromRng(t),i=t.nextBool(),s=e.add(e.mul(e.square(n[0]),n[0]),this.b);while(!e.isSquare(s));n[1]=e.sqrt(s);const g=e.isNegative(n[1]);i^g&&(n[1]=e.neg(n[1]));let d=new Uint8Array(this.F.n8*2);return d.set(n[0]),d.set(n[1],this.F.n8),this.cofactor&&(d=this.timesScalar(d,this.cofactor)),d}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)),n=this.F.toObject(t.slice(this.F.n8,this.F.n8*2));let i;return t.byteLength==this.F.n8*3?i=this.F.toObject(t.slice(this.F.n8*2,this.F.n8*3)):i=this.F.toObject(this.F.one),[e,n,i]}fromObject(t){const e=this.F.fromObject(t[0]),n=this.F.fromObject(t[1]);let i;if(t.length==3?i=this.F.fromObject(t[2]):i=this.F.one,this.F.isZero(i,this.F.one))return this.zeroAffine;if(this.F.eq(i,this.F.one)){const s=new Uint8Array(this.F.n8*2);return s.set(e),s.set(n,this.F.n8),s}else{const s=new Uint8Array(this.F.n8*3);return s.set(e),s.set(n,this.F.n8),s.set(i,this.F.n8*2),s}}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 Sa(c){let e,n;c&&(c.onmessage=function(o){let y;if(o.data?y=o.data:y=o,y[0].cmd=="INIT")i(y[0]).then(function(){c.postMessage(y.result)});else if(y[0].cmd=="TERMINATE")c.close();else{const E=l(y);c.postMessage(E)}});async function i(o){const y=new Uint8Array(o.code),E=await WebAssembly.compile(y);n=new WebAssembly.Memory({initial:o.init,maximum:32767}),e=await WebAssembly.instantiate(E,{env:{memory:n}})}function s(o){const y=new Uint32Array(n.buffer,0,1);for(;y[0]&3;)y[0]++;const E=y[0];if(y[0]+=o,y[0]+o>n.buffer.byteLength){const m=n.buffer.byteLength/65536;let x=Math.floor((y[0]+o)/65536)+1;x>32767&&(x=32767),n.grow(x-m)}return E}function g(o){const y=s(o.byteLength);return C(y,o),y}function d(o,y){const E=new Uint8Array(n.buffer);return new Uint8Array(E.buffer,E.byteOffset+o,y)}function C(o,y){new Uint8Array(n.buffer).set(new Uint8Array(y),o)}function l(o){if(o[0].cmd=="INIT")return i(o[0]);const y={vars:[],out:[]},m=new Uint32Array(n.buffer,0,1)[0];for(let O=0;O<o.length;O++)switch(o[O].cmd){case"ALLOCSET":y.vars[o[O].var]=g(o[O].buff);break;case"ALLOC":y.vars[o[O].var]=s(o[O].len);break;case"SET":C(y.vars[o[O].var],o[O].buff);break;case"CALL":{const L=[];for(let I=0;I<o[O].params.length;I++){const v=o[O].params[I];typeof v.var<"u"?L.push(y.vars[v.var]+(v.offset||0)):typeof v.val<"u"&&L.push(v.val)}e.exports[o[O].fnName](...L);break}case"GET":y.out[o[O].out]=d(y.vars[o[O].var],o[O].len).slice();break;default:throw new Error("Invalid cmd")}const x=new Uint32Array(n.buffer,0,1);return x[0]=m,y.out}return l}const qs=Worker,yn=25;class Si{constructor(){this.promise=new Promise((t,e)=>{this.reject=e,this.resolve=t})}}function Ms(c){return new Promise(t=>setTimeout(t,c))}function Ds(c){return process.browser?globalThis.btoa(c):Buffer.from(c).toString("base64")}const Rs=Ds("("+Sa.toString()+")(self)"),Ns="data:application/javascript;base64,"+Rs;async function zs(c,t){const e=new Us;e.memory=new WebAssembly.Memory({initial:yn}),e.u8=new Uint8Array(e.memory.buffer),e.u32=new Uint32Array(e.memory.buffer);const n=await WebAssembly.compile(c.code);if(e.instance=await WebAssembly.instantiate(n,{env:{memory:e.memory}}),e.singleThread=t,e.initalPFree=e.u32[0],e.pq=c.pq,e.pr=c.pr,e.pG1gen=c.pG1gen,e.pG1zero=c.pG1zero,e.pG2gen=c.pG2gen,e.pG2zero=c.pG2zero,e.pOneT=c.pOneT,t)e.code=c.code,e.taskManager=Sa(),await e.taskManager([{cmd:"INIT",init:yn,code:e.code.slice()}]),e.concurrency=1;else{e.workers=[],e.pendingDeferreds=[],e.working=[];let s;typeof navigator=="object"&&navigator.hardwareConcurrency?s=navigator.hardwareConcurrency:s=se.fs.cpus().length,s==0&&(s=2),s>64&&(s=64),e.concurrency=s;for(let d=0;d<s;d++)e.workers[d]=new qs(Ns),e.workers[d].addEventListener("message",i(d)),e.working[d]=!1;const g=[];for(let d=0;d<e.workers.length;d++){const C=c.code.slice();g.push(e.postAction(d,[{cmd:"INIT",init:yn,code:C}],[C.buffer]))}await Promise.all(g)}return e;function i(s){return function(g){let d;g&&g.data?d=g.data:d=g,e.working[s]=!1,e.pendingDeferreds[s].resolve(d),e.processWorks()}}}class Us{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,n,i){if(this.working[t])throw new Error("Posting a job t a working worker");return this.working[t]=!0,this.pendingDeferreds[t]=i||new Si,this.workers[t].postMessage(e,n),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 n=new Si;if(this.singleThread){const i=this.taskManager(t);n.resolve(i)}else this.actionQueue.push({data:t,transfers:e,deferred:n}),this.processWorks();return n.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 Ms(200)}}function Cn(c,t){const e=c[t],n=c.Fr,i=c.tm;c[t].batchApplyKey=async function(s,g,d,C,l){C=C||"affine",l=l||"affine";let o,y,E,m,x;if(t=="G1")C=="jacobian"?(E=e.F.n8*3,o="g1m_batchApplyKey"):(E=e.F.n8*2,o="g1m_batchApplyKeyMixed"),m=e.F.n8*3,l=="jacobian"?x=e.F.n8*3:(y="g1m_batchToAffine",x=e.F.n8*2);else if(t=="G2")C=="jacobian"?(E=e.F.n8*3,o="g2m_batchApplyKey"):(E=e.F.n8*2,o="g2m_batchApplyKeyMixed"),m=e.F.n8*3,l=="jacobian"?x=e.F.n8*3:(y="g2m_batchToAffine",x=e.F.n8*2);else if(t=="Fr")o="frm_batchApplyKey",E=e.n8,m=e.n8,x=e.n8;else throw new Error("Invalid group: "+t);const O=Math.floor(s.byteLength/E),L=Math.floor(O/i.concurrency),I=[];d=n.e(d);let v=n.e(g);for(let F=0;F<i.concurrency;F++){let r;if(F<i.concurrency-1?r=L:r=O-F*L,r==0)continue;const h=[];h.push({cmd:"ALLOCSET",var:0,buff:s.slice(F*L*E,F*L*E+r*E)}),h.push({cmd:"ALLOCSET",var:1,buff:v}),h.push({cmd:"ALLOCSET",var:2,buff:d}),h.push({cmd:"ALLOC",var:3,len:r*Math.max(m,x)}),h.push({cmd:"CALL",fnName:o,params:[{var:0},{val:r},{var:1},{var:2},{var:3}]}),y&&h.push({cmd:"CALL",fnName:y,params:[{var:3},{val:r},{var:3}]}),h.push({cmd:"GET",out:0,var:3,len:r*x}),I.push(i.queueAction(h)),v=n.mul(v,n.exp(d,r))}const U=await Promise.all(I);let w;s instanceof Vt?w=new Vt(O*x):w=new Uint8Array(O*x);let S=0;for(let F=0;F<U.length;F++)w.set(U[F][0],S),S+=U[F][0].byteLength;return w}}function js(c){const t=c.tm;c.pairing=function(n,i){t.startSyncOp();const s=t.allocBuff(c.G1.toJacobian(n)),g=t.allocBuff(c.G2.toJacobian(i)),d=t.alloc(c.Gt.n8);t.instance.exports[c.name+"_pairing"](s,g,d);const C=t.getBuff(d,c.Gt.n8);return t.endSyncOp(),C},c.pairingEq=async function(){let n,i;arguments.length%2==1?(n=arguments[arguments.length-1],i=(arguments.length-1)/2):(n=c.Gt.one,i=arguments.length/2);const s=[];for(let o=0;o<i;o++){const y=[],E=c.G1.toJacobian(arguments[o*2]);y.push({cmd:"ALLOCSET",var:0,buff:E}),y.push({cmd:"ALLOC",var:1,len:c.prePSize});const m=c.G2.toJacobian(arguments[o*2+1]);y.push({cmd:"ALLOCSET",var:2,buff:m}),y.push({cmd:"ALLOC",var:3,len:c.preQSize}),y.push({cmd:"ALLOC",var:4,len:c.Gt.n8}),y.push({cmd:"CALL",fnName:c.name+"_prepareG1",params:[{var:0},{var:1}]}),y.push({cmd:"CALL",fnName:c.name+"_prepareG2",params:[{var:2},{var:3}]}),y.push({cmd:"CALL",fnName:c.name+"_millerLoop",params:[{var:1},{var:3},{var:4}]}),y.push({cmd:"GET",out:0,var:4,len:c.Gt.n8}),s.push(t.queueAction(y))}const g=await Promise.all(s);t.startSyncOp();const d=t.alloc(c.Gt.n8);t.instance.exports.ftm_one(d);for(let o=0;o<g.length;o++){const y=t.allocBuff(g[o][0]);t.instance.exports.ftm_mul(d,y,d)}t.instance.exports[c.name+"_finalExponentiation"](d,d);const C=t.allocBuff(n),l=!!t.instance.exports.ftm_eq(d,C);return t.endSyncOp(),l},c.prepareG1=function(e){this.tm.startSyncOp();const n=this.tm.allocBuff(e),i=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+"_prepareG1"](n,i);const s=this.tm.getBuff(i,this.prePSize);return this.tm.endSyncOp(),s},c.prepareG2=function(e){this.tm.startSyncOp();const n=this.tm.allocBuff(e),i=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+"_prepareG2"](n,i);const s=this.tm.getBuff(i,this.preQSize);return this.tm.endSyncOp(),s},c.millerLoop=function(e,n){this.tm.startSyncOp();const i=this.tm.allocBuff(e),s=this.tm.allocBuff(n),g=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_millerLoop"](i,s,g);const d=this.tm.getBuff(g,this.Gt.n8);return this.tm.endSyncOp(),d},c.finalExponentiation=function(e){this.tm.startSyncOp();const n=this.tm.allocBuff(e),i=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+"_finalExponentiation"](n,i);const s=this.tm.getBuff(i,this.Gt.n8);return this.tm.endSyncOp(),s}}const Ii=[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 Oi(c,t){const e=c[t],n=e.tm;async function i(g,d,C,l,o){if(!(g instanceof Uint8Array))throw l&&l.error(`${o} _multiExpChunk buffBases is not Uint8Array`),new Error(`${o} _multiExpChunk buffBases is not Uint8Array`);if(!(d instanceof Uint8Array))throw l&&l.error(`${o} _multiExpChunk buffScalars is not Uint8Array`),new Error(`${o} _multiExpChunk buffScalars is not Uint8Array`);C=C||"affine";let y,E;if(t=="G1")C=="affine"?(E="g1m_multiexpAffine_chunk",y=e.F.n8*2):(E="g1m_multiexp_chunk",y=e.F.n8*3);else if(t=="G2")C=="affine"?(E="g2m_multiexpAffine_chunk",y=e.F.n8*2):(E="g2m_multiexp_chunk",y=e.F.n8*3);else throw new Error("Invalid group");const m=Math.floor(g.byteLength/y);if(m==0)return e.zero;const x=Math.floor(d.byteLength/m);if(x*m!=d.byteLength)throw new Error("Scalar size does not match");const O=Ii[ue(m)],L=Math.floor((x*8-1)/O)+1,I=[];for(let w=0;w<L;w++){const S=[{cmd:"ALLOCSET",var:0,buff:g},{cmd:"ALLOCSET",var:1,buff:d},{cmd:"ALLOC",var:2,len:e.F.n8*3},{cmd:"CALL",fnName:E,params:[{var:0},{var:1},{val:x},{val:m},{val:w*O},{val:Math.min(x*8-w*O,O)},{var:2}]},{cmd:"GET",out:0,var:2,len:e.F.n8*3}];I.push(e.tm.queueAction(S))}const v=await Promise.all(I);let U=e.zero;for(let w=v.length-1;w>=0;w--){if(!e.isZero(U))for(let S=0;S<O;S++)U=e.double(U);U=e.add(U,v[w][0])}return U}async function s(g,d,C,l,o){let m;if(t=="G1")C=="affine"?m=e.F.n8*2:m=e.F.n8*3;else if(t=="G2")C=="affine"?m=e.F.n8*2:m=e.F.n8*3;else throw new Error("Invalid group");const x=Math.floor(g.byteLength/m),O=Math.floor(d.byteLength/x);if(O*x!=d.byteLength)throw new Error("Scalar size does not match");const L=Ii[ue(x)],I=Math.floor((O*8-1)/L)+1;let v;v=Math.floor(x/(n.concurrency/I)),v>4194304&&(v=4194304),v<1024&&(v=1024);const U=[];for(let F=0;F<x;F+=v){l&&l.debug(`Multiexp start: ${o}: ${F}/${x}`);const r=Math.min(x-F,v),h=g.slice(F*m,(F+r)*m),R=d.slice(F*O,(F+r)*O);U.push(i(h,R,C,l,o).then(j=>(l&&l.debug(`Multiexp end: ${o}: ${F}/${x}`),j)))}const w=await Promise.all(U);let S=e.zero;for(let F=w.length-1;F>=0;F--)S=e.add(S,w[F]);return S}e.multiExp=async function(d,C,l,o){return await s(d,C,"jacobian",l,o)},e.multiExpAffine=async function(d,C,l,o){return await s(d,C,"affine",l,o)}}function An(c,t){const e=c[t],n=c.Fr,i=e.tm;async function s(l,o,y,E,m,x){y=y||"affine",E=E||"affine";const O=14;let L,I,v,U,w,S,F,r;t=="G1"?(y=="affine"?(L=e.F.n8*2,U="g1m_batchToJacobian"):L=e.F.n8*3,I=e.F.n8*3,o&&(r="g1m_fftFinal"),F="g1m_fftJoin",S="g1m_fftMix",E=="affine"?(v=e.F.n8*2,w="g1m_batchToAffine"):v=e.F.n8*3):t=="G2"?(y=="affine"?(L=e.F.n8*2,U="g2m_batchToJacobian"):L=e.F.n8*3,I=e.F.n8*3,o&&(r="g2m_fftFinal"),F="g2m_fftJoin",S="g2m_fftMix",E=="affine"?(v=e.F.n8*2,w="g2m_batchToAffine"):v=e.F.n8*3):t=="Fr"&&(L=e.n8,I=e.n8,v=e.n8,o&&(r="frm_fftFinal"),S="frm_fftMix",F="frm_fftJoin");let h=!1;Array.isArray(l)?(l=Vn(l,L),h=!0):l=l.slice(0,l.byteLength);const R=l.byteLength/L,j=ue(R);if(1<<j!=R)throw new Error("fft must be multiple of 2");if(j==n.s+1){let J;return o?J=await d(l,y,E,m,x):J=await g(l,y,E,m,x),h?nn(J,v):J}let T;o&&(T=n.inv(n.e(R)));let M;xa(l,L);let A,D=Math.min(1<<O,R),H=R/D;for(;H<i.concurrency&&D>=16;)H*=2,D/=2;const ut=ue(D),nt=[];for(let J=0;J<H;J++){m&&m.debug(`${x}: fft ${j} mix start: ${J}/${H}`);const ft=[];ft.push({cmd:"ALLOC",var:0,len:I*D});const it=l.slice(D*J*L,D*(J+1)*L);ft.push({cmd:"SET",var:0,buff:it}),U&&ft.push({cmd:"CALL",fnName:U,params:[{var:0},{val:D},{var:0}]});for(let _t=1;_t<=ut;_t++)ft.push({cmd:"CALL",fnName:S,params:[{var:0},{val:D},{val:_t}]});ut==j?(r&&(ft.push({cmd:"ALLOCSET",var:1,buff:T}),ft.push({cmd:"CALL",fnName:r,params:[{var:0},{val:D},{var:1}]})),w&&ft.push({cmd:"CALL",fnName:w,params:[{var:0},{val:D},{var:0}]}),ft.push({cmd:"GET",out:0,var:0,len:D*v})):ft.push({cmd:"GET",out:0,var:0,len:I*D}),nt.push(i.queueAction(ft).then(_t=>(m&&m.debug(`${x}: fft ${j} mix end: ${J}/${H}`),_t)))}A=await Promise.all(nt);for(let J=0;J<H;J++)A[J]=A[J][0];for(let J=ut+1;J<=j;J++){m&&m.debug(`${x}: fft ${j} join: ${J}/${j}`);const ft=1<<j-J,it=H/ft,_t=[];for(let G=0;G<ft;G++)for(let K=0;K<it/2;K++){const P=n.exp(n.w[J],K*D),a=n.w[J],q=G*it+K,u=G*it+K+it/2,W=[];W.push({cmd:"ALLOCSET",var:0,buff:A[q]}),W.push({cmd:"ALLOCSET",var:1,buff:A[u]}),W.push({cmd:"ALLOCSET",var:2,buff:P}),W.push({cmd:"ALLOCSET",var:3,buff:a}),W.push({cmd:"CALL",fnName:F,params:[{var:0},{var:1},{val:D},{var:2},{var:3}]}),J==j?(r&&(W.push({cmd:"ALLOCSET",var:4,buff:T}),W.push({cmd:"CALL",fnName:r,params:[{var:0},{val:D},{var:4}]}),W.push({cmd:"CALL",fnName:r,params:[{var:1},{val:D},{var:4}]})),w&&(W.push({cmd:"CALL",fnName:w,params:[{var:0},{val:D},{var:0}]}),W.push({cmd:"CALL",fnName:w,params:[{var:1},{val:D},{var:1}]})),W.push({cmd:"GET",out:0,var:0,len:D*v}),W.push({cmd:"GET",out:1,var:1,len:D*v})):(W.push({cmd:"GET",out:0,var:0,len:D*I}),W.push({cmd:"GET",out:1,var:1,len:D*I})),_t.push(i.queueAction(W).then(z=>(m&&m.debug(`${x}: fft ${j} join ${J}/${j} ${G+1}/${ft} ${K}/${it/2}`),z)))}const zt=await Promise.all(_t);for(let G=0;G<ft;G++)for(let K=0;K<it/2;K++){const P=G*it+K,a=G*it+K+it/2,q=zt.shift();A[P]=q[0],A[a]=q[1]}}if(l instanceof Vt?M=new Vt(R*v):M=new Uint8Array(R*v),o){M.set(A[0].slice((D-1)*v));let J=v;for(let ft=H-1;ft>0;ft--)M.set(A[ft],J),J+=D*v,delete A[ft];M.set(A[0].slice(0,(D-1)*v),J),delete A[0]}else for(let J=0;J<H;J++)M.set(A[J],D*v*J),delete A[J];return h?nn(M,v):M}async function g(l,o,y,E,m){let x,O;x=l.slice(0,l.byteLength/2),O=l.slice(l.byteLength/2,l.byteLength);const L=[];[x,O]=await C(x,O,"fftJoinExt",n.one,n.shift,o,"jacobian",E,m),L.push(s(x,!1,"jacobian",y,E,m)),L.push(s(O,!1,"jacobian",y,E,m));const I=await Promise.all(L);let v;return I[0].byteLength>1<<28?v=new Vt(I[0].byteLength*2):v=new Uint8Array(I[0].byteLength*2),v.set(I[0]),v.set(I[1],I[0].byteLength),v}async function d(l,o,y,E,m){let x,O;x=l.slice(0,l.byteLength/2),O=l.slice(l.byteLength/2,l.byteLength);const L=[];L.push(s(x,!0,o,"jacobian",E,m)),L.push(s(O,!0,o,"jacobian",E,m)),[x,O]=await Promise.all(L);const I=await C(x,O,"fftJoinExtInv",n.one,n.shiftInv,"jacobian",y,E,m);let v;return I[0].byteLength>1<<28?v=new Vt(I[0].byteLength*2):v=new Uint8Array(I[0].byteLength*2),v.set(I[0]),v.set(I[1],I[0].byteLength),v}async function C(l,o,y,E,m,x,O,L,I){let w,S,F,r,h,R;if(t=="G1")x=="affine"?(h=e.F.n8*2,S="g1m_batchToJacobian"):h=e.F.n8*3,R=e.F.n8*3,w="g1m_"+y,O=="affine"?(F="g1m_batchToAffine",r=e.F.n8*2):r=e.F.n8*3;else if(t=="G2")x=="affine"?(h=e.F.n8*2,S="g2m_batchToJacobian"):h=e.F.n8*3,w="g2m_"+y,R=e.F.n8*3,O=="affine"?(F="g2m_batchToAffine",r=e.F.n8*2):r=e.F.n8*3;else if(t=="Fr")h=n.n8,r=n.n8,R=n.n8,w="frm_"+y;else throw new Error("Invalid group");if(l.byteLength!=o.byteLength)throw new Error("Invalid buffer size");const j=Math.floor(l.byteLength/h);if(j!=1<<ue(j))throw new Error("Invalid number of points");let T=Math.floor(j/i.concurrency);T<16&&(T=16),T>65536&&(T=65536);const M=[];for(let nt=0;nt<j;nt+=T){L&&L.debug(`${I}: fftJoinExt Start: ${nt}/${j}`);const J=Math.min(j-nt,T),ft=n.mul(E,n.exp(m,nt)),it=[],_t=l.slice(nt*h,(nt+J)*h),zt=o.slice(nt*h,(nt+J)*h);it.push({cmd:"ALLOC",var:0,len:R*J}),it.push({cmd:"SET",var:0,buff:_t}),it.push({cmd:"ALLOC",var:1,len:R*J}),it.push({cmd:"SET",var:1,buff:zt}),it.push({cmd:"ALLOCSET",var:2,buff:ft}),it.push({cmd:"ALLOCSET",var:3,buff:m}),S&&(it.push({cmd:"CALL",fnName:S,params:[{var:0},{val:J},{var:0}]}),it.push({cmd:"CALL",fnName:S,params:[{var:1},{val:J},{var:1}]})),it.push({cmd:"CALL",fnName:w,params:[{var:0},{var:1},{val:J},{var:2},{var:3},{val:n.s}]}),F&&(it.push({cmd:"CALL",fnName:F,params:[{var:0},{val:J},{var:0}]}),it.push({cmd:"CALL",fnName:F,params:[{var:1},{val:J},{var:1}]})),it.push({cmd:"GET",out:0,var:0,len:J*r}),it.push({cmd:"GET",out:1,var:1,len:J*r}),M.push(i.queueAction(it).then(G=>(L&&L.debug(`${I}: fftJoinExt End: ${nt}/${j}`),G)))}const A=await Promise.all(M);let D,H;j*r>1<<28?(D=new Vt(j*r),H=new Vt(j*r)):(D=new Uint8Array(j*r),H=new Uint8Array(j*r));let ut=0;for(let nt=0;nt<A.length;nt++)D.set(A[nt][0],ut),H.set(A[nt][1],ut),ut+=A[nt][0].byteLength;return[D,H]}e.fft=async function(l,o,y,E,m){return await s(l,!1,o,y,E,m)},e.ifft=async function(l,o,y,E,m){return await s(l,!0,o,y,E,m)},e.lagrangeEvaluations=async function(l,o,y,E,m){o=o||"affine",y=y||"affine";let x;if(t=="G1")o=="affine"?x=e.F.n8*2:x=e.F.n8*3;else if(t=="G2")o=="affine"?x=e.F.n8*2:x=e.F.n8*3;else if(t=="Fr")x=n.n8;else throw new Error("Invalid group");const O=l.byteLength/x,L=ue(O);if(2**L*x!=l.byteLength)throw E&&E.error("lagrangeEvaluations iinvalid input size"),new Error("lagrangeEvaluations invalid Input size");if(L<=n.s)return await e.ifft(l,o,y,E,m);if(L>n.s+1)throw E&&E.error("lagrangeEvaluations input too big"),new Error("lagrangeEvaluations input too big");let I=l.slice(0,l.byteLength/2),v=l.slice(l.byteLength/2,l.byteLength);const U=n.exp(n.shift,O/2),w=n.inv(n.sub(n.one,U));[I,v]=await C(I,v,"prepareLagrangeEvaluation",w,n.shiftInv,o,"jacobian",E,m+" prep");const S=[];S.push(s(I,!0,"jacobian",y,E,m+" t0")),S.push(s(v,!0,"jacobian",y,E,m+" t1")),[I,v]=await Promise.all(S);let F;return I.byteLength>1<<28?F=new Vt(I.byteLength*2):F=new Uint8Array(I.byteLength*2),F.set(I),F.set(v,I.byteLength),F},e.fftMix=async function(o){const y=e.F.n8*3;let E,m;if(t=="G1")E="g1m_fftMix",m="g1m_fftJoin";else if(t=="G2")E="g2m_fftMix",m="g2m_fftJoin";else if(t=="Fr")E="frm_fftMix",m="frm_fftJoin";else throw new Error("Invalid group");const x=Math.floor(o.byteLength/y),O=ue(x);let L=1<<ue(i.concurrency);x<=L*2&&(L=1);const I=x/L,v=ue(I),U=[];for(let h=0;h<L;h++){const R=[],j=o.slice(h*I*y,(h+1)*I*y);R.push({cmd:"ALLOCSET",var:0,buff:j});for(let T=1;T<=v;T++)R.push({cmd:"CALL",fnName:E,params:[{var:0},{val:I},{val:T}]});R.push({cmd:"GET",out:0,var:0,len:I*y}),U.push(i.queueAction(R))}const w=await Promise.all(U),S=[];for(let h=0;h<w.length;h++)S[h]=w[h][0];for(let h=v+1;h<=O;h++){const R=1<<O-h,j=L/R,T=[];for(let A=0;A<R;A++)for(let D=0;D<j/2;D++){const H=n.exp(n.w[h],D*I),ut=n.w[h],nt=A*j+D,J=A*j+D+j/2,ft=[];ft.push({cmd:"ALLOCSET",var:0,buff:S[nt]}),ft.push({cmd:"ALLOCSET",var:1,buff:S[J]}),ft.push({cmd:"ALLOCSET",var:2,buff:H}),ft.push({cmd:"ALLOCSET",var:3,buff:ut}),ft.push({cmd:"CALL",fnName:m,params:[{var:0},{var:1},{val:I},{var:2},{var:3}]}),ft.push({cmd:"GET",out:0,var:0,len:I*y}),ft.push({cmd:"GET",out:1,var:1,len:I*y}),T.push(i.queueAction(ft))}const M=await Promise.all(T);for(let A=0;A<R;A++)for(let D=0;D<j/2;D++){const H=A*j+D,ut=A*j+D+j/2,nt=M.shift();S[H]=nt[0],S[ut]=nt[1]}}let F;o instanceof Vt?F=new Vt(x*y):F=new Uint8Array(x*y);let r=0;for(let h=0;h<L;h++)F.set(S[h],r),r+=S[h].byteLength;return F},e.fftJoin=async function(o,y,E,m){const x=e.F.n8*3;let O;if(t=="G1")O="g1m_fftJoin";else if(t=="G2")O="g2m_fftJoin";else if(t=="Fr")O="frm_fftJoin";else throw new Error("Invalid group");if(o.byteLength!=y.byteLength)throw new Error("Invalid buffer size");const L=Math.floor(o.byteLength/x);if(L!=1<<ue(L))throw new Error("Invalid number of points");let I=1<<ue(i.concurrency);L<=I*2&&(I=1);const v=L/I,U=[];for(let h=0;h<I;h++){const R=[],j=n.mul(E,n.exp(m,h*v)),T=o.slice(h*v*x,(h+1)*v*x),M=y.slice(h*v*x,(h+1)*v*x);R.push({cmd:"ALLOCSET",var:0,buff:T}),R.push({cmd:"ALLOCSET",var:1,buff:M}),R.push({cmd:"ALLOCSET",var:2,buff:j}),R.push({cmd:"ALLOCSET",var:3,buff:m}),R.push({cmd:"CALL",fnName:O,params:[{var:0},{var:1},{val:v},{var:2},{var:3}]}),R.push({cmd:"GET",out:0,var:0,len:v*x}),R.push({cmd:"GET",out:1,var:1,len:v*x}),U.push(i.queueAction(R))}const w=await Promise.all(U);let S,F;o instanceof Vt?(S=new Vt(L*x),F=new Vt(L*x)):(S=new Uint8Array(L*x),F=new Uint8Array(L*x));let r=0;for(let h=0;h<w.length;h++)S.set(w[h][0],r),F.set(w[h][1],r),r+=w[h][0].byteLength;return[S,F]},e.fftFinal=async function(o,y){const E=e.F.n8*3,m=e.F.n8*2;let x,O;if(t=="G1")x="g1m_fftFinal",O="g1m_batchToAffine";else if(t=="G2")x="g2m_fftFinal",O="g2m_batchToAffine";else throw new Error("Invalid group");const L=Math.floor(o.byteLength/E);if(L!=1<<ue(L))throw new Error("Invalid number of points");const I=Math.floor(L/i.concurrency),v=[];for(let F=0;F<i.concurrency;F++){let r;if(F<i.concurrency-1?r=I:r=L-F*I,r==0)continue;const h=[],R=o.slice(F*I*E,(F*I+r)*E);h.push({cmd:"ALLOCSET",var:0,buff:R}),h.push({cmd:"ALLOCSET",var:1,buff:y}),h.push({cmd:"CALL",fnName:x,params:[{var:0},{val:r},{var:1}]}),h.push({cmd:"CALL",fnName:O,params:[{var:0},{val:r},{var:0}]}),h.push({cmd:"GET",out:0,var:0,len:r*m}),v.push(i.queueAction(h))}const U=await Promise.all(v);let w;o instanceof Vt?w=new Vt(L*m):w=new Uint8Array(L*m);let S=0;for(let F=U.length-1;F>=0;F--)w.set(U[F][0],S),S+=U[F][0].byteLength;return w}}async function Ia(c){const t=await zs(c.wasm,c.singleThread),e={};return e.q=ee(c.wasm.q.toString()),e.r=ee(c.wasm.r.toString()),e.name=c.name,e.tm=t,e.prePSize=c.wasm.prePSize,e.preQSize=c.wasm.preQSize,e.Fr=new Bi(t,"frm",c.n8r,c.r),e.F1=new Bi(t,"f1m",c.n8q,c.q),e.F2=new vi(t,"f2m",e.F1),e.G1=new xi(t,"g1m",e.F1,c.wasm.pG1gen,c.wasm.pG1b,c.cofactorG1),e.G2=new xi(t,"g2m",e.F2,c.wasm.pG2gen,c.wasm.pG2b,c.cofactorG2),e.F6=new Ts(t,"f6m",e.F2),e.F12=new vi(t,"ftm",e.F6),e.Gt=e.F12,Cn(e,"G1"),Cn(e,"G2"),Cn(e,"Fr"),Oi(e,"G1"),Oi(e,"G2"),An(e,"G1"),An(e,"G2"),An(e,"Fr"),js(e),e.array2buffer=function(n,i){const s=new Uint8Array(i*n.length);for(let g=0;g<n.length;g++)s.set(n[g],g*i);return s},e.buffer2array=function(n,i){const s=n.byteLength/i,g=new Array(s);for(let d=0;d<s;d++)g[d]=n.slice(d*i,d*i+i);return g},e}function ke(c){return BigInt(c)}function Oa(c){return c<0n}function $s(c){return c===0n}function Gs(c){return Oa(c)?c.toString(2).length-1:c.toString(2).length}function Fn(c){const t=[],e=ke(c);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 Zs(c){for(var t=[],e=0;e<c.length;e++){var n=c.charCodeAt(e);n<128?t.push(n):n<2048?t.push(192|n>>6,128|n&63):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|n&63):(e++,n=65536+((n&1023)<<10|c.charCodeAt(e)&1023),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|n&63))}return t}function ze(c){const t=Zs(c);return[...Rt(t.length),...t]}function Pa(c){const t=[];let e=ke(c);if(Oa(e))throw new Error("Number cannot be negative");for(;!$s(e);)t.push(Number(e&0x7Fn)),e=e>>7n;t.length==0&&t.push(0);for(let n=0;n<t.length-1;n++)t[n]=t[n]|128;return t}function ka(c){let t,e;const n=Gs(c);c<0?(e=!0,t=(1n<<BigInt(n))+c):(e=!1,t=ke(c));const i=7-n%7,s=(1n<<BigInt(i))-1n<<BigInt(n),g=(1<<7-i)-1|128,d=Pa(t+s);return e||(d[d.length-1]=d[d.length-1]&g),d}function Tn(c){let t=ke(c);if(t>0xFFFFFFFFn)throw new Error("Number too big");if(t>0x7FFFFFFFn&&(t=t-0x100000000n),t<-2147483648n)throw new Error("Number too small");return ka(t)}function Ws(c){let t=ke(c);if(t>0xFFFFFFFFFFFFFFFFn)throw new Error("Number too big");if(t>0x7FFFFFFFFFFFFFFFn&&(t=t-0x10000000000000000n),t<-9223372036854775808n)throw new Error("Number too small");return ka(t)}function Rt(c){let t=ke(c);if(t>0xFFFFFFFFn)throw new Error("Number too big");return Pa(t)}function Pi(c){return Array.from(c,function(t){return("0"+(t&255).toString(16)).slice(-2)}).join("")}class Xs{constructor(t){this.func=t,this.functionName=t.functionName,this.module=t.module}setLocal(t,e){const n=this.func.localIdxByName[t];if(n===void 0)throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...e,33,...Rt(n)]}teeLocal(t,e){const n=this.func.localIdxByName[t];if(n===void 0)throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${t} `);return[...e,34,...Rt(n)]}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,...Rt(e)]}i64_load8_s(t,e,n){const i=e||0,s=n===void 0?0:n;return[...t,48,s,...Rt(i)]}i64_load8_u(t,e,n){const i=e||0,s=n===void 0?0:n;return[...t,49,s,...Rt(i)]}i64_load16_s(t,e,n){const i=e||0,s=n===void 0?1:n;return[...t,50,s,...Rt(i)]}i64_load16_u(t,e,n){const i=e||0,s=n===void 0?1:n;return[...t,51,s,...Rt(i)]}i64_load32_s(t,e,n){const i=e||0,s=n===void 0?2:n;return[...t,52,s,...Rt(i)]}i64_load32_u(t,e,n){const i=e||0,s=n===void 0?2:n;return[...t,53,s,...Rt(i)]}i64_load(t,e,n){const i=e||0,s=n===void 0?3:n;return[...t,41,s,...Rt(i)]}i64_store(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=3,d=e):Array.isArray(n)?(s=e,g=3,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,55,g,...Rt(s)]}i64_store32(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=2,d=e):Array.isArray(n)?(s=e,g=2,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,62,g,...Rt(s)]}i64_store16(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=1,d=e):Array.isArray(n)?(s=e,g=1,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,61,g,...Rt(s)]}i64_store8(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=0,d=e):Array.isArray(n)?(s=e,g=0,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,60,g,...Rt(s)]}i32_load8_s(t,e,n){const i=e||0,s=n===void 0?0:n;return[...t,44,s,...Rt(i)]}i32_load8_u(t,e,n){const i=e||0,s=n===void 0?0:n;return[...t,45,s,...Rt(i)]}i32_load16_s(t,e,n){const i=e||0,s=n===void 0?1:n;return[...t,46,s,...Rt(i)]}i32_load16_u(t,e,n){const i=e||0,s=n===void 0?1:n;return[...t,47,s,...Rt(i)]}i32_load(t,e,n){const i=e||0,s=n===void 0?2:n;return[...t,40,s,...Rt(i)]}i32_store(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=2,d=e):Array.isArray(n)?(s=e,g=2,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,54,g,...Rt(s)]}i32_store16(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=1,d=e):Array.isArray(n)?(s=e,g=1,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,59,g,...Rt(s)]}i32_store8(t,e,n,i){let s,g,d;return Array.isArray(e)?(s=0,g=0,d=e):Array.isArray(n)?(s=e,g=0,d=n):Array.isArray(i)&&(s=e,g=n,d=i),[...t,...d,58,g,...Rt(s)]}call(t,...e){const n=this.module.functionIdxByName[t];if(n===void 0)throw new Error(`Function not defined: Function: ${t}`);return[...[].concat(...e),16,...Rt(n)]}call_indirect(t,...e){return[...[].concat(...e),...t,17,0,0]}if(t,e,n){return n?[...t,4,64,...e,5,...n,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,...Rt(t)]}br(t){return[12,...Rt(t)]}ret(t){return[...t,15]}drop(t){return[...t,26]}i64_const(t){return[66,...Ws(t)]}i32_const(t){return[65,...Tn(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 En={i32:127,i64:126,f32:125,f64:124,anyfunc:112,func:96,emptyblock:64};class ki{constructor(t,e,n,i,s){if(n=="import")this.fnType="import",this.moduleName=i,this.fieldName=s;else if(n=="internal")this.fnType="internal";else throw new Error("Invalid function fnType: "+n);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 n=this.nextLocal++;this.localIdxByName[t]=n,this.params.push({type:e})}addLocal(t,e,n){const i=n||1;if(this.localIdxByName[t])throw new Error(`local already exists. Function: ${this.fnName}, Param: ${t} `);const s=this.nextLocal++;this.localIdxByName[t]=s,this.locals.push({type:e,length:i})}setReturnType(t){if(this.returnType)throw new Error(`returnType already defined. Function: ${this.fnName}`);this.returnType=t}getSignature(){const t=[...Rt(this.params.length),...this.params.map(n=>En[n.type])],e=this.returnType?[1,En[this.returnType]]:[0];return[96,...t,...e]}getBody(){const t=this.locals.map(n=>[...Rt(n.length),En[n.type]]),e=[...Rt(this.locals.length),...[].concat(...t),...this.code,11];return[...Rt(e.length),...e]}addCode(...t){this.code.push(...[].concat(...t))}getCodeBuilder(){return new Xs(this)}}class Ta{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([...Fn(1836278016),...Fn(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 ki(this,t,"internal")),this.nInternalFunctions++,this.functions[e]}addIimportFunction(t,e,n){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 i=n||t;const s=this.functions.length;return this.functionIdxByName[t]=s,this.functions.push(new ki(this,t,"import",e,i)),this.nImportFunctions++,this.functions[s]}setMemory(t,e,n){this.memory={pagesSize:t,moduleName:e||"env",fieldName:n||"memory"}}exportFunction(t,e){const n=e||t;if(typeof this.functionIdxByName[t]>"u")throw new Error(`Function not defined: ${t}`);const i=this.functionIdxByName[t];n!=t&&(this.functionIdxByName[n]=i),this.exports.push({exportName:n,idx:i})}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 n,i;(Array.isArray(t)||ArrayBuffer.isView(t))&&typeof e>"u"?(n=t.length,i=t):(n=t,i=e),n=(n-1>>3)+1<<3;const s=this.free;return this.free+=n,i&&this.addData(s,i),s}allocString(t){const n=new globalThis.TextEncoder().encode(t);return this.alloc([...n,0])}_setSignatures(){this.signatures=[];const t={};if(this.functionsTable.length>0){const e=this.functions[this.functionsTable[0]].getSignature(),n="s_"+Pi(e);t[n]=0,this.signatures.push(e)}for(let e=0;e<this.functions.length;e++){const n=this.functions[e].getSignature(),i="s_"+Pi(n);typeof t[i]>"u"&&(t[i]=this.signatures.length,this.signatures.push(n)),this.functions[e].signatureIdx=t[i]}}_buildSection(t,e){return[t,...Rt(e.length),...e]}_buildType(){return this._buildSection(1,[...Rt(this.signatures.length),...[].concat(...this.signatures)])}_buildImport(){const t=[];t.push([...ze(this.memory.moduleName),...ze(this.memory.fieldName),2,0,...Rt(this.memory.pagesSize)]);for(let e=0;e<this.nImportFunctions;e++)t.push([...ze(this.functions[e].moduleName),...ze(this.functions[e].fieldName),0,...Rt(this.functions[e].signatureIdx)]);return this._buildSection(2,Rt(t.length).concat(...t))}_buildFunctionDeclarations(){const t=[];for(let e=this.nImportFunctions;e<this.nImportFunctions+this.nInternalFunctions;e++)t.push(...Rt(this.functions[e].signatureIdx));return this._buildSection(3,[...Rt(t.length),...t])}_buildFunctionsTable(){return this.functionsTable.length==0?[]:this._buildSection(4,[...Rt(1),112,0,...Rt(this.functionsTable.length)])}_buildElements(){if(this.functionsTable.length==0)return[];const t=[];for(let e=0;e<this.functionsTable.length;e++)t.push(...Rt(this.functionsTable[e]));return this._buildSection(9,[...Rt(1),...Rt(0),65,...Tn(0),11,...Rt(this.functionsTable.length),...t])}_buildExports(){const t=[];for(let e=0;e<this.exports.length;e++)t.push([...ze(this.exports[e].exportName),0,...Rt(this.exports[e].idx)]);return this._buildSection(7,Rt(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,Rt(t.length).concat(...t))}_buildData(){const t=[];t.push([0,65,0,11,4,...Fn(this.free)]);for(let e=0;e<this.datas.length;e++)t.push([0,65,...Tn(this.datas[e].offset),11,...Rt(this.datas[e].bytes.length),...this.datas[e].bytes]);return this._buildSection(11,Rt(t.length).concat(...t))}}globalThis.curve_bn128=null;async function Vs(c,t){const e=new Ta;e.setMemory(25),vs(e),t&&t(e);const n={};if(n.code=e.build(),n.pq=e.modules.f1m.pq,n.pr=e.modules.frm.pq,n.pG1gen=e.modules.bn128.pG1gen,n.pG1zero=e.modules.bn128.pG1zero,n.pG1b=e.modules.bn128.pG1b,n.pG2gen=e.modules.bn128.pG2gen,n.pG2zero=e.modules.bn128.pG2zero,n.pG2b=e.modules.bn128.pG2b,n.pOneT=e.modules.bn128.pOneT,n.prePSize=e.modules.bn128.prePSize,n.preQSize=e.modules.bn128.preQSize,n.n8q=32,n.n8r=32,n.q=e.modules.bn128.q,n.r=e.modules.bn128.r,!c&&globalThis.curve_bn128)return globalThis.curve_bn128;const i={name:"bn128",wasm:n,q:ee("21888242871839275222246405745257275088696311157297823662689037894645226208583"),r:ee("21888242871839275222246405745257275088548364400416034343698204186575808495617"),n8q:32,n8r:32,cofactorG2:ee("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d",16),singleThread:!!c},s=await Ia(i);return s.terminate=async function(){i.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},c||(globalThis.curve_bn128=s),s}globalThis.curve_bls12381=null;async function Hs(c,t){const e=new Ta;e.setMemory(25),xs(e),t&&t(e);const n={};if(n.code=e.build(),n.pq=e.modules.f1m.pq,n.pr=e.modules.frm.pq,n.pG1gen=e.modules.bls12381.pG1gen,n.pG1zero=e.modules.bls12381.pG1zero,n.pG1b=e.modules.bls12381.pG1b,n.pG2gen=e.modules.bls12381.pG2gen,n.pG2zero=e.modules.bls12381.pG2zero,n.pG2b=e.modules.bls12381.pG2b,n.pOneT=e.modules.bls12381.pOneT,n.prePSize=e.modules.bls12381.prePSize,n.preQSize=e.modules.bls12381.preQSize,n.n8q=48,n.n8r=32,n.q=e.modules.bls12381.q,n.r=e.modules.bls12381.r,!c&&globalThis.curve_bls12381)return globalThis.curve_bls12381;const i={name:"bls12381",wasm:n,q:ee("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),r:ee("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16),n8q:48,n8r:32,cofactorG1:ee("0x396c8c005555e1568c00aaab0000aaab",16),cofactorG2:ee("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5",16),singleThread:!!c},s=await Ia(i);return s.terminate=async function(){i.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},c||(globalThis.curve_bls12381=s),s}ee("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);ee("21888242871839275222246405745257275088548364400416034343698204186575808495617");ee("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16);ee("21888242871839275222246405745257275088696311157297823662689037894645226208583");const Yt=Bc,rn=ks;Yt.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);Yt.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");const Qs=Yt.e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab",16),Js=Yt.e("21888242871839275222246405745257275088696311157297823662689037894645226208583");async function Hn(c){let t;if(Yt.eq(c,Js))t=await Vs();else if(Yt.eq(c,Qs))t=await Hs();else throw new Error(`Curve not supported: ${Yt.toString(c)}`);return t}function ln(c){return(c&4294901760?(c&=4294901760,16):0)|(c&4278255360?(c&=4278255360,8):0)|(c&4042322160?(c&=4042322160,4):0)|(c&3435973836?(c&=3435973836,2):0)|(c&2863311530)!==0}const Ks=1,Ys=2,qa=10,tr=2;async function de(c,t,e){const n=await c.read(t.G1.F.n8*2),i=t.G1.fromRprLEM(n,0);return e?t.G1.toObject(i):i}async function je(c,t,e){const n=await c.read(t.G2.F.n8*2),i=t.G2.fromRprLEM(n,0);return e?t.G2.toObject(i):i}async function er(c,t,e){await Ze(c,t,1);const n=await c.readULE32();if(await We(c),n===Ks)return await nr(c,t,e);if(n===Ys)return await ir(c,t,e);if(n===qa)return await ar(c,t,e);throw new Error("Protocol not supported: ")}async function nr(c,t,e){const n={};n.protocol="groth16",await Ze(c,t,2);const i=await c.readULE32();n.n8q=i,n.q=await Be(c,i);const s=await c.readULE32();return n.n8r=s,n.r=await Be(c,s),n.curve=await Hn(n.q),n.nVars=await c.readULE32(),n.nPublic=await c.readULE32(),n.domainSize=await c.readULE32(),n.power=ln(n.domainSize),n.vk_alpha_1=await de(c,n.curve,e),n.vk_beta_1=await de(c,n.curve,e),n.vk_beta_2=await je(c,n.curve,e),n.vk_gamma_2=await je(c,n.curve,e),n.vk_delta_1=await de(c,n.curve,e),n.vk_delta_2=await je(c,n.curve,e),await We(c),n}async function ir(c,t,e){const n={};n.protocol="plonk",await Ze(c,t,2);const i=await c.readULE32();n.n8q=i,n.q=await Be(c,i);const s=await c.readULE32();return n.n8r=s,n.r=await Be(c,s),n.curve=await Hn(n.q),n.nVars=await c.readULE32(),n.nPublic=await c.readULE32(),n.domainSize=await c.readULE32(),n.power=ln(n.domainSize),n.nAdditions=await c.readULE32(),n.nConstrains=await c.readULE32(),n.k1=await c.read(s),n.k2=await c.read(s),n.Qm=await de(c,n.curve,e),n.Ql=await de(c,n.curve,e),n.Qr=await de(c,n.curve,e),n.Qo=await de(c,n.curve,e),n.Qc=await de(c,n.curve,e),n.S1=await de(c,n.curve,e),n.S2=await de(c,n.curve,e),n.S3=await de(c,n.curve,e),n.X_2=await je(c,n.curve,e),await We(c),n}async function ar(c,t,e){const n={};n.protocol="fflonk",n.protocolId=qa,await Ze(c,t,tr);const i=await c.readULE32();n.n8q=i,n.q=await Be(c,i),n.curve=await Hn(n.q);const s=await c.readULE32();return n.n8r=s,n.r=await Be(c,s),n.nVars=await c.readULE32(),n.nPublic=await c.readULE32(),n.domainSize=await c.readULE32(),n.power=ln(n.domainSize),n.nAdditions=await c.readULE32(),n.nConstraints=await c.readULE32(),n.k1=await c.read(s),n.k2=await c.read(s),n.w3=await c.read(s),n.w4=await c.read(s),n.w8=await c.read(s),n.wr=await c.read(s),n.X_2=await je(c,n.curve,e),n.C0=await de(c,n.curve,e),await We(c),n}async function or(c,t,e){await ri(c,1);const n=(Math.floor((Yt.bitLength(e)-1)/64)+1)*8;if(await c.writeULE32(n),await rc(c,e,n),t.byteLength%n!=0)throw new Error("Invalid witness length");await c.writeULE32(t.byteLength/n),await li(c),await ri(c,2),await c.write(t),await li(c)}async function cr(c,t){await Ze(c,t,1);const e=await c.readULE32(),n=await Be(c,e),i=await c.readULE32();return await We(c),{n8:e,q:n,nWitness:i}}const{stringifyBigInts:Ti}=rn;async function sr(c,t,e){const{fd:n,sections:i}=await si(t,"wtns",2,33554432,8388608),s=await cr(n,i),{fd:g,sections:d}=await si(c,"zkey",2,1<<25,1<<23),C=await er(g,d);if(C.protocol!="groth16")throw new Error("zkey file is not groth16");if(!Yt.eq(C.r,s.q))throw new Error("Curve of the witness does not match the curve of the proving key");if(s.nWitness!=C.nVars)throw new Error(`Invalid witness length. Circuit: ${C.nVars}, witness: ${s.nWitness}`);const l=C.curve,o=l.Fr,y=l.G1,E=l.G2,m=ln(C.domainSize);e&&e.debug("Reading Wtns");const x=await Fe(n,i,2);e&&e.debug("Reading Coeffs");const O=await Fe(g,d,4);e&&e.debug("Building ABC");const[L,I,v]=await rr(l,C,x,O,e),U=m==o.s?l.Fr.shift:l.Fr.w[m+1],w=await o.ifft(L,"","",e,"IFFT_A"),S=await o.batchApplyKey(w,o.e(1),U),F=await o.fft(S,"","",e,"FFT_A"),r=await o.ifft(I,"","",e,"IFFT_B"),h=await o.batchApplyKey(r,o.e(1),U),R=await o.fft(h,"","",e,"FFT_B"),j=await o.ifft(v,"","",e,"IFFT_C"),T=await o.batchApplyKey(j,o.e(1),U),M=await o.fft(T,"","",e,"FFT_C");e&&e.debug("Join ABC");const A=await lr(l,C,F,R,M,e);let D={};e&&e.debug("Reading A Points");const H=await Fe(g,d,5);D.pi_a=await l.G1.multiExpAffine(H,x,e,"multiexp A"),e&&e.debug("Reading B1 Points");const ut=await Fe(g,d,6);let nt=await l.G1.multiExpAffine(ut,x,e,"multiexp B1");e&&e.debug("Reading B2 Points");const J=await Fe(g,d,7);D.pi_b=await l.G2.multiExpAffine(J,x,e,"multiexp B2"),e&&e.debug("Reading C Points");const ft=await Fe(g,d,8);D.pi_c=await l.G1.multiExpAffine(ft,x.slice((C.nPublic+1)*l.Fr.n8),e,"multiexp C"),e&&e.debug("Reading H Points");const it=await Fe(g,d,9),_t=await l.G1.multiExpAffine(it,A,e,"multiexp H"),zt=l.Fr.random(),G=l.Fr.random();D.pi_a=y.add(D.pi_a,C.vk_alpha_1),D.pi_a=y.add(D.pi_a,y.timesFr(C.vk_delta_1,zt)),D.pi_b=E.add(D.pi_b,C.vk_beta_2),D.pi_b=E.add(D.pi_b,E.timesFr(C.vk_delta_2,G)),nt=y.add(nt,C.vk_beta_1),nt=y.add(nt,y.timesFr(C.vk_delta_1,G)),D.pi_c=y.add(D.pi_c,_t),D.pi_c=y.add(D.pi_c,y.timesFr(D.pi_a,G)),D.pi_c=y.add(D.pi_c,y.timesFr(nt,zt)),D.pi_c=y.add(D.pi_c,y.timesFr(C.vk_delta_1,o.neg(o.mul(zt,G))));let K=[];for(let P=1;P<=C.nPublic;P++){const a=x.slice(P*o.n8,P*o.n8+o.n8);K.push(Yt.fromRprLE(a))}return D.pi_a=y.toObject(y.toAffine(D.pi_a)),D.pi_b=E.toObject(E.toAffine(D.pi_b)),D.pi_c=y.toObject(y.toAffine(D.pi_c)),D.protocol="groth16",D.curve=l.name,await g.close(),await n.close(),D=Ti(D),K=Ti(K),{proof:D,publicSignals:K}}async function rr(c,t,e,n,i){const s=c.Fr.n8,g=4*3+t.n8r,d=(n.byteLength-4)/g,C=new Vt(t.domainSize*s),l=new Vt(t.domainSize*s),o=new Vt(t.domainSize*s),y=[C,l];for(let E=0;E<d;E++){i&&E%1e6==0&&i.debug(`QAP AB: ${E}/${d}`);const m=n.slice(4+E*g,4+E*g+g),x=new DataView(m.buffer),O=x.getUint32(0,!0),L=x.getUint32(4,!0),I=x.getUint32(8,!0),v=m.slice(12,12+s);y[O].set(c.Fr.add(y[O].slice(L*s,L*s+s),c.Fr.mul(v,e.slice(I*s,I*s+s))),L*s)}for(let E=0;E<t.domainSize;E++)i&&E%1e6==0&&i.debug(`QAP C: ${E}/${t.domainSize}`),o.set(c.Fr.mul(C.slice(E*s,E*s+s),l.slice(E*s,E*s+s)),E*s);return[C,l,o]}async function lr(c,t,e,n,i,s){const d=c.Fr.n8,C=Math.floor(e.byteLength/c.Fr.n8),l=[];for(let m=0;m<C;m+=4194304){s&&s.debug(`JoinABC: ${m}/${C}`);const x=Math.min(C-m,4194304),O=[],L=e.slice(m*d,(m+x)*d),I=n.slice(m*d,(m+x)*d),v=i.slice(m*d,(m+x)*d);O.push({cmd:"ALLOCSET",var:0,buff:L}),O.push({cmd:"ALLOCSET",var:1,buff:I}),O.push({cmd:"ALLOCSET",var:2,buff:v}),O.push({cmd:"ALLOC",var:3,len:x*d}),O.push({cmd:"CALL",fnName:"qap_joinABC",params:[{var:0},{var:1},{var:2},{val:x},{var:3}]}),O.push({cmd:"CALL",fnName:"frm_batchFromMontgomery",params:[{var:3},{val:x},{var:3}]}),O.push({cmd:"GET",out:0,var:3,len:x*d}),l.push(c.tm.queueAction(O))}const o=await Promise.all(l);let y;e instanceof Vt?y=new Vt(e.byteLength):y=new Uint8Array(e.byteLength);let E=0;for(let m=0;m<o.length;m++)y.set(o[m][0],E),E+=o[m][0].byteLength;return y}function Ma(c){var t=[];return e(t,c),t;function e(n,i){if(Array.isArray(i))for(let s=0;s<i.length;s++)e(n,i[s]);else n.push(i)}}function Da(c){const t=BigInt(2)**BigInt(64);let e=BigInt("0xCBF29CE484222325");for(var n=0;n<c.length;n++)e^=BigInt(c[n].charCodeAt()),e*=BigInt(1099511628211),e%=t;let i=e.toString(16),s=16-i.length;return i="0".repeat(s).concat(i),i}function ur(c,t){const e=[];let n=BigInt(c);const i=BigInt(4294967296);for(;n;)e.unshift(Number(n%i)),n=n/i;if(t)for(var s=t-e.length;s>0;)e.unshift(0),s--;return e}async function dr(c,t){t=t||{};let e=32767,n,i=!1;for(;!i;)try{n=new WebAssembly.Memory({initial:e}),i=!0}catch(L){if(e===1)throw L;console.warn("Could not allocate "+e*1024*64+" bytes. This may cause severe instability. Trying with "+e*1024*64/2+" bytes"),e=Math.floor(e/2)}const s=await WebAssembly.compile(c);let g,d="",C="",l=1,o=0,y=0;const E=await WebAssembly.instantiate(s,{env:{memory:n},runtime:{exceptionHandler:function(L){let I;throw L==1?I="Signal not found. ":L==2?I="Too many signals set. ":L==3?I="Signal already set. ":L==4?I="Assert Failed. ":L==5?I="Not enough memory. ":L==6?I="Input signal array access exceeds the size. ":I="Unknown error. ",console.error("ERROR: ",L,d),new Error(I+d)},printErrorMessage:function(){d+=x()+`
|
|
121
|
-
`},writeBufferMessage:function(){const L=x();L===`
|
|
122
|
-
`?(console.log(C),C=""):(C!==""&&(C+=" "),C+=L)},showSharedRWMemory:function(){const L=E.exports.getFieldNumLen32(),I=new Uint32Array(L);for(let v=0;v<L;v++)I[L-1-v]=E.exports.readSharedRWMemory(v);if(l>=2&&(o>=1||y>=7)){C!==""&&(C+=" ");const v=Yt.fromArray(I,4294967296).toString();C+=v}else console.log(Yt.fromArray(I,4294967296))},error:function(L,I,v,U,w,S){let F;throw L==7?F=O(I)+" "+g.getFr(U).toString()+" != "+g.getFr(w).toString()+" "+O(S):L==9?F=O(I)+" "+g.getFr(U).toString()+" "+O(w):L==5&&t.sym?F=O(I)+" "+t.sym.labelIdx2Name[w]:F=O(I)+" "+v+" "+U+" "+w+" "+S,console.log("ERROR: ",L,F),new Error(F)},log:function(L){console.log(g.getFr(L).toString())},logGetSignal:function(L,I){t.logGetSignal&&t.logGetSignal(L,g.getFr(I))},logSetSignal:function(L,I){t.logSetSignal&&t.logSetSignal(L,g.getFr(I))},logStartComponent:function(L){t.logStartComponent&&t.logStartComponent(L)},logFinishComponent:function(L){t.logFinishComponent&&t.logFinishComponent(L)}}});typeof E.exports.getVersion=="function"&&(l=E.exports.getVersion()),typeof E.exports.getMinorVersion=="function"&&(o=E.exports.getMinorVersion()),typeof E.exports.getPatchVersion=="function"&&(y=E.exports.getPatchVersion());const m=t&&(t.sanityCheck||t.logGetSignal||t.logSetSignal||t.logStartComponent||t.logFinishComponent);return l===2?g=new _r(E,m):g=new fr(n,E,m),g;function x(){for(var L="",I=E.exports.getMessageChar();I!=0;)L+=String.fromCharCode(I),I=E.exports.getMessageChar();return L}function O(L){const I=new Uint8Array(n.buffer),v=[];for(let U=0;I[L+U]>0;U++)v.push(I[L+U]);return String.fromCharCode.apply(null,v)}}class fr{constructor(t,e,n){this.memory=t,this.i32=new Uint32Array(t.buffer),this.instance=e,this.n32=(this.instance.exports.getFrLen()>>2)-2;const i=this.instance.exports.getPRawPrime(),s=new Array(this.n32);for(let g=0;g<this.n32;g++)s[this.n32-1-g]=this.i32[(i>>2)+g];this.prime=Yt.fromArray(s,4294967296),this.Fr=new Nc(this.prime),this.mask32=Yt.fromString("FFFFFFFF",16),this.NVars=this.instance.exports.getNVars(),this.n64=Math.floor((this.Fr.bitLength-1)/64)+1,this.R=this.Fr.e(Yt.shiftLeft(1,this.n64*64)),this.RInv=this.Fr.inv(this.R),this.sanityCheck=n}circom_version(){return 1}async _doCalculateWitness(t,e){this.instance.exports.init(this.sanityCheck||e?1:0);const n=this.allocInt(),i=this.allocFr();Object.keys(t).forEach(g=>{const d=Da(g),C=parseInt(d.slice(0,8),16),l=parseInt(d.slice(8,16),16);try{this.instance.exports.getSignalOffset32(n,0,C,l)}catch{throw new Error(`Signal ${g} is not an input of the circuit.`)}const o=this.getInt(n),y=Ma(t[g]);for(let E=0;E<y.length;E++)this.setFr(i,y[E]),this.instance.exports.setSignal(0,0,o+E,i)})}async calculateWitness(t,e){const n=this,i=n.i32[0],s=[];await n._doCalculateWitness(t,e);for(let g=0;g<n.NVars;g++){const d=n.instance.exports.getPWitness(g);s.push(n.getFr(d))}return n.i32[0]=i,s}async calculateBinWitness(t,e){const n=this,i=n.i32[0];await n._doCalculateWitness(t,e);const s=n.instance.exports.getWitnessBuffer();n.i32[0]=i;const g=n.memory.buffer.slice(s,s+n.NVars*n.n64*8);return new Uint8Array(g)}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,n=t>>2;if(e.i32[n+1]&2147483648){const s=new Array(e.n32);for(let d=0;d<e.n32;d++)s[e.n32-1-d]=e.i32[n+2+d];const g=e.Fr.e(Yt.fromArray(s,4294967296));return e.i32[n+1]&1073741824?i(g):g}else return e.i32[n]&2147483648?e.Fr.e(e.i32[n]-4294967296):e.Fr.e(e.i32[n]);function i(s){return e.Fr.mul(e.RInv,s)}}setFr(t,e){const n=this;e=n.Fr.e(e);const i=n.Fr.neg(n.Fr.e("80000000",16)),s=n.Fr.e("7FFFFFFF",16);if(n.Fr.geq(e,i)&&n.Fr.leq(e,s)){let d;n.Fr.geq(e,n.Fr.zero)?d=Yt.toNumber(e):(d=Yt.toNumber(n.Fr.sub(e,i)),d=d-2147483648,d=4294967296+d),n.i32[t>>2]=d,n.i32[(t>>2)+1]=0;return}n.i32[t>>2]=0,n.i32[(t>>2)+1]=2147483648;const g=Yt.toArray(e,4294967296);for(let d=0;d<n.n32;d++){const C=g.length-1-d;C>=0?n.i32[(t>>2)+2+d]=g[C]:n.i32[(t>>2)+2+d]=0}}}class _r{constructor(t,e){this.instance=t,this.version=this.instance.exports.getVersion(),this.n32=this.instance.exports.getFieldNumLen32(),this.instance.exports.getRawPrime();const n=new Array(this.n32);for(let i=0;i<this.n32;i++)n[this.n32-1-i]=this.instance.exports.readSharedRWMemory(i);this.prime=Yt.fromArray(n,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 n=Object.keys(t);var i=0;if(n.forEach(s=>{const g=Da(s),d=parseInt(g.slice(0,8),16),C=parseInt(g.slice(8,16),16),l=Ma(t[s]);for(let o=0;o<l.length;o++){const y=ur(l[o],this.n32);for(let E=0;E<this.n32;E++)this.instance.exports.writeSharedRWMemory(E,y[this.n32-1-E]);try{this.instance.exports.setInputSignal(d,C,o),i++}catch(E){throw new Error(E)}}}),i<this.instance.exports.getInputSize())throw new Error(`Not all inputs have been set. Only ${i} out of ${this.instance.exports.getInputSize()}`)}async calculateWitness(t,e){const n=[];await this._doCalculateWitness(t,e);for(let i=0;i<this.witnessSize;i++){this.instance.exports.getWitness(i);const s=new Uint32Array(this.n32);for(let g=0;g<this.n32;g++)s[this.n32-1-g]=this.instance.exports.readSharedRWMemory(g);n.push(Yt.fromArray(s,4294967296))}return n}async calculateWTNSBin(t,e){const n=new Uint32Array(this.witnessSize*this.n32+this.n32+11),i=new Uint8Array(n.buffer);await this._doCalculateWitness(t,e),i[0]=119,i[1]=116,i[2]=110,i[3]=115,n[1]=2,n[2]=2,n[3]=1;const s=this.n32*4,d=(8+s).toString(16);n[4]=parseInt(d.slice(0,8),16),n[5]=parseInt(d.slice(8,16),16),n[6]=s,this.instance.exports.getRawPrime();var C=7;for(let y=0;y<this.n32;y++)n[C+y]=this.instance.exports.readSharedRWMemory(y);C+=this.n32,n[C]=this.witnessSize,C++,n[C]=2,C++;const o=(s*this.witnessSize).toString(16);n[C]=parseInt(o.slice(0,8),16),n[C+1]=parseInt(o.slice(8,16),16),C+=2;for(let y=0;y<this.witnessSize;y++){this.instance.exports.getWitness(y);for(let E=0;E<this.n32;E++)n[C+E]=this.instance.exports.readSharedRWMemory(E);C+=this.n32}return i}}const{unstringifyBigInts:gr}=rn;async function pr(c,t,e,n){const i=gr(c),s=await Yi(t),g=await s.read(s.totalSize);await s.close();const d=await dr(g);if(d.circom_version()==1){const C=await d.calculateBinWitness(i),l=await sc(e,"wtns",2,2);await or(l,C,d.prime),await l.close()}else{const C=await Ki(e),l=await d.calculateWTNSBin(i);await C.write(l),await C.close()}}const{unstringifyBigInts:hr}=rn;async function Lr(c,t,e,n){const i=hr(c),s={type:"mem"};return await pr(i,t,s),await sr(e,s,n)}const{unstringifyBigInts:qi}=rn;function he(c){let t=c.toString(16);for(;t.length<64;)t="0"+t;return t=`"0x${t}"`,t}async function mr(c,t){const e=qi(c),n=qi(t);let i="";for(let g=0;g<n.length;g++)i!=""&&(i=i+","),i=i+he(n[g]);let s;return s=`[${he(e.pi_a[0])}, ${he(e.pi_a[1])}],[[${he(e.pi_b[0][1])}, ${he(e.pi_b[0][0])}],[${he(e.pi_b[1][1])}, ${he(e.pi_b[1][0])}]],[${he(e.pi_c[0])}, ${he(e.pi_c[1])}],[${i}]`,s}Yt.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001",16);Yt.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");var br={},Ra={};(function(c){var t=/[|\\{}()[\]^$+*?.]/g,e=Object.prototype.hasOwnProperty,n=function(l,o){return e.apply(l,[o])};c.escapeRegExpChars=function(l){return l?String(l).replace(t,"\\$&"):""};var i={"&":"&","<":"<",">":">",'"':""","'":"'"},s=/[&<>'"]/g;function g(l){return i[l]||l}var d=`var _ENCODE_HTML_RULES = {
|
|
123
|
-
"&": "&"
|
|
124
|
-
, "<": "<"
|
|
125
|
-
, ">": ">"
|
|
126
|
-
, '"': """
|
|
127
|
-
, "'": "'"
|
|
128
|
-
}
|
|
129
|
-
, _MATCH_HTML = /[&<>'"]/g;
|
|
130
|
-
function encode_char(c) {
|
|
131
|
-
return _ENCODE_HTML_RULES[c] || c;
|
|
132
|
-
};
|
|
133
|
-
`;c.escapeXML=function(l){return l==null?"":String(l).replace(s,g)};function C(){return Function.prototype.toString.call(this)+`;
|
|
134
|
-
`+d}try{typeof Object.defineProperty=="function"?Object.defineProperty(c.escapeXML,"toString",{value:C}):c.escapeXML.toString=C}catch{console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)")}c.shallowCopy=function(l,o){if(o=o||{},l!=null)for(var y in o)n(o,y)&&(y==="__proto__"||y==="constructor"||(l[y]=o[y]));return l},c.shallowCopyFromList=function(l,o,y){if(y=y||[],o=o||{},l!=null)for(var E=0;E<y.length;E++){var m=y[E];if(typeof o[m]<"u"){if(!n(o,m)||m==="__proto__"||m==="constructor")continue;l[m]=o[m]}}return l},c.cache={_data:{},set:function(l,o){this._data[l]=o},get:function(l){return this._data[l]},remove:function(l){delete this._data[l]},reset:function(){this._data={}}},c.hyphenToCamel=function(l){return l.replace(/-[a-z]/g,function(o){return o[1].toUpperCase()})},c.createNullProtoObjWherePossible=function(){return typeof Object.create=="function"?function(){return Object.create(null)}:{__proto__:null}instanceof Object?function(){return{}}:function(){return{__proto__:null}}}()})(Ra);const yr="ejs",Cr="Embedded JavaScript templates",Ar=["template","engine","ejs"],Fr="3.1.9",Er="Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",wr="Apache-2.0",Br={ejs:"./bin/cli.js"},vr="./lib/ejs.js",xr="ejs.min.js",Sr="ejs.min.js",Ir={type:"git",url:"git://github.com/mde/ejs.git"},Or="https://github.com/mde/ejs/issues",Pr="https://github.com/mde/ejs",kr={jake:"^10.8.5"},Tr={browserify:"^16.5.1",eslint:"^6.8.0","git-directory-deploy":"^1.5.1",jsdoc:"^4.0.2","lru-cache":"^4.0.1",mocha:"^10.2.0","uglify-js":"^3.3.16"},qr={node:">=0.10.0"},Mr={test:"mocha -u tdd"},Dr={name:yr,description:Cr,keywords:Ar,version:Fr,author:Er,license:wr,bin:Br,main:vr,jsdelivr:xr,unpkg:Sr,repository:Ir,bugs:Or,homepage:Pr,dependencies:kr,devDependencies:Tr,engines:qr,scripts:Mr};(function(c){/**
|
|
135
|
-
* @file Embedded JavaScript templating engine. {@link http://ejs.co}
|
|
136
|
-
* @author Matthew Eernisse <mde@fleegix.org>
|
|
137
|
-
* @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
|
|
138
|
-
* @project EJS
|
|
139
|
-
* @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
|
|
140
|
-
*/var t=se.require$$0,e=se.require$$0,n=Ra,i=!1,s=Dr.version,g="<",d=">",C="%",l="locals",o="ejs",y="(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)",E=["delimiter","scope","context","debug","compileDebug","client","_with","rmWhitespace","strict","filename","async"],m=E.concat("cache"),x=/^\uFEFF/,O=/^[a-zA-Z_$][0-9a-zA-Z_$]*$/;c.cache=n.cache,c.fileLoader=t.readFileSync,c.localsName=l,c.promiseImpl=new Function("return this;")().Promise,c.resolveInclude=function(R,j,T){var M=e.dirname,A=e.extname,D=e.resolve,H=D(T?j:M(j),R),ut=A(R);return ut||(H+=".ejs"),H};function L(R,j){var T;if(j.some(function(M){return T=c.resolveInclude(R,M,!0),t.existsSync(T)}))return T}function I(R,j){var T,M,A=j.views,D=/^[A-Za-z]+:\\|^\//.exec(R);if(D&&D.length)R=R.replace(/^\/*/,""),Array.isArray(j.root)?T=L(R,j.root):T=c.resolveInclude(R,j.root||"/",!0);else if(j.filename&&(M=c.resolveInclude(R,j.filename),t.existsSync(M)&&(T=M)),!T&&Array.isArray(A)&&(T=L(R,A)),!T&&typeof j.includer!="function")throw new Error('Could not find the include file "'+j.escapeFunction(R)+'"');return T}function v(R,j){var T,M=R.filename,A=arguments.length>1;if(R.cache){if(!M)throw new Error("cache option requires a filename");if(T=c.cache.get(M),T)return T;A||(j=w(M).toString().replace(x,""))}else if(!A){if(!M)throw new Error("Internal EJS error: no file name or template provided");j=w(M).toString().replace(x,"")}return T=c.compile(j,R),R.cache&&c.cache.set(M,T),T}function U(R,j,T){var M;if(T){try{M=v(R)(j)}catch(A){return T(A)}T(null,M)}else{if(typeof c.promiseImpl=="function")return new c.promiseImpl(function(A,D){try{M=v(R)(j),A(M)}catch(H){D(H)}});throw new Error("Please provide a callback function")}}function w(R){return c.fileLoader(R)}function S(R,j){var T=n.shallowCopy(n.createNullProtoObjWherePossible(),j);if(T.filename=I(R,T),typeof j.includer=="function"){var M=j.includer(R,T.filename);if(M&&(M.filename&&(T.filename=M.filename),M.template))return v(T,M.template)}return v(T)}function F(R,j,T,M,A){var D=j.split(`
|
|
141
|
-
`),H=Math.max(M-3,0),ut=Math.min(D.length,M+3),nt=A(T),J=D.slice(H,ut).map(function(ft,it){var _t=it+H+1;return(_t==M?" >> ":" ")+_t+"| "+ft}).join(`
|
|
142
|
-
`);throw R.path=nt,R.message=(nt||"ejs")+":"+M+`
|
|
143
|
-
`+J+`
|
|
144
|
-
|
|
145
|
-
`+R.message,R}function r(R){return R.replace(/;(\s*$)/,"$1")}c.compile=function(j,T){var M;return T&&T.scope&&(i||(console.warn("`scope` option is deprecated and will be removed in EJS 3"),i=!0),T.context||(T.context=T.scope),delete T.scope),M=new h(j,T),M.compile()},c.render=function(R,j,T){var M=j||n.createNullProtoObjWherePossible(),A=T||n.createNullProtoObjWherePossible();return arguments.length==2&&n.shallowCopyFromList(A,M,E),v(A,R)(M)},c.renderFile=function(){var R=Array.prototype.slice.call(arguments),j=R.shift(),T,M={filename:j},A,D;return typeof arguments[arguments.length-1]=="function"&&(T=R.pop()),R.length?(A=R.shift(),R.length?n.shallowCopy(M,R.pop()):(A.settings&&(A.settings.views&&(M.views=A.settings.views),A.settings["view cache"]&&(M.cache=!0),D=A.settings["view options"],D&&n.shallowCopy(M,D)),n.shallowCopyFromList(M,A,m)),M.filename=j):A=n.createNullProtoObjWherePossible(),U(M,A,T)},c.Template=h,c.clearCache=function(){c.cache.reset()};function h(R,j){j=j||n.createNullProtoObjWherePossible();var T=n.createNullProtoObjWherePossible();this.templateText=R,this.mode=null,this.truncate=!1,this.currentLine=1,this.source="",T.client=j.client||!1,T.escapeFunction=j.escape||j.escapeFunction||n.escapeXML,T.compileDebug=j.compileDebug!==!1,T.debug=!!j.debug,T.filename=j.filename,T.openDelimiter=j.openDelimiter||c.openDelimiter||g,T.closeDelimiter=j.closeDelimiter||c.closeDelimiter||d,T.delimiter=j.delimiter||c.delimiter||C,T.strict=j.strict||!1,T.context=j.context,T.cache=j.cache||!1,T.rmWhitespace=j.rmWhitespace,T.root=j.root,T.includer=j.includer,T.outputFunctionName=j.outputFunctionName,T.localsName=j.localsName||c.localsName||l,T.views=j.views,T.async=j.async,T.destructuredLocals=j.destructuredLocals,T.legacyInclude=typeof j.legacyInclude<"u"?!!j.legacyInclude:!0,T.strict?T._with=!1:T._with=typeof j._with<"u"?j._with:!0,this.opts=T,this.regex=this.createRegex()}h.modes={EVAL:"eval",ESCAPED:"escaped",RAW:"raw",COMMENT:"comment",LITERAL:"literal"},h.prototype={createRegex:function(){var R=y,j=n.escapeRegExpChars(this.opts.delimiter),T=n.escapeRegExpChars(this.opts.openDelimiter),M=n.escapeRegExpChars(this.opts.closeDelimiter);return R=R.replace(/%/g,j).replace(/</g,T).replace(/>/g,M),new RegExp(R)},compile:function(){var R,j,T=this.opts,M="",A="",D=T.escapeFunction,H,ut=T.filename?JSON.stringify(T.filename):"undefined";if(!this.source){if(this.generateSource(),M+=` var __output = "";
|
|
146
|
-
function __append(s) { if (s !== undefined && s !== null) __output += s }
|
|
147
|
-
`,T.outputFunctionName){if(!O.test(T.outputFunctionName))throw new Error("outputFunctionName is not a valid JS identifier.");M+=" var "+T.outputFunctionName+` = __append;
|
|
148
|
-
`}if(T.localsName&&!O.test(T.localsName))throw new Error("localsName is not a valid JS identifier.");if(T.destructuredLocals&&T.destructuredLocals.length){for(var nt=" var __locals = ("+T.localsName+` || {}),
|
|
149
|
-
`,J=0;J<T.destructuredLocals.length;J++){var ft=T.destructuredLocals[J];if(!O.test(ft))throw new Error("destructuredLocals["+J+"] is not a valid JS identifier.");J>0&&(nt+=`,
|
|
150
|
-
`),nt+=ft+" = __locals."+ft}M+=nt+`;
|
|
151
|
-
`}T._with!==!1&&(M+=" with ("+T.localsName+` || {}) {
|
|
152
|
-
`,A+=` }
|
|
153
|
-
`),A+=` return __output;
|
|
154
|
-
`,this.source=M+this.source+A}T.compileDebug?R=`var __line = 1
|
|
155
|
-
, __lines = `+JSON.stringify(this.templateText)+`
|
|
156
|
-
, __filename = `+ut+`;
|
|
157
|
-
try {
|
|
158
|
-
`+this.source+`} catch (e) {
|
|
159
|
-
rethrow(e, __lines, __filename, __line, escapeFn);
|
|
160
|
-
}
|
|
161
|
-
`:R=this.source,T.client&&(R="escapeFn = escapeFn || "+D.toString()+`;
|
|
162
|
-
`+R,T.compileDebug&&(R="rethrow = rethrow || "+F.toString()+`;
|
|
163
|
-
`+R)),T.strict&&(R=`"use strict";
|
|
164
|
-
`+R),T.debug&&console.log(R),T.compileDebug&&T.filename&&(R=R+`
|
|
165
|
-
//# sourceURL=`+ut+`
|
|
166
|
-
`);try{if(T.async)try{H=new Function("return (async function(){}).constructor;")()}catch(G){throw G instanceof SyntaxError?new Error("This environment does not support async/await"):G}else H=Function;j=new H(T.localsName+", escapeFn, include, rethrow",R)}catch(G){throw G instanceof SyntaxError&&(T.filename&&(G.message+=" in "+T.filename),G.message+=` while compiling ejs
|
|
167
|
-
|
|
168
|
-
`,G.message+=`If the above error is not helpful, you may want to try EJS-Lint:
|
|
169
|
-
`,G.message+="https://github.com/RyanZim/EJS-Lint",T.async||(G.message+=`
|
|
170
|
-
`,G.message+="Or, if you meant to create an async function, pass `async: true` as an option.")),G}var it=T.client?j:function(K){var P=function(a,q){var u=n.shallowCopy(n.createNullProtoObjWherePossible(),K);return q&&(u=n.shallowCopy(u,q)),S(a,T)(u)};return j.apply(T.context,[K||n.createNullProtoObjWherePossible(),D,P,F])};if(T.filename&&typeof Object.defineProperty=="function"){var _t=T.filename,zt=e.basename(_t,e.extname(_t));try{Object.defineProperty(it,"name",{value:zt,writable:!1,enumerable:!1,configurable:!0})}catch{}}return it},generateSource:function(){var R=this.opts;R.rmWhitespace&&(this.templateText=this.templateText.replace(/[\r\n]+/g,`
|
|
171
|
-
`).replace(/^\s+|\s+$/gm,"")),this.templateText=this.templateText.replace(/[ \t]*<%_/gm,"<%_").replace(/_%>[ \t]*/gm,"_%>");var j=this,T=this.parseTemplateText(),M=this.opts.delimiter,A=this.opts.openDelimiter,D=this.opts.closeDelimiter;T&&T.length&&T.forEach(function(H,ut){var nt;if(H.indexOf(A+M)===0&&H.indexOf(A+M+M)!==0&&(nt=T[ut+2],!(nt==M+D||nt=="-"+M+D||nt=="_"+M+D)))throw new Error('Could not find matching close tag for "'+H+'".');j.scanLine(H)})},parseTemplateText:function(){for(var R=this.templateText,j=this.regex,T=j.exec(R),M=[],A;T;)A=T.index,A!==0&&(M.push(R.substring(0,A)),R=R.slice(A)),M.push(T[0]),R=R.slice(T[0].length),T=j.exec(R);return R&&M.push(R),M},_addOutput:function(R){if(this.truncate&&(R=R.replace(/^(?:\r\n|\r|\n)/,""),this.truncate=!1),!R)return R;R=R.replace(/\\/g,"\\\\"),R=R.replace(/\n/g,"\\n"),R=R.replace(/\r/g,"\\r"),R=R.replace(/"/g,'\\"'),this.source+=' ; __append("'+R+`")
|
|
172
|
-
`},scanLine:function(R){var j=this,T=this.opts.delimiter,M=this.opts.openDelimiter,A=this.opts.closeDelimiter,D=0;switch(D=R.split(`
|
|
173
|
-
`).length-1,R){case M+T:case M+T+"_":this.mode=h.modes.EVAL;break;case M+T+"=":this.mode=h.modes.ESCAPED;break;case M+T+"-":this.mode=h.modes.RAW;break;case M+T+"#":this.mode=h.modes.COMMENT;break;case M+T+T:this.mode=h.modes.LITERAL,this.source+=' ; __append("'+R.replace(M+T+T,M+T)+`")
|
|
174
|
-
`;break;case T+T+A:this.mode=h.modes.LITERAL,this.source+=' ; __append("'+R.replace(T+T+A,T+A)+`")
|
|
175
|
-
`;break;case T+A:case"-"+T+A:case"_"+T+A:this.mode==h.modes.LITERAL&&this._addOutput(R),this.mode=null,this.truncate=R.indexOf("-")===0||R.indexOf("_")===0;break;default:if(this.mode){switch(this.mode){case h.modes.EVAL:case h.modes.ESCAPED:case h.modes.RAW:R.lastIndexOf("//")>R.lastIndexOf(`
|
|
176
|
-
`)&&(R+=`
|
|
177
|
-
`)}switch(this.mode){case h.modes.EVAL:this.source+=" ; "+R+`
|
|
178
|
-
`;break;case h.modes.ESCAPED:this.source+=" ; __append(escapeFn("+r(R)+`))
|
|
179
|
-
`;break;case h.modes.RAW:this.source+=" ; __append("+r(R)+`)
|
|
180
|
-
`;break;case h.modes.COMMENT:break;case h.modes.LITERAL:this._addOutput(R);break}}else this._addOutput(R)}j.opts.compileDebug&&D&&(this.currentLine+=D,this.source+=" ; __line = "+this.currentLine+`
|
|
181
|
-
`)}},c.escapeXML=n.escapeXML,c.__express=c.renderFile,c.VERSION=s,c.name=o,typeof window<"u"&&(window.ejs=c)})(br);var Qn={exports:{}};Qn.exports;(function(c){(function(t){var e,n,i,s,g,d,C,l,o,y,E,m,x,O,L,I,v;e={},n={},[{n:"equal",f:U,s:"equal {e}"},{n:"undefined",f:w,s:"be undefined"},{n:"null",f:S,s:"be null"},{n:"assigned",f:F,s:"be assigned"},{n:"primitive",f:r,s:"be primitive type"},{n:"contains",f:$t,s:"contain {e}"},{n:"in",f:Jt,s:"be in {e}"},{n:"containsKey",f:re,s:"contain key {e}"},{n:"keyIn",f:te,s:"be key in {e}"},{n:"zero",f:h,s:"be 0"},{n:"one",f:R,s:"be 1"},{n:"infinity",f:j,s:"be infinity"},{n:"number",f:T,s:"be Number"},{n:"integer",f:M,s:"be integer"},{n:"float",f:A,s:"be non-integer number"},{n:"even",f:D,s:"be even number"},{n:"odd",f:H,s:"be odd number"},{n:"greater",f:ut,s:"be greater than {e}"},{n:"less",f:nt,s:"be less than {e}"},{n:"between",f:J,s:"be between {e} and {e2}"},{n:"greaterOrEqual",f:ft,s:"be greater than or equal to {e}"},{n:"lessOrEqual",f:it,s:"be less than or equal to {e}"},{n:"inRange",f:_t,s:"be in the range {e} to {e2}"},{n:"positive",f:zt,s:"be positive number"},{n:"negative",f:G,s:"be negative number"},{n:"string",f:K,s:"be String"},{n:"emptyString",f:P,s:"be empty string"},{n:"nonEmptyString",f:a,s:"be non-empty string"},{n:"match",f:q,s:"match {e}"},{n:"boolean",f:u,s:"be Boolean"},{n:"object",f:W,s:"be Object"},{n:"emptyObject",f:z,s:"be empty object"},{n:"nonEmptyObject",f:at,s:"be non-empty object"},{n:"instanceStrict",f:Lt,s:"be instanceof {t}"},{n:"thenable",f:At,s:"be promise-like"},{n:"instance",f:yt,s:"be {t}"},{n:"like",f:It,s:"be like {e}"},{n:"identical",f:mt,s:"be identical to {e}"},{n:"array",f:Ot,s:"be Array"},{n:"emptyArray",f:jt,s:"be empty array"},{n:"nonEmptyArray",f:Et,s:"be non-empty array"},{n:"arrayLike",f:bt,s:"be array-like"},{n:"iterable",f:pt,s:"be iterable"},{n:"date",f:Mt,s:"be valid Date"},{n:"function",f:Zt,s:"be Function"},{n:"hasLength",f:Pt,s:"have length {e}"},{n:"throws",f:vt,s:"throw"}].map(function(k){var et=k.n;e[et]="assert failed: expected {a} to "+k.s,n[et]=k.f}),i={map:Wt,all:Y,any:Z},C=["array","arrayLike","iterable","object"],l=Object.prototype.hasOwnProperty,o=Object.prototype.toString,y=Object.keys,E=Array.prototype.slice,m=Array.isArray,x=Number.NEGATIVE_INFINITY,O=Number.POSITIVE_INFINITY,L=typeof Symbol=="function",I=typeof Map=="function",v=typeof Set=="function",i=Q(i,n),s=Ft($,V),g=Ft(ct,st),d=Ft(rt,ot),s.not=xt($,g,"not "),s.maybe=xt($,d,"maybe "),C.forEach(Tt),Ut(s,$),Ut(g,ct),C.forEach(St),kt(Q(i,{assert:s,not:g,maybe:d}));function U(k,et){return k===et}function w(k){return k===void 0}function S(k){return k===null}function F(k){return k!=null}function r(k){var et;switch(k){case null:case void 0:case!1:case!0:return!0}return et=typeof k,et==="string"||et==="number"||L&&et==="symbol"}function h(k){return k===0}function R(k){return k===1}function j(k){return k===x||k===O}function T(k){return typeof k=="number"&&k>x&&k<O}function M(k){return typeof k=="number"&&k%1===0}function A(k){return T(k)&&k%1!==0}function D(k){return typeof k=="number"&&k%2===0}function H(k){return M(k)&&k%2!==0}function ut(k,et){return T(k)&&k>et}function nt(k,et){return T(k)&&k<et}function J(k,et,dt){return et<dt?ut(k,et)&&k<dt:nt(k,et)&&k>dt}function ft(k,et){return T(k)&&k>=et}function it(k,et){return T(k)&&k<=et}function _t(k,et,dt){return et<dt?ft(k,et)&&k<=dt:it(k,et)&&k>=dt}function zt(k){return ut(k,0)}function G(k){return nt(k,0)}function K(k){return typeof k=="string"}function P(k){return k===""}function a(k){return K(k)&&k!==""}function q(k,et){return K(k)&&!!k.match(et)}function u(k){return k===!1||k===!0}function W(k){return o.call(k)==="[object Object]"}function z(k){return W(k)&&!b(k,function(){return!0})}function b(k,et){for(var dt in k)if(l.call(k,dt)&&et(dt,k[dt]))return!0;return!1}function at(k){return W(k)&&b(k,function(){return!0})}function At(k){return F(k)&&Zt(k.then)}function Lt(k,et){try{return k instanceof et}catch{return!1}}function yt(k,et){try{return Lt(k,et)||k.constructor.name===et.name||o.call(k)==="[object "+et.name+"]"}catch{return!1}}function It(k,et){var dt;if(!F(k)||!F(et))return k===et;for(dt in et)if(l.call(et,dt)&&(!l.call(k,dt)||typeof k[dt]!=typeof et[dt]||W(k[dt])&&!It(k[dt],et[dt])))return!1;return!0}function mt(k,et){var dt;if(!F(k)||!F(et))return k===et;for(dt in et)if(l.call(et,dt)){if(!l.call(k,dt))return!1;if(W(k[dt])){if(!mt(k[dt],et[dt]))return!1}else if(k[dt]!==et[dt])return!1}for(dt in k)if(l.call(k,dt)){if(!l.call(et,dt))return!1;if(W(et[dt])){if(!mt(et[dt],k[dt]))return!1}else if(et[dt]!==k[dt])return!1}return!0}function Ot(k){return m(k)}function jt(k){return m(k)&&k.length===0}function Et(k){return m(k)&&k.length>0}function bt(k){return F(k)&&k.length>=0}function pt(k){return L?F(k)&&Zt(k[Symbol.iterator]):bt(k)}function $t(k,et){var dt,qt;if(!F(k))return!1;if(v&&Lt(k,Set))return k.has(et);if(K(k))return k.indexOf(et)!==-1;if(L&&k[Symbol.iterator]&&Zt(k.values)){dt=k.values();do if(qt=dt.next(),qt.value===et)return!0;while(!qt.done);return!1}return b(k,function(Ht,Qt){return Qt===et})}function Jt(k,et){return $t(et,k)}function re(k,et){return F(k)?I&&Lt(k,Map)?k.has(et):pt(k)&&!T(+et)?!1:!!k[et]:!1}function te(k,et){return re(et,k)}function Pt(k,et){return F(k)&&k.length===et}function Mt(k){return Lt(k,Date)&&M(k.getTime())}function Zt(k){return typeof k=="function"}function vt(k){if(!Zt(k))return!1;try{k()}catch{return!0}return!1}function Wt(k,et){var dt;if(m(k)?dt=[]:dt={},Zt(et))wt(k,function(Ht,Qt){dt[Ht]=et(Qt)});else{m(et)||s.object(et);var qt=y(k||{});wt(et,function(Ht,Qt){qt.some(function(Kt,fe){return Kt===Ht?(qt.splice(fe,1),!0):!1}),Zt(Qt)?g.assigned(k)?dt[Ht]=!!Qt.m:dt[Ht]=Qt(k[Ht]):dt[Ht]=Wt(k[Ht],Qt)})}return dt}function wt(k,et){for(var dt in k)l.call(k,dt)&&et(dt,k[dt])}function Y(k){return m(k)?f(k,!1):(s.object(k),_(k,!1))}function f(k,et){var dt;for(dt=0;dt<k.length;dt+=1)if(k[dt]===et)return et;return!et}function _(k,et){var dt,qt;for(dt in k)if(l.call(k,dt)&&(qt=k[dt],W(qt)&&_(qt,et)===et||qt===et))return et;return!et}function Z(k){return m(k)?f(k,!0):(s.object(k),_(k,!0))}function Q(k,et){return wt(et,function(dt,qt){k[dt]=qt}),k}function $(k,et){return function(){var dt=arguments,qt=k.l||k.length,Ht=dt[qt],Qt=dt[qt+1];return V(k.apply(null,dt),a(Ht)?Ht:et.replace("{a}",tt(dt[0])).replace("{e}",tt(dt[1])).replace("{e2}",tt(dt[2])).replace("{t}",function(){var Kt=dt[1];return Kt&&Kt.name?Kt.name:Kt}),Zt(Qt)?Qt:TypeError),dt[0]}}function tt(k){return function(){return K(k)?'"'+k.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"':k&&k!==!0&&k.constructor&&!Lt(k,RegExp)&&typeof k!="number"?k.constructor.name:k}}function V(k,et,dt){if(k)return k;throw new(dt||Error)(et||"assert failed")}function ct(k){var et=function(){return st(k.apply(null,arguments))};return et.l=k.length,et}function st(k){return!k}function rt(k){var et=function(){return g.assigned(arguments[0])?!0:k.apply(null,arguments)};return et.l=k.length,et.m=!0,et}function ot(k){return F(k)?k:!0}function gt(k,et,dt){var qt=function(){var Ht,Qt;if(Ht=arguments[0],k==="maybe"&&g.assigned(Ht))return!0;if(!et(Ht))return!1;Ht=Bt(et,Ht),Qt=E.call(arguments,1);try{Ht.forEach(function(Kt){if((k!=="maybe"||F(Kt))&&!dt.apply(null,[Kt].concat(Qt)))throw 0})}catch{return!1}return!0};return qt.l=dt.length,qt}function Bt(k,et){switch(k){case bt:return E.call(et);case W:return y(et).map(function(dt){return et[dt]});default:return et}}function Ft(k,et){return ht([k,n,et,""])}function ht(k){var et,dt,qt,Ht;return et=k.shift(),dt=k.pop(),qt=k.pop(),Ht=k.pop(),wt(Ht,function(Qt,Kt){var fe=e[Qt];fe&&dt&&(fe=fe.replace("to",dt+"to")),Object.defineProperty(qt,Qt,{configurable:!1,enumerable:!0,writable:!1,value:et.apply(null,k.concat(Kt,fe))})}),qt}function xt(k,et,dt){return ht([k,et,{},dt])}function Tt(k){n[k].of=ht([gt.bind(null,null),n[k],n,{},""])}function Ut(k,et){C.forEach(function(dt){k[dt].of=xt(et,n[dt].of)})}function St(k){d[k].of=ht([gt.bind(null,"maybe"),n[k],n,{},""]),s.maybe[k].of=xt($,d[k].of),s.not[k].of=xt($,g[k].of)}function kt(k){c!==null&&c.exports?c.exports=k:t.check=k}})(se.commonjsGlobal)})(Qn);var Jn=Qn.exports,Rr={exports:{}};(function(c){c.exports={array:"arr",object:"obj",property:"pro",string:"str",number:"num",literal:"lit",endPrefix:"end-",end:"end",error:"err"},c.exports.endArray=c.exports.endPrefix+c.exports.array,c.exports.endObject=c.exports.endPrefix+c.exports.object,c.exports.endLine=`${c.exports.endPrefix}line`,c.exports.dataError=`${c.exports.error}-data`})(Rr);se.eventsExports.EventEmitter;const Nr=se.util,Na=se.require$$0.Readable,Mi=Jn;Nr.inherits(an,Na);var za=an;function an(c,t){return Mi.not.instanceStrict(this,an)?new an(c):(Mi.assert.function(c,"Invalid read implementation"),this._read=function(){c()},Na.call(this,t))}const zr=Jn,Ua=za,Ur=se.util;Ur.inherits(qn,Ua);function qn(c,t){return zr.not.instanceStrict(this,qn)?new qn(c,t):Ua.call(this,c,{...t,objectMode:!0})}class un extends Array{constructor(t){let e,n;if(!Di(t))throw new TypeError("Argument `size` must be a positive integer.");return super(t),this.grow=i=>{if(!Di(i))throw new TypeError("Argument `by` must be a positive integer.");let s;const g=t+i;for(s=t;s<g;++s)this[s]=void 0;if(n)for(s=0;s<=e;++s){let d=t+s;d>=g&&(d%=g),this[d]=this[s],this[s]=void 0}t=g},new Proxy(this,{get(i,s){return Mn(s)?i[Ri(s,t)]:i[s]},set(i,s,g){return Mn(s)?(e=Ri(s,t),i[e]=g,Math.abs(s)>=t?n=!0:n=!1):i[s]=g,!0}})}}function Di(c){return Mn(c)&&c>0}function Mn(c){try{return+c%1===0}catch{}return!1}function Ri(c,t){return c===0?0:c<0?(t-Math.abs(c))%t:c%t}function dn(){throw new Error("Not implemented")}un.prototype.push=dn;un.prototype.pop=dn;un.prototype.shift=dn;un.prototype.unshift=dn;function Ye(c){throw new Error('Could not dynamically require "'+c+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jr={exports:{}};/*! jsonpath 1.1.1 */(function(c,t){(function(e){c.exports=e()})(function(){return function e(n,i,s){function g(l,o){if(!i[l]){if(!n[l]){var y=typeof Ye=="function"&&Ye;if(!o&&y)return y(l,!0);if(d)return d(l,!0);var E=new Error("Cannot find module '"+l+"'");throw E.code="MODULE_NOT_FOUND",E}var m=i[l]={exports:{}};n[l][0].call(m.exports,function(x){var O=n[l][1][x];return g(O||x)},m,m.exports,e,n,i,s)}return i[l].exports}for(var d=typeof Ye=="function"&&Ye,C=0;C<s.length;C++)g(s[C]);return g}({"./aesprim":[function(e,n,i){(function(s,g){g(typeof i<"u"?i:s.esprima={})})(this,function(s){var g,d,C,l,o,y,E,m,x,O,L,I,v,U,w,S,F,r;g={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8,RegularExpression:9},d={},d[g.BooleanLiteral]="Boolean",d[g.EOF]="<end>",d[g.Identifier]="Identifier",d[g.Keyword]="Keyword",d[g.NullLiteral]="Null",d[g.NumericLiteral]="Numeric",d[g.Punctuator]="Punctuator",d[g.StringLiteral]="String",d[g.RegularExpression]="RegularExpression",C=["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="],l={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"},o={Data:1,Get:2,Set:4},y={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"},E={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]")};function h(p,B){if(!p)throw new Error("ASSERT: "+B)}function R(p){return p>=48&&p<=57}function j(p){return"0123456789abcdefABCDEF".indexOf(p)>=0}function T(p){return"01234567".indexOf(p)>=0}function M(p){return p===32||p===9||p===11||p===12||p===160||p>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(p)>=0}function A(p){return p===10||p===13||p===8232||p===8233}function D(p){return p==64||p===36||p===95||p>=65&&p<=90||p>=97&&p<=122||p===92||p>=128&&E.NonAsciiIdentifierStart.test(String.fromCharCode(p))}function H(p){return p===36||p===95||p>=65&&p<=90||p>=97&&p<=122||p>=48&&p<=57||p===92||p>=128&&E.NonAsciiIdentifierPart.test(String.fromCharCode(p))}function ut(p){switch(p){case"class":case"enum":case"export":case"extends":case"import":case"super":return!0;default:return!1}}function nt(p){switch(p){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}}function J(p){return p==="eval"||p==="arguments"}function ft(p){if(O&&nt(p))return!0;switch(p.length){case 2:return p==="if"||p==="in"||p==="do";case 3:return p==="var"||p==="for"||p==="new"||p==="try"||p==="let";case 4:return p==="this"||p==="else"||p==="case"||p==="void"||p==="with"||p==="enum";case 5:return p==="while"||p==="break"||p==="catch"||p==="throw"||p==="const"||p==="yield"||p==="class"||p==="super";case 6:return p==="return"||p==="typeof"||p==="delete"||p==="switch"||p==="export"||p==="import";case 7:return p==="default"||p==="finally"||p==="extends";case 8:return p==="function"||p==="continue"||p==="debugger";case 10:return p==="instanceof";default:return!1}}function it(p,B,N,X,lt){var Ct;h(typeof N=="number","Comment must have valid position"),!(F.lastCommentStart>=N)&&(F.lastCommentStart=N,Ct={type:p,value:B},r.range&&(Ct.range=[N,X]),r.loc&&(Ct.loc=lt),r.comments.push(Ct),r.attachComment&&(r.leadingComments.push(Ct),r.trailingComments.push(Ct)))}function _t(p){var B,N,X,lt;for(B=L-p,N={start:{line:I,column:L-v-p}};L<U;)if(X=x.charCodeAt(L),++L,A(X)){r.comments&&(lt=x.slice(B+p,L-1),N.end={line:I,column:L-v-1},it("Line",lt,B,L-1,N)),X===13&&x.charCodeAt(L)===10&&++L,++I,v=L;return}r.comments&&(lt=x.slice(B+p,L),N.end={line:I,column:L-v},it("Line",lt,B,L,N))}function zt(){var p,B,N,X;for(r.comments&&(p=L-2,B={start:{line:I,column:L-v-2}});L<U;)if(N=x.charCodeAt(L),A(N))N===13&&x.charCodeAt(L+1)===10&&++L,++I,++L,v=L,L>=U&&Pt({},y.UnexpectedToken,"ILLEGAL");else if(N===42){if(x.charCodeAt(L+1)===47){++L,++L,r.comments&&(X=x.slice(p+2,L-2),B.end={line:I,column:L-v},it("Block",X,p,L,B));return}++L}else++L;Pt({},y.UnexpectedToken,"ILLEGAL")}function G(){var p,B;for(B=L===0;L<U;)if(p=x.charCodeAt(L),M(p))++L;else if(A(p))++L,p===13&&x.charCodeAt(L)===10&&++L,++I,v=L,B=!0;else if(p===47)if(p=x.charCodeAt(L+1),p===47)++L,++L,_t(2),B=!0;else if(p===42)++L,++L,zt();else break;else if(B&&p===45)if(x.charCodeAt(L+1)===45&&x.charCodeAt(L+2)===62)L+=3,_t(3);else break;else if(p===60)if(x.slice(L+1,L+4)==="!--")++L,++L,++L,++L,_t(4);else break;else break}function K(p){var B,N,X,lt=0;for(N=p==="u"?4:2,B=0;B<N;++B)if(L<U&&j(x[L]))X=x[L++],lt=lt*16+"0123456789abcdef".indexOf(X.toLowerCase());else return"";return String.fromCharCode(lt)}function P(){var p,B;for(p=x.charCodeAt(L++),B=String.fromCharCode(p),p===92&&(x.charCodeAt(L)!==117&&Pt({},y.UnexpectedToken,"ILLEGAL"),++L,p=K("u"),(!p||p==="\\"||!D(p.charCodeAt(0)))&&Pt({},y.UnexpectedToken,"ILLEGAL"),B=p);L<U&&(p=x.charCodeAt(L),!!H(p));)++L,B+=String.fromCharCode(p),p===92&&(B=B.substr(0,B.length-1),x.charCodeAt(L)!==117&&Pt({},y.UnexpectedToken,"ILLEGAL"),++L,p=K("u"),(!p||p==="\\"||!H(p.charCodeAt(0)))&&Pt({},y.UnexpectedToken,"ILLEGAL"),B+=p);return B}function a(){var p,B;for(p=L++;L<U;){if(B=x.charCodeAt(L),B===92)return L=p,P();if(H(B))++L;else break}return x.slice(p,L)}function q(){var p,B,N;return p=L,B=x.charCodeAt(L)===92?P():a(),B.length===1?N=g.Identifier:ft(B)?N=g.Keyword:B==="null"?N=g.NullLiteral:B==="true"||B==="false"?N=g.BooleanLiteral:N=g.Identifier,{type:N,value:B,lineNumber:I,lineStart:v,start:p,end:L}}function u(){var p=L,B=x.charCodeAt(L),N,X=x[L],lt,Ct,Gt;switch(B){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++L,r.tokenize&&(B===40?r.openParenToken=r.tokens.length:B===123&&(r.openCurlyToken=r.tokens.length)),{type:g.Punctuator,value:String.fromCharCode(B),lineNumber:I,lineStart:v,start:p,end:L};default:if(N=x.charCodeAt(L+1),N===61)switch(B){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return L+=2,{type:g.Punctuator,value:String.fromCharCode(B)+String.fromCharCode(N),lineNumber:I,lineStart:v,start:p,end:L};case 33:case 61:return L+=2,x.charCodeAt(L)===61&&++L,{type:g.Punctuator,value:x.slice(p,L),lineNumber:I,lineStart:v,start:p,end:L}}}if(Gt=x.substr(L,4),Gt===">>>=")return L+=4,{type:g.Punctuator,value:Gt,lineNumber:I,lineStart:v,start:p,end:L};if(Ct=Gt.substr(0,3),Ct===">>>"||Ct==="<<="||Ct===">>=")return L+=3,{type:g.Punctuator,value:Ct,lineNumber:I,lineStart:v,start:p,end:L};if(lt=Ct.substr(0,2),X===lt[1]&&"+-<>&|".indexOf(X)>=0||lt==="=>")return L+=2,{type:g.Punctuator,value:lt,lineNumber:I,lineStart:v,start:p,end:L};if("<>=!+-*%&|^/".indexOf(X)>=0)return++L,{type:g.Punctuator,value:X,lineNumber:I,lineStart:v,start:p,end:L};Pt({},y.UnexpectedToken,"ILLEGAL")}function W(p){for(var B="";L<U&&j(x[L]);)B+=x[L++];return B.length===0&&Pt({},y.UnexpectedToken,"ILLEGAL"),D(x.charCodeAt(L))&&Pt({},y.UnexpectedToken,"ILLEGAL"),{type:g.NumericLiteral,value:parseInt("0x"+B,16),lineNumber:I,lineStart:v,start:p,end:L}}function z(p){for(var B="0"+x[L++];L<U&&T(x[L]);)B+=x[L++];return(D(x.charCodeAt(L))||R(x.charCodeAt(L)))&&Pt({},y.UnexpectedToken,"ILLEGAL"),{type:g.NumericLiteral,value:parseInt(B,8),octal:!0,lineNumber:I,lineStart:v,start:p,end:L}}function b(){var p,B,N;if(N=x[L],h(R(N.charCodeAt(0))||N===".","Numeric literal must start with a decimal digit or a decimal point"),B=L,p="",N!=="."){if(p=x[L++],N=x[L],p==="0"){if(N==="x"||N==="X")return++L,W(B);if(T(N))return z(B);N&&R(N.charCodeAt(0))&&Pt({},y.UnexpectedToken,"ILLEGAL")}for(;R(x.charCodeAt(L));)p+=x[L++];N=x[L]}if(N==="."){for(p+=x[L++];R(x.charCodeAt(L));)p+=x[L++];N=x[L]}if(N==="e"||N==="E")if(p+=x[L++],N=x[L],(N==="+"||N==="-")&&(p+=x[L++]),R(x.charCodeAt(L)))for(;R(x.charCodeAt(L));)p+=x[L++];else Pt({},y.UnexpectedToken,"ILLEGAL");return D(x.charCodeAt(L))&&Pt({},y.UnexpectedToken,"ILLEGAL"),{type:g.NumericLiteral,value:parseFloat(p),lineNumber:I,lineStart:v,start:B,end:L}}function at(){var p="",B,N,X,lt,Ct,Gt,Xt=!1,ae,ie;for(ae=I,ie=v,B=x[L],h(B==="'"||B==='"',"String literal must starts with a quote"),N=L,++L;L<U;)if(X=x[L++],X===B){B="";break}else if(X==="\\")if(X=x[L++],!X||!A(X.charCodeAt(0)))switch(X){case"u":case"x":Gt=L,Ct=K(X),Ct?p+=Ct:(L=Gt,p+=X);break;case"n":p+=`
|
|
182
|
-
`;break;case"r":p+="\r";break;case"t":p+=" ";break;case"b":p+="\b";break;case"f":p+="\f";break;case"v":p+="\v";break;default:T(X)?(lt="01234567".indexOf(X),lt!==0&&(Xt=!0),L<U&&T(x[L])&&(Xt=!0,lt=lt*8+"01234567".indexOf(x[L++]),"0123".indexOf(X)>=0&&L<U&&T(x[L])&&(lt=lt*8+"01234567".indexOf(x[L++]))),p+=String.fromCharCode(lt)):p+=X;break}else++I,X==="\r"&&x[L]===`
|
|
183
|
-
`&&++L,v=L;else{if(A(X.charCodeAt(0)))break;p+=X}return B!==""&&Pt({},y.UnexpectedToken,"ILLEGAL"),{type:g.StringLiteral,value:p,octal:Xt,startLineNumber:ae,startLineStart:ie,lineNumber:I,lineStart:v,start:N,end:L}}function At(p,B){var N;try{N=new RegExp(p,B)}catch{Pt({},y.InvalidRegExp)}return N}function Lt(){var p,B,N,X,lt;for(p=x[L],h(p==="/","Regular expression literal must start with a slash"),B=x[L++],N=!1,X=!1;L<U;)if(p=x[L++],B+=p,p==="\\")p=x[L++],A(p.charCodeAt(0))&&Pt({},y.UnterminatedRegExp),B+=p;else if(A(p.charCodeAt(0)))Pt({},y.UnterminatedRegExp);else if(N)p==="]"&&(N=!1);else if(p==="/"){X=!0;break}else p==="["&&(N=!0);return X||Pt({},y.UnterminatedRegExp),lt=B.substr(1,B.length-2),{value:lt,literal:B}}function yt(){var p,B,N,X;for(B="",N="";L<U&&(p=x[L],!!H(p.charCodeAt(0)));)if(++L,p==="\\"&&L<U)if(p=x[L],p==="u"){if(++L,X=L,p=K("u"),p)for(N+=p,B+="\\u";X<L;++X)B+=x[X];else L=X,N+="u",B+="\\u";Mt({},y.UnexpectedToken,"ILLEGAL")}else B+="\\",Mt({},y.UnexpectedToken,"ILLEGAL");else N+=p,B+=p;return{value:N,literal:B}}function It(){var p,B,N,X;return S=null,G(),p=L,B=Lt(),N=yt(),X=At(B.value,N.value),r.tokenize?{type:g.RegularExpression,value:X,lineNumber:I,lineStart:v,start:p,end:L}:{literal:B.literal+N.literal,value:X,start:p,end:L}}function mt(){var p,B,N,X;return G(),p=L,B={start:{line:I,column:L-v}},N=It(),B.end={line:I,column:L-v},r.tokenize||(r.tokens.length>0&&(X=r.tokens[r.tokens.length-1],X.range[0]===p&&X.type==="Punctuator"&&(X.value==="/"||X.value==="/=")&&r.tokens.pop()),r.tokens.push({type:"RegularExpression",value:N.literal,range:[p,L],loc:B})),N}function Ot(p){return p.type===g.Identifier||p.type===g.Keyword||p.type===g.BooleanLiteral||p.type===g.NullLiteral}function jt(){var p,B;if(p=r.tokens[r.tokens.length-1],!p)return mt();if(p.type==="Punctuator"){if(p.value==="]")return u();if(p.value===")")return B=r.tokens[r.openParenToken-1],B&&B.type==="Keyword"&&(B.value==="if"||B.value==="while"||B.value==="for"||B.value==="with")?mt():u();if(p.value==="}"){if(r.tokens[r.openCurlyToken-3]&&r.tokens[r.openCurlyToken-3].type==="Keyword"){if(B=r.tokens[r.openCurlyToken-4],!B)return u()}else if(r.tokens[r.openCurlyToken-4]&&r.tokens[r.openCurlyToken-4].type==="Keyword"){if(B=r.tokens[r.openCurlyToken-5],!B)return mt()}else return u();return C.indexOf(B.value)>=0?u():mt()}return mt()}return p.type==="Keyword"?mt():u()}function Et(){var p;return G(),L>=U?{type:g.EOF,lineNumber:I,lineStart:v,start:L,end:L}:(p=x.charCodeAt(L),D(p)?q():p===40||p===41||p===59?u():p===39||p===34?at():p===46?R(x.charCodeAt(L+1))?b():u():R(p)?b():r.tokenize&&p===47?jt():u())}function bt(){var p,B,N;return G(),p={start:{line:I,column:L-v}},B=Et(),p.end={line:I,column:L-v},B.type!==g.EOF&&(N=x.slice(B.start,B.end),r.tokens.push({type:d[B.type],value:N,range:[B.start,B.end],loc:p})),B}function pt(){var p;return p=S,L=p.end,I=p.lineNumber,v=p.lineStart,S=typeof r.tokens<"u"?bt():Et(),L=p.end,I=p.lineNumber,v=p.lineStart,p}function $t(){var p,B,N;p=L,B=I,N=v,S=typeof r.tokens<"u"?bt():Et(),L=p,I=B,v=N}function Jt(p,B){this.line=p,this.column=B}function re(p,B,N,X){this.start=new Jt(p,B),this.end=new Jt(N,X)}m={name:"SyntaxTree",processComment:function(p){var B,N;if(!(p.type===l.Program&&p.body.length>0)){for(r.trailingComments.length>0?r.trailingComments[0].range[0]>=p.range[1]?(N=r.trailingComments,r.trailingComments=[]):r.trailingComments.length=0:r.bottomRightStack.length>0&&r.bottomRightStack[r.bottomRightStack.length-1].trailingComments&&r.bottomRightStack[r.bottomRightStack.length-1].trailingComments[0].range[0]>=p.range[1]&&(N=r.bottomRightStack[r.bottomRightStack.length-1].trailingComments,delete r.bottomRightStack[r.bottomRightStack.length-1].trailingComments);r.bottomRightStack.length>0&&r.bottomRightStack[r.bottomRightStack.length-1].range[0]>=p.range[0];)B=r.bottomRightStack.pop();B?B.leadingComments&&B.leadingComments[B.leadingComments.length-1].range[1]<=p.range[0]&&(p.leadingComments=B.leadingComments,delete B.leadingComments):r.leadingComments.length>0&&r.leadingComments[r.leadingComments.length-1].range[1]<=p.range[0]&&(p.leadingComments=r.leadingComments,r.leadingComments=[]),N&&(p.trailingComments=N),r.bottomRightStack.push(p)}},markEnd:function(p,B){return r.range&&(p.range=[B.start,L]),r.loc&&(p.loc=new re(B.startLineNumber===void 0?B.lineNumber:B.startLineNumber,B.start-(B.startLineStart===void 0?B.lineStart:B.startLineStart),I,L-v),this.postProcess(p)),r.attachComment&&this.processComment(p),p},postProcess:function(p){return r.source&&(p.loc.source=r.source),p},createArrayExpression:function(p){return{type:l.ArrayExpression,elements:p}},createAssignmentExpression:function(p,B,N){return{type:l.AssignmentExpression,operator:p,left:B,right:N}},createBinaryExpression:function(p,B,N){var X=p==="||"||p==="&&"?l.LogicalExpression:l.BinaryExpression;return{type:X,operator:p,left:B,right:N}},createBlockStatement:function(p){return{type:l.BlockStatement,body:p}},createBreakStatement:function(p){return{type:l.BreakStatement,label:p}},createCallExpression:function(p,B){return{type:l.CallExpression,callee:p,arguments:B}},createCatchClause:function(p,B){return{type:l.CatchClause,param:p,body:B}},createConditionalExpression:function(p,B,N){return{type:l.ConditionalExpression,test:p,consequent:B,alternate:N}},createContinueStatement:function(p){return{type:l.ContinueStatement,label:p}},createDebuggerStatement:function(){return{type:l.DebuggerStatement}},createDoWhileStatement:function(p,B){return{type:l.DoWhileStatement,body:p,test:B}},createEmptyStatement:function(){return{type:l.EmptyStatement}},createExpressionStatement:function(p){return{type:l.ExpressionStatement,expression:p}},createForStatement:function(p,B,N,X){return{type:l.ForStatement,init:p,test:B,update:N,body:X}},createForInStatement:function(p,B,N){return{type:l.ForInStatement,left:p,right:B,body:N,each:!1}},createFunctionDeclaration:function(p,B,N,X){return{type:l.FunctionDeclaration,id:p,params:B,defaults:N,body:X,rest:null,generator:!1,expression:!1}},createFunctionExpression:function(p,B,N,X){return{type:l.FunctionExpression,id:p,params:B,defaults:N,body:X,rest:null,generator:!1,expression:!1}},createIdentifier:function(p){return{type:l.Identifier,name:p}},createIfStatement:function(p,B,N){return{type:l.IfStatement,test:p,consequent:B,alternate:N}},createLabeledStatement:function(p,B){return{type:l.LabeledStatement,label:p,body:B}},createLiteral:function(p){return{type:l.Literal,value:p.value,raw:x.slice(p.start,p.end)}},createMemberExpression:function(p,B,N){return{type:l.MemberExpression,computed:p==="[",object:B,property:N}},createNewExpression:function(p,B){return{type:l.NewExpression,callee:p,arguments:B}},createObjectExpression:function(p){return{type:l.ObjectExpression,properties:p}},createPostfixExpression:function(p,B){return{type:l.UpdateExpression,operator:p,argument:B,prefix:!1}},createProgram:function(p){return{type:l.Program,body:p}},createProperty:function(p,B,N){return{type:l.Property,key:B,value:N,kind:p}},createReturnStatement:function(p){return{type:l.ReturnStatement,argument:p}},createSequenceExpression:function(p){return{type:l.SequenceExpression,expressions:p}},createSwitchCase:function(p,B){return{type:l.SwitchCase,test:p,consequent:B}},createSwitchStatement:function(p,B){return{type:l.SwitchStatement,discriminant:p,cases:B}},createThisExpression:function(){return{type:l.ThisExpression}},createThrowStatement:function(p){return{type:l.ThrowStatement,argument:p}},createTryStatement:function(p,B,N,X){return{type:l.TryStatement,block:p,guardedHandlers:B,handlers:N,finalizer:X}},createUnaryExpression:function(p,B){return p==="++"||p==="--"?{type:l.UpdateExpression,operator:p,argument:B,prefix:!0}:{type:l.UnaryExpression,operator:p,argument:B,prefix:!0}},createVariableDeclaration:function(p,B){return{type:l.VariableDeclaration,declarations:p,kind:B}},createVariableDeclarator:function(p,B){return{type:l.VariableDeclarator,id:p,init:B}},createWhileStatement:function(p,B){return{type:l.WhileStatement,test:p,body:B}},createWithStatement:function(p,B){return{type:l.WithStatement,object:p,body:B}}};function te(){var p,B,N,X;return p=L,B=I,N=v,G(),X=I!==B,L=p,I=B,v=N,X}function Pt(p,B){var N,X=Array.prototype.slice.call(arguments,2),lt=B.replace(/%(\d)/g,function(Ct,Gt){return h(Gt<X.length,"Message reference must be in range"),X[Gt]});throw typeof p.lineNumber=="number"?(N=new Error("Line "+p.lineNumber+": "+lt),N.index=p.start,N.lineNumber=p.lineNumber,N.column=p.start-v+1):(N=new Error("Line "+I+": "+lt),N.index=L,N.lineNumber=I,N.column=L-v+1),N.description=lt,N}function Mt(){try{Pt.apply(null,arguments)}catch(p){if(r.errors)r.errors.push(p);else throw p}}function Zt(p){if(p.type===g.EOF&&Pt(p,y.UnexpectedEOS),p.type===g.NumericLiteral&&Pt(p,y.UnexpectedNumber),p.type===g.StringLiteral&&Pt(p,y.UnexpectedString),p.type===g.Identifier&&Pt(p,y.UnexpectedIdentifier),p.type===g.Keyword){if(ut(p.value))Pt(p,y.UnexpectedReserved);else if(O&&nt(p.value)){Mt(p,y.StrictReservedWord);return}Pt(p,y.UnexpectedToken,p.value)}Pt(p,y.UnexpectedToken,p.value)}function vt(p){var B=pt();(B.type!==g.Punctuator||B.value!==p)&&Zt(B)}function Wt(p){var B=pt();(B.type!==g.Keyword||B.value!==p)&&Zt(B)}function wt(p){return S.type===g.Punctuator&&S.value===p}function Y(p){return S.type===g.Keyword&&S.value===p}function f(){var p;return S.type!==g.Punctuator?!1:(p=S.value,p==="="||p==="*="||p==="/="||p==="%="||p==="+="||p==="-="||p==="<<="||p===">>="||p===">>>="||p==="&="||p==="^="||p==="|=")}function _(){var p;if(x.charCodeAt(L)===59||wt(";")){pt();return}p=I,G(),I===p&&S.type!==g.EOF&&!wt("}")&&Zt(S)}function Z(p){return p.type===l.Identifier||p.type===l.MemberExpression}function Q(){var p=[],B;for(B=S,vt("[");!wt("]");)wt(",")?(pt(),p.push(null)):(p.push(dt()),wt("]")||vt(","));return pt(),w.markEnd(w.createArrayExpression(p),B)}function $(p,B){var N,X,lt;return N=O,lt=S,X=_n(),B&&O&&J(p[0].name)&&Mt(B,y.StrictParamName),O=N,w.markEnd(w.createFunctionExpression(null,p,[],X),lt)}function tt(){var p,B;return B=S,p=pt(),p.type===g.StringLiteral||p.type===g.NumericLiteral?(O&&p.octal&&Mt(p,y.StrictOctalLiteral),w.markEnd(w.createLiteral(p),B)):w.markEnd(w.createIdentifier(p.value),B)}function V(){var p,B,N,X,lt,Ct;if(p=S,Ct=S,p.type===g.Identifier)return N=tt(),p.value==="get"&&!wt(":")?(B=tt(),vt("("),vt(")"),X=$([]),w.markEnd(w.createProperty("get",B,X),Ct)):p.value==="set"&&!wt(":")?(B=tt(),vt("("),p=S,p.type!==g.Identifier?(vt(")"),Mt(p,y.UnexpectedToken,p.value),X=$([])):(lt=[Kt()],vt(")"),X=$(lt,p)),w.markEnd(w.createProperty("set",B,X),Ct)):(vt(":"),X=dt(),w.markEnd(w.createProperty("init",N,X),Ct));if(p.type===g.EOF||p.type===g.Punctuator)Zt(p);else return B=tt(),vt(":"),X=dt(),w.markEnd(w.createProperty("init",B,X),Ct)}function ct(){var p=[],B,N,X,lt,Ct={},Gt=String,Xt;for(Xt=S,vt("{");!wt("}");)B=V(),B.key.type===l.Identifier?N=B.key.name:N=Gt(B.key.value),lt=B.kind==="init"?o.Data:B.kind==="get"?o.Get:o.Set,X="$"+N,Object.prototype.hasOwnProperty.call(Ct,X)?(Ct[X]===o.Data?O&<===o.Data?Mt({},y.StrictDuplicateProperty):lt!==o.Data&&Mt({},y.AccessorDataProperty):lt===o.Data?Mt({},y.AccessorDataProperty):Ct[X]<&&Mt({},y.AccessorGetSet),Ct[X]|=lt):Ct[X]=lt,p.push(B),wt("}")||vt(",");return vt("}"),w.markEnd(w.createObjectExpression(p),Xt)}function st(){var p;return vt("("),p=qt(),vt(")"),p}function rt(){var p,B,N,X;if(wt("("))return st();if(wt("["))return Q();if(wt("{"))return ct();if(p=S.type,X=S,p===g.Identifier)N=w.createIdentifier(pt().value);else if(p===g.StringLiteral||p===g.NumericLiteral)O&&S.octal&&Mt(S,y.StrictOctalLiteral),N=w.createLiteral(pt());else if(p===g.Keyword){if(Y("function"))return ao();Y("this")?(pt(),N=w.createThisExpression()):Zt(pt())}else p===g.BooleanLiteral?(B=pt(),B.value=B.value==="true",N=w.createLiteral(B)):p===g.NullLiteral?(B=pt(),B.value=null,N=w.createLiteral(B)):wt("/")||wt("/=")?(typeof r.tokens<"u"?N=w.createLiteral(mt()):N=w.createLiteral(It()),$t()):Zt(pt());return w.markEnd(N,X)}function ot(){var p=[];if(vt("("),!wt(")"))for(;L<U&&(p.push(dt()),!wt(")"));)vt(",");return vt(")"),p}function gt(){var p,B;return B=S,p=pt(),Ot(p)||Zt(p),w.markEnd(w.createIdentifier(p.value),B)}function Bt(){return vt("."),gt()}function Ft(){var p;return vt("["),p=qt(),vt("]"),p}function ht(){var p,B,N;return N=S,Wt("new"),p=Tt(),B=wt("(")?ot():[],w.markEnd(w.createNewExpression(p,B),N)}function xt(){var p,B,N,X,lt;for(lt=S,p=F.allowIn,F.allowIn=!0,B=Y("new")?ht():rt(),F.allowIn=p;;){if(wt("."))X=Bt(),B=w.createMemberExpression(".",B,X);else if(wt("("))N=ot(),B=w.createCallExpression(B,N);else if(wt("["))X=Ft(),B=w.createMemberExpression("[",B,X);else break;w.markEnd(B,lt)}return B}function Tt(){var p,B,N,X;for(X=S,p=F.allowIn,B=Y("new")?ht():rt(),F.allowIn=p;wt(".")||wt("[");)wt("[")?(N=Ft(),B=w.createMemberExpression("[",B,N)):(N=Bt(),B=w.createMemberExpression(".",B,N)),w.markEnd(B,X);return B}function Ut(){var p,B,N=S;return p=xt(),S.type===g.Punctuator&&(wt("++")||wt("--"))&&!te()&&(O&&p.type===l.Identifier&&J(p.name)&&Mt({},y.StrictLHSPostfix),Z(p)||Mt({},y.InvalidLHSInAssignment),B=pt(),p=w.markEnd(w.createPostfixExpression(B.value,p),N)),p}function St(){var p,B,N;return S.type!==g.Punctuator&&S.type!==g.Keyword?B=Ut():wt("++")||wt("--")?(N=S,p=pt(),B=St(),O&&B.type===l.Identifier&&J(B.name)&&Mt({},y.StrictLHSPrefix),Z(B)||Mt({},y.InvalidLHSInAssignment),B=w.createUnaryExpression(p.value,B),B=w.markEnd(B,N)):wt("+")||wt("-")||wt("~")||wt("!")?(N=S,p=pt(),B=St(),B=w.createUnaryExpression(p.value,B),B=w.markEnd(B,N)):Y("delete")||Y("void")||Y("typeof")?(N=S,p=pt(),B=St(),B=w.createUnaryExpression(p.value,B),B=w.markEnd(B,N),O&&B.operator==="delete"&&B.argument.type===l.Identifier&&Mt({},y.StrictDelete)):B=Ut(),B}function kt(p,B){var N=0;if(p.type!==g.Punctuator&&p.type!==g.Keyword)return 0;switch(p.value){case"||":N=1;break;case"&&":N=2;break;case"|":N=3;break;case"^":N=4;break;case"&":N=5;break;case"==":case"!=":case"===":case"!==":N=6;break;case"<":case">":case"<=":case">=":case"instanceof":N=7;break;case"in":N=B?7:0;break;case"<<":case">>":case">>>":N=8;break;case"+":case"-":N=9;break;case"*":case"/":case"%":N=11;break}return N}function k(){var p,B,N,X,lt,Ct,Gt,Xt,ae,ie;if(p=S,ae=St(),X=S,lt=kt(X,F.allowIn),lt===0)return ae;for(X.prec=lt,pt(),B=[p,S],Gt=St(),Ct=[ae,X,Gt];(lt=kt(S,F.allowIn))>0;){for(;Ct.length>2&<<=Ct[Ct.length-2].prec;)Gt=Ct.pop(),Xt=Ct.pop().value,ae=Ct.pop(),N=w.createBinaryExpression(Xt,ae,Gt),B.pop(),p=B[B.length-1],w.markEnd(N,p),Ct.push(N);X=pt(),X.prec=lt,Ct.push(X),B.push(S),N=St(),Ct.push(N)}for(ie=Ct.length-1,N=Ct[ie],B.pop();ie>1;)N=w.createBinaryExpression(Ct[ie-1].value,Ct[ie-2],N),ie-=2,p=B.pop(),w.markEnd(N,p);return N}function et(){var p,B,N,X,lt;return lt=S,p=k(),wt("?")&&(pt(),B=F.allowIn,F.allowIn=!0,N=dt(),F.allowIn=B,vt(":"),X=dt(),p=w.createConditionalExpression(p,N,X),w.markEnd(p,lt)),p}function dt(){var p,B,N,X,lt;return p=S,lt=S,X=B=et(),f()&&(Z(B)||Mt({},y.InvalidLHSInAssignment),O&&B.type===l.Identifier&&J(B.name)&&Mt(p,y.StrictLHSAssignment),p=pt(),N=dt(),X=w.markEnd(w.createAssignmentExpression(p.value,B,N),lt)),X}function qt(){var p,B=S;if(p=dt(),wt(",")){for(p=w.createSequenceExpression([p]);L<U&&wt(",");)pt(),p.expressions.push(dt());w.markEnd(p,B)}return p}function Ht(){for(var p=[],B;L<U&&!(wt("}")||(B=qe(),typeof B>"u"));)p.push(B);return p}function Qt(){var p,B;return B=S,vt("{"),p=Ht(),vt("}"),w.markEnd(w.createBlockStatement(p),B)}function Kt(){var p,B;return B=S,p=pt(),p.type!==g.Identifier&&Zt(p),w.markEnd(w.createIdentifier(p.value),B)}function fe(p){var B=null,N,X;return X=S,N=Kt(),O&&J(N.name)&&Mt({},y.StrictVarName),p==="const"?(vt("="),B=dt()):wt("=")&&(pt(),B=dt()),w.markEnd(w.createVariableDeclarator(N,B),X)}function Ce(p){var B=[];do{if(B.push(fe(p)),!wt(","))break;pt()}while(L<U);return B}function Te(){var p;return Wt("var"),p=Ce(),_(),w.createVariableDeclaration(p,"var")}function fn(p){var B,N;return N=S,Wt(p),B=Ce(p),_(),w.markEnd(w.createVariableDeclaration(B,p),N)}function xe(){return vt(";"),w.createEmptyStatement()}function Ae(){var p=qt();return _(),w.createExpressionStatement(p)}function Qe(){var p,B,N;return Wt("if"),vt("("),p=qt(),vt(")"),B=_e(),Y("else")?(pt(),N=_e()):N=null,w.createIfStatement(p,B,N)}function Ga(){var p,B,N;return Wt("do"),N=F.inIteration,F.inIteration=!0,p=_e(),F.inIteration=N,Wt("while"),vt("("),B=qt(),vt(")"),wt(";")&&pt(),w.createDoWhileStatement(p,B)}function Za(){var p,B,N;return Wt("while"),vt("("),p=qt(),vt(")"),N=F.inIteration,F.inIteration=!0,B=_e(),F.inIteration=N,w.createWhileStatement(p,B)}function Wa(){var p,B,N;return N=S,p=pt(),B=Ce(),w.markEnd(w.createVariableDeclaration(B,p.value),N)}function Xa(){var p,B,N,X,lt,Ct,Gt;return p=B=N=null,Wt("for"),vt("("),wt(";")?pt():(Y("var")||Y("let")?(F.allowIn=!1,p=Wa(),F.allowIn=!0,p.declarations.length===1&&Y("in")&&(pt(),X=p,lt=qt(),p=null)):(F.allowIn=!1,p=qt(),F.allowIn=!0,Y("in")&&(Z(p)||Mt({},y.InvalidLHSInForIn),pt(),X=p,lt=qt(),p=null)),typeof X>"u"&&vt(";")),typeof X>"u"&&(wt(";")||(B=qt()),vt(";"),wt(")")||(N=qt())),vt(")"),Gt=F.inIteration,F.inIteration=!0,Ct=_e(),F.inIteration=Gt,typeof X>"u"?w.createForStatement(p,B,N,Ct):w.createForInStatement(X,lt,Ct)}function Va(){var p=null,B;return Wt("continue"),x.charCodeAt(L)===59?(pt(),F.inIteration||Pt({},y.IllegalContinue),w.createContinueStatement(null)):te()?(F.inIteration||Pt({},y.IllegalContinue),w.createContinueStatement(null)):(S.type===g.Identifier&&(p=Kt(),B="$"+p.name,Object.prototype.hasOwnProperty.call(F.labelSet,B)||Pt({},y.UnknownLabel,p.name)),_(),p===null&&!F.inIteration&&Pt({},y.IllegalContinue),w.createContinueStatement(p))}function Ha(){var p=null,B;return Wt("break"),x.charCodeAt(L)===59?(pt(),F.inIteration||F.inSwitch||Pt({},y.IllegalBreak),w.createBreakStatement(null)):te()?(F.inIteration||F.inSwitch||Pt({},y.IllegalBreak),w.createBreakStatement(null)):(S.type===g.Identifier&&(p=Kt(),B="$"+p.name,Object.prototype.hasOwnProperty.call(F.labelSet,B)||Pt({},y.UnknownLabel,p.name)),_(),p===null&&!(F.inIteration||F.inSwitch)&&Pt({},y.IllegalBreak),w.createBreakStatement(p))}function Qa(){var p=null;return Wt("return"),F.inFunctionBody||Mt({},y.IllegalReturn),x.charCodeAt(L)===32&&D(x.charCodeAt(L+1))?(p=qt(),_(),w.createReturnStatement(p)):te()?w.createReturnStatement(null):(wt(";")||!wt("}")&&S.type!==g.EOF&&(p=qt()),_(),w.createReturnStatement(p))}function Ja(){var p,B;return O&&(G(),Mt({},y.StrictModeWith)),Wt("with"),vt("("),p=qt(),vt(")"),B=_e(),w.createWithStatement(p,B)}function Ka(){var p,B=[],N,X;for(X=S,Y("default")?(pt(),p=null):(Wt("case"),p=qt()),vt(":");L<U&&!(wt("}")||Y("default")||Y("case"));)N=_e(),B.push(N);return w.markEnd(w.createSwitchCase(p,B),X)}function Ya(){var p,B,N,X,lt;if(Wt("switch"),vt("("),p=qt(),vt(")"),vt("{"),B=[],wt("}"))return pt(),w.createSwitchStatement(p,B);for(X=F.inSwitch,F.inSwitch=!0,lt=!1;L<U&&!wt("}");)N=Ka(),N.test===null&&(lt&&Pt({},y.MultipleDefaultsInSwitch),lt=!0),B.push(N);return F.inSwitch=X,vt("}"),w.createSwitchStatement(p,B)}function to(){var p;return Wt("throw"),te()&&Pt({},y.NewlineAfterThrow),p=qt(),_(),w.createThrowStatement(p)}function eo(){var p,B,N;return N=S,Wt("catch"),vt("("),wt(")")&&Zt(S),p=Kt(),O&&J(p.name)&&Mt({},y.StrictCatchVariable),vt(")"),B=Qt(),w.markEnd(w.createCatchClause(p,B),N)}function no(){var p,B=[],N=null;return Wt("try"),p=Qt(),Y("catch")&&B.push(eo()),Y("finally")&&(pt(),N=Qt()),B.length===0&&!N&&Pt({},y.NoCatchOrFinally),w.createTryStatement(p,[],B,N)}function io(){return Wt("debugger"),_(),w.createDebuggerStatement()}function _e(){var p=S.type,B,N,X,lt;if(p===g.EOF&&Zt(S),p===g.Punctuator&&S.value==="{")return Qt();if(lt=S,p===g.Punctuator)switch(S.value){case";":return w.markEnd(xe(),lt);case"(":return w.markEnd(Ae(),lt)}if(p===g.Keyword)switch(S.value){case"break":return w.markEnd(Ha(),lt);case"continue":return w.markEnd(Va(),lt);case"debugger":return w.markEnd(io(),lt);case"do":return w.markEnd(Ga(),lt);case"for":return w.markEnd(Xa(),lt);case"function":return w.markEnd(ei(),lt);case"if":return w.markEnd(Qe(),lt);case"return":return w.markEnd(Qa(),lt);case"switch":return w.markEnd(Ya(),lt);case"throw":return w.markEnd(to(),lt);case"try":return w.markEnd(no(),lt);case"var":return w.markEnd(Te(),lt);case"while":return w.markEnd(Za(),lt);case"with":return w.markEnd(Ja(),lt)}return B=qt(),B.type===l.Identifier&&wt(":")?(pt(),X="$"+B.name,Object.prototype.hasOwnProperty.call(F.labelSet,X)&&Pt({},y.Redeclaration,"Label",B.name),F.labelSet[X]=!0,N=_e(),delete F.labelSet[X],w.markEnd(w.createLabeledStatement(B,N),lt)):(_(),w.markEnd(w.createExpressionStatement(B),lt))}function _n(){var p,B=[],N,X,lt,Ct,Gt,Xt,ae,ie;for(ie=S,vt("{");L<U&&!(S.type!==g.StringLiteral||(N=S,p=qe(),B.push(p),p.expression.type!==l.Literal));)X=x.slice(N.start+1,N.end-1),X==="use strict"?(O=!0,lt&&Mt(lt,y.StrictOctalLiteral)):!lt&&N.octal&&(lt=N);for(Ct=F.labelSet,Gt=F.inIteration,Xt=F.inSwitch,ae=F.inFunctionBody,F.labelSet={},F.inIteration=!1,F.inSwitch=!1,F.inFunctionBody=!0;L<U&&!(wt("}")||(p=qe(),typeof p>"u"));)B.push(p);return vt("}"),F.labelSet=Ct,F.inIteration=Gt,F.inSwitch=Xt,F.inFunctionBody=ae,w.markEnd(w.createBlockStatement(B),ie)}function ti(p){var B,N=[],X,lt,Ct,Gt,Xt;if(vt("("),!wt(")"))for(Ct={};L<U&&(X=S,B=Kt(),Gt="$"+X.value,O?(J(X.value)&&(lt=X,Xt=y.StrictParamName),Object.prototype.hasOwnProperty.call(Ct,Gt)&&(lt=X,Xt=y.StrictParamDupe)):p||(J(X.value)?(p=X,Xt=y.StrictParamName):nt(X.value)?(p=X,Xt=y.StrictReservedWord):Object.prototype.hasOwnProperty.call(Ct,Gt)&&(p=X,Xt=y.StrictParamDupe)),N.push(B),Ct[Gt]=!0,!wt(")"));)vt(",");return vt(")"),{params:N,stricted:lt,firstRestricted:p,message:Xt}}function ei(){var p,B=[],N,X,lt,Ct,Gt,Xt,ae,ie;return ie=S,Wt("function"),X=S,p=Kt(),O?J(X.value)&&Mt(X,y.StrictFunctionName):J(X.value)?(Gt=X,Xt=y.StrictFunctionName):nt(X.value)&&(Gt=X,Xt=y.StrictReservedWord),Ct=ti(Gt),B=Ct.params,lt=Ct.stricted,Gt=Ct.firstRestricted,Ct.message&&(Xt=Ct.message),ae=O,N=_n(),O&&Gt&&Pt(Gt,Xt),O&<&&Mt(lt,Xt),O=ae,w.markEnd(w.createFunctionDeclaration(p,B,[],N),ie)}function ao(){var p,B=null,N,X,lt,Ct,Gt=[],Xt,ae,ie;return ie=S,Wt("function"),wt("(")||(p=S,B=Kt(),O?J(p.value)&&Mt(p,y.StrictFunctionName):J(p.value)?(X=p,lt=y.StrictFunctionName):nt(p.value)&&(X=p,lt=y.StrictReservedWord)),Ct=ti(X),Gt=Ct.params,N=Ct.stricted,X=Ct.firstRestricted,Ct.message&&(lt=Ct.message),ae=O,Xt=_n(),O&&X&&Pt(X,lt),O&&N&&Mt(N,lt),O=ae,w.markEnd(w.createFunctionExpression(B,Gt,[],Xt),ie)}function qe(){if(S.type===g.Keyword)switch(S.value){case"const":case"let":return fn(S.value);case"function":return ei();default:return _e()}if(S.type!==g.EOF)return _e()}function oo(){for(var p,B=[],N,X,lt;L<U&&(N=S,!(N.type!==g.StringLiteral||(p=qe(),B.push(p),p.expression.type!==l.Literal)));)X=x.slice(N.start+1,N.end-1),X==="use strict"?(O=!0,lt&&Mt(lt,y.StrictOctalLiteral)):!lt&&N.octal&&(lt=N);for(;L<U&&(p=qe(),!(typeof p>"u"));)B.push(p);return B}function co(){var p,B;return G(),$t(),B=S,O=!1,p=oo(),w.markEnd(w.createProgram(p),B)}function ni(){var p,B,N,X=[];for(p=0;p<r.tokens.length;++p)B=r.tokens[p],N={type:B.type,value:B.value},r.range&&(N.range=B.range),r.loc&&(N.loc=B.loc),X.push(N);r.tokens=X}function so(p,B){var N,X,lt;N=String,typeof p!="string"&&!(p instanceof String)&&(p=N(p)),w=m,x=p,L=0,I=x.length>0?1:0,v=0,U=x.length,S=null,F={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},r={},B=B||{},B.tokens=!0,r.tokens=[],r.tokenize=!0,r.openParenToken=-1,r.openCurlyToken=-1,r.range=typeof B.range=="boolean"&&B.range,r.loc=typeof B.loc=="boolean"&&B.loc,typeof B.comment=="boolean"&&B.comment&&(r.comments=[]),typeof B.tolerant=="boolean"&&B.tolerant&&(r.errors=[]);try{if($t(),S.type===g.EOF)return r.tokens;for(X=pt();S.type!==g.EOF;)try{X=pt()}catch(Ct){if(X=S,r.errors){r.errors.push(Ct);break}else throw Ct}ni(),lt=r.tokens,typeof r.comments<"u"&&(lt.comments=r.comments),typeof r.errors<"u"&&(lt.errors=r.errors)}catch(Ct){throw Ct}finally{r={}}return lt}function ro(p,B){var N,X;X=String,typeof p!="string"&&!(p instanceof String)&&(p=X(p)),w=m,x=p,L=0,I=x.length>0?1:0,v=0,U=x.length,S=null,F={allowIn:!0,labelSet:{},inFunctionBody:!1,inIteration:!1,inSwitch:!1,lastCommentStart:-1},r={},typeof B<"u"&&(r.range=typeof B.range=="boolean"&&B.range,r.loc=typeof B.loc=="boolean"&&B.loc,r.attachComment=typeof B.attachComment=="boolean"&&B.attachComment,r.loc&&B.source!==null&&B.source!==void 0&&(r.source=X(B.source)),typeof B.tokens=="boolean"&&B.tokens&&(r.tokens=[]),typeof B.comment=="boolean"&&B.comment&&(r.comments=[]),typeof B.tolerant=="boolean"&&B.tolerant&&(r.errors=[]),r.attachComment&&(r.range=!0,r.comments=[],r.bottomRightStack=[],r.trailingComments=[],r.leadingComments=[]));try{N=co(),typeof r.comments<"u"&&(N.comments=r.comments),typeof r.tokens<"u"&&(ni(),N.tokens=r.tokens),typeof r.errors<"u"&&(N.errors=r.errors)}catch(lt){throw lt}finally{r={}}return N}s.version="1.2.2",s.tokenize=so,s.parse=ro,s.Syntax=function(){var p,B={};typeof Object.create=="function"&&(B=Object.create(null));for(p in l)l.hasOwnProperty(p)&&(B[p]=l[p]);return typeof Object.freeze=="function"&&Object.freeze(B),B}()})},{}],1:[function(e,n,i){(function(s){var g=function(){var d={trace:function(){},yy:{},symbols_:{error:2,JSON_PATH:3,DOLLAR:4,PATH_COMPONENTS:5,LEADING_CHILD_MEMBER_EXPRESSION:6,PATH_COMPONENT:7,MEMBER_COMPONENT:8,SUBSCRIPT_COMPONENT:9,CHILD_MEMBER_COMPONENT:10,DESCENDANT_MEMBER_COMPONENT:11,DOT:12,MEMBER_EXPRESSION:13,DOT_DOT:14,STAR:15,IDENTIFIER:16,SCRIPT_EXPRESSION:17,INTEGER:18,END:19,CHILD_SUBSCRIPT_COMPONENT:20,DESCENDANT_SUBSCRIPT_COMPONENT:21,"[":22,SUBSCRIPT:23,"]":24,SUBSCRIPT_EXPRESSION:25,SUBSCRIPT_EXPRESSION_LIST:26,SUBSCRIPT_EXPRESSION_LISTABLE:27,",":28,STRING_LITERAL:29,ARRAY_SLICE:30,FILTER_EXPRESSION:31,QQ_STRING:32,Q_STRING:33,$accept:0,$end:1},terminals_:{2:"error",4:"DOLLAR",12:"DOT",14:"DOT_DOT",15:"STAR",16:"IDENTIFIER",17:"SCRIPT_EXPRESSION",18:"INTEGER",19:"END",22:"[",24:"]",28:",",30:"ARRAY_SLICE",31:"FILTER_EXPRESSION",32:"QQ_STRING",33:"Q_STRING"},productions_:[0,[3,1],[3,2],[3,1],[3,2],[5,1],[5,2],[7,1],[7,1],[8,1],[8,1],[10,2],[6,1],[11,2],[13,1],[13,1],[13,1],[13,1],[13,1],[9,1],[9,1],[20,3],[21,4],[23,1],[23,1],[26,1],[26,3],[27,1],[27,1],[27,1],[25,1],[25,1],[25,1],[29,1],[29,1]],performAction:function(E,m,x,O,L,I,v){O.ast||(O.ast=C,C.initialize());var U=I.length-1;switch(L){case 1:return O.ast.set({expression:{type:"root",value:I[U]}}),O.ast.unshift(),O.ast.yield();case 2:return O.ast.set({expression:{type:"root",value:I[U-1]}}),O.ast.unshift(),O.ast.yield();case 3:return O.ast.unshift(),O.ast.yield();case 4:return O.ast.set({operation:"member",scope:"child",expression:{type:"identifier",value:I[U-1]}}),O.ast.unshift(),O.ast.yield();case 5:break;case 6:break;case 7:O.ast.set({operation:"member"}),O.ast.push();break;case 8:O.ast.set({operation:"subscript"}),O.ast.push();break;case 9:O.ast.set({scope:"child"});break;case 10:O.ast.set({scope:"descendant"});break;case 11:break;case 12:O.ast.set({scope:"child",operation:"member"});break;case 13:break;case 14:O.ast.set({expression:{type:"wildcard",value:I[U]}});break;case 15:O.ast.set({expression:{type:"identifier",value:I[U]}});break;case 16:O.ast.set({expression:{type:"script_expression",value:I[U]}});break;case 17:O.ast.set({expression:{type:"numeric_literal",value:parseInt(I[U])}});break;case 18:break;case 19:O.ast.set({scope:"child"});break;case 20:O.ast.set({scope:"descendant"});break;case 21:break;case 22:break;case 23:break;case 24:I[U].length>1?O.ast.set({expression:{type:"union",value:I[U]}}):this.$=I[U];break;case 25:this.$=[I[U]];break;case 26:this.$=I[U-2].concat(I[U]);break;case 27:this.$={expression:{type:"numeric_literal",value:parseInt(I[U])}},O.ast.set(this.$);break;case 28:this.$={expression:{type:"string_literal",value:I[U]}},O.ast.set(this.$);break;case 29:this.$={expression:{type:"slice",value:I[U]}},O.ast.set(this.$);break;case 30:this.$={expression:{type:"wildcard",value:I[U]}},O.ast.set(this.$);break;case 31:this.$={expression:{type:"script_expression",value:I[U]}},O.ast.set(this.$);break;case 32:this.$={expression:{type:"filter_expression",value:I[U]}},O.ast.set(this.$);break;case 33:this.$=I[U];break;case 34:this.$=I[U];break}},table:[{3:1,4:[1,2],6:3,13:4,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{1:[3]},{1:[2,1],5:10,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,3],5:21,7:11,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,12],12:[2,12],14:[2,12],22:[2,12]},{1:[2,14],12:[2,14],14:[2,14],22:[2,14]},{1:[2,15],12:[2,15],14:[2,15],22:[2,15]},{1:[2,16],12:[2,16],14:[2,16],22:[2,16]},{1:[2,17],12:[2,17],14:[2,17],22:[2,17]},{1:[2,18],12:[2,18],14:[2,18],22:[2,18]},{1:[2,2],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,5],12:[2,5],14:[2,5],22:[2,5]},{1:[2,7],12:[2,7],14:[2,7],22:[2,7]},{1:[2,8],12:[2,8],14:[2,8],22:[2,8]},{1:[2,9],12:[2,9],14:[2,9],22:[2,9]},{1:[2,10],12:[2,10],14:[2,10],22:[2,10]},{1:[2,19],12:[2,19],14:[2,19],22:[2,19]},{1:[2,20],12:[2,20],14:[2,20],22:[2,20]},{13:23,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9]},{13:24,15:[1,5],16:[1,6],17:[1,7],18:[1,8],19:[1,9],22:[1,25]},{15:[1,29],17:[1,30],18:[1,33],23:26,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{1:[2,4],7:22,8:12,9:13,10:14,11:15,12:[1,18],14:[1,19],20:16,21:17,22:[1,20]},{1:[2,6],12:[2,6],14:[2,6],22:[2,6]},{1:[2,11],12:[2,11],14:[2,11],22:[2,11]},{1:[2,13],12:[2,13],14:[2,13],22:[2,13]},{15:[1,29],17:[1,30],18:[1,33],23:38,25:27,26:28,27:32,29:34,30:[1,35],31:[1,31],32:[1,36],33:[1,37]},{24:[1,39]},{24:[2,23]},{24:[2,24],28:[1,40]},{24:[2,30]},{24:[2,31]},{24:[2,32]},{24:[2,25],28:[2,25]},{24:[2,27],28:[2,27]},{24:[2,28],28:[2,28]},{24:[2,29],28:[2,29]},{24:[2,33],28:[2,33]},{24:[2,34],28:[2,34]},{24:[1,41]},{1:[2,21],12:[2,21],14:[2,21],22:[2,21]},{18:[1,33],27:42,29:34,30:[1,35],32:[1,36],33:[1,37]},{1:[2,22],12:[2,22],14:[2,22],22:[2,22]},{24:[2,26],28:[2,26]}],defaultActions:{27:[2,23],29:[2,30],30:[2,31],31:[2,32]},parseError:function(E,m){if(m.recoverable)this.trace(E);else throw new Error(E)},parse:function(E){var m=this,x=[0],O=[null],L=[],I=this.table,v="",U=0,w=0,S=2,F=1,r=L.slice.call(arguments,1);this.lexer.setInput(E),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,typeof this.lexer.yylloc>"u"&&(this.lexer.yylloc={});var h=this.lexer.yylloc;L.push(h);var R=this.lexer.options&&this.lexer.options.ranges;typeof this.yy.parseError=="function"?this.parseError=this.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function j(){var _t;return _t=m.lexer.lex()||F,typeof _t!="number"&&(_t=m.symbols_[_t]||_t),_t}for(var T,M,A,D,H={},ut,nt,J,ft;;){if(M=x[x.length-1],this.defaultActions[M]?A=this.defaultActions[M]:((T===null||typeof T>"u")&&(T=j()),A=I[M]&&I[M][T]),typeof A>"u"||!A.length||!A[0]){var it="";ft=[];for(ut in I[M])this.terminals_[ut]&&ut>S&&ft.push("'"+this.terminals_[ut]+"'");this.lexer.showPosition?it="Parse error on line "+(U+1)+`:
|
|
184
|
-
`+this.lexer.showPosition()+`
|
|
185
|
-
Expecting `+ft.join(", ")+", got '"+(this.terminals_[T]||T)+"'":it="Parse error on line "+(U+1)+": Unexpected "+(T==F?"end of input":"'"+(this.terminals_[T]||T)+"'"),this.parseError(it,{text:this.lexer.match,token:this.terminals_[T]||T,line:this.lexer.yylineno,loc:h,expected:ft})}if(A[0]instanceof Array&&A.length>1)throw new Error("Parse Error: multiple actions possible at state: "+M+", token: "+T);switch(A[0]){case 1:x.push(T),O.push(this.lexer.yytext),L.push(this.lexer.yylloc),x.push(A[1]),T=null,w=this.lexer.yyleng,v=this.lexer.yytext,U=this.lexer.yylineno,h=this.lexer.yylloc;break;case 2:if(nt=this.productions_[A[1]][1],H.$=O[O.length-nt],H._$={first_line:L[L.length-(nt||1)].first_line,last_line:L[L.length-1].last_line,first_column:L[L.length-(nt||1)].first_column,last_column:L[L.length-1].last_column},R&&(H._$.range=[L[L.length-(nt||1)].range[0],L[L.length-1].range[1]]),D=this.performAction.apply(H,[v,w,U,this.yy,A[1],O,L].concat(r)),typeof D<"u")return D;nt&&(x=x.slice(0,-1*nt*2),O=O.slice(0,-1*nt),L=L.slice(0,-1*nt)),x.push(this.productions_[A[1]][0]),O.push(H.$),L.push(H._$),J=I[x[x.length-2]][x[x.length-1]],x.push(J);break;case 3:return!0}}return!0}},C={initialize:function(){this._nodes=[],this._node={},this._stash=[]},set:function(y){for(var E in y)this._node[E]=y[E];return this._node},node:function(y){return arguments.length&&(this._node=y),this._node},push:function(){this._nodes.push(this._node),this._node={}},unshift:function(){this._nodes.unshift(this._node),this._node={}},yield:function(){var y=this._nodes;return this.initialize(),y}},l=function(){var y={EOF:1,parseError:function(m,x){if(this.yy.parser)this.yy.parser.parseError(m,x);else throw new Error(m)},setInput:function(E){return this._input=E,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var E=this._input[0];this.yytext+=E,this.yyleng++,this.offset++,this.match+=E,this.matched+=E;var m=E.match(/(?:\r\n?|\n).*/g);return m?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),E},unput:function(E){var m=E.length,x=E.split(/(?:\r\n?|\n)/g);this._input=E+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-m-1),this.offset-=m;var O=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),x.length-1&&(this.yylineno-=x.length-1);var L=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:x?(x.length===O.length?this.yylloc.first_column:0)+O[O.length-x.length].length-x[0].length:this.yylloc.first_column-m},this.options.ranges&&(this.yylloc.range=[L[0],L[0]+this.yyleng-m]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
186
|
-
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(E){this.unput(this.match.slice(E))},pastInput:function(){var E=this.matched.substr(0,this.matched.length-this.match.length);return(E.length>20?"...":"")+E.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var E=this.match;return E.length<20&&(E+=this._input.substr(0,20-E.length)),(E.substr(0,20)+(E.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var E=this.pastInput(),m=new Array(E.length+1).join("-");return E+this.upcomingInput()+`
|
|
187
|
-
`+m+"^"},test_match:function(E,m){var x,O,L;if(this.options.backtrack_lexer&&(L={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(L.yylloc.range=this.yylloc.range.slice(0))),O=E[0].match(/(?:\r\n?|\n).*/g),O&&(this.yylineno+=O.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:O?O[O.length-1].length-O[O.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+E[0].length},this.yytext+=E[0],this.match+=E[0],this.matches=E,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(E[0].length),this.matched+=E[0],x=this.performAction.call(this,this.yy,this,m,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),x)return x;if(this._backtrack){for(var I in L)this[I]=L[I];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var E,m,x,O;this._more||(this.yytext="",this.match="");for(var L=this._currentRules(),I=0;I<L.length;I++)if(x=this._input.match(this.rules[L[I]]),x&&(!m||x[0].length>m[0].length)){if(m=x,O=I,this.options.backtrack_lexer){if(E=this.test_match(x,L[I]),E!==!1)return E;if(this._backtrack){m=!1;continue}else return!1}else if(!this.options.flex)break}return m?(E=this.test_match(m,L[O]),E!==!1?E:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
|
|
188
|
-
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var m=this.next();return m||this.lex()},begin:function(m){this.conditionStack.push(m)},popState:function(){var m=this.conditionStack.length-1;return m>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(m){return m=this.conditionStack.length-1-Math.abs(m||0),m>=0?this.conditionStack[m]:"INITIAL"},pushState:function(m){this.begin(m)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(m,x,O,L){switch(O){case 0:return 4;case 1:return 14;case 2:return 12;case 3:return 15;case 4:return 16;case 5:return 22;case 6:return 24;case 7:return 28;case 8:return 30;case 9:return 18;case 10:return x.yytext=x.yytext.substr(1,x.yyleng-2),32;case 11:return x.yytext=x.yytext.substr(1,x.yyleng-2),33;case 12:return 17;case 13:return 31}},rules:[/^(?:\$)/,/^(?:\.\.)/,/^(?:\.)/,/^(?:\*)/,/^(?:[a-zA-Z_]+[a-zA-Z0-9_]*)/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?:((-?(?:0|[1-9][0-9]*)))?\:((-?(?:0|[1-9][0-9]*)))?(\:((-?(?:0|[1-9][0-9]*)))?)?)/,/^(?:(-?(?:0|[1-9][0-9]*)))/,/^(?:"(?:\\["bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^"\\])*")/,/^(?:'(?:\\['bfnrt/\\]|\\u[a-fA-F0-9]{4}|[^'\\])*')/,/^(?:\(.+?\)(?=\]))/,/^(?:\?\(.+?\)(?=\]))/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return y}();d.lexer=l;function o(){this.yy={}}return o.prototype=d,d.Parser=o,new o}();typeof e<"u"&&typeof i<"u"&&(i.parser=g,i.Parser=g.Parser,i.parse=function(){return g.parse.apply(g,arguments)},i.main=function(C){C[1]||(console.log("Usage: "+C[0]+" FILE"),s.exit(1));var l=e("fs").readFileSync(e("path").normalize(C[1]),"utf8");return i.parser.parse(l)},typeof n<"u"&&e.main===n&&i.main(s.argv.slice(1)))}).call(this,e("_process"))},{_process:14,fs:12,path:13}],2:[function(e,n,i){n.exports={identifier:"[a-zA-Z_]+[a-zA-Z0-9_]*",integer:"-?(?:0|[1-9][0-9]*)",qq_string:'"(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^"\\\\])*"',q_string:"'(?:\\\\['bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^'\\\\])*'"}},{}],3:[function(e,n,i){var s=e("./dict"),g=e("fs"),d={lex:{macros:{esc:"\\\\",int:s.integer},rules:[["\\$","return 'DOLLAR'"],["\\.\\.","return 'DOT_DOT'"],["\\.","return 'DOT'"],["\\*","return 'STAR'"],[s.identifier,"return 'IDENTIFIER'"],["\\[","return '['"],["\\]","return ']'"],[",","return ','"],["({int})?\\:({int})?(\\:({int})?)?","return 'ARRAY_SLICE'"],["{int}","return 'INTEGER'"],[s.qq_string,"yytext = yytext.substr(1,yyleng-2); return 'QQ_STRING';"],[s.q_string,"yytext = yytext.substr(1,yyleng-2); return 'Q_STRING';"],["\\(.+?\\)(?=\\])","return 'SCRIPT_EXPRESSION'"],["\\?\\(.+?\\)(?=\\])","return 'FILTER_EXPRESSION'"]]},start:"JSON_PATH",bnf:{JSON_PATH:[["DOLLAR",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["DOLLAR PATH_COMPONENTS",'yy.ast.set({ expression: { type: "root", value: $1 } }); yy.ast.unshift(); return yy.ast.yield()'],["LEADING_CHILD_MEMBER_EXPRESSION","yy.ast.unshift(); return yy.ast.yield()"],["LEADING_CHILD_MEMBER_EXPRESSION PATH_COMPONENTS",'yy.ast.set({ operation: "member", scope: "child", expression: { type: "identifier", value: $1 }}); yy.ast.unshift(); return yy.ast.yield()']],PATH_COMPONENTS:[["PATH_COMPONENT",""],["PATH_COMPONENTS PATH_COMPONENT",""]],PATH_COMPONENT:[["MEMBER_COMPONENT",'yy.ast.set({ operation: "member" }); yy.ast.push()'],["SUBSCRIPT_COMPONENT",'yy.ast.set({ operation: "subscript" }); yy.ast.push() ']],MEMBER_COMPONENT:[["CHILD_MEMBER_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_MEMBER_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_MEMBER_COMPONENT:[["DOT MEMBER_EXPRESSION",""]],LEADING_CHILD_MEMBER_EXPRESSION:[["MEMBER_EXPRESSION",'yy.ast.set({ scope: "child", operation: "member" })']],DESCENDANT_MEMBER_COMPONENT:[["DOT_DOT MEMBER_EXPRESSION",""]],MEMBER_EXPRESSION:[["STAR",'yy.ast.set({ expression: { type: "wildcard", value: $1 } })'],["IDENTIFIER",'yy.ast.set({ expression: { type: "identifier", value: $1 } })'],["SCRIPT_EXPRESSION",'yy.ast.set({ expression: { type: "script_expression", value: $1 } })'],["INTEGER",'yy.ast.set({ expression: { type: "numeric_literal", value: parseInt($1) } })'],["END",""]],SUBSCRIPT_COMPONENT:[["CHILD_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "child" })'],["DESCENDANT_SUBSCRIPT_COMPONENT",'yy.ast.set({ scope: "descendant" })']],CHILD_SUBSCRIPT_COMPONENT:[["[ SUBSCRIPT ]",""]],DESCENDANT_SUBSCRIPT_COMPONENT:[["DOT_DOT [ SUBSCRIPT ]",""]],SUBSCRIPT:[["SUBSCRIPT_EXPRESSION",""],["SUBSCRIPT_EXPRESSION_LIST",'$1.length > 1? yy.ast.set({ expression: { type: "union", value: $1 } }) : $$ = $1']],SUBSCRIPT_EXPRESSION_LIST:[["SUBSCRIPT_EXPRESSION_LISTABLE","$$ = [$1]"],["SUBSCRIPT_EXPRESSION_LIST , SUBSCRIPT_EXPRESSION_LISTABLE","$$ = $1.concat($3)"]],SUBSCRIPT_EXPRESSION_LISTABLE:[["INTEGER",'$$ = { expression: { type: "numeric_literal", value: parseInt($1) } }; yy.ast.set($$)'],["STRING_LITERAL",'$$ = { expression: { type: "string_literal", value: $1 } }; yy.ast.set($$)'],["ARRAY_SLICE",'$$ = { expression: { type: "slice", value: $1 } }; yy.ast.set($$)']],SUBSCRIPT_EXPRESSION:[["STAR",'$$ = { expression: { type: "wildcard", value: $1 } }; yy.ast.set($$)'],["SCRIPT_EXPRESSION",'$$ = { expression: { type: "script_expression", value: $1 } }; yy.ast.set($$)'],["FILTER_EXPRESSION",'$$ = { expression: { type: "filter_expression", value: $1 } }; yy.ast.set($$)']],STRING_LITERAL:[["QQ_STRING","$$ = $1"],["Q_STRING","$$ = $1"]]}};g.readFileSync&&(d.moduleInclude=g.readFileSync(e.resolve("../include/module.js")),d.actionInclude=g.readFileSync(e.resolve("../include/action.js"))),n.exports=d},{"./dict":2,fs:12}],4:[function(e,n,i){var s=e("./aesprim"),g=e("./slice"),d=e("static-eval"),C=e("underscore").uniq,l=function(){return this.initialize.apply(this,arguments)};l.prototype.initialize=function(){this.traverse=m(!0),this.descend=m()},l.prototype.keys=Object.keys,l.prototype.resolve=function(U){var w=[U.operation,U.scope,U.expression.type].join("-"),S=this._fns[w];if(!S)throw new Error("couldn't resolve key: "+w);return S.bind(this)},l.prototype.register=function(U,w){if(!w instanceof Function)throw new Error("handler must be a function");this._fns[U]=w},l.prototype._fns={"member-child-identifier":function(U,w){var S=U.expression.value,F=w.value;if(F instanceof Object&&S in F)return[{value:F[S],path:w.path.concat(S)}]},"member-descendant-identifier":O(function(U,w,S){return U==S}),"subscript-child-numeric_literal":x(function(U,w,S){return U===S}),"member-child-numeric_literal":x(function(U,w,S){return String(U)===String(S)}),"subscript-descendant-numeric_literal":O(function(U,w,S){return U===S}),"member-child-wildcard":x(function(){return!0}),"member-descendant-wildcard":O(function(){return!0}),"subscript-descendant-wildcard":O(function(){return!0}),"subscript-child-wildcard":x(function(){return!0}),"subscript-child-slice":function(U,w){if(y(w.value)){var S=U.expression.value.split(":").map(v),F=w.value.map(function(r,h){return{value:r,path:w.path.concat(h)}});return g.apply(null,[F].concat(S))}},"subscript-child-union":function(U,w){var S=[];return U.expression.value.forEach(function(F){var r={operation:"subscript",scope:"child",expression:F.expression},h=this.resolve(r),R=h(r,w);R&&(S=S.concat(R))},this),I(S)},"subscript-descendant-union":function(U,w,S){var F=e(".."),r=this,h=[],R=F.nodes(w,"$..*").slice(1);return R.forEach(function(j){h.length>=S||U.expression.value.forEach(function(T){var M={operation:"subscript",scope:"child",expression:T.expression},A=r.resolve(M),D=A(M,j);h=h.concat(D)})}),I(h)},"subscript-child-filter_expression":function(U,w,S){var F=U.expression.value.slice(2,-1),r=s.parse(F).body[0].expression,h=function(R,j){return L(r,{"@":j})};return this.descend(w,null,h,S)},"subscript-descendant-filter_expression":function(U,w,S){var F=U.expression.value.slice(2,-1),r=s.parse(F).body[0].expression,h=function(R,j){return L(r,{"@":j})};return this.traverse(w,null,h,S)},"subscript-child-script_expression":function(U,w){var S=U.expression.value.slice(1,-1);return o(w,S,"$[{{value}}]")},"member-child-script_expression":function(U,w){var S=U.expression.value.slice(1,-1);return o(w,S,"$.{{value}}")},"member-descendant-script_expression":function(U,w){var S=U.expression.value.slice(1,-1);return o(w,S,"$..value")}},l.prototype._fns["subscript-child-string_literal"]=l.prototype._fns["member-child-identifier"],l.prototype._fns["member-descendant-numeric_literal"]=l.prototype._fns["subscript-descendant-string_literal"]=l.prototype._fns["member-descendant-identifier"];function o(U,w,S){var F=e("./index"),r=s.parse(w).body[0].expression,h=L(r,{"@":U.value}),R=S.replace(/\{\{\s*value\s*\}\}/g,h),j=F.nodes(U.value,R);return j.forEach(function(T){T.path=U.path.concat(T.path.slice(1))}),j}function y(U){return Array.isArray(U)}function E(U){return U&&!(U instanceof Array)&&U instanceof Object}function m(U){return function(w,S,F,r){var h=w.value,R=w.path,j=[],T=function(M,A){y(M)?(M.forEach(function(D,H){j.length>=r||F(H,D,S)&&j.push({path:A.concat(H),value:D})}),M.forEach(function(D,H){j.length>=r||U&&T(D,A.concat(H))})):E(M)&&(this.keys(M).forEach(function(D){j.length>=r||F(D,M[D],S)&&j.push({path:A.concat(D),value:M[D]})}),this.keys(M).forEach(function(D){j.length>=r||U&&T(M[D],A.concat(D))}))}.bind(this);return T(h,R),j}}function x(U){return function(w,S,F){return this.descend(S,w.expression.value,U,F)}}function O(U){return function(w,S,F){return this.traverse(S,w.expression.value,U,F)}}function L(){try{return d.apply(this,arguments)}catch{}}function I(U){return U=U.filter(function(w){return w}),C(U,function(w){return w.path.map(function(S){return String(S).replace("-","--")}).join("-")})}function v(U){var w=String(U);return w.match(/^-?[0-9]+$/)?parseInt(w):null}n.exports=l},{"..":"jsonpath","./aesprim":"./aesprim","./index":5,"./slice":7,"static-eval":15,underscore:12}],5:[function(e,n,i){var s=e("assert"),g=e("./dict"),d=e("./parser"),C=e("./handlers"),l=function(){this.initialize.apply(this,arguments)};l.prototype.initialize=function(){this.parser=new d,this.handlers=new C},l.prototype.parse=function(E){return s.ok(o(E),"we need a path"),this.parser.parse(E)},l.prototype.parent=function(E,m){s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path");var x=this.nodes(E,m)[0];return x.path.pop(),this.value(E,x.path)},l.prototype.apply=function(E,m,x){s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path"),s.equal(typeof x,"function","fn needs to be function");var O=this.nodes(E,m).sort(function(L,I){return I.path.length-L.path.length});return O.forEach(function(L){var I=L.path.pop(),v=this.value(E,this.stringify(L.path)),U=L.value=x.call(E,v[I]);v[I]=U},this),O},l.prototype.value=function(E,m,x){if(s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path"),arguments.length>=3){var O=this.nodes(E,m).shift();if(!O)return this._vivify(E,m,x);var L=O.path.slice(-1).shift(),I=this.parent(E,this.stringify(O.path));I[L]=x}return this.query(E,this.stringify(m),1).shift()},l.prototype._vivify=function(E,m,x){var O=this;s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path");var L=this.parser.parse(m).map(function(v){return v.expression.value}),I=function(v,U){var w=v.pop(),S=O.value(E,v);S||(I(v.concat(),typeof w=="string"?{}:[]),S=O.value(E,v)),S[w]=U};return I(L,x),this.query(E,m)[0]},l.prototype.query=function(E,m,x){s.ok(E instanceof Object,"obj needs to be an object"),s.ok(o(m),"we need a path");var O=this.nodes(E,m,x).map(function(L){return L.value});return O},l.prototype.paths=function(E,m,x){s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path");var O=this.nodes(E,m,x).map(function(L){return L.path});return O},l.prototype.nodes=function(E,m,x){if(s.ok(E instanceof Object,"obj needs to be an object"),s.ok(m,"we need a path"),x===0)return[];var O=this.parser.parse(m),L=this.handlers,I=[{path:["$"],value:E}],v=[];return O.length&&O[0].expression.type=="root"&&O.shift(),O.length?(O.forEach(function(U,w){if(!(v.length>=x)){var S=L.resolve(U),F=[];I.forEach(function(r){if(!(v.length>=x)){var h=S(U,r,x);w==O.length-1?v=v.concat(h||[]):F=F.concat(h||[])}}),I=F}}),x?v.slice(0,x):v):I},l.prototype.stringify=function(E){s.ok(E,"we need a path");var m="$",x={"descendant-member":"..{{value}}","child-member":".{{value}}","descendant-subscript":"..[{{value}}]","child-subscript":"[{{value}}]"};return E=this._normalize(E),E.forEach(function(O){if(O.expression.type!="root"){var L=[O.scope,O.operation].join("-"),I=x[L],v;if(O.expression.type=="string_literal"?v=JSON.stringify(O.expression.value):v=O.expression.value,!I)throw new Error("couldn't find template "+L);m+=I.replace(/{{value}}/,v)}}),m},l.prototype._normalize=function(E){if(s.ok(E,"we need a path"),typeof E=="string")return this.parser.parse(E);if(Array.isArray(E)&&typeof E[0]=="string"){var m=[{expression:{type:"root",value:"$"}}];return E.forEach(function(x,O){if(!(x=="$"&&O===0))if(typeof x=="string"&&x.match("^"+g.identifier+"$"))m.push({operation:"member",scope:"child",expression:{value:x,type:"identifier"}});else{var L=typeof x=="number"?"numeric_literal":"string_literal";m.push({operation:"subscript",scope:"child",expression:{value:x,type:L}})}}),m}else if(Array.isArray(E)&&typeof E[0]=="object")return E;throw new Error("couldn't understand path "+E)};function o(E){return Object.prototype.toString.call(E)=="[object String]"}l.Handlers=C,l.Parser=d;var y=new l;y.JSONPath=l,n.exports=y},{"./dict":2,"./handlers":4,"./parser":6,assert:8}],6:[function(e,n,i){var s=e("./grammar"),g=e("../generated/parser"),d=function(){var C=new g.Parser,l=C.parseError;return C.yy.parseError=function(){C.yy.ast&&C.yy.ast.initialize(),l.apply(C,arguments)},C};d.grammar=s,n.exports=d},{"../generated/parser":1,"./grammar":3}],7:[function(e,n,i){n.exports=function(g,d,C,l){if(typeof d=="string")throw new Error("start cannot be a string");if(typeof C=="string")throw new Error("end cannot be a string");if(typeof l=="string")throw new Error("step cannot be a string");var o=g.length;if(l===0)throw new Error("step cannot be zero");if(l=l?s(l):1,d=d<0?o+d:d,C=C<0?o+C:C,d=s(d===0?0:d||(l>0?0:o-1)),C=s(C===0?0:C||(l>0?o:-1)),d=l>0?Math.max(0,d):Math.min(o,d),C=l>0?Math.min(C,o):Math.max(-1,C),l>0&&C<=d)return[];if(l<0&&d<=C)return[];for(var y=[],E=d;E!=C&&!(l<0&&E<=C||l>0&&E>=C);E+=l)y.push(g[E]);return y};function s(g){return String(g).match(/^[0-9]+$/)?parseInt(g):Number.isFinite(g)?parseInt(g,10):0}},{}],8:[function(e,n,i){var s=e("util/"),g=Array.prototype.slice,d=Object.prototype.hasOwnProperty,C=n.exports=m;C.AssertionError=function(S){this.name="AssertionError",this.actual=S.actual,this.expected=S.expected,this.operator=S.operator,S.message?(this.message=S.message,this.generatedMessage=!1):(this.message=y(this),this.generatedMessage=!0);var F=S.stackStartFunction||E;if(Error.captureStackTrace)Error.captureStackTrace(this,F);else{var r=new Error;if(r.stack){var h=r.stack,R=F.name,j=h.indexOf(`
|
|
189
|
-
`+R);if(j>=0){var T=h.indexOf(`
|
|
190
|
-
`,j+1);h=h.substring(T+1)}this.stack=h}}},s.inherits(C.AssertionError,Error);function l(w,S){return s.isUndefined(S)?""+S:s.isNumber(S)&&!isFinite(S)||s.isFunction(S)||s.isRegExp(S)?S.toString():S}function o(w,S){return s.isString(w)?w.length<S?w:w.slice(0,S):w}function y(w){return o(JSON.stringify(w.actual,l),128)+" "+w.operator+" "+o(JSON.stringify(w.expected,l),128)}function E(w,S,F,r,h){throw new C.AssertionError({message:F,actual:w,expected:S,operator:r,stackStartFunction:h})}C.fail=E;function m(w,S){w||E(w,!0,S,"==",C.ok)}C.ok=m,C.equal=function(S,F,r){S!=F&&E(S,F,r,"==",C.equal)},C.notEqual=function(S,F,r){S==F&&E(S,F,r,"!=",C.notEqual)},C.deepEqual=function(S,F,r){x(S,F)||E(S,F,r,"deepEqual",C.deepEqual)};function x(w,S){if(w===S)return!0;if(s.isBuffer(w)&&s.isBuffer(S)){if(w.length!=S.length)return!1;for(var F=0;F<w.length;F++)if(w[F]!==S[F])return!1;return!0}else return s.isDate(w)&&s.isDate(S)?w.getTime()===S.getTime():s.isRegExp(w)&&s.isRegExp(S)?w.source===S.source&&w.global===S.global&&w.multiline===S.multiline&&w.lastIndex===S.lastIndex&&w.ignoreCase===S.ignoreCase:!s.isObject(w)&&!s.isObject(S)?w==S:L(w,S)}function O(w){return Object.prototype.toString.call(w)=="[object Arguments]"}function L(w,S){if(s.isNullOrUndefined(w)||s.isNullOrUndefined(S)||w.prototype!==S.prototype)return!1;if(s.isPrimitive(w)||s.isPrimitive(S))return w===S;var F=O(w),r=O(S);if(F&&!r||!F&&r)return!1;if(F)return w=g.call(w),S=g.call(S),x(w,S);var h=U(w),R=U(S),j,T;if(h.length!=R.length)return!1;for(h.sort(),R.sort(),T=h.length-1;T>=0;T--)if(h[T]!=R[T])return!1;for(T=h.length-1;T>=0;T--)if(j=h[T],!x(w[j],S[j]))return!1;return!0}C.notDeepEqual=function(S,F,r){x(S,F)&&E(S,F,r,"notDeepEqual",C.notDeepEqual)},C.strictEqual=function(S,F,r){S!==F&&E(S,F,r,"===",C.strictEqual)},C.notStrictEqual=function(S,F,r){S===F&&E(S,F,r,"!==",C.notStrictEqual)};function I(w,S){return!w||!S?!1:Object.prototype.toString.call(S)=="[object RegExp]"?S.test(w):w instanceof S?!0:S.call({},w)===!0}function v(w,S,F,r){var h;s.isString(F)&&(r=F,F=null);try{S()}catch(R){h=R}if(r=(F&&F.name?" ("+F.name+").":".")+(r?" "+r:"."),w&&!h&&E(h,F,"Missing expected exception"+r),!w&&I(h,F)&&E(h,F,"Got unwanted exception"+r),w&&h&&F&&!I(h,F)||!w&&h)throw h}C.throws=function(w,S,F){v.apply(this,[!0].concat(g.call(arguments)))},C.doesNotThrow=function(w,S){v.apply(this,[!1].concat(g.call(arguments)))},C.ifError=function(w){if(w)throw w};var U=Object.keys||function(w){var S=[];for(var F in w)d.call(w,F)&&S.push(F);return S}},{"util/":11}],9:[function(e,n,i){typeof Object.create=="function"?n.exports=function(g,d){g.super_=d,g.prototype=Object.create(d.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}})}:n.exports=function(g,d){g.super_=d;var C=function(){};C.prototype=d.prototype,g.prototype=new C,g.prototype.constructor=g}},{}],10:[function(e,n,i){n.exports=function(g){return g&&typeof g=="object"&&typeof g.copy=="function"&&typeof g.fill=="function"&&typeof g.readUInt8=="function"}},{}],11:[function(e,n,i){(function(s,g){var d=/%[sdj%]/g;i.format=function(G){if(!R(G)){for(var K=[],P=0;P<arguments.length;P++)K.push(o(arguments[P]));return K.join(" ")}for(var P=1,a=arguments,q=a.length,u=String(G).replace(d,function(z){if(z==="%%")return"%";if(P>=q)return z;switch(z){case"%s":return String(a[P++]);case"%d":return Number(a[P++]);case"%j":try{return JSON.stringify(a[P++])}catch{return"[Circular]"}default:return z}}),W=a[P];P<q;W=a[++P])F(W)||!A(W)?u+=" "+W:u+=" "+o(W);return u},i.deprecate=function(G,K){if(T(g.process))return function(){return i.deprecate(G,K).apply(this,arguments)};if(s.noDeprecation===!0)return G;var P=!1;function a(){if(!P){if(s.throwDeprecation)throw new Error(K);s.traceDeprecation?console.trace(K):console.error(K),P=!0}return G.apply(this,arguments)}return a};var C={},l;i.debuglog=function(G){if(T(l)&&(l=s.env.NODE_DEBUG||""),G=G.toUpperCase(),!C[G])if(new RegExp("\\b"+G+"\\b","i").test(l)){var K=s.pid;C[G]=function(){var P=i.format.apply(i,arguments);console.error("%s %d: %s",G,K,P)}}else C[G]=function(){};return C[G]};function o(G,K){var P={seen:[],stylize:E};return arguments.length>=3&&(P.depth=arguments[2]),arguments.length>=4&&(P.colors=arguments[3]),S(K)?P.showHidden=K:K&&i._extend(P,K),T(P.showHidden)&&(P.showHidden=!1),T(P.depth)&&(P.depth=2),T(P.colors)&&(P.colors=!1),T(P.customInspect)&&(P.customInspect=!0),P.colors&&(P.stylize=y),x(P,G,P.depth)}i.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function y(G,K){var P=o.styles[K];return P?"\x1B["+o.colors[P][0]+"m"+G+"\x1B["+o.colors[P][1]+"m":G}function E(G,K){return G}function m(G){var K={};return G.forEach(function(P,a){K[P]=!0}),K}function x(G,K,P){if(G.customInspect&&K&&ut(K.inspect)&&K.inspect!==i.inspect&&!(K.constructor&&K.constructor.prototype===K)){var a=K.inspect(P,G);return R(a)||(a=x(G,a,P)),a}var q=O(G,K);if(q)return q;var u=Object.keys(K),W=m(u);if(G.showHidden&&(u=Object.getOwnPropertyNames(K)),H(K)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return L(K);if(u.length===0){if(ut(K)){var z=K.name?": "+K.name:"";return G.stylize("[Function"+z+"]","special")}if(M(K))return G.stylize(RegExp.prototype.toString.call(K),"regexp");if(D(K))return G.stylize(Date.prototype.toString.call(K),"date");if(H(K))return L(K)}var b="",at=!1,At=["{","}"];if(w(K)&&(at=!0,At=["[","]"]),ut(K)){var Lt=K.name?": "+K.name:"";b=" [Function"+Lt+"]"}if(M(K)&&(b=" "+RegExp.prototype.toString.call(K)),D(K)&&(b=" "+Date.prototype.toUTCString.call(K)),H(K)&&(b=" "+L(K)),u.length===0&&(!at||K.length==0))return At[0]+b+At[1];if(P<0)return M(K)?G.stylize(RegExp.prototype.toString.call(K),"regexp"):G.stylize("[Object]","special");G.seen.push(K);var yt;return at?yt=I(G,K,P,W,u):yt=u.map(function(It){return v(G,K,P,W,It,at)}),G.seen.pop(),U(yt,b,At)}function O(G,K){if(T(K))return G.stylize("undefined","undefined");if(R(K)){var P="'"+JSON.stringify(K).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return G.stylize(P,"string")}if(h(K))return G.stylize(""+K,"number");if(S(K))return G.stylize(""+K,"boolean");if(F(K))return G.stylize("null","null")}function L(G){return"["+Error.prototype.toString.call(G)+"]"}function I(G,K,P,a,q){for(var u=[],W=0,z=K.length;W<z;++W)zt(K,String(W))?u.push(v(G,K,P,a,String(W),!0)):u.push("");return q.forEach(function(b){b.match(/^\d+$/)||u.push(v(G,K,P,a,b,!0))}),u}function v(G,K,P,a,q,u){var W,z,b;if(b=Object.getOwnPropertyDescriptor(K,q)||{value:K[q]},b.get?b.set?z=G.stylize("[Getter/Setter]","special"):z=G.stylize("[Getter]","special"):b.set&&(z=G.stylize("[Setter]","special")),zt(a,q)||(W="["+q+"]"),z||(G.seen.indexOf(b.value)<0?(F(P)?z=x(G,b.value,null):z=x(G,b.value,P-1),z.indexOf(`
|
|
191
|
-
`)>-1&&(u?z=z.split(`
|
|
192
|
-
`).map(function(at){return" "+at}).join(`
|
|
193
|
-
`).substr(2):z=`
|
|
194
|
-
`+z.split(`
|
|
195
|
-
`).map(function(at){return" "+at}).join(`
|
|
196
|
-
`))):z=G.stylize("[Circular]","special")),T(W)){if(u&&q.match(/^\d+$/))return z;W=JSON.stringify(""+q),W.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(W=W.substr(1,W.length-2),W=G.stylize(W,"name")):(W=W.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),W=G.stylize(W,"string"))}return W+": "+z}function U(G,K,P){var a=G.reduce(function(q,u){return u.indexOf(`
|
|
197
|
-
`)>=0,q+u.replace(/\u001b\[\d\d?m/g,"").length+1},0);return a>60?P[0]+(K===""?"":K+`
|
|
198
|
-
`)+" "+G.join(`,
|
|
199
|
-
`)+" "+P[1]:P[0]+K+" "+G.join(", ")+" "+P[1]}function w(G){return Array.isArray(G)}i.isArray=w;function S(G){return typeof G=="boolean"}i.isBoolean=S;function F(G){return G===null}i.isNull=F;function r(G){return G==null}i.isNullOrUndefined=r;function h(G){return typeof G=="number"}i.isNumber=h;function R(G){return typeof G=="string"}i.isString=R;function j(G){return typeof G=="symbol"}i.isSymbol=j;function T(G){return G===void 0}i.isUndefined=T;function M(G){return A(G)&&J(G)==="[object RegExp]"}i.isRegExp=M;function A(G){return typeof G=="object"&&G!==null}i.isObject=A;function D(G){return A(G)&&J(G)==="[object Date]"}i.isDate=D;function H(G){return A(G)&&(J(G)==="[object Error]"||G instanceof Error)}i.isError=H;function ut(G){return typeof G=="function"}i.isFunction=ut;function nt(G){return G===null||typeof G=="boolean"||typeof G=="number"||typeof G=="string"||typeof G=="symbol"||typeof G>"u"}i.isPrimitive=nt,i.isBuffer=e("./support/isBuffer");function J(G){return Object.prototype.toString.call(G)}function ft(G){return G<10?"0"+G.toString(10):G.toString(10)}var it=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function _t(){var G=new Date,K=[ft(G.getHours()),ft(G.getMinutes()),ft(G.getSeconds())].join(":");return[G.getDate(),it[G.getMonth()],K].join(" ")}i.log=function(){console.log("%s - %s",_t(),i.format.apply(i,arguments))},i.inherits=e("inherits"),i._extend=function(G,K){if(!K||!A(K))return G;for(var P=Object.keys(K),a=P.length;a--;)G[P[a]]=K[P[a]];return G};function zt(G,K){return Object.prototype.hasOwnProperty.call(G,K)}}).call(this,e("_process"),typeof se.commonjsGlobal<"u"?se.commonjsGlobal:typeof self<"u"?self:typeof window<"u"?window:{})},{"./support/isBuffer":10,_process:14,inherits:9}],12:[function(e,n,i){},{}],13:[function(e,n,i){(function(s){function g(o,y){for(var E=0,m=o.length-1;m>=0;m--){var x=o[m];x==="."?o.splice(m,1):x===".."?(o.splice(m,1),E++):E&&(o.splice(m,1),E--)}if(y)for(;E--;E)o.unshift("..");return o}i.resolve=function(){for(var o="",y=!1,E=arguments.length-1;E>=-1&&!y;E--){var m=E>=0?arguments[E]:s.cwd();if(typeof m!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!m)continue;o=m+"/"+o,y=m.charAt(0)==="/"}return o=g(C(o.split("/"),function(x){return!!x}),!y).join("/"),(y?"/":"")+o||"."},i.normalize=function(o){var y=i.isAbsolute(o),E=l(o,-1)==="/";return o=g(C(o.split("/"),function(m){return!!m}),!y).join("/"),!o&&!y&&(o="."),o&&E&&(o+="/"),(y?"/":"")+o},i.isAbsolute=function(o){return o.charAt(0)==="/"},i.join=function(){var o=Array.prototype.slice.call(arguments,0);return i.normalize(C(o,function(y,E){if(typeof y!="string")throw new TypeError("Arguments to path.join must be strings");return y}).join("/"))},i.relative=function(o,y){o=i.resolve(o).substr(1),y=i.resolve(y).substr(1);function E(U){for(var w=0;w<U.length&&U[w]==="";w++);for(var S=U.length-1;S>=0&&U[S]==="";S--);return w>S?[]:U.slice(w,S-w+1)}for(var m=E(o.split("/")),x=E(y.split("/")),O=Math.min(m.length,x.length),L=O,I=0;I<O;I++)if(m[I]!==x[I]){L=I;break}for(var v=[],I=L;I<m.length;I++)v.push("..");return v=v.concat(x.slice(L)),v.join("/")},i.sep="/",i.delimiter=":",i.dirname=function(o){if(typeof o!="string"&&(o=o+""),o.length===0)return".";for(var y=o.charCodeAt(0),E=y===47,m=-1,x=!0,O=o.length-1;O>=1;--O)if(y=o.charCodeAt(O),y===47){if(!x){m=O;break}}else x=!1;return m===-1?E?"/":".":E&&m===1?"/":o.slice(0,m)};function d(o){typeof o!="string"&&(o=o+"");var y=0,E=-1,m=!0,x;for(x=o.length-1;x>=0;--x)if(o.charCodeAt(x)===47){if(!m){y=x+1;break}}else E===-1&&(m=!1,E=x+1);return E===-1?"":o.slice(y,E)}i.basename=function(o,y){var E=d(o);return y&&E.substr(-1*y.length)===y&&(E=E.substr(0,E.length-y.length)),E},i.extname=function(o){typeof o!="string"&&(o=o+"");for(var y=-1,E=0,m=-1,x=!0,O=0,L=o.length-1;L>=0;--L){var I=o.charCodeAt(L);if(I===47){if(!x){E=L+1;break}continue}m===-1&&(x=!1,m=L+1),I===46?y===-1?y=L:O!==1&&(O=1):y!==-1&&(O=-1)}return y===-1||m===-1||O===0||O===1&&y===m-1&&y===E+1?"":o.slice(y,m)};function C(o,y){if(o.filter)return o.filter(y);for(var E=[],m=0;m<o.length;m++)y(o[m],m,o)&&E.push(o[m]);return E}var l="ab".substr(-1)==="b"?function(o,y,E){return o.substr(y,E)}:function(o,y,E){return y<0&&(y=o.length+y),o.substr(y,E)}}).call(this,e("_process"))},{_process:14}],14:[function(e,n,i){var s=n.exports={},g,d;function C(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?g=setTimeout:g=C}catch{g=C}try{typeof clearTimeout=="function"?d=clearTimeout:d=l}catch{d=l}})();function o(w){if(g===setTimeout)return setTimeout(w,0);if((g===C||!g)&&setTimeout)return g=setTimeout,setTimeout(w,0);try{return g(w,0)}catch{try{return g.call(null,w,0)}catch{return g.call(this,w,0)}}}function y(w){if(d===clearTimeout)return clearTimeout(w);if((d===l||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(w);try{return d(w)}catch{try{return d.call(null,w)}catch{return d.call(this,w)}}}var E=[],m=!1,x,O=-1;function L(){!m||!x||(m=!1,x.length?E=x.concat(E):O=-1,E.length&&I())}function I(){if(!m){var w=o(L);m=!0;for(var S=E.length;S;){for(x=E,E=[];++O<S;)x&&x[O].run();O=-1,S=E.length}x=null,m=!1,y(w)}}s.nextTick=function(w){var S=new Array(arguments.length-1);if(arguments.length>1)for(var F=1;F<arguments.length;F++)S[F-1]=arguments[F];E.push(new v(w,S)),E.length===1&&!m&&o(I)};function v(w,S){this.fun=w,this.array=S}v.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={};function U(){}s.on=U,s.addListener=U,s.once=U,s.off=U,s.removeListener=U,s.removeAllListeners=U,s.emit=U,s.prependListener=U,s.prependOnceListener=U,s.listeners=function(w){return[]},s.binding=function(w){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(w){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],15:[function(e,n,i){var s=e("escodegen").generate;n.exports=function(g,d){d||(d={});var C={},l=function o(y,E){if(y.type==="Literal")return y.value;if(y.type==="UnaryExpression"){var m=o(y.argument);return y.operator==="+"?+m:y.operator==="-"?-m:y.operator==="~"?~m:y.operator==="!"?!m:C}else if(y.type==="ArrayExpression"){for(var x=[],O=0,L=y.elements.length;O<L;O++){var I=o(y.elements[O]);if(I===C)return C;x.push(I)}return x}else if(y.type==="ObjectExpression"){for(var v={},O=0;O<y.properties.length;O++){var U=y.properties[O],w=U.value===null?U.value:o(U.value);if(w===C)return C;v[U.key.value||U.key.name]=w}return v}else if(y.type==="BinaryExpression"||y.type==="LogicalExpression"){var L=o(y.left);if(L===C)return C;var S=o(y.right);if(S===C)return C;var F=y.operator;return F==="=="?L==S:F==="==="?L===S:F==="!="?L!=S:F==="!=="?L!==S:F==="+"?L+S:F==="-"?L-S:F==="*"?L*S:F==="/"?L/S:F==="%"?L%S:F==="<"?L<S:F==="<="?L<=S:F===">"?L>S:F===">="?L>=S:F==="|"?L|S:F==="&"?L&S:F==="^"?L^S:F==="&&"?L&&S:F==="||"?L||S:C}else{if(y.type==="Identifier")return{}.hasOwnProperty.call(d,y.name)?d[y.name]:C;if(y.type==="ThisExpression")return{}.hasOwnProperty.call(d,"this")?d.this:C;if(y.type==="CallExpression"){var r=o(y.callee);if(r===C||typeof r!="function")return C;var h=y.callee.object?o(y.callee.object):C;h===C&&(h=null);for(var R=[],O=0,L=y.arguments.length;O<L;O++){var I=o(y.arguments[O]);if(I===C)return C;R.push(I)}return r.apply(h,R)}else if(y.type==="MemberExpression"){var v=o(y.object);if(v===C||typeof v=="function")return C;if(y.property.type==="Identifier")return v[y.property.name];var U=o(y.property);return U===C?C:v[U]}else if(y.type==="ConditionalExpression"){var m=o(y.test);return m===C?C:o(m?y.consequent:y.alternate)}else if(y.type==="ExpressionStatement"){var m=o(y.expression);return m===C?C:m}else{if(y.type==="ReturnStatement")return o(y.argument);if(y.type==="FunctionExpression"){var j=y.body.body,T={};Object.keys(d).forEach(function(it){T[it]=d[it]});for(var O=0;O<y.params.length;O++){var M=y.params[O];if(M.type=="Identifier")d[M.name]=null;else return C}for(var O in j)if(o(j[O])===C)return C;d=T;var A=Object.keys(d),D=A.map(function(it){return d[it]});return Function(A.join(", "),"return "+s(y)).apply(null,D)}else if(y.type==="TemplateLiteral"){for(var H="",O=0;O<y.expressions.length;O++)H+=o(y.quasis[O]),H+=o(y.expressions[O]);return H+=o(y.quasis[O]),H}else if(y.type==="TaggedTemplateExpression"){var ut=o(y.tag),nt=y.quasi,J=nt.quasis.map(o),ft=nt.expressions.map(o);return ut.apply(null,[J].concat(ft))}else return y.type==="TemplateElement"?y.value.cooked:C}}}(g);return l===C?void 0:l}},{escodegen:12}],jsonpath:[function(e,n,i){n.exports=e("./lib/index")},{"./lib/index":5}]},{},["jsonpath"])("jsonpath")})})(jr);se.eventsExports.EventEmitter;const $r=Jn,ja=za,Gr=se.util;Gr.inherits(Dn,ja);function Dn(c,t){return $r.not.instanceStrict(this,Dn)?new Dn(c,t):ja.call(this,c,{...t,encoding:"utf8"})}var Kn={exports:{}};Kn.exports;(function(c){(function(t){c!==null?c.exports=e:t.tryer=e;function e(I){I=n(I),v();function v(){U()&&S()}function U(){return w("when",v)}function w(r,h){return I[r]()?!0:(m(I),x(I)?I.fail():L(h,O(I)),!1)}function S(){var r;if(E(I))return r=I.action(),r&&s(r.then)?r.then(F,F):F();I.action(F)}function F(){w("until",S)&&I.pass()}}function n(I){return I=I||{},{count:0,when:i(I.when),until:i(I.until),action:d(I.action),fail:d(I.fail),pass:d(I.pass),interval:o(I.interval,-1e3),limit:o(I.limit,-1)}}function i(I){return l(I,s,g)}function s(I){return typeof I=="function"}function g(){return!0}function d(I){return l(I,s,C)}function C(){}function l(I,v,U){return v(I)?I:U}function o(I,v){return l(I,y,v)}function y(I){return typeof I=="number"&&I===I}function E(I){return I.action.length===0}function m(I){I.count+=1}function x(I){return I.limit>=0&&I.count>=I.limit}function O(I){var v=I.interval;return I.interval<0&&(I.interval*=2),v}function L(I,v){setTimeout(I,Math.abs(v))}})(se.commonjsGlobal)})(Kn);Kn.exports;const Zr=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,wn=typeof __webpack_require__<"u",Yn=new lo.WorkerProxy,$a=async c=>{const{input:t,wasmFilePath:e,zKeyFilePath:n,chainId:i}=c.payload.data,{hostLocation:{origin:s},constants:{isDevelopment:g,chains:{chainIds:d}}}=c.metadata;let C=e,l=n;if(console.log({isWebpack:wn}),Zr){g&&!wn?(C=`test/circuits/${e}`,l=`test/circuits/${n}`):wn&&(C=`libs/hardhat/test/circuits/${e}`,l=`libs/hardhat/test/circuits/${n}`);const o=require("path");C=o.resolve(C),l=o.resolve(l)}else i===d.localhost&&(C=`${s}/${e}`,l=`${s}/${n}`);try{const{proof:o,publicSignals:y}=await Lr(t,C,l),E=await mr(o,y),m=JSON.parse(`[${E}]`);Yn.postMessageToMainThread({zkCallData:m,proof:o,publicSignals:y})}catch(o){console.log(o)}};Yn.attachWorkerSideOnMessage($a);exports.default=Yn;exports.onWorkerMessage=$a;
|