UNPKG

@taqueria/state

Version:

A TypeScript library for NodeJS and Deno to work with Taqueria projects

5 lines • 255 kB
"use strict";var Nf=Object.create;var ls=Object.defineProperty;var Kf=Object.getOwnPropertyDescriptor;var Of=Object.getOwnPropertyNames;var If=Object.getPrototypeOf,Uf=Object.prototype.hasOwnProperty;var Q=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),$f=(n,e)=>{for(var t in e)ls(n,t,{get:e[t],enumerable:!0})},Xi=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Of(e))!Uf.call(n,s)&&s!==t&&ls(n,s,{get:()=>e[s],enumerable:!(r=Kf(e,s))||r.enumerable});return n};var Gr=(n,e,t)=>(t=n!=null?Nf(If(n)):{},Xi(e||!n||!n.__esModule?ls(t,"default",{value:n,enumerable:!0}):t,n)),jf=n=>Xi(ls({},"__esModule",{value:!0}),n);var hs=Q((Vm,fs)=>{(function(n){"use strict";typeof fs=="object"&&typeof fs.exports=="object"?fs.exports=n():typeof define=="function"&&define.amd!=null?define([],n):self.sanctuaryTypeIdentifiers=n()})(function(){"use strict";var n="@@type",e=new RegExp("^([\\s\\S]+)/([\\s\\S]+?)(?:@([0-9]+))?$");function t(r){return r!=null&&r.constructor!=null&&r.constructor.prototype!==r&&typeof r[n]=="string"?r[n]:Object.prototype.toString.call(r).slice(8,-1)}return t.parse=function(s){var o=null,a=s,i=0,c=e.exec(s);return c!=null&&(o=c[1],a=c[2],c[3]!=null&&(i=Number(c[3]))),{namespace:o,name:a,version:i}},t})});var nc=Q((zm,ds)=>{(function(n){"use strict";typeof ds=="object"&&typeof ds.exports=="object"?ds.exports=n():typeof define=="function"&&define.amd!=null?define([],n):self.sanctuaryShow=n()})(function(){"use strict";var n="@@show",e=[];function t(o){return function(a){return s(a)+": "+s(o[a])}}function r(o){return Object.keys(o).sort()}function s(o){if(e.indexOf(o)>=0)return"<Circular>";switch(Object.prototype.toString.call(o)){case"[object Boolean]":return typeof o=="object"?"new Boolean ("+s(o.valueOf())+")":o.toString();case"[object Number]":return typeof o=="object"?"new Number ("+s(o.valueOf())+")":1/o===-1/0?"-0":o.toString(10);case"[object String]":return typeof o=="object"?"new String ("+s(o.valueOf())+")":JSON.stringify(o);case"[object Date]":return"new Date ("+s(isNaN(o.valueOf())?NaN:o.toISOString())+")";case"[object Error]":return"new "+o.name+" ("+s(o.message)+")";case"[object Arguments]":return"function () { return arguments; } ("+Array.prototype.map.call(o,s).join(", ")+")";case"[object Array]":e.push(o);try{return"["+o.map(s).concat(r(o).filter(function(a){return!/^\d+$/.test(a)}).map(t(o))).join(", ")+"]"}finally{e.pop()}case"[object Object]":e.push(o);try{return n in o&&(o.constructor==null||o.constructor.prototype!==o)?o[n]():"{"+r(o).map(t(o)).join(", ")+"}"}finally{e.pop()}case"[object Set]":e.push(o);try{return"new Set ("+s(Array.from(o.values()))+")"}finally{e.pop()}case"[object Map]":e.push(o);try{return"new Map ("+s(Array.from(o.entries()))+")"}finally{e.pop()}default:return String(o)}}return s})});var tr=Q(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});var lp="[object ArrayBuffer]",Fe=class{static isArrayBuffer(e){return Object.prototype.toString.call(e)===lp}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e).slice().buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let r=Fe.toUint8Array(e),s=Fe.toUint8Array(t);if(r.length!==s.byteLength)return!1;for(let o=0;o<r.length;o++)if(r[o]!==s[o])return!1;return!0}static concat(...e){if(Array.isArray(e[0])){let t=e[0],r=0;for(let a of t)r+=a.byteLength;let s=new Uint8Array(r),o=0;for(let a of t){let i=this.toUint8Array(a);s.set(i,o),o+=i.length}return e[1]?this.toView(s,e[1]):s.buffer}else return this.concat(e)}},Cs=class{static fromString(e){let t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r.buffer}static toString(e){let t=Fe.toUint8Array(e),r="";for(let o=0;o<t.length;o++)r+=String.fromCharCode(t[o]);return decodeURIComponent(escape(r))}},De=class{static toString(e,t=!1){let r=Fe.toArrayBuffer(e),s=new DataView(r),o="";for(let a=0;a<r.byteLength;a+=2){let i=s.getUint16(a,t);o+=String.fromCharCode(i)}return o}static fromString(e,t=!1){let r=new ArrayBuffer(e.length*2),s=new DataView(r);for(let o=0;o<e.length;o++)s.setUint16(o*2,e.charCodeAt(o),t);return r}},lt=class{static isHex(e){return typeof e=="string"&&/^[a-z0-9]+$/i.test(e)}static isBase64(e){return typeof e=="string"&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}static isBase64Url(e){return typeof e=="string"&&/^[a-zA-Z0-9-_]+$/i.test(e)}static ToString(e,t="utf8"){let r=Fe.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 De.toString(r,!0);case"utf16":case"utf16be":return De.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 De.fromString(e,!0);case"utf16":case"utf16be":return De.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Fe.toUint8Array(e);if(typeof btoa<"u"){let r=this.ToString(t,"binary");return btoa(r)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!lt.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!lt.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=lt.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Cs.fromString(e);case"utf16":case"utf16be":return De.fromString(e);case"utf16le":case"usc2":return De.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=lt.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Cs.toString(e);case"utf16":case"utf16be":return De.toString(e);case"utf16le":case"usc2":return De.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.charCodeAt(s);return r.buffer}static ToBinary(e){let t=Fe.toUint8Array(e),r="";for(let s=0;s<t.length;s++)r+=String.fromCharCode(t[s]);return r}static ToHex(e){let t=Fe.toUint8Array(e),r="",s=[],o=t.length;for(let a=0;a<o;a++){let i=t[a].toString(16).padStart(2,"0");s.push(i)}return s.join(r)}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!lt.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let r=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let o=t.slice(s,s+2);r[s/2]=parseInt(o,16)}return r.buffer}static ToUtf16String(e,t=!1){return De.toString(e,t)}static FromUtf16String(e,t=!1){return De.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};lt.DEFAULT_UTF8_ENCODING="utf8";function fp(n,...e){let t=arguments[0];for(let r=1;r<arguments.length;r++){let s=arguments[r];for(let o in s)t[o]=s[o]}return t}function hp(...n){let e=n.map(s=>s.byteLength).reduce((s,o)=>s+o),t=new Uint8Array(e),r=0;return n.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)t[r++]=o}),t.buffer}function pp(n,e){if(!(n&&e)||n.byteLength!==e.byteLength)return!1;let t=new Uint8Array(n),r=new Uint8Array(e);for(let s=0;s<n.byteLength;s++)if(t[s]!==r[s])return!1;return!0}er.BufferSourceConverter=Fe;er.Convert=lt;er.assign=fp;er.combine=hp;er.isEqual=pp});var Ir=Q((Sb,Ts)=>{var Lc,Dc,Fc,zc,qc,Jc,Gc,Wc,Zc,_s,sa,Yc,Xc,Qc,Or,eu,tu,ru,nu,su,ou,au,iu,cu,Es;(function(n){var e=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(r){n(t(e,t(r)))}):typeof Ts=="object"&&typeof Ts.exports=="object"?n(t(e,t(Ts.exports))):n(t(e));function t(r,s){return r!==e&&(typeof Object.create=="function"?Object.defineProperty(r,"__esModule",{value:!0}):r.__esModule=!0),function(o,a){return r[o]=s?s(o,a):a}}})(function(n){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])};Lc=function(r,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");e(r,s);function o(){this.constructor=r}r.prototype=s===null?Object.create(s):(o.prototype=s.prototype,new o)},Dc=Object.assign||function(r){for(var s,o=1,a=arguments.length;o<a;o++){s=arguments[o];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(r[i]=s[i])}return r},Fc=function(r,s){var o={};for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&s.indexOf(a)<0&&(o[a]=r[a]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,a=Object.getOwnPropertySymbols(r);i<a.length;i++)s.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(r,a[i])&&(o[a[i]]=r[a[i]]);return o},zc=function(r,s,o,a){var i=arguments.length,c=i<3?s:a===null?a=Object.getOwnPropertyDescriptor(s,o):a,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(r,s,o,a);else for(var l=r.length-1;l>=0;l--)(u=r[l])&&(c=(i<3?u(c):i>3?u(s,o,c):u(s,o))||c);return i>3&&c&&Object.defineProperty(s,o,c),c},qc=function(r,s){return function(o,a){s(o,a,r)}},Jc=function(r,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,s)},Gc=function(r,s,o,a){function i(c){return c instanceof o?c:new o(function(u){u(c)})}return new(o||(o=Promise))(function(c,u){function l(m){try{d(a.next(m))}catch(S){u(S)}}function f(m){try{d(a.throw(m))}catch(S){u(S)}}function d(m){m.done?c(m.value):i(m.value).then(l,f)}d((a=a.apply(r,s||[])).next())})},Wc=function(r,s){var o={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},a,i,c,u;return u={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function l(d){return function(m){return f([d,m])}}function f(d){if(a)throw new TypeError("Generator is already executing.");for(;u&&(u=0,d[0]&&(o=0)),o;)try{if(a=1,i&&(c=d[0]&2?i.return:d[0]?i.throw||((c=i.return)&&c.call(i),0):i.next)&&!(c=c.call(i,d[1])).done)return c;switch(i=0,c&&(d=[d[0]&2,c.value]),d[0]){case 0:case 1:c=d;break;case 4:return o.label++,{value:d[1],done:!1};case 5:o.label++,i=d[1],d=[0];continue;case 7:d=o.ops.pop(),o.trys.pop();continue;default:if(c=o.trys,!(c=c.length>0&&c[c.length-1])&&(d[0]===6||d[0]===2)){o=0;continue}if(d[0]===3&&(!c||d[1]>c[0]&&d[1]<c[3])){o.label=d[1];break}if(d[0]===6&&o.label<c[1]){o.label=c[1],c=d;break}if(c&&o.label<c[2]){o.label=c[2],o.ops.push(d);break}c[2]&&o.ops.pop(),o.trys.pop();continue}d=s.call(r,o)}catch(m){d=[6,m],i=0}finally{a=c=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}},Zc=function(r,s){for(var o in r)o!=="default"&&!Object.prototype.hasOwnProperty.call(s,o)&&Es(s,r,o)},Es=Object.create?function(r,s,o,a){a===void 0&&(a=o);var i=Object.getOwnPropertyDescriptor(s,o);(!i||("get"in i?!s.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return s[o]}}),Object.defineProperty(r,a,i)}:function(r,s,o,a){a===void 0&&(a=o),r[a]=s[o]},_s=function(r){var s=typeof Symbol=="function"&&Symbol.iterator,o=s&&r[s],a=0;if(o)return o.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&a>=r.length&&(r=void 0),{value:r&&r[a++],done:!r}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},sa=function(r,s){var o=typeof Symbol=="function"&&r[Symbol.iterator];if(!o)return r;var a=o.call(r),i,c=[],u;try{for(;(s===void 0||s-- >0)&&!(i=a.next()).done;)c.push(i.value)}catch(l){u={error:l}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(u)throw u.error}}return c},Yc=function(){for(var r=[],s=0;s<arguments.length;s++)r=r.concat(sa(arguments[s]));return r},Xc=function(){for(var r=0,s=0,o=arguments.length;s<o;s++)r+=arguments[s].length;for(var a=Array(r),i=0,s=0;s<o;s++)for(var c=arguments[s],u=0,l=c.length;u<l;u++,i++)a[i]=c[u];return a},Qc=function(r,s,o){if(o||arguments.length===2)for(var a=0,i=s.length,c;a<i;a++)(c||!(a in s))&&(c||(c=Array.prototype.slice.call(s,0,a)),c[a]=s[a]);return r.concat(c||Array.prototype.slice.call(s))},Or=function(r){return this instanceof Or?(this.v=r,this):new Or(r)},eu=function(r,s,o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=o.apply(r,s||[]),i,c=[];return i={},u("next"),u("throw"),u("return"),i[Symbol.asyncIterator]=function(){return this},i;function u(B){a[B]&&(i[B]=function(I){return new Promise(function(L,gt){c.push([B,I,L,gt])>1||l(B,I)})})}function l(B,I){try{f(a[B](I))}catch(L){S(c[0][3],L)}}function f(B){B.value instanceof Or?Promise.resolve(B.value.v).then(d,m):S(c[0][2],B)}function d(B){l("next",B)}function m(B){l("throw",B)}function S(B,I){B(I),c.shift(),c.length&&l(c[0][0],c[0][1])}},tu=function(r){var s,o;return s={},a("next"),a("throw",function(i){throw i}),a("return"),s[Symbol.iterator]=function(){return this},s;function a(i,c){s[i]=r[i]?function(u){return(o=!o)?{value:Or(r[i](u)),done:i==="return"}:c?c(u):u}:c}},ru=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r[Symbol.asyncIterator],o;return s?s.call(r):(r=typeof _s=="function"?_s(r):r[Symbol.iterator](),o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o);function a(c){o[c]=r[c]&&function(u){return new Promise(function(l,f){u=r[c](u),i(l,f,u.done,u.value)})}}function i(c,u,l,f){Promise.resolve(f).then(function(d){c({value:d,done:l})},u)}},nu=function(r,s){return Object.defineProperty?Object.defineProperty(r,"raw",{value:s}):r.raw=s,r};var t=Object.create?function(r,s){Object.defineProperty(r,"default",{enumerable:!0,value:s})}:function(r,s){r.default=s};su=function(r){if(r&&r.__esModule)return r;var s={};if(r!=null)for(var o in r)o!=="default"&&Object.prototype.hasOwnProperty.call(r,o)&&Es(s,r,o);return t(s,r),s},ou=function(r){return r&&r.__esModule?r:{default:r}},au=function(r,s,o,a){if(o==="a"&&!a)throw new TypeError("Private accessor was defined without a getter");if(typeof s=="function"?r!==s||!a:!s.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return o==="m"?a:o==="a"?a.call(r):a?a.value:s.get(r)},iu=function(r,s,o,a,i){if(a==="m")throw new TypeError("Private method is not writable");if(a==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof s=="function"?r!==s||!i:!s.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return a==="a"?i.call(r,o):i?i.value=o:s.set(r,o),o},cu=function(r,s){if(s===null||typeof s!="object"&&typeof s!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof r=="function"?s===r:r.has(s)},n("__extends",Lc),n("__assign",Dc),n("__rest",Fc),n("__decorate",zc),n("__param",qc),n("__metadata",Jc),n("__awaiter",Gc),n("__generator",Wc),n("__exportStar",Zc),n("__createBinding",Es),n("__values",_s),n("__read",sa),n("__spread",Yc),n("__spreadArrays",Xc),n("__spreadArray",Qc),n("__await",Or),n("__asyncGenerator",eu),n("__asyncDelegator",tu),n("__asyncValues",ru),n("__makeTemplateObject",nu),n("__importStar",su),n("__importDefault",ou),n("__classPrivateFieldGet",au),n("__classPrivateFieldSet",iu),n("__classPrivateFieldIn",cu)})});var fu=Q(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});function dp(n){return new Date(n.getTime()+n.getTimezoneOffset()*6e4)}function mp(n,e,t){var r;return n instanceof Object&&(r=n[e])!==null&&r!==void 0?r:t}function yp(n,e=0,t=n.byteLength-e,r=!1){let s="";for(let o of new Uint8Array(n,e,t)){let a=o.toString(16).toUpperCase();a.length===1&&(s+="0"),s+=a,r&&(s+=" ")}return s.trim()}function gp(n,e,t,r){return e instanceof ArrayBuffer?e.byteLength?t<0?(n.error="Wrong parameter: inputOffset less than zero",!1):r<0?(n.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-r<0?(n.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(n.error="Wrong parameter: inputBuffer has zero length",!1):(n.error='Wrong parameter: inputBuffer must be "ArrayBuffer"',!1)}function oa(n,e){let t=0;if(n.length===1)return n[0];for(let r=n.length-1;r>=0;r--)t+=n[n.length-1-r]*Math.pow(2,e*r);return t}function aa(n,e,t=-1){let r=t,s=n,o=0,a=Math.pow(2,e);for(let i=1;i<8;i++){if(n<a){let c;if(r<0)c=new ArrayBuffer(i),o=i;else{if(r<i)return new ArrayBuffer(0);c=new ArrayBuffer(r),o=r}let u=new Uint8Array(c);for(let l=i-1;l>=0;l--){let f=Math.pow(2,l*e);u[o-l-1]=Math.floor(s/f),s-=u[o-l-1]*f}return c}a*=Math.pow(2,e)}return new ArrayBuffer(0)}function vp(...n){let e=0,t=0;for(let o of n)e+=o.byteLength;let r=new ArrayBuffer(e),s=new Uint8Array(r);for(let o of n)s.set(new Uint8Array(o),t),t+=o.byteLength;return r}function wp(...n){let e=0,t=0;for(let o of n)e+=o.length;let r=new ArrayBuffer(e),s=new Uint8Array(r);for(let o of n)s.set(o,t),t+=o.length;return s}function bp(){let n=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let i=n[0]===255&&n[1]&128,c=n[0]===0&&(n[1]&128)===0;(i||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let i=0;i<this.valueHex.byteLength;i++)t[i]=0;t[0]=n[0]&128;let r=oa(t,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let i=0;i<this.valueHex.byteLength;i++)o[i]=n[i];return o[0]&=127,oa(o,8)-r}function Ap(n){let e=n<0?n*-1:n,t=128;for(let r=1;r<8;r++){if(e<=t){if(n<0){let a=t-e,i=aa(a,8,r),c=new Uint8Array(i);return c[0]|=128,i}let s=aa(e,8,r),o=new Uint8Array(s);if(o[0]&128){let a=s.slice(0),i=new Uint8Array(a);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<a.byteLength;c++)o[c+1]=i[c];o[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Sp(n,e){if(n.byteLength!==e.byteLength)return!1;let t=new Uint8Array(n),r=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==r[s])return!1;return!0}function xp(n,e){let t=n.toString(10);if(e<t.length)return"";let r=e-t.length,s=new Array(r);for(let a=0;a<r;a++)s[a]="0";return s.join("").concat(t)}var uu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",lu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=";function kp(n,e=!1,t=!1,r=!1){let s=0,o=0,a=0,i="",c=e?lu:uu;if(r){let u=0;for(let l=0;l<n.length;l++)if(n.charCodeAt(l)!==0){u=l;break}n=n.slice(u)}for(;s<n.length;){let u=n.charCodeAt(s++);s>=n.length&&(o=1);let l=n.charCodeAt(s++);s>=n.length&&(a=1);let f=n.charCodeAt(s++),d=u>>2,m=(u&3)<<4|l>>4,S=(l&15)<<2|f>>6,B=f&63;o===1?S=B=64:a===1&&(B=64),t?S===64?i+=`${c.charAt(d)}${c.charAt(m)}`:B===64?i+=`${c.charAt(d)}${c.charAt(m)}${c.charAt(S)}`:i+=`${c.charAt(d)}${c.charAt(m)}${c.charAt(S)}${c.charAt(B)}`:i+=`${c.charAt(d)}${c.charAt(m)}${c.charAt(S)}${c.charAt(B)}`}return i}function Bp(n,e=!1,t=!1){let r=e?lu:uu;function s(c){for(let u=0;u<64;u++)if(r.charAt(u)===c)return u;return 64}function o(c){return c===64?0:c}let a=0,i="";for(;a<n.length;){let c=s(n.charAt(a++)),u=a>=n.length?0:s(n.charAt(a++)),l=a>=n.length?0:s(n.charAt(a++)),f=a>=n.length?0:s(n.charAt(a++)),d=o(c)<<2|o(u)>>4,m=(o(u)&15)<<4|o(l)>>2,S=(o(l)&3)<<6|o(f);i+=String.fromCharCode(d),l!==64&&(i+=String.fromCharCode(m)),f!==64&&(i+=String.fromCharCode(S))}if(t){let c=i.length,u=-1;for(let l=c-1;l>=0;l--)if(i.charCodeAt(l)!==0){u=l;break}u!==-1?i=i.slice(0,u+1):i=""}return i}function Cp(n){let e="",t=new Uint8Array(n);for(let r of t)e+=String.fromCharCode(r);return e}function _p(n){let e=n.length,t=new ArrayBuffer(e),r=new Uint8Array(t);for(let s=0;s<e;s++)r[s]=n.charCodeAt(s);return t}var Ep=Math.log(2);function Tp(n){let e=Math.log(n)/Ep,t=Math.floor(e),r=Math.round(e);return t===r?t:r}function Pp(n,e){for(let t of e)delete n[t]}ce.arrayBufferToString=Cp;ce.bufferToHexCodes=yp;ce.checkBufferParams=gp;ce.clearProps=Pp;ce.fromBase64=Bp;ce.getParametersValue=mp;ce.getUTCDate=dp;ce.isEqualBuffer=Sp;ce.nearestPowerOf2=Tp;ce.padNumber=xp;ce.stringToArrayBuffer=_p;ce.toBase64=kp;ce.utilConcatBuf=vp;ce.utilConcatView=wp;ce.utilDecodeTC=bp;ce.utilEncodeTC=Ap;ce.utilFromBase=oa;ce.utilToBase=aa});var _t=Q(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});var Np=tr(),Kp=fu();function mu(n){if(n&&n.__esModule)return n;var e=Object.create(null);return n&&Object.keys(n).forEach(function(t){if(t!=="default"){var r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:function(){return n[t]}})}}),e.default=n,Object.freeze(e)}var R=mu(Np),J=mu(Kp);function Ps(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ua(n){let e=0,t=0;for(let s=0;s<n.length;s++)e+=n[s].byteLength;let r=new Uint8Array(e);for(let s=0;s<n.length;s++){let o=n[s];r.set(new Uint8Array(o),t),t+=o.byteLength}return r.buffer}function Ct(n,e,t,r){return e instanceof Uint8Array?e.byteLength?t<0?(n.error="Wrong parameter: inputOffset less than zero",!1):r<0?(n.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-r<0?(n.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(n.error="Wrong parameter: inputBuffer has zero length",!1):(n.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var $r=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return ua(this.items)}},cn=[new Uint8Array([1])],hu="0123456789",ia="name",pu="valueHexView",Op="isHexOnly",Ip="idBlock",Up="tagClass",$p="tagNumber",jp="isConstructed",Rp="fromBER",Vp="toBER",Hp="local",Te="",Qe=new ArrayBuffer(0),qs=new Uint8Array(0),un="EndOfContent",yu="OCTET STRING",gu="BIT STRING";function dt(n){var e;return e=class extends n{constructor(...r){var s;super(...r);let o=r[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?R.BufferSourceConverter.toUint8Array(o.valueHex):qs}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(r){this.valueHexView=new Uint8Array(r)}fromBER(r,s,o){let a=r instanceof ArrayBuffer?new Uint8Array(r):r;if(!Ct(this,a,s,o))return-1;let i=s+o;return this.valueHexView=a.subarray(s,i),this.valueHexView.length?(this.blockLength=o,i):(this.warnings.push("Zero buffer length"),s)}toBER(r=!1){return this.isHexOnly?r?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",Qe)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:R.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var kt=class{constructor({blockLength:e=0,error:t=Te,warnings:r=[],valueBeforeDecode:s=qs}={}){this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=R.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:R.Convert.ToHex(this.valueBeforeDecodeView)}}};kt.NAME="baseBlock";var ge=class extends kt{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'")}};ge.NAME="valueBlock";var Ns=class extends dt(kt){constructor({idBlock:e={}}={}){var t,r,s,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?R.BufferSourceConverter.toUint8Array(e.valueHex):qs,this.tagClass=(r=e.tagClass)!==null&&r!==void 0?r:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Qe}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=J.utilToBase(this.tagNumber,7),o=new Uint8Array(s),a=s.byteLength,i=new Uint8Array(a+1);if(i[0]=t|31,!e){for(let c=0;c<a-1;c++)i[c+1]=o[c]|128;i[a]=o[a-1]}return i.buffer}let r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=t|31,!e){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)r[o+1]=s[o]|128;r[this.valueHexView.byteLength]=s[s.length-1]}return r.buffer}fromBER(e,t,r){let s=R.BufferSourceConverter.toUint8Array(e);if(!Ct(this,s,t,r))return-1;let o=s.subarray(t,t+r);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let i=o[0]&31;if(i!==31)this.tagNumber=i,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),l=255;for(;o[c]&128;){if(u[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===l){l+=255;let d=new Uint8Array(l);for(let m=0;m<u.length;m++)d[m]=u[m];u=this.valueHexView=new Uint8Array(l)}}this.blockLength=c+1,u[c-1]=o[c]&127;let f=new Uint8Array(c);for(let d=0;d<c;d++)f[d]=u[d];u=this.valueHexView=new Uint8Array(c),u.set(f),this.blockLength<=9?this.tagNumber=J.utilFromBase(u,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Ns.NAME="identificationBlock";var Ks=class extends kt{constructor({lenBlock:e={}}={}){var t,r,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(r=e.longFormUsed)!==null&&r!==void 0?r:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,r){let s=R.BufferSourceConverter.toUint8Array(e);if(!Ct(this,s,t,r))return-1;let o=s.subarray(t,t+r);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let a=o[0]&127;if(a>8)return this.error="Too big integer",-1;if(a+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let i=t+1,c=s.subarray(i,i+a);return c[a-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=J.utilFromBase(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){let s=J.utilToBase(this.length,8);if(s.byteLength>127)return this.error="Too big length",Qe;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let o=new Uint8Array(s);r=new Uint8Array(t),r[0]=s.byteLength|128;for(let a=0;a<s.byteLength;a++)r[a+1]=o[a];return t}return t=new ArrayBuffer(1),e===!1&&(r=new Uint8Array(t),r[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Ks.NAME="lengthBlock";var b={},he=class extends kt{constructor({name:e=Te,optional:t=!1,primitiveSchema:r,...s}={},o){super(s),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new Ns(s),this.lenBlock=new Ks(s),this.valueBlock=o?new o(s):new ge(s)}fromBER(e,t,r){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}toBER(e,t){let r=t||new $r;t||vu(this);let s=this.idBlock.toBER(e);if(r.write(s),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;let a=this.lenBlock.toBER(e);r.write(a),r.write(o)}return t?Qe:r.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():R.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${R.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),r=e.toBER();return J.isEqualBuffer(t,r)}};he.NAME="BaseBlock";function vu(n){if(n instanceof b.Constructed)for(let e of n.valueBlock.value)vu(e)&&(n.lenBlock.isIndefiniteForm=!0);return!!n.lenBlock.isIndefiniteForm}var ln=class extends he{constructor({value:e=Te,...t}={},r){super(t,r),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,r){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};ln.NAME="BaseStringBlock";var Os=class extends dt(ge){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Os.NAME="PrimitiveValueBlock";var wu,fn=class extends he{constructor(e={}){super(e,Os),this.idBlock.isConstructed=!1}};wu=fn;b.Primitive=wu;fn.NAME="PRIMITIVE";function Mp(n,e){if(n instanceof e)return n;let t=new e;return t.idBlock=n.idBlock,t.lenBlock=n.lenBlock,t.warnings=n.warnings,t.valueBeforeDecodeView=n.valueBeforeDecodeView,t}function Vr(n,e=0,t=n.length){let r=e,s=new he({},ge),o=new kt;if(!Ct(o,n,e,t))return s.error=o.error,{offset:-1,result:s};if(!n.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let i=s.idBlock.fromBER(n,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),i===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=i,t-=s.idBlock.blockLength,i=s.lenBlock.fromBER(n,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),i===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=i,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=he;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=b.EndOfContent;break;case 1:c=b.Boolean;break;case 2:c=b.Integer;break;case 3:c=b.BitString;break;case 4:c=b.OctetString;break;case 5:c=b.Null;break;case 6:c=b.ObjectIdentifier;break;case 10:c=b.Enumerated;break;case 12:c=b.Utf8String;break;case 13:c=b.RelativeObjectIdentifier;break;case 14:c=b.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=b.Sequence;break;case 17:c=b.Set;break;case 18:c=b.NumericString;break;case 19:c=b.PrintableString;break;case 20:c=b.TeletexString;break;case 21:c=b.VideotexString;break;case 22:c=b.IA5String;break;case 23:c=b.UTCTime;break;case 24:c=b.GeneralizedTime;break;case 25:c=b.GraphicString;break;case 26:c=b.VisibleString;break;case 27:c=b.GeneralString;break;case 28:c=b.UniversalString;break;case 29:c=b.CharacterString;break;case 30:c=b.BmpString;break;case 31:c=b.DATE;break;case 32:c=b.TimeOfDay;break;case 33:c=b.DateTime;break;case 34:c=b.Duration;break;default:{let u=s.idBlock.isConstructed?new b.Constructed:new b.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?b.Constructed:b.Primitive}return s=Mp(s,c),i=s.fromBER(n,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=n.subarray(r,r+s.blockLength),{offset:i,result:s}}function Lp(n){if(!n.byteLength){let e=new he({},ge);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Vr(R.BufferSourceConverter.toUint8Array(n).slice(),0,n.byteLength)}function Dp(n,e){return n?1:e}var ft=class extends ge{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){let s=R.BufferSourceConverter.toUint8Array(e);if(!Ct(this,s,t,r))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+r),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;Dp(this.isIndefiniteForm,r)>0;){let a=Vr(s,o,r);if(a.offset===-1)return this.error=a.result.error,this.warnings.concat(a.result.warnings),-1;if(o=a.offset,this.blockLength+=a.result.blockLength,r-=a.result.blockLength,this.value.push(a.result),this.isIndefiniteForm&&a.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let r=t||new $r;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,r);return t?Qe:r.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ft.NAME="ConstructedValueBlock";var bu,Bt=class extends he{constructor(e={}){super(e,ft),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){let e=[];for(let r of this.valueBlock.value)e.push(r.toString("ascii").split(` `).map(s=>` ${s}`).join(` `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} : ${e.join(` `)}`:`${t} :`}};bu=Bt;b.Constructed=bu;Bt.NAME="CONSTRUCTED";var Is=class extends ge{fromBER(e,t,r){return t}toBER(e){return Qe}};Is.override="EndOfContentValueBlock";var Au,hn=class extends he{constructor(e={}){super(e,Is),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Au=hn;b.EndOfContent=Au;hn.NAME=un;var Su,pn=class extends he{constructor(e={}){super(e,ge),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){let r=new ArrayBuffer(2);if(!e){let s=new Uint8Array(r);s[0]=5,s[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}};Su=pn;b.Null=Su;pn.NAME="NULL";var Us=class extends dt(ge){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=R.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,r){let s=R.BufferSourceConverter.toUint8Array(e);return Ct(this,s,t,r)?(this.valueHexView=s.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,J.utilDecodeTC.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Us.NAME="BooleanValueBlock";var xu,dn=class extends he{constructor(e={}){super(e,Us),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};xu=dn;b.Boolean=xu;dn.NAME="BOOLEAN";var $s=class extends dt(ft){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=ft.prototype.fromBER.call(this,e,t,r),s===-1)return s;for(let o=0;o<this.value.length;o++){let a=this.value[o].constructor.NAME;if(a===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(a!==yu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,r),this.blockLength=r;return s}toBER(e,t){return this.isConstructed?ft.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};$s.NAME="OctetStringValueBlock";var ku,rr=class extends he{constructor({idBlock:e={},lenBlock:t={},...r}={}){var s,o;(s=r.isConstructed)!==null&&s!==void 0||(r.isConstructed=!!(!((o=r.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},$s),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,r===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(o.byteLength){let a=Vr(o,0,o.byteLength);a.offset!==-1&&a.offset===r&&(this.valueBlock.value=[a.result])}}catch{}}return super.fromBER(e,t,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Bt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${R.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof rr&&e.push(t.valueBlock.valueHexView);return R.BufferSourceConverter.concat(e)}};ku=rr;b.OctetString=ku;rr.NAME=yu;var js=class extends dt(ft){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 s=-1;if(this.isConstructed){if(s=ft.prototype.fromBER.call(this,e,t,r),s===-1)return s;for(let i of this.value){let c=i.constructor.NAME;if(c===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==gu)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let u=i.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}let o=R.BufferSourceConverter.toUint8Array(e);if(!Ct(this,o,t,r))return-1;let a=o.subarray(t,t+r);if(this.unusedBits=a[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let i=a.subarray(1);try{if(i.byteLength){let c=Vr(i,0,i.byteLength);c.offset!==-1&&c.offset===r-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=a.subarray(1),this.blockLength=a.length,t+r}toBER(e,t){if(this.isConstructed)return ft.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Qe;let 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}}};js.NAME="BitStringValueBlock";var Bu,mn=class extends he{constructor({idBlock:e={},lenBlock:t={},...r}={}){var s,o;(s=r.isConstructed)!==null&&s!==void 0||(r.isConstructed=!!(!((o=r.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},js),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 Bt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};Bu=mn;b.BitString=Bu;mn.NAME=gu;var Cu;function Fp(n,e){let t=new Uint8Array([0]),r=new Uint8Array(n),s=new Uint8Array(e),o=r.slice(0),a=o.length-1,i=s.slice(0),c=i.length-1,u=0,l=c<a?a:c,f=0;for(let d=l;d>=0;d--,f++){switch(!0){case f<i.length:u=o[a-f]+i[c-f]+t[0];break;default:u=o[a-f]+t[0]}switch(t[0]=u/10,!0){case f>=o.length:o=J.utilConcatView(new Uint8Array([u%10]),o);break;default:o[a-f]=u%10}}return t[0]>0&&(o=J.utilConcatView(t,o)),o}function du(n){if(n>=cn.length)for(let e=cn.length;e<=n;e++){let t=new Uint8Array([0]),r=cn[e-1].slice(0);for(let s=r.length-1;s>=0;s--){let o=new Uint8Array([(r[s]<<1)+t[0]]);t[0]=o[0]/10,r[s]=o[0]%10}t[0]>0&&(r=J.utilConcatView(t,r)),cn.push(r)}return cn[n]}function zp(n,e){let t=0,r=new Uint8Array(n),s=new Uint8Array(e),o=r.slice(0),a=o.length-1,i=s.slice(0),c=i.length-1,u,l=0;for(let f=c;f>=0;f--,l++)switch(u=o[a-l]-i[c-l]-t,!0){case u<0:t=1,o[a-l]=u+10;break;default:t=0,o[a-l]=u}if(t>0)for(let f=a-c+1;f>=0;f--,l++)if(u=o[a-l]-t,u<0)t=1,o[a-l]=u+10;else{t=0,o[a-l]=u;break}return o.slice()}var yn=class extends dt(ge){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}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=J.utilDecodeTC.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(J.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,t,r,s=0){let o=this.fromBER(e,t,r);if(o===-1)return o;let a=this.valueHexView;return a[0]===0&&(a[1]&128)!==0?this.valueHexView=a.subarray(1):s!==0&&a.length<s&&(s-a.length>1&&(s=a.length+1),this.valueHexView=a.subarray(s-a.length)),o}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let r=new Uint8Array(this.valueHexView.length+1);r[0]=0,r.set(t,1),this.valueHexView=r}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,r){let s=super.fromBER(e,t,r);return s===-1||this.setValueHex(),s}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),r=0,s,o=this.valueHexView,a="",i=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let u=0;u<8;u++){if((s&1)===1)switch(r){case e:t=zp(du(r),t),a="-";break;default:t=Fp(t,du(r))}r++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(i=!0),i&&(a+=hu.charAt(t[c]));return i===!1&&(a+=hu.charAt(0)),a}};Cu=yn;yn.NAME="IntegerValueBlock";Object.defineProperty(Cu.prototype,"valueHex",{set:function(n){this.valueHexView=new Uint8Array(n),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var _u,ht=class extends he{constructor(e={}){super(e,yn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ps(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ps();let t=BigInt(e),r=new $r,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(R.Convert.FromHex(s));if(t<0){let i=new Uint8Array(o.length+(o[0]&128?1:0));i[0]|=128;let u=BigInt(`0x${R.Convert.ToHex(i)}`)+t,l=R.BufferSourceConverter.toUint8Array(R.Convert.FromHex(u.toString(16)));l[0]|=128,r.write(l)}else o[0]&128&&r.write(new Uint8Array([0])),r.write(o);return new ht({valueHex:r.final()})}convertToDER(){let e=new ht({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new ht({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};_u=ht;b.Integer=_u;ht.NAME="INTEGER";var Eu,gn=class extends ht{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Eu=gn;b.Enumerated=Eu;gn.NAME="ENUMERATED";var vn=class extends dt(ge){constructor({valueDec:e=-1,isFirstSid:t=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;let s=R.BufferSourceConverter.toUint8Array(e);if(!Ct(this,s,t,r))return-1;let o=s.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let i=0;i<r&&(this.valueHexView[i]=o[i]&127,this.blockLength++,(o[i]&128)!==0);i++);let a=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength;i++)a[i]=this.valueHexView[i];return this.valueHexView=a,(o[this.blockLength-1]&128)!==0?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=J.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ps();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let r=new Uint8Array(t.length/7);for(let s=0;s<r.length;s++)r[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+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);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength-1;a++)o[a]=s[a]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let t=J.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Qe;let r=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let a=0;a<o;a++)r[a]=s[a]|128;r[o]=s[o]}return r}toString(){let e="";if(this.isHexOnly)e=R.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};vn.NAME="sidBlock";var Rs=class extends ge{constructor({value:e=Te,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let s=t;for(;r>0;){let o=new vn;if(s=o.fromBER(e,s,r),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,r-=o.blockLength,this.value.push(o)}return s}toBER(e){let t=[];for(let r=0;r<this.value.length;r++){let s=this.value[r].toBER(e);if(s.byteLength===0)return this.error=this.value[r].error,Qe;t.push(s)}return ua(t)}fromString(e){this.value=[];let t=0,r=0,s="",o=!1;do if(r=e.indexOf(".