@libp2p/webrtc 6.0.7 → 6.0.8-8cebf6322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +12 -12
- package/dist/index.min.js.map +4 -4
- package/package.json +8 -8
- package/dist/typedoc-urls.json +0 -14
package/dist/index.min.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PWebrtc = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PWebrtc=(()=>{var dS=Object.create;var uf=Object.defineProperty;var yS=Object.getOwnPropertyDescriptor;var mS=Object.getOwnPropertyNames;var gS=Object.getPrototypeOf,bS=Object.prototype.hasOwnProperty;var hh=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ot=(r,e)=>{for(var t in e)uf(r,t,{get:e[t],enumerable:!0})},o0=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of mS(e))!bS.call(r,o)&&o!==t&&uf(r,o,{get:()=>e[o],enumerable:!(n=yS(e,o))||n.enumerable});return r};var Vr=(r,e,t)=>(t=r!=null?dS(gS(r)):{},o0(e||!r||!r.__esModule?uf(t,"default",{value:r,enumerable:!0}):t,r)),wS=r=>o0(uf({},"__esModule",{value:!0}),r);var lx=hh(()=>{var fx;(function(r){(function(e){var t=typeof globalThis=="object"||typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:a(),n=o(r);typeof t.Reflect<"u"&&(n=o(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function o(c,f){return function(p,l){Object.defineProperty(c,p,{configurable:!0,writable:!0,value:l}),f&&f(p,l)}}function i(){try{return Function("return this;")()}catch{}}function s(){try{return(0,eval)("(function() { return this; })()")}catch{}}function a(){return i()||s()}})(function(e,t){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",i=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",c={__proto__:[]}instanceof Array,f=!a&&!c,p={create:a?function(){return ph(Object.create(null))}:c?function(){return ph({__proto__:null})}:function(){return ph({})},has:f?function(w,A){return n.call(w,A)}:function(w,A){return A in w},get:f?function(w,A){return n.call(w,A)?w[A]:void 0}:function(w,A){return w[A]}},l=Object.getPrototypeOf(Function),y=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:uS(),g=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:fS(),m=typeof WeakMap=="function"?WeakMap:lS(),C=o?Symbol.for("@reflect-metadata:registry"):void 0,d=sS(),S=aS(d);function D(w,A,k,F){if(N(k)){if(!ln(w))throw new TypeError;if(!Gn(A))throw new TypeError;return $(w,A)}else{if(!ln(w))throw new TypeError;if(!re(A))throw new TypeError;if(!re(F)&&!N(F)&&!ye(F))throw new TypeError;return ye(F)&&(F=void 0),k=ke(k),O(w,A,k,F)}}e("decorate",D);function B(w,A){function k(F,ce){if(!re(F))throw new TypeError;if(!N(ce)&&!cf(ce))throw new TypeError;L(w,A,F,ce)}return k}e("metadata",B);function H(w,A,k,F){if(!re(k))throw new TypeError;return N(F)||(F=ke(F)),L(w,A,k,F)}e("defineMetadata",H);function J(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),_(w,A,k)}e("hasMetadata",J);function z(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),v(w,A,k)}e("hasOwnMetadata",z);function oe(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),R(w,A,k)}e("getMetadata",oe);function j(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),U(w,A,k)}e("getOwnMetadata",j);function P(w,A){if(!re(w))throw new TypeError;return N(A)||(A=ke(A)),I(w,A)}e("getMetadataKeys",P);function X(w,A){if(!re(w))throw new TypeError;return N(A)||(A=ke(A)),M(w,A)}e("getOwnMetadataKeys",X);function Q(w,A,k){if(!re(A))throw new TypeError;if(N(k)||(k=ke(k)),!re(A))throw new TypeError;N(k)||(k=ke(k));var F=Pa(A,k,!1);return N(F)?!1:F.OrdinaryDeleteMetadata(w,A,k)}e("deleteMetadata",Q);function $(w,A){for(var k=w.length-1;k>=0;--k){var F=w[k],ce=F(A);if(!N(ce)&&!ye(ce)){if(!Gn(ce))throw new TypeError;A=ce}}return A}function O(w,A,k,F){for(var ce=w.length-1;ce>=0;--ce){var tt=w[ce],at=tt(A,k,F);if(!N(at)&&!ye(at)){if(!re(at))throw new TypeError;F=at}}return F}function _(w,A,k){var F=v(w,A,k);if(F)return!0;var ce=lh(A);return ye(ce)?!1:_(w,ce,k)}function v(w,A,k){var F=Pa(A,k,!1);return N(F)?!1:qe(F.OrdinaryHasOwnMetadata(w,A,k))}function R(w,A,k){var F=v(w,A,k);if(F)return U(w,A,k);var ce=lh(A);if(!ye(ce))return R(w,ce,k)}function U(w,A,k){var F=Pa(A,k,!1);if(!N(F))return F.OrdinaryGetOwnMetadata(w,A,k)}function L(w,A,k,F){var ce=Pa(k,F,!0);ce.OrdinaryDefineOwnMetadata(w,A,k,F)}function I(w,A){var k=M(w,A),F=lh(w);if(F===null)return k;var ce=I(F,A);if(ce.length<=0)return k;if(k.length<=0)return ce;for(var tt=new g,at=[],ve=0,Z=k;ve<Z.length;ve++){var ee=Z[ve],ne=tt.has(ee);ne||(tt.add(ee),at.push(ee))}for(var ie=0,Se=ce;ie<Se.length;ie++){var ee=Se[ie],ne=tt.has(ee);ne||(tt.add(ee),at.push(ee))}return at}function M(w,A){var k=Pa(w,A,!1);return k?k.OrdinaryOwnMetadataKeys(w,A):[]}function q(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}function N(w){return w===void 0}function ye(w){return w===null}function xe(w){return typeof w=="symbol"}function re(w){return typeof w=="object"?w!==null:typeof w=="function"}function Ae(w,A){switch(q(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var k=A===3?"string":A===5?"number":"default",F=Ia(w,i);if(F!==void 0){var ce=F.call(w,k);if(re(ce))throw new TypeError;return ce}return Ne(w,k==="default"?"number":k)}function Ne(w,A){if(A==="string"){var k=w.toString;if(wr(k)){var F=k.call(w);if(!re(F))return F}var ce=w.valueOf;if(wr(ce)){var F=ce.call(w);if(!re(F))return F}}else{var ce=w.valueOf;if(wr(ce)){var F=ce.call(w);if(!re(F))return F}var tt=w.toString;if(wr(tt)){var F=tt.call(w);if(!re(F))return F}}throw new TypeError}function qe(w){return!!w}function Ce(w){return""+w}function ke(w){var A=Ae(w,3);return xe(A)?A:Ce(A)}function ln(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}function wr(w){return typeof w=="function"}function Gn(w){return typeof w=="function"}function cf(w){switch(q(w)){case 3:return!0;case 4:return!0;default:return!1}}function rs(w,A){return w===A||w!==w&&A!==A}function Ia(w,A){var k=w[A];if(k!=null){if(!wr(k))throw new TypeError;return k}}function Qg(w){var A=Ia(w,s);if(!wr(A))throw new TypeError;var k=A.call(w);if(!re(k))throw new TypeError;return k}function e0(w){return w.value}function t0(w){var A=w.next();return A.done?!1:A}function r0(w){var A=w.return;A&&A.call(w)}function lh(w){var A=Object.getPrototypeOf(w);if(typeof w!="function"||w===l||A!==l)return A;var k=w.prototype,F=k&&Object.getPrototypeOf(k);if(F==null||F===Object.prototype)return A;var ce=F.constructor;return typeof ce!="function"||ce===w?A:ce}function iS(){var w;!N(C)&&typeof t.Reflect<"u"&&!(C in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(w=cS(t.Reflect));var A,k,F,ce=new m,tt={registerProvider:at,getProvider:Z,setProvider:ne};return tt;function at(ie){if(!Object.isExtensible(tt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case w===ie:break;case N(A):A=ie;break;case A===ie:break;case N(k):k=ie;break;case k===ie:break;default:F===void 0&&(F=new g),F.add(ie);break}}function ve(ie,Se){if(!N(A)){if(A.isProviderFor(ie,Se))return A;if(!N(k)){if(k.isProviderFor(ie,Se))return A;if(!N(F))for(var He=Qg(F);;){var rt=t0(He);if(!rt)return;var xr=e0(rt);if(xr.isProviderFor(ie,Se))return r0(He),xr}}}if(!N(w)&&w.isProviderFor(ie,Se))return w}function Z(ie,Se){var He=ce.get(ie),rt;return N(He)||(rt=He.get(Se)),N(rt)&&(rt=ve(ie,Se),N(rt)||(N(He)&&(He=new y,ce.set(ie,He)),He.set(Se,rt))),rt}function ee(ie){if(N(ie))throw new TypeError;return A===ie||k===ie||!N(F)&&F.has(ie)}function ne(ie,Se,He){if(!ee(He))throw new Error("Metadata provider not registered.");var rt=Z(ie,Se);if(rt!==He){if(!N(rt))return!1;var xr=ce.get(ie);N(xr)&&(xr=new y,ce.set(ie,xr)),xr.set(Se,He)}return!0}}function sS(){var w;return!N(C)&&re(t.Reflect)&&Object.isExtensible(t.Reflect)&&(w=t.Reflect[C]),N(w)&&(w=iS()),!N(C)&&re(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,C,{enumerable:!1,configurable:!1,writable:!1,value:w}),w}function aS(w){var A=new m,k={isProviderFor:function(ee,ne){var ie=A.get(ee);return N(ie)?!1:ie.has(ne)},OrdinaryDefineOwnMetadata:at,OrdinaryHasOwnMetadata:ce,OrdinaryGetOwnMetadata:tt,OrdinaryOwnMetadataKeys:ve,OrdinaryDeleteMetadata:Z};return d.registerProvider(k),k;function F(ee,ne,ie){var Se=A.get(ee),He=!1;if(N(Se)){if(!ie)return;Se=new y,A.set(ee,Se),He=!0}var rt=Se.get(ne);if(N(rt)){if(!ie)return;if(rt=new y,Se.set(ne,rt),!w.setProvider(ee,ne,k))throw Se.delete(ne),He&&A.delete(ee),new Error("Wrong provider for target.")}return rt}function ce(ee,ne,ie){var Se=F(ne,ie,!1);return N(Se)?!1:qe(Se.has(ee))}function tt(ee,ne,ie){var Se=F(ne,ie,!1);if(!N(Se))return Se.get(ee)}function at(ee,ne,ie,Se){var He=F(ie,Se,!0);He.set(ee,ne)}function ve(ee,ne){var ie=[],Se=F(ee,ne,!1);if(N(Se))return ie;for(var He=Se.keys(),rt=Qg(He),xr=0;;){var n0=t0(rt);if(!n0)return ie.length=xr,ie;var pS=e0(n0);try{ie[xr]=pS}catch(hS){try{r0(rt)}finally{throw hS}}xr++}}function Z(ee,ne,ie){var Se=F(ne,ie,!1);if(N(Se)||!Se.delete(ee))return!1;if(Se.size===0){var He=A.get(ne);N(He)||(He.delete(ie),He.size===0&&A.delete(He))}return!0}}function cS(w){var A=w.defineMetadata,k=w.hasOwnMetadata,F=w.getOwnMetadata,ce=w.getOwnMetadataKeys,tt=w.deleteMetadata,at=new m,ve={isProviderFor:function(Z,ee){var ne=at.get(Z);return!N(ne)&&ne.has(ee)?!0:ce(Z,ee).length?(N(ne)&&(ne=new g,at.set(Z,ne)),ne.add(ee),!0):!1},OrdinaryDefineOwnMetadata:A,OrdinaryHasOwnMetadata:k,OrdinaryGetOwnMetadata:F,OrdinaryOwnMetadataKeys:ce,OrdinaryDeleteMetadata:tt};return ve}function Pa(w,A,k){var F=d.getProvider(w,A);if(!N(F))return F;if(k){if(d.setProvider(w,A,S))return S;throw new Error("Illegal state.")}}function uS(){var w={},A=[],k=(function(){function ve(Z,ee,ne){this._index=0,this._keys=Z,this._values=ee,this._selector=ne}return ve.prototype["@@iterator"]=function(){return this},ve.prototype[s]=function(){return this},ve.prototype.next=function(){var Z=this._index;if(Z>=0&&Z<this._keys.length){var ee=this._selector(this._keys[Z],this._values[Z]);return Z+1>=this._keys.length?(this._index=-1,this._keys=A,this._values=A):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},ve.prototype.throw=function(Z){throw this._index>=0&&(this._index=-1,this._keys=A,this._values=A),Z},ve.prototype.return=function(Z){return this._index>=0&&(this._index=-1,this._keys=A,this._values=A),{value:Z,done:!0}},ve})(),F=(function(){function ve(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return Object.defineProperty(ve.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ve.prototype.has=function(Z){return this._find(Z,!1)>=0},ve.prototype.get=function(Z){var ee=this._find(Z,!1);return ee>=0?this._values[ee]:void 0},ve.prototype.set=function(Z,ee){var ne=this._find(Z,!0);return this._values[ne]=ee,this},ve.prototype.delete=function(Z){var ee=this._find(Z,!1);if(ee>=0){for(var ne=this._keys.length,ie=ee+1;ie<ne;ie++)this._keys[ie-1]=this._keys[ie],this._values[ie-1]=this._values[ie];return this._keys.length--,this._values.length--,rs(Z,this._cacheKey)&&(this._cacheKey=w,this._cacheIndex=-2),!0}return!1},ve.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},ve.prototype.keys=function(){return new k(this._keys,this._values,ce)},ve.prototype.values=function(){return new k(this._keys,this._values,tt)},ve.prototype.entries=function(){return new k(this._keys,this._values,at)},ve.prototype["@@iterator"]=function(){return this.entries()},ve.prototype[s]=function(){return this.entries()},ve.prototype._find=function(Z,ee){if(!rs(this._cacheKey,Z)){this._cacheIndex=-1;for(var ne=0;ne<this._keys.length;ne++)if(rs(this._keys[ne],Z)){this._cacheIndex=ne;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(Z),this._values.push(void 0)),this._cacheIndex},ve})();return F;function ce(ve,Z){return ve}function tt(ve,Z){return Z}function at(ve,Z){return[ve,Z]}}function fS(){var w=(function(){function A(){this._map=new y}return Object.defineProperty(A.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),A.prototype.has=function(k){return this._map.has(k)},A.prototype.add=function(k){return this._map.set(k,k),this},A.prototype.delete=function(k){return this._map.delete(k)},A.prototype.clear=function(){this._map.clear()},A.prototype.keys=function(){return this._map.keys()},A.prototype.values=function(){return this._map.keys()},A.prototype.entries=function(){return this._map.entries()},A.prototype["@@iterator"]=function(){return this.keys()},A.prototype[s]=function(){return this.keys()},A})();return w}function lS(){var w=16,A=p.create(),k=F();return(function(){function Z(){this._key=F()}return Z.prototype.has=function(ee){var ne=ce(ee,!1);return ne!==void 0?p.has(ne,this._key):!1},Z.prototype.get=function(ee){var ne=ce(ee,!1);return ne!==void 0?p.get(ne,this._key):void 0},Z.prototype.set=function(ee,ne){var ie=ce(ee,!0);return ie[this._key]=ne,this},Z.prototype.delete=function(ee){var ne=ce(ee,!1);return ne!==void 0?delete ne[this._key]:!1},Z.prototype.clear=function(){this._key=F()},Z})();function F(){var Z;do Z="@@WeakMap@@"+ve();while(p.has(A,Z));return A[Z]=!0,Z}function ce(Z,ee){if(!n.call(Z,k)){if(!ee)return;Object.defineProperty(Z,k,{value:p.create()})}return Z[k]}function tt(Z,ee){for(var ne=0;ne<ee;++ne)Z[ne]=Math.random()*255|0;return Z}function at(Z){if(typeof Uint8Array=="function"){var ee=new Uint8Array(Z);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):tt(ee,Z),ee}return tt(new Array(Z),Z)}function ve(){var Z=at(w);Z[6]=Z[6]&79|64,Z[8]=Z[8]&191|128;for(var ee="",ne=0;ne<w;++ne){var ie=Z[ne];(ne===4||ne===6||ne===8)&&(ee+="-"),ie<16&&(ee+="0"),ee+=ie.toString(16).toLowerCase()}return ee}}function ph(w){return w.__=void 0,delete w.__,w}})})(fx||(fx={}))});var An=hh(js=>{"use strict";var aC="[object ArrayBuffer]",Sn=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===aC}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Ry="string",cC=/^[0-9a-f\s]+$/i,uC=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,fC=/^[a-zA-Z0-9-_]+$/,kl=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Sn.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},fr=class{static toString(e,t=!1){let n=Sn.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},Dl=class r{static isHex(e){return typeof e===Ry&&cC.test(e)}static isBase64(e){return typeof e===Ry&&uC.test(e)}static isBase64Url(e){return typeof e===Ry&&fC.test(e)}static ToString(e,t="utf8"){let n=Sn.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return fr.toString(n,!0);case"utf16":case"utf16be":return fr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return fr.fromString(e,!0);case"utf16":case"utf16be":return fr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Sn.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return kl.fromString(e);case"utf16":case"utf16be":return fr.fromString(e);case"utf16le":case"usc2":return fr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return kl.toString(e);case"utf16":case"utf16be":return fr.toString(e);case"utf16le":case"usc2":return fr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Sn.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Sn.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return fr.toString(e,t)}static FromUtf16String(e,t=!1){return fr.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Dl.DEFAULT_UTF8_ENCODING="utf8";function lC(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function pC(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function hC(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}js.BufferSourceConverter=Sn;js.Convert=Dl;js.assign=lC;js.combine=pC;js.isEqual=hC});var i1=hh((Y$,Op)=>{var Mv,Kv,Hv,Vv,$v,Fv,Wv,qv,Gv,Tp,$m,zv,Xv,la,Zv,Yv,Jv,Qv,e1,t1,r1,n1,o1;(function(r){var e=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){r(t(e,t(n)))}):typeof Op=="object"&&typeof Op.exports=="object"?r(t(e,t(Op.exports))):r(t(e));function t(n,o){return n!==e&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,s){return n[i]=o?o(i,s):s}}})(function(r){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])};Mv=function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)},Kv=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Hv=function(t,n){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)n.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(o[i[s]]=t[i[s]]);return o},Vv=function(t,n,o,i){var s=arguments.length,a=s<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,o):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,n,o,i);else for(var f=t.length-1;f>=0;f--)(c=t[f])&&(a=(s<3?c(a):s>3?c(n,o,a):c(n,o))||a);return s>3&&a&&Object.defineProperty(n,o,a),a},$v=function(t,n){return function(o,i){n(o,i,t)}},Fv=function(t,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,n)},Wv=function(t,n,o,i){function s(a){return a instanceof o?a:new o(function(c){c(a)})}return new(o||(o=Promise))(function(a,c){function f(y){try{l(i.next(y))}catch(g){c(g)}}function p(y){try{l(i.throw(y))}catch(g){c(g)}}function l(y){y.done?a(y.value):s(y.value).then(f,p)}l((i=i.apply(t,n||[])).next())})},qv=function(t,n){var o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,c;return c={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(l){return function(y){return p([l,y])}}function p(l){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=l[0]&2?s.return:l[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,l[1])).done)return a;switch(s=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,s=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){o=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(l[0]===6&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(t,o)}catch(y){l=[6,y],s=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},o1=function(t,n,o,i){i===void 0&&(i=o),t[i]=n[o]},Gv=function(t,n){for(var o in t)o!=="default"&&!n.hasOwnProperty(o)&&(n[o]=t[o])},Tp=function(t){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&t[n],i=0;if(o)return o.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},$m=function(t,n){var o=typeof Symbol=="function"&&t[Symbol.iterator];if(!o)return t;var i=o.call(t),s,a=[],c;try{for(;(n===void 0||n-- >0)&&!(s=i.next()).done;)a.push(s.value)}catch(f){c={error:f}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(c)throw c.error}}return a},zv=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat($m(arguments[n]));return t},Xv=function(){for(var t=0,n=0,o=arguments.length;n<o;n++)t+=arguments[n].length;for(var i=Array(t),s=0,n=0;n<o;n++)for(var a=arguments[n],c=0,f=a.length;c<f;c++,s++)i[s]=a[c];return i},la=function(t){return this instanceof la?(this.v=t,this):new la(t)},Zv=function(t,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=o.apply(t,n||[]),s,a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(m){i[m]&&(s[m]=function(C){return new Promise(function(d,S){a.push([m,C,d,S])>1||f(m,C)})})}function f(m,C){try{p(i[m](C))}catch(d){g(a[0][3],d)}}function p(m){m.value instanceof la?Promise.resolve(m.value.v).then(l,y):g(a[0][2],m)}function l(m){f("next",m)}function y(m){f("throw",m)}function g(m,C){m(C),a.shift(),a.length&&f(a[0][0],a[0][1])}},Yv=function(t){var n,o;return n={},i("next"),i("throw",function(s){throw s}),i("return"),n[Symbol.iterator]=function(){return this},n;function i(s,a){n[s]=t[s]?function(c){return(o=!o)?{value:la(t[s](c)),done:s==="return"}:a?a(c):c}:a}},Jv=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],o;return n?n.call(t):(t=typeof Tp=="function"?Tp(t):t[Symbol.iterator](),o={},i("next"),i("throw"),i("return"),o[Symbol.asyncIterator]=function(){return this},o);function i(a){o[a]=t[a]&&function(c){return new Promise(function(f,p){c=t[a](c),s(f,p,c.done,c.value)})}}function s(a,c,f,p){Promise.resolve(p).then(function(l){a({value:l,done:f})},c)}},Qv=function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t},e1=function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var o in t)Object.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n.default=t,n},t1=function(t){return t&&t.__esModule?t:{default:t}},r1=function(t,n){if(!n.has(t))throw new TypeError("attempted to get private field on non-instance");return n.get(t)},n1=function(t,n,o){if(!n.has(t))throw new TypeError("attempted to set private field on non-instance");return n.set(t,o),o},r("__extends",Mv),r("__assign",Kv),r("__rest",Hv),r("__decorate",Vv),r("__param",$v),r("__metadata",Fv),r("__awaiter",Wv),r("__generator",qv),r("__exportStar",Gv),r("__createBinding",o1),r("__values",Tp),r("__read",$m),r("__spread",zv),r("__spreadArrays",Xv),r("__await",la),r("__asyncGenerator",Zv),r("__asyncDelegator",Yv),r("__asyncValues",Jv),r("__makeTemplateObject",Qv),r("__importStar",e1),r("__importDefault",t1),r("__classPrivateFieldGet",r1),r("__classPrivateFieldSet",n1)})});var SO={};Ot(SO,{webRTC:()=>_O,webRTCDirect:()=>vO});var ff=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},lf=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},_e=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ns=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},Na=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}};var pf=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}},hf=class extends Error{static name="MuxerClosedError";constructor(e="The muxer is closed"){super(e),this.name="MuxerClosedError"}},os=class extends Error{static name="StreamResetError";constructor(e="The stream has been reset"){super(e),this.name="StreamResetError"}};var $r=class extends Error{static name="StreamStateError";constructor(e="The stream is in an invalid state"){super(e),this.name="StreamStateError"}},ka=class extends Error{static name="StreamBufferError";constructor(e="The stream buffer was full"){super(e),this.name="StreamBufferError"}},Uo=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var df=class extends Error{static name="InvalidMultiaddrError";constructor(e="Invalid multiaddr"){super(e),this.name="InvalidMultiaddrError"}},yf=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},mf=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var gf=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var bf=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}};var zn=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var wf=class extends Event{data;constructor(e,t){super("message",t),this.data=e}},is=class extends Event{error;local;constructor(e,t,n){super("close",n),this.error=t,this.local=e}},xf=class extends is{constructor(e,t){super(!0,e,t)}},vf=class extends is{constructor(e,t){super(!1,e,t)}};var dh=Symbol.for("@libp2p/peer-id");var _f=Symbol.for("@libp2p/transport");var i0;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(i0||(i0={}));var sr=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var ss=Symbol.for("@libp2p/service-capabilities"),s0=Symbol.for("@libp2p/service-dependencies");var wh={};Ot(wh,{base58btc:()=>Ze,base58flickr:()=>CS});var tB=new Uint8Array(0);function a0(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function pn(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function c0(r){return new TextEncoder().encode(r)}function u0(r){return new TextDecoder().decode(r)}function xS(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function l(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var C=0,d=0,S=0,D=m.length;S!==D&&m[S]===0;)S++,C++;for(var B=(D-S)*p+1>>>0,H=new Uint8Array(B);S!==D;){for(var J=m[S],z=0,oe=B-1;(J!==0||z<d)&&oe!==-1;oe--,z++)J+=256*H[oe]>>>0,H[oe]=J%a>>>0,J=J/a>>>0;if(J!==0)throw new Error("Non-zero carry");d=z,S++}for(var j=B-d;j!==B&&H[j]===0;)j++;for(var P=c.repeat(C);j<B;++j)P+=r.charAt(H[j]);return P}function y(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var C=0;if(m[C]!==" "){for(var d=0,S=0;m[C]===c;)d++,C++;for(var D=(m.length-C)*f+1>>>0,B=new Uint8Array(D);m[C];){var H=t[m.charCodeAt(C)];if(H===255)return;for(var J=0,z=D-1;(H!==0||J<S)&&z!==-1;z--,J++)H+=a*B[z]>>>0,B[z]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");S=J,C++}if(m[C]!==" "){for(var oe=D-S;oe!==D&&B[oe]===0;)oe++;for(var j=new Uint8Array(d+(D-oe)),P=d;oe!==D;)j[P++]=B[oe++];return j}}}function g(m){var C=y(m);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:y,decode:g}}var vS=xS,_S=vS,l0=_S;var yh=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mh=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return p0(this,e)}},gh=class{decoders;constructor(e){this.decoders=e}or(e){return p0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function p0(r,e){return new gh({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var bh=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new yh(e,t,n),this.decoder=new mh(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function as({name:r,prefix:e,encode:t,decode:n}){return new bh(r,e,t,n)}function Xn({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=l0(t,r);return as({prefix:e,name:r,encode:n,decode:i=>pn(o(i))})}function SS(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let f=0;f<o;++f){let p=e[r[f]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|p,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function AS(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function ES(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function Xe({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=ES(n);return as({prefix:e,name:r,encode(i){return AS(i,n,t)},decode(i){return SS(i,o,t,r)}})}var Ze=Xn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),CS=Xn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xh={};Ot(xh,{base32:()=>Zn,base32hex:()=>IS,base32hexpad:()=>NS,base32hexpadupper:()=>kS,base32hexupper:()=>PS,base32pad:()=>OS,base32padupper:()=>BS,base32upper:()=>TS,base32z:()=>DS});var Zn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),TS=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),OS=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),BS=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),IS=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),PS=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),NS=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),kS=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),DS=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vh={};Ot(vh,{base36:()=>Da,base36upper:()=>RS});var Da=Xn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),RS=Xn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var vr={};Ot(vr,{Digest:()=>Mo,create:()=>Dt,decode:()=>fs,equals:()=>Sh,hasCode:()=>eA});var jS=y0,h0=128,LS=127,US=~LS,MS=Math.pow(2,31);function y0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=MS;)e[t++]=r&255|h0,r/=128;for(;r&US;)e[t++]=r&255|h0,r>>>=7;return e[t]=r|0,y0.bytes=t-n+1,e}var KS=_h,HS=128,d0=127;function _h(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw _h.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&d0)<<o:(s&d0)*Math.pow(2,o),o+=7}while(s>=HS);return _h.bytes=i-n,t}var VS=Math.pow(2,7),$S=Math.pow(2,14),FS=Math.pow(2,21),WS=Math.pow(2,28),qS=Math.pow(2,35),GS=Math.pow(2,42),zS=Math.pow(2,49),XS=Math.pow(2,56),ZS=Math.pow(2,63),YS=function(r){return r<VS?1:r<$S?2:r<FS?3:r<WS?4:r<qS?5:r<GS?6:r<zS?7:r<XS?8:r<ZS?9:10},JS={encode:jS,decode:KS,encodingLength:YS},QS=JS,Ra=QS;function ja(r,e=0){return[Ra.decode(r,e),Ra.decode.bytes]}function cs(r,e,t=0){return Ra.encode(r,e,t),e}function us(r){return Ra.encodingLength(r)}function Dt(r,e){let t=e.byteLength,n=us(r),o=n+us(t),i=new Uint8Array(o+t);return cs(r,i,0),cs(t,i,n),i.set(e,o),new Mo(r,t,e,i)}function fs(r){let e=pn(r),[t,n]=ja(e),[o,i]=ja(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Mo(t,o,s,e)}function Sh(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&a0(r.bytes,t.bytes)}}var Mo=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function eA(r,e){return r.code===e}function m0(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return rA(t,Ah(r),e??Ze.encoder);default:return nA(t,Ah(r),e??Zn.encoder)}}var g0=new WeakMap;function Ah(r){let e=g0.get(r);if(e==null){let t=new Map;return g0.set(r,t),t}return e}var ct=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==La)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==oA)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Dt(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Sh(e.multihash,n.multihash)}toString(e){return m0(this,e)}toJSON(){return{"/":m0(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??b0(n,o,i.bytes))}else if(t[iA]===!0){let{version:n,multihash:o,code:i}=t,s=fs(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==La)throw new Error(`Version 0 CID must use dag-pb (code: ${La}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=b0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,La,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=pn(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Mo(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,y]=ja(e.subarray(t));return t+=y,l},o=n(),i=La;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,p=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:p,size:f}}static parse(e,t){let[n,o]=tA(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ah(i).set(n,e),i}};function tA(r,e){switch(r[0]){case"Q":{let t=e??Ze;return[Ze.prefix,t.decode(`${Ze.prefix}${r}`)]}case Ze.prefix:{let t=e??Ze;return[Ze.prefix,t.decode(r)]}case Zn.prefix:{let t=e??Zn;return[Zn.prefix,t.decode(r)]}case Da.prefix:{let t=e??Da;return[Da.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function rA(r,e,t){let{prefix:n}=t;if(n!==Ze.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function nA(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var La=112,oA=18;function b0(r,e,t){let n=us(r),o=n+us(e),i=new Uint8Array(o+t.byteLength);return cs(r,i,0),cs(e,i,n),i.set(t,o),i}var iA=Symbol.for("@ipld/js-cid/CID");var Eh={};Ot(Eh,{identity:()=>_r});var w0=0,sA="identity",x0=pn;function aA(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return Dt(w0,x0(r))}var _r={code:w0,name:sA,encode:x0,digest:aA};function Ye(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ut(r=0){return new Uint8Array(r)}function ft(r=0){return new Uint8Array(r)}function Rt(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=ft(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var _0=Symbol.for("@achingbrain/uint8arraylist");function v0(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Af(r){return!!r?.[_0]}var ge=class r{bufs;length;[_0]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Af(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Af(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=v0(this.bufs,e);return t.buf[t.index]}set(e,t){let n=v0(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Af(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Rt(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Rt(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let f=e>=a&&e<c,p=t>a&&t<=c;if(f&&p){if(e===a&&t===c){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(t-e)));break}if(f){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(p){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Af(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,p;for(let l=t;l<=c;l+=p){p=0;for(let y=f;y>=0;y--){let g=this.get(l+y);if(n[y]!==g){p=Math.max(1,y-a[g]);break}}if(p===0)return l}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=ft(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=ut(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=ft(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=ut(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Ye(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};var Ch={};Ot(Ch,{base10:()=>uA});var uA=Xn({prefix:"9",name:"base10",alphabet:"0123456789"});var Th={};Ot(Th,{base16:()=>fA,base16upper:()=>lA});var fA=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lA=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Oh={};Ot(Oh,{base2:()=>pA});var pA=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bh={};Ot(Bh,{base256emoji:()=>gA});var S0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),hA=S0.reduce((r,e,t)=>(r[t]=e,r),[]),dA=S0.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function yA(r){return r.reduce((e,t)=>(e+=hA[t],e),"")}function mA(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=dA[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var gA=as({prefix:"\u{1F680}",name:"base256emoji",encode:yA,decode:mA});var Ih={};Ot(Ih,{base64:()=>bA,base64pad:()=>wA,base64url:()=>Ko,base64urlpad:()=>xA});var bA=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wA=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ko=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xA=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ph={};Ot(Ph,{base8:()=>vA});var vA=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nh={};Ot(Nh,{identity:()=>_A});var _A=as({prefix:"\0",name:"identity",encode:r=>u0(r),decode:r=>c0(r)});var LB=new TextEncoder,UB=new TextDecoder;var Rh={};Ot(Rh,{sha256:()=>ar,sha512:()=>CA});var EA=20;function Dh({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new kh(r,e,t,n,o)}var kh=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??EA,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?A0(n,this.code,t?.truncate):n.then(o=>A0(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function A0(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return Dt(e,r)}function C0(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ar=Dh({name:"sha2-256",code:18,encode:C0("SHA-256")}),CA=Dh({name:"sha2-512",code:19,encode:C0("SHA-512")});var Ho={...Nh,...Oh,...Ph,...Ch,...Th,...xh,...vh,...wh,...Ih,...Bh},ZB={...Rh,...Eh};function O0(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var T0=O0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),jh=O0("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ft(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),TA={utf8:T0,"utf-8":T0,hex:Ho.base16,latin1:jh,ascii:jh,binary:jh,...Ho},Ef=TA;function me(r,e="utf8"){let t=Ef[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function le(r,e="utf8"){let t=Ef[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var OA=parseInt("11111",2),Lh=parseInt("10000000",2),BA=parseInt("01111111",2),B0={0:Ua,1:Ua,2:IA,3:kA,4:DA,5:NA,6:PA,16:Ua,22:Ua,48:Ua};function hn(r,e={offset:0}){let t=r[e.offset]&OA;if(e.offset++,B0[t]!=null)return B0[t](r,e);throw new Error("No decoder for tag "+t)}function Ma(r,e){let t=0;if((r[e.offset]&Lh)===Lh){let n=r[e.offset]&BA,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(o,16)}else t=r[e.offset],e.offset++;return t}function Ua(r,e){Ma(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=hn(r,e);if(n===null)break;t.push(n)}return t}function IA(r,e){let t=Ma(r,e),n=e.offset,o=e.offset+t,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return e.offset+=t,Uint8Array.from(i)}function PA(r,e){let t=Ma(r,e),n=e.offset+t,o=r[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let f=r[e.offset];if(e.offset++,c.push(f&127),f<128){c.reverse();let p=0;for(let l=0;l<c.length;l++)p+=c[l]<<l*7;a+=`.${p}`,c=[]}}return a}function NA(r,e){return e.offset++,null}function kA(r,e){let t=Ma(r,e),n=r[e.offset];e.offset++;let o=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function DA(r,e){let t=Ma(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function RA(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new ge;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function Cf(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=RA(r.byteLength);return new ge(Uint8Array.from([e.byteLength|Lh]),e)}function jt(r){let e=new ge,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new ge(Uint8Array.from([2]),Cf(e),e)}function Ka(r){let e=Uint8Array.from([0]),t=new ge(e,r);return new ge(Uint8Array.from([3]),Cf(t),t)}function I0(r){return new ge(Uint8Array.from([4]),Cf(r),r)}function Sr(r,e=48){let t=new ge;for(let n of r)t.append(n);return new ge(Uint8Array.from([e]),Cf(t),t)}async function P0(r="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:r},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function N0(r,e,t){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["sign"]);t?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function k0(r,e,t,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,t.subarray());return n?.signal?.throwIfAborted(),i}var jA=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),LA=Uint8Array.from([6,5,43,129,4,0,34]),UA=Uint8Array.from([6,5,43,129,4,0,35]),MA={ext:!0,kty:"EC",crv:"P-256"},KA={ext:!0,kty:"EC",crv:"P-384"},HA={ext:!0,kty:"EC",crv:"P-521"},Uh=32,Mh=48,Kh=66;function Hh(r){let e=hn(r);return D0(e)}function D0(r){let e=r[1][1][0],t=1,n,o;if(e.byteLength===Uh*2+1)return n=le(e.subarray(t,t+Uh),"base64url"),o=le(e.subarray(t+Uh),"base64url"),new Vo({...MA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Mh*2+1)return n=le(e.subarray(t,t+Mh),"base64url"),o=le(e.subarray(t+Mh),"base64url"),new Vo({...KA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Kh*2+1)return n=le(e.subarray(t,t+Kh),"base64url"),o=le(e.subarray(t+Kh),"base64url"),new Vo({...HA,key_ops:["verify"],x:n,y:o});throw new _e(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function R0(r){return Sr([jt(Uint8Array.from([1])),I0(me(r.d??"","base64url")),Sr([L0(r.crv)],160),Sr([Ka(new ge(Uint8Array.from([4]),me(r.x??"","base64url"),me(r.y??"","base64url")))],161)]).subarray()}function j0(r){return Sr([jt(Uint8Array.from([1])),Sr([L0(r.crv)],160),Sr([Ka(new ge(Uint8Array.from([4]),me(r.x??"","base64url"),me(r.y??"","base64url")))],161)]).subarray()}function L0(r){if(r==="P-256")return jA;if(r==="P-384")return LA;if(r==="P-521")return UA;throw new _e(`Invalid curve ${r}`)}async function U0(r="P-256"){let e=await P0(r);return new Tf(e.privateKey)}var Vo=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=j0(this.jwk)),this._raw}toMultihash(){return _r.digest(Yn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ze.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}async verify(e,t,n){return k0(this.jwk,t,e,n)}},Tf=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new Vo({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=R0(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}async sign(e,t){return N0(this.jwk,e,t)}};function $o(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function cr(r,e=""){if(!Number.isSafeInteger(r)||r<0){let t=e&&`"${e}" `;throw new Error(`${t}expected integer >= 0, got ${r}`)}}function he(r,e,t=""){let n=$o(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function Fo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash must wrapped by utils.createHasher");cr(r.outputLen),cr(r.blockLen)}function ls(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function K0(r,e){he(r,void 0,"digestInto() output");let t=e.outputLen;if(r.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function Ar(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function Of(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Er(r,e){return r<<32-e|r>>>e}var H0=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",VA=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function yn(r){if(he(r),H0)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=VA[r[t]];return e}var dn={_0:48,_9:57,A:65,F:70,a:97,f:102};function M0(r){if(r>=dn._0&&r<=dn._9)return r-dn._0;if(r>=dn.A&&r<=dn.F)return r-(dn.A-10);if(r>=dn.a&&r<=dn.f)return r-(dn.a-10)}function mn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(H0)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=M0(r.charCodeAt(i)),a=M0(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Vt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];he(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function Vh(r,e={}){let t=(o,i)=>r(i).update(o).digest(),n=r(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=o=>r(o),Object.assign(t,e),Object.freeze(t)}function Jn(r=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(r))}var $h=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function V0(r,e,t){return r&e^~r&t}function $0(r,e,t){return r&e^r&t^e&t}var Ha=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,o){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Of(this.buffer)}update(e){ls(this),he(e);let{view:t,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Of(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ls(this),K0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,Ar(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)t[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=Of(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=c/4,p=this.get();if(f>p.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,p[l],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:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},gn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var gt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Bf=BigInt(4294967295),F0=BigInt(32);function $A(r,e=!1){return e?{h:Number(r&Bf),l:Number(r>>F0&Bf)}:{h:Number(r>>F0&Bf)|0,l:Number(r&Bf)|0}}function W0(r,e=!1){let t=r.length,n=new Uint32Array(t),o=new Uint32Array(t);for(let i=0;i<t;i++){let{h:s,l:a}=$A(r[i],e);[n[i],o[i]]=[s,a]}return[n,o]}var Fh=(r,e,t)=>r>>>t,Wh=(r,e,t)=>r<<32-t|e>>>t,Wo=(r,e,t)=>r>>>t|e<<32-t,qo=(r,e,t)=>r<<32-t|e>>>t,Va=(r,e,t)=>r<<64-t|e>>>t-32,$a=(r,e,t)=>r>>>t-32|e<<64-t;function Fr(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var q0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),G0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,z0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),X0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Z0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Y0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var WA=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]),Qn=new Uint32Array(64),qh=class extends Ha{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Qn[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let y=Qn[l-15],g=Qn[l-2],m=Er(y,7)^Er(y,18)^y>>>3,C=Er(g,17)^Er(g,19)^g>>>10;Qn[l]=C+Qn[l-7]+m+Qn[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:p}=this;for(let l=0;l<64;l++){let y=Er(a,6)^Er(a,11)^Er(a,25),g=p+y+V0(a,c,f)+WA[l]+Qn[l]|0,C=(Er(n,2)^Er(n,13)^Er(n,22))+$0(n,o,i)|0;p=f,f=c,c=a,a=s+g|0,s=i,i=o,o=n,n=g+C|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,p=p+this.H|0,this.set(n,o,i,s,a,c,f,p)}roundClean(){Ar(Qn)}destroy(){this.set(0,0,0,0,0,0,0,0),Ar(this.buffer)}},Gh=class extends qh{A=gn[0]|0;B=gn[1]|0;C=gn[2]|0;D=gn[3]|0;E=gn[4]|0;F=gn[5]|0;G=gn[6]|0;H=gn[7]|0;constructor(){super(32)}};var J0=W0(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),qA=J0[0],GA=J0[1],eo=new Uint32Array(80),to=new Uint32Array(80),zh=class extends Ha{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:p,Fh:l,Fl:y,Gh:g,Gl:m,Hh:C,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,p,l,y,g,m,C,d]}set(e,t,n,o,i,s,a,c,f,p,l,y,g,m,C,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=p|0,this.Fh=l|0,this.Fl=y|0,this.Gh=g|0,this.Gl=m|0,this.Hh=C|0,this.Hl=d|0}process(e,t){for(let B=0;B<16;B++,t+=4)eo[B]=e.getUint32(t),to[B]=e.getUint32(t+=4);for(let B=16;B<80;B++){let H=eo[B-15]|0,J=to[B-15]|0,z=Wo(H,J,1)^Wo(H,J,8)^Fh(H,J,7),oe=qo(H,J,1)^qo(H,J,8)^Wh(H,J,7),j=eo[B-2]|0,P=to[B-2]|0,X=Wo(j,P,19)^Va(j,P,61)^Fh(j,P,6),Q=qo(j,P,19)^$a(j,P,61)^Wh(j,P,6),$=z0(oe,Q,to[B-7],to[B-16]),O=X0($,z,X,eo[B-7],eo[B-16]);eo[B]=O|0,to[B]=$|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:p,Eh:l,El:y,Fh:g,Fl:m,Gh:C,Gl:d,Hh:S,Hl:D}=this;for(let B=0;B<80;B++){let H=Wo(l,y,14)^Wo(l,y,18)^Va(l,y,41),J=qo(l,y,14)^qo(l,y,18)^$a(l,y,41),z=l&g^~l&C,oe=y&m^~y&d,j=Z0(D,J,oe,GA[B],to[B]),P=Y0(j,S,H,z,qA[B],eo[B]),X=j|0,Q=Wo(n,o,28)^Va(n,o,34)^Va(n,o,39),$=qo(n,o,28)^$a(n,o,34)^$a(n,o,39),O=n&i^n&a^i&a,_=o&s^o&c^s&c;S=C|0,D=d|0,C=g|0,d=m|0,g=l|0,m=y|0,{h:l,l:y}=Fr(f|0,p|0,P|0,X|0),f=a|0,p=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let v=q0(X,$,_);n=G0(v,P,Q,O),o=v|0}({h:n,l:o}=Fr(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Fr(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Fr(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:p}=Fr(this.Dh|0,this.Dl|0,f|0,p|0),{h:l,l:y}=Fr(this.Eh|0,this.El|0,l|0,y|0),{h:g,l:m}=Fr(this.Fh|0,this.Fl|0,g|0,m|0),{h:C,l:d}=Fr(this.Gh|0,this.Gl|0,C|0,d|0),{h:S,l:D}=Fr(this.Hh|0,this.Hl|0,S|0,D|0),this.set(n,o,i,s,a,c,f,p,l,y,g,m,C,d,S,D)}roundClean(){Ar(eo,to)}destroy(){Ar(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Xh=class extends zh{Ah=gt[0]|0;Al=gt[1]|0;Bh=gt[2]|0;Bl=gt[3]|0;Ch=gt[4]|0;Cl=gt[5]|0;Dh=gt[6]|0;Dl=gt[7]|0;Eh=gt[8]|0;El=gt[9]|0;Fh=gt[10]|0;Fl=gt[11]|0;Gh=gt[12]|0;Gl=gt[13]|0;Hh=gt[14]|0;Hl=gt[15]|0;constructor(){super(64)}};var Wr=Vh(()=>new Gh,$h(1));var Q0=Vh(()=>new Xh,$h(3));var Yh=BigInt(0),Zh=BigInt(1);function bn(r,e=""){if(typeof r!="boolean"){let t=e&&`"${e}" `;throw new Error(t+"expected boolean, got type="+typeof r)}return r}function eb(r){if(typeof r=="bigint"){if(!If(r))throw new Error("positive bigint expected, got "+r)}else cr(r);return r}function Fa(r){let e=eb(r).toString(16);return e.length&1?"0"+e:e}function tb(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Yh:BigInt("0x"+r)}function ps(r){return tb(yn(r))}function qr(r){return tb(yn(Go(he(r)).reverse()))}function Pf(r,e){cr(e),r=eb(r);let t=mn(r.toString(16).padStart(e*2,"0"));if(t.length!==e)throw new Error("number too large");return t}function Wa(r,e){return Pf(r,e).reverse()}function Go(r){return Uint8Array.from(r)}var If=r=>typeof r=="bigint"&&Yh<=r;function zA(r,e,t){return If(r)&&If(e)&&If(t)&&e<=r&&r<t}function ro(r,e,t,n){if(!zA(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function Jh(r){let e;for(e=0;r>Yh;r>>=Zh,e+=1);return e}var qa=r=>(Zh<<BigInt(r))-Zh;function rb(r,e,t){if(cr(r,"hashLen"),cr(e,"qByteLen"),typeof t!="function")throw new Error("hmacFn must be a function");let n=d=>new Uint8Array(d),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(r),f=n(r),p=0,l=()=>{c.fill(1),f.fill(0),p=0},y=(...d)=>t(f,Vt(c,...d)),g=(d=o)=>{f=y(i,d),c=y(),d.length!==0&&(f=y(s,d),c=y())},m=()=>{if(p++>=a)throw new Error("drbg: tried max amount of iterations");let d=0,S=[];for(;d<e;){c=y();let D=c.slice();S.push(D),d+=c.length}return Vt(...S)};return(d,S)=>{l(),g(d);let D;for(;!(D=S(m()));)g();return l(),D}}function Gr(r,e={},t={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(i,s,a){let c=r[i];if(a&&c===void 0)return;let f=typeof c;if(f!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(t,!0)}function hs(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var Lt=BigInt(0),pt=BigInt(1),zo=BigInt(2),ib=BigInt(3),sb=BigInt(4),ab=BigInt(5),XA=BigInt(7),cb=BigInt(8),ZA=BigInt(9),ub=BigInt(16);function Ge(r,e){let t=r%e;return t>=Lt?t:e+t}function Ve(r,e,t){let n=r;for(;e-- >Lt;)n*=n,n%=t;return n}function nb(r,e){if(r===Lt)throw new Error("invert: expected non-zero number");if(e<=Lt)throw new Error("invert: expected positive modulus, got "+e);let t=Ge(r,e),n=e,o=Lt,i=pt,s=pt,a=Lt;for(;t!==Lt;){let f=n/t,p=n%t,l=o-s*f,y=i-a*f;n=t,t=p,o=s,i=a,s=l,a=y}if(n!==pt)throw new Error("invert: does not exist");return Ge(o,e)}function ed(r,e,t){if(!r.eql(r.sqr(e),t))throw new Error("Cannot find square root")}function fb(r,e){let t=(r.ORDER+pt)/sb,n=r.pow(e,t);return ed(r,n,e),n}function YA(r,e){let t=(r.ORDER-ab)/cb,n=r.mul(e,zo),o=r.pow(n,t),i=r.mul(e,o),s=r.mul(r.mul(i,zo),o),a=r.mul(i,r.sub(s,r.ONE));return ed(r,a,e),a}function JA(r){let e=ds(r),t=lb(r),n=t(e,e.neg(e.ONE)),o=t(e,n),i=t(e,e.neg(n)),s=(r+XA)/ub;return(a,c)=>{let f=a.pow(c,s),p=a.mul(f,n),l=a.mul(f,o),y=a.mul(f,i),g=a.eql(a.sqr(p),c),m=a.eql(a.sqr(l),c);f=a.cmov(f,p,g),p=a.cmov(y,l,m);let C=a.eql(a.sqr(p),c),d=a.cmov(f,p,C);return ed(a,d,c),d}}function lb(r){if(r<ib)throw new Error("sqrt is not defined for small field");let e=r-pt,t=0;for(;e%zo===Lt;)e/=zo,t++;let n=zo,o=ds(r);for(;ob(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return fb;let i=o.pow(n,e),s=(e+pt)/zo;return function(c,f){if(c.is0(f))return f;if(ob(c,f)!==1)throw new Error("Cannot find square root");let p=t,l=c.mul(c.ONE,i),y=c.pow(f,e),g=c.pow(f,s);for(;!c.eql(y,c.ONE);){if(c.is0(y))return c.ZERO;let m=1,C=c.sqr(y);for(;!c.eql(C,c.ONE);)if(m++,C=c.sqr(C),m===p)throw new Error("Cannot find square root");let d=pt<<BigInt(p-m-1),S=c.pow(l,d);p=m,l=c.sqr(S),y=c.mul(y,l),g=c.mul(g,S)}return g}}function QA(r){return r%sb===ib?fb:r%cb===ab?YA:r%ub===ZA?JA(r):lb(r)}var pb=(r,e)=>(Ge(r,e)&pt)===pt,eE=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function td(r){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},t=eE.reduce((n,o)=>(n[o]="function",n),e);return Gr(r,t),r}function tE(r,e,t){if(t<Lt)throw new Error("invalid exponent, negatives unsupported");if(t===Lt)return r.ONE;if(t===pt)return e;let n=r.ONE,o=e;for(;t>Lt;)t&pt&&(n=r.mul(n,o)),o=r.sqr(o),t>>=pt;return n}function Ga(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),o=e.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),i=r.inv(o);return e.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),i),n}function ob(r,e){let t=(r.ORDER-pt)/zo,n=r.pow(e,t),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function rE(r,e){e!==void 0&&cr(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}var Qh=class{ORDER;BITS;BYTES;isLE;ZERO=Lt;ONE=pt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=Lt)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,t!=null&&typeof t=="object"&&(typeof t.BITS=="number"&&(n=t.BITS),typeof t.sqrt=="function"&&(this.sqrt=t.sqrt),typeof t.isLE=="boolean"&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),typeof t.modFromBytes=="boolean"&&(this._mod=t.modFromBytes));let{nBitLength:o,nByteLength:i}=rE(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Ge(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return Lt<=e&&e<this.ORDER}is0(e){return e===Lt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&pt)===pt}neg(e){return Ge(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Ge(e*e,this.ORDER)}add(e,t){return Ge(e+t,this.ORDER)}sub(e,t){return Ge(e-t,this.ORDER)}mul(e,t){return Ge(e*t,this.ORDER)}pow(e,t){return tE(this,e,t)}div(e,t){return Ge(e*nb(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return nb(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=QA(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?Wa(e,this.BYTES):Pf(e,this.BYTES)}fromBytes(e,t=!1){he(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?qr(e):ps(e);if(a&&(c=Ge(c,s)),!t&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Ga(this,e)}cmov(e,t,n){return n?t:e}};function ds(r,e={}){return new Qh(r,e)}function hb(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function rd(r){let e=hb(r);return e+Math.ceil(e/2)}function nd(r,e,t=!1){he(r);let n=r.length,o=hb(e),i=rd(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=t?qr(r):ps(r),a=Ge(s,e-pt)+pt;return t?Wa(a,o):Pf(a,o)}var ys=BigInt(0),Xo=BigInt(1);function za(r,e){let t=e.negate();return r?t:e}function Zo(r,e){let t=Ga(r.Fp,e.map(n=>n.Z));return e.map((n,o)=>r.fromAffine(n.toAffine(t[o])))}function gb(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function od(r,e){gb(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),o=2**r,i=qa(r),s=BigInt(r);return{windows:t,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function db(r,e,t){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=t,a=Number(r&o),c=r>>s;a>n&&(a-=i,c+=Xo);let f=e*n,p=f+Math.abs(a)-1,l=a===0,y=a<0,g=e%2!==0;return{nextN:c,offset:p,isZero:l,isNeg:y,isNegF:g,offsetF:f}}var id=new WeakMap,bb=new WeakMap;function sd(r){return bb.get(r)||1}function yb(r){if(r!==ys)throw new Error("invalid wNAF")}var ms=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let o=e;for(;t>ys;)t&Xo&&(n=n.add(o)),o=o.double(),t>>=Xo;return n}precomputeWindow(e,t){let{windows:n,windowSize:o}=od(t,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let f=1;f<o;f++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=od(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:f,isZero:p,isNeg:l,isNegF:y,offsetF:g}=db(n,a,s);n=c,p?i=i.add(za(y,t[g])):o=o.add(za(l,t[f]))}return yb(n),{p:o,f:i}}wNAFUnsafe(e,t,n,o=this.ZERO){let i=od(e,this.bits);for(let s=0;s<i.windows&&n!==ys;s++){let{nextN:a,offset:c,isZero:f,isNeg:p}=db(n,s,i);if(n=a,!f){let l=t[c];o=o.add(p?l.negate():l)}}return yb(n),o}getPrecomputes(e,t,n){let o=id.get(t);return o||(o=this.precomputeWindow(t,e),e!==1&&(typeof n=="function"&&(o=n(o)),id.set(t,o))),o}cached(e,t,n){let o=sd(e);return this.wNAF(o,this.getPrecomputes(o,e,n),t)}unsafe(e,t,n,o){let i=sd(e);return i===1?this._unsafeLadder(e,t,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,o)}createCache(e,t){gb(t,this.bits),bb.set(e,t),id.delete(e)}hasCache(e){return sd(e)!==1}};function wb(r,e,t,n){let o=e,i=r.ZERO,s=r.ZERO;for(;t>ys||n>ys;)t&Xo&&(i=i.add(o)),n&Xo&&(s=s.add(o)),o=o.double(),t>>=Xo,n>>=Xo;return{p1:i,p2:s}}function mb(r,e,t){if(e){if(e.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return td(e),e}else return ds(r,{isLE:t})}function Nf(r,e,t={},n){if(n===void 0&&(n=r==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${r} CURVE object`);for(let c of["p","n","h"]){let f=e[c];if(!(typeof f=="bigint"&&f>ys))throw new Error(`CURVE.${c} must be positive bigint`)}let o=mb(e.p,t.Fp,n),i=mb(e.n,t.Fn,n),a=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function gs(r,e){return function(n){let o=r(n);return{secretKey:o,publicKey:e(o)}}}var no=BigInt(0),ht=BigInt(1),ad=BigInt(2),nE=BigInt(8);function oE(r,e,t,n){let o=r.sqr(t),i=r.sqr(n),s=r.add(r.mul(e.a,o),i),a=r.add(r.ONE,r.mul(e.d,r.mul(o,i)));return r.eql(s,a)}function xb(r,e={}){let t=Nf("edwards",r,e,e.FpFnLE),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s}=i;Gr(e,{},{uvRatio:"function"});let a=ad<<BigInt(o.BYTES*8)-ht,c=d=>n.create(d),f=e.uvRatio||((d,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(d,S))}}catch{return{isValid:!1,value:no}}});if(!oE(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function p(d,S,D=!1){let B=D?ht:no;return ro("coordinate "+d,S,B,a),S}function l(d){if(!(d instanceof m))throw new Error("EdwardsPoint expected")}let y=hs((d,S)=>{let{X:D,Y:B,Z:H}=d,J=d.is0();S==null&&(S=J?nE:n.inv(H));let z=c(D*S),oe=c(B*S),j=n.mul(H,S);if(J)return{x:no,y:ht};if(j!==ht)throw new Error("invZ was invalid");return{x:z,y:oe}}),g=hs(d=>{let{a:S,d:D}=i;if(d.is0())throw new Error("bad point: ZERO");let{X:B,Y:H,Z:J,T:z}=d,oe=c(B*B),j=c(H*H),P=c(J*J),X=c(P*P),Q=c(oe*S),$=c(P*c(Q+j)),O=c(X+c(D*c(oe*j)));if($!==O)throw new Error("bad point: equation left != right (1)");let _=c(B*H),v=c(J*z);if(_!==v)throw new Error("bad point: equation left != right (2)");return!0});class m{static BASE=new m(i.Gx,i.Gy,ht,c(i.Gx*i.Gy));static ZERO=new m(no,ht,ht,no);static Fp=n;static Fn=o;X;Y;Z;T;constructor(S,D,B,H){this.X=p("x",S),this.Y=p("y",D),this.Z=p("z",B,!0),this.T=p("t",H),Object.freeze(this)}static CURVE(){return i}static fromAffine(S){if(S instanceof m)throw new Error("extended point not allowed");let{x:D,y:B}=S||{};return p("x",D),p("y",B),new m(D,B,ht,c(D*B))}static fromBytes(S,D=!1){let B=n.BYTES,{a:H,d:J}=i;S=Go(he(S,B,"point")),bn(D,"zip215");let z=Go(S),oe=S[B-1];z[B-1]=oe&-129;let j=qr(z),P=D?a:n.ORDER;ro("point.y",j,no,P);let X=c(j*j),Q=c(X-ht),$=c(J*X-H),{isValid:O,value:_}=f(Q,$);if(!O)throw new Error("bad point: invalid y coordinate");let v=(_&ht)===ht,R=(oe&128)!==0;if(!D&&_===no&&R)throw new Error("bad point: x=0 and x_0=1");return R!==v&&(_=c(-_)),m.fromAffine({x:_,y:j})}static fromHex(S,D=!1){return m.fromBytes(mn(S),D)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,D=!0){return C.createCache(this,S),D||this.multiply(ad),this}assertValidity(){g(this)}equals(S){l(S);let{X:D,Y:B,Z:H}=this,{X:J,Y:z,Z:oe}=S,j=c(D*oe),P=c(J*H),X=c(B*oe),Q=c(z*H);return j===P&&X===Q}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:S}=i,{X:D,Y:B,Z:H}=this,J=c(D*D),z=c(B*B),oe=c(ad*c(H*H)),j=c(S*J),P=D+B,X=c(c(P*P)-J-z),Q=j+z,$=Q-oe,O=j-z,_=c(X*$),v=c(Q*O),R=c(X*O),U=c($*Q);return new m(_,v,U,R)}add(S){l(S);let{a:D,d:B}=i,{X:H,Y:J,Z:z,T:oe}=this,{X:j,Y:P,Z:X,T:Q}=S,$=c(H*j),O=c(J*P),_=c(oe*B*Q),v=c(z*X),R=c((H+J)*(j+P)-$-O),U=v-_,L=v+_,I=c(O-D*$),M=c(R*U),q=c(L*I),N=c(R*I),ye=c(U*L);return new m(M,q,ye,N)}subtract(S){return this.add(S.negate())}multiply(S){if(!o.isValidNot0(S))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:D,f:B}=C.cached(this,S,H=>Zo(m,H));return Zo(m,[D,B])[0]}multiplyUnsafe(S,D=m.ZERO){if(!o.isValid(S))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return S===no?m.ZERO:this.is0()||S===ht?this:C.unsafe(this,S,B=>Zo(m,B),D)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return C.unsafe(this,i.n).is0()}toAffine(S){return y(this,S)}clearCofactor(){return s===ht?this:this.multiplyUnsafe(s)}toBytes(){let{x:S,y:D}=this.toAffine(),B=n.toBytes(D);return B[B.length-1]|=S&ht?128:0,B}toHex(){return yn(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=new ms(m,o.BITS);return m.BASE.precompute(8),m}function vb(r,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Gr(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=t,{BASE:o,Fp:i,Fn:s}=r,a=t.randomBytes||Jn,c=t.adjustScalarBytes||(j=>j),f=t.domain||((j,P,X)=>{if(bn(X,"phflag"),P.length||X)throw new Error("Contexts/pre-hash are not supported");return j});function p(j){return s.create(qr(j))}function l(j){let P=B.secretKey;he(j,B.secretKey,"secretKey");let X=he(e(j),2*P,"hashedSecretKey"),Q=c(X.slice(0,P)),$=X.slice(P,2*P),O=p(Q);return{head:Q,prefix:$,scalar:O}}function y(j){let{head:P,prefix:X,scalar:Q}=l(j),$=o.multiply(Q),O=$.toBytes();return{head:P,prefix:X,scalar:Q,point:$,pointBytes:O}}function g(j){return y(j).pointBytes}function m(j=Uint8Array.of(),...P){let X=Vt(...P);return p(e(f(X,he(j,void 0,"context"),!!n)))}function C(j,P,X={}){j=he(j,void 0,"message"),n&&(j=n(j));let{prefix:Q,scalar:$,pointBytes:O}=y(P),_=m(X.context,Q,j),v=o.multiply(_).toBytes(),R=m(X.context,v,O,j),U=s.create(_+R*$);if(!s.isValid(U))throw new Error("sign failed: invalid s");let L=Vt(v,s.toBytes(U));return he(L,B.signature,"result")}let d={zip215:!0};function S(j,P,X,Q=d){let{context:$,zip215:O}=Q,_=B.signature;j=he(j,_,"signature"),P=he(P,void 0,"message"),X=he(X,B.publicKey,"publicKey"),O!==void 0&&bn(O,"zip215"),n&&(P=n(P));let v=_/2,R=j.subarray(0,v),U=qr(j.subarray(v,_)),L,I,M;try{L=r.fromBytes(X,O),I=r.fromBytes(R,O),M=o.multiplyUnsafe(U)}catch{return!1}if(!O&&L.isSmallOrder())return!1;let q=m($,I.toBytes(),L.toBytes(),P);return I.add(L.multiplyUnsafe(q)).subtract(M).clearCofactor().is0()}let D=i.BYTES,B={secretKey:D,publicKey:D,signature:2*D,seed:D};function H(j=a(B.seed)){return he(j,B.seed,"seed")}function J(j){return $o(j)&&j.length===s.BYTES}function z(j,P){try{return!!r.fromBytes(j,P)}catch{return!1}}let oe={getExtendedPublicKey:y,randomSecretKey:H,isValidSecretKey:J,isValidPublicKey:z,toMontgomery(j){let{y:P}=r.fromBytes(j),X=B.publicKey,Q=X===32;if(!Q&&X!==57)throw new Error("only defined for 25519 and 448");let $=Q?i.div(ht+P,ht-P):i.div(P-ht,P+ht);return i.toBytes($)},toMontgomerySecret(j){let P=B.secretKey;he(j,P);let X=e(j.subarray(0,P));return c(X).subarray(0,P)}};return Object.freeze({keygen:gs(H,g),getPublicKey:g,sign:C,verify:S,utils:oe,Point:r,lengths:B})}var Xa=BigInt(0),bs=BigInt(1),kf=BigInt(2);function iE(r){return Gr(r,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...r})}function _b(r){let e=iE(r),{P:t,type:n,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let c=s||Jn,f=a?255:448,p=a?32:56,l=BigInt(a?9:5),y=BigInt(a?121665:39081),g=a?kf**BigInt(254):kf**BigInt(447),m=a?BigInt(8)*kf**BigInt(251)-bs:BigInt(4)*kf**BigInt(445)-bs,C=g+m+bs,d=_=>Ge(_,t),S=D(l);function D(_){return Wa(d(_),p)}function B(_){let v=Go(he(_,p,"uCoordinate"));return a&&(v[31]&=127),d(qr(v))}function H(_){return qr(o(Go(he(_,p,"scalar"))))}function J(_,v){let R=X(B(v),H(_));if(R===Xa)throw new Error("invalid private or public key received");return D(R)}function z(_){return J(_,S)}let oe=z,j=J;function P(_,v,R){let U=d(_*(v-R));return v=d(v-U),R=d(R+U),{x_2:v,x_3:R}}function X(_,v){ro("u",_,Xa,t),ro("scalar",v,g,C);let R=v,U=_,L=bs,I=Xa,M=_,q=bs,N=Xa;for(let xe=BigInt(f-1);xe>=Xa;xe--){let re=R>>xe&bs;N^=re,{x_2:L,x_3:M}=P(N,L,M),{x_2:I,x_3:q}=P(N,I,q),N=re;let Ae=L+I,Ne=d(Ae*Ae),qe=L-I,Ce=d(qe*qe),ke=Ne-Ce,ln=M+q,wr=M-q,Gn=d(wr*Ae),cf=d(ln*qe),rs=Gn+cf,Ia=Gn-cf;M=d(rs*rs),q=d(U*d(Ia*Ia)),L=d(Ne*Ce),I=d(ke*(Ne+d(y*ke)))}({x_2:L,x_3:M}=P(N,L,M)),{x_2:I,x_3:q}=P(N,I,q);let ye=i(I);return d(L*ye)}let Q={secretKey:p,publicKey:p,seed:p},$=(_=c(p))=>(he(_,Q.seed,"seed"),_),O={randomSecretKey:$};return Object.freeze({keygen:gs($,oe),getSharedSecret:j,getPublicKey:oe,scalarMult:J,scalarMultBase:z,utils:O,GuBytes:S.slice(),lengths:Q})}var sE=BigInt(1),Sb=BigInt(2),aE=BigInt(3),cE=BigInt(5),uE=BigInt(8),Df=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),fE={p:Df,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:uE,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Eb(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Df,a=r*r%i*r%i,c=Ve(a,Sb,i)*a%i,f=Ve(c,sE,i)*r%i,p=Ve(f,cE,i)*f%i,l=Ve(p,e,i)*p%i,y=Ve(l,t,i)*l%i,g=Ve(y,n,i)*y%i,m=Ve(g,o,i)*g%i,C=Ve(m,o,i)*g%i,d=Ve(C,e,i)*p%i;return{pow_p_5_8:Ve(d,Sb,i)*r%i,b2:a}}function Cb(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var Ab=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function lE(r,e){let t=Df,n=Ge(e*e*e,t),o=Ge(n*n*e,t),i=Eb(r*o).pow_p_5_8,s=Ge(r*n*i,t),a=Ge(e*s*s,t),c=s,f=Ge(s*Ab,t),p=a===r,l=a===Ge(-r,t),y=a===Ge(-r*Ab,t);return p&&(s=c),(l||y)&&(s=f),pb(s,t)&&(s=Ge(-s,t)),{isValid:p||l,value:s}}var pE=xb(fE,{uvRatio:lE});function hE(r){return vb(pE,Q0,Object.assign({adjustScalarBytes:Cb},r))}var Za=hE({});var Ya=(()=>{let r=Df;return _b({P:r,type:"x25519",powPminus2:e=>{let{pow_p_5_8:t,b2:n}=Eb(e);return Ge(Ve(t,aE,r)*n,r)},adjustScalarBytes:Cb})})();var Ja=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},Qa=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Rf=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Tb={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new Rf("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var $t=Tb;var jf=32,ec=64,cd=32;var ws,Ob=(async()=>{try{return await $t.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function Bb(){let r=Za.utils.randomSecretKey(),e=Za.getPublicKey(r);return{privateKey:bE(r,e),publicKey:e}}async function dE(r,e){let t;r.length===ec?t=r.subarray(0,32):t=r;let n={crv:"Ed25519",kty:"OKP",x:le(r.subarray(32),"base64url"),d:le(t,"base64url"),ext:!0,key_ops:["sign"]},o=await $t.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await $t.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function yE(r,e){let t=r.subarray(0,cd);return Za.sign(e instanceof Uint8Array?e:e.subarray(),t)}async function Ib(r,e){return ws==null&&(ws=await Ob),ws?dE(r,e):yE(r,e)}async function mE(r,e,t){if(r.buffer instanceof ArrayBuffer){let n=await $t.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await $t.get().subtle.verify({name:"Ed25519"},n,e,t instanceof Uint8Array?t:t.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function gE(r,e,t){return Za.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}async function Pb(r,e,t){return ws==null&&(ws=await Ob),ws?mE(r,e,t):gE(r,e,t)}function bE(r,e){let t=new Uint8Array(ec);for(let n=0;n<cd;n++)t[n]=r[n],t[cd+n]=e[n];return t}function xs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var tc=class{type="Ed25519";raw;constructor(e){this.raw=Uf(e,jf)}toMultihash(){return _r.digest(Yn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ze.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}verify(e,t,n){n?.signal?.throwIfAborted();let o=Pb(this.raw,t,e);return xs(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},Lf=class{type="Ed25519";raw;publicKey;constructor(e,t){this.raw=Uf(e,ec),this.publicKey=new tc(t)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}sign(e,t){t?.signal?.throwIfAborted();let n=Ib(this.raw,e);return xs(n)?n.then(o=>(t?.signal?.throwIfAborted(),o)):(t?.signal?.throwIfAborted(),n)}};function ud(r){return r=Uf(r,jf),new tc(r)}async function kb(){let{privateKey:r,publicKey:e}=Bb();return new Lf(r,e)}function Uf(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new _e(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var wE=Math.pow(2,7),xE=Math.pow(2,14),vE=Math.pow(2,21),fd=Math.pow(2,28),ld=Math.pow(2,35),pd=Math.pow(2,42),hd=Math.pow(2,49),De=128,Bt=127;function $e(r){if(r<wE)return 1;if(r<xE)return 2;if(r<vE)return 3;if(r<fd)return 4;if(r<ld)return 5;if(r<pd)return 6;if(r<hd)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function vs(r,e,t=0){switch($e(r)){case 8:e[t++]=r&255|De,r/=128;case 7:e[t++]=r&255|De,r/=128;case 6:e[t++]=r&255|De,r/=128;case 5:e[t++]=r&255|De,r/=128;case 4:e[t++]=r&255|De,r>>>=7;case 3:e[t++]=r&255|De,r>>>=7;case 2:e[t++]=r&255|De,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function _E(r,e,t=0){switch($e(r)){case 8:e.set(t++,r&255|De),r/=128;case 7:e.set(t++,r&255|De),r/=128;case 6:e.set(t++,r&255|De),r/=128;case 5:e.set(t++,r&255|De),r/=128;case 4:e.set(t++,r&255|De),r>>>=7;case 3:e.set(t++,r&255|De),r>>>=7;case 2:e.set(t++,r&255|De),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function dd(r,e){let t=r[e],n=0;if(n+=t&Bt,t<De||(t=r[e+1],n+=(t&Bt)<<7,t<De)||(t=r[e+2],n+=(t&Bt)<<14,t<De)||(t=r[e+3],n+=(t&Bt)<<21,t<De)||(t=r[e+4],n+=(t&Bt)*fd,t<De)||(t=r[e+5],n+=(t&Bt)*ld,t<De)||(t=r[e+6],n+=(t&Bt)*pd,t<De)||(t=r[e+7],n+=(t&Bt)*hd,t<De))return n;throw new RangeError("Could not decode varint")}function SE(r,e){let t=r.get(e),n=0;if(n+=t&Bt,t<De||(t=r.get(e+1),n+=(t&Bt)<<7,t<De)||(t=r.get(e+2),n+=(t&Bt)<<14,t<De)||(t=r.get(e+3),n+=(t&Bt)<<21,t<De)||(t=r.get(e+4),n+=(t&Bt)*fd,t<De)||(t=r.get(e+5),n+=(t&Bt)*ld,t<De)||(t=r.get(e+6),n+=(t&Bt)*pd,t<De)||(t=r.get(e+7),n+=(t&Bt)*hd,t<De))return n;throw new RangeError("Could not decode varint")}function Mf(r,e,t=0){return e==null&&(e=ft($e(r))),e instanceof Uint8Array?vs(r,e,t):_E(r,e,t)}function wn(r,e=0){return r instanceof Uint8Array?dd(r,e):SE(r,e)}var yd=new Float32Array([-0]),oo=new Uint8Array(yd.buffer);function Db(r,e,t){yd[0]=r,e[t]=oo[0],e[t+1]=oo[1],e[t+2]=oo[2],e[t+3]=oo[3]}function Rb(r,e){return oo[0]=r[e],oo[1]=r[e+1],oo[2]=r[e+2],oo[3]=r[e+3],yd[0]}var md=new Float64Array([-0]),It=new Uint8Array(md.buffer);function jb(r,e,t){md[0]=r,e[t]=It[0],e[t+1]=It[1],e[t+2]=It[2],e[t+3]=It[3],e[t+4]=It[4],e[t+5]=It[5],e[t+6]=It[6],e[t+7]=It[7]}function Lb(r,e){return It[0]=r[e],It[1]=r[e+1],It[2]=r[e+2],It[3]=r[e+3],It[4]=r[e+4],It[5]=r[e+5],It[6]=r[e+6],It[7]=r[e+7],md[0]}var AE=BigInt(Number.MAX_SAFE_INTEGER),EE=BigInt(Number.MIN_SAFE_INTEGER),er=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Yo;if(e<AE&&e>EE)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Ub&&(o=0n,++n>Ub&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Yo;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Yo}},Yo=new er(0,0);Yo.toBigInt=function(){return 0n};Yo.zzEncode=Yo.zzDecode=function(){return this};Yo.length=function(){return 1};var Ub=4294967296n;function Mb(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Kb(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function gd(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function Cr(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Kf(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var bd=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Cr(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Cr(this,4);return Kf(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Cr(this,4);return Kf(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Cr(this,4);let e=Rb(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Cr(this,4);let e=Lb(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Cr(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Kb(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Cr(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Cr(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new er(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Cr(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Cr(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Cr(this,8);let e=Kf(this.buf,this.pos+=4),t=Kf(this.buf,this.pos+=4);return new er(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=dd(this.buf,this.pos);return this.pos+=$e(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function wd(r){return new bd(r instanceof Uint8Array?r:r.subarray())}function Tr(r,e,t){let n=wd(r);return e.decode(n,void 0,t)}function xd(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return ft(s);o+s>e&&(n=ft(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Jo=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function vd(){}var Sd=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},CE=xd();function TE(r){return globalThis.Buffer!=null?ft(r):CE(r)}var oc=class{len;head;tail;states;constructor(){this.len=0,this.head=new Jo(vd,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Jo(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ad((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Hf,10,er.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=er.fromBigInt(e);return this._push(Hf,t.length(),t)}uint64Number(e){return this._push(vs,$e(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=er.fromBigInt(e).zzEncode();return this._push(Hf,t.length(),t)}sint64Number(e){let t=er.fromNumber(e).zzEncode();return this._push(Hf,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(_d,1,e?1:0)}fixed32(e){return this._push(nc,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=er.fromBigInt(e);return this._push(nc,4,t.lo)._push(nc,4,t.hi)}fixed64Number(e){let t=er.fromNumber(e);return this._push(nc,4,t.lo)._push(nc,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Db,4,e)}double(e){return this._push(jb,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(_d,1,0):this.uint32(t)._push(BE,t,e)}string(e){let t=Mb(e);return t!==0?this.uint32(t)._push(gd,t,e):this._push(_d,1,0)}fork(){return this.states=new Sd(this),this.head=this.tail=new Jo(vd,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Jo(vd,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=TE(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function _d(r,e,t){e[t]=r&255}function OE(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ad=class extends Jo{next;constructor(e,t){super(OE,e,t),this.next=void 0}};function Hf(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function nc(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function BE(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(oc.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(IE,e,r),this},oc.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(PE,e,r),this});function IE(r,e,t){e.set(r,t)}function PE(r,e,t){r.length<40?gd(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(me(r),t)}function Ed(){return new oc}function Or(r,e){let t=Ed();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var _s;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(_s||(_s={}));function Vf(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Qo(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Vf("enum",_s.VARINT,t,n)}function Br(r,e){return Vf("message",_s.LENGTH_DELIMITED,r,e)}var ic=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var nt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(nt||(nt={}));var Cd;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Cd||(Cd={}));(function(r){r.codec=()=>Qo(Cd)})(nt||(nt={}));var zr;(function(r){let e;r.codec=()=>(e==null&&(e=Br((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),nt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=nt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(zr||(zr={}));var Td;(function(r){let e;r.codec=()=>(e==null&&(e=Br((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),nt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=nt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(Td||(Td={}));var ac={};Ot(ac,{MAX_RSA_KEY_SIZE:()=>Od,generateRSAKeyPair:()=>Ld,jwkToJWKKeyPair:()=>qb,jwkToPkcs1:()=>RE,jwkToPkix:()=>Nd,jwkToRSAPrivateKey:()=>jd,pkcs1MessageToJwk:()=>Id,pkcs1MessageToRSAPrivateKey:()=>kd,pkcs1ToJwk:()=>DE,pkcs1ToRSAPrivateKey:()=>Wb,pkixMessageToJwk:()=>Pd,pkixMessageToRSAPublicKey:()=>Rd,pkixToJwk:()=>jE,pkixToRSAPublicKey:()=>Dd});var Ss=class{type="RSA";jwk;_raw;_multihash;constructor(e,t){this.jwk=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=ac.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return Ze.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}verify(e,t,n){return Fb(this.jwk,t,e,n)}},sc=class{type="RSA";jwk;_raw;publicKey;constructor(e,t){this.jwk=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=ac.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}sign(e,t){return $b(this.jwk,e,t)}};var Od=8192,Bd=18,NE=1062,kE=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function DE(r){let e=hn(r);return Id(e)}function Id(r){return{n:le(r[1],"base64url"),e:le(r[2],"base64url"),d:le(r[3],"base64url"),p:le(r[4],"base64url"),q:le(r[5],"base64url"),dp:le(r[6],"base64url"),dq:le(r[7],"base64url"),qi:le(r[8],"base64url"),kty:"RSA"}}function RE(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new _e("JWK was missing components");return Sr([jt(Uint8Array.from([0])),jt(me(r.n,"base64url")),jt(me(r.e,"base64url")),jt(me(r.d,"base64url")),jt(me(r.p,"base64url")),jt(me(r.q,"base64url")),jt(me(r.dp,"base64url")),jt(me(r.dq,"base64url")),jt(me(r.qi,"base64url"))]).subarray()}function jE(r){let e=hn(r,{offset:0});return Pd(e)}function Pd(r){let e=hn(r[1],{offset:0});return{kty:"RSA",n:le(e[0],"base64url"),e:le(e[1],"base64url")}}function Nd(r){if(r.n==null||r.e==null)throw new _e("JWK was missing components");return Sr([kE,Ka(Sr([jt(me(r.n,"base64url")),jt(me(r.e,"base64url"))]))]).subarray()}function Wb(r){let e=hn(r);return kd(e)}function kd(r){let e=Id(r);return jd(e)}function Dd(r,e){if(r.byteLength>=NE)throw new ns("Key size is too large");let t=hn(r,{offset:0});return Rd(t,r,e)}function Rd(r,e,t){let n=Pd(r);if(t==null){let o=Wr(zr.encode({Type:nt.RSA,Data:e}));t=Dt(Bd,o)}return new Ss(n,t)}function jd(r){if(zb(r)>Od)throw new _e("Key size is too large");let e=qb(r),t=Wr(zr.encode({Type:nt.RSA,Data:Nd(e.publicKey)})),n=Dt(Bd,t);return new sc(e.privateKey,new Ss(e.publicKey,n))}async function Ld(r){if(r>Od)throw new _e("Key size is too large");let e=await Gb(r),t=Wr(zr.encode({Type:nt.RSA,Data:Nd(e.publicKey)})),n=Dt(Bd,t);return new sc(e.privateKey,new Ss(e.publicKey,n))}function qb(r){if(r==null)throw new _e("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}async function Gb(r,e){let t=await $t.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await LE(t,e);return{privateKey:n[0],publicKey:n[1]}}async function $b(r,e,t){let n=await $t.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);t?.signal?.throwIfAborted();let o=await $t.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Fb(r,e,t,n){let o=await $t.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await $t.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,t instanceof Uint8Array?t:t.subarray());return n?.signal?.throwIfAborted(),i}async function LE(r,e){if(r.privateKey==null||r.publicKey==null)throw new _e("Private and public key are required");let t=await Promise.all([$t.get().subtle.exportKey("jwk",r.privateKey),$t.get().subtle.exportKey("jwk",r.publicKey)]);return e?.signal?.throwIfAborted(),t}function zb(r){if(r.kty!=="RSA")throw new _e("invalid key type");if(r.n==null)throw new _e("invalid key modulus");return me(r.n,"base64url").length*8}var $f=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Fo(e),he(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(t.length>n?e.create().update(t).digest():t);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Ar(o)}update(e){return ls(this),this.iHash.update(e),this}digestInto(e){ls(this),he(e,this.outputLen,"output"),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:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,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()}},As=(r,e,t)=>new $f(r,e).update(t).digest();As.create=(r,e)=>new $f(r,e);var Xb=(r,e)=>(r+(r>=0?e:-e)/Zb)/e;function UE(r,e,t){let[[n,o],[i,s]]=e,a=Xb(s*r,t),c=Xb(-o*r,t),f=r-a*n-c*i,p=-a*o-c*s,l=f<xn,y=p<xn;l&&(f=-f),y&&(p=-p);let g=qa(Math.ceil(Jh(t)/2))+Es;if(f<xn||f>=g||p<xn||p>=g)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:l,k1:f,k2neg:y,k2:p}}function Md(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function Ud(r,e){let t={};for(let n of Object.keys(e))t[n]=r[n]===void 0?e[n]:r[n];return bn(t.lowS,"lowS"),bn(t.prehash,"prehash"),t.format!==void 0&&Md(t.format),t}var Kd=class extends Error{constructor(e=""){super(e)}},io={Err:Kd,_tlv:{encode:(r,e)=>{let{Err:t}=io;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Fa(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Fa(o.length/2|128):"";return Fa(r)+i+o+e},decode(r,e){let{Err:t}=io,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let p of f)s=s<<8|p;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=io;if(r<xn)throw new e("integer: negative integers are not allowed");let t=Fa(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=io;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ps(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=io,o=he(r,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:p}=n.decode(2,c);if(p.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=io,n=e.encode(2,t.encode(r.r)),o=e.encode(2,t.encode(r.s)),i=n+o;return e.encode(48,i)}},xn=BigInt(0),Es=BigInt(1),Zb=BigInt(2),Ff=BigInt(3),ME=BigInt(4);function Yb(r,e={}){let t=Nf("weierstrass",r,e),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s,n:a}=i;Gr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=Qb(n,o);function p(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l($,O,_){let{x:v,y:R}=O.toAffine(),U=n.toBytes(v);if(bn(_,"isCompressed"),_){p();let L=!n.isOdd(R);return Vt(Jb(L),U)}else return Vt(Uint8Array.of(4),U,n.toBytes(R))}function y($){he($,void 0,"Point");let{publicKey:O,publicKeyUncompressed:_}=f,v=$.length,R=$[0],U=$.subarray(1);if(v===O&&(R===2||R===3)){let L=n.fromBytes(U);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let I=C(L),M;try{M=n.sqrt(I)}catch(ye){let xe=ye instanceof Error?": "+ye.message:"";throw new Error("bad point: is not on curve, sqrt error"+xe)}p();let q=n.isOdd(M);return(R&1)===1!==q&&(M=n.neg(M)),{x:L,y:M}}else if(v===_&&R===4){let L=n.BYTES,I=n.fromBytes(U.subarray(0,L)),M=n.fromBytes(U.subarray(L,L*2));if(!d(I,M))throw new Error("bad point: is not on curve");return{x:I,y:M}}else throw new Error(`bad point: got length ${v}, expected compressed=${O} or uncompressed=${_}`)}let g=e.toBytes||l,m=e.fromBytes||y;function C($){let O=n.sqr($),_=n.mul(O,$);return n.add(n.add(_,n.mul($,i.a)),i.b)}function d($,O){let _=n.sqr(O),v=C($);return n.eql(_,v)}if(!d(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(i.a,Ff),ME),D=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(S,D)))throw new Error("bad curve params: a or b");function B($,O,_=!1){if(!n.isValid(O)||_&&n.is0(O))throw new Error(`bad point coordinate ${$}`);return O}function H($){if(!($ instanceof P))throw new Error("Weierstrass Point expected")}function J($){if(!c||!c.basises)throw new Error("no endo");return UE($,c.basises,o.ORDER)}let z=hs(($,O)=>{let{X:_,Y:v,Z:R}=$;if(n.eql(R,n.ONE))return{x:_,y:v};let U=$.is0();O==null&&(O=U?n.ONE:n.inv(R));let L=n.mul(_,O),I=n.mul(v,O),M=n.mul(R,O);if(U)return{x:n.ZERO,y:n.ZERO};if(!n.eql(M,n.ONE))throw new Error("invZ was invalid");return{x:L,y:I}}),oe=hs($=>{if($.is0()){if(e.allowInfinityPoint&&!n.is0($.Y))return;throw new Error("bad point: ZERO")}let{x:O,y:_}=$.toAffine();if(!n.isValid(O)||!n.isValid(_))throw new Error("bad point: x or y not field elements");if(!d(O,_))throw new Error("bad point: equation left != right");if(!$.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function j($,O,_,v,R){return _=new P(n.mul(_.X,$),_.Y,_.Z),O=za(v,O),_=za(R,_),O.add(_)}class P{static BASE=new P(i.Gx,i.Gy,n.ONE);static ZERO=new P(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(O,_,v){this.X=B("x",O),this.Y=B("y",_,!0),this.Z=B("z",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(O){let{x:_,y:v}=O||{};if(!O||!n.isValid(_)||!n.isValid(v))throw new Error("invalid affine point");if(O instanceof P)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(v)?P.ZERO:new P(_,v,n.ONE)}static fromBytes(O){let _=P.fromAffine(m(he(O,void 0,"point")));return _.assertValidity(),_}static fromHex(O){return P.fromBytes(mn(O))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(O=8,_=!0){return Q.createCache(this,O),_||this.multiply(Ff),this}assertValidity(){oe(this)}hasEvenY(){let{y:O}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(O)}equals(O){H(O);let{X:_,Y:v,Z:R}=this,{X:U,Y:L,Z:I}=O,M=n.eql(n.mul(_,I),n.mul(U,R)),q=n.eql(n.mul(v,I),n.mul(L,R));return M&&q}negate(){return new P(this.X,n.neg(this.Y),this.Z)}double(){let{a:O,b:_}=i,v=n.mul(_,Ff),{X:R,Y:U,Z:L}=this,I=n.ZERO,M=n.ZERO,q=n.ZERO,N=n.mul(R,R),ye=n.mul(U,U),xe=n.mul(L,L),re=n.mul(R,U);return re=n.add(re,re),q=n.mul(R,L),q=n.add(q,q),I=n.mul(O,q),M=n.mul(v,xe),M=n.add(I,M),I=n.sub(ye,M),M=n.add(ye,M),M=n.mul(I,M),I=n.mul(re,I),q=n.mul(v,q),xe=n.mul(O,xe),re=n.sub(N,xe),re=n.mul(O,re),re=n.add(re,q),q=n.add(N,N),N=n.add(q,N),N=n.add(N,xe),N=n.mul(N,re),M=n.add(M,N),xe=n.mul(U,L),xe=n.add(xe,xe),N=n.mul(xe,re),I=n.sub(I,N),q=n.mul(xe,ye),q=n.add(q,q),q=n.add(q,q),new P(I,M,q)}add(O){H(O);let{X:_,Y:v,Z:R}=this,{X:U,Y:L,Z:I}=O,M=n.ZERO,q=n.ZERO,N=n.ZERO,ye=i.a,xe=n.mul(i.b,Ff),re=n.mul(_,U),Ae=n.mul(v,L),Ne=n.mul(R,I),qe=n.add(_,v),Ce=n.add(U,L);qe=n.mul(qe,Ce),Ce=n.add(re,Ae),qe=n.sub(qe,Ce),Ce=n.add(_,R);let ke=n.add(U,I);return Ce=n.mul(Ce,ke),ke=n.add(re,Ne),Ce=n.sub(Ce,ke),ke=n.add(v,R),M=n.add(L,I),ke=n.mul(ke,M),M=n.add(Ae,Ne),ke=n.sub(ke,M),N=n.mul(ye,Ce),M=n.mul(xe,Ne),N=n.add(M,N),M=n.sub(Ae,N),N=n.add(Ae,N),q=n.mul(M,N),Ae=n.add(re,re),Ae=n.add(Ae,re),Ne=n.mul(ye,Ne),Ce=n.mul(xe,Ce),Ae=n.add(Ae,Ne),Ne=n.sub(re,Ne),Ne=n.mul(ye,Ne),Ce=n.add(Ce,Ne),re=n.mul(Ae,Ce),q=n.add(q,re),re=n.mul(ke,Ce),M=n.mul(qe,M),M=n.sub(M,re),re=n.mul(qe,Ae),N=n.mul(ke,N),N=n.add(N,re),new P(M,q,N)}subtract(O){return this.add(O.negate())}is0(){return this.equals(P.ZERO)}multiply(O){let{endo:_}=e;if(!o.isValidNot0(O))throw new Error("invalid scalar: out of range");let v,R,U=L=>Q.cached(this,L,I=>Zo(P,I));if(_){let{k1neg:L,k1:I,k2neg:M,k2:q}=J(O),{p:N,f:ye}=U(I),{p:xe,f:re}=U(q);R=ye.add(re),v=j(_.beta,N,xe,L,M)}else{let{p:L,f:I}=U(O);v=L,R=I}return Zo(P,[v,R])[0]}multiplyUnsafe(O){let{endo:_}=e,v=this;if(!o.isValid(O))throw new Error("invalid scalar: out of range");if(O===xn||v.is0())return P.ZERO;if(O===Es)return v;if(Q.hasCache(this))return this.multiply(O);if(_){let{k1neg:R,k1:U,k2neg:L,k2:I}=J(O),{p1:M,p2:q}=wb(P,v,U,I);return j(_.beta,M,q,R,L)}else return Q.unsafe(v,O)}toAffine(O){return z(this,O)}isTorsionFree(){let{isTorsionFree:O}=e;return s===Es?!0:O?O(P,this):Q.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:O}=e;return s===Es?this:O?O(P,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(O=!0){return bn(O,"isCompressed"),this.assertValidity(),g(P,this,O)}toHex(O=!0){return yn(this.toBytes(O))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=o.BITS,Q=new ms(P,e.endo?Math.ceil(X/2):X);return P.BASE.precompute(8),P}function Jb(r){return Uint8Array.of(r?2:3)}function Qb(r,e){return{secretKey:e.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function KE(r,e={}){let{Fn:t}=r,n=e.randomBytes||Jn,o=Object.assign(Qb(r.Fp,t),{seed:rd(t.ORDER)});function i(g){try{let m=t.fromBytes(g);return t.isValidNot0(m)}catch{return!1}}function s(g,m){let{publicKey:C,publicKeyUncompressed:d}=o;try{let S=g.length;return m===!0&&S!==C||m===!1&&S!==d?!1:!!r.fromBytes(g)}catch{return!1}}function a(g=n(o.seed)){return nd(he(g,o.seed,"seed"),t.ORDER)}function c(g,m=!0){return r.BASE.multiply(t.fromBytes(g)).toBytes(m)}function f(g){let{secretKey:m,publicKey:C,publicKeyUncompressed:d}=o;if(!$o(g)||"_lengths"in t&&t._lengths||m===C)return;let S=he(g,void 0,"key").length;return S===C||S===d}function p(g,m,C=!0){if(f(g)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let d=t.fromBytes(g);return r.fromBytes(m).multiply(d).toBytes(C)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},y=gs(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:p,keygen:y,Point:r,utils:l,lengths:o})}function ew(r,e,t={}){Fo(e),Gr(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),t=Object.assign({},t);let n=t.randomBytes||Jn,o=t.hmac||((_,v)=>As(e,_,v)),{Fp:i,Fn:s}=r,{ORDER:a,BITS:c}=s,{keygen:f,getPublicKey:p,getSharedSecret:l,utils:y,lengths:g}=KE(r,t),m={prehash:!0,lowS:typeof t.lowS=="boolean"?t.lowS:!0,format:"compact",extraEntropy:!1},C=a*Zb<i.ORDER;function d(_){let v=a>>Es;return _>v}function S(_,v){if(!s.isValidNot0(v))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return v}function D(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function B(_,v){Md(v);let R=g.signature,U=v==="compact"?R:v==="recovered"?R+1:void 0;return he(_,U)}class H{r;s;recovery;constructor(v,R,U){if(this.r=S("r",v),this.s=S("s",R),U!=null){if(D(),![0,1,2,3].includes(U))throw new Error("invalid recovery id");this.recovery=U}Object.freeze(this)}static fromBytes(v,R=m.format){B(v,R);let U;if(R==="der"){let{r:q,s:N}=io.toSig(he(v));return new H(q,N)}R==="recovered"&&(U=v[0],R="compact",v=v.subarray(1));let L=g.signature/2,I=v.subarray(0,L),M=v.subarray(L,L*2);return new H(s.fromBytes(I),s.fromBytes(M),U)}static fromHex(v,R){return this.fromBytes(mn(v),R)}assertRecovery(){let{recovery:v}=this;if(v==null)throw new Error("invalid recovery id: must be present");return v}addRecoveryBit(v){return new H(this.r,this.s,v)}recoverPublicKey(v){let{r:R,s:U}=this,L=this.assertRecovery(),I=L===2||L===3?R+a:R;if(!i.isValid(I))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let M=i.toBytes(I),q=r.fromBytes(Vt(Jb((L&1)===0),M)),N=s.inv(I),ye=z(he(v,void 0,"msgHash")),xe=s.create(-ye*N),re=s.create(U*N),Ae=r.BASE.multiplyUnsafe(xe).add(q.multiplyUnsafe(re));if(Ae.is0())throw new Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return d(this.s)}toBytes(v=m.format){if(Md(v),v==="der")return mn(io.hexFromSig(this));let{r:R,s:U}=this,L=s.toBytes(R),I=s.toBytes(U);return v==="recovered"?(D(),Vt(Uint8Array.of(this.assertRecovery()),L,I)):Vt(L,I)}toHex(v){return yn(this.toBytes(v))}}let J=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let R=ps(v),U=v.length*8-c;return U>0?R>>BigInt(U):R},z=t.bits2int_modN||function(v){return s.create(J(v))},oe=qa(c);function j(_){return ro("num < 2^"+c,_,xn,oe),s.toBytes(_)}function P(_,v){return he(_,void 0,"message"),v?he(e(_),void 0,"prehashed message"):_}function X(_,v,R){let{lowS:U,prehash:L,extraEntropy:I}=Ud(R,m);_=P(_,L);let M=z(_),q=s.fromBytes(v);if(!s.isValidNot0(q))throw new Error("invalid private key");let N=[j(q),j(M)];if(I!=null&&I!==!1){let Ae=I===!0?n(g.secretKey):I;N.push(he(Ae,void 0,"extraEntropy"))}let ye=Vt(...N),xe=M;function re(Ae){let Ne=J(Ae);if(!s.isValidNot0(Ne))return;let qe=s.inv(Ne),Ce=r.BASE.multiply(Ne).toAffine(),ke=s.create(Ce.x);if(ke===xn)return;let ln=s.create(qe*s.create(xe+ke*q));if(ln===xn)return;let wr=(Ce.x===ke?0:2)|Number(Ce.y&Es),Gn=ln;return U&&d(ln)&&(Gn=s.neg(ln),wr^=1),new H(ke,Gn,C?void 0:wr)}return{seed:ye,k2sig:re}}function Q(_,v,R={}){let{seed:U,k2sig:L}=X(_,v,R);return rb(e.outputLen,s.BYTES,o)(U,L).toBytes(R.format)}function $(_,v,R,U={}){let{lowS:L,prehash:I,format:M}=Ud(U,m);if(R=he(R,void 0,"publicKey"),v=P(v,I),!$o(_)){let q=_ instanceof H?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}B(_,M);try{let q=H.fromBytes(_,M),N=r.fromBytes(R);if(L&&q.hasHighS())return!1;let{r:ye,s:xe}=q,re=z(v),Ae=s.inv(xe),Ne=s.create(re*Ae),qe=s.create(ye*Ae),Ce=r.BASE.multiplyUnsafe(Ne).add(N.multiplyUnsafe(qe));return Ce.is0()?!1:s.create(Ce.x)===ye}catch{return!1}}function O(_,v,R={}){let{prehash:U}=Ud(R,m);return v=P(v,U),H.fromBytes(_,"recovered").recoverPublicKey(v).toBytes()}return Object.freeze({keygen:f,getPublicKey:p,getSharedSecret:l,utils:y,lengths:g,Point:r,sign:Q,verify:$,recoverPublicKey:O,Signature:H,hash:e})}var Vd={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},HE={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var tw=BigInt(2);function VE(r){let e=Vd.p,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,p=f*f*r%e,l=Ve(p,t,e)*p%e,y=Ve(l,t,e)*p%e,g=Ve(y,tw,e)*f%e,m=Ve(g,o,e)*g%e,C=Ve(m,i,e)*m%e,d=Ve(C,a,e)*C%e,S=Ve(d,c,e)*d%e,D=Ve(S,a,e)*C%e,B=Ve(D,t,e)*p%e,H=Ve(B,s,e)*m%e,J=Ve(H,n,e)*f%e,z=Ve(J,tw,e);if(!Hd.eql(Hd.sqr(z),r))throw new Error("Cannot find square root");return z}var Hd=ds(Vd.p,{sqrt:VE}),$E=Yb(Vd,{Fp:Hd,endo:HE}),Ir=ew($E,Wr);function rw(r,e,t){let n=ar.digest(e instanceof Uint8Array?e:e.subarray());if(xs(n))return n.then(({digest:o})=>(t?.signal?.throwIfAborted(),Ir.sign(o,r,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Ja(String(o))});try{return Ir.sign(n.digest,r,{prehash:!1,format:"der"})}catch(o){throw new Ja(String(o))}}function nw(r,e,t,n){let o=ar.digest(t instanceof Uint8Array?t:t.subarray());if(xs(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Ir.verify(e,i,r,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new Qa(String(i))});try{return n?.signal?.throwIfAborted(),Ir.verify(e,o.digest,r,{prehash:!1,format:"der"})}catch(i){throw new Qa(String(i))}}var cc=class{type="secp256k1";raw;_key;constructor(e){this._key=sw(e),this.raw=ow(this._key)}toMultihash(){return _r.digest(Yn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ze.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}verify(e,t,n){return nw(this._key,t,e,n)}},Wf=class{type="secp256k1";raw;publicKey;constructor(e,t){this.raw=iw(e),this.publicKey=new cc(t??aw(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ye(this.raw,e.raw)}sign(e,t){return rw(this.raw,e,t)}};function $d(r){return new cc(r)}async function cw(){let r=FE();return new Wf(r)}function ow(r){return Ir.Point.fromBytes(r).toBytes()}function iw(r){try{return Ir.getPublicKey(r,!0),r}catch(e){throw new Na(String(e))}}function sw(r){try{return Ir.Point.fromBytes(r),r}catch(e){throw new ns(String(e))}}function aw(r){try{return Ir.getPublicKey(r,!0)}catch(e){throw new Na(String(e))}}function FE(){return Ir.utils.randomSecretKey()}async function uw(r,e){if(r==="Ed25519")return kb();if(r==="secp256k1")return cw();if(r==="RSA")return Ld(WE(e));if(r==="ECDSA")return U0(qE(e));throw new zn}function uc(r,e){let{Type:t,Data:n}=zr.decode(r),o=n??new Uint8Array;switch(t){case nt.RSA:return Dd(o,e);case nt.Ed25519:return ud(o);case nt.secp256k1:return $d(o);case nt.ECDSA:return Hh(o);default:throw new zn}}function fw(r){let{Type:e,Data:t}=zr.decode(r.digest),n=t??new Uint8Array;switch(e){case nt.Ed25519:return ud(n);case nt.secp256k1:return $d(n);case nt.ECDSA:return Hh(n);default:throw new zn}}function Yn(r){return zr.encode({Type:nt[r.type],Data:r.raw})}function WE(r){return r==null?2048:parseInt(r,10)}function qE(r){if(r==="P-256"||r==null)return"P-256";if(r==="P-384")return"P-384";if(r==="P-521")return"P-521";throw new _e("Unsupported curve, should be P-256, P-384 or P-521")}async function qf(r){if(r.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(r.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"ECDSA",namedCurve:r.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"ECDSA",namedCurve:r.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new _e("Only RSA and ECDSA keys are supported")}var lw=Symbol.for("nodejs.util.inspect.custom"),GE=114,fc=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[dh]=!0;toString(){return this.string==null&&(this.string=Ze.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(GE,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ye(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return Ye(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[lw](){return`PeerId(${this.toString()})`}},lc=class extends fc{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},pc=class extends fc{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},hc=class extends fc{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},zE=2336,dc=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=_r.digest(me(this.url))}[lw](){return`PeerId(${this.url})`}[dh]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(zE,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=le(e)),e.toString()===this.toString())}};var XE=114,pw=2336;function Cs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=fs(Ze.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return ZE(ct.parse(r));if(e==null)throw new _e('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=fs(e.decode(r))}return hw(t)}function Fd(r){if(r.type==="Ed25519")return new pc({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new hc({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new lc({multihash:r.toCID().multihash,publicKey:r});throw new zn}function hw(r){if(JE(r))return new lc({multihash:r});if(YE(r))try{let e=fw(r);if(e.type==="Ed25519")return new pc({multihash:r,publicKey:e});if(e.type==="secp256k1")return new hc({multihash:r,publicKey:e})}catch{let t=le(r.digest);return new dc(new URL(t))}throw new mf("Supplied PeerID Multihash is invalid")}function ZE(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==XE&&r.code!==pw)throw new yf("Supplied PeerID CID is invalid");if(r.code===pw){let e=le(r.multihash.digest);return new dc(new URL(e))}return hw(r.multihash)}function YE(r){return r.code===_r.code}function JE(r){return r.code===ar.code}var bt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},vn=class extends Error{static name="ValidationError";name="ValidationError"},Gf=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},zf=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Xf=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let y=Number.parseInt(l,e);if(!Number.isNaN(y))return y});if(p===void 0)break;if(i*=e,i+=p,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var QE=45,e2=15,Zf=new Xf;function dw(r){if(!(r.length>e2))return Zf.new(r).parseWith(()=>Zf.readIPv4Addr())}function yw(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>QE))return Zf.new(r).parseWith(()=>Zf.readIPv6Addr())}function Yf(r){return!!dw(r)}function mw(r){return!!yw(r)}function qd(r){return e=>le(e,r)}function Gd(r){return e=>me(e,r)}function Ts(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ei(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function gw(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=me(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ei(n);return Rt([t,o],t.length+o.length)}function bw(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Zn.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ei(n);return Rt([t,o],t.length+o.length)}function zd(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=le(e,"base32"),o=Ts(t);return`${n}:${o}`}var Xd=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new bt("Invalid byte value in IP address");e[n]=o}),e},ww=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Yf(t[n]),s;i&&(s=Xd(t[n]),t[n]=le(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,le(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new bt("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},xw=function(r){if(r.byteLength!==4)throw new bt("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},vw=function(r){if(r.byteLength!==16)throw new bt("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new bt(`Invalid IPv6 address "${t}"`)}};function _w(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new bt(`Invalid IPv6 address "${r}"`)}}var Wd=Object.values(Ho).map(r=>r.decoder),t2=(function(){let r=Wd[0].or(Wd[1]);return Wd.slice(2).forEach(e=>r=r.or(e)),r})();function Sw(r){return t2.decode(r)}function Aw(r){return e=>r.encoder.encode(e)}function r2(r){if(parseInt(r).toString()!==r)throw new vn("Value must be an integer")}function n2(r){if(r<0)throw new vn("Value must be a positive integer, or zero")}function o2(r){return e=>{if(e>r)throw new vn(`Value must be smaller than or equal to ${r}`)}}function i2(...r){return e=>{for(let t of r)t(e)}}var yc=i2(r2,n2,o2(65535));var dt=-1,Zd=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new zf(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},_n=new Zd,x2=[{code:4,name:"ip4",size:32,valueToBytes:Xd,bytesToValue:xw,validate:r=>{if(!Yf(r))throw new vn(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ei,bytesToValue:Ts,validate:yc},{code:273,name:"udp",size:16,valueToBytes:ei,bytesToValue:Ts,validate:yc},{code:33,name:"dccp",size:16,valueToBytes:ei,bytesToValue:Ts,validate:yc},{code:41,name:"ip6",size:128,valueToBytes:ww,bytesToValue:vw,stringToValue:_w,validate:r=>{if(!mw(r))throw new vn(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:dt},{code:43,name:"ipcidr",size:8,bytesToValue:qd("base10"),valueToBytes:Gd("base10")},{code:53,name:"dns",size:dt},{code:54,name:"dns4",size:dt},{code:55,name:"dns6",size:dt},{code:56,name:"dnsaddr",size:dt},{code:132,name:"sctp",size:16,valueToBytes:ei,bytesToValue:Ts,validate:yc},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:dt,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:dt,bytesToValue:qd("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?Gd("base58btc")(r):ct.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:zd,valueToBytes:gw},{code:445,name:"onion3",size:296,bytesToValue:zd,valueToBytes:bw},{code:446,name:"garlic64",size:dt},{code:447,name:"garlic32",size:dt},{code:448,name:"tls"},{code:449,name:"sni",size:dt},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:dt,bytesToValue:Aw(Ko),valueToBytes:Sw},{code:480,name:"http"},{code:481,name:"http-path",size:dt,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:dt}];x2.forEach(r=>{_n.addProtocol(r)});function Ew(r){let e=[],t=0;for(;t<r.length;){let n=wn(r,t),o=_n.getProtocol(n),i=$e(n),s=v2(o,r,t+i),a=0;s>0&&o.size===dt&&(a=$e(s));let c=i+a+s,f={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(s>0){let p=t+i+a,l=r.subarray(p,p+s);f.value=o.bytesToValue?.(l)??le(l)}e.push(f),t+=c}return e}function Cw(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=_n.getProtocol(n.code),i=$e(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??me(n.value),a=s.byteLength,o.size===dt&&(c=$e(a)));let f=new Uint8Array(i+c+a),p=0;vs(n.code,f,p),p+=i,s!=null&&(o.size===dt&&(vs(a,f,p),p+=c),f.set(s,p)),n.bytes=f}t.push(n.bytes),e+=n.bytes.byteLength}return Rt(t,e)}function Tw(r){if(r.charAt(0)!=="/")throw new bt('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=_n.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new bt(`Component ${o} was missing value`);t="value"}else if(t==="value"){let f={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new bt(`Component ${o} was missing value`);f.value=c.stringToValue?.(n)??n}e.push(f),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new bt("Incomplete multiaddr");return e}function Ow(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=_n.getProtocol(e.code);if(t==null)throw new bt(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function v2(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:wn(e,t)}var _2=Symbol.for("nodejs.util.inspect.custom"),hy=Symbol.for("@multiformats/multiaddr");function S2(r){if(r==null&&(r="/"),Bw(r))return r.getComponents();if(r instanceof Uint8Array)return Ew(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),Tw(r);if(Array.isArray(r))return r;throw new bt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var tl=class r{[hy]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=S2(e),t.validate!==!1&&A2(this)}get bytes(){return this.#r==null&&(this.#r=Cw(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Ow(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Gf(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}equals(e){return Ye(this.bytes,e.bytes)}[_2](){return`Multiaddr(${this.toString()})`}};function A2(r){r.getComponents().forEach(e=>{let t=_n.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function Bw(r){return!!r?.[hy]}function Ps(r){return new tl(r)}var Ue=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),fe=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),Iw=r=>({match:e=>r.match(e)===!1?e:!1}),Ee=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),Pt=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1}}),Re=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function Me(...r){function e(o){if(o==null)return!1;let i=o.getComponents();for(let s of r){let a=s.match(i);if(a===!1)return!1;i=a}return i}function t(o){return e(o)!==!1}function n(o){let i=e(o);return i===!1?!1:i.length===0}return{matchers:r,matches:t,exactMatch:n}}var E2=fe(421),y8=Me(E2),nl=fe(54),ol=fe(55),il=fe(56),yy=fe(53),m8=Me(nl,Ee(fe(421))),g8=Me(ol,Ee(fe(421))),b8=Me(il,Ee(fe(421))),w8=Me(Pt(yy,il,nl,ol),Ee(fe(421))),Pw=Re(fe(4),Ee(fe(43))),Nw=Re(Ee(fe(42)),fe(41),Ee(fe(43))),my=Pt(Pw,Nw),ni=Pt(my,yy,nl,ol,il),x8=Me(Pt(my,Re(Pt(yy,il,nl,ol),Ee(fe(421))))),v8=Me(Pw),_8=Me(Nw),S8=Me(my),gy=Re(ni,fe(6)),mc=Re(ni,fe(273)),A8=Me(Re(gy,Ee(fe(421)))),E8=Me(mc),by=Re(mc,Ue(460),Ee(fe(421))),sl=Re(mc,Ue(461),Ee(fe(421))),C2=Pt(by,sl),C8=Me(by),T8=Me(sl),dy=Pt(ni,gy,mc,by,sl),kw=Pt(Re(dy,Ue(477),Ee(fe(421)))),O8=Me(kw),Dw=Pt(Re(dy,Ue(478),Ee(fe(421))),Re(dy,Ue(448),Ee(fe(449)),Ue(477),Ee(fe(421)))),B8=Me(Dw),Rw=Re(mc,Ue(280),Ee(fe(466)),Ee(fe(466)),Ee(fe(421))),jw=Me(Rw),Lw=Re(sl,Ue(465),Ee(fe(466)),Ee(fe(466)),Ee(fe(421))),I8=Me(Lw),rl=Pt(kw,Dw,Re(gy,Ee(fe(421))),Re(C2,Ee(fe(421))),Re(ni,Ee(fe(421))),Rw,Lw,fe(421)),Uw=Me(rl),T2=Re(Ee(rl),Ue(290),Iw(Ue(281)),Ee(fe(421))),P8=Me(T2),O2=Pt(Re(rl,Ue(290),Ue(281),Ee(fe(421))),Re(rl,Ue(281),Ee(fe(421))),Re(Ue(281),Ee(fe(421)))),Mw=Me(O2),B2=Pt(Re(ni,fe(6),Ue(480),Ee(fe(421))),Re(ni,Ue(480),Ee(fe(421)))),N8=Me(B2),I2=Re(ni,Pt(Re(fe(6,"443"),Ue(480)),Re(fe(6),Ue(443)),Re(fe(6),Ue(448),Ue(480)),Re(Ue(448),Ue(480)),Ue(448),Ue(443)),Ee(fe(421))),k8=Me(I2),P2=Pt(Re(fe(777),Ee(fe(421)))),D8=Me(P2),N2=Pt(Re(fe(400),Ee(fe(421)))),R8=Me(N2);var Nt;(function(r){let e;(function(o){o.FIN="FIN",o.STOP_SENDING="STOP_SENDING",o.RESET="RESET",o.FIN_ACK="FIN_ACK"})(e=r.Flag||(r.Flag={}));let t;(function(o){o[o.FIN=0]="FIN",o[o.STOP_SENDING=1]="STOP_SENDING",o[o.RESET=2]="RESET",o[o.FIN_ACK=3]="FIN_ACK"})(t||(t={})),(function(o){o.codec=()=>Qo(t)})(e=r.Flag||(r.Flag={}));let n;r.codec=()=>(n==null&&(n=Br((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.flag!=null&&(i.uint32(8),r.Flag.codec().encode(o.flag,i)),o.message!=null&&(i.uint32(18),i.bytes(o.message)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.flag=r.Flag.codec().decode(o);break}case 2:{a.message=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Or(o,r.codec()),r.decode=(o,i)=>Tr(o,r.codec(),i)})(Nt||(Nt={}));var Kw=["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478","stun:stun.cloudflare.com:3478","stun:stun.services.mozilla.com:3478"],wy=Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),Hw="libp2p+webrtc+v1/",Vw=2*1024*1024,Ns=16*1024;function k2(r=Ns){let e=$e(r-$e(r)),t=1+$e(Object.keys(Nt.Flag).length-1),n=1,o=r-e-t-n,i=$e(o);return e+t+n+i}var $w=k2();var Fw=1e4,xy="/webrtc",gc="/webrtc-signaling/0.0.1",Ww="/libp2p/webrtc-direct/certificate",qw="webrtc-direct-certificate-private-key";var Gw=12096e5,vy=864e5;function _y(r){let e=r.getComponents(),t={},n=0;if(e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n].name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null)throw new _e(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t}function al(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var cl=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},ks=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new cl(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new cl(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Sy=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Ds(r={}){return D2(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function D2(r,e){e=e??{};let t=e.onEnd,n=new ks,o,i,s,a=al(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((d,S)=>{i=D=>{i=null,n.push(D);try{d(r(n))}catch(B){S(B)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=al()})}},f=d=>i!=null?i(d):(n.push(d),o),p=d=>(n=new ks,i!=null?i({error:d}):(n.push({error:d}),o)),l=d=>{if(s)return o;if(e?.objectMode!==!0&&d?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:d})},y=d=>s?o:(s=!0,d!=null?p(d):f({done:!0})),g=()=>(n=new ks,y(),{done:!0}),m=d=>(y(d),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:g,throw:m,push:l,end:y,get readableLength(){return n.size},onEmpty:async d=>{let S=d?.signal;if(S?.throwIfAborted(),n.isEmpty())return;let D,B;S!=null&&(D=new Promise((H,J)=>{B=()=>{J(new Sy)},S.addEventListener("abort",B)}));try{await Promise.race([a.promise,D])}finally{B!=null&&S!=null&&S?.removeEventListener("abort",B)}}},t==null)return o;let C=o;return o={[Symbol.asyncIterator](){return this},next(){return C.next()},throw(d){return C.throw(d),t!=null&&(t(d),t=void 0),{done:!0}},return(){return C.return(),t!=null&&(t(),t=void 0),{done:!0}},push:l,end(d){return C.end(d),t!=null&&(t(d),t=void 0),o},get readableLength(){return C.readableLength},onEmpty:d=>C.onEmpty(d)},o}var Ay=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ey=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},zw=r=>globalThis.DOMException===void 0?new Ey(r):new DOMException(r),Xw=r=>{let e=r.reason===void 0?zw("This operation was aborted."):r.reason;return e instanceof Error?e:zw(e)};function Cy(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,f=new Promise((p,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:g}=e;g.aborted&&l(Xw(g)),a=()=>{l(Xw(g))},g.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(p,l);return}let y=new Ay;s=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(g){l(g)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?p():o instanceof Error?l(o):(y.message=o??`Promise timed out after ${t} milliseconds`,l(y))},t),(async()=>{try{p(await r)}catch(g){l(g)}})()}).finally(()=>{f.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}var R2=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function j2(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:f,removeListener:p}=R2(r),l=async(...g)=>{let m=t.multiArgs?g:g[0];if(t.filter)try{if(!await t.filter(m))return}catch(C){n(),s(C);return}c.push(m),t.count===c.length&&(n(),i(c))},y=(...g)=>{n(),s(t.rejectionMultiArgs?g:g[0])};n=()=>{for(let g of a)p(g,l);for(let g of t.rejectionEvents)a.includes(g)||p(g,y)};for(let g of a)f(g,l);for(let g of t.rejectionEvents)a.includes(g)||f(g,y);t.signal&&t.signal.addEventListener("abort",()=>{y(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=Cy(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function wt(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=j2(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}var oi=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"},ul=class extends Error{static name="MaxEarlyStreamsError";name="MaxEarlyStreamsError"},fl=class extends Error{static name="StreamClosedError";name="StreamClosedError"};function L2(r){return r.reason}async function ao(r,e,t){if(e==null)return r;let n=t?.translateError??L2;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var U2=Math.pow(2,20)*4,co=class extends sr{status;timeline;inactivityTimeout;maxReadBufferLength;maxWriteBufferLength;log;direction;maxMessageSize;readStatus;writeStatus;remoteReadStatus;remoteWriteStatus;writableNeedsDrain;readBuffer;writeBuffer;sendingData;onDrainPromise;constructor(e){super(),this.status="open",this.log=e.log,this.direction=e.direction??"outbound",this.inactivityTimeout=e.inactivityTimeout??12e4,this.maxReadBufferLength=e.maxReadBufferLength??U2,this.maxWriteBufferLength=e.maxWriteBufferLength,this.maxMessageSize=e.maxMessageSize,this.readBuffer=new ge,this.writeBuffer=new ge,this.readStatus="readable",this.remoteReadStatus="readable",this.writeStatus="writable",this.remoteWriteStatus="writable",this.sendingData=!1,this.writableNeedsDrain=!1,this.timeline={open:Date.now()},this.processSendQueue=this.processSendQueue.bind(this);let t=()=>{this.writableNeedsDrain&&(this.log.trace("drain event received, continue sending data"),this.writableNeedsDrain=!1,this.processSendQueue()),this.onDrainPromise?.resolve()};this.addEventListener("drain",t);let n=o=>{this.onDrainPromise?.reject(o.error??new fl)};this.addEventListener("close",n)}get readBufferLength(){return this.readBuffer.byteLength}get writeBufferLength(){return this.writeBuffer.byteLength}async onDrain(e){return this.writableNeedsDrain!==!0?Promise.resolve():(this.onDrainPromise==null&&(this.onDrainPromise=Promise.withResolvers()),ao(this.onDrainPromise.promise,e?.signal))}async*[Symbol.asyncIterator](){if(this.readStatus!=="readable"&&this.readStatus!=="paused")return;let e=Ds(),t=i=>{e.push(i.data)};this.addEventListener("message",t);let n=i=>{e.end(i.error)};this.addEventListener("close",n);let o=()=>{e.end()};this.addEventListener("remoteCloseWrite",o);try{yield*e}finally{this.removeEventListener("message",t),this.removeEventListener("close",n),this.removeEventListener("remoteCloseWrite",o)}}isReadable(){return this.status==="open"}send(e){if(this.writeStatus==="closed"||this.writeStatus==="closing")throw new $r(`Cannot write to a stream that is ${this.writeStatus}`);return this.log.trace("append %d bytes to write buffer",e.byteLength),this.writeBuffer.append(e),this.processSendQueue()}abort(e){if(!(this.status==="aborted"||this.status==="reset"||this.status==="closed")){this.log.error("abort with error - %e",e),this.status="aborted",this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle")),this.writeStatus="closed",this.remoteWriteStatus="closed",this.readStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now();try{this.sendReset(e)}catch(t){this.log("failed to send reset to remote - %e",t)}this.dispatchEvent(new xf(e))}}pause(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new $r("Cannot pause a stream that is closing/closed");this.readStatus!=="paused"&&(this.readStatus="paused",this.sendPause())}resume(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new $r("Cannot resume a stream that is closing/closed");this.readStatus!=="readable"&&(this.readStatus="readable",this.dispatchReadBuffer(),this.sendResume())}push(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new $r(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.append(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}unshift(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new $r(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.prepend(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}onData(e){if(e.byteLength!==0){if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("ignoring data - read status %s",this.readStatus);return}this.readBuffer.append(e),this.dispatchReadBuffer()}}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="message"&&this.readBuffer.byteLength>0&&queueMicrotask(()=>{this.dispatchReadBuffer()})}onRemoteReset(){this.log("remote reset"),this.status="reset",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now(),this.readBuffer.byteLength===0&&(this.readStatus="closed");let e=new os;this.dispatchEvent(new vf(e))}onTransportClosed(e){this.log("transport closed"),this.readStatus==="readable"&&this.readBuffer.byteLength===0&&(this.log("close readable end after transport closed and read buffer is empty"),this.readStatus="closed"),this.remoteReadStatus!=="closed"&&(this.remoteReadStatus="closed"),this.remoteWriteStatus!=="closed"&&(this.remoteWriteStatus="closed"),this.writeStatus!=="closed"&&(this.writeStatus="closed"),e!=null?this.abort(e):(this.status==="open"||this.status==="closing")&&(this.timeline.close=Date.now(),this.status="closed",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.dispatchEvent(new is))}onRemoteCloseWrite(){this.remoteWriteStatus!=="closed"&&(this.log.trace("on remote close write"),this.remoteWriteStatus="closed",this.safeDispatchEvent("remoteCloseWrite"),this.writeStatus==="closed"&&this.onTransportClosed())}onRemoteCloseRead(){this.log.trace("on remote close read"),this.remoteReadStatus="closed",this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle"))}processSendQueue(){if(this.writableNeedsDrain)return this.log.trace("not processing send queue as drain is required"),this.checkWriteBufferLength(),!1;if(this.writeBuffer.byteLength===0)return this.log.trace("not processing send queue as no bytes to send"),!0;if(this.sendingData)return this.log.trace("not processing send queue as already sending data"),!0;this.sendingData=!0,this.log.trace("processing send queue with %d queued bytes",this.writeBuffer.byteLength);try{let e=!0,t=this.writeBuffer.byteLength,n=0;for(;this.writeBuffer.byteLength>0;){let o=Math.min(this.maxMessageSize??this.writeBuffer.byteLength,this.writeBuffer.byteLength);if(o===0){e=!1;break}let i=this.writeBuffer.sublist(0,o),s=new ge(i);this.writeBuffer.consume(i.byteLength);let a=this.sendData(i);if(e=a.canSendMore,n+=a.sentBytes,a.sentBytes!==s.byteLength&&(s.consume(a.sentBytes),this.writeBuffer.prepend(s)),!e)break}return e||(this.log.trace("sent %d/%d bytes, pausing sending because underlying stream is full, %d bytes left in the write buffer",n,t,this.writeBuffer.byteLength),this.writableNeedsDrain=!0,this.checkWriteBufferLength()),this.writeBuffer.byteLength===0&&this.safeDispatchEvent("idle"),e}finally{this.sendingData=!1}}dispatchReadBuffer(){try{if(this.listenerCount("message")===0){this.log.trace("not dispatching pause buffer as there are no listeners for the message event");return}if(this.readBuffer.byteLength===0){this.log.trace("not dispatching pause buffer as there is no data to dispatch");return}if(this.readStatus==="paused"){this.log.trace("not dispatching pause buffer we are paused");return}if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("dropping %d bytes because the readable end is %s",this.readBuffer.byteLength,this.readStatus),this.readBuffer.consume(this.readBuffer.byteLength);return}let e=this.readBuffer.sublist();this.readBuffer.consume(e.byteLength),this.dispatchEvent(new wf(e))}finally{this.readBuffer.byteLength===0&&this.remoteWriteStatus==="closed"&&(this.log("close readable end after dispatching read buffer and remote writable end is closed"),this.readStatus="closed"),this.checkReadBufferLength()}}checkReadBufferLength(){this.readBuffer.byteLength>this.maxReadBufferLength&&this.abort(new ka(`Read buffer length of ${this.readBuffer.byteLength} exceeded limit of ${this.maxReadBufferLength}, read status is ${this.readStatus}`))}checkWriteBufferLength(){this.maxWriteBufferLength!=null&&this.writeBuffer.byteLength>this.maxWriteBufferLength&&this.abort(new ka(`Write buffer length of ${this.writeBuffer.byteLength} exceeded limit of ${this.maxWriteBufferLength}, write status is ${this.writeStatus}`))}onMuxerNeedsDrain(){this.writableNeedsDrain=!0}onMuxerDrain(){this.safeDispatchEvent("drain")}};var ll=class extends co{remoteAddr;metricPrefix;metrics;constructor(e){super(e),this.metricPrefix=e.metricPrefix??"",this.metrics=e.metrics,this.remoteAddr=e.remoteAddr,this.addEventListener("close",t=>{this.metrics?.increment({[`${this.metricPrefix}end`]:!0}),t.error!=null?t.local?this.metrics?.increment({[`${this.metricPrefix}abort`]:!0}):this.metrics?.increment({[`${this.metricPrefix}reset`]:!0}):t.local?this.metrics?.increment({[`${this.metricPrefix}_local_close`]:!0}):this.metrics?.increment({[`${this.metricPrefix}_remote_close`]:!0})})}async close(e){this.status==="open"&&(this.status="closing",this.writeStatus="closing",this.remoteWriteStatus="closing",this.remoteReadStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await wt(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await wt(this,"drain",{...e,rejectionEvents:["close"]})),await this.sendClose(e),this.onTransportClosed())}};function Zw(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var pl=class extends sr{streams;protocol;status;log;maConn;streamOptions;earlyStreams;maxEarlyStreams;metrics;constructor(e,t){super(),this.maConn=e,this.protocol=t.protocol,this.streams=[],this.earlyStreams=[],this.status="open",this.log=e.log.newScope(t.name),this.streamOptions=t.streamOptions,this.maxEarlyStreams=t.maxEarlyStreams??10,this.metrics=t.metrics;let n=s=>{try{this.onData(s.data)}catch(a){this.abort(a),this.maConn.abort(a)}};this.maConn.addEventListener("message",n);let o=()=>{this.log("underlying stream drained, signal %d streams to continue writing",this.streams.length),this.streams.forEach(s=>{s.onMuxerDrain()})};this.maConn.addEventListener("drain",o);let i=()=>{this.log("underlying stream closed with status %s and %d streams",this.status,this.streams.length),this.onTransportClosed()};this.maConn.addEventListener("close",i)}send(e){let t=this.maConn.send(e);return t===!1&&(this.log("underlying stream saturated, signal %d streams to pause writing",this.streams.length),this.streams.forEach(n=>{n.onMuxerNeedsDrain()})),t}async close(e){this.status==="closed"||this.status==="closing"||(this.status="closing",await ao(Promise.all([...this.streams].map(async t=>{await t.close(e)})),e?.signal),this.status="closed")}abort(e){this.status!=="closed"&&(this.status="closing",[...this.streams].forEach(t=>{t.abort(e)}),this.status="closed")}onTransportClosed(e){this.status="closing";try{[...this.streams].forEach(t=>{t.onTransportClosed(e)})}catch(t){this.abort(t)}this.status="closed"}async createStream(e){if(this.status!=="open")throw new hf;let t=this.onCreateStream({...this.streamOptions,...e});return Zw(t)&&(t=await t),this.streams.push(t),this.cleanUpStream(t),t}onRemoteStream(e){if(this.streams.push(e),this.cleanUpStream(e),this.listenerCount("stream")===0){this.earlyStreams.push(e),this.earlyStreams.length>this.maxEarlyStreams&&this.abort(new ul(`Too many early streams were opened - ${this.earlyStreams.length}/${this.maxEarlyStreams}`));return}this.safeDispatchEvent("stream",{detail:e})}cleanUpStream(e){let t=n=>{let o=this.streams.findIndex(i=>i===e);o!==-1&&this.streams.splice(o,1),n.error!=null?n.local?this.metrics?.increment({[`${e.direction}_stream_reset`]:!0}):this.metrics?.increment({[`${e.direction}_stream_abort`]:!0}):this.metrics?.increment({[`${e.direction}_stream_end`]:!0})};e.addEventListener("close",t),this.metrics?.increment({[`${e.direction}_stream`]:!0})}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="stream"&&this.earlyStreams.length>0&&queueMicrotask(()=>{this.earlyStreams.forEach(t=>{this.safeDispatchEvent("stream",{detail:t})}),this.earlyStreams=[]})}};var hl=class extends co{id;protocol;constructor(e){super(e),this.id=e.id,this.protocol=e.protocol??""}async close(e){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.writeStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await wt(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData),await wt(this,"drain",{...e,rejectionEvents:["close"]}),this.log("write queue drained, closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData)),await this.sendCloseWrite(e),this.writeStatus="closed",this.log("closed writable end gracefully"),this.remoteWriteStatus==="closed"&&this.onTransportClosed())}async closeRead(e){this.readStatus==="closing"||this.readStatus==="closed"||(this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.readStatus="closing",await this.sendCloseRead(e),this.readStatus="closed",this.log("closed readable end gracefully"))}};var M2=4194304,dl=class extends Error{static name="UnwrappedError";name="UnwrappedError"},bc=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Oy=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},By=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function K2(r){return typeof r?.closeRead=="function"}function H2(r){return typeof r?.close=="function"}function Ty(r){return K2(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:H2(r)?r.status!=="open":!1}function V2(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function $2(r,e){let t=e?.maxBufferSize??M2,n=new ge,o,i=!1;if(!V2(r))throw new _e("Argument should be a Stream or a Multiaddr");let s=p=>{if(n.append(p.data),n.byteLength>t){let l=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${l} > ${t}`))}o?.resolve()};r.addEventListener("message",s);let a=p=>{p.error!=null?o?.reject(p.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let f={readBuffer:n,async read(p){if(i===!0)throw new dl("Stream was unwrapped");if(Ty(r)){if(p?.bytes==null)return null;if(n.byteLength<p.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,p.bytes),new oi(`Unexpected EOF - stream closed after reading ${n.byteLength}/${p.bytes} bytes`)}let l=p?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=l){o.resolve();break}if(await ao(o.promise,p?.signal),Ty(r)){if(n.byteLength===0&&p?.bytes==null)return null;break}o=Promise.withResolvers()}let y=p?.bytes??n.byteLength;if(n.byteLength<y){if(Ty(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,y),new oi(`Unexpected EOF - stream closed while reading ${n.byteLength}/${y} bytes`);return f.read(p)}let g=n.sublist(0,y);return n.consume(y),g},async write(p,l){if(i===!0)throw new dl("Stream was unwrapped");r.send(p)||await wt(r,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return i||(i=!0,r.removeEventListener("message",s),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.push(n))),r}};return f}function yl(r,e={}){let t=$2(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=$e(e.maxDataLength));let n=e?.lengthDecoder??wn,o=e?.lengthEncoder??Mf;return{async read(s){let a=-1,c=new ge;for(;;){let p=await t.read({...s,bytes:1});if(p==null)break;c.append(p);try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new bc("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new By(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Oy(`Message length too long - ${a} > ${e.maxDataLength}`);let f=await t.read({...s,bytes:a});if(f==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new oi(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(f.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",f.byteLength,a),new oi(`Unexpected EOF - read ${f.byteLength}/${a} bytes before the stream closed`);return f},async write(s,a){await t.write(new ge(o(s.byteLength),s),a)},async writeV(s,a){let c=new ge(...s.flatMap(f=>[o(f.byteLength),f]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function ml(r,e){let t=yl(r,e),n={read:async(o,i)=>{let s=await t.read(i);return o.decode(s)},write:async(o,i,s)=>{await t.write(i.encode(o),s)},writeV:async(o,i,s)=>{await t.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var F2=1024*1024*4,W2=1024*1024*4,gl=class{buffer;maxBufferSize;lengthDecoder;maxDataLength;encodingLength;constructor(e={}){this.buffer=new ge,this.maxBufferSize=e.maxBufferSize??F2,this.maxDataLength=e.maxDataLength??W2,this.lengthDecoder=e.lengthDecoder??wn,this.encodingLength=e.encodingLength??$e}*decode(e){if(this.buffer.append(e),this.buffer.byteLength>this.maxBufferSize)throw new _e(`Buffer length limit exceeded - ${this.buffer.byteLength}/${this.maxBufferSize}`);for(;;){let t;try{t=this.lengthDecoder(this.buffer)}catch(i){if(i instanceof RangeError)break;throw i}if(t<0||t>this.maxDataLength)throw new bc("Invalid message length");let n=this.encodingLength(t),o=n+t;if(this.buffer.byteLength>=o){let i=this.buffer.sublist(n,o);this.buffer.consume(o),i.byteLength>0&&(yield i)}else break}}};var bl=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Rs=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},wl=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},wc=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function xl(r){return r[Symbol.asyncIterator]!=null}function Yw(r,e){if(r.byteLength>e)throw new Rs("Message length too long")}var _l=r=>{let e=$e(r),t=ft(e);return Mf(r,t),_l.bytes=e,t};_l.bytes=0;function xc(r,e){e=e??{};let t=e.lengthEncoder??_l,n=e?.maxDataLength??4194304;function*o(i){Yw(i,n);let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return xl(r)?(async function*(){for await(let i of r)yield*o(i)})():(function*(){for(let i of r)yield*o(i)})()}xc.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??_l,n=e?.maxDataLength??4194304;return Yw(r,n),new ge(t(r.byteLength),r)};var ii;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(ii||(ii={}));var Iy=r=>{let e=wn(r);return Iy.bytes=$e(e),e};Iy.bytes=0;function vc(r,e){let t=new ge,n=ii.LENGTH,o=-1,i=e?.lengthDecoder??Iy,s=e?.maxLengthLength??8,a=e?.maxDataLength??4194304;function*c(){for(;t.byteLength>0;){if(n===ii.LENGTH)try{if(o=i(t),o<0)throw new bl("Invalid message length");if(o>a)throw new Rs("Message length too long");let f=i.bytes;t.consume(f),e?.onLength!=null&&e.onLength(o),n=ii.DATA}catch(f){if(f instanceof RangeError){if(t.byteLength>s)throw new wl("Message length length too long");break}throw f}if(n===ii.DATA){if(t.byteLength<o)break;let f=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(f),yield f,n=ii.LENGTH}}}return xl(r)?(async function*(){for await(let f of r)t.append(f),yield*c();if(t.byteLength>0)throw new wc("Unexpected end of input")})():(function*(){for(let f of r)t.append(f),yield*c();if(t.byteLength>0)throw new wc("Unexpected end of input")})()}vc.fromReader=(r,e)=>{let t=1,n=(async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}})();return vc(n,{...e??{},onLength:i=>{t=i}})};var Jw=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))},z2=(function(){function r(e,t,n){this.name=e,this.version=t,this.os=n,this.type="browser"}return r})();var X2=(function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r})();var Z2=(function(){function r(e,t,n,o){this.name=e,this.version=t,this.os=n,this.bot=o,this.type="bot-device"}return r})();var Y2=(function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r})();var J2=(function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r})();var Q2=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,eC=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Qw=3,tC=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Q2]],ex=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function rx(r){return r?tx(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new J2:typeof navigator<"u"?tx(navigator.userAgent):oC()}function rC(r){return r!==""&&tC.reduce(function(e,t){var n=t[0],o=t[1];if(e)return e;var i=o.exec(r);return!!i&&[n,i]},!1)}function tx(r){var e=rC(r);if(!e)return null;var t=e[0],n=e[1];if(t==="searchbot")return new Y2;var o=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);o?o.length<Qw&&(o=Jw(Jw([],o,!0),iC(Qw-o.length),!0)):o=[];var i=o.join("."),s=nC(r),a=eC.exec(r);return a&&a[1]?new Z2(t,i,s,a[1]):new z2(t,i,s)}function nC(r){for(var e=0,t=ex.length;e<t;e++){var n=ex[e],o=n[0],i=n[1],s=i.exec(r);if(s)return o}return null}function oC(){var r=typeof process<"u"&&process.version;return r?new X2(process.version.slice(1)):null}function iC(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var nx=rx(),Sl=nx!=null&&nx.name==="firefox";async function Py(r){return r=r??{},typeof r=="function"&&(r=await r()),r.iceServers=r.iceServers??Kw.map(e=>({urls:[e]})),r}var ox=(r=32)=>Hw+[...Array(r)].map(()=>wy.at(Math.floor(Math.random()*wy.length))).join("");var Ny=class extends hl{channel;incomingData;maxBufferedAmount;receivedFinAck;finAckTimeout;constructor(e){super({...e,maxMessageSize:(e.maxMessageSize??Ns)-$w}),this.channel=e.channel,this.channel.binaryType="arraybuffer",this.incomingData=Ds(),this.maxBufferedAmount=e.maxBufferedAmount??Vw,this.finAckTimeout=e.finAckTimeout??Fw,this.channel.onclose=()=>{this.log.trace("received datachannel close event"),this.onRemoteCloseWrite(),this.onTransportClosed()},this.channel.onerror=n=>{let o=n.error;this.log.trace("received datachannel error event - %e",o),this.abort(o)},this.channel.onmessage=async n=>{this.log("incoming message %d bytes",n.data.byteLength);let{data:o}=n;o===null||o.byteLength===0||this.incomingData.push(new Uint8Array(o,0,o.byteLength))},this.channel.bufferedAmountLowThreshold=0,this.channel.onbufferedamountlow=()=>{this.writableNeedsDrain&&this.safeDispatchEvent("drain")},Promise.resolve().then(async()=>{for await(let n of vc(this.incomingData))this.processIncomingProtobuf(n)}).catch(n=>{this.log.error("error processing incoming data channel messages - %e",n)});let t=()=>{this.channel.readyState==="open"&&(this.log.trace("stream closed, closing underlying datachannel"),this.channel.close())};this.addEventListener("close",t),this.channel.readyState!=="open"&&(this.log('channel ready state is "%s" and not "open", waiting for "open" event before sending data',this.channel.readyState),wt(this.channel,"open",{rejectionEvents:["close","error"]}).then(()=>{this.log('channel ready state is now "%s", dispatching drain',this.channel.readyState),this.safeDispatchEvent("drain")}).catch(n=>{this.abort(n.error??n)}))}sendNewStream(){}_sendMessage(e){if(this.channel.readyState!=="open")throw new $r(`Invalid datachannel state - ${this.channel.readyState}`);if(this.log.trace('sending message, channel state "%s"',this.channel.readyState),Sl){this.channel.send(e.subarray());return}for(let t of e)this.channel.send(t)}sendData(e){return this.channel.readyState!=="open"?{sentBytes:0,canSendMore:!1}:(this._sendMessage(xc.single(Nt.encode({message:e.subarray()}))),{sentBytes:e.byteLength,canSendMore:this.channel.bufferedAmount<this.maxBufferedAmount})}sendReset(e){try{this.log.error("sending reset - %e",e),this._sendFlag(Nt.Flag.RESET),this.receivedFinAck?.reject(e)}catch(t){this.log.error("failed to send reset - %e",t)}}async sendCloseWrite(e){this._sendFlag(Nt.Flag.FIN),e?.signal?.throwIfAborted(),this.receivedFinAck=Promise.withResolvers();let t=e?.signal??AbortSignal.timeout(this.finAckTimeout),n=[wt(this.channel,"close",{signal:t}),wt(this.channel,"error",{signal:t})];await Promise.any([ao(this.receivedFinAck.promise,t),...n]).finally(()=>{n.forEach(o=>o.cancel())})}async sendCloseRead(e){this._sendFlag(Nt.Flag.STOP_SENDING),e?.signal?.throwIfAborted()}processIncomingProtobuf(e){let t=Nt.decode(e);t.message!=null&&(this.readStatus==="readable"||this.readStatus==="paused")&&this.onData(new ge(t.message)),t.flag!==void 0&&(this.log.trace('incoming flag %s, write status "%s", read status "%s"',t.flag,this.writeStatus,this.readStatus),t.flag===Nt.Flag.FIN&&(this._sendFlag(Nt.Flag.FIN_ACK),this.onRemoteCloseWrite()),t.flag===Nt.Flag.RESET&&(this.receivedFinAck?.reject(new os("The stream was reset")),this.onRemoteReset()),t.flag===Nt.Flag.STOP_SENDING&&this.onRemoteCloseRead(),t.flag===Nt.Flag.FIN_ACK&&this.receivedFinAck?.resolve())}_sendFlag(e){if(this.channel.readyState!=="open")return this.log.trace('not sending flag %s because channel is "%s" and not "open"',e.toString(),this.channel.readyState),!1;this.log.trace("sending flag %s",e.toString());let t=Nt.encode({flag:e}),n=xc.single(t);try{return this._sendMessage(n),!0}catch(o){this.log.error("could not send flag %s - %e",e.toString(),o)}return!1}sendPause(){}sendResume(){}};function _c(r){let{channel:e,direction:t,isHandshake:n}=r;return new Ny({...r,id:`${e.id}`,log:r.log.newScope(`${n===!0?"handshake":t}:${e.id}`),protocol:""})}var uo=class{protocol;peerConnection;metrics;dataChannelOptions;earlyDataChannels;constructor(e){this.onEarlyDataChannel=this.onEarlyDataChannel.bind(this),this.peerConnection=e.peerConnection,this.metrics=e.metrics,this.protocol=e.protocol??xy,this.dataChannelOptions=e.dataChannelOptions??{},this.peerConnection.addEventListener("datachannel",this.onEarlyDataChannel),this.earlyDataChannels=[]}onEarlyDataChannel(e){this.earlyDataChannels.push(e.channel)}createStreamMuxer(e){return this.peerConnection.removeEventListener("datachannel",this.onEarlyDataChannel),new ky(e,{peerConnection:this.peerConnection,dataChannelOptions:this.dataChannelOptions,metrics:this.metrics,protocol:this.protocol,earlyDataChannels:this.earlyDataChannels})}},ky=class extends pl{peerConnection;dataChannelOptions;constructor(e,t){super(e,{...t,name:"muxer"}),this.peerConnection=t.peerConnection,this.protocol=t.protocol??xy,this.dataChannelOptions=t.dataChannelOptions??{},this.peerConnection.ondatachannel=({channel:n})=>{this.onDataChannel(n)},queueMicrotask(()=>{if(this.status!=="open"){t.earlyDataChannels.forEach(n=>{n.close()});return}t.earlyDataChannels.forEach(n=>{this.onDataChannel(n)})})}onDataChannel(e){if(this.log("incoming datachannel with channel id %d, protocol %s and status %s",e.id,e.protocol,e.readyState),e.label==="init"){this.log.trace("closing init channel %d",e.id),e.close();return}let t=_c({...this.streamOptions,...this.dataChannelOptions,channel:e,direction:"inbound",log:this.log});this.onRemoteStream(t)}async onCreateStream(e){let t=this.peerConnection.createDataChannel("",{});return this.log("open channel %d for protocol %s",t.id,e?.protocol),_c({...e,...this.dataChannelOptions,channel:t,direction:"outbound",log:this.log})}onData(){}};var Dy=class extends ll{peerConnection;constructor(e){super(e),this.peerConnection=e.peerConnection;let t=e.peerConnection.connectionState;this.peerConnection.onconnectionstatechange=()=>{this.log.trace("peer connection state change %s initial state %s",this.peerConnection.connectionState,t),(this.peerConnection.connectionState==="disconnected"||this.peerConnection.connectionState==="failed"||this.peerConnection.connectionState==="closed")&&(this.onTransportClosed(),this.peerConnection.close())}}sendData(e){return{sentBytes:e.byteLength,canSendMore:!0}}async sendClose(e){this.peerConnection.close(),e?.signal?.throwIfAborted()}sendReset(){this.peerConnection.close()}sendPause(){}sendResume(){}},Sc=r=>new Dy(r);var Al=globalThis.RTCPeerConnection,El=globalThis.RTCSessionDescription,ix=globalThis.RTCIceCandidate;var tr=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var fo=class extends Error{constructor(e){super(`WebRTC transport error: ${e}`),this.name="WebRTCTransportError"}},ur=class extends fo{constructor(e="SDP handshake failed"){super(e),this.name="SDPHandshakeFailedError"}};var Cl=class extends fo{constructor(e,t){super(`Invalid fingerprint "${e}" within ${t}`),this.name="WebRTC/InvalidFingerprintError"}};var Tl=class extends fo{constructor(e){super(`A method (${e}) was called though it has been intentionally left unimplemented.`),this.name="WebRTC/UnimplementedError"}},Ol=class extends fo{constructor(e){super(`unsupported hash algorithm code: ${e} please see the codes at https://github.com/multiformats/multicodec/blob/master/table.csv `),this.name="WebRTC/UnsupportedHashAlgorithmError"}};var Ft;(function(r){let e;(function(o){o.SDP_OFFER="SDP_OFFER",o.SDP_ANSWER="SDP_ANSWER",o.ICE_CANDIDATE="ICE_CANDIDATE"})(e=r.Type||(r.Type={}));let t;(function(o){o[o.SDP_OFFER=0]="SDP_OFFER",o[o.SDP_ANSWER=1]="SDP_ANSWER",o[o.ICE_CANDIDATE=2]="ICE_CANDIDATE"})(t||(t={})),(function(o){o.codec=()=>Qo(t)})(e=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Br((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.data!=null&&(i.uint32(18),i.string(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.type=r.Type.codec().decode(o);break}case 2:{a.data=o.string();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Or(o,r.codec()),r.decode=(o,i)=>Tr(o,r.codec(),i)})(Ft||(Ft={}));var Bl=async(r,e,t)=>{try{let n=Promise.withResolvers();for(sC(r,n);;){let o=await Promise.race([n.promise,e.read({signal:t.signal})]);if(o==null){t.signal?.throwIfAborted();break}if(o.type!==Ft.Type.ICE_CANDIDATE)throw new gf("ICE candidate message expected");let i=JSON.parse(o.data??"null");if(i===""||i===null){t.onProgress?.(new tr("webrtc:end-of-ice-candidates")),t.log.trace("end-of-candidates received");continue}let s=new ix(i);t.log.trace("%s received new ICE candidate %o",t.direction,i);try{t.onProgress?.(new tr("webrtc:add-ice-candidate",s.candidate)),await r.addIceCandidate(s)}catch(a){t.log.error("%s bad candidate received %o - %e",t.direction,i,a)}}}catch(n){if(t.log.error("%s error parsing ICE candidate - %e",t.direction,n),t.signal?.aborted===!0&&r.connectionState!=="connected")throw n}};function sC(r,e){if(r.connectionState==="connected"){e.resolve();return}r.onconnectionstatechange=t=>{switch(r.connectionState){case"connected":e.resolve();break;case"failed":case"disconnected":case"closed":e.reject(new pf(`RTCPeerConnection connection state became "${r.connectionState}"`));break;default:break}}}function Il(r){let e;for(let t of r.getComponents())t.name==="p2p"&&(e=Cs(t.value??""));if(e==null)throw new df("Remote peerId must be present in multiaddr");return e}async function sx({rtcConfiguration:r,dataChannel:e,signal:t,metrics:n,multiaddr:o,connectionManager:i,transportManager:s,log:a,logger:c,onProgress:f}){let{circuitAddress:p,targetPeer:l}=ax(o);n?.dialerEvents.increment({open:!0}),a.trace("dialing circuit address: %a",p);let y=i.getConnections(l),g;y.length===0?(f?.(new tr("webrtc:dial-relay")),g=await s.dial(p,{signal:t,onProgress:f})):(f?.(new tr("webrtc:reuse-relay-connection")),g=y[0]),f?.(new tr("webrtc:open-signaling-stream"));let m=await g.newStream(gc,{signal:t,runOnLimitedConnection:!0}),C=ml(m).pb(Ft),d=new Al(r);d.addEventListener("connectionstatechange",()=>{switch(d.connectionState){case"closed":d.close();break;default:break}});let S=new uo({peerConnection:d,dataChannelOptions:e});try{let D=d.createDataChannel("init");d.onicecandidate=({candidate:z})=>{if(d.connectionState==="connected"){a.trace("ignore new ice candidate as peer connection is already connected");return}if(z==null||z?.candidate===""){a.trace("initiator detected end of ICE candidates");return}let oe=JSON.stringify(z?.toJSON()??null);a.trace("initiator sending ICE candidate %o",z),C.write({type:Ft.Type.ICE_CANDIDATE,data:oe},{signal:t}).catch(j=>{a.error("error sending ICE candidate - %e",j)})},d.onicecandidateerror=z=>{a.error("initiator ICE candidate error",z)};let B=await d.createOffer().catch(z=>{throw a.error("could not execute createOffer - %e",z),new ur("Failed to set createOffer")});a.trace("initiator send SDP offer %s",B.sdp),f?.(new tr("webrtc:send-sdp-offer")),await C.write({type:Ft.Type.SDP_OFFER,data:B.sdp},{signal:t}),await d.setLocalDescription(B).catch(z=>{throw a.error("could not execute setLocalDescription - %e",z),new ur("Failed to set localDescription")}),f?.(new tr("webrtc:read-sdp-answer")),a.trace("initiator read SDP answer");let H=await C.read({signal:t});if(H.type!==Ft.Type.SDP_ANSWER)throw new ur("Remote should send an SDP answer");a.trace("initiator received SDP answer %s",H.data);let J=new El({type:"answer",sdp:H.data});return await d.setRemoteDescription(J).catch(z=>{throw a.error("could not execute setRemoteDescription - %e",z),new ur("Failed to set remoteDescription")}),a.trace("initiator read candidates until connected"),f?.(new tr("webrtc:read-ice-candidates")),await Bl(d,C,{direction:"initiator",signal:t,log:a,onProgress:f}),a.trace("initiator connected"),D.readyState!=="open"&&(a.trace("wait for init channel to open"),await wt(D,"open",{signal:t})),a.trace("closing init channel"),D.close(),a.trace("waiting for init channel to close"),await wt(D,"close",{signal:t}),f?.(new tr("webrtc:close-signaling-stream")),a.trace("closing signaling channel"),await m.close({signal:t}),a.trace("initiator connected to remote address %s",o),{remoteAddress:o,peerConnection:d,muxerFactory:S}}catch(D){throw a.error("outgoing signaling error - %e",D),d.close(),m.abort(D),D}finally{d.onicecandidate=null,d.onicecandidateerror=null}}var cx=Me(Uw.matchers[0],Ue(290)),Pl=class r extends sr{transportManager;shutdownController;events;constructor(e,t){super(),this.transportManager=e.transportManager,this.events=e.events,this.shutdownController=t.shutdownController,this.onTransportListening=this.onTransportListening.bind(this)}async listen(){this.events.addEventListener("transport:listening",this.onTransportListening)}onTransportListening(e){e.detail.getAddrs().filter(n=>cx.exactMatch(n)).map(n=>n.encapsulate("/webrtc")).length>0&&this.safeDispatchEvent("listening")}getAddrs(){return this.transportManager.getListeners().filter(e=>!(e instanceof r)).map(e=>e.getAddrs().filter(t=>cx.exactMatch(t)).map(t=>t.encapsulate("/webrtc"))).flat()}updateAnnounceAddrs(){}async close(){this.events.removeEventListener("transport:listening",this.onTransportListening),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};async function ux(r,e,{peerConnection:t,signal:n,log:o}){o.trace("new inbound signaling stream");let i=ml(r).pb(Ft);try{t.onicecandidate=({candidate:l})=>{if(t.connectionState==="connected"){o.trace("ignore new ice candidate as peer connection is already connected");return}if(l==null||l?.candidate===""){o.trace("recipient detected end of ICE candidates");return}let y=JSON.stringify(l?.toJSON()??null);o.trace("recipient sending ICE candidate %s",y),i.write({type:Ft.Type.ICE_CANDIDATE,data:y},{signal:n}).catch(g=>{o.error("error sending ICE candidate - %e",g)})},o.trace("recipient read SDP offer");let c=await i.read({signal:n});if(c.type!==Ft.Type.SDP_OFFER)throw new ur(`expected message type SDP_OFFER, received: ${c.type??"undefined"} `);o.trace("recipient received SDP offer %s",c.data);let f=new El({type:"offer",sdp:c.data});await t.setRemoteDescription(f).catch(l=>{throw o.error("could not execute setRemoteDescription - %e",l),new ur("Failed to set remoteDescription")});let p=await t.createAnswer().catch(l=>{throw o.error("could not execute createAnswer - %e",l),new ur("Failed to create answer")});o.trace("recipient send SDP answer %s",p.sdp),await i.write({type:Ft.Type.SDP_ANSWER,data:p.sdp},{signal:n}),await t.setLocalDescription(p).catch(l=>{throw o.error("could not execute setLocalDescription - %e",l),new ur("Failed to set localDescription")}),o.trace("recipient read candidates until connected"),await Bl(t,i,{direction:"recipient",signal:n,log:o})}catch(c){if(t.connectionState!=="connected")throw o.error("error while handling signaling stream from peer %a - %e",e.remoteAddr,c),t.close(),c;o("error while handling signaling stream from peer %a, ignoring as the RTCPeerConnection is already connected",e.remoteAddr,c)}let s=Il(e.remoteAddr),a=Ps(`/webrtc/p2p/${s}`);return o.trace("recipient connected to remote address %s",a),{remoteAddress:a,remotePeer:s}}var Nl=class{components;init;log;_started=!1;metrics;shutdownController;constructor(e,t={}){this.components=e,this.init=t,this.log=e.logger.forComponent("libp2p:webrtc"),this.shutdownController=new AbortController,this.shutdownController.signal,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_dialer_events_total",{label:"event",help:"Total count of WebRTC dialer events by type"}),listenerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_listener_events_total",{label:"event",help:"Total count of WebRTC listener events by type"})})}[_f]=!0;[Symbol.toStringTag]="@libp2p/webrtc";[ss]=["@libp2p/transport"];[s0]=["@libp2p/identify","@libp2p/circuit-relay-v2-transport"];isStarted(){return this._started}async start(){await this.components.registrar.handle(gc,(e,t)=>{let n=this.components.upgrader.createInboundAbortSignal(this.shutdownController.signal);this._onProtocol(e,t,n).catch(o=>{this.log.error("failed to handle incoming connect from %p - %e",t.remotePeer,o)}).finally(()=>{n.clear()})},{runOnLimitedConnection:!0}),this._started=!0}async stop(){await this.components.registrar.unhandle(gc),this._started=!1}createListener(e){return new Pl(this.components,{shutdownController:this.shutdownController})}listenFilter(e){return e.filter(Mw.exactMatch)}dialFilter(e){return this.listenFilter(e)}async dial(e,t){this.log.trace("dialing address: %a",e);let{remoteAddress:n,peerConnection:o,muxerFactory:i}=await sx({rtcConfiguration:await Py(this.init.rtcConfiguration),dataChannel:this.init.dataChannel,multiaddr:e,dataChannelOptions:this.init.dataChannel,signal:t.signal,connectionManager:this.components.connectionManager,transportManager:this.components.transportManager,log:this.log,logger:this.components.logger,onProgress:t.onProgress}),s=Sc({peerConnection:o,remoteAddr:n,metrics:this.metrics?.dialerEvents,direction:"outbound",log:this.components.logger.forComponent("libp2p:webrtc:connection")}),a=await t.upgrader.upgradeOutbound(s,{skipProtection:!0,skipEncryption:!0,remotePeer:Il(e),muxerFactory:i,onProgress:t.onProgress,signal:t.signal});return this._closeOnShutdown(o,s),a}async _onProtocol(e,t,n){let o=new Al(await Py(this.init.rtcConfiguration));o.addEventListener("connectionstatechange",()=>{switch(o.connectionState){case"closed":o.close();break;default:break}});let i=new uo({peerConnection:o,dataChannelOptions:this.init.dataChannel});try{let{remoteAddress:s,remotePeer:a}=await ux(e,t,{peerConnection:o,signal:n,log:this.log});await e.close({signal:n});let c=Sc({peerConnection:o,remoteAddr:s,metrics:this.metrics?.listenerEvents,direction:"inbound",log:this.components.logger.forComponent("libp2p:webrtc:connection")});await this.components.upgrader.upgradeInbound(c,{skipEncryption:!0,skipProtection:!0,remotePeer:a,muxerFactory:i,signal:n}),this._closeOnShutdown(o,c)}catch(s){throw this.log.error("incoming signaling error - %e",s),o.close(),e.abort(s),s}}_closeOnShutdown(e,t){let n=()=>{t.close().catch(o=>{this.log.error("could not close WebRTCMultiaddrConnection - %e",o)})};this.shutdownController.signal.addEventListener("abort",n),e.addEventListener("close",()=>{this.shutdownController.signal.removeEventListener("abort",n)})}};function ax(r){let e=r.getComponents().filter(({name:n})=>n==="p2p").map(({value:n})=>n).pop();if(e==null)throw new _e("Destination peer id was missing");return{circuitAddress:Ps(r.getComponents().filter(({name:n})=>n!=="webrtc")),targetPeer:Cs(e)}}var _z=Vr(lx());var Jr={};Ot(Jr,{Any:()=>Zr,BaseBlock:()=>ot,BaseStringBlock:()=>Tc,BitString:()=>kr,BmpString:()=>fi,Boolean:()=>ai,CharacterString:()=>wi,Choice:()=>Us,Constructed:()=>it,DATE:()=>kc,DateTime:()=>Rc,Duration:()=>jc,EndOfContent:()=>Oc,Enumerated:()=>ci,GeneralString:()=>bi,GeneralizedTime:()=>xi,GraphicString:()=>gi,HexBlock:()=>Yr,IA5String:()=>mi,Integer:()=>On,Null:()=>Pr,NumericString:()=>pi,ObjectIdentifier:()=>ui,OctetString:()=>Nr,Primitive:()=>Tn,PrintableString:()=>hi,RawData:()=>Uy,RelativeObjectIdentifier:()=>Nc,Repeated:()=>vi,Sequence:()=>kt,Set:()=>Ut,TIME:()=>Lc,TeletexString:()=>di,TimeOfDay:()=>Dc,UTCTime:()=>ho,UniversalString:()=>li,Utf8String:()=>lr,ValueBlock:()=>xt,VideotexString:()=>yi,ViewWriter:()=>Ls,VisibleString:()=>po,compareSchema:()=>En,fromBER:()=>In,verifySchema:()=>TC});var be=Vr(An());function si(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function lo(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let p=a-1;p>=0;p--){let l=Math.pow(2,p*e);f[i-p-1]=Math.floor(o/l),o-=f[i-p-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function Rl(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function jy(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=si(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,si(i,8)-n}function px(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=lo(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=lo(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function hx(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Wt(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var Ek=Math.log(2);function jl(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function My(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Bn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Ls=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return My(this.items)}},Ac=[new Uint8Array([1])],dx="0123456789",Ly="name",yx="valueHexView",yC="isHexOnly",mC="idBlock",gC="tagClass",bC="tagNumber",wC="isConstructed",xC="fromBER",vC="toBER",_C="local",qt="",Dr=new ArrayBuffer(0),Yl=new Uint8Array(0),Cc="EndOfContent",gx="OCTET STRING",bx="BIT STRING";function Yr(r){var e;return e=class extends r{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?be.BufferSourceConverter.toUint8Array(i.valueHex):Yl}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Bn(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Dr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:be.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Cn=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=qt,warnings:n=[],valueBeforeDecode:o=Yl}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=be.BufferSourceConverter.toUint8Array(o)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:be.Convert.ToHex(this.valueBeforeDecodeView)}}};Cn.NAME="baseBlock";var xt=class extends Cn{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};xt.NAME="valueBlock";var Ll=class extends Yr(Cn){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?be.BufferSourceConverter.toUint8Array(e.valueHex):Yl,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Dr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=lo(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),p=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===p){p+=255;let y=new Uint8Array(p);for(let g=0;g<f.length;g++)y[g]=f[g];f=this.valueHexView=new Uint8Array(p)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let y=0;y<c;y++)l[y]=f[y];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=si(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Ll.NAME="identificationBlock";var Ul=class extends Cn{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=si(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=lo(this.length,8);if(o.byteLength>127)return this.error="Too big length",Dr;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Ul.NAME="lengthBlock";var Y={},ot=class extends Cn{constructor({name:e=qt,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Ll(o),this.lenBlock=new Ul(o),this.valueBlock=i?new i(o):new xt(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){let n=t||new Ls;t||wx(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?Dr:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():be.Convert.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,t=be.Convert.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return hx(t,n)}};ot.NAME="BaseBlock";function wx(r){var e;if(r instanceof Y.Constructed)for(let t of r.valueBlock.value)wx(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}var Tc=class extends ot{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=qt,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Tc.NAME="BaseStringBlock";var Ml=class extends Yr(xt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Ml.NAME="PrimitiveValueBlock";var xx,Tn=class extends ot{constructor(e={}){super(e,Ml),this.idBlock.isConstructed=!1}};xx=Tn;Y.Primitive=xx;Tn.NAME="PRIMITIVE";function SC(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Ms(r,e=0,t=r.length){let n=e,o=new ot({},xt),i=new Cn;if(!Bn(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=ot;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=Y.EndOfContent;break;case 1:c=Y.Boolean;break;case 2:c=Y.Integer;break;case 3:c=Y.BitString;break;case 4:c=Y.OctetString;break;case 5:c=Y.Null;break;case 6:c=Y.ObjectIdentifier;break;case 10:c=Y.Enumerated;break;case 12:c=Y.Utf8String;break;case 13:c=Y.RelativeObjectIdentifier;break;case 14:c=Y.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=Y.Sequence;break;case 17:c=Y.Set;break;case 18:c=Y.NumericString;break;case 19:c=Y.PrintableString;break;case 20:c=Y.TeletexString;break;case 21:c=Y.VideotexString;break;case 22:c=Y.IA5String;break;case 23:c=Y.UTCTime;break;case 24:c=Y.GeneralizedTime;break;case 25:c=Y.GraphicString;break;case 26:c=Y.VisibleString;break;case 27:c=Y.GeneralString;break;case 28:c=Y.UniversalString;break;case 29:c=Y.CharacterString;break;case 30:c=Y.BmpString;break;case 31:c=Y.DATE;break;case 32:c=Y.TimeOfDay;break;case 33:c=Y.DateTime;break;case 34:c=Y.Duration;break;default:{let f=o.idBlock.isConstructed?new Y.Constructed:new Y.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?Y.Constructed:Y.Primitive}return o=SC(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function In(r){if(!r.byteLength){let e=new ot({},xt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ms(be.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function AC(r,e){return r?1:e}var Xr=class extends xt{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;AC(this.isIndefiniteForm,n)>0;){let s=Ms(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===Cc)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Cc?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Ls;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?Dr:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Xr.NAME="ConstructedValueBlock";var vx,it=class extends ot{constructor(e={}){super(e,Xr),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
2
|
+
"use strict";var Libp2PWebrtc=(()=>{var xS=Object.create;var ff=Object.defineProperty;var vS=Object.getOwnPropertyDescriptor;var _S=Object.getOwnPropertyNames;var SS=Object.getPrototypeOf,AS=Object.prototype.hasOwnProperty;var dh=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Tt=(r,e)=>{for(var t in e)ff(r,t,{get:e[t],enumerable:!0})},c0=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _S(e))!AS.call(r,o)&&o!==t&&ff(r,o,{get:()=>e[o],enumerable:!(n=vS(e,o))||n.enumerable});return r};var Hr=(r,e,t)=>(t=r!=null?xS(SS(r)):{},c0(e||!r||!r.__esModule?ff(t,"default",{value:r,enumerable:!0}):t,r)),ES=r=>c0(ff({},"__esModule",{value:!0}),r);var gx=dh(()=>{var mx;(function(r){(function(e){var t=typeof globalThis=="object"||typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:a(),n=o(r);typeof t.Reflect<"u"&&(n=o(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function o(c,f){return function(p,l){Object.defineProperty(c,p,{configurable:!0,writable:!0,value:l}),f&&f(p,l)}}function i(){try{return Function("return this;")()}catch{}}function s(){try{return(0,eval)("(function() { return this; })()")}catch{}}function a(){return i()||s()}})(function(e,t){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",i=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",s=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",a=typeof Object.create=="function",c={__proto__:[]}instanceof Array,f=!a&&!c,p={create:a?function(){return hh(Object.create(null))}:c?function(){return hh({__proto__:null})}:function(){return hh({})},has:f?function(w,A){return n.call(w,A)}:function(w,A){return A in w},get:f?function(w,A){return n.call(w,A)?w[A]:void 0}:function(w,A){return w[A]}},l=Object.getPrototypeOf(Function),y=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:yS(),d=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:mS(),g=typeof WeakMap=="function"?WeakMap:gS(),C=o?Symbol.for("@reflect-metadata:registry"):void 0,m=pS(),S=hS(m);function D(w,A,k,F){if(N(k)){if(!fn(w))throw new TypeError;if(!Gn(A))throw new TypeError;return $(w,A)}else{if(!fn(w))throw new TypeError;if(!re(A))throw new TypeError;if(!re(F)&&!N(F)&&!ye(F))throw new TypeError;return ye(F)&&(F=void 0),k=ke(k),I(w,A,k,F)}}e("decorate",D);function O(w,A){function k(F,ce){if(!re(F))throw new TypeError;if(!N(ce)&&!uf(ce))throw new TypeError;L(w,A,F,ce)}return k}e("metadata",O);function H(w,A,k,F){if(!re(k))throw new TypeError;return N(F)||(F=ke(F)),L(w,A,k,F)}e("defineMetadata",H);function J(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),_(w,A,k)}e("hasMetadata",J);function z(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),v(w,A,k)}e("hasOwnMetadata",z);function oe(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),R(w,A,k)}e("getMetadata",oe);function j(w,A,k){if(!re(A))throw new TypeError;return N(k)||(k=ke(k)),M(w,A,k)}e("getOwnMetadata",j);function P(w,A){if(!re(w))throw new TypeError;return N(A)||(A=ke(A)),B(w,A)}e("getMetadataKeys",P);function X(w,A){if(!re(w))throw new TypeError;return N(A)||(A=ke(A)),U(w,A)}e("getOwnMetadataKeys",X);function Q(w,A,k){if(!re(A))throw new TypeError;if(N(k)||(k=ke(k)),!re(A))throw new TypeError;N(k)||(k=ke(k));var F=Na(A,k,!1);return N(F)?!1:F.OrdinaryDeleteMetadata(w,A,k)}e("deleteMetadata",Q);function $(w,A){for(var k=w.length-1;k>=0;--k){var F=w[k],ce=F(A);if(!N(ce)&&!ye(ce)){if(!Gn(ce))throw new TypeError;A=ce}}return A}function I(w,A,k,F){for(var ce=w.length-1;ce>=0;--ce){var tt=w[ce],at=tt(A,k,F);if(!N(at)&&!ye(at)){if(!re(at))throw new TypeError;F=at}}return F}function _(w,A,k){var F=v(w,A,k);if(F)return!0;var ce=ph(A);return ye(ce)?!1:_(w,ce,k)}function v(w,A,k){var F=Na(A,k,!1);return N(F)?!1:qe(F.OrdinaryHasOwnMetadata(w,A,k))}function R(w,A,k){var F=v(w,A,k);if(F)return M(w,A,k);var ce=ph(A);if(!ye(ce))return R(w,ce,k)}function M(w,A,k){var F=Na(A,k,!1);if(!N(F))return F.OrdinaryGetOwnMetadata(w,A,k)}function L(w,A,k,F){var ce=Na(k,F,!0);ce.OrdinaryDefineOwnMetadata(w,A,k,F)}function B(w,A){var k=U(w,A),F=ph(w);if(F===null)return k;var ce=B(F,A);if(ce.length<=0)return k;if(k.length<=0)return ce;for(var tt=new d,at=[],ve=0,Y=k;ve<Y.length;ve++){var ee=Y[ve],ne=tt.has(ee);ne||(tt.add(ee),at.push(ee))}for(var ie=0,Se=ce;ie<Se.length;ie++){var ee=Se[ie],ne=tt.has(ee);ne||(tt.add(ee),at.push(ee))}return at}function U(w,A){var k=Na(w,A,!1);return k?k.OrdinaryOwnMetadataKeys(w,A):[]}function q(w){if(w===null)return 1;switch(typeof w){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return w===null?1:6;default:return 6}}function N(w){return w===void 0}function ye(w){return w===null}function xe(w){return typeof w=="symbol"}function re(w){return typeof w=="object"?w!==null:typeof w=="function"}function Ae(w,A){switch(q(w)){case 0:return w;case 1:return w;case 2:return w;case 3:return w;case 4:return w;case 5:return w}var k=A===3?"string":A===5?"number":"default",F=Pa(w,i);if(F!==void 0){var ce=F.call(w,k);if(re(ce))throw new TypeError;return ce}return Ne(w,k==="default"?"number":k)}function Ne(w,A){if(A==="string"){var k=w.toString;if(br(k)){var F=k.call(w);if(!re(F))return F}var ce=w.valueOf;if(br(ce)){var F=ce.call(w);if(!re(F))return F}}else{var ce=w.valueOf;if(br(ce)){var F=ce.call(w);if(!re(F))return F}var tt=w.toString;if(br(tt)){var F=tt.call(w);if(!re(F))return F}}throw new TypeError}function qe(w){return!!w}function Ce(w){return""+w}function ke(w){var A=Ae(w,3);return xe(A)?A:Ce(A)}function fn(w){return Array.isArray?Array.isArray(w):w instanceof Object?w instanceof Array:Object.prototype.toString.call(w)==="[object Array]"}function br(w){return typeof w=="function"}function Gn(w){return typeof w=="function"}function uf(w){switch(q(w)){case 3:return!0;case 4:return!0;default:return!1}}function ns(w,A){return w===A||w!==w&&A!==A}function Pa(w,A){var k=w[A];if(k!=null){if(!br(k))throw new TypeError;return k}}function n0(w){var A=Pa(w,s);if(!br(A))throw new TypeError;var k=A.call(w);if(!re(k))throw new TypeError;return k}function o0(w){return w.value}function i0(w){var A=w.next();return A.done?!1:A}function s0(w){var A=w.return;A&&A.call(w)}function ph(w){var A=Object.getPrototypeOf(w);if(typeof w!="function"||w===l||A!==l)return A;var k=w.prototype,F=k&&Object.getPrototypeOf(k);if(F==null||F===Object.prototype)return A;var ce=F.constructor;return typeof ce!="function"||ce===w?A:ce}function lS(){var w;!N(C)&&typeof t.Reflect<"u"&&!(C in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(w=dS(t.Reflect));var A,k,F,ce=new g,tt={registerProvider:at,getProvider:Y,setProvider:ne};return tt;function at(ie){if(!Object.isExtensible(tt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case w===ie:break;case N(A):A=ie;break;case A===ie:break;case N(k):k=ie;break;case k===ie:break;default:F===void 0&&(F=new d),F.add(ie);break}}function ve(ie,Se){if(!N(A)){if(A.isProviderFor(ie,Se))return A;if(!N(k)){if(k.isProviderFor(ie,Se))return A;if(!N(F))for(var He=n0(F);;){var rt=i0(He);if(!rt)return;var wr=o0(rt);if(wr.isProviderFor(ie,Se))return s0(He),wr}}}if(!N(w)&&w.isProviderFor(ie,Se))return w}function Y(ie,Se){var He=ce.get(ie),rt;return N(He)||(rt=He.get(Se)),N(rt)&&(rt=ve(ie,Se),N(rt)||(N(He)&&(He=new y,ce.set(ie,He)),He.set(Se,rt))),rt}function ee(ie){if(N(ie))throw new TypeError;return A===ie||k===ie||!N(F)&&F.has(ie)}function ne(ie,Se,He){if(!ee(He))throw new Error("Metadata provider not registered.");var rt=Y(ie,Se);if(rt!==He){if(!N(rt))return!1;var wr=ce.get(ie);N(wr)&&(wr=new y,ce.set(ie,wr)),wr.set(Se,He)}return!0}}function pS(){var w;return!N(C)&&re(t.Reflect)&&Object.isExtensible(t.Reflect)&&(w=t.Reflect[C]),N(w)&&(w=lS()),!N(C)&&re(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,C,{enumerable:!1,configurable:!1,writable:!1,value:w}),w}function hS(w){var A=new g,k={isProviderFor:function(ee,ne){var ie=A.get(ee);return N(ie)?!1:ie.has(ne)},OrdinaryDefineOwnMetadata:at,OrdinaryHasOwnMetadata:ce,OrdinaryGetOwnMetadata:tt,OrdinaryOwnMetadataKeys:ve,OrdinaryDeleteMetadata:Y};return m.registerProvider(k),k;function F(ee,ne,ie){var Se=A.get(ee),He=!1;if(N(Se)){if(!ie)return;Se=new y,A.set(ee,Se),He=!0}var rt=Se.get(ne);if(N(rt)){if(!ie)return;if(rt=new y,Se.set(ne,rt),!w.setProvider(ee,ne,k))throw Se.delete(ne),He&&A.delete(ee),new Error("Wrong provider for target.")}return rt}function ce(ee,ne,ie){var Se=F(ne,ie,!1);return N(Se)?!1:qe(Se.has(ee))}function tt(ee,ne,ie){var Se=F(ne,ie,!1);if(!N(Se))return Se.get(ee)}function at(ee,ne,ie,Se){var He=F(ie,Se,!0);He.set(ee,ne)}function ve(ee,ne){var ie=[],Se=F(ee,ne,!1);if(N(Se))return ie;for(var He=Se.keys(),rt=n0(He),wr=0;;){var a0=i0(rt);if(!a0)return ie.length=wr,ie;var bS=o0(a0);try{ie[wr]=bS}catch(wS){try{s0(rt)}finally{throw wS}}wr++}}function Y(ee,ne,ie){var Se=F(ne,ie,!1);if(N(Se)||!Se.delete(ee))return!1;if(Se.size===0){var He=A.get(ne);N(He)||(He.delete(ie),He.size===0&&A.delete(He))}return!0}}function dS(w){var A=w.defineMetadata,k=w.hasOwnMetadata,F=w.getOwnMetadata,ce=w.getOwnMetadataKeys,tt=w.deleteMetadata,at=new g,ve={isProviderFor:function(Y,ee){var ne=at.get(Y);return!N(ne)&&ne.has(ee)?!0:ce(Y,ee).length?(N(ne)&&(ne=new d,at.set(Y,ne)),ne.add(ee),!0):!1},OrdinaryDefineOwnMetadata:A,OrdinaryHasOwnMetadata:k,OrdinaryGetOwnMetadata:F,OrdinaryOwnMetadataKeys:ce,OrdinaryDeleteMetadata:tt};return ve}function Na(w,A,k){var F=m.getProvider(w,A);if(!N(F))return F;if(k){if(m.setProvider(w,A,S))return S;throw new Error("Illegal state.")}}function yS(){var w={},A=[],k=(function(){function ve(Y,ee,ne){this._index=0,this._keys=Y,this._values=ee,this._selector=ne}return ve.prototype["@@iterator"]=function(){return this},ve.prototype[s]=function(){return this},ve.prototype.next=function(){var Y=this._index;if(Y>=0&&Y<this._keys.length){var ee=this._selector(this._keys[Y],this._values[Y]);return Y+1>=this._keys.length?(this._index=-1,this._keys=A,this._values=A):this._index++,{value:ee,done:!1}}return{value:void 0,done:!0}},ve.prototype.throw=function(Y){throw this._index>=0&&(this._index=-1,this._keys=A,this._values=A),Y},ve.prototype.return=function(Y){return this._index>=0&&(this._index=-1,this._keys=A,this._values=A),{value:Y,done:!0}},ve})(),F=(function(){function ve(){this._keys=[],this._values=[],this._cacheKey=w,this._cacheIndex=-2}return Object.defineProperty(ve.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),ve.prototype.has=function(Y){return this._find(Y,!1)>=0},ve.prototype.get=function(Y){var ee=this._find(Y,!1);return ee>=0?this._values[ee]:void 0},ve.prototype.set=function(Y,ee){var ne=this._find(Y,!0);return this._values[ne]=ee,this},ve.prototype.delete=function(Y){var ee=this._find(Y,!1);if(ee>=0){for(var ne=this._keys.length,ie=ee+1;ie<ne;ie++)this._keys[ie-1]=this._keys[ie],this._values[ie-1]=this._values[ie];return this._keys.length--,this._values.length--,ns(Y,this._cacheKey)&&(this._cacheKey=w,this._cacheIndex=-2),!0}return!1},ve.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=w,this._cacheIndex=-2},ve.prototype.keys=function(){return new k(this._keys,this._values,ce)},ve.prototype.values=function(){return new k(this._keys,this._values,tt)},ve.prototype.entries=function(){return new k(this._keys,this._values,at)},ve.prototype["@@iterator"]=function(){return this.entries()},ve.prototype[s]=function(){return this.entries()},ve.prototype._find=function(Y,ee){if(!ns(this._cacheKey,Y)){this._cacheIndex=-1;for(var ne=0;ne<this._keys.length;ne++)if(ns(this._keys[ne],Y)){this._cacheIndex=ne;break}}return this._cacheIndex<0&&ee&&(this._cacheIndex=this._keys.length,this._keys.push(Y),this._values.push(void 0)),this._cacheIndex},ve})();return F;function ce(ve,Y){return ve}function tt(ve,Y){return Y}function at(ve,Y){return[ve,Y]}}function mS(){var w=(function(){function A(){this._map=new y}return Object.defineProperty(A.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),A.prototype.has=function(k){return this._map.has(k)},A.prototype.add=function(k){return this._map.set(k,k),this},A.prototype.delete=function(k){return this._map.delete(k)},A.prototype.clear=function(){this._map.clear()},A.prototype.keys=function(){return this._map.keys()},A.prototype.values=function(){return this._map.keys()},A.prototype.entries=function(){return this._map.entries()},A.prototype["@@iterator"]=function(){return this.keys()},A.prototype[s]=function(){return this.keys()},A})();return w}function gS(){var w=16,A=p.create(),k=F();return(function(){function Y(){this._key=F()}return Y.prototype.has=function(ee){var ne=ce(ee,!1);return ne!==void 0?p.has(ne,this._key):!1},Y.prototype.get=function(ee){var ne=ce(ee,!1);return ne!==void 0?p.get(ne,this._key):void 0},Y.prototype.set=function(ee,ne){var ie=ce(ee,!0);return ie[this._key]=ne,this},Y.prototype.delete=function(ee){var ne=ce(ee,!1);return ne!==void 0?delete ne[this._key]:!1},Y.prototype.clear=function(){this._key=F()},Y})();function F(){var Y;do Y="@@WeakMap@@"+ve();while(p.has(A,Y));return A[Y]=!0,Y}function ce(Y,ee){if(!n.call(Y,k)){if(!ee)return;Object.defineProperty(Y,k,{value:p.create()})}return Y[k]}function tt(Y,ee){for(var ne=0;ne<ee;++ne)Y[ne]=Math.random()*255|0;return Y}function at(Y){if(typeof Uint8Array=="function"){var ee=new Uint8Array(Y);return typeof crypto<"u"?crypto.getRandomValues(ee):typeof msCrypto<"u"?msCrypto.getRandomValues(ee):tt(ee,Y),ee}return tt(new Array(Y),Y)}function ve(){var Y=at(w);Y[6]=Y[6]&79|64,Y[8]=Y[8]&191|128;for(var ee="",ne=0;ne<w;++ne){var ie=Y[ne];(ne===4||ne===6||ne===8)&&(ee+="-"),ie<16&&(ee+="0"),ee+=ie.toString(16).toLowerCase()}return ee}}function hh(w){return w.__=void 0,delete w.__,w}})})(mx||(mx={}))});var An=dh(Ls=>{"use strict";var yC="[object ArrayBuffer]",Sn=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===yC}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Uy="string",mC=/^[0-9a-f\s]+$/i,gC=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,bC=/^[a-zA-Z0-9-_]+$/,Dl=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Sn.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},ur=class{static toString(e,t=!1){let n=Sn.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},Rl=class r{static isHex(e){return typeof e===Uy&&mC.test(e)}static isBase64(e){return typeof e===Uy&&gC.test(e)}static isBase64Url(e){return typeof e===Uy&&bC.test(e)}static ToString(e,t="utf8"){let n=Sn.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return ur.toString(n,!0);case"utf16":case"utf16be":return ur.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return ur.fromString(e,!0);case"utf16":case"utf16be":return ur.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Sn.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Dl.fromString(e);case"utf16":case"utf16be":return ur.fromString(e);case"utf16le":case"usc2":return ur.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Dl.toString(e);case"utf16":case"utf16be":return ur.toString(e);case"utf16le":case"usc2":return ur.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Sn.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Sn.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return ur.toString(e,t)}static FromUtf16String(e,t=!1){return ur.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Rl.DEFAULT_UTF8_ENCODING="utf8";function wC(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function xC(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function vC(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Ls.BufferSourceConverter=Sn;Ls.Convert=Rl;Ls.assign=wC;Ls.combine=xC;Ls.isEqual=vC});var l1=dh((c7,Op)=>{var Wv,qv,Gv,zv,Xv,Yv,Zv,Jv,Qv,Ip,Gm,e1,t1,pa,r1,n1,o1,i1,s1,a1,c1,u1,f1;(function(r){var e=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(n){r(t(e,t(n)))}):typeof Op=="object"&&typeof Op.exports=="object"?r(t(e,t(Op.exports))):r(t(e));function t(n,o){return n!==e&&(typeof Object.create=="function"?Object.defineProperty(n,"__esModule",{value:!0}):n.__esModule=!0),function(i,s){return n[i]=o?o(i,s):s}}})(function(r){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])};Wv=function(t,n){e(t,n);function o(){this.constructor=t}t.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)},qv=Object.assign||function(t){for(var n,o=1,i=arguments.length;o<i;o++){n=arguments[o];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Gv=function(t,n){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&n.indexOf(i)<0&&(o[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)n.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(o[i[s]]=t[i[s]]);return o},zv=function(t,n,o,i){var s=arguments.length,a=s<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,o):i,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,n,o,i);else for(var f=t.length-1;f>=0;f--)(c=t[f])&&(a=(s<3?c(a):s>3?c(n,o,a):c(n,o))||a);return s>3&&a&&Object.defineProperty(n,o,a),a},Xv=function(t,n){return function(o,i){n(o,i,t)}},Yv=function(t,n){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,n)},Zv=function(t,n,o,i){function s(a){return a instanceof o?a:new o(function(c){c(a)})}return new(o||(o=Promise))(function(a,c){function f(y){try{l(i.next(y))}catch(d){c(d)}}function p(y){try{l(i.throw(y))}catch(d){c(d)}}function l(y){y.done?a(y.value):s(y.value).then(f,p)}l((i=i.apply(t,n||[])).next())})},Jv=function(t,n){var o={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,s,a,c;return c={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function f(l){return function(y){return p([l,y])}}function p(l){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,s&&(a=l[0]&2?s.return:l[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,l[1])).done)return a;switch(s=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return o.label++,{value:l[1],done:!1};case 5:o.label++,s=l[1],l=[0];continue;case 7:l=o.ops.pop(),o.trys.pop();continue;default:if(a=o.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){o=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){o.label=l[1];break}if(l[0]===6&&o.label<a[1]){o.label=a[1],a=l;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(l);break}a[2]&&o.ops.pop(),o.trys.pop();continue}l=n.call(t,o)}catch(y){l=[6,y],s=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},f1=function(t,n,o,i){i===void 0&&(i=o),t[i]=n[o]},Qv=function(t,n){for(var o in t)o!=="default"&&!n.hasOwnProperty(o)&&(n[o]=t[o])},Ip=function(t){var n=typeof Symbol=="function"&&Symbol.iterator,o=n&&t[n],i=0;if(o)return o.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")},Gm=function(t,n){var o=typeof Symbol=="function"&&t[Symbol.iterator];if(!o)return t;var i=o.call(t),s,a=[],c;try{for(;(n===void 0||n-- >0)&&!(s=i.next()).done;)a.push(s.value)}catch(f){c={error:f}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(c)throw c.error}}return a},e1=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(Gm(arguments[n]));return t},t1=function(){for(var t=0,n=0,o=arguments.length;n<o;n++)t+=arguments[n].length;for(var i=Array(t),s=0,n=0;n<o;n++)for(var a=arguments[n],c=0,f=a.length;c<f;c++,s++)i[s]=a[c];return i},pa=function(t){return this instanceof pa?(this.v=t,this):new pa(t)},r1=function(t,n,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=o.apply(t,n||[]),s,a=[];return s={},c("next"),c("throw"),c("return"),s[Symbol.asyncIterator]=function(){return this},s;function c(g){i[g]&&(s[g]=function(C){return new Promise(function(m,S){a.push([g,C,m,S])>1||f(g,C)})})}function f(g,C){try{p(i[g](C))}catch(m){d(a[0][3],m)}}function p(g){g.value instanceof pa?Promise.resolve(g.value.v).then(l,y):d(a[0][2],g)}function l(g){f("next",g)}function y(g){f("throw",g)}function d(g,C){g(C),a.shift(),a.length&&f(a[0][0],a[0][1])}},n1=function(t){var n,o;return n={},i("next"),i("throw",function(s){throw s}),i("return"),n[Symbol.iterator]=function(){return this},n;function i(s,a){n[s]=t[s]?function(c){return(o=!o)?{value:pa(t[s](c)),done:s==="return"}:a?a(c):c}:a}},o1=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t[Symbol.asyncIterator],o;return n?n.call(t):(t=typeof Ip=="function"?Ip(t):t[Symbol.iterator](),o={},i("next"),i("throw"),i("return"),o[Symbol.asyncIterator]=function(){return this},o);function i(a){o[a]=t[a]&&function(c){return new Promise(function(f,p){c=t[a](c),s(f,p,c.done,c.value)})}}function s(a,c,f,p){Promise.resolve(p).then(function(l){a({value:l,done:f})},c)}},i1=function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t},s1=function(t){if(t&&t.__esModule)return t;var n={};if(t!=null)for(var o in t)Object.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n.default=t,n},a1=function(t){return t&&t.__esModule?t:{default:t}},c1=function(t,n){if(!n.has(t))throw new TypeError("attempted to get private field on non-instance");return n.get(t)},u1=function(t,n,o){if(!n.has(t))throw new TypeError("attempted to set private field on non-instance");return n.set(t,o),o},r("__extends",Wv),r("__assign",qv),r("__rest",Gv),r("__decorate",zv),r("__param",Xv),r("__metadata",Yv),r("__awaiter",Zv),r("__generator",Jv),r("__exportStar",Qv),r("__createBinding",f1),r("__values",Ip),r("__read",Gm),r("__spread",e1),r("__spreadArrays",t1),r("__await",pa),r("__asyncGenerator",r1),r("__asyncDelegator",n1),r("__asyncValues",o1),r("__makeTemplateObject",i1),r("__importStar",s1),r("__importDefault",a1),r("__classPrivateFieldGet",c1),r("__classPrivateFieldSet",u1)})});var PI={};Tt(PI,{webRTC:()=>BI,webRTCDirect:()=>OI});var lf=class extends Error{static name="UnexpectedPeerError";constructor(e="Unexpected Peer"){super(e),this.name="UnexpectedPeerError"}},pf=class extends Error{static name="InvalidCryptoExchangeError";constructor(e="Invalid crypto exchange"){super(e),this.name="InvalidCryptoExchangeError"}},_e=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},os=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}},ka=class extends Error{static name="InvalidPrivateKeyError";constructor(e="Invalid private key"){super(e),this.name="InvalidPrivateKeyError"}};var hf=class extends Error{static name="ConnectionFailedError";constructor(e="Connection failed"){super(e),this.name="ConnectionFailedError"}},df=class extends Error{static name="MuxerClosedError";constructor(e="The muxer is closed"){super(e),this.name="MuxerClosedError"}},is=class extends Error{static name="StreamResetError";constructor(e="The stream has been reset"){super(e),this.name="StreamResetError"}};var Vr=class extends Error{static name="StreamStateError";constructor(e="The stream is in an invalid state"){super(e),this.name="StreamStateError"}},Da=class extends Error{static name="StreamBufferError";constructor(e="The stream buffer was full"){super(e),this.name="StreamBufferError"}},Uo=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var yf=class extends Error{static name="InvalidMultiaddrError";constructor(e="Invalid multiaddr"){super(e),this.name="InvalidMultiaddrError"}},mf=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},gf=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var bf=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var wf=class extends Error{static name="NotStartedError";constructor(e="Not started"){super(e),this.name="NotStartedError"}};var zn=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var xf=class extends Event{data;constructor(e,t){super("message",t),this.data=e}},ss=class extends Event{error;local;constructor(e,t,n){super("close",n),this.error=t,this.local=e}},vf=class extends ss{constructor(e,t){super(!0,e,t)}},_f=class extends ss{constructor(e,t){super(!1,e,t)}};var yh=Symbol.for("@libp2p/peer-id");var Sf=Symbol.for("@libp2p/transport");var u0;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(u0||(u0={}));var ir=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var as=Symbol.for("@libp2p/service-capabilities"),f0=Symbol.for("@libp2p/service-dependencies");var xh={};Tt(xh,{base58btc:()=>Ye,base58flickr:()=>NS});var uO=new Uint8Array(0);function l0(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ln(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function p0(r){return new TextEncoder().encode(r)}function h0(r){return new TextDecoder().decode(r)}function CS(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function l(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var C=0,m=0,S=0,D=g.length;S!==D&&g[S]===0;)S++,C++;for(var O=(D-S)*p+1>>>0,H=new Uint8Array(O);S!==D;){for(var J=g[S],z=0,oe=O-1;(J!==0||z<m)&&oe!==-1;oe--,z++)J+=256*H[oe]>>>0,H[oe]=J%a>>>0,J=J/a>>>0;if(J!==0)throw new Error("Non-zero carry");m=z,S++}for(var j=O-m;j!==O&&H[j]===0;)j++;for(var P=c.repeat(C);j<O;++j)P+=r.charAt(H[j]);return P}function y(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var C=0;if(g[C]!==" "){for(var m=0,S=0;g[C]===c;)m++,C++;for(var D=(g.length-C)*f+1>>>0,O=new Uint8Array(D);g[C];){var H=t[g.charCodeAt(C)];if(H===255)return;for(var J=0,z=D-1;(H!==0||J<S)&&z!==-1;z--,J++)H+=a*O[z]>>>0,O[z]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");S=J,C++}if(g[C]!==" "){for(var oe=D-S;oe!==D&&O[oe]===0;)oe++;for(var j=new Uint8Array(m+(D-oe)),P=m;oe!==D;)j[P++]=O[oe++];return j}}}function d(g){var C=y(g);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:y,decode:d}}var TS=CS,IS=TS,y0=IS;var mh=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},gh=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return m0(this,e)}},bh=class{decoders;constructor(e){this.decoders=e}or(e){return m0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function m0(r,e){return new bh({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wh=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new mh(e,t,n),this.decoder=new gh(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cs({name:r,prefix:e,encode:t,decode:n}){return new wh(r,e,t,n)}function Xn({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=y0(t,r);return cs({prefix:e,name:r,encode:n,decode:i=>ln(o(i))})}function OS(r,e,t,n){let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),s=0,a=0,c=0;for(let f=0;f<o;++f){let p=e[r[f]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|p,s+=t,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function BS(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;(i.length*t&7)!==0;)i+="=";return i}function PS(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function Xe({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let o=PS(n);return cs({prefix:e,name:r,encode(i){return BS(i,n,t)},decode(i){return OS(i,o,t,r)}})}var Ye=Xn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),NS=Xn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var vh={};Tt(vh,{base32:()=>Yn,base32hex:()=>jS,base32hexpad:()=>MS,base32hexpadupper:()=>US,base32hexupper:()=>LS,base32pad:()=>DS,base32padupper:()=>RS,base32upper:()=>kS,base32z:()=>KS});var Yn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kS=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),DS=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),RS=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jS=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),LS=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),MS=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),US=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),KS=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _h={};Tt(_h,{base36:()=>Ra,base36upper:()=>HS});var Ra=Xn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),HS=Xn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xr={};Tt(xr,{Digest:()=>Ko,create:()=>kt,decode:()=>ls,equals:()=>Ah,hasCode:()=>sA});var VS=w0,g0=128,$S=127,FS=~$S,WS=Math.pow(2,31);function w0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=WS;)e[t++]=r&255|g0,r/=128;for(;r&FS;)e[t++]=r&255|g0,r>>>=7;return e[t]=r|0,w0.bytes=t-n+1,e}var qS=Sh,GS=128,b0=127;function Sh(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Sh.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&b0)<<o:(s&b0)*Math.pow(2,o),o+=7}while(s>=GS);return Sh.bytes=i-n,t}var zS=Math.pow(2,7),XS=Math.pow(2,14),YS=Math.pow(2,21),ZS=Math.pow(2,28),JS=Math.pow(2,35),QS=Math.pow(2,42),eA=Math.pow(2,49),tA=Math.pow(2,56),rA=Math.pow(2,63),nA=function(r){return r<zS?1:r<XS?2:r<YS?3:r<ZS?4:r<JS?5:r<QS?6:r<eA?7:r<tA?8:r<rA?9:10},oA={encode:VS,decode:qS,encodingLength:nA},iA=oA,ja=iA;function La(r,e=0){return[ja.decode(r,e),ja.decode.bytes]}function us(r,e,t=0){return ja.encode(r,e,t),e}function fs(r){return ja.encodingLength(r)}function kt(r,e){let t=e.byteLength,n=fs(r),o=n+fs(t),i=new Uint8Array(o+t);return us(r,i,0),us(t,i,n),i.set(e,o),new Ko(r,t,e,i)}function ls(r){let e=ln(r),[t,n]=La(e),[o,i]=La(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ko(t,o,s,e)}function Ah(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&l0(r.bytes,t.bytes)}}var Ko=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function sA(r,e){return r.code===e}function x0(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return cA(t,Eh(r),e??Ye.encoder);default:return uA(t,Eh(r),e??Yn.encoder)}}var v0=new WeakMap;function Eh(r){let e=v0.get(r);if(e==null){let t=new Map;return v0.set(r,t),t}return e}var ct=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Ma)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==fA)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=kt(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Ah(e.multihash,n.multihash)}toString(e){return x0(this,e)}toJSON(){return{"/":x0(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??_0(n,o,i.bytes))}else if(t[lA]===!0){let{version:n,multihash:o,code:i}=t,s=ls(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Ma)throw new Error(`Version 0 CID must use dag-pb (code: ${Ma}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=_0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Ma,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=ln(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new Ko(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,y]=La(e.subarray(t));return t+=y,l},o=n(),i=Ma;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,p=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:p,size:f}}static parse(e,t){let[n,o]=aA(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Eh(i).set(n,e),i}};function aA(r,e){switch(r[0]){case"Q":{let t=e??Ye;return[Ye.prefix,t.decode(`${Ye.prefix}${r}`)]}case Ye.prefix:{let t=e??Ye;return[Ye.prefix,t.decode(r)]}case Yn.prefix:{let t=e??Yn;return[Yn.prefix,t.decode(r)]}case Ra.prefix:{let t=e??Ra;return[Ra.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function cA(r,e,t){let{prefix:n}=t;if(n!==Ye.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function uA(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Ma=112,fA=18;function _0(r,e,t){let n=fs(r),o=n+fs(e),i=new Uint8Array(o+t.byteLength);return us(r,i,0),us(e,i,n),i.set(t,o),i}var lA=Symbol.for("@ipld/js-cid/CID");var Ch={};Tt(Ch,{identity:()=>vr});var S0=0,pA="identity",A0=ln;function hA(r,e){if(e?.truncate!=null&&e.truncate!==r.byteLength){if(e.truncate<0||e.truncate>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,e.truncate)}return kt(S0,A0(r))}var vr={code:S0,name:pA,encode:A0,digest:hA};function Ze(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ut(r=0){return new Uint8Array(r)}function ft(r=0){return new Uint8Array(r)}function Dt(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=ft(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var C0=Symbol.for("@achingbrain/uint8arraylist");function E0(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Ef(r){return!!r?.[C0]}var ge=class r{bufs;length;[C0]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Ef(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Ef(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=E0(this.bufs,e);return t.buf[t.index]}set(e,t){let n=E0(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Ef(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Dt(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Dt(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),i=new r;return i.length=o,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let f=e>=a&&e<c,p=t>a&&t<=c;if(f&&p){if(e===a&&t===c){n.push(s);break}let l=e-a;n.push(s.subarray(l,l+(t-e)));break}if(f){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(p){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Ef(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,p;for(let l=t;l<=c;l+=p){p=0;for(let y=f;y>=0;y--){let d=this.get(l+y);if(n[y]!==d){p=Math.max(1,y-a[d]);break}}if(p===0)return l}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=ft(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=ut(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=ft(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=ut(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=ut(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=ut(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Ze(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((o,i)=>o+i.byteLength,0)),n.length=t,n}};var Th={};Tt(Th,{base10:()=>yA});var yA=Xn({prefix:"9",name:"base10",alphabet:"0123456789"});var Ih={};Tt(Ih,{base16:()=>mA,base16upper:()=>gA});var mA=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gA=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Oh={};Tt(Oh,{base2:()=>bA});var bA=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bh={};Tt(Bh,{base256emoji:()=>SA});var T0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wA=T0.reduce((r,e,t)=>(r[t]=e,r),[]),xA=T0.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function vA(r){return r.reduce((e,t)=>(e+=wA[t],e),"")}function _A(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=xA[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var SA=cs({prefix:"\u{1F680}",name:"base256emoji",encode:vA,decode:_A});var Ph={};Tt(Ph,{base64:()=>AA,base64pad:()=>EA,base64url:()=>Ho,base64urlpad:()=>CA});var AA=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),EA=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ho=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),CA=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nh={};Tt(Nh,{base8:()=>TA});var TA=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kh={};Tt(kh,{identity:()=>IA});var IA=cs({prefix:"\0",name:"identity",encode:r=>h0(r),decode:r=>p0(r)});var WO=new TextEncoder,qO=new TextDecoder;var jh={};Tt(jh,{sha256:()=>sr,sha512:()=>NA});var PA=20;function Rh({name:r,code:e,encode:t,minDigestLength:n,maxDigestLength:o}){return new Dh(r,e,t,n,o)}var Dh=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,t,n,o,i){this.name=e,this.code=t,this.encode=n,this.minDigestLength=o??PA,this.maxDigestLength=i}digest(e,t){if(t?.truncate!=null){if(t.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&t.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?I0(n,this.code,t?.truncate):n.then(o=>I0(o,this.code,t?.truncate))}else throw Error("Unknown type, must be binary type")}};function I0(r,e,t){if(t!=null&&t!==r.byteLength){if(t>r.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${r.byteLength}`);r=r.subarray(0,t)}return kt(e,r)}function B0(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var sr=Rh({name:"sha2-256",code:18,encode:B0("SHA-256")}),NA=Rh({name:"sha2-512",code:19,encode:B0("SHA-512")});var Vo={...kh,...Oh,...Nh,...Th,...Ih,...vh,..._h,...xh,...Ph,...Bh},oB={...jh,...Ch};function N0(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var P0=N0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Lh=N0("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=ft(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),kA={utf8:P0,"utf-8":P0,hex:Vo.base16,latin1:Lh,ascii:Lh,binary:Lh,...Vo},Cf=kA;function me(r,e="utf8"){let t=Cf[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function le(r,e="utf8"){let t=Cf[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var DA=parseInt("11111",2),Mh=parseInt("10000000",2),RA=parseInt("01111111",2),k0={0:Ua,1:Ua,2:jA,3:UA,4:KA,5:MA,6:LA,16:Ua,22:Ua,48:Ua};function pn(r,e={offset:0}){let t=r[e.offset]&DA;if(e.offset++,k0[t]!=null)return k0[t](r,e);throw new Error("No decoder for tag "+t)}function Ka(r,e){let t=0;if((r[e.offset]&Mh)===Mh){let n=r[e.offset]&RA,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(o,16)}else t=r[e.offset],e.offset++;return t}function Ua(r,e){Ka(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=pn(r,e);if(n===null)break;t.push(n)}return t}function jA(r,e){let t=Ka(r,e),n=e.offset,o=e.offset+t,i=[];for(let s=n;s<o;s++)s===n&&r[s]===0||i.push(r[s]);return e.offset+=t,Uint8Array.from(i)}function LA(r,e){let t=Ka(r,e),n=e.offset+t,o=r[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let f=r[e.offset];if(e.offset++,c.push(f&127),f<128){c.reverse();let p=0;for(let l=0;l<c.length;l++)p+=c[l]<<l*7;a+=`.${p}`,c=[]}}return a}function MA(r,e){return e.offset++,null}function UA(r,e){let t=Ka(r,e),n=r[e.offset];e.offset++;let o=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function KA(r,e){let t=Ka(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function HA(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new ge;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function Tf(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=HA(r.byteLength);return new ge(Uint8Array.from([e.byteLength|Mh]),e)}function Rt(r){let e=new ge,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new ge(Uint8Array.from([2]),Tf(e),e)}function Ha(r){let e=Uint8Array.from([0]),t=new ge(e,r);return new ge(Uint8Array.from([3]),Tf(t),t)}function D0(r){return new ge(Uint8Array.from([4]),Tf(r),r)}function _r(r,e=48){let t=new ge;for(let n of r)t.append(n);return new ge(Uint8Array.from([e]),Tf(t),t)}async function R0(r="P-256"){let e=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:r},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",e.publicKey),privateKey:await crypto.subtle.exportKey("jwk",e.privateKey)}}async function j0(r,e,t){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["sign"]);t?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function L0(r,e,t,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,e,t.subarray());return n?.signal?.throwIfAborted(),i}var VA=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),$A=Uint8Array.from([6,5,43,129,4,0,34]),FA=Uint8Array.from([6,5,43,129,4,0,35]),WA={ext:!0,kty:"EC",crv:"P-256"},qA={ext:!0,kty:"EC",crv:"P-384"},GA={ext:!0,kty:"EC",crv:"P-521"},Uh=32,Kh=48,Hh=66;function Vh(r){let e=pn(r);return M0(e)}function M0(r){let e=r[1][1][0],t=1,n,o;if(e.byteLength===Uh*2+1)return n=le(e.subarray(t,t+Uh),"base64url"),o=le(e.subarray(t+Uh),"base64url"),new $o({...WA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Kh*2+1)return n=le(e.subarray(t,t+Kh),"base64url"),o=le(e.subarray(t+Kh),"base64url"),new $o({...qA,key_ops:["verify"],x:n,y:o});if(e.byteLength===Hh*2+1)return n=le(e.subarray(t,t+Hh),"base64url"),o=le(e.subarray(t+Hh),"base64url"),new $o({...GA,key_ops:["verify"],x:n,y:o});throw new _e(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function U0(r){return _r([Rt(Uint8Array.from([1])),D0(me(r.d??"","base64url")),_r([H0(r.crv)],160),_r([Ha(new ge(Uint8Array.from([4]),me(r.x??"","base64url"),me(r.y??"","base64url")))],161)]).subarray()}function K0(r){return _r([Rt(Uint8Array.from([1])),_r([H0(r.crv)],160),_r([Ha(new ge(Uint8Array.from([4]),me(r.x??"","base64url"),me(r.y??"","base64url")))],161)]).subarray()}function H0(r){if(r==="P-256")return VA;if(r==="P-384")return $A;if(r==="P-521")return FA;throw new _e(`Invalid curve ${r}`)}async function V0(r="P-256"){let e=await R0(r);return new If(e.privateKey)}var $o=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=K0(this.jwk)),this._raw}toMultihash(){return vr.digest(Zn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ye.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}async verify(e,t,n){return L0(this.jwk,t,e,n)}},If=class{type="ECDSA";jwk;publicKey;_raw;constructor(e){this.jwk=e,this.publicKey=new $o({crv:e.crv,ext:e.ext,key_ops:["verify"],kty:"EC",x:e.x,y:e.y})}get raw(){return this._raw==null&&(this._raw=U0(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}async sign(e,t){return j0(this.jwk,e,t)}};function Fo(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ar(r,e=""){if(!Number.isSafeInteger(r)||r<0){let t=e&&`"${e}" `;throw new Error(`${t}expected integer >= 0, got ${r}`)}}function he(r,e,t=""){let n=Fo(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function Wo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash must wrapped by utils.createHasher");ar(r.outputLen),ar(r.blockLen)}function ps(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function F0(r,e){he(r,void 0,"digestInto() output");let t=e.outputLen;if(r.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function Sr(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function Of(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ar(r,e){return r<<32-e|r>>>e}var W0=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",zA=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function dn(r){if(he(r),W0)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=zA[r[t]];return e}var hn={_0:48,_9:57,A:65,F:70,a:97,f:102};function $0(r){if(r>=hn._0&&r<=hn._9)return r-hn._0;if(r>=hn.A&&r<=hn.F)return r-(hn.A-10);if(r>=hn.a&&r<=hn.f)return r-(hn.a-10)}function yn(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(W0)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=$0(r.charCodeAt(i)),a=$0(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ht(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];he(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function $h(r,e={}){let t=(o,i)=>r(i).update(o).digest(),n=r(void 0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=o=>r(o),Object.assign(t,e),Object.freeze(t)}function Jn(r=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(r))}var Fh=r=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,r])});function q0(r,e,t){return r&e^~r&t}function G0(r,e,t){return r&e^r&t^e&t}var Va=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,o){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Of(this.buffer)}update(e){ps(this),he(e);let{view:t,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Of(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ps(this),F0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,Sr(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)t[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let a=Of(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=c/4,p=this.get();if(f>p.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,p[l],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:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},mn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var gt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Bf=BigInt(4294967295),z0=BigInt(32);function XA(r,e=!1){return e?{h:Number(r&Bf),l:Number(r>>z0&Bf)}:{h:Number(r>>z0&Bf)|0,l:Number(r&Bf)|0}}function X0(r,e=!1){let t=r.length,n=new Uint32Array(t),o=new Uint32Array(t);for(let i=0;i<t;i++){let{h:s,l:a}=XA(r[i],e);[n[i],o[i]]=[s,a]}return[n,o]}var Wh=(r,e,t)=>r>>>t,qh=(r,e,t)=>r<<32-t|e>>>t,qo=(r,e,t)=>r>>>t|e<<32-t,Go=(r,e,t)=>r<<32-t|e>>>t,$a=(r,e,t)=>r<<64-t|e>>>t-32,Fa=(r,e,t)=>r>>>t-32|e<<64-t;function $r(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Y0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Z0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,J0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Q0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,eb=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),tb=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var ZA=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]),Qn=new Uint32Array(64),Gh=class extends Va{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Qn[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let y=Qn[l-15],d=Qn[l-2],g=Ar(y,7)^Ar(y,18)^y>>>3,C=Ar(d,17)^Ar(d,19)^d>>>10;Qn[l]=C+Qn[l-7]+g+Qn[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:p}=this;for(let l=0;l<64;l++){let y=Ar(a,6)^Ar(a,11)^Ar(a,25),d=p+y+q0(a,c,f)+ZA[l]+Qn[l]|0,C=(Ar(n,2)^Ar(n,13)^Ar(n,22))+G0(n,o,i)|0;p=f,f=c,c=a,a=s+d|0,s=i,i=o,o=n,n=d+C|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,p=p+this.H|0,this.set(n,o,i,s,a,c,f,p)}roundClean(){Sr(Qn)}destroy(){this.set(0,0,0,0,0,0,0,0),Sr(this.buffer)}},zh=class extends Gh{A=mn[0]|0;B=mn[1]|0;C=mn[2]|0;D=mn[3]|0;E=mn[4]|0;F=mn[5]|0;G=mn[6]|0;H=mn[7]|0;constructor(){super(32)}};var rb=X0(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),JA=rb[0],QA=rb[1],eo=new Uint32Array(80),to=new Uint32Array(80),Xh=class extends Va{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:p,Fh:l,Fl:y,Gh:d,Gl:g,Hh:C,Hl:m}=this;return[e,t,n,o,i,s,a,c,f,p,l,y,d,g,C,m]}set(e,t,n,o,i,s,a,c,f,p,l,y,d,g,C,m){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=p|0,this.Fh=l|0,this.Fl=y|0,this.Gh=d|0,this.Gl=g|0,this.Hh=C|0,this.Hl=m|0}process(e,t){for(let O=0;O<16;O++,t+=4)eo[O]=e.getUint32(t),to[O]=e.getUint32(t+=4);for(let O=16;O<80;O++){let H=eo[O-15]|0,J=to[O-15]|0,z=qo(H,J,1)^qo(H,J,8)^Wh(H,J,7),oe=Go(H,J,1)^Go(H,J,8)^qh(H,J,7),j=eo[O-2]|0,P=to[O-2]|0,X=qo(j,P,19)^$a(j,P,61)^Wh(j,P,6),Q=Go(j,P,19)^Fa(j,P,61)^qh(j,P,6),$=J0(oe,Q,to[O-7],to[O-16]),I=Q0($,z,X,eo[O-7],eo[O-16]);eo[O]=I|0,to[O]=$|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:p,Eh:l,El:y,Fh:d,Fl:g,Gh:C,Gl:m,Hh:S,Hl:D}=this;for(let O=0;O<80;O++){let H=qo(l,y,14)^qo(l,y,18)^$a(l,y,41),J=Go(l,y,14)^Go(l,y,18)^Fa(l,y,41),z=l&d^~l&C,oe=y&g^~y&m,j=eb(D,J,oe,QA[O],to[O]),P=tb(j,S,H,z,JA[O],eo[O]),X=j|0,Q=qo(n,o,28)^$a(n,o,34)^$a(n,o,39),$=Go(n,o,28)^Fa(n,o,34)^Fa(n,o,39),I=n&i^n&a^i&a,_=o&s^o&c^s&c;S=C|0,D=m|0,C=d|0,m=g|0,d=l|0,g=y|0,{h:l,l:y}=$r(f|0,p|0,P|0,X|0),f=a|0,p=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let v=Y0(X,$,_);n=Z0(v,P,Q,I),o=v|0}({h:n,l:o}=$r(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$r(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$r(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:p}=$r(this.Dh|0,this.Dl|0,f|0,p|0),{h:l,l:y}=$r(this.Eh|0,this.El|0,l|0,y|0),{h:d,l:g}=$r(this.Fh|0,this.Fl|0,d|0,g|0),{h:C,l:m}=$r(this.Gh|0,this.Gl|0,C|0,m|0),{h:S,l:D}=$r(this.Hh|0,this.Hl|0,S|0,D|0),this.set(n,o,i,s,a,c,f,p,l,y,d,g,C,m,S,D)}roundClean(){Sr(eo,to)}destroy(){Sr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Yh=class extends Xh{Ah=gt[0]|0;Al=gt[1]|0;Bh=gt[2]|0;Bl=gt[3]|0;Ch=gt[4]|0;Cl=gt[5]|0;Dh=gt[6]|0;Dl=gt[7]|0;Eh=gt[8]|0;El=gt[9]|0;Fh=gt[10]|0;Fl=gt[11]|0;Gh=gt[12]|0;Gl=gt[13]|0;Hh=gt[14]|0;Hl=gt[15]|0;constructor(){super(64)}};var Fr=$h(()=>new zh,Fh(1));var nb=$h(()=>new Yh,Fh(3));var Jh=BigInt(0),Zh=BigInt(1);function gn(r,e=""){if(typeof r!="boolean"){let t=e&&`"${e}" `;throw new Error(t+"expected boolean, got type="+typeof r)}return r}function ob(r){if(typeof r=="bigint"){if(!Pf(r))throw new Error("positive bigint expected, got "+r)}else ar(r);return r}function Wa(r){let e=ob(r).toString(16);return e.length&1?"0"+e:e}function ib(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Jh:BigInt("0x"+r)}function hs(r){return ib(dn(r))}function Wr(r){return ib(dn(zo(he(r)).reverse()))}function Nf(r,e){ar(e),r=ob(r);let t=yn(r.toString(16).padStart(e*2,"0"));if(t.length!==e)throw new Error("number too large");return t}function qa(r,e){return Nf(r,e).reverse()}function zo(r){return Uint8Array.from(r)}var Pf=r=>typeof r=="bigint"&&Jh<=r;function eE(r,e,t){return Pf(r)&&Pf(e)&&Pf(t)&&e<=r&&r<t}function ro(r,e,t,n){if(!eE(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function Qh(r){let e;for(e=0;r>Jh;r>>=Zh,e+=1);return e}var Ga=r=>(Zh<<BigInt(r))-Zh;function sb(r,e,t){if(ar(r,"hashLen"),ar(e,"qByteLen"),typeof t!="function")throw new Error("hmacFn must be a function");let n=m=>new Uint8Array(m),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(r),f=n(r),p=0,l=()=>{c.fill(1),f.fill(0),p=0},y=(...m)=>t(f,Ht(c,...m)),d=(m=o)=>{f=y(i,m),c=y(),m.length!==0&&(f=y(s,m),c=y())},g=()=>{if(p++>=a)throw new Error("drbg: tried max amount of iterations");let m=0,S=[];for(;m<e;){c=y();let D=c.slice();S.push(D),m+=c.length}return Ht(...S)};return(m,S)=>{l(),d(m);let D;for(;!(D=S(g()));)d();return l(),D}}function qr(r,e={},t={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(i,s,a){let c=r[i];if(a&&c===void 0)return;let f=typeof c;if(f!==s||c===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(e,!1),o(t,!0)}function ds(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var jt=BigInt(0),pt=BigInt(1),Xo=BigInt(2),ub=BigInt(3),fb=BigInt(4),lb=BigInt(5),tE=BigInt(7),pb=BigInt(8),rE=BigInt(9),hb=BigInt(16);function Ge(r,e){let t=r%e;return t>=jt?t:e+t}function Ve(r,e,t){let n=r;for(;e-- >jt;)n*=n,n%=t;return n}function ab(r,e){if(r===jt)throw new Error("invert: expected non-zero number");if(e<=jt)throw new Error("invert: expected positive modulus, got "+e);let t=Ge(r,e),n=e,o=jt,i=pt,s=pt,a=jt;for(;t!==jt;){let f=n/t,p=n%t,l=o-s*f,y=i-a*f;n=t,t=p,o=s,i=a,s=l,a=y}if(n!==pt)throw new Error("invert: does not exist");return Ge(o,e)}function td(r,e,t){if(!r.eql(r.sqr(e),t))throw new Error("Cannot find square root")}function db(r,e){let t=(r.ORDER+pt)/fb,n=r.pow(e,t);return td(r,n,e),n}function nE(r,e){let t=(r.ORDER-lb)/pb,n=r.mul(e,Xo),o=r.pow(n,t),i=r.mul(e,o),s=r.mul(r.mul(i,Xo),o),a=r.mul(i,r.sub(s,r.ONE));return td(r,a,e),a}function oE(r){let e=ys(r),t=yb(r),n=t(e,e.neg(e.ONE)),o=t(e,n),i=t(e,e.neg(n)),s=(r+tE)/hb;return(a,c)=>{let f=a.pow(c,s),p=a.mul(f,n),l=a.mul(f,o),y=a.mul(f,i),d=a.eql(a.sqr(p),c),g=a.eql(a.sqr(l),c);f=a.cmov(f,p,d),p=a.cmov(y,l,g);let C=a.eql(a.sqr(p),c),m=a.cmov(f,p,C);return td(a,m,c),m}}function yb(r){if(r<ub)throw new Error("sqrt is not defined for small field");let e=r-pt,t=0;for(;e%Xo===jt;)e/=Xo,t++;let n=Xo,o=ys(r);for(;cb(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return db;let i=o.pow(n,e),s=(e+pt)/Xo;return function(c,f){if(c.is0(f))return f;if(cb(c,f)!==1)throw new Error("Cannot find square root");let p=t,l=c.mul(c.ONE,i),y=c.pow(f,e),d=c.pow(f,s);for(;!c.eql(y,c.ONE);){if(c.is0(y))return c.ZERO;let g=1,C=c.sqr(y);for(;!c.eql(C,c.ONE);)if(g++,C=c.sqr(C),g===p)throw new Error("Cannot find square root");let m=pt<<BigInt(p-g-1),S=c.pow(l,m);p=g,l=c.sqr(S),y=c.mul(y,l),d=c.mul(d,S)}return d}}function iE(r){return r%fb===ub?db:r%pb===lb?nE:r%hb===rE?oE(r):yb(r)}var mb=(r,e)=>(Ge(r,e)&pt)===pt,sE=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rd(r){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},t=sE.reduce((n,o)=>(n[o]="function",n),e);return qr(r,t),r}function aE(r,e,t){if(t<jt)throw new Error("invalid exponent, negatives unsupported");if(t===jt)return r.ONE;if(t===pt)return e;let n=r.ONE,o=e;for(;t>jt;)t&pt&&(n=r.mul(n,o)),o=r.sqr(o),t>>=pt;return n}function za(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),o=e.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),i=r.inv(o);return e.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),i),n}function cb(r,e){let t=(r.ORDER-pt)/Xo,n=r.pow(e,t),o=r.eql(n,r.ONE),i=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function cE(r,e){e!==void 0&&ar(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}var ed=class{ORDER;BITS;BYTES;isLE;ZERO=jt;ONE=pt;_lengths;_sqrt;_mod;constructor(e,t={}){if(e<=jt)throw new Error("invalid field: expected ORDER > 0, got "+e);let n;this.isLE=!1,t!=null&&typeof t=="object"&&(typeof t.BITS=="number"&&(n=t.BITS),typeof t.sqrt=="function"&&(this.sqrt=t.sqrt),typeof t.isLE=="boolean"&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=t.allowedLengths?.slice()),typeof t.modFromBytes=="boolean"&&(this._mod=t.modFromBytes));let{nBitLength:o,nByteLength:i}=cE(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(e){return Ge(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return jt<=e&&e<this.ORDER}is0(e){return e===jt}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&pt)===pt}neg(e){return Ge(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return Ge(e*e,this.ORDER)}add(e,t){return Ge(e+t,this.ORDER)}sub(e,t){return Ge(e-t,this.ORDER)}mul(e,t){return Ge(e*t,this.ORDER)}pow(e,t){return aE(this,e,t)}div(e,t){return Ge(e*ab(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return ab(e,this.ORDER)}sqrt(e){return this._sqrt||(this._sqrt=iE(this.ORDER)),this._sqrt(this,e)}toBytes(e){return this.isLE?qa(e,this.BYTES):Nf(e,this.BYTES)}fromBytes(e,t=!1){he(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Wr(e):hs(e);if(a&&(c=Ge(c,s)),!t&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return za(this,e)}cmov(e,t,n){return n?t:e}};function ys(r,e={}){return new ed(r,e)}function gb(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function nd(r){let e=gb(r);return e+Math.ceil(e/2)}function od(r,e,t=!1){he(r);let n=r.length,o=gb(e),i=nd(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=t?Wr(r):hs(r),a=Ge(s,e-pt)+pt;return t?qa(a,o):Nf(a,o)}var ms=BigInt(0),Yo=BigInt(1);function Xa(r,e){let t=e.negate();return r?t:e}function Zo(r,e){let t=za(r.Fp,e.map(n=>n.Z));return e.map((n,o)=>r.fromAffine(n.toAffine(t[o])))}function vb(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function id(r,e){vb(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),o=2**r,i=Ga(r),s=BigInt(r);return{windows:t,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function bb(r,e,t){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=t,a=Number(r&o),c=r>>s;a>n&&(a-=i,c+=Yo);let f=e*n,p=f+Math.abs(a)-1,l=a===0,y=a<0,d=e%2!==0;return{nextN:c,offset:p,isZero:l,isNeg:y,isNegF:d,offsetF:f}}var sd=new WeakMap,_b=new WeakMap;function ad(r){return _b.get(r)||1}function wb(r){if(r!==ms)throw new Error("invalid wNAF")}var gs=class{BASE;ZERO;Fn;bits;constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,n=this.ZERO){let o=e;for(;t>ms;)t&Yo&&(n=n.add(o)),o=o.double(),t>>=Yo;return n}precomputeWindow(e,t){let{windows:n,windowSize:o}=id(t,this.bits),i=[],s=e,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let f=1;f<o;f++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=id(e,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:f,isZero:p,isNeg:l,isNegF:y,offsetF:d}=bb(n,a,s);n=c,p?i=i.add(Xa(y,t[d])):o=o.add(Xa(l,t[f]))}return wb(n),{p:o,f:i}}wNAFUnsafe(e,t,n,o=this.ZERO){let i=id(e,this.bits);for(let s=0;s<i.windows&&n!==ms;s++){let{nextN:a,offset:c,isZero:f,isNeg:p}=bb(n,s,i);if(n=a,!f){let l=t[c];o=o.add(p?l.negate():l)}}return wb(n),o}getPrecomputes(e,t,n){let o=sd.get(t);return o||(o=this.precomputeWindow(t,e),e!==1&&(typeof n=="function"&&(o=n(o)),sd.set(t,o))),o}cached(e,t,n){let o=ad(e);return this.wNAF(o,this.getPrecomputes(o,e,n),t)}unsafe(e,t,n,o){let i=ad(e);return i===1?this._unsafeLadder(e,t,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),t,o)}createCache(e,t){vb(t,this.bits),_b.set(e,t),sd.delete(e)}hasCache(e){return ad(e)!==1}};function Sb(r,e,t,n){let o=e,i=r.ZERO,s=r.ZERO;for(;t>ms||n>ms;)t&Yo&&(i=i.add(o)),n&Yo&&(s=s.add(o)),o=o.double(),t>>=Yo,n>>=Yo;return{p1:i,p2:s}}function xb(r,e,t){if(e){if(e.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return rd(e),e}else return ys(r,{isLE:t})}function kf(r,e,t={},n){if(n===void 0&&(n=r==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${r} CURVE object`);for(let c of["p","n","h"]){let f=e[c];if(!(typeof f=="bigint"&&f>ms))throw new Error(`CURVE.${c} must be positive bigint`)}let o=xb(e.p,t.Fp,n),i=xb(e.n,t.Fn,n),a=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function bs(r,e){return function(n){let o=r(n);return{secretKey:o,publicKey:e(o)}}}var no=BigInt(0),ht=BigInt(1),cd=BigInt(2),uE=BigInt(8);function fE(r,e,t,n){let o=r.sqr(t),i=r.sqr(n),s=r.add(r.mul(e.a,o),i),a=r.add(r.ONE,r.mul(e.d,r.mul(o,i)));return r.eql(s,a)}function Ab(r,e={}){let t=kf("edwards",r,e,e.FpFnLE),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s}=i;qr(e,{},{uvRatio:"function"});let a=cd<<BigInt(o.BYTES*8)-ht,c=m=>n.create(m),f=e.uvRatio||((m,S)=>{try{return{isValid:!0,value:n.sqrt(n.div(m,S))}}catch{return{isValid:!1,value:no}}});if(!fE(n,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");function p(m,S,D=!1){let O=D?ht:no;return ro("coordinate "+m,S,O,a),S}function l(m){if(!(m instanceof g))throw new Error("EdwardsPoint expected")}let y=ds((m,S)=>{let{X:D,Y:O,Z:H}=m,J=m.is0();S==null&&(S=J?uE:n.inv(H));let z=c(D*S),oe=c(O*S),j=n.mul(H,S);if(J)return{x:no,y:ht};if(j!==ht)throw new Error("invZ was invalid");return{x:z,y:oe}}),d=ds(m=>{let{a:S,d:D}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:O,Y:H,Z:J,T:z}=m,oe=c(O*O),j=c(H*H),P=c(J*J),X=c(P*P),Q=c(oe*S),$=c(P*c(Q+j)),I=c(X+c(D*c(oe*j)));if($!==I)throw new Error("bad point: equation left != right (1)");let _=c(O*H),v=c(J*z);if(_!==v)throw new Error("bad point: equation left != right (2)");return!0});class g{static BASE=new g(i.Gx,i.Gy,ht,c(i.Gx*i.Gy));static ZERO=new g(no,ht,ht,no);static Fp=n;static Fn=o;X;Y;Z;T;constructor(S,D,O,H){this.X=p("x",S),this.Y=p("y",D),this.Z=p("z",O,!0),this.T=p("t",H),Object.freeze(this)}static CURVE(){return i}static fromAffine(S){if(S instanceof g)throw new Error("extended point not allowed");let{x:D,y:O}=S||{};return p("x",D),p("y",O),new g(D,O,ht,c(D*O))}static fromBytes(S,D=!1){let O=n.BYTES,{a:H,d:J}=i;S=zo(he(S,O,"point")),gn(D,"zip215");let z=zo(S),oe=S[O-1];z[O-1]=oe&-129;let j=Wr(z),P=D?a:n.ORDER;ro("point.y",j,no,P);let X=c(j*j),Q=c(X-ht),$=c(J*X-H),{isValid:I,value:_}=f(Q,$);if(!I)throw new Error("bad point: invalid y coordinate");let v=(_&ht)===ht,R=(oe&128)!==0;if(!D&&_===no&&R)throw new Error("bad point: x=0 and x_0=1");return R!==v&&(_=c(-_)),g.fromAffine({x:_,y:j})}static fromHex(S,D=!1){return g.fromBytes(yn(S),D)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(S=8,D=!0){return C.createCache(this,S),D||this.multiply(cd),this}assertValidity(){d(this)}equals(S){l(S);let{X:D,Y:O,Z:H}=this,{X:J,Y:z,Z:oe}=S,j=c(D*oe),P=c(J*H),X=c(O*oe),Q=c(z*H);return j===P&&X===Q}is0(){return this.equals(g.ZERO)}negate(){return new g(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:S}=i,{X:D,Y:O,Z:H}=this,J=c(D*D),z=c(O*O),oe=c(cd*c(H*H)),j=c(S*J),P=D+O,X=c(c(P*P)-J-z),Q=j+z,$=Q-oe,I=j-z,_=c(X*$),v=c(Q*I),R=c(X*I),M=c($*Q);return new g(_,v,M,R)}add(S){l(S);let{a:D,d:O}=i,{X:H,Y:J,Z:z,T:oe}=this,{X:j,Y:P,Z:X,T:Q}=S,$=c(H*j),I=c(J*P),_=c(oe*O*Q),v=c(z*X),R=c((H+J)*(j+P)-$-I),M=v-_,L=v+_,B=c(I-D*$),U=c(R*M),q=c(L*B),N=c(R*B),ye=c(M*L);return new g(U,q,ye,N)}subtract(S){return this.add(S.negate())}multiply(S){if(!o.isValidNot0(S))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:D,f:O}=C.cached(this,S,H=>Zo(g,H));return Zo(g,[D,O])[0]}multiplyUnsafe(S,D=g.ZERO){if(!o.isValid(S))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return S===no?g.ZERO:this.is0()||S===ht?this:C.unsafe(this,S,O=>Zo(g,O),D)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return C.unsafe(this,i.n).is0()}toAffine(S){return y(this,S)}clearCofactor(){return s===ht?this:this.multiplyUnsafe(s)}toBytes(){let{x:S,y:D}=this.toAffine(),O=n.toBytes(D);return O[O.length-1]|=S&ht?128:0,O}toHex(){return dn(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=new gs(g,o.BITS);return g.BASE.precompute(8),g}function Eb(r,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');qr(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=t,{BASE:o,Fp:i,Fn:s}=r,a=t.randomBytes||Jn,c=t.adjustScalarBytes||(j=>j),f=t.domain||((j,P,X)=>{if(gn(X,"phflag"),P.length||X)throw new Error("Contexts/pre-hash are not supported");return j});function p(j){return s.create(Wr(j))}function l(j){let P=O.secretKey;he(j,O.secretKey,"secretKey");let X=he(e(j),2*P,"hashedSecretKey"),Q=c(X.slice(0,P)),$=X.slice(P,2*P),I=p(Q);return{head:Q,prefix:$,scalar:I}}function y(j){let{head:P,prefix:X,scalar:Q}=l(j),$=o.multiply(Q),I=$.toBytes();return{head:P,prefix:X,scalar:Q,point:$,pointBytes:I}}function d(j){return y(j).pointBytes}function g(j=Uint8Array.of(),...P){let X=Ht(...P);return p(e(f(X,he(j,void 0,"context"),!!n)))}function C(j,P,X={}){j=he(j,void 0,"message"),n&&(j=n(j));let{prefix:Q,scalar:$,pointBytes:I}=y(P),_=g(X.context,Q,j),v=o.multiply(_).toBytes(),R=g(X.context,v,I,j),M=s.create(_+R*$);if(!s.isValid(M))throw new Error("sign failed: invalid s");let L=Ht(v,s.toBytes(M));return he(L,O.signature,"result")}let m={zip215:!0};function S(j,P,X,Q=m){let{context:$,zip215:I}=Q,_=O.signature;j=he(j,_,"signature"),P=he(P,void 0,"message"),X=he(X,O.publicKey,"publicKey"),I!==void 0&&gn(I,"zip215"),n&&(P=n(P));let v=_/2,R=j.subarray(0,v),M=Wr(j.subarray(v,_)),L,B,U;try{L=r.fromBytes(X,I),B=r.fromBytes(R,I),U=o.multiplyUnsafe(M)}catch{return!1}if(!I&&L.isSmallOrder())return!1;let q=g($,B.toBytes(),L.toBytes(),P);return B.add(L.multiplyUnsafe(q)).subtract(U).clearCofactor().is0()}let D=i.BYTES,O={secretKey:D,publicKey:D,signature:2*D,seed:D};function H(j=a(O.seed)){return he(j,O.seed,"seed")}function J(j){return Fo(j)&&j.length===s.BYTES}function z(j,P){try{return!!r.fromBytes(j,P)}catch{return!1}}let oe={getExtendedPublicKey:y,randomSecretKey:H,isValidSecretKey:J,isValidPublicKey:z,toMontgomery(j){let{y:P}=r.fromBytes(j),X=O.publicKey,Q=X===32;if(!Q&&X!==57)throw new Error("only defined for 25519 and 448");let $=Q?i.div(ht+P,ht-P):i.div(P-ht,P+ht);return i.toBytes($)},toMontgomerySecret(j){let P=O.secretKey;he(j,P);let X=e(j.subarray(0,P));return c(X).subarray(0,P)}};return Object.freeze({keygen:bs(H,d),getPublicKey:d,sign:C,verify:S,utils:oe,Point:r,lengths:O})}var Ya=BigInt(0),ws=BigInt(1),Df=BigInt(2);function lE(r){return qr(r,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...r})}function Cb(r){let e=lE(r),{P:t,type:n,adjustScalarBytes:o,powPminus2:i,randomBytes:s}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");let c=s||Jn,f=a?255:448,p=a?32:56,l=BigInt(a?9:5),y=BigInt(a?121665:39081),d=a?Df**BigInt(254):Df**BigInt(447),g=a?BigInt(8)*Df**BigInt(251)-ws:BigInt(4)*Df**BigInt(445)-ws,C=d+g+ws,m=_=>Ge(_,t),S=D(l);function D(_){return qa(m(_),p)}function O(_){let v=zo(he(_,p,"uCoordinate"));return a&&(v[31]&=127),m(Wr(v))}function H(_){return Wr(o(zo(he(_,p,"scalar"))))}function J(_,v){let R=X(O(v),H(_));if(R===Ya)throw new Error("invalid private or public key received");return D(R)}function z(_){return J(_,S)}let oe=z,j=J;function P(_,v,R){let M=m(_*(v-R));return v=m(v-M),R=m(R+M),{x_2:v,x_3:R}}function X(_,v){ro("u",_,Ya,t),ro("scalar",v,d,C);let R=v,M=_,L=ws,B=Ya,U=_,q=ws,N=Ya;for(let xe=BigInt(f-1);xe>=Ya;xe--){let re=R>>xe&ws;N^=re,{x_2:L,x_3:U}=P(N,L,U),{x_2:B,x_3:q}=P(N,B,q),N=re;let Ae=L+B,Ne=m(Ae*Ae),qe=L-B,Ce=m(qe*qe),ke=Ne-Ce,fn=U+q,br=U-q,Gn=m(br*Ae),uf=m(fn*qe),ns=Gn+uf,Pa=Gn-uf;U=m(ns*ns),q=m(M*m(Pa*Pa)),L=m(Ne*Ce),B=m(ke*(Ne+m(y*ke)))}({x_2:L,x_3:U}=P(N,L,U)),{x_2:B,x_3:q}=P(N,B,q);let ye=i(B);return m(L*ye)}let Q={secretKey:p,publicKey:p,seed:p},$=(_=c(p))=>(he(_,Q.seed,"seed"),_),I={randomSecretKey:$};return Object.freeze({keygen:bs($,oe),getSharedSecret:j,getPublicKey:oe,scalarMult:J,scalarMultBase:z,utils:I,GuBytes:S.slice(),lengths:Q})}var pE=BigInt(1),Tb=BigInt(2),hE=BigInt(3),dE=BigInt(5),yE=BigInt(8),Rf=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),mE={p:Rf,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:yE,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ob(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Rf,a=r*r%i*r%i,c=Ve(a,Tb,i)*a%i,f=Ve(c,pE,i)*r%i,p=Ve(f,dE,i)*f%i,l=Ve(p,e,i)*p%i,y=Ve(l,t,i)*l%i,d=Ve(y,n,i)*y%i,g=Ve(d,o,i)*d%i,C=Ve(g,o,i)*d%i,m=Ve(C,e,i)*p%i;return{pow_p_5_8:Ve(m,Tb,i)*r%i,b2:a}}function Bb(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}var Ib=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function gE(r,e){let t=Rf,n=Ge(e*e*e,t),o=Ge(n*n*e,t),i=Ob(r*o).pow_p_5_8,s=Ge(r*n*i,t),a=Ge(e*s*s,t),c=s,f=Ge(s*Ib,t),p=a===r,l=a===Ge(-r,t),y=a===Ge(-r*Ib,t);return p&&(s=c),(l||y)&&(s=f),mb(s,t)&&(s=Ge(-s,t)),{isValid:p||l,value:s}}var bE=Ab(mE,{uvRatio:gE});function wE(r){return Eb(bE,nb,Object.assign({adjustScalarBytes:Bb},r))}var Za=wE({});var Ja=(()=>{let r=Rf;return Cb({P:r,type:"x25519",powPminus2:e=>{let{pow_p_5_8:t,b2:n}=Ob(e);return Ge(Ve(t,hE,r)*n,r)},adjustScalarBytes:Bb})})();var Qa=class extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}},ec=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},jf=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Pb={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new jf("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var Vt=Pb;var Lf=32,tc=64,ud=32;var xs,Nb=(async()=>{try{return await Vt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function kb(){let r=Za.utils.randomSecretKey(),e=Za.getPublicKey(r);return{privateKey:AE(r,e),publicKey:e}}async function xE(r,e){let t;r.length===tc?t=r.subarray(0,32):t=r;let n={crv:"Ed25519",kty:"OKP",x:le(r.subarray(32),"base64url"),d:le(t,"base64url"),ext:!0,key_ops:["sign"]},o=await Vt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),i=await Vt.get().subtle.sign({name:"Ed25519"},o,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(i,0,i.byteLength)}function vE(r,e){let t=r.subarray(0,ud);return Za.sign(e instanceof Uint8Array?e:e.subarray(),t)}async function Db(r,e){return xs==null&&(xs=await Nb),xs?xE(r,e):vE(r,e)}async function _E(r,e,t){if(r.buffer instanceof ArrayBuffer){let n=await Vt.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await Vt.get().subtle.verify({name:"Ed25519"},n,e,t instanceof Uint8Array?t:t.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function SE(r,e,t){return Za.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}async function Rb(r,e,t){return xs==null&&(xs=await Nb),xs?_E(r,e,t):SE(r,e,t)}function AE(r,e){let t=new Uint8Array(tc);for(let n=0;n<ud;n++)t[n]=r[n],t[ud+n]=e[n];return t}function vs(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var rc=class{type="Ed25519";raw;constructor(e){this.raw=Uf(e,Lf)}toMultihash(){return vr.digest(Zn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ye.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}verify(e,t,n){n?.signal?.throwIfAborted();let o=Rb(this.raw,t,e);return vs(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}},Mf=class{type="Ed25519";raw;publicKey;constructor(e,t){this.raw=Uf(e,tc),this.publicKey=new rc(t)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}sign(e,t){t?.signal?.throwIfAborted();let n=Db(this.raw,e);return vs(n)?n.then(o=>(t?.signal?.throwIfAborted(),o)):(t?.signal?.throwIfAborted(),n)}};function fd(r){return r=Uf(r,Lf),new rc(r)}async function Lb(){let{privateKey:r,publicKey:e}=kb();return new Mf(r,e)}function Uf(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new _e(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var EE=Math.pow(2,7),CE=Math.pow(2,14),TE=Math.pow(2,21),ld=Math.pow(2,28),pd=Math.pow(2,35),hd=Math.pow(2,42),dd=Math.pow(2,49),De=128,It=127;function $e(r){if(r<EE)return 1;if(r<CE)return 2;if(r<TE)return 3;if(r<ld)return 4;if(r<pd)return 5;if(r<hd)return 6;if(r<dd)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function _s(r,e,t=0){switch($e(r)){case 8:e[t++]=r&255|De,r/=128;case 7:e[t++]=r&255|De,r/=128;case 6:e[t++]=r&255|De,r/=128;case 5:e[t++]=r&255|De,r/=128;case 4:e[t++]=r&255|De,r>>>=7;case 3:e[t++]=r&255|De,r>>>=7;case 2:e[t++]=r&255|De,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function IE(r,e,t=0){switch($e(r)){case 8:e.set(t++,r&255|De),r/=128;case 7:e.set(t++,r&255|De),r/=128;case 6:e.set(t++,r&255|De),r/=128;case 5:e.set(t++,r&255|De),r/=128;case 4:e.set(t++,r&255|De),r>>>=7;case 3:e.set(t++,r&255|De),r>>>=7;case 2:e.set(t++,r&255|De),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function yd(r,e){let t=r[e],n=0;if(n+=t&It,t<De||(t=r[e+1],n+=(t&It)<<7,t<De)||(t=r[e+2],n+=(t&It)<<14,t<De)||(t=r[e+3],n+=(t&It)<<21,t<De)||(t=r[e+4],n+=(t&It)*ld,t<De)||(t=r[e+5],n+=(t&It)*pd,t<De)||(t=r[e+6],n+=(t&It)*hd,t<De)||(t=r[e+7],n+=(t&It)*dd,t<De))return n;throw new RangeError("Could not decode varint")}function OE(r,e){let t=r.get(e),n=0;if(n+=t&It,t<De||(t=r.get(e+1),n+=(t&It)<<7,t<De)||(t=r.get(e+2),n+=(t&It)<<14,t<De)||(t=r.get(e+3),n+=(t&It)<<21,t<De)||(t=r.get(e+4),n+=(t&It)*ld,t<De)||(t=r.get(e+5),n+=(t&It)*pd,t<De)||(t=r.get(e+6),n+=(t&It)*hd,t<De)||(t=r.get(e+7),n+=(t&It)*dd,t<De))return n;throw new RangeError("Could not decode varint")}function Kf(r,e,t=0){return e==null&&(e=ft($e(r))),e instanceof Uint8Array?_s(r,e,t):IE(r,e,t)}function bn(r,e=0){return r instanceof Uint8Array?yd(r,e):OE(r,e)}var md=new Float32Array([-0]),oo=new Uint8Array(md.buffer);function Mb(r,e,t){md[0]=r,e[t]=oo[0],e[t+1]=oo[1],e[t+2]=oo[2],e[t+3]=oo[3]}function Ub(r,e){return oo[0]=r[e],oo[1]=r[e+1],oo[2]=r[e+2],oo[3]=r[e+3],md[0]}var gd=new Float64Array([-0]),Ot=new Uint8Array(gd.buffer);function Kb(r,e,t){gd[0]=r,e[t]=Ot[0],e[t+1]=Ot[1],e[t+2]=Ot[2],e[t+3]=Ot[3],e[t+4]=Ot[4],e[t+5]=Ot[5],e[t+6]=Ot[6],e[t+7]=Ot[7]}function Hb(r,e){return Ot[0]=r[e],Ot[1]=r[e+1],Ot[2]=r[e+2],Ot[3]=r[e+3],Ot[4]=r[e+4],Ot[5]=r[e+5],Ot[6]=r[e+6],Ot[7]=r[e+7],gd[0]}var BE=BigInt(Number.MAX_SAFE_INTEGER),PE=BigInt(Number.MIN_SAFE_INTEGER),Qt=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Jo;if(e<BE&&e>PE)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Vb&&(o=0n,++n>Vb&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Jo;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Jo}},Jo=new Qt(0,0);Jo.toBigInt=function(){return 0n};Jo.zzEncode=Jo.zzDecode=function(){return this};Jo.length=function(){return 1};var Vb=4294967296n;function $b(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Fb(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function bd(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function Er(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Hf(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var wd=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Er(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Er(this,4);return Hf(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Er(this,4);return Hf(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Er(this,4);let e=Ub(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Er(this,4);let e=Hb(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Er(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Fb(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Er(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Er(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Qt(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Er(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Er(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Er(this,8);let e=Hf(this.buf,this.pos+=4),t=Hf(this.buf,this.pos+=4);return new Qt(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=yd(this.buf,this.pos);return this.pos+=$e(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function xd(r){return new wd(r instanceof Uint8Array?r:r.subarray())}function Cr(r,e,t){let n=xd(r);return e.decode(n,void 0,t)}function vd(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return ft(s);o+s>e&&(n=ft(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Qo=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function _d(){}var Ad=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},NE=vd();function kE(r){return globalThis.Buffer!=null?ft(r):NE(r)}var ic=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qo(_d,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qo(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ed((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Vf,10,Qt.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Qt.fromBigInt(e);return this._push(Vf,t.length(),t)}uint64Number(e){return this._push(_s,$e(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Qt.fromBigInt(e).zzEncode();return this._push(Vf,t.length(),t)}sint64Number(e){let t=Qt.fromNumber(e).zzEncode();return this._push(Vf,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Sd,1,e?1:0)}fixed32(e){return this._push(oc,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Qt.fromBigInt(e);return this._push(oc,4,t.lo)._push(oc,4,t.hi)}fixed64Number(e){let t=Qt.fromNumber(e);return this._push(oc,4,t.lo)._push(oc,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Mb,4,e)}double(e){return this._push(Kb,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Sd,1,0):this.uint32(t)._push(RE,t,e)}string(e){let t=$b(e);return t!==0?this.uint32(t)._push(bd,t,e):this._push(Sd,1,0)}fork(){return this.states=new Ad(this),this.head=this.tail=new Qo(_d,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Qo(_d,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=kE(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Sd(r,e,t){e[t]=r&255}function DE(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ed=class extends Qo{next;constructor(e,t){super(DE,e,t),this.next=void 0}};function Vf(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function oc(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function RE(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(ic.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(jE,e,r),this},ic.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(LE,e,r),this});function jE(r,e,t){e.set(r,t)}function LE(r,e,t){r.length<40?bd(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(me(r),t)}function Cd(){return new ic}function Tr(r,e){let t=Cd();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Ss;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ss||(Ss={}));function $f(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function ei(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return $f("enum",Ss.VARINT,t,n)}function Ir(r,e){return $f("message",Ss.LENGTH_DELIMITED,r,e)}var sc=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var nt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(nt||(nt={}));var Td;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Td||(Td={}));(function(r){r.codec=()=>ei(Td)})(nt||(nt={}));var Gr;(function(r){let e;r.codec=()=>(e==null&&(e=Ir((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),nt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=nt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(Gr||(Gr={}));var Id;(function(r){let e;r.codec=()=>(e==null&&(e=Ir((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),nt.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=nt.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(Id||(Id={}));var cc={};Tt(cc,{MAX_RSA_KEY_SIZE:()=>Od,generateRSAKeyPair:()=>Md,jwkToJWKKeyPair:()=>Yb,jwkToPkcs1:()=>HE,jwkToPkix:()=>kd,jwkToRSAPrivateKey:()=>Ld,pkcs1MessageToJwk:()=>Pd,pkcs1MessageToRSAPrivateKey:()=>Dd,pkcs1ToJwk:()=>KE,pkcs1ToRSAPrivateKey:()=>Xb,pkixMessageToJwk:()=>Nd,pkixMessageToRSAPublicKey:()=>jd,pkixToJwk:()=>VE,pkixToRSAPublicKey:()=>Rd});var As=class{type="RSA";jwk;_raw;_multihash;constructor(e,t){this.jwk=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=cc.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return Ye.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}verify(e,t,n){return zb(this.jwk,t,e,n)}},ac=class{type="RSA";jwk;_raw;publicKey;constructor(e,t){this.jwk=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=cc.jwkToPkcs1(this.jwk)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}sign(e,t){return Gb(this.jwk,e,t)}};var Od=8192,Bd=18,ME=1062,UE=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function KE(r){let e=pn(r);return Pd(e)}function Pd(r){return{n:le(r[1],"base64url"),e:le(r[2],"base64url"),d:le(r[3],"base64url"),p:le(r[4],"base64url"),q:le(r[5],"base64url"),dp:le(r[6],"base64url"),dq:le(r[7],"base64url"),qi:le(r[8],"base64url"),kty:"RSA"}}function HE(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new _e("JWK was missing components");return _r([Rt(Uint8Array.from([0])),Rt(me(r.n,"base64url")),Rt(me(r.e,"base64url")),Rt(me(r.d,"base64url")),Rt(me(r.p,"base64url")),Rt(me(r.q,"base64url")),Rt(me(r.dp,"base64url")),Rt(me(r.dq,"base64url")),Rt(me(r.qi,"base64url"))]).subarray()}function VE(r){let e=pn(r,{offset:0});return Nd(e)}function Nd(r){let e=pn(r[1],{offset:0});return{kty:"RSA",n:le(e[0],"base64url"),e:le(e[1],"base64url")}}function kd(r){if(r.n==null||r.e==null)throw new _e("JWK was missing components");return _r([UE,Ha(_r([Rt(me(r.n,"base64url")),Rt(me(r.e,"base64url"))]))]).subarray()}function Xb(r){let e=pn(r);return Dd(e)}function Dd(r){let e=Pd(r);return Ld(e)}function Rd(r,e){if(r.byteLength>=ME)throw new os("Key size is too large");let t=pn(r,{offset:0});return jd(t,r,e)}function jd(r,e,t){let n=Nd(r);if(t==null){let o=Fr(Gr.encode({Type:nt.RSA,Data:e}));t=kt(Bd,o)}return new As(n,t)}function Ld(r){if(Jb(r)>Od)throw new _e("Key size is too large");let e=Yb(r),t=Fr(Gr.encode({Type:nt.RSA,Data:kd(e.publicKey)})),n=kt(Bd,t);return new ac(e.privateKey,new As(e.publicKey,n))}async function Md(r){if(r>Od)throw new _e("Key size is too large");let e=await Zb(r),t=Fr(Gr.encode({Type:nt.RSA,Data:kd(e.publicKey)})),n=kt(Bd,t);return new ac(e.privateKey,new As(e.publicKey,n))}function Yb(r){if(r==null)throw new _e("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}async function Zb(r,e){let t=await Vt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);e?.signal?.throwIfAborted();let n=await $E(t,e);return{privateKey:n[0],publicKey:n[1]}}async function Gb(r,e,t){let n=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);t?.signal?.throwIfAborted();let o=await Vt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,e instanceof Uint8Array?e:e.subarray());return t?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function zb(r,e,t,n){let o=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Vt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,e,t instanceof Uint8Array?t:t.subarray());return n?.signal?.throwIfAborted(),i}async function $E(r,e){if(r.privateKey==null||r.publicKey==null)throw new _e("Private and public key are required");let t=await Promise.all([Vt.get().subtle.exportKey("jwk",r.privateKey),Vt.get().subtle.exportKey("jwk",r.publicKey)]);return e?.signal?.throwIfAborted(),t}function Jb(r){if(r.kty!=="RSA")throw new _e("invalid key type");if(r.n==null)throw new _e("invalid key modulus");return me(r.n,"base64url").length*8}var Ff=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(Wo(e),he(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(t.length>n?e.create().update(t).digest():t);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),Sr(o)}update(e){return ps(this),this.iHash.update(e),this}digestInto(e){ps(this),he(e,this.outputLen,"output"),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:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,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()}},Es=(r,e,t)=>new Ff(r,e).update(t).digest();Es.create=(r,e)=>new Ff(r,e);var Qb=(r,e)=>(r+(r>=0?e:-e)/ew)/e;function FE(r,e,t){let[[n,o],[i,s]]=e,a=Qb(s*r,t),c=Qb(-o*r,t),f=r-a*n-c*i,p=-a*o-c*s,l=f<wn,y=p<wn;l&&(f=-f),y&&(p=-p);let d=Ga(Math.ceil(Qh(t)/2))+Cs;if(f<wn||f>=d||p<wn||p>=d)throw new Error("splitScalar (endomorphism): failed, k="+r);return{k1neg:l,k1:f,k2neg:y,k2:p}}function Kd(r){if(!["compact","recovered","der"].includes(r))throw new Error('Signature format must be "compact", "recovered", or "der"');return r}function Ud(r,e){let t={};for(let n of Object.keys(e))t[n]=r[n]===void 0?e[n]:r[n];return gn(t.lowS,"lowS"),gn(t.prehash,"prehash"),t.format!==void 0&&Kd(t.format),t}var Hd=class extends Error{constructor(e=""){super(e)}},io={Err:Hd,_tlv:{encode:(r,e)=>{let{Err:t}=io;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Wa(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Wa(o.length/2|128):"";return Wa(r)+i+o+e},decode(r,e){let{Err:t}=io,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let p of f)s=s<<8|p;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=io;if(r<wn)throw new e("integer: negative integers are not allowed");let t=Wa(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=io;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return hs(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=io,o=he(r,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:p}=n.decode(2,c);if(p.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=io,n=e.encode(2,t.encode(r.r)),o=e.encode(2,t.encode(r.s)),i=n+o;return e.encode(48,i)}},wn=BigInt(0),Cs=BigInt(1),ew=BigInt(2),Wf=BigInt(3),WE=BigInt(4);function tw(r,e={}){let t=kf("weierstrass",r,e),{Fp:n,Fn:o}=t,i=t.CURVE,{h:s,n:a}=i;qr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=nw(n,o);function p(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l($,I,_){let{x:v,y:R}=I.toAffine(),M=n.toBytes(v);if(gn(_,"isCompressed"),_){p();let L=!n.isOdd(R);return Ht(rw(L),M)}else return Ht(Uint8Array.of(4),M,n.toBytes(R))}function y($){he($,void 0,"Point");let{publicKey:I,publicKeyUncompressed:_}=f,v=$.length,R=$[0],M=$.subarray(1);if(v===I&&(R===2||R===3)){let L=n.fromBytes(M);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let B=C(L),U;try{U=n.sqrt(B)}catch(ye){let xe=ye instanceof Error?": "+ye.message:"";throw new Error("bad point: is not on curve, sqrt error"+xe)}p();let q=n.isOdd(U);return(R&1)===1!==q&&(U=n.neg(U)),{x:L,y:U}}else if(v===_&&R===4){let L=n.BYTES,B=n.fromBytes(M.subarray(0,L)),U=n.fromBytes(M.subarray(L,L*2));if(!m(B,U))throw new Error("bad point: is not on curve");return{x:B,y:U}}else throw new Error(`bad point: got length ${v}, expected compressed=${I} or uncompressed=${_}`)}let d=e.toBytes||l,g=e.fromBytes||y;function C($){let I=n.sqr($),_=n.mul(I,$);return n.add(n.add(_,n.mul($,i.a)),i.b)}function m($,I){let _=n.sqr(I),v=C($);return n.eql(_,v)}if(!m(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let S=n.mul(n.pow(i.a,Wf),WE),D=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(S,D)))throw new Error("bad curve params: a or b");function O($,I,_=!1){if(!n.isValid(I)||_&&n.is0(I))throw new Error(`bad point coordinate ${$}`);return I}function H($){if(!($ instanceof P))throw new Error("Weierstrass Point expected")}function J($){if(!c||!c.basises)throw new Error("no endo");return FE($,c.basises,o.ORDER)}let z=ds(($,I)=>{let{X:_,Y:v,Z:R}=$;if(n.eql(R,n.ONE))return{x:_,y:v};let M=$.is0();I==null&&(I=M?n.ONE:n.inv(R));let L=n.mul(_,I),B=n.mul(v,I),U=n.mul(R,I);if(M)return{x:n.ZERO,y:n.ZERO};if(!n.eql(U,n.ONE))throw new Error("invZ was invalid");return{x:L,y:B}}),oe=ds($=>{if($.is0()){if(e.allowInfinityPoint&&!n.is0($.Y))return;throw new Error("bad point: ZERO")}let{x:I,y:_}=$.toAffine();if(!n.isValid(I)||!n.isValid(_))throw new Error("bad point: x or y not field elements");if(!m(I,_))throw new Error("bad point: equation left != right");if(!$.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function j($,I,_,v,R){return _=new P(n.mul(_.X,$),_.Y,_.Z),I=Xa(v,I),_=Xa(R,_),I.add(_)}class P{static BASE=new P(i.Gx,i.Gy,n.ONE);static ZERO=new P(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(I,_,v){this.X=O("x",I),this.Y=O("y",_,!0),this.Z=O("z",v),Object.freeze(this)}static CURVE(){return i}static fromAffine(I){let{x:_,y:v}=I||{};if(!I||!n.isValid(_)||!n.isValid(v))throw new Error("invalid affine point");if(I instanceof P)throw new Error("projective point not allowed");return n.is0(_)&&n.is0(v)?P.ZERO:new P(_,v,n.ONE)}static fromBytes(I){let _=P.fromAffine(g(he(I,void 0,"point")));return _.assertValidity(),_}static fromHex(I){return P.fromBytes(yn(I))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,_=!0){return Q.createCache(this,I),_||this.multiply(Wf),this}assertValidity(){oe(this)}hasEvenY(){let{y:I}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(I)}equals(I){H(I);let{X:_,Y:v,Z:R}=this,{X:M,Y:L,Z:B}=I,U=n.eql(n.mul(_,B),n.mul(M,R)),q=n.eql(n.mul(v,B),n.mul(L,R));return U&&q}negate(){return new P(this.X,n.neg(this.Y),this.Z)}double(){let{a:I,b:_}=i,v=n.mul(_,Wf),{X:R,Y:M,Z:L}=this,B=n.ZERO,U=n.ZERO,q=n.ZERO,N=n.mul(R,R),ye=n.mul(M,M),xe=n.mul(L,L),re=n.mul(R,M);return re=n.add(re,re),q=n.mul(R,L),q=n.add(q,q),B=n.mul(I,q),U=n.mul(v,xe),U=n.add(B,U),B=n.sub(ye,U),U=n.add(ye,U),U=n.mul(B,U),B=n.mul(re,B),q=n.mul(v,q),xe=n.mul(I,xe),re=n.sub(N,xe),re=n.mul(I,re),re=n.add(re,q),q=n.add(N,N),N=n.add(q,N),N=n.add(N,xe),N=n.mul(N,re),U=n.add(U,N),xe=n.mul(M,L),xe=n.add(xe,xe),N=n.mul(xe,re),B=n.sub(B,N),q=n.mul(xe,ye),q=n.add(q,q),q=n.add(q,q),new P(B,U,q)}add(I){H(I);let{X:_,Y:v,Z:R}=this,{X:M,Y:L,Z:B}=I,U=n.ZERO,q=n.ZERO,N=n.ZERO,ye=i.a,xe=n.mul(i.b,Wf),re=n.mul(_,M),Ae=n.mul(v,L),Ne=n.mul(R,B),qe=n.add(_,v),Ce=n.add(M,L);qe=n.mul(qe,Ce),Ce=n.add(re,Ae),qe=n.sub(qe,Ce),Ce=n.add(_,R);let ke=n.add(M,B);return Ce=n.mul(Ce,ke),ke=n.add(re,Ne),Ce=n.sub(Ce,ke),ke=n.add(v,R),U=n.add(L,B),ke=n.mul(ke,U),U=n.add(Ae,Ne),ke=n.sub(ke,U),N=n.mul(ye,Ce),U=n.mul(xe,Ne),N=n.add(U,N),U=n.sub(Ae,N),N=n.add(Ae,N),q=n.mul(U,N),Ae=n.add(re,re),Ae=n.add(Ae,re),Ne=n.mul(ye,Ne),Ce=n.mul(xe,Ce),Ae=n.add(Ae,Ne),Ne=n.sub(re,Ne),Ne=n.mul(ye,Ne),Ce=n.add(Ce,Ne),re=n.mul(Ae,Ce),q=n.add(q,re),re=n.mul(ke,Ce),U=n.mul(qe,U),U=n.sub(U,re),re=n.mul(qe,Ae),N=n.mul(ke,N),N=n.add(N,re),new P(U,q,N)}subtract(I){return this.add(I.negate())}is0(){return this.equals(P.ZERO)}multiply(I){let{endo:_}=e;if(!o.isValidNot0(I))throw new Error("invalid scalar: out of range");let v,R,M=L=>Q.cached(this,L,B=>Zo(P,B));if(_){let{k1neg:L,k1:B,k2neg:U,k2:q}=J(I),{p:N,f:ye}=M(B),{p:xe,f:re}=M(q);R=ye.add(re),v=j(_.beta,N,xe,L,U)}else{let{p:L,f:B}=M(I);v=L,R=B}return Zo(P,[v,R])[0]}multiplyUnsafe(I){let{endo:_}=e,v=this;if(!o.isValid(I))throw new Error("invalid scalar: out of range");if(I===wn||v.is0())return P.ZERO;if(I===Cs)return v;if(Q.hasCache(this))return this.multiply(I);if(_){let{k1neg:R,k1:M,k2neg:L,k2:B}=J(I),{p1:U,p2:q}=Sb(P,v,M,B);return j(_.beta,U,q,R,L)}else return Q.unsafe(v,I)}toAffine(I){return z(this,I)}isTorsionFree(){let{isTorsionFree:I}=e;return s===Cs?!0:I?I(P,this):Q.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:I}=e;return s===Cs?this:I?I(P,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(I=!0){return gn(I,"isCompressed"),this.assertValidity(),d(P,this,I)}toHex(I=!0){return dn(this.toBytes(I))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let X=o.BITS,Q=new gs(P,e.endo?Math.ceil(X/2):X);return P.BASE.precompute(8),P}function rw(r){return Uint8Array.of(r?2:3)}function nw(r,e){return{secretKey:e.BYTES,publicKey:1+r.BYTES,publicKeyUncompressed:1+2*r.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function qE(r,e={}){let{Fn:t}=r,n=e.randomBytes||Jn,o=Object.assign(nw(r.Fp,t),{seed:nd(t.ORDER)});function i(d){try{let g=t.fromBytes(d);return t.isValidNot0(g)}catch{return!1}}function s(d,g){let{publicKey:C,publicKeyUncompressed:m}=o;try{let S=d.length;return g===!0&&S!==C||g===!1&&S!==m?!1:!!r.fromBytes(d)}catch{return!1}}function a(d=n(o.seed)){return od(he(d,o.seed,"seed"),t.ORDER)}function c(d,g=!0){return r.BASE.multiply(t.fromBytes(d)).toBytes(g)}function f(d){let{secretKey:g,publicKey:C,publicKeyUncompressed:m}=o;if(!Fo(d)||"_lengths"in t&&t._lengths||g===C)return;let S=he(d,void 0,"key").length;return S===C||S===m}function p(d,g,C=!0){if(f(d)===!0)throw new Error("first arg must be private key");if(f(g)===!1)throw new Error("second arg must be public key");let m=t.fromBytes(d);return r.fromBytes(g).multiply(m).toBytes(C)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},y=bs(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:p,keygen:y,Point:r,utils:l,lengths:o})}function ow(r,e,t={}){Wo(e),qr(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),t=Object.assign({},t);let n=t.randomBytes||Jn,o=t.hmac||((_,v)=>Es(e,_,v)),{Fp:i,Fn:s}=r,{ORDER:a,BITS:c}=s,{keygen:f,getPublicKey:p,getSharedSecret:l,utils:y,lengths:d}=qE(r,t),g={prehash:!0,lowS:typeof t.lowS=="boolean"?t.lowS:!0,format:"compact",extraEntropy:!1},C=a*ew<i.ORDER;function m(_){let v=a>>Cs;return _>v}function S(_,v){if(!s.isValidNot0(v))throw new Error(`invalid signature ${_}: out of range 1..Point.Fn.ORDER`);return v}function D(){if(C)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function O(_,v){Kd(v);let R=d.signature,M=v==="compact"?R:v==="recovered"?R+1:void 0;return he(_,M)}class H{r;s;recovery;constructor(v,R,M){if(this.r=S("r",v),this.s=S("s",R),M!=null){if(D(),![0,1,2,3].includes(M))throw new Error("invalid recovery id");this.recovery=M}Object.freeze(this)}static fromBytes(v,R=g.format){O(v,R);let M;if(R==="der"){let{r:q,s:N}=io.toSig(he(v));return new H(q,N)}R==="recovered"&&(M=v[0],R="compact",v=v.subarray(1));let L=d.signature/2,B=v.subarray(0,L),U=v.subarray(L,L*2);return new H(s.fromBytes(B),s.fromBytes(U),M)}static fromHex(v,R){return this.fromBytes(yn(v),R)}assertRecovery(){let{recovery:v}=this;if(v==null)throw new Error("invalid recovery id: must be present");return v}addRecoveryBit(v){return new H(this.r,this.s,v)}recoverPublicKey(v){let{r:R,s:M}=this,L=this.assertRecovery(),B=L===2||L===3?R+a:R;if(!i.isValid(B))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let U=i.toBytes(B),q=r.fromBytes(Ht(rw((L&1)===0),U)),N=s.inv(B),ye=z(he(v,void 0,"msgHash")),xe=s.create(-ye*N),re=s.create(M*N),Ae=r.BASE.multiplyUnsafe(xe).add(q.multiplyUnsafe(re));if(Ae.is0())throw new Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return m(this.s)}toBytes(v=g.format){if(Kd(v),v==="der")return yn(io.hexFromSig(this));let{r:R,s:M}=this,L=s.toBytes(R),B=s.toBytes(M);return v==="recovered"?(D(),Ht(Uint8Array.of(this.assertRecovery()),L,B)):Ht(L,B)}toHex(v){return dn(this.toBytes(v))}}let J=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let R=hs(v),M=v.length*8-c;return M>0?R>>BigInt(M):R},z=t.bits2int_modN||function(v){return s.create(J(v))},oe=Ga(c);function j(_){return ro("num < 2^"+c,_,wn,oe),s.toBytes(_)}function P(_,v){return he(_,void 0,"message"),v?he(e(_),void 0,"prehashed message"):_}function X(_,v,R){let{lowS:M,prehash:L,extraEntropy:B}=Ud(R,g);_=P(_,L);let U=z(_),q=s.fromBytes(v);if(!s.isValidNot0(q))throw new Error("invalid private key");let N=[j(q),j(U)];if(B!=null&&B!==!1){let Ae=B===!0?n(d.secretKey):B;N.push(he(Ae,void 0,"extraEntropy"))}let ye=Ht(...N),xe=U;function re(Ae){let Ne=J(Ae);if(!s.isValidNot0(Ne))return;let qe=s.inv(Ne),Ce=r.BASE.multiply(Ne).toAffine(),ke=s.create(Ce.x);if(ke===wn)return;let fn=s.create(qe*s.create(xe+ke*q));if(fn===wn)return;let br=(Ce.x===ke?0:2)|Number(Ce.y&Cs),Gn=fn;return M&&m(fn)&&(Gn=s.neg(fn),br^=1),new H(ke,Gn,C?void 0:br)}return{seed:ye,k2sig:re}}function Q(_,v,R={}){let{seed:M,k2sig:L}=X(_,v,R);return sb(e.outputLen,s.BYTES,o)(M,L).toBytes(R.format)}function $(_,v,R,M={}){let{lowS:L,prehash:B,format:U}=Ud(M,g);if(R=he(R,void 0,"publicKey"),v=P(v,B),!Fo(_)){let q=_ instanceof H?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}O(_,U);try{let q=H.fromBytes(_,U),N=r.fromBytes(R);if(L&&q.hasHighS())return!1;let{r:ye,s:xe}=q,re=z(v),Ae=s.inv(xe),Ne=s.create(re*Ae),qe=s.create(ye*Ae),Ce=r.BASE.multiplyUnsafe(Ne).add(N.multiplyUnsafe(qe));return Ce.is0()?!1:s.create(Ce.x)===ye}catch{return!1}}function I(_,v,R={}){let{prehash:M}=Ud(R,g);return v=P(v,M),H.fromBytes(_,"recovered").recoverPublicKey(v).toBytes()}return Object.freeze({keygen:f,getPublicKey:p,getSharedSecret:l,utils:y,lengths:d,Point:r,sign:Q,verify:$,recoverPublicKey:I,Signature:H,hash:e})}var $d={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},GE={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var iw=BigInt(2);function zE(r){let e=$d.p,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,p=f*f*r%e,l=Ve(p,t,e)*p%e,y=Ve(l,t,e)*p%e,d=Ve(y,iw,e)*f%e,g=Ve(d,o,e)*d%e,C=Ve(g,i,e)*g%e,m=Ve(C,a,e)*C%e,S=Ve(m,c,e)*m%e,D=Ve(S,a,e)*C%e,O=Ve(D,t,e)*p%e,H=Ve(O,s,e)*g%e,J=Ve(H,n,e)*f%e,z=Ve(J,iw,e);if(!Vd.eql(Vd.sqr(z),r))throw new Error("Cannot find square root");return z}var Vd=ys($d.p,{sqrt:zE}),XE=tw($d,{Fp:Vd,endo:GE}),Or=ow(XE,Fr);function sw(r,e,t){let n=sr.digest(e instanceof Uint8Array?e:e.subarray());if(vs(n))return n.then(({digest:o})=>(t?.signal?.throwIfAborted(),Or.sign(o,r,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new Qa(String(o))});try{return Or.sign(n.digest,r,{prehash:!1,format:"der"})}catch(o){throw new Qa(String(o))}}function aw(r,e,t,n){let o=sr.digest(t instanceof Uint8Array?t:t.subarray());if(vs(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Or.verify(e,i,r,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new ec(String(i))});try{return n?.signal?.throwIfAborted(),Or.verify(e,o.digest,r,{prehash:!1,format:"der"})}catch(i){throw new ec(String(i))}}var uc=class{type="secp256k1";raw;_key;constructor(e){this._key=fw(e),this.raw=cw(this._key)}toMultihash(){return vr.digest(Zn(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return Ye.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}verify(e,t,n){return aw(this._key,t,e,n)}},qf=class{type="secp256k1";raw;publicKey;constructor(e,t){this.raw=uw(e),this.publicKey=new uc(t??lw(e))}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ze(this.raw,e.raw)}sign(e,t){return sw(this.raw,e,t)}};function Fd(r){return new uc(r)}async function pw(){let r=YE();return new qf(r)}function cw(r){return Or.Point.fromBytes(r).toBytes()}function uw(r){try{return Or.getPublicKey(r,!0),r}catch(e){throw new ka(String(e))}}function fw(r){try{return Or.Point.fromBytes(r),r}catch(e){throw new os(String(e))}}function lw(r){try{return Or.getPublicKey(r,!0)}catch(e){throw new ka(String(e))}}function YE(){return Or.utils.randomSecretKey()}async function hw(r,e){if(r==="Ed25519")return Lb();if(r==="secp256k1")return pw();if(r==="RSA")return Md(ZE(e));if(r==="ECDSA")return V0(JE(e));throw new zn}function fc(r,e){let{Type:t,Data:n}=Gr.decode(r),o=n??new Uint8Array;switch(t){case nt.RSA:return Rd(o,e);case nt.Ed25519:return fd(o);case nt.secp256k1:return Fd(o);case nt.ECDSA:return Vh(o);default:throw new zn}}function dw(r){let{Type:e,Data:t}=Gr.decode(r.digest),n=t??new Uint8Array;switch(e){case nt.Ed25519:return fd(n);case nt.secp256k1:return Fd(n);case nt.ECDSA:return Vh(n);default:throw new zn}}function Zn(r){return Gr.encode({Type:nt[r.type],Data:r.raw})}function ZE(r){return r==null?2048:parseInt(r,10)}function JE(r){if(r==="P-256"||r==null)return"P-256";if(r==="P-384")return"P-384";if(r==="P-521")return"P-521";throw new _e("Unsupported curve, should be P-256, P-384 or P-521")}async function Gf(r){if(r.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(r.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",r.jwk,{name:"ECDSA",namedCurve:r.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",r.publicKey.jwk,{name:"ECDSA",namedCurve:r.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new _e("Only RSA and ECDSA keys are supported")}var yw=Symbol.for("nodejs.util.inspect.custom"),QE=114,lc=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[yh]=!0;toString(){return this.string==null&&(this.string=Ye.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(QE,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ze(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return Ze(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[yw](){return`PeerId(${this.toString()})`}},pc=class extends lc{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},hc=class extends lc{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},dc=class extends lc{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},e2=2336,yc=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=vr.digest(me(this.url))}[yw](){return`PeerId(${this.url})`}[yh]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(e2,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=le(e)),e.toString()===this.toString())}};var t2=114,mw=2336;function Ts(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ls(Ye.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return r2(ct.parse(r));if(e==null)throw new _e('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ls(e.decode(r))}return gw(t)}function Wd(r){if(r.type==="Ed25519")return new hc({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new dc({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new pc({multihash:r.toCID().multihash,publicKey:r});throw new zn}function gw(r){if(o2(r))return new pc({multihash:r});if(n2(r))try{let e=dw(r);if(e.type==="Ed25519")return new hc({multihash:r,publicKey:e});if(e.type==="secp256k1")return new dc({multihash:r,publicKey:e})}catch{let t=le(r.digest);return new yc(new URL(t))}throw new gf("Supplied PeerID Multihash is invalid")}function r2(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==t2&&r.code!==mw)throw new mf("Supplied PeerID CID is invalid");if(r.code===mw){let e=le(r.multihash.digest);return new yc(new URL(e))}return gw(r.multihash)}function n2(r){return r.code===vr.code}function o2(r){return r.code===sr.code}var bt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},xn=class extends Error{static name="ValidationError";name="ValidationError"},zf=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Xf=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Yf=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let p=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let y=Number.parseInt(l,e);if(!Number.isNaN(y))return y});if(p===void 0)break;if(i*=e,i+=p,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var i2=45,s2=15,Zf=new Yf;function bw(r){if(!(r.length>s2))return Zf.new(r).parseWith(()=>Zf.readIPv4Addr())}function ww(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>i2))return Zf.new(r).parseWith(()=>Zf.readIPv6Addr())}function Jf(r){return!!bw(r)}function xw(r){return!!ww(r)}function Gd(r){return e=>le(e,r)}function zd(r){return e=>me(e,r)}function Is(r){return new DataView(r.buffer).getUint16(r.byteOffset).toString()}function ti(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof r=="string"?parseInt(r):r),new Uint8Array(e)}function vw(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=me(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ti(n);return Dt([t,o],t.length+o.length)}function _w(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Yn.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ti(n);return Dt([t,o],t.length+o.length)}function Xd(r){let e=r.subarray(0,r.length-2),t=r.subarray(r.length-2),n=le(e,"base32"),o=Is(t);return`${n}:${o}`}var Yd=function(r){r=r.toString().trim();let e=new Uint8Array(4);return r.split(/\./g).forEach((t,n)=>{let o=parseInt(t,10);if(isNaN(o)||o<0||o>255)throw new bt("Invalid byte value in IP address");e[n]=o}),e},Sw=function(r){let e=0;r=r.toString().trim();let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Jf(t[n]),s;i&&(s=Yd(t[n]),t[n]=le(s.subarray(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,le(s.subarray(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){t[n]===""&&(t[n]="0");let i=parseInt(t[n],16);if(isNaN(i)||i<0||i>65535)throw new bt("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Aw=function(r){if(r.byteLength!==4)throw new bt("IPv4 address was incorrect length");let e=[];for(let t=0;t<r.byteLength;t++)e.push(r[t]);return e.join(".")},Ew=function(r){if(r.byteLength!==16)throw new bt("IPv6 address was incorrect length");let e=[];for(let n=0;n<r.byteLength;n+=2){let o=r[n],i=r[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let t=e.join(":");try{let n=new URL(`http://[${t}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new bt(`Invalid IPv6 address "${t}"`)}};function Cw(r){try{let e=new URL(`http://[${r}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new bt(`Invalid IPv6 address "${r}"`)}}var qd=Object.values(Vo).map(r=>r.decoder),a2=(function(){let r=qd[0].or(qd[1]);return qd.slice(2).forEach(e=>r=r.or(e)),r})();function Tw(r){return a2.decode(r)}function Iw(r){return e=>r.encoder.encode(e)}function c2(r){if(parseInt(r).toString()!==r)throw new xn("Value must be an integer")}function u2(r){if(r<0)throw new xn("Value must be a positive integer, or zero")}function f2(r){return e=>{if(e>r)throw new xn(`Value must be smaller than or equal to ${r}`)}}function l2(...r){return e=>{for(let t of r)t(e)}}var mc=l2(c2,u2,f2(65535));var dt=-1,Zd=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let t;if(typeof e=="string"?t=this.protocolsByName.get(e):t=this.protocolsByCode.get(e),t==null)throw new Xf(`Protocol ${e} was unknown`);return t}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(t=>{this.protocolsByName.set(t,e)})}removeProtocol(e){let t=this.protocolsByCode.get(e);t!=null&&(this.protocolsByCode.delete(t.code),this.protocolsByName.delete(t.name),t.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},vn=new Zd,C2=[{code:4,name:"ip4",size:32,valueToBytes:Yd,bytesToValue:Aw,validate:r=>{if(!Jf(r))throw new xn(`Invalid IPv4 address "${r}"`)}},{code:6,name:"tcp",size:16,valueToBytes:ti,bytesToValue:Is,validate:mc},{code:273,name:"udp",size:16,valueToBytes:ti,bytesToValue:Is,validate:mc},{code:33,name:"dccp",size:16,valueToBytes:ti,bytesToValue:Is,validate:mc},{code:41,name:"ip6",size:128,valueToBytes:Sw,bytesToValue:Ew,stringToValue:Cw,validate:r=>{if(!xw(r))throw new xn(`Invalid IPv6 address "${r}"`)}},{code:42,name:"ip6zone",size:dt},{code:43,name:"ipcidr",size:8,bytesToValue:Gd("base10"),valueToBytes:zd("base10")},{code:53,name:"dns",size:dt},{code:54,name:"dns4",size:dt},{code:55,name:"dns6",size:dt},{code:56,name:"dnsaddr",size:dt},{code:132,name:"sctp",size:16,valueToBytes:ti,bytesToValue:Is,validate:mc},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:dt,stringToValue:r=>decodeURIComponent(r),valueToString:r=>encodeURIComponent(r)},{code:421,name:"p2p",aliases:["ipfs"],size:dt,bytesToValue:Gd("base58btc"),valueToBytes:r=>r.startsWith("Q")||r.startsWith("1")?zd("base58btc")(r):ct.parse(r).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Xd,valueToBytes:vw},{code:445,name:"onion3",size:296,bytesToValue:Xd,valueToBytes:_w},{code:446,name:"garlic64",size:dt},{code:447,name:"garlic32",size:dt},{code:448,name:"tls"},{code:449,name:"sni",size:dt},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:dt,bytesToValue:Iw(Ho),valueToBytes:Tw},{code:480,name:"http"},{code:481,name:"http-path",size:dt,stringToValue:r=>`/${decodeURIComponent(r)}`,valueToString:r=>encodeURIComponent(r.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:dt}];C2.forEach(r=>{vn.addProtocol(r)});function Ow(r){let e=[],t=0;for(;t<r.length;){let n=bn(r,t),o=vn.getProtocol(n),i=$e(n),s=T2(o,r,t+i),a=0;s>0&&o.size===dt&&(a=$e(s));let c=i+a+s,f={code:n,name:o.name,bytes:r.subarray(t,t+c)};if(s>0){let p=t+i+a,l=r.subarray(p,p+s);f.value=o.bytesToValue?.(l)??le(l)}e.push(f),t+=c}return e}function Bw(r){let e=0,t=[];for(let n of r){if(n.bytes==null){let o=vn.getProtocol(n.code),i=$e(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??me(n.value),a=s.byteLength,o.size===dt&&(c=$e(a)));let f=new Uint8Array(i+c+a),p=0;_s(n.code,f,p),p+=i,s!=null&&(o.size===dt&&(_s(a,f,p),p+=c),f.set(s,p)),n.bytes=f}t.push(n.bytes),e+=n.bytes.byteLength}return Dt(t,e)}function Pw(r){if(r.charAt(0)!=="/")throw new bt('String multiaddr must start with "/"');let e=[],t="protocol",n="",o="";for(let i=1;i<r.length;i++){let s=r.charAt(i);s!=="/"&&(t==="protocol"?o+=r.charAt(i):n+=r.charAt(i));let a=i===r.length-1;if(s==="/"||a){let c=vn.getProtocol(o);if(t==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",t="protocol";continue}else if(a)throw new bt(`Component ${o} was missing value`);t="value"}else if(t==="value"){let f={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new bt(`Component ${o} was missing value`);f.value=c.stringToValue?.(n)??n}e.push(f),n="",o="",t="protocol"}}}if(o!==""&&n!=="")throw new bt("Incomplete multiaddr");return e}function Nw(r){return`/${r.flatMap(e=>{if(e.value==null)return e.name;let t=vn.getProtocol(e.code);if(t==null)throw new bt(`Unknown protocol code ${e.code}`);return[e.name,t.valueToString?.(e.value)??e.value]}).join("/")}`}function T2(r,e,t){return r.size==null||r.size===0?0:r.size>0?r.size/8:bn(e,t)}var I2=Symbol.for("nodejs.util.inspect.custom"),dy=Symbol.for("@multiformats/multiaddr");function O2(r){if(r==null&&(r="/"),kw(r))return r.getComponents();if(r instanceof Uint8Array)return Ow(r);if(typeof r=="string")return r=r.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),r===""&&(r="/"),Pw(r);if(Array.isArray(r))return r;throw new bt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var rl=class r{[dy]=!0;#e;#t;#r;constructor(e="/",t={}){this.#e=O2(e),t.validate!==!1&&B2(this)}get bytes(){return this.#r==null&&(this.#r=Bw(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Nw(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let t=new r(e);return new r([...this.#e,...t.getComponents()],{validate:!1})}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new zf(`Address ${this.toString()} does not contain subaddress: ${t}`);return new r(n.slice(0,o),{validate:!1})}decapsulateCode(e){let t;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){t=n;break}return new r(this.#e.slice(0,t),{validate:!1})}equals(e){return Ze(this.bytes,e.bytes)}[I2](){return`Multiaddr(${this.toString()})`}};function B2(r){r.getComponents().forEach(e=>{let t=vn.getProtocol(e.code);e.value!=null&&t.validate?.(e.value)})}function kw(r){return!!r?.[dy]}function Ns(r){return new rl(r)}var Me=r=>({match:e=>{let t=e[0];return t==null||t.code!==r||t.value!=null?!1:e.slice(1)}}),fe=(r,e)=>({match:t=>{let n=t[0];return n?.code!==r||n.value==null||e!=null&&n.value!==e?!1:t.slice(1)}}),Dw=r=>({match:e=>r.match(e)===!1?e:!1}),Ee=r=>({match:e=>{let t=r.match(e);return t===!1?e:t}}),Bt=(...r)=>({match:e=>{let t;for(let n of r){let o=n.match(e);o!==!1&&(t==null||o.length<t.length)&&(t=o)}return t??!1}}),Re=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e}});function Ue(...r){function e(o){if(o==null)return!1;let i=o.getComponents();for(let s of r){let a=s.match(i);if(a===!1)return!1;i=a}return i}function t(o){return e(o)!==!1}function n(o){let i=e(o);return i===!1?!1:i.length===0}return{matchers:r,matches:t,exactMatch:n}}var P2=fe(421),S8=Ue(P2),ol=fe(54),il=fe(55),sl=fe(56),my=fe(53),A8=Ue(ol,Ee(fe(421))),E8=Ue(il,Ee(fe(421))),C8=Ue(sl,Ee(fe(421))),T8=Ue(Bt(my,sl,ol,il),Ee(fe(421))),Rw=Re(fe(4),Ee(fe(43))),jw=Re(Ee(fe(42)),fe(41),Ee(fe(43))),gy=Bt(Rw,jw),oi=Bt(gy,my,ol,il,sl),I8=Ue(Bt(gy,Re(Bt(my,sl,ol,il),Ee(fe(421))))),O8=Ue(Rw),B8=Ue(jw),P8=Ue(gy),by=Re(oi,fe(6)),gc=Re(oi,fe(273)),N8=Ue(Re(by,Ee(fe(421)))),k8=Ue(gc),wy=Re(gc,Me(460),Ee(fe(421))),al=Re(gc,Me(461),Ee(fe(421))),N2=Bt(wy,al),D8=Ue(wy),R8=Ue(al),yy=Bt(oi,by,gc,wy,al),Lw=Bt(Re(yy,Me(477),Ee(fe(421)))),j8=Ue(Lw),Mw=Bt(Re(yy,Me(478),Ee(fe(421))),Re(yy,Me(448),Ee(fe(449)),Me(477),Ee(fe(421)))),L8=Ue(Mw),Uw=Re(gc,Me(280),Ee(fe(466)),Ee(fe(466)),Ee(fe(421))),Kw=Ue(Uw),Hw=Re(al,Me(465),Ee(fe(466)),Ee(fe(466)),Ee(fe(421))),M8=Ue(Hw),nl=Bt(Lw,Mw,Re(by,Ee(fe(421))),Re(N2,Ee(fe(421))),Re(oi,Ee(fe(421))),Uw,Hw,fe(421)),Vw=Ue(nl),k2=Re(Ee(nl),Me(290),Dw(Me(281)),Ee(fe(421))),U8=Ue(k2),D2=Bt(Re(nl,Me(290),Me(281),Ee(fe(421))),Re(nl,Me(281),Ee(fe(421))),Re(Me(281),Ee(fe(421)))),$w=Ue(D2),R2=Bt(Re(oi,fe(6),Me(480),Ee(fe(421))),Re(oi,Me(480),Ee(fe(421)))),K8=Ue(R2),j2=Re(oi,Bt(Re(fe(6,"443"),Me(480)),Re(fe(6),Me(443)),Re(fe(6),Me(448),Me(480)),Re(Me(448),Me(480)),Me(448),Me(443)),Ee(fe(421))),H8=Ue(j2),L2=Bt(Re(fe(777),Ee(fe(421)))),V8=Ue(L2),M2=Bt(Re(fe(400),Ee(fe(421)))),$8=Ue(M2);var Pt;(function(r){let e;(function(o){o.FIN="FIN",o.STOP_SENDING="STOP_SENDING",o.RESET="RESET",o.FIN_ACK="FIN_ACK"})(e=r.Flag||(r.Flag={}));let t;(function(o){o[o.FIN=0]="FIN",o[o.STOP_SENDING=1]="STOP_SENDING",o[o.RESET=2]="RESET",o[o.FIN_ACK=3]="FIN_ACK"})(t||(t={})),(function(o){o.codec=()=>ei(t)})(e=r.Flag||(r.Flag={}));let n;r.codec=()=>(n==null&&(n=Ir((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.flag!=null&&(i.uint32(8),r.Flag.codec().encode(o.flag,i)),o.message!=null&&(i.uint32(18),i.bytes(o.message)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.flag=r.Flag.codec().decode(o);break}case 2:{a.message=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Tr(o,r.codec()),r.decode=(o,i)=>Cr(o,r.codec(),i)})(Pt||(Pt={}));var Fw=["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478","stun:stun.cloudflare.com:3478","stun:stun.services.mozilla.com:3478"],xy=Array.from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"),Ww="libp2p+webrtc+v1/",qw=2*1024*1024,ks=16*1024;function U2(r=ks){let e=$e(r-$e(r)),t=1+$e(Object.keys(Pt.Flag).length-1),n=1,o=r-e-t-n,i=$e(o);return e+t+n+i}var Gw=U2();var zw=1e4,vy="/webrtc",bc="/webrtc-signaling/0.0.1",Xw="/libp2p/webrtc-direct/certificate",Yw="webrtc-direct-certificate-private-key";var Zw=12096e5,_y=864e5;function Sy(r){let e=r.getComponents(),t={},n=0;if(e[n]?.name==="ip6zone"&&(t.zone=`${e[n].value}`,n++),e[n].name==="ip4"||e[n].name==="ip6"||e[n].name==="dns"||e[n].name==="dns4"||e[n].name==="dns6"?(t.type=e[n].name,t.host=e[n].value,n++):e[n].name==="dnsaddr"&&(t.type=e[n].name,t.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(t.protocol=e[n].name==="tcp"?"tcp":"udp",t.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(t.type==="ip4"?t.cidr=parseInt(`${e[n].value}`):t.type==="ip6"&&(t.cidr=`${e[n].value}`),n++),t.type==null||t.host==null)throw new _e(`Multiaddr ${r} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(t.sni=e[n+1].value,n+=2),t}function cl(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ul=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Ds=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ul(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new ul(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Ay=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Rs(r={}){return K2(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function K2(r,e){e=e??{};let t=e.onEnd,n=new Ds,o,i,s,a=cl(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((m,S)=>{i=D=>{i=null,n.push(D);try{m(r(n))}catch(O){S(O)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=cl()})}},f=m=>i!=null?i(m):(n.push(m),o),p=m=>(n=new Ds,i!=null?i({error:m}):(n.push({error:m}),o)),l=m=>{if(s)return o;if(e?.objectMode!==!0&&m?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:m})},y=m=>s?o:(s=!0,m!=null?p(m):f({done:!0})),d=()=>(n=new Ds,y(),{done:!0}),g=m=>(y(m),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:d,throw:g,push:l,end:y,get readableLength(){return n.size},onEmpty:async m=>{let S=m?.signal;if(S?.throwIfAborted(),n.isEmpty())return;let D,O;S!=null&&(D=new Promise((H,J)=>{O=()=>{J(new Ay)},S.addEventListener("abort",O)}));try{await Promise.race([a.promise,D])}finally{O!=null&&S!=null&&S?.removeEventListener("abort",O)}}},t==null)return o;let C=o;return o={[Symbol.asyncIterator](){return this},next(){return C.next()},throw(m){return C.throw(m),t!=null&&(t(m),t=void 0),{done:!0}},return(){return C.return(),t!=null&&(t(),t=void 0),{done:!0}},push:l,end(m){return C.end(m),t!=null&&(t(m),t=void 0),o},get readableLength(){return C.readableLength},onEmpty:m=>C.onEmpty(m)},o}var Ey=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Cy=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Jw=r=>globalThis.DOMException===void 0?new Cy(r):new DOMException(r),Qw=r=>{let e=r.reason===void 0?Jw("This operation was aborted."):r.reason;return e instanceof Error?e:Jw(e)};function Ty(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,f=new Promise((p,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:d}=e;d.aborted&&l(Qw(d)),a=()=>{l(Qw(d))},d.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(p,l);return}let y=new Ey;s=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(d){l(d)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?p():o instanceof Error?l(o):(y.message=o??`Promise timed out after ${t} milliseconds`,l(y))},t),(async()=>{try{p(await r)}catch(d){l(d)}})()}).finally(()=>{f.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}var H2=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function V2(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:f,removeListener:p}=H2(r),l=async(...d)=>{let g=t.multiArgs?d:d[0];if(t.filter)try{if(!await t.filter(g))return}catch(C){n(),s(C);return}c.push(g),t.count===c.length&&(n(),i(c))},y=(...d)=>{n(),s(t.rejectionMultiArgs?d:d[0])};n=()=>{for(let d of a)p(d,l);for(let d of t.rejectionEvents)a.includes(d)||p(d,y)};for(let d of a)f(d,l);for(let d of t.rejectionEvents)a.includes(d)||f(d,y);t.signal&&t.signal.addEventListener("abort",()=>{y(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=Ty(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function ao(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=V2(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}var ii=class extends Error{static name="UnexpectedEOFError";name="UnexpectedEOFError"},fl=class extends Error{static name="MaxEarlyStreamsError";name="MaxEarlyStreamsError"},ll=class extends Error{static name="StreamClosedError";name="StreamClosedError"};function $2(r){return r.reason}async function co(r,e,t){if(e==null)return r;let n=t?.translateError??$2;if(e.aborted)return r.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([r,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var F2=Math.pow(2,20)*4,uo=class extends ir{status;timeline;inactivityTimeout;maxReadBufferLength;maxWriteBufferLength;log;direction;maxMessageSize;readStatus;writeStatus;remoteReadStatus;remoteWriteStatus;writableNeedsDrain;readBuffer;writeBuffer;sendingData;onDrainPromise;constructor(e){super(),this.status="open",this.log=e.log,this.direction=e.direction??"outbound",this.inactivityTimeout=e.inactivityTimeout??12e4,this.maxReadBufferLength=e.maxReadBufferLength??F2,this.maxWriteBufferLength=e.maxWriteBufferLength,this.maxMessageSize=e.maxMessageSize,this.readBuffer=new ge,this.writeBuffer=new ge,this.readStatus="readable",this.remoteReadStatus="readable",this.writeStatus="writable",this.remoteWriteStatus="writable",this.sendingData=!1,this.writableNeedsDrain=!1,this.timeline={open:Date.now()},this.processSendQueue=this.processSendQueue.bind(this);let t=()=>{this.writableNeedsDrain&&(this.log.trace("drain event received, continue sending data"),this.writableNeedsDrain=!1,this.processSendQueue()),this.onDrainPromise?.resolve()};this.addEventListener("drain",t);let n=o=>{this.onDrainPromise?.reject(o.error??new ll)};this.addEventListener("close",n)}get readBufferLength(){return this.readBuffer.byteLength}get writeBufferLength(){return this.writeBuffer.byteLength}async onDrain(e){return this.writableNeedsDrain!==!0?Promise.resolve():(this.onDrainPromise==null&&(this.onDrainPromise=Promise.withResolvers()),co(this.onDrainPromise.promise,e?.signal))}async*[Symbol.asyncIterator](){if(this.readStatus!=="readable"&&this.readStatus!=="paused")return;let e=Rs(),t=i=>{e.push(i.data)};this.addEventListener("message",t);let n=i=>{e.end(i.error)};this.addEventListener("close",n);let o=()=>{e.end()};this.addEventListener("remoteCloseWrite",o);try{yield*e}finally{this.removeEventListener("message",t),this.removeEventListener("close",n),this.removeEventListener("remoteCloseWrite",o)}}isReadable(){return this.status==="open"}send(e){if(this.writeStatus==="closed"||this.writeStatus==="closing")throw new Vr(`Cannot write to a stream that is ${this.writeStatus}`);return this.log.trace("append %d bytes to write buffer",e.byteLength),this.writeBuffer.append(e),this.processSendQueue()}abort(e){if(!(this.status==="aborted"||this.status==="reset"||this.status==="closed")){this.log.error("abort with error - %e",e),this.status="aborted",this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle")),this.writeStatus="closed",this.remoteWriteStatus="closed",this.readStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now();try{this.sendReset(e)}catch(t){this.log("failed to send reset to remote - %e",t)}this.dispatchEvent(new vf(e))}}pause(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Vr("Cannot pause a stream that is closing/closed");this.readStatus!=="paused"&&(this.readStatus="paused",this.sendPause())}resume(){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Vr("Cannot resume a stream that is closing/closed");this.readStatus!=="readable"&&(this.readStatus="readable",this.dispatchReadBuffer(),this.sendResume())}push(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Vr(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.append(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}unshift(e){if(this.readStatus==="closed"||this.readStatus==="closing")throw new Vr(`Cannot push data onto a stream that is ${this.readStatus}`);if(e.byteLength!==0){if(this.readBuffer.prepend(e),this.readStatus==="paused"||this.listenerCount("message")===0){this.checkReadBufferLength();return}setTimeout(()=>{this.dispatchReadBuffer()},0)}}onData(e){if(e.byteLength!==0){if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("ignoring data - read status %s",this.readStatus);return}this.readBuffer.append(e),this.dispatchReadBuffer()}}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="message"&&this.readBuffer.byteLength>0&&queueMicrotask(()=>{this.dispatchReadBuffer()})}onRemoteReset(){this.log("remote reset"),this.status="reset",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.timeline.close=Date.now(),this.readBuffer.byteLength===0&&(this.readStatus="closed");let e=new is;this.dispatchEvent(new _f(e))}onTransportClosed(e){this.log("transport closed"),this.readStatus==="readable"&&this.readBuffer.byteLength===0&&(this.log("close readable end after transport closed and read buffer is empty"),this.readStatus="closed"),this.remoteReadStatus!=="closed"&&(this.remoteReadStatus="closed"),this.remoteWriteStatus!=="closed"&&(this.remoteWriteStatus="closed"),this.writeStatus!=="closed"&&(this.writeStatus="closed"),e!=null?this.abort(e):(this.status==="open"||this.status==="closing")&&(this.timeline.close=Date.now(),this.status="closed",this.writeStatus="closed",this.remoteWriteStatus="closed",this.remoteReadStatus="closed",this.dispatchEvent(new ss))}onRemoteCloseWrite(){this.remoteWriteStatus!=="closed"&&(this.log.trace("on remote close write"),this.remoteWriteStatus="closed",this.safeDispatchEvent("remoteCloseWrite"),this.writeStatus==="closed"&&this.onTransportClosed())}onRemoteCloseRead(){this.log.trace("on remote close read"),this.remoteReadStatus="closed",this.writeBuffer.byteLength>0&&(this.writeBuffer.consume(this.writeBuffer.byteLength),this.safeDispatchEvent("idle"))}processSendQueue(){if(this.writableNeedsDrain)return this.log.trace("not processing send queue as drain is required"),this.checkWriteBufferLength(),!1;if(this.writeBuffer.byteLength===0)return this.log.trace("not processing send queue as no bytes to send"),!0;if(this.sendingData)return this.log.trace("not processing send queue as already sending data"),!0;this.sendingData=!0,this.log.trace("processing send queue with %d queued bytes",this.writeBuffer.byteLength);try{let e=!0,t=this.writeBuffer.byteLength,n=0;for(;this.writeBuffer.byteLength>0;){let o=Math.min(this.maxMessageSize??this.writeBuffer.byteLength,this.writeBuffer.byteLength);if(o===0){e=!1;break}let i=this.writeBuffer.sublist(0,o),s=new ge(i);this.writeBuffer.consume(i.byteLength);let a=this.sendData(i);if(e=a.canSendMore,n+=a.sentBytes,a.sentBytes!==s.byteLength&&(s.consume(a.sentBytes),this.writeBuffer.prepend(s)),!e)break}return e||(this.log.trace("sent %d/%d bytes, pausing sending because underlying stream is full, %d bytes left in the write buffer",n,t,this.writeBuffer.byteLength),this.writableNeedsDrain=!0,this.checkWriteBufferLength()),this.writeBuffer.byteLength===0&&this.safeDispatchEvent("idle"),e}finally{this.sendingData=!1}}dispatchReadBuffer(){try{if(this.listenerCount("message")===0){this.log.trace("not dispatching pause buffer as there are no listeners for the message event");return}if(this.readBuffer.byteLength===0){this.log.trace("not dispatching pause buffer as there is no data to dispatch");return}if(this.readStatus==="paused"){this.log.trace("not dispatching pause buffer we are paused");return}if(this.readStatus==="closing"||this.readStatus==="closed"){this.log("dropping %d bytes because the readable end is %s",this.readBuffer.byteLength,this.readStatus),this.readBuffer.consume(this.readBuffer.byteLength);return}let e=this.readBuffer.sublist();this.readBuffer.consume(e.byteLength),this.dispatchEvent(new xf(e))}finally{this.readBuffer.byteLength===0&&this.remoteWriteStatus==="closed"&&(this.log("close readable end after dispatching read buffer and remote writable end is closed"),this.readStatus="closed"),this.checkReadBufferLength()}}checkReadBufferLength(){this.readBuffer.byteLength>this.maxReadBufferLength&&this.abort(new Da(`Read buffer length of ${this.readBuffer.byteLength} exceeded limit of ${this.maxReadBufferLength}, read status is ${this.readStatus}`))}checkWriteBufferLength(){this.maxWriteBufferLength!=null&&this.writeBuffer.byteLength>this.maxWriteBufferLength&&this.abort(new Da(`Write buffer length of ${this.writeBuffer.byteLength} exceeded limit of ${this.maxWriteBufferLength}, write status is ${this.writeStatus}`))}onMuxerNeedsDrain(){this.writableNeedsDrain=!0}onMuxerDrain(){this.safeDispatchEvent("drain")}};var pl=class extends uo{remoteAddr;metricPrefix;metrics;constructor(e){super(e),this.metricPrefix=e.metricPrefix??"",this.metrics=e.metrics,this.remoteAddr=e.remoteAddr,this.addEventListener("close",t=>{this.metrics?.increment({[`${this.metricPrefix}end`]:!0}),t.error!=null?t.local?this.metrics?.increment({[`${this.metricPrefix}abort`]:!0}):this.metrics?.increment({[`${this.metricPrefix}reset`]:!0}):t.local?this.metrics?.increment({[`${this.metricPrefix}_local_close`]:!0}):this.metrics?.increment({[`${this.metricPrefix}_remote_close`]:!0})})}async close(e){this.status==="open"&&(this.status="closing",this.writeStatus="closing",this.remoteWriteStatus="closing",this.remoteReadStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await ao(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await ao(this,"drain",{...e,rejectionEvents:["close"]})),await this.sendClose(e),this.onTransportClosed())}};function ex(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var hl=class extends ir{streams;protocol;status;log;maConn;streamOptions;earlyStreams;maxEarlyStreams;metrics;constructor(e,t){super(),this.maConn=e,this.protocol=t.protocol,this.streams=[],this.earlyStreams=[],this.status="open",this.log=e.log.newScope(t.name),this.streamOptions=t.streamOptions,this.maxEarlyStreams=t.maxEarlyStreams??10,this.metrics=t.metrics;let n=s=>{try{this.onData(s.data)}catch(a){this.abort(a),this.maConn.abort(a)}};this.maConn.addEventListener("message",n);let o=()=>{this.log("underlying stream drained, signal %d streams to continue writing",this.streams.length),this.streams.forEach(s=>{s.onMuxerDrain()})};this.maConn.addEventListener("drain",o);let i=()=>{this.log("underlying stream closed with status %s and %d streams",this.status,this.streams.length),this.onTransportClosed()};this.maConn.addEventListener("close",i)}send(e){let t=this.maConn.send(e);return t===!1&&(this.log("underlying stream saturated, signal %d streams to pause writing",this.streams.length),this.streams.forEach(n=>{n.onMuxerNeedsDrain()})),t}async close(e){this.status==="closed"||this.status==="closing"||(this.status="closing",await co(Promise.all([...this.streams].map(async t=>{await t.close(e)})),e?.signal),this.status="closed")}abort(e){this.status!=="closed"&&(this.status="closing",[...this.streams].forEach(t=>{t.abort(e)}),this.status="closed")}onTransportClosed(e){this.status="closing";try{[...this.streams].forEach(t=>{t.onTransportClosed(e)})}catch(t){this.abort(t)}this.status="closed"}async createStream(e){if(this.status!=="open")throw new df;let t=this.onCreateStream({...this.streamOptions,...e});return ex(t)&&(t=await t),this.streams.push(t),this.cleanUpStream(t),t}onRemoteStream(e){if(this.streams.push(e),this.cleanUpStream(e),this.listenerCount("stream")===0){this.earlyStreams.push(e),this.earlyStreams.length>this.maxEarlyStreams&&this.abort(new fl(`Too many early streams were opened - ${this.earlyStreams.length}/${this.maxEarlyStreams}`));return}this.safeDispatchEvent("stream",{detail:e})}cleanUpStream(e){let t=n=>{let o=this.streams.findIndex(i=>i===e);o!==-1&&this.streams.splice(o,1),n.error!=null?n.local?this.metrics?.increment({[`${e.direction}_stream_reset`]:!0}):this.metrics?.increment({[`${e.direction}_stream_abort`]:!0}):this.metrics?.increment({[`${e.direction}_stream_end`]:!0})};e.addEventListener("close",t),this.metrics?.increment({[`${e.direction}_stream`]:!0})}addEventListener(...e){super.addEventListener.apply(this,e),e[0]==="stream"&&this.earlyStreams.length>0&&queueMicrotask(()=>{this.earlyStreams.forEach(t=>{this.safeDispatchEvent("stream",{detail:t})}),this.earlyStreams=[]})}};var dl=class extends uo{id;protocol;constructor(e){super(e),this.id=e.id,this.protocol=e.protocol??""}async close(e){this.writeStatus==="closing"||this.writeStatus==="closed"||(this.writeStatus="closing",(this.sendingData||this.writeBuffer.byteLength>0)&&(this.log("waiting for write queue to become idle before closing writable end of stream, %d unsent bytes",this.writeBuffer.byteLength),await ao(this,"idle",{...e,rejectionEvents:["close"]})),this.writableNeedsDrain&&(this.log("waiting for write queue to drain before closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData),await ao(this,"drain",{...e,rejectionEvents:["close"]}),this.log("write queue drained, closing writable end of stream, %d unsent bytes, sending %s",this.writeBuffer.byteLength,this.sendingData)),await this.sendCloseWrite(e),this.writeStatus="closed",this.log("closed writable end gracefully"),this.remoteWriteStatus==="closed"&&this.onTransportClosed())}async closeRead(e){this.readStatus==="closing"||this.readStatus==="closed"||(this.readBuffer.byteLength>0&&this.readBuffer.consume(this.readBuffer.byteLength),this.readStatus="closing",await this.sendCloseRead(e),this.readStatus="closed",this.log("closed readable end gracefully"))}};var W2=4194304,yl=class extends Error{static name="UnwrappedError";name="UnwrappedError"},wc=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Oy=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},By=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function q2(r){return typeof r?.closeRead=="function"}function G2(r){return typeof r?.close=="function"}function Iy(r){return q2(r)?r.remoteWriteStatus!=="writable"&&r.readBufferLength===0:G2(r)?r.status!=="open":!1}function z2(r){return r?.addEventListener!=null&&r?.removeEventListener!=null&&r?.send!=null&&r?.push!=null&&r?.log!=null}function X2(r,e){let t=e?.maxBufferSize??W2,n=new ge,o,i=!1;if(!z2(r))throw new _e("Argument should be a Stream or a Multiaddr");let s=p=>{if(n.append(p.data),n.byteLength>t){let l=n.byteLength;n.consume(n.byteLength),o?.reject(new Error(`Read buffer overflow - ${l} > ${t}`))}o?.resolve()};r.addEventListener("message",s);let a=p=>{p.error!=null?o?.reject(p.error):o?.resolve()};r.addEventListener("close",a);let c=()=>{o?.resolve()};r.addEventListener("remoteCloseWrite",c);let f={readBuffer:n,async read(p){if(i===!0)throw new yl("Stream was unwrapped");if(Iy(r)){if(p?.bytes==null)return null;if(n.byteLength<p.bytes)throw r.log.error("closed after reading %d/%d bytes",n.byteLength,p.bytes),new ii(`Unexpected EOF - stream closed after reading ${n.byteLength}/${p.bytes} bytes`)}let l=p?.bytes??1;for(o=Promise.withResolvers();;){if(n.byteLength>=l){o.resolve();break}if(await co(o.promise,p?.signal),Iy(r)){if(n.byteLength===0&&p?.bytes==null)return null;break}o=Promise.withResolvers()}let y=p?.bytes??n.byteLength;if(n.byteLength<y){if(Iy(r))throw r.log.error("closed while reading %d/%d bytes",n.byteLength,y),new ii(`Unexpected EOF - stream closed while reading ${n.byteLength}/${y} bytes`);return f.read(p)}let d=n.sublist(0,y);return n.consume(y),d},async write(p,l){if(i===!0)throw new yl("Stream was unwrapped");r.send(p)||await ao(r,"drain",{signal:l?.signal,rejectionEvents:["close"]})},unwrap(){return i||(i=!0,r.removeEventListener("message",s),r.removeEventListener("close",a),r.removeEventListener("remoteCloseWrite",c),n.byteLength>0&&(r.log("stream unwrapped with %d unread bytes",n.byteLength),r.push(n))),r}};return f}function ml(r,e={}){let t=X2(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=$e(e.maxDataLength));let n=e?.lengthDecoder??bn,o=e?.lengthEncoder??Kf;return{async read(s){let a=-1,c=new ge;for(;;){let p=await t.read({...s,bytes:1});if(p==null)break;c.append(p);try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new wc("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new By(`Message length length too long - ${c.byteLength} > ${e.maxLengthLength}`);if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Oy(`Message length too long - ${a} > ${e.maxDataLength}`);let f=await t.read({...s,bytes:a});if(f==null)throw r.log.error("tried to read %d bytes but the stream closed",a),new ii(`Unexpected EOF - tried to read ${a} bytes but the stream closed`);if(f.byteLength!==a)throw r.log.error("read %d/%d bytes before the stream closed",f.byteLength,a),new ii(`Unexpected EOF - read ${f.byteLength}/${a} bytes before the stream closed`);return f},async write(s,a){await t.write(new ge(o(s.byteLength),s),a)},async writeV(s,a){let c=new ge(...s.flatMap(f=>[o(f.byteLength),f]));await t.write(c,a)},unwrap(){return t.unwrap()}}}function gl(r,e){let t=ml(r,e),n={read:async(o,i)=>{let s=await t.read(i);return o.decode(s)},write:async(o,i,s)=>{await t.write(i.encode(o),s)},writeV:async(o,i,s)=>{await t.writeV(o.map(a=>i.encode(a)),s)},pb:o=>({read:async i=>n.read(o,i),write:async(i,s)=>n.write(i,o,s),writeV:async(i,s)=>n.writeV(i,o,s),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var Y2=1024*1024*4,Z2=1024*1024*4,bl=class{buffer;maxBufferSize;lengthDecoder;maxDataLength;encodingLength;constructor(e={}){this.buffer=new ge,this.maxBufferSize=e.maxBufferSize??Y2,this.maxDataLength=e.maxDataLength??Z2,this.lengthDecoder=e.lengthDecoder??bn,this.encodingLength=e.encodingLength??$e}*decode(e){if(this.buffer.append(e),this.buffer.byteLength>this.maxBufferSize)throw new _e(`Buffer length limit exceeded - ${this.buffer.byteLength}/${this.maxBufferSize}`);for(;;){let t;try{t=this.lengthDecoder(this.buffer)}catch(i){if(i instanceof RangeError)break;throw i}if(t<0||t>this.maxDataLength)throw new wc("Invalid message length");let n=this.encodingLength(t),o=n+t;if(this.buffer.byteLength>=o){let i=this.buffer.sublist(n,o);this.buffer.consume(o),i.byteLength>0&&(yield i)}else break}}};var wl=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},js=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},xl=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"},xc=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function vl(r){return r[Symbol.asyncIterator]!=null}function tx(r,e){if(r.byteLength>e)throw new js("Message length too long")}var Sl=r=>{let e=$e(r),t=ft(e);return Kf(r,t),Sl.bytes=e,t};Sl.bytes=0;function vc(r,e){e=e??{};let t=e.lengthEncoder??Sl,n=e?.maxDataLength??4194304;function*o(i){tx(i,n);let s=t(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}return vl(r)?(async function*(){for await(let i of r)yield*o(i)})():(function*(){for(let i of r)yield*o(i)})()}vc.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Sl,n=e?.maxDataLength??4194304;return tx(r,n),new ge(t(r.byteLength),r)};var si;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(si||(si={}));var Py=r=>{let e=bn(r);return Py.bytes=$e(e),e};Py.bytes=0;function _c(r,e){let t=new ge,n=si.LENGTH,o=-1,i=e?.lengthDecoder??Py,s=e?.maxLengthLength??8,a=e?.maxDataLength??4194304;function*c(){for(;t.byteLength>0;){if(n===si.LENGTH)try{if(o=i(t),o<0)throw new wl("Invalid message length");if(o>a)throw new js("Message length too long");let f=i.bytes;t.consume(f),e?.onLength!=null&&e.onLength(o),n=si.DATA}catch(f){if(f instanceof RangeError){if(t.byteLength>s)throw new xl("Message length length too long");break}throw f}if(n===si.DATA){if(t.byteLength<o)break;let f=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(f),yield f,n=si.LENGTH}}}return vl(r)?(async function*(){for await(let f of r)t.append(f),yield*c();if(t.byteLength>0)throw new xc("Unexpected end of input")})():(function*(){for(let f of r)t.append(f),yield*c();if(t.byteLength>0)throw new xc("Unexpected end of input")})()}_c.fromReader=(r,e)=>{let t=1,n=(async function*(){for(;;)try{let{done:i,value:s}=await r.next(t);if(i===!0)return;s!=null&&(yield s)}catch(i){if(i.code==="ERR_UNDER_READ")return{done:!0,value:null};throw i}finally{t=1}})();return _c(n,{...e??{},onLength:i=>{t=i}})};var Ny=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},ky=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},rx=r=>globalThis.DOMException===void 0?new ky(r):new DOMException(r),nx=r=>{let e=r.reason===void 0?rx("This operation was aborted."):r.reason;return e instanceof Error?e:rx(e)};function Dy(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,f=new Promise((p,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:d}=e;d.aborted&&l(nx(d)),a=()=>{l(nx(d))},d.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(p,l);return}let y=new Ny;s=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(d){l(d)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?p():o instanceof Error?l(o):(y.message=o??`Promise timed out after ${t} milliseconds`,l(y))},t),(async()=>{try{p(await r)}catch(d){l(d)}})()}).finally(()=>{f.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}var eC=r=>{let e=r.addEventListener||r.on||r.addListener,t=r.removeEventListener||r.off||r.removeListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(r),removeListener:t.bind(r)}};function tC(r,e,t){let n,o=new Promise((i,s)=>{if(t={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...t},!(t.count>=0&&(t.count===Number.POSITIVE_INFINITY||Number.isInteger(t.count))))throw new TypeError("The `count` option should be at least 0 or more");t.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:f,removeListener:p}=eC(r),l=async(...d)=>{let g=t.multiArgs?d:d[0];if(t.filter)try{if(!await t.filter(g))return}catch(C){n(),s(C);return}c.push(g),t.count===c.length&&(n(),i(c))},y=(...d)=>{n(),s(t.rejectionMultiArgs?d:d[0])};n=()=>{for(let d of a)p(d,l);for(let d of t.rejectionEvents)a.includes(d)||p(d,y)};for(let d of a)f(d,l);for(let d of t.rejectionEvents)a.includes(d)||f(d,y);t.signal&&t.signal.addEventListener("abort",()=>{y(t.signal.reason)},{once:!0}),t.resolveImmediately&&i(c)});if(o.cancel=n,typeof t.timeout=="number"){let i=Dy(o,{milliseconds:t.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function _n(r,e,t){typeof t=="function"&&(t={filter:t}),t={...t,count:1,resolveImmediately:!1};let n=tC(r,e,t),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}var ox=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,i;n<o;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return r.concat(i||Array.prototype.slice.call(e))},rC=(function(){function r(e,t,n){this.name=e,this.version=t,this.os=n,this.type="browser"}return r})();var nC=(function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return r})();var oC=(function(){function r(e,t,n,o){this.name=e,this.version=t,this.os=n,this.bot=o,this.type="bot-device"}return r})();var iC=(function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r})();var sC=(function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r})();var aC=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,cC=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,ix=3,uC=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",aC]],sx=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function cx(r){return r?ax(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new sC:typeof navigator<"u"?ax(navigator.userAgent):pC()}function fC(r){return r!==""&&uC.reduce(function(e,t){var n=t[0],o=t[1];if(e)return e;var i=o.exec(r);return!!i&&[n,i]},!1)}function ax(r){var e=fC(r);if(!e)return null;var t=e[0],n=e[1];if(t==="searchbot")return new iC;var o=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);o?o.length<ix&&(o=ox(ox([],o,!0),hC(ix-o.length),!0)):o=[];var i=o.join("."),s=lC(r),a=cC.exec(r);return a&&a[1]?new oC(t,i,s,a[1]):new rC(t,i,s)}function lC(r){for(var e=0,t=sx.length;e<t;e++){var n=sx[e],o=n[0],i=n[1],s=i.exec(r);if(s)return o}return null}function pC(){var r=typeof process<"u"&&process.version;return r?new nC(process.version.slice(1)):null}function hC(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var ux=cx(),Al=ux!=null&&ux.name==="firefox";async function Ry(r){return r=r??{},typeof r=="function"&&(r=await r()),r.iceServers=r.iceServers??Fw.map(e=>({urls:[e]})),r}var fx=(r=32)=>Ww+[...Array(r)].map(()=>xy.at(Math.floor(Math.random()*xy.length))).join("");var jy=class extends dl{channel;incomingData;maxBufferedAmount;receivedFinAck;finAckTimeout;constructor(e){super({...e,maxMessageSize:(e.maxMessageSize??ks)-Gw}),this.channel=e.channel,this.channel.binaryType="arraybuffer",this.incomingData=Rs(),this.maxBufferedAmount=e.maxBufferedAmount??qw,this.finAckTimeout=e.finAckTimeout??zw,this.channel.onclose=()=>{this.log.trace("received datachannel close event"),this.onRemoteCloseWrite(),this.onTransportClosed()},this.channel.onerror=n=>{let o=n.error;this.log.trace("received datachannel error event - %e",o),this.abort(o)},this.channel.onmessage=async n=>{this.log("incoming message %d bytes",n.data.byteLength);let{data:o}=n;o===null||o.byteLength===0||this.incomingData.push(new Uint8Array(o,0,o.byteLength))},this.channel.bufferedAmountLowThreshold=0,this.channel.onbufferedamountlow=()=>{this.writableNeedsDrain&&this.safeDispatchEvent("drain")},Promise.resolve().then(async()=>{for await(let n of _c(this.incomingData))this.processIncomingProtobuf(n)}).catch(n=>{this.log.error("error processing incoming data channel messages - %e",n)});let t=()=>{this.channel.readyState==="open"&&(this.log.trace("stream closed, closing underlying datachannel"),this.channel.close())};this.addEventListener("close",t),this.channel.readyState!=="open"&&(this.log('channel ready state is "%s" and not "open", waiting for "open" event before sending data',this.channel.readyState),_n(this.channel,"open",{rejectionEvents:["close","error"]}).then(()=>{this.log('channel ready state is now "%s", dispatching drain',this.channel.readyState),this.safeDispatchEvent("drain")}).catch(n=>{this.abort(n.error??n)}))}sendNewStream(){}_sendMessage(e){if(this.channel.readyState!=="open")throw new Vr(`Invalid datachannel state - ${this.channel.readyState}`);if(this.log.trace('sending message, channel state "%s"',this.channel.readyState),Al){this.channel.send(e.subarray());return}for(let t of e)this.channel.send(t)}sendData(e){return this.channel.readyState!=="open"?{sentBytes:0,canSendMore:!1}:(this._sendMessage(vc.single(Pt.encode({message:e.subarray()}))),{sentBytes:e.byteLength,canSendMore:this.channel.bufferedAmount<this.maxBufferedAmount})}sendReset(e){try{this.log.error("sending reset - %e",e),this._sendFlag(Pt.Flag.RESET),this.receivedFinAck?.reject(e)}catch(t){this.log.error("failed to send reset - %e",t)}}async sendCloseWrite(e){this._sendFlag(Pt.Flag.FIN),e?.signal?.throwIfAborted(),this.receivedFinAck=Promise.withResolvers();let t=e?.signal??AbortSignal.timeout(this.finAckTimeout),n=[_n(this.channel,"close",{signal:t}),_n(this.channel,"error",{signal:t})];await Promise.any([co(this.receivedFinAck.promise,t),...n]).finally(()=>{n.forEach(o=>o.cancel())})}async sendCloseRead(e){this._sendFlag(Pt.Flag.STOP_SENDING),e?.signal?.throwIfAborted()}processIncomingProtobuf(e){let t=Pt.decode(e);t.message!=null&&(this.readStatus==="readable"||this.readStatus==="paused")&&this.onData(new ge(t.message)),t.flag!==void 0&&(this.log.trace('incoming flag %s, write status "%s", read status "%s"',t.flag,this.writeStatus,this.readStatus),t.flag===Pt.Flag.FIN&&(this._sendFlag(Pt.Flag.FIN_ACK),this.onRemoteCloseWrite()),t.flag===Pt.Flag.RESET&&(this.receivedFinAck?.reject(new is("The stream was reset")),this.onRemoteReset()),t.flag===Pt.Flag.STOP_SENDING&&this.onRemoteCloseRead(),t.flag===Pt.Flag.FIN_ACK&&this.receivedFinAck?.resolve())}_sendFlag(e){if(this.channel.readyState!=="open")return this.log.trace('not sending flag %s because channel is "%s" and not "open"',e.toString(),this.channel.readyState),!1;this.log.trace("sending flag %s",e.toString());let t=Pt.encode({flag:e}),n=vc.single(t);try{return this._sendMessage(n),!0}catch(o){this.log.error("could not send flag %s - %e",e.toString(),o)}return!1}sendPause(){}sendResume(){}};function Sc(r){let{channel:e,direction:t,isHandshake:n}=r;return new jy({...r,id:`${e.id}`,log:r.log.newScope(`${n===!0?"handshake":t}:${e.id}`),protocol:""})}var fo=class{protocol;peerConnection;metrics;dataChannelOptions;earlyDataChannels;constructor(e){this.onEarlyDataChannel=this.onEarlyDataChannel.bind(this),this.peerConnection=e.peerConnection,this.metrics=e.metrics,this.protocol=e.protocol??vy,this.dataChannelOptions=e.dataChannelOptions??{},this.peerConnection.addEventListener("datachannel",this.onEarlyDataChannel),this.earlyDataChannels=[]}onEarlyDataChannel(e){this.earlyDataChannels.push(e.channel)}createStreamMuxer(e){return this.peerConnection.removeEventListener("datachannel",this.onEarlyDataChannel),new Ly(e,{peerConnection:this.peerConnection,dataChannelOptions:this.dataChannelOptions,metrics:this.metrics,protocol:this.protocol,earlyDataChannels:this.earlyDataChannels})}},Ly=class extends hl{peerConnection;dataChannelOptions;constructor(e,t){super(e,{...t,name:"muxer"}),this.peerConnection=t.peerConnection,this.protocol=t.protocol??vy,this.dataChannelOptions=t.dataChannelOptions??{},this.peerConnection.ondatachannel=({channel:n})=>{this.onDataChannel(n)},queueMicrotask(()=>{if(this.status!=="open"){t.earlyDataChannels.forEach(n=>{n.close()});return}t.earlyDataChannels.forEach(n=>{this.onDataChannel(n)})})}onDataChannel(e){if(this.log("incoming datachannel with channel id %d, protocol %s and status %s",e.id,e.protocol,e.readyState),e.label==="init"){this.log.trace("closing init channel %d",e.id),e.close();return}let t=Sc({...this.streamOptions,...this.dataChannelOptions,channel:e,direction:"inbound",log:this.log});this.onRemoteStream(t)}async onCreateStream(e){let t=this.peerConnection.createDataChannel("",{});return this.log("open channel %d for protocol %s",t.id,e?.protocol),Sc({...e,...this.dataChannelOptions,channel:t,direction:"outbound",log:this.log})}onData(){}};var My=class extends pl{peerConnection;constructor(e){super(e),this.peerConnection=e.peerConnection;let t=e.peerConnection.connectionState;this.peerConnection.onconnectionstatechange=()=>{this.log.trace("peer connection state change %s initial state %s",this.peerConnection.connectionState,t),(this.peerConnection.connectionState==="disconnected"||this.peerConnection.connectionState==="failed"||this.peerConnection.connectionState==="closed")&&(this.onTransportClosed(),this.peerConnection.close())}}sendData(e){return{sentBytes:e.byteLength,canSendMore:!0}}async sendClose(e){this.peerConnection.close(),e?.signal?.throwIfAborted()}sendReset(){this.peerConnection.close()}sendPause(){}sendResume(){}},Ac=r=>new My(r);var El=globalThis.RTCPeerConnection,Cl=globalThis.RTCSessionDescription,lx=globalThis.RTCIceCandidate;var er=class extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}};var lo=class extends Error{constructor(e){super(`WebRTC transport error: ${e}`),this.name="WebRTCTransportError"}},cr=class extends lo{constructor(e="SDP handshake failed"){super(e),this.name="SDPHandshakeFailedError"}};var Tl=class extends lo{constructor(e,t){super(`Invalid fingerprint "${e}" within ${t}`),this.name="WebRTC/InvalidFingerprintError"}};var Il=class extends lo{constructor(e){super(`A method (${e}) was called though it has been intentionally left unimplemented.`),this.name="WebRTC/UnimplementedError"}},Ol=class extends lo{constructor(e){super(`unsupported hash algorithm code: ${e} please see the codes at https://github.com/multiformats/multicodec/blob/master/table.csv `),this.name="WebRTC/UnsupportedHashAlgorithmError"}};var $t;(function(r){let e;(function(o){o.SDP_OFFER="SDP_OFFER",o.SDP_ANSWER="SDP_ANSWER",o.ICE_CANDIDATE="ICE_CANDIDATE"})(e=r.Type||(r.Type={}));let t;(function(o){o[o.SDP_OFFER=0]="SDP_OFFER",o[o.SDP_ANSWER=1]="SDP_ANSWER",o[o.ICE_CANDIDATE=2]="ICE_CANDIDATE"})(t||(t={})),(function(o){o.codec=()=>ei(t)})(e=r.Type||(r.Type={}));let n;r.codec=()=>(n==null&&(n=Ir((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.type!=null&&(i.uint32(8),r.Type.codec().encode(o.type,i)),o.data!=null&&(i.uint32(18),i.string(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.type=r.Type.codec().decode(o);break}case 2:{a.data=o.string();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Tr(o,r.codec()),r.decode=(o,i)=>Cr(o,r.codec(),i)})($t||($t={}));var Bl=async(r,e,t)=>{try{let n=Promise.withResolvers();for(dC(r,n);;){let o=await Promise.race([n.promise,e.read({signal:t.signal})]);if(o==null){t.signal?.throwIfAborted();break}if(o.type!==$t.Type.ICE_CANDIDATE)throw new bf("ICE candidate message expected");let i=JSON.parse(o.data??"null");if(i===""||i===null){t.onProgress?.(new er("webrtc:end-of-ice-candidates")),t.log.trace("end-of-candidates received");continue}let s=new lx(i);t.log.trace("%s received new ICE candidate %o",t.direction,i);try{t.onProgress?.(new er("webrtc:add-ice-candidate",s.candidate)),await r.addIceCandidate(s)}catch(a){t.log.error("%s bad candidate received %o - %e",t.direction,i,a)}}}catch(n){if(t.log.error("%s error parsing ICE candidate - %e",t.direction,n),t.signal?.aborted===!0&&r.connectionState!=="connected")throw n}};function dC(r,e){if(r.connectionState==="connected"){e.resolve();return}r.onconnectionstatechange=t=>{switch(r.connectionState){case"connected":e.resolve();break;case"failed":case"disconnected":case"closed":e.reject(new hf(`RTCPeerConnection connection state became "${r.connectionState}"`));break;default:break}}}function Pl(r){let e;for(let t of r.getComponents())t.name==="p2p"&&(e=Ts(t.value??""));if(e==null)throw new yf("Remote peerId must be present in multiaddr");return e}async function px({rtcConfiguration:r,dataChannel:e,signal:t,metrics:n,multiaddr:o,connectionManager:i,transportManager:s,log:a,logger:c,onProgress:f}){let{circuitAddress:p,targetPeer:l}=hx(o);n?.dialerEvents.increment({open:!0}),a.trace("dialing circuit address: %a",p);let y=i.getConnections(l),d;y.length===0?(f?.(new er("webrtc:dial-relay")),d=await s.dial(p,{signal:t,onProgress:f})):(f?.(new er("webrtc:reuse-relay-connection")),d=y[0]),f?.(new er("webrtc:open-signaling-stream"));let g=await d.newStream(bc,{signal:t,runOnLimitedConnection:!0}),C=gl(g).pb($t),m=new El(r);m.addEventListener("connectionstatechange",()=>{switch(m.connectionState){case"closed":m.close();break;default:break}});let S=new fo({peerConnection:m,dataChannelOptions:e});try{let D=m.createDataChannel("init");m.onicecandidate=({candidate:z})=>{if(m.connectionState==="connected"){a.trace("ignore new ice candidate as peer connection is already connected");return}if(z==null||z?.candidate===""){a.trace("initiator detected end of ICE candidates");return}let oe=JSON.stringify(z?.toJSON()??null);a.trace("initiator sending ICE candidate %o",z),C.write({type:$t.Type.ICE_CANDIDATE,data:oe},{signal:t}).catch(j=>{a.error("error sending ICE candidate - %e",j)})},m.onicecandidateerror=z=>{a.error("initiator ICE candidate error",z)};let O=await m.createOffer().catch(z=>{throw a.error("could not execute createOffer - %e",z),new cr("Failed to set createOffer")});a.trace("initiator send SDP offer %s",O.sdp),f?.(new er("webrtc:send-sdp-offer")),await C.write({type:$t.Type.SDP_OFFER,data:O.sdp},{signal:t}),await m.setLocalDescription(O).catch(z=>{throw a.error("could not execute setLocalDescription - %e",z),new cr("Failed to set localDescription")}),f?.(new er("webrtc:read-sdp-answer")),a.trace("initiator read SDP answer");let H=await C.read({signal:t});if(H.type!==$t.Type.SDP_ANSWER)throw new cr("Remote should send an SDP answer");a.trace("initiator received SDP answer %s",H.data);let J=new Cl({type:"answer",sdp:H.data});return await m.setRemoteDescription(J).catch(z=>{throw a.error("could not execute setRemoteDescription - %e",z),new cr("Failed to set remoteDescription")}),a.trace("initiator read candidates until connected"),f?.(new er("webrtc:read-ice-candidates")),await Bl(m,C,{direction:"initiator",signal:t,log:a,onProgress:f}),a.trace("initiator connected"),D.readyState!=="open"&&(a.trace("wait for init channel to open"),await _n(D,"open",{signal:t})),a.trace("closing init channel"),D.close(),a.trace("waiting for init channel to close"),await _n(D,"close",{signal:t}),f?.(new er("webrtc:close-signaling-stream")),a.trace("closing signaling channel"),await g.close({signal:t}),a.trace("initiator connected to remote address %s",o),{remoteAddress:o,peerConnection:m,muxerFactory:S}}catch(D){throw a.error("outgoing signaling error - %e",D),m.close(),g.abort(D),D}finally{m.onicecandidate=null,m.onicecandidateerror=null}}var dx=Ue(Vw.matchers[0],Me(290)),Nl=class r extends ir{transportManager;shutdownController;events;constructor(e,t){super(),this.transportManager=e.transportManager,this.events=e.events,this.shutdownController=t.shutdownController,this.onTransportListening=this.onTransportListening.bind(this)}async listen(){this.events.addEventListener("transport:listening",this.onTransportListening)}onTransportListening(e){e.detail.getAddrs().filter(n=>dx.exactMatch(n)).map(n=>n.encapsulate("/webrtc")).length>0&&this.safeDispatchEvent("listening")}getAddrs(){return this.transportManager.getListeners().filter(e=>!(e instanceof r)).map(e=>e.getAddrs().filter(t=>dx.exactMatch(t)).map(t=>t.encapsulate("/webrtc"))).flat()}updateAnnounceAddrs(){}async close(){this.events.removeEventListener("transport:listening",this.onTransportListening),this.shutdownController.abort(),queueMicrotask(()=>{this.safeDispatchEvent("close")})}};async function yx(r,e,{peerConnection:t,signal:n,log:o}){o.trace("new inbound signaling stream");let i=gl(r).pb($t);try{t.onicecandidate=({candidate:l})=>{if(t.connectionState==="connected"){o.trace("ignore new ice candidate as peer connection is already connected");return}if(l==null||l?.candidate===""){o.trace("recipient detected end of ICE candidates");return}let y=JSON.stringify(l?.toJSON()??null);o.trace("recipient sending ICE candidate %s",y),i.write({type:$t.Type.ICE_CANDIDATE,data:y},{signal:n}).catch(d=>{o.error("error sending ICE candidate - %e",d)})},o.trace("recipient read SDP offer");let c=await i.read({signal:n});if(c.type!==$t.Type.SDP_OFFER)throw new cr(`expected message type SDP_OFFER, received: ${c.type??"undefined"} `);o.trace("recipient received SDP offer %s",c.data);let f=new Cl({type:"offer",sdp:c.data});await t.setRemoteDescription(f).catch(l=>{throw o.error("could not execute setRemoteDescription - %e",l),new cr("Failed to set remoteDescription")});let p=await t.createAnswer().catch(l=>{throw o.error("could not execute createAnswer - %e",l),new cr("Failed to create answer")});o.trace("recipient send SDP answer %s",p.sdp),await i.write({type:$t.Type.SDP_ANSWER,data:p.sdp},{signal:n}),await t.setLocalDescription(p).catch(l=>{throw o.error("could not execute setLocalDescription - %e",l),new cr("Failed to set localDescription")}),o.trace("recipient read candidates until connected"),await Bl(t,i,{direction:"recipient",signal:n,log:o})}catch(c){if(t.connectionState!=="connected")throw o.error("error while handling signaling stream from peer %a - %e",e.remoteAddr,c),t.close(),c;o("error while handling signaling stream from peer %a, ignoring as the RTCPeerConnection is already connected",e.remoteAddr,c)}let s=Pl(e.remoteAddr),a=Ns(`/webrtc/p2p/${s}`);return o.trace("recipient connected to remote address %s",a),{remoteAddress:a,remotePeer:s}}var kl=class{components;init;log;_started=!1;metrics;shutdownController;constructor(e,t={}){this.components=e,this.init=t,this.log=e.logger.forComponent("libp2p:webrtc"),this.shutdownController=new AbortController,this.shutdownController.signal,e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_dialer_events_total",{label:"event",help:"Total count of WebRTC dialer events by type"}),listenerEvents:e.metrics.registerCounterGroup("libp2p_webrtc_listener_events_total",{label:"event",help:"Total count of WebRTC listener events by type"})})}[Sf]=!0;[Symbol.toStringTag]="@libp2p/webrtc";[as]=["@libp2p/transport"];[f0]=["@libp2p/identify","@libp2p/circuit-relay-v2-transport"];isStarted(){return this._started}async start(){await this.components.registrar.handle(bc,(e,t)=>{let n=this.components.upgrader.createInboundAbortSignal(this.shutdownController.signal);this._onProtocol(e,t,n).catch(o=>{this.log.error("failed to handle incoming connect from %p - %e",t.remotePeer,o)}).finally(()=>{n.clear()})},{runOnLimitedConnection:!0}),this._started=!0}async stop(){await this.components.registrar.unhandle(bc),this._started=!1}createListener(e){return new Nl(this.components,{shutdownController:this.shutdownController})}listenFilter(e){return e.filter($w.exactMatch)}dialFilter(e){return this.listenFilter(e)}async dial(e,t){this.log.trace("dialing address: %a",e);let{remoteAddress:n,peerConnection:o,muxerFactory:i}=await px({rtcConfiguration:await Ry(this.init.rtcConfiguration),dataChannel:this.init.dataChannel,multiaddr:e,dataChannelOptions:this.init.dataChannel,signal:t.signal,connectionManager:this.components.connectionManager,transportManager:this.components.transportManager,log:this.log,logger:this.components.logger,onProgress:t.onProgress}),s=Ac({peerConnection:o,remoteAddr:n,metrics:this.metrics?.dialerEvents,direction:"outbound",log:this.components.logger.forComponent("libp2p:webrtc:connection")}),a=await t.upgrader.upgradeOutbound(s,{skipProtection:!0,skipEncryption:!0,remotePeer:Pl(e),muxerFactory:i,onProgress:t.onProgress,signal:t.signal});return this._closeOnShutdown(o,s),a}async _onProtocol(e,t,n){let o=new El(await Ry(this.init.rtcConfiguration));o.addEventListener("connectionstatechange",()=>{switch(o.connectionState){case"closed":o.close();break;default:break}});let i=new fo({peerConnection:o,dataChannelOptions:this.init.dataChannel});try{let{remoteAddress:s,remotePeer:a}=await yx(e,t,{peerConnection:o,signal:n,log:this.log});await e.close({signal:n});let c=Ac({peerConnection:o,remoteAddr:s,metrics:this.metrics?.listenerEvents,direction:"inbound",log:this.components.logger.forComponent("libp2p:webrtc:connection")});await this.components.upgrader.upgradeInbound(c,{skipEncryption:!0,skipProtection:!0,remotePeer:a,muxerFactory:i,signal:n}),this._closeOnShutdown(o,c)}catch(s){throw this.log.error("incoming signaling error - %e",s),o.close(),e.abort(s),s}}_closeOnShutdown(e,t){let n=()=>{t.close().catch(o=>{this.log.error("could not close WebRTCMultiaddrConnection - %e",o)})};this.shutdownController.signal.addEventListener("abort",n),e.addEventListener("close",()=>{this.shutdownController.signal.removeEventListener("abort",n)})}};function hx(r){let e=r.getComponents().filter(({name:n})=>n==="p2p").map(({value:n})=>n).pop();if(e==null)throw new _e("Destination peer id was missing");return{circuitAddress:Ns(r.getComponents().filter(({name:n})=>n!=="webrtc")),targetPeer:Ts(e)}}var kz=Hr(gx());var Zr={};Tt(Zr,{Any:()=>Xr,BaseBlock:()=>ot,BaseStringBlock:()=>Ic,BitString:()=>Nr,BmpString:()=>li,Boolean:()=>ci,CharacterString:()=>xi,Choice:()=>Us,Constructed:()=>it,DATE:()=>Dc,DateTime:()=>jc,Duration:()=>Lc,EndOfContent:()=>Oc,Enumerated:()=>ui,GeneralString:()=>wi,GeneralizedTime:()=>vi,GraphicString:()=>bi,HexBlock:()=>Yr,IA5String:()=>gi,Integer:()=>In,Null:()=>Br,NumericString:()=>hi,ObjectIdentifier:()=>fi,OctetString:()=>Pr,Primitive:()=>Tn,PrintableString:()=>di,RawData:()=>Vy,RelativeObjectIdentifier:()=>kc,Repeated:()=>_i,Sequence:()=>Nt,Set:()=>Lt,TIME:()=>Mc,TeletexString:()=>yi,TimeOfDay:()=>Rc,UTCTime:()=>yo,UniversalString:()=>pi,Utf8String:()=>fr,ValueBlock:()=>wt,VideotexString:()=>mi,ViewWriter:()=>Ms,VisibleString:()=>ho,compareSchema:()=>En,fromBER:()=>Bn,verifySchema:()=>RC});var be=Hr(An());function ai(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function po(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let p=a-1;p>=0;p--){let l=Math.pow(2,p*e);f[i-p-1]=Math.floor(o/l),o-=f[i-p-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function jl(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function Ky(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=ai(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,ai(i,8)-n}function bx(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=po(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=po(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function wx(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Ft(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var jk=Math.log(2);function Ll(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function $y(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function On(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Ms=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return $y(this.items)}},Ec=[new Uint8Array([1])],xx="0123456789",Hy="name",vx="valueHexView",SC="isHexOnly",AC="idBlock",EC="tagClass",CC="tagNumber",TC="isConstructed",IC="fromBER",OC="toBER",BC="local",Wt="",kr=new ArrayBuffer(0),Jl=new Uint8Array(0),Tc="EndOfContent",Sx="OCTET STRING",Ax="BIT STRING";function Yr(r){var e;return e=class extends r{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?be.BufferSourceConverter.toUint8Array(i.valueHex):Jl}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!On(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",kr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:be.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Cn=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=Wt,warnings:n=[],valueBeforeDecode:o=Jl}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=be.BufferSourceConverter.toUint8Array(o)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:be.Convert.ToHex(this.valueBeforeDecodeView)}}};Cn.NAME="baseBlock";var wt=class extends Cn{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};wt.NAME="valueBlock";var Ml=class extends Yr(Cn){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?be.BufferSourceConverter.toUint8Array(e.valueHex):Jl,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",kr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=po(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!On(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),p=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===p){p+=255;let y=new Uint8Array(p);for(let d=0;d<f.length;d++)y[d]=f[d];f=this.valueHexView=new Uint8Array(p)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let y=0;y<c;y++)l[y]=f[y];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=ai(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Ml.NAME="identificationBlock";var Ul=class extends Cn{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!On(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ai(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=po(this.length,8);if(o.byteLength>127)return this.error="Too big length",kr;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Ul.NAME="lengthBlock";var Z={},ot=class extends Cn{constructor({name:e=Wt,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Ml(o),this.lenBlock=new Ul(o),this.valueBlock=i?new i(o):new wt(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){let n=t||new Ms;t||Ex(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?kr:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():be.Convert.ToHex(this.toBER())}onAsciiEncoding(){let e=this.constructor.NAME,t=be.Convert.ToHex(this.valueBlock.valueBeforeDecodeView);return`${e} : ${t}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return wx(t,n)}};ot.NAME="BaseBlock";function Ex(r){var e;if(r instanceof Z.Constructed)for(let t of r.valueBlock.value)Ex(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!(!((e=r.lenBlock)===null||e===void 0)&&e.isIndefiniteForm)}var Ic=class extends ot{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=Wt,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Ic.NAME="BaseStringBlock";var Kl=class extends Yr(wt){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Kl.NAME="PrimitiveValueBlock";var Cx,Tn=class extends ot{constructor(e={}){super(e,Kl),this.idBlock.isConstructed=!1}};Cx=Tn;Z.Primitive=Cx;Tn.NAME="PRIMITIVE";function PC(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Ks(r,e=0,t=r.length){let n=e,o=new ot({},wt),i=new Cn;if(!On(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=ot;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=Z.EndOfContent;break;case 1:c=Z.Boolean;break;case 2:c=Z.Integer;break;case 3:c=Z.BitString;break;case 4:c=Z.OctetString;break;case 5:c=Z.Null;break;case 6:c=Z.ObjectIdentifier;break;case 10:c=Z.Enumerated;break;case 12:c=Z.Utf8String;break;case 13:c=Z.RelativeObjectIdentifier;break;case 14:c=Z.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=Z.Sequence;break;case 17:c=Z.Set;break;case 18:c=Z.NumericString;break;case 19:c=Z.PrintableString;break;case 20:c=Z.TeletexString;break;case 21:c=Z.VideotexString;break;case 22:c=Z.IA5String;break;case 23:c=Z.UTCTime;break;case 24:c=Z.GeneralizedTime;break;case 25:c=Z.GraphicString;break;case 26:c=Z.VisibleString;break;case 27:c=Z.GeneralString;break;case 28:c=Z.UniversalString;break;case 29:c=Z.CharacterString;break;case 30:c=Z.BmpString;break;case 31:c=Z.DATE;break;case 32:c=Z.TimeOfDay;break;case 33:c=Z.DateTime;break;case 34:c=Z.Duration;break;default:{let f=o.idBlock.isConstructed?new Z.Constructed:new Z.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?Z.Constructed:Z.Primitive}return o=PC(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Bn(r){if(!r.byteLength){let e=new ot({},wt);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ks(be.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function NC(r,e){return r?1:e}var zr=class extends wt{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);if(!On(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;NC(this.isIndefiniteForm,n)>0;){let s=Ks(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===Tc)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Tc?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Ms;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?kr:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};zr.NAME="ConstructedValueBlock";var Tx,it=class extends ot{constructor(e={}){super(e,zr),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
3
3
|
`).map(o=>` ${o}`).join(`
|
|
4
4
|
`));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
5
5
|
${e.join(`
|
|
6
|
-
`)}`:`${t} :`}};vx=it;Y.Constructed=vx;it.NAME="CONSTRUCTED";var Kl=class extends xt{fromBER(e,t,n){return t}toBER(e){return Dr}};Kl.override="EndOfContentValueBlock";var _x,Oc=class extends ot{constructor(e={}){super(e,Kl),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};_x=Oc;Y.EndOfContent=_x;Oc.NAME=Cc;var Sx,Pr=class extends ot{constructor(e={}){super(e,xt),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Sx=Pr;Y.Null=Sx;Pr.NAME="NULL";var Hl=class extends Yr(xt){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=be.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);return Bn(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,jy.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Hl.NAME="BooleanValueBlock";var Ax,ai=class extends ot{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Hl),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ax=ai;Y.Boolean=Ax;ai.NAME="BOOLEAN";var Vl=class extends Yr(Xr){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=Xr.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Cc){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==gx)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?Xr.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Vl.NAME="OctetStringValueBlock";var Ky,Nr=class extends ot{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vl),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=Ms(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return it.prototype.onAsciiEncoding.call(this);let e=this.constructor.NAME,t=be.Convert.ToHex(this.valueBlock.valueHexView);return`${e} : ${t}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof Ky&&e.push(t.valueBlock.valueHexView);return be.BufferSourceConverter.concat(e)}};Ky=Nr;Y.OctetString=Ky;Nr.NAME=gx;var $l=class extends Yr(Xr){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=Xr.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Cc){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==bx)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ms(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return Xr.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Dr;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};$l.NAME="BitStringValueBlock";var Ex,kr=class extends ot{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},$l),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return it.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join(""),o=this.constructor.NAME,i=n.substring(0,n.length-this.valueBlock.unusedBits);return`${o} : ${i}`}}};Ex=kr;Y.BitString=Ex;kr.NAME=bx;var Cx;function EC(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,p=c<s?s:c,l=0;for(let y=p;y>=0;y--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=Rl(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Rl(t,i)),i}function mx(r){if(r>=Ac.length)for(let e=Ac.length;e<=r;e++){let t=new Uint8Array([0]),n=Ac[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=Rl(t,n)),Ac.push(n)}return Ac[r]}function CC(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,p=0;for(let l=c;l>=0;l--,p++)switch(f=i[s-p]-a[c-p]-t,!0){case f<0:t=1,i[s-p]=f+10;break;default:t=0,i[s-p]=f}if(t>0)for(let l=s-c+1;l>=0;l--,p++)if(f=i[s-p]-t,f<0)t=1,i[s-p]=f+10;else{t=0,i[s-p]=f;break}return i.slice()}var Bc=class extends Yr(xt){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=jy.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(px(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&(s[1]&128)!==0?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=CC(mx(n),t),s="-";break;default:t=EC(t,mx(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=dx.charAt(t[c]));return a===!1&&(s+=dx.charAt(0)),s}};Cx=Bc;Bc.NAME="IntegerValueBlock";Object.defineProperty(Cx.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ec,On=class extends ot{constructor(e={}){super(e,Bc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return jl(),BigInt(this.valueBlock.toString())}static fromBigInt(e){jl();let t=BigInt(e),n=new Ls,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(be.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${be.Convert.ToHex(a)}`)+t,p=be.BufferSourceConverter.toUint8Array(be.Convert.FromHex(f.toString(16)));p[0]|=128,n.write(p)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new Ec({valueHex:n.final()})}convertToDER(){let e=new Ec({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Ec({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Ec=On;Y.Integer=Ec;On.NAME="INTEGER";var Tx,ci=class extends On{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Tx=ci;Y.Enumerated=Tx;ci.NAME="ENUMERATED";var Ic=class extends Yr(xt){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,(i[a]&128)!==0);a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,(i[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=si(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){jl();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=lo(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Dr;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=be.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Ic.NAME="sidBlock";var Fl=class extends xt{constructor({value:e=qt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Ic;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,Dr;t.push(o)}return My(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Ic;if(o>Number.MAX_SAFE_INTEGER){jl();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Fl.NAME="ObjectIdentifierValueBlock";var Ox,ui=class extends ot{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Fl),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Ox=ui;Y.ObjectIdentifier=Ox;ui.NAME="OBJECT IDENTIFIER";var Pc=class extends Yr(Cn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=be.BufferSourceConverter.toUint8Array(e);if(!Bn(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,(i[a]&128)!==0);a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,(i[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=si(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=lo(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Dr;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=be.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Pc.NAME="relativeSidBlock";var Wl=class extends xt{constructor({value:e=qt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Pc;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,Dr;n.push(i)}return My(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new Pc;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Wl.NAME="RelativeObjectIdentifierValueBlock";var Bx,Nc=class extends ot{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Wl),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Bx=Nc;Y.RelativeObjectIdentifier=Bx;Nc.NAME="RelativeObjectIdentifier";var Ix,kt=class extends it{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ix=kt;Y.Sequence=Ix;kt.NAME="SEQUENCE";var Px,Ut=class extends it{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Px=Ut;Y.Set=Px;Ut.NAME="SET";var ql=class extends Yr(xt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=qt}toJSON(){return{...super.toJSON(),value:this.value}}};ql.NAME="StringValueBlock";var Gl=class extends ql{};Gl.NAME="SimpleStringValueBlock";var Mt=class extends Tc{constructor({...e}={}){super(e,Gl)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,be.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Mt.NAME="SIMPLE STRING";var zl=class extends Mt{fromBuffer(e){this.valueBlock.valueHexView=be.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=be.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=be.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(be.Convert.FromUtf8String(e)),this.valueBlock.value=e}};zl.NAME="Utf8StringValueBlock";var Nx,lr=class extends zl{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Nx=lr;Y.Utf8String=Nx;lr.NAME="UTF8String";var Xl=class extends Mt{fromBuffer(e){this.valueBlock.value=be.Convert.ToUtf16String(e),this.valueBlock.valueHexView=be.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(be.Convert.FromUtf16String(e))}};Xl.NAME="BmpStringValueBlock";var kx,fi=class extends Xl{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};kx=fi;Y.BmpString=kx;fi.NAME="BMPString";var Zl=class extends Mt{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=lo(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Zl.NAME="UniversalStringValueBlock";var Dx,li=class extends Zl{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Dx=li;Y.UniversalString=Dx;li.NAME="UniversalString";var Rx,pi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Rx=pi;Y.NumericString=Rx;pi.NAME="NumericString";var jx,hi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};jx=hi;Y.PrintableString=jx;hi.NAME="PrintableString";var Lx,di=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Lx=di;Y.TeletexString=Lx;di.NAME="TeletexString";var Ux,yi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Ux=yi;Y.VideotexString=Ux;yi.NAME="VideotexString";var Mx,mi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Mx=mi;Y.IA5String=Mx;mi.NAME="IA5String";var Kx,gi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Kx=gi;Y.GraphicString=Kx;gi.NAME="GraphicString";var Hx,po=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Hx=po;Y.VisibleString=Hx;po.NAME="VisibleString";var Vx,bi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Vx=bi;Y.GeneralString=Vx;bi.NAME="GeneralString";var $x,wi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};$x=wi;Y.CharacterString=$x;wi.NAME="CharacterString";var Fx,ho=class extends po{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,be.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Wt(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Wt(this.month,2),t[2]=Wt(this.day,2),t[3]=Wt(this.hour,2),t[4]=Wt(this.minute,2),t[5]=Wt(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Fx=ho;Y.UTCTime=Fx;ho.NAME="UTCTime";var Wx,xi=class extends ho{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,y=n.indexOf("+"),g="";if(y===-1&&(y=n.indexOf("-"),l=-1),y!==-1){if(g=n.substring(y+1),n=n.substring(0,y),g.length!==2&&g.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(g.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*m,g.length===4){if(m=parseInt(g.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=l*m}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let p=s.exec(o);if(p===null)throw new Error("Wrong input string for conversion");for(let l=1;l<p.length;l++)switch(l){case 1:this.year=parseInt(p[l],10);break;case 2:this.month=parseInt(p[l],10);break;case 3:this.day=parseInt(p[l],10);break;case 4:this.hour=parseInt(p[l],10)+a;break;case 5:this.minute=parseInt(p[l],10)+c;break;case 6:this.second=parseInt(p[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Wt(this.year,4)),t.push(Wt(this.month,2)),t.push(Wt(this.day,2)),t.push(Wt(this.hour,2)),t.push(Wt(this.minute,2)),t.push(Wt(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Wt(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Wx=xi;Y.GeneralizedTime=Wx;xi.NAME="GeneralizedTime";var qx,kc=class extends lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};qx=kc;Y.DATE=qx;kc.NAME="DATE";var Gx,Dc=class extends lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Gx=Dc;Y.TimeOfDay=Gx;Dc.NAME="TimeOfDay";var zx,Rc=class extends lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};zx=Rc;Y.DateTime=zx;Rc.NAME="DateTime";var Xx,jc=class extends lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Xx=jc;Y.Duration=Xx;jc.NAME="Duration";var Zx,Lc=class extends lr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Zx=Lc;Y.TIME=Zx;Lc.NAME="TIME";var Zr=class{constructor({name:e=qt,optional:t=!1}={}){this.name=e,this.optional=t}},Us=class extends Zr{constructor({value:e=[],...t}={}){super(t),this.value=e}},vi=class extends Zr{constructor({value:e=new Zr,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},Uy=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=be.BufferSourceConverter.toUint8Array(e)}constructor({data:e=Yl}={}){this.dataView=be.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let o=t+n;return this.dataView=be.BufferSourceConverter.toUint8Array(e).subarray(t,o),o}toBER(e){return this.dataView.slice().buffer}};function En(r,e,t){if(t instanceof Us){for(let i of t.value)if(En(r,e,i).verified)return{verified:!0,result:r};{let i={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Ly)&&(i.name=t.name),i}}if(t instanceof Zr)return t.hasOwnProperty(Ly)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(mC in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(xC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(vC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(gC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(bC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(wC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(yC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(yx in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let i=t.idBlock.valueHexView,s=e.idBlock.valueHexView;if(i.length!==s.length)return{verified:!1,result:r};for(let a=0;a<i.length;a++)if(i[a]!==s[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&(r[t.name]=e)),t instanceof Y.Constructed){let i=0,s={verified:!1,result:{error:"Unknown error"}},a=t.valueBlock.value.length;if(a>0&&t.valueBlock.value[0]instanceof vi&&(a=e.valueBlock.value.length),a===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let f=0;f<t.valueBlock.value.length;f++)c=c&&(t.valueBlock.value[f].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<a;c++)if(c-i>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){let f={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof vi){if(s=En(r,e.valueBlock.value[c],t.valueBlock.value[0].value),s.verified===!1)if(t.valueBlock.value[0].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&delete r[t.name]),s;if(Ly in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};_C in t.valueBlock.value[0]&&t.valueBlock.value[0].local?f=e:f=r,typeof f[t.valueBlock.value[0].name]>"u"&&(f[t.valueBlock.value[0].name]=[]),f[t.valueBlock.value[0].name].push(e.valueBlock.value[c])}}else if(s=En(r,e.valueBlock.value[c-i],t.valueBlock.value[c]),s.verified===!1)if(t.valueBlock.value[c].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&delete r[t.name]),s;if(s.verified===!1){let c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&yx in e.valueBlock){let i=Ms(e.valueBlock.valueHexView);if(i.offset===-1){let s={verified:!1,result:i.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,qt),t.name&&(delete r[t.name],s.name=t.name)),s}return En(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function TC(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};let t=Ms(be.BufferSourceConverter.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:En(t.result,t.result,e)}var x;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(x||(x={}));var h;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(h||(h={}));var Hy=Vr(An()),Qr=class{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(Hy.BufferSourceConverter.isBufferSource(e))this.unusedBits=t,this.value=Hy.BufferSourceConverter.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof kr))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new kr({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new kr({name:e})}toNumber(){let e="",t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let o=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let i=0;for(;i<n;)o[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=o.buffer}};var Vy=Vr(An()),ae=class{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):Vy.BufferSourceConverter.isBufferSource(e)?this.buffer=Vy.BufferSourceConverter.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Nr))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Nr({valueHex:this.buffer})}toSchema(e){return new Nr({name:e})}};var OC={fromASN:r=>r instanceof Pr?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Pr;let e=In(r);if(e.result.error)throw new Error(e.result.error);return e.result}},BC={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new On({value:+r})},IC={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new ci({value:r})},we={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new On({valueHex:r})};var PC={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new kr({valueHex:r})},NC={fromASN:r=>r.valueBlock.toString(),toASN:r=>new ui({value:r})},kC={fromASN:r=>r.valueBlock.value,toASN:r=>new ai({value:r})},Ks={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Nr({valueHex:r})},Yx={fromASN:r=>new ae(r.getValue()),toASN:r=>r.toASN()};function pr(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}var $y=pr(lr),DC=pr(fi),RC=pr(li),jC=pr(pi),LC=pr(hi),UC=pr(di),MC=pr(yi),KC=pr(mi),HC=pr(gi),VC=pr(po),$C=pr(bi),FC=pr(wi),WC={fromASN:r=>r.toDate(),toASN:r=>new ho({valueDate:r})},qC={fromASN:r=>r.toDate(),toASN:r=>new xi({valueDate:r})},GC={fromASN:()=>null,toASN:()=>new Pr};function yo(r){switch(r){case h.Any:return OC;case h.BitString:return PC;case h.BmpString:return DC;case h.Boolean:return kC;case h.CharacterString:return FC;case h.Enumerated:return IC;case h.GeneralString:return $C;case h.GeneralizedTime:return qC;case h.GraphicString:return HC;case h.IA5String:return KC;case h.Integer:return BC;case h.Null:return GC;case h.NumericString:return jC;case h.ObjectIdentifier:return NC;case h.OctetString:return Ks;case h.PrintableString:return LC;case h.TeletexString:return UC;case h.UTCTime:return WC;case h.UniversalString:return RC;case h.Utf8String:return $y;case h.VideotexString:return MC;case h.VisibleString:return VC;default:return null}}function hr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:hr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Wy(r){var e;if(r){let t=Object.getPrototypeOf(r);return((e=t?.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Wy(t)}return!1}function Jx(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}var Jl=class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){let t={type:x.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let n=this.items.get(e)||this.createDefault(e),o=[];for(let i in n.items){let s=n.items[i],a=t?i:"",c;if(typeof s.type=="number"){let p=h[s.type],l=Jr[p];if(!l)throw new Error(`Cannot get ASN1 class by name '${p}'`);c=new l({name:a})}else hr(s.type)?c=new s.type().toSchema(a):s.optional?this.get(s.type).type===x.Choice?c=new Zr({name:a}):(c=this.create(s.type,!1),c.name=a):c=new Zr({name:a});let f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){c.name="";let p=s.repeated==="set"?Ut:kt;c=new p({name:"",value:[new vi({name:a,value:c})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||hr(s.type)){let p=s.repeated?it:Tn;o.push(new p({name:a,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let p=!!s.repeated,l=p?c:this.get(s.type,!0).schema;l="valueBlock"in l?l.valueBlock.value:l.value,o.push(new it({name:p?"":a,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:l}))}else o.push(new it({optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:[c]}));else c.optional=f,o.push(c)}switch(n.type){case x.Sequence:return new kt({value:o,name:""});case x.Set:return new Ut({value:o,name:""});case x.Choice:return new Us({value:o,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}};var Je=new Jl;var E=r=>e=>{let t;Je.has(e)?t=Je.get(e):(t=Je.createDefault(e),Je.set(e,t)),Object.assign(t,r)};var u=r=>(e,t)=>{let n;Je.has(e.constructor)?n=Je.get(e.constructor):(n=Je.createDefault(e.constructor),Je.set(e.constructor,n));let o=Object.assign({},r);if(typeof o.type=="number"&&!o.converter){let i=yo(r.type);if(!i)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);o.converter=i}o.raw=r.raw,n.items[t]=o};var mo=class extends Error{constructor(){super(...arguments),this.schemas=[]}};var Uc=class{static parse(e,t){let n=In(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){try{if(hr(t))return new t().fromASN(e);let n=Je.get(t);Je.cache(t);let o=n.schema,i=this.handleChoiceTypes(e,n,t,o);if(i?.result)return i.result;i?.targetSchema&&(o=i.targetSchema);let s=this.handleSequenceTypes(e,n,t,o);if(s&&"isManualMapping"in s)return s.result;let a=s,c=new t;return Wy(t)?this.handleArrayTypes(e,n,t):(this.processSchemaItems(n,a,c),c)}catch(n){throw n instanceof mo&&n.schemas.push(t.name),n}}static handleChoiceTypes(e,t,n,o){if(e.constructor===it&&t.type===x.Choice&&e.idBlock.tagClass===3)for(let i in t.items){let s=t.items[i];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type=="function"&&Je.has(s.type)){let a=Je.get(s.type);if(a&&a.type===x.Sequence){let c=new kt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in c.valueBlock){c.valueBlock.value=e.valueBlock.value;let f=this.fromASN(c,s.type),p=new n;return p[i]=f,{result:p}}}}}else if(e.constructor===it&&t.type!==x.Choice){let i=new it({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let s in t.items)delete e[s];return{targetSchema:i}}return null}static handleSequenceTypes(e,t,n,o){if(t.type===x.Sequence){if(Object.keys(t.items).filter(a=>{let c=t.items[a];return c.optional&&typeof c.type=="function"&&Je.has(c.type)&&Je.get(c.type).type===x.Choice}).length>0&&"value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&n.name==="CertReqMsg")return this.handleManualMapping(e,t,n);let s=En({},e,o);if(!s.verified)throw new mo(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}else{let i=En({},e,o);if(!i.verified)throw new mo(`Data does not match to ${n.name} ASN1 schema.${i.result.error?` ${i.result.error}`:""}`);return i}}static handleManualMapping(e,t,n){let o=new n,i=e.valueBlock.value,s=Object.keys(t.items),a=0;for(let c=0;c<s.length;c++){let f=s[c],p=t.items[f];if(a>=i.length)break;if(p.repeated){o[f]=this.processRepeatedField(i,a,p);break}else if(typeof p.type=="number")o[f]=this.processPrimitiveField(i[a],p),a++;else if(this.isOptionalChoiceField(p)){let l=this.processOptionalChoiceField(i[a],p);l.processed&&(o[f]=l.value,a++)}else o[f]=this.fromASN(i[a],p.type),a++}return{result:o,verified:!0,isManualMapping:!0}}static processRepeatedField(e,t,n){let o=e.slice(t);if(o.length===1&&o[0].constructor.name==="Sequence"){let i=o[0];i.valueBlock&&i.valueBlock.value&&Array.isArray(i.valueBlock.value)&&(o=i.valueBlock.value)}if(typeof n.type=="number"){let i=yo(n.type);if(!i)throw new Error(`No converter for ASN.1 type ${n.type}`);return o.filter(s=>s&&s.valueBlock).map(s=>{try{return i.fromASN(s)}catch{return}}).filter(s=>s!==void 0)}else return o.filter(i=>i&&i.valueBlock).map(i=>{try{return this.fromASN(i,n.type)}catch{return}}).filter(i=>i!==void 0)}static processPrimitiveField(e,t){let n=yo(t.type);if(!n)throw new Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Je.has(e.type)&&Je.get(e.type).type===x.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(n){if(n instanceof mo&&/Wrong values for Choice type/.test(n.message))return{processed:!1};throw n}}static handleArrayTypes(e,t,n){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let o=t.itemType;if(typeof o=="number"){let i=yo(o);if(!i)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,s=>i.fromASN(s))}else return n.from(e.valueBlock.value,i=>this.fromASN(i,o))}static processSchemaItems(e,t,n){for(let o in e.items){let i=t.result[o];if(!i)continue;let s=e.items[o],a=s.type,c;typeof a=="number"||hr(a)?c=this.processPrimitiveSchemaItem(i,s,a):c=this.processComplexSchemaItem(i,s,a),c&&typeof c=="object"&&"value"in c&&"raw"in c?(n[o]=c.value,n[`${o}Raw`]=c.raw):n[o]=c}}static processPrimitiveSchemaItem(e,t,n){var o;let i=(o=t.converter)!==null&&o!==void 0?o:hr(n)?new n:null;if(!i)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,i):this.processSinglePrimitiveItem(e,t,n,i)}static processRepeatedPrimitiveItem(e,t,n){if(t.implicit){let o=t.repeated==="sequence"?kt:Ut,i=new o;i.valueBlock=e.valueBlock;let s=In(i.toBER(!1));if(s.offset===-1)throw new Error(`Cannot parse the child item. ${s.result.error}`);if(!("value"in s.result.valueBlock&&Array.isArray(s.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let a=s.result.valueBlock.value;return Array.from(a,c=>n.fromASN(c))}else return Array.from(e,o=>n.fromASN(o))}static processSinglePrimitiveItem(e,t,n,o){let i=e;if(t.implicit){let s;if(hr(n))s=new n().toSchema("");else{let a=h[n],c=Jr[a];if(!c)throw new Error(`Cannot get '${a}' class from asn1js module`);s=new c}s.valueBlock=i.valueBlock,i=In(s.toBER(!1)).result}return o.fromASN(i)}static processComplexSchemaItem(e,t,n){if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,o=>this.fromASN(o,n))}else{let o=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(o,n)}catch(i){if(i instanceof mo&&/Wrong values for Choice type/.test(i.message))return;throw i}else{let i=this.fromASN(o,n);return t.raw?{value:i,raw:e.valueBeforeDecodeView}:i}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context=="number"){let o=Je.get(n);if(o.type===x.Sequence){let i=new kt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in i.valueBlock)return i.valueBlock.value=e.valueBlock.value,i}else if(o.type===x.Set){let i=new Ut;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in i.valueBlock)return i.valueBlock.value=e.valueBlock.value,i}}return e}};var Mc=class r{static serialize(e){return e instanceof ot?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&hr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let t=e.constructor,n=Je.get(t);Je.cache(t);let o=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){let s=yo(n.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);o=e.map(a=>s.toASN(a))}else o=e.map(s=>this.toAsnItem({type:n.itemType},"[]",t,s))}else for(let s in n.items){let a=n.items[s],c=e[s];if(c===void 0||a.defaultValue===c||typeof a.defaultValue=="object"&&typeof c=="object"&&Jx(this.serialize(a.defaultValue),this.serialize(c)))continue;let f=r.toAsnItem(a,s,t,c);if(typeof a.context=="number")if(a.implicit)if(!a.repeated&&(typeof a.type=="number"||hr(a.type))){let p={};p.valueHex=f instanceof Pr?f.valueBeforeDecodeView:f.valueBlock.toBER(),o.push(new Tn({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...p}))}else o.push(new it({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:f.valueBlock.value}));else o.push(new it({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[f]}));else a.repeated?o=o.concat(f):o.push(f)}let i;switch(n.type){case x.Sequence:i=new kt({value:o});break;case x.Set:i=new Ut({value:o});break;case x.Choice:if(!o[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=o[0];break}return i}static toAsnItem(e,t,n,o){let i;if(typeof e.type=="number"){let s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${h[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(o,f=>s.toASN(f)),c=e.repeated==="sequence"?kt:Ut;i=new c({value:a})}else i=s.toASN(o)}else if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");let s=Array.from(o,c=>this.toASN(c)),a=e.repeated==="sequence"?kt:Ut;i=new a({value:s})}else i=this.toASN(o);return i}};var se=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(let t of e)this.push(t)}}};var qy=Vr(An());var W=class r{static serialize(e){return Mc.serialize(e)}static parse(e,t){return Uc.parse(e,t)}static toString(e){let t=qy.BufferSourceConverter.isBufferSource(e)?qy.BufferSourceConverter.toArrayBuffer(e):r.serialize(e),n=In(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function b(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Qx=Vr(An()),Kc=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(".");if(t.length!==4)throw new Error("Invalid IPv4 address");return t.map(n=>{let o=parseInt(n,10);if(isNaN(o)||o<0||o>255)throw new Error("Invalid IPv4 address part");return o})}static parseIPv6(e){let n=this.expandIPv6(e).split(":");if(n.length!==8)throw new Error("Invalid IPv6 address");return n.reduce((o,i)=>{let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return o.push(s>>8&255),o.push(s&255),o},[])}static expandIPv6(e){if(!e.includes("::"))return e;let t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");let n=t[0]?t[0].split(":"):[],o=t[1]?t[1].split(":"):[],i=8-(n.length+o.length);if(i<0)throw new Error("Invalid IPv6 address");return[...n,...Array(i).fill("0"),...o].join(":")}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){let t=e.split(":"),n=-1,o=0,i=-1,s=0;for(let a=0;a<t.length;a++)t[a]==="0"?(i===-1&&(i=a),s++):(s>o&&(n=i,o=s),i=-1,s=0);if(s>o&&(n=i,o=s),o>1){let a=t.slice(0,n).join(":"),c=t.slice(n+o).join(":");return`${a}::${c}`}return e}static parseCIDR(e){let[t,n]=e.split("/"),o=parseInt(n,10);if(this.isIPv4(t)){if(o<0||o>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),o]}else{if(o<0||o>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),o]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split("").reduce((o,i)=>o+ +i,0),n=e.slice(0,8).replace(/(.{2})/g,o=>`${parseInt(o,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(".");if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){let n=t.length/2,o=t.slice(0,n),i=t.slice(n);if(t.every(c=>c===0))return t.length===8?"0.0.0.0/0":"::/0";let a=i.reduce((c,f)=>c+(f.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(o).join(".")}/${a}`:`${this.formatIPv6(o)}/${a}`}return this.decodeIP(Qx.Convert.ToHex(e))}static fromString(e){if(e.includes("/")){let[n,o]=this.parseCIDR(e),i=new Uint8Array(n.length),s=o;for(let c=0;c<i.length;c++)s>=8?(i[c]=255,s-=8):s>0&&(i[c]=255<<8-s,s=0);let a=new Uint8Array(n.length*2);return a.set(n,0),a.set(i,n.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}};var ev=Vr(An()),Gy,zy,Xy,st=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};b([u({type:h.TeletexString})],st.prototype,"teletexString",void 0);b([u({type:h.PrintableString})],st.prototype,"printableString",void 0);b([u({type:h.UniversalString})],st.prototype,"universalString",void 0);b([u({type:h.Utf8String})],st.prototype,"utf8String",void 0);b([u({type:h.BmpString})],st.prototype,"bmpString",void 0);st=b([E({type:x.Choice})],st);var Hs=class extends st{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ev.Convert.ToHex(this.anyValue):super.toString())}};b([u({type:h.IA5String})],Hs.prototype,"ia5String",void 0);b([u({type:h.Any})],Hs.prototype,"anyValue",void 0);Hs=b([E({type:x.Choice})],Hs);var _i=class{constructor(e={}){this.type="",this.value=new Hs,Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],_i.prototype,"type",void 0);b([u({type:Hs})],_i.prototype,"value",void 0);var go=Gy=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Gy.prototype)}};go=Gy=b([E({type:x.Set,itemType:_i})],go);var Zy=zy=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,zy.prototype)}};Zy=zy=b([E({type:x.Sequence,itemType:go})],Zy);var je=Xy=class extends Zy{constructor(e){super(e),Object.setPrototypeOf(this,Xy.prototype)}};je=Xy=b([E({type:x.Sequence})],je);var zC={fromASN:r=>Kc.toString(Ks.fromASN(r)),toASN:r=>Ks.toASN(Kc.fromString(r))},bo=class{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],bo.prototype,"typeId",void 0);b([u({type:h.Any,context:0})],bo.prototype,"value",void 0);var Hc=class{constructor(e={}){this.partyName=new st,Object.assign(this,e)}};b([u({type:st,optional:!0,context:0,implicit:!0})],Hc.prototype,"nameAssigner",void 0);b([u({type:st,context:1,implicit:!0})],Hc.prototype,"partyName",void 0);var ue=class{constructor(e={}){Object.assign(this,e)}};b([u({type:bo,context:0,implicit:!0})],ue.prototype,"otherName",void 0);b([u({type:h.IA5String,context:1,implicit:!0})],ue.prototype,"rfc822Name",void 0);b([u({type:h.IA5String,context:2,implicit:!0})],ue.prototype,"dNSName",void 0);b([u({type:h.Any,context:3,implicit:!0})],ue.prototype,"x400Address",void 0);b([u({type:je,context:4,implicit:!1})],ue.prototype,"directoryName",void 0);b([u({type:Hc,context:5})],ue.prototype,"ediPartyName",void 0);b([u({type:h.IA5String,context:6,implicit:!0})],ue.prototype,"uniformResourceIdentifier",void 0);b([u({type:h.OctetString,context:7,implicit:!0,converter:zC})],ue.prototype,"iPAddress",void 0);b([u({type:h.ObjectIdentifier,context:8,implicit:!0})],ue.prototype,"registeredID",void 0);ue=b([E({type:x.Choice})],ue);var wo="1.3.6.1.5.5.7",xo=`${wo}.1`,tv=`${wo}.2`,Si=`${wo}.3`,Ql=`${wo}.48`,RD=`${tv}.1`,jD=`${tv}.2`,Yy=`${Ql}.1`,Jy=`${Ql}.2`,Qy=`${Ql}.3`,em=`${Ql}.5`,pe="2.5.29";var tm,ep=`${xo}.1`,Pn=class{constructor(e={}){this.accessMethod="",this.accessLocation=new ue,Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Pn.prototype,"accessMethod",void 0);b([u({type:ue})],Pn.prototype,"accessLocation",void 0);var Ai=tm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,tm.prototype)}};Ai=tm=b([E({type:x.Sequence,itemType:Pn})],Ai);var tp=`${pe}.35`,Ei=class extends ae{},en=class{constructor(e={}){e&&Object.assign(this,e)}};b([u({type:Ei,context:0,optional:!0,implicit:!0})],en.prototype,"keyIdentifier",void 0);b([u({type:ue,context:1,optional:!0,implicit:!0,repeated:"sequence"})],en.prototype,"authorityCertIssuer",void 0);b([u({type:h.Integer,context:2,optional:!0,implicit:!0,converter:we})],en.prototype,"authorityCertSerialNumber",void 0);var rp=`${pe}.19`,Ci=class{constructor(e={}){this.cA=!1,Object.assign(this,e)}};b([u({type:h.Boolean,defaultValue:!1})],Ci.prototype,"cA",void 0);b([u({type:h.Integer,optional:!0})],Ci.prototype,"pathLenConstraint",void 0);var rm,Fe=rm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,rm.prototype)}};Fe=rm=b([E({type:x.Sequence,itemType:ue})],Fe);var nm,XC=`${pe}.29`,rv=nm=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,nm.prototype)}};rv=nm=b([E({type:x.Sequence})],rv);var om,op=`${pe}.32`,d3=`${op}.0`,Nn=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};b([u({type:h.IA5String})],Nn.prototype,"ia5String",void 0);b([u({type:h.VisibleString})],Nn.prototype,"visibleString",void 0);b([u({type:h.BmpString})],Nn.prototype,"bmpString",void 0);b([u({type:h.Utf8String})],Nn.prototype,"utf8String",void 0);Nn=b([E({type:x.Choice})],Nn);var Vc=class{constructor(e={}){this.organization=new Nn,this.noticeNumbers=[],Object.assign(this,e)}};b([u({type:Nn})],Vc.prototype,"organization",void 0);b([u({type:h.Integer,repeated:"sequence"})],Vc.prototype,"noticeNumbers",void 0);var $c=class{constructor(e={}){Object.assign(this,e)}};b([u({type:Vc,optional:!0})],$c.prototype,"noticeRef",void 0);b([u({type:Nn,optional:!0})],$c.prototype,"explicitText",void 0);var np=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.IA5String})],np.prototype,"cPSuri",void 0);b([u({type:$c})],np.prototype,"userNotice",void 0);np=b([E({type:x.Choice})],np);var Fc=class{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Fc.prototype,"policyQualifierId",void 0);b([u({type:h.Any})],Fc.prototype,"qualifier",void 0);var Ti=class{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Ti.prototype,"policyIdentifier",void 0);b([u({type:Fc,repeated:"sequence",optional:!0})],Ti.prototype,"policyQualifiers",void 0);var Wc=om=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,om.prototype)}};Wc=om=b([E({type:x.Sequence,itemType:Ti})],Wc);var _3=`${pe}.20`,qc=class{constructor(e=0){this.value=e}};b([u({type:h.Integer})],qc.prototype,"value",void 0);qc=b([E({type:x.Choice})],qc);var B3=`${pe}.27`,nv=class extends qc{};nv=b([E({type:x.Choice})],nv);var im,ip=`${pe}.31`,Rr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Rr||(Rr={}));var Gc=class extends Qr{toJSON(){let e=[],t=this.toNumber();return t&Rr.aACompromise&&e.push("aACompromise"),t&Rr.affiliationChanged&&e.push("affiliationChanged"),t&Rr.cACompromise&&e.push("cACompromise"),t&Rr.certificateHold&&e.push("certificateHold"),t&Rr.cessationOfOperation&&e.push("cessationOfOperation"),t&Rr.keyCompromise&&e.push("keyCompromise"),t&Rr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Rr.superseded&&e.push("superseded"),t&Rr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}},kn=class{constructor(e={}){Object.assign(this,e)}};b([u({type:ue,context:0,repeated:"sequence",implicit:!0})],kn.prototype,"fullName",void 0);b([u({type:go,context:1,implicit:!0})],kn.prototype,"nameRelativeToCRLIssuer",void 0);kn=b([E({type:x.Choice})],kn);var tn=class{constructor(e={}){Object.assign(this,e)}};b([u({type:kn,context:0,optional:!0})],tn.prototype,"distributionPoint",void 0);b([u({type:Gc,context:1,optional:!0,implicit:!0})],tn.prototype,"reasons",void 0);b([u({type:ue,context:2,optional:!0,repeated:"sequence",implicit:!0})],tn.prototype,"cRLIssuer",void 0);var vo=im=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,im.prototype)}};vo=im=b([E({type:x.Sequence,itemType:tn})],vo);var sm,F3=`${pe}.46`,ov=sm=class extends vo{constructor(e){super(e),Object.setPrototypeOf(this,sm.prototype)}};ov=sm=b([E({type:x.Sequence,itemType:tn})],ov);var J3=`${pe}.28`,rr=class r{constructor(e={}){this.onlyContainsUserCerts=r.ONLY,this.onlyContainsCACerts=r.ONLY,this.indirectCRL=r.ONLY,this.onlyContainsAttributeCerts=r.ONLY,Object.assign(this,e)}};rr.ONLY=!1;b([u({type:kn,context:0,optional:!0})],rr.prototype,"distributionPoint",void 0);b([u({type:h.Boolean,context:1,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsUserCerts",void 0);b([u({type:h.Boolean,context:2,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsCACerts",void 0);b([u({type:Gc,context:3,optional:!0,implicit:!0})],rr.prototype,"onlySomeReasons",void 0);b([u({type:h.Boolean,context:4,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"indirectCRL",void 0);b([u({type:h.Boolean,context:5,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsAttributeCerts",void 0);var iv=`${pe}.21`,zc;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(zc||(zc={}));var Xc=class{constructor(e=zc.unspecified){this.reason=zc.unspecified,this.reason=e}toJSON(){return zc[this.reason]}toString(){return this.toJSON()}};b([u({type:h.Enumerated})],Xc.prototype,"reason",void 0);Xc=b([E({type:x.Choice})],Xc);var am,sp=`${pe}.37`,Zc=am=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,am.prototype)}};Zc=am=b([E({type:x.Sequence,itemType:h.ObjectIdentifier})],Zc);var uR=`${sp}.0`,sv=`${Si}.1`,av=`${Si}.2`,cv=`${Si}.3`,uv=`${Si}.4`,fv=`${Si}.8`,lv=`${Si}.9`;var dR=`${pe}.54`,cm=class{constructor(e=new ArrayBuffer(0)){this.value=e}};b([u({type:h.Integer,converter:we})],cm.prototype,"value",void 0);cm=b([E({type:x.Choice})],cm);var pv=`${pe}.24`,Yc=class{constructor(e){this.value=new Date,e&&(this.value=e)}};b([u({type:h.GeneralizedTime})],Yc.prototype,"value",void 0);Yc=b([E({type:x.Choice})],Yc);var um,fm=`${pe}.18`,hv=um=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,um.prototype)}};hv=um=b([E({type:x.Sequence})],hv);var ap=`${pe}.15`,jr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(jr||(jr={}));var Vs=class extends Qr{toJSON(){let e=this.toNumber(),t=[];return e&jr.cRLSign&&t.push("crlSign"),e&jr.dataEncipherment&&t.push("dataEncipherment"),e&jr.decipherOnly&&t.push("decipherOnly"),e&jr.digitalSignature&&t.push("digitalSignature"),e&jr.encipherOnly&&t.push("encipherOnly"),e&jr.keyAgreement&&t.push("keyAgreement"),e&jr.keyCertSign&&t.push("keyCertSign"),e&jr.keyEncipherment&&t.push("keyEncipherment"),e&jr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}};var lm,RR=`${pe}.30`,$s=class{constructor(e={}){this.base=new ue,this.minimum=0,Object.assign(this,e)}};b([u({type:ue})],$s.prototype,"base",void 0);b([u({type:h.Integer,context:0,defaultValue:0,implicit:!0})],$s.prototype,"minimum",void 0);b([u({type:h.Integer,context:1,optional:!0,implicit:!0})],$s.prototype,"maximum",void 0);var cp=lm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,lm.prototype)}};cp=lm=b([E({type:x.Sequence,itemType:$s})],cp);var up=class{constructor(e={}){Object.assign(this,e)}};b([u({type:cp,context:0,optional:!0,implicit:!0})],up.prototype,"permittedSubtrees",void 0);b([u({type:cp,context:1,optional:!0,implicit:!0})],up.prototype,"excludedSubtrees",void 0);var HR=`${pe}.36`,fp=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.Integer,context:0,implicit:!0,optional:!0,converter:we})],fp.prototype,"requireExplicitPolicy",void 0);b([u({type:h.Integer,context:1,implicit:!0,optional:!0,converter:we})],fp.prototype,"inhibitPolicyMapping",void 0);var pm,qR=`${pe}.33`,Jc=class{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Jc.prototype,"issuerDomainPolicy",void 0);b([u({type:h.ObjectIdentifier})],Jc.prototype,"subjectDomainPolicy",void 0);var dv=pm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,pm.prototype)}};dv=pm=b([E({type:x.Sequence,itemType:Jc})],dv);var hm,dm=`${pe}.17`,lp=hm=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,hm.prototype)}};lp=hm=b([E({type:x.Sequence})],lp);var vt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],vt.prototype,"type",void 0);b([u({type:h.Any,repeated:"set"})],vt.prototype,"values",void 0);var ym,cj=`${pe}.9`,yv=ym=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,ym.prototype)}};yv=ym=b([E({type:x.Sequence,itemType:vt})],yv);var mm=`${pe}.14`,Gt=class extends Ei{};var gj=`${pe}.16`,pp=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.GeneralizedTime,context:0,implicit:!0,optional:!0})],pp.prototype,"notBefore",void 0);b([u({type:h.GeneralizedTime,context:1,implicit:!0,optional:!0})],pp.prototype,"notAfter",void 0);var Qc;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Qc||(Qc={}));var hp=class extends Qr{toJSON(){let e=[],t=this.toNumber();return t&Qc.pKIXCertificate&&e.push("pKIXCertificate"),t&Qc.newExtensions&&e.push("newExtensions"),t&Qc.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}},dp=class{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new hp,Object.assign(this,e)}};b([u({type:h.GeneralString})],dp.prototype,"entrustVers",void 0);b([u({type:hp})],dp.prototype,"entrustInfoFlags",void 0);var gm,Cj=`${xo}.11`,mv=gm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,gm.prototype)}};mv=gm=b([E({type:x.Sequence,itemType:Pn})],mv);var gv=Vr(An()),K=class r{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof r&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&gv.isEqual(e.parameters,this.parameters)||e.parameters===this.parameters)}};b([u({type:h.ObjectIdentifier})],K.prototype,"algorithm",void 0);b([u({type:h.Any,optional:!0})],K.prototype,"parameters",void 0);var _t=class{constructor(e={}){this.algorithm=new K,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:K})],_t.prototype,"algorithm",void 0);b([u({type:h.BitString})],_t.prototype,"subjectPublicKey",void 0);var Qe=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){let t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};b([u({type:h.UTCTime})],Qe.prototype,"utcTime",void 0);b([u({type:h.GeneralizedTime})],Qe.prototype,"generalTime",void 0);Qe=b([E({type:x.Choice})],Qe);var Dn=class{constructor(e){this.notBefore=new Qe(new Date),this.notAfter=new Qe(new Date),e&&(this.notBefore=new Qe(e.notBefore),this.notAfter=new Qe(e.notAfter))}};b([u({type:Qe})],Dn.prototype,"notBefore",void 0);b([u({type:Qe})],Dn.prototype,"notAfter",void 0);var bm,St=class r{constructor(e={}){this.extnID="",this.critical=r.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};St.CRITICAL=!1;b([u({type:h.ObjectIdentifier})],St.prototype,"extnID",void 0);b([u({type:h.Boolean,defaultValue:St.CRITICAL})],St.prototype,"critical",void 0);b([u({type:ae})],St.prototype,"extnValue",void 0);var nr=bm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,bm.prototype)}};nr=bm=b([E({type:x.Sequence,itemType:St})],nr);var rn;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(rn||(rn={}));var At=class{constructor(e={}){this.version=rn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new K,this.issuer=new je,this.validity=new Dn,this.subject=new je,this.subjectPublicKeyInfo=new _t,Object.assign(this,e)}};b([u({type:h.Integer,context:0,defaultValue:rn.v1})],At.prototype,"version",void 0);b([u({type:h.Integer,converter:we})],At.prototype,"serialNumber",void 0);b([u({type:K})],At.prototype,"signature",void 0);b([u({type:je})],At.prototype,"issuer",void 0);b([u({type:Dn})],At.prototype,"validity",void 0);b([u({type:je})],At.prototype,"subject",void 0);b([u({type:_t})],At.prototype,"subjectPublicKeyInfo",void 0);b([u({type:h.BitString,context:1,implicit:!0,optional:!0})],At.prototype,"issuerUniqueID",void 0);b([u({type:h.BitString,context:2,implicit:!0,optional:!0})],At.prototype,"subjectUniqueID",void 0);b([u({type:nr,context:3,optional:!0})],At.prototype,"extensions",void 0);var dr=class{constructor(e={}){this.tbsCertificate=new At,this.signatureAlgorithm=new K,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:At,raw:!0})],dr.prototype,"tbsCertificate",void 0);b([u({type:K})],dr.prototype,"signatureAlgorithm",void 0);b([u({type:h.BitString})],dr.prototype,"signatureValue",void 0);var Oi=class{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Qe,Object.assign(this,e)}};b([u({type:h.Integer,converter:we})],Oi.prototype,"userCertificate",void 0);b([u({type:Qe})],Oi.prototype,"revocationDate",void 0);b([u({type:St,optional:!0,repeated:"sequence"})],Oi.prototype,"crlEntryExtensions",void 0);var or=class{constructor(e={}){this.signature=new K,this.issuer=new je,this.thisUpdate=new Qe,Object.assign(this,e)}};b([u({type:h.Integer,optional:!0})],or.prototype,"version",void 0);b([u({type:K})],or.prototype,"signature",void 0);b([u({type:je})],or.prototype,"issuer",void 0);b([u({type:Qe})],or.prototype,"thisUpdate",void 0);b([u({type:Qe,optional:!0})],or.prototype,"nextUpdate",void 0);b([u({type:Oi,repeated:"sequence",optional:!0})],or.prototype,"revokedCertificates",void 0);b([u({type:St,optional:!0,context:0,repeated:"sequence"})],or.prototype,"crlExtensions",void 0);var Bi=class{constructor(e={}){this.tbsCertList=new or,this.signatureAlgorithm=new K,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:or,raw:!0})],Bi.prototype,"tbsCertList",void 0);b([u({type:K})],Bi.prototype,"signatureAlgorithm",void 0);b([u({type:h.BitString})],Bi.prototype,"signature",void 0);var V=Vr(An());function eu(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}function de(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function We(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}function T(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Lr=class{constructor(e={}){this.issuer=new je,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:je})],Lr.prototype,"issuer",void 0);T([u({type:h.Integer,converter:we})],Lr.prototype,"serialNumber",void 0);var Ii=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Gt,context:0,implicit:!0})],Ii.prototype,"subjectKeyIdentifier",void 0);T([u({type:Lr})],Ii.prototype,"issuerAndSerialNumber",void 0);Ii=T([E({type:x.Choice})],Ii);var Et;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(Et||(Et={}));var Pi=class extends K{};Pi=T([E({type:x.Sequence})],Pi);var tu=class extends K{};tu=T([E({type:x.Sequence})],tu);var zt=class extends K{};zt=T([E({type:x.Sequence})],zt);var ru=class extends K{};ru=T([E({type:x.Sequence})],ru);var wv=class extends K{};wv=T([E({type:x.Sequence})],wv);var yp=class extends K{};yp=T([E({type:x.Sequence})],yp);var Ur=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Ur.prototype,"attrType",void 0);T([u({type:h.Any,repeated:"set"})],Ur.prototype,"attrValues",void 0);var wm,Xt=class{constructor(e={}){this.version=Et.v0,this.sid=new Ii,this.digestAlgorithm=new Pi,this.signatureAlgorithm=new tu,this.signature=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],Xt.prototype,"version",void 0);T([u({type:Ii})],Xt.prototype,"sid",void 0);T([u({type:Pi})],Xt.prototype,"digestAlgorithm",void 0);T([u({type:Ur,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Xt.prototype,"signedAttrs",void 0);T([u({type:tu})],Xt.prototype,"signatureAlgorithm",void 0);T([u({type:ae})],Xt.prototype,"signature",void 0);T([u({type:Ur,repeated:"set",context:1,implicit:!0,optional:!0})],Xt.prototype,"unsignedAttrs",void 0);var nu=wm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,wm.prototype)}};nu=wm=T([E({type:x.Set,itemType:Xt})],nu);var xv=class extends Qe{};xv=T([E({type:x.Choice})],xv);var vv=class extends Xt{};vv=T([E({type:x.Sequence})],vv);function G(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var ou=class{constructor(e={}){this.acIssuer=new ue,this.acSerial=0,this.attrs=[],Object.assign(this,e)}};G([u({type:ue})],ou.prototype,"acIssuer",void 0);G([u({type:h.Integer})],ou.prototype,"acSerial",void 0);G([u({type:vt,repeated:"sequence"})],ou.prototype,"attrs",void 0);var xm,iu=xm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,xm.prototype)}};iu=xm=G([E({type:x.Sequence,itemType:h.ObjectIdentifier})],iu);var Fs=class{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}};G([u({type:h.Integer,optional:!0})],Fs.prototype,"pathLenConstraint",void 0);G([u({type:iu,implicit:!0,context:0,optional:!0})],Fs.prototype,"permittedAttrs",void 0);G([u({type:iu,implicit:!0,context:1,optional:!0})],Fs.prototype,"excludedAttrs",void 0);G([u({type:h.Boolean,defaultValue:!0})],Fs.prototype,"permitUnSpecified",void 0);var yr=class{constructor(e={}){this.issuer=new Fe,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:Fe})],yr.prototype,"issuer",void 0);G([u({type:h.Integer,converter:we})],yr.prototype,"serial",void 0);G([u({type:h.BitString,optional:!0})],yr.prototype,"issuerUID",void 0);var vm;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(vm||(vm={}));var mr=class{constructor(e={}){this.digestedObjectType=vm.publicKey,this.digestAlgorithm=new K,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:h.Enumerated})],mr.prototype,"digestedObjectType",void 0);G([u({type:h.ObjectIdentifier,optional:!0})],mr.prototype,"otherObjectTypeID",void 0);G([u({type:K})],mr.prototype,"digestAlgorithm",void 0);G([u({type:h.BitString})],mr.prototype,"objectDigest",void 0);var Ni=class{constructor(e={}){Object.assign(this,e)}};G([u({type:Fe,optional:!0})],Ni.prototype,"issuerName",void 0);G([u({type:yr,context:0,implicit:!0,optional:!0})],Ni.prototype,"baseCertificateID",void 0);G([u({type:mr,context:1,implicit:!0,optional:!0})],Ni.prototype,"objectDigestInfo",void 0);var ki=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ue,repeated:"sequence"})],ki.prototype,"v1Form",void 0);G([u({type:Ni,context:0,implicit:!0})],ki.prototype,"v2Form",void 0);ki=G([E({type:x.Choice})],ki);var Di=class{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}};G([u({type:h.GeneralizedTime})],Di.prototype,"notBeforeTime",void 0);G([u({type:h.GeneralizedTime})],Di.prototype,"notAfterTime",void 0);var _o=class{constructor(e={}){Object.assign(this,e)}};G([u({type:yr,implicit:!0,context:0,optional:!0})],_o.prototype,"baseCertificateID",void 0);G([u({type:Fe,implicit:!0,context:1,optional:!0})],_o.prototype,"entityName",void 0);G([u({type:mr,implicit:!0,context:2,optional:!0})],_o.prototype,"objectDigestInfo",void 0);var _m;(function(r){r[r.v2=1]="v2"})(_m||(_m={}));var Zt=class{constructor(e={}){this.version=_m.v2,this.holder=new _o,this.issuer=new ki,this.signature=new K,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Di,this.attributes=[],Object.assign(this,e)}};G([u({type:h.Integer})],Zt.prototype,"version",void 0);G([u({type:_o})],Zt.prototype,"holder",void 0);G([u({type:ki})],Zt.prototype,"issuer",void 0);G([u({type:K})],Zt.prototype,"signature",void 0);G([u({type:h.Integer,converter:we})],Zt.prototype,"serialNumber",void 0);G([u({type:Di})],Zt.prototype,"attrCertValidityPeriod",void 0);G([u({type:vt,repeated:"sequence"})],Zt.prototype,"attributes",void 0);G([u({type:h.BitString,optional:!0})],Zt.prototype,"issuerUniqueID",void 0);G([u({type:nr,optional:!0})],Zt.prototype,"extensions",void 0);var Ri=class{constructor(e={}){this.acinfo=new Zt,this.signatureAlgorithm=new K,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:Zt})],Ri.prototype,"acinfo",void 0);G([u({type:K})],Ri.prototype,"signatureAlgorithm",void 0);G([u({type:h.BitString})],Ri.prototype,"signatureValue",void 0);var su;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(su||(su={}));var Ws=class extends Qr{};var qs=class{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:h.ObjectIdentifier,implicit:!0,context:0})],qs.prototype,"type",void 0);G([u({type:h.Any,implicit:!0,context:1})],qs.prototype,"value",void 0);var au=class{constructor(e={}){this.policyId="",this.classList=new Ws(su.unclassified),Object.assign(this,e)}};G([u({type:h.ObjectIdentifier})],au.prototype,"policyId",void 0);G([u({type:Ws,defaultValue:new Ws(su.unclassified)})],au.prototype,"classList",void 0);G([u({type:qs,repeated:"set"})],au.prototype,"securityCategories",void 0);var Gs=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ae})],Gs.prototype,"cotets",void 0);G([u({type:h.ObjectIdentifier})],Gs.prototype,"oid",void 0);G([u({type:h.Utf8String})],Gs.prototype,"string",void 0);var mp=class{constructor(e={}){this.values=[],Object.assign(this,e)}};G([u({type:Fe,implicit:!0,context:0,optional:!0})],mp.prototype,"policyAuthority",void 0);G([u({type:Gs,repeated:"sequence"})],mp.prototype,"values",void 0);var u9=`${xo}.4`,f9=`${xo}.6`,l9=`${xo}.10`,p9=`${pe}.55`,cu=`${wo}.10`,h9=`${cu}.1`,d9=`${cu}.2`,y9=`${cu}.3`,m9=`${cu}.4`,g9=`${cu}.6`,Sm="2.5.4",b9=`${Sm}.72`;var Am,zs=class{constructor(e={}){this.targetCertificate=new yr,Object.assign(this,e)}};G([u({type:yr})],zs.prototype,"targetCertificate",void 0);G([u({type:ue,optional:!0})],zs.prototype,"targetName",void 0);G([u({type:mr,optional:!0})],zs.prototype,"certDigestInfo",void 0);var Xs=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ue,context:0,implicit:!0})],Xs.prototype,"targetName",void 0);G([u({type:ue,context:1,implicit:!0})],Xs.prototype,"targetGroup",void 0);G([u({type:zs,context:2,implicit:!0})],Xs.prototype,"targetCert",void 0);Xs=G([E({type:x.Choice})],Xs);var gp=Am=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Am.prototype)}};gp=Am=G([E({type:x.Sequence,itemType:Xs})],gp);var Em,_v=Em=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Em.prototype)}};_v=Em=G([E({type:x.Sequence,itemType:gp})],_v);var bp=class{constructor(e={}){Object.assign(this,e)}};G([u({type:Fe,implicit:!0,context:0,optional:!0})],bp.prototype,"roleAuthority",void 0);G([u({type:ue,implicit:!0,context:1})],bp.prototype,"roleName",void 0);var uu=class{constructor(e={}){this.service=new ue,this.ident=new ue,Object.assign(this,e)}};G([u({type:ue})],uu.prototype,"service",void 0);G([u({type:ue})],uu.prototype,"ident",void 0);G([u({type:ae,optional:!0})],uu.prototype,"authInfo",void 0);var Cm,fu=class{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],fu.prototype,"otherCertFormat",void 0);T([u({type:h.Any})],fu.prototype,"otherCert",void 0);var ji=class{constructor(e={}){Object.assign(this,e)}};T([u({type:dr})],ji.prototype,"certificate",void 0);T([u({type:Ri,context:2,implicit:!0})],ji.prototype,"v2AttrCert",void 0);T([u({type:fu,context:3,implicit:!0})],ji.prototype,"other",void 0);ji=T([E({type:x.Choice})],ji);var Li=Cm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Cm.prototype)}};Li=Cm=T([E({type:x.Set,itemType:ji})],Li);var gr=class{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],gr.prototype,"contentType",void 0);T([u({type:h.Any,context:0})],gr.prototype,"content",void 0);var Zs=class{constructor(e={}){Object.assign(this,e)}};T([u({type:ae})],Zs.prototype,"single",void 0);T([u({type:h.Any})],Zs.prototype,"any",void 0);Zs=T([E({type:x.Choice})],Zs);var Ui=class{constructor(e={}){this.eContentType="",Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Ui.prototype,"eContentType",void 0);T([u({type:Zs,context:0,optional:!0})],Ui.prototype,"eContent",void 0);var lu=class{constructor(e={}){Object.assign(this,e)}};T([u({type:ae,context:0,implicit:!0,optional:!0})],lu.prototype,"value",void 0);T([u({type:ae,converter:Yx,context:0,implicit:!0,optional:!0,repeated:"sequence"})],lu.prototype,"constructedValue",void 0);lu=T([E({type:x.Choice})],lu);var So=class{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new ru,Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],So.prototype,"contentType",void 0);T([u({type:ru})],So.prototype,"contentEncryptionAlgorithm",void 0);T([u({type:lu,optional:!0})],So.prototype,"encryptedContent",void 0);var Ao=class{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Ao.prototype,"keyAttrId",void 0);T([u({type:h.Any,optional:!0})],Ao.prototype,"keyAttr",void 0);var Tm,Ys=class{constructor(e={}){this.subjectKeyIdentifier=new Gt,Object.assign(this,e)}};T([u({type:Gt})],Ys.prototype,"subjectKeyIdentifier",void 0);T([u({type:h.GeneralizedTime,optional:!0})],Ys.prototype,"date",void 0);T([u({type:Ao,optional:!0})],Ys.prototype,"other",void 0);var Js=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Ys,context:0,implicit:!0,optional:!0})],Js.prototype,"rKeyId",void 0);T([u({type:Lr,optional:!0})],Js.prototype,"issuerAndSerialNumber",void 0);Js=T([E({type:x.Choice})],Js);var pu=class{constructor(e={}){this.rid=new Js,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:Js})],pu.prototype,"rid",void 0);T([u({type:ae})],pu.prototype,"encryptedKey",void 0);var wp=Tm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Tm.prototype)}};wp=Tm=T([E({type:x.Sequence,itemType:pu})],wp);var hu=class{constructor(e={}){this.algorithm=new K,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:K})],hu.prototype,"algorithm",void 0);T([u({type:h.BitString})],hu.prototype,"publicKey",void 0);var Mi=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Gt,context:0,implicit:!0,optional:!0})],Mi.prototype,"subjectKeyIdentifier",void 0);T([u({type:hu,context:1,implicit:!0,optional:!0})],Mi.prototype,"originatorKey",void 0);T([u({type:Lr,optional:!0})],Mi.prototype,"issuerAndSerialNumber",void 0);Mi=T([E({type:x.Choice})],Mi);var Rn=class{constructor(e={}){this.version=Et.v3,this.originator=new Mi,this.keyEncryptionAlgorithm=new zt,this.recipientEncryptedKeys=new wp,Object.assign(this,e)}};T([u({type:h.Integer})],Rn.prototype,"version",void 0);T([u({type:Mi,context:0})],Rn.prototype,"originator",void 0);T([u({type:ae,context:1,optional:!0})],Rn.prototype,"ukm",void 0);T([u({type:zt})],Rn.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:wp})],Rn.prototype,"recipientEncryptedKeys",void 0);var Qs=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Gt,context:0,implicit:!0})],Qs.prototype,"subjectKeyIdentifier",void 0);T([u({type:Lr})],Qs.prototype,"issuerAndSerialNumber",void 0);Qs=T([E({type:x.Choice})],Qs);var Eo=class{constructor(e={}){this.version=Et.v0,this.rid=new Qs,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],Eo.prototype,"version",void 0);T([u({type:Qs})],Eo.prototype,"rid",void 0);T([u({type:zt})],Eo.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],Eo.prototype,"encryptedKey",void 0);var Ki=class{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}};T([u({type:ae})],Ki.prototype,"keyIdentifier",void 0);T([u({type:h.GeneralizedTime,optional:!0})],Ki.prototype,"date",void 0);T([u({type:Ao,optional:!0})],Ki.prototype,"other",void 0);var Co=class{constructor(e={}){this.version=Et.v4,this.kekid=new Ki,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],Co.prototype,"version",void 0);T([u({type:Ki})],Co.prototype,"kekid",void 0);T([u({type:zt})],Co.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],Co.prototype,"encryptedKey",void 0);var To=class{constructor(e={}){this.version=Et.v0,this.keyEncryptionAlgorithm=new zt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],To.prototype,"version",void 0);T([u({type:yp,context:0,optional:!0})],To.prototype,"keyDerivationAlgorithm",void 0);T([u({type:zt})],To.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],To.prototype,"encryptedKey",void 0);var du=class{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],du.prototype,"oriType",void 0);T([u({type:h.Any})],du.prototype,"oriValue",void 0);var jn=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Eo,optional:!0})],jn.prototype,"ktri",void 0);T([u({type:Rn,context:1,implicit:!0,optional:!0})],jn.prototype,"kari",void 0);T([u({type:Co,context:2,implicit:!0,optional:!0})],jn.prototype,"kekri",void 0);T([u({type:To,context:3,implicit:!0,optional:!0})],jn.prototype,"pwri",void 0);T([u({type:du,context:4,implicit:!0,optional:!0})],jn.prototype,"ori",void 0);jn=T([E({type:x.Choice})],jn);var Om,yu=Om=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Om.prototype)}};yu=Om=T([E({type:x.Set,itemType:jn})],yu);var Bm,Sv=`${wo}.16`,gH=`${Sv}.2`,bH=`${Sv}.4`,ea=class{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],ea.prototype,"otherRevInfoFormat",void 0);T([u({type:h.Any})],ea.prototype,"otherRevInfo",void 0);var xp=class{constructor(e={}){this.other=new ea,Object.assign(this,e)}};T([u({type:ea,context:1,implicit:!0})],xp.prototype,"other",void 0);xp=T([E({type:x.Choice})],xp);var ta=Bm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Bm.prototype)}};ta=Bm=T([E({type:x.Set,itemType:xp})],ta);var ra=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Li,context:0,implicit:!0,optional:!0})],ra.prototype,"certs",void 0);T([u({type:ta,context:1,implicit:!0,optional:!0})],ra.prototype,"crls",void 0);var Im,Pm=Im=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Im.prototype)}};Pm=Im=T([E({type:x.Set,itemType:Ur})],Pm);var Hi=class{constructor(e={}){this.version=Et.v0,this.recipientInfos=new yu,this.encryptedContentInfo=new So,Object.assign(this,e)}};T([u({type:h.Integer})],Hi.prototype,"version",void 0);T([u({type:ra,context:0,implicit:!0,optional:!0})],Hi.prototype,"originatorInfo",void 0);T([u({type:yu})],Hi.prototype,"recipientInfos",void 0);T([u({type:So})],Hi.prototype,"encryptedContentInfo",void 0);T([u({type:Pm,context:1,implicit:!0,optional:!0})],Hi.prototype,"unprotectedAttrs",void 0);var Av="1.2.840.113549.1.7.2";var Nm,vp=Nm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Nm.prototype)}};vp=Nm=T([E({type:x.Set,itemType:Pi})],vp);var Ln=class{constructor(e={}){this.version=Et.v0,this.digestAlgorithms=new vp,this.encapContentInfo=new Ui,this.signerInfos=new nu,Object.assign(this,e)}};T([u({type:h.Integer})],Ln.prototype,"version",void 0);T([u({type:vp})],Ln.prototype,"digestAlgorithms",void 0);T([u({type:Ui})],Ln.prototype,"encapContentInfo",void 0);T([u({type:Li,context:0,implicit:!0,optional:!0})],Ln.prototype,"certificates",void 0);T([u({type:ta,context:1,implicit:!0,optional:!0})],Ln.prototype,"crls",void 0);T([u({type:nu})],Ln.prototype,"signerInfos",void 0);var Vi="1.2.840.10045.2.1";var mu="1.2.840.10045.4.1",_p="1.2.840.10045.4.3.1",gu="1.2.840.10045.4.3.2",bu="1.2.840.10045.4.3.3",wu="1.2.840.10045.4.3.4";var km="1.2.840.10045.3.1.7";var Dm="1.3.132.0.34";var Rm="1.3.132.0.35";function xu(r){return new K({algorithm:r})}var Cv=xu(mu),dV=xu(_p),Tv=xu(gu),Ov=xu(bu),Bv=xu(wu);function Le(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var vu=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.ObjectIdentifier})],vu.prototype,"fieldType",void 0);Le([u({type:h.Any})],vu.prototype,"parameters",void 0);vu=Le([E({type:x.Sequence})],vu);var jm=class extends ae{};var na=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.OctetString})],na.prototype,"a",void 0);Le([u({type:h.OctetString})],na.prototype,"b",void 0);Le([u({type:h.BitString,optional:!0})],na.prototype,"seed",void 0);na=Le([E({type:x.Sequence})],na);var Lm;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Lm||(Lm={}));var nn=class{constructor(e={}){this.version=Lm.ecpVer1,Object.assign(this,e)}};Le([u({type:h.Integer})],nn.prototype,"version",void 0);Le([u({type:vu})],nn.prototype,"fieldID",void 0);Le([u({type:na})],nn.prototype,"curve",void 0);Le([u({type:jm})],nn.prototype,"base",void 0);Le([u({type:h.Integer,converter:we})],nn.prototype,"order",void 0);Le([u({type:h.Integer,optional:!0})],nn.prototype,"cofactor",void 0);nn=Le([E({type:x.Sequence})],nn);var on=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.ObjectIdentifier})],on.prototype,"namedCurve",void 0);Le([u({type:h.Null})],on.prototype,"implicitCurve",void 0);Le([u({type:nn})],on.prototype,"specifiedCurve",void 0);on=Le([E({type:x.Choice})],on);var oa=class{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}};Le([u({type:h.Integer})],oa.prototype,"version",void 0);Le([u({type:ae})],oa.prototype,"privateKey",void 0);Le([u({type:on,context:0,optional:!0})],oa.prototype,"parameters",void 0);Le([u({type:h.BitString,context:1,optional:!0})],oa.prototype,"publicKey",void 0);var $i=class{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}};Le([u({type:h.Integer,converter:we})],$i.prototype,"r",void 0);Le([u({type:h.Integer,converter:we})],$i.prototype,"s",void 0);function Pe(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Yt="1.2.840.113549.1.1",sn=`${Yt}.1`,Iv=`${Yt}.7`,Pv=`${Yt}.9`,Oo=`${Yt}.10`,Nv=`${Yt}.2`,kv=`${Yt}.4`,ia=`${Yt}.5`,Dv=`${Yt}.14`;var Sp=`${Yt}.11`,sa=`${Yt}.12`,aa=`${Yt}.13`,Um=`${Yt}.15`,Mm=`${Yt}.16`,Fi="1.3.14.3.2.26",Ap="2.16.840.1.101.3.4.2.4",Wi="2.16.840.1.101.3.4.2.1",qi="2.16.840.1.101.3.4.2.2",Gi="2.16.840.1.101.3.4.2.3",Rv="2.16.840.1.101.3.4.2.5",jv="2.16.840.1.101.3.4.2.6",Lv="1.2.840.113549.2.2",Uv="1.2.840.113549.2.5",Bo=`${Yt}.8`;function lt(r){return new K({algorithm:r,parameters:null})}var FV=lt(Lv),WV=lt(Uv),Un=lt(Fi),qV=lt(Ap),GV=lt(Wi),zV=lt(qi),XV=lt(Gi),ZV=lt(Rv),YV=lt(jv),Ep=new K({algorithm:Bo,parameters:W.serialize(Un)}),Km=new K({algorithm:Pv,parameters:W.serialize(Ks.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),JV=lt(sn),QV=lt(Nv),e$=lt(kv),t$=lt(ia),r$=lt(Um),n$=lt(Mm),o$=lt(sa),i$=lt(aa),s$=lt(Um),a$=lt(Mm);var ca=class{constructor(e={}){this.hashAlgorithm=new K(Un),this.maskGenAlgorithm=new K({algorithm:Bo,parameters:W.serialize(Un)}),this.pSourceAlgorithm=new K(Km),Object.assign(this,e)}};Pe([u({type:K,context:0,defaultValue:Un})],ca.prototype,"hashAlgorithm",void 0);Pe([u({type:K,context:1,defaultValue:Ep})],ca.prototype,"maskGenAlgorithm",void 0);Pe([u({type:K,context:2,defaultValue:Km})],ca.prototype,"pSourceAlgorithm",void 0);var d$=new K({algorithm:Iv,parameters:W.serialize(new ca)});var an=class{constructor(e={}){this.hashAlgorithm=new K(Un),this.maskGenAlgorithm=new K({algorithm:Bo,parameters:W.serialize(Un)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}};Pe([u({type:K,context:0,defaultValue:Un})],an.prototype,"hashAlgorithm",void 0);Pe([u({type:K,context:1,defaultValue:Ep})],an.prototype,"maskGenAlgorithm",void 0);Pe([u({type:h.Integer,context:2,defaultValue:20})],an.prototype,"saltLength",void 0);Pe([u({type:h.Integer,context:3,defaultValue:1})],an.prototype,"trailerField",void 0);var v$=new K({algorithm:Oo,parameters:W.serialize(new an)});var zi=class{constructor(e={}){this.digestAlgorithm=new K,this.digest=new ae,Object.assign(this,e)}};Pe([u({type:K})],zi.prototype,"digestAlgorithm",void 0);Pe([u({type:ae})],zi.prototype,"digest",void 0);var Hm,ua=class{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer,converter:we})],ua.prototype,"prime",void 0);Pe([u({type:h.Integer,converter:we})],ua.prototype,"exponent",void 0);Pe([u({type:h.Integer,converter:we})],ua.prototype,"coefficient",void 0);var Cp=Hm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Hm.prototype)}};Cp=Hm=Pe([E({type:x.Sequence,itemType:ua})],Cp);var br=class{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer})],br.prototype,"version",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"modulus",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"publicExponent",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"privateExponent",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"prime1",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"prime2",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"exponent1",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"exponent2",void 0);Pe([u({type:h.Integer,converter:we})],br.prototype,"coefficient",void 0);Pe([u({type:Cp,optional:!0})],br.prototype,"otherPrimeInfos",void 0);var fa=class{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer,converter:we})],fa.prototype,"modulus",void 0);Pe([u({type:h.Integer,converter:we})],fa.prototype,"publicExponent",void 0);var Vm;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(Vm||(Vm={}));var Ct=Vm;var s1=Vr(i1(),1),{__extends:pa,__assign:J$,__rest:tT,__decorate:Q$,__param:e7,__metadata:t7,__awaiter:a1,__generator:c1,__exportStar:r7,__createBinding:n7,__values:_u,__read:Su,__spread:Mr,__spreadArrays:o7,__await:i7,__asyncGenerator:s7,__asyncDelegator:a7,__asyncValues:c7,__makeTemplateObject:u7,__importStar:f7,__importDefault:l7,__classPrivateFieldGet:p7,__classPrivateFieldSet:h7}=s1.default;var rT="injectionTokens";function Fm(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(rT,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Au(r){return!!r.useClass}function ha(r){return!!r.useFactory}var Bp=(function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},o=!1,i,s=function(){return o||(i=e(t.wrap()),o=!0),i};return new Proxy(n,this.createHandler(s))},r.prototype.createHandler=function(e){var t={},n=function(o){t[o]=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];i[0]=e();var a=Reflect[o];return a.apply(void 0,Mr(i))}};return this.reflectMethods.forEach(n),t},r})();function Io(r){return typeof r=="string"||typeof r=="symbol"}function Wm(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Ip(r){return typeof r=="object"&&"token"in r&&"transform"in r}function u1(r){return typeof r=="function"||r instanceof Bp}function Xi(r){return!!r.useToken}function Zi(r){return r.useValue!=null}function f1(r){return Au(r)||Zi(r)||Xi(r)||ha(r)}var nT=(function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r})(),Eu=nT;var oT=(function(r){pa(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Eu),l1=oT;var iT=(function(){function r(){this.scopedResolutions=new Map}return r})(),Cu=iT;function sT(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function aT(r,e,t){return t===void 0&&(t=" "),Mr([r],e.message.split(`
|
|
6
|
+
`)}`:`${t} :`}};Tx=it;Z.Constructed=Tx;it.NAME="CONSTRUCTED";var Hl=class extends wt{fromBER(e,t,n){return t}toBER(e){return kr}};Hl.override="EndOfContentValueBlock";var Ix,Oc=class extends ot{constructor(e={}){super(e,Hl),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ix=Oc;Z.EndOfContent=Ix;Oc.NAME=Tc;var Ox,Br=class extends ot{constructor(e={}){super(e,wt),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Ox=Br;Z.Null=Ox;Br.NAME="NULL";var Vl=class extends Yr(wt){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=be.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let o=be.BufferSourceConverter.toUint8Array(e);return On(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Ky.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Vl.NAME="BooleanValueBlock";var Bx,ci=class extends ot{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Vl),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Bx=ci;Z.Boolean=Bx;ci.NAME="BOOLEAN";var $l=class extends Yr(zr){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=zr.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===Tc){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Sx)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?zr.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};$l.NAME="OctetStringValueBlock";var Fy,Pr=class extends ot{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},$l),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=Ks(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return it.prototype.onAsciiEncoding.call(this);let e=this.constructor.NAME,t=be.Convert.ToHex(this.valueBlock.valueHexView);return`${e} : ${t}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof Fy&&e.push(t.valueBlock.valueHexView);return be.BufferSourceConverter.concat(e)}};Fy=Pr;Z.OctetString=Fy;Pr.NAME=Sx;var Fl=class extends Yr(zr){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=zr.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Tc){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ax)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=be.BufferSourceConverter.toUint8Array(e);if(!On(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ks(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return zr.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return kr;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Fl.NAME="BitStringValueBlock";var Px,Nr=class extends ot{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Fl),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return it.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join(""),o=this.constructor.NAME,i=n.substring(0,n.length-this.valueBlock.unusedBits);return`${o} : ${i}`}}};Px=Nr;Z.BitString=Px;Nr.NAME=Ax;var Nx;function kC(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,p=c<s?s:c,l=0;for(let y=p;y>=0;y--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=jl(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=jl(t,i)),i}function _x(r){if(r>=Ec.length)for(let e=Ec.length;e<=r;e++){let t=new Uint8Array([0]),n=Ec[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=jl(t,n)),Ec.push(n)}return Ec[r]}function DC(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,p=0;for(let l=c;l>=0;l--,p++)switch(f=i[s-p]-a[c-p]-t,!0){case f<0:t=1,i[s-p]=f+10;break;default:t=0,i[s-p]=f}if(t>0)for(let l=s-c+1;l>=0;l--,p++)if(f=i[s-p]-t,f<0)t=1,i[s-p]=f+10;else{t=0,i[s-p]=f;break}return i.slice()}var Bc=class extends Yr(wt){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Ky.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(bx(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&(s[1]&128)!==0?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=DC(_x(n),t),s="-";break;default:t=kC(t,_x(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=xx.charAt(t[c]));return a===!1&&(s+=xx.charAt(0)),s}};Nx=Bc;Bc.NAME="IntegerValueBlock";Object.defineProperty(Nx.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Cc,In=class extends ot{constructor(e={}){super(e,Bc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ll(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ll();let t=BigInt(e),n=new Ms,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(be.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${be.Convert.ToHex(a)}`)+t,p=be.BufferSourceConverter.toUint8Array(be.Convert.FromHex(f.toString(16)));p[0]|=128,n.write(p)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new Cc({valueHex:n.final()})}convertToDER(){let e=new Cc({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Cc({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Cc=In;Z.Integer=Cc;In.NAME="INTEGER";var kx,ui=class extends In{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};kx=ui;Z.Enumerated=kx;ui.NAME="ENUMERATED";var Pc=class extends Yr(wt){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=be.BufferSourceConverter.toUint8Array(e);if(!On(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,(i[a]&128)!==0);a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,(i[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=ai(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ll();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=po(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",kr;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=be.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Pc.NAME="sidBlock";var Wl=class extends wt{constructor({value:e=Wt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Pc;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,kr;t.push(o)}return $y(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Pc;if(o>Number.MAX_SAFE_INTEGER){Ll();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Wl.NAME="ObjectIdentifierValueBlock";var Dx,fi=class extends ot{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Wl),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Dx=fi;Z.ObjectIdentifier=Dx;fi.NAME="OBJECT IDENTIFIER";var Nc=class extends Yr(Cn){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=be.BufferSourceConverter.toUint8Array(e);if(!On(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,(i[a]&128)!==0);a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,(i[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=ai(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=po(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",kr;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=be.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Nc.NAME="relativeSidBlock";var ql=class extends wt{constructor({value:e=Wt,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Nc;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,kr;n.push(i)}return $y(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new Nc;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};ql.NAME="RelativeObjectIdentifierValueBlock";var Rx,kc=class extends ot{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,ql),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Rx=kc;Z.RelativeObjectIdentifier=Rx;kc.NAME="RelativeObjectIdentifier";var jx,Nt=class extends it{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};jx=Nt;Z.Sequence=jx;Nt.NAME="SEQUENCE";var Lx,Lt=class extends it{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Lx=Lt;Z.Set=Lx;Lt.NAME="SET";var Gl=class extends Yr(wt){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Wt}toJSON(){return{...super.toJSON(),value:this.value}}};Gl.NAME="StringValueBlock";var zl=class extends Gl{};zl.NAME="SimpleStringValueBlock";var Mt=class extends Ic{constructor({...e}={}){super(e,zl)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,be.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Mt.NAME="SIMPLE STRING";var Xl=class extends Mt{fromBuffer(e){this.valueBlock.valueHexView=be.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=be.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=be.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(be.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Xl.NAME="Utf8StringValueBlock";var Mx,fr=class extends Xl{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Mx=fr;Z.Utf8String=Mx;fr.NAME="UTF8String";var Yl=class extends Mt{fromBuffer(e){this.valueBlock.value=be.Convert.ToUtf16String(e),this.valueBlock.valueHexView=be.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(be.Convert.FromUtf16String(e))}};Yl.NAME="BmpStringValueBlock";var Ux,li=class extends Yl{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ux=li;Z.BmpString=Ux;li.NAME="BMPString";var Zl=class extends Mt{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=po(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Zl.NAME="UniversalStringValueBlock";var Kx,pi=class extends Zl{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Kx=pi;Z.UniversalString=Kx;pi.NAME="UniversalString";var Hx,hi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Hx=hi;Z.NumericString=Hx;hi.NAME="NumericString";var Vx,di=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Vx=di;Z.PrintableString=Vx;di.NAME="PrintableString";var $x,yi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};$x=yi;Z.TeletexString=$x;yi.NAME="TeletexString";var Fx,mi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Fx=mi;Z.VideotexString=Fx;mi.NAME="VideotexString";var Wx,gi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Wx=gi;Z.IA5String=Wx;gi.NAME="IA5String";var qx,bi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};qx=bi;Z.GraphicString=qx;bi.NAME="GraphicString";var Gx,ho=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Gx=ho;Z.VisibleString=Gx;ho.NAME="VisibleString";var zx,wi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};zx=wi;Z.GeneralString=zx;wi.NAME="GeneralString";var Xx,xi=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Xx=xi;Z.CharacterString=Xx;xi.NAME="CharacterString";var Yx,yo=class extends ho{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,be.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ft(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ft(this.month,2),t[2]=Ft(this.day,2),t[3]=Ft(this.hour,2),t[4]=Ft(this.minute,2),t[5]=Ft(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Yx=yo;Z.UTCTime=Yx;yo.NAME="UTCTime";var Zx,vi=class extends yo{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,y=n.indexOf("+"),d="";if(y===-1&&(y=n.indexOf("-"),l=-1),y!==-1){if(d=n.substring(y+1),n=n.substring(0,y),d.length!==2&&d.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(d.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*g,d.length===4){if(g=parseInt(d.substring(2,4),10),isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");c=l*g}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let p=s.exec(o);if(p===null)throw new Error("Wrong input string for conversion");for(let l=1;l<p.length;l++)switch(l){case 1:this.year=parseInt(p[l],10);break;case 2:this.month=parseInt(p[l],10);break;case 3:this.day=parseInt(p[l],10);break;case 4:this.hour=parseInt(p[l],10)+a;break;case 5:this.minute=parseInt(p[l],10)+c;break;case 6:this.second=parseInt(p[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Ft(this.year,4)),t.push(Ft(this.month,2)),t.push(Ft(this.day,2)),t.push(Ft(this.hour,2)),t.push(Ft(this.minute,2)),t.push(Ft(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ft(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Zx=vi;Z.GeneralizedTime=Zx;vi.NAME="GeneralizedTime";var Jx,Dc=class extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Jx=Dc;Z.DATE=Jx;Dc.NAME="DATE";var Qx,Rc=class extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Qx=Rc;Z.TimeOfDay=Qx;Rc.NAME="TimeOfDay";var ev,jc=class extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};ev=jc;Z.DateTime=ev;jc.NAME="DateTime";var tv,Lc=class extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};tv=Lc;Z.Duration=tv;Lc.NAME="Duration";var rv,Mc=class extends fr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};rv=Mc;Z.TIME=rv;Mc.NAME="TIME";var Xr=class{constructor({name:e=Wt,optional:t=!1}={}){this.name=e,this.optional=t}},Us=class extends Xr{constructor({value:e=[],...t}={}){super(t),this.value=e}},_i=class extends Xr{constructor({value:e=new Xr,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},Vy=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=be.BufferSourceConverter.toUint8Array(e)}constructor({data:e=Jl}={}){this.dataView=be.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let o=t+n;return this.dataView=be.BufferSourceConverter.toUint8Array(e).subarray(t,o),o}toBER(e){return this.dataView.slice().buffer}};function En(r,e,t){if(t instanceof Us){for(let i of t.value)if(En(r,e,i).verified)return{verified:!0,result:r};{let i={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(Hy)&&(i.name=t.name),i}}if(t instanceof Xr)return t.hasOwnProperty(Hy)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(AC in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(IC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(OC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(EC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(CC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(TC)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(SC in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(vx in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};let i=t.idBlock.valueHexView,s=e.idBlock.valueHexView;if(i.length!==s.length)return{verified:!1,result:r};for(let a=0;a<i.length;a++)if(i[a]!==s[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&(r[t.name]=e)),t instanceof Z.Constructed){let i=0,s={verified:!1,result:{error:"Unknown error"}},a=t.valueBlock.value.length;if(a>0&&t.valueBlock.value[0]instanceof _i&&(a=e.valueBlock.value.length),a===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let c=!0;for(let f=0;f<t.valueBlock.value.length;f++)c=c&&(t.valueBlock.value[f].optional||!1);return c?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let c=0;c<a;c++)if(c-i>=e.valueBlock.value.length){if(t.valueBlock.value[c].optional===!1){let f={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&(delete r[t.name],f.name=t.name)),f}}else if(t.valueBlock.value[0]instanceof _i){if(s=En(r,e.valueBlock.value[c],t.valueBlock.value[0].value),s.verified===!1)if(t.valueBlock.value[0].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&delete r[t.name]),s;if(Hy in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let f={};BC in t.valueBlock.value[0]&&t.valueBlock.value[0].local?f=e:f=r,typeof f[t.valueBlock.value[0].name]>"u"&&(f[t.valueBlock.value[0].name]=[]),f[t.valueBlock.value[0].name].push(e.valueBlock.value[c])}}else if(s=En(r,e.valueBlock.value[c-i],t.valueBlock.value[c]),s.verified===!1)if(t.valueBlock.value[c].optional)i++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&delete r[t.name]),s;if(s.verified===!1){let c={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&(delete r[t.name],c.name=t.name)),c}return{verified:!0,result:r}}if(t.primitiveSchema&&vx in e.valueBlock){let i=Ks(e.valueBlock.valueHexView);if(i.offset===-1){let s={verified:!1,result:i.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,Wt),t.name&&(delete r[t.name],s.name=t.name)),s}return En(r,i.result,t.primitiveSchema)}return{verified:!0,result:r}}function RC(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};let t=Ks(be.BufferSourceConverter.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:En(t.result,t.result,e)}var x;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(x||(x={}));var h;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(h||(h={}));var Wy=Hr(An()),Jr=class{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(Wy.BufferSourceConverter.isBufferSource(e))this.unusedBits=t,this.value=Wy.BufferSourceConverter.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof Nr))throw new TypeError("Argument 'asn' is not instance of ASN.1 BitString");return this.unusedBits=e.valueBlock.unusedBits,this.value=e.valueBlock.valueHex,this}toASN(){return new Nr({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new Nr({name:e})}toNumber(){let e="",t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let o=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let i=0;for(;i<n;)o[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=o.buffer}};var qy=Hr(An()),ae=class{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):qy.BufferSourceConverter.isBufferSource(e)?this.buffer=qy.BufferSourceConverter.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof Pr))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new Pr({valueHex:this.buffer})}toSchema(e){return new Pr({name:e})}};var jC={fromASN:r=>r instanceof Br?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new Br;let e=Bn(r);if(e.result.error)throw new Error(e.result.error);return e.result}},LC={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new In({value:+r})},MC={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new ui({value:r})},we={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new In({valueHex:r})};var UC={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Nr({valueHex:r})},KC={fromASN:r=>r.valueBlock.toString(),toASN:r=>new fi({value:r})},HC={fromASN:r=>r.valueBlock.value,toASN:r=>new ci({value:r})},Hs={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Pr({valueHex:r})},nv={fromASN:r=>new ae(r.getValue()),toASN:r=>r.toASN()};function lr(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}var Gy=lr(fr),VC=lr(li),$C=lr(pi),FC=lr(hi),WC=lr(di),qC=lr(yi),GC=lr(mi),zC=lr(gi),XC=lr(bi),YC=lr(ho),ZC=lr(wi),JC=lr(xi),QC={fromASN:r=>r.toDate(),toASN:r=>new yo({valueDate:r})},eT={fromASN:r=>r.toDate(),toASN:r=>new vi({valueDate:r})},tT={fromASN:()=>null,toASN:()=>new Br};function mo(r){switch(r){case h.Any:return jC;case h.BitString:return UC;case h.BmpString:return VC;case h.Boolean:return HC;case h.CharacterString:return JC;case h.Enumerated:return MC;case h.GeneralString:return ZC;case h.GeneralizedTime:return eT;case h.GraphicString:return XC;case h.IA5String:return zC;case h.Integer:return LC;case h.Null:return tT;case h.NumericString:return FC;case h.ObjectIdentifier:return KC;case h.OctetString:return Hs;case h.PrintableString:return WC;case h.TeletexString:return qC;case h.UTCTime:return QC;case h.UniversalString:return $C;case h.Utf8String:return Gy;case h.VideotexString:return GC;case h.VisibleString:return YC;default:return null}}function pr(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:pr(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Xy(r){var e;if(r){let t=Object.getPrototypeOf(r);return((e=t?.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Xy(t)}return!1}function ov(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}var Ql=class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){let t={type:x.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){let n=this.items.get(e)||this.createDefault(e),o=[];for(let i in n.items){let s=n.items[i],a=t?i:"",c;if(typeof s.type=="number"){let p=h[s.type],l=Zr[p];if(!l)throw new Error(`Cannot get ASN1 class by name '${p}'`);c=new l({name:a})}else pr(s.type)?c=new s.type().toSchema(a):s.optional?this.get(s.type).type===x.Choice?c=new Xr({name:a}):(c=this.create(s.type,!1),c.name=a):c=new Xr({name:a});let f=!!s.optional||s.defaultValue!==void 0;if(s.repeated){c.name="";let p=s.repeated==="set"?Lt:Nt;c=new p({name:"",value:[new _i({name:a,value:c})]})}if(s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type=="number"||pr(s.type)){let p=s.repeated?it:Tn;o.push(new p({name:a,optional:f,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let p=!!s.repeated,l=p?c:this.get(s.type,!0).schema;l="valueBlock"in l?l.valueBlock.value:l.value,o.push(new it({name:p?"":a,optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:l}))}else o.push(new it({optional:f,idBlock:{tagClass:3,tagNumber:s.context},value:[c]}));else c.optional=f,o.push(c)}switch(n.type){case x.Sequence:return new Nt({value:o,name:""});case x.Set:return new Lt({value:o,name:""});case x.Choice:return new Us({value:o,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}};var Je=new Ql;var E=r=>e=>{let t;Je.has(e)?t=Je.get(e):(t=Je.createDefault(e),Je.set(e,t)),Object.assign(t,r)};var u=r=>(e,t)=>{let n;Je.has(e.constructor)?n=Je.get(e.constructor):(n=Je.createDefault(e.constructor),Je.set(e.constructor,n));let o=Object.assign({},r);if(typeof o.type=="number"&&!o.converter){let i=mo(r.type);if(!i)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);o.converter=i}o.raw=r.raw,n.items[t]=o};var go=class extends Error{constructor(){super(...arguments),this.schemas=[]}};var Uc=class{static parse(e,t){let n=Bn(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){try{if(pr(t))return new t().fromASN(e);let n=Je.get(t);Je.cache(t);let o=n.schema,i=this.handleChoiceTypes(e,n,t,o);if(i?.result)return i.result;i?.targetSchema&&(o=i.targetSchema);let s=this.handleSequenceTypes(e,n,t,o);if(s&&"isManualMapping"in s)return s.result;let a=s,c=new t;return Xy(t)?this.handleArrayTypes(e,n,t):(this.processSchemaItems(n,a,c),c)}catch(n){throw n instanceof go&&n.schemas.push(t.name),n}}static handleChoiceTypes(e,t,n,o){if(e.constructor===it&&t.type===x.Choice&&e.idBlock.tagClass===3)for(let i in t.items){let s=t.items[i];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type=="function"&&Je.has(s.type)){let a=Je.get(s.type);if(a&&a.type===x.Sequence){let c=new Nt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in c.valueBlock){c.valueBlock.value=e.valueBlock.value;let f=this.fromASN(c,s.type),p=new n;return p[i]=f,{result:p}}}}}else if(e.constructor===it&&t.type!==x.Choice){let i=new it({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let s in t.items)delete e[s];return{targetSchema:i}}return null}static handleSequenceTypes(e,t,n,o){if(t.type===x.Sequence){if(Object.keys(t.items).filter(a=>{let c=t.items[a];return c.optional&&typeof c.type=="function"&&Je.has(c.type)&&Je.get(c.type).type===x.Choice}).length>0&&"value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&n.name==="CertReqMsg")return this.handleManualMapping(e,t,n);let s=En({},e,o);if(!s.verified)throw new go(`Data does not match to ${n.name} ASN1 schema.${s.result.error?` ${s.result.error}`:""}`);return s}else{let i=En({},e,o);if(!i.verified)throw new go(`Data does not match to ${n.name} ASN1 schema.${i.result.error?` ${i.result.error}`:""}`);return i}}static handleManualMapping(e,t,n){let o=new n,i=e.valueBlock.value,s=Object.keys(t.items),a=0;for(let c=0;c<s.length;c++){let f=s[c],p=t.items[f];if(a>=i.length)break;if(p.repeated){o[f]=this.processRepeatedField(i,a,p);break}else if(typeof p.type=="number")o[f]=this.processPrimitiveField(i[a],p),a++;else if(this.isOptionalChoiceField(p)){let l=this.processOptionalChoiceField(i[a],p);l.processed&&(o[f]=l.value,a++)}else o[f]=this.fromASN(i[a],p.type),a++}return{result:o,verified:!0,isManualMapping:!0}}static processRepeatedField(e,t,n){let o=e.slice(t);if(o.length===1&&o[0].constructor.name==="Sequence"){let i=o[0];i.valueBlock&&i.valueBlock.value&&Array.isArray(i.valueBlock.value)&&(o=i.valueBlock.value)}if(typeof n.type=="number"){let i=mo(n.type);if(!i)throw new Error(`No converter for ASN.1 type ${n.type}`);return o.filter(s=>s&&s.valueBlock).map(s=>{try{return i.fromASN(s)}catch{return}}).filter(s=>s!==void 0)}else return o.filter(i=>i&&i.valueBlock).map(i=>{try{return this.fromASN(i,n.type)}catch{return}}).filter(i=>i!==void 0)}static processPrimitiveField(e,t){let n=mo(t.type);if(!n)throw new Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type=="function"&&Je.has(e.type)&&Je.get(e.type).type===x.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(n){if(n instanceof go&&/Wrong values for Choice type/.test(n.message))return{processed:!1};throw n}}static handleArrayTypes(e,t,n){if(!("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let o=t.itemType;if(typeof o=="number"){let i=mo(o);if(!i)throw new Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,s=>i.fromASN(s))}else return n.from(e.valueBlock.value,i=>this.fromASN(i,o))}static processSchemaItems(e,t,n){for(let o in e.items){let i=t.result[o];if(!i)continue;let s=e.items[o],a=s.type,c;typeof a=="number"||pr(a)?c=this.processPrimitiveSchemaItem(i,s,a):c=this.processComplexSchemaItem(i,s,a),c&&typeof c=="object"&&"value"in c&&"raw"in c?(n[o]=c.value,n[`${o}Raw`]=c.raw):n[o]=c}}static processPrimitiveSchemaItem(e,t,n){var o;let i=(o=t.converter)!==null&&o!==void 0?o:pr(n)?new n:null;if(!i)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,i):this.processSinglePrimitiveItem(e,t,n,i)}static processRepeatedPrimitiveItem(e,t,n){if(t.implicit){let o=t.repeated==="sequence"?Nt:Lt,i=new o;i.valueBlock=e.valueBlock;let s=Bn(i.toBER(!1));if(s.offset===-1)throw new Error(`Cannot parse the child item. ${s.result.error}`);if(!("value"in s.result.valueBlock&&Array.isArray(s.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");let a=s.result.valueBlock.value;return Array.from(a,c=>n.fromASN(c))}else return Array.from(e,o=>n.fromASN(o))}static processSinglePrimitiveItem(e,t,n,o){let i=e;if(t.implicit){let s;if(pr(n))s=new n().toSchema("");else{let a=h[n],c=Zr[a];if(!c)throw new Error(`Cannot get '${a}' class from asn1js module`);s=new c}s.valueBlock=i.valueBlock,i=Bn(s.toBER(!1)).result}return o.fromASN(i)}static processComplexSchemaItem(e,t,n){if(t.repeated){if(!Array.isArray(e))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");return Array.from(e,o=>this.fromASN(o,n))}else{let o=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(o,n)}catch(i){if(i instanceof go&&/Wrong values for Choice type/.test(i.message))return;throw i}else{let i=this.fromASN(o,n);return t.raw?{value:i,raw:e.valueBeforeDecodeView}:i}}}static handleImplicitTagging(e,t,n){if(t.implicit&&typeof t.context=="number"){let o=Je.get(n);if(o.type===x.Sequence){let i=new Nt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in i.valueBlock)return i.valueBlock.value=e.valueBlock.value,i}else if(o.type===x.Set){let i=new Lt;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in i.valueBlock)return i.valueBlock.value=e.valueBlock.value,i}}return e}};var Kc=class r{static serialize(e){return e instanceof ot?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&pr(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");let t=e.constructor,n=Je.get(t);Je.cache(t);let o=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){let s=mo(n.itemType);if(!s)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);o=e.map(a=>s.toASN(a))}else o=e.map(s=>this.toAsnItem({type:n.itemType},"[]",t,s))}else for(let s in n.items){let a=n.items[s],c=e[s];if(c===void 0||a.defaultValue===c||typeof a.defaultValue=="object"&&typeof c=="object"&&ov(this.serialize(a.defaultValue),this.serialize(c)))continue;let f=r.toAsnItem(a,s,t,c);if(typeof a.context=="number")if(a.implicit)if(!a.repeated&&(typeof a.type=="number"||pr(a.type))){let p={};p.valueHex=f instanceof Br?f.valueBeforeDecodeView:f.valueBlock.toBER(),o.push(new Tn({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...p}))}else o.push(new it({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:f.valueBlock.value}));else o.push(new it({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[f]}));else a.repeated?o=o.concat(f):o.push(f)}let i;switch(n.type){case x.Sequence:i=new Nt({value:o});break;case x.Set:i=new Lt({value:o});break;case x.Choice:if(!o[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=o[0];break}return i}static toAsnItem(e,t,n,o){let i;if(typeof e.type=="number"){let s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${h[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");let a=Array.from(o,f=>s.toASN(f)),c=e.repeated==="sequence"?Nt:Lt;i=new c({value:a})}else i=s.toASN(o)}else if(e.repeated){if(!Array.isArray(o))throw new TypeError("Parameter 'objProp' should be type of Array.");let s=Array.from(o,c=>this.toASN(c)),a=e.repeated==="sequence"?Nt:Lt;i=new a({value:s})}else i=this.toASN(o);return i}};var se=class extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(let t of e)this.push(t)}}};var Yy=Hr(An());var W=class r{static serialize(e){return Kc.serialize(e)}static parse(e,t){return Uc.parse(e,t)}static toString(e){let t=Yy.BufferSourceConverter.isBufferSource(e)?Yy.BufferSourceConverter.toArrayBuffer(e):r.serialize(e),n=Bn(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}};function b(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var iv=Hr(An()),Hc=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(".");if(t.length!==4)throw new Error("Invalid IPv4 address");return t.map(n=>{let o=parseInt(n,10);if(isNaN(o)||o<0||o>255)throw new Error("Invalid IPv4 address part");return o})}static parseIPv6(e){let n=this.expandIPv6(e).split(":");if(n.length!==8)throw new Error("Invalid IPv6 address");return n.reduce((o,i)=>{let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error("Invalid IPv6 address part");return o.push(s>>8&255),o.push(s&255),o},[])}static expandIPv6(e){if(!e.includes("::"))return e;let t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");let n=t[0]?t[0].split(":"):[],o=t[1]?t[1].split(":"):[],i=8-(n.length+o.length);if(i<0)throw new Error("Invalid IPv6 address");return[...n,...Array(i).fill("0"),...o].join(":")}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){let t=e.split(":"),n=-1,o=0,i=-1,s=0;for(let a=0;a<t.length;a++)t[a]==="0"?(i===-1&&(i=a),s++):(s>o&&(n=i,o=s),i=-1,s=0);if(s>o&&(n=i,o=s),o>1){let a=t.slice(0,n).join(":"),c=t.slice(n+o).join(":");return`${a}::${c}`}return e}static parseCIDR(e){let[t,n]=e.split("/"),o=parseInt(n,10);if(this.isIPv4(t)){if(o<0||o>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),o]}else{if(o<0||o>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),o]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split("").reduce((o,i)=>o+ +i,0),n=e.slice(0,8).replace(/(.{2})/g,o=>`${parseInt(o,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let t=new Uint8Array(e);if(t.length===4)return Array.from(t).join(".");if(t.length===16)return this.formatIPv6(t);if(t.length===8||t.length===32){let n=t.length/2,o=t.slice(0,n),i=t.slice(n);if(t.every(c=>c===0))return t.length===8?"0.0.0.0/0":"::/0";let a=i.reduce((c,f)=>c+(f.toString(2).match(/1/g)||[]).length,0);return t.length===8?`${Array.from(o).join(".")}/${a}`:`${this.formatIPv6(o)}/${a}`}return this.decodeIP(iv.Convert.ToHex(e))}static fromString(e){if(e.includes("/")){let[n,o]=this.parseCIDR(e),i=new Uint8Array(n.length),s=o;for(let c=0;c<i.length;c++)s>=8?(i[c]=255,s-=8):s>0&&(i[c]=255<<8-s,s=0);let a=new Uint8Array(n.length*2);return a.set(n,0),a.set(i,n.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}};var sv=Hr(An()),Zy,Jy,Qy,st=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};b([u({type:h.TeletexString})],st.prototype,"teletexString",void 0);b([u({type:h.PrintableString})],st.prototype,"printableString",void 0);b([u({type:h.UniversalString})],st.prototype,"universalString",void 0);b([u({type:h.Utf8String})],st.prototype,"utf8String",void 0);b([u({type:h.BmpString})],st.prototype,"bmpString",void 0);st=b([E({type:x.Choice})],st);var Vs=class extends st{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?sv.Convert.ToHex(this.anyValue):super.toString())}};b([u({type:h.IA5String})],Vs.prototype,"ia5String",void 0);b([u({type:h.Any})],Vs.prototype,"anyValue",void 0);Vs=b([E({type:x.Choice})],Vs);var Si=class{constructor(e={}){this.type="",this.value=new Vs,Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Si.prototype,"type",void 0);b([u({type:Vs})],Si.prototype,"value",void 0);var bo=Zy=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Zy.prototype)}};bo=Zy=b([E({type:x.Set,itemType:Si})],bo);var em=Jy=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Jy.prototype)}};em=Jy=b([E({type:x.Sequence,itemType:bo})],em);var je=Qy=class extends em{constructor(e){super(e),Object.setPrototypeOf(this,Qy.prototype)}};je=Qy=b([E({type:x.Sequence})],je);var rT={fromASN:r=>Hc.toString(Hs.fromASN(r)),toASN:r=>Hs.toASN(Hc.fromString(r))},wo=class{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],wo.prototype,"typeId",void 0);b([u({type:h.Any,context:0})],wo.prototype,"value",void 0);var Vc=class{constructor(e={}){this.partyName=new st,Object.assign(this,e)}};b([u({type:st,optional:!0,context:0,implicit:!0})],Vc.prototype,"nameAssigner",void 0);b([u({type:st,context:1,implicit:!0})],Vc.prototype,"partyName",void 0);var ue=class{constructor(e={}){Object.assign(this,e)}};b([u({type:wo,context:0,implicit:!0})],ue.prototype,"otherName",void 0);b([u({type:h.IA5String,context:1,implicit:!0})],ue.prototype,"rfc822Name",void 0);b([u({type:h.IA5String,context:2,implicit:!0})],ue.prototype,"dNSName",void 0);b([u({type:h.Any,context:3,implicit:!0})],ue.prototype,"x400Address",void 0);b([u({type:je,context:4,implicit:!1})],ue.prototype,"directoryName",void 0);b([u({type:Vc,context:5})],ue.prototype,"ediPartyName",void 0);b([u({type:h.IA5String,context:6,implicit:!0})],ue.prototype,"uniformResourceIdentifier",void 0);b([u({type:h.OctetString,context:7,implicit:!0,converter:rT})],ue.prototype,"iPAddress",void 0);b([u({type:h.ObjectIdentifier,context:8,implicit:!0})],ue.prototype,"registeredID",void 0);ue=b([E({type:x.Choice})],ue);var xo="1.3.6.1.5.5.7",vo=`${xo}.1`,av=`${xo}.2`,Ai=`${xo}.3`,ep=`${xo}.48`,qD=`${av}.1`,GD=`${av}.2`,tm=`${ep}.1`,rm=`${ep}.2`,nm=`${ep}.3`,om=`${ep}.5`,pe="2.5.29";var im,tp=`${vo}.1`,Pn=class{constructor(e={}){this.accessMethod="",this.accessLocation=new ue,Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Pn.prototype,"accessMethod",void 0);b([u({type:ue})],Pn.prototype,"accessLocation",void 0);var Ei=im=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,im.prototype)}};Ei=im=b([E({type:x.Sequence,itemType:Pn})],Ei);var rp=`${pe}.35`,Ci=class extends ae{},Qr=class{constructor(e={}){e&&Object.assign(this,e)}};b([u({type:Ci,context:0,optional:!0,implicit:!0})],Qr.prototype,"keyIdentifier",void 0);b([u({type:ue,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Qr.prototype,"authorityCertIssuer",void 0);b([u({type:h.Integer,context:2,optional:!0,implicit:!0,converter:we})],Qr.prototype,"authorityCertSerialNumber",void 0);var np=`${pe}.19`,Ti=class{constructor(e={}){this.cA=!1,Object.assign(this,e)}};b([u({type:h.Boolean,defaultValue:!1})],Ti.prototype,"cA",void 0);b([u({type:h.Integer,optional:!0})],Ti.prototype,"pathLenConstraint",void 0);var sm,Fe=sm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,sm.prototype)}};Fe=sm=b([E({type:x.Sequence,itemType:ue})],Fe);var am,nT=`${pe}.29`,cv=am=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,am.prototype)}};cv=am=b([E({type:x.Sequence})],cv);var cm,ip=`${pe}.32`,E3=`${ip}.0`,Nn=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};b([u({type:h.IA5String})],Nn.prototype,"ia5String",void 0);b([u({type:h.VisibleString})],Nn.prototype,"visibleString",void 0);b([u({type:h.BmpString})],Nn.prototype,"bmpString",void 0);b([u({type:h.Utf8String})],Nn.prototype,"utf8String",void 0);Nn=b([E({type:x.Choice})],Nn);var $c=class{constructor(e={}){this.organization=new Nn,this.noticeNumbers=[],Object.assign(this,e)}};b([u({type:Nn})],$c.prototype,"organization",void 0);b([u({type:h.Integer,repeated:"sequence"})],$c.prototype,"noticeNumbers",void 0);var Fc=class{constructor(e={}){Object.assign(this,e)}};b([u({type:$c,optional:!0})],Fc.prototype,"noticeRef",void 0);b([u({type:Nn,optional:!0})],Fc.prototype,"explicitText",void 0);var op=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.IA5String})],op.prototype,"cPSuri",void 0);b([u({type:Fc})],op.prototype,"userNotice",void 0);op=b([E({type:x.Choice})],op);var Wc=class{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Wc.prototype,"policyQualifierId",void 0);b([u({type:h.Any})],Wc.prototype,"qualifier",void 0);var Ii=class{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Ii.prototype,"policyIdentifier",void 0);b([u({type:Wc,repeated:"sequence",optional:!0})],Ii.prototype,"policyQualifiers",void 0);var qc=cm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,cm.prototype)}};qc=cm=b([E({type:x.Sequence,itemType:Ii})],qc);var k3=`${pe}.20`,Gc=class{constructor(e=0){this.value=e}};b([u({type:h.Integer})],Gc.prototype,"value",void 0);Gc=b([E({type:x.Choice})],Gc);var K3=`${pe}.27`,uv=class extends Gc{};uv=b([E({type:x.Choice})],uv);var um,sp=`${pe}.31`,Dr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Dr||(Dr={}));var zc=class extends Jr{toJSON(){let e=[],t=this.toNumber();return t&Dr.aACompromise&&e.push("aACompromise"),t&Dr.affiliationChanged&&e.push("affiliationChanged"),t&Dr.cACompromise&&e.push("cACompromise"),t&Dr.certificateHold&&e.push("certificateHold"),t&Dr.cessationOfOperation&&e.push("cessationOfOperation"),t&Dr.keyCompromise&&e.push("keyCompromise"),t&Dr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Dr.superseded&&e.push("superseded"),t&Dr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}},kn=class{constructor(e={}){Object.assign(this,e)}};b([u({type:ue,context:0,repeated:"sequence",implicit:!0})],kn.prototype,"fullName",void 0);b([u({type:bo,context:1,implicit:!0})],kn.prototype,"nameRelativeToCRLIssuer",void 0);kn=b([E({type:x.Choice})],kn);var en=class{constructor(e={}){Object.assign(this,e)}};b([u({type:kn,context:0,optional:!0})],en.prototype,"distributionPoint",void 0);b([u({type:zc,context:1,optional:!0,implicit:!0})],en.prototype,"reasons",void 0);b([u({type:ue,context:2,optional:!0,repeated:"sequence",implicit:!0})],en.prototype,"cRLIssuer",void 0);var _o=um=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,um.prototype)}};_o=um=b([E({type:x.Sequence,itemType:en})],_o);var fm,tR=`${pe}.46`,fv=fm=class extends _o{constructor(e){super(e),Object.setPrototypeOf(this,fm.prototype)}};fv=fm=b([E({type:x.Sequence,itemType:en})],fv);var uR=`${pe}.28`,tr=class r{constructor(e={}){this.onlyContainsUserCerts=r.ONLY,this.onlyContainsCACerts=r.ONLY,this.indirectCRL=r.ONLY,this.onlyContainsAttributeCerts=r.ONLY,Object.assign(this,e)}};tr.ONLY=!1;b([u({type:kn,context:0,optional:!0})],tr.prototype,"distributionPoint",void 0);b([u({type:h.Boolean,context:1,defaultValue:tr.ONLY,implicit:!0})],tr.prototype,"onlyContainsUserCerts",void 0);b([u({type:h.Boolean,context:2,defaultValue:tr.ONLY,implicit:!0})],tr.prototype,"onlyContainsCACerts",void 0);b([u({type:zc,context:3,optional:!0,implicit:!0})],tr.prototype,"onlySomeReasons",void 0);b([u({type:h.Boolean,context:4,defaultValue:tr.ONLY,implicit:!0})],tr.prototype,"indirectCRL",void 0);b([u({type:h.Boolean,context:5,defaultValue:tr.ONLY,implicit:!0})],tr.prototype,"onlyContainsAttributeCerts",void 0);var lv=`${pe}.21`,Xc;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Xc||(Xc={}));var Yc=class{constructor(e=Xc.unspecified){this.reason=Xc.unspecified,this.reason=e}toJSON(){return Xc[this.reason]}toString(){return this.toJSON()}};b([u({type:h.Enumerated})],Yc.prototype,"reason",void 0);Yc=b([E({type:x.Choice})],Yc);var lm,ap=`${pe}.37`,Zc=lm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,lm.prototype)}};Zc=lm=b([E({type:x.Sequence,itemType:h.ObjectIdentifier})],Zc);var xR=`${ap}.0`,pv=`${Ai}.1`,hv=`${Ai}.2`,dv=`${Ai}.3`,yv=`${Ai}.4`,mv=`${Ai}.8`,gv=`${Ai}.9`;var ER=`${pe}.54`,pm=class{constructor(e=new ArrayBuffer(0)){this.value=e}};b([u({type:h.Integer,converter:we})],pm.prototype,"value",void 0);pm=b([E({type:x.Choice})],pm);var bv=`${pe}.24`,Jc=class{constructor(e){this.value=new Date,e&&(this.value=e)}};b([u({type:h.GeneralizedTime})],Jc.prototype,"value",void 0);Jc=b([E({type:x.Choice})],Jc);var hm,dm=`${pe}.18`,wv=hm=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,hm.prototype)}};wv=hm=b([E({type:x.Sequence})],wv);var cp=`${pe}.15`,Rr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Rr||(Rr={}));var $s=class extends Jr{toJSON(){let e=this.toNumber(),t=[];return e&Rr.cRLSign&&t.push("crlSign"),e&Rr.dataEncipherment&&t.push("dataEncipherment"),e&Rr.decipherOnly&&t.push("decipherOnly"),e&Rr.digitalSignature&&t.push("digitalSignature"),e&Rr.encipherOnly&&t.push("encipherOnly"),e&Rr.keyAgreement&&t.push("keyAgreement"),e&Rr.keyCertSign&&t.push("keyCertSign"),e&Rr.keyEncipherment&&t.push("keyEncipherment"),e&Rr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}};var ym,qR=`${pe}.30`,Fs=class{constructor(e={}){this.base=new ue,this.minimum=0,Object.assign(this,e)}};b([u({type:ue})],Fs.prototype,"base",void 0);b([u({type:h.Integer,context:0,defaultValue:0,implicit:!0})],Fs.prototype,"minimum",void 0);b([u({type:h.Integer,context:1,optional:!0,implicit:!0})],Fs.prototype,"maximum",void 0);var up=ym=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,ym.prototype)}};up=ym=b([E({type:x.Sequence,itemType:Fs})],up);var fp=class{constructor(e={}){Object.assign(this,e)}};b([u({type:up,context:0,optional:!0,implicit:!0})],fp.prototype,"permittedSubtrees",void 0);b([u({type:up,context:1,optional:!0,implicit:!0})],fp.prototype,"excludedSubtrees",void 0);var JR=`${pe}.36`,lp=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.Integer,context:0,implicit:!0,optional:!0,converter:we})],lp.prototype,"requireExplicitPolicy",void 0);b([u({type:h.Integer,context:1,implicit:!0,optional:!0,converter:we})],lp.prototype,"inhibitPolicyMapping",void 0);var mm,nj=`${pe}.33`,Qc=class{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],Qc.prototype,"issuerDomainPolicy",void 0);b([u({type:h.ObjectIdentifier})],Qc.prototype,"subjectDomainPolicy",void 0);var xv=mm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,mm.prototype)}};xv=mm=b([E({type:x.Sequence,itemType:Qc})],xv);var gm,bm=`${pe}.17`,pp=gm=class extends Fe{constructor(e){super(e),Object.setPrototypeOf(this,gm.prototype)}};pp=gm=b([E({type:x.Sequence})],pp);var xt=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};b([u({type:h.ObjectIdentifier})],xt.prototype,"type",void 0);b([u({type:h.Any,repeated:"set"})],xt.prototype,"values",void 0);var wm,wj=`${pe}.9`,vv=wm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,wm.prototype)}};vv=wm=b([E({type:x.Sequence,itemType:xt})],vv);var xm=`${pe}.14`,qt=class extends Ci{};var Ij=`${pe}.16`,hp=class{constructor(e={}){Object.assign(this,e)}};b([u({type:h.GeneralizedTime,context:0,implicit:!0,optional:!0})],hp.prototype,"notBefore",void 0);b([u({type:h.GeneralizedTime,context:1,implicit:!0,optional:!0})],hp.prototype,"notAfter",void 0);var eu;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(eu||(eu={}));var dp=class extends Jr{toJSON(){let e=[],t=this.toNumber();return t&eu.pKIXCertificate&&e.push("pKIXCertificate"),t&eu.newExtensions&&e.push("newExtensions"),t&eu.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}},yp=class{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new dp,Object.assign(this,e)}};b([u({type:h.GeneralString})],yp.prototype,"entrustVers",void 0);b([u({type:dp})],yp.prototype,"entrustInfoFlags",void 0);var vm,Lj=`${vo}.11`,_v=vm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,vm.prototype)}};_v=vm=b([E({type:x.Sequence,itemType:Pn})],_v);var Sv=Hr(An()),K=class r{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof r&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&Sv.isEqual(e.parameters,this.parameters)||e.parameters===this.parameters)}};b([u({type:h.ObjectIdentifier})],K.prototype,"algorithm",void 0);b([u({type:h.Any,optional:!0})],K.prototype,"parameters",void 0);var vt=class{constructor(e={}){this.algorithm=new K,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:K})],vt.prototype,"algorithm",void 0);b([u({type:h.BitString})],vt.prototype,"subjectPublicKey",void 0);var Qe=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||e instanceof Date){let t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};b([u({type:h.UTCTime})],Qe.prototype,"utcTime",void 0);b([u({type:h.GeneralizedTime})],Qe.prototype,"generalTime",void 0);Qe=b([E({type:x.Choice})],Qe);var Dn=class{constructor(e){this.notBefore=new Qe(new Date),this.notAfter=new Qe(new Date),e&&(this.notBefore=new Qe(e.notBefore),this.notAfter=new Qe(e.notAfter))}};b([u({type:Qe})],Dn.prototype,"notBefore",void 0);b([u({type:Qe})],Dn.prototype,"notAfter",void 0);var _m,_t=class r{constructor(e={}){this.extnID="",this.critical=r.CRITICAL,this.extnValue=new ae,Object.assign(this,e)}};_t.CRITICAL=!1;b([u({type:h.ObjectIdentifier})],_t.prototype,"extnID",void 0);b([u({type:h.Boolean,defaultValue:_t.CRITICAL})],_t.prototype,"critical",void 0);b([u({type:ae})],_t.prototype,"extnValue",void 0);var rr=_m=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,_m.prototype)}};rr=_m=b([E({type:x.Sequence,itemType:_t})],rr);var tn;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(tn||(tn={}));var St=class{constructor(e={}){this.version=tn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new K,this.issuer=new je,this.validity=new Dn,this.subject=new je,this.subjectPublicKeyInfo=new vt,Object.assign(this,e)}};b([u({type:h.Integer,context:0,defaultValue:tn.v1})],St.prototype,"version",void 0);b([u({type:h.Integer,converter:we})],St.prototype,"serialNumber",void 0);b([u({type:K})],St.prototype,"signature",void 0);b([u({type:je})],St.prototype,"issuer",void 0);b([u({type:Dn})],St.prototype,"validity",void 0);b([u({type:je})],St.prototype,"subject",void 0);b([u({type:vt})],St.prototype,"subjectPublicKeyInfo",void 0);b([u({type:h.BitString,context:1,implicit:!0,optional:!0})],St.prototype,"issuerUniqueID",void 0);b([u({type:h.BitString,context:2,implicit:!0,optional:!0})],St.prototype,"subjectUniqueID",void 0);b([u({type:rr,context:3,optional:!0})],St.prototype,"extensions",void 0);var hr=class{constructor(e={}){this.tbsCertificate=new St,this.signatureAlgorithm=new K,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:St,raw:!0})],hr.prototype,"tbsCertificate",void 0);b([u({type:K})],hr.prototype,"signatureAlgorithm",void 0);b([u({type:h.BitString})],hr.prototype,"signatureValue",void 0);var Oi=class{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Qe,Object.assign(this,e)}};b([u({type:h.Integer,converter:we})],Oi.prototype,"userCertificate",void 0);b([u({type:Qe})],Oi.prototype,"revocationDate",void 0);b([u({type:_t,optional:!0,repeated:"sequence"})],Oi.prototype,"crlEntryExtensions",void 0);var nr=class{constructor(e={}){this.signature=new K,this.issuer=new je,this.thisUpdate=new Qe,Object.assign(this,e)}};b([u({type:h.Integer,optional:!0})],nr.prototype,"version",void 0);b([u({type:K})],nr.prototype,"signature",void 0);b([u({type:je})],nr.prototype,"issuer",void 0);b([u({type:Qe})],nr.prototype,"thisUpdate",void 0);b([u({type:Qe,optional:!0})],nr.prototype,"nextUpdate",void 0);b([u({type:Oi,repeated:"sequence",optional:!0})],nr.prototype,"revokedCertificates",void 0);b([u({type:_t,optional:!0,context:0,repeated:"sequence"})],nr.prototype,"crlExtensions",void 0);var Bi=class{constructor(e={}){this.tbsCertList=new nr,this.signatureAlgorithm=new K,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};b([u({type:nr,raw:!0})],Bi.prototype,"tbsCertList",void 0);b([u({type:K})],Bi.prototype,"signatureAlgorithm",void 0);b([u({type:h.BitString})],Bi.prototype,"signature",void 0);var V=Hr(An());function tu(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}function de(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)}function We(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t}function T(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var jr=class{constructor(e={}){this.issuer=new je,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:je})],jr.prototype,"issuer",void 0);T([u({type:h.Integer,converter:we})],jr.prototype,"serialNumber",void 0);var Pi=class{constructor(e={}){Object.assign(this,e)}};T([u({type:qt,context:0,implicit:!0})],Pi.prototype,"subjectKeyIdentifier",void 0);T([u({type:jr})],Pi.prototype,"issuerAndSerialNumber",void 0);Pi=T([E({type:x.Choice})],Pi);var At;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(At||(At={}));var Ni=class extends K{};Ni=T([E({type:x.Sequence})],Ni);var ru=class extends K{};ru=T([E({type:x.Sequence})],ru);var Gt=class extends K{};Gt=T([E({type:x.Sequence})],Gt);var nu=class extends K{};nu=T([E({type:x.Sequence})],nu);var Ev=class extends K{};Ev=T([E({type:x.Sequence})],Ev);var mp=class extends K{};mp=T([E({type:x.Sequence})],mp);var Lr=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Lr.prototype,"attrType",void 0);T([u({type:h.Any,repeated:"set"})],Lr.prototype,"attrValues",void 0);var Sm,zt=class{constructor(e={}){this.version=At.v0,this.sid=new Pi,this.digestAlgorithm=new Ni,this.signatureAlgorithm=new ru,this.signature=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],zt.prototype,"version",void 0);T([u({type:Pi})],zt.prototype,"sid",void 0);T([u({type:Ni})],zt.prototype,"digestAlgorithm",void 0);T([u({type:Lr,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],zt.prototype,"signedAttrs",void 0);T([u({type:ru})],zt.prototype,"signatureAlgorithm",void 0);T([u({type:ae})],zt.prototype,"signature",void 0);T([u({type:Lr,repeated:"set",context:1,implicit:!0,optional:!0})],zt.prototype,"unsignedAttrs",void 0);var ou=Sm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Sm.prototype)}};ou=Sm=T([E({type:x.Set,itemType:zt})],ou);var Cv=class extends Qe{};Cv=T([E({type:x.Choice})],Cv);var Tv=class extends zt{};Tv=T([E({type:x.Sequence})],Tv);function G(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var iu=class{constructor(e={}){this.acIssuer=new ue,this.acSerial=0,this.attrs=[],Object.assign(this,e)}};G([u({type:ue})],iu.prototype,"acIssuer",void 0);G([u({type:h.Integer})],iu.prototype,"acSerial",void 0);G([u({type:xt,repeated:"sequence"})],iu.prototype,"attrs",void 0);var Am,su=Am=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Am.prototype)}};su=Am=G([E({type:x.Sequence,itemType:h.ObjectIdentifier})],su);var Ws=class{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}};G([u({type:h.Integer,optional:!0})],Ws.prototype,"pathLenConstraint",void 0);G([u({type:su,implicit:!0,context:0,optional:!0})],Ws.prototype,"permittedAttrs",void 0);G([u({type:su,implicit:!0,context:1,optional:!0})],Ws.prototype,"excludedAttrs",void 0);G([u({type:h.Boolean,defaultValue:!0})],Ws.prototype,"permitUnSpecified",void 0);var dr=class{constructor(e={}){this.issuer=new Fe,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:Fe})],dr.prototype,"issuer",void 0);G([u({type:h.Integer,converter:we})],dr.prototype,"serial",void 0);G([u({type:h.BitString,optional:!0})],dr.prototype,"issuerUID",void 0);var Em;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(Em||(Em={}));var yr=class{constructor(e={}){this.digestedObjectType=Em.publicKey,this.digestAlgorithm=new K,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:h.Enumerated})],yr.prototype,"digestedObjectType",void 0);G([u({type:h.ObjectIdentifier,optional:!0})],yr.prototype,"otherObjectTypeID",void 0);G([u({type:K})],yr.prototype,"digestAlgorithm",void 0);G([u({type:h.BitString})],yr.prototype,"objectDigest",void 0);var ki=class{constructor(e={}){Object.assign(this,e)}};G([u({type:Fe,optional:!0})],ki.prototype,"issuerName",void 0);G([u({type:dr,context:0,implicit:!0,optional:!0})],ki.prototype,"baseCertificateID",void 0);G([u({type:yr,context:1,implicit:!0,optional:!0})],ki.prototype,"objectDigestInfo",void 0);var Di=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ue,repeated:"sequence"})],Di.prototype,"v1Form",void 0);G([u({type:ki,context:0,implicit:!0})],Di.prototype,"v2Form",void 0);Di=G([E({type:x.Choice})],Di);var Ri=class{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}};G([u({type:h.GeneralizedTime})],Ri.prototype,"notBeforeTime",void 0);G([u({type:h.GeneralizedTime})],Ri.prototype,"notAfterTime",void 0);var So=class{constructor(e={}){Object.assign(this,e)}};G([u({type:dr,implicit:!0,context:0,optional:!0})],So.prototype,"baseCertificateID",void 0);G([u({type:Fe,implicit:!0,context:1,optional:!0})],So.prototype,"entityName",void 0);G([u({type:yr,implicit:!0,context:2,optional:!0})],So.prototype,"objectDigestInfo",void 0);var Cm;(function(r){r[r.v2=1]="v2"})(Cm||(Cm={}));var Xt=class{constructor(e={}){this.version=Cm.v2,this.holder=new So,this.issuer=new Di,this.signature=new K,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Ri,this.attributes=[],Object.assign(this,e)}};G([u({type:h.Integer})],Xt.prototype,"version",void 0);G([u({type:So})],Xt.prototype,"holder",void 0);G([u({type:Di})],Xt.prototype,"issuer",void 0);G([u({type:K})],Xt.prototype,"signature",void 0);G([u({type:h.Integer,converter:we})],Xt.prototype,"serialNumber",void 0);G([u({type:Ri})],Xt.prototype,"attrCertValidityPeriod",void 0);G([u({type:xt,repeated:"sequence"})],Xt.prototype,"attributes",void 0);G([u({type:h.BitString,optional:!0})],Xt.prototype,"issuerUniqueID",void 0);G([u({type:rr,optional:!0})],Xt.prototype,"extensions",void 0);var ji=class{constructor(e={}){this.acinfo=new Xt,this.signatureAlgorithm=new K,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:Xt})],ji.prototype,"acinfo",void 0);G([u({type:K})],ji.prototype,"signatureAlgorithm",void 0);G([u({type:h.BitString})],ji.prototype,"signatureValue",void 0);var au;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(au||(au={}));var qs=class extends Jr{};var Gs=class{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}};G([u({type:h.ObjectIdentifier,implicit:!0,context:0})],Gs.prototype,"type",void 0);G([u({type:h.Any,implicit:!0,context:1})],Gs.prototype,"value",void 0);var cu=class{constructor(e={}){this.policyId="",this.classList=new qs(au.unclassified),Object.assign(this,e)}};G([u({type:h.ObjectIdentifier})],cu.prototype,"policyId",void 0);G([u({type:qs,defaultValue:new qs(au.unclassified)})],cu.prototype,"classList",void 0);G([u({type:Gs,repeated:"set"})],cu.prototype,"securityCategories",void 0);var zs=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ae})],zs.prototype,"cotets",void 0);G([u({type:h.ObjectIdentifier})],zs.prototype,"oid",void 0);G([u({type:h.Utf8String})],zs.prototype,"string",void 0);var gp=class{constructor(e={}){this.values=[],Object.assign(this,e)}};G([u({type:Fe,implicit:!0,context:0,optional:!0})],gp.prototype,"policyAuthority",void 0);G([u({type:zs,repeated:"sequence"})],gp.prototype,"values",void 0);var x9=`${vo}.4`,v9=`${vo}.6`,_9=`${vo}.10`,S9=`${pe}.55`,uu=`${xo}.10`,A9=`${uu}.1`,E9=`${uu}.2`,C9=`${uu}.3`,T9=`${uu}.4`,I9=`${uu}.6`,Tm="2.5.4",O9=`${Tm}.72`;var Im,Xs=class{constructor(e={}){this.targetCertificate=new dr,Object.assign(this,e)}};G([u({type:dr})],Xs.prototype,"targetCertificate",void 0);G([u({type:ue,optional:!0})],Xs.prototype,"targetName",void 0);G([u({type:yr,optional:!0})],Xs.prototype,"certDigestInfo",void 0);var Ys=class{constructor(e={}){Object.assign(this,e)}};G([u({type:ue,context:0,implicit:!0})],Ys.prototype,"targetName",void 0);G([u({type:ue,context:1,implicit:!0})],Ys.prototype,"targetGroup",void 0);G([u({type:Xs,context:2,implicit:!0})],Ys.prototype,"targetCert",void 0);Ys=G([E({type:x.Choice})],Ys);var bp=Im=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Im.prototype)}};bp=Im=G([E({type:x.Sequence,itemType:Ys})],bp);var Om,Iv=Om=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Om.prototype)}};Iv=Om=G([E({type:x.Sequence,itemType:bp})],Iv);var wp=class{constructor(e={}){Object.assign(this,e)}};G([u({type:Fe,implicit:!0,context:0,optional:!0})],wp.prototype,"roleAuthority",void 0);G([u({type:ue,implicit:!0,context:1})],wp.prototype,"roleName",void 0);var fu=class{constructor(e={}){this.service=new ue,this.ident=new ue,Object.assign(this,e)}};G([u({type:ue})],fu.prototype,"service",void 0);G([u({type:ue})],fu.prototype,"ident",void 0);G([u({type:ae,optional:!0})],fu.prototype,"authInfo",void 0);var Bm,lu=class{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],lu.prototype,"otherCertFormat",void 0);T([u({type:h.Any})],lu.prototype,"otherCert",void 0);var Li=class{constructor(e={}){Object.assign(this,e)}};T([u({type:hr})],Li.prototype,"certificate",void 0);T([u({type:ji,context:2,implicit:!0})],Li.prototype,"v2AttrCert",void 0);T([u({type:lu,context:3,implicit:!0})],Li.prototype,"other",void 0);Li=T([E({type:x.Choice})],Li);var Mi=Bm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Bm.prototype)}};Mi=Bm=T([E({type:x.Set,itemType:Li})],Mi);var mr=class{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],mr.prototype,"contentType",void 0);T([u({type:h.Any,context:0})],mr.prototype,"content",void 0);var Zs=class{constructor(e={}){Object.assign(this,e)}};T([u({type:ae})],Zs.prototype,"single",void 0);T([u({type:h.Any})],Zs.prototype,"any",void 0);Zs=T([E({type:x.Choice})],Zs);var Ui=class{constructor(e={}){this.eContentType="",Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Ui.prototype,"eContentType",void 0);T([u({type:Zs,context:0,optional:!0})],Ui.prototype,"eContent",void 0);var pu=class{constructor(e={}){Object.assign(this,e)}};T([u({type:ae,context:0,implicit:!0,optional:!0})],pu.prototype,"value",void 0);T([u({type:ae,converter:nv,context:0,implicit:!0,optional:!0,repeated:"sequence"})],pu.prototype,"constructedValue",void 0);pu=T([E({type:x.Choice})],pu);var Ao=class{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new nu,Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Ao.prototype,"contentType",void 0);T([u({type:nu})],Ao.prototype,"contentEncryptionAlgorithm",void 0);T([u({type:pu,optional:!0})],Ao.prototype,"encryptedContent",void 0);var Eo=class{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],Eo.prototype,"keyAttrId",void 0);T([u({type:h.Any,optional:!0})],Eo.prototype,"keyAttr",void 0);var Pm,Js=class{constructor(e={}){this.subjectKeyIdentifier=new qt,Object.assign(this,e)}};T([u({type:qt})],Js.prototype,"subjectKeyIdentifier",void 0);T([u({type:h.GeneralizedTime,optional:!0})],Js.prototype,"date",void 0);T([u({type:Eo,optional:!0})],Js.prototype,"other",void 0);var Qs=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Js,context:0,implicit:!0,optional:!0})],Qs.prototype,"rKeyId",void 0);T([u({type:jr,optional:!0})],Qs.prototype,"issuerAndSerialNumber",void 0);Qs=T([E({type:x.Choice})],Qs);var hu=class{constructor(e={}){this.rid=new Qs,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:Qs})],hu.prototype,"rid",void 0);T([u({type:ae})],hu.prototype,"encryptedKey",void 0);var xp=Pm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Pm.prototype)}};xp=Pm=T([E({type:x.Sequence,itemType:hu})],xp);var du=class{constructor(e={}){this.algorithm=new K,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:K})],du.prototype,"algorithm",void 0);T([u({type:h.BitString})],du.prototype,"publicKey",void 0);var Ki=class{constructor(e={}){Object.assign(this,e)}};T([u({type:qt,context:0,implicit:!0,optional:!0})],Ki.prototype,"subjectKeyIdentifier",void 0);T([u({type:du,context:1,implicit:!0,optional:!0})],Ki.prototype,"originatorKey",void 0);T([u({type:jr,optional:!0})],Ki.prototype,"issuerAndSerialNumber",void 0);Ki=T([E({type:x.Choice})],Ki);var Rn=class{constructor(e={}){this.version=At.v3,this.originator=new Ki,this.keyEncryptionAlgorithm=new Gt,this.recipientEncryptedKeys=new xp,Object.assign(this,e)}};T([u({type:h.Integer})],Rn.prototype,"version",void 0);T([u({type:Ki,context:0})],Rn.prototype,"originator",void 0);T([u({type:ae,context:1,optional:!0})],Rn.prototype,"ukm",void 0);T([u({type:Gt})],Rn.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:xp})],Rn.prototype,"recipientEncryptedKeys",void 0);var ea=class{constructor(e={}){Object.assign(this,e)}};T([u({type:qt,context:0,implicit:!0})],ea.prototype,"subjectKeyIdentifier",void 0);T([u({type:jr})],ea.prototype,"issuerAndSerialNumber",void 0);ea=T([E({type:x.Choice})],ea);var Co=class{constructor(e={}){this.version=At.v0,this.rid=new ea,this.keyEncryptionAlgorithm=new Gt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],Co.prototype,"version",void 0);T([u({type:ea})],Co.prototype,"rid",void 0);T([u({type:Gt})],Co.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],Co.prototype,"encryptedKey",void 0);var Hi=class{constructor(e={}){this.keyIdentifier=new ae,Object.assign(this,e)}};T([u({type:ae})],Hi.prototype,"keyIdentifier",void 0);T([u({type:h.GeneralizedTime,optional:!0})],Hi.prototype,"date",void 0);T([u({type:Eo,optional:!0})],Hi.prototype,"other",void 0);var To=class{constructor(e={}){this.version=At.v4,this.kekid=new Hi,this.keyEncryptionAlgorithm=new Gt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],To.prototype,"version",void 0);T([u({type:Hi})],To.prototype,"kekid",void 0);T([u({type:Gt})],To.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],To.prototype,"encryptedKey",void 0);var Io=class{constructor(e={}){this.version=At.v0,this.keyEncryptionAlgorithm=new Gt,this.encryptedKey=new ae,Object.assign(this,e)}};T([u({type:h.Integer})],Io.prototype,"version",void 0);T([u({type:mp,context:0,optional:!0})],Io.prototype,"keyDerivationAlgorithm",void 0);T([u({type:Gt})],Io.prototype,"keyEncryptionAlgorithm",void 0);T([u({type:ae})],Io.prototype,"encryptedKey",void 0);var yu=class{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],yu.prototype,"oriType",void 0);T([u({type:h.Any})],yu.prototype,"oriValue",void 0);var jn=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Co,optional:!0})],jn.prototype,"ktri",void 0);T([u({type:Rn,context:1,implicit:!0,optional:!0})],jn.prototype,"kari",void 0);T([u({type:To,context:2,implicit:!0,optional:!0})],jn.prototype,"kekri",void 0);T([u({type:Io,context:3,implicit:!0,optional:!0})],jn.prototype,"pwri",void 0);T([u({type:yu,context:4,implicit:!0,optional:!0})],jn.prototype,"ori",void 0);jn=T([E({type:x.Choice})],jn);var Nm,mu=Nm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Nm.prototype)}};mu=Nm=T([E({type:x.Set,itemType:jn})],mu);var km,Ov=`${xo}.16`,IH=`${Ov}.2`,OH=`${Ov}.4`,ta=class{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}};T([u({type:h.ObjectIdentifier})],ta.prototype,"otherRevInfoFormat",void 0);T([u({type:h.Any})],ta.prototype,"otherRevInfo",void 0);var vp=class{constructor(e={}){this.other=new ta,Object.assign(this,e)}};T([u({type:ta,context:1,implicit:!0})],vp.prototype,"other",void 0);vp=T([E({type:x.Choice})],vp);var ra=km=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,km.prototype)}};ra=km=T([E({type:x.Set,itemType:vp})],ra);var na=class{constructor(e={}){Object.assign(this,e)}};T([u({type:Mi,context:0,implicit:!0,optional:!0})],na.prototype,"certs",void 0);T([u({type:ra,context:1,implicit:!0,optional:!0})],na.prototype,"crls",void 0);var Dm,Rm=Dm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Dm.prototype)}};Rm=Dm=T([E({type:x.Set,itemType:Lr})],Rm);var Vi=class{constructor(e={}){this.version=At.v0,this.recipientInfos=new mu,this.encryptedContentInfo=new Ao,Object.assign(this,e)}};T([u({type:h.Integer})],Vi.prototype,"version",void 0);T([u({type:na,context:0,implicit:!0,optional:!0})],Vi.prototype,"originatorInfo",void 0);T([u({type:mu})],Vi.prototype,"recipientInfos",void 0);T([u({type:Ao})],Vi.prototype,"encryptedContentInfo",void 0);T([u({type:Rm,context:1,implicit:!0,optional:!0})],Vi.prototype,"unprotectedAttrs",void 0);var Bv="1.2.840.113549.1.7.2";var jm,_p=jm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,jm.prototype)}};_p=jm=T([E({type:x.Set,itemType:Ni})],_p);var Ln=class{constructor(e={}){this.version=At.v0,this.digestAlgorithms=new _p,this.encapContentInfo=new Ui,this.signerInfos=new ou,Object.assign(this,e)}};T([u({type:h.Integer})],Ln.prototype,"version",void 0);T([u({type:_p})],Ln.prototype,"digestAlgorithms",void 0);T([u({type:Ui})],Ln.prototype,"encapContentInfo",void 0);T([u({type:Mi,context:0,implicit:!0,optional:!0})],Ln.prototype,"certificates",void 0);T([u({type:ra,context:1,implicit:!0,optional:!0})],Ln.prototype,"crls",void 0);T([u({type:ou})],Ln.prototype,"signerInfos",void 0);var $i="1.2.840.10045.2.1";var gu="1.2.840.10045.4.1",Sp="1.2.840.10045.4.3.1",bu="1.2.840.10045.4.3.2",wu="1.2.840.10045.4.3.3",xu="1.2.840.10045.4.3.4";var Lm="1.2.840.10045.3.1.7";var Mm="1.3.132.0.34";var Um="1.3.132.0.35";function vu(r){return new K({algorithm:r})}var Nv=vu(gu),EV=vu(Sp),kv=vu(bu),Dv=vu(wu),Rv=vu(xu);function Le(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var _u=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.ObjectIdentifier})],_u.prototype,"fieldType",void 0);Le([u({type:h.Any})],_u.prototype,"parameters",void 0);_u=Le([E({type:x.Sequence})],_u);var Km=class extends ae{};var oa=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.OctetString})],oa.prototype,"a",void 0);Le([u({type:h.OctetString})],oa.prototype,"b",void 0);Le([u({type:h.BitString,optional:!0})],oa.prototype,"seed",void 0);oa=Le([E({type:x.Sequence})],oa);var Hm;(function(r){r[r.ecpVer1=1]="ecpVer1"})(Hm||(Hm={}));var rn=class{constructor(e={}){this.version=Hm.ecpVer1,Object.assign(this,e)}};Le([u({type:h.Integer})],rn.prototype,"version",void 0);Le([u({type:_u})],rn.prototype,"fieldID",void 0);Le([u({type:oa})],rn.prototype,"curve",void 0);Le([u({type:Km})],rn.prototype,"base",void 0);Le([u({type:h.Integer,converter:we})],rn.prototype,"order",void 0);Le([u({type:h.Integer,optional:!0})],rn.prototype,"cofactor",void 0);rn=Le([E({type:x.Sequence})],rn);var nn=class{constructor(e={}){Object.assign(this,e)}};Le([u({type:h.ObjectIdentifier})],nn.prototype,"namedCurve",void 0);Le([u({type:h.Null})],nn.prototype,"implicitCurve",void 0);Le([u({type:rn})],nn.prototype,"specifiedCurve",void 0);nn=Le([E({type:x.Choice})],nn);var ia=class{constructor(e={}){this.version=1,this.privateKey=new ae,Object.assign(this,e)}};Le([u({type:h.Integer})],ia.prototype,"version",void 0);Le([u({type:ae})],ia.prototype,"privateKey",void 0);Le([u({type:nn,context:0,optional:!0})],ia.prototype,"parameters",void 0);Le([u({type:h.BitString,context:1,optional:!0})],ia.prototype,"publicKey",void 0);var Fi=class{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}};Le([u({type:h.Integer,converter:we})],Fi.prototype,"r",void 0);Le([u({type:h.Integer,converter:we})],Fi.prototype,"s",void 0);function Pe(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Yt="1.2.840.113549.1.1",on=`${Yt}.1`,jv=`${Yt}.7`,Lv=`${Yt}.9`,Oo=`${Yt}.10`,Mv=`${Yt}.2`,Uv=`${Yt}.4`,sa=`${Yt}.5`,Kv=`${Yt}.14`;var Ap=`${Yt}.11`,aa=`${Yt}.12`,ca=`${Yt}.13`,Vm=`${Yt}.15`,$m=`${Yt}.16`,Wi="1.3.14.3.2.26",Ep="2.16.840.1.101.3.4.2.4",qi="2.16.840.1.101.3.4.2.1",Gi="2.16.840.1.101.3.4.2.2",zi="2.16.840.1.101.3.4.2.3",Hv="2.16.840.1.101.3.4.2.5",Vv="2.16.840.1.101.3.4.2.6",$v="1.2.840.113549.2.2",Fv="1.2.840.113549.2.5",Bo=`${Yt}.8`;function lt(r){return new K({algorithm:r,parameters:null})}var t$=lt($v),r$=lt(Fv),Mn=lt(Wi),n$=lt(Ep),o$=lt(qi),i$=lt(Gi),s$=lt(zi),a$=lt(Hv),c$=lt(Vv),Cp=new K({algorithm:Bo,parameters:W.serialize(Mn)}),Fm=new K({algorithm:Lv,parameters:W.serialize(Hs.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),u$=lt(on),f$=lt(Mv),l$=lt(Uv),p$=lt(sa),h$=lt(Vm),d$=lt($m),y$=lt(aa),m$=lt(ca),g$=lt(Vm),b$=lt($m);var ua=class{constructor(e={}){this.hashAlgorithm=new K(Mn),this.maskGenAlgorithm=new K({algorithm:Bo,parameters:W.serialize(Mn)}),this.pSourceAlgorithm=new K(Fm),Object.assign(this,e)}};Pe([u({type:K,context:0,defaultValue:Mn})],ua.prototype,"hashAlgorithm",void 0);Pe([u({type:K,context:1,defaultValue:Cp})],ua.prototype,"maskGenAlgorithm",void 0);Pe([u({type:K,context:2,defaultValue:Fm})],ua.prototype,"pSourceAlgorithm",void 0);var E$=new K({algorithm:jv,parameters:W.serialize(new ua)});var sn=class{constructor(e={}){this.hashAlgorithm=new K(Mn),this.maskGenAlgorithm=new K({algorithm:Bo,parameters:W.serialize(Mn)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}};Pe([u({type:K,context:0,defaultValue:Mn})],sn.prototype,"hashAlgorithm",void 0);Pe([u({type:K,context:1,defaultValue:Cp})],sn.prototype,"maskGenAlgorithm",void 0);Pe([u({type:h.Integer,context:2,defaultValue:20})],sn.prototype,"saltLength",void 0);Pe([u({type:h.Integer,context:3,defaultValue:1})],sn.prototype,"trailerField",void 0);var N$=new K({algorithm:Oo,parameters:W.serialize(new sn)});var Xi=class{constructor(e={}){this.digestAlgorithm=new K,this.digest=new ae,Object.assign(this,e)}};Pe([u({type:K})],Xi.prototype,"digestAlgorithm",void 0);Pe([u({type:ae})],Xi.prototype,"digest",void 0);var Wm,fa=class{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer,converter:we})],fa.prototype,"prime",void 0);Pe([u({type:h.Integer,converter:we})],fa.prototype,"exponent",void 0);Pe([u({type:h.Integer,converter:we})],fa.prototype,"coefficient",void 0);var Tp=Wm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Wm.prototype)}};Tp=Wm=Pe([E({type:x.Sequence,itemType:fa})],Tp);var gr=class{constructor(e={}){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer})],gr.prototype,"version",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"modulus",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"publicExponent",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"privateExponent",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"prime1",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"prime2",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"exponent1",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"exponent2",void 0);Pe([u({type:h.Integer,converter:we})],gr.prototype,"coefficient",void 0);Pe([u({type:Tp,optional:!0})],gr.prototype,"otherPrimeInfos",void 0);var la=class{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}};Pe([u({type:h.Integer,converter:we})],la.prototype,"modulus",void 0);Pe([u({type:h.Integer,converter:we})],la.prototype,"publicExponent",void 0);var qm;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(qm||(qm={}));var Et=qm;var p1=Hr(l1(),1),{__extends:ha,__assign:u7,__rest:uT,__decorate:f7,__param:l7,__metadata:p7,__awaiter:h1,__generator:d1,__exportStar:h7,__createBinding:d7,__values:Su,__read:Au,__spread:Mr,__spreadArrays:y7,__await:m7,__asyncGenerator:g7,__asyncDelegator:b7,__asyncValues:w7,__makeTemplateObject:x7,__importStar:v7,__importDefault:_7,__classPrivateFieldGet:S7,__classPrivateFieldSet:A7}=p1.default;var fT="injectionTokens";function zm(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(fT,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Eu(r){return!!r.useClass}function da(r){return!!r.useFactory}var Bp=(function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},o=!1,i,s=function(){return o||(i=e(t.wrap()),o=!0),i};return new Proxy(n,this.createHandler(s))},r.prototype.createHandler=function(e){var t={},n=function(o){t[o]=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];i[0]=e();var a=Reflect[o];return a.apply(void 0,Mr(i))}};return this.reflectMethods.forEach(n),t},r})();function Po(r){return typeof r=="string"||typeof r=="symbol"}function Xm(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Pp(r){return typeof r=="object"&&"token"in r&&"transform"in r}function y1(r){return typeof r=="function"||r instanceof Bp}function Yi(r){return!!r.useToken}function Zi(r){return r.useValue!=null}function m1(r){return Eu(r)||Zi(r)||Yi(r)||da(r)}var lT=(function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r})(),Cu=lT;var pT=(function(r){ha(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Cu),g1=pT;var hT=(function(){function r(){this.scopedResolutions=new Map}return r})(),Tu=hT;function dT(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function yT(r,e,t){return t===void 0&&(t=" "),Mr([r],e.message.split(`
|
|
7
7
|
`).map(function(n){return t+n})).join(`
|
|
8
|
-
`)}function qm(r,e,t){var n=Su(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),o=n[1],i=o===void 0?null:o,s=sT(i,e);return aT("Cannot inject the dependency "+s+' of "'+r.name+'" constructor. Reason:',t)}function p1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var cT=(function(r){pa(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Eu);var uT=(function(r){pa(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Eu);var fT=(function(){function r(){this.preResolution=new cT,this.postResolution=new uT}return r})(),h1=fT;var Gm=new Map,lT=(function(){function r(e){this.parent=e,this._registry=new l1,this.interceptors=new h1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Ct.Transient}),this.ensureNotDisposed();var o;if(f1(t)?o=t:o={useClass:t},Xi(o))for(var i=[e],s=o;s!=null;){var a=s.useToken;if(i.includes(a))throw new Error("Token registration cycle detected! "+Mr(i,[a]).join(" -> "));i.push(a);var c=this._registry.get(a);c&&Xi(c.provider)?s=c.provider:s=null}if((n.lifecycle===Ct.Singleton||n.lifecycle==Ct.ContainerScoped||n.lifecycle==Ct.ResolutionScoped)&&(Zi(o)||ha(o)))throw new Error('Cannot use lifecycle "'+Ct[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:o,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Io(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Io(e)){if(Io(t))return this.register(e,{useToken:t},{lifecycle:Ct.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Ct.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Io(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Ct.Singleton})},r.prototype.resolve=function(e,t,n){t===void 0&&(t=new Cu),n===void 0&&(n=!1),this.ensureNotDisposed();var o=this.getRegistration(e);if(!o&&Io(e)){if(n)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),o){var i=this.resolveRegistration(o,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(u1(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,o;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var s=_u(this.interceptors.preResolution.getAll(e)),a=s.next();!a.done;a=s.next()){var c=a.value;c.options.frequency!="Once"&&i.push(c),c.callback(e,t)}}catch(f){n={error:f}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var o,i;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var a=_u(this.interceptors.postResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var f=c.value;f.options.frequency!="Once"&&s.push(f),f.callback(e,t,n)}}catch(p){o={error:p}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}this.interceptors.postResolution.setAll(e,s)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Ct.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Ct.Singleton,o=e.options.lifecycle===Ct.ContainerScoped,i=n||o,s;return Zi(e.provider)?s=e.provider.useValue:Xi(e.provider)?s=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Au(e.provider)?s=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ha(e.provider)?s=e.provider.useFactory(this):s=this.construct(e.provider,t),e.options.lifecycle===Ct.ResolutionScoped&&t.scopedResolutions.set(e,s),s},r.prototype.resolveAll=function(e,t,n){var o=this;t===void 0&&(t=new Cu),n===void 0&&(n=!1),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Io(e)){if(n)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return o.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=_u(this._registry.entries()),o=n.next();!o.done;o=n.next()){var i=Su(o.value,2),s=i[0],a=i[1];this._registry.setAll(s,a.filter(function(c){return!Zi(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var o=_u(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=Su(i.value,2),a=s[0],c=s[1];c.some(function(f){var p=f.options;return p.lifecycle===Ct.ContainerScoped})&&n._registry.setAll(a,c.map(function(f){return f.options.lifecycle===Ct.ContainerScoped?{provider:f.provider,options:f.options}:f}))}}catch(f){e={error:f}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return a1(this,void 0,void 0,function(){var e;return c1(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var o=n.dispose();o&&e.push(o)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof Bp)return e.createProxy(function(i){return n.resolve(i,t)});var o=(function(){var i=Gm.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var s=i.map(n.resolveParams(t,e));return new(e.bind.apply(e,Mr([void 0],s)))})();return p1(o)&&this.disposables.add(o),o},r.prototype.resolveParams=function(e,t){var n=this;return function(o,i){var s,a,c;try{return Wm(o)?Ip(o)?o.multiple?(s=n.resolve(o.transform)).transform.apply(s,Mr([n.resolveAll(o.token,new Cu,o.isOptional)],o.transformArgs)):(a=n.resolve(o.transform)).transform.apply(a,Mr([n.resolve(o.token,e,o.isOptional)],o.transformArgs)):o.multiple?n.resolveAll(o.token,new Cu,o.isOptional):n.resolve(o.token,e,o.isOptional):Ip(o)?(c=n.resolve(o.transform,e)).transform.apply(c,Mr([n.resolve(o.token,e)],o.transformArgs)):n.resolve(o,e)}catch(f){throw new Error(qm(t,i,f))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r})(),Ke=new lT;function pT(r){return function(e){Gm.set(e,Fm(e)),r&&r.token&&(Array.isArray(r.token)?r.token.forEach(function(t){Ke.register(t,e)}):Ke.register(r.token,e))}}var Po=pT;if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);function Oe(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}function Be(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Xm,Yi=class{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}};Be([u({type:h.ObjectIdentifier})],Yi.prototype,"attrId",void 0);Be([u({type:h.Any,repeated:"set"})],Yi.prototype,"attrValues",void 0);var d1=Xm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Xm.prototype)}};d1=Xm=Be([E({type:x.Sequence,itemType:Yi})],d1);var Zm,y1=Zm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Zm.prototype)}};y1=Zm=Be([E({type:x.Sequence,itemType:gr})],y1);var hT="1.2.840.113549",dT=`${hT}.1`,m1=`${dT}.12`,da=`${m1}.1`,CW=`${da}.1`,TW=`${da}.2`,OW=`${da}.3`,BW=`${da}.4`,IW=`${da}.5`,PW=`${da}.6`,Ji=`${m1}.10.1`;var DW=`${Ji}.1`,RW=`${Ji}.2`,jW=`${Ji}.3`,LW=`${Ji}.4`,UW=`${Ji}.5`,MW=`${Ji}.6`,Pp="1.2.840.113549.1.9";var Np=class{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}};Be([u({type:h.ObjectIdentifier})],Np.prototype,"certId",void 0);Be([u({type:h.Any,context:0})],Np.prototype,"certValue",void 0);var g1=`${Pp}.22`,FW=`${g1}.1`,WW=`${g1}.2`;var kp=class{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}};Be([u({type:h.ObjectIdentifier})],kp.prototype,"crlId",void 0);Be([u({type:h.Any,context:0})],kp.prototype,"crltValue",void 0);var yT=`${Pp}.23`,ZW=`${yT}.1`;function Mn(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Dp=class extends ae{},No=class{constructor(e={}){this.encryptionAlgorithm=new K,this.encryptedData=new Dp,Object.assign(this,e)}};Mn([u({type:K})],No.prototype,"encryptionAlgorithm",void 0);Mn([u({type:Dp})],No.prototype,"encryptedData",void 0);var Ym,Jm;(function(r){r[r.v1=0]="v1"})(Jm||(Jm={}));var Rp=class extends ae{},Qm=Ym=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Ym.prototype)}};Qm=Ym=Mn([E({type:x.Sequence,itemType:vt})],Qm);var ko=class{constructor(e={}){this.version=Jm.v1,this.privateKeyAlgorithm=new K,this.privateKey=new Rp,Object.assign(this,e)}};Mn([u({type:h.Integer})],ko.prototype,"version",void 0);Mn([u({type:K})],ko.prototype,"privateKeyAlgorithm",void 0);Mn([u({type:Rp})],ko.prototype,"privateKey",void 0);Mn([u({type:Qm,implicit:!0,context:0,optional:!0})],ko.prototype,"attributes",void 0);var b1=class extends ko{};b1=Be([E({type:x.Sequence})],b1);var w1=class extends No{};w1=Be([E({type:x.Sequence})],w1);var jp=class{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}};Be([u({type:h.ObjectIdentifier})],jp.prototype,"secretTypeId",void 0);Be([u({type:h.Any,context:0})],jp.prototype,"secretValue",void 0);var Do=class{constructor(e={}){this.mac=new zi,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}};Be([u({type:zi})],Do.prototype,"mac",void 0);Be([u({type:ae})],Do.prototype,"macSalt",void 0);Be([u({type:h.Integer,defaultValue:1})],Do.prototype,"iterations",void 0);var Qi=class{constructor(e={}){this.version=3,this.authSafe=new gr,this.macData=new Do,Object.assign(this,e)}};Be([u({type:h.Integer})],Qi.prototype,"version",void 0);Be([u({type:gr})],Qi.prototype,"authSafe",void 0);Be([u({type:Do,optional:!0})],Qi.prototype,"macData",void 0);var eg,ya=class{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}};Be([u({type:h.ObjectIdentifier})],ya.prototype,"bagId",void 0);Be([u({type:h.Any,context:0})],ya.prototype,"bagValue",void 0);Be([u({type:Yi,repeated:"set",optional:!0})],ya.prototype,"bagAttributes",void 0);var x1=eg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,eg.prototype)}};x1=eg=Be([E({type:x.Sequence,itemType:ya})],x1);var tg,rg,ng,et="1.2.840.113549.1.9",Qq=`${et}.0`,D1=`${et}.24`,Ou=`${et}.25`,R1=`${et}.26`,j1=`${et}.27`,eG=`${D1}.1`,tG=`${D1}.2`,rG=`${et}.1`,nG=`${et}.2`,oG=`${et}.3`,iG=`${et}.4`,sG=`${et}.5`,aG=`${et}.6`,lg=`${et}.7`,cG=`${et}.8`,uG=`${et}.9`,fG=`${et}.13`,Bu=`${et}.14`,lG=`${et}.15`,pG=`${et}.20`,hG=`${et}.21`;var dG=`${Ou}.1`,yG=`${Ou}.2`,mG=`${Ou}.3`,gG=`${Ou}.4`,bG=`${Ou}.5`,Iu="1.3.6.1.5.5.7.9",wG=`${Iu}.1`,xG=`${Iu}.2`,vG=`${Iu}.3`,_G=`${Iu}.4`,SG=`${Iu}.5`,AG=`${R1}.1`,EG=`${R1}.2`,CG=`${j1}.1`,TG=`${j1}.2`,OG=`${et}.16`,BG=`${et}.22`,IG=`${et}.23`,PG=`${Sm}.65`,Lp=class extends st{constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};Oe([u({type:h.IA5String})],Lp.prototype,"ia5String",void 0);Lp=Oe([E({type:x.Choice})],Lp);var v1=class extends gr{};v1=Oe([E({type:x.Sequence})],v1);var _1=class extends Qi{};_1=Oe([E({type:x.Sequence})],_1);var S1=class extends No{};S1=Oe([E({type:x.Sequence})],S1);var og=class{constructor(e=""){this.value=e}toString(){return this.value}};Oe([u({type:h.IA5String})],og.prototype,"value",void 0);og=Oe([E({type:x.Choice})],og);var A1=class extends Lp{};A1=Oe([E({type:x.Choice})],A1);var E1=class extends st{};E1=Oe([E({type:x.Choice})],E1);var ig=class{constructor(e=new Date){this.value=e}};Oe([u({type:h.GeneralizedTime})],ig.prototype,"value",void 0);ig=Oe([E({type:x.Choice})],ig);var C1=class extends st{};C1=Oe([E({type:x.Choice})],C1);var sg=class{constructor(e="M"){this.value=e}toString(){return this.value}};Oe([u({type:h.PrintableString})],sg.prototype,"value",void 0);sg=Oe([E({type:x.Choice})],sg);var Up=class{constructor(e=""){this.value=e}toString(){return this.value}};Oe([u({type:h.PrintableString})],Up.prototype,"value",void 0);Up=Oe([E({type:x.Choice})],Up);var T1=class extends Up{};T1=Oe([E({type:x.Choice})],T1);var O1=class extends st{};O1=Oe([E({type:x.Choice})],O1);var ag=class{constructor(e=""){this.value=e}toString(){return this.value}};Oe([u({type:h.ObjectIdentifier})],ag.prototype,"value",void 0);ag=Oe([E({type:x.Choice})],ag);var B1=class extends Qe{};B1=Oe([E({type:x.Choice})],B1);var cg=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};Oe([u({type:h.Integer})],cg.prototype,"value",void 0);cg=Oe([E({type:x.Choice})],cg);var I1=class extends Xt{};I1=Oe([E({type:x.Sequence})],I1);var Tu=class extends st{};Tu=Oe([E({type:x.Choice})],Tu);var P1=tg=class extends nr{constructor(e){super(e),Object.setPrototypeOf(this,tg.prototype)}};P1=tg=Oe([E({type:x.Sequence})],P1);var N1=rg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,rg.prototype)}};N1=rg=Oe([E({type:x.Set,itemType:Ur})],N1);var ug=class{constructor(e=""){this.value=e}toString(){return this.value}};Oe([u({type:h.BmpString})],ug.prototype,"value",void 0);ug=Oe([E({type:x.Choice})],ug);var fg=class extends K{};fg=Oe([E({type:x.Sequence})],fg);var k1=ng=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,ng.prototype)}};k1=ng=Oe([E({type:x.Sequence,itemType:fg})],k1);function Kr(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var pg,Pu=pg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,pg.prototype)}};Pu=pg=Kr([E({type:x.Sequence,itemType:vt})],Pu);var cn=class{constructor(e={}){this.version=0,this.subject=new je,this.subjectPKInfo=new _t,this.attributes=new Pu,Object.assign(this,e)}};Kr([u({type:h.Integer})],cn.prototype,"version",void 0);Kr([u({type:je})],cn.prototype,"subject",void 0);Kr([u({type:_t})],cn.prototype,"subjectPKInfo",void 0);Kr([u({type:Pu,implicit:!0,context:0})],cn.prototype,"attributes",void 0);var Ro=class{constructor(e={}){this.certificationRequestInfo=new cn,this.signatureAlgorithm=new K,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};Kr([u({type:cn,raw:!0})],Ro.prototype,"certificationRequestInfo",void 0);Kr([u({type:K})],Ro.prototype,"signatureAlgorithm",void 0);Kr([u({type:h.BitString})],Ro.prototype,"signature",void 0);var tf="crypto.algorithm",_g=class{getAlgorithms(){return Ke.resolveAll(tf)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new K({algorithm:e.name});if("parameters"in e){let n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(let n of this.getAlgorithms()){let o=n.toWebAlgorithm(e);if(o)return o}return{name:e.algorithm,parameters:e.parameters}}},es="crypto.algorithmProvider";Ke.registerSingleton(es,_g);var Vp,Qt="1.3.36.3.3.2.8.1.1",L1=`${Qt}.1`,U1=`${Qt}.2`,M1=`${Qt}.3`,K1=`${Qt}.4`,H1=`${Qt}.5`,V1=`${Qt}.6`,$1=`${Qt}.7`,F1=`${Qt}.8`,W1=`${Qt}.9`,q1=`${Qt}.10`,G1=`${Qt}.11`,z1=`${Qt}.12`,X1=`${Qt}.13`,Z1=`${Qt}.14`,Y1="brainpoolP160r1",J1="brainpoolP160t1",Q1="brainpoolP192r1",e_="brainpoolP192t1",t_="brainpoolP224r1",r_="brainpoolP224t1",n_="brainpoolP256r1",o_="brainpoolP256t1",i_="brainpoolP320r1",s_="brainpoolP320t1",a_="brainpoolP384r1",c_="brainpoolP384t1",u_="brainpoolP512r1",f_="brainpoolP512t1",ze="ECDSA",Yu=Vp=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ze.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Cv;case"sha-256":return Tv;case"sha-384":return Ov;case"sha-512":return Bv}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=km;break;case"K-256":t=Vp.SECP256K1;break;case"P-384":t=Dm;break;case"P-521":t=Rm;break;case Y1:t=L1;break;case J1:t=U1;break;case Q1:t=M1;break;case e_:t=K1;break;case t_:t=H1;break;case r_:t=V1;break;case n_:t=$1;break;case o_:t=F1;break;case i_:t=W1;break;case s_:t=q1;break;case a_:t=G1;break;case c_:t=z1;break;case u_:t=X1;break;case f_:t=Z1;break}if(t)return new K({algorithm:Vi,parameters:W.serialize(new on({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case mu:return{name:ze,hash:{name:"SHA-1"}};case gu:return{name:ze,hash:{name:"SHA-256"}};case bu:return{name:ze,hash:{name:"SHA-384"}};case wu:return{name:ze,hash:{name:"SHA-512"}};case Vi:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(W.parse(e.parameters,on).namedCurve){case km:return{name:ze,namedCurve:"P-256"};case Vp.SECP256K1:return{name:ze,namedCurve:"K-256"};case Dm:return{name:ze,namedCurve:"P-384"};case Rm:return{name:ze,namedCurve:"P-521"};case L1:return{name:ze,namedCurve:Y1};case U1:return{name:ze,namedCurve:J1};case M1:return{name:ze,namedCurve:Q1};case K1:return{name:ze,namedCurve:e_};case H1:return{name:ze,namedCurve:t_};case V1:return{name:ze,namedCurve:r_};case $1:return{name:ze,namedCurve:n_};case F1:return{name:ze,namedCurve:o_};case W1:return{name:ze,namedCurve:i_};case q1:return{name:ze,namedCurve:s_};case G1:return{name:ze,namedCurve:a_};case z1:return{name:ze,namedCurve:c_};case X1:return{name:ze,namedCurve:u_};case Z1:return{name:ze,namedCurve:f_}}}}return null}};Yu.SECP256K1="1.3.132.0.10";Yu=Vp=eu([Po()],Yu);Ke.registerSingleton(tf,Yu);var v_=Symbol("name"),__=Symbol("value"),Te=class{constructor(e,t={},n=""){this[v_]=e,this[__]=n;for(let o in t)this[o]=t[o]}};Te.NAME=v_;Te.VALUE=__;var Sg=class{static toTextObject(e){let t=new Te("Algorithm Identifier",{},fn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Vi:{let n=new Yu().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}},fn=class{static toString(e){let t=this.items[e];return t||e}};fn.items={[Fi]:"sha1",[Ap]:"sha224",[Wi]:"sha256",[qi]:"sha384",[Gi]:"sha512",[sn]:"rsaEncryption",[ia]:"sha1WithRSAEncryption",[Dv]:"sha224WithRSAEncryption",[Sp]:"sha256WithRSAEncryption",[sa]:"sha384WithRSAEncryption",[aa]:"sha512WithRSAEncryption",[Vi]:"ecPublicKey",[mu]:"ecdsaWithSHA1",[_p]:"ecdsaWithSHA224",[gu]:"ecdsaWithSHA256",[bu]:"ecdsaWithSHA384",[wu]:"ecdsaWithSHA512",[sv]:"TLS WWW server authentication",[av]:"TLS WWW client authentication",[cv]:"Code Signing",[uv]:"E-mail Protection",[fv]:"Time Stamping",[lv]:"OCSP Signing",[Av]:"Signed Data"};var Hn=class{static serialize(e){return this.serializeObj(e).join(`
|
|
9
|
-
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){let n=[],o=this.pad(t++),i="",s=e[Te.VALUE];s&&(i=` ${s}`),n.push(`${o}${e[Te.NAME]}:${i}`),o=this.pad(t);for(let a in e){if(typeof a=="symbol")continue;let c=e[a],f=a?`${a}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${o}${f}${c}`);else if(c instanceof Date)n.push(`${o}${f}${c.toUTCString()}`);else if(Array.isArray(c))for(let p of c)p[Te.NAME]=a,n.push(...this.serializeObj(p,t));else if(c instanceof Te)c[Te.NAME]=a,n.push(...this.serializeObj(c,t));else if(V.BufferSourceConverter.isBufferSource(c))a?(n.push(`${o}${f}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){let p=c.toTextObject();p[Te.NAME]=a,n.push(...this.serializeObj(p,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),o=V.BufferSourceConverter.toUint8Array(e),i=[];for(let s=0;s<o.length;){let a=[];for(let c=0;c<16&&s<o.length;c++){c===8&&a.push("");let f=o[s++].toString(16).padStart(2,"0");a.push(f)}i.push(`${n}${a.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};Hn.oidSerializer=
|
|
10
|
-
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return W.serialize(this.asn)}async getThumbprint(...e){var t;let n,o="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(o=e[0]||o,n=e[1]||yt.get()):n=e[0]||yt.get(),await n.subtle.digest(o,this.toArrayBuffer())}},
|
|
8
|
+
`)}function Ym(r,e,t){var n=Au(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),o=n[1],i=o===void 0?null:o,s=dT(i,e);return yT("Cannot inject the dependency "+s+' of "'+r.name+'" constructor. Reason:',t)}function b1(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var mT=(function(r){ha(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Cu);var gT=(function(r){ha(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e})(Cu);var bT=(function(){function r(){this.preResolution=new mT,this.postResolution=new gT}return r})(),w1=bT;var Zm=new Map,wT=(function(){function r(e){this.parent=e,this._registry=new g1,this.interceptors=new w1,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:Et.Transient}),this.ensureNotDisposed();var o;if(m1(t)?o=t:o={useClass:t},Yi(o))for(var i=[e],s=o;s!=null;){var a=s.useToken;if(i.includes(a))throw new Error("Token registration cycle detected! "+Mr(i,[a]).join(" -> "));i.push(a);var c=this._registry.get(a);c&&Yi(c.provider)?s=c.provider:s=null}if((n.lifecycle===Et.Singleton||n.lifecycle==Et.ContainerScoped||n.lifecycle==Et.ResolutionScoped)&&(Zi(o)||da(o)))throw new Error('Cannot use lifecycle "'+Et[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:o,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Po(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Po(e)){if(Po(t))return this.register(e,{useToken:t},{lifecycle:Et.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:Et.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Po(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:Et.Singleton})},r.prototype.resolve=function(e,t,n){t===void 0&&(t=new Tu),n===void 0&&(n=!1),this.ensureNotDisposed();var o=this.getRegistration(e);if(!o&&Po(e)){if(n)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),o){var i=this.resolveRegistration(o,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(y1(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,o;if(this.interceptors.preResolution.has(e)){var i=[];try{for(var s=Su(this.interceptors.preResolution.getAll(e)),a=s.next();!a.done;a=s.next()){var c=a.value;c.options.frequency!="Once"&&i.push(c),c.callback(e,t)}}catch(f){n={error:f}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,i)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var o,i;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var a=Su(this.interceptors.postResolution.getAll(e)),c=a.next();!c.done;c=a.next()){var f=c.value;f.options.frequency!="Once"&&s.push(f),f.callback(e,t,n)}}catch(p){o={error:p}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}this.interceptors.postResolution.setAll(e,s)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===Et.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===Et.Singleton,o=e.options.lifecycle===Et.ContainerScoped,i=n||o,s;return Zi(e.provider)?s=e.provider.useValue:Yi(e.provider)?s=i?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Eu(e.provider)?s=i?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):da(e.provider)?s=e.provider.useFactory(this):s=this.construct(e.provider,t),e.options.lifecycle===Et.ResolutionScoped&&t.scopedResolutions.set(e,s),s},r.prototype.resolveAll=function(e,t,n){var o=this;t===void 0&&(t=new Tu),n===void 0&&(n=!1),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Po(e)){if(n)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return o.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,"All"),a},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Su(this._registry.entries()),o=n.next();!o.done;o=n.next()){var i=Au(o.value,2),s=i[0],a=i[1];this._registry.setAll(s,a.filter(function(c){return!Zi(c.provider)}).map(function(c){return c.instance=void 0,c}))}}catch(c){e={error:c}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var o=Su(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=Au(i.value,2),a=s[0],c=s[1];c.some(function(f){var p=f.options;return p.lifecycle===Et.ContainerScoped})&&n._registry.setAll(a,c.map(function(f){return f.options.lifecycle===Et.ContainerScoped?{provider:f.provider,options:f.options}:f}))}}catch(f){e={error:f}}finally{try{i&&!i.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return h1(this,void 0,void 0,function(){var e;return d1(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var o=n.dispose();o&&e.push(o)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof Bp)return e.createProxy(function(i){return n.resolve(i,t)});var o=(function(){var i=Zm.get(e);if(!i||i.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var s=i.map(n.resolveParams(t,e));return new(e.bind.apply(e,Mr([void 0],s)))})();return b1(o)&&this.disposables.add(o),o},r.prototype.resolveParams=function(e,t){var n=this;return function(o,i){var s,a,c;try{return Xm(o)?Pp(o)?o.multiple?(s=n.resolve(o.transform)).transform.apply(s,Mr([n.resolveAll(o.token,new Tu,o.isOptional)],o.transformArgs)):(a=n.resolve(o.transform)).transform.apply(a,Mr([n.resolve(o.token,e,o.isOptional)],o.transformArgs)):o.multiple?n.resolveAll(o.token,new Tu,o.isOptional):n.resolve(o.token,e,o.isOptional):Pp(o)?(c=n.resolve(o.transform,e)).transform.apply(c,Mr([n.resolve(o.token,e)],o.transformArgs)):n.resolve(o,e)}catch(f){throw new Error(Ym(t,i,f))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r})(),Ke=new wT;function xT(r){return function(e){Zm.set(e,zm(e)),r&&r.token&&(Array.isArray(r.token)?r.token.forEach(function(t){Ke.register(t,e)}):Ke.register(r.token,e))}}var No=xT;if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);function Ie(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}function Oe(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Qm,Ji=class{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}};Oe([u({type:h.ObjectIdentifier})],Ji.prototype,"attrId",void 0);Oe([u({type:h.Any,repeated:"set"})],Ji.prototype,"attrValues",void 0);var x1=Qm=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,Qm.prototype)}};x1=Qm=Oe([E({type:x.Sequence,itemType:Ji})],x1);var eg,v1=eg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,eg.prototype)}};v1=eg=Oe([E({type:x.Sequence,itemType:mr})],v1);var vT="1.2.840.113549",_T=`${vT}.1`,_1=`${_T}.12`,ya=`${_1}.1`,LW=`${ya}.1`,MW=`${ya}.2`,UW=`${ya}.3`,KW=`${ya}.4`,HW=`${ya}.5`,VW=`${ya}.6`,Qi=`${_1}.10.1`;var WW=`${Qi}.1`,qW=`${Qi}.2`,GW=`${Qi}.3`,zW=`${Qi}.4`,XW=`${Qi}.5`,YW=`${Qi}.6`,Np="1.2.840.113549.1.9";var kp=class{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}};Oe([u({type:h.ObjectIdentifier})],kp.prototype,"certId",void 0);Oe([u({type:h.Any,context:0})],kp.prototype,"certValue",void 0);var S1=`${Np}.22`,tq=`${S1}.1`,rq=`${S1}.2`;var Dp=class{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}};Oe([u({type:h.ObjectIdentifier})],Dp.prototype,"crlId",void 0);Oe([u({type:h.Any,context:0})],Dp.prototype,"crltValue",void 0);var ST=`${Np}.23`,aq=`${ST}.1`;function Un(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var Rp=class extends ae{},ko=class{constructor(e={}){this.encryptionAlgorithm=new K,this.encryptedData=new Rp,Object.assign(this,e)}};Un([u({type:K})],ko.prototype,"encryptionAlgorithm",void 0);Un([u({type:Rp})],ko.prototype,"encryptedData",void 0);var tg,rg;(function(r){r[r.v1=0]="v1"})(rg||(rg={}));var jp=class extends ae{},ng=tg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,tg.prototype)}};ng=tg=Un([E({type:x.Sequence,itemType:xt})],ng);var Do=class{constructor(e={}){this.version=rg.v1,this.privateKeyAlgorithm=new K,this.privateKey=new jp,Object.assign(this,e)}};Un([u({type:h.Integer})],Do.prototype,"version",void 0);Un([u({type:K})],Do.prototype,"privateKeyAlgorithm",void 0);Un([u({type:jp})],Do.prototype,"privateKey",void 0);Un([u({type:ng,implicit:!0,context:0,optional:!0})],Do.prototype,"attributes",void 0);var A1=class extends Do{};A1=Oe([E({type:x.Sequence})],A1);var E1=class extends ko{};E1=Oe([E({type:x.Sequence})],E1);var Lp=class{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}};Oe([u({type:h.ObjectIdentifier})],Lp.prototype,"secretTypeId",void 0);Oe([u({type:h.Any,context:0})],Lp.prototype,"secretValue",void 0);var Ro=class{constructor(e={}){this.mac=new Xi,this.macSalt=new ae,this.iterations=1,Object.assign(this,e)}};Oe([u({type:Xi})],Ro.prototype,"mac",void 0);Oe([u({type:ae})],Ro.prototype,"macSalt",void 0);Oe([u({type:h.Integer,defaultValue:1})],Ro.prototype,"iterations",void 0);var es=class{constructor(e={}){this.version=3,this.authSafe=new mr,this.macData=new Ro,Object.assign(this,e)}};Oe([u({type:h.Integer})],es.prototype,"version",void 0);Oe([u({type:mr})],es.prototype,"authSafe",void 0);Oe([u({type:Ro,optional:!0})],es.prototype,"macData",void 0);var og,ma=class{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}};Oe([u({type:h.ObjectIdentifier})],ma.prototype,"bagId",void 0);Oe([u({type:h.Any,context:0})],ma.prototype,"bagValue",void 0);Oe([u({type:Ji,repeated:"set",optional:!0})],ma.prototype,"bagAttributes",void 0);var C1=og=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,og.prototype)}};C1=og=Oe([E({type:x.Sequence,itemType:ma})],C1);var ig,sg,ag,et="1.2.840.113549.1.9",fG=`${et}.0`,K1=`${et}.24`,Ou=`${et}.25`,H1=`${et}.26`,V1=`${et}.27`,lG=`${K1}.1`,pG=`${K1}.2`,hG=`${et}.1`,dG=`${et}.2`,yG=`${et}.3`,mG=`${et}.4`,gG=`${et}.5`,bG=`${et}.6`,yg=`${et}.7`,wG=`${et}.8`,xG=`${et}.9`,vG=`${et}.13`,Bu=`${et}.14`,_G=`${et}.15`,SG=`${et}.20`,AG=`${et}.21`;var EG=`${Ou}.1`,CG=`${Ou}.2`,TG=`${Ou}.3`,IG=`${Ou}.4`,OG=`${Ou}.5`,Pu="1.3.6.1.5.5.7.9",BG=`${Pu}.1`,PG=`${Pu}.2`,NG=`${Pu}.3`,kG=`${Pu}.4`,DG=`${Pu}.5`,RG=`${H1}.1`,jG=`${H1}.2`,LG=`${V1}.1`,MG=`${V1}.2`,UG=`${et}.16`,KG=`${et}.22`,HG=`${et}.23`,VG=`${Tm}.65`,Mp=class extends st{constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};Ie([u({type:h.IA5String})],Mp.prototype,"ia5String",void 0);Mp=Ie([E({type:x.Choice})],Mp);var T1=class extends mr{};T1=Ie([E({type:x.Sequence})],T1);var I1=class extends es{};I1=Ie([E({type:x.Sequence})],I1);var O1=class extends ko{};O1=Ie([E({type:x.Sequence})],O1);var cg=class{constructor(e=""){this.value=e}toString(){return this.value}};Ie([u({type:h.IA5String})],cg.prototype,"value",void 0);cg=Ie([E({type:x.Choice})],cg);var B1=class extends Mp{};B1=Ie([E({type:x.Choice})],B1);var P1=class extends st{};P1=Ie([E({type:x.Choice})],P1);var ug=class{constructor(e=new Date){this.value=e}};Ie([u({type:h.GeneralizedTime})],ug.prototype,"value",void 0);ug=Ie([E({type:x.Choice})],ug);var N1=class extends st{};N1=Ie([E({type:x.Choice})],N1);var fg=class{constructor(e="M"){this.value=e}toString(){return this.value}};Ie([u({type:h.PrintableString})],fg.prototype,"value",void 0);fg=Ie([E({type:x.Choice})],fg);var Up=class{constructor(e=""){this.value=e}toString(){return this.value}};Ie([u({type:h.PrintableString})],Up.prototype,"value",void 0);Up=Ie([E({type:x.Choice})],Up);var k1=class extends Up{};k1=Ie([E({type:x.Choice})],k1);var D1=class extends st{};D1=Ie([E({type:x.Choice})],D1);var lg=class{constructor(e=""){this.value=e}toString(){return this.value}};Ie([u({type:h.ObjectIdentifier})],lg.prototype,"value",void 0);lg=Ie([E({type:x.Choice})],lg);var R1=class extends Qe{};R1=Ie([E({type:x.Choice})],R1);var pg=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};Ie([u({type:h.Integer})],pg.prototype,"value",void 0);pg=Ie([E({type:x.Choice})],pg);var j1=class extends zt{};j1=Ie([E({type:x.Sequence})],j1);var Iu=class extends st{};Iu=Ie([E({type:x.Choice})],Iu);var L1=ig=class extends rr{constructor(e){super(e),Object.setPrototypeOf(this,ig.prototype)}};L1=ig=Ie([E({type:x.Sequence})],L1);var M1=sg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,sg.prototype)}};M1=sg=Ie([E({type:x.Set,itemType:Lr})],M1);var hg=class{constructor(e=""){this.value=e}toString(){return this.value}};Ie([u({type:h.BmpString})],hg.prototype,"value",void 0);hg=Ie([E({type:x.Choice})],hg);var dg=class extends K{};dg=Ie([E({type:x.Sequence})],dg);var U1=ag=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,ag.prototype)}};U1=ag=Ie([E({type:x.Sequence,itemType:dg})],U1);function Ur(r,e,t,n){var o=arguments.length,i=o<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,n);else for(var a=r.length-1;a>=0;a--)(s=r[a])&&(i=(o<3?s(i):o>3?s(e,t,i):s(e,t))||i);return o>3&&i&&Object.defineProperty(e,t,i),i}var mg,Nu=mg=class extends se{constructor(e){super(e),Object.setPrototypeOf(this,mg.prototype)}};Nu=mg=Ur([E({type:x.Sequence,itemType:xt})],Nu);var an=class{constructor(e={}){this.version=0,this.subject=new je,this.subjectPKInfo=new vt,this.attributes=new Nu,Object.assign(this,e)}};Ur([u({type:h.Integer})],an.prototype,"version",void 0);Ur([u({type:je})],an.prototype,"subject",void 0);Ur([u({type:vt})],an.prototype,"subjectPKInfo",void 0);Ur([u({type:Nu,implicit:!0,context:0})],an.prototype,"attributes",void 0);var jo=class{constructor(e={}){this.certificationRequestInfo=new an,this.signatureAlgorithm=new K,this.signature=new ArrayBuffer(0),Object.assign(this,e)}};Ur([u({type:an,raw:!0})],jo.prototype,"certificationRequestInfo",void 0);Ur([u({type:K})],jo.prototype,"signatureAlgorithm",void 0);Ur([u({type:h.BitString})],jo.prototype,"signature",void 0);var rf="crypto.algorithm",Cg=class{getAlgorithms(){return Ke.resolveAll(rf)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new K({algorithm:e.name});if("parameters"in e){let n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(let n of this.getAlgorithms()){let o=n.toWebAlgorithm(e);if(o)return o}return{name:e.algorithm,parameters:e.parameters}}},ts="crypto.algorithmProvider";Ke.registerSingleton(ts,Cg);var $p,Jt="1.3.36.3.3.2.8.1.1",$1=`${Jt}.1`,F1=`${Jt}.2`,W1=`${Jt}.3`,q1=`${Jt}.4`,G1=`${Jt}.5`,z1=`${Jt}.6`,X1=`${Jt}.7`,Y1=`${Jt}.8`,Z1=`${Jt}.9`,J1=`${Jt}.10`,Q1=`${Jt}.11`,e_=`${Jt}.12`,t_=`${Jt}.13`,r_=`${Jt}.14`,n_="brainpoolP160r1",o_="brainpoolP160t1",i_="brainpoolP192r1",s_="brainpoolP192t1",a_="brainpoolP224r1",c_="brainpoolP224t1",u_="brainpoolP256r1",f_="brainpoolP256t1",l_="brainpoolP320r1",p_="brainpoolP320t1",h_="brainpoolP384r1",d_="brainpoolP384t1",y_="brainpoolP512r1",m_="brainpoolP512t1",ze="ECDSA",Ju=$p=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case ze.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Nv;case"sha-256":return kv;case"sha-384":return Dv;case"sha-512":return Rv}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=Lm;break;case"K-256":t=$p.SECP256K1;break;case"P-384":t=Mm;break;case"P-521":t=Um;break;case n_:t=$1;break;case o_:t=F1;break;case i_:t=W1;break;case s_:t=q1;break;case a_:t=G1;break;case c_:t=z1;break;case u_:t=X1;break;case f_:t=Y1;break;case l_:t=Z1;break;case p_:t=J1;break;case h_:t=Q1;break;case d_:t=e_;break;case y_:t=t_;break;case m_:t=r_;break}if(t)return new K({algorithm:$i,parameters:W.serialize(new nn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case gu:return{name:ze,hash:{name:"SHA-1"}};case bu:return{name:ze,hash:{name:"SHA-256"}};case wu:return{name:ze,hash:{name:"SHA-384"}};case xu:return{name:ze,hash:{name:"SHA-512"}};case $i:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(W.parse(e.parameters,nn).namedCurve){case Lm:return{name:ze,namedCurve:"P-256"};case $p.SECP256K1:return{name:ze,namedCurve:"K-256"};case Mm:return{name:ze,namedCurve:"P-384"};case Um:return{name:ze,namedCurve:"P-521"};case $1:return{name:ze,namedCurve:n_};case F1:return{name:ze,namedCurve:o_};case W1:return{name:ze,namedCurve:i_};case q1:return{name:ze,namedCurve:s_};case G1:return{name:ze,namedCurve:a_};case z1:return{name:ze,namedCurve:c_};case X1:return{name:ze,namedCurve:u_};case Y1:return{name:ze,namedCurve:f_};case Z1:return{name:ze,namedCurve:l_};case J1:return{name:ze,namedCurve:p_};case Q1:return{name:ze,namedCurve:h_};case e_:return{name:ze,namedCurve:d_};case t_:return{name:ze,namedCurve:y_};case r_:return{name:ze,namedCurve:m_}}}}return null}};Ju.SECP256K1="1.3.132.0.10";Ju=$p=tu([No()],Ju);Ke.registerSingleton(rf,Ju);var T_=Symbol("name"),I_=Symbol("value"),Te=class{constructor(e,t={},n=""){this[T_]=e,this[I_]=n;for(let o in t)this[o]=t[o]}};Te.NAME=T_;Te.VALUE=I_;var Tg=class{static toTextObject(e){let t=new Te("Algorithm Identifier",{},un.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case $i:{let n=new Ju().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}},un=class{static toString(e){let t=this.items[e];return t||e}};un.items={[Wi]:"sha1",[Ep]:"sha224",[qi]:"sha256",[Gi]:"sha384",[zi]:"sha512",[on]:"rsaEncryption",[sa]:"sha1WithRSAEncryption",[Kv]:"sha224WithRSAEncryption",[Ap]:"sha256WithRSAEncryption",[aa]:"sha384WithRSAEncryption",[ca]:"sha512WithRSAEncryption",[$i]:"ecPublicKey",[gu]:"ecdsaWithSHA1",[Sp]:"ecdsaWithSHA224",[bu]:"ecdsaWithSHA256",[wu]:"ecdsaWithSHA384",[xu]:"ecdsaWithSHA512",[pv]:"TLS WWW server authentication",[hv]:"TLS WWW client authentication",[dv]:"Code Signing",[yv]:"E-mail Protection",[mv]:"Time Stamping",[gv]:"OCSP Signing",[Bv]:"Signed Data"};var Hn=class{static serialize(e){return this.serializeObj(e).join(`
|
|
9
|
+
`)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){let n=[],o=this.pad(t++),i="",s=e[Te.VALUE];s&&(i=` ${s}`),n.push(`${o}${e[Te.NAME]}:${i}`),o=this.pad(t);for(let a in e){if(typeof a=="symbol")continue;let c=e[a],f=a?`${a}: `:"";if(typeof c=="string"||typeof c=="number"||typeof c=="boolean")n.push(`${o}${f}${c}`);else if(c instanceof Date)n.push(`${o}${f}${c.toUTCString()}`);else if(Array.isArray(c))for(let p of c)p[Te.NAME]=a,n.push(...this.serializeObj(p,t));else if(c instanceof Te)c[Te.NAME]=a,n.push(...this.serializeObj(c,t));else if(V.BufferSourceConverter.isBufferSource(c))a?(n.push(`${o}${f}`),n.push(...this.serializeBufferSource(c,t+1))):n.push(...this.serializeBufferSource(c,t));else if("toTextObject"in c){let p=c.toTextObject();p[Te.NAME]=a,n.push(...this.serializeObj(p,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),o=V.BufferSourceConverter.toUint8Array(e),i=[];for(let s=0;s<o.length;){let a=[];for(let c=0;c<16&&s<o.length;c++){c===8&&a.push("");let f=o[s++].toString(16).padStart(2,"0");a.push(f)}i.push(`${n}${a.join(" ")}`)}return i}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};Hn.oidSerializer=un;Hn.algorithmSerializer=Tg;var ga,Lo=class r{get rawData(){return de(this,ga,"f")||We(this,ga,W.serialize(this.asn),"f"),de(this,ga,"f")}constructor(...e){ga.set(this,void 0),V.BufferSourceConverter.isBufferSource(e[0])?(this.asn=W.parse(e[0],e[1]),We(this,ga,V.BufferSourceConverter.toArrayBuffer(e[0]),"f"),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(e){return e instanceof r?(0,V.isEqual)(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return W.toString(this.rawData);case"text":return Hn.serialize(this.toTextObject());case"hex":return V.Convert.ToHex(this.rawData);case"base64":return V.Convert.ToBase64(this.rawData);case"base64url":return V.Convert.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new Te(this.getTextName(),{},e)}};ga=new WeakMap;Lo.NAME="ASN";var or=class r extends Lo{constructor(...e){let t;V.BufferSourceConverter.isBufferSource(e[0])?t=V.BufferSourceConverter.toArrayBuffer(e[0]):t=W.serialize(new _t({extnID:e[0],critical:e[1],extnValue:new ae(V.BufferSourceConverter.toArrayBuffer(e[2]))})),super(t,_t)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[Te.NAME]===r.NAME&&(e[Te.NAME]=un.toString(this.type)),e}},O_,Qu=class r{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[O_]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(r.DEFAULT,crypto):typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle&&this.set(r.DEFAULT,globalThis.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(e=r.DEFAULT){let t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(r.DEFAULT,e);return this}};O_=Symbol.toStringTag;Qu.DEFAULT="default";var yt=new Qu,TT=/^[0-2](?:\.[1-9][0-9]*)+$/;function IT(r){return new RegExp(TT).test(r)}var Wp=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return IT(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}},Zt=new Wp;Zt.register("CN","2.5.4.3");Zt.register("L","2.5.4.7");Zt.register("ST","2.5.4.8");Zt.register("O","2.5.4.10");Zt.register("OU","2.5.4.11");Zt.register("C","2.5.4.6");Zt.register("DC","0.9.2342.19200300.100.1.25");Zt.register("E","1.2.840.113549.1.9.1");Zt.register("G","2.5.4.42");Zt.register("I","2.5.4.43");Zt.register("SN","2.5.4.4");Zt.register("T","2.5.4.12");function OT(r,e){return`\\${V.Convert.ToHex(V.Convert.FromUtf8String(e)).toUpperCase()}`}function BT(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,OT)}var Kr=class r{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,t={}){this.extraNames=new Wp,this.asn=new je;for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let o=t[n];this.extraNames.register(n,o)}typeof e=="string"?this.asn=this.fromString(e):e instanceof je?this.asn=e:V.BufferSourceConverter.isBufferSource(e)?this.asn=W.parse(e,je):this.asn=this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||Zt.findId(e),n=[];for(let o of this.asn)for(let i of o)i.type===t&&n.push(i.value.toString());return n}getName(e){return this.extraNames.get(e)||Zt.get(e)}toString(){return this.asn.map(e=>e.map(t=>{let n=this.getName(t.type)||t.type,o=t.value.anyValue?`#${V.Convert.ToHex(t.value.anyValue)}`:BT(t.value.toString());return`${n}=${o}`}).join("+")).join(", ")}toJSON(){var e;let t=[];for(let n of this.asn){let o={};for(let i of n){let s=this.getName(i.type)||i.type;(e=o[s])!==null&&e!==void 0||(o[s]=[]),o[s].push(i.value.anyValue?`#${V.Convert.ToHex(i.value.anyValue)}`:i.value.toString())}t.push(o)}return t}fromString(e){let t=new je,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,o=null,i=",";for(;o=n.exec(`${e},`);){let[,s,a]=o,c=a[a.length-1];(c===","||c==="+")&&(a=a.slice(0,a.length-1),o[3]=c);let f=o[3];s=this.getTypeOid(s);let p=this.createAttribute(s,a);i==="+"?t[t.length-1].push(p):t.push(new bo([p])),i=f}return t}fromJSON(e){let t=new je;for(let n of e){let o=new bo;for(let i in n){let s=this.getTypeOid(i),a=n[i];for(let c of a){let f=this.createAttribute(s,c);o.push(f)}}t.push(o)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||""),!e)throw new Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(e,t){let n=new Si({type:e});if(typeof t=="object")for(let o in t)switch(o){case"ia5String":n.value.ia5String=t[o];break;case"utf8String":n.value.utf8String=t[o];break;case"universalString":n.value.universalString=t[o];break;case"bmpString":n.value.bmpString=t[o];break;case"printableString":n.value.printableString=t[o];break}else if(t[0]==="#")n.value.anyValue=V.Convert.FromHex(t.slice(1));else{let o=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=o:r.isPrintableString(o)?n.value.printableString=o:n.value.utf8String=o}return n}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
|
|
10
|
+
`).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return W.serialize(this.asn)}async getThumbprint(...e){var t;let n,o="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(o=e[0]||o,n=e[1]||yt.get()):n=e[0]||yt.get(),await n.subtle.digest(o,this.toArrayBuffer())}},B_="Cannot initialize GeneralName from ASN.1 data.",g_=`${B_} Unsupported string format in use.`,PT=`${B_} Value doesn't match to GUID regular expression.`,b_=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,w_="1.3.6.1.4.1.311.25.1",x_="1.3.6.1.4.1.311.20.2.3",gg="dns",bg="dn",wg="email",xg="ip",vg="url",_g="guid",Sg="upn",Kp="id",cn=class extends Lo{constructor(...e){let t;if(e.length===2)switch(e[0]){case bg:{let n=new Kr(e[1]).toArrayBuffer(),o=W.parse(n,je);t=new ue({directoryName:o});break}case gg:t=new ue({dNSName:e[1]});break;case wg:t=new ue({rfc822Name:e[1]});break;case _g:{let n=new RegExp(b_,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");let o=n.slice(1).map((i,s)=>s<3?V.Convert.ToHex(new Uint8Array(V.Convert.FromHex(i)).reverse()):i).join("");t=new ue({otherName:new wo({typeId:w_,value:W.serialize(new ae(V.Convert.FromHex(o)))})});break}case xg:t=new ue({iPAddress:e[1]});break;case Kp:t=new ue({registeredID:e[1]});break;case Sg:{t=new ue({otherName:new wo({typeId:x_,value:W.serialize(Gy.toASN(e[1]))})});break}case vg:t=new ue({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else V.BufferSourceConverter.isBufferSource(e[0])?t=W.parse(e[0],ue):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=gg,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=wg,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=xg,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=vg,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=Kp,this.value=e.registeredID;else if(e.directoryName!=null)this.type=bg,this.value=new Kr(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===w_){this.type=_g;let t=W.parse(e.otherName.value,ae),n=new RegExp(b_,"i").exec(V.Convert.ToHex(t));if(!n)throw new Error(PT);this.value=n.slice(1).map((o,i)=>i<3?V.Convert.ToHex(new Uint8Array(V.Convert.FromHex(o)).reverse()):o).join("-")}else if(e.otherName.typeId===x_)this.type=Sg,this.value=W.parse(e.otherName.value,st).toString();else throw new Error(g_);else throw new Error(g_)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case bg:case gg:case _g:case xg:case Kp:case Sg:case vg:e=this.type.toUpperCase();break;case wg:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Kp&&(t=un.toString(t)),new Te(e,void 0,t)}},Vn=class extends Lo{constructor(e){let t;if(e instanceof Fe)t=e;else if(Array.isArray(e)){let n=[];for(let o of e)if(o instanceof ue)n.push(o);else{let i=W.parse(new cn(o.type,o.value).rawData,ue);n.push(i)}t=new Fe(n)}else if(V.BufferSourceConverter.isBufferSource(e))t=W.parse(e,Fe);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){let t=[];for(let n of e){let o=null;try{o=new cn(n)}catch{continue}t.push(o)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),o=e[n[Te.NAME]];Array.isArray(o)||(o=[],e[n[Te.NAME]]=o),o.push(n)}return e}};Vn.NAME="GeneralNames";var Zu="-{5}",ef="\\n",NT=`[^${ef}]+`,kT=`${Zu}BEGIN (${NT}(?=${Zu}))${Zu}`,DT=`${Zu}END \\1${Zu}`,xa="\\n",RT=`[^:${ef}]+`,jT=`(?:[^${ef}]+${xa}(?: +[^${ef}]+${xa})*)`,LT="[a-zA-Z0-9=+/]+",MT=`(?:${LT}${xa})+`,v_=`${kT}${xa}(?:((?:${RT}: ${jT})+))?${xa}?(${MT})${DT}`,Ut=class{static isPem(e){return typeof e=="string"&&new RegExp(v_,"g").test(e.replace(/\r/g,""))}static decodeWithHeaders(e){e=e.replace(/\r/g,"");let t=new RegExp(v_,"g"),n=[],o=null;for(;o=t.exec(e);){let i=o[3].replace(new RegExp(`[${ef}]+`,"g"),""),s={type:o[1],headers:[],rawData:V.Convert.FromBase64(i)},a=o[2];if(a){let c=a.split(new RegExp(xa,"g")),f=null;for(let p of c){let[l,y]=p.split(/:(.*)/);if(y===void 0){if(!f)throw new Error("Cannot parse PEM string. Incorrect header value");f.value+=l.trim()}else f&&s.headers.push(f),f={key:l,value:y.trim()}}f&&s.headers.push(f)}n.push(s)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw new RangeError("PEM string doesn't contain any objects");return t[0]}static encode(e,t){if(Array.isArray(e)){let n=new Array;return t?e.forEach(o=>{if(!V.BufferSourceConverter.isBufferSource(o))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:V.BufferSourceConverter.toArrayBuffer(o)}))}):e.forEach(o=>{if(!("type"in o))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(o))}),n.join(`
|
|
11
11
|
`)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:V.BufferSourceConverter.toArrayBuffer(e)})}}static encodeStruct(e){var t;let n=e.type.toLocaleUpperCase(),o=[];if(o.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(let f of e.headers)o.push(`${f.key}: ${f.value}`);o.push("")}let i=V.Convert.ToBase64(e.rawData),s,a=0,c=Array();for(;a<i.length&&(i.length-a<64?s=i.substring(a):(s=i.substring(a,a+64),a+=64),s.length!==0);)if(c.push(s),s.length<64)break;return o.push(...c),o.push(`-----END ${n}-----`),o.join(`
|
|
12
|
-
`)}};Kt.CertificateTag="CERTIFICATE";Kt.CrlTag="CRL";Kt.CertificateRequestTag="CERTIFICATE REQUEST";Kt.PublicKeyTag="PUBLIC KEY";Kt.PrivateKeyTag="PRIVATE KEY";var Lo=class r extends jo{static isAsnEncoded(e){return V.BufferSourceConverter.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Kt.isPem(e))return Kt.decode(e)[0];if(V.Convert.isHex(e))return V.Convert.FromHex(e);if(V.Convert.isBase64(e))return V.Convert.FromBase64(e);if(V.Convert.isBase64Url(e))return V.Convert.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{let t=V.BufferSourceConverter.toUint8Array(e);if(t.length>0&&t[0]===48)return V.BufferSourceConverter.toArrayBuffer(e);let n=V.Convert.ToBinary(e);if(Kt.isPem(n))return Kt.decode(n)[0];if(V.Convert.isHex(n))return V.Convert.FromHex(n);if(V.Convert.isBase64(n))return V.Convert.FromBase64(n);if(V.Convert.isBase64Url(n))return V.Convert.FromBase64Url(n);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){r.isAsnEncoded(e[0])?super(r.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Kt.encode(this.rawData,this.tag);default:return super.toString(e)}}},Kn=class r extends Lo{static async create(e,t=yt.get()){if(e instanceof r)return e;if(Ju.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");let n=await t.subtle.exportKey("spki",e);return new r(n)}else{if(e.publicKey)return e.publicKey;if(V.BufferSourceConverter.isBufferSource(e))return new r(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Lo.isAsnEncoded(e)?super(e,_t):super(e),this.tag=Kt.PublicKeyTag}async export(...e){let t,n=["verify"],o={hash:"SHA-256",...this.algorithm};e.length>1?(o=e[0]||o,n=e[1]||n,t=e[2]||yt.get()):t=e[0]||yt.get();let i=this.rawData,s=W.parse(this.rawData,_t);return s.algorithm.algorithm===Oo&&(i=PT(s,i)),t.subtle.importKey("spki",i,o,!0,n)}onInit(e){let t=Ke.resolve(es),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case sn:{let o=W.parse(e.subjectPublicKey,fa),i=V.BufferSourceConverter.toUint8Array(o.modulus);n.publicExponent=V.BufferSourceConverter.toUint8Array(o.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,o="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(o=e[0]||o,n=e[1]||yt.get()):n=e[0]||yt.get(),await n.subtle.digest(o,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=yt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=yt.get();let o=W.parse(this.rawData,_t);return await t.subtle.digest(n,o.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,_t);switch(e.Algorithm=Hn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Vi:e["EC Point"]=t.subjectPublicKey;break;case sn:default:e["Raw Data"]=t.subjectPublicKey}return e}};function PT(r,e){return r.algorithm=new K({algorithm:sn,parameters:null}),e=W.serialize(r),e}var Wp=class r extends ir{static async create(e,t=!1,n=yt.get()){if("name"in e&&"serialNumber"in e)return new r(e,t);let i=await(await Kn.create(e,n)).getKeyIdentifier(n);return new r(V.Convert.ToHex(i),t)}constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){let t=new en({keyIdentifier:new Ei(V.Convert.FromHex(e[0]))});super(tp,e[1],W.serialize(t))}else{let t=e[0],n=t.name instanceof Vn?W.parse(t.name.rawData,Fe):t.name,o=new en({authorityCertIssuer:n,authorityCertSerialNumber:V.Convert.FromHex(t.serialNumber)});super(tp,e[1],W.serialize(o))}}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,en);t.keyIdentifier&&(this.keyId=V.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?V.Convert.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,en);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Vn(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}};Wp.NAME="Authority Key Identifier";var xa=class extends ir{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Ci);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new Ci({cA:e[0],pathLenConstraint:e[1]});super(rp,e[2],W.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}};xa.NAME="Basic Constraints";var m_;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(m_||(m_={}));var qp=class extends ir{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Zc);this.usages=t.map(n=>n)}else{let t=new Zc(e[0]);super(sp,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>fn.toString(t)).join(", "),e}};qp.NAME="Extended Key Usages";var g_;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(g_||(g_={}));var Gp=class extends ir{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Vs);this.usages=t.toNumber()}else{let t=new Vs(e[0]);super(ap,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,Vs);return e[""]=t.toJSON().join(", "),e}};Gp.NAME="Key Usages";var zp=class r extends ir{static async create(e,t=!1,n=yt.get()){let i=await(await Kn.create(e,n)).getKeyIdentifier(n);return new r(V.Convert.ToHex(i),t)}constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Gt);this.keyId=V.Convert.ToHex(t)}else{let t=typeof e[0]=="string"?V.Convert.FromHex(e[0]):e[0],n=new Gt(t);super(mm,e[1],W.serialize(n)),this.keyId=V.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,Gt);return e[""]=t,e}};zp.NAME="Subject Key Identifier";var Xp=class extends ir{constructor(...e){V.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(dm,e[1],new Vn(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,lp);this.names=new Vn(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};Xp.NAME="Subject Alternative Name";var Ht=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new ir(e),n=this.items.get(t.type);return n?new n(e):t}};Ht.items=new Map;var Zp=class extends ir{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=W.parse(this.value,Wc);this.policies=n.map(o=>o.policyIdentifier)}else{let n=e[0],o=(t=e[1])!==null&&t!==void 0?t:!1,i=new Wc(n.map(s=>new Ti({policyIdentifier:s})));super(op,o,W.serialize(i)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Te("",{},fn.toString(t))),e}};Zp.NAME="Certificate Policies";Ht.register(op,Zp);var Yp=class extends ir{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){let o=e[0].map(s=>new tn({distributionPoint:new kn({fullName:[new ue({uniformResourceIdentifier:s})]})})),i=new vo(o);super(ip,e[1],W.serialize(i))}else{let n=new vo(e[0]);super(ip,e[1],W.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,vo);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;let o={};return t.distributionPoint&&(o[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new un(i).toString()).join(", ")),t.reasons&&(o.Reasons=t.reasons.toString()),t.cRLIssuer&&(o["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),o}),e}};Yp.NAME="CRL Distribution Points";var Jp=class extends ir{constructor(...e){var t,n,o,i;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ai){let s=new Ai(e[0]);super(ep,e[1],W.serialize(s))}else{let s=e[0],a=new Ai;Hp(a,s,Yy,"ocsp"),Hp(a,s,Jy,"caIssuers"),Hp(a,s,Qy,"timeStamping"),Hp(a,s,em,"caRepository"),super(ep,e[1],W.serialize(a))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(o=this.timeStamping)!==null&&o!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],W.parse(e.extnValue,Ai).forEach(n=>{switch(n.accessMethod){case Yy:this.ocsp.push(new un(n.accessLocation));break;case Jy:this.caIssuers.push(new un(n.accessLocation));break;case Qy:this.timeStamping.push(new un(n.accessLocation));break;case em:this.caRepository.push(new un(n.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&Kp(e,"OCSP",this.ocsp),this.caIssuers.length&&Kp(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Kp(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Kp(e,"CA Repository",this.caRepository),e}};Jp.NAME="Authority Info Access";function Kp(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{let n=new Te("");t.forEach((o,i)=>{let s=o.toTextObject(),a=`${s[Te.NAME]} ${i+1}`,c=n[a];Array.isArray(c)||(c=[],n[a]=c),c.push(s)}),r[e]=n}}function Hp(r,e,t,n){let o=e[n];o&&(Array.isArray(o)?o:[o]).forEach(s=>{typeof s=="string"&&(s=new un("url",s)),r.push(new Pn({accessMethod:t,accessLocation:W.parse(s.rawData,ue)}))})}var Qp=class extends ir{constructor(...e){V.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(fm,e[1],new Vn(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,Fe);this.names=new Vn(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};Qp.NAME="Issuer Alternative Name";var va=class r extends jo{constructor(...e){let t;if(V.BufferSourceConverter.isBufferSource(e[0]))t=V.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],o=Array.isArray(e[1])?e[1].map(i=>V.BufferSourceConverter.toArrayBuffer(i)):[];t=W.serialize(new vt({type:n,values:o}))}super(t,vt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Te("",{"":t})),e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty();return e[Te.NAME]===r.NAME&&(e[Te.NAME]=fn.toString(this.type)),e}};va.NAME="Attribute";var eh=class extends va{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new Tu({printableString:e[0]});super(lg,[W.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){let t=W.parse(this.values[0],Tu);this.password=t.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[Te.VALUE]=this.password,e}};eh.NAME="Challenge Password";var ef=class extends va{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],o=new nr;for(let i of n)o.push(W.parse(i.rawData,St));super(Bu,[W.serialize(o)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){let t=W.parse(this.values[0],nr);this.items=t.map(n=>Ht.create(W.serialize(n)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(let n of t)e[n[Te.NAME]]=n;return e}};ef.NAME="Extensions";var _a=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new va(e),n=this.items.get(t.type);return n?new n(e):t}};_a.items=new Map;var rf="crypto.signatureFormatter",Ag=class{toAsnSignature(e,t){return V.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return V.BufferSourceConverter.toArrayBuffer(t)}},$p,Eg=$p=class{static createPssParams(e,t){let n=$p.getHashAlgorithm(e);return n?new an({hashAlgorithm:n,maskGenAlgorithm:new K({algorithm:Bo,parameters:W.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){let t=Ke.resolve(es);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new K({algorithm:ia,parameters:null});case"sha-256":return new K({algorithm:Sp,parameters:null});case"sha-384":return new K({algorithm:sa,parameters:null});case"sha-512":return new K({algorithm:aa,parameters:null})}}else return new K({algorithm:sn,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");let t=$p.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new K({algorithm:Oo,parameters:W.serialize(t)})}else return new K({algorithm:Oo,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case sn:return{name:"RSASSA-PKCS1-v1_5"};case ia:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Sp:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case sa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case aa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Oo:if(e.parameters){let t=W.parse(e.parameters,an);return{name:"RSA-PSS",hash:Ke.resolve(es).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Eg=$p=eu([Po()],Eg);Ke.registerSingleton(tf,Eg);var Cg=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new K({algorithm:Fi});case"sha-256":return new K({algorithm:Wi});case"sha-384":return new K({algorithm:qi});case"sha-512":return new K({algorithm:Gi})}return null}toWebAlgorithm(e){switch(e.algorithm){case Fi:return{name:"SHA-1"};case Wi:return{name:"SHA-256"};case qi:return{name:"SHA-384"};case Gi:return{name:"SHA-512"}}return null}};Cg=eu([Po()],Cg);Ke.registerSingleton(tf,Cg);var $n=class r{addPadding(e,t){let n=V.BufferSourceConverter.toUint8Array(t),o=new Uint8Array(e);return o.set(n,e-n.length),o.buffer}removePadding(e,t=!1){let n=V.BufferSourceConverter.toUint8Array(e);for(let o=0;o<n.length;o++)if(n[o]){n=n.slice(o);break}if(t&&n[0]>127){let o=new Uint8Array(n.length+1);return o.set(n,1),o.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){let n=e.namedCurve,o=r.namedCurveSize.get(n)||r.defaultNamedCurveSize,i=new $i,s=V.BufferSourceConverter.toUint8Array(t);return i.r=this.removePadding(s.slice(0,o),!0),i.s=this.removePadding(s.slice(o,o+o),!0),W.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){let n=W.parse(t,$i),o=e.namedCurve,i=r.namedCurveSize.get(o)||r.defaultNamedCurveSize,s=this.addPadding(i,this.removePadding(n.r)),a=this.addPadding(i,this.removePadding(n.s));return(0,V.combine)(s,a)}return null}};$n.namedCurveSize=new Map;$n.defaultNamedCurveSize=32;var xg="1.3.101.110",b_="1.3.101.111",vg="1.3.101.112",w_="1.3.101.113",Tg=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=vg;break;case"x25519":t=xg;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=vg;break;case"ed448":t=w_;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=xg;break;case"x448":t=b_;break}}return t?new K({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case vg:return{name:"Ed25519"};case w_:return{name:"EdDSA",namedCurve:"Ed448"};case xg:return{name:"X25519"};case b_:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Tg=eu([Po()],Tg);Ke.registerSingleton(tf,Tg);var Nu,ku,Du,Ru,ju,Lu,Uu,ga,Og=class extends Lo{get subjectName(){return de(this,ku,"f")||We(this,ku,new Hr(this.asn.certificationRequestInfo.subject),"f"),de(this,ku,"f")}get subject(){return de(this,Du,"f")||We(this,Du,this.subjectName.toString(),"f"),de(this,Du,"f")}get signatureAlgorithm(){if(!de(this,Ru,"f")){let e=Ke.resolve(es);We(this,Ru,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return de(this,Ru,"f")}get signature(){return de(this,ju,"f")||We(this,ju,this.asn.signature,"f"),de(this,ju,"f")}get publicKey(){return de(this,Lu,"f")||We(this,Lu,new Kn(this.asn.certificationRequestInfo.subjectPKInfo),"f"),de(this,Lu,"f")}get attributes(){return de(this,Uu,"f")||We(this,Uu,this.asn.certificationRequestInfo.attributes.map(e=>_a.create(W.serialize(e))),"f"),de(this,Uu,"f")}get extensions(){if(!de(this,ga,"f")){We(this,ga,[],"f");let e=this.getAttribute(Bu);e instanceof ef&&We(this,ga,e.items,"f")}return de(this,ga,"f")}get tbs(){return de(this,Nu,"f")||We(this,Nu,this.asn.certificationRequestInfoRaw||W.serialize(this.asn.certificationRequestInfo),"f"),de(this,Nu,"f")}constructor(e){let t=Lo.isAsnEncoded(e)?[e,Ro]:[e];super(t[0],t[1]),Nu.set(this,void 0),ku.set(this,void 0),Du.set(this,void 0),Ru.set(this,void 0),ju.set(this,void 0),Lu.set(this,void 0),Uu.set(this,void 0),ga.set(this,void 0),this.tag=Kt.CertificateRequestTag}onInit(e){}getAttribute(e){for(let t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(let t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=yt.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),o=Ke.resolveAll(rf).reverse(),i=null;for(let a of o)if(i=a.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,Ro),n=t.certificationRequestInfo,o=new Te("",{Version:`${rn[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let i=new Te("");for(let s of this.attributes){let a=s.toTextObject();i[a[Te.NAME]]=a}o.Attributes=i}return e.Data=o,e.Signature=new Te("",{Algorithm:Hn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};Nu=new WeakMap,ku=new WeakMap,Du=new WeakMap,Ru=new WeakMap,ju=new WeakMap,Lu=new WeakMap,Uu=new WeakMap,ga=new WeakMap;Og.NAME="PKCS#10 Certificate Request";var Mu,Ku,Hu,Vu,$u,Fu,Wu,qu,Gu,zu,ba,Xu,Sa=class extends Lo{get publicKey(){return de(this,Xu,"f")||We(this,Xu,new Kn(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),de(this,Xu,"f")}get serialNumber(){if(!de(this,Ku,"f")){let e=this.asn.tbsCertificate,t=new Uint8Array(e.serialNumber);t.length>1&&t[0]===0&&t[1]>127&&(t=t.slice(1)),We(this,Ku,V.Convert.ToHex(t),"f")}return de(this,Ku,"f")}get subjectName(){return de(this,Hu,"f")||We(this,Hu,new Hr(this.asn.tbsCertificate.subject),"f"),de(this,Hu,"f")}get subject(){return de(this,Vu,"f")||We(this,Vu,this.subjectName.toString(),"f"),de(this,Vu,"f")}get issuerName(){return de(this,$u,"f")||We(this,$u,new Hr(this.asn.tbsCertificate.issuer),"f"),de(this,$u,"f")}get issuer(){return de(this,Fu,"f")||We(this,Fu,this.issuerName.toString(),"f"),de(this,Fu,"f")}get notBefore(){if(!de(this,Wu,"f")){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");We(this,Wu,e,"f")}return de(this,Wu,"f")}get notAfter(){if(!de(this,qu,"f")){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");We(this,qu,e,"f")}return de(this,qu,"f")}get signatureAlgorithm(){if(!de(this,Gu,"f")){let e=Ke.resolve(es);We(this,Gu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return de(this,Gu,"f")}get signature(){return de(this,zu,"f")||We(this,zu,this.asn.signatureValue,"f"),de(this,zu,"f")}get extensions(){return de(this,ba,"f")||(We(this,ba,[],"f"),this.asn.tbsCertificate.extensions&&We(this,ba,this.asn.tbsCertificate.extensions.map(e=>Ht.create(W.serialize(e))),"f")),de(this,ba,"f")}get tbs(){return de(this,Mu,"f")||We(this,Mu,this.asn.tbsCertificateRaw||W.serialize(this.asn.tbsCertificate),"f"),de(this,Mu,"f")}constructor(e){let t=Lo.isAsnEncoded(e)?[e,dr]:[e];super(t[0],t[1]),Mu.set(this,void 0),Ku.set(this,void 0),Hu.set(this,void 0),Vu.set(this,void 0),$u.set(this,void 0),Fu.set(this,void 0),Wu.set(this,void 0),qu.set(this,void 0),Gu.set(this,void 0),zu.set(this,void 0),ba.set(this,void 0),Xu.set(this,void 0),this.tag=Kt.CertificateTag}onInit(e){}getExtension(e){for(let t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=yt.get()){let n,o,i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},o=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},o=await i.publicKey.export(n,["verify"],t);else if(i instanceof Kn)n={...i.algorithm,...this.signatureAlgorithm},o=await i.export(n,["verify"],t);else if(V.BufferSourceConverter.isBufferSource(i)){let f=new Kn(i);n={...f.algorithm,...this.signatureAlgorithm},o=await f.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},o=i}catch{return!1}let s=Ke.resolveAll(rf).reverse(),a=null;for(let f of s)if(a=f.toWebSignature(n,this.signature),a)break;if(!a)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");let c=await t.subtle.verify(this.signatureAlgorithm,o,a,this.tbs);if(e.signatureOnly)return c;{let p=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=yt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=yt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,dr),n=t.tbsCertificate,o=new Te("",{Version:`${rn[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Hn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Te("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(o["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(o["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){let i=new Te("");for(let s of this.extensions){let a=s.toTextObject();i[a[Te.NAME]]=a}o.Extensions=i}return e.Data=o,e.Signature=new Te("",{Algorithm:Hn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};Mu=new WeakMap,Ku=new WeakMap,Hu=new WeakMap,Vu=new WeakMap,$u=new WeakMap,Fu=new WeakMap,Wu=new WeakMap,qu=new WeakMap,Gu=new WeakMap,zu=new WeakMap,ba=new WeakMap,Xu=new WeakMap;Sa.NAME="Certificate";function NT(r,e=yt.get()){let t=V.BufferSourceConverter.toUint8Array(V.Convert.FromHex(r||"")),n=t&&t.length&&t.some(i=>i>0)?new Uint8Array(t):void 0;n||(n=e.getRandomValues(new Uint8Array(16)));let o=0;for(;o<n.length-1&&n[o]===0;)o++;if(n=n.slice(o),n[0]>127){let i=new Uint8Array(n.length+1);i[0]=0,i.set(n,1),n=i}return n.buffer}var th=class{static async createSelfSigned(e,t=yt.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=yt.get()){var n;let o;e.publicKey instanceof Kn?o=e.publicKey.rawData:"publicKey"in e.publicKey?o=e.publicKey.publicKey.rawData:V.BufferSourceConverter.isBufferSource(e.publicKey)?o=e.publicKey:o=await t.subtle.exportKey("spki",e.publicKey);let i=NT(e.serialNumber),s=e.notBefore||new Date,a=e.notAfter||new Date(s.getTime()+31536e6),c=new dr({tbsCertificate:new At({version:rn.v3,serialNumber:i,validity:new Dn({notBefore:s,notAfter:a}),extensions:new nr(((n=e.extensions)===null||n===void 0?void 0:n.map(d=>W.parse(d.rawData,St)))||[]),subjectPublicKeyInfo:W.parse(o,_t)})});if(e.subject){let d=e.subject instanceof Hr?e.subject:new Hr(e.subject);c.tbsCertificate.subject=W.parse(d.toArrayBuffer(),je)}if(e.issuer){let d=e.issuer instanceof Hr?e.issuer:new Hr(e.issuer);c.tbsCertificate.issuer=W.parse(d.toArrayBuffer(),je)}let f={hash:"SHA-256"},p="signingKey"in e?{...f,...e.signingAlgorithm,...e.signingKey.algorithm}:{...f,...e.signingAlgorithm},l=Ke.resolve(es);c.tbsCertificate.signature=c.signatureAlgorithm=l.toAsnAlgorithm(p);let y=W.serialize(c.tbsCertificate),g="signingKey"in e?await t.subtle.sign(p,e.signingKey,y):e.signature,m=Ke.resolveAll(rf).reverse(),C=null;for(let d of m)if(C=d.toAsnSignature(p,g),C)break;if(!C)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=C,new Sa(W.serialize(c))}},kT,DT,RT,jT,LT,x_;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(x_||(x_={}));kT=new WeakMap,DT=new WeakMap,RT=new WeakMap,jT=new WeakMap,LT=new WeakMap;var UT,MT,KT,HT,VT,$T,FT;UT=new WeakMap,MT=new WeakMap,KT=new WeakMap,HT=new WeakMap,VT=new WeakMap,$T=new WeakMap,FT=new WeakMap;Ht.register(rp,xa);Ht.register(sp,qp);Ht.register(ap,Gp);Ht.register(mm,zp);Ht.register(tp,Wp);Ht.register(dm,Xp);Ht.register(ip,Yp);Ht.register(ep,Jp);Ht.register(fm,Qp);_a.register(lg,eh);_a.register(Bu,ef);Ke.registerSingleton(rf,Ag);Ke.registerSingleton(rf,$n);$n.namedCurveSize.set("P-256",32);$n.namedCurveSize.set("K-256",32);$n.namedCurveSize.set("P-384",48);$n.namedCurveSize.set("P-521",66);var Fn="/",E_=new TextEncoder().encode(Fn),rh=E_[0],nf=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=me(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==rh)throw new Error("Invalid key")}toString(e="utf8"){return le(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Fn))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=E_),this._buf[0]!==rh){let e=new Uint8Array(this._buf.byteLength+1);e.fill(rh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===rh;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let i=t[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Fn).slice(1)}type(){return WT(this.baseNamespace())}name(){return qT(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Fn)||(e+=Fn),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Fn):new r(e.slice(0,-1).join(Fn))}child(e){return this.toString()===Fn?e:e.toString()===Fn?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...GT(e.map(t=>t.namespaces()))])}};function WT(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function qT(r){let e=r.split(":");return e[e.length-1]}function GT(r){return[].concat(...r)}var nh=class extends sr{async listen(){throw new Tl("WebRTCTransport.createListener")}getAddrs(){return[]}updateAnnounceAddrs(){}async close(){}};var Aa=!!globalThis.process?.env?.DUMP_SESSION_KEYS,Bg=16;function zT(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function oh(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function ih(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function mt(r,e,t=""){let n=zT(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function Ig(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function C_(r,e){mt(r,void 0,"output");let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Wn(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function qn(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function XT(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}var ZT=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function T_(r,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(r,e)}function O_(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}var Pg=(r,e)=>{function t(n,...o){if(mt(n,void 0,"key"),!ZT)throw new Error("Non little-endian hardware is not yet supported");if(r.nonceLength!==void 0){let p=o[0];mt(p,r.varSizeNonce?void 0:r.nonceLength,"nonce")}let i=r.tagLength;i&&o[1]!==void 0&&mt(o[1],void 0,"AAD");let s=e(n,...o),a=(p,l)=>{if(l!==void 0){if(p!==2)throw new Error("cipher output not supported");mt(l,void 0,"output")}},c=!1;return{encrypt(p,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mt(p),a(s.encrypt.length,l),s.encrypt(p,l)},decrypt(p,l){if(mt(p),i&&p.length<i)throw new Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,l),s.decrypt(p,l)}}}return Object.assign(t,r),t};function Ng(r,e,t=!0){if(e===void 0)return new Uint8Array(r);if(e.length!==r)throw new Error('"output" expected Uint8Array of length '+r+", got: "+e.length);if(t&&!YT(e))throw new Error("invalid output, must be aligned");return e}function B_(r,e,t){oh(t);let n=new Uint8Array(16),o=XT(n);return o.setBigUint64(0,BigInt(e),t),o.setBigUint64(8,BigInt(r),t),n}function YT(r){return r.byteOffset%4===0}function Ea(r){return Uint8Array.from(r)}var P_=r=>Uint8Array.from(r.split(""),e=>e.charCodeAt(0)),JT=P_("expand 16-byte k"),QT=P_("expand 32-byte k"),eO=Wn(JT),tO=Wn(QT);function te(r,e){return r<<e|r>>>32-e}function kg(r){return r.byteOffset%4===0}var sh=64,rO=16,N_=2**32-1,I_=Uint32Array.of();function nO(r,e,t,n,o,i,s,a){let c=o.length,f=new Uint8Array(sh),p=Wn(f),l=kg(o)&&kg(i),y=l?Wn(o):I_,g=l?Wn(i):I_;for(let m=0;m<c;s++){if(r(e,t,n,p,s,a),s>=N_)throw new Error("arx: counter overflow");let C=Math.min(sh,c-m);if(l&&C===sh){let d=m/4;if(m%4!==0)throw new Error("arx: invalid block position");for(let S=0,D;S<rO;S++)D=d+S,g[D]=y[D]^p[S];m+=sh;continue}for(let d=0,S;d<C;d++)S=m+d,i[S]=o[S]^f[d];m+=C}}function Dg(r,e){let{allowShortKeys:t,extendNonceFn:n,counterLength:o,counterRight:i,rounds:s}=T_({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof r!="function")throw new Error("core must be a function");return ih(o),ih(s),oh(i),oh(t),(a,c,f,p,l=0)=>{mt(a,void 0,"key"),mt(c,void 0,"nonce"),mt(f,void 0,"data");let y=f.length;if(p===void 0&&(p=new Uint8Array(y)),mt(p,void 0,"output"),ih(l),l<0||l>=N_)throw new Error("arx: counter overflow");if(p.length<y)throw new Error(`arx: output (${p.length}) is shorter than data (${y})`);let g=[],m=a.length,C,d;if(m===32)g.push(C=Ea(a)),d=tO;else if(m===16&&t)C=new Uint8Array(32),C.set(a),C.set(a,16),d=eO,g.push(C);else throw mt(a,32,"arx key"),new Error("invalid key size");kg(c)||g.push(c=Ea(c));let S=Wn(C);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(d,S,Wn(c.subarray(0,16)),S),c=c.subarray(16)}let D=16-o;if(D!==c.length)throw new Error(`arx: nonce must be ${D} or 16 bytes`);if(D!==12){let H=new Uint8Array(12);H.set(c,i?0:12-c.length),c=H,g.push(c)}let B=Wn(c);return nO(r,d,S,B,f,p,l,s),qn(...g),p}}function Tt(r,e){return r[e++]&255|(r[e++]&255)<<8}var Rg=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;constructor(e){e=Ea(mt(e,32,"key"));let t=Tt(e,0),n=Tt(e,2),o=Tt(e,4),i=Tt(e,6),s=Tt(e,8),a=Tt(e,10),c=Tt(e,12),f=Tt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let p=0;p<8;p++)this.pad[p]=Tt(e,16+2*p)}process(e,t,n=!1){let o=n?0:2048,{h:i,r:s}=this,a=s[0],c=s[1],f=s[2],p=s[3],l=s[4],y=s[5],g=s[6],m=s[7],C=s[8],d=s[9],S=Tt(e,t+0),D=Tt(e,t+2),B=Tt(e,t+4),H=Tt(e,t+6),J=Tt(e,t+8),z=Tt(e,t+10),oe=Tt(e,t+12),j=Tt(e,t+14),P=i[0]+(S&8191),X=i[1]+((S>>>13|D<<3)&8191),Q=i[2]+((D>>>10|B<<6)&8191),$=i[3]+((B>>>7|H<<9)&8191),O=i[4]+((H>>>4|J<<12)&8191),_=i[5]+(J>>>1&8191),v=i[6]+((J>>>14|z<<2)&8191),R=i[7]+((z>>>11|oe<<5)&8191),U=i[8]+((oe>>>8|j<<8)&8191),L=i[9]+(j>>>5|o),I=0,M=I+P*a+X*(5*d)+Q*(5*C)+$*(5*m)+O*(5*g);I=M>>>13,M&=8191,M+=_*(5*y)+v*(5*l)+R*(5*p)+U*(5*f)+L*(5*c),I+=M>>>13,M&=8191;let q=I+P*c+X*a+Q*(5*d)+$*(5*C)+O*(5*m);I=q>>>13,q&=8191,q+=_*(5*g)+v*(5*y)+R*(5*l)+U*(5*p)+L*(5*f),I+=q>>>13,q&=8191;let N=I+P*f+X*c+Q*a+$*(5*d)+O*(5*C);I=N>>>13,N&=8191,N+=_*(5*m)+v*(5*g)+R*(5*y)+U*(5*l)+L*(5*p),I+=N>>>13,N&=8191;let ye=I+P*p+X*f+Q*c+$*a+O*(5*d);I=ye>>>13,ye&=8191,ye+=_*(5*C)+v*(5*m)+R*(5*g)+U*(5*y)+L*(5*l),I+=ye>>>13,ye&=8191;let xe=I+P*l+X*p+Q*f+$*c+O*a;I=xe>>>13,xe&=8191,xe+=_*(5*d)+v*(5*C)+R*(5*m)+U*(5*g)+L*(5*y),I+=xe>>>13,xe&=8191;let re=I+P*y+X*l+Q*p+$*f+O*c;I=re>>>13,re&=8191,re+=_*a+v*(5*d)+R*(5*C)+U*(5*m)+L*(5*g),I+=re>>>13,re&=8191;let Ae=I+P*g+X*y+Q*l+$*p+O*f;I=Ae>>>13,Ae&=8191,Ae+=_*c+v*a+R*(5*d)+U*(5*C)+L*(5*m),I+=Ae>>>13,Ae&=8191;let Ne=I+P*m+X*g+Q*y+$*l+O*p;I=Ne>>>13,Ne&=8191,Ne+=_*f+v*c+R*a+U*(5*d)+L*(5*C),I+=Ne>>>13,Ne&=8191;let qe=I+P*C+X*m+Q*g+$*y+O*l;I=qe>>>13,qe&=8191,qe+=_*p+v*f+R*c+U*a+L*(5*d),I+=qe>>>13,qe&=8191;let Ce=I+P*d+X*C+Q*m+$*g+O*y;I=Ce>>>13,Ce&=8191,Ce+=_*l+v*p+R*f+U*c+L*a,I+=Ce>>>13,Ce&=8191,I=(I<<2)+I|0,I=I+M|0,M=I&8191,I=I>>>13,q+=I,i[0]=M,i[1]=q,i[2]=N,i[3]=ye,i[4]=xe,i[5]=re,i[6]=Ae,i[7]=Ne,i[8]=qe,i[9]=Ce}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=o,o=e[a]>>>13,e[a]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,n[0]=e[0]+5,o=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+o,o=n[a]>>>13,n[a]&=8191;n[9]-=8192;let i=(o^1)-1;for(let a=0;a<10;a++)n[a]&=i;i=~i;for(let a=0;a<10;a++)e[a]=e[a]&i|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+t[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+t[a]|0)+(s>>>16)|0,e[a]=s&65535;qn(n)}update(e){Ig(this),mt(e),e=Ea(e);let{buffer:t,blockLen:n}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);if(s===n){for(;n<=o-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){qn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ig(this),C_(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:o}=this;if(o){for(t[o++]=1;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)e[i++]=n[s]>>>0,e[i++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function oO(r){let e=(n,o)=>r(o).update(n).digest(),t=r(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}var k_=oO(r=>new Rg(r));function j_(r,e,t,n,o,i=20){let s=r[0],a=r[1],c=r[2],f=r[3],p=e[0],l=e[1],y=e[2],g=e[3],m=e[4],C=e[5],d=e[6],S=e[7],D=o,B=t[0],H=t[1],J=t[2],z=s,oe=a,j=c,P=f,X=p,Q=l,$=y,O=g,_=m,v=C,R=d,U=S,L=D,I=B,M=H,q=J;for(let ye=0;ye<i;ye+=2)z=z+X|0,L=te(L^z,16),_=_+L|0,X=te(X^_,12),z=z+X|0,L=te(L^z,8),_=_+L|0,X=te(X^_,7),oe=oe+Q|0,I=te(I^oe,16),v=v+I|0,Q=te(Q^v,12),oe=oe+Q|0,I=te(I^oe,8),v=v+I|0,Q=te(Q^v,7),j=j+$|0,M=te(M^j,16),R=R+M|0,$=te($^R,12),j=j+$|0,M=te(M^j,8),R=R+M|0,$=te($^R,7),P=P+O|0,q=te(q^P,16),U=U+q|0,O=te(O^U,12),P=P+O|0,q=te(q^P,8),U=U+q|0,O=te(O^U,7),z=z+Q|0,q=te(q^z,16),R=R+q|0,Q=te(Q^R,12),z=z+Q|0,q=te(q^z,8),R=R+q|0,Q=te(Q^R,7),oe=oe+$|0,L=te(L^oe,16),U=U+L|0,$=te($^U,12),oe=oe+$|0,L=te(L^oe,8),U=U+L|0,$=te($^U,7),j=j+O|0,I=te(I^j,16),_=_+I|0,O=te(O^_,12),j=j+O|0,I=te(I^j,8),_=_+I|0,O=te(O^_,7),P=P+X|0,M=te(M^P,16),v=v+M|0,X=te(X^v,12),P=P+X|0,M=te(M^P,8),v=v+M|0,X=te(X^v,7);let N=0;n[N++]=s+z|0,n[N++]=a+oe|0,n[N++]=c+j|0,n[N++]=f+P|0,n[N++]=p+X|0,n[N++]=l+Q|0,n[N++]=y+$|0,n[N++]=g+O|0,n[N++]=m+_|0,n[N++]=C+v|0,n[N++]=d+R|0,n[N++]=S+U|0,n[N++]=D+L|0,n[N++]=B+I|0,n[N++]=H+M|0,n[N++]=J+q|0}function iO(r,e,t,n){let o=r[0],i=r[1],s=r[2],a=r[3],c=e[0],f=e[1],p=e[2],l=e[3],y=e[4],g=e[5],m=e[6],C=e[7],d=t[0],S=t[1],D=t[2],B=t[3];for(let J=0;J<20;J+=2)o=o+c|0,d=te(d^o,16),y=y+d|0,c=te(c^y,12),o=o+c|0,d=te(d^o,8),y=y+d|0,c=te(c^y,7),i=i+f|0,S=te(S^i,16),g=g+S|0,f=te(f^g,12),i=i+f|0,S=te(S^i,8),g=g+S|0,f=te(f^g,7),s=s+p|0,D=te(D^s,16),m=m+D|0,p=te(p^m,12),s=s+p|0,D=te(D^s,8),m=m+D|0,p=te(p^m,7),a=a+l|0,B=te(B^a,16),C=C+B|0,l=te(l^C,12),a=a+l|0,B=te(B^a,8),C=C+B|0,l=te(l^C,7),o=o+f|0,B=te(B^o,16),m=m+B|0,f=te(f^m,12),o=o+f|0,B=te(B^o,8),m=m+B|0,f=te(f^m,7),i=i+p|0,d=te(d^i,16),C=C+d|0,p=te(p^C,12),i=i+p|0,d=te(d^i,8),C=C+d|0,p=te(p^C,7),s=s+l|0,S=te(S^s,16),y=y+S|0,l=te(l^y,12),s=s+l|0,S=te(S^s,8),y=y+S|0,l=te(l^y,7),a=a+c|0,D=te(D^a,16),g=g+D|0,c=te(c^g,12),a=a+c|0,D=te(D^a,8),g=g+D|0,c=te(c^g,7);let H=0;n[H++]=o,n[H++]=i,n[H++]=s,n[H++]=a,n[H++]=d,n[H++]=S,n[H++]=D,n[H++]=B}var sO=Dg(j_,{counterRight:!1,counterLength:4,allowShortKeys:!1}),aO=Dg(j_,{counterRight:!1,counterLength:8,extendNonceFn:iO,allowShortKeys:!1});var cO=new Uint8Array(16),D_=(r,e)=>{r.update(e);let t=e.length%16;t&&r.update(cO.subarray(t))},uO=new Uint8Array(32);function R_(r,e,t,n,o){o!==void 0&&mt(o,void 0,"AAD");let i=r(e,t,uO),s=B_(n.length,o?o.length:0,!0),a=k_.create(i);o&&D_(a,o),D_(a,n),a.update(s);let c=a.digest();return qn(i,s),c}var L_=r=>(e,t,n)=>({encrypt(i,s){let a=i.length;s=Ng(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);r(e,t,c,c,1);let f=R_(r,e,t,c,n);return s.set(f,a),qn(f),s},decrypt(i,s){s=Ng(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),f=R_(r,e,t,a,n);if(!O_(c,f))throw new Error("invalid tag");return s.set(i.subarray(0,-16)),r(e,t,s,s,1),qn(f),s}}),jg=Pg({blockSize:64,nonceLength:12,tagLength:16},L_(sO)),iX=Pg({blockSize:64,nonceLength:24,tagLength:16},L_(aO));function M_(r,e,t){return Fo(r),t===void 0&&(t=new Uint8Array(r.outputLen)),As(r,t,e)}var Lg=Uint8Array.of(0),U_=Uint8Array.of();function K_(r,e,t,n=32){Fo(r),cr(n,"length");let o=r.outputLen;if(n>255*o)throw new Error("Length must be <= 255*HashLen");let i=Math.ceil(n/o);t===void 0?t=U_:he(t,void 0,"info");let s=new Uint8Array(i*o),a=As.create(r,e),c=a._cloneInto(),f=new Uint8Array(a.outputLen);for(let p=0;p<i;p++)Lg[0]=p+1,c.update(p===0?U_:f).update(t).update(Lg).digestInto(f),s.set(f,o*p),a._cloneInto(c);return a.destroy(),c.destroy(),Ar(f,Lg),s.slice(0,n)}var Ug={hashSHA256(r){return Wr(r.subarray())},getHKDF(r,e){let t=M_(Wr,e,r),o=K_(Wr,t,void 0,96),i=o.subarray(0,32),s=o.subarray(32,64),a=o.subarray(64,96);return[i,s,a]},generateX25519KeyPair(){let r=Ya.utils.randomSecretKey();return{publicKey:Ya.getPublicKey(r),privateKey:r}},generateX25519KeyPairFromSeed(r){return{publicKey:Ya.getPublicKey(r),privateKey:r}},generateX25519SharedKey(r,e){return Ya.getSharedSecret(r.subarray(),e.subarray())},chaCha20Poly1305Encrypt(r,e,t,n){return jg(n,e,t).encrypt(r.subarray())},chaCha20Poly1305Decrypt(r,e,t,n,o){return jg(n,e,t).decrypt(r.subarray(),o)}};var H_=Ug;function V_(r){return{generateKeypair:r.generateX25519KeyPair,dh:(e,t)=>r.generateX25519SharedKey(e.privateKey,t).subarray(0,32),encrypt:r.chaCha20Poly1305Encrypt,decrypt:r.chaCha20Poly1305Decrypt,hash:r.hashSHA256,hkdf:r.getHKDF}}var Ca=r=>{let e=ft(2);return e[0]=r>>8,e[1]=r,e};Ca.bytes=2;var Ta=r=>{if(r.length<2)throw RangeError("Could not decode int16BE");if(r instanceof Uint8Array){let e=0;return e+=r[0]<<8,e+=r[1],e}return r.getUint16(0)};Ta.bytes=2;function $_(r){return{xxHandshakeSuccesses:r.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:r.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:r.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:r.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:r.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}function Mg(r,e){!e.enabled||!Aa||(r?(e(`LOCAL_STATIC_PUBLIC_KEY ${le(r.publicKey,"hex")}`),e(`LOCAL_STATIC_PRIVATE_KEY ${le(r.privateKey,"hex")}`)):e("Missing local static keys."))}function Kg(r,e){!e.enabled||!Aa||(r?(e(`LOCAL_PUBLIC_EPHEMERAL_KEY ${le(r.publicKey,"hex")}`),e(`LOCAL_PRIVATE_EPHEMERAL_KEY ${le(r.privateKey,"hex")}`)):e("Missing local ephemeral keys."))}function F_(r,e){!e.enabled||!Aa||e(r?`REMOTE_STATIC_PUBLIC_KEY ${le(r.subarray(),"hex")}`:"Missing remote static public key.")}function Hg(r,e){!e.enabled||!Aa||e(r?`REMOTE_EPHEMERAL_PUBLIC_KEY ${le(r.subarray(),"hex")}`:"Missing remote ephemeral keys.")}function Vg(r,e,t){!t.enabled||!Aa||(t(`CIPHER_STATE_1 ${r.n.getUint64()} ${r.k&&le(r.k,"hex")}`),t(`CIPHER_STATE_2 ${e.n.getUint64()} ${e.k&&le(e.k,"hex")}`))}var Oa=class r extends Error{code;constructor(e="Invalid crypto exchange"){super(e),this.code=r.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"};var fO=0,lO=4294967295,pO="Cipherstate has reached maximum n, a new handshake must be performed",ah=class{n;bytes;view;constructor(e=fO){this.n=e,this.bytes=ut(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>lO)throw new Error(pO)}};var ts=ut(0),Ba=class{k;n;crypto;constructor(e,t=void 0,n=0){this.crypto=e,this.k=t,this.n=new ah(n)}hasKey(){return!!this.k}encryptWithAd(e,t){if(!this.hasKey())return t;this.n.assertValue();let n=this.crypto.encrypt(t,this.n.getBytes(),e,this.k);return this.n.increment(),n}decryptWithAd(e,t,n){if(!this.hasKey())return t;this.n.assertValue();let o=this.crypto.decrypt(t,this.n.getBytes(),e,this.k,n);return this.n.increment(),o}},$g=class{cs;ck;h;crypto;constructor(e,t){this.crypto=e;let n=me(t,"utf-8");this.h=hO(e,n),this.ck=this.h,this.cs=new Ba(e)}mixKey(e){let[t,n]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Ba(this.crypto,n)}mixHash(e){this.h=this.crypto.hash(new ge(this.h,e))}encryptAndHash(e){let t=this.cs.encryptWithAd(this.h,e);return this.mixHash(t),t}decryptAndHash(e){let t=this.cs.decryptWithAd(this.h,e);return this.mixHash(e),t}split(){let[e,t]=this.crypto.hkdf(this.ck,ts);return[new Ba(this.crypto,e),new Ba(this.crypto,t)]}},Fg=class{ss;s;e;rs;re;initiator;crypto;constructor(e){let{crypto:t,protocolName:n,prologue:o,initiator:i,s,e:a,rs:c,re:f}=e;this.crypto=t,this.ss=new $g(t,n),this.ss.mixHash(o),this.initiator=i,this.s=s,this.e=a,this.rs=c,this.re=f}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");let e=this.crypto.generateKeypair();return this.ss.mixHash(e.publicKey),this.e=e,e.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(e,t=0){if(this.re)throw new Error("remote ephemeral public key is already set");if(e.byteLength<t+32)throw new Error("message is not long enough");this.re=e.sublist(t,t+32),this.ss.mixHash(this.re)}readS(e,t=0){if(this.rs)throw new Error("remote static public key is already set");let n=32+(this.ss.cs.hasKey()?16:0);if(e.byteLength<t+n)throw new Error("message is not long enough");let o=e.sublist(t,t+n);return this.rs=this.ss.decryptAndHash(o),n}readEE(){this.writeEE()}readES(){this.writeES()}readSE(){this.writeSE()}},of=class extends Fg{writeMessageA(e){return new ge(this.writeE(),this.ss.encryptAndHash(e))}writeMessageB(e){let t=this.writeE();this.writeEE();let n=this.writeS();return this.writeES(),new ge(t,n,this.ss.encryptAndHash(e))}writeMessageC(e){let t=this.writeS();return this.writeSE(),new ge(t,this.ss.encryptAndHash(e))}readMessageA(e){try{return this.readE(e),this.ss.decryptAndHash(e.sublist(32))}catch(t){throw new Oa(`handshake stage 0 validation fail: ${t.message}`)}}readMessageB(e){try{this.readE(e),this.readEE();let t=this.readS(e,32);return this.readES(),this.ss.decryptAndHash(e.sublist(32+t))}catch(t){throw new Oa(`handshake stage 1 validation fail: ${t.message}`)}}readMessageC(e){try{let t=this.readS(e);return this.readSE(),this.ss.decryptAndHash(e.sublist(t))}catch(t){throw new Oa(`handshake stage 2 validation fail: ${t.message}`)}}};function hO(r,e){if(e.length<=32){let t=ut(32);return t.set(e),t}else return r.hash(e)}var ch;(function(r){let e;r.codec=()=>(e==null&&(e=Br((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.webtransportCerthashes!=null)for(let i of t.webtransportCerthashes)n.uint32(10),n.bytes(i);if(t.streamMuxers!=null)for(let i of t.streamMuxers)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={webtransportCerthashes:[],streamMuxers:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{if(o.limits?.webtransportCerthashes!=null&&i.webtransportCerthashes.length===o.limits.webtransportCerthashes)throw new ic('Decode error - map field "webtransportCerthashes" had too many elements');i.webtransportCerthashes.push(t.bytes());break}case 2:{if(o.limits?.streamMuxers!=null&&i.streamMuxers.length===o.limits.streamMuxers)throw new ic('Decode error - map field "streamMuxers" had too many elements');i.streamMuxers.push(t.string());break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(ch||(ch={}));var sf;(function(r){let e;r.codec=()=>(e==null&&(e=Br((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.identityKey!=null&&t.identityKey.byteLength>0&&(n.uint32(10),n.bytes(t.identityKey)),t.identitySig!=null&&t.identitySig.byteLength>0&&(n.uint32(18),n.bytes(t.identitySig)),t.extensions!=null&&(n.uint32(34),ch.codec().encode(t.extensions,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={identityKey:ut(0),identitySig:ut(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.identityKey=t.bytes();break}case 2:{i.identitySig=t.bytes();break}case 4:{i.extensions=ch.codec().decode(t,t.uint32(),{limits:o.limits?.extensions});break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(sf||(sf={}));async function qg(r,e,t){let n=await r.sign(q_(e));return sf.encode({identityKey:Yn(r.publicKey),identitySig:n,extensions:t})}async function Gg(r,e,t){try{let n=sf.decode(r),o=uc(n.identityKey);if(t?.equals(o)===!1)throw new Error(`Payload identity key ${o} does not match expected remote identity key ${t}`);if(!e)throw new Error("Remote static does not exist");let i=q_(e);if(!await o.verify(i,n.identitySig))throw new Error("Invalid payload signature");return n}catch(n){throw new ff(n.message)}}function q_(r){let e=me("noise-libp2p-static-key:");return r instanceof Uint8Array?Rt([e,r],e.length+r.length):(r.prepend(e),r)}var Wg=class extends co{stream;handshake;metrics;decoder;constructor(e,t,n){super({log:e.log,inactivityTimeout:e.inactivityTimeout,maxReadBufferLength:e.maxReadBufferLength,direction:e.direction}),this.stream=e,this.handshake=t,this.metrics=n,this.decoder=new gl({lengthDecoder:Ta,maxBufferSize:16*1024*1024,encodingLength:()=>2});let o=c=>{try{for(let f of this.decoder.decode(c.data))this.onData(this.decrypt(f))}catch(f){this.abort(f)}};this.stream.addEventListener("message",o);let i=c=>{c.error!=null?c.local===!0?this.abort(c.error):this.onRemoteReset():this.onTransportClosed()};this.stream.addEventListener("close",i);let s=()=>{this.safeDispatchEvent("drain")};this.stream.addEventListener("drain",s);let a=()=>{this.onRemoteCloseWrite()};this.stream.addEventListener("remoteCloseWrite",a)}encrypt(e){let t=new ge;for(let n=0;n<e.byteLength;n+=65519){let o=n+65519;o>e.byteLength&&(o=e.byteLength);let i;e instanceof Uint8Array?i=this.handshake.encrypt(e.subarray(n,o)):i=this.handshake.encrypt(e.sublist(n,o)),this.metrics?.encryptedPackets.increment(),t.append(Ca(i.byteLength)),t.append(i)}return t}decrypt(e){let t=new ge;for(let n=0;n<e.byteLength;n+=65535){let o=n+65535;if(o>e.byteLength&&(o=e.byteLength),o-Bg<n)throw new Error("Invalid chunk");let i;e instanceof Uint8Array?i=e.subarray(n,o):i=e.sublist(n,o);let s=e.subarray(n,o-Bg);try{let a=this.handshake.decrypt(i,s);this.metrics?.decryptedPackets.increment(),t.append(a)}catch(a){throw this.metrics?.decryptErrors.increment(),a}}return t}close(e){return this.stream.close(e)}sendPause(){this.stream.pause()}sendResume(){this.stream.resume()}sendReset(e){this.stream.abort(e)}sendData(e){return{sentBytes:e.byteLength,canSendMore:this.stream.send(this.encrypt(e))}}};function zg(r,e,t){return new Wg(r,e,t)}async function G_(r,e){let{log:t,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:f}=r,p=await qg(i,a.publicKey,f),l=new of({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:s,s:a});Mg(l.s,t),t.trace("Stage 0 - Initiator starting to send first message."),await n.write(l.writeMessageA(ts),e),t.trace("Stage 0 - Initiator finished sending first message."),Kg(l.e,t),t.trace("Stage 1 - Initiator waiting to receive first message from responder...");let y=l.readMessageB(await n.read(e));t.trace("Stage 1 - Initiator received the message."),Hg(l.re,t),F_(l.rs,t),t.trace("Initiator going to check remote's signature...");let g=await Gg(y,l.rs,c);t.trace("All good with the signature!"),t.trace("Stage 2 - Initiator sending third handshake message."),await n.write(l.writeMessageC(p),e),t.trace("Stage 2 - Initiator sent message with signed payload.");let[m,C]=l.ss.split();return Vg(m,C,t),{payload:g,encrypt:d=>m.encryptWithAd(ts,d),decrypt:(d,S)=>C.decryptWithAd(ts,d,S)}}async function z_(r,e){let{log:t,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:f}=r,p=await qg(i,a.publicKey,f),l=new of({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:s,s:a});Mg(l.s,t),t.trace("Stage 0 - Responder waiting to receive first message."),l.readMessageA(await n.read(e)),t.trace("Stage 0 - Responder received first message."),Hg(l.re,t),t.trace("Stage 1 - Responder sending out first message with signed payload and static key."),await n.write(l.writeMessageB(p),e),t.trace("Stage 1 - Responder sent the second handshake message with signed payload."),Kg(l.e,t),t.trace("Stage 2 - Responder waiting for third handshake message...");let y=l.readMessageC(await n.read(e));t.trace("Stage 2 - Responder received the message, finished handshake.");let g=await Gg(y,l.rs,c),[m,C]=l.ss.split();return Vg(m,C,t),{payload:g,encrypt:d=>C.encryptWithAd(ts,d),decrypt:(d,S)=>m.decryptWithAd(ts,d,S)}}var uh=class{protocol="/noise";crypto;prologue;staticKey;extensions;metrics;components;log;constructor(e,t={}){let{staticNoiseKey:n,extensions:o,crypto:i,prologueBytes:s}=t,{metrics:a}=e;this.components=e,this.log=e.logger.forComponent("libp2p:noise");let c=i??H_;this.crypto=V_(c),this.extensions={webtransportCerthashes:[],...o},this.metrics=a?$_(a):void 0,n?this.staticKey=c.generateX25519KeyPairFromSeed(n):this.staticKey=c.generateX25519KeyPair(),this.prologue=s??ut(0)}[Symbol.toStringTag]="@chainsafe/libp2p-noise";[ss]=["@libp2p/connection-encryption","@chainsafe/libp2p-noise"];async secureOutbound(e,t){let n=e.log?.newScope("noise")??this.log,o=yl(e,{lengthEncoder:Ca,lengthDecoder:Ta,maxDataLength:65535}),i=await this.performHandshakeInitiator(o,this.components.privateKey,n,t?.remotePeer?.publicKey,t),s=uc(i.payload.identityKey);return{connection:zg(o.unwrap(),i,this.metrics),remoteExtensions:i.payload.extensions,remotePeer:Fd(s),streamMuxer:t?.skipStreamMuxerNegotiation===!0?void 0:this.getStreamMuxer(i.payload.extensions?.streamMuxers)}}getStreamMuxer(e){if(e==null||e.length===0)return;let t=this.components.upgrader.getStreamMuxers();if(t!=null)for(let n of e){let o=t.get(n);if(o!=null)return o}if(e.length)throw new lf("Early muxer negotiation was requested but the initiator and responder had no common muxers")}async secureInbound(e,t){let n=e.log?.newScope("noise")??this.log,o=yl(e,{lengthEncoder:Ca,lengthDecoder:Ta,maxDataLength:65535}),i=await this.performHandshakeResponder(o,this.components.privateKey,n,t?.remotePeer?.publicKey,t),s=uc(i.payload.identityKey);return{connection:zg(o.unwrap(),i,this.metrics),remoteExtensions:i.payload.extensions,remotePeer:Fd(s),streamMuxer:t?.skipStreamMuxerNegotiation===!0?void 0:this.getStreamMuxer(i.payload.extensions?.streamMuxers)}}async performHandshakeInitiator(e,t,n,o,i){let s,a=i?.skipStreamMuxerNegotiation===!0?[]:[...this.components.upgrader.getStreamMuxers().keys()];try{s=await G_({connection:e,privateKey:t,remoteIdentityKey:o,log:n.newScope("xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:{streamMuxers:a,webtransportCerthashes:[],...this.extensions}},i),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){throw this.metrics?.xxHandshakeErrors.increment(),c}return s}async performHandshakeResponder(e,t,n,o,i){let s,a=i?.skipStreamMuxerNegotiation===!0?[]:[...this.components.upgrader.getStreamMuxers().keys()];try{s=await z_({connection:e,privateKey:t,remoteIdentityKey:o,log:n.newScope("xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:{streamMuxers:a,webtransportCerthashes:[],...this.extensions}},i),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){throw this.metrics?.xxHandshakeErrors.increment(),c}return s}};function X_(r={}){return e=>new uh(e,r)}var Xg=Object.values(Ho).map(r=>r.decoder).reduce((r,e)=>r.or(e)),dO=/^a=fingerprint:(?:\w+-[0-9]+)\s(?<fingerprint>(:?[0-9a-fA-F]{2})+)$/m;function Z_(r){return r?.match(dO)?.groups?.fingerprint}function Zg(r){let t=r.getComponents().find(n=>n.code===466)?.value;if(t===void 0||t==="")throw new _e(`Couldn't find a certhash component of multiaddr: ${r.toString()}`);return t}function yO(r){return vr.decode(Xg.decode(r))}function mO(r){let e=yO(Zg(r)),t=gO(e.code),n=e.digest.reduce((i,s)=>i+s.toString(16).padStart(2,"0"),""),o=n.match(/.{1,2}/g);if(o==null)throw new Cl(n,r.toString());return`${t} ${o.join(":").toUpperCase()}`}function Y_(r){let e=r.split(":").map(o=>parseInt(o,16)),t=Uint8Array.from(e),n=Dt(ar.code,t);return Ps(`/certhash/${Ko.encode(n.bytes)}`)}function gO(r){switch(r){case 17:return"sha-1";case 18:return"sha-256";case 19:return"sha-512";default:throw new Ol(r)}}function J_(r,e){let{host:t,port:n,type:o}=_y(r);if(o!=="ip4"&&o!=="ip6")throw new _e(`Multiaddr ${r} was not an IPv4 or IPv6 address`);let i=mO(r);return{type:"answer",sdp:`v=0
|
|
12
|
+
`)}};Ut.CertificateTag="CERTIFICATE";Ut.CrlTag="CRL";Ut.CertificateRequestTag="CERTIFICATE REQUEST";Ut.PublicKeyTag="PUBLIC KEY";Ut.PrivateKeyTag="PRIVATE KEY";var Mo=class r extends Lo{static isAsnEncoded(e){return V.BufferSourceConverter.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ut.isPem(e))return Ut.decode(e)[0];if(V.Convert.isHex(e))return V.Convert.FromHex(e);if(V.Convert.isBase64(e))return V.Convert.FromBase64(e);if(V.Convert.isBase64Url(e))return V.Convert.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{let t=V.BufferSourceConverter.toUint8Array(e);if(t.length>0&&t[0]===48)return V.BufferSourceConverter.toArrayBuffer(e);let n=V.Convert.ToBinary(e);if(Ut.isPem(n))return Ut.decode(n)[0];if(V.Convert.isHex(n))return V.Convert.FromHex(n);if(V.Convert.isBase64(n))return V.Convert.FromBase64(n);if(V.Convert.isBase64Url(n))return V.Convert.FromBase64Url(n);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){r.isAsnEncoded(e[0])?super(r.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ut.encode(this.rawData,this.tag);default:return super.toString(e)}}},Kn=class r extends Mo{static async create(e,t=yt.get()){if(e instanceof r)return e;if(Qu.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");let n=await t.subtle.exportKey("spki",e);return new r(n)}else{if(e.publicKey)return e.publicKey;if(V.BufferSourceConverter.isBufferSource(e))return new r(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){Mo.isAsnEncoded(e)?super(e,vt):super(e),this.tag=Ut.PublicKeyTag}async export(...e){let t,n=["verify"],o={hash:"SHA-256",...this.algorithm};e.length>1?(o=e[0]||o,n=e[1]||n,t=e[2]||yt.get()):t=e[0]||yt.get();let i=this.rawData,s=W.parse(this.rawData,vt);return s.algorithm.algorithm===Oo&&(i=UT(s,i)),t.subtle.importKey("spki",i,o,!0,n)}onInit(e){let t=Ke.resolve(ts),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case on:{let o=W.parse(e.subjectPublicKey,la),i=V.BufferSourceConverter.toUint8Array(o.modulus);n.publicExponent=V.BufferSourceConverter.toUint8Array(o.publicExponent),n.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,o="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(o=e[0]||o,n=e[1]||yt.get()):n=e[0]||yt.get(),await n.subtle.digest(o,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=yt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=yt.get();let o=W.parse(this.rawData,vt);return await t.subtle.digest(n,o.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,vt);switch(e.Algorithm=Hn.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case $i:e["EC Point"]=t.subjectPublicKey;break;case on:default:e["Raw Data"]=t.subjectPublicKey}return e}};function UT(r,e){return r.algorithm=new K({algorithm:on,parameters:null}),e=W.serialize(r),e}var qp=class r extends or{static async create(e,t=!1,n=yt.get()){if("name"in e&&"serialNumber"in e)return new r(e,t);let i=await(await Kn.create(e,n)).getKeyIdentifier(n);return new r(V.Convert.ToHex(i),t)}constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){let t=new Qr({keyIdentifier:new Ci(V.Convert.FromHex(e[0]))});super(rp,e[1],W.serialize(t))}else{let t=e[0],n=t.name instanceof Vn?W.parse(t.name.rawData,Fe):t.name,o=new Qr({authorityCertIssuer:n,authorityCertSerialNumber:V.Convert.FromHex(t.serialNumber)});super(rp,e[1],W.serialize(o))}}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,Qr);t.keyIdentifier&&(this.keyId=V.Convert.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?V.Convert.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,Qr);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Vn(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}};qp.NAME="Authority Key Identifier";var va=class extends or{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Ti);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{let t=new Ti({cA:e[0],pathLenConstraint:e[1]});super(np,e[2],W.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}};va.NAME="Basic Constraints";var __;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(__||(__={}));var Gp=class extends or{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,Zc);this.usages=t.map(n=>n)}else{let t=new Zc(e[0]);super(ap,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>un.toString(t)).join(", "),e}};Gp.NAME="Extended Key Usages";var S_;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(S_||(S_={}));var zp=class extends or{constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,$s);this.usages=t.toNumber()}else{let t=new $s(e[0]);super(cp,e[1],W.serialize(t)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,$s);return e[""]=t.toJSON().join(", "),e}};zp.NAME="Key Usages";var Xp=class r extends or{static async create(e,t=!1,n=yt.get()){let i=await(await Kn.create(e,n)).getKeyIdentifier(n);return new r(V.Convert.ToHex(i),t)}constructor(...e){if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let t=W.parse(this.value,qt);this.keyId=V.Convert.ToHex(t)}else{let t=typeof e[0]=="string"?V.Convert.FromHex(e[0]):e[0],n=new qt(t);super(xm,e[1],W.serialize(n)),this.keyId=V.Convert.ToHex(t)}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=W.parse(this.value,qt);return e[""]=t,e}};Xp.NAME="Subject Key Identifier";var Yp=class extends or{constructor(...e){V.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(bm,e[1],new Vn(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,pp);this.names=new Vn(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};Yp.NAME="Subject Alternative Name";var Kt=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new or(e),n=this.items.get(t.type);return n?new n(e):t}};Kt.items=new Map;var Zp=class extends or{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=W.parse(this.value,qc);this.policies=n.map(o=>o.policyIdentifier)}else{let n=e[0],o=(t=e[1])!==null&&t!==void 0?t:!1,i=new qc(n.map(s=>new Ii({policyIdentifier:s})));super(ip,o,W.serialize(i)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new Te("",{},un.toString(t))),e}};Zp.NAME="Certificate Policies";Kt.register(ip,Zp);var Jp=class extends or{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){let o=e[0].map(s=>new en({distributionPoint:new kn({fullName:[new ue({uniformResourceIdentifier:s})]})})),i=new _o(o);super(sp,e[1],W.serialize(i))}else{let n=new _o(e[0]);super(sp,e[1],W.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,_o);this.distributionPoints=t}toTextObject(){let e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;let o={};return t.distributionPoint&&(o[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(i=>new cn(i).toString()).join(", ")),t.reasons&&(o.Reasons=t.reasons.toString()),t.cRLIssuer&&(o["CRL Issuer"]=t.cRLIssuer.map(i=>i.toString()).join(", ")),o}),e}};Jp.NAME="CRL Distribution Points";var Qp=class extends or{constructor(...e){var t,n,o,i;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Ei){let s=new Ei(e[0]);super(tp,e[1],W.serialize(s))}else{let s=e[0],a=new Ei;Vp(a,s,tm,"ocsp"),Vp(a,s,rm,"caIssuers"),Vp(a,s,nm,"timeStamping"),Vp(a,s,om,"caRepository"),super(tp,e[1],W.serialize(a))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(o=this.timeStamping)!==null&&o!==void 0||(this.timeStamping=[]),(i=this.caRepository)!==null&&i!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],W.parse(e.extnValue,Ei).forEach(n=>{switch(n.accessMethod){case tm:this.ocsp.push(new cn(n.accessLocation));break;case rm:this.caIssuers.push(new cn(n.accessLocation));break;case nm:this.timeStamping.push(new cn(n.accessLocation));break;case om:this.caRepository.push(new cn(n.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&Hp(e,"OCSP",this.ocsp),this.caIssuers.length&&Hp(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Hp(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Hp(e,"CA Repository",this.caRepository),e}};Qp.NAME="Authority Info Access";function Hp(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{let n=new Te("");t.forEach((o,i)=>{let s=o.toTextObject(),a=`${s[Te.NAME]} ${i+1}`,c=n[a];Array.isArray(c)||(c=[],n[a]=c),c.push(s)}),r[e]=n}}function Vp(r,e,t,n){let o=e[n];o&&(Array.isArray(o)?o:[o]).forEach(s=>{typeof s=="string"&&(s=new cn("url",s)),r.push(new Pn({accessMethod:t,accessLocation:W.parse(s.rawData,ue)}))})}var eh=class extends or{constructor(...e){V.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(dm,e[1],new Vn(e[0]||[]).rawData)}onInit(e){super.onInit(e);let t=W.parse(e.extnValue,Fe);this.names=new Vn(t)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};eh.NAME="Issuer Alternative Name";var _a=class r extends Lo{constructor(...e){let t;if(V.BufferSourceConverter.isBufferSource(e[0]))t=V.BufferSourceConverter.toArrayBuffer(e[0]);else{let n=e[0],o=Array.isArray(e[1])?e[1].map(i=>V.BufferSourceConverter.toArrayBuffer(i)):[];t=W.serialize(new xt({type:n,values:o}))}super(t,xt)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(t=>new Te("",{"":t})),e}toTextObjectWithoutValue(){let e=this.toTextObjectEmpty();return e[Te.NAME]===r.NAME&&(e[Te.NAME]=un.toString(this.type)),e}};_a.NAME="Attribute";var th=class extends _a{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new Iu({printableString:e[0]});super(yg,[W.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){let t=W.parse(this.values[0],Iu);this.password=t.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[Te.VALUE]=this.password,e}};th.NAME="Challenge Password";var tf=class extends _a{constructor(...e){var t;if(V.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],o=new rr;for(let i of n)o.push(W.parse(i.rawData,_t));super(Bu,[W.serialize(o)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){let t=W.parse(this.values[0],rr);this.items=t.map(n=>Kt.create(W.serialize(n)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(let n of t)e[n[Te.NAME]]=n;return e}};tf.NAME="Extensions";var Sa=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new _a(e),n=this.items.get(t.type);return n?new n(e):t}};Sa.items=new Map;var nf="crypto.signatureFormatter",Ig=class{toAsnSignature(e,t){return V.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return V.BufferSourceConverter.toArrayBuffer(t)}},Fp,Og=Fp=class{static createPssParams(e,t){let n=Fp.getHashAlgorithm(e);return n?new sn({hashAlgorithm:n,maskGenAlgorithm:new K({algorithm:Bo,parameters:W.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){let t=Ke.resolve(ts);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new K({algorithm:sa,parameters:null});case"sha-256":return new K({algorithm:Ap,parameters:null});case"sha-384":return new K({algorithm:aa,parameters:null});case"sha-512":return new K({algorithm:ca,parameters:null})}}else return new K({algorithm:on,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");let t=Fp.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new K({algorithm:Oo,parameters:W.serialize(t)})}else return new K({algorithm:Oo,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case on:return{name:"RSASSA-PKCS1-v1_5"};case sa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Ap:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case aa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case ca:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Oo:if(e.parameters){let t=W.parse(e.parameters,sn);return{name:"RSA-PSS",hash:Ke.resolve(ts).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};Og=Fp=tu([No()],Og);Ke.registerSingleton(rf,Og);var Bg=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new K({algorithm:Wi});case"sha-256":return new K({algorithm:qi});case"sha-384":return new K({algorithm:Gi});case"sha-512":return new K({algorithm:zi})}return null}toWebAlgorithm(e){switch(e.algorithm){case Wi:return{name:"SHA-1"};case qi:return{name:"SHA-256"};case Gi:return{name:"SHA-384"};case zi:return{name:"SHA-512"}}return null}};Bg=tu([No()],Bg);Ke.registerSingleton(rf,Bg);var $n=class r{addPadding(e,t){let n=V.BufferSourceConverter.toUint8Array(t),o=new Uint8Array(e);return o.set(n,e-n.length),o.buffer}removePadding(e,t=!1){let n=V.BufferSourceConverter.toUint8Array(e);for(let o=0;o<n.length;o++)if(n[o]){n=n.slice(o);break}if(t&&n[0]>127){let o=new Uint8Array(n.length+1);return o.set(n,1),o.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){let n=e.namedCurve,o=r.namedCurveSize.get(n)||r.defaultNamedCurveSize,i=new Fi,s=V.BufferSourceConverter.toUint8Array(t);return i.r=this.removePadding(s.slice(0,o),!0),i.s=this.removePadding(s.slice(o,o+o),!0),W.serialize(i)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){let n=W.parse(t,Fi),o=e.namedCurve,i=r.namedCurveSize.get(o)||r.defaultNamedCurveSize,s=this.addPadding(i,this.removePadding(n.r)),a=this.addPadding(i,this.removePadding(n.s));return(0,V.combine)(s,a)}return null}};$n.namedCurveSize=new Map;$n.defaultNamedCurveSize=32;var Ag="1.3.101.110",A_="1.3.101.111",Eg="1.3.101.112",E_="1.3.101.113",Pg=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=Eg;break;case"x25519":t=Ag;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=Eg;break;case"ed448":t=E_;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=Ag;break;case"x448":t=A_;break}}return t?new K({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case Eg:return{name:"Ed25519"};case E_:return{name:"EdDSA",namedCurve:"Ed448"};case Ag:return{name:"X25519"};case A_:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Pg=tu([No()],Pg);Ke.registerSingleton(rf,Pg);var ku,Du,Ru,ju,Lu,Mu,Uu,ba,Ng=class extends Mo{get subjectName(){return de(this,Du,"f")||We(this,Du,new Kr(this.asn.certificationRequestInfo.subject),"f"),de(this,Du,"f")}get subject(){return de(this,Ru,"f")||We(this,Ru,this.subjectName.toString(),"f"),de(this,Ru,"f")}get signatureAlgorithm(){if(!de(this,ju,"f")){let e=Ke.resolve(ts);We(this,ju,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return de(this,ju,"f")}get signature(){return de(this,Lu,"f")||We(this,Lu,this.asn.signature,"f"),de(this,Lu,"f")}get publicKey(){return de(this,Mu,"f")||We(this,Mu,new Kn(this.asn.certificationRequestInfo.subjectPKInfo),"f"),de(this,Mu,"f")}get attributes(){return de(this,Uu,"f")||We(this,Uu,this.asn.certificationRequestInfo.attributes.map(e=>Sa.create(W.serialize(e))),"f"),de(this,Uu,"f")}get extensions(){if(!de(this,ba,"f")){We(this,ba,[],"f");let e=this.getAttribute(Bu);e instanceof tf&&We(this,ba,e.items,"f")}return de(this,ba,"f")}get tbs(){return de(this,ku,"f")||We(this,ku,this.asn.certificationRequestInfoRaw||W.serialize(this.asn.certificationRequestInfo),"f"),de(this,ku,"f")}constructor(e){let t=Mo.isAsnEncoded(e)?[e,jo]:[e];super(t[0],t[1]),ku.set(this,void 0),Du.set(this,void 0),Ru.set(this,void 0),ju.set(this,void 0),Lu.set(this,void 0),Mu.set(this,void 0),Uu.set(this,void 0),ba.set(this,void 0),this.tag=Ut.CertificateRequestTag}onInit(e){}getAttribute(e){for(let t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(let t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=yt.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),o=Ke.resolveAll(nf).reverse(),i=null;for(let a of o)if(i=a.toWebSignature(t,this.signature),i)break;if(!i)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,jo),n=t.certificationRequestInfo,o=new Te("",{Version:`${tn[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let i=new Te("");for(let s of this.attributes){let a=s.toTextObject();i[a[Te.NAME]]=a}o.Attributes=i}return e.Data=o,e.Signature=new Te("",{Algorithm:Hn.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}};ku=new WeakMap,Du=new WeakMap,Ru=new WeakMap,ju=new WeakMap,Lu=new WeakMap,Mu=new WeakMap,Uu=new WeakMap,ba=new WeakMap;Ng.NAME="PKCS#10 Certificate Request";var Ku,Hu,Vu,$u,Fu,Wu,qu,Gu,zu,Xu,wa,Yu,Aa=class extends Mo{get publicKey(){return de(this,Yu,"f")||We(this,Yu,new Kn(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),de(this,Yu,"f")}get serialNumber(){if(!de(this,Hu,"f")){let e=this.asn.tbsCertificate,t=new Uint8Array(e.serialNumber);t.length>1&&t[0]===0&&t[1]>127&&(t=t.slice(1)),We(this,Hu,V.Convert.ToHex(t),"f")}return de(this,Hu,"f")}get subjectName(){return de(this,Vu,"f")||We(this,Vu,new Kr(this.asn.tbsCertificate.subject),"f"),de(this,Vu,"f")}get subject(){return de(this,$u,"f")||We(this,$u,this.subjectName.toString(),"f"),de(this,$u,"f")}get issuerName(){return de(this,Fu,"f")||We(this,Fu,new Kr(this.asn.tbsCertificate.issuer),"f"),de(this,Fu,"f")}get issuer(){return de(this,Wu,"f")||We(this,Wu,this.issuerName.toString(),"f"),de(this,Wu,"f")}get notBefore(){if(!de(this,qu,"f")){let e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");We(this,qu,e,"f")}return de(this,qu,"f")}get notAfter(){if(!de(this,Gu,"f")){let e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");We(this,Gu,e,"f")}return de(this,Gu,"f")}get signatureAlgorithm(){if(!de(this,zu,"f")){let e=Ke.resolve(ts);We(this,zu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return de(this,zu,"f")}get signature(){return de(this,Xu,"f")||We(this,Xu,this.asn.signatureValue,"f"),de(this,Xu,"f")}get extensions(){return de(this,wa,"f")||(We(this,wa,[],"f"),this.asn.tbsCertificate.extensions&&We(this,wa,this.asn.tbsCertificate.extensions.map(e=>Kt.create(W.serialize(e))),"f")),de(this,wa,"f")}get tbs(){return de(this,Ku,"f")||We(this,Ku,this.asn.tbsCertificateRaw||W.serialize(this.asn.tbsCertificate),"f"),de(this,Ku,"f")}constructor(e){let t=Mo.isAsnEncoded(e)?[e,hr]:[e];super(t[0],t[1]),Ku.set(this,void 0),Hu.set(this,void 0),Vu.set(this,void 0),$u.set(this,void 0),Fu.set(this,void 0),Wu.set(this,void 0),qu.set(this,void 0),Gu.set(this,void 0),zu.set(this,void 0),Xu.set(this,void 0),wa.set(this,void 0),Yu.set(this,void 0),this.tag=Ut.CertificateTag}onInit(e){}getExtension(e){for(let t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=yt.get()){let n,o,i=e.publicKey;try{if(!i)n={...this.publicKey.algorithm,...this.signatureAlgorithm},o=await this.publicKey.export(n,["verify"],t);else if("publicKey"in i)n={...i.publicKey.algorithm,...this.signatureAlgorithm},o=await i.publicKey.export(n,["verify"],t);else if(i instanceof Kn)n={...i.algorithm,...this.signatureAlgorithm},o=await i.export(n,["verify"],t);else if(V.BufferSourceConverter.isBufferSource(i)){let f=new Kn(i);n={...f.algorithm,...this.signatureAlgorithm},o=await f.export(n,["verify"],t)}else n={...i.algorithm,...this.signatureAlgorithm},o=i}catch{return!1}let s=Ke.resolveAll(nf).reverse(),a=null;for(let f of s)if(a=f.toWebSignature(n,this.signature),a)break;if(!a)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");let c=await t.subtle.verify(this.signatureAlgorithm,o,a,this.tbs);if(e.signatureOnly)return c;{let p=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<p&&p<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=yt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=yt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),t=W.parse(this.rawData,hr),n=t.tbsCertificate,o=new Te("",{Version:`${tn[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":Hn.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new Te("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(o["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(o["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){let i=new Te("");for(let s of this.extensions){let a=s.toTextObject();i[a[Te.NAME]]=a}o.Extensions=i}return e.Data=o,e.Signature=new Te("",{Algorithm:Hn.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}};Ku=new WeakMap,Hu=new WeakMap,Vu=new WeakMap,$u=new WeakMap,Fu=new WeakMap,Wu=new WeakMap,qu=new WeakMap,Gu=new WeakMap,zu=new WeakMap,Xu=new WeakMap,wa=new WeakMap,Yu=new WeakMap;Aa.NAME="Certificate";function KT(r,e=yt.get()){let t=V.BufferSourceConverter.toUint8Array(V.Convert.FromHex(r||"")),n=t&&t.length&&t.some(i=>i>0)?new Uint8Array(t):void 0;n||(n=e.getRandomValues(new Uint8Array(16)));let o=0;for(;o<n.length-1&&n[o]===0;)o++;if(n=n.slice(o),n[0]>127){let i=new Uint8Array(n.length+1);i[0]=0,i.set(n,1),n=i}return n.buffer}var rh=class{static async createSelfSigned(e,t=yt.get()){if(!e.keys.privateKey)throw new Error("Bad field 'keys' in 'params' argument. 'privateKey' is empty");if(!e.keys.publicKey)throw new Error("Bad field 'keys' in 'params' argument. 'publicKey' is empty");return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,t=yt.get()){var n;let o;e.publicKey instanceof Kn?o=e.publicKey.rawData:"publicKey"in e.publicKey?o=e.publicKey.publicKey.rawData:V.BufferSourceConverter.isBufferSource(e.publicKey)?o=e.publicKey:o=await t.subtle.exportKey("spki",e.publicKey);let i=KT(e.serialNumber),s=e.notBefore||new Date,a=e.notAfter||new Date(s.getTime()+31536e6),c=new hr({tbsCertificate:new St({version:tn.v3,serialNumber:i,validity:new Dn({notBefore:s,notAfter:a}),extensions:new rr(((n=e.extensions)===null||n===void 0?void 0:n.map(m=>W.parse(m.rawData,_t)))||[]),subjectPublicKeyInfo:W.parse(o,vt)})});if(e.subject){let m=e.subject instanceof Kr?e.subject:new Kr(e.subject);c.tbsCertificate.subject=W.parse(m.toArrayBuffer(),je)}if(e.issuer){let m=e.issuer instanceof Kr?e.issuer:new Kr(e.issuer);c.tbsCertificate.issuer=W.parse(m.toArrayBuffer(),je)}let f={hash:"SHA-256"},p="signingKey"in e?{...f,...e.signingAlgorithm,...e.signingKey.algorithm}:{...f,...e.signingAlgorithm},l=Ke.resolve(ts);c.tbsCertificate.signature=c.signatureAlgorithm=l.toAsnAlgorithm(p);let y=W.serialize(c.tbsCertificate),d="signingKey"in e?await t.subtle.sign(p,e.signingKey,y):e.signature,g=Ke.resolveAll(nf).reverse(),C=null;for(let m of g)if(C=m.toAsnSignature(p,d),C)break;if(!C)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=C,new Aa(W.serialize(c))}},HT,VT,$T,FT,WT,C_;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(C_||(C_={}));HT=new WeakMap,VT=new WeakMap,$T=new WeakMap,FT=new WeakMap,WT=new WeakMap;var qT,GT,zT,XT,YT,ZT,JT;qT=new WeakMap,GT=new WeakMap,zT=new WeakMap,XT=new WeakMap,YT=new WeakMap,ZT=new WeakMap,JT=new WeakMap;Kt.register(np,va);Kt.register(ap,Gp);Kt.register(cp,zp);Kt.register(xm,Xp);Kt.register(rp,qp);Kt.register(bm,Yp);Kt.register(sp,Jp);Kt.register(tp,Qp);Kt.register(dm,eh);Sa.register(yg,th);Sa.register(Bu,tf);Ke.registerSingleton(nf,Ig);Ke.registerSingleton(nf,$n);$n.namedCurveSize.set("P-256",32);$n.namedCurveSize.set("K-256",32);$n.namedCurveSize.set("P-384",48);$n.namedCurveSize.set("P-521",66);var Fn="/",P_=new TextEncoder().encode(Fn),nh=P_[0],of=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=me(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==nh)throw new Error("Invalid key")}toString(e="utf8"){return le(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Fn))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=P_),this._buf[0]!==nh){let e=new Uint8Array(this._buf.byteLength+1);e.fill(nh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===nh;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let i=t[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Fn).slice(1)}type(){return QT(this.baseNamespace())}name(){return eI(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Fn)||(e+=Fn),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Fn):new r(e.slice(0,-1).join(Fn))}child(e){return this.toString()===Fn?e:e.toString()===Fn?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...tI(e.map(t=>t.namespaces()))])}};function QT(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function eI(r){let e=r.split(":");return e[e.length-1]}function tI(r){return[].concat(...r)}var oh=class extends ir{async listen(){throw new Il("WebRTCTransport.createListener")}getAddrs(){return[]}updateAnnounceAddrs(){}async close(){}};var Ea=!!globalThis.process?.env?.DUMP_SESSION_KEYS,kg=16;function rI(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ih(r){if(typeof r!="boolean")throw new Error(`boolean expected, not ${r}`)}function sh(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function mt(r,e,t=""){let n=rI(r),o=r?.length,i=e!==void 0;if(!n||i&&o!==e){let s=t&&`"${t}" `,a=i?` of length ${e}`:"",c=n?`length=${o}`:`type=${typeof r}`;throw new Error(s+"expected Uint8Array"+a+", got "+c)}return r}function Dg(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function N_(r,e){mt(r,void 0,"output");let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Wn(r){return new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4))}function qn(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function nI(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}var oI=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function k_(r,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(r,e)}function D_(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}var Rg=(r,e)=>{function t(n,...o){if(mt(n,void 0,"key"),!oI)throw new Error("Non little-endian hardware is not yet supported");if(r.nonceLength!==void 0){let p=o[0];mt(p,r.varSizeNonce?void 0:r.nonceLength,"nonce")}let i=r.tagLength;i&&o[1]!==void 0&&mt(o[1],void 0,"AAD");let s=e(n,...o),a=(p,l)=>{if(l!==void 0){if(p!==2)throw new Error("cipher output not supported");mt(l,void 0,"output")}},c=!1;return{encrypt(p,l){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mt(p),a(s.encrypt.length,l),s.encrypt(p,l)},decrypt(p,l){if(mt(p),i&&p.length<i)throw new Error('"ciphertext" expected length bigger than tagLength='+i);return a(s.decrypt.length,l),s.decrypt(p,l)}}}return Object.assign(t,r),t};function jg(r,e,t=!0){if(e===void 0)return new Uint8Array(r);if(e.length!==r)throw new Error('"output" expected Uint8Array of length '+r+", got: "+e.length);if(t&&!iI(e))throw new Error("invalid output, must be aligned");return e}function R_(r,e,t){ih(t);let n=new Uint8Array(16),o=nI(n);return o.setBigUint64(0,BigInt(e),t),o.setBigUint64(8,BigInt(r),t),n}function iI(r){return r.byteOffset%4===0}function Ca(r){return Uint8Array.from(r)}var L_=r=>Uint8Array.from(r.split(""),e=>e.charCodeAt(0)),sI=L_("expand 16-byte k"),aI=L_("expand 32-byte k"),cI=Wn(sI),uI=Wn(aI);function te(r,e){return r<<e|r>>>32-e}function Lg(r){return r.byteOffset%4===0}var ah=64,fI=16,M_=2**32-1,j_=Uint32Array.of();function lI(r,e,t,n,o,i,s,a){let c=o.length,f=new Uint8Array(ah),p=Wn(f),l=Lg(o)&&Lg(i),y=l?Wn(o):j_,d=l?Wn(i):j_;for(let g=0;g<c;s++){if(r(e,t,n,p,s,a),s>=M_)throw new Error("arx: counter overflow");let C=Math.min(ah,c-g);if(l&&C===ah){let m=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let S=0,D;S<fI;S++)D=m+S,d[D]=y[D]^p[S];g+=ah;continue}for(let m=0,S;m<C;m++)S=g+m,i[S]=o[S]^f[m];g+=C}}function Mg(r,e){let{allowShortKeys:t,extendNonceFn:n,counterLength:o,counterRight:i,rounds:s}=k_({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof r!="function")throw new Error("core must be a function");return sh(o),sh(s),ih(i),ih(t),(a,c,f,p,l=0)=>{mt(a,void 0,"key"),mt(c,void 0,"nonce"),mt(f,void 0,"data");let y=f.length;if(p===void 0&&(p=new Uint8Array(y)),mt(p,void 0,"output"),sh(l),l<0||l>=M_)throw new Error("arx: counter overflow");if(p.length<y)throw new Error(`arx: output (${p.length}) is shorter than data (${y})`);let d=[],g=a.length,C,m;if(g===32)d.push(C=Ca(a)),m=uI;else if(g===16&&t)C=new Uint8Array(32),C.set(a),C.set(a,16),m=cI,d.push(C);else throw mt(a,32,"arx key"),new Error("invalid key size");Lg(c)||d.push(c=Ca(c));let S=Wn(C);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(m,S,Wn(c.subarray(0,16)),S),c=c.subarray(16)}let D=16-o;if(D!==c.length)throw new Error(`arx: nonce must be ${D} or 16 bytes`);if(D!==12){let H=new Uint8Array(12);H.set(c,i?0:12-c.length),c=H,d.push(c)}let O=Wn(c);return lI(r,m,S,O,f,p,l,s),qn(...d),p}}function Ct(r,e){return r[e++]&255|(r[e++]&255)<<8}var Ug=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;constructor(e){e=Ca(mt(e,32,"key"));let t=Ct(e,0),n=Ct(e,2),o=Ct(e,4),i=Ct(e,6),s=Ct(e,8),a=Ct(e,10),c=Ct(e,12),f=Ct(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|n<<3)&8191,this.r[2]=(n>>>10|o<<6)&7939,this.r[3]=(o>>>7|i<<9)&8191,this.r[4]=(i>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let p=0;p<8;p++)this.pad[p]=Ct(e,16+2*p)}process(e,t,n=!1){let o=n?0:2048,{h:i,r:s}=this,a=s[0],c=s[1],f=s[2],p=s[3],l=s[4],y=s[5],d=s[6],g=s[7],C=s[8],m=s[9],S=Ct(e,t+0),D=Ct(e,t+2),O=Ct(e,t+4),H=Ct(e,t+6),J=Ct(e,t+8),z=Ct(e,t+10),oe=Ct(e,t+12),j=Ct(e,t+14),P=i[0]+(S&8191),X=i[1]+((S>>>13|D<<3)&8191),Q=i[2]+((D>>>10|O<<6)&8191),$=i[3]+((O>>>7|H<<9)&8191),I=i[4]+((H>>>4|J<<12)&8191),_=i[5]+(J>>>1&8191),v=i[6]+((J>>>14|z<<2)&8191),R=i[7]+((z>>>11|oe<<5)&8191),M=i[8]+((oe>>>8|j<<8)&8191),L=i[9]+(j>>>5|o),B=0,U=B+P*a+X*(5*m)+Q*(5*C)+$*(5*g)+I*(5*d);B=U>>>13,U&=8191,U+=_*(5*y)+v*(5*l)+R*(5*p)+M*(5*f)+L*(5*c),B+=U>>>13,U&=8191;let q=B+P*c+X*a+Q*(5*m)+$*(5*C)+I*(5*g);B=q>>>13,q&=8191,q+=_*(5*d)+v*(5*y)+R*(5*l)+M*(5*p)+L*(5*f),B+=q>>>13,q&=8191;let N=B+P*f+X*c+Q*a+$*(5*m)+I*(5*C);B=N>>>13,N&=8191,N+=_*(5*g)+v*(5*d)+R*(5*y)+M*(5*l)+L*(5*p),B+=N>>>13,N&=8191;let ye=B+P*p+X*f+Q*c+$*a+I*(5*m);B=ye>>>13,ye&=8191,ye+=_*(5*C)+v*(5*g)+R*(5*d)+M*(5*y)+L*(5*l),B+=ye>>>13,ye&=8191;let xe=B+P*l+X*p+Q*f+$*c+I*a;B=xe>>>13,xe&=8191,xe+=_*(5*m)+v*(5*C)+R*(5*g)+M*(5*d)+L*(5*y),B+=xe>>>13,xe&=8191;let re=B+P*y+X*l+Q*p+$*f+I*c;B=re>>>13,re&=8191,re+=_*a+v*(5*m)+R*(5*C)+M*(5*g)+L*(5*d),B+=re>>>13,re&=8191;let Ae=B+P*d+X*y+Q*l+$*p+I*f;B=Ae>>>13,Ae&=8191,Ae+=_*c+v*a+R*(5*m)+M*(5*C)+L*(5*g),B+=Ae>>>13,Ae&=8191;let Ne=B+P*g+X*d+Q*y+$*l+I*p;B=Ne>>>13,Ne&=8191,Ne+=_*f+v*c+R*a+M*(5*m)+L*(5*C),B+=Ne>>>13,Ne&=8191;let qe=B+P*C+X*g+Q*d+$*y+I*l;B=qe>>>13,qe&=8191,qe+=_*p+v*f+R*c+M*a+L*(5*m),B+=qe>>>13,qe&=8191;let Ce=B+P*m+X*C+Q*g+$*d+I*y;B=Ce>>>13,Ce&=8191,Ce+=_*l+v*p+R*f+M*c+L*a,B+=Ce>>>13,Ce&=8191,B=(B<<2)+B|0,B=B+U|0,U=B&8191,B=B>>>13,q+=B,i[0]=U,i[1]=q,i[2]=N,i[3]=ye,i[4]=xe,i[5]=re,i[6]=Ae,i[7]=Ne,i[8]=qe,i[9]=Ce}finalize(){let{h:e,pad:t}=this,n=new Uint16Array(10),o=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=o,o=e[a]>>>13,e[a]&=8191;e[0]+=o*5,o=e[0]>>>13,e[0]&=8191,e[1]+=o,o=e[1]>>>13,e[1]&=8191,e[2]+=o,n[0]=e[0]+5,o=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+o,o=n[a]>>>13,n[a]&=8191;n[9]-=8192;let i=(o^1)-1;for(let a=0;a<10;a++)n[a]&=i;i=~i;for(let a=0;a<10;a++)e[a]=e[a]&i|n[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+t[0];e[0]=s&65535;for(let a=1;a<8;a++)s=(e[a]+t[a]|0)+(s>>>16)|0,e[a]=s&65535;qn(n)}update(e){Dg(this),mt(e),e=Ca(e);let{buffer:t,blockLen:n}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);if(s===n){for(;n<=o-i;i+=n)this.process(e,i);continue}t.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){qn(this.h,this.r,this.buffer,this.pad)}digestInto(e){Dg(this),N_(e,this),this.finished=!0;let{buffer:t,h:n}=this,{pos:o}=this;if(o){for(t[o++]=1;o<16;o++)t[o]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)e[i++]=n[s]>>>0,e[i++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}};function pI(r){let e=(n,o)=>r(o).update(n).digest(),t=r(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}var U_=pI(r=>new Ug(r));function V_(r,e,t,n,o,i=20){let s=r[0],a=r[1],c=r[2],f=r[3],p=e[0],l=e[1],y=e[2],d=e[3],g=e[4],C=e[5],m=e[6],S=e[7],D=o,O=t[0],H=t[1],J=t[2],z=s,oe=a,j=c,P=f,X=p,Q=l,$=y,I=d,_=g,v=C,R=m,M=S,L=D,B=O,U=H,q=J;for(let ye=0;ye<i;ye+=2)z=z+X|0,L=te(L^z,16),_=_+L|0,X=te(X^_,12),z=z+X|0,L=te(L^z,8),_=_+L|0,X=te(X^_,7),oe=oe+Q|0,B=te(B^oe,16),v=v+B|0,Q=te(Q^v,12),oe=oe+Q|0,B=te(B^oe,8),v=v+B|0,Q=te(Q^v,7),j=j+$|0,U=te(U^j,16),R=R+U|0,$=te($^R,12),j=j+$|0,U=te(U^j,8),R=R+U|0,$=te($^R,7),P=P+I|0,q=te(q^P,16),M=M+q|0,I=te(I^M,12),P=P+I|0,q=te(q^P,8),M=M+q|0,I=te(I^M,7),z=z+Q|0,q=te(q^z,16),R=R+q|0,Q=te(Q^R,12),z=z+Q|0,q=te(q^z,8),R=R+q|0,Q=te(Q^R,7),oe=oe+$|0,L=te(L^oe,16),M=M+L|0,$=te($^M,12),oe=oe+$|0,L=te(L^oe,8),M=M+L|0,$=te($^M,7),j=j+I|0,B=te(B^j,16),_=_+B|0,I=te(I^_,12),j=j+I|0,B=te(B^j,8),_=_+B|0,I=te(I^_,7),P=P+X|0,U=te(U^P,16),v=v+U|0,X=te(X^v,12),P=P+X|0,U=te(U^P,8),v=v+U|0,X=te(X^v,7);let N=0;n[N++]=s+z|0,n[N++]=a+oe|0,n[N++]=c+j|0,n[N++]=f+P|0,n[N++]=p+X|0,n[N++]=l+Q|0,n[N++]=y+$|0,n[N++]=d+I|0,n[N++]=g+_|0,n[N++]=C+v|0,n[N++]=m+R|0,n[N++]=S+M|0,n[N++]=D+L|0,n[N++]=O+B|0,n[N++]=H+U|0,n[N++]=J+q|0}function hI(r,e,t,n){let o=r[0],i=r[1],s=r[2],a=r[3],c=e[0],f=e[1],p=e[2],l=e[3],y=e[4],d=e[5],g=e[6],C=e[7],m=t[0],S=t[1],D=t[2],O=t[3];for(let J=0;J<20;J+=2)o=o+c|0,m=te(m^o,16),y=y+m|0,c=te(c^y,12),o=o+c|0,m=te(m^o,8),y=y+m|0,c=te(c^y,7),i=i+f|0,S=te(S^i,16),d=d+S|0,f=te(f^d,12),i=i+f|0,S=te(S^i,8),d=d+S|0,f=te(f^d,7),s=s+p|0,D=te(D^s,16),g=g+D|0,p=te(p^g,12),s=s+p|0,D=te(D^s,8),g=g+D|0,p=te(p^g,7),a=a+l|0,O=te(O^a,16),C=C+O|0,l=te(l^C,12),a=a+l|0,O=te(O^a,8),C=C+O|0,l=te(l^C,7),o=o+f|0,O=te(O^o,16),g=g+O|0,f=te(f^g,12),o=o+f|0,O=te(O^o,8),g=g+O|0,f=te(f^g,7),i=i+p|0,m=te(m^i,16),C=C+m|0,p=te(p^C,12),i=i+p|0,m=te(m^i,8),C=C+m|0,p=te(p^C,7),s=s+l|0,S=te(S^s,16),y=y+S|0,l=te(l^y,12),s=s+l|0,S=te(S^s,8),y=y+S|0,l=te(l^y,7),a=a+c|0,D=te(D^a,16),d=d+D|0,c=te(c^d,12),a=a+c|0,D=te(D^a,8),d=d+D|0,c=te(c^d,7);let H=0;n[H++]=o,n[H++]=i,n[H++]=s,n[H++]=a,n[H++]=m,n[H++]=S,n[H++]=D,n[H++]=O}var dI=Mg(V_,{counterRight:!1,counterLength:4,allowShortKeys:!1}),yI=Mg(V_,{counterRight:!1,counterLength:8,extendNonceFn:hI,allowShortKeys:!1});var mI=new Uint8Array(16),K_=(r,e)=>{r.update(e);let t=e.length%16;t&&r.update(mI.subarray(t))},gI=new Uint8Array(32);function H_(r,e,t,n,o){o!==void 0&&mt(o,void 0,"AAD");let i=r(e,t,gI),s=R_(n.length,o?o.length:0,!0),a=U_.create(i);o&&K_(a,o),K_(a,n),a.update(s);let c=a.digest();return qn(i,s),c}var $_=r=>(e,t,n)=>({encrypt(i,s){let a=i.length;s=jg(a+16,s,!1),s.set(i);let c=s.subarray(0,-16);r(e,t,c,c,1);let f=H_(r,e,t,c,n);return s.set(f,a),qn(f),s},decrypt(i,s){s=jg(i.length-16,s,!1);let a=i.subarray(0,-16),c=i.subarray(-16),f=H_(r,e,t,a,n);if(!D_(c,f))throw new Error("invalid tag");return s.set(i.subarray(0,-16)),r(e,t,s,s,1),qn(f),s}}),Kg=Rg({blockSize:64,nonceLength:12,tagLength:16},$_(dI)),mX=Rg({blockSize:64,nonceLength:24,tagLength:16},$_(yI));function W_(r,e,t){return Wo(r),t===void 0&&(t=new Uint8Array(r.outputLen)),Es(r,t,e)}var Hg=Uint8Array.of(0),F_=Uint8Array.of();function q_(r,e,t,n=32){Wo(r),ar(n,"length");let o=r.outputLen;if(n>255*o)throw new Error("Length must be <= 255*HashLen");let i=Math.ceil(n/o);t===void 0?t=F_:he(t,void 0,"info");let s=new Uint8Array(i*o),a=Es.create(r,e),c=a._cloneInto(),f=new Uint8Array(a.outputLen);for(let p=0;p<i;p++)Hg[0]=p+1,c.update(p===0?F_:f).update(t).update(Hg).digestInto(f),s.set(f,o*p),a._cloneInto(c);return a.destroy(),c.destroy(),Sr(f,Hg),s.slice(0,n)}var Vg={hashSHA256(r){return Fr(r.subarray())},getHKDF(r,e){let t=W_(Fr,e,r),o=q_(Fr,t,void 0,96),i=o.subarray(0,32),s=o.subarray(32,64),a=o.subarray(64,96);return[i,s,a]},generateX25519KeyPair(){let r=Ja.utils.randomSecretKey();return{publicKey:Ja.getPublicKey(r),privateKey:r}},generateX25519KeyPairFromSeed(r){return{publicKey:Ja.getPublicKey(r),privateKey:r}},generateX25519SharedKey(r,e){return Ja.getSharedSecret(r.subarray(),e.subarray())},chaCha20Poly1305Encrypt(r,e,t,n){return Kg(n,e,t).encrypt(r.subarray())},chaCha20Poly1305Decrypt(r,e,t,n,o){return Kg(n,e,t).decrypt(r.subarray(),o)}};var G_=Vg;function z_(r){return{generateKeypair:r.generateX25519KeyPair,dh:(e,t)=>r.generateX25519SharedKey(e.privateKey,t).subarray(0,32),encrypt:r.chaCha20Poly1305Encrypt,decrypt:r.chaCha20Poly1305Decrypt,hash:r.hashSHA256,hkdf:r.getHKDF}}var Ta=r=>{let e=ft(2);return e[0]=r>>8,e[1]=r,e};Ta.bytes=2;var Ia=r=>{if(r.length<2)throw RangeError("Could not decode int16BE");if(r instanceof Uint8Array){let e=0;return e+=r[0]<<8,e+=r[1],e}return r.getUint16(0)};Ia.bytes=2;function X_(r){return{xxHandshakeSuccesses:r.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:r.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:r.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:r.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:r.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}function $g(r,e){!e.enabled||!Ea||(r?(e(`LOCAL_STATIC_PUBLIC_KEY ${le(r.publicKey,"hex")}`),e(`LOCAL_STATIC_PRIVATE_KEY ${le(r.privateKey,"hex")}`)):e("Missing local static keys."))}function Fg(r,e){!e.enabled||!Ea||(r?(e(`LOCAL_PUBLIC_EPHEMERAL_KEY ${le(r.publicKey,"hex")}`),e(`LOCAL_PRIVATE_EPHEMERAL_KEY ${le(r.privateKey,"hex")}`)):e("Missing local ephemeral keys."))}function Y_(r,e){!e.enabled||!Ea||e(r?`REMOTE_STATIC_PUBLIC_KEY ${le(r.subarray(),"hex")}`:"Missing remote static public key.")}function Wg(r,e){!e.enabled||!Ea||e(r?`REMOTE_EPHEMERAL_PUBLIC_KEY ${le(r.subarray(),"hex")}`:"Missing remote ephemeral keys.")}function qg(r,e,t){!t.enabled||!Ea||(t(`CIPHER_STATE_1 ${r.n.getUint64()} ${r.k&&le(r.k,"hex")}`),t(`CIPHER_STATE_2 ${e.n.getUint64()} ${e.k&&le(e.k,"hex")}`))}var Oa=class r extends Error{code;constructor(e="Invalid crypto exchange"){super(e),this.code=r.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"};var bI=0,wI=4294967295,xI="Cipherstate has reached maximum n, a new handshake must be performed",ch=class{n;bytes;view;constructor(e=bI){this.n=e,this.bytes=ut(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>wI)throw new Error(xI)}};var rs=ut(0),Ba=class{k;n;crypto;constructor(e,t=void 0,n=0){this.crypto=e,this.k=t,this.n=new ch(n)}hasKey(){return!!this.k}encryptWithAd(e,t){if(!this.hasKey())return t;this.n.assertValue();let n=this.crypto.encrypt(t,this.n.getBytes(),e,this.k);return this.n.increment(),n}decryptWithAd(e,t,n){if(!this.hasKey())return t;this.n.assertValue();let o=this.crypto.decrypt(t,this.n.getBytes(),e,this.k,n);return this.n.increment(),o}},Gg=class{cs;ck;h;crypto;constructor(e,t){this.crypto=e;let n=me(t,"utf-8");this.h=vI(e,n),this.ck=this.h,this.cs=new Ba(e)}mixKey(e){let[t,n]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Ba(this.crypto,n)}mixHash(e){this.h=this.crypto.hash(new ge(this.h,e))}encryptAndHash(e){let t=this.cs.encryptWithAd(this.h,e);return this.mixHash(t),t}decryptAndHash(e){let t=this.cs.decryptWithAd(this.h,e);return this.mixHash(e),t}split(){let[e,t]=this.crypto.hkdf(this.ck,rs);return[new Ba(this.crypto,e),new Ba(this.crypto,t)]}},zg=class{ss;s;e;rs;re;initiator;crypto;constructor(e){let{crypto:t,protocolName:n,prologue:o,initiator:i,s,e:a,rs:c,re:f}=e;this.crypto=t,this.ss=new Gg(t,n),this.ss.mixHash(o),this.initiator=i,this.s=s,this.e=a,this.rs=c,this.re=f}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");let e=this.crypto.generateKeypair();return this.ss.mixHash(e.publicKey),this.e=e,e.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(e,t=0){if(this.re)throw new Error("remote ephemeral public key is already set");if(e.byteLength<t+32)throw new Error("message is not long enough");this.re=e.sublist(t,t+32),this.ss.mixHash(this.re)}readS(e,t=0){if(this.rs)throw new Error("remote static public key is already set");let n=32+(this.ss.cs.hasKey()?16:0);if(e.byteLength<t+n)throw new Error("message is not long enough");let o=e.sublist(t,t+n);return this.rs=this.ss.decryptAndHash(o),n}readEE(){this.writeEE()}readES(){this.writeES()}readSE(){this.writeSE()}},sf=class extends zg{writeMessageA(e){return new ge(this.writeE(),this.ss.encryptAndHash(e))}writeMessageB(e){let t=this.writeE();this.writeEE();let n=this.writeS();return this.writeES(),new ge(t,n,this.ss.encryptAndHash(e))}writeMessageC(e){let t=this.writeS();return this.writeSE(),new ge(t,this.ss.encryptAndHash(e))}readMessageA(e){try{return this.readE(e),this.ss.decryptAndHash(e.sublist(32))}catch(t){throw new Oa(`handshake stage 0 validation fail: ${t.message}`)}}readMessageB(e){try{this.readE(e),this.readEE();let t=this.readS(e,32);return this.readES(),this.ss.decryptAndHash(e.sublist(32+t))}catch(t){throw new Oa(`handshake stage 1 validation fail: ${t.message}`)}}readMessageC(e){try{let t=this.readS(e);return this.readSE(),this.ss.decryptAndHash(e.sublist(t))}catch(t){throw new Oa(`handshake stage 2 validation fail: ${t.message}`)}}};function vI(r,e){if(e.length<=32){let t=ut(32);return t.set(e),t}else return r.hash(e)}var uh;(function(r){let e;r.codec=()=>(e==null&&(e=Ir((t,n,o={})=>{if(o.lengthDelimited!==!1&&n.fork(),t.webtransportCerthashes!=null)for(let i of t.webtransportCerthashes)n.uint32(10),n.bytes(i);if(t.streamMuxers!=null)for(let i of t.streamMuxers)n.uint32(18),n.string(i);o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={webtransportCerthashes:[],streamMuxers:[]},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{if(o.limits?.webtransportCerthashes!=null&&i.webtransportCerthashes.length===o.limits.webtransportCerthashes)throw new sc('Decode error - map field "webtransportCerthashes" had too many elements');i.webtransportCerthashes.push(t.bytes());break}case 2:{if(o.limits?.streamMuxers!=null&&i.streamMuxers.length===o.limits.streamMuxers)throw new sc('Decode error - map field "streamMuxers" had too many elements');i.streamMuxers.push(t.string());break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(uh||(uh={}));var af;(function(r){let e;r.codec=()=>(e==null&&(e=Ir((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.identityKey!=null&&t.identityKey.byteLength>0&&(n.uint32(10),n.bytes(t.identityKey)),t.identitySig!=null&&t.identitySig.byteLength>0&&(n.uint32(18),n.bytes(t.identitySig)),t.extensions!=null&&(n.uint32(34),uh.codec().encode(t.extensions,n)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={identityKey:ut(0),identitySig:ut(0)},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.identityKey=t.bytes();break}case 2:{i.identitySig=t.bytes();break}case 4:{i.extensions=uh.codec().decode(t,t.uint32(),{limits:o.limits?.extensions});break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(af||(af={}));async function Yg(r,e,t){let n=await r.sign(J_(e));return af.encode({identityKey:Zn(r.publicKey),identitySig:n,extensions:t})}async function Zg(r,e,t){try{let n=af.decode(r),o=fc(n.identityKey);if(t?.equals(o)===!1)throw new Error(`Payload identity key ${o} does not match expected remote identity key ${t}`);if(!e)throw new Error("Remote static does not exist");let i=J_(e);if(!await o.verify(i,n.identitySig))throw new Error("Invalid payload signature");return n}catch(n){throw new lf(n.message)}}function J_(r){let e=me("noise-libp2p-static-key:");return r instanceof Uint8Array?Dt([e,r],e.length+r.length):(r.prepend(e),r)}var Xg=class extends uo{stream;handshake;metrics;decoder;constructor(e,t,n){super({log:e.log,inactivityTimeout:e.inactivityTimeout,maxReadBufferLength:e.maxReadBufferLength,direction:e.direction}),this.stream=e,this.handshake=t,this.metrics=n,this.decoder=new bl({lengthDecoder:Ia,maxBufferSize:16*1024*1024,encodingLength:()=>2});let o=c=>{try{for(let f of this.decoder.decode(c.data))this.onData(this.decrypt(f))}catch(f){this.abort(f)}};this.stream.addEventListener("message",o);let i=c=>{c.error!=null?c.local===!0?this.abort(c.error):this.onRemoteReset():this.onTransportClosed()};this.stream.addEventListener("close",i);let s=()=>{this.safeDispatchEvent("drain")};this.stream.addEventListener("drain",s);let a=()=>{this.onRemoteCloseWrite()};this.stream.addEventListener("remoteCloseWrite",a)}encrypt(e){let t=new ge;for(let n=0;n<e.byteLength;n+=65519){let o=n+65519;o>e.byteLength&&(o=e.byteLength);let i;e instanceof Uint8Array?i=this.handshake.encrypt(e.subarray(n,o)):i=this.handshake.encrypt(e.sublist(n,o)),this.metrics?.encryptedPackets.increment(),t.append(Ta(i.byteLength)),t.append(i)}return t}decrypt(e){let t=new ge;for(let n=0;n<e.byteLength;n+=65535){let o=n+65535;if(o>e.byteLength&&(o=e.byteLength),o-kg<n)throw new Error("Invalid chunk");let i;e instanceof Uint8Array?i=e.subarray(n,o):i=e.sublist(n,o);let s=e.subarray(n,o-kg);try{let a=this.handshake.decrypt(i,s);this.metrics?.decryptedPackets.increment(),t.append(a)}catch(a){throw this.metrics?.decryptErrors.increment(),a}}return t}close(e){return this.stream.close(e)}sendPause(){this.stream.pause()}sendResume(){this.stream.resume()}sendReset(e){this.stream.abort(e)}sendData(e){return{sentBytes:e.byteLength,canSendMore:this.stream.send(this.encrypt(e))}}};function Jg(r,e,t){return new Xg(r,e,t)}async function Q_(r,e){let{log:t,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:f}=r,p=await Yg(i,a.publicKey,f),l=new sf({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:s,s:a});$g(l.s,t),t.trace("Stage 0 - Initiator starting to send first message."),await n.write(l.writeMessageA(rs),e),t.trace("Stage 0 - Initiator finished sending first message."),Fg(l.e,t),t.trace("Stage 1 - Initiator waiting to receive first message from responder...");let y=l.readMessageB(await n.read(e));t.trace("Stage 1 - Initiator received the message."),Wg(l.re,t),Y_(l.rs,t),t.trace("Initiator going to check remote's signature...");let d=await Zg(y,l.rs,c);t.trace("All good with the signature!"),t.trace("Stage 2 - Initiator sending third handshake message."),await n.write(l.writeMessageC(p),e),t.trace("Stage 2 - Initiator sent message with signed payload.");let[g,C]=l.ss.split();return qg(g,C,t),{payload:d,encrypt:m=>g.encryptWithAd(rs,m),decrypt:(m,S)=>C.decryptWithAd(rs,m,S)}}async function eS(r,e){let{log:t,connection:n,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:c,extensions:f}=r,p=await Yg(i,a.publicKey,f),l=new sf({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:s,s:a});$g(l.s,t),t.trace("Stage 0 - Responder waiting to receive first message."),l.readMessageA(await n.read(e)),t.trace("Stage 0 - Responder received first message."),Wg(l.re,t),t.trace("Stage 1 - Responder sending out first message with signed payload and static key."),await n.write(l.writeMessageB(p),e),t.trace("Stage 1 - Responder sent the second handshake message with signed payload."),Fg(l.e,t),t.trace("Stage 2 - Responder waiting for third handshake message...");let y=l.readMessageC(await n.read(e));t.trace("Stage 2 - Responder received the message, finished handshake.");let d=await Zg(y,l.rs,c),[g,C]=l.ss.split();return qg(g,C,t),{payload:d,encrypt:m=>C.encryptWithAd(rs,m),decrypt:(m,S)=>g.decryptWithAd(rs,m,S)}}var fh=class{protocol="/noise";crypto;prologue;staticKey;extensions;metrics;components;log;constructor(e,t={}){let{staticNoiseKey:n,extensions:o,crypto:i,prologueBytes:s}=t,{metrics:a}=e;this.components=e,this.log=e.logger.forComponent("libp2p:noise");let c=i??G_;this.crypto=z_(c),this.extensions={webtransportCerthashes:[],...o},this.metrics=a?X_(a):void 0,n?this.staticKey=c.generateX25519KeyPairFromSeed(n):this.staticKey=c.generateX25519KeyPair(),this.prologue=s??ut(0)}[Symbol.toStringTag]="@chainsafe/libp2p-noise";[as]=["@libp2p/connection-encryption","@chainsafe/libp2p-noise"];async secureOutbound(e,t){let n=e.log?.newScope("noise")??this.log,o=ml(e,{lengthEncoder:Ta,lengthDecoder:Ia,maxDataLength:65535}),i=await this.performHandshakeInitiator(o,this.components.privateKey,n,t?.remotePeer?.publicKey,t),s=fc(i.payload.identityKey);return{connection:Jg(o.unwrap(),i,this.metrics),remoteExtensions:i.payload.extensions,remotePeer:Wd(s),streamMuxer:t?.skipStreamMuxerNegotiation===!0?void 0:this.getStreamMuxer(i.payload.extensions?.streamMuxers)}}getStreamMuxer(e){if(e==null||e.length===0)return;let t=this.components.upgrader.getStreamMuxers();if(t!=null)for(let n of e){let o=t.get(n);if(o!=null)return o}if(e.length)throw new pf("Early muxer negotiation was requested but the initiator and responder had no common muxers")}async secureInbound(e,t){let n=e.log?.newScope("noise")??this.log,o=ml(e,{lengthEncoder:Ta,lengthDecoder:Ia,maxDataLength:65535}),i=await this.performHandshakeResponder(o,this.components.privateKey,n,t?.remotePeer?.publicKey,t),s=fc(i.payload.identityKey);return{connection:Jg(o.unwrap(),i,this.metrics),remoteExtensions:i.payload.extensions,remotePeer:Wd(s),streamMuxer:t?.skipStreamMuxerNegotiation===!0?void 0:this.getStreamMuxer(i.payload.extensions?.streamMuxers)}}async performHandshakeInitiator(e,t,n,o,i){let s,a=i?.skipStreamMuxerNegotiation===!0?[]:[...this.components.upgrader.getStreamMuxers().keys()];try{s=await Q_({connection:e,privateKey:t,remoteIdentityKey:o,log:n.newScope("xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:{streamMuxers:a,webtransportCerthashes:[],...this.extensions}},i),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){throw this.metrics?.xxHandshakeErrors.increment(),c}return s}async performHandshakeResponder(e,t,n,o,i){let s,a=i?.skipStreamMuxerNegotiation===!0?[]:[...this.components.upgrader.getStreamMuxers().keys()];try{s=await eS({connection:e,privateKey:t,remoteIdentityKey:o,log:n.newScope("xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:{streamMuxers:a,webtransportCerthashes:[],...this.extensions}},i),this.metrics?.xxHandshakeSuccesses.increment()}catch(c){throw this.metrics?.xxHandshakeErrors.increment(),c}return s}};function tS(r={}){return e=>new fh(e,r)}var Qg=Object.values(Vo).map(r=>r.decoder).reduce((r,e)=>r.or(e)),_I=/^a=fingerprint:(?:\w+-[0-9]+)\s(?<fingerprint>(:?[0-9a-fA-F]{2})+)$/m;function rS(r){return r?.match(_I)?.groups?.fingerprint}function e0(r){let t=r.getComponents().find(n=>n.code===466)?.value;if(t===void 0||t==="")throw new _e(`Couldn't find a certhash component of multiaddr: ${r.toString()}`);return t}function SI(r){return xr.decode(Qg.decode(r))}function AI(r){let e=SI(e0(r)),t=EI(e.code),n=e.digest.reduce((i,s)=>i+s.toString(16).padStart(2,"0"),""),o=n.match(/.{1,2}/g);if(o==null)throw new Tl(n,r.toString());return`${t} ${o.join(":").toUpperCase()}`}function nS(r){let e=r.split(":").map(o=>parseInt(o,16)),t=Uint8Array.from(e),n=kt(sr.code,t);return Ns(`/certhash/${Ho.encode(n.bytes)}`)}function EI(r){switch(r){case 17:return"sha-1";case 18:return"sha-256";case 19:return"sha-512";default:throw new Ol(r)}}function oS(r,e){let{host:t,port:n,type:o}=Sy(r);if(o!=="ip4"&&o!=="ip6")throw new _e(`Multiaddr ${r} was not an IPv4 or IPv6 address`);let i=AI(r);return{type:"answer",sdp:`v=0
|
|
13
13
|
o=- 0 0 IN IP${o==="ip4"?4:6} ${t}
|
|
14
14
|
s=-
|
|
15
15
|
t=0 0
|
|
@@ -23,10 +23,10 @@ a=ice-pwd:${e}
|
|
|
23
23
|
a=fingerprint:${i}
|
|
24
24
|
a=setup:passive
|
|
25
25
|
a=sctp-port:5000
|
|
26
|
-
a=max-message-size:${
|
|
26
|
+
a=max-message-size:${ks}
|
|
27
27
|
a=candidate:1467250027 1 UDP 1467250027 ${t} ${n} typ host
|
|
28
28
|
a=end-of-candidates
|
|
29
|
-
`}}function
|
|
29
|
+
`}}function iS(r,e){let{host:t,port:n,type:o}=Sy(r);if(o!=="ip4"&&o!=="ip6")throw new _e(`Multiaddr ${r} was not an IPv4 or IPv6 address`);return{type:"offer",sdp:`v=0
|
|
30
30
|
o=- 0 0 IN IP${o==="ip4"?4:6} ${t}
|
|
31
31
|
s=-
|
|
32
32
|
c=IN IP${o==="ip4"?4:6} ${t}
|
|
@@ -39,16 +39,16 @@ a=ice-ufrag:${e}
|
|
|
39
39
|
a=ice-pwd:${e}
|
|
40
40
|
a=fingerprint:sha-256 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
|
|
41
41
|
a=sctp-port:5000
|
|
42
|
-
a=max-message-size:${
|
|
42
|
+
a=max-message-size:${ks}
|
|
43
43
|
a=candidate:1467250027 1 UDP 1467250027 ${t} ${n} typ host
|
|
44
44
|
a=end-of-candidates
|
|
45
|
-
`}}function
|
|
45
|
+
`}}function t0(r,e){if(r.sdp===void 0)throw new _e("Can't munge a missing SDP");let t=r.sdp.includes(`\r
|
|
46
46
|
`)?`\r
|
|
47
47
|
`:`
|
|
48
48
|
`;try{r.sdp=r.sdp.replace(/\na=ice-ufrag:[^\n]*\n/,`
|
|
49
49
|
a=ice-ufrag:`+e+t).replace(/\na=ice-pwd:[^\n]*\n/,`
|
|
50
|
-
a=ice-pwd:`+e+t)}catch{}return r}var
|
|
51
|
-
`)}var
|
|
50
|
+
a=ice-pwd:`+e+t)}catch{}return r}var r0=me("libp2p-webrtc-noise:");function aS(r,e,t){let n=r.trim().toLowerCase().replaceAll(":",""),o=me(n,"hex"),i=kt(sr.code,o),s=Qg.decode(e0(e)),a=r0.byteLength+i.bytes.byteLength+s.byteLength;return t==="server"?Dt([r0,s,i.bytes],a):Dt([r0,i.bytes,s],a)}var CI=Al?"iceconnectionstatechange":"connectionstatechange";function TI(r,e){return r.role==="server"}async function cS(r,e,t,n){let o=r.createDataChannel("",{negotiated:!0,id:0});try{if(n.role==="client"){n.log.trace("client creating local offer");let l=await r.createOffer();n.log.trace("client created local offer %s",l.sdp);let y=t0(l,t);n.log.trace("client setting local offer %s",y.sdp),await r.setLocalDescription(y);let d=oS(n.remoteAddr,t);n.log.trace("client setting server description %s",d.sdp),await r.setRemoteDescription(d)}else{let l=iS(n.remoteAddr,t);n.log.trace("server setting client %s %s",l.type,l.sdp),await r.setRemoteDescription(l),n.log.trace("server creating local answer");let y=await r.createAnswer();n.log.trace("server created local answer");let d=t0(y,t);n.log.trace("server setting local description %s",y.sdp),await r.setLocalDescription(d)}if(o.readyState!=="open"&&(n.log.trace("%s wait for handshake channel to open, starting status %s",n.role,o.readyState),await _n(o,"open",n)),n.log.trace("%s handshake channel opened",n.role),TI(n,r)){let l=r.remoteFingerprint()?.value??"";n.remoteAddr=n.remoteAddr.encapsulate(nS(l))}let i=rS(r.localDescription?.sdp);if(i==null)throw new lo("Could not get fingerprint from local description sdp");n.log.trace("%s performing noise handshake",n.role);let s=aS(i,n.remoteAddr,n.role),a=tS({prologueBytes:s})(n),c=Sc({channel:o,direction:"outbound",isHandshake:!0,log:n.log,...n.dataChannel??{}}),f=Ac({peerConnection:r,remoteAddr:n.remoteAddr,metrics:n.events,direction:n.role==="client"?"outbound":"inbound",log:n.logger.forComponent("libp2p:webrtc-direct:connection")});if(r.addEventListener(CI,()=>{switch(r.connectionState){case"failed":case"disconnected":case"closed":f.close().catch(l=>{n.log.error("error closing connection - %e",l),f.abort(l)});break;default:break}}),n.events?.increment({peer_connection:!0}),n.role==="client"){n.log.trace("%s secure inbound",n.role);let l=await a.secureInbound(c,{remotePeer:n.remotePeer,signal:n.signal,skipStreamMuxerNegotiation:!0});return n.log.trace("%s upgrade outbound",n.role),await n.upgrader.upgradeOutbound(f,{skipProtection:!0,skipEncryption:!0,remotePeer:l.remotePeer,muxerFactory:e,signal:n.signal})}n.log.trace("%s secure outbound",n.role);let p=await a.secureOutbound(c,{remotePeer:n.remotePeer,signal:n.signal,skipStreamMuxerNegotiation:!0});f.remoteAddr=f.remoteAddr.encapsulate(`/p2p/${p.remotePeer}`),n.log.trace("%s upgrade inbound",n.role),await n.upgrader.upgradeInbound(f,{skipProtection:!0,skipEncryption:!0,remotePeer:p.remotePeer,muxerFactory:e,signal:n.signal})}catch(i){throw o.close(),r.close(),i}}async function uS(r,e,t={}){let n=t.certificate;n==null&&(n=await RTCPeerConnection.generateCertificate({name:"ECDSA",namedCurve:"P-256"}));let o=typeof t.rtcConfiguration=="function"?await t.rtcConfiguration():t.rtcConfiguration,i=new RTCPeerConnection({...o??{},certificates:[n]}),s=new fo({peerConnection:i,metrics:t.events,dataChannelOptions:t.dataChannel});return{peerConnection:i,muxerFactory:s}}async function fS(r){let e=await Gf(r),t=await crypto.subtle.exportKey("pkcs8",e.privateKey);return["-----BEGIN PRIVATE KEY-----",...le(new Uint8Array(t),"base64pad").split(/(.{64})/).filter(Boolean),"-----END PRIVATE KEY-----"].join(`
|
|
51
|
+
`)}var lh=class{log;metrics;components;init;certificate;privateKey;emitter;renewCertificateTask;constructor(e,t={}){if(this.log=e.logger.forComponent("libp2p:webrtc-direct"),this.components=e,this.init=t,this.emitter=new ir,t.certificateLifespan!=null&&t.certificateRenewalThreshold!=null&&t.certificateRenewalThreshold>=t.certificateLifespan)throw new _e("Certificate renewal threshold must be less than certificate lifespan");e.metrics!=null&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_webrtc-direct_dialer_events_total",{label:"event",help:"Total count of WebRTC-direct dial events by type"})})}[Sf]=!0;[Symbol.toStringTag]="@libp2p/webrtc-direct";[as]=["@libp2p/transport"];async start(){this.certificate=await this.getCertificate()}async stop(){this.renewCertificateTask!=null&&clearTimeout(this.renewCertificateTask),this.certificate=void 0}async dial(e,t){this.log("dial %a",e),t.signal.throwIfAborted();let n,o=e.getComponents().findLast(c=>c.code===421)?.value;o!=null&&(n=Ts(o));let i=fx(),{peerConnection:s,muxerFactory:a}=await uS("client",i,{rtcConfiguration:typeof this.init.rtcConfiguration=="function"?await this.init.rtcConfiguration():this.init.rtcConfiguration??{},dataChannel:this.init.dataChannel});try{return await cS(s,a,i,{role:"client",log:this.log,logger:this.components.logger,events:this.metrics?.dialerEvents,signal:t.signal,remoteAddr:e,dataChannel:this.init.dataChannel,upgrader:t.upgrader,peerId:this.components.peerId,remotePeer:n,privateKey:this.components.privateKey})}catch(c){throw s.close(),c}}createListener(e){if(this.certificate==null)throw new wf;return new oh(this.components,{...this.init,...e,certificate:this.certificate,emitter:this.emitter})}listenFilter(e){return e.filter(Kw.exactMatch)}dialFilter(e){return this.listenFilter(e)}async getCertificate(e){if(II(this.init.certificate))return this.log("using provided TLS certificate"),this.init.certificate;let t=await this.loadOrCreatePrivateKey(),{pem:n,certhash:o}=await this.loadOrCreateCertificate(t,e);return{privateKey:await fS(t),pem:n,certhash:o}}async loadOrCreatePrivateKey(){if(this.privateKey!=null)return this.privateKey;let e=this.init.certificateKeychainName??Yw,t=this.getKeychain();try{if(t==null)throw this.log("no keychain configured - not checking for stored private key"),new Uo;this.log.trace("checking for stored private key"),this.privateKey=await t.exportKey(e)}catch(n){if(n.name!=="NotFoundError")throw n;this.log.trace("generating private key"),this.privateKey=await hw("ECDSA","P-256"),t!=null?(this.log.trace("storing private key"),await t.importKey(e,this.privateKey)):this.log("no keychain configured - not storing private key")}return this.privateKey}async loadOrCreateCertificate(e,t){if(this.certificate!=null&&t!==!0)return this.certificate;let n,o=new of(this.init.certificateDatastoreKey??Xw),i=await Gf(e);try{if(t===!0)throw this.log.trace("forcing renewal of TLS certificate"),new Uo;this.log.trace("checking for stored TLS certificate"),n=await this.loadCertificate(o,i)}catch(a){if(a.name!=="NotFoundError")throw a;this.log.trace("generating new TLS certificate"),n=await this.createCertificate(o,i)}let s=n.notAfter.getTime()-(this.init.certificateRenewalThreshold??_y)-Date.now();return s<0&&(s=100),this.log("will renew TLS certificate after %d ms",s),this.renewCertificateTask=setTimeout(()=>{this.log("renewing TLS certificate"),this.getCertificate(!0).then(a=>{this.certificate=a,this.emitter.safeDispatchEvent("certificate:renew",{detail:a})}).catch(a=>{this.log.error("could not renew certificate - %e",a)})},s),{pem:n.toString("pem"),certhash:Ho.encode((await sr.digest(new Uint8Array(n.rawData))).bytes)}}async loadCertificate(e,t){let n=await this.components.datastore.get(e),o=new Aa(n),i=o.notAfter.getTime()-(this.init.certificateRenewalThreshold??_y);if(Date.now()>i)throw this.log("stored TLS certificate has expired"),new Uo;this.log("loaded certificate, expires in %d ms",i);let s=await o.publicKey.export(crypto),a=await crypto.subtle.exportKey("raw",s),c=await crypto.subtle.exportKey("raw",t.publicKey);if(!Ze(new Uint8Array(a,0,a.byteLength),new Uint8Array(c,0,c.byteLength)))throw this.log("stored TLS certificate public key did not match public key from private key"),new Uo;return this.log("loaded certificate, expiry time is %o",i),o}async createCertificate(e,t){let n=new Date,o=new Date(Date.now()+(this.init.certificateLifespan??Zw));n.setMilliseconds(0),o.setMilliseconds(0);let i=await rh.createSelfSigned({serialNumber:(BigInt(Math.random().toString().replace(".",""))*100000n).toString(16),name:"CN=example.com, C=US, L=CA, O=example, ST=CA",notBefore:n,notAfter:o,keys:t,extensions:[new va(!1,void 0,!0)]},crypto);return this.getKeychain()!=null?(this.log.trace("storing TLS certificate"),await this.components.datastore.put(e,me(i.toString("pem")))):this.log("no keychain is configured so not storing TLS certificate since the private key will not be reused"),i}getKeychain(){try{return this.components.keychain}catch{}}};function II(r){return r==null?!1:typeof r.privateKey=="string"&&typeof r.pem=="string"&&typeof r.certhash=="string"}function OI(r){return e=>new lh(e,r)}function BI(r){return e=>new kl(e,r)}return ES(PI);})();
|
|
52
52
|
/*! Bundled license information:
|
|
53
53
|
|
|
54
54
|
reflect-metadata/Reflect.js:
|