@cmts-dev/carmentis-sdk-core 1.0.0 → 1.1.0
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n;(function(e){e[e.CARMENTIS_ERROR=0]=`CARMENTIS_ERROR`,e[e.NODE_ERROR=1]=`NODE_ERROR`,e[e.NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR=2]=`NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR`,e[e.INTERNAL_ERROR=500]=`INTERNAL_ERROR`,e[e.TYPE_CHECKING_FAILURE_ERROR=501]=`TYPE_CHECKING_FAILURE_ERROR`,e[e.SERIALIZATION_ERROR=502]=`SERIALIZATION_ERROR`,e[e.PROOF_VERIFICATION_FAILURE=300]=`PROOF_VERIFICATION_FAILURE`,e[e.BLOCKCHAIN_ERROR=100]=`BLOCKCHAIN_ERROR`,e[e.ACCOUNT_NOT_FOUND=101]=`ACCOUNT_NOT_FOUND`,e[e.ACCOUNT_ALREADY_EXISTS=102]=`ACCOUNT_ALREADY_EXISTS`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY=103]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH=104]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH`,e[e.ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY=105]=`ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_ADDRESS=106]=`ACCOUNT_NOT_FOUND_FOR_ADDRESS`,e[e.ORGANIZATION_NOT_FOUND=107]=`ORGANIZATION_NOT_FOUND`,e[e.APPLICATION_NOT_FOUND=108]=`APPLICATION_NOT_FOUND`,e[e.APPLICATION_LEDGER_NOT_FOUND=109]=`APPLICATION_LEDGER_NOT_FOUND`,e[e.VALIDATOR_NODE_NOT_FOUND=110]=`VALIDATOR_NODE_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_NOT_FOUND=111]=`VIRTUAL_BLOCKCHAIN_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS=112]=`VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS`,e[e.MICROBLOCK_STRUCTURE_CHECKING_ERROR=113]=`MICROBLOCK_STRUCTURE_CHECKING_ERROR`,e[e.ECONOMICS_ERROR=200]=`ECONOMICS_ERROR`,e[e.INVALID_TOKEN_UNIT=201]=`INVALID_TOKEN_UNIT`,e[e.PROTOCOL_ERROR=400]=`PROTOCOL_ERROR`})(n||={});var r=class extends Error{},i=class extends r{},a=class extends r{},o=class e extends Error{code;constructor(e,t=n.CARMENTIS_ERROR){super(`[error ${t}] ${e}`),this.code=t}getErrorCode(){return this.code}static isCarmentisError(t){return t instanceof e}},s=class extends o{constructor(e){super(`Microblock structure checking error: ${e??`Not specified`}`,n.MICROBLOCK_STRUCTURE_CHECKING_ERROR)}},c=class extends o{constructor(){super(`You are not authenticated`)}},l=class extends o{constructor(e=`Parsing failure`){super(e)}},u=class extends o{constructor(e){super(e,n.BLOCKCHAIN_ERROR)}},d=class extends o{},f=class extends d{constructor(e){super(e??`Decryption failure`)}},p=class extends f{constructor(e){super(e)}},m=class extends o{},h=class extends m{},g=class extends h{constructor(e){super(`Connection with node at ${e} refused`,n.NODE_ERROR)}},_=class extends h{constructor(){super(`Query rejected while catching up`,n.NODE_ERROR)}},v=class extends o{constructor(e,t=n.ECONOMICS_ERROR){super(e,t)}},y=class extends v{constructor(){super(`Invalid unit type`,n.INVALID_TOKEN_UNIT)}},b=class extends o{constructor(e,t=n.BLOCKCHAIN_ERROR){super(e,t)}},ee=class extends Error{constructor(){super(`No implemented`)}},x=class extends b{constructor(e,t){super(`MicroBlock in virtual blockchain ${e.encode()} not found at height ${t}`)}},te=class extends b{constructor(){super(`MicroBlock not found`)}},S=class extends b{constructor(){super(`MicroBlock not found in block`)}},ne=class extends r{constructor(e){super(`Actor '${e}' already defined`)}},re=class extends r{constructor(e,t){super(`invalid actor ID ${e} (expected ID: ${t})`)}},ie=class extends r{constructor(e){super(`Channel '${e}' already defined`)}},ae=class extends r{constructor(e){super(`Unknown actor '${e}'`)}},oe=class extends r{constructor(e){super(`Unknown channel '${e}'`)}},se=class extends o{constructor(e,t,r){super(`Proof verification failed on channel ${e} (computed hash is ${t}, on-chain hash is ${r})`,n.PROOF_VERIFICATION_FAILURE)}},ce=class extends r{constructor(e){super(`Cannot subscribe as undefined actor ${e}`)}},C=class extends r{constructor(e){super(`Actor ${e} is already subscribed`)}},le=class extends r{constructor(e){super(`signature scheme of type ${e} is not allowed on this application ledger`)}},ue=class extends r{constructor(e){super(`PKE scheme of type ${e} is not allowed on this application ledger`)}},de=class extends r{constructor(e){super(`Invalid channel ID ${e}`)}},fe=class extends r{constructor(){super(`Current actor not found`)}},pe=class extends b{},me=class extends b{constructor(e,t){super(`Actor ${e} has not been invited to channel ${t}`)}},he=class extends b{constructor(e){super(`Account not found for public key`)}},ge=class extends b{constructor(e){super(`Account not found for account hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY)}},_e=class extends b{constructor(e){super(`Organization not found for hash: ${e.encode()}`,n.ORGANIZATION_NOT_FOUND)}},ve=class extends b{constructor(e){super(`Application not found for id: ${e.encode()}`,n.APPLICATION_NOT_FOUND)}},ye=class extends b{constructor(e){super(`Validator node not found for id: ${e.encode()}`,n.VALIDATOR_NODE_NOT_FOUND)}},be=class extends b{constructor(e){super(`Account not found for public key hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH)}},xe=class extends b{constructor(e){super(`Virtual blockchain not found: ${e.encode()}`,n.VIRTUAL_BLOCKCHAIN_NOT_FOUND)}},Se=class extends xe{constructor(e){super(e)}},Ce=class extends o{constructor(e,t=n.PROTOCOL_ERROR){super(`/!\\ `+e,t)}},we=class extends Ce{actorId;actorName;constructor(e,t){super(`Actor ${t} (id ${e}) has not subscribed to a public encryption key.`),this.actorId=e,this.actorName=t}getNotSubscribedActorName(){return this.actorName}},Te=class extends Ce{constructor(){super(`Section not found`)}},Ee=class extends Ce{constructor(e,t){super(`No shared secret between host ${t} and guest ${e}`)}},De=class extends o{constructor(e){super(e,n.SERIALIZATION_ERROR)}},Oe=9e15,ke=1e9,Ae=`0123456789abcdef`,je=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,Me=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Ne={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Oe,maxE:Oe,crypto:!1},Pe,Fe,w=!0,Ie=`[DecimalError] `,Le=Ie+`Invalid argument: `,Re=Ie+`Precision limit exceeded`,ze=Ie+`crypto unavailable`,Be=`[object Decimal]`,Ve=Math.floor,He=Math.pow,Ue=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,We=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ge=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ke=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,T=7,Je=9007199254740991,Ye=je.length-1,Xe=Me.length-1,E={toStringTag:Be};E.absoluteValue=E.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},E.ceil=function(){return D(new this.constructor(this),this.e+1,2)},E.clampedTo=E.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Le+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},E.comparedTo=E.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},E.cosine=E.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+T,r.rounding=1,n=tt(r,bt(r,n)),r.precision=e,r.rounding=t,D(Fe==2||Fe==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},E.cubeRoot=E.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(w=!1,a=u.s*He(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Ze(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=He(n,1/3),e=Ve((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=nt(l.plus(u).times(s),l.plus(c),o+2,1),Ze(s.d).slice(0,o)===(n=Ze(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(D(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return w=!0,D(r,e,d.rounding,t)},E.decimalPlaces=E.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Ve(this.e/T))*T,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},E.dividedBy=E.div=function(e){return nt(this,new this.constructor(e))},E.dividedToIntegerBy=E.divToInt=function(e){var t=this,n=t.constructor;return D(nt(t,new n(e),0,1,1),n.precision,n.rounding)},E.equals=E.eq=function(e){return this.cmp(e)===0},E.floor=function(){return D(new this.constructor(this),this.e+1,3)},E.greaterThan=E.gt=function(e){return this.cmp(e)>0},E.greaterThanOrEqualTo=E.gte=function(e){var t=this.cmp(e);return t==1||t===0},E.hyperbolicCosine=E.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/yt(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=vt(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return D(a,o.precision=n,o.rounding=r,!0)},E.hyperbolicSine=E.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=vt(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/yt(5,e)),i=vt(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,D(i,t,n,!0)},E.hyperbolicTangent=E.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,nt(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},E.inverseCosine=E.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?ot(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?ot(t,r,i):new t(0):new t(NaN)},E.inverseHyperbolicCosine=E.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,w=!1,n=n.times(n).minus(1).sqrt().plus(n),w=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},E.inverseHyperbolicSine=E.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,w=!1,n=n.times(n).plus(1).sqrt().plus(n),w=!0,r.precision=e,r.rounding=t,n.ln())},E.inverseHyperbolicTangent=E.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=n=r-i.e,i=nt(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},E.inverseSine=E.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=ot(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},E.inverseTangent=E.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Xe)return o=ot(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Xe)return o=ot(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/T+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(w=!1,t=Math.ceil(s/T),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),w=!0,D(o,u.precision=d,u.rounding=f,!0)},E.isFinite=function(){return!!this.d},E.isInteger=E.isInt=function(){return!!this.d&&Ve(this.e/T)>this.d.length-2},E.isNaN=function(){return!this.s},E.isNegative=E.isNeg=function(){return this.s<0},E.isPositive=E.isPos=function(){return this.s>0},E.isZero=function(){return!!this.d&&this.d[0]===0},E.lessThan=E.lt=function(e){return this.cmp(e)<0},E.lessThanOrEqualTo=E.lte=function(e){return this.cmp(e)<1},E.logarithm=E.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(w=!1,s=d+p,o=pt(l,s),r=t?at(u,s+10):pt(e,s),c=nt(o,r,s,1),$e(c.d,i=d,f))do if(s+=10,o=pt(l,s),r=t?at(u,s+10):pt(e,s),c=nt(o,r,s,1),!a){+Ze(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=D(c,d+1,0));break}while($e(c.d,i+=10,f));return w=!0,D(c,d,f)},E.minus=E.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return w?D(e,s,c):e}if(n=Ve(e.e/T),u=Ve(p.e/T),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/T),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=qe-1;--l[i],l[r]+=qe}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=it(l,n),w?D(e,s,c):e):new m(c===3?-0:0)},E.modulo=E.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?D(new r(n),r.precision,r.rounding):(w=!1,r.modulo==9?(t=nt(n,e.abs(),0,3,1),t.s*=e.s):t=nt(n,e,0,r.modulo,1),t=t.times(e),w=!0,n.minus(t))},E.naturalExponential=E.exp=function(){return ft(this)},E.naturalLogarithm=E.ln=function(){return pt(this)},E.negated=E.neg=function(){var e=new this.constructor(this);return e.s=-e.s,D(e)},E.plus=E.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),w?D(e,s,c):e;if(a=Ve(d.e/T),r=Ve(e.e/T),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/T),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/qe|0,l[i]%=qe;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=it(l,r),w?D(e,s,c):e},E.precision=E.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Le+e);return n.d?(t=st(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},E.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},E.sine=E.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+T,r.rounding=1,n=_t(r,bt(r,n)),r.precision=e,r.rounding=t,D(Fe>2?n.neg():n,e,t,!0)):new r(NaN)},E.squareRoot=E.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(w=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Ze(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=Ve((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(nt(o,a,n+2,1)).times(.5),Ze(a.d).slice(0,n)===(t=Ze(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(D(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(D(r,c+1,1),e=!r.times(r).eq(o));break}return w=!0,D(r,c,u.rounding,e)},E.tangent=E.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=nt(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,D(Fe==2||Fe==4?n.neg():n,e,t,!0)):new r(NaN)},E.times=E.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=Ve(u.e/T)+Ve(e.e/T),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%qe|0,t=s/qe|0;a[i]=(a[i]+t)%qe|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=it(a,n),w?D(e,d.precision,d.rounding):e},E.toBinary=function(e,t){return xt(this,2,e,t)},E.toDecimalPlaces=E.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Qe(e,0,ke),t===void 0?t=r.rounding:Qe(t,0,8),D(n,e+n.e+1,t))},E.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rt(r,!0):(Qe(e,0,ke),t===void 0?t=i.rounding:Qe(t,0,8),r=D(new i(r),e+1,t),n=rt(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},E.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=rt(i):(Qe(e,0,ke),t===void 0?t=a.rounding:Qe(t,0,8),r=D(new a(i),e+i.e+1,t),n=rt(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},E.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=st(m)-p.e-1,o=a%T,t.d[0]=He(10,o<0?T+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Le+s);e=s.gt(t)?a>0?t:l:s}for(w=!1,s=new h(Ze(m)),u=h.precision,h.precision=a=m.length*T*2;d=nt(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=nt(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=nt(l,r,a,1).minus(p).abs().cmp(nt(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,w=!0,f},E.toHexadecimal=E.toHex=function(e,t){return xt(this,16,e,t)},E.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Qe(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(w=!1,n=nt(n,e,0,t,1).times(e),w=!0,D(n)):(e.s=n.s,n=e),n},E.toNumber=function(){return+this},E.toOctal=function(e,t){return xt(this,8,e,t)},E.toPower=E.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(He(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return D(s,r,a);if(t=Ve(e.e/T),t>=e.d.length-1&&(n=l<0?-l:l)<=Je)return i=lt(c,s,n,r),e.s<0?new c(1).div(i):D(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=He(+s,l),t=n==0||!isFinite(n)?Ve(l*(Math.log(`0.`+Ze(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(w=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=ft(e.times(pt(s,r+n)),r),i.d&&(i=D(i,r+5,1),$e(i.d,r,a)&&(t=r+10,i=D(ft(e.times(pt(s,t+n)),t),t+5,1),+Ze(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=D(i,r+1,0)))),i.s=o,w=!0,c.rounding=a,D(i,r,a))},E.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rt(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Qe(e,1,ke),t===void 0?t=i.rounding:Qe(t,0,8),r=D(new i(r),e,t),n=rt(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},E.toSignificantDigits=E.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Qe(e,1,ke),t===void 0?t=r.rounding:Qe(t,0,8)),D(new r(n),e,t)},E.toString=function(){var e=this,t=e.constructor,n=rt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},E.truncated=E.trunc=function(){return D(new this.constructor(this),this.e+1,1)},E.valueOf=E.toJSON=function(){var e=this,t=e.constructor,n=rt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Ze(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=T-r.length,n&&(a+=ct(n)),a+=r;o=e[t],r=o+``,n=T-r.length,n&&(a+=ct(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function Qe(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Le+e)}function $e(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=T,i=0):(i=Math.ceil((t+1)/T),t%=T),a=He(10,T-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==He(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==He(10,t-3)-1,o}function et(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=Ae.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function tt(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/yt(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=vt(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var nt=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,ee,x,te,S,ne,re,ie,ae,oe=r.constructor,se=r.s==i.s?1:-1,ce=r.d,C=i.d;if(!ce||!ce[0]||!C||!C[0])return new oe(!r.s||!i.s||(ce?C&&ce[0]==C[0]:!C)?NaN:ce&&ce[0]==0||!C?se*0:se/0);for(c?(p=1,u=r.e-i.e):(c=qe,p=T,u=Ve(r.e/p)-Ve(i.e/p)),ie=C.length,ne=ce.length,_=new oe(se),v=_.d=[],d=0;C[d]==(ce[d]||0);d++);if(C[d]>(ce[d]||0)&&u--,a==null?(x=a=oe.precision,o=oe.rounding):x=s?a+(r.e-i.e)+1:a,x<0)v.push(1),m=!0;else{if(x=x/p+2|0,d=0,ie==1){for(f=0,C=C[0],x++;(d<ne||f)&&x--;d++)te=f*c+(ce[d]||0),v[d]=te/C|0,f=te%C|0;m=f||d<ne}else{for(f=c/(C[0]+1)|0,f>1&&(C=e(C,f,c),ce=e(ce,f,c),ie=C.length,ne=ce.length),S=ie,y=ce.slice(0,ie),b=y.length;b<ie;)y[b++]=0;ae=C.slice(),ae.unshift(0),re=C[0],C[1]>=c/2&&++re;do f=0,l=t(C,y,ie,b),l<0?(ee=y[0],ie!=b&&(ee=ee*c+(y[1]||0)),f=ee/re|0,f>1?(f>=c&&(f=c-1),h=e(C,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,ie<g?ae:C,g,c))):(f==0&&(l=f=1),h=C.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(C,y,ie,b),l<1&&(f++,n(y,ie<b?ae:C,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=ce[S]||0:(y=[ce[S]],b=1);while((S++<ne||y[0]!==void 0)&&x--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Pe=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,D(_,s?a+_.e+1:a,o,m)}return _}})();function D(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=T,o=t,u=d[f=0],c=u/He(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/T),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=T,o=a-T+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=T,o=a-T+i,c=o<0?0:u/He(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%He(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/He(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=He(10,(T-t%T)%T),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=He(10,T-a),d[f]=o>0?(u/He(10,i-o)%He(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==qe&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=qe)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return w&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function rt(e,t,n){if(!e.isFinite())return mt(e);var r,i=e.e,a=Ze(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+ct(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+ct(-i-1)+a,n&&(r=n-o)>0&&(a+=ct(r))):i>=o?(a+=ct(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+ct(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=ct(r))),a}function it(e,t){var n=e[0];for(t*=T;n>=10;n/=10)t++;return t}function at(e,t,n){if(t>Ye)throw w=!0,n&&(e.precision=n),Error(Re);return D(new e(je),t,1,!0)}function ot(e,t,n){if(t>Xe)throw Error(Re);return D(new e(Me),t,n,!0)}function st(e){var t=e.length-1,n=t*T+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ct(e){for(var t=``;e--;)t+=`0`;return t}function lt(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/T+4);for(w=!1;;){if(n%2&&(a=a.times(t),St(a.d,o)&&(i=!0)),n=Ve(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),St(t.d,o)}return w=!0,a}function ut(e){return e.d[e.d.length-1]&1}function dt(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function ft(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(w=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(He(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=D(a.times(e),c,1),n=n.times(++u),s=o.plus(nt(a,n,c,1)),Ze(s.d).slice(0,c)===Ze(o.d).slice(0,c)){for(i=d;i--;)o=D(o.times(o),c,1);if(t==null)if(l<3&&$e(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return D(o,f.precision=m,p,w=!0);else return f.precision=m,o}o=s}}function pt(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(w=!1,u=y):u=t,_.precision=u+=m,n=Ze(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Ze(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=at(_,u+2,y).times(a+``),h=pt(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?D(h,y,v,w=!0):h;for(d=h,c=o=h=nt(h.minus(1),h.plus(1),u,1),f=D(h.times(h),u,1),i=3;;){if(o=D(o.times(f),u,1),l=c.plus(nt(o,new _(i),u,1)),Ze(l.d).slice(0,u)===Ze(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(at(_,u+2,y).times(a+``))),c=nt(c,new _(p),u,1),t==null)if($e(c.d,u-m,v,s))_.precision=u+=m,l=o=h=nt(d.minus(1),d.plus(1),u,1),f=D(h.times(h),u,1),i=s=1;else return D(c,_.precision=y,v,w=!0);else return _.precision=y,c;c=l,i+=2}}function mt(e){return String(e.s*e.s/0)}function ht(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%T,n<0&&(r+=T),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=T;r<i;)e.d.push(+t.slice(r,r+=T));t=t.slice(r),r=T-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),w&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function gt(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),Ke.test(t))return ht(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(We.test(t))n=16,t=t.toLowerCase();else if(Ue.test(t))n=2;else if(Ge.test(t))n=8;else throw Error(Le+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=lt(r,new r(n),a,a*2)),l=et(t,n,qe),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=it(l,u),e.d=l,w=!1,o&&(e=nt(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?He(2,c):dn.pow(2,c))),w=!0,e)}function _t(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:vt(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/yt(5,n)),t=vt(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function vt(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/T);for(w=!1,c=n.times(n),s=new e(r);;){if(o=nt(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=nt(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return w=!0,o.d.length=d+1,o}function yt(e,t){for(var n=e;--t;)n*=e;return n}function bt(e,t){var n,r=t.s<0,i=ot(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Fe=r?4:1,t;if(n=t.divToInt(i),n.isZero())Fe=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Fe=ut(n)?r?2:3:r?4:1,t;Fe=ut(n)?r?1:4:r?3:2}return t.minus(i).abs()}function xt(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(Qe(n,1,ke),r===void 0?r=p.rounding:Qe(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=mt(e);else{for(u=rt(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=et(rt(f),10,i),f.e=f.d.length),d=et(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=nt(e,f,n,r,0,i),d=e.d,a=e.e,l=Pe),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=Ae.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=et(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=Ae.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function St(e,t){if(e.length>t)return e.length=t,!0}function Ct(e){return new this(e).abs()}function wt(e){return new this(e).acos()}function Tt(e){return new this(e).acosh()}function Et(e,t){return new this(e).plus(t)}function Dt(e){return new this(e).asin()}function Ot(e){return new this(e).asinh()}function kt(e){return new this(e).atan()}function At(e){return new this(e).atanh()}function jt(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=ot(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?ot(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=ot(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(nt(e,t,a,1)),t=ot(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(nt(e,t,a,1)),n}function Mt(e){return new this(e).cbrt()}function Nt(e){return D(e=new this(e),e.e+1,2)}function Pt(e,t,n){return new this(e).clamp(t,n)}function Ft(e){if(!e||typeof e!=`object`)throw Error(Ie+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,ke,`rounding`,0,8,`toExpNeg`,-Oe,0,`toExpPos`,0,Oe,`maxE`,0,Oe,`minE`,-Oe,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Ne[n]),(r=e[n])!==void 0)if(Ve(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Le+n+`: `+r);if(n=`crypto`,i&&(this[n]=Ne[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(ze);else this[n]=!1;else throw Error(Le+n+`: `+r);return this}function It(e){return new this(e).cos()}function Lt(e){return new this(e).cosh()}function Rt(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,Ut(e)){a.s=e.s,w?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;w?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return ht(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),Ke.test(e)?ht(a,e):gt(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,ht(a,e.toString());throw Error(Le+e)}if(i.prototype=E,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Ft,i.clone=Rt,i.isDecimal=Ut,i.abs=Ct,i.acos=wt,i.acosh=Tt,i.add=Et,i.asin=Dt,i.asinh=Ot,i.atan=kt,i.atanh=At,i.atan2=jt,i.cbrt=Mt,i.ceil=Nt,i.clamp=Pt,i.cos=It,i.cosh=Lt,i.div=zt,i.exp=Bt,i.floor=Vt,i.hypot=Ht,i.ln=Wt,i.log=Gt,i.log10=qt,i.log2=Kt,i.max=Jt,i.min=Yt,i.mod=Xt,i.mul=Zt,i.pow=Qt,i.random=$t,i.round=en,i.sign=tn,i.sin=nn,i.sinh=rn,i.sqrt=an,i.sub=on,i.sum=sn,i.tan=cn,i.tanh=ln,i.trunc=un,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function zt(e,t){return new this(e).div(t)}function Bt(e){return new this(e).exp()}function Vt(e){return D(e=new this(e),e.e+1,3)}function Ht(){var e,t,n=new this(0);for(w=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return w=!0,new this(1/0);n=t}return w=!0,n.sqrt()}function Ut(e){return e instanceof dn||e&&e.toStringTag===Be||!1}function Wt(e){return new this(e).ln()}function Gt(e,t){return new this(e).log(t)}function Kt(e){return new this(e).log(2)}function qt(e){return new this(e).log(10)}function Jt(){return dt(this,arguments,-1)}function Yt(){return dt(this,arguments,1)}function Xt(e,t){return new this(e).mod(t)}function Zt(e,t){return new this(e).mul(t)}function Qt(e,t){return new this(e).pow(t)}function $t(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:Qe(e,1,ke),r=Math.ceil(e/T),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(ze);for(r=s[--a],e%=T,r&&e&&(i=He(10,T-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=T)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<T&&(n-=T-r)}return o.e=n,o.d=s,o}function en(e){return D(e=new this(e),e.e+1,this.rounding)}function tn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function nn(e){return new this(e).sin()}function rn(e){return new this(e).sinh()}function an(e){return new this(e).sqrt()}function on(e,t){return new this(e).sub(t)}function sn(){var e=0,t=arguments,n=new this(t[e]);for(w=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return w=!0,D(n,this.precision,this.rounding)}function cn(e){return new this(e).tan()}function ln(e){return new this(e).tanh()}function un(e){return D(e=new this(e),e.e+1,1)}E[Symbol.for(`nodejs.util.inspect.custom`)]=E.toString,E[Symbol.toStringTag]=`Decimal`;var dn=E.constructor=Rt(Ne);je=new dn(je),Me=new dn(Me);var fn;(function(e){e[e.TOKEN=1e5]=`TOKEN`,e[e.DECI_TOKEN=1e4]=`DECI_TOKEN`,e[e.CENTI_TOKEN=1e3]=`CENTI_TOKEN`,e[e.MILLI_TOKEN=100]=`MILLI_TOKEN`,e[e.MICRO_TOKEN=10]=`MICRO_TOKEN`,e[e.ATOMIC=1]=`ATOMIC`})(fn||={});var pn;(function(e){e.TOKEN=`CMTS`,e.DECI_TOKEN=`dCMTS`,e.CENTI_TOKEN=`cCMTS`,e.MILLI_TOKEN=`mCMTS`,e.MICRO_TOKEN=`μCMTS`,e.ATOMIC=`aCMTS`})(pn||={});var mn=class e{amount;constructor(e){this.amount=e}static create(e,t=fn.TOKEN){if(t!=fn.TOKEN)throw new y;return this.createCMTS(e)}static createCMTS(e){return this.createSafeCmtsToken(dn(e),dn(fn.TOKEN))}static createDeciToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.DECI_TOKEN))}static createMicroToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MICRO_TOKEN))}static createMilliToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MILLI_TOKEN))}static createCentiToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.CENTI_TOKEN))}static createMillionToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MICRO_TOKEN))}static createAtomic(e){return this.createSafeCmtsToken(dn(e),dn(fn.ATOMIC))}static createSafeCmtsToken(t,n){let r=t.mul(n);if(r.isInteger())return new e(r);throw new v(`Invalid amount: An atomic token should be insecable: got ${r}`)}static zero(){return this.createAtomic(0)}static oneCMTS(){return this.createCMTS(1)}static parse(t){let n=t.trim().match(/^(\d+(?:\.\d+)?)\s*(\S+)$/);if(!n)throw new v(`Invalid token amount format: "${t}"`);let[,r,i]=n,a=parseFloat(r);switch(i){case pn.TOKEN:return e.createCMTS(a);case pn.DECI_TOKEN:return e.createDeciToken(a);case pn.CENTI_TOKEN:return e.createCentiToken(a);case pn.MILLI_TOKEN:return e.createMilliToken(a);case pn.MICRO_TOKEN:return e.createMicroToken(a);case pn.ATOMIC:return e.createAtomic(a);default:throw new y}}getAmount(e=fn.TOKEN){switch(e){case fn.TOKEN:return this.amount.div(dn(fn.TOKEN)).toNumber();case fn.CENTI_TOKEN:return this.amount.div(dn(fn.CENTI_TOKEN)).toNumber();case fn.MILLI_TOKEN:return this.amount.div(dn(fn.MILLI_TOKEN)).toNumber();case fn.DECI_TOKEN:return this.amount.div(dn(fn.DECI_TOKEN)).toNumber();case fn.MICRO_TOKEN:return this.amount.div(dn(fn.MICRO_TOKEN)).toNumber();case fn.ATOMIC:return this.amount.toNumber()}}getAmountAsAtomic(){return this.getAmount(fn.ATOMIC)}getAmountAsCMTS(){return this.getAmount(fn.TOKEN)}isPositive(){return this.amount.isPositive()||this.amount.isZero()}isPositiveStrict(){return this.isPositive()&&!this.isZero()}isNegative(){return this.amount.isNegative()}isZero(){return this.amount.isZero()}equals(e){return this.amount.equals(e.amount)}isGreaterThan(e){return this.amount.gt(e.amount)}isLessThan(e){return this.amount.lt(e.amount)}add(t){return e.createAtomic(this.getAmountAsAtomic()+t.getAmountAsAtomic())}sub(t){return e.createAtomic(this.getAmountAsAtomic()-t.getAmountAsAtomic())}toString(t=fn.TOKEN){switch(t){case fn.TOKEN:return`${this.getAmountAsCMTS()} ${e.getUnitLabel(t)}`;case fn.ATOMIC:return`${this.getAmountAsAtomic()} ${e.getUnitLabel(t)}`;default:throw new y}}static getUnitLabel(e){switch(e){case fn.TOKEN:return pn.TOKEN;case fn.ATOMIC:return pn.ATOMIC;default:throw new y}}},hn=t({FORMAT:()=>28,HASHABLE:()=>1,HASHED:()=>8,MASKABLE:()=>2,MASKED:()=>16,PROPERTIES:()=>3,REDACTED:()=>4,TYPE_ARRAY:()=>1,TYPE_ARRAY_OF:()=>32,TYPE_BIN256:()=>13,TYPE_BINARY:()=>12,TYPE_BOOLEAN:()=>5,TYPE_HASH_STR:()=>14,TYPE_MAIN:()=>31,TYPE_NAMES:()=>Nn,TYPE_NULL:()=>6,TYPE_NUMBER:()=>4,TYPE_OBJECT:()=>2,TYPE_STRING:()=>3,TYPE_UINT16:()=>8,TYPE_UINT24:()=>9,TYPE_UINT32:()=>10,TYPE_UINT48:()=>11,TYPE_UINT8:()=>7,TYPE_UNKNOWN:()=>0}),gn=0,_n=1,vn=2,yn=3,bn=4,xn=5,Sn=6,Cn=7,wn=8,Tn=9,En=10,Dn=11,On=12,kn=13,An=14,jn=31,Mn=32,Nn=[`unknown`,`array`,`object`,`string`,`number`,`boolean`,`null`,`uint8`,`uint16`,`uint24`,`uint32`,`uint48`,`binary`,`bin256`,`hashString`],Pn=1,Fn=2,In=3,Ln=4,Rn=8,zn=16,Bn=28,Vn=t({MAGIC_STRING:()=>Hn,MAX_MICROBLOCK_FUTURE_DELAY:()=>120,MAX_MICROBLOCK_PAST_DELAY:()=>300,MB_STATUS_PREVIOUS_HASH_ERROR:()=>3,MB_STATUS_TIMESTAMP_ERROR:()=>2,MB_STATUS_UNRECOVERABLE_ERROR:()=>1,N_VIRTUAL_BLOCKCHAINS:()=>6,PROTOCOL_VERSION:()=>1,VB_ACCOUNT:()=>1,VB_APPLICATION:()=>4,VB_APP_LEDGER:()=>5,VB_NAME:()=>Zn,VB_ORGANIZATION:()=>3,VB_PROTOCOL:()=>0,VB_VALIDATOR_NODE:()=>2}),Hn=`CMTS`,Un=1,Wn=0,Gn=1,Kn=2,qn=3,Jn=4,Yn=5,Xn=6,Zn=[`protocol`,`account`,`validator node`,`organization`,`application`,`application ledger`],Qn=300,$n=120,er=1,tr=2,nr=3,rr=t({ACCOUNT_ALLOWED_TRANSFERS:()=>Wr,ACCOUNT_BLOCK_FEES:()=>2,ACCOUNT_BURNT_TOKENS:()=>0,ACCOUNT_NAMES:()=>Ur,ACCOUNT_STANDARD:()=>1,BK_EARNED_BLOCK_FEES:()=>3,BK_EARNED_TX_FEES:()=>1,BK_NAMES:()=>zr,BK_PAID_BLOCK_FEES:()=>2,BK_PAID_TX_FEES:()=>0,BK_PLUS:()=>1,BK_PURCHASE:()=>7,BK_RECEIVED_ESCROW:()=>13,BK_RECEIVED_ESCROW_REFUND:()=>15,BK_RECEIVED_EXPIRED_ESCROW:()=>17,BK_RECEIVED_ISSUANCE:()=>5,BK_RECEIVED_PAYMENT:()=>9,BK_RECEIVED_SLASHED_TOKENS:()=>19,BK_RECEIVED_VESTING:()=>11,BK_REFERENCES:()=>Rr,BK_REF_BLOCK:()=>0,BK_REF_MICROBLOCK:()=>1,BK_REF_SECTION:()=>2,BK_SALE:()=>6,BK_SENT_ESCROW:()=>12,BK_SENT_ESCROW_REFUND:()=>14,BK_SENT_EXPIRED_ESCROW:()=>16,BK_SENT_ISSUANCE:()=>4,BK_SENT_PAYMENT:()=>8,BK_SENT_SLASHED_TOKENS:()=>18,BK_SENT_VESTING:()=>10,CENTITOKEN:()=>or,FIXED_GAS_FEE:()=>dr,GAS_PER_BYTE:()=>1,GAS_UNIT:()=>pr,INITIAL_OFFER:()=>cr,MAXIMUM_GAS_PRICE:()=>ur,MILLITOKEN:()=>100,MINIMUM_GAS_PRICE:()=>1,TOKEN:()=>ar,TOKEN_NAME:()=>ir}),ir=`CMTS`,ar=1e5,or=1e3,sr=100,cr=1e9*ar,lr=1,ur=2**29-1,dr=1e3,fr=1,pr=1e3,mr=1,hr=0,gr=2,_r=4,vr=6,yr=8,br=10,xr=12,Sr=14,Cr=16,wr=18,Tr=1,Er=3,Dr=5,Or=7,kr=9,Ar=11,jr=13,Mr=15,Nr=17,Pr=19,Fr=0,Ir=1,Lr=2,Rr=[1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],zr=[`Paid TX fees`,`Earned TX fees`,`Paid block fees`,`Earned block fees`,`Sent initial token issuance`,`Received initial token issuance`,`Sale`,`Purchase`,`Sent payment`,`Received payment`,`Sent vesting`,`Received vesting`,`Sent escrow`,`Received escrow`,`Sent escrow refund`,`Received escrow refund`,`Sent expired escrow`,`Received expired escrow`,`Sent slashed tokens`,`Received slashed tokens`],Br=0,Vr=1,Hr=2,Ur=[`Burnt tokens account`,`Standard account`,`Block fees account`],Wr=[524800,524265,6],Gr=t({ACCOUNT_HISTORY:()=>ii,ACCOUNT_STATE:()=>ri,ALL_SCHEMAS:()=>aa,BLOCK_CONTENT:()=>ui,BLOCK_INFORMATION:()=>li,CONTRACT_PARAMETER_SCHEMA:()=>qr,CONTRACT_SCHEMA:()=>Jr,ERROR:()=>Kr,MICROBLOCK_BODY:()=>gi,MICROBLOCK_HEADER:()=>mi,MICROBLOCK_HEADER_BODY_HASH_OFFSET:()=>58,MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET:()=>13,MICROBLOCK_HEADER_SIZE:()=>122,MICROBLOCK_SECTION:()=>hi,MICROBLOCK_VB_INFORMATION:()=>_i,MSG_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>22,MSG_ACCOUNT_HISTORY:()=>20,MSG_ACCOUNT_STATE:()=>18,MSG_AWAIT_MICROBLOCK_ANCHORING:()=>13,MSG_BLOCK_CONTENT:()=>6,MSG_BLOCK_INFORMATION:()=>4,MSG_CHAIN_INFORMATION:()=>2,MSG_ERROR:()=>0,MSG_GENESIS_SNAPSHOT:()=>28,MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>21,MSG_GET_ACCOUNT_HISTORY:()=>19,MSG_GET_ACCOUNT_STATE:()=>17,MSG_GET_BLOCK_CONTENT:()=>5,MSG_GET_BLOCK_INFORMATION:()=>3,MSG_GET_CHAIN_INFORMATION:()=>1,MSG_GET_GENESIS_SNAPSHOT:()=>27,MSG_GET_MICROBLOCK_BODYS:()=>15,MSG_GET_MICROBLOCK_INFORMATION:()=>11,MSG_GET_OBJECT_LIST:()=>25,MSG_GET_VALIDATOR_NODE_BY_ADDRESS:()=>23,MSG_GET_VIRTUAL_BLOCKCHAIN_STATE:()=>7,MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE:()=>9,MSG_MICROBLOCK_ANCHORING:()=>14,MSG_MICROBLOCK_BODYS:()=>16,MSG_MICROBLOCK_INFORMATION:()=>12,MSG_OBJECT_LIST:()=>26,MSG_VALIDATOR_NODE_BY_ADDRESS:()=>24,MSG_VIRTUAL_BLOCKCHAIN_STATE:()=>8,MSG_VIRTUAL_BLOCKCHAIN_UPDATE:()=>10,NODE_MESSAGES:()=>qi,PROTOCOL_VARIABLES:()=>oi,PROTOCOL_VB_STATE:()=>si,RECORD_DESCRIPTION:()=>ni,VB_STATES:()=>ci,VIRTUAL_BLOCKCHAIN_STATE:()=>ai,WIMSG_ANSWER:()=>5,WIMSG_CONNECTION_ACCEPTED:()=>7,WIMSG_CONNECTION_INFO:()=>6,WIMSG_CONNECTION_TOKEN:()=>2,WIMSG_FORWARDED_ANSWER:()=>3,WIMSG_FORWARDED_REQUEST:()=>8,WIMSG_GET_CONNECTION_INFO:()=>4,WIMSG_REQUEST:()=>0,WIMSG_UPDATE_QR:()=>1,WI_MESSAGES:()=>ia,WI_QR_CODE:()=>Ji}),Kr={label:`Error`,definition:[{name:`type`,type:7},{name:`id`,type:7},{name:`arg`,type:35}]},qr={label:`contractParameter`,definition:[{name:`name`,type:3},{name:`type`,type:3},{name:`defaultValue`,type:3},{name:`modifiable`,type:5}]},Jr={label:`contract`,definition:[{name:`name`,type:3},{name:`parametersDefinition`,type:34,schema:qr}]},Yr={label:`RecordActor`,definition:[{name:`name`,type:3}]},Xr={label:`RecordChannel`,definition:[{name:`name`,type:3},{name:`public`,type:5}]},Zr={label:`RecordChannelAssignation`,definition:[{name:`fieldPath`,type:3},{name:`channelName`,type:3}]},Qr={label:`RecordActorAssignation`,definition:[{name:`actorName`,type:3},{name:`channelName`,type:3}]},$r={label:`RecordMaskedPart`,definition:[{name:`position`,type:10},{name:`length`,type:10},{name:`replacementString`,type:3}]},ei={label:`RecordMaskableField`,definition:[{name:`fieldPath`,type:3},{name:`maskedParts`,type:34,schema:$r}]},ti={label:`RecordHashableField`,definition:[{name:`fieldPath`,type:3}]},ni={label:`RecordDescription`,definition:[{name:`applicationId`,type:14},{name:`virtualBlockchainId`,type:14,optional:!0},{name:`data`,type:2,unspecifiedSchema:!0},{name:`actors`,type:34,optional:!0,schema:Yr},{name:`channels`,type:34,optional:!0,schema:Xr},{name:`channelAssignations`,type:34,optional:!0,schema:Zr},{name:`actorAssignations`,type:34,optional:!0,schema:Qr},{name:`hashableFields`,type:34,optional:!0,schema:ti},{name:`maskableFields`,type:34,optional:!0,schema:ei},{name:`author`,type:3},{name:`endorser`,type:3,optional:!0},{name:`approvalMessage`,type:3,optional:!0}]},ri={label:`AccountState`,definition:[{name:`height`,type:11},{name:`balance`,type:11},{name:`lastHistoryHash`,type:13},{name:`locks`,type:34,definition:[{name:`type`,type:7},{name:`amount`,type:11},{name:`parameters`,type:12}]}]},ii={label:`AccountHistory`,definition:[{name:`height`,type:11},{name:`previousHistoryHash`,type:13},{name:`type`,type:7},{name:`timestamp`,type:11},{name:`linkedAccount`,type:13},{name:`amount`,type:11},{name:`chainReference`,type:12}]},ai={label:`VirtualBlockchainState`,definition:[{name:`type`,type:7},{name:`expirationDay`,type:10},{name:`height`,type:11},{name:`lastMicroblockHash`,type:13},{name:`serializedInternalState`,type:12}]},oi={label:`PROTOCOL_VARIABLES`,definition:[{name:`protocolVersionName`,type:3},{name:`protocolVersion`,type:8},{name:`feesCalculationVersion`,type:8},{name:`globalStateUpdaterVersion`,type:8},{name:`applicationLedgerInternalStateUpdaterVersion`,type:8},{name:`applicationInternalStateUpdaterVersion`,type:8},{name:`organizationInternalStateUpdaterVersion`,type:8},{name:`validatorNodeInternalStateUpdaterVersion`,type:8},{name:`accountInternalStateUpdaterVersion`,type:8},{name:`protocolInternalStateUpdaterVersion`,type:8}]},si={label:`ProtocolVbState`,definition:[{name:`organizationId`,type:13},{name:`currentProtocolVariables`,type:2,schema:oi},{name:`protocolUpdates`,type:34,schema:{label:`PROTOCOL_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi},{name:`protocolVersionName`,type:3}]}}]},ci=[si,{label:`AccountVbState`,definition:[{name:`signatureSchemeId`,type:7},{name:`publicKeyHeight`,type:11}]},{label:`ValidatorNodeVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11},{name:`rpcEndpointHeight`,type:11},{name:`networkIntegrationHeight`,type:11}]},{label:`OrganizationVbState`,definition:[{name:`accountId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`ApplicationVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`AppLedgerVbState`,definition:[{name:`allowedSignatureSchemeIds`,type:39},{name:`allowedPkeSchemeIds`,type:39},{name:`applicationId`,type:13},{name:`channels`,type:34,definition:[{name:`name`,type:3},{name:`isPrivate`,type:5},{name:`creatorId`,type:7}]},{name:`actors`,type:34,definition:[{name:`name`,type:3},{name:`subscribed`,type:5},{name:`signatureKeyHeight`,type:11},{name:`pkeKeyHeight`,type:11},{name:`sharedSecrets`,type:34,definition:[{name:`peerActorId`,type:7},{name:`height`,type:11}]},{name:`invitations`,type:34,definition:[{name:`channelId`,type:7},{name:`height`,type:11}]}]}]}],li={label:`BlockInformation`,definition:[{name:`hash`,type:13},{name:`timestamp`,type:11},{name:`proposerAddress`,type:12},{name:`size`,type:11},{name:`microblockCount`,type:11}]},ui={label:`BlockContent`,definition:[{name:`microblocks`,type:34,definition:[{name:`hash`,type:13},{name:`vbIdentifier`,type:13},{name:`vbType`,type:7},{name:`height`,type:11},{name:`size`,type:11},{name:`sectionCount`,type:11}]}]},di=13,fi=58,pi=122,mi={label:`MicroblockHeader`,definition:[{name:`magicString`,type:3,size:4},{name:`protocolVersion`,type:8},{name:`microblockType`,type:7},{name:`height`,type:11},{name:`previousHash`,type:13},{name:`timestamp`,type:11},{name:`gas`,type:9},{name:`gasPrice`,type:10},{name:`bodyHash`,type:13},{name:`feesPayerAccount`,type:13}]},hi={label:`MicroblockSection`,definition:[{name:`type`,type:7},{name:`data`,type:12}]},gi={label:`MicroblockBody`,definition:[{name:`body`,type:34,schema:hi}]},_i={label:`MicroblockVbInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13}]},vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=6,Ti=7,Ei=8,Di=9,Oi=10,ki=11,Ai=12,ji=13,Mi=14,Ni=15,Pi=16,Fi=17,Ii=18,Li=19,Ri=20,zi=21,Bi=22,Vi=23,Hi=24,Ui=25,Wi=26,Gi=27,Ki=28,qi=[];qi[0]={label:`MessageError`,definition:[{name:`error`,type:3}]},qi[1]={label:`MessageGetChainInformation`,definition:[]},qi[2]={label:`MessageChainInformation`,definition:[{name:`height`,type:11},{name:`lastBlockTimestamp`,type:11},{name:`microblockCount`,type:11},{name:`objectCounts`,type:43,size:6}]},qi[3]={label:`MessageGetBlockInformation`,definition:[{name:`height`,type:11}]},qi[4]={label:`MessageBlockInformation`,definition:li.definition},qi[5]={label:`MessageGetBlockContent`,definition:[{name:`height`,type:11}]},qi[6]={label:`MessageBlockContent`,definition:ui.definition},qi[7]={label:`MessageGetVirtualBlockchainState`,definition:[{name:`virtualBlockchainId`,type:13}]},qi[8]={label:`MessageVirtualBlockchainState`,definition:[{name:`stateData`,type:12}]},qi[9]={label:`MessageGetVirtualBlockchainUpdate`,definition:[{name:`virtualBlockchainId`,type:13},{name:`knownHeight`,type:11}]},qi[10]={label:`MessageVirtualBlockchainUpdate`,definition:[{name:`exists`,type:5},{name:`changed`,type:5},{name:`stateData`,type:12},{name:`headers`,type:44}]},qi[11]={label:`MessageGetMicroblockInformation`,definition:[{name:`hash`,type:13}]},qi[12]={label:`MessageMicroblockInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13},{name:`header`,type:12}]},qi[13]={label:`MessageAwaitMicroblockAnchoring`,definition:[{name:`hash`,type:13}]},qi[14]={label:`MessageMicroblockAnchoring`,definition:_i.definition},qi[15]={label:`MessageGetMicroblockBodys`,definition:[{name:`hashes`,type:45}]},qi[16]={label:`MessageMicroblockBodys`,definition:[{name:`list`,type:34,definition:[{name:`hash`,type:13},{name:`body`,type:12}]}]},qi[17]={label:`MessageGetAccountState`,definition:[{name:`accountHash`,type:13}]},qi[18]={label:`MessageAccountState`,definition:ri.definition},qi[19]={label:`MessageGetAccountHistory`,definition:[{name:`accountHash`,type:13},{name:`lastHistoryHash`,type:13},{name:`maxRecords`,type:8}]},qi[20]={label:`MessageAccountHistory`,definition:[{name:`list`,type:34,schema:ii}]},qi[21]={label:`MessageGetAccountByPublicKeyHash`,definition:[{name:`publicKeyHash`,type:13}]},qi[22]={label:`MessageAccountByPublicKeyHash`,definition:[{name:`accountHash`,type:13}]},qi[23]={label:`MessageGetValidatorNodeByAddress`,definition:[{name:`address`,type:12}]},qi[24]={label:`MessageValidatorNodeByAddress`,definition:[{name:`validatorNodeHash`,type:13}]},qi[25]={label:`MessageGetObjectList`,definition:[{name:`type`,type:7}]},qi[26]={label:`MessageObjectList`,definition:[{name:`list`,type:45}]},qi[27]={label:`MessageGetGenesisSnapshot`,definition:[]},qi[28]={label:`MessageGenesisSnapshot`,definition:[{name:`base64EncodedChunks`,type:35}]};var Ji={label:`WiQrCode`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11},{name:`serverUrl`,type:3,size:100}]},Yi=0,Xi=1,Zi=2,Qi=3,$i=4,ea=5,ta=6,na=7,ra=8,ia=[];ia[0]={label:`WiMsgRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12},{name:`deviceId`,type:13},{name:`withToken`,type:7}]},ia[1]={label:`WiMsgUpdateQr`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11}]},ia[2]={label:`WiMsgConnectionToken`,definition:[{name:`token`,type:13}]},ia[3]={label:`WiMsgForwardedAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ia[4]={label:`WiMsgGetConnectionInfo`,definition:[{name:`qrId`,type:13}]},ia[5]={label:`WiMsgAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ia[6]={label:`WiMsgConnectionInfo`,definition:[]},ia[7]={label:`WiMsgConnectionAccepted`,definition:[{name:`qrId`,type:13}]},ia[8]={label:`WiMsgForwardedRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12}]};var aa={singles:[Yr,Xr,Zr,Qr,$r,ei,ti,ni,mi,hi,gi,_i,Ji],collections:[{label:`VbState`,list:ci},{label:`NodeMessage`,list:qi},{label:`WiMessage`,list:ia}]},O;(function(e){e[e.SIGNATURE=127]=`SIGNATURE`,e[e.ALLOWED_ADDITIONAL_WRITER=128]=`ALLOWED_ADDITIONAL_WRITER`,e[e.CUSTOM=129]=`CUSTOM`,e[e.PROTOCOL_CREATION=1]=`PROTOCOL_CREATION`,e[e.PROTOCOL_UPDATE=2]=`PROTOCOL_UPDATE`,e[e.PROTOCOL_VARIABLES=5]=`PROTOCOL_VARIABLES`,e[e.ACCOUNT_PUBLIC_KEY=17]=`ACCOUNT_PUBLIC_KEY`,e[e.ACCOUNT_TOKEN_ISSUANCE=18]=`ACCOUNT_TOKEN_ISSUANCE`,e[e.ACCOUNT_CREATION=19]=`ACCOUNT_CREATION`,e[e.ACCOUNT_TRANSFER=20]=`ACCOUNT_TRANSFER`,e[e.ACCOUNT_VESTING_TRANSFER=21]=`ACCOUNT_VESTING_TRANSFER`,e[e.ACCOUNT_ESCROW_TRANSFER=22]=`ACCOUNT_ESCROW_TRANSFER`,e[e.ACCOUNT_ESCROW_SETTLEMENT=23]=`ACCOUNT_ESCROW_SETTLEMENT`,e[e.ACCOUNT_STAKE=24]=`ACCOUNT_STAKE`,e[e.ACCOUNT_UNSTAKE=25]=`ACCOUNT_UNSTAKE`,e[e.VN_CREATION=33]=`VN_CREATION`,e[e.VN_COMETBFT_PUBLIC_KEY_DECLARATION=34]=`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,e[e.VN_RPC_ENDPOINT=35]=`VN_RPC_ENDPOINT`,e[e.VN_APPROVAL=36]=`VN_APPROVAL`,e[e.VN_SLASHING_CANCELLATION=37]=`VN_SLASHING_CANCELLATION`,e[e.ORG_CREATION=52]=`ORG_CREATION`,e[e.ORG_DESCRIPTION=50]=`ORG_DESCRIPTION`,e[e.APP_CREATION=65]=`APP_CREATION`,e[e.APP_DESCRIPTION=66]=`APP_DESCRIPTION`,e[e.APP_LEDGER_ALLOWED_SIG_SCHEMES=80]=`APP_LEDGER_ALLOWED_SIG_SCHEMES`,e[e.APP_LEDGER_ALLOWED_PKE_SCHEMES=81]=`APP_LEDGER_ALLOWED_PKE_SCHEMES`,e[e.APP_LEDGER_CREATION=82]=`APP_LEDGER_CREATION`,e[e.APP_LEDGER_ACTOR_CREATION=83]=`APP_LEDGER_ACTOR_CREATION`,e[e.APP_LEDGER_CHANNEL_CREATION=84]=`APP_LEDGER_CHANNEL_CREATION`,e[e.APP_LEDGER_SHARED_SECRET=85]=`APP_LEDGER_SHARED_SECRET`,e[e.APP_LEDGER_CHANNEL_INVITATION=86]=`APP_LEDGER_CHANNEL_INVITATION`,e[e.APP_LEDGER_ACTOR_SUBSCRIPTION=87]=`APP_LEDGER_ACTOR_SUBSCRIPTION`,e[e.APP_LEDGER_PUBLIC_CHANNEL_DATA=88]=`APP_LEDGER_PUBLIC_CHANNEL_DATA`,e[e.APP_LEDGER_PRIVATE_CHANNEL_DATA=89]=`APP_LEDGER_PRIVATE_CHANNEL_DATA`,e[e.APP_LEDGER_AUTHOR=90]=`APP_LEDGER_AUTHOR`,e[e.APP_LEDGER_ENDORSEMENT_REQUEST=91]=`APP_LEDGER_ENDORSEMENT_REQUEST`})(O||={});var oa=t({ACCOUNT_CREATION:()=>ma,ACCOUNT_ESCROW_SETTLEMENT:()=>va,ACCOUNT_ESCROW_TRANSFER:()=>_a,ACCOUNT_PUBLIC_KEY:()=>fa,ACCOUNT_STAKE:()=>ya,ACCOUNT_TOKEN_ISSUANCE:()=>pa,ACCOUNT_TRANSFER:()=>ha,ACCOUNT_VESTING_TRANSFER:()=>ga,ALL_SECTIONS_SCHEMAS:()=>Ga,APP_CREATION:()=>ka,APP_DESCRIPTION:()=>Aa,APP_LEDGER_ACTOR_CREATION:()=>Fa,APP_LEDGER_ACTOR_SUBSCRIPTION:()=>za,APP_LEDGER_ALLOWED_PKE_SCHEMES:()=>Na,APP_LEDGER_ALLOWED_SIG_SCHEMES:()=>Ma,APP_LEDGER_AUTHOR:()=>Ha,APP_LEDGER_CHANNEL_CREATION:()=>Ia,APP_LEDGER_CHANNEL_INVITATION:()=>Ra,APP_LEDGER_CREATION:()=>Pa,APP_LEDGER_ENDORSEMENT_REQUEST:()=>Ua,APP_LEDGER_PRIVATE_CHANNEL_DATA:()=>Va,APP_LEDGER_PUBLIC_CHANNEL_DATA:()=>Ba,APP_LEDGER_SHARED_SECRET:()=>La,DEF:()=>Ka,ORG_CREATION:()=>Ea,ORG_DESCRIPTION:()=>Da,PROTOCOL_CREATION:()=>la,PROTOCOL_UPDATE:()=>ua,SIGNATURE:()=>sa,SIGNATURE_SCHEMA:()=>ca,VN_APPROVAL:()=>wa,VN_COMETBFT_PUBLIC_KEY_DECLARATION:()=>Sa,VN_CREATION:()=>xa,VN_RPC_ENDPOINT:()=>Ca}),sa=O.SIGNATURE,ca={label:`SIGNATURE`,definition:[{name:`schemeId`,type:7},{name:`signature`,type:12}]},la=O.PROTOCOL_CREATION,ua=O.PROTOCOL_UPDATE,da=[];da[la]={label:`PROTOCOL_CREATION`,definition:[{name:`organizationId`,type:13}]},da[ua]={label:`PROTOCOL_VARIABLES_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`protocolVersionName`,type:3},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi}]};var fa=O.ACCOUNT_PUBLIC_KEY,pa=O.ACCOUNT_TOKEN_ISSUANCE,ma=O.ACCOUNT_CREATION,ha=O.ACCOUNT_TRANSFER,ga=O.ACCOUNT_VESTING_TRANSFER,_a=O.ACCOUNT_ESCROW_TRANSFER,va=O.ACCOUNT_ESCROW_SETTLEMENT,ya=O.ACCOUNT_STAKE,ba=[];ba[fa]={label:`ACCOUNT_PUBLIC_KEY`,definition:[{name:`publicKey`,type:12},{name:`schemeId`,type:7}]},ba[pa]={label:`ACCOUNT_TOKEN_ISSUANCE`,definition:[{name:`amount`,type:11}]},ba[ma]={label:`ACCOUNT_CREATION`,definition:[{name:`sellerAccount`,type:13},{name:`amount`,type:11}]},ba[ha]={label:`ACCOUNT_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3}]},ba[ga]={label:`ACCOUNT_VESTING_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`cliffDurationDays`,type:8},{name:`vestingDurationDays`,type:8}]},ba[_a]={label:`ACCOUNT_ESCROW_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`escrowIdentifier`,type:13},{name:`agentAccount`,type:13},{name:`durationDays`,type:8}]},ba[va]={label:`ACCOUNT_ESCROW_SETTLEMENT`,definition:[{name:`confirmed`,type:5},{name:`escrowIdentifier`,type:13}]},ba[ya]={label:`ACCOUNT_STAKE`,definition:[{name:`amount`,type:11},{name:`objectType`,type:7},{name:`objectIdentifier`,type:13}]};var xa=O.VN_CREATION,Sa=O.VN_COMETBFT_PUBLIC_KEY_DECLARATION,Ca=O.VN_RPC_ENDPOINT,wa=O.VN_APPROVAL,Ta=[];Ta[xa]={label:`VN_CREATION`,definition:[{name:`organizationId`,type:13}]},Ta[Sa]={label:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,definition:[{name:`cometPublicKeyType`,type:3},{name:`cometPublicKey`,type:3}]},Ta[Ca]={label:`VN_RPC_ENDPOINT`,definition:[{name:`rpcEndpoint`,type:3}]},Ta[wa]={label:`VN_APPROVAL`,definition:[{name:`status`,type:5}]};var Ea=O.ORG_CREATION,Da=O.ORG_DESCRIPTION,Oa=[];Oa[Ea]={label:`ORG_CREATION`,definition:[{name:`accountId`,type:13}]},Oa[Da]={label:`ORG_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`city`,type:3},{name:`countryCode`,type:3,size:2},{name:`website`,type:3}]};var ka=O.APP_CREATION,Aa=O.APP_DESCRIPTION,ja=[];ja[ka]={label:`APP_CREATION`,definition:[{name:`organizationId`,type:13}]},ja[Aa]={label:`APP_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`logoUrl`,type:3},{name:`homepageUrl`,type:3},{name:`description`,type:3}]};var Ma=O.APP_LEDGER_ALLOWED_SIG_SCHEMES,Na=O.APP_LEDGER_ALLOWED_PKE_SCHEMES,Pa=O.APP_LEDGER_CREATION,Fa=O.APP_LEDGER_ACTOR_CREATION,Ia=O.APP_LEDGER_CHANNEL_CREATION,La=O.APP_LEDGER_SHARED_SECRET,Ra=O.APP_LEDGER_CHANNEL_INVITATION,za=O.APP_LEDGER_ACTOR_SUBSCRIPTION,Ba=O.APP_LEDGER_PUBLIC_CHANNEL_DATA,Va=O.APP_LEDGER_PRIVATE_CHANNEL_DATA,Ha=O.APP_LEDGER_AUTHOR,Ua=O.APP_LEDGER_ENDORSEMENT_REQUEST,Wa=[];Wa[Ma]={label:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Wa[Na]={label:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Wa[Pa]={label:`APP_LEDGER_CREATION`,definition:[{name:`applicationId`,type:13}]},Wa[Fa]={label:`APP_LEDGER_ACTOR_CREATION`,definition:[{name:`id`,type:7},{name:`type`,type:7},{name:`name`,type:3}]},Wa[Ia]={label:`APP_LEDGER_CHANNEL_CREATION`,definition:[{name:`id`,type:7},{name:`isPrivate`,type:5},{name:`creatorId`,type:7},{name:`name`,type:3}]},Wa[La]={label:`APP_LEDGER_SHARED_SECRET`,definition:[{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedSharedKey`,type:12}]},Wa[Ra]={label:`APP_LEDGER_CHANNEL_INVITATION`,definition:[{name:`channelId`,type:7},{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedChannelKey`,type:12}]},Wa[za]={label:`APP_LEDGER_ACTOR_SUBSCRIPTION`,definition:[{name:`actorId`,type:7},{name:`actorType`,type:7},{name:`organizationId`,type:13},{name:`signatureSchemeId`,type:7},{name:`signaturePublicKey`,type:12},{name:`pkeSchemeId`,type:7},{name:`pkePublicKey`,type:12}]},Wa[Ba]={label:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`data`,type:12}]},Wa[Va]={label:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`merkleRootHash`,type:13},{name:`encryptedData`,type:12}]},Wa[Ha]={label:`APP_LEDGER_AUTHOR`,definition:[{name:`authorId`,type:7}]},Wa[Ua]={label:`APP_LEDGER_ENDORSEMENT_REQUEST`,definition:[{name:`endorserId`,type:7},{name:`message`,type:3}]};var Ga={...da,...ba,...Ta,...Oa,...ja,...Wa},Ka=[da,ba,Ta,Oa,ja,Wa],qa=t({WI_INVALID_SIGNATURE:()=>0}),Ja=0,Ya;(function(e){e[e.SECP256K1=0]=`SECP256K1`,e[e.ML_DSA_65=1]=`ML_DSA_65`,e[e.PKMS_SECP256K1=2]=`PKMS_SECP256K1`,e[e.ED25519=3]=`ED25519`})(Ya||={});var Xa=new TextEncoder,Za=new TextDecoder,Qa={encode:$a,decode:eo};function $a(e){return Xa.encode(e)}function eo(e){return Za.decode(e)}var to=class extends m{constructor(e){super(e,n.TYPE_CHECKING_FAILURE_ERROR)}},no=126,ro=class{static getType(e){switch(typeof e){case`string`:return 3;case`number`:return 4;case`boolean`:return 5;case`object`:if(e===null)return 6;if(Array.isArray(e))return 1;if(e instanceof Uint8Array)return 12;if(Object.getPrototypeOf(e).isPrototypeOf(Object))return 2}return 0}static isJsonType(e){return no>>e&1}},io=class{basicType;definition;value;constructor(e,t){this.definition=e,this.value=t,this.basicType=ro.getType(t)}check(){let e=this.definition.type&31;switch(e){case 3:this.isString();break;case 4:this.isNumber();break;case 5:this.isBoolean();break;case 7:this.isUnsignedInteger(8);break;case 8:this.isUnsignedInteger(16);break;case 9:this.isUnsignedInteger(24);break;case 10:this.isUnsignedInteger(32);break;case 11:this.isUnsignedInteger(48);break;case 12:this.isBinary();break;case 13:this.isBinary(32);break;case 14:this.isHashString();break;default:throw`unexpected definition type ${e}`}}isString(){if(this.basicType!=3)throw`string expected`;if(this.definition.size){let e=Qa.encode(this.value);this.checkSize(e.length,this.definition.size)}}isNumber(){if(this.basicType!=4)throw`number expected`}isBoolean(){if(this.basicType!=5)throw`Boolean value expected`}isInteger(){if(this.isNumber(),this.value%1)throw`integer expected`;if(this.value<-(2**53-1)||this.value>2**53-1)throw`value is outside the safe integer range`}isUnsignedInteger(e){if(this.isInteger(),this.value<0)throw new to(`non-negative value expected`);if(this.value>=2**e)throw Error(`value is too big (${e}-bit value expected)`)}isBinary(e){if(this.basicType!=12)throw`Uint8Array expected`;this.checkSize(this.value.length,e||this.definition.size)}isHashString(){if(this.isString(),this.checkSize(this.value.length,64),/[^\da-f]/i.test(this.value))throw`hexadecimal string expected`}checkSize(e,t){if(t!==void 0&&e!=t)throw`invalid size (expecting ${t}, got ${e})`}};function ao(e){return typeof e==`function`?e:oo(e)}function oo(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}var so=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function co(e,t){let n=so.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=so.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function lo(e=[]){return fo.getLogger(e)}var uo=Symbol.for(`logtape.rootLogger`),fo=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=uo in globalThis?globalThis[uo]??null:null;return n??(n=new e(null,[]),globalThis[uo]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new po(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||co(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=Co(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);if(!(this.lowestLevel===null||co(o.level,this.lowestLevel)<0||!this.filter(o))){for(let e of this.getSinks(o.level))if(!t?.has(e))try{e(o)}catch(n){let r=new Set(t);r.add(e),mo.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:o},r)}}}log(e,t,n,r){let i=wo(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return bo(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:bo(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=wo(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,xo(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=wo();this.emit({category:this.category,level:e,message:xo(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},po=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},mo=fo.getLogger([`logtape`,`meta`]);function ho(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function go(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function _o(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=function(e){return e[e.CARMENTIS_ERROR=0]=`CARMENTIS_ERROR`,e[e.NODE_ERROR=1]=`NODE_ERROR`,e[e.NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR=2]=`NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR`,e[e.INTERNAL_ERROR=500]=`INTERNAL_ERROR`,e[e.TYPE_CHECKING_FAILURE_ERROR=501]=`TYPE_CHECKING_FAILURE_ERROR`,e[e.SERIALIZATION_ERROR=502]=`SERIALIZATION_ERROR`,e[e.PROOF_VERIFICATION_FAILURE=300]=`PROOF_VERIFICATION_FAILURE`,e[e.BLOCKCHAIN_ERROR=100]=`BLOCKCHAIN_ERROR`,e[e.ACCOUNT_NOT_FOUND=101]=`ACCOUNT_NOT_FOUND`,e[e.ACCOUNT_ALREADY_EXISTS=102]=`ACCOUNT_ALREADY_EXISTS`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY=103]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH=104]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH`,e[e.ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY=105]=`ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_ADDRESS=106]=`ACCOUNT_NOT_FOUND_FOR_ADDRESS`,e[e.ORGANIZATION_NOT_FOUND=107]=`ORGANIZATION_NOT_FOUND`,e[e.APPLICATION_NOT_FOUND=108]=`APPLICATION_NOT_FOUND`,e[e.APPLICATION_LEDGER_NOT_FOUND=109]=`APPLICATION_LEDGER_NOT_FOUND`,e[e.VALIDATOR_NODE_NOT_FOUND=110]=`VALIDATOR_NODE_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_NOT_FOUND=111]=`VIRTUAL_BLOCKCHAIN_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS=112]=`VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS`,e[e.MICROBLOCK_STRUCTURE_CHECKING_ERROR=113]=`MICROBLOCK_STRUCTURE_CHECKING_ERROR`,e[e.ECONOMICS_ERROR=200]=`ECONOMICS_ERROR`,e[e.INVALID_TOKEN_UNIT=201]=`INVALID_TOKEN_UNIT`,e[e.PROTOCOL_ERROR=400]=`PROTOCOL_ERROR`,e}({}),r=class extends Error{},i=class extends r{},a=class extends r{},o=class e extends Error{constructor(e,t=n.CARMENTIS_ERROR){super(`[error ${t}] ${e}`),this.code=t}getErrorCode(){return this.code}static isCarmentisError(t){return t instanceof e}},s=class extends o{constructor(e){super(`Microblock structure checking error: ${e??`Not specified`}`,n.MICROBLOCK_STRUCTURE_CHECKING_ERROR)}},c=class extends o{constructor(){super(`You are not authenticated`)}},l=class extends o{constructor(e=`Parsing failure`){super(e)}},u=class extends o{constructor(e){super(e,n.BLOCKCHAIN_ERROR)}},d=class extends o{},f=class extends d{constructor(e){super(e??`Decryption failure`)}},p=class extends f{constructor(e){super(e)}},m=class extends o{},h=class extends m{},g=class extends h{constructor(e){super(`Connection with node at ${e} refused`,n.NODE_ERROR)}},_=class extends h{constructor(){super(`Query rejected while catching up`,n.NODE_ERROR)}},v=class extends o{constructor(e,t=n.ECONOMICS_ERROR){super(e,t)}},y=class extends v{constructor(){super(`Invalid unit type`,n.INVALID_TOKEN_UNIT)}},b=class extends o{constructor(e,t=n.BLOCKCHAIN_ERROR){super(e,t)}},ee=class extends Error{constructor(){super(`No implemented`)}},x=class extends b{constructor(e,t){super(`MicroBlock in virtual blockchain ${e.encode()} not found at height ${t}`)}},te=class extends b{constructor(){super(`MicroBlock not found`)}},S=class extends b{constructor(){super(`MicroBlock not found in block`)}},ne=class extends r{constructor(e){super(`Actor '${e}' already defined`)}},re=class extends r{constructor(e,t){super(`invalid actor ID ${e} (expected ID: ${t})`)}},ie=class extends r{constructor(e){super(`Channel '${e}' already defined`)}},ae=class extends r{constructor(e){super(`Unknown actor '${e}'`)}},oe=class extends r{constructor(e){super(`Unknown channel '${e}'`)}},se=class extends o{constructor(e,t,r){super(`Proof verification failed on channel ${e} (computed hash is ${t}, on-chain hash is ${r})`,n.PROOF_VERIFICATION_FAILURE)}},ce=class extends r{constructor(e){super(`Cannot subscribe as undefined actor ${e}`)}},C=class extends r{constructor(e){super(`Actor ${e} is already subscribed`)}},le=class extends r{constructor(e){super(`signature scheme of type ${e} is not allowed on this application ledger`)}},ue=class extends r{constructor(e){super(`PKE scheme of type ${e} is not allowed on this application ledger`)}},de=class extends r{constructor(e){super(`Invalid channel ID ${e}`)}},fe=class extends r{constructor(){super(`Current actor not found`)}},pe=class extends b{},me=class extends b{constructor(e,t){super(`Actor ${e} has not been invited to channel ${t}`)}},he=class extends b{constructor(e){super(`Account not found for public key`)}},ge=class extends b{constructor(e){super(`Account not found for account hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY)}},_e=class extends b{constructor(e){super(`Organization not found for hash: ${e.encode()}`,n.ORGANIZATION_NOT_FOUND)}},ve=class extends b{constructor(e){super(`Application not found for id: ${e.encode()}`,n.APPLICATION_NOT_FOUND)}},ye=class extends b{constructor(e){super(`Validator node not found for id: ${e.encode()}`,n.VALIDATOR_NODE_NOT_FOUND)}},be=class extends b{constructor(e){super(`Account not found for public key hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH)}},xe=class extends b{constructor(e){super(`Virtual blockchain not found: ${e.encode()}`,n.VIRTUAL_BLOCKCHAIN_NOT_FOUND)}},Se=class extends xe{constructor(e){super(e)}},Ce=class extends o{constructor(e,t=n.PROTOCOL_ERROR){super(`/!\\ `+e,t)}},we=class extends Ce{constructor(e,t){super(`Actor ${t} (id ${e}) has not subscribed to a public encryption key.`),this.actorId=e,this.actorName=t}getNotSubscribedActorName(){return this.actorName}},Te=class extends Ce{constructor(){super(`Section not found`)}},Ee=class extends Ce{constructor(e,t){super(`No shared secret between host ${t} and guest ${e}`)}},De=class extends o{constructor(e){super(e,n.SERIALIZATION_ERROR)}},Oe=9e15,ke=1e9,Ae=`0123456789abcdef`,je=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,Me=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Ne={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Oe,maxE:Oe,crypto:!1},Pe,Fe,w=!0,Ie=`[DecimalError] `,Le=Ie+`Invalid argument: `,Re=Ie+`Precision limit exceeded`,ze=Ie+`crypto unavailable`,Be=`[object Decimal]`,Ve=Math.floor,He=Math.pow,Ue=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,We=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ge=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ke=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,qe=1e7,T=7,Je=9007199254740991,Ye=je.length-1,Xe=Me.length-1,E={toStringTag:Be};E.absoluteValue=E.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),D(e)},E.ceil=function(){return D(new this.constructor(this),this.e+1,2)},E.clampedTo=E.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Le+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},E.comparedTo=E.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},E.cosine=E.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+T,r.rounding=1,n=tt(r,bt(r,n)),r.precision=e,r.rounding=t,D(Fe==2||Fe==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},E.cubeRoot=E.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(w=!1,a=u.s*He(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Ze(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=He(n,1/3),e=Ve((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=nt(l.plus(u).times(s),l.plus(c),o+2,1),Ze(s.d).slice(0,o)===(n=Ze(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(D(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(D(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return w=!0,D(r,e,d.rounding,t)},E.decimalPlaces=E.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Ve(this.e/T))*T,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},E.dividedBy=E.div=function(e){return nt(this,new this.constructor(e))},E.dividedToIntegerBy=E.divToInt=function(e){var t=this,n=t.constructor;return D(nt(t,new n(e),0,1,1),n.precision,n.rounding)},E.equals=E.eq=function(e){return this.cmp(e)===0},E.floor=function(){return D(new this.constructor(this),this.e+1,3)},E.greaterThan=E.gt=function(e){return this.cmp(e)>0},E.greaterThanOrEqualTo=E.gte=function(e){var t=this.cmp(e);return t==1||t===0},E.hyperbolicCosine=E.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/yt(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=vt(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return D(a,o.precision=n,o.rounding=r,!0)},E.hyperbolicSine=E.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=vt(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/yt(5,e)),i=vt(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,D(i,t,n,!0)},E.hyperbolicTangent=E.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,nt(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},E.inverseCosine=E.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?ot(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?ot(t,r,i):new t(0):new t(NaN)},E.inverseHyperbolicCosine=E.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,w=!1,n=n.times(n).minus(1).sqrt().plus(n),w=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},E.inverseHyperbolicSine=E.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,w=!1,n=n.times(n).plus(1).sqrt().plus(n),w=!0,r.precision=e,r.rounding=t,n.ln())},E.inverseHyperbolicTangent=E.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?D(new a(i),e,t,!0):(a.precision=n=r-i.e,i=nt(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},E.inverseSine=E.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=ot(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},E.inverseTangent=E.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Xe)return o=ot(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Xe)return o=ot(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/T+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(w=!1,t=Math.ceil(s/T),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),w=!0,D(o,u.precision=d,u.rounding=f,!0)},E.isFinite=function(){return!!this.d},E.isInteger=E.isInt=function(){return!!this.d&&Ve(this.e/T)>this.d.length-2},E.isNaN=function(){return!this.s},E.isNegative=E.isNeg=function(){return this.s<0},E.isPositive=E.isPos=function(){return this.s>0},E.isZero=function(){return!!this.d&&this.d[0]===0},E.lessThan=E.lt=function(e){return this.cmp(e)<0},E.lessThanOrEqualTo=E.lte=function(e){return this.cmp(e)<1},E.logarithm=E.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(w=!1,s=d+p,o=pt(l,s),r=t?at(u,s+10):pt(e,s),c=nt(o,r,s,1),$e(c.d,i=d,f))do if(s+=10,o=pt(l,s),r=t?at(u,s+10):pt(e,s),c=nt(o,r,s,1),!a){+Ze(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=D(c,d+1,0));break}while($e(c.d,i+=10,f));return w=!0,D(c,d,f)},E.minus=E.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return w?D(e,s,c):e}if(n=Ve(e.e/T),u=Ve(p.e/T),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/T),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=qe-1;--l[i],l[r]+=qe}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=it(l,n),w?D(e,s,c):e):new m(c===3?-0:0)},E.modulo=E.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?D(new r(n),r.precision,r.rounding):(w=!1,r.modulo==9?(t=nt(n,e.abs(),0,3,1),t.s*=e.s):t=nt(n,e,0,r.modulo,1),t=t.times(e),w=!0,n.minus(t))},E.naturalExponential=E.exp=function(){return ft(this)},E.naturalLogarithm=E.ln=function(){return pt(this)},E.negated=E.neg=function(){var e=new this.constructor(this);return e.s=-e.s,D(e)},E.plus=E.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),w?D(e,s,c):e;if(a=Ve(d.e/T),r=Ve(e.e/T),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/T),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/qe|0,l[i]%=qe;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=it(l,r),w?D(e,s,c):e},E.precision=E.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Le+e);return n.d?(t=st(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},E.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},E.sine=E.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+T,r.rounding=1,n=_t(r,bt(r,n)),r.precision=e,r.rounding=t,D(Fe>2?n.neg():n,e,t,!0)):new r(NaN)},E.squareRoot=E.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(w=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Ze(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=Ve((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(nt(o,a,n+2,1)).times(.5),Ze(a.d).slice(0,n)===(t=Ze(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(D(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(D(r,c+1,1),e=!r.times(r).eq(o));break}return w=!0,D(r,c,u.rounding,e)},E.tangent=E.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=nt(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,D(Fe==2||Fe==4?n.neg():n,e,t,!0)):new r(NaN)},E.times=E.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=Ve(u.e/T)+Ve(e.e/T),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%qe|0,t=s/qe|0;a[i]=(a[i]+t)%qe|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=it(a,n),w?D(e,d.precision,d.rounding):e},E.toBinary=function(e,t){return xt(this,2,e,t)},E.toDecimalPlaces=E.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Qe(e,0,ke),t===void 0?t=r.rounding:Qe(t,0,8),D(n,e+n.e+1,t))},E.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rt(r,!0):(Qe(e,0,ke),t===void 0?t=i.rounding:Qe(t,0,8),r=D(new i(r),e+1,t),n=rt(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},E.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=rt(i):(Qe(e,0,ke),t===void 0?t=a.rounding:Qe(t,0,8),r=D(new a(i),e+i.e+1,t),n=rt(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},E.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=st(m)-p.e-1,o=a%T,t.d[0]=He(10,o<0?T+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Le+s);e=s.gt(t)?a>0?t:l:s}for(w=!1,s=new h(Ze(m)),u=h.precision,h.precision=a=m.length*T*2;d=nt(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=nt(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=nt(l,r,a,1).minus(p).abs().cmp(nt(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,w=!0,f},E.toHexadecimal=E.toHex=function(e,t){return xt(this,16,e,t)},E.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Qe(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(w=!1,n=nt(n,e,0,t,1).times(e),w=!0,D(n)):(e.s=n.s,n=e),n},E.toNumber=function(){return+this},E.toOctal=function(e,t){return xt(this,8,e,t)},E.toPower=E.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(He(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return D(s,r,a);if(t=Ve(e.e/T),t>=e.d.length-1&&(n=l<0?-l:l)<=Je)return i=lt(c,s,n,r),e.s<0?new c(1).div(i):D(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=He(+s,l),t=n==0||!isFinite(n)?Ve(l*(Math.log(`0.`+Ze(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(w=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=ft(e.times(pt(s,r+n)),r),i.d&&(i=D(i,r+5,1),$e(i.d,r,a)&&(t=r+10,i=D(ft(e.times(pt(s,t+n)),t),t+5,1),+Ze(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=D(i,r+1,0)))),i.s=o,w=!0,c.rounding=a,D(i,r,a))},E.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=rt(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Qe(e,1,ke),t===void 0?t=i.rounding:Qe(t,0,8),r=D(new i(r),e,t),n=rt(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},E.toSignificantDigits=E.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Qe(e,1,ke),t===void 0?t=r.rounding:Qe(t,0,8)),D(new r(n),e,t)},E.toString=function(){var e=this,t=e.constructor,n=rt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},E.truncated=E.trunc=function(){return D(new this.constructor(this),this.e+1,1)},E.valueOf=E.toJSON=function(){var e=this,t=e.constructor,n=rt(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Ze(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=T-r.length,n&&(a+=ct(n)),a+=r;o=e[t],r=o+``,n=T-r.length,n&&(a+=ct(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function Qe(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Le+e)}function $e(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=T,i=0):(i=Math.ceil((t+1)/T),t%=T),a=He(10,T-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==He(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==He(10,t-3)-1,o}function et(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=Ae.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function tt(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/yt(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=vt(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var nt=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,ee,x,te,S,ne,re,ie,ae,oe=r.constructor,se=r.s==i.s?1:-1,ce=r.d,C=i.d;if(!ce||!ce[0]||!C||!C[0])return new oe(!r.s||!i.s||(ce?C&&ce[0]==C[0]:!C)?NaN:ce&&ce[0]==0||!C?se*0:se/0);for(c?(p=1,u=r.e-i.e):(c=qe,p=T,u=Ve(r.e/p)-Ve(i.e/p)),ie=C.length,ne=ce.length,_=new oe(se),v=_.d=[],d=0;C[d]==(ce[d]||0);d++);if(C[d]>(ce[d]||0)&&u--,a==null?(x=a=oe.precision,o=oe.rounding):x=s?a+(r.e-i.e)+1:a,x<0)v.push(1),m=!0;else{if(x=x/p+2|0,d=0,ie==1){for(f=0,C=C[0],x++;(d<ne||f)&&x--;d++)te=f*c+(ce[d]||0),v[d]=te/C|0,f=te%C|0;m=f||d<ne}else{for(f=c/(C[0]+1)|0,f>1&&(C=e(C,f,c),ce=e(ce,f,c),ie=C.length,ne=ce.length),S=ie,y=ce.slice(0,ie),b=y.length;b<ie;)y[b++]=0;ae=C.slice(),ae.unshift(0),re=C[0],C[1]>=c/2&&++re;do f=0,l=t(C,y,ie,b),l<0?(ee=y[0],ie!=b&&(ee=ee*c+(y[1]||0)),f=ee/re|0,f>1?(f>=c&&(f=c-1),h=e(C,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,ie<g?ae:C,g,c))):(f==0&&(l=f=1),h=C.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(C,y,ie,b),l<1&&(f++,n(y,ie<b?ae:C,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=ce[S]||0:(y=[ce[S]],b=1);while((S++<ne||y[0]!==void 0)&&x--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Pe=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,D(_,s?a+_.e+1:a,o,m)}return _}})();function D(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=T,o=t,u=d[f=0],c=u/He(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/T),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=T,o=a-T+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=T,o=a-T+i,c=o<0?0:u/He(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%He(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/He(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=He(10,(T-t%T)%T),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=He(10,T-a),d[f]=o>0?(u/He(10,i-o)%He(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==qe&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=qe)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return w&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function rt(e,t,n){if(!e.isFinite())return mt(e);var r,i=e.e,a=Ze(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+ct(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+ct(-i-1)+a,n&&(r=n-o)>0&&(a+=ct(r))):i>=o?(a+=ct(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+ct(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=ct(r))),a}function it(e,t){var n=e[0];for(t*=T;n>=10;n/=10)t++;return t}function at(e,t,n){if(t>Ye)throw w=!0,n&&(e.precision=n),Error(Re);return D(new e(je),t,1,!0)}function ot(e,t,n){if(t>Xe)throw Error(Re);return D(new e(Me),t,n,!0)}function st(e){var t=e.length-1,n=t*T+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ct(e){for(var t=``;e--;)t+=`0`;return t}function lt(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/T+4);for(w=!1;;){if(n%2&&(a=a.times(t),St(a.d,o)&&(i=!0)),n=Ve(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),St(t.d,o)}return w=!0,a}function ut(e){return e.d[e.d.length-1]&1}function dt(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function ft(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(w=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(He(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=D(a.times(e),c,1),n=n.times(++u),s=o.plus(nt(a,n,c,1)),Ze(s.d).slice(0,c)===Ze(o.d).slice(0,c)){for(i=d;i--;)o=D(o.times(o),c,1);if(t==null)if(l<3&&$e(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return D(o,f.precision=m,p,w=!0);else return f.precision=m,o}o=s}}function pt(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(w=!1,u=y):u=t,_.precision=u+=m,n=Ze(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Ze(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=at(_,u+2,y).times(a+``),h=pt(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?D(h,y,v,w=!0):h;for(d=h,c=o=h=nt(h.minus(1),h.plus(1),u,1),f=D(h.times(h),u,1),i=3;;){if(o=D(o.times(f),u,1),l=c.plus(nt(o,new _(i),u,1)),Ze(l.d).slice(0,u)===Ze(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(at(_,u+2,y).times(a+``))),c=nt(c,new _(p),u,1),t==null)if($e(c.d,u-m,v,s))_.precision=u+=m,l=o=h=nt(d.minus(1),d.plus(1),u,1),f=D(h.times(h),u,1),i=s=1;else return D(c,_.precision=y,v,w=!0);else return _.precision=y,c;c=l,i+=2}}function mt(e){return String(e.s*e.s/0)}function ht(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%T,n<0&&(r+=T),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=T;r<i;)e.d.push(+t.slice(r,r+=T));t=t.slice(r),r=T-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),w&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function gt(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),Ke.test(t))return ht(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(We.test(t))n=16,t=t.toLowerCase();else if(Ue.test(t))n=2;else if(Ge.test(t))n=8;else throw Error(Le+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=lt(r,new r(n),a,a*2)),l=et(t,n,qe),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=it(l,u),e.d=l,w=!1,o&&(e=nt(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?He(2,c):dn.pow(2,c))),w=!0,e)}function _t(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:vt(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/yt(5,n)),t=vt(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function vt(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/T);for(w=!1,c=n.times(n),s=new e(r);;){if(o=nt(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=nt(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return w=!0,o.d.length=d+1,o}function yt(e,t){for(var n=e;--t;)n*=e;return n}function bt(e,t){var n,r=t.s<0,i=ot(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Fe=r?4:1,t;if(n=t.divToInt(i),n.isZero())Fe=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Fe=ut(n)?r?2:3:r?4:1,t;Fe=ut(n)?r?1:4:r?3:2}return t.minus(i).abs()}function xt(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(Qe(n,1,ke),r===void 0?r=p.rounding:Qe(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=mt(e);else{for(u=rt(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=et(rt(f),10,i),f.e=f.d.length),d=et(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=nt(e,f,n,r,0,i),d=e.d,a=e.e,l=Pe),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=Ae.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=et(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=Ae.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function St(e,t){if(e.length>t)return e.length=t,!0}function Ct(e){return new this(e).abs()}function wt(e){return new this(e).acos()}function Tt(e){return new this(e).acosh()}function Et(e,t){return new this(e).plus(t)}function Dt(e){return new this(e).asin()}function Ot(e){return new this(e).asinh()}function kt(e){return new this(e).atan()}function At(e){return new this(e).atanh()}function jt(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=ot(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?ot(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=ot(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(nt(e,t,a,1)),t=ot(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(nt(e,t,a,1)),n}function Mt(e){return new this(e).cbrt()}function Nt(e){return D(e=new this(e),e.e+1,2)}function Pt(e,t,n){return new this(e).clamp(t,n)}function Ft(e){if(!e||typeof e!=`object`)throw Error(Ie+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,ke,`rounding`,0,8,`toExpNeg`,-Oe,0,`toExpPos`,0,Oe,`maxE`,0,Oe,`minE`,-Oe,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Ne[n]),(r=e[n])!==void 0)if(Ve(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Le+n+`: `+r);if(n=`crypto`,i&&(this[n]=Ne[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(ze);else this[n]=!1;else throw Error(Le+n+`: `+r);return this}function It(e){return new this(e).cos()}function Lt(e){return new this(e).cosh()}function Rt(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,Ut(e)){a.s=e.s,w?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;w?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return ht(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),Ke.test(e)?ht(a,e):gt(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,ht(a,e.toString());throw Error(Le+e)}if(i.prototype=E,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Ft,i.clone=Rt,i.isDecimal=Ut,i.abs=Ct,i.acos=wt,i.acosh=Tt,i.add=Et,i.asin=Dt,i.asinh=Ot,i.atan=kt,i.atanh=At,i.atan2=jt,i.cbrt=Mt,i.ceil=Nt,i.clamp=Pt,i.cos=It,i.cosh=Lt,i.div=zt,i.exp=Bt,i.floor=Vt,i.hypot=Ht,i.ln=Wt,i.log=Gt,i.log10=qt,i.log2=Kt,i.max=Jt,i.min=Yt,i.mod=Xt,i.mul=Zt,i.pow=Qt,i.random=$t,i.round=en,i.sign=tn,i.sin=nn,i.sinh=rn,i.sqrt=an,i.sub=on,i.sum=sn,i.tan=cn,i.tanh=ln,i.trunc=un,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function zt(e,t){return new this(e).div(t)}function Bt(e){return new this(e).exp()}function Vt(e){return D(e=new this(e),e.e+1,3)}function Ht(){var e,t,n=new this(0);for(w=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return w=!0,new this(1/0);n=t}return w=!0,n.sqrt()}function Ut(e){return e instanceof dn||e&&e.toStringTag===Be||!1}function Wt(e){return new this(e).ln()}function Gt(e,t){return new this(e).log(t)}function Kt(e){return new this(e).log(2)}function qt(e){return new this(e).log(10)}function Jt(){return dt(this,arguments,-1)}function Yt(){return dt(this,arguments,1)}function Xt(e,t){return new this(e).mod(t)}function Zt(e,t){return new this(e).mul(t)}function Qt(e,t){return new this(e).pow(t)}function $t(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:Qe(e,1,ke),r=Math.ceil(e/T),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(ze);for(r=s[--a],e%=T,r&&e&&(i=He(10,T-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=T)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<T&&(n-=T-r)}return o.e=n,o.d=s,o}function en(e){return D(e=new this(e),e.e+1,this.rounding)}function tn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function nn(e){return new this(e).sin()}function rn(e){return new this(e).sinh()}function an(e){return new this(e).sqrt()}function on(e,t){return new this(e).sub(t)}function sn(){var e=0,t=arguments,n=new this(t[e]);for(w=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return w=!0,D(n,this.precision,this.rounding)}function cn(e){return new this(e).tan()}function ln(e){return new this(e).tanh()}function un(e){return D(e=new this(e),e.e+1,1)}E[Symbol.for(`nodejs.util.inspect.custom`)]=E.toString,E[Symbol.toStringTag]=`Decimal`;var dn=E.constructor=Rt(Ne);je=new dn(je),Me=new dn(Me);var fn=function(e){return e[e.TOKEN=1e5]=`TOKEN`,e[e.DECI_TOKEN=1e4]=`DECI_TOKEN`,e[e.CENTI_TOKEN=1e3]=`CENTI_TOKEN`,e[e.MILLI_TOKEN=100]=`MILLI_TOKEN`,e[e.MICRO_TOKEN=10]=`MICRO_TOKEN`,e[e.ATOMIC=1]=`ATOMIC`,e}({}),pn=function(e){return e.TOKEN=`CMTS`,e.DECI_TOKEN=`dCMTS`,e.CENTI_TOKEN=`cCMTS`,e.MILLI_TOKEN=`mCMTS`,e.MICRO_TOKEN=`μCMTS`,e.ATOMIC=`aCMTS`,e}({}),mn=class e{constructor(e){this.amount=e}static create(e,t=fn.TOKEN){if(t!=fn.TOKEN)throw new y;return this.createCMTS(e)}static createCMTS(e){return this.createSafeCmtsToken(dn(e),dn(fn.TOKEN))}static createDeciToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.DECI_TOKEN))}static createMicroToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MICRO_TOKEN))}static createMilliToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MILLI_TOKEN))}static createCentiToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.CENTI_TOKEN))}static createMillionToken(e){return this.createSafeCmtsToken(dn(e),dn(fn.MICRO_TOKEN))}static createAtomic(e){return this.createSafeCmtsToken(dn(e),dn(fn.ATOMIC))}static createSafeCmtsToken(t,n){let r=t.mul(n);if(r.isInteger())return new e(r);throw new v(`Invalid amount: An atomic token should be insecable: got ${r}`)}static zero(){return this.createAtomic(0)}static oneCMTS(){return this.createCMTS(1)}static parse(t){let n=t.trim().match(/^(\d+(?:\.\d+)?)\s*(\S+)$/);if(!n)throw new v(`Invalid token amount format: "${t}"`);let[,r,i]=n,a=parseFloat(r);switch(i){case pn.TOKEN:return e.createCMTS(a);case pn.DECI_TOKEN:return e.createDeciToken(a);case pn.CENTI_TOKEN:return e.createCentiToken(a);case pn.MILLI_TOKEN:return e.createMilliToken(a);case pn.MICRO_TOKEN:return e.createMicroToken(a);case pn.ATOMIC:return e.createAtomic(a);default:throw new y}}getAmount(e=fn.TOKEN){switch(e){case fn.TOKEN:return this.amount.div(dn(fn.TOKEN)).toNumber();case fn.CENTI_TOKEN:return this.amount.div(dn(fn.CENTI_TOKEN)).toNumber();case fn.MILLI_TOKEN:return this.amount.div(dn(fn.MILLI_TOKEN)).toNumber();case fn.DECI_TOKEN:return this.amount.div(dn(fn.DECI_TOKEN)).toNumber();case fn.MICRO_TOKEN:return this.amount.div(dn(fn.MICRO_TOKEN)).toNumber();case fn.ATOMIC:return this.amount.toNumber()}}getAmountAsAtomic(){return this.getAmount(fn.ATOMIC)}getAmountAsCMTS(){return this.getAmount(fn.TOKEN)}isPositive(){return this.amount.isPositive()||this.amount.isZero()}isPositiveStrict(){return this.isPositive()&&!this.isZero()}isNegative(){return this.amount.isNegative()}isZero(){return this.amount.isZero()}equals(e){return this.amount.equals(e.amount)}isGreaterThan(e){return this.amount.gt(e.amount)}isLessThan(e){return this.amount.lt(e.amount)}add(t){return e.createAtomic(this.getAmountAsAtomic()+t.getAmountAsAtomic())}sub(t){return e.createAtomic(this.getAmountAsAtomic()-t.getAmountAsAtomic())}toString(t=fn.TOKEN){switch(t){case fn.TOKEN:return`${this.getAmountAsCMTS()} ${e.getUnitLabel(t)}`;case fn.ATOMIC:return`${this.getAmountAsAtomic()} ${e.getUnitLabel(t)}`;default:throw new y}}static getUnitLabel(e){switch(e){case fn.TOKEN:return pn.TOKEN;case fn.ATOMIC:return pn.ATOMIC;default:throw new y}}},hn=t({FORMAT:()=>28,HASHABLE:()=>1,HASHED:()=>8,MASKABLE:()=>2,MASKED:()=>16,PROPERTIES:()=>3,REDACTED:()=>4,TYPE_ARRAY:()=>1,TYPE_ARRAY_OF:()=>32,TYPE_BIN256:()=>13,TYPE_BINARY:()=>12,TYPE_BOOLEAN:()=>5,TYPE_HASH_STR:()=>14,TYPE_MAIN:()=>31,TYPE_NAMES:()=>Nn,TYPE_NULL:()=>6,TYPE_NUMBER:()=>4,TYPE_OBJECT:()=>2,TYPE_STRING:()=>3,TYPE_UINT16:()=>8,TYPE_UINT24:()=>9,TYPE_UINT32:()=>10,TYPE_UINT48:()=>11,TYPE_UINT8:()=>7,TYPE_UNKNOWN:()=>0}),gn=0,_n=1,vn=2,yn=3,bn=4,xn=5,Sn=6,Cn=7,wn=8,Tn=9,En=10,Dn=11,On=12,kn=13,An=14,jn=31,Mn=32,Nn=[`unknown`,`array`,`object`,`string`,`number`,`boolean`,`null`,`uint8`,`uint16`,`uint24`,`uint32`,`uint48`,`binary`,`bin256`,`hashString`],Pn=1,Fn=2,In=3,Ln=4,Rn=8,zn=16,Bn=28,Vn=t({MAGIC_STRING:()=>Hn,MAX_MICROBLOCK_FUTURE_DELAY:()=>120,MAX_MICROBLOCK_PAST_DELAY:()=>300,MB_STATUS_PREVIOUS_HASH_ERROR:()=>3,MB_STATUS_TIMESTAMP_ERROR:()=>2,MB_STATUS_UNRECOVERABLE_ERROR:()=>1,N_VIRTUAL_BLOCKCHAINS:()=>6,PROTOCOL_VERSION:()=>1,VB_ACCOUNT:()=>1,VB_APPLICATION:()=>4,VB_APP_LEDGER:()=>5,VB_NAME:()=>Zn,VB_ORGANIZATION:()=>3,VB_PROTOCOL:()=>0,VB_VALIDATOR_NODE:()=>2}),Hn=`CMTS`,Un=1,Wn=0,Gn=1,Kn=2,qn=3,Jn=4,Yn=5,Xn=6,Zn=[`protocol`,`account`,`validator node`,`organization`,`application`,`application ledger`],Qn=300,$n=120,er=1,tr=2,nr=3,rr=t({ACCOUNT_ALLOWED_TRANSFERS:()=>Wr,ACCOUNT_BLOCK_FEES:()=>2,ACCOUNT_BURNT_TOKENS:()=>0,ACCOUNT_NAMES:()=>Ur,ACCOUNT_STANDARD:()=>1,BK_EARNED_BLOCK_FEES:()=>3,BK_EARNED_TX_FEES:()=>1,BK_NAMES:()=>zr,BK_PAID_BLOCK_FEES:()=>2,BK_PAID_TX_FEES:()=>0,BK_PLUS:()=>1,BK_PURCHASE:()=>7,BK_RECEIVED_ESCROW:()=>13,BK_RECEIVED_ESCROW_REFUND:()=>15,BK_RECEIVED_EXPIRED_ESCROW:()=>17,BK_RECEIVED_ISSUANCE:()=>5,BK_RECEIVED_PAYMENT:()=>9,BK_RECEIVED_SLASHED_TOKENS:()=>19,BK_RECEIVED_VESTING:()=>11,BK_REFERENCES:()=>Rr,BK_REF_BLOCK:()=>0,BK_REF_MICROBLOCK:()=>1,BK_REF_SECTION:()=>2,BK_SALE:()=>6,BK_SENT_ESCROW:()=>12,BK_SENT_ESCROW_REFUND:()=>14,BK_SENT_EXPIRED_ESCROW:()=>16,BK_SENT_ISSUANCE:()=>4,BK_SENT_PAYMENT:()=>8,BK_SENT_SLASHED_TOKENS:()=>18,BK_SENT_VESTING:()=>10,CENTITOKEN:()=>or,FIXED_GAS_FEE:()=>dr,GAS_PER_BYTE:()=>1,GAS_UNIT:()=>pr,INITIAL_OFFER:()=>cr,MAXIMUM_GAS_PRICE:()=>ur,MILLITOKEN:()=>100,MINIMUM_GAS_PRICE:()=>1,TOKEN:()=>ar,TOKEN_NAME:()=>ir}),ir=`CMTS`,ar=1e5,or=1e3,sr=100,cr=1e9*ar,lr=1,ur=2**29-1,dr=1e3,fr=1,pr=1e3,mr=1,hr=0,gr=2,_r=4,vr=6,yr=8,br=10,xr=12,Sr=14,Cr=16,wr=18,Tr=1,Er=3,Dr=5,Or=7,kr=9,Ar=11,jr=13,Mr=15,Nr=17,Pr=19,Fr=0,Ir=1,Lr=2,Rr=[1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],zr=[`Paid TX fees`,`Earned TX fees`,`Paid block fees`,`Earned block fees`,`Sent initial token issuance`,`Received initial token issuance`,`Sale`,`Purchase`,`Sent payment`,`Received payment`,`Sent vesting`,`Received vesting`,`Sent escrow`,`Received escrow`,`Sent escrow refund`,`Received escrow refund`,`Sent expired escrow`,`Received expired escrow`,`Sent slashed tokens`,`Received slashed tokens`],Br=0,Vr=1,Hr=2,Ur=[`Burnt tokens account`,`Standard account`,`Block fees account`],Wr=[524800,524265,6],Gr=t({ACCOUNT_HISTORY:()=>ii,ACCOUNT_STATE:()=>ri,ALL_SCHEMAS:()=>aa,BLOCK_CONTENT:()=>ui,BLOCK_INFORMATION:()=>li,CONTRACT_PARAMETER_SCHEMA:()=>qr,CONTRACT_SCHEMA:()=>Jr,ERROR:()=>Kr,MICROBLOCK_BODY:()=>gi,MICROBLOCK_HEADER:()=>mi,MICROBLOCK_HEADER_BODY_HASH_OFFSET:()=>58,MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET:()=>13,MICROBLOCK_HEADER_SIZE:()=>122,MICROBLOCK_SECTION:()=>hi,MICROBLOCK_VB_INFORMATION:()=>_i,MSG_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>22,MSG_ACCOUNT_HISTORY:()=>20,MSG_ACCOUNT_STATE:()=>18,MSG_AWAIT_MICROBLOCK_ANCHORING:()=>13,MSG_BLOCK_CONTENT:()=>6,MSG_BLOCK_INFORMATION:()=>4,MSG_CHAIN_INFORMATION:()=>2,MSG_ERROR:()=>0,MSG_GENESIS_SNAPSHOT:()=>28,MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>21,MSG_GET_ACCOUNT_HISTORY:()=>19,MSG_GET_ACCOUNT_STATE:()=>17,MSG_GET_BLOCK_CONTENT:()=>5,MSG_GET_BLOCK_INFORMATION:()=>3,MSG_GET_CHAIN_INFORMATION:()=>1,MSG_GET_GENESIS_SNAPSHOT:()=>27,MSG_GET_MICROBLOCK_BODYS:()=>15,MSG_GET_MICROBLOCK_INFORMATION:()=>11,MSG_GET_OBJECT_LIST:()=>25,MSG_GET_VALIDATOR_NODE_BY_ADDRESS:()=>23,MSG_GET_VIRTUAL_BLOCKCHAIN_STATE:()=>7,MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE:()=>9,MSG_MICROBLOCK_ANCHORING:()=>14,MSG_MICROBLOCK_BODYS:()=>16,MSG_MICROBLOCK_INFORMATION:()=>12,MSG_OBJECT_LIST:()=>26,MSG_VALIDATOR_NODE_BY_ADDRESS:()=>24,MSG_VIRTUAL_BLOCKCHAIN_STATE:()=>8,MSG_VIRTUAL_BLOCKCHAIN_UPDATE:()=>10,NODE_MESSAGES:()=>qi,PROTOCOL_VARIABLES:()=>oi,PROTOCOL_VB_STATE:()=>si,RECORD_DESCRIPTION:()=>ni,VB_STATES:()=>ci,VIRTUAL_BLOCKCHAIN_STATE:()=>ai,WIMSG_ANSWER:()=>5,WIMSG_CONNECTION_ACCEPTED:()=>7,WIMSG_CONNECTION_INFO:()=>6,WIMSG_CONNECTION_TOKEN:()=>2,WIMSG_FORWARDED_ANSWER:()=>3,WIMSG_FORWARDED_REQUEST:()=>8,WIMSG_GET_CONNECTION_INFO:()=>4,WIMSG_REQUEST:()=>0,WIMSG_UPDATE_QR:()=>1,WI_MESSAGES:()=>ia,WI_QR_CODE:()=>Ji}),Kr={label:`Error`,definition:[{name:`type`,type:7},{name:`id`,type:7},{name:`arg`,type:35}]},qr={label:`contractParameter`,definition:[{name:`name`,type:3},{name:`type`,type:3},{name:`defaultValue`,type:3},{name:`modifiable`,type:5}]},Jr={label:`contract`,definition:[{name:`name`,type:3},{name:`parametersDefinition`,type:34,schema:qr}]},Yr={label:`RecordActor`,definition:[{name:`name`,type:3}]},Xr={label:`RecordChannel`,definition:[{name:`name`,type:3},{name:`public`,type:5}]},Zr={label:`RecordChannelAssignation`,definition:[{name:`fieldPath`,type:3},{name:`channelName`,type:3}]},Qr={label:`RecordActorAssignation`,definition:[{name:`actorName`,type:3},{name:`channelName`,type:3}]},$r={label:`RecordMaskedPart`,definition:[{name:`position`,type:10},{name:`length`,type:10},{name:`replacementString`,type:3}]},ei={label:`RecordMaskableField`,definition:[{name:`fieldPath`,type:3},{name:`maskedParts`,type:34,schema:$r}]},ti={label:`RecordHashableField`,definition:[{name:`fieldPath`,type:3}]},ni={label:`RecordDescription`,definition:[{name:`applicationId`,type:14},{name:`virtualBlockchainId`,type:14,optional:!0},{name:`data`,type:2,unspecifiedSchema:!0},{name:`actors`,type:34,optional:!0,schema:Yr},{name:`channels`,type:34,optional:!0,schema:Xr},{name:`channelAssignations`,type:34,optional:!0,schema:Zr},{name:`actorAssignations`,type:34,optional:!0,schema:Qr},{name:`hashableFields`,type:34,optional:!0,schema:ti},{name:`maskableFields`,type:34,optional:!0,schema:ei},{name:`author`,type:3},{name:`endorser`,type:3,optional:!0},{name:`approvalMessage`,type:3,optional:!0}]},ri={label:`AccountState`,definition:[{name:`height`,type:11},{name:`balance`,type:11},{name:`lastHistoryHash`,type:13},{name:`locks`,type:34,definition:[{name:`type`,type:7},{name:`amount`,type:11},{name:`parameters`,type:12}]}]},ii={label:`AccountHistory`,definition:[{name:`height`,type:11},{name:`previousHistoryHash`,type:13},{name:`type`,type:7},{name:`timestamp`,type:11},{name:`linkedAccount`,type:13},{name:`amount`,type:11},{name:`chainReference`,type:12}]},ai={label:`VirtualBlockchainState`,definition:[{name:`type`,type:7},{name:`expirationDay`,type:10},{name:`height`,type:11},{name:`lastMicroblockHash`,type:13},{name:`serializedInternalState`,type:12}]},oi={label:`PROTOCOL_VARIABLES`,definition:[{name:`protocolVersionName`,type:3},{name:`protocolVersion`,type:8},{name:`feesCalculationVersion`,type:8},{name:`globalStateUpdaterVersion`,type:8},{name:`applicationLedgerInternalStateUpdaterVersion`,type:8},{name:`applicationInternalStateUpdaterVersion`,type:8},{name:`organizationInternalStateUpdaterVersion`,type:8},{name:`validatorNodeInternalStateUpdaterVersion`,type:8},{name:`accountInternalStateUpdaterVersion`,type:8},{name:`protocolInternalStateUpdaterVersion`,type:8}]},si={label:`ProtocolVbState`,definition:[{name:`organizationId`,type:13},{name:`currentProtocolVariables`,type:2,schema:oi},{name:`protocolUpdates`,type:34,schema:{label:`PROTOCOL_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi},{name:`protocolVersionName`,type:3}]}}]},ci=[si,{label:`AccountVbState`,definition:[{name:`signatureSchemeId`,type:7},{name:`publicKeyHeight`,type:11}]},{label:`ValidatorNodeVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11},{name:`rpcEndpointHeight`,type:11},{name:`networkIntegrationHeight`,type:11}]},{label:`OrganizationVbState`,definition:[{name:`accountId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`ApplicationVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`AppLedgerVbState`,definition:[{name:`allowedSignatureSchemeIds`,type:39},{name:`allowedPkeSchemeIds`,type:39},{name:`applicationId`,type:13},{name:`channels`,type:34,definition:[{name:`name`,type:3},{name:`isPrivate`,type:5},{name:`creatorId`,type:7}]},{name:`actors`,type:34,definition:[{name:`name`,type:3},{name:`subscribed`,type:5},{name:`signatureKeyHeight`,type:11},{name:`pkeKeyHeight`,type:11},{name:`sharedSecrets`,type:34,definition:[{name:`peerActorId`,type:7},{name:`height`,type:11}]},{name:`invitations`,type:34,definition:[{name:`channelId`,type:7},{name:`height`,type:11}]}]}]}],li={label:`BlockInformation`,definition:[{name:`hash`,type:13},{name:`timestamp`,type:11},{name:`proposerAddress`,type:12},{name:`size`,type:11},{name:`microblockCount`,type:11}]},ui={label:`BlockContent`,definition:[{name:`microblocks`,type:34,definition:[{name:`hash`,type:13},{name:`vbIdentifier`,type:13},{name:`vbType`,type:7},{name:`height`,type:11},{name:`size`,type:11},{name:`sectionCount`,type:11}]}]},di=13,fi=58,pi=122,mi={label:`MicroblockHeader`,definition:[{name:`magicString`,type:3,size:4},{name:`protocolVersion`,type:8},{name:`microblockType`,type:7},{name:`height`,type:11},{name:`previousHash`,type:13},{name:`timestamp`,type:11},{name:`gas`,type:9},{name:`gasPrice`,type:10},{name:`bodyHash`,type:13},{name:`feesPayerAccount`,type:13}]},hi={label:`MicroblockSection`,definition:[{name:`type`,type:7},{name:`data`,type:12}]},gi={label:`MicroblockBody`,definition:[{name:`body`,type:34,schema:hi}]},_i={label:`MicroblockVbInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13}]},vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=6,Ti=7,Ei=8,Di=9,Oi=10,ki=11,Ai=12,ji=13,Mi=14,Ni=15,Pi=16,Fi=17,Ii=18,Li=19,Ri=20,zi=21,Bi=22,Vi=23,Hi=24,Ui=25,Wi=26,Gi=27,Ki=28,qi=[];qi[0]={label:`MessageError`,definition:[{name:`error`,type:3}]},qi[1]={label:`MessageGetChainInformation`,definition:[]},qi[2]={label:`MessageChainInformation`,definition:[{name:`height`,type:11},{name:`lastBlockTimestamp`,type:11},{name:`microblockCount`,type:11},{name:`objectCounts`,type:43,size:6}]},qi[3]={label:`MessageGetBlockInformation`,definition:[{name:`height`,type:11}]},qi[4]={label:`MessageBlockInformation`,definition:li.definition},qi[5]={label:`MessageGetBlockContent`,definition:[{name:`height`,type:11}]},qi[6]={label:`MessageBlockContent`,definition:ui.definition},qi[7]={label:`MessageGetVirtualBlockchainState`,definition:[{name:`virtualBlockchainId`,type:13}]},qi[8]={label:`MessageVirtualBlockchainState`,definition:[{name:`stateData`,type:12}]},qi[9]={label:`MessageGetVirtualBlockchainUpdate`,definition:[{name:`virtualBlockchainId`,type:13},{name:`knownHeight`,type:11}]},qi[10]={label:`MessageVirtualBlockchainUpdate`,definition:[{name:`exists`,type:5},{name:`changed`,type:5},{name:`stateData`,type:12},{name:`headers`,type:44}]},qi[11]={label:`MessageGetMicroblockInformation`,definition:[{name:`hash`,type:13}]},qi[12]={label:`MessageMicroblockInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13},{name:`header`,type:12}]},qi[13]={label:`MessageAwaitMicroblockAnchoring`,definition:[{name:`hash`,type:13}]},qi[14]={label:`MessageMicroblockAnchoring`,definition:_i.definition},qi[15]={label:`MessageGetMicroblockBodys`,definition:[{name:`hashes`,type:45}]},qi[16]={label:`MessageMicroblockBodys`,definition:[{name:`list`,type:34,definition:[{name:`hash`,type:13},{name:`body`,type:12}]}]},qi[17]={label:`MessageGetAccountState`,definition:[{name:`accountHash`,type:13}]},qi[18]={label:`MessageAccountState`,definition:ri.definition},qi[19]={label:`MessageGetAccountHistory`,definition:[{name:`accountHash`,type:13},{name:`lastHistoryHash`,type:13},{name:`maxRecords`,type:8}]},qi[20]={label:`MessageAccountHistory`,definition:[{name:`list`,type:34,schema:ii}]},qi[21]={label:`MessageGetAccountByPublicKeyHash`,definition:[{name:`publicKeyHash`,type:13}]},qi[22]={label:`MessageAccountByPublicKeyHash`,definition:[{name:`accountHash`,type:13}]},qi[23]={label:`MessageGetValidatorNodeByAddress`,definition:[{name:`address`,type:12}]},qi[24]={label:`MessageValidatorNodeByAddress`,definition:[{name:`validatorNodeHash`,type:13}]},qi[25]={label:`MessageGetObjectList`,definition:[{name:`type`,type:7}]},qi[26]={label:`MessageObjectList`,definition:[{name:`list`,type:45}]},qi[27]={label:`MessageGetGenesisSnapshot`,definition:[]},qi[28]={label:`MessageGenesisSnapshot`,definition:[{name:`base64EncodedChunks`,type:35}]};var Ji={label:`WiQrCode`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11},{name:`serverUrl`,type:3,size:100}]},Yi=0,Xi=1,Zi=2,Qi=3,$i=4,ea=5,ta=6,na=7,ra=8,ia=[];ia[0]={label:`WiMsgRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12},{name:`deviceId`,type:13},{name:`withToken`,type:7}]},ia[1]={label:`WiMsgUpdateQr`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11}]},ia[2]={label:`WiMsgConnectionToken`,definition:[{name:`token`,type:13}]},ia[3]={label:`WiMsgForwardedAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ia[4]={label:`WiMsgGetConnectionInfo`,definition:[{name:`qrId`,type:13}]},ia[5]={label:`WiMsgAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ia[6]={label:`WiMsgConnectionInfo`,definition:[]},ia[7]={label:`WiMsgConnectionAccepted`,definition:[{name:`qrId`,type:13}]},ia[8]={label:`WiMsgForwardedRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12}]};var aa={singles:[Yr,Xr,Zr,Qr,$r,ei,ti,ni,mi,hi,gi,_i,Ji],collections:[{label:`VbState`,list:ci},{label:`NodeMessage`,list:qi},{label:`WiMessage`,list:ia}]},O=function(e){return e[e.SIGNATURE=127]=`SIGNATURE`,e[e.ALLOWED_ADDITIONAL_WRITER=128]=`ALLOWED_ADDITIONAL_WRITER`,e[e.CUSTOM=129]=`CUSTOM`,e[e.PROTOCOL_CREATION=1]=`PROTOCOL_CREATION`,e[e.PROTOCOL_UPDATE=2]=`PROTOCOL_UPDATE`,e[e.PROTOCOL_VARIABLES=5]=`PROTOCOL_VARIABLES`,e[e.ACCOUNT_PUBLIC_KEY=17]=`ACCOUNT_PUBLIC_KEY`,e[e.ACCOUNT_TOKEN_ISSUANCE=18]=`ACCOUNT_TOKEN_ISSUANCE`,e[e.ACCOUNT_CREATION=19]=`ACCOUNT_CREATION`,e[e.ACCOUNT_TRANSFER=20]=`ACCOUNT_TRANSFER`,e[e.ACCOUNT_VESTING_TRANSFER=21]=`ACCOUNT_VESTING_TRANSFER`,e[e.ACCOUNT_ESCROW_TRANSFER=22]=`ACCOUNT_ESCROW_TRANSFER`,e[e.ACCOUNT_ESCROW_SETTLEMENT=23]=`ACCOUNT_ESCROW_SETTLEMENT`,e[e.ACCOUNT_STAKE=24]=`ACCOUNT_STAKE`,e[e.ACCOUNT_UNSTAKE=25]=`ACCOUNT_UNSTAKE`,e[e.VN_CREATION=33]=`VN_CREATION`,e[e.VN_COMETBFT_PUBLIC_KEY_DECLARATION=34]=`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,e[e.VN_RPC_ENDPOINT=35]=`VN_RPC_ENDPOINT`,e[e.VN_APPROVAL=36]=`VN_APPROVAL`,e[e.VN_SLASHING_CANCELLATION=37]=`VN_SLASHING_CANCELLATION`,e[e.ORG_CREATION=52]=`ORG_CREATION`,e[e.ORG_DESCRIPTION=50]=`ORG_DESCRIPTION`,e[e.APP_CREATION=65]=`APP_CREATION`,e[e.APP_DESCRIPTION=66]=`APP_DESCRIPTION`,e[e.APP_LEDGER_ALLOWED_SIG_SCHEMES=80]=`APP_LEDGER_ALLOWED_SIG_SCHEMES`,e[e.APP_LEDGER_ALLOWED_PKE_SCHEMES=81]=`APP_LEDGER_ALLOWED_PKE_SCHEMES`,e[e.APP_LEDGER_CREATION=82]=`APP_LEDGER_CREATION`,e[e.APP_LEDGER_ACTOR_CREATION=83]=`APP_LEDGER_ACTOR_CREATION`,e[e.APP_LEDGER_CHANNEL_CREATION=84]=`APP_LEDGER_CHANNEL_CREATION`,e[e.APP_LEDGER_SHARED_SECRET=85]=`APP_LEDGER_SHARED_SECRET`,e[e.APP_LEDGER_CHANNEL_INVITATION=86]=`APP_LEDGER_CHANNEL_INVITATION`,e[e.APP_LEDGER_ACTOR_SUBSCRIPTION=87]=`APP_LEDGER_ACTOR_SUBSCRIPTION`,e[e.APP_LEDGER_PUBLIC_CHANNEL_DATA=88]=`APP_LEDGER_PUBLIC_CHANNEL_DATA`,e[e.APP_LEDGER_PRIVATE_CHANNEL_DATA=89]=`APP_LEDGER_PRIVATE_CHANNEL_DATA`,e[e.APP_LEDGER_AUTHOR=90]=`APP_LEDGER_AUTHOR`,e[e.APP_LEDGER_ENDORSEMENT_REQUEST=91]=`APP_LEDGER_ENDORSEMENT_REQUEST`,e}({}),oa=t({ACCOUNT_CREATION:()=>ma,ACCOUNT_ESCROW_SETTLEMENT:()=>va,ACCOUNT_ESCROW_TRANSFER:()=>_a,ACCOUNT_PUBLIC_KEY:()=>fa,ACCOUNT_STAKE:()=>ya,ACCOUNT_TOKEN_ISSUANCE:()=>pa,ACCOUNT_TRANSFER:()=>ha,ACCOUNT_VESTING_TRANSFER:()=>ga,ALL_SECTIONS_SCHEMAS:()=>Ga,APP_CREATION:()=>ka,APP_DESCRIPTION:()=>Aa,APP_LEDGER_ACTOR_CREATION:()=>Fa,APP_LEDGER_ACTOR_SUBSCRIPTION:()=>za,APP_LEDGER_ALLOWED_PKE_SCHEMES:()=>Na,APP_LEDGER_ALLOWED_SIG_SCHEMES:()=>Ma,APP_LEDGER_AUTHOR:()=>Ha,APP_LEDGER_CHANNEL_CREATION:()=>Ia,APP_LEDGER_CHANNEL_INVITATION:()=>Ra,APP_LEDGER_CREATION:()=>Pa,APP_LEDGER_ENDORSEMENT_REQUEST:()=>Ua,APP_LEDGER_PRIVATE_CHANNEL_DATA:()=>Va,APP_LEDGER_PUBLIC_CHANNEL_DATA:()=>Ba,APP_LEDGER_SHARED_SECRET:()=>La,DEF:()=>Ka,ORG_CREATION:()=>Ea,ORG_DESCRIPTION:()=>Da,PROTOCOL_CREATION:()=>la,PROTOCOL_UPDATE:()=>ua,SIGNATURE:()=>sa,SIGNATURE_SCHEMA:()=>ca,VN_APPROVAL:()=>wa,VN_COMETBFT_PUBLIC_KEY_DECLARATION:()=>Sa,VN_CREATION:()=>xa,VN_RPC_ENDPOINT:()=>Ca}),sa=O.SIGNATURE,ca={label:`SIGNATURE`,definition:[{name:`schemeId`,type:7},{name:`signature`,type:12}]},la=O.PROTOCOL_CREATION,ua=O.PROTOCOL_UPDATE,da=[];da[la]={label:`PROTOCOL_CREATION`,definition:[{name:`organizationId`,type:13}]},da[ua]={label:`PROTOCOL_VARIABLES_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`protocolVersionName`,type:3},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi}]};var fa=O.ACCOUNT_PUBLIC_KEY,pa=O.ACCOUNT_TOKEN_ISSUANCE,ma=O.ACCOUNT_CREATION,ha=O.ACCOUNT_TRANSFER,ga=O.ACCOUNT_VESTING_TRANSFER,_a=O.ACCOUNT_ESCROW_TRANSFER,va=O.ACCOUNT_ESCROW_SETTLEMENT,ya=O.ACCOUNT_STAKE,ba=[];ba[fa]={label:`ACCOUNT_PUBLIC_KEY`,definition:[{name:`publicKey`,type:12},{name:`schemeId`,type:7}]},ba[pa]={label:`ACCOUNT_TOKEN_ISSUANCE`,definition:[{name:`amount`,type:11}]},ba[ma]={label:`ACCOUNT_CREATION`,definition:[{name:`sellerAccount`,type:13},{name:`amount`,type:11}]},ba[ha]={label:`ACCOUNT_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3}]},ba[ga]={label:`ACCOUNT_VESTING_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`cliffDurationDays`,type:8},{name:`vestingDurationDays`,type:8}]},ba[_a]={label:`ACCOUNT_ESCROW_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`escrowIdentifier`,type:13},{name:`agentAccount`,type:13},{name:`durationDays`,type:8}]},ba[va]={label:`ACCOUNT_ESCROW_SETTLEMENT`,definition:[{name:`confirmed`,type:5},{name:`escrowIdentifier`,type:13}]},ba[ya]={label:`ACCOUNT_STAKE`,definition:[{name:`amount`,type:11},{name:`objectType`,type:7},{name:`objectIdentifier`,type:13}]};var xa=O.VN_CREATION,Sa=O.VN_COMETBFT_PUBLIC_KEY_DECLARATION,Ca=O.VN_RPC_ENDPOINT,wa=O.VN_APPROVAL,Ta=[];Ta[xa]={label:`VN_CREATION`,definition:[{name:`organizationId`,type:13}]},Ta[Sa]={label:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,definition:[{name:`cometPublicKeyType`,type:3},{name:`cometPublicKey`,type:3}]},Ta[Ca]={label:`VN_RPC_ENDPOINT`,definition:[{name:`rpcEndpoint`,type:3}]},Ta[wa]={label:`VN_APPROVAL`,definition:[{name:`status`,type:5}]};var Ea=O.ORG_CREATION,Da=O.ORG_DESCRIPTION,Oa=[];Oa[Ea]={label:`ORG_CREATION`,definition:[{name:`accountId`,type:13}]},Oa[Da]={label:`ORG_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`city`,type:3},{name:`countryCode`,type:3,size:2},{name:`website`,type:3}]};var ka=O.APP_CREATION,Aa=O.APP_DESCRIPTION,ja=[];ja[ka]={label:`APP_CREATION`,definition:[{name:`organizationId`,type:13}]},ja[Aa]={label:`APP_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`logoUrl`,type:3},{name:`homepageUrl`,type:3},{name:`description`,type:3}]};var Ma=O.APP_LEDGER_ALLOWED_SIG_SCHEMES,Na=O.APP_LEDGER_ALLOWED_PKE_SCHEMES,Pa=O.APP_LEDGER_CREATION,Fa=O.APP_LEDGER_ACTOR_CREATION,Ia=O.APP_LEDGER_CHANNEL_CREATION,La=O.APP_LEDGER_SHARED_SECRET,Ra=O.APP_LEDGER_CHANNEL_INVITATION,za=O.APP_LEDGER_ACTOR_SUBSCRIPTION,Ba=O.APP_LEDGER_PUBLIC_CHANNEL_DATA,Va=O.APP_LEDGER_PRIVATE_CHANNEL_DATA,Ha=O.APP_LEDGER_AUTHOR,Ua=O.APP_LEDGER_ENDORSEMENT_REQUEST,Wa=[];Wa[Ma]={label:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Wa[Na]={label:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Wa[Pa]={label:`APP_LEDGER_CREATION`,definition:[{name:`applicationId`,type:13}]},Wa[Fa]={label:`APP_LEDGER_ACTOR_CREATION`,definition:[{name:`id`,type:7},{name:`type`,type:7},{name:`name`,type:3}]},Wa[Ia]={label:`APP_LEDGER_CHANNEL_CREATION`,definition:[{name:`id`,type:7},{name:`isPrivate`,type:5},{name:`creatorId`,type:7},{name:`name`,type:3}]},Wa[La]={label:`APP_LEDGER_SHARED_SECRET`,definition:[{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedSharedKey`,type:12}]},Wa[Ra]={label:`APP_LEDGER_CHANNEL_INVITATION`,definition:[{name:`channelId`,type:7},{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedChannelKey`,type:12}]},Wa[za]={label:`APP_LEDGER_ACTOR_SUBSCRIPTION`,definition:[{name:`actorId`,type:7},{name:`actorType`,type:7},{name:`organizationId`,type:13},{name:`signatureSchemeId`,type:7},{name:`signaturePublicKey`,type:12},{name:`pkeSchemeId`,type:7},{name:`pkePublicKey`,type:12}]},Wa[Ba]={label:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`data`,type:12}]},Wa[Va]={label:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`merkleRootHash`,type:13},{name:`encryptedData`,type:12}]},Wa[Ha]={label:`APP_LEDGER_AUTHOR`,definition:[{name:`authorId`,type:7}]},Wa[Ua]={label:`APP_LEDGER_ENDORSEMENT_REQUEST`,definition:[{name:`endorserId`,type:7},{name:`message`,type:3}]};var Ga={...da,...ba,...Ta,...Oa,...ja,...Wa},Ka=[da,ba,Ta,Oa,ja,Wa],qa=t({WI_INVALID_SIGNATURE:()=>0}),Ja=0,Ya=function(e){return e[e.SECP256K1=0]=`SECP256K1`,e[e.ML_DSA_65=1]=`ML_DSA_65`,e[e.PKMS_SECP256K1=2]=`PKMS_SECP256K1`,e[e.ED25519=3]=`ED25519`,e}({}),Xa=new TextEncoder,Za=new TextDecoder,Qa={encode:$a,decode:eo};function $a(e){return Xa.encode(e)}function eo(e){return Za.decode(e)}var to=class extends m{constructor(e){super(e,n.TYPE_CHECKING_FAILURE_ERROR)}},no=126,ro=class{static getType(e){switch(typeof e){case`string`:return 3;case`number`:return 4;case`boolean`:return 5;case`object`:if(e===null)return 6;if(Array.isArray(e))return 1;if(e instanceof Uint8Array)return 12;if(Object.getPrototypeOf(e).isPrototypeOf(Object))return 2}return 0}static isJsonType(e){return no>>e&1}},io=class{basicType;definition;value;constructor(e,t){this.definition=e,this.value=t,this.basicType=ro.getType(t)}check(){let e=this.definition.type&31;switch(e){case 3:this.isString();break;case 4:this.isNumber();break;case 5:this.isBoolean();break;case 7:this.isUnsignedInteger(8);break;case 8:this.isUnsignedInteger(16);break;case 9:this.isUnsignedInteger(24);break;case 10:this.isUnsignedInteger(32);break;case 11:this.isUnsignedInteger(48);break;case 12:this.isBinary();break;case 13:this.isBinary(32);break;case 14:this.isHashString();break;default:throw`unexpected definition type ${e}`}}isString(){if(this.basicType!=3)throw`string expected`;if(this.definition.size){let e=Qa.encode(this.value);this.checkSize(e.length,this.definition.size)}}isNumber(){if(this.basicType!=4)throw`number expected`}isBoolean(){if(this.basicType!=5)throw`Boolean value expected`}isInteger(){if(this.isNumber(),this.value%1)throw`integer expected`;if(this.value<-(2**53-1)||this.value>2**53-1)throw`value is outside the safe integer range`}isUnsignedInteger(e){if(this.isInteger(),this.value<0)throw new to(`non-negative value expected`);if(this.value>=2**e)throw Error(`value is too big (${e}-bit value expected)`)}isBinary(e){if(this.basicType!=12)throw`Uint8Array expected`;this.checkSize(this.value.length,e||this.definition.size)}isHashString(){if(this.isString(),this.checkSize(this.value.length,64),/[^\da-f]/i.test(this.value))throw`hexadecimal string expected`}checkSize(e,t){if(t!==void 0&&e!=t)throw`invalid size (expecting ${t}, got ${e})`}};function ao(e){return typeof e==`function`?e:oo(e)}function oo(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}var so=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function co(e,t){let n=so.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=so.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function lo(e=[]){return fo.getLogger(e)}var uo=Symbol.for(`logtape.rootLogger`),fo=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=uo in globalThis?globalThis[uo]??null:null;return n??(n=new e(null,[]),globalThis[uo]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new po(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||co(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=Co(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);if(!(this.lowestLevel===null||co(o.level,this.lowestLevel)<0||!this.filter(o))){for(let e of this.getSinks(o.level))if(!t?.has(e))try{e(o)}catch(n){let r=new Set(t);r.add(e),mo.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:o},r)}}}log(e,t,n,r){let i=wo(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return bo(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:bo(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=wo(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,xo(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=wo();this.emit({category:this.category,level:e,message:xo(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},po=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},mo=fo.getLogger([`logtape`,`meta`]);function ho(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function go(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function _o(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
2
2
|
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function vo(e,t){if(typeof t==`string`)return go(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function yo(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=_o(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=vo(n,i),n===void 0)return}return n}function bo(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&ho(u)&&(l=yo(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function xo(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}var So=Symbol.for(`logtape.categoryPrefix`);function Co(){let e=fo.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[So];return Array.isArray(t)?t:[]}function wo(){let e=fo.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var To=t({inspect:()=>Eo});function Eo(e,t){let n=t?.compact===!0?void 0:2;return JSON.stringify(e,null,n)}var Do={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},Oo=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):To!=null&&`inspect`in To&&typeof Eo==`function`?(e,t)=>Eo(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function ko(e){return e<10?`0${e}`:`${e}`}function Ao(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}var jo={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${ko(t.getUTCMonth()+1)}-${ko(t.getUTCDate())} ${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${ko(t.getUTCMonth()+1)}-${ko(t.getUTCDate())} ${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${ko(t.getUTCMonth()+1)}-${ko(t.getUTCDate())} ${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${ko(t.getUTCHours())}:${ko(t.getUTCMinutes())}:${ko(t.getUTCSeconds())}.${Ao(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${ko(t.getUTCMonth()+1)}-${ko(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},Mo={ABBR:Do,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function No(e={}){let t=(()=>{let t=e.timestamp;return t==null?jo[`date-time-timezone`]:t===`disabled`?jo.none:typeof t==`string`&&t in jo?jo[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,Oo):Oo,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>Mo.ABBR[e]:t===`abbr`?e=>Mo.abbr[e]:t===`FULL`?e=>Mo.FULL[e]:t===`full`?e=>Mo.full[e]:t===`L`?e=>Mo.L[e]:t===`l`?e=>Mo.l[e]:t})(),a=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let o=e.message,s=o.length,c;if(s===1)c=o[0];else if(s<=6){c=``;for(let e=0;e<s;e++)c+=e%2==0?o[e]:r(o[e])}else{let e=Array(s);for(let t=0;t<s;t++)e[t]=t%2==0?o[t]:r(o[t]);c=e.join(``)}return`${a({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:c,record:e})}\n`}}No();var Po=`\x1B[0m`,Fo={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},Io={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},Lo={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function Ro(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:Io[n]}${r==null?``:Fo[r]}`,a=n==null&&r==null?``:Po,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??Lo,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:Io[c]}${l==null?``:Fo[l]}`,d=c==null&&l==null?``:Po;return No({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=`${i}${e}${a}`,n=`${o==null?``:Io[o]}${f==null?``:Fo[f]}${n}${o==null&&f==null?``:Po}`,t==null?`${e} ${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}Ro();function zo(e={}){if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties})+`
|
|
3
3
|
`;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties})+`
|
|
4
4
|
`;let t=e.message[0];for(let n=1;n<e.message.length;n++)t+=n&1?JSON.stringify(e.message[n]):e.message[n];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:t,logger:e.category.join(`.`),properties:e.properties})+`
|
|
5
5
|
`};let t=e.message===`template`,n=e.properties??`nest:properties`,r;if(typeof e.categorySeparator==`function`)r=e.categorySeparator;else{let t=e.categorySeparator??`.`;r=e=>e.join(t)}let i;if(n===`flatten`)i=e=>e;else if(n.startsWith(`prepend:`)){let e=n.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);i=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(n.startsWith(`nest:`)){let e=n.substring(5);i=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let a;return a=t?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:a(e),logger:r(e.category),...i(e.properties)})+`
|
|
6
|
-
`}zo();var Bo={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function Vo(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${Do[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,Bo[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function Ho(e={}){let t=e.formatter??Vo,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}var Uo=null,Wo=new Set,Go=new Set,Ko=new Set;function qo(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function Jo(e){if(Uo!=null&&!e.reset)throw new es(`Already configured; if you want to reset, turn on the reset flag.`);if(Ko.size>0)throw new es(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);Xo();try{Yo(e,!1)}catch(e){throw e instanceof es&&Xo(),e}}function Yo(e,t){Uo=e;let n=!1,r=new Set;for(let t of e.loggers){qo(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new es(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=fo.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new es(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new es(`Filter not found: ${n}.`);a.filters.push(ao(t))}Wo.add(a)}fo.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)Ko.add(n);else throw new es(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Go.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)Ko.add(n);else throw new es(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Go.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?Qo:$o)}else addEventListener(`unload`,t?Qo:$o);let i=fo.getLogger([`logtape`,`meta`]);n||i.sinks.push(Ho()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function Xo(){$o(),Zo()}function Zo(){let e=fo.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,Wo.clear(),Uo=null}async function Qo(){$o();let e=[];for(let t of Ko)e.push(t[Symbol.asyncDispose]()),Ko.delete(t);await Promise.all(e)}function $o(){for(let e of Go)e[Symbol.dispose]();Go.clear()}var es=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}},ts=class{static getLogger(e=[]){return lo([`@cmts-dev/carmentis-sdk`,...e])}static getProviderLogger(){return this.getLogger([`provider`])}static getMemoryProviderLogger(){return this.getLogger([`provider`,`memory`])}static async enableLogs(){this.enableLogsSync()}static enableLogsSync(){Jo({sinks:{console:Ho()},loggers:[{category:`@cmts-dev/carmentis-sdk`,lowestLevel:`debug`,sinks:[`console`]}]})}static getNetworkProviderLogger(){return this.getLogger([`provider`,`network`])}static getMicroblockLogger(){return this.getLogger([`microblock`])}static getVirtualBlockchainLogger(){return this.getLogger([`virtual-blockchain`])}static getInternalStateUpdaterLogger(e){return this.getLogger([`internal-state-updater`,e])}static getAbstractProviderLogger(e){return this.getLogger([`provider`,e])}static getMicroblockStructureCheckerLogger(){return this.getLogger([`microblock`,`structure-checker`])}},k={numberToHexa:rs,truncateString:is,truncateStringMiddle:as,getNullHash:os,getTimestampInSeconds:ss,encodeDay:ls,decodeDay:us,dateToDay:ds,dayToDate:fs,addDaysToTimestamp:ps,timestampDifferenceInDays:ms,bufferToUint8Array:hs,binaryToHexa:gs,binaryFromHexa:_s,binaryFrom:vs,binaryIsEqual:ys,binaryCompare:bs,intToByteArray:xs,byteArrayToInt:Ss,getGenesisEpochInTimestamp:cs},ns=ts.getLogger([`utils`]);function rs(e,t){return e.toString(16).toUpperCase().padStart(t||1,`0`)}function is(e,t){return e.slice(0,t)+(e.length>t?`(...)`:``)}function as(e,t,n){return e.length<=t+n?e:e.slice(0,t)+`(...)`+e.slice(e.length-n)}function os(){return new Uint8Array(32)}function ss(){return Math.floor(Date.now()/1e3)}function cs(){return 0}function ls(e,t,n){return e<<9|t<<5|n}function us(e){let t=e&31,n=e>>5&15;return[e>>>9,n,t]}function ds(e){let t=e.getDate(),n=e.getMonth()+1;return ls(e.getFullYear(),n,t)}function fs(e){let[t,n,r]=us(e);return new Date(Date.UTC(t,n-1,r))}function ps(e,t){let n=new Date(e*1e3);return Math.floor(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+t)/1e3)}function ms(e,t){return Math.round((t-e)/86400)}function hs(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)}function gs(e){return[...e].map(e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(``)}function _s(e){if(typeof e!=`string`)throw new i(`Expecting hex-string value: received ${typeof e}`);if(!e.match(/^([\da-f]{2})*$/gi))throw new i(`Expecting hex-string value: received '${e}'`);let t=(e.match(/../g)||[]).map(e=>parseInt(e,16));return new Uint8Array(t)}function vs(...e){let t=Array(e.length),n=Array(e.length),r=0;e.forEach((i,a)=>{let o=ro.getType(i);switch(o){case 4:n[a]=new Uint8Array(xs(i));break;case 3:n[a]=Qa.encode(i);break;case 12:n[a]=i;break;default:{let t=e.length,n=e.map(e=>Nn[ro.getType(e)]).join(`, `);throw Error(`unsupported type '${Nn[o]}' for Utils.binaryFrom(): got ${t} arguments of type ${n}`)}}t[a]=r,r+=n[a].length});let i=new Uint8Array(r);return t.forEach((e,t)=>{i.set(n[t],e)}),i}function ys(e,t){if(!(e instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof e}`);if(!(t instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof t}`);let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength!==r.byteLength)return ns.debug(`Comparison result is false (distinct length): ${n.byteLength} != ${r.byteLength}`),!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return ns.debug(`Comparison result is false (distinct value): ${n[e]} != ${r[e]}`),!1;return ns.debug(`Comparison result is true`),!0}function bs(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!=t.length)throw`cannot compare`;for(let n in e)if(e[n]<t[n])return-1;else if(e[n]>t[n])return 1;return 0}function xs(e,t=1){let n=[],r=e,i=t;for(;r>0||i>0;)n.push(r&255),r=Math.floor(r/256),i--;return n.reverse()}function Ss(e){return e.reduce((e,t)=>e*256+t,0)}var Cs=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function ws(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ts(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Es(e,...t){if(!ws(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Ds(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);Ts(e.outputLen),Ts(e.blockLen)}function Os(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ks(e,t){Es(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function As(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function js(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ms(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ns(e,t){return e<<32-t|e>>>t}function Ps(e,t){return e<<t|e>>>32-t>>>0}var Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Is(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ls(e){for(let t=0;t<e.length;t++)e[t]=Is(e[t]);return e}var Rs=Fs?e=>e:Ls,zs=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Bs={_0:48,_9:57,A:65,F:70,a:97,f:102};function Vs(e){if(e>=Bs._0&&e<=Bs._9)return e-Bs._0;if(e>=Bs.A&&e<=Bs.F)return e-(Bs.A-10);if(e>=Bs.a&&e<=Bs.f)return e-(Bs.a-10)}function Hs(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(zs)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Vs(e.charCodeAt(i)),a=Vs(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Us(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Ws(e){return typeof e==`string`&&(e=Us(e)),Es(e),e}function Gs(e){return typeof e==`string`&&(e=Us(e)),Es(e),e}function Ks(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Es(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function qs(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw Error(`options should be object or undefined`);return Object.assign(e,t)}var Js=class{};function Ys(e){let t=t=>e().update(Ws(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Xs(e){let t=(t,n)=>e(n).update(Ws(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function Zs(e=32){if(Cs&&typeof Cs.getRandomValues==`function`)return Cs.getRandomValues(new Uint8Array(e));if(Cs&&typeof Cs.randomBytes==`function`)return Uint8Array.from(Cs.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var Qs={getBytes:$s,getInteger:ec,getKey256:tc};function $s(e){return Zs(e)}function ec(e){let t=$s(6),n=0;for(let e=0;e<6;e++)n=n*256+t[e];return Math.floor(n/2**48*e)}function tc(){let e=$s(32);return k.binaryToHexa(e)}function nc(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function rc(e,t,n){return e&t^~e&n}function ic(e,t,n){return e&t^e&n^t&n}var ac=class extends Js{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Ms(this.buffer)}update(e){Os(this),e=Ws(e),Es(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Ms(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Os(this),ks(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,js(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;nc(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Ms(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},oc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),sc=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),cc=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),lc=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),uc=BigInt(2**32-1),dc=BigInt(32);function fc(e,t=!1){return t?{h:Number(e&uc),l:Number(e>>dc&uc)}:{h:Number(e>>dc&uc)|0,l:Number(e&uc)|0}}function pc(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=fc(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var mc=(e,t,n)=>e>>>n,hc=(e,t,n)=>e<<32-n|t>>>n,gc=(e,t,n)=>e>>>n|t<<32-n,_c=(e,t,n)=>e<<32-n|t>>>n,vc=(e,t,n)=>e<<64-n|t>>>n-32,yc=(e,t,n)=>e>>>n-32|t<<64-n,bc=(e,t,n)=>e<<n|t>>>32-n,xc=(e,t,n)=>t<<n|e>>>32-n,Sc=(e,t,n)=>t<<n-32|e>>>64-n,Cc=(e,t,n)=>e<<n-32|t>>>64-n;function wc(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Tc=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ec=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Dc=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Oc=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,kc=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Ac=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,jc=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]),Mc=new Uint32Array(64),Nc=class extends ac{constructor(e=32){super(64,e,8,!1),this.A=oc[0]|0,this.B=oc[1]|0,this.C=oc[2]|0,this.D=oc[3]|0,this.E=oc[4]|0,this.F=oc[5]|0,this.G=oc[6]|0,this.H=oc[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Mc[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Mc[e-15],n=Mc[e-2],r=Ns(t,7)^Ns(t,18)^t>>>3;Mc[e]=(Ns(n,17)^Ns(n,19)^n>>>10)+Mc[e-7]+r+Mc[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ns(o,6)^Ns(o,11)^Ns(o,25),u=l+t+rc(o,s,c)+jc[e]+Mc[e]|0,d=(Ns(n,2)^Ns(n,13)^Ns(n,22))+ic(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){js(Mc)}destroy(){this.set(0,0,0,0,0,0,0,0),js(this.buffer)}},Pc=class extends Nc{constructor(){super(28),this.A=sc[0]|0,this.B=sc[1]|0,this.C=sc[2]|0,this.D=sc[3]|0,this.E=sc[4]|0,this.F=sc[5]|0,this.G=sc[6]|0,this.H=sc[7]|0}},Fc=pc(`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`.split(`.`).map(e=>BigInt(e))),Ic=Fc[0],Lc=Fc[1],Rc=new Uint32Array(80),zc=new Uint32Array(80),Bc=class extends ac{constructor(e=64){super(128,e,16,!1),this.Ah=lc[0]|0,this.Al=lc[1]|0,this.Bh=lc[2]|0,this.Bl=lc[3]|0,this.Ch=lc[4]|0,this.Cl=lc[5]|0,this.Dh=lc[6]|0,this.Dl=lc[7]|0,this.Eh=lc[8]|0,this.El=lc[9]|0,this.Fh=lc[10]|0,this.Fl=lc[11]|0,this.Gh=lc[12]|0,this.Gl=lc[13]|0,this.Hh=lc[14]|0,this.Hl=lc[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Rc[n]=e.getUint32(t),zc[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Rc[e-15]|0,n=zc[e-15]|0,r=gc(t,n,1)^gc(t,n,8)^mc(t,n,7),i=_c(t,n,1)^_c(t,n,8)^hc(t,n,7),a=Rc[e-2]|0,o=zc[e-2]|0,s=gc(a,o,19)^vc(a,o,61)^mc(a,o,6),c=Dc(i,_c(a,o,19)^yc(a,o,61)^hc(a,o,6),zc[e-7],zc[e-16]);Rc[e]=Oc(c,r,s,Rc[e-7],Rc[e-16])|0,zc[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=gc(u,d,14)^gc(u,d,18)^vc(u,d,41),v=_c(u,d,14)^_c(u,d,18)^yc(u,d,41),y=u&f^~u&m,b=d&p^~d&h,ee=kc(_,v,b,Lc[e],zc[e]),x=Ac(ee,g,t,y,Ic[e],Rc[e]),te=ee|0,S=gc(n,r,28)^vc(n,r,34)^vc(n,r,39),ne=_c(n,r,28)^yc(n,r,34)^yc(n,r,39),re=n&i^n&o^i&o,ie=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=wc(c|0,l|0,x|0,te|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ae=Tc(te,ne,ie);n=Ec(ae,x,S,re),r=ae|0}({h:n,l:r}=wc(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=wc(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=wc(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=wc(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=wc(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=wc(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=wc(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=wc(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){js(Rc,zc)}destroy(){js(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Vc=class extends Bc{constructor(){super(48),this.Ah=cc[0]|0,this.Al=cc[1]|0,this.Bh=cc[2]|0,this.Bl=cc[3]|0,this.Ch=cc[4]|0,this.Cl=cc[5]|0,this.Dh=cc[6]|0,this.Dl=cc[7]|0,this.Eh=cc[8]|0,this.El=cc[9]|0,this.Fh=cc[10]|0,this.Fl=cc[11]|0,this.Gh=cc[12]|0,this.Gl=cc[13]|0,this.Hh=cc[14]|0,this.Hl=cc[15]|0}},Hc=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Uc=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Wc=class extends Bc{constructor(){super(28),this.Ah=Hc[0]|0,this.Al=Hc[1]|0,this.Bh=Hc[2]|0,this.Bl=Hc[3]|0,this.Ch=Hc[4]|0,this.Cl=Hc[5]|0,this.Dh=Hc[6]|0,this.Dl=Hc[7]|0,this.Eh=Hc[8]|0,this.El=Hc[9]|0,this.Fh=Hc[10]|0,this.Fl=Hc[11]|0,this.Gh=Hc[12]|0,this.Gl=Hc[13]|0,this.Hh=Hc[14]|0,this.Hl=Hc[15]|0}},Gc=class extends Bc{constructor(){super(32),this.Ah=Uc[0]|0,this.Al=Uc[1]|0,this.Bh=Uc[2]|0,this.Bl=Uc[3]|0,this.Ch=Uc[4]|0,this.Cl=Uc[5]|0,this.Dh=Uc[6]|0,this.Dl=Uc[7]|0,this.Eh=Uc[8]|0,this.El=Uc[9]|0,this.Fh=Uc[10]|0,this.Fl=Uc[11]|0,this.Gh=Uc[12]|0,this.Gl=Uc[13]|0,this.Hh=Uc[14]|0,this.Hl=Uc[15]|0}},Kc=Ys(()=>new Nc),qc=Ys(()=>new Pc),Jc=Ys(()=>new Bc),Yc=Ys(()=>new Vc),Xc=Ys(()=>new Gc),Zc=Ys(()=>new Wc),Qc=Jc,$c={sha256AsBinary:el,sha256:tl,sha512AsBinary:nl,sha512:rl};ts.getLogger([`utils`,`crypto`]);function el(e){if(!(e instanceof Uint8Array))throw new m(`Argument passed to compute sha256 is not an instance of Uint8Array: got ${typeof e}`);return Kc(e)}function tl(e){return k.binaryToHexa(el(e))}function nl(e){if(!(e instanceof Uint8Array))throw`Argument passed to compute sha512 is not an instance of Uint8Array`;return Qc(e)}function rl(e){return k.binaryToHexa(nl(e))}function il(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function al(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}function ol(e,...t){if(!il(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function sl(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function cl(e,t){ol(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ll(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ul(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function dl(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function fl(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var pl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ml=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,hl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function gl(e){if(ol(e),ml)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=hl[e[n]];return t}var _l={_0:48,_9:57,A:65,F:70,a:97,f:102};function vl(e){if(e>=_l._0&&e<=_l._9)return e-_l._0;if(e>=_l.A&&e<=_l.F)return e-(_l.A-10);if(e>=_l.a&&e<=_l.f)return e-(_l.a-10)}function yl(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ml)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=vl(e.charCodeAt(i)),a=vl(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function bl(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function xl(e){return new TextDecoder().decode(e)}function Sl(e){if(typeof e==`string`)e=bl(e);else if(il(e))e=kl(e);else throw Error(`Uint8Array expected, got `+typeof e);return e}function Cl(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}var wl=(e,t)=>{function n(n,...r){if(ol(n),!pl)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];if(!t)throw Error(`nonce / iv required`);e.varSizeNonce?ol(t):ol(t,e.nonceLength)}let i=e.tagLength;i&&r[1]!==void 0&&ol(r[1]);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);ol(t)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,ol(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(ol(e),i&&e.length<i)throw Error(`invalid ciphertext length: smaller than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function Tl(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`invalid output length, expected `+e+`, got: `+t.length);if(n&&!Ol(t))throw Error(`invalid output, must be aligned`);return t}function El(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Dl(e,t,n){al(n);let r=new Uint8Array(16),i=fl(r);return El(i,0,BigInt(t),n),El(i,8,BigInt(e),n),r}function Ol(e){return e.byteOffset%4==0}function kl(e){return Uint8Array.from(e)}var Al=16,jl=new Uint8Array(16),Ml=ul(jl),Nl=225,Pl=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^Nl<<24&-(i&1)}},Fl=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function Il(e){e.reverse();let t=e[15]&1,n=0;for(let t=0;t<e.length;t++){let r=e[t];e[t]=r>>>1|n,n=(r&1)<<7}return e[0]^=-t&225,e}var Ll=e=>e>64*1024?8:e>1024?4:2,Rl=class{constructor(e,t){this.blockLen=Al,this.outputLen=Al,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=Sl(e),ol(e,16);let n=fl(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:Fl(r),s1:Fl(i),s2:Fl(a),s3:Fl(o)}),{s0:r,s1:i,s2:a,s3:o}=Pl(r,i,a,o);let c=Ll(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e<l;e++)for(let t=0;t<u;t++){let n=0,r=0,i=0,a=0;for(let o=0;o<c;o++){if(!(t>>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<<i)-1,f=0;for(let p of[e,t,n,r])for(let e=0;e<4;e++){let t=p>>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){sl(this),e=Sl(e),ol(e);let t=ul(e),n=Math.floor(e.length/Al),r=e.length%Al;for(let e=0;e<n;e++)this._updateBlock(t[e*4+0],t[e*4+1],t[e*4+2],t[e*4+3]);return r&&(jl.set(e.subarray(n*Al)),this._updateBlock(Ml[0],Ml[1],Ml[2],Ml[3]),dl(Ml)),this}destroy(){let{t:e}=this;for(let t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){sl(this),cl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ul(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e}digest(){let e=new Uint8Array(Al);return this.digestInto(e),this.destroy(),e}},zl=class extends Rl{constructor(e,t){e=Sl(e),ol(e);let n=Il(kl(e));super(n,t),dl(n)}update(e){e=Sl(e),sl(this);let t=ul(e),n=e.length%Al,r=Math.floor(e.length/Al);for(let e=0;e<r;e++)this._updateBlock(Fl(t[e*4+3]),Fl(t[e*4+2]),Fl(t[e*4+1]),Fl(t[e*4+0]));return n&&(jl.set(e.subarray(r*Al)),this._updateBlock(Fl(Ml[3]),Fl(Ml[2]),Fl(Ml[1]),Fl(Ml[0])),dl(Ml)),this}digestInto(e){sl(this),cl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ul(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e.reverse()}};function Bl(e){let t=(t,n)=>e(n,t.length).update(Sl(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}var Vl=Bl((e,t)=>new Rl(e,t));Bl((e,t)=>new zl(e,t));var Hl=16,Ul=4,Wl=new Uint8Array(Hl),Gl=283;function Kl(e){return e<<1^Gl&-(e>>7)}function ql(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Kl(e);return n}var Jl=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Kl(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return dl(e),t})(),Yl=e=>e<<24|e>>>8,Xl=e=>e<<8|e>>>24;function Zl(e,t){if(e.length!==256)throw Error(`Wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Xl),i=r.map(Xl),a=i.map(Xl),o=new Uint32Array(256*256),s=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var Ql=Zl(Jl,e=>ql(e,3)<<24|e<<16|e<<8|ql(e,2)),$l=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Kl(n))e[t]=n;return e})();function eu(e){ol(e);let t=e.length;if(![16,24,32].includes(t))throw Error(`aes: invalid key size, should be 16, 24 or 32, got `+t);let{sbox2:n}=Ql,r=[];Ol(e)||r.push(e=kl(e));let i=ul(e),a=i.length,o=e=>nu(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e<s.length;e++){let t=s[e-1];e%a===0?t=o(Yl(t))^$l[e/a-1]:a>6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return dl(...r),s}function tu(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function nu(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function ru(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=Ql,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a<l;a++){let a=e[c++]^tu(o,s,t,n,r,i),l=e[c++]^tu(o,s,n,r,i,t),u=e[c++]^tu(o,s,r,i,t,n),d=e[c++]^tu(o,s,i,t,n,r);t=a,n=l,r=u,i=d}return{s0:e[c++]^nu(a,t,n,r,i),s1:e[c++]^nu(a,n,r,i,t),s2:e[c++]^nu(a,r,i,t,n),s3:e[c++]^nu(a,i,t,n,r)}}function iu(e,t,n,r,i){ol(n,Hl),ol(r),i=Tl(r.length,i);let a=n,o=ul(a),s=fl(a),c=ul(r),l=ul(i),u=t?0:12,d=r.length,f=s.getUint32(u,t),{s0:p,s1:m,s2:h,s3:g}=ru(e,o[0],o[1],o[2],o[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^p,l[n+1]=c[n+1]^m,l[n+2]=c[n+2]^h,l[n+3]=c[n+3]^g,f=f+1>>>0,s.setUint32(u,f,t),{s0:p,s1:m,s2:h,s3:g}=ru(e,o[0],o[1],o[2],o[3]);let _=Hl*Math.floor(c.length/Ul);if(_<d){let e=new Uint32Array([p,m,h,g]),t=ll(e);for(let e=_,n=0;e<d;e++,n++)i[e]=r[e]^t[n];dl(e)}return i}function au(e,t,n,r,i){let a=i?i.length:0,o=e.create(n,r.length+a);i&&o.update(i);let s=Dl(8*r.length,8*a,t);o.update(r),o.update(s);let c=o.digest();return dl(s),c}var ou=wl({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,t,n){if(t.length<8)throw Error(`aes/gcm: invalid nonce length`);function r(e,t,r){let i=au(Vl,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){let n=eu(e),r=Wl.slice(),i=Wl.slice();if(iu(n,!1,i,i,r),t.length===12)i.set(t);else{let e=Wl.slice();El(fl(e),8,BigInt(t.length*8),!1);let n=Vl.create(r).update(t).update(e);n.digestInto(i),n.destroy()}return{xk:n,authKey:r,counter:i,tagMask:iu(n,!1,i,Wl)}}return{encrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=new Uint8Array(e.length+16),c=[t,n,a,o];Ol(e)||c.push(e=kl(e)),iu(t,!1,a,e,s.subarray(0,e.length));let l=r(n,o,s.subarray(0,s.length-16));return c.push(l),s.set(l,e.length),dl(...c),s},decrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=[t,n,o,a];Ol(e)||s.push(e=kl(e));let c=e.subarray(0,-16),l=e.subarray(-16),u=r(n,o,c);if(s.push(u),!Cl(u,l))throw Error(`aes/gcm: invalid ghash tag`);let d=iu(t,!1,a,c);return dl(...s),d}}}),su=ts.getLogger([`crypto`,`aes-gcm`]),cu={encryptGcm:lu,decryptGcm:uu};function lu(e,t,n){return ou(e,n).encrypt(t)}function uu(e,t,n){try{return ou(e,n).decrypt(t)}catch(e){throw su.warn(`{e}`,{e}),new f}}var du=BigInt(0),fu=BigInt(1),pu=BigInt(2),mu=BigInt(7),hu=BigInt(256),gu=BigInt(113),_u=[],vu=[],yu=[];for(let e=0,t=fu,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_u.push(2*(5*r+n)),vu.push((e+1)*(e+2)/2%64);let i=du;for(let e=0;e<7;e++)t=(t<<fu^(t>>mu)*gu)%hu,t&pu&&(i^=fu<<(fu<<BigInt(e))-fu);yu.push(i)}var bu=pc(yu,!0),xu=bu[0],Su=bu[1],Cu=(e,t,n)=>n>32?Sc(e,t,n):bc(e,t,n),wu=(e,t,n)=>n>32?Cc(e,t,n):xc(e,t,n);function Tu(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Cu(a,o,1)^n[r],c=wu(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=vu[n],a=Cu(t,i,r),o=wu(t,i,r),s=_u[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=xu[r],e[1]^=Su[r]}js(n)}var Eu=class e extends Js{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,Ts(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=As(this.state)}clone(){return this._cloneInto()}keccak(){Rs(this.state32),Tu(this.state32,this.rounds),Rs(this.state32),this.posOut=0,this.pos=0}update(e){Os(this),e=Ws(e),Es(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Os(this,!1),Es(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Ts(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ks(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,js(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Du=(e,t,n)=>Ys(()=>new Eu(t,e,n)),Ou=Du(6,144,224/8),ku=Du(6,136,256/8),Au=Du(6,104,384/8),ju=Du(6,72,512/8);Du(1,144,224/8),Du(1,136,256/8),Du(1,104,384/8),Du(1,72,512/8);var Mu=(e,t,n)=>Xs((r={})=>new Eu(t,e,r.dkLen===void 0?n:r.dkLen,!0)),Nu=Mu(31,168,128/8),Pu=Mu(31,136,256/8),Fu=Es,Iu=Zs;function Lu(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}function Ru(...e){let t=e=>typeof e==`number`?e:e.bytesLen,n=e.reduce((e,n)=>e+t(n),0);return{bytesLen:n,encode:r=>{let i=new Uint8Array(n);for(let n=0,a=0;n<e.length;n++){let o=e[n],s=t(o),c=typeof o==`number`?r[n]:o.encode(r[n]);Fu(c,s),i.set(c,a),typeof o!=`number`&&c.fill(0),a+=s}return i},decode:r=>{Fu(r,n);let i=[];for(let n of e){let e=t(n),a=r.subarray(0,e);i.push(typeof n==`number`?a:n.decode(a)),r=r.subarray(e)}return i}}}function zu(e,t){let n=t*e.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==t)throw Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${t}`);let i=new Uint8Array(n);for(let t=0,n=0;t<r.length;t++){let a=e.encode(r[t]);i.set(a,n),a.fill(0),n+=a.length}return i},decode:t=>{Fu(t,n);let r=[];for(let n=0;n<t.length;n+=e.bytesLen)r.push(e.decode(t.subarray(n,n+e.bytesLen)));return r}}}function Bu(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function Vu(e){return(1<<e)-1}var Hu=new Uint8Array;function Uu(e,t=Hu){if(Fu(e),Fu(t),t.length>255)throw Error(`context should be less than 255 bytes`);return Ks(new Uint8Array([0,t.length]),t,e)}var Wu={"SHA2-256":{oid:Hs(`0609608648016503040201`),hash:Kc},"SHA2-384":{oid:Hs(`0609608648016503040202`),hash:Yc},"SHA2-512":{oid:Hs(`0609608648016503040203`),hash:Jc},"SHA2-224":{oid:Hs(`0609608648016503040204`),hash:qc},"SHA2-512/224":{oid:Hs(`0609608648016503040205`),hash:Zc},"SHA2-512/256":{oid:Hs(`0609608648016503040206`),hash:Xc},"SHA3-224":{oid:Hs(`0609608648016503040207`),hash:Ou},"SHA3-256":{oid:Hs(`0609608648016503040208`),hash:ku},"SHA3-384":{oid:Hs(`0609608648016503040209`),hash:Au},"SHA3-512":{oid:Hs(`060960864801650304020A`),hash:ju},"SHAKE-128":{oid:Hs(`060960864801650304020B`),hash:e=>Nu(e,{dkLen:32})},"SHAKE-256":{oid:Hs(`060960864801650304020C`),hash:e=>Pu(e,{dkLen:64})}};function Gu(e,t,n=Hu){if(Fu(t),Fu(n),n.length>255)throw Error(`context should be less than 255 bytes`);if(!Wu[e])throw Error(`unknown hash: `+e);let{oid:r,hash:i}=Wu[e],a=i(t);return Ks(new Uint8Array([1,n.length]),n,r,a)}function Ku(e,t=8){let n=e.toString(2).padStart(8,`0`).slice(-t).padStart(7,`0`).split(``).reverse().join(``);return Number.parseInt(n,2)}var qu=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Ku(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=s?128:n,p=+!!s;return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>{for(let t=1,r=128;r>p;r>>=1)for(let i=0;i<n;i+=2*r){let n=d[t++];for(let t=i;t<i+r;t++){let i=c(n*e[t+r]);e[t+r]=c(e[t]-i)|0,e[t]=c(e[t]+i)|0}}return e},decode:e=>{for(let t=f-1,r=1+p;r<f+p;r<<=1)for(let i=0;i<n;i+=2*r){let n=d[t--];for(let t=i;t<i+r;t++){let i=e[t];e[t]=c(i+e[t+r]),e[t+r]=c(n*(e[t+r]-i))}}for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}},bitsCoder:(e,r)=>{let i=Vu(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=new Uint8Array(a);for(let a=0,o=0,s=0,c=0;a<t.length;a++)for(o|=(r.encode(t[a])&i)<<s,s+=e;s>=8;s-=8,o>>=8)n[c++]=o&Vu(s);return n},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},Ju=e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),a.fill(0),r.fill(0)}}},Yu=Ju(Nu),Xu=Ju(Pu),Zu=256,Qu=8380417,$u=1753,ed=8347681,td=13,nd=Math.floor((Qu-1)/88)|0,rd=Math.floor((Qu-1)/32)|0,id={2:{K:4,L:4,D:td,GAMMA1:2**17,GAMMA2:nd,TAU:39,ETA:2,OMEGA:80},3:{K:6,L:5,D:td,GAMMA1:2**19,GAMMA2:rd,TAU:49,ETA:4,OMEGA:55},5:{K:8,L:7,D:td,GAMMA1:2**19,GAMMA2:rd,TAU:60,ETA:2,OMEGA:75}},ad=e=>new Int32Array(e),{mod:od,smod:sd,NTT:cd,bitsCoder:ld}=qu({N:Zu,Q:Qu,F:ed,ROOT_OF_UNITY:$u,newPoly:ad,isKyber:!1,brvBits:8}),ud=e=>e,dd=(e,t=ud,n=ud)=>ld(e,{encode:e=>t(n(e)),decode:e=>n(t(e))}),fd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=od(e[n]+t[n]);return e},pd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=od(e[n]-t[n]);return e},md=e=>{for(let t=0;t<Zu;t++)e[t]<<=td;return e},hd=(e,t)=>{for(let n=0;n<Zu;n++)if(Math.abs(sd(e[n]))>=t)return!0;return!1},gd=(e,t)=>{let n=ad(Zu);for(let r=0;r<e.length;r++)n[r]=od(e[r]*t[r]);return n};function _d(e){let t=ad(Zu);for(let n=0;n<Zu;){let r=e();if(r.length%3)throw Error(`RejNTTPoly: unaligned block`);for(let e=0;n<Zu&&e<=r.length-3;e+=3){let i=(r[e+0]|r[e+1]<<8|r[e+2]<<16)&8388607;i<Qu&&(t[n++]=i)}}return t}function vd(e){let{K:t,L:n,GAMMA1:r,GAMMA2:i,TAU:a,ETA:o,OMEGA:s}=e,{CRH_BYTES:c,TR_BYTES:l,C_TILDE_BYTES:u,XOF128:d,XOF256:f}=e;if(![2,4].includes(o))throw Error(`Wrong ETA`);if(![1<<17,1<<19].includes(r))throw Error(`Wrong GAMMA1`);if(![nd,rd].includes(i))throw Error(`Wrong GAMMA2`);let p=a*o,m=e=>{let t=od(e),n=sd(t,2*i)|0;return t-n===Qu-1?{r1:0,r0:n-1|0}:{r1:Math.floor((t-n)/(2*i))|0,r0:n}},h=e=>m(e).r1,g=e=>m(e).r0,_=(e,t)=>e<=i||e>Qu-i||e===Qu-i&&t===0?0:1,v=(e,t)=>{let n=Math.floor((Qu-1)/(2*i)),{r1:r,r0:a}=m(t);return e===1?a>0?od(r+1,n)|0:od(r-1,n)|0:r|0},y=e=>{let t=od(e),n=sd(t,2**td)|0;return{r1:Math.floor((t-n)/2**td)|0,r0:n}},b={bytesLen:s+t,encode:e=>{if(e===!1)throw Error(`hint.encode: hint is false`);let n=new Uint8Array(s+t);for(let r=0,i=0;r<t;r++){for(let t=0;t<Zu;t++)e[r][t]!==0&&(n[i++]=t);n[s+r]=i}return n},decode:e=>{let n=[],r=0;for(let i=0;i<t;i++){let t=ad(Zu);if(e[s+i]<r||e[s+i]>s)return!1;for(let n=r;n<e[s+i];n++){if(n>r&&e[n]<=e[n-1])return!1;t[e[n]]=1}r=e[s+i],n.push(t)}for(let t=r;t<s;t++)if(e[t]!==0)return!1;return n}},ee=dd(o===2?3:4,e=>o-e,e=>{if(!(-o<=e&&e<=o))throw Error(`malformed key s1/s3 ${e} outside of ETA range [${-o}, ${o}]`);return e}),x=dd(13,e=>(1<<td-1)-e),te=dd(10),S=dd(r===1<<17?18:20,e=>sd(r-e)),ne=zu(dd(i===nd?6:4),t),re=Ru(32,zu(te,t)),ie=Ru(32,32,l,zu(ee,n),zu(ee,t),zu(x,t)),ae=Ru(u,zu(S,n),b),oe=o===2?e=>e<15?2-e%5:!1:e=>e<9?4-e:!1;function se(e){let t=ad(Zu);for(let n=0;n<Zu;){let r=e();for(let e=0;n<Zu&&e<r.length;e+=1){let i=oe(r[e]&15),a=oe(r[e]>>4&15);i!==!1&&(t[n++]=i),n<Zu&&a!==!1&&(t[n++]=a)}}return t}let ce=e=>{let t=ad(Zu),n=Pu.create({}).update(e),r=new Uint8Array(Pu.blockLen);n.xofInto(r);let i=r.slice(0,8);for(let e=Zu-a,o=8,s=0,c=0;e<Zu;e++){let a=e+1;for(;a>e;)a=r[o++],!(o<Pu.blockLen)&&(n.xofInto(r),o=0);t[e]=t[a],t[a]=1-((i[s]>>c++&1)<<1),c>=8&&(s++,c=0)}return t},C=e=>{let t=ad(Zu),n=ad(Zu);for(let r=0;r<e.length;r++){let{r0:i,r1:a}=y(e[r]);t[r]=i,n[r]=a}return{r0:t,r1:n}},le=(e,t)=>{for(let n=0;n<Zu;n++)e[n]=v(t[n],e[n]);return e},ue=(e,t)=>{let n=ad(Zu),r=0;for(let i=0;i<Zu;i++){let a=_(e[i],t[i]);n[i]=a,r+=a}return{v:n,cnt:r}},de=Ru(32,64,32),fe={signRandBytes:32,keygen:e=>{let r=new Uint8Array(34),i=e===void 0;i&&(e=Iu(32)),Fu(e,32),r.set(e),i&&e.fill(0),r[32]=t,r[33]=n;let[a,o,s]=de.decode(Pu(r,{dkLen:de.bytesLen})),c=f(o),u=[];for(let e=0;e<n;e++)u.push(se(c.get(e&255,e>>8&255)));let p=[];for(let e=n;e<n+t;e++)p.push(se(c.get(e&255,e>>8&255)));let m=u.map(e=>cd.encode(e.slice())),h=[],g=[],_=d(a),v=ad(Zu);for(let e=0;e<t;e++){v.fill(0);for(let t=0;t<n;t++)fd(v,gd(_d(_.get(t,e)),m[t]));cd.decode(v);let{r0:t,r1:r}=C(fd(v,p[e]));h.push(t),g.push(r)}let y=re.encode([a,g]),b=Pu(y,{dkLen:l}),ee=ie.encode([a,s,b,u,p,h]);return _.clean(),c.clean(),Bu(a,o,s,u,p,m,v,h,g,b,r),{publicKey:y,secretKey:ee}},sign:(e,a,o,l=!1)=>{let[m,_,v,y,b,ee]=ie.decode(e),x=[],te=d(m);for(let e=0;e<t;e++){let t=[];for(let r=0;r<n;r++)t.push(_d(te.get(r,e)));x.push(t)}te.clean();for(let e=0;e<n;e++)cd.encode(y[e]);for(let e=0;e<t;e++)cd.encode(b[e]),cd.encode(ee[e]);let re=l?a:Pu.create({dkLen:c}).update(v).update(a).digest(),oe=o||new Uint8Array(32);Fu(oe);let se=Pu.create({dkLen:c}).update(_).update(oe).update(re).digest();Fu(se,c);let C=f(se,S.bytesLen);main_loop:for(let e=0;;){let a=[];for(let t=0;t<n;t++,e++)a.push(S.decode(C.get(e&255,e>>8)()));let o=a.map(e=>cd.encode(e.slice())),c=[];for(let e=0;e<t;e++){let t=ad(Zu);for(let r=0;r<n;r++)fd(t,gd(x[e][r],o[r]));cd.decode(t),c.push(t)}let l=c.map(e=>e.map(h)),d=Pu.create({dkLen:u}).update(re).update(ne.encode(l)).digest(),f=cd.encode(ce(d)),m=y.map(e=>gd(e,f));for(let e=0;e<n;e++)if(fd(cd.decode(m[e]),a[e]),hd(m[e],r-p))continue main_loop;let _=0,v=[];for(let e=0;e<t;e++){let t=cd.decode(gd(b[e],f)),n=pd(c[e],t).map(g);if(hd(n,i-p))continue main_loop;let r=cd.decode(gd(ee[e],f));if(hd(r,i))continue main_loop;fd(n,r);let a=ue(n,l[e]);v.push(a.v),_+=a.cnt}if(_>s)continue;C.clean();let te=ae.encode([d,m,v]);return Bu(d,m,v,f,l,c,o,a,se,re,y,b,ee,...x),te}throw Error(`Unreachable code path reached, report this error`)},verify:(e,i,a,o=!1)=>{let[f,m]=re.decode(e),h=Pu(e,{dkLen:l});if(a.length!==ae.bytesLen)return!1;let[g,_,v]=ae.decode(a);if(v===!1)return!1;for(let e=0;e<n;e++)if(hd(_[e],r-p))return!1;let y=o?i:Pu.create({dkLen:c}).update(h).update(i).digest(),b=cd.encode(ce(g)),ee=_.map(e=>e.slice());for(let e=0;e<n;e++)cd.encode(ee[e]);let x=[],te=d(f);for(let e=0;e<t;e++){let t=gd(cd.encode(md(m[e])),b),r=ad(Zu);for(let t=0;t<n;t++)fd(r,gd(_d(te.get(t,e)),ee[t]));let i=cd.decode(pd(r,t));x.push(le(i,v[e]))}te.clean();let S=Pu.create({dkLen:u}).update(y).update(ne.encode(x)).digest();for(let e of v)if(!(e.reduce((e,t)=>e+t,0)<=s))return!1;for(let e of _)if(hd(e,r-p))return!1;return Lu(g,S)}};return{internal:fe,keygen:fe.keygen,signRandBytes:fe.signRandBytes,sign:(e,t,n=Hu,r)=>{let i=Uu(t,n),a=fe.sign(e,i,r);return i.fill(0),a},verify:(e,t,n,r=Hu)=>fe.verify(e,Uu(t,r),n),prehash:e=>({sign:(t,n,r=Hu,i)=>{let a=Gu(e,n,r),o=fe.sign(t,a,i);return a.fill(0),o},verify:(t,n,r,i=Hu)=>fe.verify(t,Gu(e,n,i),r)})}}({...id[2]});var yd=vd({...id[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:Yu,XOF256:Xu});({...id[5]});var bd={generateKeyPair:xd,sign:Sd,verify:Cd};function xd(e){e??=Iu(32);let t=yd.keygen(e);return{publicKey:t.publicKey,privateKey:t.secretKey}}function Sd(e,t){return yd.sign(e,t)}function Cd(e,t,n){return yd.verify(e,t,n)}var wd=256,Td=3329,{mod:Ed,nttZetas:Dd,NTT:Od,bitsCoder:kd}=qu({N:wd,Q:Td,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),Ad={512:{N:wd,Q:Td,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:wd,Q:Td,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:wd,Q:Td,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},jd=e=>{if(e>=12)return{encode:e=>e,decode:e=>e};let t=2**(e-1);return{encode:t=>((t<<e)+Td/2)/Td,decode:n=>n*Td+t>>>e}},Md=e=>kd(e,jd(e));function Nd(e,t){for(let n=0;n<wd;n++)e[n]=Ed(e[n]+t[n])}function Pd(e,t){for(let n=0;n<wd;n++)e[n]=Ed(e[n]-t[n])}function Fd(e,t,n,r,i){return{c0:Ed(t*r*i+e*n),c1:Ed(e*r+t*n)}}function Id(e,t){for(let n=0;n<wd/2;n++){let r=Dd[64+(n>>1)];n&1&&(r=-r);let{c0:i,c1:a}=Fd(e[2*n+0],e[2*n+1],t[2*n+0],t[2*n+1],r);e[2*n+0]=i,e[2*n+1]=a}return e}function Ld(e){let t=new Uint16Array(wd);for(let n=0;n<wd;){let r=e();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let e=0;n<wd&&e+3<=r.length;e+=3){let i=(r[e+0]>>0|r[e+1]<<8)&4095,a=(r[e+1]>>4|r[e+2]<<4)&4095;i<Td&&(t[n++]=i),n<wd&&a<Td&&(t[n++]=a)}}return t}function Rd(e,t,n,r){let i=e(r*wd/4,t,n),a=new Uint16Array(wd),o=As(i),s=0;for(let e=0,t=0,n=0,i=0;e<o.length;e++){let c=o[e];for(let e=0;e<32;e++)n+=c&1,c>>=1,s+=1,s===r?(i=n,n=0):s===2*r&&(a[t++]=Ed(i-n),n=0,s=0)}if(s)throw Error(`sampleCBD: leftover bits: ${s}`);return a}var zd=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=Md(1),u=Md(c),d=Md(s),f=Ru(zu(Md(12),t),32),p=zu(Md(12),t),m=Ru(zu(d,t),u),h=Ru(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:f.bytesLen,cipherTextLen:m.bytesLen,keygen:e=>{Fu(e,32);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(Od.encode(Rd(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=Od.encode(Rd(n,l,t+e,a));for(let n=0;n<t;n++)Nd(r,Id(Ld(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return Bu(c,l,u,d,o,s),g},encrypt:(e,i,s)=>{let[c,u]=f.decode(e),d=[];for(let e=0;e<t;e++)d.push(Od.encode(Rd(n,s,e,a)));let p=r(u),h=new Uint16Array(wd),g=[];for(let e=0;e<t;e++){let r=Rd(n,s,t+e,o),i=new Uint16Array(wd);for(let n=0;n<t;n++)Nd(i,Id(Ld(p.get(e,n)),d[n]));Nd(r,Od.decode(i)),g.push(r),Nd(h,Id(c[e],d[e])),i.fill(0)}p.clean();let _=Rd(n,s,2*t,o);Nd(_,Od.decode(h));let v=l.decode(i);return Nd(v,_),Bu(c,d,h,_),m.encode([g,v])},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(wd);for(let e=0;e<t;e++)Nd(o,Id(a[e],Od.encode(r[e])));return Pd(i,Od.decode(o)),Bu(o,a,r),l.encode(i)}}};function Bd(e){let t=zd(e),{HASH256:n,HASH512:r,KDF:i}=e,{secretCoder:a,cipherTextLen:o}=t,s=t.publicKeyLen,c=Ru(t.secretKeyLen,t.publicKeyLen,32,32),l=c.bytesLen;return{publicKeyLen:s,msgLen:32,keygen:(e=Iu(64))=>{Fu(e,64);let{publicKey:r,secretKey:i}=t.keygen(e.subarray(0,32)),a=n(r),o=c.encode([i,r,a,e.subarray(32)]);return Bu(i,a),{publicKey:r,secretKey:o}},encapsulate:(i,o=Iu(32))=>{Fu(i,s),Fu(o,32);let c=i.subarray(0,384*e.K),l=a.encode(a.decode(c.slice()));if(!Lu(l,c))throw Bu(l),Error(`ML-KEM.encapsulate: wrong publicKey modulus`);Bu(l);let u=r.create().update(o).update(n(i)).digest(),d=t.encrypt(i,o,u.subarray(32,64));return u.subarray(32).fill(0),{cipherText:d,sharedSecret:u.subarray(0,32)}},decapsulate:(e,n)=>{Fu(n,l),Fu(e,o);let[a,s,u,d]=c.decode(n),f=t.decrypt(e,a),p=r.create().update(f).update(u).digest(),m=p.subarray(0,32),h=t.encrypt(s,f,p.subarray(32,64)),g=Lu(e,h),_=i.create({dkLen:32}).update(d).update(e).digest();return Bu(f,h,g?_:m),g?m:_}}}function Vd(e,t,n){return Pu.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Hd={HASH256:ku,HASH512:ju,KDF:Pu,XOF:Yu,PRF:Vd};({...Hd,...Ad[512]});var Ud=Bd({...Hd,...Ad[768]});({...Hd,...Ad[1024]});var Wd={generateKeyPair:Gd,encapsulate:Kd,decapsulate:qd};function Gd(e){return e??=Iu(64),Ud.keygen(e)}function Kd(e){return Ud.encapsulate(e)}function qd(e,t){return Ud.decapsulate(e,t)}var Jd=Kc,Yd=class extends Js{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ds(e);let n=Ws(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),js(i)}update(e){return Os(this),this.iHash.update(e),this}digestInto(e){Os(this),Es(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xd=(e,t,n)=>new Yd(e,t).update(n).digest();Xd.create=(e,t)=>new Yd(e,t);var{p:Zd,n:Qd,Gx:$d,Gy:ef,b:tf}={p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n},nf=32,rf=64,af=(e=``)=>{throw Error(e)},of=e=>typeof e==`bigint`,sf=e=>typeof e==`string`,cf=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,lf=(e,t)=>!cf(e)||typeof t==`number`&&t>0&&e.length!==t?af(`Uint8Array expected`):e,uf=e=>new Uint8Array(e),df=e=>Uint8Array.from(e),ff=(e,t)=>e.toString(16).padStart(t,`0`),pf=e=>Array.from(lf(e)).map(e=>ff(e,2)).join(``),mf={_0:48,_9:57,A:65,F:70,a:97,f:102},hf=e=>{if(e>=mf._0&&e<=mf._9)return e-mf._0;if(e>=mf.A&&e<=mf.F)return e-(mf.A-10);if(e>=mf.a&&e<=mf.f)return e-(mf.a-10)},gf=e=>{let t=`hex invalid`;if(!sf(e))return af(t);let n=e.length,r=n/2;if(n%2)return af(t);let i=uf(r);for(let n=0,a=0;n<r;n++,a+=2){let r=hf(e.charCodeAt(a)),o=hf(e.charCodeAt(a+1));if(r===void 0||o===void 0)return af(t);i[n]=r*16+o}return i},_f=(e,t)=>lf(sf(e)?gf(e):df(lf(e)),t),vf=()=>globalThis?.crypto,yf=()=>vf()?.subtle??af(`crypto.subtle must be defined`),bf=(...e)=>{let t=uf(e.reduce((e,t)=>e+lf(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},xf=(e=nf)=>vf().getRandomValues(uf(e)),Sf=BigInt,Cf=(e,t,n,r=`bad number: out of range`)=>of(e)&&t<=e&&e<n?e:af(r),A=(e,t=Zd)=>{let n=e%t;return n>=0n?n:t+n},wf=e=>A(e,Qd),Tf=(e,t)=>{(e===0n||t<=0n)&&af(`no inverse n=`+e+` mod=`+t);let n=A(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?A(i,t):af(`no inverse`)},Ef=e=>{let t=op[e];return typeof t!=`function`&&af(`hashes.`+e+` not set`),t},Df=e=>e instanceof If?e:af(`Point expected`),Of=e=>A(A(e*e)*e+tf),kf=e=>Cf(e,0n,Zd),Af=e=>Cf(e,1n,Zd),jf=e=>Cf(e,1n,Qd),Mf=e=>(e&1n)==0n,Nf=e=>Uint8Array.of(e),Pf=e=>Nf(Mf(e)?2:3),Ff=e=>{let t=Of(Af(e)),n=1n;for(let e=t,r=(Zd+1n)/4n;r>0n;r>>=1n)r&1n&&(n=n*e%Zd),e=e*e%Zd;return A(n*n)===t?n:af(`sqrt invalid`)},If=class e{static BASE;static ZERO;px;py;pz;constructor(e,t,n){this.px=kf(e),this.py=Af(t),this.pz=kf(n),Object.freeze(this)}static fromBytes(t){lf(t);let n,r=t[0],i=t.subarray(1),a=Vf(i,0,nf),o=t.length;if(o===nf+1&&[2,3].includes(r)){let t=Ff(a),i=Mf(t);Mf(Sf(r))!==i&&(t=A(-t)),n=new e(a,t,1n)}return o===rf+1&&r===4&&(n=new e(a,Vf(i,nf,rf),1n)),n?n.assertValidity():af(`bad point: not on curve`)}equals(e){let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:o}=Df(e),s=A(t*o),c=A(i*r),l=A(n*o),u=A(a*r);return s===c&&l===u}is0(){return this.equals(Rf)}negate(){return new e(this.px,A(-this.py),this.pz)}double(){return this.add(this)}add(t){let{px:n,py:r,pz:i}=this,{px:a,py:o,pz:s}=Df(t),c=0n,l=tf,u=0n,d=0n,f=0n,p=A(l*3n),m=A(n*a),h=A(r*o),g=A(i*s),_=A(n+r),v=A(a+o);_=A(_*v),v=A(m+h),_=A(_-v),v=A(n+i);let y=A(a+s);return v=A(v*y),y=A(m+g),v=A(v-y),y=A(r+i),u=A(o+s),y=A(y*u),u=A(h+g),y=A(y-u),f=A(c*v),u=A(p*g),f=A(u+f),u=A(h-f),f=A(h+f),d=A(u*f),h=A(m+m),h=A(h+m),g=A(c*g),v=A(p*v),h=A(h+g),g=A(m-g),g=A(c*g),v=A(v+g),m=A(h*v),d=A(d+m),m=A(y*v),u=A(_*u),u=A(u-m),m=A(_*h),f=A(y*f),f=A(f+m),new e(u,d,f)}multiply(e,t=!0){if(!t&&e===0n)return Rf;if(jf(e),e===1n)return this;if(this.equals(Lf))return mp(e).p;let n=Rf,r=Lf;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}toAffine(){let{px:e,py:t,pz:n}=this;if(this.equals(Rf))return{x:0n,y:0n};if(n===1n)return{x:e,y:t};let r=Tf(n,Zd);return A(n*r)!==1n&&af(`inverse invalid`),{x:A(e*r),y:A(t*r)}}assertValidity(){let{x:e,y:t}=this.toAffine();return Af(e),Af(t),A(t*t)===Of(e)?this:af(`bad point: not on curve`)}toBytes(e=!0){let{x:t,y:n}=this.assertValidity().toAffine(),r=Uf(t);return e?bf(Pf(n),r):bf(Nf(4),r,Uf(n))}static fromAffine(t){let{x:n,y:r}=t;return n===0n&&r===0n?Rf:new e(n,r,1n)}toHex(e){return pf(this.toBytes(e))}static fromPrivateKey(e){return Lf.multiply(Wf(e))}static fromHex(t){return e.fromBytes(_f(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}},Lf=new If($d,ef,1n),Rf=new If(0n,1n,0n);If.BASE=Lf,If.ZERO=Rf;var zf=(e,t,n)=>Lf.multiply(t,!1).add(e.multiply(n,!1)).assertValidity(),Bf=e=>Sf(`0x`+(pf(e)||`0`)),Vf=(e,t,n)=>Bf(e.subarray(t,n)),Hf=2n**256n,Uf=e=>gf(ff(Cf(e,0n,Hf),rf)),Wf=e=>Cf(of(e)?e:Bf(_f(e,nf)),1n,Qd,`private key invalid 3`),Gf=e=>e>Qd>>1n,Kf=(e,t=!0)=>Lf.multiply(Wf(e)).toBytes(t),qf=class e{r;s;recovery;constructor(e,t,n){this.r=jf(e),this.s=jf(t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(t){return lf(t,rf),new e(Vf(t,0,nf),Vf(t,nf,rf))}toBytes(){let{r:e,s:t}=this;return bf(Uf(e),Uf(t))}addRecoveryBit(t){return new e(this.r,this.s,t)}hasHighS(){return Gf(this.s)}toCompactRawBytes(){return this.toBytes()}toCompactHex(){return pf(this.toBytes())}recoverPublicKey(e){return np(this,e)}static fromCompact(t){return e.fromBytes(_f(t,rf))}assertValidity(){return this}normalizeS(){let{r:t,s:n,recovery:r}=this;return Gf(n)?new e(t,wf(-n),r):this}},Jf=e=>{let t=e.length*8-256;t>1024&&af(`msg invalid`);let n=Bf(e);return t>0?n>>Sf(t):n},Yf=e=>wf(Jf(lf(e))),Xf={lowS:!0},Zf={lowS:!0},Qf=(e,t,n=Xf)=>{[`der`,`recovered`,`canonical`].some(e=>e in n)&&af(`option not supported`);let{lowS:r,extraEntropy:i}=n;r??=!0;let a=Uf,o=Yf(_f(e)),s=a(o),c=Wf(t),l=[a(c),s];i&&l.push(i===!0?xf(nf):_f(i));let u=o,d=e=>{let t=Jf(e);if(!(1n<=t&&t<Qd))return;let n=Lf.multiply(t).toAffine(),i=wf(n.x);if(i===0n)return;let a=wf(Tf(t,Qd)*wf(u+wf(c*i)));if(a===0n)return;let o=a,s=(n.x===i?0:2)|Number(n.y&1n);return r&&Gf(a)&&(o=wf(-a),s^=1),new qf(i,o,s)};return{seed:bf(...l),k2sig:d}},$f=e=>{let t=uf(nf),n=uf(nf),r=0,i=uf(0),a=()=>{t.fill(1),n.fill(0),r=0},o=1e3,s=`drbg: tried 1000 values`;if(e){let e=(...e)=>op.hmacSha256Async(n,t,...e),c=async(r=i)=>{n=await e(Nf(0),r),t=await e(),r.length!==0&&(n=await e(Nf(1),r),t=await e())},l=async()=>(r++>=o&&af(s),t=await e(),t);return async(e,t)=>{a(),await c(e);let n;for(;!(n=t(await l()));)await c();return a(),n}}else{let e=(...e)=>Ef(`hmacSha256Sync`)(n,t,...e),c=(r=i)=>{n=e(Nf(0),r),t=e(),r.length!==0&&(n=e(Nf(1),r),t=e())},l=()=>(r++>=o&&af(s),t=e(),t);return(e,t)=>{a(),c(e);let n;for(;!(n=t(l()));)c();return a(),n}}},ep=(e,t,n=Xf)=>{let{seed:r,k2sig:i}=Qf(e,t,n);return $f(!1)(r,i)},tp=(e,t,n,r=Zf)=>{let{lowS:i}=r;i??=!0,`strict`in r&&af(`option not supported`);let a,o=e&&typeof e==`object`&&`r`in e;!o&&_f(e).length!==rf&&af(`signature must be 64 bytes`);try{a=o?new qf(e.r,e.s):qf.fromCompact(e);let r=Yf(_f(t)),s=If.fromBytes(_f(n)),{r:c,s:l}=a;if(i&&Gf(l))return!1;let u=Tf(l,Qd);return wf(zf(s,wf(r*u),wf(c*u)).toAffine().x)===c}catch{return!1}},np=(e,t)=>{let{r:n,s:r,recovery:i}=e;[0,1,2,3].includes(i)||af(`recovery id invalid`);let a=Yf(_f(t,nf)),o=i===2||i===3?n+Qd:n;Af(o);let s=bf(Pf(Sf(i)),Uf(o)),c=If.fromBytes(s),l=Tf(o,Qd);return zf(c,wf(-a*l),wf(r*l))},rp=e=>(e=_f(e),(e.length<nf+8||e.length>1024)&&af(`expected 40-1024b`),Uf(A(Bf(e),Qd-1n)+1n)),ip=()=>rp(xf(nf+16)),ap=`SHA-256`,op={hexToBytes:gf,bytesToHex:pf,concatBytes:bf,bytesToNumberBE:Bf,numberToBytesBE:Uf,mod:A,invert:Tf,hmacSha256Async:async(e,...t)=>{let n=yf(),r=`HMAC`,i=await n.importKey(`raw`,e,{name:r,hash:{name:ap}},!1,[`sign`]);return uf(await n.sign(r,i,bf(...t)))},hmacSha256Sync:void 0,hashToPrivateKey:rp,randomBytes:xf},sp={normPrivateKeyToScalar:Wf,isValidPrivateKey:e=>{try{return!!Wf(e)}catch{return!1}},randomPrivateKey:ip,precompute:(e=8,t=Lf)=>(t.multiply(3n),t)},cp=8,lp=Math.ceil(256/cp)+1,up=2**(cp-1),dp=()=>{let e=[],t=Lf,n=t;for(let r=0;r<lp;r++){n=t,e.push(n);for(let r=1;r<up;r++)n=n.add(t),e.push(n);t=n.double()}return e},fp=void 0,pp=(e,t)=>{let n=t.negate();return e?n:t},mp=e=>{let t=fp||=dp(),n=Rf,r=Lf,i=2**cp,a=i,o=Sf(i-1),s=Sf(cp);for(let i=0;i<lp;i++){let c=Number(e&o);e>>=s,c>up&&(c-=a,e+=1n);let l=i*up,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(pp(f,t[u])):n=n.add(pp(p,t[d]))}return{p:n,f:r}};op.hmacSha256Sync=(e,...t)=>Xd(Jd,e,op.concatBytes(...t));var hp={publicKeyFromPrivateKey:gp,sign:_p,verify:vp};function gp(e){return Kf(e)}function _p(e,t){return ep(Jd(t),e).toCompactRawBytes()}function vp(e,t,n){return tp(n,Jd(t),e)}var yp={SECP256K1:0,ML_DSA:1},bp=[{name:`SECP256K1`,signatureSectionSize:65},{name:`ML_DSA`,signatureSectionSize:3311}],xp={ML_KEM:0},Sp=[{name:`ML-KEM`}],j={...yp,SIG_SCHEMES:bp,...xp,KEM_SCHEMES:Sp,Random:Qs,Hashes:$c,Aes:cu,MLDsa:bd,MLKem:Wd,Secp256k1:hp},Cp;function wp(e){return{lang:e?.lang??Cp?.lang,message:e?.message,abortEarly:e?.abortEarly??Cp?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Cp?.abortPipeEarly}}var Tp;function Ep(e){return Tp?.get(e)}var Dp;function Op(e){return Dp?.get(e)}var kp;function Ap(e,t){return kp?.get(e)?.get(t)}function jp(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function Mp(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??jp(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Ap(e.reference,c.lang)??(l?Op(c.lang):null)??r.message??Ep(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Np(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},wp())}}}function Pp(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Fp(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ip=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Lp(e){return{kind:`validation`,type:`integer`,reference:Lp,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Mp(this,`integer`,e,t),e}}}function Rp(e,t){return{kind:`validation`,type:`max_length`,reference:Rp,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Mp(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function zp(e,t){return{kind:`validation`,type:`max_value`,reference:zp,async:!1,expects:`<=${e instanceof Date?e.toJSON():jp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&Mp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():jp(e.value)}),e}}}function Bp(e){return{kind:`metadata`,type:`metadata`,reference:Bp,metadata:e}}function Vp(e,t){return{kind:`validation`,type:`min_value`,reference:Vp,async:!1,expects:`>=${e instanceof Date?e.toJSON():jp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Mp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():jp(e.value)}),e}}}function Hp(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Up(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Wp(e,t){return!e[`~run`]({value:t},{abortEarly:!0}).issues}function Gp(){return{kind:`schema`,type:`any`,reference:Gp,expects:`any`,async:!1,get"~standard"(){return Np(this)},"~run"(e){return e.typed=!0,e}}}function M(e,t){return{kind:`schema`,type:`array`,reference:M,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else Mp(this,`type`,e,t);return e}}}function Kp(e){return{kind:`schema`,type:`boolean`,reference:Kp,expects:`boolean`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Mp(this,`type`,e,t),e}}}function qp(e,t){return{kind:`schema`,type:`custom`,reference:qp,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function Jp(e,t){return{kind:`schema`,type:`instance`,reference:Jp,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:Mp(this,`type`,e,t),e}}}function Yp(e){return{kind:`schema`,type:`lazy`,reference:Yp,expects:`unknown`,async:!1,getter:e,get"~standard"(){return Np(this)},"~run"(e,t){return this.getter(e.value)[`~run`](e,t)}}}function N(e,t){return{kind:`schema`,type:`literal`,reference:N,expects:jp(e),async:!1,literal:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Mp(this,`type`,e,t),e}}}function Xp(e){return{kind:`schema`,type:`null`,reference:Xp,expects:`null`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===null?e.typed=!0:Mp(this,`type`,e,t),e}}}function P(e){return{kind:`schema`,type:`number`,reference:P,expects:`number`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function F(e,t){return{kind:`schema`,type:`object`,reference:F,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Up(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Hp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Mp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else Mp(this,`type`,e,t);return e}}}function Zp(e,t,n){return{kind:`schema`,type:`object_with_rest`,reference:Zp,expects:`Object`,async:!1,entries:e,rest:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Up(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Hp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Mp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(Pp(n,r)&&!(r in this.entries)){let i=this.rest[`~run`]({value:n[r]},t);if(i.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:n[r]};for(let t of i.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=i.issues,t.abortEarly){e.typed=!1;break}}i.typed||(e.typed=!1),e.value[r]=i.value}}}else Mp(this,`type`,e,t);return e}}}function Qp(e,t){return{kind:`schema`,type:`optional`,reference:Qp,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Up(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function $p(e,t){return{kind:`schema`,type:`picklist`,reference:$p,expects:Fp(e.map(jp),`|`),async:!1,options:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function em(e,t,n){return{kind:`schema`,type:`record`,reference:em,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Pp(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else Mp(this,`type`,e,t);return e}}}function I(e){return{kind:`schema`,type:`string`,reference:I,expects:`string`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Mp(this,`type`,e,t),e}}}function tm(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function nm(e,t){return{kind:`schema`,type:`union`,reference:nm,expects:Fp(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];Mp(this,`type`,e,t,{issues:tm(r)}),e.typed=!0}else if(i?.length===1)return i[0];else Mp(this,`type`,e,t,{issues:tm(i)});return e}}}function rm(){return{kind:`schema`,type:`unknown`,reference:rm,expects:`unknown`,async:!1,get"~standard"(){return Np(this)},"~run"(e){return e.typed=!0,e}}}function im(e,t,n){return{kind:`schema`,type:`variant`,reference:im,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;Mp(this,`type`,e,t,{input:n[a],expected:Fp(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else Mp(this,`type`,e,t);return e}}}function L(e,t,n){let r=e[`~run`]({value:t},wp(n));if(r.issues)throw new Ip(r.issues);return r.value}function R(...e){return{...e[0],pipe:e,get"~standard"(){return Np(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function am(e,t,n){let r=e[`~run`]({value:t},wp(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var om=0,sm=1,cm=2,lm=3,um=4,dm=5,fm=6,pm=7,mm=8,hm=9,gm=10,_m=11,vm=12,ym=13;function bm(e){return R(M(e.items),Bp({typeId:0,elementSchema:e.items,...e}))}function xm(e={}){let t=e&&e.size||-1;return R(I(),qp(e=>typeof e==`string`&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Bp({typeId:2,size:t,...e}))}function z(e={}){return R(P(),Bp({typeId:3,...e}))}function Sm(e={}){return R(Kp(),Bp({typeId:4,...e}))}function Cm(e,t,n){return R(P(),Lp(),Vp(0),zp(2**t-1),Bp({typeId:e,...n}))}function wm(e={}){return Cm(6,8,e)}function Tm(e={}){return Cm(7,16,e)}function Em(e={}){return Cm(8,24,e)}function Dm(e={}){return Cm(9,32,e)}function Om(e={}){return Cm(10,48,e)}function km(e={}){let t=e&&e.size||-1;return R(Jp(Uint8Array),qp(e=>e instanceof Uint8Array&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Bp({typeId:11,...e}))}function Am(e={}){return R(Jp(Uint8Array),qp(e=>e instanceof Uint8Array&&e.length===32,`Expected Uint8Array of 32 bytes`),Bp({typeId:12,...e}))}function B(){return Jp(Uint8Array)}function jm(){return B()}function Mm(){return R(P(),Vp(0))}var Nm=F({magicString:N(Hn),protocolVersion:P(),microblockType:P(),height:P(),previousHash:B(),timestamp:P(),maxFees:P(),gasPrice:P(),bodyHash:B(),feesPayerAccount:B()}),Pm=F({pricingRate:P(),maximumNumberOfDays:P()}),Fm=M(Pm),Im=F({numberOfDays:P(),pricingRate:P(),priceInAtomics:P()}),Lm=F({protocolVersionName:I(),protocolVersion:P(),feesCalculationVersion:P(),globalStateUpdaterVersion:P(),applicationLedgerInternalStateUpdaterVersion:P(),applicationInternalStateUpdaterVersion:P(),organizationInternalStateUpdaterVersion:P(),validatorNodeInternalStateUpdaterVersion:P(),accountInternalStateUpdaterVersion:P(),protocolInternalStateUpdaterVersion:P(),minimumNodeStakingAmountInAtomics:P(),maximumNodeStakingAmountInAtomics:P(),unstakingDelayInDays:P(),maxBlockSizeInBytes:P(),priceStructure:Fm,abciVersion:P()}),Rm=F({protocolVersion:P(),protocolVersionName:I(),changeLog:I(),protocolVariables:Lm}),zm=Zp({type:N(O.CUSTOM)},rm()),Bm=F({type:N(O.SIGNATURE),signature:B(),schemeId:wm()}),Vm=F({type:N(O.ALLOWED_ADDITIONAL_WRITER),allowedWriterAccountId:B()}),Hm=F({type:N(O.PROTOCOL_CREATION),organizationId:jm()}),Um=F({type:N(O.PROTOCOL_UPDATE),...Rm.entries}),Wm=F({type:N(O.PROTOCOL_VARIABLES),protocolVariables:Gp()}),Gm=F({type:N(O.ACCOUNT_PUBLIC_KEY),publicKey:B(),schemeId:wm()}),Km=F({type:N(O.ACCOUNT_TOKEN_ISSUANCE),amount:z()}),qm=F({type:N(O.ACCOUNT_CREATION),sellerAccount:jm(),amount:z()}),Jm=F({type:N(O.ACCOUNT_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm()}),Ym=F({type:N(O.ACCOUNT_VESTING_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm(),cliffDurationDays:z(),vestingDurationDays:z()}),Xm=F({type:N(O.ACCOUNT_ESCROW_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm(),escrowIdentifier:jm(),agentAccount:jm(),durationDays:z()}),Zm=F({type:N(O.ACCOUNT_ESCROW_SETTLEMENT),escrowIdentifier:jm(),confirmed:Sm()}),Qm=F({type:N(O.ACCOUNT_STAKE),amount:z(),objectType:z(),objectIdentifier:jm()}),$m=F({type:N(O.ACCOUNT_UNSTAKE),amount:z(),objectType:z(),objectIdentifier:jm()}),eh=F({type:N(O.VN_CREATION),organizationId:jm()}),th=F({type:N(O.VN_COMETBFT_PUBLIC_KEY_DECLARATION),cometPublicKeyType:xm(),cometPublicKey:xm()}),nh=F({type:N(O.VN_RPC_ENDPOINT),rpcEndpoint:xm()}),rh=F({type:N(O.VN_APPROVAL),status:Sm()}),ih=F({type:N(O.VN_SLASHING_CANCELLATION),reason:xm()}),ah=F({type:N(O.ORG_CREATION),accountId:jm()}),oh=F({type:N(O.ORG_DESCRIPTION),name:xm(),city:xm(),countryCode:xm(),website:xm(),misc:Qp(em(I(),I()))}),sh=F({type:N(O.APP_CREATION),organizationId:jm()}),ch=F({type:N(O.APP_DESCRIPTION),name:xm(),logoUrl:xm(),homepageUrl:xm(),description:xm(),misc:Qp(em(I(),I()))}),lh=F({type:N(O.APP_LEDGER_ALLOWED_SIG_SCHEMES),schemeIds:M(wm())}),uh=F({type:N(O.APP_LEDGER_ALLOWED_PKE_SCHEMES),schemeIds:M(wm())}),dh=F({type:N(O.APP_LEDGER_CREATION),applicationId:jm()}),fh=F({type:N(O.APP_LEDGER_ACTOR_CREATION),id:z(),actorType:z(),name:xm()}),ph=F({type:N(O.APP_LEDGER_CHANNEL_CREATION),id:z(),isPrivate:Sm(),creatorId:z(),name:xm()}),mh=F({type:N(O.APP_LEDGER_SHARED_SECRET),hostId:z(),guestId:z(),encryptedSharedKey:B()}),hh=F({type:N(O.APP_LEDGER_CHANNEL_INVITATION),channelId:z(),hostId:z(),guestId:z(),encryptedChannelKey:B()}),gh=F({type:N(O.APP_LEDGER_ACTOR_SUBSCRIPTION),actorId:z(),actorType:z(),organizationId:jm(),signatureSchemeId:wm(),signaturePublicKey:B(),pkeSchemeId:wm(),pkePublicKey:B()}),_h=F({type:N(O.APP_LEDGER_PUBLIC_CHANNEL_DATA),channelId:z(),data:B()}),vh=F({type:N(O.APP_LEDGER_PRIVATE_CHANNEL_DATA),channelId:z(),merkleRootHash:jm(),encryptedData:B()}),yh=F({type:N(O.APP_LEDGER_AUTHOR),authorId:z()}),bh=F({type:N(O.APP_LEDGER_ENDORSEMENT_REQUEST),endorserId:z(),message:xm()}),xh=im(`type`,[Bm,Vm,zm,Hm,Um,Wm,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh]),Sh=F({sections:M(xh)}),V;(function(e){e[e.ACCOUNT_VIRTUAL_BLOCKCHAIN=1]=`ACCOUNT_VIRTUAL_BLOCKCHAIN`,e[e.NODE_VIRTUAL_BLOCKCHAIN=2]=`NODE_VIRTUAL_BLOCKCHAIN`,e[e.APPLICATION_VIRTUAL_BLOCKCHAIN=4]=`APPLICATION_VIRTUAL_BLOCKCHAIN`,e[e.ORGANIZATION_VIRTUAL_BLOCKCHAIN=3]=`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,e[e.APP_LEDGER_VIRTUAL_BLOCKCHAIN=5]=`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,e[e.PROTOCOL_VIRTUAL_BLOCKCHAIN=0]=`PROTOCOL_VIRTUAL_BLOCKCHAIN`})(V||={});var Ch=F({organizationId:jm(),currentProtocolVariables:Lm,protocolUpdates:M(Rm)}),wh=F({signatureSchemeId:z(),publicKeyHeight:Mm()}),Th=F({accountId:jm(),descriptionHeight:Mm()}),Eh=F({organizationId:jm(),cometbftPublicKeyDeclarationHeight:Mm(),rpcEndpointHeight:Mm(),lastKnownApprovalStatus:Sm()}),Dh=F({organizationId:jm(),descriptionHeight:Mm()}),Oh=F({name:xm(),isPrivate:Sm(),creatorId:z()}),kh=F({channelId:z(),height:Mm()}),Ah=F({peerActorId:z(),height:Mm()}),jh=F({name:xm(),subscribed:Sm(),signatureKeyHeight:z(),pkeKeyHeight:z(),sharedSecrets:M(Ah),invitations:M(kh)}),Mh=F({allowedAdditionalWriters:M(jm()),allowedSignatureSchemeIds:M(z()),allowedPkeSchemeIds:M(z()),applicationId:jm(),channels:M(Oh),actors:M(jh)}),Nh=F({height:z(),expirationDay:z(),lastMicroblockHash:B()}),Ph=F({type:N(V.ACCOUNT_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:wh}),Fh=F({type:N(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Th}),Ih=F({type:N(V.NODE_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Eh}),Lh=F({type:N(V.APPLICATION_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Dh}),Rh=F({type:N(V.APP_LEDGER_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Mh}),zh=F({type:N(V.PROTOCOL_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Ch}),Bh=im(`type`,[Ph,Fh,Ih,Lh,Rh,zh]),Vh=F({virtualBlockchainType:P(),virtualBlockchainId:jm()}),Hh=F({virtualBlockchainId:B(),virtualBlockchainType:P(),header:Nm}),Uh=3,Wh;(function(e){e[e.Escrow=0]=`Escrow`,e[e.Vesting=1]=`Vesting`,e[e.NodeStaking=2]=`NodeStaking`})(Wh||={});var Gh=F({escrowIdentifier:B(),fundEmitterAccountId:B(),transferAuthorizerAccountId:B(),startTimestamp:P(),durationDays:P()}),Kh=F({type:N(Wh.Escrow),lockedAmountInAtomics:P(),parameters:Gh}),qh=F({initialVestedAmountInAtomics:P(),cliffStartTimestamp:P(),cliffDurationDays:P(),vestingDurationDays:P()}),Jh=F({type:N(Wh.Vesting),lockedAmountInAtomics:P(),parameters:qh}),Yh=F({validatorNodeId:B(),plannedUnlockAmountInAtomics:P(),plannedUnlockTimestamp:P(),slashed:Kp(),plannedSlashingAmountInAtomics:P(),plannedSlashingTimestamp:P()}),Xh=F({type:N(Wh.NodeStaking),lockedAmountInAtomics:P(),parameters:Yh}),Zh=im(`type`,[Kh,Jh,Xh]),Qh=F({balance:P(),escrowed:P(),vested:P(),releasable:P(),staked:P(),stakeable:P(),locked:P(),spendable:P()}),$h=F({height:P(),balance:P(),lastHistoryHash:B(),locks:M(Zh)}),eg=F({type:P(),exists:Kp(),state:$h}),tg=F({height:R(P(),Lp(),Vp(0)),previousHistoryHash:Am(),type:R(P(),Lp(),Vp(0),zp(255)),timestamp:R(P(),Lp(),Vp(0)),linkedAccount:Am(),amount:R(P(),Lp(),Vp(0)),chainReference:B()}),ng=M(tg),rg=F({accountHash:B(),lastKnownHistoryHash:B()}),ig=F({accountHash:B(),currentState:$h,historyUpdate:ng}),ag=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,og=ag+`+/=`,sg={BASE64:og,URL:ag+`-_=`,encodeString:cg,decodeString:lg,encodeBinary:ug,decodeBinary:dg};function cg(e,t=og,n=!1){return ug(Qa.encode(e),t,n)}function lg(e,t=og){return Qa.decode(dg(e,t))}function ug(e,t=og,n=!1){let r=e.length%3,i=0,a=``;for(let n=0;n<e.length||n%3;)if(i=i<<8|e[n++],!(n%3)){for(let e=4;e--;)a+=t[i>>e*6&63];i=0}return r?a.slice(0,r-3)+t[64].repeat(n?3-r:0):a}function dg(e,t=og){let n=0,r=0,i=[];e+=t[64].repeat(-e.length&3);for(let a=0;a<e.length;){let o=t.indexOf(e[a++]);o==64&&n++,r=r<<6|o,a&3||i.push(r>>16&255,r>>8&255,r&255)}return new Uint8Array(n?i.slice(0,-n):i)}var fg=class{static defaultBytesToStringEncoder(){return new mg}static bytesToBase64Encoder(){return new pg}static bytesToHexEncoder(){return new mg}},pg=class{static decode(e){return sg.decodeBinary(e,sg.BASE64)}static encode(e){return sg.encodeBinary(e,sg.BASE64,!0)}decode(e){return sg.decodeBinary(e,sg.BASE64)}encode(e){return sg.encodeBinary(e,sg.BASE64,!0)}},mg=class{decode(e){return yl(e)}encode(e){if(!(e instanceof Uint8Array))throw TypeError(`Encoding data must be a Uint8Array, got ${typeof e}`);return gl(e)}},hg=class{keys;value;constructor(e,t){this.keys=e,this.value=t}matchesKeys(...e){return e.length===this.keys.length?e.every((e,t)=>e===this.keys[t]):!1}getKeys(){return[...this.keys]}getValue(){return this.value}},gg=class{static encode(...e){if(e.length<2)throw Error(`At least one key and one value must be provided`);let t=e.slice(0,-1),n=e[e.length-1];return`${t.join(`:`)}${n?`{${n}}`:`{}`}`}static decode(e){let t=e.match(/^(.*?)(?:\{(.*)\})?$/);if(!t)throw Error(`Invalid encoded string format`);let n=t[1],r=t[2]||``;return new hg(n?n.split(`:`):[],r)}},_g={},vg={};vg.byteLength=Eg,vg.toByteArray=Og,vg.fromByteArray=jg;for(var yg=[],bg=[],xg=typeof Uint8Array<`u`?Uint8Array:Array,Sg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Cg=0,wg=Sg.length;Cg<wg;++Cg)yg[Cg]=Sg[Cg],bg[Sg.charCodeAt(Cg)]=Cg;bg[45]=62,bg[95]=63;function Tg(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Eg(e){var t=Tg(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Dg(e,t,n){return(t+n)*3/4-n}function Og(e){var t,n=Tg(e),r=n[0],i=n[1],a=new xg(Dg(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=bg[e.charCodeAt(c)]<<18|bg[e.charCodeAt(c+1)]<<12|bg[e.charCodeAt(c+2)]<<6|bg[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=bg[e.charCodeAt(c)]<<2|bg[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=bg[e.charCodeAt(c)]<<10|bg[e.charCodeAt(c+1)]<<4|bg[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function kg(e){return yg[e>>18&63]+yg[e>>12&63]+yg[e>>6&63]+yg[e&63]}function Ag(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(kg(r));return i.join(``)}function jg(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Ag(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(yg[t>>2]+yg[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(yg[t>>10]+yg[t>>4&63]+yg[t<<2&63]+`=`)),i.join(``)}var Mg={};Mg.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Mg.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=vg,n=Mg,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=ee,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,`parent`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,`offset`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Ie(e,o)||e&&Ie(e.buffer,o)||s!==void 0&&(Ie(e,s)||e&&Ie(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=x(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Ie(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Le(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function ee(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Ie(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Ie(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Ie(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function x(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Ie(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return Me(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Fe(e).length;default:if(i)return r?-1:Me(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=x;function te(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return me(this,t,n);case`utf8`:case`utf-8`:return le(this,t,n);case`ascii`:return fe(this,t,n);case`latin1`:case`binary`:return pe(this,t,n);case`base64`:return C(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return he(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function S(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)S(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)S(this,t,t+3),S(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)S(this,t,t+7),S(this,t+1,t+6),S(this,t+2,t+5),S(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?le(this,0,e):te.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Ie(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function ne(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Le(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:re(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):re(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function re(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return ne(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return ne(this,e,t,n,!1)};function ie(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Le(r))return o;e[n+o]=r}return o}function ae(e,t,n,r){return w(Me(t,e.length-n),e,n,r)}function oe(e,t,n,r){return w(Ne(t),e,n,r)}function se(e,t,n,r){return w(Fe(t),e,n,r)}function ce(e,t,n,r){return w(Pe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ie(this,e,t,n);case`utf8`:case`utf-8`:return ae(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return oe(this,e,t,n);case`base64`:return se(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ce(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function C(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function le(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return de(r)}let ue=4096;function de(e){let t=e.length;if(t<=ue)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ue));return n}function fe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function pe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function me(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=Re[e[r]];return i}function he(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function ge(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||ge(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||ge(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||ge(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||ge(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||ge(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||ge(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||ge(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||ge(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||ge(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||ge(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||ge(e,8,this.length),n.read(this,e,!1,52,8)};function _e(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;_e(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;_e(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ve(e,t,n,r,i){De(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function ye(e,t,n,r,i){De(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=ze(function(e,t=0){return ve(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=ze(function(e,t=0){return ye(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);_e(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);_e(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=ze(function(e,t=0){return ve(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=ze(function(e,t=0){return ye(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function be(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function xe(e,t,r,i,a){return t=+t,r>>>=0,a||be(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return xe(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return xe(this,e,t,!1,n)};function Se(e,t,r,i,a){return t=+t,r>>>=0,a||be(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return Se(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return Se(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let Ce={};function we(e,t,n){Ce[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}we(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),we(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),we(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=Te(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=Te(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function Te(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function Ee(e,t,n){Oe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&ke(t,e.length-(n+1))}function De(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new Ce.ERR_OUT_OF_RANGE(`value`,i,e)}Ee(r,i,a)}function Oe(e,t){if(typeof e!=`number`)throw new Ce.ERR_INVALID_ARG_TYPE(t,`number`,e)}function ke(e,t,n){throw Math.floor(e)===e?t<0?new Ce.ERR_BUFFER_OUT_OF_BOUNDS:new Ce.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(Oe(e,n),new Ce.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let Ae=/[^+/0-9A-Za-z-_]/g;function je(e){if(e=e.split(`=`)[0],e=e.trim().replace(Ae,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function Me(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Ne(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Pe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Fe(e){return t.toByteArray(je(e))}function w(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Ie(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Le(e){return e!==e}let Re=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function ze(e){return typeof BigInt>`u`?Be:e}function Be(){throw Error(`BigInt not supported`)}})(_g);var Ng=_g.Buffer;_g.Blob,_g.BlobOptions,_g.Buffer,_g.File,_g.FileOptions,_g.INSPECT_MAX_BYTES,_g.SlowBuffer,_g.TranscodeEncoding,_g.atob,_g.btoa,_g.constants,_g.isAscii,_g.isUtf8,_g.kMaxLength,_g.kStringMaxLength,_g.resolveObjectURL,_g.transcode;var Pg;(function(e){e[e.AES_256_GCM=0]=`AES_256_GCM`})(Pg||={});var Fg=class e{static KEY_LENGTH_IN_BYTES=32;getSymmetricEncryptionSchemeId(){return Pg.AES_256_GCM}getSupportedKeyLengths(){return[e.KEY_LENGTH_IN_BYTES]}getDefaultKeyLength(){return e.KEY_LENGTH_IN_BYTES}},Ig=class e{key;constructor(e){this.key=e}static async generate(){let t=new Uint8Array(32);return crypto.getRandomValues(t),new e(t)}static createFromBytes(t){return new e(t)}getRawSecretKey(){return this.key}getSymmetricEncryptionSchemeId(){return Pg.AES_256_GCM}async encrypt(e){let t=new Uint8Array(12);crypto.getRandomValues(t);let n=ou(this.key,t).encrypt(e),r=new Uint8Array(t.length+n.length);return r.set(t),r.set(n,t.length),r}async decrypt(e){try{let t=e.slice(0,12),n=e.slice(12);return ou(this.key,t).decrypt(n)}catch(e){throw o.isCarmentisError(e)?new f:e}}},Lg=class{wrappedKey;constructor(e){this.wrappedKey=e}async encryptString(e){let t=new TextEncoder().encode(e),n=await this.encrypt(t);return Ng.from(n).toString(`base64`)}async decryptString(e){let t=Ng.from(e,`base64`),n=await this.decrypt(t);return new TextDecoder().decode(n)}getSymmetricEncryptionSchemeId(){return this.wrappedKey.getSymmetricEncryptionSchemeId()}async encrypt(e){return this.wrappedKey.encrypt(e)}async decrypt(e){return this.wrappedKey.decrypt(e)}getRawSecretKey(){return this.wrappedKey.getRawSecretKey()}},Rg;(function(e){e[e.ML_KEM=0]=`ML_KEM`})(Rg||={});var zg=class{getPrivateKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(this.getPrivateKeyAsBytes())}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Bg=class{async getPublicKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Vg=class e{static SIGNATURE_SIZE=3311;getSignatureSchemeId(){return Ya.ML_DSA_65}getSignatureSize(){return e.SIGNATURE_SIZE}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}expectedSeedSize(){return 32}},Hg=class extends Bg{publicKey;constructor(e){super(),this.publicKey=e}async getPublicKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}async verify(e,t){return yd.verify(this.publicKey,e,t)}async getPublicKeyAsBytes(){return this.publicKey}getScheme(){return new Vg}},Ug=class e extends zg{seed;static async gen(){return new e(Iu(32))}verificationKey;signatureKey;getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}constructor(e){super(),this.seed=e;let t=yd.keygen(e);this.signatureKey=t.secretKey,this.verificationKey=t.publicKey}async getPublicKey(){return new Hg(this.verificationKey)}getPrivateKeyAsBytes(){return this.seed}async sign(e){return yd.sign(this.signatureKey,e)}getScheme(){return new Vg}},Wg={p:57896044618658097711785492504343953926634992332820282019728792003956564819949n,n:7237005577332262213973186563042994240857116359379907606001950938285454250989n,h:8n,a:57896044618658097711785492504343953926634992332820282019728792003956564819948n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,Gx:15112221349535400772501151409588531511454012693041857206046113283949847762202n,Gy:46316835694926478169428394003475163141307993866256225615783033603165251855960n},{p:Gg,n:Kg,Gx:qg,Gy:Jg,a:Yg,d:Xg,h:Zg}=Wg,Qg=32,$g=(...e)=>{`captureStackTrace`in Error&&typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(...e)},e_=(e=``)=>{let t=Error(e);throw $g(t,e_),t},t_=e=>typeof e==`bigint`,n_=e=>typeof e==`string`,r_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,i_=(e,t,n=``)=>{let r=r_(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;e_(o+`expected Uint8Array`+s+`, got `+c)}return e},a_=e=>new Uint8Array(e),o_=e=>Uint8Array.from(e),s_=(e,t)=>e.toString(16).padStart(t,`0`),c_=e=>Array.from(i_(e)).map(e=>s_(e,2)).join(``),l_={_0:48,_9:57,A:65,F:70,a:97,f:102},u_=e=>{if(e>=l_._0&&e<=l_._9)return e-l_._0;if(e>=l_.A&&e<=l_.F)return e-(l_.A-10);if(e>=l_.a&&e<=l_.f)return e-(l_.a-10)},d_=e=>{let t=`hex invalid`;if(!n_(e))return e_(t);let n=e.length,r=n/2;if(n%2)return e_(t);let i=a_(r);for(let n=0,a=0;n<r;n++,a+=2){let r=u_(e.charCodeAt(a)),o=u_(e.charCodeAt(a+1));if(r===void 0||o===void 0)return e_(t);i[n]=r*16+o}return i},f_=()=>globalThis?.crypto,p_=()=>f_()?.subtle??e_(`crypto.subtle must be defined, consider polyfill`),m_=(...e)=>{let t=a_(e.reduce((e,t)=>e+i_(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},h_=(e=Qg)=>f_().getRandomValues(a_(e)),g_=BigInt,__=(e,t,n,r=`bad number: out of range`)=>t_(e)&&t<=e&&e<n?e:e_(r),v_=(e,t=Gg)=>{let n=e%t;return n>=0n?n:t+n},y_=(1n<<255n)-1n,H=e=>{e<0n&&e_(`negative coordinate`);let t=(e>>255n)*19n+(e&y_);return t=(t>>255n)*19n+(t&y_),t%Gg},b_=e=>v_(e,Kg),x_=(e,t)=>{(e===0n||t<=0n)&&e_(`no inverse n=`+e+` mod=`+t);let n=v_(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?v_(i,t):e_(`no inverse`)},S_=e=>{let t=q_[e];return typeof t!=`function`&&e_(`hashes.`+e+` not set`),t},C_=e=>e instanceof T_?e:e_(`Point expected`),w_=2n**256n,T_=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=w_;this.X=__(e,0n,i),this.Y=__(t,0n,i),this.Z=__(n,1n,i),this.T=__(r,0n,i),Object.freeze(this)}static CURVE(){return Wg}static fromAffine(t){return new e(t.x,t.y,1n,H(t.x*t.y))}static fromBytes(t,n=!1){let r=Xg,i=o_(i_(t,Qg)),a=t[31];i[31]=a&-129;let o=k_(i);__(o,0n,n?w_:Gg);let s=H(o*o),{isValid:c,value:l}=N_(v_(s-1n),H(r*s+1n));c||e_(`bad point: y not sqrt`);let u=(l&1n)==1n,d=(a&128)!=0;return!n&&l===0n&&d&&e_(`bad point: x==0, isLastByteOdd`),d!==u&&(l=v_(-l)),new e(l,o,1n,H(l*o))}static fromHex(t,n){return e.fromBytes(d_(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=Yg,t=Xg,n=this;if(n.is0())return e_(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=n,s=H(r*r),c=H(i*i),l=H(a*a),u=H(l*l);return H(l*(H(s*e)+c))===v_(u+H(t*H(s*c)))?H(r*i)===H(a*o)?this:e_(`bad point: equation left != right (2)`):e_(`bad point: equation left != right (1)`)}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=C_(e),s=H(t*o),c=H(i*r),l=H(n*o),u=H(a*r);return s===c&&l===u}is0(){return this.equals(D_)}negate(){return new e(v_(-this.X),this.Y,this.Z,v_(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=Yg,a=H(t*t),o=H(n*n),s=H(2n*r*r),c=H(i*a),l=v_(t+n),u=v_(H(l*l)-a-o),d=v_(c+o),f=v_(d-s),p=v_(c-o),m=H(u*f),h=H(d*p),g=H(u*p);return new e(m,h,H(f*d),g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=C_(t),u=Yg,d=Xg,f=H(n*o),p=H(r*s),m=H(H(a*d)*l),h=H(i*c),g=v_(H(v_(n+r)*v_(o+s))-f-p),_=v_(h-m),v=v_(h+m),y=v_(p-H(u*f)),b=H(g*_),ee=H(v*y),x=H(g*y);return new e(b,ee,H(_*v),x)}subtract(e){return this.add(C_(e).negate())}multiply(e,t=!0){if(!t&&(e===0n||this.is0()))return D_;if(__(e,1n,Kg),e===1n)return this;if(this.equals(E_))return tv(e).p;let n=D_,r=E_;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals(D_))return{x:0n,y:1n};let r=x_(n,Gg);return H(n*r)!==1n&&e_(`invalid inverse`),{x:H(e*r),y:H(t*r)}}toBytes(){let{x:e,y:t}=this.toAffine(),n=O_(t);return n[31]|=e&1n?128:0,n}toHex(){return c_(this.toBytes())}clearCofactor(){return this.multiply(g_(Zg),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(Kg/2n,!1).double();return Kg%2n&&(e=e.add(this)),e.is0()}},E_=new T_(qg,Jg,1n,v_(qg*Jg)),D_=new T_(0n,1n,1n,0n);T_.BASE=E_,T_.ZERO=D_;var O_=e=>d_(s_(__(e,0n,w_),64)).reverse(),k_=e=>g_(`0x`+c_(o_(i_(e)).reverse())),A_=(e,t)=>{let n=e;for(;t-- >0n;)n=H(n*n);return n},j_=e=>{let t=H(H(e*e)*e),n=H(A_(H(A_(t,2n)*t),1n)*e),r=H(A_(n,5n)*n),i=H(A_(r,10n)*r),a=H(A_(i,20n)*i),o=H(A_(a,40n)*a);return{pow_p_5_8:H(A_(H(A_(H(A_(H(A_(o,80n)*o),80n)*o),10n)*r),2n)*e),b2:t}},M_=19681161376707505956807079304988542015446066515923890162744021073123829784752n,N_=(e,t)=>{let n=H(t*H(t*t)),r=j_(H(e*H(H(n*n)*t))).pow_p_5_8,i=H(e*H(n*r)),a=H(t*H(i*i)),o=i,s=H(i*M_),c=a===e,l=a===v_(-e),u=a===v_(-e*M_);return c&&(i=o),(l||u)&&(i=s),(v_(i)&1n)==1n&&(i=v_(-i)),{isValid:c||l,value:i}},P_=e=>b_(k_(e)),F_=(...e)=>q_.sha512Async(m_(...e)),I_=(...e)=>S_(`sha512`)(m_(...e)),L_=e=>{let t=e.slice(0,32);t[0]&=248,t[31]&=127,t[31]|=64;let n=e.slice(32,64),r=P_(t),i=E_.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}},R_=e=>F_(i_(e,Qg)).then(L_),z_=e=>L_(I_(i_(e,Qg))),B_=e=>z_(e).pointBytes,V_=e=>e.finish(I_(e.hashable)),H_=(e,t,n)=>{let{pointBytes:r,scalar:i}=e,a=P_(t),o=E_.multiply(a).toBytes();return{hashable:m_(o,r,n),finish:e=>i_(m_(o,O_(b_(a+P_(e)*i))),64)}},U_=(e,t)=>{let n=i_(e),r=z_(t);return V_(H_(r,I_(r.prefix,n),n))},W_={zip215:!0},G_=(e,t,n,r=W_)=>{e=i_(e,64),t=i_(t),n=i_(n,Qg);let{zip215:i}=r,a=e.subarray(0,Qg),o=k_(e.subarray(Qg,Qg*2)),s,c,l,u=Uint8Array.of(),d=!1;try{s=T_.fromBytes(n,i),c=T_.fromBytes(a,i),l=E_.multiply(o,!1),u=m_(c.toBytes(),s.toBytes(),t),d=!0}catch{}return{hashable:u,finish:e=>{if(!d||!i&&s.isSmallOrder())return!1;let t=P_(e);return c.add(s.multiply(t,!1)).subtract(l).clearCofactor().is0()}}},K_=(e,t,n,r=W_)=>V_(G_(e,t,n,r)),q_={sha512Async:async e=>{let t=p_(),n=m_(e);return a_(await t.digest(`SHA-512`,n.buffer))},sha512:void 0},J_={getExtendedPublicKeyAsync:R_,getExtendedPublicKey:z_,randomSecretKey:(e=h_(Qg))=>e},Y_=8,X_=Math.ceil(256/Y_)+1,Z_=2**(Y_-1),Q_=()=>{let e=[],t=E_,n=t;for(let r=0;r<X_;r++){n=t,e.push(n);for(let r=1;r<Z_;r++)n=n.add(t),e.push(n);t=n.double()}return e},$_=void 0,ev=(e,t)=>{let n=t.negate();return e?n:t},tv=e=>{let t=$_||=Q_(),n=D_,r=E_,i=2**Y_,a=i,o=g_(i-1),s=g_(Y_);for(let i=0;i<X_;i++){let c=Number(e&o);e>>=s,c>Z_&&(c-=a,e+=1n);let l=i*Z_,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(ev(f,t[u])):n=n.add(ev(p,t[d]))}return e!==0n&&e_(`invalid wnaf`),{p:n,f:r}};q_.sha512=Jc;var nv;(function(e){e[e.SHA256=0]=`SHA256`})(nv||={});var rv=class{getHashSchemeId(){return nv.SHA256}hash(e){return Kc(e)}};function iv(e,t,n,r){Ds(e);let{c:i,dkLen:a,asyncTick:o}=qs({dkLen:32,asyncTick:10},r);if(Ts(i),Ts(a),Ts(o),i<1)throw Error(`iterations (c) should be >= 1`);let s=Gs(t),c=Gs(n),l=new Uint8Array(a),u=Xd.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function av(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),js(i),n}function ov(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=iv(e,t,n,r),l,u=new Uint8Array(4),d=Ms(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return av(s,c,o,l,f)}var sv;(function(e){e[e.PBKDF2=0]=`PBKDF2`,e[e.SCRYPT=1]=`SCRYPT`})(sv||={});var cv=class{deriveKeyNoSalt(e,t){return this.deriveKey(e,``,t)}},lv=class extends cv{getKeyDerivationFunctionSchemeId(){return sv.PBKDF2}deriveKey(e,t,n){return ov(Kc,e,t,{c:1e5,dkLen:n})}};function uv(e,t,n){return Ds(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Xd(e,Ws(n),Ws(t))}var dv=Uint8Array.from([0]),fv=Uint8Array.of();function pv(e,t,n,r=32){Ds(e),Ts(r);let i=e.outputLen;if(r>255*i)throw Error(`Length should be <= 255*HashLen`);let a=Math.ceil(r/i);n===void 0&&(n=fv);let o=new Uint8Array(a*i),s=Xd.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)dv[0]=e+1,c.update(e===0?fv:l).update(n).update(dv).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),js(l,dv),o.slice(0,r)}var mv=(e,t,n,r,i)=>pv(e,uv(e,t,n),r,i),hv=class{deriveKeyNoSalt(e,t,n){let r=new Uint8Array;return this.deriveKey(e,r,t,n)}},gv;(function(e){e[e.HKDF=0]=`HKDF`})(gv||={});var _v=class extends hv{getKeyDerivationFunctionSchemeId(){return gv.HKDF}deriveKey(e,t,n,r){return mv(Kc,e,t,n,r)}},vv;(function(e){e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`})(vv||={});var yv;(function(e){e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`})(yv||={});var bv=class{},xv=class{async encode(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getRawPublicKey())}getSchemeId(){return this.getScheme().getSchemeId()}},Sv=class{encode(e=fg.defaultBytesToStringEncoder()){return e.encode(this.getRawPrivateKey())}},Cv=class extends bv{getSchemeId(){return vv.ML_KEM_768_AES_256_GCM}getSupportedSeedLength(){return[32]}},wv=128,Tv=96,Ev=32,Dv=64,Ov=7,kv=8,Av=class{byteStream;constructor(){this.clear()}clear(){this.byteStream=[]}getByteStream(){return new Uint8Array(this.byteStream)}writeJsonValue(e,t){switch(e){case 3:this.writeString(t);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;default:throw`Type ${e} is not a JSON type`}}writeSchemaValue(e,t,n){switch(e){case 3:this.writeString(t,n);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;case 7:this.writeUint8(t);break;case 8:this.writeUint16(t);break;case 9:this.writeUint24(t);break;case 10:this.writeUint32(t);break;case 11:this.writeUint48(t);break;case 12:this.writeBinary(t,n);break;case 13:this.writeByteArray(t);break;case 14:this.writeHashString(t);break;default:throw`Unexpected type ${e}`}}writeByte(e){this.byteStream.push(e&255)}writeUnsigned(e,t){for(;t--;)this.writeByte(e/2**(t*8))}writeUint8(e){this.writeUnsigned(e,1)}writeUint16(e){this.writeUnsigned(e,2)}writeUint24(e){this.writeUnsigned(e,3)}writeUint32(e){this.writeUnsigned(e,4)}writeUint48(e){this.writeUnsigned(e,6)}writeBinary(e,t=-1){t==-1&&this.writeVarUint(e.length),this.writeByteArray(e)}writeHashString(e){this.writeByteArray(k.binaryFromHexa(e))}writeByteArray(e){for(let t of e)this.writeByte(t)}writeString(e,t=-1){let n=Qa.encode(e);t==-1&&this.writeVarUint(n.length),this.writeByteArray(n)}writeVarUint(e){if(e==0)this.writeByte(0);else{if(e<0||e%1||e>2**53-1)throw`Invalid varUint ${e}`;for(;e;)this.writeByte(e%128|(e>127)<<7),e=Math.floor(e/128)}}writeBoolean(e){this.writeByte(e?255:0)}writeNumber(e){let t=!(e%1);if(t&&e>=-64&&e<64){this.writeByte(wv|e&127);return}for(let n=1,r=256;n<=6;n++,r*=256){if(t&&e>=-r&&e<r){let t=e<0;this.writeByte(t<<3|n),this.writeUnsigned(t?-e-1:e,n);return}if(n==4){let t=new Float32Array([e]);if(+t[0].toPrecision(7)===e){this.writeByte(Ev),this.writeByteArray(new Uint8Array(t.buffer));return}}}this.writeByte(Dv),this.writeByteArray(new Uint8Array(new Float64Array([e]).buffer))}},jv=class{byteStream;lastPointer;pointer;constructor(e){this.byteStream=e,this.pointer=0}readJsonValue(e){switch(this.lastPointer=this.pointer,e){case 3:return this.readString();case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;default:throw`Type ${e} is not a JSON type`}}readSchemaValue(e,t){switch(this.lastPointer=this.pointer,e){case 3:return this.readString(t);case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;case 7:return this.readUint8();case 8:return this.readUint16();case 9:return this.readUint24();case 10:return this.readUint32();case 11:return this.readUint48();case 12:return this.readBinary(t);case 13:return this.readByteArray(32);case 14:return this.readHashString()}}getPointer(){return this.pointer}extractFrom(e){return this.byteStream.slice(e,this.pointer)}getLastField(){return this.byteStream.slice(this.lastPointer,this.pointer)}readByte(){return this.byteStream[this.pointer++]}readUnsigned(e){let t=0;for(;e--;)t=t*256+this.readByte();return t}readUint8(){return this.readUnsigned(1)}readUint16(){return this.readUnsigned(2)}readUint24(){return this.readUnsigned(3)}readUint32(){return this.readUnsigned(4)}readUint48(){return this.readUnsigned(6)}readBinary(e=-1){return this.readByteArray(e==-1?this.readVarUint():e)}readHashString(){return k.binaryToHexa(this.readByteArray(32))}readByteArray(e){return this.byteStream.slice(this.pointer,this.pointer+=e)}readString(e=-1){let t=this.readByteArray(e==-1?this.readVarUint():e);return Qa.decode(t)}readVarUint(){let e=[],t;do t=this.readByte(),e.push(t&127);while(t&128);return e.reduceRight((e,t)=>e*128+t,0)}readBoolean(){return!!this.readByte()}readNumber(){let e=this.readByte();if(e&wv)return(e&127^64)-64;switch(e&Tv){case Ev:return+new Float32Array(this.readByteArray(4).buffer)[0].toPrecision(7);case Dv:return new Float64Array(this.readByteArray(8).buffer)[0];default:{let t=this.readUnsigned(e&Ov);return e&kv?-t-1:t}}}},Mv=class{schema;stream;constructor(e){this.schema=e}serialize(e){if(this.schema===void 0)throw new De(`Provided schema is undefined: this should not happen`);return this.stream=new Av,this.serializeObject(this.schema.definition,e),this.stream.getByteStream()}serializeObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0)throw new De(`field '${e}' is missing`);if(r.type&32){if(ro.getType(i)!=1)throw new De(`'${e}' is not an array`);if(r.size!==void 0){if(i.length!=r.size)throw new De(`invalid size for '${e}' (expecting ${r.size} entries, got ${i.length})`)}else this.stream.writeVarUint(i.length);for(let t in i)this.serializeItem(r,i[t],e+`[${t}]`)}else this.serializeItem(r,i,e)}}serializeItem(e,t,n){let r=e.type&31;if(r==2){if(ro.getType(t)!=2)throw new De(`'${n}' is not an object`);if(e.definition)this.serializeObject(e.definition,t,n);else if(e.schema)this.serializeObject(e.schema.definition,t,n);else throw new De(`missing definition in schema`)}else{let i=new io(e,t);try{i.check()}catch(e){throw new De(`Error on field '${n}': ${e}`)}this.stream.writeSchemaValue(r,t,e.size)}}},Nv=class{schema;stream;constructor(e){this.schema=e}unserialize(e){this.stream=new jv(e);let t=this.unserializeObject(this.schema.definition),n=this.stream.getPointer(),r=e.length;if(n!=r)throw console.error(k.binaryToHexa(e)),new o(`Invalid stream length (decoded ${n} bytes, actual length is ${r} bytes)`);return t}unserializeObject(e){let t={};for(let n of e){let e;if(n.type&32){let t=n.size===void 0?this.stream.readVarUint():n.size;for(e=[];t--;)e.push(this.unserializeItem(n))}else e=this.unserializeItem(n);t[n.name]=e}return t}unserializeItem(e){let t=e.type&31;if(t==2){if(e.definition)return this.unserializeObject(e.definition);if(e.schema)return this.unserializeObject(e.schema.definition);throw`missing definition in schema`}return this.stream.readSchemaValue(t,e.size)}},Pv=class e{static schema={label:`PKE_ML_KEM_CIPHERTEXT`,definition:[{name:`encryptedSharedSecret`,type:12},{name:`encryptedMessage`,type:12}]};serializer=new Mv(e.schema);deserializer=new Nv(e.schema);encode(e,t){return this.serializer.serialize({encryptedSharedSecret:e,encryptedMessage:t})}decode(e){return this.deserializer.unserialize(e)}},Fv=class extends xv{publicKey;static encoder=fg.bytesToBase64Encoder();constructor(e){super(),this.publicKey=e}async encrypt(e){let{cipherText:t,sharedSecret:n}=Ud.encapsulate(this.publicKey),r=await Ig.createFromBytes(n).encrypt(e);return new Pv().encode(t,r)}async getRawPublicKey(){return this.publicKey}getScheme(){return new Cv}},Iv=class e extends Sv{seed;static async genFromSeed(t){if(t.length!==64)throw Error(`Seed must be 64 bytes long: got length: ${t?.length} bytes`);return new e(t)}static async gen(){return new e(Iu(64))}privateKey;publicKey;constructor(e){super(),this.seed=e;let{secretKey:t,publicKey:n}=Ud.keygen(e);this.privateKey=t,this.publicKey=n}getSupportedSeedLength(){return[64]}getScheme(){return new Cv}async getPublicKey(){return new Fv(this.publicKey)}getRawPrivateKey(){return this.privateKey}async decrypt(e){try{let{encryptedMessage:t,encryptedSharedSecret:n}=new Pv().decode(e),r=Ud.decapsulate(n,this.privateKey);return Ig.createFromBytes(r).decrypt(t)}catch(e){throw o.isCarmentisError(e)?new f:e}}},Lv=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ya.SECP256K1}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},Rv=class extends Bg{publicKey;constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return tp(t,Kc(e),this.publicKey)}getScheme(){return new Lv}},zv=class e extends zg{privateKey;constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(sp.randomPrivateKey())}static genFromSeed(t){return new e(op.bytesToHex(t))}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new Rv(Kf(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return ep(Kc(e),this.privateKey).toCompactRawBytes()}getScheme(){return new Lv}},Bv=class e{static createPrivateSignatureKey(e,t){switch(e){case Ya.SECP256K1:return new zv(t);case Ya.ML_DSA_65:return new Ug(t);default:throw`Not supported signature scheme ID: ${e}`}}static createVirtualBlockchainPrivateSignature(e,t,n,r){let i=new Uint8Array([...n,...r]),a=new TextEncoder,o=e.deriveKeyNoSalt(i,a.encode(`VB_ACTOR_KEY`),32);switch(t){case Ya.ML_DSA_65:return new Ug(o);case Ya.SECP256K1:return zv.genFromSeed(o);default:throw`Not supported signature scheme ID: ${t}`}}static deriveKeyFromPassword(t,n=sv.PBKDF2,r=Pg.AES_256_GCM){let i=e.createSymmetricEncryptionKeyScheme(r).getDefaultKeyLength(),a=e.createDefaultPBKDF().deriveKeyNoSalt(t,i);return e.createSymmetricEncryptionKey(r,a)}createDecapsulationKey(e,t){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}createVirtualBlockchainDecapsulationKey(e,t,n){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}async createPublicSignatureKey(t,n){return e.createPublicSignatureKey(t,n)}static async createPublicSignatureKey(e,t){switch(e){case Ya.SECP256K1:return new Rv(t);case Ya.ML_DSA_65:return new Hg(t);default:throw Error(`Not supported signature scheme ID: ${e}`)}}static async createPublicEncryptionKey(e,t){switch(e){case vv.ML_KEM_768_AES_256_GCM:return new Fv(t);default:throw Error(`Not supported scheme ID: ${e}`)}}static async createPrivateDecryptionKey(e,t){switch(e){case vv.ML_KEM_768_AES_256_GCM:return await Iv.genFromSeed(t);default:throw Error(`Not supported scheme ID: ${e}`)}}createSymmetricEncryptionKey(t,n){return e.createSymmetricEncryptionKey(t,n)}static createSymmetricEncryptionKey(e,t){switch(e){case Pg.AES_256_GCM:return Ig.createFromBytes(t);default:throw`Not supported encryption scheme ID: ${e}`}}static createSymmetricEncryptionKeyScheme(e){switch(e){case Pg.AES_256_GCM:return new Fg;default:throw`Not supported encryption scheme ID: ${e}`}}static createCryptographicHash(e){switch(e){case nv.SHA256:return new rv;default:throw`Not supported hash scheme ID: ${e}`}}static createDefaultCryptographicHash(){return new rv}static createDefaultPBKDF(){return new lv}static createDefaultKDF(){return new _v}static createSignatureScheme(e){switch(e){case Ya.SECP256K1:return new Lv;case Ya.ML_DSA_65:return new Vg;default:throw Error(`Not supported signature scheme ID: ${e}`)}}},Vv=class e{stringEncoder;static PKE_KEY=`PKE`;static SK_PKE_KEY=`SK`;static PK_PKE_KEY=`PK`;static PKE_SCHEMES=[{algoId:vv.ML_KEM_768_AES_256_GCM,label:`MLKEM768AES256GCM`}];static createHexHCVPkeEncoder(){return new e(fg.bytesToHexEncoder())}static createBase64HCVPkeEncoder(){return new e(fg.bytesToBase64Encoder())}constructor(e){this.stringEncoder=e}async decodePrivateDecryptionKey(t){let n=gg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.SK_PKE_KEY))return await Bv.createPrivateDecryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async decodePublicEncryptionKey(t){let n=gg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.PK_PKE_KEY))return Bv.createPublicEncryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async encodePrivateDecryptionKey(t){return gg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.SK_PKE_KEY,this.stringEncoder.encode(t.getRawPrivateKey()))}async encodePublicEncryptionKey(t){return gg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.PK_PKE_KEY,this.stringEncoder.encode(await t.getRawPublicKey()))}},Hv=`SIG`,Uv=`SK`,Wv=`PK`,Gv=class{labels;bytesEncoder=fg.bytesToHexEncoder();constructor(e){this.labels=e}async encodePublicKey(e){return gg.encode(...this.getHCVPublicKeyEncodingPrefix(),this.bytesEncoder.encode(await e.getPublicKeyAsBytes()))}getHCVPrivateKeyEncodingPrefix(){return[Hv,...this.labels,Uv]}getHCVPublicKeyEncodingPrefix(){return[Hv,...this.labels,Wv]}},Kv=class extends Gv{constructor(e){super(e)}async encodePrivateKey(e){return gg.encode(...this.getHCVPrivateKeyEncodingPrefix(),this.bytesEncoder.encode(e.getPrivateKeyAsBytes()))}},qv=class extends Kv{constructor(){super([`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof zv}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Rv}},Jv=class extends Kv{constructor(){super([`MLDSA65`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof Ug}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Hg}};function Yv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Xv={exports:{}},Zv=Xv.exports={},Qv,$v;function ey(){throw Error(`setTimeout has not been defined`)}function ty(){throw Error(`clearTimeout has not been defined`)}(function(){try{Qv=typeof setTimeout==`function`?setTimeout:ey}catch{Qv=ey}try{$v=typeof clearTimeout==`function`?clearTimeout:ty}catch{$v=ty}})();function ny(e){if(Qv===setTimeout)return setTimeout(e,0);if((Qv===ey||!Qv)&&setTimeout)return Qv=setTimeout,setTimeout(e,0);try{return Qv(e,0)}catch{try{return Qv.call(null,e,0)}catch{return Qv.call(this,e,0)}}}function ry(e){if($v===clearTimeout)return clearTimeout(e);if(($v===ty||!$v)&&clearTimeout)return $v=clearTimeout,clearTimeout(e);try{return $v(e)}catch{try{return $v.call(null,e)}catch{return $v.call(this,e)}}}var iy=[],ay=!1,oy,sy=-1;function cy(){!ay||!oy||(ay=!1,oy.length?iy=oy.concat(iy):sy=-1,iy.length&&ly())}function ly(){if(!ay){var e=ny(cy);ay=!0;for(var t=iy.length;t;){for(oy=iy,iy=[];++sy<t;)oy&&oy[sy].run();sy=-1,t=iy.length}oy=null,ay=!1,ry(e)}}Zv.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];iy.push(new uy(e,t)),iy.length===1&&!ay&&ny(ly)};function uy(e,t){this.fun=e,this.array=t}uy.prototype.run=function(){this.fun.apply(null,this.array)},Zv.title=`browser`,Zv.browser=!0,Zv.env={},Zv.argv=[],Zv.version=``,Zv.versions={};function dy(){}Zv.on=dy,Zv.addListener=dy,Zv.once=dy,Zv.off=dy,Zv.removeListener=dy,Zv.removeAllListeners=dy,Zv.emit=dy,Zv.prependListener=dy,Zv.prependOnceListener=dy,Zv.listeners=function(e){return[]},Zv.binding=function(e){throw Error(`process.binding is not supported`)},Zv.cwd=function(){return`/`},Zv.chdir=function(e){throw Error(`process.chdir is not supported`)},Zv.umask=function(){return 0};var fy=Xv.exports,py=Yv(fy),my=class{async getPkmsCredential(){let e=py.env.PKMS_API_KEY;if(e===void 0)throw Error(`PKMS_API_KEY environment variable is not set.`);return e}},hy=`https://pkms.admin.carmentis.io`,gy=class e{keyId;options;static createFromKeyId(t){return new e(t)}credentialProvider=new my;constructor(e,t={host:hy}){this.keyId=e,this.options=t}getKeyId(){return this.keyId}getPrivateKeyAsBytes(){throw Error(`Private key material cannot be exported.`)}async getPublicKey(){let e=await fetch(`${this.options.host}/api/keys/${this.keyId}/pk`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to fetch public key with id ${this.keyId} at ${this.options.host}: ${e.statusText}.`);let t=(await e.json()).publicKey;if(t===void 0)throw Error(`Failed to fetch public key: no "publicKey" field found in response body.`);return new _y(new Uint8Array(Ng.from(t,`base64`)))}getScheme(){return new Lv}getSignatureSchemeId(){return Ya.PKMS_SECP256K1}getSignatureSize(){return this.getScheme().getSignatureSize()}setCredentialProvider(e){this.credentialProvider=e}async sign(e){let t=await this.credentialProvider.getPkmsCredential();try{let n=await fetch(`${this.options.host}/api/sign`,{method:`POST`,headers:{authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({keyId:this.keyId,base64EncodedData:Ng.from(e).toString(`base64`)})});if(n.ok){let e=await n.json();return Ng.from(e.signature,`base64`)}else throw Error(`Failed to sign data.`)}catch(e){throw e}}},_y=class extends Rv{getSignatureSchemeId(){return Ya.PKMS_SECP256K1}},vy=class extends Gv{constructor(){super([`PKMS`,`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof gy}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof _y}async encodePrivateKey(e){if(!(e instanceof gy))throw Error(`Invalid private key type: `+e.constructor.name);let t=e.getKeyId();return gg.encode(...this.getHCVPrivateKeyEncodingPrefix(),t)}},yy=`SIG`,by=`SK`,xy=`PK`,Sy=class e{labels;static logger=ts.getLogger([`HCVSignatureDecoder`]);bytesEncoder=fg.bytesToHexEncoder();constructor(e){this.labels=e}async isAcceptingPrivateKeyDecodingRequest(t){try{let n=gg.decode(t);return e.logger.debug(`Attempt to decode private key for ${this.labels}: found ${n.getKeys()}`),n.matchesKeys(yy,...this.labels,by)}catch(t){return e.logger.debug(`Fail to decode private key for ${this.labels}: ${t}`),!1}}async isAcceptingPublicKeyDecodingRequest(e){try{return gg.decode(e).matchesKeys(yy,...this.labels,xy)}catch{return!1}}static getSignatureKey(){return yy}static getSkSignatureKey(){return by}static getPkSignatureKey(){return xy}},Cy=class extends Sy{async decodePrivateKey(e){let t=gg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPrivateKey(n)}async decodePublicKey(e){let t=gg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPublicKey(n)}},wy=class e extends Cy{static label=`SECP256K1`;constructor(){super([e.label])}bootstrapPrivateKey(e){return new zv(e)}bootstrapPublicKey(e){return new Rv(e)}},Ty=class e extends Cy{static ML_DSA65_SIGNATURE_KEY=`MLDSA65`;constructor(){super([e.ML_DSA65_SIGNATURE_KEY])}bootstrapPrivateKey(e){return new Ug(e)}bootstrapPublicKey(e){return new Hg(e)}},Ey=class e extends Sy{static label=[`PKMS`,`SECP256K1`];constructor(){super(e.label)}async decodePrivateKey(e){return new gy(gg.decode(e).getValue())}async decodePublicKey(e){let t=gg.decode(e);return new _y(this.bytesEncoder.decode(t.getValue()))}},Dy=class{bytesEncoder;encoders=[new qv,new Jv,new vy];decoders=[new wy,new Ty,new Ey];constructor(e=fg.bytesToHexEncoder()){this.bytesEncoder=e}registerEncoder(e){this.encoders.push(e)}registerDecoder(e){this.decoders.push(e)}decodeMessage(e){return this.bytesEncoder.decode(e)}async decodePrivateKey(e){for(let t of this.decoders)if(await t.isAcceptingPrivateKeyDecodingRequest(e))return await t.decodePrivateKey(e);throw Error(`Invalid private key format: no decoder found`)}async decodePublicKey(e){for(let t of this.decoders)if(await t.isAcceptingPublicKeyDecodingRequest(e))return await t.decodePublicKey(e);throw Error(`Invalid private key format: no decoder found`)}decodeSignature(e){return this.bytesEncoder.decode(e)}encodeMessage(e){return this.bytesEncoder.encode(e)}async encodePrivateKey(e){for(let t of this.encoders)if(await t.isAcceptingPrivateKeyEncodingRequest(e))return await t.encodePrivateKey(e);throw Error(`No encoder found`)}async encodePublicKey(e){for(let t of this.encoders)if(await t.isAcceptingPublicKeyEncodingRequest(e))return await t.encodePublicKey(e);throw Error(`No encoder found`)}encodeSignature(e){return this.bytesEncoder.encode(e)}},Oy;try{Oy=new TextDecoder}catch{}var U,ky,W=0,Ay=[],jy=105,My=57342,Ny=57343,Py=57337,Fy=6,Iy={},Ly=11281e4,Ry=1681e4,zy=Ay,By=0,G={},Vy,Hy,Uy=0,Wy=0,Gy,Ky,qy=[],Jy=[],Yy,Xy,Zy,Qy={useRecords:!1,mapsAsObjects:!0},$y=!1,eb=2;try{Function(``)}catch{eb=1/0}var tb=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[ab(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(U)return kb(()=>(Ab(),this?this.decode(t,n):e.prototype.decode.call(Qy,t,n)));ky=n>-1?n:t.length,W=0,By=0,Wy=0,Hy=null,zy=Ay,Gy=null,U=t;try{Xy=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw U=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(G=this,Yy=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return Vy=this.structures,nb();(!Vy||Vy.length>0)&&(Vy=[])}else G=Qy,(!Vy||Vy.length>0)&&(Vy=[]),Yy=null;return nb()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;$y=!0;let a=this?this.decode(e,i):Mb.decode(e,i);if(t){if(t(a)===!1)return;for(;W<i;)if(r=W,t(nb())===!1)return}else{for(n=[a];W<i;)r=W,n.push(nb());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{$y=!1,Ab()}}};function nb(){try{let e=K();if(Gy){if(W>=Gy.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}W=Gy.postBundlePosition,Gy=null}if(W==ky)Vy=null,U=null,Ky&&=null;else if(W>ky){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!$y)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Ab(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function K(){let e=U[W++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=U[W++];break;case 25:if(t==7)return mb();e=Xy.getUint16(W),W+=2;break;case 26:if(t==7){let e=Xy.getFloat32(W);if(G.useFloat32>2){let t=jb[(U[W]&127)<<1|U[W+1]>>7];return W+=4,(t*e+(e>0?.5:-.5)>>0)/t}return W+=4,e}if(e=Xy.getUint32(W),W+=4,t===1)return-1-e;break;case 27:if(t==7){let e=Xy.getFloat64(W);return W+=8,e}if(t>1){if(Xy.getUint32(W)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=Xy.getUint32(W+4)}else G.int64AsNumber?(e=Xy.getUint32(W)*4294967296,e+=Xy.getUint32(W+4)):e=Xy.getBigUint64(W);W+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=K())!=Iy;){if(r>=Ly)throw Error(`Array length exceeds ${Ly}`);e[r++]=n}return t==4?e:t==3?e.join(``):Ng.concat(e);case 5:let i;if(G.mapsAsObjects){let e={},t=0;if(G.keyMap)for(;(i=K())!=Iy;){if(t++>=Ry)throw Error(`Property count exceeds ${Ry}`);e[ab(G.decodeKey(i))]=K()}else for(;(i=K())!=Iy;){if(t++>=Ry)throw Error(`Property count exceeds ${Ry}`);e[ab(i)]=K()}return e}else{Zy&&=(G.mapsAsObjects=!0,!1);let e=new Map;if(G.keyMap){let t=0;for(;(i=K())!=Iy;){if(t++>=Ry)throw Error(`Map size exceeds ${Ry}`);e.set(G.decodeKey(i),K())}}else{let t=0;for(;(i=K())!=Iy;){if(t++>=Ry)throw Error(`Map size exceeds ${Ry}`);e.set(i,K())}}return e}case 7:return Iy;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return db(e);case 3:if(Wy>=W)return Hy.slice(W-Uy,(W+=e)-Uy);if(Wy==0&&ky<140&&e<32){let t=e<16?ub(e):lb(e);if(t!=null)return t}return ob(e);case 4:if(e>=Ly)throw Error(`Array length exceeds ${Ly}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=K();return t;case 5:if(e>=Ry)throw Error(`Map size exceeds ${Ly}`);if(G.mapsAsObjects){let t={};if(G.keyMap)for(let n=0;n<e;n++)t[ab(G.decodeKey(K()))]=K();else for(let n=0;n<e;n++)t[ab(K())]=K();return t}else{Zy&&=(G.mapsAsObjects=!0,!1);let t=new Map;if(G.keyMap)for(let n=0;n<e;n++)t.set(G.decodeKey(K()),K());else for(let n=0;n<e;n++)t.set(K(),K());return t}case 6:if(e>=Py){let t=Vy[e&8191];if(t)return t.read||=ib(t),t.read();if(e<65536){if(e==Ny){let e=Db(),t=K(),n=K();gb(t,n);let r={};if(G.keyMap)for(let t=2;t<e;t++){let e=G.decodeKey(n[t-2]);r[ab(e)]=K()}else for(let t=2;t<e;t++){let e=n[t-2];r[ab(e)]=K()}return r}else if(e==My){let e=Db(),t=K();for(let n=2;n<e;n++)gb(t++,K());return K()}else if(e==Py)return Eb();if(G.getShared&&(Ob(),t=Vy[e&8191],t))return t.read||=ib(t),t.read()}}let n=qy[e];if(n)return n.handlesRead?n(K):n(K());{let t=K();for(let n=0;n<Jy.length;n++){let r=Jy[n](e,t);if(r!==void 0)return r}return new hb(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(Yy||bb())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}var rb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ib(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=U[W++];if(e&=31,e>23)switch(e){case 24:e=U[W++];break;case 25:e=Xy.getUint16(W),W+=2;break;case 26:e=Xy.getUint32(W),W+=4;break;default:throw Error(`Expected array header, but got `+U[W-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(K);t=t.next}if(this.slowReads++>=eb){let n=this.length==e?this:this.slice(0,e);return t=G.keyMap?Function(`r`,`return {`+n.map(e=>G.decodeKey(e)).map(e=>rb.test(e)?ab(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>rb.test(e)?ab(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(K)}let n={};if(G.keyMap)for(let t=0;t<e;t++)n[ab(G.decodeKey(this[t]))]=K();else for(let t=0;t<e;t++)n[ab(this[t])]=K();return n}return e.slowReads=0,t}function ab(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}var ob=sb;function sb(e){let t;if(e<16&&(t=ub(e)))return t;if(e>64&&Oy)return Oy.decode(U.subarray(W,W+=e));let n=W+e,r=[];for(t=``;W<n;){let e=U[W++];if(!(e&128))r.push(e);else if((e&224)==192){let t=U[W++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=U[W++]&63,n=U[W++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=U[W++]&63,n=U[W++]&63,i=U[W++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=cb.apply(String,r),r.length=0)}return r.length>0&&(t+=cb.apply(String,r)),t}var cb=String.fromCharCode;function lb(e){let t=W,n=Array(e);for(let r=0;r<e;r++){let e=U[W++];if((e&128)>0){W=t;return}n[r]=e}return cb.apply(String,n)}function ub(e){if(e<4)if(e<2){if(e===0)return``;{let e=U[W++];if((e&128)>1){--W;return}return cb(e)}}else{let t=U[W++],n=U[W++];if((t&128)>0||(n&128)>0){W-=2;return}if(e<3)return cb(t,n);let r=U[W++];if((r&128)>0){W-=3;return}return cb(t,n,r)}else{let t=U[W++],n=U[W++],r=U[W++],i=U[W++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){W-=4;return}if(e<6){if(e===4)return cb(t,n,r,i);{let e=U[W++];if((e&128)>0){W-=5;return}return cb(t,n,r,i,e)}}else if(e<8){let a=U[W++],o=U[W++];if((a&128)>0||(o&128)>0){W-=6;return}if(e<7)return cb(t,n,r,i,a,o);let s=U[W++];if((s&128)>0){W-=7;return}return cb(t,n,r,i,a,o,s)}else{let a=U[W++],o=U[W++],s=U[W++],c=U[W++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){W-=8;return}if(e<10){if(e===8)return cb(t,n,r,i,a,o,s,c);{let e=U[W++];if((e&128)>0){W-=9;return}return cb(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=U[W++],u=U[W++];if((l&128)>0||(u&128)>0){W-=10;return}if(e<11)return cb(t,n,r,i,a,o,s,c,l,u);let d=U[W++];if((d&128)>0){W-=11;return}return cb(t,n,r,i,a,o,s,c,l,u,d)}else{let l=U[W++],u=U[W++],d=U[W++],f=U[W++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){W-=12;return}if(e<14){if(e===12)return cb(t,n,r,i,a,o,s,c,l,u,d,f);{let e=U[W++];if((e&128)>0){W-=13;return}return cb(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=U[W++],m=U[W++];if((p&128)>0||(m&128)>0){W-=14;return}if(e<15)return cb(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=U[W++];if((h&128)>0){W-=15;return}return cb(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function db(e){return G.copyBuffers?Uint8Array.prototype.slice.call(U,W,W+=e):U.subarray(W,W+=e)}var fb=new Float32Array(1),pb=new Uint8Array(fb.buffer,0,4);function mb(){let e=U[W++],t=U[W++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return pb[3]=e&128|(n>>1)+56,pb[2]=(e&7)<<5|t>>3,pb[1]=t<<5,pb[0]=0,fb[0]}Array(4096);var hb=class{constructor(e,t){this.value=e,this.tag=t}};qy[0]=e=>new Date(e),qy[1]=e=>new Date(Math.round(e*1e3)),qy[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},qy[3]=e=>BigInt(-1)-qy[2](e),qy[4]=e=>+(e[1]+`e`+e[0]),qy[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));var gb=(e,t)=>{e-=57344;let n=Vy[e];n&&n.isShared&&((Vy.restoreStructures||=[])[e]=n),Vy[e]=t,t.read=ib(t)};qy[jy]=e=>{let t=e.length,n=e[1];gb(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[ab(t)]=e[i]}return r},qy[14]=e=>Gy?Gy[0].slice(Gy.position0,Gy.position0+=e):new hb(e,14),qy[15]=e=>Gy?Gy[1].slice(Gy.position1,Gy.position1+=e):new hb(e,15);var _b={Error,RegExp};qy[27]=e=>(_b[e[0]]||Error)(e[1],e[2]);var vb=e=>{if(U[W++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw U.length<W&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return Yy=Yy?t.concat(Yy.slice(t.length)):t,Yy.prefixes=e(),Yy.suffixes=e(),e()};vb.handlesRead=!0,qy[51]=vb,qy[Fy]=e=>{if(!Yy)if(G.getShared)Ob();else return new hb(e,Fy);if(typeof e==`number`)return Yy[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},qy[28]=e=>{Ky||(Ky=new Map,Ky.id=0);let t=Ky.id++,n=W,r=U[W],i;i=r>>5==4?[]:{};let a={target:i};Ky.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(W=n,i=o,Ky.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},qy[28].handlesRead=!0,qy[29]=e=>{let t=Ky.get(e);return t.used=!0,t.target},qy[258]=e=>new Set(e),(qy[259]=e=>(G.mapsAsObjects&&(G.mapsAsObjects=!1,Zy=!0),e())).handlesRead=!0;function yb(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function bb(){if(!Yy)if(G.getShared)Ob();else throw Error(`No packed values available`);return Yy}var xb=1399353956;Jy.push((e,t)=>{if(e>=225&&e<=255)return yb(bb().prefixes[e-224],t);if(e>=28704&&e<=32767)return yb(bb().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return yb(bb().prefixes[e-1879048192],t);if(e>=216&&e<=223)return yb(t,bb().suffixes[e-216]);if(e>=27647&&e<=28671)return yb(t,bb().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return yb(t,bb().suffixes[e-1811939328]);if(e==xb)return{packedValues:Yy,structures:Vy.slice(0),version:t};if(e==55799)return t});var Sb=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Cb=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],wb=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Cb.length;e++)Tb(Cb[e],wb[e]);function Tb(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;qy[i?t:t-4]=r==1||i==Sb?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!G.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function Eb(){let e=Db(),t=W+K();for(let t=2;t<e;t++){let e=Db();W+=e}let n=W;return W=t,Gy=[sb(Db()),sb(Db())],Gy.position0=0,Gy.position1=0,Gy.postBundlePosition=W,W=n,K()}function Db(){let e=U[W++]&31;if(e>23)switch(e){case 24:e=U[W++];break;case 25:e=Xy.getUint16(W),W+=2;break;case 26:e=Xy.getUint32(W),W+=4;break}return e}function Ob(){if(G.getShared){let e=kb(()=>(U=null,G.getShared()))||{},t=e.structures||[];G.sharedVersion=e.version,Yy=G.sharedValues=e.packedValues,Vy===!0?G.structures=Vy=t:Vy.splice.apply(Vy,[0,t.length].concat(t))}}function kb(e){let t=ky,n=W,r=By,i=Uy,a=Wy,o=Hy,s=zy,c=Ky,l=Gy,u=new Uint8Array(U.slice(0,ky)),d=Vy,f=G,p=$y,m=e();return ky=t,W=n,By=r,Uy=i,Wy=a,Hy=o,zy=s,Ky=c,Gy=l,U=u,$y=p,Vy=d,G=f,Xy=new DataView(U.buffer,U.byteOffset,U.byteLength),m}function Ab(){U=null,Ky=null,Vy=null}var jb=Array(147);for(let e=0;e<256;e++)jb[e]=+(`1e`+Math.floor(45.15-e*.30103));var Mb=new tb({useRecords:!1}),Nb=Mb.decode;Mb.decodeMultiple;var Pb={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Fb;try{Fb=new TextEncoder}catch{}var Ib,Lb,Rb=typeof globalThis==`object`&&globalThis.Buffer,zb=Rb!==void 0,Bb=zb?Rb.allocUnsafeSlow:Uint8Array,Vb=zb?Rb:Uint8Array,Hb=256,Ub=zb?4294967296:2144337920,Wb,q,Gb,J=0,Kb,qb=null,Jb=61440,Yb=/[\u0080-\uFFFF]/,Xb=Symbol(`record-id`),Zb=class extends tb{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Vb.prototype.utf8Write?function(e,t){return q.utf8Write(e,t,q.byteLength-t)}:Fb&&Fb.encodeInto?function(e,t){return Fb.encodeInto(e,q.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(q||(q=new Bb(8192),Gb=new DataView(q.buffer,0,8192),J=0),Kb=q.length-10,Kb-J<2048?(q=new Bb(q.length),Gb=new DataView(q.buffer,0,q.length),Kb=q.length-10,J=0):c===512&&(J=J+7&2147483640),t=J,s.useSelfDescribedHeader&&(Gb.setUint32(J,3654940416),J+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(qb=[],qb.size=1/0):qb=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[Xb]===void 0&&(i[Xb]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[Xb]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,rx(o,t),t.values.length>0){q[J++]=216,q[J++]=51,ex(4);let e=t.values;v(e),ex(0),ex(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}Wb=c&hx;try{if(Wb)return;if(v(o),qb&&cx(t,v),s.offset=J,a&&a.idsToInsert){J+=a.idsToInsert.length*2,J>Kb&&b(J),s.offset=J;let e=sx(q.subarray(t,J),a.idsToInsert);return a=null,e}return c&512?(q.start=t,q.end=J,q):q.subarray(t,J)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][Xb]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=q.subarray(t,J);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(J=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{J>Kb&&(q=b(J));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?q[J++]=t+224:(q[J++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(qb&&r>=4&&r<1024){if((qb.size+=r)>Jb){let e,n=(qb[0]?qb[0].length*3+qb[1].length:0)+10;J+n>Kb&&(q=b(J+n)),q[J++]=217,q[J++]=223,q[J++]=249,q[J++]=qb.position?132:130,q[J++]=26,e=J-t,J+=4,qb.position&&cx(t,v),qb=[``,``],qb.size=0,qb.position=e}let e=Yb.test(n);qb[+!e]+=n,q[J++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(J+s>Kb&&(q=b(J+s)),r<64||!o){let e,t,o,s=J+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?q[s++]=t:t<2048?(q[s++]=t>>6|192,q[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,q[s++]=t>>18|240,q[s++]=t>>12&63|128,q[s++]=t>>6&63|128,q[s++]=t&63|128):(q[s++]=t>>12|224,q[s++]=t>>6&63|128,q[s++]=t&63|128);i=s-J-a}else i=o(n,J+a,s);i<24?q[J++]=96|i:i<256?(a<2&&q.copyWithin(J+2,J+1,J+1+i),q[J++]=120,q[J++]=i):i<65536?(a<3&&q.copyWithin(J+3,J+2,J+2+i),q[J++]=121,q[J++]=i>>8,q[J++]=i&255):(a<5&&q.copyWithin(J+5,J+3,J+3+i),q[J++]=122,Gb.setUint32(J,i),J+=4),J+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?q[J++]=n:n<256?(q[J++]=24,q[J++]=n):n<65536?(q[J++]=25,q[J++]=n>>8,q[J++]=n&255):(q[J++]=26,Gb.setUint32(J,n),J+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?q[J++]=31-n:n>=-256?(q[J++]=56,q[J++]=~n):n>=-65536?(q[J++]=57,Gb.setUint16(J,~n),J+=2):(q[J++]=58,Gb.setUint32(J,~n),J+=4);else if(!this.alwaysUseFloat&&n<0&&n>=-4294967296&&Math.floor(n)===n)q[J++]=58,Gb.setUint32(J,-1-n),J+=4;else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){q[J++]=250,Gb.setFloat32(J,n);let t;if(e<4||(t=n*jb[(q[J]&127)<<1|q[J+1]>>7])>>0===t){J+=4;return}else J--}q[J++]=251,Gb.setFloat64(J,n),J+=8}else if(r===`object`)if(!n)q[J++]=246;else{if(a){let e=a.get(n);if(e){if(q[J++]=216,q[J++]=29,q[J++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(J-t),J+=2;return}else a.set(n,{offset:J-t})}let e=n.constructor;if(e===Object)this.skipFunction===!0&&(n=Object.fromEntries([...Object.keys(n).filter(e=>typeof n[e]!=`function`).map(e=>[e,n[e]])])),y(n);else if(e===Array){i=n.length,i<24?q[J++]=128|i:ex(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(q[J++]=217,q[J++]=1,q[J++]=3),i=n.size,i<24?q[J++]=160|i:i<256?(q[J++]=184,q[J++]=i):i<65536?(q[J++]=185,q[J++]=i>>8,q[J++]=i&255):(q[J++]=186,Gb.setUint32(J,i),J+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=Ib.length;e<t;e++){let t=Lb[e];if(n instanceof t){let t=Ib[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?q[J++]=192|r:r<256?(q[J++]=216,q[J++]=r):r<65536?(q[J++]=217,q[J++]=r>>8,q[J++]=r&255):r>-1&&(q[J++]=218,Gb.setUint32(J,r),J+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(Wb){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}q[J++]=159;for(let e of n)v(e);q[J++]=255;return}if(n[Symbol.asyncIterator]||nx(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)q[J++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)q[J++]=27,Gb.setBigUint64(J,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)q[J++]=59,Gb.setBigUint64(J,-n-BigInt(1));else if(this.largeBigIntToFloat)q[J++]=251,Gb.setFloat64(J,Number(n));else{n>=BigInt(0)?q[J++]=194:(q[J++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);ox(new Uint8Array(e.reverse()),b);return}J+=8}else if(r===`undefined`)q[J++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?q[J++]=160|r:r<256?(q[J++]=184,q[J++]=r):r<65536?(q[J++]=185,q[J++]=r>>8,q[J++]=r&255):(q[J++]=186,Gb.setUint32(J,r),J+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{q[J++]=185;let n=J-t;J+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);q[n+++t]=r>>8,q[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[Xb]&1048576&&(c=a[Xb]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[Xb];if(d!==void 0)d&=65535,q[J++]=217,q[J++]=d>>8|224,q[J++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=Hb&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){q[J++]=217,q[J++]=d>>8|224,q[J++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[Xb]===void 0||a[Xb]&1048576)&&(a[Xb]=d),a=a[u[e]];a[Xb]=d|1048576,r=!0}else{if(a[Xb]=d,Gb.setUint32(J,3655335680),J+=3,o&&(g+=_*o),h.length>=Hb-l&&(h.shift()[Xb]=void 0),h.push(a),ex(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?q[J++]=128|s:ex(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>Ub)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Ub,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,q.length-1)>>12)+1<<12;let r=new Bb(n);return Gb=new DataView(r.buffer,0,n),q.copy?q.copy(r,0,t,e):r.set(q.slice(t,e)),J-=t,t=0,Kb=r.length-10,q=r},ee=100,x=1e3;this.encodeAsIterable=function(e,t){return re(e,t,te)},this.encodeAsAsyncIterable=function(e,t){return re(e,t,ie)};function*te(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):Qb(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*te(i,n[r]):yield*S(i,n,r):v(i)}}else if(i===Array){let r=e.length;ex(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||J-t>ee)?n.element?yield*te(r,n.element):yield*S(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){q[J++]=159;for(let r of e)r&&(typeof r==`object`||J-t>ee)?n.element?yield*te(r,n.element):yield*S(r,n,`element`):v(r);q[J++]=255}else nx(e)?(Qb(e.size,64),yield q.subarray(t,J),yield e,ne()):e[Symbol.asyncIterator]?(q[J++]=159,yield q.subarray(t,J),yield e,ne(),q[J++]=255):v(e);r&&J>t?yield q.subarray(t,J):J-t>ee&&(yield q.subarray(t,J),ne())}function*S(e,n,r){let i=J-t;try{v(e),J-t>ee&&(yield q.subarray(t,J),ne())}catch(a){if(a.iteratorNotHandled)n[r]={},J=t+i,yield*te.call(this,e,n[r]);else throw a}}function ne(){ee=x,s.encode(null,hx)}function re(e,t,n){return ee=t&&t.chunkThreshold?x=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,hx),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*ie(e,t){for(let n of te(e,t,!0)){let e=n.constructor;if(e===Vb||e===Uint8Array)yield n;else if(nx(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)ne(),e?yield*ie(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){q=e,Gb=new DataView(q.buffer,q.byteOffset,q.byteLength),J=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new $b(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function Qb(e,t){e<24?q[J++]=t|e:e<256?(q[J++]=t|24,q[J++]=e):e<65536?(q[J++]=t|25,q[J++]=e>>8,q[J++]=e&255):(q[J++]=t|26,Gb.setUint32(J,e),J+=4)}var $b=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function ex(e){e<24?q[J++]=128|e:e<256?(q[J++]=152,q[J++]=e):e<65536?(q[J++]=153,q[J++]=e>>8,q[J++]=e&255):(q[J++]=154,Gb.setUint32(J,e),J+=4)}var tx=typeof Blob>`u`?function(){}:Blob;function nx(e){if(e instanceof tx)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function rx(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)rx(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&rx(n,t),rx(e[n],t))}break;case`function`:console.log(e)}}var ix=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Lb=[Date,Set,Error,RegExp,hb,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,$b],Ib=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(q[J++]=26,Gb.setUint32(J,n),J+=4):(q[J++]=251,Gb.setFloat64(J,n),J+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){ox(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||zb&&this.tagUint8Array!==!1))return 64},encode(e,t,n){ox(e,n)}},ax(68,1),ax(69,2),ax(70,4),ax(71,8),ax(72,1),ax(77,2),ax(78,4),ax(79,8),ax(85,4),ax(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){q[J++]=216,q[J++]=51,ex(4);let e=n.values;t(e),ex(0),ex(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){Gb.setUint32(J,3655335424),J+=3;let n=r.slice(0);n.unshift(57344),n.push(new hb(e.version,1399353956)),t(n)}else t(new hb(e.version,1399353956))}}];function ax(e,t){return!ix&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(zb?Rb.from(i,r,n):new Uint8Array(i,r,n))}}}function ox(e,t){let n=e.byteLength;n<24?q[J++]=64+n:n<256?(q[J++]=88,q[J++]=n):n<65536?(q[J++]=89,q[J++]=n>>8,q[J++]=n&255):(q[J++]=90,Gb.setUint32(J,n),J+=4),J+n>=q.length&&t(J+n),q.set(e.buffer?e:new Uint8Array(e),J),J+=n}function sx(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function cx(e,t){Gb.setUint32(qb.position+e,J-qb.position-e+1);let n=qb;qb=null,t(n[0]),t(n[1])}var lx=new Zb({useRecords:!1}),ux=lx.encode;lx.encodeAsIterable,lx.encodeAsAsyncIterable;var{NEVER:dx,ALWAYS:fx,DECIMAL_ROUND:px,DECIMAL_FIT:mx}=Pb,hx=2048,gx=class e{static encoder=new Zb({tagUint8Array:!1});decode(t){return e.encoder.decode(t)}encode(t){return e.encoder.encode(t)}},_x=class e{static defaultStringSignatureEncoder(){return new Dy(fg.defaultBytesToStringEncoder())}static defaultStringPublicKeyEncryptionEncoder(){return Vv.createBase64HCVPkeEncoder()}static cryptoBinaryEncoder=new gx;static getCryptoBinaryEncoder(){return e.cryptoBinaryEncoder}},Y=class e{static encoder=_x.getCryptoBinaryEncoder();static logger=ts.getLogger([`utils`]);static computeMicroblockHashFromHeader(t){let n=e.encodeMicroblockHeader(t);return j.Hashes.sha256AsBinary(n)}static checkHeaderList(t){let n=t.length;if(n===0)return{valid:!0,hashes:[]};if(n===1)return{valid:!0,hashes:[j.Hashes.sha256AsBinary(t[0])]};let r=[],i=null,a=ts.getProviderLogger();for(let n of t.reverse()){let t=j.Hashes.sha256AsBinary(n);if(i&&!k.binaryIsEqual(t,i))return a.error(`Received headers mismatch: Expected ${k.binaryToHexa(i)}, got ${k.binaryToHexa(t)}: aborting verification`),{valid:!1,hashes:[]};r.push(t),i=e.previousHashFromHeader(n)}return{valid:!0,hashes:r}}static previousHashFromHeader(t){return e.decodeMicroblockHeader(t).previousHash}static encodeVirtualBlockchainInfo(e){return this.encodeObjectToBinary(L(Vh,e))}static decodeVirtualBlockchainInfo(e){return L(Vh,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainState(e){return this.encodeObjectToBinary(L(Bh,e))}static decodeVirtualBlockchainState(e){return L(Bh,this.decodeObjectFromBinary(e))}static encodeMicroblockBody(e){return this.encodeObjectToBinary(L(Sh,e))}static decodeMicroblockBody(e){return L(Sh,this.decodeObjectFromBinary(e))}static encodeSection(e){return this.encodeObjectToBinary(L(xh,e))}static decodeSection(e){return L(xh,this.decodeObjectFromBinary(e))}static encodeMicroblockHeader(e){return this.encodeObjectToBinary(L(Nm,e))}static decodeMicroblockHeader(t){let n=this.decodeObjectFromBinary(t),r=L(Nm,n);if(!k.binaryIsEqual(n.bodyHash,r.bodyHash))throw e.logger.error(`Modified validated object: ${JSON.stringify(n)} vs ${JSON.stringify(r)}`),Error(`Modified body hash detected during deserialization: ${n.bodyHash} vs ${r.bodyHash}`);return r}static encodeEscrowParameters(e){return this.encodeObjectToBinary(L(Gh,e))}static decodeEscrowParameters(e){return L(Gh,this.decodeObjectFromBinary(e))}static encodeEscrowLock(e){return this.encodeObjectToBinary(L(Kh,e))}static decodeEscrowLock(e){return L(Kh,this.decodeObjectFromBinary(e))}static encodeVestingParameters(e){return this.encodeObjectToBinary(L(qh,e))}static decodeVestingParameters(e){return L(qh,this.decodeObjectFromBinary(e))}static encodeVestingLock(e){return this.encodeObjectToBinary(L(Jh,e))}static decodeVestingLock(e){return L(Jh,this.decodeObjectFromBinary(e))}static encodeNodeStakingParameters(e){return this.encodeObjectToBinary(L(Yh,e))}static decodeNodeStakingParameters(e){return L(Yh,this.decodeObjectFromBinary(e))}static encodeNodeStakingLock(e){return this.encodeObjectToBinary(L(Xh,e))}static decodeNodeStakingLock(e){return L(Xh,this.decodeObjectFromBinary(e))}static encodeLock(e){return this.encodeObjectToBinary(L(Zh,e))}static decodeLock(e){return L(Zh,this.decodeObjectFromBinary(e))}static encodeAccountBreakdown(e){return this.encodeObjectToBinary(L(Qh,e))}static decodeAccountBreakdown(e){return L(Qh,this.decodeObjectFromBinary(e))}static encodeAccountState(e){return this.encodeObjectToBinary(L($h,e))}static decodeAccountState(e){return L($h,this.decodeObjectFromBinary(e))}static encodeAccountInformation(e){return this.encodeObjectToBinary(L(eg,e))}static decodeAccountInformation(e){return L(eg,this.decodeObjectFromBinary(e))}static encodeMicroblockInformation(e){return this.encodeObjectToBinary(L(Hh,e))}static decodeMicroblockInformation(e){return L(Hh,this.decodeObjectFromBinary(e))}static encodeObjectToBinary(t){return e.encoder.encode(t)}static decodeObjectFromBinary(t){return e.encoder.decode(t)}},vx=86400,yx=class{priceStructure;constructor(e){this.priceStructure=e,this.priceStructure.sort((e,t)=>e.maximumNumberOfDays-t.maximumNumberOfDays)}getNumberOfDaysOfStorage(e,t){return t>0?Math.max(1,Math.round((t-e)/vx)):this.priceStructure[this.priceStructure.length-1].maximumNumberOfDays}getStoragePrice(e,t){let n=this.getBreakdown(e,t).reduce((e,t)=>e+t.priceInAtomics,0);return mn.createAtomic(n)}getBreakdown(e,t){let n=e.getAmountAsAtomic(),r=[];for(let e=0,i=0;i<t;e++){let a=this.priceStructure[e],o,s;a==null?(o=t-i,s=0):(o=Math.min(a.maximumNumberOfDays,t)-i,s=a.pricingRate);let c=Math.floor(n*o*s/100);r.push({numberOfDays:o,pricingRate:s,priceInAtomics:c}),i+=o}return r}},bx=class e{provider;static DEFAULT_GAS_PRICE=mn.createAtomic(1);constructor(e){this.provider=e}async computeFees(t,n,r,i=k.getTimestampInSeconds()){if(r<0)throw Error(`Invalid expiration day`);let a=this.computeSizeInBytesOfMicroblock(n),o=n.getGasPrice(),s=o.isZero()?e.DEFAULT_GAS_PRICE:o,c=(dr+1*a)*s.getAmountAsAtomic(),l=mn.createAtomic(c),u=new yx((await this.provider.getProtocolState()).getPriceStructure()),d=u.getNumberOfDaysOfStorage(i,r),f=u.getStoragePrice(l,d),p=mn.createAtomic(this.getAdditionalCosts(t)*s.getAmountAsAtomic());return f.add(p),f}getAdditionalCosts(e){switch(e){case Ya.SECP256K1:return 1e3;case Ya.ML_DSA_65:return 5e3;case Ya.PKMS_SECP256K1:return 0}return 0}computeSizeInBytesOfMicroblock(e){let t=e.getAllSections();if(t.length===0)return 0;if(e.getMaxFees().isZero())return this.getSizeOfListOfSections(t);{let e=t[t.length-1].type===O.SIGNATURE?t.slice(0,t.length-1):t;return this.getSizeOfListOfSections(e)}}getSizeOfListOfSections(e){return e.reduce((e,t)=>e+Y.encodeSection(t).length,0)}},xx=class{static getGenesisFeesCalculationFormula(e){return new bx(e)}static getFeesCalculationFormulaByVersion(e,t){return this.getGenesisFeesCalculationFormula(e)}},Sx=class e{internalState;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({signatureSchemeId:0,publicKeyHeight:0})}toObject(){return this.internalState}updateSignatureScheme(e){this.internalState.signatureSchemeId=e}updatePublicKeyHeight(e){this.internalState.publicKeyHeight=e}getPublicKeyHeight(){return this.internalState.publicKeyHeight}getPublicKeySchemeId(){return this.internalState.signatureSchemeId}},Cx=class e{hash;constructor(e){this.hash=e}static from(t){let n=typeof t==`string`,r=t instanceof Uint8Array;if(!n&&!r)throw TypeError(`Expected hash of type string or Uint8Array: got ${typeof t}`);let i=fg.bytesToHexEncoder();return new e(typeof t==`string`?i.decode(t):t)}static fromHex(t){return new e(fg.bytesToHexEncoder().decode(t))}encode(e=new mg){return e.encode(this.hash).toUpperCase()}toBytes(){return new Uint8Array(this.hash)}equals(e){return this.hash.every((t,n)=>t===e.hash[n])}},wx=class e{internalState;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({organizationId:k.getNullHash(),descriptionHeight:0})}clone(){return new e({...this.internalState})}toObject(){return this.internalState}setOrganizationId(e){this.internalState.organizationId=e}setDescriptionHeight(e){this.internalState.descriptionHeight=e}getOrganizationId(){return Cx.from(this.internalState.organizationId)}getDescriptionHeight(){return this.internalState.descriptionHeight}},Tx=class e{internalState;static UNDEFINED_APPLICATION_ID=new Uint8Array;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({allowedAdditionalWriters:[],actors:[],allowedPkeSchemeIds:[],allowedSignatureSchemeIds:[],applicationId:this.UNDEFINED_APPLICATION_ID,channels:[]})}getAdditionalAllowedWriters(){return this.internalState.allowedAdditionalWriters}addAdditionalWriter(e){this.internalState.allowedAdditionalWriters.push(e)}toObject(){return this.internalState}clone(){return new e(structuredClone(this.internalState))}createActor(e){this.internalState.actors.push(e)}createActorWithId(e,t){if(this.isActorDefinedById(e))throw new ae(`Id: ${e}`);this.internalState.actors[e]=t}setAllowedSignatureSchemeIds(e){this.internalState.allowedSignatureSchemeIds=e}setAllowedPkeSchemeIds(e){this.internalState.allowedPkeSchemeIds=e}setApplicationId(e){this.internalState.applicationId=e}isChannelDefinedById(e){return this.internalState.channels[e]!==void 0}isChannelDefinedByName(e){return this.internalState.channels.some(t=>t.name===e)}createChannel(e){if(!this.isActorDefinedById(e.creatorId))throw new ae(`Id: ${e.creatorId}`);if(this.isChannelDefinedByName(e.name))throw new ie(e.name);this.internalState.channels.push(e)}createChannelWithId(e,t){if(this.isChannelDefinedById(e))throw new ie(`Id: ${e}`);if(this.isActorDefinedById(t.creatorId))throw new ae(`Id: ${t.creatorId}`);if(this.isChannelDefinedByName(t.name))throw new ie(t.name);this.internalState.channels[e]=t}isActorDefinedByName(e){return this.internalState.actors.some(t=>t.name===e)}isActorDefinedById(e){return this.internalState.actors[e]!==void 0}getAllowedSignatureSchemes(){return this.internalState.allowedSignatureSchemeIds}getAllowedPkeSchemes(){return this.internalState.allowedPkeSchemeIds}getNumberOfActors(){return this.internalState.actors.length}getActorById(e){let t=this.internalState.actors[e];if(t===void 0)throw new ae(`ID: ${e}`);return t}getNumberOfChannels(){return this.internalState.channels.length}getApplicationId(){return Cx.from(this.internalState.applicationId)}getChannelIdFromChannelName(e){let t=this.internalState.channels.findIndex(t=>t.name===e);if(t===void 0)throw new oe(e);return t}getChannelCreatorIdFromChannelId(e){return this.getChannelFromChannelId(e).creatorId}getChannelFromChannelId(e){let t=this.internalState.channels[e];if(t===void 0)throw new oe(`ID: ${e}`);return t}getActorByName(e){let t=this.internalState.actors.find(t=>t.name===e);if(t===void 0)throw new ae(e);return t}getActorIdByName(e){let t=this.internalState.actors.findIndex(t=>t.name===e);if(t===-1)throw new ae(e);return t}updateActor(e,t){if(!this.isActorDefinedById(e))throw new ae(`Id: ${e}`);this.internalState.actors[e]=t}updateChannel(e,t){if(!this.isChannelDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.channels[e]=t}getAllActors(){return this.internalState.actors}getAllChannels(){return this.internalState.channels}},Ex;(function(e){e.INITIAL_PROTOCOL_VERSION_NAME=`Clermont`})(Ex||={});var Dx=class e{internalState;constructor(e){this.internalState=e}static createFromObject(t){let n=am(Ch,t);if(n.success)return new e(n.output);throw Error(`Provided internal state is not valid: ${n.issues}`)}static createInitialState(){return new e({organizationId:k.getNullHash(),currentProtocolVariables:{protocolVersionName:Ex.INITIAL_PROTOCOL_VERSION_NAME,protocolVersion:1,feesCalculationVersion:1,globalStateUpdaterVersion:1,applicationLedgerInternalStateUpdaterVersion:1,applicationInternalStateUpdaterVersion:1,organizationInternalStateUpdaterVersion:1,validatorNodeInternalStateUpdaterVersion:1,accountInternalStateUpdaterVersion:1,protocolInternalStateUpdaterVersion:1,minimumNodeStakingAmountInAtomics:mn.create(1e6).getAmountAsAtomic(),maximumNodeStakingAmountInAtomics:mn.create(1e7).getAmountAsAtomic(),unstakingDelayInDays:30,maxBlockSizeInBytes:4194304,priceStructure:[{pricingRate:100,maximumNumberOfDays:7},{pricingRate:70,maximumNumberOfDays:30},{pricingRate:40,maximumNumberOfDays:365},{pricingRate:20,maximumNumberOfDays:3650},{pricingRate:10,maximumNumberOfDays:36500}],abciVersion:1},protocolUpdates:[]})}getAbciVersion(){return this.internalState.currentProtocolVariables.abciVersion}getMaximumBlockSizeInBytes(){return this.internalState.currentProtocolVariables.maxBlockSizeInBytes}getProtocolVariables(){return this.internalState.currentProtocolVariables}getApplicationLedgerInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationLedgerInternalStateUpdaterVersion}getApplicationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationInternalStateUpdaterVersion}getOrganizationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.organizationInternalStateUpdaterVersion}getValidatorNodeInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.validatorNodeInternalStateUpdaterVersion}getAccountInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.accountInternalStateUpdaterVersion}getProtocolInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.protocolInternalStateUpdaterVersion}getMinimumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.minimumNodeStakingAmountInAtomics}getMaximumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.maximumNodeStakingAmountInAtomics}getUnstakingDelayInDays(){return this.internalState.currentProtocolVariables.unstakingDelayInDays}getPriceStructure(){return this.internalState.currentProtocolVariables.priceStructure}toObject(){return this.internalState}getFeesCalculationVersion(){return this.internalState.currentProtocolVariables.feesCalculationVersion}setProtocolVersion(e){this.internalState.currentProtocolVariables.protocolVersion=e}setProtocolVersionName(e){this.internalState.currentProtocolVariables.protocolVersionName=e}setProtocolVariables(e){this.internalState.currentProtocolVariables=e}setOrganizationId(e){this.internalState.organizationId=e}},Ox=class e{internalState;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({accountId:k.getNullHash(),descriptionHeight:0})}toObject(){return this.internalState}getAccountIdAsBytes(){return this.internalState.accountId}getAccountId(){return Cx.from(this.internalState.accountId)}setAccountId(e){return this.internalState.accountId=e}getDescriptionHeight(){return this.internalState.descriptionHeight}updateDescriptionHeight(e){this.internalState.descriptionHeight=e}},kx=class e{internalState;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({cometbftPublicKeyDeclarationHeight:0,lastKnownApprovalStatus:!1,organizationId:k.getNullHash(),rpcEndpointHeight:0})}toObject(){return this.internalState}getOrganizationId(){return Cx.from(this.internalState.organizationId)}getLastKnownApprovalStatus(){return this.internalState.lastKnownApprovalStatus}getCometbftPublicKeyDeclarationHeight(){return this.internalState.cometbftPublicKeyDeclarationHeight}getRpcEndpointHeight(){return this.internalState.rpcEndpointHeight}clone(){return structuredClone(this)}setApprovalStatus(e){this.internalState.lastKnownApprovalStatus=e}setCometbftPublicKeyDeclarationHeight(e){this.internalState.cometbftPublicKeyDeclarationHeight=e}setOrganizationId(e){this.internalState.organizationId=e}setRpcEndpointDeclarationHeight(e){this.internalState.rpcEndpointHeight=e}},Ax=class{static createInternalStateFromObject(e,t){switch(e){case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:return Dx.createFromObject(t);case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:return Sx.createFromObject(t);case V.APPLICATION_VIRTUAL_BLOCKCHAIN:return wx.createFromObject(t);case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return Tx.createFromObject(t);case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return Ox.createFromObject(t);case V.NODE_VIRTUAL_BLOCKCHAIN:return kx.createFromObject(t);default:throw Error(`Unknown virtual blockchain type: ${e}`)}}},jx=class{constructor(){}async updateState(e,t,n){let r=Sx.createFromObject({...t.toObject()}),i=n.getAllSections();for(let e of i)switch(e.type){case O.ACCOUNT_PUBLIC_KEY:await this.publicKeyCallback(r,n,e);break;case O.ACCOUNT_TOKEN_ISSUANCE:await this.tokenIssuanceCallback(r,n,e);break;case O.ACCOUNT_CREATION:await this.creationCallback(r,n,e);break;case O.ACCOUNT_TRANSFER:await this.transferCallback(r,n,e);break;case O.ACCOUNT_VESTING_TRANSFER:await this.vestingTransferCallback(r,n,e);break;case O.ACCOUNT_ESCROW_TRANSFER:await this.escrowTransferCallback(r,n,e);break;case O.ACCOUNT_STAKE:await this.stakeCallback(r,n,e);break;case O.SIGNATURE:await this.signatureCallback(r,n,e);break}return r}async publicKeyCallback(e,t,n){e.updatePublicKeyHeight(t.getHeight()),e.updateSignatureScheme(n.schemeId)}async tokenIssuanceCallback(e,t,n){if(n.amount!=0x5af3107a4000)throw Error(`the amount of the initial token issuance is not the expected one`)}async creationCallback(e,t,n){}async transferCallback(e,t,n){}async vestingTransferCallback(e,t,n){if(n.cliffDurationDays<0)throw Error(`The cliff duration must be greater than or equal to 0`);if(n.vestingDurationDays<=0)throw Error(`The vesting duration must be greater than 0`);if(n.amount<=0)throw Error(`The amount must be greater than 0`)}async escrowTransferCallback(e,t,n){}async stakeCallback(e,t,n){}async signatureCallback(e,t,n){}},Mx=class{updateState(e,t,n){let r=t.clone();for(let e of n.getAllSections())e.type===O.APP_CREATION&&r.setOrganizationId(e.organizationId),e.type===O.APP_DESCRIPTION&&r.setDescriptionHeight(n.getHeight());return r}},Nx={[O.SIGNATURE]:`SIGNATURE`,[O.ALLOWED_ADDITIONAL_WRITER]:`ALLOWED_ADDITIONAL_WRITER_CREATION`,[O.CUSTOM]:`CUSTOM`,[O.PROTOCOL_CREATION]:`PROTOCOL_CREATION`,[O.PROTOCOL_UPDATE]:`PROTOCOL_UPDATE`,[O.PROTOCOL_VARIABLES]:`PROTOCOL_VARIABLES`,[O.ACCOUNT_PUBLIC_KEY]:`ACCOUNT_PUBLIC_KEY`,[O.ACCOUNT_TOKEN_ISSUANCE]:`ACCOUNT_TOKEN_ISSUANCE`,[O.ACCOUNT_CREATION]:`ACCOUNT_CREATION`,[O.ACCOUNT_TRANSFER]:`ACCOUNT_TRANSFER`,[O.ACCOUNT_VESTING_TRANSFER]:`ACCOUNT_VESTING_TRANSFER`,[O.ACCOUNT_ESCROW_TRANSFER]:`ACCOUNT_ESCROW_TRANSFER`,[O.ACCOUNT_ESCROW_SETTLEMENT]:`ACCOUNT_ESCROW_SETTLEMENT`,[O.ACCOUNT_STAKE]:`ACCOUNT_STAKE`,[O.ACCOUNT_UNSTAKE]:`ACCOUNT_UNSTAKE`,[O.VN_CREATION]:`VN_CREATION`,[O.VN_COMETBFT_PUBLIC_KEY_DECLARATION]:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,[O.VN_RPC_ENDPOINT]:`VN_RPC_ENDPOINT`,[O.VN_APPROVAL]:`VN_APPROVAL`,[O.VN_SLASHING_CANCELLATION]:`VN_SLASHING_CANCELLATION`,[O.ORG_CREATION]:`ORG_CREATION`,[O.ORG_DESCRIPTION]:`ORG_DESCRIPTION`,[O.APP_CREATION]:`APP_CREATION`,[O.APP_DESCRIPTION]:`APP_DESCRIPTION`,[O.APP_LEDGER_ALLOWED_SIG_SCHEMES]:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,[O.APP_LEDGER_ALLOWED_PKE_SCHEMES]:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,[O.APP_LEDGER_CREATION]:`APP_LEDGER_CREATION`,[O.APP_LEDGER_ACTOR_CREATION]:`APP_LEDGER_ACTOR_CREATION`,[O.APP_LEDGER_CHANNEL_CREATION]:`APP_LEDGER_CHANNEL_CREATION`,[O.APP_LEDGER_SHARED_SECRET]:`APP_LEDGER_SHARED_SECRET`,[O.APP_LEDGER_CHANNEL_INVITATION]:`APP_LEDGER_CHANNEL_INVITATION`,[O.APP_LEDGER_ACTOR_SUBSCRIPTION]:`APP_LEDGER_ACTOR_SUBSCRIPTION`,[O.APP_LEDGER_PUBLIC_CHANNEL_DATA]:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,[O.APP_LEDGER_PRIVATE_CHANNEL_DATA]:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,[O.APP_LEDGER_AUTHOR]:`APP_LEDGER_AUTHOR`,[O.APP_LEDGER_ENDORSEMENT_REQUEST]:`APP_LEDGER_ENDORSEMENT_REQUEST`},Px=class{static getSectionLabelFromSection(e){return this.getSectionLabelFromSectionType(e.type)}static getSectionLabelFromSectionType(e){return Nx[e]}},Fx=class e{logger=ts.getInternalStateUpdaterLogger(e.name);async updateState(e,t,n){let r=t.clone(),i=n.getHeight();for(let a of n.getAllSections())r=await this.updateStateFromSection(e,t,a,i);return r}async updateStateFromSection(e,t,n,r){let i=t;switch(n.type){case O.APP_LEDGER_ALLOWED_SIG_SCHEMES:await this.allowedSignatureSchemesCallback(n,i);break;case O.APP_LEDGER_ALLOWED_PKE_SCHEMES:await this.allowedPkeSchemesCallback(n,i);break;case O.APP_LEDGER_CREATION:await this.declarationCallback(n,i);break;case O.APP_LEDGER_ACTOR_CREATION:await this.actorCreationCallback(n,i);break;case O.APP_LEDGER_ACTOR_SUBSCRIPTION:await this.actorSubscriptionCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_CREATION:await this.channelCreationCallback(n,i);break;case O.APP_LEDGER_SHARED_SECRET:await this.sharedSecretCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_INVITATION:await this.invitationCallback(r,n,i);break;case O.APP_LEDGER_PUBLIC_CHANNEL_DATA:await this.publicChannelDataCallback(n,i);break;case O.APP_LEDGER_PRIVATE_CHANNEL_DATA:await this.privateChannelDataCallback(n,i);break;case O.ALLOWED_ADDITIONAL_WRITER:i.addAdditionalWriter(n.allowedWriterAccountId);break;case O.SIGNATURE:await this.endorserSignatureCallback();break;default:ts.getLogger().warn(`Unhandled section ${Px.getSectionLabelFromSection(n)}`)}return i}async allowedSignatureSchemesCallback(e,t){t.setAllowedSignatureSchemeIds(e.schemeIds)}async allowedPkeSchemesCallback(e,t){t.setAllowedPkeSchemeIds(e.schemeIds)}async declarationCallback(e,t){t.setApplicationId(e.applicationId)}async actorCreationCallback(e,t){let{id:n,name:r}=e,i=t.getNumberOfActors();if(n!=i)throw this.logger.error(`Actor creation failure: Invalid actor identifier found for actor ${r}: expected ${i}, got ${n}`),new re(n,t.getNumberOfActors());if(t.isActorDefinedByName(r))throw new ne(r);this.logger.info(`Creating actor ${r} with id ${n} `),t.createActor({name:r,subscribed:!1,signatureKeyHeight:0,pkeKeyHeight:0,sharedSecrets:[],invitations:[]})}async actorSubscriptionCallback(e,t,n){let r=n.getActorById(t.actorId);if(r===void 0)throw new ce(t.actorId);if(r.subscribed)throw new C(t.actorId);let i=t.signatureSchemeId,a=n.getAllowedSignatureSchemes(),o=a.length==0,s=a.includes(i);if(!o&&!s)throw new le(t.signatureSchemeId);let c=t.pkeSchemeId,l=n.getAllowedPkeSchemes(),u=l.length===0,d=l.includes(c);if(!u&&!d)throw new ue(t.pkeSchemeId);r.subscribed=!0,r.signatureKeyHeight=e,r.pkeKeyHeight=e}async channelCreationCallback(e,t){if(e.id!=t.getNumberOfChannels())throw new de(e.id);let n=e.name;if(t.isChannelDefinedByName(n))throw new ie(n);t.createChannel({name:e.name,isPrivate:e.isPrivate,creatorId:e.creatorId})}async sharedSecretCallback(e,t,n){let{hostId:r,guestId:i}=t;n.getActorById(r).sharedSecrets.push({height:e,peerActorId:i}),n.getActorById(i).sharedSecrets.push({height:e,peerActorId:r})}async invitationCallback(e,t,n){let{guestId:r,channelId:i}=t;n.getActorById(r).invitations.push({channelId:i,height:e}),ts.getLogger().debug(`Updated state after channel invitation callback: {state}`,{state:n})}async publicChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new oe(`invalid channel ID ${e.channelId}`)}async privateChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new oe(`invalid channel ID ${e.channelId}`)}async endorserSignatureCallback(){}},Ix=class{updateState(e,t,n){let r=t;for(let e of n.getAllSections())switch(e.type){case O.VN_CREATION:r.setOrganizationId(e.organizationId);break;case O.VN_APPROVAL:this.updateApproval(r,e);break;case O.VN_COMETBFT_PUBLIC_KEY_DECLARATION:r.setCometbftPublicKeyDeclarationHeight(n.getHeight());break;case O.VN_RPC_ENDPOINT:r.setRpcEndpointDeclarationHeight(n.getHeight());break}return r}updateApproval(e,t){e.setApprovalStatus(t.status)}},Lx=class e{logger=ts.getInternalStateUpdaterLogger(e.name);updateState(e,t,n){for(let e of n.getAllSections()){if(e.type===O.PROTOCOL_UPDATE){let n=e;this.logger.debug(`Updating protocol variables: ${JSON.stringify(n.protocolVariables)}`),t.setProtocolVariables(n.protocolVariables)}if(e.type===O.PROTOCOL_CREATION){let n=e.organizationId;this.logger.debug(`Updating organization ID: ${k.binaryToHexa(n)}`),t.setOrganizationId(n)}}return t}},Rx=class{updateState(e,t,n){for(let e of n.getAllSections())e.type===O.ORG_CREATION&&t.setAccountId(e.accountId),e.type===O.ORG_DESCRIPTION&&t.updateDescriptionHeight(n.getHeight());return t}},zx=class{static createApplicationLedgerInternalStateUpdater(e){return new Fx}static createAccountInternalStateUpdater(e){switch(e){case 1:return new jx;default:throw new i(`Unknown account local state version`)}}static createOrganizationInternalStateUpdater(e){switch(e){case 1:return new Rx;default:throw new i(`Unknown organization local state version`)}}static createProtocolInternalStateUpdater(e){return new Lx}static createValidatorNodeInternalStateUpdater(e){switch(e){case 1:return new Ix;default:throw new i(`Unknown validator node local state version`)}}static createApplicationInternalStateUpdater(e){switch(e){case 1:return new Mx;default:throw new i(`Unknown validator node local state version`)}}static defaultInternalStateUpdaterVersionByVbType(e){return 1}},Bx;(function(e){e[e.VALID=0]=`VALID`,e[e.TOO_FAR_IN_THE_PAST=1]=`TOO_FAR_IN_THE_PAST`,e[e.TOO_FAR_IN_THE_FUTURE=2]=`TOO_FAR_IN_THE_FUTURE`})(Bx||={});var Vx=F({header:Nm,body:Sh}),Hx=class e{static createGenesisMicroblock(t,n=0){let r=new e(t);return r.create(1,null,n),r}static createMicroblock(t,n,r,i){let a=new e(t);return a.create(n,r,i),a}static createGenesisAccountMicroblock(){return new e(V.ACCOUNT_VIRTUAL_BLOCKCHAIN)}static createGenesisValidatorNodeMicroblock(){return new e(V.NODE_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationMicroblock(){return new e(V.APPLICATION_VIRTUAL_BLOCKCHAIN)}static createGenesisProtocolMicroblock(){return new e(V.PROTOCOL_VIRTUAL_BLOCKCHAIN)}static createGenesisOrganizationMicroblock(){return new e(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationLedgerMicroblock(){return new e(V.APPLICATION_VIRTUAL_BLOCKCHAIN)}static loadFromSerializedMicroblock(t,n){let r=L(Vx,Nb(t));return e.loadFromHeaderAndBody(r.header,r.body,n)}static loadFromHeaderAndBody(t,n,r){let i=t.microblockType;if(r!==void 0&&r!==i)throw new o(`Microblock type mismatch: expected ${r}, got ${i} from header`);if(t.magicString!=`CMTS`)throw Error(`magic string '${Hn}' is missing`);let a=t.bodyHash,s=new e(i);s.header=structuredClone(t),s.addSections(n.sections);let c=s.computeBodyHash();if(!k.binaryIsEqual(a,c)){let e=fg.bytesToHexEncoder();throw new o(`Body hash in the header is different of the locally computed body hash: header.bodyHash=${e.encode(a)}, computed=${e.encode(c)}`)}return s.setMicroblockHash(s.computeHash()),s}static loadFromSerializedHeaderAndBody(t,n,r){let i=Y.decodeMicroblockHeader(t),a=Y.decodeMicroblockBody(n);return e.loadFromHeaderAndBody(i,a,r)}static computeInitialBodyHash(){return e.computeBodyHashFromSections([])}static computeMicroblockHash(e){let t=Y.encodeMicroblockHeader(e);return j.Hashes.sha256AsBinary(t)}static computeBodyHashFromSections(e){let t={sections:e},n=Y.encodeMicroblockBody(t);return j.Hashes.sha256AsBinary(n)}static generatePreviousHashForGenesisMicroblock(e,t=0){let n=j.Random.getBytes(24),r=k.getNullHash();return r[0]=e,r[1]=t>>24,r[2]=t>>16,r[3]=t>>8,r[4]=t,r.set(n,8),r}static logger=ts.getMicroblockLogger();hash;header;sections;type;constructor(t){let n=Math.floor(Date.now()/1e3),r=mn.zero().getAmountAsAtomic(),i={magicString:Hn,protocolVersion:1,microblockType:t,height:1,previousHash:e.generatePreviousHashForGenesisMicroblock(t,0),timestamp:n,maxFees:0,gasPrice:r,bodyHash:e.computeInitialBodyHash(),feesPayerAccount:k.getNullHash()};this.type=t,this.sections=[],this.header=i,this.hash=e.computeMicroblockHash(i)}create(t,n,r){if(t==1)n=e.generatePreviousHashForGenesisMicroblock(this.type,r);else if(n===null)throw Error(`previous hash not provided`);this.header={magicString:Hn,protocolVersion:1,microblockType:this.type,height:t,previousHash:n,timestamp:k.getTimestampInSeconds(),maxFees:0,gasPrice:0,bodyHash:k.getNullHash(),feesPayerAccount:k.getNullHash()},this.hash=e.computeMicroblockHash(this.header)}isSigned(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}updateTimestamp(){this.header.timestamp=k.getTimestampInSeconds(),this.hash=e.computeMicroblockHash(this.header)}getHeader(){return this.header}getHash(){return Cx.from(this.hash)}getHashAsBytes(){return this.hash}getTimestampAsDate(){return new Date(this.header.timestamp*1e3)}getHeight(){return this.header.height}getPreviousHash(){return Cx.from(this.header.previousHash)}getTimestamp(){return this.header.timestamp}getGas(){return this.getMaxFees()}getMaxFees(){return mn.createAtomic(this.header.maxFees)}setMaxFees(t){this.header.maxFees=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}setGas(e){this.setMaxFees(e)}setHeight(t){this.header.height=t,this.hash=e.computeMicroblockHash(this.header)}setGasPrice(t){this.header.gasPrice=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}getGasPrice(){return mn.createAtomic(this.header.gasPrice)}isFeesPayerAccountDefined(){return k.binaryIsEqual(this.getFeesPayerAccount(),k.getNullHash())==0}getFeesPayerAccount(){return this.header.feesPayerAccount}setTimestamp(t){this.header.timestamp=t,this.hash=e.computeMicroblockHash(this.header)}setFeesPayerAccount(t){this.header.feesPayerAccount=t,this.hash=e.computeMicroblockHash(this.header)}computeBodyHash(){return e.computeBodyHashFromSections(this.sections)}serializeHeader(){return Y.encodeMicroblockHeader(this.header)}serializedBody(){return Y.encodeMicroblockBody({sections:this.sections})}serialize(){let t=this.serializedBody(),n=this.header.bodyHash,r=this.serializeHeader();return{microblockHash:e.computeMicroblockHash(this.header),headerData:r,bodyHash:n,bodyData:t,microblockData:ux(L(Vx,{header:this.header,body:{sections:this.sections}}))}}getSection(e){let t=this.sections.find(t=>e(t));if(t===void 0)throw new Te;return t}getNumberOfSections(){return this.sections.length}getSections(e){return this.sections.filter(t=>e(t))}getSectionsByType(e){return this.getSections(t=>t.type===e)}getAllSections(){return this.sections}async seal(e,t={}){let n=t.feesPayerAccount;n&&this.setFeesPayerAccount(n);let r=typeof t.includeGas==`boolean`?t.includeGas:!0,i=await this.sign(e,r),a={type:O.SIGNATURE,signature:i,schemeId:e.getSignatureSchemeId()};this.addSection(a)}async sign(t,n=!0){let r=this.sections,i=e.computeBodyHashFromSections(r),a={...this.header,maxFees:n?this.header.maxFees:0,gasPrice:n?this.header.gasPrice:0,bodyHash:i},o=Y.encodeMicroblockHeader(a);return await t.sign(o)}async verify(t,n={includeGas:!0,verifiedSignatureIndex:`last`}){let r=typeof n.includeGas==`boolean`?n.includeGas:!0,o=this.getNumberOfSignatures();if(o===0)throw new a(`Microblock verification failure: The current microblock is not signed`);let s=n.verifiedSignatureIndex,c=o;if(typeof s==`number`){if(s<=0)throw new i(`verifiedSignatureIndex must be positive`);if(o<s)throw new i(`Invalid provided signature index ${s}: this microblock contains ${o} signatures`);c=s}else if(!(s===`last`||s===void 0))throw new i(`Unknown signature index: ${s} (type ${typeof s})`);let{signatureSection:l,sectionIndexInMicroblock:u}=this.getNthSignatureSectionAndIndexInMicroblock(c),d=this.sections.slice(0,u),f={...this.header,maxFees:r?this.header.maxFees:0,gasPrice:r?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(d)},p=Y.encodeMicroblockHeader(f),m=l.signature;return await t.verify(p,m)}getNthSignatureSectionAndIndexInMicroblock(e){if(e<=0)throw new i(`Cannot return the ${e}-th signature: should be strictly positive`);let t=this.sections.map((e,t)=>({section:e,index:t})).filter(({section:e,index:t})=>e.type===O.SIGNATURE);if(t.length<e)throw new i(`Cannot return the ${e}-th signature: only ${t.length} signature (index starting at 1)`);let n=t[e-1];if(n.section.type!==O.SIGNATURE)throw Error(`Returned section is not a signature section`);return{signatureSection:n.section,sectionIndexInMicroblock:n.index}}getNumberOfSignatures(){return this.sections.filter(e=>e.type===O.SIGNATURE).length}isLastSectionSignature(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}isTemporallyCloseTo(e=k.getTimestampInSeconds()){return this.header.timestamp<e-300?Bx.TOO_FAR_IN_THE_PAST:this.header.timestamp>e+120?Bx.TOO_FAR_IN_THE_FUTURE:Bx.VALID}hasSection(e){try{return this.getSectionByType(e),!0}catch(e){if(e instanceof Te)return!1;throw e}}containsOnlyTheseSections(e){return this.sections.every(t=>e.includes(t.type))}getIndexOfSection(e){return this.sections.findIndex(t=>t.type===e)}setAsSuccessorOf(t){let n=this.getType(),r=t.getType();if(n!==r)throw new i(`Cannot make this microblock the successor: expected microblock of type ${n}, got ${r}`);let a=t.getHash();this.setPreviousHash(a),this.setHeight(t.getHeight()+1),this.hash=e.computeMicroblockHash(this.header),e.logger.info(`Microblock ${k.binaryToHexa(this.hash)} updated as successor of microblock ${a.encode()}`)}countSectionsByType(e){return this.sections.filter(t=>t.type===e).length}addSections(t){e.logger.debug(`Adding sections to microblock: {names}`,()=>({names:t.map(e=>Px.getSectionLabelFromSection(e)).join(`, `)})),this.sections.push(...t),this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header)}addSection(e){this.addSections([e])}popSection(){let t=this.sections.pop();if(this.getNumberOfSections()==0||t===void 0)throw new a(`Cannot pop section from empty microblock`);return this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header),t}getSectionByType(e){let t=this.sections.find(t=>t.type===e);if(t===void 0)throw new Te;return t}toString(){let e=fg.bytesToHexEncoder(),t=`Microblock:
|
|
6
|
+
`}zo();var Bo={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function Vo(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${Do[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,Bo[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function Ho(e={}){let t=e.formatter??Vo,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}var Uo=null,Wo=new Set,Go=new Set,Ko=new Set;function qo(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function Jo(e){if(Uo!=null&&!e.reset)throw new es(`Already configured; if you want to reset, turn on the reset flag.`);if(Ko.size>0)throw new es(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);Xo();try{Yo(e,!1)}catch(e){throw e instanceof es&&Xo(),e}}function Yo(e,t){Uo=e;let n=!1,r=new Set;for(let t of e.loggers){qo(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new es(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=fo.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new es(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new es(`Filter not found: ${n}.`);a.filters.push(ao(t))}Wo.add(a)}fo.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)Ko.add(n);else throw new es(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Go.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)Ko.add(n);else throw new es(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Go.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?Qo:$o)}else addEventListener(`unload`,t?Qo:$o);let i=fo.getLogger([`logtape`,`meta`]);n||i.sinks.push(Ho()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function Xo(){$o(),Zo()}function Zo(){let e=fo.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,Wo.clear(),Uo=null}async function Qo(){$o();let e=[];for(let t of Ko)e.push(t[Symbol.asyncDispose]()),Ko.delete(t);await Promise.all(e)}function $o(){for(let e of Go)e[Symbol.dispose]();Go.clear()}var es=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}},ts=class{static getLogger(e=[]){return lo([`@cmts-dev/carmentis-sdk`,...e])}static getProviderLogger(){return this.getLogger([`provider`])}static getMemoryProviderLogger(){return this.getLogger([`provider`,`memory`])}static async enableLogs(){this.enableLogsSync()}static enableLogsSync(){Jo({sinks:{console:Ho()},loggers:[{category:`@cmts-dev/carmentis-sdk`,lowestLevel:`debug`,sinks:[`console`]}]})}static getNetworkProviderLogger(){return this.getLogger([`provider`,`network`])}static getMicroblockLogger(){return this.getLogger([`microblock`])}static getVirtualBlockchainLogger(){return this.getLogger([`virtual-blockchain`])}static getInternalStateUpdaterLogger(e){return this.getLogger([`internal-state-updater`,e])}static getAbstractProviderLogger(e){return this.getLogger([`provider`,e])}static getMicroblockStructureCheckerLogger(){return this.getLogger([`microblock`,`structure-checker`])}},k={numberToHexa:rs,truncateString:is,truncateStringMiddle:as,getNullHash:os,getTimestampInSeconds:ss,encodeDay:ls,decodeDay:us,dateToDay:ds,dayToDate:fs,addDaysToTimestamp:ps,timestampDifferenceInDays:ms,bufferToUint8Array:hs,binaryToHexa:gs,binaryFromHexa:_s,binaryFrom:vs,binaryIsEqual:ys,binaryCompare:bs,intToByteArray:xs,byteArrayToInt:Ss,getGenesisEpochInTimestamp:cs},ns=ts.getLogger([`utils`]);function rs(e,t){return e.toString(16).toUpperCase().padStart(t||1,`0`)}function is(e,t){return e.slice(0,t)+(e.length>t?`(...)`:``)}function as(e,t,n){return e.length<=t+n?e:e.slice(0,t)+`(...)`+e.slice(e.length-n)}function os(){return new Uint8Array(32)}function ss(){return Math.floor(Date.now()/1e3)}function cs(){return 0}function ls(e,t,n){return e<<9|t<<5|n}function us(e){let t=e&31,n=e>>5&15;return[e>>>9,n,t]}function ds(e){let t=e.getDate(),n=e.getMonth()+1;return ls(e.getFullYear(),n,t)}function fs(e){let[t,n,r]=us(e);return new Date(Date.UTC(t,n-1,r))}function ps(e,t){let n=new Date(e*1e3);return Math.floor(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+t)/1e3)}function ms(e,t){return Math.round((t-e)/86400)}function hs(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)}function gs(e){return[...e].map(e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(``)}function _s(e){if(typeof e!=`string`)throw new i(`Expecting hex-string value: received ${typeof e}`);if(!e.match(/^([\da-f]{2})*$/gi))throw new i(`Expecting hex-string value: received '${e}'`);let t=(e.match(/../g)||[]).map(e=>parseInt(e,16));return new Uint8Array(t)}function vs(...e){let t=Array(e.length),n=Array(e.length),r=0;e.forEach((i,a)=>{let o=ro.getType(i);switch(o){case 4:n[a]=new Uint8Array(xs(i));break;case 3:n[a]=Qa.encode(i);break;case 12:n[a]=i;break;default:{let t=e.length,n=e.map(e=>Nn[ro.getType(e)]).join(`, `);throw Error(`unsupported type '${Nn[o]}' for Utils.binaryFrom(): got ${t} arguments of type ${n}`)}}t[a]=r,r+=n[a].length});let i=new Uint8Array(r);return t.forEach((e,t)=>{i.set(n[t],e)}),i}function ys(e,t){if(!(e instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof e}`);if(!(t instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof t}`);let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength!==r.byteLength)return ns.debug(`Comparison result is false (distinct length): ${n.byteLength} != ${r.byteLength}`),!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return ns.debug(`Comparison result is false (distinct value): ${n[e]} != ${r[e]}`),!1;return ns.debug(`Comparison result is true`),!0}function bs(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!=t.length)throw`cannot compare`;for(let n in e)if(e[n]<t[n])return-1;else if(e[n]>t[n])return 1;return 0}function xs(e,t=1){let n=[],r=e,i=t;for(;r>0||i>0;)n.push(r&255),r=Math.floor(r/256),i--;return n.reverse()}function Ss(e){return e.reduce((e,t)=>e*256+t,0)}var Cs=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function ws(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ts(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Es(e,...t){if(!ws(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Ds(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);Ts(e.outputLen),Ts(e.blockLen)}function Os(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ks(e,t){Es(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function As(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function js(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ms(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ns(e,t){return e<<32-t|e>>>t}function Ps(e,t){return e<<t|e>>>32-t>>>0}var Fs=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Is(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Ls(e){for(let t=0;t<e.length;t++)e[t]=Is(e[t]);return e}var Rs=Fs?e=>e:Ls,zs=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Bs={_0:48,_9:57,A:65,F:70,a:97,f:102};function Vs(e){if(e>=Bs._0&&e<=Bs._9)return e-Bs._0;if(e>=Bs.A&&e<=Bs.F)return e-(Bs.A-10);if(e>=Bs.a&&e<=Bs.f)return e-(Bs.a-10)}function Hs(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(zs)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Vs(e.charCodeAt(i)),a=Vs(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Us(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Ws(e){return typeof e==`string`&&(e=Us(e)),Es(e),e}function Gs(e){return typeof e==`string`&&(e=Us(e)),Es(e),e}function Ks(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Es(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function qs(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw Error(`options should be object or undefined`);return Object.assign(e,t)}var Js=class{};function Ys(e){let t=t=>e().update(Ws(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Xs(e){let t=(t,n)=>e(n).update(Ws(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function Zs(e=32){if(Cs&&typeof Cs.getRandomValues==`function`)return Cs.getRandomValues(new Uint8Array(e));if(Cs&&typeof Cs.randomBytes==`function`)return Uint8Array.from(Cs.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var Qs={getBytes:$s,getInteger:ec,getKey256:tc};function $s(e){return Zs(e)}function ec(e){let t=$s(6),n=0;for(let e=0;e<6;e++)n=n*256+t[e];return Math.floor(n/2**48*e)}function tc(){let e=$s(32);return k.binaryToHexa(e)}function nc(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function rc(e,t,n){return e&t^~e&n}function ic(e,t,n){return e&t^e&n^t&n}var ac=class extends Js{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Ms(this.buffer)}update(e){Os(this),e=Ws(e),Es(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Ms(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Os(this),ks(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,js(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;nc(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Ms(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},oc=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),sc=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),cc=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),lc=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),uc=BigInt(2**32-1),dc=BigInt(32);function fc(e,t=!1){return t?{h:Number(e&uc),l:Number(e>>dc&uc)}:{h:Number(e>>dc&uc)|0,l:Number(e&uc)|0}}function pc(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=fc(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var mc=(e,t,n)=>e>>>n,hc=(e,t,n)=>e<<32-n|t>>>n,gc=(e,t,n)=>e>>>n|t<<32-n,_c=(e,t,n)=>e<<32-n|t>>>n,vc=(e,t,n)=>e<<64-n|t>>>n-32,yc=(e,t,n)=>e>>>n-32|t<<64-n,bc=(e,t,n)=>e<<n|t>>>32-n,xc=(e,t,n)=>t<<n|e>>>32-n,Sc=(e,t,n)=>t<<n-32|e>>>64-n,Cc=(e,t,n)=>e<<n-32|t>>>64-n;function wc(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Tc=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ec=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Dc=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Oc=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,kc=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Ac=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,jc=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]),Mc=new Uint32Array(64),Nc=class extends ac{constructor(e=32){super(64,e,8,!1),this.A=oc[0]|0,this.B=oc[1]|0,this.C=oc[2]|0,this.D=oc[3]|0,this.E=oc[4]|0,this.F=oc[5]|0,this.G=oc[6]|0,this.H=oc[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Mc[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Mc[e-15],n=Mc[e-2],r=Ns(t,7)^Ns(t,18)^t>>>3;Mc[e]=(Ns(n,17)^Ns(n,19)^n>>>10)+Mc[e-7]+r+Mc[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ns(o,6)^Ns(o,11)^Ns(o,25),u=l+t+rc(o,s,c)+jc[e]+Mc[e]|0,d=(Ns(n,2)^Ns(n,13)^Ns(n,22))+ic(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){js(Mc)}destroy(){this.set(0,0,0,0,0,0,0,0),js(this.buffer)}},Pc=class extends Nc{constructor(){super(28),this.A=sc[0]|0,this.B=sc[1]|0,this.C=sc[2]|0,this.D=sc[3]|0,this.E=sc[4]|0,this.F=sc[5]|0,this.G=sc[6]|0,this.H=sc[7]|0}},Fc=pc(`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`.split(`.`).map(e=>BigInt(e))),Ic=Fc[0],Lc=Fc[1],Rc=new Uint32Array(80),zc=new Uint32Array(80),Bc=class extends ac{constructor(e=64){super(128,e,16,!1),this.Ah=lc[0]|0,this.Al=lc[1]|0,this.Bh=lc[2]|0,this.Bl=lc[3]|0,this.Ch=lc[4]|0,this.Cl=lc[5]|0,this.Dh=lc[6]|0,this.Dl=lc[7]|0,this.Eh=lc[8]|0,this.El=lc[9]|0,this.Fh=lc[10]|0,this.Fl=lc[11]|0,this.Gh=lc[12]|0,this.Gl=lc[13]|0,this.Hh=lc[14]|0,this.Hl=lc[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Rc[n]=e.getUint32(t),zc[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Rc[e-15]|0,n=zc[e-15]|0,r=gc(t,n,1)^gc(t,n,8)^mc(t,n,7),i=_c(t,n,1)^_c(t,n,8)^hc(t,n,7),a=Rc[e-2]|0,o=zc[e-2]|0,s=gc(a,o,19)^vc(a,o,61)^mc(a,o,6),c=Dc(i,_c(a,o,19)^yc(a,o,61)^hc(a,o,6),zc[e-7],zc[e-16]);Rc[e]=Oc(c,r,s,Rc[e-7],Rc[e-16])|0,zc[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=gc(u,d,14)^gc(u,d,18)^vc(u,d,41),v=_c(u,d,14)^_c(u,d,18)^yc(u,d,41),y=u&f^~u&m,b=d&p^~d&h,ee=kc(_,v,b,Lc[e],zc[e]),x=Ac(ee,g,t,y,Ic[e],Rc[e]),te=ee|0,S=gc(n,r,28)^vc(n,r,34)^vc(n,r,39),ne=_c(n,r,28)^yc(n,r,34)^yc(n,r,39),re=n&i^n&o^i&o,ie=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=wc(c|0,l|0,x|0,te|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let ae=Tc(te,ne,ie);n=Ec(ae,x,S,re),r=ae|0}({h:n,l:r}=wc(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=wc(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=wc(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=wc(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=wc(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=wc(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=wc(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=wc(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){js(Rc,zc)}destroy(){js(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Vc=class extends Bc{constructor(){super(48),this.Ah=cc[0]|0,this.Al=cc[1]|0,this.Bh=cc[2]|0,this.Bl=cc[3]|0,this.Ch=cc[4]|0,this.Cl=cc[5]|0,this.Dh=cc[6]|0,this.Dl=cc[7]|0,this.Eh=cc[8]|0,this.El=cc[9]|0,this.Fh=cc[10]|0,this.Fl=cc[11]|0,this.Gh=cc[12]|0,this.Gl=cc[13]|0,this.Hh=cc[14]|0,this.Hl=cc[15]|0}},Hc=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Uc=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Wc=class extends Bc{constructor(){super(28),this.Ah=Hc[0]|0,this.Al=Hc[1]|0,this.Bh=Hc[2]|0,this.Bl=Hc[3]|0,this.Ch=Hc[4]|0,this.Cl=Hc[5]|0,this.Dh=Hc[6]|0,this.Dl=Hc[7]|0,this.Eh=Hc[8]|0,this.El=Hc[9]|0,this.Fh=Hc[10]|0,this.Fl=Hc[11]|0,this.Gh=Hc[12]|0,this.Gl=Hc[13]|0,this.Hh=Hc[14]|0,this.Hl=Hc[15]|0}},Gc=class extends Bc{constructor(){super(32),this.Ah=Uc[0]|0,this.Al=Uc[1]|0,this.Bh=Uc[2]|0,this.Bl=Uc[3]|0,this.Ch=Uc[4]|0,this.Cl=Uc[5]|0,this.Dh=Uc[6]|0,this.Dl=Uc[7]|0,this.Eh=Uc[8]|0,this.El=Uc[9]|0,this.Fh=Uc[10]|0,this.Fl=Uc[11]|0,this.Gh=Uc[12]|0,this.Gl=Uc[13]|0,this.Hh=Uc[14]|0,this.Hl=Uc[15]|0}},Kc=Ys(()=>new Nc),qc=Ys(()=>new Pc),Jc=Ys(()=>new Bc),Yc=Ys(()=>new Vc),Xc=Ys(()=>new Gc),Zc=Ys(()=>new Wc),Qc=Jc,$c={sha256AsBinary:el,sha256:tl,sha512AsBinary:nl,sha512:rl};ts.getLogger([`utils`,`crypto`]);function el(e){if(!(e instanceof Uint8Array))throw new m(`Argument passed to compute sha256 is not an instance of Uint8Array: got ${typeof e}`);return Kc(e)}function tl(e){return k.binaryToHexa(el(e))}function nl(e){if(!(e instanceof Uint8Array))throw`Argument passed to compute sha512 is not an instance of Uint8Array`;return Qc(e)}function rl(e){return k.binaryToHexa(nl(e))}function il(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function al(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}function ol(e,...t){if(!il(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function sl(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function cl(e,t){ol(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ll(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ul(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function dl(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function fl(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var pl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ml=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,hl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function gl(e){if(ol(e),ml)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=hl[e[n]];return t}var _l={_0:48,_9:57,A:65,F:70,a:97,f:102};function vl(e){if(e>=_l._0&&e<=_l._9)return e-_l._0;if(e>=_l.A&&e<=_l.F)return e-(_l.A-10);if(e>=_l.a&&e<=_l.f)return e-(_l.a-10)}function yl(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(ml)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=vl(e.charCodeAt(i)),a=vl(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function bl(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function xl(e){return new TextDecoder().decode(e)}function Sl(e){if(typeof e==`string`)e=bl(e);else if(il(e))e=kl(e);else throw Error(`Uint8Array expected, got `+typeof e);return e}function Cl(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}var wl=(e,t)=>{function n(n,...r){if(ol(n),!pl)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];if(!t)throw Error(`nonce / iv required`);e.varSizeNonce?ol(t):ol(t,e.nonceLength)}let i=e.tagLength;i&&r[1]!==void 0&&ol(r[1]);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);ol(t)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,ol(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(ol(e),i&&e.length<i)throw Error(`invalid ciphertext length: smaller than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function Tl(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`invalid output length, expected `+e+`, got: `+t.length);if(n&&!Ol(t))throw Error(`invalid output, must be aligned`);return t}function El(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Dl(e,t,n){al(n);let r=new Uint8Array(16),i=fl(r);return El(i,0,BigInt(t),n),El(i,8,BigInt(e),n),r}function Ol(e){return e.byteOffset%4==0}function kl(e){return Uint8Array.from(e)}var Al=16,jl=new Uint8Array(16),Ml=ul(jl),Nl=225,Pl=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^Nl<<24&-(i&1)}},Fl=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function Il(e){e.reverse();let t=e[15]&1,n=0;for(let t=0;t<e.length;t++){let r=e[t];e[t]=r>>>1|n,n=(r&1)<<7}return e[0]^=-t&225,e}var Ll=e=>e>64*1024?8:e>1024?4:2,Rl=class{constructor(e,t){this.blockLen=Al,this.outputLen=Al,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=Sl(e),ol(e,16);let n=fl(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:Fl(r),s1:Fl(i),s2:Fl(a),s3:Fl(o)}),{s0:r,s1:i,s2:a,s3:o}=Pl(r,i,a,o);let c=Ll(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e<l;e++)for(let t=0;t<u;t++){let n=0,r=0,i=0,a=0;for(let o=0;o<c;o++){if(!(t>>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<<i)-1,f=0;for(let p of[e,t,n,r])for(let e=0;e<4;e++){let t=p>>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){sl(this),e=Sl(e),ol(e);let t=ul(e),n=Math.floor(e.length/Al),r=e.length%Al;for(let e=0;e<n;e++)this._updateBlock(t[e*4+0],t[e*4+1],t[e*4+2],t[e*4+3]);return r&&(jl.set(e.subarray(n*Al)),this._updateBlock(Ml[0],Ml[1],Ml[2],Ml[3]),dl(Ml)),this}destroy(){let{t:e}=this;for(let t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){sl(this),cl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ul(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e}digest(){let e=new Uint8Array(Al);return this.digestInto(e),this.destroy(),e}},zl=class extends Rl{constructor(e,t){e=Sl(e),ol(e);let n=Il(kl(e));super(n,t),dl(n)}update(e){e=Sl(e),sl(this);let t=ul(e),n=e.length%Al,r=Math.floor(e.length/Al);for(let e=0;e<r;e++)this._updateBlock(Fl(t[e*4+3]),Fl(t[e*4+2]),Fl(t[e*4+1]),Fl(t[e*4+0]));return n&&(jl.set(e.subarray(r*Al)),this._updateBlock(Fl(Ml[3]),Fl(Ml[2]),Fl(Ml[1]),Fl(Ml[0])),dl(Ml)),this}digestInto(e){sl(this),cl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ul(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e.reverse()}};function Bl(e){let t=(t,n)=>e(n,t.length).update(Sl(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}var Vl=Bl((e,t)=>new Rl(e,t));Bl((e,t)=>new zl(e,t));var Hl=16,Ul=4,Wl=new Uint8Array(Hl),Gl=283;function Kl(e){return e<<1^Gl&-(e>>7)}function ql(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Kl(e);return n}var Jl=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Kl(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return dl(e),t})(),Yl=e=>e<<24|e>>>8,Xl=e=>e<<8|e>>>24;function Zl(e,t){if(e.length!==256)throw Error(`Wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Xl),i=r.map(Xl),a=i.map(Xl),o=new Uint32Array(256*256),s=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var Ql=Zl(Jl,e=>ql(e,3)<<24|e<<16|e<<8|ql(e,2)),$l=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Kl(n))e[t]=n;return e})();function eu(e){ol(e);let t=e.length;if(![16,24,32].includes(t))throw Error(`aes: invalid key size, should be 16, 24 or 32, got `+t);let{sbox2:n}=Ql,r=[];Ol(e)||r.push(e=kl(e));let i=ul(e),a=i.length,o=e=>nu(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e<s.length;e++){let t=s[e-1];e%a===0?t=o(Yl(t))^$l[e/a-1]:a>6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return dl(...r),s}function tu(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function nu(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function ru(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=Ql,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a<l;a++){let a=e[c++]^tu(o,s,t,n,r,i),l=e[c++]^tu(o,s,n,r,i,t),u=e[c++]^tu(o,s,r,i,t,n),d=e[c++]^tu(o,s,i,t,n,r);t=a,n=l,r=u,i=d}return{s0:e[c++]^nu(a,t,n,r,i),s1:e[c++]^nu(a,n,r,i,t),s2:e[c++]^nu(a,r,i,t,n),s3:e[c++]^nu(a,i,t,n,r)}}function iu(e,t,n,r,i){ol(n,Hl),ol(r),i=Tl(r.length,i);let a=n,o=ul(a),s=fl(a),c=ul(r),l=ul(i),u=t?0:12,d=r.length,f=s.getUint32(u,t),{s0:p,s1:m,s2:h,s3:g}=ru(e,o[0],o[1],o[2],o[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^p,l[n+1]=c[n+1]^m,l[n+2]=c[n+2]^h,l[n+3]=c[n+3]^g,f=f+1>>>0,s.setUint32(u,f,t),{s0:p,s1:m,s2:h,s3:g}=ru(e,o[0],o[1],o[2],o[3]);let _=Hl*Math.floor(c.length/Ul);if(_<d){let e=new Uint32Array([p,m,h,g]),t=ll(e);for(let e=_,n=0;e<d;e++,n++)i[e]=r[e]^t[n];dl(e)}return i}function au(e,t,n,r,i){let a=i?i.length:0,o=e.create(n,r.length+a);i&&o.update(i);let s=Dl(8*r.length,8*a,t);o.update(r),o.update(s);let c=o.digest();return dl(s),c}var ou=wl({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,t,n){if(t.length<8)throw Error(`aes/gcm: invalid nonce length`);function r(e,t,r){let i=au(Vl,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){let n=eu(e),r=Wl.slice(),i=Wl.slice();if(iu(n,!1,i,i,r),t.length===12)i.set(t);else{let e=Wl.slice();El(fl(e),8,BigInt(t.length*8),!1);let n=Vl.create(r).update(t).update(e);n.digestInto(i),n.destroy()}return{xk:n,authKey:r,counter:i,tagMask:iu(n,!1,i,Wl)}}return{encrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=new Uint8Array(e.length+16),c=[t,n,a,o];Ol(e)||c.push(e=kl(e)),iu(t,!1,a,e,s.subarray(0,e.length));let l=r(n,o,s.subarray(0,s.length-16));return c.push(l),s.set(l,e.length),dl(...c),s},decrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=[t,n,o,a];Ol(e)||s.push(e=kl(e));let c=e.subarray(0,-16),l=e.subarray(-16),u=r(n,o,c);if(s.push(u),!Cl(u,l))throw Error(`aes/gcm: invalid ghash tag`);let d=iu(t,!1,a,c);return dl(...s),d}}}),su=ts.getLogger([`crypto`,`aes-gcm`]),cu={encryptGcm:lu,decryptGcm:uu};function lu(e,t,n){return ou(e,n).encrypt(t)}function uu(e,t,n){try{return ou(e,n).decrypt(t)}catch(e){throw su.warn(`{e}`,{e}),new f}}var du=BigInt(0),fu=BigInt(1),pu=BigInt(2),mu=BigInt(7),hu=BigInt(256),gu=BigInt(113),_u=[],vu=[],yu=[];for(let e=0,t=fu,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],_u.push(2*(5*r+n)),vu.push((e+1)*(e+2)/2%64);let i=du;for(let e=0;e<7;e++)t=(t<<fu^(t>>mu)*gu)%hu,t&pu&&(i^=fu<<(fu<<BigInt(e))-fu);yu.push(i)}var bu=pc(yu,!0),xu=bu[0],Su=bu[1],Cu=(e,t,n)=>n>32?Sc(e,t,n):bc(e,t,n),wu=(e,t,n)=>n>32?Cc(e,t,n):xc(e,t,n);function Tu(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Cu(a,o,1)^n[r],c=wu(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=vu[n],a=Cu(t,i,r),o=wu(t,i,r),s=_u[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=xu[r],e[1]^=Su[r]}js(n)}var Eu=class e extends Js{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,Ts(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=As(this.state)}clone(){return this._cloneInto()}keccak(){Rs(this.state32),Tu(this.state32,this.rounds),Rs(this.state32),this.posOut=0,this.pos=0}update(e){Os(this),e=Ws(e),Es(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Os(this,!1),Es(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Ts(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ks(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,js(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Du=(e,t,n)=>Ys(()=>new Eu(t,e,n)),Ou=Du(6,144,224/8),ku=Du(6,136,256/8),Au=Du(6,104,384/8),ju=Du(6,72,512/8);Du(1,144,224/8),Du(1,136,256/8),Du(1,104,384/8),Du(1,72,512/8);var Mu=(e,t,n)=>Xs((r={})=>new Eu(t,e,r.dkLen===void 0?n:r.dkLen,!0)),Nu=Mu(31,168,128/8),Pu=Mu(31,136,256/8),Fu=Es,Iu=Zs;function Lu(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}function Ru(...e){let t=e=>typeof e==`number`?e:e.bytesLen,n=e.reduce((e,n)=>e+t(n),0);return{bytesLen:n,encode:r=>{let i=new Uint8Array(n);for(let n=0,a=0;n<e.length;n++){let o=e[n],s=t(o),c=typeof o==`number`?r[n]:o.encode(r[n]);Fu(c,s),i.set(c,a),typeof o!=`number`&&c.fill(0),a+=s}return i},decode:r=>{Fu(r,n);let i=[];for(let n of e){let e=t(n),a=r.subarray(0,e);i.push(typeof n==`number`?a:n.decode(a)),r=r.subarray(e)}return i}}}function zu(e,t){let n=t*e.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==t)throw Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${t}`);let i=new Uint8Array(n);for(let t=0,n=0;t<r.length;t++){let a=e.encode(r[t]);i.set(a,n),a.fill(0),n+=a.length}return i},decode:t=>{Fu(t,n);let r=[];for(let n=0;n<t.length;n+=e.bytesLen)r.push(e.decode(t.subarray(n,n+e.bytesLen)));return r}}}function Bu(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function Vu(e){return(1<<e)-1}var Hu=new Uint8Array;function Uu(e,t=Hu){if(Fu(e),Fu(t),t.length>255)throw Error(`context should be less than 255 bytes`);return Ks(new Uint8Array([0,t.length]),t,e)}var Wu={"SHA2-256":{oid:Hs(`0609608648016503040201`),hash:Kc},"SHA2-384":{oid:Hs(`0609608648016503040202`),hash:Yc},"SHA2-512":{oid:Hs(`0609608648016503040203`),hash:Jc},"SHA2-224":{oid:Hs(`0609608648016503040204`),hash:qc},"SHA2-512/224":{oid:Hs(`0609608648016503040205`),hash:Zc},"SHA2-512/256":{oid:Hs(`0609608648016503040206`),hash:Xc},"SHA3-224":{oid:Hs(`0609608648016503040207`),hash:Ou},"SHA3-256":{oid:Hs(`0609608648016503040208`),hash:ku},"SHA3-384":{oid:Hs(`0609608648016503040209`),hash:Au},"SHA3-512":{oid:Hs(`060960864801650304020A`),hash:ju},"SHAKE-128":{oid:Hs(`060960864801650304020B`),hash:e=>Nu(e,{dkLen:32})},"SHAKE-256":{oid:Hs(`060960864801650304020C`),hash:e=>Pu(e,{dkLen:64})}};function Gu(e,t,n=Hu){if(Fu(t),Fu(n),n.length>255)throw Error(`context should be less than 255 bytes`);if(!Wu[e])throw Error(`unknown hash: `+e);let{oid:r,hash:i}=Wu[e],a=i(t);return Ks(new Uint8Array([1,n.length]),n,r,a)}function Ku(e,t=8){let n=e.toString(2).padStart(8,`0`).slice(-t).padStart(7,`0`).split(``).reverse().join(``);return Number.parseInt(n,2)}var qu=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Ku(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=s?128:n,p=+!!s;return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>{for(let t=1,r=128;r>p;r>>=1)for(let i=0;i<n;i+=2*r){let n=d[t++];for(let t=i;t<i+r;t++){let i=c(n*e[t+r]);e[t+r]=c(e[t]-i)|0,e[t]=c(e[t]+i)|0}}return e},decode:e=>{for(let t=f-1,r=1+p;r<f+p;r<<=1)for(let i=0;i<n;i+=2*r){let n=d[t--];for(let t=i;t<i+r;t++){let i=e[t];e[t]=c(i+e[t+r]),e[t+r]=c(n*(e[t+r]-i))}}for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}},bitsCoder:(e,r)=>{let i=Vu(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=new Uint8Array(a);for(let a=0,o=0,s=0,c=0;a<t.length;a++)for(o|=(r.encode(t[a])&i)<<s,s+=e;s>=8;s-=8,o>>=8)n[c++]=o&Vu(s);return n},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},Ju=e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),a.fill(0),r.fill(0)}}},Yu=Ju(Nu),Xu=Ju(Pu),Zu=256,Qu=8380417,$u=1753,ed=8347681,td=13,nd=Math.floor((Qu-1)/88)|0,rd=Math.floor((Qu-1)/32)|0,id={2:{K:4,L:4,D:td,GAMMA1:2**17,GAMMA2:nd,TAU:39,ETA:2,OMEGA:80},3:{K:6,L:5,D:td,GAMMA1:2**19,GAMMA2:rd,TAU:49,ETA:4,OMEGA:55},5:{K:8,L:7,D:td,GAMMA1:2**19,GAMMA2:rd,TAU:60,ETA:2,OMEGA:75}},ad=e=>new Int32Array(e),{mod:od,smod:sd,NTT:cd,bitsCoder:ld}=qu({N:Zu,Q:Qu,F:ed,ROOT_OF_UNITY:$u,newPoly:ad,isKyber:!1,brvBits:8}),ud=e=>e,dd=(e,t=ud,n=ud)=>ld(e,{encode:e=>t(n(e)),decode:e=>n(t(e))}),fd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=od(e[n]+t[n]);return e},pd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=od(e[n]-t[n]);return e},md=e=>{for(let t=0;t<Zu;t++)e[t]<<=td;return e},hd=(e,t)=>{for(let n=0;n<Zu;n++)if(Math.abs(sd(e[n]))>=t)return!0;return!1},gd=(e,t)=>{let n=ad(Zu);for(let r=0;r<e.length;r++)n[r]=od(e[r]*t[r]);return n};function _d(e){let t=ad(Zu);for(let n=0;n<Zu;){let r=e();if(r.length%3)throw Error(`RejNTTPoly: unaligned block`);for(let e=0;n<Zu&&e<=r.length-3;e+=3){let i=(r[e+0]|r[e+1]<<8|r[e+2]<<16)&8388607;i<Qu&&(t[n++]=i)}}return t}function vd(e){let{K:t,L:n,GAMMA1:r,GAMMA2:i,TAU:a,ETA:o,OMEGA:s}=e,{CRH_BYTES:c,TR_BYTES:l,C_TILDE_BYTES:u,XOF128:d,XOF256:f}=e;if(![2,4].includes(o))throw Error(`Wrong ETA`);if(![1<<17,1<<19].includes(r))throw Error(`Wrong GAMMA1`);if(![nd,rd].includes(i))throw Error(`Wrong GAMMA2`);let p=a*o,m=e=>{let t=od(e),n=sd(t,2*i)|0;return t-n===Qu-1?{r1:0,r0:n-1|0}:{r1:Math.floor((t-n)/(2*i))|0,r0:n}},h=e=>m(e).r1,g=e=>m(e).r0,_=(e,t)=>e<=i||e>Qu-i||e===Qu-i&&t===0?0:1,v=(e,t)=>{let n=Math.floor((Qu-1)/(2*i)),{r1:r,r0:a}=m(t);return e===1?a>0?od(r+1,n)|0:od(r-1,n)|0:r|0},y=e=>{let t=od(e),n=sd(t,2**td)|0;return{r1:Math.floor((t-n)/2**td)|0,r0:n}},b={bytesLen:s+t,encode:e=>{if(e===!1)throw Error(`hint.encode: hint is false`);let n=new Uint8Array(s+t);for(let r=0,i=0;r<t;r++){for(let t=0;t<Zu;t++)e[r][t]!==0&&(n[i++]=t);n[s+r]=i}return n},decode:e=>{let n=[],r=0;for(let i=0;i<t;i++){let t=ad(Zu);if(e[s+i]<r||e[s+i]>s)return!1;for(let n=r;n<e[s+i];n++){if(n>r&&e[n]<=e[n-1])return!1;t[e[n]]=1}r=e[s+i],n.push(t)}for(let t=r;t<s;t++)if(e[t]!==0)return!1;return n}},ee=dd(o===2?3:4,e=>o-e,e=>{if(!(-o<=e&&e<=o))throw Error(`malformed key s1/s3 ${e} outside of ETA range [${-o}, ${o}]`);return e}),x=dd(13,e=>(1<<td-1)-e),te=dd(10),S=dd(r===1<<17?18:20,e=>sd(r-e)),ne=zu(dd(i===nd?6:4),t),re=Ru(32,zu(te,t)),ie=Ru(32,32,l,zu(ee,n),zu(ee,t),zu(x,t)),ae=Ru(u,zu(S,n),b),oe=o===2?e=>e<15?2-e%5:!1:e=>e<9?4-e:!1;function se(e){let t=ad(Zu);for(let n=0;n<Zu;){let r=e();for(let e=0;n<Zu&&e<r.length;e+=1){let i=oe(r[e]&15),a=oe(r[e]>>4&15);i!==!1&&(t[n++]=i),n<Zu&&a!==!1&&(t[n++]=a)}}return t}let ce=e=>{let t=ad(Zu),n=Pu.create({}).update(e),r=new Uint8Array(Pu.blockLen);n.xofInto(r);let i=r.slice(0,8);for(let e=Zu-a,o=8,s=0,c=0;e<Zu;e++){let a=e+1;for(;a>e;)a=r[o++],!(o<Pu.blockLen)&&(n.xofInto(r),o=0);t[e]=t[a],t[a]=1-((i[s]>>c++&1)<<1),c>=8&&(s++,c=0)}return t},C=e=>{let t=ad(Zu),n=ad(Zu);for(let r=0;r<e.length;r++){let{r0:i,r1:a}=y(e[r]);t[r]=i,n[r]=a}return{r0:t,r1:n}},le=(e,t)=>{for(let n=0;n<Zu;n++)e[n]=v(t[n],e[n]);return e},ue=(e,t)=>{let n=ad(Zu),r=0;for(let i=0;i<Zu;i++){let a=_(e[i],t[i]);n[i]=a,r+=a}return{v:n,cnt:r}},de=Ru(32,64,32),fe={signRandBytes:32,keygen:e=>{let r=new Uint8Array(34),i=e===void 0;i&&(e=Iu(32)),Fu(e,32),r.set(e),i&&e.fill(0),r[32]=t,r[33]=n;let[a,o,s]=de.decode(Pu(r,{dkLen:de.bytesLen})),c=f(o),u=[];for(let e=0;e<n;e++)u.push(se(c.get(e&255,e>>8&255)));let p=[];for(let e=n;e<n+t;e++)p.push(se(c.get(e&255,e>>8&255)));let m=u.map(e=>cd.encode(e.slice())),h=[],g=[],_=d(a),v=ad(Zu);for(let e=0;e<t;e++){v.fill(0);for(let t=0;t<n;t++)fd(v,gd(_d(_.get(t,e)),m[t]));cd.decode(v);let{r0:t,r1:r}=C(fd(v,p[e]));h.push(t),g.push(r)}let y=re.encode([a,g]),b=Pu(y,{dkLen:l}),ee=ie.encode([a,s,b,u,p,h]);return _.clean(),c.clean(),Bu(a,o,s,u,p,m,v,h,g,b,r),{publicKey:y,secretKey:ee}},sign:(e,a,o,l=!1)=>{let[m,_,v,y,b,ee]=ie.decode(e),x=[],te=d(m);for(let e=0;e<t;e++){let t=[];for(let r=0;r<n;r++)t.push(_d(te.get(r,e)));x.push(t)}te.clean();for(let e=0;e<n;e++)cd.encode(y[e]);for(let e=0;e<t;e++)cd.encode(b[e]),cd.encode(ee[e]);let re=l?a:Pu.create({dkLen:c}).update(v).update(a).digest(),oe=o||new Uint8Array(32);Fu(oe);let se=Pu.create({dkLen:c}).update(_).update(oe).update(re).digest();Fu(se,c);let C=f(se,S.bytesLen);main_loop:for(let e=0;;){let a=[];for(let t=0;t<n;t++,e++)a.push(S.decode(C.get(e&255,e>>8)()));let o=a.map(e=>cd.encode(e.slice())),c=[];for(let e=0;e<t;e++){let t=ad(Zu);for(let r=0;r<n;r++)fd(t,gd(x[e][r],o[r]));cd.decode(t),c.push(t)}let l=c.map(e=>e.map(h)),d=Pu.create({dkLen:u}).update(re).update(ne.encode(l)).digest(),f=cd.encode(ce(d)),m=y.map(e=>gd(e,f));for(let e=0;e<n;e++)if(fd(cd.decode(m[e]),a[e]),hd(m[e],r-p))continue main_loop;let _=0,v=[];for(let e=0;e<t;e++){let t=cd.decode(gd(b[e],f)),n=pd(c[e],t).map(g);if(hd(n,i-p))continue main_loop;let r=cd.decode(gd(ee[e],f));if(hd(r,i))continue main_loop;fd(n,r);let a=ue(n,l[e]);v.push(a.v),_+=a.cnt}if(_>s)continue;C.clean();let te=ae.encode([d,m,v]);return Bu(d,m,v,f,l,c,o,a,se,re,y,b,ee,...x),te}throw Error(`Unreachable code path reached, report this error`)},verify:(e,i,a,o=!1)=>{let[f,m]=re.decode(e),h=Pu(e,{dkLen:l});if(a.length!==ae.bytesLen)return!1;let[g,_,v]=ae.decode(a);if(v===!1)return!1;for(let e=0;e<n;e++)if(hd(_[e],r-p))return!1;let y=o?i:Pu.create({dkLen:c}).update(h).update(i).digest(),b=cd.encode(ce(g)),ee=_.map(e=>e.slice());for(let e=0;e<n;e++)cd.encode(ee[e]);let x=[],te=d(f);for(let e=0;e<t;e++){let t=gd(cd.encode(md(m[e])),b),r=ad(Zu);for(let t=0;t<n;t++)fd(r,gd(_d(te.get(t,e)),ee[t]));let i=cd.decode(pd(r,t));x.push(le(i,v[e]))}te.clean();let S=Pu.create({dkLen:u}).update(y).update(ne.encode(x)).digest();for(let e of v)if(!(e.reduce((e,t)=>e+t,0)<=s))return!1;for(let e of _)if(hd(e,r-p))return!1;return Lu(g,S)}};return{internal:fe,keygen:fe.keygen,signRandBytes:fe.signRandBytes,sign:(e,t,n=Hu,r)=>{let i=Uu(t,n),a=fe.sign(e,i,r);return i.fill(0),a},verify:(e,t,n,r=Hu)=>fe.verify(e,Uu(t,r),n),prehash:e=>({sign:(t,n,r=Hu,i)=>{let a=Gu(e,n,r),o=fe.sign(t,a,i);return a.fill(0),o},verify:(t,n,r,i=Hu)=>fe.verify(t,Gu(e,n,i),r)})}}({...id[2]});var yd=vd({...id[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:Yu,XOF256:Xu});({...id[5]});var bd={generateKeyPair:xd,sign:Sd,verify:Cd};function xd(e){e??=Iu(32);let t=yd.keygen(e);return{publicKey:t.publicKey,privateKey:t.secretKey}}function Sd(e,t){return yd.sign(e,t)}function Cd(e,t,n){return yd.verify(e,t,n)}var wd=256,Td=3329,{mod:Ed,nttZetas:Dd,NTT:Od,bitsCoder:kd}=qu({N:wd,Q:Td,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),Ad={512:{N:wd,Q:Td,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:wd,Q:Td,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:wd,Q:Td,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},jd=e=>{if(e>=12)return{encode:e=>e,decode:e=>e};let t=2**(e-1);return{encode:t=>((t<<e)+Td/2)/Td,decode:n=>n*Td+t>>>e}},Md=e=>kd(e,jd(e));function Nd(e,t){for(let n=0;n<wd;n++)e[n]=Ed(e[n]+t[n])}function Pd(e,t){for(let n=0;n<wd;n++)e[n]=Ed(e[n]-t[n])}function Fd(e,t,n,r,i){return{c0:Ed(t*r*i+e*n),c1:Ed(e*r+t*n)}}function Id(e,t){for(let n=0;n<wd/2;n++){let r=Dd[64+(n>>1)];n&1&&(r=-r);let{c0:i,c1:a}=Fd(e[2*n+0],e[2*n+1],t[2*n+0],t[2*n+1],r);e[2*n+0]=i,e[2*n+1]=a}return e}function Ld(e){let t=new Uint16Array(wd);for(let n=0;n<wd;){let r=e();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let e=0;n<wd&&e+3<=r.length;e+=3){let i=(r[e+0]>>0|r[e+1]<<8)&4095,a=(r[e+1]>>4|r[e+2]<<4)&4095;i<Td&&(t[n++]=i),n<wd&&a<Td&&(t[n++]=a)}}return t}function Rd(e,t,n,r){let i=e(r*wd/4,t,n),a=new Uint16Array(wd),o=As(i),s=0;for(let e=0,t=0,n=0,i=0;e<o.length;e++){let c=o[e];for(let e=0;e<32;e++)n+=c&1,c>>=1,s+=1,s===r?(i=n,n=0):s===2*r&&(a[t++]=Ed(i-n),n=0,s=0)}if(s)throw Error(`sampleCBD: leftover bits: ${s}`);return a}var zd=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=Md(1),u=Md(c),d=Md(s),f=Ru(zu(Md(12),t),32),p=zu(Md(12),t),m=Ru(zu(d,t),u),h=Ru(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:f.bytesLen,cipherTextLen:m.bytesLen,keygen:e=>{Fu(e,32);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(Od.encode(Rd(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=Od.encode(Rd(n,l,t+e,a));for(let n=0;n<t;n++)Nd(r,Id(Ld(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return Bu(c,l,u,d,o,s),g},encrypt:(e,i,s)=>{let[c,u]=f.decode(e),d=[];for(let e=0;e<t;e++)d.push(Od.encode(Rd(n,s,e,a)));let p=r(u),h=new Uint16Array(wd),g=[];for(let e=0;e<t;e++){let r=Rd(n,s,t+e,o),i=new Uint16Array(wd);for(let n=0;n<t;n++)Nd(i,Id(Ld(p.get(e,n)),d[n]));Nd(r,Od.decode(i)),g.push(r),Nd(h,Id(c[e],d[e])),i.fill(0)}p.clean();let _=Rd(n,s,2*t,o);Nd(_,Od.decode(h));let v=l.decode(i);return Nd(v,_),Bu(c,d,h,_),m.encode([g,v])},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(wd);for(let e=0;e<t;e++)Nd(o,Id(a[e],Od.encode(r[e])));return Pd(i,Od.decode(o)),Bu(o,a,r),l.encode(i)}}};function Bd(e){let t=zd(e),{HASH256:n,HASH512:r,KDF:i}=e,{secretCoder:a,cipherTextLen:o}=t,s=t.publicKeyLen,c=Ru(t.secretKeyLen,t.publicKeyLen,32,32),l=c.bytesLen;return{publicKeyLen:s,msgLen:32,keygen:(e=Iu(64))=>{Fu(e,64);let{publicKey:r,secretKey:i}=t.keygen(e.subarray(0,32)),a=n(r),o=c.encode([i,r,a,e.subarray(32)]);return Bu(i,a),{publicKey:r,secretKey:o}},encapsulate:(i,o=Iu(32))=>{Fu(i,s),Fu(o,32);let c=i.subarray(0,384*e.K),l=a.encode(a.decode(c.slice()));if(!Lu(l,c))throw Bu(l),Error(`ML-KEM.encapsulate: wrong publicKey modulus`);Bu(l);let u=r.create().update(o).update(n(i)).digest(),d=t.encrypt(i,o,u.subarray(32,64));return u.subarray(32).fill(0),{cipherText:d,sharedSecret:u.subarray(0,32)}},decapsulate:(e,n)=>{Fu(n,l),Fu(e,o);let[a,s,u,d]=c.decode(n),f=t.decrypt(e,a),p=r.create().update(f).update(u).digest(),m=p.subarray(0,32),h=t.encrypt(s,f,p.subarray(32,64)),g=Lu(e,h),_=i.create({dkLen:32}).update(d).update(e).digest();return Bu(f,h,g?_:m),g?m:_}}}function Vd(e,t,n){return Pu.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Hd={HASH256:ku,HASH512:ju,KDF:Pu,XOF:Yu,PRF:Vd};({...Hd,...Ad[512]});var Ud=Bd({...Hd,...Ad[768]});({...Hd,...Ad[1024]});var Wd={generateKeyPair:Gd,encapsulate:Kd,decapsulate:qd};function Gd(e){return e??=Iu(64),Ud.keygen(e)}function Kd(e){return Ud.encapsulate(e)}function qd(e,t){return Ud.decapsulate(e,t)}var Jd=Kc,Yd=class extends Js{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ds(e);let n=Ws(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),js(i)}update(e){return Os(this),this.iHash.update(e),this}digestInto(e){Os(this),Es(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xd=(e,t,n)=>new Yd(e,t).update(n).digest();Xd.create=(e,t)=>new Yd(e,t);var{p:Zd,n:Qd,Gx:$d,Gy:ef,b:tf}={p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n},nf=32,rf=64,af=(e=``)=>{throw Error(e)},of=e=>typeof e==`bigint`,sf=e=>typeof e==`string`,cf=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,lf=(e,t)=>!cf(e)||typeof t==`number`&&t>0&&e.length!==t?af(`Uint8Array expected`):e,uf=e=>new Uint8Array(e),df=e=>Uint8Array.from(e),ff=(e,t)=>e.toString(16).padStart(t,`0`),pf=e=>Array.from(lf(e)).map(e=>ff(e,2)).join(``),mf={_0:48,_9:57,A:65,F:70,a:97,f:102},hf=e=>{if(e>=mf._0&&e<=mf._9)return e-mf._0;if(e>=mf.A&&e<=mf.F)return e-(mf.A-10);if(e>=mf.a&&e<=mf.f)return e-(mf.a-10)},gf=e=>{let t=`hex invalid`;if(!sf(e))return af(t);let n=e.length,r=n/2;if(n%2)return af(t);let i=uf(r);for(let n=0,a=0;n<r;n++,a+=2){let r=hf(e.charCodeAt(a)),o=hf(e.charCodeAt(a+1));if(r===void 0||o===void 0)return af(t);i[n]=r*16+o}return i},_f=(e,t)=>lf(sf(e)?gf(e):df(lf(e)),t),vf=()=>globalThis?.crypto,yf=()=>vf()?.subtle??af(`crypto.subtle must be defined`),bf=(...e)=>{let t=uf(e.reduce((e,t)=>e+lf(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},xf=(e=nf)=>vf().getRandomValues(uf(e)),Sf=BigInt,Cf=(e,t,n,r=`bad number: out of range`)=>of(e)&&t<=e&&e<n?e:af(r),A=(e,t=Zd)=>{let n=e%t;return n>=0n?n:t+n},wf=e=>A(e,Qd),Tf=(e,t)=>{(e===0n||t<=0n)&&af(`no inverse n=`+e+` mod=`+t);let n=A(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?A(i,t):af(`no inverse`)},Ef=e=>{let t=op[e];return typeof t!=`function`&&af(`hashes.`+e+` not set`),t},Df=e=>e instanceof If?e:af(`Point expected`),Of=e=>A(A(e*e)*e+tf),kf=e=>Cf(e,0n,Zd),Af=e=>Cf(e,1n,Zd),jf=e=>Cf(e,1n,Qd),Mf=e=>(e&1n)==0n,Nf=e=>Uint8Array.of(e),Pf=e=>Nf(Mf(e)?2:3),Ff=e=>{let t=Of(Af(e)),n=1n;for(let e=t,r=(Zd+1n)/4n;r>0n;r>>=1n)r&1n&&(n=n*e%Zd),e=e*e%Zd;return A(n*n)===t?n:af(`sqrt invalid`)},If=class e{static BASE;static ZERO;px;py;pz;constructor(e,t,n){this.px=kf(e),this.py=Af(t),this.pz=kf(n),Object.freeze(this)}static fromBytes(t){lf(t);let n,r=t[0],i=t.subarray(1),a=Vf(i,0,nf),o=t.length;if(o===nf+1&&[2,3].includes(r)){let t=Ff(a),i=Mf(t);Mf(Sf(r))!==i&&(t=A(-t)),n=new e(a,t,1n)}return o===rf+1&&r===4&&(n=new e(a,Vf(i,nf,rf),1n)),n?n.assertValidity():af(`bad point: not on curve`)}equals(e){let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:o}=Df(e),s=A(t*o),c=A(i*r),l=A(n*o),u=A(a*r);return s===c&&l===u}is0(){return this.equals(Rf)}negate(){return new e(this.px,A(-this.py),this.pz)}double(){return this.add(this)}add(t){let{px:n,py:r,pz:i}=this,{px:a,py:o,pz:s}=Df(t),c=0n,l=tf,u=0n,d=0n,f=0n,p=A(l*3n),m=A(n*a),h=A(r*o),g=A(i*s),_=A(n+r),v=A(a+o);_=A(_*v),v=A(m+h),_=A(_-v),v=A(n+i);let y=A(a+s);return v=A(v*y),y=A(m+g),v=A(v-y),y=A(r+i),u=A(o+s),y=A(y*u),u=A(h+g),y=A(y-u),f=A(c*v),u=A(p*g),f=A(u+f),u=A(h-f),f=A(h+f),d=A(u*f),h=A(m+m),h=A(h+m),g=A(c*g),v=A(p*v),h=A(h+g),g=A(m-g),g=A(c*g),v=A(v+g),m=A(h*v),d=A(d+m),m=A(y*v),u=A(_*u),u=A(u-m),m=A(_*h),f=A(y*f),f=A(f+m),new e(u,d,f)}multiply(e,t=!0){if(!t&&e===0n)return Rf;if(jf(e),e===1n)return this;if(this.equals(Lf))return mp(e).p;let n=Rf,r=Lf;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}toAffine(){let{px:e,py:t,pz:n}=this;if(this.equals(Rf))return{x:0n,y:0n};if(n===1n)return{x:e,y:t};let r=Tf(n,Zd);return A(n*r)!==1n&&af(`inverse invalid`),{x:A(e*r),y:A(t*r)}}assertValidity(){let{x:e,y:t}=this.toAffine();return Af(e),Af(t),A(t*t)===Of(e)?this:af(`bad point: not on curve`)}toBytes(e=!0){let{x:t,y:n}=this.assertValidity().toAffine(),r=Uf(t);return e?bf(Pf(n),r):bf(Nf(4),r,Uf(n))}static fromAffine(t){let{x:n,y:r}=t;return n===0n&&r===0n?Rf:new e(n,r,1n)}toHex(e){return pf(this.toBytes(e))}static fromPrivateKey(e){return Lf.multiply(Wf(e))}static fromHex(t){return e.fromBytes(_f(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}},Lf=new If($d,ef,1n),Rf=new If(0n,1n,0n);If.BASE=Lf,If.ZERO=Rf;var zf=(e,t,n)=>Lf.multiply(t,!1).add(e.multiply(n,!1)).assertValidity(),Bf=e=>Sf(`0x`+(pf(e)||`0`)),Vf=(e,t,n)=>Bf(e.subarray(t,n)),Hf=2n**256n,Uf=e=>gf(ff(Cf(e,0n,Hf),rf)),Wf=e=>Cf(of(e)?e:Bf(_f(e,nf)),1n,Qd,`private key invalid 3`),Gf=e=>e>Qd>>1n,Kf=(e,t=!0)=>Lf.multiply(Wf(e)).toBytes(t),qf=class e{r;s;recovery;constructor(e,t,n){this.r=jf(e),this.s=jf(t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(t){return lf(t,rf),new e(Vf(t,0,nf),Vf(t,nf,rf))}toBytes(){let{r:e,s:t}=this;return bf(Uf(e),Uf(t))}addRecoveryBit(t){return new e(this.r,this.s,t)}hasHighS(){return Gf(this.s)}toCompactRawBytes(){return this.toBytes()}toCompactHex(){return pf(this.toBytes())}recoverPublicKey(e){return np(this,e)}static fromCompact(t){return e.fromBytes(_f(t,rf))}assertValidity(){return this}normalizeS(){let{r:t,s:n,recovery:r}=this;return Gf(n)?new e(t,wf(-n),r):this}},Jf=e=>{let t=e.length*8-256;t>1024&&af(`msg invalid`);let n=Bf(e);return t>0?n>>Sf(t):n},Yf=e=>wf(Jf(lf(e))),Xf={lowS:!0},Zf={lowS:!0},Qf=(e,t,n=Xf)=>{[`der`,`recovered`,`canonical`].some(e=>e in n)&&af(`option not supported`);let{lowS:r,extraEntropy:i}=n;r??=!0;let a=Uf,o=Yf(_f(e)),s=a(o),c=Wf(t),l=[a(c),s];i&&l.push(i===!0?xf(nf):_f(i));let u=o,d=e=>{let t=Jf(e);if(!(1n<=t&&t<Qd))return;let n=Lf.multiply(t).toAffine(),i=wf(n.x);if(i===0n)return;let a=wf(Tf(t,Qd)*wf(u+wf(c*i)));if(a===0n)return;let o=a,s=(n.x===i?0:2)|Number(n.y&1n);return r&&Gf(a)&&(o=wf(-a),s^=1),new qf(i,o,s)};return{seed:bf(...l),k2sig:d}},$f=e=>{let t=uf(nf),n=uf(nf),r=0,i=uf(0),a=()=>{t.fill(1),n.fill(0),r=0},o=1e3,s=`drbg: tried 1000 values`;if(e){let e=(...e)=>op.hmacSha256Async(n,t,...e),c=async(r=i)=>{n=await e(Nf(0),r),t=await e(),r.length!==0&&(n=await e(Nf(1),r),t=await e())},l=async()=>(r++>=o&&af(s),t=await e(),t);return async(e,t)=>{a(),await c(e);let n;for(;!(n=t(await l()));)await c();return a(),n}}else{let e=(...e)=>Ef(`hmacSha256Sync`)(n,t,...e),c=(r=i)=>{n=e(Nf(0),r),t=e(),r.length!==0&&(n=e(Nf(1),r),t=e())},l=()=>(r++>=o&&af(s),t=e(),t);return(e,t)=>{a(),c(e);let n;for(;!(n=t(l()));)c();return a(),n}}},ep=(e,t,n=Xf)=>{let{seed:r,k2sig:i}=Qf(e,t,n);return $f(!1)(r,i)},tp=(e,t,n,r=Zf)=>{let{lowS:i}=r;i??=!0,`strict`in r&&af(`option not supported`);let a,o=e&&typeof e==`object`&&`r`in e;!o&&_f(e).length!==rf&&af(`signature must be 64 bytes`);try{a=o?new qf(e.r,e.s):qf.fromCompact(e);let r=Yf(_f(t)),s=If.fromBytes(_f(n)),{r:c,s:l}=a;if(i&&Gf(l))return!1;let u=Tf(l,Qd);return wf(zf(s,wf(r*u),wf(c*u)).toAffine().x)===c}catch{return!1}},np=(e,t)=>{let{r:n,s:r,recovery:i}=e;[0,1,2,3].includes(i)||af(`recovery id invalid`);let a=Yf(_f(t,nf)),o=i===2||i===3?n+Qd:n;Af(o);let s=bf(Pf(Sf(i)),Uf(o)),c=If.fromBytes(s),l=Tf(o,Qd);return zf(c,wf(-a*l),wf(r*l))},rp=e=>(e=_f(e),(e.length<nf+8||e.length>1024)&&af(`expected 40-1024b`),Uf(A(Bf(e),Qd-1n)+1n)),ip=()=>rp(xf(nf+16)),ap=`SHA-256`,op={hexToBytes:gf,bytesToHex:pf,concatBytes:bf,bytesToNumberBE:Bf,numberToBytesBE:Uf,mod:A,invert:Tf,hmacSha256Async:async(e,...t)=>{let n=yf(),r=`HMAC`,i=await n.importKey(`raw`,e,{name:r,hash:{name:ap}},!1,[`sign`]);return uf(await n.sign(r,i,bf(...t)))},hmacSha256Sync:void 0,hashToPrivateKey:rp,randomBytes:xf},sp={normPrivateKeyToScalar:Wf,isValidPrivateKey:e=>{try{return!!Wf(e)}catch{return!1}},randomPrivateKey:ip,precompute:(e=8,t=Lf)=>(t.multiply(3n),t)},cp=8,lp=Math.ceil(256/cp)+1,up=2**(cp-1),dp=()=>{let e=[],t=Lf,n=t;for(let r=0;r<lp;r++){n=t,e.push(n);for(let r=1;r<up;r++)n=n.add(t),e.push(n);t=n.double()}return e},fp=void 0,pp=(e,t)=>{let n=t.negate();return e?n:t},mp=e=>{let t=fp||=dp(),n=Rf,r=Lf,i=2**cp,a=i,o=Sf(i-1),s=Sf(cp);for(let i=0;i<lp;i++){let c=Number(e&o);e>>=s,c>up&&(c-=a,e+=1n);let l=i*up,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(pp(f,t[u])):n=n.add(pp(p,t[d]))}return{p:n,f:r}};op.hmacSha256Sync=(e,...t)=>Xd(Jd,e,op.concatBytes(...t));var hp={publicKeyFromPrivateKey:gp,sign:_p,verify:vp};function gp(e){return Kf(e)}function _p(e,t){return ep(Jd(t),e).toCompactRawBytes()}function vp(e,t,n){return tp(n,Jd(t),e)}var yp={SECP256K1:0,ML_DSA:1},bp=[{name:`SECP256K1`,signatureSectionSize:65},{name:`ML_DSA`,signatureSectionSize:3311}],xp={ML_KEM:0},Sp=[{name:`ML-KEM`}],j={...yp,SIG_SCHEMES:bp,...xp,KEM_SCHEMES:Sp,Random:Qs,Hashes:$c,Aes:cu,MLDsa:bd,MLKem:Wd,Secp256k1:hp},Cp;function wp(e){return{lang:e?.lang??Cp?.lang,message:e?.message,abortEarly:e?.abortEarly??Cp?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Cp?.abortPipeEarly}}var Tp;function Ep(e){return Tp?.get(e)}var Dp;function Op(e){return Dp?.get(e)}var kp;function Ap(e,t){return kp?.get(e)?.get(t)}function jp(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function Mp(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??jp(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Ap(e.reference,c.lang)??(l?Op(c.lang):null)??r.message??Ep(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Np(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},wp())}}}function Pp(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Fp(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Ip=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Lp(e){return{kind:`validation`,type:`integer`,reference:Lp,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Mp(this,`integer`,e,t),e}}}function Rp(e,t){return{kind:`validation`,type:`max_length`,reference:Rp,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Mp(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function zp(e,t){return{kind:`validation`,type:`max_value`,reference:zp,async:!1,expects:`<=${e instanceof Date?e.toJSON():jp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&Mp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():jp(e.value)}),e}}}function Bp(e){return{kind:`metadata`,type:`metadata`,reference:Bp,metadata:e}}function Vp(e,t){return{kind:`validation`,type:`min_value`,reference:Vp,async:!1,expects:`>=${e instanceof Date?e.toJSON():jp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Mp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():jp(e.value)}),e}}}function Hp(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Up(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Wp(e,t){return!e[`~run`]({value:t},{abortEarly:!0}).issues}function Gp(){return{kind:`schema`,type:`any`,reference:Gp,expects:`any`,async:!1,get"~standard"(){return Np(this)},"~run"(e){return e.typed=!0,e}}}function M(e,t){return{kind:`schema`,type:`array`,reference:M,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else Mp(this,`type`,e,t);return e}}}function Kp(e){return{kind:`schema`,type:`boolean`,reference:Kp,expects:`boolean`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Mp(this,`type`,e,t),e}}}function qp(e,t){return{kind:`schema`,type:`custom`,reference:qp,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function Jp(e,t){return{kind:`schema`,type:`instance`,reference:Jp,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:Mp(this,`type`,e,t),e}}}function Yp(e){return{kind:`schema`,type:`lazy`,reference:Yp,expects:`unknown`,async:!1,getter:e,get"~standard"(){return Np(this)},"~run"(e,t){return this.getter(e.value)[`~run`](e,t)}}}function N(e,t){return{kind:`schema`,type:`literal`,reference:N,expects:jp(e),async:!1,literal:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Mp(this,`type`,e,t),e}}}function Xp(e){return{kind:`schema`,type:`null`,reference:Xp,expects:`null`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===null?e.typed=!0:Mp(this,`type`,e,t),e}}}function P(e){return{kind:`schema`,type:`number`,reference:P,expects:`number`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function F(e,t){return{kind:`schema`,type:`object`,reference:F,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Up(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Hp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Mp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else Mp(this,`type`,e,t);return e}}}function Zp(e,t,n){return{kind:`schema`,type:`object_with_rest`,reference:Zp,expects:`Object`,async:!1,entries:e,rest:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Up(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Hp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Mp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(Pp(n,r)&&!(r in this.entries)){let i=this.rest[`~run`]({value:n[r]},t);if(i.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:n[r]};for(let t of i.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=i.issues,t.abortEarly){e.typed=!1;break}}i.typed||(e.typed=!1),e.value[r]=i.value}}}else Mp(this,`type`,e,t);return e}}}function Qp(e,t){return{kind:`schema`,type:`optional`,reference:Qp,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Np(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Up(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function $p(e,t){return{kind:`schema`,type:`picklist`,reference:$p,expects:Fp(e.map(jp),`|`),async:!1,options:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Mp(this,`type`,e,t),e}}}function em(e,t,n){return{kind:`schema`,type:`record`,reference:em,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Pp(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else Mp(this,`type`,e,t);return e}}}function I(e){return{kind:`schema`,type:`string`,reference:I,expects:`string`,async:!1,message:e,get"~standard"(){return Np(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Mp(this,`type`,e,t),e}}}function tm(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function nm(e,t){return{kind:`schema`,type:`union`,reference:nm,expects:Fp(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Np(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];Mp(this,`type`,e,t,{issues:tm(r)}),e.typed=!0}else if(i?.length===1)return i[0];else Mp(this,`type`,e,t,{issues:tm(i)});return e}}}function rm(){return{kind:`schema`,type:`unknown`,reference:rm,expects:`unknown`,async:!1,get"~standard"(){return Np(this)},"~run"(e){return e.typed=!0,e}}}function im(e,t,n){return{kind:`schema`,type:`variant`,reference:im,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return Np(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;Mp(this,`type`,e,t,{input:n[a],expected:Fp(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else Mp(this,`type`,e,t);return e}}}function L(e,t,n){let r=e[`~run`]({value:t},wp(n));if(r.issues)throw new Ip(r.issues);return r.value}function R(...e){return{...e[0],pipe:e,get"~standard"(){return Np(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function am(e,t,n){let r=e[`~run`]({value:t},wp(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var om=0,sm=1,cm=2,lm=3,um=4,dm=5,fm=6,pm=7,mm=8,hm=9,gm=10,_m=11,vm=12,ym=13;function bm(e){return R(M(e.items),Bp({typeId:0,elementSchema:e.items,...e}))}function xm(e={}){let t=e&&e.size||-1;return R(I(),qp(e=>typeof e==`string`&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Bp({typeId:2,size:t,...e}))}function z(e={}){return R(P(),Bp({typeId:3,...e}))}function Sm(e={}){return R(Kp(),Bp({typeId:4,...e}))}function Cm(e,t,n){return R(P(),Lp(),Vp(0),zp(2**t-1),Bp({typeId:e,...n}))}function wm(e={}){return Cm(6,8,e)}function Tm(e={}){return Cm(7,16,e)}function Em(e={}){return Cm(8,24,e)}function Dm(e={}){return Cm(9,32,e)}function Om(e={}){return Cm(10,48,e)}function km(e={}){let t=e&&e.size||-1;return R(Jp(Uint8Array),qp(e=>e instanceof Uint8Array&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Bp({typeId:11,...e}))}function Am(e={}){return R(Jp(Uint8Array),qp(e=>e instanceof Uint8Array&&e.length===32,`Expected Uint8Array of 32 bytes`),Bp({typeId:12,...e}))}function B(){return Jp(Uint8Array)}function jm(){return B()}function Mm(){return R(P(),Vp(0))}var Nm=F({magicString:N(Hn),protocolVersion:P(),microblockType:P(),height:P(),previousHash:B(),timestamp:P(),maxFees:P(),gasPrice:P(),bodyHash:B(),feesPayerAccount:B()}),Pm=F({pricingRate:P(),maximumNumberOfDays:P()}),Fm=M(Pm),Im=F({numberOfDays:P(),pricingRate:P(),priceInAtomics:P()}),Lm=F({protocolVersionName:I(),protocolVersion:P(),feesCalculationVersion:P(),globalStateUpdaterVersion:P(),applicationLedgerInternalStateUpdaterVersion:P(),applicationInternalStateUpdaterVersion:P(),organizationInternalStateUpdaterVersion:P(),validatorNodeInternalStateUpdaterVersion:P(),accountInternalStateUpdaterVersion:P(),protocolInternalStateUpdaterVersion:P(),minimumNodeStakingAmountInAtomics:P(),maximumNodeStakingAmountInAtomics:P(),unstakingDelayInDays:P(),maxBlockSizeInBytes:P(),priceStructure:Fm,abciVersion:P()}),Rm=F({protocolVersion:P(),protocolVersionName:I(),changeLog:I(),protocolVariables:Lm}),zm=Zp({type:N(O.CUSTOM)},rm()),Bm=F({type:N(O.SIGNATURE),signature:B(),schemeId:wm()}),Vm=F({type:N(O.ALLOWED_ADDITIONAL_WRITER),allowedWriterAccountId:B()}),Hm=F({type:N(O.PROTOCOL_CREATION),organizationId:jm()}),Um=F({type:N(O.PROTOCOL_UPDATE),...Rm.entries}),Wm=F({type:N(O.PROTOCOL_VARIABLES),protocolVariables:Gp()}),Gm=F({type:N(O.ACCOUNT_PUBLIC_KEY),publicKey:B(),schemeId:wm()}),Km=F({type:N(O.ACCOUNT_TOKEN_ISSUANCE),amount:z()}),qm=F({type:N(O.ACCOUNT_CREATION),sellerAccount:jm(),amount:z()}),Jm=F({type:N(O.ACCOUNT_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm()}),Ym=F({type:N(O.ACCOUNT_VESTING_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm(),cliffDurationDays:z(),vestingDurationDays:z()}),Xm=F({type:N(O.ACCOUNT_ESCROW_TRANSFER),account:jm(),amount:z(),publicReference:xm(),privateReference:xm(),escrowIdentifier:jm(),agentAccount:jm(),durationDays:z()}),Zm=F({type:N(O.ACCOUNT_ESCROW_SETTLEMENT),escrowIdentifier:jm(),confirmed:Sm()}),Qm=F({type:N(O.ACCOUNT_STAKE),amount:z(),objectType:z(),objectIdentifier:jm()}),$m=F({type:N(O.ACCOUNT_UNSTAKE),amount:z(),objectType:z(),objectIdentifier:jm()}),eh=F({type:N(O.VN_CREATION),organizationId:jm()}),th=F({type:N(O.VN_COMETBFT_PUBLIC_KEY_DECLARATION),cometPublicKeyType:xm(),cometPublicKey:xm()}),nh=F({type:N(O.VN_RPC_ENDPOINT),rpcEndpoint:xm()}),rh=F({type:N(O.VN_APPROVAL),status:Sm()}),ih=F({type:N(O.VN_SLASHING_CANCELLATION),reason:xm()}),ah=F({type:N(O.ORG_CREATION),accountId:jm()}),oh=F({type:N(O.ORG_DESCRIPTION),name:xm(),city:xm(),countryCode:xm(),website:xm(),misc:Qp(em(I(),I()))}),sh=F({type:N(O.APP_CREATION),organizationId:jm()}),ch=F({type:N(O.APP_DESCRIPTION),name:xm(),logoUrl:xm(),homepageUrl:xm(),description:xm(),misc:Qp(em(I(),I()))}),lh=F({type:N(O.APP_LEDGER_ALLOWED_SIG_SCHEMES),schemeIds:M(wm())}),uh=F({type:N(O.APP_LEDGER_ALLOWED_PKE_SCHEMES),schemeIds:M(wm())}),dh=F({type:N(O.APP_LEDGER_CREATION),applicationId:jm()}),fh=F({type:N(O.APP_LEDGER_ACTOR_CREATION),id:z(),actorType:z(),name:xm()}),ph=F({type:N(O.APP_LEDGER_CHANNEL_CREATION),id:z(),isPrivate:Sm(),creatorId:z(),name:xm()}),mh=F({type:N(O.APP_LEDGER_SHARED_SECRET),hostId:z(),guestId:z(),encryptedSharedKey:B()}),hh=F({type:N(O.APP_LEDGER_CHANNEL_INVITATION),channelId:z(),hostId:z(),guestId:z(),encryptedChannelKey:B()}),gh=F({type:N(O.APP_LEDGER_ACTOR_SUBSCRIPTION),actorId:z(),actorType:z(),organizationId:jm(),signatureSchemeId:wm(),signaturePublicKey:B(),pkeSchemeId:wm(),pkePublicKey:B()}),_h=F({type:N(O.APP_LEDGER_PUBLIC_CHANNEL_DATA),channelId:z(),data:B()}),vh=F({type:N(O.APP_LEDGER_PRIVATE_CHANNEL_DATA),channelId:z(),merkleRootHash:jm(),encryptedData:B()}),yh=F({type:N(O.APP_LEDGER_AUTHOR),authorId:z()}),bh=F({type:N(O.APP_LEDGER_ENDORSEMENT_REQUEST),endorserId:z(),message:xm()}),xh=im(`type`,[Bm,Vm,zm,Hm,Um,Wm,Gm,Km,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh]),Sh=F({sections:M(xh)}),V=function(e){return e[e.ACCOUNT_VIRTUAL_BLOCKCHAIN=1]=`ACCOUNT_VIRTUAL_BLOCKCHAIN`,e[e.NODE_VIRTUAL_BLOCKCHAIN=2]=`NODE_VIRTUAL_BLOCKCHAIN`,e[e.APPLICATION_VIRTUAL_BLOCKCHAIN=4]=`APPLICATION_VIRTUAL_BLOCKCHAIN`,e[e.ORGANIZATION_VIRTUAL_BLOCKCHAIN=3]=`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,e[e.APP_LEDGER_VIRTUAL_BLOCKCHAIN=5]=`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,e[e.PROTOCOL_VIRTUAL_BLOCKCHAIN=0]=`PROTOCOL_VIRTUAL_BLOCKCHAIN`,e}({}),Ch=F({organizationId:jm(),currentProtocolVariables:Lm,protocolUpdates:M(Rm)}),wh=F({signatureSchemeId:z(),publicKeyHeight:Mm()}),Th=F({accountId:jm(),descriptionHeight:Mm()}),Eh=F({organizationId:jm(),cometbftPublicKeyDeclarationHeight:Mm(),rpcEndpointHeight:Mm(),lastKnownApprovalStatus:Sm()}),Dh=F({organizationId:jm(),descriptionHeight:Mm()}),Oh=F({name:xm(),isPrivate:Sm(),creatorId:z()}),kh=F({channelId:z(),height:Mm()}),Ah=F({peerActorId:z(),height:Mm()}),jh=F({name:xm(),subscribed:Sm(),signatureKeyHeight:z(),pkeKeyHeight:z(),sharedSecrets:M(Ah),invitations:M(kh)}),Mh=F({allowedAdditionalWriters:M(jm()),allowedSignatureSchemeIds:M(z()),allowedPkeSchemeIds:M(z()),applicationId:jm(),channels:M(Oh),actors:M(jh)}),Nh=F({height:z(),expirationDay:z(),lastMicroblockHash:B()}),Ph=F({type:N(V.ACCOUNT_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:wh}),Fh=F({type:N(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Th}),Ih=F({type:N(V.NODE_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Eh}),Lh=F({type:N(V.APPLICATION_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Dh}),Rh=F({type:N(V.APP_LEDGER_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Mh}),zh=F({type:N(V.PROTOCOL_VIRTUAL_BLOCKCHAIN),...Nh.entries,internalState:Ch}),Bh=im(`type`,[Ph,Fh,Ih,Lh,Rh,zh]),Vh=F({virtualBlockchainType:P(),virtualBlockchainId:jm()}),Hh=F({virtualBlockchainId:B(),virtualBlockchainType:P(),header:Nm}),Uh=3,Wh=function(e){return e[e.Escrow=0]=`Escrow`,e[e.Vesting=1]=`Vesting`,e[e.NodeStaking=2]=`NodeStaking`,e}({}),Gh=F({escrowIdentifier:B(),fundEmitterAccountId:B(),transferAuthorizerAccountId:B(),startTimestamp:P(),durationDays:P()}),Kh=F({type:N(Wh.Escrow),lockedAmountInAtomics:P(),parameters:Gh}),qh=F({initialVestedAmountInAtomics:P(),cliffStartTimestamp:P(),cliffDurationDays:P(),vestingDurationDays:P()}),Jh=F({type:N(Wh.Vesting),lockedAmountInAtomics:P(),parameters:qh}),Yh=F({validatorNodeId:B(),plannedUnlockAmountInAtomics:P(),plannedUnlockTimestamp:P(),slashed:Kp(),plannedSlashingAmountInAtomics:P(),plannedSlashingTimestamp:P()}),Xh=F({type:N(Wh.NodeStaking),lockedAmountInAtomics:P(),parameters:Yh}),Zh=im(`type`,[Kh,Jh,Xh]),Qh=F({balance:P(),escrowed:P(),vested:P(),releasable:P(),staked:P(),stakeable:P(),locked:P(),spendable:P()}),$h=F({height:P(),balance:P(),lastHistoryHash:B(),locks:M(Zh)}),eg=F({type:P(),exists:Kp(),state:$h}),tg=F({height:R(P(),Lp(),Vp(0)),previousHistoryHash:Am(),type:R(P(),Lp(),Vp(0),zp(255)),timestamp:R(P(),Lp(),Vp(0)),linkedAccount:Am(),amount:R(P(),Lp(),Vp(0)),chainReference:B()}),ng=M(tg),rg=F({accountHash:B(),lastKnownHistoryHash:B()}),ig=F({accountHash:B(),currentState:$h,historyUpdate:ng}),ag=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,og=ag+`+/=`,sg={BASE64:og,URL:ag+`-_=`,encodeString:cg,decodeString:lg,encodeBinary:ug,decodeBinary:dg};function cg(e,t=og,n=!1){return ug(Qa.encode(e),t,n)}function lg(e,t=og){return Qa.decode(dg(e,t))}function ug(e,t=og,n=!1){let r=e.length%3,i=0,a=``;for(let n=0;n<e.length||n%3;)if(i=i<<8|e[n++],!(n%3)){for(let e=4;e--;)a+=t[i>>e*6&63];i=0}return r?a.slice(0,r-3)+t[64].repeat(n?3-r:0):a}function dg(e,t=og){let n=0,r=0,i=[];e+=t[64].repeat(-e.length&3);for(let a=0;a<e.length;){let o=t.indexOf(e[a++]);o==64&&n++,r=r<<6|o,a&3||i.push(r>>16&255,r>>8&255,r&255)}return new Uint8Array(n?i.slice(0,-n):i)}var fg=class{static defaultBytesToStringEncoder(){return new mg}static bytesToBase64Encoder(){return new pg}static bytesToHexEncoder(){return new mg}},pg=class{static decode(e){return sg.decodeBinary(e,sg.BASE64)}static encode(e){return sg.encodeBinary(e,sg.BASE64,!0)}decode(e){return sg.decodeBinary(e,sg.BASE64)}encode(e){return sg.encodeBinary(e,sg.BASE64,!0)}},mg=class{decode(e){return yl(e)}encode(e){if(!(e instanceof Uint8Array))throw TypeError(`Encoding data must be a Uint8Array, got ${typeof e}`);return gl(e)}},hg=class{keys;value;constructor(e,t){this.keys=e,this.value=t}matchesKeys(...e){return e.length===this.keys.length?e.every((e,t)=>e===this.keys[t]):!1}getKeys(){return[...this.keys]}getValue(){return this.value}},gg=class{static encode(...e){if(e.length<2)throw Error(`At least one key and one value must be provided`);let t=e.slice(0,-1),n=e[e.length-1];return`${t.join(`:`)}${n?`{${n}}`:`{}`}`}static decode(e){let t=e.match(/^(.*?)(?:\{(.*)\})?$/);if(!t)throw Error(`Invalid encoded string format`);let n=t[1],r=t[2]||``;return new hg(n?n.split(`:`):[],r)}},_g={},vg={};vg.byteLength=Eg,vg.toByteArray=Og,vg.fromByteArray=jg;for(var yg=[],bg=[],xg=typeof Uint8Array<`u`?Uint8Array:Array,Sg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Cg=0,wg=Sg.length;Cg<wg;++Cg)yg[Cg]=Sg[Cg],bg[Sg.charCodeAt(Cg)]=Cg;bg[45]=62,bg[95]=63;function Tg(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Eg(e){var t=Tg(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Dg(e,t,n){return(t+n)*3/4-n}function Og(e){var t,n=Tg(e),r=n[0],i=n[1],a=new xg(Dg(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=bg[e.charCodeAt(c)]<<18|bg[e.charCodeAt(c+1)]<<12|bg[e.charCodeAt(c+2)]<<6|bg[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=bg[e.charCodeAt(c)]<<2|bg[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=bg[e.charCodeAt(c)]<<10|bg[e.charCodeAt(c+1)]<<4|bg[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function kg(e){return yg[e>>18&63]+yg[e>>12&63]+yg[e>>6&63]+yg[e&63]}function Ag(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(kg(r));return i.join(``)}function jg(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Ag(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(yg[t>>2]+yg[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(yg[t>>10]+yg[t>>4&63]+yg[t<<2&63]+`=`)),i.join(``)}var Mg={};Mg.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Mg.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=vg,n=Mg,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=ee,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,`parent`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,`offset`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Ie(e,o)||e&&Ie(e.buffer,o)||s!==void 0&&(Ie(e,s)||e&&Ie(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=x(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Ie(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Le(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function ee(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Ie(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Ie(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Ie(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function x(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Ie(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return Me(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Fe(e).length;default:if(i)return r?-1:Me(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=x;function te(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return me(this,t,n);case`utf8`:case`utf-8`:return le(this,t,n);case`ascii`:return fe(this,t,n);case`latin1`:case`binary`:return pe(this,t,n);case`base64`:return C(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return he(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function S(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)S(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)S(this,t,t+3),S(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)S(this,t,t+7),S(this,t+1,t+6),S(this,t+2,t+5),S(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?le(this,0,e):te.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Ie(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function ne(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Le(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:re(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):re(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function re(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return ne(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return ne(this,e,t,n,!1)};function ie(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Le(r))return o;e[n+o]=r}return o}function ae(e,t,n,r){return w(Me(t,e.length-n),e,n,r)}function oe(e,t,n,r){return w(Ne(t),e,n,r)}function se(e,t,n,r){return w(Fe(t),e,n,r)}function ce(e,t,n,r){return w(Pe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ie(this,e,t,n);case`utf8`:case`utf-8`:return ae(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return oe(this,e,t,n);case`base64`:return se(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ce(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function C(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function le(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return de(r)}let ue=4096;function de(e){let t=e.length;if(t<=ue)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ue));return n}function fe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function pe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function me(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=Re[e[r]];return i}function he(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function ge(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||ge(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||ge(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||ge(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||ge(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||ge(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||ge(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||ge(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||ge(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||ge(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=ze(function(e){e>>>=0,Oe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&ke(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||ge(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||ge(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||ge(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||ge(e,8,this.length),n.read(this,e,!1,52,8)};function _e(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;_e(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;_e(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ve(e,t,n,r,i){De(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function ye(e,t,n,r,i){De(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=ze(function(e,t=0){return ve(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=ze(function(e,t=0){return ye(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);_e(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);_e(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||_e(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=ze(function(e,t=0){return ve(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=ze(function(e,t=0){return ye(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function be(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function xe(e,t,r,i,a){return t=+t,r>>>=0,a||be(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return xe(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return xe(this,e,t,!1,n)};function Se(e,t,r,i,a){return t=+t,r>>>=0,a||be(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return Se(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return Se(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let Ce={};function we(e,t,n){Ce[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}we(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),we(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),we(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=Te(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=Te(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function Te(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function Ee(e,t,n){Oe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&ke(t,e.length-(n+1))}function De(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new Ce.ERR_OUT_OF_RANGE(`value`,i,e)}Ee(r,i,a)}function Oe(e,t){if(typeof e!=`number`)throw new Ce.ERR_INVALID_ARG_TYPE(t,`number`,e)}function ke(e,t,n){throw Math.floor(e)===e?t<0?new Ce.ERR_BUFFER_OUT_OF_BOUNDS:new Ce.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(Oe(e,n),new Ce.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let Ae=/[^+/0-9A-Za-z-_]/g;function je(e){if(e=e.split(`=`)[0],e=e.trim().replace(Ae,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function Me(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Ne(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Pe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Fe(e){return t.toByteArray(je(e))}function w(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Ie(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Le(e){return e!==e}let Re=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function ze(e){return typeof BigInt>`u`?Be:e}function Be(){throw Error(`BigInt not supported`)}})(_g);var Ng=_g.Buffer;_g.Blob,_g.BlobOptions,_g.Buffer,_g.File,_g.FileOptions,_g.INSPECT_MAX_BYTES,_g.SlowBuffer,_g.TranscodeEncoding,_g.atob,_g.btoa,_g.constants,_g.isAscii,_g.isUtf8,_g.kMaxLength,_g.kStringMaxLength,_g.resolveObjectURL,_g.transcode;var Pg=function(e){return e[e.AES_256_GCM=0]=`AES_256_GCM`,e}({}),Fg=class e{static KEY_LENGTH_IN_BYTES=32;getSymmetricEncryptionSchemeId(){return Pg.AES_256_GCM}getSupportedKeyLengths(){return[e.KEY_LENGTH_IN_BYTES]}getDefaultKeyLength(){return e.KEY_LENGTH_IN_BYTES}},Ig=class e{constructor(e){this.key=e}static async generate(){let t=new Uint8Array(32);return crypto.getRandomValues(t),new e(t)}static createFromBytes(t){return new e(t)}getRawSecretKey(){return this.key}getSymmetricEncryptionSchemeId(){return Pg.AES_256_GCM}async encrypt(e){let t=new Uint8Array(12);crypto.getRandomValues(t);let n=ou(this.key,t).encrypt(e),r=new Uint8Array(t.length+n.length);return r.set(t),r.set(n,t.length),r}async decrypt(e){try{let t=e.slice(0,12),n=e.slice(12);return ou(this.key,t).decrypt(n)}catch(e){throw o.isCarmentisError(e)?new f:e}}},Lg=class{constructor(e){this.wrappedKey=e}async encryptString(e){let t=new TextEncoder().encode(e),n=await this.encrypt(t);return Ng.from(n).toString(`base64`)}async decryptString(e){let t=Ng.from(e,`base64`),n=await this.decrypt(t);return new TextDecoder().decode(n)}getSymmetricEncryptionSchemeId(){return this.wrappedKey.getSymmetricEncryptionSchemeId()}async encrypt(e){return this.wrappedKey.encrypt(e)}async decrypt(e){return this.wrappedKey.decrypt(e)}getRawSecretKey(){return this.wrappedKey.getRawSecretKey()}},Rg=function(e){return e[e.ML_KEM=0]=`ML_KEM`,e}({}),zg=class{getPrivateKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(this.getPrivateKeyAsBytes())}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Bg=class{async getPublicKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Vg=class e{static SIGNATURE_SIZE=3311;getSignatureSchemeId(){return Ya.ML_DSA_65}getSignatureSize(){return e.SIGNATURE_SIZE}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}expectedSeedSize(){return 32}},Hg=class extends Bg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsString(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}async verify(e,t){return yd.verify(this.publicKey,e,t)}async getPublicKeyAsBytes(){return this.publicKey}getScheme(){return new Vg}},Ug=class e extends zg{static async gen(){return new e(Iu(32))}verificationKey;signatureKey;getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}constructor(e){super(),this.seed=e;let t=yd.keygen(e);this.signatureKey=t.secretKey,this.verificationKey=t.publicKey}async getPublicKey(){return new Hg(this.verificationKey)}getPrivateKeyAsBytes(){return this.seed}async sign(e){return yd.sign(this.signatureKey,e)}getScheme(){return new Vg}},Wg={p:57896044618658097711785492504343953926634992332820282019728792003956564819949n,n:7237005577332262213973186563042994240857116359379907606001950938285454250989n,h:8n,a:57896044618658097711785492504343953926634992332820282019728792003956564819948n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,Gx:15112221349535400772501151409588531511454012693041857206046113283949847762202n,Gy:46316835694926478169428394003475163141307993866256225615783033603165251855960n},{p:Gg,n:Kg,Gx:qg,Gy:Jg,a:Yg,d:Xg,h:Zg}=Wg,Qg=32,$g=(...e)=>{`captureStackTrace`in Error&&typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(...e)},e_=(e=``)=>{let t=Error(e);throw $g(t,e_),t},t_=e=>typeof e==`bigint`,n_=e=>typeof e==`string`,r_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,i_=(e,t,n=``)=>{let r=r_(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;e_(o+`expected Uint8Array`+s+`, got `+c)}return e},a_=e=>new Uint8Array(e),o_=e=>Uint8Array.from(e),s_=(e,t)=>e.toString(16).padStart(t,`0`),c_=e=>Array.from(i_(e)).map(e=>s_(e,2)).join(``),l_={_0:48,_9:57,A:65,F:70,a:97,f:102},u_=e=>{if(e>=l_._0&&e<=l_._9)return e-l_._0;if(e>=l_.A&&e<=l_.F)return e-(l_.A-10);if(e>=l_.a&&e<=l_.f)return e-(l_.a-10)},d_=e=>{let t=`hex invalid`;if(!n_(e))return e_(t);let n=e.length,r=n/2;if(n%2)return e_(t);let i=a_(r);for(let n=0,a=0;n<r;n++,a+=2){let r=u_(e.charCodeAt(a)),o=u_(e.charCodeAt(a+1));if(r===void 0||o===void 0)return e_(t);i[n]=r*16+o}return i},f_=()=>globalThis?.crypto,p_=()=>f_()?.subtle??e_(`crypto.subtle must be defined, consider polyfill`),m_=(...e)=>{let t=a_(e.reduce((e,t)=>e+i_(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},h_=(e=Qg)=>f_().getRandomValues(a_(e)),g_=BigInt,__=(e,t,n,r=`bad number: out of range`)=>t_(e)&&t<=e&&e<n?e:e_(r),v_=(e,t=Gg)=>{let n=e%t;return n>=0n?n:t+n},y_=(1n<<255n)-1n,H=e=>{e<0n&&e_(`negative coordinate`);let t=(e>>255n)*19n+(e&y_);return t=(t>>255n)*19n+(t&y_),t%Gg},b_=e=>v_(e,Kg),x_=(e,t)=>{(e===0n||t<=0n)&&e_(`no inverse n=`+e+` mod=`+t);let n=v_(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?v_(i,t):e_(`no inverse`)},S_=e=>{let t=q_[e];return typeof t!=`function`&&e_(`hashes.`+e+` not set`),t},C_=e=>e instanceof T_?e:e_(`Point expected`),w_=2n**256n,T_=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=w_;this.X=__(e,0n,i),this.Y=__(t,0n,i),this.Z=__(n,1n,i),this.T=__(r,0n,i),Object.freeze(this)}static CURVE(){return Wg}static fromAffine(t){return new e(t.x,t.y,1n,H(t.x*t.y))}static fromBytes(t,n=!1){let r=Xg,i=o_(i_(t,Qg)),a=t[31];i[31]=a&-129;let o=k_(i);__(o,0n,n?w_:Gg);let s=H(o*o),{isValid:c,value:l}=N_(v_(s-1n),H(r*s+1n));c||e_(`bad point: y not sqrt`);let u=(l&1n)==1n,d=(a&128)!=0;return!n&&l===0n&&d&&e_(`bad point: x==0, isLastByteOdd`),d!==u&&(l=v_(-l)),new e(l,o,1n,H(l*o))}static fromHex(t,n){return e.fromBytes(d_(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=Yg,t=Xg,n=this;if(n.is0())return e_(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=n,s=H(r*r),c=H(i*i),l=H(a*a),u=H(l*l);return H(l*(H(s*e)+c))===v_(u+H(t*H(s*c)))?H(r*i)===H(a*o)?this:e_(`bad point: equation left != right (2)`):e_(`bad point: equation left != right (1)`)}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=C_(e),s=H(t*o),c=H(i*r),l=H(n*o),u=H(a*r);return s===c&&l===u}is0(){return this.equals(D_)}negate(){return new e(v_(-this.X),this.Y,this.Z,v_(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=Yg,a=H(t*t),o=H(n*n),s=H(2n*r*r),c=H(i*a),l=v_(t+n),u=v_(H(l*l)-a-o),d=v_(c+o),f=v_(d-s),p=v_(c-o),m=H(u*f),h=H(d*p),g=H(u*p);return new e(m,h,H(f*d),g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=C_(t),u=Yg,d=Xg,f=H(n*o),p=H(r*s),m=H(H(a*d)*l),h=H(i*c),g=v_(H(v_(n+r)*v_(o+s))-f-p),_=v_(h-m),v=v_(h+m),y=v_(p-H(u*f)),b=H(g*_),ee=H(v*y),x=H(g*y);return new e(b,ee,H(_*v),x)}subtract(e){return this.add(C_(e).negate())}multiply(e,t=!0){if(!t&&(e===0n||this.is0()))return D_;if(__(e,1n,Kg),e===1n)return this;if(this.equals(E_))return tv(e).p;let n=D_,r=E_;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals(D_))return{x:0n,y:1n};let r=x_(n,Gg);return H(n*r)!==1n&&e_(`invalid inverse`),{x:H(e*r),y:H(t*r)}}toBytes(){let{x:e,y:t}=this.toAffine(),n=O_(t);return n[31]|=e&1n?128:0,n}toHex(){return c_(this.toBytes())}clearCofactor(){return this.multiply(g_(Zg),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(Kg/2n,!1).double();return Kg%2n&&(e=e.add(this)),e.is0()}},E_=new T_(qg,Jg,1n,v_(qg*Jg)),D_=new T_(0n,1n,1n,0n);T_.BASE=E_,T_.ZERO=D_;var O_=e=>d_(s_(__(e,0n,w_),64)).reverse(),k_=e=>g_(`0x`+c_(o_(i_(e)).reverse())),A_=(e,t)=>{let n=e;for(;t-- >0n;)n=H(n*n);return n},j_=e=>{let t=H(H(e*e)*e),n=H(A_(H(A_(t,2n)*t),1n)*e),r=H(A_(n,5n)*n),i=H(A_(r,10n)*r),a=H(A_(i,20n)*i),o=H(A_(a,40n)*a);return{pow_p_5_8:H(A_(H(A_(H(A_(H(A_(o,80n)*o),80n)*o),10n)*r),2n)*e),b2:t}},M_=19681161376707505956807079304988542015446066515923890162744021073123829784752n,N_=(e,t)=>{let n=H(t*H(t*t)),r=j_(H(e*H(H(n*n)*t))).pow_p_5_8,i=H(e*H(n*r)),a=H(t*H(i*i)),o=i,s=H(i*M_),c=a===e,l=a===v_(-e),u=a===v_(-e*M_);return c&&(i=o),(l||u)&&(i=s),(v_(i)&1n)==1n&&(i=v_(-i)),{isValid:c||l,value:i}},P_=e=>b_(k_(e)),F_=(...e)=>q_.sha512Async(m_(...e)),I_=(...e)=>S_(`sha512`)(m_(...e)),L_=e=>{let t=e.slice(0,32);t[0]&=248,t[31]&=127,t[31]|=64;let n=e.slice(32,64),r=P_(t),i=E_.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}},R_=e=>F_(i_(e,Qg)).then(L_),z_=e=>L_(I_(i_(e,Qg))),B_=e=>z_(e).pointBytes,V_=e=>e.finish(I_(e.hashable)),H_=(e,t,n)=>{let{pointBytes:r,scalar:i}=e,a=P_(t),o=E_.multiply(a).toBytes();return{hashable:m_(o,r,n),finish:e=>i_(m_(o,O_(b_(a+P_(e)*i))),64)}},U_=(e,t)=>{let n=i_(e),r=z_(t);return V_(H_(r,I_(r.prefix,n),n))},W_={zip215:!0},G_=(e,t,n,r=W_)=>{e=i_(e,64),t=i_(t),n=i_(n,Qg);let{zip215:i}=r,a=e.subarray(0,Qg),o=k_(e.subarray(Qg,Qg*2)),s,c,l,u=Uint8Array.of(),d=!1;try{s=T_.fromBytes(n,i),c=T_.fromBytes(a,i),l=E_.multiply(o,!1),u=m_(c.toBytes(),s.toBytes(),t),d=!0}catch{}return{hashable:u,finish:e=>{if(!d||!i&&s.isSmallOrder())return!1;let t=P_(e);return c.add(s.multiply(t,!1)).subtract(l).clearCofactor().is0()}}},K_=(e,t,n,r=W_)=>V_(G_(e,t,n,r)),q_={sha512Async:async e=>{let t=p_(),n=m_(e);return a_(await t.digest(`SHA-512`,n.buffer))},sha512:void 0},J_={getExtendedPublicKeyAsync:R_,getExtendedPublicKey:z_,randomSecretKey:(e=h_(Qg))=>e},Y_=8,X_=Math.ceil(256/Y_)+1,Z_=2**(Y_-1),Q_=()=>{let e=[],t=E_,n=t;for(let r=0;r<X_;r++){n=t,e.push(n);for(let r=1;r<Z_;r++)n=n.add(t),e.push(n);t=n.double()}return e},$_=void 0,ev=(e,t)=>{let n=t.negate();return e?n:t},tv=e=>{let t=$_||=Q_(),n=D_,r=E_,i=2**Y_,a=i,o=g_(i-1),s=g_(Y_);for(let i=0;i<X_;i++){let c=Number(e&o);e>>=s,c>Z_&&(c-=a,e+=1n);let l=i*Z_,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(ev(f,t[u])):n=n.add(ev(p,t[d]))}return e!==0n&&e_(`invalid wnaf`),{p:n,f:r}};q_.sha512=Jc;var nv=function(e){return e[e.SHA256=0]=`SHA256`,e}({}),rv=class{getHashSchemeId(){return nv.SHA256}hash(e){return Kc(e)}};function iv(e,t,n,r){Ds(e);let{c:i,dkLen:a,asyncTick:o}=qs({dkLen:32,asyncTick:10},r);if(Ts(i),Ts(a),Ts(o),i<1)throw Error(`iterations (c) should be >= 1`);let s=Gs(t),c=Gs(n),l=new Uint8Array(a),u=Xd.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function av(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),js(i),n}function ov(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=iv(e,t,n,r),l,u=new Uint8Array(4),d=Ms(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return av(s,c,o,l,f)}var sv=function(e){return e[e.PBKDF2=0]=`PBKDF2`,e[e.SCRYPT=1]=`SCRYPT`,e}({}),cv=class{deriveKeyNoSalt(e,t){return this.deriveKey(e,``,t)}},lv=class extends cv{getKeyDerivationFunctionSchemeId(){return sv.PBKDF2}deriveKey(e,t,n){return ov(Kc,e,t,{c:1e5,dkLen:n})}};function uv(e,t,n){return Ds(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Xd(e,Ws(n),Ws(t))}var dv=Uint8Array.from([0]),fv=Uint8Array.of();function pv(e,t,n,r=32){Ds(e),Ts(r);let i=e.outputLen;if(r>255*i)throw Error(`Length should be <= 255*HashLen`);let a=Math.ceil(r/i);n===void 0&&(n=fv);let o=new Uint8Array(a*i),s=Xd.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)dv[0]=e+1,c.update(e===0?fv:l).update(n).update(dv).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),js(l,dv),o.slice(0,r)}var mv=(e,t,n,r,i)=>pv(e,uv(e,t,n),r,i),hv=class{deriveKeyNoSalt(e,t,n){let r=new Uint8Array;return this.deriveKey(e,r,t,n)}},gv=function(e){return e[e.HKDF=0]=`HKDF`,e}({}),_v=class extends hv{getKeyDerivationFunctionSchemeId(){return gv.HKDF}deriveKey(e,t,n,r){return mv(Kc,e,t,n,r)}},vv=function(e){return e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`,e}({}),yv=class{},bv=class{async encode(e=fg.defaultBytesToStringEncoder()){return e.encode(await this.getRawPublicKey())}getSchemeId(){return this.getScheme().getSchemeId()}},xv=class{encode(e=fg.defaultBytesToStringEncoder()){return e.encode(this.getRawPrivateKey())}},Sv=class extends yv{getSchemeId(){return vv.ML_KEM_768_AES_256_GCM}getSupportedSeedLength(){return[32]}},Cv=128,wv=96,Tv=32,Ev=64,Dv=7,Ov=8,kv=class{byteStream;constructor(){this.clear()}clear(){this.byteStream=[]}getByteStream(){return new Uint8Array(this.byteStream)}writeJsonValue(e,t){switch(e){case 3:this.writeString(t);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;default:throw`Type ${e} is not a JSON type`}}writeSchemaValue(e,t,n){switch(e){case 3:this.writeString(t,n);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;case 7:this.writeUint8(t);break;case 8:this.writeUint16(t);break;case 9:this.writeUint24(t);break;case 10:this.writeUint32(t);break;case 11:this.writeUint48(t);break;case 12:this.writeBinary(t,n);break;case 13:this.writeByteArray(t);break;case 14:this.writeHashString(t);break;default:throw`Unexpected type ${e}`}}writeByte(e){this.byteStream.push(e&255)}writeUnsigned(e,t){for(;t--;)this.writeByte(e/2**(t*8))}writeUint8(e){this.writeUnsigned(e,1)}writeUint16(e){this.writeUnsigned(e,2)}writeUint24(e){this.writeUnsigned(e,3)}writeUint32(e){this.writeUnsigned(e,4)}writeUint48(e){this.writeUnsigned(e,6)}writeBinary(e,t=-1){t==-1&&this.writeVarUint(e.length),this.writeByteArray(e)}writeHashString(e){this.writeByteArray(k.binaryFromHexa(e))}writeByteArray(e){for(let t of e)this.writeByte(t)}writeString(e,t=-1){let n=Qa.encode(e);t==-1&&this.writeVarUint(n.length),this.writeByteArray(n)}writeVarUint(e){if(e==0)this.writeByte(0);else{if(e<0||e%1||e>2**53-1)throw`Invalid varUint ${e}`;for(;e;)this.writeByte(e%128|(e>127)<<7),e=Math.floor(e/128)}}writeBoolean(e){this.writeByte(e?255:0)}writeNumber(e){let t=!(e%1);if(t&&e>=-64&&e<64){this.writeByte(Cv|e&127);return}for(let n=1,r=256;n<=6;n++,r*=256){if(t&&e>=-r&&e<r){let t=e<0;this.writeByte(t<<3|n),this.writeUnsigned(t?-e-1:e,n);return}if(n==4){let t=new Float32Array([e]);if(+t[0].toPrecision(7)===e){this.writeByte(Tv),this.writeByteArray(new Uint8Array(t.buffer));return}}}this.writeByte(Ev),this.writeByteArray(new Uint8Array(new Float64Array([e]).buffer))}},Av=class{byteStream;lastPointer;pointer;constructor(e){this.byteStream=e,this.pointer=0}readJsonValue(e){switch(this.lastPointer=this.pointer,e){case 3:return this.readString();case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;default:throw`Type ${e} is not a JSON type`}}readSchemaValue(e,t){switch(this.lastPointer=this.pointer,e){case 3:return this.readString(t);case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;case 7:return this.readUint8();case 8:return this.readUint16();case 9:return this.readUint24();case 10:return this.readUint32();case 11:return this.readUint48();case 12:return this.readBinary(t);case 13:return this.readByteArray(32);case 14:return this.readHashString()}}getPointer(){return this.pointer}extractFrom(e){return this.byteStream.slice(e,this.pointer)}getLastField(){return this.byteStream.slice(this.lastPointer,this.pointer)}readByte(){return this.byteStream[this.pointer++]}readUnsigned(e){let t=0;for(;e--;)t=t*256+this.readByte();return t}readUint8(){return this.readUnsigned(1)}readUint16(){return this.readUnsigned(2)}readUint24(){return this.readUnsigned(3)}readUint32(){return this.readUnsigned(4)}readUint48(){return this.readUnsigned(6)}readBinary(e=-1){return this.readByteArray(e==-1?this.readVarUint():e)}readHashString(){return k.binaryToHexa(this.readByteArray(32))}readByteArray(e){return this.byteStream.slice(this.pointer,this.pointer+=e)}readString(e=-1){let t=this.readByteArray(e==-1?this.readVarUint():e);return Qa.decode(t)}readVarUint(){let e=[],t;do t=this.readByte(),e.push(t&127);while(t&128);return e.reduceRight((e,t)=>e*128+t,0)}readBoolean(){return!!this.readByte()}readNumber(){let e=this.readByte();if(e&Cv)return(e&127^64)-64;switch(e&wv){case Tv:return+new Float32Array(this.readByteArray(4).buffer)[0].toPrecision(7);case Ev:return new Float64Array(this.readByteArray(8).buffer)[0];default:{let t=this.readUnsigned(e&Dv);return e&Ov?-t-1:t}}}},jv=class{schema;stream;constructor(e){this.schema=e}serialize(e){if(this.schema===void 0)throw new De(`Provided schema is undefined: this should not happen`);return this.stream=new kv,this.serializeObject(this.schema.definition,e),this.stream.getByteStream()}serializeObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0)throw new De(`field '${e}' is missing`);if(r.type&32){if(ro.getType(i)!=1)throw new De(`'${e}' is not an array`);if(r.size!==void 0){if(i.length!=r.size)throw new De(`invalid size for '${e}' (expecting ${r.size} entries, got ${i.length})`)}else this.stream.writeVarUint(i.length);for(let t in i)this.serializeItem(r,i[t],e+`[${t}]`)}else this.serializeItem(r,i,e)}}serializeItem(e,t,n){let r=e.type&31;if(r==2){if(ro.getType(t)!=2)throw new De(`'${n}' is not an object`);if(e.definition)this.serializeObject(e.definition,t,n);else if(e.schema)this.serializeObject(e.schema.definition,t,n);else throw new De(`missing definition in schema`)}else{let i=new io(e,t);try{i.check()}catch(e){throw new De(`Error on field '${n}': ${e}`)}this.stream.writeSchemaValue(r,t,e.size)}}},Mv=class{schema;stream;constructor(e){this.schema=e}unserialize(e){this.stream=new Av(e);let t=this.unserializeObject(this.schema.definition),n=this.stream.getPointer(),r=e.length;if(n!=r)throw console.error(k.binaryToHexa(e)),new o(`Invalid stream length (decoded ${n} bytes, actual length is ${r} bytes)`);return t}unserializeObject(e){let t={};for(let n of e){let e;if(n.type&32){let t=n.size===void 0?this.stream.readVarUint():n.size;for(e=[];t--;)e.push(this.unserializeItem(n))}else e=this.unserializeItem(n);t[n.name]=e}return t}unserializeItem(e){let t=e.type&31;if(t==2){if(e.definition)return this.unserializeObject(e.definition);if(e.schema)return this.unserializeObject(e.schema.definition);throw`missing definition in schema`}return this.stream.readSchemaValue(t,e.size)}},Nv=class e{static schema={label:`PKE_ML_KEM_CIPHERTEXT`,definition:[{name:`encryptedSharedSecret`,type:12},{name:`encryptedMessage`,type:12}]};serializer=new jv(e.schema);deserializer=new Mv(e.schema);encode(e,t){return this.serializer.serialize({encryptedSharedSecret:e,encryptedMessage:t})}decode(e){return this.deserializer.unserialize(e)}},Pv=class extends bv{static encoder=fg.bytesToBase64Encoder();constructor(e){super(),this.publicKey=e}async encrypt(e){let{cipherText:t,sharedSecret:n}=Ud.encapsulate(this.publicKey),r=await Ig.createFromBytes(n).encrypt(e);return new Nv().encode(t,r)}async getRawPublicKey(){return this.publicKey}getScheme(){return new Sv}},Fv=class e extends xv{static async genFromSeed(t){if(t.length!==64)throw Error(`Seed must be 64 bytes long: got length: ${t?.length} bytes`);return new e(t)}static async gen(){return new e(Iu(64))}privateKey;publicKey;constructor(e){super(),this.seed=e;let{secretKey:t,publicKey:n}=Ud.keygen(e);this.privateKey=t,this.publicKey=n}getSupportedSeedLength(){return[64]}getScheme(){return new Sv}async getPublicKey(){return new Pv(this.publicKey)}getRawPrivateKey(){return this.privateKey}async decrypt(e){try{let{encryptedMessage:t,encryptedSharedSecret:n}=new Nv().decode(e),r=Ud.decapsulate(n,this.privateKey);return Ig.createFromBytes(r).decrypt(t)}catch(e){throw o.isCarmentisError(e)?new f:e}}},Iv=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ya.SECP256K1}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},Lv=class extends Bg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return tp(t,Kc(e),this.publicKey)}getScheme(){return new Iv}},Rv=class e extends zg{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(sp.randomPrivateKey())}static genFromSeed(t){return new e(op.bytesToHex(t))}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new Lv(Kf(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return ep(Kc(e),this.privateKey).toCompactRawBytes()}getScheme(){return new Iv}},zv=class e{static createPrivateSignatureKey(e,t){switch(e){case Ya.SECP256K1:return new Rv(t);case Ya.ML_DSA_65:return new Ug(t);default:throw`Not supported signature scheme ID: ${e}`}}static createVirtualBlockchainPrivateSignature(e,t,n,r){let i=new Uint8Array([...n,...r]),a=new TextEncoder,o=e.deriveKeyNoSalt(i,a.encode(`VB_ACTOR_KEY`),32);switch(t){case Ya.ML_DSA_65:return new Ug(o);case Ya.SECP256K1:return Rv.genFromSeed(o);default:throw`Not supported signature scheme ID: ${t}`}}static deriveKeyFromPassword(t,n=sv.PBKDF2,r=Pg.AES_256_GCM){let i=e.createSymmetricEncryptionKeyScheme(r).getDefaultKeyLength(),a=e.createDefaultPBKDF().deriveKeyNoSalt(t,i);return e.createSymmetricEncryptionKey(r,a)}createDecapsulationKey(e,t){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}createVirtualBlockchainDecapsulationKey(e,t,n){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}async createPublicSignatureKey(t,n){return e.createPublicSignatureKey(t,n)}static async createPublicSignatureKey(e,t){switch(e){case Ya.SECP256K1:return new Lv(t);case Ya.ML_DSA_65:return new Hg(t);default:throw Error(`Not supported signature scheme ID: ${e}`)}}static async createPublicEncryptionKey(e,t){switch(e){case vv.ML_KEM_768_AES_256_GCM:return new Pv(t);default:throw Error(`Not supported scheme ID: ${e}`)}}static async createPrivateDecryptionKey(e,t){switch(e){case vv.ML_KEM_768_AES_256_GCM:return await Fv.genFromSeed(t);default:throw Error(`Not supported scheme ID: ${e}`)}}createSymmetricEncryptionKey(t,n){return e.createSymmetricEncryptionKey(t,n)}static createSymmetricEncryptionKey(e,t){switch(e){case Pg.AES_256_GCM:return Ig.createFromBytes(t);default:throw`Not supported encryption scheme ID: ${e}`}}static createSymmetricEncryptionKeyScheme(e){switch(e){case Pg.AES_256_GCM:return new Fg;default:throw`Not supported encryption scheme ID: ${e}`}}static createCryptographicHash(e){switch(e){case nv.SHA256:return new rv;default:throw`Not supported hash scheme ID: ${e}`}}static createDefaultCryptographicHash(){return new rv}static createDefaultPBKDF(){return new lv}static createDefaultKDF(){return new _v}static createSignatureScheme(e){switch(e){case Ya.SECP256K1:return new Iv;case Ya.ML_DSA_65:return new Vg;default:throw Error(`Not supported signature scheme ID: ${e}`)}}},Bv=class e{static PKE_KEY=`PKE`;static SK_PKE_KEY=`SK`;static PK_PKE_KEY=`PK`;static PKE_SCHEMES=[{algoId:vv.ML_KEM_768_AES_256_GCM,label:`MLKEM768AES256GCM`}];static createHexHCVPkeEncoder(){return new e(fg.bytesToHexEncoder())}static createBase64HCVPkeEncoder(){return new e(fg.bytesToBase64Encoder())}constructor(e){this.stringEncoder=e}async decodePrivateDecryptionKey(t){let n=gg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.SK_PKE_KEY))return await zv.createPrivateDecryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async decodePublicEncryptionKey(t){let n=gg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.PK_PKE_KEY))return zv.createPublicEncryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async encodePrivateDecryptionKey(t){return gg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.SK_PKE_KEY,this.stringEncoder.encode(t.getRawPrivateKey()))}async encodePublicEncryptionKey(t){return gg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.PK_PKE_KEY,this.stringEncoder.encode(await t.getRawPublicKey()))}},Vv=`SIG`,Hv=`SK`,Uv=`PK`,Wv=class{bytesEncoder=fg.bytesToHexEncoder();constructor(e){this.labels=e}async encodePublicKey(e){return gg.encode(...this.getHCVPublicKeyEncodingPrefix(),this.bytesEncoder.encode(await e.getPublicKeyAsBytes()))}getHCVPrivateKeyEncodingPrefix(){return[Vv,...this.labels,Hv]}getHCVPublicKeyEncodingPrefix(){return[Vv,...this.labels,Uv]}},Gv=class extends Wv{constructor(e){super(e)}async encodePrivateKey(e){return gg.encode(...this.getHCVPrivateKeyEncodingPrefix(),this.bytesEncoder.encode(e.getPrivateKeyAsBytes()))}},Kv=class extends Gv{constructor(){super([`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof Rv}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Lv}},qv=class extends Gv{constructor(){super([`MLDSA65`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof Ug}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Hg}};function Jv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Yv={exports:{}},Xv=Yv.exports={},Zv,Qv;function $v(){throw Error(`setTimeout has not been defined`)}function ey(){throw Error(`clearTimeout has not been defined`)}(function(){try{Zv=typeof setTimeout==`function`?setTimeout:$v}catch{Zv=$v}try{Qv=typeof clearTimeout==`function`?clearTimeout:ey}catch{Qv=ey}})();function ty(e){if(Zv===setTimeout)return setTimeout(e,0);if((Zv===$v||!Zv)&&setTimeout)return Zv=setTimeout,setTimeout(e,0);try{return Zv(e,0)}catch{try{return Zv.call(null,e,0)}catch{return Zv.call(this,e,0)}}}function ny(e){if(Qv===clearTimeout)return clearTimeout(e);if((Qv===ey||!Qv)&&clearTimeout)return Qv=clearTimeout,clearTimeout(e);try{return Qv(e)}catch{try{return Qv.call(null,e)}catch{return Qv.call(this,e)}}}var ry=[],iy=!1,ay,oy=-1;function sy(){!iy||!ay||(iy=!1,ay.length?ry=ay.concat(ry):oy=-1,ry.length&&cy())}function cy(){if(!iy){var e=ty(sy);iy=!0;for(var t=ry.length;t;){for(ay=ry,ry=[];++oy<t;)ay&&ay[oy].run();oy=-1,t=ry.length}ay=null,iy=!1,ny(e)}}Xv.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];ry.push(new ly(e,t)),ry.length===1&&!iy&&ty(cy)};function ly(e,t){this.fun=e,this.array=t}ly.prototype.run=function(){this.fun.apply(null,this.array)},Xv.title=`browser`,Xv.browser=!0,Xv.env={},Xv.argv=[],Xv.version=``,Xv.versions={};function uy(){}Xv.on=uy,Xv.addListener=uy,Xv.once=uy,Xv.off=uy,Xv.removeListener=uy,Xv.removeAllListeners=uy,Xv.emit=uy,Xv.prependListener=uy,Xv.prependOnceListener=uy,Xv.listeners=function(e){return[]},Xv.binding=function(e){throw Error(`process.binding is not supported`)},Xv.cwd=function(){return`/`},Xv.chdir=function(e){throw Error(`process.chdir is not supported`)},Xv.umask=function(){return 0};var dy=Yv.exports,fy=Jv(dy),py=class{async getPkmsCredential(){let e=fy.env.PKMS_API_KEY;if(e===void 0)throw Error(`PKMS_API_KEY environment variable is not set.`);return e}},my=`https://pkms.admin.carmentis.io`,hy=class e{static createFromKeyId(t){return new e(t)}credentialProvider=new py;constructor(e,t={host:my}){this.keyId=e,this.options=t}getKeyId(){return this.keyId}getPrivateKeyAsBytes(){throw Error(`Private key material cannot be exported.`)}async getPublicKey(){let e=await fetch(`${this.options.host}/api/keys/${this.keyId}/pk`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to fetch public key with id ${this.keyId} at ${this.options.host}: ${e.statusText}.`);let t=(await e.json()).publicKey;if(t===void 0)throw Error(`Failed to fetch public key: no "publicKey" field found in response body.`);return new gy(new Uint8Array(Ng.from(t,`base64`)))}getScheme(){return new Iv}getSignatureSchemeId(){return Ya.PKMS_SECP256K1}getSignatureSize(){return this.getScheme().getSignatureSize()}setCredentialProvider(e){this.credentialProvider=e}async sign(e){let t=await this.credentialProvider.getPkmsCredential();try{let n=await fetch(`${this.options.host}/api/sign`,{method:`POST`,headers:{authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({keyId:this.keyId,base64EncodedData:Ng.from(e).toString(`base64`)})});if(n.ok){let e=await n.json();return Ng.from(e.signature,`base64`)}else throw Error(`Failed to sign data.`)}catch(e){throw e}}},gy=class extends Lv{getSignatureSchemeId(){return Ya.PKMS_SECP256K1}},_y=class extends Wv{constructor(){super([`PKMS`,`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof hy}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof gy}async encodePrivateKey(e){if(!(e instanceof hy))throw Error(`Invalid private key type: `+e.constructor.name);let t=e.getKeyId();return gg.encode(...this.getHCVPrivateKeyEncodingPrefix(),t)}},vy=`SIG`,yy=`SK`,by=`PK`,xy=class e{static logger=ts.getLogger([`HCVSignatureDecoder`]);bytesEncoder=fg.bytesToHexEncoder();constructor(e){this.labels=e}async isAcceptingPrivateKeyDecodingRequest(t){try{let n=gg.decode(t);return e.logger.debug(`Attempt to decode private key for ${this.labels}: found ${n.getKeys()}`),n.matchesKeys(vy,...this.labels,yy)}catch(t){return e.logger.debug(`Fail to decode private key for ${this.labels}: ${t}`),!1}}async isAcceptingPublicKeyDecodingRequest(e){try{return gg.decode(e).matchesKeys(vy,...this.labels,by)}catch{return!1}}static getSignatureKey(){return vy}static getSkSignatureKey(){return yy}static getPkSignatureKey(){return by}},Sy=class extends xy{async decodePrivateKey(e){let t=gg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPrivateKey(n)}async decodePublicKey(e){let t=gg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPublicKey(n)}},Cy=class e extends Sy{static label=`SECP256K1`;constructor(){super([e.label])}bootstrapPrivateKey(e){return new Rv(e)}bootstrapPublicKey(e){return new Lv(e)}},wy=class e extends Sy{static ML_DSA65_SIGNATURE_KEY=`MLDSA65`;constructor(){super([e.ML_DSA65_SIGNATURE_KEY])}bootstrapPrivateKey(e){return new Ug(e)}bootstrapPublicKey(e){return new Hg(e)}},Ty=class e extends xy{static label=[`PKMS`,`SECP256K1`];constructor(){super(e.label)}async decodePrivateKey(e){return new hy(gg.decode(e).getValue())}async decodePublicKey(e){let t=gg.decode(e);return new gy(this.bytesEncoder.decode(t.getValue()))}},Ey=class{encoders=[new Kv,new qv,new _y];decoders=[new Cy,new wy,new Ty];constructor(e=fg.bytesToHexEncoder()){this.bytesEncoder=e}registerEncoder(e){this.encoders.push(e)}registerDecoder(e){this.decoders.push(e)}decodeMessage(e){return this.bytesEncoder.decode(e)}async decodePrivateKey(e){for(let t of this.decoders)if(await t.isAcceptingPrivateKeyDecodingRequest(e))return await t.decodePrivateKey(e);throw Error(`Invalid private key format: no decoder found`)}async decodePublicKey(e){for(let t of this.decoders)if(await t.isAcceptingPublicKeyDecodingRequest(e))return await t.decodePublicKey(e);throw Error(`Invalid private key format: no decoder found`)}decodeSignature(e){return this.bytesEncoder.decode(e)}encodeMessage(e){return this.bytesEncoder.encode(e)}async encodePrivateKey(e){for(let t of this.encoders)if(await t.isAcceptingPrivateKeyEncodingRequest(e))return await t.encodePrivateKey(e);throw Error(`No encoder found`)}async encodePublicKey(e){for(let t of this.encoders)if(await t.isAcceptingPublicKeyEncodingRequest(e))return await t.encodePublicKey(e);throw Error(`No encoder found`)}encodeSignature(e){return this.bytesEncoder.encode(e)}},Dy;try{Dy=new TextDecoder}catch{}var U,Oy,W=0,ky=[],Ay=105,jy=57342,My=57343,Ny=57337,Py=6,Fy={},Iy=11281e4,Ly=1681e4,Ry=ky,zy=0,G={},By,Vy,Hy=0,Uy=0,Wy,Gy,Ky=[],qy=[],Jy,Yy,Xy,Zy={useRecords:!1,mapsAsObjects:!0},Qy=!1,$y=2;try{Function(``)}catch{$y=1/0}var eb=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[ib(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(U)return Ob(()=>(kb(),this?this.decode(t,n):e.prototype.decode.call(Zy,t,n)));Oy=n>-1?n:t.length,W=0,zy=0,Uy=0,Vy=null,Ry=ky,Wy=null,U=t;try{Yy=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw U=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(G=this,Jy=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return By=this.structures,tb();(!By||By.length>0)&&(By=[])}else G=Zy,(!By||By.length>0)&&(By=[]),Jy=null;return tb()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;Qy=!0;let a=this?this.decode(e,i):jb.decode(e,i);if(t){if(t(a)===!1)return;for(;W<i;)if(r=W,t(tb())===!1)return}else{for(n=[a];W<i;)r=W,n.push(tb());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Qy=!1,kb()}}};function tb(){try{let e=K();if(Wy){if(W>=Wy.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}W=Wy.postBundlePosition,Wy=null}if(W==Oy)By=null,U=null,Gy&&=null;else if(W>Oy){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!Qy)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw kb(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function K(){let e=U[W++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=U[W++];break;case 25:if(t==7)return pb();e=Yy.getUint16(W),W+=2;break;case 26:if(t==7){let e=Yy.getFloat32(W);if(G.useFloat32>2){let t=Ab[(U[W]&127)<<1|U[W+1]>>7];return W+=4,(t*e+(e>0?.5:-.5)>>0)/t}return W+=4,e}if(e=Yy.getUint32(W),W+=4,t===1)return-1-e;break;case 27:if(t==7){let e=Yy.getFloat64(W);return W+=8,e}if(t>1){if(Yy.getUint32(W)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=Yy.getUint32(W+4)}else G.int64AsNumber?(e=Yy.getUint32(W)*4294967296,e+=Yy.getUint32(W+4)):e=Yy.getBigUint64(W);W+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=K())!=Fy;){if(r>=Iy)throw Error(`Array length exceeds ${Iy}`);e[r++]=n}return t==4?e:t==3?e.join(``):Ng.concat(e);case 5:let i;if(G.mapsAsObjects){let e={},t=0;if(G.keyMap)for(;(i=K())!=Fy;){if(t++>=Ly)throw Error(`Property count exceeds ${Ly}`);e[ib(G.decodeKey(i))]=K()}else for(;(i=K())!=Fy;){if(t++>=Ly)throw Error(`Property count exceeds ${Ly}`);e[ib(i)]=K()}return e}else{Xy&&=(G.mapsAsObjects=!0,!1);let e=new Map;if(G.keyMap){let t=0;for(;(i=K())!=Fy;){if(t++>=Ly)throw Error(`Map size exceeds ${Ly}`);e.set(G.decodeKey(i),K())}}else{let t=0;for(;(i=K())!=Fy;){if(t++>=Ly)throw Error(`Map size exceeds ${Ly}`);e.set(i,K())}}return e}case 7:return Fy;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return ub(e);case 3:if(Uy>=W)return Vy.slice(W-Hy,(W+=e)-Hy);if(Uy==0&&Oy<140&&e<32){let t=e<16?lb(e):cb(e);if(t!=null)return t}return ab(e);case 4:if(e>=Iy)throw Error(`Array length exceeds ${Iy}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=K();return t;case 5:if(e>=Ly)throw Error(`Map size exceeds ${Iy}`);if(G.mapsAsObjects){let t={};if(G.keyMap)for(let n=0;n<e;n++)t[ib(G.decodeKey(K()))]=K();else for(let n=0;n<e;n++)t[ib(K())]=K();return t}else{Xy&&=(G.mapsAsObjects=!0,!1);let t=new Map;if(G.keyMap)for(let n=0;n<e;n++)t.set(G.decodeKey(K()),K());else for(let n=0;n<e;n++)t.set(K(),K());return t}case 6:if(e>=Ny){let t=By[e&8191];if(t)return t.read||=rb(t),t.read();if(e<65536){if(e==My){let e=Eb(),t=K(),n=K();hb(t,n);let r={};if(G.keyMap)for(let t=2;t<e;t++){let e=G.decodeKey(n[t-2]);r[ib(e)]=K()}else for(let t=2;t<e;t++){let e=n[t-2];r[ib(e)]=K()}return r}else if(e==jy){let e=Eb(),t=K();for(let n=2;n<e;n++)hb(t++,K());return K()}else if(e==Ny)return Tb();if(G.getShared&&(Db(),t=By[e&8191],t))return t.read||=rb(t),t.read()}}let n=Ky[e];if(n)return n.handlesRead?n(K):n(K());{let t=K();for(let n=0;n<qy.length;n++){let r=qy[n](e,t);if(r!==void 0)return r}return new mb(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(Jy||yb())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}var nb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function rb(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=U[W++];if(e&=31,e>23)switch(e){case 24:e=U[W++];break;case 25:e=Yy.getUint16(W),W+=2;break;case 26:e=Yy.getUint32(W),W+=4;break;default:throw Error(`Expected array header, but got `+U[W-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(K);t=t.next}if(this.slowReads++>=$y){let n=this.length==e?this:this.slice(0,e);return t=G.keyMap?Function(`r`,`return {`+n.map(e=>G.decodeKey(e)).map(e=>nb.test(e)?ib(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>nb.test(e)?ib(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(K)}let n={};if(G.keyMap)for(let t=0;t<e;t++)n[ib(G.decodeKey(this[t]))]=K();else for(let t=0;t<e;t++)n[ib(this[t])]=K();return n}return e.slowReads=0,t}function ib(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}var ab=ob;function ob(e){let t;if(e<16&&(t=lb(e)))return t;if(e>64&&Dy)return Dy.decode(U.subarray(W,W+=e));let n=W+e,r=[];for(t=``;W<n;){let e=U[W++];if(!(e&128))r.push(e);else if((e&224)==192){let t=U[W++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=U[W++]&63,n=U[W++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=U[W++]&63,n=U[W++]&63,i=U[W++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=sb.apply(String,r),r.length=0)}return r.length>0&&(t+=sb.apply(String,r)),t}var sb=String.fromCharCode;function cb(e){let t=W,n=Array(e);for(let r=0;r<e;r++){let e=U[W++];if((e&128)>0){W=t;return}n[r]=e}return sb.apply(String,n)}function lb(e){if(e<4)if(e<2){if(e===0)return``;{let e=U[W++];if((e&128)>1){--W;return}return sb(e)}}else{let t=U[W++],n=U[W++];if((t&128)>0||(n&128)>0){W-=2;return}if(e<3)return sb(t,n);let r=U[W++];if((r&128)>0){W-=3;return}return sb(t,n,r)}else{let t=U[W++],n=U[W++],r=U[W++],i=U[W++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){W-=4;return}if(e<6){if(e===4)return sb(t,n,r,i);{let e=U[W++];if((e&128)>0){W-=5;return}return sb(t,n,r,i,e)}}else if(e<8){let a=U[W++],o=U[W++];if((a&128)>0||(o&128)>0){W-=6;return}if(e<7)return sb(t,n,r,i,a,o);let s=U[W++];if((s&128)>0){W-=7;return}return sb(t,n,r,i,a,o,s)}else{let a=U[W++],o=U[W++],s=U[W++],c=U[W++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){W-=8;return}if(e<10){if(e===8)return sb(t,n,r,i,a,o,s,c);{let e=U[W++];if((e&128)>0){W-=9;return}return sb(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=U[W++],u=U[W++];if((l&128)>0||(u&128)>0){W-=10;return}if(e<11)return sb(t,n,r,i,a,o,s,c,l,u);let d=U[W++];if((d&128)>0){W-=11;return}return sb(t,n,r,i,a,o,s,c,l,u,d)}else{let l=U[W++],u=U[W++],d=U[W++],f=U[W++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){W-=12;return}if(e<14){if(e===12)return sb(t,n,r,i,a,o,s,c,l,u,d,f);{let e=U[W++];if((e&128)>0){W-=13;return}return sb(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=U[W++],m=U[W++];if((p&128)>0||(m&128)>0){W-=14;return}if(e<15)return sb(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=U[W++];if((h&128)>0){W-=15;return}return sb(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function ub(e){return G.copyBuffers?Uint8Array.prototype.slice.call(U,W,W+=e):U.subarray(W,W+=e)}var db=new Float32Array(1),fb=new Uint8Array(db.buffer,0,4);function pb(){let e=U[W++],t=U[W++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return fb[3]=e&128|(n>>1)+56,fb[2]=(e&7)<<5|t>>3,fb[1]=t<<5,fb[0]=0,db[0]}Array(4096);var mb=class{constructor(e,t){this.value=e,this.tag=t}};Ky[0]=e=>new Date(e),Ky[1]=e=>new Date(Math.round(e*1e3)),Ky[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},Ky[3]=e=>BigInt(-1)-Ky[2](e),Ky[4]=e=>+(e[1]+`e`+e[0]),Ky[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));var hb=(e,t)=>{e-=57344;let n=By[e];n&&n.isShared&&((By.restoreStructures||=[])[e]=n),By[e]=t,t.read=rb(t)};Ky[Ay]=e=>{let t=e.length,n=e[1];hb(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[ib(t)]=e[i]}return r},Ky[14]=e=>Wy?Wy[0].slice(Wy.position0,Wy.position0+=e):new mb(e,14),Ky[15]=e=>Wy?Wy[1].slice(Wy.position1,Wy.position1+=e):new mb(e,15);var gb={Error,RegExp};Ky[27]=e=>(gb[e[0]]||Error)(e[1],e[2]);var _b=e=>{if(U[W++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw U.length<W&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return Jy=Jy?t.concat(Jy.slice(t.length)):t,Jy.prefixes=e(),Jy.suffixes=e(),e()};_b.handlesRead=!0,Ky[51]=_b,Ky[Py]=e=>{if(!Jy)if(G.getShared)Db();else return new mb(e,Py);if(typeof e==`number`)return Jy[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},Ky[28]=e=>{Gy||(Gy=new Map,Gy.id=0);let t=Gy.id++,n=W,r=U[W],i;i=r>>5==4?[]:{};let a={target:i};Gy.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(W=n,i=o,Gy.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},Ky[28].handlesRead=!0,Ky[29]=e=>{let t=Gy.get(e);return t.used=!0,t.target},Ky[258]=e=>new Set(e),(Ky[259]=e=>(G.mapsAsObjects&&(G.mapsAsObjects=!1,Xy=!0),e())).handlesRead=!0;function vb(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function yb(){if(!Jy)if(G.getShared)Db();else throw Error(`No packed values available`);return Jy}var bb=1399353956;qy.push((e,t)=>{if(e>=225&&e<=255)return vb(yb().prefixes[e-224],t);if(e>=28704&&e<=32767)return vb(yb().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return vb(yb().prefixes[e-1879048192],t);if(e>=216&&e<=223)return vb(t,yb().suffixes[e-216]);if(e>=27647&&e<=28671)return vb(t,yb().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return vb(t,yb().suffixes[e-1811939328]);if(e==bb)return{packedValues:Jy,structures:By.slice(0),version:t};if(e==55799)return t});var xb=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Sb=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Cb=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Sb.length;e++)wb(Sb[e],Cb[e]);function wb(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;Ky[i?t:t-4]=r==1||i==xb?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!G.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function Tb(){let e=Eb(),t=W+K();for(let t=2;t<e;t++){let e=Eb();W+=e}let n=W;return W=t,Wy=[ob(Eb()),ob(Eb())],Wy.position0=0,Wy.position1=0,Wy.postBundlePosition=W,W=n,K()}function Eb(){let e=U[W++]&31;if(e>23)switch(e){case 24:e=U[W++];break;case 25:e=Yy.getUint16(W),W+=2;break;case 26:e=Yy.getUint32(W),W+=4;break}return e}function Db(){if(G.getShared){let e=Ob(()=>(U=null,G.getShared()))||{},t=e.structures||[];G.sharedVersion=e.version,Jy=G.sharedValues=e.packedValues,By===!0?G.structures=By=t:By.splice.apply(By,[0,t.length].concat(t))}}function Ob(e){let t=Oy,n=W,r=zy,i=Hy,a=Uy,o=Vy,s=Ry,c=Gy,l=Wy,u=new Uint8Array(U.slice(0,Oy)),d=By,f=G,p=Qy,m=e();return Oy=t,W=n,zy=r,Hy=i,Uy=a,Vy=o,Ry=s,Gy=c,Wy=l,U=u,Qy=p,By=d,G=f,Yy=new DataView(U.buffer,U.byteOffset,U.byteLength),m}function kb(){U=null,Gy=null,By=null}var Ab=Array(147);for(let e=0;e<256;e++)Ab[e]=+(`1e`+Math.floor(45.15-e*.30103));var jb=new eb({useRecords:!1}),Mb=jb.decode;jb.decodeMultiple;var Nb={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Pb;try{Pb=new TextEncoder}catch{}var Fb,Ib,Lb=typeof globalThis==`object`&&globalThis.Buffer,Rb=Lb!==void 0,zb=Rb?Lb.allocUnsafeSlow:Uint8Array,Bb=Rb?Lb:Uint8Array,Vb=256,Hb=Rb?4294967296:2144337920,Ub,q,Wb,J=0,Gb,Kb=null,qb=61440,Jb=/[\u0080-\uFFFF]/,Yb=Symbol(`record-id`),Xb=class extends eb{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=Bb.prototype.utf8Write?function(e,t){return q.utf8Write(e,t,q.byteLength-t)}:Pb&&Pb.encodeInto?function(e,t){return Pb.encodeInto(e,q.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(q||(q=new zb(8192),Wb=new DataView(q.buffer,0,8192),J=0),Gb=q.length-10,Gb-J<2048?(q=new zb(q.length),Wb=new DataView(q.buffer,0,q.length),Gb=q.length-10,J=0):c===512&&(J=J+7&2147483640),t=J,s.useSelfDescribedHeader&&(Wb.setUint32(J,3654940416),J+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(Kb=[],Kb.size=1/0):Kb=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[Yb]===void 0&&(i[Yb]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[Yb]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,nx(o,t),t.values.length>0){q[J++]=216,q[J++]=51,$b(4);let e=t.values;v(e),$b(0),$b(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}Ub=c&mx;try{if(Ub)return;if(v(o),Kb&&sx(t,v),s.offset=J,a&&a.idsToInsert){J+=a.idsToInsert.length*2,J>Gb&&b(J),s.offset=J;let e=ox(q.subarray(t,J),a.idsToInsert);return a=null,e}return c&512?(q.start=t,q.end=J,q):q.subarray(t,J)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][Yb]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=q.subarray(t,J);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(J=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{J>Gb&&(q=b(J));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?q[J++]=t+224:(q[J++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(Kb&&r>=4&&r<1024){if((Kb.size+=r)>qb){let e,n=(Kb[0]?Kb[0].length*3+Kb[1].length:0)+10;J+n>Gb&&(q=b(J+n)),q[J++]=217,q[J++]=223,q[J++]=249,q[J++]=Kb.position?132:130,q[J++]=26,e=J-t,J+=4,Kb.position&&sx(t,v),Kb=[``,``],Kb.size=0,Kb.position=e}let e=Jb.test(n);Kb[+!e]+=n,q[J++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(J+s>Gb&&(q=b(J+s)),r<64||!o){let e,t,o,s=J+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?q[s++]=t:t<2048?(q[s++]=t>>6|192,q[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,q[s++]=t>>18|240,q[s++]=t>>12&63|128,q[s++]=t>>6&63|128,q[s++]=t&63|128):(q[s++]=t>>12|224,q[s++]=t>>6&63|128,q[s++]=t&63|128);i=s-J-a}else i=o(n,J+a,s);i<24?q[J++]=96|i:i<256?(a<2&&q.copyWithin(J+2,J+1,J+1+i),q[J++]=120,q[J++]=i):i<65536?(a<3&&q.copyWithin(J+3,J+2,J+2+i),q[J++]=121,q[J++]=i>>8,q[J++]=i&255):(a<5&&q.copyWithin(J+5,J+3,J+3+i),q[J++]=122,Wb.setUint32(J,i),J+=4),J+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?q[J++]=n:n<256?(q[J++]=24,q[J++]=n):n<65536?(q[J++]=25,q[J++]=n>>8,q[J++]=n&255):(q[J++]=26,Wb.setUint32(J,n),J+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?q[J++]=31-n:n>=-256?(q[J++]=56,q[J++]=~n):n>=-65536?(q[J++]=57,Wb.setUint16(J,~n),J+=2):(q[J++]=58,Wb.setUint32(J,~n),J+=4);else if(!this.alwaysUseFloat&&n<0&&n>=-4294967296&&Math.floor(n)===n)q[J++]=58,Wb.setUint32(J,-1-n),J+=4;else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){q[J++]=250,Wb.setFloat32(J,n);let t;if(e<4||(t=n*Ab[(q[J]&127)<<1|q[J+1]>>7])>>0===t){J+=4;return}else J--}q[J++]=251,Wb.setFloat64(J,n),J+=8}else if(r===`object`)if(!n)q[J++]=246;else{if(a){let e=a.get(n);if(e){if(q[J++]=216,q[J++]=29,q[J++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(J-t),J+=2;return}else a.set(n,{offset:J-t})}let e=n.constructor;if(e===Object)this.skipFunction===!0&&(n=Object.fromEntries([...Object.keys(n).filter(e=>typeof n[e]!=`function`).map(e=>[e,n[e]])])),y(n);else if(e===Array){i=n.length,i<24?q[J++]=128|i:$b(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(q[J++]=217,q[J++]=1,q[J++]=3),i=n.size,i<24?q[J++]=160|i:i<256?(q[J++]=184,q[J++]=i):i<65536?(q[J++]=185,q[J++]=i>>8,q[J++]=i&255):(q[J++]=186,Wb.setUint32(J,i),J+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=Fb.length;e<t;e++){let t=Ib[e];if(n instanceof t){let t=Fb[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?q[J++]=192|r:r<256?(q[J++]=216,q[J++]=r):r<65536?(q[J++]=217,q[J++]=r>>8,q[J++]=r&255):r>-1&&(q[J++]=218,Wb.setUint32(J,r),J+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(Ub){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}q[J++]=159;for(let e of n)v(e);q[J++]=255;return}if(n[Symbol.asyncIterator]||tx(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)q[J++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)q[J++]=27,Wb.setBigUint64(J,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)q[J++]=59,Wb.setBigUint64(J,-n-BigInt(1));else if(this.largeBigIntToFloat)q[J++]=251,Wb.setFloat64(J,Number(n));else{n>=BigInt(0)?q[J++]=194:(q[J++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);ax(new Uint8Array(e.reverse()),b);return}J+=8}else if(r===`undefined`)q[J++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?q[J++]=160|r:r<256?(q[J++]=184,q[J++]=r):r<65536?(q[J++]=185,q[J++]=r>>8,q[J++]=r&255):(q[J++]=186,Wb.setUint32(J,r),J+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{q[J++]=185;let n=J-t;J+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);q[n+++t]=r>>8,q[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[Yb]&1048576&&(c=a[Yb]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[Yb];if(d!==void 0)d&=65535,q[J++]=217,q[J++]=d>>8|224,q[J++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=Vb&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){q[J++]=217,q[J++]=d>>8|224,q[J++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[Yb]===void 0||a[Yb]&1048576)&&(a[Yb]=d),a=a[u[e]];a[Yb]=d|1048576,r=!0}else{if(a[Yb]=d,Wb.setUint32(J,3655335680),J+=3,o&&(g+=_*o),h.length>=Vb-l&&(h.shift()[Yb]=void 0),h.push(a),$b(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?q[J++]=128|s:$b(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>Hb)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(Hb,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,q.length-1)>>12)+1<<12;let r=new zb(n);return Wb=new DataView(r.buffer,0,n),q.copy?q.copy(r,0,t,e):r.set(q.slice(t,e)),J-=t,t=0,Gb=r.length-10,q=r},ee=100,x=1e3;this.encodeAsIterable=function(e,t){return re(e,t,te)},this.encodeAsAsyncIterable=function(e,t){return re(e,t,ie)};function*te(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):Zb(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*te(i,n[r]):yield*S(i,n,r):v(i)}}else if(i===Array){let r=e.length;$b(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||J-t>ee)?n.element?yield*te(r,n.element):yield*S(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){q[J++]=159;for(let r of e)r&&(typeof r==`object`||J-t>ee)?n.element?yield*te(r,n.element):yield*S(r,n,`element`):v(r);q[J++]=255}else tx(e)?(Zb(e.size,64),yield q.subarray(t,J),yield e,ne()):e[Symbol.asyncIterator]?(q[J++]=159,yield q.subarray(t,J),yield e,ne(),q[J++]=255):v(e);r&&J>t?yield q.subarray(t,J):J-t>ee&&(yield q.subarray(t,J),ne())}function*S(e,n,r){let i=J-t;try{v(e),J-t>ee&&(yield q.subarray(t,J),ne())}catch(a){if(a.iteratorNotHandled)n[r]={},J=t+i,yield*te.call(this,e,n[r]);else throw a}}function ne(){ee=x,s.encode(null,mx)}function re(e,t,n){return ee=t&&t.chunkThreshold?x=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,mx),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*ie(e,t){for(let n of te(e,t,!0)){let e=n.constructor;if(e===Bb||e===Uint8Array)yield n;else if(tx(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)ne(),e?yield*ie(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){q=e,Wb=new DataView(q.buffer,q.byteOffset,q.byteLength),J=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new Qb(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function Zb(e,t){e<24?q[J++]=t|e:e<256?(q[J++]=t|24,q[J++]=e):e<65536?(q[J++]=t|25,q[J++]=e>>8,q[J++]=e&255):(q[J++]=t|26,Wb.setUint32(J,e),J+=4)}var Qb=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function $b(e){e<24?q[J++]=128|e:e<256?(q[J++]=152,q[J++]=e):e<65536?(q[J++]=153,q[J++]=e>>8,q[J++]=e&255):(q[J++]=154,Wb.setUint32(J,e),J+=4)}var ex=typeof Blob>`u`?function(){}:Blob;function tx(e){if(e instanceof ex)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function nx(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)nx(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&nx(n,t),nx(e[n],t))}break;case`function`:console.log(e)}}var rx=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Ib=[Date,Set,Error,RegExp,mb,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,Qb],Fb=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(q[J++]=26,Wb.setUint32(J,n),J+=4):(q[J++]=251,Wb.setFloat64(J,n),J+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){ax(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Rb&&this.tagUint8Array!==!1))return 64},encode(e,t,n){ax(e,n)}},ix(68,1),ix(69,2),ix(70,4),ix(71,8),ix(72,1),ix(77,2),ix(78,4),ix(79,8),ix(85,4),ix(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){q[J++]=216,q[J++]=51,$b(4);let e=n.values;t(e),$b(0),$b(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){Wb.setUint32(J,3655335424),J+=3;let n=r.slice(0);n.unshift(57344),n.push(new mb(e.version,1399353956)),t(n)}else t(new mb(e.version,1399353956))}}];function ix(e,t){return!rx&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Rb?Lb.from(i,r,n):new Uint8Array(i,r,n))}}}function ax(e,t){let n=e.byteLength;n<24?q[J++]=64+n:n<256?(q[J++]=88,q[J++]=n):n<65536?(q[J++]=89,q[J++]=n>>8,q[J++]=n&255):(q[J++]=90,Wb.setUint32(J,n),J+=4),J+n>=q.length&&t(J+n),q.set(e.buffer?e:new Uint8Array(e),J),J+=n}function ox(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function sx(e,t){Wb.setUint32(Kb.position+e,J-Kb.position-e+1);let n=Kb;Kb=null,t(n[0]),t(n[1])}var cx=new Xb({useRecords:!1}),lx=cx.encode;cx.encodeAsIterable,cx.encodeAsAsyncIterable;var{NEVER:ux,ALWAYS:dx,DECIMAL_ROUND:fx,DECIMAL_FIT:px}=Nb,mx=2048,hx=class e{static encoder=new Xb({tagUint8Array:!1});decode(t){return e.encoder.decode(t)}encode(t){return e.encoder.encode(t)}},gx=class e{static defaultStringSignatureEncoder(){return new Ey(fg.defaultBytesToStringEncoder())}static defaultStringPublicKeyEncryptionEncoder(){return Bv.createBase64HCVPkeEncoder()}static cryptoBinaryEncoder=new hx;static getCryptoBinaryEncoder(){return e.cryptoBinaryEncoder}},Y=class e{static encoder=gx.getCryptoBinaryEncoder();static logger=ts.getLogger([`utils`]);static computeMicroblockHashFromHeader(t){let n=e.encodeMicroblockHeader(t);return j.Hashes.sha256AsBinary(n)}static checkHeaderList(t){let n=t.length;if(n===0)return{valid:!0,hashes:[]};if(n===1)return{valid:!0,hashes:[j.Hashes.sha256AsBinary(t[0])]};let r=[],i=null,a=ts.getProviderLogger();for(let n of t.reverse()){let t=j.Hashes.sha256AsBinary(n);if(i&&!k.binaryIsEqual(t,i))return a.error(`Received headers mismatch: Expected ${k.binaryToHexa(i)}, got ${k.binaryToHexa(t)}: aborting verification`),{valid:!1,hashes:[]};r.push(t),i=e.previousHashFromHeader(n)}return{valid:!0,hashes:r}}static previousHashFromHeader(t){return e.decodeMicroblockHeader(t).previousHash}static encodeVirtualBlockchainInfo(e){return this.encodeObjectToBinary(L(Vh,e))}static decodeVirtualBlockchainInfo(e){return L(Vh,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainState(e){return this.encodeObjectToBinary(L(Bh,e))}static decodeVirtualBlockchainState(e){return L(Bh,this.decodeObjectFromBinary(e))}static encodeMicroblockBody(e){return this.encodeObjectToBinary(L(Sh,e))}static decodeMicroblockBody(e){return L(Sh,this.decodeObjectFromBinary(e))}static encodeSection(e){return this.encodeObjectToBinary(L(xh,e))}static decodeSection(e){return L(xh,this.decodeObjectFromBinary(e))}static encodeMicroblockHeader(e){return this.encodeObjectToBinary(L(Nm,e))}static decodeMicroblockHeader(t){let n=this.decodeObjectFromBinary(t),r=L(Nm,n);if(!k.binaryIsEqual(n.bodyHash,r.bodyHash))throw e.logger.error(`Modified validated object: ${JSON.stringify(n)} vs ${JSON.stringify(r)}`),Error(`Modified body hash detected during deserialization: ${n.bodyHash} vs ${r.bodyHash}`);return r}static encodeEscrowParameters(e){return this.encodeObjectToBinary(L(Gh,e))}static decodeEscrowParameters(e){return L(Gh,this.decodeObjectFromBinary(e))}static encodeEscrowLock(e){return this.encodeObjectToBinary(L(Kh,e))}static decodeEscrowLock(e){return L(Kh,this.decodeObjectFromBinary(e))}static encodeVestingParameters(e){return this.encodeObjectToBinary(L(qh,e))}static decodeVestingParameters(e){return L(qh,this.decodeObjectFromBinary(e))}static encodeVestingLock(e){return this.encodeObjectToBinary(L(Jh,e))}static decodeVestingLock(e){return L(Jh,this.decodeObjectFromBinary(e))}static encodeNodeStakingParameters(e){return this.encodeObjectToBinary(L(Yh,e))}static decodeNodeStakingParameters(e){return L(Yh,this.decodeObjectFromBinary(e))}static encodeNodeStakingLock(e){return this.encodeObjectToBinary(L(Xh,e))}static decodeNodeStakingLock(e){return L(Xh,this.decodeObjectFromBinary(e))}static encodeLock(e){return this.encodeObjectToBinary(L(Zh,e))}static decodeLock(e){return L(Zh,this.decodeObjectFromBinary(e))}static encodeAccountBreakdown(e){return this.encodeObjectToBinary(L(Qh,e))}static decodeAccountBreakdown(e){return L(Qh,this.decodeObjectFromBinary(e))}static encodeAccountState(e){return this.encodeObjectToBinary(L($h,e))}static decodeAccountState(e){return L($h,this.decodeObjectFromBinary(e))}static encodeAccountInformation(e){return this.encodeObjectToBinary(L(eg,e))}static decodeAccountInformation(e){return L(eg,this.decodeObjectFromBinary(e))}static encodeMicroblockInformation(e){return this.encodeObjectToBinary(L(Hh,e))}static decodeMicroblockInformation(e){return L(Hh,this.decodeObjectFromBinary(e))}static encodeObjectToBinary(t){return e.encoder.encode(t)}static decodeObjectFromBinary(t){return e.encoder.decode(t)}},_x=86400,vx=class{constructor(e){this.priceStructure=e,this.priceStructure.sort((e,t)=>e.maximumNumberOfDays-t.maximumNumberOfDays)}getNumberOfDaysOfStorage(e,t){return t>0?Math.max(1,Math.round((t-e)/_x)):this.priceStructure[this.priceStructure.length-1].maximumNumberOfDays}getStoragePrice(e,t){let n=this.getBreakdown(e,t).reduce((e,t)=>e+t.priceInAtomics,0);return mn.createAtomic(n)}getBreakdown(e,t){let n=e.getAmountAsAtomic(),r=[];for(let e=0,i=0;i<t;e++){let a=this.priceStructure[e],o,s;a==null?(o=t-i,s=0):(o=Math.min(a.maximumNumberOfDays,t)-i,s=a.pricingRate);let c=Math.floor(n*o*s/100);r.push({numberOfDays:o,pricingRate:s,priceInAtomics:c}),i+=o}return r}},yx=class e{static DEFAULT_GAS_PRICE=mn.createAtomic(1);constructor(e){this.provider=e}async computeFees(t,n,r,i=k.getTimestampInSeconds()){if(r<0)throw Error(`Invalid expiration day`);let a=this.computeSizeInBytesOfMicroblock(n),o=n.getGasPrice(),s=o.isZero()?e.DEFAULT_GAS_PRICE:o,c=(dr+1*a)*s.getAmountAsAtomic(),l=mn.createAtomic(c),u=new vx((await this.provider.getProtocolState()).getPriceStructure()),d=u.getNumberOfDaysOfStorage(i,r),f=u.getStoragePrice(l,d),p=mn.createAtomic(this.getAdditionalCosts(t)*s.getAmountAsAtomic());return f.add(p),f}getAdditionalCosts(e){switch(e){case Ya.SECP256K1:return 1e3;case Ya.ML_DSA_65:return 5e3;case Ya.PKMS_SECP256K1:return 0}return 0}computeSizeInBytesOfMicroblock(e){let t=e.getAllSections();if(t.length===0)return 0;if(e.getMaxFees().isZero())return this.getSizeOfListOfSections(t);{let e=t[t.length-1].type===O.SIGNATURE?t.slice(0,t.length-1):t;return this.getSizeOfListOfSections(e)}}getSizeOfListOfSections(e){return e.reduce((e,t)=>e+Y.encodeSection(t).length,0)}},bx=class{static getGenesisFeesCalculationFormula(e){return new yx(e)}static getFeesCalculationFormulaByVersion(e,t){return this.getGenesisFeesCalculationFormula(e)}},xx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({signatureSchemeId:0,publicKeyHeight:0})}toObject(){return this.internalState}updateSignatureScheme(e){this.internalState.signatureSchemeId=e}updatePublicKeyHeight(e){this.internalState.publicKeyHeight=e}getPublicKeyHeight(){return this.internalState.publicKeyHeight}getPublicKeySchemeId(){return this.internalState.signatureSchemeId}},Sx=class e{constructor(e){this.hash=e}static from(t){let n=typeof t==`string`,r=t instanceof Uint8Array;if(!n&&!r)throw TypeError(`Expected hash of type string or Uint8Array: got ${typeof t}`);let i=fg.bytesToHexEncoder();return new e(typeof t==`string`?i.decode(t):t)}static fromHex(t){return new e(fg.bytesToHexEncoder().decode(t))}encode(e=new mg){return e.encode(this.hash).toUpperCase()}toBytes(){return new Uint8Array(this.hash)}equals(e){return this.hash.every((t,n)=>t===e.hash[n])}},Cx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({organizationId:k.getNullHash(),descriptionHeight:0})}clone(){return new e({...this.internalState})}toObject(){return this.internalState}setOrganizationId(e){this.internalState.organizationId=e}setDescriptionHeight(e){this.internalState.descriptionHeight=e}getOrganizationId(){return Sx.from(this.internalState.organizationId)}getDescriptionHeight(){return this.internalState.descriptionHeight}},wx=class e{static UNDEFINED_APPLICATION_ID=new Uint8Array;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({allowedAdditionalWriters:[],actors:[],allowedPkeSchemeIds:[],allowedSignatureSchemeIds:[],applicationId:this.UNDEFINED_APPLICATION_ID,channels:[]})}getAdditionalAllowedWriters(){return this.internalState.allowedAdditionalWriters}addAdditionalWriter(e){this.internalState.allowedAdditionalWriters.push(e)}toObject(){return this.internalState}clone(){return new e(structuredClone(this.internalState))}createActor(e){this.internalState.actors.push(e)}createActorWithId(e,t){if(this.isActorDefinedById(e))throw new ae(`Id: ${e}`);this.internalState.actors[e]=t}setAllowedSignatureSchemeIds(e){this.internalState.allowedSignatureSchemeIds=e}setAllowedPkeSchemeIds(e){this.internalState.allowedPkeSchemeIds=e}setApplicationId(e){this.internalState.applicationId=e}isChannelDefinedById(e){return this.internalState.channels[e]!==void 0}isChannelDefinedByName(e){return this.internalState.channels.some(t=>t.name===e)}createChannel(e){if(!this.isActorDefinedById(e.creatorId))throw new ae(`Id: ${e.creatorId}`);if(this.isChannelDefinedByName(e.name))throw new ie(e.name);this.internalState.channels.push(e)}createChannelWithId(e,t){if(this.isChannelDefinedById(e))throw new ie(`Id: ${e}`);if(this.isActorDefinedById(t.creatorId))throw new ae(`Id: ${t.creatorId}`);if(this.isChannelDefinedByName(t.name))throw new ie(t.name);this.internalState.channels[e]=t}isActorDefinedByName(e){return this.internalState.actors.some(t=>t.name===e)}isActorDefinedById(e){return this.internalState.actors[e]!==void 0}getAllowedSignatureSchemes(){return this.internalState.allowedSignatureSchemeIds}getAllowedPkeSchemes(){return this.internalState.allowedPkeSchemeIds}getNumberOfActors(){return this.internalState.actors.length}getActorById(e){let t=this.internalState.actors[e];if(t===void 0)throw new ae(`ID: ${e}`);return t}getNumberOfChannels(){return this.internalState.channels.length}getApplicationId(){return Sx.from(this.internalState.applicationId)}getChannelIdFromChannelName(e){let t=this.internalState.channels.findIndex(t=>t.name===e);if(t===void 0)throw new oe(e);return t}getChannelCreatorIdFromChannelId(e){return this.getChannelFromChannelId(e).creatorId}getChannelFromChannelId(e){let t=this.internalState.channels[e];if(t===void 0)throw new oe(`ID: ${e}`);return t}getActorByName(e){let t=this.internalState.actors.find(t=>t.name===e);if(t===void 0)throw new ae(e);return t}getActorIdByName(e){let t=this.internalState.actors.findIndex(t=>t.name===e);if(t===-1)throw new ae(e);return t}updateActor(e,t){if(!this.isActorDefinedById(e))throw new ae(`Id: ${e}`);this.internalState.actors[e]=t}updateChannel(e,t){if(!this.isChannelDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.channels[e]=t}getAllActors(){return this.internalState.actors}getAllChannels(){return this.internalState.channels}},Tx=function(e){return e.INITIAL_PROTOCOL_VERSION_NAME=`Clermont`,e}(Tx||{}),Ex=class e{constructor(e){this.internalState=e}static createFromObject(t){let n=am(Ch,t);if(n.success)return new e(n.output);throw Error(`Provided internal state is not valid: ${n.issues}`)}static createInitialState(){return new e({organizationId:k.getNullHash(),currentProtocolVariables:{protocolVersionName:Tx.INITIAL_PROTOCOL_VERSION_NAME,protocolVersion:1,feesCalculationVersion:1,globalStateUpdaterVersion:1,applicationLedgerInternalStateUpdaterVersion:1,applicationInternalStateUpdaterVersion:1,organizationInternalStateUpdaterVersion:1,validatorNodeInternalStateUpdaterVersion:1,accountInternalStateUpdaterVersion:1,protocolInternalStateUpdaterVersion:1,minimumNodeStakingAmountInAtomics:mn.create(1e6).getAmountAsAtomic(),maximumNodeStakingAmountInAtomics:mn.create(1e7).getAmountAsAtomic(),unstakingDelayInDays:30,maxBlockSizeInBytes:4194304,priceStructure:[{pricingRate:100,maximumNumberOfDays:7},{pricingRate:70,maximumNumberOfDays:30},{pricingRate:40,maximumNumberOfDays:365},{pricingRate:20,maximumNumberOfDays:3650},{pricingRate:10,maximumNumberOfDays:36500}],abciVersion:1},protocolUpdates:[]})}getAbciVersion(){return this.internalState.currentProtocolVariables.abciVersion}getMaximumBlockSizeInBytes(){return this.internalState.currentProtocolVariables.maxBlockSizeInBytes}getProtocolVariables(){return this.internalState.currentProtocolVariables}getApplicationLedgerInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationLedgerInternalStateUpdaterVersion}getApplicationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationInternalStateUpdaterVersion}getOrganizationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.organizationInternalStateUpdaterVersion}getValidatorNodeInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.validatorNodeInternalStateUpdaterVersion}getAccountInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.accountInternalStateUpdaterVersion}getProtocolInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.protocolInternalStateUpdaterVersion}getMinimumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.minimumNodeStakingAmountInAtomics}getMaximumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.maximumNodeStakingAmountInAtomics}getUnstakingDelayInDays(){return this.internalState.currentProtocolVariables.unstakingDelayInDays}getPriceStructure(){return this.internalState.currentProtocolVariables.priceStructure}toObject(){return this.internalState}getFeesCalculationVersion(){return this.internalState.currentProtocolVariables.feesCalculationVersion}setProtocolVersion(e){this.internalState.currentProtocolVariables.protocolVersion=e}setProtocolVersionName(e){this.internalState.currentProtocolVariables.protocolVersionName=e}setProtocolVariables(e){this.internalState.currentProtocolVariables=e}setOrganizationId(e){this.internalState.organizationId=e}},Dx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({accountId:k.getNullHash(),descriptionHeight:0})}toObject(){return this.internalState}getAccountIdAsBytes(){return this.internalState.accountId}getAccountId(){return Sx.from(this.internalState.accountId)}setAccountId(e){return this.internalState.accountId=e}getDescriptionHeight(){return this.internalState.descriptionHeight}updateDescriptionHeight(e){this.internalState.descriptionHeight=e}},Ox=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({cometbftPublicKeyDeclarationHeight:0,lastKnownApprovalStatus:!1,organizationId:k.getNullHash(),rpcEndpointHeight:0})}toObject(){return this.internalState}getOrganizationId(){return Sx.from(this.internalState.organizationId)}getLastKnownApprovalStatus(){return this.internalState.lastKnownApprovalStatus}getCometbftPublicKeyDeclarationHeight(){return this.internalState.cometbftPublicKeyDeclarationHeight}getRpcEndpointHeight(){return this.internalState.rpcEndpointHeight}clone(){return structuredClone(this)}setApprovalStatus(e){this.internalState.lastKnownApprovalStatus=e}setCometbftPublicKeyDeclarationHeight(e){this.internalState.cometbftPublicKeyDeclarationHeight=e}setOrganizationId(e){this.internalState.organizationId=e}setRpcEndpointDeclarationHeight(e){this.internalState.rpcEndpointHeight=e}},kx=class{static createInternalStateFromObject(e,t){switch(e){case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:return Ex.createFromObject(t);case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:return xx.createFromObject(t);case V.APPLICATION_VIRTUAL_BLOCKCHAIN:return Cx.createFromObject(t);case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return wx.createFromObject(t);case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return Dx.createFromObject(t);case V.NODE_VIRTUAL_BLOCKCHAIN:return Ox.createFromObject(t);default:throw Error(`Unknown virtual blockchain type: ${e}`)}}},Ax=class{constructor(){}async updateState(e,t,n){let r=xx.createFromObject({...t.toObject()}),i=n.getAllSections();for(let e of i)switch(e.type){case O.ACCOUNT_PUBLIC_KEY:await this.publicKeyCallback(r,n,e);break;case O.ACCOUNT_TOKEN_ISSUANCE:await this.tokenIssuanceCallback(r,n,e);break;case O.ACCOUNT_CREATION:await this.creationCallback(r,n,e);break;case O.ACCOUNT_TRANSFER:await this.transferCallback(r,n,e);break;case O.ACCOUNT_VESTING_TRANSFER:await this.vestingTransferCallback(r,n,e);break;case O.ACCOUNT_ESCROW_TRANSFER:await this.escrowTransferCallback(r,n,e);break;case O.ACCOUNT_STAKE:await this.stakeCallback(r,n,e);break;case O.SIGNATURE:await this.signatureCallback(r,n,e);break}return r}async publicKeyCallback(e,t,n){e.updatePublicKeyHeight(t.getHeight()),e.updateSignatureScheme(n.schemeId)}async tokenIssuanceCallback(e,t,n){if(n.amount!=0x5af3107a4000)throw Error(`the amount of the initial token issuance is not the expected one`)}async creationCallback(e,t,n){}async transferCallback(e,t,n){}async vestingTransferCallback(e,t,n){if(n.cliffDurationDays<0)throw Error(`The cliff duration must be greater than or equal to 0`);if(n.vestingDurationDays<=0)throw Error(`The vesting duration must be greater than 0`);if(n.amount<=0)throw Error(`The amount must be greater than 0`)}async escrowTransferCallback(e,t,n){}async stakeCallback(e,t,n){}async signatureCallback(e,t,n){}},jx=class{updateState(e,t,n){let r=t.clone();for(let e of n.getAllSections())e.type===O.APP_CREATION&&r.setOrganizationId(e.organizationId),e.type===O.APP_DESCRIPTION&&r.setDescriptionHeight(n.getHeight());return r}},Mx={[O.SIGNATURE]:`SIGNATURE`,[O.ALLOWED_ADDITIONAL_WRITER]:`ALLOWED_ADDITIONAL_WRITER_CREATION`,[O.CUSTOM]:`CUSTOM`,[O.PROTOCOL_CREATION]:`PROTOCOL_CREATION`,[O.PROTOCOL_UPDATE]:`PROTOCOL_UPDATE`,[O.PROTOCOL_VARIABLES]:`PROTOCOL_VARIABLES`,[O.ACCOUNT_PUBLIC_KEY]:`ACCOUNT_PUBLIC_KEY`,[O.ACCOUNT_TOKEN_ISSUANCE]:`ACCOUNT_TOKEN_ISSUANCE`,[O.ACCOUNT_CREATION]:`ACCOUNT_CREATION`,[O.ACCOUNT_TRANSFER]:`ACCOUNT_TRANSFER`,[O.ACCOUNT_VESTING_TRANSFER]:`ACCOUNT_VESTING_TRANSFER`,[O.ACCOUNT_ESCROW_TRANSFER]:`ACCOUNT_ESCROW_TRANSFER`,[O.ACCOUNT_ESCROW_SETTLEMENT]:`ACCOUNT_ESCROW_SETTLEMENT`,[O.ACCOUNT_STAKE]:`ACCOUNT_STAKE`,[O.ACCOUNT_UNSTAKE]:`ACCOUNT_UNSTAKE`,[O.VN_CREATION]:`VN_CREATION`,[O.VN_COMETBFT_PUBLIC_KEY_DECLARATION]:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,[O.VN_RPC_ENDPOINT]:`VN_RPC_ENDPOINT`,[O.VN_APPROVAL]:`VN_APPROVAL`,[O.VN_SLASHING_CANCELLATION]:`VN_SLASHING_CANCELLATION`,[O.ORG_CREATION]:`ORG_CREATION`,[O.ORG_DESCRIPTION]:`ORG_DESCRIPTION`,[O.APP_CREATION]:`APP_CREATION`,[O.APP_DESCRIPTION]:`APP_DESCRIPTION`,[O.APP_LEDGER_ALLOWED_SIG_SCHEMES]:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,[O.APP_LEDGER_ALLOWED_PKE_SCHEMES]:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,[O.APP_LEDGER_CREATION]:`APP_LEDGER_CREATION`,[O.APP_LEDGER_ACTOR_CREATION]:`APP_LEDGER_ACTOR_CREATION`,[O.APP_LEDGER_CHANNEL_CREATION]:`APP_LEDGER_CHANNEL_CREATION`,[O.APP_LEDGER_SHARED_SECRET]:`APP_LEDGER_SHARED_SECRET`,[O.APP_LEDGER_CHANNEL_INVITATION]:`APP_LEDGER_CHANNEL_INVITATION`,[O.APP_LEDGER_ACTOR_SUBSCRIPTION]:`APP_LEDGER_ACTOR_SUBSCRIPTION`,[O.APP_LEDGER_PUBLIC_CHANNEL_DATA]:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,[O.APP_LEDGER_PRIVATE_CHANNEL_DATA]:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,[O.APP_LEDGER_AUTHOR]:`APP_LEDGER_AUTHOR`,[O.APP_LEDGER_ENDORSEMENT_REQUEST]:`APP_LEDGER_ENDORSEMENT_REQUEST`},Nx=class{static getSectionLabelFromSection(e){return this.getSectionLabelFromSectionType(e.type)}static getSectionLabelFromSectionType(e){return Mx[e]}},Px=class e{logger=ts.getInternalStateUpdaterLogger(e.name);async updateState(e,t,n){let r=t.clone(),i=n.getHeight();for(let a of n.getAllSections())r=await this.updateStateFromSection(e,t,a,i);return r}async updateStateFromSection(e,t,n,r){let i=t;switch(n.type){case O.APP_LEDGER_ALLOWED_SIG_SCHEMES:await this.allowedSignatureSchemesCallback(n,i);break;case O.APP_LEDGER_ALLOWED_PKE_SCHEMES:await this.allowedPkeSchemesCallback(n,i);break;case O.APP_LEDGER_CREATION:await this.declarationCallback(n,i);break;case O.APP_LEDGER_ACTOR_CREATION:await this.actorCreationCallback(n,i);break;case O.APP_LEDGER_ACTOR_SUBSCRIPTION:await this.actorSubscriptionCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_CREATION:await this.channelCreationCallback(n,i);break;case O.APP_LEDGER_SHARED_SECRET:await this.sharedSecretCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_INVITATION:await this.invitationCallback(r,n,i);break;case O.APP_LEDGER_PUBLIC_CHANNEL_DATA:await this.publicChannelDataCallback(n,i);break;case O.APP_LEDGER_PRIVATE_CHANNEL_DATA:await this.privateChannelDataCallback(n,i);break;case O.ALLOWED_ADDITIONAL_WRITER:i.addAdditionalWriter(n.allowedWriterAccountId);break;case O.SIGNATURE:await this.endorserSignatureCallback();break;default:ts.getLogger().warn(`Unhandled section ${Nx.getSectionLabelFromSection(n)}`)}return i}async allowedSignatureSchemesCallback(e,t){t.setAllowedSignatureSchemeIds(e.schemeIds)}async allowedPkeSchemesCallback(e,t){t.setAllowedPkeSchemeIds(e.schemeIds)}async declarationCallback(e,t){t.setApplicationId(e.applicationId)}async actorCreationCallback(e,t){let{id:n,name:r}=e,i=t.getNumberOfActors();if(n!=i)throw this.logger.error(`Actor creation failure: Invalid actor identifier found for actor ${r}: expected ${i}, got ${n}`),new re(n,t.getNumberOfActors());if(t.isActorDefinedByName(r))throw new ne(r);this.logger.info(`Creating actor ${r} with id ${n} `),t.createActor({name:r,subscribed:!1,signatureKeyHeight:0,pkeKeyHeight:0,sharedSecrets:[],invitations:[]})}async actorSubscriptionCallback(e,t,n){let r=n.getActorById(t.actorId);if(r===void 0)throw new ce(t.actorId);if(r.subscribed)throw new C(t.actorId);let i=t.signatureSchemeId,a=n.getAllowedSignatureSchemes(),o=a.length==0,s=a.includes(i);if(!o&&!s)throw new le(t.signatureSchemeId);let c=t.pkeSchemeId,l=n.getAllowedPkeSchemes(),u=l.length===0,d=l.includes(c);if(!u&&!d)throw new ue(t.pkeSchemeId);r.subscribed=!0,r.signatureKeyHeight=e,r.pkeKeyHeight=e}async channelCreationCallback(e,t){if(e.id!=t.getNumberOfChannels())throw new de(e.id);let n=e.name;if(t.isChannelDefinedByName(n))throw new ie(n);t.createChannel({name:e.name,isPrivate:e.isPrivate,creatorId:e.creatorId})}async sharedSecretCallback(e,t,n){let{hostId:r,guestId:i}=t;n.getActorById(r).sharedSecrets.push({height:e,peerActorId:i}),n.getActorById(i).sharedSecrets.push({height:e,peerActorId:r})}async invitationCallback(e,t,n){let{guestId:r,channelId:i}=t;n.getActorById(r).invitations.push({channelId:i,height:e}),ts.getLogger().debug(`Updated state after channel invitation callback: {state}`,{state:n})}async publicChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new oe(`invalid channel ID ${e.channelId}`)}async privateChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new oe(`invalid channel ID ${e.channelId}`)}async endorserSignatureCallback(){}},Fx=class{updateState(e,t,n){let r=t;for(let e of n.getAllSections())switch(e.type){case O.VN_CREATION:r.setOrganizationId(e.organizationId);break;case O.VN_APPROVAL:this.updateApproval(r,e);break;case O.VN_COMETBFT_PUBLIC_KEY_DECLARATION:r.setCometbftPublicKeyDeclarationHeight(n.getHeight());break;case O.VN_RPC_ENDPOINT:r.setRpcEndpointDeclarationHeight(n.getHeight());break}return r}updateApproval(e,t){e.setApprovalStatus(t.status)}},Ix=class e{logger=ts.getInternalStateUpdaterLogger(e.name);updateState(e,t,n){for(let e of n.getAllSections()){if(e.type===O.PROTOCOL_UPDATE){let n=e;this.logger.debug(`Updating protocol variables: ${JSON.stringify(n.protocolVariables)}`),t.setProtocolVariables(n.protocolVariables)}if(e.type===O.PROTOCOL_CREATION){let n=e.organizationId;this.logger.debug(`Updating organization ID: ${k.binaryToHexa(n)}`),t.setOrganizationId(n)}}return t}},Lx=class{updateState(e,t,n){for(let e of n.getAllSections())e.type===O.ORG_CREATION&&t.setAccountId(e.accountId),e.type===O.ORG_DESCRIPTION&&t.updateDescriptionHeight(n.getHeight());return t}},Rx=class{static createApplicationLedgerInternalStateUpdater(e){return new Px}static createAccountInternalStateUpdater(e){switch(e){case 1:return new Ax;default:throw new i(`Unknown account local state version`)}}static createOrganizationInternalStateUpdater(e){switch(e){case 1:return new Lx;default:throw new i(`Unknown organization local state version`)}}static createProtocolInternalStateUpdater(e){return new Ix}static createValidatorNodeInternalStateUpdater(e){switch(e){case 1:return new Fx;default:throw new i(`Unknown validator node local state version`)}}static createApplicationInternalStateUpdater(e){switch(e){case 1:return new jx;default:throw new i(`Unknown validator node local state version`)}}static defaultInternalStateUpdaterVersionByVbType(e){return 1}},zx=function(e){return e[e.VALID=0]=`VALID`,e[e.TOO_FAR_IN_THE_PAST=1]=`TOO_FAR_IN_THE_PAST`,e[e.TOO_FAR_IN_THE_FUTURE=2]=`TOO_FAR_IN_THE_FUTURE`,e}({}),Bx=F({header:Nm,body:Sh}),Vx=class e{static createGenesisMicroblock(t,n=0){let r=new e(t);return r.create(1,null,n),r}static createMicroblock(t,n,r,i){let a=new e(t);return a.create(n,r,i),a}static createGenesisAccountMicroblock(){return new e(V.ACCOUNT_VIRTUAL_BLOCKCHAIN)}static createGenesisValidatorNodeMicroblock(){return new e(V.NODE_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationMicroblock(){return new e(V.APPLICATION_VIRTUAL_BLOCKCHAIN)}static createGenesisProtocolMicroblock(){return new e(V.PROTOCOL_VIRTUAL_BLOCKCHAIN)}static createGenesisOrganizationMicroblock(){return new e(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationLedgerMicroblock(){return new e(V.APPLICATION_VIRTUAL_BLOCKCHAIN)}static loadFromSerializedMicroblock(t,n){let r=L(Bx,Mb(t));return e.loadFromHeaderAndBody(r.header,r.body,n)}static loadFromHeaderAndBody(t,n,r){let i=t.microblockType;if(r!==void 0&&r!==i)throw new o(`Microblock type mismatch: expected ${r}, got ${i} from header`);if(t.magicString!=`CMTS`)throw Error(`magic string '${Hn}' is missing`);let a=t.bodyHash,s=new e(i);s.header=structuredClone(t),s.addSections(n.sections);let c=s.computeBodyHash();if(!k.binaryIsEqual(a,c)){let e=fg.bytesToHexEncoder();throw new o(`Body hash in the header is different of the locally computed body hash: header.bodyHash=${e.encode(a)}, computed=${e.encode(c)}`)}return s.setMicroblockHash(s.computeHash()),s}static loadFromSerializedHeaderAndBody(t,n,r){let i=Y.decodeMicroblockHeader(t),a=Y.decodeMicroblockBody(n);return e.loadFromHeaderAndBody(i,a,r)}static computeInitialBodyHash(){return e.computeBodyHashFromSections([])}static computeMicroblockHash(e){let t=Y.encodeMicroblockHeader(e);return j.Hashes.sha256AsBinary(t)}static computeBodyHashFromSections(e){let t={sections:e},n=Y.encodeMicroblockBody(t);return j.Hashes.sha256AsBinary(n)}static generatePreviousHashForGenesisMicroblock(e,t=0){let n=j.Random.getBytes(24),r=k.getNullHash();return r[0]=e,r[1]=t>>24,r[2]=t>>16,r[3]=t>>8,r[4]=t,r.set(n,8),r}static logger=ts.getMicroblockLogger();hash;header;sections;type;constructor(t){let n=Math.floor(Date.now()/1e3),r=mn.zero().getAmountAsAtomic(),i={magicString:Hn,protocolVersion:1,microblockType:t,height:1,previousHash:e.generatePreviousHashForGenesisMicroblock(t,0),timestamp:n,maxFees:0,gasPrice:r,bodyHash:e.computeInitialBodyHash(),feesPayerAccount:k.getNullHash()};this.type=t,this.sections=[],this.header=i,this.hash=e.computeMicroblockHash(i)}create(t,n,r){if(t==1)n=e.generatePreviousHashForGenesisMicroblock(this.type,r);else if(n===null)throw Error(`previous hash not provided`);this.header={magicString:Hn,protocolVersion:1,microblockType:this.type,height:t,previousHash:n,timestamp:k.getTimestampInSeconds(),maxFees:0,gasPrice:0,bodyHash:k.getNullHash(),feesPayerAccount:k.getNullHash()},this.hash=e.computeMicroblockHash(this.header)}isSigned(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}updateTimestamp(){this.header.timestamp=k.getTimestampInSeconds(),this.hash=e.computeMicroblockHash(this.header)}getHeader(){return this.header}getHash(){return Sx.from(this.hash)}getHashAsBytes(){return this.hash}getTimestampAsDate(){return new Date(this.header.timestamp*1e3)}getHeight(){return this.header.height}getPreviousHash(){return Sx.from(this.header.previousHash)}getTimestamp(){return this.header.timestamp}getGas(){return this.getMaxFees()}getMaxFees(){return mn.createAtomic(this.header.maxFees)}setMaxFees(t){this.header.maxFees=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}setGas(e){this.setMaxFees(e)}setHeight(t){this.header.height=t,this.hash=e.computeMicroblockHash(this.header)}setGasPrice(t){this.header.gasPrice=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}getGasPrice(){return mn.createAtomic(this.header.gasPrice)}isFeesPayerAccountDefined(){return k.binaryIsEqual(this.getFeesPayerAccount(),k.getNullHash())==0}getFeesPayerAccount(){return this.header.feesPayerAccount}setTimestamp(t){this.header.timestamp=t,this.hash=e.computeMicroblockHash(this.header)}setFeesPayerAccount(t){this.header.feesPayerAccount=t,this.hash=e.computeMicroblockHash(this.header)}computeBodyHash(){return e.computeBodyHashFromSections(this.sections)}serializeHeader(){return Y.encodeMicroblockHeader(this.header)}serializedBody(){return Y.encodeMicroblockBody({sections:this.sections})}serialize(){let t=this.serializedBody(),n=this.header.bodyHash,r=this.serializeHeader();return{microblockHash:e.computeMicroblockHash(this.header),headerData:r,bodyHash:n,bodyData:t,microblockData:lx(L(Bx,{header:this.header,body:{sections:this.sections}}))}}getSection(e){let t=this.sections.find(t=>e(t));if(t===void 0)throw new Te;return t}getNumberOfSections(){return this.sections.length}getSections(e){return this.sections.filter(t=>e(t))}getSectionsByType(e){return this.getSections(t=>t.type===e)}getAllSections(){return this.sections}async seal(e,t={}){let n=t.feesPayerAccount;n&&this.setFeesPayerAccount(n);let r=typeof t.includeGas==`boolean`?t.includeGas:!0,i=await this.sign(e,r),a={type:O.SIGNATURE,signature:i,schemeId:e.getSignatureSchemeId()};this.addSection(a)}async sign(t,n=!0){let r=this.sections,i=e.computeBodyHashFromSections(r),a={...this.header,maxFees:n?this.header.maxFees:0,gasPrice:n?this.header.gasPrice:0,bodyHash:i},o=Y.encodeMicroblockHeader(a);return await t.sign(o)}async verify(t,n={includeGas:!0,verifiedSignatureIndex:`last`}){let r=typeof n.includeGas==`boolean`?n.includeGas:!0,o=this.getNumberOfSignatures();if(o===0)throw new a(`Microblock verification failure: The current microblock is not signed`);let s=n.verifiedSignatureIndex,c=o;if(typeof s==`number`){if(s<=0)throw new i(`verifiedSignatureIndex must be positive`);if(o<s)throw new i(`Invalid provided signature index ${s}: this microblock contains ${o} signatures`);c=s}else if(!(s===`last`||s===void 0))throw new i(`Unknown signature index: ${s} (type ${typeof s})`);let{signatureSection:l,sectionIndexInMicroblock:u}=this.getNthSignatureSectionAndIndexInMicroblock(c),d=this.sections.slice(0,u),f={...this.header,maxFees:r?this.header.maxFees:0,gasPrice:r?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(d)},p=Y.encodeMicroblockHeader(f),m=l.signature;return await t.verify(p,m)}getNthSignatureSectionAndIndexInMicroblock(e){if(e<=0)throw new i(`Cannot return the ${e}-th signature: should be strictly positive`);let t=this.sections.map((e,t)=>({section:e,index:t})).filter(({section:e,index:t})=>e.type===O.SIGNATURE);if(t.length<e)throw new i(`Cannot return the ${e}-th signature: only ${t.length} signature (index starting at 1)`);let n=t[e-1];if(n.section.type!==O.SIGNATURE)throw Error(`Returned section is not a signature section`);return{signatureSection:n.section,sectionIndexInMicroblock:n.index}}getNumberOfSignatures(){return this.sections.filter(e=>e.type===O.SIGNATURE).length}isLastSectionSignature(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}isTemporallyCloseTo(e=k.getTimestampInSeconds()){return this.header.timestamp<e-300?zx.TOO_FAR_IN_THE_PAST:this.header.timestamp>e+120?zx.TOO_FAR_IN_THE_FUTURE:zx.VALID}hasSection(e){try{return this.getSectionByType(e),!0}catch(e){if(e instanceof Te)return!1;throw e}}containsOnlyTheseSections(e){return this.sections.every(t=>e.includes(t.type))}getIndexOfSection(e){return this.sections.findIndex(t=>t.type===e)}setAsSuccessorOf(t){let n=this.getType(),r=t.getType();if(n!==r)throw new i(`Cannot make this microblock the successor: expected microblock of type ${n}, got ${r}`);let a=t.getHash();this.setPreviousHash(a),this.setHeight(t.getHeight()+1),this.hash=e.computeMicroblockHash(this.header),e.logger.info(`Microblock ${k.binaryToHexa(this.hash)} updated as successor of microblock ${a.encode()}`)}countSectionsByType(e){return this.sections.filter(t=>t.type===e).length}addSections(t){e.logger.debug(`Adding sections to microblock: {names}`,()=>({names:t.map(e=>Nx.getSectionLabelFromSection(e)).join(`, `)})),this.sections.push(...t),this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header)}addSection(e){this.addSections([e])}popSection(){let t=this.sections.pop();if(this.getNumberOfSections()==0||t===void 0)throw new a(`Cannot pop section from empty microblock`);return this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header),t}getSectionByType(e){let t=this.sections.find(t=>t.type===e);if(t===void 0)throw new Te;return t}toString(){let e=fg.bytesToHexEncoder(),t=`Microblock:
|
|
7
7
|
`;return t+=` Hash: ${e.encode(this.hash)}\n`,t+=` Recomputed hash: ${e.encode(this.computeHash())}\n`,t+=` Header:
|
|
8
|
-
`,t+=` Microblock type: ${this.header.microblockType} or ${this.type}\n`,t+=` Magic String: ${this.header.magicString}\n`,t+=` Protocol Version: ${this.header.protocolVersion}\n`,t+=` Fees payer account: ${e.encode(this.header.feesPayerAccount)}\n`,t+=` Height: ${this.header.height}\n`,t+=` Previous Hash: ${e.encode(this.header.previousHash)}\n`,t+=` Timestamp: ${this.header.timestamp}\n`,t+=` Max fees: ${this.header.maxFees}\n`,t+=` Gas Price: ${this.header.gasPrice}\n`,t+=` Body Hash: ${e.encode(this.header.bodyHash)}\n`,t+=` Computed body Hash: ${e.encode(this.computeBodyHash())}\n`,t+=` Sections (${this.sections.length}):\n`,this.sections.forEach((e,n)=>{t+=` Section ${n}:\n`,t+=` Section Type: ${Px.getSectionLabelFromSection(e)} (type ${e.type})\n`,t+=` Section Data: ${k.binaryToHexa(Y.encodeSection(e))}\n`}),t}getType(){return this.type}setPreviousHash(e){this.header.previousHash=e.toBytes()}static extractTypeFromGenesisPreviousHash(e){return e[0]}static extractExpirationDayFromGenesisPreviousHash(e){return e[1]<<24|e[2]<<16|e[3]<<8|e[4]}getBodyHashInHeader(){return this.header.bodyHash}isDeclaringConsistentBodyHash(){let e=this.computeBodyHash();return k.binaryIsEqual(e,this.header.bodyHash)}isGenesisMicroblock(){return this.getHeight()===1}setBodyHash(e){this.header.bodyHash=e}computeHash(){let{microblockHash:e}=this.serialize();return e}setMicroblockHash(e){this.hash=e}getLastSignatureSection(){let e=this.sections[this.sections.length-1];if(e.type!==O.SIGNATURE)throw Error(`Last section is not a signature section`);return e}},Ux=class{onMicroblockSearchFailureForExceedingHeight(e,t){throw e.isEmpty()?new x(Cx.from(k.getNullHash()),t):new x(e.getIdentifier(),t)}},Wx=class e{static INITIAL_HEIGHT=1;static staticLogger=ts.getVirtualBlockchainLogger();logger=e.staticLogger;internalState;height;identifier;microblockHashByHeight;microblockByHeight;provider;type;expirationDay;microblockSearchFailureFallback;onMicroblockInsertionEventListeners=[];constructor(e,t,n){this.internalState=n,this.provider=e,this.microblockHashByHeight=new Map,this.microblockByHeight=new Map,this.type=t,this.expirationDay=0,this.height=0,this.microblockSearchFailureFallback=new Ux}async isAccountIdAllowedToWrite(e){if(this.height===0)return!0;let t=await this.getVirtualBlockchainOwnerId();return k.binaryIsEqual(t.toBytes(),e.toBytes())}getProvider(){return this.provider}addOnMicroblockInsertionEventListener(e){this.onMicroblockInsertionEventListeners.push(e)}getInternalState(){return this.internalState}setInternalState(e){this.internalState=e}async createMicroblock(){if(this.isEmpty())return new Hx(this.type);let e=await this.getLastMicroblock(),t=new Hx(this.type);return t.setPreviousHash(e.getHash()),t.setHeight(this.getHeight()+1),t}getLastMicroblock(){return this.getMicroblock(this.getHeight())}setHeight(e){this.height=e}setIdentifier(e){this.logger.debug(`Updating virtual blockchain identifier to ${k.binaryToHexa(e)}`),this.identifier=e}setMicroblockHashes(e){let t=1;for(let n of e)this.microblockHashByHeight.set(t,n),t++}setExpirationDay(e){this.expirationDay=e}async getSerializedVirtualBlockchainState(){return Y.encodeVirtualBlockchainState(await this.getVirtualBlockchainState())}async getGenesisSeed(){return(await this.getFirstMicroBlock()).getPreviousHash()}getHeight(){return this.height}getId(){return this.identifier}isVirtualBlockchainIdDefined(){return this.identifier instanceof Uint8Array}async getFirstMicroBlock(){return this.getMicroblock(1)}getAllMicroblockHashes(){let e=[];for(let t of this.microblockHashByHeight.entries())e.push(Cx.from(t[1]));return e}async getMicroblock(e){this.logger.debug(`Accessing microblock at height ${e} of vb`);for(let e of this.microblockHashByHeight.entries())this.logger.debug(`\t- Height ${e[0]}: ${k.binaryToHexa(e[1])}`);if(e<1)throw new i(`Cannot retrieve microblock at height strictly lower than 1: got ${e}`);if(this.getHeight()<e)return await this.microblockSearchFailureFallback.onMicroblockSearchFailureForExceedingHeight(this,e);let t=this.microblockByHeight.get(e);if(t!==void 0)return t;let n=this.microblockHashByHeight.get(e);if(n===void 0)throw new x(this.getIdentifier(),e);let r=await this.provider.getMicroblockHeader(Cx.from(n));if(r===null){let t=fg.bytesToHexEncoder();throw Error(`Unable to load microblock information from hash ${t.encode(n)} (height ${e})`)}let a=await this.provider.getMicroblockBody(Cx.from(n));if(a===null)throw Error(`Unable to load the microblock body`);let o=Hx.loadFromHeaderAndBody(r,a,this.type);if(o.getHeight()!==e)throw Error(`Received microblock contains an unexpected height: expected ${e}, defined ${o.getHeight()} `);if(!k.binaryIsEqual(o.getHash().toBytes(),n)){let e=`Mismatch between microblock hash ${o.getHash().encode()} and expected hash ${k.binaryToHexa(n)}`;throw this.logger.error(o.toString()),Error(e)}this.microblockByHeight.set(e,o);for(let e of this.onMicroblockInsertionEventListeners)e.onMicroblockInserted(this,o);return o}getIdentifier(){if(this.identifier===void 0)throw new a(`You cannot access identifier of an empty virtual blockchain (current height is ${this.height})`);return Cx.from(this.identifier)}isEmpty(){return this.getHeight()===0}async appendMicroBlock(e){if(this.isEmpty()&&this.identifier instanceof Uint8Array)throw Error(`Virtual blockchain is empty but is initialized: should not happen`);if(!this.isEmpty()&&!(this.identifier instanceof Uint8Array))throw Error(`Virtual blockchain is empty but has an identifier: should not happen`);let t=this.height+1,n=e.getHeight();if(t!==n)throw Error(`Microblock height mismatch: expected ${t} but got ${n}`);if(!this.isEmpty()){let t=(await this.getLastMicroblock()).getHash().toBytes(),n=e.getPreviousHash().toBytes();if(!k.binaryIsEqual(n,t))throw Error(`Previous hash mismatch: microblock's previous hash ${k.binaryToHexa(n)} does not match the last microblock's hash ${k.binaryToHexa(t)}`)}if(!this.checkMicroblockStructure(e))throw new i(`Provided microblock has an invalid structure`);let r=await this.provider.getProtocolState();this.internalState=await this.updateInternalState(r,this.internalState,e),this.identifier===void 0&&(this.identifier=e.getHash().toBytes()),this.height+=1;let a=e.getHash().toBytes();this.microblockHashByHeight.set(this.height,a),this.microblockByHeight.set(this.height,e),this.logger.debug(`Microblock ${k.binaryToHexa(a)} added to vb (now at height ${this.height} `)}setMicroblockSearchFailureFallback(e){this.microblockSearchFailureFallback=e}getType(){return this.type}getExpirationDay(){return this.expirationDay}},X;(function(e){e[e.ANY=0]=`ANY`,e[e.ZERO=1]=`ZERO`,e[e.ONE=2]=`ONE`,e[e.AT_MOST_ONE=3]=`AT_MOST_ONE`,e[e.AT_LEAST_ONE=4]=`AT_LEAST_ONE`})(X||={});var Gx={[X.ANY]:`Any`,[X.ONE]:`Exactly one`,[X.ZERO]:`Exactly zero`,[X.AT_LEAST_ONE]:`At least one`,[X.AT_MOST_ONE]:`At most one`},Kx=class{microblock;pointer;constructor(e){this.microblock=e,this.pointer=0}isFirstBlock(){return this.microblock.getHeight()==1}expects(e,t){let n=0;for(;!this.endOfList()&&this.currentSection().type==t;)n++,this.pointer++;if(!this.checkConstraint(e,n))throw new s(`expected ${Gx[e]} of type ${this.getSectionLabelBySectionType(t)}, got ${n}`)}group(e,t){let n=new Map,r=0;for(let[e,r]of t)n.set(r,0);for(;!this.endOfList();){let e=this.currentSection().type;if(!t.some(([t,n])=>n==e))break;n.set(e,n.get(e)+1),r++,this.pointer++}if(!this.checkConstraint(e,r))throw new s(`expected ${Gx[e]} in group, got ${r}`);for(let[e,r]of t){let t=n.get(r);if(!this.checkConstraint(e,t))throw new s(`expected ${Gx[e]} of type ${this.getSectionLabelBySectionType(r)}, got ${t}`)}}endsHere(){if(!this.endOfList()){let e=this.currentSection().type;throw new s(`Unexpected section ${this.getSectionLabelBySectionType(e)}`)}}currentSection(){return this.microblock.getAllSections()[this.pointer]}endOfList(){return!this.currentSection()}checkConstraint(e,t){switch(e){case X.ANY:return!0;case X.ZERO:return t==0;case X.ONE:return t==1;case X.AT_LEAST_ONE:return t>=1;case X.AT_MOST_ONE:return t<=1}return!1}getSectionLabelBySectionType(e){return Px.getSectionLabelFromSectionType(e)}},qx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.ORG_CREATION),t.group(X.AT_MOST_ONE,[[X.ONE,O.ORG_DESCRIPTION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},Jx=class e extends Wx{static createOrganizationVirtualBlockchain(t){return new e(t)}constructor(e,t=Ox.createInitialState()){super(e,V.ORGANIZATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getOrganizationInternalStateUpdaterVersion();return zx.createOrganizationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){return this.internalState.getAccountId()}checkMicroblockStructure(e){return new qx().checkMicroblockStructure(e)}getAccountId(){return this.internalState.getAccountId()}async getDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.ORG_DESCRIPTION)return e;throw new a(`No description found for the organization`)}},Yx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.AT_MOST_ONE,O.ACCOUNT_PUBLIC_KEY),t.isFirstBlock()?t.group(X.ONE,[[X.AT_MOST_ONE,O.ACCOUNT_TOKEN_ISSUANCE],[X.AT_MOST_ONE,O.ACCOUNT_CREATION]]):t.group(X.AT_LEAST_ONE,[[X.ANY,O.ACCOUNT_TRANSFER],[X.ANY,O.ACCOUNT_VESTING_TRANSFER],[X.ANY,O.ACCOUNT_STAKE],[X.ANY,O.ACCOUNT_UNSTAKE],[X.ANY,_a],[X.ANY,O.ACCOUNT_ESCROW_SETTLEMENT]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},Xx=class extends Wx{constructor(e,t=Sx.createInitialState()){super(e,V.ACCOUNT_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getAccountInternalStateUpdaterVersion();return zx.createAccountInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){return Cx.from(this.getId())}checkMicroblockStructure(e){return new Yx().checkMicroblockStructure(e)}async getPublicKey(){let e=this.internalState.getPublicKeyHeight(),t=this.internalState.getPublicKeySchemeId(),n=await this.getMicroblock(e);for(let e of n.getAllSections())if(e.type===O.ACCOUNT_PUBLIC_KEY)return new Bv().createPublicSignatureKey(t,e.publicKey);throw new a(`Account public key not found`)}async isIssuer(){let e=await this.getFirstMicroBlock();for(let t of e.getAllSections())if(t.type===O.ACCOUNT_TOKEN_ISSUANCE)return!0;return!1}static async createAccountCreationMicroblock(e,t,n,r=``){let i=Hx.createGenesisAccountMicroblock();return i.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await e.getPublicKeyAsBytes(),schemeId:e.getSignatureSchemeId()}),i.addSection({type:O.ACCOUNT_CREATION,amount:t.getAmountAsAtomic(),sellerAccount:n}),i}static async createIssuerAccountCreationMicroblock(e){let t=e,n=Hx.createGenesisAccountMicroblock();return n.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await t.getPublicKeyAsBytes(),schemeId:t.getSignatureSchemeId()}),n.addSection({type:O.ACCOUNT_TOKEN_ISSUANCE,amount:cr}),n}},Zx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.APP_CREATION),t.group(X.AT_LEAST_ONE,[[X.AT_MOST_ONE,O.APP_DESCRIPTION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},Qx=class extends Wx{constructor(e,t=wx.createInitialState()){super(e,V.APPLICATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getApplicationInternalStateUpdaterVersion();return zx.createApplicationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}checkMicroblockStructure(e){return new Zx().checkMicroblockStructure(e)}getOrganizationId(){return this.internalState.getOrganizationId()}async getApplicationDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type==O.APP_DESCRIPTION)return e;throw Error(`Application description not found`)}},$x=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.VN_CREATION),t.group(X.AT_LEAST_ONE,t.isFirstBlock()?[[X.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[X.AT_MOST_ONE,O.VN_RPC_ENDPOINT]]:[[X.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[X.AT_MOST_ONE,O.VN_RPC_ENDPOINT],[X.AT_MOST_ONE,O.VN_APPROVAL],[X.AT_MOST_ONE,O.VN_SLASHING_CANCELLATION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},eS=class extends Wx{constructor(e,t=kx.createInitialState()){super(e,V.NODE_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getValidatorNodeInternalStateUpdaterVersion();return zx.createValidatorNodeInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){return this.internalState.getOrganizationId()}checkMicroblockStructure(e){return new $x().checkMicroblockStructure(e)}async getCometbftPublicKeyDeclaration(){let e=this.internalState.getCometbftPublicKeyDeclarationHeight();if(e===0)throw new a(`Node has not declared its CometBFT public key yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections()){if(e.type!==O.VN_COMETBFT_PUBLIC_KEY_DECLARATION)continue;let t=e.cometPublicKey;return{cometbftPublicKeyType:e.cometPublicKeyType,cometbftPublicKey:t}}throw new a(`Node has not declared its CometBFT public key yet`)}async getRpcEndpointDeclaration(){let e=this.internalState.getRpcEndpointHeight();if(e===0)throw new a(`Node has not declared its RPC endpoint yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.VN_RPC_ENDPOINT)return e.rpcEndpoint;throw new a(`Node has not declared its RPC endpoint yet`)}getNodeDeclarationHeight(){return this.getInternalState().getCometbftPublicKeyDeclarationHeight()}async getOrganizationVirtualBlockchain(){let e=this.internalState.getOrganizationId();return await this.provider.loadOrganizationVirtualBlockchain(e)}},tS=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.PROTOCOL_CREATION),t.isFirstBlock()||t.group(X.AT_MOST_ONE,[[X.ONE,O.PROTOCOL_UPDATE]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},nS=class extends Wx{constructor(e,t=Dx.createInitialState()){super(e,V.PROTOCOL_VIRTUAL_BLOCKCHAIN,t)}checkMicroblockStructure(e){return new tS().checkMicroblockStructure(e)}async updateInternalState(e,t,n){let r=e.getProtocolInternalStateUpdaterVersion();return zx.createProtocolInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){let e=(await this.getFirstMicroBlock()).getAllSections();for(let t of e)if(t.type===O.PROTOCOL_CREATION)return Cx.from(t.organizationId);throw Error(`Organization ID not found in protocol vb`)}},rS=class{static assert(e,t=`Unspecified verification`){if(!e)throw new m(`Assertion failed: ${t}`)}},iS=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Kx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.APP_LEDGER_CREATION),t.group(X.ANY,[[X.ANY,O.APP_LEDGER_ACTOR_CREATION],[X.ANY,O.APP_LEDGER_ACTOR_SUBSCRIPTION],[X.ANY,O.APP_LEDGER_ENDORSEMENT_REQUEST],[X.ANY,O.APP_LEDGER_AUTHOR],[X.ANY,O.APP_LEDGER_PUBLIC_CHANNEL_DATA],[X.ANY,O.APP_LEDGER_PRIVATE_CHANNEL_DATA],[X.ANY,O.APP_LEDGER_SHARED_SECRET],[X.ANY,O.APP_LEDGER_CHANNEL_CREATION],[X.ANY,O.APP_LEDGER_CHANNEL_INVITATION],[X.ANY,O.ALLOWED_ADDITIONAL_WRITER]]),t.expects(X.AT_LEAST_ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},aS=class e{identifier;microblocks;constructor(){this.identifier=``,this.microblocks=[]}static fromObject(t){let n=new e;n.setIdentifier(t.id);for(let e of t.microblocks)n.addMicroblock(e.height,e.channels);return n}toObject(){return{id:this.identifier,microblocks:this.microblocks}}setIdentifier(e){this.identifier=e}getIdentifier(){return this.identifier}addMicroblock(e,t){let n={height:e,channels:t};this.microblocks.push(n)}getMicroblock(e){let t=this.microblocks.find(t=>t.height===e);if(!t)throw Error(`no microblock found for height ${e}`);return t}getMicroblocks(){return this.microblocks}},oS=Yp(()=>nm([I(),P(),Kp(),Xp(),M(oS),em(I(),oS)])),sS=M(nm([I(),P()])),cS;(function(e){e[e.None=0]=`None`,e[e.Hashable=1]=`Hashable`,e[e.Maskable=2]=`Maskable`})(cS||={});var lS=im(`type`,[F({type:N(cS.None)}),F({type:N(cS.Hashable)}),F({type:N(cS.Maskable),visibleParts:M(I()),hiddenParts:M(I())})]),uS;(function(e){e[e.String=0]=`String`,e[e.Number=1]=`Number`,e[e.Boolean=2]=`Boolean`,e[e.Null=3]=`Null`,e[e.Array=4]=`Array`,e[e.Object=5]=`Object`})(uS||={});var dS,fS={channelId:P()};dS=im(`type`,[F({...fS,type:N(uS.String),value:I(),transformation:lS}),F({...fS,type:N(uS.Number),value:P()}),F({...fS,type:N(uS.Boolean),value:Kp()}),F({...fS,type:N(uS.Null),value:Xp()}),F({type:N(uS.Array),value:M(Yp(()=>dS))}),F({type:N(uS.Object),value:M(F({key:I(),value:Yp(()=>dS)}))})]);var pS=nm([I(),P(),Kp(),Xp()]),mS=F({pepper:B(),data:B()}),hS=F({path:sS,value:pS,transformation:Qp(lS)}),gS=M(hS),Z;(function(e){e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableFromValue=2]=`HashableFromValue`,e[e.Hashable=3]=`Hashable`,e[e.MaskableFromAllParts=4]=`MaskableFromAllParts`,e[e.MaskableFromVisibleParts=5]=`MaskableFromVisibleParts`,e[e.Maskable=6]=`Maskable`})(Z||={}),Z.Public,Z.Plain,Z.HashableFromValue,Z.Hashable,Z.MaskableFromAllParts,Z.MaskableFromVisibleParts,Z.Maskable;var _S;(function(e){e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableAsPlain=2]=`HashableAsPlain`,e[e.HashableAsHash=3]=`HashableAsHash`,e[e.MaskableAsAllParts=4]=`MaskableAsAllParts`,e[e.MaskableAsVisibleParts=5]=`MaskableAsVisibleParts`})(_S||={});var vS=F({path:sS,type:N(_S.Public),value:pS}),yS={path:sS,index:P()},bS=im(`type`,[vS,F({...yS,type:N(_S.Plain),salt:I(),value:pS}),F({...yS,type:N(_S.HashableAsPlain),salt:I(),value:pS}),F({...yS,type:N(_S.HashableAsHash),salt:I(),hash:I()}),F({...yS,type:N(_S.MaskableAsAllParts),v_salt:I(),v_parts:M(I()),h_salt:I(),h_parts:M(I())}),F({...yS,type:N(_S.MaskableAsVisibleParts),v_salt:I(),v_parts:M(I()),h_hash:I()})]),xS=F({version:P(),info:F({title:I(),date:I(),description:I(),author:I()}),virtual_blockchains:M(F({id:I(),microblocks:M(F({height:P(),channels:M(F({id:P(),is_public:Kp(),n_leaves:P(),fields:M(bS),witnesses:M(I())}))}))})),signature:Qp(F({commitment:F({issued_at:Qp(I()),digest_alg:Qp($p([`sha256`])),digest_target:Qp($p([`cbor_proof`])),digest:Qp(I())}),signer:I(),pubkey:I(),alg:$p([`ecdsa-secp256k1`,`ml-dsa-65`]),sig:I()}))}),SS=1,CS=class e{encoder=new gx;wrapper;constructor(){this.wrapper={version:SS,info:{title:`Carmentis proof`,description:`This is a Carmentis proof file. Visit www.carmentis.io for more information.`,author:``,date:new Date().toISOString()},virtual_blockchains:[]}}static fromObject(t){L(xS,t);let n=new e;return n.wrapper=t,n}setTitle(e){this.wrapper.info.title=e}getTitle(){return this.wrapper.info.title}setDescription(e){this.wrapper.info.description=e}getDescription(){return this.wrapper.info.description}setAuthor(e){this.wrapper.info.author=e}getAuthor(){return this.wrapper.info.author}setDate(e){this.wrapper.info.date=e.toISOString()}getDate(){return new Date(this.wrapper.info.date)}addVirtualBlockchain(e){this.wrapper.virtual_blockchains.push(e.toObject())}getSingleVirtualBlockchainOrFail(){let e=this.getVirtualBlockchains();if(e.length==0)throw Error(`no virtual blockchain is defined in this proof`);if(e.length>1)throw Error(`proofs with multiple virtual blockchains are not supported at this time`);return e[0]}getVirtualBlockchain(e){let t=this.wrapper.virtual_blockchains.find(t=>t.id===e);if(!t)throw Error(`no virtual blockchain found with ID ${e}`);return t}getVirtualBlockchains(){return this.wrapper.virtual_blockchains.map(e=>aS.fromObject(e))}sign(e=new Date){let t=this.computeDigest(),n={issued_at:e.toISOString(),digest_alg:`sha256`,digest_target:`cbor_proof`,digest:k.binaryToHexa(t)},r=this.encoder.encode(n);j.Hashes.sha256AsBinary(r),this.wrapper.signature={commitment:n,signer:``,pubkey:``,alg:`ecdsa-secp256k1`,sig:``}}verifySignature(){this.computeDigest()}computeDigest(){let e={info:this.wrapper.info,virtual_blockchains:this.wrapper.virtual_blockchains},t=this.encoder.encode(e);return j.Hashes.sha256AsBinary(t)}getObject(){return this.wrapper}},wS=class{leaves;nLeaves;tree;constructor(){this.leaves=[],this.nLeaves=0,this.tree=[]}addLeaf(e){this.checkHash(e),this.leaves.push(e)}setLeaf(e,t){this.checkHash(t),this.leaves[e]=t}checkHash(e){if(e.length!=32)throw Error(`invalid hash: expected size is 32 bytes, got ${e.length}`)}finalize(e=void 0){this.nLeaves=e===void 0?this.leaves.length:e,this.buildTreeStructure()}getNumberOfLeaves(){return this.nLeaves}getRootHash(){let e=this.tree.length-1;for(let t=0;t<e;t++){let e=this.tree[t];for(let n=0;n<e.length;n+=2)e[n]&&e[n+1]&&(this.tree[t+1][n>>1]=this.mergeHashes(t+1,e[n],e[n+1]))}return this.tree[e][0]}getWitnesses(e){let t=new Set(e),n=this.getWitnessPositions(t),r=[];for(let e=0;e<this.tree[0].length;e++)if(!t.has(e)&&!this.tree[0][e])throw Error(`cannot find leaf at index ${e}`);for(let[e,t]of n){let n=this.tree[e][t];if(!n)throw Error(`cannot find witness hash at depth ${e}, index ${t}`);r.push(n)}return r}setWitnesses(e){let t=new Set;for(let e=0;e<this.nLeaves;e++)this.leaves[e]||t.add(e);let n=this.getWitnessPositions(t);if(e.length!=n.length)throw Error(`invalid witness list: expected ${n.length} witness(es), got ${e.length}`);let r=0;for(let[t,i]of n)this.checkHash(e[r]),this.tree[t][i]=e[r++]}buildTreeStructure(){let e=this.nLeaves;for(this.tree=[];e;){let t=Array(e).fill(null);e>1&&e&1&&(t.push(k.getNullHash()),e++),this.tree.push(t),e>>=1}for(let e=0;e<this.nLeaves;e++)this.leaves[e]&&(this.tree[0][e]=this.leaves[e])}getWitnessPositions(e){let t=this.nLeaves,n=[];for(let r=0;t;r++){let i=new Set;for(let a=0;a<t;a+=2){let o=e.has(a),s=a+1<t&&e.has(a+1);o&&s?i.add(a>>1):(o||s)&&n.push([r,s?a+1:a])}e=i,t=t+ +(t>1)>>1}return n}mergeHashes(e,t,n){let r=new Uint8Array(65);return r[0]=+(e==this.tree.length-1),r.set(t,1),r.set(n,33),j.Hashes.sha256AsBinary(r)}},TS=class e{internalData=void 0;encoder=new gx;static fromProofFormat(t){let n=new e;return n.fromProofField(t),n}static fromItemWithPublicData(t){let n=new e;return n.setPublicDataFromValue(t.value),n}static fromItemWithPlainData(t,n){let r=new e,i=t.getSalt();return r.setPlainDataFromValue(i,n.value),r}static fromItemWithHashedData(t,n){let r=new e,i=t.getSalt();return r.setHashedDataFromValue(i,n.value),r}static fromItemWithMaskedData(t,n){let r=new e,i=t.getSalt(),a=t.getSalt();return r.setMaskedDataFromAllParts(i,n.transformation.visibleParts,a,n.transformation.hiddenParts),r}setPublicDataFromValue(e){this.internalData={type:Z.Public,value:e}}setPlainDataFromValue(e,t){this.internalData={type:Z.Plain,salt:e,value:t}}setHashedDataFromValue(e,t){this.internalData={type:Z.HashableFromValue,salt:e,value:t}}setHashedDataFromHash(e,t){this.internalData={type:Z.Hashable,salt:e,hash:t}}setMaskedDataFromAllParts(e,t,n,r){let i={salt:e,parts:t},a={salt:n,parts:r};this.internalData={type:Z.MaskableFromAllParts,visible:i,hidden:a}}setMaskedDataFromVisibleParts(e,t,n){let r={salt:e,parts:t};this.internalData={type:Z.MaskableFromVisibleParts,visible:r,hiddenHash:n}}setToHashed(){let e=this.getInternalData();if(e.type==Z.Hashable)return;if(e.type!=Z.HashableFromValue)throw Error(`this field is not hashable`);let t=this.encoder.encode(e.value),n=j.Hashes.sha256AsBinary(t);this.setHashedDataFromHash(e.salt,n)}setToMasked(){let e=this.getInternalData();if(e.type==Z.MaskableFromVisibleParts)return;if(e.type!=Z.MaskableFromAllParts)throw Error(`this field is not maskable`);let t=this.encoder.encode(e.hidden),n=j.Hashes.sha256AsBinary(t);this.setMaskedDataFromVisibleParts(e.visible.salt,e.visible.parts,n)}getInternalData(){if(this.internalData===void 0)throw Error(`internal leaf data has not been set`);return this.internalData}fromProofField(e){switch(e.type){case _S.Public:this.setPublicDataFromValue(e.value);break;case _S.Plain:this.setPlainDataFromValue(k.binaryFromHexa(e.salt),e.value);break;case _S.HashableAsPlain:this.setHashedDataFromValue(k.binaryFromHexa(e.salt),e.value);break;case _S.HashableAsHash:this.setHashedDataFromHash(k.binaryFromHexa(e.salt),k.binaryFromHexa(e.hash));break;case _S.MaskableAsAllParts:this.setMaskedDataFromAllParts(k.binaryFromHexa(e.v_salt),e.v_parts,k.binaryFromHexa(e.h_salt),e.h_parts);break;case _S.MaskableAsVisibleParts:this.setMaskedDataFromVisibleParts(k.binaryFromHexa(e.v_salt),e.v_parts,k.binaryFromHexa(e.h_hash));break}}toProofFormat(e,t){let n=this.getInternalData();switch(n.type){case Z.Public:return{path:e,type:_S.Public,value:n.value};case Z.Plain:return{path:e,index:t,type:_S.Plain,salt:k.binaryToHexa(n.salt),value:n.value};case Z.HashableFromValue:return{path:e,index:t,type:_S.HashableAsPlain,salt:k.binaryToHexa(n.salt),value:n.value};case Z.Hashable:return{path:e,index:t,type:_S.HashableAsHash,salt:k.binaryToHexa(n.salt),hash:k.binaryToHexa(n.hash)};case Z.MaskableFromAllParts:return{path:e,index:t,type:_S.MaskableAsAllParts,v_salt:k.binaryToHexa(n.visible.salt),v_parts:n.visible.parts,h_salt:k.binaryToHexa(n.hidden.salt),h_parts:n.hidden.parts};case Z.MaskableFromVisibleParts:return{path:e,index:t,type:_S.MaskableAsVisibleParts,v_salt:k.binaryToHexa(n.visible.salt),v_parts:n.visible.parts,h_hash:k.binaryToHexa(n.hiddenHash)};default:throw Error(`invalid internal data type ${n.type}`)}}getCommitmentData(){let e=this.getInternalData();switch(e.type){case Z.Public:case Z.Plain:case Z.Hashable:return e;case Z.HashableFromValue:{let t=this.encoder.encode(e.value),n=j.Hashes.sha256AsBinary(t);return{type:Z.Hashable,salt:e.salt,hash:n}}case Z.MaskableFromAllParts:{let t=this.encoder.encode(e.visible),n=j.Hashes.sha256AsBinary(t),r=this.encoder.encode(e.hidden),i=j.Hashes.sha256AsBinary(r);return{type:Z.Maskable,visibleHash:n,hiddenHash:i}}case Z.MaskableFromVisibleParts:{let t=this.encoder.encode(e.visible),n=j.Hashes.sha256AsBinary(t);return{type:Z.Maskable,visibleHash:n,hiddenHash:e.hiddenHash}}default:throw Error(`invalid internal data type ${e.type}`)}}getHash(){let e=this.getCommitmentData(),t=this.encoder.encode(e);return j.Hashes.sha256AsBinary(t)}getRawValue(){let e=this.getInternalData();switch(e.type){case Z.Public:case Z.Plain:case Z.HashableFromValue:return e.value;case Z.Hashable:return k.binaryToHexa(e.hash);case Z.MaskableFromAllParts:return e.visible.parts.map((t,n)=>n&1?e.hidden.parts[n>>1]:t).join(``);case Z.MaskableFromVisibleParts:return e.visible.parts.join(``);default:throw Error(`invalid internal data type ${e.type}`)}}getTypedValue(){let e=this.getInternalData(),t=this.getRawValue();switch(e.type){case Z.Public:case Z.Plain:case Z.HashableFromValue:case Z.MaskableFromAllParts:return{disclosure:`plain`,value:t};case Z.Hashable:return{disclosure:`hashed`,value:t};case Z.MaskableFromVisibleParts:return{disclosure:`masked`,value:t};default:throw Error(`invalid internal data type ${e.type}`)}}},ES=class e{channelMap;fieldMap;publicChannels;constructor(){this.channelMap=new Map,this.fieldMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}static fromProofChannels(t){let n=new e;return n.setChannelsFromProofChannels(t),n}setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getLeavesByChannelMap();for(let[e,n]of t)this.channelMap.set(e,{nLeaves:n.length,leaves:n,tree:new wS,witnesses:[]});this.buildTrees(),this.buildFieldMap()}setChannelsFromProofChannels(e){for(let t of e){let e=[];for(let n of t.fields){let t=TS.fromProofFormat(n),r=n.type==_S.Public?0:n.index;e.push({leaf:t,path:n.path,index:r})}let n=t.witnesses.map(e=>k.binaryFromHexa(e));t.is_public&&this.publicChannels.add(t.id),this.channelMap.set(t.id,{nLeaves:t.n_leaves,leaves:e,tree:new wS,witnesses:n})}this.buildTrees(),this.buildFieldMap()}toJson(e=!1){let t={},n=[];for(let{leaves:e}of this.channelMap.values())for(let t of e)t!==null&&n.push(t);for(let{path:r,leaf:i}of n){let n=[`root`,...r],a=t;for(let t=0;t<n.length;t++){let r=n[t];if(t==n.length-1)a[r]=e?i.getTypedValue():i.getRawValue();else{let e=typeof n[t+1]==`number`;if(a[r]===void 0)a[r]=e?[]:{};else if(Array.isArray(a[r])!==e){let e=n.slice(0,t+1).join(`.`);throw Error(`${e} is defined as both an array and an object`)}a=a[r]}}}return t.root}buildTrees(){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){for(let e of t.leaves)e!==null&&t.tree.setLeaf(e.index,e.leaf.getHash());t.tree.finalize(t.nLeaves),t.tree.setWitnesses(t.witnesses)}}buildWitnesses(){for(let[e,t]of this.channelMap){if(this.publicChannels.has(e))continue;let n=new Set;for(let e of t.leaves)e!==null&&n.add(e.index);let r=[];for(let e=0;e<t.nLeaves;e++)n.has(e)||r.push(e);t.witnesses=t.tree.getWitnesses(r)}}buildFieldMap(){this.fieldMap.clear();for(let[e,t]of this.channelMap)for(let n=0;n<t.leaves.length;n++){let r=t.leaves[n];if(r===null)continue;let i=r.path,a=JSON.stringify(i);this.fieldMap.set(a,{channelId:e,index:n})}}getLeafByPath(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t).leaves[n];if(r===null)throw Error(`this field has been removed`);return r.leaf}getFieldByPath(e){let t=JSON.stringify(e),n=this.fieldMap.get(t);if(n===void 0)throw Error(`unknown path ${t}`);return n}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`unknown channel ID ${e}`);return t}removeField(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t);r.leaves[n]=null}setFieldToHashed(e){this.getLeafByPath(e).setToHashed()}setFieldToMasked(e){this.getLeafByPath(e).setToMasked()}getRootHashAsBinary(e){let t=this.getChannel(e);return this.publicChannels.has(e)?k.getNullHash():t.tree.getRootHash()}getRootHashAsHexString(e){let t=this.getRootHashAsBinary(e);return k.binaryToHexa(t)}toProofChannels(){this.buildWitnesses();let e=[];for(let[t,n]of this.channelMap){let r=this.publicChannels.has(t),i=[];for(let e of n.leaves){if(e===null)continue;let t=e.leaf.toProofFormat(e.path,e.index);i.push(t)}let a=n.witnesses.map(e=>k.binaryToHexa(e));e.push({id:t,is_public:r,n_leaves:n.nLeaves,fields:i,witnesses:a})}return e}},DS=class e{channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecord(t){let n=new e;n.setPublicChannels(t.getPublicChannels());let r=t.getItemList();for(let e of r){let t=e.item.channelId,r=n.channelMap.get(t);r===void 0&&(r=[],n.channelMap.set(t,r)),r.push(e)}return n}setChannel(e,t,n){t?this.publicChannels.add(e):this.publicChannels.delete(e),this.channelMap.set(e,n)}setPublicChannels(e){this.publicChannels=e}getPublicChannels(){return this.publicChannels}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getFlatItems(e){let t=this.channelMap.get(e);if(t==null)throw Error(`Channel ${e} not found`);return t}},OS=class{pepper;hasNullPepper;sha512;counter;constructor(e){this.pepper=e,this.sha512=new Uint8Array(64),this.counter=0,this.hasNullPepper=this.pepper.every(e=>e==0)}static generatePepper(){return j.Random.getBytes(32)}getPepper(){return this.pepper}getSalt(){let e=this.counter&3,t=this.counter++>>2;return!e&&!this.hasNullPepper&&(this.sha512=j.Hashes.sha512AsBinary(k.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},kS=class e{channelMap;recordByChannels;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecordByChannels(t,n=void 0){let r=new e;return r.setChannelsFromRecordByChannels(t,n),r}setChannelsFromRecordByChannels(e,t=void 0){this.publicChannels=e.getPublicChannels(),this.recordByChannels=e;let n=this.recordByChannels.getChannelIds();for(let e of n){let n=this.publicChannels.has(e),r=n?k.getNullHash():t===void 0?OS.generatePepper():t.get(e);if(r===void 0)throw Error(`no pepper specified for channel ${e}`);let i=this.recordByChannels.getFlatItems(e);this.storeChannel(e,n,i,r)}}storeChannel(e,t,n,r){let i=this.flatItemsToPositionedLeaves(n,t,r);this.channelMap.set(e,{pepper:r,positionedLeaves:i})}getPublicChannels(){return this.publicChannels}getLeavesByChannelMap(){let e=new Map;for(let[t,n]of this.channelMap)e.set(t,n.positionedLeaves);return e}getRecordByChannels(){let e=this.recordByChannels;if(e===void 0)throw Error(`recordByChannels is not set`);return e}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getChannelPepper(e){return this.getChannel(e).pepper}getChannelRootHash(e){let t=this.getChannel(e);if(this.publicChannels.has(e))return k.getNullHash();let n=new wS;for(let e of t.positionedLeaves){let t=e.leaf.getHash();n.addLeaf(t)}return n.finalize(),n.getRootHash()}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}flatItemsToPositionedLeaves(e,t,n){let r=new OS(n);return e.map((e,n)=>({leaf:this.flatItemToLeaf(r,t,e.item),index:n,path:e.path}))}flatItemToLeaf(e,t,n){let r=n.type==uS.String?n.transformation.type:cS.None;if(t&&r!=cS.None)throw Error(`no transformation may be applied to a public field`);switch(r){case cS.None:return t?TS.fromItemWithPublicData(n):TS.fromItemWithPlainData(e,n);case cS.Hashable:return TS.fromItemWithHashedData(e,n);case cS.Maskable:return TS.fromItemWithMaskedData(e,n);default:throw Error(`unsupported transformation type ${r}`)}}},AS=class e{itemList;publicChannels;constructor(){this.itemList=[],this.publicChannels=new Set}static fromObject(t){let n=new e,r=L(oS,t);return n.buildItemListByDfs(r),n}setChannelAsPublic(e){this.publicChannels.add(e)}setChannelAsPrivate(e){this.publicChannels.delete(e)}getPublicChannels(){return this.publicChannels}setChannel(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setFieldChannel(e.item,t)}setFieldChannel(e,t){e.channelId=t}setAsHashable(e){let t=this.getFieldsByPathString(e);for(let e of t)this.setFieldAsHashable(e.item)}setFieldAsHashable(e){if(e.type!==uS.String)throw Error(`only a string may be set as hashable`);e.transformation={type:cS.Hashable}}setMaskOnField(e,t){if(e.type!==uS.String)throw Error(`a mask may only be applied to a string`);let n=[],r=[];t.sort((e,t)=>e.start-t.start),t.forEach((i,a)=>{let o=a>0?t[a-1].start:0,s=a>0?t[a-1].end:0;if(i.start<0||i.start>=e.value.length||i.end<=i.start)throw`invalid interval [${[i.start,i.end]}]`;if(i.start<s)throw`overlapping intervals [${[o,s]}] and [${[i.start,i.end]}]`;let c=e.value.slice(i.start,i.end);a&&i.start==s?(n[n.length-1]+=i.replacement,r[r.length-1]+=c):(n.push(e.value.slice(s,i.start),i.replacement),r.push(c)),a==t.length-1&&i.end<e.value.length&&n.push(e.value.slice(i.end))}),e.transformation={type:cS.Maskable,visibleParts:n,hiddenParts:r}}setMaskByPositions(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setMaskOnField(e.item,t)}setMaskByRegex(e,t,n){let r=this.getFieldsByPathString(e);for(let e of r)this.setMaskByRegexOnField(e.item,t,n)}setMaskByRegexOnField(e,t,n){if(e.type!==uS.String)throw Error(`a mask may only be applied to a string`);let r=(t.exec(e.value)||[]).slice(1);if(r.join(``)!=e.value)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>({shown:!!(t&1),string:e})).filter(e=>e.string!=``);if(i.length!=r.length||i.some((e,t)=>e.shown&&e.string!=`$`+(t+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;i.forEach((e,t)=>{let n=o+r[t].length;e.shown||a.push({start:o,end:n,replacement:e.string}),o=n}),this.setMaskOnField(e,a)}getItemList(){return this.itemList}getFieldsByPathString(e){let t=e.match(/\[\d+\]|[^.[]+/g)||[];if(t[0]!==`this`)throw Error(`the path should begin with 'this'`);let n=t.slice(1).map(e=>e[0]==`[`?Number(e.slice(1,-1)):e);if(n.some((e,t)=>e==`*`&&t!=n.length-1))throw Error(`a wildcard may only appear at the end of the path`);let r=n[n.length-1]==`*`;return this.itemList.filter(e=>{let t;if(r){if(e.path.length<n.length)return!1;t=n.slice(0,-1)}else{if(e.path.length!=n.length)return!1;t=n}return t.every((t,n)=>t===e.path[n])})}static getValueType(e){if(typeof e==`string`)return uS.String;if(typeof e==`number`)return uS.Number;if(typeof e==`boolean`)return uS.Boolean;if(e===null)return uS.Null;if(Array.isArray(e))return uS.Array;if(typeof e==`object`&&Object.getPrototypeOf(e).isPrototypeOf(Object))return uS.Object;throw Error(`unsupported field type`)}static getPrimitiveValueType(t){let n=e.getValueType(t);if(n==uS.Array||n==uS.Object)throw Error(`expected a primitive value, got an array or an object`);return n}buildItemListByDfs(t,n=[]){switch(e.getValueType(t)){case uS.String:this.addFlatItem(n,this.buildStringItem(t));break;case uS.Number:this.addFlatItem(n,this.buildNumberItem(t));break;case uS.Boolean:this.addFlatItem(n,this.buildBooleanItem(t));break;case uS.Null:this.addFlatItem(n,this.buildNullItem());break;case uS.Array:this.buildArrayItem(t,n);break;case uS.Object:this.buildObjectItem(t,n);break;default:throw Error(`unsupported field type`)}}addFlatItem(e,t){let n={path:e,item:t};this.itemList.push(n)}buildStringItem(e){return{type:uS.String,value:e,transformation:{type:cS.None},channelId:-1}}buildNumberItem(e){return{type:uS.Number,value:e,channelId:-1}}buildBooleanItem(e){return{type:uS.Boolean,value:e,channelId:-1}}buildNullItem(){return{type:uS.Null,value:null,channelId:-1}}buildArrayItem(e,t){e.forEach((e,n)=>{this.buildItemListByDfs(e,[...t,n])})}buildObjectItem(e,t){Object.keys(e).forEach(n=>{let r=e[n];this.buildItemListByDfs(r,[...t,n])})}},jS=class e{encoder=new gx;channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}logger=ts.getLogger([e.name]);setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getRecordByChannels(),n=e.getChannelIds();for(let r of n){let n=e.getChannelPepper(r),i=e.getChannelRootHash(r),a=t.getFlatItems(r).map(e=>({path:e.path,value:e.item.value,...e.item.transformation?{transformation:e.item.transformation}:{}}));this.channelMap.set(r,{rootHash:i,pepper:n,onChainItems:a})}}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getOnChainData(e,t=!1){let n=this.getChannel(e),r=new gx().encode(n.onChainItems),i={pepper:n.pepper,data:r},a=this.encoder.encode(i);return{isPublic:this.publicChannels.has(e),merkleRootHash:n.rootHash,data:a}}addOnChainData(e,t,n,r){if(this.channelMap.has(e))throw Error(`channel ${e} has already been set`);t?this.publicChannels.add(e):this.publicChannels.delete(e);let i=this.encoder.decode(r);L(mS,i);let a=i.pepper,o=this.encoder.decode(i.data);L(gS,o),this.channelMap.set(e,{rootHash:n,pepper:a,onChainItems:o})}toMerkleRecord(e=!0){let t=new DS,n=new Map;for(let[e,r]of this.channelMap){let i=r.onChainItems.map(t=>{let n={channelId:e,type:AS.getPrimitiveValueType(t.value),value:t.value,...t.transformation?{transformation:t.transformation}:{}};return{path:t.path,item:n}}),a=this.publicChannels.has(e);t.setChannel(e,a,i),n.set(e,r.pepper)}let r=kS.fromRecordByChannels(t,n);if(e){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){let n=r.getChannelRootHash(e);if(!k.binaryIsEqual(n,t.rootHash))throw Error(`inconsistent Merkle root hash for private channel ${e} (computed ${k.binaryToHexa(n)}, on-chain value is ${k.binaryToHexa(t.rootHash)})`)}}return r}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}},MS=class e extends Wx{static createApplicationLedgerVirtualBlockchain(t){return new e(t)}draftModeEnabled=!1;constructor(e,t=Tx.createInitialState()){super(e,V.APP_LEDGER_VIRTUAL_BLOCKCHAIN,t)}async isAccountIdAllowedToWrite(e){if(this.getHeight()===0)return!0;let t=await this.getVirtualBlockchainOwnerId(),n=this.internalState.getAdditionalAllowedWriters();return[t.toBytes(),...n].some(t=>k.binaryIsEqual(t,e.toBytes()))}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async updateInternalState(e,t,n){let r=e.getApplicationLedgerInternalStateUpdaterVersion();return zx.createApplicationLedgerInternalStateUpdater(r).updateState(this.provider,this.internalState,n)}checkMicroblockStructure(e){return this.draftModeEnabled?!0:new iS().checkMicroblockStructure(e)}enableDraftMode(){this.draftModeEnabled=!0}disableDraftMode(){this.draftModeEnabled=!1}setInternalState(e){this.internalState=e}isActorDefined(e){return this.internalState.isActorDefinedByName(e)}actorIsSubscribed(e){return this.getActor(e).subscribed}getInternalState(){return this.internalState}async getActorIdByPublicSignatureKey(t){let n=ts.getLogger([e.name]),r=this.internalState,i=t.getPublicKeyAsBytes();for(let e=0;e<r.getNumberOfActors();e++){let t=r.getActorById(e);if(n.debug(`Search current actor id: loop index ${e}`),t.subscribed)try{let r=await this.getMicroblock(t.signatureKeyHeight);for(let a of r.getAllSections()){if(a.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION)continue;let{actorId:r}=a;if(r!==e)continue;let{signaturePublicKey:o}=a,s=k.binaryIsEqual(a.signaturePublicKey,await i);if(n.debug(`Is public key matching for actor ${t.name} (id ${e})? ${o} and ${i}: ${s}`),s)return n.debug(`Matching public signature key: {actor.name} (id ${e})`,{actor:t}),e}}catch(e){if(e instanceof x)n.debug(`{e}`,{e});else if(e instanceof Te)n.debug(`{e}`,{e});else throw e}}throw n.debug(`Current actor not found`),new fe}async getPublicEncryptionKeyByActorId(e){let t=this.internalState.getActorById(e).pkeKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.pkePublicKey,r=t.pkeSchemeId;return Bv.createPublicEncryptionKey(r,n)}}throw new we(e,this.getActorNameById(e))}async getPublicSignatureKeyByActorId(e){let t=this.internalState.getActorById(e).signatureKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.signaturePublicKey,r=t.signatureSchemeId;return Bv.createPublicSignatureKey(r,n)}}throw new Ce(`Actor ${e} has not subscribed to a public signature key.`)}async getExistingSharedKey(e,t){let n=this.internalState.getActorById(t).sharedSecrets.find(t=>t.peerActorId==e);if(n===void 0)return;let r=await this.getMicroblock(n.height);for(let n of r.getAllSections())if(n.type===O.APP_LEDGER_SHARED_SECRET&&!(n.hostId!==e||n.guestId!==t))return n.encryptedSharedKey;throw new Ee(t,e)}getChannelIdByChannelName(e){return this.internalState.getChannelIdFromChannelName(e)}getActorNameById(e){return this.internalState.getActorById(e).name}getChannelNameById(e){return this.internalState.getChannelFromChannelId(e).name}getActorIdFromActorName(e){return this.internalState.getActorIdByName(e)}getActor(e){return this.internalState.getActorByName(e)}getAllActors(){return this.internalState.getAllActors()}getAllChannels(){return this.internalState.getAllChannels()}async getOrganizationId(){let e=this.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getOrganizationId()}getApplicationId(){return this.internalState.getApplicationId()}getNumberOfChannels(){return this.internalState.getNumberOfChannels()}getChannelById(e){return this.internalState.getChannelFromChannelId(e)}getNumberOfActors(){return this.internalState.getNumberOfActors()}async getMicroblockMerkleRecord(t,n){let r=await this.getMicroblock(t),i=[];for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PUBLIC_CHANNEL_DATA)continue;let{channelId:t,data:n}=e;i.push({channelId:t,isPublic:!0,merkleRootHash:k.getNullHash(),data:n})}let a=ts.getLogger([e.name]);if(n!==void 0){let o=await(await n.getPrivateSignatureKey(Ya.SECP256K1)).getPublicKey(),s;try{s=await this.getActorIdByPublicSignatureKey(o)}catch(t){if(t instanceof fe)ts.getLogger([e.name]).debug(`Unabled to recover private channels: {e}`,{e:t});else throw t}if(typeof s==`number`)for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PRIVATE_CHANNEL_DATA)continue;let{channelId:r,encryptedData:o,merkleRootHash:c}=e;try{let e=await this.getChannelKey(s,r,n),l=this.deriveChannelSectionKey(e,t,r),u=this.deriveChannelSectionIv(e,t,r);a.debug(`Channel key ${e} at height ${t} and channel id ${r} -> Channel section key: ${l} (iv ${u}) `);let d=j.Aes.decryptGcm(l,o,u);a.debug(`Allowed to access private channel {channelName} (channel id={channelId})`,()=>({channelName:this.getChannelNameById(r),channelId:r})),i.push({channelId:r,isPublic:!1,merkleRootHash:c,data:d})}catch(e){if(e instanceof f||e instanceof me)a.debug(`Access to private channel {channelName} forbidden (channel id={channelId}): {e}`,()=>({e,channelName:this.getChannelNameById(r),channelId:r}));else throw e}}}else console.warn(`No private channel loaded: no private decryption key provided.`);let o=new jS;for(let e of i)o.addOnChainData(e.channelId,e.isPublic,e.merkleRootHash,e.data);return o.toMerkleRecord(!1)}deriveChannelSectionKey(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_KEY`,t,n,32)}deriveChannelSectionIv(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_IV`,t,n,12)}deriveChannelSectionMaterial(e,t,n,r,i){let a=new Uint8Array,o=new TextEncoder,s=k.binaryFrom(o.encode(t),r,new Uint8Array(k.intToByteArray(n,6)));return new _v().deriveKey(e,a,s,i)}async getChannelKey(e,t,n){rS.assert(typeof e==`number`,`Expected actor id with type number`),rS.assert(typeof t==`number`,`Expected channel id of type number: got ${typeof t}`);let r=this.internalState.getChannelCreatorIdFromChannelId(t),i=await n.getPrivateDecryptionKey(vv.ML_KEM_768_AES_256_GCM);if(r===e){let e=n.getSeedAsBytes();return await this.deriveChannelKey(e,t)}return await this.getChannelKeyFromInvitation(e,t,i)}async deriveChannelKey(e,t){let n=await this.getGenesisSeed(),r=new TextEncoder,i=k.binaryFrom(r.encode(`CHANNEL_KEY`)),a=k.binaryFrom(e,r.encode(`GENESIS_SEED`),n.toBytes(),r.encode(`CHANNEL_ID`),k.binaryFrom(t));return new _v().deriveKeyNoSalt(a,i,32)}async getChannelKeyFromInvitation(e,t,n){rS.assert(typeof e==`number`,`actorId should be a number, got ${typeof e}`),rS.assert(typeof t==`number`,`channelId should be a number, got ${typeof e}`);let r=this.internalState.getActorById(e).invitations.find(e=>e.channelId==t);if(!r){let n=this.internalState.getActorById(e).name,r=this.internalState.getChannelFromChannelId(t).name;throw new me(n,r)}let i=await this.getMicroblock(r.height),a;for(let n of i.getAllSections())n.type===O.APP_LEDGER_CHANNEL_INVITATION&&(n.guestId!==e||n.channelId!==t||(a=n));if(a===void 0)throw new me(e,t);let o=a.encryptedChannelKey;return await n.decrypt(o)}async exportProof(e,t){let n=new aS;n.setIdentifier(k.binaryToHexa(this.getIdentifier().toBytes()));for(let e=1;e<=this.getHeight();e++){let r=await this.getMicroblockMerkleRecord(e,t);console.log(`Merkle record at height ${e}:`,r);let i=ES.fromMerkleRecord(r);console.log(`Proof record at height ${e}:`,i);let a=i.toProofChannels();console.log(`Proof channels at height ${e}:`,a),n.addMicroblock(e,a)}let r=new CS;return r.setAuthor(e.author),r.addVirtualBlockchain(n),r.getObject()}async importProof(e){let t=[],n=CS.fromObject(e).getSingleVirtualBlockchainOrFail().getMicroblocks();for(let e of n){let n=e.height,r=await this.getMicroblock(n),i=[];for(let e of r.getAllSections())if(e.type===O.APP_LEDGER_PUBLIC_CHANNEL_DATA){let{channelId:t}=e;i.push({channelId:t,merkleRootHash:k.getNullHash()})}else if(e.type===O.APP_LEDGER_PRIVATE_CHANNEL_DATA){let{channelId:t,merkleRootHash:n}=e;i.push({channelId:t,merkleRootHash:n})}console.log(`ProofMicroblock.channels=`,e.channels);let a=ES.fromProofChannels(e.channels);for(let e of i){let t=a.getRootHashAsBinary(e.channelId);if(!k.binaryIsEqual(e.merkleRootHash,t)){console.log(t,e);let n=k.binaryToHexa(t),r=k.binaryToHexa(e.merkleRootHash);throw new se(e.channelId,n,r)}}t.push({height:n,data:a.toJson()})}return t}async getRecord(e,t){let n=await this.getMicroblockMerkleRecord(e,t);return ES.fromMerkleRecord(n).toJson()}async isActorInChannel(e,t){return this.internalState.getActorById(t).invitations.some(t=>t.channelId==e)}},NS=class e{value;constructor(e){this.value=e}static of(t){return new e(t)}static some(t){return new e(t)}static none(){return new e(null)}map(t){return this.value===null?e.none():e.some(t(this.value))}unwrap(){if(this.value===null)throw Error(`Called unwrap on a None value`);return this.value}unwrapOrThrow(e){if(this.value===null)throw e;return this.value}unwrapOr(e){return this.value===null?e:this.value}isSome(){return this.value!==null}isNone(){return this.value===null}},PS=class{provider;checkedMicroblock;_error=NS.none();hash;header;verificationState={isMicroblockParsingCompleted:!1};constructor(e,t){this.provider=e,this.checkedMicroblock=t}async checkVirtualBlockchainConsistencyOrFail(){if(this.verificationState.isMicroblockParsingCompleted)throw new a(`You have already called parseMicroblock() method. You can only call it once.`);if(!this.checkedMicroblock.isDeclaringConsistentBodyHash())throw Error(`inconsistent body hash detected for microblock hash ${k.binaryToHexa(this.checkedMicroblock.getHashAsBytes())}`);let e=this.checkedMicroblock.getType(),t=0,n,r=this.checkedMicroblock.getPreviousHash().toBytes();if(this.checkedMicroblock.isGenesisMicroblock()){let t=r;e=Hx.extractTypeFromGenesisPreviousHash(t),n=this.checkedMicroblock.getHash()}else{let e=await this.provider.getMicroblockHeader(Cx.from(r));if(!e)throw Error(`previous microblock ${k.binaryToHexa(r)} not found`);if(this.checkedMicroblock.getHeight()!=e.height+1)throw Error(`inconsistent microblock height (expected ${e.height+1}, got ${this.checkedMicroblock.getHeight()})`);let t=Y.computeMicroblockHashFromHeader(e);n=await this.provider.getVirtualBlockchainIdContainingMicroblock(Cx.from(t))}let i;if(this.checkedMicroblock.isGenesisMicroblock()){switch(e){case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=new Jx(this.provider);break;case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=new Xx(this.provider);break;case V.APPLICATION_VIRTUAL_BLOCKCHAIN:i=new Qx(this.provider);break;case V.NODE_VIRTUAL_BLOCKCHAIN:i=new eS(this.provider);break;case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=new nS(this.provider);break;case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=new MS(this.provider);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}let n=this.checkedMicroblock.getPreviousHash().toBytes();t=Hx.extractExpirationDayFromGenesisPreviousHash(n),i.setExpirationDay(t)}else switch(e){case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadOrganizationVirtualBlockchain(n);break;case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadAccountVirtualBlockchain(n);break;case V.APPLICATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationVirtualBlockchain(n);break;case V.NODE_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadValidatorNodeVirtualBlockchain(n);break;case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadProtocolVirtualBlockchain(n);break;case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationLedgerVirtualBlockchain(n);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}await i.appendMicroBlock(this.checkedMicroblock),this.verificationState={isMicroblockParsingCompleted:!0,virtualBlockchain:i}}checkTimestampOrFail(e){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock;e||=k.getTimestampInSeconds();let n=t.isTemporallyCloseTo(e);if(n===Bx.TOO_FAR_IN_THE_PAST)throw Error(`timestamp is too far in the past (header:${this.header.timestamp} / current:${e})`);if(n===Bx.TOO_FAR_IN_THE_FUTURE)throw Error(`timestamp is too far in the future (header:${this.header.timestamp} / current:${e})`)}async checkGasOrFail(e=k.getTimestampInSeconds()){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock,n=await this.provider.computeMicroblockFees(t,{referenceTimestampInSeconds:e}),r=t.getMaxFees();if(r.getAmountAsAtomic()<n.getAmountAsAtomic())throw Error(`Computed fees ${n.toString()} is strictly higher than max fees ${r.toString()} `)}get virtualBlockchain(){if(this.verificationState.isMicroblockParsingCompleted)return this.verificationState.virtualBlockchain;throw new a(`Virtual blockchain not initialized.`)}getVirtualBlockchain(){return this.virtualBlockchain}getMicroblock(){return this.checkedMicroblock}getHash(){return this.hash}getError(){return this._error}containsError(){return this._error.isSome()}get error(){return this.containsError()?this._error.unwrap().toString():``}},FS=class{mbUnderConstruction;vb;provider;stateUpdater;constructor(e,t,n){this.mbUnderConstruction=e,this.vb=t,this.provider=n}onMicroblockSearchFailureForExceedingHeight(e,t){if(e.getHeight()+1===t)return Promise.resolve(this.mbUnderConstruction);throw new x(e.getIdentifier(),t)}getBuiltMicroblock(){return this.mbUnderConstruction}async updateStateWithSection(e){if(!this.stateUpdater){let e=await this.provider.getProtocolState();this.stateUpdater=zx.createApplicationLedgerInternalStateUpdater(e.getApplicationLedgerInternalStateUpdaterVersion())}this.vb.setInternalState(await this.stateUpdater.updateStateFromSection(this.provider,this.vb.getInternalState(),e,this.mbUnderConstruction.getHeight()))}getInternalState(){return this.vb.getInternalState()}},IS;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WALLET=1]=`WALLET`,e[e.OPERATOR=2]=`OPERATOR`})(IS||={});var LS=F({name:I()}),RS=F({name:I(),public:Kp()}),zS=F({fieldPath:I(),channelName:I()}),BS=F({actorName:I(),channelName:I()}),VS=F({position:P(),length:P(),replacementString:I()}),HS=F({fieldPath:I(),maskedParts:M(VS)}),US=F({fieldPath:I()}),WS=F({virtualBlockchainId:Qp(I()),data:Gp(),actors:Qp(M(LS)),channels:Qp(M(RS)),channelAssignations:Qp(M(zS)),actorAssignations:Qp(M(BS)),hashableFields:Qp(M(US)),maskableFields:Qp(M(HS)),author:I(),endorser:Qp(I()),approvalMessage:Qp(I())}),GS=class{static validate(e){return L(WS,e)}static safeParse(e){return am(WS,e)}static is(e){return Wp(WS,e)}},KS=class e extends FS{logger=ts.getLogger([e.name]);static async createFromVirtualBlockchain(t,n){let r=await n.createMicroblock(),i=new e(r,n);if(n.setMicroblockSearchFailureFallback(i),n.isEmpty()){let e={type:O.APP_LEDGER_CREATION,applicationId:t.toBytes()};r.addSection(e),await i.updateStateWithSection(e)}return i}usedSignatureSchemeId=Ya.SECP256K1;usedPkeSchemeId=vv.ML_KEM_768_AES_256_GCM;constructor(e,t){super(e,t,t.getProvider())}get state(){return this.getInternalState()}getActorPrivateSignatureKey(e){return e.getPrivateSignatureKey(this.usedSignatureSchemeId)}getActorPrivateDecryptionKey(e){return e.getPrivateDecryptionKey(this.usedPkeSchemeId)}async createMicroblockFromStateUpdateRequest(e,t){let n=GS.validate(t),r=await this.getActorPrivateDecryptionKey(e),a=await this.getActorPrivateSignatureKey(e),o=this.state.getNumberOfActors();for(let e of n.actors||[]){console.log(this.state.getAllActors());let t=e.name;this.vb.isActorDefined(t)?console.log(`Skipping actor creation: ${t} already created`):(await this.createActor(o,e.name),o+=1)}let s=n.author,c=this.getActorIdFromActorName(s);if(this.vb.isEmpty()){let e=await r.getPublicKey();await this.subscribeActor(s,await a.getPublicKey(),e)}let l=this.state.getNumberOfChannels();for(let e of n.channels||[]){let t={type:O.APP_LEDGER_CHANNEL_CREATION,id:l,isPrivate:!e.public,creatorId:c,name:e.name};this.mbUnderConstruction.addSection(t),await this.updateStateWithSection(t),l+=1}let u=AS.fromObject(n.data);for(let e of n.channelAssignations||[]){let t=this.state.getChannelIdFromChannelName(e.channelName);u.setChannel(e.fieldPath,t)}for(let t of n.actorAssignations||[]){let n=t.channelName,r=t.actorName;await this.inviteActorOnChannel(r,n,e)}for(let e of n.hashableFields||[])u.setAsHashable(e.fieldPath);for(let e of n.maskableFields||[]){let t=e.maskedParts.map(e=>({start:e.position,end:e.position+e.length,replacement:e.replacementString}));u.setMaskByPositions(e.fieldPath,t)}let d=this.state.getAllChannels();for(let e in d){let t=Number(e);d[t].isPrivate||u.setChannelAsPublic(Number(t))}let f=DS.fromRecord(u),p=kS.fromRecordByChannels(f),m=jS.fromMerkleRecord(p),h=m.getChannelIds();for(let t of h){let n=m.getOnChainData(t),{isPublic:r,merkleRootHash:i}=n;if(r){let e={type:O.APP_LEDGER_PUBLIC_CHANNEL_DATA,channelId:t,data:n.data};this.mbUnderConstruction.addSection(e),await this.updateStateWithSection(e)}else{let r=ts.getLogger([`critical`]),a=this.vb.getHeight()+1,o=await this.vb.getChannelKey(c,t,e),s=this.vb.deriveChannelSectionKey(o,a,t),l=this.vb.deriveChannelSectionIv(o,a,t);r.debug(`Channel key ${o} at height ${a} and channel id ${t} -> Channel section key: ${s} (iv ${l}) `);let u=j.Aes.encryptGcm(s,n.data,l),d={type:O.APP_LEDGER_PRIVATE_CHANNEL_DATA,channelId:t,merkleRootHash:i,encryptedData:u};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}}if(typeof n.endorser==`string`){if(n.endorser.trim().length===0)throw new i(`Empty endorser provided: should be a non-empty string or undefined`);let e=this.getActorIdFromActorName(n.endorser),t=n.approvalMessage??``,r={type:O.APP_LEDGER_ENDORSEMENT_REQUEST,message:t,endorserId:e};this.mbUnderConstruction.addSection(r),await this.updateStateWithSection(r)}return this.mbUnderConstruction}async createActor(e,t){console.log(`Creating actor ${t} (id ${e})`);let n={type:O.APP_LEDGER_ACTOR_CREATION,id:e,actorType:IS.UNKNOWN,name:t};this.mbUnderConstruction.addSection(n),await this.updateStateWithSection(n)}async inviteActorOnChannel(e,t,n){console.log(`Inviting actor `+e+` on channel `+t);let r=this.state.getChannelIdFromChannelName(t),i=this.getActorIdFromActorName(e),a=await this.getActorPrivateSignatureKey(n),o=await this.vb.getActorIdByPublicSignatureKey(await a.getPublicKey());rS.assert(typeof r==`number`,`Expected channel id of type number: got ${typeof r} for channel ${t}`);let s=i;if(await this.vb.isActorInChannel(r,s))return;let c=await this.vb.getChannelKey(o,r,n),l=await(await this.vb.getPublicEncryptionKeyByActorId(s)).encrypt(c),u=ts.getLogger([MS.name]);u.info(`Actor {guestName} invited to channel ${t}`,()=>({guestName:e})),u.debug(`Channel key for channel ${t}: ${c}`);let d={type:O.APP_LEDGER_CHANNEL_INVITATION,channelId:r,hostId:o,guestId:s,encryptedChannelKey:l};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}async createSharedKey(e,t,n){let{encryptedSharedKey:r,hostGuestSharedKey:i}=await this.generateSharedKeyAndEncryptedSharedKey(e,n),a={type:O.APP_LEDGER_SHARED_SECRET,hostId:t,guestId:n,encryptedSharedKey:r};return this.mbUnderConstruction.addSection(a),await this.updateStateWithSection(a),i}static deriveHostGuestSharedKey(e,t,n){let r=e.getRawPrivateKey(),i=new TextEncoder,a=k.binaryFrom(i.encode(`SHARED_SECRET`),n),o=new _v,s=k.binaryFrom(r,t),c=o.deriveKeyNoSalt(s,a,32);return Ig.createFromBytes(c)}async generateSharedKeyAndEncryptedSharedKey(t,n){let r=await this.getGenesisSeed(),i=e.deriveHostGuestSharedKey(t,r.toBytes(),n);return{encryptedSharedKey:await(await this.vb.getPublicEncryptionKeyByActorId(n)).encrypt(i.getRawSecretKey()),hostGuestSharedKey:i}}async getGenesisSeed(){return this.vb.isEmpty()?this.mbUnderConstruction.getPreviousHash():await this.vb.getGenesisSeed()}async subscribeActor(e,t,n){if(console.debug(`Subscribing ${e}`),!this.vb.isActorDefined(e)){console.log(`It appears that ${e} does not exist: create it`);let t=this.vb.getNumberOfActors();await this.createActor(t,e)}let r=IS.UNKNOWN,i=this.getActorIdFromActorName(e),a=k.getNullHash(),o={type:O.APP_LEDGER_ACTOR_SUBSCRIPTION,actorId:i,actorType:r,organizationId:a,signatureSchemeId:t.getSignatureSchemeId(),signaturePublicKey:await t.getPublicKeyAsBytes(),pkeSchemeId:n.getSchemeId(),pkePublicKey:await n.getRawPublicKey()};this.mbUnderConstruction.addSection(o),await this.updateStateWithSection(o)}getActorIdFromActorName(e){return this.state.getActorIdByName(e)}},qS=class e{type;publicKey;static ED25519_PUBLIC_KEY_TYPE=`tendermint/PubKeyEd25519`;static createFromEd25519PublicKey(t){return new e(e.ED25519_PUBLIC_KEY_TYPE,t)}constructor(e,t){this.type=e,this.publicKey=t}getType(){return this.type}getPublicKey(){return this.publicKey}},JS=class{encodeSignature(e){return e}decodeSignature(e){return e}encodeMessage(e){return e}decodeMessage(e){return e}async encodePublicKey(e){return Us(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),publicKey:gl(await e.getPublicKeyAsBytes())}))}async decodePublicKey(e){let t=JSON.parse(xl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.publicKey==`string`){let e=yl(t.publicKey);return new Bv().createPublicSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and publicKey fields.`}async encodePrivateKey(e){return Us(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),privateKey:gl(e.getPrivateKeyAsBytes())}))}async decodePrivateKey(e){let t=JSON.parse(xl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.privateKey==`string`){let e=yl(t.privateKey);return Bv.createPrivateSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and privateKey fields.`}},YS=class{static defaultEncoder(){return Vv.createBase64HCVPkeEncoder()}},XS=class{encodeAsUint8Array(e){return Us(JSON.stringify({symmetricEncryptionSchemeId:e.getSymmetricEncryptionSchemeId(),key:gl(e.getRawSecretKey())}))}decodeFromUint8Array(e){let t=JSON.parse(xl(e));if(t&&typeof t.symmetricEncryptionSchemeId==`number`&&typeof t.key==`string`){let e=yl(t.key);return new Bv().createSymmetricEncryptionKey(t.symmetricEncryptionSchemeId,e)}else throw`Invalid symmetric encryption key format: expected raw-encoded JSON object with symmetricEncryptionSchemeId and key fields.`}};function ZS(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],ee=e[t++]^n[r++],x=o,te=s,S=c,ne=l,re=u,ie=d,ae=f,oe=p,se=m,ce=h,C=g,le=_,ue=v,de=y,fe=b,pe=ee;for(let e=0;e<8;e+=2)re^=Ps(x+ue|0,7),se^=Ps(re+x|0,9),ue^=Ps(se+re|0,13),x^=Ps(ue+se|0,18),ce^=Ps(ie+te|0,7),de^=Ps(ce+ie|0,9),te^=Ps(de+ce|0,13),ie^=Ps(te+de|0,18),fe^=Ps(C+ae|0,7),S^=Ps(fe+C|0,9),ae^=Ps(S+fe|0,13),C^=Ps(ae+S|0,18),ne^=Ps(pe+le|0,7),oe^=Ps(ne+pe|0,9),le^=Ps(oe+ne|0,13),pe^=Ps(le+oe|0,18),te^=Ps(x+ne|0,7),S^=Ps(te+x|0,9),ne^=Ps(S+te|0,13),x^=Ps(ne+S|0,18),ae^=Ps(ie+re|0,7),oe^=Ps(ae+ie|0,9),re^=Ps(oe+ae|0,13),ie^=Ps(re+oe|0,18),le^=Ps(C+ce|0,7),se^=Ps(le+C|0,9),ce^=Ps(se+le|0,13),C^=Ps(ce+se|0,18),ue^=Ps(pe+fe|0,7),de^=Ps(ue+pe|0,9),fe^=Ps(de+ue|0,13),pe^=Ps(fe+de|0,18);i[a++]=o+x|0,i[a++]=s+te|0,i[a++]=c+S|0,i[a++]=l+ne|0,i[a++]=u+re|0,i[a++]=d+ie|0,i[a++]=f+ae|0,i[a++]=p+oe|0,i[a++]=m+se|0,i[a++]=h+ce|0,i[a++]=g+C|0,i[a++]=_+le|0,i[a++]=v+ue|0,i[a++]=y+de|0,i[a++]=b+fe|0,i[a++]=ee+pe|0}function QS(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)ZS(n,o,e,t,n,a),r>0&&(o+=16),ZS(n,a,e,t+=16,n,o)}function $S(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=qs({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(Ts(r),Ts(i),Ts(a),Ts(o),Ts(s),Ts(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4,f=2**32;if(r<=1||r&r-1||r>f)throw Error(`Scrypt: N must be larger than 1, a power of 2, and less than 2^32`);if(a<0||a>(f-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(f-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);if(u*(r+a)>c)throw Error(`Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of `+c);let p=ov(Kc,e,t,{c:1,dkLen:u*a}),m=As(p),h=As(new Uint8Array(u*r)),g=As(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function eC(e,t,n,r,i){let a=ov(Kc,e,n,{c:1,dkLen:t});return js(n,r,i),a}function tC(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=$S(e,t,n);Rs(l);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)QS(c,t,c,t+=s,i),f();QS(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];QS(d,0,l,t,i),f()}}return Rs(l),eC(e,o,u,c,d)}var nC=class extends cv{getKeyDerivationFunctionSchemeId(){return sv.SCRYPT}deriveKey(e,t,n){return tC(e,t,{N:2**16,r:8,p:1,dkLen:n})}},rC=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ya.ED25519}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},iC=class extends Bg{publicKey;constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return K_(t,Kc(e),this.publicKey)}getScheme(){return new rC}},aC=class e extends zg{privateKey;constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(J_.randomSecretKey())}static genFromSeed(t){return new e(t)}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new iC(B_(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return U_(Kc(e),this.privateKey)}getScheme(){return new rC}},oC=class{apiKey;constructor(e){this.apiKey=e}async getPkmsCredential(){return this.apiKey}},sC=class{key;constructor(e,t,n){this.key=`${e}|${t}|${n}`}getKey(){return this.key}},cC=class{map;constructor(){this.map=new Map}async has(e){return this.map.has(e.getKey())}async get(e){return this.map.get(e.getKey())}async set(e,t){this.map.set(e.getKey(),t)}};(async function(){new cC})();var lC=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,uC={verifyFormat:dC,encodeNumber:fC,decodeNumber:pC,encodeToChar:mC,decodeFromChar:hC,CROCKFORD_CHARS:lC};function dC(e,t=e.length){return RegExp(`^(${[...lC].join(`|`)}){${t}}$`).test(e)}function fC(e,t){if(!Number.isInteger(t)||t<1||t>10)throw Error(`Invalid or unsafe size for base32 encoding`);if(!Number.isInteger(e)||e<0||e>=32**t)throw Error(`Invalid number for base32 encoding of size ${t}`);return[...Array(t).keys()].map(t=>mC(e>>t*5&31)).join(``)}function pC(e){if(e.length==0||e.length>10)throw Error(`Invalid base32 string length`);return[...e].reduceRight((e,t)=>e<<5|hC(t),0)}function mC(e){let t=lC[e];if(t===void 0)throw Error(`Invalid base32 value`);return t}function hC(e){let t=lC.indexOf(e);if(e.length!=1||t==-1)throw Error(`Invalid base32 character`);return t}var gC=class{collection;constructor(e){this.collection=e}serialize(e,t){let n=this.collection[e],r=new Mv(n).serialize(t);return new Uint8Array([e,...r])}},_C=class{collection;constructor(e){this.collection=e}unserialize(e){let t=e[0],n=this.collection[t];if(!n)throw Error(`Unknown message type ${t}: I do not know how to unserialize this message.`);return{type:t,object:new Nv(n).unserialize(e.slice(1))}}},vC=class{schema;constructor(e){this.schema=e}validate(e){if(this.schema===void 0)throw new o(`Provided schema is undefined: this should not happen`);this.validateObject(this.schema.definition,e)}validateObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0){if(r.optional)continue;throw Error(`field '${e}' is missing`)}if(r.type&32){if(ro.getType(i)!=1)throw`'${e}' is not an array`;for(let t in i)this.validateItem(r,i[t],e+`[${t}]`)}else this.validateItem(r,i,e)}}validateItem(e,t,n){if((e.type&31)==2){if(ro.getType(t)!=2)throw`'${n}' is not an object`;if(!e.unspecifiedSchema){if(!e.schema)throw`missing definition in schema`;this.validateObject(e.schema.definition,t,n)}}else{let r=new io(e,t);try{r.check()}catch(e){throw`Error on field '${n}': ${e}`}}}},yC={getAccountTypeFromIdentifier:bC,getSpecialAccountTypeIdentifier:xC,isAllowedTransfer:SC};function bC(e){if(e.length!=32)throw Error(`invalid account identifier`);if(e.slice(0,-1).every(e=>e==0)){let t=e[31];if(t==1||!Ur[t])throw Error(`special account format detected, but with an invalid type (${t})`);return t}return 1}function xC(e){if(e==1||!Ur[e])throw Error(`${e} is not a valid special account type`);let t=new Uint8Array(32);return t[31]=e,t}function SC(e,t){return Wr[e]>>t&1}var CC=class e{amount;constructor(e){this.amount=e}static create(t){return new e(t)}getAmount(){return this.amount}toString(){return`${this.amount} €`}},wC=class{static defaultEurosToCMTSTokenConverter(){return new TC}},TC=class e{static TOKENS_FOR_ONE_EUROS=100;convert(t){return mn.create(t.getAmount()*e.TOKENS_FOR_ONE_EUROS)}invert(t){return CC.create(t.getAmount()/e.TOKENS_FOR_ONE_EUROS)}},EC=class e{verified;appLedger;importedProofs;constructor(e,t,n){this.verified=e,this.appLedger=t,this.importedProofs=n}static createSuccessfulProofVerificationResult(t,n){return new e(!0,t,NS.some(n))}static createFailedProofVerificationResult(t){return new e(!1,t,NS.none())}isVerified(){return this.verified}getInvolvedBlockHeights(){return this.importedProofs.isSome()?this.importedProofs.unwrap().map(e=>e.height):[]}getApplicationLedgerId(){return this.appLedger.getIdentifier()}async getRecordContainedInBlockAtHeight(e,t){throw Error(`Not implemented`)}},DC;(function(e){e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP=-32603]=`ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP`,e[e.TX_ALREADY_EXISTS=-32003]=`TX_ALREADY_EXISTS`,e[e.TX_OUT_OF_GAS=-32002]=`TX_OUT_OF_GAS`,e[e.TX_CHECK_FAILED=-32001]=`TX_CHECK_FAILED`,e[e.TX_DELIVER_FAILED=-32e3]=`TX_DELIVER_FAILED`})(DC||={});var OC=class e{log=ts.getAbstractProviderLogger(e.name);async loadValidatorNodeVirtualBlockchain(e){let t=new eS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadAccountVirtualBlockchain(e){this.log.debug(`Loading account virtual blockchain with id ${e.encode()}`);let t=new Xx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationLedgerVirtualBlockchain(e){let t=new MS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationVirtualBlockchain(e){let t=new Qx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadOrganizationVirtualBlockchain(e){let t=new Jx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadProtocolVirtualBlockchain(e){let t=new nS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadVirtualBlockchain(e){let t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Virtual Blockchain with hash ${e.encode()} does not exist.`);let n=t.type;switch(n){case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:return await this.loadAccountVirtualBlockchain(e);case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return await this.loadOrganizationVirtualBlockchain(e);case V.APPLICATION_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationVirtualBlockchain(e);case V.NODE_VIRTUAL_BLOCKCHAIN:return await this.loadValidatorNodeVirtualBlockchain(e);case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:return await this.loadProtocolVirtualBlockchain(e);case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationLedgerVirtualBlockchain(e);default:throw Error(`Unknown virtual blockchain type: ${n}`)}}async loadMicroblockByMicroblockHash(e){this.log.info(`Loading microblock ${e.encode()}`);let t=await this.getMicroblockHeader(e),n=await this.getMicroblockBody(e);if(t===null||n===null)throw Error(`Microblock ${e.encode()} not found`);return Hx.loadFromHeaderAndBody(t,n)}async getCurrentFeesFormula(){let e=(await this.getProtocolState()).getFeesCalculationVersion();return xx.getFeesCalculationFormulaByVersion(this,e)}async computeMicroblockFees(e,t={}){let n=t.referenceTimestampInSeconds??k.getTimestampInSeconds(),r=0;if(e.isGenesisMicroblock())r=Hx.extractExpirationDayFromGenesisPreviousHash(e.getPreviousHash().toBytes());else{let t=await this.getVirtualBlockchainIdContainingMicroblock(e.getPreviousHash()),n=await this.getVirtualBlockchainState(t.toBytes());if(n===null)throw Error(`Virtual blockchain state not found`);r=n.expirationDay}let i=t.signatureSchemeId??e.getLastSignatureSection().schemeId;if(i===null)throw Error(`Signature scheme ID cannot be null`);return(await this.getCurrentFeesFormula()).computeFees(i,e,r,n)}async initializeVirtualBlockchain(e,t){let n=t.toBytes(),r=await this.getVirtualBlockchainStatus(n);if(r===null||r.state===void 0)throw new xe(t);if(r.state.type!==e.getType())throw Error(`Invalid blockchain type loaded`);e.setIdentifier(n),e.setHeight(r.state.height),e.setExpirationDay(r.state.expirationDay),e.setMicroblockHashes(r.microblockHashes),e.setInternalState(Ax.createInternalStateFromObject(e.getType(),r.state.internalState))}},kC=class e{expirationDate;endless;constructor(e,t){this.expirationDate=e,this.endless=t}static endless(){return new e(NS.none(),!0)}static of(t){return new e(NS.of(t),!1)}static fromDurationInDays(t){let n=new Date;return n.setDate(n.getDate()+t),e.of(n)}isEndless(){return this.endless}getExpirationDate(){return this.expirationDate.unwrap()}},AC=class e{static logger=ts.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}microblockHeaderStore;microblockBodyStore;microblockVbInformationStore;virtualBlockchainStateStore;constructor(){this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}clear(){e.logger.info(`Clearing`),this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(t){let n=await e.get(this.microblockVbInformationStore,t);return e.logger.info(`getMicroblockVbInformation identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getInformationOfVirtualBlockchainContainingMicroblock(e){let t=await this.getSerializedInformationOfVirtualBlockchainContainingMicroblock(e);return t===null?null:Y.decodeVirtualBlockchainInfo(t)}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=Y.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier=${k.binaryToHexa(t)} found: {header}`,{header:r}),r}}async getSerializedMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=j.Hashes.sha256(n),i=Y.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier (sha256:${r})=${k.binaryToHexa(t)} found: {header}`,{header:JSON.stringify(i)}),n}}async getMicroblockBody(t){let n=await e.get(this.microblockBodyStore,t);return e.logger.info(`getMicroblockBody identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getSerializedVirtualBlockchainState(t){let n=await e.get(this.virtualBlockchainStateStore,t);return e.logger.info(`getVirtualBlockchainState identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(t,n){let r=Y.decodeVirtualBlockchainInfo(n);return e.logger.info(`Store info of vb identifier=${k.binaryToHexa(t)}: {info}`,{info:r}),await e.set(this.microblockVbInformationStore,t,n)}async setSerializedMicroblockHeader(t,n){let r=Y.decodeMicroblockHeader(n);return e.logger.info(`Store header of microblock identifier=${k.binaryToHexa(t)} -> {header}`,{header:r}),await e.set(this.microblockHeaderStore,t,n)}async setSerializedMicroblockBody(t,n){let r=Y.decodeMicroblockBody(n);return e.logger.info(`Store body of microblock ${k.binaryToHexa(t)}: {body}`,{body:r}),await e.set(this.microblockBodyStore,t,n)}async setMicroblockHeader(e,t){let n=Y.encodeMicroblockHeader(t);await this.setSerializedMicroblockHeader(e,n)}async setMicroblockBody(e,t){let n=Y.encodeMicroblockBody(t);await this.setSerializedMicroblockBody(e,n)}async setSerializedVirtualBlockchainState(t,n){let r=Y.decodeVirtualBlockchainState(n);return e.logger.info(`Store vb state for vb ${k.binaryToHexa(t)}: {state}`,{state:r}),await e.set(this.virtualBlockchainStateStore,t,n)}static async get(e,t){let n=k.binaryToHexa(t);if(!e.has(n))return null;let r=e.get(n);return r===void 0?null:k.binaryFromHexa(r)}static async set(t,n,r){let i=k.binaryToHexa(n),a=k.binaryToHexa(r),o=t.get(i);o===void 0?e.logger.info(`Storing new entry for key ${i}`):o===a?e.logger.info(`Storing the same data for the same key ${i}`):e.logger.info(`Storing new data for key ${i}`),t.set(i,a)}},jC=globalThis||self;function MC(e,t){return function(){return e.apply(t,arguments)}}var{toString:NC}=Object.prototype,{getPrototypeOf:PC}=Object,{iterator:FC,toStringTag:IC}=Symbol,LC=(e=>t=>{let n=NC.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),RC=e=>(e=e.toLowerCase(),t=>LC(t)===e),zC=e=>t=>typeof t===e,{isArray:BC}=Array,VC=zC(`undefined`);function HC(e){return e!==null&&!VC(e)&&e.constructor!==null&&!VC(e.constructor)&&KC(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var UC=RC(`ArrayBuffer`);function WC(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&UC(e.buffer),t}var GC=zC(`string`),KC=zC(`function`),qC=zC(`number`),JC=e=>typeof e==`object`&&!!e,YC=e=>e===!0||e===!1,XC=e=>{if(LC(e)!==`object`)return!1;let t=PC(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(IC in e)&&!(FC in e)},ZC=e=>{if(!JC(e)||HC(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},QC=RC(`Date`),$C=RC(`File`),ew=e=>!!(e&&e.uri!==void 0),tw=e=>e&&e.getParts!==void 0,nw=RC(`Blob`),rw=RC(`FileList`),iw=e=>JC(e)&&KC(e.pipe);function aw(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:jC===void 0?{}:jC}var ow=aw(),sw=ow.FormData===void 0?void 0:ow.FormData,cw=e=>{let t;return e&&(sw&&e instanceof sw||KC(e.append)&&((t=LC(e))===`formdata`||t===`object`&&KC(e.toString)&&e.toString()===`[object FormData]`))},lw=RC(`URLSearchParams`),[uw,dw,fw,pw]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(RC),mw=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function hw(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),BC(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(HC(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function gw(e,t){if(HC(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var _w=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:jC,vw=e=>!VC(e)&&e!==_w;function yw(){let{caseless:e,skipUndefined:t}=vw(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&gw(n,i)||i;XC(n[a])&&XC(r)?n[a]=yw(n[a],r):XC(r)?n[a]=yw({},r):BC(r)?n[a]=r.slice():(!t||!VC(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&hw(arguments[e],r);return n}var bw=(e,t,n,{allOwnKeys:r}={})=>(hw(t,(t,r)=>{n&&KC(t)?Object.defineProperty(e,r,{value:MC(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),xw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Sw=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},Cw=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&PC(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ww=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Tw=e=>{if(!e)return null;if(BC(e))return e;let t=e.length;if(!qC(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},Ew=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&PC(Uint8Array)),Dw=(e,t)=>{let n=(e&&e[FC]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Ow=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},kw=RC(`HTMLFormElement`),Aw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),jw=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Mw=RC(`RegExp`),Nw=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};hw(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Pw=e=>{Nw(e,(t,n)=>{if(KC(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(KC(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Fw=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return BC(e)?r(e):r(String(e).split(t)),n},Iw=()=>{},Lw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Rw(e){return!!(e&&KC(e.append)&&e[IC]===`FormData`&&e[FC])}var zw=e=>{let t=Array(10),n=(e,r)=>{if(JC(e)){if(t.indexOf(e)>=0)return;if(HC(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=BC(e)?[]:{};return hw(e,(e,t)=>{let a=n(e,r+1);!VC(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Bw=RC(`AsyncFunction`),Vw=e=>e&&(JC(e)||KC(e))&&KC(e.then)&&KC(e.catch),Hw=((e,t)=>e?setImmediate:t?((e,t)=>(_w.addEventListener(`message`,({source:n,data:r})=>{n===_w&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),_w.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,KC(_w.postMessage)),Q={isArray:BC,isArrayBuffer:UC,isBuffer:HC,isFormData:cw,isArrayBufferView:WC,isString:GC,isNumber:qC,isBoolean:YC,isObject:JC,isPlainObject:XC,isEmptyObject:ZC,isReadableStream:uw,isRequest:dw,isResponse:fw,isHeaders:pw,isUndefined:VC,isDate:QC,isFile:$C,isReactNativeBlob:ew,isReactNative:tw,isBlob:nw,isRegExp:Mw,isFunction:KC,isStream:iw,isURLSearchParams:lw,isTypedArray:Ew,isFileList:rw,forEach:hw,merge:yw,extend:bw,trim:mw,stripBOM:xw,inherits:Sw,toFlatObject:Cw,kindOf:LC,kindOfTest:RC,endsWith:ww,toArray:Tw,forEachEntry:Dw,matchAll:Ow,isHTMLForm:kw,hasOwnProperty:jw,hasOwnProp:jw,reduceDescriptors:Nw,freezeMethods:Pw,toObjectSet:Fw,toCamelCase:Aw,noop:Iw,toFiniteNumber:Lw,findKey:gw,global:_w,isContextDefined:vw,isSpecCompliantForm:Rw,toJSONObject:zw,isAsyncFn:Bw,isThenable:Vw,setImmediate:Hw,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(_w):py!==void 0&&py.nextTick||Hw,isIterable:e=>e!=null&&KC(e[FC])},$=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Q.toJSONObject(this.config),code:this.code,status:this.status}}};$.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,$.ERR_BAD_OPTION=`ERR_BAD_OPTION`,$.ECONNABORTED=`ECONNABORTED`,$.ETIMEDOUT=`ETIMEDOUT`,$.ERR_NETWORK=`ERR_NETWORK`,$.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,$.ERR_DEPRECATED=`ERR_DEPRECATED`,$.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,$.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,$.ERR_CANCELED=`ERR_CANCELED`,$.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,$.ERR_INVALID_URL=`ERR_INVALID_URL`;function Uw(e){return Q.isPlainObject(e)||Q.isArray(e)}function Ww(e){return Q.endsWith(e,`[]`)?e.slice(0,-2):e}function Gw(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ww(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function Kw(e){return Q.isArray(e)&&!e.some(Uw)}var qw=Q.toFlatObject(Q,{},null,function(e){return/^is[A-Z]/.test(e)});function Jw(e,t,n){if(!Q.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=Q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Q.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&Q.isSpecCompliantForm(t);if(!Q.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if(Q.isDate(e))return e.toISOString();if(Q.isBoolean(e))return e.toString();if(!s&&Q.isBlob(e))throw new $(`Blob is not supported. Use a Buffer instead.`);return Q.isArrayBuffer(e)||Q.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Ng.from(e):e}function l(e,n,i){let s=e;if(Q.isReactNative(t)&&Q.isReactNativeBlob(e))return t.append(Gw(i,n,a),c(e)),!1;if(e&&!i&&typeof e==`object`){if(Q.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Q.isArray(e)&&Kw(e)||(Q.isFileList(e)||Q.endsWith(n,`[]`))&&(s=Q.toArray(e)))return n=Ww(n),s.forEach(function(e,r){!(Q.isUndefined(e)||e===null)&&t.append(o===!0?Gw([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return Uw(e)?!0:(t.append(Gw(i,n,a),c(e)),!1)}let u=[],d=Object.assign(qw,{defaultVisitor:l,convertValue:c,isVisitable:Uw});function f(e,n){if(!Q.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),Q.forEach(e,function(e,r){(!(Q.isUndefined(e)||e===null)&&i.call(t,e,Q.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!Q.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function Yw(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Xw(e,t){this._pairs=[],e&&Jw(e,this,t)}var Zw=Xw.prototype;Zw.append=function(e,t){this._pairs.push([e,t])},Zw.toString=function(e){let t=e?function(t){return e.call(this,t,Yw)}:Yw;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function Qw(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function $w(e,t,n){if(!t)return e;let r=n&&n.encode||Qw,i=Q.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):Q.isURLSearchParams(t)?t.toString():new Xw(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var eT=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){Q.forEach(this.handlers,function(t){t!==null&&e(t)})}},tT={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},nT={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:Xw,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},rT=t({hasBrowserEnv:()=>iT,hasStandardBrowserEnv:()=>oT,hasStandardBrowserWebWorkerEnv:()=>sT,navigator:()=>aT,origin:()=>cT}),iT=typeof window<`u`&&typeof document<`u`,aT=typeof navigator==`object`&&navigator||void 0,oT=iT&&(!aT||[`ReactNative`,`NativeScript`,`NS`].indexOf(aT.product)<0),sT=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,cT=iT&&window.location.href||`http://localhost`,lT={...rT,...nT};function uT(e,t){return Jw(e,new lT.classes.URLSearchParams,{visitor:function(e,t,n,r){return lT.isNode&&Q.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function dT(e){return Q.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function fT(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function pT(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&Q.isArray(r)?r.length:a,s?(Q.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!Q.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&Q.isArray(r[a])&&(r[a]=fT(r[a])),!o)}if(Q.isFormData(e)&&Q.isFunction(e.entries)){let n={};return Q.forEachEntry(e,(e,r)=>{t(dT(e),r,n,0)}),n}return null}function mT(e,t,n){if(Q.isString(e))try{return(t||JSON.parse)(e),Q.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var hT={transitional:tT,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=Q.isObject(e);if(i&&Q.isHTMLForm(e)&&(e=new FormData(e)),Q.isFormData(e))return r?JSON.stringify(pT(e)):e;if(Q.isArrayBuffer(e)||Q.isBuffer(e)||Q.isStream(e)||Q.isFile(e)||Q.isBlob(e)||Q.isReadableStream(e))return e;if(Q.isArrayBufferView(e))return e.buffer;if(Q.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return uT(e,this.formSerializer).toString();if((a=Q.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return Jw(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),mT(e)):e}],transformResponse:[function(e){let t=this.transitional||hT.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if(Q.isResponse(e)||Q.isReadableStream(e))return e;if(e&&Q.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?$.from(e,$.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:lT.classes.FormData,Blob:lT.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};Q.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{hT.headers[e]={}});var gT=Q.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),_T=e=>{let t={},n,r,i;return e&&e.split(`
|
|
9
|
-
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&
|
|
10
|
-
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[vT]=this[vT]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=yT(e);t[r]||(TT(n,e),t[r]=!0)}return Q.isArray(e)?e.forEach(r):r(e),this}};ET.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),Q.reduceDescriptors(ET.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Q.freezeMethods(ET);function DT(e,t){let n=this||hT,r=t||n,i=ET.from(r.headers),a=r.data;return Q.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function OT(e){return!!(e&&e.__CANCEL__)}var kT=class extends ${constructor(e,t,n){super(e??`canceled`,$.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function AT(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new $(`Request failed with status code `+n.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function jT(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function MT(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function NT(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var PT=(e,t,n=3)=>{let r=0,i=MT(50,250);return NT(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},FT=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},IT=e=>(...t)=>Q.asap(()=>e(...t)),LT=lT.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,lT.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(lT.origin),lT.navigator&&/(msie|trident)/i.test(lT.navigator.userAgent)):()=>!0,RT=lT.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];Q.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),Q.isString(r)&&s.push(`path=${r}`),Q.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),Q.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function zT(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function BT(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function VT(e,t,n){let r=!zT(t);return e&&(r||n==0)?BT(e,t):t}var HT=e=>e instanceof ET?{...e}:e;function UT(e,t){t||={};let n={};function r(e,t,n,r){return Q.isPlainObject(e)&&Q.isPlainObject(t)?Q.merge.call({caseless:r},e,t):Q.isPlainObject(t)?Q.merge({},t):Q.isArray(t)?t.slice():t}function i(e,t,n,i){if(!Q.isUndefined(t))return r(e,t,n,i);if(!Q.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!Q.isUndefined(t))return r(void 0,t)}function o(e,t){if(!Q.isUndefined(t))return r(void 0,t);if(!Q.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(HT(e),HT(t),n,!0)};return Q.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=Q.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);Q.isUndefined(o)&&a!==s||(n[r]=o)}),n}var WT=e=>{let t=UT({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=ET.from(o),t.url=$w(VT(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),Q.isFormData(n)){if(lT.hasStandardBrowserEnv||lT.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Q.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(lT.hasStandardBrowserEnv&&(r&&Q.isFunction(r)&&(r=r(t)),r||r!==!1&<(t.url))){let e=i&&a&&RT.read(a);e&&o.set(i,e)}return t},GT=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=WT(e),i=r.data,a=ET.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=ET.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());AT(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new $(`Request aborted`,$.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new $(t&&t.message?t.message:`Network Error`,$.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||tT;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new $(t,i.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&Q.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),Q.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=PT(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=PT(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new kT(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=jT(r.url);if(_&&lT.protocols.indexOf(_)===-1){n(new $(`Unsupported protocol `+_+`:`,$.ERR_BAD_REQUEST,e));return}h.send(i||null)})},KT=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof $?t:new kT(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new $(`timeout of ${t}ms exceeded`,$.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>Q.asap(o),s}},qT=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},JT=async function*(e,t){for await(let n of YT(e))yield*qT(n,t)},YT=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},XT=(e,t,n,r)=>{let i=JT(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},ZT=64*1024,{isFunction:QT}=Q,$T=(({Request:e,Response:t})=>({Request:e,Response:t}))(Q.global),{ReadableStream:eE,TextEncoder:tE}=Q.global,nE=(e,...t)=>{try{return!!e(...t)}catch{return!1}},rE=e=>{e=Q.merge.call({skipUndefined:!0},$T,e);let{fetch:t,Request:n,Response:r}=e,i=t?QT(t):typeof fetch==`function`,a=QT(n),o=QT(r);if(!i)return!1;let s=i&&QT(eE),c=i&&(typeof tE==`function`?(e=>t=>e.encode(t))(new tE):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&nE(()=>{let e=!1,t=new eE,r=new n(lT.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&nE(()=>Q.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new $(`Response type '${e}' is not supported`,$.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(Q.isBlob(e))return e.size;if(Q.isSpecCompliantForm(e))return(await new n(lT.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(Q.isArrayBufferView(e)||Q.isArrayBuffer(e))return e.byteLength;if(Q.isURLSearchParams(e)&&(e+=``),Q.isString(e))return(await c(e)).byteLength},p=async(e,t)=>Q.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=WT(e),ee=t||fetch;_=_?(_+``).toLowerCase():`text`;let x=KT([c,f&&f.toAbortSignal()],m),te=null,S=x&&x.unsubscribe&&(()=>{x.unsubscribe()}),ne;try{if(g&&l&&o!==`get`&&o!==`head`&&(ne=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(Q.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=FT(ne,PT(IT(g)));s=XT(e.body,ZT,t,n)}}Q.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:x,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};te=a&&new n(i,c);let f=await(a?ee(te,b):ee(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&S)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=Q.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&FT(t,PT(IT(h),!0))||[];f=new r(XT(f.body,ZT,n,()=>{i&&i(),S&&S()}),e)}_||=`text`;let re=await d[Q.findKey(d,_)||`text`](f,e);return!m&&S&&S(),await new Promise((t,n)=>{AT(t,n,{data:re,headers:ET.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:te})})}catch(t){throw S&&S(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new $(`Network Error`,$.ERR_NETWORK,e,te,t&&t.response),{cause:t.cause||t}):$.from(t,t&&t.code,e,te,t&&t.response)}}},iE=new Map,aE=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=iE;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:rE(t)),l=c;return c};aE();var oE={http:null,xhr:GT,fetch:{get:aE}};Q.forEach(oE,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var sE=e=>`- ${e}`,cE=e=>Q.isFunction(e)||e===null||e===!1;function lE(e,t){e=Q.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!cE(r)&&(i=oE[(n=String(r)).toLowerCase()],i===void 0))throw new $(`Unknown adapter '${n}'`);if(i&&(Q.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new $(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
|
|
11
|
-
`+e.map(
|
|
12
|
-
`):` `+
|
|
13
|
-
`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=UT(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&_E.assertOptions(n,{silentJSONParsing:vE.transitional(vE.boolean),forcedJSONParsing:vE.transitional(vE.boolean),clarifyTimeoutError:vE.transitional(vE.boolean),legacyInterceptorReqResOrdering:vE.transitional(vE.boolean)},!1),r!=null&&(Q.isFunction(r)?t.paramsSerializer={serialize:r}:_E.assertOptions(r,{encode:vE.function,serialize:vE.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),_E.assertOptions(t,{baseUrl:vE.spelling(`baseURL`),withXsrfToken:vE.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&Q.merge(i.common,i[t.method]);i&&Q.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=ET.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||tT;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[fE.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=fE.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=UT(this.defaults,e),$w(VT(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Q.forEach([`delete`,`get`,`head`,`options`],function(e){yE.prototype[e]=function(t,n){return this.request(UT(n||{},{method:e,url:t,data:(n||{}).data}))}}),Q.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(UT(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}yE.prototype[e]=t(),yE.prototype[e+`Form`]=t(!0)});var bE=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new kT(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function xE(e){return function(t){return e.apply(null,t)}}function SE(e){return Q.isObject(e)&&e.isAxiosError===!0}var CE={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(CE).forEach(([e,t])=>{CE[t]=e});function wE(e){let t=new yE(e),n=MC(yE.prototype.request,t);return Q.extend(n,yE.prototype,t,{allOwnKeys:!0}),Q.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return wE(UT(e,t))},n}var TE=wE(hT);TE.Axios=yE,TE.CanceledError=kT,TE.CancelToken=bE,TE.isCancel=OT,TE.VERSION=pE,TE.toFormData=Jw,TE.AxiosError=$,TE.Cancel=TE.CanceledError,TE.all=function(e){return Promise.all(e)},TE.spread=xE,TE.isAxiosError=SE,TE.mergeConfig=UT,TE.AxiosHeaders=ET,TE.formToJSON=e=>pT(Q.isHTMLForm(e)?new FormData(e):e),TE.getAdapter=uE.getAdapter,TE.HttpStatusCode=CE,TE.default=TE;var{Axios:EE,AxiosError:DE,CanceledError:OE,isCancel:kE,CancelToken:AE,VERSION:jE,all:ME,Cancel:NE,isAxiosError:PE,spread:FE,toFormData:IE,AxiosHeaders:LE,HttpStatusCode:RE,formToJSON:zE,getAdapter:BE,mergeConfig:VE}=TE,HE=F({jsonrpc:N(`2.0`),id:P(),result:F({node_info:F({protocol_version:F({p2p:I(),block:I(),app:I()}),id:I(),listen_addr:I(),network:I(),version:I(),channels:I(),moniker:I(),other:F({tx_index:I(),rpc_address:I()})}),sync_info:F({latest_block_hash:I(),latest_app_hash:I(),latest_block_height:I(),latest_block_time:I(),earliest_block_hash:I(),earliest_app_hash:I(),earliest_block_height:I(),earliest_block_time:I(),catching_up:Kp()}),validator_info:F({address:I(),pub_key:F({type:I(),value:I()}),voting_power:I()})})}),UE;(function(e){e[e.GET_CHAIN_INFORMATION=1]=`GET_CHAIN_INFORMATION`,e[e.GET_BLOCK_INFORMATION=3]=`GET_BLOCK_INFORMATION`,e[e.GET_BLOCK_CONTENT=5]=`GET_BLOCK_CONTENT`,e[e.GET_VIRTUAL_BLOCKCHAIN_STATE=7]=`GET_VIRTUAL_BLOCKCHAIN_STATE`,e[e.GET_VIRTUAL_BLOCKCHAIN_UPDATE=9]=`GET_VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.GET_MICROBLOCK_INFORMATION=11]=`GET_MICROBLOCK_INFORMATION`,e[e.AWAIT_MICROBLOCK_ANCHORING=13]=`AWAIT_MICROBLOCK_ANCHORING`,e[e.GET_MICROBLOCK_BODYS=15]=`GET_MICROBLOCK_BODYS`,e[e.GET_ACCOUNT_STATE=17]=`GET_ACCOUNT_STATE`,e[e.GET_ACCOUNT_HISTORY=19]=`GET_ACCOUNT_HISTORY`,e[e.GET_ACCOUNT_BY_PUBLIC_KEY_HASH=21]=`GET_ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.GET_VALIDATOR_NODE_BY_ADDRESS=23]=`GET_VALIDATOR_NODE_BY_ADDRESS`,e[e.GET_OBJECT_LIST=25]=`GET_OBJECT_LIST`,e[e.GET_GENESIS_SNAPSHOT=27]=`GET_GENESIS_SNAPSHOT`,e[e.GET_RAW_BLOCK_CONTENT=29]=`GET_RAW_BLOCK_CONTENT`,e[e.GET_BLOCK_MODIFIED_ACCOUNTS=31]=`GET_BLOCK_MODIFIED_ACCOUNTS`,e[e.GET_ACCOUNT_UPDATES=33]=`GET_ACCOUNT_UPDATES`})(UE||={});var WE=F({requestType:N(UE.GET_CHAIN_INFORMATION)}),GE=F({requestType:N(UE.GET_BLOCK_INFORMATION),height:R(P(),Lp(),Vp(0))}),KE=F({requestType:N(UE.GET_BLOCK_CONTENT),height:R(P(),Lp(),Vp(0))}),qE=F({requestType:N(UE.GET_VIRTUAL_BLOCKCHAIN_STATE),virtualBlockchainId:Am()}),JE=F({requestType:N(UE.GET_VIRTUAL_BLOCKCHAIN_UPDATE),virtualBlockchainId:Am(),knownHeight:R(P(),Lp(),Vp(0))}),YE=F({requestType:N(UE.GET_MICROBLOCK_INFORMATION),hash:Am()}),XE=F({requestType:N(UE.AWAIT_MICROBLOCK_ANCHORING),hash:Am()}),ZE=F({requestType:N(UE.GET_MICROBLOCK_BODYS),hashes:M(Am())}),QE=F({requestType:N(UE.GET_ACCOUNT_STATE),accountHash:Am()}),$E=F({requestType:N(UE.GET_ACCOUNT_HISTORY),accountHash:Am(),lastHistoryHash:Am(),maxRecords:R(P(),Lp(),Vp(1))}),eD=F({requestType:N(UE.GET_ACCOUNT_BY_PUBLIC_KEY_HASH),publicKeyHash:Am()}),tD=F({requestType:N(UE.GET_VALIDATOR_NODE_BY_ADDRESS),address:B()}),nD=F({requestType:N(UE.GET_OBJECT_LIST),type:R(P(),Lp(),Vp(0),zp(255))}),rD=F({requestType:N(UE.GET_GENESIS_SNAPSHOT)}),iD=F({requestType:N(UE.GET_RAW_BLOCK_CONTENT),height:R(P(),Lp(),Vp(0)),partIndex:R(P(),Lp(),Vp(0))}),aD=F({requestType:N(UE.GET_BLOCK_MODIFIED_ACCOUNTS),height:R(P(),Lp(),Vp(0))}),oD=F({requestType:N(UE.GET_ACCOUNT_UPDATES),list:M(rg)}),sD=im(`requestType`,[WE,GE,KE,qE,JE,YE,XE,ZE,QE,$E,eD,tD,nD,rD,iD,aD,oD]),cD;(function(e){e[e.ERROR=0]=`ERROR`,e[e.CHAIN_INFORMATION=2]=`CHAIN_INFORMATION`,e[e.BLOCK_INFORMATION=4]=`BLOCK_INFORMATION`,e[e.BLOCK_CONTENT=6]=`BLOCK_CONTENT`,e[e.VIRTUAL_BLOCKCHAIN_STATE=8]=`VIRTUAL_BLOCKCHAIN_STATE`,e[e.VIRTUAL_BLOCKCHAIN_UPDATE=10]=`VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.MICROBLOCK_INFORMATION=12]=`MICROBLOCK_INFORMATION`,e[e.MICROBLOCK_ANCHORING=14]=`MICROBLOCK_ANCHORING`,e[e.MICROBLOCK_BODYS=16]=`MICROBLOCK_BODYS`,e[e.ACCOUNT_STATE=18]=`ACCOUNT_STATE`,e[e.ACCOUNT_HISTORY=20]=`ACCOUNT_HISTORY`,e[e.ACCOUNT_BY_PUBLIC_KEY_HASH=22]=`ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.VALIDATOR_NODE_BY_ADDRESS=24]=`VALIDATOR_NODE_BY_ADDRESS`,e[e.OBJECT_LIST=26]=`OBJECT_LIST`,e[e.GENESIS_SNAPSHOT=28]=`GENESIS_SNAPSHOT`,e[e.RAW_BLOCK_CONTENT=30]=`RAW_BLOCK_CONTENT`,e[e.BLOCK_MODIFIED_ACCOUNTS=32]=`BLOCK_MODIFIED_ACCOUNTS`,e[e.ACCOUNT_UPDATES=34]=`ACCOUNT_UPDATES`})(cD||={});var lD=F({responseType:N(cD.ERROR),error:I()}),uD=F({responseType:N(cD.CHAIN_INFORMATION),height:R(P(),Lp(),Vp(0)),lastBlockTimestamp:R(P(),Lp(),Vp(0)),microblockCount:R(P(),Lp(),Vp(0)),objectCounts:M(R(P(),Lp(),Vp(0)))}),dD=F({responseType:N(cD.BLOCK_INFORMATION),hash:Am(),timestamp:R(P(),Lp(),Vp(0)),proposerAddress:B(),size:R(P(),Lp(),Vp(0)),microblockCount:R(P(),Lp(),Vp(0))}),fD=F({hash:Am(),vbId:Am(),vbType:R(P(),Lp(),Vp(0),zp(255)),height:R(P(),Lp(),Vp(0)),size:R(P(),Lp(),Vp(0)),sectionCount:R(P(),Lp(),Vp(0))}),pD=F({responseType:N(cD.BLOCK_CONTENT),microblocks:M(fD)}),mD=F({responseType:N(cD.VIRTUAL_BLOCKCHAIN_STATE),serializedVirtualBlockchainState:B()}),hD=F({responseType:N(cD.VIRTUAL_BLOCKCHAIN_UPDATE),exists:Kp(),changed:Kp(),serializedVirtualBlockchainState:B(),serializedHeaders:M(B())}),gD=F({responseType:N(cD.MICROBLOCK_INFORMATION),...Hh.entries}),_D=F({responseType:N(cD.MICROBLOCK_ANCHORING),...Hh.entries}),vD=F({microblockHash:Am(),microblockBody:Sh}),yD=F({responseType:N(cD.MICROBLOCK_BODYS),list:M(vD)}),bD=F({responseType:N(cD.ACCOUNT_STATE),height:R(P(),Lp(),Vp(0)),balance:R(P(),Lp(),Vp(0)),lastHistoryHash:Am(),locks:M(Zh)}),xD=F({responseType:N(cD.ACCOUNT_HISTORY),list:ng}),SD=F({responseType:N(cD.ACCOUNT_BY_PUBLIC_KEY_HASH),accountHash:Am()}),CD=F({responseType:N(cD.VALIDATOR_NODE_BY_ADDRESS),validatorNodeHash:Am()}),wD=F({responseType:N(cD.OBJECT_LIST),list:M(Am())}),TD=F({responseType:N(cD.GENESIS_SNAPSHOT),base64EncodedChunks:M(I())}),ED=F({responseType:N(cD.RAW_BLOCK_CONTENT),partIndex:P(),numberOfParts:P(),serializedMicroblocks:M(B())}),DD=F({responseType:N(cD.BLOCK_MODIFIED_ACCOUNTS),modifiedAccounts:M(B())}),OD=F({responseType:N(cD.ACCOUNT_UPDATES),list:M(ig)}),kD=im(`responseType`,[lD,uD,dD,pD,ED,mD,hD,gD,_D,yD,bD,xD,SD,CD,wD,TD,DD,OD]),AD=class{static encodeAbciRequest(e){return ux(L(sD,e))}static decodeAbciRequest(e){return L(sD,Nb(e))}static encodeAbciResponse(e){return ux(L(kD,e))}static decodeAbciResponse(e){return L(kD,Nb(e))}},jD=class e{nodeUrl;static staticLogger=ts.getNetworkProviderLogger();logger=e.staticLogger;requestLogger=e.staticLogger.getChild(`request`);responseLogger=e.staticLogger.getChild(`response`);static createFromUrl(t){e.staticLogger.debug(`NetworkProvider constructor -> nodeUrl: ${t}`);try{return new URL(t),new e(t)}catch{throw new i(`Invalid node URL: got ${t}`)}}constructor(e){this.nodeUrl=e}async sendSerializedMicroblock(e){this.requestLogger.info(`Sending serialized microblock (${e.length} bytes)`);let t=await this.broadcastTx(e);return this.responseLogger.info(`Received response: <- {data}`,()=>({data:t?.data})),t}async awaitMicroblockAnchoring(e){let t=k.binaryToHexa(e);return this.requestLogger.info(`Awaiting microblock {hash} to be published...`,()=>({hash:t})),L(Hh,await this.abciQuery({requestType:UE.AWAIT_MICROBLOCK_ANCHORING,hash:e}))}async getChainInformation(){return this.requestLogger.info(`Requesting chain information`),L(uD,await this.abciQuery({requestType:UE.GET_CHAIN_INFORMATION}))}async getBlockInformation(e){this.requestLogger.info(`Requesting block information at height: ${e}`);let t=await this.abciQuery({requestType:UE.GET_BLOCK_INFORMATION,height:e});return this.responseLogger.info(`Received block information at height ${e}`),L(dD,t)}async getBlockContent(e){this.requestLogger.info(`Requesting block content for height ${e}`);let t=L(pD,await this.abciQuery({requestType:UE.GET_BLOCK_CONTENT,height:e}));return this.responseLogger.info(`Received block content for height ${e}: ${t.microblocks.length} microblocks received`),t}async getValidatorNodeByAddress(e){this.requestLogger.info(`Requesting validator node id for address {address}`,()=>({address:k.binaryToHexa(e)}));let t=await this.abciQuery({requestType:UE.GET_VALIDATOR_NODE_BY_ADDRESS,address:e});return this.responseLogger.info(`Receiving validator node id {id}`,()=>({id:k.binaryToHexa(e)})),L(CD,t)}async getAccountState(e){this.requestLogger.info(`Requesting account state for account hash {accountHash}`,()=>({accountHash:k.binaryToHexa(e)}));let t=L(bD,await this.abciQuery({requestType:UE.GET_ACCOUNT_STATE,accountHash:e}));return this.responseLogger.info(`Receiving account state: height={height}, balance={balance}`,()=>({height:t.height,balance:mn.createAtomic(t.balance).toString()})),t}async getAccountHistory(e,t,n){this.requestLogger.info(`Requesting account history for account hash: ${k.binaryToHexa(e)}, lastHistoryHash: ${k.binaryToHexa(t)}, maxRecords: ${n}`);let r=L(xD,await this.abciQuery({requestType:UE.GET_ACCOUNT_HISTORY,accountHash:e,lastHistoryHash:t,maxRecords:n}));return this.responseLogger.info(`Receiving account history with ${r.list.length} entries`),r}async getAccountByPublicKeyHash(e){this.requestLogger.info(`Requesting account hash by public key hash: ${k.binaryToHexa(e)}`);let t=L(SD,await this.abciQuery({requestType:UE.GET_ACCOUNT_BY_PUBLIC_KEY_HASH,publicKeyHash:e}));return this.responseLogger.info(`Received account hash {accountHash}`,()=>({accountHash:k.binaryToHexa(t.accountHash)})),t}async getObjectList(e){this.requestLogger.info(`Requesting list of objects of type ${e}`);let t=L(wD,await this.abciQuery({requestType:UE.GET_OBJECT_LIST,type:e}));return this.responseLogger.info(`Receiving object lists with ${t.list.length} elements)`),t}async getMicroblockInformation(e){this.requestLogger.info(`Requesting microblock information for hash ${k.binaryToHexa(e)}`);let t=L(gD,await this.abciQuery({requestType:UE.GET_MICROBLOCK_INFORMATION,hash:e}));return this.responseLogger.info(`Received microblock information: vbType={vbType}, vbId={vbId}`,()=>({vbType:t.virtualBlockchainType,vbId:k.binaryToHexa(t.virtualBlockchainId)})),this.logger.info(`Received microblock information body hash for microblock ${k.binaryToHexa(e)}: ${k.binaryToHexa(t.header.bodyHash)}`),L(Hh,t)}async getMicroblockBodys(e){this.requestLogger.info(`Requesting microblock bodys for microblock hashes ${e.length}`),this.requestLogger.info(`Lisf of requested hashes: {hashes}`,()=>({hashes:e.map(e=>k.binaryToHexa(e)).join(`, `)}));let t=L(yD,await this.abciQuery({requestType:UE.GET_MICROBLOCK_BODYS,hashes:e}));return this.responseLogger.info(`Returned number of microblock bodys: ${t.list.length}`),t}async getVirtualBlockchainUpdate(e,t){this.requestLogger.info(`Request virtual blockchain update for virtualBlockchainId: ${k.binaryToHexa(e)}, knownHeight: ${t}`);let n=await this.abciQuery({requestType:UE.GET_VIRTUAL_BLOCKCHAIN_UPDATE,virtualBlockchainId:e,knownHeight:t});return this.responseLogger.info(`Receiving virtual blockchain update`),L(hD,n)}async getSerializedVirtualBlockchainState(e){this.requestLogger.info(`Requesting virtual blockchain state for vb id {vbId}`,()=>({vbId:k.binaryToHexa(e)}));let t=L(mD,await this.abciQuery({requestType:UE.GET_VIRTUAL_BLOCKCHAIN_STATE,virtualBlockchainId:e}));return this.responseLogger.info(`Receiving virtual blockchain state: ${t.serializedVirtualBlockchainState.length} bytes`),t.serializedVirtualBlockchainState}static async query(e,t={}){try{return(await TE.post(e,t,{headers:{"Content-Type":`application/json; charset=UTF-8`,Accept:`application/json`}})).data}catch(t){if(t instanceof DE){if(t.code===`ECONNREFUSED`)throw new g(e);if(t.status===500)throw new h(`Internal error in the node: ${t.message}`)}throw t}}async broadcastTx(t){let n=new URL(this.nodeUrl);this.logger.info(`broadcastTx -> ${t.length} bytes to ${this.nodeUrl}`);let r=fg.bytesToBase64Encoder();return await e.query(n,{jsonrpc:`2.0`,id:1,method:`broadcast_tx_sync`,params:{tx:r.encode(t)}})}async abciQuery(t){if(t===void 0)throw new i(`Cannot send an undefined request`);this.logger.debug(`Sending ABCI request:`,t);let n=AD.encodeAbciRequest(t);return await e.sendABCIQueryToNodeServer(this.nodeUrl,n)}static async sendABCIQueryToNodeServer(t,n){e.staticLogger.debug(`Sending ABCI Query to node server at ${t} (${n.length} bytes) `);let r=new URL(t);r.pathname=`abci_query`,r.searchParams.append(`path`,`"/carmentis"`),r.searchParams.append(`data`,`0x`+k.binaryToHexa(n));let i=await e.query(r),a=i?.result?.response?.value;if(typeof a!=`string`)throw this.staticLogger.error(`Invalid response type detected:`,i),this.staticLogger.error(`rawBase64EncodedResponse: `,a),new h(`Invalid response detected`);let o=sg.decodeBinary(a),s=AD.decodeAbciResponse(o);if(s.responseType==cD.ERROR){let t=s.error;throw e.staticLogger.error(`sendABCIQueryToNodeServer <- {*}`,()=>({error:t})),new h(`Remote error: ${t}`)}return e.staticLogger.debug(`Returning ABCI response`),s}static async sendStatusQueryToNodeServer(t){e.staticLogger.debug(`sendStatusQueryToNodeServer -> nodeUrl: ${t}`);let n=new URL(t);n.pathname=`status`;let r=am(HE,await e.query(n));if(r.success)return e.staticLogger.debug(`sendStatusQueryToNodeServer <- received valid status response`),r.output;throw e.staticLogger.debug(`sendStatusQueryToNodeServer <- parsing error: ${r.issues}`),new h(r.issues.map(e=>e.message).join(`, `))}async getGenesisSnapshot(){this.requestLogger.info(`Requesting genesis snapshot`);let e=L(TD,await this.abciQuery({requestType:UE.GET_GENESIS_SNAPSHOT}));return this.responseLogger.info(`Received genesis snapshots containing {chunksNumber} chunks`,()=>({chunksNumber:e.base64EncodedChunks.length})),e}},MD=class e{static logger=ts.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}constructor(){}clear(){e.logger.info(`Clearing`)}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(e){return null}async getSerializedMicroblockHeader(e){return null}async getMicroblockBody(e){return null}async getSerializedVirtualBlockchainState(e){return null}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(e,t){}async setSerializedMicroblockHeader(e,t){}async setSerializedMicroblockBody(e,t){}async setMicroblockHeader(e,t){}async setMicroblockBody(e,t){}async setSerializedVirtualBlockchainState(e,t){}},ND=class{constructor(){}sendSerializedMicroblock(e){throw Error(`Method not implemented.`)}awaitMicroblockAnchoring(e){throw Error(`Method not implemented.`)}getChainInformation(){throw Error(`Method not implemented.`)}getBlockInformation(e){throw Error(`Method not implemented.`)}getBlockContent(e){throw Error(`Method not implemented.`)}getValidatorNodeByAddress(e){throw Error(`Method not implemented.`)}getAccountState(e){throw Error(`Method not implemented.`)}getAccountHistory(e,t,n){throw Error(`Method not implemented.`)}getAccountByPublicKeyHash(e){throw Error(`Method not implemented.`)}getObjectList(e){throw Error(`Method not implemented.`)}getMicroblockInformation(e){return Promise.resolve(null)}getMicroblockBodys(e){return Promise.resolve(null)}getVirtualBlockchainUpdate(e,t){throw Error(`Method not implemented.`)}getSerializedVirtualBlockchainState(e){throw Error(`Method not implemented.`)}broadcastTx(e){throw Error(`Method not implemented.`)}abciQuery(e){throw Error(`Method not implemented.`)}getGenesisSnapshot(){throw Error(`Method not implemented.`)}},PD=class{static convertRawPublicKeyIntoAddress(e){return $c.sha256AsBinary(e).slice(0,20)}},FD=class e extends OC{logger=ts.getProviderLogger();externalProvider;internalProvider;constructor(e,t){super(),this.internalProvider=e,this.externalProvider=t}async awaitMicroblockAnchoring(e){return await this.externalProvider.awaitMicroblockAnchoring(e)}async getChainInformation(){return await this.externalProvider.getChainInformation()}async getGenesisSnapshot(){return await this.externalProvider.getGenesisSnapshot()}async getBlockInformation(e){return await this.externalProvider.getBlockInformation(e)}async getBlockContent(e){return await this.externalProvider.getBlockContent(e)}async getAccountState(e){return await this.externalProvider.getAccountState(e)}async getAccountHistory(e,t,n){return await this.externalProvider.getAccountHistory(e,t,n)}async getAccountByPublicKeyHash(t){let n=await this.internalProvider.getAccountByPublicKeyHash(t);if(n!==null)return n;let r=await this.externalProvider.getAccountByPublicKeyHash(t);return ts.getLogger([e.name]).debug(`Account hash ${r} is associated to public key hash ${t}`),r.accountHash}async getVirtualBlockchainState(e){this.logger.info(`Getting state for virtual blockchain ${k.binaryToHexa(e)}`);let t=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(t!==null)return this.logger.info(`State for virtual blockchain ${k.binaryToHexa(e)} found locally`),Y.decodeVirtualBlockchainState(t);{let t=await this.externalProvider.getSerializedVirtualBlockchainState(e);return t?(this.logger.info(`State for virtual blockchain ${k.binaryToHexa(e)} found online`),await this.internalProvider.setSerializedVirtualBlockchainState(e,t),Y.decodeVirtualBlockchainState(t)):null}}async getAccountIdByPublicKey(e){let t=await e.getPublicKeyAsBytes(),n=j.Hashes.sha256AsBinary(t);return await this.getAccountByPublicKeyHash(n)}async getProtocolState(){let e=await this.getProtocolVirtualBlockchainId(),t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Cannot get protocol parameters from the internal provider`);if(t.type!==V.PROTOCOL_VIRTUAL_BLOCKCHAIN)throw Error(`Expected protocol virtual blockchain, got ${V[t.type]}`);return Dx.createFromObject(t.internalState)}async getProtocolVirtualBlockchainId(){let e=await this.getObjectList(V.PROTOCOL_VIRTUAL_BLOCKCHAIN),t=e.list.length;if(t===0)throw this.logger.error(`No protocol virtual blockchain found: Expecting exactly one protocol virtual blockchain.`),Error(`No protocol virtual blockchain found`);return t!==1&&this.logger.warning(`Found `+t+` protocol virtual blockchains, expecting exactly one`),Cx.from(e.list[0])}async getAllAccounts(){return(await this.getObjectList(V.ACCOUNT_VIRTUAL_BLOCKCHAIN)).list.map(Cx.from)}async getAllValidatorNodes(){return(await this.getObjectList(V.NODE_VIRTUAL_BLOCKCHAIN)).list.map(Cx.from)}async getAllOrganizationIds(){return(await this.getObjectList(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN)).list.map(Cx.from)}async getAllApplicationIds(){return(await this.getObjectList(V.APPLICATION_VIRTUAL_BLOCKCHAIN)).list.map(Cx.from)}async getObjectList(e){return await this.externalProvider.getObjectList(e)}async getMicroblockInformation(e){let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e),n=await this.internalProvider.getMicroblockHeader(e);if(t&&n)return{...t,header:n};let r=await this.externalProvider.getMicroblockInformation(e);if(r){let t=Y.encodeVirtualBlockchainInfo({virtualBlockchainId:r.virtualBlockchainId,virtualBlockchainType:r.virtualBlockchainType});return await this.internalProvider.setMicroblockVbInformation(e,t),await this.internalProvider.setMicroblockHeader(e,r.header),r}return null}async getListOfMicroblockBody(e){let t=[],n=[],r=0;for(let i of e){let e=await this.internalProvider.getMicroblockBody(i);if(e){let n=Y.decodeMicroblockBody(e);t.push({hash:i,body:n})}else n.push(i);r+=1}if(n.length){let r=await this.externalProvider.getMicroblockBodys(n);if(r===null)throw Error(`Unable to load microblock bodies`);for(let{microblockBody:e,microblockHash:n}of r.list){let r=Y.encodeMicroblockBody(e);await this.internalProvider.setSerializedMicroblockBody(n,r),t.push({hash:n,body:e})}t.sort((t,n)=>e.indexOf(t.hash)-e.indexOf(n.hash))}return t.map(e=>e.body)}async getMicroblockBody(e){this.logger.info(`Looking for body for microblock ${e.encode()}`);let t=await this.internalProvider.getMicroblockBody(e.toBytes());if(t instanceof Uint8Array)return this.logger.info(`Body for microblock ${e.encode()} found locally`),Y.decodeMicroblockBody(t);{let t=await this.externalProvider.getMicroblockBodys([e.toBytes()]);if(t!==null&&t.list.length!==0){let n=t.list[0].microblockBody;return await this.internalProvider.setMicroblockBody(e.toBytes(),n),this.logger.info(`Body for microblock ${e.encode()} found online`),n}}return this.logger.warning(`Body for microblock ${e.encode()} not found`),null}async getMicroblockHeader(e){this.logger.info(`Looking for header for microblock ${e.encode()}`);let t=await this.internalProvider.getSerializedMicroblockHeader(e.toBytes());if(t instanceof Uint8Array){let n=j.Hashes.sha256(t),r=Y.decodeMicroblockHeader(t);return this.logger.info(`Header for microblock ${e.encode()} found locally (sha256:${n}): {header}`,{header:JSON.stringify(r)}),r}let n=await this.externalProvider.getMicroblockInformation(e.toBytes());if(n!==null)return this.logger.info(`Header for microblock ${e.encode()} found online: {header}:`,{header:n.header}),n.header;throw new te}async getVirtualBlockchainIdContainingMicroblock(e){this.logger.info(`Searching for virtual blockchain containing microblock ${e.encode()}`);let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e.toBytes());if(t!==null)return Cx.from(t.virtualBlockchainId);{let t=await this.externalProvider.getMicroblockInformation(e.toBytes());if(t!==null)return Cx.from(t.virtualBlockchainId);throw new te}}async getVirtualBlockchainHashes(e){let t=await this.getVirtualBlockchainStatus(e);if(t===void 0||t?.microblockHashes===void 0)throw Error(`Cannot access the virtual blockchain`);return t.microblockHashes}async getVirtualBlockchainHeaders(e,t){let n=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(n instanceof Uint8Array){let e=Y.decodeVirtualBlockchainState(n),r=e.height,i=e.lastMicroblockHash,o=[];for(;r>t;){let e=await this.internalProvider.getSerializedMicroblockHeader(i);if(e instanceof Uint8Array)o.push(e),i=Y.previousHashFromHeader(e),r--;else throw new a(`Cannot get the headers of a non-existing microblock ${k.binaryToHexa(i)}`)}return o}else throw new a(`Cannot get the headers of a non-existing VB`)}async getVirtualBlockchainStatus(e){let t=[],n=null,r=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(r!==null){n=Y.decodeVirtualBlockchainState(r);let i=n.height,a=n.lastMicroblockHash,o=[];for(;i;){let e=await this.internalProvider.getSerializedMicroblockHeader(a);if(!e)break;o.push(e),a=Y.previousHashFromHeader(e),i--}if(i==0){let n=Y.checkHeaderList(o);n.valid?(n.hashes.reverse(),k.binaryIsEqual(n.hashes[0],e)?t=n.hashes:this.logger.warning(`WARNING - genesis microblock hash from internal storage does not match VB identifier`)):this.logger.warning(`WARNING - inconsistent hash chain in internal storage`)}}let i=t.length,a=await this.externalProvider.getVirtualBlockchainUpdate(e,i);if(!a.exists)return null;if(a.changed){let r=Y.checkHeaderList(a.serializedHeaders);if(!r.valid)throw Error(`received headers are inconsistent`);if(i){let e=a.serializedHeaders.length,n=a.serializedHeaders[e-1],r=Y.previousHashFromHeader(n);if(!k.binaryIsEqual(r,t[i-1]))throw Error(`received headers do not link properly to the last known header`)}await this.internalProvider.setSerializedVirtualBlockchainState(e,a.serializedVirtualBlockchainState),n=Y.decodeVirtualBlockchainState(a.serializedVirtualBlockchainState);for(let t=0;t<a.serializedHeaders.length;t++)await this.internalProvider.setMicroblockVbInformation(r.hashes[t],Y.encodeVirtualBlockchainInfo({virtualBlockchainType:n.type,virtualBlockchainId:e})),await this.internalProvider.setSerializedMicroblockHeader(r.hashes[t],a.serializedHeaders[t]);t=[...t,...r.hashes.reverse()]}return n===null?null:{state:n,microblockHashes:t}}async getAccountIdFromPublicKey(e){let t=new rv,n=await this.externalProvider.getAccountByPublicKeyHash(t.hash(await e.getPublicKeyAsBytes()));return Cx.from(n.accountHash)}async publishMicroblock(e){this.logger.info(`Publishing microblock ${e.getHash().encode()}`);let{microblockData:t}=e.serialize();return await this.externalProvider.sendSerializedMicroblock(t),e.getHash()}async getNodeStatus(e){return jD.sendStatusQueryToNodeServer(e)}async getValidatorNodeIdByAddress(e){return(await this.externalProvider.getValidatorNodeByAddress(e.toBytes())).validatorNodeHash}async getValidatorNodeIdByCometbftPublicKey(e){let t=fg.bytesToBase64Encoder(),n=PD.convertRawPublicKeyIntoAddress(t.decode(e));return this.getValidatorNodeIdByAddress(Cx.from(n))}},ID=class{static createInMemoryProvider(){return new FD(new AC,new ND)}static createInMemoryProviderWithExternalProvider(e){return new FD(new AC,jD.createFromUrl(e))}static createNullInMemoryProviderWithExternalProvider(e){return new FD(new MD,jD.createFromUrl(e))}},LD=class extends jD{constructor(e){super(e)}},RD=F({jsonrpc:N(`2.0`),id:P(),result:F({query:I(),data:F({type:N(`tendermint/event/NewBlock`),value:F({block:F({header:F({version:F({block:I(),app:Qp(I())}),chain_id:I(),height:I(),time:I(),last_block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),last_commit_hash:I(),data_hash:I(),validators_hash:I(),next_validators_hash:I(),consensus_hash:I(),app_hash:I(),last_results_hash:I(),evidence_hash:I(),proposer_address:I()}),data:F({txs:M(I())}),evidence:F({evidence:M(Gp())}),last_commit:F({height:I(),round:P(),block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),signatures:M(F({block_id_flag:P(),validator_address:I(),timestamp:I(),signature:I()}))})}),block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),result_finalize_block:F({validator_updates:Qp(nm([Xp(),Gp()])),app_hash:I()})})}),events:F({"tm.event":M(I())})})}),zD=class e{ws;callbacks=[];constructor(e){this.ws=e,e.onmessage=this.onMessage.bind(this),e.onopen=this.onConnect.bind(this),e.onclose=this.onDisconnect.bind(this)}static new(t){return new e(new WebSocket(t))}addCallback(e){this.callbacks.push(e)}onConnect(e){this.ws.send(JSON.stringify({jsonrpc:`2.0`,method:`subscribe`,id:1,params:{query:`tm.event='NewBlock'`}}))}onMessage(e){let t=am(RD,JSON.parse(e.data));if(t.success){let e=t.output;this.onNewBlock(e)}}onNewBlock(e){for(let t of this.callbacks)t.onNewBlock&&t.onNewBlock(e)}onDisconnect(e){}},BD={parsePrefix:VD,toNumericPath:HD,fromNumericPath:UD,processCallback:GD,fromParents:WD};function VD(e){let t=/^(this|previous|block(\d+))(?=\.|\[)/.exec(e);if(!t)throw`invalid prefix for path '${e}'`;return{prefix:t[0],pathString:e.slice(t[0].length)}}function HD(e,t){return KD(e,t,!1).numericPath}function UD(e,t){let n=e[0],r=``;for(let e of t)n.type==2?(n=n.properties[e],r+=`.`+n.name):n.type==1&&(n=n.entries[e],r+=`[${n.index}]`);return r}function WD(e){let t=``;for(let n=1;n<e.length;n++){let r=e[n];t+=e[n-1].type==1?`[${r.index}]`:`.`+r.name}return t}function GD(e,t,n){let r=KD(e,t,!0);r.hasWildcard?(function e(t){for(let r of t)r.type==2?e(r.properties):r.type==1?e(r.entries):n(r)})(r.item):n(r.item)}function KD(e,t,n){let r=t.match(/\[(?:\*|\d+)\]|\.(?:\*|[^.*\[\]]+)/g);if(r.join(``)!=t)throw`invalid syntax for path '${t}'`;let i=[],a=e[0],o,s=!1;for(let e of r){if(s)throw`a wildcard cannot be followed by anything else`;switch(e[0]){case`.`:{let t=e.slice(1);if(a.type!=2)throw`cannot read property '${t}': the parent node is not an object`;if(t==`*`){if(!n)throw`a wildcard is not allowed`;a=a.properties,s=!0}else{if(o=a.properties.findIndex(e=>e.name==t),o==-1)throw`cannot find property '${t}'`;a=a.properties[o]}break}case`[`:{if(a.type!=1)throw`cannot read entry '${e}': the parent node is not an array`;let t=e.slice(1,-1);if(t==`*`){if(!n)throw`a wildcard is not allowed`;a=a.entries,s=!0}else{if(o=a.entries.findIndex(e=>e.index==t),o==-1)throw`cannot find index '${t}'`;a=a.entries[o]}break}}i.push(o)}if(!s)switch(a.type){case 2:throw`the last part of the path must be a primitive type${n?` (use .* to access all object properties)`:``}`;case 1:throw`the last part of the path must be a primitive type${n?` (use [*] to access all array entries)`:``}`}return{item:a,numericPath:i,hasWildcard:s}}var qD=class{nLeaves;tree;constructor(){this.tree=new wS}addItem(e,t){let n=this.getLeafInfo(e,t);e.attributes&2?this.addMaskableItem(e,n):e.attributes&1?this.addHashableItem(e,n):this.addRawItem(e,n)}getLeafInfo(e,t){let n=BD.fromParents(t),r=Qa.encode(n);if(r.length>65535)throw`path too long`;let i=new Uint8Array(r.length+3);return i[0]=e.type,i[1]=r.length>>8,i[2]=r.length&255,i.set(r,3),i}getWitnesses(e){let t=[];for(let n=0;n<this.nLeaves;n++)e.has(n)||t.push(n);return this.tree.getWitnesses(t).map(e=>k.binaryToHexa(e)).join(``)}},JD=class extends qD{leaves;pepper;saltCounter;sha512;constructor(e){super(),this.pepper=e||this.constructor.generatePepper(),this.saltCounter=0,this.leaves=[]}static generatePepper(){return j.Random.getBytes(32)}addLeaf(e,t){this.leaves.push({item:e,hash:j.Hashes.sha256AsBinary(t)})}generateTree(){this.nLeaves=this.leaves.length,this.leaves.sort((e,t)=>k.binaryCompare(e.hash,t.hash));for(let e in this.leaves)this.tree.addLeaf(this.leaves[+e].hash),this.leaves[+e].item.leafIndex=+e;this.tree.finalize();let e=this.tree.getRootHash();return{nLeaves:this.leaves.length,rootHash:k.binaryToHexa(e),pepper:k.binaryToHexa(this.pepper)}}addRawItem(e,t){let n=this.getSalt();e.salt=k.binaryToHexa(n),this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addHashableItem(e,t){let n=this.getSalt(),r=j.Hashes.sha256AsBinary(e.valueBinary);e.hash=k.binaryToHexa(r),e.salt=k.binaryToHexa(n),this.addLeaf(e,k.binaryFrom(n,t,r))}addMaskableItem(e,t){let n=this.getSalt(),r=j.Hashes.sha256AsBinary(k.binaryFrom(n,t,e.visiblePartsBinary)),i=this.getSalt(),a=j.Hashes.sha256AsBinary(k.binaryFrom(i,e.hiddenPartsBinary));e.visibleSalt=k.binaryToHexa(n),e.hiddenSalt=k.binaryToHexa(i),e.hiddenHash=k.binaryToHexa(a),this.addLeaf(e,k.binaryFrom(r,a))}getSalt(){let e=this.saltCounter&3,t=this.saltCounter++>>2;return e||(this.sha512=j.Hashes.sha512AsBinary(k.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},YD=class extends qD{nLeaves;witnesses;constructor(e,t){super(),this.nLeaves=e,this.witnesses=(t.match(/.{64}/g)||[]).map(e=>k.binaryFromHexa(e))}addLeaf(e,t){this.tree.setLeaf(e.leafIndex,j.Hashes.sha256AsBinary(t))}generateTree(){this.tree.finalize(this.nLeaves),this.tree.setWitnesses(this.witnesses);let e=this.tree.getRootHash();return{nLeaves:this.tree.getNumberOfLeaves(),rootHash:k.binaryToHexa(e)}}addRawItem(e,t){let n=k.binaryFromHexa(e.salt);this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addHashableItem(e,t){let n=k.binaryFromHexa(e.salt),r;e.hash?r=k.binaryFromHexa(e.hash):(r=j.Hashes.sha256AsBinary(e.valueBinary),e.hash=r),this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addMaskableItem(e,t){let n=k.binaryFromHexa(e.visibleSalt),r=j.Hashes.sha256AsBinary(k.binaryFrom(n,t,e.visiblePartsBinary)),i;if(e.hiddenHash)i=k.binaryFromHexa(e.hiddenHash);else{let t=k.binaryFromHexa(e.hiddenSalt);i=j.Hashes.sha256AsBinary(k.binaryFrom(t,e.hiddenPartsBinary)),e.hiddenHash=k.binaryToHexa(i)}this.addLeaf(e,k.binaryFrom(r,i))}},XD={getListFromRegex:ZD,applyMask:QD,getVisibleText:$D,getFullText:eO};function ZD(e,t,n){let r=(t.exec(e)||[]).slice(1);if(r.join(``)!=e)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>[t&1,e]).filter(e=>e[1]);if(i.length!=r.length||i.some(([e,t],n)=>e&&t!=`$`+(n+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;return i.forEach(([e,t],n)=>{let i=o+r[n].length;e||a.push([o,i,t]),o=i}),a}function QD(e,t){let n=[],r=[];return t.sort((e,t)=>e[0]-t[0]),t.forEach(([i,a,o],s)=>{let[c,l]=s?t[s-1]:[0,0];if(i<0||i>=e.length||a<=i)throw`invalid interval [${[i,a]}]`;if(i<l)throw`overlapping intervals [${[c,l]}] / [${[i,a]}]`;let u=e.slice(i,a);s&&i==l?(n[n.length-1]+=o,r[r.length-1]+=u):(n.push(e.slice(l,i),o),r.push(u)),s==t.length-1&&a<e.length&&n.push(e.slice(a))}),{visible:n,hidden:r}}function $D(e){return e.join(``)}function eO(e,t){return e.map((e,n)=>n&1?t[n>>1]:e).join(``)}var tO=24,nO=class e{importedFromProof;channelDefinitions;irObject=[];object;usedChannels=[];constructor(){this.irObject=[],this.importedFromProof=!1,this.channelDefinitions=new Map,this.object={recordData:this.irObject}}static getItemInstance(e){return{type:e,index:-1,name:``,properties:[],entries:[],value:null,attributes:0,channelId:null,channels:new Set,visibleParts:[],visiblePartsBinary:new Uint8Array,hiddenParts:[],hiddenPartsBinary:new Uint8Array,valueBinary:new Uint8Array,leafIndex:-1,salt:new Uint8Array,visibleSalt:new Uint8Array,hiddenSalt:new Uint8Array,hash:new Uint8Array,hiddenHash:new Uint8Array}}addPublicChannel(e){if(this.channelDefinitions.has(e))throw Error(`channel ${e} was already added`);this.channelDefinitions.set(e,{id:e,isPrivate:!1})}addPrivateChannel(e){if(this.channelDefinitions.has(e))throw Error(`channel ${e} was already added`);this.channelDefinitions.set(e,{id:e,isPrivate:!0,pepper:JD.generatePepper()})}buildFromJson(t){let n=[];this.importedFromProof=!1,i({root:t},n,!1),this.irObject=n;function r(t,n,r,a){let o=t[n],s=ro.getType(o);if(!ro.isJsonType(s))throw Error(`Invalid JSON type`);let c=e.getItemInstance(s);a?c.index=+n:c.name=n,s==2?(c.properties=[],i(o,c.properties,!1)):s==1?(c.entries=[],i(o,c.entries,!0)):(c.value=o,c.attributes=0,c.channelId=null),r.push(c)}function i(e,t,n){for(let i in e)r(e,i,t,n)}}exportToSectionFormat(){let e=[];for(let t of this.usedChannels){let n=this.channelDefinitions.get(t);if(n){let r=this.exportChannelToSectionFormat(n),i;i=n.isPrivate?{isPrivate:!0,channelId:t,data:r,merkleRootHash:this.getMerkleRootHash(t)}:{isPrivate:!1,channelId:t,data:r},e.push(i)}}return e}exportChannelToSectionFormat(e){let t=new Av;e.isPrivate&&t.writeByteArray(e.pepper);let n=this.buildDictionary(e.id);t.writeVarUint(n.length);for(let e of n)t.writeString(e);return this.traverseIrObject({channelId:e.id,onObject:(e,n,a,o)=>{o.length>1&&r(e,a),t.writeByte(e.type),t.writeVarUint(i(e.properties))},onArray:(e,n,a,o)=>{o.length>1&&r(e,a),t.writeByte(e.type),t.writeVarUint(i(e.entries))},onPrimitive:(e,n,i,a)=>{r(e,i),t.writeByte(e.type|e.attributes<<3),e.attributes==2?(t.writeByteArray(e.visiblePartsBinary),t.writeByteArray(e.hiddenPartsBinary)):t.writeByteArray(e.valueBinary)}}),t.getByteStream();function r(e,r){t.writeVarUint(r?e.index:n.indexOf(e.name))}function i(t){return t.reduce((t,n)=>t+=n.type==1||n.type==2?+!!n.channels.has(e.id):+(n.channelId===e.id),0)}}importFromSectionFormat(e){this.importedFromProof=!1;for(let t of e){let e=this.channelDefinitions.get(t.channelId);if(e&&(this.importChannelFromSectionFormat(e,t.data),e.isPrivate)){let e=this.getMerkleRootHash(t.channelId);if(e!=t.merkleRootHash)throw Error(`inconsistent Merkle root hash (expected: ${t.merkleRootHash}, computed: ${e})`)}}this.populateChannels()}importChannelFromSectionFormat(t,n){let r=new jv(n);t.isPrivate&&(t.pepper=r.readByteArray(32));let i=r.readVarUint(),a=[];for(let e=0;e<i;e++)a.push(r.readString());o(this.irObject,!1,!0);function o(n,i,o=!1){let l=o?-1:r.readVarUint(),u=i?``:o?`root`:a[l],d=r.readByte(),f=d&7,p=d>>3,m;(f==2||f==1)&&(m=n.find(e=>i?e.index==l:e.name==u));let h,g;if(m===void 0?(g=e.getItemInstance(f),h=!0,i?g.index=l:g.name=u):(g=m,h=!1),f==2)g.channels.add(t.id),s(g);else if(f==1)g.channels.add(t.id),c(g,!h);else{if(p==2){let e;g.visibleParts=[],g.hiddenParts=[],e=r.getPointer();for(let e=r.readVarUint();e--;)g.visibleParts.push(r.readString());g.visiblePartsBinary=r.extractFrom(e),e=r.getPointer();for(let e=r.readVarUint();e--;)g.hiddenParts.push(r.readString());g.hiddenPartsBinary=r.extractFrom(e),g.value=XD.getFullText(g.visibleParts,g.hiddenParts)}else g.value=r.readJsonValue(f),g.valueBinary=r.getLastField();g.attributes=p,g.channelId=t.id}h&&n.push(g)}function s(e){let t=r.readVarUint();e.properties=e.properties||[];for(let n=0;n<t;n++)o(e.properties,!1)}function c(e,t){let n=r.readVarUint();e.entries=e.entries||[];for(let t=0;t<n;t++)o(e.entries,!0);t&&e.entries.sort((e,t)=>e.index-t.index)}}exportToProof(){let t=new e,n=[];for(let e of this.usedChannels){let r=this.channelDefinitions.get(e);if(r===void 0||!r.isPrivate)continue;let i=this.getMerklizer(e),a=i.generateTree(),o=new Set;this.traverseIrObject({channelId:e,onPrimitive:(e,n,r,i)=>{if(!(e.attributes&4)){o.add(e.leafIndex);let n=t.createBranch(i);n.attributes=e.attributes,n.channelId=e.channelId,n.leafIndex=e.leafIndex,e.attributes&2?(n.visibleSalt=e.visibleSalt,n.visibleParts=e.visibleParts,e.attributes&16?n.hiddenHash=e.hiddenHash:(n.hiddenSalt=e.hiddenSalt,n.hiddenParts=e.hiddenParts)):e.attributes&1?(n.salt=e.salt,e.attributes&8?n.hash=e.hash:n.value=e.value):(n.salt=e.salt,n.value=e.value)}}}),n.push({channelId:e,nLeaves:a.nLeaves,witnesses:i.getWitnesses(o)})}return t.object.merkleData=n,t.object}importFromProof(e){this.importedFromProof=!0,this.object=e,this.irObject=e.recordData,this.populateChannels(),this.serializeFields();let t=[];for(let e of this.usedChannels){let n=this.channelDefinitions.get(e);if(n){if(!n.isPrivate)continue;let r=this.getMerklizer(e).generateTree();t.push({channelId:e,rootHash:r.rootHash})}}return t}createBranch(t){let n=this.irObject,r=!1,i;for(let e of t)if(e.type==2||e.type==1){let t=n.find(t=>r?t.index==e.index:t.name==e.name);t===void 0&&(t=a(e),e.type==2?t.properties=[]:t.entries=[],n.push(t)),r=t.type==1,n=r?t.entries:t.properties}else{i=a(e),n.push(i);break}if(i===void 0)throw Error(`internal error: failed to create a branch`);return i;function a(t){let n=e.getItemInstance(t.type);return r?n.index=t.index:n.name=t.name,n}}getMerkleRootHash(e){return this.getMerklizer(e).generateTree().rootHash}getMerklizer(e){let t;if(this.importedFromProof){let n=this.object.merkleData.find(t=>t.channelId==e);t=new YD(n.nLeaves,n.witnesses)}else{let n=this.channelDefinitions.get(e);if(n&&n.isPrivate)t=new JD(n.pepper);else throw Error(`internal error: cannot compute the merklizer for either undefined channel or public channel`)}return this.traverseIrObject({channelId:e,onPrimitive:(e,n,r,i)=>{t.addItem(e,i)}}),t}getIRObject(){return this.irObject}dumpIRObject(){return JSON.stringify(this.irObject,(e,t)=>t instanceof Uint8Array?[`<${t.length} byte(s)>`,...[...t.slice(0,tO)].map(e=>e.toString(16).toUpperCase().padStart(2,`0`))].join(` `)+(t.length>tO?` ..`:``):t instanceof Set?[...t]:t,2)}setChannel(e,t){if(!this.channelDefinitions.has(t))throw`channel ${t} is undefined`;this.processPath(e,e=>{e.channelId=t})}setAsMaskable(e,t){this.processPath(e,e=>{let n=XD.applyMask(e.value,t);e.visibleParts=n.visible,e.hiddenParts=n.hidden,e.attributes=2})}setAsMaskableByRegex(e,t,n){this.processPath(e,e=>{let r=XD.getListFromRegex(e.value,t,n),i=XD.applyMask(e.value,r);e.visibleParts=i.visible,e.hiddenParts=i.hidden,e.attributes=e.attributes&-4|2})}setAsHashable(e){this.processPath(e,e=>{e.attributes=e.attributes&-4|1})}setAsRedacted(e){this.processPath(e,e=>{e.attributes=e.attributes&-29|4})}setAsMasked(e){this.processPath(e,e=>{if(!(e.attributes&2))throw`this item is not maskable`;if(e.attributes&28)throw`the format of this item was already set`;e.attributes=e.attributes&-29|16})}setAsHashed(e){this.processPath(e,e=>{if(!(e.attributes&1))throw`this item is not hashable`;if(e.attributes&28)throw`the format of this item was already set`;e.attributes=e.attributes&-29|8})}processPath(e,t){let n=e.split(/, */);for(let e of n){let n=BD.parsePrefix(e);if(n.prefix!=`this`)throw`the path must start with 'this'`;BD.processCallback(this.irObject,n.pathString,t)}}finalizeChannelData(){this.serializeFields(),this.populateChannels()}populateChannels(){this.traverseIrObject({onPrimitive:(e,t,n,r)=>{for(let t=0;t<r.length-1;t++){if(e.channelId===null)throw Error(`field '${BD.fromParents(r)}' is not assigned to any channel`);(r[t].channels=r[t].channels||new Set).add(e.channelId)}}});let e=this.irObject[0];e===void 0?this.usedChannels=[]:this.usedChannels=[...e.channels].sort((e,t)=>e-t);for(let e of this.usedChannels)if(!this.channelDefinitions.has(e))throw Error(`channel ${e} is undefined`)}buildDictionary(e){let t=new Map;this.traverseIrObject({channelId:e,onObject:(e,t,r,i)=>{i.length>1&&!r&&n(e)},onArray:(e,t,r,i)=>{r||n(e)},onPrimitive:(e,t,r,i)=>{r||n(e)}});function n(e){t.set(e.name,t.has(e.name)?t.get(e.name)+1:1)}let r=[];for(let[e,n]of t)r.push([n,e]);return[...new Map([...r.sort((e,t)=>t[0]-e[0]).map((e,t)=>[e[1],t])]).keys()]}serializeFields(){this.traverseIrObject({onPrimitive:(e,t,n,r)=>{let i=new Av;if(e.attributes&2){i.writeVarUint(e.visibleParts.length);for(let t of e.visibleParts)i.writeString(t);if(e.visiblePartsBinary=i.getByteStream(),!(e.attributes&16)){i.clear(),i.writeVarUint(e.hiddenParts.length);for(let t of e.hiddenParts)i.writeString(t);e.hiddenPartsBinary=i.getByteStream()}}else e.attributes&8||(i.writeJsonValue(e.type,e.value),e.valueBinary=i.getByteStream())}})}traverseIrObject(e){r(this.irObject,e.initialContext,!1,[]);function t(t,n){return e.channelId===void 0||(n?t.channelId===e.channelId:t.channels.has(e.channelId))}function n(n,i,a,o){let s=[...o,n];if(n.type==1){if(t(n,!1)){let t=e.onArray&&e.onArray(n,i,a,s);r(n.entries,t,!0,s)}}else if(n.type==2){if(t(n,!1)){let t=e.onObject&&e.onObject(n,i,a,s);r(n.properties,t,!1,s)}}else t(n,!0)&&e.onPrimitive&&e.onPrimitive(n,i,a,s)}function r(e,t,r,i){for(let a of e)n(a,t,r,i)}}exportToJson(){let e={root:null};return this.traverseIrObject({initialContext:e,onArray:(e,t,n)=>t[n?e.index:e.name]=[],onObject:(e,t,n)=>t[n?e.index:e.name]={},onPrimitive:(e,t,n,r)=>{t[n?e.index:e.name]=e.value}}),e.root===null?{}:e.root}},rO=class{static async encode(e,t){let n=[],r=[],i=e.split(/(\{\{.+?\}\})/);for(let e in i){let a=i[e];if(e&1){let e=a.slice(2,-2).trim(),n=BD.parsePrefix(e),i=await t(n.blockIndex),o=BD.toNumericPath(i,n.pathString);r.push(o)}else n.push(a)}for(;n[n.length-1]==``;)n.pop();return{texts:n,fields:r}}static async decode(e,t){for(let n of e.fields){let e=await t(0),r=BD.fromNumericPath(e,n);console.log(r)}}},iO=2,aO=32,oO={CACHE_HORIZON:iO,HASH_SIZE:aO,ROOT_ANCHORING_HASH:new Uint8Array(aO)},sO={keyDifference:cO,getHashList:lO};function cO(e,t,n){for(let r=e;r<oO.HASH_SIZE*2;r++)if((t[r>>1]^n[2+(r>>1)-(e>>1)])>>4*(r&1)&15)return 1;return 0}function lO(e,t){let n=[],r=2;for(let i=0;i<16;i++)n.push(e&1<<i?t.slice(r,r+=oO.HASH_SIZE):null);return n}var uO={verifyProof:dO};async function dO(e,t,n){return await fO(e,t,n,null,0)&&j.Hashes.sha256AsBinary(n[0])}async function fO(e,t,n,r,i){if(i==oO.HASH_SIZE*2)return k.binaryIsEqual(r,t);let a=n[i];if(i&&!k.binaryIsEqual(j.Hashes.sha256AsBinary(a),r))return!1;let o=a[0]<<8|a[1];if(o){let r=sO.getHashList(o,a),s=e[i>>1]>>4*(i&1)&15;return o&1<<s?await fO(e,t,n,r[s],i+1):t===!1}if(sO.keyDifference(i,e,a))return t===!1;let s=oO.HASH_SIZE*2+1-i>>1;return k.binaryIsEqual(a.slice(2+s),t)}var pO=class{transaction;constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Cx.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getLinkedAccount(){return Cx.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return mn.createAtomic(this.transaction.amount*e)}getChainReference(){return Cx.from(this.transaction.chainReference)}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},mO=class{transactionByHeight;constructor(){this.transactionByHeight=new Map}setTransactionAtHeight(e,t){this.transactionByHeight.set(e,t)}containsTransactions(){return this.transactionByHeight.size>0}getTransactionHeights(){return Array.from(this.transactionByHeight.keys())}getAllTransactions(){return Array.from(this.transactionByHeight.values()).map(e=>new pO(e))}getNumberOfTransactions(){return this.transactionByHeight.size}containsTransactionAtHeight(e){return this.transactionByHeight.has(e)}getTransactionAtHeight(e){let t=this.transactionByHeight.get(e);if(t===void 0)throw new i(`No transaction found at height ${e}`);return new pO(t)}},hO={[V.PROTOCOL_VIRTUAL_BLOCKCHAIN]:`PROTOCOL_VIRTUAL_BLOCKCHAIN`,[V.NODE_VIRTUAL_BLOCKCHAIN]:`NODE_VIRTUAL_BLOCKCHAIN`,[V.APPLICATION_VIRTUAL_BLOCKCHAIN]:`APPLICATION_VIRTUAL_BLOCKCHAIN`,[V.ORGANIZATION_VIRTUAL_BLOCKCHAIN]:`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,[V.APP_LEDGER_VIRTUAL_BLOCKCHAIN]:`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,[V.ACCOUNT_VIRTUAL_BLOCKCHAIN]:`ACCOUNT_VIRTUAL_BLOCKCHAIN`},gO=class{static getVirtualBlockchainLabelFromVirtualBlockchainType(e){return hO[e]}},_O;(function(e){e.AUTH_BY_PUBLIC_KEY=`WALLET_REQUEST_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_REQUEST_DATA_APPROVAL`})(_O||={});var vO;(function(e){e.AUTH_BY_PUBLIC_KEY=`WALLET_RESPONSE_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_RESPONSE_DATA_APPROVAL`})(vO||={});var yO=F({type:N(_O.AUTH_BY_PUBLIC_KEY),base64EncodedChallenge:I()}),bO=F({type:N(_O.DATA_APPROVAL),anchorRequestId:I(),serverUrl:I()}),xO=im(`type`,[yO,bO]),SO=F({type:N(vO.AUTH_BY_PUBLIC_KEY),publicKey:I(),signature:I()}),CO=F({type:N(vO.DATA_APPROVAL),b64VbHash:I(),b64MbHash:I(),height:P()}),wO=im(`type`,[SO,CO]),TO=100,EO;(function(e){e.REQUEST=`CLIENT_BRIDGE_REQUEST`,e.UPDATE_QR=`CLIENT_BRIDGE_UPDATE_QR`,e.CONNECTION_TOKEN=`CLIENT_BRIDGE_CONNECTION_TOKEN`,e.FORWARDED_ANSWER=`CLIENT_BRIDGE_FORWARDED_ANSWER`,e.GET_CONNECTION_INFO=`CLIENT_BRIDGE_GET_CONNECTION_INFO`,e.ANSWER=`CLIENT_BRIDGE_ANSWER`,e.CONNECTION_INFO=`CLIENT_BRIDGE_CONNECTION_INFO`,e.CONNECTION_ACCEPTED=`CLIENT_BRIDGE_CONNECTION_ACCEPTED`,e.FORWARDED_REQUEST=`CLIENT_BRIDGE_FORWARDED_REQUEST`,e.ERROR=`CLIENT_BRIDGE_ERROR`})(EO||={});var DO=F({base64EncodedQrId:I(),timestamp:P(),serverUrl:R(I(),Rp(100))}),OO=F({type:N(EO.REQUEST),walletRequest:xO,deviceId:Am(),withToken:P()}),kO=F({type:N(EO.UPDATE_QR),base64EncodedQrId:I(),timestamp:P()}),AO=F({type:N(EO.CONNECTION_TOKEN),token:Am()}),jO=F({type:N(EO.FORWARDED_ANSWER),walletResponse:wO}),MO=F({type:N(EO.GET_CONNECTION_INFO),base64EncodedQrId:I()}),NO=F({type:N(EO.ANSWER),walletResponse:wO}),PO=F({type:N(EO.CONNECTION_INFO)}),FO=F({type:N(EO.CONNECTION_ACCEPTED),base64EncodedQrId:I()}),IO=F({type:N(EO.FORWARDED_REQUEST),walletRequest:xO}),LO=F({type:N(EO.ERROR),errorMessage:I()}),RO=im(`type`,[OO,kO,AO,jO,MO,NO,PO,FO,IO,LO]),zO=class{static encode(e){return ux(L(RO,e))}static decode(e){return L(RO,Nb(e))}},BO=class{static validateClientBridgeMessage(e){return L(RO,e)}},VO=class{static encode(e){return ux(L(DO,e))}static decode(e){return L(DO,Nb(e))}},HO=em(I(),F({networkName:Qp(I()),nodes:em(I(),F({nodeName:Qp(I()),hostname:I(),rpcEndpoint:I(),p2pEndpoint:I(),trusted:Qp(Kp(),!1),nodeId:I()}))})),UO=F({state:Bh,microblockHashes:M(B())}),WO;(function(e){e.APPROVAL_HANDSHAKE=`WALLET_OPERATOR_REQUEST_APPROVAL_HANDSHAKE`,e.ACTOR_KEY=`WALLET_OPERATOR_REQUEST_ACTOR_KEY`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_REQUEST_APPROVAL_SIGNATURE`})(WO||={});var GO;(function(e){e.ERROR=`WALLET_OPERATOR_RESPONSE_ERROR`,e.ACTOR_KEY_REQUIRED=`WALLET_OPERATOR_RESPONSE_ACTOR_KEY_REQUIRED`,e.APPROVAL_DATA=`WALLET_OPERATOR_RESPONSE_APPROVAL_DATA`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_RESPONSE_APPROVAL_SIGNATURE`})(GO||={});var KO=F({type:N(WO.APPROVAL_HANDSHAKE),anchorRequestId:I()}),qO=F({type:N(WO.ACTOR_KEY),anchorRequestId:I(),actorSignaturePublicKey:I(),actorPkePublicKey:I()}),JO=F({type:N(WO.APPROVAL_SIGNATURE),anchorRequestId:I(),b64Signature:I()}),YO=im(`type`,[KO,qO,JO]),XO=F({type:N(GO.ERROR),errorMessage:Qp(I(),``)}),ZO=F({type:N(GO.ACTOR_KEY_REQUIRED),b64GenesisSeed:I()}),QO=F({type:N(GO.APPROVAL_DATA),b64SerializedMicroblock:I()}),$O=F({type:N(GO.APPROVAL_SIGNATURE),b64VbHash:I(),b64MbHash:I(),height:P()}),ek=im(`type`,[XO,ZO,QO,$O]),tk=class{static encodeRequest(e){return ux(L(xO,e))}static decodeRequest(e){return L(xO,Nb(e))}static encodeResponse(e){return ux(L(wO,e))}static decodeResponse(e){return L(wO,Nb(e))}},nk=class{static validateWalletRequest(e){return L(xO,e)}static validateWalletResponse(e){return L(wO,e)}},rk=class{stringEncoder;constructor(e=new pg){this.stringEncoder=e}decode(e){let t=this.getPrefix(),n=gg.decode(e);if(n.matchesKeys(...t))return this.stringEncoder.decode(n.getValue());throw new l(`Invalid seed format`)}encode(e){let t=this.getPrefix();return gg.encode(...t,this.stringEncoder.encode(e))}getPrefix(){return[`SEED`]}},ik=class extends rk{getPrefix(){return[`ACCOUNT`,`SEED`]}},ak=class e{transactions;static createFromAbciResponse(t){return new e(t.list)}constructor(e){this.transactions=e}containsTransactions(){return this.transactions.length>0}getTransactions(){return this.transactions.map(e=>new ok(e))}},ok=class{transaction;constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Cx.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getTransactionTypeLabel(){return this.isEarnedFees()?`Earned fees`:this.isPaidFees()?`Paid fees`:this.isSentPayment()?`Sent payment`:this.isReceivedPayment()?`Received payment`:this.isPurchase()?`Purchase`:this.isSentIssuance()?`Sent issuance`:this.isReceivedIssuance()?`Received issuance`:this.isSale()?`Sale`:`Transaction`}getLinkedAccount(){return Cx.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return mn.createAtomic(this.transaction.amount*e)}getChainReference(){return Cx.from(this.transaction.chainReference)}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},sk=class extends rk{getPrefix(){return[`ACTOR`,`SEED`]}},ck=class e{initialBalance;initialLocks;static createFromAccountStateAbciResponse(t){return new e(t.balance,t.locks)}logger=ts.getLogger([`accounts`,e.name]);balanceInAtomics;locks;constructor(t=0,n=[]){this.initialBalance=t,this.initialLocks=n,this.balanceInAtomics=t,this.locks=n,this.logger=lo([`node`,`accounts`,e.name])}setBalance(e){this.balanceInAtomics=e}getBalanceAsAtomics(){return this.balanceInAtomics}getBalance(){return mn.createAtomic(this.balanceInAtomics)}setLocks(e){this.locks=[...e]}getLocks(){return this.locks}hasNodeStakingLocks(){return this.locks.some(e=>e.type==Wh.NodeStaking)}getNodeStakingLocks(){return this.locks.filter(e=>e.type==Wh.NodeStaking)}getNodeStakingLock(e){return this.getNodeStakingLocks().find(t=>k.binaryIsEqual(t.parameters.validatorNodeId,e))}getNodeStakingLockAmount(e){let t=this.getNodeStakingLock(e);return t===void 0?0:t.lockedAmountInAtomics}hasEscrowLocks(){return this.locks.some(e=>e.type==Wh.Escrow)}getEscrowLocks(){return this.locks.filter(e=>e.type==Wh.Escrow)}hasVestingLocks(){return this.locks.some(e=>e.type==Wh.Vesting)}getVestingLocks(){return this.locks.filter(e=>e.type==Wh.Vesting)}removeExpiredEscrowLocks(){this.removeExpiredLocks(Wh.Escrow)}removeExpiredVestingLocks(){this.removeExpiredLocks(Wh.Vesting)}removeExpiredStakingLocks(){this.removeExpiredLocks(Wh.NodeStaking)}removeExpiredLocks(e){this.locks=this.locks.filter(t=>!(t.type==e&&t.lockedAmountInAtomics==0))}addSpendableTokens(e){this.balanceInAtomics+=e}addVestedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:Wh.Vesting,lockedAmountInAtomics:e,parameters:t})}addEscrowedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:Wh.Escrow,lockedAmountInAtomics:e,parameters:t})}releaseEscrowedTokens(e,t){let n=this.locks.findIndex(t=>t.type==Wh.Escrow&&k.binaryIsEqual(t.parameters.fundEmitterAccountId,e));if(n==-1)throw Error(`Escrow not found`);this.locks.splice(n,1)}addNodeStaking(e,t){let n=this.getBreakdown();if(e<0)throw Error(`Stake amount must be greater than 0`);if(e>n.stakeable)throw Error(`Cannot stake more than ${n.stakeable} atomic units`);let r=this.getNodeStakingLock(t);r===void 0?this.locks.push({type:Wh.NodeStaking,lockedAmountInAtomics:e,parameters:{validatorNodeId:t,plannedUnlockAmountInAtomics:0,plannedUnlockTimestamp:0,slashed:!1,plannedSlashingAmountInAtomics:0,plannedSlashingTimestamp:0}}):r.lockedAmountInAtomics+=e}planNodeStakingUnlock(e,t,n){let r=this.getNodeStakingLock(n);if(r===void 0)throw Error(`Staking not found`);if(r.parameters.plannedUnlockAmountInAtomics!=0)throw Error(`There's already a pending staking unlock for this node`);r.parameters.plannedUnlockAmountInAtomics=e,r.parameters.plannedUnlockTimestamp=k.addDaysToTimestamp(t,0)}applyNodeStakingUnlocks(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.plannedUnlockTimestamp!=0&&e>=r.parameters.plannedUnlockTimestamp){let e=r.parameters.plannedUnlockAmountInAtomics;this.removeNodeStaking(e,r.parameters.validatorNodeId),n+=e}return this.removeExpiredStakingLocks(),n}setSlashing(e,t){let n=this.getNodeStakingLocks().find(t=>t.parameters.validatorNodeId==e);if(n==null)throw Error(`Staking not found`);n.parameters.slashed=!0,n.parameters.plannedSlashingAmountInAtomics=n.lockedAmountInAtomics,n.parameters.plannedSlashingTimestamp=t}cancelNodeSlashing(e){let t=this.getNodeStakingLocks().find(t=>t.parameters.validatorNodeId==e);if(t==null)throw Error(`Staking not found`);t.parameters.slashed?(t.parameters.slashed=!1,t.parameters.plannedSlashingAmountInAtomics=0,t.parameters.plannedSlashingTimestamp=0):this.logger.warn(`No pending slashing for this node`)}applyNodeSlashing(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.slashed){let t=r.parameters.plannedSlashingAmountInAtomics;t>0&&r.parameters.plannedSlashingTimestamp!=0&&e>=r.parameters.plannedSlashingTimestamp&&(r.lockedAmountInAtomics-=t,this.balanceInAtomics-=t,n+=t,r.parameters.slashed=!1,r.parameters.plannedSlashingTimestamp=0,r.parameters.plannedSlashingAmountInAtomics=0)}return this.adjustVesting(),this.removeExpiredStakingLocks(),n}adjustVesting(){let e=this.getBreakdown().vested,t=e-this.balanceInAtomics;if(t>0){let n=this.getVestingLocks(),r=0;for(let i of n){let n=Math.floor(t*i.lockedAmountInAtomics/e);i.lockedAmountInAtomics-=n,r+=n}for(let e of n)r<t&&e.lockedAmountInAtomics>0&&(e.lockedAmountInAtomics--,r++);this.removeExpiredVestingLocks()}}removeNodeStaking(e,t){let n=this.getNodeStakingLock(t);if(n===void 0)throw Error(`Staking not found`);if(e<0)throw Error(`Unstake amount must be greater than 0`);if(e>n.lockedAmountInAtomics)throw Error(`Cannot unstake more than ${n.lockedAmountInAtomics} atomic units`);n.lockedAmountInAtomics-=e}applyLinearVesting(e){let t=this.getBreakdown().releasable,n=0,r=this.getVestingLocks();for(let i of r){let r=i.parameters.initialVestedAmountInAtomics,a=i.parameters.cliffStartTimestamp,o=i.parameters.cliffDurationDays,s=i.parameters.vestingDurationDays,c=k.addDaysToTimestamp(a,o),l=Math.min(k.timestampDifferenceInDays(c,e),s);if(this.logger.debug(`start date: {cliffStartDate}, initial amount: {initialAmount}, cliff during {cliffDurationDays} day(s), vesting during {vestingDurationDays} day(s)`,()=>({cliffStartDate:new Date(a*1e3).toISOString(),initialAmount:r,cliffDurationDays:o,vestingDurationDays:s})),this.logger.debug(`cliff end date: {cliffEndDay}, today: {today}, elapsed time in vesting: {elapsed} day(s)`,()=>({cliffEndDay:new Date(c*1e3).toISOString(),today:new Date(e*1e3).toISOString(),elapsed:l})),l>0){let e=r-i.lockedAmountInAtomics,a=Math.floor(r*l/s),o=Math.min(a-e,t);this.logger.debug(`already released: ${e}, max. release: ${a}, released today: ${o}`),i.lockedAmountInAtomics-=o,t-=o,n+=o}else this.logger.debug(`nothing is released today`)}return this.removeExpiredVestingLocks(),n}getBreakdown(){let e=new Map;for(let t of this.locks){let n=e.get(t.type)||0;e.set(t.type,n+t.lockedAmountInAtomics)}let t=e.get(Wh.Escrow)||0,n=e.get(Wh.Vesting)||0,r=e.get(Wh.NodeStaking)||0,i=this.balanceInAtomics-r-t,a=Math.max(0,n-r),o=t+Math.max(n,r),s=this.balanceInAtomics-o;return{balance:this.balanceInAtomics,escrowed:t,vested:n,releasable:a,staked:r,stakeable:i,locked:o,spendable:s}}getSpendable(){return mn.createAtomic(this.getBreakdown().spendable)}getVested(){return mn.createAtomic(this.getBreakdown().vested)}getStakeable(){return mn.createAtomic(this.getBreakdown().stakeable)}getStaked(){return mn.createAtomic(this.getBreakdown().staked)}},lk=class{static encoder=new Zb({tagUint8Array:!0,mapsAsObjects:!0});static encodeRequest(e){return this.encoder.encode(L(YO,e))}static decodeRequest(e){return L(YO,this.encoder.decode(e))}static encodeResponse(e){return this.encoder.encode(L(ek,e))}static decodeResponse(e){return L(ek,this.encoder.decode(e))}},uk=class{static validateRequest(e){return L(YO,e)}static validateResponse(e){return L(ek,e)}},dk=class extends rk{getPrefix(){return[`WALLET`,`SEED`]}},fk=class e{actorSeed;constructor(e){this.actorSeed=e}static createFromAccountSeedAndVbSeed(t,n){return new e(k.binaryFrom(t,n))}static parseFromString(t,n=new rk){return new e(n.decode(t))}encode(e=new rk){return e.encode(this.actorSeed)}getSeedAsBytes(){return this.actorSeed}async getPrivateSignatureKey(e){let t=Bv.createDefaultKDF(),n=this.encoderStringAsBytes(`SIG`),r=t.deriveKeyNoSalt(this.actorSeed,n,32);return Bv.createPrivateSignatureKey(e,r)}async getPublicSignatureKey(e){return(await this.getPrivateSignatureKey(e)).getPublicKey()}getPrivateDecryptionKey(e){let t=Bv.createDefaultKDF(),n=this.encoderStringAsBytes(`PKE`),r=t.deriveKeyNoSalt(this.actorSeed,n,64);return Bv.createPrivateDecryptionKey(e,r)}async getPublicEncryptionKey(e){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}encoderStringAsBytes(e){return new TextEncoder().encode(e)}},pk=class e{accountSeed;static createFromWalletSeedAndNonce(t,n){let r=k.binaryFrom(t,n),i=Bv.createDefaultKDF(),a=this.encoderStringAsBytes(`ACCOUNT_SEED`);return new e(i.deriveKeyNoSalt(r,a,32))}static parseFromString(t,n=new rk){return new e(n.decode(t))}encode(e=new rk){return e.encode(this.accountSeed)}constructor(e){this.accountSeed=e}deriveActorFromVbSeed(e){return fk.createFromAccountSeedAndVbSeed(this.accountSeed,e)}async getPrivateSignatureKey(t){let n=Bv.createDefaultKDF();Bv.createSignatureScheme(t);let r=e.encoderStringAsBytes(`SIG_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,32);return Bv.createPrivateSignatureKey(t,i)}async getPublicSignatureKey(e){return(await this.getPrivateSignatureKey(e)).getPublicKey()}async getPrivateDecryptionKey(t){let n=Bv.createDefaultKDF(),r=e.encoderStringAsBytes(`PKE_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,64);return Bv.createPrivateDecryptionKey(t,i)}async getPublicEncryptionKey(e){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}static encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSeedAsBytes(){return this.accountSeed}getAccountSeed(){return this.accountSeed}static concatWalletSeedWith(e,t){return new Uint8Array([...e,...t])}static numberToUint8Array(e,t=4){let n=new ArrayBuffer(t),r=new DataView(n);return t===1?r.setUint8(0,e):t===2?r.setUint16(0,e,!1):t===4?r.setUint32(0,e,!1):t===8&&r.setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}getActor(e){return fk.createFromAccountSeedAndVbSeed(this.accountSeed,e)}},mk=class e{walletSeed;static generateWallet(){return new e(Iu(64))}static fromSeed(t){if(!(t instanceof Uint8Array))throw new i(`Seed must be a Uint8Array, got ${typeof t}`);return new e(t)}static parseFromString(t,n=new rk){if(typeof t!=`string`)throw new i(`Seed must be a string, got ${typeof t}`);return new e(n.decode(t))}encode(e=new rk){return e.encode(this.walletSeed)}constructor(e){this.walletSeed=e}getDefaultAccountCrypto(){return pk.createFromWalletSeedAndNonce(this.walletSeed,0)}async generateActorPrivateSignatureKey(e,t){let n=Bv.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`SIG`),32);return Bv.createPrivateSignatureKey(e,a)}async generateActorPrivateDecryptionKey(e,t){let n=Bv.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`PKE`),32);return Bv.createPrivateDecryptionKey(e,a)}getPrivateSignatureKey(e=Ya.SECP256K1){let t=Bv.createDefaultKDF(),n=Bv.createSignatureScheme(e).expectedSeedSize(),r=pk.encoderStringAsBytes(`SIG_${e}`),i=t.deriveKeyNoSalt(this.walletSeed,r,n);return Bv.createPrivateSignatureKey(e,i)}getDecapsulationKey(e){return new Bv().createDecapsulationKey(e,this.walletSeed)}getAccountSeed(e){return this.getAccount(e).getAccountSeed()}getAccount(e){return pk.createFromWalletSeedAndNonce(this.walletSeed,e)}getAccountPrivateSignatureKey(e,t){return pk.createFromWalletSeedAndNonce(this.walletSeed,t).getPrivateSignatureKey(e)}getActorPrivateSignatureKey(e,t,n){return pk.createFromWalletSeedAndNonce(this.walletSeed,n).deriveActorFromVbSeed(t).getPrivateSignatureKey(e)}getVirtualBlockchainDecapsulationKey(e,t){return new Bv().createVirtualBlockchainDecapsulationKey(e,this.walletSeed,t)}getSeedAsBytes(){return this.walletSeed}};exports.ACCOUNT_ALLOWED_TRANSFERS=Wr,exports.ACCOUNT_BLOCK_FEES=Hr,exports.ACCOUNT_BURNT_TOKENS=Br,exports.ACCOUNT_CREATION=ma,exports.ACCOUNT_ESCROW_SETTLEMENT=va,exports.ACCOUNT_ESCROW_TRANSFER=_a,exports.ACCOUNT_HISTORY=ii,exports.ACCOUNT_NAMES=Ur,exports.ACCOUNT_PUBLIC_KEY=fa,exports.ACCOUNT_STAKE=ya,exports.ACCOUNT_STANDARD=Vr,exports.ACCOUNT_STATE=ri,exports.ACCOUNT_TOKEN_ISSUANCE=pa,exports.ACCOUNT_TRANSFER=ha,exports.ACCOUNT_VESTING_TRANSFER=ga,exports.AES256GCMSymmetricEncryptionKey=Ig,exports.AES256GCMSymmetricEncryptionScheme=Fg,exports.ALL_SCHEMAS=aa,exports.ALL_SECTIONS_SCHEMAS=Ga,exports.APP_CREATION=ka,exports.APP_DESCRIPTION=Aa,exports.APP_LEDGER_ACTOR_CREATION=Fa,exports.APP_LEDGER_ACTOR_SUBSCRIPTION=za,exports.APP_LEDGER_ALLOWED_PKE_SCHEMES=Na,exports.APP_LEDGER_ALLOWED_SIG_SCHEMES=Ma,exports.APP_LEDGER_AUTHOR=Ha,exports.APP_LEDGER_CHANNEL_CREATION=Ia,exports.APP_LEDGER_CHANNEL_INVITATION=Ra,exports.APP_LEDGER_CREATION=Pa,exports.APP_LEDGER_ENDORSEMENT_REQUEST=Ua,exports.APP_LEDGER_PRIVATE_CHANNEL_DATA=Va,exports.APP_LEDGER_PUBLIC_CHANNEL_DATA=Ba,exports.APP_LEDGER_SHARED_SECRET=La,exports.ARRAY=om,exports.AbciQueryEncoder=AD,exports.AbciRequestSchema=sD,Object.defineProperty(exports,`AbciRequestType`,{enumerable:!0,get:function(){return UE}}),exports.AbciResponseSchema=kD,Object.defineProperty(exports,`AbciResponseType`,{enumerable:!0,get:function(){return cD}}),exports.AbstractPrivateDecryptionKey=Sv,exports.AbstractProvider=OC,exports.AbstractPublicEncryptionKey=xv,exports.AbstractPublicKeyEncryptionScheme=bv,exports.AccountBreakdownSchema=Qh,exports.AccountByPublicKeyHashAbciResponseSchema=SD,exports.AccountCreationSectionSchema=qm,exports.AccountCrypto=pk,exports.AccountEscrowSettlementSectionSchema=Zm,exports.AccountEscrowTransferSectionSchema=Xm,exports.AccountHistoryAbciResponseSchema=xD,exports.AccountHistoryEntrySchema=tg,exports.AccountHistorySchema=ng,exports.AccountHistoryView=mO,exports.AccountInformationSchema=eg,exports.AccountInternalState=Sx,exports.AccountInternalStateUpdater=jx,exports.AccountMicroblockStructureChecker=Yx,exports.AccountNotFoundForAccountHashError=ge,exports.AccountNotFoundForPublicKeyError=he,exports.AccountNotFoundForPublicKeyHashError=be,exports.AccountPublicKeySectionSchema=Gm,exports.AccountSeedEncoder=ik,exports.AccountStakeSectionSchema=Qm,exports.AccountStateAbciResponseSchema=bD,exports.AccountStateSchema=$h,exports.AccountTokenIssuanceSectionSchema=Km,exports.AccountTransaction=ok,exports.AccountTransactions=ak,exports.AccountTransferSectionSchema=Jm,exports.AccountUnstakeSectionSchema=$m,exports.AccountUpdateSchema=ig,exports.AccountUpdatesAbciResponseSchema=OD,exports.AccountVb=Xx,exports.AccountVestingTransferSectionSchema=Ym,exports.AccountVirtualBlockchainInternalStateSchema=wh,exports.AccountVirtualBlockchainStateSchema=Ph,exports.ActorAlreadyDefinedError=ne,exports.ActorCrypto=fk,exports.ActorNotDefinedError=ae,exports.ActorNotInvitedError=me,exports.ActorNotSubscribedError=we,exports.ActorSeedEncoder=sk,Object.defineProperty(exports,`ActorType`,{enumerable:!0,get:function(){return IS}}),exports.Aes=cu,exports.AllowedAdditionalWriterSectionSchema=Vm,exports.AlreadySubscribedError=C,exports.AppLedgerLocalStateUpdaterV1=Fx,exports.AppLedgerMicroblockBuildRequestSchema=WS,exports.AppLedgerMicroblockBuildRequestValidation=GS,exports.ApplicationCreationSectionSchema=sh,exports.ApplicationDescriptionSectionSchema=ch,exports.ApplicationInternalState=wx,exports.ApplicationInternalStateUpdater=Mx,exports.ApplicationLedgerActorCreationSectionSchema=fh,exports.ApplicationLedgerActorInvitationStateSchema=kh,exports.ApplicationLedgerActorSchema=jh,exports.ApplicationLedgerActorSubscriptionSectionSchema=gh,exports.ApplicationLedgerAllowedPkeSchemesSectionSchema=uh,exports.ApplicationLedgerAllowedSigSchemesSectionSchema=lh,exports.ApplicationLedgerAuthorSectionSchema=yh,exports.ApplicationLedgerChannelCreationSectionSchema=ph,exports.ApplicationLedgerChannelInvitationSectionSchema=hh,exports.ApplicationLedgerChannelSchema=Oh,exports.ApplicationLedgerCreationSectionSchema=dh,exports.ApplicationLedgerEndorsementRequestSectionSchema=bh,exports.ApplicationLedgerInternalState=Tx,exports.ApplicationLedgerInternalStateObjectSchema=Mh,exports.ApplicationLedgerMicroblockBuilder=FS,exports.ApplicationLedgerMicroblockStructureChecker=iS,exports.ApplicationLedgerNotFoundError=Se,exports.ApplicationLedgerPrivateChannelDataSectionSchema=vh,exports.ApplicationLedgerPublicChannelDataSectionSchema=_h,exports.ApplicationLedgerSharedSecretSectionSchema=mh,exports.ApplicationLedgerSharedSecretStateSchema=Ah,exports.ApplicationLedgerVb=MS,exports.ApplicationLedgerVirtualBlockchainStateSchema=Rh,exports.ApplicationMicroblockStructureChecker=Zx,exports.ApplicationNotFoundError=ve,exports.ApplicationVBInternalStateObjectSchema=Dh,exports.ApplicationVb=Qx,exports.ApplicationVirtualBlockchainStateSchema=Lh,exports.Assertion=rS,exports.AwaitMicroblockAnchoringAbciRequestSchema=XE,exports.BIN256=vm,exports.BINARY=_m,exports.BK_EARNED_BLOCK_FEES=Er,exports.BK_EARNED_TX_FEES=Tr,exports.BK_NAMES=zr,exports.BK_PAID_BLOCK_FEES=gr,exports.BK_PAID_TX_FEES=hr,exports.BK_PLUS=mr,exports.BK_PURCHASE=Or,exports.BK_RECEIVED_ESCROW=jr,exports.BK_RECEIVED_ESCROW_REFUND=Mr,exports.BK_RECEIVED_EXPIRED_ESCROW=Nr,exports.BK_RECEIVED_ISSUANCE=Dr,exports.BK_RECEIVED_PAYMENT=kr,exports.BK_RECEIVED_SLASHED_TOKENS=Pr,exports.BK_RECEIVED_VESTING=Ar,exports.BK_REFERENCES=Rr,exports.BK_REF_BLOCK=Fr,exports.BK_REF_MICROBLOCK=Ir,exports.BK_REF_SECTION=Lr,exports.BK_SALE=vr,exports.BK_SENT_ESCROW=xr,exports.BK_SENT_ESCROW_REFUND=Sr,exports.BK_SENT_EXPIRED_ESCROW=Cr,exports.BK_SENT_ISSUANCE=_r,exports.BK_SENT_PAYMENT=yr,exports.BK_SENT_SLASHED_TOKENS=wr,exports.BK_SENT_VESTING=br,exports.BLOCK_CONTENT=ui,exports.BLOCK_INFORMATION=li,exports.BOOLEAN=um,exports.BalanceAvailability=ck,exports.Base32=uC,exports.Base64=sg,exports.BaseHCVSignatureDecoder=Sy,exports.BaseHCVSignatureEncoder=Gv,exports.BasePrivateSignatureKey=zg,exports.BasePublicSignatureKey=Bg,exports.BlockContentAbciResponseSchema=pD,exports.BlockInformationAbciResponseSchema=dD,exports.BlockModifiedAccountsAbciResponseSchema=DD,exports.BlockchainError=b,exports.BlockchainUtils=Y,exports.BytesSignatureEncoder=JS,exports.BytesToBase64Encoder=pg,exports.BytesToHexEncoder=mg,exports.CBORCryptoBinaryEncoder=gx,exports.CENTITOKEN=or,Object.defineProperty(exports,`CHAIN`,{enumerable:!0,get:function(){return Vn}}),exports.CMTSToken=mn,exports.CONTRACT_PARAMETER_SCHEMA=qr,exports.CONTRACT_SCHEMA=Jr,exports.CannotSubscribeError=ce,exports.CarmentisError=o,Object.defineProperty(exports,`CarmentisErrorCode`,{enumerable:!0,get:function(){return n}}),exports.ChainInformationAbciResponseSchema=uD,exports.ChannelAlreadyDefinedError=ie,exports.ChannelNotDefinedError=oe,exports.ClientBridgeEncoder=zO,exports.ClientBridgeMessageSchema=RO,exports.ClientBridgeMessageSchema_Answer=NO,exports.ClientBridgeMessageSchema_ConnectionAccepted=FO,exports.ClientBridgeMessageSchema_ConnectionInfo=PO,exports.ClientBridgeMessageSchema_ConnectionToken=AO,exports.ClientBridgeMessageSchema_Error=LO,exports.ClientBridgeMessageSchema_ForwardedAnswer=jO,exports.ClientBridgeMessageSchema_ForwardedRequest=IO,exports.ClientBridgeMessageSchema_GetConnectionInfo=MO,exports.ClientBridgeMessageSchema_Request=OO,exports.ClientBridgeMessageSchema_UpdateQr=kO,Object.defineProperty(exports,`ClientBridgeMessageType`,{enumerable:!0,get:function(){return EO}}),exports.ClientBridgeValidation=BO,Object.defineProperty(exports,`CometBFTErrorCode`,{enumerable:!0,get:function(){return DC}}),exports.CometBFTNodeWebSocket=zD,exports.CometBFTPublicKey=qS,exports.CometBFTPublicKeyConverter=PD,exports.ConstraintNameByConstraint=Gx,exports.Crypto=j,exports.CryptoEncoderFactory=_x,exports.CryptoError=d,exports.CryptoSchemeFactory=Bv,Object.defineProperty(exports,`CryptographicHashSchemeId`,{enumerable:!0,get:function(){return nv}}),exports.CurrencyConverterFactory=wC,exports.CurrentActorNotFoundError=fe,exports.CustomSectionSchema=zm,Object.defineProperty(exports,`DATA`,{enumerable:!0,get:function(){return hn}}),exports.DEF=Ka,exports.DecryptionError=f,Object.defineProperty(exports,`ECO`,{enumerable:!0,get:function(){return rr}}),exports.ERROR=Kr,Object.defineProperty(exports,`ERRORS`,{enumerable:!0,get:function(){return qa}}),exports.Economics=yC,exports.EconomicsError=v,exports.Ed25519PrivateSignatureKey=aC,exports.Ed25519PublicSignatureKey=iC,exports.Ed25519SignatureScheme=rC,exports.EmptyBlockError=u,exports.EncoderFactory=fg,exports.EnvApiKeyPkmsCredentialProvider=my,exports.ErrorAbciResponseSchema=lD,exports.EscrowLockSchema=Kh,exports.EscrowParametersSchema=Gh,exports.Euros=CC,exports.EurosToCMTSConverter=TC,exports.ExpirationDate=kC,exports.ExtendedSymmetricEncryptionKey=Lg,exports.FIXED_GAS_FEE=dr,exports.FORMAT=Bn,exports.FeesCalculationFormulaFactory=xx,exports.FirstFeesFormula=bx,exports.GAS_PER_BYTE=fr,exports.GAS_UNIT=pr,exports.GenericSymmetricKeyEncoder=XS,exports.GenesisSnapshotAbciResponseSchema=TD,exports.GetAccountByPublicKeyHashAbciRequestSchema=eD,exports.GetAccountHistoryAbciRequestSchema=$E,exports.GetAccountStateAbciRequestSchema=QE,exports.GetAccountUpdatesAbciRequestSchema=oD,exports.GetBlockContentAbciRequestSchema=KE,exports.GetBlockInformationAbciRequestSchema=GE,exports.GetBlockModifiedAccountsAbciRequestSchema=aD,exports.GetChainInformationAbciRequestSchema=WE,exports.GetGenesisSnapshotAbciRequestSchema=rD,exports.GetMicroblockBodysAbciRequestSchema=ZE,exports.GetMicroblockInformationAbciRequestSchema=YE,exports.GetObjectListAbciRequestSchema=nD,exports.GetRawBlockContentAbciRequestSchema=iD,exports.GetValidatorNodeByAddressAbciRequestSchema=tD,exports.GetVirtualBlockchainStateAbciRequestSchema=qE,exports.GetVirtualBlockchainUpdateAbciRequestSchema=JE,exports.HASHABLE=Pn,exports.HASHED=Rn,exports.HASH_STR=ym,exports.HCVCodec=gg,exports.HCVDecoded=hg,exports.HCVPkeEncoder=Vv,exports.HKDF=_v,exports.HandlerBasedSignatureEncoder=Dy,exports.Hash=Cx,exports.Hashes=$c,exports.INITIAL_OFFER=cr,exports.IllegalParameterError=i,exports.IllegalStateError=a,exports.IllegalUsageError=r,exports.IntermediateRepresentation=nO,exports.InternalError=m,exports.InternalStateFactory=Ax,exports.InternalStateUpdaterFactory=zx,exports.InvalidActorError=re,exports.InvalidChannelError=de,exports.InvalidTokenUnitError=y,exports.JsonSchema=oS,exports.KeyDerivationFunction=hv,Object.defineProperty(exports,`KeyExchangeSchemeId`,{enumerable:!0,get:function(){return Rg}}),exports.LOCK_TYPE_COUNT=Uh,exports.LockSchema=Zh,Object.defineProperty(exports,`LockType`,{enumerable:!0,get:function(){return Wh}}),exports.Logger=ts,exports.MAGIC_STRING=Hn,exports.MASKABLE=Fn,exports.MASKED=zn,exports.MAXIMUM_GAS_PRICE=ur,exports.MAX_MICROBLOCK_FUTURE_DELAY=$n,exports.MAX_MICROBLOCK_PAST_DELAY=Qn,exports.MB_STATUS_PREVIOUS_HASH_ERROR=nr,exports.MB_STATUS_TIMESTAMP_ERROR=tr,exports.MB_STATUS_UNRECOVERABLE_ERROR=er,exports.MICROBLOCK_BODY=gi,exports.MICROBLOCK_HEADER=mi,exports.MICROBLOCK_HEADER_BODY_HASH_OFFSET=fi,exports.MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET=di,exports.MICROBLOCK_HEADER_SIZE=pi,exports.MICROBLOCK_SECTION=hi,exports.MICROBLOCK_VB_INFORMATION=_i,exports.MILLITOKEN=sr,exports.MINIMUM_GAS_PRICE=lr,exports.MLDSA65HCVSignatureDecoder=Ty,exports.MLDSA65HCVSignatureEncoder=Jv,exports.MLDSA65PrivateSignatureKey=Ug,exports.MLDSA65PublicSignatureKey=Hg,exports.MLDSA65SignatureScheme=Vg,exports.MLDsa=bd,exports.MLKem=Wd,exports.MSG_ACCOUNT_BY_PUBLIC_KEY_HASH=Bi,exports.MSG_ACCOUNT_HISTORY=Ri,exports.MSG_ACCOUNT_STATE=Ii,exports.MSG_AWAIT_MICROBLOCK_ANCHORING=ji,exports.MSG_BLOCK_CONTENT=wi,exports.MSG_BLOCK_INFORMATION=Si,exports.MSG_CHAIN_INFORMATION=bi,exports.MSG_ERROR=vi,exports.MSG_GENESIS_SNAPSHOT=Ki,exports.MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH=zi,exports.MSG_GET_ACCOUNT_HISTORY=Li,exports.MSG_GET_ACCOUNT_STATE=Fi,exports.MSG_GET_BLOCK_CONTENT=Ci,exports.MSG_GET_BLOCK_INFORMATION=xi,exports.MSG_GET_CHAIN_INFORMATION=yi,exports.MSG_GET_GENESIS_SNAPSHOT=Gi,exports.MSG_GET_MICROBLOCK_BODYS=Ni,exports.MSG_GET_MICROBLOCK_INFORMATION=ki,exports.MSG_GET_OBJECT_LIST=Ui,exports.MSG_GET_VALIDATOR_NODE_BY_ADDRESS=Vi,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_STATE=Ti,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE=Di,exports.MSG_MICROBLOCK_ANCHORING=Mi,exports.MSG_MICROBLOCK_BODYS=Pi,exports.MSG_MICROBLOCK_INFORMATION=Ai,exports.MSG_OBJECT_LIST=Wi,exports.MSG_VALIDATOR_NODE_BY_ADDRESS=Hi,exports.MSG_VIRTUAL_BLOCKCHAIN_STATE=Ei,exports.MSG_VIRTUAL_BLOCKCHAIN_UPDATE=Oi,exports.MaskManager=XD,exports.MemoryProvider=AC,exports.MerkleLeaf=TS,Object.defineProperty(exports,`MerkleLeafTypeEnum`,{enumerable:!0,get:function(){return Z}}),exports.MerkleTree=wS,exports.Merklizer=qD,exports.MessageManager=rO,exports.MessageSerializer=gC,exports.MessageUnserializer=_C,exports.MicroBlockNotFoundError=te,exports.MicroBlockNotFoundInBlockError=S,exports.MicroBlockNotFoundInVirtualBlockchainAtHeightError=x,exports.Microblock=Hx,exports.MicroblockAnchoringAbciResponseSchema=_D,exports.MicroblockBodyItemSchema=vD,exports.MicroblockBodySchema=Sh,exports.MicroblockBodysAbciResponseSchema=yD,exports.MicroblockConsistencyChecker=PS,exports.MicroblockHeaderSchema=Nm,exports.MicroblockInformationAbciResponseSchema=gD,exports.MicroblockInformationSchema=Hh,exports.MicroblockStructSchema=Vx,exports.MicroblockStructureCheckingError=s,exports.MlKemCiphertextEncoder=Pv,exports.MlKemPrivateDecryptionKey=Iv,exports.MlKemPublicEncryptionKey=Fv,exports.MlKemPublicKeyEncryptionScheme=Cv,exports.NODE_MESSAGES=qi,exports.NULL=dm,exports.NUMBER=lm,exports.N_VIRTUAL_BLOCKCHAINS=Xn,exports.NativeHCVSignatureDecoder=Cy,exports.NativeHCVSignatureEncoder=Kv,exports.NetworkProvider=jD,exports.NetworksFileSchema=HO,exports.NewBlockEventSchema=RD,exports.NoSharedSecretError=Ee,exports.NodeConnectionRefusedError=g,exports.NodeEndpointClosedWhileCatchingUpError=_,exports.NodeError=h,exports.NodeStakingLockSchema=Xh,exports.NodeStakingParametersSchema=Yh,exports.NotAllowedPkeSchemeError=ue,exports.NotAllowedSignatureSchemeError=le,exports.NotAuthenticatedError=c,exports.NotImplementedError=ee,exports.NullMemoryProvider=MD,exports.NullNetworkProvider=ND,exports.OBJECT=sm,exports.ORG_CREATION=Ea,exports.ORG_DESCRIPTION=Da,exports.ObjectListAbciResponseSchema=wD,exports.OnChainChannelSchema=mS,exports.OnChainItemListSchema=gS,exports.OnChainItemSchema=hS,exports.Optional=NS,exports.OrganizationCreationSectionSchema=ah,exports.OrganizationDescriptionSectionSchema=oh,exports.OrganizationInternalState=Ox,exports.OrganizationInternalStateUpdater=Rx,exports.OrganizationMicroblockStructureChecker=qx,exports.OrganizationNotFoundError=_e,exports.OrganizationVBInternalStateObjectSchema=Th,exports.OrganizationVb=Jx,exports.OrganizationVirtualBlockchainStateSchema=Fh,exports.PBKDF2=lv,exports.PROPERTIES=In,exports.PROTOCOL_CREATION=la,exports.PROTOCOL_UPDATE=ua,exports.PROTOCOL_VARIABLES=oi,exports.PROTOCOL_VB_STATE=si,exports.PROTOCOL_VERSION=Un,exports.ParsingError=l,exports.PasswordBasedKeyDerivationFunction=cv,exports.PathManager=BD,exports.PepperMerklizer=JD,exports.PkeEncoderFactory=YS,exports.PkmsSecp256k1PrivateSignatureKey=gy,exports.PkmsSecp256k1PublicSignatureKey=_y,exports.PkmsSecp256k1SignatureDecoder=Ey,exports.PkmsSecp256k1SignatureEncoder=vy,exports.PriceBreakdownSchema=Im,exports.PriceCategorySchema=Pm,exports.PriceStructureSchema=Fm,exports.ProofDocument=CS,exports.ProofDocumentVB=aS,Object.defineProperty(exports,`ProofFieldTypeEnum`,{enumerable:!0,get:function(){return _S}}),exports.ProofVerificationFailedError=se,exports.ProofVerificationResult=EC,exports.ProofWrapperSchema=xS,exports.ProtocolCreationSectionSchema=Hm,exports.ProtocolError=Ce,exports.ProtocolInternalState=Dx,exports.ProtocolInternalStateUpdater=Lx,exports.ProtocolMicroblockStructureChecker=tS,exports.ProtocolUpdateSchema=Rm,exports.ProtocolUpdateSectionSchema=Um,exports.ProtocolVBInternalStateObjectSchema=Ch,exports.ProtocolVariablesSchema=Lm,exports.ProtocolVariablesSectionSchema=Wm,exports.ProtocolVb=nS,exports.ProtocolVirtualBlockchainStateSchema=zh,exports.Provider=FD,exports.ProviderFactory=ID,exports.RADIX_CST=oO,exports.RECORD_DESCRIPTION=ni,exports.REDACTED=Ln,exports.RPCNodeStatusResponseSchema=HE,exports.RadixChecker=uO,exports.RadixUtils=sO,exports.Random=Qs,exports.RawBlockContentAbciResponseSchema=ED,exports.ReadStream=jv,exports.RecordActorAssignationSchema=BS,exports.RecordActorSchema=LS,exports.RecordByChannels=DS,exports.RecordChannelAssignationSchema=zS,exports.RecordChannelSchema=RS,exports.RecordHashableFieldSchema=US,exports.RecordMaskableFieldSchema=HS,exports.RecordMaskedPartSchema=VS,exports.RequestedAccountUpdateSchema=rg,Object.defineProperty(exports,`SCHEMAS`,{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(exports,`SECTIONS`,{enumerable:!0,get:function(){return oa}}),exports.SIGNATURE=sa,exports.SIGNATURE_SCHEMA=ca,exports.STRING=cm,exports.SaltMerklizer=YD,exports.SaltShaker=OS,exports.SchemaSerializer=Mv,exports.SchemaUnserializer=Nv,exports.SchemaValidator=vC,exports.Scrypt=nC,exports.Secp256k1=hp,exports.Secp256k1HCVSignatureDecoder=wy,exports.Secp256k1HCVSignatureEncoder=qv,exports.Secp256k1PrivateSignatureKey=zv,exports.Secp256k1PublicSignatureKey=Rv,exports.Secp256k1SignatureScheme=Lv,Object.defineProperty(exports,`SectionConstraint`,{enumerable:!0,get:function(){return X}}),exports.SectionError=pe,exports.SectionLabel=Px,exports.SectionNotFoundError=Te,exports.SectionSchema=xh,Object.defineProperty(exports,`SectionType`,{enumerable:!0,get:function(){return O}}),exports.SeedEncoder=rk,exports.SelfProvidedApiKeyPkmsCredentialProvider=oC,exports.SerializationError=De,exports.ServerNetworkProvider=LD,exports.Sha256CryptographicHash=rv,exports.SharedKeyDecryptionError=p,exports.SignatureCacheEntry=sC,exports.SignatureSectionSchema=Bm,exports.StoragePriceManager=yx,exports.StructureChecker=Kx,Object.defineProperty(exports,`SymmetricEncryptionSchemeId`,{enumerable:!0,get:function(){return Pg}}),exports.TOKEN=ar,exports.TOKEN_NAME=ir,exports.TYPE_ARRAY=_n,exports.TYPE_ARRAY_OF=Mn,exports.TYPE_BIN256=kn,exports.TYPE_BINARY=On,exports.TYPE_BOOLEAN=xn,exports.TYPE_HASH_STR=An,exports.TYPE_MAIN=jn,exports.TYPE_NAMES=Nn,exports.TYPE_NULL=Sn,exports.TYPE_NUMBER=bn,exports.TYPE_OBJECT=vn,exports.TYPE_STRING=yn,exports.TYPE_UINT16=wn,exports.TYPE_UINT24=Tn,exports.TYPE_UINT32=En,exports.TYPE_UINT48=Dn,exports.TYPE_UINT8=Cn,exports.TYPE_UNKNOWN=gn,exports.ThrownErrorMicroblockSearchFailureFallback=Ux,Object.defineProperty(exports,`TimestampValidationResult`,{enumerable:!0,get:function(){return Bx}}),Object.defineProperty(exports,`TokenUnit`,{enumerable:!0,get:function(){return fn}}),Object.defineProperty(exports,`TokenUnitLabel`,{enumerable:!0,get:function(){return pn}}),exports.Transaction=pO,Object.defineProperty(exports,`TransformationTypeEnum`,{enumerable:!0,get:function(){return cS}}),exports.TypeChecker=io,exports.TypeCheckingFailureError=to,Object.defineProperty(exports,`TypeEnum`,{enumerable:!0,get:function(){return uS}}),exports.TypeManager=ro,exports.UINT16=pm,exports.UINT24=mm,exports.UINT32=hm,exports.UINT48=gm,exports.UINT8=fm,exports.Utf8Encoder=Qa,exports.Utils=k,exports.VB_ACCOUNT=Gn,exports.VB_APPLICATION=Jn,exports.VB_APP_LEDGER=Yn,exports.VB_NAME=Zn,exports.VB_ORGANIZATION=qn,exports.VB_PROTOCOL=Wn,exports.VB_STATES=ci,exports.VB_VALIDATOR_NODE=Kn,exports.VIRTUAL_BLOCKCHAIN_STATE=ai,exports.VN_APPROVAL=wa,exports.VN_COMETBFT_PUBLIC_KEY_DECLARATION=Sa,exports.VN_CREATION=xa,exports.VN_RPC_ENDPOINT=Ca,exports.ValidatorNodeApprovalSectionSchema=rh,exports.ValidatorNodeByAddressAbciResponseSchema=CD,exports.ValidatorNodeCometbftPublicKeyDeclarationSectionSchema=th,exports.ValidatorNodeCreationSectionSchema=eh,exports.ValidatorNodeInternalState=kx,exports.ValidatorNodeInternalStateUpdater=Ix,exports.ValidatorNodeMicroblockStructureChecker=$x,exports.ValidatorNodeNotFoundError=ye,exports.ValidatorNodeRpcEndpointSectionSchema=nh,exports.ValidatorNodeSlashingCancellationSectionSchema=ih,exports.ValidatorNodeVBInternalStateObjectSchema=Eh,exports.ValidatorNodeVb=eS,exports.ValidatorNodeVirtualBlockchainStateSchema=Ih,exports.VestingLockSchema=Jh,exports.VestingParametersSchema=qh,exports.VirtualBlockchain=Wx,exports.VirtualBlockchainInfoSchema=Vh,exports.VirtualBlockchainLabel=gO,exports.VirtualBlockchainNotFoundError=xe,exports.VirtualBlockchainSharedPropertiesSchema=Nh,exports.VirtualBlockchainStateAbciResponseSchema=mD,exports.VirtualBlockchainStateSchema=Bh,exports.VirtualBlockchainStatusSchema=UO,Object.defineProperty(exports,`VirtualBlockchainType`,{enumerable:!0,get:function(){return V}}),exports.VirtualBlockchainUpdateAbciResponseSchema=hD,exports.WIMSG_ANSWER=ea,exports.WIMSG_CONNECTION_ACCEPTED=na,exports.WIMSG_CONNECTION_INFO=ta,exports.WIMSG_CONNECTION_TOKEN=Zi,exports.WIMSG_FORWARDED_ANSWER=Qi,exports.WIMSG_FORWARDED_REQUEST=ra,exports.WIMSG_GET_CONNECTION_INFO=$i,exports.WIMSG_REQUEST=Yi,exports.WIMSG_UPDATE_QR=Xi,exports.WI_INVALID_SIGNATURE=Ja,exports.WI_MAX_SERVER_URL_LENGTH=TO,exports.WI_MESSAGES=ia,exports.WI_QR_CODE=Ji,exports.WalletCrypto=mk,exports.WalletInteractiveAnchoringEncoder=lk,exports.WalletInteractiveAnchoringRequestActorKeySchema=qO,exports.WalletInteractiveAnchoringRequestApprovalHandshakeSchema=KO,exports.WalletInteractiveAnchoringRequestApprovalSignatureSchema=JO,exports.WalletInteractiveAnchoringRequestSchema=YO,Object.defineProperty(exports,`WalletInteractiveAnchoringRequestType`,{enumerable:!0,get:function(){return WO}}),exports.WalletInteractiveAnchoringResponseActorKeyRequiredSchema=ZO,exports.WalletInteractiveAnchoringResponseApprovalDataSchema=QO,exports.WalletInteractiveAnchoringResponseApprovalSignatureSchema=$O,exports.WalletInteractiveAnchoringResponseErrorSchema=XO,exports.WalletInteractiveAnchoringResponseSchema=ek,Object.defineProperty(exports,`WalletInteractiveAnchoringResponseType`,{enumerable:!0,get:function(){return GO}}),exports.WalletInteractiveAnchoringValidation=uk,exports.WalletRequestAuthByPublicKeySchema=yO,exports.WalletRequestBasedApplicationLedgerMicroblockBuilder=KS,exports.WalletRequestDataApprovalSchema=bO,exports.WalletRequestEncoder=tk,exports.WalletRequestSchema=xO,Object.defineProperty(exports,`WalletRequestType`,{enumerable:!0,get:function(){return _O}}),exports.WalletRequestValidation=nk,exports.WalletResponseAuthByPublicKeySchema=SO,exports.WalletResponseDataApprovalSchema=CO,exports.WalletResponseSchema=wO,Object.defineProperty(exports,`WalletResponseType`,{enumerable:!0,get:function(){return vO}}),exports.WalletSeedEncoder=dk,exports.WiQrCodeEncoder=VO,exports.WiQrCodeSchema=DO,exports.WriteStream=Av,exports.accountId=jm,exports.array=bm,exports.bin256=Am,exports.binary=km,exports.boolean=Sm,exports.height=Mm,exports.number=z,exports.string=xm,exports.uint16=Tm,exports.uint24=Em,exports.uint32=Dm,exports.uint48=Om,exports.uint8=wm,exports.uint8array=B;
|
|
8
|
+
`,t+=` Microblock type: ${this.header.microblockType} or ${this.type}\n`,t+=` Magic String: ${this.header.magicString}\n`,t+=` Protocol Version: ${this.header.protocolVersion}\n`,t+=` Fees payer account: ${e.encode(this.header.feesPayerAccount)}\n`,t+=` Height: ${this.header.height}\n`,t+=` Previous Hash: ${e.encode(this.header.previousHash)}\n`,t+=` Timestamp: ${this.header.timestamp}\n`,t+=` Max fees: ${this.header.maxFees}\n`,t+=` Gas Price: ${this.header.gasPrice}\n`,t+=` Body Hash: ${e.encode(this.header.bodyHash)}\n`,t+=` Computed body Hash: ${e.encode(this.computeBodyHash())}\n`,t+=` Sections (${this.sections.length}):\n`,this.sections.forEach((e,n)=>{t+=` Section ${n}:\n`,t+=` Section Type: ${Nx.getSectionLabelFromSection(e)} (type ${e.type})\n`,t+=` Section Data: ${k.binaryToHexa(Y.encodeSection(e))}\n`}),t}getType(){return this.type}setPreviousHash(e){this.header.previousHash=e.toBytes()}static extractTypeFromGenesisPreviousHash(e){return e[0]}static extractExpirationDayFromGenesisPreviousHash(e){return e[1]<<24|e[2]<<16|e[3]<<8|e[4]}getBodyHashInHeader(){return this.header.bodyHash}isDeclaringConsistentBodyHash(){let e=this.computeBodyHash();return k.binaryIsEqual(e,this.header.bodyHash)}isGenesisMicroblock(){return this.getHeight()===1}setBodyHash(e){this.header.bodyHash=e}computeHash(){let{microblockHash:e}=this.serialize();return e}setMicroblockHash(e){this.hash=e}getLastSignatureSection(){let e=this.sections[this.sections.length-1];if(e.type!==O.SIGNATURE)throw Error(`Last section is not a signature section`);return e}},Hx=class{onMicroblockSearchFailureForExceedingHeight(e,t){throw e.isEmpty()?new x(Sx.from(k.getNullHash()),t):new x(e.getIdentifier(),t)}},Ux=class e{static INITIAL_HEIGHT=1;static staticLogger=ts.getVirtualBlockchainLogger();logger=e.staticLogger;internalState;height;identifier;microblockHashByHeight;microblockByHeight;provider;type;expirationDay;microblockSearchFailureFallback;onMicroblockInsertionEventListeners=[];constructor(e,t,n){this.internalState=n,this.provider=e,this.microblockHashByHeight=new Map,this.microblockByHeight=new Map,this.type=t,this.expirationDay=0,this.height=0,this.microblockSearchFailureFallback=new Hx}async isAccountIdAllowedToWrite(e){if(this.height===0)return!0;let t=await this.getVirtualBlockchainOwnerId();return k.binaryIsEqual(t.toBytes(),e.toBytes())}getProvider(){return this.provider}addOnMicroblockInsertionEventListener(e){this.onMicroblockInsertionEventListeners.push(e)}getInternalState(){return this.internalState}setInternalState(e){this.internalState=e}async createMicroblock(){if(this.isEmpty())return new Vx(this.type);let e=await this.getLastMicroblock(),t=new Vx(this.type);return t.setPreviousHash(e.getHash()),t.setHeight(this.getHeight()+1),t}getLastMicroblock(){return this.getMicroblock(this.getHeight())}setHeight(e){this.height=e}setIdentifier(e){this.logger.debug(`Updating virtual blockchain identifier to ${k.binaryToHexa(e)}`),this.identifier=e}setMicroblockHashes(e){let t=1;for(let n of e)this.microblockHashByHeight.set(t,n),t++}setExpirationDay(e){this.expirationDay=e}async getSerializedVirtualBlockchainState(){return Y.encodeVirtualBlockchainState(await this.getVirtualBlockchainState())}async getGenesisSeed(){return(await this.getFirstMicroBlock()).getPreviousHash()}getHeight(){return this.height}getId(){return this.identifier}isVirtualBlockchainIdDefined(){return this.identifier instanceof Uint8Array}async getFirstMicroBlock(){return this.getMicroblock(1)}getAllMicroblockHashes(){let e=[];for(let t of this.microblockHashByHeight.entries())e.push(Sx.from(t[1]));return e}async getMicroblock(e){this.logger.debug(`Accessing microblock at height ${e} of vb`);for(let e of this.microblockHashByHeight.entries())this.logger.debug(`\t- Height ${e[0]}: ${k.binaryToHexa(e[1])}`);if(e<1)throw new i(`Cannot retrieve microblock at height strictly lower than 1: got ${e}`);if(this.getHeight()<e)return await this.microblockSearchFailureFallback.onMicroblockSearchFailureForExceedingHeight(this,e);let t=this.microblockByHeight.get(e);if(t!==void 0)return t;let n=this.microblockHashByHeight.get(e);if(n===void 0)throw new x(this.getIdentifier(),e);let r=await this.provider.getMicroblockHeader(Sx.from(n));if(r===null){let t=fg.bytesToHexEncoder();throw Error(`Unable to load microblock information from hash ${t.encode(n)} (height ${e})`)}let a=await this.provider.getMicroblockBody(Sx.from(n));if(a===null)throw Error(`Unable to load the microblock body`);let o=Vx.loadFromHeaderAndBody(r,a,this.type);if(o.getHeight()!==e)throw Error(`Received microblock contains an unexpected height: expected ${e}, defined ${o.getHeight()} `);if(!k.binaryIsEqual(o.getHash().toBytes(),n)){let e=`Mismatch between microblock hash ${o.getHash().encode()} and expected hash ${k.binaryToHexa(n)}`;throw this.logger.error(o.toString()),Error(e)}this.microblockByHeight.set(e,o);for(let e of this.onMicroblockInsertionEventListeners)e.onMicroblockInserted(this,o);return o}getIdentifier(){if(this.identifier===void 0)throw new a(`You cannot access identifier of an empty virtual blockchain (current height is ${this.height})`);return Sx.from(this.identifier)}isEmpty(){return this.getHeight()===0}async appendMicroBlock(e){if(this.isEmpty()&&this.identifier instanceof Uint8Array)throw Error(`Virtual blockchain is empty but is initialized: should not happen`);if(!this.isEmpty()&&!(this.identifier instanceof Uint8Array))throw Error(`Virtual blockchain is empty but has an identifier: should not happen`);let t=this.height+1,n=e.getHeight();if(t!==n)throw Error(`Microblock height mismatch: expected ${t} but got ${n}`);if(!this.isEmpty()){let t=(await this.getLastMicroblock()).getHash().toBytes(),n=e.getPreviousHash().toBytes();if(!k.binaryIsEqual(n,t))throw Error(`Previous hash mismatch: microblock's previous hash ${k.binaryToHexa(n)} does not match the last microblock's hash ${k.binaryToHexa(t)}`)}if(!this.checkMicroblockStructure(e))throw new i(`Provided microblock has an invalid structure`);let r=await this.provider.getProtocolState();this.internalState=await this.updateInternalState(r,this.internalState,e),this.identifier===void 0&&(this.identifier=e.getHash().toBytes()),this.height+=1;let a=e.getHash().toBytes();this.microblockHashByHeight.set(this.height,a),this.microblockByHeight.set(this.height,e),this.logger.debug(`Microblock ${k.binaryToHexa(a)} added to vb (now at height ${this.height} `)}setMicroblockSearchFailureFallback(e){this.microblockSearchFailureFallback=e}getType(){return this.type}getExpirationDay(){return this.expirationDay}},X=function(e){return e[e.ANY=0]=`ANY`,e[e.ZERO=1]=`ZERO`,e[e.ONE=2]=`ONE`,e[e.AT_MOST_ONE=3]=`AT_MOST_ONE`,e[e.AT_LEAST_ONE=4]=`AT_LEAST_ONE`,e}({}),Wx={[X.ANY]:`Any`,[X.ONE]:`Exactly one`,[X.ZERO]:`Exactly zero`,[X.AT_LEAST_ONE]:`At least one`,[X.AT_MOST_ONE]:`At most one`},Gx=class{microblock;pointer;constructor(e){this.microblock=e,this.pointer=0}isFirstBlock(){return this.microblock.getHeight()==1}expects(e,t){let n=0;for(;!this.endOfList()&&this.currentSection().type==t;)n++,this.pointer++;if(!this.checkConstraint(e,n))throw new s(`expected ${Wx[e]} of type ${this.getSectionLabelBySectionType(t)}, got ${n}`)}group(e,t){let n=new Map,r=0;for(let[e,r]of t)n.set(r,0);for(;!this.endOfList();){let e=this.currentSection().type;if(!t.some(([t,n])=>n==e))break;n.set(e,n.get(e)+1),r++,this.pointer++}if(!this.checkConstraint(e,r))throw new s(`expected ${Wx[e]} in group, got ${r}`);for(let[e,r]of t){let t=n.get(r);if(!this.checkConstraint(e,t))throw new s(`expected ${Wx[e]} of type ${this.getSectionLabelBySectionType(r)}, got ${t}`)}}endsHere(){if(!this.endOfList()){let e=this.currentSection().type;throw new s(`Unexpected section ${this.getSectionLabelBySectionType(e)}`)}}currentSection(){return this.microblock.getAllSections()[this.pointer]}endOfList(){return!this.currentSection()}checkConstraint(e,t){switch(e){case X.ANY:return!0;case X.ZERO:return t==0;case X.ONE:return t==1;case X.AT_LEAST_ONE:return t>=1;case X.AT_MOST_ONE:return t<=1}return!1}getSectionLabelBySectionType(e){return Nx.getSectionLabelFromSectionType(e)}},Kx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.ORG_CREATION),t.group(X.AT_MOST_ONE,[[X.ONE,O.ORG_DESCRIPTION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},qx=class e extends Ux{static createOrganizationVirtualBlockchain(t){return new e(t)}constructor(e,t=Dx.createInitialState()){super(e,V.ORGANIZATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getOrganizationInternalStateUpdaterVersion();return Rx.createOrganizationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){return this.internalState.getAccountId()}checkMicroblockStructure(e){return new Kx().checkMicroblockStructure(e)}getAccountId(){return this.internalState.getAccountId()}async getDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.ORG_DESCRIPTION)return e;throw new a(`No description found for the organization`)}},Jx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.AT_MOST_ONE,O.ACCOUNT_PUBLIC_KEY),t.isFirstBlock()?t.group(X.ONE,[[X.AT_MOST_ONE,O.ACCOUNT_TOKEN_ISSUANCE],[X.AT_MOST_ONE,O.ACCOUNT_CREATION]]):t.group(X.AT_LEAST_ONE,[[X.ANY,O.ACCOUNT_TRANSFER],[X.ANY,O.ACCOUNT_VESTING_TRANSFER],[X.ANY,O.ACCOUNT_STAKE],[X.ANY,O.ACCOUNT_UNSTAKE],[X.ANY,_a],[X.ANY,O.ACCOUNT_ESCROW_SETTLEMENT]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},Yx=class extends Ux{constructor(e,t=xx.createInitialState()){super(e,V.ACCOUNT_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getAccountInternalStateUpdaterVersion();return Rx.createAccountInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){return Sx.from(this.getId())}checkMicroblockStructure(e){return new Jx().checkMicroblockStructure(e)}async getPublicKey(){let e=this.internalState.getPublicKeyHeight(),t=this.internalState.getPublicKeySchemeId(),n=await this.getMicroblock(e);for(let e of n.getAllSections())if(e.type===O.ACCOUNT_PUBLIC_KEY)return new zv().createPublicSignatureKey(t,e.publicKey);throw new a(`Account public key not found`)}async isIssuer(){let e=await this.getFirstMicroBlock();for(let t of e.getAllSections())if(t.type===O.ACCOUNT_TOKEN_ISSUANCE)return!0;return!1}static async createAccountCreationMicroblock(e,t,n,r=``){let i=Vx.createGenesisAccountMicroblock();return i.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await e.getPublicKeyAsBytes(),schemeId:e.getSignatureSchemeId()}),i.addSection({type:O.ACCOUNT_CREATION,amount:t.getAmountAsAtomic(),sellerAccount:n}),i}static async createIssuerAccountCreationMicroblock(e){let t=e,n=Vx.createGenesisAccountMicroblock();return n.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await t.getPublicKeyAsBytes(),schemeId:t.getSignatureSchemeId()}),n.addSection({type:O.ACCOUNT_TOKEN_ISSUANCE,amount:cr}),n}},Xx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.APP_CREATION),t.group(X.AT_LEAST_ONE,[[X.AT_MOST_ONE,O.APP_DESCRIPTION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},Zx=class extends Ux{constructor(e,t=Cx.createInitialState()){super(e,V.APPLICATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getApplicationInternalStateUpdaterVersion();return Rx.createApplicationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}checkMicroblockStructure(e){return new Xx().checkMicroblockStructure(e)}getOrganizationId(){return this.internalState.getOrganizationId()}async getApplicationDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type==O.APP_DESCRIPTION)return e;throw Error(`Application description not found`)}},Qx=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.VN_CREATION),t.group(X.AT_LEAST_ONE,t.isFirstBlock()?[[X.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[X.AT_MOST_ONE,O.VN_RPC_ENDPOINT]]:[[X.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[X.AT_MOST_ONE,O.VN_RPC_ENDPOINT],[X.AT_MOST_ONE,O.VN_APPROVAL],[X.AT_MOST_ONE,O.VN_SLASHING_CANCELLATION]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},$x=class extends Ux{constructor(e,t=Ox.createInitialState()){super(e,V.NODE_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getValidatorNodeInternalStateUpdaterVersion();return Rx.createValidatorNodeInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){return this.internalState.getOrganizationId()}checkMicroblockStructure(e){return new Qx().checkMicroblockStructure(e)}async getCometbftPublicKeyDeclaration(){let e=this.internalState.getCometbftPublicKeyDeclarationHeight();if(e===0)throw new a(`Node has not declared its CometBFT public key yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections()){if(e.type!==O.VN_COMETBFT_PUBLIC_KEY_DECLARATION)continue;let t=e.cometPublicKey;return{cometbftPublicKeyType:e.cometPublicKeyType,cometbftPublicKey:t}}throw new a(`Node has not declared its CometBFT public key yet`)}async getRpcEndpointDeclaration(){let e=this.internalState.getRpcEndpointHeight();if(e===0)throw new a(`Node has not declared its RPC endpoint yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.VN_RPC_ENDPOINT)return e.rpcEndpoint;throw new a(`Node has not declared its RPC endpoint yet`)}getNodeDeclarationHeight(){return this.getInternalState().getCometbftPublicKeyDeclarationHeight()}async getOrganizationVirtualBlockchain(){let e=this.internalState.getOrganizationId();return await this.provider.loadOrganizationVirtualBlockchain(e)}},eS=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.PROTOCOL_CREATION),t.isFirstBlock()||t.group(X.AT_MOST_ONE,[[X.ONE,O.PROTOCOL_UPDATE]]),t.expects(X.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},tS=class extends Ux{constructor(e,t=Ex.createInitialState()){super(e,V.PROTOCOL_VIRTUAL_BLOCKCHAIN,t)}checkMicroblockStructure(e){return new eS().checkMicroblockStructure(e)}async updateInternalState(e,t,n){let r=e.getProtocolInternalStateUpdaterVersion();return Rx.createProtocolInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){let e=(await this.getFirstMicroBlock()).getAllSections();for(let t of e)if(t.type===O.PROTOCOL_CREATION)return Sx.from(t.organizationId);throw Error(`Organization ID not found in protocol vb`)}},nS=class{static assert(e,t=`Unspecified verification`){if(!e)throw new m(`Assertion failed: ${t}`)}},rS=class{logger=ts.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new Gx(e);return t.expects(t.isFirstBlock()?X.ONE:X.ZERO,O.APP_LEDGER_CREATION),t.group(X.ANY,[[X.ANY,O.APP_LEDGER_ACTOR_CREATION],[X.ANY,O.APP_LEDGER_ACTOR_SUBSCRIPTION],[X.ANY,O.APP_LEDGER_ENDORSEMENT_REQUEST],[X.ANY,O.APP_LEDGER_AUTHOR],[X.ANY,O.APP_LEDGER_PUBLIC_CHANNEL_DATA],[X.ANY,O.APP_LEDGER_PRIVATE_CHANNEL_DATA],[X.ANY,O.APP_LEDGER_SHARED_SECRET],[X.ANY,O.APP_LEDGER_CHANNEL_CREATION],[X.ANY,O.APP_LEDGER_CHANNEL_INVITATION],[X.ANY,O.ALLOWED_ADDITIONAL_WRITER]]),t.expects(X.AT_LEAST_ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},iS=class e{identifier;microblocks;constructor(){this.identifier=``,this.microblocks=[]}static fromObject(t){let n=new e;n.setIdentifier(t.id);for(let e of t.microblocks)n.addMicroblock(e.height,e.channels);return n}toObject(){return{id:this.identifier,microblocks:this.microblocks}}setIdentifier(e){this.identifier=e}getIdentifier(){return this.identifier}addMicroblock(e,t){let n={height:e,channels:t};this.microblocks.push(n)}getMicroblock(e){let t=this.microblocks.find(t=>t.height===e);if(!t)throw Error(`no microblock found for height ${e}`);return t}getMicroblocks(){return this.microblocks}},aS=Yp(()=>nm([I(),P(),Kp(),Xp(),M(aS),em(I(),aS)])),oS=M(nm([I(),P()])),sS=function(e){return e[e.None=0]=`None`,e[e.Hashable=1]=`Hashable`,e[e.Maskable=2]=`Maskable`,e}({}),cS=im(`type`,[F({type:N(sS.None)}),F({type:N(sS.Hashable)}),F({type:N(sS.Maskable),visibleParts:M(I()),hiddenParts:M(I())})]),lS=function(e){return e[e.String=0]=`String`,e[e.Number=1]=`Number`,e[e.Boolean=2]=`Boolean`,e[e.Null=3]=`Null`,e[e.Array=4]=`Array`,e[e.Object=5]=`Object`,e}({}),uS,dS={channelId:P()};uS=im(`type`,[F({...dS,type:N(lS.String),value:I(),transformation:cS}),F({...dS,type:N(lS.Number),value:P()}),F({...dS,type:N(lS.Boolean),value:Kp()}),F({...dS,type:N(lS.Null),value:Xp()}),F({type:N(lS.Array),value:M(Yp(()=>uS))}),F({type:N(lS.Object),value:M(F({key:I(),value:Yp(()=>uS)}))})]);var fS=nm([I(),P(),Kp(),Xp()]),pS=F({pepper:B(),data:B()}),mS=F({path:oS,value:fS,transformation:Qp(cS)}),hS=M(mS),Z=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableFromValue=2]=`HashableFromValue`,e[e.Hashable=3]=`Hashable`,e[e.MaskableFromAllParts=4]=`MaskableFromAllParts`,e[e.MaskableFromVisibleParts=5]=`MaskableFromVisibleParts`,e[e.Maskable=6]=`Maskable`,e}({});Z.Public,Z.Plain,Z.HashableFromValue,Z.Hashable,Z.MaskableFromAllParts,Z.MaskableFromVisibleParts,Z.Maskable;var gS=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableAsPlain=2]=`HashableAsPlain`,e[e.HashableAsHash=3]=`HashableAsHash`,e[e.MaskableAsAllParts=4]=`MaskableAsAllParts`,e[e.MaskableAsVisibleParts=5]=`MaskableAsVisibleParts`,e}({}),_S=F({path:oS,type:N(gS.Public),value:fS}),vS={path:oS,index:P()},yS=im(`type`,[_S,F({...vS,type:N(gS.Plain),salt:I(),value:fS}),F({...vS,type:N(gS.HashableAsPlain),salt:I(),value:fS}),F({...vS,type:N(gS.HashableAsHash),salt:I(),hash:I()}),F({...vS,type:N(gS.MaskableAsAllParts),v_salt:I(),v_parts:M(I()),h_salt:I(),h_parts:M(I())}),F({...vS,type:N(gS.MaskableAsVisibleParts),v_salt:I(),v_parts:M(I()),h_hash:I()})]),bS=F({version:P(),info:F({title:I(),date:I(),description:I(),author:I()}),virtual_blockchains:M(F({id:I(),microblocks:M(F({height:P(),channels:M(F({id:P(),is_public:Kp(),n_leaves:P(),fields:M(yS),witnesses:M(I())}))}))})),signature:Qp(F({commitment:F({issued_at:Qp(I()),digest_alg:Qp($p([`sha256`])),digest_target:Qp($p([`cbor_proof`])),digest:Qp(I())}),signer:I(),pubkey:I(),alg:$p([`ecdsa-secp256k1`,`ml-dsa-65`]),sig:I()}))}),xS=1,SS=class e{encoder=new hx;wrapper;constructor(){this.wrapper={version:xS,info:{title:`Carmentis proof`,description:`This is a Carmentis proof file. Visit www.carmentis.io for more information.`,author:``,date:new Date().toISOString()},virtual_blockchains:[]}}static fromObject(t){L(bS,t);let n=new e;return n.wrapper=t,n}setTitle(e){this.wrapper.info.title=e}getTitle(){return this.wrapper.info.title}setDescription(e){this.wrapper.info.description=e}getDescription(){return this.wrapper.info.description}setAuthor(e){this.wrapper.info.author=e}getAuthor(){return this.wrapper.info.author}setDate(e){this.wrapper.info.date=e.toISOString()}getDate(){return new Date(this.wrapper.info.date)}addVirtualBlockchain(e){this.wrapper.virtual_blockchains.push(e.toObject())}getSingleVirtualBlockchainOrFail(){let e=this.getVirtualBlockchains();if(e.length==0)throw Error(`no virtual blockchain is defined in this proof`);if(e.length>1)throw Error(`proofs with multiple virtual blockchains are not supported at this time`);return e[0]}getVirtualBlockchain(e){let t=this.wrapper.virtual_blockchains.find(t=>t.id===e);if(!t)throw Error(`no virtual blockchain found with ID ${e}`);return t}getVirtualBlockchains(){return this.wrapper.virtual_blockchains.map(e=>iS.fromObject(e))}sign(e=new Date){let t=this.computeDigest(),n={issued_at:e.toISOString(),digest_alg:`sha256`,digest_target:`cbor_proof`,digest:k.binaryToHexa(t)},r=this.encoder.encode(n);j.Hashes.sha256AsBinary(r),this.wrapper.signature={commitment:n,signer:``,pubkey:``,alg:`ecdsa-secp256k1`,sig:``}}verifySignature(){this.computeDigest()}computeDigest(){let e={info:this.wrapper.info,virtual_blockchains:this.wrapper.virtual_blockchains},t=this.encoder.encode(e);return j.Hashes.sha256AsBinary(t)}getObject(){return this.wrapper}},CS=class{leaves;nLeaves;tree;constructor(){this.leaves=[],this.nLeaves=0,this.tree=[]}addLeaf(e){this.checkHash(e),this.leaves.push(e)}setLeaf(e,t){this.checkHash(t),this.leaves[e]=t}checkHash(e){if(e.length!=32)throw Error(`invalid hash: expected size is 32 bytes, got ${e.length}`)}finalize(e=void 0){this.nLeaves=e===void 0?this.leaves.length:e,this.buildTreeStructure()}getNumberOfLeaves(){return this.nLeaves}getRootHash(){let e=this.tree.length-1;for(let t=0;t<e;t++){let e=this.tree[t];for(let n=0;n<e.length;n+=2)e[n]&&e[n+1]&&(this.tree[t+1][n>>1]=this.mergeHashes(t+1,e[n],e[n+1]))}return this.tree[e][0]}getWitnesses(e){let t=new Set(e),n=this.getWitnessPositions(t),r=[];for(let e=0;e<this.tree[0].length;e++)if(!t.has(e)&&!this.tree[0][e])throw Error(`cannot find leaf at index ${e}`);for(let[e,t]of n){let n=this.tree[e][t];if(!n)throw Error(`cannot find witness hash at depth ${e}, index ${t}`);r.push(n)}return r}setWitnesses(e){let t=new Set;for(let e=0;e<this.nLeaves;e++)this.leaves[e]||t.add(e);let n=this.getWitnessPositions(t);if(e.length!=n.length)throw Error(`invalid witness list: expected ${n.length} witness(es), got ${e.length}`);let r=0;for(let[t,i]of n)this.checkHash(e[r]),this.tree[t][i]=e[r++]}buildTreeStructure(){let e=this.nLeaves;for(this.tree=[];e;){let t=Array(e).fill(null);e>1&&e&1&&(t.push(k.getNullHash()),e++),this.tree.push(t),e>>=1}for(let e=0;e<this.nLeaves;e++)this.leaves[e]&&(this.tree[0][e]=this.leaves[e])}getWitnessPositions(e){let t=this.nLeaves,n=[];for(let r=0;t;r++){let i=new Set;for(let a=0;a<t;a+=2){let o=e.has(a),s=a+1<t&&e.has(a+1);o&&s?i.add(a>>1):(o||s)&&n.push([r,s?a+1:a])}e=i,t=t+ +(t>1)>>1}return n}mergeHashes(e,t,n){let r=new Uint8Array(65);return r[0]=+(e==this.tree.length-1),r.set(t,1),r.set(n,33),j.Hashes.sha256AsBinary(r)}},wS=class e{internalData=void 0;encoder=new hx;static fromProofFormat(t){let n=new e;return n.fromProofField(t),n}static fromItemWithPublicData(t){let n=new e;return n.setPublicDataFromValue(t.value),n}static fromItemWithPlainData(t,n){let r=new e,i=t.getSalt();return r.setPlainDataFromValue(i,n.value),r}static fromItemWithHashedData(t,n){let r=new e,i=t.getSalt();return r.setHashedDataFromValue(i,n.value),r}static fromItemWithMaskedData(t,n){let r=new e,i=t.getSalt(),a=t.getSalt();return r.setMaskedDataFromAllParts(i,n.transformation.visibleParts,a,n.transformation.hiddenParts),r}setPublicDataFromValue(e){this.internalData={type:Z.Public,value:e}}setPlainDataFromValue(e,t){this.internalData={type:Z.Plain,salt:e,value:t}}setHashedDataFromValue(e,t){this.internalData={type:Z.HashableFromValue,salt:e,value:t}}setHashedDataFromHash(e,t){this.internalData={type:Z.Hashable,salt:e,hash:t}}setMaskedDataFromAllParts(e,t,n,r){let i={salt:e,parts:t},a={salt:n,parts:r};this.internalData={type:Z.MaskableFromAllParts,visible:i,hidden:a}}setMaskedDataFromVisibleParts(e,t,n){let r={salt:e,parts:t};this.internalData={type:Z.MaskableFromVisibleParts,visible:r,hiddenHash:n}}setToHashed(){let e=this.getInternalData();if(e.type==Z.Hashable)return;if(e.type!=Z.HashableFromValue)throw Error(`this field is not hashable`);let t=this.encoder.encode(e.value),n=j.Hashes.sha256AsBinary(t);this.setHashedDataFromHash(e.salt,n)}setToMasked(){let e=this.getInternalData();if(e.type==Z.MaskableFromVisibleParts)return;if(e.type!=Z.MaskableFromAllParts)throw Error(`this field is not maskable`);let t=this.encoder.encode(e.hidden),n=j.Hashes.sha256AsBinary(t);this.setMaskedDataFromVisibleParts(e.visible.salt,e.visible.parts,n)}getInternalData(){if(this.internalData===void 0)throw Error(`internal leaf data has not been set`);return this.internalData}fromProofField(e){switch(e.type){case gS.Public:this.setPublicDataFromValue(e.value);break;case gS.Plain:this.setPlainDataFromValue(k.binaryFromHexa(e.salt),e.value);break;case gS.HashableAsPlain:this.setHashedDataFromValue(k.binaryFromHexa(e.salt),e.value);break;case gS.HashableAsHash:this.setHashedDataFromHash(k.binaryFromHexa(e.salt),k.binaryFromHexa(e.hash));break;case gS.MaskableAsAllParts:this.setMaskedDataFromAllParts(k.binaryFromHexa(e.v_salt),e.v_parts,k.binaryFromHexa(e.h_salt),e.h_parts);break;case gS.MaskableAsVisibleParts:this.setMaskedDataFromVisibleParts(k.binaryFromHexa(e.v_salt),e.v_parts,k.binaryFromHexa(e.h_hash));break}}toProofFormat(e,t){let n=this.getInternalData();switch(n.type){case Z.Public:return{path:e,type:gS.Public,value:n.value};case Z.Plain:return{path:e,index:t,type:gS.Plain,salt:k.binaryToHexa(n.salt),value:n.value};case Z.HashableFromValue:return{path:e,index:t,type:gS.HashableAsPlain,salt:k.binaryToHexa(n.salt),value:n.value};case Z.Hashable:return{path:e,index:t,type:gS.HashableAsHash,salt:k.binaryToHexa(n.salt),hash:k.binaryToHexa(n.hash)};case Z.MaskableFromAllParts:return{path:e,index:t,type:gS.MaskableAsAllParts,v_salt:k.binaryToHexa(n.visible.salt),v_parts:n.visible.parts,h_salt:k.binaryToHexa(n.hidden.salt),h_parts:n.hidden.parts};case Z.MaskableFromVisibleParts:return{path:e,index:t,type:gS.MaskableAsVisibleParts,v_salt:k.binaryToHexa(n.visible.salt),v_parts:n.visible.parts,h_hash:k.binaryToHexa(n.hiddenHash)};default:throw Error(`invalid internal data type ${n.type}`)}}getCommitmentData(){let e=this.getInternalData();switch(e.type){case Z.Public:case Z.Plain:case Z.Hashable:return e;case Z.HashableFromValue:{let t=this.encoder.encode(e.value),n=j.Hashes.sha256AsBinary(t);return{type:Z.Hashable,salt:e.salt,hash:n}}case Z.MaskableFromAllParts:{let t=this.encoder.encode(e.visible),n=j.Hashes.sha256AsBinary(t),r=this.encoder.encode(e.hidden),i=j.Hashes.sha256AsBinary(r);return{type:Z.Maskable,visibleHash:n,hiddenHash:i}}case Z.MaskableFromVisibleParts:{let t=this.encoder.encode(e.visible),n=j.Hashes.sha256AsBinary(t);return{type:Z.Maskable,visibleHash:n,hiddenHash:e.hiddenHash}}default:throw Error(`invalid internal data type ${e.type}`)}}getHash(){let e=this.getCommitmentData(),t=this.encoder.encode(e);return j.Hashes.sha256AsBinary(t)}getRawValue(){let e=this.getInternalData();switch(e.type){case Z.Public:case Z.Plain:case Z.HashableFromValue:return e.value;case Z.Hashable:return k.binaryToHexa(e.hash);case Z.MaskableFromAllParts:return e.visible.parts.map((t,n)=>n&1?e.hidden.parts[n>>1]:t).join(``);case Z.MaskableFromVisibleParts:return e.visible.parts.join(``);default:throw Error(`invalid internal data type ${e.type}`)}}getTypedValue(){let e=this.getInternalData(),t=this.getRawValue();switch(e.type){case Z.Public:case Z.Plain:case Z.HashableFromValue:case Z.MaskableFromAllParts:return{disclosure:`plain`,value:t};case Z.Hashable:return{disclosure:`hashed`,value:t};case Z.MaskableFromVisibleParts:return{disclosure:`masked`,value:t};default:throw Error(`invalid internal data type ${e.type}`)}}},TS=class e{channelMap;fieldMap;publicChannels;constructor(){this.channelMap=new Map,this.fieldMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}static fromProofChannels(t){let n=new e;return n.setChannelsFromProofChannels(t),n}setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getLeavesByChannelMap();for(let[e,n]of t)this.channelMap.set(e,{nLeaves:n.length,leaves:n,tree:new CS,witnesses:[]});this.buildTrees(),this.buildFieldMap()}setChannelsFromProofChannels(e){for(let t of e){let e=[];for(let n of t.fields){let t=wS.fromProofFormat(n),r=n.type==gS.Public?0:n.index;e.push({leaf:t,path:n.path,index:r})}let n=t.witnesses.map(e=>k.binaryFromHexa(e));t.is_public&&this.publicChannels.add(t.id),this.channelMap.set(t.id,{nLeaves:t.n_leaves,leaves:e,tree:new CS,witnesses:n})}this.buildTrees(),this.buildFieldMap()}toJson(e=!1){let t={},n=[];for(let{leaves:e}of this.channelMap.values())for(let t of e)t!==null&&n.push(t);for(let{path:r,leaf:i}of n){let n=[`root`,...r],a=t;for(let t=0;t<n.length;t++){let r=n[t];if(t==n.length-1)a[r]=e?i.getTypedValue():i.getRawValue();else{let e=typeof n[t+1]==`number`;if(a[r]===void 0)a[r]=e?[]:{};else if(Array.isArray(a[r])!==e){let e=n.slice(0,t+1).join(`.`);throw Error(`${e} is defined as both an array and an object`)}a=a[r]}}}return t.root}buildTrees(){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){for(let e of t.leaves)e!==null&&t.tree.setLeaf(e.index,e.leaf.getHash());t.tree.finalize(t.nLeaves),t.tree.setWitnesses(t.witnesses)}}buildWitnesses(){for(let[e,t]of this.channelMap){if(this.publicChannels.has(e))continue;let n=new Set;for(let e of t.leaves)e!==null&&n.add(e.index);let r=[];for(let e=0;e<t.nLeaves;e++)n.has(e)||r.push(e);t.witnesses=t.tree.getWitnesses(r)}}buildFieldMap(){this.fieldMap.clear();for(let[e,t]of this.channelMap)for(let n=0;n<t.leaves.length;n++){let r=t.leaves[n];if(r===null)continue;let i=r.path,a=JSON.stringify(i);this.fieldMap.set(a,{channelId:e,index:n})}}getLeafByPath(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t).leaves[n];if(r===null)throw Error(`this field has been removed`);return r.leaf}getFieldByPath(e){let t=JSON.stringify(e),n=this.fieldMap.get(t);if(n===void 0)throw Error(`unknown path ${t}`);return n}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`unknown channel ID ${e}`);return t}removeField(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t);r.leaves[n]=null}setFieldToHashed(e){this.getLeafByPath(e).setToHashed()}setFieldToMasked(e){this.getLeafByPath(e).setToMasked()}getRootHashAsBinary(e){let t=this.getChannel(e);return this.publicChannels.has(e)?k.getNullHash():t.tree.getRootHash()}getRootHashAsHexString(e){let t=this.getRootHashAsBinary(e);return k.binaryToHexa(t)}toProofChannels(){this.buildWitnesses();let e=[];for(let[t,n]of this.channelMap){let r=this.publicChannels.has(t),i=[];for(let e of n.leaves){if(e===null)continue;let t=e.leaf.toProofFormat(e.path,e.index);i.push(t)}let a=n.witnesses.map(e=>k.binaryToHexa(e));e.push({id:t,is_public:r,n_leaves:n.nLeaves,fields:i,witnesses:a})}return e}},ES=class e{channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecord(t){let n=new e;n.setPublicChannels(t.getPublicChannels());let r=t.getItemList();for(let e of r){let t=e.item.channelId,r=n.channelMap.get(t);r===void 0&&(r=[],n.channelMap.set(t,r)),r.push(e)}return n}setChannel(e,t,n){t?this.publicChannels.add(e):this.publicChannels.delete(e),this.channelMap.set(e,n)}setPublicChannels(e){this.publicChannels=e}getPublicChannels(){return this.publicChannels}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getFlatItems(e){let t=this.channelMap.get(e);if(t==null)throw Error(`Channel ${e} not found`);return t}},DS=class{pepper;hasNullPepper;sha512;counter;constructor(e){this.pepper=e,this.sha512=new Uint8Array(64),this.counter=0,this.hasNullPepper=this.pepper.every(e=>e==0)}static generatePepper(){return j.Random.getBytes(32)}getPepper(){return this.pepper}getSalt(){let e=this.counter&3,t=this.counter++>>2;return!e&&!this.hasNullPepper&&(this.sha512=j.Hashes.sha512AsBinary(k.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},OS=class e{channelMap;recordByChannels;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecordByChannels(t,n=void 0){let r=new e;return r.setChannelsFromRecordByChannels(t,n),r}setChannelsFromRecordByChannels(e,t=void 0){this.publicChannels=e.getPublicChannels(),this.recordByChannels=e;let n=this.recordByChannels.getChannelIds();for(let e of n){let n=this.publicChannels.has(e),r=n?k.getNullHash():t===void 0?DS.generatePepper():t.get(e);if(r===void 0)throw Error(`no pepper specified for channel ${e}`);let i=this.recordByChannels.getFlatItems(e);this.storeChannel(e,n,i,r)}}storeChannel(e,t,n,r){let i=this.flatItemsToPositionedLeaves(n,t,r);this.channelMap.set(e,{pepper:r,positionedLeaves:i})}getPublicChannels(){return this.publicChannels}getLeavesByChannelMap(){let e=new Map;for(let[t,n]of this.channelMap)e.set(t,n.positionedLeaves);return e}getRecordByChannels(){let e=this.recordByChannels;if(e===void 0)throw Error(`recordByChannels is not set`);return e}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getChannelPepper(e){return this.getChannel(e).pepper}getChannelRootHash(e){let t=this.getChannel(e);if(this.publicChannels.has(e))return k.getNullHash();let n=new CS;for(let e of t.positionedLeaves){let t=e.leaf.getHash();n.addLeaf(t)}return n.finalize(),n.getRootHash()}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}flatItemsToPositionedLeaves(e,t,n){let r=new DS(n);return e.map((e,n)=>({leaf:this.flatItemToLeaf(r,t,e.item),index:n,path:e.path}))}flatItemToLeaf(e,t,n){let r=n.type==lS.String?n.transformation.type:sS.None;if(t&&r!=sS.None)throw Error(`no transformation may be applied to a public field`);switch(r){case sS.None:return t?wS.fromItemWithPublicData(n):wS.fromItemWithPlainData(e,n);case sS.Hashable:return wS.fromItemWithHashedData(e,n);case sS.Maskable:return wS.fromItemWithMaskedData(e,n);default:throw Error(`unsupported transformation type ${r}`)}}},kS=class e{itemList;publicChannels;constructor(){this.itemList=[],this.publicChannels=new Set}static fromObject(t){let n=new e,r=L(aS,t);return n.buildItemListByDfs(r),n}setChannelAsPublic(e){this.publicChannels.add(e)}setChannelAsPrivate(e){this.publicChannels.delete(e)}getPublicChannels(){return this.publicChannels}setChannel(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setFieldChannel(e.item,t)}setFieldChannel(e,t){e.channelId=t}setAsHashable(e){let t=this.getFieldsByPathString(e);for(let e of t)this.setFieldAsHashable(e.item)}setFieldAsHashable(e){if(e.type!==lS.String)throw Error(`only a string may be set as hashable`);e.transformation={type:sS.Hashable}}setMaskOnField(e,t){if(e.type!==lS.String)throw Error(`a mask may only be applied to a string`);let n=[],r=[];t.sort((e,t)=>e.start-t.start),t.forEach((i,a)=>{let o=a>0?t[a-1].start:0,s=a>0?t[a-1].end:0;if(i.start<0||i.start>=e.value.length||i.end<=i.start)throw`invalid interval [${[i.start,i.end]}]`;if(i.start<s)throw`overlapping intervals [${[o,s]}] and [${[i.start,i.end]}]`;let c=e.value.slice(i.start,i.end);a&&i.start==s?(n[n.length-1]+=i.replacement,r[r.length-1]+=c):(n.push(e.value.slice(s,i.start),i.replacement),r.push(c)),a==t.length-1&&i.end<e.value.length&&n.push(e.value.slice(i.end))}),e.transformation={type:sS.Maskable,visibleParts:n,hiddenParts:r}}setMaskByPositions(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setMaskOnField(e.item,t)}setMaskByRegex(e,t,n){let r=this.getFieldsByPathString(e);for(let e of r)this.setMaskByRegexOnField(e.item,t,n)}setMaskByRegexOnField(e,t,n){if(e.type!==lS.String)throw Error(`a mask may only be applied to a string`);let r=(t.exec(e.value)||[]).slice(1);if(r.join(``)!=e.value)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>({shown:!!(t&1),string:e})).filter(e=>e.string!=``);if(i.length!=r.length||i.some((e,t)=>e.shown&&e.string!=`$`+(t+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;i.forEach((e,t)=>{let n=o+r[t].length;e.shown||a.push({start:o,end:n,replacement:e.string}),o=n}),this.setMaskOnField(e,a)}getItemList(){return this.itemList}getFieldsByPathString(e){let t=e.match(/\[\d+\]|[^.[]+/g)||[];if(t[0]!==`this`)throw Error(`the path should begin with 'this'`);let n=t.slice(1).map(e=>e[0]==`[`?Number(e.slice(1,-1)):e);if(n.some((e,t)=>e==`*`&&t!=n.length-1))throw Error(`a wildcard may only appear at the end of the path`);let r=n[n.length-1]==`*`;return this.itemList.filter(e=>{let t;if(r){if(e.path.length<n.length)return!1;t=n.slice(0,-1)}else{if(e.path.length!=n.length)return!1;t=n}return t.every((t,n)=>t===e.path[n])})}static getValueType(e){if(typeof e==`string`)return lS.String;if(typeof e==`number`)return lS.Number;if(typeof e==`boolean`)return lS.Boolean;if(e===null)return lS.Null;if(Array.isArray(e))return lS.Array;if(typeof e==`object`&&Object.getPrototypeOf(e).isPrototypeOf(Object))return lS.Object;throw Error(`unsupported field type`)}static getPrimitiveValueType(t){let n=e.getValueType(t);if(n==lS.Array||n==lS.Object)throw Error(`expected a primitive value, got an array or an object`);return n}buildItemListByDfs(t,n=[]){switch(e.getValueType(t)){case lS.String:this.addFlatItem(n,this.buildStringItem(t));break;case lS.Number:this.addFlatItem(n,this.buildNumberItem(t));break;case lS.Boolean:this.addFlatItem(n,this.buildBooleanItem(t));break;case lS.Null:this.addFlatItem(n,this.buildNullItem());break;case lS.Array:this.buildArrayItem(t,n);break;case lS.Object:this.buildObjectItem(t,n);break;default:throw Error(`unsupported field type`)}}addFlatItem(e,t){let n={path:e,item:t};this.itemList.push(n)}buildStringItem(e){return{type:lS.String,value:e,transformation:{type:sS.None},channelId:-1}}buildNumberItem(e){return{type:lS.Number,value:e,channelId:-1}}buildBooleanItem(e){return{type:lS.Boolean,value:e,channelId:-1}}buildNullItem(){return{type:lS.Null,value:null,channelId:-1}}buildArrayItem(e,t){e.forEach((e,n)=>{this.buildItemListByDfs(e,[...t,n])})}buildObjectItem(e,t){Object.keys(e).forEach(n=>{let r=e[n];this.buildItemListByDfs(r,[...t,n])})}},AS=class e{encoder=new hx;channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}logger=ts.getLogger([e.name]);setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getRecordByChannels(),n=e.getChannelIds();for(let r of n){let n=e.getChannelPepper(r),i=e.getChannelRootHash(r),a=t.getFlatItems(r).map(e=>({path:e.path,value:e.item.value,...e.item.transformation?{transformation:e.item.transformation}:{}}));this.channelMap.set(r,{rootHash:i,pepper:n,onChainItems:a})}}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getOnChainData(e,t=!1){let n=this.getChannel(e),r=new hx().encode(n.onChainItems),i={pepper:n.pepper,data:r},a=this.encoder.encode(i);return{isPublic:this.publicChannels.has(e),merkleRootHash:n.rootHash,data:a}}addOnChainData(e,t,n,r){if(this.channelMap.has(e))throw Error(`channel ${e} has already been set`);t?this.publicChannels.add(e):this.publicChannels.delete(e);let i=this.encoder.decode(r);L(pS,i);let a=i.pepper,o=this.encoder.decode(i.data);L(hS,o),this.channelMap.set(e,{rootHash:n,pepper:a,onChainItems:o})}toMerkleRecord(e=!0){let t=new ES,n=new Map;for(let[e,r]of this.channelMap){let i=r.onChainItems.map(t=>{let n={channelId:e,type:kS.getPrimitiveValueType(t.value),value:t.value,...t.transformation?{transformation:t.transformation}:{}};return{path:t.path,item:n}}),a=this.publicChannels.has(e);t.setChannel(e,a,i),n.set(e,r.pepper)}let r=OS.fromRecordByChannels(t,n);if(e){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){let n=r.getChannelRootHash(e);if(!k.binaryIsEqual(n,t.rootHash))throw Error(`inconsistent Merkle root hash for private channel ${e} (computed ${k.binaryToHexa(n)}, on-chain value is ${k.binaryToHexa(t.rootHash)})`)}}return r}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}},jS=class e extends Ux{static createApplicationLedgerVirtualBlockchain(t){return new e(t)}draftModeEnabled=!1;constructor(e,t=wx.createInitialState()){super(e,V.APP_LEDGER_VIRTUAL_BLOCKCHAIN,t)}async isAccountIdAllowedToWrite(e){if(this.getHeight()===0)return!0;let t=await this.getVirtualBlockchainOwnerId(),n=this.internalState.getAdditionalAllowedWriters();return[t.toBytes(),...n].some(t=>k.binaryIsEqual(t,e.toBytes()))}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?k.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async updateInternalState(e,t,n){let r=e.getApplicationLedgerInternalStateUpdaterVersion();return Rx.createApplicationLedgerInternalStateUpdater(r).updateState(this.provider,this.internalState,n)}checkMicroblockStructure(e){return this.draftModeEnabled?!0:new rS().checkMicroblockStructure(e)}enableDraftMode(){this.draftModeEnabled=!0}disableDraftMode(){this.draftModeEnabled=!1}setInternalState(e){this.internalState=e}isActorDefined(e){return this.internalState.isActorDefinedByName(e)}actorIsSubscribed(e){return this.getActor(e).subscribed}getInternalState(){return this.internalState}async getActorIdByPublicSignatureKey(t){let n=ts.getLogger([e.name]),r=this.internalState,i=t.getPublicKeyAsBytes();for(let e=0;e<r.getNumberOfActors();e++){let t=r.getActorById(e);if(n.debug(`Search current actor id: loop index ${e}`),t.subscribed)try{let r=await this.getMicroblock(t.signatureKeyHeight);for(let a of r.getAllSections()){if(a.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION)continue;let{actorId:r}=a;if(r!==e)continue;let{signaturePublicKey:o}=a,s=k.binaryIsEqual(a.signaturePublicKey,await i);if(n.debug(`Is public key matching for actor ${t.name} (id ${e})? ${o} and ${i}: ${s}`),s)return n.debug(`Matching public signature key: {actor.name} (id ${e})`,{actor:t}),e}}catch(e){if(e instanceof x)n.debug(`{e}`,{e});else if(e instanceof Te)n.debug(`{e}`,{e});else throw e}}throw n.debug(`Current actor not found`),new fe}async getPublicEncryptionKeyByActorId(e){let t=this.internalState.getActorById(e).pkeKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.pkePublicKey,r=t.pkeSchemeId;return zv.createPublicEncryptionKey(r,n)}}throw new we(e,this.getActorNameById(e))}async getPublicSignatureKeyByActorId(e){let t=this.internalState.getActorById(e).signatureKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.signaturePublicKey,r=t.signatureSchemeId;return zv.createPublicSignatureKey(r,n)}}throw new Ce(`Actor ${e} has not subscribed to a public signature key.`)}async getExistingSharedKey(e,t){let n=this.internalState.getActorById(t).sharedSecrets.find(t=>t.peerActorId==e);if(n===void 0)return;let r=await this.getMicroblock(n.height);for(let n of r.getAllSections())if(n.type===O.APP_LEDGER_SHARED_SECRET&&!(n.hostId!==e||n.guestId!==t))return n.encryptedSharedKey;throw new Ee(t,e)}getChannelIdByChannelName(e){return this.internalState.getChannelIdFromChannelName(e)}getActorNameById(e){return this.internalState.getActorById(e).name}getChannelNameById(e){return this.internalState.getChannelFromChannelId(e).name}getActorIdFromActorName(e){return this.internalState.getActorIdByName(e)}getActor(e){return this.internalState.getActorByName(e)}getAllActors(){return this.internalState.getAllActors()}getAllChannels(){return this.internalState.getAllChannels()}async getOrganizationId(){let e=this.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getOrganizationId()}getApplicationId(){return this.internalState.getApplicationId()}getNumberOfChannels(){return this.internalState.getNumberOfChannels()}getChannelById(e){return this.internalState.getChannelFromChannelId(e)}getNumberOfActors(){return this.internalState.getNumberOfActors()}async getMicroblockMerkleRecord(t,n){let r=await this.getMicroblock(t),i=[];for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PUBLIC_CHANNEL_DATA)continue;let{channelId:t,data:n}=e;i.push({channelId:t,isPublic:!0,merkleRootHash:k.getNullHash(),data:n})}let a=ts.getLogger([e.name]);if(n!==void 0){let o=await(await n.getPrivateSignatureKey(Ya.SECP256K1)).getPublicKey(),s;try{s=await this.getActorIdByPublicSignatureKey(o)}catch(t){if(t instanceof fe)ts.getLogger([e.name]).debug(`Unabled to recover private channels: {e}`,{e:t});else throw t}if(typeof s==`number`)for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PRIVATE_CHANNEL_DATA)continue;let{channelId:r,encryptedData:o,merkleRootHash:c}=e;try{let e=await this.getChannelKey(s,r,n),l=this.deriveChannelSectionKey(e,t,r),u=this.deriveChannelSectionIv(e,t,r);a.debug(`Channel key ${e} at height ${t} and channel id ${r} -> Channel section key: ${l} (iv ${u}) `);let d=j.Aes.decryptGcm(l,o,u);a.debug(`Allowed to access private channel {channelName} (channel id={channelId})`,()=>({channelName:this.getChannelNameById(r),channelId:r})),i.push({channelId:r,isPublic:!1,merkleRootHash:c,data:d})}catch(e){if(e instanceof f||e instanceof me)a.debug(`Access to private channel {channelName} forbidden (channel id={channelId}): {e}`,()=>({e,channelName:this.getChannelNameById(r),channelId:r}));else throw e}}}else console.warn(`No private channel loaded: no private decryption key provided.`);let o=new AS;for(let e of i)o.addOnChainData(e.channelId,e.isPublic,e.merkleRootHash,e.data);return o.toMerkleRecord(!1)}deriveChannelSectionKey(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_KEY`,t,n,32)}deriveChannelSectionIv(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_IV`,t,n,12)}deriveChannelSectionMaterial(e,t,n,r,i){let a=new Uint8Array,o=new TextEncoder,s=k.binaryFrom(o.encode(t),r,new Uint8Array(k.intToByteArray(n,6)));return new _v().deriveKey(e,a,s,i)}async getChannelKey(e,t,n){nS.assert(typeof e==`number`,`Expected actor id with type number`),nS.assert(typeof t==`number`,`Expected channel id of type number: got ${typeof t}`);let r=this.internalState.getChannelCreatorIdFromChannelId(t),i=await n.getPrivateDecryptionKey(vv.ML_KEM_768_AES_256_GCM);if(r===e){let e=n.getSeedAsBytes();return await this.deriveChannelKey(e,t)}return await this.getChannelKeyFromInvitation(e,t,i)}async deriveChannelKey(e,t){let n=await this.getGenesisSeed(),r=new TextEncoder,i=k.binaryFrom(r.encode(`CHANNEL_KEY`)),a=k.binaryFrom(e,r.encode(`GENESIS_SEED`),n.toBytes(),r.encode(`CHANNEL_ID`),k.binaryFrom(t));return new _v().deriveKeyNoSalt(a,i,32)}async getChannelKeyFromInvitation(e,t,n){nS.assert(typeof e==`number`,`actorId should be a number, got ${typeof e}`),nS.assert(typeof t==`number`,`channelId should be a number, got ${typeof e}`);let r=this.internalState.getActorById(e).invitations.find(e=>e.channelId==t);if(!r){let n=this.internalState.getActorById(e).name,r=this.internalState.getChannelFromChannelId(t).name;throw new me(n,r)}let i=await this.getMicroblock(r.height),a;for(let n of i.getAllSections())n.type===O.APP_LEDGER_CHANNEL_INVITATION&&(n.guestId!==e||n.channelId!==t||(a=n));if(a===void 0)throw new me(e,t);let o=a.encryptedChannelKey;return await n.decrypt(o)}async exportProof(e,t){let n=new iS;n.setIdentifier(k.binaryToHexa(this.getIdentifier().toBytes()));for(let e=1;e<=this.getHeight();e++){let r=await this.getMicroblockMerkleRecord(e,t);console.log(`Merkle record at height ${e}:`,r);let i=TS.fromMerkleRecord(r);console.log(`Proof record at height ${e}:`,i);let a=i.toProofChannels();console.log(`Proof channels at height ${e}:`,a),n.addMicroblock(e,a)}let r=new SS;return r.setAuthor(e.author),r.addVirtualBlockchain(n),r.getObject()}async importProof(e){let t=[],n=SS.fromObject(e).getSingleVirtualBlockchainOrFail().getMicroblocks();for(let e of n){let n=e.height,r=await this.getMicroblock(n),i=[];for(let e of r.getAllSections())if(e.type===O.APP_LEDGER_PUBLIC_CHANNEL_DATA){let{channelId:t}=e;i.push({channelId:t,merkleRootHash:k.getNullHash()})}else if(e.type===O.APP_LEDGER_PRIVATE_CHANNEL_DATA){let{channelId:t,merkleRootHash:n}=e;i.push({channelId:t,merkleRootHash:n})}console.log(`ProofMicroblock.channels=`,e.channels);let a=TS.fromProofChannels(e.channels);for(let e of i){let t=a.getRootHashAsBinary(e.channelId);if(!k.binaryIsEqual(e.merkleRootHash,t)){console.log(t,e);let n=k.binaryToHexa(t),r=k.binaryToHexa(e.merkleRootHash);throw new se(e.channelId,n,r)}}t.push({height:n,data:a.toJson()})}return t}async getRecord(e,t){let n=await this.getMicroblockMerkleRecord(e,t);return TS.fromMerkleRecord(n).toJson()}async isActorInChannel(e,t){return this.internalState.getActorById(t).invitations.some(t=>t.channelId==e)}},MS=class e{constructor(e){this.value=e}static of(t){return new e(t)}static some(t){return new e(t)}static none(){return new e(null)}map(t){return this.value===null?e.none():e.some(t(this.value))}unwrap(){if(this.value===null)throw Error(`Called unwrap on a None value`);return this.value}unwrapOrThrow(e){if(this.value===null)throw e;return this.value}unwrapOr(e){return this.value===null?e:this.value}isSome(){return this.value!==null}isNone(){return this.value===null}},NS=class{_error=MS.none();hash;header;verificationState={isMicroblockParsingCompleted:!1};constructor(e,t){this.provider=e,this.checkedMicroblock=t}async checkVirtualBlockchainConsistencyOrFail(){if(this.verificationState.isMicroblockParsingCompleted)throw new a(`You have already called parseMicroblock() method. You can only call it once.`);if(!this.checkedMicroblock.isDeclaringConsistentBodyHash())throw Error(`inconsistent body hash detected for microblock hash ${k.binaryToHexa(this.checkedMicroblock.getHashAsBytes())}`);let e=this.checkedMicroblock.getType(),t=0,n,r=this.checkedMicroblock.getPreviousHash().toBytes();if(this.checkedMicroblock.isGenesisMicroblock()){let t=r;e=Vx.extractTypeFromGenesisPreviousHash(t),n=this.checkedMicroblock.getHash()}else{let e=await this.provider.getMicroblockHeader(Sx.from(r));if(!e)throw Error(`previous microblock ${k.binaryToHexa(r)} not found`);if(this.checkedMicroblock.getHeight()!=e.height+1)throw Error(`inconsistent microblock height (expected ${e.height+1}, got ${this.checkedMicroblock.getHeight()})`);let t=Y.computeMicroblockHashFromHeader(e);n=await this.provider.getVirtualBlockchainIdContainingMicroblock(Sx.from(t))}let i;if(this.checkedMicroblock.isGenesisMicroblock()){switch(e){case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=new qx(this.provider);break;case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=new Yx(this.provider);break;case V.APPLICATION_VIRTUAL_BLOCKCHAIN:i=new Zx(this.provider);break;case V.NODE_VIRTUAL_BLOCKCHAIN:i=new $x(this.provider);break;case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=new tS(this.provider);break;case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=new jS(this.provider);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}let n=this.checkedMicroblock.getPreviousHash().toBytes();t=Vx.extractExpirationDayFromGenesisPreviousHash(n),i.setExpirationDay(t)}else switch(e){case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadOrganizationVirtualBlockchain(n);break;case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadAccountVirtualBlockchain(n);break;case V.APPLICATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationVirtualBlockchain(n);break;case V.NODE_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadValidatorNodeVirtualBlockchain(n);break;case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadProtocolVirtualBlockchain(n);break;case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationLedgerVirtualBlockchain(n);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}await i.appendMicroBlock(this.checkedMicroblock),this.verificationState={isMicroblockParsingCompleted:!0,virtualBlockchain:i}}checkTimestampOrFail(e){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock;e||=k.getTimestampInSeconds();let n=t.isTemporallyCloseTo(e);if(n===zx.TOO_FAR_IN_THE_PAST)throw Error(`timestamp is too far in the past (header:${this.header.timestamp} / current:${e})`);if(n===zx.TOO_FAR_IN_THE_FUTURE)throw Error(`timestamp is too far in the future (header:${this.header.timestamp} / current:${e})`)}async checkGasOrFail(e=k.getTimestampInSeconds()){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock,n=await this.provider.computeMicroblockFees(t,{referenceTimestampInSeconds:e}),r=t.getMaxFees();if(r.getAmountAsAtomic()<n.getAmountAsAtomic())throw Error(`Computed fees ${n.toString()} is strictly higher than max fees ${r.toString()} `)}get virtualBlockchain(){if(this.verificationState.isMicroblockParsingCompleted)return this.verificationState.virtualBlockchain;throw new a(`Virtual blockchain not initialized.`)}getVirtualBlockchain(){return this.virtualBlockchain}getMicroblock(){return this.checkedMicroblock}getHash(){return this.hash}getError(){return this._error}containsError(){return this._error.isSome()}get error(){return this.containsError()?this._error.unwrap().toString():``}},PS=class{stateUpdater;constructor(e,t,n){this.mbUnderConstruction=e,this.vb=t,this.provider=n}onMicroblockSearchFailureForExceedingHeight(e,t){if(e.getHeight()+1===t)return Promise.resolve(this.mbUnderConstruction);throw new x(e.getIdentifier(),t)}getBuiltMicroblock(){return this.mbUnderConstruction}async updateStateWithSection(e){if(!this.stateUpdater){let e=await this.provider.getProtocolState();this.stateUpdater=Rx.createApplicationLedgerInternalStateUpdater(e.getApplicationLedgerInternalStateUpdaterVersion())}this.vb.setInternalState(await this.stateUpdater.updateStateFromSection(this.provider,this.vb.getInternalState(),e,this.mbUnderConstruction.getHeight()))}getInternalState(){return this.vb.getInternalState()}},FS=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WALLET=1]=`WALLET`,e[e.OPERATOR=2]=`OPERATOR`,e}({}),IS=F({name:I()}),LS=F({name:I(),public:Kp()}),RS=F({fieldPath:I(),channelName:I()}),zS=F({actorName:I(),channelName:I()}),BS=F({position:P(),length:P(),replacementString:I()}),VS=F({fieldPath:I(),maskedParts:M(BS)}),HS=F({fieldPath:I()}),US=F({virtualBlockchainId:Qp(I()),data:Gp(),actors:Qp(M(IS)),channels:Qp(M(LS)),channelAssignations:Qp(M(RS)),actorAssignations:Qp(M(zS)),hashableFields:Qp(M(HS)),maskableFields:Qp(M(VS)),author:I(),endorser:Qp(I()),approvalMessage:Qp(I())}),WS=class{static validate(e){return L(US,e)}static safeParse(e){return am(US,e)}static is(e){return Wp(US,e)}},GS=class e extends PS{logger=ts.getLogger([e.name]);static async createFromVirtualBlockchain(t,n){let r=await n.createMicroblock(),i=new e(r,n);if(n.setMicroblockSearchFailureFallback(i),n.isEmpty()){let e={type:O.APP_LEDGER_CREATION,applicationId:t.toBytes()};r.addSection(e),await i.updateStateWithSection(e)}return i}usedSignatureSchemeId=Ya.SECP256K1;usedPkeSchemeId=vv.ML_KEM_768_AES_256_GCM;constructor(e,t){super(e,t,t.getProvider())}get state(){return this.getInternalState()}getActorPrivateSignatureKey(e){return e.getPrivateSignatureKey(this.usedSignatureSchemeId)}getActorPrivateDecryptionKey(e){return e.getPrivateDecryptionKey(this.usedPkeSchemeId)}async createMicroblockFromStateUpdateRequest(e,t){let n=WS.validate(t),r=await this.getActorPrivateDecryptionKey(e),a=await this.getActorPrivateSignatureKey(e),o=this.state.getNumberOfActors();for(let e of n.actors||[]){console.log(this.state.getAllActors());let t=e.name;this.vb.isActorDefined(t)?console.log(`Skipping actor creation: ${t} already created`):(await this.createActor(o,e.name),o+=1)}let s=n.author,c=this.getActorIdFromActorName(s);if(this.vb.isEmpty()){let e=await r.getPublicKey();await this.subscribeActor(s,await a.getPublicKey(),e)}let l=this.state.getNumberOfChannels();for(let e of n.channels||[]){let t={type:O.APP_LEDGER_CHANNEL_CREATION,id:l,isPrivate:!e.public,creatorId:c,name:e.name};this.mbUnderConstruction.addSection(t),await this.updateStateWithSection(t),l+=1}let u=kS.fromObject(n.data);for(let e of n.channelAssignations||[]){let t=this.state.getChannelIdFromChannelName(e.channelName);u.setChannel(e.fieldPath,t)}for(let t of n.actorAssignations||[]){let n=t.channelName,r=t.actorName;await this.inviteActorOnChannel(r,n,e)}for(let e of n.hashableFields||[])u.setAsHashable(e.fieldPath);for(let e of n.maskableFields||[]){let t=e.maskedParts.map(e=>({start:e.position,end:e.position+e.length,replacement:e.replacementString}));u.setMaskByPositions(e.fieldPath,t)}let d=this.state.getAllChannels();for(let e in d){let t=Number(e);d[t].isPrivate||u.setChannelAsPublic(Number(t))}let f=ES.fromRecord(u),p=OS.fromRecordByChannels(f),m=AS.fromMerkleRecord(p),h=m.getChannelIds();for(let t of h){let n=m.getOnChainData(t),{isPublic:r,merkleRootHash:i}=n;if(r){let e={type:O.APP_LEDGER_PUBLIC_CHANNEL_DATA,channelId:t,data:n.data};this.mbUnderConstruction.addSection(e),await this.updateStateWithSection(e)}else{let r=ts.getLogger([`critical`]),a=this.vb.getHeight()+1,o=await this.vb.getChannelKey(c,t,e),s=this.vb.deriveChannelSectionKey(o,a,t),l=this.vb.deriveChannelSectionIv(o,a,t);r.debug(`Channel key ${o} at height ${a} and channel id ${t} -> Channel section key: ${s} (iv ${l}) `);let u=j.Aes.encryptGcm(s,n.data,l),d={type:O.APP_LEDGER_PRIVATE_CHANNEL_DATA,channelId:t,merkleRootHash:i,encryptedData:u};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}}if(typeof n.endorser==`string`){if(n.endorser.trim().length===0)throw new i(`Empty endorser provided: should be a non-empty string or undefined`);let e=this.getActorIdFromActorName(n.endorser),t=n.approvalMessage??``,r={type:O.APP_LEDGER_ENDORSEMENT_REQUEST,message:t,endorserId:e};this.mbUnderConstruction.addSection(r),await this.updateStateWithSection(r)}return this.mbUnderConstruction}async createActor(e,t){console.log(`Creating actor ${t} (id ${e})`);let n={type:O.APP_LEDGER_ACTOR_CREATION,id:e,actorType:FS.UNKNOWN,name:t};this.mbUnderConstruction.addSection(n),await this.updateStateWithSection(n)}async inviteActorOnChannel(e,t,n){console.log(`Inviting actor `+e+` on channel `+t);let r=this.state.getChannelIdFromChannelName(t),i=this.getActorIdFromActorName(e),a=await this.getActorPrivateSignatureKey(n),o=await this.vb.getActorIdByPublicSignatureKey(await a.getPublicKey());nS.assert(typeof r==`number`,`Expected channel id of type number: got ${typeof r} for channel ${t}`);let s=i;if(await this.vb.isActorInChannel(r,s))return;let c=await this.vb.getChannelKey(o,r,n),l=await(await this.vb.getPublicEncryptionKeyByActorId(s)).encrypt(c),u=ts.getLogger([jS.name]);u.info(`Actor {guestName} invited to channel ${t}`,()=>({guestName:e})),u.debug(`Channel key for channel ${t}: ${c}`);let d={type:O.APP_LEDGER_CHANNEL_INVITATION,channelId:r,hostId:o,guestId:s,encryptedChannelKey:l};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}async createSharedKey(e,t,n){let{encryptedSharedKey:r,hostGuestSharedKey:i}=await this.generateSharedKeyAndEncryptedSharedKey(e,n),a={type:O.APP_LEDGER_SHARED_SECRET,hostId:t,guestId:n,encryptedSharedKey:r};return this.mbUnderConstruction.addSection(a),await this.updateStateWithSection(a),i}static deriveHostGuestSharedKey(e,t,n){let r=e.getRawPrivateKey(),i=new TextEncoder,a=k.binaryFrom(i.encode(`SHARED_SECRET`),n),o=new _v,s=k.binaryFrom(r,t),c=o.deriveKeyNoSalt(s,a,32);return Ig.createFromBytes(c)}async generateSharedKeyAndEncryptedSharedKey(t,n){let r=await this.getGenesisSeed(),i=e.deriveHostGuestSharedKey(t,r.toBytes(),n);return{encryptedSharedKey:await(await this.vb.getPublicEncryptionKeyByActorId(n)).encrypt(i.getRawSecretKey()),hostGuestSharedKey:i}}async getGenesisSeed(){return this.vb.isEmpty()?this.mbUnderConstruction.getPreviousHash():await this.vb.getGenesisSeed()}async subscribeActor(e,t,n){if(console.debug(`Subscribing ${e}`),!this.vb.isActorDefined(e)){console.log(`It appears that ${e} does not exist: create it`);let t=this.vb.getNumberOfActors();await this.createActor(t,e)}let r=FS.UNKNOWN,i=this.getActorIdFromActorName(e),a=k.getNullHash(),o={type:O.APP_LEDGER_ACTOR_SUBSCRIPTION,actorId:i,actorType:r,organizationId:a,signatureSchemeId:t.getSignatureSchemeId(),signaturePublicKey:await t.getPublicKeyAsBytes(),pkeSchemeId:n.getSchemeId(),pkePublicKey:await n.getRawPublicKey()};this.mbUnderConstruction.addSection(o),await this.updateStateWithSection(o)}getActorIdFromActorName(e){return this.state.getActorIdByName(e)}},KS=class e{static ED25519_PUBLIC_KEY_TYPE=`tendermint/PubKeyEd25519`;static createFromEd25519PublicKey(t){return new e(e.ED25519_PUBLIC_KEY_TYPE,t)}constructor(e,t){this.type=e,this.publicKey=t}getType(){return this.type}getPublicKey(){return this.publicKey}},qS=class{encodeSignature(e){return e}decodeSignature(e){return e}encodeMessage(e){return e}decodeMessage(e){return e}async encodePublicKey(e){return Us(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),publicKey:gl(await e.getPublicKeyAsBytes())}))}async decodePublicKey(e){let t=JSON.parse(xl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.publicKey==`string`){let e=yl(t.publicKey);return new zv().createPublicSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and publicKey fields.`}async encodePrivateKey(e){return Us(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),privateKey:gl(e.getPrivateKeyAsBytes())}))}async decodePrivateKey(e){let t=JSON.parse(xl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.privateKey==`string`){let e=yl(t.privateKey);return zv.createPrivateSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and privateKey fields.`}},JS=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ya.ED25519}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},YS=class extends Bg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return K_(t,Kc(e),this.publicKey)}getScheme(){return new JS}},XS=new TextEncoder,ZS=new TextDecoder;function QS(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function $S(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function eC(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:ZS.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=ZS.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return $S(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function tC(e){let t=e;return typeof t==`string`&&(t=XS.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):QS(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var nC=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},rC=class extends nC{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},iC=e=>typeof e==`object`&&!!e;function aC(e){if(!iC(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var oC=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function sC(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new rC(oC)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new rC(oC)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new rC(oC)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new rC(oC)}break;default:throw new rC(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function cC(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=sC(e),r={...e};return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??!(e.d||e.priv),e.key_ops??n)}async function lC(e,t,n){if(!aC(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return eC(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new rC(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return cC({...e,alg:t,ext:r});case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return cC({...e,ext:r});case`EC`:case`OKP`:return cC({...e,alg:t,ext:r});default:throw new rC(`Unsupported "kty" (Key Type) Parameter value`)}}q_.sha512=Jc;var uC=class e extends zg{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(J_.randomSecretKey())}static genFromSeed(t){return new e(t)}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new YS(B_(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return U_(Kc(e),this.privateKey)}getScheme(){return new JS}},dC=class{static async exportPublicSignatureKey(e){if(e instanceof YS)return await lC({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,x:tC(await e.getPublicKeyAsBytes())});throw Error(`Unsupported public key type`)}static async exportPrivateSignatureKey(e){if(e instanceof uC){let t=e.getPrivateKeyAsBytes(),n=await(await e.getPublicKey()).getPublicKeyAsBytes();return await lC({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,d:tC(t),x:tC(n)})}throw Error(`Unsupported key type`)}},fC=class{static defaultEncoder(){return Bv.createBase64HCVPkeEncoder()}},pC=class{encodeAsUint8Array(e){return Us(JSON.stringify({symmetricEncryptionSchemeId:e.getSymmetricEncryptionSchemeId(),key:gl(e.getRawSecretKey())}))}decodeFromUint8Array(e){let t=JSON.parse(xl(e));if(t&&typeof t.symmetricEncryptionSchemeId==`number`&&typeof t.key==`string`){let e=yl(t.key);return new zv().createSymmetricEncryptionKey(t.symmetricEncryptionSchemeId,e)}else throw`Invalid symmetric encryption key format: expected raw-encoded JSON object with symmetricEncryptionSchemeId and key fields.`}};function mC(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],ee=e[t++]^n[r++],x=o,te=s,S=c,ne=l,re=u,ie=d,ae=f,oe=p,se=m,ce=h,C=g,le=_,ue=v,de=y,fe=b,pe=ee;for(let e=0;e<8;e+=2)re^=Ps(x+ue|0,7),se^=Ps(re+x|0,9),ue^=Ps(se+re|0,13),x^=Ps(ue+se|0,18),ce^=Ps(ie+te|0,7),de^=Ps(ce+ie|0,9),te^=Ps(de+ce|0,13),ie^=Ps(te+de|0,18),fe^=Ps(C+ae|0,7),S^=Ps(fe+C|0,9),ae^=Ps(S+fe|0,13),C^=Ps(ae+S|0,18),ne^=Ps(pe+le|0,7),oe^=Ps(ne+pe|0,9),le^=Ps(oe+ne|0,13),pe^=Ps(le+oe|0,18),te^=Ps(x+ne|0,7),S^=Ps(te+x|0,9),ne^=Ps(S+te|0,13),x^=Ps(ne+S|0,18),ae^=Ps(ie+re|0,7),oe^=Ps(ae+ie|0,9),re^=Ps(oe+ae|0,13),ie^=Ps(re+oe|0,18),le^=Ps(C+ce|0,7),se^=Ps(le+C|0,9),ce^=Ps(se+le|0,13),C^=Ps(ce+se|0,18),ue^=Ps(pe+fe|0,7),de^=Ps(ue+pe|0,9),fe^=Ps(de+ue|0,13),pe^=Ps(fe+de|0,18);i[a++]=o+x|0,i[a++]=s+te|0,i[a++]=c+S|0,i[a++]=l+ne|0,i[a++]=u+re|0,i[a++]=d+ie|0,i[a++]=f+ae|0,i[a++]=p+oe|0,i[a++]=m+se|0,i[a++]=h+ce|0,i[a++]=g+C|0,i[a++]=_+le|0,i[a++]=v+ue|0,i[a++]=y+de|0,i[a++]=b+fe|0,i[a++]=ee+pe|0}function hC(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)mC(n,o,e,t,n,a),r>0&&(o+=16),mC(n,a,e,t+=16,n,o)}function gC(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=qs({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(Ts(r),Ts(i),Ts(a),Ts(o),Ts(s),Ts(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4,f=2**32;if(r<=1||r&r-1||r>f)throw Error(`Scrypt: N must be larger than 1, a power of 2, and less than 2^32`);if(a<0||a>(f-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(f-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);if(u*(r+a)>c)throw Error(`Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of `+c);let p=ov(Kc,e,t,{c:1,dkLen:u*a}),m=As(p),h=As(new Uint8Array(u*r)),g=As(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function _C(e,t,n,r,i){let a=ov(Kc,e,n,{c:1,dkLen:t});return js(n,r,i),a}function vC(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=gC(e,t,n);Rs(l);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)hC(c,t,c,t+=s,i),f();hC(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];hC(d,0,l,t,i),f()}}return Rs(l),_C(e,o,u,c,d)}var yC=class extends cv{getKeyDerivationFunctionSchemeId(){return sv.SCRYPT}deriveKey(e,t,n){return vC(e,t,{N:2**16,r:8,p:1,dkLen:n})}},bC=class{constructor(e){this.apiKey=e}async getPkmsCredential(){return this.apiKey}},xC=class{key;constructor(e,t,n){this.key=`${e}|${t}|${n}`}getKey(){return this.key}},SC=class{map;constructor(){this.map=new Map}async has(e){return this.map.has(e.getKey())}async get(e){return this.map.get(e.getKey())}async set(e,t){this.map.set(e.getKey(),t)}};(async function(){new SC})();var CC=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,wC={verifyFormat:TC,encodeNumber:EC,decodeNumber:DC,encodeToChar:OC,decodeFromChar:kC,CROCKFORD_CHARS:CC};function TC(e,t=e.length){return RegExp(`^(${[...CC].join(`|`)}){${t}}$`).test(e)}function EC(e,t){if(!Number.isInteger(t)||t<1||t>10)throw Error(`Invalid or unsafe size for base32 encoding`);if(!Number.isInteger(e)||e<0||e>=32**t)throw Error(`Invalid number for base32 encoding of size ${t}`);return[...Array(t).keys()].map(t=>OC(e>>t*5&31)).join(``)}function DC(e){if(e.length==0||e.length>10)throw Error(`Invalid base32 string length`);return[...e].reduceRight((e,t)=>e<<5|kC(t),0)}function OC(e){let t=CC[e];if(t===void 0)throw Error(`Invalid base32 value`);return t}function kC(e){let t=CC.indexOf(e);if(e.length!=1||t==-1)throw Error(`Invalid base32 character`);return t}var AC=class{collection;constructor(e){this.collection=e}serialize(e,t){let n=this.collection[e],r=new jv(n).serialize(t);return new Uint8Array([e,...r])}},jC=class{collection;constructor(e){this.collection=e}unserialize(e){let t=e[0],n=this.collection[t];if(!n)throw Error(`Unknown message type ${t}: I do not know how to unserialize this message.`);return{type:t,object:new Mv(n).unserialize(e.slice(1))}}},MC=class{schema;constructor(e){this.schema=e}validate(e){if(this.schema===void 0)throw new o(`Provided schema is undefined: this should not happen`);this.validateObject(this.schema.definition,e)}validateObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0){if(r.optional)continue;throw Error(`field '${e}' is missing`)}if(r.type&32){if(ro.getType(i)!=1)throw`'${e}' is not an array`;for(let t in i)this.validateItem(r,i[t],e+`[${t}]`)}else this.validateItem(r,i,e)}}validateItem(e,t,n){if((e.type&31)==2){if(ro.getType(t)!=2)throw`'${n}' is not an object`;if(!e.unspecifiedSchema){if(!e.schema)throw`missing definition in schema`;this.validateObject(e.schema.definition,t,n)}}else{let r=new io(e,t);try{r.check()}catch(e){throw`Error on field '${n}': ${e}`}}}},NC={getAccountTypeFromIdentifier:PC,getSpecialAccountTypeIdentifier:FC,isAllowedTransfer:IC};function PC(e){if(e.length!=32)throw Error(`invalid account identifier`);if(e.slice(0,-1).every(e=>e==0)){let t=e[31];if(t==1||!Ur[t])throw Error(`special account format detected, but with an invalid type (${t})`);return t}return 1}function FC(e){if(e==1||!Ur[e])throw Error(`${e} is not a valid special account type`);let t=new Uint8Array(32);return t[31]=e,t}function IC(e,t){return Wr[e]>>t&1}var LC=class e{constructor(e){this.amount=e}static create(t){return new e(t)}getAmount(){return this.amount}toString(){return`${this.amount} €`}},RC=class{static defaultEurosToCMTSTokenConverter(){return new zC}},zC=class e{static TOKENS_FOR_ONE_EUROS=100;convert(t){return mn.create(t.getAmount()*e.TOKENS_FOR_ONE_EUROS)}invert(t){return LC.create(t.getAmount()/e.TOKENS_FOR_ONE_EUROS)}},BC=class e{constructor(e,t,n){this.verified=e,this.appLedger=t,this.importedProofs=n}static createSuccessfulProofVerificationResult(t,n){return new e(!0,t,MS.some(n))}static createFailedProofVerificationResult(t){return new e(!1,t,MS.none())}isVerified(){return this.verified}getInvolvedBlockHeights(){return this.importedProofs.isSome()?this.importedProofs.unwrap().map(e=>e.height):[]}getApplicationLedgerId(){return this.appLedger.getIdentifier()}async getRecordContainedInBlockAtHeight(e,t){throw Error(`Not implemented`)}},VC=function(e){return e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP=-32603]=`ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP`,e[e.TX_ALREADY_EXISTS=-32003]=`TX_ALREADY_EXISTS`,e[e.TX_OUT_OF_GAS=-32002]=`TX_OUT_OF_GAS`,e[e.TX_CHECK_FAILED=-32001]=`TX_CHECK_FAILED`,e[e.TX_DELIVER_FAILED=-32e3]=`TX_DELIVER_FAILED`,e}({}),HC=class e{log=ts.getAbstractProviderLogger(e.name);async loadValidatorNodeVirtualBlockchain(e){let t=new $x(this);return await this.initializeVirtualBlockchain(t,e),t}async loadAccountVirtualBlockchain(e){this.log.debug(`Loading account virtual blockchain with id ${e.encode()}`);let t=new Yx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationLedgerVirtualBlockchain(e){let t=new jS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationVirtualBlockchain(e){let t=new Zx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadOrganizationVirtualBlockchain(e){let t=new qx(this);return await this.initializeVirtualBlockchain(t,e),t}async loadProtocolVirtualBlockchain(e){let t=new tS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadVirtualBlockchain(e){let t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Virtual Blockchain with hash ${e.encode()} does not exist.`);let n=t.type;switch(n){case V.ACCOUNT_VIRTUAL_BLOCKCHAIN:return await this.loadAccountVirtualBlockchain(e);case V.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return await this.loadOrganizationVirtualBlockchain(e);case V.APPLICATION_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationVirtualBlockchain(e);case V.NODE_VIRTUAL_BLOCKCHAIN:return await this.loadValidatorNodeVirtualBlockchain(e);case V.PROTOCOL_VIRTUAL_BLOCKCHAIN:return await this.loadProtocolVirtualBlockchain(e);case V.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationLedgerVirtualBlockchain(e);default:throw Error(`Unknown virtual blockchain type: ${n}`)}}async loadMicroblockByMicroblockHash(e){this.log.info(`Loading microblock ${e.encode()}`);let t=await this.getMicroblockHeader(e),n=await this.getMicroblockBody(e);if(t===null||n===null)throw Error(`Microblock ${e.encode()} not found`);return Vx.loadFromHeaderAndBody(t,n)}async getCurrentFeesFormula(){let e=(await this.getProtocolState()).getFeesCalculationVersion();return bx.getFeesCalculationFormulaByVersion(this,e)}async computeMicroblockFees(e,t={}){let n=t.referenceTimestampInSeconds??k.getTimestampInSeconds(),r=0;if(e.isGenesisMicroblock())r=Vx.extractExpirationDayFromGenesisPreviousHash(e.getPreviousHash().toBytes());else{let t=await this.getVirtualBlockchainIdContainingMicroblock(e.getPreviousHash()),n=await this.getVirtualBlockchainState(t.toBytes());if(n===null)throw Error(`Virtual blockchain state not found`);r=n.expirationDay}let i=t.signatureSchemeId??e.getLastSignatureSection().schemeId;if(i===null)throw Error(`Signature scheme ID cannot be null`);return(await this.getCurrentFeesFormula()).computeFees(i,e,r,n)}async initializeVirtualBlockchain(e,t){let n=t.toBytes(),r=await this.getVirtualBlockchainStatus(n);if(r===null||r.state===void 0)throw new xe(t);if(r.state.type!==e.getType())throw Error(`Invalid blockchain type loaded`);e.setIdentifier(n),e.setHeight(r.state.height),e.setExpirationDay(r.state.expirationDay),e.setMicroblockHashes(r.microblockHashes),e.setInternalState(kx.createInternalStateFromObject(e.getType(),r.state.internalState))}},UC=class e{expirationDate;endless;constructor(e,t){this.expirationDate=e,this.endless=t}static endless(){return new e(MS.none(),!0)}static of(t){return new e(MS.of(t),!1)}static fromDurationInDays(t){let n=new Date;return n.setDate(n.getDate()+t),e.of(n)}isEndless(){return this.endless}getExpirationDate(){return this.expirationDate.unwrap()}},WC=class e{static logger=ts.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}microblockHeaderStore;microblockBodyStore;microblockVbInformationStore;virtualBlockchainStateStore;constructor(){this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}clear(){e.logger.info(`Clearing`),this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(t){let n=await e.get(this.microblockVbInformationStore,t);return e.logger.info(`getMicroblockVbInformation identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getInformationOfVirtualBlockchainContainingMicroblock(e){let t=await this.getSerializedInformationOfVirtualBlockchainContainingMicroblock(e);return t===null?null:Y.decodeVirtualBlockchainInfo(t)}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=Y.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier=${k.binaryToHexa(t)} found: {header}`,{header:r}),r}}async getSerializedMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=j.Hashes.sha256(n),i=Y.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier (sha256:${r})=${k.binaryToHexa(t)} found: {header}`,{header:JSON.stringify(i)}),n}}async getMicroblockBody(t){let n=await e.get(this.microblockBodyStore,t);return e.logger.info(`getMicroblockBody identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getSerializedVirtualBlockchainState(t){let n=await e.get(this.virtualBlockchainStateStore,t);return e.logger.info(`getVirtualBlockchainState identifier=${k.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(t,n){let r=Y.decodeVirtualBlockchainInfo(n);return e.logger.info(`Store info of vb identifier=${k.binaryToHexa(t)}: {info}`,{info:r}),await e.set(this.microblockVbInformationStore,t,n)}async setSerializedMicroblockHeader(t,n){let r=Y.decodeMicroblockHeader(n);return e.logger.info(`Store header of microblock identifier=${k.binaryToHexa(t)} -> {header}`,{header:r}),await e.set(this.microblockHeaderStore,t,n)}async setSerializedMicroblockBody(t,n){let r=Y.decodeMicroblockBody(n);return e.logger.info(`Store body of microblock ${k.binaryToHexa(t)}: {body}`,{body:r}),await e.set(this.microblockBodyStore,t,n)}async setMicroblockHeader(e,t){let n=Y.encodeMicroblockHeader(t);await this.setSerializedMicroblockHeader(e,n)}async setMicroblockBody(e,t){let n=Y.encodeMicroblockBody(t);await this.setSerializedMicroblockBody(e,n)}async setSerializedVirtualBlockchainState(t,n){let r=Y.decodeVirtualBlockchainState(n);return e.logger.info(`Store vb state for vb ${k.binaryToHexa(t)}: {state}`,{state:r}),await e.set(this.virtualBlockchainStateStore,t,n)}static async get(e,t){let n=k.binaryToHexa(t);if(!e.has(n))return null;let r=e.get(n);return r===void 0?null:k.binaryFromHexa(r)}static async set(t,n,r){let i=k.binaryToHexa(n),a=k.binaryToHexa(r),o=t.get(i);o===void 0?e.logger.info(`Storing new entry for key ${i}`):o===a?e.logger.info(`Storing the same data for the same key ${i}`):e.logger.info(`Storing new data for key ${i}`),t.set(i,a)}},GC=globalThis||self;function KC(e,t){return function(){return e.apply(t,arguments)}}var{toString:qC}=Object.prototype,{getPrototypeOf:JC}=Object,{iterator:YC,toStringTag:XC}=Symbol,ZC=(e=>t=>{let n=qC.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),QC=e=>(e=e.toLowerCase(),t=>ZC(t)===e),$C=e=>t=>typeof t===e,{isArray:ew}=Array,tw=$C(`undefined`);function nw(e){return e!==null&&!tw(e)&&e.constructor!==null&&!tw(e.constructor)&&ow(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var rw=QC(`ArrayBuffer`);function iw(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&rw(e.buffer),t}var aw=$C(`string`),ow=$C(`function`),sw=$C(`number`),cw=e=>typeof e==`object`&&!!e,lw=e=>e===!0||e===!1,uw=e=>{if(ZC(e)!==`object`)return!1;let t=JC(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(XC in e)&&!(YC in e)},dw=e=>{if(!cw(e)||nw(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},fw=QC(`Date`),pw=QC(`File`),mw=e=>!!(e&&e.uri!==void 0),hw=e=>e&&e.getParts!==void 0,gw=QC(`Blob`),_w=QC(`FileList`),vw=e=>cw(e)&&ow(e.pipe);function yw(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:GC===void 0?{}:GC}var bw=yw(),xw=bw.FormData===void 0?void 0:bw.FormData,Sw=e=>{let t;return e&&(xw&&e instanceof xw||ow(e.append)&&((t=ZC(e))===`formdata`||t===`object`&&ow(e.toString)&&e.toString()===`[object FormData]`))},Cw=QC(`URLSearchParams`),[ww,Tw,Ew,Dw]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(QC),Ow=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function kw(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),ew(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(nw(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function Aw(e,t){if(nw(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}var jw=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:GC,Mw=e=>!tw(e)&&e!==jw;function Nw(){let{caseless:e,skipUndefined:t}=Mw(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&Aw(n,i)||i;uw(n[a])&&uw(r)?n[a]=Nw(n[a],r):uw(r)?n[a]=Nw({},r):ew(r)?n[a]=r.slice():(!t||!tw(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&kw(arguments[e],r);return n}var Pw=(e,t,n,{allOwnKeys:r}={})=>(kw(t,(t,r)=>{n&&ow(t)?Object.defineProperty(e,r,{value:KC(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Fw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Iw=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},Lw=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&JC(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Rw=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},zw=e=>{if(!e)return null;if(ew(e))return e;let t=e.length;if(!sw(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},Bw=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&JC(Uint8Array)),Vw=(e,t)=>{let n=(e&&e[YC]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Hw=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Uw=QC(`HTMLFormElement`),Ww=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),Gw=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Kw=QC(`RegExp`),qw=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};kw(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Jw=e=>{qw(e,(t,n)=>{if(ow(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(ow(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Yw=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return ew(e)?r(e):r(String(e).split(t)),n},Xw=()=>{},Zw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Qw(e){return!!(e&&ow(e.append)&&e[XC]===`FormData`&&e[YC])}var $w=e=>{let t=Array(10),n=(e,r)=>{if(cw(e)){if(t.indexOf(e)>=0)return;if(nw(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=ew(e)?[]:{};return kw(e,(e,t)=>{let a=n(e,r+1);!tw(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},eT=QC(`AsyncFunction`),tT=e=>e&&(cw(e)||ow(e))&&ow(e.then)&&ow(e.catch),nT=((e,t)=>e?setImmediate:t?((e,t)=>(jw.addEventListener(`message`,({source:n,data:r})=>{n===jw&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),jw.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,ow(jw.postMessage)),Q={isArray:ew,isArrayBuffer:rw,isBuffer:nw,isFormData:Sw,isArrayBufferView:iw,isString:aw,isNumber:sw,isBoolean:lw,isObject:cw,isPlainObject:uw,isEmptyObject:dw,isReadableStream:ww,isRequest:Tw,isResponse:Ew,isHeaders:Dw,isUndefined:tw,isDate:fw,isFile:pw,isReactNativeBlob:mw,isReactNative:hw,isBlob:gw,isRegExp:Kw,isFunction:ow,isStream:vw,isURLSearchParams:Cw,isTypedArray:Bw,isFileList:_w,forEach:kw,merge:Nw,extend:Pw,trim:Ow,stripBOM:Fw,inherits:Iw,toFlatObject:Lw,kindOf:ZC,kindOfTest:QC,endsWith:Rw,toArray:zw,forEachEntry:Vw,matchAll:Hw,isHTMLForm:Uw,hasOwnProperty:Gw,hasOwnProp:Gw,reduceDescriptors:qw,freezeMethods:Jw,toObjectSet:Yw,toCamelCase:Ww,noop:Xw,toFiniteNumber:Zw,findKey:Aw,global:jw,isContextDefined:Mw,isSpecCompliantForm:Qw,toJSONObject:$w,isAsyncFn:eT,isThenable:tT,setImmediate:nT,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(jw):fy!==void 0&&fy.nextTick||nT,isIterable:e=>e!=null&&ow(e[YC])},$=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Q.toJSONObject(this.config),code:this.code,status:this.status}}};$.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,$.ERR_BAD_OPTION=`ERR_BAD_OPTION`,$.ECONNABORTED=`ECONNABORTED`,$.ETIMEDOUT=`ETIMEDOUT`,$.ERR_NETWORK=`ERR_NETWORK`,$.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,$.ERR_DEPRECATED=`ERR_DEPRECATED`,$.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,$.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,$.ERR_CANCELED=`ERR_CANCELED`,$.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,$.ERR_INVALID_URL=`ERR_INVALID_URL`;function rT(e){return Q.isPlainObject(e)||Q.isArray(e)}function iT(e){return Q.endsWith(e,`[]`)?e.slice(0,-2):e}function aT(e,t,n){return e?e.concat(t).map(function(e,t){return e=iT(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function oT(e){return Q.isArray(e)&&!e.some(rT)}var sT=Q.toFlatObject(Q,{},null,function(e){return/^is[A-Z]/.test(e)});function cT(e,t,n){if(!Q.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=Q.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Q.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&Q.isSpecCompliantForm(t);if(!Q.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if(Q.isDate(e))return e.toISOString();if(Q.isBoolean(e))return e.toString();if(!s&&Q.isBlob(e))throw new $(`Blob is not supported. Use a Buffer instead.`);return Q.isArrayBuffer(e)||Q.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Ng.from(e):e}function l(e,n,i){let s=e;if(Q.isReactNative(t)&&Q.isReactNativeBlob(e))return t.append(aT(i,n,a),c(e)),!1;if(e&&!i&&typeof e==`object`){if(Q.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Q.isArray(e)&&oT(e)||(Q.isFileList(e)||Q.endsWith(n,`[]`))&&(s=Q.toArray(e)))return n=iT(n),s.forEach(function(e,r){!(Q.isUndefined(e)||e===null)&&t.append(o===!0?aT([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return rT(e)?!0:(t.append(aT(i,n,a),c(e)),!1)}let u=[],d=Object.assign(sT,{defaultVisitor:l,convertValue:c,isVisitable:rT});function f(e,n){if(!Q.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),Q.forEach(e,function(e,r){(!(Q.isUndefined(e)||e===null)&&i.call(t,e,Q.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!Q.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function lT(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function uT(e,t){this._pairs=[],e&&cT(e,this,t)}var dT=uT.prototype;dT.append=function(e,t){this._pairs.push([e,t])},dT.toString=function(e){let t=e?function(t){return e.call(this,t,lT)}:lT;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function fT(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function pT(e,t,n){if(!t)return e;let r=n&&n.encode||fT,i=Q.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):Q.isURLSearchParams(t)?t.toString():new uT(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var mT=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){Q.forEach(this.handlers,function(t){t!==null&&e(t)})}},hT={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},gT={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:uT,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},_T=t({hasBrowserEnv:()=>vT,hasStandardBrowserEnv:()=>bT,hasStandardBrowserWebWorkerEnv:()=>xT,navigator:()=>yT,origin:()=>ST}),vT=typeof window<`u`&&typeof document<`u`,yT=typeof navigator==`object`&&navigator||void 0,bT=vT&&(!yT||[`ReactNative`,`NativeScript`,`NS`].indexOf(yT.product)<0),xT=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,ST=vT&&window.location.href||`http://localhost`,CT={..._T,...gT};function wT(e,t){return cT(e,new CT.classes.URLSearchParams,{visitor:function(e,t,n,r){return CT.isNode&&Q.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function TT(e){return Q.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function ET(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function DT(e){function t(e,n,r,i){let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&Q.isArray(r)?r.length:a,s?(Q.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!Q.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&Q.isArray(r[a])&&(r[a]=ET(r[a])),!o)}if(Q.isFormData(e)&&Q.isFunction(e.entries)){let n={};return Q.forEachEntry(e,(e,r)=>{t(TT(e),r,n,0)}),n}return null}function OT(e,t,n){if(Q.isString(e))try{return(t||JSON.parse)(e),Q.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var kT={transitional:hT,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=Q.isObject(e);if(i&&Q.isHTMLForm(e)&&(e=new FormData(e)),Q.isFormData(e))return r?JSON.stringify(DT(e)):e;if(Q.isArrayBuffer(e)||Q.isBuffer(e)||Q.isStream(e)||Q.isFile(e)||Q.isBlob(e)||Q.isReadableStream(e))return e;if(Q.isArrayBufferView(e))return e.buffer;if(Q.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return wT(e,this.formSerializer).toString();if((a=Q.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return cT(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),OT(e)):e}],transformResponse:[function(e){let t=this.transitional||kT.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if(Q.isResponse(e)||Q.isReadableStream(e))return e;if(e&&Q.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?$.from(e,$.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:CT.classes.FormData,Blob:CT.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};Q.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{kT.headers[e]={}});var AT=Q.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),jT=e=>{let t={},n,r,i;return e&&e.split(`
|
|
9
|
+
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&AT[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},MT=Symbol(`internals`);function NT(e){return e&&String(e).trim().toLowerCase()}function PT(e){return e===!1||e==null?e:Q.isArray(e)?e.map(PT):String(e).replace(/[\r\n]+$/,``)}function FT(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var IT=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function LT(e,t,n,r,i){if(Q.isFunction(r))return r.call(this,t,n);if(i&&(t=n),Q.isString(t)){if(Q.isString(r))return t.indexOf(r)!==-1;if(Q.isRegExp(r))return r.test(t)}}function RT(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function zT(e,t){let n=Q.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var BT=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=NT(t);if(!i)throw Error(`header name must be a non-empty string`);let a=Q.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=PT(e))}let a=(e,t)=>Q.forEach(e,(e,n)=>i(e,n,t));if(Q.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(Q.isString(e)&&(e=e.trim())&&!IT(e))a(jT(e),t);else if(Q.isObject(e)&&Q.isIterable(e)){let n={},r,i;for(let t of e){if(!Q.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?Q.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=NT(e),e){let n=Q.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return FT(e);if(Q.isFunction(t))return t.call(this,e,n);if(Q.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=NT(e),e){let n=Q.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||LT(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=NT(e),e){let i=Q.findKey(n,e);i&&(!t||LT(n,n[i],i,t))&&(delete n[i],r=!0)}}return Q.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||LT(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return Q.forEach(this,(r,i)=>{let a=Q.findKey(n,i);if(a){t[a]=PT(r),delete t[i];return}let o=e?RT(i):String(i).trim();o!==i&&delete t[i],t[o]=PT(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return Q.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&Q.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
|
|
10
|
+
`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[MT]=this[MT]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=NT(e);t[r]||(zT(n,e),t[r]=!0)}return Q.isArray(e)?e.forEach(r):r(e),this}};BT.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),Q.reduceDescriptors(BT.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),Q.freezeMethods(BT);function VT(e,t){let n=this||kT,r=t||n,i=BT.from(r.headers),a=r.data;return Q.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function HT(e){return!!(e&&e.__CANCEL__)}var UT=class extends ${constructor(e,t,n){super(e??`canceled`,$.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function WT(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new $(`Request failed with status code `+n.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function GT(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function KT(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function qT(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var JT=(e,t,n=3)=>{let r=0,i=KT(50,250);return qT(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},YT=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},XT=e=>(...t)=>Q.asap(()=>e(...t)),ZT=CT.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,CT.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(CT.origin),CT.navigator&&/(msie|trident)/i.test(CT.navigator.userAgent)):()=>!0,QT=CT.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];Q.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),Q.isString(r)&&s.push(`path=${r}`),Q.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),Q.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function $T(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function eE(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function tE(e,t,n){let r=!$T(t);return e&&(r||n==0)?eE(e,t):t}var nE=e=>e instanceof BT?{...e}:e;function rE(e,t){t||={};let n={};function r(e,t,n,r){return Q.isPlainObject(e)&&Q.isPlainObject(t)?Q.merge.call({caseless:r},e,t):Q.isPlainObject(t)?Q.merge({},t):Q.isArray(t)?t.slice():t}function i(e,t,n,i){if(!Q.isUndefined(t))return r(e,t,n,i);if(!Q.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!Q.isUndefined(t))return r(void 0,t)}function o(e,t){if(!Q.isUndefined(t))return r(void 0,t);if(!Q.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(nE(e),nE(t),n,!0)};return Q.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=Q.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);Q.isUndefined(o)&&a!==s||(n[r]=o)}),n}var iE=e=>{let t=rE({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=BT.from(o),t.url=pT(tE(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),Q.isFormData(n)){if(CT.hasStandardBrowserEnv||CT.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Q.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(CT.hasStandardBrowserEnv&&(r&&Q.isFunction(r)&&(r=r(t)),r||r!==!1&&ZT(t.url))){let e=i&&a&&QT.read(a);e&&o.set(i,e)}return t},aE=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=iE(e),i=r.data,a=BT.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=BT.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());WT(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new $(`Request aborted`,$.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new $(t&&t.message?t.message:`Network Error`,$.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||hT;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new $(t,i.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&Q.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),Q.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=JT(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=JT(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new UT(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=GT(r.url);if(_&&CT.protocols.indexOf(_)===-1){n(new $(`Unsupported protocol `+_+`:`,$.ERR_BAD_REQUEST,e));return}h.send(i||null)})},oE=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof $?t:new UT(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new $(`timeout of ${t}ms exceeded`,$.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>Q.asap(o),s}},sE=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},cE=async function*(e,t){for await(let n of lE(e))yield*sE(n,t)},lE=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},uE=(e,t,n,r)=>{let i=cE(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},dE=64*1024,{isFunction:fE}=Q,pE=(({Request:e,Response:t})=>({Request:e,Response:t}))(Q.global),{ReadableStream:mE,TextEncoder:hE}=Q.global,gE=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_E=e=>{e=Q.merge.call({skipUndefined:!0},pE,e);let{fetch:t,Request:n,Response:r}=e,i=t?fE(t):typeof fetch==`function`,a=fE(n),o=fE(r);if(!i)return!1;let s=i&&fE(mE),c=i&&(typeof hE==`function`?(e=>t=>e.encode(t))(new hE):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&gE(()=>{let e=!1,t=new mE,r=new n(CT.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&gE(()=>Q.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new $(`Response type '${e}' is not supported`,$.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(Q.isBlob(e))return e.size;if(Q.isSpecCompliantForm(e))return(await new n(CT.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(Q.isArrayBufferView(e)||Q.isArrayBuffer(e))return e.byteLength;if(Q.isURLSearchParams(e)&&(e+=``),Q.isString(e))return(await c(e)).byteLength},p=async(e,t)=>Q.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:b}=iE(e),ee=t||fetch;_=_?(_+``).toLowerCase():`text`;let x=oE([c,f&&f.toAbortSignal()],m),te=null,S=x&&x.unsubscribe&&(()=>{x.unsubscribe()}),ne;try{if(g&&l&&o!==`get`&&o!==`head`&&(ne=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(Q.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=YT(ne,JT(XT(g)));s=uE(e.body,dE,t,n)}}Q.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...b,signal:x,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};te=a&&new n(i,c);let f=await(a?ee(te,b):ee(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&S)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=Q.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&YT(t,JT(XT(h),!0))||[];f=new r(uE(f.body,dE,n,()=>{i&&i(),S&&S()}),e)}_||=`text`;let re=await d[Q.findKey(d,_)||`text`](f,e);return!m&&S&&S(),await new Promise((t,n)=>{WT(t,n,{data:re,headers:BT.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:te})})}catch(t){throw S&&S(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new $(`Network Error`,$.ERR_NETWORK,e,te,t&&t.response),{cause:t.cause||t}):$.from(t,t&&t.code,e,te,t&&t.response)}}},vE=new Map,yE=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=vE;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:_E(t)),l=c;return c};yE();var bE={http:null,xhr:aE,fetch:{get:yE}};Q.forEach(bE,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var xE=e=>`- ${e}`,SE=e=>Q.isFunction(e)||e===null||e===!1;function CE(e,t){e=Q.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!SE(r)&&(i=bE[(n=String(r)).toLowerCase()],i===void 0))throw new $(`Unknown adapter '${n}'`);if(i&&(Q.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new $(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
|
|
11
|
+
`+e.map(xE).join(`
|
|
12
|
+
`):` `+xE(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var wE={getAdapter:CE,adapters:bE};function TE(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new UT(null,e)}function EE(e){return TE(e),e.headers=BT.from(e.headers),e.data=VT.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),wE.getAdapter(e.adapter||kT.adapter,e)(e).then(function(t){return TE(e),t.data=VT.call(e,e.transformResponse,t),t.headers=BT.from(t.headers),t},function(t){return HT(t)||(TE(e),t&&t.response&&(t.response.data=VT.call(e,e.transformResponse,t.response),t.response.headers=BT.from(t.response.headers))),Promise.reject(t)})}var DE=`1.14.0`,OE={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{OE[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var kE={};OE.transitional=function(e,t,n){function r(e,t){return`[Axios v`+DE+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new $(r(i,` has been removed`+(t?` in `+t:``)),$.ERR_DEPRECATED);return t&&!kE[i]&&(kE[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},OE.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function AE(e,t,n){if(typeof e!=`object`)throw new $(`options must be an object`,$.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new $(`option `+a+` must be `+n,$.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new $(`Unknown option `+a,$.ERR_BAD_OPTION)}}var jE={assertOptions:AE,validators:OE},ME=jE.validators,NE=class{constructor(e){this.defaults=e||{},this.interceptors={request:new mT,response:new mT}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=t.stack?t.stack.replace(/^.+\n/,``):``;try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,``))&&(e.stack+=`
|
|
13
|
+
`+n):e.stack=n}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=rE(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&jE.assertOptions(n,{silentJSONParsing:ME.transitional(ME.boolean),forcedJSONParsing:ME.transitional(ME.boolean),clarifyTimeoutError:ME.transitional(ME.boolean),legacyInterceptorReqResOrdering:ME.transitional(ME.boolean)},!1),r!=null&&(Q.isFunction(r)?t.paramsSerializer={serialize:r}:jE.assertOptions(r,{encode:ME.function,serialize:ME.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),jE.assertOptions(t,{baseUrl:ME.spelling(`baseURL`),withXsrfToken:ME.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&Q.merge(i.common,i[t.method]);i&&Q.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=BT.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||hT;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[EE.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e(f)}catch(e){t.call(this,e);break}}try{l=EE.call(this,f)}catch(e){return Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=rE(this.defaults,e),pT(tE(e.baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Q.forEach([`delete`,`get`,`head`,`options`],function(e){NE.prototype[e]=function(t,n){return this.request(rE(n||{},{method:e,url:t,data:(n||{}).data}))}}),Q.forEach([`post`,`put`,`patch`],function(e){function t(t){return function(n,r,i){return this.request(rE(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}NE.prototype[e]=t(),NE.prototype[e+`Form`]=t(!0)});var PE=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new UT(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function FE(e){return function(t){return e.apply(null,t)}}function IE(e){return Q.isObject(e)&&e.isAxiosError===!0}var LE={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(LE).forEach(([e,t])=>{LE[t]=e});function RE(e){let t=new NE(e),n=KC(NE.prototype.request,t);return Q.extend(n,NE.prototype,t,{allOwnKeys:!0}),Q.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return RE(rE(e,t))},n}var zE=RE(kT);zE.Axios=NE,zE.CanceledError=UT,zE.CancelToken=PE,zE.isCancel=HT,zE.VERSION=DE,zE.toFormData=cT,zE.AxiosError=$,zE.Cancel=zE.CanceledError,zE.all=function(e){return Promise.all(e)},zE.spread=FE,zE.isAxiosError=IE,zE.mergeConfig=rE,zE.AxiosHeaders=BT,zE.formToJSON=e=>DT(Q.isHTMLForm(e)?new FormData(e):e),zE.getAdapter=wE.getAdapter,zE.HttpStatusCode=LE,zE.default=zE;var{Axios:BE,AxiosError:VE,CanceledError:HE,isCancel:UE,CancelToken:WE,VERSION:GE,all:KE,Cancel:qE,isAxiosError:JE,spread:YE,toFormData:XE,AxiosHeaders:ZE,HttpStatusCode:QE,formToJSON:$E,getAdapter:eD,mergeConfig:tD}=zE,nD=F({jsonrpc:N(`2.0`),id:P(),result:F({node_info:F({protocol_version:F({p2p:I(),block:I(),app:I()}),id:I(),listen_addr:I(),network:I(),version:I(),channels:I(),moniker:I(),other:F({tx_index:I(),rpc_address:I()})}),sync_info:F({latest_block_hash:I(),latest_app_hash:I(),latest_block_height:I(),latest_block_time:I(),earliest_block_hash:I(),earliest_app_hash:I(),earliest_block_height:I(),earliest_block_time:I(),catching_up:Kp()}),validator_info:F({address:I(),pub_key:F({type:I(),value:I()}),voting_power:I()})})}),rD=function(e){return e[e.GET_CHAIN_INFORMATION=1]=`GET_CHAIN_INFORMATION`,e[e.GET_BLOCK_INFORMATION=3]=`GET_BLOCK_INFORMATION`,e[e.GET_BLOCK_CONTENT=5]=`GET_BLOCK_CONTENT`,e[e.GET_VIRTUAL_BLOCKCHAIN_STATE=7]=`GET_VIRTUAL_BLOCKCHAIN_STATE`,e[e.GET_VIRTUAL_BLOCKCHAIN_UPDATE=9]=`GET_VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.GET_MICROBLOCK_INFORMATION=11]=`GET_MICROBLOCK_INFORMATION`,e[e.AWAIT_MICROBLOCK_ANCHORING=13]=`AWAIT_MICROBLOCK_ANCHORING`,e[e.GET_MICROBLOCK_BODYS=15]=`GET_MICROBLOCK_BODYS`,e[e.GET_ACCOUNT_STATE=17]=`GET_ACCOUNT_STATE`,e[e.GET_ACCOUNT_HISTORY=19]=`GET_ACCOUNT_HISTORY`,e[e.GET_ACCOUNT_BY_PUBLIC_KEY_HASH=21]=`GET_ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.GET_VALIDATOR_NODE_BY_ADDRESS=23]=`GET_VALIDATOR_NODE_BY_ADDRESS`,e[e.GET_OBJECT_LIST=25]=`GET_OBJECT_LIST`,e[e.GET_GENESIS_SNAPSHOT=27]=`GET_GENESIS_SNAPSHOT`,e[e.GET_RAW_BLOCK_CONTENT=29]=`GET_RAW_BLOCK_CONTENT`,e[e.GET_BLOCK_MODIFIED_ACCOUNTS=31]=`GET_BLOCK_MODIFIED_ACCOUNTS`,e[e.GET_ACCOUNT_UPDATES=33]=`GET_ACCOUNT_UPDATES`,e}({}),iD=F({requestType:N(rD.GET_CHAIN_INFORMATION)}),aD=F({requestType:N(rD.GET_BLOCK_INFORMATION),height:R(P(),Lp(),Vp(0))}),oD=F({requestType:N(rD.GET_BLOCK_CONTENT),height:R(P(),Lp(),Vp(0))}),sD=F({requestType:N(rD.GET_VIRTUAL_BLOCKCHAIN_STATE),virtualBlockchainId:Am()}),cD=F({requestType:N(rD.GET_VIRTUAL_BLOCKCHAIN_UPDATE),virtualBlockchainId:Am(),knownHeight:R(P(),Lp(),Vp(0))}),lD=F({requestType:N(rD.GET_MICROBLOCK_INFORMATION),hash:Am()}),uD=F({requestType:N(rD.AWAIT_MICROBLOCK_ANCHORING),hash:Am()}),dD=F({requestType:N(rD.GET_MICROBLOCK_BODYS),hashes:M(Am())}),fD=F({requestType:N(rD.GET_ACCOUNT_STATE),accountHash:Am()}),pD=F({requestType:N(rD.GET_ACCOUNT_HISTORY),accountHash:Am(),lastHistoryHash:Am(),maxRecords:R(P(),Lp(),Vp(1))}),mD=F({requestType:N(rD.GET_ACCOUNT_BY_PUBLIC_KEY_HASH),publicKeyHash:Am()}),hD=F({requestType:N(rD.GET_VALIDATOR_NODE_BY_ADDRESS),address:B()}),gD=F({requestType:N(rD.GET_OBJECT_LIST),type:R(P(),Lp(),Vp(0),zp(255))}),_D=F({requestType:N(rD.GET_GENESIS_SNAPSHOT)}),vD=F({requestType:N(rD.GET_RAW_BLOCK_CONTENT),height:R(P(),Lp(),Vp(0)),partIndex:R(P(),Lp(),Vp(0))}),yD=F({requestType:N(rD.GET_BLOCK_MODIFIED_ACCOUNTS),height:R(P(),Lp(),Vp(0))}),bD=F({requestType:N(rD.GET_ACCOUNT_UPDATES),list:M(rg)}),xD=im(`requestType`,[iD,aD,oD,sD,cD,lD,uD,dD,fD,pD,mD,hD,gD,_D,vD,yD,bD]),SD=function(e){return e[e.ERROR=0]=`ERROR`,e[e.CHAIN_INFORMATION=2]=`CHAIN_INFORMATION`,e[e.BLOCK_INFORMATION=4]=`BLOCK_INFORMATION`,e[e.BLOCK_CONTENT=6]=`BLOCK_CONTENT`,e[e.VIRTUAL_BLOCKCHAIN_STATE=8]=`VIRTUAL_BLOCKCHAIN_STATE`,e[e.VIRTUAL_BLOCKCHAIN_UPDATE=10]=`VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.MICROBLOCK_INFORMATION=12]=`MICROBLOCK_INFORMATION`,e[e.MICROBLOCK_ANCHORING=14]=`MICROBLOCK_ANCHORING`,e[e.MICROBLOCK_BODYS=16]=`MICROBLOCK_BODYS`,e[e.ACCOUNT_STATE=18]=`ACCOUNT_STATE`,e[e.ACCOUNT_HISTORY=20]=`ACCOUNT_HISTORY`,e[e.ACCOUNT_BY_PUBLIC_KEY_HASH=22]=`ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.VALIDATOR_NODE_BY_ADDRESS=24]=`VALIDATOR_NODE_BY_ADDRESS`,e[e.OBJECT_LIST=26]=`OBJECT_LIST`,e[e.GENESIS_SNAPSHOT=28]=`GENESIS_SNAPSHOT`,e[e.RAW_BLOCK_CONTENT=30]=`RAW_BLOCK_CONTENT`,e[e.BLOCK_MODIFIED_ACCOUNTS=32]=`BLOCK_MODIFIED_ACCOUNTS`,e[e.ACCOUNT_UPDATES=34]=`ACCOUNT_UPDATES`,e}({}),CD=F({responseType:N(SD.ERROR),error:I()}),wD=F({responseType:N(SD.CHAIN_INFORMATION),height:R(P(),Lp(),Vp(0)),lastBlockTimestamp:R(P(),Lp(),Vp(0)),microblockCount:R(P(),Lp(),Vp(0)),objectCounts:M(R(P(),Lp(),Vp(0)))}),TD=F({responseType:N(SD.BLOCK_INFORMATION),hash:Am(),timestamp:R(P(),Lp(),Vp(0)),proposerAddress:B(),size:R(P(),Lp(),Vp(0)),microblockCount:R(P(),Lp(),Vp(0))}),ED=F({hash:Am(),vbId:Am(),vbType:R(P(),Lp(),Vp(0),zp(255)),height:R(P(),Lp(),Vp(0)),size:R(P(),Lp(),Vp(0)),sectionCount:R(P(),Lp(),Vp(0))}),DD=F({responseType:N(SD.BLOCK_CONTENT),microblocks:M(ED)}),OD=F({responseType:N(SD.VIRTUAL_BLOCKCHAIN_STATE),serializedVirtualBlockchainState:B()}),kD=F({responseType:N(SD.VIRTUAL_BLOCKCHAIN_UPDATE),exists:Kp(),changed:Kp(),serializedVirtualBlockchainState:B(),serializedHeaders:M(B())}),AD=F({responseType:N(SD.MICROBLOCK_INFORMATION),...Hh.entries}),jD=F({responseType:N(SD.MICROBLOCK_ANCHORING),...Hh.entries}),MD=F({microblockHash:Am(),microblockBody:Sh}),ND=F({responseType:N(SD.MICROBLOCK_BODYS),list:M(MD)}),PD=F({responseType:N(SD.ACCOUNT_STATE),height:R(P(),Lp(),Vp(0)),balance:R(P(),Lp(),Vp(0)),lastHistoryHash:Am(),locks:M(Zh)}),FD=F({responseType:N(SD.ACCOUNT_HISTORY),list:ng}),ID=F({responseType:N(SD.ACCOUNT_BY_PUBLIC_KEY_HASH),accountHash:Am()}),LD=F({responseType:N(SD.VALIDATOR_NODE_BY_ADDRESS),validatorNodeHash:Am()}),RD=F({responseType:N(SD.OBJECT_LIST),list:M(Am())}),zD=F({responseType:N(SD.GENESIS_SNAPSHOT),base64EncodedChunks:M(I())}),BD=F({responseType:N(SD.RAW_BLOCK_CONTENT),partIndex:P(),numberOfParts:P(),serializedMicroblocks:M(B())}),VD=F({responseType:N(SD.BLOCK_MODIFIED_ACCOUNTS),modifiedAccounts:M(B())}),HD=F({responseType:N(SD.ACCOUNT_UPDATES),list:M(ig)}),UD=im(`responseType`,[CD,wD,TD,DD,BD,OD,kD,AD,jD,ND,PD,FD,ID,LD,RD,zD,VD,HD]),WD=class{static encodeAbciRequest(e){return lx(L(xD,e))}static decodeAbciRequest(e){return L(xD,Mb(e))}static encodeAbciResponse(e){return lx(L(UD,e))}static decodeAbciResponse(e){return L(UD,Mb(e))}},GD=class e{static staticLogger=ts.getNetworkProviderLogger();logger=e.staticLogger;requestLogger=e.staticLogger.getChild(`request`);responseLogger=e.staticLogger.getChild(`response`);static createFromUrl(t){e.staticLogger.debug(`NetworkProvider constructor -> nodeUrl: ${t}`);try{return new URL(t),new e(t)}catch{throw new i(`Invalid node URL: got ${t}`)}}constructor(e){this.nodeUrl=e}async sendSerializedMicroblock(e){this.requestLogger.info(`Sending serialized microblock (${e.length} bytes)`);let t=await this.broadcastTx(e);return this.responseLogger.info(`Received response: <- {data}`,()=>({data:t?.data})),t}async awaitMicroblockAnchoring(e){let t=k.binaryToHexa(e);return this.requestLogger.info(`Awaiting microblock {hash} to be published...`,()=>({hash:t})),L(Hh,await this.abciQuery({requestType:rD.AWAIT_MICROBLOCK_ANCHORING,hash:e}))}async getChainInformation(){return this.requestLogger.info(`Requesting chain information`),L(wD,await this.abciQuery({requestType:rD.GET_CHAIN_INFORMATION}))}async getBlockInformation(e){this.requestLogger.info(`Requesting block information at height: ${e}`);let t=await this.abciQuery({requestType:rD.GET_BLOCK_INFORMATION,height:e});return this.responseLogger.info(`Received block information at height ${e}`),L(TD,t)}async getBlockContent(e){this.requestLogger.info(`Requesting block content for height ${e}`);let t=L(DD,await this.abciQuery({requestType:rD.GET_BLOCK_CONTENT,height:e}));return this.responseLogger.info(`Received block content for height ${e}: ${t.microblocks.length} microblocks received`),t}async getValidatorNodeByAddress(e){this.requestLogger.info(`Requesting validator node id for address {address}`,()=>({address:k.binaryToHexa(e)}));let t=await this.abciQuery({requestType:rD.GET_VALIDATOR_NODE_BY_ADDRESS,address:e});return this.responseLogger.info(`Receiving validator node id {id}`,()=>({id:k.binaryToHexa(e)})),L(LD,t)}async getAccountState(e){this.requestLogger.info(`Requesting account state for account hash {accountHash}`,()=>({accountHash:k.binaryToHexa(e)}));let t=L(PD,await this.abciQuery({requestType:rD.GET_ACCOUNT_STATE,accountHash:e}));return this.responseLogger.info(`Receiving account state: height={height}, balance={balance}`,()=>({height:t.height,balance:mn.createAtomic(t.balance).toString()})),t}async getAccountHistory(e,t,n){this.requestLogger.info(`Requesting account history for account hash: ${k.binaryToHexa(e)}, lastHistoryHash: ${k.binaryToHexa(t)}, maxRecords: ${n}`);let r=L(FD,await this.abciQuery({requestType:rD.GET_ACCOUNT_HISTORY,accountHash:e,lastHistoryHash:t,maxRecords:n}));return this.responseLogger.info(`Receiving account history with ${r.list.length} entries`),r}async getAccountByPublicKeyHash(e){this.requestLogger.info(`Requesting account hash by public key hash: ${k.binaryToHexa(e)}`);let t=L(ID,await this.abciQuery({requestType:rD.GET_ACCOUNT_BY_PUBLIC_KEY_HASH,publicKeyHash:e}));return this.responseLogger.info(`Received account hash {accountHash}`,()=>({accountHash:k.binaryToHexa(t.accountHash)})),t}async getObjectList(e){this.requestLogger.info(`Requesting list of objects of type ${e}`);let t=L(RD,await this.abciQuery({requestType:rD.GET_OBJECT_LIST,type:e}));return this.responseLogger.info(`Receiving object lists with ${t.list.length} elements)`),t}async getMicroblockInformation(e){this.requestLogger.info(`Requesting microblock information for hash ${k.binaryToHexa(e)}`);let t=L(AD,await this.abciQuery({requestType:rD.GET_MICROBLOCK_INFORMATION,hash:e}));return this.responseLogger.info(`Received microblock information: vbType={vbType}, vbId={vbId}`,()=>({vbType:t.virtualBlockchainType,vbId:k.binaryToHexa(t.virtualBlockchainId)})),this.logger.info(`Received microblock information body hash for microblock ${k.binaryToHexa(e)}: ${k.binaryToHexa(t.header.bodyHash)}`),L(Hh,t)}async getMicroblockBodys(e){this.requestLogger.info(`Requesting microblock bodys for microblock hashes ${e.length}`),this.requestLogger.info(`Lisf of requested hashes: {hashes}`,()=>({hashes:e.map(e=>k.binaryToHexa(e)).join(`, `)}));let t=L(ND,await this.abciQuery({requestType:rD.GET_MICROBLOCK_BODYS,hashes:e}));return this.responseLogger.info(`Returned number of microblock bodys: ${t.list.length}`),t}async getVirtualBlockchainUpdate(e,t){this.requestLogger.info(`Request virtual blockchain update for virtualBlockchainId: ${k.binaryToHexa(e)}, knownHeight: ${t}`);let n=await this.abciQuery({requestType:rD.GET_VIRTUAL_BLOCKCHAIN_UPDATE,virtualBlockchainId:e,knownHeight:t});return this.responseLogger.info(`Receiving virtual blockchain update`),L(kD,n)}async getSerializedVirtualBlockchainState(e){this.requestLogger.info(`Requesting virtual blockchain state for vb id {vbId}`,()=>({vbId:k.binaryToHexa(e)}));let t=L(OD,await this.abciQuery({requestType:rD.GET_VIRTUAL_BLOCKCHAIN_STATE,virtualBlockchainId:e}));return this.responseLogger.info(`Receiving virtual blockchain state: ${t.serializedVirtualBlockchainState.length} bytes`),t.serializedVirtualBlockchainState}static async query(e,t={}){try{return(await zE.post(e,t,{headers:{"Content-Type":`application/json; charset=UTF-8`,Accept:`application/json`}})).data}catch(t){if(t instanceof VE){if(t.code===`ECONNREFUSED`)throw new g(e);if(t.status===500)throw new h(`Internal error in the node: ${t.message}`)}throw t}}async broadcastTx(t){let n=new URL(this.nodeUrl);this.logger.info(`broadcastTx -> ${t.length} bytes to ${this.nodeUrl}`);let r=fg.bytesToBase64Encoder();return await e.query(n,{jsonrpc:`2.0`,id:1,method:`broadcast_tx_sync`,params:{tx:r.encode(t)}})}async abciQuery(t){if(t===void 0)throw new i(`Cannot send an undefined request`);this.logger.debug(`Sending ABCI request:`,t);let n=WD.encodeAbciRequest(t);return await e.sendABCIQueryToNodeServer(this.nodeUrl,n)}static async sendABCIQueryToNodeServer(t,n){e.staticLogger.debug(`Sending ABCI Query to node server at ${t} (${n.length} bytes) `);let r=new URL(t);r.pathname=`abci_query`,r.searchParams.append(`path`,`"/carmentis"`),r.searchParams.append(`data`,`0x`+k.binaryToHexa(n));let i=await e.query(r),a=i?.result?.response?.value;if(typeof a!=`string`)throw this.staticLogger.error(`Invalid response type detected:`,i),this.staticLogger.error(`rawBase64EncodedResponse: `,a),new h(`Invalid response detected`);let o=sg.decodeBinary(a),s=WD.decodeAbciResponse(o);if(s.responseType==SD.ERROR){let t=s.error;throw e.staticLogger.error(`sendABCIQueryToNodeServer <- {*}`,()=>({error:t})),new h(`Remote error: ${t}`)}return e.staticLogger.debug(`Returning ABCI response`),s}static async sendStatusQueryToNodeServer(t){e.staticLogger.debug(`sendStatusQueryToNodeServer -> nodeUrl: ${t}`);let n=new URL(t);n.pathname=`status`;let r=am(nD,await e.query(n));if(r.success)return e.staticLogger.debug(`sendStatusQueryToNodeServer <- received valid status response`),r.output;throw e.staticLogger.debug(`sendStatusQueryToNodeServer <- parsing error: ${r.issues}`),new h(r.issues.map(e=>e.message).join(`, `))}async getGenesisSnapshot(){this.requestLogger.info(`Requesting genesis snapshot`);let e=L(zD,await this.abciQuery({requestType:rD.GET_GENESIS_SNAPSHOT}));return this.responseLogger.info(`Received genesis snapshots containing {chunksNumber} chunks`,()=>({chunksNumber:e.base64EncodedChunks.length})),e}},KD=class e{static logger=ts.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}constructor(){}clear(){e.logger.info(`Clearing`)}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(e){return null}async getSerializedMicroblockHeader(e){return null}async getMicroblockBody(e){return null}async getSerializedVirtualBlockchainState(e){return null}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(e,t){}async setSerializedMicroblockHeader(e,t){}async setSerializedMicroblockBody(e,t){}async setMicroblockHeader(e,t){}async setMicroblockBody(e,t){}async setSerializedVirtualBlockchainState(e,t){}},qD=class{constructor(){}sendSerializedMicroblock(e){throw Error(`Method not implemented.`)}awaitMicroblockAnchoring(e){throw Error(`Method not implemented.`)}getChainInformation(){throw Error(`Method not implemented.`)}getBlockInformation(e){throw Error(`Method not implemented.`)}getBlockContent(e){throw Error(`Method not implemented.`)}getValidatorNodeByAddress(e){throw Error(`Method not implemented.`)}getAccountState(e){throw Error(`Method not implemented.`)}getAccountHistory(e,t,n){throw Error(`Method not implemented.`)}getAccountByPublicKeyHash(e){throw Error(`Method not implemented.`)}getObjectList(e){throw Error(`Method not implemented.`)}getMicroblockInformation(e){return Promise.resolve(null)}getMicroblockBodys(e){return Promise.resolve(null)}getVirtualBlockchainUpdate(e,t){throw Error(`Method not implemented.`)}getSerializedVirtualBlockchainState(e){throw Error(`Method not implemented.`)}broadcastTx(e){throw Error(`Method not implemented.`)}abciQuery(e){throw Error(`Method not implemented.`)}getGenesisSnapshot(){throw Error(`Method not implemented.`)}},JD=class{static convertRawPublicKeyIntoAddress(e){return $c.sha256AsBinary(e).slice(0,20)}},YD=class e extends HC{logger=ts.getProviderLogger();externalProvider;internalProvider;constructor(e,t){super(),this.internalProvider=e,this.externalProvider=t}async awaitMicroblockAnchoring(e){return await this.externalProvider.awaitMicroblockAnchoring(e)}async getChainInformation(){return await this.externalProvider.getChainInformation()}async getGenesisSnapshot(){return await this.externalProvider.getGenesisSnapshot()}async getBlockInformation(e){return await this.externalProvider.getBlockInformation(e)}async getBlockContent(e){return await this.externalProvider.getBlockContent(e)}async getAccountState(e){return await this.externalProvider.getAccountState(e)}async getAccountHistory(e,t,n){return await this.externalProvider.getAccountHistory(e,t,n)}async getAccountByPublicKeyHash(t){let n=await this.internalProvider.getAccountByPublicKeyHash(t);if(n!==null)return n;let r=await this.externalProvider.getAccountByPublicKeyHash(t);return ts.getLogger([e.name]).debug(`Account hash ${r} is associated to public key hash ${t}`),r.accountHash}async getVirtualBlockchainState(e){this.logger.info(`Getting state for virtual blockchain ${k.binaryToHexa(e)}`);let t=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(t!==null)return this.logger.info(`State for virtual blockchain ${k.binaryToHexa(e)} found locally`),Y.decodeVirtualBlockchainState(t);{let t=await this.externalProvider.getSerializedVirtualBlockchainState(e);return t?(this.logger.info(`State for virtual blockchain ${k.binaryToHexa(e)} found online`),await this.internalProvider.setSerializedVirtualBlockchainState(e,t),Y.decodeVirtualBlockchainState(t)):null}}async getAccountIdByPublicKey(e){let t=await e.getPublicKeyAsBytes(),n=j.Hashes.sha256AsBinary(t);return await this.getAccountByPublicKeyHash(n)}async getProtocolState(){let e=await this.getProtocolVirtualBlockchainId(),t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Cannot get protocol parameters from the internal provider`);if(t.type!==V.PROTOCOL_VIRTUAL_BLOCKCHAIN)throw Error(`Expected protocol virtual blockchain, got ${V[t.type]}`);return Ex.createFromObject(t.internalState)}async getProtocolVirtualBlockchainId(){let e=await this.getObjectList(V.PROTOCOL_VIRTUAL_BLOCKCHAIN),t=e.list.length;if(t===0)throw this.logger.error(`No protocol virtual blockchain found: Expecting exactly one protocol virtual blockchain.`),Error(`No protocol virtual blockchain found`);return t!==1&&this.logger.warning(`Found `+t+` protocol virtual blockchains, expecting exactly one`),Sx.from(e.list[0])}async getAllAccounts(){return(await this.getObjectList(V.ACCOUNT_VIRTUAL_BLOCKCHAIN)).list.map(Sx.from)}async getAllValidatorNodes(){return(await this.getObjectList(V.NODE_VIRTUAL_BLOCKCHAIN)).list.map(Sx.from)}async getAllOrganizationIds(){return(await this.getObjectList(V.ORGANIZATION_VIRTUAL_BLOCKCHAIN)).list.map(Sx.from)}async getAllApplicationIds(){return(await this.getObjectList(V.APPLICATION_VIRTUAL_BLOCKCHAIN)).list.map(Sx.from)}async getObjectList(e){return await this.externalProvider.getObjectList(e)}async getMicroblockInformation(e){let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e),n=await this.internalProvider.getMicroblockHeader(e);if(t&&n)return{...t,header:n};let r=await this.externalProvider.getMicroblockInformation(e);if(r){let t=Y.encodeVirtualBlockchainInfo({virtualBlockchainId:r.virtualBlockchainId,virtualBlockchainType:r.virtualBlockchainType});return await this.internalProvider.setMicroblockVbInformation(e,t),await this.internalProvider.setMicroblockHeader(e,r.header),r}return null}async getListOfMicroblockBody(e){let t=[],n=[],r=0;for(let i of e){let e=await this.internalProvider.getMicroblockBody(i);if(e){let n=Y.decodeMicroblockBody(e);t.push({hash:i,body:n})}else n.push(i);r+=1}if(n.length){let r=await this.externalProvider.getMicroblockBodys(n);if(r===null)throw Error(`Unable to load microblock bodies`);for(let{microblockBody:e,microblockHash:n}of r.list){let r=Y.encodeMicroblockBody(e);await this.internalProvider.setSerializedMicroblockBody(n,r),t.push({hash:n,body:e})}t.sort((t,n)=>e.indexOf(t.hash)-e.indexOf(n.hash))}return t.map(e=>e.body)}async getMicroblockBody(e){this.logger.info(`Looking for body for microblock ${e.encode()}`);let t=await this.internalProvider.getMicroblockBody(e.toBytes());if(t instanceof Uint8Array)return this.logger.info(`Body for microblock ${e.encode()} found locally`),Y.decodeMicroblockBody(t);{let t=await this.externalProvider.getMicroblockBodys([e.toBytes()]);if(t!==null&&t.list.length!==0){let n=t.list[0].microblockBody;return await this.internalProvider.setMicroblockBody(e.toBytes(),n),this.logger.info(`Body for microblock ${e.encode()} found online`),n}}return this.logger.warning(`Body for microblock ${e.encode()} not found`),null}async getMicroblockHeader(e){this.logger.info(`Looking for header for microblock ${e.encode()}`);let t=await this.internalProvider.getSerializedMicroblockHeader(e.toBytes());if(t instanceof Uint8Array){let n=j.Hashes.sha256(t),r=Y.decodeMicroblockHeader(t);return this.logger.info(`Header for microblock ${e.encode()} found locally (sha256:${n}): {header}`,{header:JSON.stringify(r)}),r}let n=await this.externalProvider.getMicroblockInformation(e.toBytes());if(n!==null)return this.logger.info(`Header for microblock ${e.encode()} found online: {header}:`,{header:n.header}),n.header;throw new te}async getVirtualBlockchainIdContainingMicroblock(e){this.logger.info(`Searching for virtual blockchain containing microblock ${e.encode()}`);let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e.toBytes());if(t!==null)return Sx.from(t.virtualBlockchainId);{let t=await this.externalProvider.getMicroblockInformation(e.toBytes());if(t!==null)return Sx.from(t.virtualBlockchainId);throw new te}}async getVirtualBlockchainHashes(e){let t=await this.getVirtualBlockchainStatus(e);if(t===void 0||t?.microblockHashes===void 0)throw Error(`Cannot access the virtual blockchain`);return t.microblockHashes}async getVirtualBlockchainHeaders(e,t){let n=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(n instanceof Uint8Array){let e=Y.decodeVirtualBlockchainState(n),r=e.height,i=e.lastMicroblockHash,o=[];for(;r>t;){let e=await this.internalProvider.getSerializedMicroblockHeader(i);if(e instanceof Uint8Array)o.push(e),i=Y.previousHashFromHeader(e),r--;else throw new a(`Cannot get the headers of a non-existing microblock ${k.binaryToHexa(i)}`)}return o}else throw new a(`Cannot get the headers of a non-existing VB`)}async getVirtualBlockchainStatus(e){let t=[],n=null,r=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(r!==null){n=Y.decodeVirtualBlockchainState(r);let i=n.height,a=n.lastMicroblockHash,o=[];for(;i;){let e=await this.internalProvider.getSerializedMicroblockHeader(a);if(!e)break;o.push(e),a=Y.previousHashFromHeader(e),i--}if(i==0){let n=Y.checkHeaderList(o);n.valid?(n.hashes.reverse(),k.binaryIsEqual(n.hashes[0],e)?t=n.hashes:this.logger.warning(`WARNING - genesis microblock hash from internal storage does not match VB identifier`)):this.logger.warning(`WARNING - inconsistent hash chain in internal storage`)}}let i=t.length,a=await this.externalProvider.getVirtualBlockchainUpdate(e,i);if(!a.exists)return null;if(a.changed){let r=Y.checkHeaderList(a.serializedHeaders);if(!r.valid)throw Error(`received headers are inconsistent`);if(i){let e=a.serializedHeaders.length,n=a.serializedHeaders[e-1],r=Y.previousHashFromHeader(n);if(!k.binaryIsEqual(r,t[i-1]))throw Error(`received headers do not link properly to the last known header`)}await this.internalProvider.setSerializedVirtualBlockchainState(e,a.serializedVirtualBlockchainState),n=Y.decodeVirtualBlockchainState(a.serializedVirtualBlockchainState);for(let t=0;t<a.serializedHeaders.length;t++)await this.internalProvider.setMicroblockVbInformation(r.hashes[t],Y.encodeVirtualBlockchainInfo({virtualBlockchainType:n.type,virtualBlockchainId:e})),await this.internalProvider.setSerializedMicroblockHeader(r.hashes[t],a.serializedHeaders[t]);t=[...t,...r.hashes.reverse()]}return n===null?null:{state:n,microblockHashes:t}}async getAccountIdFromPublicKey(e){let t=new rv,n=await this.externalProvider.getAccountByPublicKeyHash(t.hash(await e.getPublicKeyAsBytes()));return Sx.from(n.accountHash)}async publishMicroblock(e){this.logger.info(`Publishing microblock ${e.getHash().encode()}`);let{microblockData:t}=e.serialize();return await this.externalProvider.sendSerializedMicroblock(t),e.getHash()}async getNodeStatus(e){return GD.sendStatusQueryToNodeServer(e)}async getValidatorNodeIdByAddress(e){return(await this.externalProvider.getValidatorNodeByAddress(e.toBytes())).validatorNodeHash}async getValidatorNodeIdByCometbftPublicKey(e){let t=fg.bytesToBase64Encoder(),n=JD.convertRawPublicKeyIntoAddress(t.decode(e));return this.getValidatorNodeIdByAddress(Sx.from(n))}},XD=class{static createInMemoryProvider(){return new YD(new WC,new qD)}static createInMemoryProviderWithExternalProvider(e){return new YD(new WC,GD.createFromUrl(e))}static createNullInMemoryProviderWithExternalProvider(e){return new YD(new KD,GD.createFromUrl(e))}},ZD=class extends GD{constructor(e){super(e)}},QD=F({jsonrpc:N(`2.0`),id:P(),result:F({query:I(),data:F({type:N(`tendermint/event/NewBlock`),value:F({block:F({header:F({version:F({block:I(),app:Qp(I())}),chain_id:I(),height:I(),time:I(),last_block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),last_commit_hash:I(),data_hash:I(),validators_hash:I(),next_validators_hash:I(),consensus_hash:I(),app_hash:I(),last_results_hash:I(),evidence_hash:I(),proposer_address:I()}),data:F({txs:M(I())}),evidence:F({evidence:M(Gp())}),last_commit:F({height:I(),round:P(),block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),signatures:M(F({block_id_flag:P(),validator_address:I(),timestamp:I(),signature:I()}))})}),block_id:F({hash:I(),parts:F({total:P(),hash:I()})}),result_finalize_block:F({validator_updates:Qp(nm([Xp(),Gp()])),app_hash:I()})})}),events:F({"tm.event":M(I())})})}),$D=class e{callbacks=[];constructor(e){this.ws=e,e.onmessage=this.onMessage.bind(this),e.onopen=this.onConnect.bind(this),e.onclose=this.onDisconnect.bind(this)}static new(t){return new e(new WebSocket(t))}addCallback(e){this.callbacks.push(e)}onConnect(e){this.ws.send(JSON.stringify({jsonrpc:`2.0`,method:`subscribe`,id:1,params:{query:`tm.event='NewBlock'`}}))}onMessage(e){let t=am(QD,JSON.parse(e.data));if(t.success){let e=t.output;this.onNewBlock(e)}}onNewBlock(e){for(let t of this.callbacks)t.onNewBlock&&t.onNewBlock(e)}onDisconnect(e){}},eO={parsePrefix:tO,toNumericPath:nO,fromNumericPath:rO,processCallback:aO,fromParents:iO};function tO(e){let t=/^(this|previous|block(\d+))(?=\.|\[)/.exec(e);if(!t)throw`invalid prefix for path '${e}'`;return{prefix:t[0],pathString:e.slice(t[0].length)}}function nO(e,t){return oO(e,t,!1).numericPath}function rO(e,t){let n=e[0],r=``;for(let e of t)n.type==2?(n=n.properties[e],r+=`.`+n.name):n.type==1&&(n=n.entries[e],r+=`[${n.index}]`);return r}function iO(e){let t=``;for(let n=1;n<e.length;n++){let r=e[n];t+=e[n-1].type==1?`[${r.index}]`:`.`+r.name}return t}function aO(e,t,n){let r=oO(e,t,!0);r.hasWildcard?(function e(t){for(let r of t)r.type==2?e(r.properties):r.type==1?e(r.entries):n(r)})(r.item):n(r.item)}function oO(e,t,n){let r=t.match(/\[(?:\*|\d+)\]|\.(?:\*|[^.*\[\]]+)/g);if(r.join(``)!=t)throw`invalid syntax for path '${t}'`;let i=[],a=e[0],o,s=!1;for(let e of r){if(s)throw`a wildcard cannot be followed by anything else`;switch(e[0]){case`.`:{let t=e.slice(1);if(a.type!=2)throw`cannot read property '${t}': the parent node is not an object`;if(t==`*`){if(!n)throw`a wildcard is not allowed`;a=a.properties,s=!0}else{if(o=a.properties.findIndex(e=>e.name==t),o==-1)throw`cannot find property '${t}'`;a=a.properties[o]}break}case`[`:{if(a.type!=1)throw`cannot read entry '${e}': the parent node is not an array`;let t=e.slice(1,-1);if(t==`*`){if(!n)throw`a wildcard is not allowed`;a=a.entries,s=!0}else{if(o=a.entries.findIndex(e=>e.index==t),o==-1)throw`cannot find index '${t}'`;a=a.entries[o]}break}}i.push(o)}if(!s)switch(a.type){case 2:throw`the last part of the path must be a primitive type${n?` (use .* to access all object properties)`:``}`;case 1:throw`the last part of the path must be a primitive type${n?` (use [*] to access all array entries)`:``}`}return{item:a,numericPath:i,hasWildcard:s}}var sO=class{nLeaves;tree;constructor(){this.tree=new CS}addItem(e,t){let n=this.getLeafInfo(e,t);e.attributes&2?this.addMaskableItem(e,n):e.attributes&1?this.addHashableItem(e,n):this.addRawItem(e,n)}getLeafInfo(e,t){let n=eO.fromParents(t),r=Qa.encode(n);if(r.length>65535)throw`path too long`;let i=new Uint8Array(r.length+3);return i[0]=e.type,i[1]=r.length>>8,i[2]=r.length&255,i.set(r,3),i}getWitnesses(e){let t=[];for(let n=0;n<this.nLeaves;n++)e.has(n)||t.push(n);return this.tree.getWitnesses(t).map(e=>k.binaryToHexa(e)).join(``)}},cO=class extends sO{leaves;pepper;saltCounter;sha512;constructor(e){super(),this.pepper=e||this.constructor.generatePepper(),this.saltCounter=0,this.leaves=[]}static generatePepper(){return j.Random.getBytes(32)}addLeaf(e,t){this.leaves.push({item:e,hash:j.Hashes.sha256AsBinary(t)})}generateTree(){this.nLeaves=this.leaves.length,this.leaves.sort((e,t)=>k.binaryCompare(e.hash,t.hash));for(let e in this.leaves)this.tree.addLeaf(this.leaves[+e].hash),this.leaves[+e].item.leafIndex=+e;this.tree.finalize();let e=this.tree.getRootHash();return{nLeaves:this.leaves.length,rootHash:k.binaryToHexa(e),pepper:k.binaryToHexa(this.pepper)}}addRawItem(e,t){let n=this.getSalt();e.salt=k.binaryToHexa(n),this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addHashableItem(e,t){let n=this.getSalt(),r=j.Hashes.sha256AsBinary(e.valueBinary);e.hash=k.binaryToHexa(r),e.salt=k.binaryToHexa(n),this.addLeaf(e,k.binaryFrom(n,t,r))}addMaskableItem(e,t){let n=this.getSalt(),r=j.Hashes.sha256AsBinary(k.binaryFrom(n,t,e.visiblePartsBinary)),i=this.getSalt(),a=j.Hashes.sha256AsBinary(k.binaryFrom(i,e.hiddenPartsBinary));e.visibleSalt=k.binaryToHexa(n),e.hiddenSalt=k.binaryToHexa(i),e.hiddenHash=k.binaryToHexa(a),this.addLeaf(e,k.binaryFrom(r,a))}getSalt(){let e=this.saltCounter&3,t=this.saltCounter++>>2;return e||(this.sha512=j.Hashes.sha512AsBinary(k.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},lO=class extends sO{nLeaves;witnesses;constructor(e,t){super(),this.nLeaves=e,this.witnesses=(t.match(/.{64}/g)||[]).map(e=>k.binaryFromHexa(e))}addLeaf(e,t){this.tree.setLeaf(e.leafIndex,j.Hashes.sha256AsBinary(t))}generateTree(){this.tree.finalize(this.nLeaves),this.tree.setWitnesses(this.witnesses);let e=this.tree.getRootHash();return{nLeaves:this.tree.getNumberOfLeaves(),rootHash:k.binaryToHexa(e)}}addRawItem(e,t){let n=k.binaryFromHexa(e.salt);this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addHashableItem(e,t){let n=k.binaryFromHexa(e.salt),r;e.hash?r=k.binaryFromHexa(e.hash):(r=j.Hashes.sha256AsBinary(e.valueBinary),e.hash=r),this.addLeaf(e,k.binaryFrom(n,t,e.valueBinary))}addMaskableItem(e,t){let n=k.binaryFromHexa(e.visibleSalt),r=j.Hashes.sha256AsBinary(k.binaryFrom(n,t,e.visiblePartsBinary)),i;if(e.hiddenHash)i=k.binaryFromHexa(e.hiddenHash);else{let t=k.binaryFromHexa(e.hiddenSalt);i=j.Hashes.sha256AsBinary(k.binaryFrom(t,e.hiddenPartsBinary)),e.hiddenHash=k.binaryToHexa(i)}this.addLeaf(e,k.binaryFrom(r,i))}},uO={getListFromRegex:dO,applyMask:fO,getVisibleText:pO,getFullText:mO};function dO(e,t,n){let r=(t.exec(e)||[]).slice(1);if(r.join(``)!=e)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>[t&1,e]).filter(e=>e[1]);if(i.length!=r.length||i.some(([e,t],n)=>e&&t!=`$`+(n+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;return i.forEach(([e,t],n)=>{let i=o+r[n].length;e||a.push([o,i,t]),o=i}),a}function fO(e,t){let n=[],r=[];return t.sort((e,t)=>e[0]-t[0]),t.forEach(([i,a,o],s)=>{let[c,l]=s?t[s-1]:[0,0];if(i<0||i>=e.length||a<=i)throw`invalid interval [${[i,a]}]`;if(i<l)throw`overlapping intervals [${[c,l]}] / [${[i,a]}]`;let u=e.slice(i,a);s&&i==l?(n[n.length-1]+=o,r[r.length-1]+=u):(n.push(e.slice(l,i),o),r.push(u)),s==t.length-1&&a<e.length&&n.push(e.slice(a))}),{visible:n,hidden:r}}function pO(e){return e.join(``)}function mO(e,t){return e.map((e,n)=>n&1?t[n>>1]:e).join(``)}var hO=24,gO=class e{importedFromProof;channelDefinitions;irObject=[];object;usedChannels=[];constructor(){this.irObject=[],this.importedFromProof=!1,this.channelDefinitions=new Map,this.object={recordData:this.irObject}}static getItemInstance(e){return{type:e,index:-1,name:``,properties:[],entries:[],value:null,attributes:0,channelId:null,channels:new Set,visibleParts:[],visiblePartsBinary:new Uint8Array,hiddenParts:[],hiddenPartsBinary:new Uint8Array,valueBinary:new Uint8Array,leafIndex:-1,salt:new Uint8Array,visibleSalt:new Uint8Array,hiddenSalt:new Uint8Array,hash:new Uint8Array,hiddenHash:new Uint8Array}}addPublicChannel(e){if(this.channelDefinitions.has(e))throw Error(`channel ${e} was already added`);this.channelDefinitions.set(e,{id:e,isPrivate:!1})}addPrivateChannel(e){if(this.channelDefinitions.has(e))throw Error(`channel ${e} was already added`);this.channelDefinitions.set(e,{id:e,isPrivate:!0,pepper:cO.generatePepper()})}buildFromJson(t){let n=[];this.importedFromProof=!1,i({root:t},n,!1),this.irObject=n;function r(t,n,r,a){let o=t[n],s=ro.getType(o);if(!ro.isJsonType(s))throw Error(`Invalid JSON type`);let c=e.getItemInstance(s);a?c.index=+n:c.name=n,s==2?(c.properties=[],i(o,c.properties,!1)):s==1?(c.entries=[],i(o,c.entries,!0)):(c.value=o,c.attributes=0,c.channelId=null),r.push(c)}function i(e,t,n){for(let i in e)r(e,i,t,n)}}exportToSectionFormat(){let e=[];for(let t of this.usedChannels){let n=this.channelDefinitions.get(t);if(n){let r=this.exportChannelToSectionFormat(n),i;i=n.isPrivate?{isPrivate:!0,channelId:t,data:r,merkleRootHash:this.getMerkleRootHash(t)}:{isPrivate:!1,channelId:t,data:r},e.push(i)}}return e}exportChannelToSectionFormat(e){let t=new kv;e.isPrivate&&t.writeByteArray(e.pepper);let n=this.buildDictionary(e.id);t.writeVarUint(n.length);for(let e of n)t.writeString(e);return this.traverseIrObject({channelId:e.id,onObject:(e,n,a,o)=>{o.length>1&&r(e,a),t.writeByte(e.type),t.writeVarUint(i(e.properties))},onArray:(e,n,a,o)=>{o.length>1&&r(e,a),t.writeByte(e.type),t.writeVarUint(i(e.entries))},onPrimitive:(e,n,i,a)=>{r(e,i),t.writeByte(e.type|e.attributes<<3),e.attributes==2?(t.writeByteArray(e.visiblePartsBinary),t.writeByteArray(e.hiddenPartsBinary)):t.writeByteArray(e.valueBinary)}}),t.getByteStream();function r(e,r){t.writeVarUint(r?e.index:n.indexOf(e.name))}function i(t){return t.reduce((t,n)=>t+=n.type==1||n.type==2?+!!n.channels.has(e.id):+(n.channelId===e.id),0)}}importFromSectionFormat(e){this.importedFromProof=!1;for(let t of e){let e=this.channelDefinitions.get(t.channelId);if(e&&(this.importChannelFromSectionFormat(e,t.data),e.isPrivate)){let e=this.getMerkleRootHash(t.channelId);if(e!=t.merkleRootHash)throw Error(`inconsistent Merkle root hash (expected: ${t.merkleRootHash}, computed: ${e})`)}}this.populateChannels()}importChannelFromSectionFormat(t,n){let r=new Av(n);t.isPrivate&&(t.pepper=r.readByteArray(32));let i=r.readVarUint(),a=[];for(let e=0;e<i;e++)a.push(r.readString());o(this.irObject,!1,!0);function o(n,i,o=!1){let l=o?-1:r.readVarUint(),u=i?``:o?`root`:a[l],d=r.readByte(),f=d&7,p=d>>3,m;(f==2||f==1)&&(m=n.find(e=>i?e.index==l:e.name==u));let h,g;if(m===void 0?(g=e.getItemInstance(f),h=!0,i?g.index=l:g.name=u):(g=m,h=!1),f==2)g.channels.add(t.id),s(g);else if(f==1)g.channels.add(t.id),c(g,!h);else{if(p==2){let e;g.visibleParts=[],g.hiddenParts=[],e=r.getPointer();for(let e=r.readVarUint();e--;)g.visibleParts.push(r.readString());g.visiblePartsBinary=r.extractFrom(e),e=r.getPointer();for(let e=r.readVarUint();e--;)g.hiddenParts.push(r.readString());g.hiddenPartsBinary=r.extractFrom(e),g.value=uO.getFullText(g.visibleParts,g.hiddenParts)}else g.value=r.readJsonValue(f),g.valueBinary=r.getLastField();g.attributes=p,g.channelId=t.id}h&&n.push(g)}function s(e){let t=r.readVarUint();e.properties=e.properties||[];for(let n=0;n<t;n++)o(e.properties,!1)}function c(e,t){let n=r.readVarUint();e.entries=e.entries||[];for(let t=0;t<n;t++)o(e.entries,!0);t&&e.entries.sort((e,t)=>e.index-t.index)}}exportToProof(){let t=new e,n=[];for(let e of this.usedChannels){let r=this.channelDefinitions.get(e);if(r===void 0||!r.isPrivate)continue;let i=this.getMerklizer(e),a=i.generateTree(),o=new Set;this.traverseIrObject({channelId:e,onPrimitive:(e,n,r,i)=>{if(!(e.attributes&4)){o.add(e.leafIndex);let n=t.createBranch(i);n.attributes=e.attributes,n.channelId=e.channelId,n.leafIndex=e.leafIndex,e.attributes&2?(n.visibleSalt=e.visibleSalt,n.visibleParts=e.visibleParts,e.attributes&16?n.hiddenHash=e.hiddenHash:(n.hiddenSalt=e.hiddenSalt,n.hiddenParts=e.hiddenParts)):e.attributes&1?(n.salt=e.salt,e.attributes&8?n.hash=e.hash:n.value=e.value):(n.salt=e.salt,n.value=e.value)}}}),n.push({channelId:e,nLeaves:a.nLeaves,witnesses:i.getWitnesses(o)})}return t.object.merkleData=n,t.object}importFromProof(e){this.importedFromProof=!0,this.object=e,this.irObject=e.recordData,this.populateChannels(),this.serializeFields();let t=[];for(let e of this.usedChannels){let n=this.channelDefinitions.get(e);if(n){if(!n.isPrivate)continue;let r=this.getMerklizer(e).generateTree();t.push({channelId:e,rootHash:r.rootHash})}}return t}createBranch(t){let n=this.irObject,r=!1,i;for(let e of t)if(e.type==2||e.type==1){let t=n.find(t=>r?t.index==e.index:t.name==e.name);t===void 0&&(t=a(e),e.type==2?t.properties=[]:t.entries=[],n.push(t)),r=t.type==1,n=r?t.entries:t.properties}else{i=a(e),n.push(i);break}if(i===void 0)throw Error(`internal error: failed to create a branch`);return i;function a(t){let n=e.getItemInstance(t.type);return r?n.index=t.index:n.name=t.name,n}}getMerkleRootHash(e){return this.getMerklizer(e).generateTree().rootHash}getMerklizer(e){let t;if(this.importedFromProof){let n=this.object.merkleData.find(t=>t.channelId==e);t=new lO(n.nLeaves,n.witnesses)}else{let n=this.channelDefinitions.get(e);if(n&&n.isPrivate)t=new cO(n.pepper);else throw Error(`internal error: cannot compute the merklizer for either undefined channel or public channel`)}return this.traverseIrObject({channelId:e,onPrimitive:(e,n,r,i)=>{t.addItem(e,i)}}),t}getIRObject(){return this.irObject}dumpIRObject(){return JSON.stringify(this.irObject,(e,t)=>t instanceof Uint8Array?[`<${t.length} byte(s)>`,...[...t.slice(0,hO)].map(e=>e.toString(16).toUpperCase().padStart(2,`0`))].join(` `)+(t.length>hO?` ..`:``):t instanceof Set?[...t]:t,2)}setChannel(e,t){if(!this.channelDefinitions.has(t))throw`channel ${t} is undefined`;this.processPath(e,e=>{e.channelId=t})}setAsMaskable(e,t){this.processPath(e,e=>{let n=uO.applyMask(e.value,t);e.visibleParts=n.visible,e.hiddenParts=n.hidden,e.attributes=2})}setAsMaskableByRegex(e,t,n){this.processPath(e,e=>{let r=uO.getListFromRegex(e.value,t,n),i=uO.applyMask(e.value,r);e.visibleParts=i.visible,e.hiddenParts=i.hidden,e.attributes=e.attributes&-4|2})}setAsHashable(e){this.processPath(e,e=>{e.attributes=e.attributes&-4|1})}setAsRedacted(e){this.processPath(e,e=>{e.attributes=e.attributes&-29|4})}setAsMasked(e){this.processPath(e,e=>{if(!(e.attributes&2))throw`this item is not maskable`;if(e.attributes&28)throw`the format of this item was already set`;e.attributes=e.attributes&-29|16})}setAsHashed(e){this.processPath(e,e=>{if(!(e.attributes&1))throw`this item is not hashable`;if(e.attributes&28)throw`the format of this item was already set`;e.attributes=e.attributes&-29|8})}processPath(e,t){let n=e.split(/, */);for(let e of n){let n=eO.parsePrefix(e);if(n.prefix!=`this`)throw`the path must start with 'this'`;eO.processCallback(this.irObject,n.pathString,t)}}finalizeChannelData(){this.serializeFields(),this.populateChannels()}populateChannels(){this.traverseIrObject({onPrimitive:(e,t,n,r)=>{for(let t=0;t<r.length-1;t++){if(e.channelId===null)throw Error(`field '${eO.fromParents(r)}' is not assigned to any channel`);(r[t].channels=r[t].channels||new Set).add(e.channelId)}}});let e=this.irObject[0];e===void 0?this.usedChannels=[]:this.usedChannels=[...e.channels].sort((e,t)=>e-t);for(let e of this.usedChannels)if(!this.channelDefinitions.has(e))throw Error(`channel ${e} is undefined`)}buildDictionary(e){let t=new Map;this.traverseIrObject({channelId:e,onObject:(e,t,r,i)=>{i.length>1&&!r&&n(e)},onArray:(e,t,r,i)=>{r||n(e)},onPrimitive:(e,t,r,i)=>{r||n(e)}});function n(e){t.set(e.name,t.has(e.name)?t.get(e.name)+1:1)}let r=[];for(let[e,n]of t)r.push([n,e]);return[...new Map([...r.sort((e,t)=>t[0]-e[0]).map((e,t)=>[e[1],t])]).keys()]}serializeFields(){this.traverseIrObject({onPrimitive:(e,t,n,r)=>{let i=new kv;if(e.attributes&2){i.writeVarUint(e.visibleParts.length);for(let t of e.visibleParts)i.writeString(t);if(e.visiblePartsBinary=i.getByteStream(),!(e.attributes&16)){i.clear(),i.writeVarUint(e.hiddenParts.length);for(let t of e.hiddenParts)i.writeString(t);e.hiddenPartsBinary=i.getByteStream()}}else e.attributes&8||(i.writeJsonValue(e.type,e.value),e.valueBinary=i.getByteStream())}})}traverseIrObject(e){r(this.irObject,e.initialContext,!1,[]);function t(t,n){return e.channelId===void 0||(n?t.channelId===e.channelId:t.channels.has(e.channelId))}function n(n,i,a,o){let s=[...o,n];if(n.type==1){if(t(n,!1)){let t=e.onArray&&e.onArray(n,i,a,s);r(n.entries,t,!0,s)}}else if(n.type==2){if(t(n,!1)){let t=e.onObject&&e.onObject(n,i,a,s);r(n.properties,t,!1,s)}}else t(n,!0)&&e.onPrimitive&&e.onPrimitive(n,i,a,s)}function r(e,t,r,i){for(let a of e)n(a,t,r,i)}}exportToJson(){let e={root:null};return this.traverseIrObject({initialContext:e,onArray:(e,t,n)=>t[n?e.index:e.name]=[],onObject:(e,t,n)=>t[n?e.index:e.name]={},onPrimitive:(e,t,n,r)=>{t[n?e.index:e.name]=e.value}}),e.root===null?{}:e.root}},_O=class{static async encode(e,t){let n=[],r=[],i=e.split(/(\{\{.+?\}\})/);for(let e in i){let a=i[e];if(e&1){let e=a.slice(2,-2).trim(),n=eO.parsePrefix(e),i=await t(n.blockIndex),o=eO.toNumericPath(i,n.pathString);r.push(o)}else n.push(a)}for(;n[n.length-1]==``;)n.pop();return{texts:n,fields:r}}static async decode(e,t){for(let n of e.fields){let e=await t(0),r=eO.fromNumericPath(e,n);console.log(r)}}},vO=2,yO=32,bO={CACHE_HORIZON:vO,HASH_SIZE:yO,ROOT_ANCHORING_HASH:new Uint8Array(yO)},xO={keyDifference:SO,getHashList:CO};function SO(e,t,n){for(let r=e;r<bO.HASH_SIZE*2;r++)if((t[r>>1]^n[2+(r>>1)-(e>>1)])>>4*(r&1)&15)return 1;return 0}function CO(e,t){let n=[],r=2;for(let i=0;i<16;i++)n.push(e&1<<i?t.slice(r,r+=bO.HASH_SIZE):null);return n}var wO={verifyProof:TO};async function TO(e,t,n){return await EO(e,t,n,null,0)&&j.Hashes.sha256AsBinary(n[0])}async function EO(e,t,n,r,i){if(i==bO.HASH_SIZE*2)return k.binaryIsEqual(r,t);let a=n[i];if(i&&!k.binaryIsEqual(j.Hashes.sha256AsBinary(a),r))return!1;let o=a[0]<<8|a[1];if(o){let r=xO.getHashList(o,a),s=e[i>>1]>>4*(i&1)&15;return o&1<<s?await EO(e,t,n,r[s],i+1):t===!1}if(xO.keyDifference(i,e,a))return t===!1;let s=bO.HASH_SIZE*2+1-i>>1;return k.binaryIsEqual(a.slice(2+s),t)}var DO=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Sx.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getLinkedAccount(){return Sx.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return mn.createAtomic(this.transaction.amount*e)}getChainReference(){return Sx.from(this.transaction.chainReference)}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},OO=class{transactionByHeight;constructor(){this.transactionByHeight=new Map}setTransactionAtHeight(e,t){this.transactionByHeight.set(e,t)}containsTransactions(){return this.transactionByHeight.size>0}getTransactionHeights(){return Array.from(this.transactionByHeight.keys())}getAllTransactions(){return Array.from(this.transactionByHeight.values()).map(e=>new DO(e))}getNumberOfTransactions(){return this.transactionByHeight.size}containsTransactionAtHeight(e){return this.transactionByHeight.has(e)}getTransactionAtHeight(e){let t=this.transactionByHeight.get(e);if(t===void 0)throw new i(`No transaction found at height ${e}`);return new DO(t)}},kO={[V.PROTOCOL_VIRTUAL_BLOCKCHAIN]:`PROTOCOL_VIRTUAL_BLOCKCHAIN`,[V.NODE_VIRTUAL_BLOCKCHAIN]:`NODE_VIRTUAL_BLOCKCHAIN`,[V.APPLICATION_VIRTUAL_BLOCKCHAIN]:`APPLICATION_VIRTUAL_BLOCKCHAIN`,[V.ORGANIZATION_VIRTUAL_BLOCKCHAIN]:`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,[V.APP_LEDGER_VIRTUAL_BLOCKCHAIN]:`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,[V.ACCOUNT_VIRTUAL_BLOCKCHAIN]:`ACCOUNT_VIRTUAL_BLOCKCHAIN`},AO=class{static getVirtualBlockchainLabelFromVirtualBlockchainType(e){return kO[e]}},jO=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_REQUEST_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_REQUEST_DATA_APPROVAL`,e}({}),MO=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_RESPONSE_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_RESPONSE_DATA_APPROVAL`,e}({}),NO=F({type:N(jO.AUTH_BY_PUBLIC_KEY),base64EncodedChallenge:I()}),PO=F({type:N(jO.DATA_APPROVAL),anchorRequestId:I(),serverUrl:I()}),FO=im(`type`,[NO,PO]),IO=F({type:N(MO.AUTH_BY_PUBLIC_KEY),publicKey:I(),signature:I()}),LO=F({type:N(MO.DATA_APPROVAL),b64VbHash:I(),b64MbHash:I(),height:P()}),RO=im(`type`,[IO,LO]),zO=100,BO=function(e){return e.REQUEST=`CLIENT_BRIDGE_REQUEST`,e.UPDATE_QR=`CLIENT_BRIDGE_UPDATE_QR`,e.CONNECTION_TOKEN=`CLIENT_BRIDGE_CONNECTION_TOKEN`,e.FORWARDED_ANSWER=`CLIENT_BRIDGE_FORWARDED_ANSWER`,e.GET_CONNECTION_INFO=`CLIENT_BRIDGE_GET_CONNECTION_INFO`,e.ANSWER=`CLIENT_BRIDGE_ANSWER`,e.CONNECTION_INFO=`CLIENT_BRIDGE_CONNECTION_INFO`,e.CONNECTION_ACCEPTED=`CLIENT_BRIDGE_CONNECTION_ACCEPTED`,e.FORWARDED_REQUEST=`CLIENT_BRIDGE_FORWARDED_REQUEST`,e.ERROR=`CLIENT_BRIDGE_ERROR`,e}({}),VO=F({base64EncodedQrId:I(),timestamp:P(),serverUrl:R(I(),Rp(100))}),HO=F({type:N(BO.REQUEST),walletRequest:FO,deviceId:Am(),withToken:P()}),UO=F({type:N(BO.UPDATE_QR),base64EncodedQrId:I(),timestamp:P()}),WO=F({type:N(BO.CONNECTION_TOKEN),token:Am()}),GO=F({type:N(BO.FORWARDED_ANSWER),walletResponse:RO}),KO=F({type:N(BO.GET_CONNECTION_INFO),base64EncodedQrId:I()}),qO=F({type:N(BO.ANSWER),walletResponse:RO}),JO=F({type:N(BO.CONNECTION_INFO)}),YO=F({type:N(BO.CONNECTION_ACCEPTED),base64EncodedQrId:I()}),XO=F({type:N(BO.FORWARDED_REQUEST),walletRequest:FO}),ZO=F({type:N(BO.ERROR),errorMessage:I()}),QO=im(`type`,[HO,UO,WO,GO,KO,qO,JO,YO,XO,ZO]),$O=class{static encode(e){return lx(L(QO,e))}static decode(e){return L(QO,Mb(e))}},ek=class{static validateClientBridgeMessage(e){return L(QO,e)}},tk=class{static encode(e){return lx(L(VO,e))}static decode(e){return L(VO,Mb(e))}},nk=em(I(),F({networkName:Qp(I()),nodes:em(I(),F({nodeName:Qp(I()),hostname:I(),rpcEndpoint:I(),p2pEndpoint:I(),trusted:Qp(Kp(),!1),nodeId:I()}))})),rk=F({state:Bh,microblockHashes:M(B())}),ik=function(e){return e.APPROVAL_HANDSHAKE=`WALLET_OPERATOR_REQUEST_APPROVAL_HANDSHAKE`,e.ACTOR_KEY=`WALLET_OPERATOR_REQUEST_ACTOR_KEY`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_REQUEST_APPROVAL_SIGNATURE`,e}({}),ak=function(e){return e.ERROR=`WALLET_OPERATOR_RESPONSE_ERROR`,e.ACTOR_KEY_REQUIRED=`WALLET_OPERATOR_RESPONSE_ACTOR_KEY_REQUIRED`,e.APPROVAL_DATA=`WALLET_OPERATOR_RESPONSE_APPROVAL_DATA`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_RESPONSE_APPROVAL_SIGNATURE`,e}({}),ok=F({type:N(ik.APPROVAL_HANDSHAKE),anchorRequestId:I()}),sk=F({type:N(ik.ACTOR_KEY),anchorRequestId:I(),actorSignaturePublicKey:I(),actorPkePublicKey:I()}),ck=F({type:N(ik.APPROVAL_SIGNATURE),anchorRequestId:I(),b64Signature:I()}),lk=im(`type`,[ok,sk,ck]),uk=F({type:N(ak.ERROR),errorMessage:Qp(I(),``)}),dk=F({type:N(ak.ACTOR_KEY_REQUIRED),b64GenesisSeed:I()}),fk=F({type:N(ak.APPROVAL_DATA),b64SerializedMicroblock:I()}),pk=F({type:N(ak.APPROVAL_SIGNATURE),b64VbHash:I(),b64MbHash:I(),height:P()}),mk=im(`type`,[uk,dk,fk,pk]),hk=class{static encodeRequest(e){return lx(L(FO,e))}static decodeRequest(e){return L(FO,Mb(e))}static encodeResponse(e){return lx(L(RO,e))}static decodeResponse(e){return L(RO,Mb(e))}},gk=class{static validateWalletRequest(e){return L(FO,e)}static validateWalletResponse(e){return L(RO,e)}},_k=class{constructor(e=new pg){this.stringEncoder=e}decode(e){let t=this.getPrefix(),n=gg.decode(e);if(n.matchesKeys(...t))return this.stringEncoder.decode(n.getValue());throw new l(`Invalid seed format`)}encode(e){let t=this.getPrefix();return gg.encode(...t,this.stringEncoder.encode(e))}getPrefix(){return[`SEED`]}},vk=class extends _k{getPrefix(){return[`ACCOUNT`,`SEED`]}},yk=class e{static createFromAbciResponse(t){return new e(t.list)}constructor(e){this.transactions=e}containsTransactions(){return this.transactions.length>0}getTransactions(){return this.transactions.map(e=>new bk(e))}},bk=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Sx.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getTransactionTypeLabel(){return this.isEarnedFees()?`Earned fees`:this.isPaidFees()?`Paid fees`:this.isSentPayment()?`Sent payment`:this.isReceivedPayment()?`Received payment`:this.isPurchase()?`Purchase`:this.isSentIssuance()?`Sent issuance`:this.isReceivedIssuance()?`Received issuance`:this.isSale()?`Sale`:`Transaction`}getLinkedAccount(){return Sx.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return mn.createAtomic(this.transaction.amount*e)}getChainReference(){return Sx.from(this.transaction.chainReference)}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},xk=class extends _k{getPrefix(){return[`ACTOR`,`SEED`]}},Sk=class e{static createFromAccountStateAbciResponse(t){return new e(t.balance,t.locks)}logger=ts.getLogger([`accounts`,e.name]);balanceInAtomics;locks;constructor(t=0,n=[]){this.initialBalance=t,this.initialLocks=n,this.balanceInAtomics=t,this.locks=n,this.logger=lo([`node`,`accounts`,e.name])}setBalance(e){this.balanceInAtomics=e}getBalanceAsAtomics(){return this.balanceInAtomics}getBalance(){return mn.createAtomic(this.balanceInAtomics)}setLocks(e){this.locks=[...e]}getLocks(){return this.locks}hasNodeStakingLocks(){return this.locks.some(e=>e.type==Wh.NodeStaking)}getNodeStakingLocks(){return this.locks.filter(e=>e.type==Wh.NodeStaking)}getNodeStakingLock(e){return this.getNodeStakingLocks().find(t=>k.binaryIsEqual(t.parameters.validatorNodeId,e))}getNodeStakingLockAmount(e){let t=this.getNodeStakingLock(e);return t===void 0?0:t.lockedAmountInAtomics}hasEscrowLocks(){return this.locks.some(e=>e.type==Wh.Escrow)}getEscrowLocks(){return this.locks.filter(e=>e.type==Wh.Escrow)}hasVestingLocks(){return this.locks.some(e=>e.type==Wh.Vesting)}getVestingLocks(){return this.locks.filter(e=>e.type==Wh.Vesting)}removeExpiredEscrowLocks(){this.removeExpiredLocks(Wh.Escrow)}removeExpiredVestingLocks(){this.removeExpiredLocks(Wh.Vesting)}removeExpiredStakingLocks(){this.removeExpiredLocks(Wh.NodeStaking)}removeExpiredLocks(e){this.locks=this.locks.filter(t=>!(t.type==e&&t.lockedAmountInAtomics==0))}addSpendableTokens(e){this.balanceInAtomics+=e}addVestedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:Wh.Vesting,lockedAmountInAtomics:e,parameters:t})}addEscrowedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:Wh.Escrow,lockedAmountInAtomics:e,parameters:t})}releaseEscrowedTokens(e,t){let n=this.locks.findIndex(t=>t.type==Wh.Escrow&&k.binaryIsEqual(t.parameters.fundEmitterAccountId,e));if(n==-1)throw Error(`Escrow not found`);this.locks.splice(n,1)}addNodeStaking(e,t){let n=this.getBreakdown();if(e<0)throw Error(`Stake amount must be greater than 0`);if(e>n.stakeable)throw Error(`Cannot stake more than ${n.stakeable} atomic units`);let r=this.getNodeStakingLock(t);r===void 0?this.locks.push({type:Wh.NodeStaking,lockedAmountInAtomics:e,parameters:{validatorNodeId:t,plannedUnlockAmountInAtomics:0,plannedUnlockTimestamp:0,slashed:!1,plannedSlashingAmountInAtomics:0,plannedSlashingTimestamp:0}}):r.lockedAmountInAtomics+=e}planNodeStakingUnlock(e,t,n){let r=this.getNodeStakingLock(n);if(r===void 0)throw Error(`Staking not found`);if(r.parameters.plannedUnlockAmountInAtomics!=0)throw Error(`There's already a pending staking unlock for this node`);r.parameters.plannedUnlockAmountInAtomics=e,r.parameters.plannedUnlockTimestamp=k.addDaysToTimestamp(t,0)}applyNodeStakingUnlocks(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.plannedUnlockTimestamp!=0&&e>=r.parameters.plannedUnlockTimestamp){let e=r.parameters.plannedUnlockAmountInAtomics;this.removeNodeStaking(e,r.parameters.validatorNodeId),n+=e}return this.removeExpiredStakingLocks(),n}setSlashing(e,t){let n=this.getNodeStakingLocks().find(t=>t.parameters.validatorNodeId==e);if(n==null)throw Error(`Staking not found`);n.parameters.slashed=!0,n.parameters.plannedSlashingAmountInAtomics=n.lockedAmountInAtomics,n.parameters.plannedSlashingTimestamp=t}cancelNodeSlashing(e){let t=this.getNodeStakingLocks().find(t=>t.parameters.validatorNodeId==e);if(t==null)throw Error(`Staking not found`);t.parameters.slashed?(t.parameters.slashed=!1,t.parameters.plannedSlashingAmountInAtomics=0,t.parameters.plannedSlashingTimestamp=0):this.logger.warn(`No pending slashing for this node`)}applyNodeSlashing(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.slashed){let t=r.parameters.plannedSlashingAmountInAtomics;t>0&&r.parameters.plannedSlashingTimestamp!=0&&e>=r.parameters.plannedSlashingTimestamp&&(r.lockedAmountInAtomics-=t,this.balanceInAtomics-=t,n+=t,r.parameters.slashed=!1,r.parameters.plannedSlashingTimestamp=0,r.parameters.plannedSlashingAmountInAtomics=0)}return this.adjustVesting(),this.removeExpiredStakingLocks(),n}adjustVesting(){let e=this.getBreakdown().vested,t=e-this.balanceInAtomics;if(t>0){let n=this.getVestingLocks(),r=0;for(let i of n){let n=Math.floor(t*i.lockedAmountInAtomics/e);i.lockedAmountInAtomics-=n,r+=n}for(let e of n)r<t&&e.lockedAmountInAtomics>0&&(e.lockedAmountInAtomics--,r++);this.removeExpiredVestingLocks()}}removeNodeStaking(e,t){let n=this.getNodeStakingLock(t);if(n===void 0)throw Error(`Staking not found`);if(e<0)throw Error(`Unstake amount must be greater than 0`);if(e>n.lockedAmountInAtomics)throw Error(`Cannot unstake more than ${n.lockedAmountInAtomics} atomic units`);n.lockedAmountInAtomics-=e}applyLinearVesting(e){let t=this.getBreakdown().releasable,n=0,r=this.getVestingLocks();for(let i of r){let r=i.parameters.initialVestedAmountInAtomics,a=i.parameters.cliffStartTimestamp,o=i.parameters.cliffDurationDays,s=i.parameters.vestingDurationDays,c=k.addDaysToTimestamp(a,o),l=Math.min(k.timestampDifferenceInDays(c,e),s);if(this.logger.debug(`start date: {cliffStartDate}, initial amount: {initialAmount}, cliff during {cliffDurationDays} day(s), vesting during {vestingDurationDays} day(s)`,()=>({cliffStartDate:new Date(a*1e3).toISOString(),initialAmount:r,cliffDurationDays:o,vestingDurationDays:s})),this.logger.debug(`cliff end date: {cliffEndDay}, today: {today}, elapsed time in vesting: {elapsed} day(s)`,()=>({cliffEndDay:new Date(c*1e3).toISOString(),today:new Date(e*1e3).toISOString(),elapsed:l})),l>0){let e=r-i.lockedAmountInAtomics,a=Math.floor(r*l/s),o=Math.min(a-e,t);this.logger.debug(`already released: ${e}, max. release: ${a}, released today: ${o}`),i.lockedAmountInAtomics-=o,t-=o,n+=o}else this.logger.debug(`nothing is released today`)}return this.removeExpiredVestingLocks(),n}getBreakdown(){let e=new Map;for(let t of this.locks){let n=e.get(t.type)||0;e.set(t.type,n+t.lockedAmountInAtomics)}let t=e.get(Wh.Escrow)||0,n=e.get(Wh.Vesting)||0,r=e.get(Wh.NodeStaking)||0,i=this.balanceInAtomics-r-t,a=Math.max(0,n-r),o=t+Math.max(n,r),s=this.balanceInAtomics-o;return{balance:this.balanceInAtomics,escrowed:t,vested:n,releasable:a,staked:r,stakeable:i,locked:o,spendable:s}}getSpendable(){return mn.createAtomic(this.getBreakdown().spendable)}getVested(){return mn.createAtomic(this.getBreakdown().vested)}getStakeable(){return mn.createAtomic(this.getBreakdown().stakeable)}getStaked(){return mn.createAtomic(this.getBreakdown().staked)}},Ck=class{static encoder=new Xb({tagUint8Array:!0,mapsAsObjects:!0});static encodeRequest(e){return this.encoder.encode(L(lk,e))}static decodeRequest(e){return L(lk,this.encoder.decode(e))}static encodeResponse(e){return this.encoder.encode(L(mk,e))}static decodeResponse(e){return L(mk,this.encoder.decode(e))}},wk=class{static validateRequest(e){return L(lk,e)}static validateResponse(e){return L(mk,e)}},Tk=class extends _k{getPrefix(){return[`WALLET`,`SEED`]}},Ek=class e{constructor(e){this.actorSeed=e}static createFromAccountSeedAndVbSeed(t,n){return new e(k.binaryFrom(t,n))}static parseFromString(t,n=new _k){return new e(n.decode(t))}encode(e=new _k){return e.encode(this.actorSeed)}getSeedAsBytes(){return this.actorSeed}async getPrivateSignatureKey(e){let t=zv.createDefaultKDF(),n=this.encoderStringAsBytes(`SIG`),r=t.deriveKeyNoSalt(this.actorSeed,n,32);return zv.createPrivateSignatureKey(e,r)}async getPublicSignatureKey(e){return(await this.getPrivateSignatureKey(e)).getPublicKey()}getPrivateDecryptionKey(e){let t=zv.createDefaultKDF(),n=this.encoderStringAsBytes(`PKE`),r=t.deriveKeyNoSalt(this.actorSeed,n,64);return zv.createPrivateDecryptionKey(e,r)}async getPublicEncryptionKey(e){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}encoderStringAsBytes(e){return new TextEncoder().encode(e)}},Dk=class e{static createFromWalletSeedAndNonce(t,n){let r=k.binaryFrom(t,n),i=zv.createDefaultKDF(),a=this.encoderStringAsBytes(`ACCOUNT_SEED`);return new e(i.deriveKeyNoSalt(r,a,32))}static parseFromString(t,n=new _k){return new e(n.decode(t))}encode(e=new _k){return e.encode(this.accountSeed)}constructor(e){this.accountSeed=e}deriveActorFromVbSeed(e){return Ek.createFromAccountSeedAndVbSeed(this.accountSeed,e)}async getPrivateSignatureKey(t){let n=zv.createDefaultKDF();zv.createSignatureScheme(t);let r=e.encoderStringAsBytes(`SIG_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,32);return zv.createPrivateSignatureKey(t,i)}async getPublicSignatureKey(e){return(await this.getPrivateSignatureKey(e)).getPublicKey()}async getPrivateDecryptionKey(t){let n=zv.createDefaultKDF(),r=e.encoderStringAsBytes(`PKE_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,64);return zv.createPrivateDecryptionKey(t,i)}async getPublicEncryptionKey(e){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}static encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSeedAsBytes(){return this.accountSeed}getAccountSeed(){return this.accountSeed}static concatWalletSeedWith(e,t){return new Uint8Array([...e,...t])}static numberToUint8Array(e,t=4){let n=new ArrayBuffer(t),r=new DataView(n);return t===1?r.setUint8(0,e):t===2?r.setUint16(0,e,!1):t===4?r.setUint32(0,e,!1):t===8&&r.setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}getActor(e){return Ek.createFromAccountSeedAndVbSeed(this.accountSeed,e)}},Ok=class e{static generateWallet(){return new e(Iu(64))}static fromSeed(t){if(!(t instanceof Uint8Array))throw new i(`Seed must be a Uint8Array, got ${typeof t}`);return new e(t)}static parseFromString(t,n=new _k){if(typeof t!=`string`)throw new i(`Seed must be a string, got ${typeof t}`);return new e(n.decode(t))}encode(e=new _k){return e.encode(this.walletSeed)}constructor(e){this.walletSeed=e}getDefaultAccountCrypto(){return Dk.createFromWalletSeedAndNonce(this.walletSeed,0)}async generateActorPrivateSignatureKey(e,t){let n=zv.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`SIG`),32);return zv.createPrivateSignatureKey(e,a)}async generateActorPrivateDecryptionKey(e,t){let n=zv.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`PKE`),32);return zv.createPrivateDecryptionKey(e,a)}getPrivateSignatureKey(e=Ya.SECP256K1){let t=zv.createDefaultKDF(),n=zv.createSignatureScheme(e).expectedSeedSize(),r=Dk.encoderStringAsBytes(`SIG_${e}`),i=t.deriveKeyNoSalt(this.walletSeed,r,n);return zv.createPrivateSignatureKey(e,i)}getDecapsulationKey(e){return new zv().createDecapsulationKey(e,this.walletSeed)}getAccountSeed(e){return this.getAccount(e).getAccountSeed()}getAccount(e){return Dk.createFromWalletSeedAndNonce(this.walletSeed,e)}getAccountPrivateSignatureKey(e,t){return Dk.createFromWalletSeedAndNonce(this.walletSeed,t).getPrivateSignatureKey(e)}getActorPrivateSignatureKey(e,t,n){return Dk.createFromWalletSeedAndNonce(this.walletSeed,n).deriveActorFromVbSeed(t).getPrivateSignatureKey(e)}getVirtualBlockchainDecapsulationKey(e,t){return new zv().createVirtualBlockchainDecapsulationKey(e,this.walletSeed,t)}getSeedAsBytes(){return this.walletSeed}};exports.ACCOUNT_ALLOWED_TRANSFERS=Wr,exports.ACCOUNT_BLOCK_FEES=Hr,exports.ACCOUNT_BURNT_TOKENS=Br,exports.ACCOUNT_CREATION=ma,exports.ACCOUNT_ESCROW_SETTLEMENT=va,exports.ACCOUNT_ESCROW_TRANSFER=_a,exports.ACCOUNT_HISTORY=ii,exports.ACCOUNT_NAMES=Ur,exports.ACCOUNT_PUBLIC_KEY=fa,exports.ACCOUNT_STAKE=ya,exports.ACCOUNT_STANDARD=Vr,exports.ACCOUNT_STATE=ri,exports.ACCOUNT_TOKEN_ISSUANCE=pa,exports.ACCOUNT_TRANSFER=ha,exports.ACCOUNT_VESTING_TRANSFER=ga,exports.AES256GCMSymmetricEncryptionKey=Ig,exports.AES256GCMSymmetricEncryptionScheme=Fg,exports.ALL_SCHEMAS=aa,exports.ALL_SECTIONS_SCHEMAS=Ga,exports.APP_CREATION=ka,exports.APP_DESCRIPTION=Aa,exports.APP_LEDGER_ACTOR_CREATION=Fa,exports.APP_LEDGER_ACTOR_SUBSCRIPTION=za,exports.APP_LEDGER_ALLOWED_PKE_SCHEMES=Na,exports.APP_LEDGER_ALLOWED_SIG_SCHEMES=Ma,exports.APP_LEDGER_AUTHOR=Ha,exports.APP_LEDGER_CHANNEL_CREATION=Ia,exports.APP_LEDGER_CHANNEL_INVITATION=Ra,exports.APP_LEDGER_CREATION=Pa,exports.APP_LEDGER_ENDORSEMENT_REQUEST=Ua,exports.APP_LEDGER_PRIVATE_CHANNEL_DATA=Va,exports.APP_LEDGER_PUBLIC_CHANNEL_DATA=Ba,exports.APP_LEDGER_SHARED_SECRET=La,exports.ARRAY=om,exports.AbciQueryEncoder=WD,exports.AbciRequestSchema=xD,exports.AbciRequestType=rD,exports.AbciResponseSchema=UD,exports.AbciResponseType=SD,exports.AbstractPrivateDecryptionKey=xv,exports.AbstractProvider=HC,exports.AbstractPublicEncryptionKey=bv,exports.AbstractPublicKeyEncryptionScheme=yv,exports.AccountBreakdownSchema=Qh,exports.AccountByPublicKeyHashAbciResponseSchema=ID,exports.AccountCreationSectionSchema=qm,exports.AccountCrypto=Dk,exports.AccountEscrowSettlementSectionSchema=Zm,exports.AccountEscrowTransferSectionSchema=Xm,exports.AccountHistoryAbciResponseSchema=FD,exports.AccountHistoryEntrySchema=tg,exports.AccountHistorySchema=ng,exports.AccountHistoryView=OO,exports.AccountInformationSchema=eg,exports.AccountInternalState=xx,exports.AccountInternalStateUpdater=Ax,exports.AccountMicroblockStructureChecker=Jx,exports.AccountNotFoundForAccountHashError=ge,exports.AccountNotFoundForPublicKeyError=he,exports.AccountNotFoundForPublicKeyHashError=be,exports.AccountPublicKeySectionSchema=Gm,exports.AccountSeedEncoder=vk,exports.AccountStakeSectionSchema=Qm,exports.AccountStateAbciResponseSchema=PD,exports.AccountStateSchema=$h,exports.AccountTokenIssuanceSectionSchema=Km,exports.AccountTransaction=bk,exports.AccountTransactions=yk,exports.AccountTransferSectionSchema=Jm,exports.AccountUnstakeSectionSchema=$m,exports.AccountUpdateSchema=ig,exports.AccountUpdatesAbciResponseSchema=HD,exports.AccountVb=Yx,exports.AccountVestingTransferSectionSchema=Ym,exports.AccountVirtualBlockchainInternalStateSchema=wh,exports.AccountVirtualBlockchainStateSchema=Ph,exports.ActorAlreadyDefinedError=ne,exports.ActorCrypto=Ek,exports.ActorNotDefinedError=ae,exports.ActorNotInvitedError=me,exports.ActorNotSubscribedError=we,exports.ActorSeedEncoder=xk,exports.ActorType=FS,exports.Aes=cu,exports.AllowedAdditionalWriterSectionSchema=Vm,exports.AlreadySubscribedError=C,exports.AppLedgerLocalStateUpdaterV1=Px,exports.AppLedgerMicroblockBuildRequestSchema=US,exports.AppLedgerMicroblockBuildRequestValidation=WS,exports.ApplicationCreationSectionSchema=sh,exports.ApplicationDescriptionSectionSchema=ch,exports.ApplicationInternalState=Cx,exports.ApplicationInternalStateUpdater=jx,exports.ApplicationLedgerActorCreationSectionSchema=fh,exports.ApplicationLedgerActorInvitationStateSchema=kh,exports.ApplicationLedgerActorSchema=jh,exports.ApplicationLedgerActorSubscriptionSectionSchema=gh,exports.ApplicationLedgerAllowedPkeSchemesSectionSchema=uh,exports.ApplicationLedgerAllowedSigSchemesSectionSchema=lh,exports.ApplicationLedgerAuthorSectionSchema=yh,exports.ApplicationLedgerChannelCreationSectionSchema=ph,exports.ApplicationLedgerChannelInvitationSectionSchema=hh,exports.ApplicationLedgerChannelSchema=Oh,exports.ApplicationLedgerCreationSectionSchema=dh,exports.ApplicationLedgerEndorsementRequestSectionSchema=bh,exports.ApplicationLedgerInternalState=wx,exports.ApplicationLedgerInternalStateObjectSchema=Mh,exports.ApplicationLedgerMicroblockBuilder=PS,exports.ApplicationLedgerMicroblockStructureChecker=rS,exports.ApplicationLedgerNotFoundError=Se,exports.ApplicationLedgerPrivateChannelDataSectionSchema=vh,exports.ApplicationLedgerPublicChannelDataSectionSchema=_h,exports.ApplicationLedgerSharedSecretSectionSchema=mh,exports.ApplicationLedgerSharedSecretStateSchema=Ah,exports.ApplicationLedgerVb=jS,exports.ApplicationLedgerVirtualBlockchainStateSchema=Rh,exports.ApplicationMicroblockStructureChecker=Xx,exports.ApplicationNotFoundError=ve,exports.ApplicationVBInternalStateObjectSchema=Dh,exports.ApplicationVb=Zx,exports.ApplicationVirtualBlockchainStateSchema=Lh,exports.Assertion=nS,exports.AwaitMicroblockAnchoringAbciRequestSchema=uD,exports.BIN256=vm,exports.BINARY=_m,exports.BK_EARNED_BLOCK_FEES=Er,exports.BK_EARNED_TX_FEES=Tr,exports.BK_NAMES=zr,exports.BK_PAID_BLOCK_FEES=gr,exports.BK_PAID_TX_FEES=hr,exports.BK_PLUS=mr,exports.BK_PURCHASE=Or,exports.BK_RECEIVED_ESCROW=jr,exports.BK_RECEIVED_ESCROW_REFUND=Mr,exports.BK_RECEIVED_EXPIRED_ESCROW=Nr,exports.BK_RECEIVED_ISSUANCE=Dr,exports.BK_RECEIVED_PAYMENT=kr,exports.BK_RECEIVED_SLASHED_TOKENS=Pr,exports.BK_RECEIVED_VESTING=Ar,exports.BK_REFERENCES=Rr,exports.BK_REF_BLOCK=Fr,exports.BK_REF_MICROBLOCK=Ir,exports.BK_REF_SECTION=Lr,exports.BK_SALE=vr,exports.BK_SENT_ESCROW=xr,exports.BK_SENT_ESCROW_REFUND=Sr,exports.BK_SENT_EXPIRED_ESCROW=Cr,exports.BK_SENT_ISSUANCE=_r,exports.BK_SENT_PAYMENT=yr,exports.BK_SENT_SLASHED_TOKENS=wr,exports.BK_SENT_VESTING=br,exports.BLOCK_CONTENT=ui,exports.BLOCK_INFORMATION=li,exports.BOOLEAN=um,exports.BalanceAvailability=Sk,exports.Base32=wC,exports.Base64=sg,exports.BaseHCVSignatureDecoder=xy,exports.BaseHCVSignatureEncoder=Wv,exports.BasePrivateSignatureKey=zg,exports.BasePublicSignatureKey=Bg,exports.BlockContentAbciResponseSchema=DD,exports.BlockInformationAbciResponseSchema=TD,exports.BlockModifiedAccountsAbciResponseSchema=VD,exports.BlockchainError=b,exports.BlockchainUtils=Y,exports.BytesSignatureEncoder=qS,exports.BytesToBase64Encoder=pg,exports.BytesToHexEncoder=mg,exports.CBORCryptoBinaryEncoder=hx,exports.CENTITOKEN=or,Object.defineProperty(exports,`CHAIN`,{enumerable:!0,get:function(){return Vn}}),exports.CMTSToken=mn,exports.CONTRACT_PARAMETER_SCHEMA=qr,exports.CONTRACT_SCHEMA=Jr,exports.CannotSubscribeError=ce,exports.CarmentisError=o,exports.CarmentisErrorCode=n,exports.ChainInformationAbciResponseSchema=wD,exports.ChannelAlreadyDefinedError=ie,exports.ChannelNotDefinedError=oe,exports.ClientBridgeEncoder=$O,exports.ClientBridgeMessageSchema=QO,exports.ClientBridgeMessageSchema_Answer=qO,exports.ClientBridgeMessageSchema_ConnectionAccepted=YO,exports.ClientBridgeMessageSchema_ConnectionInfo=JO,exports.ClientBridgeMessageSchema_ConnectionToken=WO,exports.ClientBridgeMessageSchema_Error=ZO,exports.ClientBridgeMessageSchema_ForwardedAnswer=GO,exports.ClientBridgeMessageSchema_ForwardedRequest=XO,exports.ClientBridgeMessageSchema_GetConnectionInfo=KO,exports.ClientBridgeMessageSchema_Request=HO,exports.ClientBridgeMessageSchema_UpdateQr=UO,exports.ClientBridgeMessageType=BO,exports.ClientBridgeValidation=ek,exports.CometBFTErrorCode=VC,exports.CometBFTNodeWebSocket=$D,exports.CometBFTPublicKey=KS,exports.CometBFTPublicKeyConverter=JD,exports.ConstraintNameByConstraint=Wx,exports.Crypto=j,exports.CryptoEncoderFactory=gx,exports.CryptoError=d,exports.CryptoSchemeFactory=zv,exports.CryptographicHashSchemeId=nv,exports.CurrencyConverterFactory=RC,exports.CurrentActorNotFoundError=fe,exports.CustomSectionSchema=zm,Object.defineProperty(exports,`DATA`,{enumerable:!0,get:function(){return hn}}),exports.DEF=Ka,exports.DecryptionError=f,Object.defineProperty(exports,`ECO`,{enumerable:!0,get:function(){return rr}}),exports.ERROR=Kr,Object.defineProperty(exports,`ERRORS`,{enumerable:!0,get:function(){return qa}}),exports.Economics=NC,exports.EconomicsError=v,exports.Ed25519PrivateSignatureKey=uC,exports.Ed25519PublicSignatureKey=YS,exports.Ed25519SignatureScheme=JS,exports.EmptyBlockError=u,exports.EncoderFactory=fg,exports.EnvApiKeyPkmsCredentialProvider=py,exports.ErrorAbciResponseSchema=CD,exports.EscrowLockSchema=Kh,exports.EscrowParametersSchema=Gh,exports.Euros=LC,exports.EurosToCMTSConverter=zC,exports.ExpirationDate=UC,exports.ExtendedSymmetricEncryptionKey=Lg,exports.FIXED_GAS_FEE=dr,exports.FORMAT=Bn,exports.FeesCalculationFormulaFactory=bx,exports.FirstFeesFormula=yx,exports.GAS_PER_BYTE=fr,exports.GAS_UNIT=pr,exports.GenericSymmetricKeyEncoder=pC,exports.GenesisSnapshotAbciResponseSchema=zD,exports.GetAccountByPublicKeyHashAbciRequestSchema=mD,exports.GetAccountHistoryAbciRequestSchema=pD,exports.GetAccountStateAbciRequestSchema=fD,exports.GetAccountUpdatesAbciRequestSchema=bD,exports.GetBlockContentAbciRequestSchema=oD,exports.GetBlockInformationAbciRequestSchema=aD,exports.GetBlockModifiedAccountsAbciRequestSchema=yD,exports.GetChainInformationAbciRequestSchema=iD,exports.GetGenesisSnapshotAbciRequestSchema=_D,exports.GetMicroblockBodysAbciRequestSchema=dD,exports.GetMicroblockInformationAbciRequestSchema=lD,exports.GetObjectListAbciRequestSchema=gD,exports.GetRawBlockContentAbciRequestSchema=vD,exports.GetValidatorNodeByAddressAbciRequestSchema=hD,exports.GetVirtualBlockchainStateAbciRequestSchema=sD,exports.GetVirtualBlockchainUpdateAbciRequestSchema=cD,exports.HASHABLE=Pn,exports.HASHED=Rn,exports.HASH_STR=ym,exports.HCVCodec=gg,exports.HCVDecoded=hg,exports.HCVPkeEncoder=Bv,exports.HKDF=_v,exports.HandlerBasedSignatureEncoder=Ey,exports.Hash=Sx,exports.Hashes=$c,exports.INITIAL_OFFER=cr,exports.IllegalParameterError=i,exports.IllegalStateError=a,exports.IllegalUsageError=r,exports.IntermediateRepresentation=gO,exports.InternalError=m,exports.InternalStateFactory=kx,exports.InternalStateUpdaterFactory=Rx,exports.InvalidActorError=re,exports.InvalidChannelError=de,exports.InvalidTokenUnitError=y,exports.JsonSchema=aS,exports.JwkSignatureEncoder=dC,exports.KeyDerivationFunction=hv,exports.KeyExchangeSchemeId=Rg,exports.LOCK_TYPE_COUNT=Uh,exports.LockSchema=Zh,exports.LockType=Wh,exports.Logger=ts,exports.MAGIC_STRING=Hn,exports.MASKABLE=Fn,exports.MASKED=zn,exports.MAXIMUM_GAS_PRICE=ur,exports.MAX_MICROBLOCK_FUTURE_DELAY=$n,exports.MAX_MICROBLOCK_PAST_DELAY=Qn,exports.MB_STATUS_PREVIOUS_HASH_ERROR=nr,exports.MB_STATUS_TIMESTAMP_ERROR=tr,exports.MB_STATUS_UNRECOVERABLE_ERROR=er,exports.MICROBLOCK_BODY=gi,exports.MICROBLOCK_HEADER=mi,exports.MICROBLOCK_HEADER_BODY_HASH_OFFSET=fi,exports.MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET=di,exports.MICROBLOCK_HEADER_SIZE=pi,exports.MICROBLOCK_SECTION=hi,exports.MICROBLOCK_VB_INFORMATION=_i,exports.MILLITOKEN=sr,exports.MINIMUM_GAS_PRICE=lr,exports.MLDSA65HCVSignatureDecoder=wy,exports.MLDSA65HCVSignatureEncoder=qv,exports.MLDSA65PrivateSignatureKey=Ug,exports.MLDSA65PublicSignatureKey=Hg,exports.MLDSA65SignatureScheme=Vg,exports.MLDsa=bd,exports.MLKem=Wd,exports.MSG_ACCOUNT_BY_PUBLIC_KEY_HASH=Bi,exports.MSG_ACCOUNT_HISTORY=Ri,exports.MSG_ACCOUNT_STATE=Ii,exports.MSG_AWAIT_MICROBLOCK_ANCHORING=ji,exports.MSG_BLOCK_CONTENT=wi,exports.MSG_BLOCK_INFORMATION=Si,exports.MSG_CHAIN_INFORMATION=bi,exports.MSG_ERROR=vi,exports.MSG_GENESIS_SNAPSHOT=Ki,exports.MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH=zi,exports.MSG_GET_ACCOUNT_HISTORY=Li,exports.MSG_GET_ACCOUNT_STATE=Fi,exports.MSG_GET_BLOCK_CONTENT=Ci,exports.MSG_GET_BLOCK_INFORMATION=xi,exports.MSG_GET_CHAIN_INFORMATION=yi,exports.MSG_GET_GENESIS_SNAPSHOT=Gi,exports.MSG_GET_MICROBLOCK_BODYS=Ni,exports.MSG_GET_MICROBLOCK_INFORMATION=ki,exports.MSG_GET_OBJECT_LIST=Ui,exports.MSG_GET_VALIDATOR_NODE_BY_ADDRESS=Vi,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_STATE=Ti,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE=Di,exports.MSG_MICROBLOCK_ANCHORING=Mi,exports.MSG_MICROBLOCK_BODYS=Pi,exports.MSG_MICROBLOCK_INFORMATION=Ai,exports.MSG_OBJECT_LIST=Wi,exports.MSG_VALIDATOR_NODE_BY_ADDRESS=Hi,exports.MSG_VIRTUAL_BLOCKCHAIN_STATE=Ei,exports.MSG_VIRTUAL_BLOCKCHAIN_UPDATE=Oi,exports.MaskManager=uO,exports.MemoryProvider=WC,exports.MerkleLeaf=wS,exports.MerkleLeafTypeEnum=Z,exports.MerkleTree=CS,exports.Merklizer=sO,exports.MessageManager=_O,exports.MessageSerializer=AC,exports.MessageUnserializer=jC,exports.MicroBlockNotFoundError=te,exports.MicroBlockNotFoundInBlockError=S,exports.MicroBlockNotFoundInVirtualBlockchainAtHeightError=x,exports.Microblock=Vx,exports.MicroblockAnchoringAbciResponseSchema=jD,exports.MicroblockBodyItemSchema=MD,exports.MicroblockBodySchema=Sh,exports.MicroblockBodysAbciResponseSchema=ND,exports.MicroblockConsistencyChecker=NS,exports.MicroblockHeaderSchema=Nm,exports.MicroblockInformationAbciResponseSchema=AD,exports.MicroblockInformationSchema=Hh,exports.MicroblockStructSchema=Bx,exports.MicroblockStructureCheckingError=s,exports.MlKemCiphertextEncoder=Nv,exports.MlKemPrivateDecryptionKey=Fv,exports.MlKemPublicEncryptionKey=Pv,exports.MlKemPublicKeyEncryptionScheme=Sv,exports.NODE_MESSAGES=qi,exports.NULL=dm,exports.NUMBER=lm,exports.N_VIRTUAL_BLOCKCHAINS=Xn,exports.NativeHCVSignatureDecoder=Sy,exports.NativeHCVSignatureEncoder=Gv,exports.NetworkProvider=GD,exports.NetworksFileSchema=nk,exports.NewBlockEventSchema=QD,exports.NoSharedSecretError=Ee,exports.NodeConnectionRefusedError=g,exports.NodeEndpointClosedWhileCatchingUpError=_,exports.NodeError=h,exports.NodeStakingLockSchema=Xh,exports.NodeStakingParametersSchema=Yh,exports.NotAllowedPkeSchemeError=ue,exports.NotAllowedSignatureSchemeError=le,exports.NotAuthenticatedError=c,exports.NotImplementedError=ee,exports.NullMemoryProvider=KD,exports.NullNetworkProvider=qD,exports.OBJECT=sm,exports.ORG_CREATION=Ea,exports.ORG_DESCRIPTION=Da,exports.ObjectListAbciResponseSchema=RD,exports.OnChainChannelSchema=pS,exports.OnChainItemListSchema=hS,exports.OnChainItemSchema=mS,exports.Optional=MS,exports.OrganizationCreationSectionSchema=ah,exports.OrganizationDescriptionSectionSchema=oh,exports.OrganizationInternalState=Dx,exports.OrganizationInternalStateUpdater=Lx,exports.OrganizationMicroblockStructureChecker=Kx,exports.OrganizationNotFoundError=_e,exports.OrganizationVBInternalStateObjectSchema=Th,exports.OrganizationVb=qx,exports.OrganizationVirtualBlockchainStateSchema=Fh,exports.PBKDF2=lv,exports.PROPERTIES=In,exports.PROTOCOL_CREATION=la,exports.PROTOCOL_UPDATE=ua,exports.PROTOCOL_VARIABLES=oi,exports.PROTOCOL_VB_STATE=si,exports.PROTOCOL_VERSION=Un,exports.ParsingError=l,exports.PasswordBasedKeyDerivationFunction=cv,exports.PathManager=eO,exports.PepperMerklizer=cO,exports.PkeEncoderFactory=fC,exports.PkmsSecp256k1PrivateSignatureKey=hy,exports.PkmsSecp256k1PublicSignatureKey=gy,exports.PkmsSecp256k1SignatureDecoder=Ty,exports.PkmsSecp256k1SignatureEncoder=_y,exports.PriceBreakdownSchema=Im,exports.PriceCategorySchema=Pm,exports.PriceStructureSchema=Fm,exports.ProofDocument=SS,exports.ProofDocumentVB=iS,exports.ProofFieldTypeEnum=gS,exports.ProofVerificationFailedError=se,exports.ProofVerificationResult=BC,exports.ProofWrapperSchema=bS,exports.ProtocolCreationSectionSchema=Hm,exports.ProtocolError=Ce,exports.ProtocolInternalState=Ex,exports.ProtocolInternalStateUpdater=Ix,exports.ProtocolMicroblockStructureChecker=eS,exports.ProtocolUpdateSchema=Rm,exports.ProtocolUpdateSectionSchema=Um,exports.ProtocolVBInternalStateObjectSchema=Ch,exports.ProtocolVariablesSchema=Lm,exports.ProtocolVariablesSectionSchema=Wm,exports.ProtocolVb=tS,exports.ProtocolVirtualBlockchainStateSchema=zh,exports.Provider=YD,exports.ProviderFactory=XD,exports.RADIX_CST=bO,exports.RECORD_DESCRIPTION=ni,exports.REDACTED=Ln,exports.RPCNodeStatusResponseSchema=nD,exports.RadixChecker=wO,exports.RadixUtils=xO,exports.Random=Qs,exports.RawBlockContentAbciResponseSchema=BD,exports.ReadStream=Av,exports.RecordActorAssignationSchema=zS,exports.RecordActorSchema=IS,exports.RecordByChannels=ES,exports.RecordChannelAssignationSchema=RS,exports.RecordChannelSchema=LS,exports.RecordHashableFieldSchema=HS,exports.RecordMaskableFieldSchema=VS,exports.RecordMaskedPartSchema=BS,exports.RequestedAccountUpdateSchema=rg,Object.defineProperty(exports,`SCHEMAS`,{enumerable:!0,get:function(){return Gr}}),Object.defineProperty(exports,`SECTIONS`,{enumerable:!0,get:function(){return oa}}),exports.SIGNATURE=sa,exports.SIGNATURE_SCHEMA=ca,exports.STRING=cm,exports.SaltMerklizer=lO,exports.SaltShaker=DS,exports.SchemaSerializer=jv,exports.SchemaUnserializer=Mv,exports.SchemaValidator=MC,exports.Scrypt=yC,exports.Secp256k1=hp,exports.Secp256k1HCVSignatureDecoder=Cy,exports.Secp256k1HCVSignatureEncoder=Kv,exports.Secp256k1PrivateSignatureKey=Rv,exports.Secp256k1PublicSignatureKey=Lv,exports.Secp256k1SignatureScheme=Iv,exports.SectionConstraint=X,exports.SectionError=pe,exports.SectionLabel=Nx,exports.SectionNotFoundError=Te,exports.SectionSchema=xh,exports.SectionType=O,exports.SeedEncoder=_k,exports.SelfProvidedApiKeyPkmsCredentialProvider=bC,exports.SerializationError=De,exports.ServerNetworkProvider=ZD,exports.Sha256CryptographicHash=rv,exports.SharedKeyDecryptionError=p,exports.SignatureCacheEntry=xC,exports.SignatureSectionSchema=Bm,exports.StoragePriceManager=vx,exports.StructureChecker=Gx,exports.SymmetricEncryptionSchemeId=Pg,exports.TOKEN=ar,exports.TOKEN_NAME=ir,exports.TYPE_ARRAY=_n,exports.TYPE_ARRAY_OF=Mn,exports.TYPE_BIN256=kn,exports.TYPE_BINARY=On,exports.TYPE_BOOLEAN=xn,exports.TYPE_HASH_STR=An,exports.TYPE_MAIN=jn,exports.TYPE_NAMES=Nn,exports.TYPE_NULL=Sn,exports.TYPE_NUMBER=bn,exports.TYPE_OBJECT=vn,exports.TYPE_STRING=yn,exports.TYPE_UINT16=wn,exports.TYPE_UINT24=Tn,exports.TYPE_UINT32=En,exports.TYPE_UINT48=Dn,exports.TYPE_UINT8=Cn,exports.TYPE_UNKNOWN=gn,exports.ThrownErrorMicroblockSearchFailureFallback=Hx,exports.TimestampValidationResult=zx,exports.TokenUnit=fn,exports.TokenUnitLabel=pn,exports.Transaction=DO,exports.TransformationTypeEnum=sS,exports.TypeChecker=io,exports.TypeCheckingFailureError=to,exports.TypeEnum=lS,exports.TypeManager=ro,exports.UINT16=pm,exports.UINT24=mm,exports.UINT32=hm,exports.UINT48=gm,exports.UINT8=fm,exports.Utf8Encoder=Qa,exports.Utils=k,exports.VB_ACCOUNT=Gn,exports.VB_APPLICATION=Jn,exports.VB_APP_LEDGER=Yn,exports.VB_NAME=Zn,exports.VB_ORGANIZATION=qn,exports.VB_PROTOCOL=Wn,exports.VB_STATES=ci,exports.VB_VALIDATOR_NODE=Kn,exports.VIRTUAL_BLOCKCHAIN_STATE=ai,exports.VN_APPROVAL=wa,exports.VN_COMETBFT_PUBLIC_KEY_DECLARATION=Sa,exports.VN_CREATION=xa,exports.VN_RPC_ENDPOINT=Ca,exports.ValidatorNodeApprovalSectionSchema=rh,exports.ValidatorNodeByAddressAbciResponseSchema=LD,exports.ValidatorNodeCometbftPublicKeyDeclarationSectionSchema=th,exports.ValidatorNodeCreationSectionSchema=eh,exports.ValidatorNodeInternalState=Ox,exports.ValidatorNodeInternalStateUpdater=Fx,exports.ValidatorNodeMicroblockStructureChecker=Qx,exports.ValidatorNodeNotFoundError=ye,exports.ValidatorNodeRpcEndpointSectionSchema=nh,exports.ValidatorNodeSlashingCancellationSectionSchema=ih,exports.ValidatorNodeVBInternalStateObjectSchema=Eh,exports.ValidatorNodeVb=$x,exports.ValidatorNodeVirtualBlockchainStateSchema=Ih,exports.VestingLockSchema=Jh,exports.VestingParametersSchema=qh,exports.VirtualBlockchain=Ux,exports.VirtualBlockchainInfoSchema=Vh,exports.VirtualBlockchainLabel=AO,exports.VirtualBlockchainNotFoundError=xe,exports.VirtualBlockchainSharedPropertiesSchema=Nh,exports.VirtualBlockchainStateAbciResponseSchema=OD,exports.VirtualBlockchainStateSchema=Bh,exports.VirtualBlockchainStatusSchema=rk,exports.VirtualBlockchainType=V,exports.VirtualBlockchainUpdateAbciResponseSchema=kD,exports.WIMSG_ANSWER=ea,exports.WIMSG_CONNECTION_ACCEPTED=na,exports.WIMSG_CONNECTION_INFO=ta,exports.WIMSG_CONNECTION_TOKEN=Zi,exports.WIMSG_FORWARDED_ANSWER=Qi,exports.WIMSG_FORWARDED_REQUEST=ra,exports.WIMSG_GET_CONNECTION_INFO=$i,exports.WIMSG_REQUEST=Yi,exports.WIMSG_UPDATE_QR=Xi,exports.WI_INVALID_SIGNATURE=Ja,exports.WI_MAX_SERVER_URL_LENGTH=zO,exports.WI_MESSAGES=ia,exports.WI_QR_CODE=Ji,exports.WalletCrypto=Ok,exports.WalletInteractiveAnchoringEncoder=Ck,exports.WalletInteractiveAnchoringRequestActorKeySchema=sk,exports.WalletInteractiveAnchoringRequestApprovalHandshakeSchema=ok,exports.WalletInteractiveAnchoringRequestApprovalSignatureSchema=ck,exports.WalletInteractiveAnchoringRequestSchema=lk,exports.WalletInteractiveAnchoringRequestType=ik,exports.WalletInteractiveAnchoringResponseActorKeyRequiredSchema=dk,exports.WalletInteractiveAnchoringResponseApprovalDataSchema=fk,exports.WalletInteractiveAnchoringResponseApprovalSignatureSchema=pk,exports.WalletInteractiveAnchoringResponseErrorSchema=uk,exports.WalletInteractiveAnchoringResponseSchema=mk,exports.WalletInteractiveAnchoringResponseType=ak,exports.WalletInteractiveAnchoringValidation=wk,exports.WalletRequestAuthByPublicKeySchema=NO,exports.WalletRequestBasedApplicationLedgerMicroblockBuilder=GS,exports.WalletRequestDataApprovalSchema=PO,exports.WalletRequestEncoder=hk,exports.WalletRequestSchema=FO,exports.WalletRequestType=jO,exports.WalletRequestValidation=gk,exports.WalletResponseAuthByPublicKeySchema=IO,exports.WalletResponseDataApprovalSchema=LO,exports.WalletResponseSchema=RO,exports.WalletResponseType=MO,exports.WalletSeedEncoder=Tk,exports.WiQrCodeEncoder=tk,exports.WiQrCodeSchema=VO,exports.WriteStream=kv,exports.accountId=jm,exports.array=bm,exports.bin256=Am,exports.binary=km,exports.boolean=Sm,exports.height=Mm,exports.number=z,exports.string=xm,exports.uint16=Tm,exports.uint24=Em,exports.uint32=Dm,exports.uint48=Om,exports.uint8=wm,exports.uint8array=B;
|
|
14
14
|
//# sourceMappingURL=carmentis-sdk-core.cjs.map
|