You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
99 KiB
1 lines
99 KiB
var Kr=Object.defineProperty;var Rr=(e,t,n)=>t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var P=(e,t,n)=>Rr(e,typeof t!="symbol"?t+"":t,n);/* empty css */import{D as Tn}from"./datetime-BDQ5ptpc.js";import{G as qr,g as ue,I as Dr,aI as Pr,aJ as jr,r as Vr}from"./index-MyY_xqVN.js";import{V as _r,f as Un,b as zr,C as Fr,c as Mr,_ as Zr,g as _t,h as zt,i as Ht,j as O,k as ke,t as Oe,m as xt,s as Ft,l as de,o as Hn,w as Gr,q as Nn,F as Yr,x as Nt,p as Wr}from"./index-BLqts8WY.js";import{i as Jr,u as Xr,v as Qr}from"./vue-leaflet.es-D17g3l39.js";import{I as to}from"./ImageMethodDialog-B6b8zZ7c.js";import{Q as eo}from"./QuickNav-DgCyvgDx.js";import"./index-CsfPLOYu.js";import"./PhotoDialog-Dn3GjI9b.js";const Ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const un=e=>e instanceof Uint8Array,qt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),dt=(e,t)=>e<<32-t|e>>>t,no=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!no)throw new Error("Non little-endian hardware is not supported");const ro=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Zt(e){if(!un(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=ro[e[n]];return t}function oo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let r=0;r<n.length;r++){const o=r*2,i=e.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function Qn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function ie(e){if(typeof e=="string"&&(e=Qn(e)),!un(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function oe(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!un(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}let tr=class{clone(){return this._cloneInto()}};const io=e=>Object.prototype.toString.call(e)==="[object Object]"&&e.constructor===Object;function so(e,t){if(t!==void 0&&(typeof t!="object"||!io(t)))throw new Error("Options should be object or undefined");return Object.assign(e,t)}function jt(e){const t=r=>e().update(ie(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ao(e=32){if(Ke&&typeof Ke.getRandomValues=="function")return Ke.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function Ge(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function co(e){if(typeof e!="boolean")throw new Error(`Expected boolean, not ${e}`)}function Lt(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function lo(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ge(e.outputLen),Ge(e.blockLen)}function fo(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function uo(e,t){Lt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const ut={number:Ge,bool:co,bytes:Lt,hash:lo,exists:fo,output:uo};let er=class extends tr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,ut.hash(t);const r=ie(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return ut.exists(this),this.iHash.update(t),this}digestInto(t){ut.exists(this),ut.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const se=(e,t,n)=>new er(e,t).update(n).digest();se.create=(e,t)=>new er(e,t);function ho(e,t,n,r){ut.hash(e);const o=so({dkLen:32,asyncTick:10},r),{c:i,dkLen:s,asyncTick:a}=o;if(ut.number(i),ut.number(s),ut.number(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=ie(t),l=ie(n),d=new Uint8Array(s),f=se.create(e,c),b=f._cloneInto().update(l);return{c:i,dkLen:s,asyncTick:a,DK:d,PRF:f,PRFSalt:b}}function po(e,t,n,r,o){return e.destroy(),t.destroy(),r&&r.destroy(),o.fill(0),n}function go(e,t,n,r){const{c:o,dkLen:i,DK:s,PRF:a,PRFSalt:c}=ho(e,t,n,r);let l;const d=new Uint8Array(4),f=qt(d),b=new Uint8Array(a.outputLen);for(let g=1,y=0;y<i;g++,y+=a.outputLen){const u=s.subarray(y,y+a.outputLen);f.setInt32(0,g,!1),(l=c._cloneInto(l)).update(d).digestInto(b),u.set(b.subarray(0,u.length));for(let h=1;h<o;h++){a._cloneInto(l).update(b).digestInto(b);for(let w=0;w<u.length;w++)u[w]^=b[w]}}return po(a,c,s,l,b)}function wo(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}let dn=class extends tr{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=qt(this.buffer)}update(t){ut.exists(this);const{view:n,buffer:r,blockLen:o}=this;t=ie(t);const i=t.length;for(let s=0;s<i;){const a=Math.min(o-this.pos,i-s);if(a===o){const c=qt(t);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ut.exists(this),ut.output(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let f=s;f<o;f++)n[f]=0;wo(r,o-8,BigInt(this.length*8),i),this.process(r,0);const a=qt(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,d[f],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}};const bo=(e,t,n)=>e&t^~e&n,yo=(e,t,n)=>e&t^e&n^t&n,mo=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Et=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vt=new Uint32Array(64);let nr=class extends dn{constructor(){super(64,32,8,!1),this.A=Et[0]|0,this.B=Et[1]|0,this.C=Et[2]|0,this.D=Et[3]|0,this.E=Et[4]|0,this.F=Et[5]|0,this.G=Et[6]|0,this.H=Et[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[t,n,r,o,i,s,a,c]}set(t,n,r,o,i,s,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)vt[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const b=vt[f-15],g=vt[f-2],y=dt(b,7)^dt(b,18)^b>>>3,u=dt(g,17)^dt(g,19)^g>>>10;vt[f]=u+vt[f-7]+y+vt[f-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:l,H:d}=this;for(let f=0;f<64;f++){const b=dt(a,6)^dt(a,11)^dt(a,25),g=d+b+bo(a,c,l)+mo[f]+vt[f]|0,u=(dt(r,2)^dt(r,13)^dt(r,22))+yo(r,o,i)|0;d=l,l=c,c=a,a=s+g|0,s=i,i=o,o=r,r=g+u|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,i,s,a,c,l,d)}roundClean(){vt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};class xo extends nr{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const Ae=jt(()=>new nr);jt(()=>new xo);const he=BigInt(2**32-1),Ye=BigInt(32);function rr(e,t=!1){return t?{h:Number(e&he),l:Number(e>>Ye&he)}:{h:Number(e>>Ye&he)|0,l:Number(e&he)|0}}function Eo(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=rr(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const vo=(e,t)=>BigInt(e>>>0)<<Ye|BigInt(t>>>0),Bo=(e,t,n)=>e>>>n,Ao=(e,t,n)=>e<<32-n|t>>>n,So=(e,t,n)=>e>>>n|t<<32-n,Io=(e,t,n)=>e<<32-n|t>>>n,$o=(e,t,n)=>e<<64-n|t>>>n-32,To=(e,t,n)=>e>>>n-32|t<<64-n,Uo=(e,t)=>t,Ho=(e,t)=>e,No=(e,t,n)=>e<<n|t>>>32-n,Lo=(e,t,n)=>t<<n|e>>>32-n,Co=(e,t,n)=>t<<n-32|e>>>64-n,ko=(e,t,n)=>e<<n-32|t>>>64-n;function Oo(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const Ko=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ro=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,qo=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Do=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,Po=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),jo=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,L={fromBig:rr,split:Eo,toBig:vo,shrSH:Bo,shrSL:Ao,rotrSH:So,rotrSL:Io,rotrBH:$o,rotrBL:To,rotr32H:Uo,rotr32L:Ho,rotlSH:No,rotlSL:Lo,rotlBH:Co,rotlBL:ko,add:Oo,add3L:Ko,add3H:Ro,add4L:qo,add4H:Do,add5H:jo,add5L:Po},[Vo,_o]=L.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Bt=new Uint32Array(80),At=new Uint32Array(80);class Se extends dn{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:d,Fh:f,Fl:b,Gh:g,Gl:y,Hh:u,Hl:h}=this;return[t,n,r,o,i,s,a,c,l,d,f,b,g,y,u,h]}set(t,n,r,o,i,s,a,c,l,d,f,b,g,y,u,h){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=d|0,this.Fh=f|0,this.Fl=b|0,this.Gh=g|0,this.Gl=y|0,this.Hh=u|0,this.Hl=h|0}process(t,n){for(let x=0;x<16;x++,n+=4)Bt[x]=t.getUint32(n),At[x]=t.getUint32(n+=4);for(let x=16;x<80;x++){const I=Bt[x-15]|0,B=At[x-15]|0,E=L.rotrSH(I,B,1)^L.rotrSH(I,B,8)^L.shrSH(I,B,7),A=L.rotrSL(I,B,1)^L.rotrSL(I,B,8)^L.shrSL(I,B,7),S=Bt[x-2]|0,C=At[x-2]|0,U=L.rotrSH(S,C,19)^L.rotrBH(S,C,61)^L.shrSH(S,C,6),T=L.rotrSL(S,C,19)^L.rotrBL(S,C,61)^L.shrSL(S,C,6),K=L.add4L(A,T,At[x-7],At[x-16]),R=L.add4H(K,E,U,Bt[x-7],Bt[x-16]);Bt[x]=R|0,At[x]=K|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:d,Eh:f,El:b,Fh:g,Fl:y,Gh:u,Gl:h,Hh:w,Hl:v}=this;for(let x=0;x<80;x++){const I=L.rotrSH(f,b,14)^L.rotrSH(f,b,18)^L.rotrBH(f,b,41),B=L.rotrSL(f,b,14)^L.rotrSL(f,b,18)^L.rotrBL(f,b,41),E=f&g^~f&u,A=b&y^~b&h,S=L.add5L(v,B,A,_o[x],At[x]),C=L.add5H(S,w,I,E,Vo[x],Bt[x]),U=S|0,T=L.rotrSH(r,o,28)^L.rotrBH(r,o,34)^L.rotrBH(r,o,39),K=L.rotrSL(r,o,28)^L.rotrBL(r,o,34)^L.rotrBL(r,o,39),R=r&i^r&a^i&a,z=o&s^o&c^s&c;w=u|0,v=h|0,u=g|0,h=y|0,g=f|0,y=b|0,{h:f,l:b}=L.add(l|0,d|0,C|0,U|0),l=a|0,d=c|0,a=i|0,c=s|0,i=r|0,s=o|0;const p=L.add3L(U,K,z);r=L.add3H(p,C,T,R),o=p|0}({h:r,l:o}=L.add(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=L.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=L.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:d}=L.add(this.Dh|0,this.Dl|0,l|0,d|0),{h:f,l:b}=L.add(this.Eh|0,this.El|0,f|0,b|0),{h:g,l:y}=L.add(this.Fh|0,this.Fl|0,g|0,y|0),{h:u,l:h}=L.add(this.Gh|0,this.Gl|0,u|0,h|0),{h:w,l:v}=L.add(this.Hh|0,this.Hl|0,w|0,v|0),this.set(r,o,i,s,a,c,l,d,f,b,g,y,u,h,w,v)}roundClean(){Bt.fill(0),At.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class zo extends Se{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Fo extends Se{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Mo extends Se{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const We=jt(()=>new Se);jt(()=>new zo);jt(()=>new Fo);jt(()=>new Mo);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Vt(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function gt(...e){const t=(o,i)=>s=>o(i(s)),n=Array.from(e).reverse().reduce((o,i)=>o?t(o,i.encode):i.encode,void 0),r=e.reduce((o,i)=>o?t(o,i.decode):i.decode,void 0);return{encode:n,decode:r}}function yt(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return t.map(n=>{if(Vt(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("alphabet.decode input should be array of strings");return t.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);const r=e.indexOf(n);if(r===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return r})}}}function mt(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of t)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return t.join(e)},decode:t=>{if(typeof t!="string")throw new Error("join.decode input should be string");return t.split(e)}}}function Ie(e,t="="){if(Vt(e),typeof t!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let r of n)if(typeof r!="string")throw new Error(`padding.encode: non-string input=${r}`);for(;n.length*e%8;)n.push(t);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let o of n)if(typeof o!="string")throw new Error(`padding.decode: non-string input=${o}`);let r=n.length;if(r*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if(!((r-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function or(e){if(typeof e!="function")throw new Error("normalize fn should be function");return{encode:t=>t,decode:t=>e(t)}}function Ln(e,t,n){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let r=0;const o=[],i=Array.from(e);for(i.forEach(s=>{if(Vt(s),s<0||s>=t)throw new Error(`Wrong integer: ${s}`)});;){let s=0,a=!0;for(let c=r;c<i.length;c++){const l=i[c],d=t*s+l;if(!Number.isSafeInteger(d)||t*s/t!==s||d-l!==t*s)throw new Error("convertRadix: carry overflow");if(s=d%n,i[c]=Math.floor(d/n),!Number.isSafeInteger(i[c])||i[c]*n+s!==d)throw new Error("convertRadix: carry overflow");if(a)i[c]?a=!1:r=c;else continue}if(o.push(s),a)break}for(let s=0;s<e.length-1&&e[s]===0;s++)o.push(0);return o.reverse()}const ir=(e,t)=>t?ir(t,e%t):e,ye=(e,t)=>e+(t-ir(e,t));function Je(e,t,n,r){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(ye(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ye(t,n)}`);let o=0,i=0;const s=2**n-1,a=[];for(const c of e){if(Vt(c),c>=2**t)throw new Error(`convertRadix2: invalid data word=${c} from=${t}`);if(o=o<<t|c,i+t>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)a.push((o>>i-n&s)>>>0);o&=2**i-1}if(o=o<<n-i&s,!r&&i>=t)throw new Error("Excess padding");if(!r&&o)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&a.push(o>>>0),a}function Zo(e){return Vt(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return Ln(Array.from(t),2**8,e)},decode:t=>{if(!Array.isArray(t)||t.length&&typeof t[0]!="number")throw new Error("radix.decode input should be array of strings");return Uint8Array.from(Ln(t,e,2**8))}}}function Tt(e,t=!1){if(Vt(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(ye(8,e)>32||ye(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!(n instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return Je(Array.from(n),8,e,!t)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(Je(n,e,8,t))}}}function Cn(e){if(typeof e!="function")throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch{}}}function Go(e,t){if(Vt(e),typeof t!="function")throw new Error("checksum fn should be function");return{encode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!(n instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=t(r).slice(0,e),i=n.slice(-e);for(let s=0;s<e;s++)if(o[s]!==i[s])throw new Error("Invalid checksum");return r}}}const Yo=gt(Tt(4),yt("0123456789ABCDEF"),mt("")),Wo=gt(Tt(5),yt("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),Ie(5),mt(""));gt(Tt(5),yt("0123456789ABCDEFGHIJKLMNOPQRSTUV"),Ie(5),mt(""));gt(Tt(5),yt("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),mt(""),or(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));const Jo=gt(Tt(6),yt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),Ie(6),mt("")),Xo=gt(Tt(6),yt("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),Ie(6),mt("")),hn=e=>gt(Zo(58),yt(e),mt("")),me=hn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");hn("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");hn("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const kn=[0,2,3,5,6,7,9,10,11],Qo={encode(e){let t="";for(let n=0;n<e.length;n+=8){const r=e.subarray(n,n+8);t+=me.encode(r).padStart(kn[r.length],"1")}return t},decode(e){let t=[];for(let n=0;n<e.length;n+=11){const r=e.slice(n,n+11),o=kn.indexOf(r.length),i=me.decode(r);for(let s=0;s<i.length-o;s++)if(i[s]!==0)throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(i.slice(i.length-o)))}return Uint8Array.from(t)}},ti=e=>gt(Go(4,t=>e(e(t))),me),Xe=gt(yt("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),mt("")),On=[996825010,642813549,513874426,1027748829,705979059];function ne(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<On.length;r++)(t>>r&1)===1&&(n^=On[r]);return n}function Kn(e,t,n=1){const r=e.length;let o=1;for(let i=0;i<r;i++){const s=e.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);o=ne(o)^s>>5}o=ne(o);for(let i=0;i<r;i++)o=ne(o)^e.charCodeAt(i)&31;for(let i of t)o=ne(o)^i;for(let i=0;i<6;i++)o=ne(o);return o^=n,Xe.encode(Je([o%2**30],30,5,!1))}function sr(e){const t=e==="bech32"?1:734539939,n=Tt(5),r=n.decode,o=n.encode,i=Cn(r);function s(d,f,b=90){if(typeof d!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof d}`);if(!Array.isArray(f)||f.length&&typeof f[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof f}`);const g=d.length+7+f.length;if(b!==!1&&g>b)throw new TypeError(`Length ${g} exceeds limit ${b}`);return d=d.toLowerCase(),`${d}1${Xe.encode(f)}${Kn(d,f,t)}`}function a(d,f=90){if(typeof d!="string")throw new Error(`bech32.decode input should be string, not ${typeof d}`);if(d.length<8||f!==!1&&d.length>f)throw new TypeError(`Wrong string length: ${d.length} (${d}). Expected (8..${f})`);const b=d.toLowerCase();if(d!==b&&d!==d.toUpperCase())throw new Error("String must be lowercase or uppercase");d=b;const g=d.lastIndexOf("1");if(g===0||g===-1)throw new Error('Letter "1" must be present between prefix and data only');const y=d.slice(0,g),u=d.slice(g+1);if(u.length<6)throw new Error("Data must be at least 6 characters long");const h=Xe.decode(u).slice(0,-6),w=Kn(y,h,t);if(!u.endsWith(w))throw new Error(`Invalid checksum in ${d}: expected "${w}"`);return{prefix:y,words:h}}const c=Cn(a);function l(d){const{prefix:f,words:b}=a(d,!1);return{prefix:f,words:b,bytes:r(b)}}return{encode:s,decode:a,decodeToBytes:l,decodeUnsafe:c,fromWords:r,fromWordsUnsafe:i,toWords:o}}sr("bech32");sr("bech32m");const ei={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)},ni=gt(Tt(4),yt("0123456789abcdef"),mt(""),or(e=>{if(typeof e!="string"||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),ri={utf8:ei,hex:ni,base16:Yo,base32:Wo,base64:Jo,base64url:Xo,base58:me,base58xmr:Qo};`${Object.keys(ri).join(", ")}`;function ar(e){if(typeof e!="string")throw new TypeError(`Invalid mnemonic type: ${typeof e}`);return e.normalize("NFKD")}function oi(e){const t=ar(e),n=t.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:n}}const ii=e=>ar(`mnemonic${e}`);function si(e,t=""){return go(We,oi(e).nfkd,ii(t),{c:2048,dkLen:64})}const ai=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),cr=Uint8Array.from({length:16},(e,t)=>t),ci=cr.map(e=>(9*e+5)%16);let pn=[cr],gn=[ci];for(let e=0;e<4;e++)for(let t of[pn,gn])t.push(t[e].map(n=>ai[n]));const lr=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),li=pn.map((e,t)=>e.map(n=>lr[t][n])),fi=gn.map((e,t)=>e.map(n=>lr[t][n])),ui=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),di=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),pe=(e,t)=>e<<t|e>>>32-t;function Rn(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const ge=new Uint32Array(16);class hi extends dn{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:o,h4:i}=this;return[t,n,r,o,i]}set(t,n,r,o,i){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=o|0,this.h4=i|0}process(t,n){for(let g=0;g<16;g++,n+=4)ge[g]=t.getUint32(n,!0);let r=this.h0|0,o=r,i=this.h1|0,s=i,a=this.h2|0,c=a,l=this.h3|0,d=l,f=this.h4|0,b=f;for(let g=0;g<5;g++){const y=4-g,u=ui[g],h=di[g],w=pn[g],v=gn[g],x=li[g],I=fi[g];for(let B=0;B<16;B++){const E=pe(r+Rn(g,i,a,l)+ge[w[B]]+u,x[B])+f|0;r=f,f=l,l=pe(a,10)|0,a=i,i=E}for(let B=0;B<16;B++){const E=pe(o+Rn(y,s,c,d)+ge[v[B]]+h,I[B])+b|0;o=b,b=d,d=pe(c,10)|0,c=s,s=E}}this.set(this.h1+a+d|0,this.h2+l+b|0,this.h3+f+o|0,this.h4+r+s|0,this.h0+i+c|0)}roundClean(){ge.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const pi=jt(()=>new hi);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fr=BigInt(0),$e=BigInt(1),gi=BigInt(2),Te=e=>e instanceof Uint8Array,wi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Yt(e){if(!Te(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=wi[e[n]];return t}function ur(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function wn(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function Wt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let r=0;r<n.length;r++){const o=r*2,i=e.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function Dt(e){return wn(Yt(e))}function bn(e){if(!Te(e))throw new Error("Uint8Array expected");return wn(Yt(Uint8Array.from(e).reverse()))}function Gt(e,t){return Wt(e.toString(16).padStart(t*2,"0"))}function dr(e,t){return Gt(e,t).reverse()}function bi(e){return Wt(ur(e))}function at(e,t,n){let r;if(typeof t=="string")try{r=Wt(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else if(Te(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function ae(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!Te(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function yi(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function mi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function xi(e){let t;for(t=0;e>fr;e>>=$e,t+=1);return t}function Ei(e,t){return e>>BigInt(t)&$e}const vi=(e,t,n)=>e|(n?$e:fr)<<BigInt(t),yn=e=>(gi<<BigInt(e-1))-$e,Re=e=>new Uint8Array(e),qn=e=>Uint8Array.from(e);function hr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Re(e),o=Re(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...f)=>n(o,r,...f),c=(f=Re())=>{o=a(qn([0]),f),r=a(),f.length!==0&&(o=a(qn([1]),f),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const b=[];for(;f<t;){r=a();const g=r.slice();b.push(g),f+=r.length}return ae(...b)};return(f,b)=>{s(),c(f);let g;for(;!(g=b(l()));)c();return s(),g}}const Bi={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function le(e,t,n={}){const r=(o,i,s)=>{const a=Bi[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const Ai=Object.freeze(Object.defineProperty({__proto__:null,bitGet:Ei,bitLen:xi,bitMask:yn,bitSet:vi,bytesToHex:Yt,bytesToNumberBE:Dt,bytesToNumberLE:bn,concatBytes:ae,createHmacDrbg:hr,ensureBytes:at,equalBytes:yi,hexToBytes:Wt,hexToNumber:wn,numberToBytesBE:Gt,numberToBytesLE:dr,numberToHexUnpadded:ur,numberToVarBytesBE:bi,utf8ToBytes:mi,validateObject:le},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const F=BigInt(0),V=BigInt(1),Ct=BigInt(2),Si=BigInt(3),Qe=BigInt(4),Dn=BigInt(5),Pn=BigInt(8);BigInt(9);BigInt(16);function Q(e,t){const n=e%t;return n>=F?n:t+n}function Ii(e,t,n){if(n<=F||t<F)throw new Error("Expected power/modulo > 0");if(n===V)return F;let r=V;for(;t>F;)t&V&&(r=r*e%n),e=e*e%n,t>>=V;return r}function it(e,t,n){let r=e;for(;t-- >F;)r*=r,r%=n;return r}function tn(e,t){if(e===F||t<=F)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=Q(e,t),r=t,o=F,i=V;for(;n!==F;){const a=r/n,c=r%n,l=o-i*a;r=n,n=c,o=i,i=l}if(r!==V)throw new Error("invert: does not exist");return Q(o,t)}function $i(e){const t=(e-V)/Ct;let n,r,o;for(n=e-V,r=0;n%Ct===F;n/=Ct,r++);for(o=Ct;o<e&&Ii(o,t,e)!==e-V;o++);if(r===1){const s=(e+V)/Qe;return function(c,l){const d=c.pow(l,s);if(!c.eql(c.sqr(d),l))throw new Error("Cannot find square root");return d}}const i=(n+V)/Ct;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,d=a.pow(a.mul(a.ONE,o),n),f=a.pow(c,i),b=a.pow(c,n);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let g=1;for(let u=a.sqr(b);g<l&&!a.eql(u,a.ONE);g++)u=a.sqr(u);const y=a.pow(d,V<<BigInt(l-g-1));d=a.sqr(y),f=a.mul(f,y),b=a.mul(b,d),l=g}return f}}function Ti(e){if(e%Qe===Si){const t=(e+V)/Qe;return function(r,o){const i=r.pow(o,t);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%Pn===Dn){const t=(e-Dn)/Pn;return function(r,o){const i=r.mul(o,Ct),s=r.pow(i,t),a=r.mul(o,s),c=r.mul(r.mul(a,Ct),s),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return $i(e)}const Ui=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hi(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=Ui.reduce((r,o)=>(r[o]="function",r),t);return le(e,n)}function Ni(e,t,n){if(n<F)throw new Error("Expected power > 0");if(n===F)return e.ONE;if(n===V)return t;let r=e.ONE,o=t;for(;n>F;)n&V&&(r=e.mul(r,o)),o=e.sqr(o),n>>=V;return r}function Li(e,t){const n=new Array(t.length),r=t.reduce((i,s,a)=>e.is0(s)?i:(n[a]=i,e.mul(i,s)),e.ONE),o=e.inv(r);return t.reduceRight((i,s,a)=>e.is0(s)?i:(n[a]=e.mul(i,n[a]),e.mul(i,s)),o),n}function mn(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ci(e,t,n=!1,r={}){if(e<=F)throw new Error(`Expected Fp ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=mn(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Ti(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:yn(o),ZERO:F,ONE:V,create:c=>Q(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return F<=c&&c<e},is0:c=>c===F,isOdd:c=>(c&V)===V,neg:c=>Q(-c,e),eql:(c,l)=>c===l,sqr:c=>Q(c*c,e),add:(c,l)=>Q(c+l,e),sub:(c,l)=>Q(c-l,e),mul:(c,l)=>Q(c*l,e),pow:(c,l)=>Ni(a,c,l),div:(c,l)=>Q(c*tn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>tn(c,e),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>Li(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>n?dr(c,i):Gt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return n?bn(c):Dt(c)}});return Object.freeze(a)}function ki(e,t,n=!1){e=at("privateHash",e);const r=e.length,o=mn(t).nByteLength+8;if(o<24||r<o||r>1024)throw new Error(`hashToPrivateScalar: expected ${o}-1024 bytes of input, got ${r}`);const i=n?bn(e):Dt(e);return Q(i,t-V)+V}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Oi=BigInt(0),qe=BigInt(1);function Ki(e,t){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=e.ZERO,a=o;for(;i>Oi;)i&qe&&(s=s.add(a)),a=a.double(),i>>=qe;return s},precomputeWindow(o,i){const{windows:s,windowSize:a}=r(i),c=[];let l=o,d=l;for(let f=0;f<s;f++){d=l,c.push(d);for(let b=1;b<a;b++)d=d.add(l),c.push(d);l=d.double()}return c},wNAF(o,i,s){const{windows:a,windowSize:c}=r(o);let l=e.ZERO,d=e.BASE;const f=BigInt(2**o-1),b=2**o,g=BigInt(o);for(let y=0;y<a;y++){const u=y*c;let h=Number(s&f);s>>=g,h>c&&(h-=b,s+=qe);const w=u,v=u+Math.abs(h)-1,x=y%2!==0,I=h<0;h===0?d=d.add(n(x,i[w])):l=l.add(n(I,i[v]))}return{p:l,f:d}},wNAFCached(o,i,s,a){const c=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&i.set(o,a(l))),this.wNAF(c,l,s)}}}function pr(e){return Hi(e.Fp),le(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...mn(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ri(e){const t=pr(e);le(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:qi,hexToBytes:Di}=Ai,Kt={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=Kt;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:qi(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=Kt,n=typeof e=="string"?Di(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=Kt._parseInt(n.subarray(2)),{d:s,l:a}=Kt._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(e){const t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const d=l.toString(16);return d.length&1?`0${d}`:d},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},wt=BigInt(0),ct=BigInt(1);BigInt(2);const jn=BigInt(3);BigInt(4);function Pi(e){const t=Ri(e),{Fp:n}=t,r=t.toBytes||((y,u,h)=>{const w=u.toAffine();return ae(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=t.fromBytes||(y=>{const u=y.subarray(1),h=n.fromBytes(u.subarray(0,n.BYTES)),w=n.fromBytes(u.subarray(n.BYTES,2*n.BYTES));return{x:h,y:w}});function i(y){const{a:u,b:h}=t,w=n.sqr(y),v=n.mul(w,y);return n.add(n.add(v,n.mul(y,u)),h)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(y){return typeof y=="bigint"&&wt<y&&y<t.n}function a(y){if(!s(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(y){const{allowedPrivateKeyLengths:u,nByteLength:h,wrapPrivateKey:w,n:v}=t;if(u&&typeof y!="bigint"){if(y instanceof Uint8Array&&(y=Yt(y)),typeof y!="string"||!u.includes(y.length))throw new Error("Invalid key");y=y.padStart(h*2,"0")}let x;try{x=typeof y=="bigint"?y:Dt(at("private key",y,h))}catch{throw new Error(`private key must be ${h} bytes, hex or bigint, not ${typeof y}`)}return w&&(x=Q(x,v)),a(x),x}const l=new Map;function d(y){if(!(y instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(u,h,w){if(this.px=u,this.py=h,this.pz=w,u==null||!n.isValid(u))throw new Error("x required");if(h==null||!n.isValid(h))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(u){const{x:h,y:w}=u||{};if(!u||!n.isValid(h)||!n.isValid(w))throw new Error("invalid affine point");if(u instanceof f)throw new Error("projective point not allowed");const v=x=>n.eql(x,n.ZERO);return v(h)&&v(w)?f.ZERO:new f(h,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){const h=n.invertBatch(u.map(w=>w.pz));return u.map((w,v)=>w.toAffine(h[v])).map(f.fromAffine)}static fromHex(u){const h=f.fromAffine(o(at("pointHex",u)));return h.assertValidity(),h}static fromPrivateKey(u){return f.BASE.multiply(c(u))}_setWindowSize(u){this._WINDOW_SIZE=u,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint)return;throw new Error("bad point: ZERO")}const{x:u,y:h}=this.toAffine();if(!n.isValid(u)||!n.isValid(h))throw new Error("bad point: x or y not FE");const w=n.sqr(h),v=i(u);if(!n.eql(w,v))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:u}=this.toAffine();if(n.isOdd)return!n.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){d(u);const{px:h,py:w,pz:v}=this,{px:x,py:I,pz:B}=u,E=n.eql(n.mul(h,B),n.mul(x,v)),A=n.eql(n.mul(w,B),n.mul(I,v));return E&&A}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:u,b:h}=t,w=n.mul(h,jn),{px:v,py:x,pz:I}=this;let B=n.ZERO,E=n.ZERO,A=n.ZERO,S=n.mul(v,v),C=n.mul(x,x),U=n.mul(I,I),T=n.mul(v,x);return T=n.add(T,T),A=n.mul(v,I),A=n.add(A,A),B=n.mul(u,A),E=n.mul(w,U),E=n.add(B,E),B=n.sub(C,E),E=n.add(C,E),E=n.mul(B,E),B=n.mul(T,B),A=n.mul(w,A),U=n.mul(u,U),T=n.sub(S,U),T=n.mul(u,T),T=n.add(T,A),A=n.add(S,S),S=n.add(A,S),S=n.add(S,U),S=n.mul(S,T),E=n.add(E,S),U=n.mul(x,I),U=n.add(U,U),S=n.mul(U,T),B=n.sub(B,S),A=n.mul(U,C),A=n.add(A,A),A=n.add(A,A),new f(B,E,A)}add(u){d(u);const{px:h,py:w,pz:v}=this,{px:x,py:I,pz:B}=u;let E=n.ZERO,A=n.ZERO,S=n.ZERO;const C=t.a,U=n.mul(t.b,jn);let T=n.mul(h,x),K=n.mul(w,I),R=n.mul(v,B),z=n.add(h,w),p=n.add(x,I);z=n.mul(z,p),p=n.add(T,K),z=n.sub(z,p),p=n.add(h,v);let m=n.add(x,B);return p=n.mul(p,m),m=n.add(T,R),p=n.sub(p,m),m=n.add(w,v),E=n.add(I,B),m=n.mul(m,E),E=n.add(K,R),m=n.sub(m,E),S=n.mul(C,p),E=n.mul(U,R),S=n.add(E,S),E=n.sub(K,S),S=n.add(K,S),A=n.mul(E,S),K=n.add(T,T),K=n.add(K,T),R=n.mul(C,R),p=n.mul(U,p),K=n.add(K,R),R=n.sub(T,R),R=n.mul(C,R),p=n.add(p,R),T=n.mul(K,p),A=n.add(A,T),T=n.mul(m,p),E=n.mul(z,E),E=n.sub(E,T),T=n.mul(z,K),S=n.mul(m,S),S=n.add(S,T),new f(E,A,S)}subtract(u){return this.add(u.negate())}is0(){return this.equals(f.ZERO)}wNAF(u){return g.wNAFCached(this,l,u,h=>{const w=n.invertBatch(h.map(v=>v.pz));return h.map((v,x)=>v.toAffine(w[x])).map(f.fromAffine)})}multiplyUnsafe(u){const h=f.ZERO;if(u===wt)return h;if(a(u),u===ct)return this;const{endo:w}=t;if(!w)return g.unsafeLadder(this,u);let{k1neg:v,k1:x,k2neg:I,k2:B}=w.splitScalar(u),E=h,A=h,S=this;for(;x>wt||B>wt;)x&ct&&(E=E.add(S)),B&ct&&(A=A.add(S)),S=S.double(),x>>=ct,B>>=ct;return v&&(E=E.negate()),I&&(A=A.negate()),A=new f(n.mul(A.px,w.beta),A.py,A.pz),E.add(A)}multiply(u){a(u);let h=u,w,v;const{endo:x}=t;if(x){const{k1neg:I,k1:B,k2neg:E,k2:A}=x.splitScalar(h);let{p:S,f:C}=this.wNAF(B),{p:U,f:T}=this.wNAF(A);S=g.constTimeNegate(I,S),U=g.constTimeNegate(E,U),U=new f(n.mul(U.px,x.beta),U.py,U.pz),w=S.add(U),v=C.add(T)}else{const{p:I,f:B}=this.wNAF(h);w=I,v=B}return f.normalizeZ([w,v])[0]}multiplyAndAddUnsafe(u,h,w){const v=f.BASE,x=(B,E)=>E===wt||E===ct||!B.equals(v)?B.multiplyUnsafe(E):B.multiply(E),I=x(this,h).add(x(u,w));return I.is0()?void 0:I}toAffine(u){const{px:h,py:w,pz:v}=this,x=this.is0();u==null&&(u=x?n.ONE:n.inv(v));const I=n.mul(h,u),B=n.mul(w,u),E=n.mul(v,u);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(E,n.ONE))throw new Error("invZ was invalid");return{x:I,y:B}}isTorsionFree(){const{h:u,isTorsionFree:h}=t;if(u===ct)return!0;if(h)return h(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:u,clearCofactor:h}=t;return u===ct?this:h?h(f,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return this.assertValidity(),r(f,this,u)}toHex(u=!0){return Yt(this.toRawBytes(u))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const b=t.nBitLength,g=Ki(f,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function ji(e){const t=pr(e);return le(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Vi(e){const t=ji(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(p){return wt<p&&p<n.ORDER}function a(p){return Q(p,r)}function c(p){return tn(p,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:b}=Pi({...t,toBytes(p,m,$){const N=m.toAffine(),H=n.toBytes(N.x),k=ae;return $?k(Uint8Array.from([m.hasEvenY()?2:3]),H):k(Uint8Array.from([4]),H,n.toBytes(N.y))},fromBytes(p){const m=p.length,$=p[0],N=p.subarray(1);if(m===o&&($===2||$===3)){const H=Dt(N);if(!s(H))throw new Error("Point is not on curve");const k=f(H);let q=n.sqrt(k);const D=(q&ct)===ct;return($&1)===1!==D&&(q=n.neg(q)),{x:H,y:q}}else if(m===i&&$===4){const H=n.fromBytes(N.subarray(0,n.BYTES)),k=n.fromBytes(N.subarray(n.BYTES,2*n.BYTES));return{x:H,y:k}}else throw new Error(`Point of length ${m} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),g=p=>Yt(Gt(p,t.nByteLength));function y(p){const m=r>>ct;return p>m}function u(p){return y(p)?a(-p):p}const h=(p,m,$)=>Dt(p.slice(m,$));class w{constructor(m,$,N){this.r=m,this.s=$,this.recovery=N,this.assertValidity()}static fromCompact(m){const $=t.nByteLength;return m=at("compactSignature",m,$*2),new w(h(m,0,$),h(m,$,2*$))}static fromDER(m){const{r:$,s:N}=Kt.toSig(at("DER",m));return new w($,N)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new w(this.r,this.s,m)}recoverPublicKey(m){const{r:$,s:N,recovery:H}=this,k=A(at("msgHash",m));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");const q=H===2||H===3?$+t.n:$;if(q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const D=H&1?"03":"02",Z=l.fromHex(D+g(q)),G=c(q),et=a(-k*G),ft=a(N*G),Y=l.BASE.multiplyAndAddUnsafe(Z,et,ft);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Wt(this.toDERHex())}toDERHex(){return Kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wt(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const v={isValidPrivateKey(p){try{return d(p),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const p=t.randomBytes(n.BYTES+8),m=ki(p,r);return Gt(m,t.nByteLength)},precompute(p=8,m=l.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function x(p,m=!0){return l.fromPrivateKey(p).toRawBytes(m)}function I(p){const m=p instanceof Uint8Array,$=typeof p=="string",N=(m||$)&&p.length;return m?N===o||N===i:$?N===2*o||N===2*i:p instanceof l}function B(p,m,$=!0){if(I(p))throw new Error("first arg must be private key");if(!I(m))throw new Error("second arg must be public key");return l.fromHex(m).multiply(d(p)).toRawBytes($)}const E=t.bits2int||function(p){const m=Dt(p),$=p.length*8-t.nBitLength;return $>0?m>>BigInt($):m},A=t.bits2int_modN||function(p){return a(E(p))},S=yn(t.nBitLength);function C(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(wt<=p&&p<S))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Gt(p,t.nByteLength)}function U(p,m,$=T){if(["recovered","canonical"].some(X=>X in $))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:H}=t;let{lowS:k,prehash:q,extraEntropy:D}=$;k==null&&(k=!0),p=at("msgHash",p),q&&(p=at("prehashed msgHash",N(p)));const Z=A(p),G=d(m),et=[C(G),C(Z)];if(D!=null){const X=D===!0?H(n.BYTES):D;et.push(at("extraEntropy",X,n.BYTES))}const ft=ae(...et),Y=Z;function Ut(X){const nt=E(X);if(!b(nt))return;const Qt=c(nt),rt=l.BASE.multiply(nt).toAffine(),j=a(rt.x);if(j===wt)return;const ot=a(Qt*a(Y+j*G));if(ot===wt)return;let te=(rt.x===j?0:2)|Number(rt.y&ct),ee=ot;return k&&y(ot)&&(ee=u(ot),te^=1),new w(j,ee,te)}return{seed:ft,k2sig:Ut}}const T={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function R(p,m,$=T){const{seed:N,k2sig:H}=U(p,m,$),k=t;return hr(k.hash.outputLen,k.nByteLength,k.hmac)(N,H)}l.BASE._setWindowSize(8);function z(p,m,$,N=K){var rt;const H=p;if(m=at("msgHash",m),$=at("publicKey",$),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:k,prehash:q}=N;let D,Z;try{if(typeof H=="string"||H instanceof Uint8Array)try{D=w.fromDER(H)}catch(j){if(!(j instanceof Kt.Err))throw j;D=w.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){const{r:j,s:ot}=H;D=new w(j,ot)}else throw new Error("PARSE");Z=l.fromHex($)}catch(j){if(j.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(k&&D.hasHighS())return!1;q&&(m=t.hash(m));const{r:G,s:et}=D,ft=A(m),Y=c(et),Ut=a(ft*Y),X=a(G*Y),nt=(rt=l.BASE.multiplyAndAddUnsafe(Z,Ut,X))==null?void 0:rt.toAffine();return nt?a(nt.x)===G:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:B,sign:R,verify:z,ProjectivePoint:l,Signature:w,utils:v}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function _i(e){return{hash:e,hmac:(t,...n)=>se(e,t,oe(...n)),randomBytes:ao}}function zi(e,t){const n=r=>Vi({...e,..._i(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gr=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Vn=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Fi=BigInt(1),en=BigInt(2),_n=(e,t)=>(e+t/en)/t;function Mi(e){const t=gr,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,d=l*l*e%t,f=it(d,n,t)*d%t,b=it(f,n,t)*d%t,g=it(b,en,t)*l%t,y=it(g,o,t)*g%t,u=it(y,i,t)*y%t,h=it(u,a,t)*u%t,w=it(h,c,t)*h%t,v=it(w,a,t)*u%t,x=it(v,n,t)*d%t,I=it(x,s,t)*y%t,B=it(I,r,t)*l%t,E=it(B,en,t);if(!nn.eql(nn.sqr(E),e))throw new Error("Cannot find square root");return E}const nn=Ci(gr,void 0,void 0,{sqrt:Mi}),pt=zi({a:BigInt(0),b:BigInt(7),Fp:nn,n:Vn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Vn,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Fi*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=_n(i*e,t),c=_n(-r*e,t);let l=Q(e-a*n-c*o,t),d=Q(-a*r-c*i,t);const f=l>s,b=d>s;if(f&&(l=t-l),b&&(d=t-d),l>s||d>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:b,k2:d}}}},Ae);BigInt(0);pt.ProjectivePoint;const we=pt.ProjectivePoint,De=ti(Ae);function zn(e){return BigInt(`0x${Zt(e)}`)}function Zi(e){return oo(e.toString(16).padStart(64,"0"))}const Gi=Qn("Bitcoin seed"),Pe={private:76066276,public:76067358},je=2147483648,Yi=e=>pi(Ae(e)),Wi=e=>qt(e).getUint32(0,!1),be=e=>{if(!Number.isSafeInteger(e)||e<0||e>2**32-1)throw new Error(`Invalid number=${e}. Should be from 0 to 2 ** 32 - 1`);const t=new Uint8Array(4);return qt(t).setUint32(0,e,!1),t};class kt{get fingerprint(){if(!this.pubHash)throw new Error("No publicKey set!");return Wi(this.pubHash)}get identifier(){return this.pubHash}get pubKeyHash(){return this.pubHash}get privateKey(){return this.privKeyBytes||null}get publicKey(){return this.pubKey||null}get privateExtendedKey(){const t=this.privateKey;if(!t)throw new Error("No private key");return De.encode(this.serialize(this.versions.private,oe(new Uint8Array([0]),t)))}get publicExtendedKey(){if(!this.pubKey)throw new Error("No public key");return De.encode(this.serialize(this.versions.public,this.pubKey))}static fromMasterSeed(t,n=Pe){if(Lt(t),8*t.length<128||8*t.length>512)throw new Error(`HDKey: wrong seed length=${t.length}. Should be between 128 and 512 bits; 256 bits is advised)`);const r=se(We,Gi,t);return new kt({versions:n,chainCode:r.slice(32),privateKey:r.slice(0,32)})}static fromExtendedKey(t,n=Pe){const r=De.decode(t),o=qt(r),i=o.getUint32(0,!1),s={versions:n,depth:r[4],parentFingerprint:o.getUint32(5,!1),index:o.getUint32(9,!1),chainCode:r.slice(13,45)},a=r.slice(45),c=a[0]===0;if(i!==n[c?"private":"public"])throw new Error("Version mismatch");return c?new kt({...s,privateKey:a.slice(1)}):new kt({...s,publicKey:a})}static fromJSON(t){return kt.fromExtendedKey(t.xpriv)}constructor(t){if(this.depth=0,this.index=0,this.chainCode=null,this.parentFingerprint=0,!t||typeof t!="object")throw new Error("HDKey.constructor must not be called directly");if(this.versions=t.versions||Pe,this.depth=t.depth||0,this.chainCode=t.chainCode,this.index=t.index||0,this.parentFingerprint=t.parentFingerprint||0,!this.depth&&(this.parentFingerprint||this.index))throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");if(t.publicKey&&t.privateKey)throw new Error("HDKey: publicKey and privateKey at same time.");if(t.privateKey){if(!pt.utils.isValidPrivateKey(t.privateKey))throw new Error("Invalid private key");this.privKey=typeof t.privateKey=="bigint"?t.privateKey:zn(t.privateKey),this.privKeyBytes=Zi(this.privKey),this.pubKey=pt.getPublicKey(t.privateKey,!0)}else if(t.publicKey)this.pubKey=we.fromHex(t.publicKey).toRawBytes(!0);else throw new Error("HDKey: no public or private key provided");this.pubHash=Yi(this.pubKey)}derive(t){if(!/^[mM]'?/.test(t))throw new Error('Path must start with "m" or "M"');if(/^[mM]'?$/.test(t))return this;const n=t.replace(/^[mM]'?\//,"").split("/");let r=this;for(const o of n){const i=/^(\d+)('?)$/.exec(o);if(!i||i.length!==3)throw new Error(`Invalid child index: ${o}`);let s=+i[1];if(!Number.isSafeInteger(s)||s>=je)throw new Error("Invalid index");i[2]==="'"&&(s+=je),r=r.deriveChild(s)}return r}deriveChild(t){if(!this.pubKey||!this.chainCode)throw new Error("No publicKey or chainCode set");let n=be(t);if(t>=je){const a=this.privateKey;if(!a)throw new Error("Could not derive hardened child key");n=oe(new Uint8Array([0]),a,n)}else n=oe(this.pubKey,n);const r=se(We,this.chainCode,n),o=zn(r.slice(0,32)),i=r.slice(32);if(!pt.utils.isValidPrivateKey(o))throw new Error("Tweak bigger than curve order");const s={versions:this.versions,chainCode:i,depth:this.depth+1,parentFingerprint:this.fingerprint,index:t};try{if(this.privateKey){const a=Q(this.privKey+o,pt.CURVE.n);if(!pt.utils.isValidPrivateKey(a))throw new Error("The tweak was out of range or the resulted private key is invalid");s.privateKey=a}else{const a=we.fromHex(this.pubKey).add(we.fromPrivateKey(o));if(a.equals(we.ZERO))throw new Error("The tweak was equal to negative P, which made the result key invalid");s.publicKey=a.toRawBytes(!0)}return new kt(s)}catch{return this.deriveChild(t+1)}}sign(t){if(!this.privateKey)throw new Error("No privateKey set!");return Lt(t,32),pt.sign(t,this.privKey).toCompactRawBytes()}verify(t,n){if(Lt(t,32),Lt(n,64),!this.publicKey)throw new Error("No publicKey set!");let r;try{r=pt.Signature.fromCompact(n)}catch{return!1}return pt.verify(r,t,this.publicKey)}wipePrivateData(){return this.privKey=void 0,this.privKeyBytes&&(this.privKeyBytes.fill(0),this.privKeyBytes=void 0),this}toJSON(){return{xpriv:this.privateExtendedKey,xpub:this.publicExtendedKey}}serialize(t,n){if(!this.chainCode)throw new Error("No chainCode set");return Lt(n,33),oe(be(t),new Uint8Array([this.depth]),be(this.parentFingerprint),be(this.index),this.chainCode,n)}}var Ji="m/44'/1237'";function Fn(e,t,n=0){const o=kt.fromMasterSeed(si(e,t)).derive(`${Ji}/${n}'/0/0`),i=Zt(o.publicKey.slice(1)),s=o.privateKey;if(!s||!i)throw new Error("could not derive key pair");return{privateKey:s,publicKey:i}}function Mn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function wr(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Xi(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mn(e.outputLen),Mn(e.blockLen)}function xe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Qi(e,t){wr(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Ve=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const br=e=>e instanceof Uint8Array,_e=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),ht=(e,t)=>e<<32-t|e>>>t,ts=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ts)throw new Error("Non little-endian hardware is not supported");function es(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function xn(e){if(typeof e=="string"&&(e=es(e)),!br(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function ns(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!br(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}class yr{clone(){return this._cloneInto()}}function rs(e){const t=r=>e().update(xn(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function mr(e=32){if(Ve&&typeof Ve.getRandomValues=="function")return Ve.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}function os(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}class is extends yr{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=_e(this.buffer)}update(t){xe(this);const{view:n,buffer:r,blockLen:o}=this;t=xn(t);const i=t.length;for(let s=0;s<i;){const a=Math.min(o-this.pos,i-s);if(a===o){const c=_e(t);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xe(this),Qi(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let f=s;f<o;f++)n[f]=0;os(r,o-8,BigInt(this.length*8),i),this.process(r,0);const a=_e(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,d[f],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}}const ss=(e,t,n)=>e&t^~e&n,as=(e,t,n)=>e&t^e&n^t&n,cs=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),St=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),It=new Uint32Array(64);class ls extends is{constructor(){super(64,32,8,!1),this.A=St[0]|0,this.B=St[1]|0,this.C=St[2]|0,this.D=St[3]|0,this.E=St[4]|0,this.F=St[5]|0,this.G=St[6]|0,this.H=St[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[t,n,r,o,i,s,a,c]}set(t,n,r,o,i,s,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,n){for(let f=0;f<16;f++,n+=4)It[f]=t.getUint32(n,!1);for(let f=16;f<64;f++){const b=It[f-15],g=It[f-2],y=ht(b,7)^ht(b,18)^b>>>3,u=ht(g,17)^ht(g,19)^g>>>10;It[f]=u+It[f-7]+y+It[f-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:l,H:d}=this;for(let f=0;f<64;f++){const b=ht(a,6)^ht(a,11)^ht(a,25),g=d+b+ss(a,c,l)+cs[f]+It[f]|0,u=(ht(r,2)^ht(r,13)^ht(r,22))+as(r,o,i)|0;d=l,l=c,c=a,a=s+g|0,s=i,i=o,o=r,r=g+u|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,o,i,s,a,c,l,d)}roundClean(){It.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const rn=rs(()=>new ls);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const xr=BigInt(0),Ue=BigInt(1),fs=BigInt(2),He=e=>e instanceof Uint8Array,us=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Jt(e){if(!He(e))throw new Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=us[e[n]];return t}function Er(e){const t=e.toString(16);return t.length&1?`0${t}`:t}function En(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}function Xt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(t/2);for(let r=0;r<n.length;r++){const o=r*2,i=e.slice(o,o+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");n[r]=s}return n}function tt(e){return En(Jt(e))}function vn(e){if(!He(e))throw new Error("Uint8Array expected");return En(Jt(Uint8Array.from(e).reverse()))}function $t(e,t){return Xt(e.toString(16).padStart(t*2,"0"))}function Bn(e,t){return $t(e,t).reverse()}function ds(e){return Xt(Er(e))}function J(e,t,n){let r;if(typeof t=="string")try{r=Xt(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else if(He(t))r=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function Pt(...e){const t=new Uint8Array(e.reduce((r,o)=>r+o.length,0));let n=0;return e.forEach(r=>{if(!He(r))throw new Error("Uint8Array expected");t.set(r,n),n+=r.length}),t}function hs(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ps(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function gs(e){let t;for(t=0;e>xr;e>>=Ue,t+=1);return t}function ws(e,t){return e>>BigInt(t)&Ue}const bs=(e,t,n)=>e|(n?Ue:xr)<<BigInt(t),An=e=>(fs<<BigInt(e-1))-Ue,ze=e=>new Uint8Array(e),Zn=e=>Uint8Array.from(e);function vr(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=ze(e),o=ze(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=(...f)=>n(o,r,...f),c=(f=ze())=>{o=a(Zn([0]),f),r=a(),f.length!==0&&(o=a(Zn([1]),f),r=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const b=[];for(;f<t;){r=a();const g=r.slice();b.push(g),f+=r.length}return Pt(...b)};return(f,b)=>{s(),c(f);let g;for(;!(g=b(l()));)c();return s(),g}}const ys={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function fe(e,t,n={}){const r=(o,i,s)=>{const a=ys[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const ms=Object.freeze(Object.defineProperty({__proto__:null,bitGet:ws,bitLen:gs,bitMask:An,bitSet:bs,bytesToHex:Jt,bytesToNumberBE:tt,bytesToNumberLE:vn,concatBytes:Pt,createHmacDrbg:vr,ensureBytes:J,equalBytes:hs,hexToBytes:Xt,hexToNumber:En,numberToBytesBE:$t,numberToBytesLE:Bn,numberToHexUnpadded:Er,numberToVarBytesBE:ds,utf8ToBytes:ps,validateObject:fe},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const M=BigInt(0),_=BigInt(1),Ot=BigInt(2),xs=BigInt(3),on=BigInt(4),Gn=BigInt(5),Yn=BigInt(8);BigInt(9);BigInt(16);function W(e,t){const n=e%t;return n>=M?n:t+n}function Es(e,t,n){if(n<=M||t<M)throw new Error("Expected power/modulo > 0");if(n===_)return M;let r=_;for(;t>M;)t&_&&(r=r*e%n),e=e*e%n,t>>=_;return r}function st(e,t,n){let r=e;for(;t-- >M;)r*=r,r%=n;return r}function sn(e,t){if(e===M||t<=M)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=W(e,t),r=t,o=M,i=_;for(;n!==M;){const a=r/n,c=r%n,l=o-i*a;r=n,n=c,o=i,i=l}if(r!==_)throw new Error("invert: does not exist");return W(o,t)}function vs(e){const t=(e-_)/Ot;let n,r,o;for(n=e-_,r=0;n%Ot===M;n/=Ot,r++);for(o=Ot;o<e&&Es(o,t,e)!==e-_;o++);if(r===1){const s=(e+_)/on;return function(c,l){const d=c.pow(l,s);if(!c.eql(c.sqr(d),l))throw new Error("Cannot find square root");return d}}const i=(n+_)/Ot;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=r,d=a.pow(a.mul(a.ONE,o),n),f=a.pow(c,i),b=a.pow(c,n);for(;!a.eql(b,a.ONE);){if(a.eql(b,a.ZERO))return a.ZERO;let g=1;for(let u=a.sqr(b);g<l&&!a.eql(u,a.ONE);g++)u=a.sqr(u);const y=a.pow(d,_<<BigInt(l-g-1));d=a.sqr(y),f=a.mul(f,y),b=a.mul(b,d),l=g}return f}}function Bs(e){if(e%on===xs){const t=(e+_)/on;return function(r,o){const i=r.pow(o,t);if(!r.eql(r.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%Yn===Gn){const t=(e-Gn)/Yn;return function(r,o){const i=r.mul(o,Ot),s=r.pow(i,t),a=r.mul(o,s),c=r.mul(r.mul(a,Ot),s),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),o))throw new Error("Cannot find square root");return l}}return vs(e)}const As=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ss(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=As.reduce((r,o)=>(r[o]="function",r),t);return fe(e,n)}function Is(e,t,n){if(n<M)throw new Error("Expected power > 0");if(n===M)return e.ONE;if(n===_)return t;let r=e.ONE,o=t;for(;n>M;)n&_&&(r=e.mul(r,o)),o=e.sqr(o),n>>=_;return r}function $s(e,t){const n=new Array(t.length),r=t.reduce((i,s,a)=>e.is0(s)?i:(n[a]=i,e.mul(i,s)),e.ONE),o=e.inv(r);return t.reduceRight((i,s,a)=>e.is0(s)?i:(n[a]=e.mul(i,n[a]),e.mul(i,s)),o),n}function Br(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ts(e,t,n=!1,r={}){if(e<=M)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Br(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Bs(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:An(o),ZERO:M,ONE:_,create:c=>W(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return M<=c&&c<e},is0:c=>c===M,isOdd:c=>(c&_)===_,neg:c=>W(-c,e),eql:(c,l)=>c===l,sqr:c=>W(c*c,e),add:(c,l)=>W(c+l,e),sub:(c,l)=>W(c-l,e),mul:(c,l)=>W(c*l,e),pow:(c,l)=>Is(a,c,l),div:(c,l)=>W(c*sn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>sn(c,e),sqrt:r.sqrt||(c=>s(a,c)),invertBatch:c=>$s(a,c),cmov:(c,l,d)=>d?l:c,toBytes:c=>n?Bn(c,i):$t(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return n?vn(c):tt(c)}});return Object.freeze(a)}function Ar(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Sr(e){const t=Ar(e);return t+Math.ceil(t/2)}function Us(e,t,n=!1){const r=e.length,o=Ar(t),i=Sr(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=n?tt(e):vn(e),a=W(s,t-_)+_;return n?Bn(a,o):$t(a,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hs=BigInt(0),Fe=BigInt(1);function Ns(e,t){const n=(o,i)=>{const s=i.negate();return o?s:i},r=o=>{const i=Math.ceil(t/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:n,unsafeLadder(o,i){let s=e.ZERO,a=o;for(;i>Hs;)i&Fe&&(s=s.add(a)),a=a.double(),i>>=Fe;return s},precomputeWindow(o,i){const{windows:s,windowSize:a}=r(i),c=[];let l=o,d=l;for(let f=0;f<s;f++){d=l,c.push(d);for(let b=1;b<a;b++)d=d.add(l),c.push(d);l=d.double()}return c},wNAF(o,i,s){const{windows:a,windowSize:c}=r(o);let l=e.ZERO,d=e.BASE;const f=BigInt(2**o-1),b=2**o,g=BigInt(o);for(let y=0;y<a;y++){const u=y*c;let h=Number(s&f);s>>=g,h>c&&(h-=b,s+=Fe);const w=u,v=u+Math.abs(h)-1,x=y%2!==0,I=h<0;h===0?d=d.add(n(x,i[w])):l=l.add(n(I,i[v]))}return{p:l,f:d}},wNAFCached(o,i,s,a){const c=o._WINDOW_SIZE||1;let l=i.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&i.set(o,a(l))),this.wNAF(c,l,s)}}}function Ir(e){return Ss(e.Fp),fe(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Br(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ls(e){const t=Ir(e);fe(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}const{bytesToNumberBE:Cs,hexToBytes:ks}=ms,Rt={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(e){const{Err:t}=Rt;if(e.length<2||e[0]!==2)throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Cs(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=Rt,n=typeof e=="string"?ks(e):e;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let r=n.length;if(r<2||n[0]!=48)throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:o,l:i}=Rt._parseInt(n.subarray(2)),{d:s,l:a}=Rt._parseInt(i);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(e){const t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,n=l=>{const d=l.toString(16);return d.length&1?`0${d}`:d},r=t(n(e.s)),o=t(n(e.r)),i=r.length/2,s=o.length/2,a=n(i),c=n(s);return`30${n(s+i+4)}02${c}${o}02${a}${r}`}},bt=BigInt(0),lt=BigInt(1);BigInt(2);const Wn=BigInt(3);BigInt(4);function Os(e){const t=Ls(e),{Fp:n}=t,r=t.toBytes||((y,u,h)=>{const w=u.toAffine();return Pt(Uint8Array.from([4]),n.toBytes(w.x),n.toBytes(w.y))}),o=t.fromBytes||(y=>{const u=y.subarray(1),h=n.fromBytes(u.subarray(0,n.BYTES)),w=n.fromBytes(u.subarray(n.BYTES,2*n.BYTES));return{x:h,y:w}});function i(y){const{a:u,b:h}=t,w=n.sqr(y),v=n.mul(w,y);return n.add(n.add(v,n.mul(y,u)),h)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function s(y){return typeof y=="bigint"&&bt<y&&y<t.n}function a(y){if(!s(y))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(y){const{allowedPrivateKeyLengths:u,nByteLength:h,wrapPrivateKey:w,n:v}=t;if(u&&typeof y!="bigint"){if(y instanceof Uint8Array&&(y=Jt(y)),typeof y!="string"||!u.includes(y.length))throw new Error("Invalid key");y=y.padStart(h*2,"0")}let x;try{x=typeof y=="bigint"?y:tt(J("private key",y,h))}catch{throw new Error(`private key must be ${h} bytes, hex or bigint, not ${typeof y}`)}return w&&(x=W(x,v)),a(x),x}const l=new Map;function d(y){if(!(y instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(u,h,w){if(this.px=u,this.py=h,this.pz=w,u==null||!n.isValid(u))throw new Error("x required");if(h==null||!n.isValid(h))throw new Error("y required");if(w==null||!n.isValid(w))throw new Error("z required")}static fromAffine(u){const{x:h,y:w}=u||{};if(!u||!n.isValid(h)||!n.isValid(w))throw new Error("invalid affine point");if(u instanceof f)throw new Error("projective point not allowed");const v=x=>n.eql(x,n.ZERO);return v(h)&&v(w)?f.ZERO:new f(h,w,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){const h=n.invertBatch(u.map(w=>w.pz));return u.map((w,v)=>w.toAffine(h[v])).map(f.fromAffine)}static fromHex(u){const h=f.fromAffine(o(J("pointHex",u)));return h.assertValidity(),h}static fromPrivateKey(u){return f.BASE.multiply(c(u))}_setWindowSize(u){this._WINDOW_SIZE=u,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:u,y:h}=this.toAffine();if(!n.isValid(u)||!n.isValid(h))throw new Error("bad point: x or y not FE");const w=n.sqr(h),v=i(u);if(!n.eql(w,v))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:u}=this.toAffine();if(n.isOdd)return!n.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){d(u);const{px:h,py:w,pz:v}=this,{px:x,py:I,pz:B}=u,E=n.eql(n.mul(h,B),n.mul(x,v)),A=n.eql(n.mul(w,B),n.mul(I,v));return E&&A}negate(){return new f(this.px,n.neg(this.py),this.pz)}double(){const{a:u,b:h}=t,w=n.mul(h,Wn),{px:v,py:x,pz:I}=this;let B=n.ZERO,E=n.ZERO,A=n.ZERO,S=n.mul(v,v),C=n.mul(x,x),U=n.mul(I,I),T=n.mul(v,x);return T=n.add(T,T),A=n.mul(v,I),A=n.add(A,A),B=n.mul(u,A),E=n.mul(w,U),E=n.add(B,E),B=n.sub(C,E),E=n.add(C,E),E=n.mul(B,E),B=n.mul(T,B),A=n.mul(w,A),U=n.mul(u,U),T=n.sub(S,U),T=n.mul(u,T),T=n.add(T,A),A=n.add(S,S),S=n.add(A,S),S=n.add(S,U),S=n.mul(S,T),E=n.add(E,S),U=n.mul(x,I),U=n.add(U,U),S=n.mul(U,T),B=n.sub(B,S),A=n.mul(U,C),A=n.add(A,A),A=n.add(A,A),new f(B,E,A)}add(u){d(u);const{px:h,py:w,pz:v}=this,{px:x,py:I,pz:B}=u;let E=n.ZERO,A=n.ZERO,S=n.ZERO;const C=t.a,U=n.mul(t.b,Wn);let T=n.mul(h,x),K=n.mul(w,I),R=n.mul(v,B),z=n.add(h,w),p=n.add(x,I);z=n.mul(z,p),p=n.add(T,K),z=n.sub(z,p),p=n.add(h,v);let m=n.add(x,B);return p=n.mul(p,m),m=n.add(T,R),p=n.sub(p,m),m=n.add(w,v),E=n.add(I,B),m=n.mul(m,E),E=n.add(K,R),m=n.sub(m,E),S=n.mul(C,p),E=n.mul(U,R),S=n.add(E,S),E=n.sub(K,S),S=n.add(K,S),A=n.mul(E,S),K=n.add(T,T),K=n.add(K,T),R=n.mul(C,R),p=n.mul(U,p),K=n.add(K,R),R=n.sub(T,R),R=n.mul(C,R),p=n.add(p,R),T=n.mul(K,p),A=n.add(A,T),T=n.mul(m,p),E=n.mul(z,E),E=n.sub(E,T),T=n.mul(z,K),S=n.mul(m,S),S=n.add(S,T),new f(E,A,S)}subtract(u){return this.add(u.negate())}is0(){return this.equals(f.ZERO)}wNAF(u){return g.wNAFCached(this,l,u,h=>{const w=n.invertBatch(h.map(v=>v.pz));return h.map((v,x)=>v.toAffine(w[x])).map(f.fromAffine)})}multiplyUnsafe(u){const h=f.ZERO;if(u===bt)return h;if(a(u),u===lt)return this;const{endo:w}=t;if(!w)return g.unsafeLadder(this,u);let{k1neg:v,k1:x,k2neg:I,k2:B}=w.splitScalar(u),E=h,A=h,S=this;for(;x>bt||B>bt;)x<&&(E=E.add(S)),B<&&(A=A.add(S)),S=S.double(),x>>=lt,B>>=lt;return v&&(E=E.negate()),I&&(A=A.negate()),A=new f(n.mul(A.px,w.beta),A.py,A.pz),E.add(A)}multiply(u){a(u);let h=u,w,v;const{endo:x}=t;if(x){const{k1neg:I,k1:B,k2neg:E,k2:A}=x.splitScalar(h);let{p:S,f:C}=this.wNAF(B),{p:U,f:T}=this.wNAF(A);S=g.constTimeNegate(I,S),U=g.constTimeNegate(E,U),U=new f(n.mul(U.px,x.beta),U.py,U.pz),w=S.add(U),v=C.add(T)}else{const{p:I,f:B}=this.wNAF(h);w=I,v=B}return f.normalizeZ([w,v])[0]}multiplyAndAddUnsafe(u,h,w){const v=f.BASE,x=(B,E)=>E===bt||E===lt||!B.equals(v)?B.multiplyUnsafe(E):B.multiply(E),I=x(this,h).add(x(u,w));return I.is0()?void 0:I}toAffine(u){const{px:h,py:w,pz:v}=this,x=this.is0();u==null&&(u=x?n.ONE:n.inv(v));const I=n.mul(h,u),B=n.mul(w,u),E=n.mul(v,u);if(x)return{x:n.ZERO,y:n.ZERO};if(!n.eql(E,n.ONE))throw new Error("invZ was invalid");return{x:I,y:B}}isTorsionFree(){const{h:u,isTorsionFree:h}=t;if(u===lt)return!0;if(h)return h(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:u,clearCofactor:h}=t;return u===lt?this:h?h(f,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return this.assertValidity(),r(f,this,u)}toHex(u=!0){return Jt(this.toRawBytes(u))}}f.BASE=new f(t.Gx,t.Gy,n.ONE),f.ZERO=new f(n.ZERO,n.ONE,n.ZERO);const b=t.nBitLength,g=Ns(f,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:f,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Ks(e){const t=Ir(e);return fe(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Rs(e){const t=Ks(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(p){return bt<p&&p<n.ORDER}function a(p){return W(p,r)}function c(p){return sn(p,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:d,weierstrassEquation:f,isWithinCurveOrder:b}=Os({...t,toBytes(p,m,$){const N=m.toAffine(),H=n.toBytes(N.x),k=Pt;return $?k(Uint8Array.from([m.hasEvenY()?2:3]),H):k(Uint8Array.from([4]),H,n.toBytes(N.y))},fromBytes(p){const m=p.length,$=p[0],N=p.subarray(1);if(m===o&&($===2||$===3)){const H=tt(N);if(!s(H))throw new Error("Point is not on curve");const k=f(H);let q=n.sqrt(k);const D=(q<)===lt;return($&1)===1!==D&&(q=n.neg(q)),{x:H,y:q}}else if(m===i&&$===4){const H=n.fromBytes(N.subarray(0,n.BYTES)),k=n.fromBytes(N.subarray(n.BYTES,2*n.BYTES));return{x:H,y:k}}else throw new Error(`Point of length ${m} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),g=p=>Jt($t(p,t.nByteLength));function y(p){const m=r>>lt;return p>m}function u(p){return y(p)?a(-p):p}const h=(p,m,$)=>tt(p.slice(m,$));class w{constructor(m,$,N){this.r=m,this.s=$,this.recovery=N,this.assertValidity()}static fromCompact(m){const $=t.nByteLength;return m=J("compactSignature",m,$*2),new w(h(m,0,$),h(m,$,2*$))}static fromDER(m){const{r:$,s:N}=Rt.toSig(J("DER",m));return new w($,N)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new w(this.r,this.s,m)}recoverPublicKey(m){const{r:$,s:N,recovery:H}=this,k=A(J("msgHash",m));if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");const q=H===2||H===3?$+t.n:$;if(q>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const D=H&1?"03":"02",Z=l.fromHex(D+g(q)),G=c(q),et=a(-k*G),ft=a(N*G),Y=l.BASE.multiplyAndAddUnsafe(Z,et,ft);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Xt(this.toDERHex())}toDERHex(){return Rt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xt(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}const v={isValidPrivateKey(p){try{return d(p),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const p=Sr(t.n);return Us(t.randomBytes(p),t.n)},precompute(p=8,m=l.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function x(p,m=!0){return l.fromPrivateKey(p).toRawBytes(m)}function I(p){const m=p instanceof Uint8Array,$=typeof p=="string",N=(m||$)&&p.length;return m?N===o||N===i:$?N===2*o||N===2*i:p instanceof l}function B(p,m,$=!0){if(I(p))throw new Error("first arg must be private key");if(!I(m))throw new Error("second arg must be public key");return l.fromHex(m).multiply(d(p)).toRawBytes($)}const E=t.bits2int||function(p){const m=tt(p),$=p.length*8-t.nBitLength;return $>0?m>>BigInt($):m},A=t.bits2int_modN||function(p){return a(E(p))},S=An(t.nBitLength);function C(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(bt<=p&&p<S))throw new Error(`bigint expected < 2^${t.nBitLength}`);return $t(p,t.nByteLength)}function U(p,m,$=T){if(["recovered","canonical"].some(X=>X in $))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:H}=t;let{lowS:k,prehash:q,extraEntropy:D}=$;k==null&&(k=!0),p=J("msgHash",p),q&&(p=J("prehashed msgHash",N(p)));const Z=A(p),G=d(m),et=[C(G),C(Z)];if(D!=null){const X=D===!0?H(n.BYTES):D;et.push(J("extraEntropy",X))}const ft=Pt(...et),Y=Z;function Ut(X){const nt=E(X);if(!b(nt))return;const Qt=c(nt),rt=l.BASE.multiply(nt).toAffine(),j=a(rt.x);if(j===bt)return;const ot=a(Qt*a(Y+j*G));if(ot===bt)return;let te=(rt.x===j?0:2)|Number(rt.y<),ee=ot;return k&&y(ot)&&(ee=u(ot),te^=1),new w(j,ee,te)}return{seed:ft,k2sig:Ut}}const T={lowS:t.lowS,prehash:!1},K={lowS:t.lowS,prehash:!1};function R(p,m,$=T){const{seed:N,k2sig:H}=U(p,m,$),k=t;return vr(k.hash.outputLen,k.nByteLength,k.hmac)(N,H)}l.BASE._setWindowSize(8);function z(p,m,$,N=K){var rt;const H=p;if(m=J("msgHash",m),$=J("publicKey",$),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:k,prehash:q}=N;let D,Z;try{if(typeof H=="string"||H instanceof Uint8Array)try{D=w.fromDER(H)}catch(j){if(!(j instanceof Rt.Err))throw j;D=w.fromCompact(H)}else if(typeof H=="object"&&typeof H.r=="bigint"&&typeof H.s=="bigint"){const{r:j,s:ot}=H;D=new w(j,ot)}else throw new Error("PARSE");Z=l.fromHex($)}catch(j){if(j.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(k&&D.hasHighS())return!1;q&&(m=t.hash(m));const{r:G,s:et}=D,ft=A(m),Y=c(et),Ut=a(ft*Y),X=a(G*Y),nt=(rt=l.BASE.multiplyAndAddUnsafe(Z,Ut,X))==null?void 0:rt.toAffine();return nt?a(nt.x)===G:!1}return{CURVE:t,getPublicKey:x,getSharedSecret:B,sign:R,verify:z,ProjectivePoint:l,Signature:w,utils:v}}class $r extends yr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Xi(t);const r=xn(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return xe(this),this.iHash.update(t),this}digestInto(t){xe(this),wr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Tr=(e,t,n)=>new $r(e,t).update(n).digest();Tr.create=(e,t)=>new $r(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qs(e){return{hash:e,hmac:(t,...n)=>Tr(e,t,ns(...n)),randomBytes:mr}}function Ds(e,t){const n=r=>Rs({...e,...qs(r)});return Object.freeze({...n(t),create:n})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ne=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ee=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ur=BigInt(1),ve=BigInt(2),Jn=(e,t)=>(e+t/ve)/t;function Hr(e){const t=Ne,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,d=l*l*e%t,f=st(d,n,t)*d%t,b=st(f,n,t)*d%t,g=st(b,ve,t)*l%t,y=st(g,o,t)*g%t,u=st(y,i,t)*y%t,h=st(u,a,t)*u%t,w=st(h,c,t)*h%t,v=st(w,a,t)*u%t,x=st(v,n,t)*d%t,I=st(x,s,t)*y%t,B=st(I,r,t)*l%t,E=st(B,ve,t);if(!an.eql(an.sqr(E),e))throw new Error("Cannot find square root");return E}const an=Ts(Ne,void 0,void 0,{sqrt:Hr}),Sn=Ds({a:BigInt(0),b:BigInt(7),Fp:an,n:Ee,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Ee,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ur*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=Jn(i*e,t),c=Jn(-r*e,t);let l=W(e-a*n-c*o,t),d=W(-a*r-c*i,t);const f=l>s,b=d>s;if(f&&(l=t-l),b&&(d=t-d),l>s||d>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:b,k2:d}}}},rn),Le=BigInt(0),Nr=e=>typeof e=="bigint"&&Le<e&&e<Ne,Ps=e=>typeof e=="bigint"&&Le<e&&e<Ee,Xn={};function Be(e,...t){let n=Xn[e];if(n===void 0){const r=rn(Uint8Array.from(e,o=>o.charCodeAt(0)));n=Pt(r,r),Xn[e]=n}return rn(Pt(n,...t))}const In=e=>e.toRawBytes(!0).slice(1),cn=e=>$t(e,32),Me=e=>W(e,Ne),ce=e=>W(e,Ee),$n=Sn.ProjectivePoint,js=(e,t,n)=>$n.BASE.multiplyAndAddUnsafe(e,t,n);function ln(e){let t=Sn.utils.normPrivateKeyToScalar(e),n=$n.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:ce(-t),bytes:In(n)}}function Lr(e){if(!Nr(e))throw new Error("bad x: need 0 < x < p");const t=Me(e*e),n=Me(t*e+BigInt(7));let r=Hr(n);r%ve!==Le&&(r=Me(-r));const o=new $n(e,r,Ur);return o.assertValidity(),o}function Cr(...e){return ce(tt(Be("BIP0340/challenge",...e)))}function Vs(e){return ln(e).bytes}function _s(e,t,n=mr(32)){const r=J("message",e),{bytes:o,scalar:i}=ln(t),s=J("auxRand",n,32),a=cn(i^tt(Be("BIP0340/aux",s))),c=Be("BIP0340/nonce",a,o,r),l=ce(tt(c));if(l===Le)throw new Error("sign failed: k is zero");const{bytes:d,scalar:f}=ln(l),b=Cr(d,o,r),g=new Uint8Array(64);if(g.set(d,0),g.set(cn(ce(f+b*i)),32),!kr(g,r,o))throw new Error("sign: Invalid signature produced");return g}function kr(e,t,n){const r=J("signature",e,64),o=J("message",t),i=J("publicKey",n,32);try{const s=Lr(tt(i)),a=tt(r.subarray(0,32));if(!Nr(a))return!1;const c=tt(r.subarray(32,64));if(!Ps(c))return!1;const l=Cr(cn(a),In(s),o),d=js(s,c,ce(-l));return!(!d||!d.hasEvenY()||d.toAffine().x!==a)}catch{return!1}}const re={getPublicKey:Vs,sign:_s,verify:kr,utils:{randomPrivateKey:Sn.utils.randomPrivateKey,lift_x:Lr,pointToBytes:In,numberToBytesBE:$t,bytesToNumberBE:tt,taggedHash:Be,mod:W}};var Mt=Symbol("verified"),zs=e=>e instanceof Object;function Fs(e){if(!zs(e)||typeof e.kind!="number"||typeof e.content!="string"||typeof e.created_at!="number"||typeof e.pubkey!="string"||!e.pubkey.match(/^[a-f0-9]{64}$/)||!Array.isArray(e.tags))return!1;for(let t=0;t<e.tags.length;t++){let n=e.tags[t];if(!Array.isArray(n))return!1;for(let r=0;r<n.length;r++)if(typeof n[r]=="object")return!1}return!0}new TextDecoder("utf-8");var Ms=new TextEncoder,Zs=class{generateSecretKey(){return re.utils.randomPrivateKey()}getPublicKey(e){return Zt(re.getPublicKey(e))}finalizeEvent(e,t){const n=e;return n.pubkey=Zt(re.getPublicKey(t)),n.id=Ze(n),n.sig=Zt(re.sign(Ze(n),t)),n[Mt]=!0,n}verifyEvent(e){if(typeof e[Mt]=="boolean")return e[Mt];const t=Ze(e);if(t!==e.id)return e[Mt]=!1,!1;try{const n=re.verify(e.sig,t,e.pubkey);return e[Mt]=n,n}catch{return e[Mt]=!1,!1}}};function Or(e){if(!Fs(e))throw new Error("can't serialize event with wrong or missing properties");return JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content])}function Ze(e){let t=Ae(Ms.encode(Or(e)));return Zt(t)}var Ce=new Zs;Ce.generateSecretKey;Ce.getPublicKey;var Gs=Ce.finalizeEvent;Ce.verifyEvent;var Ys=Object.defineProperty,Ws=Object.getOwnPropertyDescriptor,Js=(e,t,n,r)=>{for(var o=r>1?void 0:r?Ws(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(o=(r?s(t,n,o):s(o))||o);return r&&o&&Ys(t,n,o),o};let fn=class extends _r{constructor(){super(...arguments);P(this,"$notify");P(this,"activeDid","");P(this,"agentDid","");P(this,"apiServer","");P(this,"errorMessage","");P(this,"fullClaim",{"@context":"https://schema.org","@type":"PlanAction",name:"",description:""});P(this,"imageUrl","");P(this,"includeLocation",!1);P(this,"isHiddenSave",!1);P(this,"isHiddenSpinner",!0);P(this,"lastClaimJwtId","");P(this,"latitude",0);P(this,"longitude",0);P(this,"numAccounts",0);P(this,"projectId","");P(this,"projectIssuerDid","");P(this,"sendToTrustroots",!1);P(this,"sendToTripHopping",!1);P(this,"showGeneralAdvanced",!1);P(this,"startDateInput");P(this,"startTimeInput");P(this,"zoneName",Tn.local().zoneName);P(this,"zoom",2)}errNote(n){this.$notify({group:"alert",type:"danger",title:"Error",text:n},5e3)}async mounted(){this.numAccounts=await qr();const n=await Un();this.activeDid=n.activeDid||"",this.apiServer=n.apiServer||"",this.showGeneralAdvanced=!!n.showGeneralAdvanced,this.projectId=this.$route.query.projectId||"",this.projectId&&(this.numAccounts===0?this.errNote("There was a problem loading your account info."):this.loadProject(this.activeDid))}async loadProject(n){var i,s,a;const r=this.apiServer+"/api/claim/byHandle/"+encodeURIComponent(this.projectId),o=await ue(n);try{const c=await this.axios.get(r,{headers:o});if(c.status===200&&(this.projectIssuerDid=c.data.issuer,this.fullClaim=c.data.claim,this.imageUrl=c.data.claim.image||"",this.lastClaimJwtId=c.data.id,(i=this.fullClaim)!=null&&i.location&&(this.includeLocation=!0,this.latitude=this.fullClaim.location.geo.latitude,this.longitude=this.fullClaim.location.geo.longitude),(a=(s=this.fullClaim)==null?void 0:s.agent)!=null&&a.identifier&&(this.agentDid=this.fullClaim.agent.identifier),this.fullClaim.startTime)){const l=Tn.fromISO(this.fullClaim.startTime).toLocal();this.startDateInput=l.toFormat("yyyy-MM-dd"),this.startTimeInput=l.toFormat("HH:mm")}}catch(c){console.error("Got error retrieving that project",c),this.errNote("There was an error retrieving that project.")}}openImageDialog(){this.$refs.imageDialog.open(n=>{this.imageUrl=n},"PlanAction")}confirmDeleteImage(){this.$notify({group:"modal",type:"confirm",title:"Are you sure you want to delete the image?",text:"",onYes:this.deleteImage},-1)}async deleteImage(){if(this.imageUrl)try{const n=await ue(this.activeDid),r=await this.axios.delete(zr+"/image/"+encodeURIComponent(this.imageUrl),{headers:n});if(r.status!==204){console.error("Problem deleting image:",r),this.$notify({group:"alert",type:"danger",title:"Error",text:"There was a problem deleting the image."},5e3);return}this.imageUrl=""}catch(n){console.error("Error deleting image:",n),n.response.status===404?(console.log("The image was already deleted:",n),this.imageUrl=""):this.$notify({group:"alert",type:"danger",title:"Error",text:"There was an error deleting the image."},5e3)}}async saveProject(){var a,c,l,d,f;const n=this.fullClaim;if(this.projectId&&(n.lastClaimId=this.lastClaimJwtId),this.agentDid?n.agent={identifier:this.agentDid}:delete n.agent,this.imageUrl?n.image=this.imageUrl:delete n.image,this.includeLocation?n.location={geo:{"@type":"GeoCoordinates",latitude:this.latitude,longitude:this.longitude}}:delete n.location,this.startDateInput)try{const b=this.startTimeInput||"00:00:00",g=this.startDateInput+" "+b;n.startTime=new Date(g).toISOString()}catch{delete n.startTime,this.$notify({group:"alert",type:"danger",title:"Error",text:"The date was invalid so it was not set."},5e3)}else delete n.startTime;const r=await Dr(this.activeDid,n),o=JSON.stringify({jwtEncoded:r}),i=this.apiServer+"/api/v2/claim",s=await ue(this.activeDid);try{const b=await this.axios.post(i,o,{headers:s});if((c=(a=b.data)==null?void 0:a.success)!=null&&c.handleId){this.errorMessage="";const g=encodeURIComponent(b.data.success.handleId);let y;this.sendToTrustroots&&(y=await this.signPayload(),this.sendToNostrPartner("NOSTR-EVENT-TRUSTROOTS","Trustroots",b.data.success.claimId,y)),this.sendToTripHopping&&(y||(y=await this.signPayload()),this.sendToNostrPartner("NOSTR-EVENT-TRIPHOPPING","TripHopping",b.data.success.claimId,y)),this.$router.push({path:"/project/"+g})}else console.error("Got unexpected 'data' inside response from server",b),this.$notify({group:"alert",type:"danger",title:"Error Saving Idea",text:"Server did not save the idea. Try again."},5e3)}catch(b){let g="There was an error saving the project.";const y=b;y?(console.error("Got error from server",y),Object.prototype.hasOwnProperty.call(y,"message")?(g=((f=(d=(l=y.response)==null?void 0:l.data)==null?void 0:d.error)==null?void 0:f.message)||g,this.$notify({group:"alert",type:"danger",title:"User Message",text:g},5e3)):this.$notify({group:"alert",type:"danger",title:"Server Message",text:JSON.stringify(y.toJSON())},5e3)):(console.error("Here's the full error trying to save the claim:",b),this.$notify({group:"alert",type:"danger",title:"Claim Error",text:b},5e3)),this.errorMessage=g}}async signPayload(){var d,f,b;const n=await Pr(this.activeDid),r=(b=(f=(d=n==null?void 0:n.derivationPath)==null?void 0:d.split)==null?void 0:f.call(d,"/"))==null?void 0:b.reverse()[0],o=r==null?void 0:r.replace(/'/g,""),i=Number(o||0),s=Fn(n==null?void 0:n.mnemonic,"",i),a=jr(s==null?void 0:s.privateKey);return Gs({kind:30402,tags:[[]],content:"",created_at:0},a)}async sendToNostrPartner(n,r,o,i){var I,B,E,A,S,C;const s=await Vr(this.activeDid),a=(E=(B=(I=s==null?void 0:s.derivationPath)==null?void 0:I.split)==null?void 0:B.call(I,"/"))==null?void 0:E.reverse()[0],c=a==null?void 0:a.replace(/'/g,""),l=Number(c||0),d=Fn(s==null?void 0:s.mnemonic,"",l),f=d==null?void 0:d.publicKey;let b=Mr;const g=await Un();g.partnerApiServer&&(b=g.partnerApiServer);const y=b+"/api/partner/link",u=window.location.origin+"/claim/"+o,h=this.fullClaim.name+" - see "+u,w=Or(i),v={jwtId:o,linkCode:n,inputJson:JSON.stringify(h),pubKeyHex:f,pubKeyImage:w,pubKeySigHex:i.sig},x=await ue(this.activeDid);try{const U=await this.axios.post(y,v,{headers:x});U.status===201?this.$notify({group:"alert",type:"success",title:`Sent to ${r}`,text:`The project info was sent to ${r}.`},5e3):this.$notify({group:"alert",type:"danger",title:`Failed Sending to ${r}`,text:JSON.stringify(U.data)},5e3)}catch(U){console.error(`Error sending to ${r}`,U);let T=`There was an error sending to ${r}.`;(C=(S=(A=U.response)==null?void 0:A.data)==null?void 0:S.error)!=null&&C.message&&(T=U.response.data.error.message),this.$notify({group:"alert",type:"danger",title:`Error Sending to ${r}`,text:T},7e3)}}async onSaveProjectClick(){this.isHiddenSave=!0,this.isHiddenSpinner=!1,this.numAccounts===0?console.error("Error: there is no account."):this.saveProject()}confirmEraseLatLong(){this.$notify({group:"modal",type:"confirm",title:"Erase Marker",text:"Are you sure you don't want to mark a location? This will erase the current location.",onYes:async()=>{this.eraseLatLong()}},-1)}eraseLatLong(){this.latitude=0,this.longitude=0,this.includeLocation=!1}onCancelClick(){this.$router.back()}};fn=Js([Fr({components:{ImageMethodDialog:to,LMap:Jr,LMarker:Xr,LTileLayer:Qr,QuickNav:eo}})],fn);const Xs={id:"Content",class:"p-6 pb-24 max-w-3xl mx-auto"},Qs={id:"ViewBreadcrumb",class:"mb-8"},ta={class:"text-lg text-center font-light relative px-7"},ea={class:"flex justify-center mt-4"},na={key:0,class:"flex justify-between"},ra=["href"],oa=["src"],ia={key:1},sa={class:"mb-4"},aa={key:0},ca={class:"text-xs text-slate-500 italic -mt-3 mb-4"},la={class:"flex mb-4 columns-3 w-full"},fa=["disabled"],ua={class:"col-span-1 w-full flex justify-center"},da={key:0,class:"mb-4 aspect-video"},ha={key:1,class:"items-center mb-4"},pa={class:"mt-8"},ga={class:"grid grid-cols-1 sm:grid-cols-2 gap-2"},wa=["disabled"];function ba(e,t,n,r,o,i){var b;const s=_t("QuickNav"),a=_t("fa"),c=_t("ImageMethodDialog"),l=_t("l-tile-layer"),d=_t("l-marker"),f=_t("l-map");return Nt(),zt(Yr,null,[Ht(s,{selected:"Projects"}),O("section",Xs,[O("div",Qs,[O("h1",ta,[O("button",{onClick:t[0]||(t[0]=g=>e.$router.go(-1)),class:"text-lg text-center px-2 py-1 absolute -left-2 -top-1"},[Ht(a,{icon:"chevron-left",class:"fa-fw"})]),t[17]||(t[17]=ke(" Edit Project Idea "))])]),O("div",null,Oe(e.errorMessage),1),xt(O("input",{type:"text",placeholder:"Idea Name",class:"block w-full rounded border border-slate-400 mb-4 px-3 py-2","onUpdate:modelValue":t[1]||(t[1]=g=>e.fullClaim.name=g)},null,512),[[Ft,e.fullClaim.name]]),O("div",ea,[e.imageUrl?(Nt(),zt("span",na,[O("a",{href:e.imageUrl,target:"_blank",class:"text-blue-500 ml-4"},[O("img",{src:e.imageUrl,class:"h-24 rounded-xl"},null,8,oa)],8,ra),Ht(a,{icon:"trash-can",onClick:e.confirmDeleteImage,class:"text-red-500 fa-fw ml-8 mt-10"},null,8,["onClick"])])):(Nt(),zt("span",ia,[Ht(a,{icon:"camera",class:"bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-2 rounded-md",onClick:e.openImageDialog},null,8,["onClick"])]))]),Ht(c,{ref:"imageDialog"},null,512),xt(O("input",{type:"text",placeholder:"Other Authorized Representative",class:"mt-4 block w-full rounded border border-slate-400 px-3 py-2","onUpdate:modelValue":t[2]||(t[2]=g=>e.agentDid=g)},null,512),[[Ft,e.agentDid]]),O("div",sa,[e.activeDid!=e.projectIssuerDid&&e.agentDid!=e.projectIssuerDid?(Nt(),zt("p",aa,[t[18]||(t[18]=O("span",{class:"text-red-500"},"Beware!",-1)),t[19]||(t[19]=ke(" If you save this, the original project owner will no longer be able to edit it. ")),O("button",{onClick:t[3]||(t[3]=g=>e.agentDid=e.projectIssuerDid),class:"text-blue-500"}," Click here to make the original owner an authorized representative. ")])):de("",!0)]),xt(O("textarea",{placeholder:"Description",class:"block w-full rounded border border-slate-400 mb-4 px-3 py-2",rows:"5","onUpdate:modelValue":t[4]||(t[4]=g=>e.fullClaim.description=g),maxlength:"5000"},null,512),[[Ft,e.fullClaim.description]]),t[24]||(t[24]=O("div",{class:"text-xs text-slate-500 italic -mt-3 mb-4"}," If you want to be contacted, be sure to include your contact information. ",-1)),O("div",ca,Oe((b=e.fullClaim.description)==null?void 0:b.length)+"/5000 max. characters ",1),xt(O("input",{"onUpdate:modelValue":t[5]||(t[5]=g=>e.fullClaim.url=g),placeholder:"Website",autocapitalize:"none",class:"block w-full rounded border border-slate-400 mb-4 px-3 py-2"},null,512),[[Ft,e.fullClaim.url]]),O("div",la,[xt(O("input",{"onUpdate:modelValue":t[6]||(t[6]=g=>e.startDateInput=g),placeholder:"Start Date",type:"date",class:"col-span-1 w-full rounded border border-slate-400 px-3 py-2"},null,512),[[Ft,e.startDateInput]]),xt(O("input",{disabled:!e.startDateInput,placeholder:"Start Time","onUpdate:modelValue":t[7]||(t[7]=g=>e.startTimeInput=g),type:"time",class:"col-span-1 w-full rounded border border-slate-400 ml-2 px-3 py-2"},null,8,fa),[[Ft,e.startTimeInput]]),O("span",ua,Oe(e.zoneName),1)]),O("div",{class:"flex items-center mb-4",onClick:t[9]||(t[9]=g=>e.includeLocation=!e.includeLocation)},[xt(O("input",{type:"checkbox",class:"mr-2","onUpdate:modelValue":t[8]||(t[8]=g=>e.includeLocation=g)},null,512),[[Hn,e.includeLocation]]),t[20]||(t[20]=O("label",{for:"includeLocation"},"Include Location",-1))]),e.includeLocation?(Nt(),zt("div",da,[t[21]||(t[21]=O("p",{class:"text-sm mb-2 text-slate-500"}," For your security, choose a location nearby but not exactly at the place. ",-1)),Ht(f,{ref:"map",zoom:e.zoom,"onUpdate:zoom":t[11]||(t[11]=g=>e.zoom=g),center:[0,0],class:"!z-40 rounded-md",onClick:t[12]||(t[12]=g=>{e.latitude=g.latlng.lat,e.longitude=g.latlng.lng})},{default:Gr(()=>[Ht(l,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png","layer-type":"base",name:"OpenStreetMap"}),e.latitude&&e.longitude?(Nt(),Wr(d,{key:0,"lat-lng":[e.latitude,e.longitude],onClick:t[10]||(t[10]=g=>e.confirmEraseLatLong())},null,8,["lat-lng"])):de("",!0)]),_:1},8,["zoom"])])):de("",!0),e.showGeneralAdvanced&&e.includeLocation?(Nt(),zt("div",ha,[O("div",{class:"flex",onClick:t[14]||(t[14]=g=>e.sendToTrustroots=!e.sendToTrustroots)},[xt(O("input",{type:"checkbox",class:"mr-2","onUpdate:modelValue":t[13]||(t[13]=g=>e.sendToTrustroots=g)},null,512),[[Hn,e.sendToTrustroots]]),t[22]||(t[22]=O("label",null,"Send to Trustroots",-1))])])):de("",!0),O("div",pa,[O("div",ga,[O("button",{disabled:e.isHiddenSave,class:"block w-full text-center text-lg font-bold uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md mb-2",onClick:t[15]||(t[15]=g=>e.onSaveProjectClick())},[O("span",{class:Nn({hidden:e.isHiddenSave})},"Save Project",2),O("span",{class:Nn({hidden:e.isHiddenSpinner})},t[23]||(t[23]=[O("i",{class:"fa-solid fa-spinner fa-spin-pulse"},null,-1),ke(" Saving...")]),2)],8,wa),O("button",{type:"button",class:"block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-md",onClick:t[16]||(t[16]=g=>e.onCancelClick())}," Cancel ")])])])],64)}const Oa=Zr(fn,[["render",ba]]);export{Oa as default};
|
|
|