@walletconnect/pay 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(ie,en){typeof exports=="object"&&typeof module<"u"?en(exports):typeof define=="function"&&define.amd?define(["exports"],en):(ie=typeof globalThis<"u"?globalThis:ie||self,en(ie["@walletconnect/pay"]={}))})(this,function(ie){"use strict";var en={exports:{}};function Bl(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}var Dl=Al;function Al(e,t,n){var r=n&&n.stringify||Bl,o=1;if(typeof e=="object"&&e!==null){var i=t.length+o;if(i===1)return e;var s=new Array(i);s[0]=r(e);for(var c=1;c<i;c++)s[c]=r(t[c]);return s.join(" ")}if(typeof e!="string")return e;var f=t.length;if(f===0)return e;for(var a="",l=1-o,h=-1,d=e&&e.length||0,u=0;u<d;){if(e.charCodeAt(u)===37&&u+1<d){switch(h=h>-1?h:0,e.charCodeAt(u+1)){case 100:case 102:if(l>=f||t[l]==null)break;h<u&&(a+=e.slice(h,u)),a+=Number(t[l]),h=u+2,u++;break;case 105:if(l>=f||t[l]==null)break;h<u&&(a+=e.slice(h,u)),a+=Math.floor(Number(t[l])),h=u+2,u++;break;case 79:case 111:case 106:if(l>=f||t[l]===void 0)break;h<u&&(a+=e.slice(h,u));var p=typeof t[l];if(p==="string"){a+="'"+t[l]+"'",h=u+2,u++;break}if(p==="function"){a+=t[l].name||"<anonymous>",h=u+2,u++;break}a+=r(t[l]),h=u+2,u++;break;case 115:if(l>=f)break;h<u&&(a+=e.slice(h,u)),a+=String(t[l]),h=u+2,u++;break;case 37:h<u&&(a+=e.slice(h,u)),a+="%",h=u+2,u++,l--;break}++l}++u}return h===-1?e:(h<d&&(a+=e.slice(h)),a)}const Ts=Dl;en.exports=st;const kn=jl().console||{},Ol={mapHttpRequest:Er,mapHttpResponse:Er,wrapRequestSerializer:No,wrapResponseSerializer:No,wrapErrorSerializer:No,req:Er,res:Er,err:Ls,errWithCause:Ls};function St(e,t){return e==="silent"?1/0:t.levels.values[e]}const Oo=Symbol("pino.logFuncs"),So=Symbol("pino.hierarchy"),Sl={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function Ps(e,t){const n={logger:t,parent:e[So]};t[So]=n}function _l(e,t,n){const r={};t.forEach(o=>{r[o]=n[o]?n[o]:kn[o]||kn[Sl[o]||"log"]||pn}),e[Oo]=r}function Il(e,t){return Array.isArray(e)?e.filter(function(n){return n!=="!stdSerializers.err"}):e===!0?Object.keys(t):!1}function st(e){e=e||{},e.browser=e.browser||{};const t=e.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const n=e.browser.write||kn;e.browser.write&&(e.browser.asObject=!0);const r=e.serializers||{},o=Il(e.browser.serialize,r);let i=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(i=!1);const s=Object.keys(e.customLevels||{}),c=["error","fatal","warn","info","debug","trace"].concat(s);typeof n=="function"&&c.forEach(function(m){n[m]=n}),(e.enabled===!1||e.browser.disabled)&&(e.level="silent");const f=e.level||"info",a=Object.create(n);a.log||(a.log=pn),_l(a,c,n),Ps({},a),Object.defineProperty(a,"levelVal",{get:h}),Object.defineProperty(a,"level",{get:d,set:u});const l={transmit:t,serialize:o,asObject:e.browser.asObject,asObjectBindingsOnly:e.browser.asObjectBindingsOnly,formatters:e.browser.formatters,levels:c,timestamp:Pl(e),messageKey:e.messageKey||"msg",onChild:e.onChild||pn};a.levels=Nl(e),a.level=f,a.isLevelEnabled=function(m){return this.levels.values[m]?this.levels.values[m]>=this.levels.values[this.level]:!1},a.setMaxListeners=a.getMaxListeners=a.emit=a.addListener=a.on=a.prependListener=a.once=a.prependOnceListener=a.removeListener=a.removeAllListeners=a.listeners=a.listenerCount=a.eventNames=a.write=a.flush=pn,a.serializers=r,a._serialize=o,a._stdErrSerialize=i,a.child=function(...m){return p.call(this,l,...m)},t&&(a._logEvent=Io());function h(){return St(this.level,this)}function d(){return this._level}function u(m){if(m!=="silent"&&!this.levels.values[m])throw Error("unknown level "+m);this._level=m,tn(this,l,a,"error"),tn(this,l,a,"fatal"),tn(this,l,a,"warn"),tn(this,l,a,"info"),tn(this,l,a,"debug"),tn(this,l,a,"trace"),s.forEach(v=>{tn(this,l,a,v)})}function p(m,v,_){if(!v)throw new Error("missing bindings for child Pino");_=_||{},o&&v.serializers&&(_.serializers=v.serializers);const R=_.serializers;if(o&&R){var D=Object.assign({},r,R),x=e.browser.serialize===!0?Object.keys(D):o;delete v.serializers,_o([v],x,D,this._stdErrSerialize)}function C(q){this._childLevel=(q._childLevel|0)+1,this.bindings=v,D&&(this.serializers=D,this._serialize=x),t&&(this._logEvent=Io([].concat(q._logEvent.bindings,v)))}C.prototype=this;const P=new C(this);return Ps(this,P),P.child=function(...q){return p.call(this,m,...q)},P.level=_.level||this.level,m.onChild(P),P}return a}function Nl(e){const t=e.customLevels||{},n=Object.assign({},st.levels.values,t),r=Object.assign({},st.levels.labels,Fl(t));return{values:n,labels:r}}function Fl(e){const t={};return Object.keys(e).forEach(function(n){t[e[n]]=n}),t}st.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},st.stdSerializers=Ol,st.stdTimeFunctions=Object.assign({},{nullTime:qs,epochTime:js,unixTime:Ll,isoTime:ql});function Cl(e){const t=[];e.bindings&&t.push(e.bindings);let n=e[So];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}function tn(e,t,n,r){if(Object.defineProperty(e,r,{value:St(e.level,n)>St(r,n)?pn:n[Oo][r],writable:!0,enumerable:!0,configurable:!0}),e[r]===pn){if(!t.transmit)return;const i=t.transmit.level||e.level,s=St(i,n);if(St(r,n)<s)return}e[r]=$l(e,t,n,r);const o=Cl(e);o.length!==0&&(e[r]=Ul(o,e[r]))}function Ul(e,t){return function(){return t.apply(this,[...e,...arguments])}}function $l(e,t,n,r){return function(o){return function(){const i=t.timestamp(),s=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===kn?kn:this;for(var f=0;f<s.length;f++)s[f]=arguments[f];var a=!1;if(t.serialize&&(_o(s,this._serialize,this.serializers,this._stdErrSerialize),a=!0),t.asObject||t.formatters?o.call(c,...Rl(this,r,s,i,t)):o.apply(c,s),t.transmit){const l=t.transmit.level||e._level,h=St(l,n),d=St(r,n);if(d<h)return;Tl(this,{ts:i,methodLevel:r,methodValue:d,transmitLevel:l,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:St(e._level,n)},s,a)}}}(e[Oo][r])}function Rl(e,t,n,r,o){const{level:i,log:s=h=>h}=o.formatters||{},c=n.slice();let f=c[0];const a={};let l=(e._childLevel|0)+1;if(l<1&&(l=1),r&&(a.time=r),i){const h=i(t,e.levels.values[t]);Object.assign(a,h)}else a.level=e.levels.values[t];if(o.asObjectBindingsOnly){if(f!==null&&typeof f=="object")for(;l--&&typeof c[0]=="object";)Object.assign(a,c.shift());return[s(a),...c]}else{if(f!==null&&typeof f=="object"){for(;l--&&typeof c[0]=="object";)Object.assign(a,c.shift());f=c.length?Ts(c.shift(),c):void 0}else typeof f=="string"&&(f=Ts(c.shift(),c));return f!==void 0&&(a[o.messageKey]=f),[s(a)]}}function _o(e,t,n,r){for(const o in e)if(r&&e[o]instanceof Error)e[o]=st.stdSerializers.err(e[o]);else if(typeof e[o]=="object"&&!Array.isArray(e[o])&&t)for(const i in e[o])t.indexOf(i)>-1&&i in n&&(e[o][i]=n[i](e[o][i]))}function Tl(e,t,n,r=!1){const o=t.send,i=t.ts,s=t.methodLevel,c=t.methodValue,f=t.val,a=e._logEvent.bindings;r||_o(n,e._serialize||Object.keys(e.serializers),e.serializers,e._stdErrSerialize===void 0?!0:e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter(function(l){return a.indexOf(l)===-1}),e._logEvent.level.label=s,e._logEvent.level.value=c,o(s,e._logEvent,f),e._logEvent=Io(a)}function Io(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function Ls(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)t[n]===void 0&&(t[n]=e[n]);return t}function Pl(e){return typeof e.timestamp=="function"?e.timestamp:e.timestamp===!1?qs:js}function Er(){return{}}function No(e){return e}function pn(){}function qs(){return!1}function js(){return Date.now()}function Ll(){return Math.round(Date.now()/1e3)}function ql(){return new Date(Date.now()).toISOString()}function jl(){function e(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return e(self)||e(window)||e(this)||{}}}en.exports.default=st;var Hs=en.exports.pino=st;const Hl={level:"info"};var Ml=Object.defineProperty,zl=Object.defineProperties,kl=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,Zl=Object.prototype.hasOwnProperty,Vl=Object.prototype.propertyIsEnumerable,zs=(e,t,n)=>t in e?Ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gl=(e,t)=>{for(var n in t||(t={}))Zl.call(t,n)&&zs(e,n,t[n]);if(Ms)for(var n of Ms(t))Vl.call(t,n)&&zs(e,n,t[n]);return e},Kl=(e,t)=>zl(e,kl(t));function ks(e){return Kl(Gl({},e),{level:e?.level||Hl.level})}function Yl(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Wl={};/*! *****************************************************************************
1
+ (function(ie,en){typeof exports=="object"&&typeof module<"u"?en(exports):typeof define=="function"&&define.amd?define(["exports"],en):(ie=typeof globalThis<"u"?globalThis:ie||self,en(ie["@walletconnect/pay"]={}))})(this,function(ie){"use strict";var en={exports:{}};function Bl(e){try{return JSON.stringify(e)}catch{return'"[Circular]"'}}var Dl=Al;function Al(e,t,n){var r=n&&n.stringify||Bl,o=1;if(typeof e=="object"&&e!==null){var i=t.length+o;if(i===1)return e;var s=new Array(i);s[0]=r(e);for(var c=1;c<i;c++)s[c]=r(t[c]);return s.join(" ")}if(typeof e!="string")return e;var f=t.length;if(f===0)return e;for(var a="",l=1-o,h=-1,d=e&&e.length||0,u=0;u<d;){if(e.charCodeAt(u)===37&&u+1<d){switch(h=h>-1?h:0,e.charCodeAt(u+1)){case 100:case 102:if(l>=f||t[l]==null)break;h<u&&(a+=e.slice(h,u)),a+=Number(t[l]),h=u+2,u++;break;case 105:if(l>=f||t[l]==null)break;h<u&&(a+=e.slice(h,u)),a+=Math.floor(Number(t[l])),h=u+2,u++;break;case 79:case 111:case 106:if(l>=f||t[l]===void 0)break;h<u&&(a+=e.slice(h,u));var p=typeof t[l];if(p==="string"){a+="'"+t[l]+"'",h=u+2,u++;break}if(p==="function"){a+=t[l].name||"<anonymous>",h=u+2,u++;break}a+=r(t[l]),h=u+2,u++;break;case 115:if(l>=f)break;h<u&&(a+=e.slice(h,u)),a+=String(t[l]),h=u+2,u++;break;case 37:h<u&&(a+=e.slice(h,u)),a+="%",h=u+2,u++,l--;break}++l}++u}return h===-1?e:(h<d&&(a+=e.slice(h)),a)}const Ts=Dl;en.exports=st;const kn=jl().console||{},Ol={mapHttpRequest:Er,mapHttpResponse:Er,wrapRequestSerializer:No,wrapResponseSerializer:No,wrapErrorSerializer:No,req:Er,res:Er,err:Ls,errWithCause:Ls};function St(e,t){return e==="silent"?1/0:t.levels.values[e]}const Oo=Symbol("pino.logFuncs"),So=Symbol("pino.hierarchy"),Sl={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function Ps(e,t){const n={logger:t,parent:e[So]};t[So]=n}function _l(e,t,n){const r={};t.forEach(o=>{r[o]=n[o]?n[o]:kn[o]||kn[Sl[o]||"log"]||pn}),e[Oo]=r}function Il(e,t){return Array.isArray(e)?e.filter(function(n){return n!=="!stdSerializers.err"}):e===!0?Object.keys(t):!1}function st(e){e=e||{},e.browser=e.browser||{};const t=e.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const n=e.browser.write||kn;e.browser.write&&(e.browser.asObject=!0);const r=e.serializers||{},o=Il(e.browser.serialize,r);let i=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(i=!1);const s=Object.keys(e.customLevels||{}),c=["error","fatal","warn","info","debug","trace"].concat(s);typeof n=="function"&&c.forEach(function(m){n[m]=n}),(e.enabled===!1||e.browser.disabled)&&(e.level="silent");const f=e.level||"info",a=Object.create(n);a.log||(a.log=pn),_l(a,c,n),Ps({},a),Object.defineProperty(a,"levelVal",{get:h}),Object.defineProperty(a,"level",{get:d,set:u});const l={transmit:t,serialize:o,asObject:e.browser.asObject,asObjectBindingsOnly:e.browser.asObjectBindingsOnly,formatters:e.browser.formatters,levels:c,timestamp:Pl(e),messageKey:e.messageKey||"msg",onChild:e.onChild||pn};a.levels=Nl(e),a.level=f,a.isLevelEnabled=function(m){return this.levels.values[m]?this.levels.values[m]>=this.levels.values[this.level]:!1},a.setMaxListeners=a.getMaxListeners=a.emit=a.addListener=a.on=a.prependListener=a.once=a.prependOnceListener=a.removeListener=a.removeAllListeners=a.listeners=a.listenerCount=a.eventNames=a.write=a.flush=pn,a.serializers=r,a._serialize=o,a._stdErrSerialize=i,a.child=function(...m){return p.call(this,l,...m)},t&&(a._logEvent=Io());function h(){return St(this.level,this)}function d(){return this._level}function u(m){if(m!=="silent"&&!this.levels.values[m])throw Error("unknown level "+m);this._level=m,tn(this,l,a,"error"),tn(this,l,a,"fatal"),tn(this,l,a,"warn"),tn(this,l,a,"info"),tn(this,l,a,"debug"),tn(this,l,a,"trace"),s.forEach(v=>{tn(this,l,a,v)})}function p(m,v,_){if(!v)throw new Error("missing bindings for child Pino");_=_||{},o&&v.serializers&&(_.serializers=v.serializers);const $=_.serializers;if(o&&$){var D=Object.assign({},r,$),x=e.browser.serialize===!0?Object.keys(D):o;delete v.serializers,_o([v],x,D,this._stdErrSerialize)}function C(q){this._childLevel=(q._childLevel|0)+1,this.bindings=v,D&&(this.serializers=D,this._serialize=x),t&&(this._logEvent=Io([].concat(q._logEvent.bindings,v)))}C.prototype=this;const P=new C(this);return Ps(this,P),P.child=function(...q){return p.call(this,m,...q)},P.level=_.level||this.level,m.onChild(P),P}return a}function Nl(e){const t=e.customLevels||{},n=Object.assign({},st.levels.values,t),r=Object.assign({},st.levels.labels,Fl(t));return{values:n,labels:r}}function Fl(e){const t={};return Object.keys(e).forEach(function(n){t[e[n]]=n}),t}st.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},st.stdSerializers=Ol,st.stdTimeFunctions=Object.assign({},{nullTime:qs,epochTime:js,unixTime:Ll,isoTime:ql});function Cl(e){const t=[];e.bindings&&t.push(e.bindings);let n=e[So];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}function tn(e,t,n,r){if(Object.defineProperty(e,r,{value:St(e.level,n)>St(r,n)?pn:n[Oo][r],writable:!0,enumerable:!0,configurable:!0}),e[r]===pn){if(!t.transmit)return;const i=t.transmit.level||e.level,s=St(i,n);if(St(r,n)<s)return}e[r]=Rl(e,t,n,r);const o=Cl(e);o.length!==0&&(e[r]=Ul(o,e[r]))}function Ul(e,t){return function(){return t.apply(this,[...e,...arguments])}}function Rl(e,t,n,r){return function(o){return function(){const i=t.timestamp(),s=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===kn?kn:this;for(var f=0;f<s.length;f++)s[f]=arguments[f];var a=!1;if(t.serialize&&(_o(s,this._serialize,this.serializers,this._stdErrSerialize),a=!0),t.asObject||t.formatters?o.call(c,...$l(this,r,s,i,t)):o.apply(c,s),t.transmit){const l=t.transmit.level||e._level,h=St(l,n),d=St(r,n);if(d<h)return;Tl(this,{ts:i,methodLevel:r,methodValue:d,transmitLevel:l,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:St(e._level,n)},s,a)}}}(e[Oo][r])}function $l(e,t,n,r,o){const{level:i,log:s=h=>h}=o.formatters||{},c=n.slice();let f=c[0];const a={};let l=(e._childLevel|0)+1;if(l<1&&(l=1),r&&(a.time=r),i){const h=i(t,e.levels.values[t]);Object.assign(a,h)}else a.level=e.levels.values[t];if(o.asObjectBindingsOnly){if(f!==null&&typeof f=="object")for(;l--&&typeof c[0]=="object";)Object.assign(a,c.shift());return[s(a),...c]}else{if(f!==null&&typeof f=="object"){for(;l--&&typeof c[0]=="object";)Object.assign(a,c.shift());f=c.length?Ts(c.shift(),c):void 0}else typeof f=="string"&&(f=Ts(c.shift(),c));return f!==void 0&&(a[o.messageKey]=f),[s(a)]}}function _o(e,t,n,r){for(const o in e)if(r&&e[o]instanceof Error)e[o]=st.stdSerializers.err(e[o]);else if(typeof e[o]=="object"&&!Array.isArray(e[o])&&t)for(const i in e[o])t.indexOf(i)>-1&&i in n&&(e[o][i]=n[i](e[o][i]))}function Tl(e,t,n,r=!1){const o=t.send,i=t.ts,s=t.methodLevel,c=t.methodValue,f=t.val,a=e._logEvent.bindings;r||_o(n,e._serialize||Object.keys(e.serializers),e.serializers,e._stdErrSerialize===void 0?!0:e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter(function(l){return a.indexOf(l)===-1}),e._logEvent.level.label=s,e._logEvent.level.value=c,o(s,e._logEvent,f),e._logEvent=Io(a)}function Io(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function Ls(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)t[n]===void 0&&(t[n]=e[n]);return t}function Pl(e){return typeof e.timestamp=="function"?e.timestamp:e.timestamp===!1?qs:js}function Er(){return{}}function No(e){return e}function pn(){}function qs(){return!1}function js(){return Date.now()}function Ll(){return Math.round(Date.now()/1e3)}function ql(){return new Date(Date.now()).toISOString()}function jl(){function e(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return e(self)||e(window)||e(this)||{}}}en.exports.default=st;var Hs=en.exports.pino=st;const Hl={level:"info"};var Ml=Object.defineProperty,zl=Object.defineProperties,kl=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,Zl=Object.prototype.hasOwnProperty,Vl=Object.prototype.propertyIsEnumerable,zs=(e,t,n)=>t in e?Ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gl=(e,t)=>{for(var n in t||(t={}))Zl.call(t,n)&&zs(e,n,t[n]);if(Ms)for(var n of Ms(t))Vl.call(t,n)&&zs(e,n,t[n]);return e},Kl=(e,t)=>zl(e,kl(t));function ks(e){return Kl(Gl({},e),{level:e?.level||Hl.level})}function Yl(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}),n}var Wl={};/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -11,7 +11,7 @@
11
11
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
12
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
13
  PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */var Fo=function(e,t){return Fo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Fo(e,t)};function Xl(e,t){Fo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Co=function(){return Co=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Co.apply(this,arguments)};function Jl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ql(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}function ed(e,t){return function(n,r){t(n,r,e)}}function td(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function nd(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function c(l){try{a(r.next(l))}catch(h){s(h)}}function f(l){try{a(r.throw(l))}catch(h){s(h)}}function a(l){l.done?i(l.value):o(l.value).then(c,f)}a((r=r.apply(e,t||[])).next())})}function rd(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(l){return f([a,l])}}function f(a){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function od(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function id(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Uo(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Zs(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function sd(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Zs(arguments[t]));return e}function cd(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var i=arguments[t],s=0,c=i.length;s<c;s++,o++)r[o]=i[s];return r}function Zn(e){return this instanceof Zn?(this.v=e,this):new Zn(e)}function fd(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(d){r[d]&&(o[d]=function(u){return new Promise(function(p,m){i.push([d,u,p,m])>1||c(d,u)})})}function c(d,u){try{f(r[d](u))}catch(p){h(i[0][3],p)}}function f(d){d.value instanceof Zn?Promise.resolve(d.value.v).then(a,l):h(i[0][2],d)}function a(d){c("next",d)}function l(d){c("throw",d)}function h(d,u){d(u),i.shift(),i.length&&c(i[0][0],i[0][1])}}function ad(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,i){t[o]=e[o]?function(s){return(n=!n)?{value:Zn(e[o](s)),done:o==="return"}:i?i(s):s}:i}}function ud(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Uo=="function"?Uo(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(c,f){s=e[i](s),o(c,f,s.done,s.value)})}}function o(i,s,c,f){Promise.resolve(f).then(function(a){i({value:a,done:c})},s)}}function ld(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function dd(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function hd(e){return e&&e.__esModule?e:{default:e}}function bd(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function gd(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var wd=Object.freeze({__proto__:null,__extends:Xl,get __assign(){return Co},__rest:Jl,__decorate:Ql,__param:ed,__metadata:td,__awaiter:nd,__generator:rd,__createBinding:od,__exportStar:id,__values:Uo,__read:Zs,__spread:sd,__spreadArrays:cd,__await:Zn,__asyncGenerator:fd,__asyncDelegator:ad,__asyncValues:ud,__makeTemplateObject:ld,__importStar:dd,__importDefault:hd,__classPrivateFieldGet:bd,__classPrivateFieldSet:gd}),xr=Yl(wd),$o={},Vn={},Vs;function pd(){if(Vs)return Vn;Vs=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return Vn.delay=e,Vn}var nn={},Ro={},rn={},Gs;function yd(){return Gs||(Gs=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.ONE_THOUSAND=rn.ONE_HUNDRED=void 0,rn.ONE_HUNDRED=100,rn.ONE_THOUSAND=1e3),rn}var To={},Ks;function md(){return Ks||(Ks=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=e.ONE_MINUTE*5,e.TEN_MINUTES=e.ONE_MINUTE*10,e.THIRTY_MINUTES=e.ONE_MINUTE*30,e.SIXTY_MINUTES=e.ONE_MINUTE*60,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=e.ONE_HOUR*3,e.SIX_HOURS=e.ONE_HOUR*6,e.TWELVE_HOURS=e.ONE_HOUR*12,e.TWENTY_FOUR_HOURS=e.ONE_HOUR*24,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=e.ONE_DAY*3,e.FIVE_DAYS=e.ONE_DAY*5,e.SEVEN_DAYS=e.ONE_DAY*7,e.THIRTY_DAYS=e.ONE_DAY*30,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=e.ONE_WEEK*2,e.THREE_WEEKS=e.ONE_WEEK*3,e.FOUR_WEEKS=e.ONE_WEEK*4,e.ONE_YEAR=e.ONE_DAY*365}(To)),To}var Ys;function Ws(){return Ys||(Ys=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(yd(),e),t.__exportStar(md(),e)}(Ro)),Ro}var Xs;function Ed(){if(Xs)return nn;Xs=1,Object.defineProperty(nn,"__esModule",{value:!0}),nn.fromMiliseconds=nn.toMiliseconds=void 0;const e=Ws();function t(r){return r*e.ONE_THOUSAND}nn.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return nn.fromMiliseconds=n,nn}var Js;function xd(){return Js||(Js=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(pd(),e),t.__exportStar(Ed(),e)}($o)),$o}var yn={},Qs;function vd(){if(Qs)return yn;Qs=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(n){if(this.timestamps.has(n))throw new Error(`Watch already started for label: ${n}`);this.timestamps.set(n,{started:Date.now()})}stop(n){const r=this.get(n);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${n}`);const o=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:o})}get(n){const r=this.timestamps.get(n);if(typeof r>"u")throw new Error(`No timestamp found for label: ${n}`);return r}elapsed(n){const r=this.get(n);return r.elapsed||Date.now()-r.started}}return yn.Watch=e,yn.default=e,yn}var Po={},Gn={},ec;function Bd(){if(ec)return Gn;ec=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.IWatch=void 0;class e{}return Gn.IWatch=e,Gn}var tc;function Dd(){return tc||(tc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),xr.__exportStar(Bd(),e)}(Po)),Po}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(xd(),e),t.__exportStar(vd(),e),t.__exportStar(Dd(),e),t.__exportStar(Ws(),e)})(Wl);var re={};Object.defineProperty(re,"__esModule",{value:!0}),re.getLocalStorage=re.getLocalStorageOrThrow=re.getCrypto=re.getCryptoOrThrow=re.getLocation=re.getLocationOrThrow=qo=re.getNavigator=re.getNavigatorOrThrow=Lo=re.getDocument=re.getDocumentOrThrow=re.getFromWindowOrThrow=re.getFromWindow=void 0;function on(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}re.getFromWindow=on;function mn(e){const t=on(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}re.getFromWindowOrThrow=mn;function Ad(){return mn("document")}re.getDocumentOrThrow=Ad;function Od(){return on("document")}var Lo=re.getDocument=Od;function Sd(){return mn("navigator")}re.getNavigatorOrThrow=Sd;function _d(){return on("navigator")}var qo=re.getNavigator=_d;function Id(){return mn("location")}re.getLocationOrThrow=Id;function Nd(){return on("location")}re.getLocation=Nd;function Fd(){return mn("crypto")}re.getCryptoOrThrow=Fd;function Cd(){return on("crypto")}re.getCrypto=Cd;function Ud(){return mn("localStorage")}re.getLocalStorageOrThrow=Ud;function $d(){return on("localStorage")}re.getLocalStorage=$d;var jo={};Object.defineProperty(jo,"__esModule",{value:!0}),jo.getWindowMetadata=void 0;const nc=re;function Rd(){let e,t;try{e=nc.getDocumentOrThrow(),t=nc.getLocationOrThrow()}catch{return null}function n(){const h=e.getElementsByTagName("link"),d=[];for(let u=0;u<h.length;u++){const p=h[u],m=p.getAttribute("rel");if(m&&m.toLowerCase().indexOf("icon")>-1){const v=p.getAttribute("href");if(v)if(v.toLowerCase().indexOf("https:")===-1&&v.toLowerCase().indexOf("http:")===-1&&v.indexOf("//")!==0){let _=t.protocol+"//"+t.host;if(v.indexOf("/")===0)_+=v;else{const R=t.pathname.split("/");R.pop();const D=R.join("/");_+=D+"/"+v}d.push(_)}else if(v.indexOf("//")===0){const _=t.protocol+v;d.push(_)}else d.push(v)}}return d}function r(...h){const d=e.getElementsByTagName("meta");for(let u=0;u<d.length;u++){const p=d[u],m=["itemprop","property","name"].map(v=>p.getAttribute(v)).filter(v=>v?h.includes(v):!1);if(m.length&&m){const v=p.getAttribute("content");if(v)return v}}return""}function o(){let h=r("name","og:site_name","og:title","twitter:title");return h||(h=e.title),h}function i(){return r("description","og:description","twitter:description","keywords")}const s=o(),c=i(),f=t.origin,a=n();return{description:c,url:f,icons:a,name:s}}jo.getWindowMetadata=Rd;const Td="0.1.1";function Pd(){return Td}class Ae extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof Ae){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),o=n.cause instanceof Ae&&n.cause.docsPath||n.docsPath,s=`https://oxlib.sh${o??""}`,c=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||o?["",r?`Details: ${r}`:void 0,o?`See: ${s}`:void 0]:[]].filter(f=>typeof f=="string").join(`
15
- `);super(c,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Pd()}`}),this.cause=n.cause,this.details=r,this.docs=s,this.docsPath=o,this.shortMessage=t}walk(t){return rc(this,t)}}function rc(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?rc(e.cause,t):t?null:e}const En=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function vr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function xn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!vr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function oc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");xn(e.outputLen),xn(e.blockLen)}function vn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ic(e,t){ct(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ld(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function _t(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ho(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tt(e,t){return e<<32-t|e>>>t}const qd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function jd(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Hd(e){for(let t=0;t<e.length;t++)e[t]=jd(e[t]);return e}const sc=qd?e=>e:Hd,cc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Md=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bn(e){if(ct(e),cc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Md[e[n]];return t}const ft={_0:48,_9:57,A:65,F:70,a:97,f:102};function fc(e){if(e>=ft._0&&e<=ft._9)return e-ft._0;if(e>=ft.A&&e<=ft.F)return e-(ft.A-10);if(e>=ft.a&&e<=ft.f)return e-(ft.a-10)}function Br(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(cc)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=fc(e.charCodeAt(i)),c=fc(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function Mo(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Dr(e){return typeof e=="string"&&(e=Mo(e)),ct(e),e}function at(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];ct(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}class zo{}function Ar(e){const t=r=>e().update(Dr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Or(e=32){if(En&&typeof En.getRandomValues=="function")return En.getRandomValues(new Uint8Array(e));if(En&&typeof En.randomBytes=="function")return Uint8Array.from(En.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function zd(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function kd(e,t,n){return e&t^~e&n}function Zd(e,t,n){return e&t^e&n^t&n}class ac extends zo{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Ho(this.buffer)}update(t){vn(this),t=Dr(t),ct(t);const{view:n,buffer:r,blockLen:o}=this,i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=Ho(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vn(this),ic(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,_t(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;zd(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Ho(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const ut=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ye=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),me=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Sr=BigInt(2**32-1),uc=BigInt(32);function Vd(e,t=!1){return t?{h:Number(e&Sr),l:Number(e>>uc&Sr)}:{h:Number(e>>uc&Sr)|0,l:Number(e&Sr)|0}}function lc(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:s,l:c}=Vd(e[i],t);[r[i],o[i]]=[s,c]}return[r,o]}const dc=(e,t,n)=>e>>>n,hc=(e,t,n)=>e<<32-n|t>>>n,Dn=(e,t,n)=>e>>>n|t<<32-n,An=(e,t,n)=>e<<32-n|t>>>n,_r=(e,t,n)=>e<<64-n|t>>>n-32,Ir=(e,t,n)=>e>>>n-32|t<<64-n,Gd=(e,t,n)=>e<<n|t>>>32-n,Kd=(e,t,n)=>t<<n|e>>>32-n,Yd=(e,t,n)=>t<<n-32|e>>>64-n,Wd=(e,t,n)=>e<<n-32|t>>>64-n;function lt(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const Xd=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Jd=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Qd=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),e0=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,t0=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),n0=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,r0=BigInt(0),Kn=BigInt(1),o0=BigInt(2),i0=BigInt(7),s0=BigInt(256),c0=BigInt(113),bc=[],gc=[],wc=[];for(let e=0,t=Kn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],bc.push(2*(5*r+n)),gc.push((e+1)*(e+2)/2%64);let o=r0;for(let i=0;i<7;i++)t=(t<<Kn^(t>>i0)*c0)%s0,t&o0&&(o^=Kn<<(Kn<<BigInt(i))-Kn);wc.push(o)}const pc=lc(wc,!0),f0=pc[0],a0=pc[1],yc=(e,t,n)=>n>32?Yd(e,t,n):Gd(e,t,n),mc=(e,t,n)=>n>32?Wd(e,t,n):Kd(e,t,n);function u0(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,f=(s+2)%10,a=n[f],l=n[f+1],h=yc(a,l,1)^n[c],d=mc(a,l,1)^n[c+1];for(let u=0;u<50;u+=10)e[s+u]^=h,e[s+u+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=gc[s],f=yc(o,i,c),a=mc(o,i,c),l=bc[s];o=e[l],i=e[l+1],e[l]=f,e[l+1]=a}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=f0[r],e[1]^=a0[r]}_t(n)}class ko extends zo{constructor(t,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,xn(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ld(this.state)}clone(){return this._cloneInto()}keccak(){sc(this.state32),u0(this.state32,this.rounds),sc(this.state32),this.posOut=0,this.pos=0}update(t){vn(this),t=Dr(t),ct(t);const{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let c=0;c<s;c++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){vn(this,!1),ct(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return xn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ic(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,_t(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new ko(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const l0=(e,t,n)=>Ar(()=>new ko(t,e,n)),d0=l0(1,136,256/8),h0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),It=new Uint32Array(64);class b0 extends ac{constructor(t=32){super(64,t,8,!1),this.A=ut[0]|0,this.B=ut[1]|0,this.C=ut[2]|0,this.D=ut[3]|0,this.E=ut[4]|0,this.F=ut[5]|0,this.G=ut[6]|0,this.H=ut[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:f}=this;return[t,n,r,o,i,s,c,f]}set(t,n,r,o,i,s,c,f){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,n){for(let h=0;h<16;h++,n+=4)It[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const d=It[h-15],u=It[h-2],p=tt(d,7)^tt(d,18)^d>>>3,m=tt(u,17)^tt(u,19)^u>>>10;It[h]=m+It[h-7]+p+It[h-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:f,G:a,H:l}=this;for(let h=0;h<64;h++){const d=tt(c,6)^tt(c,11)^tt(c,25),u=l+d+kd(c,f,a)+h0[h]+It[h]|0,m=(tt(r,2)^tt(r,13)^tt(r,22))+Zd(r,o,i)|0;l=a,a=f,f=c,c=s+u|0,s=i,i=o,o=r,r=u+m|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,l=l+this.H|0,this.set(r,o,i,s,c,f,a,l)}roundClean(){_t(It)}destroy(){this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}}const Ec=lc(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),g0=Ec[0],w0=Ec[1],Nt=new Uint32Array(80),Ft=new Uint32Array(80);class xc extends ac{constructor(t=64){super(128,t,16,!1),this.Ah=me[0]|0,this.Al=me[1]|0,this.Bh=me[2]|0,this.Bl=me[3]|0,this.Ch=me[4]|0,this.Cl=me[5]|0,this.Dh=me[6]|0,this.Dl=me[7]|0,this.Eh=me[8]|0,this.El=me[9]|0,this.Fh=me[10]|0,this.Fl=me[11]|0,this.Gh=me[12]|0,this.Gl=me[13]|0,this.Hh=me[14]|0,this.Hl=me[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Nt[D]=t.getUint32(n),Ft[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Nt[D-15]|0,C=Ft[D-15]|0,P=Dn(x,C,1)^Dn(x,C,8)^dc(x,C,7),q=An(x,C,1)^An(x,C,8)^hc(x,C,7),L=Nt[D-2]|0,I=Ft[D-2]|0,k=Dn(L,I,19)^_r(L,I,61)^dc(L,I,6),H=An(L,I,19)^Ir(L,I,61)^hc(L,I,6),E=Qd(q,H,Ft[D-7],Ft[D-16]),g=e0(E,P,k,Nt[D-7],Nt[D-16]);Nt[D]=g|0,Ft[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:R}=this;for(let D=0;D<80;D++){const x=Dn(h,d,14)^Dn(h,d,18)^_r(h,d,41),C=An(h,d,14)^An(h,d,18)^Ir(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=t0(R,C,q,w0[D],Ft[D]),I=n0(L,_,x,P,g0[D],Nt[D]),k=L|0,H=Dn(r,o,28)^_r(r,o,34)^_r(r,o,39),E=An(r,o,28)^Ir(r,o,34)^Ir(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,R=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=lt(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=Xd(k,E,y);r=Jd(b,I,H,g),o=b|0}({h:r,l:o}=lt(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=lt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=lt(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=lt(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=lt(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=lt(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=lt(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:R}=lt(this.Hh|0,this.Hl|0,_|0,R|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,R)}roundClean(){_t(Nt,Ft)}destroy(){_t(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class p0 extends xc{constructor(){super(48),this.Ah=ye[0]|0,this.Al=ye[1]|0,this.Bh=ye[2]|0,this.Bl=ye[3]|0,this.Ch=ye[4]|0,this.Cl=ye[5]|0,this.Dh=ye[6]|0,this.Dl=ye[7]|0,this.Eh=ye[8]|0,this.El=ye[9]|0,this.Fh=ye[10]|0,this.Fl=ye[11]|0,this.Gh=ye[12]|0,this.Gl=ye[13]|0,this.Hh=ye[14]|0,this.Hl=ye[15]|0}}const On=Ar(()=>new b0),y0=Ar(()=>new xc),m0=Ar(()=>new p0);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Zo=BigInt(0),Nr=BigInt(1);function Yn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ct(e){if(!Yn(e))throw new Error("Uint8Array expected")}function Wn(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Fr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function vc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Zo:BigInt("0x"+e)}const Bc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",E0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function sn(e){if(Ct(e),Bc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=E0[e[n]];return t}const dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Dc(e){if(e>=dt._0&&e<=dt._9)return e-dt._0;if(e>=dt.A&&e<=dt.F)return e-(dt.A-10);if(e>=dt.a&&e<=dt.f)return e-(dt.a-10)}function Cr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Bc)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=Dc(e.charCodeAt(i)),c=Dc(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function Oe(e){return vc(sn(e))}function Ac(e){return Ct(e),vc(sn(Uint8Array.from(e).reverse()))}function ue(e,t){return Cr(e.toString(16).padStart(t*2,"0"))}function Oc(e,t){return ue(e,t).reverse()}function Ee(e,t,n){let r;if(typeof t=="string")try{r=Cr(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Yn(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function ce(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Ct(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}function Vo(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}const Go=e=>typeof e=="bigint"&&Zo<=e;function Ko(e,t,n){return Go(e)&&Go(t)&&Go(n)&&t<=e&&e<n}function Sn(e,t,n,r){if(!Ko(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Xn(e){let t;for(t=0;e>Zo;e>>=Nr,t+=1);return t}function x0(e,t){return e>>BigInt(t)&Nr}const cn=e=>(Nr<<BigInt(e))-Nr,Yo=e=>new Uint8Array(e),Sc=e=>Uint8Array.from(e);function v0(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Yo(e),o=Yo(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...h)=>n(o,r,...h),f=(h=Yo(0))=>{o=c(Sc([0]),h),r=c(),h.length!==0&&(o=c(Sc([1]),h),r=c())},a=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const d=[];for(;h<t;){r=c();const u=r.slice();d.push(u),h+=r.length}return ce(...d)};return(h,d)=>{s(),f(h);let u;for(;!(u=d(a()));)f();return s(),u}}const B0={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Yn(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Jn(e,t,n={}){const r=(o,i,s)=>{const c=B0[i];if(typeof c!="function")throw new Error("invalid validator function");const f=e[o];if(!(s&&f===void 0)&&!c(f,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+f)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const _c=()=>{throw new Error("not implemented")};function Wo(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}function D0(e,t){if(Uc(e)>t)throw new j0({givenSize:Uc(e),maxSize:t})}const ht={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ic(e){if(e>=ht.zero&&e<=ht.nine)return e-ht.zero;if(e>=ht.A&&e<=ht.F)return e-(ht.A-10);if(e>=ht.a&&e<=ht.f)return e-(ht.a-10)}function A0(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new H0({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let i=0;i<r;i++){const s=n==="right";o[s?i:r-i-1]=e[s?i:e.length-i-1]}return o}function Xo(e,t){if(Qo(e)>t)throw new C0({givenSize:Qo(e),maxSize:t})}function Nc(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const o=e.replace("0x","");if(o.length>r*2)throw new U0({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const O0=new TextEncoder,S0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fc(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function _0(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(Xo(n,t.size),Ur(n,t.size)):n}function Cc(e,t={}){let n="";for(let o=0;o<e.length;o++)n+=S0[e[o]];const r=`0x${n}`;return typeof t.size=="number"?(Xo(r,t.size),Jo(r,t.size)):r}function I0(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof i=="bigint"&&n?-i-1n:0;if(i&&o>i||o<s){const a=typeof e=="bigint"?"n":"";throw new F0({max:i?`${i}${a}`:void 0,min:`${s}${a}`,signed:n,size:r,value:`${e}${a}`})}const f=`0x${(n&&o<0?(1n<<BigInt(r*8))+BigInt(o):o).toString(16)}`;return r?Ur(f,r):f}function N0(e,t={}){return Cc(O0.encode(e),t)}function Ur(e,t){return Nc(e,{dir:"left",size:t})}function Jo(e,t){return Nc(e,{dir:"right",size:t})}function Qo(e){return Math.ceil((e.length-2)/2)}class F0 extends Ae{constructor({max:t,min:n,signed:r,size:o,value:i}){super(`Number \`${i}\` is not in safe${o?` ${o*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class C0 extends Ae{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class U0 extends Ae{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const $0=new TextEncoder;function R0(e){return e instanceof Uint8Array?e:typeof e=="string"?P0(e):T0(e)}function T0(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function P0(e,t={}){const{size:n}=t;let r=e;n&&(Xo(e,n),r=Jo(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const i=o.length/2,s=new Uint8Array(i);for(let c=0,f=0;c<i;c++){const a=Ic(o.charCodeAt(f++)),l=Ic(o.charCodeAt(f++));if(a===void 0||l===void 0)throw new Ae(`Invalid byte sequence ("${o[f-2]}${o[f-1]}" in "${o}").`);s[c]=a*16+l}return s}function L0(e,t={}){const{size:n}=t,r=$0.encode(e);return typeof n=="number"?(D0(r,n),q0(r,n)):r}function q0(e,t){return A0(e,{dir:"right",size:t})}function Uc(e){return e.length}class j0 extends Ae{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class H0 extends Ae{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function M0(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=d0(R0(e));return n==="Bytes"?r:Cc(r)}class z0 extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ei={checksum:new z0(8192)}.checksum,k0=/^0x[a-fA-F0-9]{40}$/;function $c(e,t={}){const{strict:n=!0}=t;if(!k0.test(e))throw new Rc({address:e,cause:new V0});if(n){if(e.toLowerCase()===e)return;if(Z0(e)!==e)throw new Rc({address:e,cause:new G0})}}function Z0(e){if(ei.has(e))return ei.get(e);$c(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=M0(L0(t),{as:"Bytes"}),r=t.split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&r[i]&&(r[i]=r[i].toUpperCase()),(n[i>>1]&15)>=8&&r[i+1]&&(r[i+1]=r[i+1].toUpperCase());const o=`0x${r.join("")}`;return ei.set(e,o),o}class Rc extends Ae{constructor({address:t,cause:n}){super(`Address "${t}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class V0 extends Ae{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class G0 extends Ae{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const K0=/^(.*)\[([0-9]*)\]$/,Y0=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,W0=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function ti(e,t){if(e.length!==t.length)throw new J0({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r];n.push(ti.encode(o,i))}return Fc(...n)}(function(e){function t(n,r,o=!1){if(n==="address"){const f=r;return $c(f),Ur(f.toLowerCase(),o?32:0)}if(n==="string")return N0(r);if(n==="bytes")return r;if(n==="bool")return Ur(_0(r),o?32:1);const i=n.match(W0);if(i){const[f,a,l="256"]=i,h=Number.parseInt(l,10)/8;return I0(r,{size:o?32:h,signed:a==="int"})}const s=n.match(Y0);if(s){const[f,a]=s;if(Number.parseInt(a,10)!==(r.length-2)/2)throw new X0({expectedSize:Number.parseInt(a,10),value:r});return Jo(r,o?32:0)}const c=n.match(K0);if(c&&Array.isArray(r)){const[f,a]=c,l=[];for(let h=0;h<r.length;h++)l.push(t(a,r[h],!0));return l.length===0?"0x":Fc(...l)}throw new Q0(n)}e.encode=t})(ti||(ti={}));class X0 extends Ae{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${Qo(n)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class J0 extends Ae{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${n}`].join(`
16
- `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Q0 extends Ae{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class Tc extends zo{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,oc(t);const r=Dr(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),_t(i)}update(t){return vn(this),this.iHash.update(t),this}digestInto(t){vn(this),ct(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ni=(e,t,n)=>new Tc(e,t).update(n).digest();ni.create=(e,t)=>new Tc(e,t);const Ce=BigInt(0),Se=BigInt(1),fn=BigInt(2),eh=BigInt(3),Pc=BigInt(4),Lc=BigInt(5),qc=BigInt(8);function _e(e,t){const n=e%t;return n>=Ce?n:t+n}function Me(e,t,n){let r=e;for(;t-- >Ce;)r*=r,r%=n;return r}function ri(e,t){if(e===Ce)throw new Error("invert: expected non-zero number");if(t<=Ce)throw new Error("invert: expected positive modulus, got "+t);let n=_e(e,t),r=t,o=Ce,i=Se;for(;n!==Ce;){const c=r/n,f=r%n,a=o-i*c;r=n,n=f,o=i,i=a}if(r!==Se)throw new Error("invert: does not exist");return _e(o,t)}function jc(e,t){const n=(e.ORDER+Se)/Pc,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function th(e,t){const n=(e.ORDER-Lc)/qc,r=e.mul(t,fn),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,fn),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function nh(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-Se,n=0;for(;t%fn===Ce;)t/=fn,n++;let r=fn;const o=Ut(e);for(;Rr(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return jc;let i=o.pow(r,t);const s=(t+Se)/fn;return function(f,a){if(f.is0(a))return a;if(Rr(f,a)!==1)throw new Error("Cannot find square root");let l=n,h=f.mul(f.ONE,i),d=f.pow(a,t),u=f.pow(a,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let p=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(p++,m=f.sqr(m),p===l)throw new Error("Cannot find square root");const v=Se<<BigInt(l-p-1),_=f.pow(h,v);l=p,h=f.sqr(_),d=f.mul(d,h),u=f.mul(u,_)}return u}}function rh(e){return e%Pc===eh?jc:e%qc===Lc?th:nh(e)}const oh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hc(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=oh.reduce((r,o)=>(r[o]="function",r),t);return Jn(e,n)}function $r(e,t,n){if(n<Ce)throw new Error("invalid exponent, negatives unsupported");if(n===Ce)return e.ONE;if(n===Se)return t;let r=e.ONE,o=t;for(;n>Ce;)n&Se&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Se;return r}function an(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function Rr(e,t){const n=(e.ORDER-Se)/fn,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mc(e,t){t!==void 0&&xn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ut(e,t,n=!1,r={}){if(e<=Ce)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:i}=Mc(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const c=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:i,MASK:cn(o),ZERO:Ce,ONE:Se,create:f=>_e(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Ce<=f&&f<e},is0:f=>f===Ce,isOdd:f=>(f&Se)===Se,neg:f=>_e(-f,e),eql:(f,a)=>f===a,sqr:f=>_e(f*f,e),add:(f,a)=>_e(f+a,e),sub:(f,a)=>_e(f-a,e),mul:(f,a)=>_e(f*a,e),pow:(f,a)=>$r(c,f,a),div:(f,a)=>_e(f*ri(a,e),e),sqrN:f=>f*f,addN:(f,a)=>f+a,subN:(f,a)=>f-a,mulN:(f,a)=>f*a,inv:f=>ri(f,e),sqrt:r.sqrt||(f=>(s||(s=rh(e)),s(c,f))),toBytes:f=>n?Oc(f,i):ue(f,i),fromBytes:f=>{if(f.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+f.length);return n?Ac(f):Oe(f)},invertBatch:f=>an(c,f),cmov:(f,a,l)=>l?a:f});return Object.freeze(c)}function zc(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function oi(e){const t=zc(e);return t+Math.ceil(t/2)}function kc(e,t,n=!1){const r=e.length,o=zc(t),i=oi(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?Ac(e):Oe(e),c=_e(s,t-Se)+Se;return n?Oc(c,o):ue(c,o)}const Zc=BigInt(0),ii=BigInt(1);function si(e,t){const n=t.negate();return e?n:t}function Vc(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ci(e,t){Vc(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=cn(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Gc(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=ii);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function ih(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function sh(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const fi=new WeakMap,Kc=new WeakMap;function ai(e){return Kc.get(e)||1}function ch(e,t){return{constTimeNegate:si,hasPrecomputes(n){return ai(n)!==1},unsafeLadder(n,r,o=e.ZERO){let i=n;for(;r>Zc;)r&ii&&(o=o.add(i)),i=i.double(),r>>=ii;return o},precomputeWindow(n,r){const{windows:o,windowSize:i}=ci(r,t),s=[];let c=n,f=c;for(let a=0;a<o;a++){f=c,s.push(f);for(let l=1;l<i;l++)f=f.add(c),s.push(f);c=f.double()}return s},wNAF(n,r,o){let i=e.ZERO,s=e.BASE;const c=ci(n,t);for(let f=0;f<c.windows;f++){const{nextN:a,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:p}=Gc(o,f,c);o=a,h?s=s.add(si(u,r[p])):i=i.add(si(d,r[l]))}return{p:i,f:s}},wNAFUnsafe(n,r,o,i=e.ZERO){const s=ci(n,t);for(let c=0;c<s.windows&&o!==Zc;c++){const{nextN:f,offset:a,isZero:l,isNeg:h}=Gc(o,c,s);if(o=f,!l){const d=r[a];i=i.add(h?d.negate():d)}}return i},getPrecomputes(n,r,o){let i=fi.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&fi.set(r,o(i))),i},wNAFCached(n,r,o){const i=ai(n);return this.wNAF(i,this.getPrecomputes(i,n,o),r)},wNAFCachedUnsafe(n,r,o,i){const s=ai(n);return s===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,n,o),r,i)},setWindowSize(n,r){Vc(r,t),Kc.set(n,r),fi.delete(n)}}}function fh(e,t,n,r){ih(n,e),sh(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=Xn(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=cn(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Yc(e){return Hc(e.Fp),Jn(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Mc(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Wc(e){e.lowS!==void 0&&Wn("lowS",e.lowS),e.prehash!==void 0&&Wn("prehash",e.prehash)}function ah(e){const t=Yc(e);Jn(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}class uh extends Error{constructor(t=""){super(t)}}const bt={Err:uh,_tlv:{encode:(e,t)=>{const{Err:n}=bt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=Fr(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Fr(o.length/2|128):"";return Fr(e)+i+o+t},decode(e,t){const{Err:n}=bt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=bt;if(e<Ge)throw new t("integer: negative integers are not allowed");let n=Fr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=bt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Oe(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=bt,o=Ee("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=bt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}};function ui(e,t){return sn(ue(e,t))}const Ge=BigInt(0),ne=BigInt(1),$t=BigInt(2),Qn=BigInt(3),li=BigInt(4);function di(e){const t=ah(e),{Fp:n}=t,r=Ut(t.n,t.nBitLength),o=t.toBytes||((D,x,C)=>{const P=x.toAffine();return ce(Uint8Array.from([4]),n.toBytes(P.x),n.toBytes(P.y))}),i=t.fromBytes||(D=>{const x=D.subarray(1),C=n.fromBytes(x.subarray(0,n.BYTES)),P=n.fromBytes(x.subarray(n.BYTES,2*n.BYTES));return{x:C,y:P}});function s(D){const{a:x,b:C}=t,P=n.sqr(D),q=n.mul(P,D);return n.add(n.add(q,n.mul(D,x)),C)}function c(D,x){const C=n.sqr(x),P=s(D);return n.eql(C,P)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const f=n.mul(n.pow(t.a,Qn),li),a=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(f,a)))throw new Error("bad curve params: a or b");function l(D){return Ko(D,ne,t.n)}function h(D){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:P,n:q}=t;if(x&&typeof D!="bigint"){if(Yn(D)&&(D=sn(D)),typeof D!="string"||!x.includes(D.length))throw new Error("invalid private key");D=D.padStart(C*2,"0")}let L;try{L=typeof D=="bigint"?D:Oe(Ee("private key",D,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof D)}return P&&(L=_e(L,q)),Sn("private key",L,ne,q),L}function d(D){if(!(D instanceof m))throw new Error("ProjectivePoint expected")}const u=Wo((D,x)=>{const{px:C,py:P,pz:q}=D;if(n.eql(q,n.ONE))return{x:C,y:P};const L=D.is0();x==null&&(x=L?n.ONE:n.inv(q));const I=n.mul(C,x),k=n.mul(P,x),H=n.mul(q,x);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(H,n.ONE))throw new Error("invZ was invalid");return{x:I,y:k}}),p=Wo(D=>{if(D.is0()){if(t.allowInfinityPoint&&!n.is0(D.py))return;throw new Error("bad point: ZERO")}const{x,y:C}=D.toAffine();if(!n.isValid(x)||!n.isValid(C))throw new Error("bad point: x or y not FE");if(!c(x,C))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(x,C,P){if(x==null||!n.isValid(x))throw new Error("x required");if(C==null||!n.isValid(C)||n.is0(C))throw new Error("y required");if(P==null||!n.isValid(P))throw new Error("z required");this.px=x,this.py=C,this.pz=P,Object.freeze(this)}static fromAffine(x){const{x:C,y:P}=x||{};if(!x||!n.isValid(C)||!n.isValid(P))throw new Error("invalid affine point");if(x instanceof m)throw new Error("projective point not allowed");const q=L=>n.eql(L,n.ZERO);return q(C)&&q(P)?m.ZERO:new m(C,P,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){const C=an(n,x.map(P=>P.pz));return x.map((P,q)=>P.toAffine(C[q])).map(m.fromAffine)}static fromHex(x){const C=m.fromAffine(i(Ee("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return m.BASE.multiply(h(x))}static msm(x,C){return fh(m,r,x,C)}_setWindowSize(x){R.setWindowSize(this,x)}assertValidity(){p(this)}hasEvenY(){const{y:x}=this.toAffine();if(n.isOdd)return!n.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){d(x);const{px:C,py:P,pz:q}=this,{px:L,py:I,pz:k}=x,H=n.eql(n.mul(C,k),n.mul(L,q)),E=n.eql(n.mul(P,k),n.mul(I,q));return H&&E}negate(){return new m(this.px,n.neg(this.py),this.pz)}double(){const{a:x,b:C}=t,P=n.mul(C,Qn),{px:q,py:L,pz:I}=this;let k=n.ZERO,H=n.ZERO,E=n.ZERO,g=n.mul(q,q),y=n.mul(L,L),b=n.mul(I,I),w=n.mul(q,L);return w=n.add(w,w),E=n.mul(q,I),E=n.add(E,E),k=n.mul(x,E),H=n.mul(P,b),H=n.add(k,H),k=n.sub(y,H),H=n.add(y,H),H=n.mul(k,H),k=n.mul(w,k),E=n.mul(P,E),b=n.mul(x,b),w=n.sub(g,b),w=n.mul(x,w),w=n.add(w,E),E=n.add(g,g),g=n.add(E,g),g=n.add(g,b),g=n.mul(g,w),H=n.add(H,g),b=n.mul(L,I),b=n.add(b,b),g=n.mul(b,w),k=n.sub(k,g),E=n.mul(b,y),E=n.add(E,E),E=n.add(E,E),new m(k,H,E)}add(x){d(x);const{px:C,py:P,pz:q}=this,{px:L,py:I,pz:k}=x;let H=n.ZERO,E=n.ZERO,g=n.ZERO;const y=t.a,b=n.mul(t.b,Qn);let w=n.mul(C,L),B=n.mul(P,I),A=n.mul(q,k),O=n.add(C,P),S=n.add(L,I);O=n.mul(O,S),S=n.add(w,B),O=n.sub(O,S),S=n.add(C,q);let N=n.add(L,k);return S=n.mul(S,N),N=n.add(w,A),S=n.sub(S,N),N=n.add(P,q),H=n.add(I,k),N=n.mul(N,H),H=n.add(B,A),N=n.sub(N,H),g=n.mul(y,S),H=n.mul(b,A),g=n.add(H,g),H=n.sub(B,g),g=n.add(B,g),E=n.mul(H,g),B=n.add(w,w),B=n.add(B,w),A=n.mul(y,A),S=n.mul(b,S),B=n.add(B,A),A=n.sub(w,A),A=n.mul(y,A),S=n.add(S,A),w=n.mul(B,S),E=n.add(E,w),w=n.mul(N,S),H=n.mul(O,H),H=n.sub(H,w),w=n.mul(O,B),g=n.mul(N,g),g=n.add(g,w),new m(H,E,g)}subtract(x){return this.add(x.negate())}is0(){return this.equals(m.ZERO)}wNAF(x){return R.wNAFCached(this,x,m.normalizeZ)}multiplyUnsafe(x){const{endo:C,n:P}=t;Sn("scalar",x,Ge,P);const q=m.ZERO;if(x===Ge)return q;if(this.is0()||x===ne)return this;if(!C||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,x,m.normalizeZ);let{k1neg:L,k1:I,k2neg:k,k2:H}=C.splitScalar(x),E=q,g=q,y=this;for(;I>Ge||H>Ge;)I&ne&&(E=E.add(y)),H&ne&&(g=g.add(y)),y=y.double(),I>>=ne,H>>=ne;return L&&(E=E.negate()),k&&(g=g.negate()),g=new m(n.mul(g.px,C.beta),g.py,g.pz),E.add(g)}multiply(x){const{endo:C,n:P}=t;Sn("scalar",x,ne,P);let q,L;if(C){const{k1neg:I,k1:k,k2neg:H,k2:E}=C.splitScalar(x);let{p:g,f:y}=this.wNAF(k),{p:b,f:w}=this.wNAF(E);g=R.constTimeNegate(I,g),b=R.constTimeNegate(H,b),b=new m(n.mul(b.px,C.beta),b.py,b.pz),q=g.add(b),L=y.add(w)}else{const{p:I,f:k}=this.wNAF(x);q=I,L=k}return m.normalizeZ([q,L])[0]}multiplyAndAddUnsafe(x,C,P){const q=m.BASE,L=(k,H)=>H===Ge||H===ne||!k.equals(q)?k.multiplyUnsafe(H):k.multiply(H),I=L(this,C).add(L(x,P));return I.is0()?void 0:I}toAffine(x){return u(this,x)}isTorsionFree(){const{h:x,isTorsionFree:C}=t;if(x===ne)return!0;if(C)return C(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:x,clearCofactor:C}=t;return x===ne?this:C?C(m,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return Wn("isCompressed",x),this.assertValidity(),o(m,this,x)}toHex(x=!0){return Wn("isCompressed",x),sn(this.toRawBytes(x))}}m.BASE=new m(t.Gx,t.Gy,n.ONE),m.ZERO=new m(n.ZERO,n.ONE,n.ZERO);const{endo:v,nBitLength:_}=t,R=ch(m,v?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:h,weierstrassEquation:s,isWithinCurveOrder:l}}function lh(e){const t=Yc(e);return Jn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function dh(e){const t=lh(e),{Fp:n,n:r,nByteLength:o,nBitLength:i}=t,s=n.BYTES+1,c=2*n.BYTES+1;function f(b){return _e(b,r)}function a(b){return ri(b,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:u}=di({...t,toBytes(b,w,B){const A=w.toAffine(),O=n.toBytes(A.x),S=ce;return Wn("isCompressed",B),B?S(Uint8Array.from([w.hasEvenY()?2:3]),O):S(Uint8Array.from([4]),O,n.toBytes(A.y))},fromBytes(b){const w=b.length,B=b[0],A=b.subarray(1);if(w===s&&(B===2||B===3)){const O=Oe(A);if(!Ko(O,ne,n.ORDER))throw new Error("Point is not on curve");const S=d(O);let N;try{N=n.sqrt(S)}catch(T){const F=T instanceof Error?": "+T.message:"";throw new Error("Point is not on curve"+F)}const $=(N&ne)===ne;return(B&1)===1!==$&&(N=n.neg(N)),{x:O,y:N}}else if(w===c&&B===4){const O=n.fromBytes(A.subarray(0,n.BYTES)),S=n.fromBytes(A.subarray(n.BYTES,2*n.BYTES));return{x:O,y:S}}else{const O=s,S=c;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+S+", got "+w)}}});function p(b){const w=r>>ne;return b>w}function m(b){return p(b)?f(-b):b}const v=(b,w,B)=>Oe(b.slice(w,B));class _{constructor(w,B,A){Sn("r",w,ne,r),Sn("s",B,ne,r),this.r=w,this.s=B,A!=null&&(this.recovery=A),Object.freeze(this)}static fromCompact(w){const B=o;return w=Ee("compactSignature",w,B*2),new _(v(w,0,B),v(w,B,2*B))}static fromDER(w){const{r:B,s:A}=bt.toSig(Ee("DER",w));return new _(B,A)}assertValidity(){}addRecoveryBit(w){return new _(this.r,this.s,w)}recoverPublicKey(w){const{r:B,s:A,recovery:O}=this,S=q(Ee("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const N=O===2||O===3?B+t.n:B;if(N>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const $=(O&1)===0?"02":"03",U=l.fromHex($+ui(N,n.BYTES)),T=a(N),F=f(-S*T),j=f(A*T),M=l.BASE.multiplyAndAddUnsafe(U,F,j);if(!M)throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,f(-this.s),this.recovery):this}toDERRawBytes(){return Cr(this.toDERHex())}toDERHex(){return bt.hexFromSig(this)}toCompactRawBytes(){return Cr(this.toCompactHex())}toCompactHex(){const w=o;return ui(this.r,w)+ui(this.s,w)}}const R={isValidPrivateKey(b){try{return h(b),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const b=oi(t.n);return kc(t.randomBytes(b),t.n)},precompute(b=8,w=l.BASE){return w._setWindowSize(b),w.multiply(BigInt(3)),w}};function D(b,w=!0){return l.fromPrivateKey(b).toRawBytes(w)}function x(b){if(typeof b=="bigint")return!1;if(b instanceof l)return!0;const B=Ee("key",b).length,A=n.BYTES,O=A+1,S=2*A+1;if(!(t.allowedPrivateKeyLengths||o===O))return B===O||B===S}function C(b,w,B=!0){if(x(b)===!0)throw new Error("first arg must be private key");if(x(w)===!1)throw new Error("second arg must be public key");return l.fromHex(w).multiply(h(b)).toRawBytes(B)}const P=t.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const w=Oe(b),B=b.length*8-i;return B>0?w>>BigInt(B):w},q=t.bits2int_modN||function(b){return f(P(b))},L=cn(i);function I(b){return Sn("num < 2^"+i,b,Ge,L),ue(b,o)}function k(b,w,B=H){if(["recovered","canonical"].some(z=>z in B))throw new Error("sign() legacy options not supported");const{hash:A,randomBytes:O}=t;let{lowS:S,prehash:N,extraEntropy:$}=B;S==null&&(S=!0),b=Ee("msgHash",b),Wc(B),N&&(b=Ee("prehashed msgHash",A(b)));const U=q(b),T=h(w),F=[I(T),I(U)];if($!=null&&$!==!1){const z=$===!0?O(n.BYTES):$;F.push(Ee("extraEntropy",z))}const j=ce(...F),M=U;function V(z){const Z=P(z);if(!u(Z))return;const W=a(Z),J=l.BASE.multiply(Z).toAffine(),ee=f(J.x);if(ee===Ge)return;const oe=f(W*f(M+ee*T));if(oe===Ge)return;let se=(J.x===ee?0:2)|Number(J.y&ne),Ot=oe;return S&&p(oe)&&(Ot=m(oe),se^=1),new _(ee,Ot,se)}return{seed:j,k2sig:V}}const H={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};function g(b,w,B=H){const{seed:A,k2sig:O}=k(b,w,B),S=t;return v0(S.hash.outputLen,S.nByteLength,S.hmac)(A,O)}l.BASE._setWindowSize(8);function y(b,w,B,A=E){const O=b;w=Ee("msgHash",w),B=Ee("publicKey",B);const{lowS:S,prehash:N,format:$}=A;if(Wc(A),"strict"in A)throw new Error("options.strict was renamed to lowS");if($!==void 0&&$!=="compact"&&$!=="der")throw new Error("format must be compact or der");const U=typeof O=="string"||Yn(O),T=!U&&!$&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!U&&!T)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,j;try{if(T&&(F=new _(O.r,O.s)),U){try{$!=="compact"&&(F=_.fromDER(O))}catch(se){if(!(se instanceof bt.Err))throw se}!F&&$!=="der"&&(F=_.fromCompact(O))}j=l.fromHex(B)}catch{return!1}if(!F||S&&F.hasHighS())return!1;N&&(w=t.hash(w));const{r:M,s:V}=F,z=q(w),Z=a(V),W=f(z*Z),J=f(M*Z),ee=l.BASE.multiplyAndAddUnsafe(j,W,J)?.toAffine();return ee?f(ee.x)===M:!1}return{CURVE:t,getPublicKey:D,getSharedSecret:C,sign:g,verify:y,ProjectivePoint:l,Signature:_,utils:R}}function hh(e,t){const n=e.ORDER;let r=Ge;for(let p=n-ne;p%$t===Ge;p/=$t)r+=ne;const o=r,i=$t<<o-ne-ne,s=i*$t,c=(n-ne)/s,f=(c-ne)/$t,a=s-ne,l=i,h=e.pow(t,c),d=e.pow(t,(c+ne)/$t);let u=(p,m)=>{let v=h,_=e.pow(m,a),R=e.sqr(_);R=e.mul(R,m);let D=e.mul(p,R);D=e.pow(D,f),D=e.mul(D,_),_=e.mul(D,m),R=e.mul(D,p);let x=e.mul(R,_);D=e.pow(x,l);let C=e.eql(D,e.ONE);_=e.mul(R,d),D=e.mul(x,v),R=e.cmov(_,R,C),x=e.cmov(D,x,C);for(let P=o;P>ne;P--){let q=P-$t;q=$t<<q-ne;let L=e.pow(x,q);const I=e.eql(L,e.ONE);_=e.mul(R,v),v=e.mul(v,v),L=e.mul(x,v),R=e.cmov(_,R,I),x=e.cmov(L,x,I)}return{isValid:C,value:R}};if(e.ORDER%li===Qn){const p=(e.ORDER-Qn)/li,m=e.sqrt(e.neg(t));u=(v,_)=>{let R=e.sqr(_);const D=e.mul(v,_);R=e.mul(R,D);let x=e.pow(R,p);x=e.mul(x,D);const C=e.mul(x,m),P=e.mul(e.sqr(x),_),q=e.eql(P,v);let L=e.cmov(C,x,q);return{isValid:q,value:L}}}return u}function Xc(e,t){if(Hc(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=hh(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let o,i,s,c,f,a,l,h;o=e.sqr(r),o=e.mul(o,t.Z),i=e.sqr(o),i=e.add(i,o),s=e.add(i,e.ONE),s=e.mul(s,t.B),c=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),c=e.mul(c,t.A),i=e.sqr(s),a=e.sqr(c),f=e.mul(a,t.A),i=e.add(i,f),i=e.mul(i,s),a=e.mul(a,c),f=e.mul(a,t.B),i=e.add(i,f),l=e.mul(o,s);const{isValid:d,value:u}=n(i,a);h=e.mul(o,r),h=e.mul(h,u),l=e.cmov(l,s,d),h=e.cmov(h,u,d);const p=e.isOdd(r)===e.isOdd(h);h=e.cmov(e.neg(h),h,p);const m=an(e,[c],!0)[0];return l=e.mul(l,m),{x:l,y:h}}}function bh(e){return{hash:e,hmac:(t,...n)=>ni(e,t,at(...n)),randomBytes:Or}}function Tr(e,t){const n=r=>dh({...e,...bh(r)});return{...n(t),create:n}}const gh=Oe;function Rt(e,t){if(er(e),er(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function wh(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function er(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ph(e,t,n,r){Ct(e),Ct(t),er(n),t.length>255&&(t=r(ce(Vo("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:i}=r,s=Math.ceil(n/o);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const c=ce(t,Rt(t.length,1)),f=Rt(0,i),a=Rt(n,2),l=new Array(s),h=r(ce(f,e,a,Rt(0,1),c));l[0]=r(ce(h,Rt(1,1),c));for(let u=1;u<=s;u++){const p=[wh(h,l[u-1]),Rt(u+1,1),c];l[u]=r(ce(...p))}return ce(...l).slice(0,n)}function yh(e,t,n,r,o){if(Ct(e),Ct(t),er(n),t.length>255){const i=Math.ceil(2*r/8);t=o.create({dkLen:i}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update(Rt(n,2)).update(t).update(Rt(t.length,1)).digest()}function Jc(e,t,n){Jn(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:o,m:i,hash:s,expand:c,DST:f}=n;Ct(e),er(t);const a=typeof f=="string"?Vo(f):f,l=r.toString(2).length,h=Math.ceil((l+o)/8),d=t*i*h;let u;if(c==="xmd")u=ph(e,a,d,s);else if(c==="xof")u=yh(e,a,d,o,s);else if(c==="_internal_pass")u=e;else throw new Error('expand must be "xmd" or "xof"');const p=new Array(t);for(let m=0;m<t;m++){const v=new Array(i);for(let _=0;_<i;_++){const R=h*(_+m*i),D=u.subarray(R,R+h);v[_]=_e(gh(D),r)}p[m]=v}return p}function Qc(e,t){const n=t.map(r=>Array.from(r).reverse());return(r,o)=>{const[i,s,c,f]=n.map(h=>h.reduce((d,u)=>e.add(e.mul(d,r),u))),[a,l]=an(e,[s,f],!0);return r=e.mul(i,a),o=e.mul(o,e.mul(c,l)),{x:r,y:o}}}function ef(e,t,n){if(typeof t!="function")throw new Error("mapToCurve() must be defined");function r(i){return e.fromAffine(t(i))}function o(i){const s=i.clearCofactor();return s.equals(e.ZERO)?e.ZERO:(s.assertValidity(),s)}return{defaults:n,hashToCurve(i,s){const c=Jc(i,2,{...n,DST:n.DST,...s}),f=r(c[0]),a=r(c[1]);return o(f.add(a))},encodeToCurve(i,s){const c=Jc(i,1,{...n,DST:n.encodeDST,...s});return o(r(c[0]))},mapToCurve(i){if(!Array.isArray(i))throw new Error("expected array of bigints");for(const s of i)if(typeof s!="bigint")throw new Error("expected array of bigints");return o(r(i))}}}const tf=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),mh=BigInt(0),Eh=BigInt(1),hi=BigInt(2),rf=(e,t)=>(e+t/hi)/t;function xh(e){const t=tf,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,l=a*a*e%t,h=Me(l,n,t)*l%t,d=Me(h,n,t)*l%t,u=Me(d,hi,t)*a%t,p=Me(u,o,t)*u%t,m=Me(p,i,t)*p%t,v=Me(m,c,t)*m%t,_=Me(v,f,t)*v%t,R=Me(_,c,t)*m%t,D=Me(R,n,t)*l%t,x=Me(D,s,t)*p%t,C=Me(x,r,t)*a%t,P=Me(C,hi,t);if(!bi.eql(bi.sqr(P),e))throw new Error("Cannot find square root");return P}const bi=Ut(tf,void 0,void 0,{sqrt:xh});Tr({a:mh,b:BigInt(7),Fp:bi,n:nf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=nf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Eh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=rf(i*e,t),f=rf(-r*e,t);let a=_e(e-c*n-f*o,t),l=_e(-c*r-f*i,t);const h=a>s,d=l>s;if(h&&(a=t-a),d&&(l=t-l),a>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}}},On),Object.freeze({1:0n,2:1n,3:2n,4:3n,5:4n,6:5n,7:6n,8:7n,9:8n,A:9n,B:10n,C:11n,D:12n,E:13n,F:14n,G:15n,H:16n,J:17n,K:18n,L:19n,M:20n,N:21n,P:22n,Q:23n,R:24n,S:25n,T:26n,U:27n,V:28n,W:29n,X:30n,Y:31n,Z:32n,a:33n,b:34n,c:35n,d:36n,e:37n,f:38n,g:39n,h:40n,i:41n,j:42n,k:43n,m:44n,n:45n,o:46n,p:47n,q:48n,r:49n,s:50n,t:51n,u:52n,v:53n,w:54n,x:55n,y:56n,z:57n}),Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]),{...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t]))},ut.slice();const vh=BigInt(0),Pr=BigInt(1),of=BigInt(2),_n=BigInt(3);function Bh(e){const t=[];for(;e>Pr;e>>=Pr)(e&Pr)===vh?t.unshift(0):(e&_n)===_n?(t.unshift(-1),e+=Pr):t.unshift(1);return t}function Dh(e){const{Fp:t,Fr:n,Fp2:r,Fp6:o,Fp12:i}=e.fields,s=e.params.xNegative,c=e.params.twistType,f=di({n:n.ORDER,...e.G1}),a=Object.assign(f,ef(f.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),l=di({n:n.ORDER,...e.G2}),h=Object.assign(l,ef(l.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults}));let d;if(c==="multiplicative")d=(U,T,F,j,M,V)=>i.mul014(j,U,r.mul(T,M),r.mul(F,V));else if(c==="divisive")d=(U,T,F,j,M,V)=>i.mul034(j,r.mul(F,V),r.mul(T,M),U);else throw new Error("bls: unknown twist type");const u=r.div(r.ONE,r.mul(r.ONE,of));function p(U,T,F,j){const M=r.sqr(F),V=r.sqr(j),z=r.mulByB(r.mul(V,_n)),Z=r.mul(z,_n),W=r.sub(r.sub(r.sqr(r.add(F,j)),V),M),J=r.sub(z,M),ee=r.mul(r.sqr(T),_n),oe=r.neg(W);return U.push([J,ee,oe]),T=r.mul(r.mul(r.mul(r.sub(M,Z),T),F),u),F=r.sub(r.sqr(r.mul(r.add(M,Z),u)),r.mul(r.sqr(z),_n)),j=r.mul(M,W),{Rx:T,Ry:F,Rz:j}}function m(U,T,F,j,M,V){const z=r.sub(F,r.mul(V,j)),Z=r.sub(T,r.mul(M,j)),W=r.sub(r.mul(z,M),r.mul(Z,V)),J=r.neg(z),ee=Z;U.push([W,J,ee]);const oe=r.sqr(Z),se=r.mul(oe,Z),Ot=r.mul(oe,T),Ao=r.add(r.sub(se,r.mul(Ot,of)),r.mul(r.sqr(z),j));return T=r.mul(Z,Ao),F=r.sub(r.mul(r.sub(Ot,Ao),z),r.mul(se,F)),j=r.mul(j,se),{Rx:T,Ry:F,Rz:j}}const v=Bh(e.params.ateLoopSize),_=Wo(U=>{const T=U,{x:F,y:j}=T.toAffine(),M=F,V=j,z=r.neg(j);let Z=M,W=V,J=r.ONE;const ee=[];for(const oe of v){const se=[];({Rx:Z,Ry:W,Rz:J}=p(se,Z,W,J)),oe&&({Rx:Z,Ry:W,Rz:J}=m(se,Z,W,J,M,oe===-1?z:V)),ee.push(se)}if(e.postPrecompute){const oe=ee[ee.length-1];e.postPrecompute(Z,W,J,M,V,m.bind(null,oe))}return ee});function R(U,T=!1){let F=i.ONE;if(U.length){const j=U[0][0].length;for(let M=0;M<j;M++){F=i.sqr(F);for(const[V,z,Z]of U)for(const[W,J,ee]of V[M])F=d(W,J,ee,F,z,Z)}}return s&&(F=i.conjugate(F)),T?i.finalExponentiate(F):F}function D(U,T=!0){const F=[];a.ProjectivePoint.normalizeZ(U.map(({g1:j})=>j)),h.ProjectivePoint.normalizeZ(U.map(({g2:j})=>j));for(const{g1:j,g2:M}of U){if(j.equals(a.ProjectivePoint.ZERO)||M.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");j.assertValidity(),M.assertValidity();const V=j.toAffine();F.push([_(M),V.x,V.y])}return R(F,T)}function x(U,T,F=!0){return D([{g1:U,g2:T}],F)}const C={randomPrivateKey:()=>{const U=oi(n.ORDER);return kc(e.randomBytes(U),n.ORDER)},calcPairingPrecomputes:_},{ShortSignature:P}=e.G1,{Signature:q}=e.G2;function L(U){return U instanceof a.ProjectivePoint?U:a.ProjectivePoint.fromHex(U)}function I(U,T){return U instanceof a.ProjectivePoint?U:a.hashToCurve(Ee("point",U),T)}function k(U){return U instanceof h.ProjectivePoint?U:q.fromHex(U)}function H(U,T){return U instanceof h.ProjectivePoint?U:h.hashToCurve(Ee("point",U),T)}function E(U){return a.ProjectivePoint.fromPrivateKey(U).toRawBytes(!0)}function g(U){return h.ProjectivePoint.fromPrivateKey(U).toRawBytes(!0)}function y(U,T,F){const j=H(U,F);j.assertValidity();const M=j.multiply(a.normPrivateKeyToScalar(T));return U instanceof h.ProjectivePoint?M:q.toRawBytes(M)}function b(U,T,F){const j=I(U,F);j.assertValidity();const M=j.multiply(a.normPrivateKeyToScalar(T));return U instanceof a.ProjectivePoint?M:P.toRawBytes(M)}function w(U,T,F,j){const M=L(F),V=H(T,j),z=a.ProjectivePoint.BASE,Z=k(U),W=D([{g1:M.negate(),g2:V},{g1:z,g2:Z}]);return i.eql(W,i.ONE)}function B(U,T,F,j){const M=k(F),V=I(T,j),z=h.ProjectivePoint.BASE,Z=L(U),W=D([{g1:V,g2:M},{g1:Z,g2:z.negate()}]);return i.eql(W,i.ONE)}function A(U){if(!Array.isArray(U)||U.length===0)throw new Error("expected non-empty array")}function O(U){A(U);const F=U.map(L).reduce((j,M)=>j.add(M),a.ProjectivePoint.ZERO);return U[0]instanceof a.ProjectivePoint?(F.assertValidity(),F):F.toRawBytes(!0)}function S(U){A(U);const F=U.map(k).reduce((j,M)=>j.add(M),h.ProjectivePoint.ZERO);return U[0]instanceof h.ProjectivePoint?(F.assertValidity(),F):q.toRawBytes(F)}function N(U){A(U);const F=U.map(L).reduce((j,M)=>j.add(M),a.ProjectivePoint.ZERO);return U[0]instanceof a.ProjectivePoint?(F.assertValidity(),F):P.toRawBytes(F)}function $(U,T,F,j){if(A(T),F.length!==T.length)throw new Error("amount of public keys and messages should be equal");const M=k(U),V=T.map(J=>H(J,j)),z=F.map(L),Z=new Map;for(let J=0;J<z.length;J++){const ee=z[J],oe=V[J];let se=Z.get(oe);se===void 0&&(se=[],Z.set(oe,se)),se.push(ee)}const W=[];try{for(const[J,ee]of Z){const oe=ee.reduce((se,Ot)=>se.add(Ot));W.push({g1:oe,g2:J})}return W.push({g1:a.ProjectivePoint.BASE.negate(),g2:M}),i.eql(D(W),i.ONE)}catch{return!1}}return a.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:E,getPublicKeyForShortSignatures:g,sign:y,signShortSignature:b,verify:w,verifyBatch:$,verifyShortSignature:B,aggregatePublicKeys:O,aggregateSignatures:S,aggregateShortSignatures:N,millerLoopBatch:R,pairing:x,pairingBatch:D,G1:a,G2:h,Signature:q,ShortSignature:P,fields:{Fr:n,Fp:t,Fp2:r,Fp6:o,Fp12:i},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:C}}const Ah=BigInt(0),In=BigInt(1),gt=BigInt(2),sf=BigInt(3);function gi(e,t,n,r,o=1,i){const s=BigInt(i===void 0?r:i),c=n**BigInt(r),f=[];for(let a=0;a<o;a++){const l=BigInt(a+1),h=[];for(let d=0,u=In;d<r;d++){const p=(l*u-l)/s%c;h.push(e.pow(t,p)),u*=n}f.push(h)}return f}function Oh(e,t,n){const r=t.pow(n,(e.ORDER-In)/sf),o=t.pow(n,(e.ORDER-In)/gt);function i(d,u){const p=t.mul(t.frobeniusMap(d,1),r),m=t.mul(t.frobeniusMap(u,1),o);return[p,m]}const s=t.pow(n,(e.ORDER**gt-In)/sf),c=t.pow(n,(e.ORDER**gt-In)/gt);if(!t.eql(c,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function f(d,u){return[t.mul(d,s),t.neg(u)]}const a=d=>(u,p)=>{const m=p.toAffine(),v=d(m.x,m.y);return u.fromAffine({x:v[0],y:v[1]})},l=a(i),h=a(f);return{psi:i,psi2:f,G2psi:l,G2psi2:h,PSI_X:r,PSI_Y:o,PSI2_X:s,PSI2_Y:c}}function Sh(e){const{ORDER:t}=e,n=Ut(t),r=n.create(e.NONRESIDUE||BigInt(-1)),o=n.div(n.ONE,gt),i=gi(n,r,n.ORDER,2)[0],s=({c0:E,c1:g},{c0:y,c1:b})=>({c0:n.add(E,y),c1:n.add(g,b)}),c=({c0:E,c1:g},{c0:y,c1:b})=>({c0:n.sub(E,y),c1:n.sub(g,b)}),f=({c0:E,c1:g},y)=>{if(typeof y=="bigint")return{c0:n.mul(E,y),c1:n.mul(g,y)};const{c0:b,c1:w}=y;let B=n.mul(E,b),A=n.mul(g,w);const O=n.sub(B,A),S=n.sub(n.mul(n.add(E,g),n.add(b,w)),n.add(B,A));return{c0:O,c1:S}},a=({c0:E,c1:g})=>{const y=n.add(E,g),b=n.sub(E,g),w=n.add(E,E);return{c0:n.mul(y,b),c1:n.mul(w,g)}},l=E=>{if(E.length!==2)throw new Error("invalid tuple");const g=E.map(y=>n.create(y));return{c0:g[0],c1:g[1]}},h=t*t,d=l(e.FP2_NONRESIDUE),u={ORDER:h,isLE:n.isLE,NONRESIDUE:d,BITS:Xn(h),BYTES:Math.ceil(Xn(h)/8),MASK:cn(Xn(h)),ZERO:{c0:n.ZERO,c1:n.ZERO},ONE:{c0:n.ONE,c1:n.ZERO},create:E=>E,isValid:({c0:E,c1:g})=>typeof E=="bigint"&&typeof g=="bigint",is0:({c0:E,c1:g})=>n.is0(E)&&n.is0(g),eql:({c0:E,c1:g},{c0:y,c1:b})=>n.eql(E,y)&&n.eql(g,b),neg:({c0:E,c1:g})=>({c0:n.neg(E),c1:n.neg(g)}),pow:(E,g)=>$r(u,E,g),invertBatch:E=>an(u,E),add:s,sub:c,mul:f,sqr:a,addN:s,subN:c,mulN:f,sqrN:a,div:(E,g)=>u.mul(E,typeof g=="bigint"?n.inv(n.create(g)):u.inv(g)),inv:({c0:E,c1:g})=>{const y=n.inv(n.create(E*E+g*g));return{c0:n.mul(y,n.create(E)),c1:n.mul(y,n.create(-g))}},sqrt:E=>{if(e.Fp2sqrt)return e.Fp2sqrt(E);const{c0:g,c1:y}=E;if(n.is0(y))return Rr(n,g)===1?u.create({c0:n.sqrt(g),c1:n.ZERO}):u.create({c0:n.ZERO,c1:n.sqrt(n.div(g,r))});const b=n.sqrt(n.sub(n.sqr(g),n.mul(n.sqr(y),r)));let w=n.mul(n.add(b,g),o);Rr(n,w)===-1&&(w=n.sub(w,b));const A=n.sqrt(w),O=u.create({c0:A,c1:n.div(n.mul(y,o),A)});if(!u.eql(u.sqr(O),E))throw new Error("Cannot find square root");const S=O,N=u.neg(S),{re:$,im:U}=u.reim(S),{re:T,im:F}=u.reim(N);return U>F||U===F&&$>T?S:N},isOdd:E=>{const{re:g,im:y}=u.reim(E),b=g%gt,w=g===Ah,B=y%gt;return BigInt(b||w&&B)==In},fromBytes(E){if(E.length!==u.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:n.fromBytes(E.subarray(0,n.BYTES)),c1:n.fromBytes(E.subarray(n.BYTES))}},toBytes:({c0:E,c1:g})=>ce(n.toBytes(E),n.toBytes(g)),cmov:({c0:E,c1:g},{c0:y,c1:b},w)=>({c0:n.cmov(E,y,w),c1:n.cmov(g,b,w)}),reim:({c0:E,c1:g})=>({re:E,im:g}),mulByNonresidue:({c0:E,c1:g})=>u.mul({c0:E,c1:g},d),mulByB:e.Fp2mulByB,fromBigTuple:l,frobeniusMap:({c0:E,c1:g},y)=>({c0:E,c1:n.mul(g,i[y%2])})},p=({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>({c0:u.add(E,b),c1:u.add(g,w),c2:u.add(y,B)}),m=({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>({c0:u.sub(E,b),c1:u.sub(g,w),c2:u.sub(y,B)}),v=({c0:E,c1:g,c2:y},b)=>{if(typeof b=="bigint")return{c0:u.mul(E,b),c1:u.mul(g,b),c2:u.mul(y,b)};const{c0:w,c1:B,c2:A}=b,O=u.mul(E,w),S=u.mul(g,B),N=u.mul(y,A);return{c0:u.add(O,u.mulByNonresidue(u.sub(u.mul(u.add(g,y),u.add(B,A)),u.add(S,N)))),c1:u.add(u.sub(u.mul(u.add(E,g),u.add(w,B)),u.add(O,S)),u.mulByNonresidue(N)),c2:u.sub(u.add(S,u.mul(u.add(E,y),u.add(w,A))),u.add(O,N))}},_=({c0:E,c1:g,c2:y})=>{let b=u.sqr(E),w=u.mul(u.mul(E,g),gt),B=u.mul(u.mul(g,y),gt),A=u.sqr(y);return{c0:u.add(u.mulByNonresidue(B),b),c1:u.add(u.mulByNonresidue(A),w),c2:u.sub(u.sub(u.add(u.add(w,u.sqr(u.add(u.sub(E,g),y))),B),b),A)}},[R,D]=gi(u,d,n.ORDER,6,2,3),x={ORDER:u.ORDER,isLE:u.isLE,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:cn(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:E=>E,isValid:({c0:E,c1:g,c2:y})=>u.isValid(E)&&u.isValid(g)&&u.isValid(y),is0:({c0:E,c1:g,c2:y})=>u.is0(E)&&u.is0(g)&&u.is0(y),neg:({c0:E,c1:g,c2:y})=>({c0:u.neg(E),c1:u.neg(g),c2:u.neg(y)}),eql:({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>u.eql(E,b)&&u.eql(g,w)&&u.eql(y,B),sqrt:_c,div:(E,g)=>x.mul(E,typeof g=="bigint"?n.inv(n.create(g)):x.inv(g)),pow:(E,g)=>$r(x,E,g),invertBatch:E=>an(x,E),add:p,sub:m,mul:v,sqr:_,addN:p,subN:m,mulN:v,sqrN:_,inv:({c0:E,c1:g,c2:y})=>{let b=u.sub(u.sqr(E),u.mulByNonresidue(u.mul(y,g))),w=u.sub(u.mulByNonresidue(u.sqr(y)),u.mul(E,g)),B=u.sub(u.sqr(g),u.mul(E,y)),A=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(y,w),u.mul(g,B))),u.mul(E,b)));return{c0:u.mul(A,b),c1:u.mul(A,w),c2:u.mul(A,B)}},fromBytes:E=>{if(E.length!==x.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:u.fromBytes(E.subarray(0,u.BYTES)),c1:u.fromBytes(E.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(E.subarray(2*u.BYTES))}},toBytes:({c0:E,c1:g,c2:y})=>ce(u.toBytes(E),u.toBytes(g),u.toBytes(y)),cmov:({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B},A)=>({c0:u.cmov(E,b,A),c1:u.cmov(g,w,A),c2:u.cmov(y,B,A)}),fromBigSix:E=>{if(!Array.isArray(E)||E.length!==6)throw new Error("invalid Fp6 usage");return{c0:u.fromBigTuple(E.slice(0,2)),c1:u.fromBigTuple(E.slice(2,4)),c2:u.fromBigTuple(E.slice(4,6))}},frobeniusMap:({c0:E,c1:g,c2:y},b)=>({c0:u.frobeniusMap(E,b),c1:u.mul(u.frobeniusMap(g,b),R[b%6]),c2:u.mul(u.frobeniusMap(y,b),D[b%6])}),mulByFp2:({c0:E,c1:g,c2:y},b)=>({c0:u.mul(E,b),c1:u.mul(g,b),c2:u.mul(y,b)}),mulByNonresidue:({c0:E,c1:g,c2:y})=>({c0:u.mulByNonresidue(y),c1:E,c2:g}),mul1:({c0:E,c1:g,c2:y},b)=>({c0:u.mulByNonresidue(u.mul(y,b)),c1:u.mul(E,b),c2:u.mul(g,b)}),mul01({c0:E,c1:g,c2:y},b,w){let B=u.mul(E,b),A=u.mul(g,w);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(g,y),w),A)),B),c1:u.sub(u.sub(u.mul(u.add(b,w),u.add(E,g)),B),A),c2:u.add(u.sub(u.mul(u.add(E,y),b),B),A)}}},C=gi(u,d,n.ORDER,12,1,6)[0],P=({c0:E,c1:g},{c0:y,c1:b})=>({c0:x.add(E,y),c1:x.add(g,b)}),q=({c0:E,c1:g},{c0:y,c1:b})=>({c0:x.sub(E,y),c1:x.sub(g,b)}),L=({c0:E,c1:g},y)=>{if(typeof y=="bigint")return{c0:x.mul(E,y),c1:x.mul(g,y)};let{c0:b,c1:w}=y,B=x.mul(E,b),A=x.mul(g,w);return{c0:x.add(B,x.mulByNonresidue(A)),c1:x.sub(x.mul(x.add(E,g),x.add(b,w)),x.add(B,A))}},I=({c0:E,c1:g})=>{let y=x.mul(E,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),E),x.add(E,g)),y),x.mulByNonresidue(y)),c1:x.add(y,y)}};function k(E,g){const y=u.sqr(E),b=u.sqr(g);return{first:u.add(u.mulByNonresidue(b),y),second:u.sub(u.sub(u.sqr(u.add(E,g)),y),b)}}const H={ORDER:u.ORDER,isLE:x.isLE,BITS:2*x.BITS,BYTES:2*x.BYTES,MASK:cn(2*x.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:E=>E,isValid:({c0:E,c1:g})=>x.isValid(E)&&x.isValid(g),is0:({c0:E,c1:g})=>x.is0(E)&&x.is0(g),neg:({c0:E,c1:g})=>({c0:x.neg(E),c1:x.neg(g)}),eql:({c0:E,c1:g},{c0:y,c1:b})=>x.eql(E,y)&&x.eql(g,b),sqrt:_c,inv:({c0:E,c1:g})=>{let y=x.inv(x.sub(x.sqr(E),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(E,y),c1:x.neg(x.mul(g,y))}},div:(E,g)=>H.mul(E,typeof g=="bigint"?n.inv(n.create(g)):H.inv(g)),pow:(E,g)=>$r(H,E,g),invertBatch:E=>an(H,E),add:P,sub:q,mul:L,sqr:I,addN:P,subN:q,mulN:L,sqrN:I,fromBytes:E=>{if(E.length!==H.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:x.fromBytes(E.subarray(0,x.BYTES)),c1:x.fromBytes(E.subarray(x.BYTES))}},toBytes:({c0:E,c1:g})=>ce(x.toBytes(E),x.toBytes(g)),cmov:({c0:E,c1:g},{c0:y,c1:b},w)=>({c0:x.cmov(E,y,w),c1:x.cmov(g,b,w)}),fromBigTwelve:E=>({c0:x.fromBigSix(E.slice(0,6)),c1:x.fromBigSix(E.slice(6,12))}),frobeniusMap(E,g){const{c0:y,c1:b,c2:w}=x.frobeniusMap(E.c1,g),B=C[g%12];return{c0:x.frobeniusMap(E.c0,g),c1:x.create({c0:u.mul(y,B),c1:u.mul(b,B),c2:u.mul(w,B)})}},mulByFp2:({c0:E,c1:g},y)=>({c0:x.mulByFp2(E,y),c1:x.mulByFp2(g,y)}),conjugate:({c0:E,c1:g})=>({c0:E,c1:x.neg(g)}),mul014:({c0:E,c1:g},y,b,w)=>{let B=x.mul01(E,y,b),A=x.mul1(g,w);return{c0:x.add(x.mulByNonresidue(A),B),c1:x.sub(x.sub(x.mul01(x.add(g,E),y,u.add(b,w)),B),A)}},mul034:({c0:E,c1:g},y,b,w)=>{const B=x.create({c0:u.mul(E.c0,y),c1:u.mul(E.c1,y),c2:u.mul(E.c2,y)}),A=x.mul01(g,b,w),O=x.mul01(x.add(E,g),u.add(y,b),w);return{c0:x.add(x.mulByNonresidue(A),B),c1:x.sub(O,x.add(B,A))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:n,Fp2:u,Fp6:x,Fp4Square:k,Fp12:H}}const Ie=BigInt(0),Lr=BigInt(1),he=BigInt(2),qr=BigInt(3),tr=BigInt(4),Tt=BigInt("0xd201000000010000"),_h=Xn(Tt),{Fp:K,Fp2:Y,Fp6:wi,Fp4Square:pi,Fp12:Q}=Sh({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Lr,Lr],Fp2mulByB:({c0:e,c1:t})=>{const n=K.mul(e,tr),r=K.mul(t,tr);return{c0:K.sub(n,r),c1:K.add(n,r)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{const{c0:n,c1:r,c2:o}=e,{c0:i,c1:s,c2:c}=t,{first:f,second:a}=pi(n,s),{first:l,second:h}=pi(i,o),{first:d,second:u}=pi(r,c),p=Y.mulByNonresidue(u);return{c0:wi.create({c0:Y.add(Y.mul(Y.sub(f,n),he),f),c1:Y.add(Y.mul(Y.sub(l,r),he),l),c2:Y.add(Y.mul(Y.sub(d,o),he),d)}),c1:wi.create({c0:Y.add(Y.mul(Y.add(p,i),he),p),c1:Y.add(Y.mul(Y.add(a,s),he),a),c2:Y.add(Y.mul(Y.add(h,c),he),h)})}},Fp12cyclotomicExp(e,t){let n=Q.ONE;for(let r=_h-1;r>=0;r--)n=Q._cyclotomicSquare(n),x0(t,r)&&(n=Q.mul(n,e));return n},Fp12finalExponentiate:e=>{const t=Tt,n=Q.div(Q.frobeniusMap(e,6),e),r=Q.mul(Q.frobeniusMap(n,2),n),o=Q.conjugate(Q._cyclotomicExp(r,t)),i=Q.mul(Q.conjugate(Q._cyclotomicSquare(r)),o),s=Q.conjugate(Q._cyclotomicExp(i,t)),c=Q.conjugate(Q._cyclotomicExp(s,t)),f=Q.mul(Q.conjugate(Q._cyclotomicExp(c,t)),Q._cyclotomicSquare(o)),a=Q.conjugate(Q._cyclotomicExp(f,t)),l=Q.frobeniusMap(Q.mul(o,c),2),h=Q.frobeniusMap(Q.mul(s,r),3),d=Q.frobeniusMap(Q.mul(f,Q.conjugate(r)),1),u=Q.mul(Q.mul(a,Q.conjugate(i)),r);return Q.mul(Q.mul(Q.mul(l,h),d),u)}}),cf=Ut(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Ih=Qc(Y,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>Y.fromBigTuple(t.map(BigInt))))),Nh=Qc(K,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Fh=Xc(Y,{A:Y.create({c0:K.create(Ie),c1:K.create(BigInt(240))}),B:Y.create({c0:K.create(BigInt(1012)),c1:K.create(BigInt(1012))}),Z:Y.create({c0:K.create(BigInt(-2)),c1:K.create(BigInt(-1))})}),Ch=Xc(K,{A:K.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:K.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:K.create(BigInt(11))}),{G2psi:ff,G2psi2:Uh}=Oh(K,Y,Y.div(Y.ONE,Y.NONRESIDUE)),yi=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:K.ORDER,m:2,k:128,expand:"xmd",hash:On}),jr=nr(K.toBytes(Ie),{infinity:!0,compressed:!0});function Hr(e){e=e.slice();const t=e[0]&224,n=!!(t>>7&1),r=!!(t>>6&1),o=!!(t>>5&1);return e[0]&=31,{compressed:n,infinity:r,sort:o,value:e}}function nr(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function af(e){e.assertValidity();const t=e.equals(Ke.G1.ProjectivePoint.ZERO),{x:n,y:r}=e.toAffine();if(t)return jr.slice();const o=K.ORDER,i=!!(r*he/o);return nr(ue(n,K.BYTES),{compressed:!0,sort:i})}function uf(e){e.assertValidity();const t=K.BYTES;if(e.equals(Ke.G2.ProjectivePoint.ZERO))return ce(jr,ue(Ie,t));const{x:n,y:r}=e.toAffine(),{re:o,im:i}=Y.reim(n),{re:s,im:c}=Y.reim(r),a=!!((c>Ie?c*he:s*he)/K.ORDER&Lr),l=o;return ce(nr(ue(i,t),{sort:a,compressed:!0}),ue(l,t))}const Ke=Dh({fields:{Fp:K,Fp2:Y,Fp6:wi,Fp12:Q,Fr:cf},G1:{Fp:K,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:K.ZERO,b:tr,htfDefaults:{...yi,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{const n=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),r=new e(K.mul(t.px,n),t.py,t.pz);return t.multiplyUnsafe(Tt).negate().multiplyUnsafe(Tt).equals(r)},clearCofactor:(e,t)=>t.multiplyUnsafe(Tt).add(t),mapToCurve:e=>{const{x:t,y:n}=Ch(K.create(e[0]));return Nh(t,n)},fromBytes:e=>{const{compressed:t,infinity:n,sort:r,value:o}=Hr(e);if(o.length===48&&t){const i=K.ORDER,s=Oe(o),c=K.create(s&K.MASK);if(n){if(c!==Ie)throw new Error("G1: non-empty compressed point at infinity");return{x:Ie,y:Ie}}const f=K.add(K.pow(c,qr),K.create(Ke.params.G1b));let a=K.sqrt(f);if(!a)throw new Error("invalid compressed G1 point");return a*he/i!==BigInt(r)&&(a=K.neg(a)),{x:K.create(c),y:K.create(a)}}else if(o.length===96&&!t){const i=Oe(o.subarray(0,K.BYTES)),s=Oe(o.subarray(K.BYTES));if(n){if(i!==Ie||s!==Ie)throw new Error("G1: non-empty point at infinity");return Ke.G1.ProjectivePoint.ZERO.toAffine()}return{x:K.create(i),y:K.create(s)}}else throw new Error("invalid point G1, expected 48/96 bytes")},toBytes:(e,t,n)=>{const r=t.equals(e.ZERO),{x:o,y:i}=t.toAffine();if(n){if(r)return jr.slice();const s=K.ORDER,c=!!(i*he/s);return nr(ue(o,K.BYTES),{compressed:!0,sort:c})}else return r?ce(new Uint8Array([64]),new Uint8Array(2*K.BYTES-1)):ce(ue(o,K.BYTES),ue(i,K.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:r}=Hr(Ee("signatureHex",e,48)),o=K.ORDER,i=Oe(r);if(t)return Ke.G1.ProjectivePoint.ZERO;const s=K.create(i&K.MASK),c=K.add(K.pow(s,qr),K.create(Ke.params.G1b));let f=K.sqrt(c);if(!f)throw new Error("invalid compressed G1 point");const a=BigInt(n);f*he/o!==a&&(f=K.neg(f));const l=Ke.G1.ProjectivePoint.fromAffine({x:s,y:f});return l.assertValidity(),l},toRawBytes(e){return af(e)},toHex(e){return sn(af(e))}}},G2:{Fp:Y,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:Y.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:Y.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:Y.ZERO,b:Y.fromBigTuple([tr,tr]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...yi},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{const{x:t,y:n}=Fh(Y.fromBigTuple(e));return Ih(t,n)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Tt).negate().equals(ff(e,t)),clearCofactor:(e,t)=>{const n=Tt;let r=t.multiplyUnsafe(n).negate(),o=ff(e,t),i=t.double();return i=Uh(e,i),i=i.subtract(o),o=r.add(o),o=o.multiplyUnsafe(n).negate(),i=i.add(o),i=i.subtract(r),i.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:r,value:o}=Hr(e);if(!t&&!n&&r||!t&&n&&r||r&&n&&t)throw new Error("invalid encoding flag: "+(e[0]&224));const i=K.BYTES,s=(c,f,a)=>Oe(c.slice(f,a));if(o.length===96&&t){const c=Ke.params.G2b,f=K.ORDER;if(n){if(o.reduce((m,v)=>m!==0?v+1:v,0)>0)throw new Error("invalid compressed G2 point");return{x:Y.ZERO,y:Y.ZERO}}const a=s(o,0,i),l=s(o,i,2*i),h=Y.create({c0:K.create(l),c1:K.create(a)}),d=Y.add(Y.pow(h,qr),c);let u=Y.sqrt(d);const p=u.c1===Ie?u.c0*he/f:u.c1*he/f?Lr:Ie;return u=r&&p>0?u:Y.neg(u),{x:h,y:u}}else if(o.length===192&&!t){if(n){if(o.reduce((h,d)=>h!==0?d+1:d,0)>0)throw new Error("invalid uncompressed G2 point");return{x:Y.ZERO,y:Y.ZERO}}const c=s(o,0,i),f=s(o,i,2*i),a=s(o,2*i,3*i),l=s(o,3*i,4*i);return{x:Y.fromBigTuple([f,c]),y:Y.fromBigTuple([l,a])}}else throw new Error("invalid point G2, expected 96/192 bytes")},toBytes:(e,t,n)=>{const{BYTES:r,ORDER:o}=K,i=t.equals(e.ZERO),{x:s,y:c}=t.toAffine();if(n){if(i)return ce(jr,ue(Ie,r));const f=!!(c.c1===Ie?c.c0*he/o:c.c1*he/o);return ce(nr(ue(s.c1,r),{compressed:!0,sort:f}),ue(s.c0,r))}else{if(i)return ce(new Uint8Array([64]),new Uint8Array(4*r-1));const{re:f,im:a}=Y.reim(s),{re:l,im:h}=Y.reim(c);return ce(ue(a,r),ue(f,r),ue(h,r),ue(l,r))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:r}=Hr(Ee("signatureHex",e)),o=K.ORDER,i=r.length/2;if(i!==48&&i!==96)throw new Error("invalid compressed signature length, must be 96 or 192");const s=Oe(r.slice(0,i)),c=Oe(r.slice(i));if(t)return Ke.G2.ProjectivePoint.ZERO;const f=K.create(s&K.MASK),a=K.create(c),l=Y.create({c0:a,c1:f}),h=Y.add(Y.pow(l,qr),Ke.params.G2b);let d=Y.sqrt(h);if(!d)throw new Error("Failed to find a square root");const{re:u,im:p}=Y.reim(d),m=BigInt(n),v=p>Ie&&p*he/o!==m,_=p===Ie&&u*he/o!==m;(v||_)&&(d=Y.neg(d));const R=Ke.G2.ProjectivePoint.fromAffine({x:l,y:d});return R.assertValidity(),R},toRawBytes(e){return uf(e)},toHex(e){return sn(uf(e))}}},params:{ateLoopSize:Tt,r:cf.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:yi,hash:On,randomBytes:Or});BigInt(0),BigInt(1),BigInt(2),BigInt(8),BigInt(0),BigInt(1),BigInt(2),BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),BigInt(0),BigInt(1),BigInt(2),BigInt(3),BigInt(5),BigInt(8);const mi=BigInt(0),Ei=BigInt(1);function Mr(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function un(e,t,n=""){const r=vr(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){const s=n&&`"${n}" `,c=i?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+f)}return e}function zr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function lf(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?mi:BigInt("0x"+e)}function kr(e){return lf(Bn(e))}function df(e){return ct(e),lf(Bn(Uint8Array.from(e).reverse()))}function xi(e,t){return Br(e.toString(16).padStart(t*2,"0"))}function hf(e,t){return xi(e,t).reverse()}function Ue(e,t,n){let r;if(typeof t=="string")try{r=Br(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(vr(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const vi=e=>typeof e=="bigint"&&mi<=e;function $h(e,t,n){return vi(e)&&vi(t)&&vi(n)&&t<=e&&e<n}function Rh(e,t,n,r){if(!$h(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function bf(e){let t;for(t=0;e>mi;e>>=Ei,t+=1);return t}const rr=e=>(Ei<<BigInt(e))-Ei;function Th(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=u=>new Uint8Array(u),o=u=>Uint8Array.of(u);let i=r(e),s=r(e),c=0;const f=()=>{i.fill(1),s.fill(0),c=0},a=(...u)=>n(s,i,...u),l=(u=r(0))=>{s=a(o(0),u),i=a(),u.length!==0&&(s=a(o(1),u),i=a())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const p=[];for(;u<t;){i=a();const m=i.slice();p.push(m),u+=i.length}return at(...p)};return(u,p)=>{f(),l(u);let m;for(;!(m=p(h()));)l();return f(),m}}function Bi(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,i,s){const c=e[o];if(s&&c===void 0)return;const f=typeof c;if(f!==i||c===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${f}`)}Object.entries(t).forEach(([o,i])=>r(o,i,!1)),Object.entries(n).forEach(([o,i])=>r(o,i,!0))}function gf(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const $e=BigInt(0),Ne=BigInt(1),ln=BigInt(2),wf=BigInt(3),pf=BigInt(4),yf=BigInt(5),Ph=BigInt(7),mf=BigInt(8),Lh=BigInt(9),Ef=BigInt(16);function Ye(e,t){const n=e%t;return n>=$e?n:t+n}function ze(e,t,n){let r=e;for(;t-- >$e;)r*=r,r%=n;return r}function xf(e,t){if(e===$e)throw new Error("invert: expected non-zero number");if(t<=$e)throw new Error("invert: expected positive modulus, got "+t);let n=Ye(e,t),r=t,o=$e,i=Ne;for(;n!==$e;){const c=r/n,f=r%n,a=o-i*c;r=n,n=f,o=i,i=a}if(r!==Ne)throw new Error("invert: does not exist");return Ye(o,t)}function Di(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function vf(e,t){const n=(e.ORDER+Ne)/pf,r=e.pow(t,n);return Di(e,r,t),r}function qh(e,t){const n=(e.ORDER-yf)/mf,r=e.mul(t,ln),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,ln),o),c=e.mul(i,e.sub(s,e.ONE));return Di(e,c,t),c}function jh(e){const t=or(e),n=Bf(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+Ph)/Ef;return(c,f)=>{let a=c.pow(f,s),l=c.mul(a,r);const h=c.mul(a,o),d=c.mul(a,i),u=c.eql(c.sqr(l),f),p=c.eql(c.sqr(h),f);a=c.cmov(a,l,u),l=c.cmov(d,h,p);const m=c.eql(c.sqr(l),f),v=c.cmov(a,l,m);return Di(c,v,f),v}}function Bf(e){if(e<wf)throw new Error("sqrt is not defined for small field");let t=e-Ne,n=0;for(;t%ln===$e;)t/=ln,n++;let r=ln;const o=or(e);for(;Af(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return vf;let i=o.pow(r,t);const s=(t+Ne)/ln;return function(f,a){if(f.is0(a))return a;if(Af(f,a)!==1)throw new Error("Cannot find square root");let l=n,h=f.mul(f.ONE,i),d=f.pow(a,t),u=f.pow(a,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let p=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(p++,m=f.sqr(m),p===l)throw new Error("Cannot find square root");const v=Ne<<BigInt(l-p-1),_=f.pow(h,v);l=p,h=f.sqr(_),d=f.mul(d,h),u=f.mul(u,_)}return u}}function Hh(e){return e%pf===wf?vf:e%mf===yf?qh:e%Ef===Lh?jh(e):Bf(e)}const Mh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zh(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Mh.reduce((r,o)=>(r[o]="function",r),t);return Bi(e,n),e}function kh(e,t,n){if(n<$e)throw new Error("invalid exponent, negatives unsupported");if(n===$e)return e.ONE;if(n===Ne)return t;let r=e.ONE,o=t;for(;n>$e;)n&Ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Ne;return r}function Df(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function Af(e,t){const n=(e.ORDER-Ne)/ln,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Of(e,t){t!==void 0&&xn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function or(e,t,n=!1,r={}){if(e<=$e)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(s=d.modFromBytes),c=d.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:f,nByteLength:a}=Of(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:a,MASK:rr(f),ZERO:$e,ONE:Ne,allowedLengths:c,create:d=>Ye(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return $e<=d&&d<e},is0:d=>d===$e,isValidNot0:d=>!h.is0(d)&&h.isValid(d),isOdd:d=>(d&Ne)===Ne,neg:d=>Ye(-d,e),eql:(d,u)=>d===u,sqr:d=>Ye(d*d,e),add:(d,u)=>Ye(d+u,e),sub:(d,u)=>Ye(d-u,e),mul:(d,u)=>Ye(d*u,e),pow:(d,u)=>kh(h,d,u),div:(d,u)=>Ye(d*xf(u,e),e),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>xf(d,e),sqrt:i||(d=>(l||(l=Hh(e)),l(h,d))),toBytes:d=>n?hf(d,a):xi(d,a),fromBytes:(d,u=!0)=>{if(c){if(!c.includes(d.length)||d.length>a)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(a);m.set(d,n?0:m.length-d.length),d=m}if(d.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);let p=n?df(d):kr(d);if(s&&(p=Ye(p,e)),!u&&!h.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:d=>Df(h,d),cmov:(d,u,p)=>p?u:d});return Object.freeze(h)}function Sf(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function _f(e){const t=Sf(e);return t+Math.ceil(t/2)}function Zh(e,t,n=!1){const r=e.length,o=Sf(t),i=_f(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?df(e):kr(e),c=Ye(s,t-Ne)+Ne;return n?hf(c,o):xi(c,o)}const Nn=BigInt(0),dn=BigInt(1);function Zr(e,t){const n=t.negate();return e?n:t}function Ai(e,t){const n=Df(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function If(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Oi(e,t){If(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=rr(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Nf(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=dn);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function Vh(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Gh(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Si=new WeakMap,Ff=new WeakMap;function _i(e){return Ff.get(e)||1}function Cf(e){if(e!==Nn)throw new Error("invalid wNAF")}class Kh{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>Nn;)n&dn&&(r=r.add(o)),o=o.double(),n>>=dn;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=Oi(n,this.bits),i=[];let s=t,c=s;for(let f=0;f<r;f++){c=s,i.push(c);for(let a=1;a<o;a++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE;const s=Oi(t,this.bits);for(let c=0;c<s.windows;c++){const{nextN:f,offset:a,isZero:l,isNeg:h,isNegF:d,offsetF:u}=Nf(r,c,s);r=f,l?i=i.add(Zr(d,n[u])):o=o.add(Zr(h,n[a]))}return Cf(r),{p:o,f:i}}wNAFUnsafe(t,n,r,o=this.ZERO){const i=Oi(t,this.bits);for(let s=0;s<i.windows&&r!==Nn;s++){const{nextN:c,offset:f,isZero:a,isNeg:l}=Nf(r,s,i);if(r=c,!a){const h=n[f];o=o.add(l?h.negate():h)}}return Cf(r),o}getPrecomputes(t,n,r){let o=Si.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),Si.set(n,o))),o}cached(t,n,r){const o=_i(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const i=_i(t);return i===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),n,o)}createCache(t,n){If(n,this.bits),Ff.set(t,n),Si.delete(t)}hasCache(t){return _i(t)!==1}}function Yh(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Nn||r>Nn;)n&dn&&(i=i.add(o)),r&dn&&(s=s.add(o)),o=o.double(),n>>=dn,r>>=dn;return{p1:i,p2:s}}function Wh(e,t,n,r){Vh(n,e),Gh(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=bf(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=rr(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Uf(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return zh(t),t}else return or(e,{isLE:n})}function Xh(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const f of["p","n","h"]){const a=t[f];if(!(typeof a=="bigint"&&a>Nn))throw new Error(`CURVE.${f} must be positive bigint`)}const o=Uf(t.p,n.Fp,r),i=Uf(t.n,n.Fn,r),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}const $f=(e,t)=>(e+(e>=0?t:-t)/Rf)/t;function Jh(e,t,n){const[[r,o],[i,s]]=t,c=$f(s*e,n),f=$f(-o*e,n);let a=e-c*r-f*i,l=-c*o-f*s;const h=a<pt,d=l<pt;h&&(a=-a),d&&(l=-l);const u=rr(Math.ceil(bf(n)/2))+Fn;if(a<pt||a>=u||l<pt||l>=u)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}function Ii(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Ni(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Mr(n.lowS,"lowS"),Mr(n.prehash,"prehash"),n.format!==void 0&&Ii(n.format),n}class Qh extends Error{constructor(t=""){super(t)}}const wt={Err:Qh,_tlv:{encode:(e,t)=>{const{Err:n}=wt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=zr(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?zr(o.length/2|128):"";return zr(e)+i+o+t},decode(e,t){const{Err:n}=wt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=wt;if(e<pt)throw new t("integer: negative integers are not allowed");let n=zr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=wt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kr(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=wt,o=Ue("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=wt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}},pt=BigInt(0),Fn=BigInt(1),Rf=BigInt(2),Vr=BigInt(3),e1=BigInt(4);function Cn(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=Ue("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function t1(e,t={}){const n=Xh("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:c}=i;Bi(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(i.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const a=Pf(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(E,g,y){const{x:b,y:w}=g.toAffine(),B=r.toBytes(b);if(Mr(y,"isCompressed"),y){l();const A=!r.isOdd(w);return at(Tf(A),B)}else return at(Uint8Array.of(4),B,r.toBytes(w))}function d(E){un(E,void 0,"Point");const{publicKey:g,publicKeyUncompressed:y}=a,b=E.length,w=E[0],B=E.subarray(1);if(b===g&&(w===2||w===3)){const A=r.fromBytes(B);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const O=m(A);let S;try{S=r.sqrt(O)}catch(U){const T=U instanceof Error?": "+U.message:"";throw new Error("bad point: is not on curve, sqrt error"+T)}l();const N=r.isOdd(S);return(w&1)===1!==N&&(S=r.neg(S)),{x:A,y:S}}else if(b===y&&w===4){const A=r.BYTES,O=r.fromBytes(B.subarray(0,A)),S=r.fromBytes(B.subarray(A,A*2));if(!v(O,S))throw new Error("bad point: is not on curve");return{x:O,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${g} or uncompressed=${y}`)}const u=t.toBytes||h,p=t.fromBytes||d;function m(E){const g=r.sqr(E),y=r.mul(g,E);return r.add(r.add(y,r.mul(E,i.a)),i.b)}function v(E,g){const y=r.sqr(g),b=m(E);return r.eql(y,b)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const _=r.mul(r.pow(i.a,Vr),e1),R=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(_,R)))throw new Error("bad curve params: a or b");function D(E,g,y=!1){if(!r.isValid(g)||y&&r.is0(g))throw new Error(`bad point coordinate ${E}`);return g}function x(E){if(!(E instanceof I))throw new Error("ProjectivePoint expected")}function C(E){if(!f||!f.basises)throw new Error("no endo");return Jh(E,f.basises,o.ORDER)}const P=gf((E,g)=>{const{X:y,Y:b,Z:w}=E;if(r.eql(w,r.ONE))return{x:y,y:b};const B=E.is0();g==null&&(g=B?r.ONE:r.inv(w));const A=r.mul(y,g),O=r.mul(b,g),S=r.mul(w,g);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),q=gf(E=>{if(E.is0()){if(t.allowInfinityPoint&&!r.is0(E.Y))return;throw new Error("bad point: ZERO")}const{x:g,y}=E.toAffine();if(!r.isValid(g)||!r.isValid(y))throw new Error("bad point: x or y not field elements");if(!v(g,y))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(E,g,y,b,w){return y=new I(r.mul(y.X,E),y.Y,y.Z),g=Zr(b,g),y=Zr(w,y),g.add(y)}class I{constructor(g,y,b){this.X=D("x",g),this.Y=D("y",y,!0),this.Z=D("z",b),Object.freeze(this)}static CURVE(){return i}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!r.isValid(y)||!r.isValid(b))throw new Error("invalid affine point");if(g instanceof I)throw new Error("projective point not allowed");return r.is0(y)&&r.is0(b)?I.ZERO:new I(y,b,r.ONE)}static fromBytes(g){const y=I.fromAffine(p(un(g,void 0,"point")));return y.assertValidity(),y}static fromHex(g){return I.fromBytes(Ue("pointHex",g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,y=!0){return H.createCache(this,g),y||this.multiply(Vr),this}assertValidity(){q(this)}hasEvenY(){const{y:g}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(g)}equals(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g,S=r.eql(r.mul(y,O),r.mul(B,w)),N=r.eql(r.mul(b,O),r.mul(A,w));return S&&N}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:g,b:y}=i,b=r.mul(y,Vr),{X:w,Y:B,Z:A}=this;let O=r.ZERO,S=r.ZERO,N=r.ZERO,$=r.mul(w,w),U=r.mul(B,B),T=r.mul(A,A),F=r.mul(w,B);return F=r.add(F,F),N=r.mul(w,A),N=r.add(N,N),O=r.mul(g,N),S=r.mul(b,T),S=r.add(O,S),O=r.sub(U,S),S=r.add(U,S),S=r.mul(O,S),O=r.mul(F,O),N=r.mul(b,N),T=r.mul(g,T),F=r.sub($,T),F=r.mul(g,F),F=r.add(F,N),N=r.add($,$),$=r.add(N,$),$=r.add($,T),$=r.mul($,F),S=r.add(S,$),T=r.mul(B,A),T=r.add(T,T),$=r.mul(T,F),O=r.sub(O,$),N=r.mul(T,U),N=r.add(N,N),N=r.add(N,N),new I(O,S,N)}add(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g;let S=r.ZERO,N=r.ZERO,$=r.ZERO;const U=i.a,T=r.mul(i.b,Vr);let F=r.mul(y,B),j=r.mul(b,A),M=r.mul(w,O),V=r.add(y,b),z=r.add(B,A);V=r.mul(V,z),z=r.add(F,j),V=r.sub(V,z),z=r.add(y,w);let Z=r.add(B,O);return z=r.mul(z,Z),Z=r.add(F,M),z=r.sub(z,Z),Z=r.add(b,w),S=r.add(A,O),Z=r.mul(Z,S),S=r.add(j,M),Z=r.sub(Z,S),$=r.mul(U,z),S=r.mul(T,M),$=r.add(S,$),S=r.sub(j,$),$=r.add(j,$),N=r.mul(S,$),j=r.add(F,F),j=r.add(j,F),M=r.mul(U,M),z=r.mul(T,z),j=r.add(j,M),M=r.sub(F,M),M=r.mul(U,M),z=r.add(z,M),F=r.mul(j,z),N=r.add(N,F),F=r.mul(Z,z),S=r.mul(V,S),S=r.sub(S,F),F=r.mul(V,j),$=r.mul(Z,$),$=r.add($,F),new I(S,N,$)}subtract(g){return this.add(g.negate())}is0(){return this.equals(I.ZERO)}multiply(g){const{endo:y}=t;if(!o.isValidNot0(g))throw new Error("invalid scalar: out of range");let b,w;const B=A=>H.cached(this,A,O=>Ai(I,O));if(y){const{k1neg:A,k1:O,k2neg:S,k2:N}=C(g),{p:$,f:U}=B(O),{p:T,f:F}=B(N);w=U.add(F),b=L(y.beta,$,T,A,S)}else{const{p:A,f:O}=B(g);b=A,w=O}return Ai(I,[b,w])[0]}multiplyUnsafe(g){const{endo:y}=t,b=this;if(!o.isValid(g))throw new Error("invalid scalar: out of range");if(g===pt||b.is0())return I.ZERO;if(g===Fn)return b;if(H.hasCache(this))return this.multiply(g);if(y){const{k1neg:w,k1:B,k2neg:A,k2:O}=C(g),{p1:S,p2:N}=Yh(I,b,B,O);return L(y.beta,S,N,w,A)}else return H.unsafe(b,g)}multiplyAndAddUnsafe(g,y,b){const w=this.multiplyUnsafe(y).add(g.multiplyUnsafe(b));return w.is0()?void 0:w}toAffine(g){return P(this,g)}isTorsionFree(){const{isTorsionFree:g}=t;return s===Fn?!0:g?g(I,this):H.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:g}=t;return s===Fn?this:g?g(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(g=!0){return Mr(g,"isCompressed"),this.assertValidity(),u(I,this,g)}toHex(g=!0){return Bn(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(g=!0){return this.toBytes(g)}_setWindowSize(g){this.precompute(g)}static normalizeZ(g){return Ai(I,g)}static msm(g,y){return Wh(I,o,g,y)}static fromPrivateKey(g){return I.BASE.multiply(Cn(o,g))}}I.BASE=new I(i.Gx,i.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=o;const k=o.BITS,H=new Kh(I,t.endo?Math.ceil(k/2):k);return I.BASE.precompute(8),I}function Tf(e){return Uint8Array.of(e?2:3)}function Pf(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function n1(e,t={}){const{Fn:n}=e,r=t.randomBytes||Or,o=Object.assign(Pf(e.Fp,n),{seed:_f(n.ORDER)});function i(u){try{return!!Cn(n,u)}catch{return!1}}function s(u,p){const{publicKey:m,publicKeyUncompressed:v}=o;try{const _=u.length;return p===!0&&_!==m||p===!1&&_!==v?!1:!!e.fromBytes(u)}catch{return!1}}function c(u=r(o.seed)){return Zh(un(u,o.seed,"seed"),n.ORDER)}function f(u,p=!0){return e.BASE.multiply(Cn(n,u)).toBytes(p)}function a(u){const p=c(u);return{secretKey:p,publicKey:f(p)}}function l(u){if(typeof u=="bigint")return!1;if(u instanceof e)return!0;const{secretKey:p,publicKey:m,publicKeyUncompressed:v}=o;if(n.allowedLengths||p===m)return;const _=Ue("key",u).length;return _===m||_===v}function h(u,p,m=!0){if(l(u)===!0)throw new Error("first arg must be private key");if(l(p)===!1)throw new Error("second arg must be public key");const v=Cn(n,u);return e.fromHex(p).multiply(v).toBytes(m)}return Object.freeze({getPublicKey:f,getSharedSecret:h,keygen:a,Point:e,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:u=>Cn(n,u),precompute(u=8,p=e.BASE){return p.precompute(u,!1)}},lengths:o})}function r1(e,t,n={}){oc(t),Bi(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Or,o=n.hmac||((y,...b)=>ni(t,y,at(...b))),{Fp:i,Fn:s}=e,{ORDER:c,BITS:f}=s,{keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u}=n1(e,n),p={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},m="compact";function v(y){const b=c>>Fn;return y>b}function _(y,b){if(!s.isValidNot0(b))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return b}function R(y,b){Ii(b);const w=u.signature,B=b==="compact"?w:b==="recovered"?w+1:void 0;return un(y,B,`${b} signature`)}class D{constructor(b,w,B){this.r=_("r",b),this.s=_("s",w),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,w=m){R(b,w);let B;if(w==="der"){const{r:N,s:$}=wt.toSig(un(b));return new D(N,$)}w==="recovered"&&(B=b[0],w="compact",b=b.subarray(1));const A=s.BYTES,O=b.subarray(0,A),S=b.subarray(A,A*2);return new D(s.fromBytes(O),s.fromBytes(S),B)}static fromHex(b,w){return this.fromBytes(Br(b),w)}addRecoveryBit(b){return new D(this.r,this.s,b)}recoverPublicKey(b){const w=i.ORDER,{r:B,s:A,recovery:O}=this;if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");if(c*Rf<w&&O>1)throw new Error("recovery id is ambiguous for h>1 curve");const N=O===2||O===3?B+c:B;if(!i.isValid(N))throw new Error("recovery id 2 or 3 invalid");const $=i.toBytes(N),U=e.fromBytes(at(Tf((O&1)===0),$)),T=s.inv(N),F=C(Ue("msgHash",b)),j=s.create(-F*T),M=s.create(A*T),V=e.BASE.multiplyUnsafe(j).add(U.multiplyUnsafe(M));if(V.is0())throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return v(this.s)}toBytes(b=m){if(Ii(b),b==="der")return Br(wt.hexFromSig(this));const w=s.toBytes(this.r),B=s.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return at(Uint8Array.of(this.recovery),w,B)}return at(w,B)}toHex(b){return Bn(this.toBytes(b))}assertValidity(){}static fromCompact(b){return D.fromBytes(Ue("sig",b),"compact")}static fromDER(b){return D.fromBytes(Ue("sig",b),"der")}normalizeS(){return this.hasHighS()?new D(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Bn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Bn(this.toBytes("compact"))}}const x=n.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const w=kr(b),B=b.length*8-f;return B>0?w>>BigInt(B):w},C=n.bits2int_modN||function(b){return s.create(x(b))},P=rr(f);function q(y){return Rh("num < 2^"+f,y,pt,P),s.toBytes(y)}function L(y,b){return un(y,void 0,"message"),b?un(t(y),void 0,"prehashed message"):y}function I(y,b,w){if(["recovered","canonical"].some(j=>j in w))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:A,extraEntropy:O}=Ni(w,p);y=L(y,A);const S=C(y),N=Cn(s,b),$=[q(N),q(S)];if(O!=null&&O!==!1){const j=O===!0?r(u.secretKey):O;$.push(Ue("extraEntropy",j))}const U=at(...$),T=S;function F(j){const M=x(j);if(!s.isValidNot0(M))return;const V=s.inv(M),z=e.BASE.multiply(M).toAffine(),Z=s.create(z.x);if(Z===pt)return;const W=s.create(V*s.create(T+Z*N));if(W===pt)return;let J=(z.x===Z?0:2)|Number(z.y&Fn),ee=W;return B&&v(W)&&(ee=s.neg(W),J^=1),new D(Z,ee,J)}return{seed:U,k2sig:F}}function k(y,b,w={}){y=Ue("message",y);const{seed:B,k2sig:A}=I(y,b,w);return Th(t.outputLen,s.BYTES,o)(B,A)}function H(y){let b;const w=typeof y=="string"||vr(y),B=!w&&y!==null&&typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!w&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new D(y.r,y.s);else if(w){try{b=D.fromBytes(Ue("sig",y),"der")}catch(A){if(!(A instanceof wt.Err))throw A}if(!b)try{b=D.fromBytes(Ue("sig",y),"compact")}catch{return!1}}return b||!1}function E(y,b,w,B={}){const{lowS:A,prehash:O,format:S}=Ni(B,p);if(w=Ue("publicKey",w),b=L(Ue("message",b),O),"strict"in B)throw new Error("options.strict was renamed to lowS");const N=S===void 0?H(y):D.fromBytes(Ue("sig",y),S);if(N===!1)return!1;try{const $=e.fromBytes(w);if(A&&N.hasHighS())return!1;const{r:U,s:T}=N,F=C(b),j=s.inv(T),M=s.create(F*j),V=s.create(U*j),z=e.BASE.multiplyUnsafe(M).add($.multiplyUnsafe(V));return z.is0()?!1:s.create(z.x)===U}catch{return!1}}function g(y,b,w={}){const{prehash:B}=Ni(w,p);return b=L(b,B),D.fromBytes(y,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u,Point:e,sign:k,verify:E,recoverPublicKey:g,Signature:D,hash:t})}function o1(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const o=or(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),i={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:i}}function i1(e){const{CURVE:t,curveOpts:n}=o1(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function s1(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Of(n.Fn.ORDER,n.Fn.BITS))})}function c1(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=i1(e),i=t1(t,n),s=r1(i,r,o);return s1(e,s)}function f1(e,t){const n=r=>c1({...e,hash:r});return{...n(t),create:n}}Mo("HashToScalar-");const Fi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},a1={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Lf=BigInt(2);function u1(e){const t=Fi.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,l=a*a*e%t,h=ze(l,n,t)*l%t,d=ze(h,n,t)*l%t,u=ze(d,Lf,t)*a%t,p=ze(u,o,t)*u%t,m=ze(p,i,t)*p%t,v=ze(m,c,t)*m%t,_=ze(v,f,t)*v%t,R=ze(_,c,t)*m%t,D=ze(R,n,t)*l%t,x=ze(D,s,t)*p%t,C=ze(x,r,t)*a%t,P=ze(C,Lf,t);if(!Ci.eql(Ci.sqr(P),e))throw new Error("Cannot find square root");return P}const Ci=or(Fi.p,{sqrt:u1});f1({...Fi,Fp:Ci,lowS:!0,endo:a1},On);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Un(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ui(e,...t){if(!Un(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function qf(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function $i(e){if(typeof e!="function")throw new Error("function expected");return!0}function Pt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function $n(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gr(e){if(!Array.isArray(e))throw new Error("array expected")}function Kr(e,t){if(!qf(!0,t))throw new Error(`${e}: array of strings expected`)}function Ri(e,t){if(!qf(!1,t))throw new Error(`${e}: array of numbers expected`)}function Re(...e){const t=i=>i,n=(i,s)=>c=>i(s(c)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function qe(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Kr("alphabet",t);const r=new Map(t.map((o,i)=>[o,i]));return{encode:o=>(Gr(o),o.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:o=>(Gr(o),o.map(i=>{Pt("alphabet.decode",i);const s=r.get(i);if(s===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function je(e=""){return Pt("join",e),{encode:t=>(Kr("join.decode",t),t.join(e)),decode:t=>(Pt("join.decode",t),t.split(e))}}function Yr(e,t="="){return $n(e),Pt("padding",t),{encode(n){for(Kr("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){Kr("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function jf(e){return $i(e),{encode:t=>t,decode:t=>e(t)}}function Hf(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Gr(e),!e.length)return[];let r=0;const o=[],i=Array.from(e,c=>{if($n(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),s=i.length;for(;;){let c=0,f=!0;for(let a=r;a<s;a++){const l=i[a],h=t*c,d=h+l;if(!Number.isSafeInteger(d)||h/t!==c||d-l!==h)throw new Error("convertRadix: carry overflow");const u=d/n;c=d%n;const p=Math.floor(u);if(i[a]=p,!Number.isSafeInteger(p)||p*n+c!==d)throw new Error("convertRadix: carry overflow");if(f)p?f=!1:r=a;else continue}if(o.push(c),f)break}for(let c=0;c<e.length-1&&e[c]===0;c++)o.push(0);return o.reverse()}const Mf=(e,t)=>t===0?e:Mf(t,e%t),Wr=(e,t)=>e+(t-Mf(e,t)),Xr=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Ti(e,t,n,r){if(Gr(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Wr(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wr(t,n)}`);let o=0,i=0;const s=Xr[t],c=Xr[n]-1,f=[];for(const a of e){if($n(a),a>=s)throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);if(o=o<<t|a,i+t>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)f.push((o>>i-n&c)>>>0);const l=Xr[i];if(l===void 0)throw new Error("invalid carry");o&=l-1}if(o=o<<n-i&c,!r&&i>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&f.push(o>>>0),f}function l1(e){$n(e);const t=2**8;return{encode:n=>{if(!Un(n))throw new Error("radix.encode input should be Uint8Array");return Hf(Array.from(n),t,e)},decode:n=>(Ri("radix.decode",n),Uint8Array.from(Hf(n,e,t)))}}function ke(e,t=!1){if($n(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wr(8,e)>32||Wr(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Un(n))throw new Error("radix2.encode input should be Uint8Array");return Ti(Array.from(n),8,e,!t)},decode:n=>(Ri("radix2.decode",n),Uint8Array.from(Ti(n,e,8,t)))}}function zf(e){return $i(e),function(...t){try{return e.apply(null,t)}catch{}}}function d1(e,t){return $n(e),$i(t),{encode(n){if(!Un(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!Un(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=n.slice(-e),i=t(r).slice(0,e);for(let s=0;s<e;s++)if(i[s]!==o[s])throw new Error("Invalid checksum");return r}}}const kf=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",Zf=(e,t)=>{Pt("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},Pi=e=>Re(l1(58),qe(e),je("")),h1=Pi("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),b1=e=>Re(d1(4,t=>e(e(t))),h1),Li=Re(qe("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),je("")),Vf=[996825010,642813549,513874426,1027748829,705979059];function ir(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<Vf.length;r++)(t>>r&1)===1&&(n^=Vf[r]);return n}function Gf(e,t,n=1){const r=e.length;let o=1;for(let i=0;i<r;i++){const s=e.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);o=ir(o)^s>>5}o=ir(o);for(let i=0;i<r;i++)o=ir(o)^e.charCodeAt(i)&31;for(let i of t)o=ir(o)^i;for(let i=0;i<6;i++)o=ir(o);return o^=n,Li.encode(Ti([o%Xr[30]],30,5,!1))}function Kf(e){const t=e==="bech32"?1:734539939,n=ke(5),r=n.decode,o=n.encode,i=zf(r);function s(h,d,u=90){Pt("bech32.encode prefix",h),Un(d)&&(d=Array.from(d)),Ri("bech32.encode",d);const p=h.length;if(p===0)throw new TypeError(`Invalid prefix length ${p}`);const m=p+7+d.length;if(u!==!1&&m>u)throw new TypeError(`Length ${m} exceeds limit ${u}`);const v=h.toLowerCase(),_=Gf(v,d,t);return`${v}1${Li.encode(d)}${_}`}function c(h,d=90){Pt("bech32.decode input",h);const u=h.length;if(u<8||d!==!1&&u>d)throw new TypeError(`invalid string length: ${u} (${h}). Expected (8..${d})`);const p=h.toLowerCase();if(h!==p&&h!==h.toUpperCase())throw new Error("String must be lowercase or uppercase");const m=p.lastIndexOf("1");if(m===0||m===-1)throw new Error('Letter "1" must be present between prefix and data only');const v=p.slice(0,m),_=p.slice(m+1);if(_.length<6)throw new Error("Data must be at least 6 characters long");const R=Li.decode(_).slice(0,-6),D=Gf(v,R,t);if(!_.endsWith(D))throw new Error(`Invalid checksum in ${h}: expected "${D}"`);return{prefix:v,words:R}}const f=zf(c);function a(h){const{prefix:d,words:u}=c(h,!1);return{prefix:d,words:u,bytes:r(u)}}function l(h,d){return s(h,o(d))}return{encode:s,decode:c,encodeFromBytes:l,decodeToBytes:a,decodeUnsafe:f,fromWords:r,fromWordsUnsafe:i,toWords:o}}const g1=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",w1={encode(e){return Ui(e),e.toHex()},decode(e){return Pt("hex",e),Uint8Array.fromHex(e)}};b1(On),Mo("Bitcoin seed");/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Yf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jr(e,...t){if(!Yf(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Qr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Wf(e,t){Jr(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function sr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qi(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function p1(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function y1(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function cr(e){if(typeof e=="string")e=y1(e);else if(Yf(e))e=Xf(e);else throw new Error("Uint8Array expected, got "+typeof e);return e}function Xf(e){return Uint8Array.from(e)}const yt=16,ji=new Uint8Array(16),nt=sr(ji),m1=225,E1=(e,t,n,r)=>{const o=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^m1<<24&-(o&1)}},Ze=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function x1(e){e.reverse();const t=e[15]&1;let n=0;for(let r=0;r<e.length;r++){const o=e[r];e[r]=o>>>1|n,n=(o&1)<<7}return e[0]^=-t&225,e}const v1=e=>e>64*1024?8:e>1024?4:2;class Jf{constructor(t,n){this.blockLen=yt,this.outputLen=yt,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,t=cr(t),Jr(t,16);const r=p1(t);let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const f=[];for(let p=0;p<128;p++)f.push({s0:Ze(o),s1:Ze(i),s2:Ze(s),s3:Ze(c)}),{s0:o,s1:i,s2:s,s3:c}=E1(o,i,s,c);const a=v1(n||1024);if(![1,2,4,8].includes(a))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=a;const h=128/a,d=this.windowSize=2**a,u=[];for(let p=0;p<h;p++)for(let m=0;m<d;m++){let v=0,_=0,R=0,D=0;for(let x=0;x<a;x++){if(!(m>>>a-x-1&1))continue;const{s0:P,s1:q,s2:L,s3:I}=f[a*p+x];v^=P,_^=q,R^=L,D^=I}u.push({s0:v,s1:_,s2:R,s3:D})}this.t=u}_updateBlock(t,n,r,o){t^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;const{W:i,t:s,windowSize:c}=this;let f=0,a=0,l=0,h=0;const d=(1<<i)-1;let u=0;for(const p of[t,n,r,o])for(let m=0;m<4;m++){const v=p>>>8*m&255;for(let _=8/i-1;_>=0;_--){const R=v>>>i*_&d,{s0:D,s1:x,s2:C,s3:P}=s[u*c+R];f^=D,a^=x,l^=C,h^=P,u+=1}}this.s0=f,this.s1=a,this.s2=l,this.s3=h}update(t){Qr(this),t=cr(t),Jr(t);const n=sr(t),r=Math.floor(t.length/yt),o=t.length%yt;for(let i=0;i<r;i++)this._updateBlock(n[i*4+0],n[i*4+1],n[i*4+2],n[i*4+3]);return o&&(ji.set(t.subarray(r*yt)),this._updateBlock(nt[0],nt[1],nt[2],nt[3]),qi(nt)),this}destroy(){const{t}=this;for(const n of t)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(t){Qr(this),Wf(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=sr(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t}digest(){const t=new Uint8Array(yt);return this.digestInto(t),this.destroy(),t}}class B1 extends Jf{constructor(t,n){t=cr(t),Jr(t);const r=x1(Xf(t));super(r,n),qi(r)}update(t){t=cr(t),Qr(this);const n=sr(t),r=t.length%yt,o=Math.floor(t.length/yt);for(let i=0;i<o;i++)this._updateBlock(Ze(n[i*4+3]),Ze(n[i*4+2]),Ze(n[i*4+1]),Ze(n[i*4+0]));return r&&(ji.set(t.subarray(o*yt)),this._updateBlock(Ze(nt[3]),Ze(nt[2]),Ze(nt[1]),Ze(nt[0])),qi(nt)),this}digestInto(t){Qr(this),Wf(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=sr(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t.reverse()}}function Qf(e){const t=(r,o)=>e(o,r.length).update(cr(r)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(r,o)=>e(r,o),t}Qf((e,t)=>new Jf(e,t)),Qf((e,t)=>new B1(e,t));const ea=Ut(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),D1=ea.create(BigInt("-3")),A1=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");Tr({a:D1,b:A1,Fp:ea,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},On);const ta=Ut(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),O1=ta.create(BigInt("-3")),S1=BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");Tr({a:O1,b:S1,Fp:ta,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},m0);const na=Ut(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),_1=na.create(BigInt("-3")),I1=BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");Tr({a:_1,b:I1,Fp:na,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},y0);var N1={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(f,a,l){this.fn=f,this.context=a,this.once=l||!1}function i(f,a,l,h,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var u=new o(l,h||f,d),p=n?n+a:a;return f._events[p]?f._events[p].fn?f._events[p]=[f._events[p],u]:f._events[p].push(u):(f._events[p]=u,f._eventsCount++),f}function s(f,a){--f._eventsCount===0?f._events=new r:delete f._events[a]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var a=[],l,h;if(this._eventsCount===0)return a;for(h in l=this._events)t.call(l,h)&&a.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(l)):a},c.prototype.listeners=function(a){var l=n?n+a:a,h=this._events[l];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,u=h.length,p=new Array(u);d<u;d++)p[d]=h[d].fn;return p},c.prototype.listenerCount=function(a){var l=n?n+a:a,h=this._events[l];return h?h.fn?1:h.length:0},c.prototype.emit=function(a,l,h,d,u,p){var m=n?n+a:a;if(!this._events[m])return!1;var v=this._events[m],_=arguments.length,R,D;if(v.fn){switch(v.once&&this.removeListener(a,v.fn,void 0,!0),_){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,l),!0;case 3:return v.fn.call(v.context,l,h),!0;case 4:return v.fn.call(v.context,l,h,d),!0;case 5:return v.fn.call(v.context,l,h,d,u),!0;case 6:return v.fn.call(v.context,l,h,d,u,p),!0}for(D=1,R=new Array(_-1);D<_;D++)R[D-1]=arguments[D];v.fn.apply(v.context,R)}else{var x=v.length,C;for(D=0;D<x;D++)switch(v[D].once&&this.removeListener(a,v[D].fn,void 0,!0),_){case 1:v[D].fn.call(v[D].context);break;case 2:v[D].fn.call(v[D].context,l);break;case 3:v[D].fn.call(v[D].context,l,h);break;case 4:v[D].fn.call(v[D].context,l,h,d);break;default:if(!R)for(C=1,R=new Array(_-1);C<_;C++)R[C-1]=arguments[C];v[D].fn.apply(v[D].context,R)}}return!0},c.prototype.on=function(a,l,h){return i(this,a,l,h,!1)},c.prototype.once=function(a,l,h){return i(this,a,l,h,!0)},c.prototype.removeListener=function(a,l,h,d){var u=n?n+a:a;if(!this._events[u])return this;if(!l)return s(this,u),this;var p=this._events[u];if(p.fn)p.fn===l&&(!d||p.once)&&(!h||p.context===h)&&s(this,u);else{for(var m=0,v=[],_=p.length;m<_;m++)(p[m].fn!==l||d&&!p[m].once||h&&p[m].context!==h)&&v.push(p[m]);v.length?this._events[u]=v.length===1?v[0]:v:s(this,u)}return this},c.prototype.removeAllListeners=function(a){var l;return a?(l=n?n+a:a,this._events[l]&&s(this,l)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c})(N1);function F1(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let a=0;a<t.length;a++)t[a]=255;for(let a=0;a<e.length;a++){const l=e.charAt(a),h=l.charCodeAt(0);if(t[h]!==255)throw new TypeError(l+" is ambiguous");t[h]=a}const n=e.length,r=e.charAt(0),o=Math.log(n)/Math.log(256),i=Math.log(256)/Math.log(n);function s(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";let l=0,h=0,d=0;const u=a.length;for(;d!==u&&a[d]===0;)d++,l++;const p=(u-d)*i+1>>>0,m=new Uint8Array(p);for(;d!==u;){let R=a[d],D=0;for(let x=p-1;(R!==0||D<h)&&x!==-1;x--,D++)R+=256*m[x]>>>0,m[x]=R%n>>>0,R=R/n>>>0;if(R!==0)throw new Error("Non-zero carry");h=D,d++}let v=p-h;for(;v!==p&&m[v]===0;)v++;let _=r.repeat(l);for(;v<p;++v)_+=e.charAt(m[v]);return _}function c(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;let l=0,h=0,d=0;for(;a[l]===r;)h++,l++;const u=(a.length-l)*o+1>>>0,p=new Uint8Array(u);for(;l<a.length;){const R=a.charCodeAt(l);if(R>255)return;let D=t[R];if(D===255)return;let x=0;for(let C=u-1;(D!==0||x<d)&&C!==-1;C--,x++)D+=n*p[C]>>>0,p[C]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");d=x,l++}let m=u-d;for(;m!==u&&p[m]===0;)m++;const v=new Uint8Array(h+(u-m));let _=h;for(;m!==u;)v[_++]=p[m++];return v}function f(a){const l=c(a);if(l)return l;throw new Error("Non-base"+n+" character")}return{encode:s,decodeUnsafe:c,decode:f}}var C1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";F1(C1);function U1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ra(e,...t){if(!U1(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function oa(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $1(e,t){ra(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const Rn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hi=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function R1(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function ia(e){return typeof e=="string"&&(e=R1(e)),ra(e),e}class T1{clone(){return this._cloneInto()}}function P1(e){const t=r=>e().update(ia(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function L1(e=32){if(Rn&&typeof Rn.getRandomValues=="function")return Rn.getRandomValues(new Uint8Array(e));if(Rn&&typeof Rn.randomBytes=="function")return Rn.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function q1(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}class j1 extends T1{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Hi(this.buffer)}update(t){oa(this);const{view:n,buffer:r,blockLen:o}=this;t=ia(t);const i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=Hi(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){oa(this),$1(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;q1(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Hi(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}}const eo=BigInt(2**32-1),Mi=BigInt(32);function sa(e,t=!1){return t?{h:Number(e&eo),l:Number(e>>Mi&eo)}:{h:Number(e>>Mi&eo)|0,l:Number(e&eo)|0}}function H1(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=sa(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const M1=(e,t)=>BigInt(e>>>0)<<Mi|BigInt(t>>>0),z1=(e,t,n)=>e>>>n,k1=(e,t,n)=>e<<32-n|t>>>n,Z1=(e,t,n)=>e>>>n|t<<32-n,V1=(e,t,n)=>e<<32-n|t>>>n,G1=(e,t,n)=>e<<64-n|t>>>n-32,K1=(e,t,n)=>e>>>n-32|t<<64-n,Y1=(e,t)=>t,W1=(e,t)=>e,X1=(e,t,n)=>e<<n|t>>>32-n,J1=(e,t,n)=>t<<n|e>>>32-n,Q1=(e,t,n)=>t<<n-32|e>>>64-n,e2=(e,t,n)=>e<<n-32|t>>>64-n;function t2(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const n2=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),r2=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,o2=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),i2=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,s2=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),c2=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,X={fromBig:sa,split:H1,toBig:M1,shrSH:z1,shrSL:k1,rotrSH:Z1,rotrSL:V1,rotrBH:G1,rotrBL:K1,rotr32H:Y1,rotr32L:W1,rotlSH:X1,rotlSL:J1,rotlBH:Q1,rotlBL:e2,add:t2,add3L:n2,add3H:r2,add4L:o2,add4H:i2,add5H:c2,add5L:s2},[f2,a2]=X.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Lt=new Uint32Array(80),qt=new Uint32Array(80);class u2 extends j1{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Lt[D]=t.getUint32(n),qt[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Lt[D-15]|0,C=qt[D-15]|0,P=X.rotrSH(x,C,1)^X.rotrSH(x,C,8)^X.shrSH(x,C,7),q=X.rotrSL(x,C,1)^X.rotrSL(x,C,8)^X.shrSL(x,C,7),L=Lt[D-2]|0,I=qt[D-2]|0,k=X.rotrSH(L,I,19)^X.rotrBH(L,I,61)^X.shrSH(L,I,6),H=X.rotrSL(L,I,19)^X.rotrBL(L,I,61)^X.shrSL(L,I,6),E=X.add4L(q,H,qt[D-7],qt[D-16]),g=X.add4H(E,P,k,Lt[D-7],Lt[D-16]);Lt[D]=g|0,qt[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:R}=this;for(let D=0;D<80;D++){const x=X.rotrSH(h,d,14)^X.rotrSH(h,d,18)^X.rotrBH(h,d,41),C=X.rotrSL(h,d,14)^X.rotrSL(h,d,18)^X.rotrBL(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=X.add5L(R,C,q,a2[D],qt[D]),I=X.add5H(L,_,x,P,f2[D],Lt[D]),k=L|0,H=X.rotrSH(r,o,28)^X.rotrBH(r,o,34)^X.rotrBH(r,o,39),E=X.rotrSL(r,o,28)^X.rotrBL(r,o,34)^X.rotrBL(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,R=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=X.add(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=X.add3L(k,E,y);r=X.add3H(b,I,H,g),o=b|0}({h:r,l:o}=X.add(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=X.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=X.add(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=X.add(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=X.add(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=X.add(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=X.add(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:R}=X.add(this.Hh|0,this.Hl|0,_|0,R|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,R)}roundClean(){Lt.fill(0),qt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const l2=P1(()=>new u2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zi=BigInt(0),ca=BigInt(1),d2=BigInt(2);function ki(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zi(e){if(!ki(e))throw new Error("Uint8Array expected")}function Vi(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}const h2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Gi(e){Zi(e);let t="";for(let n=0;n<e.length;n++)t+=h2[e[n]];return t}function fa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?zi:BigInt("0x"+e)}const mt={_0:48,_9:57,A:65,F:70,a:97,f:102};function aa(e){if(e>=mt._0&&e<=mt._9)return e-mt._0;if(e>=mt.A&&e<=mt.F)return e-(mt.A-10);if(e>=mt.a&&e<=mt.f)return e-(mt.a-10)}function ua(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=aa(e.charCodeAt(i)),c=aa(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function b2(e){return fa(Gi(e))}function to(e){return Zi(e),fa(Gi(Uint8Array.from(e).reverse()))}function la(e,t){return ua(e.toString(16).padStart(t*2,"0"))}function Ki(e,t){return la(e,t).reverse()}function Et(e,t,n){let r;if(typeof t=="string")try{r=ua(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ki(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function da(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Zi(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}const Yi=e=>typeof e=="bigint"&&zi<=e;function g2(e,t,n){return Yi(e)&&Yi(t)&&Yi(n)&&t<=e&&e<n}function fr(e,t,n,r){if(!g2(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function w2(e){let t;for(t=0;e>zi;e>>=ca,t+=1);return t}const p2=e=>(d2<<BigInt(e-1))-ca,y2={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||ki(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Wi(e,t,n={}){const r=(o,i,s)=>{const c=y2[i];if(typeof c!="function")throw new Error("invalid validator function");const f=e[o];if(!(s&&f===void 0)&&!c(f,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+f)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}function ha(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const be=BigInt(0),fe=BigInt(1),hn=BigInt(2),m2=BigInt(3),Xi=BigInt(4),ba=BigInt(5),ga=BigInt(8);function le(e,t){const n=e%t;return n>=be?n:t+n}function E2(e,t,n){if(t<be)throw new Error("invalid exponent, negatives unsupported");if(n<=be)throw new Error("invalid modulus");if(n===fe)return be;let r=fe;for(;t>be;)t&fe&&(r=r*e%n),e=e*e%n,t>>=fe;return r}function rt(e,t,n){let r=e;for(;t-- >be;)r*=r,r%=n;return r}function wa(e,t){if(e===be)throw new Error("invert: expected non-zero number");if(t<=be)throw new Error("invert: expected positive modulus, got "+t);let n=le(e,t),r=t,o=be,i=fe;for(;n!==be;){const s=r/n,c=r%n,f=o-i*s;r=n,n=c,o=i,i=f}if(r!==fe)throw new Error("invert: does not exist");return le(o,t)}function x2(e){const t=(e-fe)/hn;let n,r,o;for(n=e-fe,r=0;n%hn===be;n/=hn,r++);for(o=hn;o<e&&E2(o,t,e)!==e-fe;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const s=(e+fe)/Xi;return function(c,f){const a=c.pow(f,s);if(!c.eql(c.sqr(a),f))throw new Error("Cannot find square root");return a}}const i=(n+fe)/hn;return function(s,c){if(s.pow(c,t)===s.neg(s.ONE))throw new Error("Cannot find square root");let f=r,a=s.pow(s.mul(s.ONE,o),n),l=s.pow(c,i),h=s.pow(c,n);for(;!s.eql(h,s.ONE);){if(s.eql(h,s.ZERO))return s.ZERO;let d=1;for(let p=s.sqr(h);d<f&&!s.eql(p,s.ONE);d++)p=s.sqr(p);const u=s.pow(a,fe<<BigInt(f-d-1));a=s.sqr(u),l=s.mul(l,u),h=s.mul(h,a),f=d}return l}}function v2(e){if(e%Xi===m2){const t=(e+fe)/Xi;return function(n,r){const o=n.pow(r,t);if(!n.eql(n.sqr(o),r))throw new Error("Cannot find square root");return o}}if(e%ga===ba){const t=(e-ba)/ga;return function(n,r){const o=n.mul(r,hn),i=n.pow(o,t),s=n.mul(r,i),c=n.mul(n.mul(s,hn),i),f=n.mul(s,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),r))throw new Error("Cannot find square root");return f}}return x2(e)}const B2=(e,t)=>(le(e,t)&fe)===fe,D2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function A2(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=D2.reduce((r,o)=>(r[o]="function",r),t);return Wi(e,n)}function O2(e,t,n){if(n<be)throw new Error("invalid exponent, negatives unsupported");if(n===be)return e.ONE;if(n===fe)return t;let r=e.ONE,o=t;for(;n>be;)n&fe&&(r=e.mul(r,o)),o=e.sqr(o),n>>=fe;return r}function S2(e,t){const n=new Array(t.length),r=t.reduce((i,s,c)=>e.is0(s)?i:(n[c]=i,e.mul(i,s)),e.ONE),o=e.inv(r);return t.reduceRight((i,s,c)=>e.is0(s)?i:(n[c]=e.mul(i,n[c]),e.mul(i,s)),o),n}function pa(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ya(e,t,n=!1,r={}){if(e<=be)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:i}=pa(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const c=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:i,MASK:p2(o),ZERO:be,ONE:fe,create:f=>le(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return be<=f&&f<e},is0:f=>f===be,isOdd:f=>(f&fe)===fe,neg:f=>le(-f,e),eql:(f,a)=>f===a,sqr:f=>le(f*f,e),add:(f,a)=>le(f+a,e),sub:(f,a)=>le(f-a,e),mul:(f,a)=>le(f*a,e),pow:(f,a)=>O2(c,f,a),div:(f,a)=>le(f*wa(a,e),e),sqrN:f=>f*f,addN:(f,a)=>f+a,subN:(f,a)=>f-a,mulN:(f,a)=>f*a,inv:f=>wa(f,e),sqrt:r.sqrt||(f=>(s||(s=v2(e)),s(c,f))),invertBatch:f=>S2(c,f),cmov:(f,a,l)=>l?a:f,toBytes:f=>n?Ki(f,i):la(f,i),fromBytes:f=>{if(f.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+f.length);return n?to(f):b2(f)}});return Object.freeze(c)}const ma=BigInt(0),no=BigInt(1);function Ji(e,t){const n=t.negate();return e?n:t}function Ea(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Qi(e,t){Ea(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1);return{windows:n,windowSize:r}}function _2(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function I2(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const es=new WeakMap,xa=new WeakMap;function ts(e){return xa.get(e)||1}function N2(e,t){return{constTimeNegate:Ji,hasPrecomputes(n){return ts(n)!==1},unsafeLadder(n,r,o=e.ZERO){let i=n;for(;r>ma;)r&no&&(o=o.add(i)),i=i.double(),r>>=no;return o},precomputeWindow(n,r){const{windows:o,windowSize:i}=Qi(r,t),s=[];let c=n,f=c;for(let a=0;a<o;a++){f=c,s.push(f);for(let l=1;l<i;l++)f=f.add(c),s.push(f);c=f.double()}return s},wNAF(n,r,o){const{windows:i,windowSize:s}=Qi(n,t);let c=e.ZERO,f=e.BASE;const a=BigInt(2**n-1),l=2**n,h=BigInt(n);for(let d=0;d<i;d++){const u=d*s;let p=Number(o&a);o>>=h,p>s&&(p-=l,o+=no);const m=u,v=u+Math.abs(p)-1,_=d%2!==0,R=p<0;p===0?f=f.add(Ji(_,r[m])):c=c.add(Ji(R,r[v]))}return{p:c,f}},wNAFUnsafe(n,r,o,i=e.ZERO){const{windows:s,windowSize:c}=Qi(n,t),f=BigInt(2**n-1),a=2**n,l=BigInt(n);for(let h=0;h<s;h++){const d=h*c;if(o===ma)break;let u=Number(o&f);if(o>>=l,u>c&&(u-=a,o+=no),u===0)continue;let p=r[d+Math.abs(u)-1];u<0&&(p=p.negate()),i=i.add(p)}return i},getPrecomputes(n,r,o){let i=es.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&es.set(r,o(i))),i},wNAFCached(n,r,o){const i=ts(n);return this.wNAF(i,this.getPrecomputes(i,n,o),r)},wNAFCachedUnsafe(n,r,o,i){const s=ts(n);return s===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,n,o),r,i)},setWindowSize(n,r){Ea(r,t),xa.set(n,r),es.delete(n)}}}function F2(e,t,n,r){if(_2(n,e),I2(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,i=w2(BigInt(n.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,f=new Array(c+1).fill(o),a=Math.floor((t.BITS-1)/s)*s;let l=o;for(let h=a;h>=0;h-=s){f.fill(o);for(let u=0;u<r.length;u++){const p=r[u],m=Number(p>>BigInt(h)&BigInt(c));f[m]=f[m].add(n[u])}let d=o;for(let u=f.length-1,p=o;u>0;u--)p=p.add(f[u]),d=d.add(p);if(l=l.add(d),h!==0)for(let u=0;u<s;u++)l=l.double()}return l}function C2(e){return A2(e.Fp),Wi(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...pa(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const We=BigInt(0),Te=BigInt(1),ro=BigInt(2),U2=BigInt(8),$2={zip215:!0};function R2(e){const t=C2(e);return Wi(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function T2(e){const t=R2(e),{Fp:n,n:r,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:f}=t,a=ro<<BigInt(c*8)-Te,l=n.create,h=ya(t.n,t.nBitLength),d=t.uvRatio||((b,w)=>{try{return{isValid:!0,value:n.sqrt(b*n.inv(w))}}catch{return{isValid:!1,value:We}}}),u=t.adjustScalarBytes||(b=>b),p=t.domain||((b,w,B)=>{if(Vi("phflag",B),w.length||B)throw new Error("Contexts/pre-hash are not supported");return b});function m(b,w){fr("coordinate "+b,w,We,a)}function v(b){if(!(b instanceof D))throw new Error("ExtendedPoint expected")}const _=ha((b,w)=>{const{ex:B,ey:A,ez:O}=b,S=b.is0();w==null&&(w=S?U2:n.inv(O));const N=l(B*w),$=l(A*w),U=l(O*w);if(S)return{x:We,y:Te};if(U!==Te)throw new Error("invZ was invalid");return{x:N,y:$}}),R=ha(b=>{const{a:w,d:B}=t;if(b.is0())throw new Error("bad point: ZERO");const{ex:A,ey:O,ez:S,et:N}=b,$=l(A*A),U=l(O*O),T=l(S*S),F=l(T*T),j=l($*w),M=l(T*l(j+U)),V=l(F+l(B*l($*U)));if(M!==V)throw new Error("bad point: equation left != right (1)");const z=l(A*O),Z=l(S*N);if(z!==Z)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(w,B,A,O){this.ex=w,this.ey=B,this.ez=A,this.et=O,m("x",w),m("y",B),m("z",A),m("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof D)throw new Error("extended point not allowed");const{x:B,y:A}=w||{};return m("x",B),m("y",A),new D(B,A,Te,l(B*A))}static normalizeZ(w){const B=n.invertBatch(w.map(A=>A.ez));return w.map((A,O)=>A.toAffine(B[O])).map(D.fromAffine)}static msm(w,B){return F2(D,h,w,B)}_setWindowSize(w){P.setWindowSize(this,w)}assertValidity(){R(this)}equals(w){v(w);const{ex:B,ey:A,ez:O}=this,{ex:S,ey:N,ez:$}=w,U=l(B*$),T=l(S*O),F=l(A*$),j=l(N*O);return U===T&&F===j}is0(){return this.equals(D.ZERO)}negate(){return new D(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:w}=t,{ex:B,ey:A,ez:O}=this,S=l(B*B),N=l(A*A),$=l(ro*l(O*O)),U=l(w*S),T=B+A,F=l(l(T*T)-S-N),j=U+N,M=j-$,V=U-N,z=l(F*M),Z=l(j*V),W=l(F*V),J=l(M*j);return new D(z,Z,J,W)}add(w){v(w);const{a:B,d:A}=t,{ex:O,ey:S,ez:N,et:$}=this,{ex:U,ey:T,ez:F,et:j}=w;if(B===BigInt(-1)){const wl=l((S-O)*(T+U)),pl=l((S+O)*(T-U)),Rs=l(pl-wl);if(Rs===We)return this.double();const yl=l(N*ro*j),ml=l($*ro*F),El=ml+yl,xl=pl+wl,vl=ml-yl,kp=l(El*Rs),Zp=l(xl*vl),Vp=l(El*vl),Gp=l(Rs*xl);return new D(kp,Zp,Gp,Vp)}const M=l(O*U),V=l(S*T),z=l($*A*j),Z=l(N*F),W=l((O+S)*(U+T)-M-V),J=Z-z,ee=Z+z,oe=l(V-B*M),se=l(W*J),Ot=l(ee*oe),Ao=l(W*oe),zp=l(J*ee);return new D(se,Ot,zp,Ao)}subtract(w){return this.add(w.negate())}wNAF(w){return P.wNAFCached(this,w,D.normalizeZ)}multiply(w){const B=w;fr("scalar",B,Te,r);const{p:A,f:O}=this.wNAF(B);return D.normalizeZ([A,O])[0]}multiplyUnsafe(w,B=D.ZERO){const A=w;return fr("scalar",A,We,r),A===We?C:this.is0()||A===Te?this:P.wNAFCachedUnsafe(this,A,D.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return P.unsafeLadder(this,r).is0()}toAffine(w){return _(this,w)}clearCofactor(){const{h:w}=t;return w===Te?this:this.multiplyUnsafe(w)}static fromHex(w,B=!1){const{d:A,a:O}=t,S=n.BYTES;w=Et("pointHex",w,S),Vi("zip215",B);const N=w.slice(),$=w[S-1];N[S-1]=$&-129;const U=to(N),T=B?a:n.ORDER;fr("pointHex.y",U,We,T);const F=l(U*U),j=l(F-Te),M=l(A*F-O);let{isValid:V,value:z}=d(j,M);if(!V)throw new Error("Point.fromHex: invalid y coordinate");const Z=(z&Te)===Te,W=($&128)!==0;if(!B&&z===We&&W)throw new Error("Point.fromHex: x=0 and x_0=1");return W!==Z&&(z=l(-z)),D.fromAffine({x:z,y:U})}static fromPrivateKey(w){return I(w).point}toRawBytes(){const{x:w,y:B}=this.toAffine(),A=Ki(B,n.BYTES);return A[A.length-1]|=w&Te?128:0,A}toHex(){return Gi(this.toRawBytes())}}D.BASE=new D(t.Gx,t.Gy,Te,l(t.Gx*t.Gy)),D.ZERO=new D(We,Te,Te,We);const{BASE:x,ZERO:C}=D,P=N2(D,c*8);function q(b){return le(b,r)}function L(b){return q(to(b))}function I(b){const w=n.BYTES;b=Et("private key",b,w);const B=Et("hashed private key",i(b),2*w),A=u(B.slice(0,w)),O=B.slice(w,2*w),S=L(A),N=x.multiply(S),$=N.toRawBytes();return{head:A,prefix:O,scalar:S,point:N,pointBytes:$}}function k(b){return I(b).pointBytes}function H(b=new Uint8Array,...w){const B=da(...w);return L(i(p(B,Et("context",b),!!o)))}function E(b,w,B={}){b=Et("message",b),o&&(b=o(b));const{prefix:A,scalar:O,pointBytes:S}=I(w),N=H(B.context,A,b),$=x.multiply(N).toRawBytes(),U=H(B.context,$,S,b),T=q(N+U*O);fr("signature.s",T,We,r);const F=da($,Ki(T,n.BYTES));return Et("result",F,n.BYTES*2)}const g=$2;function y(b,w,B,A=g){const{context:O,zip215:S}=A,N=n.BYTES;b=Et("signature",b,2*N),w=Et("message",w),B=Et("publicKey",B,N),S!==void 0&&Vi("zip215",S),o&&(w=o(w));const $=to(b.slice(N,2*N));let U,T,F;try{U=D.fromHex(B,S),T=D.fromHex(b.slice(0,N),S),F=x.multiplyUnsafe($)}catch{return!1}if(!S&&U.isSmallOrder())return!1;const j=H(O,T.toRawBytes(),U.toRawBytes(),w);return T.add(U.multiplyUnsafe(j)).subtract(F).clearCofactor().equals(D.ZERO)}return x._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:E,verify:y,ExtendedPoint:D,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(n.BYTES),precompute(b=8,w=D.BASE){return w._setWindowSize(b),w.multiply(BigInt(3)),w}}}}BigInt(0),BigInt(1);const ns=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),va=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const P2=BigInt(1),Ba=BigInt(2);BigInt(3);const L2=BigInt(5),q2=BigInt(8);function j2(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=ns,s=e*e%i*e%i,c=rt(s,Ba,i)*s%i,f=rt(c,P2,i)*e%i,a=rt(f,L2,i)*f%i,l=rt(a,t,i)*a%i,h=rt(l,n,i)*l%i,d=rt(h,r,i)*h%i,u=rt(d,o,i)*d%i,p=rt(u,o,i)*d%i,m=rt(p,t,i)*a%i;return{pow_p_5_8:rt(m,Ba,i)*e%i,b2:s}}function H2(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function M2(e,t){const n=ns,r=le(t*t*t,n),o=le(r*r*t,n),i=j2(e*o).pow_p_5_8;let s=le(e*r*i,n);const c=le(t*s*s,n),f=s,a=le(s*va,n),l=c===e,h=c===le(-e,n),d=c===le(-e*va,n);return l&&(s=f),(h||d)&&(s=a),B2(s,n)&&(s=le(-s,n)),{isValid:l||h,value:s}}const z2=ya(ns,void 0,!0),k2={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:z2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:q2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:l2,randomBytes:L1,adjustScalarBytes:H2,uvRatio:M2};T2(k2);function Z2(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(n[s]!==255)throw new TypeError(i+" is ambiguous");n[s]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,v=0,_=0,R=p.length;_!==R&&p[_]===0;)_++,m++;for(var D=(R-_)*l+1>>>0,x=new Uint8Array(D);_!==R;){for(var C=p[_],P=0,q=D-1;(C!==0||P<v)&&q!==-1;q--,P++)C+=256*x[q]>>>0,x[q]=C%c>>>0,C=C/c>>>0;if(C!==0)throw new Error("Non-zero carry");v=P,_++}for(var L=D-v;L!==D&&x[L]===0;)L++;for(var I=f.repeat(m);L<D;++L)I+=e.charAt(x[L]);return I}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var v=0,_=0;p[m]===f;)v++,m++;for(var R=(p.length-m)*a+1>>>0,D=new Uint8Array(R);p[m];){var x=n[p.charCodeAt(m)];if(x===255)return;for(var C=0,P=R-1;(x!==0||C<_)&&P!==-1;P--,C++)x+=c*D[P]>>>0,D[P]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");_=C,m++}if(p[m]!==" "){for(var q=R-_;q!==R&&D[q]===0;)q++;for(var L=new Uint8Array(v+(R-q)),I=v;q!==R;)L[I++]=D[q++];return L}}}function u(p){var m=d(p);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:d,decode:u}}var V2=Z2,G2=V2;const Da=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},K2=e=>new TextEncoder().encode(e),Y2=e=>new TextDecoder().decode(e);class W2{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class X2{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Aa(this,t)}}class J2{constructor(t){this.decoders=t}or(t){return Aa(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Aa=(e,t)=>new J2({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Q2{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new W2(t,n,r),this.decoder=new X2(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const oo=({name:e,prefix:t,encode:n,decode:r})=>new Q2(e,t,n,r),ar=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=G2(n,t);return oo({prefix:e,name:t,encode:r,decode:i=>Da(o(i))})},eb=(e,t,n,r)=>{const o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;const s=new Uint8Array(i*n/8|0);let c=0,f=0,a=0;for(let l=0;l<i;++l){const h=o[e[l]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);f=f<<n|h,c+=n,c>=8&&(c-=8,s[a++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return s},tb=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let i="",s=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],s+=8;s>n;)s-=n,i+=t[o&c>>s];if(s&&(i+=t[o&c<<n-s]),r)for(;i.length*n&7;)i+="=";return i},ge=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>oo({prefix:t,name:e,encode(o){return tb(o,r,n)},decode(o){return eb(o,r,n,e)}}),nb=oo({prefix:"\0",name:"identity",encode:e=>Y2(e),decode:e=>K2(e)});var rb=Object.freeze({__proto__:null,identity:nb});const ob=ge({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ib=Object.freeze({__proto__:null,base2:ob});const sb=ge({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cb=Object.freeze({__proto__:null,base8:sb});const fb=ar({prefix:"9",name:"base10",alphabet:"0123456789"});var ab=Object.freeze({__proto__:null,base10:fb});const ub=ge({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lb=ge({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var db=Object.freeze({__proto__:null,base16:ub,base16upper:lb});const hb=ge({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bb=ge({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gb=ge({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wb=ge({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pb=ge({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yb=ge({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mb=ge({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Eb=ge({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xb=ge({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vb=Object.freeze({__proto__:null,base32:hb,base32upper:bb,base32pad:gb,base32padupper:wb,base32hex:pb,base32hexupper:yb,base32hexpad:mb,base32hexpadupper:Eb,base32z:xb});const Bb=ar({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Db=ar({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ab=Object.freeze({__proto__:null,base36:Bb,base36upper:Db});const Ob=ar({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sb=ar({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _b=Object.freeze({__proto__:null,base58btc:Ob,base58flickr:Sb});const Ib=ge({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nb=ge({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fb=ge({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cb=ge({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ub=Object.freeze({__proto__:null,base64:Ib,base64pad:Nb,base64url:Fb,base64urlpad:Cb});const Oa=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$b=Oa.reduce((e,t,n)=>(e[n]=t,e),[]),Rb=Oa.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function Tb(e){return e.reduce((t,n)=>(t+=$b[n],t),"")}function Pb(e){const t=[];for(const n of e){const r=Rb[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const Lb=oo({prefix:"\u{1F680}",name:"base256emoji",encode:Tb,decode:Pb});var qb=Object.freeze({__proto__:null,base256emoji:Lb}),jb=_a,Sa=128,Hb=127,Mb=~Hb,zb=Math.pow(2,31);function _a(e,t,n){t=t||[],n=n||0;for(var r=n;e>=zb;)t[n++]=e&255|Sa,e/=128;for(;e&Mb;)t[n++]=e&255|Sa,e>>>=7;return t[n]=e|0,_a.bytes=n-r+1,t}var kb=rs,Zb=128,Ia=127;function rs(e,r){var n=0,r=r||0,o=0,i=r,s,c=e.length;do{if(i>=c)throw rs.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Ia)<<o:(s&Ia)*Math.pow(2,o),o+=7}while(s>=Zb);return rs.bytes=i-r,n}var Vb=Math.pow(2,7),Gb=Math.pow(2,14),Kb=Math.pow(2,21),Yb=Math.pow(2,28),Wb=Math.pow(2,35),Xb=Math.pow(2,42),Jb=Math.pow(2,49),Qb=Math.pow(2,56),eg=Math.pow(2,63),tg=function(e){return e<Vb?1:e<Gb?2:e<Kb?3:e<Yb?4:e<Wb?5:e<Xb?6:e<Jb?7:e<Qb?8:e<eg?9:10},ng={encode:jb,decode:kb,encodingLength:tg},Na=ng;const Fa=(e,t,n=0)=>(Na.encode(e,t,n),t),Ca=e=>Na.encodingLength(e),os=(e,t)=>{const n=t.byteLength,r=Ca(e),o=r+Ca(n),i=new Uint8Array(o+n);return Fa(e,i,0),Fa(n,i,r),i.set(t,o),new rg(e,n,t,i)};class rg{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const Ua=({name:e,code:t,encode:n})=>new og(e,t,n);class og{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?os(this.code,n):n.then(r=>os(this.code,r))}else throw Error("Unknown type, must be binary type")}}const $a=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ig=Ua({name:"sha2-256",code:18,encode:$a("SHA-256")}),sg=Ua({name:"sha2-512",code:19,encode:$a("SHA-512")});var cg=Object.freeze({__proto__:null,sha256:ig,sha512:sg});const Ra=0,fg="identity",Ta=Da;var ag=Object.freeze({__proto__:null,identity:{code:Ra,name:fg,encode:Ta,digest:e=>os(Ra,Ta(e))}});new TextEncoder,new TextDecoder,{...rb,...ib,...cb,...ab,...db,...vb,...Ab,..._b,...Ub,...qb},{...cg,...ag};function ug(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(n[s]!==255)throw new TypeError(i+" is ambiguous");n[s]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,v=0,_=0,R=p.length;_!==R&&p[_]===0;)_++,m++;for(var D=(R-_)*l+1>>>0,x=new Uint8Array(D);_!==R;){for(var C=p[_],P=0,q=D-1;(C!==0||P<v)&&q!==-1;q--,P++)C+=256*x[q]>>>0,x[q]=C%c>>>0,C=C/c>>>0;if(C!==0)throw new Error("Non-zero carry");v=P,_++}for(var L=D-v;L!==D&&x[L]===0;)L++;for(var I=f.repeat(m);L<D;++L)I+=e.charAt(x[L]);return I}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var v=0,_=0;p[m]===f;)v++,m++;for(var R=(p.length-m)*a+1>>>0,D=new Uint8Array(R);p[m];){var x=n[p.charCodeAt(m)];if(x===255)return;for(var C=0,P=R-1;(x!==0||C<_)&&P!==-1;P--,C++)x+=c*D[P]>>>0,D[P]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");_=C,m++}if(p[m]!==" "){for(var q=R-_;q!==R&&D[q]===0;)q++;for(var L=new Uint8Array(v+(R-q)),I=v;q!==R;)L[I++]=D[q++];return L}}}function u(p){var m=d(p);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:d,decode:u}}var lg=ug,dg=lg;const Pa=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},hg=e=>new TextEncoder().encode(e),bg=e=>new TextDecoder().decode(e);class gg{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class wg{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return La(this,t)}}class pg{constructor(t){this.decoders=t}or(t){return La(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const La=(e,t)=>new pg({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class yg{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new gg(t,n,r),this.decoder=new wg(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const io=({name:e,prefix:t,encode:n,decode:r})=>new yg(e,t,n,r),ur=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=dg(n,t);return io({prefix:e,name:t,encode:r,decode:i=>Pa(o(i))})},mg=(e,t,n,r)=>{const o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;const s=new Uint8Array(i*n/8|0);let c=0,f=0,a=0;for(let l=0;l<i;++l){const h=o[e[l]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);f=f<<n|h,c+=n,c>=8&&(c-=8,s[a++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return s},Eg=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let i="",s=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],s+=8;s>n;)s-=n,i+=t[o&c>>s];if(s&&(i+=t[o&c<<n-s]),r)for(;i.length*n&7;)i+="=";return i},we=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>io({prefix:t,name:e,encode(o){return Eg(o,r,n)},decode(o){return mg(o,r,n,e)}}),xg=io({prefix:"\0",name:"identity",encode:e=>bg(e),decode:e=>hg(e)});var vg=Object.freeze({__proto__:null,identity:xg});const Bg=we({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dg=Object.freeze({__proto__:null,base2:Bg});const Ag=we({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Og=Object.freeze({__proto__:null,base8:Ag});const Sg=ur({prefix:"9",name:"base10",alphabet:"0123456789"});var _g=Object.freeze({__proto__:null,base10:Sg});const Ig=we({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ng=we({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fg=Object.freeze({__proto__:null,base16:Ig,base16upper:Ng});const Cg=we({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ug=we({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$g=we({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Rg=we({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Tg=we({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pg=we({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lg=we({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),qg=we({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jg=we({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hg=Object.freeze({__proto__:null,base32:Cg,base32upper:Ug,base32pad:$g,base32padupper:Rg,base32hex:Tg,base32hexupper:Pg,base32hexpad:Lg,base32hexpadupper:qg,base32z:jg});const Mg=ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zg=ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var kg=Object.freeze({__proto__:null,base36:Mg,base36upper:zg});const Zg=ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vg=ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gg=Object.freeze({__proto__:null,base58btc:Zg,base58flickr:Vg});const Kg=we({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yg=we({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wg=we({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xg=we({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jg=Object.freeze({__proto__:null,base64:Kg,base64pad:Yg,base64url:Wg,base64urlpad:Xg});const qa=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Qg=qa.reduce((e,t,n)=>(e[n]=t,e),[]),e3=qa.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function t3(e){return e.reduce((t,n)=>(t+=Qg[n],t),"")}function n3(e){const t=[];for(const n of e){const r=e3[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const r3=io({prefix:"\u{1F680}",name:"base256emoji",encode:t3,decode:n3});var o3=Object.freeze({__proto__:null,base256emoji:r3}),i3=Ha,ja=128,s3=127,c3=~s3,f3=Math.pow(2,31);function Ha(e,t,n){t=t||[],n=n||0;for(var r=n;e>=f3;)t[n++]=e&255|ja,e/=128;for(;e&c3;)t[n++]=e&255|ja,e>>>=7;return t[n]=e|0,Ha.bytes=n-r+1,t}var a3=is,u3=128,Ma=127;function is(e,r){var n=0,r=r||0,o=0,i=r,s,c=e.length;do{if(i>=c)throw is.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Ma)<<o:(s&Ma)*Math.pow(2,o),o+=7}while(s>=u3);return is.bytes=i-r,n}var l3=Math.pow(2,7),d3=Math.pow(2,14),h3=Math.pow(2,21),b3=Math.pow(2,28),g3=Math.pow(2,35),w3=Math.pow(2,42),p3=Math.pow(2,49),y3=Math.pow(2,56),m3=Math.pow(2,63),E3=function(e){return e<l3?1:e<d3?2:e<h3?3:e<b3?4:e<g3?5:e<w3?6:e<p3?7:e<y3?8:e<m3?9:10},x3={encode:i3,decode:a3,encodingLength:E3},za=x3;const ka=(e,t,n=0)=>(za.encode(e,t,n),t),Za=e=>za.encodingLength(e),ss=(e,t)=>{const n=t.byteLength,r=Za(e),o=r+Za(n),i=new Uint8Array(o+n);return ka(e,i,0),ka(n,i,r),i.set(t,o),new v3(e,n,t,i)};class v3{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const Va=({name:e,code:t,encode:n})=>new B3(e,t,n);class B3{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?ss(this.code,n):n.then(r=>ss(this.code,r))}else throw Error("Unknown type, must be binary type")}}const Ga=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),D3=Va({name:"sha2-256",code:18,encode:Ga("SHA-256")}),A3=Va({name:"sha2-512",code:19,encode:Ga("SHA-512")});var O3=Object.freeze({__proto__:null,sha256:D3,sha512:A3});const Ka=0,S3="identity",Ya=Pa;var _3=Object.freeze({__proto__:null,identity:{code:Ka,name:S3,encode:Ya,digest:e=>ss(Ka,Ya(e))}});new TextEncoder,new TextDecoder,{...vg,...Dg,...Og,..._g,...Fg,...Hg,...kg,...Gg,...Jg,...o3},{...O3,..._3};var I3=Object.defineProperty,N3=Object.defineProperties,F3=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertySymbols,C3=Object.prototype.hasOwnProperty,U3=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?I3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tn=(e,t)=>{for(var n in t||(t={}))C3.call(t,n)&&Xa(e,n,t[n]);if(Wa)for(var n of Wa(t))U3.call(t,n)&&Xa(e,n,t[n]);return e},lr=(e,t)=>N3(e,F3(t));const $3="ReactNative";function Ja(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function cs(){return!Lo()&&!!qo()&&navigator.product===$3}function R3(){return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function T3(){return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function P3(){return!Ja()&&!!qo()&&!!Lo()}function L3(){var e;try{return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(e=global.Application)==null?void 0:e.applicationId:void 0}catch{return}}const so=BigInt(2**32-1),Qa=BigInt(32);function eu(e,t=!1){return t?{h:Number(e&so),l:Number(e>>Qa&so)}:{h:Number(e>>Qa&so)|0,l:Number(e&so)|0}}function tu(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:s,l:c}=eu(e[i],t);[r[i],o[i]]=[s,c]}return[r,o]}const nu=(e,t,n)=>e>>>n,ru=(e,t,n)=>e<<32-n|t>>>n,jt=(e,t,n)=>e>>>n|t<<32-n,Ht=(e,t,n)=>e<<32-n|t>>>n,dr=(e,t,n)=>e<<64-n|t>>>n-32,hr=(e,t,n)=>e>>>n-32|t<<64-n,q3=(e,t)=>t,j3=(e,t)=>e,H3=(e,t,n)=>e<<n|t>>>32-n,M3=(e,t,n)=>t<<n|e>>>32-n,z3=(e,t,n)=>t<<n-32|e>>>64-n,k3=(e,t,n)=>e<<n-32|t>>>64-n;function Xe(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const fs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),as=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Z3=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),V3=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,G3=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),K3=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,Pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function co(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Je(e,...t){if(!co(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ou(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Mt(e.outputLen),Mt(e.blockLen)}function zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function us(e,t){Je(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function br(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Qe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ls(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ot(e,t){return e<<32-t|e>>>t}const iu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function su(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const xt=iu?e=>e:e=>su(e);function Y3(e){for(let t=0;t<e.length;t++)e[t]=su(e[t]);return e}const kt=iu?e=>e:Y3,cu=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",W3=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ln(e){if(Je(e),cu)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=W3[e[n]];return t}const vt={_0:48,_9:57,A:65,F:70,a:97,f:102};function fu(e){if(e>=vt._0&&e<=vt._9)return e-vt._0;if(e>=vt.A&&e<=vt.F)return e-(vt.A-10);if(e>=vt.a&&e<=vt.f)return e-(vt.a-10)}function fo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(cu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=fu(e.charCodeAt(i)),c=fu(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function au(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Bt(e){return typeof e=="string"&&(e=au(e)),Je(e),e}function Zt(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Je(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}class ao{}function gr(e){const t=r=>e().update(Bt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function X3(e){const t=(r,o)=>e(o).update(Bt(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function ds(e=32){if(Pn&&typeof Pn.getRandomValues=="function")return Pn.getRandomValues(new Uint8Array(e));if(Pn&&typeof Pn.randomBytes=="function")return Uint8Array.from(Pn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const J3=BigInt(0),wr=BigInt(1),Q3=BigInt(2),ew=BigInt(7),tw=BigInt(256),nw=BigInt(113),uu=[],lu=[],du=[];for(let e=0,t=wr,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],uu.push(2*(5*r+n)),lu.push((e+1)*(e+2)/2%64);let o=J3;for(let i=0;i<7;i++)t=(t<<wr^(t>>ew)*nw)%tw,t&Q3&&(o^=wr<<(wr<<BigInt(i))-wr);du.push(o)}const hu=tu(du,!0),rw=hu[0],ow=hu[1],bu=(e,t,n)=>n>32?z3(e,t,n):H3(e,t,n),gu=(e,t,n)=>n>32?k3(e,t,n):M3(e,t,n);function iw(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,f=(s+2)%10,a=n[f],l=n[f+1],h=bu(a,l,1)^n[c],d=gu(a,l,1)^n[c+1];for(let u=0;u<50;u+=10)e[s+u]^=h,e[s+u+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=lu[s],f=bu(o,i,c),a=gu(o,i,c),l=uu[s];o=e[l],i=e[l+1],e[l]=f,e[l+1]=a}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=rw[r],e[1]^=ow[r]}Qe(n)}class hs extends ao{constructor(t,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Mt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=br(this.state)}clone(){return this._cloneInto()}keccak(){kt(this.state32),iw(this.state32,this.rounds),kt(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=Bt(t),Je(t);const{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let c=0;c<s;c++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){zt(this,!1),Je(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(us(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Qe(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new hs(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}((e,t,n)=>gr(()=>new hs(t,e,n)))(1,136,256/8);function sw(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function cw(e,t,n){return e&t^~e&n}function fw(e,t,n){return e&t^e&n^t&n}class wu extends ao{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ls(this.buffer)}update(t){zt(this),t=Bt(t),Je(t);const{view:n,buffer:r,blockLen:o}=this,i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=ls(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){zt(this),us(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,Qe(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;sw(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=ls(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const Vt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xe=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ve=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),aw=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array(64);class uw extends wu{constructor(t=32){super(64,t,8,!1),this.A=Vt[0]|0,this.B=Vt[1]|0,this.C=Vt[2]|0,this.D=Vt[3]|0,this.E=Vt[4]|0,this.F=Vt[5]|0,this.G=Vt[6]|0,this.H=Vt[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:f}=this;return[t,n,r,o,i,s,c,f]}set(t,n,r,o,i,s,c,f){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,n){for(let h=0;h<16;h++,n+=4)Gt[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const d=Gt[h-15],u=Gt[h-2],p=ot(d,7)^ot(d,18)^d>>>3,m=ot(u,17)^ot(u,19)^u>>>10;Gt[h]=m+Gt[h-7]+p+Gt[h-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:f,G:a,H:l}=this;for(let h=0;h<64;h++){const d=ot(c,6)^ot(c,11)^ot(c,25),u=l+d+cw(c,f,a)+aw[h]+Gt[h]|0,p=(ot(r,2)^ot(r,13)^ot(r,22))+fw(r,o,i)|0;l=a,a=f,f=c,c=s+u|0,s=i,i=o,o=r,r=u+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,l=l+this.H|0,this.set(r,o,i,s,c,f,a,l)}roundClean(){Qe(Gt)}destroy(){this.set(0,0,0,0,0,0,0,0),Qe(this.buffer)}}const pu=tu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),lw=pu[0],dw=pu[1],Kt=new Uint32Array(80),Yt=new Uint32Array(80);class bs extends wu{constructor(t=64){super(128,t,16,!1),this.Ah=ve[0]|0,this.Al=ve[1]|0,this.Bh=ve[2]|0,this.Bl=ve[3]|0,this.Ch=ve[4]|0,this.Cl=ve[5]|0,this.Dh=ve[6]|0,this.Dl=ve[7]|0,this.Eh=ve[8]|0,this.El=ve[9]|0,this.Fh=ve[10]|0,this.Fl=ve[11]|0,this.Gh=ve[12]|0,this.Gl=ve[13]|0,this.Hh=ve[14]|0,this.Hl=ve[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Kt[D]=t.getUint32(n),Yt[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Kt[D-15]|0,C=Yt[D-15]|0,P=jt(x,C,1)^jt(x,C,8)^nu(x,C,7),q=Ht(x,C,1)^Ht(x,C,8)^ru(x,C,7),L=Kt[D-2]|0,I=Yt[D-2]|0,k=jt(L,I,19)^dr(L,I,61)^nu(L,I,6),H=Ht(L,I,19)^hr(L,I,61)^ru(L,I,6),E=Z3(q,H,Yt[D-7],Yt[D-16]),g=V3(E,P,k,Kt[D-7],Kt[D-16]);Kt[D]=g|0,Yt[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:R}=this;for(let D=0;D<80;D++){const x=jt(h,d,14)^jt(h,d,18)^dr(h,d,41),C=Ht(h,d,14)^Ht(h,d,18)^hr(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=G3(R,C,q,dw[D],Yt[D]),I=K3(L,_,x,P,lw[D],Kt[D]),k=L|0,H=jt(r,o,28)^dr(r,o,34)^dr(r,o,39),E=Ht(r,o,28)^hr(r,o,34)^hr(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,R=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=Xe(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=fs(k,E,y);r=as(b,I,H,g),o=b|0}({h:r,l:o}=Xe(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=Xe(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=Xe(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=Xe(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=Xe(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=Xe(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=Xe(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:R}=Xe(this.Hh|0,this.Hl|0,_|0,R|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,R)}roundClean(){Qe(Kt,Yt)}destroy(){Qe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class hw extends bs{constructor(){super(48),this.Ah=xe[0]|0,this.Al=xe[1]|0,this.Bh=xe[2]|0,this.Bl=xe[3]|0,this.Ch=xe[4]|0,this.Cl=xe[5]|0,this.Dh=xe[6]|0,this.Dl=xe[7]|0,this.Eh=xe[8]|0,this.El=xe[9]|0,this.Fh=xe[10]|0,this.Fl=xe[11]|0,this.Gh=xe[12]|0,this.Gl=xe[13]|0,this.Hh=xe[14]|0,this.Hl=xe[15]|0}}const Be=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class bw extends bs{constructor(){super(32),this.Ah=Be[0]|0,this.Al=Be[1]|0,this.Bh=Be[2]|0,this.Bl=Be[3]|0,this.Ch=Be[4]|0,this.Cl=Be[5]|0,this.Dh=Be[6]|0,this.Dl=Be[7]|0,this.Eh=Be[8]|0,this.El=Be[9]|0,this.Fh=Be[10]|0,this.Fl=Be[11]|0,this.Gh=Be[12]|0,this.Gl=Be[13]|0,this.Hh=Be[14]|0,this.Hl=Be[15]|0}}const gw=gr(()=>new uw),ww=gr(()=>new bs),pw=gr(()=>new hw);gr(()=>new bw);const yw=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),de=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),G=new Uint32Array(32);function Wt(e,t,n,r,o,i){const s=o[i],c=o[i+1];let f=G[2*e],a=G[2*e+1],l=G[2*t],h=G[2*t+1],d=G[2*n],u=G[2*n+1],p=G[2*r],m=G[2*r+1],v=fs(f,l,s);a=as(v,a,h,c),f=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^f},{Dh:m,Dl:p}={Dh:q3(m,p),Dl:j3(m)},{h:u,l:d}=Xe(u,d,m,p),{Bh:h,Bl:l}={Bh:h^u,Bl:l^d},{Bh:h,Bl:l}={Bh:jt(h,l,24),Bl:Ht(h,l,24)},G[2*e]=f,G[2*e+1]=a,G[2*t]=l,G[2*t+1]=h,G[2*n]=d,G[2*n+1]=u,G[2*r]=p,G[2*r+1]=m}function Xt(e,t,n,r,o,i){const s=o[i],c=o[i+1];let f=G[2*e],a=G[2*e+1],l=G[2*t],h=G[2*t+1],d=G[2*n],u=G[2*n+1],p=G[2*r],m=G[2*r+1],v=fs(f,l,s);a=as(v,a,h,c),f=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^f},{Dh:m,Dl:p}={Dh:jt(m,p,16),Dl:Ht(m,p,16)},{h:u,l:d}=Xe(u,d,m,p),{Bh:h,Bl:l}={Bh:h^u,Bl:l^d},{Bh:h,Bl:l}={Bh:dr(h,l,63),Bl:hr(h,l,63)},G[2*e]=f,G[2*e+1]=a,G[2*t]=l,G[2*t+1]=h,G[2*n]=d,G[2*n+1]=u,G[2*r]=p,G[2*r+1]=m}function mw(e,t={},n,r,o){if(Mt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:i,salt:s,personalization:c}=t;if(i!==void 0&&(i.length<1||i.length>n))throw new Error("key length must be undefined or 1.."+n);if(s!==void 0&&s.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==o)throw new Error("personalization must be undefined or "+o)}class Ew extends ao{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=br(this.buffer)}update(t){zt(this),t=Bt(t),Je(t);const{blockLen:n,buffer:r,buffer32:o}=this,i=t.length,s=t.byteOffset,c=t.buffer;for(let f=0;f<i;){this.pos===n&&(kt(o),this.compress(o,0,!1),kt(o),this.pos=0);const a=Math.min(n-this.pos,i-f),l=s+f;if(a===n&&!(l%4)&&f+a<i){const h=new Uint32Array(c,l,Math.floor((i-f)/4));kt(h);for(let d=0;f+n<i;d+=o.length,f+=n)this.length+=n,this.compress(h,d,!1);kt(h);continue}r.set(t.subarray(f,f+a),this.pos),this.pos+=a,this.length+=a,f+=a}return this}digestInto(t){zt(this),us(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,Qe(this.buffer.subarray(n)),kt(r),this.compress(r,0,!0),kt(r);const o=br(t);this.get().forEach((i,s)=>o[s]=xt(i))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:o,destroyed:i,outputLen:s,pos:c}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.buffer.set(n),t.destroyed=i,t.finished=o,t.length=r,t.pos=c,t.outputLen=s,t}clone(){return this._cloneInto()}}class xw extends Ew{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=de[0]|0,this.v0h=de[1]|0,this.v1l=de[2]|0,this.v1h=de[3]|0,this.v2l=de[4]|0,this.v2h=de[5]|0,this.v3l=de[6]|0,this.v3h=de[7]|0,this.v4l=de[8]|0,this.v4h=de[9]|0,this.v5l=de[10]|0,this.v5h=de[11]|0,this.v6l=de[12]|0,this.v6h=de[13]|0,this.v7l=de[14]|0,this.v7h=de[15]|0,mw(n,t,64,16,16);let{key:r,personalization:o,salt:i}=t,s=0;if(r!==void 0&&(r=Bt(r),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,i!==void 0){i=Bt(i);const c=br(i);this.v4l^=xt(c[0]),this.v4h^=xt(c[1]),this.v5l^=xt(c[2]),this.v5h^=xt(c[3])}if(o!==void 0){o=Bt(o);const c=br(o);this.v6l^=xt(c[0]),this.v6h^=xt(c[1]),this.v7l^=xt(c[2]),this.v7h^=xt(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:c,v3h:f,v4l:a,v4h:l,v5l:h,v5h:d,v6l:u,v6h:p,v7l:m,v7h:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=c|0,this.v3h=f|0,this.v4l=a|0,this.v4h=l|0,this.v5l=h|0,this.v5h=d|0,this.v6l=u|0,this.v6h=p|0,this.v7l=m|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((f,a)=>G[a]=f),G.set(de,16);let{h:o,l:i}=eu(BigInt(this.length));G[24]=de[8]^i,G[25]=de[9]^o,r&&(G[28]=~G[28],G[29]=~G[29]);let s=0;const c=yw;for(let f=0;f<12;f++)Wt(0,4,8,12,t,n+2*c[s++]),Xt(0,4,8,12,t,n+2*c[s++]),Wt(1,5,9,13,t,n+2*c[s++]),Xt(1,5,9,13,t,n+2*c[s++]),Wt(2,6,10,14,t,n+2*c[s++]),Xt(2,6,10,14,t,n+2*c[s++]),Wt(3,7,11,15,t,n+2*c[s++]),Xt(3,7,11,15,t,n+2*c[s++]),Wt(0,5,10,15,t,n+2*c[s++]),Xt(0,5,10,15,t,n+2*c[s++]),Wt(1,6,11,12,t,n+2*c[s++]),Xt(1,6,11,12,t,n+2*c[s++]),Wt(2,7,8,13,t,n+2*c[s++]),Xt(2,7,8,13,t,n+2*c[s++]),Wt(3,4,9,14,t,n+2*c[s++]),Xt(3,4,9,14,t,n+2*c[s++]);this.v0l^=G[0]^G[16],this.v0h^=G[1]^G[17],this.v1l^=G[2]^G[18],this.v1h^=G[3]^G[19],this.v2l^=G[4]^G[20],this.v2h^=G[5]^G[21],this.v3l^=G[6]^G[22],this.v3h^=G[7]^G[23],this.v4l^=G[8]^G[24],this.v4h^=G[9]^G[25],this.v5l^=G[10]^G[26],this.v5h^=G[11]^G[27],this.v6l^=G[12]^G[28],this.v6h^=G[13]^G[29],this.v7l^=G[14]^G[30],this.v7h^=G[15]^G[31],Qe(G)}destroy(){this.destroyed=!0,Qe(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}X3(e=>new xw(e));/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function yu(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gs(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function ws(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Pe(e,...t){if(!yu(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function mu(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function vw(e,t){Pe(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Jt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Bw(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Dw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Aw(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ps(e){if(typeof e=="string")e=Aw(e);else if(yu(e))e=ys(e);else throw new Error("Uint8Array expected, got "+typeof e);return e}function Ow(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function Sw(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}const _w=(e,t)=>{function n(r,...o){if(Pe(r),!Dw)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){const a=o[0];if(!a)throw new Error("nonce / iv required");e.varSizeNonce?Pe(a):Pe(a,e.nonceLength)}const i=e.tagLength;i&&o[1]!==void 0&&Pe(o[1]);const s=t(r,...o),c=(a,l)=>{if(l!==void 0){if(a!==2)throw new Error("cipher output not supported");Pe(l)}};let f=!1;return{encrypt(a,l){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=!0,Pe(a),c(s.encrypt.length,l),s.encrypt(a,l)},decrypt(a,l){if(Pe(a),i&&a.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return c(s.decrypt.length,l),s.decrypt(a,l)}}}return Object.assign(n,e),n};function Eu(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(n&&!Nw(t))throw new Error("invalid output, must be aligned");return t}function xu(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function Iw(e,t,n){gs(n);const r=new Uint8Array(16),o=Bw(r);return xu(o,0,BigInt(t),n),xu(o,8,BigInt(e),n),r}function Nw(e){return e.byteOffset%4===0}function ys(e){return Uint8Array.from(e)}const vu=e=>Uint8Array.from(e.split("").map(t=>t.charCodeAt(0))),Fw=vu("expand 16-byte k"),Cw=vu("expand 32-byte k"),Uw=Jt(Fw),$w=Jt(Cw);function te(e,t){return e<<t|e>>>32-t}function ms(e){return e.byteOffset%4===0}const uo=64,Rw=16,Bu=2**32-1,Du=new Uint32Array;function Tw(e,t,n,r,o,i,s,c){const f=o.length,a=new Uint8Array(uo),l=Jt(a),h=ms(o)&&ms(i),d=h?Jt(o):Du,u=h?Jt(i):Du;for(let p=0;p<f;s++){if(e(t,n,r,l,s,c),s>=Bu)throw new Error("arx: counter overflow");const m=Math.min(uo,f-p);if(h&&m===uo){const v=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let _=0,R;_<Rw;_++)R=v+_,u[R]=d[R]^l[_];p+=uo;continue}for(let v=0,_;v<m;v++)_=p+v,i[_]=o[_]^a[v];p+=m}}function Pw(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=Ow({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!="function")throw new Error("core must be a function");return ws(o),ws(s),gs(i),gs(n),(c,f,a,l,h=0)=>{Pe(c),Pe(f),Pe(a);const d=a.length;if(l===void 0&&(l=new Uint8Array(d)),Pe(l),ws(h),h<0||h>=Bu)throw new Error("arx: counter overflow");if(l.length<d)throw new Error(`arx: output (${l.length}) is shorter than data (${d})`);const u=[];let p=c.length,m,v;if(p===32)u.push(m=ys(c)),v=$w;else if(p===16&&n)m=new Uint8Array(32),m.set(c),m.set(c,16),v=Uw,u.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);ms(f)||u.push(f=ys(f));const _=Jt(m);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(v,_,Jt(f.subarray(0,16)),_),f=f.subarray(16)}const R=16-o;if(R!==f.length)throw new Error(`arx: nonce must be ${R} or 16 bytes`);if(R!==12){const x=new Uint8Array(12);x.set(f,i?0:12-f.length),f=x,u.push(f)}const D=Jt(f);return Tw(e,v,_,D,a,l,h,s),qn(...u),l}}const pe=(e,t)=>e[t++]&255|(e[t++]&255)<<8;class Lw{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=ps(t),Pe(t,32);const n=pe(t,0),r=pe(t,2),o=pe(t,4),i=pe(t,6),s=pe(t,8),c=pe(t,10),f=pe(t,12),a=pe(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|a<<8)&8191,this.r[9]=a>>>5&127;for(let l=0;l<8;l++)this.pad[l]=pe(t,16+2*l)}process(t,n,r=!1){const o=r?0:2048,{h:i,r:s}=this,c=s[0],f=s[1],a=s[2],l=s[3],h=s[4],d=s[5],u=s[6],p=s[7],m=s[8],v=s[9],_=pe(t,n+0),R=pe(t,n+2),D=pe(t,n+4),x=pe(t,n+6),C=pe(t,n+8),P=pe(t,n+10),q=pe(t,n+12),L=pe(t,n+14);let I=i[0]+(_&8191),k=i[1]+((_>>>13|R<<3)&8191),H=i[2]+((R>>>10|D<<6)&8191),E=i[3]+((D>>>7|x<<9)&8191),g=i[4]+((x>>>4|C<<12)&8191),y=i[5]+(C>>>1&8191),b=i[6]+((C>>>14|P<<2)&8191),w=i[7]+((P>>>11|q<<5)&8191),B=i[8]+((q>>>8|L<<8)&8191),A=i[9]+(L>>>5|o),O=0,S=O+I*c+k*(5*v)+H*(5*m)+E*(5*p)+g*(5*u);O=S>>>13,S&=8191,S+=y*(5*d)+b*(5*h)+w*(5*l)+B*(5*a)+A*(5*f),O+=S>>>13,S&=8191;let N=O+I*f+k*c+H*(5*v)+E*(5*m)+g*(5*p);O=N>>>13,N&=8191,N+=y*(5*u)+b*(5*d)+w*(5*h)+B*(5*l)+A*(5*a),O+=N>>>13,N&=8191;let $=O+I*a+k*f+H*c+E*(5*v)+g*(5*m);O=$>>>13,$&=8191,$+=y*(5*p)+b*(5*u)+w*(5*d)+B*(5*h)+A*(5*l),O+=$>>>13,$&=8191;let U=O+I*l+k*a+H*f+E*c+g*(5*v);O=U>>>13,U&=8191,U+=y*(5*m)+b*(5*p)+w*(5*u)+B*(5*d)+A*(5*h),O+=U>>>13,U&=8191;let T=O+I*h+k*l+H*a+E*f+g*c;O=T>>>13,T&=8191,T+=y*(5*v)+b*(5*m)+w*(5*p)+B*(5*u)+A*(5*d),O+=T>>>13,T&=8191;let F=O+I*d+k*h+H*l+E*a+g*f;O=F>>>13,F&=8191,F+=y*c+b*(5*v)+w*(5*m)+B*(5*p)+A*(5*u),O+=F>>>13,F&=8191;let j=O+I*u+k*d+H*h+E*l+g*a;O=j>>>13,j&=8191,j+=y*f+b*c+w*(5*v)+B*(5*m)+A*(5*p),O+=j>>>13,j&=8191;let M=O+I*p+k*u+H*d+E*h+g*l;O=M>>>13,M&=8191,M+=y*a+b*f+w*c+B*(5*v)+A*(5*m),O+=M>>>13,M&=8191;let V=O+I*m+k*p+H*u+E*d+g*h;O=V>>>13,V&=8191,V+=y*l+b*a+w*f+B*c+A*(5*v),O+=V>>>13,V&=8191;let z=O+I*v+k*m+H*p+E*u+g*d;O=z>>>13,z&=8191,z+=y*h+b*l+w*a+B*f+A*c,O+=z>>>13,z&=8191,O=(O<<2)+O|0,O=O+S|0,S=O&8191,O=O>>>13,N+=O,i[0]=S,i[1]=N,i[2]=$,i[3]=U,i[4]=T,i[5]=F,i[6]=j,i[7]=M,i[8]=V,i[9]=z}finalize(){const{h:t,pad:n}=this,r=new Uint16Array(10);let o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,r[0]=t[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=t[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let i=(o^1)-1;for(let c=0;c<10;c++)r[c]&=i;i=~i;for(let c=0;c<10;c++)t[c]=t[c]&i|r[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+n[0];t[0]=s&65535;for(let c=1;c<8;c++)s=(t[c]+n[c]|0)+(s>>>16)|0,t[c]=s&65535;qn(r)}update(t){mu(this),t=ps(t),Pe(t);const{buffer:n,blockLen:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){qn(this.h,this.r,this.buffer,this.pad)}digestInto(t){mu(this),vw(t,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)t[i++]=r[s]>>>0,t[i++]=r[s]>>>8;return t}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}}function qw(e){const t=(r,o)=>e(o).update(ps(r)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const jw=qw(e=>new Lw(e));function Hw(e,t,n,r,o,i=20){let s=e[0],c=e[1],f=e[2],a=e[3],l=t[0],h=t[1],d=t[2],u=t[3],p=t[4],m=t[5],v=t[6],_=t[7],R=o,D=n[0],x=n[1],C=n[2],P=s,q=c,L=f,I=a,k=l,H=h,E=d,g=u,y=p,b=m,w=v,B=_,A=R,O=D,S=x,N=C;for(let U=0;U<i;U+=2)P=P+k|0,A=te(A^P,16),y=y+A|0,k=te(k^y,12),P=P+k|0,A=te(A^P,8),y=y+A|0,k=te(k^y,7),q=q+H|0,O=te(O^q,16),b=b+O|0,H=te(H^b,12),q=q+H|0,O=te(O^q,8),b=b+O|0,H=te(H^b,7),L=L+E|0,S=te(S^L,16),w=w+S|0,E=te(E^w,12),L=L+E|0,S=te(S^L,8),w=w+S|0,E=te(E^w,7),I=I+g|0,N=te(N^I,16),B=B+N|0,g=te(g^B,12),I=I+g|0,N=te(N^I,8),B=B+N|0,g=te(g^B,7),P=P+H|0,N=te(N^P,16),w=w+N|0,H=te(H^w,12),P=P+H|0,N=te(N^P,8),w=w+N|0,H=te(H^w,7),q=q+E|0,A=te(A^q,16),B=B+A|0,E=te(E^B,12),q=q+E|0,A=te(A^q,8),B=B+A|0,E=te(E^B,7),L=L+g|0,O=te(O^L,16),y=y+O|0,g=te(g^y,12),L=L+g|0,O=te(O^L,8),y=y+O|0,g=te(g^y,7),I=I+k|0,S=te(S^I,16),b=b+S|0,k=te(k^b,12),I=I+k|0,S=te(S^I,8),b=b+S|0,k=te(k^b,7);let $=0;r[$++]=s+P|0,r[$++]=c+q|0,r[$++]=f+L|0,r[$++]=a+I|0,r[$++]=l+k|0,r[$++]=h+H|0,r[$++]=d+E|0,r[$++]=u+g|0,r[$++]=p+y|0,r[$++]=m+b|0,r[$++]=v+w|0,r[$++]=_+B|0,r[$++]=R+A|0,r[$++]=D+O|0,r[$++]=x+S|0,r[$++]=C+N|0}const Mw=Pw(Hw,{counterRight:!1,counterLength:4,allowShortKeys:!1}),zw=new Uint8Array(16),Au=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(zw.subarray(n))},kw=new Uint8Array(32);function Ou(e,t,n,r,o){const i=e(t,n,kw),s=jw.create(i);o&&Au(s,o),Au(s,r);const c=Iw(r.length,o?o.length:0,!0);s.update(c);const f=s.digest();return qn(i,c),f}_w({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(o,i){const s=o.length;i=Eu(s+16,i,!1),i.set(o);const c=i.subarray(0,-16);e(t,n,c,c,1);const f=Ou(e,t,n,c,r);return i.set(f,s),qn(f),i},decrypt(o,i){i=Eu(o.length-16,i,!1);const s=o.subarray(0,-16),c=o.subarray(-16),f=Ou(e,t,n,s,r);if(!Sw(c,f))throw new Error("invalid tag");return i.set(o.subarray(0,-16)),e(t,n,i,i,1),qn(f),i}}))(Mw));class Su extends ao{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,ou(t);const r=Bt(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),Qe(i)}update(t){return zt(this),this.iHash.update(t),this}digestInto(t){zt(this),Je(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const _u=(e,t,n)=>new Su(e,t).update(n).digest();_u.create=(e,t)=>new Su(e,t);const Es=BigInt(0),xs=BigInt(1);function lo(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function bn(e,t,n=""){const r=co(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){const s=n&&`"${n}" `,c=i?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+f)}return e}function ho(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Iu(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Es:BigInt("0x"+e)}function bo(e){return Iu(Ln(e))}function go(e){return Je(e),Iu(Ln(Uint8Array.from(e).reverse()))}function vs(e,t){return fo(e.toString(16).padStart(t*2,"0"))}function Bs(e,t){return vs(e,t).reverse()}function De(e,t,n){let r;if(typeof t=="string")try{r=fo(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(co(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const Ds=e=>typeof e=="bigint"&&Es<=e;function Zw(e,t,n){return Ds(e)&&Ds(t)&&Ds(n)&&t<=e&&e<n}function As(e,t,n,r){if(!Zw(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Nu(e){let t;for(t=0;e>Es;e>>=xs,t+=1);return t}const pr=e=>(xs<<BigInt(e))-xs;function Vw(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=d=>new Uint8Array(d),o=d=>Uint8Array.of(d);let i=r(e),s=r(e),c=0;const f=()=>{i.fill(1),s.fill(0),c=0},a=(...d)=>n(s,i,...d),l=(d=r(0))=>{s=a(o(0),d),i=a(),d.length!==0&&(s=a(o(1),d),i=a())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const u=[];for(;d<t;){i=a();const p=i.slice();u.push(p),d+=i.length}return Zt(...u)};return(d,u)=>{f(),l(d);let p;for(;!(p=u(h()));)l();return f(),p}}function wo(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,i,s){const c=e[o];if(s&&c===void 0)return;const f=typeof c;if(f!==i||c===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${f}`)}Object.entries(t).forEach(([o,i])=>r(o,i,!1)),Object.entries(n).forEach(([o,i])=>r(o,i,!0))}function Fu(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const Le=BigInt(0),Fe=BigInt(1),gn=BigInt(2),Cu=BigInt(3),Uu=BigInt(4),$u=BigInt(5),Gw=BigInt(7),Ru=BigInt(8),Kw=BigInt(9),Tu=BigInt(16);function He(e,t){const n=e%t;return n>=Le?n:t+n}function et(e,t,n){let r=e;for(;t-- >Le;)r*=r,r%=n;return r}function Pu(e,t){if(e===Le)throw new Error("invert: expected non-zero number");if(t<=Le)throw new Error("invert: expected positive modulus, got "+t);let n=He(e,t),r=t,o=Le,i=Fe;for(;n!==Le;){const s=r/n,c=r%n,f=o-i*s;r=n,n=c,o=i,i=f}if(r!==Fe)throw new Error("invert: does not exist");return He(o,t)}function Os(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Lu(e,t){const n=(e.ORDER+Fe)/Uu,r=e.pow(t,n);return Os(e,r,t),r}function Yw(e,t){const n=(e.ORDER-$u)/Ru,r=e.mul(t,gn),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,gn),o),c=e.mul(i,e.sub(s,e.ONE));return Os(e,c,t),c}function Ww(e){const t=Qt(e),n=qu(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+Gw)/Tu;return(c,f)=>{let a=c.pow(f,s),l=c.mul(a,r);const h=c.mul(a,o),d=c.mul(a,i),u=c.eql(c.sqr(l),f),p=c.eql(c.sqr(h),f);a=c.cmov(a,l,u),l=c.cmov(d,h,p);const m=c.eql(c.sqr(l),f),v=c.cmov(a,l,m);return Os(c,v,f),v}}function qu(e){if(e<Cu)throw new Error("sqrt is not defined for small field");let t=e-Fe,n=0;for(;t%gn===Le;)t/=gn,n++;let r=gn;const o=Qt(e);for(;Hu(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Lu;let i=o.pow(r,t);const s=(t+Fe)/gn;return function(c,f){if(c.is0(f))return f;if(Hu(c,f)!==1)throw new Error("Cannot find square root");let a=n,l=c.mul(c.ONE,i),h=c.pow(f,t),d=c.pow(f,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let u=1,p=c.sqr(h);for(;!c.eql(p,c.ONE);)if(u++,p=c.sqr(p),u===a)throw new Error("Cannot find square root");const m=Fe<<BigInt(a-u-1),v=c.pow(l,m);a=u,l=c.sqr(v),h=c.mul(h,l),d=c.mul(d,v)}return d}}function Xw(e){return e%Uu===Cu?Lu:e%Ru===$u?Yw:e%Tu===Kw?Ww(e):qu(e)}const Jw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qw(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Jw.reduce((r,o)=>(r[o]="function",r),t);return wo(e,n),e}function ep(e,t,n){if(n<Le)throw new Error("invalid exponent, negatives unsupported");if(n===Le)return e.ONE;if(n===Fe)return t;let r=e.ONE,o=t;for(;n>Le;)n&Fe&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Fe;return r}function ju(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function Hu(e,t){const n=(e.ORDER-Fe)/gn,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mu(e,t){t!==void 0&&Mt(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Qt(e,t,n=!1,r={}){if(e<=Le)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(s=d.modFromBytes),c=d.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:f,nByteLength:a}=Mu(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:a,MASK:pr(f),ZERO:Le,ONE:Fe,allowedLengths:c,create:d=>He(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Le<=d&&d<e},is0:d=>d===Le,isValidNot0:d=>!h.is0(d)&&h.isValid(d),isOdd:d=>(d&Fe)===Fe,neg:d=>He(-d,e),eql:(d,u)=>d===u,sqr:d=>He(d*d,e),add:(d,u)=>He(d+u,e),sub:(d,u)=>He(d-u,e),mul:(d,u)=>He(d*u,e),pow:(d,u)=>ep(h,d,u),div:(d,u)=>He(d*Pu(u,e),e),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>Pu(d,e),sqrt:i||(d=>(l||(l=Xw(e)),l(h,d))),toBytes:d=>n?Bs(d,a):vs(d,a),fromBytes:(d,u=!0)=>{if(c){if(!c.includes(d.length)||d.length>a)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(a);m.set(d,n?0:m.length-d.length),d=m}if(d.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);let p=n?go(d):bo(d);if(s&&(p=He(p,e)),!u&&!h.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:d=>ju(h,d),cmov:(d,u,p)=>p?u:d});return Object.freeze(h)}function zu(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ku(e){const t=zu(e);return t+Math.ceil(t/2)}function tp(e,t,n=!1){const r=e.length,o=zu(t),i=ku(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?go(e):bo(e),c=He(s,t-Fe)+Fe;return n?Bs(c,o):vs(c,o)}const jn=BigInt(0),wn=BigInt(1);function po(e,t){const n=t.negate();return e?n:t}function Ss(e,t){const n=ju(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function Zu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function _s(e,t){Zu(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=pr(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Vu(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=wn);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function np(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function rp(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Is=new WeakMap,Gu=new WeakMap;function Ns(e){return Gu.get(e)||1}function Ku(e){if(e!==jn)throw new Error("invalid wNAF")}class op{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>jn;)n&wn&&(r=r.add(o)),o=o.double(),n>>=wn;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=_s(n,this.bits),i=[];let s=t,c=s;for(let f=0;f<r;f++){c=s,i.push(c);for(let a=1;a<o;a++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE;const s=_s(t,this.bits);for(let c=0;c<s.windows;c++){const{nextN:f,offset:a,isZero:l,isNeg:h,isNegF:d,offsetF:u}=Vu(r,c,s);r=f,l?i=i.add(po(d,n[u])):o=o.add(po(h,n[a]))}return Ku(r),{p:o,f:i}}wNAFUnsafe(t,n,r,o=this.ZERO){const i=_s(t,this.bits);for(let s=0;s<i.windows&&r!==jn;s++){const{nextN:c,offset:f,isZero:a,isNeg:l}=Vu(r,s,i);if(r=c,!a){const h=n[f];o=o.add(l?h.negate():h)}}return Ku(r),o}getPrecomputes(t,n,r){let o=Is.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),Is.set(n,o))),o}cached(t,n,r){const o=Ns(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const i=Ns(t);return i===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),n,o)}createCache(t,n){Zu(n,this.bits),Gu.set(t,n),Is.delete(t)}hasCache(t){return Ns(t)!==1}}function ip(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>jn||r>jn;)n&wn&&(i=i.add(o)),r&wn&&(s=s.add(o)),o=o.double(),n>>=wn,r>>=wn;return{p1:i,p2:s}}function sp(e,t,n,r){np(n,e),rp(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=Nu(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=pr(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Yu(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Qw(t),t}else return Qt(e,{isLE:n})}function cp(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const c of["p","n","h"]){const f=t[c];if(!(typeof f=="bigint"&&f>jn))throw new Error(`CURVE.${c} must be positive bigint`)}const o=Yu(t.p,n.Fp,r),i=Yu(t.n,n.Fn,r),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const c of s)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),au("HashToScalar-");const yr=BigInt(0),Hn=BigInt(1),yo=BigInt(2);function fp(e){return wo(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze(Tn({},e))}function ap(e){const t=fp(e),{P:n,type:r,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=t,c=r==="x25519";if(!c&&r!=="x448")throw new Error("invalid type");const f=s||ds,a=c?255:448,l=c?32:56,h=BigInt(c?9:5),d=BigInt(c?121665:39081),u=c?yo**BigInt(254):yo**BigInt(447),p=c?BigInt(8)*yo**BigInt(251)-Hn:BigInt(4)*yo**BigInt(445)-Hn,m=u+p+Hn,v=E=>He(E,n),_=R(h);function R(E){return Bs(v(E),l)}function D(E){const g=De("u coordinate",E,l);return c&&(g[31]&=127),v(go(g))}function x(E){return go(o(De("scalar",E,l)))}function C(E,g){const y=L(D(g),x(E));if(y===yr)throw new Error("invalid private or public key received");return R(y)}function P(E){return C(E,_)}function q(E,g,y){const b=v(E*(g-y));return g=v(g-b),y=v(y+b),{x_2:g,x_3:y}}function L(E,g){As("u",E,yr,n),As("scalar",g,u,m);const y=g,b=E;let w=Hn,B=yr,A=E,O=Hn,S=yr;for(let $=BigInt(a-1);$>=yr;$--){const U=y>>$&Hn;S^=U,{x_2:w,x_3:A}=q(S,w,A),{x_2:B,x_3:O}=q(S,B,O),S=U;const T=w+B,F=v(T*T),j=w-B,M=v(j*j),V=F-M,z=A+O,Z=A-O,W=v(Z*T),J=v(z*j),ee=W+J,oe=W-J;A=v(ee*ee),O=v(b*v(oe*oe)),w=v(F*M),B=v(V*(F+v(d*V)))}({x_2:w,x_3:A}=q(S,w,A)),{x_2:B,x_3:O}=q(S,B,O);const N=i(B);return v(w*N)}const I={secretKey:l,publicKey:l,seed:l},k=(E=f(l))=>(Je(E,I.seed),E);function H(E){const g=k(E);return{secretKey:g,publicKey:P(g)}}return{keygen:H,getSharedSecret:(E,g)=>C(E,g),getPublicKey:E=>P(E),scalarMult:C,scalarMultBase:P,utils:{randomSecretKey:k,randomPrivateKey:k},GuBytes:_.slice(),lengths:I}}const up=BigInt(1),Wu=BigInt(2),lp=BigInt(3),dp=BigInt(5),hp=BigInt(8),Xu=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),bp={p:Xu,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:hp,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function gp(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=Xu,s=e*e%i*e%i,c=et(s,Wu,i)*s%i,f=et(c,up,i)*e%i,a=et(f,dp,i)*f%i,l=et(a,t,i)*a%i,h=et(l,n,i)*l%i,d=et(h,r,i)*h%i,u=et(d,o,i)*d%i,p=et(u,o,i)*d%i,m=et(p,t,i)*a%i;return{pow_p_5_8:et(m,Wu,i)*e%i,b2:s}}function wp(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const pp=Qt(bp.p,{isLE:!0});(()=>{const e=pp.ORDER;return ap({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=gp(t);return He(et(n,lp,e)*r,e)},adjustScalarBytes:wp})})();const Ju=(e,t)=>(e+(e>=0?t:-t)/Qu)/t;function yp(e,t,n){const[[r,o],[i,s]]=t,c=Ju(s*e,n),f=Ju(-o*e,n);let a=e-c*r-f*i,l=-c*o-f*s;const h=a<At,d=l<At;h&&(a=-a),d&&(l=-l);const u=pr(Math.ceil(Nu(n)/2))+Mn;if(a<At||a>=u||l<At||l>=u)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}function Fs(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Cs(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return lo(n.lowS,"lowS"),lo(n.prehash,"prehash"),n.format!==void 0&&Fs(n.format),n}class mp extends Error{constructor(t=""){super(t)}}const Dt={Err:mp,_tlv:{encode:(e,t)=>{const{Err:n}=Dt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=ho(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?ho(o.length/2|128):"";return ho(e)+i+o+t},decode(e,t){const{Err:n}=Dt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=Dt;if(e<At)throw new t("integer: negative integers are not allowed");let n=ho(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Dt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return bo(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Dt,o=De("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=Dt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}},At=BigInt(0),Mn=BigInt(1),Qu=BigInt(2),mo=BigInt(3),Ep=BigInt(4);function zn(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=De("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function xp(e,t={}){const n=cp("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:c}=i;wo(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(i.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const a=tl(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(E,g,y){const{x:b,y:w}=g.toAffine(),B=r.toBytes(b);if(lo(y,"isCompressed"),y){l();const A=!r.isOdd(w);return Zt(el(A),B)}else return Zt(Uint8Array.of(4),B,r.toBytes(w))}function d(E){bn(E,void 0,"Point");const{publicKey:g,publicKeyUncompressed:y}=a,b=E.length,w=E[0],B=E.subarray(1);if(b===g&&(w===2||w===3)){const A=r.fromBytes(B);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const O=m(A);let S;try{S=r.sqrt(O)}catch($){const U=$ instanceof Error?": "+$.message:"";throw new Error("bad point: is not on curve, sqrt error"+U)}l();const N=r.isOdd(S);return(w&1)===1!==N&&(S=r.neg(S)),{x:A,y:S}}else if(b===y&&w===4){const A=r.BYTES,O=r.fromBytes(B.subarray(0,A)),S=r.fromBytes(B.subarray(A,A*2));if(!v(O,S))throw new Error("bad point: is not on curve");return{x:O,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${g} or uncompressed=${y}`)}const u=t.toBytes||h,p=t.fromBytes||d;function m(E){const g=r.sqr(E),y=r.mul(g,E);return r.add(r.add(y,r.mul(E,i.a)),i.b)}function v(E,g){const y=r.sqr(g),b=m(E);return r.eql(y,b)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const _=r.mul(r.pow(i.a,mo),Ep),R=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(_,R)))throw new Error("bad curve params: a or b");function D(E,g,y=!1){if(!r.isValid(g)||y&&r.is0(g))throw new Error(`bad point coordinate ${E}`);return g}function x(E){if(!(E instanceof I))throw new Error("ProjectivePoint expected")}function C(E){if(!f||!f.basises)throw new Error("no endo");return yp(E,f.basises,o.ORDER)}const P=Fu((E,g)=>{const{X:y,Y:b,Z:w}=E;if(r.eql(w,r.ONE))return{x:y,y:b};const B=E.is0();g==null&&(g=B?r.ONE:r.inv(w));const A=r.mul(y,g),O=r.mul(b,g),S=r.mul(w,g);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),q=Fu(E=>{if(E.is0()){if(t.allowInfinityPoint&&!r.is0(E.Y))return;throw new Error("bad point: ZERO")}const{x:g,y}=E.toAffine();if(!r.isValid(g)||!r.isValid(y))throw new Error("bad point: x or y not field elements");if(!v(g,y))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(E,g,y,b,w){return y=new I(r.mul(y.X,E),y.Y,y.Z),g=po(b,g),y=po(w,y),g.add(y)}class I{constructor(g,y,b){this.X=D("x",g),this.Y=D("y",y,!0),this.Z=D("z",b),Object.freeze(this)}static CURVE(){return i}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!r.isValid(y)||!r.isValid(b))throw new Error("invalid affine point");if(g instanceof I)throw new Error("projective point not allowed");return r.is0(y)&&r.is0(b)?I.ZERO:new I(y,b,r.ONE)}static fromBytes(g){const y=I.fromAffine(p(bn(g,void 0,"point")));return y.assertValidity(),y}static fromHex(g){return I.fromBytes(De("pointHex",g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,y=!0){return H.createCache(this,g),y||this.multiply(mo),this}assertValidity(){q(this)}hasEvenY(){const{y:g}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(g)}equals(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g,S=r.eql(r.mul(y,O),r.mul(B,w)),N=r.eql(r.mul(b,O),r.mul(A,w));return S&&N}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:g,b:y}=i,b=r.mul(y,mo),{X:w,Y:B,Z:A}=this;let O=r.ZERO,S=r.ZERO,N=r.ZERO,$=r.mul(w,w),U=r.mul(B,B),T=r.mul(A,A),F=r.mul(w,B);return F=r.add(F,F),N=r.mul(w,A),N=r.add(N,N),O=r.mul(g,N),S=r.mul(b,T),S=r.add(O,S),O=r.sub(U,S),S=r.add(U,S),S=r.mul(O,S),O=r.mul(F,O),N=r.mul(b,N),T=r.mul(g,T),F=r.sub($,T),F=r.mul(g,F),F=r.add(F,N),N=r.add($,$),$=r.add(N,$),$=r.add($,T),$=r.mul($,F),S=r.add(S,$),T=r.mul(B,A),T=r.add(T,T),$=r.mul(T,F),O=r.sub(O,$),N=r.mul(T,U),N=r.add(N,N),N=r.add(N,N),new I(O,S,N)}add(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g;let S=r.ZERO,N=r.ZERO,$=r.ZERO;const U=i.a,T=r.mul(i.b,mo);let F=r.mul(y,B),j=r.mul(b,A),M=r.mul(w,O),V=r.add(y,b),z=r.add(B,A);V=r.mul(V,z),z=r.add(F,j),V=r.sub(V,z),z=r.add(y,w);let Z=r.add(B,O);return z=r.mul(z,Z),Z=r.add(F,M),z=r.sub(z,Z),Z=r.add(b,w),S=r.add(A,O),Z=r.mul(Z,S),S=r.add(j,M),Z=r.sub(Z,S),$=r.mul(U,z),S=r.mul(T,M),$=r.add(S,$),S=r.sub(j,$),$=r.add(j,$),N=r.mul(S,$),j=r.add(F,F),j=r.add(j,F),M=r.mul(U,M),z=r.mul(T,z),j=r.add(j,M),M=r.sub(F,M),M=r.mul(U,M),z=r.add(z,M),F=r.mul(j,z),N=r.add(N,F),F=r.mul(Z,z),S=r.mul(V,S),S=r.sub(S,F),F=r.mul(V,j),$=r.mul(Z,$),$=r.add($,F),new I(S,N,$)}subtract(g){return this.add(g.negate())}is0(){return this.equals(I.ZERO)}multiply(g){const{endo:y}=t;if(!o.isValidNot0(g))throw new Error("invalid scalar: out of range");let b,w;const B=A=>H.cached(this,A,O=>Ss(I,O));if(y){const{k1neg:A,k1:O,k2neg:S,k2:N}=C(g),{p:$,f:U}=B(O),{p:T,f:F}=B(N);w=U.add(F),b=L(y.beta,$,T,A,S)}else{const{p:A,f:O}=B(g);b=A,w=O}return Ss(I,[b,w])[0]}multiplyUnsafe(g){const{endo:y}=t,b=this;if(!o.isValid(g))throw new Error("invalid scalar: out of range");if(g===At||b.is0())return I.ZERO;if(g===Mn)return b;if(H.hasCache(this))return this.multiply(g);if(y){const{k1neg:w,k1:B,k2neg:A,k2:O}=C(g),{p1:S,p2:N}=ip(I,b,B,O);return L(y.beta,S,N,w,A)}else return H.unsafe(b,g)}multiplyAndAddUnsafe(g,y,b){const w=this.multiplyUnsafe(y).add(g.multiplyUnsafe(b));return w.is0()?void 0:w}toAffine(g){return P(this,g)}isTorsionFree(){const{isTorsionFree:g}=t;return s===Mn?!0:g?g(I,this):H.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:g}=t;return s===Mn?this:g?g(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(g=!0){return lo(g,"isCompressed"),this.assertValidity(),u(I,this,g)}toHex(g=!0){return Ln(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(g=!0){return this.toBytes(g)}_setWindowSize(g){this.precompute(g)}static normalizeZ(g){return Ss(I,g)}static msm(g,y){return sp(I,o,g,y)}static fromPrivateKey(g){return I.BASE.multiply(zn(o,g))}}I.BASE=new I(i.Gx,i.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=o;const k=o.BITS,H=new op(I,t.endo?Math.ceil(k/2):k);return I.BASE.precompute(8),I}function el(e){return Uint8Array.of(e?2:3)}function tl(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function vp(e,t={}){const{Fn:n}=e,r=t.randomBytes||ds,o=Object.assign(tl(e.Fp,n),{seed:ku(n.ORDER)});function i(d){try{return!!zn(n,d)}catch{return!1}}function s(d,u){const{publicKey:p,publicKeyUncompressed:m}=o;try{const v=d.length;return u===!0&&v!==p||u===!1&&v!==m?!1:!!e.fromBytes(d)}catch{return!1}}function c(d=r(o.seed)){return tp(bn(d,o.seed,"seed"),n.ORDER)}function f(d,u=!0){return e.BASE.multiply(zn(n,d)).toBytes(u)}function a(d){const u=c(d);return{secretKey:u,publicKey:f(u)}}function l(d){if(typeof d=="bigint")return!1;if(d instanceof e)return!0;const{secretKey:u,publicKey:p,publicKeyUncompressed:m}=o;if(n.allowedLengths||u===p)return;const v=De("key",d).length;return v===p||v===m}function h(d,u,p=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(u)===!1)throw new Error("second arg must be public key");const m=zn(n,d);return e.fromHex(u).multiply(m).toBytes(p)}return Object.freeze({getPublicKey:f,getSharedSecret:h,keygen:a,Point:e,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:d=>zn(n,d),precompute(d=8,u=e.BASE){return u.precompute(d,!1)}},lengths:o})}function Bp(e,t,n={}){ou(t),wo(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||ds,o=n.hmac||((y,...b)=>_u(t,y,Zt(...b))),{Fp:i,Fn:s}=e,{ORDER:c,BITS:f}=s,{keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u}=vp(e,n),p={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},m="compact";function v(y){const b=c>>Mn;return y>b}function _(y,b){if(!s.isValidNot0(b))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return b}function R(y,b){Fs(b);const w=u.signature,B=b==="compact"?w:b==="recovered"?w+1:void 0;return bn(y,B,`${b} signature`)}class D{constructor(b,w,B){this.r=_("r",b),this.s=_("s",w),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,w=m){R(b,w);let B;if(w==="der"){const{r:N,s:$}=Dt.toSig(bn(b));return new D(N,$)}w==="recovered"&&(B=b[0],w="compact",b=b.subarray(1));const A=s.BYTES,O=b.subarray(0,A),S=b.subarray(A,A*2);return new D(s.fromBytes(O),s.fromBytes(S),B)}static fromHex(b,w){return this.fromBytes(fo(b),w)}addRecoveryBit(b){return new D(this.r,this.s,b)}recoverPublicKey(b){const w=i.ORDER,{r:B,s:A,recovery:O}=this;if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");if(c*Qu<w&&O>1)throw new Error("recovery id is ambiguous for h>1 curve");const S=O===2||O===3?B+c:B;if(!i.isValid(S))throw new Error("recovery id 2 or 3 invalid");const N=i.toBytes(S),$=e.fromBytes(Zt(el((O&1)===0),N)),U=s.inv(S),T=C(De("msgHash",b)),F=s.create(-T*U),j=s.create(A*U),M=e.BASE.multiplyUnsafe(F).add($.multiplyUnsafe(j));if(M.is0())throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return v(this.s)}toBytes(b=m){if(Fs(b),b==="der")return fo(Dt.hexFromSig(this));const w=s.toBytes(this.r),B=s.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Zt(Uint8Array.of(this.recovery),w,B)}return Zt(w,B)}toHex(b){return Ln(this.toBytes(b))}assertValidity(){}static fromCompact(b){return D.fromBytes(De("sig",b),"compact")}static fromDER(b){return D.fromBytes(De("sig",b),"der")}normalizeS(){return this.hasHighS()?new D(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Ln(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Ln(this.toBytes("compact"))}}const x=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const b=bo(y),w=y.length*8-f;return w>0?b>>BigInt(w):b},C=n.bits2int_modN||function(y){return s.create(x(y))},P=pr(f);function q(y){return As("num < 2^"+f,y,At,P),s.toBytes(y)}function L(y,b){return bn(y,void 0,"message"),b?bn(t(y),void 0,"prehashed message"):y}function I(y,b,w){if(["recovered","canonical"].some(j=>j in w))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:A,extraEntropy:O}=Cs(w,p);y=L(y,A);const S=C(y),N=zn(s,b),$=[q(N),q(S)];if(O!=null&&O!==!1){const j=O===!0?r(u.secretKey):O;$.push(De("extraEntropy",j))}const U=Zt(...$),T=S;function F(j){const M=x(j);if(!s.isValidNot0(M))return;const V=s.inv(M),z=e.BASE.multiply(M).toAffine(),Z=s.create(z.x);if(Z===At)return;const W=s.create(V*s.create(T+Z*N));if(W===At)return;let J=(z.x===Z?0:2)|Number(z.y&Mn),ee=W;return B&&v(W)&&(ee=s.neg(W),J^=1),new D(Z,ee,J)}return{seed:U,k2sig:F}}function k(y,b,w={}){y=De("message",y);const{seed:B,k2sig:A}=I(y,b,w);return Vw(t.outputLen,s.BYTES,o)(B,A)}function H(y){let b;const w=typeof y=="string"||co(y),B=!w&&y!==null&&typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!w&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new D(y.r,y.s);else if(w){try{b=D.fromBytes(De("sig",y),"der")}catch(A){if(!(A instanceof Dt.Err))throw A}if(!b)try{b=D.fromBytes(De("sig",y),"compact")}catch{return!1}}return b||!1}function E(y,b,w,B={}){const{lowS:A,prehash:O,format:S}=Cs(B,p);if(w=De("publicKey",w),b=L(De("message",b),O),"strict"in B)throw new Error("options.strict was renamed to lowS");const N=S===void 0?H(y):D.fromBytes(De("sig",y),S);if(N===!1)return!1;try{const $=e.fromBytes(w);if(A&&N.hasHighS())return!1;const{r:U,s:T}=N,F=C(b),j=s.inv(T),M=s.create(F*j),V=s.create(U*j),z=e.BASE.multiplyUnsafe(M).add($.multiplyUnsafe(V));return z.is0()?!1:s.create(z.x)===U}catch{return!1}}function g(y,b,w={}){const{prehash:B}=Cs(w,p);return b=L(b,B),D.fromBytes(y,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u,Point:e,sign:k,verify:E,recoverPublicKey:g,Signature:D,hash:t})}function Dp(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const o=Qt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),i={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:i}}function Ap(e){const{CURVE:t,curveOpts:n}=Dp(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Op(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Mu(n.Fn.ORDER,n.Fn.BITS))})}function Sp(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Ap(e),i=xp(t,n),s=Bp(i,r,o);return Op(e,s)}function Us(e,t){const n=r=>Sp(lr(Tn({},e),{hash:r}));return lr(Tn({},n(t)),{create:n})}const nl={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},rl={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},ol={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},_p=Qt(nl.p),Ip=Qt(rl.p),Np=Qt(ol.p);Us(lr(Tn({},nl),{Fp:_p,lowS:!1}),gw),Us(lr(Tn({},rl),{Fp:Ip,lowS:!1}),pw),Us(lr(Tn({},ol),{Fp:Np,lowS:!1,allowedPrivateKeyLengths:[130,131,132]}),ww);const il="https://api.pay.walletconnect.com",sl="js-walletconnect-pay",cl="1.0.1",Fp="pay",Ve="WalletConnectPay";function Cp(){return T3()?"rn-ios":R3()?"rn-android":P3()?"browser":Ja()?"node":"unknown"}var Up=Object.defineProperty,$p=(e,t,n)=>t in e?Up(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fl=(e,t,n)=>$p(e,typeof t!="symbol"?t+"":t,n);class ae extends Error{constructor(t,n,r){super(n),fl(this,"code"),fl(this,"originalMessage"),this.name="PayError",this.code=t,this.originalMessage=r??n,Object.setPrototypeOf(this,ae.prototype)}static fromNativeError(t){if(t instanceof ae)return t;const n=t instanceof Error?t.message:String(t);return n.includes("JSON parse error")?new ae("JSON_PARSE",n):n.includes("JSON serialize error")?new ae("JSON_SERIALIZE",n):n.includes("Payment options error")?new ae("PAYMENT_OPTIONS",n):n.includes("Payment request error")?new ae("PAYMENT_REQUEST",n):n.includes("Confirm payment error")?new ae("CONFIRM_PAYMENT",n):new ae("UNKNOWN",n)}}class Eo extends ae{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,Eo.prototype)}}class xo extends ae{constructor(t){super("PAYMENT_OPTIONS",`Failed to get payment options: ${t}`,t),this.name="PaymentOptionsError",Object.setPrototypeOf(this,xo.prototype)}}class vo extends ae{constructor(t){super("PAYMENT_REQUEST",`Failed to get payment actions: ${t}`,t),this.name="PaymentActionsError",Object.setPrototypeOf(this,vo.prototype)}}class Bo extends ae{constructor(t){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${t}`,t),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,Bo.prototype)}}var Rp=Object.defineProperty,Tp=(e,t,n)=>t in e?Rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pp=(e,t,n)=>Tp(e,typeof t!="symbol"?t+"":t,n);let it,Do=null;function al(){var e,t;if(Do)return Do;if(it!==void 0)return it;try{const n=globalThis.ReactNative;if((e=n?.NativeModules)!=null&&e.RNWalletConnectPay)return it=n.NativeModules.RNWalletConnectPay,it;const r=(t=globalThis.expo)==null?void 0:t.modules;return r!=null&&r.RNWalletConnectPay?(it=r.RNWalletConnectPay,it):(it=null,null)}catch{return it=null,null}}function Lp(e){Do=e,it=e}function ul(){return al()!==null}function qp(){Do=null,it=void 0}class ll{constructor(t){Pp(this,"module");const n=al();if(!n)throw new Eo;if(n.initialize)try{const r=JSON.stringify(t);n.initialize(r)}catch(r){throw new ae("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=n}async getPaymentOptions(t){var n;const r={paymentLink:t.paymentLink,accounts:t.accounts,includePaymentInfo:(n=t.includePaymentInfo)!=null?n:!1};try{const o=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(o)}catch(o){throw ae.fromNativeError(o)}}async getRequiredPaymentActions(t){const n={paymentId:t.paymentId,optionId:t.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(n));return JSON.parse(r)}catch(r){throw ae.fromNativeError(r)}}async confirmPayment(t){const n={paymentId:t.paymentId,optionId:t.optionId,signatures:t.signatures,collectedData:t.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(n));return JSON.parse(r)}catch(r){throw ae.fromNativeError(r)}}}function dl(e){return new ll(e)}function $s(){return ul()?"native":null}function hl(e){const t=$s();if(!t)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(t){case"native":return dl(e);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${t}`)}}function bl(){return $s()!==null}var jp=Object.defineProperty,Hp=(e,t,n)=>t in e?jp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mr=(e,t,n)=>Hp(e,typeof t!="symbol"?t+"":t,n);class gl{constructor(t){mr(this,"projectId"),mr(this,"apiKey"),mr(this,"baseUrl"),mr(this,"logger"),mr(this,"provider");var n,r,o;this.projectId=t.projectId,this.apiKey=t.apiKey,this.baseUrl=(n=t.baseUrl)!=null?n:il,this.logger=typeof t.logger=="string"?Hs(ks({level:t.logger})):(r=t.logger)!=null?r:Hs(ks({level:"error"})),this.logger.trace(`${Ve} initialized`);const i={baseUrl:this.baseUrl,projectId:this.projectId,apiKey:this.apiKey,sdkName:sl,sdkVersion:cl,sdkPlatform:Cp(),bundleId:(o=L3())!=null?o:""};this.provider=hl(i),this.logger.debug(`${Ve} provider initialized`)}static isAvailable(){return bl()}async getPaymentOptions(t){this.logger.debug({paymentLink:t.paymentLink,accounts:t.accounts,includePaymentInfo:t.includePaymentInfo},`${Ve} getPaymentOptions`);try{const n=await this.provider.getPaymentOptions(t);return this.logger.debug({paymentId:n.paymentId,optionsCount:n.options.length},`${Ve} getPaymentOptions response`),n}catch(n){throw this.logger.error({error:n},`${Ve} getPaymentOptions error`),n instanceof ae?n:new xo(String(n))}}async getRequiredPaymentActions(t){this.logger.debug({paymentId:t.paymentId,optionId:t.optionId},`${Ve} getRequiredPaymentActions`);try{const n=await this.provider.getRequiredPaymentActions(t);return this.logger.debug({actionsCount:n.length},`${Ve} getRequiredPaymentActions response`),n}catch(n){throw this.logger.error({error:n},`${Ve} getRequiredPaymentActions error`),n instanceof ae?n:new vo(String(n))}}async confirmPayment(t){this.logger.debug({paymentId:t.paymentId,optionId:t.optionId,signaturesCount:t.signatures.length,hasCollectedData:!!t.collectedData},`${Ve} confirmPayment`);try{const n=await this.provider.confirmPayment(t);return this.logger.debug({status:n.status,isFinal:n.isFinal},`${Ve} confirmPayment response`),n}catch(n){throw this.logger.error({error:n},`${Ve} confirmPayment error`),n instanceof ae?n:new Bo(String(n))}}}const Mp=gl;ie.CLIENT_CONTEXT=Fp,ie.ConfirmPaymentError=Bo,ie.LOGGER_CONTEXT=Ve,ie.NativeModuleNotFoundError=Eo,ie.NativeProvider=ll,ie.PAY_API_BASE_URL=il,ie.PayError=ae,ie.PaymentActionsError=vo,ie.PaymentOptionsError=xo,ie.SDK_NAME=sl,ie.SDK_VERSION=cl,ie.WalletConnectPay=Mp,ie.createNativeProvider=dl,ie.createProvider=hl,ie.default=gl,ie.detectProviderType=$s,ie.isNativeProviderAvailable=ul,ie.isProviderAvailable=bl,ie.resetNativeModule=qp,ie.setNativeModule=Lp,Object.defineProperty(ie,"__esModule",{value:!0})});
14
+ ***************************************************************************** */var Fo=function(e,t){return Fo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},Fo(e,t)};function Xl(e,t){Fo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Co=function(){return Co=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Co.apply(this,arguments)};function Jl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Ql(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i}function ed(e,t){return function(n,r){t(n,r,e)}}function td(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function nd(e,t,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function c(l){try{a(r.next(l))}catch(h){s(h)}}function f(l){try{a(r.throw(l))}catch(h){s(h)}}function a(l){l.done?i(l.value):o(l.value).then(c,f)}a((r=r.apply(e,t||[])).next())})}function rd(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s;return s={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function c(a){return function(l){return f([a,l])}}function f(a){if(r)throw new TypeError("Generator is already executing.");for(;n;)try{if(r=1,o&&(i=a[0]&2?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return n.label++,{value:a[1],done:!1};case 5:n.label++,o=a[1],a=[0];continue;case 7:a=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){n.label=a[1];break}if(a[0]===6&&n.label<i[1]){n.label=i[1],i=a;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(a);break}i[2]&&n.ops.pop(),n.trys.pop();continue}a=t.call(e,n)}catch(l){a=[6,l],o=0}finally{r=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function od(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function id(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Uo(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Zs(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function sd(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Zs(arguments[t]));return e}function cd(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),o=0,t=0;t<n;t++)for(var i=arguments[t],s=0,c=i.length;s<c;s++,o++)r[o]=i[s];return r}function Zn(e){return this instanceof Zn?(this.v=e,this):new Zn(e)}function fd(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,i=[];return o={},s("next"),s("throw"),s("return"),o[Symbol.asyncIterator]=function(){return this},o;function s(d){r[d]&&(o[d]=function(u){return new Promise(function(p,m){i.push([d,u,p,m])>1||c(d,u)})})}function c(d,u){try{f(r[d](u))}catch(p){h(i[0][3],p)}}function f(d){d.value instanceof Zn?Promise.resolve(d.value.v).then(a,l):h(i[0][2],d)}function a(d){c("next",d)}function l(d){c("throw",d)}function h(d,u){d(u),i.shift(),i.length&&c(i[0][0],i[0][1])}}function ad(e){var t,n;return t={},r("next"),r("throw",function(o){throw o}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(o,i){t[o]=e[o]?function(s){return(n=!n)?{value:Zn(e[o](s)),done:o==="return"}:i?i(s):s}:i}}function ud(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Uo=="function"?Uo(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=e[i]&&function(s){return new Promise(function(c,f){s=e[i](s),o(c,f,s.done,s.value)})}}function o(i,s,c,f){Promise.resolve(f).then(function(a){i({value:a,done:c})},s)}}function ld(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function dd(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function hd(e){return e&&e.__esModule?e:{default:e}}function bd(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function gd(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}var wd=Object.freeze({__proto__:null,__extends:Xl,get __assign(){return Co},__rest:Jl,__decorate:Ql,__param:ed,__metadata:td,__awaiter:nd,__generator:rd,__createBinding:od,__exportStar:id,__values:Uo,__read:Zs,__spread:sd,__spreadArrays:cd,__await:Zn,__asyncGenerator:fd,__asyncDelegator:ad,__asyncValues:ud,__makeTemplateObject:ld,__importStar:dd,__importDefault:hd,__classPrivateFieldGet:bd,__classPrivateFieldSet:gd}),xr=Yl(wd),Ro={},Vn={},Vs;function pd(){if(Vs)return Vn;Vs=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.delay=void 0;function e(t){return new Promise(n=>{setTimeout(()=>{n(!0)},t)})}return Vn.delay=e,Vn}var nn={},$o={},rn={},Gs;function yd(){return Gs||(Gs=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.ONE_THOUSAND=rn.ONE_HUNDRED=void 0,rn.ONE_HUNDRED=100,rn.ONE_THOUSAND=1e3),rn}var To={},Ks;function md(){return Ks||(Ks=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=e.ONE_MINUTE*5,e.TEN_MINUTES=e.ONE_MINUTE*10,e.THIRTY_MINUTES=e.ONE_MINUTE*30,e.SIXTY_MINUTES=e.ONE_MINUTE*60,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=e.ONE_HOUR*3,e.SIX_HOURS=e.ONE_HOUR*6,e.TWELVE_HOURS=e.ONE_HOUR*12,e.TWENTY_FOUR_HOURS=e.ONE_HOUR*24,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=e.ONE_DAY*3,e.FIVE_DAYS=e.ONE_DAY*5,e.SEVEN_DAYS=e.ONE_DAY*7,e.THIRTY_DAYS=e.ONE_DAY*30,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=e.ONE_WEEK*2,e.THREE_WEEKS=e.ONE_WEEK*3,e.FOUR_WEEKS=e.ONE_WEEK*4,e.ONE_YEAR=e.ONE_DAY*365}(To)),To}var Ys;function Ws(){return Ys||(Ys=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(yd(),e),t.__exportStar(md(),e)}($o)),$o}var Xs;function Ed(){if(Xs)return nn;Xs=1,Object.defineProperty(nn,"__esModule",{value:!0}),nn.fromMiliseconds=nn.toMiliseconds=void 0;const e=Ws();function t(r){return r*e.ONE_THOUSAND}nn.toMiliseconds=t;function n(r){return Math.floor(r/e.ONE_THOUSAND)}return nn.fromMiliseconds=n,nn}var Js;function xd(){return Js||(Js=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(pd(),e),t.__exportStar(Ed(),e)}(Ro)),Ro}var yn={},Qs;function vd(){if(Qs)return yn;Qs=1,Object.defineProperty(yn,"__esModule",{value:!0}),yn.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(n){if(this.timestamps.has(n))throw new Error(`Watch already started for label: ${n}`);this.timestamps.set(n,{started:Date.now()})}stop(n){const r=this.get(n);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${n}`);const o=Date.now()-r.started;this.timestamps.set(n,{started:r.started,elapsed:o})}get(n){const r=this.timestamps.get(n);if(typeof r>"u")throw new Error(`No timestamp found for label: ${n}`);return r}elapsed(n){const r=this.get(n);return r.elapsed||Date.now()-r.started}}return yn.Watch=e,yn.default=e,yn}var Po={},Gn={},ec;function Bd(){if(ec)return Gn;ec=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.IWatch=void 0;class e{}return Gn.IWatch=e,Gn}var tc;function Dd(){return tc||(tc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),xr.__exportStar(Bd(),e)}(Po)),Po}(function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=xr;t.__exportStar(xd(),e),t.__exportStar(vd(),e),t.__exportStar(Dd(),e),t.__exportStar(Ws(),e)})(Wl);var re={};Object.defineProperty(re,"__esModule",{value:!0}),re.getLocalStorage=re.getLocalStorageOrThrow=re.getCrypto=re.getCryptoOrThrow=re.getLocation=re.getLocationOrThrow=qo=re.getNavigator=re.getNavigatorOrThrow=Lo=re.getDocument=re.getDocumentOrThrow=re.getFromWindowOrThrow=re.getFromWindow=void 0;function on(e){let t;return typeof window<"u"&&typeof window[e]<"u"&&(t=window[e]),t}re.getFromWindow=on;function mn(e){const t=on(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}re.getFromWindowOrThrow=mn;function Ad(){return mn("document")}re.getDocumentOrThrow=Ad;function Od(){return on("document")}var Lo=re.getDocument=Od;function Sd(){return mn("navigator")}re.getNavigatorOrThrow=Sd;function _d(){return on("navigator")}var qo=re.getNavigator=_d;function Id(){return mn("location")}re.getLocationOrThrow=Id;function Nd(){return on("location")}re.getLocation=Nd;function Fd(){return mn("crypto")}re.getCryptoOrThrow=Fd;function Cd(){return on("crypto")}re.getCrypto=Cd;function Ud(){return mn("localStorage")}re.getLocalStorageOrThrow=Ud;function Rd(){return on("localStorage")}re.getLocalStorage=Rd;var jo={};Object.defineProperty(jo,"__esModule",{value:!0}),jo.getWindowMetadata=void 0;const nc=re;function $d(){let e,t;try{e=nc.getDocumentOrThrow(),t=nc.getLocationOrThrow()}catch{return null}function n(){const h=e.getElementsByTagName("link"),d=[];for(let u=0;u<h.length;u++){const p=h[u],m=p.getAttribute("rel");if(m&&m.toLowerCase().indexOf("icon")>-1){const v=p.getAttribute("href");if(v)if(v.toLowerCase().indexOf("https:")===-1&&v.toLowerCase().indexOf("http:")===-1&&v.indexOf("//")!==0){let _=t.protocol+"//"+t.host;if(v.indexOf("/")===0)_+=v;else{const $=t.pathname.split("/");$.pop();const D=$.join("/");_+=D+"/"+v}d.push(_)}else if(v.indexOf("//")===0){const _=t.protocol+v;d.push(_)}else d.push(v)}}return d}function r(...h){const d=e.getElementsByTagName("meta");for(let u=0;u<d.length;u++){const p=d[u],m=["itemprop","property","name"].map(v=>p.getAttribute(v)).filter(v=>v?h.includes(v):!1);if(m.length&&m){const v=p.getAttribute("content");if(v)return v}}return""}function o(){let h=r("name","og:site_name","og:title","twitter:title");return h||(h=e.title),h}function i(){return r("description","og:description","twitter:description","keywords")}const s=o(),c=i(),f=t.origin,a=n();return{description:c,url:f,icons:a,name:s}}jo.getWindowMetadata=$d;const Td="0.1.1";function Pd(){return Td}class Ae extends Error{constructor(t,n={}){const r=(()=>{if(n.cause instanceof Ae){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),o=n.cause instanceof Ae&&n.cause.docsPath||n.docsPath,s=`https://oxlib.sh${o??""}`,c=[t||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||o?["",r?`Details: ${r}`:void 0,o?`See: ${s}`:void 0]:[]].filter(f=>typeof f=="string").join(`
15
+ `);super(c,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${Pd()}`}),this.cause=n.cause,this.details=r,this.docs=s,this.docsPath=o,this.shortMessage=t}walk(t){return rc(this,t)}}function rc(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?rc(e.cause,t):t?null:e}const En=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function vr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function xn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ct(e,...t){if(!vr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function oc(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");xn(e.outputLen),xn(e.blockLen)}function vn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function ic(e,t){ct(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ld(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function _t(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ho(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tt(e,t){return e<<32-t|e>>>t}const qd=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function jd(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Hd(e){for(let t=0;t<e.length;t++)e[t]=jd(e[t]);return e}const sc=qd?e=>e:Hd,cc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Md=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bn(e){if(ct(e),cc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Md[e[n]];return t}const ft={_0:48,_9:57,A:65,F:70,a:97,f:102};function fc(e){if(e>=ft._0&&e<=ft._9)return e-ft._0;if(e>=ft.A&&e<=ft.F)return e-(ft.A-10);if(e>=ft.a&&e<=ft.f)return e-(ft.a-10)}function Br(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(cc)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=fc(e.charCodeAt(i)),c=fc(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function Mo(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Dr(e){return typeof e=="string"&&(e=Mo(e)),ct(e),e}function at(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];ct(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}class zo{}function Ar(e){const t=r=>e().update(Dr(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Or(e=32){if(En&&typeof En.getRandomValues=="function")return En.getRandomValues(new Uint8Array(e));if(En&&typeof En.randomBytes=="function")return Uint8Array.from(En.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function zd(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function kd(e,t,n){return e&t^~e&n}function Zd(e,t,n){return e&t^e&n^t&n}class ac extends zo{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Ho(this.buffer)}update(t){vn(this),t=Dr(t),ct(t);const{view:n,buffer:r,blockLen:o}=this,i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=Ho(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){vn(this),ic(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,_t(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;zd(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Ho(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const ut=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ye=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),me=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Sr=BigInt(2**32-1),uc=BigInt(32);function Vd(e,t=!1){return t?{h:Number(e&Sr),l:Number(e>>uc&Sr)}:{h:Number(e>>uc&Sr)|0,l:Number(e&Sr)|0}}function lc(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:s,l:c}=Vd(e[i],t);[r[i],o[i]]=[s,c]}return[r,o]}const dc=(e,t,n)=>e>>>n,hc=(e,t,n)=>e<<32-n|t>>>n,Dn=(e,t,n)=>e>>>n|t<<32-n,An=(e,t,n)=>e<<32-n|t>>>n,_r=(e,t,n)=>e<<64-n|t>>>n-32,Ir=(e,t,n)=>e>>>n-32|t<<64-n,Gd=(e,t,n)=>e<<n|t>>>32-n,Kd=(e,t,n)=>t<<n|e>>>32-n,Yd=(e,t,n)=>t<<n-32|e>>>64-n,Wd=(e,t,n)=>e<<n-32|t>>>64-n;function lt(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const Xd=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Jd=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Qd=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),e0=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,t0=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),n0=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,r0=BigInt(0),Kn=BigInt(1),o0=BigInt(2),i0=BigInt(7),s0=BigInt(256),c0=BigInt(113),bc=[],gc=[],wc=[];for(let e=0,t=Kn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],bc.push(2*(5*r+n)),gc.push((e+1)*(e+2)/2%64);let o=r0;for(let i=0;i<7;i++)t=(t<<Kn^(t>>i0)*c0)%s0,t&o0&&(o^=Kn<<(Kn<<BigInt(i))-Kn);wc.push(o)}const pc=lc(wc,!0),f0=pc[0],a0=pc[1],yc=(e,t,n)=>n>32?Yd(e,t,n):Gd(e,t,n),mc=(e,t,n)=>n>32?Wd(e,t,n):Kd(e,t,n);function u0(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,f=(s+2)%10,a=n[f],l=n[f+1],h=yc(a,l,1)^n[c],d=mc(a,l,1)^n[c+1];for(let u=0;u<50;u+=10)e[s+u]^=h,e[s+u+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=gc[s],f=yc(o,i,c),a=mc(o,i,c),l=bc[s];o=e[l],i=e[l+1],e[l]=f,e[l+1]=a}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=f0[r],e[1]^=a0[r]}_t(n)}class ko extends zo{constructor(t,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,xn(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ld(this.state)}clone(){return this._cloneInto()}keccak(){sc(this.state32),u0(this.state32,this.rounds),sc(this.state32),this.posOut=0,this.pos=0}update(t){vn(this),t=Dr(t),ct(t);const{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let c=0;c<s;c++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){vn(this,!1),ct(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return xn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(ic(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,_t(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new ko(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}const l0=(e,t,n)=>Ar(()=>new ko(t,e,n)),d0=l0(1,136,256/8),h0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),It=new Uint32Array(64);class b0 extends ac{constructor(t=32){super(64,t,8,!1),this.A=ut[0]|0,this.B=ut[1]|0,this.C=ut[2]|0,this.D=ut[3]|0,this.E=ut[4]|0,this.F=ut[5]|0,this.G=ut[6]|0,this.H=ut[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:f}=this;return[t,n,r,o,i,s,c,f]}set(t,n,r,o,i,s,c,f){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,n){for(let h=0;h<16;h++,n+=4)It[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const d=It[h-15],u=It[h-2],p=tt(d,7)^tt(d,18)^d>>>3,m=tt(u,17)^tt(u,19)^u>>>10;It[h]=m+It[h-7]+p+It[h-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:f,G:a,H:l}=this;for(let h=0;h<64;h++){const d=tt(c,6)^tt(c,11)^tt(c,25),u=l+d+kd(c,f,a)+h0[h]+It[h]|0,m=(tt(r,2)^tt(r,13)^tt(r,22))+Zd(r,o,i)|0;l=a,a=f,f=c,c=s+u|0,s=i,i=o,o=r,r=u+m|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,l=l+this.H|0,this.set(r,o,i,s,c,f,a,l)}roundClean(){_t(It)}destroy(){this.set(0,0,0,0,0,0,0,0),_t(this.buffer)}}const Ec=lc(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),g0=Ec[0],w0=Ec[1],Nt=new Uint32Array(80),Ft=new Uint32Array(80);class xc extends ac{constructor(t=64){super(128,t,16,!1),this.Ah=me[0]|0,this.Al=me[1]|0,this.Bh=me[2]|0,this.Bl=me[3]|0,this.Ch=me[4]|0,this.Cl=me[5]|0,this.Dh=me[6]|0,this.Dl=me[7]|0,this.Eh=me[8]|0,this.El=me[9]|0,this.Fh=me[10]|0,this.Fl=me[11]|0,this.Gh=me[12]|0,this.Gl=me[13]|0,this.Hh=me[14]|0,this.Hl=me[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Nt[D]=t.getUint32(n),Ft[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Nt[D-15]|0,C=Ft[D-15]|0,P=Dn(x,C,1)^Dn(x,C,8)^dc(x,C,7),q=An(x,C,1)^An(x,C,8)^hc(x,C,7),L=Nt[D-2]|0,I=Ft[D-2]|0,k=Dn(L,I,19)^_r(L,I,61)^dc(L,I,6),H=An(L,I,19)^Ir(L,I,61)^hc(L,I,6),E=Qd(q,H,Ft[D-7],Ft[D-16]),g=e0(E,P,k,Nt[D-7],Nt[D-16]);Nt[D]=g|0,Ft[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:$}=this;for(let D=0;D<80;D++){const x=Dn(h,d,14)^Dn(h,d,18)^_r(h,d,41),C=An(h,d,14)^An(h,d,18)^Ir(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=t0($,C,q,w0[D],Ft[D]),I=n0(L,_,x,P,g0[D],Nt[D]),k=L|0,H=Dn(r,o,28)^_r(r,o,34)^_r(r,o,39),E=An(r,o,28)^Ir(r,o,34)^Ir(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,$=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=lt(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=Xd(k,E,y);r=Jd(b,I,H,g),o=b|0}({h:r,l:o}=lt(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=lt(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=lt(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=lt(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=lt(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=lt(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=lt(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:$}=lt(this.Hh|0,this.Hl|0,_|0,$|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,$)}roundClean(){_t(Nt,Ft)}destroy(){_t(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class p0 extends xc{constructor(){super(48),this.Ah=ye[0]|0,this.Al=ye[1]|0,this.Bh=ye[2]|0,this.Bl=ye[3]|0,this.Ch=ye[4]|0,this.Cl=ye[5]|0,this.Dh=ye[6]|0,this.Dl=ye[7]|0,this.Eh=ye[8]|0,this.El=ye[9]|0,this.Fh=ye[10]|0,this.Fl=ye[11]|0,this.Gh=ye[12]|0,this.Gl=ye[13]|0,this.Hh=ye[14]|0,this.Hl=ye[15]|0}}const On=Ar(()=>new b0),y0=Ar(()=>new xc),m0=Ar(()=>new p0);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Zo=BigInt(0),Nr=BigInt(1);function Yn(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ct(e){if(!Yn(e))throw new Error("Uint8Array expected")}function Wn(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Fr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function vc(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Zo:BigInt("0x"+e)}const Bc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",E0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function sn(e){if(Ct(e),Bc)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=E0[e[n]];return t}const dt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Dc(e){if(e>=dt._0&&e<=dt._9)return e-dt._0;if(e>=dt.A&&e<=dt.F)return e-(dt.A-10);if(e>=dt.a&&e<=dt.f)return e-(dt.a-10)}function Cr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Bc)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=Dc(e.charCodeAt(i)),c=Dc(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function Oe(e){return vc(sn(e))}function Ac(e){return Ct(e),vc(sn(Uint8Array.from(e).reverse()))}function ue(e,t){return Cr(e.toString(16).padStart(t*2,"0"))}function Oc(e,t){return ue(e,t).reverse()}function Ee(e,t,n){let r;if(typeof t=="string")try{r=Cr(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Yn(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function ce(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Ct(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}function Vo(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}const Go=e=>typeof e=="bigint"&&Zo<=e;function Ko(e,t,n){return Go(e)&&Go(t)&&Go(n)&&t<=e&&e<n}function Sn(e,t,n,r){if(!Ko(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Xn(e){let t;for(t=0;e>Zo;e>>=Nr,t+=1);return t}function x0(e,t){return e>>BigInt(t)&Nr}const cn=e=>(Nr<<BigInt(e))-Nr,Yo=e=>new Uint8Array(e),Sc=e=>Uint8Array.from(e);function v0(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=Yo(e),o=Yo(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},c=(...h)=>n(o,r,...h),f=(h=Yo(0))=>{o=c(Sc([0]),h),r=c(),h.length!==0&&(o=c(Sc([1]),h),r=c())},a=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const d=[];for(;h<t;){r=c();const u=r.slice();d.push(u),h+=r.length}return ce(...d)};return(h,d)=>{s(),f(h);let u;for(;!(u=d(a()));)f();return s(),u}}const B0={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Yn(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Jn(e,t,n={}){const r=(o,i,s)=>{const c=B0[i];if(typeof c!="function")throw new Error("invalid validator function");const f=e[o];if(!(s&&f===void 0)&&!c(f,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+f)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}const _c=()=>{throw new Error("not implemented")};function Wo(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}function D0(e,t){if(Uc(e)>t)throw new j0({givenSize:Uc(e),maxSize:t})}const ht={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ic(e){if(e>=ht.zero&&e<=ht.nine)return e-ht.zero;if(e>=ht.A&&e<=ht.F)return e-(ht.A-10);if(e>=ht.a&&e<=ht.f)return e-(ht.a-10)}function A0(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;if(e.length>r)throw new H0({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let i=0;i<r;i++){const s=n==="right";o[s?i:r-i-1]=e[s?i:e.length-i-1]}return o}function Xo(e,t){if(Qo(e)>t)throw new C0({givenSize:Qo(e),maxSize:t})}function Nc(e,t={}){const{dir:n,size:r=32}=t;if(r===0)return e;const o=e.replace("0x","");if(o.length>r*2)throw new U0({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o[n==="right"?"padEnd":"padStart"](r*2,"0")}`}const O0=new TextEncoder,S0=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Fc(...e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function _0(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(Xo(n,t.size),Ur(n,t.size)):n}function Cc(e,t={}){let n="";for(let o=0;o<e.length;o++)n+=S0[e[o]];const r=`0x${n}`;return typeof t.size=="number"?(Xo(r,t.size),Jo(r,t.size)):r}function I0(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof i=="bigint"&&n?-i-1n:0;if(i&&o>i||o<s){const a=typeof e=="bigint"?"n":"";throw new F0({max:i?`${i}${a}`:void 0,min:`${s}${a}`,signed:n,size:r,value:`${e}${a}`})}const f=`0x${(n&&o<0?(1n<<BigInt(r*8))+BigInt(o):o).toString(16)}`;return r?Ur(f,r):f}function N0(e,t={}){return Cc(O0.encode(e),t)}function Ur(e,t){return Nc(e,{dir:"left",size:t})}function Jo(e,t){return Nc(e,{dir:"right",size:t})}function Qo(e){return Math.ceil((e.length-2)/2)}class F0 extends Ae{constructor({max:t,min:n,signed:r,size:o,value:i}){super(`Number \`${i}\` is not in safe${o?` ${o*8}-bit`:""}${r?" signed":" unsigned"} integer range ${t?`(\`${n}\` to \`${t}\`)`:`(above \`${n}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class C0 extends Ae{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class U0 extends Ae{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}const R0=new TextEncoder;function $0(e){return e instanceof Uint8Array?e:typeof e=="string"?P0(e):T0(e)}function T0(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function P0(e,t={}){const{size:n}=t;let r=e;n&&(Xo(e,n),r=Jo(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const i=o.length/2,s=new Uint8Array(i);for(let c=0,f=0;c<i;c++){const a=Ic(o.charCodeAt(f++)),l=Ic(o.charCodeAt(f++));if(a===void 0||l===void 0)throw new Ae(`Invalid byte sequence ("${o[f-2]}${o[f-1]}" in "${o}").`);s[c]=a*16+l}return s}function L0(e,t={}){const{size:n}=t,r=R0.encode(e);return typeof n=="number"?(D0(r,n),q0(r,n)):r}function q0(e,t){return A0(e,{dir:"right",size:t})}function Uc(e){return e.length}class j0 extends Ae{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed \`${n}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class H0 extends Ae{constructor({size:t,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}function M0(e,t={}){const{as:n=typeof e=="string"?"Hex":"Bytes"}=t,r=d0($0(e));return n==="Bytes"?r:Cc(r)}class z0 extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const ei={checksum:new z0(8192)}.checksum,k0=/^0x[a-fA-F0-9]{40}$/;function Rc(e,t={}){const{strict:n=!0}=t;if(!k0.test(e))throw new $c({address:e,cause:new V0});if(n){if(e.toLowerCase()===e)return;if(Z0(e)!==e)throw new $c({address:e,cause:new G0})}}function Z0(e){if(ei.has(e))return ei.get(e);Rc(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=M0(L0(t),{as:"Bytes"}),r=t.split("");for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&r[i]&&(r[i]=r[i].toUpperCase()),(n[i>>1]&15)>=8&&r[i+1]&&(r[i+1]=r[i+1].toUpperCase());const o=`0x${r.join("")}`;return ei.set(e,o),o}class $c extends Ae{constructor({address:t,cause:n}){super(`Address "${t}" is invalid.`,{cause:n}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class V0 extends Ae{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class G0 extends Ae{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const K0=/^(.*)\[([0-9]*)\]$/,Y0=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,W0=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function ti(e,t){if(e.length!==t.length)throw new J0({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r];n.push(ti.encode(o,i))}return Fc(...n)}(function(e){function t(n,r,o=!1){if(n==="address"){const f=r;return Rc(f),Ur(f.toLowerCase(),o?32:0)}if(n==="string")return N0(r);if(n==="bytes")return r;if(n==="bool")return Ur(_0(r),o?32:1);const i=n.match(W0);if(i){const[f,a,l="256"]=i,h=Number.parseInt(l,10)/8;return I0(r,{size:o?32:h,signed:a==="int"})}const s=n.match(Y0);if(s){const[f,a]=s;if(Number.parseInt(a,10)!==(r.length-2)/2)throw new X0({expectedSize:Number.parseInt(a,10),value:r});return Jo(r,o?32:0)}const c=n.match(K0);if(c&&Array.isArray(r)){const[f,a]=c,l=[];for(let h=0;h<r.length;h++)l.push(t(a,r[h],!0));return l.length===0?"0x":Fc(...l)}throw new Q0(n)}e.encode=t})(ti||(ti={}));class X0 extends Ae{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${Qo(n)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class J0 extends Ae{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${n}`].join(`
16
+ `)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Q0 extends Ae{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class Tc extends zo{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,oc(t);const r=Dr(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),_t(i)}update(t){return vn(this),this.iHash.update(t),this}digestInto(t){vn(this),ct(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ni=(e,t,n)=>new Tc(e,t).update(n).digest();ni.create=(e,t)=>new Tc(e,t);const Ce=BigInt(0),Se=BigInt(1),fn=BigInt(2),eh=BigInt(3),Pc=BigInt(4),Lc=BigInt(5),qc=BigInt(8);function _e(e,t){const n=e%t;return n>=Ce?n:t+n}function Me(e,t,n){let r=e;for(;t-- >Ce;)r*=r,r%=n;return r}function ri(e,t){if(e===Ce)throw new Error("invert: expected non-zero number");if(t<=Ce)throw new Error("invert: expected positive modulus, got "+t);let n=_e(e,t),r=t,o=Ce,i=Se;for(;n!==Ce;){const c=r/n,f=r%n,a=o-i*c;r=n,n=f,o=i,i=a}if(r!==Se)throw new Error("invert: does not exist");return _e(o,t)}function jc(e,t){const n=(e.ORDER+Se)/Pc,r=e.pow(t,n);if(!e.eql(e.sqr(r),t))throw new Error("Cannot find square root");return r}function th(e,t){const n=(e.ORDER-Lc)/qc,r=e.mul(t,fn),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,fn),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function nh(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-Se,n=0;for(;t%fn===Ce;)t/=fn,n++;let r=fn;const o=Ut(e);for(;$r(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return jc;let i=o.pow(r,t);const s=(t+Se)/fn;return function(f,a){if(f.is0(a))return a;if($r(f,a)!==1)throw new Error("Cannot find square root");let l=n,h=f.mul(f.ONE,i),d=f.pow(a,t),u=f.pow(a,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let p=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(p++,m=f.sqr(m),p===l)throw new Error("Cannot find square root");const v=Se<<BigInt(l-p-1),_=f.pow(h,v);l=p,h=f.sqr(_),d=f.mul(d,h),u=f.mul(u,_)}return u}}function rh(e){return e%Pc===eh?jc:e%qc===Lc?th:nh(e)}const oh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Hc(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=oh.reduce((r,o)=>(r[o]="function",r),t);return Jn(e,n)}function Rr(e,t,n){if(n<Ce)throw new Error("invalid exponent, negatives unsupported");if(n===Ce)return e.ONE;if(n===Se)return t;let r=e.ONE,o=t;for(;n>Ce;)n&Se&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Se;return r}function an(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function $r(e,t){const n=(e.ORDER-Se)/fn,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mc(e,t){t!==void 0&&xn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ut(e,t,n=!1,r={}){if(e<=Ce)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:i}=Mc(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const c=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:i,MASK:cn(o),ZERO:Ce,ONE:Se,create:f=>_e(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return Ce<=f&&f<e},is0:f=>f===Ce,isOdd:f=>(f&Se)===Se,neg:f=>_e(-f,e),eql:(f,a)=>f===a,sqr:f=>_e(f*f,e),add:(f,a)=>_e(f+a,e),sub:(f,a)=>_e(f-a,e),mul:(f,a)=>_e(f*a,e),pow:(f,a)=>Rr(c,f,a),div:(f,a)=>_e(f*ri(a,e),e),sqrN:f=>f*f,addN:(f,a)=>f+a,subN:(f,a)=>f-a,mulN:(f,a)=>f*a,inv:f=>ri(f,e),sqrt:r.sqrt||(f=>(s||(s=rh(e)),s(c,f))),toBytes:f=>n?Oc(f,i):ue(f,i),fromBytes:f=>{if(f.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+f.length);return n?Ac(f):Oe(f)},invertBatch:f=>an(c,f),cmov:(f,a,l)=>l?a:f});return Object.freeze(c)}function zc(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function oi(e){const t=zc(e);return t+Math.ceil(t/2)}function kc(e,t,n=!1){const r=e.length,o=zc(t),i=oi(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?Ac(e):Oe(e),c=_e(s,t-Se)+Se;return n?Oc(c,o):ue(c,o)}const Zc=BigInt(0),ii=BigInt(1);function si(e,t){const n=t.negate();return e?n:t}function Vc(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ci(e,t){Vc(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=cn(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Gc(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=ii);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function ih(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function sh(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const fi=new WeakMap,Kc=new WeakMap;function ai(e){return Kc.get(e)||1}function ch(e,t){return{constTimeNegate:si,hasPrecomputes(n){return ai(n)!==1},unsafeLadder(n,r,o=e.ZERO){let i=n;for(;r>Zc;)r&ii&&(o=o.add(i)),i=i.double(),r>>=ii;return o},precomputeWindow(n,r){const{windows:o,windowSize:i}=ci(r,t),s=[];let c=n,f=c;for(let a=0;a<o;a++){f=c,s.push(f);for(let l=1;l<i;l++)f=f.add(c),s.push(f);c=f.double()}return s},wNAF(n,r,o){let i=e.ZERO,s=e.BASE;const c=ci(n,t);for(let f=0;f<c.windows;f++){const{nextN:a,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:p}=Gc(o,f,c);o=a,h?s=s.add(si(u,r[p])):i=i.add(si(d,r[l]))}return{p:i,f:s}},wNAFUnsafe(n,r,o,i=e.ZERO){const s=ci(n,t);for(let c=0;c<s.windows&&o!==Zc;c++){const{nextN:f,offset:a,isZero:l,isNeg:h}=Gc(o,c,s);if(o=f,!l){const d=r[a];i=i.add(h?d.negate():d)}}return i},getPrecomputes(n,r,o){let i=fi.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&fi.set(r,o(i))),i},wNAFCached(n,r,o){const i=ai(n);return this.wNAF(i,this.getPrecomputes(i,n,o),r)},wNAFCachedUnsafe(n,r,o,i){const s=ai(n);return s===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,n,o),r,i)},setWindowSize(n,r){Vc(r,t),Kc.set(n,r),fi.delete(n)}}}function fh(e,t,n,r){ih(n,e),sh(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=Xn(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=cn(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Yc(e){return Hc(e.Fp),Jn(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Mc(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Wc(e){e.lowS!==void 0&&Wn("lowS",e.lowS),e.prehash!==void 0&&Wn("prehash",e.prehash)}function ah(e){const t=Yc(e);Jn(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}class uh extends Error{constructor(t=""){super(t)}}const bt={Err:uh,_tlv:{encode:(e,t)=>{const{Err:n}=bt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=Fr(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Fr(o.length/2|128):"";return Fr(e)+i+o+t},decode(e,t){const{Err:n}=bt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=bt;if(e<Ge)throw new t("integer: negative integers are not allowed");let n=Fr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=bt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Oe(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=bt,o=Ee("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=bt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}};function ui(e,t){return sn(ue(e,t))}const Ge=BigInt(0),ne=BigInt(1),Rt=BigInt(2),Qn=BigInt(3),li=BigInt(4);function di(e){const t=ah(e),{Fp:n}=t,r=Ut(t.n,t.nBitLength),o=t.toBytes||((D,x,C)=>{const P=x.toAffine();return ce(Uint8Array.from([4]),n.toBytes(P.x),n.toBytes(P.y))}),i=t.fromBytes||(D=>{const x=D.subarray(1),C=n.fromBytes(x.subarray(0,n.BYTES)),P=n.fromBytes(x.subarray(n.BYTES,2*n.BYTES));return{x:C,y:P}});function s(D){const{a:x,b:C}=t,P=n.sqr(D),q=n.mul(P,D);return n.add(n.add(q,n.mul(D,x)),C)}function c(D,x){const C=n.sqr(x),P=s(D);return n.eql(C,P)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const f=n.mul(n.pow(t.a,Qn),li),a=n.mul(n.sqr(t.b),BigInt(27));if(n.is0(n.add(f,a)))throw new Error("bad curve params: a or b");function l(D){return Ko(D,ne,t.n)}function h(D){const{allowedPrivateKeyLengths:x,nByteLength:C,wrapPrivateKey:P,n:q}=t;if(x&&typeof D!="bigint"){if(Yn(D)&&(D=sn(D)),typeof D!="string"||!x.includes(D.length))throw new Error("invalid private key");D=D.padStart(C*2,"0")}let L;try{L=typeof D=="bigint"?D:Oe(Ee("private key",D,C))}catch{throw new Error("invalid private key, expected hex or "+C+" bytes, got "+typeof D)}return P&&(L=_e(L,q)),Sn("private key",L,ne,q),L}function d(D){if(!(D instanceof m))throw new Error("ProjectivePoint expected")}const u=Wo((D,x)=>{const{px:C,py:P,pz:q}=D;if(n.eql(q,n.ONE))return{x:C,y:P};const L=D.is0();x==null&&(x=L?n.ONE:n.inv(q));const I=n.mul(C,x),k=n.mul(P,x),H=n.mul(q,x);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(H,n.ONE))throw new Error("invZ was invalid");return{x:I,y:k}}),p=Wo(D=>{if(D.is0()){if(t.allowInfinityPoint&&!n.is0(D.py))return;throw new Error("bad point: ZERO")}const{x,y:C}=D.toAffine();if(!n.isValid(x)||!n.isValid(C))throw new Error("bad point: x or y not FE");if(!c(x,C))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(x,C,P){if(x==null||!n.isValid(x))throw new Error("x required");if(C==null||!n.isValid(C)||n.is0(C))throw new Error("y required");if(P==null||!n.isValid(P))throw new Error("z required");this.px=x,this.py=C,this.pz=P,Object.freeze(this)}static fromAffine(x){const{x:C,y:P}=x||{};if(!x||!n.isValid(C)||!n.isValid(P))throw new Error("invalid affine point");if(x instanceof m)throw new Error("projective point not allowed");const q=L=>n.eql(L,n.ZERO);return q(C)&&q(P)?m.ZERO:new m(C,P,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(x){const C=an(n,x.map(P=>P.pz));return x.map((P,q)=>P.toAffine(C[q])).map(m.fromAffine)}static fromHex(x){const C=m.fromAffine(i(Ee("pointHex",x)));return C.assertValidity(),C}static fromPrivateKey(x){return m.BASE.multiply(h(x))}static msm(x,C){return fh(m,r,x,C)}_setWindowSize(x){$.setWindowSize(this,x)}assertValidity(){p(this)}hasEvenY(){const{y:x}=this.toAffine();if(n.isOdd)return!n.isOdd(x);throw new Error("Field doesn't support isOdd")}equals(x){d(x);const{px:C,py:P,pz:q}=this,{px:L,py:I,pz:k}=x,H=n.eql(n.mul(C,k),n.mul(L,q)),E=n.eql(n.mul(P,k),n.mul(I,q));return H&&E}negate(){return new m(this.px,n.neg(this.py),this.pz)}double(){const{a:x,b:C}=t,P=n.mul(C,Qn),{px:q,py:L,pz:I}=this;let k=n.ZERO,H=n.ZERO,E=n.ZERO,g=n.mul(q,q),y=n.mul(L,L),b=n.mul(I,I),w=n.mul(q,L);return w=n.add(w,w),E=n.mul(q,I),E=n.add(E,E),k=n.mul(x,E),H=n.mul(P,b),H=n.add(k,H),k=n.sub(y,H),H=n.add(y,H),H=n.mul(k,H),k=n.mul(w,k),E=n.mul(P,E),b=n.mul(x,b),w=n.sub(g,b),w=n.mul(x,w),w=n.add(w,E),E=n.add(g,g),g=n.add(E,g),g=n.add(g,b),g=n.mul(g,w),H=n.add(H,g),b=n.mul(L,I),b=n.add(b,b),g=n.mul(b,w),k=n.sub(k,g),E=n.mul(b,y),E=n.add(E,E),E=n.add(E,E),new m(k,H,E)}add(x){d(x);const{px:C,py:P,pz:q}=this,{px:L,py:I,pz:k}=x;let H=n.ZERO,E=n.ZERO,g=n.ZERO;const y=t.a,b=n.mul(t.b,Qn);let w=n.mul(C,L),B=n.mul(P,I),A=n.mul(q,k),O=n.add(C,P),S=n.add(L,I);O=n.mul(O,S),S=n.add(w,B),O=n.sub(O,S),S=n.add(C,q);let N=n.add(L,k);return S=n.mul(S,N),N=n.add(w,A),S=n.sub(S,N),N=n.add(P,q),H=n.add(I,k),N=n.mul(N,H),H=n.add(B,A),N=n.sub(N,H),g=n.mul(y,S),H=n.mul(b,A),g=n.add(H,g),H=n.sub(B,g),g=n.add(B,g),E=n.mul(H,g),B=n.add(w,w),B=n.add(B,w),A=n.mul(y,A),S=n.mul(b,S),B=n.add(B,A),A=n.sub(w,A),A=n.mul(y,A),S=n.add(S,A),w=n.mul(B,S),E=n.add(E,w),w=n.mul(N,S),H=n.mul(O,H),H=n.sub(H,w),w=n.mul(O,B),g=n.mul(N,g),g=n.add(g,w),new m(H,E,g)}subtract(x){return this.add(x.negate())}is0(){return this.equals(m.ZERO)}wNAF(x){return $.wNAFCached(this,x,m.normalizeZ)}multiplyUnsafe(x){const{endo:C,n:P}=t;Sn("scalar",x,Ge,P);const q=m.ZERO;if(x===Ge)return q;if(this.is0()||x===ne)return this;if(!C||$.hasPrecomputes(this))return $.wNAFCachedUnsafe(this,x,m.normalizeZ);let{k1neg:L,k1:I,k2neg:k,k2:H}=C.splitScalar(x),E=q,g=q,y=this;for(;I>Ge||H>Ge;)I&ne&&(E=E.add(y)),H&ne&&(g=g.add(y)),y=y.double(),I>>=ne,H>>=ne;return L&&(E=E.negate()),k&&(g=g.negate()),g=new m(n.mul(g.px,C.beta),g.py,g.pz),E.add(g)}multiply(x){const{endo:C,n:P}=t;Sn("scalar",x,ne,P);let q,L;if(C){const{k1neg:I,k1:k,k2neg:H,k2:E}=C.splitScalar(x);let{p:g,f:y}=this.wNAF(k),{p:b,f:w}=this.wNAF(E);g=$.constTimeNegate(I,g),b=$.constTimeNegate(H,b),b=new m(n.mul(b.px,C.beta),b.py,b.pz),q=g.add(b),L=y.add(w)}else{const{p:I,f:k}=this.wNAF(x);q=I,L=k}return m.normalizeZ([q,L])[0]}multiplyAndAddUnsafe(x,C,P){const q=m.BASE,L=(k,H)=>H===Ge||H===ne||!k.equals(q)?k.multiplyUnsafe(H):k.multiply(H),I=L(this,C).add(L(x,P));return I.is0()?void 0:I}toAffine(x){return u(this,x)}isTorsionFree(){const{h:x,isTorsionFree:C}=t;if(x===ne)return!0;if(C)return C(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:x,clearCofactor:C}=t;return x===ne?this:C?C(m,this):this.multiplyUnsafe(t.h)}toRawBytes(x=!0){return Wn("isCompressed",x),this.assertValidity(),o(m,this,x)}toHex(x=!0){return Wn("isCompressed",x),sn(this.toRawBytes(x))}}m.BASE=new m(t.Gx,t.Gy,n.ONE),m.ZERO=new m(n.ZERO,n.ONE,n.ZERO);const{endo:v,nBitLength:_}=t,$=ch(m,v?Math.ceil(_/2):_);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:h,weierstrassEquation:s,isWithinCurveOrder:l}}function lh(e){const t=Yc(e);return Jn(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function dh(e){const t=lh(e),{Fp:n,n:r,nByteLength:o,nBitLength:i}=t,s=n.BYTES+1,c=2*n.BYTES+1;function f(b){return _e(b,r)}function a(b){return ri(b,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:d,isWithinCurveOrder:u}=di({...t,toBytes(b,w,B){const A=w.toAffine(),O=n.toBytes(A.x),S=ce;return Wn("isCompressed",B),B?S(Uint8Array.from([w.hasEvenY()?2:3]),O):S(Uint8Array.from([4]),O,n.toBytes(A.y))},fromBytes(b){const w=b.length,B=b[0],A=b.subarray(1);if(w===s&&(B===2||B===3)){const O=Oe(A);if(!Ko(O,ne,n.ORDER))throw new Error("Point is not on curve");const S=d(O);let N;try{N=n.sqrt(S)}catch(T){const F=T instanceof Error?": "+T.message:"";throw new Error("Point is not on curve"+F)}const R=(N&ne)===ne;return(B&1)===1!==R&&(N=n.neg(N)),{x:O,y:N}}else if(w===c&&B===4){const O=n.fromBytes(A.subarray(0,n.BYTES)),S=n.fromBytes(A.subarray(n.BYTES,2*n.BYTES));return{x:O,y:S}}else{const O=s,S=c;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+S+", got "+w)}}});function p(b){const w=r>>ne;return b>w}function m(b){return p(b)?f(-b):b}const v=(b,w,B)=>Oe(b.slice(w,B));class _{constructor(w,B,A){Sn("r",w,ne,r),Sn("s",B,ne,r),this.r=w,this.s=B,A!=null&&(this.recovery=A),Object.freeze(this)}static fromCompact(w){const B=o;return w=Ee("compactSignature",w,B*2),new _(v(w,0,B),v(w,B,2*B))}static fromDER(w){const{r:B,s:A}=bt.toSig(Ee("DER",w));return new _(B,A)}assertValidity(){}addRecoveryBit(w){return new _(this.r,this.s,w)}recoverPublicKey(w){const{r:B,s:A,recovery:O}=this,S=q(Ee("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");const N=O===2||O===3?B+t.n:B;if(N>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const R=(O&1)===0?"02":"03",U=l.fromHex(R+ui(N,n.BYTES)),T=a(N),F=f(-S*T),j=f(A*T),M=l.BASE.multiplyAndAddUnsafe(U,F,j);if(!M)throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new _(this.r,f(-this.s),this.recovery):this}toDERRawBytes(){return Cr(this.toDERHex())}toDERHex(){return bt.hexFromSig(this)}toCompactRawBytes(){return Cr(this.toCompactHex())}toCompactHex(){const w=o;return ui(this.r,w)+ui(this.s,w)}}const $={isValidPrivateKey(b){try{return h(b),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{const b=oi(t.n);return kc(t.randomBytes(b),t.n)},precompute(b=8,w=l.BASE){return w._setWindowSize(b),w.multiply(BigInt(3)),w}};function D(b,w=!0){return l.fromPrivateKey(b).toRawBytes(w)}function x(b){if(typeof b=="bigint")return!1;if(b instanceof l)return!0;const B=Ee("key",b).length,A=n.BYTES,O=A+1,S=2*A+1;if(!(t.allowedPrivateKeyLengths||o===O))return B===O||B===S}function C(b,w,B=!0){if(x(b)===!0)throw new Error("first arg must be private key");if(x(w)===!1)throw new Error("second arg must be public key");return l.fromHex(w).multiply(h(b)).toRawBytes(B)}const P=t.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const w=Oe(b),B=b.length*8-i;return B>0?w>>BigInt(B):w},q=t.bits2int_modN||function(b){return f(P(b))},L=cn(i);function I(b){return Sn("num < 2^"+i,b,Ge,L),ue(b,o)}function k(b,w,B=H){if(["recovered","canonical"].some(z=>z in B))throw new Error("sign() legacy options not supported");const{hash:A,randomBytes:O}=t;let{lowS:S,prehash:N,extraEntropy:R}=B;S==null&&(S=!0),b=Ee("msgHash",b),Wc(B),N&&(b=Ee("prehashed msgHash",A(b)));const U=q(b),T=h(w),F=[I(T),I(U)];if(R!=null&&R!==!1){const z=R===!0?O(n.BYTES):R;F.push(Ee("extraEntropy",z))}const j=ce(...F),M=U;function V(z){const Z=P(z);if(!u(Z))return;const W=a(Z),J=l.BASE.multiply(Z).toAffine(),ee=f(J.x);if(ee===Ge)return;const oe=f(W*f(M+ee*T));if(oe===Ge)return;let se=(J.x===ee?0:2)|Number(J.y&ne),Ot=oe;return S&&p(oe)&&(Ot=m(oe),se^=1),new _(ee,Ot,se)}return{seed:j,k2sig:V}}const H={lowS:t.lowS,prehash:!1},E={lowS:t.lowS,prehash:!1};function g(b,w,B=H){const{seed:A,k2sig:O}=k(b,w,B),S=t;return v0(S.hash.outputLen,S.nByteLength,S.hmac)(A,O)}l.BASE._setWindowSize(8);function y(b,w,B,A=E){const O=b;w=Ee("msgHash",w),B=Ee("publicKey",B);const{lowS:S,prehash:N,format:R}=A;if(Wc(A),"strict"in A)throw new Error("options.strict was renamed to lowS");if(R!==void 0&&R!=="compact"&&R!=="der")throw new Error("format must be compact or der");const U=typeof O=="string"||Yn(O),T=!U&&!R&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!U&&!T)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,j;try{if(T&&(F=new _(O.r,O.s)),U){try{R!=="compact"&&(F=_.fromDER(O))}catch(se){if(!(se instanceof bt.Err))throw se}!F&&R!=="der"&&(F=_.fromCompact(O))}j=l.fromHex(B)}catch{return!1}if(!F||S&&F.hasHighS())return!1;N&&(w=t.hash(w));const{r:M,s:V}=F,z=q(w),Z=a(V),W=f(z*Z),J=f(M*Z),ee=l.BASE.multiplyAndAddUnsafe(j,W,J)?.toAffine();return ee?f(ee.x)===M:!1}return{CURVE:t,getPublicKey:D,getSharedSecret:C,sign:g,verify:y,ProjectivePoint:l,Signature:_,utils:$}}function hh(e,t){const n=e.ORDER;let r=Ge;for(let p=n-ne;p%Rt===Ge;p/=Rt)r+=ne;const o=r,i=Rt<<o-ne-ne,s=i*Rt,c=(n-ne)/s,f=(c-ne)/Rt,a=s-ne,l=i,h=e.pow(t,c),d=e.pow(t,(c+ne)/Rt);let u=(p,m)=>{let v=h,_=e.pow(m,a),$=e.sqr(_);$=e.mul($,m);let D=e.mul(p,$);D=e.pow(D,f),D=e.mul(D,_),_=e.mul(D,m),$=e.mul(D,p);let x=e.mul($,_);D=e.pow(x,l);let C=e.eql(D,e.ONE);_=e.mul($,d),D=e.mul(x,v),$=e.cmov(_,$,C),x=e.cmov(D,x,C);for(let P=o;P>ne;P--){let q=P-Rt;q=Rt<<q-ne;let L=e.pow(x,q);const I=e.eql(L,e.ONE);_=e.mul($,v),v=e.mul(v,v),L=e.mul(x,v),$=e.cmov(_,$,I),x=e.cmov(L,x,I)}return{isValid:C,value:$}};if(e.ORDER%li===Qn){const p=(e.ORDER-Qn)/li,m=e.sqrt(e.neg(t));u=(v,_)=>{let $=e.sqr(_);const D=e.mul(v,_);$=e.mul($,D);let x=e.pow($,p);x=e.mul(x,D);const C=e.mul(x,m),P=e.mul(e.sqr(x),_),q=e.eql(P,v);let L=e.cmov(C,x,q);return{isValid:q,value:L}}}return u}function Xc(e,t){if(Hc(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=hh(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let o,i,s,c,f,a,l,h;o=e.sqr(r),o=e.mul(o,t.Z),i=e.sqr(o),i=e.add(i,o),s=e.add(i,e.ONE),s=e.mul(s,t.B),c=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),c=e.mul(c,t.A),i=e.sqr(s),a=e.sqr(c),f=e.mul(a,t.A),i=e.add(i,f),i=e.mul(i,s),a=e.mul(a,c),f=e.mul(a,t.B),i=e.add(i,f),l=e.mul(o,s);const{isValid:d,value:u}=n(i,a);h=e.mul(o,r),h=e.mul(h,u),l=e.cmov(l,s,d),h=e.cmov(h,u,d);const p=e.isOdd(r)===e.isOdd(h);h=e.cmov(e.neg(h),h,p);const m=an(e,[c],!0)[0];return l=e.mul(l,m),{x:l,y:h}}}function bh(e){return{hash:e,hmac:(t,...n)=>ni(e,t,at(...n)),randomBytes:Or}}function Tr(e,t){const n=r=>dh({...e,...bh(r)});return{...n(t),create:n}}const gh=Oe;function $t(e,t){if(er(e),er(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=e&255,e>>>=8;return new Uint8Array(n)}function wh(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function er(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function ph(e,t,n,r){Ct(e),Ct(t),er(n),t.length>255&&(t=r(ce(Vo("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:i}=r,s=Math.ceil(n/o);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const c=ce(t,$t(t.length,1)),f=$t(0,i),a=$t(n,2),l=new Array(s),h=r(ce(f,e,a,$t(0,1),c));l[0]=r(ce(h,$t(1,1),c));for(let u=1;u<=s;u++){const p=[wh(h,l[u-1]),$t(u+1,1),c];l[u]=r(ce(...p))}return ce(...l).slice(0,n)}function yh(e,t,n,r,o){if(Ct(e),Ct(t),er(n),t.length>255){const i=Math.ceil(2*r/8);t=o.create({dkLen:i}).update(Vo("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update($t(n,2)).update(t).update($t(t.length,1)).digest()}function Jc(e,t,n){Jn(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:o,m:i,hash:s,expand:c,DST:f}=n;Ct(e),er(t);const a=typeof f=="string"?Vo(f):f,l=r.toString(2).length,h=Math.ceil((l+o)/8),d=t*i*h;let u;if(c==="xmd")u=ph(e,a,d,s);else if(c==="xof")u=yh(e,a,d,o,s);else if(c==="_internal_pass")u=e;else throw new Error('expand must be "xmd" or "xof"');const p=new Array(t);for(let m=0;m<t;m++){const v=new Array(i);for(let _=0;_<i;_++){const $=h*(_+m*i),D=u.subarray($,$+h);v[_]=_e(gh(D),r)}p[m]=v}return p}function Qc(e,t){const n=t.map(r=>Array.from(r).reverse());return(r,o)=>{const[i,s,c,f]=n.map(h=>h.reduce((d,u)=>e.add(e.mul(d,r),u))),[a,l]=an(e,[s,f],!0);return r=e.mul(i,a),o=e.mul(o,e.mul(c,l)),{x:r,y:o}}}function ef(e,t,n){if(typeof t!="function")throw new Error("mapToCurve() must be defined");function r(i){return e.fromAffine(t(i))}function o(i){const s=i.clearCofactor();return s.equals(e.ZERO)?e.ZERO:(s.assertValidity(),s)}return{defaults:n,hashToCurve(i,s){const c=Jc(i,2,{...n,DST:n.DST,...s}),f=r(c[0]),a=r(c[1]);return o(f.add(a))},encodeToCurve(i,s){const c=Jc(i,1,{...n,DST:n.encodeDST,...s});return o(r(c[0]))},mapToCurve(i){if(!Array.isArray(i))throw new Error("expected array of bigints");for(const s of i)if(typeof s!="bigint")throw new Error("expected array of bigints");return o(r(i))}}}const tf=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nf=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),mh=BigInt(0),Eh=BigInt(1),hi=BigInt(2),rf=(e,t)=>(e+t/hi)/t;function xh(e){const t=tf,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,l=a*a*e%t,h=Me(l,n,t)*l%t,d=Me(h,n,t)*l%t,u=Me(d,hi,t)*a%t,p=Me(u,o,t)*u%t,m=Me(p,i,t)*p%t,v=Me(m,c,t)*m%t,_=Me(v,f,t)*v%t,$=Me(_,c,t)*m%t,D=Me($,n,t)*l%t,x=Me(D,s,t)*p%t,C=Me(x,r,t)*a%t,P=Me(C,hi,t);if(!bi.eql(bi.sqr(P),e))throw new Error("Cannot find square root");return P}const bi=Ut(tf,void 0,void 0,{sqrt:xh});Tr({a:mh,b:BigInt(7),Fp:bi,n:nf,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=nf,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Eh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),c=rf(i*e,t),f=rf(-r*e,t);let a=_e(e-c*n-f*o,t),l=_e(-c*r-f*i,t);const h=a>s,d=l>s;if(h&&(a=t-a),d&&(l=t-l),a>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}}},On),Object.freeze({1:0n,2:1n,3:2n,4:3n,5:4n,6:5n,7:6n,8:7n,9:8n,A:9n,B:10n,C:11n,D:12n,E:13n,F:14n,G:15n,H:16n,J:17n,K:18n,L:19n,M:20n,N:21n,P:22n,Q:23n,R:24n,S:25n,T:26n,U:27n,V:28n,W:29n,X:30n,Y:31n,Z:32n,a:33n,b:34n,c:35n,d:36n,e:37n,f:38n,g:39n,h:40n,i:41n,j:42n,k:43n,m:44n,n:45n,o:46n,p:47n,q:48n,r:49n,s:50n,t:51n,u:52n,v:53n,w:54n,x:55n,y:56n,z:57n}),Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)]),{...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t]))},ut.slice();const vh=BigInt(0),Pr=BigInt(1),of=BigInt(2),_n=BigInt(3);function Bh(e){const t=[];for(;e>Pr;e>>=Pr)(e&Pr)===vh?t.unshift(0):(e&_n)===_n?(t.unshift(-1),e+=Pr):t.unshift(1);return t}function Dh(e){const{Fp:t,Fr:n,Fp2:r,Fp6:o,Fp12:i}=e.fields,s=e.params.xNegative,c=e.params.twistType,f=di({n:n.ORDER,...e.G1}),a=Object.assign(f,ef(f.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),l=di({n:n.ORDER,...e.G2}),h=Object.assign(l,ef(l.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults}));let d;if(c==="multiplicative")d=(U,T,F,j,M,V)=>i.mul014(j,U,r.mul(T,M),r.mul(F,V));else if(c==="divisive")d=(U,T,F,j,M,V)=>i.mul034(j,r.mul(F,V),r.mul(T,M),U);else throw new Error("bls: unknown twist type");const u=r.div(r.ONE,r.mul(r.ONE,of));function p(U,T,F,j){const M=r.sqr(F),V=r.sqr(j),z=r.mulByB(r.mul(V,_n)),Z=r.mul(z,_n),W=r.sub(r.sub(r.sqr(r.add(F,j)),V),M),J=r.sub(z,M),ee=r.mul(r.sqr(T),_n),oe=r.neg(W);return U.push([J,ee,oe]),T=r.mul(r.mul(r.mul(r.sub(M,Z),T),F),u),F=r.sub(r.sqr(r.mul(r.add(M,Z),u)),r.mul(r.sqr(z),_n)),j=r.mul(M,W),{Rx:T,Ry:F,Rz:j}}function m(U,T,F,j,M,V){const z=r.sub(F,r.mul(V,j)),Z=r.sub(T,r.mul(M,j)),W=r.sub(r.mul(z,M),r.mul(Z,V)),J=r.neg(z),ee=Z;U.push([W,J,ee]);const oe=r.sqr(Z),se=r.mul(oe,Z),Ot=r.mul(oe,T),Ao=r.add(r.sub(se,r.mul(Ot,of)),r.mul(r.sqr(z),j));return T=r.mul(Z,Ao),F=r.sub(r.mul(r.sub(Ot,Ao),z),r.mul(se,F)),j=r.mul(j,se),{Rx:T,Ry:F,Rz:j}}const v=Bh(e.params.ateLoopSize),_=Wo(U=>{const T=U,{x:F,y:j}=T.toAffine(),M=F,V=j,z=r.neg(j);let Z=M,W=V,J=r.ONE;const ee=[];for(const oe of v){const se=[];({Rx:Z,Ry:W,Rz:J}=p(se,Z,W,J)),oe&&({Rx:Z,Ry:W,Rz:J}=m(se,Z,W,J,M,oe===-1?z:V)),ee.push(se)}if(e.postPrecompute){const oe=ee[ee.length-1];e.postPrecompute(Z,W,J,M,V,m.bind(null,oe))}return ee});function $(U,T=!1){let F=i.ONE;if(U.length){const j=U[0][0].length;for(let M=0;M<j;M++){F=i.sqr(F);for(const[V,z,Z]of U)for(const[W,J,ee]of V[M])F=d(W,J,ee,F,z,Z)}}return s&&(F=i.conjugate(F)),T?i.finalExponentiate(F):F}function D(U,T=!0){const F=[];a.ProjectivePoint.normalizeZ(U.map(({g1:j})=>j)),h.ProjectivePoint.normalizeZ(U.map(({g2:j})=>j));for(const{g1:j,g2:M}of U){if(j.equals(a.ProjectivePoint.ZERO)||M.equals(h.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");j.assertValidity(),M.assertValidity();const V=j.toAffine();F.push([_(M),V.x,V.y])}return $(F,T)}function x(U,T,F=!0){return D([{g1:U,g2:T}],F)}const C={randomPrivateKey:()=>{const U=oi(n.ORDER);return kc(e.randomBytes(U),n.ORDER)},calcPairingPrecomputes:_},{ShortSignature:P}=e.G1,{Signature:q}=e.G2;function L(U){return U instanceof a.ProjectivePoint?U:a.ProjectivePoint.fromHex(U)}function I(U,T){return U instanceof a.ProjectivePoint?U:a.hashToCurve(Ee("point",U),T)}function k(U){return U instanceof h.ProjectivePoint?U:q.fromHex(U)}function H(U,T){return U instanceof h.ProjectivePoint?U:h.hashToCurve(Ee("point",U),T)}function E(U){return a.ProjectivePoint.fromPrivateKey(U).toRawBytes(!0)}function g(U){return h.ProjectivePoint.fromPrivateKey(U).toRawBytes(!0)}function y(U,T,F){const j=H(U,F);j.assertValidity();const M=j.multiply(a.normPrivateKeyToScalar(T));return U instanceof h.ProjectivePoint?M:q.toRawBytes(M)}function b(U,T,F){const j=I(U,F);j.assertValidity();const M=j.multiply(a.normPrivateKeyToScalar(T));return U instanceof a.ProjectivePoint?M:P.toRawBytes(M)}function w(U,T,F,j){const M=L(F),V=H(T,j),z=a.ProjectivePoint.BASE,Z=k(U),W=D([{g1:M.negate(),g2:V},{g1:z,g2:Z}]);return i.eql(W,i.ONE)}function B(U,T,F,j){const M=k(F),V=I(T,j),z=h.ProjectivePoint.BASE,Z=L(U),W=D([{g1:V,g2:M},{g1:Z,g2:z.negate()}]);return i.eql(W,i.ONE)}function A(U){if(!Array.isArray(U)||U.length===0)throw new Error("expected non-empty array")}function O(U){A(U);const F=U.map(L).reduce((j,M)=>j.add(M),a.ProjectivePoint.ZERO);return U[0]instanceof a.ProjectivePoint?(F.assertValidity(),F):F.toRawBytes(!0)}function S(U){A(U);const F=U.map(k).reduce((j,M)=>j.add(M),h.ProjectivePoint.ZERO);return U[0]instanceof h.ProjectivePoint?(F.assertValidity(),F):q.toRawBytes(F)}function N(U){A(U);const F=U.map(L).reduce((j,M)=>j.add(M),a.ProjectivePoint.ZERO);return U[0]instanceof a.ProjectivePoint?(F.assertValidity(),F):P.toRawBytes(F)}function R(U,T,F,j){if(A(T),F.length!==T.length)throw new Error("amount of public keys and messages should be equal");const M=k(U),V=T.map(J=>H(J,j)),z=F.map(L),Z=new Map;for(let J=0;J<z.length;J++){const ee=z[J],oe=V[J];let se=Z.get(oe);se===void 0&&(se=[],Z.set(oe,se)),se.push(ee)}const W=[];try{for(const[J,ee]of Z){const oe=ee.reduce((se,Ot)=>se.add(Ot));W.push({g1:oe,g2:J})}return W.push({g1:a.ProjectivePoint.BASE.negate(),g2:M}),i.eql(D(W),i.ONE)}catch{return!1}}return a.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:E,getPublicKeyForShortSignatures:g,sign:y,signShortSignature:b,verify:w,verifyBatch:R,verifyShortSignature:B,aggregatePublicKeys:O,aggregateSignatures:S,aggregateShortSignatures:N,millerLoopBatch:$,pairing:x,pairingBatch:D,G1:a,G2:h,Signature:q,ShortSignature:P,fields:{Fr:n,Fp:t,Fp2:r,Fp6:o,Fp12:i},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:C}}const Ah=BigInt(0),In=BigInt(1),gt=BigInt(2),sf=BigInt(3);function gi(e,t,n,r,o=1,i){const s=BigInt(i===void 0?r:i),c=n**BigInt(r),f=[];for(let a=0;a<o;a++){const l=BigInt(a+1),h=[];for(let d=0,u=In;d<r;d++){const p=(l*u-l)/s%c;h.push(e.pow(t,p)),u*=n}f.push(h)}return f}function Oh(e,t,n){const r=t.pow(n,(e.ORDER-In)/sf),o=t.pow(n,(e.ORDER-In)/gt);function i(d,u){const p=t.mul(t.frobeniusMap(d,1),r),m=t.mul(t.frobeniusMap(u,1),o);return[p,m]}const s=t.pow(n,(e.ORDER**gt-In)/sf),c=t.pow(n,(e.ORDER**gt-In)/gt);if(!t.eql(c,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function f(d,u){return[t.mul(d,s),t.neg(u)]}const a=d=>(u,p)=>{const m=p.toAffine(),v=d(m.x,m.y);return u.fromAffine({x:v[0],y:v[1]})},l=a(i),h=a(f);return{psi:i,psi2:f,G2psi:l,G2psi2:h,PSI_X:r,PSI_Y:o,PSI2_X:s,PSI2_Y:c}}function Sh(e){const{ORDER:t}=e,n=Ut(t),r=n.create(e.NONRESIDUE||BigInt(-1)),o=n.div(n.ONE,gt),i=gi(n,r,n.ORDER,2)[0],s=({c0:E,c1:g},{c0:y,c1:b})=>({c0:n.add(E,y),c1:n.add(g,b)}),c=({c0:E,c1:g},{c0:y,c1:b})=>({c0:n.sub(E,y),c1:n.sub(g,b)}),f=({c0:E,c1:g},y)=>{if(typeof y=="bigint")return{c0:n.mul(E,y),c1:n.mul(g,y)};const{c0:b,c1:w}=y;let B=n.mul(E,b),A=n.mul(g,w);const O=n.sub(B,A),S=n.sub(n.mul(n.add(E,g),n.add(b,w)),n.add(B,A));return{c0:O,c1:S}},a=({c0:E,c1:g})=>{const y=n.add(E,g),b=n.sub(E,g),w=n.add(E,E);return{c0:n.mul(y,b),c1:n.mul(w,g)}},l=E=>{if(E.length!==2)throw new Error("invalid tuple");const g=E.map(y=>n.create(y));return{c0:g[0],c1:g[1]}},h=t*t,d=l(e.FP2_NONRESIDUE),u={ORDER:h,isLE:n.isLE,NONRESIDUE:d,BITS:Xn(h),BYTES:Math.ceil(Xn(h)/8),MASK:cn(Xn(h)),ZERO:{c0:n.ZERO,c1:n.ZERO},ONE:{c0:n.ONE,c1:n.ZERO},create:E=>E,isValid:({c0:E,c1:g})=>typeof E=="bigint"&&typeof g=="bigint",is0:({c0:E,c1:g})=>n.is0(E)&&n.is0(g),eql:({c0:E,c1:g},{c0:y,c1:b})=>n.eql(E,y)&&n.eql(g,b),neg:({c0:E,c1:g})=>({c0:n.neg(E),c1:n.neg(g)}),pow:(E,g)=>Rr(u,E,g),invertBatch:E=>an(u,E),add:s,sub:c,mul:f,sqr:a,addN:s,subN:c,mulN:f,sqrN:a,div:(E,g)=>u.mul(E,typeof g=="bigint"?n.inv(n.create(g)):u.inv(g)),inv:({c0:E,c1:g})=>{const y=n.inv(n.create(E*E+g*g));return{c0:n.mul(y,n.create(E)),c1:n.mul(y,n.create(-g))}},sqrt:E=>{if(e.Fp2sqrt)return e.Fp2sqrt(E);const{c0:g,c1:y}=E;if(n.is0(y))return $r(n,g)===1?u.create({c0:n.sqrt(g),c1:n.ZERO}):u.create({c0:n.ZERO,c1:n.sqrt(n.div(g,r))});const b=n.sqrt(n.sub(n.sqr(g),n.mul(n.sqr(y),r)));let w=n.mul(n.add(b,g),o);$r(n,w)===-1&&(w=n.sub(w,b));const A=n.sqrt(w),O=u.create({c0:A,c1:n.div(n.mul(y,o),A)});if(!u.eql(u.sqr(O),E))throw new Error("Cannot find square root");const S=O,N=u.neg(S),{re:R,im:U}=u.reim(S),{re:T,im:F}=u.reim(N);return U>F||U===F&&R>T?S:N},isOdd:E=>{const{re:g,im:y}=u.reim(E),b=g%gt,w=g===Ah,B=y%gt;return BigInt(b||w&&B)==In},fromBytes(E){if(E.length!==u.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:n.fromBytes(E.subarray(0,n.BYTES)),c1:n.fromBytes(E.subarray(n.BYTES))}},toBytes:({c0:E,c1:g})=>ce(n.toBytes(E),n.toBytes(g)),cmov:({c0:E,c1:g},{c0:y,c1:b},w)=>({c0:n.cmov(E,y,w),c1:n.cmov(g,b,w)}),reim:({c0:E,c1:g})=>({re:E,im:g}),mulByNonresidue:({c0:E,c1:g})=>u.mul({c0:E,c1:g},d),mulByB:e.Fp2mulByB,fromBigTuple:l,frobeniusMap:({c0:E,c1:g},y)=>({c0:E,c1:n.mul(g,i[y%2])})},p=({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>({c0:u.add(E,b),c1:u.add(g,w),c2:u.add(y,B)}),m=({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>({c0:u.sub(E,b),c1:u.sub(g,w),c2:u.sub(y,B)}),v=({c0:E,c1:g,c2:y},b)=>{if(typeof b=="bigint")return{c0:u.mul(E,b),c1:u.mul(g,b),c2:u.mul(y,b)};const{c0:w,c1:B,c2:A}=b,O=u.mul(E,w),S=u.mul(g,B),N=u.mul(y,A);return{c0:u.add(O,u.mulByNonresidue(u.sub(u.mul(u.add(g,y),u.add(B,A)),u.add(S,N)))),c1:u.add(u.sub(u.mul(u.add(E,g),u.add(w,B)),u.add(O,S)),u.mulByNonresidue(N)),c2:u.sub(u.add(S,u.mul(u.add(E,y),u.add(w,A))),u.add(O,N))}},_=({c0:E,c1:g,c2:y})=>{let b=u.sqr(E),w=u.mul(u.mul(E,g),gt),B=u.mul(u.mul(g,y),gt),A=u.sqr(y);return{c0:u.add(u.mulByNonresidue(B),b),c1:u.add(u.mulByNonresidue(A),w),c2:u.sub(u.sub(u.add(u.add(w,u.sqr(u.add(u.sub(E,g),y))),B),b),A)}},[$,D]=gi(u,d,n.ORDER,6,2,3),x={ORDER:u.ORDER,isLE:u.isLE,BITS:3*u.BITS,BYTES:3*u.BYTES,MASK:cn(3*u.BITS),ZERO:{c0:u.ZERO,c1:u.ZERO,c2:u.ZERO},ONE:{c0:u.ONE,c1:u.ZERO,c2:u.ZERO},create:E=>E,isValid:({c0:E,c1:g,c2:y})=>u.isValid(E)&&u.isValid(g)&&u.isValid(y),is0:({c0:E,c1:g,c2:y})=>u.is0(E)&&u.is0(g)&&u.is0(y),neg:({c0:E,c1:g,c2:y})=>({c0:u.neg(E),c1:u.neg(g),c2:u.neg(y)}),eql:({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B})=>u.eql(E,b)&&u.eql(g,w)&&u.eql(y,B),sqrt:_c,div:(E,g)=>x.mul(E,typeof g=="bigint"?n.inv(n.create(g)):x.inv(g)),pow:(E,g)=>Rr(x,E,g),invertBatch:E=>an(x,E),add:p,sub:m,mul:v,sqr:_,addN:p,subN:m,mulN:v,sqrN:_,inv:({c0:E,c1:g,c2:y})=>{let b=u.sub(u.sqr(E),u.mulByNonresidue(u.mul(y,g))),w=u.sub(u.mulByNonresidue(u.sqr(y)),u.mul(E,g)),B=u.sub(u.sqr(g),u.mul(E,y)),A=u.inv(u.add(u.mulByNonresidue(u.add(u.mul(y,w),u.mul(g,B))),u.mul(E,b)));return{c0:u.mul(A,b),c1:u.mul(A,w),c2:u.mul(A,B)}},fromBytes:E=>{if(E.length!==x.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:u.fromBytes(E.subarray(0,u.BYTES)),c1:u.fromBytes(E.subarray(u.BYTES,2*u.BYTES)),c2:u.fromBytes(E.subarray(2*u.BYTES))}},toBytes:({c0:E,c1:g,c2:y})=>ce(u.toBytes(E),u.toBytes(g),u.toBytes(y)),cmov:({c0:E,c1:g,c2:y},{c0:b,c1:w,c2:B},A)=>({c0:u.cmov(E,b,A),c1:u.cmov(g,w,A),c2:u.cmov(y,B,A)}),fromBigSix:E=>{if(!Array.isArray(E)||E.length!==6)throw new Error("invalid Fp6 usage");return{c0:u.fromBigTuple(E.slice(0,2)),c1:u.fromBigTuple(E.slice(2,4)),c2:u.fromBigTuple(E.slice(4,6))}},frobeniusMap:({c0:E,c1:g,c2:y},b)=>({c0:u.frobeniusMap(E,b),c1:u.mul(u.frobeniusMap(g,b),$[b%6]),c2:u.mul(u.frobeniusMap(y,b),D[b%6])}),mulByFp2:({c0:E,c1:g,c2:y},b)=>({c0:u.mul(E,b),c1:u.mul(g,b),c2:u.mul(y,b)}),mulByNonresidue:({c0:E,c1:g,c2:y})=>({c0:u.mulByNonresidue(y),c1:E,c2:g}),mul1:({c0:E,c1:g,c2:y},b)=>({c0:u.mulByNonresidue(u.mul(y,b)),c1:u.mul(E,b),c2:u.mul(g,b)}),mul01({c0:E,c1:g,c2:y},b,w){let B=u.mul(E,b),A=u.mul(g,w);return{c0:u.add(u.mulByNonresidue(u.sub(u.mul(u.add(g,y),w),A)),B),c1:u.sub(u.sub(u.mul(u.add(b,w),u.add(E,g)),B),A),c2:u.add(u.sub(u.mul(u.add(E,y),b),B),A)}}},C=gi(u,d,n.ORDER,12,1,6)[0],P=({c0:E,c1:g},{c0:y,c1:b})=>({c0:x.add(E,y),c1:x.add(g,b)}),q=({c0:E,c1:g},{c0:y,c1:b})=>({c0:x.sub(E,y),c1:x.sub(g,b)}),L=({c0:E,c1:g},y)=>{if(typeof y=="bigint")return{c0:x.mul(E,y),c1:x.mul(g,y)};let{c0:b,c1:w}=y,B=x.mul(E,b),A=x.mul(g,w);return{c0:x.add(B,x.mulByNonresidue(A)),c1:x.sub(x.mul(x.add(E,g),x.add(b,w)),x.add(B,A))}},I=({c0:E,c1:g})=>{let y=x.mul(E,g);return{c0:x.sub(x.sub(x.mul(x.add(x.mulByNonresidue(g),E),x.add(E,g)),y),x.mulByNonresidue(y)),c1:x.add(y,y)}};function k(E,g){const y=u.sqr(E),b=u.sqr(g);return{first:u.add(u.mulByNonresidue(b),y),second:u.sub(u.sub(u.sqr(u.add(E,g)),y),b)}}const H={ORDER:u.ORDER,isLE:x.isLE,BITS:2*x.BITS,BYTES:2*x.BYTES,MASK:cn(2*x.BITS),ZERO:{c0:x.ZERO,c1:x.ZERO},ONE:{c0:x.ONE,c1:x.ZERO},create:E=>E,isValid:({c0:E,c1:g})=>x.isValid(E)&&x.isValid(g),is0:({c0:E,c1:g})=>x.is0(E)&&x.is0(g),neg:({c0:E,c1:g})=>({c0:x.neg(E),c1:x.neg(g)}),eql:({c0:E,c1:g},{c0:y,c1:b})=>x.eql(E,y)&&x.eql(g,b),sqrt:_c,inv:({c0:E,c1:g})=>{let y=x.inv(x.sub(x.sqr(E),x.mulByNonresidue(x.sqr(g))));return{c0:x.mul(E,y),c1:x.neg(x.mul(g,y))}},div:(E,g)=>H.mul(E,typeof g=="bigint"?n.inv(n.create(g)):H.inv(g)),pow:(E,g)=>Rr(H,E,g),invertBatch:E=>an(H,E),add:P,sub:q,mul:L,sqr:I,addN:P,subN:q,mulN:L,sqrN:I,fromBytes:E=>{if(E.length!==H.BYTES)throw new Error("fromBytes invalid length="+E.length);return{c0:x.fromBytes(E.subarray(0,x.BYTES)),c1:x.fromBytes(E.subarray(x.BYTES))}},toBytes:({c0:E,c1:g})=>ce(x.toBytes(E),x.toBytes(g)),cmov:({c0:E,c1:g},{c0:y,c1:b},w)=>({c0:x.cmov(E,y,w),c1:x.cmov(g,b,w)}),fromBigTwelve:E=>({c0:x.fromBigSix(E.slice(0,6)),c1:x.fromBigSix(E.slice(6,12))}),frobeniusMap(E,g){const{c0:y,c1:b,c2:w}=x.frobeniusMap(E.c1,g),B=C[g%12];return{c0:x.frobeniusMap(E.c0,g),c1:x.create({c0:u.mul(y,B),c1:u.mul(b,B),c2:u.mul(w,B)})}},mulByFp2:({c0:E,c1:g},y)=>({c0:x.mulByFp2(E,y),c1:x.mulByFp2(g,y)}),conjugate:({c0:E,c1:g})=>({c0:E,c1:x.neg(g)}),mul014:({c0:E,c1:g},y,b,w)=>{let B=x.mul01(E,y,b),A=x.mul1(g,w);return{c0:x.add(x.mulByNonresidue(A),B),c1:x.sub(x.sub(x.mul01(x.add(g,E),y,u.add(b,w)),B),A)}},mul034:({c0:E,c1:g},y,b,w)=>{const B=x.create({c0:u.mul(E.c0,y),c1:u.mul(E.c1,y),c2:u.mul(E.c2,y)}),A=x.mul01(g,b,w),O=x.mul01(x.add(E,g),u.add(y,b),w);return{c0:x.add(x.mulByNonresidue(A),B),c1:x.sub(O,x.add(B,A))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:n,Fp2:u,Fp6:x,Fp4Square:k,Fp12:H}}const Ie=BigInt(0),Lr=BigInt(1),he=BigInt(2),qr=BigInt(3),tr=BigInt(4),Tt=BigInt("0xd201000000010000"),_h=Xn(Tt),{Fp:K,Fp2:Y,Fp6:wi,Fp4Square:pi,Fp12:Q}=Sh({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[Lr,Lr],Fp2mulByB:({c0:e,c1:t})=>{const n=K.mul(e,tr),r=K.mul(t,tr);return{c0:K.sub(n,r),c1:K.add(n,r)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{const{c0:n,c1:r,c2:o}=e,{c0:i,c1:s,c2:c}=t,{first:f,second:a}=pi(n,s),{first:l,second:h}=pi(i,o),{first:d,second:u}=pi(r,c),p=Y.mulByNonresidue(u);return{c0:wi.create({c0:Y.add(Y.mul(Y.sub(f,n),he),f),c1:Y.add(Y.mul(Y.sub(l,r),he),l),c2:Y.add(Y.mul(Y.sub(d,o),he),d)}),c1:wi.create({c0:Y.add(Y.mul(Y.add(p,i),he),p),c1:Y.add(Y.mul(Y.add(a,s),he),a),c2:Y.add(Y.mul(Y.add(h,c),he),h)})}},Fp12cyclotomicExp(e,t){let n=Q.ONE;for(let r=_h-1;r>=0;r--)n=Q._cyclotomicSquare(n),x0(t,r)&&(n=Q.mul(n,e));return n},Fp12finalExponentiate:e=>{const t=Tt,n=Q.div(Q.frobeniusMap(e,6),e),r=Q.mul(Q.frobeniusMap(n,2),n),o=Q.conjugate(Q._cyclotomicExp(r,t)),i=Q.mul(Q.conjugate(Q._cyclotomicSquare(r)),o),s=Q.conjugate(Q._cyclotomicExp(i,t)),c=Q.conjugate(Q._cyclotomicExp(s,t)),f=Q.mul(Q.conjugate(Q._cyclotomicExp(c,t)),Q._cyclotomicSquare(o)),a=Q.conjugate(Q._cyclotomicExp(f,t)),l=Q.frobeniusMap(Q.mul(o,c),2),h=Q.frobeniusMap(Q.mul(s,r),3),d=Q.frobeniusMap(Q.mul(f,Q.conjugate(r)),1),u=Q.mul(Q.mul(a,Q.conjugate(i)),r);return Q.mul(Q.mul(Q.mul(l,h),d),u)}}),cf=Ut(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),Ih=Qc(Y,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(t=>Y.fromBigTuple(t.map(BigInt))))),Nh=Qc(K,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(t=>BigInt(t)))),Fh=Xc(Y,{A:Y.create({c0:K.create(Ie),c1:K.create(BigInt(240))}),B:Y.create({c0:K.create(BigInt(1012)),c1:K.create(BigInt(1012))}),Z:Y.create({c0:K.create(BigInt(-2)),c1:K.create(BigInt(-1))})}),Ch=Xc(K,{A:K.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:K.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:K.create(BigInt(11))}),{G2psi:ff,G2psi2:Uh}=Oh(K,Y,Y.div(Y.ONE,Y.NONRESIDUE)),yi=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:K.ORDER,m:2,k:128,expand:"xmd",hash:On}),jr=nr(K.toBytes(Ie),{infinity:!0,compressed:!0});function Hr(e){e=e.slice();const t=e[0]&224,n=!!(t>>7&1),r=!!(t>>6&1),o=!!(t>>5&1);return e[0]&=31,{compressed:n,infinity:r,sort:o,value:e}}function nr(e,t){if(e[0]&224)throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function af(e){e.assertValidity();const t=e.equals(Ke.G1.ProjectivePoint.ZERO),{x:n,y:r}=e.toAffine();if(t)return jr.slice();const o=K.ORDER,i=!!(r*he/o);return nr(ue(n,K.BYTES),{compressed:!0,sort:i})}function uf(e){e.assertValidity();const t=K.BYTES;if(e.equals(Ke.G2.ProjectivePoint.ZERO))return ce(jr,ue(Ie,t));const{x:n,y:r}=e.toAffine(),{re:o,im:i}=Y.reim(n),{re:s,im:c}=Y.reim(r),a=!!((c>Ie?c*he:s*he)/K.ORDER&Lr),l=o;return ce(nr(ue(i,t),{sort:a,compressed:!0}),ue(l,t))}const Ke=Dh({fields:{Fp:K,Fp2:Y,Fp6:wi,Fp12:Q,Fr:cf},G1:{Fp:K,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:K.ZERO,b:tr,htfDefaults:{...yi,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{const n=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),r=new e(K.mul(t.px,n),t.py,t.pz);return t.multiplyUnsafe(Tt).negate().multiplyUnsafe(Tt).equals(r)},clearCofactor:(e,t)=>t.multiplyUnsafe(Tt).add(t),mapToCurve:e=>{const{x:t,y:n}=Ch(K.create(e[0]));return Nh(t,n)},fromBytes:e=>{const{compressed:t,infinity:n,sort:r,value:o}=Hr(e);if(o.length===48&&t){const i=K.ORDER,s=Oe(o),c=K.create(s&K.MASK);if(n){if(c!==Ie)throw new Error("G1: non-empty compressed point at infinity");return{x:Ie,y:Ie}}const f=K.add(K.pow(c,qr),K.create(Ke.params.G1b));let a=K.sqrt(f);if(!a)throw new Error("invalid compressed G1 point");return a*he/i!==BigInt(r)&&(a=K.neg(a)),{x:K.create(c),y:K.create(a)}}else if(o.length===96&&!t){const i=Oe(o.subarray(0,K.BYTES)),s=Oe(o.subarray(K.BYTES));if(n){if(i!==Ie||s!==Ie)throw new Error("G1: non-empty point at infinity");return Ke.G1.ProjectivePoint.ZERO.toAffine()}return{x:K.create(i),y:K.create(s)}}else throw new Error("invalid point G1, expected 48/96 bytes")},toBytes:(e,t,n)=>{const r=t.equals(e.ZERO),{x:o,y:i}=t.toAffine();if(n){if(r)return jr.slice();const s=K.ORDER,c=!!(i*he/s);return nr(ue(o,K.BYTES),{compressed:!0,sort:c})}else return r?ce(new Uint8Array([64]),new Uint8Array(2*K.BYTES-1)):ce(ue(o,K.BYTES),ue(i,K.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:r}=Hr(Ee("signatureHex",e,48)),o=K.ORDER,i=Oe(r);if(t)return Ke.G1.ProjectivePoint.ZERO;const s=K.create(i&K.MASK),c=K.add(K.pow(s,qr),K.create(Ke.params.G1b));let f=K.sqrt(c);if(!f)throw new Error("invalid compressed G1 point");const a=BigInt(n);f*he/o!==a&&(f=K.neg(f));const l=Ke.G1.ProjectivePoint.fromAffine({x:s,y:f});return l.assertValidity(),l},toRawBytes(e){return af(e)},toHex(e){return sn(af(e))}}},G2:{Fp:Y,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:Y.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:Y.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:Y.ZERO,b:Y.fromBigTuple([tr,tr]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{...yi},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{const{x:t,y:n}=Fh(Y.fromBigTuple(e));return Ih(t,n)},isTorsionFree:(e,t)=>t.multiplyUnsafe(Tt).negate().equals(ff(e,t)),clearCofactor:(e,t)=>{const n=Tt;let r=t.multiplyUnsafe(n).negate(),o=ff(e,t),i=t.double();return i=Uh(e,i),i=i.subtract(o),o=r.add(o),o=o.multiplyUnsafe(n).negate(),i=i.add(o),i=i.subtract(r),i.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:r,value:o}=Hr(e);if(!t&&!n&&r||!t&&n&&r||r&&n&&t)throw new Error("invalid encoding flag: "+(e[0]&224));const i=K.BYTES,s=(c,f,a)=>Oe(c.slice(f,a));if(o.length===96&&t){const c=Ke.params.G2b,f=K.ORDER;if(n){if(o.reduce((m,v)=>m!==0?v+1:v,0)>0)throw new Error("invalid compressed G2 point");return{x:Y.ZERO,y:Y.ZERO}}const a=s(o,0,i),l=s(o,i,2*i),h=Y.create({c0:K.create(l),c1:K.create(a)}),d=Y.add(Y.pow(h,qr),c);let u=Y.sqrt(d);const p=u.c1===Ie?u.c0*he/f:u.c1*he/f?Lr:Ie;return u=r&&p>0?u:Y.neg(u),{x:h,y:u}}else if(o.length===192&&!t){if(n){if(o.reduce((h,d)=>h!==0?d+1:d,0)>0)throw new Error("invalid uncompressed G2 point");return{x:Y.ZERO,y:Y.ZERO}}const c=s(o,0,i),f=s(o,i,2*i),a=s(o,2*i,3*i),l=s(o,3*i,4*i);return{x:Y.fromBigTuple([f,c]),y:Y.fromBigTuple([l,a])}}else throw new Error("invalid point G2, expected 96/192 bytes")},toBytes:(e,t,n)=>{const{BYTES:r,ORDER:o}=K,i=t.equals(e.ZERO),{x:s,y:c}=t.toAffine();if(n){if(i)return ce(jr,ue(Ie,r));const f=!!(c.c1===Ie?c.c0*he/o:c.c1*he/o);return ce(nr(ue(s.c1,r),{compressed:!0,sort:f}),ue(s.c0,r))}else{if(i)return ce(new Uint8Array([64]),new Uint8Array(4*r-1));const{re:f,im:a}=Y.reim(s),{re:l,im:h}=Y.reim(c);return ce(ue(a,r),ue(f,r),ue(h,r),ue(l,r))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:r}=Hr(Ee("signatureHex",e)),o=K.ORDER,i=r.length/2;if(i!==48&&i!==96)throw new Error("invalid compressed signature length, must be 96 or 192");const s=Oe(r.slice(0,i)),c=Oe(r.slice(i));if(t)return Ke.G2.ProjectivePoint.ZERO;const f=K.create(s&K.MASK),a=K.create(c),l=Y.create({c0:a,c1:f}),h=Y.add(Y.pow(l,qr),Ke.params.G2b);let d=Y.sqrt(h);if(!d)throw new Error("Failed to find a square root");const{re:u,im:p}=Y.reim(d),m=BigInt(n),v=p>Ie&&p*he/o!==m,_=p===Ie&&u*he/o!==m;(v||_)&&(d=Y.neg(d));const $=Ke.G2.ProjectivePoint.fromAffine({x:l,y:d});return $.assertValidity(),$},toRawBytes(e){return uf(e)},toHex(e){return sn(uf(e))}}},params:{ateLoopSize:Tt,r:cf.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:yi,hash:On,randomBytes:Or});BigInt(0),BigInt(1),BigInt(2),BigInt(8),BigInt(0),BigInt(1),BigInt(2),BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),BigInt(0),BigInt(1),BigInt(2),BigInt(3),BigInt(5),BigInt(8);const mi=BigInt(0),Ei=BigInt(1);function Mr(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function un(e,t,n=""){const r=vr(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){const s=n&&`"${n}" `,c=i?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+f)}return e}function zr(e){const t=e.toString(16);return t.length&1?"0"+t:t}function lf(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?mi:BigInt("0x"+e)}function kr(e){return lf(Bn(e))}function df(e){return ct(e),lf(Bn(Uint8Array.from(e).reverse()))}function xi(e,t){return Br(e.toString(16).padStart(t*2,"0"))}function hf(e,t){return xi(e,t).reverse()}function Ue(e,t,n){let r;if(typeof t=="string")try{r=Br(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(vr(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const vi=e=>typeof e=="bigint"&&mi<=e;function Rh(e,t,n){return vi(e)&&vi(t)&&vi(n)&&t<=e&&e<n}function $h(e,t,n,r){if(!Rh(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function bf(e){let t;for(t=0;e>mi;e>>=Ei,t+=1);return t}const rr=e=>(Ei<<BigInt(e))-Ei;function Th(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=u=>new Uint8Array(u),o=u=>Uint8Array.of(u);let i=r(e),s=r(e),c=0;const f=()=>{i.fill(1),s.fill(0),c=0},a=(...u)=>n(s,i,...u),l=(u=r(0))=>{s=a(o(0),u),i=a(),u.length!==0&&(s=a(o(1),u),i=a())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const p=[];for(;u<t;){i=a();const m=i.slice();p.push(m),u+=i.length}return at(...p)};return(u,p)=>{f(),l(u);let m;for(;!(m=p(h()));)l();return f(),m}}function Bi(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,i,s){const c=e[o];if(s&&c===void 0)return;const f=typeof c;if(f!==i||c===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${f}`)}Object.entries(t).forEach(([o,i])=>r(o,i,!1)),Object.entries(n).forEach(([o,i])=>r(o,i,!0))}function gf(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const Re=BigInt(0),Ne=BigInt(1),ln=BigInt(2),wf=BigInt(3),pf=BigInt(4),yf=BigInt(5),Ph=BigInt(7),mf=BigInt(8),Lh=BigInt(9),Ef=BigInt(16);function Ye(e,t){const n=e%t;return n>=Re?n:t+n}function ze(e,t,n){let r=e;for(;t-- >Re;)r*=r,r%=n;return r}function xf(e,t){if(e===Re)throw new Error("invert: expected non-zero number");if(t<=Re)throw new Error("invert: expected positive modulus, got "+t);let n=Ye(e,t),r=t,o=Re,i=Ne;for(;n!==Re;){const c=r/n,f=r%n,a=o-i*c;r=n,n=f,o=i,i=a}if(r!==Ne)throw new Error("invert: does not exist");return Ye(o,t)}function Di(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function vf(e,t){const n=(e.ORDER+Ne)/pf,r=e.pow(t,n);return Di(e,r,t),r}function qh(e,t){const n=(e.ORDER-yf)/mf,r=e.mul(t,ln),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,ln),o),c=e.mul(i,e.sub(s,e.ONE));return Di(e,c,t),c}function jh(e){const t=or(e),n=Bf(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+Ph)/Ef;return(c,f)=>{let a=c.pow(f,s),l=c.mul(a,r);const h=c.mul(a,o),d=c.mul(a,i),u=c.eql(c.sqr(l),f),p=c.eql(c.sqr(h),f);a=c.cmov(a,l,u),l=c.cmov(d,h,p);const m=c.eql(c.sqr(l),f),v=c.cmov(a,l,m);return Di(c,v,f),v}}function Bf(e){if(e<wf)throw new Error("sqrt is not defined for small field");let t=e-Ne,n=0;for(;t%ln===Re;)t/=ln,n++;let r=ln;const o=or(e);for(;Af(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return vf;let i=o.pow(r,t);const s=(t+Ne)/ln;return function(f,a){if(f.is0(a))return a;if(Af(f,a)!==1)throw new Error("Cannot find square root");let l=n,h=f.mul(f.ONE,i),d=f.pow(a,t),u=f.pow(a,s);for(;!f.eql(d,f.ONE);){if(f.is0(d))return f.ZERO;let p=1,m=f.sqr(d);for(;!f.eql(m,f.ONE);)if(p++,m=f.sqr(m),p===l)throw new Error("Cannot find square root");const v=Ne<<BigInt(l-p-1),_=f.pow(h,v);l=p,h=f.sqr(_),d=f.mul(d,h),u=f.mul(u,_)}return u}}function Hh(e){return e%pf===wf?vf:e%mf===yf?qh:e%Ef===Lh?jh(e):Bf(e)}const Mh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function zh(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Mh.reduce((r,o)=>(r[o]="function",r),t);return Bi(e,n),e}function kh(e,t,n){if(n<Re)throw new Error("invalid exponent, negatives unsupported");if(n===Re)return e.ONE;if(n===Ne)return t;let r=e.ONE,o=t;for(;n>Re;)n&Ne&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Ne;return r}function Df(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function Af(e,t){const n=(e.ORDER-Ne)/ln,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Of(e,t){t!==void 0&&xn(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function or(e,t,n=!1,r={}){if(e<=Re)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(s=d.modFromBytes),c=d.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:f,nByteLength:a}=Of(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:a,MASK:rr(f),ZERO:Re,ONE:Ne,allowedLengths:c,create:d=>Ye(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Re<=d&&d<e},is0:d=>d===Re,isValidNot0:d=>!h.is0(d)&&h.isValid(d),isOdd:d=>(d&Ne)===Ne,neg:d=>Ye(-d,e),eql:(d,u)=>d===u,sqr:d=>Ye(d*d,e),add:(d,u)=>Ye(d+u,e),sub:(d,u)=>Ye(d-u,e),mul:(d,u)=>Ye(d*u,e),pow:(d,u)=>kh(h,d,u),div:(d,u)=>Ye(d*xf(u,e),e),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>xf(d,e),sqrt:i||(d=>(l||(l=Hh(e)),l(h,d))),toBytes:d=>n?hf(d,a):xi(d,a),fromBytes:(d,u=!0)=>{if(c){if(!c.includes(d.length)||d.length>a)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(a);m.set(d,n?0:m.length-d.length),d=m}if(d.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);let p=n?df(d):kr(d);if(s&&(p=Ye(p,e)),!u&&!h.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:d=>Df(h,d),cmov:(d,u,p)=>p?u:d});return Object.freeze(h)}function Sf(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function _f(e){const t=Sf(e);return t+Math.ceil(t/2)}function Zh(e,t,n=!1){const r=e.length,o=Sf(t),i=_f(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?df(e):kr(e),c=Ye(s,t-Ne)+Ne;return n?hf(c,o):xi(c,o)}const Nn=BigInt(0),dn=BigInt(1);function Zr(e,t){const n=t.negate();return e?n:t}function Ai(e,t){const n=Df(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function If(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Oi(e,t){If(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=rr(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Nf(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=dn);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function Vh(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Gh(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Si=new WeakMap,Ff=new WeakMap;function _i(e){return Ff.get(e)||1}function Cf(e){if(e!==Nn)throw new Error("invalid wNAF")}class Kh{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>Nn;)n&dn&&(r=r.add(o)),o=o.double(),n>>=dn;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=Oi(n,this.bits),i=[];let s=t,c=s;for(let f=0;f<r;f++){c=s,i.push(c);for(let a=1;a<o;a++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE;const s=Oi(t,this.bits);for(let c=0;c<s.windows;c++){const{nextN:f,offset:a,isZero:l,isNeg:h,isNegF:d,offsetF:u}=Nf(r,c,s);r=f,l?i=i.add(Zr(d,n[u])):o=o.add(Zr(h,n[a]))}return Cf(r),{p:o,f:i}}wNAFUnsafe(t,n,r,o=this.ZERO){const i=Oi(t,this.bits);for(let s=0;s<i.windows&&r!==Nn;s++){const{nextN:c,offset:f,isZero:a,isNeg:l}=Nf(r,s,i);if(r=c,!a){const h=n[f];o=o.add(l?h.negate():h)}}return Cf(r),o}getPrecomputes(t,n,r){let o=Si.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),Si.set(n,o))),o}cached(t,n,r){const o=_i(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const i=_i(t);return i===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),n,o)}createCache(t,n){If(n,this.bits),Ff.set(t,n),Si.delete(t)}hasCache(t){return _i(t)!==1}}function Yh(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>Nn||r>Nn;)n&dn&&(i=i.add(o)),r&dn&&(s=s.add(o)),o=o.double(),n>>=dn,r>>=dn;return{p1:i,p2:s}}function Wh(e,t,n,r){Vh(n,e),Gh(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=bf(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=rr(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Uf(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return zh(t),t}else return or(e,{isLE:n})}function Xh(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const f of["p","n","h"]){const a=t[f];if(!(typeof a=="bigint"&&a>Nn))throw new Error(`CURVE.${f} must be positive bigint`)}const o=Uf(t.p,n.Fp,r),i=Uf(t.n,n.Fn,r),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const f of c)if(!o.isValid(t[f]))throw new Error(`CURVE.${f} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}const Rf=(e,t)=>(e+(e>=0?t:-t)/$f)/t;function Jh(e,t,n){const[[r,o],[i,s]]=t,c=Rf(s*e,n),f=Rf(-o*e,n);let a=e-c*r-f*i,l=-c*o-f*s;const h=a<pt,d=l<pt;h&&(a=-a),d&&(l=-l);const u=rr(Math.ceil(bf(n)/2))+Fn;if(a<pt||a>=u||l<pt||l>=u)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}function Ii(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Ni(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Mr(n.lowS,"lowS"),Mr(n.prehash,"prehash"),n.format!==void 0&&Ii(n.format),n}class Qh extends Error{constructor(t=""){super(t)}}const wt={Err:Qh,_tlv:{encode:(e,t)=>{const{Err:n}=wt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=zr(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?zr(o.length/2|128):"";return zr(e)+i+o+t},decode(e,t){const{Err:n}=wt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=wt;if(e<pt)throw new t("integer: negative integers are not allowed");let n=zr(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=wt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kr(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=wt,o=Ue("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=wt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}},pt=BigInt(0),Fn=BigInt(1),$f=BigInt(2),Vr=BigInt(3),e1=BigInt(4);function Cn(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=Ue("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function t1(e,t={}){const n=Xh("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:c}=i;Bi(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(i.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const a=Pf(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(E,g,y){const{x:b,y:w}=g.toAffine(),B=r.toBytes(b);if(Mr(y,"isCompressed"),y){l();const A=!r.isOdd(w);return at(Tf(A),B)}else return at(Uint8Array.of(4),B,r.toBytes(w))}function d(E){un(E,void 0,"Point");const{publicKey:g,publicKeyUncompressed:y}=a,b=E.length,w=E[0],B=E.subarray(1);if(b===g&&(w===2||w===3)){const A=r.fromBytes(B);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const O=m(A);let S;try{S=r.sqrt(O)}catch(U){const T=U instanceof Error?": "+U.message:"";throw new Error("bad point: is not on curve, sqrt error"+T)}l();const N=r.isOdd(S);return(w&1)===1!==N&&(S=r.neg(S)),{x:A,y:S}}else if(b===y&&w===4){const A=r.BYTES,O=r.fromBytes(B.subarray(0,A)),S=r.fromBytes(B.subarray(A,A*2));if(!v(O,S))throw new Error("bad point: is not on curve");return{x:O,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${g} or uncompressed=${y}`)}const u=t.toBytes||h,p=t.fromBytes||d;function m(E){const g=r.sqr(E),y=r.mul(g,E);return r.add(r.add(y,r.mul(E,i.a)),i.b)}function v(E,g){const y=r.sqr(g),b=m(E);return r.eql(y,b)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const _=r.mul(r.pow(i.a,Vr),e1),$=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(_,$)))throw new Error("bad curve params: a or b");function D(E,g,y=!1){if(!r.isValid(g)||y&&r.is0(g))throw new Error(`bad point coordinate ${E}`);return g}function x(E){if(!(E instanceof I))throw new Error("ProjectivePoint expected")}function C(E){if(!f||!f.basises)throw new Error("no endo");return Jh(E,f.basises,o.ORDER)}const P=gf((E,g)=>{const{X:y,Y:b,Z:w}=E;if(r.eql(w,r.ONE))return{x:y,y:b};const B=E.is0();g==null&&(g=B?r.ONE:r.inv(w));const A=r.mul(y,g),O=r.mul(b,g),S=r.mul(w,g);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),q=gf(E=>{if(E.is0()){if(t.allowInfinityPoint&&!r.is0(E.Y))return;throw new Error("bad point: ZERO")}const{x:g,y}=E.toAffine();if(!r.isValid(g)||!r.isValid(y))throw new Error("bad point: x or y not field elements");if(!v(g,y))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(E,g,y,b,w){return y=new I(r.mul(y.X,E),y.Y,y.Z),g=Zr(b,g),y=Zr(w,y),g.add(y)}class I{constructor(g,y,b){this.X=D("x",g),this.Y=D("y",y,!0),this.Z=D("z",b),Object.freeze(this)}static CURVE(){return i}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!r.isValid(y)||!r.isValid(b))throw new Error("invalid affine point");if(g instanceof I)throw new Error("projective point not allowed");return r.is0(y)&&r.is0(b)?I.ZERO:new I(y,b,r.ONE)}static fromBytes(g){const y=I.fromAffine(p(un(g,void 0,"point")));return y.assertValidity(),y}static fromHex(g){return I.fromBytes(Ue("pointHex",g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,y=!0){return H.createCache(this,g),y||this.multiply(Vr),this}assertValidity(){q(this)}hasEvenY(){const{y:g}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(g)}equals(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g,S=r.eql(r.mul(y,O),r.mul(B,w)),N=r.eql(r.mul(b,O),r.mul(A,w));return S&&N}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:g,b:y}=i,b=r.mul(y,Vr),{X:w,Y:B,Z:A}=this;let O=r.ZERO,S=r.ZERO,N=r.ZERO,R=r.mul(w,w),U=r.mul(B,B),T=r.mul(A,A),F=r.mul(w,B);return F=r.add(F,F),N=r.mul(w,A),N=r.add(N,N),O=r.mul(g,N),S=r.mul(b,T),S=r.add(O,S),O=r.sub(U,S),S=r.add(U,S),S=r.mul(O,S),O=r.mul(F,O),N=r.mul(b,N),T=r.mul(g,T),F=r.sub(R,T),F=r.mul(g,F),F=r.add(F,N),N=r.add(R,R),R=r.add(N,R),R=r.add(R,T),R=r.mul(R,F),S=r.add(S,R),T=r.mul(B,A),T=r.add(T,T),R=r.mul(T,F),O=r.sub(O,R),N=r.mul(T,U),N=r.add(N,N),N=r.add(N,N),new I(O,S,N)}add(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g;let S=r.ZERO,N=r.ZERO,R=r.ZERO;const U=i.a,T=r.mul(i.b,Vr);let F=r.mul(y,B),j=r.mul(b,A),M=r.mul(w,O),V=r.add(y,b),z=r.add(B,A);V=r.mul(V,z),z=r.add(F,j),V=r.sub(V,z),z=r.add(y,w);let Z=r.add(B,O);return z=r.mul(z,Z),Z=r.add(F,M),z=r.sub(z,Z),Z=r.add(b,w),S=r.add(A,O),Z=r.mul(Z,S),S=r.add(j,M),Z=r.sub(Z,S),R=r.mul(U,z),S=r.mul(T,M),R=r.add(S,R),S=r.sub(j,R),R=r.add(j,R),N=r.mul(S,R),j=r.add(F,F),j=r.add(j,F),M=r.mul(U,M),z=r.mul(T,z),j=r.add(j,M),M=r.sub(F,M),M=r.mul(U,M),z=r.add(z,M),F=r.mul(j,z),N=r.add(N,F),F=r.mul(Z,z),S=r.mul(V,S),S=r.sub(S,F),F=r.mul(V,j),R=r.mul(Z,R),R=r.add(R,F),new I(S,N,R)}subtract(g){return this.add(g.negate())}is0(){return this.equals(I.ZERO)}multiply(g){const{endo:y}=t;if(!o.isValidNot0(g))throw new Error("invalid scalar: out of range");let b,w;const B=A=>H.cached(this,A,O=>Ai(I,O));if(y){const{k1neg:A,k1:O,k2neg:S,k2:N}=C(g),{p:R,f:U}=B(O),{p:T,f:F}=B(N);w=U.add(F),b=L(y.beta,R,T,A,S)}else{const{p:A,f:O}=B(g);b=A,w=O}return Ai(I,[b,w])[0]}multiplyUnsafe(g){const{endo:y}=t,b=this;if(!o.isValid(g))throw new Error("invalid scalar: out of range");if(g===pt||b.is0())return I.ZERO;if(g===Fn)return b;if(H.hasCache(this))return this.multiply(g);if(y){const{k1neg:w,k1:B,k2neg:A,k2:O}=C(g),{p1:S,p2:N}=Yh(I,b,B,O);return L(y.beta,S,N,w,A)}else return H.unsafe(b,g)}multiplyAndAddUnsafe(g,y,b){const w=this.multiplyUnsafe(y).add(g.multiplyUnsafe(b));return w.is0()?void 0:w}toAffine(g){return P(this,g)}isTorsionFree(){const{isTorsionFree:g}=t;return s===Fn?!0:g?g(I,this):H.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:g}=t;return s===Fn?this:g?g(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(g=!0){return Mr(g,"isCompressed"),this.assertValidity(),u(I,this,g)}toHex(g=!0){return Bn(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(g=!0){return this.toBytes(g)}_setWindowSize(g){this.precompute(g)}static normalizeZ(g){return Ai(I,g)}static msm(g,y){return Wh(I,o,g,y)}static fromPrivateKey(g){return I.BASE.multiply(Cn(o,g))}}I.BASE=new I(i.Gx,i.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=o;const k=o.BITS,H=new Kh(I,t.endo?Math.ceil(k/2):k);return I.BASE.precompute(8),I}function Tf(e){return Uint8Array.of(e?2:3)}function Pf(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function n1(e,t={}){const{Fn:n}=e,r=t.randomBytes||Or,o=Object.assign(Pf(e.Fp,n),{seed:_f(n.ORDER)});function i(u){try{return!!Cn(n,u)}catch{return!1}}function s(u,p){const{publicKey:m,publicKeyUncompressed:v}=o;try{const _=u.length;return p===!0&&_!==m||p===!1&&_!==v?!1:!!e.fromBytes(u)}catch{return!1}}function c(u=r(o.seed)){return Zh(un(u,o.seed,"seed"),n.ORDER)}function f(u,p=!0){return e.BASE.multiply(Cn(n,u)).toBytes(p)}function a(u){const p=c(u);return{secretKey:p,publicKey:f(p)}}function l(u){if(typeof u=="bigint")return!1;if(u instanceof e)return!0;const{secretKey:p,publicKey:m,publicKeyUncompressed:v}=o;if(n.allowedLengths||p===m)return;const _=Ue("key",u).length;return _===m||_===v}function h(u,p,m=!0){if(l(u)===!0)throw new Error("first arg must be private key");if(l(p)===!1)throw new Error("second arg must be public key");const v=Cn(n,u);return e.fromHex(p).multiply(v).toBytes(m)}return Object.freeze({getPublicKey:f,getSharedSecret:h,keygen:a,Point:e,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:u=>Cn(n,u),precompute(u=8,p=e.BASE){return p.precompute(u,!1)}},lengths:o})}function r1(e,t,n={}){oc(t),Bi(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||Or,o=n.hmac||((y,...b)=>ni(t,y,at(...b))),{Fp:i,Fn:s}=e,{ORDER:c,BITS:f}=s,{keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u}=n1(e,n),p={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},m="compact";function v(y){const b=c>>Fn;return y>b}function _(y,b){if(!s.isValidNot0(b))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return b}function $(y,b){Ii(b);const w=u.signature,B=b==="compact"?w:b==="recovered"?w+1:void 0;return un(y,B,`${b} signature`)}class D{constructor(b,w,B){this.r=_("r",b),this.s=_("s",w),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,w=m){$(b,w);let B;if(w==="der"){const{r:N,s:R}=wt.toSig(un(b));return new D(N,R)}w==="recovered"&&(B=b[0],w="compact",b=b.subarray(1));const A=s.BYTES,O=b.subarray(0,A),S=b.subarray(A,A*2);return new D(s.fromBytes(O),s.fromBytes(S),B)}static fromHex(b,w){return this.fromBytes(Br(b),w)}addRecoveryBit(b){return new D(this.r,this.s,b)}recoverPublicKey(b){const w=i.ORDER,{r:B,s:A,recovery:O}=this;if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");if(c*$f<w&&O>1)throw new Error("recovery id is ambiguous for h>1 curve");const N=O===2||O===3?B+c:B;if(!i.isValid(N))throw new Error("recovery id 2 or 3 invalid");const R=i.toBytes(N),U=e.fromBytes(at(Tf((O&1)===0),R)),T=s.inv(N),F=C(Ue("msgHash",b)),j=s.create(-F*T),M=s.create(A*T),V=e.BASE.multiplyUnsafe(j).add(U.multiplyUnsafe(M));if(V.is0())throw new Error("point at infinify");return V.assertValidity(),V}hasHighS(){return v(this.s)}toBytes(b=m){if(Ii(b),b==="der")return Br(wt.hexFromSig(this));const w=s.toBytes(this.r),B=s.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return at(Uint8Array.of(this.recovery),w,B)}return at(w,B)}toHex(b){return Bn(this.toBytes(b))}assertValidity(){}static fromCompact(b){return D.fromBytes(Ue("sig",b),"compact")}static fromDER(b){return D.fromBytes(Ue("sig",b),"der")}normalizeS(){return this.hasHighS()?new D(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Bn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Bn(this.toBytes("compact"))}}const x=n.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");const w=kr(b),B=b.length*8-f;return B>0?w>>BigInt(B):w},C=n.bits2int_modN||function(b){return s.create(x(b))},P=rr(f);function q(y){return $h("num < 2^"+f,y,pt,P),s.toBytes(y)}function L(y,b){return un(y,void 0,"message"),b?un(t(y),void 0,"prehashed message"):y}function I(y,b,w){if(["recovered","canonical"].some(j=>j in w))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:A,extraEntropy:O}=Ni(w,p);y=L(y,A);const S=C(y),N=Cn(s,b),R=[q(N),q(S)];if(O!=null&&O!==!1){const j=O===!0?r(u.secretKey):O;R.push(Ue("extraEntropy",j))}const U=at(...R),T=S;function F(j){const M=x(j);if(!s.isValidNot0(M))return;const V=s.inv(M),z=e.BASE.multiply(M).toAffine(),Z=s.create(z.x);if(Z===pt)return;const W=s.create(V*s.create(T+Z*N));if(W===pt)return;let J=(z.x===Z?0:2)|Number(z.y&Fn),ee=W;return B&&v(W)&&(ee=s.neg(W),J^=1),new D(Z,ee,J)}return{seed:U,k2sig:F}}function k(y,b,w={}){y=Ue("message",y);const{seed:B,k2sig:A}=I(y,b,w);return Th(t.outputLen,s.BYTES,o)(B,A)}function H(y){let b;const w=typeof y=="string"||vr(y),B=!w&&y!==null&&typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!w&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new D(y.r,y.s);else if(w){try{b=D.fromBytes(Ue("sig",y),"der")}catch(A){if(!(A instanceof wt.Err))throw A}if(!b)try{b=D.fromBytes(Ue("sig",y),"compact")}catch{return!1}}return b||!1}function E(y,b,w,B={}){const{lowS:A,prehash:O,format:S}=Ni(B,p);if(w=Ue("publicKey",w),b=L(Ue("message",b),O),"strict"in B)throw new Error("options.strict was renamed to lowS");const N=S===void 0?H(y):D.fromBytes(Ue("sig",y),S);if(N===!1)return!1;try{const R=e.fromBytes(w);if(A&&N.hasHighS())return!1;const{r:U,s:T}=N,F=C(b),j=s.inv(T),M=s.create(F*j),V=s.create(U*j),z=e.BASE.multiplyUnsafe(M).add(R.multiplyUnsafe(V));return z.is0()?!1:s.create(z.x)===U}catch{return!1}}function g(y,b,w={}){const{prehash:B}=Ni(w,p);return b=L(b,B),D.fromBytes(y,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u,Point:e,sign:k,verify:E,recoverPublicKey:g,Signature:D,hash:t})}function o1(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const o=or(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),i={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:i}}function i1(e){const{CURVE:t,curveOpts:n}=o1(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function s1(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Of(n.Fn.ORDER,n.Fn.BITS))})}function c1(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=i1(e),i=t1(t,n),s=r1(i,r,o);return s1(e,s)}function f1(e,t){const n=r=>c1({...e,hash:r});return{...n(t),create:n}}Mo("HashToScalar-");const Fi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},a1={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Lf=BigInt(2);function u1(e){const t=Fi.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),f=BigInt(88),a=e*e*e%t,l=a*a*e%t,h=ze(l,n,t)*l%t,d=ze(h,n,t)*l%t,u=ze(d,Lf,t)*a%t,p=ze(u,o,t)*u%t,m=ze(p,i,t)*p%t,v=ze(m,c,t)*m%t,_=ze(v,f,t)*v%t,$=ze(_,c,t)*m%t,D=ze($,n,t)*l%t,x=ze(D,s,t)*p%t,C=ze(x,r,t)*a%t,P=ze(C,Lf,t);if(!Ci.eql(Ci.sqr(P),e))throw new Error("Cannot find square root");return P}const Ci=or(Fi.p,{sqrt:u1});f1({...Fi,Fp:Ci,lowS:!0,endo:a1},On);/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Un(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Ui(e,...t){if(!Un(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function qf(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function Ri(e){if(typeof e!="function")throw new Error("function expected");return!0}function Pt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Rn(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gr(e){if(!Array.isArray(e))throw new Error("array expected")}function Kr(e,t){if(!qf(!0,t))throw new Error(`${e}: array of strings expected`)}function $i(e,t){if(!qf(!1,t))throw new Error(`${e}: array of numbers expected`)}function $e(...e){const t=i=>i,n=(i,s)=>c=>i(s(c)),r=e.map(i=>i.encode).reduceRight(n,t),o=e.map(i=>i.decode).reduce(n,t);return{encode:r,decode:o}}function qe(e){const t=typeof e=="string"?e.split(""):e,n=t.length;Kr("alphabet",t);const r=new Map(t.map((o,i)=>[o,i]));return{encode:o=>(Gr(o),o.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:o=>(Gr(o),o.map(i=>{Pt("alphabet.decode",i);const s=r.get(i);if(s===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${e}`);return s}))}}function je(e=""){return Pt("join",e),{encode:t=>(Kr("join.decode",t),t.join(e)),decode:t=>(Pt("join.decode",t),t.split(e))}}function Yr(e,t="="){return Rn(e),Pt("padding",t),{encode(n){for(Kr("padding.encode",n);n.length*e%8;)n.push(t);return n},decode(n){Kr("padding.decode",n);let r=n.length;if(r*e%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===t;r--)if((r-1)*e%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,r)}}}function jf(e){return Ri(e),{encode:t=>t,decode:t=>e(t)}}function Hf(e,t,n){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(Gr(e),!e.length)return[];let r=0;const o=[],i=Array.from(e,c=>{if(Rn(c),c<0||c>=t)throw new Error(`invalid integer: ${c}`);return c}),s=i.length;for(;;){let c=0,f=!0;for(let a=r;a<s;a++){const l=i[a],h=t*c,d=h+l;if(!Number.isSafeInteger(d)||h/t!==c||d-l!==h)throw new Error("convertRadix: carry overflow");const u=d/n;c=d%n;const p=Math.floor(u);if(i[a]=p,!Number.isSafeInteger(p)||p*n+c!==d)throw new Error("convertRadix: carry overflow");if(f)p?f=!1:r=a;else continue}if(o.push(c),f)break}for(let c=0;c<e.length-1&&e[c]===0;c++)o.push(0);return o.reverse()}const Mf=(e,t)=>t===0?e:Mf(t,e%t),Wr=(e,t)=>e+(t-Mf(e,t)),Xr=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Ti(e,t,n,r){if(Gr(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Wr(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Wr(t,n)}`);let o=0,i=0;const s=Xr[t],c=Xr[n]-1,f=[];for(const a of e){if(Rn(a),a>=s)throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);if(o=o<<t|a,i+t>32)throw new Error(`convertRadix2: carry overflow pos=${i} from=${t}`);for(i+=t;i>=n;i-=n)f.push((o>>i-n&c)>>>0);const l=Xr[i];if(l===void 0)throw new Error("invalid carry");o&=l-1}if(o=o<<n-i&c,!r&&i>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&i>0&&f.push(o>>>0),f}function l1(e){Rn(e);const t=2**8;return{encode:n=>{if(!Un(n))throw new Error("radix.encode input should be Uint8Array");return Hf(Array.from(n),t,e)},decode:n=>($i("radix.decode",n),Uint8Array.from(Hf(n,e,t)))}}function ke(e,t=!1){if(Rn(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Wr(8,e)>32||Wr(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Un(n))throw new Error("radix2.encode input should be Uint8Array");return Ti(Array.from(n),8,e,!t)},decode:n=>($i("radix2.decode",n),Uint8Array.from(Ti(n,e,8,t)))}}function zf(e){return Ri(e),function(...t){try{return e.apply(null,t)}catch{}}}function d1(e,t){return Rn(e),Ri(t),{encode(n){if(!Un(n))throw new Error("checksum.encode: input should be Uint8Array");const r=t(n).slice(0,e),o=new Uint8Array(n.length+e);return o.set(n),o.set(r,n.length),o},decode(n){if(!Un(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-e),o=n.slice(-e),i=t(r).slice(0,e);for(let s=0;s<e;s++)if(i[s]!==o[s])throw new Error("Invalid checksum");return r}}}const kf=typeof Uint8Array.from([]).toBase64=="function"&&typeof Uint8Array.fromBase64=="function",Zf=(e,t)=>{Pt("base64",e);const n=t?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=t?"base64url":"base64";if(e.length>0&&!n.test(e))throw new Error("invalid base64");return Uint8Array.fromBase64(e,{alphabet:r,lastChunkHandling:"strict"})},Pi=e=>$e(l1(58),qe(e),je("")),h1=Pi("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),b1=e=>$e(d1(4,t=>e(e(t))),h1),Li=$e(qe("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),je("")),Vf=[996825010,642813549,513874426,1027748829,705979059];function ir(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<Vf.length;r++)(t>>r&1)===1&&(n^=Vf[r]);return n}function Gf(e,t,n=1){const r=e.length;let o=1;for(let i=0;i<r;i++){const s=e.charCodeAt(i);if(s<33||s>126)throw new Error(`Invalid prefix (${e})`);o=ir(o)^s>>5}o=ir(o);for(let i=0;i<r;i++)o=ir(o)^e.charCodeAt(i)&31;for(let i of t)o=ir(o)^i;for(let i=0;i<6;i++)o=ir(o);return o^=n,Li.encode(Ti([o%Xr[30]],30,5,!1))}function Kf(e){const t=e==="bech32"?1:734539939,n=ke(5),r=n.decode,o=n.encode,i=zf(r);function s(h,d,u=90){Pt("bech32.encode prefix",h),Un(d)&&(d=Array.from(d)),$i("bech32.encode",d);const p=h.length;if(p===0)throw new TypeError(`Invalid prefix length ${p}`);const m=p+7+d.length;if(u!==!1&&m>u)throw new TypeError(`Length ${m} exceeds limit ${u}`);const v=h.toLowerCase(),_=Gf(v,d,t);return`${v}1${Li.encode(d)}${_}`}function c(h,d=90){Pt("bech32.decode input",h);const u=h.length;if(u<8||d!==!1&&u>d)throw new TypeError(`invalid string length: ${u} (${h}). Expected (8..${d})`);const p=h.toLowerCase();if(h!==p&&h!==h.toUpperCase())throw new Error("String must be lowercase or uppercase");const m=p.lastIndexOf("1");if(m===0||m===-1)throw new Error('Letter "1" must be present between prefix and data only');const v=p.slice(0,m),_=p.slice(m+1);if(_.length<6)throw new Error("Data must be at least 6 characters long");const $=Li.decode(_).slice(0,-6),D=Gf(v,$,t);if(!_.endsWith(D))throw new Error(`Invalid checksum in ${h}: expected "${D}"`);return{prefix:v,words:$}}const f=zf(c);function a(h){const{prefix:d,words:u}=c(h,!1);return{prefix:d,words:u,bytes:r(u)}}function l(h,d){return s(h,o(d))}return{encode:s,decode:c,encodeFromBytes:l,decodeToBytes:a,decodeUnsafe:f,fromWords:r,fromWordsUnsafe:i,toWords:o}}const g1=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",w1={encode(e){return Ui(e),e.toHex()},decode(e){return Pt("hex",e),Uint8Array.fromHex(e)}};b1(On),Mo("Bitcoin seed");/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Yf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Jr(e,...t){if(!Yf(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Qr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Wf(e,t){Jr(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function sr(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qi(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function p1(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function y1(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function cr(e){if(typeof e=="string")e=y1(e);else if(Yf(e))e=Xf(e);else throw new Error("Uint8Array expected, got "+typeof e);return e}function Xf(e){return Uint8Array.from(e)}const yt=16,ji=new Uint8Array(16),nt=sr(ji),m1=225,E1=(e,t,n,r)=>{const o=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^m1<<24&-(o&1)}},Ze=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function x1(e){e.reverse();const t=e[15]&1;let n=0;for(let r=0;r<e.length;r++){const o=e[r];e[r]=o>>>1|n,n=(o&1)<<7}return e[0]^=-t&225,e}const v1=e=>e>64*1024?8:e>1024?4:2;class Jf{constructor(t,n){this.blockLen=yt,this.outputLen=yt,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,t=cr(t),Jr(t,16);const r=p1(t);let o=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const f=[];for(let p=0;p<128;p++)f.push({s0:Ze(o),s1:Ze(i),s2:Ze(s),s3:Ze(c)}),{s0:o,s1:i,s2:s,s3:c}=E1(o,i,s,c);const a=v1(n||1024);if(![1,2,4,8].includes(a))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=a;const h=128/a,d=this.windowSize=2**a,u=[];for(let p=0;p<h;p++)for(let m=0;m<d;m++){let v=0,_=0,$=0,D=0;for(let x=0;x<a;x++){if(!(m>>>a-x-1&1))continue;const{s0:P,s1:q,s2:L,s3:I}=f[a*p+x];v^=P,_^=q,$^=L,D^=I}u.push({s0:v,s1:_,s2:$,s3:D})}this.t=u}_updateBlock(t,n,r,o){t^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;const{W:i,t:s,windowSize:c}=this;let f=0,a=0,l=0,h=0;const d=(1<<i)-1;let u=0;for(const p of[t,n,r,o])for(let m=0;m<4;m++){const v=p>>>8*m&255;for(let _=8/i-1;_>=0;_--){const $=v>>>i*_&d,{s0:D,s1:x,s2:C,s3:P}=s[u*c+$];f^=D,a^=x,l^=C,h^=P,u+=1}}this.s0=f,this.s1=a,this.s2=l,this.s3=h}update(t){Qr(this),t=cr(t),Jr(t);const n=sr(t),r=Math.floor(t.length/yt),o=t.length%yt;for(let i=0;i<r;i++)this._updateBlock(n[i*4+0],n[i*4+1],n[i*4+2],n[i*4+3]);return o&&(ji.set(t.subarray(r*yt)),this._updateBlock(nt[0],nt[1],nt[2],nt[3]),qi(nt)),this}destroy(){const{t}=this;for(const n of t)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(t){Qr(this),Wf(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=sr(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t}digest(){const t=new Uint8Array(yt);return this.digestInto(t),this.destroy(),t}}class B1 extends Jf{constructor(t,n){t=cr(t),Jr(t);const r=x1(Xf(t));super(r,n),qi(r)}update(t){t=cr(t),Qr(this);const n=sr(t),r=t.length%yt,o=Math.floor(t.length/yt);for(let i=0;i<o;i++)this._updateBlock(Ze(n[i*4+3]),Ze(n[i*4+2]),Ze(n[i*4+1]),Ze(n[i*4+0]));return r&&(ji.set(t.subarray(o*yt)),this._updateBlock(Ze(nt[3]),Ze(nt[2]),Ze(nt[1]),Ze(nt[0])),qi(nt)),this}digestInto(t){Qr(this),Wf(t,this),this.finished=!0;const{s0:n,s1:r,s2:o,s3:i}=this,s=sr(t);return s[0]=n,s[1]=r,s[2]=o,s[3]=i,t.reverse()}}function Qf(e){const t=(r,o)=>e(o,r.length).update(cr(r)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(r,o)=>e(r,o),t}Qf((e,t)=>new Jf(e,t)),Qf((e,t)=>new B1(e,t));const ea=Ut(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),D1=ea.create(BigInt("-3")),A1=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");Tr({a:D1,b:A1,Fp:ea,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},On);const ta=Ut(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),O1=ta.create(BigInt("-3")),S1=BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");Tr({a:O1,b:S1,Fp:ta,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},m0);const na=Ut(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),_1=na.create(BigInt("-3")),I1=BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");Tr({a:_1,b:I1,Fp:na,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},y0);var N1={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(f,a,l){this.fn=f,this.context=a,this.once=l||!1}function i(f,a,l,h,d){if(typeof l!="function")throw new TypeError("The listener must be a function");var u=new o(l,h||f,d),p=n?n+a:a;return f._events[p]?f._events[p].fn?f._events[p]=[f._events[p],u]:f._events[p].push(u):(f._events[p]=u,f._eventsCount++),f}function s(f,a){--f._eventsCount===0?f._events=new r:delete f._events[a]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var a=[],l,h;if(this._eventsCount===0)return a;for(h in l=this._events)t.call(l,h)&&a.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(l)):a},c.prototype.listeners=function(a){var l=n?n+a:a,h=this._events[l];if(!h)return[];if(h.fn)return[h.fn];for(var d=0,u=h.length,p=new Array(u);d<u;d++)p[d]=h[d].fn;return p},c.prototype.listenerCount=function(a){var l=n?n+a:a,h=this._events[l];return h?h.fn?1:h.length:0},c.prototype.emit=function(a,l,h,d,u,p){var m=n?n+a:a;if(!this._events[m])return!1;var v=this._events[m],_=arguments.length,$,D;if(v.fn){switch(v.once&&this.removeListener(a,v.fn,void 0,!0),_){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,l),!0;case 3:return v.fn.call(v.context,l,h),!0;case 4:return v.fn.call(v.context,l,h,d),!0;case 5:return v.fn.call(v.context,l,h,d,u),!0;case 6:return v.fn.call(v.context,l,h,d,u,p),!0}for(D=1,$=new Array(_-1);D<_;D++)$[D-1]=arguments[D];v.fn.apply(v.context,$)}else{var x=v.length,C;for(D=0;D<x;D++)switch(v[D].once&&this.removeListener(a,v[D].fn,void 0,!0),_){case 1:v[D].fn.call(v[D].context);break;case 2:v[D].fn.call(v[D].context,l);break;case 3:v[D].fn.call(v[D].context,l,h);break;case 4:v[D].fn.call(v[D].context,l,h,d);break;default:if(!$)for(C=1,$=new Array(_-1);C<_;C++)$[C-1]=arguments[C];v[D].fn.apply(v[D].context,$)}}return!0},c.prototype.on=function(a,l,h){return i(this,a,l,h,!1)},c.prototype.once=function(a,l,h){return i(this,a,l,h,!0)},c.prototype.removeListener=function(a,l,h,d){var u=n?n+a:a;if(!this._events[u])return this;if(!l)return s(this,u),this;var p=this._events[u];if(p.fn)p.fn===l&&(!d||p.once)&&(!h||p.context===h)&&s(this,u);else{for(var m=0,v=[],_=p.length;m<_;m++)(p[m].fn!==l||d&&!p[m].once||h&&p[m].context!==h)&&v.push(p[m]);v.length?this._events[u]=v.length===1?v[0]:v:s(this,u)}return this},c.prototype.removeAllListeners=function(a){var l;return a?(l=n?n+a:a,this._events[l]&&s(this,l)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c})(N1);function F1(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let a=0;a<t.length;a++)t[a]=255;for(let a=0;a<e.length;a++){const l=e.charAt(a),h=l.charCodeAt(0);if(t[h]!==255)throw new TypeError(l+" is ambiguous");t[h]=a}const n=e.length,r=e.charAt(0),o=Math.log(n)/Math.log(256),i=Math.log(256)/Math.log(n);function s(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";let l=0,h=0,d=0;const u=a.length;for(;d!==u&&a[d]===0;)d++,l++;const p=(u-d)*i+1>>>0,m=new Uint8Array(p);for(;d!==u;){let $=a[d],D=0;for(let x=p-1;($!==0||D<h)&&x!==-1;x--,D++)$+=256*m[x]>>>0,m[x]=$%n>>>0,$=$/n>>>0;if($!==0)throw new Error("Non-zero carry");h=D,d++}let v=p-h;for(;v!==p&&m[v]===0;)v++;let _=r.repeat(l);for(;v<p;++v)_+=e.charAt(m[v]);return _}function c(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;let l=0,h=0,d=0;for(;a[l]===r;)h++,l++;const u=(a.length-l)*o+1>>>0,p=new Uint8Array(u);for(;l<a.length;){const $=a.charCodeAt(l);if($>255)return;let D=t[$];if(D===255)return;let x=0;for(let C=u-1;(D!==0||x<d)&&C!==-1;C--,x++)D+=n*p[C]>>>0,p[C]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");d=x,l++}let m=u-d;for(;m!==u&&p[m]===0;)m++;const v=new Uint8Array(h+(u-m));let _=h;for(;m!==u;)v[_++]=p[m++];return v}function f(a){const l=c(a);if(l)return l;throw new Error("Non-base"+n+" character")}return{encode:s,decodeUnsafe:c,decode:f}}var C1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";F1(C1);function U1(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ra(e,...t){if(!U1(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function oa(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function R1(e,t){ra(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const $n=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hi=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function $1(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function ia(e){return typeof e=="string"&&(e=$1(e)),ra(e),e}class T1{clone(){return this._cloneInto()}}function P1(e){const t=r=>e().update(ia(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function L1(e=32){if($n&&typeof $n.getRandomValues=="function")return $n.getRandomValues(new Uint8Array(e));if($n&&typeof $n.randomBytes=="function")return $n.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function q1(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}class j1 extends T1{constructor(t,n,r,o){super(),this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Hi(this.buffer)}update(t){oa(this);const{view:n,buffer:r,blockLen:o}=this;t=ia(t);const i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=Hi(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){oa(this),R1(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;q1(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=Hi(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.length=o,t.pos=c,t.finished=i,t.destroyed=s,o%n&&t.buffer.set(r),t}}const eo=BigInt(2**32-1),Mi=BigInt(32);function sa(e,t=!1){return t?{h:Number(e&eo),l:Number(e>>Mi&eo)}:{h:Number(e>>Mi&eo)|0,l:Number(e&eo)|0}}function H1(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=sa(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const M1=(e,t)=>BigInt(e>>>0)<<Mi|BigInt(t>>>0),z1=(e,t,n)=>e>>>n,k1=(e,t,n)=>e<<32-n|t>>>n,Z1=(e,t,n)=>e>>>n|t<<32-n,V1=(e,t,n)=>e<<32-n|t>>>n,G1=(e,t,n)=>e<<64-n|t>>>n-32,K1=(e,t,n)=>e>>>n-32|t<<64-n,Y1=(e,t)=>t,W1=(e,t)=>e,X1=(e,t,n)=>e<<n|t>>>32-n,J1=(e,t,n)=>t<<n|e>>>32-n,Q1=(e,t,n)=>t<<n-32|e>>>64-n,e2=(e,t,n)=>e<<n-32|t>>>64-n;function t2(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const n2=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),r2=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,o2=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),i2=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,s2=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),c2=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,X={fromBig:sa,split:H1,toBig:M1,shrSH:z1,shrSL:k1,rotrSH:Z1,rotrSL:V1,rotrBH:G1,rotrBL:K1,rotr32H:Y1,rotr32L:W1,rotlSH:X1,rotlSL:J1,rotlBH:Q1,rotlBL:e2,add:t2,add3L:n2,add3H:r2,add4L:o2,add4H:i2,add5H:c2,add5L:s2},[f2,a2]=X.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Lt=new Uint32Array(80),qt=new Uint32Array(80);class u2 extends j1{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Lt[D]=t.getUint32(n),qt[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Lt[D-15]|0,C=qt[D-15]|0,P=X.rotrSH(x,C,1)^X.rotrSH(x,C,8)^X.shrSH(x,C,7),q=X.rotrSL(x,C,1)^X.rotrSL(x,C,8)^X.shrSL(x,C,7),L=Lt[D-2]|0,I=qt[D-2]|0,k=X.rotrSH(L,I,19)^X.rotrBH(L,I,61)^X.shrSH(L,I,6),H=X.rotrSL(L,I,19)^X.rotrBL(L,I,61)^X.shrSL(L,I,6),E=X.add4L(q,H,qt[D-7],qt[D-16]),g=X.add4H(E,P,k,Lt[D-7],Lt[D-16]);Lt[D]=g|0,qt[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:$}=this;for(let D=0;D<80;D++){const x=X.rotrSH(h,d,14)^X.rotrSH(h,d,18)^X.rotrBH(h,d,41),C=X.rotrSL(h,d,14)^X.rotrSL(h,d,18)^X.rotrBL(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=X.add5L($,C,q,a2[D],qt[D]),I=X.add5H(L,_,x,P,f2[D],Lt[D]),k=L|0,H=X.rotrSH(r,o,28)^X.rotrBH(r,o,34)^X.rotrBH(r,o,39),E=X.rotrSL(r,o,28)^X.rotrBL(r,o,34)^X.rotrBL(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,$=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=X.add(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=X.add3L(k,E,y);r=X.add3H(b,I,H,g),o=b|0}({h:r,l:o}=X.add(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=X.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=X.add(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=X.add(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=X.add(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=X.add(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=X.add(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:$}=X.add(this.Hh|0,this.Hl|0,_|0,$|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,$)}roundClean(){Lt.fill(0),qt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const l2=P1(()=>new u2);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zi=BigInt(0),ca=BigInt(1),d2=BigInt(2);function ki(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Zi(e){if(!ki(e))throw new Error("Uint8Array expected")}function Vi(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}const h2=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Gi(e){Zi(e);let t="";for(let n=0;n<e.length;n++)t+=h2[e[n]];return t}function fa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?zi:BigInt("0x"+e)}const mt={_0:48,_9:57,A:65,F:70,a:97,f:102};function aa(e){if(e>=mt._0&&e<=mt._9)return e-mt._0;if(e>=mt.A&&e<=mt.F)return e-(mt.A-10);if(e>=mt.a&&e<=mt.f)return e-(mt.a-10)}function ua(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=aa(e.charCodeAt(i)),c=aa(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function b2(e){return fa(Gi(e))}function to(e){return Zi(e),fa(Gi(Uint8Array.from(e).reverse()))}function la(e,t){return ua(e.toString(16).padStart(t*2,"0"))}function Ki(e,t){return la(e,t).reverse()}function Et(e,t,n){let r;if(typeof t=="string")try{r=ua(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ki(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function da(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Zi(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}const Yi=e=>typeof e=="bigint"&&zi<=e;function g2(e,t,n){return Yi(e)&&Yi(t)&&Yi(n)&&t<=e&&e<n}function fr(e,t,n,r){if(!g2(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function w2(e){let t;for(t=0;e>zi;e>>=ca,t+=1);return t}const p2=e=>(d2<<BigInt(e-1))-ca,y2={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||ki(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function Wi(e,t,n={}){const r=(o,i,s)=>{const c=y2[i];if(typeof c!="function")throw new Error("invalid validator function");const f=e[o];if(!(s&&f===void 0)&&!c(f,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+f)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}function ha(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const be=BigInt(0),fe=BigInt(1),hn=BigInt(2),m2=BigInt(3),Xi=BigInt(4),ba=BigInt(5),ga=BigInt(8);function le(e,t){const n=e%t;return n>=be?n:t+n}function E2(e,t,n){if(t<be)throw new Error("invalid exponent, negatives unsupported");if(n<=be)throw new Error("invalid modulus");if(n===fe)return be;let r=fe;for(;t>be;)t&fe&&(r=r*e%n),e=e*e%n,t>>=fe;return r}function rt(e,t,n){let r=e;for(;t-- >be;)r*=r,r%=n;return r}function wa(e,t){if(e===be)throw new Error("invert: expected non-zero number");if(t<=be)throw new Error("invert: expected positive modulus, got "+t);let n=le(e,t),r=t,o=be,i=fe;for(;n!==be;){const s=r/n,c=r%n,f=o-i*s;r=n,n=c,o=i,i=f}if(r!==fe)throw new Error("invert: does not exist");return le(o,t)}function x2(e){const t=(e-fe)/hn;let n,r,o;for(n=e-fe,r=0;n%hn===be;n/=hn,r++);for(o=hn;o<e&&E2(o,t,e)!==e-fe;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(r===1){const s=(e+fe)/Xi;return function(c,f){const a=c.pow(f,s);if(!c.eql(c.sqr(a),f))throw new Error("Cannot find square root");return a}}const i=(n+fe)/hn;return function(s,c){if(s.pow(c,t)===s.neg(s.ONE))throw new Error("Cannot find square root");let f=r,a=s.pow(s.mul(s.ONE,o),n),l=s.pow(c,i),h=s.pow(c,n);for(;!s.eql(h,s.ONE);){if(s.eql(h,s.ZERO))return s.ZERO;let d=1;for(let p=s.sqr(h);d<f&&!s.eql(p,s.ONE);d++)p=s.sqr(p);const u=s.pow(a,fe<<BigInt(f-d-1));a=s.sqr(u),l=s.mul(l,u),h=s.mul(h,a),f=d}return l}}function v2(e){if(e%Xi===m2){const t=(e+fe)/Xi;return function(n,r){const o=n.pow(r,t);if(!n.eql(n.sqr(o),r))throw new Error("Cannot find square root");return o}}if(e%ga===ba){const t=(e-ba)/ga;return function(n,r){const o=n.mul(r,hn),i=n.pow(o,t),s=n.mul(r,i),c=n.mul(n.mul(s,hn),i),f=n.mul(s,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),r))throw new Error("Cannot find square root");return f}}return x2(e)}const B2=(e,t)=>(le(e,t)&fe)===fe,D2=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function A2(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=D2.reduce((r,o)=>(r[o]="function",r),t);return Wi(e,n)}function O2(e,t,n){if(n<be)throw new Error("invalid exponent, negatives unsupported");if(n===be)return e.ONE;if(n===fe)return t;let r=e.ONE,o=t;for(;n>be;)n&fe&&(r=e.mul(r,o)),o=e.sqr(o),n>>=fe;return r}function S2(e,t){const n=new Array(t.length),r=t.reduce((i,s,c)=>e.is0(s)?i:(n[c]=i,e.mul(i,s)),e.ONE),o=e.inv(r);return t.reduceRight((i,s,c)=>e.is0(s)?i:(n[c]=e.mul(i,n[c]),e.mul(i,s)),o),n}function pa(e,t){const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ya(e,t,n=!1,r={}){if(e<=be)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:i}=pa(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const c=Object.freeze({ORDER:e,isLE:n,BITS:o,BYTES:i,MASK:p2(o),ZERO:be,ONE:fe,create:f=>le(f,e),isValid:f=>{if(typeof f!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof f);return be<=f&&f<e},is0:f=>f===be,isOdd:f=>(f&fe)===fe,neg:f=>le(-f,e),eql:(f,a)=>f===a,sqr:f=>le(f*f,e),add:(f,a)=>le(f+a,e),sub:(f,a)=>le(f-a,e),mul:(f,a)=>le(f*a,e),pow:(f,a)=>O2(c,f,a),div:(f,a)=>le(f*wa(a,e),e),sqrN:f=>f*f,addN:(f,a)=>f+a,subN:(f,a)=>f-a,mulN:(f,a)=>f*a,inv:f=>wa(f,e),sqrt:r.sqrt||(f=>(s||(s=v2(e)),s(c,f))),invertBatch:f=>S2(c,f),cmov:(f,a,l)=>l?a:f,toBytes:f=>n?Ki(f,i):la(f,i),fromBytes:f=>{if(f.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+f.length);return n?to(f):b2(f)}});return Object.freeze(c)}const ma=BigInt(0),no=BigInt(1);function Ji(e,t){const n=t.negate();return e?n:t}function Ea(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Qi(e,t){Ea(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1);return{windows:n,windowSize:r}}function _2(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function I2(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const es=new WeakMap,xa=new WeakMap;function ts(e){return xa.get(e)||1}function N2(e,t){return{constTimeNegate:Ji,hasPrecomputes(n){return ts(n)!==1},unsafeLadder(n,r,o=e.ZERO){let i=n;for(;r>ma;)r&no&&(o=o.add(i)),i=i.double(),r>>=no;return o},precomputeWindow(n,r){const{windows:o,windowSize:i}=Qi(r,t),s=[];let c=n,f=c;for(let a=0;a<o;a++){f=c,s.push(f);for(let l=1;l<i;l++)f=f.add(c),s.push(f);c=f.double()}return s},wNAF(n,r,o){const{windows:i,windowSize:s}=Qi(n,t);let c=e.ZERO,f=e.BASE;const a=BigInt(2**n-1),l=2**n,h=BigInt(n);for(let d=0;d<i;d++){const u=d*s;let p=Number(o&a);o>>=h,p>s&&(p-=l,o+=no);const m=u,v=u+Math.abs(p)-1,_=d%2!==0,$=p<0;p===0?f=f.add(Ji(_,r[m])):c=c.add(Ji($,r[v]))}return{p:c,f}},wNAFUnsafe(n,r,o,i=e.ZERO){const{windows:s,windowSize:c}=Qi(n,t),f=BigInt(2**n-1),a=2**n,l=BigInt(n);for(let h=0;h<s;h++){const d=h*c;if(o===ma)break;let u=Number(o&f);if(o>>=l,u>c&&(u-=a,o+=no),u===0)continue;let p=r[d+Math.abs(u)-1];u<0&&(p=p.negate()),i=i.add(p)}return i},getPrecomputes(n,r,o){let i=es.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&es.set(r,o(i))),i},wNAFCached(n,r,o){const i=ts(n);return this.wNAF(i,this.getPrecomputes(i,n,o),r)},wNAFCachedUnsafe(n,r,o,i){const s=ts(n);return s===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(s,this.getPrecomputes(s,n,o),r,i)},setWindowSize(n,r){Ea(r,t),xa.set(n,r),es.delete(n)}}}function F2(e,t,n,r){if(_2(n,e),I2(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,i=w2(BigInt(n.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,f=new Array(c+1).fill(o),a=Math.floor((t.BITS-1)/s)*s;let l=o;for(let h=a;h>=0;h-=s){f.fill(o);for(let u=0;u<r.length;u++){const p=r[u],m=Number(p>>BigInt(h)&BigInt(c));f[m]=f[m].add(n[u])}let d=o;for(let u=f.length-1,p=o;u>0;u--)p=p.add(f[u]),d=d.add(p);if(l=l.add(d),h!==0)for(let u=0;u<s;u++)l=l.double()}return l}function C2(e){return A2(e.Fp),Wi(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...pa(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const We=BigInt(0),Te=BigInt(1),ro=BigInt(2),U2=BigInt(8),R2={zip215:!0};function $2(e){const t=C2(e);return Wi(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function T2(e){const t=$2(e),{Fp:n,n:r,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:f}=t,a=ro<<BigInt(c*8)-Te,l=n.create,h=ya(t.n,t.nBitLength),d=t.uvRatio||((b,w)=>{try{return{isValid:!0,value:n.sqrt(b*n.inv(w))}}catch{return{isValid:!1,value:We}}}),u=t.adjustScalarBytes||(b=>b),p=t.domain||((b,w,B)=>{if(Vi("phflag",B),w.length||B)throw new Error("Contexts/pre-hash are not supported");return b});function m(b,w){fr("coordinate "+b,w,We,a)}function v(b){if(!(b instanceof D))throw new Error("ExtendedPoint expected")}const _=ha((b,w)=>{const{ex:B,ey:A,ez:O}=b,S=b.is0();w==null&&(w=S?U2:n.inv(O));const N=l(B*w),R=l(A*w),U=l(O*w);if(S)return{x:We,y:Te};if(U!==Te)throw new Error("invZ was invalid");return{x:N,y:R}}),$=ha(b=>{const{a:w,d:B}=t;if(b.is0())throw new Error("bad point: ZERO");const{ex:A,ey:O,ez:S,et:N}=b,R=l(A*A),U=l(O*O),T=l(S*S),F=l(T*T),j=l(R*w),M=l(T*l(j+U)),V=l(F+l(B*l(R*U)));if(M!==V)throw new Error("bad point: equation left != right (1)");const z=l(A*O),Z=l(S*N);if(z!==Z)throw new Error("bad point: equation left != right (2)");return!0});class D{constructor(w,B,A,O){this.ex=w,this.ey=B,this.ez=A,this.et=O,m("x",w),m("y",B),m("z",A),m("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof D)throw new Error("extended point not allowed");const{x:B,y:A}=w||{};return m("x",B),m("y",A),new D(B,A,Te,l(B*A))}static normalizeZ(w){const B=n.invertBatch(w.map(A=>A.ez));return w.map((A,O)=>A.toAffine(B[O])).map(D.fromAffine)}static msm(w,B){return F2(D,h,w,B)}_setWindowSize(w){P.setWindowSize(this,w)}assertValidity(){$(this)}equals(w){v(w);const{ex:B,ey:A,ez:O}=this,{ex:S,ey:N,ez:R}=w,U=l(B*R),T=l(S*O),F=l(A*R),j=l(N*O);return U===T&&F===j}is0(){return this.equals(D.ZERO)}negate(){return new D(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:w}=t,{ex:B,ey:A,ez:O}=this,S=l(B*B),N=l(A*A),R=l(ro*l(O*O)),U=l(w*S),T=B+A,F=l(l(T*T)-S-N),j=U+N,M=j-R,V=U-N,z=l(F*M),Z=l(j*V),W=l(F*V),J=l(M*j);return new D(z,Z,J,W)}add(w){v(w);const{a:B,d:A}=t,{ex:O,ey:S,ez:N,et:R}=this,{ex:U,ey:T,ez:F,et:j}=w;if(B===BigInt(-1)){const wl=l((S-O)*(T+U)),pl=l((S+O)*(T-U)),$s=l(pl-wl);if($s===We)return this.double();const yl=l(N*ro*j),ml=l(R*ro*F),El=ml+yl,xl=pl+wl,vl=ml-yl,kp=l(El*$s),Zp=l(xl*vl),Vp=l(El*vl),Gp=l($s*xl);return new D(kp,Zp,Gp,Vp)}const M=l(O*U),V=l(S*T),z=l(R*A*j),Z=l(N*F),W=l((O+S)*(U+T)-M-V),J=Z-z,ee=Z+z,oe=l(V-B*M),se=l(W*J),Ot=l(ee*oe),Ao=l(W*oe),zp=l(J*ee);return new D(se,Ot,zp,Ao)}subtract(w){return this.add(w.negate())}wNAF(w){return P.wNAFCached(this,w,D.normalizeZ)}multiply(w){const B=w;fr("scalar",B,Te,r);const{p:A,f:O}=this.wNAF(B);return D.normalizeZ([A,O])[0]}multiplyUnsafe(w,B=D.ZERO){const A=w;return fr("scalar",A,We,r),A===We?C:this.is0()||A===Te?this:P.wNAFCachedUnsafe(this,A,D.normalizeZ,B)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return P.unsafeLadder(this,r).is0()}toAffine(w){return _(this,w)}clearCofactor(){const{h:w}=t;return w===Te?this:this.multiplyUnsafe(w)}static fromHex(w,B=!1){const{d:A,a:O}=t,S=n.BYTES;w=Et("pointHex",w,S),Vi("zip215",B);const N=w.slice(),R=w[S-1];N[S-1]=R&-129;const U=to(N),T=B?a:n.ORDER;fr("pointHex.y",U,We,T);const F=l(U*U),j=l(F-Te),M=l(A*F-O);let{isValid:V,value:z}=d(j,M);if(!V)throw new Error("Point.fromHex: invalid y coordinate");const Z=(z&Te)===Te,W=(R&128)!==0;if(!B&&z===We&&W)throw new Error("Point.fromHex: x=0 and x_0=1");return W!==Z&&(z=l(-z)),D.fromAffine({x:z,y:U})}static fromPrivateKey(w){return I(w).point}toRawBytes(){const{x:w,y:B}=this.toAffine(),A=Ki(B,n.BYTES);return A[A.length-1]|=w&Te?128:0,A}toHex(){return Gi(this.toRawBytes())}}D.BASE=new D(t.Gx,t.Gy,Te,l(t.Gx*t.Gy)),D.ZERO=new D(We,Te,Te,We);const{BASE:x,ZERO:C}=D,P=N2(D,c*8);function q(b){return le(b,r)}function L(b){return q(to(b))}function I(b){const w=n.BYTES;b=Et("private key",b,w);const B=Et("hashed private key",i(b),2*w),A=u(B.slice(0,w)),O=B.slice(w,2*w),S=L(A),N=x.multiply(S),R=N.toRawBytes();return{head:A,prefix:O,scalar:S,point:N,pointBytes:R}}function k(b){return I(b).pointBytes}function H(b=new Uint8Array,...w){const B=da(...w);return L(i(p(B,Et("context",b),!!o)))}function E(b,w,B={}){b=Et("message",b),o&&(b=o(b));const{prefix:A,scalar:O,pointBytes:S}=I(w),N=H(B.context,A,b),R=x.multiply(N).toRawBytes(),U=H(B.context,R,S,b),T=q(N+U*O);fr("signature.s",T,We,r);const F=da(R,Ki(T,n.BYTES));return Et("result",F,n.BYTES*2)}const g=R2;function y(b,w,B,A=g){const{context:O,zip215:S}=A,N=n.BYTES;b=Et("signature",b,2*N),w=Et("message",w),B=Et("publicKey",B,N),S!==void 0&&Vi("zip215",S),o&&(w=o(w));const R=to(b.slice(N,2*N));let U,T,F;try{U=D.fromHex(B,S),T=D.fromHex(b.slice(0,N),S),F=x.multiplyUnsafe(R)}catch{return!1}if(!S&&U.isSmallOrder())return!1;const j=H(O,T.toRawBytes(),U.toRawBytes(),w);return T.add(U.multiplyUnsafe(j)).subtract(F).clearCofactor().equals(D.ZERO)}return x._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:E,verify:y,ExtendedPoint:D,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(n.BYTES),precompute(b=8,w=D.BASE){return w._setWindowSize(b),w.multiply(BigInt(3)),w}}}}BigInt(0),BigInt(1);const ns=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),va=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const P2=BigInt(1),Ba=BigInt(2);BigInt(3);const L2=BigInt(5),q2=BigInt(8);function j2(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=ns,s=e*e%i*e%i,c=rt(s,Ba,i)*s%i,f=rt(c,P2,i)*e%i,a=rt(f,L2,i)*f%i,l=rt(a,t,i)*a%i,h=rt(l,n,i)*l%i,d=rt(h,r,i)*h%i,u=rt(d,o,i)*d%i,p=rt(u,o,i)*d%i,m=rt(p,t,i)*a%i;return{pow_p_5_8:rt(m,Ba,i)*e%i,b2:s}}function H2(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function M2(e,t){const n=ns,r=le(t*t*t,n),o=le(r*r*t,n),i=j2(e*o).pow_p_5_8;let s=le(e*r*i,n);const c=le(t*s*s,n),f=s,a=le(s*va,n),l=c===e,h=c===le(-e,n),d=c===le(-e*va,n);return l&&(s=f),(h||d)&&(s=a),B2(s,n)&&(s=le(-s,n)),{isValid:l||h,value:s}}const z2=ya(ns,void 0,!0),k2={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:z2,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:q2,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:l2,randomBytes:L1,adjustScalarBytes:H2,uvRatio:M2};T2(k2);function Z2(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(n[s]!==255)throw new TypeError(i+" is ambiguous");n[s]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,v=0,_=0,$=p.length;_!==$&&p[_]===0;)_++,m++;for(var D=($-_)*l+1>>>0,x=new Uint8Array(D);_!==$;){for(var C=p[_],P=0,q=D-1;(C!==0||P<v)&&q!==-1;q--,P++)C+=256*x[q]>>>0,x[q]=C%c>>>0,C=C/c>>>0;if(C!==0)throw new Error("Non-zero carry");v=P,_++}for(var L=D-v;L!==D&&x[L]===0;)L++;for(var I=f.repeat(m);L<D;++L)I+=e.charAt(x[L]);return I}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var v=0,_=0;p[m]===f;)v++,m++;for(var $=(p.length-m)*a+1>>>0,D=new Uint8Array($);p[m];){var x=n[p.charCodeAt(m)];if(x===255)return;for(var C=0,P=$-1;(x!==0||C<_)&&P!==-1;P--,C++)x+=c*D[P]>>>0,D[P]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");_=C,m++}if(p[m]!==" "){for(var q=$-_;q!==$&&D[q]===0;)q++;for(var L=new Uint8Array(v+($-q)),I=v;q!==$;)L[I++]=D[q++];return L}}}function u(p){var m=d(p);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:d,decode:u}}var V2=Z2,G2=V2;const Da=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},K2=e=>new TextEncoder().encode(e),Y2=e=>new TextDecoder().decode(e);class W2{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class X2{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Aa(this,t)}}class J2{constructor(t){this.decoders=t}or(t){return Aa(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Aa=(e,t)=>new J2({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Q2{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new W2(t,n,r),this.decoder=new X2(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const oo=({name:e,prefix:t,encode:n,decode:r})=>new Q2(e,t,n,r),ar=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=G2(n,t);return oo({prefix:e,name:t,encode:r,decode:i=>Da(o(i))})},eb=(e,t,n,r)=>{const o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;const s=new Uint8Array(i*n/8|0);let c=0,f=0,a=0;for(let l=0;l<i;++l){const h=o[e[l]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);f=f<<n|h,c+=n,c>=8&&(c-=8,s[a++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return s},tb=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let i="",s=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],s+=8;s>n;)s-=n,i+=t[o&c>>s];if(s&&(i+=t[o&c<<n-s]),r)for(;i.length*n&7;)i+="=";return i},ge=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>oo({prefix:t,name:e,encode(o){return tb(o,r,n)},decode(o){return eb(o,r,n,e)}}),nb=oo({prefix:"\0",name:"identity",encode:e=>Y2(e),decode:e=>K2(e)});var rb=Object.freeze({__proto__:null,identity:nb});const ob=ge({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ib=Object.freeze({__proto__:null,base2:ob});const sb=ge({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var cb=Object.freeze({__proto__:null,base8:sb});const fb=ar({prefix:"9",name:"base10",alphabet:"0123456789"});var ab=Object.freeze({__proto__:null,base10:fb});const ub=ge({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lb=ge({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var db=Object.freeze({__proto__:null,base16:ub,base16upper:lb});const hb=ge({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bb=ge({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gb=ge({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wb=ge({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pb=ge({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yb=ge({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mb=ge({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Eb=ge({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),xb=ge({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vb=Object.freeze({__proto__:null,base32:hb,base32upper:bb,base32pad:gb,base32padupper:wb,base32hex:pb,base32hexupper:yb,base32hexpad:mb,base32hexpadupper:Eb,base32z:xb});const Bb=ar({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Db=ar({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ab=Object.freeze({__proto__:null,base36:Bb,base36upper:Db});const Ob=ar({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sb=ar({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _b=Object.freeze({__proto__:null,base58btc:Ob,base58flickr:Sb});const Ib=ge({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nb=ge({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fb=ge({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Cb=ge({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ub=Object.freeze({__proto__:null,base64:Ib,base64pad:Nb,base64url:Fb,base64urlpad:Cb});const Oa=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Rb=Oa.reduce((e,t,n)=>(e[n]=t,e),[]),$b=Oa.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function Tb(e){return e.reduce((t,n)=>(t+=Rb[n],t),"")}function Pb(e){const t=[];for(const n of e){const r=$b[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const Lb=oo({prefix:"\u{1F680}",name:"base256emoji",encode:Tb,decode:Pb});var qb=Object.freeze({__proto__:null,base256emoji:Lb}),jb=_a,Sa=128,Hb=127,Mb=~Hb,zb=Math.pow(2,31);function _a(e,t,n){t=t||[],n=n||0;for(var r=n;e>=zb;)t[n++]=e&255|Sa,e/=128;for(;e&Mb;)t[n++]=e&255|Sa,e>>>=7;return t[n]=e|0,_a.bytes=n-r+1,t}var kb=rs,Zb=128,Ia=127;function rs(e,r){var n=0,r=r||0,o=0,i=r,s,c=e.length;do{if(i>=c)throw rs.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Ia)<<o:(s&Ia)*Math.pow(2,o),o+=7}while(s>=Zb);return rs.bytes=i-r,n}var Vb=Math.pow(2,7),Gb=Math.pow(2,14),Kb=Math.pow(2,21),Yb=Math.pow(2,28),Wb=Math.pow(2,35),Xb=Math.pow(2,42),Jb=Math.pow(2,49),Qb=Math.pow(2,56),eg=Math.pow(2,63),tg=function(e){return e<Vb?1:e<Gb?2:e<Kb?3:e<Yb?4:e<Wb?5:e<Xb?6:e<Jb?7:e<Qb?8:e<eg?9:10},ng={encode:jb,decode:kb,encodingLength:tg},Na=ng;const Fa=(e,t,n=0)=>(Na.encode(e,t,n),t),Ca=e=>Na.encodingLength(e),os=(e,t)=>{const n=t.byteLength,r=Ca(e),o=r+Ca(n),i=new Uint8Array(o+n);return Fa(e,i,0),Fa(n,i,r),i.set(t,o),new rg(e,n,t,i)};class rg{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const Ua=({name:e,code:t,encode:n})=>new og(e,t,n);class og{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?os(this.code,n):n.then(r=>os(this.code,r))}else throw Error("Unknown type, must be binary type")}}const Ra=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ig=Ua({name:"sha2-256",code:18,encode:Ra("SHA-256")}),sg=Ua({name:"sha2-512",code:19,encode:Ra("SHA-512")});var cg=Object.freeze({__proto__:null,sha256:ig,sha512:sg});const $a=0,fg="identity",Ta=Da;var ag=Object.freeze({__proto__:null,identity:{code:$a,name:fg,encode:Ta,digest:e=>os($a,Ta(e))}});new TextEncoder,new TextDecoder,{...rb,...ib,...cb,...ab,...db,...vb,...Ab,..._b,...Ub,...qb},{...cg,...ag};function ug(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(n[s]!==255)throw new TypeError(i+" is ambiguous");n[s]=o}var c=e.length,f=e.charAt(0),a=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function h(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var m=0,v=0,_=0,$=p.length;_!==$&&p[_]===0;)_++,m++;for(var D=($-_)*l+1>>>0,x=new Uint8Array(D);_!==$;){for(var C=p[_],P=0,q=D-1;(C!==0||P<v)&&q!==-1;q--,P++)C+=256*x[q]>>>0,x[q]=C%c>>>0,C=C/c>>>0;if(C!==0)throw new Error("Non-zero carry");v=P,_++}for(var L=D-v;L!==D&&x[L]===0;)L++;for(var I=f.repeat(m);L<D;++L)I+=e.charAt(x[L]);return I}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var v=0,_=0;p[m]===f;)v++,m++;for(var $=(p.length-m)*a+1>>>0,D=new Uint8Array($);p[m];){var x=n[p.charCodeAt(m)];if(x===255)return;for(var C=0,P=$-1;(x!==0||C<_)&&P!==-1;P--,C++)x+=c*D[P]>>>0,D[P]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");_=C,m++}if(p[m]!==" "){for(var q=$-_;q!==$&&D[q]===0;)q++;for(var L=new Uint8Array(v+($-q)),I=v;q!==$;)L[I++]=D[q++];return L}}}function u(p){var m=d(p);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:d,decode:u}}var lg=ug,dg=lg;const Pa=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},hg=e=>new TextEncoder().encode(e),bg=e=>new TextDecoder().decode(e);class gg{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class wg{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return La(this,t)}}class pg{constructor(t){this.decoders=t}or(t){return La(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const La=(e,t)=>new pg({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class yg{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new gg(t,n,r),this.decoder=new wg(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const io=({name:e,prefix:t,encode:n,decode:r})=>new yg(e,t,n,r),ur=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=dg(n,t);return io({prefix:e,name:t,encode:r,decode:i=>Pa(o(i))})},mg=(e,t,n,r)=>{const o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;const s=new Uint8Array(i*n/8|0);let c=0,f=0,a=0;for(let l=0;l<i;++l){const h=o[e[l]];if(h===void 0)throw new SyntaxError(`Non-${r} character`);f=f<<n|h,c+=n,c>=8&&(c-=8,s[a++]=255&f>>c)}if(c>=n||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return s},Eg=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let i="",s=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],s+=8;s>n;)s-=n,i+=t[o&c>>s];if(s&&(i+=t[o&c<<n-s]),r)for(;i.length*n&7;)i+="=";return i},we=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>io({prefix:t,name:e,encode(o){return Eg(o,r,n)},decode(o){return mg(o,r,n,e)}}),xg=io({prefix:"\0",name:"identity",encode:e=>bg(e),decode:e=>hg(e)});var vg=Object.freeze({__proto__:null,identity:xg});const Bg=we({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dg=Object.freeze({__proto__:null,base2:Bg});const Ag=we({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Og=Object.freeze({__proto__:null,base8:Ag});const Sg=ur({prefix:"9",name:"base10",alphabet:"0123456789"});var _g=Object.freeze({__proto__:null,base10:Sg});const Ig=we({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ng=we({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fg=Object.freeze({__proto__:null,base16:Ig,base16upper:Ng});const Cg=we({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ug=we({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Rg=we({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$g=we({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Tg=we({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pg=we({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lg=we({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),qg=we({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jg=we({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hg=Object.freeze({__proto__:null,base32:Cg,base32upper:Ug,base32pad:Rg,base32padupper:$g,base32hex:Tg,base32hexupper:Pg,base32hexpad:Lg,base32hexpadupper:qg,base32z:jg});const Mg=ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zg=ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var kg=Object.freeze({__proto__:null,base36:Mg,base36upper:zg});const Zg=ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vg=ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gg=Object.freeze({__proto__:null,base58btc:Zg,base58flickr:Vg});const Kg=we({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yg=we({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wg=we({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xg=we({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jg=Object.freeze({__proto__:null,base64:Kg,base64pad:Yg,base64url:Wg,base64urlpad:Xg});const qa=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Qg=qa.reduce((e,t,n)=>(e[n]=t,e),[]),e3=qa.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function t3(e){return e.reduce((t,n)=>(t+=Qg[n],t),"")}function n3(e){const t=[];for(const n of e){const r=e3[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const r3=io({prefix:"\u{1F680}",name:"base256emoji",encode:t3,decode:n3});var o3=Object.freeze({__proto__:null,base256emoji:r3}),i3=Ha,ja=128,s3=127,c3=~s3,f3=Math.pow(2,31);function Ha(e,t,n){t=t||[],n=n||0;for(var r=n;e>=f3;)t[n++]=e&255|ja,e/=128;for(;e&c3;)t[n++]=e&255|ja,e>>>=7;return t[n]=e|0,Ha.bytes=n-r+1,t}var a3=is,u3=128,Ma=127;function is(e,r){var n=0,r=r||0,o=0,i=r,s,c=e.length;do{if(i>=c)throw is.bytes=0,new RangeError("Could not decode varint");s=e[i++],n+=o<28?(s&Ma)<<o:(s&Ma)*Math.pow(2,o),o+=7}while(s>=u3);return is.bytes=i-r,n}var l3=Math.pow(2,7),d3=Math.pow(2,14),h3=Math.pow(2,21),b3=Math.pow(2,28),g3=Math.pow(2,35),w3=Math.pow(2,42),p3=Math.pow(2,49),y3=Math.pow(2,56),m3=Math.pow(2,63),E3=function(e){return e<l3?1:e<d3?2:e<h3?3:e<b3?4:e<g3?5:e<w3?6:e<p3?7:e<y3?8:e<m3?9:10},x3={encode:i3,decode:a3,encodingLength:E3},za=x3;const ka=(e,t,n=0)=>(za.encode(e,t,n),t),Za=e=>za.encodingLength(e),ss=(e,t)=>{const n=t.byteLength,r=Za(e),o=r+Za(n),i=new Uint8Array(o+n);return ka(e,i,0),ka(n,i,r),i.set(t,o),new v3(e,n,t,i)};class v3{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const Va=({name:e,code:t,encode:n})=>new B3(e,t,n);class B3{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?ss(this.code,n):n.then(r=>ss(this.code,r))}else throw Error("Unknown type, must be binary type")}}const Ga=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),D3=Va({name:"sha2-256",code:18,encode:Ga("SHA-256")}),A3=Va({name:"sha2-512",code:19,encode:Ga("SHA-512")});var O3=Object.freeze({__proto__:null,sha256:D3,sha512:A3});const Ka=0,S3="identity",Ya=Pa;var _3=Object.freeze({__proto__:null,identity:{code:Ka,name:S3,encode:Ya,digest:e=>ss(Ka,Ya(e))}});new TextEncoder,new TextDecoder,{...vg,...Dg,...Og,..._g,...Fg,...Hg,...kg,...Gg,...Jg,...o3},{...O3,..._3};var I3=Object.defineProperty,N3=Object.defineProperties,F3=Object.getOwnPropertyDescriptors,Wa=Object.getOwnPropertySymbols,C3=Object.prototype.hasOwnProperty,U3=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?I3(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tn=(e,t)=>{for(var n in t||(t={}))C3.call(t,n)&&Xa(e,n,t[n]);if(Wa)for(var n of Wa(t))U3.call(t,n)&&Xa(e,n,t[n]);return e},lr=(e,t)=>N3(e,F3(t));const R3="ReactNative";function Ja(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function cs(){return!Lo()&&!!qo()&&navigator.product===R3}function $3(){return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function T3(){return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function P3(){return!Ja()&&!!qo()&&!!Lo()}function L3(){var e;try{return cs()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(e=global.Application)==null?void 0:e.applicationId:void 0}catch{return}}const so=BigInt(2**32-1),Qa=BigInt(32);function eu(e,t=!1){return t?{h:Number(e&so),l:Number(e>>Qa&so)}:{h:Number(e>>Qa&so)|0,l:Number(e&so)|0}}function tu(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){const{h:s,l:c}=eu(e[i],t);[r[i],o[i]]=[s,c]}return[r,o]}const nu=(e,t,n)=>e>>>n,ru=(e,t,n)=>e<<32-n|t>>>n,jt=(e,t,n)=>e>>>n|t<<32-n,Ht=(e,t,n)=>e<<32-n|t>>>n,dr=(e,t,n)=>e<<64-n|t>>>n-32,hr=(e,t,n)=>e>>>n-32|t<<64-n,q3=(e,t)=>t,j3=(e,t)=>e,H3=(e,t,n)=>e<<n|t>>>32-n,M3=(e,t,n)=>t<<n|e>>>32-n,z3=(e,t,n)=>t<<n-32|e>>>64-n,k3=(e,t,n)=>e<<n-32|t>>>64-n;function Xe(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const fs=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),as=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Z3=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),V3=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,G3=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),K3=(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,Pn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function co(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Mt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Je(e,...t){if(!co(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ou(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Mt(e.outputLen),Mt(e.blockLen)}function zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function us(e,t){Je(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function br(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Qe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ls(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ot(e,t){return e<<32-t|e>>>t}const iu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function su(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const xt=iu?e=>e:e=>su(e);function Y3(e){for(let t=0;t<e.length;t++)e[t]=su(e[t]);return e}const kt=iu?e=>e:Y3,cu=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",W3=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ln(e){if(Je(e),cu)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=W3[e[n]];return t}const vt={_0:48,_9:57,A:65,F:70,a:97,f:102};function fu(e){if(e>=vt._0&&e<=vt._9)return e-vt._0;if(e>=vt.A&&e<=vt.F)return e-(vt.A-10);if(e>=vt.a&&e<=vt.f)return e-(vt.a-10)}function fo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(cu)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const s=fu(e.charCodeAt(i)),c=fu(e.charCodeAt(i+1));if(s===void 0||c===void 0){const f=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[o]=s*16+c}return r}function au(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Bt(e){return typeof e=="string"&&(e=au(e)),Je(e),e}function Zt(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Je(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const i=e[r];n.set(i,o),o+=i.length}return n}class ao{}function gr(e){const t=r=>e().update(Bt(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function X3(e){const t=(r,o)=>e(o).update(Bt(r)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}function ds(e=32){if(Pn&&typeof Pn.getRandomValues=="function")return Pn.getRandomValues(new Uint8Array(e));if(Pn&&typeof Pn.randomBytes=="function")return Uint8Array.from(Pn.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const J3=BigInt(0),wr=BigInt(1),Q3=BigInt(2),ew=BigInt(7),tw=BigInt(256),nw=BigInt(113),uu=[],lu=[],du=[];for(let e=0,t=wr,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],uu.push(2*(5*r+n)),lu.push((e+1)*(e+2)/2%64);let o=J3;for(let i=0;i<7;i++)t=(t<<wr^(t>>ew)*nw)%tw,t&Q3&&(o^=wr<<(wr<<BigInt(i))-wr);du.push(o)}const hu=tu(du,!0),rw=hu[0],ow=hu[1],bu=(e,t,n)=>n>32?z3(e,t,n):H3(e,t,n),gu=(e,t,n)=>n>32?k3(e,t,n):M3(e,t,n);function iw(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let s=0;s<10;s++)n[s]=e[s]^e[s+10]^e[s+20]^e[s+30]^e[s+40];for(let s=0;s<10;s+=2){const c=(s+8)%10,f=(s+2)%10,a=n[f],l=n[f+1],h=bu(a,l,1)^n[c],d=gu(a,l,1)^n[c+1];for(let u=0;u<50;u+=10)e[s+u]^=h,e[s+u+1]^=d}let o=e[2],i=e[3];for(let s=0;s<24;s++){const c=lu[s],f=bu(o,i,c),a=gu(o,i,c),l=uu[s];o=e[l],i=e[l+1],e[l]=f,e[l+1]=a}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=e[s+c];for(let c=0;c<10;c++)e[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=rw[r],e[1]^=ow[r]}Qe(n)}class hs extends ao{constructor(t,n,r,o=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Mt(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=br(this.state)}clone(){return this._cloneInto()}keccak(){kt(this.state32),iw(this.state32,this.rounds),kt(this.state32),this.posOut=0,this.pos=0}update(t){zt(this),t=Bt(t),Je(t);const{blockLen:n,state:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);for(let c=0;c<s;c++)r[this.pos++]^=t[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){zt(this,!1),Je(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,i=t.length;o<i;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,i-o);t.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Mt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(us(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Qe(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return t||(t=new hs(n,r,o,s,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=o,t.enableXOF=s,t.destroyed=this.destroyed,t}}((e,t,n)=>gr(()=>new hs(t,e,n)))(1,136,256/8);function sw(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function cw(e,t,n){return e&t^~e&n}function fw(e,t,n){return e&t^e&n^t&n}class wu extends ao{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=ls(this.buffer)}update(t){zt(this),t=Bt(t),Je(t);const{view:n,buffer:r,blockLen:o}=this,i=t.length;for(let s=0;s<i;){const c=Math.min(o-this.pos,i-s);if(c===o){const f=ls(t);for(;o<=i-s;s+=o)this.process(f,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){zt(this),us(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:i}=this;let{pos:s}=this;n[s++]=128,Qe(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let h=s;h<o;h++)n[h]=0;sw(r,o-8,BigInt(this.length*8),i),this.process(r,0);const c=ls(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=f/4,l=this.get();if(a>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<a;h++)c.setUint32(4*h,l[h],i)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const Vt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xe=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ve=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),aw=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Gt=new Uint32Array(64);class uw extends wu{constructor(t=32){super(64,t,8,!1),this.A=Vt[0]|0,this.B=Vt[1]|0,this.C=Vt[2]|0,this.D=Vt[3]|0,this.E=Vt[4]|0,this.F=Vt[5]|0,this.G=Vt[6]|0,this.H=Vt[7]|0}get(){const{A:t,B:n,C:r,D:o,E:i,F:s,G:c,H:f}=this;return[t,n,r,o,i,s,c,f]}set(t,n,r,o,i,s,c,f){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,n){for(let h=0;h<16;h++,n+=4)Gt[h]=t.getUint32(n,!1);for(let h=16;h<64;h++){const d=Gt[h-15],u=Gt[h-2],p=ot(d,7)^ot(d,18)^d>>>3,m=ot(u,17)^ot(u,19)^u>>>10;Gt[h]=m+Gt[h-7]+p+Gt[h-16]|0}let{A:r,B:o,C:i,D:s,E:c,F:f,G:a,H:l}=this;for(let h=0;h<64;h++){const d=ot(c,6)^ot(c,11)^ot(c,25),u=l+d+cw(c,f,a)+aw[h]+Gt[h]|0,p=(ot(r,2)^ot(r,13)^ot(r,22))+fw(r,o,i)|0;l=a,a=f,f=c,c=s+u|0,s=i,i=o,o=r,r=u+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,a=a+this.G|0,l=l+this.H|0,this.set(r,o,i,s,c,f,a,l)}roundClean(){Qe(Gt)}destroy(){this.set(0,0,0,0,0,0,0,0),Qe(this.buffer)}}const pu=tu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),lw=pu[0],dw=pu[1],Kt=new Uint32Array(80),Yt=new Uint32Array(80);class bs extends wu{constructor(t=64){super(128,t,16,!1),this.Ah=ve[0]|0,this.Al=ve[1]|0,this.Bh=ve[2]|0,this.Bl=ve[3]|0,this.Ch=ve[4]|0,this.Cl=ve[5]|0,this.Dh=ve[6]|0,this.Dl=ve[7]|0,this.Eh=ve[8]|0,this.El=ve[9]|0,this.Fh=ve[10]|0,this.Fl=ve[11]|0,this.Gh=ve[12]|0,this.Gl=ve[13]|0,this.Hh=ve[14]|0,this.Hl=ve[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:c,Dl:f,Eh:a,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:m,Hl:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=f|0,this.Eh=a|0,this.El=l|0,this.Fh=h|0,this.Fl=d|0,this.Gh=u|0,this.Gl=p|0,this.Hh=m|0,this.Hl=v|0}process(t,n){for(let D=0;D<16;D++,n+=4)Kt[D]=t.getUint32(n),Yt[D]=t.getUint32(n+=4);for(let D=16;D<80;D++){const x=Kt[D-15]|0,C=Yt[D-15]|0,P=jt(x,C,1)^jt(x,C,8)^nu(x,C,7),q=Ht(x,C,1)^Ht(x,C,8)^ru(x,C,7),L=Kt[D-2]|0,I=Yt[D-2]|0,k=jt(L,I,19)^dr(L,I,61)^nu(L,I,6),H=Ht(L,I,19)^hr(L,I,61)^ru(L,I,6),E=Z3(q,H,Yt[D-7],Yt[D-16]),g=V3(E,P,k,Kt[D-7],Kt[D-16]);Kt[D]=g|0,Yt[D]=E|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:c,Cl:f,Dh:a,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:m,Gl:v,Hh:_,Hl:$}=this;for(let D=0;D<80;D++){const x=jt(h,d,14)^jt(h,d,18)^dr(h,d,41),C=Ht(h,d,14)^Ht(h,d,18)^hr(h,d,41),P=h&u^~h&m,q=d&p^~d&v,L=G3($,C,q,dw[D],Yt[D]),I=K3(L,_,x,P,lw[D],Kt[D]),k=L|0,H=jt(r,o,28)^dr(r,o,34)^dr(r,o,39),E=Ht(r,o,28)^hr(r,o,34)^hr(r,o,39),g=r&i^r&c^i&c,y=o&s^o&f^s&f;_=m|0,$=v|0,m=u|0,v=p|0,u=h|0,p=d|0,{h,l:d}=Xe(a|0,l|0,I|0,k|0),a=c|0,l=f|0,c=i|0,f=s|0,i=r|0,s=o|0;const b=fs(k,E,y);r=as(b,I,H,g),o=b|0}({h:r,l:o}=Xe(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=Xe(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:f}=Xe(this.Ch|0,this.Cl|0,c|0,f|0),{h:a,l}=Xe(this.Dh|0,this.Dl|0,a|0,l|0),{h,l:d}=Xe(this.Eh|0,this.El|0,h|0,d|0),{h:u,l:p}=Xe(this.Fh|0,this.Fl|0,u|0,p|0),{h:m,l:v}=Xe(this.Gh|0,this.Gl|0,m|0,v|0),{h:_,l:$}=Xe(this.Hh|0,this.Hl|0,_|0,$|0),this.set(r,o,i,s,c,f,a,l,h,d,u,p,m,v,_,$)}roundClean(){Qe(Kt,Yt)}destroy(){Qe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class hw extends bs{constructor(){super(48),this.Ah=xe[0]|0,this.Al=xe[1]|0,this.Bh=xe[2]|0,this.Bl=xe[3]|0,this.Ch=xe[4]|0,this.Cl=xe[5]|0,this.Dh=xe[6]|0,this.Dl=xe[7]|0,this.Eh=xe[8]|0,this.El=xe[9]|0,this.Fh=xe[10]|0,this.Fl=xe[11]|0,this.Gh=xe[12]|0,this.Gl=xe[13]|0,this.Hh=xe[14]|0,this.Hl=xe[15]|0}}const Be=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class bw extends bs{constructor(){super(32),this.Ah=Be[0]|0,this.Al=Be[1]|0,this.Bh=Be[2]|0,this.Bl=Be[3]|0,this.Ch=Be[4]|0,this.Cl=Be[5]|0,this.Dh=Be[6]|0,this.Dl=Be[7]|0,this.Eh=Be[8]|0,this.El=Be[9]|0,this.Fh=Be[10]|0,this.Fl=Be[11]|0,this.Gh=Be[12]|0,this.Gl=Be[13]|0,this.Hh=Be[14]|0,this.Hl=Be[15]|0}}const gw=gr(()=>new uw),ww=gr(()=>new bs),pw=gr(()=>new hw);gr(()=>new bw);const yw=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),de=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),G=new Uint32Array(32);function Wt(e,t,n,r,o,i){const s=o[i],c=o[i+1];let f=G[2*e],a=G[2*e+1],l=G[2*t],h=G[2*t+1],d=G[2*n],u=G[2*n+1],p=G[2*r],m=G[2*r+1],v=fs(f,l,s);a=as(v,a,h,c),f=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^f},{Dh:m,Dl:p}={Dh:q3(m,p),Dl:j3(m)},{h:u,l:d}=Xe(u,d,m,p),{Bh:h,Bl:l}={Bh:h^u,Bl:l^d},{Bh:h,Bl:l}={Bh:jt(h,l,24),Bl:Ht(h,l,24)},G[2*e]=f,G[2*e+1]=a,G[2*t]=l,G[2*t+1]=h,G[2*n]=d,G[2*n+1]=u,G[2*r]=p,G[2*r+1]=m}function Xt(e,t,n,r,o,i){const s=o[i],c=o[i+1];let f=G[2*e],a=G[2*e+1],l=G[2*t],h=G[2*t+1],d=G[2*n],u=G[2*n+1],p=G[2*r],m=G[2*r+1],v=fs(f,l,s);a=as(v,a,h,c),f=v|0,{Dh:m,Dl:p}={Dh:m^a,Dl:p^f},{Dh:m,Dl:p}={Dh:jt(m,p,16),Dl:Ht(m,p,16)},{h:u,l:d}=Xe(u,d,m,p),{Bh:h,Bl:l}={Bh:h^u,Bl:l^d},{Bh:h,Bl:l}={Bh:dr(h,l,63),Bl:hr(h,l,63)},G[2*e]=f,G[2*e+1]=a,G[2*t]=l,G[2*t+1]=h,G[2*n]=d,G[2*n+1]=u,G[2*r]=p,G[2*r+1]=m}function mw(e,t={},n,r,o){if(Mt(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:i,salt:s,personalization:c}=t;if(i!==void 0&&(i.length<1||i.length>n))throw new Error("key length must be undefined or 1.."+n);if(s!==void 0&&s.length!==r)throw new Error("salt must be undefined or "+r);if(c!==void 0&&c.length!==o)throw new Error("personalization must be undefined or "+o)}class Ew extends ao{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Mt(t),Mt(n),this.blockLen=t,this.outputLen=n,this.buffer=new Uint8Array(t),this.buffer32=br(this.buffer)}update(t){zt(this),t=Bt(t),Je(t);const{blockLen:n,buffer:r,buffer32:o}=this,i=t.length,s=t.byteOffset,c=t.buffer;for(let f=0;f<i;){this.pos===n&&(kt(o),this.compress(o,0,!1),kt(o),this.pos=0);const a=Math.min(n-this.pos,i-f),l=s+f;if(a===n&&!(l%4)&&f+a<i){const h=new Uint32Array(c,l,Math.floor((i-f)/4));kt(h);for(let d=0;f+n<i;d+=o.length,f+=n)this.length+=n,this.compress(h,d,!1);kt(h);continue}r.set(t.subarray(f,f+a),this.pos),this.pos+=a,this.length+=a,f+=a}return this}digestInto(t){zt(this),us(t,this);const{pos:n,buffer32:r}=this;this.finished=!0,Qe(this.buffer.subarray(n)),kt(r),this.compress(r,0,!0),kt(r);const o=br(t);this.get().forEach((i,s)=>o[s]=xt(i))}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){const{buffer:n,length:r,finished:o,destroyed:i,outputLen:s,pos:c}=this;return t||(t=new this.constructor({dkLen:s})),t.set(...this.get()),t.buffer.set(n),t.destroyed=i,t.finished=o,t.length=r,t.pos=c,t.outputLen=s,t}clone(){return this._cloneInto()}}class xw extends Ew{constructor(t={}){const n=t.dkLen===void 0?64:t.dkLen;super(128,n),this.v0l=de[0]|0,this.v0h=de[1]|0,this.v1l=de[2]|0,this.v1h=de[3]|0,this.v2l=de[4]|0,this.v2h=de[5]|0,this.v3l=de[6]|0,this.v3h=de[7]|0,this.v4l=de[8]|0,this.v4h=de[9]|0,this.v5l=de[10]|0,this.v5h=de[11]|0,this.v6l=de[12]|0,this.v6h=de[13]|0,this.v7l=de[14]|0,this.v7h=de[15]|0,mw(n,t,64,16,16);let{key:r,personalization:o,salt:i}=t,s=0;if(r!==void 0&&(r=Bt(r),s=r.length),this.v0l^=this.outputLen|s<<8|65536|1<<24,i!==void 0){i=Bt(i);const c=br(i);this.v4l^=xt(c[0]),this.v4h^=xt(c[1]),this.v5l^=xt(c[2]),this.v5h^=xt(c[3])}if(o!==void 0){o=Bt(o);const c=br(o);this.v6l^=xt(c[0]),this.v6h^=xt(c[1]),this.v7l^=xt(c[2]),this.v7h^=xt(c[3])}if(r!==void 0){const c=new Uint8Array(this.blockLen);c.set(r),this.update(c)}}get(){let{v0l:t,v0h:n,v1l:r,v1h:o,v2l:i,v2h:s,v3l:c,v3h:f,v4l:a,v4h:l,v5l:h,v5h:d,v6l:u,v6h:p,v7l:m,v7h:v}=this;return[t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v]}set(t,n,r,o,i,s,c,f,a,l,h,d,u,p,m,v){this.v0l=t|0,this.v0h=n|0,this.v1l=r|0,this.v1h=o|0,this.v2l=i|0,this.v2h=s|0,this.v3l=c|0,this.v3h=f|0,this.v4l=a|0,this.v4h=l|0,this.v5l=h|0,this.v5h=d|0,this.v6l=u|0,this.v6h=p|0,this.v7l=m|0,this.v7h=v|0}compress(t,n,r){this.get().forEach((f,a)=>G[a]=f),G.set(de,16);let{h:o,l:i}=eu(BigInt(this.length));G[24]=de[8]^i,G[25]=de[9]^o,r&&(G[28]=~G[28],G[29]=~G[29]);let s=0;const c=yw;for(let f=0;f<12;f++)Wt(0,4,8,12,t,n+2*c[s++]),Xt(0,4,8,12,t,n+2*c[s++]),Wt(1,5,9,13,t,n+2*c[s++]),Xt(1,5,9,13,t,n+2*c[s++]),Wt(2,6,10,14,t,n+2*c[s++]),Xt(2,6,10,14,t,n+2*c[s++]),Wt(3,7,11,15,t,n+2*c[s++]),Xt(3,7,11,15,t,n+2*c[s++]),Wt(0,5,10,15,t,n+2*c[s++]),Xt(0,5,10,15,t,n+2*c[s++]),Wt(1,6,11,12,t,n+2*c[s++]),Xt(1,6,11,12,t,n+2*c[s++]),Wt(2,7,8,13,t,n+2*c[s++]),Xt(2,7,8,13,t,n+2*c[s++]),Wt(3,4,9,14,t,n+2*c[s++]),Xt(3,4,9,14,t,n+2*c[s++]);this.v0l^=G[0]^G[16],this.v0h^=G[1]^G[17],this.v1l^=G[2]^G[18],this.v1h^=G[3]^G[19],this.v2l^=G[4]^G[20],this.v2h^=G[5]^G[21],this.v3l^=G[6]^G[22],this.v3h^=G[7]^G[23],this.v4l^=G[8]^G[24],this.v4h^=G[9]^G[25],this.v5l^=G[10]^G[26],this.v5h^=G[11]^G[27],this.v6l^=G[12]^G[28],this.v6h^=G[13]^G[29],this.v7l^=G[14]^G[30],this.v7h^=G[15]^G[31],Qe(G)}destroy(){this.destroyed=!0,Qe(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}X3(e=>new xw(e));/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function yu(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function gs(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function ws(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Pe(e,...t){if(!yu(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function mu(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function vw(e,t){Pe(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Jt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function qn(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Bw(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Dw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Aw(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ps(e){if(typeof e=="string")e=Aw(e);else if(yu(e))e=ys(e);else throw new Error("Uint8Array expected, got "+typeof e);return e}function Ow(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function Sw(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}const _w=(e,t)=>{function n(r,...o){if(Pe(r),!Dw)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){const a=o[0];if(!a)throw new Error("nonce / iv required");e.varSizeNonce?Pe(a):Pe(a,e.nonceLength)}const i=e.tagLength;i&&o[1]!==void 0&&Pe(o[1]);const s=t(r,...o),c=(a,l)=>{if(l!==void 0){if(a!==2)throw new Error("cipher output not supported");Pe(l)}};let f=!1;return{encrypt(a,l){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=!0,Pe(a),c(s.encrypt.length,l),s.encrypt(a,l)},decrypt(a,l){if(Pe(a),i&&a.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return c(s.decrypt.length,l),s.decrypt(a,l)}}}return Object.assign(n,e),n};function Eu(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(n&&!Nw(t))throw new Error("invalid output, must be aligned");return t}function xu(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),c=Number(n&i),f=r?4:0,a=r?0:4;e.setUint32(t+f,s,r),e.setUint32(t+a,c,r)}function Iw(e,t,n){gs(n);const r=new Uint8Array(16),o=Bw(r);return xu(o,0,BigInt(t),n),xu(o,8,BigInt(e),n),r}function Nw(e){return e.byteOffset%4===0}function ys(e){return Uint8Array.from(e)}const vu=e=>Uint8Array.from(e.split("").map(t=>t.charCodeAt(0))),Fw=vu("expand 16-byte k"),Cw=vu("expand 32-byte k"),Uw=Jt(Fw),Rw=Jt(Cw);function te(e,t){return e<<t|e>>>32-t}function ms(e){return e.byteOffset%4===0}const uo=64,$w=16,Bu=2**32-1,Du=new Uint32Array;function Tw(e,t,n,r,o,i,s,c){const f=o.length,a=new Uint8Array(uo),l=Jt(a),h=ms(o)&&ms(i),d=h?Jt(o):Du,u=h?Jt(i):Du;for(let p=0;p<f;s++){if(e(t,n,r,l,s,c),s>=Bu)throw new Error("arx: counter overflow");const m=Math.min(uo,f-p);if(h&&m===uo){const v=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let _=0,$;_<$w;_++)$=v+_,u[$]=d[$]^l[_];p+=uo;continue}for(let v=0,_;v<m;v++)_=p+v,i[_]=o[_]^a[v];p+=m}}function Pw(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=Ow({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!="function")throw new Error("core must be a function");return ws(o),ws(s),gs(i),gs(n),(c,f,a,l,h=0)=>{Pe(c),Pe(f),Pe(a);const d=a.length;if(l===void 0&&(l=new Uint8Array(d)),Pe(l),ws(h),h<0||h>=Bu)throw new Error("arx: counter overflow");if(l.length<d)throw new Error(`arx: output (${l.length}) is shorter than data (${d})`);const u=[];let p=c.length,m,v;if(p===32)u.push(m=ys(c)),v=Rw;else if(p===16&&n)m=new Uint8Array(32),m.set(c),m.set(c,16),v=Uw,u.push(m);else throw new Error(`arx: invalid 32-byte key, got length=${p}`);ms(f)||u.push(f=ys(f));const _=Jt(m);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(v,_,Jt(f.subarray(0,16)),_),f=f.subarray(16)}const $=16-o;if($!==f.length)throw new Error(`arx: nonce must be ${$} or 16 bytes`);if($!==12){const x=new Uint8Array(12);x.set(f,i?0:12-f.length),f=x,u.push(f)}const D=Jt(f);return Tw(e,v,_,D,a,l,h,s),qn(...u),l}}const pe=(e,t)=>e[t++]&255|(e[t++]&255)<<8;class Lw{constructor(t){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,t=ps(t),Pe(t,32);const n=pe(t,0),r=pe(t,2),o=pe(t,4),i=pe(t,6),s=pe(t,8),c=pe(t,10),f=pe(t,12),a=pe(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|a<<8)&8191,this.r[9]=a>>>5&127;for(let l=0;l<8;l++)this.pad[l]=pe(t,16+2*l)}process(t,n,r=!1){const o=r?0:2048,{h:i,r:s}=this,c=s[0],f=s[1],a=s[2],l=s[3],h=s[4],d=s[5],u=s[6],p=s[7],m=s[8],v=s[9],_=pe(t,n+0),$=pe(t,n+2),D=pe(t,n+4),x=pe(t,n+6),C=pe(t,n+8),P=pe(t,n+10),q=pe(t,n+12),L=pe(t,n+14);let I=i[0]+(_&8191),k=i[1]+((_>>>13|$<<3)&8191),H=i[2]+(($>>>10|D<<6)&8191),E=i[3]+((D>>>7|x<<9)&8191),g=i[4]+((x>>>4|C<<12)&8191),y=i[5]+(C>>>1&8191),b=i[6]+((C>>>14|P<<2)&8191),w=i[7]+((P>>>11|q<<5)&8191),B=i[8]+((q>>>8|L<<8)&8191),A=i[9]+(L>>>5|o),O=0,S=O+I*c+k*(5*v)+H*(5*m)+E*(5*p)+g*(5*u);O=S>>>13,S&=8191,S+=y*(5*d)+b*(5*h)+w*(5*l)+B*(5*a)+A*(5*f),O+=S>>>13,S&=8191;let N=O+I*f+k*c+H*(5*v)+E*(5*m)+g*(5*p);O=N>>>13,N&=8191,N+=y*(5*u)+b*(5*d)+w*(5*h)+B*(5*l)+A*(5*a),O+=N>>>13,N&=8191;let R=O+I*a+k*f+H*c+E*(5*v)+g*(5*m);O=R>>>13,R&=8191,R+=y*(5*p)+b*(5*u)+w*(5*d)+B*(5*h)+A*(5*l),O+=R>>>13,R&=8191;let U=O+I*l+k*a+H*f+E*c+g*(5*v);O=U>>>13,U&=8191,U+=y*(5*m)+b*(5*p)+w*(5*u)+B*(5*d)+A*(5*h),O+=U>>>13,U&=8191;let T=O+I*h+k*l+H*a+E*f+g*c;O=T>>>13,T&=8191,T+=y*(5*v)+b*(5*m)+w*(5*p)+B*(5*u)+A*(5*d),O+=T>>>13,T&=8191;let F=O+I*d+k*h+H*l+E*a+g*f;O=F>>>13,F&=8191,F+=y*c+b*(5*v)+w*(5*m)+B*(5*p)+A*(5*u),O+=F>>>13,F&=8191;let j=O+I*u+k*d+H*h+E*l+g*a;O=j>>>13,j&=8191,j+=y*f+b*c+w*(5*v)+B*(5*m)+A*(5*p),O+=j>>>13,j&=8191;let M=O+I*p+k*u+H*d+E*h+g*l;O=M>>>13,M&=8191,M+=y*a+b*f+w*c+B*(5*v)+A*(5*m),O+=M>>>13,M&=8191;let V=O+I*m+k*p+H*u+E*d+g*h;O=V>>>13,V&=8191,V+=y*l+b*a+w*f+B*c+A*(5*v),O+=V>>>13,V&=8191;let z=O+I*v+k*m+H*p+E*u+g*d;O=z>>>13,z&=8191,z+=y*h+b*l+w*a+B*f+A*c,O+=z>>>13,z&=8191,O=(O<<2)+O|0,O=O+S|0,S=O&8191,O=O>>>13,N+=O,i[0]=S,i[1]=N,i[2]=R,i[3]=U,i[4]=T,i[5]=F,i[6]=j,i[7]=M,i[8]=V,i[9]=z}finalize(){const{h:t,pad:n}=this,r=new Uint16Array(10);let o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,r[0]=t[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=t[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let i=(o^1)-1;for(let c=0;c<10;c++)r[c]&=i;i=~i;for(let c=0;c<10;c++)t[c]=t[c]&i|r[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let s=t[0]+n[0];t[0]=s&65535;for(let c=1;c<8;c++)s=(t[c]+n[c]|0)+(s>>>16)|0,t[c]=s&65535;qn(r)}update(t){mu(this),t=ps(t),Pe(t);const{buffer:n,blockLen:r}=this,o=t.length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s===r){for(;r<=o-i;i+=r)this.process(t,i);continue}n.set(t.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){qn(this.h,this.r,this.buffer,this.pad)}digestInto(t){mu(this),vw(t,this),this.finished=!0;const{buffer:n,h:r}=this;let{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)t[i++]=r[s]>>>0,t[i++]=r[s]>>>8;return t}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}}function qw(e){const t=(r,o)=>e(o).update(ps(r)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}const jw=qw(e=>new Lw(e));function Hw(e,t,n,r,o,i=20){let s=e[0],c=e[1],f=e[2],a=e[3],l=t[0],h=t[1],d=t[2],u=t[3],p=t[4],m=t[5],v=t[6],_=t[7],$=o,D=n[0],x=n[1],C=n[2],P=s,q=c,L=f,I=a,k=l,H=h,E=d,g=u,y=p,b=m,w=v,B=_,A=$,O=D,S=x,N=C;for(let U=0;U<i;U+=2)P=P+k|0,A=te(A^P,16),y=y+A|0,k=te(k^y,12),P=P+k|0,A=te(A^P,8),y=y+A|0,k=te(k^y,7),q=q+H|0,O=te(O^q,16),b=b+O|0,H=te(H^b,12),q=q+H|0,O=te(O^q,8),b=b+O|0,H=te(H^b,7),L=L+E|0,S=te(S^L,16),w=w+S|0,E=te(E^w,12),L=L+E|0,S=te(S^L,8),w=w+S|0,E=te(E^w,7),I=I+g|0,N=te(N^I,16),B=B+N|0,g=te(g^B,12),I=I+g|0,N=te(N^I,8),B=B+N|0,g=te(g^B,7),P=P+H|0,N=te(N^P,16),w=w+N|0,H=te(H^w,12),P=P+H|0,N=te(N^P,8),w=w+N|0,H=te(H^w,7),q=q+E|0,A=te(A^q,16),B=B+A|0,E=te(E^B,12),q=q+E|0,A=te(A^q,8),B=B+A|0,E=te(E^B,7),L=L+g|0,O=te(O^L,16),y=y+O|0,g=te(g^y,12),L=L+g|0,O=te(O^L,8),y=y+O|0,g=te(g^y,7),I=I+k|0,S=te(S^I,16),b=b+S|0,k=te(k^b,12),I=I+k|0,S=te(S^I,8),b=b+S|0,k=te(k^b,7);let R=0;r[R++]=s+P|0,r[R++]=c+q|0,r[R++]=f+L|0,r[R++]=a+I|0,r[R++]=l+k|0,r[R++]=h+H|0,r[R++]=d+E|0,r[R++]=u+g|0,r[R++]=p+y|0,r[R++]=m+b|0,r[R++]=v+w|0,r[R++]=_+B|0,r[R++]=$+A|0,r[R++]=D+O|0,r[R++]=x+S|0,r[R++]=C+N|0}const Mw=Pw(Hw,{counterRight:!1,counterLength:4,allowShortKeys:!1}),zw=new Uint8Array(16),Au=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(zw.subarray(n))},kw=new Uint8Array(32);function Ou(e,t,n,r,o){const i=e(t,n,kw),s=jw.create(i);o&&Au(s,o),Au(s,r);const c=Iw(r.length,o?o.length:0,!0);s.update(c);const f=s.digest();return qn(i,c),f}_w({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,r)=>({encrypt(o,i){const s=o.length;i=Eu(s+16,i,!1),i.set(o);const c=i.subarray(0,-16);e(t,n,c,c,1);const f=Ou(e,t,n,c,r);return i.set(f,s),qn(f),i},decrypt(o,i){i=Eu(o.length-16,i,!1);const s=o.subarray(0,-16),c=o.subarray(-16),f=Ou(e,t,n,s,r);if(!Sw(c,f))throw new Error("invalid tag");return i.set(o.subarray(0,-16)),e(t,n,i,i,1),qn(f),i}}))(Mw));class Su extends ao{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,ou(t);const r=Bt(n);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(r.length>o?t.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),Qe(i)}update(t){return zt(this),this.iHash.update(t),this}digestInto(t){zt(this),Je(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const _u=(e,t,n)=>new Su(e,t).update(n).digest();_u.create=(e,t)=>new Su(e,t);const Es=BigInt(0),xs=BigInt(1);function lo(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function bn(e,t,n=""){const r=co(e),o=e?.length,i=t!==void 0;if(!r||i&&o!==t){const s=n&&`"${n}" `,c=i?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+f)}return e}function ho(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Iu(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Es:BigInt("0x"+e)}function bo(e){return Iu(Ln(e))}function go(e){return Je(e),Iu(Ln(Uint8Array.from(e).reverse()))}function vs(e,t){return fo(e.toString(16).padStart(t*2,"0"))}function Bs(e,t){return vs(e,t).reverse()}function De(e,t,n){let r;if(typeof t=="string")try{r=fo(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(co(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}const Ds=e=>typeof e=="bigint"&&Es<=e;function Zw(e,t,n){return Ds(e)&&Ds(t)&&Ds(n)&&t<=e&&e<n}function As(e,t,n,r){if(!Zw(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function Nu(e){let t;for(t=0;e>Es;e>>=xs,t+=1);return t}const pr=e=>(xs<<BigInt(e))-xs;function Vw(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=d=>new Uint8Array(d),o=d=>Uint8Array.of(d);let i=r(e),s=r(e),c=0;const f=()=>{i.fill(1),s.fill(0),c=0},a=(...d)=>n(s,i,...d),l=(d=r(0))=>{s=a(o(0),d),i=a(),d.length!==0&&(s=a(o(1),d),i=a())},h=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const u=[];for(;d<t;){i=a();const p=i.slice();u.push(p),d+=i.length}return Zt(...u)};return(d,u)=>{f(),l(d);let p;for(;!(p=u(h()));)l();return f(),p}}function wo(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,i,s){const c=e[o];if(s&&c===void 0)return;const f=typeof c;if(f!==i||c===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${f}`)}Object.entries(t).forEach(([o,i])=>r(o,i,!1)),Object.entries(n).forEach(([o,i])=>r(o,i,!0))}function Fu(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const i=e(n,...r);return t.set(n,i),i}}const Le=BigInt(0),Fe=BigInt(1),gn=BigInt(2),Cu=BigInt(3),Uu=BigInt(4),Ru=BigInt(5),Gw=BigInt(7),$u=BigInt(8),Kw=BigInt(9),Tu=BigInt(16);function He(e,t){const n=e%t;return n>=Le?n:t+n}function et(e,t,n){let r=e;for(;t-- >Le;)r*=r,r%=n;return r}function Pu(e,t){if(e===Le)throw new Error("invert: expected non-zero number");if(t<=Le)throw new Error("invert: expected positive modulus, got "+t);let n=He(e,t),r=t,o=Le,i=Fe;for(;n!==Le;){const s=r/n,c=r%n,f=o-i*s;r=n,n=c,o=i,i=f}if(r!==Fe)throw new Error("invert: does not exist");return He(o,t)}function Os(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Lu(e,t){const n=(e.ORDER+Fe)/Uu,r=e.pow(t,n);return Os(e,r,t),r}function Yw(e,t){const n=(e.ORDER-Ru)/$u,r=e.mul(t,gn),o=e.pow(r,n),i=e.mul(t,o),s=e.mul(e.mul(i,gn),o),c=e.mul(i,e.sub(s,e.ONE));return Os(e,c,t),c}function Ww(e){const t=Qt(e),n=qu(e),r=n(t,t.neg(t.ONE)),o=n(t,r),i=n(t,t.neg(r)),s=(e+Gw)/Tu;return(c,f)=>{let a=c.pow(f,s),l=c.mul(a,r);const h=c.mul(a,o),d=c.mul(a,i),u=c.eql(c.sqr(l),f),p=c.eql(c.sqr(h),f);a=c.cmov(a,l,u),l=c.cmov(d,h,p);const m=c.eql(c.sqr(l),f),v=c.cmov(a,l,m);return Os(c,v,f),v}}function qu(e){if(e<Cu)throw new Error("sqrt is not defined for small field");let t=e-Fe,n=0;for(;t%gn===Le;)t/=gn,n++;let r=gn;const o=Qt(e);for(;Hu(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Lu;let i=o.pow(r,t);const s=(t+Fe)/gn;return function(c,f){if(c.is0(f))return f;if(Hu(c,f)!==1)throw new Error("Cannot find square root");let a=n,l=c.mul(c.ONE,i),h=c.pow(f,t),d=c.pow(f,s);for(;!c.eql(h,c.ONE);){if(c.is0(h))return c.ZERO;let u=1,p=c.sqr(h);for(;!c.eql(p,c.ONE);)if(u++,p=c.sqr(p),u===a)throw new Error("Cannot find square root");const m=Fe<<BigInt(a-u-1),v=c.pow(l,m);a=u,l=c.sqr(v),h=c.mul(h,l),d=c.mul(d,v)}return d}}function Xw(e){return e%Uu===Cu?Lu:e%$u===Ru?Yw:e%Tu===Kw?Ww(e):qu(e)}const Jw=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Qw(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=Jw.reduce((r,o)=>(r[o]="function",r),t);return wo(e,n),e}function ep(e,t,n){if(n<Le)throw new Error("invalid exponent, negatives unsupported");if(n===Le)return e.ONE;if(n===Fe)return t;let r=e.ONE,o=t;for(;n>Le;)n&Fe&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Fe;return r}function ju(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((s,c,f)=>e.is0(c)?s:(r[f]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,f)=>e.is0(c)?s:(r[f]=e.mul(s,r[f]),e.mul(s,c)),i),r}function Hu(e,t){const n=(e.ORDER-Fe)/gn,r=e.pow(t,n),o=e.eql(r,e.ONE),i=e.eql(r,e.ZERO),s=e.eql(r,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Mu(e,t){t!==void 0&&Mt(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Qt(e,t,n=!1,r={}){if(e<=Le)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i,s=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const d=t;d.BITS&&(o=d.BITS),d.sqrt&&(i=d.sqrt),typeof d.isLE=="boolean"&&(n=d.isLE),typeof d.modFromBytes=="boolean"&&(s=d.modFromBytes),c=d.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(i=r.sqrt);const{nBitLength:f,nByteLength:a}=Mu(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let l;const h=Object.freeze({ORDER:e,isLE:n,BITS:f,BYTES:a,MASK:pr(f),ZERO:Le,ONE:Fe,allowedLengths:c,create:d=>He(d,e),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Le<=d&&d<e},is0:d=>d===Le,isValidNot0:d=>!h.is0(d)&&h.isValid(d),isOdd:d=>(d&Fe)===Fe,neg:d=>He(-d,e),eql:(d,u)=>d===u,sqr:d=>He(d*d,e),add:(d,u)=>He(d+u,e),sub:(d,u)=>He(d-u,e),mul:(d,u)=>He(d*u,e),pow:(d,u)=>ep(h,d,u),div:(d,u)=>He(d*Pu(u,e),e),sqrN:d=>d*d,addN:(d,u)=>d+u,subN:(d,u)=>d-u,mulN:(d,u)=>d*u,inv:d=>Pu(d,e),sqrt:i||(d=>(l||(l=Xw(e)),l(h,d))),toBytes:d=>n?Bs(d,a):vs(d,a),fromBytes:(d,u=!0)=>{if(c){if(!c.includes(d.length)||d.length>a)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+d.length);const m=new Uint8Array(a);m.set(d,n?0:m.length-d.length),d=m}if(d.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+d.length);let p=n?go(d):bo(d);if(s&&(p=He(p,e)),!u&&!h.isValid(p))throw new Error("invalid field element: outside of range 0..ORDER");return p},invertBatch:d=>ju(h,d),cmov:(d,u,p)=>p?u:d});return Object.freeze(h)}function zu(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ku(e){const t=zu(e);return t+Math.ceil(t/2)}function tp(e,t,n=!1){const r=e.length,o=zu(t),i=ku(t);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const s=n?go(e):bo(e),c=He(s,t-Fe)+Fe;return n?Bs(c,o):vs(c,o)}const jn=BigInt(0),wn=BigInt(1);function po(e,t){const n=t.negate();return e?n:t}function Ss(e,t){const n=ju(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function Zu(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function _s(e,t){Zu(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,i=pr(e),s=BigInt(e);return{windows:n,windowSize:r,mask:i,maxNumber:o,shiftBy:s}}function Vu(e,t,n){const{windowSize:r,mask:o,maxNumber:i,shiftBy:s}=n;let c=Number(e&o),f=e>>s;c>r&&(c-=i,f+=wn);const a=t*r,l=a+Math.abs(c)-1,h=c===0,d=c<0,u=t%2!==0;return{nextN:f,offset:l,isZero:h,isNeg:d,isNegF:u,offsetF:a}}function np(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function rp(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const Is=new WeakMap,Gu=new WeakMap;function Ns(e){return Gu.get(e)||1}function Ku(e){if(e!==jn)throw new Error("invalid wNAF")}class op{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>jn;)n&wn&&(r=r.add(o)),o=o.double(),n>>=wn;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=_s(n,this.bits),i=[];let s=t,c=s;for(let f=0;f<r;f++){c=s,i.push(c);for(let a=1;a<o;a++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE;const s=_s(t,this.bits);for(let c=0;c<s.windows;c++){const{nextN:f,offset:a,isZero:l,isNeg:h,isNegF:d,offsetF:u}=Vu(r,c,s);r=f,l?i=i.add(po(d,n[u])):o=o.add(po(h,n[a]))}return Ku(r),{p:o,f:i}}wNAFUnsafe(t,n,r,o=this.ZERO){const i=_s(t,this.bits);for(let s=0;s<i.windows&&r!==jn;s++){const{nextN:c,offset:f,isZero:a,isNeg:l}=Vu(r,s,i);if(r=c,!a){const h=n[f];o=o.add(l?h.negate():h)}}return Ku(r),o}getPrecomputes(t,n,r){let o=Is.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),Is.set(n,o))),o}cached(t,n,r){const o=Ns(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const i=Ns(t);return i===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,r),n,o)}createCache(t,n){Zu(n,this.bits),Gu.set(t,n),Is.delete(t)}hasCache(t){return Ns(t)!==1}}function ip(e,t,n,r){let o=t,i=e.ZERO,s=e.ZERO;for(;n>jn||r>jn;)n&wn&&(i=i.add(o)),r&wn&&(s=s.add(o)),o=o.double(),n>>=wn,r>>=wn;return{p1:i,p2:s}}function sp(e,t,n,r){np(n,e),rp(r,t);const o=n.length,i=r.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=Nu(BigInt(o));let f=1;c>12?f=c-3:c>4?f=c-2:c>0&&(f=2);const a=pr(f),l=new Array(Number(a)+1).fill(s),h=Math.floor((t.BITS-1)/f)*f;let d=s;for(let u=h;u>=0;u-=f){l.fill(s);for(let m=0;m<i;m++){const v=r[m],_=Number(v>>BigInt(u)&a);l[_]=l[_].add(n[m])}let p=s;for(let m=l.length-1,v=s;m>0;m--)v=v.add(l[m]),p=p.add(v);if(d=d.add(p),u!==0)for(let m=0;m<f;m++)d=d.double()}return d}function Yu(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Qw(t),t}else return Qt(e,{isLE:n})}function cp(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const c of["p","n","h"]){const f=t[c];if(!(typeof f=="bigint"&&f>jn))throw new Error(`CURVE.${c} must be positive bigint`)}const o=Yu(t.p,n.Fp,r),i=Yu(t.n,n.Fn,r),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const c of s)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),au("HashToScalar-");const yr=BigInt(0),Hn=BigInt(1),yo=BigInt(2);function fp(e){return wo(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze(Tn({},e))}function ap(e){const t=fp(e),{P:n,type:r,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=t,c=r==="x25519";if(!c&&r!=="x448")throw new Error("invalid type");const f=s||ds,a=c?255:448,l=c?32:56,h=BigInt(c?9:5),d=BigInt(c?121665:39081),u=c?yo**BigInt(254):yo**BigInt(447),p=c?BigInt(8)*yo**BigInt(251)-Hn:BigInt(4)*yo**BigInt(445)-Hn,m=u+p+Hn,v=E=>He(E,n),_=$(h);function $(E){return Bs(v(E),l)}function D(E){const g=De("u coordinate",E,l);return c&&(g[31]&=127),v(go(g))}function x(E){return go(o(De("scalar",E,l)))}function C(E,g){const y=L(D(g),x(E));if(y===yr)throw new Error("invalid private or public key received");return $(y)}function P(E){return C(E,_)}function q(E,g,y){const b=v(E*(g-y));return g=v(g-b),y=v(y+b),{x_2:g,x_3:y}}function L(E,g){As("u",E,yr,n),As("scalar",g,u,m);const y=g,b=E;let w=Hn,B=yr,A=E,O=Hn,S=yr;for(let R=BigInt(a-1);R>=yr;R--){const U=y>>R&Hn;S^=U,{x_2:w,x_3:A}=q(S,w,A),{x_2:B,x_3:O}=q(S,B,O),S=U;const T=w+B,F=v(T*T),j=w-B,M=v(j*j),V=F-M,z=A+O,Z=A-O,W=v(Z*T),J=v(z*j),ee=W+J,oe=W-J;A=v(ee*ee),O=v(b*v(oe*oe)),w=v(F*M),B=v(V*(F+v(d*V)))}({x_2:w,x_3:A}=q(S,w,A)),{x_2:B,x_3:O}=q(S,B,O);const N=i(B);return v(w*N)}const I={secretKey:l,publicKey:l,seed:l},k=(E=f(l))=>(Je(E,I.seed),E);function H(E){const g=k(E);return{secretKey:g,publicKey:P(g)}}return{keygen:H,getSharedSecret:(E,g)=>C(E,g),getPublicKey:E=>P(E),scalarMult:C,scalarMultBase:P,utils:{randomSecretKey:k,randomPrivateKey:k},GuBytes:_.slice(),lengths:I}}const up=BigInt(1),Wu=BigInt(2),lp=BigInt(3),dp=BigInt(5),hp=BigInt(8),Xu=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),bp={p:Xu,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:hp,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function gp(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=Xu,s=e*e%i*e%i,c=et(s,Wu,i)*s%i,f=et(c,up,i)*e%i,a=et(f,dp,i)*f%i,l=et(a,t,i)*a%i,h=et(l,n,i)*l%i,d=et(h,r,i)*h%i,u=et(d,o,i)*d%i,p=et(u,o,i)*d%i,m=et(p,t,i)*a%i;return{pow_p_5_8:et(m,Wu,i)*e%i,b2:s}}function wp(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const pp=Qt(bp.p,{isLE:!0});(()=>{const e=pp.ORDER;return ap({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:r}=gp(t);return He(et(n,lp,e)*r,e)},adjustScalarBytes:wp})})();const Ju=(e,t)=>(e+(e>=0?t:-t)/Qu)/t;function yp(e,t,n){const[[r,o],[i,s]]=t,c=Ju(s*e,n),f=Ju(-o*e,n);let a=e-c*r-f*i,l=-c*o-f*s;const h=a<At,d=l<At;h&&(a=-a),d&&(l=-l);const u=pr(Math.ceil(Nu(n)/2))+Mn;if(a<At||a>=u||l<At||l>=u)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:a,k2neg:d,k2:l}}function Fs(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Cs(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return lo(n.lowS,"lowS"),lo(n.prehash,"prehash"),n.format!==void 0&&Fs(n.format),n}class mp extends Error{constructor(t=""){super(t)}}const Dt={Err:mp,_tlv:{encode:(e,t)=>{const{Err:n}=Dt;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=ho(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?ho(o.length/2|128):"";return ho(e)+i+o+t},decode(e,t){const{Err:n}=Dt;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],i=!!(o&128);let s=0;if(!i)s=o;else{const f=o&127;if(!f)throw new n("tlv.decode(long): indefinite length not supported");if(f>4)throw new n("tlv.decode(long): byte length is too big");const a=t.subarray(r,r+f);if(a.length!==f)throw new n("tlv.decode: length bytes not complete");if(a[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const l of a)s=s<<8|l;if(r+=f,s<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+s);if(c.length!==s)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+s)}}},_int:{encode(e){const{Err:t}=Dt;if(e<At)throw new t("integer: negative integers are not allowed");let n=ho(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Dt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return bo(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Dt,o=De("signature",e),{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:f}=r.decode(2,i),{v:a,l}=r.decode(2,f);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(a)}},hexFromSig(e){const{_tlv:t,_int:n}=Dt,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),i=r+o;return t.encode(48,i)}},At=BigInt(0),Mn=BigInt(1),Qu=BigInt(2),mo=BigInt(3),Ep=BigInt(4);function zn(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=De("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function xp(e,t={}){const n=cp("weierstrass",e,t),{Fp:r,Fn:o}=n;let i=n.CURVE;const{h:s,n:c}=i;wo(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:f}=t;if(f&&(!r.is0(i.a)||typeof f.beta!="bigint"||!Array.isArray(f.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const a=tl(r,o);function l(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(E,g,y){const{x:b,y:w}=g.toAffine(),B=r.toBytes(b);if(lo(y,"isCompressed"),y){l();const A=!r.isOdd(w);return Zt(el(A),B)}else return Zt(Uint8Array.of(4),B,r.toBytes(w))}function d(E){bn(E,void 0,"Point");const{publicKey:g,publicKeyUncompressed:y}=a,b=E.length,w=E[0],B=E.subarray(1);if(b===g&&(w===2||w===3)){const A=r.fromBytes(B);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");const O=m(A);let S;try{S=r.sqrt(O)}catch(R){const U=R instanceof Error?": "+R.message:"";throw new Error("bad point: is not on curve, sqrt error"+U)}l();const N=r.isOdd(S);return(w&1)===1!==N&&(S=r.neg(S)),{x:A,y:S}}else if(b===y&&w===4){const A=r.BYTES,O=r.fromBytes(B.subarray(0,A)),S=r.fromBytes(B.subarray(A,A*2));if(!v(O,S))throw new Error("bad point: is not on curve");return{x:O,y:S}}else throw new Error(`bad point: got length ${b}, expected compressed=${g} or uncompressed=${y}`)}const u=t.toBytes||h,p=t.fromBytes||d;function m(E){const g=r.sqr(E),y=r.mul(g,E);return r.add(r.add(y,r.mul(E,i.a)),i.b)}function v(E,g){const y=r.sqr(g),b=m(E);return r.eql(y,b)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const _=r.mul(r.pow(i.a,mo),Ep),$=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(_,$)))throw new Error("bad curve params: a or b");function D(E,g,y=!1){if(!r.isValid(g)||y&&r.is0(g))throw new Error(`bad point coordinate ${E}`);return g}function x(E){if(!(E instanceof I))throw new Error("ProjectivePoint expected")}function C(E){if(!f||!f.basises)throw new Error("no endo");return yp(E,f.basises,o.ORDER)}const P=Fu((E,g)=>{const{X:y,Y:b,Z:w}=E;if(r.eql(w,r.ONE))return{x:y,y:b};const B=E.is0();g==null&&(g=B?r.ONE:r.inv(w));const A=r.mul(y,g),O=r.mul(b,g),S=r.mul(w,g);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),q=Fu(E=>{if(E.is0()){if(t.allowInfinityPoint&&!r.is0(E.Y))return;throw new Error("bad point: ZERO")}const{x:g,y}=E.toAffine();if(!r.isValid(g)||!r.isValid(y))throw new Error("bad point: x or y not field elements");if(!v(g,y))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function L(E,g,y,b,w){return y=new I(r.mul(y.X,E),y.Y,y.Z),g=po(b,g),y=po(w,y),g.add(y)}class I{constructor(g,y,b){this.X=D("x",g),this.Y=D("y",y,!0),this.Z=D("z",b),Object.freeze(this)}static CURVE(){return i}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!r.isValid(y)||!r.isValid(b))throw new Error("invalid affine point");if(g instanceof I)throw new Error("projective point not allowed");return r.is0(y)&&r.is0(b)?I.ZERO:new I(y,b,r.ONE)}static fromBytes(g){const y=I.fromAffine(p(bn(g,void 0,"point")));return y.assertValidity(),y}static fromHex(g){return I.fromBytes(De("pointHex",g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,y=!0){return H.createCache(this,g),y||this.multiply(mo),this}assertValidity(){q(this)}hasEvenY(){const{y:g}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(g)}equals(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g,S=r.eql(r.mul(y,O),r.mul(B,w)),N=r.eql(r.mul(b,O),r.mul(A,w));return S&&N}negate(){return new I(this.X,r.neg(this.Y),this.Z)}double(){const{a:g,b:y}=i,b=r.mul(y,mo),{X:w,Y:B,Z:A}=this;let O=r.ZERO,S=r.ZERO,N=r.ZERO,R=r.mul(w,w),U=r.mul(B,B),T=r.mul(A,A),F=r.mul(w,B);return F=r.add(F,F),N=r.mul(w,A),N=r.add(N,N),O=r.mul(g,N),S=r.mul(b,T),S=r.add(O,S),O=r.sub(U,S),S=r.add(U,S),S=r.mul(O,S),O=r.mul(F,O),N=r.mul(b,N),T=r.mul(g,T),F=r.sub(R,T),F=r.mul(g,F),F=r.add(F,N),N=r.add(R,R),R=r.add(N,R),R=r.add(R,T),R=r.mul(R,F),S=r.add(S,R),T=r.mul(B,A),T=r.add(T,T),R=r.mul(T,F),O=r.sub(O,R),N=r.mul(T,U),N=r.add(N,N),N=r.add(N,N),new I(O,S,N)}add(g){x(g);const{X:y,Y:b,Z:w}=this,{X:B,Y:A,Z:O}=g;let S=r.ZERO,N=r.ZERO,R=r.ZERO;const U=i.a,T=r.mul(i.b,mo);let F=r.mul(y,B),j=r.mul(b,A),M=r.mul(w,O),V=r.add(y,b),z=r.add(B,A);V=r.mul(V,z),z=r.add(F,j),V=r.sub(V,z),z=r.add(y,w);let Z=r.add(B,O);return z=r.mul(z,Z),Z=r.add(F,M),z=r.sub(z,Z),Z=r.add(b,w),S=r.add(A,O),Z=r.mul(Z,S),S=r.add(j,M),Z=r.sub(Z,S),R=r.mul(U,z),S=r.mul(T,M),R=r.add(S,R),S=r.sub(j,R),R=r.add(j,R),N=r.mul(S,R),j=r.add(F,F),j=r.add(j,F),M=r.mul(U,M),z=r.mul(T,z),j=r.add(j,M),M=r.sub(F,M),M=r.mul(U,M),z=r.add(z,M),F=r.mul(j,z),N=r.add(N,F),F=r.mul(Z,z),S=r.mul(V,S),S=r.sub(S,F),F=r.mul(V,j),R=r.mul(Z,R),R=r.add(R,F),new I(S,N,R)}subtract(g){return this.add(g.negate())}is0(){return this.equals(I.ZERO)}multiply(g){const{endo:y}=t;if(!o.isValidNot0(g))throw new Error("invalid scalar: out of range");let b,w;const B=A=>H.cached(this,A,O=>Ss(I,O));if(y){const{k1neg:A,k1:O,k2neg:S,k2:N}=C(g),{p:R,f:U}=B(O),{p:T,f:F}=B(N);w=U.add(F),b=L(y.beta,R,T,A,S)}else{const{p:A,f:O}=B(g);b=A,w=O}return Ss(I,[b,w])[0]}multiplyUnsafe(g){const{endo:y}=t,b=this;if(!o.isValid(g))throw new Error("invalid scalar: out of range");if(g===At||b.is0())return I.ZERO;if(g===Mn)return b;if(H.hasCache(this))return this.multiply(g);if(y){const{k1neg:w,k1:B,k2neg:A,k2:O}=C(g),{p1:S,p2:N}=ip(I,b,B,O);return L(y.beta,S,N,w,A)}else return H.unsafe(b,g)}multiplyAndAddUnsafe(g,y,b){const w=this.multiplyUnsafe(y).add(g.multiplyUnsafe(b));return w.is0()?void 0:w}toAffine(g){return P(this,g)}isTorsionFree(){const{isTorsionFree:g}=t;return s===Mn?!0:g?g(I,this):H.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:g}=t;return s===Mn?this:g?g(I,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(g=!0){return lo(g,"isCompressed"),this.assertValidity(),u(I,this,g)}toHex(g=!0){return Ln(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(g=!0){return this.toBytes(g)}_setWindowSize(g){this.precompute(g)}static normalizeZ(g){return Ss(I,g)}static msm(g,y){return sp(I,o,g,y)}static fromPrivateKey(g){return I.BASE.multiply(zn(o,g))}}I.BASE=new I(i.Gx,i.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=o;const k=o.BITS,H=new op(I,t.endo?Math.ceil(k/2):k);return I.BASE.precompute(8),I}function el(e){return Uint8Array.of(e?2:3)}function tl(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function vp(e,t={}){const{Fn:n}=e,r=t.randomBytes||ds,o=Object.assign(tl(e.Fp,n),{seed:ku(n.ORDER)});function i(d){try{return!!zn(n,d)}catch{return!1}}function s(d,u){const{publicKey:p,publicKeyUncompressed:m}=o;try{const v=d.length;return u===!0&&v!==p||u===!1&&v!==m?!1:!!e.fromBytes(d)}catch{return!1}}function c(d=r(o.seed)){return tp(bn(d,o.seed,"seed"),n.ORDER)}function f(d,u=!0){return e.BASE.multiply(zn(n,d)).toBytes(u)}function a(d){const u=c(d);return{secretKey:u,publicKey:f(u)}}function l(d){if(typeof d=="bigint")return!1;if(d instanceof e)return!0;const{secretKey:u,publicKey:p,publicKeyUncompressed:m}=o;if(n.allowedLengths||u===p)return;const v=De("key",d).length;return v===p||v===m}function h(d,u,p=!0){if(l(d)===!0)throw new Error("first arg must be private key");if(l(u)===!1)throw new Error("second arg must be public key");const m=zn(n,d);return e.fromHex(u).multiply(m).toBytes(p)}return Object.freeze({getPublicKey:f,getSharedSecret:h,keygen:a,Point:e,utils:{isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c,isValidPrivateKey:i,randomPrivateKey:c,normPrivateKeyToScalar:d=>zn(n,d),precompute(d=8,u=e.BASE){return u.precompute(d,!1)}},lengths:o})}function Bp(e,t,n={}){ou(t),wo(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||ds,o=n.hmac||((y,...b)=>_u(t,y,Zt(...b))),{Fp:i,Fn:s}=e,{ORDER:c,BITS:f}=s,{keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u}=vp(e,n),p={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},m="compact";function v(y){const b=c>>Mn;return y>b}function _(y,b){if(!s.isValidNot0(b))throw new Error(`invalid signature ${y}: out of range 1..Point.Fn.ORDER`);return b}function $(y,b){Fs(b);const w=u.signature,B=b==="compact"?w:b==="recovered"?w+1:void 0;return bn(y,B,`${b} signature`)}class D{constructor(b,w,B){this.r=_("r",b),this.s=_("s",w),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(b,w=m){$(b,w);let B;if(w==="der"){const{r:N,s:R}=Dt.toSig(bn(b));return new D(N,R)}w==="recovered"&&(B=b[0],w="compact",b=b.subarray(1));const A=s.BYTES,O=b.subarray(0,A),S=b.subarray(A,A*2);return new D(s.fromBytes(O),s.fromBytes(S),B)}static fromHex(b,w){return this.fromBytes(fo(b),w)}addRecoveryBit(b){return new D(this.r,this.s,b)}recoverPublicKey(b){const w=i.ORDER,{r:B,s:A,recovery:O}=this;if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");if(c*Qu<w&&O>1)throw new Error("recovery id is ambiguous for h>1 curve");const S=O===2||O===3?B+c:B;if(!i.isValid(S))throw new Error("recovery id 2 or 3 invalid");const N=i.toBytes(S),R=e.fromBytes(Zt(el((O&1)===0),N)),U=s.inv(S),T=C(De("msgHash",b)),F=s.create(-T*U),j=s.create(A*U),M=e.BASE.multiplyUnsafe(F).add(R.multiplyUnsafe(j));if(M.is0())throw new Error("point at infinify");return M.assertValidity(),M}hasHighS(){return v(this.s)}toBytes(b=m){if(Fs(b),b==="der")return fo(Dt.hexFromSig(this));const w=s.toBytes(this.r),B=s.toBytes(this.s);if(b==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Zt(Uint8Array.of(this.recovery),w,B)}return Zt(w,B)}toHex(b){return Ln(this.toBytes(b))}assertValidity(){}static fromCompact(b){return D.fromBytes(De("sig",b),"compact")}static fromDER(b){return D.fromBytes(De("sig",b),"der")}normalizeS(){return this.hasHighS()?new D(this.r,s.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Ln(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Ln(this.toBytes("compact"))}}const x=n.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");const b=bo(y),w=y.length*8-f;return w>0?b>>BigInt(w):b},C=n.bits2int_modN||function(y){return s.create(x(y))},P=pr(f);function q(y){return As("num < 2^"+f,y,At,P),s.toBytes(y)}function L(y,b){return bn(y,void 0,"message"),b?bn(t(y),void 0,"prehashed message"):y}function I(y,b,w){if(["recovered","canonical"].some(j=>j in w))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:A,extraEntropy:O}=Cs(w,p);y=L(y,A);const S=C(y),N=zn(s,b),R=[q(N),q(S)];if(O!=null&&O!==!1){const j=O===!0?r(u.secretKey):O;R.push(De("extraEntropy",j))}const U=Zt(...R),T=S;function F(j){const M=x(j);if(!s.isValidNot0(M))return;const V=s.inv(M),z=e.BASE.multiply(M).toAffine(),Z=s.create(z.x);if(Z===At)return;const W=s.create(V*s.create(T+Z*N));if(W===At)return;let J=(z.x===Z?0:2)|Number(z.y&Mn),ee=W;return B&&v(W)&&(ee=s.neg(W),J^=1),new D(Z,ee,J)}return{seed:U,k2sig:F}}function k(y,b,w={}){y=De("message",y);const{seed:B,k2sig:A}=I(y,b,w);return Vw(t.outputLen,s.BYTES,o)(B,A)}function H(y){let b;const w=typeof y=="string"||co(y),B=!w&&y!==null&&typeof y=="object"&&typeof y.r=="bigint"&&typeof y.s=="bigint";if(!w&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)b=new D(y.r,y.s);else if(w){try{b=D.fromBytes(De("sig",y),"der")}catch(A){if(!(A instanceof Dt.Err))throw A}if(!b)try{b=D.fromBytes(De("sig",y),"compact")}catch{return!1}}return b||!1}function E(y,b,w,B={}){const{lowS:A,prehash:O,format:S}=Cs(B,p);if(w=De("publicKey",w),b=L(De("message",b),O),"strict"in B)throw new Error("options.strict was renamed to lowS");const N=S===void 0?H(y):D.fromBytes(De("sig",y),S);if(N===!1)return!1;try{const R=e.fromBytes(w);if(A&&N.hasHighS())return!1;const{r:U,s:T}=N,F=C(b),j=s.inv(T),M=s.create(F*j),V=s.create(U*j),z=e.BASE.multiplyUnsafe(M).add(R.multiplyUnsafe(V));return z.is0()?!1:s.create(z.x)===U}catch{return!1}}function g(y,b,w={}){const{prehash:B}=Cs(w,p);return b=L(b,B),D.fromBytes(y,"recovered").recoverPublicKey(b).toBytes()}return Object.freeze({keygen:a,getPublicKey:l,getSharedSecret:h,utils:d,lengths:u,Point:e,sign:k,verify:E,recoverPublicKey:g,Signature:D,hash:t})}function Dp(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(s=>Math.ceil(s/2)))):void 0;const o=Qt(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),i={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:i}}function Ap(e){const{CURVE:t,curveOpts:n}=Dp(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Op(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,Mu(n.Fn.ORDER,n.Fn.BITS))})}function Sp(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Ap(e),i=xp(t,n),s=Bp(i,r,o);return Op(e,s)}function Us(e,t){const n=r=>Sp(lr(Tn({},e),{hash:r}));return lr(Tn({},n(t)),{create:n})}const nl={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},rl={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},ol={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},_p=Qt(nl.p),Ip=Qt(rl.p),Np=Qt(ol.p);Us(lr(Tn({},nl),{Fp:_p,lowS:!1}),gw),Us(lr(Tn({},rl),{Fp:Ip,lowS:!1}),pw),Us(lr(Tn({},ol),{Fp:Np,lowS:!1,allowedPrivateKeyLengths:[130,131,132]}),ww);const il="https://api.pay.walletconnect.com",sl="js-walletconnect-pay",cl="1.0.2",Fp="pay",Ve="WalletConnectPay";function Cp(){return T3()?"rn-ios":$3()?"rn-android":P3()?"browser":Ja()?"node":"unknown"}var Up=Object.defineProperty,Rp=(e,t,n)=>t in e?Up(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fl=(e,t,n)=>Rp(e,typeof t!="symbol"?t+"":t,n);class ae extends Error{constructor(t,n,r){super(n),fl(this,"code"),fl(this,"originalMessage"),this.name="PayError",this.code=t,this.originalMessage=r??n,Object.setPrototypeOf(this,ae.prototype)}static fromNativeError(t){if(t instanceof ae)return t;const n=t instanceof Error?t.message:String(t);return n.includes("JSON parse error")?new ae("JSON_PARSE",n):n.includes("JSON serialize error")?new ae("JSON_SERIALIZE",n):n.includes("Payment options error")?new ae("PAYMENT_OPTIONS",n):n.includes("Payment request error")?new ae("PAYMENT_REQUEST",n):n.includes("Confirm payment error")?new ae("CONFIRM_PAYMENT",n):new ae("UNKNOWN",n)}}class Eo extends ae{constructor(){super("NATIVE_MODULE_NOT_FOUND","WalletConnect Pay native module not found. Make sure @walletconnect/react-native-compat is installed and linked."),this.name="NativeModuleNotFoundError",Object.setPrototypeOf(this,Eo.prototype)}}class xo extends ae{constructor(t){super("PAYMENT_OPTIONS",`Failed to get payment options: ${t}`,t),this.name="PaymentOptionsError",Object.setPrototypeOf(this,xo.prototype)}}class vo extends ae{constructor(t){super("PAYMENT_REQUEST",`Failed to get payment actions: ${t}`,t),this.name="PaymentActionsError",Object.setPrototypeOf(this,vo.prototype)}}class Bo extends ae{constructor(t){super("CONFIRM_PAYMENT",`Failed to confirm payment: ${t}`,t),this.name="ConfirmPaymentError",Object.setPrototypeOf(this,Bo.prototype)}}var $p=Object.defineProperty,Tp=(e,t,n)=>t in e?$p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pp=(e,t,n)=>Tp(e,typeof t!="symbol"?t+"":t,n);let it,Do=null;function al(){var e,t;if(Do)return Do;if(it!==void 0)return it;try{const n=globalThis.ReactNative;if((e=n?.NativeModules)!=null&&e.RNWalletConnectPay)return it=n.NativeModules.RNWalletConnectPay,it;const r=(t=globalThis.expo)==null?void 0:t.modules;return r!=null&&r.RNWalletConnectPay?(it=r.RNWalletConnectPay,it):(it=null,null)}catch{return it=null,null}}function Lp(e){Do=e,it=e}function ul(){return al()!==null}function qp(){Do=null,it=void 0}class ll{constructor(t){Pp(this,"module");const n=al();if(!n)throw new Eo;if(n.initialize)try{const r=JSON.stringify(t);n.initialize(r)}catch(r){throw new ae("INITIALIZATION_ERROR",`Failed to initialize native Pay module: ${r instanceof Error?r.message:String(r)}`)}this.module=n}async getPaymentOptions(t){var n;const r={paymentLink:t.paymentLink,accounts:t.accounts,includePaymentInfo:(n=t.includePaymentInfo)!=null?n:!1};try{const o=await this.module.getPaymentOptions(JSON.stringify(r));return JSON.parse(o)}catch(o){throw ae.fromNativeError(o)}}async getRequiredPaymentActions(t){const n={paymentId:t.paymentId,optionId:t.optionId};try{const r=await this.module.getRequiredPaymentActions(JSON.stringify(n));return JSON.parse(r)}catch(r){throw ae.fromNativeError(r)}}async confirmPayment(t){const n={paymentId:t.paymentId,optionId:t.optionId,signatures:t.signatures,collectedData:t.collectedData};try{const r=await this.module.confirmPayment(JSON.stringify(n));return JSON.parse(r)}catch(r){throw ae.fromNativeError(r)}}}function dl(e){return new ll(e)}function Rs(){return ul()?"native":null}function hl(e){const t=Rs();if(!t)throw new Error("No Pay provider available. Make sure you are running in React Native with the native module installed, or in a browser with WASM support.");switch(t){case"native":return dl(e);case"wasm":throw new Error("WASM provider not yet implemented");default:throw new Error(`Unknown provider type: ${t}`)}}function bl(){return Rs()!==null}var jp=Object.defineProperty,Hp=(e,t,n)=>t in e?jp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mr=(e,t,n)=>Hp(e,typeof t!="symbol"?t+"":t,n);class gl{constructor(t){mr(this,"appId"),mr(this,"apiKey"),mr(this,"baseUrl"),mr(this,"logger"),mr(this,"provider");var n,r,o;this.appId=t.appId,this.apiKey=t.apiKey,this.baseUrl=(n=t.baseUrl)!=null?n:il,this.logger=typeof t.logger=="string"?Hs(ks({level:t.logger})):(r=t.logger)!=null?r:Hs(ks({level:"error"})),this.logger.trace(`${Ve} initialized`);const i={baseUrl:this.baseUrl,projectId:t.appId,apiKey:t.apiKey,appId:t.appId,clientId:t.clientId,sdkName:sl,sdkVersion:cl,sdkPlatform:Cp(),bundleId:(o=L3())!=null?o:""};this.provider=hl(i),this.logger.debug(`${Ve} provider initialized`)}static isAvailable(){return bl()}async getPaymentOptions(t){this.logger.debug({paymentLink:t.paymentLink,accounts:t.accounts,includePaymentInfo:t.includePaymentInfo},`${Ve} getPaymentOptions`);try{const n=await this.provider.getPaymentOptions(t);return this.logger.debug({paymentId:n.paymentId,optionsCount:n.options.length},`${Ve} getPaymentOptions response`),n}catch(n){throw this.logger.error({error:n},`${Ve} getPaymentOptions error`),n instanceof ae?n:new xo(String(n))}}async getRequiredPaymentActions(t){this.logger.debug({paymentId:t.paymentId,optionId:t.optionId},`${Ve} getRequiredPaymentActions`);try{const n=await this.provider.getRequiredPaymentActions(t);return this.logger.debug({actionsCount:n.length},`${Ve} getRequiredPaymentActions response`),n}catch(n){throw this.logger.error({error:n},`${Ve} getRequiredPaymentActions error`),n instanceof ae?n:new vo(String(n))}}async confirmPayment(t){this.logger.debug({paymentId:t.paymentId,optionId:t.optionId,signaturesCount:t.signatures.length,hasCollectedData:!!t.collectedData},`${Ve} confirmPayment`);try{const n=await this.provider.confirmPayment(t);return this.logger.debug({status:n.status,isFinal:n.isFinal},`${Ve} confirmPayment response`),n}catch(n){throw this.logger.error({error:n},`${Ve} confirmPayment error`),n instanceof ae?n:new Bo(String(n))}}}const Mp=gl;ie.CLIENT_CONTEXT=Fp,ie.ConfirmPaymentError=Bo,ie.LOGGER_CONTEXT=Ve,ie.NativeModuleNotFoundError=Eo,ie.NativeProvider=ll,ie.PAY_API_BASE_URL=il,ie.PayError=ae,ie.PaymentActionsError=vo,ie.PaymentOptionsError=xo,ie.SDK_NAME=sl,ie.SDK_VERSION=cl,ie.WalletConnectPay=Mp,ie.createNativeProvider=dl,ie.createProvider=hl,ie.default=gl,ie.detectProviderType=Rs,ie.isNativeProviderAvailable=ul,ie.isProviderAvailable=bl,ie.resetNativeModule=qp,ie.setNativeModule=Lp,Object.defineProperty(ie,"__esModule",{value:!0})});
17
17
  //# sourceMappingURL=index.umd.js.map