B[l]^J?1:-1;return g==h?0:g>h^J?1:-1}function D(j,P,J,Q){if(jJ||j!==a(j))throw Error(s+(Q||"Argument")+(typeof j=="number"?j
J?" out of range: ":" not an integer: ":" not a primitive number: ")+String(j))}function O(j){var P=j.c.length-1;return I(j.e/u)==P&&j.c[P]%2!=0}function F(j,P){return(j.length>1?j.charAt(0)+"."+j.slice(1):j)+(P<0?"e":"e+")+P}function H(j,P,J){var Q,N;if(P<0){for(N=J+".";++P;N+=J);j=N+j}else if(Q=j.length,++P>Q){for(N=J,P-=Q;--P;N+=J);j+=N}else P{"use strict";Object.defineProperty(pr1,"__esModule",{value:!0});var GW2=OT(),hr1=class{BigNum;constructor(){this.BigNum=(e,r)=>{let n=GW2.BigNumber.clone({DECIMAL_PLACES:r});return new n(e)}}winstonToAr(e,{formatted:r=!1,decimals:n=12,trim:a=!0}={}){let s=this.stringToBigNum(e,n).shiftedBy(-12);return r?s.toFormat(n):s.toFixed(n)}arToWinston(e,{formatted:r=!1}={}){let n=this.stringToBigNum(e).shiftedBy(12);return r?n.toFormat():n.toFixed(0)}compare(e,r){let n=this.stringToBigNum(e),a=this.stringToBigNum(r);return n.comparedTo(a)}isEqual(e,r){return this.compare(e,r)===0}isLessThan(e,r){let n=this.stringToBigNum(e),a=this.stringToBigNum(r);return n.isLessThan(a)}isGreaterThan(e,r){let n=this.stringToBigNum(e),a=this.stringToBigNum(r);return n.isGreaterThan(a)}add(e,r){let n=this.stringToBigNum(e),a=this.stringToBigNum(r);return n.plus(r).toFixed(0)}sub(e,r){let n=this.stringToBigNum(e),a=this.stringToBigNum(r);return n.minus(r).toFixed(0)}stringToBigNum(e,r=12){return this.BigNum(e,r)}};pr1.default=hr1});var pN1=_(gr1=>{"use strict";Object.defineProperty(gr1,"__esModule",{value:!0});var Ar1=class{METHOD_GET="GET";METHOD_POST="POST";config;constructor(e){this.applyConfig(e)}applyConfig(e){this.config=this.mergeDefaults(e)}getConfig(){return this.config}mergeDefaults(e){let r=e.protocol||"http",n=e.port||(r==="https"?443:80);return{host:e.host||"127.0.0.1",protocol:r,port:n,timeout:e.timeout||2e4,logging:e.logging||!1,logger:e.logger||console.log,network:e.network}}async get(e,r){return await this.request(e,{...r,method:this.METHOD_GET})}async post(e,r,n){let a=new Headers(n?.headers||{});return a.get("content-type")?.includes("application/json")||a.append("content-type","application/json"),a.append("accept","application/json, text/plain, */*"),await this.request(e,{...n,method:this.METHOD_POST,body:typeof r!="string"?JSON.stringify(r):r,headers:a})}async request(e,r){let n=new Headers(r?.headers||{}),a=`${this.config.protocol}://${this.config.host}:${this.config.port}`,s=r?.responseType;delete r?.responseType,e.startsWith("/")&&(e=e.slice(1)),this.config.network&&n.append("x-network",this.config.network),this.config.logging&&this.config.logger(`Requesting: ${a}/${e}`);let o=await fetch(`${a}/${e}`,{...r||{},headers:n});this.config.logging&&this.config.logger(`Response: ${o.url} - ${o.status}`);let u=o.headers.get("content-type")?.match(/charset=([^()<>@,;:\"/[\]?.=\s]*)/i)?.[1],f=o,p=async()=>{if(u)try{f.data=new TextDecoder(u).decode(await o.arrayBuffer())}catch{f.data=await o.text()}else f.data=await o.text()};if(s==="arraybuffer")f.data=await o.arrayBuffer();else if(s==="text")await p();else if(s==="webstream")f.data=jW2(o.body);else try{let y=await o.clone().json();typeof y!="object"?await p():f.data=await o.json(),y=null}catch{await p()}return f}};gr1.default=Ar1;var jW2=t=>{let e=t;return typeof e[Symbol.asyncIterator]>"u"&&(e[Symbol.asyncIterator]=JW2(t)),e},JW2=function(t){return async function*(){let r=t.getReader();try{for(;;){let{done:n,value:a}=await r.read();if(n)return;yield a}}finally{r.releaseLock()}}}});var AN1=_(yr1=>{"use strict";Object.defineProperty(yr1,"__esModule",{value:!0});var mr1=class{api;constructor(e){this.api=e}getInfo(){return this.api.get("info").then(e=>e.data)}getPeers(){return this.api.get("peers").then(e=>e.data)}};yr1.default=mr1});var NT=_(PP=>{"use strict";Object.defineProperty(PP,"__esModule",{value:!0});PP.getError=zW2;var br1=class extends Error{type;response;constructor(e,r={}){r.message?super(r.message):super(),this.type=e,this.response=r.response}getType(){return this.type}};PP.default=br1;function zW2(t){let e=t.data;if(typeof t.data=="string")try{e=JSON.parse(t.data)}catch{}if(t.data instanceof ArrayBuffer||t.data instanceof Uint8Array)try{e=JSON.parse(e.toString())}catch{}return e?e.error||e:t.statusText||"unknown"}});var Cr1=_(He=>{"use strict";var KW2=He&&He.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(He,"__esModule",{value:!0});He.arrayCompare=He.MIN_CHUNK_SIZE=He.MAX_CHUNK_SIZE=void 0;He.chunkData=xr1;He.generateLeaves=wr1;He.computeRootHash=VW2;He.generateTree=mN1;He.generateTransactionChunks=YW2;He.buildLayers=qP;He.generateProofs=yN1;He.arrayFlatten=Er1;He.intToBuffer=LT;He.bufferToInt=Ir1;He.validatePath=FT;He.debug=bN1;var UP=KW2(HP()),gN1=mu();He.MAX_CHUNK_SIZE=256*1024;He.MIN_CHUNK_SIZE=32*1024;var QT=32,vw=32;async function xr1(t){let e=[],r=t,n=0;for(;r.byteLength>=He.MAX_CHUNK_SIZE;){let a=He.MAX_CHUNK_SIZE,s=r.byteLength-He.MAX_CHUNK_SIZE;s>0&&s({type:"leaf",id:await tr(await Promise.all([tr(e),tr(LT(n))])),dataHash:e,minByteRange:r,maxByteRange:n})))}async function VW2(t){return(await mN1(t)).id}async function mN1(t){return await qP(await wr1(await xr1(t)))}async function YW2(t){let e=await xr1(t),r=await wr1(e),n=await qP(r),a=await yN1(n),s=e.slice(-1)[0];return s.maxByteRange-s.minByteRange===0&&(e.splice(e.length-1,1),a.splice(a.length-1,1)),{data_root:n.id,chunks:e,proofs:a}}async function qP(t,e=0){if(t.length<2)return t[0];let r=[];for(let n=0;n{Array.isArray(r)?e.push(...Er1(r)):e.push(r)}),e}async function WW2(t,e){return e?{type:"branch",id:await tr([await tr(t.id),await tr(e.id),await tr(LT(t.maxByteRange))]),byteRange:t.maxByteRange,maxByteRange:e.maxByteRange,leftChild:t,rightChild:e}:t}async function tr(t){return Array.isArray(t)&&(t=UP.default.utils.concatBuffers(t)),new Uint8Array(await UP.default.crypto.hash(t))}function LT(t){let e=new Uint8Array(QT);for(var r=e.length-1;r>=0;r--){var n=t%256;e[r]=n,t=(t-n)/256}return e}function Ir1(t){let e=0;for(var r=0;rt.every((r,n)=>e[n]===r);He.arrayCompare=XW2;async function FT(t,e,r,n,a){if(n<=0)return!1;if(e>=n)return FT(t,0,n-1,n,a);if(e<0)return FT(t,0,0,n,a);if(a.length==vw+QT){let y=a.slice(0,vw),v=a.slice(y.length,y.length+QT),E=await tr([await tr(y),await tr(v)]);return(0,He.arrayCompare)(t,E)?{offset:n-1,leftBound:r,rightBound:n,chunkSize:n-r}:!1}let s=a.slice(0,vw),o=a.slice(s.length,s.length+vw),c=a.slice(s.length+o.length,s.length+o.length+QT),u=Ir1(c),f=a.slice(s.length+o.length+c.length),p=await tr([await tr(s),await tr(o),await tr(c)]);return(0,He.arrayCompare)(t,p)?e ${JSON.stringify(c)}`;return bN1(o,u)}});var EN1=_(Vs=>{"use strict";var ZW2=Vs&&Vs.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),$W2=Vs&&Vs.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),eX2=Vs&&Vs.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&ZW2(e,t,r);return $W2(e,t),e},tX2=Vs&&Vs.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Vs,"__esModule",{value:!0});Vs.TransactionUploader=void 0;var vN1=tX2(PT()),rX2=eX2(mu()),Br1=NT(),nX2=Cr1(),xN1=1,iX2=["invalid_json","chunk_too_big","data_path_too_big","offset_too_big","data_size_too_big","chunk_proof_ratio_not_attractive","invalid_proof"],wN1=1e3*40,Sr1=class t{api;chunkIndex=0;txPosted=!1;transaction;lastRequestTimeEnd=0;totalErrors=0;data;lastResponseStatus=0;lastResponseError="";get isComplete(){return this.txPosted&&this.chunkIndex===this.transaction.chunks.chunks.length}get totalChunks(){return this.transaction.chunks.chunks.length}get uploadedChunks(){return this.chunkIndex}get pctComplete(){return Math.trunc(this.uploadedChunks/this.totalChunks*100)}constructor(e,r){if(this.api=e,!r.id)throw new Error("Transaction is not signed");if(!r.chunks)throw new Error("Transaction chunks not prepared");this.data=r.data,this.transaction=new vN1.default(Object.assign({},r,{data:new Uint8Array(0)}))}async uploadChunk(e){if(this.isComplete)throw new Error("Upload is already complete");if(this.lastResponseError!==""?this.totalErrors++:this.totalErrors=0,this.totalErrors===100)throw new Error(`Unable to complete upload: ${this.lastResponseStatus}: ${this.lastResponseError}`);let r=this.lastResponseError===""?0:Math.max(this.lastRequestTimeEnd+wN1-Date.now(),wN1);if(r>0&&(r=r-r*Math.random()*.3,await new Promise(o=>setTimeout(o,r))),this.lastResponseError="",!this.txPosted){await this.postTransaction();return}e&&(this.chunkIndex=e);let n=this.transaction.getChunk(e||this.chunkIndex,this.data);if(!await(0,nX2.validatePath)(this.transaction.chunks.data_root,parseInt(n.offset),0,parseInt(n.data_size),rX2.b64UrlToBuffer(n.data_path)))throw new Error(`Unable to validate chunk ${this.chunkIndex}`);let s=await this.api.post("chunk",this.transaction.getChunk(this.chunkIndex,this.data)).catch(o=>(console.error(o.message),{status:-1,data:{error:o.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=s.status,this.lastResponseStatus==200)this.chunkIndex++;else if(this.lastResponseError=(0,Br1.getError)(s),iX2.includes(this.lastResponseError))throw new Error(`Fatal error uploading chunk ${this.chunkIndex}: ${this.lastResponseError}`)}static async fromSerialized(e,r,n){if(!r||typeof r.chunkIndex!="number"||typeof r.transaction!="object")throw new Error("Serialized object does not match expected format.");var a=new vN1.default(r.transaction);a.chunks||await a.prepareChunks(n);let s=new t(e,a);if(s.chunkIndex=r.chunkIndex,s.lastRequestTimeEnd=r.lastRequestTimeEnd,s.lastResponseError=r.lastResponseError,s.lastResponseStatus=r.lastResponseStatus,s.txPosted=r.txPosted,s.data=n,s.transaction.data_root!==r.transaction.data_root)throw new Error("Data mismatch: Uploader doesn't match provided data.");return s}static async fromTransactionId(e,r){let n=await e.get(`tx/${r}`);if(n.status!==200)throw new Error(`Tx ${r} not found: ${n.status}`);let a=n.data;return a.data=new Uint8Array(0),{txPosted:!0,chunkIndex:0,lastResponseError:"",lastRequestTimeEnd:0,lastResponseStatus:0,transaction:a}}toJSON(){return{chunkIndex:this.chunkIndex,transaction:this.transaction,lastRequestTimeEnd:this.lastRequestTimeEnd,lastResponseStatus:this.lastResponseStatus,lastResponseError:this.lastResponseError,txPosted:this.txPosted}}async postTransaction(){if(this.totalChunks<=xN1){this.transaction.data=this.data;let n=await this.api.post("tx",this.transaction).catch(a=>(console.error(a),{status:-1,data:{error:a.message}}));if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=n.status,this.transaction.data=new Uint8Array(0),n.status>=200&&n.status<300){this.txPosted=!0,this.chunkIndex=xN1;return}throw this.lastResponseError=(0,Br1.getError)(n),new Error(`Unable to upload transaction: ${n.status}, ${this.lastResponseError}`)}let r=await this.api.post("tx",this.transaction);if(this.lastRequestTimeEnd=Date.now(),this.lastResponseStatus=r.status,!(r.status>=200&&r.status<300))throw this.lastResponseError=(0,Br1.getError)(r),new Error(`Unable to upload transaction: ${r.status}, ${this.lastResponseError}`);this.txPosted=!0}};Vs.TransactionUploader=Sr1});var gm=_((_K3,IN1)=>{IN1.exports={}});var BN1=_(Rc=>{"use strict";var aX2=Rc&&Rc.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),sX2=Rc&&Rc.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),oX2=Rc&&Rc.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&aX2(e,t,r);return sX2(e,t),e},CN1=Rc&&Rc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rc,"__esModule",{value:!0});var _r1=CN1(NT()),dl=CN1(PT()),UT=oX2(mu()),Rr1=EN1();gm();var Tr1=class{api;crypto;chunks;constructor(e,r,n){this.api=e,this.crypto=r,this.chunks=n}async getTransactionAnchor(){let e=await this.api.get("tx_anchor");if(!e.data.match(/^[a-z0-9_-]{43,}/i)||!e.ok)throw new Error(`Could not getTransactionAnchor. Received: ${e.data}. Status: ${e.status}, ${e.statusText}`);return e.data}async getPrice(e,r){let n=r?`price/${e}/${r}`:`price/${e}`,a=await this.api.get(n);if(!/^\d+$/.test(a.data)||!a.ok)throw new Error(`Could not getPrice. Received: ${a.data}. Status: ${a.status}, ${a.statusText}`);return a.data}async get(e){let r=await this.api.get(`tx/${e}`);if(r.status==200){let n=parseInt(r.data.data_size);if(r.data.format>=2&&n>0&&n<=1024*1024*12){let a=await this.getData(e);return new dl.default({...r.data,data:a})}return new dl.default({...r.data,format:r.data.format||1})}throw r.status==404?new _r1.default("TX_NOT_FOUND"):r.status==410?new _r1.default("TX_FAILED"):new _r1.default("TX_INVALID")}fromRaw(e){return new dl.default(e)}async search(e,r){return this.api.post("arql",{op:"equals",expr1:e,expr2:r}).then(n=>n.data?n.data:[])}getStatus(e){return this.api.get(`tx/${e}/status`).then(r=>r.status==200?{status:200,confirmed:r.data}:{status:r.status,confirmed:null})}async getData(e,r){let n;try{n=await this.chunks.downloadChunkedData(e)}catch(a){console.error(`Error while trying to download chunked data for ${e}`),console.error(a)}if(!n){console.warn(`Falling back to gateway cache for ${e}`);try{let{data:a,ok:s,status:o,statusText:c}=await this.api.get(`/${e}`,{responseType:"arraybuffer"});if(!s)throw new Error("Bad http status code",{cause:{status:o,statusText:c}});n=a}catch(a){console.error(`Error while trying to download contiguous data from gateway cache for ${e}`),console.error(a)}}if(!n)throw new Error(`${e} data was not found!`);return r&&r.decode&&!r.string?n:r&&r.decode&&r.string?UT.bufferToString(n):UT.bufferTob64Url(n)}async sign(e,r,n){let s=typeof r=="object"&&(c=>{let u=!0;return["n","e","d","p","q","dp","dq","qi"].map(f=>!(f in c)&&(u=!1)),u})(r),o=typeof arweaveWallet=="object";if(!s&&!o)throw new Error("No valid JWK or external wallet found to sign transaction.");if(s){e.setOwner(r.n);let c=await e.getSignatureData(),u=await this.crypto.sign(r,c,n),f=await this.crypto.hash(u);e.setSignature({id:UT.bufferTob64Url(f),owner:r.n,signature:UT.bufferTob64Url(u)})}else if(o){try{(await arweaveWallet.getPermissions()).includes("SIGN_TRANSACTION")||await arweaveWallet.connect(["SIGN_TRANSACTION"])}catch{}let c=await arweaveWallet.sign(e,n);e.setSignature({id:c.id,owner:c.owner,reward:c.reward,tags:c.tags,signature:c.signature})}else throw new Error("An error occurred while signing. Check wallet is valid")}async verify(e){let r=await e.getSignatureData(),n=e.get("signature",{decode:!0,string:!1}),a=UT.bufferTob64Url(await this.crypto.hash(n));if(e.id!==a)throw new Error("Invalid transaction signature or ID! The transaction ID doesn't match the expected SHA-256 hash of the signature.");return this.crypto.verify(e.owner,r,n)}async post(e){if(typeof e=="string"?e=new dl.default(JSON.parse(e)):typeof e.readInt32BE=="function"?e=new dl.default(JSON.parse(e.toString())):typeof e=="object"&&!(e instanceof dl.default)&&(e=new dl.default(e)),!(e instanceof dl.default))throw new Error("Must be Transaction object");e.chunks||await e.prepareChunks(e.data);let r=await this.getUploader(e,e.data);try{for(;!r.isComplete;)await r.uploadChunk()}catch(n){if(r.lastResponseStatus>0)return{status:r.lastResponseStatus,statusText:r.lastResponseError,data:{error:r.lastResponseError}};throw n}return{status:200,statusText:"OK",data:{}}}async getUploader(e,r){let n;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),e instanceof dl.default){if(r||(r=e.data),!(r instanceof Uint8Array))throw new Error("Data format is invalid");e.chunks||await e.prepareChunks(r),n=new Rr1.TransactionUploader(this.api,e),(!n.data||n.data.length===0)&&(n.data=r)}else{if(typeof e=="string"&&(e=await Rr1.TransactionUploader.fromTransactionId(this.api,e)),!r||!(r instanceof Uint8Array))throw new Error("Must provide data when resuming upload");n=await Rr1.TransactionUploader.fromSerialized(this.api,e,r)}return n}async*upload(e,r){let n=await this.getUploader(e,r);for(;!n.isComplete;)await n.uploadChunk(),yield n;return n}};Rc.default=Tr1});var _N1=_(hl=>{"use strict";var cX2=hl&&hl.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),uX2=hl&&hl.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),fX2=hl&&hl.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&cX2(e,t,r);return uX2(e,t),e};Object.defineProperty(hl,"__esModule",{value:!0});var SN1=fX2(mu());gm();var Dr1=class{api;crypto;constructor(e,r){this.api=e,this.crypto=r}getBalance(e){return this.api.get(`wallet/${e}/balance`).then(r=>r.data)}getLastTransactionID(e){return this.api.get(`wallet/${e}/last_tx`).then(r=>r.data)}generate(){return this.crypto.generateJWK()}async jwkToAddress(e){return!e||e==="use_wallet"?this.getAddress():this.getAddress(e)}async getAddress(e){if(!e||e==="use_wallet"){try{await arweaveWallet.connect(["ACCESS_ADDRESS"])}catch{}return arweaveWallet.getActiveAddress()}else return this.ownerToAddress(e.n)}async ownerToAddress(e){return SN1.bufferTob64Url(await this.crypto.hash(SN1.b64UrlToBuffer(e)))}};hl.default=Dr1});var TN1=_(Tc=>{"use strict";var lX2=Tc&&Tc.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),dX2=Tc&&Tc.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),hX2=Tc&&Tc.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&lX2(e,t,r);return dX2(e,t),e};Object.defineProperty(Tc,"__esModule",{value:!0});Tc.SiloResource=void 0;var RN1=hX2(mu()),kr1=class{api;crypto;transactions;constructor(e,r,n){this.api=e,this.crypto=r,this.transactions=n}async get(e){if(!e)throw new Error("No Silo URI specified");let r=await this.parseUri(e),n=await this.transactions.search("Silo-Name",r.getAccessKey());if(n.length==0)throw new Error(`No data could be found for the Silo URI: ${e}`);let a=await this.transactions.get(n[0]);if(!a)throw new Error(`No data could be found for the Silo URI: ${e}`);let s=a.get("data",{decode:!0,string:!1});return this.crypto.decrypt(s,r.getEncryptionKey())}async readTransactionData(e,r){if(!r)throw new Error("No Silo URI specified");let n=await this.parseUri(r),a=e.get("data",{decode:!0,string:!1});return this.crypto.decrypt(a,n.getEncryptionKey())}async parseUri(e){let r=e.match(/^([a-z0-9-_]+)\.([0-9]+)/i);if(!r)throw new Error("Invalid Silo name, must be a name in the format of [a-z0-9]+.[0-9]+, e.g. 'bubble.7'");let n=r[1],a=Math.pow(2,parseInt(r[2])),s=await this.hash(RN1.stringToBuffer(n),a),o=RN1.bufferTob64(s.slice(0,15)),c=await this.hash(s.slice(16,31),1);return new GP(e,o,c)}async hash(e,r){let n=await this.crypto.hash(e);for(let a=0;a{"use strict";var pX2=pl&&pl.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),AX2=pl&&pl.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),gX2=pl&&pl.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&pX2(e,t,r);return AX2(e,t),e};Object.defineProperty(pl,"__esModule",{value:!0});var DN1=NT(),mX2=gX2(mu()),Mr1=class{api;constructor(e){this.api=e}async getTransactionOffset(e){let r=await this.api.get(`tx/${e}/offset`);if(r.status===200)return r.data;throw new Error(`Unable to get transaction offset: ${(0,DN1.getError)(r)}`)}async getChunk(e){let r=await this.api.get(`chunk/${e}`);if(r.status===200)return r.data;throw new Error(`Unable to get chunk: ${(0,DN1.getError)(r)}`)}async getChunkData(e){let r=await this.getChunk(e);return mX2.b64UrlToBuffer(r.chunk)}firstChunkOffset(e){return parseInt(e.offset)-parseInt(e.size)+1}async downloadChunkedData(e){let r=await this.getTransactionOffset(e),n=parseInt(r.size),s=parseInt(r.offset)-n+1,o=new Uint8Array(n),c=0;for(;c{"use strict";var yX2=qT&&qT.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(qT,"__esModule",{value:!0});var MN1=yX2(NT());gm();var Or1=class t{api;network;static HASH_ENDPOINT="block/hash/";static HEIGHT_ENDPOINT="block/height/";constructor(e,r){this.api=e,this.network=r}async get(e){let r=await this.api.get(`${t.HASH_ENDPOINT}${e}`);if(r.status===200)return r.data;throw r.status===404?new MN1.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${r}`)}async getByHeight(e){let r=await this.api.get(`${t.HEIGHT_ENDPOINT}${e}`);if(r.status===200)return r.data;throw r.status===404?new MN1.default("BLOCK_NOT_FOUND"):new Error(`Error while loading block data: ${r}`)}async getCurrent(){let{current:e}=await this.network.getInfo();return await this.get(e)}};qT.default=Or1});var HP=_(Dc=>{"use strict";var bX2=Dc&&Dc.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),vX2=Dc&&Dc.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),xX2=Dc&&Dc.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&bX2(e,t,r);return vX2(e,t),e},bu=Dc&&Dc.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Dc,"__esModule",{value:!0});var wX2=bu(hN1()),EX2=bu(pN1()),IX2=bu(dr1()),CX2=bu(AN1()),BX2=bu(BN1()),SX2=bu(_N1()),NN1=bu(PT()),HT=xX2(mu()),_X2=bu(TN1()),RX2=bu(kN1()),TX2=bu(ON1()),Nr1=class t{api;wallets;transactions;network;blocks;ar;silo;chunks;static init;static crypto=new IX2.default;static utils=HT;constructor(e){this.api=new EX2.default(e),this.wallets=new SX2.default(this.api,t.crypto),this.chunks=new RX2.default(this.api),this.transactions=new BX2.default(this.api,t.crypto,this.chunks),this.silo=new _X2.default(this.api,this.crypto,this.transactions),this.network=new CX2.default(this.api),this.blocks=new TX2.default(this.api,this.network),this.ar=new wX2.default}get crypto(){return t.crypto}get utils(){return t.utils}getConfig(){return{api:this.api.getConfig(),crypto:null}}async createTransaction(e,r){let n={};if(Object.assign(n,e),!e.data&&!(e.target&&e.quantity))throw new Error("A new Arweave transaction must have a 'data' value, or 'target' and 'quantity' values.");if(e.owner==null&&r&&r!=="use_wallet"&&(n.owner=r.n),e.last_tx==null&&(n.last_tx=await this.transactions.getTransactionAnchor()),typeof e.data=="string"&&(e.data=HT.stringToBuffer(e.data)),e.data instanceof ArrayBuffer&&(e.data=new Uint8Array(e.data)),e.data&&!(e.data instanceof Uint8Array))throw new Error("Expected data to be a string, Uint8Array or ArrayBuffer");if(e.reward==null){let s=e.data?e.data.byteLength:0;n.reward=await this.transactions.getPrice(s,n.target)}n.data_root="",n.data_size=e.data?e.data.byteLength.toString():"0",n.data=e.data||new Uint8Array(0);let a=new NN1.default(n);return await a.getSignatureData(),a}async createSiloTransaction(e,r,n){let a={};if(Object.assign(a,e),!e.data)throw new Error("Silo transactions must have a 'data' value");if(!n)throw new Error("No Silo URI specified.");if(e.target||e.quantity)throw new Error("Silo transactions can only be used for storing data, sending AR to other wallets isn't supported.");if(e.owner==null){if(!r||!r.n)throw new Error("A new Arweave transaction must either have an 'owner' attribute, or you must provide the jwk parameter.");a.owner=r.n}e.last_tx==null&&(a.last_tx=await this.transactions.getTransactionAnchor());let s=await this.silo.parseUri(n);if(typeof e.data=="string"){let c=await this.crypto.encrypt(HT.stringToBuffer(e.data),s.getEncryptionKey());a.reward=await this.transactions.getPrice(c.byteLength),a.data=HT.bufferTob64Url(c)}if(e.data instanceof Uint8Array){let c=await this.crypto.encrypt(e.data,s.getEncryptionKey());a.reward=await this.transactions.getPrice(c.byteLength),a.data=HT.bufferTob64Url(c)}let o=new NN1.default(a);return o.addTag("Silo-Name",s.getAccessKey()),o.addTag("Silo-Version","0.1.0"),o}arql(e){return this.api.post("/arql",e).then(r=>r.data||[])}};Dc.default=Nr1});var LN1=_(GT=>{"use strict";var DX2=GT&>.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(GT,"__esModule",{value:!0});GT.default=FN1;var Fa=DX2(HP());async function FN1(t){if(Array.isArray(t)){let n=Fa.default.utils.concatBuffers([Fa.default.utils.stringToBuffer("list"),Fa.default.utils.stringToBuffer(t.length.toString())]);return await QN1(t,await Fa.default.crypto.hash(n,"SHA-384"))}let e=Fa.default.utils.concatBuffers([Fa.default.utils.stringToBuffer("blob"),Fa.default.utils.stringToBuffer(t.byteLength.toString())]),r=Fa.default.utils.concatBuffers([await Fa.default.crypto.hash(e,"SHA-384"),await Fa.default.crypto.hash(t,"SHA-384")]);return await Fa.default.crypto.hash(r,"SHA-384")}async function QN1(t,e){if(t.length<1)return e;let r=Fa.default.utils.concatBuffers([e,await FN1(t[0])]),n=await Fa.default.crypto.hash(r,"SHA-384");return await QN1(t.slice(1),n)}});var PT=_(Qa=>{"use strict";var kX2=Qa&&Qa.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),MX2=Qa&&Qa.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),OX2=Qa&&Qa.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&kX2(e,t,r);return MX2(e,t),e},NX2=Qa&&Qa.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Qa,"__esModule",{value:!0});Qa.Tag=void 0;var F4=OX2(mu()),FX2=NX2(LN1()),QX2=Cr1(),jP=class{get(e,r){if(!Object.getOwnPropertyNames(this).includes(e))throw new Error(`Field "${e}" is not a property of the Arweave Transaction class.`);if(this[e]instanceof Uint8Array)return r&&r.decode&&r.string?F4.bufferToString(this[e]):r&&r.decode&&!r.string?this[e]:F4.bufferTob64Url(this[e]);if(this[e]instanceof Array){if(r?.decode!==void 0||r?.string!==void 0)throw e==="tags"&&console.warn(`Did you mean to use 'transaction["tags"]' ?`),new Error("Cannot decode or stringify an array.");return this[e]}return r&&r.decode==!0?r&&r.string?F4.b64UrlToString(this[e]):F4.b64UrlToBuffer(this[e]):this[e]}},jT=class extends jP{name;value;constructor(e,r,n=!1){super(),this.name=e,this.value=r}};Qa.Tag=jT;var Fr1=class extends jP{format=2;id="";last_tx="";owner="";tags=[];target="";quantity="0";data_size="0";data=new Uint8Array;data_root="";reward="0";signature="";chunks;constructor(e={}){super(),Object.assign(this,e),typeof this.data=="string"&&(this.data=F4.b64UrlToBuffer(this.data)),e.tags&&(this.tags=e.tags.map(r=>new jT(r.name,r.value)))}addTag(e,r){this.tags.push(new jT(F4.stringToB64Url(e),F4.stringToB64Url(r)))}toJSON(){return{format:this.format,id:this.id,last_tx:this.last_tx,owner:this.owner,tags:this.tags,target:this.target,quantity:this.quantity,data:F4.bufferTob64Url(this.data),data_size:this.data_size,data_root:this.data_root,data_tree:this.data_tree,reward:this.reward,signature:this.signature}}setOwner(e){this.owner=e}setSignature({id:e,owner:r,reward:n,tags:a,signature:s}){this.id=e,this.owner=r,n&&(this.reward=n),a&&(this.tags=a),this.signature=s}async prepareChunks(e){!this.chunks&&e.byteLength>0&&(this.chunks=await(0,QX2.generateTransactionChunks)(e),this.data_root=F4.bufferTob64Url(this.chunks.data_root)),!this.chunks&&e.byteLength===0&&(this.chunks={chunks:[],data_root:new Uint8Array,proofs:[]},this.data_root="")}getChunk(e,r){if(!this.chunks)throw new Error("Chunks have not been prepared");let n=this.chunks.proofs[e],a=this.chunks.chunks[e];return{data_root:this.data_root,data_size:this.data_size,data_path:F4.bufferTob64Url(n.proof),offset:n.offset.toString(),chunk:F4.bufferTob64Url(r.slice(a.minByteRange,a.maxByteRange))}}async getSignatureData(){switch(this.format){case 1:let e=this.tags.reduce((n,a)=>F4.concatBuffers([n,a.get("name",{decode:!0,string:!1}),a.get("value",{decode:!0,string:!1})]),new Uint8Array);return F4.concatBuffers([this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),this.get("data",{decode:!0,string:!1}),F4.stringToBuffer(this.quantity),F4.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),e]);case 2:this.data_root||await this.prepareChunks(this.data);let r=this.tags.map(n=>[n.get("name",{decode:!0,string:!1}),n.get("value",{decode:!0,string:!1})]);return await(0,FX2.default)([F4.stringToBuffer(this.format.toString()),this.get("owner",{decode:!0,string:!1}),this.get("target",{decode:!0,string:!1}),F4.stringToBuffer(this.quantity),F4.stringToBuffer(this.reward),this.get("last_tx",{decode:!0,string:!1}),r,F4.stringToBuffer(this.data_size),this.get("data_root",{decode:!0,string:!1})]);default:throw new Error(`Unexpected transaction format: ${this.format}`)}}};Qa.default=Fr1});var UN1=_((Lr1,PN1)=>{"use strict";var LX2=Lr1&&Lr1.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},Qr1=LX2(HP());Qr1.default.init=function(t={}){return new Qr1.default(t)};PN1.exports=Qr1.default});var KP=_((WK3,zP)=>{(function(){"use strict";var t="input is invalid type",e="finalize already called",r=typeof window=="object",n=r?window:{};n.JS_SHA3_NO_WINDOW&&(r=!1);var a=!r&&typeof self=="object",s=!n.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?n=global:a&&(n=self);var o=!n.JS_SHA3_NO_COMMON_JS&&typeof zP=="object"&&zP.exports,c=typeof define=="function"&&define.amd,u=!n.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),p=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],v=[1,256,65536,16777216],E=[6,1536,393216,100663296],I=[0,8,16,24],R=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],T=[224,256,384,512],D=[128,256],O=["hex","buffer","arrayBuffer","array","digest"],F={128:168,256:136};(n.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(L){return Object.prototype.toString.call(L)==="[object Array]"}),u&&(n.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(L){return typeof L=="object"&&L.buffer&&L.buffer.constructor===ArrayBuffer});for(var H=function(L,W,a1){return function(t1){return new S(L,W,L).update(t1)[a1]()}},j=function(L,W,a1){return function(t1,q){return new S(L,W,q).update(t1)[a1]()}},P=function(L,W,a1){return function(t1,q,$,V){return h["cshake"+L].update(t1,q,$,V)[a1]()}},J=function(L,W,a1){return function(t1,q,$,V){return h["kmac"+L].update(t1,q,$,V)[a1]()}},Q=function(L,W,a1,t1){for(var q=0;q>5,this.byteCount=this.blockCount<<2,this.outputBlocks=a1>>5,this.extraBytes=(a1&31)>>3;for(var t1=0;t1<50;++t1)this.s[t1]=0}S.prototype.update=function(L){if(this.finalized)throw new Error(e);var W,a1=typeof L;if(a1!=="string"){if(a1==="object"){if(L===null)throw new Error(t);if(u&&L.constructor===ArrayBuffer)L=new Uint8Array(L);else if(!Array.isArray(L)&&(!u||!ArrayBuffer.isView(L)))throw new Error(t)}else throw new Error(t);W=!0}for(var t1=this.blocks,q=this.byteCount,$=L.length,V=this.blockCount,i1=0,m1=this.s,n1,u1;i1<$;){if(this.reset)for(this.reset=!1,t1[0]=this.block,n1=1;n1>2]|=L[i1]<>2]|=u1<>2]|=(192|u1>>6)<>2]|=(128|u1&63)<=57344?(t1[n1>>2]|=(224|u1>>12)<>2]|=(128|u1>>6&63)<>2]|=(128|u1&63)<>2]|=(240|u1>>18)<>2]|=(128|u1>>12&63)<>2]|=(128|u1>>6&63)<>2]|=(128|u1&63)<=q){for(this.start=n1-q,this.block=t1[V],n1=0;n1>8,a1=L&255;a1>0;)q.unshift(a1),L=L>>8,a1=L&255,++t1;return W?q.push(t1):q.unshift(t1),this.update(q),q.length},S.prototype.encodeString=function(L){var W,a1=typeof L;if(a1!=="string"){if(a1==="object"){if(L===null)throw new Error(t);if(u&&L.constructor===ArrayBuffer)L=new Uint8Array(L);else if(!Array.isArray(L)&&(!u||!ArrayBuffer.isView(L)))throw new Error(t)}else throw new Error(t);W=!0}var t1=0,q=L.length;if(W)t1=q;else for(var $=0;$=57344?t1+=3:(V=65536+((V&1023)<<10|L.charCodeAt(++$)&1023),t1+=4)}return t1+=this.encode(t1*8),this.update(L),t1},S.prototype.bytepad=function(L,W){for(var a1=this.encode(W),t1=0;t1>2]|=this.padding[W&3],this.lastByteIndex===this.byteCount)for(L[0]=L[a1],W=1;W>4&15]+f[i1&15]+f[i1>>12&15]+f[i1>>8&15]+f[i1>>20&15]+f[i1>>16&15]+f[i1>>28&15]+f[i1>>24&15];$%L===0&&(z(W),q=0)}return t1&&(i1=W[q],V+=f[i1>>4&15]+f[i1&15],t1>1&&(V+=f[i1>>12&15]+f[i1>>8&15]),t1>2&&(V+=f[i1>>20&15]+f[i1>>16&15])),V},S.prototype.arrayBuffer=function(){this.finalize();var L=this.blockCount,W=this.s,a1=this.outputBlocks,t1=this.extraBytes,q=0,$=0,V=this.outputBits>>3,i1;t1?i1=new ArrayBuffer(a1+1<<2):i1=new ArrayBuffer(V);for(var m1=new Uint32Array(i1);$>8&255,V[i1+2]=m1>>16&255,V[i1+3]=m1>>24&255;$%L===0&&z(W)}return t1&&(i1=$<<2,m1=W[q],V[i1]=m1&255,t1>1&&(V[i1+1]=m1>>8&255),t1>2&&(V[i1+2]=m1>>16&255)),V};function M(L,W,a1){S.call(this,L,W,a1)}M.prototype=new S,M.prototype.finalize=function(){return this.encode(this.outputBits,!0),S.prototype.finalize.call(this)};var z=function(L){var W,a1,t1,q,$,V,i1,m1,n1,u1,R1,f1,d1,N1,p1,B1,Z1,v1,k1,y2,r1,s1,E1,h1,g1,u2,_1,M1,v2,T1,D1,i0,L1,Q1,y0,P1,U1,r0,j1,J1,Z3,z1,K1,ve,q1,V1,Z,X,Y,G,e1,l1,F1,A1,y1,p2,W1,o2,c2,w2,E2,_2,S2;for(t1=0;t1<48;t1+=2)q=L[0]^L[10]^L[20]^L[30]^L[40],$=L[1]^L[11]^L[21]^L[31]^L[41],V=L[2]^L[12]^L[22]^L[32]^L[42],i1=L[3]^L[13]^L[23]^L[33]^L[43],m1=L[4]^L[14]^L[24]^L[34]^L[44],n1=L[5]^L[15]^L[25]^L[35]^L[45],u1=L[6]^L[16]^L[26]^L[36]^L[46],R1=L[7]^L[17]^L[27]^L[37]^L[47],f1=L[8]^L[18]^L[28]^L[38]^L[48],d1=L[9]^L[19]^L[29]^L[39]^L[49],W=f1^(V<<1|i1>>>31),a1=d1^(i1<<1|V>>>31),L[0]^=W,L[1]^=a1,L[10]^=W,L[11]^=a1,L[20]^=W,L[21]^=a1,L[30]^=W,L[31]^=a1,L[40]^=W,L[41]^=a1,W=q^(m1<<1|n1>>>31),a1=$^(n1<<1|m1>>>31),L[2]^=W,L[3]^=a1,L[12]^=W,L[13]^=a1,L[22]^=W,L[23]^=a1,L[32]^=W,L[33]^=a1,L[42]^=W,L[43]^=a1,W=V^(u1<<1|R1>>>31),a1=i1^(R1<<1|u1>>>31),L[4]^=W,L[5]^=a1,L[14]^=W,L[15]^=a1,L[24]^=W,L[25]^=a1,L[34]^=W,L[35]^=a1,L[44]^=W,L[45]^=a1,W=m1^(f1<<1|d1>>>31),a1=n1^(d1<<1|f1>>>31),L[6]^=W,L[7]^=a1,L[16]^=W,L[17]^=a1,L[26]^=W,L[27]^=a1,L[36]^=W,L[37]^=a1,L[46]^=W,L[47]^=a1,W=u1^(q<<1|$>>>31),a1=R1^($<<1|q>>>31),L[8]^=W,L[9]^=a1,L[18]^=W,L[19]^=a1,L[28]^=W,L[29]^=a1,L[38]^=W,L[39]^=a1,L[48]^=W,L[49]^=a1,N1=L[0],p1=L[1],V1=L[11]<<4|L[10]>>>28,Z=L[10]<<4|L[11]>>>28,M1=L[20]<<3|L[21]>>>29,v2=L[21]<<3|L[20]>>>29,w2=L[31]<<9|L[30]>>>23,E2=L[30]<<9|L[31]>>>23,z1=L[40]<<18|L[41]>>>14,K1=L[41]<<18|L[40]>>>14,Q1=L[2]<<1|L[3]>>>31,y0=L[3]<<1|L[2]>>>31,B1=L[13]<<12|L[12]>>>20,Z1=L[12]<<12|L[13]>>>20,X=L[22]<<10|L[23]>>>22,Y=L[23]<<10|L[22]>>>22,T1=L[33]<<13|L[32]>>>19,D1=L[32]<<13|L[33]>>>19,_2=L[42]<<2|L[43]>>>30,S2=L[43]<<2|L[42]>>>30,A1=L[5]<<30|L[4]>>>2,y1=L[4]<<30|L[5]>>>2,P1=L[14]<<6|L[15]>>>26,U1=L[15]<<6|L[14]>>>26,v1=L[25]<<11|L[24]>>>21,k1=L[24]<<11|L[25]>>>21,G=L[34]<<15|L[35]>>>17,e1=L[35]<<15|L[34]>>>17,i0=L[45]<<29|L[44]>>>3,L1=L[44]<<29|L[45]>>>3,h1=L[6]<<28|L[7]>>>4,g1=L[7]<<28|L[6]>>>4,p2=L[17]<<23|L[16]>>>9,W1=L[16]<<23|L[17]>>>9,r0=L[26]<<25|L[27]>>>7,j1=L[27]<<25|L[26]>>>7,y2=L[36]<<21|L[37]>>>11,r1=L[37]<<21|L[36]>>>11,l1=L[47]<<24|L[46]>>>8,F1=L[46]<<24|L[47]>>>8,ve=L[8]<<27|L[9]>>>5,q1=L[9]<<27|L[8]>>>5,u2=L[18]<<20|L[19]>>>12,_1=L[19]<<20|L[18]>>>12,o2=L[29]<<7|L[28]>>>25,c2=L[28]<<7|L[29]>>>25,J1=L[38]<<8|L[39]>>>24,Z3=L[39]<<8|L[38]>>>24,s1=L[48]<<14|L[49]>>>18,E1=L[49]<<14|L[48]>>>18,L[0]=N1^~B1&v1,L[1]=p1^~Z1&k1,L[10]=h1^~u2&M1,L[11]=g1^~_1&v2,L[20]=Q1^~P1&r0,L[21]=y0^~U1&j1,L[30]=ve^~V1&X,L[31]=q1^~Z&Y,L[40]=A1^~p2&o2,L[41]=y1^~W1&c2,L[2]=B1^~v1&y2,L[3]=Z1^~k1&r1,L[12]=u2^~M1&T1,L[13]=_1^~v2&D1,L[22]=P1^~r0&J1,L[23]=U1^~j1&Z3,L[32]=V1^~X&G,L[33]=Z^~Y&e1,L[42]=p2^~o2&w2,L[43]=W1^~c2&E2,L[4]=v1^~y2&s1,L[5]=k1^~r1&E1,L[14]=M1^~T1&i0,L[15]=v2^~D1&L1,L[24]=r0^~J1&z1,L[25]=j1^~Z3&K1,L[34]=X^~G&l1,L[35]=Y^~e1&F1,L[44]=o2^~w2&_2,L[45]=c2^~E2&S2,L[6]=y2^~s1&N1,L[7]=r1^~E1&p1,L[16]=T1^~i0&h1,L[17]=D1^~L1&g1,L[26]=J1^~z1&Q1,L[27]=Z3^~K1&y0,L[36]=G^~l1&ve,L[37]=e1^~F1&q1,L[46]=w2^~_2&A1,L[47]=E2^~S2&y1,L[8]=s1^~N1&B1,L[9]=E1^~p1&Z1,L[18]=i0^~h1&u2,L[19]=L1^~g1&_1,L[28]=z1^~Q1&P1,L[29]=K1^~y0&U1,L[38]=l1^~ve&V1,L[39]=F1^~q1&Z,L[48]=_2^~A1&p2,L[49]=S2^~y1&W1,L[0]^=R[t1],L[1]^=R[t1+1]};if(o)zP.exports=h;else{for(x=0;x{"use strict";Object.defineProperty(VP,"__esModule",{value:!0});VP.version=void 0;VP.version="logger/5.8.0"});var L2=_(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});xu.Logger=xu.ErrorCode=xu.LogLevel=void 0;var zN1=!1,KN1=!1,YP={debug:1,default:2,info:2,warning:3,error:4,off:5},VN1=YP.default,JX2=JN1(),Ur1=null;function zX2(){try{var t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(e){try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(e){return e.message}return null}var YN1=zX2(),XN1;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(XN1=xu.LogLevel||(xu.LogLevel={}));var vu;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(vu=xu.ErrorCode||(xu.ErrorCode={}));var WN1="0123456789abcdef",KX2=function(){function t(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return t.prototype._log=function(e,r){var n=e.toLowerCase();YP[n]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(VN1>YP[n])&&console.log.apply(console,r)},t.prototype.debug=function(){for(var e=[],r=0;r>4],y+=WN1[p[v]&15];a.push(f+"=Uint8Array(0x"+y+")")}else a.push(f+"="+JSON.stringify(p))}catch{a.push(f+"="+JSON.stringify(n[f].toString()))}}),a.push("code="+r),a.push("version="+this.version);var s=e,o="";switch(r){case vu.NUMERIC_FAULT:{o="NUMERIC_FAULT";var c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case vu.CALL_EXCEPTION:case vu.INSUFFICIENT_FUNDS:case vu.MISSING_NEW:case vu.NONCE_EXPIRED:case vu.REPLACEMENT_UNDERPRICED:case vu.TRANSACTION_REPLACED:case vu.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),a.length&&(e+=" ("+a.join(", ")+")");var u=new Error(e);return u.reason=s,u.code=r,Object.keys(n).forEach(function(f){u[f]=n[f]}),u},t.prototype.throwError=function(e,r,n){throw this.makeError(e,r,n)},t.prototype.throwArgumentError=function(e,r,n){return this.throwError(e,t.errors.INVALID_ARGUMENT,{argument:r,value:n})},t.prototype.assert=function(e,r,n,a){e||this.throwError(r,n,a)},t.prototype.assertArgument=function(e,r,n,a){e||this.throwArgumentError(r,n,a)},t.prototype.checkNormalize=function(e){e==null&&(e="platform missing String.prototype.normalize"),YN1&&this.throwError("platform missing String.prototype.normalize",t.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:YN1})},t.prototype.checkSafeUint53=function(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))},t.prototype.checkArgumentCount=function(e,r,n){n?n=": "+n:n="",er&&this.throwError("too many arguments"+n,t.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})},t.prototype.checkNew=function(e,r){(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name})},t.prototype.checkAbstract=function(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",t.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name})},t.globalLogger=function(){return Ur1||(Ur1=new t(JX2.version)),Ur1},t.setCensorship=function(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),zN1){if(!e)return;this.globalLogger().throwError("error censorship permanent",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}KN1=!!e,zN1=!!r},t.setLogLevel=function(e){var r=YP[e.toLowerCase()];if(r==null){t.globalLogger().warn("invalid log level - "+e);return}VN1=r},t.from=function(e){return new t(e)},t.errors=vu,t.levels=XN1,t}();xu.Logger=KX2});var ZN1=_(WP=>{"use strict";Object.defineProperty(WP,"__esModule",{value:!0});WP.version=void 0;WP.version="bytes/5.8.0"});var sF1=_(C3=>{"use strict";Object.defineProperty(C3,"__esModule",{value:!0});C3.joinSignature=C3.splitSignature=C3.hexZeroPad=C3.hexStripZeros=C3.hexValue=C3.hexConcat=C3.hexDataSlice=C3.hexDataLength=C3.hexlify=C3.isHexString=C3.zeroPad=C3.stripZeros=C3.concat=C3.arrayify=C3.isBytes=C3.isBytesLike=void 0;var VX2=L2(),YX2=ZN1(),gt=new VX2.Logger(YX2.version);function eF1(t){return!!t.toHexString}function Ew(t){return t.slice||(t.slice=function(){var e=Array.prototype.slice.call(arguments);return Ew(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function tF1(t){return kc(t)&&!(t.length%2)||ZP(t)}C3.isBytesLike=tF1;function $N1(t){return typeof t=="number"&&t==t&&t%1===0}function ZP(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!$N1(t.length)||t.length<0)return!1;for(var e=0;e=256)return!1}return!0}C3.isBytes=ZP;function ym(t,e){if(e||(e={}),typeof t=="number"){gt.checkSafeUint53(t,"invalid arrayify value");for(var r=[];t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Ew(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),eF1(t)&&(t=t.toHexString()),kc(t)){var n=t.substring(2);n.length%2&&(e.hexPad==="left"?n="0"+n:e.hexPad==="right"?n+="0":gt.throwArgumentError("hex data is odd-length","value",t));for(var r=[],a=0;ae&>.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(e);return r.set(t,e-t.length),Ew(r)}C3.zeroPad=nF1;function kc(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}C3.isHexString=kc;var qr1="0123456789abcdef";function G5(t,e){if(e||(e={}),typeof t=="number"){gt.checkSafeUint53(t,"invalid hexlify value");for(var r="";t;)r=qr1[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),eF1(t))return t.toHexString();if(kc(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":gt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(ZP(t)){for(var n="0x",a=0;a>4]+qr1[s&15]}return n}return gt.throwArgumentError("invalid hexlify value","value",t)}C3.hexlify=G5;function XX2(t){if(typeof t!="string")t=G5(t);else if(!kc(t)||t.length%2)return null;return(t.length-2)/2}C3.hexDataLength=XX2;function ZX2(t,e,r){return typeof t!="string"?t=G5(t):(!kc(t)||t.length%2)&>.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}C3.hexDataSlice=ZX2;function $X2(t){var e="0x";return t.forEach(function(r){e+=G5(r).substring(2)}),e}C3.hexConcat=$X2;function eZ2(t){var e=iF1(G5(t,{hexPad:"left"}));return e==="0x"?"0x0":e}C3.hexValue=eZ2;function iF1(t){typeof t!="string"&&(t=G5(t)),kc(t)||gt.throwArgumentError("invalid hex string","value",t),t=t.substring(2);for(var e=0;e2*e+2&>.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}C3.hexZeroPad=XP;function aF1(t){var e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(tF1(t)){var r=ym(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=G5(r.slice(0,32)),e.s=G5(r.slice(32,64))):r.length===65?(e.r=G5(r.slice(0,32)),e.s=G5(r.slice(32,64)),e.v=r[64]):gt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:gt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=G5(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){var n=nF1(ym(e._vs),32);e._vs=G5(n);var a=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&>.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;var s=G5(n);e.s==null?e.s=s:e.s!==s&>.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?gt.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{var o=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==o&>.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!kc(e.r)?gt.throwArgumentError("signature missing or invalid r","signature",t):e.r=XP(e.r,32),e.s==null||!kc(e.s)?gt.throwArgumentError("signature missing or invalid s","signature",t):e.s=XP(e.s,32);var c=ym(e.s);c[0]>=128&>.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(c[0]|=128);var u=G5(c);e._vs&&(kc(e._vs)||gt.throwArgumentError("signature invalid _vs","signature",t),e._vs=XP(e._vs,32)),e._vs==null?e._vs=u:e._vs!==u&>.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}C3.splitSignature=aF1;function tZ2(t){return t=aF1(t),G5(rF1([t.r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}C3.joinSignature=tZ2});var mt=_(Iw=>{"use strict";var rZ2=Iw&&Iw.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Iw,"__esModule",{value:!0});Iw.keccak256=void 0;var nZ2=rZ2(KP()),iZ2=sF1();function aZ2(t){return"0x"+nZ2.default.keccak_256((0,iZ2.arrayify)(t))}Iw.keccak256=aZ2});var oF1=_($P=>{"use strict";Object.defineProperty($P,"__esModule",{value:!0});$P.AddressZero=void 0;$P.AddressZero="0x0000000000000000000000000000000000000000"});var JT=_((cF1,Hr1)=>{(function(t,e){"use strict";function r(g,h){if(!g)throw new Error(h||"Assertion failed")}function n(g,h){g.super_=h;var m=function(){};m.prototype=h.prototype,g.prototype=new m,g.prototype.constructor=g}function a(g,h,m){if(a.isBN(g))return g;this.negative=0,this.words=null,this.length=0,this.red=null,g!==null&&((h==="le"||h==="be")&&(m=h,h=10),this._init(g||0,h||10,m||"be"))}typeof t=="object"?t.exports=a:e.BN=a,a.BN=a,a.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=o1("buffer").Buffer}catch{}a.isBN=function(h){return h instanceof a?!0:h!==null&&typeof h=="object"&&h.constructor.wordSize===a.wordSize&&Array.isArray(h.words)},a.max=function(h,m){return h.cmp(m)>0?h:m},a.min=function(h,m){return h.cmp(m)<0?h:m},a.prototype._init=function(h,m,x){if(typeof h=="number")return this._initNumber(h,m,x);if(typeof h=="object")return this._initArray(h,m,x);m==="hex"&&(m=16),r(m===(m|0)&&m>=2&&m<=36),h=h.toString().replace(/\s+/g,"");var C=0;h[0]==="-"&&(C++,this.negative=1),C=0;C-=3)d=h[C]|h[C-1]<<8|h[C-2]<<16,this.words[b]|=d<>>26-w&67108863,w+=24,w>=26&&(w-=26,b++);else if(x==="le")for(C=0,b=0;C>>26-w&67108863,w+=24,w>=26&&(w-=26,b++);return this._strip()};function o(g,h){var m=g.charCodeAt(h);if(m>=48&&m<=57)return m-48;if(m>=65&&m<=70)return m-55;if(m>=97&&m<=102)return m-87;r(!1,"Invalid character in "+g)}function c(g,h,m){var x=o(g,m);return m-1>=h&&(x|=o(g,m-1)<<4),x}a.prototype._parseHex=function(h,m,x){this.length=Math.ceil((h.length-m)/6),this.words=new Array(this.length);for(var C=0;C=m;C-=2)w=c(h,m,C)<=18?(b-=18,d+=1,this.words[d]|=w>>>26):b+=8;else{var k=h.length-m;for(C=k%2===0?m+1:m;C=18?(b-=18,d+=1,this.words[d]|=w>>>26):b+=8}this._strip()};function u(g,h,m,x){for(var C=0,b=0,d=Math.min(g.length,m),w=h;w=49?b=k-49+10:k>=17?b=k-17+10:b=k,r(k>=0&&b1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},a.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{a.prototype[Symbol.for("nodejs.util.inspect.custom")]=p}catch{a.prototype.inspect=p}else a.prototype.inspect=p;function p(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],v=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],E=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];a.prototype.toString=function(h,m){h=h||10,m=m|0||1;var x;if(h===16||h==="hex"){x="";for(var C=0,b=0,d=0;d>>24-C&16777215,C+=2,C>=26&&(C-=26,d--),b!==0||d!==this.length-1?x=y[6-k.length]+k+x:x=k+x}for(b!==0&&(x=b.toString(16)+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}if(h===(h|0)&&h>=2&&h<=36){var S=v[h],M=E[h];x="";var z=this.clone();for(z.negative=0;!z.isZero();){var L=z.modrn(M).toString(h);z=z.idivn(M),z.isZero()?x=L+x:x=y[S-L.length]+L+x}for(this.isZero()&&(x="0"+x);x.length%m!==0;)x="0"+x;return this.negative!==0&&(x="-"+x),x}r(!1,"Base should be between 2 and 36")},a.prototype.toNumber=function(){var h=this.words[0];return this.length===2?h+=this.words[1]*67108864:this.length===3&&this.words[2]===1?h+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-h:h},a.prototype.toJSON=function(){return this.toString(16,2)},s&&(a.prototype.toBuffer=function(h,m){return this.toArrayLike(s,h,m)}),a.prototype.toArray=function(h,m){return this.toArrayLike(Array,h,m)};var I=function(h,m){return h.allocUnsafe?h.allocUnsafe(m):new h(m)};a.prototype.toArrayLike=function(h,m,x){this._strip();var C=this.byteLength(),b=x||Math.max(1,C);r(C<=b,"byte array longer than desired length"),r(b>0,"Requested array length <= 0");var d=I(h,b),w=m==="le"?"LE":"BE";return this["_toArrayLike"+w](d,C),d},a.prototype._toArrayLikeLE=function(h,m){for(var x=0,C=0,b=0,d=0;b>8&255),x>16&255),d===6?(x>24&255),C=0,d=0):(C=w>>>24,d+=2)}if(x=0&&(h[x--]=w>>8&255),x>=0&&(h[x--]=w>>16&255),d===6?(x>=0&&(h[x--]=w>>24&255),C=0,d=0):(C=w>>>24,d+=2)}if(x>=0)for(h[x--]=C;x>=0;)h[x--]=0},Math.clz32?a.prototype._countBits=function(h){return 32-Math.clz32(h)}:a.prototype._countBits=function(h){var m=h,x=0;return m>=4096&&(x+=13,m>>>=13),m>=64&&(x+=7,m>>>=7),m>=8&&(x+=4,m>>>=4),m>=2&&(x+=2,m>>>=2),x+m},a.prototype._zeroBits=function(h){if(h===0)return 26;var m=h,x=0;return m&8191||(x+=13,m>>>=13),m&127||(x+=7,m>>>=7),m&15||(x+=4,m>>>=4),m&3||(x+=2,m>>>=2),m&1||x++,x},a.prototype.bitLength=function(){var h=this.words[this.length-1],m=this._countBits(h);return(this.length-1)*26+m};function R(g){for(var h=new Array(g.bitLength()),m=0;m>>C&1}return h}a.prototype.zeroBits=function(){if(this.isZero())return 0;for(var h=0,m=0;mh.length?this.clone().ior(h):h.clone().ior(this)},a.prototype.uor=function(h){return this.length>h.length?this.clone().iuor(h):h.clone().iuor(this)},a.prototype.iuand=function(h){var m;this.length>h.length?m=h:m=this;for(var x=0;xh.length?this.clone().iand(h):h.clone().iand(this)},a.prototype.uand=function(h){return this.length>h.length?this.clone().iuand(h):h.clone().iuand(this)},a.prototype.iuxor=function(h){var m,x;this.length>h.length?(m=this,x=h):(m=h,x=this);for(var C=0;Ch.length?this.clone().ixor(h):h.clone().ixor(this)},a.prototype.uxor=function(h){return this.length>h.length?this.clone().iuxor(h):h.clone().iuxor(this)},a.prototype.inotn=function(h){r(typeof h=="number"&&h>=0);var m=Math.ceil(h/26)|0,x=h%26;this._expand(m),x>0&&m--;for(var C=0;C0&&(this.words[C]=~this.words[C]&67108863>>26-x),this._strip()},a.prototype.notn=function(h){return this.clone().inotn(h)},a.prototype.setn=function(h,m){r(typeof h=="number"&&h>=0);var x=h/26|0,C=h%26;return this._expand(x+1),m?this.words[x]=this.words[x]|1<h.length?(x=this,C=h):(x=h,C=this);for(var b=0,d=0;d>>26;for(;b!==0&&d>>26;if(this.length=x.length,b!==0)this.words[this.length]=b,this.length++;else if(x!==this)for(;dh.length?this.clone().iadd(h):h.clone().iadd(this)},a.prototype.isub=function(h){if(h.negative!==0){h.negative=0;var m=this.iadd(h);return h.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(h),this.negative=1,this._normSign();var x=this.cmp(h);if(x===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,b;x>0?(C=this,b=h):(C=h,b=this);for(var d=0,w=0;w>26,this.words[w]=m&67108863;for(;d!==0&&w>26,this.words[w]=m&67108863;if(d===0&&w>>26,z=k&67108863,L=Math.min(S,h.length-1),W=Math.max(0,S-g.length+1);W<=L;W++){var a1=S-W|0;C=g.words[a1]|0,b=h.words[W]|0,d=C*b+z,M+=d/67108864|0,z=d&67108863}m.words[S]=z|0,k=M|0}return k!==0?m.words[S]=k|0:m.length--,m._strip()}var D=function(h,m,x){var C=h.words,b=m.words,d=x.words,w=0,k,S,M,z=C[0]|0,L=z&8191,W=z>>>13,a1=C[1]|0,t1=a1&8191,q=a1>>>13,$=C[2]|0,V=$&8191,i1=$>>>13,m1=C[3]|0,n1=m1&8191,u1=m1>>>13,R1=C[4]|0,f1=R1&8191,d1=R1>>>13,N1=C[5]|0,p1=N1&8191,B1=N1>>>13,Z1=C[6]|0,v1=Z1&8191,k1=Z1>>>13,y2=C[7]|0,r1=y2&8191,s1=y2>>>13,E1=C[8]|0,h1=E1&8191,g1=E1>>>13,u2=C[9]|0,_1=u2&8191,M1=u2>>>13,v2=b[0]|0,T1=v2&8191,D1=v2>>>13,i0=b[1]|0,L1=i0&8191,Q1=i0>>>13,y0=b[2]|0,P1=y0&8191,U1=y0>>>13,r0=b[3]|0,j1=r0&8191,J1=r0>>>13,Z3=b[4]|0,z1=Z3&8191,K1=Z3>>>13,ve=b[5]|0,q1=ve&8191,V1=ve>>>13,Z=b[6]|0,X=Z&8191,Y=Z>>>13,G=b[7]|0,e1=G&8191,l1=G>>>13,F1=b[8]|0,A1=F1&8191,y1=F1>>>13,p2=b[9]|0,W1=p2&8191,o2=p2>>>13;x.negative=h.negative^m.negative,x.length=19,k=Math.imul(L,T1),S=Math.imul(L,D1),S=S+Math.imul(W,T1)|0,M=Math.imul(W,D1);var c2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(c2>>>26)|0,c2&=67108863,k=Math.imul(t1,T1),S=Math.imul(t1,D1),S=S+Math.imul(q,T1)|0,M=Math.imul(q,D1),k=k+Math.imul(L,L1)|0,S=S+Math.imul(L,Q1)|0,S=S+Math.imul(W,L1)|0,M=M+Math.imul(W,Q1)|0;var w2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(w2>>>26)|0,w2&=67108863,k=Math.imul(V,T1),S=Math.imul(V,D1),S=S+Math.imul(i1,T1)|0,M=Math.imul(i1,D1),k=k+Math.imul(t1,L1)|0,S=S+Math.imul(t1,Q1)|0,S=S+Math.imul(q,L1)|0,M=M+Math.imul(q,Q1)|0,k=k+Math.imul(L,P1)|0,S=S+Math.imul(L,U1)|0,S=S+Math.imul(W,P1)|0,M=M+Math.imul(W,U1)|0;var E2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(E2>>>26)|0,E2&=67108863,k=Math.imul(n1,T1),S=Math.imul(n1,D1),S=S+Math.imul(u1,T1)|0,M=Math.imul(u1,D1),k=k+Math.imul(V,L1)|0,S=S+Math.imul(V,Q1)|0,S=S+Math.imul(i1,L1)|0,M=M+Math.imul(i1,Q1)|0,k=k+Math.imul(t1,P1)|0,S=S+Math.imul(t1,U1)|0,S=S+Math.imul(q,P1)|0,M=M+Math.imul(q,U1)|0,k=k+Math.imul(L,j1)|0,S=S+Math.imul(L,J1)|0,S=S+Math.imul(W,j1)|0,M=M+Math.imul(W,J1)|0;var _2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(_2>>>26)|0,_2&=67108863,k=Math.imul(f1,T1),S=Math.imul(f1,D1),S=S+Math.imul(d1,T1)|0,M=Math.imul(d1,D1),k=k+Math.imul(n1,L1)|0,S=S+Math.imul(n1,Q1)|0,S=S+Math.imul(u1,L1)|0,M=M+Math.imul(u1,Q1)|0,k=k+Math.imul(V,P1)|0,S=S+Math.imul(V,U1)|0,S=S+Math.imul(i1,P1)|0,M=M+Math.imul(i1,U1)|0,k=k+Math.imul(t1,j1)|0,S=S+Math.imul(t1,J1)|0,S=S+Math.imul(q,j1)|0,M=M+Math.imul(q,J1)|0,k=k+Math.imul(L,z1)|0,S=S+Math.imul(L,K1)|0,S=S+Math.imul(W,z1)|0,M=M+Math.imul(W,K1)|0;var S2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(S2>>>26)|0,S2&=67108863,k=Math.imul(p1,T1),S=Math.imul(p1,D1),S=S+Math.imul(B1,T1)|0,M=Math.imul(B1,D1),k=k+Math.imul(f1,L1)|0,S=S+Math.imul(f1,Q1)|0,S=S+Math.imul(d1,L1)|0,M=M+Math.imul(d1,Q1)|0,k=k+Math.imul(n1,P1)|0,S=S+Math.imul(n1,U1)|0,S=S+Math.imul(u1,P1)|0,M=M+Math.imul(u1,U1)|0,k=k+Math.imul(V,j1)|0,S=S+Math.imul(V,J1)|0,S=S+Math.imul(i1,j1)|0,M=M+Math.imul(i1,J1)|0,k=k+Math.imul(t1,z1)|0,S=S+Math.imul(t1,K1)|0,S=S+Math.imul(q,z1)|0,M=M+Math.imul(q,K1)|0,k=k+Math.imul(L,q1)|0,S=S+Math.imul(L,V1)|0,S=S+Math.imul(W,q1)|0,M=M+Math.imul(W,V1)|0;var R2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(R2>>>26)|0,R2&=67108863,k=Math.imul(v1,T1),S=Math.imul(v1,D1),S=S+Math.imul(k1,T1)|0,M=Math.imul(k1,D1),k=k+Math.imul(p1,L1)|0,S=S+Math.imul(p1,Q1)|0,S=S+Math.imul(B1,L1)|0,M=M+Math.imul(B1,Q1)|0,k=k+Math.imul(f1,P1)|0,S=S+Math.imul(f1,U1)|0,S=S+Math.imul(d1,P1)|0,M=M+Math.imul(d1,U1)|0,k=k+Math.imul(n1,j1)|0,S=S+Math.imul(n1,J1)|0,S=S+Math.imul(u1,j1)|0,M=M+Math.imul(u1,J1)|0,k=k+Math.imul(V,z1)|0,S=S+Math.imul(V,K1)|0,S=S+Math.imul(i1,z1)|0,M=M+Math.imul(i1,K1)|0,k=k+Math.imul(t1,q1)|0,S=S+Math.imul(t1,V1)|0,S=S+Math.imul(q,q1)|0,M=M+Math.imul(q,V1)|0,k=k+Math.imul(L,X)|0,S=S+Math.imul(L,Y)|0,S=S+Math.imul(W,X)|0,M=M+Math.imul(W,Y)|0;var k2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(k2>>>26)|0,k2&=67108863,k=Math.imul(r1,T1),S=Math.imul(r1,D1),S=S+Math.imul(s1,T1)|0,M=Math.imul(s1,D1),k=k+Math.imul(v1,L1)|0,S=S+Math.imul(v1,Q1)|0,S=S+Math.imul(k1,L1)|0,M=M+Math.imul(k1,Q1)|0,k=k+Math.imul(p1,P1)|0,S=S+Math.imul(p1,U1)|0,S=S+Math.imul(B1,P1)|0,M=M+Math.imul(B1,U1)|0,k=k+Math.imul(f1,j1)|0,S=S+Math.imul(f1,J1)|0,S=S+Math.imul(d1,j1)|0,M=M+Math.imul(d1,J1)|0,k=k+Math.imul(n1,z1)|0,S=S+Math.imul(n1,K1)|0,S=S+Math.imul(u1,z1)|0,M=M+Math.imul(u1,K1)|0,k=k+Math.imul(V,q1)|0,S=S+Math.imul(V,V1)|0,S=S+Math.imul(i1,q1)|0,M=M+Math.imul(i1,V1)|0,k=k+Math.imul(t1,X)|0,S=S+Math.imul(t1,Y)|0,S=S+Math.imul(q,X)|0,M=M+Math.imul(q,Y)|0,k=k+Math.imul(L,e1)|0,S=S+Math.imul(L,l1)|0,S=S+Math.imul(W,e1)|0,M=M+Math.imul(W,l1)|0;var T2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(T2>>>26)|0,T2&=67108863,k=Math.imul(h1,T1),S=Math.imul(h1,D1),S=S+Math.imul(g1,T1)|0,M=Math.imul(g1,D1),k=k+Math.imul(r1,L1)|0,S=S+Math.imul(r1,Q1)|0,S=S+Math.imul(s1,L1)|0,M=M+Math.imul(s1,Q1)|0,k=k+Math.imul(v1,P1)|0,S=S+Math.imul(v1,U1)|0,S=S+Math.imul(k1,P1)|0,M=M+Math.imul(k1,U1)|0,k=k+Math.imul(p1,j1)|0,S=S+Math.imul(p1,J1)|0,S=S+Math.imul(B1,j1)|0,M=M+Math.imul(B1,J1)|0,k=k+Math.imul(f1,z1)|0,S=S+Math.imul(f1,K1)|0,S=S+Math.imul(d1,z1)|0,M=M+Math.imul(d1,K1)|0,k=k+Math.imul(n1,q1)|0,S=S+Math.imul(n1,V1)|0,S=S+Math.imul(u1,q1)|0,M=M+Math.imul(u1,V1)|0,k=k+Math.imul(V,X)|0,S=S+Math.imul(V,Y)|0,S=S+Math.imul(i1,X)|0,M=M+Math.imul(i1,Y)|0,k=k+Math.imul(t1,e1)|0,S=S+Math.imul(t1,l1)|0,S=S+Math.imul(q,e1)|0,M=M+Math.imul(q,l1)|0,k=k+Math.imul(L,A1)|0,S=S+Math.imul(L,y1)|0,S=S+Math.imul(W,A1)|0,M=M+Math.imul(W,y1)|0;var h2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(h2>>>26)|0,h2&=67108863,k=Math.imul(_1,T1),S=Math.imul(_1,D1),S=S+Math.imul(M1,T1)|0,M=Math.imul(M1,D1),k=k+Math.imul(h1,L1)|0,S=S+Math.imul(h1,Q1)|0,S=S+Math.imul(g1,L1)|0,M=M+Math.imul(g1,Q1)|0,k=k+Math.imul(r1,P1)|0,S=S+Math.imul(r1,U1)|0,S=S+Math.imul(s1,P1)|0,M=M+Math.imul(s1,U1)|0,k=k+Math.imul(v1,j1)|0,S=S+Math.imul(v1,J1)|0,S=S+Math.imul(k1,j1)|0,M=M+Math.imul(k1,J1)|0,k=k+Math.imul(p1,z1)|0,S=S+Math.imul(p1,K1)|0,S=S+Math.imul(B1,z1)|0,M=M+Math.imul(B1,K1)|0,k=k+Math.imul(f1,q1)|0,S=S+Math.imul(f1,V1)|0,S=S+Math.imul(d1,q1)|0,M=M+Math.imul(d1,V1)|0,k=k+Math.imul(n1,X)|0,S=S+Math.imul(n1,Y)|0,S=S+Math.imul(u1,X)|0,M=M+Math.imul(u1,Y)|0,k=k+Math.imul(V,e1)|0,S=S+Math.imul(V,l1)|0,S=S+Math.imul(i1,e1)|0,M=M+Math.imul(i1,l1)|0,k=k+Math.imul(t1,A1)|0,S=S+Math.imul(t1,y1)|0,S=S+Math.imul(q,A1)|0,M=M+Math.imul(q,y1)|0,k=k+Math.imul(L,W1)|0,S=S+Math.imul(L,o2)|0,S=S+Math.imul(W,W1)|0,M=M+Math.imul(W,o2)|0;var b2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(b2>>>26)|0,b2&=67108863,k=Math.imul(_1,L1),S=Math.imul(_1,Q1),S=S+Math.imul(M1,L1)|0,M=Math.imul(M1,Q1),k=k+Math.imul(h1,P1)|0,S=S+Math.imul(h1,U1)|0,S=S+Math.imul(g1,P1)|0,M=M+Math.imul(g1,U1)|0,k=k+Math.imul(r1,j1)|0,S=S+Math.imul(r1,J1)|0,S=S+Math.imul(s1,j1)|0,M=M+Math.imul(s1,J1)|0,k=k+Math.imul(v1,z1)|0,S=S+Math.imul(v1,K1)|0,S=S+Math.imul(k1,z1)|0,M=M+Math.imul(k1,K1)|0,k=k+Math.imul(p1,q1)|0,S=S+Math.imul(p1,V1)|0,S=S+Math.imul(B1,q1)|0,M=M+Math.imul(B1,V1)|0,k=k+Math.imul(f1,X)|0,S=S+Math.imul(f1,Y)|0,S=S+Math.imul(d1,X)|0,M=M+Math.imul(d1,Y)|0,k=k+Math.imul(n1,e1)|0,S=S+Math.imul(n1,l1)|0,S=S+Math.imul(u1,e1)|0,M=M+Math.imul(u1,l1)|0,k=k+Math.imul(V,A1)|0,S=S+Math.imul(V,y1)|0,S=S+Math.imul(i1,A1)|0,M=M+Math.imul(i1,y1)|0,k=k+Math.imul(t1,W1)|0,S=S+Math.imul(t1,o2)|0,S=S+Math.imul(q,W1)|0,M=M+Math.imul(q,o2)|0;var l2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(l2>>>26)|0,l2&=67108863,k=Math.imul(_1,P1),S=Math.imul(_1,U1),S=S+Math.imul(M1,P1)|0,M=Math.imul(M1,U1),k=k+Math.imul(h1,j1)|0,S=S+Math.imul(h1,J1)|0,S=S+Math.imul(g1,j1)|0,M=M+Math.imul(g1,J1)|0,k=k+Math.imul(r1,z1)|0,S=S+Math.imul(r1,K1)|0,S=S+Math.imul(s1,z1)|0,M=M+Math.imul(s1,K1)|0,k=k+Math.imul(v1,q1)|0,S=S+Math.imul(v1,V1)|0,S=S+Math.imul(k1,q1)|0,M=M+Math.imul(k1,V1)|0,k=k+Math.imul(p1,X)|0,S=S+Math.imul(p1,Y)|0,S=S+Math.imul(B1,X)|0,M=M+Math.imul(B1,Y)|0,k=k+Math.imul(f1,e1)|0,S=S+Math.imul(f1,l1)|0,S=S+Math.imul(d1,e1)|0,M=M+Math.imul(d1,l1)|0,k=k+Math.imul(n1,A1)|0,S=S+Math.imul(n1,y1)|0,S=S+Math.imul(u1,A1)|0,M=M+Math.imul(u1,y1)|0,k=k+Math.imul(V,W1)|0,S=S+Math.imul(V,o2)|0,S=S+Math.imul(i1,W1)|0,M=M+Math.imul(i1,o2)|0;var A2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(A2>>>26)|0,A2&=67108863,k=Math.imul(_1,j1),S=Math.imul(_1,J1),S=S+Math.imul(M1,j1)|0,M=Math.imul(M1,J1),k=k+Math.imul(h1,z1)|0,S=S+Math.imul(h1,K1)|0,S=S+Math.imul(g1,z1)|0,M=M+Math.imul(g1,K1)|0,k=k+Math.imul(r1,q1)|0,S=S+Math.imul(r1,V1)|0,S=S+Math.imul(s1,q1)|0,M=M+Math.imul(s1,V1)|0,k=k+Math.imul(v1,X)|0,S=S+Math.imul(v1,Y)|0,S=S+Math.imul(k1,X)|0,M=M+Math.imul(k1,Y)|0,k=k+Math.imul(p1,e1)|0,S=S+Math.imul(p1,l1)|0,S=S+Math.imul(B1,e1)|0,M=M+Math.imul(B1,l1)|0,k=k+Math.imul(f1,A1)|0,S=S+Math.imul(f1,y1)|0,S=S+Math.imul(d1,A1)|0,M=M+Math.imul(d1,y1)|0,k=k+Math.imul(n1,W1)|0,S=S+Math.imul(n1,o2)|0,S=S+Math.imul(u1,W1)|0,M=M+Math.imul(u1,o2)|0;var m2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(m2>>>26)|0,m2&=67108863,k=Math.imul(_1,z1),S=Math.imul(_1,K1),S=S+Math.imul(M1,z1)|0,M=Math.imul(M1,K1),k=k+Math.imul(h1,q1)|0,S=S+Math.imul(h1,V1)|0,S=S+Math.imul(g1,q1)|0,M=M+Math.imul(g1,V1)|0,k=k+Math.imul(r1,X)|0,S=S+Math.imul(r1,Y)|0,S=S+Math.imul(s1,X)|0,M=M+Math.imul(s1,Y)|0,k=k+Math.imul(v1,e1)|0,S=S+Math.imul(v1,l1)|0,S=S+Math.imul(k1,e1)|0,M=M+Math.imul(k1,l1)|0,k=k+Math.imul(p1,A1)|0,S=S+Math.imul(p1,y1)|0,S=S+Math.imul(B1,A1)|0,M=M+Math.imul(B1,y1)|0,k=k+Math.imul(f1,W1)|0,S=S+Math.imul(f1,o2)|0,S=S+Math.imul(d1,W1)|0,M=M+Math.imul(d1,o2)|0;var s2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(s2>>>26)|0,s2&=67108863,k=Math.imul(_1,q1),S=Math.imul(_1,V1),S=S+Math.imul(M1,q1)|0,M=Math.imul(M1,V1),k=k+Math.imul(h1,X)|0,S=S+Math.imul(h1,Y)|0,S=S+Math.imul(g1,X)|0,M=M+Math.imul(g1,Y)|0,k=k+Math.imul(r1,e1)|0,S=S+Math.imul(r1,l1)|0,S=S+Math.imul(s1,e1)|0,M=M+Math.imul(s1,l1)|0,k=k+Math.imul(v1,A1)|0,S=S+Math.imul(v1,y1)|0,S=S+Math.imul(k1,A1)|0,M=M+Math.imul(k1,y1)|0,k=k+Math.imul(p1,W1)|0,S=S+Math.imul(p1,o2)|0,S=S+Math.imul(B1,W1)|0,M=M+Math.imul(B1,o2)|0;var H1=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(H1>>>26)|0,H1&=67108863,k=Math.imul(_1,X),S=Math.imul(_1,Y),S=S+Math.imul(M1,X)|0,M=Math.imul(M1,Y),k=k+Math.imul(h1,e1)|0,S=S+Math.imul(h1,l1)|0,S=S+Math.imul(g1,e1)|0,M=M+Math.imul(g1,l1)|0,k=k+Math.imul(r1,A1)|0,S=S+Math.imul(r1,y1)|0,S=S+Math.imul(s1,A1)|0,M=M+Math.imul(s1,y1)|0,k=k+Math.imul(v1,W1)|0,S=S+Math.imul(v1,o2)|0,S=S+Math.imul(k1,W1)|0,M=M+Math.imul(k1,o2)|0;var G1=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(G1>>>26)|0,G1&=67108863,k=Math.imul(_1,e1),S=Math.imul(_1,l1),S=S+Math.imul(M1,e1)|0,M=Math.imul(M1,l1),k=k+Math.imul(h1,A1)|0,S=S+Math.imul(h1,y1)|0,S=S+Math.imul(g1,A1)|0,M=M+Math.imul(g1,y1)|0,k=k+Math.imul(r1,W1)|0,S=S+Math.imul(r1,o2)|0,S=S+Math.imul(s1,W1)|0,M=M+Math.imul(s1,o2)|0;var i2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(i2>>>26)|0,i2&=67108863,k=Math.imul(_1,A1),S=Math.imul(_1,y1),S=S+Math.imul(M1,A1)|0,M=Math.imul(M1,y1),k=k+Math.imul(h1,W1)|0,S=S+Math.imul(h1,o2)|0,S=S+Math.imul(g1,W1)|0,M=M+Math.imul(g1,o2)|0;var t2=(w+k|0)+((S&8191)<<13)|0;w=(M+(S>>>13)|0)+(t2>>>26)|0,t2&=67108863,k=Math.imul(_1,W1),S=Math.imul(_1,o2),S=S+Math.imul(M1,W1)|0,M=Math.imul(M1,o2);var r2=(w+k|0)+((S&8191)<<13)|0;return w=(M+(S>>>13)|0)+(r2>>>26)|0,r2&=67108863,d[0]=c2,d[1]=w2,d[2]=E2,d[3]=_2,d[4]=S2,d[5]=R2,d[6]=k2,d[7]=T2,d[8]=h2,d[9]=b2,d[10]=l2,d[11]=A2,d[12]=m2,d[13]=s2,d[14]=H1,d[15]=G1,d[16]=i2,d[17]=t2,d[18]=r2,w!==0&&(d[19]=w,x.length++),x};Math.imul||(D=T);function O(g,h,m){m.negative=h.negative^g.negative,m.length=g.length+h.length;for(var x=0,C=0,b=0;b>>26)|0,C+=d>>>26,d&=67108863}m.words[b]=w,x=d,d=C}return x!==0?m.words[b]=x:m.length--,m._strip()}function F(g,h,m){return O(g,h,m)}a.prototype.mulTo=function(h,m){var x,C=this.length+h.length;return this.length===10&&h.length===10?x=D(this,h,m):C<63?x=T(this,h,m):C<1024?x=O(this,h,m):x=F(this,h,m),x};function H(g,h){this.x=g,this.y=h}H.prototype.makeRBT=function(h){for(var m=new Array(h),x=a.prototype._countBits(h)-1,C=0;C>=1;return C},H.prototype.permute=function(h,m,x,C,b,d){for(var w=0;w>>1)b++;return 1<>>13,x[2*d+1]=b&8191,b=b>>>13;for(d=2*m;d>=26,x+=b/67108864|0,x+=d>>>26,this.words[C]=d&67108863}return x!==0&&(this.words[C]=x,this.length++),this.length=h===0?1:this.length,m?this.ineg():this},a.prototype.muln=function(h){return this.clone().imuln(h)},a.prototype.sqr=function(){return this.mul(this)},a.prototype.isqr=function(){return this.imul(this.clone())},a.prototype.pow=function(h){var m=R(h);if(m.length===0)return new a(1);for(var x=this,C=0;C=0);var m=h%26,x=(h-m)/26,C=67108863>>>26-m<<26-m,b;if(m!==0){var d=0;for(b=0;b>>26-m}d&&(this.words[b]=d,this.length++)}if(x!==0){for(b=this.length-1;b>=0;b--)this.words[b+x]=this.words[b];for(b=0;b=0);var C;m?C=(m-m%26)/26:C=0;var b=h%26,d=Math.min((h-b)/26,this.length),w=67108863^67108863>>>b<d)for(this.length-=d,S=0;S=0&&(M!==0||S>=C);S--){var z=this.words[S]|0;this.words[S]=M<<26-b|z>>>b,M=z&w}return k&&M!==0&&(k.words[k.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},a.prototype.ishrn=function(h,m,x){return r(this.negative===0),this.iushrn(h,m,x)},a.prototype.shln=function(h){return this.clone().ishln(h)},a.prototype.ushln=function(h){return this.clone().iushln(h)},a.prototype.shrn=function(h){return this.clone().ishrn(h)},a.prototype.ushrn=function(h){return this.clone().iushrn(h)},a.prototype.testn=function(h){r(typeof h=="number"&&h>=0);var m=h%26,x=(h-m)/26,C=1<=0);var m=h%26,x=(h-m)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=x)return this;if(m!==0&&x++,this.length=Math.min(x,this.length),m!==0){var C=67108863^67108863>>>m<=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},a.prototype.isubn=function(h){if(r(typeof h=="number"),r(h<67108864),h<0)return this.iaddn(-h);if(this.negative!==0)return this.negative=0,this.iaddn(h),this.negative=1,this;if(this.words[0]-=h,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m>26)-(k/67108864|0),this.words[b+x]=d&67108863}for(;b>26,this.words[b+x]=d&67108863;if(w===0)return this._strip();for(r(w===-1),w=0,b=0;b>26,this.words[b]=d&67108863;return this.negative=1,this._strip()},a.prototype._wordDiv=function(h,m){var x=this.length-h.length,C=this.clone(),b=h,d=b.words[b.length-1]|0,w=this._countBits(d);x=26-w,x!==0&&(b=b.ushln(x),C.iushln(x),d=b.words[b.length-1]|0);var k=C.length-b.length,S;if(m!=="mod"){S=new a(null),S.length=k+1,S.words=new Array(S.length);for(var M=0;M=0;L--){var W=(C.words[b.length+L]|0)*67108864+(C.words[b.length+L-1]|0);for(W=Math.min(W/d|0,67108863),C._ishlnsubmul(b,W,L);C.negative!==0;)W--,C.negative=0,C._ishlnsubmul(b,1,L),C.isZero()||(C.negative^=1);S&&(S.words[L]=W)}return S&&S._strip(),C._strip(),m!=="div"&&x!==0&&C.iushrn(x),{div:S||null,mod:C}},a.prototype.divmod=function(h,m,x){if(r(!h.isZero()),this.isZero())return{div:new a(0),mod:new a(0)};var C,b,d;return this.negative!==0&&h.negative===0?(d=this.neg().divmod(h,m),m!=="mod"&&(C=d.div.neg()),m!=="div"&&(b=d.mod.neg(),x&&b.negative!==0&&b.iadd(h)),{div:C,mod:b}):this.negative===0&&h.negative!==0?(d=this.divmod(h.neg(),m),m!=="mod"&&(C=d.div.neg()),{div:C,mod:d.mod}):this.negative&h.negative?(d=this.neg().divmod(h.neg(),m),m!=="div"&&(b=d.mod.neg(),x&&b.negative!==0&&b.isub(h)),{div:d.div,mod:b}):h.length>this.length||this.cmp(h)<0?{div:new a(0),mod:this}:h.length===1?m==="div"?{div:this.divn(h.words[0]),mod:null}:m==="mod"?{div:null,mod:new a(this.modrn(h.words[0]))}:{div:this.divn(h.words[0]),mod:new a(this.modrn(h.words[0]))}:this._wordDiv(h,m)},a.prototype.div=function(h){return this.divmod(h,"div",!1).div},a.prototype.mod=function(h){return this.divmod(h,"mod",!1).mod},a.prototype.umod=function(h){return this.divmod(h,"mod",!0).mod},a.prototype.divRound=function(h){var m=this.divmod(h);if(m.mod.isZero())return m.div;var x=m.div.negative!==0?m.mod.isub(h):m.mod,C=h.ushrn(1),b=h.andln(1),d=x.cmp(C);return d<0||b===1&&d===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},a.prototype.modrn=function(h){var m=h<0;m&&(h=-h),r(h<=67108863);for(var x=(1<<26)%h,C=0,b=this.length-1;b>=0;b--)C=(x*C+(this.words[b]|0))%h;return m?-C:C},a.prototype.modn=function(h){return this.modrn(h)},a.prototype.idivn=function(h){var m=h<0;m&&(h=-h),r(h<=67108863);for(var x=0,C=this.length-1;C>=0;C--){var b=(this.words[C]|0)+x*67108864;this.words[C]=b/h|0,x=b%h}return this._strip(),m?this.ineg():this},a.prototype.divn=function(h){return this.clone().idivn(h)},a.prototype.egcd=function(h){r(h.negative===0),r(!h.isZero());var m=this,x=h.clone();m.negative!==0?m=m.umod(h):m=m.clone();for(var C=new a(1),b=new a(0),d=new a(0),w=new a(1),k=0;m.isEven()&&x.isEven();)m.iushrn(1),x.iushrn(1),++k;for(var S=x.clone(),M=m.clone();!m.isZero();){for(var z=0,L=1;!(m.words[0]&L)&&z<26;++z,L<<=1);if(z>0)for(m.iushrn(z);z-- >0;)(C.isOdd()||b.isOdd())&&(C.iadd(S),b.isub(M)),C.iushrn(1),b.iushrn(1);for(var W=0,a1=1;!(x.words[0]&a1)&&W<26;++W,a1<<=1);if(W>0)for(x.iushrn(W);W-- >0;)(d.isOdd()||w.isOdd())&&(d.iadd(S),w.isub(M)),d.iushrn(1),w.iushrn(1);m.cmp(x)>=0?(m.isub(x),C.isub(d),b.isub(w)):(x.isub(m),d.isub(C),w.isub(b))}return{a:d,b:w,gcd:x.iushln(k)}},a.prototype._invmp=function(h){r(h.negative===0),r(!h.isZero());var m=this,x=h.clone();m.negative!==0?m=m.umod(h):m=m.clone();for(var C=new a(1),b=new a(0),d=x.clone();m.cmpn(1)>0&&x.cmpn(1)>0;){for(var w=0,k=1;!(m.words[0]&k)&&w<26;++w,k<<=1);if(w>0)for(m.iushrn(w);w-- >0;)C.isOdd()&&C.iadd(d),C.iushrn(1);for(var S=0,M=1;!(x.words[0]&M)&&S<26;++S,M<<=1);if(S>0)for(x.iushrn(S);S-- >0;)b.isOdd()&&b.iadd(d),b.iushrn(1);m.cmp(x)>=0?(m.isub(x),C.isub(b)):(x.isub(m),b.isub(C))}var z;return m.cmpn(1)===0?z=C:z=b,z.cmpn(0)<0&&z.iadd(h),z},a.prototype.gcd=function(h){if(this.isZero())return h.abs();if(h.isZero())return this.abs();var m=this.clone(),x=h.clone();m.negative=0,x.negative=0;for(var C=0;m.isEven()&&x.isEven();C++)m.iushrn(1),x.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;x.isEven();)x.iushrn(1);var b=m.cmp(x);if(b<0){var d=m;m=x,x=d}else if(b===0||x.cmpn(1)===0)break;m.isub(x)}while(!0);return x.iushln(C)},a.prototype.invm=function(h){return this.egcd(h).a.umod(h)},a.prototype.isEven=function(){return(this.words[0]&1)===0},a.prototype.isOdd=function(){return(this.words[0]&1)===1},a.prototype.andln=function(h){return this.words[0]&h},a.prototype.bincn=function(h){r(typeof h=="number");var m=h%26,x=(h-m)/26,C=1<>>26,w&=67108863,this.words[d]=w}return b!==0&&(this.words[d]=b,this.length++),this},a.prototype.isZero=function(){return this.length===1&&this.words[0]===0},a.prototype.cmpn=function(h){var m=h<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this._strip();var x;if(this.length>1)x=1;else{m&&(h=-h),r(h<=67108863,"Number is too big");var C=this.words[0]|0;x=C===h?0:Ch.length)return 1;if(this.length=0;x--){var C=this.words[x]|0,b=h.words[x]|0;if(C!==b){Cb&&(m=1);break}}return m},a.prototype.gtn=function(h){return this.cmpn(h)===1},a.prototype.gt=function(h){return this.cmp(h)===1},a.prototype.gten=function(h){return this.cmpn(h)>=0},a.prototype.gte=function(h){return this.cmp(h)>=0},a.prototype.ltn=function(h){return this.cmpn(h)===-1},a.prototype.lt=function(h){return this.cmp(h)===-1},a.prototype.lten=function(h){return this.cmpn(h)<=0},a.prototype.lte=function(h){return this.cmp(h)<=0},a.prototype.eqn=function(h){return this.cmpn(h)===0},a.prototype.eq=function(h){return this.cmp(h)===0},a.red=function(h){return new l(h)},a.prototype.toRed=function(h){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),h.convertTo(this)._forceRed(h)},a.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},a.prototype._forceRed=function(h){return this.red=h,this},a.prototype.forceRed=function(h){return r(!this.red,"Already a number in reduction context"),this._forceRed(h)},a.prototype.redAdd=function(h){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,h)},a.prototype.redIAdd=function(h){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,h)},a.prototype.redSub=function(h){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,h)},a.prototype.redISub=function(h){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,h)},a.prototype.redShl=function(h){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,h)},a.prototype.redMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.mul(this,h)},a.prototype.redIMul=function(h){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,h),this.red.imul(this,h)},a.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},a.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},a.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},a.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},a.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},a.prototype.redPow=function(h){return r(this.red&&!h.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,h)};var j={k256:null,p224:null,p192:null,p25519:null};function P(g,h){this.name=g,this.p=new a(h,16),this.n=this.p.bitLength(),this.k=new a(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}P.prototype._tmp=function(){var h=new a(null);return h.words=new Array(Math.ceil(this.n/13)),h},P.prototype.ireduce=function(h){var m=h,x;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),x=m.bitLength();while(x>this.n);var C=x0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},P.prototype.split=function(h,m){h.iushrn(this.n,0,m)},P.prototype.imulK=function(h){return h.imul(this.k)};function J(){P.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(J,P),J.prototype.split=function(h,m){for(var x=4194303,C=Math.min(h.length,9),b=0;b>>22,d=w}d>>>=22,h.words[b-10]=d,d===0&&h.length>10?h.length-=10:h.length-=9},J.prototype.imulK=function(h){h.words[h.length]=0,h.words[h.length+1]=0,h.length+=2;for(var m=0,x=0;x>>=26,h.words[x]=b,m=C}return m!==0&&(h.words[h.length++]=m),h},a._prime=function(h){if(j[h])return j[h];var m;if(h==="k256")m=new J;else if(h==="p224")m=new Q;else if(h==="p192")m=new N;else if(h==="p25519")m=new B;else throw new Error("Unknown prime "+h);return j[h]=m,m};function l(g){if(typeof g=="string"){var h=a._prime(g);this.m=h.p,this.prime=h}else r(g.gtn(1),"modulus must be greater than 1"),this.m=g,this.prime=null}l.prototype._verify1=function(h){r(h.negative===0,"red works only with positives"),r(h.red,"red works only with red numbers")},l.prototype._verify2=function(h,m){r((h.negative|m.negative)===0,"red works only with positives"),r(h.red&&h.red===m.red,"red works only with red numbers")},l.prototype.imod=function(h){return this.prime?this.prime.ireduce(h)._forceRed(this):(f(h,h.umod(this.m)._forceRed(this)),h)},l.prototype.neg=function(h){return h.isZero()?h.clone():this.m.sub(h)._forceRed(this)},l.prototype.add=function(h,m){this._verify2(h,m);var x=h.add(m);return x.cmp(this.m)>=0&&x.isub(this.m),x._forceRed(this)},l.prototype.iadd=function(h,m){this._verify2(h,m);var x=h.iadd(m);return x.cmp(this.m)>=0&&x.isub(this.m),x},l.prototype.sub=function(h,m){this._verify2(h,m);var x=h.sub(m);return x.cmpn(0)<0&&x.iadd(this.m),x._forceRed(this)},l.prototype.isub=function(h,m){this._verify2(h,m);var x=h.isub(m);return x.cmpn(0)<0&&x.iadd(this.m),x},l.prototype.shl=function(h,m){return this._verify1(h),this.imod(h.ushln(m))},l.prototype.imul=function(h,m){return this._verify2(h,m),this.imod(h.imul(m))},l.prototype.mul=function(h,m){return this._verify2(h,m),this.imod(h.mul(m))},l.prototype.isqr=function(h){return this.imul(h,h.clone())},l.prototype.sqr=function(h){return this.mul(h,h)},l.prototype.sqrt=function(h){if(h.isZero())return h.clone();var m=this.m.andln(3);if(r(m%2===1),m===3){var x=this.m.add(new a(1)).iushrn(2);return this.pow(h,x)}for(var C=this.m.subn(1),b=0;!C.isZero()&&C.andln(1)===0;)b++,C.iushrn(1);r(!C.isZero());var d=new a(1).toRed(this),w=d.redNeg(),k=this.m.subn(1).iushrn(1),S=this.m.bitLength();for(S=new a(2*S*S).toRed(this);this.pow(S,k).cmp(w)!==0;)S.redIAdd(w);for(var M=this.pow(S,C),z=this.pow(h,C.addn(1).iushrn(1)),L=this.pow(h,C),W=b;L.cmp(d)!==0;){for(var a1=L,t1=0;a1.cmp(d)!==0;t1++)a1=a1.redSqr();r(t1=0;b--){for(var M=m.words[b],z=S-1;z>=0;z--){var L=M>>z&1;if(d!==C[0]&&(d=this.sqr(d)),L===0&&w===0){k=0;continue}w<<=1,w|=L,k++,!(k!==x&&(b!==0||z!==0))&&(d=this.mul(d,C[w]),k=0,w=0)}S=26}return d},l.prototype.convertTo=function(h){var m=h.umod(this.m);return m===h?m.clone():m},l.prototype.convertFrom=function(h){var m=h.clone();return m.red=null,m},a.mont=function(h){return new A(h)};function A(g){l.call(this,g),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new a(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(A,l),A.prototype.convertTo=function(h){return this.imod(h.ushln(this.shift))},A.prototype.convertFrom=function(h){var m=this.imod(h.mul(this.rinv));return m.red=null,m},A.prototype.imul=function(h,m){if(h.isZero()||m.isZero())return h.words[0]=0,h.length=1,h;var x=h.imul(m),C=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=x.isub(C).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},A.prototype.mul=function(h,m){if(h.isZero()||m.isZero())return new a(0)._forceRed(this);var x=h.mul(m),C=x.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),b=x.isub(C).iushrn(this.shift),d=b;return b.cmp(this.m)>=0?d=b.isub(this.m):b.cmpn(0)<0&&(d=b.iadd(this.m)),d._forceRed(this)},A.prototype.invm=function(h){var m=this.imod(h._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(typeof Hr1>"u"||Hr1,cF1)});var uF1=_(eU=>{"use strict";Object.defineProperty(eU,"__esModule",{value:!0});eU.version=void 0;eU.version="bytes/5.8.0"});var jr1=_(B3=>{"use strict";Object.defineProperty(B3,"__esModule",{value:!0});B3.joinSignature=B3.splitSignature=B3.hexZeroPad=B3.hexStripZeros=B3.hexValue=B3.hexConcat=B3.hexDataSlice=B3.hexDataLength=B3.hexlify=B3.isHexString=B3.zeroPad=B3.stripZeros=B3.concat=B3.arrayify=B3.isBytes=B3.isBytesLike=void 0;var sZ2=L2(),oZ2=uF1(),yt=new sZ2.Logger(oZ2.version);function lF1(t){return!!t.toHexString}function Cw(t){return t.slice||(t.slice=function(){var e=Array.prototype.slice.call(arguments);return Cw(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function dF1(t){return Mc(t)&&!(t.length%2)||rU(t)}B3.isBytesLike=dF1;function fF1(t){return typeof t=="number"&&t==t&&t%1===0}function rU(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!fF1(t.length)||t.length<0)return!1;for(var e=0;e=256)return!1}return!0}B3.isBytes=rU;function bm(t,e){if(e||(e={}),typeof t=="number"){yt.checkSafeUint53(t,"invalid arrayify value");for(var r=[];t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),Cw(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),lF1(t)&&(t=t.toHexString()),Mc(t)){var n=t.substring(2);n.length%2&&(e.hexPad==="left"?n="0"+n:e.hexPad==="right"?n+="0":yt.throwArgumentError("hex data is odd-length","value",t));for(var r=[],a=0;ae&&yt.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(e);return r.set(t,e-t.length),Cw(r)}B3.zeroPad=pF1;function Mc(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}B3.isHexString=Mc;var Gr1="0123456789abcdef";function j5(t,e){if(e||(e={}),typeof t=="number"){yt.checkSafeUint53(t,"invalid hexlify value");for(var r="";t;)r=Gr1[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),lF1(t))return t.toHexString();if(Mc(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":yt.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(rU(t)){for(var n="0x",a=0;a>4]+Gr1[s&15]}return n}return yt.throwArgumentError("invalid hexlify value","value",t)}B3.hexlify=j5;function uZ2(t){if(typeof t!="string")t=j5(t);else if(!Mc(t)||t.length%2)return null;return(t.length-2)/2}B3.hexDataLength=uZ2;function fZ2(t,e,r){return typeof t!="string"?t=j5(t):(!Mc(t)||t.length%2)&&yt.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}B3.hexDataSlice=fZ2;function lZ2(t){var e="0x";return t.forEach(function(r){e+=j5(r).substring(2)}),e}B3.hexConcat=lZ2;function dZ2(t){var e=AF1(j5(t,{hexPad:"left"}));return e==="0x"?"0x0":e}B3.hexValue=dZ2;function AF1(t){typeof t!="string"&&(t=j5(t)),Mc(t)||yt.throwArgumentError("invalid hex string","value",t),t=t.substring(2);for(var e=0;e2*e+2&&yt.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}B3.hexZeroPad=tU;function gF1(t){var e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(dF1(t)){var r=bm(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=j5(r.slice(0,32)),e.s=j5(r.slice(32,64))):r.length===65?(e.r=j5(r.slice(0,32)),e.s=j5(r.slice(32,64)),e.v=r[64]):yt.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:yt.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=j5(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){var n=pF1(bm(e._vs),32);e._vs=j5(n);var a=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=a:e.recoveryParam!==a&&yt.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),n[0]&=127;var s=j5(n);e.s==null?e.s=s:e.s!==s&&yt.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?yt.throwArgumentError("signature missing v and recoveryParam","signature",t):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{var o=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==o&&yt.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Mc(e.r)?yt.throwArgumentError("signature missing or invalid r","signature",t):e.r=tU(e.r,32),e.s==null||!Mc(e.s)?yt.throwArgumentError("signature missing or invalid s","signature",t):e.s=tU(e.s,32);var c=bm(e.s);c[0]>=128&&yt.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(c[0]|=128);var u=j5(c);e._vs&&(Mc(e._vs)||yt.throwArgumentError("signature invalid _vs","signature",t),e._vs=tU(e._vs,32)),e._vs==null?e._vs=u:e._vs!==u&&yt.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}B3.splitSignature=gF1;function hZ2(t){return t=gF1(t),j5(hF1([t.r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}B3.joinSignature=hZ2});var Jr1=_(nU=>{"use strict";Object.defineProperty(nU,"__esModule",{value:!0});nU.version=void 0;nU.version="bignumber/5.8.0"});var aU=_(Ws=>{"use strict";var pZ2=Ws&&Ws.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ws,"__esModule",{value:!0});Ws._base16To36=Ws._base36To16=Ws.BigNumber=Ws.isBigNumberish=void 0;var AZ2=pZ2(JT()),zT=AZ2.default.BN,Bw=jr1(),Sw=L2(),gZ2=Jr1(),Al=new Sw.Logger(gZ2.version),zr1={},mF1=9007199254740991;function mZ2(t){return t!=null&&(iU.isBigNumber(t)||typeof t=="number"&&t%1===0||typeof t=="string"&&!!t.match(/^-?[0-9]+$/)||(0,Bw.isHexString)(t)||typeof t=="bigint"||(0,Bw.isBytes)(t))}Ws.isBigNumberish=mZ2;var yF1=!1,iU=function(){function t(e,r){e!==zr1&&Al.throwError("cannot call constructor directly; use BigNumber.from",Sw.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return t.prototype.fromTwos=function(e){return Hi(c3(this).fromTwos(e))},t.prototype.toTwos=function(e){return Hi(c3(this).toTwos(e))},t.prototype.abs=function(){return this._hex[0]==="-"?t.from(this._hex.substring(1)):this},t.prototype.add=function(e){return Hi(c3(this).add(c3(e)))},t.prototype.sub=function(e){return Hi(c3(this).sub(c3(e)))},t.prototype.div=function(e){var r=t.from(e);return r.isZero()&&Ys("division-by-zero","div"),Hi(c3(this).div(c3(e)))},t.prototype.mul=function(e){return Hi(c3(this).mul(c3(e)))},t.prototype.mod=function(e){var r=c3(e);return r.isNeg()&&Ys("division-by-zero","mod"),Hi(c3(this).umod(r))},t.prototype.pow=function(e){var r=c3(e);return r.isNeg()&&Ys("negative-power","pow"),Hi(c3(this).pow(r))},t.prototype.and=function(e){var r=c3(e);return(this.isNegative()||r.isNeg())&&Ys("unbound-bitwise-result","and"),Hi(c3(this).and(r))},t.prototype.or=function(e){var r=c3(e);return(this.isNegative()||r.isNeg())&&Ys("unbound-bitwise-result","or"),Hi(c3(this).or(r))},t.prototype.xor=function(e){var r=c3(e);return(this.isNegative()||r.isNeg())&&Ys("unbound-bitwise-result","xor"),Hi(c3(this).xor(r))},t.prototype.mask=function(e){return(this.isNegative()||e<0)&&Ys("negative-width","mask"),Hi(c3(this).maskn(e))},t.prototype.shl=function(e){return(this.isNegative()||e<0)&&Ys("negative-width","shl"),Hi(c3(this).shln(e))},t.prototype.shr=function(e){return(this.isNegative()||e<0)&&Ys("negative-width","shr"),Hi(c3(this).shrn(e))},t.prototype.eq=function(e){return c3(this).eq(c3(e))},t.prototype.lt=function(e){return c3(this).lt(c3(e))},t.prototype.lte=function(e){return c3(this).lte(c3(e))},t.prototype.gt=function(e){return c3(this).gt(c3(e))},t.prototype.gte=function(e){return c3(this).gte(c3(e))},t.prototype.isNegative=function(){return this._hex[0]==="-"},t.prototype.isZero=function(){return c3(this).isZero()},t.prototype.toNumber=function(){try{return c3(this).toNumber()}catch{Ys("overflow","toNumber",this.toString())}return null},t.prototype.toBigInt=function(){try{return BigInt(this.toString())}catch{}return Al.throwError("this platform does not support BigInt",Sw.Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})},t.prototype.toString=function(){return arguments.length>0&&(arguments[0]===10?yF1||(yF1=!0,Al.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?Al.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Sw.Logger.errors.UNEXPECTED_ARGUMENT,{}):Al.throwError("BigNumber.toString does not accept parameters",Sw.Logger.errors.UNEXPECTED_ARGUMENT,{})),c3(this).toString(10)},t.prototype.toHexString=function(){return this._hex},t.prototype.toJSON=function(e){return{type:"BigNumber",hex:this.toHexString()}},t.from=function(e){if(e instanceof t)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new t(zr1,KT(e)):e.match(/^-?[0-9]+$/)?new t(zr1,KT(new zT(e))):Al.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Ys("underflow","BigNumber.from",e),(e>=mF1||e<=-mF1)&&Ys("overflow","BigNumber.from",e),t.from(String(e));var r=e;if(typeof r=="bigint")return t.from(r.toString());if((0,Bw.isBytes)(r))return t.from((0,Bw.hexlify)(r));if(r)if(r.toHexString){var n=r.toHexString();if(typeof n=="string")return t.from(n)}else{var n=r._hex;if(n==null&&r.type==="BigNumber"&&(n=r.hex),typeof n=="string"&&((0,Bw.isHexString)(n)||n[0]==="-"&&(0,Bw.isHexString)(n.substring(1))))return t.from(n)}return Al.throwArgumentError("invalid BigNumber value","value",e)},t.isBigNumber=function(e){return!!(e&&e._isBigNumber)},t}();Ws.BigNumber=iU;function KT(t){if(typeof t!="string")return KT(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&Al.throwArgumentError("invalid hex","value",t),t=KT(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function Hi(t){return iU.from(KT(t))}function c3(t){var e=iU.from(t).toHexString();return e[0]==="-"?new zT("-"+e.substring(3),16):new zT(e.substring(2),16)}function Ys(t,e,r){var n={fault:t,operation:e};return r!=null&&(n.value=r),Al.throwError(t,Sw.Logger.errors.NUMERIC_FAULT,n)}function yZ2(t){return new zT(t,36).toString(16)}Ws._base36To16=yZ2;function bZ2(t){return new zT(t,16).toString(36)}Ws._base16To36=bZ2});var EF1=_(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});Eu.FixedNumber=Eu.FixedFormat=Eu.parseFixed=Eu.formatFixed=void 0;var sU=jr1(),WT=L2(),vZ2=Jr1(),ii=new WT.Logger(vZ2.version),gl=aU(),VT={},vF1=gl.BigNumber.from(0),xF1=gl.BigNumber.from(-1);function wF1(t,e,r,n){var a={fault:e,operation:r};return n!==void 0&&(a.value=n),ii.throwError(t,WT.Logger.errors.NUMERIC_FAULT,a)}var YT="0";for(;YT.length<256;)YT+=YT;function Kr1(t){if(typeof t!="number")try{t=gl.BigNumber.from(t).toNumber()}catch{}return typeof t=="number"&&t>=0&&t<=256&&!(t%1)?"1"+YT.substring(0,t):ii.throwArgumentError("invalid decimal size","decimals",t)}function oU(t,e){e==null&&(e=0);var r=Kr1(e);t=gl.BigNumber.from(t);var n=t.lt(vF1);n&&(t=t.mul(xF1));for(var a=t.mod(r).toString();a.length