/*!
 * MIT License
 * 
 * Copyright (c) Peculiar Ventures. All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 */
var x509=function(e){"use strict";var t,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={};!function(){return t||(t=1,function(e){!function(){var t="object"==typeof globalThis?globalThis:"object"==typeof r?r:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),i=n(e);function n(e,t){return function(r,i){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:i}),t&&t(r,i)}}void 0!==t.Reflect&&(i=n(t.Reflect,i)),function(e,t){var r=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,n=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,l={create:o?function(){return he(Object.create(null))}:a?function(){return he({__proto__:null})}:function(){return he({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),h="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:le(),f="function"==typeof WeakMap?WeakMap:ue(),y=i?Symbol.for("@reflect-metadata:registry"):void 0,d=ne(),g=se(d);function v(e,t,r,i){if(D(r)){if(!z(e))throw new TypeError;if(!G(t))throw new TypeError;return E(e,t)}if(!z(e))throw new TypeError;if(!M(t))throw new TypeError;if(!M(i)&&!D(i)&&!L(i))throw new TypeError;return L(i)&&(i=void 0),O(e,t,r=W(r),i)}function m(e,t){function r(r,i){if(!M(r))throw new TypeError;if(!D(i)&&!J(i))throw new TypeError;U(e,t,r,i)}return r}function w(e,t,r,i){if(!M(r))throw new TypeError;return D(i)||(i=W(i)),U(e,t,r,i)}function b(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),N(e,t,r)}function A(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),I(e,t,r)}function S(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),T(e,t,r)}function x(e,t,r){if(!M(t))throw new TypeError;return D(r)||(r=W(r)),j(e,t,r)}function B(e,t){if(!M(e))throw new TypeError;return D(t)||(t=W(t)),P(e,t)}function k(e,t){if(!M(e))throw new TypeError;return D(t)||(t=W(t)),R(e,t)}function C(e,t,r){if(!M(t))throw new TypeError;if(D(r)||(r=W(r)),!M(t))throw new TypeError;D(r)||(r=W(r));var i=ae(t,r,!1);return!D(i)&&i.OrdinaryDeleteMetadata(e,t,r)}function E(e,t){for(var r=e.length-1;r>=0;--r){var i=(0,e[r])(t);if(!D(i)&&!L(i)){if(!G(i))throw new TypeError;t=i}}return t}function O(e,t,r,i){for(var n=e.length-1;n>=0;--n){var s=(0,e[n])(t,r,i);if(!D(s)&&!L(s)){if(!M(s))throw new TypeError;i=s}}return i}function N(e,t,r){if(I(e,t,r))return!0;var i=re(t);return!L(i)&&N(e,i,r)}function I(e,t,r){var i=ae(t,r,!1);return!D(i)&&F(i.OrdinaryHasOwnMetadata(e,t,r))}function T(e,t,r){if(I(e,t,r))return j(e,t,r);var i=re(t);return L(i)?void 0:T(e,i,r)}function j(e,t,r){var i=ae(t,r,!1);if(!D(i))return i.OrdinaryGetOwnMetadata(e,t,r)}function U(e,t,r,i){ae(r,i,!0).OrdinaryDefineOwnMetadata(e,t,r,i)}function P(e,t){var r=R(e,t),i=re(e);if(null===i)return r;var n=P(i,t);if(n.length<=0)return r;if(r.length<=0)return n;for(var s=new p,o=[],a=0,c=r;a<c.length;a++){var l=c[a];s.has(l)||(s.add(l),o.push(l))}for(var u=0,h=n;u<h.length;u++){l=h[u];s.has(l)||(s.add(l),o.push(l))}return o}function R(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function V(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function D(e){return void 0===e}function L(e){return null===e}function H(e){return"symbol"==typeof e}function M(e){return"object"==typeof e?null!==e:"function"==typeof e}function $(e,t){switch(V(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r="string",i=Z(e,n);if(void 0!==i){var s=i.call(e,r);if(M(s))throw new TypeError;return s}return K(e)}function K(e,t){var r,i,n=e.toString;if(q(n)&&!M(i=n.call(e)))return i;if(q(r=e.valueOf)&&!M(i=r.call(e)))return i;throw new TypeError}function F(e){return!!e}function _(e){return""+e}function W(e){var t=$(e);return H(t)?t:_(t)}function z(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function q(e){return"function"==typeof e}function G(e){return"function"==typeof e}function J(e){switch(V(e)){case 3:case 4:return!0;default:return!1}}function X(e,t){return e===t||e!=e&&t!=t}function Z(e,t){var r=e[t];if(null!=r){if(!q(r))throw new TypeError;return r}}function Y(e){var t=Z(e,s);if(!q(t))throw new TypeError;var r=t.call(e);if(!M(r))throw new TypeError;return r}function Q(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,i=r&&Object.getPrototypeOf(r);if(null==i||i===Object.prototype)return t;var n=i.constructor;return"function"!=typeof n||n===e?t:n}function ie(){var e,r,i,n;D(y)||void 0===t.Reflect||y in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new f,o={registerProvider:a,getProvider:l,setProvider:d};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case D(r):r=t;break;case r===t:break;case D(i):i=t;break;case i===t:break;default:void 0===n&&(n=new p),n.add(t)}}function c(t,s){if(!D(r)){if(r.isProviderFor(t,s))return r;if(!D(i)){if(i.isProviderFor(t,s))return r;if(!D(n))for(var o=Y(n);;){var a=ee(o);if(!a)return;var c=Q(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!D(e)&&e.isProviderFor(t,s))return e}function l(e,t){var r,i=s.get(e);return D(i)||(r=i.get(t)),D(r)?(D(r=c(e,t))||(D(i)&&(i=new h,s.set(e,i)),i.set(t,r)),r):r}function u(e){if(D(e))throw new TypeError;return r===e||i===e||!D(n)&&n.has(e)}function d(e,t,r){if(!u(r))throw new Error("Metadata provider not registered.");var i=l(e,t);if(i!==r){if(!D(i))return!1;var n=s.get(e);D(n)&&(n=new h,s.set(e,n)),n.set(t,r)}return!0}}function ne(){var e;return!D(y)&&M(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[y]),D(e)&&(e=ie()),!D(y)&&M(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,y,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new f,r={isProviderFor:function(e,r){var i=t.get(e);return!D(i)&&i.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return d.registerProvider(r),r;function i(i,n,s){var o=t.get(i),a=!1;if(D(o)){if(!s)return;o=new h,t.set(i,o),a=!0}var c=o.get(n);if(D(c)){if(!s)return;if(c=new h,o.set(n,c),!e.setProvider(i,n,r))throw o.delete(n),a&&t.delete(i),new Error("Wrong provider for target.")}return c}function n(e,t,r){var n=i(t,r,!1);return!D(n)&&F(n.has(e))}function s(e,t,r){var n=i(t,r,!1);if(!D(n))return n.get(e)}function o(e,t,r,n){i(r,n,!0).set(e,t)}function a(e,t){var r=[],n=i(e,t,!1);if(D(n))return r;for(var s=Y(n.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=Q(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,n){var s=i(r,n,!1);if(D(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);D(o)||(o.delete(n),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,i=e.getOwnMetadata,n=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new f;return{isProviderFor:function(e,t){var r=o.get(e);return!(D(r)||!r.has(t))||!!n(e,t).length&&(D(r)&&(r=new p,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:n,OrdinaryDeleteMetadata:s}}function ae(e,t,r){var i=d.getProvider(e,t);if(!D(i))return i;if(r){if(d.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var i=this._keys.length,n=r+1;n<i;n++)this._keys[n-1]=this._keys[n],this._values[n-1]=this._values[n];return this._keys.length--,this._values.length--,X(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,n)},t.prototype.entries=function(){return new r(this._keys,this._values,o)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!X(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(X(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function i(e,t){return e}function n(e,t){return t}function o(e,t){return[e,t]}}function le(){return function(){function e(){this._map=new h}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}()}function ue(){var e=16,t=l.create(),i=n();return function(){function e(){this._key=n()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&l.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?l.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=n()},e}();function n(){var e;do{e="@@WeakMap@@"+c()}while(l.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,i)){if(!t)return;Object.defineProperty(e,i,{value:l.create()})}return e[i]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",i=0;i<e;++i){var n=t[i];4!==i&&6!==i&&8!==i||(r+="-"),n<16&&(r+="0"),r+=n.toString(16).toLowerCase()}return r}}function he(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",m),e("defineMetadata",w),e("hasMetadata",b),e("hasOwnMetadata",A),e("getMetadata",S),e("getOwnMetadata",x),e("getMetadataKeys",B),e("getOwnMetadataKeys",k),e("deleteMetadata",C)}(i,t),void 0===t.Reflect&&(t.Reflect=e)}()}(e||(e={}))),i;var e}();class n{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&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){const r=n.toUint8Array(e),i=n.toUint8Array(t);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}static concat(...e){let t;t=!Array.isArray(e[0])||e[1]instanceof Function?Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e:e[0];let r=0;for(const e of t)r+=e.byteLength;const i=new Uint8Array(r);let n=0;for(const e of t){const t=this.toUint8Array(e);i.set(t,n),n+=t.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const s="string",o=/^[0-9a-f\s]+$/i,a=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,c=/^[a-zA-Z0-9-_]+$/;class l{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer}static toString(e){const t=n.toUint8Array(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return decodeURIComponent(escape(r))}}class u{static toString(e,t=!1){const r=n.toArrayBuffer(e),i=new DataView(r);let s="";for(let e=0;e<r.byteLength;e+=2){const r=i.getUint16(e,t);s+=String.fromCharCode(r)}return s}static fromString(e,t=!1){const r=new ArrayBuffer(2*e.length),i=new DataView(r);for(let r=0;r<e.length;r++)i.setUint16(2*r,e.charCodeAt(r),t);return r}}class h{static isHex(e){return typeof e===s&&o.test(e)}static isBase64(e){return typeof e===s&&a.test(e)}static isBase64Url(e){return typeof e===s&&c.test(e)}static ToString(e,t="utf8"){const r=n.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return u.toString(r,!0);case"utf16":case"utf16be":return u.toString(r);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 u.fromString(e,!0);case"utf16":case"utf16be":return u.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=n.toUint8Array(e);if("undefined"!=typeof btoa){const e=this.ToString(t,"binary");return btoa(e)}return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!h.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!h.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=h.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return l.fromString(e);case"utf16":case"utf16be":return u.fromString(e);case"utf16le":case"usc2":return u.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=h.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return l.toString(e);case"utf16":case"utf16be":return u.toString(e);case"utf16le":case"usc2":return u.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.charCodeAt(i);return r.buffer}static ToBinary(e){const t=n.toUint8Array(e);let r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return r}static ToHex(e){const t=n.toUint8Array(e);let r="";const i=t.length;for(let e=0;e<i;e++){const i=t[e];i<16&&(r+="0"),r+=i.toString(16)}return r}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!h.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const i=t.slice(e,e+2);r[e/2]=parseInt(i,16)}return r.buffer}static ToUtf16String(e,t=!1){return u.toString(e,t)}static FromUtf16String(e,t=!1){return u.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null==e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}function p(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==i[t])return!1;return!0}
/*!
	 Copyright (c) Peculiar Ventures, LLC
	*/function f(e,t){let r=0;if(1===e.length)return e[0];for(let i=e.length-1;i>=0;i--)r+=e[e.length-1-i]*Math.pow(2,t*i);return r}function y(e,t,r=-1){const i=r;let n=e,s=0,o=Math.pow(2,t);for(let r=1;r<8;r++){if(e<o){let e;if(i<0)e=new ArrayBuffer(r),s=r;else{if(i<r)return new ArrayBuffer(0);e=new ArrayBuffer(i),s=i}const o=new Uint8Array(e);for(let e=r-1;e>=0;e--){const r=Math.pow(2,e*t);o[s-e-1]=Math.floor(n/r),n-=o[s-e-1]*r}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function d(...e){let t=0,r=0;for(const r of e)t+=r.length;const i=new ArrayBuffer(t),n=new Uint8Array(i);for(const t of e)n.set(t,r),r+=t.length;return n}function g(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&!(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)r[e]=0;r[0]=128&e[0];const i=f(r,8),n=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(n);for(let t=0;t<this.valueHex.byteLength;t++)s[t]=e[t];s[0]&=127;return f(s,8)-i}function v(e,t){const r=e.toString(10);if(t<r.length)return"";const i=t-r.length,n=new Array(i);for(let e=0;e<i;e++)n[e]="0";return n.join("").concat(r)}
/*!
	 * Copyright (c) 2014, GMO GlobalSign
	 * Copyright (c) 2015-2022, Peculiar Ventures
	 * All rights reserved.
	 * 
	 * Author 2014-2019, Yury Strozhevsky
	 * 
	 * Redistribution and use in source and binary forms, with or without modification,
	 * are permitted provided that the following conditions are met:
	 * 
	 * * Redistributions of source code must retain the above copyright notice, this
	 *   list of conditions and the following disclaimer.
	 * 
	 * * Redistributions in binary form must reproduce the above copyright notice, this
	 *   list of conditions and the following disclaimer in the documentation and/or
	 *   other materials provided with the distribution.
	 * 
	 * * Neither the name of the copyright holder nor the names of its
	 *   contributors may be used to endorse or promote products derived from
	 *   this software without specific prior written permission.
	 * 
	 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
	 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
	 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
	 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
	 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
	 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
	 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
	 * 
	 */function m(){if("undefined"==typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function w(e){let t=0,r=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const i=new Uint8Array(t);for(let t=0;t<e.length;t++){const n=e[t];i.set(new Uint8Array(n),r),r+=n.byteLength}return i.buffer}function b(e,t,r,i){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):i<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-i<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}h.DEFAULT_UTF8_ENCODING="utf8";class A{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return w(this.items)}}const S=[new Uint8Array([1])],x="0123456789",B="name",k="valueHexView",C="",E=new ArrayBuffer(0),O=new Uint8Array(0),N="EndOfContent",I="OCTET STRING",T="BIT STRING";function j(e){var t;return(t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){var t;super(...e);const r=e[0]||{};this.isHexOnly=null!==(t=r.isHexOnly)&&void 0!==t&&t,this.valueHexView=r.valueHex?n.toUint8Array(r.valueHex):O}fromBER(e,t,r){const i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!b(this,i,t,r))return-1;const n=t+r;return this.valueHexView=i.subarray(t,n),this.valueHexView.length?(this.blockLength=r,n):(this.warnings.push("Zero buffer length"),t)}toBER(e=!1){return this.isHexOnly?e?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",E)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:h.ToHex(this.valueHexView)}}}).NAME="hexBlock",t}class U{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="",warnings:r=[],valueBeforeDecode:i=O}={}){this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=n.toUint8Array(i)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:h.ToHex(this.valueBeforeDecodeView)}}}U.NAME="baseBlock";class P extends U{fromBER(e,t,r){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'")}}P.NAME="valueBlock";class R extends(j(U)){constructor({idBlock:e={}}={}){var t,r,i,s;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?n.toUint8Array(e.valueHex):O,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(i=e.tagNumber)&&void 0!==i?i:-1,this.isConstructed=null!==(s=e.isConstructed)&&void 0!==s&&s):(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",E}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=y(this.tagNumber,7),i=new Uint8Array(r),n=r.byteLength,s=new Uint8Array(n+1);if(s[0]=31|t,!e){for(let e=0;e<n-1;e++)s[e+1]=128|i[e];s[n]=i[n-1]}return s.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;const s=i.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;switch(192&s[0]){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=!(32&~s[0]),this.isHexOnly=!1;const o=31&s[0];if(31!==o)this.tagNumber=o,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&s[e];){if(t[e-1]=127&s[e],e++,e>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&s[e];const i=new Uint8Array(e);for(let r=0;r<e;r++)i[r]=t[r];t=this.valueHexView=new Uint8Array(e),t.set(i),this.blockLength<=9?this.tagNumber=f(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&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}}}R.NAME="identificationBlock";class V extends U{constructor({lenBlock:e={}}={}){var t,r,i;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(i=e.length)&&void 0!==i?i:0}fromBER(e,t,r){const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;const s=i.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;if(255===s[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===s[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&s[0]),!1===this.longFormUsed)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=127&s[0];if(o>8)return this.error="Too big integer",-1;if(o+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const a=t+1,c=i.subarray(a,a+o);return 0===c[o-1]&&this.warnings.push("Needlessly long encoded length"),this.length=f(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){const i=y(this.length,8);if(i.byteLength>127)return this.error="Too big length",E;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const n=new Uint8Array(i);r=new Uint8Array(t),r[0]=128|i.byteLength;for(let e=0;e<i.byteLength;e++)r[e+1]=n[e];return t}return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}V.NAME="lengthBlock";const D={};class L extends U{constructor({name:e="",optional:t=!1,primitiveSchema:r,...i}={},n){super(i),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new R(i),this.lenBlock=new V(i),this.valueBlock=n?new n(i):new P(i)}fromBER(e,t,r){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(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),i)}toBER(e,t){const r=t||new A;t||H(this);const i=this.idBlock.toBER(e);if(r.write(i),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const i=this.lenBlock.toBER(e);r.write(i),r.write(t)}return t?E:r.final()}toJSON(){const 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"ascii"===e?this.onAsciiEncoding():h.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${h.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}(this.toBER(),e.toBER())}}function H(e){var t;if(e instanceof D.Constructed)for(const t of e.valueBlock.value)H(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!(null===(t=e.lenBlock)||void 0===t?void 0:t.isIndefiniteForm)}L.NAME="BaseBlock";class M extends L{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e="",...t}={},r){super(t,r),e&&this.fromString(e)}fromBER(e,t,r){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}M.NAME="BaseStringBlock";class $ extends(j(P)){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}var K,F,_,W,z,q;$.NAME="PrimitiveValueBlock";class G extends L{constructor(e={}){super(e,$),this.idBlock.isConstructed=!1}}function J(e,t=0,r=e.length){const i=t;let n=new L({},P);const s=new U;if(!b(s,e,t,r))return n.error=s.error,{offset:-1,result:n};if(!e.subarray(t,t+r).length)return n.error="Zero buffer length",{offset:-1,result:n};let o=n.idBlock.fromBER(e,t,r);if(n.idBlock.warnings.length&&n.warnings.concat(n.idBlock.warnings),-1===o)return n.error=n.idBlock.error,{offset:-1,result:n};if(t=o,r-=n.idBlock.blockLength,o=n.lenBlock.fromBER(e,t,r),n.lenBlock.warnings.length&&n.warnings.concat(n.lenBlock.warnings),-1===o)return n.error=n.lenBlock.error,{offset:-1,result:n};if(t=o,r-=n.lenBlock.blockLength,!n.idBlock.isConstructed&&n.lenBlock.isIndefiniteForm)return n.error="Indefinite length form used for primitive encoding form",{offset:-1,result:n};let a=L;if(1===n.idBlock.tagClass){if(n.idBlock.tagNumber>=37&&!1===n.idBlock.isHexOnly)return n.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:n};switch(n.idBlock.tagNumber){case 0:if(n.idBlock.isConstructed&&n.lenBlock.length>0)return n.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:n};a=D.EndOfContent;break;case 1:a=D.Boolean;break;case 2:a=D.Integer;break;case 3:a=D.BitString;break;case 4:a=D.OctetString;break;case 5:a=D.Null;break;case 6:a=D.ObjectIdentifier;break;case 10:a=D.Enumerated;break;case 12:a=D.Utf8String;break;case 13:a=D.RelativeObjectIdentifier;break;case 14:a=D.TIME;break;case 15:return n.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:n};case 16:a=D.Sequence;break;case 17:a=D.Set;break;case 18:a=D.NumericString;break;case 19:a=D.PrintableString;break;case 20:a=D.TeletexString;break;case 21:a=D.VideotexString;break;case 22:a=D.IA5String;break;case 23:a=D.UTCTime;break;case 24:a=D.GeneralizedTime;break;case 25:a=D.GraphicString;break;case 26:a=D.VisibleString;break;case 27:a=D.GeneralString;break;case 28:a=D.UniversalString;break;case 29:a=D.CharacterString;break;case 30:a=D.BmpString;break;case 31:a=D.DATE;break;case 32:a=D.TimeOfDay;break;case 33:a=D.DateTime;break;case 34:a=D.Duration;break;default:{const e=n.idBlock.isConstructed?new D.Constructed:new D.Primitive;e.idBlock=n.idBlock,e.lenBlock=n.lenBlock,e.warnings=n.warnings,n=e}}}else a=n.idBlock.isConstructed?D.Constructed:D.Primitive;return n=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(n,a),o=n.fromBER(e,t,n.lenBlock.isIndefiniteForm?r:n.lenBlock.length),n.valueBeforeDecodeView=e.subarray(i,i+n.blockLength),{offset:o,result:n}}function X(e){if(!e.byteLength){const e=new L({},P);return e.error="Input buffer has zero length",{offset:-1,result:e}}return J(n.toUint8Array(e).slice(),0,e.byteLength)}function Z(e,t){return e?1:t}K=G,D.Primitive=K,G.NAME="PRIMITIVE";class Y extends P{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Z(this.isIndefiniteForm,r)>0;){const e=J(i,s,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===N)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===N?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const r=t||new A;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,r);return t?E:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Y.NAME="ConstructedValueBlock";class Q extends L{constructor(e={}){super(e,Y),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===i?(this.error=this.valueBlock.error,i):(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),i)}onAsciiEncoding(){const e=[];for(const t of this.valueBlock.value)e.push(t.toString("ascii").split("\n").map(e=>`  ${e}`).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}F=Q,D.Constructed=F,Q.NAME="CONSTRUCTED";class ee extends P{fromBER(e,t,r){return t}toBER(e){return E}}ee.override="EndOfContentValueBlock";class te extends L{constructor(e={}){super(e,ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}_=te,D.EndOfContent=_,te.NAME=N;class re extends L{constructor(e={}){super(e,P),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){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+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}W=re,D.Null=W,re.NAME="NULL";class ie extends(j(P)){get value(){for(const 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=n.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,r){const i=n.toUint8Array(e);return b(this,i,t,r)?(this.valueHexView=i.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,g.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}ie.NAME="BooleanValueBlock";class ne extends L{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,ie),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}z=ne,D.Boolean=z,ne.NAME="BOOLEAN";class se extends(j(Y)){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Y.prototype.fromBER.call(this,e,t,r),-1===i)return i;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===N){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==I)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,r),this.blockLength=r;return i}toBER(e,t){return this.isConstructed?Y.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}se.NAME="OctetStringValueBlock";let oe=class extends L{constructor({idBlock:e={},lenBlock:t={},...r}={}){var i,n;null!==(i=r.isConstructed)&&void 0!==i||(r.isConstructed=!!(null===(n=r.value)||void 0===n?void 0:n.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},se),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(i.byteLength){const e=J(i,0,i.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch(e){}}return super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Q.prototype.onAsciiEncoding.call(this);return`${this.constructor.NAME} : ${h.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof q&&e.push(t.valueBlock.valueHexView);return n.concat(e)}};q=oe,D.OctetString=q,oe.NAME=I;class ae extends(j(Y)){constructor({unusedBits:e=0,isConstructed:t=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let i=-1;if(this.isConstructed){if(i=Y.prototype.fromBER.call(this,e,t,r),-1===i)return i;for(const e of this.value){const t=e.constructor.NAME;if(t===N){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==T)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return i}const s=n.toUint8Array(e);if(!b(this,s,t,r))return-1;const o=s.subarray(t,t+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=o.subarray(1);try{if(e.byteLength){const t=J(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch(e){}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+r}toBER(e,t){if(this.isConstructed)return Y.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return E;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}var ce;ae.NAME="BitStringValueBlock";let le=class extends L{constructor({idBlock:e={},lenBlock:t={},...r}={}){var i,n;null!==(i=r.isConstructed)&&void 0!==i||(r.isConstructed=!!(null===(n=r.value)||void 0===n?void 0:n.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},ae),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Q.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};var ue,he,pe,fe,ye,de,ge;function ve(e,t){const r=new Uint8Array([0]),i=new Uint8Array(e),n=new Uint8Array(t);let s=i.slice(0);const o=s.length-1,a=n.slice(0),c=a.length-1;let l=0;let u=0;for(let e=c<o?o:c;e>=0;e--,u++){if(!0==u<a.length)l=s[o-u]+a[c-u]+r[0];else l=s[o-u]+r[0];if(r[0]=l/10,!0==u>=s.length)s=d(new Uint8Array([l%10]),s);else s[o-u]=l%10}return r[0]>0&&(s=d(r,s)),s}function me(e){if(e>=S.length)for(let t=S.length;t<=e;t++){const e=new Uint8Array([0]);let r=S[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const i=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=i[0]/10,r[t]=i[0]%10}e[0]>0&&(r=d(e,r)),S.push(r)}return S[e]}function we(e,t){let r=0;const i=new Uint8Array(e),n=new Uint8Array(t),s=i.slice(0),o=s.length-1,a=n.slice(0),c=a.length-1;let l,u=0;for(let e=c;e>=0;e--,u++)if(l=s[o-u]-a[c-u]-r,!0==l<0)r=1,s[o-u]=l+10;else r=0,s[o-u]=l;if(r>0)for(let e=o-c+1;e>=0;e--,u++){if(l=s[o-u]-r,!(l<0)){r=0,s[o-u]=l;break}r=1,s[o-u]=l+10}return s.slice()}ce=le,D.BitString=ce,le.NAME=T;class be extends(j(P)){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=g.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let i=1;i<8;i++){if(t<=r){if(e<0){const e=y(r-t,8,i);return new Uint8Array(e)[0]|=128,e}let n=y(t,8,i),s=new Uint8Array(n);if(128&s[0]){const e=n.slice(0),t=new Uint8Array(e);n=new ArrayBuffer(n.byteLength+1),s=new Uint8Array(n);for(let r=0;r<e.byteLength;r++)s[r+1]=t[r];s[0]=0}return n}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r,i=0){const n=this.fromBER(e,t,r);if(-1===n)return n;const s=this.valueHexView;return 0===s[0]&&128&s[1]?this.valueHexView=s.subarray(1):0!==i&&s.length<i&&(i-s.length>1&&(i=s.length+1),this.valueHexView=s.subarray(i-s.length)),n}toDER(e=!1){const t=this.valueHexView;switch(!0){case!!(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&!(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const i=super.fromBER(e,t,r);return-1===i||this.setValueHex(),i}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),i=0;const n=this.valueHexView;let s="",o=!1;for(let o=n.byteLength-1;o>=0;o--){t=n[o];for(let n=0;n<8;n++){if(!(1&~t))if(i===e)r=we(me(i),r),s="-";else r=ve(r,me(i));i++,t>>=1}}for(let e=0;e<r.length;e++)r[e]&&(o=!0),o&&(s+=x.charAt(r[e]));return!1===o&&(s+=x.charAt(0)),s}}ue=be,be.NAME="IntegerValueBlock",Object.defineProperty(ue.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class Ae extends L{constructor(e={}){super(e,be),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return m(),BigInt(this.valueBlock.toString())}static fromBigInt(e){m();const t=BigInt(e),r=new A,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(h.FromHex(i));if(t<0){const e=new Uint8Array(s.length+(128&s[0]?1:0));e[0]|=128;const i=BigInt(`0x${h.ToHex(e)}`)+t,o=n.toUint8Array(h.FromHex(i.toString(16)));o[0]|=128,r.write(o)}else 128&s[0]&&r.write(new Uint8Array([0])),r.write(s);return new he({valueHex:r.final()})}convertToDER(){const e=new he({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new he({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}he=Ae,D.Integer=he,Ae.NAME="INTEGER";class Se extends Ae{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}pe=Se,D.Enumerated=pe,Se.NAME="ENUMERATED";class xe extends(j(P)){constructor({valueDec:e=-1,isFirstSid:t=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;const s=i.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const o=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)o[e]=this.valueHexView[e];return this.valueHexView=o,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=f(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){m();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let e=0;e<r.length;e++)r[e]=parseInt(t.slice(7*e,7*e+7),2)+(e+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=y(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",E;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),i=t.byteLength-1;for(let t=0;t<i;t++)r[t]=128|e[t];r[i]=e[i]}return r}toString(){let e="";if(this.isHexOnly)e=h.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}}}xe.NAME="sidBlock";class Be extends P{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let i=t;for(;r>0;){const t=new xe;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const i=this.value[r].toBER(e);if(0===i.byteLength)return this.error=this.value[r].error,E;t.push(i)}return w(t)}fromString(e){this.value=[];let t=0,r=0,i="",n=!1;do{if(r=e.indexOf(".",t),i=-1===r?e.substring(t):e.substring(t,r),t=r+1,n){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(i,10);if(isNaN(r))return;e.valueDec=r+t,n=!1}else{const e=new xe;if(i>Number.MAX_SAFE_INTEGER){m();const t=BigInt(i);e.valueBigInt=t}else if(e.valueDec=parseInt(i,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,n=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let i=this.value[r].toString();0!==r&&(e=`${e}.`),t?(i=`{${i}}`,this.value[r].isFirstSid?e=`2.{${i} - 80}`:e+=i):e+=i}return e}toJSON(){const 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}}Be.NAME="ObjectIdentifierValueBlock";class ke extends L{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Be),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}fe=ke,D.ObjectIdentifier=fe,ke.NAME="OBJECT IDENTIFIER";class Ce extends(j(U)){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const i=n.toUint8Array(e);if(!b(this,i,t,r))return-1;const s=i.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const o=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)o[e]=this.valueHexView[e];return this.valueHexView=o,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=f(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);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=y(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",E;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),i=t.byteLength-1;for(let t=0;t<i;t++)r[t]=128|e[t];r[i]=e[i]}return r.buffer}toString(){let e="";return e=this.isHexOnly?h.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Ce.NAME="relativeSidBlock";class Ee extends P{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let i=t;for(;r>0;){const t=new Ce;if(i=t.fromBER(e,i,r),-1===i)return this.blockLength=0,this.error=t.error,i;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return i}toBER(e,t){const r=[];for(let t=0;t<this.value.length;t++){const i=this.value[t].toBER(e);if(0===i.byteLength)return this.error=this.value[t].error,E;r.push(i)}return w(r)}fromString(e){this.value=[];let t=0,r=0,i="";do{r=e.indexOf(".",t),i=-1===r?e.substring(t):e.substring(t,r),t=r+1;const n=new Ce;if(n.valueDec=parseInt(i,10),isNaN(n.valueDec))return!0;this.value.push(n)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let i=this.value[r].toString();0!==r&&(e=`${e}.`),t?(i=`{${i}}`,e+=i):e+=i}return e}toJSON(){const 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}}Ee.NAME="RelativeObjectIdentifierValueBlock";class Oe extends L{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,Ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ye=Oe,D.RelativeObjectIdentifier=ye,Oe.NAME="RelativeObjectIdentifier";class Ne extends Q{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}de=Ne,D.Sequence=de,Ne.NAME="SEQUENCE";let Ie=class extends Q{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};ge=Ie,D.Set=ge,Ie.NAME="SET";class Te extends(j(P)){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=C}toJSON(){return{...super.toJSON(),value:this.value}}}Te.NAME="StringValueBlock";class je extends Te{}je.NAME="SimpleStringValueBlock";class Ue extends M{constructor({...e}={}){super(e,je)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,n.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.charCodeAt(i);this.valueBlock.value=e}}Ue.NAME="SIMPLE STRING";class Pe extends Ue{fromBuffer(e){this.valueBlock.valueHexView=n.toUint8Array(e);try{this.valueBlock.value=h.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=h.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(h.FromUtf8String(e)),this.valueBlock.value=e}}var Re,Ve,De,Le,He,Me,$e,Ke,Fe,_e,We,ze,qe,Ge,Je,Xe,Ze,Ye,Qe;Pe.NAME="Utf8StringValueBlock";class et extends Pe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}Re=et,D.Utf8String=Re,et.NAME="UTF8String";class tt extends Ue{fromBuffer(e){this.valueBlock.value=h.ToUtf16String(e),this.valueBlock.valueHexView=n.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(h.FromUtf16String(e))}}tt.NAME="BmpStringValueBlock";class rt extends tt{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Ve=rt,D.BmpString=Ve,rt.NAME="BMPString";class it extends Ue{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let e=0;e<r.length;e+=4)r[e]=r[e+3],r[e+1]=r[e+2],r[e+2]=0,r[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let i=0;i<t;i++){const t=y(e.charCodeAt(i),8),n=new Uint8Array(t);if(n.length>4)continue;const s=4-n.length;for(let e=n.length-1;e>=0;e--)r[4*i+e+s]=n[e]}this.valueBlock.value=e}}it.NAME="UniversalStringValueBlock";class nt extends it{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}De=nt,D.UniversalString=De,nt.NAME="UniversalString";class st extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Le=st,D.NumericString=Le,st.NAME="NumericString";class ot extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}He=ot,D.PrintableString=He,ot.NAME="PrintableString";class at extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Me=at,D.TeletexString=Me,at.NAME="TeletexString";class ct extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}$e=ct,D.VideotexString=$e,ct.NAME="VideotexString";class lt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ke=lt,D.IA5String=Ke,lt.NAME="IA5String";class ut extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Fe=ut,D.GraphicString=Fe,ut.NAME="GraphicString";class ht extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}_e=ht,D.VisibleString=_e,ht.NAME="VisibleString";class pt extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}We=pt,D.GeneralString=We,pt.NAME="GeneralString";class ft extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}ze=ft,D.CharacterString=ze,ft.NAME="CharacterString";class yt extends ht{constructor({value:e,valueDate:t,...r}={}){if(super(r),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 t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}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,n.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);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){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if("iso"===e){const e=new Array(7);return e[0]=v(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=v(this.month,2),e[2]=v(this.day,2),e[3]=v(this.hour,2),e[4]=v(this.minute,2),e[5]=v(this.second,2),e[6]="Z",e.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}}}qe=yt,D.UTCTime=qe,yt.NAME="UTCTime";class dt extends yt{constructor(e={}){var t;super(e),null!==(t=this.millisecond)&&void 0!==t||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const 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,r=!1,i="",n="",s=0,o=0,a=0;if("Z"===e[e.length-1])i=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");i=e}if(r){if(-1!==i.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==i.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=i.indexOf("+"),r="";if(-1===t&&(t=i.indexOf("-"),e=-1),-1!==t){if(r=i.substring(t+1),i=i.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let n=parseInt(r.substring(0,2),10);if(isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*n,4===r.length){if(n=parseInt(r.substring(2,4),10),isNaN(n.valueOf()))throw new Error("Wrong input string for conversion");a=e*n}}}let c=i.indexOf(".");if(-1===c&&(c=i.indexOf(",")),-1!==c){const e=new Number(`0${i.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");s=e.valueOf(),n=i.substring(0,c)}else n=i;switch(!0){case 8===n.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===n.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*s;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const l=t.exec(n);if(null===l)throw new Error("Wrong input string for conversion");for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+a;break;case 6:this.second=parseInt(l[e],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e="iso"){if("iso"===e){const e=[];return e.push(v(this.year,4)),e.push(v(this.month,2)),e.push(v(this.day,2)),e.push(v(this.hour,2)),e.push(v(this.minute,2)),e.push(v(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(v(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Ge=dt,D.GeneralizedTime=Ge,dt.NAME="GeneralizedTime";class gt extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Je=gt,D.DATE=Je,gt.NAME="DATE";class vt extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Xe=vt,D.TimeOfDay=Xe,vt.NAME="TimeOfDay";class mt extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Ze=mt,D.DateTime=Ze,mt.NAME="DateTime";class wt extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Ye=wt,D.Duration=Ye,wt.NAME="Duration";class bt extends et{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Qe=bt,D.TIME=Qe,bt.NAME="TIME";class At{constructor({name:e="",optional:t=!1}={}){this.name=e,this.optional=t}}class St extends At{constructor({value:e=[],...t}={}){super(t),this.value=e}}class xt extends At{constructor({value:e=new At,local:t=!1,...r}={}){super(r),this.value=e,this.local=t}}function Bt(e,t,r){if(r instanceof St){for(const i of r.value){if(Bt(e,t,i).verified)return{verified:!0,result:e}}{const e={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(B)&&(e.name=r.name),e}}if(r instanceof At)return r.hasOwnProperty(B)&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("idBlock"in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=r.idBlock.toBER(!1);if(0===i.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(i,0,i.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty("tagClass"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("tagNumber"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("isConstructed"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!("isHexOnly"in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(r.idBlock.isHexOnly){if(k in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const i=r.idBlock.valueHexView,n=t.idBlock.valueHexView;if(i.length!==n.length)return{verified:!1,result:e};for(let t=0;t<i.length;t++)if(i[t]!==n[1])return{verified:!1,result:e}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(e[r.name]=t)),r instanceof D.Constructed){let i=0,n={verified:!1,result:{error:"Unknown error"}},s=r.valueBlock.value.length;if(s>0&&r.valueBlock.value[0]instanceof xt&&(s=t.valueBlock.value.length),0===s)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){let t=!0;for(let e=0;e<r.valueBlock.value.length;e++)t=t&&(r.valueBlock.value[e].optional||!1);return t?{verified:!0,result:e}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(let o=0;o<s;o++)if(o-i>=t.valueBlock.value.length){if(!1===r.valueBlock.value[o].optional){const t={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}}else if(r.valueBlock.value[0]instanceof xt){if(n=Bt(e,t.valueBlock.value[o],r.valueBlock.value[0].value),!1===n.verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&delete e[r.name]),n;i++}if(B in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let i={};i="local"in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e,void 0===i[r.valueBlock.value[0].name]&&(i[r.valueBlock.value[0].name]=[]),i[r.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(n=Bt(e,t.valueBlock.value[o-i],r.valueBlock.value[o]),!1===n.verified){if(!r.valueBlock.value[o].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&delete e[r.name]),n;i++}if(!1===n.verified){const t={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}return{verified:!0,result:e}}if(r.primitiveSchema&&k in t.valueBlock){const i=J(t.valueBlock.valueHexView);if(-1===i.offset){const t={verified:!1,result:i.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,C),r.name&&(delete e[r.name],t.name=r.name)),t}return Bt(e,i.result,r.primitiveSchema)}return{verified:!0,result:e}}var kt,Ct,Et=Object.freeze({__proto__:null,Any:At,BaseBlock:L,BaseStringBlock:M,BitString:le,BmpString:rt,Boolean:ne,CharacterString:ft,Choice:St,Constructed:Q,DATE:gt,DateTime:mt,Duration:wt,EndOfContent:te,Enumerated:Se,GeneralString:pt,GeneralizedTime:dt,GraphicString:ut,HexBlock:j,IA5String:lt,Integer:Ae,Null:re,NumericString:st,ObjectIdentifier:ke,OctetString:oe,Primitive:G,PrintableString:ot,RawData:class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=n.toUint8Array(e)}constructor({data:e=O}={}){this.dataView=n.toUint8Array(e)}fromBER(e,t,r){const i=t+r;return this.dataView=n.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:Oe,Repeated:xt,Sequence:Ne,Set:Ie,TIME:bt,TeletexString:at,TimeOfDay:vt,UTCTime:yt,UniversalString:nt,Utf8String:et,ValueBlock:P,VideotexString:ct,ViewWriter:A,VisibleString:ht,compareSchema:Bt,fromBER:X,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const r=J(n.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:Bt(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(kt||(kt={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(Ct||(Ct={}));class Ot{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if("number"==typeof e)this.fromNumber(e);else{if(!n.isBufferSource(e))throw TypeError("Unsupported type of 'params' argument for BitString");this.unusedBits=t,this.value=n.toArrayBuffer(e)}}fromASN(e){if(!(e instanceof le))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 le({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new le({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const r of t)e+=r.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);const r=t.length+7>>3;this.unusedBits=(r<<3)-t.length;const i=new Uint8Array(r);t=t.padStart(r<<3,"0").split("").reverse().join("");let n=0;for(;n<r;)i[n]=parseInt(t.slice(n<<3,8+(n<<3)),2),n++;this.value=i.buffer}}class Nt{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){"number"==typeof e?this.buffer=new ArrayBuffer(e):n.isBufferSource(e)?this.buffer=n.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof oe))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new oe({valueHex:this.buffer})}toSchema(e){return new oe({name:e})}}const It={fromASN:e=>e instanceof re?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new re;const t=X(e);if(t.result.error)throw new Error(t.result.error);return t.result}},Tt={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new Ae({value:+e})},jt={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new Se({value:e})},Ut={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Ae({valueHex:e})},Pt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new le({valueHex:e})},Rt={fromASN:e=>e.valueBlock.toString(),toASN:e=>new ke({value:e})},Vt={fromASN:e=>e.valueBlock.value,toASN:e=>new ne({value:e})},Dt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new oe({valueHex:e})},Lt={fromASN:e=>new Nt(e.getValue()),toASN:e=>e.toASN()};function Ht(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}const Mt=Ht(et),$t=Ht(rt),Kt=Ht(nt),Ft=Ht(st),_t=Ht(ot),Wt=Ht(at),zt=Ht(ct),qt=Ht(lt),Gt=Ht(ut),Jt=Ht(ht),Xt=Ht(pt),Zt=Ht(ft),Yt={fromASN:e=>e.toDate(),toASN:e=>new yt({valueDate:e})},Qt={fromASN:e=>e.toDate(),toASN:e=>new dt({valueDate:e})},er={fromASN:()=>null,toASN:()=>new re};function tr(e){switch(e){case Ct.Any:return It;case Ct.BitString:return Pt;case Ct.BmpString:return $t;case Ct.Boolean:return Vt;case Ct.CharacterString:return Zt;case Ct.Enumerated:return jt;case Ct.GeneralString:return Xt;case Ct.GeneralizedTime:return Qt;case Ct.GraphicString:return Gt;case Ct.IA5String:return qt;case Ct.Integer:return Tt;case Ct.Null:return er;case Ct.NumericString:return Ft;case Ct.ObjectIdentifier:return Rt;case Ct.OctetString:return Dt;case Ct.PrintableString:return _t;case Ct.TeletexString:return Wt;case Ct.UTCTime:return Yt;case Ct.UniversalString:return Kt;case Ct.Utf8String:return Mt;case Ct.VideotexString:return zt;case Ct.VisibleString:return Jt;default:return null}}function rr(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||rr(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function ir(e){var t;if(e){const r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||ir(r)}return!1}function nr(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),i=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==i[t])return!1;return!0}const sr=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:kt.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,t){const r=this.items.get(e)||this.createDefault(e),i=[];for(const e in r.items){const n=r.items[e],s=t?e:"";let o;if("number"==typeof n.type){const e=Ct[n.type],t=Et[e];if(!t)throw new Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:s})}else if(rr(n.type)){o=(new n.type).toSchema(s)}else if(n.optional){this.get(n.type).type===kt.Choice?o=new At({name:s}):(o=this.create(n.type,!1),o.name=s)}else o=new At({name:s});const a=!!n.optional||void 0!==n.defaultValue;if(n.repeated){o.name="";o=new("set"===n.repeated?Ie:Ne)({name:"",value:[new xt({name:s,value:o})]})}if(null!==n.context&&void 0!==n.context)if(n.implicit)if("number"==typeof n.type||rr(n.type)){const e=n.repeated?Q:G;i.push(new e({name:s,optional:a,idBlock:{tagClass:3,tagNumber:n.context}}))}else{this.cache(n.type);const e=!!n.repeated;let t=e?o:this.get(n.type,!0).schema;t="valueBlock"in t?t.valueBlock.value:t.value,i.push(new Q({name:e?"":s,optional:a,idBlock:{tagClass:3,tagNumber:n.context},value:t}))}else i.push(new Q({optional:a,idBlock:{tagClass:3,tagNumber:n.context},value:[o]}));else o.optional=a,i.push(o)}switch(r.type){case kt.Sequence:return new Ne({value:i,name:""});case kt.Set:return new Ie({value:i,name:""});case kt.Choice:return new St({value:i,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);if(t){return this.items.get(t)||this.findParentSchema(t)}return null}},or=e=>t=>{let r;sr.has(t)?r=sr.get(t):(r=sr.createDefault(t),sr.set(t,r)),Object.assign(r,e)},ar=e=>(t,r)=>{let i;sr.has(t.constructor)?i=sr.get(t.constructor):(i=sr.createDefault(t.constructor),sr.set(t.constructor,i));const n=Object.assign({},e);if("number"==typeof n.type&&!n.converter){const i=tr(e.type);if(!i)throw new Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);n.converter=i}n.raw=e.raw,i.items[r]=n};class cr extends Error{constructor(){super(...arguments),this.schemas=[]}}class lr{static parse(e,t){const r=X(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){try{if(rr(t)){return(new t).fromASN(e)}const r=sr.get(t);sr.cache(t);let i=r.schema;const n=this.handleChoiceTypes(e,r,t,i);if(null==n?void 0:n.result)return n.result;(null==n?void 0:n.targetSchema)&&(i=n.targetSchema);const s=this.handleSequenceTypes(e,r,t,i),o=new t;return ir(t)?this.handleArrayTypes(e,r,t):(this.processSchemaItems(r,s,o),o)}catch(e){throw e instanceof cr&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,r,i){if(e.constructor===Q&&t.type===kt.Choice&&3===e.idBlock.tagClass)for(const i in t.items){const n=t.items[i];if(n.context===e.idBlock.tagNumber&&n.implicit&&"function"==typeof n.type&&sr.has(n.type)){const t=sr.get(n.type);if(t&&t.type===kt.Sequence){const t=new Ne;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock){t.valueBlock.value=e.valueBlock.value;const s=this.fromASN(t,n.type),o=new r;return o[i]=s,{result:o}}}}}else if(e.constructor===Q&&t.type!==kt.Choice){const r=new Q({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(const r in t.items)delete e[r];return{targetSchema:r}}return null}static handleSequenceTypes(e,t,r,i){if(t.type===kt.Sequence){const t=Bt({},e,i);if(!t.verified)throw new cr(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:""}`);return t}{const t=Bt({},e,i);if(!t.verified)throw new cr(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:""}`);return t}}static processRepeatedField(e,t,r){let i=e.slice(t);if(1===i.length&&"Sequence"===i[0].constructor.name){const e=i[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(i=e.valueBlock.value)}if("number"==typeof r.type){const e=tr(r.type);if(!e)throw new Error(`No converter for ASN.1 type ${r.type}`);return i.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch(e){return}}).filter(e=>void 0!==e)}return i.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,r.type)}catch(e){return}}).filter(e=>void 0!==e)}static processPrimitiveField(e,t){const r=tr(t.type);if(!r)throw new Error(`No converter for ASN.1 type ${t.type}`);return r.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&"function"==typeof e.type&&sr.has(e.type)&&sr.get(e.type).type===kt.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof cr&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,r){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.");const i=t.itemType;if("number"==typeof i){const t=tr(i);if(!t)throw new Error(`Cannot get default converter for array item of ${r.name} ASN1 schema`);return r.from(e.valueBlock.value,e=>t.fromASN(e))}return r.from(e.valueBlock.value,e=>this.fromASN(e,i))}static processSchemaItems(e,t,r){for(const i in e.items){const n=t.result[i];if(!n)continue;const s=e.items[i],o=s.type;let a;a="number"==typeof o||rr(o)?this.processPrimitiveSchemaItem(n,s,o):this.processComplexSchemaItem(n,s,o),a&&"object"==typeof a&&"value"in a&&"raw"in a?(r[i]=a.value,r[`${i}Raw`]=a.raw):r[i]=a}}static processPrimitiveSchemaItem(e,t,r){var i;const n=null!==(i=t.converter)&&void 0!==i?i:rr(r)?new r:null;if(!n)throw new Error("Converter is empty");return t.repeated?this.processRepeatedPrimitiveItem(e,t,n):this.processSinglePrimitiveItem(e,t,r,n)}static processRepeatedPrimitiveItem(e,t,r){if(t.implicit){const i=new("sequence"===t.repeated?Ne:Ie);i.valueBlock=e.valueBlock;const n=X(i.toBER(!1));if(-1===n.offset)throw new Error(`Cannot parse the child item. ${n.result.error}`);if(!("value"in n.result.valueBlock)||!Array.isArray(n.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const s=n.result.valueBlock.value;return Array.from(s,e=>r.fromASN(e))}return Array.from(e,e=>r.fromASN(e))}static processSinglePrimitiveItem(e,t,r,i){let n=e;if(t.implicit){let e;if(rr(r))e=(new r).toSchema("");else{const t=Ct[r],i=Et[t];if(!i)throw new Error(`Cannot get '${t}' class from asn1js module`);e=new i}e.valueBlock=n.valueBlock,n=X(e.toBER(!1)).result}return i.fromASN(n)}static processComplexSchemaItem(e,t,r){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,e=>this.fromASN(e,r))}{const i=this.handleImplicitTagging(e,t,r);if(!this.isOptionalChoiceField(t)){const n=this.fromASN(i,r);return t.raw?{value:n,raw:e.valueBeforeDecodeView}:n}try{return this.fromASN(i,r)}catch(e){if(e instanceof cr&&/Wrong values for Choice type/.test(e.message))return;throw e}}}static handleImplicitTagging(e,t,r){if(t.implicit&&"number"==typeof t.context){const t=sr.get(r);if(t.type===kt.Sequence){const t=new Ne;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===kt.Set){const t=new Ie;if("value"in e.valueBlock&&Array.isArray(e.valueBlock.value)&&"value"in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}class ur{static serialize(e){return e instanceof L?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&rr(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,r=sr.get(t);sr.cache(t);let i,n=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){const i=tr(r.itemType);if(!i)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);n=e.map(e=>i.toASN(e))}else n=e.map(e=>this.toAsnItem({type:r.itemType},"[]",t,e))}else for(const i in r.items){const s=r.items[i],o=e[i];if(void 0===o||s.defaultValue===o||"object"==typeof s.defaultValue&&"object"==typeof o&&nr(this.serialize(s.defaultValue),this.serialize(o)))continue;const a=ur.toAsnItem(s,i,t,o);if("number"==typeof s.context)if(s.implicit)if(s.repeated||"number"!=typeof s.type&&!rr(s.type))n.push(new Q({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:a.valueBlock.value}));else{const e={};e.valueHex=a instanceof re?a.valueBeforeDecodeView:a.valueBlock.toBER(),n.push(new G({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},...e}))}else n.push(new Q({optional:s.optional,idBlock:{tagClass:3,tagNumber:s.context},value:[a]}));else s.repeated?n=n.concat(a):n.push(a)}switch(r.type){case kt.Sequence:i=new Ne({value:n});break;case kt.Set:i=new Ie({value:n});break;case kt.Choice:if(!n[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);i=n[0]}return i}static toAsnItem(e,t,r,i){let n;if("number"==typeof e.type){const s=e.converter;if(!s)throw new Error(`Property '${t}' doesn't have converter for type ${Ct[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,e=>s.toASN(e));n=new("sequence"===e.repeated?Ne:Ie)({value:t})}else n=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(i,e=>this.toASN(e));n=new("sequence"===e.repeated?Ne:Ie)({value:t})}else n=this.toASN(i);return n}}class hr extends Array{constructor(e=[]){if("number"==typeof e)super(e);else{super();for(const t of e)this.push(t)}}}class pr{static serialize(e){return ur.serialize(e)}static parse(e,t){return lr.parse(e,t)}static toString(e){const t=X(n.isBufferSource(e)?n.toArrayBuffer(e):pr.serialize(e));if(-1===t.offset)throw new Error(`Cannot decode ASN.1 data. ${t.result.error}`);return t.result.toString()}}var fr,yr,dr,gr=function(e,t){return gr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},gr(e,t)};function vr(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}gr(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function mr(e,t,r,i){var n,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,r,o):n(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o}function wr(e,t,r,i){return new(r||(r=Promise))(function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,a)}c((i=i.apply(e,t||[])).next())})}function br(e,t){var r,i,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=a(0),o.throw=a(1),o.return=a(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function Ar(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sr(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,s=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return o}function xr(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Sr(arguments[t]));return e}function Br(e,t,r,i){if("a"===r&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?i:"a"===r?i.call(e):i?i.value:t.get(e)}function kr(e,t,r,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,r):n?n.value=r:t.set(e,r),r}"function"==typeof SuppressedError&&SuppressedError;class Cr{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){const t=e.split(".");if(4!==t.length)throw new Error("Invalid IPv4 address");return t.map(e=>{const t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw new Error("Invalid IPv4 address part");return t})}static parseIPv6(e){const t=this.expandIPv6(e).split(":");if(8!==t.length)throw new Error("Invalid IPv6 address");return t.reduce((e,t)=>{const r=parseInt(t,16);if(isNaN(r)||r<0||r>65535)throw new Error("Invalid IPv6 address part");return e.push(r>>8&255),e.push(255&r),e},[])}static expandIPv6(e){if(!e.includes("::"))return e;const t=e.split("::");if(t.length>2)throw new Error("Invalid IPv6 address");const r=t[0]?t[0].split(":"):[],i=t[1]?t[1].split(":"):[],n=8-(r.length+i.length);if(n<0)throw new Error("Invalid IPv6 address");return[...r,...Array(n).fill("0"),...i].join(":")}static formatIPv6(e){const t=[];for(let r=0;r<16;r+=2)t.push((e[r]<<8|e[r+1]).toString(16));return this.compressIPv6(t.join(":"))}static compressIPv6(e){const t=e.split(":");let r=-1,i=0,n=-1,s=0;for(let e=0;e<t.length;e++)"0"===t[e]?(-1===n&&(n=e),s++):(s>i&&(r=n,i=s),n=-1,s=0);if(s>i&&(r=n,i=s),i>1){return`${t.slice(0,r).join(":")}::${t.slice(r+i).join(":")}`}return e}static parseCIDR(e){const[t,r]=e.split("/"),i=parseInt(r,10);if(this.isIPv4(t)){if(i<0||i>32)throw new Error("Invalid IPv4 prefix length");return[this.parseIPv4(t),i]}if(i<0||i>128)throw new Error("Invalid IPv6 prefix length");return[this.parseIPv6(t),i]}static decodeIP(e){if(64===e.length&&0===parseInt(e,16))return"::/0";if(16!==e.length)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((e,t)=>e+ +t,0);let r=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return r=r.slice(0,-1),`${r}/${t}`}static toString(e){const t=new Uint8Array(e);if(4===t.length)return Array.from(t).join(".");if(16===t.length)return this.formatIPv6(t);if(8===t.length||32===t.length){const e=t.length/2,r=t.slice(0,e),i=t.slice(e);if(t.every(e=>0===e))return 8===t.length?"0.0.0.0/0":"::/0";const n=i.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);if(8===t.length){return`${Array.from(r).join(".")}/${n}`}return`${this.formatIPv6(r)}/${n}`}return this.decodeIP(h.ToHex(e))}static fromString(e){if(e.includes("/")){const[t,r]=this.parseCIDR(e),i=new Uint8Array(t.length);let n=r;for(let e=0;e<i.length;e++)n>=8?(i[e]=255,n-=8):n>0&&(i[e]=255<<8-n,n=0);const s=new Uint8Array(2*t.length);return s.set(t,0),s.set(i,t.length),s.buffer}const t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}let Er=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};mr([ar({type:Ct.TeletexString})],Er.prototype,"teletexString",void 0),mr([ar({type:Ct.PrintableString})],Er.prototype,"printableString",void 0),mr([ar({type:Ct.UniversalString})],Er.prototype,"universalString",void 0),mr([ar({type:Ct.Utf8String})],Er.prototype,"utf8String",void 0),mr([ar({type:Ct.BmpString})],Er.prototype,"bmpString",void 0),Er=mr([or({type:kt.Choice})],Er);let Or=class extends Er{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?h.ToHex(this.anyValue):super.toString())}};mr([ar({type:Ct.IA5String})],Or.prototype,"ia5String",void 0),mr([ar({type:Ct.Any})],Or.prototype,"anyValue",void 0),Or=mr([or({type:kt.Choice})],Or);class Nr{constructor(e={}){this.type="",this.value=new Or,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Nr.prototype,"type",void 0),mr([ar({type:Or})],Nr.prototype,"value",void 0);let Ir=fr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,fr.prototype)}};Ir=fr=mr([or({type:kt.Set,itemType:Nr})],Ir);let Tr=yr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,yr.prototype)}};Tr=yr=mr([or({type:kt.Sequence,itemType:Ir})],Tr);let jr=dr=class extends Tr{constructor(e){super(e),Object.setPrototypeOf(this,dr.prototype)}};jr=dr=mr([or({type:kt.Sequence})],jr);const Ur={fromASN:e=>Cr.toString(Dt.fromASN(e)),toASN:e=>Dt.toASN(Cr.fromString(e))};class Pr{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Pr.prototype,"typeId",void 0),mr([ar({type:Ct.Any,context:0})],Pr.prototype,"value",void 0);class Rr{constructor(e={}){this.partyName=new Er,Object.assign(this,e)}}mr([ar({type:Er,optional:!0,context:0,implicit:!0})],Rr.prototype,"nameAssigner",void 0),mr([ar({type:Er,context:1,implicit:!0})],Rr.prototype,"partyName",void 0);let Vr=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Pr,context:0,implicit:!0})],Vr.prototype,"otherName",void 0),mr([ar({type:Ct.IA5String,context:1,implicit:!0})],Vr.prototype,"rfc822Name",void 0),mr([ar({type:Ct.IA5String,context:2,implicit:!0})],Vr.prototype,"dNSName",void 0),mr([ar({type:Ct.Any,context:3,implicit:!0})],Vr.prototype,"x400Address",void 0),mr([ar({type:jr,context:4,implicit:!1})],Vr.prototype,"directoryName",void 0),mr([ar({type:Rr,context:5})],Vr.prototype,"ediPartyName",void 0),mr([ar({type:Ct.IA5String,context:6,implicit:!0})],Vr.prototype,"uniformResourceIdentifier",void 0),mr([ar({type:Ct.OctetString,context:7,implicit:!0,converter:Ur})],Vr.prototype,"iPAddress",void 0),mr([ar({type:Ct.ObjectIdentifier,context:8,implicit:!0})],Vr.prototype,"registeredID",void 0),Vr=mr([or({type:kt.Choice})],Vr);const Dr="1.3.6.1.5.5.7",Lr=`${Dr}.3`,Hr=`${Dr}.48`,Mr=`${Hr}.1`,$r=`${Hr}.2`,Kr=`${Hr}.3`,Fr=`${Hr}.5`,_r="2.5.29";var Wr;const zr=`${`${Dr}.1`}.1`;class qr{constructor(e={}){this.accessMethod="",this.accessLocation=new Vr,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],qr.prototype,"accessMethod",void 0),mr([ar({type:Vr})],qr.prototype,"accessLocation",void 0);let Gr=Wr=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Wr.prototype)}};Gr=Wr=mr([or({type:kt.Sequence,itemType:qr})],Gr);const Jr=`${_r}.35`;class Xr extends Nt{}class Zr{constructor(e={}){e&&Object.assign(this,e)}}mr([ar({type:Xr,context:0,optional:!0,implicit:!0})],Zr.prototype,"keyIdentifier",void 0),mr([ar({type:Vr,context:1,optional:!0,implicit:!0,repeated:"sequence"})],Zr.prototype,"authorityCertIssuer",void 0),mr([ar({type:Ct.Integer,context:2,optional:!0,implicit:!0,converter:Ut})],Zr.prototype,"authorityCertSerialNumber",void 0);const Yr=`${_r}.19`;class Qr{constructor(e={}){this.cA=!1,Object.assign(this,e)}}var ei;mr([ar({type:Ct.Boolean,defaultValue:!1})],Qr.prototype,"cA",void 0),mr([ar({type:Ct.Integer,optional:!0})],Qr.prototype,"pathLenConstraint",void 0);let ti=ei=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ei.prototype)}};var ri;ti=ei=mr([or({type:kt.Sequence,itemType:Vr})],ti);const ii=`${_r}.29`;let ni=ri=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,ri.prototype)}};var si;ni=ri=mr([or({type:kt.Sequence})],ni);const oi=`${_r}.32`;let ai=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};mr([ar({type:Ct.IA5String})],ai.prototype,"ia5String",void 0),mr([ar({type:Ct.VisibleString})],ai.prototype,"visibleString",void 0),mr([ar({type:Ct.BmpString})],ai.prototype,"bmpString",void 0),mr([ar({type:Ct.Utf8String})],ai.prototype,"utf8String",void 0),ai=mr([or({type:kt.Choice})],ai);class ci{constructor(e={}){this.organization=new ai,this.noticeNumbers=[],Object.assign(this,e)}}mr([ar({type:ai})],ci.prototype,"organization",void 0),mr([ar({type:Ct.Integer,repeated:"sequence"})],ci.prototype,"noticeNumbers",void 0);class li{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ci,optional:!0})],li.prototype,"noticeRef",void 0),mr([ar({type:ai,optional:!0})],li.prototype,"explicitText",void 0);let ui=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.IA5String})],ui.prototype,"cPSuri",void 0),mr([ar({type:li})],ui.prototype,"userNotice",void 0),ui=mr([or({type:kt.Choice})],ui);class hi{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],hi.prototype,"policyQualifierId",void 0),mr([ar({type:Ct.Any})],hi.prototype,"qualifier",void 0);class pi{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],pi.prototype,"policyIdentifier",void 0),mr([ar({type:hi,repeated:"sequence",optional:!0})],pi.prototype,"policyQualifiers",void 0);let fi=si=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,si.prototype)}};fi=si=mr([or({type:kt.Sequence,itemType:pi})],fi);let yi=class{constructor(e=0){this.value=e}};mr([ar({type:Ct.Integer})],yi.prototype,"value",void 0),yi=mr([or({type:kt.Choice})],yi);let di=class extends yi{};var gi;di=mr([or({type:kt.Choice})],di);const vi=`${_r}.31`;var mi;!function(e){e[e.unused=1]="unused",e[e.keyCompromise=2]="keyCompromise",e[e.cACompromise=4]="cACompromise",e[e.affiliationChanged=8]="affiliationChanged",e[e.superseded=16]="superseded",e[e.cessationOfOperation=32]="cessationOfOperation",e[e.certificateHold=64]="certificateHold",e[e.privilegeWithdrawn=128]="privilegeWithdrawn",e[e.aACompromise=256]="aACompromise"}(mi||(mi={}));class wi extends Ot{toJSON(){const e=[],t=this.toNumber();return t&mi.aACompromise&&e.push("aACompromise"),t&mi.affiliationChanged&&e.push("affiliationChanged"),t&mi.cACompromise&&e.push("cACompromise"),t&mi.certificateHold&&e.push("certificateHold"),t&mi.cessationOfOperation&&e.push("cessationOfOperation"),t&mi.keyCompromise&&e.push("keyCompromise"),t&mi.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&mi.superseded&&e.push("superseded"),t&mi.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let bi=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,context:0,repeated:"sequence",implicit:!0})],bi.prototype,"fullName",void 0),mr([ar({type:Ir,context:1,implicit:!0})],bi.prototype,"nameRelativeToCRLIssuer",void 0),bi=mr([or({type:kt.Choice})],bi);class Ai{constructor(e={}){Object.assign(this,e)}}mr([ar({type:bi,context:0,optional:!0})],Ai.prototype,"distributionPoint",void 0),mr([ar({type:wi,context:1,optional:!0,implicit:!0})],Ai.prototype,"reasons",void 0),mr([ar({type:Vr,context:2,optional:!0,repeated:"sequence",implicit:!0})],Ai.prototype,"cRLIssuer",void 0);let Si=gi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,gi.prototype)}};var xi;Si=gi=mr([or({type:kt.Sequence,itemType:Ai})],Si);let Bi=xi=class extends Si{constructor(e){super(e),Object.setPrototypeOf(this,xi.prototype)}};Bi=xi=mr([or({type:kt.Sequence,itemType:Ai})],Bi);class ki{constructor(e={}){this.onlyContainsUserCerts=ki.ONLY,this.onlyContainsCACerts=ki.ONLY,this.indirectCRL=ki.ONLY,this.onlyContainsAttributeCerts=ki.ONLY,Object.assign(this,e)}}ki.ONLY=!1,mr([ar({type:bi,context:0,optional:!0})],ki.prototype,"distributionPoint",void 0),mr([ar({type:Ct.Boolean,context:1,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsUserCerts",void 0),mr([ar({type:Ct.Boolean,context:2,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsCACerts",void 0),mr([ar({type:wi,context:3,optional:!0,implicit:!0})],ki.prototype,"onlySomeReasons",void 0),mr([ar({type:Ct.Boolean,context:4,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"indirectCRL",void 0),mr([ar({type:Ct.Boolean,context:5,defaultValue:ki.ONLY,implicit:!0})],ki.prototype,"onlyContainsAttributeCerts",void 0);const Ci=`${_r}.21`;var Ei;!function(e){e[e.unspecified=0]="unspecified",e[e.keyCompromise=1]="keyCompromise",e[e.cACompromise=2]="cACompromise",e[e.affiliationChanged=3]="affiliationChanged",e[e.superseded=4]="superseded",e[e.cessationOfOperation=5]="cessationOfOperation",e[e.certificateHold=6]="certificateHold",e[e.removeFromCRL=8]="removeFromCRL",e[e.privilegeWithdrawn=9]="privilegeWithdrawn",e[e.aACompromise=10]="aACompromise"}(Ei||(Ei={}));let Oi=class{constructor(e=Ei.unspecified){this.reason=Ei.unspecified,this.reason=e}toJSON(){return Ei[this.reason]}toString(){return this.toJSON()}};var Ni;mr([ar({type:Ct.Enumerated})],Oi.prototype,"reason",void 0),Oi=mr([or({type:kt.Choice})],Oi);const Ii=`${_r}.37`;let Ti=Ni=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Ni.prototype)}};Ti=Ni=mr([or({type:kt.Sequence,itemType:Ct.ObjectIdentifier})],Ti);const ji=`${Lr}.1`,Ui=`${Lr}.2`,Pi=`${Lr}.3`,Ri=`${Lr}.4`,Vi=`${Lr}.8`,Di=`${Lr}.9`;let Li=class{constructor(e=new ArrayBuffer(0)){this.value=e}};mr([ar({type:Ct.Integer,converter:Ut})],Li.prototype,"value",void 0),Li=mr([or({type:kt.Choice})],Li);const Hi=`${_r}.24`;let Mi=class{constructor(e){this.value=new Date,e&&(this.value=e)}};var $i;mr([ar({type:Ct.GeneralizedTime})],Mi.prototype,"value",void 0),Mi=mr([or({type:kt.Choice})],Mi);const Ki=`${_r}.18`;let Fi=$i=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,$i.prototype)}};Fi=$i=mr([or({type:kt.Sequence})],Fi);const _i=`${_r}.15`;var Wi,zi;!function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(Wi||(Wi={}));class qi extends Ot{toJSON(){const e=this.toNumber(),t=[];return e&Wi.cRLSign&&t.push("crlSign"),e&Wi.dataEncipherment&&t.push("dataEncipherment"),e&Wi.decipherOnly&&t.push("decipherOnly"),e&Wi.digitalSignature&&t.push("digitalSignature"),e&Wi.encipherOnly&&t.push("encipherOnly"),e&Wi.keyAgreement&&t.push("keyAgreement"),e&Wi.keyCertSign&&t.push("keyCertSign"),e&Wi.keyEncipherment&&t.push("keyEncipherment"),e&Wi.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}class Gi{constructor(e={}){this.base=new Vr,this.minimum=0,Object.assign(this,e)}}mr([ar({type:Vr})],Gi.prototype,"base",void 0),mr([ar({type:Ct.Integer,context:0,defaultValue:0,implicit:!0})],Gi.prototype,"minimum",void 0),mr([ar({type:Ct.Integer,context:1,optional:!0,implicit:!0})],Gi.prototype,"maximum",void 0);let Ji=zi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,zi.prototype)}};Ji=zi=mr([or({type:kt.Sequence,itemType:Gi})],Ji);class Xi{constructor(e={}){Object.assign(this,e)}}mr([ar({type:Ji,context:0,optional:!0,implicit:!0})],Xi.prototype,"permittedSubtrees",void 0),mr([ar({type:Ji,context:1,optional:!0,implicit:!0})],Xi.prototype,"excludedSubtrees",void 0);class Zi{constructor(e={}){Object.assign(this,e)}}var Yi;mr([ar({type:Ct.Integer,context:0,implicit:!0,optional:!0,converter:Ut})],Zi.prototype,"requireExplicitPolicy",void 0),mr([ar({type:Ct.Integer,context:1,implicit:!0,optional:!0,converter:Ut})],Zi.prototype,"inhibitPolicyMapping",void 0);class Qi{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Qi.prototype,"issuerDomainPolicy",void 0),mr([ar({type:Ct.ObjectIdentifier})],Qi.prototype,"subjectDomainPolicy",void 0);let en=Yi=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Yi.prototype)}};var tn;en=Yi=mr([or({type:kt.Sequence,itemType:Qi})],en);const rn=`${_r}.17`;let nn=tn=class extends ti{constructor(e){super(e),Object.setPrototypeOf(this,tn.prototype)}};nn=tn=mr([or({type:kt.Sequence})],nn);let sn=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};var on;mr([ar({type:Ct.ObjectIdentifier})],sn.prototype,"type",void 0),mr([ar({type:Ct.Any,repeated:"set"})],sn.prototype,"values",void 0);let an=on=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,on.prototype)}};an=on=mr([or({type:kt.Sequence,itemType:sn})],an);const cn=`${_r}.14`;class ln extends Xr{}class un{constructor(e={}){Object.assign(this,e)}}var hn,pn;mr([ar({type:Ct.GeneralizedTime,context:0,implicit:!0,optional:!0})],un.prototype,"notBefore",void 0),mr([ar({type:Ct.GeneralizedTime,context:1,implicit:!0,optional:!0})],un.prototype,"notAfter",void 0),function(e){e[e.keyUpdateAllowed=1]="keyUpdateAllowed",e[e.newExtensions=2]="newExtensions",e[e.pKIXCertificate=4]="pKIXCertificate"}(hn||(hn={}));class fn extends Ot{toJSON(){const e=[],t=this.toNumber();return t&hn.pKIXCertificate&&e.push("pKIXCertificate"),t&hn.newExtensions&&e.push("newExtensions"),t&hn.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class yn{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new fn,Object.assign(this,e)}}mr([ar({type:Ct.GeneralString})],yn.prototype,"entrustVers",void 0),mr([ar({type:fn})],yn.prototype,"entrustInfoFlags",void 0);let dn=pn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,pn.prototype)}};dn=pn=mr([or({type:kt.Sequence,itemType:qr})],dn);class gn{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof gn&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&p(e.parameters,this.parameters)||e.parameters===this.parameters)}}mr([ar({type:Ct.ObjectIdentifier})],gn.prototype,"algorithm",void 0),mr([ar({type:Ct.Any,optional:!0})],gn.prototype,"parameters",void 0);class vn{constructor(e={}){this.algorithm=new gn,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:gn})],vn.prototype,"algorithm",void 0),mr([ar({type:Ct.BitString})],vn.prototype,"subjectPublicKey",void 0);let mn=class{constructor(e){if(e)if("string"==typeof e||"number"==typeof e||e instanceof Date){const t=new Date(e);t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){const e=this.utcTime||this.generalTime;if(!e)throw new Error("Cannot get time from CHOICE object");return e}};mr([ar({type:Ct.UTCTime})],mn.prototype,"utcTime",void 0),mr([ar({type:Ct.GeneralizedTime})],mn.prototype,"generalTime",void 0),mn=mr([or({type:kt.Choice})],mn);class wn{constructor(e){this.notBefore=new mn(new Date),this.notAfter=new mn(new Date),e&&(this.notBefore=new mn(e.notBefore),this.notAfter=new mn(e.notAfter))}}var bn;mr([ar({type:mn})],wn.prototype,"notBefore",void 0),mr([ar({type:mn})],wn.prototype,"notAfter",void 0);let An=class e{constructor(t={}){this.extnID="",this.critical=e.CRITICAL,this.extnValue=new Nt,Object.assign(this,t)}};An.CRITICAL=!1,mr([ar({type:Ct.ObjectIdentifier})],An.prototype,"extnID",void 0),mr([ar({type:Ct.Boolean,defaultValue:An.CRITICAL})],An.prototype,"critical",void 0),mr([ar({type:Nt})],An.prototype,"extnValue",void 0);let Sn=bn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,bn.prototype)}};var xn;Sn=bn=mr([or({type:kt.Sequence,itemType:An})],Sn),function(e){e[e.v1=0]="v1",e[e.v2=1]="v2",e[e.v3=2]="v3"}(xn||(xn={}));class Bn{constructor(e={}){this.version=xn.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new gn,this.issuer=new jr,this.validity=new wn,this.subject=new jr,this.subjectPublicKeyInfo=new vn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,context:0,defaultValue:xn.v1})],Bn.prototype,"version",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Bn.prototype,"serialNumber",void 0),mr([ar({type:gn})],Bn.prototype,"signature",void 0),mr([ar({type:jr})],Bn.prototype,"issuer",void 0),mr([ar({type:wn})],Bn.prototype,"validity",void 0),mr([ar({type:jr})],Bn.prototype,"subject",void 0),mr([ar({type:vn})],Bn.prototype,"subjectPublicKeyInfo",void 0),mr([ar({type:Ct.BitString,context:1,implicit:!0,optional:!0})],Bn.prototype,"issuerUniqueID",void 0),mr([ar({type:Ct.BitString,context:2,implicit:!0,optional:!0})],Bn.prototype,"subjectUniqueID",void 0),mr([ar({type:Sn,context:3,optional:!0})],Bn.prototype,"extensions",void 0);class kn{constructor(e={}){this.tbsCertificate=new Bn,this.signatureAlgorithm=new gn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Bn,raw:!0})],kn.prototype,"tbsCertificate",void 0),mr([ar({type:gn})],kn.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],kn.prototype,"signatureValue",void 0);class Cn{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new mn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Cn.prototype,"userCertificate",void 0),mr([ar({type:mn})],Cn.prototype,"revocationDate",void 0),mr([ar({type:An,optional:!0,repeated:"sequence"})],Cn.prototype,"crlEntryExtensions",void 0);class En{constructor(e={}){this.signature=new gn,this.issuer=new jr,this.thisUpdate=new mn,Object.assign(this,e)}}mr([ar({type:Ct.Integer,optional:!0})],En.prototype,"version",void 0),mr([ar({type:gn})],En.prototype,"signature",void 0),mr([ar({type:jr})],En.prototype,"issuer",void 0),mr([ar({type:mn})],En.prototype,"thisUpdate",void 0),mr([ar({type:mn,optional:!0})],En.prototype,"nextUpdate",void 0),mr([ar({type:Cn,repeated:"sequence",optional:!0})],En.prototype,"revokedCertificates",void 0),mr([ar({type:An,optional:!0,context:0,repeated:"sequence"})],En.prototype,"crlExtensions",void 0);class On{constructor(e={}){this.tbsCertList=new En,this.signatureAlgorithm=new gn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:En,raw:!0})],On.prototype,"tbsCertList",void 0),mr([ar({type:gn})],On.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],On.prototype,"signature",void 0);class Nn{constructor(e={}){this.issuer=new jr,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:jr})],Nn.prototype,"issuer",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Nn.prototype,"serialNumber",void 0);let In=class{constructor(e={}){Object.assign(this,e)}};var Tn;mr([ar({type:ln,context:0,implicit:!0})],In.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Nn})],In.prototype,"issuerAndSerialNumber",void 0),In=mr([or({type:kt.Choice})],In),function(e){e[e.v0=0]="v0",e[e.v1=1]="v1",e[e.v2=2]="v2",e[e.v3=3]="v3",e[e.v4=4]="v4",e[e.v5=5]="v5"}(Tn||(Tn={}));let jn=class extends gn{};jn=mr([or({type:kt.Sequence})],jn);let Un=class extends gn{};Un=mr([or({type:kt.Sequence})],Un);let Pn=class extends gn{};Pn=mr([or({type:kt.Sequence})],Pn);let Rn=class extends gn{};Rn=mr([or({type:kt.Sequence})],Rn);let Vn=class extends gn{};Vn=mr([or({type:kt.Sequence})],Vn);let Dn=class extends gn{};Dn=mr([or({type:kt.Sequence})],Dn);let Ln=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};var Hn;mr([ar({type:Ct.ObjectIdentifier})],Ln.prototype,"attrType",void 0),mr([ar({type:Ct.Any,repeated:"set"})],Ln.prototype,"attrValues",void 0);class Mn{constructor(e={}){this.version=Tn.v0,this.sid=new In,this.digestAlgorithm=new jn,this.signatureAlgorithm=new Un,this.signature=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Mn.prototype,"version",void 0),mr([ar({type:In})],Mn.prototype,"sid",void 0),mr([ar({type:jn})],Mn.prototype,"digestAlgorithm",void 0),mr([ar({type:Ln,repeated:"set",context:0,implicit:!0,optional:!0,raw:!0})],Mn.prototype,"signedAttrs",void 0),mr([ar({type:Un})],Mn.prototype,"signatureAlgorithm",void 0),mr([ar({type:Nt})],Mn.prototype,"signature",void 0),mr([ar({type:Ln,repeated:"set",context:1,implicit:!0,optional:!0})],Mn.prototype,"unsignedAttrs",void 0);let $n=Hn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Hn.prototype)}};$n=Hn=mr([or({type:kt.Set,itemType:Mn})],$n);let Kn=class extends Mn{};Kn=mr([or({type:kt.Sequence})],Kn);let Fn=class extends mn{};Fn=mr([or({type:kt.Choice})],Fn);class _n{constructor(e={}){this.acIssuer=new Vr,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}var Wn;mr([ar({type:Vr})],_n.prototype,"acIssuer",void 0),mr([ar({type:Ct.Integer})],_n.prototype,"acSerial",void 0),mr([ar({type:sn,repeated:"sequence"})],_n.prototype,"attrs",void 0);let zn=Wn=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Wn.prototype)}};zn=Wn=mr([or({type:kt.Sequence,itemType:Ct.ObjectIdentifier})],zn);class qn{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}mr([ar({type:Ct.Integer,optional:!0})],qn.prototype,"pathLenConstraint",void 0),mr([ar({type:zn,implicit:!0,context:0,optional:!0})],qn.prototype,"permittedAttrs",void 0),mr([ar({type:zn,implicit:!0,context:1,optional:!0})],qn.prototype,"excludedAttrs",void 0),mr([ar({type:Ct.Boolean,defaultValue:!0})],qn.prototype,"permitUnSpecified",void 0);class Gn{constructor(e={}){this.issuer=new ti,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}var Jn;mr([ar({type:ti})],Gn.prototype,"issuer",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Gn.prototype,"serial",void 0),mr([ar({type:Ct.BitString,optional:!0})],Gn.prototype,"issuerUID",void 0),function(e){e[e.publicKey=0]="publicKey",e[e.publicKeyCert=1]="publicKeyCert",e[e.otherObjectTypes=2]="otherObjectTypes"}(Jn||(Jn={}));class Xn{constructor(e={}){this.digestedObjectType=Jn.publicKey,this.digestAlgorithm=new gn,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Enumerated})],Xn.prototype,"digestedObjectType",void 0),mr([ar({type:Ct.ObjectIdentifier,optional:!0})],Xn.prototype,"otherObjectTypeID",void 0),mr([ar({type:gn})],Xn.prototype,"digestAlgorithm",void 0),mr([ar({type:Ct.BitString})],Xn.prototype,"objectDigest",void 0);class Zn{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ti,optional:!0})],Zn.prototype,"issuerName",void 0),mr([ar({type:Gn,context:0,implicit:!0,optional:!0})],Zn.prototype,"baseCertificateID",void 0),mr([ar({type:Xn,context:1,implicit:!0,optional:!0})],Zn.prototype,"objectDigestInfo",void 0);let Yn=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,repeated:"sequence"})],Yn.prototype,"v1Form",void 0),mr([ar({type:Zn,context:0,implicit:!0})],Yn.prototype,"v2Form",void 0),Yn=mr([or({type:kt.Choice})],Yn);class Qn{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}mr([ar({type:Ct.GeneralizedTime})],Qn.prototype,"notBeforeTime",void 0),mr([ar({type:Ct.GeneralizedTime})],Qn.prototype,"notAfterTime",void 0);class es{constructor(e={}){Object.assign(this,e)}}var ts,rs,is;mr([ar({type:Gn,implicit:!0,context:0,optional:!0})],es.prototype,"baseCertificateID",void 0),mr([ar({type:ti,implicit:!0,context:1,optional:!0})],es.prototype,"entityName",void 0),mr([ar({type:Xn,implicit:!0,context:2,optional:!0})],es.prototype,"objectDigestInfo",void 0),function(e){e[e.v2=1]="v2"}(ts||(ts={}));class ns{constructor(e={}){this.version=ts.v2,this.holder=new es,this.issuer=new Yn,this.signature=new gn,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new Qn,this.attributes=[],Object.assign(this,e)}}mr([ar({type:Ct.Integer})],ns.prototype,"version",void 0),mr([ar({type:es})],ns.prototype,"holder",void 0),mr([ar({type:Yn})],ns.prototype,"issuer",void 0),mr([ar({type:gn})],ns.prototype,"signature",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ns.prototype,"serialNumber",void 0),mr([ar({type:Qn})],ns.prototype,"attrCertValidityPeriod",void 0),mr([ar({type:sn,repeated:"sequence"})],ns.prototype,"attributes",void 0),mr([ar({type:Ct.BitString,optional:!0})],ns.prototype,"issuerUniqueID",void 0),mr([ar({type:Sn,optional:!0})],ns.prototype,"extensions",void 0);class ss{constructor(e={}){this.acinfo=new ns,this.signatureAlgorithm=new gn,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:ns})],ss.prototype,"acinfo",void 0),mr([ar({type:gn})],ss.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],ss.prototype,"signatureValue",void 0),function(e){e[e.unmarked=1]="unmarked",e[e.unclassified=2]="unclassified",e[e.restricted=4]="restricted",e[e.confidential=8]="confidential",e[e.secret=16]="secret",e[e.topSecret=32]="topSecret"}(rs||(rs={}));class os extends Ot{}class as{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier,implicit:!0,context:0})],as.prototype,"type",void 0),mr([ar({type:Ct.Any,implicit:!0,context:1})],as.prototype,"value",void 0);class cs{constructor(e={}){this.policyId="",this.classList=new os(rs.unclassified),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],cs.prototype,"policyId",void 0),mr([ar({type:os,defaultValue:new os(rs.unclassified)})],cs.prototype,"classList",void 0),mr([ar({type:as,repeated:"set"})],cs.prototype,"securityCategories",void 0);class ls{constructor(e={}){Object.assign(this,e)}}mr([ar({type:Nt})],ls.prototype,"cotets",void 0),mr([ar({type:Ct.ObjectIdentifier})],ls.prototype,"oid",void 0),mr([ar({type:Ct.Utf8String})],ls.prototype,"string",void 0);class us{constructor(e={}){this.values=[],Object.assign(this,e)}}mr([ar({type:ti,implicit:!0,context:0,optional:!0})],us.prototype,"policyAuthority",void 0),mr([ar({type:ls,repeated:"sequence"})],us.prototype,"values",void 0);class hs{constructor(e={}){this.targetCertificate=new Gn,Object.assign(this,e)}}mr([ar({type:Gn})],hs.prototype,"targetCertificate",void 0),mr([ar({type:Vr,optional:!0})],hs.prototype,"targetName",void 0),mr([ar({type:Xn,optional:!0})],hs.prototype,"certDigestInfo",void 0);let ps=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Vr,context:0,implicit:!0})],ps.prototype,"targetName",void 0),mr([ar({type:Vr,context:1,implicit:!0})],ps.prototype,"targetGroup",void 0),mr([ar({type:hs,context:2,implicit:!0})],ps.prototype,"targetCert",void 0),ps=mr([or({type:kt.Choice})],ps);let fs=is=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,is.prototype)}};var ys;fs=is=mr([or({type:kt.Sequence,itemType:ps})],fs);let ds=ys=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ys.prototype)}};ds=ys=mr([or({type:kt.Sequence,itemType:fs})],ds);class gs{constructor(e={}){Object.assign(this,e)}}mr([ar({type:ti,implicit:!0,context:0,optional:!0})],gs.prototype,"roleAuthority",void 0),mr([ar({type:Vr,implicit:!0,context:1})],gs.prototype,"roleName",void 0);class vs{constructor(e={}){this.service=new Vr,this.ident=new Vr,Object.assign(this,e)}}var ms;mr([ar({type:Vr})],vs.prototype,"service",void 0),mr([ar({type:Vr})],vs.prototype,"ident",void 0),mr([ar({type:Nt,optional:!0})],vs.prototype,"authInfo",void 0);class ws{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],ws.prototype,"otherCertFormat",void 0),mr([ar({type:Ct.Any})],ws.prototype,"otherCert",void 0);let bs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:kn})],bs.prototype,"certificate",void 0),mr([ar({type:ss,context:2,implicit:!0})],bs.prototype,"v2AttrCert",void 0),mr([ar({type:ws,context:3,implicit:!0})],bs.prototype,"other",void 0),bs=mr([or({type:kt.Choice})],bs);let As=ms=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,ms.prototype)}};As=ms=mr([or({type:kt.Set,itemType:bs})],As);class Ss{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Ss.prototype,"contentType",void 0),mr([ar({type:Ct.Any,context:0})],Ss.prototype,"content",void 0);let xs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Nt})],xs.prototype,"single",void 0),mr([ar({type:Ct.Any})],xs.prototype,"any",void 0),xs=mr([or({type:kt.Choice})],xs);class Bs{constructor(e={}){this.eContentType="",Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Bs.prototype,"eContentType",void 0),mr([ar({type:xs,context:0,optional:!0})],Bs.prototype,"eContent",void 0);let ks=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Nt,context:0,implicit:!0,optional:!0})],ks.prototype,"value",void 0),mr([ar({type:Nt,converter:Lt,context:0,implicit:!0,optional:!0,repeated:"sequence"})],ks.prototype,"constructedValue",void 0),ks=mr([or({type:kt.Choice})],ks);class Cs{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new Rn,Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Cs.prototype,"contentType",void 0),mr([ar({type:Rn})],Cs.prototype,"contentEncryptionAlgorithm",void 0),mr([ar({type:ks,optional:!0})],Cs.prototype,"encryptedContent",void 0);class Es{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}var Os;mr([ar({type:Ct.ObjectIdentifier})],Es.prototype,"keyAttrId",void 0),mr([ar({type:Ct.Any,optional:!0})],Es.prototype,"keyAttr",void 0);class Ns{constructor(e={}){this.subjectKeyIdentifier=new ln,Object.assign(this,e)}}mr([ar({type:ln})],Ns.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Ct.GeneralizedTime,optional:!0})],Ns.prototype,"date",void 0),mr([ar({type:Es,optional:!0})],Ns.prototype,"other",void 0);let Is=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ns,context:0,implicit:!0,optional:!0})],Is.prototype,"rKeyId",void 0),mr([ar({type:Nn,optional:!0})],Is.prototype,"issuerAndSerialNumber",void 0),Is=mr([or({type:kt.Choice})],Is);class Ts{constructor(e={}){this.rid=new Is,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Is})],Ts.prototype,"rid",void 0),mr([ar({type:Nt})],Ts.prototype,"encryptedKey",void 0);let js=Os=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Os.prototype)}};js=Os=mr([or({type:kt.Sequence,itemType:Ts})],js);class Us{constructor(e={}){this.algorithm=new gn,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:gn})],Us.prototype,"algorithm",void 0),mr([ar({type:Ct.BitString})],Us.prototype,"publicKey",void 0);let Ps=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:ln,context:0,implicit:!0,optional:!0})],Ps.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Us,context:1,implicit:!0,optional:!0})],Ps.prototype,"originatorKey",void 0),mr([ar({type:Nn,optional:!0})],Ps.prototype,"issuerAndSerialNumber",void 0),Ps=mr([or({type:kt.Choice})],Ps);class Rs{constructor(e={}){this.version=Tn.v3,this.originator=new Ps,this.keyEncryptionAlgorithm=new Pn,this.recipientEncryptedKeys=new js,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Rs.prototype,"version",void 0),mr([ar({type:Ps,context:0})],Rs.prototype,"originator",void 0),mr([ar({type:Nt,context:1,optional:!0})],Rs.prototype,"ukm",void 0),mr([ar({type:Pn})],Rs.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:js})],Rs.prototype,"recipientEncryptedKeys",void 0);let Vs=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:ln,context:0,implicit:!0})],Vs.prototype,"subjectKeyIdentifier",void 0),mr([ar({type:Nn})],Vs.prototype,"issuerAndSerialNumber",void 0),Vs=mr([or({type:kt.Choice})],Vs);class Ds{constructor(e={}){this.version=Tn.v0,this.rid=new Vs,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ds.prototype,"version",void 0),mr([ar({type:Vs})],Ds.prototype,"rid",void 0),mr([ar({type:Pn})],Ds.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Ds.prototype,"encryptedKey",void 0);class Ls{constructor(e={}){this.keyIdentifier=new Nt,Object.assign(this,e)}}mr([ar({type:Nt})],Ls.prototype,"keyIdentifier",void 0),mr([ar({type:Ct.GeneralizedTime,optional:!0})],Ls.prototype,"date",void 0),mr([ar({type:Es,optional:!0})],Ls.prototype,"other",void 0);class Hs{constructor(e={}){this.version=Tn.v4,this.kekid=new Ls,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Hs.prototype,"version",void 0),mr([ar({type:Ls})],Hs.prototype,"kekid",void 0),mr([ar({type:Pn})],Hs.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Hs.prototype,"encryptedKey",void 0);class Ms{constructor(e={}){this.version=Tn.v0,this.keyEncryptionAlgorithm=new Pn,this.encryptedKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ms.prototype,"version",void 0),mr([ar({type:Dn,context:0,optional:!0})],Ms.prototype,"keyDerivationAlgorithm",void 0),mr([ar({type:Pn})],Ms.prototype,"keyEncryptionAlgorithm",void 0),mr([ar({type:Nt})],Ms.prototype,"encryptedKey",void 0);class $s{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],$s.prototype,"oriType",void 0),mr([ar({type:Ct.Any})],$s.prototype,"oriValue",void 0);let Ks=class{constructor(e={}){Object.assign(this,e)}};var Fs;mr([ar({type:Ds,optional:!0})],Ks.prototype,"ktri",void 0),mr([ar({type:Rs,context:1,implicit:!0,optional:!0})],Ks.prototype,"kari",void 0),mr([ar({type:Hs,context:2,implicit:!0,optional:!0})],Ks.prototype,"kekri",void 0),mr([ar({type:Ms,context:3,implicit:!0,optional:!0})],Ks.prototype,"pwri",void 0),mr([ar({type:$s,context:4,implicit:!0,optional:!0})],Ks.prototype,"ori",void 0),Ks=mr([or({type:kt.Choice})],Ks);let _s=Fs=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Fs.prototype)}};var Ws;_s=Fs=mr([or({type:kt.Set,itemType:Ks})],_s);class zs{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],zs.prototype,"otherRevInfoFormat",void 0),mr([ar({type:Ct.Any})],zs.prototype,"otherRevInfo",void 0);let qs=class{constructor(e={}){this.other=new zs,Object.assign(this,e)}};mr([ar({type:zs,context:1,implicit:!0})],qs.prototype,"other",void 0),qs=mr([or({type:kt.Choice})],qs);let Gs=Ws=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Ws.prototype)}};Gs=Ws=mr([or({type:kt.Set,itemType:qs})],Gs);class Js{constructor(e={}){Object.assign(this,e)}}var Xs;mr([ar({type:As,context:0,implicit:!0,optional:!0})],Js.prototype,"certs",void 0),mr([ar({type:Gs,context:1,implicit:!0,optional:!0})],Js.prototype,"crls",void 0);let Zs=Xs=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Xs.prototype)}};Zs=Xs=mr([or({type:kt.Set,itemType:Ln})],Zs);class Ys{constructor(e={}){this.version=Tn.v0,this.recipientInfos=new _s,this.encryptedContentInfo=new Cs,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],Ys.prototype,"version",void 0),mr([ar({type:Js,context:0,implicit:!0,optional:!0})],Ys.prototype,"originatorInfo",void 0),mr([ar({type:_s})],Ys.prototype,"recipientInfos",void 0),mr([ar({type:Cs})],Ys.prototype,"encryptedContentInfo",void 0),mr([ar({type:Zs,context:1,implicit:!0,optional:!0})],Ys.prototype,"unprotectedAttrs",void 0);const Qs="1.2.840.113549.1.7.2";var eo;let to=eo=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,eo.prototype)}};to=eo=mr([or({type:kt.Set,itemType:jn})],to);class ro{constructor(e={}){this.version=Tn.v0,this.digestAlgorithms=new to,this.encapContentInfo=new Bs,this.signerInfos=new $n,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],ro.prototype,"version",void 0),mr([ar({type:to})],ro.prototype,"digestAlgorithms",void 0),mr([ar({type:Bs})],ro.prototype,"encapContentInfo",void 0),mr([ar({type:As,context:0,implicit:!0,optional:!0})],ro.prototype,"certificates",void 0),mr([ar({type:Gs,context:1,implicit:!0,optional:!0})],ro.prototype,"crls",void 0),mr([ar({type:$n})],ro.prototype,"signerInfos",void 0);const io="1.2.840.10045.2.1",no="1.2.840.10045.4.1",so="1.2.840.10045.4.3.1",oo="1.2.840.10045.4.3.2",ao="1.2.840.10045.4.3.3",co="1.2.840.10045.4.3.4",lo="1.2.840.10045.3.1.7",uo="1.3.132.0.34",ho="1.3.132.0.35";function po(e){return new gn({algorithm:e})}const fo=po(no);po(so);const yo=po(oo),go=po(ao),vo=po(co);let mo=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.ObjectIdentifier})],mo.prototype,"fieldType",void 0),mr([ar({type:Ct.Any})],mo.prototype,"parameters",void 0),mo=mr([or({type:kt.Sequence})],mo);let wo=class{constructor(e={}){Object.assign(this,e)}};var bo;mr([ar({type:Ct.OctetString})],wo.prototype,"a",void 0),mr([ar({type:Ct.OctetString})],wo.prototype,"b",void 0),mr([ar({type:Ct.BitString,optional:!0})],wo.prototype,"seed",void 0),wo=mr([or({type:kt.Sequence})],wo),function(e){e[e.ecpVer1=1]="ecpVer1"}(bo||(bo={}));let Ao=class{constructor(e={}){this.version=bo.ecpVer1,Object.assign(this,e)}};mr([ar({type:Ct.Integer})],Ao.prototype,"version",void 0),mr([ar({type:mo})],Ao.prototype,"fieldID",void 0),mr([ar({type:wo})],Ao.prototype,"curve",void 0),mr([ar({type:class extends Nt{}})],Ao.prototype,"base",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Ao.prototype,"order",void 0),mr([ar({type:Ct.Integer,optional:!0})],Ao.prototype,"cofactor",void 0),Ao=mr([or({type:kt.Sequence})],Ao);let So=class{constructor(e={}){Object.assign(this,e)}};mr([ar({type:Ct.ObjectIdentifier})],So.prototype,"namedCurve",void 0),mr([ar({type:Ct.Null})],So.prototype,"implicitCurve",void 0),mr([ar({type:Ao})],So.prototype,"specifiedCurve",void 0),So=mr([or({type:kt.Choice})],So);class xo{constructor(e={}){this.version=1,this.privateKey=new Nt,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],xo.prototype,"version",void 0),mr([ar({type:Nt})],xo.prototype,"privateKey",void 0),mr([ar({type:So,context:0,optional:!0})],xo.prototype,"parameters",void 0),mr([ar({type:Ct.BitString,context:1,optional:!0})],xo.prototype,"publicKey",void 0);class Bo{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Bo.prototype,"r",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Bo.prototype,"s",void 0);const ko="1.2.840.113549.1.1",Co=`${ko}.1`,Eo=`${ko}.7`,Oo=`${ko}.9`,No=`${ko}.10`,Io=`${ko}.2`,To=`${ko}.4`,jo=`${ko}.5`,Uo=`${ko}.14`,Po=`${ko}.11`,Ro=`${ko}.12`,Vo=`${ko}.13`,Do=`${ko}.15`,Lo=`${ko}.16`,Ho="1.3.14.3.2.26",Mo="2.16.840.1.101.3.4.2.4",$o="2.16.840.1.101.3.4.2.1",Ko="2.16.840.1.101.3.4.2.2",Fo="2.16.840.1.101.3.4.2.3",_o=`${ko}.8`;function Wo(e){return new gn({algorithm:e,parameters:null})}Wo("1.2.840.113549.2.2"),Wo("1.2.840.113549.2.5");const zo=Wo(Ho);Wo(Mo),Wo($o),Wo(Ko),Wo(Fo),Wo("2.16.840.1.101.3.4.2.5"),Wo("2.16.840.1.101.3.4.2.6");const qo=new gn({algorithm:_o,parameters:pr.serialize(zo)}),Go=new gn({algorithm:Oo,parameters:pr.serialize(Dt.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Wo(Co),Wo(Io),Wo(To),Wo(jo),Wo(Do),Wo(Lo),Wo(Ro),Wo(Vo),Wo(Do),Wo(Lo);class Jo{constructor(e={}){this.hashAlgorithm=new gn(zo),this.maskGenAlgorithm=new gn({algorithm:_o,parameters:pr.serialize(zo)}),this.pSourceAlgorithm=new gn(Go),Object.assign(this,e)}}mr([ar({type:gn,context:0,defaultValue:zo})],Jo.prototype,"hashAlgorithm",void 0),mr([ar({type:gn,context:1,defaultValue:qo})],Jo.prototype,"maskGenAlgorithm",void 0),mr([ar({type:gn,context:2,defaultValue:Go})],Jo.prototype,"pSourceAlgorithm",void 0),new gn({algorithm:Eo,parameters:pr.serialize(new Jo)});class Xo{constructor(e={}){this.hashAlgorithm=new gn(zo),this.maskGenAlgorithm=new gn({algorithm:_o,parameters:pr.serialize(zo)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}mr([ar({type:gn,context:0,defaultValue:zo})],Xo.prototype,"hashAlgorithm",void 0),mr([ar({type:gn,context:1,defaultValue:qo})],Xo.prototype,"maskGenAlgorithm",void 0),mr([ar({type:Ct.Integer,context:2,defaultValue:20})],Xo.prototype,"saltLength",void 0),mr([ar({type:Ct.Integer,context:3,defaultValue:1})],Xo.prototype,"trailerField",void 0),new gn({algorithm:No,parameters:pr.serialize(new Xo)});class Zo{constructor(e={}){this.digestAlgorithm=new gn,this.digest=new Nt,Object.assign(this,e)}}var Yo;mr([ar({type:gn})],Zo.prototype,"digestAlgorithm",void 0),mr([ar({type:Nt})],Zo.prototype,"digest",void 0);class Qo{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"prime",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"exponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],Qo.prototype,"coefficient",void 0);let ea=Yo=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Yo.prototype)}};ea=Yo=mr([or({type:kt.Sequence,itemType:Qo})],ea);class ta{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)}}mr([ar({type:Ct.Integer})],ta.prototype,"version",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"modulus",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"publicExponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"privateExponent",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"prime1",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"prime2",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"exponent1",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"exponent2",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ta.prototype,"coefficient",void 0),mr([ar({type:ea,optional:!0})],ta.prototype,"otherPrimeInfos",void 0);class ra{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}var ia;mr([ar({type:Ct.Integer,converter:Ut})],ra.prototype,"modulus",void 0),mr([ar({type:Ct.Integer,converter:Ut})],ra.prototype,"publicExponent",void 0),function(e){e[e.Transient=0]="Transient",e[e.Singleton=1]="Singleton",e[e.ResolutionScoped=2]="ResolutionScoped",e[e.ContainerScoped=3]="ContainerScoped"}(ia||(ia={}));var na=ia;function sa(e){return!!e.useClass}function oa(e){return!!e.useFactory}var aa=function(){function e(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return e.prototype.createProxy=function(e){var t,r=this,i=!1;return new Proxy({},this.createHandler(function(){return i||(t=e(r.wrap()),i=!0),t}))},e.prototype.createHandler=function(e){var t={};return this.reflectMethods.forEach(function(r){t[r]=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return t[0]=e(),Reflect[r].apply(void 0,xr(t))}}),t},e}();function ca(e){return"string"==typeof e||"symbol"==typeof e}function la(e){return"object"==typeof e&&"token"in e&&"transform"in e}function ua(e){return!!e.useToken}function ha(e){return null!=e.useValue}var pa=function(){function e(){this._registryMap=new Map}return e.prototype.entries=function(){return this._registryMap.entries()},e.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},e.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},e.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},e.prototype.setAll=function(e,t){this._registryMap.set(e,t)},e.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},e.prototype.clear=function(){this._registryMap.clear()},e.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},e}(),fa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),ya=function(){this.scopedResolutions=new Map};function da(e,t,r){var i,n,s=Sr(e.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],o=function(e,t){return null===e?"at position #"+t:'"'+e.split(",")[t].trim()+'" at position #'+t}(void 0===s?null:s,t);return i="Cannot inject the dependency "+o+' of "'+e.name+'" constructor. Reason:',void 0===n&&(n="    "),xr([i],r.message.split("\n").map(function(e){return n+e})).join("\n")}var ga=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),va=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vr(t,e),t}(pa),ma=function(){this.preResolution=new ga,this.postResolution=new va},wa=new Map,ba=function(){function e(e){this.parent=e,this._registry=new fa,this.interceptors=new ma,this.disposed=!1,this.disposables=new Set}return e.prototype.register=function(e,t,r){var i;if(void 0===r&&(r={lifecycle:na.Transient}),this.ensureNotDisposed(),i=function(e){return sa(e)||ha(e)||ua(e)||oa(e)}(t)?t:{useClass:t},ua(i))for(var n=[e],s=i;null!=s;){var o=s.useToken;if(n.includes(o))throw new Error("Token registration cycle detected! "+xr(n,[o]).join(" -> "));n.push(o);var a=this._registry.get(o);s=a&&ua(a.provider)?a.provider:null}if((r.lifecycle===na.Singleton||r.lifecycle==na.ContainerScoped||r.lifecycle==na.ResolutionScoped)&&(ha(i)||oa(i)))throw new Error('Cannot use lifecycle "'+na[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:r}),this},e.prototype.registerType=function(e,t){return this.ensureNotDisposed(),ca(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},e.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},e.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),ca(e)){if(ca(t))return this.register(e,{useToken:t},{lifecycle:na.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:na.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=e;return t&&!ca(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:na.Singleton})},e.prototype.resolve=function(e,t,r){void 0===t&&(t=new ya),void 0===r&&(r=!1),this.ensureNotDisposed();var i=this.getRegistration(e);if(!i&&ca(e)){if(r)return;throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"Single"),i){var n=this.resolveRegistration(i,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}if(function(e){return"function"==typeof e||e instanceof aa}(e)){n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,"Single"),n}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},e.prototype.executePreResolutionInterceptor=function(e,t){var r,i;if(this.interceptors.preResolution.has(e)){var n=[];try{for(var s=Ar(this.interceptors.preResolution.getAll(e)),o=s.next();!o.done;o=s.next()){var a=o.value;"Once"!=a.options.frequency&&n.push(a),a.callback(e,t)}}catch(e){r={error:e}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(e,n)}},e.prototype.executePostResolutionInterceptor=function(e,t,r){var i,n;if(this.interceptors.postResolution.has(e)){var s=[];try{for(var o=Ar(this.interceptors.postResolution.getAll(e)),a=o.next();!a.done;a=o.next()){var c=a.value;"Once"!=c.options.frequency&&s.push(c),c.callback(e,t,r)}}catch(e){i={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,s)}},e.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===na.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var r,i=e.options.lifecycle===na.Singleton,n=e.options.lifecycle===na.ContainerScoped,s=i||n;return r=ha(e.provider)?e.provider.useValue:ua(e.provider)?s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):sa(e.provider)?s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):oa(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===na.ResolutionScoped&&t.scopedResolutions.set(e,r),r},e.prototype.resolveAll=function(e,t,r){var i=this;void 0===t&&(t=new ya),void 0===r&&(r=!1),this.ensureNotDisposed();var n=this.getAllRegistrations(e);if(!n&&ca(e)){if(r)return[];throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"')}if(this.executePreResolutionInterceptor(e,"All"),n){var s=n.map(function(e){return i.resolveRegistration(e,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},e.prototype.isRegistered=function(e,t){return void 0===t&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},e.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},e.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var r=Ar(this._registry.entries()),i=r.next();!i.done;i=r.next()){var n=Sr(i.value,2),s=n[0],o=n[1];this._registry.setAll(s,o.filter(function(e){return!ha(e.provider)}).map(function(e){return e.instance=void 0,e}))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.createChildContainer=function(){var t,r;this.ensureNotDisposed();var i=new e(this);try{for(var n=Ar(this._registry.entries()),s=n.next();!s.done;s=n.next()){var o=Sr(s.value,2),a=o[0],c=o[1];c.some(function(e){return e.options.lifecycle===na.ContainerScoped})&&i._registry.setAll(a,c.map(function(e){return e.options.lifecycle===na.ContainerScoped?{provider:e.provider,options:e.options}:e}))}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return i},e.prototype.beforeResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:r})},e.prototype.afterResolution=function(e,t,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:r})},e.prototype.dispose=function(){return wr(this,void 0,void 0,function(){var e;return br(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(t){var r=t.dispose();r&&e.push(r)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},e.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},e.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},e.prototype.construct=function(e,t){var r=this;if(e instanceof aa)return e.createProxy(function(e){return r.resolve(e,t)});var i,n=function(){var i=wa.get(e);if(!i||0===i.length){if(0===e.length)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var n=i.map(r.resolveParams(t,e));return new(e.bind.apply(e,xr([void 0],n)))}();return"function"!=typeof(i=n).dispose||i.dispose.length>0||this.disposables.add(n),n},e.prototype.resolveParams=function(e,t){var r=this;return function(i,n){var s,o,a,c;try{return"object"==typeof(c=i)&&"token"in c&&"multiple"in c?la(i)?i.multiple?(s=r.resolve(i.transform)).transform.apply(s,xr([r.resolveAll(i.token,new ya,i.isOptional)],i.transformArgs)):(o=r.resolve(i.transform)).transform.apply(o,xr([r.resolve(i.token,e,i.isOptional)],i.transformArgs)):i.multiple?r.resolveAll(i.token,new ya,i.isOptional):r.resolve(i.token,e,i.isOptional):la(i)?(a=r.resolve(i.transform,e)).transform.apply(a,xr([r.resolve(i.token,e)],i.transformArgs)):r.resolve(i,e)}catch(e){throw new Error(da(t,n,e))}}},e.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},e}(),Aa=new ba;function Sa(e){return function(e){wa.set(e,function(e){var t=Reflect.getMetadata("design:paramtypes",e)||[],r=Reflect.getOwnMetadata("injectionTokens",e)||{};return Object.keys(r).forEach(function(e){t[+e]=r[e]}),t}(e))}}if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");const xa="crypto.algorithm";class Ba{getAlgorithms(){return Aa.resolveAll(xa)}toAsnAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toAsnAlgorithm(e);if(r)return r}if(/^[0-9.]+$/.test(e.name)){const t=new gn({algorithm:e.name});if("parameters"in e){const r=e;t.parameters=r.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const t of this.getAlgorithms()){const r=t.toWebAlgorithm(e);if(r)return r}return{name:e.algorithm,parameters:e.parameters}}}const ka="crypto.algorithmProvider";var Ca;Aa.registerSingleton(ka,Ba);const Ea="1.3.36.3.3.2.8.1.1",Oa=`${Ea}.1`,Na=`${Ea}.2`,Ia=`${Ea}.3`,Ta=`${Ea}.4`,ja=`${Ea}.5`,Ua=`${Ea}.6`,Pa=`${Ea}.7`,Ra=`${Ea}.8`,Va=`${Ea}.9`,Da=`${Ea}.10`,La=`${Ea}.11`,Ha=`${Ea}.12`,Ma=`${Ea}.13`,$a=`${Ea}.14`,Ka="brainpoolP160r1",Fa="brainpoolP160t1",_a="brainpoolP192r1",Wa="brainpoolP192t1",za="brainpoolP224r1",qa="brainpoolP224t1",Ga="brainpoolP256r1",Ja="brainpoolP256t1",Xa="brainpoolP320r1",Za="brainpoolP320t1",Ya="brainpoolP384r1",Qa="brainpoolP384t1",ec="brainpoolP512r1",tc="brainpoolP512t1",rc="ECDSA";e.EcAlgorithm=Ca=class{toAsnAlgorithm(e){if(e.name.toLowerCase()===rc.toLowerCase())if("hash"in e){switch(("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase()){case"sha-1":return fo;case"sha-256":return yo;case"sha-384":return go;case"sha-512":return vo}}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=lo;break;case"K-256":t=Ca.SECP256K1;break;case"P-384":t=uo;break;case"P-521":t=ho;break;case Ka:t=Oa;break;case Fa:t=Na;break;case _a:t=Ia;break;case Wa:t=Ta;break;case za:t=ja;break;case qa:t=Ua;break;case Ga:t=Pa;break;case Ja:t=Ra;break;case Xa:t=Va;break;case Za:t=Da;break;case Ya:t=La;break;case Qa:t=Ha;break;case ec:t=Ma;break;case tc:t=$a}if(t)return new gn({algorithm:io,parameters:pr.serialize(new So({namedCurve:t}))})}return null}toWebAlgorithm(e){switch(e.algorithm){case no:return{name:rc,hash:{name:"SHA-1"}};case oo:return{name:rc,hash:{name:"SHA-256"}};case ao:return{name:rc,hash:{name:"SHA-384"}};case co:return{name:rc,hash:{name:"SHA-512"}};case io:if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(pr.parse(e.parameters,So).namedCurve){case lo:return{name:rc,namedCurve:"P-256"};case Ca.SECP256K1:return{name:rc,namedCurve:"K-256"};case uo:return{name:rc,namedCurve:"P-384"};case ho:return{name:rc,namedCurve:"P-521"};case Oa:return{name:rc,namedCurve:Ka};case Na:return{name:rc,namedCurve:Fa};case Ia:return{name:rc,namedCurve:_a};case Ta:return{name:rc,namedCurve:Wa};case ja:return{name:rc,namedCurve:za};case Ua:return{name:rc,namedCurve:qa};case Pa:return{name:rc,namedCurve:Ga};case Ra:return{name:rc,namedCurve:Ja};case Va:return{name:rc,namedCurve:Xa};case Da:return{name:rc,namedCurve:Za};case La:return{name:rc,namedCurve:Ya};case Ha:return{name:rc,namedCurve:Qa};case Ma:return{name:rc,namedCurve:ec};case $a:return{name:rc,namedCurve:tc}}}return null}},e.EcAlgorithm.SECP256K1="1.3.132.0.10",e.EcAlgorithm=Ca=mr([Sa()],e.EcAlgorithm),Aa.registerSingleton(xa,e.EcAlgorithm);const ic=Symbol("name"),nc=Symbol("value");class sc{constructor(e,t={},r=""){this[ic]=e,this[nc]=r;for(const e in t)this[e]=t[e]}}sc.NAME=ic,sc.VALUE=nc;class oc{static toTextObject(t){const r=new sc("Algorithm Identifier",{},ac.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case io:{const i=(new e.EcAlgorithm).toWebAlgorithm(t);i&&"namedCurve"in i?r["Named Curve"]=i.namedCurve:r.Parameters=t.parameters;break}default:r.Parameters=t.parameters}return r}}class ac{static toString(e){const t=this.items[e];return t||e}}ac.items={[Ho]:"sha1",[Mo]:"sha224",[$o]:"sha256",[Ko]:"sha384",[Fo]:"sha512",[Co]:"rsaEncryption",[jo]:"sha1WithRSAEncryption",[Uo]:"sha224WithRSAEncryption",[Po]:"sha256WithRSAEncryption",[Ro]:"sha384WithRSAEncryption",[Vo]:"sha512WithRSAEncryption",[io]:"ecPublicKey",[no]:"ecdsaWithSHA1",[so]:"ecdsaWithSHA224",[oo]:"ecdsaWithSHA256",[ao]:"ecdsaWithSHA384",[co]:"ecdsaWithSHA512",[ji]:"TLS WWW server authentication",[Ui]:"TLS WWW client authentication",[Pi]:"Code Signing",[Ri]:"E-mail Protection",[Vi]:"Time Stamping",[Di]:"OCSP Signing",[Qs]:"Signed Data"};class cc{static serialize(e){return this.serializeObj(e).join("\n")}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const r=[];let i=this.pad(t++),s="";const o=e[sc.VALUE];o&&(s=` ${o}`),r.push(`${i}${e[sc.NAME]}:${s}`),i=this.pad(t);for(const s in e){if("symbol"==typeof s)continue;const o=e[s],a=s?`${s}: `:"";if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)r.push(`${i}${a}${o}`);else if(o instanceof Date)r.push(`${i}${a}${o.toUTCString()}`);else if(Array.isArray(o))for(const e of o)e[sc.NAME]=s,r.push(...this.serializeObj(e,t));else if(o instanceof sc)o[sc.NAME]=s,r.push(...this.serializeObj(o,t));else if(n.isBufferSource(o))s?(r.push(`${i}${a}`),r.push(...this.serializeBufferSource(o,t+1))):r.push(...this.serializeBufferSource(o,t));else{if(!("toTextObject"in o))throw new TypeError("Cannot serialize data in text format. Unsupported type.");{const e=o.toTextObject();e[sc.NAME]=s,r.push(...this.serializeObj(e,t))}}}return r}static serializeBufferSource(e,t=0){const r=this.pad(t),i=n.toUint8Array(e),s=[];for(let e=0;e<i.length;){const t=[];for(let r=0;r<16&&e<i.length;r++){8===r&&t.push("");const n=i[e++].toString(16).padStart(2,"0");t.push(n)}s.push(`${r}${t.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}var lc,uc;cc.oidSerializer=ac,cc.algorithmSerializer=oc;class hc{get rawData(){return Br(this,lc,"f")||kr(this,lc,pr.serialize(this.asn),"f"),Br(this,lc,"f")}constructor(...e){lc.set(this,void 0),n.isBufferSource(e[0])?(this.asn=pr.parse(e[0],e[1]),kr(this,lc,n.toArrayBuffer(e[0]),"f"),this.onInit(this.asn)):(this.asn=e[0],this.onInit(this.asn))}equal(e){return e instanceof hc&&p(e.rawData,this.rawData)}toString(e="text"){switch(e){case"asn":return pr.toString(this.rawData);case"text":return cc.serialize(this.toTextObject());case"hex":return h.ToHex(this.rawData);case"base64":return h.ToBase64(this.rawData);case"base64url":return h.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const e=this.toTextObjectEmpty();return e[""]=this.rawData,e}toTextObjectEmpty(e){return new sc(this.getTextName(),{},e)}}lc=new WeakMap,hc.NAME="ASN";class pc extends hc{constructor(...e){let t;t=n.isBufferSource(e[0])?n.toArrayBuffer(e[0]):pr.serialize(new An({extnID:e[0],critical:e[1],extnValue:new Nt(n.toArrayBuffer(e[2]))})),super(t,An)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.value,e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty(this.critical?"critical":void 0);return e[sc.NAME]===pc.NAME&&(e[sc.NAME]=ac.toString(this.type)),e}}class fc{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&void 0!==e.extractable}constructor(){this.items=new Map,this[uc]="CryptoProvider","undefined"!=typeof self&&"undefined"!=typeof crypto?this.set(fc.DEFAULT,crypto):"undefined"!=typeof global&&global.crypto&&global.crypto.subtle&&this.set(fc.DEFAULT,global.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=fc.DEFAULT){const t=this.items.get(e.toLowerCase());if(!t)throw new Error(`Cannot get Crypto by name '${e}'`);return t}set(e,t){if("string"==typeof e){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(fc.DEFAULT,e);return this}}uc=Symbol.toStringTag,fc.DEFAULT="default";const yc=new fc,dc=/^[0-2](?:\.[1-9][0-9]*)+$/;class gc{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return t=e,new RegExp(dc).test(t)?e:this.get(e);var t}register(e,t){this.items[e]=t,this.items[t]=e}}const vc=new gc;function mc(e,t){return`\\${h.ToHex(h.FromUtf8String(t)).toUpperCase()}`}vc.register("CN","2.5.4.3"),vc.register("L","2.5.4.7"),vc.register("ST","2.5.4.8"),vc.register("O","2.5.4.10"),vc.register("OU","2.5.4.11"),vc.register("C","2.5.4.6"),vc.register("DC","0.9.2342.19200300.100.1.25"),vc.register("E","1.2.840.113549.1.9.1"),vc.register("G","2.5.4.42"),vc.register("I","2.5.4.43"),vc.register("SN","2.5.4.4"),vc.register("T","2.5.4.12");class wc{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 gc,this.asn=new jr;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const r=t[e];this.extraNames.register(e,r)}"string"==typeof e?this.asn=this.fromString(e):e instanceof jr?this.asn=e:n.isBufferSource(e)?this.asn=pr.parse(e,jr):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||vc.findId(e),r=[];for(const e of this.asn)for(const i of e)i.type===t&&r.push(i.value.toString());return r}getName(e){return this.extraNames.get(e)||vc.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${h.ToHex(e.value.anyValue)}`:e.value.toString().replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,mc)}`).join("+")).join(", ")}toJSON(){var e;const t=[];for(const r of this.asn){const i={};for(const t of r){const r=this.getName(t.type)||t.type;null!==(e=i[r])&&void 0!==e||(i[r]=[]),i[r].push(t.value.anyValue?`#${h.ToHex(t.value.anyValue)}`:t.value.toString())}t.push(i)}return t}fromString(e){const t=new jr,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+"\\](?=[,+]|$))|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,n=",";for(;i=r.exec(`${e},`);){let[,e,r]=i;const s=r[r.length-1];","!==s&&"+"!==s||(r=r.slice(0,r.length-1),i[3]=s);const o=i[3];e=this.getTypeOid(e);const a=this.createAttribute(e,r);"+"===n?t[t.length-1].push(a):t.push(new Ir([a])),n=o}return t}fromJSON(e){const t=new jr;for(const r of e){const e=new Ir;for(const t in r){const i=this.getTypeOid(t),n=r[t];for(const t of n){const r=this.createAttribute(i,t);e.push(r)}}t.push(e)}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){const r=new Nr({type:e});if("object"==typeof t)for(const e in t)switch(e){case"ia5String":r.value.ia5String=t[e];break;case"utf8String":r.value.utf8String=t[e];break;case"universalString":r.value.universalString=t[e];break;case"bmpString":r.value.bmpString=t[e];break;case"printableString":r.value.printableString=t[e]}else if("#"===t[0])r.value.anyValue=h.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?r.value.ia5String=i:wc.isPrintableString(i)?r.value.printableString=i:r.value.utf8String=i}return r}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1")}toArrayBuffer(){return pr.serialize(this.asn)}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||yc.get()):r=e[0]||yc.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const bc="Cannot initialize GeneralName from ASN.1 data.",Ac=`${bc} Unsupported string format in use.`,Sc=`${bc} Value doesn't match to GUID regular expression.`,xc=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Bc="1.3.6.1.4.1.311.25.1",kc="1.3.6.1.4.1.311.20.2.3",Cc="dns",Ec="dn",Oc="email",Nc="ip",Ic="url",Tc="guid",jc="upn",Uc="id";class Pc extends hc{constructor(...e){let t;if(2===e.length)switch(e[0]){case Ec:{const r=new wc(e[1]).toArrayBuffer(),i=pr.parse(r,jr);t=new Vr({directoryName:i});break}case Cc:t=new Vr({dNSName:e[1]});break;case Oc:t=new Vr({rfc822Name:e[1]});break;case Tc:{const r=new RegExp(xc,"i").exec(e[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map((e,t)=>t<3?h.ToHex(new Uint8Array(h.FromHex(e)).reverse()):e).join("");t=new Vr({otherName:new Pr({typeId:Bc,value:pr.serialize(new Nt(h.FromHex(i)))})});break}case Nc:t=new Vr({iPAddress:e[1]});break;case Uc:t=new Vr({registeredID:e[1]});break;case jc:t=new Vr({otherName:new Pr({typeId:kc,value:pr.serialize(Mt.toASN(e[1]))})});break;case Ic:t=new Vr({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else t=n.isBufferSource(e[0])?pr.parse(e[0],Vr):e[0];super(t)}onInit(e){if(null!=e.dNSName)this.type=Cc,this.value=e.dNSName;else if(null!=e.rfc822Name)this.type=Oc,this.value=e.rfc822Name;else if(null!=e.iPAddress)this.type=Nc,this.value=e.iPAddress;else if(null!=e.uniformResourceIdentifier)this.type=Ic,this.value=e.uniformResourceIdentifier;else if(null!=e.registeredID)this.type=Uc,this.value=e.registeredID;else if(null!=e.directoryName)this.type=Ec,this.value=new wc(e.directoryName).toString();else{if(null==e.otherName)throw new Error(Ac);if(e.otherName.typeId===Bc){this.type=Tc;const t=pr.parse(e.otherName.value,Nt),r=new RegExp(xc,"i").exec(h.ToHex(t));if(!r)throw new Error(Sc);this.value=r.slice(1).map((e,t)=>t<3?h.ToHex(new Uint8Array(h.FromHex(e)).reverse()):e).join("-")}else{if(e.otherName.typeId!==kc)throw new Error(Ac);this.type=jc,this.value=pr.parse(e.otherName.value,Er).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Ec:case Cc:case Tc:case Nc:case Uc:case jc:case Ic:e=this.type.toUpperCase();break;case Oc:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===Uc&&(t=ac.toString(t)),new sc(e,void 0,t)}}class Rc extends hc{constructor(e){let t;if(e instanceof ti)t=e;else if(Array.isArray(e)){const r=[];for(const t of e)if(t instanceof Vr)r.push(t);else{const e=pr.parse(new Pc(t.type,t.value).rawData,Vr);r.push(e)}t=new ti(r)}else{if(!n.isBufferSource(e))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");t=pr.parse(e,ti)}super(t)}onInit(e){const t=[];for(const r of e){let e=null;try{e=new Pc(r)}catch(e){continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const r=t.toTextObject();let i=e[r[sc.NAME]];Array.isArray(i)||(i=[],e[r[sc.NAME]]=i),i.push(r)}return e}}Rc.NAME="GeneralNames";const Vc="-{5}",Dc="\\n",Lc="\\n",Hc=`${`${Vc}BEGIN (${`[^${Dc}]+`}(?=${Vc}))${Vc}`}${Lc}(?:((?:${`[^:${Dc}]+`}: ${`(?:[^${Dc}]+${Lc}(?: +[^${Dc}]+${Lc})*)`})+))?${Lc}?(${`(?:[a-zA-Z0-9=+/]+${Lc})+`})${`${Vc}END \\1${Vc}`}`;class Mc{static isPem(e){return"string"==typeof e&&new RegExp(Hc,"g").test(e.replace(/\r/g,""))}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Hc,"g"),r=[];let i=null;for(;i=t.exec(e);){const e=i[3].replace(new RegExp(`[${Dc}]+`,"g"),""),t={type:i[1],headers:[],rawData:h.FromBase64(e)},n=i[2];if(n){const e=n.split(new RegExp(Lc,"g"));let r=null;for(const i of e){const[e,n]=i.split(/:(.*)/);if(void 0===n){if(!r)throw new Error("Cannot parse PEM string. Incorrect header value");r.value+=e.trim()}else r&&t.headers.push(r),r={key:e,value:n.trim()}}r&&t.headers.push(r)}r.push(t)}return r}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){const 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)){const r=new Array;return t?e.forEach(e=>{if(!n.isBufferSource(e))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:t,rawData:n.toArrayBuffer(e)}))}):e.forEach(e=>{if(!("type"in e))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(e))}),r.join("\n")}if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:n.toArrayBuffer(e)})}static encodeStruct(e){var t;const r=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),null===(t=e.headers)||void 0===t?void 0:t.length){for(const t of e.headers)i.push(`${t.key}: ${t.value}`);i.push("")}const n=h.ToBase64(e.rawData);let s,o=0;const a=Array();for(;o<n.length&&(n.length-o<64?s=n.substring(o):(s=n.substring(o,o+64),o+=64),0!==s.length)&&(a.push(s),!(s.length<64)););return i.push(...a),i.push(`-----END ${r}-----`),i.join("\n")}}Mc.CertificateTag="CERTIFICATE",Mc.CrlTag="CRL",Mc.CertificateRequestTag="CERTIFICATE REQUEST",Mc.PublicKeyTag="PUBLIC KEY",Mc.PrivateKeyTag="PRIVATE KEY";class $c extends hc{static isAsnEncoded(e){return n.isBufferSource(e)||"string"==typeof e}static toArrayBuffer(e){if("string"==typeof e){if(Mc.isPem(e))return Mc.decode(e)[0];if(h.isHex(e))return h.FromHex(e);if(h.isBase64(e))return h.FromBase64(e);if(h.isBase64Url(e))return h.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}{const t=n.toUint8Array(e);if(t.length>0&&48===t[0])return n.toArrayBuffer(e);const r=h.ToBinary(e);if(Mc.isPem(r))return Mc.decode(r)[0];if(h.isHex(r))return h.FromHex(r);if(h.isBase64(r))return h.FromBase64(r);if(h.isBase64Url(r))return h.FromBase64Url(r);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}}constructor(...e){$c.isAsnEncoded(e[0])?super($c.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){return"pem"===e?Mc.encode(this.rawData,this.tag):super.toString(e)}}class Kc extends $c{static async create(e,t=yc.get()){if(e instanceof Kc)return e;if(fc.isCryptoKey(e)){if("public"!==e.type)throw new TypeError("Public key is required");const r=await t.subtle.exportKey("spki",e);return new Kc(r)}if(e.publicKey)return e.publicKey;if(n.isBufferSource(e))return new Kc(e);throw new TypeError("Unsupported PublicKeyType")}constructor(e){$c.isAsnEncoded(e)?super(e,vn):super(e),this.tag=Mc.PublicKeyTag}async export(...e){let t,r=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,r=e[1]||r,t=e[2]||yc.get()):t=e[0]||yc.get();let n=this.rawData;const s=pr.parse(this.rawData,vn);return s.algorithm.algorithm===No&&(n=function(e,t){return e.algorithm=new gn({algorithm:Co,parameters:null}),t=pr.serialize(e),t}(s,n)),t.subtle.importKey("spki",n,i,!0,r)}onInit(e){const t=Aa.resolve(ka),r=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case Co:{const t=pr.parse(e.subjectPublicKey,ra),i=n.toUint8Array(t.modulus);r.publicExponent=n.toUint8Array(t.publicExponent),r.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let r,i="SHA-1";return e.length>=1&&!(null===(t=e[0])||void 0===t?void 0:t.subtle)?(i=e[0]||i,r=e[1]||yc.get()):r=e[0]||yc.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,r="SHA-1";1===e.length?"string"==typeof e[0]?(r=e[0],t=yc.get()):t=e[0]:2===e.length?(r=e[0],t=e[1]):t=yc.get();const i=pr.parse(this.rawData,vn);return await t.subtle.digest(r,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=pr.parse(this.rawData,vn);if(e.Algorithm=cc.serializeAlgorithm(t.algorithm),t.algorithm.algorithm===io)e["EC Point"]=t.subjectPublicKey;else e["Raw Data"]=t.subjectPublicKey;return e}}class Fc extends pc{static async create(e,t=!1,r=yc.get()){if("name"in e&&"serialNumber"in e)return new Fc(e,t);const i=await Kc.create(e,r),n=await i.getKeyIdentifier(r);return new Fc(h.ToHex(n),t)}constructor(...e){if(n.isBufferSource(e[0]))super(e[0]);else if("string"==typeof e[0]){const t=new Zr({keyIdentifier:new Xr(h.FromHex(e[0]))});super(Jr,e[1],pr.serialize(t))}else{const t=e[0],r=t.name instanceof Rc?pr.parse(t.name.rawData,ti):t.name,i=new Zr({authorityCertIssuer:r,authorityCertSerialNumber:h.FromHex(t.serialNumber)});super(Jr,e[1],pr.serialize(i))}}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,Zr);t.keyIdentifier&&(this.keyId=h.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?h.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,Zr);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Rc(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Fc.NAME="Authority Key Identifier";class _c extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,Qr);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new Qr({cA:e[0],pathLenConstraint:e[1]});super(Yr,e[2],pr.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),void 0!==this.pathLength&&(e["Path Length"]=this.pathLength),e}}_c.NAME="Basic Constraints",e.ExtendedKeyUsage=void 0,function(e){e.serverAuth="1.3.6.1.5.5.7.3.1",e.clientAuth="1.3.6.1.5.5.7.3.2",e.codeSigning="1.3.6.1.5.5.7.3.3",e.emailProtection="1.3.6.1.5.5.7.3.4",e.timeStamping="1.3.6.1.5.5.7.3.8",e.ocspSigning="1.3.6.1.5.5.7.3.9"}(e.ExtendedKeyUsage||(e.ExtendedKeyUsage={}));class Wc extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,Ti);this.usages=t.map(e=>e)}else{const t=new Ti(e[0]);super(Ii,e[1],pr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(e=>ac.toString(e)).join(", "),e}}Wc.NAME="Extended Key Usages",e.KeyUsageFlags=void 0,function(e){e[e.digitalSignature=1]="digitalSignature",e[e.nonRepudiation=2]="nonRepudiation",e[e.keyEncipherment=4]="keyEncipherment",e[e.dataEncipherment=8]="dataEncipherment",e[e.keyAgreement=16]="keyAgreement",e[e.keyCertSign=32]="keyCertSign",e[e.cRLSign=64]="cRLSign",e[e.encipherOnly=128]="encipherOnly",e[e.decipherOnly=256]="decipherOnly"}(e.KeyUsageFlags||(e.KeyUsageFlags={}));class zc extends pc{constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,qi);this.usages=t.toNumber()}else{const t=new qi(e[0]);super(_i,e[1],pr.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,qi);return e[""]=t.toJSON().join(", "),e}}zc.NAME="Key Usages";class qc extends pc{static async create(e,t=!1,r=yc.get()){const i=await Kc.create(e,r),n=await i.getKeyIdentifier(r);return new qc(h.ToHex(n),t)}constructor(...e){if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,ln);this.keyId=h.ToHex(t)}else{const t="string"==typeof e[0]?h.FromHex(e[0]):e[0],r=new ln(t);super(cn,e[1],pr.serialize(r)),this.keyId=h.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=pr.parse(this.value,ln);return e[""]=t,e}}qc.NAME="Subject Key Identifier";class Gc extends pc{constructor(...e){n.isBufferSource(e[0])?super(e[0]):super(rn,e[1],new Rc(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,nn);this.names=new Rc(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const r in t)e[r]=t[r];return e}}Gc.NAME="Subject Alternative Name";class Jc{static register(e,t){this.items.set(e,t)}static create(e){const t=new pc(e),r=this.items.get(t.type);return r?new r(e):t}}Jc.items=new Map;class Xc extends pc{constructor(...e){var t;if(n.isBufferSource(e[0])){super(e[0]);const t=pr.parse(this.value,fi);this.policies=t.map(e=>e.policyIdentifier)}else{const r=e[0],i=null!==(t=e[1])&&void 0!==t&&t,n=new fi(r.map(e=>new pi({policyIdentifier:e})));super(oi,i,pr.serialize(n)),this.policies=r}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new sc("",{},ac.toString(e))),e}}Xc.NAME="Certificate Policies",Jc.register(oi,Xc);class Zc extends pc{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&"string"==typeof e[0][0]){const t=e[0].map(e=>new Ai({distributionPoint:new bi({fullName:[new Vr({uniformResourceIdentifier:e})]})})),r=new Si(t);super(vi,e[1],pr.serialize(r))}else{const t=new Si(e[0]);super(vi,e[1],pr.serialize(t))}null!==(t=this.distributionPoints)&&void 0!==t||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,Si);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(e=>{var t;const r={};return e.distributionPoint&&(r[""]=null===(t=e.distributionPoint.fullName)||void 0===t?void 0:t.map(e=>new Pc(e).toString()).join(", ")),e.reasons&&(r.Reasons=e.reasons.toString()),e.cRLIssuer&&(r["CRL Issuer"]=e.cRLIssuer.map(e=>e.toString()).join(", ")),r}),e}}Zc.NAME="CRL Distribution Points";class Yc extends pc{constructor(...e){var t,r,i,s;if(n.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Gr){const t=new Gr(e[0]);super(zr,e[1],pr.serialize(t))}else{const t=e[0],r=new Gr;el(r,t,Mr,"ocsp"),el(r,t,$r,"caIssuers"),el(r,t,Kr,"timeStamping"),el(r,t,Fr,"caRepository"),super(zr,e[1],pr.serialize(r))}null!==(t=this.ocsp)&&void 0!==t||(this.ocsp=[]),null!==(r=this.caIssuers)&&void 0!==r||(this.caIssuers=[]),null!==(i=this.timeStamping)&&void 0!==i||(this.timeStamping=[]),null!==(s=this.caRepository)&&void 0!==s||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[];pr.parse(e.extnValue,Gr).forEach(e=>{switch(e.accessMethod){case Mr:this.ocsp.push(new Pc(e.accessLocation));break;case $r:this.caIssuers.push(new Pc(e.accessLocation));break;case Kr:this.timeStamping.push(new Pc(e.accessLocation));break;case Fr:this.caRepository.push(new Pc(e.accessLocation))}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&Qc(e,"OCSP",this.ocsp),this.caIssuers.length&&Qc(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&Qc(e,"Time Stamping",this.timeStamping),this.caRepository.length&&Qc(e,"CA Repository",this.caRepository),e}}function Qc(e,t,r){if(1===r.length)e[t]=r[0].toTextObject();else{const i=new sc("");r.forEach((e,t)=>{const r=e.toTextObject(),n=`${r[sc.NAME]} ${t+1}`;let s=i[n];Array.isArray(s)||(s=[],i[n]=s),s.push(r)}),e[t]=i}}function el(e,t,r,i){const n=t[i];if(n){(Array.isArray(n)?n:[n]).forEach(t=>{"string"==typeof t&&(t=new Pc("url",t)),e.push(new qr({accessMethod:r,accessLocation:pr.parse(t.rawData,Vr)}))})}}Yc.NAME="Authority Info Access";class tl extends pc{constructor(...e){n.isBufferSource(e[0])?super(e[0]):super(Ki,e[1],new Rc(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=pr.parse(e.extnValue,ti);this.names=new Rc(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const r in t)e[r]=t[r];return e}}var rl;tl.NAME="Issuer Alternative Name";class il{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}mr([ar({type:Ct.ObjectIdentifier})],il.prototype,"attrId",void 0),mr([ar({type:Ct.Any,repeated:"set"})],il.prototype,"attrValues",void 0);let nl=rl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,rl.prototype)}};var sl;nl=rl=mr([or({type:kt.Sequence,itemType:il})],nl);let ol=sl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,sl.prototype)}};ol=sl=mr([or({type:kt.Sequence,itemType:Ss})],ol);class al{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],al.prototype,"certId",void 0),mr([ar({type:Ct.Any,context:0})],al.prototype,"certValue",void 0);class cl{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],cl.prototype,"crlId",void 0),mr([ar({type:Ct.Any,context:0})],cl.prototype,"crltValue",void 0);class ll extends Nt{}let ul=class{constructor(e={}){this.encryptionAlgorithm=new gn,this.encryptedData=new ll,Object.assign(this,e)}};var hl,pl;mr([ar({type:gn})],ul.prototype,"encryptionAlgorithm",void 0),mr([ar({type:ll})],ul.prototype,"encryptedData",void 0),function(e){e[e.v1=0]="v1"}(pl||(pl={}));class fl extends Nt{}let yl=hl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,hl.prototype)}};yl=hl=mr([or({type:kt.Sequence,itemType:sn})],yl);class dl{constructor(e={}){this.version=pl.v1,this.privateKeyAlgorithm=new gn,this.privateKey=new fl,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],dl.prototype,"version",void 0),mr([ar({type:gn})],dl.prototype,"privateKeyAlgorithm",void 0),mr([ar({type:fl})],dl.prototype,"privateKey",void 0),mr([ar({type:yl,implicit:!0,context:0,optional:!0})],dl.prototype,"attributes",void 0);let gl=class extends dl{};gl=mr([or({type:kt.Sequence})],gl);let vl=class extends ul{};vl=mr([or({type:kt.Sequence})],vl);class ml{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],ml.prototype,"secretTypeId",void 0),mr([ar({type:Ct.Any,context:0})],ml.prototype,"secretValue",void 0);class wl{constructor(e={}){this.mac=new Zo,this.macSalt=new Nt,this.iterations=1,Object.assign(this,e)}}mr([ar({type:Zo})],wl.prototype,"mac",void 0),mr([ar({type:Nt})],wl.prototype,"macSalt",void 0),mr([ar({type:Ct.Integer,defaultValue:1})],wl.prototype,"iterations",void 0);class bl{constructor(e={}){this.version=3,this.authSafe=new Ss,this.macData=new wl,Object.assign(this,e)}}var Al;mr([ar({type:Ct.Integer})],bl.prototype,"version",void 0),mr([ar({type:Ss})],bl.prototype,"authSafe",void 0),mr([ar({type:wl,optional:!0})],bl.prototype,"macData",void 0);class Sl{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}mr([ar({type:Ct.ObjectIdentifier})],Sl.prototype,"bagId",void 0),mr([ar({type:Ct.Any,context:0})],Sl.prototype,"bagValue",void 0),mr([ar({type:il,repeated:"set",optional:!0})],Sl.prototype,"bagAttributes",void 0);let xl=Al=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Al.prototype)}};var Bl,kl,Cl;xl=Al=mr([or({type:kt.Sequence,itemType:Sl})],xl);const El="1.2.840.113549.1.9",Ol=`${El}.7`,Nl=`${El}.14`;let Il=class extends Er{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};mr([ar({type:Ct.IA5String})],Il.prototype,"ia5String",void 0),Il=mr([or({type:kt.Choice})],Il);let Tl=class extends Ss{};Tl=mr([or({type:kt.Sequence})],Tl);let jl=class extends bl{};jl=mr([or({type:kt.Sequence})],jl);let Ul=class extends ul{};Ul=mr([or({type:kt.Sequence})],Ul);let Pl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.IA5String})],Pl.prototype,"value",void 0),Pl=mr([or({type:kt.Choice})],Pl);let Rl=class extends Il{};Rl=mr([or({type:kt.Choice})],Rl);let Vl=class extends Er{};Vl=mr([or({type:kt.Choice})],Vl);let Dl=class{constructor(e=new Date){this.value=e}};mr([ar({type:Ct.GeneralizedTime})],Dl.prototype,"value",void 0),Dl=mr([or({type:kt.Choice})],Dl);let Ll=class extends Er{};Ll=mr([or({type:kt.Choice})],Ll);let Hl=class{constructor(e="M"){this.value=e}toString(){return this.value}};mr([ar({type:Ct.PrintableString})],Hl.prototype,"value",void 0),Hl=mr([or({type:kt.Choice})],Hl);let Ml=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.PrintableString})],Ml.prototype,"value",void 0),Ml=mr([or({type:kt.Choice})],Ml);let $l=class extends Ml{};$l=mr([or({type:kt.Choice})],$l);let Kl=class extends Er{};Kl=mr([or({type:kt.Choice})],Kl);let Fl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.ObjectIdentifier})],Fl.prototype,"value",void 0),Fl=mr([or({type:kt.Choice})],Fl);let _l=class extends mn{};_l=mr([or({type:kt.Choice})],_l);let Wl=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};mr([ar({type:Ct.Integer})],Wl.prototype,"value",void 0),Wl=mr([or({type:kt.Choice})],Wl);let zl=class extends Mn{};zl=mr([or({type:kt.Sequence})],zl);let ql=class extends Er{};ql=mr([or({type:kt.Choice})],ql);let Gl=Bl=class extends Sn{constructor(e){super(e),Object.setPrototypeOf(this,Bl.prototype)}};Gl=Bl=mr([or({type:kt.Sequence})],Gl);let Jl=kl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};Jl=kl=mr([or({type:kt.Set,itemType:Ln})],Jl);let Xl=class{constructor(e=""){this.value=e}toString(){return this.value}};mr([ar({type:Ct.BmpString})],Xl.prototype,"value",void 0),Xl=mr([or({type:kt.Choice})],Xl);let Zl=class extends gn{};Zl=mr([or({type:kt.Sequence})],Zl);let Yl=Cl=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,Cl.prototype)}};Yl=Cl=mr([or({type:kt.Sequence,itemType:Zl})],Yl);class Ql extends hc{constructor(...e){let t;if(n.isBufferSource(e[0]))t=n.toArrayBuffer(e[0]);else{const r=e[0],i=Array.isArray(e[1])?e[1].map(e=>n.toArrayBuffer(e)):[];t=pr.serialize(new sn({type:r,values:i}))}super(t,sn)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new sc("",{"":e})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[sc.NAME]===Ql.NAME&&(e[sc.NAME]=ac.toString(this.type)),e}}Ql.NAME="Attribute";class eu extends Ql{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else{const t=new ql({printableString:e[0]});super(Ol,[pr.serialize(t)])}null!==(t=this.password)&&void 0!==t||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const e=pr.parse(this.values[0],ql);this.password=e.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[sc.VALUE]=this.password,e}}eu.NAME="Challenge Password";class tu extends Ql{constructor(...e){var t;if(n.isBufferSource(e[0]))super(e[0]);else{const t=e[0],r=new Sn;for(const e of t)r.push(pr.parse(e.rawData,An));super(Nl,[pr.serialize(r)])}null!==(t=this.items)&&void 0!==t||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const e=pr.parse(this.values[0],Sn);this.items=e.map(e=>Jc.create(pr.serialize(e)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(const r of t)e[r[sc.NAME]]=r;return e}}tu.NAME="Extensions";class ru{static register(e,t){this.items.set(e,t)}static create(e){const t=new Ql(e),r=this.items.get(t.type);return r?new r(e):t}}ru.items=new Map;const iu="crypto.signatureFormatter";class nu{toAsnSignature(e,t){return n.toArrayBuffer(t)}toWebSignature(e,t){return n.toArrayBuffer(t)}}var su;e.RsaAlgorithm=su=class{static createPssParams(e,t){const r=su.getHashAlgorithm(e);return r?new Xo({hashAlgorithm:r,maskGenAlgorithm:new gn({algorithm:_o,parameters:pr.serialize(r)}),saltLength:t}):null}static getHashAlgorithm(e){const t=Aa.resolve(ka);return"string"==typeof e?t.toAsnAlgorithm({name:e}):"object"==typeof e&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if(!("hash"in e))return new gn({algorithm:Co,parameters:null});{let t;if("string"==typeof e.hash)t=e.hash;else{if(!e.hash||"object"!=typeof e.hash||!("name"in e.hash)||"string"!=typeof e.hash.name)throw new Error("Cannot get hash algorithm name");t=e.hash.name.toUpperCase()}switch(t.toLowerCase()){case"sha-1":return new gn({algorithm:jo,parameters:null});case"sha-256":return new gn({algorithm:Po,parameters:null});case"sha-384":return new gn({algorithm:Ro,parameters:null});case"sha-512":return new gn({algorithm:Vo,parameters:null})}}break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e)||"number"!=typeof e.saltLength)throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=su.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new gn({algorithm:No,parameters:pr.serialize(t)})}return new gn({algorithm:No,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case Co:return{name:"RSASSA-PKCS1-v1_5"};case jo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Po:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ro:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Vo:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case No:if(e.parameters){const t=pr.parse(e.parameters,Xo);return{name:"RSA-PSS",hash:Aa.resolve(ka).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}return{name:"RSA-PSS"}}return null}},e.RsaAlgorithm=su=mr([Sa()],e.RsaAlgorithm),Aa.registerSingleton(xa,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new gn({algorithm:Ho});case"sha-256":return new gn({algorithm:$o});case"sha-384":return new gn({algorithm:Ko});case"sha-512":return new gn({algorithm:Fo})}return null}toWebAlgorithm(e){switch(e.algorithm){case Ho:return{name:"SHA-1"};case $o:return{name:"SHA-256"};case Ko:return{name:"SHA-384"};case Fo:return{name:"SHA-512"}}return null}},e.ShaAlgorithm=mr([Sa()],e.ShaAlgorithm),Aa.registerSingleton(xa,e.ShaAlgorithm);class ou{addPadding(e,t){const r=n.toUint8Array(t),i=new Uint8Array(e);return i.set(r,e-r.length),i.buffer}removePadding(e,t=!1){let r=n.toUint8Array(e);for(let e=0;e<r.length;e++)if(r[e]){r=r.slice(e);break}if(t&&r[0]>127){const e=new Uint8Array(r.length+1);return e.set(r,1),e.buffer}return r.buffer}toAsnSignature(e,t){if("ECDSA"===e.name){const r=e.namedCurve,i=ou.namedCurveSize.get(r)||ou.defaultNamedCurveSize,s=new Bo,o=n.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),pr.serialize(s)}return null}toWebSignature(e,t){if("ECDSA"===e.name){const r=pr.parse(t,Bo),i=e.namedCurve,n=ou.namedCurveSize.get(i)||ou.defaultNamedCurveSize;return function(...e){const t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(t);let i=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(const t of e)r[i++]=t}),r.buffer}(this.addPadding(n,this.removePadding(r.r)),this.addPadding(n,this.removePadding(r.s)))}return null}}ou.namedCurveSize=new Map,ou.defaultNamedCurveSize=32;const au="1.3.101.110",cu="1.3.101.111",lu="1.3.101.112",uu="1.3.101.113";var hu;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=lu;break;case"x25519":t=au;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=lu;break;case"ed448":t=uu}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=au;break;case"x448":t=cu}}return t?new gn({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case lu:return{name:"Ed25519"};case uu:return{name:"EdDSA",namedCurve:"Ed448"};case au:return{name:"X25519"};case cu:return{name:"ECDH-ES",namedCurve:"X448"}}return null}},e.EdAlgorithm=mr([Sa()],e.EdAlgorithm),Aa.registerSingleton(xa,e.EdAlgorithm);let pu=hu=class extends hr{constructor(e){super(e),Object.setPrototypeOf(this,hu.prototype)}};pu=hu=mr([or({type:kt.Sequence,itemType:sn})],pu);class fu{constructor(e={}){this.version=0,this.subject=new jr,this.subjectPKInfo=new vn,this.attributes=new pu,Object.assign(this,e)}}mr([ar({type:Ct.Integer})],fu.prototype,"version",void 0),mr([ar({type:jr})],fu.prototype,"subject",void 0),mr([ar({type:vn})],fu.prototype,"subjectPKInfo",void 0),mr([ar({type:pu,implicit:!0,context:0,optional:!0})],fu.prototype,"attributes",void 0);class yu{constructor(e={}){this.certificationRequestInfo=new fu,this.signatureAlgorithm=new gn,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}var du,gu,vu,mu,wu,bu,Au,Su,xu,Bu,ku,Cu,Eu,Ou,Nu,Iu,Tu,ju,Uu,Pu,Ru,Vu,Du,Lu,Hu,Mu,$u,Ku,Fu,_u,Wu,zu,qu;mr([ar({type:fu,raw:!0})],yu.prototype,"certificationRequestInfo",void 0),mr([ar({type:gn})],yu.prototype,"signatureAlgorithm",void 0),mr([ar({type:Ct.BitString})],yu.prototype,"signature",void 0);class Gu extends $c{get subjectName(){return Br(this,gu,"f")||kr(this,gu,new wc(this.asn.certificationRequestInfo.subject),"f"),Br(this,gu,"f")}get subject(){return Br(this,vu,"f")||kr(this,vu,this.subjectName.toString(),"f"),Br(this,vu,"f")}get signatureAlgorithm(){if(!Br(this,mu,"f")){const e=Aa.resolve(ka);kr(this,mu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,mu,"f")}get signature(){return Br(this,wu,"f")||kr(this,wu,this.asn.signature,"f"),Br(this,wu,"f")}get publicKey(){return Br(this,bu,"f")||kr(this,bu,new Kc(this.asn.certificationRequestInfo.subjectPKInfo),"f"),Br(this,bu,"f")}get attributes(){return Br(this,Au,"f")||kr(this,Au,this.asn.certificationRequestInfo.attributes.map(e=>ru.create(pr.serialize(e))),"f"),Br(this,Au,"f")}get extensions(){if(!Br(this,Su,"f")){kr(this,Su,[],"f");const e=this.getAttribute(Nl);e instanceof tu&&kr(this,Su,e.items,"f")}return Br(this,Su,"f")}get tbs(){return Br(this,du,"f")||kr(this,du,this.asn.certificationRequestInfoRaw||pr.serialize(this.asn.certificationRequestInfo),"f"),Br(this,du,"f")}constructor(e){const t=$c.isAsnEncoded(e)?[e,yu]:[e];super(t[0],t[1]),du.set(this,void 0),gu.set(this,void 0),vu.set(this,void 0),mu.set(this,void 0),wu.set(this,void 0),bu.set(this,void 0),Au.set(this,void 0),Su.set(this,void 0),this.tag=Mc.CertificateRequestTag}onInit(e){}getAttribute(e){for(const 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(const 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=yc.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(t,["verify"],e),i=Aa.resolveAll(iu).reverse();let n=null;for(const e of i)if(n=e.toWebSignature(t,this.signature),n)break;if(!n)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,r,n,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=pr.parse(this.rawData,yu),r=t.certificationRequestInfo,i=new sc("",{Version:`${xn[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const e=new sc("");for(const t of this.attributes){const r=t.toTextObject();e[r[sc.NAME]]=r}i.Attributes=e}return e.Data=i,e.Signature=new sc("",{Algorithm:cc.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}du=new WeakMap,gu=new WeakMap,vu=new WeakMap,mu=new WeakMap,wu=new WeakMap,bu=new WeakMap,Au=new WeakMap,Su=new WeakMap,Gu.NAME="PKCS#10 Certificate Request";class Ju extends $c{get publicKey(){return Br(this,Pu,"f")||kr(this,Pu,new Kc(this.asn.tbsCertificate.subjectPublicKeyInfo),"f"),Br(this,Pu,"f")}get serialNumber(){if(!Br(this,Bu,"f")){const e=this.asn.tbsCertificate;let t=new Uint8Array(e.serialNumber);t.length>1&&0===t[0]&&t[1]>127&&(t=t.slice(1)),kr(this,Bu,h.ToHex(t),"f")}return Br(this,Bu,"f")}get subjectName(){return Br(this,ku,"f")||kr(this,ku,new wc(this.asn.tbsCertificate.subject),"f"),Br(this,ku,"f")}get subject(){return Br(this,Cu,"f")||kr(this,Cu,this.subjectName.toString(),"f"),Br(this,Cu,"f")}get issuerName(){return Br(this,Eu,"f")||kr(this,Eu,new wc(this.asn.tbsCertificate.issuer),"f"),Br(this,Eu,"f")}get issuer(){return Br(this,Ou,"f")||kr(this,Ou,this.issuerName.toString(),"f"),Br(this,Ou,"f")}get notBefore(){if(!Br(this,Nu,"f")){const e=this.asn.tbsCertificate.validity.notBefore.utcTime||this.asn.tbsCertificate.validity.notBefore.generalTime;if(!e)throw new Error("Cannot get 'notBefore' value");kr(this,Nu,e,"f")}return Br(this,Nu,"f")}get notAfter(){if(!Br(this,Iu,"f")){const e=this.asn.tbsCertificate.validity.notAfter.utcTime||this.asn.tbsCertificate.validity.notAfter.generalTime;if(!e)throw new Error("Cannot get 'notAfter' value");kr(this,Iu,e,"f")}return Br(this,Iu,"f")}get signatureAlgorithm(){if(!Br(this,Tu,"f")){const e=Aa.resolve(ka);kr(this,Tu,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,Tu,"f")}get signature(){return Br(this,ju,"f")||kr(this,ju,this.asn.signatureValue,"f"),Br(this,ju,"f")}get extensions(){return Br(this,Uu,"f")||(kr(this,Uu,[],"f"),this.asn.tbsCertificate.extensions&&kr(this,Uu,this.asn.tbsCertificate.extensions.map(e=>Jc.create(pr.serialize(e))),"f")),Br(this,Uu,"f")}get tbs(){return Br(this,xu,"f")||kr(this,xu,this.asn.tbsCertificateRaw||pr.serialize(this.asn.tbsCertificate),"f"),Br(this,xu,"f")}constructor(e){const t=$c.isAsnEncoded(e)?[e,kn]:[e];super(t[0],t[1]),xu.set(this,void 0),Bu.set(this,void 0),ku.set(this,void 0),Cu.set(this,void 0),Eu.set(this,void 0),Ou.set(this,void 0),Nu.set(this,void 0),Iu.set(this,void 0),Tu.set(this,void 0),ju.set(this,void 0),Uu.set(this,void 0),Pu.set(this,void 0),this.tag=Mc.CertificateTag}onInit(e){}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>"string"==typeof e?t.type===e:t instanceof e)}async verify(e={},t=yc.get()){let r,i;const s=e.publicKey;try{if(s)if("publicKey"in s)r={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(r,["verify"],t);else if(s instanceof Kc)r={...s.algorithm,...this.signatureAlgorithm},i=await s.export(r,["verify"],t);else if(n.isBufferSource(s)){const e=new Kc(s);r={...e.algorithm,...this.signatureAlgorithm},i=await e.export(r,["verify"],t)}else r={...s.algorithm,...this.signatureAlgorithm},i=s;else r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],t)}catch(e){return!1}const o=Aa.resolveAll(iu).reverse();let a=null;for(const e of o)if(a=e.toWebSignature(r,this.signature),a)break;if(!a)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const c=await t.subtle.verify(this.signatureAlgorithm,i,a,this.tbs);if(e.signatureOnly)return c;{const t=(e.date||new Date).getTime();return c&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,r="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(r=e[0]||r,t=e[1])),null!=t||(t=yc.get()),await t.subtle.digest(r,this.rawData)}async isSelfSigned(e=yc.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=pr.parse(this.rawData,kn),r=t.tbsCertificate,i=new sc("",{Version:`${xn[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":cc.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new sc("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const e=new sc("");for(const t of this.extensions){const r=t.toTextObject();e[r[sc.NAME]]=r}i.Extensions=e}return e.Data=i,e.Signature=new sc("",{Algorithm:cc.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}xu=new WeakMap,Bu=new WeakMap,ku=new WeakMap,Cu=new WeakMap,Eu=new WeakMap,Ou=new WeakMap,Nu=new WeakMap,Iu=new WeakMap,Tu=new WeakMap,ju=new WeakMap,Uu=new WeakMap,Pu=new WeakMap,Ju.NAME="Certificate";class Xu extends Array{constructor(e){if(super(),$c.isAsnEncoded(e))this.import(e);else if(e instanceof Ju)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new ro;t.version=1,t.encapContentInfo.eContentType="1.2.840.113549.1.7.1",t.encapContentInfo.eContent=new xs({single:new Nt}),t.certificates=new As(this.map(e=>new bs({certificate:pr.parse(e.rawData,kn)})));const r=new Ss({contentType:Qs,content:pr.serialize(t)}),i=pr.serialize(r);return"raw"===e?i:this.toString(e)}import(e){const t=$c.toArrayBuffer(e),r=pr.parse(t,Ss);if(r.contentType!==Qs)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=pr.parse(r.content,ro);this.clear();for(const e of i.certificates||[])e.certificate&&this.push(new Ju(e.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return Mc.encode(t,"CMS");case"pem-chain":return this.map(e=>e.toString("pem")).join("\n");case"asn":return pr.toString(t);case"hex":return h.ToHex(t);case"base64":return h.ToBase64(t);case"base64url":return h.ToBase64Url(t);case"text":return cc.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=pr.parse(this.export("raw"),Ss),t=pr.parse(e.content,ro);return new sc("X509Certificates",{"Content Type":ac.toString(e.contentType),Content:new sc("",{Version:`${Tn[t.version]} (${t.version})`,Certificates:new sc("",{Certificate:this.map(e=>e.toTextObject())})})})}}function Zu(e,t=yc.get()){const r=n.toUint8Array(h.FromHex(e||""));let i=r&&r.length&&r.some(e=>e>0)?new Uint8Array(r):void 0;i||(i=t.getRandomValues(new Uint8Array(16)));let s=0;for(;s<i.length-1&&0===i[s];)s++;if(i=i.slice(s),i[0]>127){const e=new Uint8Array(i.length+1);e[0]=0,e.set(i,1),i=e}return i.buffer}e.X509CrlReason=void 0,(Mu=e.X509CrlReason||(e.X509CrlReason={}))[Mu.unspecified=0]="unspecified",Mu[Mu.keyCompromise=1]="keyCompromise",Mu[Mu.cACompromise=2]="cACompromise",Mu[Mu.affiliationChanged=3]="affiliationChanged",Mu[Mu.superseded=4]="superseded",Mu[Mu.cessationOfOperation=5]="cessationOfOperation",Mu[Mu.certificateHold=6]="certificateHold",Mu[Mu.removeFromCRL=8]="removeFromCRL",Mu[Mu.privilegeWithdrawn=9]="privilegeWithdrawn",Mu[Mu.aACompromise=10]="aACompromise";class Yu extends hc{get serialNumber(){return Br(this,Ru,"f")||kr(this,Ru,h.ToHex(this.asn.userCertificate),"f"),Br(this,Ru,"f")}get revocationDate(){return Br(this,Vu,"f")||kr(this,Vu,this.asn.revocationDate.getTime(),"f"),Br(this,Vu,"f")}get reason(){return void 0===Br(this,Du,"f")&&this.extensions,Br(this,Du,"f")}get invalidity(){return void 0===Br(this,Lu,"f")&&this.extensions,Br(this,Lu,"f")}get extensions(){return Br(this,Hu,"f")||(kr(this,Hu,[],"f"),this.asn.crlEntryExtensions&&kr(this,Hu,this.asn.crlEntryExtensions.map(e=>{const t=Jc.create(pr.serialize(e));switch(t.type){case Ci:void 0===Br(this,Du,"f")&&kr(this,Du,pr.parse(t.value,Oi).reason,"f");break;case Hi:void 0===Br(this,Lu,"f")&&kr(this,Lu,pr.parse(t.value,Mi).value,"f")}return t}),"f")),Br(this,Hu,"f")}constructor(...e){let t;if(n.isBufferSource(e[0])?t=n.toArrayBuffer(e[0]):"string"==typeof e[0]?t=pr.serialize(new Cn({userCertificate:Zu(e[0]),revocationDate:new mn(e[1]),crlEntryExtensions:e[2]})):e[0]instanceof Cn&&(t=e[0]),!t)throw new TypeError("Cannot create X509CrlEntry instance. Wrong constructor arguments.");super(t,Cn),Ru.set(this,void 0),Vu.set(this,void 0),Du.set(this,void 0),Lu.set(this,void 0),Hu.set(this,void 0)}onInit(e){}}Ru=new WeakMap,Vu=new WeakMap,Du=new WeakMap,Lu=new WeakMap,Hu=new WeakMap;class Qu extends $c{get version(){return this.asn.tbsCertList.version}get signatureAlgorithm(){if(!Br(this,Ku,"f")){const e=Aa.resolve(ka);kr(this,Ku,e.toWebAlgorithm(this.asn.signatureAlgorithm),"f")}return Br(this,Ku,"f")}get signature(){return this.asn.signature}get issuer(){return this.issuerName.toString()}get issuerName(){return Br(this,Fu,"f")||kr(this,Fu,new wc(this.asn.tbsCertList.issuer),"f"),Br(this,Fu,"f")}get thisUpdate(){if(!Br(this,_u,"f")){const e=this.asn.tbsCertList.thisUpdate.getTime();if(!e)throw new Error("Cannot get 'thisUpdate' value");kr(this,_u,e,"f")}return Br(this,_u,"f")}get nextUpdate(){var e;return void 0===Br(this,Wu,"f")&&kr(this,Wu,(null===(e=this.asn.tbsCertList.nextUpdate)||void 0===e?void 0:e.getTime())||void 0,"f"),Br(this,Wu,"f")}get entries(){var e;return Br(this,zu,"f")||kr(this,zu,(null===(e=this.asn.tbsCertList.revokedCertificates)||void 0===e?void 0:e.map(e=>new Yu(e)))||[],"f"),Br(this,zu,"f")}get extensions(){return Br(this,qu,"f")||(kr(this,qu,[],"f"),this.asn.tbsCertList.crlExtensions&&kr(this,qu,this.asn.tbsCertList.crlExtensions.map(e=>Jc.create(pr.serialize(e))),"f")),Br(this,qu,"f")}get tbs(){return Br(this,$u,"f")||kr(this,$u,this.asn.tbsCertListRaw||pr.serialize(this.asn.tbsCertList),"f"),Br(this,$u,"f")}get tbsCertListSignatureAlgorithm(){return this.asn.tbsCertList.signature}get certListSignatureAlgorithm(){return this.asn.signatureAlgorithm}constructor(e){super(e,$c.isAsnEncoded(e)?On:void 0),this.tag=Mc.CrlTag,$u.set(this,void 0),Ku.set(this,void 0),Fu.set(this,void 0),_u.set(this,void 0),Wu.set(this,void 0),zu.set(this,void 0),qu.set(this,void 0)}onInit(e){}getExtension(e){for(const t of this.extensions)if("string"==typeof e){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>"string"==typeof e?t.type===e:t instanceof e)}async verify(e,t=yc.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw new Error("algorithm identifier in the sequence tbsCertList and CertificateList mismatch");let r,i;const n=e.publicKey;try{n instanceof Ju?(r={...n.publicKey.algorithm,...n.signatureAlgorithm},i=await n.publicKey.export(r,["verify"])):n instanceof Kc?(r={...n.algorithm,...this.signatureAlgorithm},i=await n.export(r,["verify"])):(r={...n.algorithm,...this.signatureAlgorithm},i=n)}catch(e){return!1}const s=Aa.resolveAll(iu).reverse();let o=null;for(const e of s)if(o=e.toWebSignature(r,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return await t.subtle.verify(this.signatureAlgorithm,i,o,this.tbs)}async getThumbprint(...e){let t,r="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(r=e[0]||r,t=e[1])),null!=t||(t=yc.get()),await t.subtle.digest(r,this.rawData)}findRevoked(e){const t=Zu("string"==typeof e?e:e.serialNumber);for(const e of this.asn.tbsCertList.revokedCertificates||[])if(n.isEqual(e.userCertificate,t))return new Yu(pr.serialize(e));return null}}$u=new WeakMap,Ku=new WeakMap,Fu=new WeakMap,_u=new WeakMap,Wu=new WeakMap,zu=new WeakMap,qu=new WeakMap;return Jc.register(Yr,_c),Jc.register(Ii,Wc),Jc.register(_i,zc),Jc.register(cn,qc),Jc.register(Jr,Fc),Jc.register(rn,Gc),Jc.register(vi,Zc),Jc.register(zr,Yc),Jc.register(Ki,tl),ru.register(Ol,eu),ru.register(Nl,tu),Aa.registerSingleton(iu,nu),Aa.registerSingleton(iu,ou),ou.namedCurveSize.set("P-256",32),ou.namedCurveSize.set("K-256",32),ou.namedCurveSize.set("P-384",48),ou.namedCurveSize.set("P-521",66),e.AlgorithmProvider=Ba,e.AsnData=hc,e.AsnDefaultSignatureFormatter=nu,e.AsnEcSignatureFormatter=ou,e.Attribute=Ql,e.AttributeFactory=ru,e.AuthorityInfoAccessExtension=Yc,e.AuthorityKeyIdentifierExtension=Fc,e.BasicConstraintsExtension=_c,e.CRLDistributionPointsExtension=Zc,e.CertificatePolicyExtension=Xc,e.ChallengePasswordAttribute=eu,e.CryptoProvider=fc,e.DN=Ec,e.DNS=Cc,e.DefaultAlgorithmSerializer=oc,e.EMAIL=Oc,e.ExtendedKeyUsageExtension=Wc,e.Extension=pc,e.ExtensionFactory=Jc,e.ExtensionsAttribute=tu,e.GUID=Tc,e.GeneralName=Pc,e.GeneralNames=Rc,e.IP=Nc,e.IssuerAlternativeNameExtension=tl,e.KeyUsagesExtension=zc,e.Name=wc,e.NameIdentifier=gc,e.OidSerializer=ac,e.PemConverter=Mc,e.PemData=$c,e.Pkcs10CertificateRequest=Gu,e.Pkcs10CertificateRequestGenerator=class{static async create(e,t=yc.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");const r=await t.subtle.exportKey("spki",e.keys.publicKey),i=new yu({certificationRequestInfo:new fu({subjectPKInfo:pr.parse(r,vn)})});if(e.name){const t=e.name instanceof wc?e.name:new wc(e.name);i.certificationRequestInfo.subject=pr.parse(t.toArrayBuffer(),jr)}if(e.attributes)for(const t of e.attributes)i.certificationRequestInfo.attributes.push(pr.parse(t.rawData,sn));if(e.extensions&&e.extensions.length){const t=new sn({type:Nl}),r=new Sn;for(const t of e.extensions)r.push(pr.parse(t.rawData,An));t.values.push(pr.serialize(r)),i.certificationRequestInfo.attributes.push(t)}const n={...e.signingAlgorithm,...e.keys.privateKey.algorithm},s=Aa.resolve(ka);i.signatureAlgorithm=s.toAsnAlgorithm(n);const o=pr.serialize(i.certificationRequestInfo),a=await t.subtle.sign(n,e.keys.privateKey,o),c=Aa.resolveAll(iu).reverse();let l=null;for(const e of c)if(l=e.toAsnSignature(n,a),l)break;if(!l)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return i.signature=l,new Gu(pr.serialize(i))}},e.PublicKey=Kc,e.REGISTERED_ID=Uc,e.SubjectAlternativeNameExtension=Gc,e.SubjectKeyIdentifierExtension=qc,e.TextConverter=cc,e.TextObject=sc,e.UPN=jc,e.URL=Ic,e.X509Certificate=Ju,e.X509CertificateGenerator=class{static async createSelfSigned(e,t=yc.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=yc.get()){var r;let i;i=e.publicKey instanceof Kc?e.publicKey.rawData:"publicKey"in e.publicKey?e.publicKey.publicKey.rawData:n.isBufferSource(e.publicKey)?e.publicKey:await t.subtle.exportKey("spki",e.publicKey);const s=Zu(e.serialNumber,t),o=e.notBefore||new Date,a=e.notAfter||new Date(o.getTime()+31536e6),c=new kn({tbsCertificate:new Bn({version:xn.v3,serialNumber:s,validity:new wn({notBefore:o,notAfter:a}),extensions:new Sn((null===(r=e.extensions)||void 0===r?void 0:r.map(e=>pr.parse(e.rawData,An)))||[]),subjectPublicKeyInfo:pr.parse(i,vn)})});if(e.subject){const t=e.subject instanceof wc?e.subject:new wc(e.subject);c.tbsCertificate.subject=pr.parse(t.toArrayBuffer(),jr)}if(e.issuer){const t=e.issuer instanceof wc?e.issuer:new wc(e.issuer);c.tbsCertificate.issuer=pr.parse(t.toArrayBuffer(),jr)}const l={hash:"SHA-256"},u="signingKey"in e?{...l,...e.signingAlgorithm,...e.signingKey.algorithm}:{...l,...e.signingAlgorithm},h=Aa.resolve(ka);c.tbsCertificate.signature=c.signatureAlgorithm=h.toAsnAlgorithm(u);const p=pr.serialize(c.tbsCertificate),f="signingKey"in e?await t.subtle.sign(u,e.signingKey,p):e.signature,y=Aa.resolveAll(iu).reverse();let d=null;for(const e of y)if(d=e.toAsnSignature(u,f),d)break;if(!d)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return c.signatureValue=d,new Ju(pr.serialize(c))}},e.X509Certificates=Xu,e.X509ChainBuilder=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=yc.get()){const r=new Xu(e);let i=e;for(;i=await this.findIssuer(i,t);){const e=await i.getThumbprint(t);for(const i of r){if(p(e,await i.getThumbprint(t)))throw new Error("Cannot build a certificate chain. Circular dependency.")}r.push(i)}return r}async findIssuer(e,t=yc.get()){if(!await e.isSelfSigned(t)){const r=e.getExtension(Jr);for(const i of this.certificates)if(i.subject===e.issuer){if(r)if(r.keyId){const e=i.getExtension(cn);if(e&&e.keyId!==r.keyId)continue}else if(r.certId){const e=i.getExtension(rn);if(e&&(r.certId.serialNumber!==i.serialNumber||!p(pr.serialize(r.certId.name),pr.serialize(e))))continue}try{const r={...i.publicKey.algorithm,...e.signatureAlgorithm},n=await i.publicKey.export(r,["verify"],t);if(!await e.verify({publicKey:n,signatureOnly:!0},t))continue}catch(e){continue}return i}}return null}},e.X509Crl=Qu,e.X509CrlEntry=Yu,e.X509CrlGenerator=class{static async create(e,t=yc.get()){var r;const i=e.issuer instanceof wc?e.issuer:new wc(e.issuer),n=new On({tbsCertList:new En({version:xn.v2,issuer:pr.parse(i.toArrayBuffer(),jr),thisUpdate:new mn(e.thisUpdate||new Date)})});if(e.nextUpdate&&(n.tbsCertList.nextUpdate=new mn(e.nextUpdate)),e.extensions&&e.extensions.length&&(n.tbsCertList.crlExtensions=new Sn(e.extensions.map(e=>pr.parse(e.rawData,An))||[])),e.entries&&e.entries.length){n.tbsCertList.revokedCertificates=[];for(const t of e.entries){const i=$c.toArrayBuffer(t.serialNumber);if(n.tbsCertList.revokedCertificates.findIndex(e=>p(e.userCertificate,i))>-1)throw new Error(`Certificate serial number ${t.serialNumber} already exists in tbsCertList`);const s=new Cn({userCertificate:i,revocationDate:new mn(t.revocationDate||new Date)});if("extensions"in t&&(null===(r=t.extensions)||void 0===r?void 0:r.length)?s.crlEntryExtensions=t.extensions.map(e=>pr.parse(e.rawData,An)):s.crlEntryExtensions=[],!(t instanceof Yu)&&(t.reason&&s.crlEntryExtensions.push(new An({extnID:Ci,critical:!1,extnValue:new Nt(pr.serialize(new Oi(t.reason)))})),t.invalidity&&s.crlEntryExtensions.push(new An({extnID:Hi,critical:!1,extnValue:new Nt(pr.serialize(new Mi(t.invalidity)))})),t.issuer)){const t=e.issuer instanceof wc?e.issuer:new wc(e.issuer);s.crlEntryExtensions.push(new An({extnID:ii,critical:!1,extnValue:new Nt(pr.serialize(pr.parse(t.toArrayBuffer(),jr)))}))}n.tbsCertList.revokedCertificates.push(s)}}const s={...e.signingAlgorithm,...e.signingKey.algorithm},o=Aa.resolve(ka);n.tbsCertList.signature=n.signatureAlgorithm=o.toAsnAlgorithm(s);const a=pr.serialize(n.tbsCertList),c=await t.subtle.sign(s,e.signingKey,a),l=Aa.resolveAll(iu).reverse();let u=null;for(const e of l)if(u=e.toAsnSignature(s,c),u)break;if(!u)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");return n.signature=u,new Qu(pr.serialize(n))}},e.cryptoProvider=yc,e.diAlgorithm=xa,e.diAlgorithmProvider=ka,e.diAsnSignatureFormatter=iu,e.idEd25519=lu,e.idEd448=uu,e.idX25519=au,e.idX448=cu,e}({});
