@opensecret/react 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(je,ut){typeof exports=="object"&&typeof module<"u"?ut(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],ut):(je=typeof globalThis<"u"?globalThis:je||self,ut(je.OpenSecretReact={},je.React,je.React))})(this,function(je,ut,ft){"use strict";var lw=Object.defineProperty;var Ay=je=>{throw TypeError(je)};var uw=(je,ut,ft)=>ut in je?lw(je,ut,{enumerable:!0,configurable:!0,writable:!0,value:ft}):je[ut]=ft;var He=(je,ut,ft)=>uw(je,typeof ut!="symbol"?ut+"":ut,ft),_f=(je,ut,ft)=>ut.has(je)||Ay("Cannot "+ft);var $=(je,ut,ft)=>(_f(je,ut,"read from private field"),ft?ft.call(je):ut.get(je)),cr=(je,ut,ft)=>ut.has(je)?Ay("Cannot add the same private member more than once"):ut instanceof WeakSet?ut.add(je):ut.set(je,ft),Tt=(je,ut,ft,Ni)=>(_f(je,ut,"write to private field"),Ni?Ni.call(je,ft):ut.set(je,ft),ft),De=(je,ut,ft)=>(_f(je,ut,"access private method"),ft);var Sy=(je,ut,ft,Ni)=>({set _(ti){Tt(je,ut,ti,ft)},get _(){return $(je,ut,Ni)}});var vo,Tn,un,Xn,Qt,Sr,$t,Qn,Xe,Oi,Vc,Ef,yn,gn,Cr,Yr,er,Dr,tr,Ti,If,To,fn,dr,hn,Uc,Iy,wy,by;class Ni{constructor(){He(this,"_appApiUrl","");He(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const ti=new Ni,kf=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:ti},Symbol.toStringTag,{value:"Module"})),yr=256;class ky{constructor(e="="){He(this,"_paddingCharacter");this._paddingCharacter=e}encodedLength(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0}encode(e){let t="",n=0;for(;n<e.length-2;n+=3){let s=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),t+=this._encodeByte(s>>>1*6&63),t+=this._encodeByte(s>>>0*6&63)}const i=e.length-n;if(i>0){let s=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),i===2?t+=this._encodeByte(s>>>1*6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t}maxDecodedLength(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0}decodedLength(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))}decode(e){if(e.length===0)return new Uint8Array(0);const t=this._getPaddingLength(e),n=e.length-t,i=new Uint8Array(this.maxDecodedLength(n));let s=0,o=0,c=0,u=0,h=0,m=0,x=0;for(;o<n-4;o+=4)u=this._decodeChar(e.charCodeAt(o+0)),h=this._decodeChar(e.charCodeAt(o+1)),m=this._decodeChar(e.charCodeAt(o+2)),x=this._decodeChar(e.charCodeAt(o+3)),i[s++]=u<<2|h>>>4,i[s++]=h<<4|m>>>2,i[s++]=m<<6|x,c|=u&yr,c|=h&yr,c|=m&yr,c|=x&yr;if(o<n-1&&(u=this._decodeChar(e.charCodeAt(o)),h=this._decodeChar(e.charCodeAt(o+1)),i[s++]=u<<2|h>>>4,c|=u&yr,c|=h&yr),o<n-2&&(m=this._decodeChar(e.charCodeAt(o+2)),i[s++]=h<<4|m>>>2,c|=m&yr),o<n-3&&(x=this._decodeChar(e.charCodeAt(o+3)),i[s++]=m<<6|x,c|=x&yr),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return i}_encodeByte(e){let t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)}_decodeChar(e){let t=yr;return t+=(42-e&e-44)>>>8&-yr+e-43+62,t+=(46-e&e-48)>>>8&-yr+e-47+63,t+=(47-e&e-58)>>>8&-yr+e-48+52,t+=(64-e&e-91)>>>8&-yr+e-65+0,t+=(96-e&e-123)>>>8&-yr+e-97+26,t}_getPaddingLength(e){let t=0;if(this._paddingCharacter){for(let n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t}}const Cf=new ky;function $r(r){return Cf.encode(r)}function gs(r){return Cf.decode(r)}function qt(r,e=new Uint8Array(4),t=0){return e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}function Bf(r,e=new Uint8Array(8),t=0){return qt(r>>>0,e,t),qt(r/4294967296>>>0,e,t+4),e}function Or(r){for(let e=0;e<r.length;e++)r[e]=0;return r}const Cy=20;function By(r,e,t){let n=1634760805,i=857760878,s=2036477234,o=1797285236,c=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],m=t[15]<<24|t[14]<<16|t[13]<<8|t[12],x=t[19]<<24|t[18]<<16|t[17]<<8|t[16],G=t[23]<<24|t[22]<<16|t[21]<<8|t[20],N=t[27]<<24|t[26]<<16|t[25]<<8|t[24],v=t[31]<<24|t[30]<<16|t[29]<<8|t[28],A=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],I=e[11]<<24|e[10]<<16|e[9]<<8|e[8],j=e[15]<<24|e[14]<<16|e[13]<<8|e[12],R=n,le=i,Q=s,re=o,Y=c,ye=u,Ke=h,dt=m,Bt=x,jt=G,Pt=N,Ot=v,pt=A,Je=O,ce=I,Ie=j;for(let vt=0;vt<Cy;vt+=2)R=R+Y|0,pt^=R,pt=pt>>>16|pt<<16,Bt=Bt+pt|0,Y^=Bt,Y=Y>>>20|Y<<12,le=le+ye|0,Je^=le,Je=Je>>>16|Je<<16,jt=jt+Je|0,ye^=jt,ye=ye>>>20|ye<<12,Q=Q+Ke|0,ce^=Q,ce=ce>>>16|ce<<16,Pt=Pt+ce|0,Ke^=Pt,Ke=Ke>>>20|Ke<<12,re=re+dt|0,Ie^=re,Ie=Ie>>>16|Ie<<16,Ot=Ot+Ie|0,dt^=Ot,dt=dt>>>20|dt<<12,Q=Q+Ke|0,ce^=Q,ce=ce>>>24|ce<<8,Pt=Pt+ce|0,Ke^=Pt,Ke=Ke>>>25|Ke<<7,re=re+dt|0,Ie^=re,Ie=Ie>>>24|Ie<<8,Ot=Ot+Ie|0,dt^=Ot,dt=dt>>>25|dt<<7,le=le+ye|0,Je^=le,Je=Je>>>24|Je<<8,jt=jt+Je|0,ye^=jt,ye=ye>>>25|ye<<7,R=R+Y|0,pt^=R,pt=pt>>>24|pt<<8,Bt=Bt+pt|0,Y^=Bt,Y=Y>>>25|Y<<7,R=R+ye|0,Ie^=R,Ie=Ie>>>16|Ie<<16,Pt=Pt+Ie|0,ye^=Pt,ye=ye>>>20|ye<<12,le=le+Ke|0,pt^=le,pt=pt>>>16|pt<<16,Ot=Ot+pt|0,Ke^=Ot,Ke=Ke>>>20|Ke<<12,Q=Q+dt|0,Je^=Q,Je=Je>>>16|Je<<16,Bt=Bt+Je|0,dt^=Bt,dt=dt>>>20|dt<<12,re=re+Y|0,ce^=re,ce=ce>>>16|ce<<16,jt=jt+ce|0,Y^=jt,Y=Y>>>20|Y<<12,Q=Q+dt|0,Je^=Q,Je=Je>>>24|Je<<8,Bt=Bt+Je|0,dt^=Bt,dt=dt>>>25|dt<<7,re=re+Y|0,ce^=re,ce=ce>>>24|ce<<8,jt=jt+ce|0,Y^=jt,Y=Y>>>25|Y<<7,le=le+Ke|0,pt^=le,pt=pt>>>24|pt<<8,Ot=Ot+pt|0,Ke^=Ot,Ke=Ke>>>25|Ke<<7,R=R+ye|0,Ie^=R,Ie=Ie>>>24|Ie<<8,Pt=Pt+Ie|0,ye^=Pt,ye=ye>>>25|ye<<7;qt(R+n|0,r,0),qt(le+i|0,r,4),qt(Q+s|0,r,8),qt(re+o|0,r,12),qt(Y+c|0,r,16),qt(ye+u|0,r,20),qt(Ke+h|0,r,24),qt(dt+m|0,r,28),qt(Bt+x|0,r,32),qt(jt+G|0,r,36),qt(Pt+N|0,r,40),qt(Ot+v|0,r,44),qt(pt+A|0,r,48),qt(Je+O|0,r,52),qt(ce+I|0,r,56),qt(Ie+j|0,r,60)}function Lc(r,e,t,n,i=0){if(r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");let s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}const c=new Uint8Array(64);for(let u=0;u<t.length;u+=64){By(c,s,r);for(let h=u;h<u+64&&h<t.length;h++)n[h]=t[h]^c[h-u];Oy(s,0,o)}return Or(c),i===0&&Or(s),n}function Of(r,e,t,n=0){return Or(t),Lc(r,e,t,t,n)}function Oy(r,e,t){let n=1;for(;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}function Ty(r,e){if(r.length!==e.length)return 0;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}function Ny(r,e){return r.length===0||e.length===0?!1:Ty(r,e)!==0}const jy=16;class Py{constructor(e){He(this,"digestLength",jy);He(this,"_buffer",new Uint8Array(16));He(this,"_r",new Uint16Array(10));He(this,"_h",new Uint16Array(10));He(this,"_pad",new Uint16Array(8));He(this,"_leftover",0);He(this,"_fin",0);He(this,"_finished",!1);let t=e[0]|e[1]<<8;this._r[0]=t&8191;let n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;let i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;let s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;let o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;let c=e[10]|e[11]<<8;this._r[6]=(o>>>14|c<<2)&8191;let u=e[12]|e[13]<<8;this._r[7]=(c>>>11|u<<5)&8065;let h=e[14]|e[15]<<8;this._r[8]=(u>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}_blocks(e,t,n){let i=this._fin?0:2048,s=this._h[0],o=this._h[1],c=this._h[2],u=this._h[3],h=this._h[4],m=this._h[5],x=this._h[6],G=this._h[7],N=this._h[8],v=this._h[9],A=this._r[0],O=this._r[1],I=this._r[2],j=this._r[3],R=this._r[4],le=this._r[5],Q=this._r[6],re=this._r[7],Y=this._r[8],ye=this._r[9];for(;n>=16;){let Ke=e[t+0]|e[t+1]<<8;s+=Ke&8191;let dt=e[t+2]|e[t+3]<<8;o+=(Ke>>>13|dt<<3)&8191;let Bt=e[t+4]|e[t+5]<<8;c+=(dt>>>10|Bt<<6)&8191;let jt=e[t+6]|e[t+7]<<8;u+=(Bt>>>7|jt<<9)&8191;let Pt=e[t+8]|e[t+9]<<8;h+=(jt>>>4|Pt<<12)&8191,m+=Pt>>>1&8191;let Ot=e[t+10]|e[t+11]<<8;x+=(Pt>>>14|Ot<<2)&8191;let pt=e[t+12]|e[t+13]<<8;G+=(Ot>>>11|pt<<5)&8191;let Je=e[t+14]|e[t+15]<<8;N+=(pt>>>8|Je<<8)&8191,v+=Je>>>5|i;let ce=0,Ie=ce;Ie+=s*A,Ie+=o*(5*ye),Ie+=c*(5*Y),Ie+=u*(5*re),Ie+=h*(5*Q),ce=Ie>>>13,Ie&=8191,Ie+=m*(5*le),Ie+=x*(5*R),Ie+=G*(5*j),Ie+=N*(5*I),Ie+=v*(5*O),ce+=Ie>>>13,Ie&=8191;let vt=ce;vt+=s*O,vt+=o*A,vt+=c*(5*ye),vt+=u*(5*Y),vt+=h*(5*re),ce=vt>>>13,vt&=8191,vt+=m*(5*Q),vt+=x*(5*le),vt+=G*(5*R),vt+=N*(5*j),vt+=v*(5*I),ce+=vt>>>13,vt&=8191;let Mt=ce;Mt+=s*I,Mt+=o*O,Mt+=c*A,Mt+=u*(5*ye),Mt+=h*(5*Y),ce=Mt>>>13,Mt&=8191,Mt+=m*(5*re),Mt+=x*(5*Q),Mt+=G*(5*le),Mt+=N*(5*R),Mt+=v*(5*j),ce+=Mt>>>13,Mt&=8191;let Vt=ce;Vt+=s*j,Vt+=o*I,Vt+=c*O,Vt+=u*A,Vt+=h*(5*ye),ce=Vt>>>13,Vt&=8191,Vt+=m*(5*Y),Vt+=x*(5*re),Vt+=G*(5*Q),Vt+=N*(5*le),Vt+=v*(5*R),ce+=Vt>>>13,Vt&=8191;let he=ce;he+=s*R,he+=o*j,he+=c*I,he+=u*O,he+=h*A,ce=he>>>13,he&=8191,he+=m*(5*ye),he+=x*(5*Y),he+=G*(5*re),he+=N*(5*Q),he+=v*(5*le),ce+=he>>>13,he&=8191;let it=ce;it+=s*le,it+=o*R,it+=c*j,it+=u*I,it+=h*O,ce=it>>>13,it&=8191,it+=m*A,it+=x*(5*ye),it+=G*(5*Y),it+=N*(5*re),it+=v*(5*Q),ce+=it>>>13,it&=8191;let mt=ce;mt+=s*Q,mt+=o*le,mt+=c*R,mt+=u*j,mt+=h*I,ce=mt>>>13,mt&=8191,mt+=m*O,mt+=x*A,mt+=G*(5*ye),mt+=N*(5*Y),mt+=v*(5*re),ce+=mt>>>13,mt&=8191;let te=ce;te+=s*re,te+=o*Q,te+=c*le,te+=u*R,te+=h*j,ce=te>>>13,te&=8191,te+=m*I,te+=x*O,te+=G*A,te+=N*(5*ye),te+=v*(5*Y),ce+=te>>>13,te&=8191;let gt=ce;gt+=s*Y,gt+=o*re,gt+=c*Q,gt+=u*le,gt+=h*R,ce=gt>>>13,gt&=8191,gt+=m*j,gt+=x*I,gt+=G*O,gt+=N*A,gt+=v*(5*ye),ce+=gt>>>13,gt&=8191;let Ft=ce;Ft+=s*ye,Ft+=o*Y,Ft+=c*re,Ft+=u*Q,Ft+=h*le,ce=Ft>>>13,Ft&=8191,Ft+=m*R,Ft+=x*j,Ft+=G*I,Ft+=N*O,Ft+=v*A,ce+=Ft>>>13,Ft&=8191,ce=(ce<<2)+ce|0,ce=ce+Ie|0,Ie=ce&8191,ce=ce>>>13,vt+=ce,s=Ie,o=vt,c=Mt,u=Vt,h=he,m=it,x=mt,G=te,N=gt,v=Ft,t+=16,n-=16}this._h[0]=s,this._h[1]=o,this._h[2]=c,this._h[3]=u,this._h[4]=h,this._h[5]=m,this._h[6]=x,this._h[7]=G,this._h[8]=N,this._h[9]=v}finish(e,t=0){const n=new Uint16Array(10);let i,s,o,c;if(this._leftover){for(c=this._leftover,this._buffer[c++]=1;c<16;c++)this._buffer[c]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,c=2;c<10;c++)this._h[c]+=i,i=this._h[c]>>>13,this._h[c]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,c=1;c<10;c++)n[c]=this._h[c]+i,i=n[c]>>>13,n[c]&=8191;for(n[9]-=8192,s=(i^1)-1,c=0;c<10;c++)n[c]&=s;for(s=~s,c=0;c<10;c++)this._h[c]=this._h[c]&s|n[c];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,c=1;c<8;c++)o=(this._h[c]+this._pad[c]|0)+(o>>>16)|0,this._h[c]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this}update(e){let t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(let s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(let s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this}digest(){if(this._finished)throw new Error("Poly1305 was finished");let e=new Uint8Array(16);return this.finish(e),e}clean(){return Or(this._buffer),Or(this._r),Or(this._h),Or(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this}}const Ry=32,Uy=12,Dy=16,Tf=new Uint8Array(16);class Hc{constructor(e){He(this,"nonceLength",Uy);He(this,"tagLength",Dy);He(this,"_key");if(e.length!==Ry)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}seal(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Of(this._key,s,o,4);const c=t.length+this.tagLength;let u;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");u=i}else u=new Uint8Array(c);return Lc(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),n),Or(s),u}open(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Of(this._key,s,o,4);const c=new Uint8Array(this.tagLength);if(this._authenticate(c,o,t.subarray(0,t.length-this.tagLength),n),!Ny(c,t.subarray(t.length-this.tagLength,t.length)))return null;const u=t.length-this.tagLength;let h;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");h=i}else h=new Uint8Array(u);return Lc(this._key,s,t.subarray(0,t.length-this.tagLength),h,4),Or(s),h}clean(){return Or(this._key),this}_authenticate(e,t,n,i){const s=new Py(t);i&&(s.update(i),i.length%16>0&&s.update(Tf.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(Tf.subarray(n.length%16));const o=new Uint8Array(8);i&&Bf(i.length,o),s.update(o),Bf(n.length,o),s.update(o);const c=s.digest();for(let u=0;u<c.length;u++)e[u]=c[u];s.clean(),Or(c),Or(o)}}const Nf=65536;class $y{constructor(){He(this,"isAvailable",!1);He(this,"isInstantiated",!1);typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const t=new Uint8Array(e);for(let n=0;n<t.length;n+=Nf)crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,Nf)));return t}}const My=new $y;function Vy(r,e=My){return e.randomBytes(r)}function jf(r,e){const t=new Hc(r),n=Vy(12),s=new TextEncoder().encode(e),o=t.seal(n,s),c=new Uint8Array(n.length+o.length);return c.set(n),c.set(o,n.length),$r(c)}function Pf(r,e){const t=new Hc(r),n=gs(e),i=12,s=n.slice(0,i),o=n.slice(i),c=t.open(s,o);if(!c)throw new Error("Decryption failed");return new TextDecoder().decode(c)}var Fc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ly(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Hy(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
1
+ (function(Pe,pt){typeof exports=="object"&&typeof module<"u"?pt(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],pt):(Pe=typeof globalThis<"u"?globalThis:Pe||self,pt(Pe.OpenSecretReact={},Pe.React,Pe.React))})(this,function(Pe,pt,yt){"use strict";var hw=Object.defineProperty;var Ay=Pe=>{throw TypeError(Pe)};var dw=(Pe,pt,yt)=>pt in Pe?hw(Pe,pt,{enumerable:!0,configurable:!0,writable:!0,value:yt}):Pe[pt]=yt;var Fe=(Pe,pt,yt)=>dw(Pe,typeof pt!="symbol"?pt+"":pt,yt),_f=(Pe,pt,yt)=>pt.has(Pe)||Ay("Cannot "+yt);var $=(Pe,pt,yt)=>(_f(Pe,pt,"read from private field"),yt?yt.call(Pe):pt.get(Pe)),cr=(Pe,pt,yt)=>pt.has(Pe)?Ay("Cannot add the same private member more than once"):pt instanceof WeakSet?pt.add(Pe):pt.set(Pe,yt),jt=(Pe,pt,yt,Ni)=>(_f(Pe,pt,"write to private field"),Ni?Ni.call(Pe,yt):pt.set(Pe,yt),yt),$e=(Pe,pt,yt)=>(_f(Pe,pt,"access private method"),yt);var Sy=(Pe,pt,yt,Ni)=>({set _(ti){jt(Pe,pt,ti,yt)},get _(){return $(Pe,pt,Ni)}});var vo,Tn,un,Xn,Qt,Sr,Mt,Qn,et,Oi,Vc,Ef,yn,gn,Cr,Yr,er,Dr,tr,Ti,If,To,fn,dr,hn,Uc,Iy,wy,by;class Ni{constructor(){Fe(this,"_appApiUrl","");Fe(this,"_platformApiUrl","")}configure(e,t){this._appApiUrl=e,this._platformApiUrl=t}get platformApiUrl(){return this._platformApiUrl}get appApiUrl(){return this._appApiUrl}isPlatformPath(e){return e.includes("/platform/")}resolveEndpoint(e){const t=this.isPlatformPath(e);return{baseUrl:t?this._platformApiUrl:this._appApiUrl,context:t?"platform":"app"}}buildUrl(e){if(e.startsWith("http"))return e;const t=this.resolveEndpoint(e),n=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,i=e.startsWith("/")?e:`/${e}`;return`${n}${i}`}getRefreshFunction(e){return this.isPlatformPath(e)?"platformRefreshToken":"refreshToken"}}const ti=new Ni,kf=Object.freeze(Object.defineProperty({__proto__:null,apiConfig:ti},Symbol.toStringTag,{value:"Module"})),yr=256;class ky{constructor(e="="){Fe(this,"_paddingCharacter");this._paddingCharacter=e}encodedLength(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0}encode(e){let t="",n=0;for(;n<e.length-2;n+=3){let s=e[n]<<16|e[n+1]<<8|e[n+2];t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),t+=this._encodeByte(s>>>1*6&63),t+=this._encodeByte(s>>>0*6&63)}const i=e.length-n;if(i>0){let s=e[n]<<16|(i===2?e[n+1]<<8:0);t+=this._encodeByte(s>>>3*6&63),t+=this._encodeByte(s>>>2*6&63),i===2?t+=this._encodeByte(s>>>1*6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t}maxDecodedLength(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0}decodedLength(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))}decode(e){if(e.length===0)return new Uint8Array(0);const t=this._getPaddingLength(e),n=e.length-t,i=new Uint8Array(this.maxDecodedLength(n));let s=0,o=0,c=0,u=0,h=0,m=0,x=0;for(;o<n-4;o+=4)u=this._decodeChar(e.charCodeAt(o+0)),h=this._decodeChar(e.charCodeAt(o+1)),m=this._decodeChar(e.charCodeAt(o+2)),x=this._decodeChar(e.charCodeAt(o+3)),i[s++]=u<<2|h>>>4,i[s++]=h<<4|m>>>2,i[s++]=m<<6|x,c|=u&yr,c|=h&yr,c|=m&yr,c|=x&yr;if(o<n-1&&(u=this._decodeChar(e.charCodeAt(o)),h=this._decodeChar(e.charCodeAt(o+1)),i[s++]=u<<2|h>>>4,c|=u&yr,c|=h&yr),o<n-2&&(m=this._decodeChar(e.charCodeAt(o+2)),i[s++]=h<<4|m>>>2,c|=m&yr),o<n-3&&(x=this._decodeChar(e.charCodeAt(o+3)),i[s++]=m<<6|x,c|=x&yr),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return i}_encodeByte(e){let t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)}_decodeChar(e){let t=yr;return t+=(42-e&e-44)>>>8&-yr+e-43+62,t+=(46-e&e-48)>>>8&-yr+e-47+63,t+=(47-e&e-58)>>>8&-yr+e-48+52,t+=(64-e&e-91)>>>8&-yr+e-65+0,t+=(96-e&e-123)>>>8&-yr+e-97+26,t}_getPaddingLength(e){let t=0;if(this._paddingCharacter){for(let n=e.length-1;n>=0&&e[n]===this._paddingCharacter;n--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t}}const Cf=new ky;function $r(r){return Cf.encode(r)}function gs(r){return Cf.decode(r)}function qt(r,e=new Uint8Array(4),t=0){return e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}function Bf(r,e=new Uint8Array(8),t=0){return qt(r>>>0,e,t),qt(r/4294967296>>>0,e,t+4),e}function Or(r){for(let e=0;e<r.length;e++)r[e]=0;return r}const Cy=20;function By(r,e,t){let n=1634760805,i=857760878,s=2036477234,o=1797285236,c=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],m=t[15]<<24|t[14]<<16|t[13]<<8|t[12],x=t[19]<<24|t[18]<<16|t[17]<<8|t[16],G=t[23]<<24|t[22]<<16|t[21]<<8|t[20],N=t[27]<<24|t[26]<<16|t[25]<<8|t[24],v=t[31]<<24|t[30]<<16|t[29]<<8|t[28],A=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],I=e[11]<<24|e[10]<<16|e[9]<<8|e[8],P=e[15]<<24|e[14]<<16|e[13]<<8|e[12],R=n,fe=i,qe=s,Je=o,Re=c,W=u,se=h,oe=m,Ae=x,it=G,It=N,Pt=v,gt=A,Qe=O,ce=I,Ie=P;for(let wt=0;wt<Cy;wt+=2)R=R+Re|0,gt^=R,gt=gt>>>16|gt<<16,Ae=Ae+gt|0,Re^=Ae,Re=Re>>>20|Re<<12,fe=fe+W|0,Qe^=fe,Qe=Qe>>>16|Qe<<16,it=it+Qe|0,W^=it,W=W>>>20|W<<12,qe=qe+se|0,ce^=qe,ce=ce>>>16|ce<<16,It=It+ce|0,se^=It,se=se>>>20|se<<12,Je=Je+oe|0,Ie^=Je,Ie=Ie>>>16|Ie<<16,Pt=Pt+Ie|0,oe^=Pt,oe=oe>>>20|oe<<12,qe=qe+se|0,ce^=qe,ce=ce>>>24|ce<<8,It=It+ce|0,se^=It,se=se>>>25|se<<7,Je=Je+oe|0,Ie^=Je,Ie=Ie>>>24|Ie<<8,Pt=Pt+Ie|0,oe^=Pt,oe=oe>>>25|oe<<7,fe=fe+W|0,Qe^=fe,Qe=Qe>>>24|Qe<<8,it=it+Qe|0,W^=it,W=W>>>25|W<<7,R=R+Re|0,gt^=R,gt=gt>>>24|gt<<8,Ae=Ae+gt|0,Re^=Ae,Re=Re>>>25|Re<<7,R=R+W|0,Ie^=R,Ie=Ie>>>16|Ie<<16,It=It+Ie|0,W^=It,W=W>>>20|W<<12,fe=fe+se|0,gt^=fe,gt=gt>>>16|gt<<16,Pt=Pt+gt|0,se^=Pt,se=se>>>20|se<<12,qe=qe+oe|0,Qe^=qe,Qe=Qe>>>16|Qe<<16,Ae=Ae+Qe|0,oe^=Ae,oe=oe>>>20|oe<<12,Je=Je+Re|0,ce^=Je,ce=ce>>>16|ce<<16,it=it+ce|0,Re^=it,Re=Re>>>20|Re<<12,qe=qe+oe|0,Qe^=qe,Qe=Qe>>>24|Qe<<8,Ae=Ae+Qe|0,oe^=Ae,oe=oe>>>25|oe<<7,Je=Je+Re|0,ce^=Je,ce=ce>>>24|ce<<8,it=it+ce|0,Re^=it,Re=Re>>>25|Re<<7,fe=fe+se|0,gt^=fe,gt=gt>>>24|gt<<8,Pt=Pt+gt|0,se^=Pt,se=se>>>25|se<<7,R=R+W|0,Ie^=R,Ie=Ie>>>24|Ie<<8,It=It+Ie|0,W^=It,W=W>>>25|W<<7;qt(R+n|0,r,0),qt(fe+i|0,r,4),qt(qe+s|0,r,8),qt(Je+o|0,r,12),qt(Re+c|0,r,16),qt(W+u|0,r,20),qt(se+h|0,r,24),qt(oe+m|0,r,28),qt(Ae+x|0,r,32),qt(it+G|0,r,36),qt(It+N|0,r,40),qt(Pt+v|0,r,44),qt(gt+A|0,r,48),qt(Qe+O|0,r,52),qt(ce+I|0,r,56),qt(Ie+P|0,r,60)}function Lc(r,e,t,n,i=0){if(r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<t.length)throw new Error("ChaCha: destination is shorter than source");let s,o;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),o=s.length-e.length,s.set(e,o)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,o=i}const c=new Uint8Array(64);for(let u=0;u<t.length;u+=64){By(c,s,r);for(let h=u;h<u+64&&h<t.length;h++)n[h]=t[h]^c[h-u];Oy(s,0,o)}return Or(c),i===0&&Or(s),n}function Of(r,e,t,n=0){return Or(t),Lc(r,e,t,t,n)}function Oy(r,e,t){let n=1;for(;t--;)n=n+(r[e]&255)|0,r[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}function Ty(r,e){if(r.length!==e.length)return 0;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return 1&t-1>>>8}function Ny(r,e){return r.length===0||e.length===0?!1:Ty(r,e)!==0}const Py=16;class jy{constructor(e){Fe(this,"digestLength",Py);Fe(this,"_buffer",new Uint8Array(16));Fe(this,"_r",new Uint16Array(10));Fe(this,"_h",new Uint16Array(10));Fe(this,"_pad",new Uint16Array(8));Fe(this,"_leftover",0);Fe(this,"_fin",0);Fe(this,"_finished",!1);let t=e[0]|e[1]<<8;this._r[0]=t&8191;let n=e[2]|e[3]<<8;this._r[1]=(t>>>13|n<<3)&8191;let i=e[4]|e[5]<<8;this._r[2]=(n>>>10|i<<6)&7939;let s=e[6]|e[7]<<8;this._r[3]=(i>>>7|s<<9)&8191;let o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;let c=e[10]|e[11]<<8;this._r[6]=(o>>>14|c<<2)&8191;let u=e[12]|e[13]<<8;this._r[7]=(c>>>11|u<<5)&8065;let h=e[14]|e[15]<<8;this._r[8]=(u>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}_blocks(e,t,n){let i=this._fin?0:2048,s=this._h[0],o=this._h[1],c=this._h[2],u=this._h[3],h=this._h[4],m=this._h[5],x=this._h[6],G=this._h[7],N=this._h[8],v=this._h[9],A=this._r[0],O=this._r[1],I=this._r[2],P=this._r[3],R=this._r[4],fe=this._r[5],qe=this._r[6],Je=this._r[7],Re=this._r[8],W=this._r[9];for(;n>=16;){let se=e[t+0]|e[t+1]<<8;s+=se&8191;let oe=e[t+2]|e[t+3]<<8;o+=(se>>>13|oe<<3)&8191;let Ae=e[t+4]|e[t+5]<<8;c+=(oe>>>10|Ae<<6)&8191;let it=e[t+6]|e[t+7]<<8;u+=(Ae>>>7|it<<9)&8191;let It=e[t+8]|e[t+9]<<8;h+=(it>>>4|It<<12)&8191,m+=It>>>1&8191;let Pt=e[t+10]|e[t+11]<<8;x+=(It>>>14|Pt<<2)&8191;let gt=e[t+12]|e[t+13]<<8;G+=(Pt>>>11|gt<<5)&8191;let Qe=e[t+14]|e[t+15]<<8;N+=(gt>>>8|Qe<<8)&8191,v+=Qe>>>5|i;let ce=0,Ie=ce;Ie+=s*A,Ie+=o*(5*W),Ie+=c*(5*Re),Ie+=u*(5*Je),Ie+=h*(5*qe),ce=Ie>>>13,Ie&=8191,Ie+=m*(5*fe),Ie+=x*(5*R),Ie+=G*(5*P),Ie+=N*(5*I),Ie+=v*(5*O),ce+=Ie>>>13,Ie&=8191;let wt=ce;wt+=s*O,wt+=o*A,wt+=c*(5*W),wt+=u*(5*Re),wt+=h*(5*Je),ce=wt>>>13,wt&=8191,wt+=m*(5*qe),wt+=x*(5*fe),wt+=G*(5*R),wt+=N*(5*P),wt+=v*(5*I),ce+=wt>>>13,wt&=8191;let Vt=ce;Vt+=s*I,Vt+=o*O,Vt+=c*A,Vt+=u*(5*W),Vt+=h*(5*Re),ce=Vt>>>13,Vt&=8191,Vt+=m*(5*Je),Vt+=x*(5*qe),Vt+=G*(5*fe),Vt+=N*(5*R),Vt+=v*(5*P),ce+=Vt>>>13,Vt&=8191;let Lt=ce;Lt+=s*P,Lt+=o*I,Lt+=c*O,Lt+=u*A,Lt+=h*(5*W),ce=Lt>>>13,Lt&=8191,Lt+=m*(5*Re),Lt+=x*(5*Je),Lt+=G*(5*qe),Lt+=N*(5*fe),Lt+=v*(5*R),ce+=Lt>>>13,Lt&=8191;let he=ce;he+=s*R,he+=o*P,he+=c*I,he+=u*O,he+=h*A,ce=he>>>13,he&=8191,he+=m*(5*W),he+=x*(5*Re),he+=G*(5*Je),he+=N*(5*qe),he+=v*(5*fe),ce+=he>>>13,he&=8191;let ct=ce;ct+=s*fe,ct+=o*R,ct+=c*P,ct+=u*I,ct+=h*O,ce=ct>>>13,ct&=8191,ct+=m*A,ct+=x*(5*W),ct+=G*(5*Re),ct+=N*(5*Je),ct+=v*(5*qe),ce+=ct>>>13,ct&=8191;let bt=ce;bt+=s*qe,bt+=o*fe,bt+=c*R,bt+=u*P,bt+=h*I,ce=bt>>>13,bt&=8191,bt+=m*O,bt+=x*A,bt+=G*(5*W),bt+=N*(5*Re),bt+=v*(5*Je),ce+=bt>>>13,bt&=8191;let ee=ce;ee+=s*Je,ee+=o*qe,ee+=c*fe,ee+=u*R,ee+=h*P,ce=ee>>>13,ee&=8191,ee+=m*I,ee+=x*O,ee+=G*A,ee+=N*(5*W),ee+=v*(5*Re),ce+=ee>>>13,ee&=8191;let mt=ce;mt+=s*Re,mt+=o*Je,mt+=c*qe,mt+=u*fe,mt+=h*R,ce=mt>>>13,mt&=8191,mt+=m*P,mt+=x*I,mt+=G*O,mt+=N*A,mt+=v*(5*W),ce+=mt>>>13,mt&=8191;let Ft=ce;Ft+=s*W,Ft+=o*Re,Ft+=c*Je,Ft+=u*qe,Ft+=h*fe,ce=Ft>>>13,Ft&=8191,Ft+=m*R,Ft+=x*P,Ft+=G*I,Ft+=N*O,Ft+=v*A,ce+=Ft>>>13,Ft&=8191,ce=(ce<<2)+ce|0,ce=ce+Ie|0,Ie=ce&8191,ce=ce>>>13,wt+=ce,s=Ie,o=wt,c=Vt,u=Lt,h=he,m=ct,x=bt,G=ee,N=mt,v=Ft,t+=16,n-=16}this._h[0]=s,this._h[1]=o,this._h[2]=c,this._h[3]=u,this._h[4]=h,this._h[5]=m,this._h[6]=x,this._h[7]=G,this._h[8]=N,this._h[9]=v}finish(e,t=0){const n=new Uint16Array(10);let i,s,o,c;if(this._leftover){for(c=this._leftover,this._buffer[c++]=1;c<16;c++)this._buffer[c]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(i=this._h[1]>>>13,this._h[1]&=8191,c=2;c<10;c++)this._h[c]+=i,i=this._h[c]>>>13,this._h[c]&=8191;for(this._h[0]+=i*5,i=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=i,i=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=i,n[0]=this._h[0]+5,i=n[0]>>>13,n[0]&=8191,c=1;c<10;c++)n[c]=this._h[c]+i,i=n[c]>>>13,n[c]&=8191;for(n[9]-=8192,s=(i^1)-1,c=0;c<10;c++)n[c]&=s;for(s=~s,c=0;c<10;c++)this._h[c]=this._h[c]&s|n[c];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,c=1;c<8;c++)o=(this._h[c]+this._pad[c]|0)+(o>>>16)|0,this._h[c]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this}update(e){let t=0,n=e.length,i;if(this._leftover){i=16-this._leftover,i>n&&(i=n);for(let s=0;s<i;s++)this._buffer[this._leftover+s]=e[t+s];if(n-=i,t+=i,this._leftover+=i,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(i=n-n%16,this._blocks(e,t,i),t+=i,n-=i),n){for(let s=0;s<n;s++)this._buffer[this._leftover+s]=e[t+s];this._leftover+=n}return this}digest(){if(this._finished)throw new Error("Poly1305 was finished");let e=new Uint8Array(16);return this.finish(e),e}clean(){return Or(this._buffer),Or(this._r),Or(this._h),Or(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this}}const Ry=32,Uy=12,Dy=16,Tf=new Uint8Array(16);class Hc{constructor(e){Fe(this,"nonceLength",Uy);Fe(this,"tagLength",Dy);Fe(this,"_key");if(e.length!==Ry)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}seal(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Of(this._key,s,o,4);const c=t.length+this.tagLength;let u;if(i){if(i.length!==c)throw new Error("ChaCha20Poly1305: incorrect destination length");u=i}else u=new Uint8Array(c);return Lc(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),n),Or(s),u}open(e,t,n,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length<this.tagLength)return null;const s=new Uint8Array(16);s.set(e,s.length-e.length);const o=new Uint8Array(32);Of(this._key,s,o,4);const c=new Uint8Array(this.tagLength);if(this._authenticate(c,o,t.subarray(0,t.length-this.tagLength),n),!Ny(c,t.subarray(t.length-this.tagLength,t.length)))return null;const u=t.length-this.tagLength;let h;if(i){if(i.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");h=i}else h=new Uint8Array(u);return Lc(this._key,s,t.subarray(0,t.length-this.tagLength),h,4),Or(s),h}clean(){return Or(this._key),this}_authenticate(e,t,n,i){const s=new jy(t);i&&(s.update(i),i.length%16>0&&s.update(Tf.subarray(i.length%16))),s.update(n),n.length%16>0&&s.update(Tf.subarray(n.length%16));const o=new Uint8Array(8);i&&Bf(i.length,o),s.update(o),Bf(n.length,o),s.update(o);const c=s.digest();for(let u=0;u<c.length;u++)e[u]=c[u];s.clean(),Or(c),Or(o)}}const Nf=65536;class $y{constructor(){Fe(this,"isAvailable",!1);Fe(this,"isInstantiated",!1);typeof crypto<"u"&&"getRandomValues"in crypto&&(this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");const t=new Uint8Array(e);for(let n=0;n<t.length;n+=Nf)crypto.getRandomValues(t.subarray(n,n+Math.min(t.length-n,Nf)));return t}}const My=new $y;function Vy(r,e=My){return e.randomBytes(r)}function Pf(r,e){const t=new Hc(r),n=Vy(12),s=new TextEncoder().encode(e),o=t.seal(n,s),c=new Uint8Array(n.length+o.length);return c.set(n),c.set(o,n.length),$r(c)}function jf(r,e){const t=new Hc(r),n=gs(e),i=12,s=n.slice(0,i),o=n.slice(i),c=t.open(s,o);if(!c)throw new Error("Decryption failed");return new TextDecoder().decode(c)}var Fc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ly(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Hy(r){if(r.__esModule)return r;var e=r.default;if(typeof e=="function"){var t=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(r).forEach(function(n){var i=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return r[n]}})}),t}/*! *****************************************************************************
2
2
  Copyright (C) Microsoft. All rights reserved.
3
3
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
4
  this file except in compliance with the License. You may obtain a copy of the
@@ -11,7 +11,7 @@
11
11
 
12
12
  See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
- ***************************************************************************** */var Rf;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Fc=="object"?Fc:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(u,h){return function(m,x){Object.defineProperty(u,m,{configurable:!0,writable:!0,value:x}),h&&h(m,x)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",u={__proto__:[]}instanceof Array,h=!c&&!u,m={create:c?function(){return Bo(Object.create(null))}:u?function(){return Bo({__proto__:null})}:function(){return Bo({})},has:h?function(_,k){return n.call(_,k)}:function(_,k){return k in _},get:h?function(_,k){return n.call(_,k)?_[k]:void 0}:function(_,k){return _[k]}},x=Object.getPrototypeOf(Function),G=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:ko(),N=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Co(),v=typeof WeakMap=="function"?WeakMap:$c(),A=i?Symbol.for("@reflect-metadata:registry"):void 0,O=Eo(),I=ps(O);function j(_,k,T,K){if(he(T)){if(!wo(_))throw new TypeError;if(!bo(k))throw new TypeError;return jt(_,k)}else{if(!wo(_))throw new TypeError;if(!te(k))throw new TypeError;if(!te(K)&&!he(K)&&!it(K))throw new TypeError;return it(K)&&(K=void 0),T=pr(T),Pt(_,k,T,K)}}e("decorate",j);function R(_,k){function T(K,xe){if(!te(K))throw new TypeError;if(!he(xe)&&!Sf(xe))throw new TypeError;Ie(_,k,K,xe)}return T}e("metadata",R);function le(_,k,T,K){if(!te(T))throw new TypeError;return he(K)||(K=pr(K)),Ie(_,k,T,K)}e("defineMetadata",le);function Q(_,k,T){if(!te(k))throw new TypeError;return he(T)||(T=pr(T)),Ot(_,k,T)}e("hasMetadata",Q);function re(_,k,T){if(!te(k))throw new TypeError;return he(T)||(T=pr(T)),pt(_,k,T)}e("hasOwnMetadata",re);function Y(_,k,T){if(!te(k))throw new TypeError;return he(T)||(T=pr(T)),Je(_,k,T)}e("getMetadata",Y);function ye(_,k,T){if(!te(k))throw new TypeError;return he(T)||(T=pr(T)),ce(_,k,T)}e("getOwnMetadata",ye);function Ke(_,k){if(!te(_))throw new TypeError;return he(k)||(k=pr(k)),vt(_,k)}e("getMetadataKeys",Ke);function dt(_,k){if(!te(_))throw new TypeError;return he(k)||(k=pr(k)),Mt(_,k)}e("getOwnMetadataKeys",dt);function Bt(_,k,T){if(!te(k))throw new TypeError;if(he(T)||(T=pr(T)),!te(k))throw new TypeError;he(T)||(T=pr(T));var K=pn(k,T,!1);return he(K)?!1:K.OrdinaryDeleteMetadata(_,k,T)}e("deleteMetadata",Bt);function jt(_,k){for(var T=_.length-1;T>=0;--T){var K=_[T],xe=K(k);if(!he(xe)&&!it(xe)){if(!bo(xe))throw new TypeError;k=xe}}return k}function Pt(_,k,T,K){for(var xe=_.length-1;xe>=0;--xe){var _t=_[xe],Et=_t(k,T,K);if(!he(Et)&&!it(Et)){if(!te(Et))throw new TypeError;K=Et}}return K}function Ot(_,k,T){var K=pt(_,k,T);if(K)return!0;var xe=ds(k);return it(xe)?!1:Ot(_,xe,T)}function pt(_,k,T){var K=pn(k,T,!1);return he(K)?!1:mo(K.OrdinaryHasOwnMetadata(_,k,T))}function Je(_,k,T){var K=pt(_,k,T);if(K)return ce(_,k,T);var xe=ds(k);if(!it(xe))return Je(_,xe,T)}function ce(_,k,T){var K=pn(k,T,!1);if(!he(K))return K.OrdinaryGetOwnMetadata(_,k,T)}function Ie(_,k,T,K){var xe=pn(T,K,!0);xe.OrdinaryDefineOwnMetadata(_,k,T,K)}function vt(_,k){var T=Mt(_,k),K=ds(_);if(K===null)return T;var xe=vt(K,k);if(xe.length<=0)return T;if(T.length<=0)return xe;for(var _t=new N,Et=[],Re=0,Z=T;Re<Z.length;Re++){var ne=Z[Re],de=_t.has(ne);de||(_t.add(ne),Et.push(ne))}for(var me=0,Ye=xe;me<Ye.length;me++){var ne=Ye[me],de=_t.has(ne);de||(_t.add(ne),Et.push(ne))}return Et}function Mt(_,k){var T=pn(_,k,!1);return T?T.OrdinaryOwnMetadataKeys(_,k):[]}function Vt(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function he(_){return _===void 0}function it(_){return _===null}function mt(_){return typeof _=="symbol"}function te(_){return typeof _=="object"?_!==null:typeof _=="function"}function gt(_,k){switch(Vt(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",K=Dc(_,s);if(K!==void 0){var xe=K.call(_,T);if(te(xe))throw new TypeError;return xe}return Ft(_)}function Ft(_,k){var T,K;{var xe=_.toString;if(Nn(xe)){var K=xe.call(_);if(!te(K))return K}var T=_.valueOf;if(Nn(T)){var K=T.call(_);if(!te(K))return K}}throw new TypeError}function mo(_){return!!_}function hs(_){return""+_}function pr(_){var k=gt(_);return mt(k)?k:hs(k)}function wo(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function Nn(_){return typeof _=="function"}function bo(_){return typeof _=="function"}function Sf(_){switch(Vt(_)){case 3:return!0;case 4:return!0;default:return!1}}function xo(_,k){return _===k||_!==_&&k!==k}function Dc(_,k){var T=_[k];if(T!=null){if(!Nn(T))throw new TypeError;return T}}function Ao(_){var k=Dc(_,o);if(!Nn(k))throw new TypeError;var T=k.call(_);if(!te(T))throw new TypeError;return T}function So(_){return _.value}function dn(_){var k=_.next();return k.done?!1:k}function Bi(_){var k=_.return;k&&k.call(_)}function ds(_){var k=Object.getPrototypeOf(_);if(typeof _!="function"||_===x||k!==x)return k;var T=_.prototype,K=T&&Object.getPrototypeOf(T);if(K==null||K===Object.prototype)return k;var xe=K.constructor;return typeof xe!="function"||xe===_?k:xe}function _o(){var _;!he(A)&&typeof t.Reflect<"u"&&!(A in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=Io(t.Reflect));var k,T,K,xe=new v,_t={registerProvider:Et,getProvider:Z,setProvider:de};return _t;function Et(me){if(!Object.isExtensible(_t))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===me:break;case he(k):k=me;break;case k===me:break;case he(T):T=me;break;case T===me:break;default:K===void 0&&(K=new N),K.add(me);break}}function Re(me,Ye){if(!he(k)){if(k.isProviderFor(me,Ye))return k;if(!he(T)){if(T.isProviderFor(me,Ye))return k;if(!he(K))for(var tt=Ao(K);;){var wt=dn(tt);if(!wt)return;var Zt=So(wt);if(Zt.isProviderFor(me,Ye))return Bi(tt),Zt}}}if(!he(_)&&_.isProviderFor(me,Ye))return _}function Z(me,Ye){var tt=xe.get(me),wt;return he(tt)||(wt=tt.get(Ye)),he(wt)&&(wt=Re(me,Ye),he(wt)||(he(tt)&&(tt=new G,xe.set(me,tt)),tt.set(Ye,wt))),wt}function ne(me){if(he(me))throw new TypeError;return k===me||T===me||!he(K)&&K.has(me)}function de(me,Ye,tt){if(!ne(tt))throw new Error("Metadata provider not registered.");var wt=Z(me,Ye);if(wt!==tt){if(!he(wt))return!1;var Zt=xe.get(me);he(Zt)&&(Zt=new G,xe.set(me,Zt)),Zt.set(Ye,tt)}return!0}}function Eo(){var _;return!he(A)&&te(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[A]),he(_)&&(_=_o()),!he(A)&&te(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,A,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function ps(_){var k=new v,T={isProviderFor:function(ne,de){var me=k.get(ne);return he(me)?!1:me.has(de)},OrdinaryDefineOwnMetadata:Et,OrdinaryHasOwnMetadata:xe,OrdinaryGetOwnMetadata:_t,OrdinaryOwnMetadataKeys:Re,OrdinaryDeleteMetadata:Z};return O.registerProvider(T),T;function K(ne,de,me){var Ye=k.get(ne),tt=!1;if(he(Ye)){if(!me)return;Ye=new G,k.set(ne,Ye),tt=!0}var wt=Ye.get(de);if(he(wt)){if(!me)return;if(wt=new G,Ye.set(de,wt),!_.setProvider(ne,de,T))throw Ye.delete(de),tt&&k.delete(ne),new Error("Wrong provider for target.")}return wt}function xe(ne,de,me){var Ye=K(de,me,!1);return he(Ye)?!1:mo(Ye.has(ne))}function _t(ne,de,me){var Ye=K(de,me,!1);if(!he(Ye))return Ye.get(ne)}function Et(ne,de,me,Ye){var tt=K(me,Ye,!0);tt.set(ne,de)}function Re(ne,de){var me=[],Ye=K(ne,de,!1);if(he(Ye))return me;for(var tt=Ye.keys(),wt=Ao(tt),Zt=0;;){var ys=dn(wt);if(!ys)return me.length=Zt,me;var Oo=So(ys);try{me[Zt]=Oo}catch(Mc){try{Bi(wt)}finally{throw Mc}}Zt++}}function Z(ne,de,me){var Ye=K(de,me,!1);if(he(Ye)||!Ye.delete(ne))return!1;if(Ye.size===0){var tt=k.get(de);he(tt)||(tt.delete(me),tt.size===0&&k.delete(tt))}return!0}}function Io(_){var k=_.defineMetadata,T=_.hasOwnMetadata,K=_.getOwnMetadata,xe=_.getOwnMetadataKeys,_t=_.deleteMetadata,Et=new v,Re={isProviderFor:function(Z,ne){var de=Et.get(Z);return!he(de)&&de.has(ne)?!0:xe(Z,ne).length?(he(de)&&(de=new N,Et.set(Z,de)),de.add(ne),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:K,OrdinaryOwnMetadataKeys:xe,OrdinaryDeleteMetadata:_t};return Re}function pn(_,k,T){var K=O.getProvider(_,k);if(!he(K))return K;if(T){if(O.setProvider(_,k,I))return I;throw new Error("Illegal state.")}}function ko(){var _={},k=[],T=function(){function Re(Z,ne,de){this._index=0,this._keys=Z,this._values=ne,this._selector=de}return Re.prototype["@@iterator"]=function(){return this},Re.prototype[o]=function(){return this},Re.prototype.next=function(){var Z=this._index;if(Z>=0&&Z<this._keys.length){var ne=this._selector(this._keys[Z],this._values[Z]);return Z+1>=this._keys.length?(this._index=-1,this._keys=k,this._values=k):this._index++,{value:ne,done:!1}}return{value:void 0,done:!0}},Re.prototype.throw=function(Z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),Z},Re.prototype.return=function(Z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:Z,done:!0}},Re}(),K=function(){function Re(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Re.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Re.prototype.has=function(Z){return this._find(Z,!1)>=0},Re.prototype.get=function(Z){var ne=this._find(Z,!1);return ne>=0?this._values[ne]:void 0},Re.prototype.set=function(Z,ne){var de=this._find(Z,!0);return this._values[de]=ne,this},Re.prototype.delete=function(Z){var ne=this._find(Z,!1);if(ne>=0){for(var de=this._keys.length,me=ne+1;me<de;me++)this._keys[me-1]=this._keys[me],this._values[me-1]=this._values[me];return this._keys.length--,this._values.length--,xo(Z,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Re.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Re.prototype.keys=function(){return new T(this._keys,this._values,xe)},Re.prototype.values=function(){return new T(this._keys,this._values,_t)},Re.prototype.entries=function(){return new T(this._keys,this._values,Et)},Re.prototype["@@iterator"]=function(){return this.entries()},Re.prototype[o]=function(){return this.entries()},Re.prototype._find=function(Z,ne){if(!xo(this._cacheKey,Z)){this._cacheIndex=-1;for(var de=0;de<this._keys.length;de++)if(xo(this._keys[de],Z)){this._cacheIndex=de;break}}return this._cacheIndex<0&&ne&&(this._cacheIndex=this._keys.length,this._keys.push(Z),this._values.push(void 0)),this._cacheIndex},Re}();return K;function xe(Re,Z){return Re}function _t(Re,Z){return Z}function Et(Re,Z){return[Re,Z]}}function Co(){var _=function(){function k(){this._map=new G}return Object.defineProperty(k.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),k.prototype.has=function(T){return this._map.has(T)},k.prototype.add=function(T){return this._map.set(T,T),this},k.prototype.delete=function(T){return this._map.delete(T)},k.prototype.clear=function(){this._map.clear()},k.prototype.keys=function(){return this._map.keys()},k.prototype.values=function(){return this._map.keys()},k.prototype.entries=function(){return this._map.entries()},k.prototype["@@iterator"]=function(){return this.keys()},k.prototype[o]=function(){return this.keys()},k}();return _}function $c(){var _=16,k=m.create(),T=K();return function(){function Z(){this._key=K()}return Z.prototype.has=function(ne){var de=xe(ne,!1);return de!==void 0?m.has(de,this._key):!1},Z.prototype.get=function(ne){var de=xe(ne,!1);return de!==void 0?m.get(de,this._key):void 0},Z.prototype.set=function(ne,de){var me=xe(ne,!0);return me[this._key]=de,this},Z.prototype.delete=function(ne){var de=xe(ne,!1);return de!==void 0?delete de[this._key]:!1},Z.prototype.clear=function(){this._key=K()},Z}();function K(){var Z;do Z="@@WeakMap@@"+Re();while(m.has(k,Z));return k[Z]=!0,Z}function xe(Z,ne){if(!n.call(Z,T)){if(!ne)return;Object.defineProperty(Z,T,{value:m.create()})}return Z[T]}function _t(Z,ne){for(var de=0;de<ne;++de)Z[de]=Math.random()*255|0;return Z}function Et(Z){if(typeof Uint8Array=="function"){var ne=new Uint8Array(Z);return typeof crypto<"u"?crypto.getRandomValues(ne):typeof msCrypto<"u"?msCrypto.getRandomValues(ne):_t(ne,Z),ne}return _t(new Array(Z),Z)}function Re(){var Z=Et(_);Z[6]=Z[6]&79|64,Z[8]=Z[8]&191|128;for(var ne="",de=0;de<_;++de){var me=Z[de];(de===4||de===6||de===8)&&(ne+="-"),me<16&&(ne+="0"),ne+=me.toString(16).toLowerCase()}return ne}}function Bo(_){return _.__=void 0,delete _.__,_}})})(Rf||(Rf={}));/*!
14
+ ***************************************************************************** */var Rf;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof Fc=="object"?Fc:typeof self=="object"?self:typeof this=="object"?this:c(),n=i(r);typeof t.Reflect<"u"&&(n=i(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function i(u,h){return function(m,x){Object.defineProperty(u,m,{configurable:!0,writable:!0,value:x}),h&&h(m,x)}}function s(){try{return Function("return this;")()}catch{}}function o(){try{return(0,eval)("(function() { return this; })()")}catch{}}function c(){return s()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,i=typeof Symbol=="function",s=i&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",o=i&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",c=typeof Object.create=="function",u={__proto__:[]}instanceof Array,h=!c&&!u,m={create:c?function(){return Bo(Object.create(null))}:u?function(){return Bo({__proto__:null})}:function(){return Bo({})},has:h?function(_,k){return n.call(_,k)}:function(_,k){return k in _},get:h?function(_,k){return n.call(_,k)?_[k]:void 0}:function(_,k){return _[k]}},x=Object.getPrototypeOf(Function),G=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:ko(),N=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Co(),v=typeof WeakMap=="function"?WeakMap:$c(),A=i?Symbol.for("@reflect-metadata:registry"):void 0,O=Eo(),I=ps(O);function P(_,k,T,K){if(he(T)){if(!wo(_))throw new TypeError;if(!bo(k))throw new TypeError;return it(_,k)}else{if(!wo(_))throw new TypeError;if(!ee(k))throw new TypeError;if(!ee(K)&&!he(K)&&!ct(K))throw new TypeError;return ct(K)&&(K=void 0),T=pr(T),It(_,k,T,K)}}e("decorate",P);function R(_,k){function T(K,be){if(!ee(K))throw new TypeError;if(!he(be)&&!Sf(be))throw new TypeError;Ie(_,k,K,be)}return T}e("metadata",R);function fe(_,k,T,K){if(!ee(T))throw new TypeError;return he(K)||(K=pr(K)),Ie(_,k,T,K)}e("defineMetadata",fe);function qe(_,k,T){if(!ee(k))throw new TypeError;return he(T)||(T=pr(T)),Pt(_,k,T)}e("hasMetadata",qe);function Je(_,k,T){if(!ee(k))throw new TypeError;return he(T)||(T=pr(T)),gt(_,k,T)}e("hasOwnMetadata",Je);function Re(_,k,T){if(!ee(k))throw new TypeError;return he(T)||(T=pr(T)),Qe(_,k,T)}e("getMetadata",Re);function W(_,k,T){if(!ee(k))throw new TypeError;return he(T)||(T=pr(T)),ce(_,k,T)}e("getOwnMetadata",W);function se(_,k){if(!ee(_))throw new TypeError;return he(k)||(k=pr(k)),wt(_,k)}e("getMetadataKeys",se);function oe(_,k){if(!ee(_))throw new TypeError;return he(k)||(k=pr(k)),Vt(_,k)}e("getOwnMetadataKeys",oe);function Ae(_,k,T){if(!ee(k))throw new TypeError;if(he(T)||(T=pr(T)),!ee(k))throw new TypeError;he(T)||(T=pr(T));var K=pn(k,T,!1);return he(K)?!1:K.OrdinaryDeleteMetadata(_,k,T)}e("deleteMetadata",Ae);function it(_,k){for(var T=_.length-1;T>=0;--T){var K=_[T],be=K(k);if(!he(be)&&!ct(be)){if(!bo(be))throw new TypeError;k=be}}return k}function It(_,k,T,K){for(var be=_.length-1;be>=0;--be){var kt=_[be],Ct=kt(k,T,K);if(!he(Ct)&&!ct(Ct)){if(!ee(Ct))throw new TypeError;K=Ct}}return K}function Pt(_,k,T){var K=gt(_,k,T);if(K)return!0;var be=ds(k);return ct(be)?!1:Pt(_,be,T)}function gt(_,k,T){var K=pn(k,T,!1);return he(K)?!1:mo(K.OrdinaryHasOwnMetadata(_,k,T))}function Qe(_,k,T){var K=gt(_,k,T);if(K)return ce(_,k,T);var be=ds(k);if(!ct(be))return Qe(_,be,T)}function ce(_,k,T){var K=pn(k,T,!1);if(!he(K))return K.OrdinaryGetOwnMetadata(_,k,T)}function Ie(_,k,T,K){var be=pn(T,K,!0);be.OrdinaryDefineOwnMetadata(_,k,T,K)}function wt(_,k){var T=Vt(_,k),K=ds(_);if(K===null)return T;var be=wt(K,k);if(be.length<=0)return T;if(T.length<=0)return be;for(var kt=new N,Ct=[],Ue=0,Z=T;Ue<Z.length;Ue++){var te=Z[Ue],de=kt.has(te);de||(kt.add(te),Ct.push(te))}for(var ve=0,Xe=be;ve<Xe.length;ve++){var te=Xe[ve],de=kt.has(te);de||(kt.add(te),Ct.push(te))}return Ct}function Vt(_,k){var T=pn(_,k,!1);return T?T.OrdinaryOwnMetadataKeys(_,k):[]}function Lt(_){if(_===null)return 1;switch(typeof _){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return _===null?1:6;default:return 6}}function he(_){return _===void 0}function ct(_){return _===null}function bt(_){return typeof _=="symbol"}function ee(_){return typeof _=="object"?_!==null:typeof _=="function"}function mt(_,k){switch(Lt(_)){case 0:return _;case 1:return _;case 2:return _;case 3:return _;case 4:return _;case 5:return _}var T="string",K=Dc(_,s);if(K!==void 0){var be=K.call(_,T);if(ee(be))throw new TypeError;return be}return Ft(_)}function Ft(_,k){var T,K;{var be=_.toString;if(Nn(be)){var K=be.call(_);if(!ee(K))return K}var T=_.valueOf;if(Nn(T)){var K=T.call(_);if(!ee(K))return K}}throw new TypeError}function mo(_){return!!_}function hs(_){return""+_}function pr(_){var k=mt(_);return bt(k)?k:hs(k)}function wo(_){return Array.isArray?Array.isArray(_):_ instanceof Object?_ instanceof Array:Object.prototype.toString.call(_)==="[object Array]"}function Nn(_){return typeof _=="function"}function bo(_){return typeof _=="function"}function Sf(_){switch(Lt(_)){case 3:return!0;case 4:return!0;default:return!1}}function xo(_,k){return _===k||_!==_&&k!==k}function Dc(_,k){var T=_[k];if(T!=null){if(!Nn(T))throw new TypeError;return T}}function Ao(_){var k=Dc(_,o);if(!Nn(k))throw new TypeError;var T=k.call(_);if(!ee(T))throw new TypeError;return T}function So(_){return _.value}function dn(_){var k=_.next();return k.done?!1:k}function Bi(_){var k=_.return;k&&k.call(_)}function ds(_){var k=Object.getPrototypeOf(_);if(typeof _!="function"||_===x||k!==x)return k;var T=_.prototype,K=T&&Object.getPrototypeOf(T);if(K==null||K===Object.prototype)return k;var be=K.constructor;return typeof be!="function"||be===_?k:be}function _o(){var _;!he(A)&&typeof t.Reflect<"u"&&!(A in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(_=Io(t.Reflect));var k,T,K,be=new v,kt={registerProvider:Ct,getProvider:Z,setProvider:de};return kt;function Ct(ve){if(!Object.isExtensible(kt))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case _===ve:break;case he(k):k=ve;break;case k===ve:break;case he(T):T=ve;break;case T===ve:break;default:K===void 0&&(K=new N),K.add(ve);break}}function Ue(ve,Xe){if(!he(k)){if(k.isProviderFor(ve,Xe))return k;if(!he(T)){if(T.isProviderFor(ve,Xe))return k;if(!he(K))for(var st=Ao(K);;){var xt=dn(st);if(!xt)return;var Zt=So(xt);if(Zt.isProviderFor(ve,Xe))return Bi(st),Zt}}}if(!he(_)&&_.isProviderFor(ve,Xe))return _}function Z(ve,Xe){var st=be.get(ve),xt;return he(st)||(xt=st.get(Xe)),he(xt)&&(xt=Ue(ve,Xe),he(xt)||(he(st)&&(st=new G,be.set(ve,st)),st.set(Xe,xt))),xt}function te(ve){if(he(ve))throw new TypeError;return k===ve||T===ve||!he(K)&&K.has(ve)}function de(ve,Xe,st){if(!te(st))throw new Error("Metadata provider not registered.");var xt=Z(ve,Xe);if(xt!==st){if(!he(xt))return!1;var Zt=be.get(ve);he(Zt)&&(Zt=new G,be.set(ve,Zt)),Zt.set(Xe,st)}return!0}}function Eo(){var _;return!he(A)&&ee(t.Reflect)&&Object.isExtensible(t.Reflect)&&(_=t.Reflect[A]),he(_)&&(_=_o()),!he(A)&&ee(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,A,{enumerable:!1,configurable:!1,writable:!1,value:_}),_}function ps(_){var k=new v,T={isProviderFor:function(te,de){var ve=k.get(te);return he(ve)?!1:ve.has(de)},OrdinaryDefineOwnMetadata:Ct,OrdinaryHasOwnMetadata:be,OrdinaryGetOwnMetadata:kt,OrdinaryOwnMetadataKeys:Ue,OrdinaryDeleteMetadata:Z};return O.registerProvider(T),T;function K(te,de,ve){var Xe=k.get(te),st=!1;if(he(Xe)){if(!ve)return;Xe=new G,k.set(te,Xe),st=!0}var xt=Xe.get(de);if(he(xt)){if(!ve)return;if(xt=new G,Xe.set(de,xt),!_.setProvider(te,de,T))throw Xe.delete(de),st&&k.delete(te),new Error("Wrong provider for target.")}return xt}function be(te,de,ve){var Xe=K(de,ve,!1);return he(Xe)?!1:mo(Xe.has(te))}function kt(te,de,ve){var Xe=K(de,ve,!1);if(!he(Xe))return Xe.get(te)}function Ct(te,de,ve,Xe){var st=K(ve,Xe,!0);st.set(te,de)}function Ue(te,de){var ve=[],Xe=K(te,de,!1);if(he(Xe))return ve;for(var st=Xe.keys(),xt=Ao(st),Zt=0;;){var ys=dn(xt);if(!ys)return ve.length=Zt,ve;var Oo=So(ys);try{ve[Zt]=Oo}catch(Mc){try{Bi(xt)}finally{throw Mc}}Zt++}}function Z(te,de,ve){var Xe=K(de,ve,!1);if(he(Xe)||!Xe.delete(te))return!1;if(Xe.size===0){var st=k.get(de);he(st)||(st.delete(ve),st.size===0&&k.delete(st))}return!0}}function Io(_){var k=_.defineMetadata,T=_.hasOwnMetadata,K=_.getOwnMetadata,be=_.getOwnMetadataKeys,kt=_.deleteMetadata,Ct=new v,Ue={isProviderFor:function(Z,te){var de=Ct.get(Z);return!he(de)&&de.has(te)?!0:be(Z,te).length?(he(de)&&(de=new N,Ct.set(Z,de)),de.add(te),!0):!1},OrdinaryDefineOwnMetadata:k,OrdinaryHasOwnMetadata:T,OrdinaryGetOwnMetadata:K,OrdinaryOwnMetadataKeys:be,OrdinaryDeleteMetadata:kt};return Ue}function pn(_,k,T){var K=O.getProvider(_,k);if(!he(K))return K;if(T){if(O.setProvider(_,k,I))return I;throw new Error("Illegal state.")}}function ko(){var _={},k=[],T=function(){function Ue(Z,te,de){this._index=0,this._keys=Z,this._values=te,this._selector=de}return Ue.prototype["@@iterator"]=function(){return this},Ue.prototype[o]=function(){return this},Ue.prototype.next=function(){var Z=this._index;if(Z>=0&&Z<this._keys.length){var te=this._selector(this._keys[Z],this._values[Z]);return Z+1>=this._keys.length?(this._index=-1,this._keys=k,this._values=k):this._index++,{value:te,done:!1}}return{value:void 0,done:!0}},Ue.prototype.throw=function(Z){throw this._index>=0&&(this._index=-1,this._keys=k,this._values=k),Z},Ue.prototype.return=function(Z){return this._index>=0&&(this._index=-1,this._keys=k,this._values=k),{value:Z,done:!0}},Ue}(),K=function(){function Ue(){this._keys=[],this._values=[],this._cacheKey=_,this._cacheIndex=-2}return Object.defineProperty(Ue.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Ue.prototype.has=function(Z){return this._find(Z,!1)>=0},Ue.prototype.get=function(Z){var te=this._find(Z,!1);return te>=0?this._values[te]:void 0},Ue.prototype.set=function(Z,te){var de=this._find(Z,!0);return this._values[de]=te,this},Ue.prototype.delete=function(Z){var te=this._find(Z,!1);if(te>=0){for(var de=this._keys.length,ve=te+1;ve<de;ve++)this._keys[ve-1]=this._keys[ve],this._values[ve-1]=this._values[ve];return this._keys.length--,this._values.length--,xo(Z,this._cacheKey)&&(this._cacheKey=_,this._cacheIndex=-2),!0}return!1},Ue.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=_,this._cacheIndex=-2},Ue.prototype.keys=function(){return new T(this._keys,this._values,be)},Ue.prototype.values=function(){return new T(this._keys,this._values,kt)},Ue.prototype.entries=function(){return new T(this._keys,this._values,Ct)},Ue.prototype["@@iterator"]=function(){return this.entries()},Ue.prototype[o]=function(){return this.entries()},Ue.prototype._find=function(Z,te){if(!xo(this._cacheKey,Z)){this._cacheIndex=-1;for(var de=0;de<this._keys.length;de++)if(xo(this._keys[de],Z)){this._cacheIndex=de;break}}return this._cacheIndex<0&&te&&(this._cacheIndex=this._keys.length,this._keys.push(Z),this._values.push(void 0)),this._cacheIndex},Ue}();return K;function be(Ue,Z){return Ue}function kt(Ue,Z){return Z}function Ct(Ue,Z){return[Ue,Z]}}function Co(){var _=function(){function k(){this._map=new G}return Object.defineProperty(k.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),k.prototype.has=function(T){return this._map.has(T)},k.prototype.add=function(T){return this._map.set(T,T),this},k.prototype.delete=function(T){return this._map.delete(T)},k.prototype.clear=function(){this._map.clear()},k.prototype.keys=function(){return this._map.keys()},k.prototype.values=function(){return this._map.keys()},k.prototype.entries=function(){return this._map.entries()},k.prototype["@@iterator"]=function(){return this.keys()},k.prototype[o]=function(){return this.keys()},k}();return _}function $c(){var _=16,k=m.create(),T=K();return function(){function Z(){this._key=K()}return Z.prototype.has=function(te){var de=be(te,!1);return de!==void 0?m.has(de,this._key):!1},Z.prototype.get=function(te){var de=be(te,!1);return de!==void 0?m.get(de,this._key):void 0},Z.prototype.set=function(te,de){var ve=be(te,!0);return ve[this._key]=de,this},Z.prototype.delete=function(te){var de=be(te,!1);return de!==void 0?delete de[this._key]:!1},Z.prototype.clear=function(){this._key=K()},Z}();function K(){var Z;do Z="@@WeakMap@@"+Ue();while(m.has(k,Z));return k[Z]=!0,Z}function be(Z,te){if(!n.call(Z,T)){if(!te)return;Object.defineProperty(Z,T,{value:m.create()})}return Z[T]}function kt(Z,te){for(var de=0;de<te;++de)Z[de]=Math.random()*255|0;return Z}function Ct(Z){if(typeof Uint8Array=="function"){var te=new Uint8Array(Z);return typeof crypto<"u"?crypto.getRandomValues(te):typeof msCrypto<"u"?msCrypto.getRandomValues(te):kt(te,Z),te}return kt(new Array(Z),Z)}function Ue(){var Z=Ct(_);Z[6]=Z[6]&79|64,Z[8]=Z[8]&191|128;for(var te="",de=0;de<_;++de){var ve=Z[de];(de===4||de===6||de===8)&&(te+="-"),ve<16&&(te+="0"),te+=ve.toString(16).toLowerCase()}return te}}function Bo(_){return _.__=void 0,delete _.__,_}})})(Rf||(Rf={}));/*!
15
15
  * MIT License
16
16
  *
17
17
  * Copyright (c) 2017-2022 Peculiar Ventures, LLC
@@ -34,9 +34,9 @@
34
34
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
35
  * SOFTWARE.
36
36
  *
37
- */const Fy="[object ArrayBuffer]";class W{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Fy}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=W.toUint8Array(e),i=W.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const o of t)n+=o.byteLength;const i=new Uint8Array(n);let s=0;for(const o of t){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const zc="string",zy=/^[0-9a-f]+$/i,Gy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ky=/^[a-zA-Z0-9-_]+$/;class Uf{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=W.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Jr{static toString(e,t=!1){const n=W.toArrayBuffer(e),i=new DataView(n);let s="";for(let o=0;o<n.byteLength;o+=2){const c=i.getUint16(o,t);s+=String.fromCharCode(c)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class fe{static isHex(e){return typeof e===zc&&zy.test(e)}static isBase64(e){return typeof e===zc&&Gy.test(e)}static isBase64Url(e){return typeof e===zc&&Ky.test(e)}static ToString(e,t="utf8"){const n=W.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Jr.toString(n,!0);case"utf16":case"utf16be":return Jr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Jr.fromString(e,!0);case"utf16":case"utf16be":return Jr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=W.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!fe.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){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!fe.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=fe.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Uf.fromString(e);case"utf16":case"utf16be":return Jr.fromString(e);case"utf16le":case"usc2":return Jr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=fe.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Uf.toString(e);case"utf16":case"utf16be":return Jr.toString(e);case"utf16le":case"usc2":return Jr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=W.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=W.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const o=t[s];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!fe.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return Jr.toString(e,t)}static FromUtf16String(e,t=!1){return Jr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}fe.DEFAULT_UTF8_ENCODING="utf8";function qy(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function No(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
37
+ */const Fy="[object ArrayBuffer]";class Y{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Fy}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){const n=Y.toUint8Array(e),i=Y.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==i[s])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(const o of t)n+=o.byteLength;const i=new Uint8Array(n);let s=0;for(const o of t){const c=this.toUint8Array(o);i.set(c,s),s+=c.length}return e[e.length-1]instanceof Function?this.toView(i,e[e.length-1]):i.buffer}}const zc="string",zy=/^[0-9a-f]+$/i,Gy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Ky=/^[a-zA-Z0-9-_]+$/;class Uf{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n.buffer}static toString(e){const t=Y.toUint8Array(e);let n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}}class Jr{static toString(e,t=!1){const n=Y.toArrayBuffer(e),i=new DataView(n);let s="";for(let o=0;o<n.byteLength;o+=2){const c=i.getUint16(o,t);s+=String.fromCharCode(c)}return s}static fromString(e,t=!1){const n=new ArrayBuffer(e.length*2),i=new DataView(n);for(let s=0;s<e.length;s++)i.setUint16(s*2,e.charCodeAt(s),t);return n}}class ue{static isHex(e){return typeof e===zc&&zy.test(e)}static isBase64(e){return typeof e===zc&&Gy.test(e)}static isBase64Url(e){return typeof e===zc&&Ky.test(e)}static ToString(e,t="utf8"){const n=Y.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Jr.toString(n,!0);case"utf16":case"utf16be":return Jr.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Jr.fromString(e,!0);case"utf16":case"utf16be":return Jr.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=Y.toUint8Array(e);if(typeof btoa<"u"){const n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ue.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){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ue.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=ue.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Uf.fromString(e);case"utf16":case"utf16be":return Jr.fromString(e);case"utf16le":case"usc2":return Jr.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=ue.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Uf.toString(e);case"utf16":case"utf16be":return Jr.toString(e);case"utf16le":case"usc2":return Jr.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n.buffer}static ToBinary(e){const t=Y.toUint8Array(e);let n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return n}static ToHex(e){const t=Y.toUint8Array(e);let n="";const i=t.length;for(let s=0;s<i;s++){const o=t[s];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!ue.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i=i+2){const s=t.slice(i,i+2);n[i/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return Jr.toString(e,t)}static FromUtf16String(e,t=!1){return Jr.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(e==null?void 0:e.replace(/[\n\r\t ]/g,""))||""}}ue.DEFAULT_UTF8_ENCODING="utf8";function qy(...r){const e=r.map(i=>i.byteLength).reduce((i,s)=>i+s),t=new Uint8Array(e);let n=0;return r.map(i=>new Uint8Array(i)).forEach(i=>{for(const s of i)t[n++]=s}),t.buffer}function No(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}/*!
38
38
  Copyright (c) Peculiar Ventures, LLC
39
- */function ji(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ri(r,e,t=-1){const n=t;let i=r,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(r<o){let u;if(n<0)u=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);u=new ArrayBuffer(n),s=n}const h=new Uint8Array(u);for(let m=c-1;m>=0;m--){const x=Math.pow(2,m*e);h[s-m-1]=Math.floor(i/x),i-=h[s-m-1]*x}return u}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Gc(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Df(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,u=r[0]===0&&(r[1]&128)===0;(c||u)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const n=ji(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,ji(s,8)-n}function Zy(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const o=t-e,c=ri(o,8,n),u=new Uint8Array(c);return u[0]|=128,c}let i=ri(e,8,n),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let u=0;u<o.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Wy(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function _r(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}/*!
39
+ */function Pi(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function ri(r,e,t=-1){const n=t;let i=r,s=0,o=Math.pow(2,e);for(let c=1;c<8;c++){if(r<o){let u;if(n<0)u=new ArrayBuffer(c),s=c;else{if(n<c)return new ArrayBuffer(0);u=new ArrayBuffer(n),s=n}const h=new Uint8Array(u);for(let m=c-1;m>=0;m--){const x=Math.pow(2,m*e);h[s-m-1]=Math.floor(i/x),i-=h[s-m-1]*x}return u}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function Gc(...r){let e=0,t=0;for(const s of r)e+=s.length;const n=new ArrayBuffer(e),i=new Uint8Array(n);for(const s of r)i.set(s,t),t+=s.length;return i}function Df(){const r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const c=r[0]===255&&r[1]&128,u=r[0]===0&&(r[1]&128)===0;(c||u)&&this.warnings.push("Needlessly long format")}const e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let c=0;c<this.valueHex.byteLength;c++)t[c]=0;t[0]=r[0]&128;const n=Pi(t,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let c=0;c<this.valueHex.byteLength;c++)s[c]=r[c];return s[0]&=127,Pi(s,8)-n}function Zy(r){const e=r<0?r*-1:r;let t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){const o=t-e,c=ri(o,8,n),u=new Uint8Array(c);return u[0]|=128,c}let i=ri(e,8,n),s=new Uint8Array(i);if(s[0]&128){const o=i.slice(0),c=new Uint8Array(o);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let u=0;u<o.byteLength;u++)s[u+1]=c[u];s[0]=0}return i}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Wy(r,e){if(r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<t.length;i++)if(t[i]!==n[i])return!1;return!0}function _r(r,e){const t=r.toString(10);if(e<t.length)return"";const n=e-t.length,i=new Array(n);for(let o=0;o<n;o++)i[o]="0";return i.join("").concat(t)}/*!
40
40
  * Copyright (c) 2014, GMO GlobalSign
41
41
  * Copyright (c) 2015-2022, Peculiar Ventures
42
42
  * All rights reserved.
@@ -68,11 +68,11 @@
68
68
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
69
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
70
  *
71
- */function jo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Kc(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function vn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class Po{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Kc(this.items)}}const vs=[new Uint8Array([1])],$f="0123456789",qc="name",Mf="valueHexView",Yy="isHexOnly",Jy="idBlock",Xy="tagClass",Qy="tagNumber",eg="isConstructed",tg="fromBER",rg="toBER",ng="local",gr="",Mr=new ArrayBuffer(0),Ro=new Uint8Array(0),ms="EndOfContent",Vf="OCTET STRING",Lf="BIT STRING";function Xr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?W.toUint8Array(s.valueHex):Ro}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!vn(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Mr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:fe.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class ni{constructor({blockLength:e=0,error:t=gr,warnings:n=[],valueBeforeDecode:i=Ro}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=W.toUint8Array(i)}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:fe.ToHex(this.valueBeforeDecodeView)}}}ni.NAME="baseBlock";class lr extends ni{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}lr.NAME="valueBlock";class Hf extends Xr(ni){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?W.toUint8Array(e.valueHex):Ro,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",Mr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ri(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=t|31,!e){for(let u=0;u<o-1;u++)c[u+1]=s[u]|128;c[o]=s[o-1]}return c.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=W.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let u=1,h=this.valueHexView=new Uint8Array(255),m=255;for(;s[u]&128;){if(h[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u===m){m+=255;const G=new Uint8Array(m);for(let N=0;N<h.length;N++)G[N]=h[N];h=this.valueHexView=new Uint8Array(m)}}this.blockLength=u+1,h[u-1]=s[u]&127;const x=new Uint8Array(u);for(let G=0;G<u;G++)x[G]=h[G];h=this.valueHexView=new Uint8Array(u),h.set(x),this.blockLength<=9?this.tagNumber=ji(h,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}}}Hf.NAME="identificationBlock";class Ff extends ni{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=W.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=s[0]&127;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 c=t+1,u=i.subarray(c,c+o);return u[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ji(u,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,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ri(this.length,8);if(i.byteLength>127)return this.error="Too big length",Mr;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Ff.NAME="lengthBlock";const ae={};class Wt extends ni{constructor({name:e=gr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Hf(i),this.lenBlock=new Ff(i),this.valueBlock=s?new s(i):new lr(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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 n=t||new Po;t||zf(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?Mr:n.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 e==="ascii"?this.onAsciiEncoding():fe.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${fe.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return Wy(t,n)}}Wt.NAME="BaseBlock";function zf(r){if(r instanceof ae.Constructed)for(const e of r.valueBlock.value)zf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Zc extends Wt{constructor({value:e=gr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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}'`}}Zc.NAME="BaseStringBlock";class Gf extends Xr(lr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Gf.NAME="PrimitiveValueBlock";var Kf;class ws extends Wt{constructor(e={}){super(e,Gf),this.idBlock.isConstructed=!1}}Kf=ws,ae.Primitive=Kf,ws.NAME="PRIMITIVE";function ig(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Pi(r,e=0,t=r.length){const n=e;let i=new Wt({},lr);const s=new ni;if(!vn(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,t-=i.idBlock.blockLength,c=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let u=Wt;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};u=ae.EndOfContent;break;case 1:u=ae.Boolean;break;case 2:u=ae.Integer;break;case 3:u=ae.BitString;break;case 4:u=ae.OctetString;break;case 5:u=ae.Null;break;case 6:u=ae.ObjectIdentifier;break;case 10:u=ae.Enumerated;break;case 12:u=ae.Utf8String;break;case 13:u=ae.RelativeObjectIdentifier;break;case 14:u=ae.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:u=ae.Sequence;break;case 17:u=ae.Set;break;case 18:u=ae.NumericString;break;case 19:u=ae.PrintableString;break;case 20:u=ae.TeletexString;break;case 21:u=ae.VideotexString;break;case 22:u=ae.IA5String;break;case 23:u=ae.UTCTime;break;case 24:u=ae.GeneralizedTime;break;case 25:u=ae.GraphicString;break;case 26:u=ae.VisibleString;break;case 27:u=ae.GeneralString;break;case 28:u=ae.UniversalString;break;case 29:u=ae.CharacterString;break;case 30:u=ae.BmpString;break;case 31:u=ae.DATE;break;case 32:u=ae.TimeOfDay;break;case 33:u=ae.DateTime;break;case 34:u=ae.Duration;break;default:{const h=i.idBlock.isConstructed?new ae.Constructed:new ae.Primitive;h.idBlock=i.idBlock,h.lenBlock=i.lenBlock,h.warnings=i.warnings,i=h}}break;case 2:case 3:case 4:default:u=i.idBlock.isConstructed?ae.Constructed:ae.Primitive}return i=ig(i,u),c=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:c,result:i}}function Ri(r){if(!r.byteLength){const e=new Wt({},lr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Pi(W.toUint8Array(r).slice(),0,r.byteLength)}function sg(r,e){return r?1:e}class jn extends lr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=W.toUint8Array(e);if(!vn(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;sg(this.isIndefiniteForm,n)>0;){const o=Pi(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===ms)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ms?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new Po;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?Mr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}jn.NAME="ConstructedValueBlock";var qf;class vr extends Wt{constructor(e={}){super(e,jn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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 n of this.valueBlock.value)e.push(n.toString("ascii").split(`
71
+ */function Po(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Kc(r){let e=0,t=0;for(let i=0;i<r.length;i++){const s=r[i];e+=s.byteLength}const n=new Uint8Array(e);for(let i=0;i<r.length;i++){const s=r[i];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function vn(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class jo{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Kc(this.items)}}const vs=[new Uint8Array([1])],$f="0123456789",qc="name",Mf="valueHexView",Yy="isHexOnly",Jy="idBlock",Xy="tagClass",Qy="tagNumber",eg="isConstructed",tg="fromBER",rg="toBER",ng="local",gr="",Mr=new ArrayBuffer(0),Ro=new Uint8Array(0),ms="EndOfContent",Vf="OCTET STRING",Lf="BIT STRING";function Xr(r){var e;return e=class extends r{constructor(...n){var i;super(...n);const s=n[0]||{};this.isHexOnly=(i=s.isHexOnly)!==null&&i!==void 0?i:!1,this.valueHexView=s.valueHex?Y.toUint8Array(s.valueHex):Ro}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,i,s){const o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!vn(this,o,i,s))return-1;const c=i+s;return this.valueHexView=o.subarray(i,c),this.valueHexView.length?(this.blockLength=s,c):(this.warnings.push("Zero buffer length"),i)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Mr)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:ue.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}class ni{constructor({blockLength:e=0,error:t=gr,warnings:n=[],valueBeforeDecode:i=Ro}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Y.toUint8Array(i)}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:ue.ToHex(this.valueBeforeDecodeView)}}}ni.NAME="baseBlock";class lr extends ni{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}lr.NAME="valueBlock";class Hf extends Xr(ni){constructor({idBlock:e={}}={}){var t,n,i,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Y.toUint8Array(e.valueHex):Ro,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(i=e.tagNumber)!==null&&i!==void 0?i:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",Mr}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const i=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,i[0]=t}return i.buffer}if(!this.isHexOnly){const i=ri(this.tagNumber,7),s=new Uint8Array(i),o=i.byteLength,c=new Uint8Array(o+1);if(c[0]=t|31,!e){for(let u=0;u<o-1;u++)c[u+1]=s[u]|128;c[o]=s[o-1]}return c.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){const i=this.valueHexView;for(let s=0;s<i.length-1;s++)n[s+1]=i[s]|128;n[this.valueHexView.byteLength]=i[i.length-1]}return n.buffer}fromBER(e,t,n){const i=Y.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;const c=s[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let u=1,h=this.valueHexView=new Uint8Array(255),m=255;for(;s[u]&128;){if(h[u-1]=s[u]&127,u++,u>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(u===m){m+=255;const G=new Uint8Array(m);for(let N=0;N<h.length;N++)G[N]=h[N];h=this.valueHexView=new Uint8Array(m)}}this.blockLength=u+1,h[u-1]=s[u]&127;const x=new Uint8Array(u);for(let G=0;G<u;G++)x[G]=h[G];h=this.valueHexView=new Uint8Array(u),h.set(x),this.blockLength<=9?this.tagNumber=Pi(h,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}}}Hf.NAME="identificationBlock";class Ff extends ni{constructor({lenBlock:e={}}={}){var t,n,i;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(i=e.length)!==null&&i!==void 0?i:0}fromBER(e,t,n){const i=Y.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;const o=s[0]&127;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 c=t+1,u=i.subarray(c,c+o);return u[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Pi(u,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,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){const i=ri(this.length,8);if(i.byteLength>127)return this.error="Too big length",Mr;if(t=new ArrayBuffer(i.byteLength+1),e)return t;const s=new Uint8Array(i);n=new Uint8Array(t),n[0]=i.byteLength|128;for(let o=0;o<i.byteLength;o++)n[o+1]=s[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Ff.NAME="lengthBlock";const ae={};class Wt extends ni{constructor({name:e=gr,optional:t=!1,primitiveSchema:n,...i}={},s){super(i),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Hf(i),this.lenBlock=new Ff(i),this.valueBlock=s?new s(i):new lr(i)}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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 n=t||new jo;t||zf(this);const i=this.idBlock.toBER(e);if(n.write(i),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;const o=this.lenBlock.toBER(e);n.write(o),n.write(s)}return t?Mr:n.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 e==="ascii"?this.onAsciiEncoding():ue.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${ue.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;const t=this.toBER(),n=e.toBER();return Wy(t,n)}}Wt.NAME="BaseBlock";function zf(r){if(r instanceof ae.Constructed)for(const e of r.valueBlock.value)zf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}class Zc extends Wt{constructor({value:e=gr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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}'`}}Zc.NAME="BaseStringBlock";class Gf extends Xr(lr){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}Gf.NAME="PrimitiveValueBlock";var Kf;class ws extends Wt{constructor(e={}){super(e,Gf),this.idBlock.isConstructed=!1}}Kf=ws,ae.Primitive=Kf,ws.NAME="PRIMITIVE";function ig(r,e){if(r instanceof e)return r;const t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function ji(r,e=0,t=r.length){const n=e;let i=new Wt({},lr);const s=new ni;if(!vn(s,r,e,t))return i.error=s.error,{offset:-1,result:i};if(!r.subarray(e,e+t).length)return i.error="Zero buffer length",{offset:-1,result:i};let c=i.idBlock.fromBER(r,e,t);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),c===-1)return i.error=i.idBlock.error,{offset:-1,result:i};if(e=c,t-=i.idBlock.blockLength,c=i.lenBlock.fromBER(r,e,t),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),c===-1)return i.error=i.lenBlock.error,{offset:-1,result:i};if(e=c,t-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let u=Wt;switch(i.idBlock.tagClass){case 1:if(i.idBlock.tagNumber>=37&&i.idBlock.isHexOnly===!1)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};u=ae.EndOfContent;break;case 1:u=ae.Boolean;break;case 2:u=ae.Integer;break;case 3:u=ae.BitString;break;case 4:u=ae.OctetString;break;case 5:u=ae.Null;break;case 6:u=ae.ObjectIdentifier;break;case 10:u=ae.Enumerated;break;case 12:u=ae.Utf8String;break;case 13:u=ae.RelativeObjectIdentifier;break;case 14:u=ae.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:u=ae.Sequence;break;case 17:u=ae.Set;break;case 18:u=ae.NumericString;break;case 19:u=ae.PrintableString;break;case 20:u=ae.TeletexString;break;case 21:u=ae.VideotexString;break;case 22:u=ae.IA5String;break;case 23:u=ae.UTCTime;break;case 24:u=ae.GeneralizedTime;break;case 25:u=ae.GraphicString;break;case 26:u=ae.VisibleString;break;case 27:u=ae.GeneralString;break;case 28:u=ae.UniversalString;break;case 29:u=ae.CharacterString;break;case 30:u=ae.BmpString;break;case 31:u=ae.DATE;break;case 32:u=ae.TimeOfDay;break;case 33:u=ae.DateTime;break;case 34:u=ae.Duration;break;default:{const h=i.idBlock.isConstructed?new ae.Constructed:new ae.Primitive;h.idBlock=i.idBlock,h.lenBlock=i.lenBlock,h.warnings=i.warnings,i=h}}break;case 2:case 3:case 4:default:u=i.idBlock.isConstructed?ae.Constructed:ae.Primitive}return i=ig(i,u),c=i.fromBER(r,e,i.lenBlock.isIndefiniteForm?t:i.lenBlock.length),i.valueBeforeDecodeView=r.subarray(n,n+i.blockLength),{offset:c,result:i}}function Ri(r){if(!r.byteLength){const e=new Wt({},lr);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ji(Y.toUint8Array(r).slice(),0,r.byteLength)}function sg(r,e){return r?1:e}class Pn extends lr{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const i=Y.toUint8Array(e);if(!vn(this,i,t,n))return-1;if(this.valueBeforeDecodeView=i.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;sg(this.isIndefiniteForm,n)>0;){const o=ji(i,s,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(s=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===ms)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ms?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const n=t||new jo;for(let i=0;i<this.value.length;i++)this.value[i].toBER(e,n);return t?Mr:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Pn.NAME="ConstructedValueBlock";var qf;class vr extends Wt{constructor(e={}){super(e,Pn),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return i===-1?(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 n of this.valueBlock.value)e.push(n.toString("ascii").split(`
72
72
  `).map(i=>` ${i}`).join(`
73
73
  `));const t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
74
74
  ${e.join(`
75
- `)}`:`${t} :`}}qf=vr,ae.Constructed=qf,vr.NAME="CONSTRUCTED";class Zf extends lr{fromBER(e,t,n){return t}toBER(e){return Mr}}Zf.override="EndOfContentValueBlock";var Wf;class Wc extends Wt{constructor(e={}){super(e,Zf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Wf=Wc,ae.EndOfContent=Wf,Wc.NAME=ms;var Yf;class ii extends Wt{constructor(e={}){super(e,lr),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Yf=ii,ae.Null=Yf,ii.NAME="NULL";class Jf extends Xr(lr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=W.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=W.toUint8Array(e);return vn(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Df.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Jf.NAME="BooleanValueBlock";var Xf;let Uo=class extends Wt{constructor(e={}){super(e,Jf),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}`}};Xf=Uo,ae.Boolean=Xf,Uo.NAME="BOOLEAN";class Qf extends Xr(jn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=jn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===ms){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Vf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?jn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Qf.NAME="OctetStringValueBlock";var eh;let si=class _y extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Qf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const o=Pi(s,0,s.byteLength);o.offset!==-1&&o.offset===n&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?vr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${fe.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 _y&&e.push(t.valueBlock.valueHexView);return W.concat(e)}};eh=si,ae.OctetString=eh,si.NAME=Vf;class th extends Xr(jn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=jn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const c of this.value){const u=c.constructor.NAME;if(u===ms){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(u!==Lf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const h=c.valueBlock;if(this.unusedBits>0&&h.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=h.unusedBits}return i}const s=W.toUint8Array(e);if(!vn(this,s,t,n))return-1;const o=s.subarray(t,t+n);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 c=o.subarray(1);try{if(c.byteLength){const u=Pi(c,0,c.byteLength);u.offset!==-1&&u.offset===n-1&&(this.value=[u.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+n}toBER(e,t){if(this.isConstructed)return jn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Mr;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}th.NAME="BitStringValueBlock";var rh;let oi=class extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},th),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return vr.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};rh=oi,ae.BitString=rh,oi.NAME=Lf;var nh;function og(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const o=s.length-1,c=i.slice(0),u=c.length-1;let h=0;const m=u<o?o:u;let x=0;for(let G=m;G>=0;G--,x++){switch(!0){case x<c.length:h=s[o-x]+c[u-x]+t[0];break;default:h=s[o-x]+t[0]}switch(t[0]=h/10,!0){case x>=s.length:s=Gc(new Uint8Array([h%10]),s);break;default:s[o-x]=h%10}}return t[0]>0&&(s=Gc(t,s)),s}function ih(r){if(r>=vs.length)for(let e=vs.length;e<=r;e++){const t=new Uint8Array([0]);let n=vs[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Gc(t,n)),vs.push(n)}return vs[r]}function ag(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),o=s.length-1,c=i.slice(0),u=c.length-1;let h,m=0;for(let x=u;x>=0;x--,m++)switch(h=s[o-m]-c[u-m]-t,!0){case h<0:t=1,s[o-m]=h+10;break;default:t=0,s[o-m]=h}if(t>0)for(let x=o-u+1;x>=0;x--,m++)if(h=s[o-m]-t,h<0)t=1,s[o-m]=h+10;else{t=0,s[o-m]=h;break}return s.slice()}class Yc extends Xr(lr){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=Df.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Zy(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||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=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let o="",c=!1;for(let u=s.byteLength-1;u>=0;u--){i=s[u];for(let h=0;h<8;h++){if((i&1)===1)switch(n){case e:t=ag(ih(n),t),o="-";break;default:t=og(t,ih(n))}n++,i>>=1}}for(let u=0;u<t.length;u++)t[u]&&(c=!0),c&&(o+=$f.charAt(t[u]));return c===!1&&(o+=$f.charAt(0)),o}}nh=Yc,Yc.NAME="IntegerValueBlock",Object.defineProperty(nh.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var sh;class Qr extends Wt{constructor(e={}){super(e,Yc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return jo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){jo();const t=BigInt(e),n=new Po,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(fe.FromHex(i));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const h=BigInt(`0x${fe.ToHex(c)}`)+t,m=W.toUint8Array(fe.FromHex(h.toString(16)));m[0]|=128,n.write(m)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Qr({valueHex:n.final()})}convertToDER(){const e=new Qr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Qr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}sh=Qr,ae.Integer=sh,Qr.NAME="INTEGER";var oh;class Do extends Qr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}oh=Do,ae.Enumerated=oh,Do.NAME="ENUMERATED";class Jc extends Xr(lr){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=W.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=ji(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){jo();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ri(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Mr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=fe.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}}}Jc.NAME="sidBlock";class ah extends lr{constructor({value:e=gr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Jc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,Mr;t.push(i)}return Kc(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const u=parseInt(i,10);if(isNaN(u))return;o.valueDec=u+c,s=!1}else{const o=new Jc;if(i>Number.MAX_SAFE_INTEGER){jo();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].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}}ah.NAME="ObjectIdentifierValueBlock";var ch;class $o extends Wt{constructor(e={}){super(e,ah),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ch=$o,ae.ObjectIdentifier=ch,$o.NAME="OBJECT IDENTIFIER";class Xc extends Xr(ni){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=W.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=ji(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 i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ri(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Mr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=fe.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Xc.NAME="relativeSidBlock";class lh extends lr{constructor({value:e=gr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Xc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,Mr;n.push(s)}return Kc(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Xc;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${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}}lh.NAME="RelativeObjectIdentifierValueBlock";var uh;class Qc extends Wt{constructor(e={}){super(e,lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}uh=Qc,ae.RelativeObjectIdentifier=uh,Qc.NAME="RelativeObjectIdentifier";var fh;class mn extends vr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}fh=mn,ae.Sequence=fh,mn.NAME="SEQUENCE";var hh;let wn=class extends vr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};hh=wn,ae.Set=hh,wn.NAME="SET";class dh extends Xr(lr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=gr}toJSON(){return{...super.toJSON(),value:this.value}}}dh.NAME="StringValueBlock";class ph extends dh{}ph.NAME="SimpleStringValueBlock";class Er extends Zc{constructor({...e}={}){super(e,ph)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,W.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Er.NAME="SIMPLE STRING";class yh extends Er{fromBuffer(e){this.valueBlock.valueHexView=W.toUint8Array(e);try{this.valueBlock.value=fe.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=fe.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(fe.FromUtf8String(e)),this.valueBlock.value=e}}yh.NAME="Utf8StringValueBlock";var gh;class bn extends yh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}gh=bn,ae.Utf8String=gh,bn.NAME="UTF8String";class vh extends Er{fromBuffer(e){this.valueBlock.value=fe.ToUtf16String(e),this.valueBlock.valueHexView=W.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(fe.FromUtf16String(e))}}vh.NAME="BmpStringValueBlock";var mh;class Mo extends vh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}mh=Mo,ae.BmpString=mh,Mo.NAME="BMPString";class wh extends Er{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ri(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let u=o.length-1;u>=0;u--)n[i*4+u+c]=o[u]}this.valueBlock.value=e}}wh.NAME="UniversalStringValueBlock";var bh;class Vo extends wh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}bh=Vo,ae.UniversalString=bh,Vo.NAME="UniversalString";var xh;class Lo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}xh=Lo,ae.NumericString=xh,Lo.NAME="NumericString";var Ah;class Ho extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ah=Ho,ae.PrintableString=Ah,Ho.NAME="PrintableString";var Sh;class Fo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Sh=Fo,ae.TeletexString=Sh,Fo.NAME="TeletexString";var _h;class zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}_h=zo,ae.VideotexString=_h,zo.NAME="VideotexString";var Eh;class Go extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Eh=Go,ae.IA5String=Eh,Go.NAME="IA5String";var Ih;class Ko extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ih=Ko,ae.GraphicString=Ih,Ko.NAME="GraphicString";var kh;class bs extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}kh=bs,ae.VisibleString=kh,bs.NAME="VisibleString";var Ch;class qo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ch=qo,ae.GeneralString=Ch,qo.NAME="GeneralString";var Bh;class Zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Bh=Zo,ae.CharacterString=Bh,Zo.NAME="CharacterString";var Oh;class xs extends bs{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}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,W.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);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 n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=_r(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_r(this.month,2),t[2]=_r(this.day,2),t[3]=_r(this.hour,2),t[4]=_r(this.minute,2),t[5]=_r(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Oh=xs,ae.UTCTime=Oh,xs.NAME="UTCTime";var Th;class Wo extends xs{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,o,c=0,u=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const x=new Number(e[e.length-1]);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let x=1,G=n.indexOf("+"),N="";if(G===-1&&(G=n.indexOf("-"),x=-1),G!==-1){if(N=n.substring(G+1),n=n.substring(0,G),N.length!==2&&N.length!==4)throw new Error("Wrong input string for conversion");let v=parseInt(N.substring(0,2),10);if(isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");if(c=x*v,N.length===4){if(v=parseInt(N.substring(2,4),10),isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");u=x*v}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){const x=new Number(`0${n.substring(h)}`);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");s=x.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.minute=Math.floor(x),x=60*(x-this.minute),this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){const x=1e3*s;this.millisecond=Math.floor(x)}break;default:throw new Error("Wrong input string for conversion")}const m=o.exec(i);if(m===null)throw new Error("Wrong input string for conversion");for(let x=1;x<m.length;x++)switch(x){case 1:this.year=parseInt(m[x],10);break;case 2:this.month=parseInt(m[x],10);break;case 3:this.day=parseInt(m[x],10);break;case 4:this.hour=parseInt(m[x],10)+c;break;case 5:this.minute=parseInt(m[x],10)+u;break;case 6:this.second=parseInt(m[x],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const x=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=x.getUTCFullYear(),this.month=x.getUTCMonth(),this.day=x.getUTCDay(),this.hour=x.getUTCHours(),this.minute=x.getUTCMinutes(),this.second=x.getUTCSeconds(),this.millisecond=x.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(_r(this.year,4)),t.push(_r(this.month,2)),t.push(_r(this.day,2)),t.push(_r(this.hour,2)),t.push(_r(this.minute,2)),t.push(_r(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_r(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Th=Wo,ae.GeneralizedTime=Th,Wo.NAME="GeneralizedTime";var Nh;class el extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Nh=el,ae.DATE=Nh,el.NAME="DATE";var jh;class tl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}jh=tl,ae.TimeOfDay=jh,tl.NAME="TimeOfDay";var Ph;class rl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Ph=rl,ae.DateTime=Ph,rl.NAME="DateTime";var Rh;class nl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Rh=nl,ae.Duration=Rh,nl.NAME="Duration";var Uh;class il extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Uh=il,ae.TIME=Uh,il.NAME="TIME";class ai{constructor({name:e=gr,optional:t=!1}={}){this.name=e,this.optional=t}}class sl extends ai{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Yo extends ai{constructor({value:e=new ai,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class cg{constructor({data:e=Ro}={}){this.dataView=W.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=W.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=W.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function ci(r,e,t){if(t instanceof sl){for(let s=0;s<t.value.length;s++)if(ci(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(qc)&&(s.name=t.name),s}}if(t instanceof ai)return t.hasOwnProperty(qc)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Jy in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(tg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(rg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Xy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Qy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(eg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Yy in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Mf in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(r[t.name]=e)),t instanceof ae.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof Yo&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let u=!0;for(let h=0;h<t.valueBlock.value.length;h++)u=u&&(t.valueBlock.value[h].optional||!1);return u?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let u=0;u<c;u++)if(u-s>=e.valueBlock.value.length){if(t.valueBlock.value[u].optional===!1){const h={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],h.name=t.name)),h}}else if(t.valueBlock.value[0]instanceof Yo){if(o=ci(r,e.valueBlock.value[u],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),o;if(qc in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let h={};ng in t.valueBlock.value[0]&&t.valueBlock.value[0].local?h=e:h=r,typeof h[t.valueBlock.value[0].name]>"u"&&(h[t.valueBlock.value[0].name]=[]),h[t.valueBlock.value[0].name].push(e.valueBlock.value[u])}}else if(o=ci(r,e.valueBlock.value[u-s],t.valueBlock.value[u]),o.verified===!1)if(t.valueBlock.value[u].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),o;if(o.verified===!1){const u={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],u.name=t.name)),u}return{verified:!0,result:r}}if(t.primitiveSchema&&Mf in e.valueBlock){const s=Pi(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],o.name=t.name)),o}return ci(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function lg(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=Pi(W.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:ci(t.result,t.result,e)}const Dh=Object.freeze(Object.defineProperty({__proto__:null,Any:ai,BaseBlock:Wt,BaseStringBlock:Zc,BitString:oi,BmpString:Mo,Boolean:Uo,CharacterString:Zo,Choice:sl,Constructed:vr,DATE:el,DateTime:rl,Duration:nl,EndOfContent:Wc,Enumerated:Do,GeneralString:qo,GeneralizedTime:Wo,GraphicString:Ko,HexBlock:Xr,IA5String:Go,Integer:Qr,Null:ii,NumericString:Lo,ObjectIdentifier:$o,OctetString:si,Primitive:ws,PrintableString:Ho,RawData:cg,RelativeObjectIdentifier:Qc,Repeated:Yo,Sequence:mn,Set:wn,TIME:il,TeletexString:Fo,TimeOfDay:tl,UTCTime:xs,UniversalString:Vo,Utf8String:bn,ValueBlock:lr,VideotexString:zo,ViewWriter:Po,VisibleString:bs,compareSchema:ci,fromBER:Ri,verifySchema:lg},Symbol.toStringTag,{value:"Module"}));var M;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(M||(M={}));var b;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(b||(b={}));class Jo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(W.isBufferSource(e))this.unusedBits=t,this.value=W.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof oi))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 oi({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new oi({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class Qe{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):W.isBufferSource(e)?this.buffer=W.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof si))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new si({valueHex:this.buffer})}toSchema(e){return new si({name:e})}}const ug={fromASN:r=>r instanceof ii?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ii;const e=Ri(r);if(e.result.error)throw new Error(e.result.error);return e.result}},fg={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Qr({value:+r})},hg={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Do({value:r})},At={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Qr({valueHex:r})},dg={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new oi({valueHex:r})},pg={fromASN:r=>r.valueBlock.toString(),toASN:r=>new $o({value:r})},yg={fromASN:r=>r.valueBlock.value,toASN:r=>new Uo({value:r})},Xo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new si({valueHex:r})},gg={fromASN:r=>new Qe(r.getValue()),toASN:r=>r.toASN()};function Tr(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const $h=Tr(bn),vg=Tr(Mo),mg=Tr(Vo),wg=Tr(Lo),bg=Tr(Ho),xg=Tr(Fo),Ag=Tr(zo),Sg=Tr(Go),_g=Tr(Ko),Eg=Tr(bs),Ig=Tr(qo),kg=Tr(Zo),Cg={fromASN:r=>r.toDate(),toASN:r=>new xs({valueDate:r})},Bg={fromASN:r=>r.toDate(),toASN:r=>new Wo({valueDate:r})},Og={fromASN:()=>null,toASN:()=>new ii};function ol(r){switch(r){case b.Any:return ug;case b.BitString:return dg;case b.BmpString:return vg;case b.Boolean:return yg;case b.CharacterString:return kg;case b.Enumerated:return hg;case b.GeneralString:return Ig;case b.GeneralizedTime:return Bg;case b.GraphicString:return _g;case b.IA5String:return Sg;case b.Integer:return fg;case b.Null:return Og;case b.NumericString:return wg;case b.ObjectIdentifier:return pg;case b.OctetString:return Xo;case b.PrintableString:return bg;case b.TeletexString:return xg;case b.UTCTime:return Cg;case b.UniversalString:return mg;case b.Utf8String:return $h;case b.VideotexString:return Ag;case b.VisibleString:return Eg;default:return null}}function xn(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:xn(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Mh(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Mh(t)}return!1}function Tg(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Ng{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:M.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const o=n.items[s],c=t?s:"";let u;if(typeof o.type=="number"){const m=b[o.type],x=Dh[m];if(!x)throw new Error(`Cannot get ASN1 class by name '${m}'`);u=new x({name:c})}else xn(o.type)?u=new o.type().toSchema(c):o.optional?this.get(o.type).type===M.Choice?u=new ai({name:c}):(u=this.create(o.type,!1),u.name=c):u=new ai({name:c});const h=!!o.optional||o.defaultValue!==void 0;if(o.repeated){u.name="";const m=o.repeated==="set"?wn:mn;u=new m({name:"",value:[new Yo({name:c,value:u})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||xn(o.type)){const m=o.repeated?vr:ws;i.push(new m({name:c,optional:h,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const m=!!o.repeated;let x=m?u:this.get(o.type,!0).schema;x="valueBlock"in x?x.valueBlock.value:x.value,i.push(new vr({name:m?"":c,optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:x}))}else i.push(new vr({optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else u.optional=h,i.push(u)}switch(n.type){case M.Sequence:return new mn({value:i,name:""});case M.Set:return new wn({value:i,name:""});case M.Choice:return new sl({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);return t?this.items.get(t)||this.findParentSchema(t):null}}const Nr=new Ng,H=r=>e=>{let t;Nr.has(e)?t=Nr.get(e):(t=Nr.createDefault(e),Nr.set(e,t)),Object.assign(t,r)},y=r=>(e,t)=>{let n;Nr.has(e.constructor)?n=Nr.get(e.constructor):(n=Nr.createDefault(e.constructor),Nr.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=ol(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class Vh extends Error{constructor(){super(...arguments),this.schemas=[]}}class jg{static parse(e,t){const n=Ri(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(xn(t))return new t().fromASN(e);const i=Nr.get(t);Nr.cache(t);let s=i.schema;if(e.constructor===vr&&i.type!==M.Choice){s=new vr({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const u in i.items)delete e[u]}const o=ci({},e,s);if(!o.verified)throw new Vh(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Mh(t)){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 u=i.itemType;if(typeof u=="number"){const h=ol(u);if(!h)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,m=>h.fromASN(m))}else return t.from(e.valueBlock.value,h=>this.fromASN(h,u))}for(const u in i.items){const h=o.result[u];if(!h)continue;const m=i.items[u],x=m.type;if(typeof x=="number"||xn(x)){const G=(n=m.converter)!==null&&n!==void 0?n:xn(x)?new x:null;if(!G)throw new Error("Converter is empty");if(m.repeated)if(m.implicit){const N=m.repeated==="sequence"?mn:wn,v=new N;v.valueBlock=h.valueBlock;const A=Ri(v.toBER(!1));if(A.offset===-1)throw new Error(`Cannot parse the child item. ${A.result.error}`);if(!("value"in A.result.valueBlock&&Array.isArray(A.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const O=A.result.valueBlock.value;c[u]=Array.from(O,I=>G.fromASN(I))}else c[u]=Array.from(h,N=>G.fromASN(N));else{let N=h;if(m.implicit){let v;if(xn(x))v=new x().toSchema("");else{const A=b[x],O=Dh[A];if(!O)throw new Error(`Cannot get '${A}' class from asn1js module`);v=new O}v.valueBlock=N.valueBlock,N=Ri(v.toBER(!1)).result}c[u]=G.fromASN(N)}}else if(m.repeated){if(!Array.isArray(h))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[u]=Array.from(h,G=>this.fromASN(G,x))}else c[u]=this.fromASN(h,x)}return c}catch(i){throw i instanceof Vh&&i.schemas.push(t.name),i}}}class al{static serialize(e){return e instanceof Wt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&xn(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Nr.get(t);Nr.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const o=ol(n.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:n.itemType},"[]",t,o))}else for(const o in n.items){const c=n.items[o],u=e[o];if(u===void 0||c.defaultValue===u||typeof c.defaultValue=="object"&&typeof u=="object"&&Tg(this.serialize(c.defaultValue),this.serialize(u)))continue;const h=al.toAsnItem(c,o,t,u);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||xn(c.type))){const m={};m.valueHex=h instanceof ii?h.valueBeforeDecodeView:h.valueBlock.toBER(),i.push(new ws({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...m}))}else i.push(new vr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new vr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case M.Sequence:s=new mn({value:i});break;case M.Set:s=new wn({value:i});break;case M.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${b[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,h=>o.toASN(h)),u=e.repeated==="sequence"?mn:wn;s=new u({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>this.toASN(u)),c=e.repeated==="sequence"?mn:wn;s=new c({value:o})}else s=this.toASN(i);return s}}class yt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class q{static serialize(e){return al.serialize(e)}static parse(e,t){return jg.parse(e,t)}static toString(e){const t=W.isBufferSource(e)?W.toArrayBuffer(e):q.serialize(e),n=Ri(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}typeof SuppressedError=="function"&&SuppressedError;var Lh={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function h(v,A){if(v.indexOf("::")!==v.lastIndexOf("::"))return null;let O=0,I=-1,j=(v.match(u.zoneIndex)||[])[0],R,le;for(j&&(j=j.substring(1),v=v.replace(/%.+$/,""));(I=v.indexOf(":",I+1))>=0;)O++;if(v.substr(0,2)==="::"&&O--,v.substr(-2,2)==="::"&&O--,O>A)return null;for(le=A-O,R=":";le--;)R+="0:";return v=v.replace("::",R),v[0]===":"&&(v=v.slice(1)),v[v.length-1]===":"&&(v=v.slice(0,-1)),A=function(){const Q=v.split(":"),re=[];for(let Y=0;Y<Q.length;Y++)re.push(parseInt(Q[Y],16));return re}(),{parts:A,zoneId:j}}function m(v,A,O,I){if(v.length!==A.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let j=0,R;for(;I>0;){if(R=O-I,R<0&&(R=0),v[j]>>R!==A[j]>>R)return!1;I-=O,j+=1}return!0}function x(v){if(s.test(v))return parseInt(v,16);if(v[0]==="0"&&!isNaN(parseInt(v[1],10))){if(i.test(v))return parseInt(v,8);throw new Error(`ipaddr: cannot parse ${v} as octal`)}return parseInt(v,10)}function G(v,A){for(;v.length<A;)v=`0${v}`;return v}const N={};N.IPv4=function(){function v(A){if(A.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let O,I;for(O=0;O<A.length;O++)if(I=A[O],!(0<=I&&I<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=A}return v.prototype.SpecialRanges={unspecified:[[new v([0,0,0,0]),8]],broadcast:[[new v([255,255,255,255]),32]],multicast:[[new v([224,0,0,0]),4]],linkLocal:[[new v([169,254,0,0]),16]],loopback:[[new v([127,0,0,0]),8]],carrierGradeNat:[[new v([100,64,0,0]),10]],private:[[new v([10,0,0,0]),8],[new v([172,16,0,0]),12],[new v([192,168,0,0]),16]],reserved:[[new v([192,0,0,0]),24],[new v([192,0,2,0]),24],[new v([192,88,99,0]),24],[new v([198,18,0,0]),15],[new v([198,51,100,0]),24],[new v([203,0,113,0]),24],[new v([240,0,0,0]),4]],as112:[[new v([192,175,48,0]),24],[new v([192,31,196,0]),24]],amt:[[new v([192,52,193,0]),24]]},v.prototype.kind=function(){return"ipv4"},v.prototype.match=function(A,O){let I;if(O===void 0&&(I=A,A=I[0],O=I[1]),A.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return m(this.octets,A.octets,8,O)},v.prototype.prefixLengthFromSubnetMask=function(){let A=0,O=!1;const I={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let j,R,le;for(j=3;j>=0;j-=1)if(R=this.octets[j],R in I){if(le=I[R],O&&le!==0)return null;le!==8&&(O=!0),A+=le}else return null;return 32-A},v.prototype.range=function(){return N.subnetMatch(this,this.SpecialRanges)},v.prototype.toByteArray=function(){return this.octets.slice(0)},v.prototype.toIPv4MappedAddress=function(){return N.IPv6.parse(`::ffff:${this.toString()}`)},v.prototype.toNormalizedString=function(){return this.toString()},v.prototype.toString=function(){return this.octets.join(".")},v}(),N.IPv4.broadcastAddressFromCIDR=function(v){try{const A=this.parseCIDR(v),O=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),j=[];let R=0;for(;R<4;)j.push(parseInt(O[R],10)|parseInt(I[R],10)^255),R++;return new this(j)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},N.IPv4.isIPv4=function(v){return this.parser(v)!==null},N.IPv4.isValid=function(v){try{return new this(this.parser(v)),!0}catch{return!1}},N.IPv4.isValidCIDR=function(v){try{return this.parseCIDR(v),!0}catch{return!1}},N.IPv4.isValidFourPartDecimal=function(v){return!!(N.IPv4.isValid(v)&&v.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},N.IPv4.networkAddressFromCIDR=function(v){let A,O,I,j,R;try{for(A=this.parseCIDR(v),I=A[0].toByteArray(),R=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),j=[],O=0;O<4;)j.push(parseInt(I[O],10)&parseInt(R[O],10)),O++;return new this(j)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},N.IPv4.parse=function(v){const A=this.parser(v);if(A===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(A)},N.IPv4.parseCIDR=function(v){let A;if(A=v.match(/^(.+)\/(\d+)$/)){const O=parseInt(A[2]);if(O>=0&&O<=32){const I=[this.parse(A[1]),O];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},N.IPv4.parser=function(v){let A,O,I;if(A=v.match(n.fourOctet))return function(){const j=A.slice(1,6),R=[];for(let le=0;le<j.length;le++)O=j[le],R.push(x(O));return R}();if(A=v.match(n.longValue)){if(I=x(A[1]),I>4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const j=[];let R;for(R=0;R<=24;R+=8)j.push(I>>R&255);return j}().reverse()}else return(A=v.match(n.twoOctet))?function(){const j=A.slice(1,4),R=[];if(I=x(j[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return R.push(x(j[0])),R.push(I>>16&255),R.push(I>>8&255),R.push(I&255),R}():(A=v.match(n.threeOctet))?function(){const j=A.slice(1,5),R=[];if(I=x(j[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return R.push(x(j[0])),R.push(x(j[1])),R.push(I>>8&255),R.push(I&255),R}():null},N.IPv4.subnetMaskFromPrefixLength=function(v){if(v=parseInt(v),v<0||v>32)throw new Error("ipaddr: invalid IPv4 prefix length");const A=[0,0,0,0];let O=0;const I=Math.floor(v/8);for(;O<I;)A[O]=255,O++;return I<4&&(A[I]=Math.pow(2,v%8)-1<<8-v%8),new this(A)},N.IPv6=function(){function v(A,O){let I,j;if(A.length===16)for(this.parts=[],I=0;I<=14;I+=2)this.parts.push(A[I]<<8|A[I+1]);else if(A.length===8)this.parts=A;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(I=0;I<this.parts.length;I++)if(j=this.parts[I],!(0<=j&&j<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");O&&(this.zoneId=O)}return v.prototype.SpecialRanges={unspecified:[new v([0,0,0,0,0,0,0,0]),128],linkLocal:[new v([65152,0,0,0,0,0,0,0]),10],multicast:[new v([65280,0,0,0,0,0,0,0]),8],loopback:[new v([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new v([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new v([0,0,0,0,0,65535,0,0]),96],discard:[new v([256,0,0,0,0,0,0,0]),64],rfc6145:[new v([0,0,0,0,65535,0,0,0]),96],rfc6052:[new v([100,65435,0,0,0,0,0,0]),96],"6to4":[new v([8194,0,0,0,0,0,0,0]),16],teredo:[new v([8193,0,0,0,0,0,0,0]),32],benchmarking:[new v([8193,2,0,0,0,0,0,0]),48],amt:[new v([8193,3,0,0,0,0,0,0]),32],as112v6:[[new v([8193,4,274,0,0,0,0,0]),48],[new v([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new v([8193,16,0,0,0,0,0,0]),28],orchid2:[new v([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new v([8193,48,0,0,0,0,0,0]),28],reserved:[[new v([8193,0,0,0,0,0,0,0]),23],[new v([8193,3512,0,0,0,0,0,0]),32]]},v.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},v.prototype.kind=function(){return"ipv6"},v.prototype.match=function(A,O){let I;if(O===void 0&&(I=A,A=I[0],O=I[1]),A.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return m(this.parts,A.parts,16,O)},v.prototype.prefixLengthFromSubnetMask=function(){let A=0,O=!1;const I={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let j,R;for(let le=7;le>=0;le-=1)if(j=this.parts[le],j in I){if(R=I[j],O&&R!==0)return null;R!==16&&(O=!0),A+=R}else return null;return 128-A},v.prototype.range=function(){return N.subnetMatch(this,this.SpecialRanges)},v.prototype.toByteArray=function(){let A;const O=[],I=this.parts;for(let j=0;j<I.length;j++)A=I[j],O.push(A>>8),O.push(A&255);return O},v.prototype.toFixedLengthString=function(){const A=(function(){const I=[];for(let j=0;j<this.parts.length;j++)I.push(G(this.parts[j].toString(16),4));return I}).call(this).join(":");let O="";return this.zoneId&&(O=`%${this.zoneId}`),A+O},v.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const A=this.parts.slice(-2),O=A[0],I=A[1];return new N.IPv4([O>>8,O&255,I>>8,I&255])},v.prototype.toNormalizedString=function(){const A=(function(){const I=[];for(let j=0;j<this.parts.length;j++)I.push(this.parts[j].toString(16));return I}).call(this).join(":");let O="";return this.zoneId&&(O=`%${this.zoneId}`),A+O},v.prototype.toRFC5952String=function(){const A=/((^|:)(0(:|$)){2,})/g,O=this.toNormalizedString();let I=0,j=-1,R;for(;R=A.exec(O);)R[0].length>j&&(I=R.index,j=R[0].length);return j<0?O:`${O.substring(0,I)}::${O.substring(I+j)}`},v.prototype.toString=function(){return this.toRFC5952String()},v}(),N.IPv6.broadcastAddressFromCIDR=function(v){try{const A=this.parseCIDR(v),O=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),j=[];let R=0;for(;R<16;)j.push(parseInt(O[R],10)|parseInt(I[R],10)^255),R++;return new this(j)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},N.IPv6.isIPv6=function(v){return this.parser(v)!==null},N.IPv6.isValid=function(v){if(typeof v=="string"&&v.indexOf(":")===-1)return!1;try{const A=this.parser(v);return new this(A.parts,A.zoneId),!0}catch{return!1}},N.IPv6.isValidCIDR=function(v){if(typeof v=="string"&&v.indexOf(":")===-1)return!1;try{return this.parseCIDR(v),!0}catch{return!1}},N.IPv6.networkAddressFromCIDR=function(v){let A,O,I,j,R;try{for(A=this.parseCIDR(v),I=A[0].toByteArray(),R=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),j=[],O=0;O<16;)j.push(parseInt(I[O],10)&parseInt(R[O],10)),O++;return new this(j)}catch(le){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${le})`)}},N.IPv6.parse=function(v){const A=this.parser(v);if(A.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(A.parts,A.zoneId)},N.IPv6.parseCIDR=function(v){let A,O,I;if((O=v.match(/^(.+)\/(\d+)$/))&&(A=parseInt(O[2]),A>=0&&A<=128))return I=[this.parse(O[1]),A],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},N.IPv6.parser=function(v){let A,O,I,j,R,le;if(I=v.match(u.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(u.native.test(v))return h(v,8);if((I=v.match(u.transitional))&&(le=I[6]||"",A=I[1],I[1].endsWith("::")||(A=A.slice(0,-1)),A=h(A+le,6),A.parts)){for(R=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],O=0;O<R.length;O++)if(j=R[O],!(0<=j&&j<=255))return null;return A.parts.push(R[0]<<8|R[1]),A.parts.push(R[2]<<8|R[3]),{parts:A.parts,zoneId:A.zoneId}}return null},N.IPv6.subnetMaskFromPrefixLength=function(v){if(v=parseInt(v),v<0||v>128)throw new Error("ipaddr: invalid IPv6 prefix length");const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let O=0;const I=Math.floor(v/8);for(;O<I;)A[O]=255,O++;return I<16&&(A[I]=Math.pow(2,v%8)-1<<8-v%8),new this(A)},N.fromByteArray=function(v){const A=v.length;if(A===4)return new N.IPv4(v);if(A===16)return new N.IPv6(v);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},N.isValid=function(v){return N.IPv6.isValid(v)||N.IPv4.isValid(v)},N.isValidCIDR=function(v){return N.IPv6.isValidCIDR(v)||N.IPv4.isValidCIDR(v)},N.parse=function(v){if(N.IPv6.isValid(v))return N.IPv6.parse(v);if(N.IPv4.isValid(v))return N.IPv4.parse(v);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},N.parseCIDR=function(v){try{return N.IPv6.parseCIDR(v)}catch{try{return N.IPv4.parseCIDR(v)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},N.process=function(v){const A=this.parse(v);return A.kind()==="ipv6"&&A.isIPv4MappedAddress()?A.toIPv4Address():A},N.subnetMatch=function(v,A,O){let I,j,R,le;O==null&&(O="unicast");for(j in A)if(Object.prototype.hasOwnProperty.call(A,j)){for(R=A[j],R[0]&&!(R[0]instanceof Array)&&(R=[R]),I=0;I<R.length;I++)if(le=R[I],v.kind()===le[0].kind()&&v.match.apply(v,le))return j}return O},r.exports?r.exports=N:e.ipaddr=N})(Fc)})(Lh);var Hh=Lh.exports;class Fh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Hh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(fe.ToHex(e))}static fromString(e){const t=Hh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var cl,ll,ul;let Yt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([y({type:b.TeletexString})],Yt.prototype,"teletexString",void 0),f([y({type:b.PrintableString})],Yt.prototype,"printableString",void 0),f([y({type:b.UniversalString})],Yt.prototype,"universalString",void 0),f([y({type:b.Utf8String})],Yt.prototype,"utf8String",void 0),f([y({type:b.BmpString})],Yt.prototype,"bmpString",void 0),Yt=f([H({type:M.Choice})],Yt);let Ui=class extends Yt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?fe.ToHex(this.anyValue):super.toString())}};f([y({type:b.IA5String})],Ui.prototype,"ia5String",void 0),f([y({type:b.Any})],Ui.prototype,"anyValue",void 0),Ui=f([H({type:M.Choice})],Ui);class Qo{constructor(e={}){this.type="",this.value=new Ui,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Qo.prototype,"type",void 0),f([y({type:Ui})],Qo.prototype,"value",void 0);let Di=cl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,cl.prototype)}};Di=cl=f([H({type:M.Set,itemType:Qo})],Di);let fl=ll=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,ll.prototype)}};fl=ll=f([H({type:M.Sequence,itemType:Di})],fl);let zt=ul=class extends fl{constructor(e){super(e),Object.setPrototypeOf(this,ul.prototype)}};zt=ul=f([H({type:M.Sequence})],zt);const Pg={fromASN:r=>Fh.toString(Xo.fromASN(r)),toASN:r=>Xo.toASN(Fh.fromString(r))};class As{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],As.prototype,"typeId",void 0),f([y({type:b.Any,context:0})],As.prototype,"value",void 0);class hl{constructor(e={}){this.partyName=new Yt,Object.assign(this,e)}}f([y({type:Yt,optional:!0,context:0,implicit:!0})],hl.prototype,"nameAssigner",void 0),f([y({type:Yt,context:1,implicit:!0})],hl.prototype,"partyName",void 0);let Pe=class{constructor(e={}){Object.assign(this,e)}};f([y({type:As,context:0,implicit:!0})],Pe.prototype,"otherName",void 0),f([y({type:b.IA5String,context:1,implicit:!0})],Pe.prototype,"rfc822Name",void 0),f([y({type:b.IA5String,context:2,implicit:!0})],Pe.prototype,"dNSName",void 0),f([y({type:b.Any,context:3,implicit:!0})],Pe.prototype,"x400Address",void 0),f([y({type:zt,context:4,implicit:!1})],Pe.prototype,"directoryName",void 0),f([y({type:hl,context:5})],Pe.prototype,"ediPartyName",void 0),f([y({type:b.IA5String,context:6,implicit:!0})],Pe.prototype,"uniformResourceIdentifier",void 0),f([y({type:b.OctetString,context:7,implicit:!0,converter:Pg})],Pe.prototype,"iPAddress",void 0),f([y({type:b.ObjectIdentifier,context:8,implicit:!0})],Pe.prototype,"registeredID",void 0),Pe=f([H({type:M.Choice})],Pe);const dl="1.3.6.1.5.5.7",Rg=`${dl}.1`,$i=`${dl}.3`,ea=`${dl}.48`,zh=`${ea}.1`,Gh=`${ea}.2`,Kh=`${ea}.3`,qh=`${ea}.5`,Pn="2.5.29";var pl;const yl=`${Rg}.1`;class Ss{constructor(e={}){this.accessMethod="",this.accessLocation=new Pe,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Ss.prototype,"accessMethod",void 0),f([y({type:Pe})],Ss.prototype,"accessLocation",void 0);let Mi=pl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,pl.prototype)}};Mi=pl=f([H({type:M.Sequence,itemType:Ss})],Mi);const ta=`${Pn}.35`;class gl extends Qe{}class li{constructor(e={}){e&&Object.assign(this,e)}}f([y({type:gl,context:0,optional:!0,implicit:!0})],li.prototype,"keyIdentifier",void 0),f([y({type:Pe,context:1,optional:!0,implicit:!0,repeated:"sequence"})],li.prototype,"authorityCertIssuer",void 0),f([y({type:b.Integer,context:2,optional:!0,implicit:!0,converter:At})],li.prototype,"authorityCertSerialNumber",void 0);const Zh=`${Pn}.19`;class ra{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([y({type:b.Boolean,defaultValue:!1})],ra.prototype,"cA",void 0),f([y({type:b.Integer,optional:!0})],ra.prototype,"pathLenConstraint",void 0);var vl;let ur=vl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,vl.prototype)}};ur=vl=f([H({type:M.Sequence,itemType:Pe})],ur);var ml;let Wh=ml=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};Wh=ml=f([H({type:M.Sequence})],Wh);var wl;const Yh=`${Pn}.32`;let An=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([y({type:b.IA5String})],An.prototype,"ia5String",void 0),f([y({type:b.VisibleString})],An.prototype,"visibleString",void 0),f([y({type:b.BmpString})],An.prototype,"bmpString",void 0),f([y({type:b.Utf8String})],An.prototype,"utf8String",void 0),An=f([H({type:M.Choice})],An);class bl{constructor(e={}){this.organization=new An,this.noticeNumbers=[],Object.assign(this,e)}}f([y({type:An})],bl.prototype,"organization",void 0),f([y({type:b.Integer,repeated:"sequence"})],bl.prototype,"noticeNumbers",void 0);class xl{constructor(e={}){Object.assign(this,e)}}f([y({type:bl,optional:!0})],xl.prototype,"noticeRef",void 0),f([y({type:An,optional:!0})],xl.prototype,"explicitText",void 0);let na=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.IA5String})],na.prototype,"cPSuri",void 0),f([y({type:xl})],na.prototype,"userNotice",void 0),na=f([H({type:M.Choice})],na);class Al{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Al.prototype,"policyQualifierId",void 0),f([y({type:b.Any})],Al.prototype,"qualifier",void 0);class ia{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],ia.prototype,"policyIdentifier",void 0),f([y({type:Al,repeated:"sequence",optional:!0})],ia.prototype,"policyQualifiers",void 0);let sa=wl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};sa=wl=f([H({type:M.Sequence,itemType:ia})],sa);let oa=class{constructor(e=0){this.value=e}};f([y({type:b.Integer})],oa.prototype,"value",void 0),oa=f([H({type:M.Choice})],oa);let Jh=class extends oa{};Jh=f([H({type:M.Choice})],Jh);var Sl;const _l=`${Pn}.31`;var Vr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Vr||(Vr={}));class Xh extends Jo{toJSON(){const e=[],t=this.toNumber();return t&Vr.aACompromise&&e.push("aACompromise"),t&Vr.affiliationChanged&&e.push("affiliationChanged"),t&Vr.cACompromise&&e.push("cACompromise"),t&Vr.certificateHold&&e.push("certificateHold"),t&Vr.cessationOfOperation&&e.push("cessationOfOperation"),t&Vr.keyCompromise&&e.push("keyCompromise"),t&Vr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Vr.superseded&&e.push("superseded"),t&Vr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ui=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Pe,context:0,repeated:"sequence",implicit:!0})],ui.prototype,"fullName",void 0),f([y({type:Di,context:1,implicit:!0})],ui.prototype,"nameRelativeToCRLIssuer",void 0),ui=f([H({type:M.Choice})],ui);class Vi{constructor(e={}){Object.assign(this,e)}}f([y({type:ui,context:0,optional:!0})],Vi.prototype,"distributionPoint",void 0),f([y({type:Xh,context:1,optional:!0,implicit:!0})],Vi.prototype,"reasons",void 0),f([y({type:Pe,context:2,optional:!0,repeated:"sequence",implicit:!0})],Vi.prototype,"cRLIssuer",void 0);let Li=Sl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Sl.prototype)}};Li=Sl=f([H({type:M.Sequence,itemType:Vi})],Li);var El;let Qh=El=class extends Li{constructor(e){super(e),Object.setPrototypeOf(this,El.prototype)}};Qh=El=f([H({type:M.Sequence,itemType:Vi})],Qh);class rr{constructor(e={}){this.onlyContainsUserCerts=rr.ONLY,this.onlyContainsCACerts=rr.ONLY,this.indirectCRL=rr.ONLY,this.onlyContainsAttributeCerts=rr.ONLY,Object.assign(this,e)}}rr.ONLY=!1,f([y({type:ui,context:0,optional:!0})],rr.prototype,"distributionPoint",void 0),f([y({type:b.Boolean,context:1,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsUserCerts",void 0),f([y({type:b.Boolean,context:2,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsCACerts",void 0),f([y({type:Xh,context:3,optional:!0,implicit:!0})],rr.prototype,"onlySomeReasons",void 0),f([y({type:b.Boolean,context:4,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"indirectCRL",void 0),f([y({type:b.Boolean,context:5,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsAttributeCerts",void 0);var _s;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(_s||(_s={}));let Il=class{constructor(e=_s.unspecified){this.reason=_s.unspecified,this.reason=e}toJSON(){return _s[this.reason]}toString(){return this.toJSON()}};f([y({type:b.Enumerated})],Il.prototype,"reason",void 0),Il=f([H({type:M.Choice})],Il);var kl;const ed=`${Pn}.37`;let aa=kl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};aa=kl=f([H({type:M.Sequence,itemType:b.ObjectIdentifier})],aa);const Ug=`${$i}.1`,Dg=`${$i}.2`,$g=`${$i}.3`,Mg=`${$i}.4`,Vg=`${$i}.8`,Lg=`${$i}.9`;let Cl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([y({type:b.Integer,converter:At})],Cl.prototype,"value",void 0),Cl=f([H({type:M.Choice})],Cl);let Bl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([y({type:b.GeneralizedTime})],Bl.prototype,"value",void 0),Bl=f([H({type:M.Choice})],Bl);var Ol;let td=Ol=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};td=Ol=f([H({type:M.Sequence})],td);const rd=`${Pn}.15`;var Lr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Lr||(Lr={}));class Tl extends Jo{toJSON(){const e=this.toNumber(),t=[];return e&Lr.cRLSign&&t.push("crlSign"),e&Lr.dataEncipherment&&t.push("dataEncipherment"),e&Lr.decipherOnly&&t.push("decipherOnly"),e&Lr.digitalSignature&&t.push("digitalSignature"),e&Lr.encipherOnly&&t.push("encipherOnly"),e&Lr.keyAgreement&&t.push("keyAgreement"),e&Lr.keyCertSign&&t.push("keyCertSign"),e&Lr.keyEncipherment&&t.push("keyEncipherment"),e&Lr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Nl;class ca{constructor(e={}){this.base=new Pe,this.minimum=0,Object.assign(this,e)}}f([y({type:Pe})],ca.prototype,"base",void 0),f([y({type:b.Integer,context:0,defaultValue:0,implicit:!0})],ca.prototype,"minimum",void 0),f([y({type:b.Integer,context:1,optional:!0,implicit:!0})],ca.prototype,"maximum",void 0);let la=Nl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};la=Nl=f([H({type:M.Sequence,itemType:ca})],la);class nd{constructor(e={}){Object.assign(this,e)}}f([y({type:la,context:0,optional:!0,implicit:!0})],nd.prototype,"permittedSubtrees",void 0),f([y({type:la,context:1,optional:!0,implicit:!0})],nd.prototype,"excludedSubtrees",void 0);class id{constructor(e={}){Object.assign(this,e)}}f([y({type:b.Integer,context:0,implicit:!0,optional:!0,converter:At})],id.prototype,"requireExplicitPolicy",void 0),f([y({type:b.Integer,context:1,implicit:!0,optional:!0,converter:At})],id.prototype,"inhibitPolicyMapping",void 0);var jl;class Pl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Pl.prototype,"issuerDomainPolicy",void 0),f([y({type:b.ObjectIdentifier})],Pl.prototype,"subjectDomainPolicy",void 0);let sd=jl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,jl.prototype)}};sd=jl=f([H({type:M.Sequence,itemType:Pl})],sd);var Rl;const Ul=`${Pn}.17`;let Dl=Rl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};Dl=Rl=f([H({type:M.Sequence})],Dl);let Sn=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Sn.prototype,"type",void 0),f([y({type:b.Any,repeated:"set"})],Sn.prototype,"values",void 0);var $l;let od=$l=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};od=$l=f([H({type:M.Sequence,itemType:Sn})],od);const Ml=`${Pn}.14`;class Rn extends gl{}class ad{constructor(e={}){Object.assign(this,e)}}f([y({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],ad.prototype,"notBefore",void 0),f([y({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],ad.prototype,"notAfter",void 0);var Es;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Es||(Es={}));class cd extends Jo{toJSON(){const e=[],t=this.toNumber();return t&Es.pKIXCertificate&&e.push("pKIXCertificate"),t&Es.newExtensions&&e.push("newExtensions"),t&Es.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class ld{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new cd,Object.assign(this,e)}}f([y({type:b.GeneralString})],ld.prototype,"entrustVers",void 0),f([y({type:cd})],ld.prototype,"entrustInfoFlags",void 0);var Vl;let ud=Vl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};ud=Vl=f([H({type:M.Sequence,itemType:Ss})],ud);class se{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof se&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&No(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([y({type:b.ObjectIdentifier})],se.prototype,"algorithm",void 0),f([y({type:b.Any,optional:!0})],se.prototype,"parameters",void 0);class en{constructor(e={}){this.algorithm=new se,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:se})],en.prototype,"algorithm",void 0),f([y({type:b.BitString})],en.prototype,"subjectPublicKey",void 0);let Jt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||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}};f([y({type:b.UTCTime})],Jt.prototype,"utcTime",void 0),f([y({type:b.GeneralizedTime})],Jt.prototype,"generalTime",void 0),Jt=f([H({type:M.Choice})],Jt);class ua{constructor(e){this.notBefore=new Jt(new Date),this.notAfter=new Jt(new Date),e&&(this.notBefore=new Jt(e.notBefore),this.notAfter=new Jt(e.notAfter))}}f([y({type:Jt})],ua.prototype,"notBefore",void 0),f([y({type:Jt})],ua.prototype,"notAfter",void 0);var Ll;let Hr=class Ey{constructor(e={}){this.extnID="",this.critical=Ey.CRITICAL,this.extnValue=new Qe,Object.assign(this,e)}};Hr.CRITICAL=!1,f([y({type:b.ObjectIdentifier})],Hr.prototype,"extnID",void 0),f([y({type:b.Boolean,defaultValue:Hr.CRITICAL})],Hr.prototype,"critical",void 0),f([y({type:Qe})],Hr.prototype,"extnValue",void 0);let fi=Ll=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};fi=Ll=f([H({type:M.Sequence,itemType:Hr})],fi);var Hi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Hi||(Hi={}));class jr{constructor(e={}){this.version=Hi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new se,this.issuer=new zt,this.validity=new ua,this.subject=new zt,this.subjectPublicKeyInfo=new en,Object.assign(this,e)}}f([y({type:b.Integer,context:0,defaultValue:Hi.v1})],jr.prototype,"version",void 0),f([y({type:b.Integer,converter:At})],jr.prototype,"serialNumber",void 0),f([y({type:se})],jr.prototype,"signature",void 0),f([y({type:zt})],jr.prototype,"issuer",void 0),f([y({type:ua})],jr.prototype,"validity",void 0),f([y({type:zt})],jr.prototype,"subject",void 0),f([y({type:en})],jr.prototype,"subjectPublicKeyInfo",void 0),f([y({type:b.BitString,context:1,implicit:!0,optional:!0})],jr.prototype,"issuerUniqueID",void 0),f([y({type:b.BitString,context:2,implicit:!0,optional:!0})],jr.prototype,"subjectUniqueID",void 0),f([y({type:fi,context:3,optional:!0})],jr.prototype,"extensions",void 0);class hi{constructor(e={}){this.tbsCertificate=new jr,this.signatureAlgorithm=new se,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:jr})],hi.prototype,"tbsCertificate",void 0),f([y({type:se})],hi.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],hi.prototype,"signatureValue",void 0);class fa{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Jt,Object.assign(this,e)}}f([y({type:b.Integer,converter:At})],fa.prototype,"userCertificate",void 0),f([y({type:Jt})],fa.prototype,"revocationDate",void 0),f([y({type:Hr,optional:!0,repeated:"sequence"})],fa.prototype,"crlEntryExtensions",void 0);class _n{constructor(e={}){this.signature=new se,this.issuer=new zt,this.thisUpdate=new Jt,Object.assign(this,e)}}f([y({type:b.Integer,optional:!0})],_n.prototype,"version",void 0),f([y({type:se})],_n.prototype,"signature",void 0),f([y({type:zt})],_n.prototype,"issuer",void 0),f([y({type:Jt})],_n.prototype,"thisUpdate",void 0),f([y({type:Jt,optional:!0})],_n.prototype,"nextUpdate",void 0),f([y({type:fa,repeated:"sequence",optional:!0})],_n.prototype,"revokedCertificates",void 0),f([y({type:Hr,optional:!0,context:0,repeated:"sequence"})],_n.prototype,"crlExtensions",void 0);class Hl{constructor(e={}){this.tbsCertList=new _n,this.signatureAlgorithm=new se,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:_n})],Hl.prototype,"tbsCertList",void 0),f([y({type:se})],Hl.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],Hl.prototype,"signature",void 0);class Fi{constructor(e={}){this.issuer=new zt,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:zt})],Fi.prototype,"issuer",void 0),f([y({type:b.Integer,converter:At})],Fi.prototype,"serialNumber",void 0);let zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0})],zi.prototype,"subjectKeyIdentifier",void 0),f([y({type:Fi})],zi.prototype,"issuerAndSerialNumber",void 0),zi=f([H({type:M.Choice})],zi);var tn;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(tn||(tn={}));let Is=class extends se{};Is=f([H({type:M.Sequence})],Is);let ha=class extends se{};ha=f([H({type:M.Sequence})],ha);let rn=class extends se{};rn=f([H({type:M.Sequence})],rn);let da=class extends se{};da=f([H({type:M.Sequence})],da);let fd=class extends se{};fd=f([H({type:M.Sequence})],fd);let Fl=class extends se{};Fl=f([H({type:M.Sequence})],Fl);let Gi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Gi.prototype,"attrType",void 0),f([y({type:b.Any,repeated:"set"})],Gi.prototype,"attrValues",void 0);var zl;class nn{constructor(e={}){this.version=tn.v0,this.sid=new zi,this.digestAlgorithm=new Is,this.signatureAlgorithm=new ha,this.signature=new Qe,Object.assign(this,e)}}f([y({type:b.Integer})],nn.prototype,"version",void 0),f([y({type:zi})],nn.prototype,"sid",void 0),f([y({type:Is})],nn.prototype,"digestAlgorithm",void 0),f([y({type:Gi,repeated:"set",context:0,implicit:!0,optional:!0})],nn.prototype,"signedAttrs",void 0),f([y({type:ha})],nn.prototype,"signatureAlgorithm",void 0),f([y({type:Qe})],nn.prototype,"signature",void 0),f([y({type:Gi,repeated:"set",context:1,implicit:!0,optional:!0})],nn.prototype,"unsignedAttrs",void 0);let pa=zl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};pa=zl=f([H({type:M.Set,itemType:nn})],pa);let hd=class extends Jt{};hd=f([H({type:M.Choice})],hd);let dd=class extends nn{};dd=f([H({type:M.Sequence})],dd);class Gl{constructor(e={}){this.acIssuer=new Pe,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([y({type:Pe})],Gl.prototype,"acIssuer",void 0),f([y({type:b.Integer})],Gl.prototype,"acSerial",void 0),f([y({type:Sn,repeated:"sequence"})],Gl.prototype,"attrs",void 0);var Kl;let ya=Kl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};ya=Kl=f([H({type:M.Sequence,itemType:b.ObjectIdentifier})],ya);class ga{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([y({type:b.Integer,optional:!0})],ga.prototype,"pathLenConstraint",void 0),f([y({type:ya,implicit:!0,context:0,optional:!0})],ga.prototype,"permittedAttrs",void 0),f([y({type:ya,implicit:!0,context:1,optional:!0})],ga.prototype,"excludedAttrs",void 0),f([y({type:b.Boolean,defaultValue:!0})],ga.prototype,"permitUnSpecified",void 0);class di{constructor(e={}){this.issuer=new ur,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ur})],di.prototype,"issuer",void 0),f([y({type:b.Integer,converter:At})],di.prototype,"serial",void 0),f([y({type:b.BitString,optional:!0})],di.prototype,"issuerUID",void 0);var ql;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(ql||(ql={}));class pi{constructor(e={}){this.digestedObjectType=ql.publicKey,this.digestAlgorithm=new se,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Enumerated})],pi.prototype,"digestedObjectType",void 0),f([y({type:b.ObjectIdentifier,optional:!0})],pi.prototype,"otherObjectTypeID",void 0),f([y({type:se})],pi.prototype,"digestAlgorithm",void 0),f([y({type:b.BitString})],pi.prototype,"objectDigest",void 0);class va{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,optional:!0})],va.prototype,"issuerName",void 0),f([y({type:di,context:0,implicit:!0,optional:!0})],va.prototype,"baseCertificateID",void 0),f([y({type:pi,context:1,implicit:!0,optional:!0})],va.prototype,"objectDigestInfo",void 0);let Ki=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Pe,repeated:"sequence"})],Ki.prototype,"v1Form",void 0),f([y({type:va,context:0,implicit:!0})],Ki.prototype,"v2Form",void 0),Ki=f([H({type:M.Choice})],Ki);class ma{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([y({type:b.GeneralizedTime})],ma.prototype,"notBeforeTime",void 0),f([y({type:b.GeneralizedTime})],ma.prototype,"notAfterTime",void 0);class ks{constructor(e={}){Object.assign(this,e)}}f([y({type:di,implicit:!0,context:0,optional:!0})],ks.prototype,"baseCertificateID",void 0),f([y({type:ur,implicit:!0,context:1,optional:!0})],ks.prototype,"entityName",void 0),f([y({type:pi,implicit:!0,context:2,optional:!0})],ks.prototype,"objectDigestInfo",void 0);var Zl;(function(r){r[r.v2=1]="v2"})(Zl||(Zl={}));class Fr{constructor(e={}){this.version=Zl.v2,this.holder=new ks,this.issuer=new Ki,this.signature=new se,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new ma,this.attributes=[],Object.assign(this,e)}}f([y({type:b.Integer})],Fr.prototype,"version",void 0),f([y({type:ks})],Fr.prototype,"holder",void 0),f([y({type:Ki})],Fr.prototype,"issuer",void 0),f([y({type:se})],Fr.prototype,"signature",void 0),f([y({type:b.Integer,converter:At})],Fr.prototype,"serialNumber",void 0),f([y({type:ma})],Fr.prototype,"attrCertValidityPeriod",void 0),f([y({type:Sn,repeated:"sequence"})],Fr.prototype,"attributes",void 0),f([y({type:b.BitString,optional:!0})],Fr.prototype,"issuerUniqueID",void 0),f([y({type:fi,optional:!0})],Fr.prototype,"extensions",void 0);class wa{constructor(e={}){this.acinfo=new Fr,this.signatureAlgorithm=new se,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Fr})],wa.prototype,"acinfo",void 0),f([y({type:se})],wa.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],wa.prototype,"signatureValue",void 0);var ba;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(ba||(ba={}));class Wl extends Jo{}class Yl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier,implicit:!0,context:0})],Yl.prototype,"type",void 0),f([y({type:b.Any,implicit:!0,context:1})],Yl.prototype,"value",void 0);class Jl{constructor(e={}){this.policyId="",this.classList=new Wl(ba.unclassified),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Jl.prototype,"policyId",void 0),f([y({type:Wl,defaultValue:new Wl(ba.unclassified)})],Jl.prototype,"classList",void 0),f([y({type:Yl,repeated:"set"})],Jl.prototype,"securityCategories",void 0);class xa{constructor(e={}){Object.assign(this,e)}}f([y({type:Qe})],xa.prototype,"cotets",void 0),f([y({type:b.ObjectIdentifier})],xa.prototype,"oid",void 0),f([y({type:b.Utf8String})],xa.prototype,"string",void 0);class pd{constructor(e={}){this.values=[],Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],pd.prototype,"policyAuthority",void 0),f([y({type:xa,repeated:"sequence"})],pd.prototype,"values",void 0);var Xl;class Aa{constructor(e={}){this.targetCertificate=new di,Object.assign(this,e)}}f([y({type:di})],Aa.prototype,"targetCertificate",void 0),f([y({type:Pe,optional:!0})],Aa.prototype,"targetName",void 0),f([y({type:pi,optional:!0})],Aa.prototype,"certDigestInfo",void 0);let qi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Pe,context:0,implicit:!0})],qi.prototype,"targetName",void 0),f([y({type:Pe,context:1,implicit:!0})],qi.prototype,"targetGroup",void 0),f([y({type:Aa,context:2,implicit:!0})],qi.prototype,"targetCert",void 0),qi=f([H({type:M.Choice})],qi);let Ql=Xl=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};Ql=Xl=f([H({type:M.Sequence,itemType:qi})],Ql);var eu;let yd=eu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,eu.prototype)}};yd=eu=f([H({type:M.Sequence,itemType:Ql})],yd);class gd{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],gd.prototype,"roleAuthority",void 0),f([y({type:Pe,implicit:!0,context:1})],gd.prototype,"roleName",void 0);class tu{constructor(e={}){this.service=new Pe,this.ident=new Pe,Object.assign(this,e)}}f([y({type:Pe})],tu.prototype,"service",void 0),f([y({type:Pe})],tu.prototype,"ident",void 0),f([y({type:Qe,optional:!0})],tu.prototype,"authInfo",void 0);var ru;class nu{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],nu.prototype,"otherCertFormat",void 0),f([y({type:b.Any})],nu.prototype,"otherCert",void 0);let yi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:hi})],yi.prototype,"certificate",void 0),f([y({type:wa,context:2,implicit:!0})],yi.prototype,"v2AttrCert",void 0),f([y({type:nu,context:3,implicit:!0})],yi.prototype,"other",void 0),yi=f([H({type:M.Choice})],yi);let Cs=ru=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,ru.prototype)}};Cs=ru=f([H({type:M.Set,itemType:yi})],Cs);class En{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],En.prototype,"contentType",void 0),f([y({type:b.Any,context:0})],En.prototype,"content",void 0);let Zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Qe})],Zi.prototype,"single",void 0),f([y({type:b.Any})],Zi.prototype,"any",void 0),Zi=f([H({type:M.Choice})],Zi);class Sa{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Sa.prototype,"eContentType",void 0),f([y({type:Zi,context:0,optional:!0})],Sa.prototype,"eContent",void 0);let Bs=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Qe,context:0,implicit:!0,optional:!0})],Bs.prototype,"value",void 0),f([y({type:Qe,converter:gg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Bs.prototype,"constructedValue",void 0),Bs=f([H({type:M.Choice})],Bs);class Os{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new da,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Os.prototype,"contentType",void 0),f([y({type:da})],Os.prototype,"contentEncryptionAlgorithm",void 0),f([y({type:Bs,optional:!0})],Os.prototype,"encryptedContent",void 0);class _a{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],_a.prototype,"keyAttrId",void 0),f([y({type:b.Any,optional:!0})],_a.prototype,"keyAttr",void 0);var iu;class Ea{constructor(e={}){this.subjectKeyIdentifier=new Rn,Object.assign(this,e)}}f([y({type:Rn})],Ea.prototype,"subjectKeyIdentifier",void 0),f([y({type:b.GeneralizedTime,optional:!0})],Ea.prototype,"date",void 0),f([y({type:_a,optional:!0})],Ea.prototype,"other",void 0);let Wi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Ea,context:0,implicit:!0,optional:!0})],Wi.prototype,"rKeyId",void 0),f([y({type:Fi,optional:!0})],Wi.prototype,"issuerAndSerialNumber",void 0),Wi=f([H({type:M.Choice})],Wi);class su{constructor(e={}){this.rid=new Wi,this.encryptedKey=new Qe,Object.assign(this,e)}}f([y({type:Wi})],su.prototype,"rid",void 0),f([y({type:Qe})],su.prototype,"encryptedKey",void 0);let Ia=iu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,iu.prototype)}};Ia=iu=f([H({type:M.Sequence,itemType:su})],Ia);class ou{constructor(e={}){this.algorithm=new se,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:se})],ou.prototype,"algorithm",void 0),f([y({type:b.BitString})],ou.prototype,"publicKey",void 0);let gi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0,optional:!0})],gi.prototype,"subjectKeyIdentifier",void 0),f([y({type:ou,context:1,implicit:!0,optional:!0})],gi.prototype,"originatorKey",void 0),f([y({type:Fi,optional:!0})],gi.prototype,"issuerAndSerialNumber",void 0),gi=f([H({type:M.Choice})],gi);class Yi{constructor(e={}){this.version=tn.v3,this.originator=new gi,this.keyEncryptionAlgorithm=new rn,this.recipientEncryptedKeys=new Ia,Object.assign(this,e)}}f([y({type:b.Integer})],Yi.prototype,"version",void 0),f([y({type:gi,context:0})],Yi.prototype,"originator",void 0),f([y({type:Qe,context:1,optional:!0})],Yi.prototype,"ukm",void 0),f([y({type:rn})],Yi.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Ia})],Yi.prototype,"recipientEncryptedKeys",void 0);let Ji=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0})],Ji.prototype,"subjectKeyIdentifier",void 0),f([y({type:Fi})],Ji.prototype,"issuerAndSerialNumber",void 0),Ji=f([H({type:M.Choice})],Ji);class Ts{constructor(e={}){this.version=tn.v0,this.rid=new Ji,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new Qe,Object.assign(this,e)}}f([y({type:b.Integer})],Ts.prototype,"version",void 0),f([y({type:Ji})],Ts.prototype,"rid",void 0),f([y({type:rn})],Ts.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Qe})],Ts.prototype,"encryptedKey",void 0);class Ns{constructor(e={}){this.keyIdentifier=new Qe,Object.assign(this,e)}}f([y({type:Qe})],Ns.prototype,"keyIdentifier",void 0),f([y({type:b.GeneralizedTime,optional:!0})],Ns.prototype,"date",void 0),f([y({type:_a,optional:!0})],Ns.prototype,"other",void 0);class js{constructor(e={}){this.version=tn.v4,this.kekid=new Ns,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new Qe,Object.assign(this,e)}}f([y({type:b.Integer})],js.prototype,"version",void 0),f([y({type:Ns})],js.prototype,"kekid",void 0),f([y({type:rn})],js.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Qe})],js.prototype,"encryptedKey",void 0);class Ps{constructor(e={}){this.version=tn.v0,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new Qe,Object.assign(this,e)}}f([y({type:b.Integer})],Ps.prototype,"version",void 0),f([y({type:Fl,context:0,optional:!0})],Ps.prototype,"keyDerivationAlgorithm",void 0),f([y({type:rn})],Ps.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Qe})],Ps.prototype,"encryptedKey",void 0);class au{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],au.prototype,"oriType",void 0),f([y({type:b.Any})],au.prototype,"oriValue",void 0);let Un=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Ts,optional:!0})],Un.prototype,"ktri",void 0),f([y({type:Yi,context:1,implicit:!0,optional:!0})],Un.prototype,"kari",void 0),f([y({type:js,context:2,implicit:!0,optional:!0})],Un.prototype,"kekri",void 0),f([y({type:Ps,context:3,implicit:!0,optional:!0})],Un.prototype,"pwri",void 0),f([y({type:au,context:4,implicit:!0,optional:!0})],Un.prototype,"ori",void 0),Un=f([H({type:M.Choice})],Un);var cu;let ka=cu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,cu.prototype)}};ka=cu=f([H({type:M.Set,itemType:Un})],ka);var lu;class Ca{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Ca.prototype,"otherRevInfoFormat",void 0),f([y({type:b.Any})],Ca.prototype,"otherRevInfo",void 0);let Ba=class{constructor(e={}){this.other=new Ca,Object.assign(this,e)}};f([y({type:Ca,context:1,implicit:!0})],Ba.prototype,"other",void 0),Ba=f([H({type:M.Choice})],Ba);let Oa=lu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,lu.prototype)}};Oa=lu=f([H({type:M.Set,itemType:Ba})],Oa);class uu{constructor(e={}){Object.assign(this,e)}}f([y({type:Cs,context:0,implicit:!0,optional:!0})],uu.prototype,"certs",void 0),f([y({type:Oa,context:1,implicit:!0,optional:!0})],uu.prototype,"crls",void 0);var fu;let hu=fu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,fu.prototype)}};hu=fu=f([H({type:M.Set,itemType:Gi})],hu);class Rs{constructor(e={}){this.version=tn.v0,this.recipientInfos=new ka,this.encryptedContentInfo=new Os,Object.assign(this,e)}}f([y({type:b.Integer})],Rs.prototype,"version",void 0),f([y({type:uu,context:0,implicit:!0,optional:!0})],Rs.prototype,"originatorInfo",void 0),f([y({type:ka})],Rs.prototype,"recipientInfos",void 0),f([y({type:Os})],Rs.prototype,"encryptedContentInfo",void 0),f([y({type:hu,context:1,implicit:!0,optional:!0})],Rs.prototype,"unprotectedAttrs",void 0);const Hg="1.2.840.113549.1.7.1",du="1.2.840.113549.1.7.2";var pu;let Ta=pu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,pu.prototype)}};Ta=pu=f([H({type:M.Set,itemType:Is})],Ta);class In{constructor(e={}){this.version=tn.v0,this.digestAlgorithms=new Ta,this.encapContentInfo=new Sa,this.signerInfos=new pa,Object.assign(this,e)}}f([y({type:b.Integer})],In.prototype,"version",void 0),f([y({type:Ta})],In.prototype,"digestAlgorithms",void 0),f([y({type:Sa})],In.prototype,"encapContentInfo",void 0),f([y({type:Cs,context:0,implicit:!0,optional:!0})],In.prototype,"certificates",void 0),f([y({type:Oa,context:1,implicit:!0,optional:!0})],In.prototype,"crls",void 0),f([y({type:pa})],In.prototype,"signerInfos",void 0);const Us="1.2.840.10045.2.1",yu="1.2.840.10045.4.1",vd="1.2.840.10045.4.3.1",gu="1.2.840.10045.4.3.2",vu="1.2.840.10045.4.3.3",mu="1.2.840.10045.4.3.4",md="1.2.840.10045.3.1.7",wd="1.3.132.0.34",bd="1.3.132.0.35";function Ds(r){return new se({algorithm:r})}const Fg=Ds(yu);Ds(vd);const zg=Ds(gu),Gg=Ds(vu),Kg=Ds(mu);let $s=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],$s.prototype,"fieldType",void 0),f([y({type:b.Any})],$s.prototype,"parameters",void 0),$s=f([H({type:M.Sequence})],$s);class qg extends Qe{}let Xi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.OctetString})],Xi.prototype,"a",void 0),f([y({type:b.OctetString})],Xi.prototype,"b",void 0),f([y({type:b.BitString,optional:!0})],Xi.prototype,"seed",void 0),Xi=f([H({type:M.Sequence})],Xi);var wu;(function(r){r[r.ecpVer1=1]="ecpVer1"})(wu||(wu={}));let kn=class{constructor(e={}){this.version=wu.ecpVer1,Object.assign(this,e)}};f([y({type:b.Integer})],kn.prototype,"version",void 0),f([y({type:$s})],kn.prototype,"fieldID",void 0),f([y({type:Xi})],kn.prototype,"curve",void 0),f([y({type:qg})],kn.prototype,"base",void 0),f([y({type:b.Integer,converter:At})],kn.prototype,"order",void 0),f([y({type:b.Integer,optional:!0})],kn.prototype,"cofactor",void 0),kn=f([H({type:M.Sequence})],kn);let Dn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Dn.prototype,"namedCurve",void 0),f([y({type:b.Null})],Dn.prototype,"implicitCurve",void 0),f([y({type:kn})],Dn.prototype,"specifiedCurve",void 0),Dn=f([H({type:M.Choice})],Dn);class Na{constructor(e={}){this.version=1,this.privateKey=new Qe,Object.assign(this,e)}}f([y({type:b.Integer})],Na.prototype,"version",void 0),f([y({type:Qe})],Na.prototype,"privateKey",void 0),f([y({type:Dn,context:0,optional:!0})],Na.prototype,"parameters",void 0),f([y({type:b.BitString,context:1,optional:!0})],Na.prototype,"publicKey",void 0);class ja{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:At})],ja.prototype,"r",void 0),f([y({type:b.Integer,converter:At})],ja.prototype,"s",void 0);const mr="1.2.840.113549.1.1",vi=`${mr}.1`,Zg=`${mr}.7`,Wg=`${mr}.9`,Ms=`${mr}.10`,Yg=`${mr}.2`,Jg=`${mr}.4`,Pa=`${mr}.5`,Xg=`${mr}.14`,bu=`${mr}.11`,Ra=`${mr}.12`,Ua=`${mr}.13`,xd=`${mr}.15`,Ad=`${mr}.16`,Da="1.3.14.3.2.26",Sd="2.16.840.1.101.3.4.2.4",$a="2.16.840.1.101.3.4.2.1",Ma="2.16.840.1.101.3.4.2.2",Va="2.16.840.1.101.3.4.2.3",Qg="2.16.840.1.101.3.4.2.5",ev="2.16.840.1.101.3.4.2.6",tv="1.2.840.113549.2.2",rv="1.2.840.113549.2.5",La=`${mr}.8`;function Gt(r){return new se({algorithm:r,parameters:null})}Gt(tv),Gt(rv);const mi=Gt(Da);Gt(Sd),Gt($a),Gt(Ma),Gt(Va),Gt(Qg),Gt(ev);const _d=new se({algorithm:La,parameters:q.serialize(mi)}),Ed=new se({algorithm:Wg,parameters:q.serialize(Xo.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Gt(vi),Gt(Yg),Gt(Jg),Gt(Pa),Gt(xd),Gt(Ad),Gt(Ra),Gt(Ua),Gt(xd),Gt(Ad);class Ha{constructor(e={}){this.hashAlgorithm=new se(mi),this.maskGenAlgorithm=new se({algorithm:La,parameters:q.serialize(mi)}),this.pSourceAlgorithm=new se(Ed),Object.assign(this,e)}}f([y({type:se,context:0,defaultValue:mi})],Ha.prototype,"hashAlgorithm",void 0),f([y({type:se,context:1,defaultValue:_d})],Ha.prototype,"maskGenAlgorithm",void 0),f([y({type:se,context:2,defaultValue:Ed})],Ha.prototype,"pSourceAlgorithm",void 0),new se({algorithm:Zg,parameters:q.serialize(new Ha)});class wi{constructor(e={}){this.hashAlgorithm=new se(mi),this.maskGenAlgorithm=new se({algorithm:La,parameters:q.serialize(mi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([y({type:se,context:0,defaultValue:mi})],wi.prototype,"hashAlgorithm",void 0),f([y({type:se,context:1,defaultValue:_d})],wi.prototype,"maskGenAlgorithm",void 0),f([y({type:b.Integer,context:2,defaultValue:20})],wi.prototype,"saltLength",void 0),f([y({type:b.Integer,context:3,defaultValue:1})],wi.prototype,"trailerField",void 0),new se({algorithm:Ms,parameters:q.serialize(new wi)});class Fa{constructor(e={}){this.digestAlgorithm=new se,this.digest=new Qe,Object.assign(this,e)}}f([y({type:se})],Fa.prototype,"digestAlgorithm",void 0),f([y({type:Qe})],Fa.prototype,"digest",void 0);var xu;class za{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:At})],za.prototype,"prime",void 0),f([y({type:b.Integer,converter:At})],za.prototype,"exponent",void 0),f([y({type:b.Integer,converter:At})],za.prototype,"coefficient",void 0);let Au=xu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,xu.prototype)}};Au=xu=f([H({type:M.Sequence,itemType:za})],Au);class sn{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)}}f([y({type:b.Integer})],sn.prototype,"version",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"modulus",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"publicExponent",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"privateExponent",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"prime1",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"prime2",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"exponent1",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"exponent2",void 0),f([y({type:b.Integer,converter:At})],sn.prototype,"coefficient",void 0),f([y({type:Au,optional:!0})],sn.prototype,"otherPrimeInfos",void 0);class Su{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:At})],Su.prototype,"modulus",void 0),f([y({type:b.Integer,converter:At})],Su.prototype,"publicExponent",void 0);var _u;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(_u||(_u={}));const wr=_u;/*! *****************************************************************************
75
+ `)}`:`${t} :`}}qf=vr,ae.Constructed=qf,vr.NAME="CONSTRUCTED";class Zf extends lr{fromBER(e,t,n){return t}toBER(e){return Mr}}Zf.override="EndOfContentValueBlock";var Wf;class Wc extends Wt{constructor(e={}){super(e,Zf),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}Wf=Wc,ae.EndOfContent=Wf,Wc.NAME=ms;var Yf;class ii extends Wt{constructor(e={}){super(e,lr),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const i=new Uint8Array(n);i[0]=5,i[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}Yf=ii,ae.Null=Yf,ii.NAME="NULL";class Jf extends Xr(lr){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Y.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){const i=Y.toUint8Array(e);return vn(this,i,t,n)?(this.valueHexView=i.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Df.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Jf.NAME="BooleanValueBlock";var Xf;let Uo=class extends Wt{constructor(e={}){super(e,Jf),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}`}};Xf=Uo,ae.Boolean=Xf,Uo.NAME="BOOLEAN";class Qf extends Xr(Pn){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=Pn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(let s=0;s<this.value.length;s++){const o=this.value[s].constructor.NAME;if(o===ms){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(o!==Vf)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?Pn.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Qf.NAME="OctetStringValueBlock";var eh;let si=class _y extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Qf),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){const o=ji(s,0,s.byteLength);o.offset!==-1&&o.offset===n&&(this.valueBlock.value=[o.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?vr.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${ue.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 _y&&e.push(t.valueBlock.valueHexView);return Y.concat(e)}};eh=si,ae.OctetString=eh,si.NAME=Vf;class th extends Xr(Pn){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let i=-1;if(this.isConstructed){if(i=Pn.prototype.fromBER.call(this,e,t,n),i===-1)return i;for(const c of this.value){const u=c.constructor.NAME;if(u===ms){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(u!==Lf)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const h=c.valueBlock;if(this.unusedBits>0&&h.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=h.unusedBits}return i}const s=Y.toUint8Array(e);if(!vn(this,s,t,n))return-1;const o=s.subarray(t,t+n);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 c=o.subarray(1);try{if(c.byteLength){const u=ji(c,0,c.byteLength);u.offset!==-1&&u.offset===n-1&&(this.value=[u.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+n}toBER(e,t){if(this.isConstructed)return Pn.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Mr;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}th.NAME="BitStringValueBlock";var rh;let oi=class extends Wt{constructor({idBlock:e={},lenBlock:t={},...n}={}){var i,s;(i=n.isConstructed)!==null&&i!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},th),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return vr.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const i of t)e.push(i.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};rh=oi,ae.BitString=rh,oi.NAME=Lf;var nh;function og(r,e){const t=new Uint8Array([0]),n=new Uint8Array(r),i=new Uint8Array(e);let s=n.slice(0);const o=s.length-1,c=i.slice(0),u=c.length-1;let h=0;const m=u<o?o:u;let x=0;for(let G=m;G>=0;G--,x++){switch(!0){case x<c.length:h=s[o-x]+c[u-x]+t[0];break;default:h=s[o-x]+t[0]}switch(t[0]=h/10,!0){case x>=s.length:s=Gc(new Uint8Array([h%10]),s);break;default:s[o-x]=h%10}}return t[0]>0&&(s=Gc(t,s)),s}function ih(r){if(r>=vs.length)for(let e=vs.length;e<=r;e++){const t=new Uint8Array([0]);let n=vs[e-1].slice(0);for(let i=n.length-1;i>=0;i--){const s=new Uint8Array([(n[i]<<1)+t[0]]);t[0]=s[0]/10,n[i]=s[0]%10}t[0]>0&&(n=Gc(t,n)),vs.push(n)}return vs[r]}function ag(r,e){let t=0;const n=new Uint8Array(r),i=new Uint8Array(e),s=n.slice(0),o=s.length-1,c=i.slice(0),u=c.length-1;let h,m=0;for(let x=u;x>=0;x--,m++)switch(h=s[o-m]-c[u-m]-t,!0){case h<0:t=1,s[o-m]=h+10;break;default:t=0,s[o-m]=h}if(t>0)for(let x=o-u+1;x>=0;x--,m++)if(h=s[o-m]-t,h<0)t=1,s[o-m]=h+10;else{t=0,s[o-m]=h;break}return s.slice()}class Yc extends Xr(lr){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=Df.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Zy(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,i=0){const s=this.fromBER(e,t,n);if(s===-1)return s;const o=this.valueHexView;return o[0]===0&&o[1]&128?this.valueHexView=o.subarray(1):i!==0&&o.length<i&&(i-o.length>1&&(i=o.length+1),this.valueHexView=o.subarray(i-o.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{const n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){const i=super.fromBER(e,t,n);return i===-1||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=this.valueHexView.length*8-1;let t=new Uint8Array(this.valueHexView.length*8/3),n=0,i;const s=this.valueHexView;let o="",c=!1;for(let u=s.byteLength-1;u>=0;u--){i=s[u];for(let h=0;h<8;h++){if((i&1)===1)switch(n){case e:t=ag(ih(n),t),o="-";break;default:t=og(t,ih(n))}n++,i>>=1}}for(let u=0;u<t.length;u++)t[u]&&(c=!0),c&&(o+=$f.charAt(t[u]));return c===!1&&(o+=$f.charAt(0)),o}}nh=Yc,Yc.NAME="IntegerValueBlock",Object.defineProperty(nh.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var sh;class Qr extends Wt{constructor(e={}){super(e,Yc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Po(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Po();const t=BigInt(e),n=new jo,i=t.toString(16).replace(/^-/,""),s=new Uint8Array(ue.FromHex(i));if(t<0){const c=new Uint8Array(s.length+(s[0]&128?1:0));c[0]|=128;const h=BigInt(`0x${ue.ToHex(c)}`)+t,m=Y.toUint8Array(ue.FromHex(h.toString(16)));m[0]|=128,n.write(m)}else s[0]&128&&n.write(new Uint8Array([0])),n.write(s);return new Qr({valueHex:n.final()})}convertToDER(){const e=new Qr({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Qr({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}sh=Qr,ae.Integer=sh,Qr.NAME="INTEGER";var oh;class Do extends Qr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}oh=Do,ae.Enumerated=oh,Do.NAME="ENUMERATED";class Jc extends Xr(lr){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const i=Y.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Pi(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Po();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let i=0;i<n.length;i++)n[i]=parseInt(t.slice(i*7,i*7+7),2)+(i+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ri(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Mr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n}toString(){let e="";if(this.isHexOnly)e=ue.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}}}Jc.NAME="sidBlock";class ah extends lr{constructor({value:e=gr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Jc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const i=this.value[n].toBER(e);if(i.byteLength===0)return this.error=this.value[n].error,Mr;t.push(i)}return Kc(t)}fromString(e){this.value=[];let t=0,n=0,i="",s=!1;do if(n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1,s){const o=this.value[0];let c=0;switch(o.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}const u=parseInt(i,10);if(isNaN(u))return;o.valueDec=u+c,s=!1}else{const o=new Jc;if(i>Number.MAX_SAFE_INTEGER){Po();const c=BigInt(i);o.valueBigInt=c}else if(o.valueDec=parseInt(i,10),isNaN(o.valueDec))return;this.value.length||(o.isFirstSid=!0,s=!0),this.value.push(o)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t?(i=`{${i}}`,this.value[n].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}}ah.NAME="ObjectIdentifierValueBlock";var ch;class $o extends Wt{constructor(e={}){super(e,ah),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ch=$o,ae.ObjectIdentifier=ch,$o.NAME="OBJECT IDENTIFIER";class Xc extends Xr(ni){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;const i=Y.toUint8Array(e);if(!vn(this,i,t,n))return-1;const s=i.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=s[c]&127,this.blockLength++,!!(s[c]&128));c++);const o=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)o[c]=this.valueHexView[c];return this.valueHexView=o,s[this.blockLength-1]&128?(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=Pi(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 i=this.valueHexView,s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength-1;o++)s[o]=i[o]|128;return s[this.blockLength-1]=i[this.blockLength-1],s.buffer}const t=ri(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Mr;const n=new Uint8Array(t.byteLength);if(!e){const i=new Uint8Array(t),s=t.byteLength-1;for(let o=0;o<s;o++)n[o]=i[o]|128;n[s]=i[s]}return n.buffer}toString(){let e="";return this.isHexOnly?e=ue.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}Xc.NAME="relativeSidBlock";class lh extends lr{constructor({value:e=gr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let i=t;for(;n>0;){const s=new Xc;if(i=s.fromBER(e,i,n),i===-1)return this.blockLength=0,this.error=s.error,i;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return i}toBER(e,t){const n=[];for(let i=0;i<this.value.length;i++){const s=this.value[i].toBER(e);if(s.byteLength===0)return this.error=this.value[i].error,Mr;n.push(s)}return Kc(n)}fromString(e){this.value=[];let t=0,n=0,i="";do{n=e.indexOf(".",t),n===-1?i=e.substring(t):i=e.substring(t,n),t=n+1;const s=new Xc;if(s.valueDec=parseInt(i,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let i=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(i=`{${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}}lh.NAME="RelativeObjectIdentifierValueBlock";var uh;class Qc extends Wt{constructor(e={}){super(e,lh),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}uh=Qc,ae.RelativeObjectIdentifier=uh,Qc.NAME="RelativeObjectIdentifier";var fh;class mn extends vr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}fh=mn,ae.Sequence=fh,mn.NAME="SEQUENCE";var hh;let wn=class extends vr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};hh=wn,ae.Set=hh,wn.NAME="SET";class dh extends Xr(lr){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=gr}toJSON(){return{...super.toJSON(),value:this.value}}}dh.NAME="StringValueBlock";class ph extends dh{}ph.NAME="SimpleStringValueBlock";class Er extends Zc{constructor({...e}={}){super(e,ph)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Y.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);this.valueBlock.value=e}}Er.NAME="SIMPLE STRING";class yh extends Er{fromBuffer(e){this.valueBlock.valueHexView=Y.toUint8Array(e);try{this.valueBlock.value=ue.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=ue.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(ue.FromUtf8String(e)),this.valueBlock.value=e}}yh.NAME="Utf8StringValueBlock";var gh;class bn extends yh{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}gh=bn,ae.Utf8String=gh,bn.NAME="UTF8String";class vh extends Er{fromBuffer(e){this.valueBlock.value=ue.ToUtf16String(e),this.valueBlock.valueHexView=Y.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(ue.FromUtf16String(e))}}vh.NAME="BmpStringValueBlock";var mh;class Mo extends vh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}mh=Mo,ae.BmpString=mh,Mo.NAME="BMPString";class wh extends Er{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let i=0;i<n.length;i+=4)n[i]=n[i+3],n[i+1]=n[i+2],n[i+2]=0,n[i+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let i=0;i<t;i++){const s=ri(e.charCodeAt(i),8),o=new Uint8Array(s);if(o.length>4)continue;const c=4-o.length;for(let u=o.length-1;u>=0;u--)n[i*4+u+c]=o[u]}this.valueBlock.value=e}}wh.NAME="UniversalStringValueBlock";var bh;class Vo extends wh{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}bh=Vo,ae.UniversalString=bh,Vo.NAME="UniversalString";var xh;class Lo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}xh=Lo,ae.NumericString=xh,Lo.NAME="NumericString";var Ah;class Ho extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ah=Ho,ae.PrintableString=Ah,Ho.NAME="PrintableString";var Sh;class Fo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Sh=Fo,ae.TeletexString=Sh,Fo.NAME="TeletexString";var _h;class zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}_h=zo,ae.VideotexString=_h,zo.NAME="VideotexString";var Eh;class Go extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Eh=Go,ae.IA5String=Eh,Go.NAME="IA5String";var Ih;class Ko extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ih=Ko,ae.GraphicString=Ih,Ko.NAME="GraphicString";var kh;class bs extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}kh=bs,ae.VisibleString=kh,bs.NAME="VisibleString";var Ch;class qo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ch=qo,ae.GeneralString=Ch,qo.NAME="GeneralString";var Bh;class Zo extends Er{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Bh=Zo,ae.CharacterString=Bh,Zo.NAME="CharacterString";var Oh;class xs extends bs{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let i=0;i<e.length;i++)this.valueBlock.valueHexView[i]=e.charCodeAt(i)}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,Y.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);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 n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}const i=parseInt(n[1],10);i>=50?this.year=1900+i:this.year=2e3+i,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){const t=new Array(7);return t[0]=_r(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_r(this.month,2),t[2]=_r(this.day,2),t[3]=_r(this.hour,2),t[4]=_r(this.minute,2),t[5]=_r(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Oh=xs,ae.UTCTime=Oh,xs.NAME="UTCTime";var Th;class Wo extends xs{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",i="",s=0,o,c=0,u=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{const x=new Number(e[e.length-1]);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let x=1,G=n.indexOf("+"),N="";if(G===-1&&(G=n.indexOf("-"),x=-1),G!==-1){if(N=n.substring(G+1),n=n.substring(0,G),N.length!==2&&N.length!==4)throw new Error("Wrong input string for conversion");let v=parseInt(N.substring(0,2),10);if(isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");if(c=x*v,N.length===4){if(v=parseInt(N.substring(2,4),10),isNaN(v.valueOf()))throw new Error("Wrong input string for conversion");u=x*v}}}let h=n.indexOf(".");if(h===-1&&(h=n.indexOf(",")),h!==-1){const x=new Number(`0${n.substring(h)}`);if(isNaN(x.valueOf()))throw new Error("Wrong input string for conversion");s=x.valueOf(),i=n.substring(0,h)}else i=n;switch(!0){case i.length===8:if(o=/(\d{4})(\d{2})(\d{2})/ig,h!==-1)throw new Error("Wrong input string for conversion");break;case i.length===10:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.minute=Math.floor(x),x=60*(x-this.minute),this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===12:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){let x=60*s;this.second=Math.floor(x),x=1e3*(x-this.second),this.millisecond=Math.floor(x)}break;case i.length===14:if(o=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,h!==-1){const x=1e3*s;this.millisecond=Math.floor(x)}break;default:throw new Error("Wrong input string for conversion")}const m=o.exec(i);if(m===null)throw new Error("Wrong input string for conversion");for(let x=1;x<m.length;x++)switch(x){case 1:this.year=parseInt(m[x],10);break;case 2:this.month=parseInt(m[x],10);break;case 3:this.day=parseInt(m[x],10);break;case 4:this.hour=parseInt(m[x],10)+c;break;case 5:this.minute=parseInt(m[x],10)+u;break;case 6:this.second=parseInt(m[x],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){const x=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=x.getUTCFullYear(),this.month=x.getUTCMonth(),this.day=x.getUTCDay(),this.hour=x.getUTCHours(),this.minute=x.getUTCMinutes(),this.second=x.getUTCSeconds(),this.millisecond=x.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){const t=[];return t.push(_r(this.year,4)),t.push(_r(this.month,2)),t.push(_r(this.day,2)),t.push(_r(this.hour,2)),t.push(_r(this.minute,2)),t.push(_r(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_r(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Th=Wo,ae.GeneralizedTime=Th,Wo.NAME="GeneralizedTime";var Nh;class el extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Nh=el,ae.DATE=Nh,el.NAME="DATE";var Ph;class tl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Ph=tl,ae.TimeOfDay=Ph,tl.NAME="TimeOfDay";var jh;class rl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}jh=rl,ae.DateTime=jh,rl.NAME="DateTime";var Rh;class nl extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Rh=nl,ae.Duration=Rh,nl.NAME="Duration";var Uh;class il extends bn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Uh=il,ae.TIME=Uh,il.NAME="TIME";class ai{constructor({name:e=gr,optional:t=!1}={}){this.name=e,this.optional=t}}class sl extends ai{constructor({value:e=[],...t}={}){super(t),this.value=e}}class Yo extends ai{constructor({value:e=new ai,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}}class cg{constructor({data:e=Ro}={}){this.dataView=Y.toUint8Array(e)}get data(){return this.dataView.slice().buffer}set data(e){this.dataView=Y.toUint8Array(e)}fromBER(e,t,n){const i=t+n;return this.dataView=Y.toUint8Array(e).subarray(t,i),i}toBER(e){return this.dataView.slice().buffer}}function ci(r,e,t){if(t instanceof sl){for(let s=0;s<t.value.length;s++)if(ci(r,e,t.value[s]).verified)return{verified:!0,result:r};{const s={verified:!1,result:{error:"Wrong values for Choice type"}};return t.hasOwnProperty(qc)&&(s.name=t.name),s}}if(t instanceof ai)return t.hasOwnProperty(qc)&&(r[t.name]=e),{verified:!0,result:r};if(!(r instanceof Object))return{verified:!1,result:{error:"Wrong root object"}};if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(!(t instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(Jy in t))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(tg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(!(rg in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=t.idBlock.toBER(!1);if(n.byteLength===0)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(t.idBlock.fromBER(n,0,n.byteLength)===-1)return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(t.idBlock.hasOwnProperty(Xy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagClass!==e.idBlock.tagClass)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(Qy)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.tagNumber!==e.idBlock.tagNumber)return{verified:!1,result:r};if(t.idBlock.hasOwnProperty(eg)===!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isConstructed!==e.idBlock.isConstructed)return{verified:!1,result:r};if(!(Yy in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(t.idBlock.isHexOnly!==e.idBlock.isHexOnly)return{verified:!1,result:r};if(t.idBlock.isHexOnly){if(!(Mf in t.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const s=t.idBlock.valueHexView,o=e.idBlock.valueHexView;if(s.length!==o.length)return{verified:!1,result:r};for(let c=0;c<s.length;c++)if(s[c]!==o[1])return{verified:!1,result:r}}if(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(r[t.name]=e)),t instanceof ae.Constructed){let s=0,o={verified:!1,result:{error:"Unknown error"}},c=t.valueBlock.value.length;if(c>0&&t.valueBlock.value[0]instanceof Yo&&(c=e.valueBlock.value.length),c===0)return{verified:!0,result:r};if(e.valueBlock.value.length===0&&t.valueBlock.value.length!==0){let u=!0;for(let h=0;h<t.valueBlock.value.length;h++)u=u&&(t.valueBlock.value[h].optional||!1);return u?{verified:!0,result:r}:(t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),r.error="Inconsistent object length",{verified:!1,result:r})}for(let u=0;u<c;u++)if(u-s>=e.valueBlock.value.length){if(t.valueBlock.value[u].optional===!1){const h={verified:!1,result:r};return r.error="Inconsistent length between ASN.1 data and schema",t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],h.name=t.name)),h}}else if(t.valueBlock.value[0]instanceof Yo){if(o=ci(r,e.valueBlock.value[u],t.valueBlock.value[0].value),o.verified===!1)if(t.valueBlock.value[0].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),o;if(qc in t.valueBlock.value[0]&&t.valueBlock.value[0].name.length>0){let h={};ng in t.valueBlock.value[0]&&t.valueBlock.value[0].local?h=e:h=r,typeof h[t.valueBlock.value[0].name]>"u"&&(h[t.valueBlock.value[0].name]=[]),h[t.valueBlock.value[0].name].push(e.valueBlock.value[u])}}else if(o=ci(r,e.valueBlock.value[u-s],t.valueBlock.value[u]),o.verified===!1)if(t.valueBlock.value[u].optional)s++;else return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&delete r[t.name]),o;if(o.verified===!1){const u={verified:!1,result:r};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],u.name=t.name)),u}return{verified:!0,result:r}}if(t.primitiveSchema&&Mf in e.valueBlock){const s=ji(e.valueBlock.valueHexView);if(s.offset===-1){const o={verified:!1,result:s.result};return t.name&&(t.name=t.name.replace(/^\s+|\s+$/g,gr),t.name&&(delete r[t.name],o.name=t.name)),o}return ci(r,s.result,t.primitiveSchema)}return{verified:!0,result:r}}function lg(r,e){if(!(e instanceof Object))return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const t=ji(Y.toUint8Array(r));return t.offset===-1?{verified:!1,result:t.result}:ci(t.result,t.result,e)}const Dh=Object.freeze(Object.defineProperty({__proto__:null,Any:ai,BaseBlock:Wt,BaseStringBlock:Zc,BitString:oi,BmpString:Mo,Boolean:Uo,CharacterString:Zo,Choice:sl,Constructed:vr,DATE:el,DateTime:rl,Duration:nl,EndOfContent:Wc,Enumerated:Do,GeneralString:qo,GeneralizedTime:Wo,GraphicString:Ko,HexBlock:Xr,IA5String:Go,Integer:Qr,Null:ii,NumericString:Lo,ObjectIdentifier:$o,OctetString:si,Primitive:ws,PrintableString:Ho,RawData:cg,RelativeObjectIdentifier:Qc,Repeated:Yo,Sequence:mn,Set:wn,TIME:il,TeletexString:Fo,TimeOfDay:tl,UTCTime:xs,UniversalString:Vo,Utf8String:bn,ValueBlock:lr,VideotexString:zo,ViewWriter:jo,VisibleString:bs,compareSchema:ci,fromBER:Ri,verifySchema:lg},Symbol.toStringTag,{value:"Module"}));var M;(function(r){r[r.Sequence=0]="Sequence",r[r.Set=1]="Set",r[r.Choice=2]="Choice"})(M||(M={}));var b;(function(r){r[r.Any=1]="Any",r[r.Boolean=2]="Boolean",r[r.OctetString=3]="OctetString",r[r.BitString=4]="BitString",r[r.Integer=5]="Integer",r[r.Enumerated=6]="Enumerated",r[r.ObjectIdentifier=7]="ObjectIdentifier",r[r.Utf8String=8]="Utf8String",r[r.BmpString=9]="BmpString",r[r.UniversalString=10]="UniversalString",r[r.NumericString=11]="NumericString",r[r.PrintableString=12]="PrintableString",r[r.TeletexString=13]="TeletexString",r[r.VideotexString=14]="VideotexString",r[r.IA5String=15]="IA5String",r[r.GraphicString=16]="GraphicString",r[r.VisibleString=17]="VisibleString",r[r.GeneralString=18]="GeneralString",r[r.CharacterString=19]="CharacterString",r[r.UTCTime=20]="UTCTime",r[r.GeneralizedTime=21]="GeneralizedTime",r[r.DATE=22]="DATE",r[r.TimeOfDay=23]="TimeOfDay",r[r.DateTime=24]="DateTime",r[r.Duration=25]="Duration",r[r.TIME=26]="TIME",r[r.Null=27]="Null"})(b||(b={}));class Jo{constructor(e,t=0){if(this.unusedBits=0,this.value=new ArrayBuffer(0),e)if(typeof e=="number")this.fromNumber(e);else if(Y.isBufferSource(e))this.unusedBits=t,this.value=Y.toArrayBuffer(e);else throw TypeError("Unsupported type of 'params' argument for BitString")}fromASN(e){if(!(e instanceof oi))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 oi({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new oi({name:e})}toNumber(){let e="";const t=new Uint8Array(this.value);for(const n of t)e+=n.toString(2).padStart(8,"0");return e=e.split("").reverse().join(""),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,"0")),parseInt(e,2)}fromNumber(e){let t=e.toString(2);const n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;const i=new Uint8Array(n);t=t.padStart(n<<3,"0").split("").reverse().join("");let s=0;for(;s<n;)i[s]=parseInt(t.slice(s<<3,(s<<3)+8),2),s++;this.value=i.buffer}}class tt{get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e=="number"?this.buffer=new ArrayBuffer(e):Y.isBufferSource(e)?this.buffer=Y.toArrayBuffer(e):Array.isArray(e)?this.buffer=new Uint8Array(e):this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof si))throw new TypeError("Argument 'asn' is not instance of ASN.1 OctetString");return this.buffer=e.valueBlock.valueHex,this}toASN(){return new si({valueHex:this.buffer})}toSchema(e){return new si({name:e})}}const ug={fromASN:r=>r instanceof ii?null:r.valueBeforeDecodeView,toASN:r=>{if(r===null)return new ii;const e=Ri(r);if(e.result.error)throw new Error(e.result.error);return e.result}},fg={fromASN:r=>r.valueBlock.valueHexView.byteLength>=4?r.valueBlock.toString():r.valueBlock.valueDec,toASN:r=>new Qr({value:+r})},hg={fromASN:r=>r.valueBlock.valueDec,toASN:r=>new Do({value:r})},_t={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new Qr({valueHex:r})},dg={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new oi({valueHex:r})},pg={fromASN:r=>r.valueBlock.toString(),toASN:r=>new $o({value:r})},yg={fromASN:r=>r.valueBlock.value,toASN:r=>new Uo({value:r})},Xo={fromASN:r=>r.valueBlock.valueHexView,toASN:r=>new si({valueHex:r})},gg={fromASN:r=>new tt(r.getValue()),toASN:r=>r.toASN()};function Tr(r){return{fromASN:e=>e.valueBlock.value,toASN:e=>new r({value:e})}}const $h=Tr(bn),vg=Tr(Mo),mg=Tr(Vo),wg=Tr(Lo),bg=Tr(Ho),xg=Tr(Fo),Ag=Tr(zo),Sg=Tr(Go),_g=Tr(Ko),Eg=Tr(bs),Ig=Tr(qo),kg=Tr(Zo),Cg={fromASN:r=>r.toDate(),toASN:r=>new xs({valueDate:r})},Bg={fromASN:r=>r.toDate(),toASN:r=>new Wo({valueDate:r})},Og={fromASN:()=>null,toASN:()=>new ii};function ol(r){switch(r){case b.Any:return ug;case b.BitString:return dg;case b.BmpString:return vg;case b.Boolean:return yg;case b.CharacterString:return kg;case b.Enumerated:return hg;case b.GeneralString:return Ig;case b.GeneralizedTime:return Bg;case b.GraphicString:return _g;case b.IA5String:return Sg;case b.Integer:return fg;case b.Null:return Og;case b.NumericString:return wg;case b.ObjectIdentifier:return pg;case b.OctetString:return Xo;case b.PrintableString:return bg;case b.TeletexString:return xg;case b.UTCTime:return Cg;case b.UniversalString:return mg;case b.Utf8String:return $h;case b.VideotexString:return Ag;case b.VisibleString:return Eg;default:return null}}function xn(r){return typeof r=="function"&&r.prototype?r.prototype.toASN&&r.prototype.fromASN?!0:xn(r.prototype):!!(r&&typeof r=="object"&&"toASN"in r&&"fromASN"in r)}function Mh(r){var e;if(r){const t=Object.getPrototypeOf(r);return((e=t==null?void 0:t.prototype)===null||e===void 0?void 0:e.constructor)===Array?!0:Mh(t)}return!1}function Tg(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;const t=new Uint8Array(r),n=new Uint8Array(e);for(let i=0;i<r.byteLength;i++)if(t[i]!==n[i])return!1;return!0}class Ng{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const n=this.items.get(e);if(!n)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:M.Sequence,items:{}},n=this.findParentSchema(e);return n&&(Object.assign(t,n),t.items=Object.assign({},t.items,n.items)),t}create(e,t){const n=this.items.get(e)||this.createDefault(e),i=[];for(const s in n.items){const o=n.items[s],c=t?s:"";let u;if(typeof o.type=="number"){const m=b[o.type],x=Dh[m];if(!x)throw new Error(`Cannot get ASN1 class by name '${m}'`);u=new x({name:c})}else xn(o.type)?u=new o.type().toSchema(c):o.optional?this.get(o.type).type===M.Choice?u=new ai({name:c}):(u=this.create(o.type,!1),u.name=c):u=new ai({name:c});const h=!!o.optional||o.defaultValue!==void 0;if(o.repeated){u.name="";const m=o.repeated==="set"?wn:mn;u=new m({name:"",value:[new Yo({name:c,value:u})]})}if(o.context!==null&&o.context!==void 0)if(o.implicit)if(typeof o.type=="number"||xn(o.type)){const m=o.repeated?vr:ws;i.push(new m({name:c,optional:h,idBlock:{tagClass:3,tagNumber:o.context}}))}else{this.cache(o.type);const m=!!o.repeated;let x=m?u:this.get(o.type,!0).schema;x="valueBlock"in x?x.valueBlock.value:x.value,i.push(new vr({name:m?"":c,optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:x}))}else i.push(new vr({optional:h,idBlock:{tagClass:3,tagNumber:o.context},value:[u]}));else u.optional=h,i.push(u)}switch(n.type){case M.Sequence:return new mn({value:i,name:""});case M.Set:return new wn({value:i,name:""});case M.Choice:return new sl({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);return t?this.items.get(t)||this.findParentSchema(t):null}}const Nr=new Ng,H=r=>e=>{let t;Nr.has(e)?t=Nr.get(e):(t=Nr.createDefault(e),Nr.set(e,t)),Object.assign(t,r)},y=r=>(e,t)=>{let n;Nr.has(e.constructor)?n=Nr.get(e.constructor):(n=Nr.createDefault(e.constructor),Nr.set(e.constructor,n));const i=Object.assign({},r);if(typeof i.type=="number"&&!i.converter){const s=ol(r.type);if(!s)throw new Error(`Cannot get default converter for property '${t}' of ${e.constructor.name}`);i.converter=s}n.items[t]=i};class Vh extends Error{constructor(){super(...arguments),this.schemas=[]}}class Pg{static parse(e,t){const n=Ri(e);if(n.result.error)throw new Error(n.result.error);return this.fromASN(n.result,t)}static fromASN(e,t){var n;try{if(xn(t))return new t().fromASN(e);const i=Nr.get(t);Nr.cache(t);let s=i.schema;if(e.constructor===vr&&i.type!==M.Choice){s=new vr({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:i.schema.valueBlock.value});for(const u in i.items)delete e[u]}const o=ci({},e,s);if(!o.verified)throw new Vh(`Data does not match to ${t.name} ASN1 schema. ${o.result.error}`);const c=new t;if(Mh(t)){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 u=i.itemType;if(typeof u=="number"){const h=ol(u);if(!h)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,m=>h.fromASN(m))}else return t.from(e.valueBlock.value,h=>this.fromASN(h,u))}for(const u in i.items){const h=o.result[u];if(!h)continue;const m=i.items[u],x=m.type;if(typeof x=="number"||xn(x)){const G=(n=m.converter)!==null&&n!==void 0?n:xn(x)?new x:null;if(!G)throw new Error("Converter is empty");if(m.repeated)if(m.implicit){const N=m.repeated==="sequence"?mn:wn,v=new N;v.valueBlock=h.valueBlock;const A=Ri(v.toBER(!1));if(A.offset===-1)throw new Error(`Cannot parse the child item. ${A.result.error}`);if(!("value"in A.result.valueBlock&&Array.isArray(A.result.valueBlock.value)))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const O=A.result.valueBlock.value;c[u]=Array.from(O,I=>G.fromASN(I))}else c[u]=Array.from(h,N=>G.fromASN(N));else{let N=h;if(m.implicit){let v;if(xn(x))v=new x().toSchema("");else{const A=b[x],O=Dh[A];if(!O)throw new Error(`Cannot get '${A}' class from asn1js module`);v=new O}v.valueBlock=N.valueBlock,N=Ri(v.toBER(!1)).result}c[u]=G.fromASN(N)}}else if(m.repeated){if(!Array.isArray(h))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");c[u]=Array.from(h,G=>this.fromASN(G,x))}else c[u]=this.fromASN(h,x)}return c}catch(i){throw i instanceof Vh&&i.schemas.push(t.name),i}}}class al{static serialize(e){return e instanceof Wt?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&typeof e=="object"&&xn(e))return e.toASN();if(!(e&&typeof e=="object"))throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,n=Nr.get(t);Nr.cache(t);let i=[];if(n.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if(typeof n.itemType=="number"){const o=ol(n.itemType);if(!o)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);i=e.map(c=>o.toASN(c))}else i=e.map(o=>this.toAsnItem({type:n.itemType},"[]",t,o))}else for(const o in n.items){const c=n.items[o],u=e[o];if(u===void 0||c.defaultValue===u||typeof c.defaultValue=="object"&&typeof u=="object"&&Tg(this.serialize(c.defaultValue),this.serialize(u)))continue;const h=al.toAsnItem(c,o,t,u);if(typeof c.context=="number")if(c.implicit)if(!c.repeated&&(typeof c.type=="number"||xn(c.type))){const m={};m.valueHex=h instanceof ii?h.valueBeforeDecodeView:h.valueBlock.toBER(),i.push(new ws({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},...m}))}else i.push(new vr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:h.valueBlock.value}));else i.push(new vr({optional:c.optional,idBlock:{tagClass:3,tagNumber:c.context},value:[h]}));else c.repeated?i=i.concat(h):i.push(h)}let s;switch(n.type){case M.Sequence:s=new mn({value:i});break;case M.Set:s=new wn({value:i});break;case M.Choice:if(!i[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);s=i[0];break}return s}static toAsnItem(e,t,n,i){let s;if(typeof e.type=="number"){const o=e.converter;if(!o)throw new Error(`Property '${t}' doesn't have converter for type ${b[e.type]} in schema '${n.name}'`);if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const c=Array.from(i,h=>o.toASN(h)),u=e.repeated==="sequence"?mn:wn;s=new u({value:c})}else s=o.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw new TypeError("Parameter 'objProp' should be type of Array.");const o=Array.from(i,u=>this.toASN(u)),c=e.repeated==="sequence"?mn:wn;s=new c({value:o})}else s=this.toASN(i);return s}}class vt extends Array{constructor(e=[]){if(typeof e=="number")super(e);else{super();for(const t of e)this.push(t)}}}class q{static serialize(e){return al.serialize(e)}static parse(e,t){return Pg.parse(e,t)}static toString(e){const t=Y.isBufferSource(e)?Y.toArrayBuffer(e):q.serialize(e),n=Ri(t);if(n.offset===-1)throw new Error(`Cannot decode ASN.1 data. ${n.result.error}`);return n.result.toString()}}function f(r,e,t,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,n);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(s=(i<3?o(s):i>3?o(e,t,s):o(e,t))||s);return i>3&&s&&Object.defineProperty(e,t,s),s}typeof SuppressedError=="function"&&SuppressedError;var Lh={exports:{}};(function(r){(function(e){const t="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function h(v,A){if(v.indexOf("::")!==v.lastIndexOf("::"))return null;let O=0,I=-1,P=(v.match(u.zoneIndex)||[])[0],R,fe;for(P&&(P=P.substring(1),v=v.replace(/%.+$/,""));(I=v.indexOf(":",I+1))>=0;)O++;if(v.substr(0,2)==="::"&&O--,v.substr(-2,2)==="::"&&O--,O>A)return null;for(fe=A-O,R=":";fe--;)R+="0:";return v=v.replace("::",R),v[0]===":"&&(v=v.slice(1)),v[v.length-1]===":"&&(v=v.slice(0,-1)),A=function(){const qe=v.split(":"),Je=[];for(let Re=0;Re<qe.length;Re++)Je.push(parseInt(qe[Re],16));return Je}(),{parts:A,zoneId:P}}function m(v,A,O,I){if(v.length!==A.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P=0,R;for(;I>0;){if(R=O-I,R<0&&(R=0),v[P]>>R!==A[P]>>R)return!1;I-=O,P+=1}return!0}function x(v){if(s.test(v))return parseInt(v,16);if(v[0]==="0"&&!isNaN(parseInt(v[1],10))){if(i.test(v))return parseInt(v,8);throw new Error(`ipaddr: cannot parse ${v} as octal`)}return parseInt(v,10)}function G(v,A){for(;v.length<A;)v=`0${v}`;return v}const N={};N.IPv4=function(){function v(A){if(A.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let O,I;for(O=0;O<A.length;O++)if(I=A[O],!(0<=I&&I<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=A}return v.prototype.SpecialRanges={unspecified:[[new v([0,0,0,0]),8]],broadcast:[[new v([255,255,255,255]),32]],multicast:[[new v([224,0,0,0]),4]],linkLocal:[[new v([169,254,0,0]),16]],loopback:[[new v([127,0,0,0]),8]],carrierGradeNat:[[new v([100,64,0,0]),10]],private:[[new v([10,0,0,0]),8],[new v([172,16,0,0]),12],[new v([192,168,0,0]),16]],reserved:[[new v([192,0,0,0]),24],[new v([192,0,2,0]),24],[new v([192,88,99,0]),24],[new v([198,18,0,0]),15],[new v([198,51,100,0]),24],[new v([203,0,113,0]),24],[new v([240,0,0,0]),4]],as112:[[new v([192,175,48,0]),24],[new v([192,31,196,0]),24]],amt:[[new v([192,52,193,0]),24]]},v.prototype.kind=function(){return"ipv4"},v.prototype.match=function(A,O){let I;if(O===void 0&&(I=A,A=I[0],O=I[1]),A.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return m(this.octets,A.octets,8,O)},v.prototype.prefixLengthFromSubnetMask=function(){let A=0,O=!1;const I={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let P,R,fe;for(P=3;P>=0;P-=1)if(R=this.octets[P],R in I){if(fe=I[R],O&&fe!==0)return null;fe!==8&&(O=!0),A+=fe}else return null;return 32-A},v.prototype.range=function(){return N.subnetMatch(this,this.SpecialRanges)},v.prototype.toByteArray=function(){return this.octets.slice(0)},v.prototype.toIPv4MappedAddress=function(){return N.IPv6.parse(`::ffff:${this.toString()}`)},v.prototype.toNormalizedString=function(){return this.toString()},v.prototype.toString=function(){return this.octets.join(".")},v}(),N.IPv4.broadcastAddressFromCIDR=function(v){try{const A=this.parseCIDR(v),O=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let R=0;for(;R<4;)P.push(parseInt(O[R],10)|parseInt(I[R],10)^255),R++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},N.IPv4.isIPv4=function(v){return this.parser(v)!==null},N.IPv4.isValid=function(v){try{return new this(this.parser(v)),!0}catch{return!1}},N.IPv4.isValidCIDR=function(v){try{return this.parseCIDR(v),!0}catch{return!1}},N.IPv4.isValidFourPartDecimal=function(v){return!!(N.IPv4.isValid(v)&&v.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},N.IPv4.networkAddressFromCIDR=function(v){let A,O,I,P,R;try{for(A=this.parseCIDR(v),I=A[0].toByteArray(),R=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],O=0;O<4;)P.push(parseInt(I[O],10)&parseInt(R[O],10)),O++;return new this(P)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},N.IPv4.parse=function(v){const A=this.parser(v);if(A===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(A)},N.IPv4.parseCIDR=function(v){let A;if(A=v.match(/^(.+)\/(\d+)$/)){const O=parseInt(A[2]);if(O>=0&&O<=32){const I=[this.parse(A[1]),O];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},N.IPv4.parser=function(v){let A,O,I;if(A=v.match(n.fourOctet))return function(){const P=A.slice(1,6),R=[];for(let fe=0;fe<P.length;fe++)O=P[fe],R.push(x(O));return R}();if(A=v.match(n.longValue)){if(I=x(A[1]),I>4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const P=[];let R;for(R=0;R<=24;R+=8)P.push(I>>R&255);return P}().reverse()}else return(A=v.match(n.twoOctet))?function(){const P=A.slice(1,4),R=[];if(I=x(P[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return R.push(x(P[0])),R.push(I>>16&255),R.push(I>>8&255),R.push(I&255),R}():(A=v.match(n.threeOctet))?function(){const P=A.slice(1,5),R=[];if(I=x(P[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return R.push(x(P[0])),R.push(x(P[1])),R.push(I>>8&255),R.push(I&255),R}():null},N.IPv4.subnetMaskFromPrefixLength=function(v){if(v=parseInt(v),v<0||v>32)throw new Error("ipaddr: invalid IPv4 prefix length");const A=[0,0,0,0];let O=0;const I=Math.floor(v/8);for(;O<I;)A[O]=255,O++;return I<4&&(A[I]=Math.pow(2,v%8)-1<<8-v%8),new this(A)},N.IPv6=function(){function v(A,O){let I,P;if(A.length===16)for(this.parts=[],I=0;I<=14;I+=2)this.parts.push(A[I]<<8|A[I+1]);else if(A.length===8)this.parts=A;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(I=0;I<this.parts.length;I++)if(P=this.parts[I],!(0<=P&&P<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");O&&(this.zoneId=O)}return v.prototype.SpecialRanges={unspecified:[new v([0,0,0,0,0,0,0,0]),128],linkLocal:[new v([65152,0,0,0,0,0,0,0]),10],multicast:[new v([65280,0,0,0,0,0,0,0]),8],loopback:[new v([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new v([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new v([0,0,0,0,0,65535,0,0]),96],discard:[new v([256,0,0,0,0,0,0,0]),64],rfc6145:[new v([0,0,0,0,65535,0,0,0]),96],rfc6052:[new v([100,65435,0,0,0,0,0,0]),96],"6to4":[new v([8194,0,0,0,0,0,0,0]),16],teredo:[new v([8193,0,0,0,0,0,0,0]),32],benchmarking:[new v([8193,2,0,0,0,0,0,0]),48],amt:[new v([8193,3,0,0,0,0,0,0]),32],as112v6:[[new v([8193,4,274,0,0,0,0,0]),48],[new v([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new v([8193,16,0,0,0,0,0,0]),28],orchid2:[new v([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new v([8193,48,0,0,0,0,0,0]),28],reserved:[[new v([8193,0,0,0,0,0,0,0]),23],[new v([8193,3512,0,0,0,0,0,0]),32]]},v.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},v.prototype.kind=function(){return"ipv6"},v.prototype.match=function(A,O){let I;if(O===void 0&&(I=A,A=I[0],O=I[1]),A.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return m(this.parts,A.parts,16,O)},v.prototype.prefixLengthFromSubnetMask=function(){let A=0,O=!1;const I={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let P,R;for(let fe=7;fe>=0;fe-=1)if(P=this.parts[fe],P in I){if(R=I[P],O&&R!==0)return null;R!==16&&(O=!0),A+=R}else return null;return 128-A},v.prototype.range=function(){return N.subnetMatch(this,this.SpecialRanges)},v.prototype.toByteArray=function(){let A;const O=[],I=this.parts;for(let P=0;P<I.length;P++)A=I[P],O.push(A>>8),O.push(A&255);return O},v.prototype.toFixedLengthString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(G(this.parts[P].toString(16),4));return I}).call(this).join(":");let O="";return this.zoneId&&(O=`%${this.zoneId}`),A+O},v.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const A=this.parts.slice(-2),O=A[0],I=A[1];return new N.IPv4([O>>8,O&255,I>>8,I&255])},v.prototype.toNormalizedString=function(){const A=(function(){const I=[];for(let P=0;P<this.parts.length;P++)I.push(this.parts[P].toString(16));return I}).call(this).join(":");let O="";return this.zoneId&&(O=`%${this.zoneId}`),A+O},v.prototype.toRFC5952String=function(){const A=/((^|:)(0(:|$)){2,})/g,O=this.toNormalizedString();let I=0,P=-1,R;for(;R=A.exec(O);)R[0].length>P&&(I=R.index,P=R[0].length);return P<0?O:`${O.substring(0,I)}::${O.substring(I+P)}`},v.prototype.toString=function(){return this.toRFC5952String()},v}(),N.IPv6.broadcastAddressFromCIDR=function(v){try{const A=this.parseCIDR(v),O=A[0].toByteArray(),I=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[];let R=0;for(;R<16;)P.push(parseInt(O[R],10)|parseInt(I[R],10)^255),R++;return new this(P)}catch(A){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${A})`)}},N.IPv6.isIPv6=function(v){return this.parser(v)!==null},N.IPv6.isValid=function(v){if(typeof v=="string"&&v.indexOf(":")===-1)return!1;try{const A=this.parser(v);return new this(A.parts,A.zoneId),!0}catch{return!1}},N.IPv6.isValidCIDR=function(v){if(typeof v=="string"&&v.indexOf(":")===-1)return!1;try{return this.parseCIDR(v),!0}catch{return!1}},N.IPv6.networkAddressFromCIDR=function(v){let A,O,I,P,R;try{for(A=this.parseCIDR(v),I=A[0].toByteArray(),R=this.subnetMaskFromPrefixLength(A[1]).toByteArray(),P=[],O=0;O<16;)P.push(parseInt(I[O],10)&parseInt(R[O],10)),O++;return new this(P)}catch(fe){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${fe})`)}},N.IPv6.parse=function(v){const A=this.parser(v);if(A.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(A.parts,A.zoneId)},N.IPv6.parseCIDR=function(v){let A,O,I;if((O=v.match(/^(.+)\/(\d+)$/))&&(A=parseInt(O[2]),A>=0&&A<=128))return I=[this.parse(O[1]),A],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},N.IPv6.parser=function(v){let A,O,I,P,R,fe;if(I=v.match(u.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(u.native.test(v))return h(v,8);if((I=v.match(u.transitional))&&(fe=I[6]||"",A=I[1],I[1].endsWith("::")||(A=A.slice(0,-1)),A=h(A+fe,6),A.parts)){for(R=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],O=0;O<R.length;O++)if(P=R[O],!(0<=P&&P<=255))return null;return A.parts.push(R[0]<<8|R[1]),A.parts.push(R[2]<<8|R[3]),{parts:A.parts,zoneId:A.zoneId}}return null},N.IPv6.subnetMaskFromPrefixLength=function(v){if(v=parseInt(v),v<0||v>128)throw new Error("ipaddr: invalid IPv6 prefix length");const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let O=0;const I=Math.floor(v/8);for(;O<I;)A[O]=255,O++;return I<16&&(A[I]=Math.pow(2,v%8)-1<<8-v%8),new this(A)},N.fromByteArray=function(v){const A=v.length;if(A===4)return new N.IPv4(v);if(A===16)return new N.IPv6(v);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},N.isValid=function(v){return N.IPv6.isValid(v)||N.IPv4.isValid(v)},N.isValidCIDR=function(v){return N.IPv6.isValidCIDR(v)||N.IPv4.isValidCIDR(v)},N.parse=function(v){if(N.IPv6.isValid(v))return N.IPv6.parse(v);if(N.IPv4.isValid(v))return N.IPv4.parse(v);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},N.parseCIDR=function(v){try{return N.IPv6.parseCIDR(v)}catch{try{return N.IPv4.parseCIDR(v)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},N.process=function(v){const A=this.parse(v);return A.kind()==="ipv6"&&A.isIPv4MappedAddress()?A.toIPv4Address():A},N.subnetMatch=function(v,A,O){let I,P,R,fe;O==null&&(O="unicast");for(P in A)if(Object.prototype.hasOwnProperty.call(A,P)){for(R=A[P],R[0]&&!(R[0]instanceof Array)&&(R=[R]),I=0;I<R.length;I++)if(fe=R[I],v.kind()===fe[0].kind()&&v.match.apply(v,fe))return P}return O},r.exports?r.exports=N:e.ipaddr=N})(Fc)})(Lh);var Hh=Lh.exports;class Fh{static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return"::/0";if(e.length!==16)return e;const t=parseInt(e.slice(8),16).toString(2).split("").reduce((i,s)=>i+ +s,0);let n=e.slice(0,8).replace(/(.{2})/g,i=>`${parseInt(i,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){if(e.byteLength===4||e.byteLength===16){const t=new Uint8Array(e);return Hh.fromByteArray(Array.from(t)).toString()}return this.decodeIP(ue.ToHex(e))}static fromString(e){const t=Hh.parse(e);return new Uint8Array(t.toByteArray()).buffer}}var cl,ll,ul;let Yt=class{constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||""}};f([y({type:b.TeletexString})],Yt.prototype,"teletexString",void 0),f([y({type:b.PrintableString})],Yt.prototype,"printableString",void 0),f([y({type:b.UniversalString})],Yt.prototype,"universalString",void 0),f([y({type:b.Utf8String})],Yt.prototype,"utf8String",void 0),f([y({type:b.BmpString})],Yt.prototype,"bmpString",void 0),Yt=f([H({type:M.Choice})],Yt);let Ui=class extends Yt{constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?ue.ToHex(this.anyValue):super.toString())}};f([y({type:b.IA5String})],Ui.prototype,"ia5String",void 0),f([y({type:b.Any})],Ui.prototype,"anyValue",void 0),Ui=f([H({type:M.Choice})],Ui);class Qo{constructor(e={}){this.type="",this.value=new Ui,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Qo.prototype,"type",void 0),f([y({type:Ui})],Qo.prototype,"value",void 0);let Di=cl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,cl.prototype)}};Di=cl=f([H({type:M.Set,itemType:Qo})],Di);let fl=ll=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,ll.prototype)}};fl=ll=f([H({type:M.Sequence,itemType:Di})],fl);let zt=ul=class extends fl{constructor(e){super(e),Object.setPrototypeOf(this,ul.prototype)}};zt=ul=f([H({type:M.Sequence})],zt);const jg={fromASN:r=>Fh.toString(Xo.fromASN(r)),toASN:r=>Xo.toASN(Fh.fromString(r))};class As{constructor(e={}){this.typeId="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],As.prototype,"typeId",void 0),f([y({type:b.Any,context:0})],As.prototype,"value",void 0);class hl{constructor(e={}){this.partyName=new Yt,Object.assign(this,e)}}f([y({type:Yt,optional:!0,context:0,implicit:!0})],hl.prototype,"nameAssigner",void 0),f([y({type:Yt,context:1,implicit:!0})],hl.prototype,"partyName",void 0);let je=class{constructor(e={}){Object.assign(this,e)}};f([y({type:As,context:0,implicit:!0})],je.prototype,"otherName",void 0),f([y({type:b.IA5String,context:1,implicit:!0})],je.prototype,"rfc822Name",void 0),f([y({type:b.IA5String,context:2,implicit:!0})],je.prototype,"dNSName",void 0),f([y({type:b.Any,context:3,implicit:!0})],je.prototype,"x400Address",void 0),f([y({type:zt,context:4,implicit:!1})],je.prototype,"directoryName",void 0),f([y({type:hl,context:5})],je.prototype,"ediPartyName",void 0),f([y({type:b.IA5String,context:6,implicit:!0})],je.prototype,"uniformResourceIdentifier",void 0),f([y({type:b.OctetString,context:7,implicit:!0,converter:jg})],je.prototype,"iPAddress",void 0),f([y({type:b.ObjectIdentifier,context:8,implicit:!0})],je.prototype,"registeredID",void 0),je=f([H({type:M.Choice})],je);const dl="1.3.6.1.5.5.7",Rg=`${dl}.1`,$i=`${dl}.3`,ea=`${dl}.48`,zh=`${ea}.1`,Gh=`${ea}.2`,Kh=`${ea}.3`,qh=`${ea}.5`,jn="2.5.29";var pl;const yl=`${Rg}.1`;class Ss{constructor(e={}){this.accessMethod="",this.accessLocation=new je,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Ss.prototype,"accessMethod",void 0),f([y({type:je})],Ss.prototype,"accessLocation",void 0);let Mi=pl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,pl.prototype)}};Mi=pl=f([H({type:M.Sequence,itemType:Ss})],Mi);const ta=`${jn}.35`;class gl extends tt{}class li{constructor(e={}){e&&Object.assign(this,e)}}f([y({type:gl,context:0,optional:!0,implicit:!0})],li.prototype,"keyIdentifier",void 0),f([y({type:je,context:1,optional:!0,implicit:!0,repeated:"sequence"})],li.prototype,"authorityCertIssuer",void 0),f([y({type:b.Integer,context:2,optional:!0,implicit:!0,converter:_t})],li.prototype,"authorityCertSerialNumber",void 0);const Zh=`${jn}.19`;class ra{constructor(e={}){this.cA=!1,Object.assign(this,e)}}f([y({type:b.Boolean,defaultValue:!1})],ra.prototype,"cA",void 0),f([y({type:b.Integer,optional:!0})],ra.prototype,"pathLenConstraint",void 0);var vl;let ur=vl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,vl.prototype)}};ur=vl=f([H({type:M.Sequence,itemType:je})],ur);var ml;let Wh=ml=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,ml.prototype)}};Wh=ml=f([H({type:M.Sequence})],Wh);var wl;const Yh=`${jn}.32`;let An=class{constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||""}};f([y({type:b.IA5String})],An.prototype,"ia5String",void 0),f([y({type:b.VisibleString})],An.prototype,"visibleString",void 0),f([y({type:b.BmpString})],An.prototype,"bmpString",void 0),f([y({type:b.Utf8String})],An.prototype,"utf8String",void 0),An=f([H({type:M.Choice})],An);class bl{constructor(e={}){this.organization=new An,this.noticeNumbers=[],Object.assign(this,e)}}f([y({type:An})],bl.prototype,"organization",void 0),f([y({type:b.Integer,repeated:"sequence"})],bl.prototype,"noticeNumbers",void 0);class xl{constructor(e={}){Object.assign(this,e)}}f([y({type:bl,optional:!0})],xl.prototype,"noticeRef",void 0),f([y({type:An,optional:!0})],xl.prototype,"explicitText",void 0);let na=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.IA5String})],na.prototype,"cPSuri",void 0),f([y({type:xl})],na.prototype,"userNotice",void 0),na=f([H({type:M.Choice})],na);class Al{constructor(e={}){this.policyQualifierId="",this.qualifier=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Al.prototype,"policyQualifierId",void 0),f([y({type:b.Any})],Al.prototype,"qualifier",void 0);class ia{constructor(e={}){this.policyIdentifier="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],ia.prototype,"policyIdentifier",void 0),f([y({type:Al,repeated:"sequence",optional:!0})],ia.prototype,"policyQualifiers",void 0);let sa=wl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,wl.prototype)}};sa=wl=f([H({type:M.Sequence,itemType:ia})],sa);let oa=class{constructor(e=0){this.value=e}};f([y({type:b.Integer})],oa.prototype,"value",void 0),oa=f([H({type:M.Choice})],oa);let Jh=class extends oa{};Jh=f([H({type:M.Choice})],Jh);var Sl;const _l=`${jn}.31`;var Vr;(function(r){r[r.unused=1]="unused",r[r.keyCompromise=2]="keyCompromise",r[r.cACompromise=4]="cACompromise",r[r.affiliationChanged=8]="affiliationChanged",r[r.superseded=16]="superseded",r[r.cessationOfOperation=32]="cessationOfOperation",r[r.certificateHold=64]="certificateHold",r[r.privilegeWithdrawn=128]="privilegeWithdrawn",r[r.aACompromise=256]="aACompromise"})(Vr||(Vr={}));class Xh extends Jo{toJSON(){const e=[],t=this.toNumber();return t&Vr.aACompromise&&e.push("aACompromise"),t&Vr.affiliationChanged&&e.push("affiliationChanged"),t&Vr.cACompromise&&e.push("cACompromise"),t&Vr.certificateHold&&e.push("certificateHold"),t&Vr.cessationOfOperation&&e.push("cessationOfOperation"),t&Vr.keyCompromise&&e.push("keyCompromise"),t&Vr.privilegeWithdrawn&&e.push("privilegeWithdrawn"),t&Vr.superseded&&e.push("superseded"),t&Vr.unused&&e.push("unused"),e}toString(){return`[${this.toJSON().join(", ")}]`}}let ui=class{constructor(e={}){Object.assign(this,e)}};f([y({type:je,context:0,repeated:"sequence",implicit:!0})],ui.prototype,"fullName",void 0),f([y({type:Di,context:1,implicit:!0})],ui.prototype,"nameRelativeToCRLIssuer",void 0),ui=f([H({type:M.Choice})],ui);class Vi{constructor(e={}){Object.assign(this,e)}}f([y({type:ui,context:0,optional:!0})],Vi.prototype,"distributionPoint",void 0),f([y({type:Xh,context:1,optional:!0,implicit:!0})],Vi.prototype,"reasons",void 0),f([y({type:je,context:2,optional:!0,repeated:"sequence",implicit:!0})],Vi.prototype,"cRLIssuer",void 0);let Li=Sl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Sl.prototype)}};Li=Sl=f([H({type:M.Sequence,itemType:Vi})],Li);var El;let Qh=El=class extends Li{constructor(e){super(e),Object.setPrototypeOf(this,El.prototype)}};Qh=El=f([H({type:M.Sequence,itemType:Vi})],Qh);class rr{constructor(e={}){this.onlyContainsUserCerts=rr.ONLY,this.onlyContainsCACerts=rr.ONLY,this.indirectCRL=rr.ONLY,this.onlyContainsAttributeCerts=rr.ONLY,Object.assign(this,e)}}rr.ONLY=!1,f([y({type:ui,context:0,optional:!0})],rr.prototype,"distributionPoint",void 0),f([y({type:b.Boolean,context:1,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsUserCerts",void 0),f([y({type:b.Boolean,context:2,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsCACerts",void 0),f([y({type:Xh,context:3,optional:!0,implicit:!0})],rr.prototype,"onlySomeReasons",void 0),f([y({type:b.Boolean,context:4,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"indirectCRL",void 0),f([y({type:b.Boolean,context:5,defaultValue:rr.ONLY,implicit:!0})],rr.prototype,"onlyContainsAttributeCerts",void 0);var _s;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(_s||(_s={}));let Il=class{constructor(e=_s.unspecified){this.reason=_s.unspecified,this.reason=e}toJSON(){return _s[this.reason]}toString(){return this.toJSON()}};f([y({type:b.Enumerated})],Il.prototype,"reason",void 0),Il=f([H({type:M.Choice})],Il);var kl;const ed=`${jn}.37`;let aa=kl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,kl.prototype)}};aa=kl=f([H({type:M.Sequence,itemType:b.ObjectIdentifier})],aa);const Ug=`${$i}.1`,Dg=`${$i}.2`,$g=`${$i}.3`,Mg=`${$i}.4`,Vg=`${$i}.8`,Lg=`${$i}.9`;let Cl=class{constructor(e=new ArrayBuffer(0)){this.value=e}};f([y({type:b.Integer,converter:_t})],Cl.prototype,"value",void 0),Cl=f([H({type:M.Choice})],Cl);let Bl=class{constructor(e){this.value=new Date,e&&(this.value=e)}};f([y({type:b.GeneralizedTime})],Bl.prototype,"value",void 0),Bl=f([H({type:M.Choice})],Bl);var Ol;let td=Ol=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Ol.prototype)}};td=Ol=f([H({type:M.Sequence})],td);const rd=`${jn}.15`;var Lr;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Lr||(Lr={}));class Tl extends Jo{toJSON(){const e=this.toNumber(),t=[];return e&Lr.cRLSign&&t.push("crlSign"),e&Lr.dataEncipherment&&t.push("dataEncipherment"),e&Lr.decipherOnly&&t.push("decipherOnly"),e&Lr.digitalSignature&&t.push("digitalSignature"),e&Lr.encipherOnly&&t.push("encipherOnly"),e&Lr.keyAgreement&&t.push("keyAgreement"),e&Lr.keyCertSign&&t.push("keyCertSign"),e&Lr.keyEncipherment&&t.push("keyEncipherment"),e&Lr.nonRepudiation&&t.push("nonRepudiation"),t}toString(){return`[${this.toJSON().join(", ")}]`}}var Nl;class ca{constructor(e={}){this.base=new je,this.minimum=0,Object.assign(this,e)}}f([y({type:je})],ca.prototype,"base",void 0),f([y({type:b.Integer,context:0,defaultValue:0,implicit:!0})],ca.prototype,"minimum",void 0),f([y({type:b.Integer,context:1,optional:!0,implicit:!0})],ca.prototype,"maximum",void 0);let la=Nl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Nl.prototype)}};la=Nl=f([H({type:M.Sequence,itemType:ca})],la);class nd{constructor(e={}){Object.assign(this,e)}}f([y({type:la,context:0,optional:!0,implicit:!0})],nd.prototype,"permittedSubtrees",void 0),f([y({type:la,context:1,optional:!0,implicit:!0})],nd.prototype,"excludedSubtrees",void 0);class id{constructor(e={}){Object.assign(this,e)}}f([y({type:b.Integer,context:0,implicit:!0,optional:!0,converter:_t})],id.prototype,"requireExplicitPolicy",void 0),f([y({type:b.Integer,context:1,implicit:!0,optional:!0,converter:_t})],id.prototype,"inhibitPolicyMapping",void 0);var Pl;class jl{constructor(e={}){this.issuerDomainPolicy="",this.subjectDomainPolicy="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],jl.prototype,"issuerDomainPolicy",void 0),f([y({type:b.ObjectIdentifier})],jl.prototype,"subjectDomainPolicy",void 0);let sd=Pl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Pl.prototype)}};sd=Pl=f([H({type:M.Sequence,itemType:jl})],sd);var Rl;const Ul=`${jn}.17`;let Dl=Rl=class extends ur{constructor(e){super(e),Object.setPrototypeOf(this,Rl.prototype)}};Dl=Rl=f([H({type:M.Sequence})],Dl);let Sn=class{constructor(e={}){this.type="",this.values=[],Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Sn.prototype,"type",void 0),f([y({type:b.Any,repeated:"set"})],Sn.prototype,"values",void 0);var $l;let od=$l=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,$l.prototype)}};od=$l=f([H({type:M.Sequence,itemType:Sn})],od);const Ml=`${jn}.14`;class Rn extends gl{}class ad{constructor(e={}){Object.assign(this,e)}}f([y({type:b.GeneralizedTime,context:0,implicit:!0,optional:!0})],ad.prototype,"notBefore",void 0),f([y({type:b.GeneralizedTime,context:1,implicit:!0,optional:!0})],ad.prototype,"notAfter",void 0);var Es;(function(r){r[r.keyUpdateAllowed=1]="keyUpdateAllowed",r[r.newExtensions=2]="newExtensions",r[r.pKIXCertificate=4]="pKIXCertificate"})(Es||(Es={}));class cd extends Jo{toJSON(){const e=[],t=this.toNumber();return t&Es.pKIXCertificate&&e.push("pKIXCertificate"),t&Es.newExtensions&&e.push("newExtensions"),t&Es.keyUpdateAllowed&&e.push("keyUpdateAllowed"),e}toString(){return`[${this.toJSON().join(", ")}]`}}class ld{constructor(e={}){this.entrustVers="",this.entrustInfoFlags=new cd,Object.assign(this,e)}}f([y({type:b.GeneralString})],ld.prototype,"entrustVers",void 0),f([y({type:cd})],ld.prototype,"entrustInfoFlags",void 0);var Vl;let ud=Vl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Vl.prototype)}};ud=Vl=f([H({type:M.Sequence,itemType:Ss})],ud);class ne{constructor(e={}){this.algorithm="",Object.assign(this,e)}isEqual(e){return e instanceof ne&&e.algorithm==this.algorithm&&(e.parameters&&this.parameters&&No(e.parameters,this.parameters)||e.parameters===this.parameters)}}f([y({type:b.ObjectIdentifier})],ne.prototype,"algorithm",void 0),f([y({type:b.Any,optional:!0})],ne.prototype,"parameters",void 0);class en{constructor(e={}){this.algorithm=new ne,this.subjectPublicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ne})],en.prototype,"algorithm",void 0),f([y({type:b.BitString})],en.prototype,"subjectPublicKey",void 0);let Jt=class{constructor(e){if(e)if(typeof e=="string"||typeof e=="number"||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}};f([y({type:b.UTCTime})],Jt.prototype,"utcTime",void 0),f([y({type:b.GeneralizedTime})],Jt.prototype,"generalTime",void 0),Jt=f([H({type:M.Choice})],Jt);class ua{constructor(e){this.notBefore=new Jt(new Date),this.notAfter=new Jt(new Date),e&&(this.notBefore=new Jt(e.notBefore),this.notAfter=new Jt(e.notAfter))}}f([y({type:Jt})],ua.prototype,"notBefore",void 0),f([y({type:Jt})],ua.prototype,"notAfter",void 0);var Ll;let Hr=class Ey{constructor(e={}){this.extnID="",this.critical=Ey.CRITICAL,this.extnValue=new tt,Object.assign(this,e)}};Hr.CRITICAL=!1,f([y({type:b.ObjectIdentifier})],Hr.prototype,"extnID",void 0),f([y({type:b.Boolean,defaultValue:Hr.CRITICAL})],Hr.prototype,"critical",void 0),f([y({type:tt})],Hr.prototype,"extnValue",void 0);let fi=Ll=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Ll.prototype)}};fi=Ll=f([H({type:M.Sequence,itemType:Hr})],fi);var Hi;(function(r){r[r.v1=0]="v1",r[r.v2=1]="v2",r[r.v3=2]="v3"})(Hi||(Hi={}));class Pr{constructor(e={}){this.version=Hi.v1,this.serialNumber=new ArrayBuffer(0),this.signature=new ne,this.issuer=new zt,this.validity=new ua,this.subject=new zt,this.subjectPublicKeyInfo=new en,Object.assign(this,e)}}f([y({type:b.Integer,context:0,defaultValue:Hi.v1})],Pr.prototype,"version",void 0),f([y({type:b.Integer,converter:_t})],Pr.prototype,"serialNumber",void 0),f([y({type:ne})],Pr.prototype,"signature",void 0),f([y({type:zt})],Pr.prototype,"issuer",void 0),f([y({type:ua})],Pr.prototype,"validity",void 0),f([y({type:zt})],Pr.prototype,"subject",void 0),f([y({type:en})],Pr.prototype,"subjectPublicKeyInfo",void 0),f([y({type:b.BitString,context:1,implicit:!0,optional:!0})],Pr.prototype,"issuerUniqueID",void 0),f([y({type:b.BitString,context:2,implicit:!0,optional:!0})],Pr.prototype,"subjectUniqueID",void 0),f([y({type:fi,context:3,optional:!0})],Pr.prototype,"extensions",void 0);class hi{constructor(e={}){this.tbsCertificate=new Pr,this.signatureAlgorithm=new ne,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Pr})],hi.prototype,"tbsCertificate",void 0),f([y({type:ne})],hi.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],hi.prototype,"signatureValue",void 0);class fa{constructor(e={}){this.userCertificate=new ArrayBuffer(0),this.revocationDate=new Jt,Object.assign(this,e)}}f([y({type:b.Integer,converter:_t})],fa.prototype,"userCertificate",void 0),f([y({type:Jt})],fa.prototype,"revocationDate",void 0),f([y({type:Hr,optional:!0,repeated:"sequence"})],fa.prototype,"crlEntryExtensions",void 0);class _n{constructor(e={}){this.signature=new ne,this.issuer=new zt,this.thisUpdate=new Jt,Object.assign(this,e)}}f([y({type:b.Integer,optional:!0})],_n.prototype,"version",void 0),f([y({type:ne})],_n.prototype,"signature",void 0),f([y({type:zt})],_n.prototype,"issuer",void 0),f([y({type:Jt})],_n.prototype,"thisUpdate",void 0),f([y({type:Jt,optional:!0})],_n.prototype,"nextUpdate",void 0),f([y({type:fa,repeated:"sequence",optional:!0})],_n.prototype,"revokedCertificates",void 0),f([y({type:Hr,optional:!0,context:0,repeated:"sequence"})],_n.prototype,"crlExtensions",void 0);class Hl{constructor(e={}){this.tbsCertList=new _n,this.signatureAlgorithm=new ne,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:_n})],Hl.prototype,"tbsCertList",void 0),f([y({type:ne})],Hl.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],Hl.prototype,"signature",void 0);class Fi{constructor(e={}){this.issuer=new zt,this.serialNumber=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:zt})],Fi.prototype,"issuer",void 0),f([y({type:b.Integer,converter:_t})],Fi.prototype,"serialNumber",void 0);let zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0})],zi.prototype,"subjectKeyIdentifier",void 0),f([y({type:Fi})],zi.prototype,"issuerAndSerialNumber",void 0),zi=f([H({type:M.Choice})],zi);var tn;(function(r){r[r.v0=0]="v0",r[r.v1=1]="v1",r[r.v2=2]="v2",r[r.v3=3]="v3",r[r.v4=4]="v4",r[r.v5=5]="v5"})(tn||(tn={}));let Is=class extends ne{};Is=f([H({type:M.Sequence})],Is);let ha=class extends ne{};ha=f([H({type:M.Sequence})],ha);let rn=class extends ne{};rn=f([H({type:M.Sequence})],rn);let da=class extends ne{};da=f([H({type:M.Sequence})],da);let fd=class extends ne{};fd=f([H({type:M.Sequence})],fd);let Fl=class extends ne{};Fl=f([H({type:M.Sequence})],Fl);let Gi=class{constructor(e={}){this.attrType="",this.attrValues=[],Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Gi.prototype,"attrType",void 0),f([y({type:b.Any,repeated:"set"})],Gi.prototype,"attrValues",void 0);var zl;class nn{constructor(e={}){this.version=tn.v0,this.sid=new zi,this.digestAlgorithm=new Is,this.signatureAlgorithm=new ha,this.signature=new tt,Object.assign(this,e)}}f([y({type:b.Integer})],nn.prototype,"version",void 0),f([y({type:zi})],nn.prototype,"sid",void 0),f([y({type:Is})],nn.prototype,"digestAlgorithm",void 0),f([y({type:Gi,repeated:"set",context:0,implicit:!0,optional:!0})],nn.prototype,"signedAttrs",void 0),f([y({type:ha})],nn.prototype,"signatureAlgorithm",void 0),f([y({type:tt})],nn.prototype,"signature",void 0),f([y({type:Gi,repeated:"set",context:1,implicit:!0,optional:!0})],nn.prototype,"unsignedAttrs",void 0);let pa=zl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,zl.prototype)}};pa=zl=f([H({type:M.Set,itemType:nn})],pa);let hd=class extends Jt{};hd=f([H({type:M.Choice})],hd);let dd=class extends nn{};dd=f([H({type:M.Sequence})],dd);class Gl{constructor(e={}){this.acIssuer=new je,this.acSerial=0,this.attrs=[],Object.assign(this,e)}}f([y({type:je})],Gl.prototype,"acIssuer",void 0),f([y({type:b.Integer})],Gl.prototype,"acSerial",void 0),f([y({type:Sn,repeated:"sequence"})],Gl.prototype,"attrs",void 0);var Kl;let ya=Kl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Kl.prototype)}};ya=Kl=f([H({type:M.Sequence,itemType:b.ObjectIdentifier})],ya);class ga{constructor(e={}){this.permitUnSpecified=!0,Object.assign(this,e)}}f([y({type:b.Integer,optional:!0})],ga.prototype,"pathLenConstraint",void 0),f([y({type:ya,implicit:!0,context:0,optional:!0})],ga.prototype,"permittedAttrs",void 0),f([y({type:ya,implicit:!0,context:1,optional:!0})],ga.prototype,"excludedAttrs",void 0),f([y({type:b.Boolean,defaultValue:!0})],ga.prototype,"permitUnSpecified",void 0);class di{constructor(e={}){this.issuer=new ur,this.serial=new ArrayBuffer(0),this.issuerUID=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ur})],di.prototype,"issuer",void 0),f([y({type:b.Integer,converter:_t})],di.prototype,"serial",void 0),f([y({type:b.BitString,optional:!0})],di.prototype,"issuerUID",void 0);var ql;(function(r){r[r.publicKey=0]="publicKey",r[r.publicKeyCert=1]="publicKeyCert",r[r.otherObjectTypes=2]="otherObjectTypes"})(ql||(ql={}));class pi{constructor(e={}){this.digestedObjectType=ql.publicKey,this.digestAlgorithm=new ne,this.objectDigest=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Enumerated})],pi.prototype,"digestedObjectType",void 0),f([y({type:b.ObjectIdentifier,optional:!0})],pi.prototype,"otherObjectTypeID",void 0),f([y({type:ne})],pi.prototype,"digestAlgorithm",void 0),f([y({type:b.BitString})],pi.prototype,"objectDigest",void 0);class va{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,optional:!0})],va.prototype,"issuerName",void 0),f([y({type:di,context:0,implicit:!0,optional:!0})],va.prototype,"baseCertificateID",void 0),f([y({type:pi,context:1,implicit:!0,optional:!0})],va.prototype,"objectDigestInfo",void 0);let Ki=class{constructor(e={}){Object.assign(this,e)}};f([y({type:je,repeated:"sequence"})],Ki.prototype,"v1Form",void 0),f([y({type:va,context:0,implicit:!0})],Ki.prototype,"v2Form",void 0),Ki=f([H({type:M.Choice})],Ki);class ma{constructor(e={}){this.notBeforeTime=new Date,this.notAfterTime=new Date,Object.assign(this,e)}}f([y({type:b.GeneralizedTime})],ma.prototype,"notBeforeTime",void 0),f([y({type:b.GeneralizedTime})],ma.prototype,"notAfterTime",void 0);class ks{constructor(e={}){Object.assign(this,e)}}f([y({type:di,implicit:!0,context:0,optional:!0})],ks.prototype,"baseCertificateID",void 0),f([y({type:ur,implicit:!0,context:1,optional:!0})],ks.prototype,"entityName",void 0),f([y({type:pi,implicit:!0,context:2,optional:!0})],ks.prototype,"objectDigestInfo",void 0);var Zl;(function(r){r[r.v2=1]="v2"})(Zl||(Zl={}));class Fr{constructor(e={}){this.version=Zl.v2,this.holder=new ks,this.issuer=new Ki,this.signature=new ne,this.serialNumber=new ArrayBuffer(0),this.attrCertValidityPeriod=new ma,this.attributes=[],Object.assign(this,e)}}f([y({type:b.Integer})],Fr.prototype,"version",void 0),f([y({type:ks})],Fr.prototype,"holder",void 0),f([y({type:Ki})],Fr.prototype,"issuer",void 0),f([y({type:ne})],Fr.prototype,"signature",void 0),f([y({type:b.Integer,converter:_t})],Fr.prototype,"serialNumber",void 0),f([y({type:ma})],Fr.prototype,"attrCertValidityPeriod",void 0),f([y({type:Sn,repeated:"sequence"})],Fr.prototype,"attributes",void 0),f([y({type:b.BitString,optional:!0})],Fr.prototype,"issuerUniqueID",void 0),f([y({type:fi,optional:!0})],Fr.prototype,"extensions",void 0);class wa{constructor(e={}){this.acinfo=new Fr,this.signatureAlgorithm=new ne,this.signatureValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:Fr})],wa.prototype,"acinfo",void 0),f([y({type:ne})],wa.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],wa.prototype,"signatureValue",void 0);var ba;(function(r){r[r.unmarked=1]="unmarked",r[r.unclassified=2]="unclassified",r[r.restricted=4]="restricted",r[r.confidential=8]="confidential",r[r.secret=16]="secret",r[r.topSecret=32]="topSecret"})(ba||(ba={}));class Wl extends Jo{}class Yl{constructor(e={}){this.type="",this.value=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier,implicit:!0,context:0})],Yl.prototype,"type",void 0),f([y({type:b.Any,implicit:!0,context:1})],Yl.prototype,"value",void 0);class Jl{constructor(e={}){this.policyId="",this.classList=new Wl(ba.unclassified),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Jl.prototype,"policyId",void 0),f([y({type:Wl,defaultValue:new Wl(ba.unclassified)})],Jl.prototype,"classList",void 0),f([y({type:Yl,repeated:"set"})],Jl.prototype,"securityCategories",void 0);class xa{constructor(e={}){Object.assign(this,e)}}f([y({type:tt})],xa.prototype,"cotets",void 0),f([y({type:b.ObjectIdentifier})],xa.prototype,"oid",void 0),f([y({type:b.Utf8String})],xa.prototype,"string",void 0);class pd{constructor(e={}){this.values=[],Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],pd.prototype,"policyAuthority",void 0),f([y({type:xa,repeated:"sequence"})],pd.prototype,"values",void 0);var Xl;class Aa{constructor(e={}){this.targetCertificate=new di,Object.assign(this,e)}}f([y({type:di})],Aa.prototype,"targetCertificate",void 0),f([y({type:je,optional:!0})],Aa.prototype,"targetName",void 0),f([y({type:pi,optional:!0})],Aa.prototype,"certDigestInfo",void 0);let qi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:je,context:0,implicit:!0})],qi.prototype,"targetName",void 0),f([y({type:je,context:1,implicit:!0})],qi.prototype,"targetGroup",void 0),f([y({type:Aa,context:2,implicit:!0})],qi.prototype,"targetCert",void 0),qi=f([H({type:M.Choice})],qi);let Ql=Xl=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Xl.prototype)}};Ql=Xl=f([H({type:M.Sequence,itemType:qi})],Ql);var eu;let yd=eu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,eu.prototype)}};yd=eu=f([H({type:M.Sequence,itemType:Ql})],yd);class gd{constructor(e={}){Object.assign(this,e)}}f([y({type:ur,implicit:!0,context:0,optional:!0})],gd.prototype,"roleAuthority",void 0),f([y({type:je,implicit:!0,context:1})],gd.prototype,"roleName",void 0);class tu{constructor(e={}){this.service=new je,this.ident=new je,Object.assign(this,e)}}f([y({type:je})],tu.prototype,"service",void 0),f([y({type:je})],tu.prototype,"ident",void 0),f([y({type:tt,optional:!0})],tu.prototype,"authInfo",void 0);var ru;class nu{constructor(e={}){this.otherCertFormat="",this.otherCert=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],nu.prototype,"otherCertFormat",void 0),f([y({type:b.Any})],nu.prototype,"otherCert",void 0);let yi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:hi})],yi.prototype,"certificate",void 0),f([y({type:wa,context:2,implicit:!0})],yi.prototype,"v2AttrCert",void 0),f([y({type:nu,context:3,implicit:!0})],yi.prototype,"other",void 0),yi=f([H({type:M.Choice})],yi);let Cs=ru=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,ru.prototype)}};Cs=ru=f([H({type:M.Set,itemType:yi})],Cs);class En{constructor(e={}){this.contentType="",this.content=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],En.prototype,"contentType",void 0),f([y({type:b.Any,context:0})],En.prototype,"content",void 0);let Zi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:tt})],Zi.prototype,"single",void 0),f([y({type:b.Any})],Zi.prototype,"any",void 0),Zi=f([H({type:M.Choice})],Zi);class Sa{constructor(e={}){this.eContentType="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Sa.prototype,"eContentType",void 0),f([y({type:Zi,context:0,optional:!0})],Sa.prototype,"eContent",void 0);let Bs=class{constructor(e={}){Object.assign(this,e)}};f([y({type:tt,context:0,implicit:!0,optional:!0})],Bs.prototype,"value",void 0),f([y({type:tt,converter:gg,context:0,implicit:!0,optional:!0,repeated:"sequence"})],Bs.prototype,"constructedValue",void 0),Bs=f([H({type:M.Choice})],Bs);class Os{constructor(e={}){this.contentType="",this.contentEncryptionAlgorithm=new da,Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Os.prototype,"contentType",void 0),f([y({type:da})],Os.prototype,"contentEncryptionAlgorithm",void 0),f([y({type:Bs,optional:!0})],Os.prototype,"encryptedContent",void 0);class _a{constructor(e={}){this.keyAttrId="",Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],_a.prototype,"keyAttrId",void 0),f([y({type:b.Any,optional:!0})],_a.prototype,"keyAttr",void 0);var iu;class Ea{constructor(e={}){this.subjectKeyIdentifier=new Rn,Object.assign(this,e)}}f([y({type:Rn})],Ea.prototype,"subjectKeyIdentifier",void 0),f([y({type:b.GeneralizedTime,optional:!0})],Ea.prototype,"date",void 0),f([y({type:_a,optional:!0})],Ea.prototype,"other",void 0);let Wi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Ea,context:0,implicit:!0,optional:!0})],Wi.prototype,"rKeyId",void 0),f([y({type:Fi,optional:!0})],Wi.prototype,"issuerAndSerialNumber",void 0),Wi=f([H({type:M.Choice})],Wi);class su{constructor(e={}){this.rid=new Wi,this.encryptedKey=new tt,Object.assign(this,e)}}f([y({type:Wi})],su.prototype,"rid",void 0),f([y({type:tt})],su.prototype,"encryptedKey",void 0);let Ia=iu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,iu.prototype)}};Ia=iu=f([H({type:M.Sequence,itemType:su})],Ia);class ou{constructor(e={}){this.algorithm=new ne,this.publicKey=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:ne})],ou.prototype,"algorithm",void 0),f([y({type:b.BitString})],ou.prototype,"publicKey",void 0);let gi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0,optional:!0})],gi.prototype,"subjectKeyIdentifier",void 0),f([y({type:ou,context:1,implicit:!0,optional:!0})],gi.prototype,"originatorKey",void 0),f([y({type:Fi,optional:!0})],gi.prototype,"issuerAndSerialNumber",void 0),gi=f([H({type:M.Choice})],gi);class Yi{constructor(e={}){this.version=tn.v3,this.originator=new gi,this.keyEncryptionAlgorithm=new rn,this.recipientEncryptedKeys=new Ia,Object.assign(this,e)}}f([y({type:b.Integer})],Yi.prototype,"version",void 0),f([y({type:gi,context:0})],Yi.prototype,"originator",void 0),f([y({type:tt,context:1,optional:!0})],Yi.prototype,"ukm",void 0),f([y({type:rn})],Yi.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:Ia})],Yi.prototype,"recipientEncryptedKeys",void 0);let Ji=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Rn,context:0,implicit:!0})],Ji.prototype,"subjectKeyIdentifier",void 0),f([y({type:Fi})],Ji.prototype,"issuerAndSerialNumber",void 0),Ji=f([H({type:M.Choice})],Ji);class Ts{constructor(e={}){this.version=tn.v0,this.rid=new Ji,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new tt,Object.assign(this,e)}}f([y({type:b.Integer})],Ts.prototype,"version",void 0),f([y({type:Ji})],Ts.prototype,"rid",void 0),f([y({type:rn})],Ts.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:tt})],Ts.prototype,"encryptedKey",void 0);class Ns{constructor(e={}){this.keyIdentifier=new tt,Object.assign(this,e)}}f([y({type:tt})],Ns.prototype,"keyIdentifier",void 0),f([y({type:b.GeneralizedTime,optional:!0})],Ns.prototype,"date",void 0),f([y({type:_a,optional:!0})],Ns.prototype,"other",void 0);class Ps{constructor(e={}){this.version=tn.v4,this.kekid=new Ns,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new tt,Object.assign(this,e)}}f([y({type:b.Integer})],Ps.prototype,"version",void 0),f([y({type:Ns})],Ps.prototype,"kekid",void 0),f([y({type:rn})],Ps.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:tt})],Ps.prototype,"encryptedKey",void 0);class js{constructor(e={}){this.version=tn.v0,this.keyEncryptionAlgorithm=new rn,this.encryptedKey=new tt,Object.assign(this,e)}}f([y({type:b.Integer})],js.prototype,"version",void 0),f([y({type:Fl,context:0,optional:!0})],js.prototype,"keyDerivationAlgorithm",void 0),f([y({type:rn})],js.prototype,"keyEncryptionAlgorithm",void 0),f([y({type:tt})],js.prototype,"encryptedKey",void 0);class au{constructor(e={}){this.oriType="",this.oriValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],au.prototype,"oriType",void 0),f([y({type:b.Any})],au.prototype,"oriValue",void 0);let Un=class{constructor(e={}){Object.assign(this,e)}};f([y({type:Ts,optional:!0})],Un.prototype,"ktri",void 0),f([y({type:Yi,context:1,implicit:!0,optional:!0})],Un.prototype,"kari",void 0),f([y({type:Ps,context:2,implicit:!0,optional:!0})],Un.prototype,"kekri",void 0),f([y({type:js,context:3,implicit:!0,optional:!0})],Un.prototype,"pwri",void 0),f([y({type:au,context:4,implicit:!0,optional:!0})],Un.prototype,"ori",void 0),Un=f([H({type:M.Choice})],Un);var cu;let ka=cu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,cu.prototype)}};ka=cu=f([H({type:M.Set,itemType:Un})],ka);var lu;class Ca{constructor(e={}){this.otherRevInfoFormat="",this.otherRevInfo=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Ca.prototype,"otherRevInfoFormat",void 0),f([y({type:b.Any})],Ca.prototype,"otherRevInfo",void 0);let Ba=class{constructor(e={}){this.other=new Ca,Object.assign(this,e)}};f([y({type:Ca,context:1,implicit:!0})],Ba.prototype,"other",void 0),Ba=f([H({type:M.Choice})],Ba);let Oa=lu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,lu.prototype)}};Oa=lu=f([H({type:M.Set,itemType:Ba})],Oa);class uu{constructor(e={}){Object.assign(this,e)}}f([y({type:Cs,context:0,implicit:!0,optional:!0})],uu.prototype,"certs",void 0),f([y({type:Oa,context:1,implicit:!0,optional:!0})],uu.prototype,"crls",void 0);var fu;let hu=fu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,fu.prototype)}};hu=fu=f([H({type:M.Set,itemType:Gi})],hu);class Rs{constructor(e={}){this.version=tn.v0,this.recipientInfos=new ka,this.encryptedContentInfo=new Os,Object.assign(this,e)}}f([y({type:b.Integer})],Rs.prototype,"version",void 0),f([y({type:uu,context:0,implicit:!0,optional:!0})],Rs.prototype,"originatorInfo",void 0),f([y({type:ka})],Rs.prototype,"recipientInfos",void 0),f([y({type:Os})],Rs.prototype,"encryptedContentInfo",void 0),f([y({type:hu,context:1,implicit:!0,optional:!0})],Rs.prototype,"unprotectedAttrs",void 0);const Hg="1.2.840.113549.1.7.1",du="1.2.840.113549.1.7.2";var pu;let Ta=pu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,pu.prototype)}};Ta=pu=f([H({type:M.Set,itemType:Is})],Ta);class In{constructor(e={}){this.version=tn.v0,this.digestAlgorithms=new Ta,this.encapContentInfo=new Sa,this.signerInfos=new pa,Object.assign(this,e)}}f([y({type:b.Integer})],In.prototype,"version",void 0),f([y({type:Ta})],In.prototype,"digestAlgorithms",void 0),f([y({type:Sa})],In.prototype,"encapContentInfo",void 0),f([y({type:Cs,context:0,implicit:!0,optional:!0})],In.prototype,"certificates",void 0),f([y({type:Oa,context:1,implicit:!0,optional:!0})],In.prototype,"crls",void 0),f([y({type:pa})],In.prototype,"signerInfos",void 0);const Us="1.2.840.10045.2.1",yu="1.2.840.10045.4.1",vd="1.2.840.10045.4.3.1",gu="1.2.840.10045.4.3.2",vu="1.2.840.10045.4.3.3",mu="1.2.840.10045.4.3.4",md="1.2.840.10045.3.1.7",wd="1.3.132.0.34",bd="1.3.132.0.35";function Ds(r){return new ne({algorithm:r})}const Fg=Ds(yu);Ds(vd);const zg=Ds(gu),Gg=Ds(vu),Kg=Ds(mu);let $s=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],$s.prototype,"fieldType",void 0),f([y({type:b.Any})],$s.prototype,"parameters",void 0),$s=f([H({type:M.Sequence})],$s);class qg extends tt{}let Xi=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.OctetString})],Xi.prototype,"a",void 0),f([y({type:b.OctetString})],Xi.prototype,"b",void 0),f([y({type:b.BitString,optional:!0})],Xi.prototype,"seed",void 0),Xi=f([H({type:M.Sequence})],Xi);var wu;(function(r){r[r.ecpVer1=1]="ecpVer1"})(wu||(wu={}));let kn=class{constructor(e={}){this.version=wu.ecpVer1,Object.assign(this,e)}};f([y({type:b.Integer})],kn.prototype,"version",void 0),f([y({type:$s})],kn.prototype,"fieldID",void 0),f([y({type:Xi})],kn.prototype,"curve",void 0),f([y({type:qg})],kn.prototype,"base",void 0),f([y({type:b.Integer,converter:_t})],kn.prototype,"order",void 0),f([y({type:b.Integer,optional:!0})],kn.prototype,"cofactor",void 0),kn=f([H({type:M.Sequence})],kn);let Dn=class{constructor(e={}){Object.assign(this,e)}};f([y({type:b.ObjectIdentifier})],Dn.prototype,"namedCurve",void 0),f([y({type:b.Null})],Dn.prototype,"implicitCurve",void 0),f([y({type:kn})],Dn.prototype,"specifiedCurve",void 0),Dn=f([H({type:M.Choice})],Dn);class Na{constructor(e={}){this.version=1,this.privateKey=new tt,Object.assign(this,e)}}f([y({type:b.Integer})],Na.prototype,"version",void 0),f([y({type:tt})],Na.prototype,"privateKey",void 0),f([y({type:Dn,context:0,optional:!0})],Na.prototype,"parameters",void 0),f([y({type:b.BitString,context:1,optional:!0})],Na.prototype,"publicKey",void 0);class Pa{constructor(e={}){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:_t})],Pa.prototype,"r",void 0),f([y({type:b.Integer,converter:_t})],Pa.prototype,"s",void 0);const mr="1.2.840.113549.1.1",vi=`${mr}.1`,Zg=`${mr}.7`,Wg=`${mr}.9`,Ms=`${mr}.10`,Yg=`${mr}.2`,Jg=`${mr}.4`,ja=`${mr}.5`,Xg=`${mr}.14`,bu=`${mr}.11`,Ra=`${mr}.12`,Ua=`${mr}.13`,xd=`${mr}.15`,Ad=`${mr}.16`,Da="1.3.14.3.2.26",Sd="2.16.840.1.101.3.4.2.4",$a="2.16.840.1.101.3.4.2.1",Ma="2.16.840.1.101.3.4.2.2",Va="2.16.840.1.101.3.4.2.3",Qg="2.16.840.1.101.3.4.2.5",ev="2.16.840.1.101.3.4.2.6",tv="1.2.840.113549.2.2",rv="1.2.840.113549.2.5",La=`${mr}.8`;function Gt(r){return new ne({algorithm:r,parameters:null})}Gt(tv),Gt(rv);const mi=Gt(Da);Gt(Sd),Gt($a),Gt(Ma),Gt(Va),Gt(Qg),Gt(ev);const _d=new ne({algorithm:La,parameters:q.serialize(mi)}),Ed=new ne({algorithm:Wg,parameters:q.serialize(Xo.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))});Gt(vi),Gt(Yg),Gt(Jg),Gt(ja),Gt(xd),Gt(Ad),Gt(Ra),Gt(Ua),Gt(xd),Gt(Ad);class Ha{constructor(e={}){this.hashAlgorithm=new ne(mi),this.maskGenAlgorithm=new ne({algorithm:La,parameters:q.serialize(mi)}),this.pSourceAlgorithm=new ne(Ed),Object.assign(this,e)}}f([y({type:ne,context:0,defaultValue:mi})],Ha.prototype,"hashAlgorithm",void 0),f([y({type:ne,context:1,defaultValue:_d})],Ha.prototype,"maskGenAlgorithm",void 0),f([y({type:ne,context:2,defaultValue:Ed})],Ha.prototype,"pSourceAlgorithm",void 0),new ne({algorithm:Zg,parameters:q.serialize(new Ha)});class wi{constructor(e={}){this.hashAlgorithm=new ne(mi),this.maskGenAlgorithm=new ne({algorithm:La,parameters:q.serialize(mi)}),this.saltLength=20,this.trailerField=1,Object.assign(this,e)}}f([y({type:ne,context:0,defaultValue:mi})],wi.prototype,"hashAlgorithm",void 0),f([y({type:ne,context:1,defaultValue:_d})],wi.prototype,"maskGenAlgorithm",void 0),f([y({type:b.Integer,context:2,defaultValue:20})],wi.prototype,"saltLength",void 0),f([y({type:b.Integer,context:3,defaultValue:1})],wi.prototype,"trailerField",void 0),new ne({algorithm:Ms,parameters:q.serialize(new wi)});class Fa{constructor(e={}){this.digestAlgorithm=new ne,this.digest=new tt,Object.assign(this,e)}}f([y({type:ne})],Fa.prototype,"digestAlgorithm",void 0),f([y({type:tt})],Fa.prototype,"digest",void 0);var xu;class za{constructor(e={}){this.prime=new ArrayBuffer(0),this.exponent=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:_t})],za.prototype,"prime",void 0),f([y({type:b.Integer,converter:_t})],za.prototype,"exponent",void 0),f([y({type:b.Integer,converter:_t})],za.prototype,"coefficient",void 0);let Au=xu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,xu.prototype)}};Au=xu=f([H({type:M.Sequence,itemType:za})],Au);class sn{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)}}f([y({type:b.Integer})],sn.prototype,"version",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"modulus",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"publicExponent",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"privateExponent",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"prime1",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"prime2",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"exponent1",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"exponent2",void 0),f([y({type:b.Integer,converter:_t})],sn.prototype,"coefficient",void 0),f([y({type:Au,optional:!0})],sn.prototype,"otherPrimeInfos",void 0);class Su{constructor(e={}){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.Integer,converter:_t})],Su.prototype,"modulus",void 0),f([y({type:b.Integer,converter:_t})],Su.prototype,"publicExponent",void 0);var _u;(function(r){r[r.Transient=0]="Transient",r[r.Singleton=1]="Singleton",r[r.ResolutionScoped=2]="ResolutionScoped",r[r.ContainerScoped=3]="ContainerScoped"})(_u||(_u={}));const wr=_u;/*! *****************************************************************************
76
76
  Copyright (c) Microsoft Corporation.
77
77
 
78
78
  Permission to use, copy, modify, and/or distribute this software for any
@@ -87,7 +87,7 @@ ${e.join(`
87
87
  PERFORMANCE OF THIS SOFTWARE.
88
88
  ***************************************************************************** */var Eu=function(r,e){return Eu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])},Eu(r,e)};function Iu(r,e){Eu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function nv(r,e,t,n){function i(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function c(m){try{h(n.next(m))}catch(x){o(x)}}function u(m){try{h(n.throw(m))}catch(x){o(x)}}function h(m){m.done?s(m.value):i(m.value).then(c,u)}h((n=n.apply(r,[])).next())})}function iv(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(h){return function(m){return u([h,m])}}function u(h){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,i=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){t.label=h[1];break}if(h[0]===6&&t.label<s[1]){t.label=s[1],s=h;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(h);break}s[2]&&t.ops.pop(),t.trys.pop();continue}h=e.call(r,t)}catch(m){h=[6,m],i=0}finally{n=s=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}}function Ga(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ka(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return s}function bi(){for(var r=[],e=0;e<arguments.length;e++)r=r.concat(Ka(arguments[e]));return r}var sv="injectionTokens";function ov(r){var e=Reflect.getMetadata("design:paramtypes",r)||[],t=Reflect.getOwnMetadata(sv,r)||{};return Object.keys(t).forEach(function(n){e[+n]=t[n]}),e}function Id(r){return!!r.useClass}function ku(r){return!!r.useFactory}var kd=function(){function r(e){this.wrap=e,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return r.prototype.createProxy=function(e){var t=this,n={},i=!1,s,o=function(){return i||(s=e(t.wrap()),i=!0),s};return new Proxy(n,this.createHandler(o))},r.prototype.createHandler=function(e){var t={},n=function(i){t[i]=function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];s[0]=e();var c=Reflect[i];return c.apply(void 0,bi(s))}};return this.reflectMethods.forEach(n),t},r}();function Qi(r){return typeof r=="string"||typeof r=="symbol"}function av(r){return typeof r=="object"&&"token"in r&&"multiple"in r}function Cd(r){return typeof r=="object"&&"token"in r&&"transform"in r}function cv(r){return typeof r=="function"||r instanceof kd}function qa(r){return!!r.useToken}function Za(r){return r.useValue!=null}function lv(r){return Id(r)||Za(r)||qa(r)||ku(r)}var Cu=function(){function r(){this._registryMap=new Map}return r.prototype.entries=function(){return this._registryMap.entries()},r.prototype.getAll=function(e){return this.ensure(e),this._registryMap.get(e)},r.prototype.get=function(e){this.ensure(e);var t=this._registryMap.get(e);return t[t.length-1]||null},r.prototype.set=function(e,t){this.ensure(e),this._registryMap.get(e).push(t)},r.prototype.setAll=function(e,t){this._registryMap.set(e,t)},r.prototype.has=function(e){return this.ensure(e),this._registryMap.get(e).length>0},r.prototype.clear=function(){this._registryMap.clear()},r.prototype.ensure=function(e){this._registryMap.has(e)||this._registryMap.set(e,[])},r}(),uv=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Cu),Bd=function(){function r(){this.scopedResolutions=new Map}return r}();function fv(r,e){if(r===null)return"at position #"+e;var t=r.split(",")[e].trim();return'"'+t+'" at position #'+e}function hv(r,e,t){return t===void 0&&(t=" "),bi([r],e.message.split(`
89
89
  `).map(function(n){return t+n})).join(`
90
- `)}function dv(r,e,t){var n=Ka(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,o=fv(s,e);return hv("Cannot inject the dependency "+o+' of "'+r.name+'" constructor. Reason:',t)}function pv(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var yv=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Cu),gv=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Cu),vv=function(){function r(){this.preResolution=new yv,this.postResolution=new gv}return r}(),Od=new Map,mv=function(){function r(e){this.parent=e,this._registry=new uv,this.interceptors=new vv,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:wr.Transient}),this.ensureNotDisposed();var i;if(lv(t)?i=t:i={useClass:t},qa(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+bi(s,[c]).join(" -> "));s.push(c);var u=this._registry.get(c);u&&qa(u.provider)?o=u.provider:o=null}if((n.lifecycle===wr.Singleton||n.lifecycle==wr.ContainerScoped||n.lifecycle==wr.ResolutionScoped)&&(Za(i)||ku(i)))throw new Error('Cannot use lifecycle "'+wr[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Qi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Qi(e)){if(Qi(t))return this.register(e,{useToken:t},{lifecycle:wr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:wr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Qi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:wr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Bd),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Qi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(cv(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Ga(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&s.push(u),u.callback(e,t)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=Ga(this.interceptors.postResolution.getAll(e)),u=c.next();!u.done;u=c.next()){var h=u.value;h.options.frequency!="Once"&&o.push(h),h.callback(e,t,n)}}catch(m){i={error:m}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===wr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===wr.Singleton,i=e.options.lifecycle===wr.ContainerScoped,s=n||i,o;return Za(e.provider)?o=e.provider.useValue:qa(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Id(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ku(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===wr.ResolutionScoped&&t.scopedResolutions.set(e,o),o},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Bd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Qi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return n.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Ga(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Ka(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(u){return!Za(u.provider)}).map(function(u){return u.instance=void 0,u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=Ga(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=Ka(s.value,2),c=o[0],u=o[1];u.some(function(h){var m=h.options;return m.lifecycle===wr.ContainerScoped})&&n._registry.setAll(c,u.map(function(h){return h.options.lifecycle===wr.ContainerScoped?{provider:h.provider,options:h.options}:h}))}}catch(h){e={error:h}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return nv(this,void 0,void 0,function(){var e;return iv(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof kd)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=Od.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,bi([void 0],o)))}();return pv(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var o,c,u;try{return av(i)?Cd(i)?i.multiple?(o=n.resolve(i.transform)).transform.apply(o,bi([n.resolveAll(i.token)],i.transformArgs)):(c=n.resolve(i.transform)).transform.apply(c,bi([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):Cd(i)?(u=n.resolve(i.transform,e)).transform.apply(u,bi([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(h){throw new Error(dv(t,s,h))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),fr=new mv;function Wa(){return function(r){Od.set(r,ov(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Bu;class Ya{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([y({type:b.ObjectIdentifier})],Ya.prototype,"attrId",void 0),f([y({type:b.Any,repeated:"set"})],Ya.prototype,"attrValues",void 0);let Td=Bu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Bu.prototype)}};Td=Bu=f([H({type:M.Sequence,itemType:Ya})],Td);var Ou;let Nd=Ou=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Ou.prototype)}};Nd=Ou=f([H({type:M.Sequence,itemType:En})],Nd);class jd{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],jd.prototype,"certId",void 0),f([y({type:b.Any,context:0})],jd.prototype,"certValue",void 0);class Pd{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Pd.prototype,"crlId",void 0),f([y({type:b.Any,context:0})],Pd.prototype,"crltValue",void 0);class Rd extends Qe{}let Ja=class{constructor(e={}){this.encryptionAlgorithm=new se,this.encryptedData=new Rd,Object.assign(this,e)}};f([y({type:se})],Ja.prototype,"encryptionAlgorithm",void 0),f([y({type:Rd})],Ja.prototype,"encryptedData",void 0);var Tu,Nu;(function(r){r[r.v1=0]="v1"})(Nu||(Nu={}));class Ud extends Qe{}let ju=Tu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Tu.prototype)}};ju=Tu=f([H({type:M.Sequence,itemType:Sn})],ju);class Vs{constructor(e={}){this.version=Nu.v1,this.privateKeyAlgorithm=new se,this.privateKey=new Ud,Object.assign(this,e)}}f([y({type:b.Integer})],Vs.prototype,"version",void 0),f([y({type:se})],Vs.prototype,"privateKeyAlgorithm",void 0),f([y({type:Ud})],Vs.prototype,"privateKey",void 0),f([y({type:ju,implicit:!0,context:0,optional:!0})],Vs.prototype,"attributes",void 0);let Dd=class extends Vs{};Dd=f([H({type:M.Sequence})],Dd);let $d=class extends Ja{};$d=f([H({type:M.Sequence})],$d);class Md{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Md.prototype,"secretTypeId",void 0),f([y({type:b.Any,context:0})],Md.prototype,"secretValue",void 0);class Ls{constructor(e={}){this.mac=new Fa,this.macSalt=new Qe,this.iterations=1,Object.assign(this,e)}}f([y({type:Fa})],Ls.prototype,"mac",void 0),f([y({type:Qe})],Ls.prototype,"macSalt",void 0),f([y({type:b.Integer,defaultValue:1})],Ls.prototype,"iterations",void 0);class Xa{constructor(e={}){this.version=3,this.authSafe=new En,this.macData=new Ls,Object.assign(this,e)}}f([y({type:b.Integer})],Xa.prototype,"version",void 0),f([y({type:En})],Xa.prototype,"authSafe",void 0),f([y({type:Ls,optional:!0})],Xa.prototype,"macData",void 0);var Pu;class Qa{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Qa.prototype,"bagId",void 0),f([y({type:b.Any,context:0})],Qa.prototype,"bagValue",void 0),f([y({type:Ya,repeated:"set",optional:!0})],Qa.prototype,"bagAttributes",void 0);let Vd=Pu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Pu.prototype)}};Vd=Pu=f([H({type:M.Sequence,itemType:Qa})],Vd);var Ru,Uu,Du;const Ld="1.2.840.113549.1.9",Hd=`${Ld}.7`,$u=`${Ld}.14`;let ec=class extends Yt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([y({type:b.IA5String})],ec.prototype,"ia5String",void 0),ec=f([H({type:M.Choice})],ec);let Fd=class extends En{};Fd=f([H({type:M.Sequence})],Fd);let zd=class extends Xa{};zd=f([H({type:M.Sequence})],zd);let Gd=class extends Ja{};Gd=f([H({type:M.Sequence})],Gd);let Mu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.IA5String})],Mu.prototype,"value",void 0),Mu=f([H({type:M.Choice})],Mu);let Kd=class extends ec{};Kd=f([H({type:M.Choice})],Kd);let qd=class extends Yt{};qd=f([H({type:M.Choice})],qd);let Vu=class{constructor(e=new Date){this.value=e}};f([y({type:b.GeneralizedTime})],Vu.prototype,"value",void 0),Vu=f([H({type:M.Choice})],Vu);let Zd=class extends Yt{};Zd=f([H({type:M.Choice})],Zd);let Lu=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([y({type:b.PrintableString})],Lu.prototype,"value",void 0),Lu=f([H({type:M.Choice})],Lu);let tc=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.PrintableString})],tc.prototype,"value",void 0),tc=f([H({type:M.Choice})],tc);let Wd=class extends tc{};Wd=f([H({type:M.Choice})],Wd);let Yd=class extends Yt{};Yd=f([H({type:M.Choice})],Yd);let Hu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.ObjectIdentifier})],Hu.prototype,"value",void 0),Hu=f([H({type:M.Choice})],Hu);let Jd=class extends Jt{};Jd=f([H({type:M.Choice})],Jd);let Fu=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([y({type:b.Integer})],Fu.prototype,"value",void 0),Fu=f([H({type:M.Choice})],Fu);let Xd=class extends nn{};Xd=f([H({type:M.Sequence})],Xd);let rc=class extends Yt{};rc=f([H({type:M.Choice})],rc);let Qd=Ru=class extends fi{constructor(e){super(e),Object.setPrototypeOf(this,Ru.prototype)}};Qd=Ru=f([H({type:M.Sequence})],Qd);let ep=Uu=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Uu.prototype)}};ep=Uu=f([H({type:M.Set,itemType:Gi})],ep);let zu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.BmpString})],zu.prototype,"value",void 0),zu=f([H({type:M.Choice})],zu);let Gu=class extends se{};Gu=f([H({type:M.Sequence})],Gu);let tp=Du=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Du.prototype)}};tp=Du=f([H({type:M.Sequence,itemType:Gu})],tp);var Ku;let nc=Ku=class extends yt{constructor(e){super(e),Object.setPrototypeOf(this,Ku.prototype)}};nc=Ku=f([H({type:M.Sequence,itemType:Sn})],nc);class es{constructor(e={}){this.version=0,this.subject=new zt,this.subjectPKInfo=new en,this.attributes=new nc,Object.assign(this,e)}}f([y({type:b.Integer})],es.prototype,"version",void 0),f([y({type:zt})],es.prototype,"subject",void 0),f([y({type:en})],es.prototype,"subjectPKInfo",void 0),f([y({type:nc,implicit:!0,context:0})],es.prototype,"attributes",void 0);class Hs{constructor(e={}){this.certificationRequestInfo=new es,this.signatureAlgorithm=new se,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:es})],Hs.prototype,"certificationRequestInfo",void 0),f([y({type:se})],Hs.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],Hs.prototype,"signature",void 0);/*!
90
+ `)}function dv(r,e,t){var n=Ka(r.toString().match(/constructor\(([\w, ]+)\)/)||[],2),i=n[1],s=i===void 0?null:i,o=fv(s,e);return hv("Cannot inject the dependency "+o+' of "'+r.name+'" constructor. Reason:',t)}function pv(r){if(typeof r.dispose!="function")return!1;var e=r.dispose;return!(e.length>0)}var yv=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Cu),gv=function(r){Iu(e,r);function e(){return r!==null&&r.apply(this,arguments)||this}return e}(Cu),vv=function(){function r(){this.preResolution=new yv,this.postResolution=new gv}return r}(),Od=new Map,mv=function(){function r(e){this.parent=e,this._registry=new uv,this.interceptors=new vv,this.disposed=!1,this.disposables=new Set}return r.prototype.register=function(e,t,n){n===void 0&&(n={lifecycle:wr.Transient}),this.ensureNotDisposed();var i;if(lv(t)?i=t:i={useClass:t},qa(i))for(var s=[e],o=i;o!=null;){var c=o.useToken;if(s.includes(c))throw new Error("Token registration cycle detected! "+bi(s,[c]).join(" -> "));s.push(c);var u=this._registry.get(c);u&&qa(u.provider)?o=u.provider:o=null}if((n.lifecycle===wr.Singleton||n.lifecycle==wr.ContainerScoped||n.lifecycle==wr.ResolutionScoped)&&(Za(i)||ku(i)))throw new Error('Cannot use lifecycle "'+wr[n.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(e,{provider:i,options:n}),this},r.prototype.registerType=function(e,t){return this.ensureNotDisposed(),Qi(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})},r.prototype.registerInstance=function(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})},r.prototype.registerSingleton=function(e,t){if(this.ensureNotDisposed(),Qi(e)){if(Qi(t))return this.register(e,{useToken:t},{lifecycle:wr.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:wr.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var n=e;return t&&!Qi(t)&&(n=t),this.register(e,{useClass:n},{lifecycle:wr.Singleton})},r.prototype.resolve=function(e,t){t===void 0&&(t=new Bd),this.ensureNotDisposed();var n=this.getRegistration(e);if(!n&&Qi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"Single"),n){var i=this.resolveRegistration(n,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}if(cv(e)){var i=this.construct(e,t);return this.executePostResolutionInterceptor(e,i,"Single"),i}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},r.prototype.executePreResolutionInterceptor=function(e,t){var n,i;if(this.interceptors.preResolution.has(e)){var s=[];try{for(var o=Ga(this.interceptors.preResolution.getAll(e)),c=o.next();!c.done;c=o.next()){var u=c.value;u.options.frequency!="Once"&&s.push(u),u.callback(e,t)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this.interceptors.preResolution.setAll(e,s)}},r.prototype.executePostResolutionInterceptor=function(e,t,n){var i,s;if(this.interceptors.postResolution.has(e)){var o=[];try{for(var c=Ga(this.interceptors.postResolution.getAll(e)),u=c.next();!u.done;u=c.next()){var h=u.value;h.options.frequency!="Once"&&o.push(h),h.callback(e,t,n)}}catch(m){i={error:m}}finally{try{u&&!u.done&&(s=c.return)&&s.call(c)}finally{if(i)throw i.error}}this.interceptors.postResolution.setAll(e,o)}},r.prototype.resolveRegistration=function(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===wr.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);var n=e.options.lifecycle===wr.Singleton,i=e.options.lifecycle===wr.ContainerScoped,s=n||i,o;return Za(e.provider)?o=e.provider.useValue:qa(e.provider)?o=s?e.instance||(e.instance=this.resolve(e.provider.useToken,t)):this.resolve(e.provider.useToken,t):Id(e.provider)?o=s?e.instance||(e.instance=this.construct(e.provider.useClass,t)):this.construct(e.provider.useClass,t):ku(e.provider)?o=e.provider.useFactory(this):o=this.construct(e.provider,t),e.options.lifecycle===wr.ResolutionScoped&&t.scopedResolutions.set(e,o),o},r.prototype.resolveAll=function(e,t){var n=this;t===void 0&&(t=new Bd),this.ensureNotDisposed();var i=this.getAllRegistrations(e);if(!i&&Qi(e))throw new Error('Attempted to resolve unregistered dependency token: "'+e.toString()+'"');if(this.executePreResolutionInterceptor(e,"All"),i){var s=i.map(function(c){return n.resolveRegistration(c,t)});return this.executePostResolutionInterceptor(e,s,"All"),s}var o=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,o,"All"),o},r.prototype.isRegistered=function(e,t){return t===void 0&&(t=!1),this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)},r.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},r.prototype.clearInstances=function(){var e,t;this.ensureNotDisposed();try{for(var n=Ga(this._registry.entries()),i=n.next();!i.done;i=n.next()){var s=Ka(i.value,2),o=s[0],c=s[1];this._registry.setAll(o,c.filter(function(u){return!Za(u.provider)}).map(function(u){return u.instance=void 0,u}))}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}},r.prototype.createChildContainer=function(){var e,t;this.ensureNotDisposed();var n=new r(this);try{for(var i=Ga(this._registry.entries()),s=i.next();!s.done;s=i.next()){var o=Ka(s.value,2),c=o[0],u=o[1];u.some(function(h){var m=h.options;return m.lifecycle===wr.ContainerScoped})&&n._registry.setAll(c,u.map(function(h){return h.options.lifecycle===wr.ContainerScoped?{provider:h.provider,options:h.options}:h}))}}catch(h){e={error:h}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return n},r.prototype.beforeResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.preResolution.set(e,{callback:t,options:n})},r.prototype.afterResolution=function(e,t,n){n===void 0&&(n={frequency:"Always"}),this.interceptors.postResolution.set(e,{callback:t,options:n})},r.prototype.dispose=function(){return nv(this,void 0,void 0,function(){var e;return iv(this,function(t){switch(t.label){case 0:return this.disposed=!0,e=[],this.disposables.forEach(function(n){var i=n.dispose();i&&e.push(i)}),[4,Promise.all(e)];case 1:return t.sent(),[2]}})})},r.prototype.getRegistration=function(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null},r.prototype.getAllRegistrations=function(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null},r.prototype.construct=function(e,t){var n=this;if(e instanceof kd)return e.createProxy(function(s){return n.resolve(s,t)});var i=function(){var s=Od.get(e);if(!s||s.length===0){if(e.length===0)return new e;throw new Error('TypeInfo not known for "'+e.name+'"')}var o=s.map(n.resolveParams(t,e));return new(e.bind.apply(e,bi([void 0],o)))}();return pv(i)&&this.disposables.add(i),i},r.prototype.resolveParams=function(e,t){var n=this;return function(i,s){var o,c,u;try{return av(i)?Cd(i)?i.multiple?(o=n.resolve(i.transform)).transform.apply(o,bi([n.resolveAll(i.token)],i.transformArgs)):(c=n.resolve(i.transform)).transform.apply(c,bi([n.resolve(i.token,e)],i.transformArgs)):i.multiple?n.resolveAll(i.token):n.resolve(i.token,e):Cd(i)?(u=n.resolve(i.transform,e)).transform.apply(u,bi([n.resolve(i.token,e)],i.transformArgs)):n.resolve(i,e)}catch(h){throw new Error(dv(t,s,h))}}},r.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},r}(),fr=new mv;function Wa(){return function(r){Od.set(r,ov(r))}}if(typeof Reflect>"u"||!Reflect.getMetadata)throw new Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var Bu;class Ya{constructor(e={}){this.attrId="",this.attrValues=[],Object.assign(e)}}f([y({type:b.ObjectIdentifier})],Ya.prototype,"attrId",void 0),f([y({type:b.Any,repeated:"set"})],Ya.prototype,"attrValues",void 0);let Td=Bu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Bu.prototype)}};Td=Bu=f([H({type:M.Sequence,itemType:Ya})],Td);var Ou;let Nd=Ou=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Ou.prototype)}};Nd=Ou=f([H({type:M.Sequence,itemType:En})],Nd);class Pd{constructor(e={}){this.certId="",this.certValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Pd.prototype,"certId",void 0),f([y({type:b.Any,context:0})],Pd.prototype,"certValue",void 0);class jd{constructor(e={}){this.crlId="",this.crltValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],jd.prototype,"crlId",void 0),f([y({type:b.Any,context:0})],jd.prototype,"crltValue",void 0);class Rd extends tt{}let Ja=class{constructor(e={}){this.encryptionAlgorithm=new ne,this.encryptedData=new Rd,Object.assign(this,e)}};f([y({type:ne})],Ja.prototype,"encryptionAlgorithm",void 0),f([y({type:Rd})],Ja.prototype,"encryptedData",void 0);var Tu,Nu;(function(r){r[r.v1=0]="v1"})(Nu||(Nu={}));class Ud extends tt{}let Pu=Tu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Tu.prototype)}};Pu=Tu=f([H({type:M.Sequence,itemType:Sn})],Pu);class Vs{constructor(e={}){this.version=Nu.v1,this.privateKeyAlgorithm=new ne,this.privateKey=new Ud,Object.assign(this,e)}}f([y({type:b.Integer})],Vs.prototype,"version",void 0),f([y({type:ne})],Vs.prototype,"privateKeyAlgorithm",void 0),f([y({type:Ud})],Vs.prototype,"privateKey",void 0),f([y({type:Pu,implicit:!0,context:0,optional:!0})],Vs.prototype,"attributes",void 0);let Dd=class extends Vs{};Dd=f([H({type:M.Sequence})],Dd);let $d=class extends Ja{};$d=f([H({type:M.Sequence})],$d);class Md{constructor(e={}){this.secretTypeId="",this.secretValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Md.prototype,"secretTypeId",void 0),f([y({type:b.Any,context:0})],Md.prototype,"secretValue",void 0);class Ls{constructor(e={}){this.mac=new Fa,this.macSalt=new tt,this.iterations=1,Object.assign(this,e)}}f([y({type:Fa})],Ls.prototype,"mac",void 0),f([y({type:tt})],Ls.prototype,"macSalt",void 0),f([y({type:b.Integer,defaultValue:1})],Ls.prototype,"iterations",void 0);class Xa{constructor(e={}){this.version=3,this.authSafe=new En,this.macData=new Ls,Object.assign(this,e)}}f([y({type:b.Integer})],Xa.prototype,"version",void 0),f([y({type:En})],Xa.prototype,"authSafe",void 0),f([y({type:Ls,optional:!0})],Xa.prototype,"macData",void 0);var ju;class Qa{constructor(e={}){this.bagId="",this.bagValue=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:b.ObjectIdentifier})],Qa.prototype,"bagId",void 0),f([y({type:b.Any,context:0})],Qa.prototype,"bagValue",void 0),f([y({type:Ya,repeated:"set",optional:!0})],Qa.prototype,"bagAttributes",void 0);let Vd=ju=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,ju.prototype)}};Vd=ju=f([H({type:M.Sequence,itemType:Qa})],Vd);var Ru,Uu,Du;const Ld="1.2.840.113549.1.9",Hd=`${Ld}.7`,$u=`${Ld}.14`;let ec=class extends Yt{constructor(e={}){super(e)}toString(){return this.ia5String||super.toString()}};f([y({type:b.IA5String})],ec.prototype,"ia5String",void 0),ec=f([H({type:M.Choice})],ec);let Fd=class extends En{};Fd=f([H({type:M.Sequence})],Fd);let zd=class extends Xa{};zd=f([H({type:M.Sequence})],zd);let Gd=class extends Ja{};Gd=f([H({type:M.Sequence})],Gd);let Mu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.IA5String})],Mu.prototype,"value",void 0),Mu=f([H({type:M.Choice})],Mu);let Kd=class extends ec{};Kd=f([H({type:M.Choice})],Kd);let qd=class extends Yt{};qd=f([H({type:M.Choice})],qd);let Vu=class{constructor(e=new Date){this.value=e}};f([y({type:b.GeneralizedTime})],Vu.prototype,"value",void 0),Vu=f([H({type:M.Choice})],Vu);let Zd=class extends Yt{};Zd=f([H({type:M.Choice})],Zd);let Lu=class{constructor(e="M"){this.value=e}toString(){return this.value}};f([y({type:b.PrintableString})],Lu.prototype,"value",void 0),Lu=f([H({type:M.Choice})],Lu);let tc=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.PrintableString})],tc.prototype,"value",void 0),tc=f([H({type:M.Choice})],tc);let Wd=class extends tc{};Wd=f([H({type:M.Choice})],Wd);let Yd=class extends Yt{};Yd=f([H({type:M.Choice})],Yd);let Hu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.ObjectIdentifier})],Hu.prototype,"value",void 0),Hu=f([H({type:M.Choice})],Hu);let Jd=class extends Jt{};Jd=f([H({type:M.Choice})],Jd);let Fu=class{constructor(e=0){this.value=e}toString(){return this.value.toString()}};f([y({type:b.Integer})],Fu.prototype,"value",void 0),Fu=f([H({type:M.Choice})],Fu);let Xd=class extends nn{};Xd=f([H({type:M.Sequence})],Xd);let rc=class extends Yt{};rc=f([H({type:M.Choice})],rc);let Qd=Ru=class extends fi{constructor(e){super(e),Object.setPrototypeOf(this,Ru.prototype)}};Qd=Ru=f([H({type:M.Sequence})],Qd);let ep=Uu=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Uu.prototype)}};ep=Uu=f([H({type:M.Set,itemType:Gi})],ep);let zu=class{constructor(e=""){this.value=e}toString(){return this.value}};f([y({type:b.BmpString})],zu.prototype,"value",void 0),zu=f([H({type:M.Choice})],zu);let Gu=class extends ne{};Gu=f([H({type:M.Sequence})],Gu);let tp=Du=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Du.prototype)}};tp=Du=f([H({type:M.Sequence,itemType:Gu})],tp);var Ku;let nc=Ku=class extends vt{constructor(e){super(e),Object.setPrototypeOf(this,Ku.prototype)}};nc=Ku=f([H({type:M.Sequence,itemType:Sn})],nc);class es{constructor(e={}){this.version=0,this.subject=new zt,this.subjectPKInfo=new en,this.attributes=new nc,Object.assign(this,e)}}f([y({type:b.Integer})],es.prototype,"version",void 0),f([y({type:zt})],es.prototype,"subject",void 0),f([y({type:en})],es.prototype,"subjectPKInfo",void 0),f([y({type:nc,implicit:!0,context:0})],es.prototype,"attributes",void 0);class Hs{constructor(e={}){this.certificationRequestInfo=new es,this.signatureAlgorithm=new ne,this.signature=new ArrayBuffer(0),Object.assign(this,e)}}f([y({type:es})],Hs.prototype,"certificationRequestInfo",void 0),f([y({type:ne})],Hs.prototype,"signatureAlgorithm",void 0),f([y({type:b.BitString})],Hs.prototype,"signature",void 0);/*!
91
91
  * MIT License
92
92
  *
93
93
  * Copyright (c) Peculiar Ventures. All rights reserved.
@@ -110,24 +110,24 @@ ${e.join(`
110
110
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
111
111
  * SOFTWARE.
112
112
  *
113
- */const Fs="crypto.algorithm";class wv{getAlgorithms(){return fr.resolveAll(Fs)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new se({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const ts="crypto.algorithmProvider";fr.registerSingleton(ts,wv);var ic;const br="1.3.36.3.3.2.8.1.1",rp=`${br}.1`,np=`${br}.2`,ip=`${br}.3`,sp=`${br}.4`,op=`${br}.5`,ap=`${br}.6`,cp=`${br}.7`,lp=`${br}.8`,up=`${br}.9`,fp=`${br}.10`,hp=`${br}.11`,dp=`${br}.12`,pp=`${br}.13`,yp=`${br}.14`,gp="brainpoolP160r1",vp="brainpoolP160t1",mp="brainpoolP192r1",wp="brainpoolP192t1",bp="brainpoolP224r1",xp="brainpoolP224t1",Ap="brainpoolP256r1",Sp="brainpoolP256t1",_p="brainpoolP320r1",Ep="brainpoolP320t1",Ip="brainpoolP384r1",kp="brainpoolP384t1",Cp="brainpoolP512r1",Bp="brainpoolP512t1",It="ECDSA";let zs=ic=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case It.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Fg;case"sha-256":return zg;case"sha-384":return Gg;case"sha-512":return Kg}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=md;break;case"K-256":t=ic.SECP256K1;break;case"P-384":t=wd;break;case"P-521":t=bd;break;case gp:t=rp;break;case vp:t=np;break;case mp:t=ip;break;case wp:t=sp;break;case bp:t=op;break;case xp:t=ap;break;case Ap:t=cp;break;case Sp:t=lp;break;case _p:t=up;break;case Ep:t=fp;break;case Ip:t=hp;break;case kp:t=dp;break;case Cp:t=pp;break;case Bp:t=yp;break}if(t)return new se({algorithm:Us,parameters:q.serialize(new Dn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case yu:return{name:It,hash:{name:"SHA-1"}};case gu:return{name:It,hash:{name:"SHA-256"}};case vu:return{name:It,hash:{name:"SHA-384"}};case mu:return{name:It,hash:{name:"SHA-512"}};case Us:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,Dn).namedCurve){case md:return{name:It,namedCurve:"P-256"};case ic.SECP256K1:return{name:It,namedCurve:"K-256"};case wd:return{name:It,namedCurve:"P-384"};case bd:return{name:It,namedCurve:"P-521"};case rp:return{name:It,namedCurve:gp};case np:return{name:It,namedCurve:vp};case ip:return{name:It,namedCurve:mp};case sp:return{name:It,namedCurve:wp};case op:return{name:It,namedCurve:bp};case ap:return{name:It,namedCurve:xp};case cp:return{name:It,namedCurve:Ap};case lp:return{name:It,namedCurve:Sp};case up:return{name:It,namedCurve:_p};case fp:return{name:It,namedCurve:Ep};case hp:return{name:It,namedCurve:Ip};case dp:return{name:It,namedCurve:kp};case pp:return{name:It,namedCurve:Cp};case yp:return{name:It,namedCurve:Bp}}}}return null}};zs.SECP256K1="1.3.132.0.10",zs=ic=f([Wa()],zs),fr.registerSingleton(Fs,zs);const Op=Symbol("name"),Tp=Symbol("value");class et{constructor(e,t={},n=""){this[Op]=e,this[Tp]=n;for(const i in t)this[i]=t[i]}}et.NAME=Op,et.VALUE=Tp;class bv{static toTextObject(e){const t=new et("Algorithm Identifier",{},Cn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Us:{const n=new zs().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Cn{static toString(e){const t=this.items[e];return t||e}}Cn.items={[Da]:"sha1",[Sd]:"sha224",[$a]:"sha256",[Ma]:"sha384",[Va]:"sha512",[vi]:"rsaEncryption",[Pa]:"sha1WithRSAEncryption",[Xg]:"sha224WithRSAEncryption",[bu]:"sha256WithRSAEncryption",[Ra]:"sha384WithRSAEncryption",[Ua]:"sha512WithRSAEncryption",[Us]:"ecPublicKey",[yu]:"ecdsaWithSHA1",[vd]:"ecdsaWithSHA224",[gu]:"ecdsaWithSHA256",[vu]:"ecdsaWithSHA384",[mu]:"ecdsaWithSHA512",[Ug]:"TLS WWW server authentication",[Dg]:"TLS WWW client authentication",[$g]:"Code Signing",[Mg]:"E-mail Protection",[Vg]:"Time Stamping",[Lg]:"OCSP Signing",[du]:"Signed Data"};class $n{static serialize(e){return this.serializeObj(e).join(`
114
- `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const o=e[et.VALUE];o&&(s=` ${o}`),n.push(`${i}${e[et.NAME]}:${s}`),i=this.pad(t);for(const c in e){if(typeof c=="symbol")continue;const u=e[c],h=c?`${c}: `:"";if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")n.push(`${i}${h}${u}`);else if(u instanceof Date)n.push(`${i}${h}${u.toUTCString()}`);else if(Array.isArray(u))for(const m of u)m[et.NAME]=c,n.push(...this.serializeObj(m,t));else if(u instanceof et)u[et.NAME]=c,n.push(...this.serializeObj(u,t));else if(W.isBufferSource(u))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(u,t+1))):n.push(...this.serializeBufferSource(u,t));else if("toTextObject"in u){const m=u.toTextObject();m[et.NAME]=c,n.push(...this.serializeObj(m,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=W.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let u=0;u<16&&o<i.length;u++){u===8&&c.push("");const h=i[o++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}$n.oidSerializer=Cn,$n.algorithmSerializer=bv;class Mn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=q.serialize(t),this.onInit(t)}else{const t=q.parse(e[0],e[1]);this.rawData=W.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Mn?No(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return $n.serialize(this.toTextObject());case"hex":return fe.ToHex(this.rawData);case"base64":return fe.ToBase64(this.rawData);case"base64url":return fe.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 et(this.getTextName(),{},e)}}Mn.NAME="ASN";class Pr extends Mn{constructor(...e){let t;W.isBufferSource(e[0])?t=W.toArrayBuffer(e[0]):t=q.serialize(new Hr({extnID:e[0],critical:e[1],extnValue:new Qe(W.toArrayBuffer(e[2]))})),super(t,Hr)}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[et.NAME]===Pr.NAME&&(e[et.NAME]=Cn.toString(this.type)),e}}var Np;class Vn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Np]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Vn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Vn.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=Vn.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(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(Vn.DEFAULT,e);return this}}Np=Symbol.toStringTag,Vn.DEFAULT="default";const Xt=new Vn,xv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Av(r){return new RegExp(xv).test(r)}class jp{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Av(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const xr=new jp;xr.register("CN","2.5.4.3"),xr.register("L","2.5.4.7"),xr.register("ST","2.5.4.8"),xr.register("O","2.5.4.10"),xr.register("OU","2.5.4.11"),xr.register("C","2.5.4.6"),xr.register("DC","0.9.2342.19200300.100.1.25"),xr.register("E","1.2.840.113549.1.9.1"),xr.register("G","2.5.4.42"),xr.register("I","2.5.4.43"),xr.register("SN","2.5.4.4"),xr.register("T","2.5.4.12");function Sv(r,e){return`\\${fe.ToHex(fe.FromUtf8String(e)).toUpperCase()}`}function _v(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Sv)}class Ln{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 jp,this.asn=new zt;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof zt?this.asn=e:W.isBufferSource(e)?this.asn=q.parse(e,zt):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||xr.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||xr.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${fe.ToHex(t.value.anyValue)}`:_v(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].push(s.value.anyValue?`#${fe.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new zt,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,o,c]=i;const u=c[c.length-1];(u===","||u==="+")&&(c=c.slice(0,c.length-1),i[3]=u);const h=i[3];o=this.getTypeOid(o);const m=this.createAttribute(o,c);s==="+"?t[t.length-1].push(m):t.push(new Di([m])),s=h}return t}fromJSON(e){const t=new zt;for(const n of e){const i=new Di;for(const s in n){const o=this.getTypeOid(s),c=n[s];for(const u of c){const h=this.createAttribute(o,u);i.push(h)}}t.push(i)}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 n=new Qo({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=fe.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Ln.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
- `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const Pp="Cannot initialize GeneralName from ASN.1 data.",Rp=`${Pp} Unsupported string format in use.`,Ev=`${Pp} Value doesn't match to GUID regular expression.`,Up=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Dp="1.3.6.1.4.1.311.25.1",$p="1.3.6.1.4.1.311.20.2.3",qu="dns",Zu="dn",Wu="email",Yu="ip",Ju="url",Xu="guid",Qu="upn",sc="id";class Hn extends Mn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Zu:{const n=new Ln(e[1]).toArrayBuffer(),i=q.parse(n,zt);t=new Pe({directoryName:i});break}case qu:t=new Pe({dNSName:e[1]});break;case Wu:t=new Pe({rfc822Name:e[1]});break;case Xu:{const n=new RegExp(Up,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,o)=>o<3?fe.ToHex(new Uint8Array(fe.FromHex(s)).reverse()):s).join("");t=new Pe({otherName:new As({typeId:Dp,value:q.serialize(new Qe(fe.FromHex(i)))})});break}case Yu:t=new Pe({iPAddress:e[1]});break;case sc:t=new Pe({registeredID:e[1]});break;case Qu:{t=new Pe({otherName:new As({typeId:$p,value:q.serialize($h.toASN(e[1]))})});break}case Ju:t=new Pe({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else W.isBufferSource(e[0])?t=q.parse(e[0],Pe):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=qu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Wu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Yu,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Ju,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=sc,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Zu,this.value=new Ln(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Dp){this.type=Xu;const t=q.parse(e.otherName.value,Qe),n=new RegExp(Up,"i").exec(fe.ToHex(t));if(!n)throw new Error(Ev);this.value=n.slice(1).map((i,s)=>s<3?fe.ToHex(new Uint8Array(fe.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===$p)this.type=Qu,this.value=q.parse(e.otherName.value,Yt).toString();else throw new Error(Rp);else throw new Error(Rp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Zu:case qu:case Xu:case Yu:case sc:case Qu:case Ju:e=this.type.toUpperCase();break;case Wu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===sc&&(t=Cn.toString(t)),new et(e,void 0,t)}}class Gs extends Mn{constructor(e){let t;if(e instanceof ur)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof Pe)n.push(i);else{const s=q.parse(new Hn(i.type,i.value).rawData,Pe);n.push(s)}t=new ur(n)}else if(W.isBufferSource(e))t=q.parse(e,ur);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new Hn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[et.NAME]];Array.isArray(i)||(i=[],e[n[et.NAME]]=i),i.push(n)}return e}}Gs.NAME="GeneralNames";const Ks="-{5}",qs="\\n",Iv=`[^${qs}]+`,kv=`${Ks}BEGIN (${Iv}(?=${Ks}))${Ks}`,Cv=`${Ks}END \\1${Ks}`,rs="\\n",Bv=`[^:${qs}]+`,Ov=`(?:[^${qs}]+${rs}(?: +[^${qs}]+${rs})*)`,Tv=`(?:[a-zA-Z0-9=+/]+${rs})+`,Mp=`${kv}${rs}(?:((?:${Bv}: ${Ov})+))?${rs}?(${Tv})${Cv}`;class Ar{static isPem(e){return typeof e=="string"&&new RegExp(Mp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Mp,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${qs}]+`,"g"),""),o={type:i[1],headers:[],rawData:fe.FromBase64(s)},c=i[2];if(c){const u=c.split(new RegExp(rs,"g"));let h=null;for(const m of u){const[x,G]=m.split(/:(.*)/);if(G===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=x.trim()}else h&&o.headers.push(h),h={key:x,value:G.trim()}}h&&o.headers.push(h)}n.push(o)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.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 n=new Array;return t?e.forEach(i=>{if(!W.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:W.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
116
- `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:W.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const h of e.headers)i.push(`${h.key}: ${h.value}`);i.push("")}const s=fe.ToBase64(e.rawData);let o,c=0;const u=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(u.push(o),o.length<64)break;return i.push(...u),i.push(`-----END ${n}-----`),i.join(`
117
- `)}}Ar.CertificateTag="CERTIFICATE",Ar.CrlTag="CRL",Ar.CertificateRequestTag="CERTIFICATE REQUEST",Ar.PublicKeyTag="PUBLIC KEY",Ar.PrivateKeyTag="PRIVATE KEY";class zr extends Mn{static isAsnEncoded(e){return W.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ar.isPem(e))return Ar.decode(e)[0];if(fe.isHex(e))return fe.FromHex(e);if(fe.isBase64(e))return fe.FromBase64(e);if(fe.isBase64Url(e))return fe.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=fe.ToBinary(e);return Ar.isPem(t)?Ar.decode(t)[0]:fe.isHex(t)?fe.FromHex(t):fe.isBase64(t)?fe.FromBase64(t):fe.isBase64Url(t)?fe.FromBase64Url(t):W.toArrayBuffer(e)}}constructor(...e){zr.isAsnEncoded(e[0])?super(zr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ar.encode(this.rawData,this.tag);default:return super.toString(e)}}}class on extends zr{static async create(e,t=Xt.get()){if(e instanceof on)return e;if(Vn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new on(n)}else{if(e.publicKey)return e.publicKey;if(W.isBufferSource(e))return new on(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){zr.isAsnEncoded(e)?super(e,en):super(e),this.tag=Ar.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||Xt.get()):t=e[0]||Xt.get();let s=this.rawData;const o=q.parse(this.rawData,en);return o.algorithm.algorithm===Ms&&(s=Nv(o,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=fr.resolve(ts),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case vi:{const i=q.parse(e.subjectPublicKey,Su),s=W.toUint8Array(i.modulus);n.publicExponent=W.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=Xt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=Xt.get();const i=q.parse(this.rawData,en);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,en);switch(e.Algorithm=$n.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Us:e["EC Point"]=t.subjectPublicKey;break;case vi:default:e["Raw Data"]=t.subjectPublicKey}return e}}function Nv(r,e){return r.algorithm=new se({algorithm:vi,parameters:null}),e=q.serialize(r),e}class Zs extends Pr{static async create(e,t=!1,n=Xt.get()){if("name"in e&&"serialNumber"in e)return new Zs(e,t);const s=await(await on.create(e,n)).getKeyIdentifier(n);return new Zs(fe.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new li({keyIdentifier:new gl(fe.FromHex(e[0]))});super(ta,e[1],q.serialize(t))}else{const t=e[0],n=t.name instanceof Gs?q.parse(t.name.rawData,ur):t.name,i=new li({authorityCertIssuer:n,authorityCertSerialNumber:fe.FromHex(t.serialNumber)});super(ta,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,li);t.keyIdentifier&&(this.keyId=fe.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?fe.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,li);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Gs(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Zs.NAME="Authority Key Identifier";class Vp extends Pr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,ra);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new ra({cA:e[0],pathLenConstraint:e[1]});super(Zh,e[2],q.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Vp.NAME="Basic Constraints";var Lp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Lp||(Lp={}));class Hp extends Pr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,aa);this.usages=t.map(n=>n)}else{const t=new aa(e[0]);super(ed,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Cn.toString(t)).join(", "),e}}Hp.NAME="Extended Key Usages";var Fp;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Fp||(Fp={}));class zp extends Pr{constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Tl);this.usages=t.toNumber()}else{const t=new Tl(e[0]);super(rd,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Tl);return e[""]=t.toJSON().join(", "),e}}zp.NAME="Key Usages";class oc extends Pr{static async create(e,t=!1,n=Xt.get()){const s=await(await on.create(e,n)).getKeyIdentifier(n);return new oc(fe.ToHex(s),t)}constructor(...e){if(W.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Rn);this.keyId=fe.ToHex(t)}else{const t=typeof e[0]=="string"?fe.FromHex(e[0]):e[0],n=new Rn(t);super(Ml,e[1],q.serialize(n)),this.keyId=fe.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Rn);return e[""]=t,e}}oc.NAME="Subject Key Identifier";class Gp extends Pr{constructor(...e){W.isBufferSource(e[0])?super(e[0]):super(Ul,e[1],new Gs(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,Dl);this.names=new Gs(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Gp.NAME="Subject Alternative Name";class Rr{static register(e,t){this.items.set(e,t)}static create(e){const t=new Pr(e),n=this.items.get(t.type);return n?new n(e):t}}Rr.items=new Map;class Kp extends Pr{constructor(...e){var t;if(W.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,sa);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new sa(n.map(o=>new ia({policyIdentifier:o})));super(Yh,i,q.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new et("",{},Cn.toString(t))),e}}Kp.NAME="Certificate Policies",Rr.register(Yh,Kp);class qp extends Pr{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new Vi({distributionPoint:new ui({fullName:[new Pe({uniformResourceIdentifier:o})]})})),s=new Li(i);super(_l,e[1],q.serialize(s))}else{const n=new Li(e[0]);super(_l,e[1],q.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,Li);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Hn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}qp.NAME="CRL Distribution Points";class Zp extends Pr{constructor(...e){var t,n,i,s;if(W.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Mi){const o=new Mi(e[0]);super(yl,e[1],q.serialize(o))}else{const o=e[0],c=new Mi;cc(c,o,zh,"ocsp"),cc(c,o,Gh,"caIssuers"),cc(c,o,Kh,"timeStamping"),cc(c,o,qh,"caRepository"),super(yl,e[1],q.serialize(c))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Mi).forEach(n=>{switch(n.accessMethod){case zh:this.ocsp.push(new Hn(n.accessLocation));break;case Gh:this.caIssuers.push(new Hn(n.accessLocation));break;case Kh:this.timeStamping.push(new Hn(n.accessLocation));break;case qh:this.caRepository.push(new Hn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ac(e,"OCSP",this.ocsp),this.caIssuers.length&&ac(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ac(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ac(e,"CA Repository",this.caRepository),e}}Zp.NAME="Authority Info Access";function ac(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new et("");t.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[et.NAME]} ${s+1}`;let u=n[c];Array.isArray(u)||(u=[],n[c]=u),u.push(o)}),r[e]=n}}function cc(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Hn("url",o)),r.push(new Ss({accessMethod:t,accessLocation:q.parse(o.rawData,Pe)}))})}class ns extends Mn{constructor(...e){let t;if(W.isBufferSource(e[0]))t=W.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>W.toArrayBuffer(s)):[];t=q.serialize(new Sn({type:n,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(t=>new et("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[et.NAME]===ns.NAME&&(e[et.NAME]=Cn.toString(this.type)),e}}ns.NAME="Attribute";class Wp extends ns{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=new rc({printableString:e[0]});super(Hd,[q.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],rc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[et.VALUE]=this.password,e}}Wp.NAME="Challenge Password";class ef extends ns{constructor(...e){var t;if(W.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new fi;for(const s of n)i.push(q.parse(s.rawData,Hr));super($u,[q.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],fi);this.items=t.map(n=>Rr.create(q.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[et.NAME]]=n;return e}}ef.NAME="Extensions";class lc{static register(e,t){this.items.set(e,t)}static create(e){const t=new ns(e),n=this.items.get(t.type);return n?new n(e):t}}lc.items=new Map;const uc="crypto.signatureFormatter";class jv{toAsnSignature(e,t){return W.toArrayBuffer(t)}toWebSignature(e,t){return W.toArrayBuffer(t)}}var fc;let tf=fc=class{static createPssParams(e,t){const n=fc.getHashAlgorithm(e);return n?new wi({hashAlgorithm:n,maskGenAlgorithm:new se({algorithm:La,parameters:q.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=fr.resolve(ts);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new se({algorithm:Pa,parameters:null});case"sha-256":return new se({algorithm:bu,parameters:null});case"sha-384":return new se({algorithm:Ra,parameters:null});case"sha-512":return new se({algorithm:Ua,parameters:null})}}else return new se({algorithm:vi,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=fc.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new se({algorithm:Ms,parameters:q.serialize(t)})}else return new se({algorithm:Ms,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case vi:return{name:"RSASSA-PKCS1-v1_5"};case Pa:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case bu:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ra:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ua:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ms:if(e.parameters){const t=q.parse(e.parameters,wi);return{name:"RSA-PSS",hash:fr.resolve(ts).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};tf=fc=f([Wa()],tf),fr.registerSingleton(Fs,tf);let rf=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new se({algorithm:Da});case"sha-256":return new se({algorithm:$a});case"sha-384":return new se({algorithm:Ma});case"sha-512":return new se({algorithm:Va})}return null}toWebAlgorithm(e){switch(e.algorithm){case Da:return{name:"SHA-1"};case $a:return{name:"SHA-256"};case Ma:return{name:"SHA-384"};case Va:return{name:"SHA-512"}}return null}};rf=f([Wa()],rf),fr.registerSingleton(Fs,rf);class Ur{addPadding(e,t){const n=W.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=W.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Ur.namedCurveSize.get(n)||Ur.defaultNamedCurveSize,s=new ja,o=W.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=q.parse(t,ja),i=e.namedCurve,s=Ur.namedCurveSize.get(i)||Ur.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return qy(o,c)}return null}}Ur.namedCurveSize=new Map,Ur.defaultNamedCurveSize=32;const nf="1.3.101.110",Yp="1.3.101.111",sf="1.3.101.112",Jp="1.3.101.113";let of=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=sf;break;case"x25519":t=nf;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=sf;break;case"ed448":t=Jp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=nf;break;case"x448":t=Yp;break}}return t?new se({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case sf:return{name:"Ed25519"};case Jp:return{name:"EdDSA",namedCurve:"Ed448"};case nf:return{name:"X25519"};case Yp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};of=f([Wa()],of),fr.registerSingleton(Fs,of);class Pv extends zr{constructor(e){zr.isAsnEncoded(e)?super(e,Hs):super(e),this.tag=Ar.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new on(e.certificationRequestInfo.subjectPKInfo);const t=fr.resolve(ts);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>lc.create(q.serialize(i)));const n=this.getAttribute($u);this.extensions=[],n instanceof ef&&(this.extensions=n.items),this.subjectName=new Ln(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}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=Xt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=fr.resolveAll(uc).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Hs),n=t.certificationRequestInfo,i=new et("",{Version:`${Hi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new et("");for(const o of this.attributes){const c=o.toTextObject();s[c[et.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new et("",{Algorithm:$n.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}Pv.NAME="PKCS#10 Certificate Request";class xi extends zr{constructor(e){zr.isAsnEncoded(e)?super(e,hi):super(e),this.tag=Ar.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=q.serialize(t),this.serialNumber=fe.ToHex(t.serialNumber),this.subjectName=new Ln(t.subject),this.subject=new Ln(t.subject).toString(),this.issuerName=new Ln(t.issuer),this.issuer=this.issuerName.toString();const n=fr.resolve(ts);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(o=>Rr.create(q.serialize(o)))),this.publicKey=new on(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=Xt.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof on)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(W.isBufferSource(s)){const h=new on(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=fr.resolveAll(uc).reverse();let c=null;for(const h of o)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const u=await t.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return u;{const m=(e.date||new Date).getTime();return u&&this.notBefore.getTime()<m&&m<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=Xt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=Xt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,hi),n=t.tbsCertificate,i=new et("",{Version:`${Hi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":$n.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new et("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new et("");for(const o of this.extensions){const c=o.toTextObject();s[c[et.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new et("",{Algorithm:$n.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}xi.NAME="Certificate";class Rv extends Array{constructor(e){if(super(),zr.isAsnEncoded(e))this.import(e);else if(e instanceof xi)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new In;t.version=1,t.encapContentInfo.eContentType=Hg,t.encapContentInfo.eContent=new Zi({single:new Qe}),t.certificates=new Cs(this.map(s=>new yi({certificate:q.parse(s.rawData,hi)})));const n=new En({contentType:du,content:q.serialize(t)}),i=q.serialize(n);return e==="raw"?i:this.toString(e)}import(e){const t=zr.toArrayBuffer(e),n=q.parse(t,En);if(n.contentType!==du)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=q.parse(n.content,In);this.clear();for(const s of i.certificates||[])s.certificate&&this.push(new xi(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return Ar.encode(t,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
118
- `);case"asn":return q.toString(t);case"hex":return fe.ToHex(t);case"base64":return fe.ToBase64(t);case"base64url":return fe.ToBase64Url(t);case"text":return $n.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=q.parse(this.export("raw"),En),t=q.parse(e.content,In);return new et("X509Certificates",{"Content Type":Cn.toString(e.contentType),Content:new et("",{Version:`${tn[t.version]} (${t.version})`,Certificates:new et("",{Certificate:this.map(i=>i.toTextObject())})})})}}class Uv{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=Xt.get()){const n=new Rv(e);let i=e;for(;i=await this.findIssuer(i,t);){const s=await i.getThumbprint(t);for(const o of n){const c=await o.getThumbprint(t);if(No(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,t=Xt.get()){if(!await e.isSelfSigned(t)){const n=e.getExtension(ta);for(const i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){const s=i.getExtension(Ml);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){const s=i.getExtension(Ul);if(s&&!(n.certId.serialNumber===i.serialNumber&&No(q.serialize(n.certId.name),q.serialize(s))))continue}}try{const s={...i.publicKey.algorithm,...e.signatureAlgorithm},o=await i.publicKey.export(s,["verify"],t);if(!await e.verify({publicKey:o,signatureOnly:!0},t))continue}catch{continue}return i}}return null}}var Xp;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Xp||(Xp={})),Rr.register(Zh,Vp),Rr.register(ed,Hp),Rr.register(rd,zp),Rr.register(Ml,oc),Rr.register(ta,Zs),Rr.register(Ul,Gp),Rr.register(_l,qp),Rr.register(yl,Zp),lc.register(Hd,Wp),lc.register($u,ef),fr.registerSingleton(uc,jv),fr.registerSingleton(uc,Ur),Ur.namedCurveSize.set("P-256",32),Ur.namedCurveSize.set("K-256",32),Ur.namedCurveSize.set("P-384",48),Ur.namedCurveSize.set("P-521",66);const ve={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},St={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,SET:258,JSON:262,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},xt={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Fn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ir=(vo=class{},He(vo,"BREAK",Symbol.for("github.com/hildjj/cbor2/break")),He(vo,"ENCODED",Symbol.for("github.com/hildjj/cbor2/cbor-encoded")),He(vo,"LENGTH",Symbol.for("github.com/hildjj/cbor2/length")),vo);const hc={MIN:-(2n**63n),MAX:2n**64n-1n};let Ze=(Tn=class{constructor(e,t=void 0){He(this,"tag");He(this,"contents");this.tag=e,this.contents=t}get noChildren(){var e;return!!((e=$(Tn,un).get(this.tag))!=null&&e.noChildren)}static registerDecoder(e,t,n){const i=$(this,un).get(e);return $(this,un).set(e,t),i&&("comment"in t||(t.comment=i.comment),"noChildren"in t||(t.noChildren=i.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),i}static clearDecoder(e){const t=$(this,un).get(e);return $(this,un).delete(e),t}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const t=$(Tn,un).get(this.tag);return t?t(this,e):this}comment(e,t){const n=$(Tn,un).get(this.tag);if(n!=null&&n.comment)return n.comment(this,e,t)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`${this.tag}(${n(this.contents,t)})`}},un=new WeakMap,cr(Tn,un,new Map),Tn);function dc(r){if(r!=null&&typeof r=="object")return r[Ir.ENCODED]}function Dv(r){if(r!=null&&typeof r=="object")return r[Ir.LENGTH]}function Ws(r,e){Object.defineProperty(r,Ir.ENCODED,{configurable:!0,enumerable:!1,value:e})}function Ys(r,e){const t=Object(r);return Ws(t,e),t}function Qp(r){let e=Math.ceil(r.length/2);const t=new Uint8Array(e);e--;for(let n=r.length,i=n-2;n>=0;n=i,i-=2,e--)t[e]=parseInt(r.substring(i,n),16);return t}function Gr(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function $v(r){const e=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(e);let n=0;for(const i of r)t.set(i,n),n+=i.length;return t}function af(r){const e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}const Mv={"-":"+",_:"/"};function Vv(r){const e=r.replace(/[_-]/g,t=>Mv[t]);return af(e.padEnd(Math.ceil(e.length/4)*4,"="))}function Lv(){const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])}function e0(r){var t;let e="";for(const n of r){const i=(t=n.codePointAt(0))==null?void 0:t.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${i}`}return e}function t0(r,e){const[t,n,i]=r,[s,o,c]=e,u=Math.min(i.length,c.length);for(let h=0;h<u;h++){const m=i[h]-c[h];if(m!==0)return m}return 0}const Pc=class Pc{constructor(e={}){cr(this,Xe);cr(this,Xn);cr(this,Qt,[]);cr(this,Sr,null);cr(this,$t,0);cr(this,Qn,0);if(Tt(this,Xn,{...Pc.defaultOptions,...e}),$(this,Xn).chunkSize<8)throw new RangeError(`Expected size >= 8, got ${$(this,Xn).chunkSize}`);De(this,Xe,Oi).call(this)}get length(){return $(this,Qn)}read(){De(this,Xe,Vc).call(this);const e=new Uint8Array($(this,Qn));let t=0;for(const n of $(this,Qt))e.set(n,t),t+=n.length;return De(this,Xe,Oi).call(this),e}write(e){const t=e.length;t>De(this,Xe,Ef).call(this)?(De(this,Xe,Vc).call(this),t>$(this,Xn).chunkSize?($(this,Qt).push(e),De(this,Xe,Oi).call(this)):(De(this,Xe,Oi).call(this),$(this,Qt)[$(this,Qt).length-1].set(e),Tt(this,$t,t))):($(this,Qt)[$(this,Qt).length-1].set(e,$(this,$t)),Tt(this,$t,$(this,$t)+t)),Tt(this,Qn,$(this,Qn)+t)}writeUint8(e){De(this,Xe,yn).call(this,1),$(this,Sr).setUint8($(this,$t),e),De(this,Xe,gn).call(this,1)}writeUint16(e,t=!1){De(this,Xe,yn).call(this,2),$(this,Sr).setUint16($(this,$t),e,t),De(this,Xe,gn).call(this,2)}writeUint32(e,t=!1){De(this,Xe,yn).call(this,4),$(this,Sr).setUint32($(this,$t),e,t),De(this,Xe,gn).call(this,4)}writeBigUint64(e,t=!1){De(this,Xe,yn).call(this,8),$(this,Sr).setBigUint64($(this,$t),e,t),De(this,Xe,gn).call(this,8)}writeInt16(e,t=!1){De(this,Xe,yn).call(this,2),$(this,Sr).setInt16($(this,$t),e,t),De(this,Xe,gn).call(this,2)}writeInt32(e,t=!1){De(this,Xe,yn).call(this,4),$(this,Sr).setInt32($(this,$t),e,t),De(this,Xe,gn).call(this,4)}writeBigInt64(e,t=!1){De(this,Xe,yn).call(this,8),$(this,Sr).setBigInt64($(this,$t),e,t),De(this,Xe,gn).call(this,8)}writeFloat32(e,t=!1){De(this,Xe,yn).call(this,4),$(this,Sr).setFloat32($(this,$t),e,t),De(this,Xe,gn).call(this,4)}writeFloat64(e,t=!1){De(this,Xe,yn).call(this,8),$(this,Sr).setFloat64($(this,$t),e,t),De(this,Xe,gn).call(this,8)}clear(){Tt(this,Qn,0),Tt(this,Qt,[]),De(this,Xe,Oi).call(this)}};Xn=new WeakMap,Qt=new WeakMap,Sr=new WeakMap,$t=new WeakMap,Qn=new WeakMap,Xe=new WeakSet,Oi=function(){const e=new Uint8Array($(this,Xn).chunkSize);$(this,Qt).push(e),Tt(this,$t,0),Tt(this,Sr,new DataView(e.buffer,e.byteOffset,e.byteLength))},Vc=function(){if($(this,$t)===0){$(this,Qt).pop();return}const e=$(this,Qt).length-1;$(this,Qt)[e]=$(this,Qt)[e].subarray(0,$(this,$t)),Tt(this,$t,0),Tt(this,Sr,null)},Ef=function(){const e=$(this,Qt).length-1;return $(this,Qt)[e].length-$(this,$t)},yn=function(e){De(this,Xe,Ef).call(this)<e&&(De(this,Xe,Vc).call(this),De(this,Xe,Oi).call(this))},gn=function(e){Tt(this,$t,$(this,$t)+e),Tt(this,Qn,$(this,Qn)+e)},He(Pc,"defaultOptions",{chunkSize:4096});let pc=Pc;function r0(r,e=0,t=!1){const n=r[e]&128?-1:1,i=(r[e]&124)>>2,s=(r[e]&3)<<8|r[e+1];if(i===0){if(t&&s!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*s}`);return n*5960464477539063e-23*s}else if(i===31)return s?NaN:n*(1/0);return n*2**(i-25)*(1024+s)}function Hv(r){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,r,!1);const t=e.getUint32(0,!1);if(t&8191)return null;let n=t>>16&32768;const i=t>>23&255,s=t&8388607;if(!(i===0&&s===0))if(i>=113&&i<=142)n+=(i-112<<10)+(s>>13);else if(i>=103&&i<113){if(s&(1<<126-i)-1)return null;n+=s+8388608>>126-i}else if(i===255)n|=31744,n|=s>>13;else return null;return n}function Fv(r){if(r!==0){const e=new ArrayBuffer(8),t=new DataView(e);t.setFloat64(0,r,!1);const n=t.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return r}function zv(r){switch(r.length){case 2:r0(r,0,!0);break;case 4:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getUint32(0,!1);if(!(t&2139095040)&&t&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getBigUint64(0,!1);if((t&0x7ff0000000000000n)===0n&&t&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${r}`)}}const n0=ve.SIMPLE_FLOAT<<5|xt.TWO,Gv=ve.SIMPLE_FLOAT<<5|xt.FOUR,Kv=ve.SIMPLE_FLOAT<<5|xt.EIGHT,qv=ve.SIMPLE_FLOAT<<5|Fn.TRUE,Zv=ve.SIMPLE_FLOAT<<5|Fn.FALSE,Wv=ve.SIMPLE_FLOAT<<5|Fn.UNDEFINED,Yv=ve.SIMPLE_FLOAT<<5|Fn.NULL,Jv=new TextEncoder,Xv={...pc.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null},i0={cde:!0,ignoreOriginalEncoding:!0,sortKeys:t0},Qv={...i0,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function s0(r){const e=r<0;return typeof r=="bigint"?[e?-r-1n:r,e]:[e?-r-1:r,e]}function cf(r,e,t){if(t.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${r}`);if(isNaN(r))e.writeUint8(n0),e.writeUint16(32256);else if(!t.float64&&Math.fround(r)===r){const n=Hv(r);n===null?(e.writeUint8(Gv),e.writeFloat32(r)):(e.writeUint8(n0),e.writeUint16(n))}else e.writeUint8(Kv),e.writeFloat64(r)}function Kr(r,e,t){const[n,i]=s0(r);if(i&&t)throw new TypeError(`Negative size: ${r}`);t??(t=i?ve.NEG_INT:ve.POS_INT),t<<=5,n<24?e.writeUint8(t|n):n<=255?(e.writeUint8(t|xt.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(t|xt.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(t|xt.FOUR),e.writeUint32(n)):(e.writeUint8(t|xt.EIGHT),e.writeBigUint64(BigInt(n)))}function yc(r,e,t){typeof r=="number"?Kr(r,e,ve.TAG):typeof r=="object"&&!t.ignoreOriginalEncoding&&Ir.ENCODED in r?e.write(r[Ir.ENCODED]):r<=Number.MAX_SAFE_INTEGER?Kr(Number(r),e,ve.TAG):(e.writeUint8(ve.TAG<<5|xt.EIGHT),e.writeBigUint64(BigInt(r)))}function o0(r,e,t){const[n,i]=s0(r);if(t.collapseBigInts&&(!t.largeNegativeAsBigInt||r>=-0x8000000000000000n)){if(n<=0xffffffffn){Kr(Number(r),e);return}if(n<=0xffffffffffffffffn){const h=(i?ve.NEG_INT:ve.POS_INT)<<5;e.writeUint8(h|xt.EIGHT),e.writeBigUint64(n);return}}if(t.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${r}`);const s=i?St.NEG_BIGINT:St.POS_BIGINT,o=n.toString(16),c=o.length%2?"0":"";yc(s,e,t);const u=Qp(c+o);Kr(u.length,e,ve.BYTE_STRING),e.write(u)}function em(r,e,t){t.flushToZero&&(r=Fv(r)),Object.is(r,-0)?t.simplifyNegativeZero?t.avoidInts?cf(0,e,t):Kr(0,e):cf(r,e,t):!t.avoidInts&&Number.isSafeInteger(r)?Kr(r,e):t.reduceUnsafeNumbers&&Math.floor(r)===r&&r>=hc.MIN&&r<=hc.MAX?o0(BigInt(r),e,t):cf(r,e,t)}function tm(r,e,t){const n=t.stringNormalization?r.normalize(t.stringNormalization):r,i=Jv.encode(n);Kr(i.length,e,ve.UTF8_STRING),e.write(i)}function rm(r,e,t){const n=r;uf(n,n.length,ve.ARRAY,e,t);for(const i of n)Ai(i,e,t)}function nm(r,e){const t=r;Kr(t.length,e,ve.BYTE_STRING),e.write(t)}const lf=new Map([[Array,rm],[Uint8Array,nm]]);function Nt(r,e){const t=lf.get(r);return lf.set(r,e),t}function uf(r,e,t,n,i){const s=Dv(r);s&&!i.ignoreOriginalEncoding?n.write(s):Kr(e,n,t)}function im(r,e,t){if(r===null){e.writeUint8(Yv);return}if(!t.ignoreOriginalEncoding&&Ir.ENCODED in r){e.write(r[Ir.ENCODED]);return}const n=lf.get(r.constructor);if(n){const s=n(r,e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&yc(s[0],e,t),Ai(s[1],e,t));return}if(typeof r.toCBOR=="function"){const s=r.toCBOR(e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&yc(s[0],e,t),Ai(s[1],e,t));return}if(typeof r.toJSON=="function"){Ai(r.toJSON(),e,t);return}const i=Object.entries(r).map(s=>[s[0],s[1],gc(s[0],t)]);t.sortKeys&&i.sort(t.sortKeys),uf(r,i.length,ve.MAP,e,t);for(const[s,o,c]of i)e.write(c),Ai(o,e,t)}function Ai(r,e,t){switch(typeof r){case"number":em(r,e,t);break;case"bigint":o0(r,e,t);break;case"string":tm(r,e,t);break;case"boolean":e.writeUint8(r?qv:Zv);break;case"undefined":if(t.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(Wv);break;case"object":im(r,e,t);break;case"symbol":throw new TypeError(`Unknown symbol: ${r.toString()}`);default:throw new TypeError(`Unknown type: ${typeof r}, ${String(r)}`)}}function gc(r,e={}){const t={...Xv};e.dcbor?Object.assign(t,Qv):e.cde&&Object.assign(t,i0),Object.assign(t,e);const n=new pc(t);return Ai(r,n,t),n.read()}var a0=(r=>(r[r.NEVER=-1]="NEVER",r[r.PREFERRED=0]="PREFERRED",r[r.ALWAYS=1]="ALWAYS",r))(a0||{});const ei=class ei{constructor(e){He(this,"value");this.value=e}static create(e){return ei.KnownSimple.has(e)?ei.KnownSimple.get(e):new ei(e)}toCBOR(e,t){if(t.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Kr(this.value,e,ve.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return ei.KnownSimple.has(this.value)?ei.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`simple(${n(this.value,t)})`}};He(ei,"KnownSimple",new Map([[Fn.FALSE,!1],[Fn.TRUE,!0],[Fn.NULL,null],[Fn.UNDEFINED,void 0]]));let Js=ei;const sm=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}),Rc=class Rc{constructor(e,t){cr(this,tr);cr(this,Cr);cr(this,Yr);cr(this,er,0);cr(this,Dr);if(Tt(this,Dr,{...Rc.defaultOptions,...t}),typeof e=="string")switch($(this,Dr).encoding){case"hex":Tt(this,Cr,Qp(e));break;case"base64":Tt(this,Cr,af(e));break;default:throw new TypeError(`Encoding not implemented: "${$(this,Dr).encoding}"`)}else Tt(this,Cr,e);Tt(this,Yr,new DataView($(this,Cr).buffer,$(this,Cr).byteOffset,$(this,Cr).byteLength))}toHere(e){return $(this,Cr).subarray(e,$(this,er))}*[Symbol.iterator](){if(yield*De(this,tr,Ti).call(this,0),$(this,er)!==$(this,Cr).length)throw new Error("Extra data in input")}};Cr=new WeakMap,Yr=new WeakMap,er=new WeakMap,Dr=new WeakMap,tr=new WeakSet,Ti=function*(e){if(e++>$(this,Dr).maxDepth)throw new Error(`Maximum depth ${$(this,Dr).maxDepth} exceeded`);const t=$(this,er),n=$(this,Yr).getUint8(Sy(this,er)._++),i=n>>5,s=n&31;let o=s,c=!1,u=0;switch(s){case xt.ONE:if(u=1,o=$(this,Yr).getUint8($(this,er)),i===ve.SIMPLE_FLOAT){if(o<32)throw new Error(`Invalid simple encoding in extra byte: ${o}`);c=!0}else if($(this,Dr).requirePreferred&&o<24)throw new Error(`Unexpectedly long integer encoding (1) for ${o}`);break;case xt.TWO:if(u=2,i===ve.SIMPLE_FLOAT)o=r0($(this,Cr),$(this,er));else if(o=$(this,Yr).getUint16($(this,er),!1),$(this,Dr).requirePreferred&&o<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${o}`);break;case xt.FOUR:if(u=4,i===ve.SIMPLE_FLOAT)o=$(this,Yr).getFloat32($(this,er),!1);else if(o=$(this,Yr).getUint32($(this,er),!1),$(this,Dr).requirePreferred&&o<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${o}`);break;case xt.EIGHT:{if(u=8,i===ve.SIMPLE_FLOAT)o=$(this,Yr).getFloat64($(this,er),!1);else if(o=$(this,Yr).getBigUint64($(this,er),!1),o<=Number.MAX_SAFE_INTEGER&&(o=Number(o)),$(this,Dr).requirePreferred&&o<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${o}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${s}`);case xt.INDEFINITE:switch(i){case ve.POS_INT:case ve.NEG_INT:case ve.TAG:throw new Error(`Invalid indefinite encoding for MT ${i}`);case ve.SIMPLE_FLOAT:yield[i,s,Ir.BREAK,t,0];return}o=1/0;break;default:c=!0}switch(Tt(this,er,$(this,er)+u),i){case ve.POS_INT:yield[i,s,o,t,u];break;case ve.NEG_INT:yield[i,s,typeof o=="bigint"?-1n-o:-1-Number(o),t,u];break;case ve.BYTE_STRING:o===1/0?yield*De(this,tr,To).call(this,i,e,t):yield[i,s,De(this,tr,If).call(this,o),t,o];break;case ve.UTF8_STRING:o===1/0?yield*De(this,tr,To).call(this,i,e,t):yield[i,s,sm.decode(De(this,tr,If).call(this,o)),t,o];break;case ve.ARRAY:if(o===1/0)yield*De(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let m=0;m<h;m++)yield*De(this,tr,Ti).call(this,e+1)}break;case ve.MAP:if(o===1/0)yield*De(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let m=0;m<h;m++)yield*De(this,tr,Ti).call(this,e),yield*De(this,tr,Ti).call(this,e)}break;case ve.TAG:yield[i,s,o,t,u],yield*De(this,tr,Ti).call(this,e);break;case ve.SIMPLE_FLOAT:{const h=o;c&&(o=Js.create(Number(o))),yield[i,s,o,t,h];break}}},If=function(e){const t=$(this,Cr).subarray($(this,er),Tt(this,er,$(this,er)+e));if(t.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t},To=function*(e,t,n,i=!0){for(yield[e,xt.INDEFINITE,1/0,n,1/0];;){const s=De(this,tr,Ti).call(this,t),o=s.next(),[c,u,h]=o.value;if(h===Ir.BREAK){yield o.value,s.next();return}if(i){if(c!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${c}.`);if(u===xt.INDEFINITE)throw new Error("New stream started in typed stream")}yield o.value,yield*s}},He(Rc,"defaultOptions",{maxDepth:1024,encoding:"hex",requirePreferred:!1});let Xs=Rc;const om=new Map([[xt.ZERO,1],[xt.ONE,2],[xt.TWO,3],[xt.FOUR,5],[xt.EIGHT,9]]),am=new Uint8Array(0);let zn=(fn=class{constructor(e,t,n,i){cr(this,Uc);He(this,"parent");He(this,"mt");He(this,"ai");He(this,"left");He(this,"offset");He(this,"count",0);He(this,"children",[]);He(this,"depth",0);cr(this,dr);cr(this,hn,null);if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,Tt(this,dr,i),n&&(this.depth=n.depth+1),this.mt===ve.MAP&&($(this,dr).sortKeys||$(this,dr).rejectDuplicateKeys)&&Tt(this,hn,[]),$(this,dr).rejectStreaming&&this.ai===xt.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,i){const[s,o,c,u]=e;switch(s){case ve.POS_INT:case ve.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${c}`);if(n.rejectLargeNegatives&&c<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${c}`);let h=c;return n.convertUnsafeIntsToFloat&&h>=hc.MIN&&h<=hc.MAX&&(h=Number(c)),n.boxed?Ys(h,i.toHere(u)):h}case ve.SIMPLE_FLOAT:if(o>xt.ONE){if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${c}`);if(n.rejectNegativeZero&&Object.is(c,-0))throw new Error("Decoding negative zero");if(n.rejectLongLoundNaN&&isNaN(c)){const h=i.toHere(u);if(h.length!==3||h[1]!==126||h[2]!==0)throw new Error(`Invalid NaN encoding: "${Gr(h)}"`)}if(n.rejectSubnormals&&zv(i.toHere(u+1)),n.rejectLongFloats){const h=gc(c,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(h[0]>>5!==s)throw new Error(`Should have been encoded as int, not float: ${c}`);if(h.length<om.get(o))throw new Error(`Number should have been encoded shorter: ${c}`)}if(typeof c=="number"&&n.boxed)return Ys(c,i.toHere(u))}else{if(n.rejectSimple&&c instanceof Js)throw new Error(`Invalid simple value: ${c}`);if(n.rejectUndefined&&c===void 0)throw new Error("Unexpected undefined")}return c;case ve.BYTE_STRING:case ve.UTF8_STRING:if(c===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof c=="string"){const h=c.normalize(n.rejectStringsNotNormalizedAs);if(c!==h)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${e0(c)}] instead of [${e0(h)}]`)}return n.boxed?Ys(c,i.toHere(u)):c;case ve.ARRAY:return new n.ParentType(e,c,t,n);case ve.MAP:return new n.ParentType(e,c*2,t,n);case ve.TAG:{const h=new n.ParentType(e,1,t,n);return h.children=new Ze(c),h}}throw new TypeError(`Invalid major type: ${s}`)}push(e,t,n){if(this.children.push(e),$(this,hn)){const i=dc(e)||t.toHere(n);$(this,hn).push(i)}return--this.left}replaceLast(e,t,n){let i,s=-1/0;if(this.children instanceof Ze?(s=0,i=this.children.contents,this.children.contents=e):(s=this.children.length-1,i=this.children[s],this.children[s]=e),$(this,hn)){const o=dc(e)||n.toHere(t.offset);$(this,hn)[s]=o}return i}convert(e){let t;switch(this.mt){case ve.ARRAY:t=this.children;break;case ve.MAP:{const n=De(this,Uc,Iy).call(this);if($(this,dr).sortKeys){let i;for(const s of n){if(i&&$(this,dr).sortKeys(i,s)>=0)throw new Error(`Duplicate or out of order key: "0x${s[2]}"`);i=s}}else if($(this,dr).rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate key: "0x${u}"`);i.add(u)}}t=!$(this,dr).boxed&&!$(this,dr).preferMap&&n.every(([i])=>typeof i=="string")?Object.fromEntries(n):new Map(n);break}case ve.BYTE_STRING:return $v(this.children);case ve.UTF8_STRING:{const n=this.children.join("");t=$(this,dr).boxed?Ys(n,e.toHere(this.offset)):n;break}case ve.TAG:t=this.children.decode($(this,dr));break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return $(this,dr).saveOriginal&&t&&typeof t=="object"&&Ws(t,e.toHere(this.offset)),t}},dr=new WeakMap,hn=new WeakMap,Uc=new WeakSet,Iy=function(){const e=this.children,t=e.length;if(t%2)throw new Error("Missing map value");const n=new Array(t/2);if($(this,hn))for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],$(this,hn)[i]];else for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],am];return n},He(fn,"defaultDecodeOptions",{...Xs.defaultOptions,ParentType:fn,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:a0.PREFERRED,convertUnsafeIntsToFloat:!1,pretty:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null}),He(fn,"cdeDecodeOptions",{cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:t0}),He(fn,"dcborDecodeOptions",{...fn.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"}),fn);class ff extends(by=zn,wy=Ir.ENCODED,by){constructor(t,n,i,s){super(t,n,i,s);He(this,"depth",0);He(this,"leaf",!1);He(this,"value");He(this,"length");He(this,wy);this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=t}numBytes(){switch(this.ai){case xt.ONE:return 1;case xt.TWO:return 2;case xt.FOUR:return 4;case xt.EIGHT:return 8}return 0}}function c0(r){return r instanceof ff}function vc(r,e){return r===1/0?"Indefinite":e?`${r} ${e}${r!==1&&r!==1n?"s":""}`:String(r)}function hf(r){return"".padStart(r," ")}function l0(r,e,t){let n="";n+=hf(r.depth*2);const i=dc(r);n+=Gr(i.subarray(0,1));const s=r.numBytes();s&&(n+=" ",n+=Gr(i.subarray(1,s+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",t!==void 0&&(n+=hf(r.depth*2),t!==""&&(n+=`[${t}] `));let o=!1;const[c]=r.children;switch(r.mt){case ve.POS_INT:n+=`Unsigned: ${c}`,typeof c=="bigint"&&(n+="n");break;case ve.NEG_INT:n+=`Negative: ${c}`,typeof c=="bigint"&&(n+="n");break;case ve.BYTE_STRING:n+=`Bytes (Length: ${vc(r.length)})`;break;case ve.UTF8_STRING:n+=`UTF8 (Length: ${vc(r.length)})`,r.length!==1/0&&(n+=`: ${JSON.stringify(c)}`);break;case ve.ARRAY:n+=`Array (Length: ${vc(r.value,"item")})`;break;case ve.MAP:n+=`Map (Length: ${vc(r.value,"pair")})`;break;case ve.TAG:{n+=`Tag #${r.value}`;const u=r.children,[h]=u.contents.children,m=new Ze(u.tag,h);Ws(m,i);const x=m.comment(e,r.depth);x&&(n+=": ",n+=x),o||(o=m.noChildren);break}case ve.SIMPLE_FLOAT:c===Ir.BREAK?n+="BREAK":r.ai>xt.ONE?Object.is(c,-0)?n+="Float: -0":n+=`Float: ${c}`:(n+="Simple: ",c instanceof Js?n+=c.value:n+=c);break}if(!o)if(r.leaf){if(n+=`
113
+ */const Fs="crypto.algorithm";class wv{getAlgorithms(){return fr.resolveAll(Fs)}toAsnAlgorithm(e){({...e});for(const t of this.getAlgorithms()){const n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){const t=new ne({algorithm:e.name});if("parameters"in e){const n=e;t.parameters=n.parameters}return t}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(e){for(const n of this.getAlgorithms()){const i=n.toWebAlgorithm(e);if(i)return i}return{name:e.algorithm,parameters:e.parameters}}}const ts="crypto.algorithmProvider";fr.registerSingleton(ts,wv);var ic;const br="1.3.36.3.3.2.8.1.1",rp=`${br}.1`,np=`${br}.2`,ip=`${br}.3`,sp=`${br}.4`,op=`${br}.5`,ap=`${br}.6`,cp=`${br}.7`,lp=`${br}.8`,up=`${br}.9`,fp=`${br}.10`,hp=`${br}.11`,dp=`${br}.12`,pp=`${br}.13`,yp=`${br}.14`,gp="brainpoolP160r1",vp="brainpoolP160t1",mp="brainpoolP192r1",wp="brainpoolP192t1",bp="brainpoolP224r1",xp="brainpoolP224t1",Ap="brainpoolP256r1",Sp="brainpoolP256t1",_p="brainpoolP320r1",Ep="brainpoolP320t1",Ip="brainpoolP384r1",kp="brainpoolP384t1",Cp="brainpoolP512r1",Bp="brainpoolP512t1",Bt="ECDSA";let zs=ic=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case Bt.toLowerCase():if("hash"in e)switch((typeof e.hash=="string"?e.hash:e.hash.name).toLowerCase()){case"sha-1":return Fg;case"sha-256":return zg;case"sha-384":return Gg;case"sha-512":return Kg}else if("namedCurve"in e){let t="";switch(e.namedCurve){case"P-256":t=md;break;case"K-256":t=ic.SECP256K1;break;case"P-384":t=wd;break;case"P-521":t=bd;break;case gp:t=rp;break;case vp:t=np;break;case mp:t=ip;break;case wp:t=sp;break;case bp:t=op;break;case xp:t=ap;break;case Ap:t=cp;break;case Sp:t=lp;break;case _p:t=up;break;case Ep:t=fp;break;case Ip:t=hp;break;case kp:t=dp;break;case Cp:t=pp;break;case Bp:t=yp;break}if(t)return new ne({algorithm:Us,parameters:q.serialize(new Dn({namedCurve:t}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case yu:return{name:Bt,hash:{name:"SHA-1"}};case gu:return{name:Bt,hash:{name:"SHA-256"}};case vu:return{name:Bt,hash:{name:"SHA-384"}};case mu:return{name:Bt,hash:{name:"SHA-512"}};case Us:{if(!e.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(q.parse(e.parameters,Dn).namedCurve){case md:return{name:Bt,namedCurve:"P-256"};case ic.SECP256K1:return{name:Bt,namedCurve:"K-256"};case wd:return{name:Bt,namedCurve:"P-384"};case bd:return{name:Bt,namedCurve:"P-521"};case rp:return{name:Bt,namedCurve:gp};case np:return{name:Bt,namedCurve:vp};case ip:return{name:Bt,namedCurve:mp};case sp:return{name:Bt,namedCurve:wp};case op:return{name:Bt,namedCurve:bp};case ap:return{name:Bt,namedCurve:xp};case cp:return{name:Bt,namedCurve:Ap};case lp:return{name:Bt,namedCurve:Sp};case up:return{name:Bt,namedCurve:_p};case fp:return{name:Bt,namedCurve:Ep};case hp:return{name:Bt,namedCurve:Ip};case dp:return{name:Bt,namedCurve:kp};case pp:return{name:Bt,namedCurve:Cp};case yp:return{name:Bt,namedCurve:Bp}}}}return null}};zs.SECP256K1="1.3.132.0.10",zs=ic=f([Wa()],zs),fr.registerSingleton(Fs,zs);const Op=Symbol("name"),Tp=Symbol("value");class rt{constructor(e,t={},n=""){this[Op]=e,this[Tp]=n;for(const i in t)this[i]=t[i]}}rt.NAME=Op,rt.VALUE=Tp;class bv{static toTextObject(e){const t=new rt("Algorithm Identifier",{},Cn.toString(e.algorithm));if(e.parameters)switch(e.algorithm){case Us:{const n=new zs().toWebAlgorithm(e);n&&"namedCurve"in n?t["Named Curve"]=n.namedCurve:t.Parameters=e.parameters;break}default:t.Parameters=e.parameters}return t}}class Cn{static toString(e){const t=this.items[e];return t||e}}Cn.items={[Da]:"sha1",[Sd]:"sha224",[$a]:"sha256",[Ma]:"sha384",[Va]:"sha512",[vi]:"rsaEncryption",[ja]:"sha1WithRSAEncryption",[Xg]:"sha224WithRSAEncryption",[bu]:"sha256WithRSAEncryption",[Ra]:"sha384WithRSAEncryption",[Ua]:"sha512WithRSAEncryption",[Us]:"ecPublicKey",[yu]:"ecdsaWithSHA1",[vd]:"ecdsaWithSHA224",[gu]:"ecdsaWithSHA256",[vu]:"ecdsaWithSHA384",[mu]:"ecdsaWithSHA512",[Ug]:"TLS WWW server authentication",[Dg]:"TLS WWW client authentication",[$g]:"Code Signing",[Mg]:"E-mail Protection",[Vg]:"Time Stamping",[Lg]:"OCSP Signing",[du]:"Signed Data"};class $n{static serialize(e){return this.serializeObj(e).join(`
114
+ `)}static pad(e=0){return"".padStart(2*e," ")}static serializeObj(e,t=0){const n=[];let i=this.pad(t++),s="";const o=e[rt.VALUE];o&&(s=` ${o}`),n.push(`${i}${e[rt.NAME]}:${s}`),i=this.pad(t);for(const c in e){if(typeof c=="symbol")continue;const u=e[c],h=c?`${c}: `:"";if(typeof u=="string"||typeof u=="number"||typeof u=="boolean")n.push(`${i}${h}${u}`);else if(u instanceof Date)n.push(`${i}${h}${u.toUTCString()}`);else if(Array.isArray(u))for(const m of u)m[rt.NAME]=c,n.push(...this.serializeObj(m,t));else if(u instanceof rt)u[rt.NAME]=c,n.push(...this.serializeObj(u,t));else if(Y.isBufferSource(u))c?(n.push(`${i}${h}`),n.push(...this.serializeBufferSource(u,t+1))):n.push(...this.serializeBufferSource(u,t));else if("toTextObject"in u){const m=u.toTextObject();m[rt.NAME]=c,n.push(...this.serializeObj(m,t))}else throw new TypeError("Cannot serialize data in text format. Unsupported type.")}return n}static serializeBufferSource(e,t=0){const n=this.pad(t),i=Y.toUint8Array(e),s=[];for(let o=0;o<i.length;){const c=[];for(let u=0;u<16&&o<i.length;u++){u===8&&c.push("");const h=i[o++].toString(16).padStart(2,"0");c.push(h)}s.push(`${n}${c.join(" ")}`)}return s}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}}$n.oidSerializer=Cn,$n.algorithmSerializer=bv;class Mn{constructor(...e){if(e.length===1){const t=e[0];this.rawData=q.serialize(t),this.onInit(t)}else{const t=q.parse(e[0],e[1]);this.rawData=Y.toArrayBuffer(e[0]),this.onInit(t)}}equal(e){return e instanceof Mn?No(e.rawData,this.rawData):!1}toString(e="text"){switch(e){case"asn":return q.toString(this.rawData);case"text":return $n.serialize(this.toTextObject());case"hex":return ue.ToHex(this.rawData);case"base64":return ue.ToBase64(this.rawData);case"base64url":return ue.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 rt(this.getTextName(),{},e)}}Mn.NAME="ASN";class jr extends Mn{constructor(...e){let t;Y.isBufferSource(e[0])?t=Y.toArrayBuffer(e[0]):t=q.serialize(new Hr({extnID:e[0],critical:e[1],extnValue:new tt(Y.toArrayBuffer(e[2]))})),super(t,Hr)}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[rt.NAME]===jr.NAME&&(e[rt.NAME]=Cn.toString(this.type)),e}}var Np;class Vn{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Np]="CryptoProvider",typeof self<"u"&&typeof crypto<"u"?this.set(Vn.DEFAULT,crypto):typeof global<"u"&&global.crypto&&global.crypto.subtle&&this.set(Vn.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=Vn.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(typeof e=="string"){if(!t)throw new TypeError("Argument 'value' is required");this.items.set(e.toLowerCase(),t)}else this.items.set(Vn.DEFAULT,e);return this}}Np=Symbol.toStringTag,Vn.DEFAULT="default";const Xt=new Vn,xv=/^[0-2](?:\.[1-9][0-9]*)+$/;function Av(r){return new RegExp(xv).test(r)}class Pp{constructor(e={}){this.items={};for(const t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Av(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}}const xr=new Pp;xr.register("CN","2.5.4.3"),xr.register("L","2.5.4.7"),xr.register("ST","2.5.4.8"),xr.register("O","2.5.4.10"),xr.register("OU","2.5.4.11"),xr.register("C","2.5.4.6"),xr.register("DC","0.9.2342.19200300.100.1.25"),xr.register("E","1.2.840.113549.1.9.1"),xr.register("G","2.5.4.42"),xr.register("I","2.5.4.43"),xr.register("SN","2.5.4.4"),xr.register("T","2.5.4.12");function Sv(r,e){return`\\${ue.ToHex(ue.FromUtf8String(e)).toUpperCase()}`}function _v(r){return r.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Sv)}class Ln{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 Pp,this.asn=new zt;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const i=t[n];this.extraNames.register(n,i)}typeof e=="string"?this.asn=this.fromString(e):e instanceof zt?this.asn=e:Y.isBufferSource(e)?this.asn=q.parse(e,zt):this.asn=this.fromJSON(e)}getField(e){const t=this.extraNames.findId(e)||xr.findId(e),n=[];for(const i of this.asn)for(const s of i)s.type===t&&n.push(s.value.toString());return n}getName(e){return this.extraNames.get(e)||xr.get(e)}toString(){return this.asn.map(e=>e.map(t=>{const n=this.getName(t.type)||t.type,i=t.value.anyValue?`#${ue.ToHex(t.value.anyValue)}`:_v(t.value.toString());return`${n}=${i}`}).join("+")).join(", ")}toJSON(){var e;const t=[];for(const n of this.asn){const i={};for(const s of n){const o=this.getName(s.type)||s.type;(e=i[o])!==null&&e!==void 0||(i[o]=[]),i[o].push(s.value.anyValue?`#${ue.ToHex(s.value.anyValue)}`:s.value.toString())}t.push(i)}return t}fromString(e){const t=new zt,n=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,s=",";for(;i=n.exec(`${e},`);){let[,o,c]=i;const u=c[c.length-1];(u===","||u==="+")&&(c=c.slice(0,c.length-1),i[3]=u);const h=i[3];o=this.getTypeOid(o);const m=this.createAttribute(o,c);s==="+"?t[t.length-1].push(m):t.push(new Di([m])),s=h}return t}fromJSON(e){const t=new zt;for(const n of e){const i=new Di;for(const s in n){const o=this.getTypeOid(s),c=n[s];for(const u of c){const h=this.createAttribute(o,u);i.push(h)}}t.push(i)}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 n=new Qo({type:e});if(typeof t=="object")for(const i in t)switch(i){case"ia5String":n.value.ia5String=t[i];break;case"utf8String":n.value.utf8String=t[i];break;case"universalString":n.value.universalString=t[i];break;case"bmpString":n.value.bmpString=t[i];break;case"printableString":n.value.printableString=t[i];break}else if(t[0]==="#")n.value.anyValue=ue.FromHex(t.slice(1));else{const i=this.processStringValue(t);e===this.getName("E")||e===this.getName("DC")?n.value.ia5String=i:Ln.isPrintableString(i)?n.value.printableString=i:n.value.utf8String=i}return n}processStringValue(e){const t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/ig,`
115
+ `).replace(/\\0d/ig,"\r").replace(/\\0g/ig," ").replace(/\\(.)/g,"$1")}toArrayBuffer(){return q.serialize(this.asn)}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.toArrayBuffer())}}const jp="Cannot initialize GeneralName from ASN.1 data.",Rp=`${jp} Unsupported string format in use.`,Ev=`${jp} Value doesn't match to GUID regular expression.`,Up=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Dp="1.3.6.1.4.1.311.25.1",$p="1.3.6.1.4.1.311.20.2.3",qu="dns",Zu="dn",Wu="email",Yu="ip",Ju="url",Xu="guid",Qu="upn",sc="id";class Hn extends Mn{constructor(...e){let t;if(e.length===2)switch(e[0]){case Zu:{const n=new Ln(e[1]).toArrayBuffer(),i=q.parse(n,zt);t=new je({directoryName:i});break}case qu:t=new je({dNSName:e[1]});break;case Wu:t=new je({rfc822Name:e[1]});break;case Xu:{const n=new RegExp(Up,"i").exec(e[1]);if(!n)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=n.slice(1).map((s,o)=>o<3?ue.ToHex(new Uint8Array(ue.FromHex(s)).reverse()):s).join("");t=new je({otherName:new As({typeId:Dp,value:q.serialize(new tt(ue.FromHex(i)))})});break}case Yu:t=new je({iPAddress:e[1]});break;case sc:t=new je({registeredID:e[1]});break;case Qu:{t=new je({otherName:new As({typeId:$p,value:q.serialize($h.toASN(e[1]))})});break}case Ju:t=new je({uniformResourceIdentifier:e[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else Y.isBufferSource(e[0])?t=q.parse(e[0],je):t=e[0];super(t)}onInit(e){if(e.dNSName!=null)this.type=qu,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Wu,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=Yu,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=Ju,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=sc,this.value=e.registeredID;else if(e.directoryName!=null)this.type=Zu,this.value=new Ln(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Dp){this.type=Xu;const t=q.parse(e.otherName.value,tt),n=new RegExp(Up,"i").exec(ue.ToHex(t));if(!n)throw new Error(Ev);this.value=n.slice(1).map((i,s)=>s<3?ue.ToHex(new Uint8Array(ue.FromHex(i)).reverse()):i).join("-")}else if(e.otherName.typeId===$p)this.type=Qu,this.value=q.parse(e.otherName.value,Yt).toString();else throw new Error(Rp);else throw new Error(Rp)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case Zu:case qu:case Xu:case Yu:case sc:case Qu:case Ju:e=this.type.toUpperCase();break;case Wu:e="Email";break;default:throw new Error("Unsupported GeneralName type")}let t=this.value;return this.type===sc&&(t=Cn.toString(t)),new rt(e,void 0,t)}}class Gs extends Mn{constructor(e){let t;if(e instanceof ur)t=e;else if(Array.isArray(e)){const n=[];for(const i of e)if(i instanceof je)n.push(i);else{const s=q.parse(new Hn(i.type,i.value).rawData,je);n.push(s)}t=new ur(n)}else if(Y.isBufferSource(e))t=q.parse(e,ur);else throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");super(t)}onInit(e){const t=[];for(const n of e){let i=null;try{i=new Hn(n)}catch{continue}t.push(i)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){const e=super.toTextObjectEmpty();for(const t of this.items){const n=t.toTextObject();let i=e[n[rt.NAME]];Array.isArray(i)||(i=[],e[n[rt.NAME]]=i),i.push(n)}return e}}Gs.NAME="GeneralNames";const Ks="-{5}",qs="\\n",Iv=`[^${qs}]+`,kv=`${Ks}BEGIN (${Iv}(?=${Ks}))${Ks}`,Cv=`${Ks}END \\1${Ks}`,rs="\\n",Bv=`[^:${qs}]+`,Ov=`(?:[^${qs}]+${rs}(?: +[^${qs}]+${rs})*)`,Tv=`(?:[a-zA-Z0-9=+/]+${rs})+`,Mp=`${kv}${rs}(?:((?:${Bv}: ${Ov})+))?${rs}?(${Tv})${Cv}`;class Ar{static isPem(e){return typeof e=="string"&&new RegExp(Mp,"g").test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,"");const t=new RegExp(Mp,"g"),n=[];let i=null;for(;i=t.exec(e);){const s=i[3].replace(new RegExp(`[${qs}]+`,"g"),""),o={type:i[1],headers:[],rawData:ue.FromBase64(s)},c=i[2];if(c){const u=c.split(new RegExp(rs,"g"));let h=null;for(const m of u){const[x,G]=m.split(/:(.*)/);if(G===void 0){if(!h)throw new Error("Cannot parse PEM string. Incorrect header value");h.value+=x.trim()}else h&&o.headers.push(h),h={key:x,value:G.trim()}}h&&o.headers.push(h)}n.push(o)}return n}static decode(e){return this.decodeWithHeaders(e).map(n=>n.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 n=new Array;return t?e.forEach(i=>{if(!Y.isBufferSource(i))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");n.push(this.encodeStruct({type:t,rawData:Y.toArrayBuffer(i)}))}):e.forEach(i=>{if(!("type"in i))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");n.push(this.encodeStruct(i))}),n.join(`
116
+ `)}else{if(!t)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:t,rawData:Y.toArrayBuffer(e)})}}static encodeStruct(e){var t;const n=e.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${n}-----`),!((t=e.headers)===null||t===void 0)&&t.length){for(const h of e.headers)i.push(`${h.key}: ${h.value}`);i.push("")}const s=ue.ToBase64(e.rawData);let o,c=0;const u=Array();for(;c<s.length&&(s.length-c<64?o=s.substring(c):(o=s.substring(c,c+64),c+=64),o.length!==0);)if(u.push(o),o.length<64)break;return i.push(...u),i.push(`-----END ${n}-----`),i.join(`
117
+ `)}}Ar.CertificateTag="CERTIFICATE",Ar.CrlTag="CRL",Ar.CertificateRequestTag="CERTIFICATE REQUEST",Ar.PublicKeyTag="PUBLIC KEY",Ar.PrivateKeyTag="PRIVATE KEY";class zr extends Mn{static isAsnEncoded(e){return Y.isBufferSource(e)||typeof e=="string"}static toArrayBuffer(e){if(typeof e=="string"){if(Ar.isPem(e))return Ar.decode(e)[0];if(ue.isHex(e))return ue.FromHex(e);if(ue.isBase64(e))return ue.FromBase64(e);if(ue.isBase64Url(e))return ue.FromBase64Url(e);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}else{const t=ue.ToBinary(e);return Ar.isPem(t)?Ar.decode(t)[0]:ue.isHex(t)?ue.FromHex(t):ue.isBase64(t)?ue.FromBase64(t):ue.isBase64Url(t)?ue.FromBase64Url(t):Y.toArrayBuffer(e)}}constructor(...e){zr.isAsnEncoded(e[0])?super(zr.toArrayBuffer(e[0]),e[1]):super(e[0])}toString(e="pem"){switch(e){case"pem":return Ar.encode(this.rawData,this.tag);default:return super.toString(e)}}}class on extends zr{static async create(e,t=Xt.get()){if(e instanceof on)return e;if(Vn.isCryptoKey(e)){if(e.type!=="public")throw new TypeError("Public key is required");const n=await t.subtle.exportKey("spki",e);return new on(n)}else{if(e.publicKey)return e.publicKey;if(Y.isBufferSource(e))return new on(e);throw new TypeError("Unsupported PublicKeyType")}}constructor(e){zr.isAsnEncoded(e)?super(e,en):super(e),this.tag=Ar.PublicKeyTag}async export(...e){let t,n=["verify"],i={hash:"SHA-256",...this.algorithm};e.length>1?(i=e[0]||i,n=e[1]||n,t=e[2]||Xt.get()):t=e[0]||Xt.get();let s=this.rawData;const o=q.parse(this.rawData,en);return o.algorithm.algorithm===Ms&&(s=Nv(o,s)),t.subtle.importKey("spki",s,i,!0,n)}onInit(e){const t=fr.resolve(ts),n=this.algorithm=t.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case vi:{const i=q.parse(e.subjectPublicKey,Su),s=Y.toUint8Array(i.modulus);n.publicExponent=Y.toUint8Array(i.publicExponent),n.modulusLength=(s[0]?s:s.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){var t;let n,i="SHA-1";return e.length>=1&&!(!((t=e[0])===null||t===void 0)&&t.subtle)?(i=e[0]||i,n=e[1]||Xt.get()):n=e[0]||Xt.get(),await n.subtle.digest(i,this.rawData)}async getKeyIdentifier(...e){let t,n="SHA-1";e.length===1?typeof e[0]=="string"?(n=e[0],t=Xt.get()):t=e[0]:e.length===2?(n=e[0],t=e[1]):t=Xt.get();const i=q.parse(this.rawData,en);return await t.subtle.digest(n,i.subjectPublicKey)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,en);switch(e.Algorithm=$n.serializeAlgorithm(t.algorithm),t.algorithm.algorithm){case Us:e["EC Point"]=t.subjectPublicKey;break;case vi:default:e["Raw Data"]=t.subjectPublicKey}return e}}function Nv(r,e){return r.algorithm=new ne({algorithm:vi,parameters:null}),e=q.serialize(r),e}class Zs extends jr{static async create(e,t=!1,n=Xt.get()){if("name"in e&&"serialNumber"in e)return new Zs(e,t);const s=await(await on.create(e,n)).getKeyIdentifier(n);return new Zs(ue.ToHex(s),t)}constructor(...e){if(Y.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]=="string"){const t=new li({keyIdentifier:new gl(ue.FromHex(e[0]))});super(ta,e[1],q.serialize(t))}else{const t=e[0],n=t.name instanceof Gs?q.parse(t.name.rawData,ur):t.name,i=new li({authorityCertIssuer:n,authorityCertSerialNumber:ue.FromHex(t.serialNumber)});super(ta,e[1],q.serialize(i))}}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,li);t.keyIdentifier&&(this.keyId=ue.ToHex(t.keyIdentifier)),(t.authorityCertIssuer||t.authorityCertSerialNumber)&&(this.certId={name:t.authorityCertIssuer||[],serialNumber:t.authorityCertSerialNumber?ue.ToHex(t.authorityCertSerialNumber):""})}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,li);return t.authorityCertIssuer&&(e["Authority Issuer"]=new Gs(t.authorityCertIssuer).toTextObject()),t.authorityCertSerialNumber&&(e["Authority Serial Number"]=t.authorityCertSerialNumber),t.keyIdentifier&&(e[""]=t.keyIdentifier),e}}Zs.NAME="Authority Key Identifier";class Vp extends jr{constructor(...e){if(Y.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,ra);this.ca=t.cA,this.pathLength=t.pathLenConstraint}else{const t=new ra({cA:e[0],pathLenConstraint:e[1]});super(Zh,e[2],q.serialize(t)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e["Path Length"]=this.pathLength),e}}Vp.NAME="Basic Constraints";var Lp;(function(r){r.serverAuth="1.3.6.1.5.5.7.3.1",r.clientAuth="1.3.6.1.5.5.7.3.2",r.codeSigning="1.3.6.1.5.5.7.3.3",r.emailProtection="1.3.6.1.5.5.7.3.4",r.timeStamping="1.3.6.1.5.5.7.3.8",r.ocspSigning="1.3.6.1.5.5.7.3.9"})(Lp||(Lp={}));class Hp extends jr{constructor(...e){if(Y.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,aa);this.usages=t.map(n=>n)}else{const t=new aa(e[0]);super(ed,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[""]=this.usages.map(t=>Cn.toString(t)).join(", "),e}}Hp.NAME="Extended Key Usages";var Fp;(function(r){r[r.digitalSignature=1]="digitalSignature",r[r.nonRepudiation=2]="nonRepudiation",r[r.keyEncipherment=4]="keyEncipherment",r[r.dataEncipherment=8]="dataEncipherment",r[r.keyAgreement=16]="keyAgreement",r[r.keyCertSign=32]="keyCertSign",r[r.cRLSign=64]="cRLSign",r[r.encipherOnly=128]="encipherOnly",r[r.decipherOnly=256]="decipherOnly"})(Fp||(Fp={}));class zp extends jr{constructor(...e){if(Y.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Tl);this.usages=t.toNumber()}else{const t=new Tl(e[0]);super(rd,e[1],q.serialize(t)),this.usages=e[0]}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Tl);return e[""]=t.toJSON().join(", "),e}}zp.NAME="Key Usages";class oc extends jr{static async create(e,t=!1,n=Xt.get()){const s=await(await on.create(e,n)).getKeyIdentifier(n);return new oc(ue.ToHex(s),t)}constructor(...e){if(Y.isBufferSource(e[0])){super(e[0]);const t=q.parse(this.value,Rn);this.keyId=ue.ToHex(t)}else{const t=typeof e[0]=="string"?ue.FromHex(e[0]):e[0],n=new Rn(t);super(Ml,e[1],q.serialize(n)),this.keyId=ue.ToHex(t)}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=q.parse(this.value,Rn);return e[""]=t,e}}oc.NAME="Subject Key Identifier";class Gp extends jr{constructor(...e){Y.isBufferSource(e[0])?super(e[0]):super(Ul,e[1],new Gs(e[0]||[]).rawData)}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,Dl);this.names=new Gs(t)}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(const n in t)e[n]=t[n];return e}}Gp.NAME="Subject Alternative Name";class Rr{static register(e,t){this.items.set(e,t)}static create(e){const t=new jr(e),n=this.items.get(t.type);return n?new n(e):t}}Rr.items=new Map;class Kp extends jr{constructor(...e){var t;if(Y.isBufferSource(e[0])){super(e[0]);const n=q.parse(this.value,sa);this.policies=n.map(i=>i.policyIdentifier)}else{const n=e[0],i=(t=e[1])!==null&&t!==void 0?t:!1,s=new sa(n.map(o=>new ia({policyIdentifier:o})));super(Yh,i,q.serialize(s)),this.policies=n}}toTextObject(){const e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(t=>new rt("",{},Cn.toString(t))),e}}Kp.NAME="Certificate Policies",Rr.register(Yh,Kp);class qp extends jr{constructor(...e){var t;if(Y.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]=="string"){const i=e[0].map(o=>new Vi({distributionPoint:new ui({fullName:[new je({uniformResourceIdentifier:o})]})})),s=new Li(i);super(_l,e[1],q.serialize(s))}else{const n=new Li(e[0]);super(_l,e[1],q.serialize(n))}(t=this.distributionPoints)!==null&&t!==void 0||(this.distributionPoints=[])}onInit(e){super.onInit(e);const t=q.parse(e.extnValue,Li);this.distributionPoints=t}toTextObject(){const e=this.toTextObjectWithoutValue();return e["Distribution Point"]=this.distributionPoints.map(t=>{var n;const i={};return t.distributionPoint&&(i[""]=(n=t.distributionPoint.fullName)===null||n===void 0?void 0:n.map(s=>new Hn(s).toString()).join(", ")),t.reasons&&(i.Reasons=t.reasons.toString()),t.cRLIssuer&&(i["CRL Issuer"]=t.cRLIssuer.map(s=>s.toString()).join(", ")),i}),e}}qp.NAME="CRL Distribution Points";class Zp extends jr{constructor(...e){var t,n,i,s;if(Y.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof Mi){const o=new Mi(e[0]);super(yl,e[1],q.serialize(o))}else{const o=e[0],c=new Mi;cc(c,o,zh,"ocsp"),cc(c,o,Gh,"caIssuers"),cc(c,o,Kh,"timeStamping"),cc(c,o,qh,"caRepository"),super(yl,e[1],q.serialize(c))}(t=this.ocsp)!==null&&t!==void 0||(this.ocsp=[]),(n=this.caIssuers)!==null&&n!==void 0||(this.caIssuers=[]),(i=this.timeStamping)!==null&&i!==void 0||(this.timeStamping=[]),(s=this.caRepository)!==null&&s!==void 0||(this.caRepository=[])}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],q.parse(e.extnValue,Mi).forEach(n=>{switch(n.accessMethod){case zh:this.ocsp.push(new Hn(n.accessLocation));break;case Gh:this.caIssuers.push(new Hn(n.accessLocation));break;case Kh:this.timeStamping.push(new Hn(n.accessLocation));break;case qh:this.caRepository.push(new Hn(n.accessLocation));break}})}toTextObject(){const e=this.toTextObjectWithoutValue();return this.ocsp.length&&ac(e,"OCSP",this.ocsp),this.caIssuers.length&&ac(e,"CA Issuers",this.caIssuers),this.timeStamping.length&&ac(e,"Time Stamping",this.timeStamping),this.caRepository.length&&ac(e,"CA Repository",this.caRepository),e}}Zp.NAME="Authority Info Access";function ac(r,e,t){if(t.length===1)r[e]=t[0].toTextObject();else{const n=new rt("");t.forEach((i,s)=>{const o=i.toTextObject(),c=`${o[rt.NAME]} ${s+1}`;let u=n[c];Array.isArray(u)||(u=[],n[c]=u),u.push(o)}),r[e]=n}}function cc(r,e,t,n){const i=e[n];i&&(Array.isArray(i)?i:[i]).forEach(o=>{typeof o=="string"&&(o=new Hn("url",o)),r.push(new Ss({accessMethod:t,accessLocation:q.parse(o.rawData,je)}))})}class ns extends Mn{constructor(...e){let t;if(Y.isBufferSource(e[0]))t=Y.toArrayBuffer(e[0]);else{const n=e[0],i=Array.isArray(e[1])?e[1].map(s=>Y.toArrayBuffer(s)):[];t=q.serialize(new Sn({type:n,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(t=>new rt("",{"":t})),e}toTextObjectWithoutValue(){const e=this.toTextObjectEmpty();return e[rt.NAME]===ns.NAME&&(e[rt.NAME]=Cn.toString(this.type)),e}}ns.NAME="Attribute";class Wp extends ns{constructor(...e){var t;if(Y.isBufferSource(e[0]))super(e[0]);else{const n=new rc({printableString:e[0]});super(Hd,[q.serialize(n)])}(t=this.password)!==null&&t!==void 0||(this.password="")}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],rc);this.password=t.toString()}}toTextObject(){const e=this.toTextObjectWithoutValue();return e[rt.VALUE]=this.password,e}}Wp.NAME="Challenge Password";class ef extends ns{constructor(...e){var t;if(Y.isBufferSource(e[0]))super(e[0]);else{const n=e[0],i=new fi;for(const s of n)i.push(q.parse(s.rawData,Hr));super($u,[q.serialize(i)])}(t=this.items)!==null&&t!==void 0||(this.items=[])}onInit(e){if(super.onInit(e),this.values[0]){const t=q.parse(this.values[0],fi);this.items=t.map(n=>Rr.create(q.serialize(n)))}}toTextObject(){const e=this.toTextObjectWithoutValue(),t=this.items.map(n=>n.toTextObject());for(const n of t)e[n[rt.NAME]]=n;return e}}ef.NAME="Extensions";class lc{static register(e,t){this.items.set(e,t)}static create(e){const t=new ns(e),n=this.items.get(t.type);return n?new n(e):t}}lc.items=new Map;const uc="crypto.signatureFormatter";class Pv{toAsnSignature(e,t){return Y.toArrayBuffer(t)}toWebSignature(e,t){return Y.toArrayBuffer(t)}}var fc;let tf=fc=class{static createPssParams(e,t){const n=fc.getHashAlgorithm(e);return n?new wi({hashAlgorithm:n,maskGenAlgorithm:new ne({algorithm:La,parameters:q.serialize(n)}),saltLength:t}):null}static getHashAlgorithm(e){const t=fr.resolve(ts);return typeof e=="string"?t.toAsnAlgorithm({name:e}):typeof e=="object"&&e&&"name"in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"rsassa-pkcs1-v1_5":if("hash"in e){let t;if(typeof e.hash=="string")t=e.hash;else if(e.hash&&typeof e.hash=="object"&&"name"in e.hash&&typeof e.hash.name=="string")t=e.hash.name.toUpperCase();else throw new Error("Cannot get hash algorithm name");switch(t.toLowerCase()){case"sha-1":return new ne({algorithm:ja,parameters:null});case"sha-256":return new ne({algorithm:bu,parameters:null});case"sha-384":return new ne({algorithm:Ra,parameters:null});case"sha-512":return new ne({algorithm:Ua,parameters:null})}}else return new ne({algorithm:vi,parameters:null});break;case"rsa-pss":if("hash"in e){if(!("saltLength"in e&&typeof e.saltLength=="number"))throw new Error("Cannot get 'saltLength' from 'alg' argument");const t=fc.createPssParams(e.hash,e.saltLength);if(!t)throw new Error("Cannot create PSS parameters");return new ne({algorithm:Ms,parameters:q.serialize(t)})}else return new ne({algorithm:Ms,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case vi:return{name:"RSASSA-PKCS1-v1_5"};case ja:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case bu:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case Ra:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case Ua:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case Ms:if(e.parameters){const t=q.parse(e.parameters,wi);return{name:"RSA-PSS",hash:fr.resolve(ts).toWebAlgorithm(t.hashAlgorithm),saltLength:t.saltLength}}else return{name:"RSA-PSS"}}return null}};tf=fc=f([Wa()],tf),fr.registerSingleton(Fs,tf);let rf=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case"sha-1":return new ne({algorithm:Da});case"sha-256":return new ne({algorithm:$a});case"sha-384":return new ne({algorithm:Ma});case"sha-512":return new ne({algorithm:Va})}return null}toWebAlgorithm(e){switch(e.algorithm){case Da:return{name:"SHA-1"};case $a:return{name:"SHA-256"};case Ma:return{name:"SHA-384"};case Va:return{name:"SHA-512"}}return null}};rf=f([Wa()],rf),fr.registerSingleton(Fs,rf);class Ur{addPadding(e,t){const n=Y.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=Y.toUint8Array(e);for(let i=0;i<n.length;i++)if(n[i]){n=n.slice(i);break}if(t&&n[0]>127){const i=new Uint8Array(n.length+1);return i.set(n,1),i.buffer}return n.buffer}toAsnSignature(e,t){if(e.name==="ECDSA"){const n=e.namedCurve,i=Ur.namedCurveSize.get(n)||Ur.defaultNamedCurveSize,s=new Pa,o=Y.toUint8Array(t);return s.r=this.removePadding(o.slice(0,i),!0),s.s=this.removePadding(o.slice(i,i+i),!0),q.serialize(s)}return null}toWebSignature(e,t){if(e.name==="ECDSA"){const n=q.parse(t,Pa),i=e.namedCurve,s=Ur.namedCurveSize.get(i)||Ur.defaultNamedCurveSize,o=this.addPadding(s,this.removePadding(n.r)),c=this.addPadding(s,this.removePadding(n.s));return qy(o,c)}return null}}Ur.namedCurveSize=new Map,Ur.defaultNamedCurveSize=32;const nf="1.3.101.110",Yp="1.3.101.111",sf="1.3.101.112",Jp="1.3.101.113";let of=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case"ed25519":t=sf;break;case"x25519":t=nf;break;case"eddsa":switch(e.namedCurve.toLowerCase()){case"ed25519":t=sf;break;case"ed448":t=Jp;break}break;case"ecdh-es":switch(e.namedCurve.toLowerCase()){case"x25519":t=nf;break;case"x448":t=Yp;break}}return t?new ne({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case sf:return{name:"Ed25519"};case Jp:return{name:"EdDSA",namedCurve:"Ed448"};case nf:return{name:"X25519"};case Yp:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};of=f([Wa()],of),fr.registerSingleton(Fs,of);class jv extends zr{constructor(e){zr.isAsnEncoded(e)?super(e,Hs):super(e),this.tag=Ar.CertificateRequestTag}onInit(e){this.tbs=q.serialize(e.certificationRequestInfo),this.publicKey=new on(e.certificationRequestInfo.subjectPKInfo);const t=fr.resolve(ts);this.signatureAlgorithm=t.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(i=>lc.create(q.serialize(i)));const n=this.getAttribute($u);this.extensions=[],n instanceof ef&&(this.extensions=n.items),this.subjectName=new Ln(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}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=Xt.get()){const t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,["verify"],e),i=fr.resolveAll(uc).reverse();let s=null;for(const c of i)if(s=c.toWebSignature(t,this.signature),s)break;if(!s)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await e.subtle.verify(this.signatureAlgorithm,n,s,this.tbs)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,Hs),n=t.certificationRequestInfo,i=new rt("",{Version:`${Hi[n.version]} (${n.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const s=new rt("");for(const o of this.attributes){const c=o.toTextObject();s[c[rt.NAME]]=c}i.Attributes=s}return e.Data=i,e.Signature=new rt("",{Algorithm:$n.serializeAlgorithm(t.signatureAlgorithm),"":t.signature}),e}}jv.NAME="PKCS#10 Certificate Request";class xi extends zr{constructor(e){zr.isAsnEncoded(e)?super(e,hi):super(e),this.tag=Ar.CertificateTag}onInit(e){const t=e.tbsCertificate;this.tbs=q.serialize(t),this.serialNumber=ue.ToHex(t.serialNumber),this.subjectName=new Ln(t.subject),this.subject=new Ln(t.subject).toString(),this.issuerName=new Ln(t.issuer),this.issuer=this.issuerName.toString();const n=fr.resolve(ts);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;const i=t.validity.notBefore.utcTime||t.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const s=t.validity.notAfter.utcTime||t.validity.notAfter.generalTime;if(!s)throw new Error("Cannot get 'notAfter' value");this.notAfter=s,this.extensions=[],t.extensions&&(this.extensions=t.extensions.map(o=>Rr.create(q.serialize(o)))),this.publicKey=new on(t.subjectPublicKeyInfo)}getExtension(e){for(const t of this.extensions)if(typeof e=="string"){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e=="string"?t.type===e:t instanceof e)}async verify(e={},t=Xt.get()){let n,i;const s=e.publicKey;try{if(!s)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,["verify"],t);else if("publicKey"in s)n={...s.publicKey.algorithm,...this.signatureAlgorithm},i=await s.publicKey.export(n,["verify"],t);else if(s instanceof on)n={...s.algorithm,...this.signatureAlgorithm},i=await s.export(n,["verify"],t);else if(Y.isBufferSource(s)){const h=new on(s);n={...h.algorithm,...this.signatureAlgorithm},i=await h.export(n,["verify"],t)}else n={...s.algorithm,...this.signatureAlgorithm},i=s}catch{return!1}const o=fr.resolveAll(uc).reverse();let c=null;for(const h of o)if(c=h.toWebSignature(n,this.signature),c)break;if(!c)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const u=await t.subtle.verify(this.signatureAlgorithm,i,c,this.tbs);if(e.signatureOnly)return u;{const m=(e.date||new Date).getTime();return u&&this.notBefore.getTime()<m&&m<this.notAfter.getTime()}}async getThumbprint(...e){let t,n="SHA-1";return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??(t=Xt.get()),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=Xt.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){const e=this.toTextObjectEmpty(),t=q.parse(this.rawData,hi),n=t.tbsCertificate,i=new rt("",{Version:`${Hi[n.version]} (${n.version})`,"Serial Number":n.serialNumber,"Signature Algorithm":$n.serializeAlgorithm(n.signature),Issuer:this.issuer,Validity:new rt("",{"Not Before":n.validity.notBefore.getTime(),"Not After":n.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(n.issuerUniqueID&&(i["Issuer Unique ID"]=n.issuerUniqueID),n.subjectUniqueID&&(i["Subject Unique ID"]=n.subjectUniqueID),this.extensions.length){const s=new rt("");for(const o of this.extensions){const c=o.toTextObject();s[c[rt.NAME]]=c}i.Extensions=s}return e.Data=i,e.Signature=new rt("",{Algorithm:$n.serializeAlgorithm(t.signatureAlgorithm),"":t.signatureValue}),e}}xi.NAME="Certificate";class Rv extends Array{constructor(e){if(super(),zr.isAsnEncoded(e))this.import(e);else if(e instanceof xi)this.push(e);else if(Array.isArray(e))for(const t of e)this.push(t)}export(e){const t=new In;t.version=1,t.encapContentInfo.eContentType=Hg,t.encapContentInfo.eContent=new Zi({single:new tt}),t.certificates=new Cs(this.map(s=>new yi({certificate:q.parse(s.rawData,hi)})));const n=new En({contentType:du,content:q.serialize(t)}),i=q.serialize(n);return e==="raw"?i:this.toString(e)}import(e){const t=zr.toArrayBuffer(e),n=q.parse(t,En);if(n.contentType!==du)throw new TypeError("Cannot parse CMS package. Incoming data is not a SignedData object.");const i=q.parse(n.content,In);this.clear();for(const s of i.certificates||[])s.certificate&&this.push(new xi(s.certificate))}clear(){for(;this.pop(););}toString(e="pem"){const t=this.export("raw");switch(e){case"pem":return Ar.encode(t,"CMS");case"pem-chain":return this.map(n=>n.toString("pem")).join(`
118
+ `);case"asn":return q.toString(t);case"hex":return ue.ToHex(t);case"base64":return ue.ToBase64(t);case"base64url":return ue.ToBase64Url(t);case"text":return $n.serialize(this.toTextObject());default:throw TypeError("Argument 'format' is unsupported value")}}toTextObject(){const e=q.parse(this.export("raw"),En),t=q.parse(e.content,In);return new rt("X509Certificates",{"Content Type":Cn.toString(e.contentType),Content:new rt("",{Version:`${tn[t.version]} (${t.version})`,Certificates:new rt("",{Certificate:this.map(i=>i.toTextObject())})})})}}class Uv{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=Xt.get()){const n=new Rv(e);let i=e;for(;i=await this.findIssuer(i,t);){const s=await i.getThumbprint(t);for(const o of n){const c=await o.getThumbprint(t);if(No(s,c))throw new Error("Cannot build a certificate chain. Circular dependency.")}n.push(i)}return n}async findIssuer(e,t=Xt.get()){if(!await e.isSelfSigned(t)){const n=e.getExtension(ta);for(const i of this.certificates)if(i.subject===e.issuer){if(n){if(n.keyId){const s=i.getExtension(Ml);if(s&&s.keyId!==n.keyId)continue}else if(n.certId){const s=i.getExtension(Ul);if(s&&!(n.certId.serialNumber===i.serialNumber&&No(q.serialize(n.certId.name),q.serialize(s))))continue}}try{const s={...i.publicKey.algorithm,...e.signatureAlgorithm},o=await i.publicKey.export(s,["verify"],t);if(!await e.verify({publicKey:o,signatureOnly:!0},t))continue}catch{continue}return i}}return null}}var Xp;(function(r){r[r.unspecified=0]="unspecified",r[r.keyCompromise=1]="keyCompromise",r[r.cACompromise=2]="cACompromise",r[r.affiliationChanged=3]="affiliationChanged",r[r.superseded=4]="superseded",r[r.cessationOfOperation=5]="cessationOfOperation",r[r.certificateHold=6]="certificateHold",r[r.removeFromCRL=8]="removeFromCRL",r[r.privilegeWithdrawn=9]="privilegeWithdrawn",r[r.aACompromise=10]="aACompromise"})(Xp||(Xp={})),Rr.register(Zh,Vp),Rr.register(ed,Hp),Rr.register(rd,zp),Rr.register(Ml,oc),Rr.register(ta,Zs),Rr.register(Ul,Gp),Rr.register(_l,qp),Rr.register(yl,Zp),lc.register(Hd,Wp),lc.register($u,ef),fr.registerSingleton(uc,Pv),fr.registerSingleton(uc,Ur),Ur.namedCurveSize.set("P-256",32),Ur.namedCurveSize.set("K-256",32),Ur.namedCurveSize.set("P-384",48),Ur.namedCurveSize.set("P-521",66);const ge={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},Et={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,MIME:36,SET:258,JSON:262,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},St={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},Fn={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ir=(vo=class{},Fe(vo,"BREAK",Symbol.for("github.com/hildjj/cbor2/break")),Fe(vo,"ENCODED",Symbol.for("github.com/hildjj/cbor2/cbor-encoded")),Fe(vo,"LENGTH",Symbol.for("github.com/hildjj/cbor2/length")),vo);const hc={MIN:-(2n**63n),MAX:2n**64n-1n};let We=(Tn=class{constructor(e,t=void 0){Fe(this,"tag");Fe(this,"contents");this.tag=e,this.contents=t}get noChildren(){var e;return!!((e=$(Tn,un).get(this.tag))!=null&&e.noChildren)}static registerDecoder(e,t,n){const i=$(this,un).get(e);return $(this,un).set(e,t),i&&("comment"in t||(t.comment=i.comment),"noChildren"in t||(t.noChildren=i.noChildren)),n&&!t.comment&&(t.comment=()=>`(${n})`),i}static clearDecoder(e){const t=$(this,un).get(e);return $(this,un).delete(e),t}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const t=$(Tn,un).get(this.tag);return t?t(this,e):this}comment(e,t){const n=$(Tn,un).get(this.tag);if(n!=null&&n.comment)return n.comment(this,e,t)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`${this.tag}(${n(this.contents,t)})`}},un=new WeakMap,cr(Tn,un,new Map),Tn);function dc(r){if(r!=null&&typeof r=="object")return r[Ir.ENCODED]}function Dv(r){if(r!=null&&typeof r=="object")return r[Ir.LENGTH]}function Ws(r,e){Object.defineProperty(r,Ir.ENCODED,{configurable:!0,enumerable:!1,value:e})}function Ys(r,e){const t=Object(r);return Ws(t,e),t}function Qp(r){let e=Math.ceil(r.length/2);const t=new Uint8Array(e);e--;for(let n=r.length,i=n-2;n>=0;n=i,i-=2,e--)t[e]=parseInt(r.substring(i,n),16);return t}function Gr(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function $v(r){const e=r.reduce((i,s)=>i+s.length,0),t=new Uint8Array(e);let n=0;for(const i of r)t.set(i,n),n+=i.length;return t}function af(r){const e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}const Mv={"-":"+",_:"/"};function Vv(r){const e=r.replace(/[_-]/g,t=>Mv[t]);return af(e.padEnd(Math.ceil(e.length/4)*4,"="))}function Lv(){const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])}function e0(r){var t;let e="";for(const n of r){const i=(t=n.codePointAt(0))==null?void 0:t.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${i}`}return e}function t0(r,e){const[t,n,i]=r,[s,o,c]=e,u=Math.min(i.length,c.length);for(let h=0;h<u;h++){const m=i[h]-c[h];if(m!==0)return m}return 0}const jc=class jc{constructor(e={}){cr(this,et);cr(this,Xn);cr(this,Qt,[]);cr(this,Sr,null);cr(this,Mt,0);cr(this,Qn,0);if(jt(this,Xn,{...jc.defaultOptions,...e}),$(this,Xn).chunkSize<8)throw new RangeError(`Expected size >= 8, got ${$(this,Xn).chunkSize}`);$e(this,et,Oi).call(this)}get length(){return $(this,Qn)}read(){$e(this,et,Vc).call(this);const e=new Uint8Array($(this,Qn));let t=0;for(const n of $(this,Qt))e.set(n,t),t+=n.length;return $e(this,et,Oi).call(this),e}write(e){const t=e.length;t>$e(this,et,Ef).call(this)?($e(this,et,Vc).call(this),t>$(this,Xn).chunkSize?($(this,Qt).push(e),$e(this,et,Oi).call(this)):($e(this,et,Oi).call(this),$(this,Qt)[$(this,Qt).length-1].set(e),jt(this,Mt,t))):($(this,Qt)[$(this,Qt).length-1].set(e,$(this,Mt)),jt(this,Mt,$(this,Mt)+t)),jt(this,Qn,$(this,Qn)+t)}writeUint8(e){$e(this,et,yn).call(this,1),$(this,Sr).setUint8($(this,Mt),e),$e(this,et,gn).call(this,1)}writeUint16(e,t=!1){$e(this,et,yn).call(this,2),$(this,Sr).setUint16($(this,Mt),e,t),$e(this,et,gn).call(this,2)}writeUint32(e,t=!1){$e(this,et,yn).call(this,4),$(this,Sr).setUint32($(this,Mt),e,t),$e(this,et,gn).call(this,4)}writeBigUint64(e,t=!1){$e(this,et,yn).call(this,8),$(this,Sr).setBigUint64($(this,Mt),e,t),$e(this,et,gn).call(this,8)}writeInt16(e,t=!1){$e(this,et,yn).call(this,2),$(this,Sr).setInt16($(this,Mt),e,t),$e(this,et,gn).call(this,2)}writeInt32(e,t=!1){$e(this,et,yn).call(this,4),$(this,Sr).setInt32($(this,Mt),e,t),$e(this,et,gn).call(this,4)}writeBigInt64(e,t=!1){$e(this,et,yn).call(this,8),$(this,Sr).setBigInt64($(this,Mt),e,t),$e(this,et,gn).call(this,8)}writeFloat32(e,t=!1){$e(this,et,yn).call(this,4),$(this,Sr).setFloat32($(this,Mt),e,t),$e(this,et,gn).call(this,4)}writeFloat64(e,t=!1){$e(this,et,yn).call(this,8),$(this,Sr).setFloat64($(this,Mt),e,t),$e(this,et,gn).call(this,8)}clear(){jt(this,Qn,0),jt(this,Qt,[]),$e(this,et,Oi).call(this)}};Xn=new WeakMap,Qt=new WeakMap,Sr=new WeakMap,Mt=new WeakMap,Qn=new WeakMap,et=new WeakSet,Oi=function(){const e=new Uint8Array($(this,Xn).chunkSize);$(this,Qt).push(e),jt(this,Mt,0),jt(this,Sr,new DataView(e.buffer,e.byteOffset,e.byteLength))},Vc=function(){if($(this,Mt)===0){$(this,Qt).pop();return}const e=$(this,Qt).length-1;$(this,Qt)[e]=$(this,Qt)[e].subarray(0,$(this,Mt)),jt(this,Mt,0),jt(this,Sr,null)},Ef=function(){const e=$(this,Qt).length-1;return $(this,Qt)[e].length-$(this,Mt)},yn=function(e){$e(this,et,Ef).call(this)<e&&($e(this,et,Vc).call(this),$e(this,et,Oi).call(this))},gn=function(e){jt(this,Mt,$(this,Mt)+e),jt(this,Qn,$(this,Qn)+e)},Fe(jc,"defaultOptions",{chunkSize:4096});let pc=jc;function r0(r,e=0,t=!1){const n=r[e]&128?-1:1,i=(r[e]&124)>>2,s=(r[e]&3)<<8|r[e+1];if(i===0){if(t&&s!==0)throw new Error(`Unwanted subnormal: ${n*5960464477539063e-23*s}`);return n*5960464477539063e-23*s}else if(i===31)return s?NaN:n*(1/0);return n*2**(i-25)*(1024+s)}function Hv(r){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,r,!1);const t=e.getUint32(0,!1);if(t&8191)return null;let n=t>>16&32768;const i=t>>23&255,s=t&8388607;if(!(i===0&&s===0))if(i>=113&&i<=142)n+=(i-112<<10)+(s>>13);else if(i>=103&&i<113){if(s&(1<<126-i)-1)return null;n+=s+8388608>>126-i}else if(i===255)n|=31744,n|=s>>13;else return null;return n}function Fv(r){if(r!==0){const e=new ArrayBuffer(8),t=new DataView(e);t.setFloat64(0,r,!1);const n=t.getBigUint64(0,!1);if((n&0x7ff0000000000000n)===0n)return n&0x8000000000000000n?-0:0}return r}function zv(r){switch(r.length){case 2:r0(r,0,!0);break;case 4:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getUint32(0,!1);if(!(t&2139095040)&&t&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(r.buffer,r.byteOffset,r.byteLength),t=e.getBigUint64(0,!1);if((t&0x7ff0000000000000n)===0n&&t&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${r}`)}}const n0=ge.SIMPLE_FLOAT<<5|St.TWO,Gv=ge.SIMPLE_FLOAT<<5|St.FOUR,Kv=ge.SIMPLE_FLOAT<<5|St.EIGHT,qv=ge.SIMPLE_FLOAT<<5|Fn.TRUE,Zv=ge.SIMPLE_FLOAT<<5|Fn.FALSE,Wv=ge.SIMPLE_FLOAT<<5|Fn.UNDEFINED,Yv=ge.SIMPLE_FLOAT<<5|Fn.NULL,Jv=new TextEncoder,Xv={...pc.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null},i0={cde:!0,ignoreOriginalEncoding:!0,sortKeys:t0},Qv={...i0,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function s0(r){const e=r<0;return typeof r=="bigint"?[e?-r-1n:r,e]:[e?-r-1:r,e]}function cf(r,e,t){if(t.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${r}`);if(isNaN(r))e.writeUint8(n0),e.writeUint16(32256);else if(!t.float64&&Math.fround(r)===r){const n=Hv(r);n===null?(e.writeUint8(Gv),e.writeFloat32(r)):(e.writeUint8(n0),e.writeUint16(n))}else e.writeUint8(Kv),e.writeFloat64(r)}function Kr(r,e,t){const[n,i]=s0(r);if(i&&t)throw new TypeError(`Negative size: ${r}`);t??(t=i?ge.NEG_INT:ge.POS_INT),t<<=5,n<24?e.writeUint8(t|n):n<=255?(e.writeUint8(t|St.ONE),e.writeUint8(n)):n<=65535?(e.writeUint8(t|St.TWO),e.writeUint16(n)):n<=4294967295?(e.writeUint8(t|St.FOUR),e.writeUint32(n)):(e.writeUint8(t|St.EIGHT),e.writeBigUint64(BigInt(n)))}function yc(r,e,t){typeof r=="number"?Kr(r,e,ge.TAG):typeof r=="object"&&!t.ignoreOriginalEncoding&&Ir.ENCODED in r?e.write(r[Ir.ENCODED]):r<=Number.MAX_SAFE_INTEGER?Kr(Number(r),e,ge.TAG):(e.writeUint8(ge.TAG<<5|St.EIGHT),e.writeBigUint64(BigInt(r)))}function o0(r,e,t){const[n,i]=s0(r);if(t.collapseBigInts&&(!t.largeNegativeAsBigInt||r>=-0x8000000000000000n)){if(n<=0xffffffffn){Kr(Number(r),e);return}if(n<=0xffffffffffffffffn){const h=(i?ge.NEG_INT:ge.POS_INT)<<5;e.writeUint8(h|St.EIGHT),e.writeBigUint64(n);return}}if(t.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${r}`);const s=i?Et.NEG_BIGINT:Et.POS_BIGINT,o=n.toString(16),c=o.length%2?"0":"";yc(s,e,t);const u=Qp(c+o);Kr(u.length,e,ge.BYTE_STRING),e.write(u)}function em(r,e,t){t.flushToZero&&(r=Fv(r)),Object.is(r,-0)?t.simplifyNegativeZero?t.avoidInts?cf(0,e,t):Kr(0,e):cf(r,e,t):!t.avoidInts&&Number.isSafeInteger(r)?Kr(r,e):t.reduceUnsafeNumbers&&Math.floor(r)===r&&r>=hc.MIN&&r<=hc.MAX?o0(BigInt(r),e,t):cf(r,e,t)}function tm(r,e,t){const n=t.stringNormalization?r.normalize(t.stringNormalization):r,i=Jv.encode(n);Kr(i.length,e,ge.UTF8_STRING),e.write(i)}function rm(r,e,t){const n=r;uf(n,n.length,ge.ARRAY,e,t);for(const i of n)Ai(i,e,t)}function nm(r,e){const t=r;Kr(t.length,e,ge.BYTE_STRING),e.write(t)}const lf=new Map([[Array,rm],[Uint8Array,nm]]);function Rt(r,e){const t=lf.get(r);return lf.set(r,e),t}function uf(r,e,t,n,i){const s=Dv(r);s&&!i.ignoreOriginalEncoding?n.write(s):Kr(e,n,t)}function im(r,e,t){if(r===null){e.writeUint8(Yv);return}if(!t.ignoreOriginalEncoding&&Ir.ENCODED in r){e.write(r[Ir.ENCODED]);return}const n=lf.get(r.constructor);if(n){const s=n(r,e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&yc(s[0],e,t),Ai(s[1],e,t));return}if(typeof r.toCBOR=="function"){const s=r.toCBOR(e,t);s&&((typeof s[0]=="bigint"||isFinite(Number(s[0])))&&yc(s[0],e,t),Ai(s[1],e,t));return}if(typeof r.toJSON=="function"){Ai(r.toJSON(),e,t);return}const i=Object.entries(r).map(s=>[s[0],s[1],gc(s[0],t)]);t.sortKeys&&i.sort(t.sortKeys),uf(r,i.length,ge.MAP,e,t);for(const[s,o,c]of i)e.write(c),Ai(o,e,t)}function Ai(r,e,t){switch(typeof r){case"number":em(r,e,t);break;case"bigint":o0(r,e,t);break;case"string":tm(r,e,t);break;case"boolean":e.writeUint8(r?qv:Zv);break;case"undefined":if(t.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(Wv);break;case"object":im(r,e,t);break;case"symbol":throw new TypeError(`Unknown symbol: ${r.toString()}`);default:throw new TypeError(`Unknown type: ${typeof r}, ${String(r)}`)}}function gc(r,e={}){const t={...Xv};e.dcbor?Object.assign(t,Qv):e.cde&&Object.assign(t,i0),Object.assign(t,e);const n=new pc(t);return Ai(r,n,t),n.read()}var a0=(r=>(r[r.NEVER=-1]="NEVER",r[r.PREFERRED=0]="PREFERRED",r[r.ALWAYS=1]="ALWAYS",r))(a0||{});const ei=class ei{constructor(e){Fe(this,"value");this.value=e}static create(e){return ei.KnownSimple.has(e)?ei.KnownSimple.get(e):new ei(e)}toCBOR(e,t){if(t.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Kr(this.value,e,ge.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return ei.KnownSimple.has(this.value)?ei.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return`simple(${n(this.value,t)})`}};Fe(ei,"KnownSimple",new Map([[Fn.FALSE,!1],[Fn.TRUE,!0],[Fn.NULL,null],[Fn.UNDEFINED,void 0]]));let Js=ei;const sm=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}),Rc=class Rc{constructor(e,t){cr(this,tr);cr(this,Cr);cr(this,Yr);cr(this,er,0);cr(this,Dr);if(jt(this,Dr,{...Rc.defaultOptions,...t}),typeof e=="string")switch($(this,Dr).encoding){case"hex":jt(this,Cr,Qp(e));break;case"base64":jt(this,Cr,af(e));break;default:throw new TypeError(`Encoding not implemented: "${$(this,Dr).encoding}"`)}else jt(this,Cr,e);jt(this,Yr,new DataView($(this,Cr).buffer,$(this,Cr).byteOffset,$(this,Cr).byteLength))}toHere(e){return $(this,Cr).subarray(e,$(this,er))}*[Symbol.iterator](){if(yield*$e(this,tr,Ti).call(this,0),$(this,er)!==$(this,Cr).length)throw new Error("Extra data in input")}};Cr=new WeakMap,Yr=new WeakMap,er=new WeakMap,Dr=new WeakMap,tr=new WeakSet,Ti=function*(e){if(e++>$(this,Dr).maxDepth)throw new Error(`Maximum depth ${$(this,Dr).maxDepth} exceeded`);const t=$(this,er),n=$(this,Yr).getUint8(Sy(this,er)._++),i=n>>5,s=n&31;let o=s,c=!1,u=0;switch(s){case St.ONE:if(u=1,o=$(this,Yr).getUint8($(this,er)),i===ge.SIMPLE_FLOAT){if(o<32)throw new Error(`Invalid simple encoding in extra byte: ${o}`);c=!0}else if($(this,Dr).requirePreferred&&o<24)throw new Error(`Unexpectedly long integer encoding (1) for ${o}`);break;case St.TWO:if(u=2,i===ge.SIMPLE_FLOAT)o=r0($(this,Cr),$(this,er));else if(o=$(this,Yr).getUint16($(this,er),!1),$(this,Dr).requirePreferred&&o<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${o}`);break;case St.FOUR:if(u=4,i===ge.SIMPLE_FLOAT)o=$(this,Yr).getFloat32($(this,er),!1);else if(o=$(this,Yr).getUint32($(this,er),!1),$(this,Dr).requirePreferred&&o<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${o}`);break;case St.EIGHT:{if(u=8,i===ge.SIMPLE_FLOAT)o=$(this,Yr).getFloat64($(this,er),!1);else if(o=$(this,Yr).getBigUint64($(this,er),!1),o<=Number.MAX_SAFE_INTEGER&&(o=Number(o)),$(this,Dr).requirePreferred&&o<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${o}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${s}`);case St.INDEFINITE:switch(i){case ge.POS_INT:case ge.NEG_INT:case ge.TAG:throw new Error(`Invalid indefinite encoding for MT ${i}`);case ge.SIMPLE_FLOAT:yield[i,s,Ir.BREAK,t,0];return}o=1/0;break;default:c=!0}switch(jt(this,er,$(this,er)+u),i){case ge.POS_INT:yield[i,s,o,t,u];break;case ge.NEG_INT:yield[i,s,typeof o=="bigint"?-1n-o:-1-Number(o),t,u];break;case ge.BYTE_STRING:o===1/0?yield*$e(this,tr,To).call(this,i,e,t):yield[i,s,$e(this,tr,If).call(this,o),t,o];break;case ge.UTF8_STRING:o===1/0?yield*$e(this,tr,To).call(this,i,e,t):yield[i,s,sm.decode($e(this,tr,If).call(this,o)),t,o];break;case ge.ARRAY:if(o===1/0)yield*$e(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let m=0;m<h;m++)yield*$e(this,tr,Ti).call(this,e+1)}break;case ge.MAP:if(o===1/0)yield*$e(this,tr,To).call(this,i,e,t,!1);else{const h=Number(o);yield[i,s,h,t,u];for(let m=0;m<h;m++)yield*$e(this,tr,Ti).call(this,e),yield*$e(this,tr,Ti).call(this,e)}break;case ge.TAG:yield[i,s,o,t,u],yield*$e(this,tr,Ti).call(this,e);break;case ge.SIMPLE_FLOAT:{const h=o;c&&(o=Js.create(Number(o))),yield[i,s,o,t,h];break}}},If=function(e){const t=$(this,Cr).subarray($(this,er),jt(this,er,$(this,er)+e));if(t.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${t.length}`);return t},To=function*(e,t,n,i=!0){for(yield[e,St.INDEFINITE,1/0,n,1/0];;){const s=$e(this,tr,Ti).call(this,t),o=s.next(),[c,u,h]=o.value;if(h===Ir.BREAK){yield o.value,s.next();return}if(i){if(c!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${c}.`);if(u===St.INDEFINITE)throw new Error("New stream started in typed stream")}yield o.value,yield*s}},Fe(Rc,"defaultOptions",{maxDepth:1024,encoding:"hex",requirePreferred:!1});let Xs=Rc;const om=new Map([[St.ZERO,1],[St.ONE,2],[St.TWO,3],[St.FOUR,5],[St.EIGHT,9]]),am=new Uint8Array(0);let zn=(fn=class{constructor(e,t,n,i){cr(this,Uc);Fe(this,"parent");Fe(this,"mt");Fe(this,"ai");Fe(this,"left");Fe(this,"offset");Fe(this,"count",0);Fe(this,"children",[]);Fe(this,"depth",0);cr(this,dr);cr(this,hn,null);if([this.mt,this.ai,,this.offset]=e,this.left=t,this.parent=n,jt(this,dr,i),n&&(this.depth=n.depth+1),this.mt===ge.MAP&&($(this,dr).sortKeys||$(this,dr).rejectDuplicateKeys)&&jt(this,hn,[]),$(this,dr).rejectStreaming&&this.ai===St.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,t,n,i){const[s,o,c,u]=e;switch(s){case ge.POS_INT:case ge.NEG_INT:{if(n.rejectInts)throw new Error(`Unexpected integer: ${c}`);if(n.rejectLargeNegatives&&c<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${c}`);let h=c;return n.convertUnsafeIntsToFloat&&h>=hc.MIN&&h<=hc.MAX&&(h=Number(c)),n.boxed?Ys(h,i.toHere(u)):h}case ge.SIMPLE_FLOAT:if(o>St.ONE){if(n.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${c}`);if(n.rejectNegativeZero&&Object.is(c,-0))throw new Error("Decoding negative zero");if(n.rejectLongLoundNaN&&isNaN(c)){const h=i.toHere(u);if(h.length!==3||h[1]!==126||h[2]!==0)throw new Error(`Invalid NaN encoding: "${Gr(h)}"`)}if(n.rejectSubnormals&&zv(i.toHere(u+1)),n.rejectLongFloats){const h=gc(c,{chunkSize:9,reduceUnsafeNumbers:n.rejectUnsafeFloatInts});if(h[0]>>5!==s)throw new Error(`Should have been encoded as int, not float: ${c}`);if(h.length<om.get(o))throw new Error(`Number should have been encoded shorter: ${c}`)}if(typeof c=="number"&&n.boxed)return Ys(c,i.toHere(u))}else{if(n.rejectSimple&&c instanceof Js)throw new Error(`Invalid simple value: ${c}`);if(n.rejectUndefined&&c===void 0)throw new Error("Unexpected undefined")}return c;case ge.BYTE_STRING:case ge.UTF8_STRING:if(c===1/0)return new n.ParentType(e,1/0,t,n);if(n.rejectStringsNotNormalizedAs&&typeof c=="string"){const h=c.normalize(n.rejectStringsNotNormalizedAs);if(c!==h)throw new Error(`String not normalized as "${n.rejectStringsNotNormalizedAs}", got [${e0(c)}] instead of [${e0(h)}]`)}return n.boxed?Ys(c,i.toHere(u)):c;case ge.ARRAY:return new n.ParentType(e,c,t,n);case ge.MAP:return new n.ParentType(e,c*2,t,n);case ge.TAG:{const h=new n.ParentType(e,1,t,n);return h.children=new We(c),h}}throw new TypeError(`Invalid major type: ${s}`)}push(e,t,n){if(this.children.push(e),$(this,hn)){const i=dc(e)||t.toHere(n);$(this,hn).push(i)}return--this.left}replaceLast(e,t,n){let i,s=-1/0;if(this.children instanceof We?(s=0,i=this.children.contents,this.children.contents=e):(s=this.children.length-1,i=this.children[s],this.children[s]=e),$(this,hn)){const o=dc(e)||n.toHere(t.offset);$(this,hn)[s]=o}return i}convert(e){let t;switch(this.mt){case ge.ARRAY:t=this.children;break;case ge.MAP:{const n=$e(this,Uc,Iy).call(this);if($(this,dr).sortKeys){let i;for(const s of n){if(i&&$(this,dr).sortKeys(i,s)>=0)throw new Error(`Duplicate or out of order key: "0x${s[2]}"`);i=s}}else if($(this,dr).rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate key: "0x${u}"`);i.add(u)}}t=!$(this,dr).boxed&&!$(this,dr).preferMap&&n.every(([i])=>typeof i=="string")?Object.fromEntries(n):new Map(n);break}case ge.BYTE_STRING:return $v(this.children);case ge.UTF8_STRING:{const n=this.children.join("");t=$(this,dr).boxed?Ys(n,e.toHere(this.offset)):n;break}case ge.TAG:t=this.children.decode($(this,dr));break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return $(this,dr).saveOriginal&&t&&typeof t=="object"&&Ws(t,e.toHere(this.offset)),t}},dr=new WeakMap,hn=new WeakMap,Uc=new WeakSet,Iy=function(){const e=this.children,t=e.length;if(t%2)throw new Error("Missing map value");const n=new Array(t/2);if($(this,hn))for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],$(this,hn)[i]];else for(let i=0;i<t;i+=2)n[i>>1]=[e[i],e[i+1],am];return n},Fe(fn,"defaultDecodeOptions",{...Xs.defaultOptions,ParentType:fn,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:a0.PREFERRED,convertUnsafeIntsToFloat:!1,pretty:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null}),Fe(fn,"cdeDecodeOptions",{cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:t0}),Fe(fn,"dcborDecodeOptions",{...fn.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"}),fn);class ff extends(by=zn,wy=Ir.ENCODED,by){constructor(t,n,i,s){super(t,n,i,s);Fe(this,"depth",0);Fe(this,"leaf",!1);Fe(this,"value");Fe(this,"length");Fe(this,wy);this.parent?this.depth=this.parent.depth+1:this.depth=s.initialDepth,[,,this.value,,this.length]=t}numBytes(){switch(this.ai){case St.ONE:return 1;case St.TWO:return 2;case St.FOUR:return 4;case St.EIGHT:return 8}return 0}}function c0(r){return r instanceof ff}function vc(r,e){return r===1/0?"Indefinite":e?`${r} ${e}${r!==1&&r!==1n?"s":""}`:String(r)}function hf(r){return"".padStart(r," ")}function l0(r,e,t){let n="";n+=hf(r.depth*2);const i=dc(r);n+=Gr(i.subarray(0,1));const s=r.numBytes();s&&(n+=" ",n+=Gr(i.subarray(1,s+1))),n=n.padEnd(e.minCol+1," "),n+="-- ",t!==void 0&&(n+=hf(r.depth*2),t!==""&&(n+=`[${t}] `));let o=!1;const[c]=r.children;switch(r.mt){case ge.POS_INT:n+=`Unsigned: ${c}`,typeof c=="bigint"&&(n+="n");break;case ge.NEG_INT:n+=`Negative: ${c}`,typeof c=="bigint"&&(n+="n");break;case ge.BYTE_STRING:n+=`Bytes (Length: ${vc(r.length)})`;break;case ge.UTF8_STRING:n+=`UTF8 (Length: ${vc(r.length)})`,r.length!==1/0&&(n+=`: ${JSON.stringify(c)}`);break;case ge.ARRAY:n+=`Array (Length: ${vc(r.value,"item")})`;break;case ge.MAP:n+=`Map (Length: ${vc(r.value,"pair")})`;break;case ge.TAG:{n+=`Tag #${r.value}`;const u=r.children,[h]=u.contents.children,m=new We(u.tag,h);Ws(m,i);const x=m.comment(e,r.depth);x&&(n+=": ",n+=x),o||(o=m.noChildren);break}case ge.SIMPLE_FLOAT:c===Ir.BREAK?n+="BREAK":r.ai>St.ONE?Object.is(c,-0)?n+="Float: -0":n+=`Float: ${c}`:(n+="Simple: ",c instanceof Js?n+=c.value:n+=c);break}if(!o)if(r.leaf){if(n+=`
119
119
  `,i.length>s+1){const u=hf((r.depth+1)*2);for(let h=s+1;h<i.length;h+=8)n+=u,n+=Gr(i.subarray(h,h+8)),n+=`
120
120
  `}}else{n+=`
121
- `;let u=0;for(const h of r.children){if(c0(h)){let m=String(u);r.mt===ve.MAP?m=u%2?`val ${(u-1)/2}`:`key ${u/2}`:r.mt===ve.TAG&&(m=""),n+=l0(h,e,m)}u++}}return n}const cm={...zn.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function lm(r,e){const t={...cm,...e,ParentType:ff,saveOriginal:!0},n=new Xs(r,t);let i,s;for(const c of n){if(s=zn.create(c,i,t,n),c[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=1;else throw new Error("Unexpected BREAK");if(!c0(s)){const m=new ff(c,0,i,t);m.leaf=!0,m.children.push(s),Ws(m,n.toHere(c[3])),s=m}let u=(s.depth+1)*2;const h=s.numBytes();for(h&&(u+=1,u+=h*2),t.minCol=Math.max(t.minCol,u),i&&i.push(s,n,c[3]),i=s;i!=null&&i.done;)s=i,s.leaf||Ws(s,n.toHere(s.offset)),{parent:i}=i}e&&(e.minCol=t.minCol);let o=t.noPrefixHex?"":`0x${Gr(n.toHere(0))}
122
- `;return o+=l0(s,t),o}const u0=!Lv();function f0(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Gn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function Si(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function h0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Nt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],gc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),uf(r,r.size,ve.MAP,e,t);for(const[i,s,o]of n)e.write(o),Ai(s,e,t)});function d0(r){return Gn(r.contents),new Date(r.contents)}d0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),Ze.registerDecoder(St.DATE_STRING,d0);function p0(r){return f0(r.contents),new Date(r.contents*1e3)}p0.comment=r=>(f0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),Ze.registerDecoder(St.DATE_EPOCH,p0),Nt(Date,r=>[St.DATE_EPOCH,r.valueOf()/1e3]);function mc(r,e,t){if(Si(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?Ys(n,e.contents):n}const y0=mc.bind(null,!1),g0=mc.bind(null,!0);y0.comment=(r,e)=>`(Positive BigInt) ${mc(!1,r,e)}n`,g0.comment=(r,e)=>`(Negative BigInt) ${mc(!0,r,e)}n`,Ze.registerDecoder(St.POS_BIGINT,y0),Ze.registerDecoder(St.NEG_BIGINT,g0);function df(r,e){return Si(r.contents),r}df.comment=(r,e,t)=>{Si(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=dc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Gr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=lm(r.contents,n);let h=`Embedded CBOR
121
+ `;let u=0;for(const h of r.children){if(c0(h)){let m=String(u);r.mt===ge.MAP?m=u%2?`val ${(u-1)/2}`:`key ${u/2}`:r.mt===ge.TAG&&(m=""),n+=l0(h,e,m)}u++}}return n}const cm={...zn.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function lm(r,e){const t={...cm,...e,ParentType:ff,saveOriginal:!0},n=new Xs(r,t);let i,s;for(const c of n){if(s=zn.create(c,i,t,n),c[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=1;else throw new Error("Unexpected BREAK");if(!c0(s)){const m=new ff(c,0,i,t);m.leaf=!0,m.children.push(s),Ws(m,n.toHere(c[3])),s=m}let u=(s.depth+1)*2;const h=s.numBytes();for(h&&(u+=1,u+=h*2),t.minCol=Math.max(t.minCol,u),i&&i.push(s,n,c[3]),i=s;i!=null&&i.done;)s=i,s.leaf||Ws(s,n.toHere(s.offset)),{parent:i}=i}e&&(e.minCol=t.minCol);let o=t.noPrefixHex?"":`0x${Gr(n.toHere(0))}
122
+ `;return o+=l0(s,t),o}const u0=!Lv();function f0(r){if(typeof r=="object"&&r){if(r.constructor!==Number)throw new Error(`Expected number: ${r}`)}else if(typeof r!="number")throw new Error(`Expected number: ${r}`)}function Gn(r){if(typeof r=="object"&&r){if(r.constructor!==String)throw new Error(`Expected string: ${r}`)}else if(typeof r!="string")throw new Error(`Expected string: ${r}`)}function Si(r){if(!(r instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${r}`)}function h0(r){if(!Array.isArray(r))throw new Error(`Expected Array: ${r}`)}Rt(Map,(r,e,t)=>{const n=[...r.entries()].map(i=>[i[0],i[1],gc(i[0],t)]);if(t.rejectDuplicateKeys){const i=new Set;for(const[s,o,c]of n){const u=Gr(c);if(i.has(u))throw new Error(`Duplicate map key: 0x${u}`);i.add(u)}}t.sortKeys&&n.sort(t.sortKeys),uf(r,r.size,ge.MAP,e,t);for(const[i,s,o]of n)e.write(o),Ai(s,e,t)});function d0(r){return Gn(r.contents),new Date(r.contents)}d0.comment=r=>(Gn(r.contents),`(String Date) ${new Date(r.contents).toISOString()}`),We.registerDecoder(Et.DATE_STRING,d0);function p0(r){return f0(r.contents),new Date(r.contents*1e3)}p0.comment=r=>(f0(r.contents),`(Epoch Date) ${new Date(r.contents*1e3).toISOString()}`),We.registerDecoder(Et.DATE_EPOCH,p0),Rt(Date,r=>[Et.DATE_EPOCH,r.valueOf()/1e3]);function mc(r,e,t){if(Si(e.contents),t.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Gr(e.contents)}')`);if(t.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Gr(e.contents)})`);let n=e.contents.reduce((i,s)=>i<<8n|BigInt(s),0n);if(r&&(n=-1n-n),t.requirePreferred&&n>=Number.MIN_SAFE_INTEGER&&n<=Number.MAX_SAFE_INTEGER)throw new Error(`Decoding bigint that could have been int: ${n}n`);return t.boxed?Ys(n,e.contents):n}const y0=mc.bind(null,!1),g0=mc.bind(null,!0);y0.comment=(r,e)=>`(Positive BigInt) ${mc(!1,r,e)}n`,g0.comment=(r,e)=>`(Negative BigInt) ${mc(!0,r,e)}n`,We.registerDecoder(Et.POS_BIGINT,y0),We.registerDecoder(Et.NEG_BIGINT,g0);function df(r,e){return Si(r.contents),r}df.comment=(r,e,t)=>{Si(r.contents);const n={...e,initialDepth:t+2,noPrefixHex:!0},i=dc(r);let s=2**((i[0]&31)-24)+1;const o=i[s]&31;let c=Gr(i.subarray(s,++s));o>=24&&(c+=" ",c+=Gr(i.subarray(s,s+2**(o-24)))),n.minCol=Math.max(n.minCol,(t+1)*2+c.length);const u=lm(r.contents,n);let h=`Embedded CBOR
123
123
  `;return h+=`${"".padStart((t+1)*2," ")}${c}`.padEnd(n.minCol+1," "),h+=`-- Bytes (Length: ${r.contents.length})
124
- `,h+=u,h},df.noChildren=!0,Ze.registerDecoder(St.CBOR,df),Ze.registerDecoder(St.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Nt(URL,r=>[St.URI,r.toString()]),Ze.registerDecoder(St.BASE64URL,r=>(Gn(r.contents),Vv(r.contents)),"Base64url-encoded"),Ze.registerDecoder(St.BASE64,r=>(Gn(r.contents),af(r.contents)),"Base64-encoded"),Ze.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),Ze.registerDecoder(21065,r=>{Gn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
125
- \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),Ze.registerDecoder(St.REGEXP,r=>{if(h0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Nt(RegExp,r=>[St.REGEXP,[r.source,r.flags]]),Ze.registerDecoder(64,r=>(Si(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){Si(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function Kn(r,e,t,n,i){const s=i.forceEndian??u0;if(yc(s?e:t,r,i),Kr(n.byteLength,r,ve.BYTE_STRING),u0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}Ze.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),Ze.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),Ze.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),Ze.registerDecoder(68,r=>(Si(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Nt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Ze.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Nt(Uint16Array,(r,e,t)=>Kn(e,69,65,r,t)),Ze.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Nt(Uint32Array,(r,e,t)=>Kn(e,70,66,r,t)),Ze.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Nt(BigUint64Array,(r,e,t)=>Kn(e,71,67,r,t)),Ze.registerDecoder(72,r=>(Si(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Nt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),Ze.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),Ze.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),Ze.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),Ze.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Nt(Int16Array,(r,e,t)=>Kn(e,77,73,r,t)),Ze.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Nt(Int32Array,(r,e,t)=>Kn(e,78,74,r,t)),Ze.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Nt(BigInt64Array,(r,e,t)=>Kn(e,79,75,r,t)),Ze.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Ze.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Ze.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Nt(Float32Array,(r,e,t)=>Kn(e,85,81,r,t)),Ze.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Nt(Float64Array,(r,e,t)=>Kn(e,86,82,r,t)),Ze.registerDecoder(St.SET,r=>(h0(r.contents),new Set(r.contents)),"Set"),Nt(Set,r=>[St.SET,[...r]]),Ze.registerDecoder(St.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),Ze.registerDecoder(St.SELF_DESCRIBED,r=>r.contents,"Self-Described"),Ze.registerDecoder(St.INVALID_16,()=>{throw new Error(`Tag always invalid: ${St.INVALID_16}`)},"Invalid"),Ze.registerDecoder(St.INVALID_32,()=>{throw new Error(`Tag always invalid: ${St.INVALID_32}`)},"Invalid"),Ze.registerDecoder(St.INVALID_64,()=>{throw new Error(`Tag always invalid: ${St.INVALID_64}`)},"Invalid");function pf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Nt(ArrayBuffer,pf),Nt(DataView,pf),typeof SharedArrayBuffer<"u"&&Nt(SharedArrayBuffer,pf);function wc(r){return[NaN,r.valueOf()]}Nt(Boolean,wc),Nt(Number,wc),Nt(String,wc),Nt(BigInt,wc);function bc(r,e={}){const t={...zn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,zn.dcborDecodeOptions):e.cde&&Object.assign(t,zn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new Xs(r,t);let i,s;for(const o of n){if(s=zn.create(o,i,t,n),o[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof zn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var rt;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(rt||(rt={}));var yf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yf||(yf={}));const oe=rt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qn=r=>{switch(typeof r){case"undefined":return oe.undefined;case"string":return oe.string;case"number":return isNaN(r)?oe.nan:oe.number;case"boolean":return oe.boolean;case"function":return oe.function;case"bigint":return oe.bigint;case"symbol":return oe.symbol;case"object":return Array.isArray(r)?oe.array:r===null?oe.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?oe.promise:typeof Map<"u"&&r instanceof Map?oe.map:typeof Set<"u"&&r instanceof Set?oe.set:typeof Date<"u"&&r instanceof Date?oe.date:oe.object;default:return oe.unknown}},F=rt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),um=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const is=(r,e)=>{let t;switch(r.code){case F.invalid_type:r.received===oe.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case F.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,rt.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:t=`Unrecognized key(s) in object: ${rt.joinValues(r.keys,", ")}`;break;case F.invalid_union:t="Invalid input";break;case F.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${rt.joinValues(r.options)}`;break;case F.invalid_enum_value:t=`Invalid enum value. Expected ${rt.joinValues(r.options)}, received '${r.received}'`;break;case F.invalid_arguments:t="Invalid function arguments";break;case F.invalid_return_type:t="Invalid function return type";break;case F.invalid_date:t="Invalid date";break;case F.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:rt.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case F.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case F.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case F.custom:t="Invalid input";break;case F.invalid_intersection_types:t="Intersection results could not be merged";break;case F.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case F.not_finite:t="Number must be finite";break;default:t=e.defaultError,rt.assertNever(r)}return{message:t}};let v0=is;function fm(r){v0=r}function xc(){return v0}const Ac=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},hm=[];function X(r,e){const t=xc(),n=Ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class ir{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return ke;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return ir.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ke;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const ke=Object.freeze({status:"aborted"}),ss=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),gf=r=>r.status==="aborted",vf=r=>r.status==="dirty",Qs=r=>r.status==="valid",eo=r=>typeof Promise<"u"&&r instanceof Promise;function Sc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function m0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ae;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Ae||(Ae={}));var to,ro;class an{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const w0=(r,e)=>{if(Qs(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function $e(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,h;const{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=m??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ge{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return qn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(eo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:qn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return w0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:qn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eo(i)?i:Promise.resolve(i));return w0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:F.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Wr({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ln.create(this,this._def)}nullable(){return Jn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zr.create(this,this._def)}promise(){return ls.create(this,this._def)}or(e){return oo.create([this,e],this._def)}and(e){return ao.create(this,e,this._def)}transform(e){return new Wr({...$e(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ho({...$e(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new bf({typeName:Ee.ZodBranded,type:this,...$e(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new po({...$e(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return yo.create(this,e)}readonly(){return go.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dm=/^c[^\s-]{8,}$/i,pm=/^[0-9a-z]+$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,gm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,vm=/^[a-z0-9_-]{21}$/i,mm=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,wm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mf;const xm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Am=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Sm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_m=new RegExp(`^${b0}$`);function x0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Em(r){return new RegExp(`^${x0(r)}$`)}function A0(r){let e=`${b0}T${x0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Im(r,e){return!!((e==="v4"||!e)&&xm.test(r)||(e==="v6"||!e)&&Am.test(r))}class qr extends Ge{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==oe.string){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:oe.string,received:s.parsedType}),ke}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")wm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"email",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mf||(mf=new RegExp(bm,"u")),mf.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"emoji",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")gm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"uuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"nanoid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")dm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")pm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid2",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ulid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),X(i,{validation:"url",code:F.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"regex",code:F.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?A0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_m.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Em(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?mm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"duration",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Im(e.data,s.version)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ip",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Sm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"base64",code:F.invalid_string,message:s.message}),n.dirty()):rt.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:F.invalid_string,...Ae.errToObj(n)})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ae.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ae.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ae.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ae.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ae.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ae.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ae.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ae.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ae.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ae.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Ae.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Ae.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Ae.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ae.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Ae.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ae.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ae.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ae.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ae.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ae.errToObj(t)})}nonempty(e){return this.min(1,Ae.errToObj(e))}trim(){return new qr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qr.create=r=>{var e;return new qr({checks:[],typeName:Ee.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...$e(r)})};function km(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class Zn extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==oe.number){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:oe.number,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?rt.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?km(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_finite,message:s.message}),i.dirty()):rt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ae.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ae.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ae.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ae.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ae.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ae.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ae.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&rt.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Zn.create=r=>new Zn({checks:[],typeName:Ee.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...$e(r)});class Wn extends Ge{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==oe.bigint){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:oe.bigint,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):rt.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ae.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ae.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ae.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ae.toString(t))}setLimit(e,t,n,i){return new Wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Ae.toString(i)}]})}_addCheck(e){return new Wn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ae.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ae.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ae.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ae.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ae.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Wn.create=r=>{var e;return new Wn({checks:[],typeName:Ee.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...$e(r)})};class no extends Ge{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==oe.boolean){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.boolean,received:n.parsedType}),ke}return hr(e.data)}}no.create=r=>new no({typeName:Ee.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...$e(r)});class _i extends Ge{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==oe.date){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:oe.date,received:s.parsedType}),ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_date}),ke}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):rt.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _i({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ae.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ae.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}_i.create=r=>new _i({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ee.ZodDate,...$e(r)});class _c extends Ge{_parse(e){if(this._getType(e)!==oe.symbol){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.symbol,received:n.parsedType}),ke}return hr(e.data)}}_c.create=r=>new _c({typeName:Ee.ZodSymbol,...$e(r)});class io extends Ge{_parse(e){if(this._getType(e)!==oe.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.undefined,received:n.parsedType}),ke}return hr(e.data)}}io.create=r=>new io({typeName:Ee.ZodUndefined,...$e(r)});class so extends Ge{_parse(e){if(this._getType(e)!==oe.null){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.null,received:n.parsedType}),ke}return hr(e.data)}}so.create=r=>new so({typeName:Ee.ZodNull,...$e(r)});class os extends Ge{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}os.create=r=>new os({typeName:Ee.ZodAny,...$e(r)});class Ei extends Ge{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Ei.create=r=>new Ei({typeName:Ee.ZodUnknown,...$e(r)});class Bn extends Ge{_parse(e){const t=this._getOrReturnCtx(e);return X(t,{code:F.invalid_type,expected:oe.never,received:t.parsedType}),ke}}Bn.create=r=>new Bn({typeName:Ee.ZodNever,...$e(r)});class Ec extends Ge{_parse(e){if(this._getType(e)!==oe.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.void,received:n.parsedType}),ke}return hr(e.data)}}Ec.create=r=>new Ec({typeName:Ee.ZodVoid,...$e(r)});class Zr extends Ge{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==oe.array)return X(t,{code:F.invalid_type,expected:oe.array,received:t.parsedType}),ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(X(t,{code:o?F.too_big:F.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(X(t,{code:F.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(X(t,{code:F.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new an(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new an(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Zr({...this._def,minLength:{value:e,message:Ae.toString(t)}})}max(e,t){return new Zr({...this._def,maxLength:{value:e,message:Ae.toString(t)}})}length(e,t){return new Zr({...this._def,exactLength:{value:e,message:Ae.toString(t)}})}nonempty(e){return this.min(1,e)}}Zr.create=(r,e)=>new Zr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...$e(e)});function as(r){if(r instanceof kt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ln.create(as(n))}return new kt({...r._def,shape:()=>e})}else return r instanceof Zr?new Zr({...r._def,type:as(r.element)}):r instanceof ln?ln.create(as(r.unwrap())):r instanceof Jn?Jn.create(as(r.unwrap())):r instanceof cn?cn.create(r.items.map(e=>as(e))):r}class kt extends Ge{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=rt.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==oe.object){const h=this._getOrReturnCtx(e);return X(h,{code:F.invalid_type,expected:oe.object,received:h.parsedType}),ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Bn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const m=s[h],x=i.data[h];u.push({key:{status:"valid",value:h},value:m._parse(new an(i,x,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Bn){const h=this._def.unknownKeys;if(h==="passthrough")for(const m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(h==="strict")c.length>0&&(X(i,{code:F.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const m of c){const x=i.data[m];u.push({key:{status:"valid",value:m},value:h._parse(new an(i,x,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const m of u){const x=await m.key,G=await m.value;h.push({key:x,value:G,alwaysSet:m.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Ae.errToObj,new kt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=Ae.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new kt({...this._def,unknownKeys:"strip"})}passthrough(){return new kt({...this._def,unknownKeys:"passthrough"})}extend(e){return new kt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new kt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new kt({...this._def,catchall:e})}pick(e){const t={};return rt.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new kt({...this._def,shape:()=>t})}omit(e){const t={};return rt.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new kt({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return rt.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new kt({...this._def,shape:()=>t})}required(e){const t={};return rt.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ln;)s=s._def.innerType;t[n]=s}}),new kt({...this._def,shape:()=>t})}keyof(){return S0(rt.objectKeys(this.shape))}}kt.create=(r,e)=>new kt({shape:()=>r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...$e(e)}),kt.strictCreate=(r,e)=>new kt({shape:()=>r,unknownKeys:"strict",catchall:Bn.create(),typeName:Ee.ZodObject,...$e(e)}),kt.lazycreate=(r,e)=>new kt({shape:r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...$e(e)});class oo extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return X(t,{code:F.invalid_union,unionErrors:o}),ke}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const h={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:h});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return X(t,{code:F.invalid_union,unionErrors:c}),ke}}get options(){return this._def.options}}oo.create=(r,e)=>new oo({options:r,typeName:Ee.ZodUnion,...$e(e)});const On=r=>r instanceof lo?On(r.schema):r instanceof Wr?On(r.innerType()):r instanceof uo?[r.value]:r instanceof Yn?r.options:r instanceof fo?rt.objectValues(r.enum):r instanceof ho?On(r._def.innerType):r instanceof io?[void 0]:r instanceof so?[null]:r instanceof ln?[void 0,...On(r.unwrap())]:r instanceof Jn?[null,...On(r.unwrap())]:r instanceof bf||r instanceof go?On(r.unwrap()):r instanceof po?On(r._def.innerType):[];class Ic extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==oe.object)return X(t,{code:F.invalid_type,expected:oe.object,received:t.parsedType}),ke;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(X(t,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=On(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Ic({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...$e(n)})}}function wf(r,e){const t=qn(r),n=qn(e);if(r===e)return{valid:!0,data:r};if(t===oe.object&&n===oe.object){const i=rt.objectKeys(e),s=rt.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=wf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===oe.array&&n===oe.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=wf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===oe.date&&n===oe.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ao extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(gf(s)||gf(o))return ke;const c=wf(s.value,o.value);return c.valid?((vf(s)||vf(o))&&t.dirty(),{status:t.value,value:c.data}):(X(n,{code:F.invalid_intersection_types}),ke)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ao.create=(r,e,t)=>new ao({left:r,right:e,typeName:Ee.ZodIntersection,...$e(t)});class cn extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==oe.array)return X(n,{code:F.invalid_type,expected:oe.array,received:n.parsedType}),ke;if(n.data.length<this._def.items.length)return X(n,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new an(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new cn({...this._def,rest:e})}}cn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new cn({items:r,typeName:Ee.ZodTuple,rest:null,...$e(e)})};class co extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==oe.object)return X(n,{code:F.invalid_type,expected:oe.object,received:n.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new an(n,c,n.path,c)),value:o._parse(new an(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ge?new co({keyType:e,valueType:t,typeName:Ee.ZodRecord,...$e(n)}):new co({keyType:qr.create(),valueType:e,typeName:Ee.ZodRecord,...$e(t)})}}class kc extends Ge{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==oe.map)return X(n,{code:F.invalid_type,expected:oe.map,received:n.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new an(n,c,n.path,[h,"key"])),value:s._parse(new an(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,m=await u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,m=u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}}}}kc.create=(r,e,t)=>new kc({valueType:e,keyType:r,typeName:Ee.ZodMap,...$e(t)});class Ii extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==oe.set)return X(n,{code:F.invalid_type,expected:oe.set,received:n.parsedType}),ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(X(n,{code:F.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(X(n,{code:F.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const h=new Set;for(const m of u){if(m.status==="aborted")return ke;m.status==="dirty"&&t.dirty(),h.add(m.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new an(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Ii({...this._def,minSize:{value:e,message:Ae.toString(t)}})}max(e,t){return new Ii({...this._def,maxSize:{value:e,message:Ae.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ii.create=(r,e)=>new Ii({valueType:r,minSize:null,maxSize:null,typeName:Ee.ZodSet,...$e(e)});class cs extends Ge{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==oe.function)return X(t,{code:F.invalid_type,expected:oe.function,received:t.parsedType}),ke;function n(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_arguments,argumentsError:u}})}function i(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ls){const c=this;return hr(async function(...u){const h=new kr([]),m=await c._def.args.parseAsync(u,s).catch(N=>{throw h.addIssue(n(u,N)),h}),x=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(x,s).catch(N=>{throw h.addIssue(i(x,N)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const m=Reflect.apply(o,this,h.data),x=c._def.returns.safeParse(m,s);if(!x.success)throw new kr([i(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cs({...this._def,args:cn.create(e).rest(Ei.create())})}returns(e){return new cs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cs({args:e||cn.create([]).rest(Ei.create()),returns:t||Ei.create(),typeName:Ee.ZodFunction,...$e(n)})}}class lo extends Ge{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}lo.create=(r,e)=>new lo({getter:r,typeName:Ee.ZodLazy,...$e(e)});class uo extends Ge{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:F.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}uo.create=(r,e)=>new uo({value:r,typeName:Ee.ZodLiteral,...$e(e)});function S0(r,e){return new Yn({values:r,typeName:Ee.ZodEnum,...$e(e)})}class Yn extends Ge{constructor(){super(...arguments),to.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:rt.joinValues(n),received:t.parsedType,code:F.invalid_type}),ke}if(Sc(this,to)||m0(this,to,new Set(this._def.values)),!Sc(this,to).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:F.invalid_enum_value,options:n}),ke}return hr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Yn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Yn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}to=new WeakMap,Yn.create=S0;class fo extends Ge{constructor(){super(...arguments),ro.set(this,void 0)}_parse(e){const t=rt.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==oe.string&&n.parsedType!==oe.number){const i=rt.objectValues(t);return X(n,{expected:rt.joinValues(i),received:n.parsedType,code:F.invalid_type}),ke}if(Sc(this,ro)||m0(this,ro,new Set(rt.getValidEnumValues(this._def.values))),!Sc(this,ro).has(e.data)){const i=rt.objectValues(t);return X(n,{received:n.data,code:F.invalid_enum_value,options:i}),ke}return hr(e.data)}get enum(){return this._def.values}}ro=new WeakMap,fo.create=(r,e)=>new fo({values:r,typeName:Ee.ZodNativeEnum,...$e(e)});class ls extends Ge{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==oe.promise&&t.common.async===!1)return X(t,{code:F.invalid_type,expected:oe.promise,received:t.parsedType}),ke;const n=t.parsedType===oe.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ls.create=(r,e)=>new ls({type:r,typeName:Ee.ZodPromise,...$e(e)});class Wr extends Ge{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{X(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return ke;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ke:u.status==="dirty"||t.value==="dirty"?ss(u.value):u});{if(t.value==="aborted")return ke;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ke:c.status==="dirty"||t.value==="dirty"?ss(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?ke:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?ke:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Qs(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Qs(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);rt.assertNever(i)}}Wr.create=(r,e,t)=>new Wr({schema:r,typeName:Ee.ZodEffects,effect:e,...$e(t)}),Wr.createWithPreprocess=(r,e,t)=>new Wr({schema:e,effect:{type:"preprocess",transform:r},typeName:Ee.ZodEffects,...$e(t)});class ln extends Ge{_parse(e){return this._getType(e)===oe.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:Ee.ZodOptional,...$e(e)});class Jn extends Ge{_parse(e){return this._getType(e)===oe.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jn.create=(r,e)=>new Jn({innerType:r,typeName:Ee.ZodNullable,...$e(e)});class ho extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===oe.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ho.create=(r,e)=>new ho({innerType:r,typeName:Ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$e(e)});class po extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return eo(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:Ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$e(e)});class Cc extends Ge{_parse(e){if(this._getType(e)!==oe.nan){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:oe.nan,received:n.parsedType}),ke}return{status:"valid",value:e.data}}}Cc.create=r=>new Cc({typeName:Ee.ZodNaN,...$e(r)});const Cm=Symbol("zod_brand");class bf extends Ge{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class yo extends Ge{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ke:s.status==="dirty"?(t.dirty(),ss(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ke:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new yo({in:e,out:t,typeName:Ee.ZodPipeline})}}class go extends Ge{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Qs(i)&&(i.value=Object.freeze(i.value)),i);return eo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}go.create=(r,e)=>new go({innerType:r,typeName:Ee.ZodReadonly,...$e(e)});function _0(r,e={},t){return r?os.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):os.create()}const Bm={object:kt.lazycreate};var Ee;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Ee||(Ee={}));const Om=(r,e={message:`Input not instance of ${r.name}`})=>_0(t=>t instanceof r,e),E0=qr.create,I0=Zn.create,Tm=Cc.create,Nm=Wn.create,k0=no.create,jm=_i.create,Pm=_c.create,Rm=io.create,Um=so.create,Dm=os.create,$m=Ei.create,Mm=Bn.create,Vm=Ec.create,Lm=Zr.create,Hm=kt.create,Fm=kt.strictCreate,zm=oo.create,Gm=Ic.create,Km=ao.create,qm=cn.create,Zm=co.create,Wm=kc.create,Ym=Ii.create,Jm=cs.create,Xm=lo.create,Qm=uo.create,e1=Yn.create,t1=fo.create,r1=ls.create,C0=Wr.create,n1=ln.create,i1=Jn.create,s1=Wr.createWithPreprocess,o1=yo.create;var Ct=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:fm,getErrorMap:xc,makeIssue:Ac,EMPTY_PATH:hm,addIssueToContext:X,ParseStatus:ir,INVALID:ke,DIRTY:ss,OK:hr,isAborted:gf,isDirty:vf,isValid:Qs,isAsync:eo,get util(){return rt},get objectUtil(){return yf},ZodParsedType:oe,getParsedType:qn,ZodType:Ge,datetimeRegex:A0,ZodString:qr,ZodNumber:Zn,ZodBigInt:Wn,ZodBoolean:no,ZodDate:_i,ZodSymbol:_c,ZodUndefined:io,ZodNull:so,ZodAny:os,ZodUnknown:Ei,ZodNever:Bn,ZodVoid:Ec,ZodArray:Zr,ZodObject:kt,ZodUnion:oo,ZodDiscriminatedUnion:Ic,ZodIntersection:ao,ZodTuple:cn,ZodRecord:co,ZodMap:kc,ZodSet:Ii,ZodFunction:cs,ZodLazy:lo,ZodLiteral:uo,ZodEnum:Yn,ZodNativeEnum:fo,ZodPromise:ls,ZodEffects:Wr,ZodTransformer:Wr,ZodOptional:ln,ZodNullable:Jn,ZodDefault:ho,ZodCatch:po,ZodNaN:Cc,BRAND:Cm,ZodBranded:bf,ZodPipeline:yo,ZodReadonly:go,custom:_0,Schema:Ge,ZodSchema:Ge,late:Bm,get ZodFirstPartyTypeKind(){return Ee},coerce:{string:r=>qr.create({...r,coerce:!0}),number:r=>Zn.create({...r,coerce:!0}),boolean:r=>no.create({...r,coerce:!0}),bigint:r=>Wn.create({...r,coerce:!0}),date:r=>_i.create({...r,coerce:!0})},any:Dm,array:Lm,bigint:Nm,boolean:k0,date:jm,discriminatedUnion:Gm,effect:C0,enum:e1,function:Jm,instanceof:Om,intersection:Km,lazy:Xm,literal:Qm,map:Wm,nan:Tm,nativeEnum:t1,never:Mm,null:Um,nullable:i1,number:I0,object:Hm,oboolean:()=>k0().optional(),onumber:()=>I0().optional(),optional:n1,ostring:()=>E0().optional(),pipeline:o1,preprocess:s1,promise:r1,record:Zm,set:Ym,strictObject:Fm,string:E0,symbol:Pm,transformer:C0,tuple:qm,undefined:Rm,union:zm,unknown:$m,void:Vm,NEVER:ke,ZodIssueCode:F,quotelessJson:um,ZodError:kr});const Bc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Bc||Bc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const a1=Ct.object({module_id:Ct.string().min(1),digest:Ct.literal("SHA384"),timestamp:Ct.number().min(1677721600),pcrs:Ct.map(Ct.number(),Ct.instanceof(Uint8Array)),certificate:Ct.instanceof(Uint8Array),cabundle:Ct.array(Ct.instanceof(Uint8Array)),public_key:Ct.nullable(Ct.instanceof(Uint8Array)),user_data:Ct.nullable(Ct.instanceof(Uint8Array)),nonce:Ct.nullable(Ct.instanceof(Uint8Array))}),c1=Ct.object({protected:Ct.instanceof(Uint8Array),payload:Ct.instanceof(Uint8Array),signature:Ct.instanceof(Uint8Array)});async function l1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=gs(r),t=bc(e),n=t[0],i=t[2],s=t[3];return c1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function u1(r){try{const e=bc(r);return a1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function f1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return gc(t)}async function h1(r,e){try{console.log("SIGNATURE:"),console.log($r(r.signature));const t=f1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log($r(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function ki(r,e,t){try{const n=await l1(r),i=await u1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=$r(i.cabundle[0]);if(u!==$r(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",$r(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const j=new xi(i.cabundle[I]);c.push(j)}const h=new xi(i.certificate),x=await new Uv({certificates:c}).build(h);console.log("Chain items:",x);const N=new Date().getTime();for(let I=0;I<x.length;I++){const j=x[I];if(console.log("CERT: ",I),console.log(j.subject),console.log("Not before:",j.notBefore),console.log("Not after:",j.notAfter),console.log(j.toString("pem")),j.notBefore.getTime()>N||j.notAfter.getTime()<N)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(x.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const v=h.publicKey;console.log("PUBLIC KEY:"),console.log($r(new Uint8Array(v.rawData)));const A=await v.export(),O=await h1(n,A);if(console.log("Signature verified:",O),!O)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const d1=Ct.object({public_key:Ct.nullable(Ct.instanceof(Uint8Array))});async function p1(r){const e=gs(r),n=bc(e)[2],i=bc(n);return await d1.parse(i)}async function y1(r,e){try{const t=await R1(r,e),n=e||C1();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await p1(t)):await ki(t,Bc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function g1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var B0={exports:{}};const v1=Hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),x=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),G=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),N=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function O(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function j(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,ee=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,at=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,ue=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Me=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Ue=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,ie=E,ge=U,we=z,J=be,C=ee,B=at,V=ue,P=Ce,D=Be,L=Me,_e=Ue,Ve=Oe,ze=Ne,Le=Te,w,We=0;We<20;We+=2)w=pe+_e|0,we^=w<<7|w>>>25,w=we+pe|0,V^=w<<9|w>>>23,w=V+we|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,P^=w<<7|w>>>25,w=P+J|0,Ve^=w<<9|w>>>23,w=Ve+P|0,Se^=w<<13|w>>>19,w=Se+Ve|0,J^=w<<18|w>>>14,w=D+C|0,ze^=w<<7|w>>>25,w=ze+D|0,ie^=w<<9|w>>>23,w=ie+ze|0,C^=w<<13|w>>>19,w=C+ie|0,D^=w<<18|w>>>14,w=Le+L|0,ge^=w<<7|w>>>25,w=ge+Le|0,B^=w<<9|w>>>23,w=B+ge|0,L^=w<<13|w>>>19,w=L+B|0,Le^=w<<18|w>>>14,w=pe+ge|0,Se^=w<<7|w>>>25,w=Se+pe|0,ie^=w<<9|w>>>23,w=ie+Se|0,ge^=w<<13|w>>>19,w=ge+ie|0,pe^=w<<18|w>>>14,w=J+we|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,we^=w<<13|w>>>19,w=we+B|0,J^=w<<18|w>>>14,w=D+P|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,P^=w<<13|w>>>19,w=P+V|0,D^=w<<18|w>>>14,w=Le+ze|0,_e^=w<<7|w>>>25,w=_e+Le|0,Ve^=w<<9|w>>>23,w=Ve+_e|0,ze^=w<<13|w>>>19,w=ze+Ve|0,Le^=w<<18|w>>>14;pe=pe+g|0,Se=Se+S|0,ie=ie+E|0,ge=ge+U|0,we=we+z|0,J=J+be|0,C=C+ee|0,B=B+at|0,V=V+ue|0,P=P+Ce|0,D=D+Be|0,L=L+Me|0,_e=_e+Ue|0,Ve=Ve+Oe|0,ze=ze+Ne|0,Le=Le+Te|0,l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=Se>>>0&255,l[5]=Se>>>8&255,l[6]=Se>>>16&255,l[7]=Se>>>24&255,l[8]=ie>>>0&255,l[9]=ie>>>8&255,l[10]=ie>>>16&255,l[11]=ie>>>24&255,l[12]=ge>>>0&255,l[13]=ge>>>8&255,l[14]=ge>>>16&255,l[15]=ge>>>24&255,l[16]=we>>>0&255,l[17]=we>>>8&255,l[18]=we>>>16&255,l[19]=we>>>24&255,l[20]=J>>>0&255,l[21]=J>>>8&255,l[22]=J>>>16&255,l[23]=J>>>24&255,l[24]=C>>>0&255,l[25]=C>>>8&255,l[26]=C>>>16&255,l[27]=C>>>24&255,l[28]=B>>>0&255,l[29]=B>>>8&255,l[30]=B>>>16&255,l[31]=B>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=P>>>0&255,l[37]=P>>>8&255,l[38]=P>>>16&255,l[39]=P>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=_e>>>0&255,l[49]=_e>>>8&255,l[50]=_e>>>16&255,l[51]=_e>>>24&255,l[52]=Ve>>>0&255,l[53]=Ve>>>8&255,l[54]=Ve>>>16&255,l[55]=Ve>>>24&255,l[56]=ze>>>0&255,l[57]=ze>>>8&255,l[58]=ze>>>16&255,l[59]=ze>>>24&255,l[60]=Le>>>0&255,l[61]=Le>>>8&255,l[62]=Le>>>16&255,l[63]=Le>>>24&255}function R(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,be=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,ee=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,at=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,ue=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Me=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,Ue=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,ie=E,ge=U,we=z,J=be,C=ee,B=at,V=ue,P=Ce,D=Be,L=Me,_e=Ue,Ve=Oe,ze=Ne,Le=Te,w,We=0;We<20;We+=2)w=pe+_e|0,we^=w<<7|w>>>25,w=we+pe|0,V^=w<<9|w>>>23,w=V+we|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,P^=w<<7|w>>>25,w=P+J|0,Ve^=w<<9|w>>>23,w=Ve+P|0,Se^=w<<13|w>>>19,w=Se+Ve|0,J^=w<<18|w>>>14,w=D+C|0,ze^=w<<7|w>>>25,w=ze+D|0,ie^=w<<9|w>>>23,w=ie+ze|0,C^=w<<13|w>>>19,w=C+ie|0,D^=w<<18|w>>>14,w=Le+L|0,ge^=w<<7|w>>>25,w=ge+Le|0,B^=w<<9|w>>>23,w=B+ge|0,L^=w<<13|w>>>19,w=L+B|0,Le^=w<<18|w>>>14,w=pe+ge|0,Se^=w<<7|w>>>25,w=Se+pe|0,ie^=w<<9|w>>>23,w=ie+Se|0,ge^=w<<13|w>>>19,w=ge+ie|0,pe^=w<<18|w>>>14,w=J+we|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,we^=w<<13|w>>>19,w=we+B|0,J^=w<<18|w>>>14,w=D+P|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,P^=w<<13|w>>>19,w=P+V|0,D^=w<<18|w>>>14,w=Le+ze|0,_e^=w<<7|w>>>25,w=_e+Le|0,Ve^=w<<9|w>>>23,w=Ve+_e|0,ze^=w<<13|w>>>19,w=ze+Ve|0,Le^=w<<18|w>>>14;l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=J>>>0&255,l[5]=J>>>8&255,l[6]=J>>>16&255,l[7]=J>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=Le>>>0&255,l[13]=Le>>>8&255,l[14]=Le>>>16&255,l[15]=Le>>>24&255,l[16]=C>>>0&255,l[17]=C>>>8&255,l[18]=C>>>16&255,l[19]=C>>>24&255,l[20]=B>>>0&255,l[21]=B>>>8&255,l[22]=B>>>16&255,l[23]=B>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=P>>>0&255,l[29]=P>>>8&255,l[30]=P>>>16&255,l[31]=P>>>24&255}function le(l,p,d,a){j(l,p,d,a)}function Q(l,p,d,a){R(l,p,d,a)}var re=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Y(l,p,d,a,g,S,E){var U=new Uint8Array(16),z=new Uint8Array(64),be,ee;for(ee=0;ee<16;ee++)U[ee]=0;for(ee=0;ee<8;ee++)U[ee]=S[ee];for(;g>=64;){for(le(z,U,E,re),ee=0;ee<64;ee++)l[p+ee]=d[a+ee]^z[ee];for(be=1,ee=8;ee<16;ee++)be=be+(U[ee]&255)|0,U[ee]=be&255,be>>>=8;g-=64,p+=64,a+=64}if(g>0)for(le(z,U,E,re),ee=0;ee<g;ee++)l[p+ee]=d[a+ee]^z[ee];return 0}function ye(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),U,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(le(E,S,g,re),z=0;z<64;z++)l[p+z]=E[z];for(U=1,z=8;z<16;z++)U=U+(S[z]&255)|0,S[z]=U&255,U>>>=8;d-=64,p+=64}if(d>0)for(le(E,S,g,re),z=0;z<d;z++)l[p+z]=E[z];return 0}function Ke(l,p,d,a,g){var S=new Uint8Array(32);Q(S,a,g,re);for(var E=new Uint8Array(8),U=0;U<8;U++)E[U]=a[U+16];return ye(l,p,d,E,S)}function dt(l,p,d,a,g,S,E){var U=new Uint8Array(32);Q(U,S,E,re);for(var z=new Uint8Array(8),be=0;be<8;be++)z[be]=S[be+16];return Y(l,p,d,a,g,z,U)}var Bt=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,S,E,U,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,U=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|U<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(U>>>8|z<<8)&8191,this.r[9]=z>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};Bt.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,U,z,be,ee,at,ue,Ce,Be,Me,Ue,Oe,Ne,Te,pe,Se,ie,ge=this.h[0],we=this.h[1],J=this.h[2],C=this.h[3],B=this.h[4],V=this.h[5],P=this.h[6],D=this.h[7],L=this.h[8],_e=this.h[9],Ve=this.r[0],ze=this.r[1],Le=this.r[2],w=this.r[3],We=this.r[4],ct=this.r[5],lt=this.r[6],qe=this.r[7],st=this.r[8],ot=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,ge+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,we+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,J+=(S>>>10|E<<6)&8191,U=l[p+6]&255|(l[p+7]&255)<<8,C+=(E>>>7|U<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,B+=(U>>>4|z<<12)&8191,V+=z>>>1&8191,be=l[p+10]&255|(l[p+11]&255)<<8,P+=(z>>>14|be<<2)&8191,ee=l[p+12]&255|(l[p+13]&255)<<8,D+=(be>>>11|ee<<5)&8191,at=l[p+14]&255|(l[p+15]&255)<<8,L+=(ee>>>8|at<<8)&8191,_e+=at>>>5|a,ue=0,Ce=ue,Ce+=ge*Ve,Ce+=we*(5*ot),Ce+=J*(5*st),Ce+=C*(5*qe),Ce+=B*(5*lt),ue=Ce>>>13,Ce&=8191,Ce+=V*(5*ct),Ce+=P*(5*We),Ce+=D*(5*w),Ce+=L*(5*Le),Ce+=_e*(5*ze),ue+=Ce>>>13,Ce&=8191,Be=ue,Be+=ge*ze,Be+=we*Ve,Be+=J*(5*ot),Be+=C*(5*st),Be+=B*(5*qe),ue=Be>>>13,Be&=8191,Be+=V*(5*lt),Be+=P*(5*ct),Be+=D*(5*We),Be+=L*(5*w),Be+=_e*(5*Le),ue+=Be>>>13,Be&=8191,Me=ue,Me+=ge*Le,Me+=we*ze,Me+=J*Ve,Me+=C*(5*ot),Me+=B*(5*st),ue=Me>>>13,Me&=8191,Me+=V*(5*qe),Me+=P*(5*lt),Me+=D*(5*ct),Me+=L*(5*We),Me+=_e*(5*w),ue+=Me>>>13,Me&=8191,Ue=ue,Ue+=ge*w,Ue+=we*Le,Ue+=J*ze,Ue+=C*Ve,Ue+=B*(5*ot),ue=Ue>>>13,Ue&=8191,Ue+=V*(5*st),Ue+=P*(5*qe),Ue+=D*(5*lt),Ue+=L*(5*ct),Ue+=_e*(5*We),ue+=Ue>>>13,Ue&=8191,Oe=ue,Oe+=ge*We,Oe+=we*w,Oe+=J*Le,Oe+=C*ze,Oe+=B*Ve,ue=Oe>>>13,Oe&=8191,Oe+=V*(5*ot),Oe+=P*(5*st),Oe+=D*(5*qe),Oe+=L*(5*lt),Oe+=_e*(5*ct),ue+=Oe>>>13,Oe&=8191,Ne=ue,Ne+=ge*ct,Ne+=we*We,Ne+=J*w,Ne+=C*Le,Ne+=B*ze,ue=Ne>>>13,Ne&=8191,Ne+=V*Ve,Ne+=P*(5*ot),Ne+=D*(5*st),Ne+=L*(5*qe),Ne+=_e*(5*lt),ue+=Ne>>>13,Ne&=8191,Te=ue,Te+=ge*lt,Te+=we*ct,Te+=J*We,Te+=C*w,Te+=B*Le,ue=Te>>>13,Te&=8191,Te+=V*ze,Te+=P*Ve,Te+=D*(5*ot),Te+=L*(5*st),Te+=_e*(5*qe),ue+=Te>>>13,Te&=8191,pe=ue,pe+=ge*qe,pe+=we*lt,pe+=J*ct,pe+=C*We,pe+=B*w,ue=pe>>>13,pe&=8191,pe+=V*Le,pe+=P*ze,pe+=D*Ve,pe+=L*(5*ot),pe+=_e*(5*st),ue+=pe>>>13,pe&=8191,Se=ue,Se+=ge*st,Se+=we*qe,Se+=J*lt,Se+=C*ct,Se+=B*We,ue=Se>>>13,Se&=8191,Se+=V*w,Se+=P*Le,Se+=D*ze,Se+=L*Ve,Se+=_e*(5*ot),ue+=Se>>>13,Se&=8191,ie=ue,ie+=ge*ot,ie+=we*st,ie+=J*qe,ie+=C*lt,ie+=B*ct,ue=ie>>>13,ie&=8191,ie+=V*We,ie+=P*w,ie+=D*Le,ie+=L*ze,ie+=_e*Ve,ue+=ie>>>13,ie&=8191,ue=(ue<<2)+ue|0,ue=ue+Ce|0,Ce=ue&8191,ue=ue>>>13,Be+=ue,ge=Ce,we=Be,J=Me,C=Ue,B=Oe,V=Ne,P=Te,D=pe,L=Se,_e=ie,p+=16,d-=16;this.h[0]=ge,this.h[1]=we,this.h[2]=J,this.h[3]=C,this.h[4]=B,this.h[5]=V,this.h[6]=P,this.h[7]=D,this.h[8]=L,this.h[9]=_e},Bt.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},Bt.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function jt(l,p,d,a,g,S){var E=new Bt(S);return E.update(d,a,g),E.finish(l,p),0}function Pt(l,p,d,a,g,S){var E=new Uint8Array(16);return jt(E,0,d,a,g,S),O(l,p,E,0)}function Ot(l,p,d,a,g){var S;if(d<32)return-1;for(dt(l,0,p,0,d,a,g),jt(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function pt(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(Ke(E,0,32,a,g),Pt(p,16,p,32,d-32,E)!==0))return-1;for(dt(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Je(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function ce(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ie(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function vt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(ce(E),ce(E),ce(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ie(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Mt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return vt(d,l),vt(a,p),I(d,0,a,0)}function Vt(l){var p=new Uint8Array(32);return vt(p,l),p[0]&1}function he(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function it(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function mt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function te(l,p,d){var a,g,S=0,E=0,U=0,z=0,be=0,ee=0,at=0,ue=0,Ce=0,Be=0,Me=0,Ue=0,Oe=0,Ne=0,Te=0,pe=0,Se=0,ie=0,ge=0,we=0,J=0,C=0,B=0,V=0,P=0,D=0,L=0,_e=0,Ve=0,ze=0,Le=0,w=d[0],We=d[1],ct=d[2],lt=d[3],qe=d[4],st=d[5],ot=d[6],Lt=d[7],bt=d[8],Rt=d[9],Ut=d[10],Dt=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*We,U+=a*ct,z+=a*lt,be+=a*qe,ee+=a*st,at+=a*ot,ue+=a*Lt,Ce+=a*bt,Be+=a*Rt,Me+=a*Ut,Ue+=a*Dt,Oe+=a*Kt,Ne+=a*sr,Te+=a*or,pe+=a*ar,a=p[1],E+=a*w,U+=a*We,z+=a*ct,be+=a*lt,ee+=a*qe,at+=a*st,ue+=a*ot,Ce+=a*Lt,Be+=a*bt,Me+=a*Rt,Ue+=a*Ut,Oe+=a*Dt,Ne+=a*Kt,Te+=a*sr,pe+=a*or,Se+=a*ar,a=p[2],U+=a*w,z+=a*We,be+=a*ct,ee+=a*lt,at+=a*qe,ue+=a*st,Ce+=a*ot,Be+=a*Lt,Me+=a*bt,Ue+=a*Rt,Oe+=a*Ut,Ne+=a*Dt,Te+=a*Kt,pe+=a*sr,Se+=a*or,ie+=a*ar,a=p[3],z+=a*w,be+=a*We,ee+=a*ct,at+=a*lt,ue+=a*qe,Ce+=a*st,Be+=a*ot,Me+=a*Lt,Ue+=a*bt,Oe+=a*Rt,Ne+=a*Ut,Te+=a*Dt,pe+=a*Kt,Se+=a*sr,ie+=a*or,ge+=a*ar,a=p[4],be+=a*w,ee+=a*We,at+=a*ct,ue+=a*lt,Ce+=a*qe,Be+=a*st,Me+=a*ot,Ue+=a*Lt,Oe+=a*bt,Ne+=a*Rt,Te+=a*Ut,pe+=a*Dt,Se+=a*Kt,ie+=a*sr,ge+=a*or,we+=a*ar,a=p[5],ee+=a*w,at+=a*We,ue+=a*ct,Ce+=a*lt,Be+=a*qe,Me+=a*st,Ue+=a*ot,Oe+=a*Lt,Ne+=a*bt,Te+=a*Rt,pe+=a*Ut,Se+=a*Dt,ie+=a*Kt,ge+=a*sr,we+=a*or,J+=a*ar,a=p[6],at+=a*w,ue+=a*We,Ce+=a*ct,Be+=a*lt,Me+=a*qe,Ue+=a*st,Oe+=a*ot,Ne+=a*Lt,Te+=a*bt,pe+=a*Rt,Se+=a*Ut,ie+=a*Dt,ge+=a*Kt,we+=a*sr,J+=a*or,C+=a*ar,a=p[7],ue+=a*w,Ce+=a*We,Be+=a*ct,Me+=a*lt,Ue+=a*qe,Oe+=a*st,Ne+=a*ot,Te+=a*Lt,pe+=a*bt,Se+=a*Rt,ie+=a*Ut,ge+=a*Dt,we+=a*Kt,J+=a*sr,C+=a*or,B+=a*ar,a=p[8],Ce+=a*w,Be+=a*We,Me+=a*ct,Ue+=a*lt,Oe+=a*qe,Ne+=a*st,Te+=a*ot,pe+=a*Lt,Se+=a*bt,ie+=a*Rt,ge+=a*Ut,we+=a*Dt,J+=a*Kt,C+=a*sr,B+=a*or,V+=a*ar,a=p[9],Be+=a*w,Me+=a*We,Ue+=a*ct,Oe+=a*lt,Ne+=a*qe,Te+=a*st,pe+=a*ot,Se+=a*Lt,ie+=a*bt,ge+=a*Rt,we+=a*Ut,J+=a*Dt,C+=a*Kt,B+=a*sr,V+=a*or,P+=a*ar,a=p[10],Me+=a*w,Ue+=a*We,Oe+=a*ct,Ne+=a*lt,Te+=a*qe,pe+=a*st,Se+=a*ot,ie+=a*Lt,ge+=a*bt,we+=a*Rt,J+=a*Ut,C+=a*Dt,B+=a*Kt,V+=a*sr,P+=a*or,D+=a*ar,a=p[11],Ue+=a*w,Oe+=a*We,Ne+=a*ct,Te+=a*lt,pe+=a*qe,Se+=a*st,ie+=a*ot,ge+=a*Lt,we+=a*bt,J+=a*Rt,C+=a*Ut,B+=a*Dt,V+=a*Kt,P+=a*sr,D+=a*or,L+=a*ar,a=p[12],Oe+=a*w,Ne+=a*We,Te+=a*ct,pe+=a*lt,Se+=a*qe,ie+=a*st,ge+=a*ot,we+=a*Lt,J+=a*bt,C+=a*Rt,B+=a*Ut,V+=a*Dt,P+=a*Kt,D+=a*sr,L+=a*or,_e+=a*ar,a=p[13],Ne+=a*w,Te+=a*We,pe+=a*ct,Se+=a*lt,ie+=a*qe,ge+=a*st,we+=a*ot,J+=a*Lt,C+=a*bt,B+=a*Rt,V+=a*Ut,P+=a*Dt,D+=a*Kt,L+=a*sr,_e+=a*or,Ve+=a*ar,a=p[14],Te+=a*w,pe+=a*We,Se+=a*ct,ie+=a*lt,ge+=a*qe,we+=a*st,J+=a*ot,C+=a*Lt,B+=a*bt,V+=a*Rt,P+=a*Ut,D+=a*Dt,L+=a*Kt,_e+=a*sr,Ve+=a*or,ze+=a*ar,a=p[15],pe+=a*w,Se+=a*We,ie+=a*ct,ge+=a*lt,we+=a*qe,J+=a*st,C+=a*ot,B+=a*Lt,V+=a*bt,P+=a*Rt,D+=a*Ut,L+=a*Dt,_e+=a*Kt,Ve+=a*sr,ze+=a*or,Le+=a*ar,S+=38*Se,E+=38*ie,U+=38*ge,z+=38*we,be+=38*J,ee+=38*C,at+=38*B,ue+=38*V,Ce+=38*P,Be+=38*D,Me+=38*L,Ue+=38*_e,Oe+=38*Ve,Ne+=38*ze,Te+=38*Le,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=at+g+65535,g=Math.floor(a/65536),at=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Me+g+65535,g=Math.floor(a/65536),Me=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=be+g+65535,g=Math.floor(a/65536),be=a-g*65536,a=ee+g+65535,g=Math.floor(a/65536),ee=a-g*65536,a=at+g+65535,g=Math.floor(a/65536),at=a-g*65536,a=ue+g+65535,g=Math.floor(a/65536),ue=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Me+g+65535,g=Math.floor(a/65536),Me=a-g*65536,a=Ue+g+65535,g=Math.floor(a/65536),Ue=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=U,l[3]=z,l[4]=be,l[5]=ee,l[6]=at,l[7]=ue,l[8]=Ce,l[9]=Be,l[10]=Me,l[11]=Ue,l[12]=Oe,l[13]=Ne,l[14]=Te,l[15]=pe}function gt(l,p){te(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)gt(d,d),a!==2&&a!==4&&te(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function mo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)gt(d,d),a!==1&&te(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function hs(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,U=t(),z=t(),be=t(),ee=t(),at=t(),ue=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,he(g,d),E=0;E<16;E++)z[E]=g[E],ee[E]=U[E]=be[E]=0;for(U[0]=ee[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ie(U,z,S),Ie(be,ee,S),it(at,U,be),mt(U,U,be),it(be,z,ee),mt(z,z,ee),gt(ee,at),gt(ue,U),te(U,be,U),te(be,z,at),it(at,U,be),mt(U,U,be),gt(z,U),mt(be,ee,ue),te(U,be,u),it(U,U,ee),te(be,be,U),te(U,ee,ue),te(ee,z,g),gt(z,at),Ie(U,z,S),Ie(be,ee,S);for(E=0;E<16;E++)g[E+16]=U[E],g[E+32]=be[E],g[E+48]=z[E],g[E+64]=ee[E];var Ce=g.subarray(32),Be=g.subarray(16);return Ft(Ce,Ce),te(Be,Be,Ce),vt(l,Be),0}function pr(l,p){return hs(l,p,s)}function wo(l,p){return n(p,32),pr(l,p)}function Nn(l,p,d){var a=new Uint8Array(32);return hs(a,d,p),Q(l,i,a,re)}var bo=Ot,Sf=pt;function xo(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),bo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),Sf(l,p,d,a,E)}var Ao=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function So(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,U,z,be,ee,at,ue,Ce,Be,Me,Ue,Oe,Ne,Te,pe,Se,ie,ge,we,J,C,B,V,P,D,L,_e=l[0],Ve=l[1],ze=l[2],Le=l[3],w=l[4],We=l[5],ct=l[6],lt=l[7],qe=p[0],st=p[1],ot=p[2],Lt=p[3],bt=p[4],Rt=p[5],Ut=p[6],Dt=p[7],Kt=0;a>=128;){for(we=0;we<16;we++)J=8*we+Kt,g[we]=d[J+0]<<24|d[J+1]<<16|d[J+2]<<8|d[J+3],S[we]=d[J+4]<<24|d[J+5]<<16|d[J+6]<<8|d[J+7];for(we=0;we<80;we++)if(E=_e,U=Ve,z=ze,be=Le,ee=w,at=We,ue=ct,Ce=lt,Be=qe,Me=st,Ue=ot,Oe=Lt,Ne=bt,Te=Rt,pe=Ut,Se=Dt,C=lt,B=Dt,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=(w>>>14|bt<<18)^(w>>>18|bt<<14)^(bt>>>9|w<<23),B=(bt>>>14|w<<18)^(bt>>>18|w<<14)^(w>>>9|bt<<23),V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,C=w&We^~w&ct,B=bt&Rt^~bt&Ut,V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,C=Ao[we*2],B=Ao[we*2+1],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,C=g[we%16],B=S[we%16],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,ie=D&65535|L<<16,ge=V&65535|P<<16,C=ie,B=ge,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=(_e>>>28|qe<<4)^(qe>>>2|_e<<30)^(qe>>>7|_e<<25),B=(qe>>>28|_e<<4)^(_e>>>2|qe<<30)^(_e>>>7|qe<<25),V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,C=_e&Ve^_e&ze^Ve&ze,B=qe&st^qe&ot^st&ot,V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,Ce=D&65535|L<<16,Se=V&65535|P<<16,C=be,B=Oe,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=ie,B=ge,V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,be=D&65535|L<<16,Oe=V&65535|P<<16,Ve=E,ze=U,Le=z,w=be,We=ee,ct=at,lt=ue,_e=Ce,st=Be,ot=Me,Lt=Ue,bt=Oe,Rt=Ne,Ut=Te,Dt=pe,qe=Se,we%16===15)for(J=0;J<16;J++)C=g[J],B=S[J],V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=g[(J+9)%16],B=S[(J+9)%16],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,ie=g[(J+1)%16],ge=S[(J+1)%16],C=(ie>>>1|ge<<31)^(ie>>>8|ge<<24)^ie>>>7,B=(ge>>>1|ie<<31)^(ge>>>8|ie<<24)^(ge>>>7|ie<<25),V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,ie=g[(J+14)%16],ge=S[(J+14)%16],C=(ie>>>19|ge<<13)^(ge>>>29|ie<<3)^ie>>>6,B=(ge>>>19|ie<<13)^(ie>>>29|ge<<3)^(ge>>>6|ie<<26),V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,g[J]=D&65535|L<<16,S[J]=V&65535|P<<16;C=_e,B=qe,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[0],B=p[0],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[0]=_e=D&65535|L<<16,p[0]=qe=V&65535|P<<16,C=Ve,B=st,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[1],B=p[1],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[1]=Ve=D&65535|L<<16,p[1]=st=V&65535|P<<16,C=ze,B=ot,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[2],B=p[2],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[2]=ze=D&65535|L<<16,p[2]=ot=V&65535|P<<16,C=Le,B=Lt,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[3],B=p[3],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[3]=Le=D&65535|L<<16,p[3]=Lt=V&65535|P<<16,C=w,B=bt,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[4],B=p[4],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=bt=V&65535|P<<16,C=We,B=Rt,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[5],B=p[5],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[5]=We=D&65535|L<<16,p[5]=Rt=V&65535|P<<16,C=ct,B=Ut,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[6],B=p[6],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[6]=ct=D&65535|L<<16,p[6]=Ut=V&65535|P<<16,C=lt,B=Dt,V=B&65535,P=B>>>16,D=C&65535,L=C>>>16,C=l[7],B=p[7],V+=B&65535,P+=B>>>16,D+=C&65535,L+=C>>>16,P+=V>>>16,D+=P>>>16,L+=D>>>16,l[7]=lt=D&65535|L<<16,p[7]=Dt=V&65535|P<<16,Kt+=128,a-=128}return a}function dn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,U=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,So(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[U-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,v(S,d-8,U/536870912|0,U<<3),So(a,g,S,d),E=0;E<8;E++)v(l,8*E,a[E],g[E]);return 0}function Bi(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t(),be=t(),ee=t();mt(d,l[1],l[0]),mt(ee,p[1],p[0]),te(d,d,ee),it(a,l[0],l[1]),it(ee,p[0],p[1]),te(a,a,ee),te(g,l[3],p[3]),te(g,g,m),te(S,l[2],p[2]),it(S,S,S),mt(E,a,d),mt(U,S,g),it(z,S,g),it(be,a,d),te(l[0],E,U),te(l[1],be,z),te(l[2],z,U),te(l[3],E,be)}function ds(l,p,d){var a;for(a=0;a<4;a++)Ie(l[a],p[a],d)}function _o(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),te(d,p[0],g),te(a,p[1],g),vt(l,a),l[31]^=Vt(d)<<7}function Eo(l,p,d){var a,g;for(Je(l[0],o),Je(l[1],c),Je(l[2],c),Je(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,ds(l,p,a),Bi(p,l),Bi(l,l),ds(l,p,a)}function ps(l,p){var d=[t(),t(),t(),t()];Je(d[0],x),Je(d[1],G),Je(d[2],c),te(d[3],x,G),Eo(l,d,p)}function Io(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),dn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ps(g,a),_o(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var pn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ko(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*pn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*pn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*pn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function Co(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;ko(l,p)}function $c(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),U,z,be=new Float64Array(64),ee=[t(),t(),t(),t()];dn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var at=d+64;for(U=0;U<d;U++)l[64+U]=p[U];for(U=0;U<32;U++)l[32+U]=g[32+U];for(dn(E,l.subarray(32),d+32),Co(E),ps(ee,E),_o(l,ee),U=32;U<64;U++)l[U]=a[U];for(dn(S,l,d+64),Co(S),U=0;U<64;U++)be[U]=0;for(U=0;U<32;U++)be[U]=E[U];for(U=0;U<32;U++)for(z=0;z<32;z++)be[U+z]+=S[U]*g[z];return ko(l.subarray(32),be),at}function Bo(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t();return Je(l[2],c),he(l[1],p),gt(g,l[1]),te(S,g,h),mt(g,g,l[2]),it(S,l[2],S),gt(E,S),gt(U,E),te(z,U,E),te(d,z,g),te(d,d,S),mo(d,d),te(d,d,g),te(d,d,S),te(d,d,S),te(l[0],d,S),gt(a,l[0]),te(a,a,S),Mt(a,g)&&te(l[0],l[0],N),gt(a,l[0]),te(a,a,S),Mt(a,g)?-1:(Vt(l[0])===p[31]>>7&&mt(l[0],o,l[0]),te(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),U=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Bo(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(dn(E,l,d),Co(E),Eo(U,z,E),ps(z,p.subarray(32)),Bi(U,z),_o(S,U),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var k=32,T=24,K=32,xe=16,_t=32,Et=32,Re=32,Z=32,ne=32,de=T,me=K,Ye=xe,tt=64,wt=32,Zt=64,ys=32,Oo=64;e.lowlevel={crypto_core_hsalsa20:Q,crypto_stream_xor:dt,crypto_stream:Ke,crypto_stream_salsa20_xor:Y,crypto_stream_salsa20:ye,crypto_onetimeauth:jt,crypto_onetimeauth_verify:Pt,crypto_verify_16:O,crypto_verify_32:I,crypto_secretbox:Ot,crypto_secretbox_open:pt,crypto_scalarmult:hs,crypto_scalarmult_base:pr,crypto_box_beforenm:Nn,crypto_box_afternm:bo,crypto_box:xo,crypto_box_open:Dc,crypto_box_keypair:wo,crypto_hash:dn,crypto_sign:$c,crypto_sign_keypair:Io,crypto_sign_open:_,crypto_secretbox_KEYBYTES:k,crypto_secretbox_NONCEBYTES:T,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:xe,crypto_scalarmult_BYTES:_t,crypto_scalarmult_SCALARBYTES:Et,crypto_box_PUBLICKEYBYTES:Re,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:ne,crypto_box_NONCEBYTES:de,crypto_box_ZEROBYTES:me,crypto_box_BOXZEROBYTES:Ye,crypto_sign_BYTES:tt,crypto_sign_PUBLICKEYBYTES:wt,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:ys,crypto_hash_BYTES:Oo,gf:t,D:h,L:pn,pack25519:vt,unpack25519:he,M:te,A:it,S:gt,Z:mt,pow2523:mo,add:Bi,set25519:Je,modL:ko,scalarmult:Eo,scalarbase:ps};function Mc(l,p){if(l.length!==k)throw new Error("bad key size");if(p.length!==T)throw new Error("bad nonce size")}function cw(l,p){if(l.length!==Re)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function xy(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return Ot(g,a,a.length,p,d),g.subarray(xe)},e.secretbox.open=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(xe+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+xe]=l[S];return a.length<32||pt(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=k,e.secretbox.nonceLength=T,e.secretbox.overheadLength=xe,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Et)throw new Error("bad n size");if(p.length!==_t)throw new Error("bad p size");var d=new Uint8Array(_t);return hs(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Et)throw new Error("bad n size");var p=new Uint8Array(_t);return pr(p,l),p},e.scalarMult.scalarLength=Et,e.scalarMult.groupElementLength=_t,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),cw(l,p);var d=new Uint8Array(ne);return Nn(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Re),p=new Uint8Array(Z);return wo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(Re);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Re,e.box.secretKeyLength=Z,e.box.sharedKeyLength=ne,e.box.nonceLength=de,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(tt+l.length);return $c(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==wt)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(tt),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==tt)throw new Error("bad signature size");if(d.length!==wt)throw new Error("bad public key size");var a=new Uint8Array(tt+l.length),g=new Uint8Array(tt+l.length),S;for(S=0;S<tt;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+tt]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(wt),p=new Uint8Array(Zt);return Io(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(wt),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==ys)throw new Error("bad seed size");for(var p=new Uint8Array(wt),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Io(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=wt,e.sign.secretKeyLength=Zt,e.sign.seedLength=ys,e.sign.signatureLength=tt,e.hash=function(l){Br(l);var p=new Uint8Array(Oo);return dn(p,l,l.length),p},e.hash.hashLength=Oo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];xy(S)})}else typeof g1<"u"&&(l=v1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];xy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(B0);var m1=B0.exports;const O0=Ly(m1);function w1(){return O0.box.keyPair()}async function Ci(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=gs(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await y1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=w1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await U1($r(o.publicKey),i,e);console.log("Key exchange completed.");const m=O0.scalarMult(o.secretKey,c),x=gs(u),G=12,N=x.slice(0,G),v=x.slice(G),O=new Hc(m).open(N,v);if(O)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",$r(O)),window.sessionStorage.setItem("sessionId",h),{sessionKey:O,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let nt="";function b1(r){nt=r}async function x1(r,e){return Ht(`${nt}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function A1(r,e,t,n){return Ht(`${nt}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function S1(r){return Ht(`${nt}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function _1(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Ht(`${nt}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing platform token:",t),t}}async function T0(r){return Fe(`${nt}/platform/orgs`,"POST",{name:r})}async function N0(){return Fe(`${nt}/platform/orgs`,"GET",void 0)}async function j0(r){return Fe(`${nt}/platform/orgs/${r}`,"DELETE",void 0)}async function P0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function R0(r){return Fe(`${nt}/platform/orgs/${r}/projects`,"GET",void 0)}async function U0(r,e){return Fe(`${nt}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function D0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function $0(r,e){return Fe(`${nt}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function E1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function M0(r,e,t,n){if(!E1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return Fe(`${nt}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function V0(r,e){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function L0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function H0(r,e){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function F0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function z0(r,e){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function G0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function K0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return Fe(`${nt}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function q0(r){return Fe(`${nt}/platform/orgs/${r}/invites`,"GET",void 0)}async function Z0(r,e){return Fe(`${nt}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function W0(r,e){return Fe(`${nt}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function Y0(r){return Fe(`${nt}/platform/orgs/${r}/memberships`,"GET",void 0)}async function J0(r,e,t){return Fe(`${nt}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function X0(r,e){return Fe(`${nt}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function Q0(r){return Fe(`${nt}/platform/accept_invite/${r}`,"POST",void 0)}async function I1(){return Fe(`${nt}/platform/me`,"GET",void 0)}async function ey(r){return Ht(`${nt}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return Fe(`${nt}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function ty(r,e){const t={email:r,hashed_secret:e};return Ht(`${nt}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ry(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Ht(`${nt}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function ny(r,e){const t={current_password:r,new_password:e};return Fe(`${nt}/platform/change-password`,"POST",t,"Failed to change platform password")}async function Fe(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=ti.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await _1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await iy(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, attempting to refresh token`),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function iy(r,e,t,n,i){const o=ti.resolveEndpoint(r).context==="platform"?ti.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ci(!1,o);const h=async(x,G=!1)=>{if(G||!c||!u){const j=await Ci(!0,o);c=j.sessionKey,u=j.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const N=t?JSON.stringify(t):void 0,v=N?jf(c,N):void 0,A={"Content-Type":"application/json","x-session-id":u};x&&(A.Authorization=`Bearer ${x}`);const O=await fetch(r,{method:e,headers:A,body:v?JSON.stringify({encrypted:v}):void 0}),I={status:O.status};if(O.ok)try{const j=await O.json(),R=Pf(c,j.encrypted);I.data=JSON.parse(R)}catch(j){console.error("Error decrypting or parsing response:",j),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const j=await O.json();I.error=j.message||i||`HTTP error! Status: ${O.status}`}catch{I.error=i||`HTTP error! Status: ${O.status}`}return I},m=async(x,G=!1)=>{var N;try{const v=await h(x,G);return(v.status===400||(N=v.error)!=null&&N.includes("Encryption error"))&&!G?(console.log("Encryption error or Bad Request, attempting to renew attestation"),m(x,!0)):v}catch(v){return{status:500,error:v instanceof Error?v.message:"Unknown error occurred"}}};return m(n)}async function Ht(r,e,t,n,i){const s=await iy(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let ht="";function k1(r){ht=r}function C1(){return ht}async function B1(r,e,t){return Ht(`${ht}/login`,"POST",{email:r,password:e,client_id:t})}async function O1(r,e,t){return Ht(`${ht}/login`,"POST",{id:r,password:e,client_id:t})}async function T1(r,e,t,n,i){return Ht(`${ht}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function N1(r,e,t){return Ht(`${ht}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Ht(`${ht}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function j1(){return Fe(`${ht}/protected/user`,"GET",void 0,"Failed to fetch user")}async function sy(r,e){return Fe(`${ht}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function oy(r){return Fe(`${ht}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function ay(r){try{return await Fe(`${ht}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function cy(){return Fe(`${ht}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function P1(r){const e={refresh_token:r};return Ht(`${ht}/logout`,"POST",e)}async function ly(r){return Ht(`${ht}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Nc(){return Fe(`${ht}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function R1(r,e){const n=await fetch(`${e||ht}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function U1(r,e,t){const i=await fetch(`${t||ht}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function D1(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Ht(`${ht}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function $1(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Ht(`${ht}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function uy(r,e){const t={current_password:r,new_password:e};return Fe(`${ht}/protected/change_password`,"POST",t,"Failed to change password")}async function M1(r,e){try{return await Ht(`${ht}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function V1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ht(`${ht}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function L1(r,e){try{return await Ht(`${ht}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function H1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Ht(`${ht}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function fy(r){let e=`${ht}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Fe(e,"GET",void 0,"Failed to fetch private key")}async function hy(r){let e=`${ht}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),Fe(e,"GET",void 0,"Failed to fetch private key bytes")}async function dy(r,e,t){const i={message_base64:$r(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return Fe(`${ht}/protected/sign_message`,"POST",i,"Failed to sign message")}async function py(r,e){let t=`${ht}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),Fe(t,"GET",void 0,"Failed to fetch public key")}async function F1(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return Fe(`${ht}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function z1(r){return Fe(`${ht}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function yy(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Fe(`${ht}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function gy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return Fe(`${ht}/protected/decrypt`,"POST",t,"Failed to decrypt data")}function G1(){return async(r,e)=>{var n,i;const t=()=>{const s=window.localStorage.getItem("access_token");if(!s)throw new Error("No access token available");return`Bearer ${s}`};try{const s=new Headers(e==null?void 0:e.headers);s.set("Authorization",t());const{sessionKey:o,sessionId:c}=await Ci();if(!o||!c)throw new Error("No session key or ID available");s.set("x-session-id",c);const u={...e,headers:s};if(e!=null&&e.body){const m=jf(o,e.body);u.body=JSON.stringify({encrypted:m}),s.set("Content-Type","application/json")}let h=await fetch(r,u);if(h.status===401&&(console.warn("Unauthorized, refreshing access token"),await Tc(),s.set("Authorization",t()),u.headers=s,h=await fetch(r,u)),!h.ok){const m=await h.text();throw console.error("Request failed with response status:",h.status," and message:",m),new Error(`Request failed with status ${h.status}: ${m}`)}if((n=h.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const m=(i=h.body)==null?void 0:i.getReader(),x=new TextDecoder;let G="";const N=new ReadableStream({async start(v){for(;;){const{done:A,value:O}=await m.read();if(A)break;const I=x.decode(O);G+=I;let j;for(;j=K1(G);)if(G=G.slice(j.length),j.trim().startsWith("data: ")){const R=j.slice(6).trim();if(R==="[DONE]")v.enqueue(`data: [DONE]
124
+ `,h+=u,h},df.noChildren=!0,We.registerDecoder(Et.CBOR,df),We.registerDecoder(Et.URI,r=>(Gn(r.contents),new URL(r.contents)),"URI"),Rt(URL,r=>[Et.URI,r.toString()]),We.registerDecoder(Et.BASE64URL,r=>(Gn(r.contents),Vv(r.contents)),"Base64url-encoded"),We.registerDecoder(Et.BASE64,r=>(Gn(r.contents),af(r.contents)),"Base64-encoded"),We.registerDecoder(35,r=>(Gn(r.contents),new RegExp(r.contents)),"RegExp"),We.registerDecoder(21065,r=>{Gn(r.contents);let e=r.contents.replace(new RegExp("(?<!\\\\)(?<!\\[(?:[^\\]]|\\\\\\])*)\\.","g"),`[^
125
+ \r]`);return e=`^(?:${e})$`,new RegExp(e,"u")},"I-RegExp"),We.registerDecoder(Et.REGEXP,r=>{if(h0(r.contents),r.contents.length<1||r.contents.length>2)throw new Error(`Invalid RegExp Array: ${r.contents}`);return new RegExp(r.contents[0],r.contents[1])},"RegExp"),Rt(RegExp,r=>[Et.REGEXP,[r.source,r.flags]]),We.registerDecoder(64,r=>(Si(r.contents),r.contents),"uint8 Typed Array");function nr(r,e,t){Si(r.contents);let n=r.contents.length;if(n%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${n}`);n/=e.BYTES_PER_ELEMENT;const i=new e(n),s=new DataView(r.contents.buffer,r.contents.byteOffset,r.contents.byteLength),o=s[`get${e.name.replace(/Array/,"")}`].bind(s);for(let c=0;c<n;c++)i[c]=o(c*e.BYTES_PER_ELEMENT,t);return i}function Kn(r,e,t,n,i){const s=i.forceEndian??u0;if(yc(s?e:t,r,i),Kr(n.byteLength,r,ge.BYTE_STRING),u0===s)r.write(new Uint8Array(n.buffer,n.byteOffset,n.byteLength));else{const o=`write${n.constructor.name.replace(/Array/,"")}`,c=r[o].bind(r);for(const u of n)c(u,s)}}We.registerDecoder(65,r=>nr(r,Uint16Array,!1),"uint16, big endian, Typed Array"),We.registerDecoder(66,r=>nr(r,Uint32Array,!1),"uint32, big endian, Typed Array"),We.registerDecoder(67,r=>nr(r,BigUint64Array,!1),"uint64, big endian, Typed Array"),We.registerDecoder(68,r=>(Si(r.contents),new Uint8ClampedArray(r.contents)),"uint8 Typed Array, clamped arithmetic"),Rt(Uint8ClampedArray,r=>[68,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(69,r=>nr(r,Uint16Array,!0),"uint16, little endian, Typed Array"),Rt(Uint16Array,(r,e,t)=>Kn(e,69,65,r,t)),We.registerDecoder(70,r=>nr(r,Uint32Array,!0),"uint32, little endian, Typed Array"),Rt(Uint32Array,(r,e,t)=>Kn(e,70,66,r,t)),We.registerDecoder(71,r=>nr(r,BigUint64Array,!0),"uint64, little endian, Typed Array"),Rt(BigUint64Array,(r,e,t)=>Kn(e,71,67,r,t)),We.registerDecoder(72,r=>(Si(r.contents),new Int8Array(r.contents)),"sint8 Typed Array"),Rt(Int8Array,r=>[72,new Uint8Array(r.buffer,r.byteOffset,r.byteLength)]),We.registerDecoder(73,r=>nr(r,Int16Array,!1),"sint16, big endian, Typed Array"),We.registerDecoder(74,r=>nr(r,Int32Array,!1),"sint32, big endian, Typed Array"),We.registerDecoder(75,r=>nr(r,BigInt64Array,!1),"sint64, big endian, Typed Array"),We.registerDecoder(77,r=>nr(r,Int16Array,!0),"sint16, little endian, Typed Array"),Rt(Int16Array,(r,e,t)=>Kn(e,77,73,r,t)),We.registerDecoder(78,r=>nr(r,Int32Array,!0),"sint32, little endian, Typed Array"),Rt(Int32Array,(r,e,t)=>Kn(e,78,74,r,t)),We.registerDecoder(79,r=>nr(r,BigInt64Array,!0),"sint64, little endian, Typed Array"),Rt(BigInt64Array,(r,e,t)=>Kn(e,79,75,r,t)),We.registerDecoder(81,r=>nr(r,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),We.registerDecoder(82,r=>nr(r,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),We.registerDecoder(85,r=>nr(r,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),Rt(Float32Array,(r,e,t)=>Kn(e,85,81,r,t)),We.registerDecoder(86,r=>nr(r,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),Rt(Float64Array,(r,e,t)=>Kn(e,86,82,r,t)),We.registerDecoder(Et.SET,r=>(h0(r.contents),new Set(r.contents)),"Set"),Rt(Set,r=>[Et.SET,[...r]]),We.registerDecoder(Et.JSON,r=>(Gn(r.contents),JSON.parse(r.contents)),"JSON-encoded"),We.registerDecoder(Et.SELF_DESCRIBED,r=>r.contents,"Self-Described"),We.registerDecoder(Et.INVALID_16,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_16}`)},"Invalid"),We.registerDecoder(Et.INVALID_32,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_32}`)},"Invalid"),We.registerDecoder(Et.INVALID_64,()=>{throw new Error(`Tag always invalid: ${Et.INVALID_64}`)},"Invalid");function pf(r){throw new Error(`Encoding ${r.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}Rt(ArrayBuffer,pf),Rt(DataView,pf),typeof SharedArrayBuffer<"u"&&Rt(SharedArrayBuffer,pf);function wc(r){return[NaN,r.valueOf()]}Rt(Boolean,wc),Rt(Number,wc),Rt(String,wc),Rt(BigInt,wc);function bc(r,e={}){const t={...zn.defaultDecodeOptions};if(e.dcbor?Object.assign(t,zn.dcborDecodeOptions):e.cde&&Object.assign(t,zn.cdeDecodeOptions),Object.assign(t,e),Object.hasOwn(t,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");t.boxed&&(t.saveOriginal=!0);const n=new Xs(r,t);let i,s;for(const o of n){if(s=zn.create(o,i,t,n),o[2]===Ir.BREAK)if(i!=null&&i.isStreaming)i.left=0;else throw new Error("Unexpected BREAK");else i&&i.push(s,n,o[3]);for(s instanceof zn&&(i=s);i!=null&&i.done;){s=i.convert(n);const c=i.parent;c==null||c.replaceLast(s,i,n),i=c}}return s}new TextEncoder;var ot;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(const c of s)o[c]=i[c];return r.objectValues(o)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},r.find=(i,s)=>{for(const o of i)if(s(o))return o},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(ot||(ot={}));var yf;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yf||(yf={}));const ie=ot.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qn=r=>{switch(typeof r){case"undefined":return ie.undefined;case"string":return ie.string;case"number":return isNaN(r)?ie.nan:ie.number;case"boolean":return ie.boolean;case"function":return ie.function;case"bigint":return ie.bigint;case"symbol":return ie.symbol;case"object":return Array.isArray(r)?ie.array:r===null?ie.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ie.promise:typeof Map<"u"&&r instanceof Map?ie.map:typeof Set<"u"&&r instanceof Set?ie.set:typeof Date<"u"&&r instanceof Date?ie.date:ie.object;default:return ie.unknown}},F=ot.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),um=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class kr extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let c=n,u=0;for(;u<o.path.length;){const h=o.path[u];u===o.path.length-1?(c[h]=c[h]||{_errors:[]},c[h]._errors.push(t(o))):c[h]=c[h]||{_errors:[]},c=c[h],u++}}};return i(this),n}static assert(e){if(!(e instanceof kr))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ot.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}kr.create=r=>new kr(r);const is=(r,e)=>{let t;switch(r.code){case F.invalid_type:r.received===ie.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case F.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ot.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:t=`Unrecognized key(s) in object: ${ot.joinValues(r.keys,", ")}`;break;case F.invalid_union:t="Invalid input";break;case F.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ot.joinValues(r.options)}`;break;case F.invalid_enum_value:t=`Invalid enum value. Expected ${ot.joinValues(r.options)}, received '${r.received}'`;break;case F.invalid_arguments:t="Invalid function arguments";break;case F.invalid_return_type:t="Invalid function return type";break;case F.invalid_date:t="Invalid date";break;case F.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:ot.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case F.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case F.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case F.custom:t="Invalid input";break;case F.invalid_intersection_types:t="Intersection results could not be merged";break;case F.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case F.not_finite:t="Number must be finite";break;default:t=e.defaultError,ot.assertNever(r)}return{message:t}};let v0=is;function fm(r){v0=r}function xc(){return v0}const Ac=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="";const u=n.filter(h=>!!h).slice().reverse();for(const h of u)c=h(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},hm=[];function X(r,e){const t=xc(),n=Ac({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===is?void 0:is].filter(i=>!!i)});r.common.issues.push(n)}class ir{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return ke;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t){const s=await i.key,o=await i.value;n.push({key:s,value:o})}return ir.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return ke;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[s.value]=o.value)}return{status:e.value,value:n}}}const ke=Object.freeze({status:"aborted"}),ss=r=>({status:"dirty",value:r}),hr=r=>({status:"valid",value:r}),gf=r=>r.status==="aborted",vf=r=>r.status==="dirty",Qs=r=>r.status==="valid",eo=r=>typeof Promise<"u"&&r instanceof Promise;function Sc(r,e,t,n){if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(r)}function m0(r,e,t,n,i){if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(r,t),t}typeof SuppressedError=="function"&&SuppressedError;var xe;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(xe||(xe={}));var to,ro;class an{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const w0=(r,e)=>{if(Qs(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new kr(r.common.issues);return this._error=t,this._error}}};function Me(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{var u,h;const{message:m}=r;return o.code==="invalid_enum_value"?{message:m??c.defaultError}:typeof c.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(h=m??t)!==null&&h!==void 0?h:c.defaultError}},description:i}}class Ke{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return qn(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ir,ctx:{common:e.parent.common,data:e.data,parsedType:qn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(eo(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:qn(e)},s=this._parseSync({data:e,path:i.path,parent:i});return w0(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:qn(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(eo(i)?i:Promise.resolve(i));return w0(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const o=e(i),c=()=>s.addIssue({code:F.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new Wr({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ln.create(this,this._def)}nullable(){return Jn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zr.create(this,this._def)}promise(){return ls.create(this,this._def)}or(e){return oo.create([this,e],this._def)}and(e){return ao.create(this,e,this._def)}transform(e){return new Wr({...Me(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ho({...Me(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new bf({typeName:Ee.ZodBranded,type:this,...Me(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new po({...Me(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return yo.create(this,e)}readonly(){return go.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const dm=/^c[^\s-]{8,}$/i,pm=/^[0-9a-z]+$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,gm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,vm=/^[a-z0-9_-]{21}$/i,mm=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,wm=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mf;const xm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Am=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Sm=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,b0="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",_m=new RegExp(`^${b0}$`);function x0(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Em(r){return new RegExp(`^${x0(r)}$`)}function A0(r){let e=`${b0}T${x0(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Im(r,e){return!!((e==="v4"||!e)&&xm.test(r)||(e==="v6"||!e)&&Am.test(r))}class qr extends Ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ie.string){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.string,received:s.parsedType}),ke}const n=new ir;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?X(i,{code:F.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&X(i,{code:F.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")wm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"email",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mf||(mf=new RegExp(bm,"u")),mf.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"emoji",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")gm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"uuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"nanoid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")dm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")pm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"cuid2",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ulid",code:F.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),X(i,{validation:"url",code:F.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"regex",code:F.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?A0(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_m.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Em(s).test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{code:F.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?mm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"duration",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Im(e.data,s.version)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"ip",code:F.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?Sm.test(e.data)||(i=this._getOrReturnCtx(e,i),X(i,{validation:"base64",code:F.invalid_string,message:s.message}),n.dirty()):ot.assertNever(s);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(i=>e.test(i),{validation:t,code:F.invalid_string,...xe.errToObj(n)})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...xe.errToObj(e)})}datetime(e){var t,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...xe.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...xe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...xe.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...xe.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...xe.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...xe.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...xe.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...xe.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...xe.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...xe.errToObj(t)})}nonempty(e){return this.min(1,xe.errToObj(e))}trim(){return new qr({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new qr({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qr.create=r=>{var e;return new qr({checks:[],typeName:Ee.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};function km(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),o=parseInt(e.toFixed(i).replace(".",""));return s%o/Math.pow(10,i)}class Zn extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ie.number){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.number,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="int"?ot.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?km(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_finite,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Zn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:xe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:xe.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ot.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Zn.create=r=>new Zn({checks:[],typeName:Ee.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class Wn extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ie.bigint){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.bigint,received:s.parsedType}),ke}let n;const i=new ir;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),X(n,{code:F.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):ot.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,xe.toString(t))}gt(e,t){return this.setLimit("min",e,!1,xe.toString(t))}lte(e,t){return this.setLimit("max",e,!0,xe.toString(t))}lt(e,t){return this.setLimit("max",e,!1,xe.toString(t))}setLimit(e,t,n,i){return new Wn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:xe.toString(i)}]})}_addCheck(e){return new Wn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Wn.create=r=>{var e;return new Wn({checks:[],typeName:Ee.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Me(r)})};class no extends Ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ie.boolean){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.boolean,received:n.parsedType}),ke}return hr(e.data)}}no.create=r=>new no({typeName:Ee.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Me(r)});class _i extends Ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ie.date){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_type,expected:ie.date,received:s.parsedType}),ke}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return X(s,{code:F.invalid_date}),ke}const n=new ir;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),X(i,{code:F.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):ot.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new _i({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:xe.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:xe.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}_i.create=r=>new _i({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Ee.ZodDate,...Me(r)});class _c extends Ke{_parse(e){if(this._getType(e)!==ie.symbol){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.symbol,received:n.parsedType}),ke}return hr(e.data)}}_c.create=r=>new _c({typeName:Ee.ZodSymbol,...Me(r)});class io extends Ke{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.undefined,received:n.parsedType}),ke}return hr(e.data)}}io.create=r=>new io({typeName:Ee.ZodUndefined,...Me(r)});class so extends Ke{_parse(e){if(this._getType(e)!==ie.null){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.null,received:n.parsedType}),ke}return hr(e.data)}}so.create=r=>new so({typeName:Ee.ZodNull,...Me(r)});class os extends Ke{constructor(){super(...arguments),this._any=!0}_parse(e){return hr(e.data)}}os.create=r=>new os({typeName:Ee.ZodAny,...Me(r)});class Ei extends Ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return hr(e.data)}}Ei.create=r=>new Ei({typeName:Ee.ZodUnknown,...Me(r)});class Bn extends Ke{_parse(e){const t=this._getOrReturnCtx(e);return X(t,{code:F.invalid_type,expected:ie.never,received:t.parsedType}),ke}}Bn.create=r=>new Bn({typeName:Ee.ZodNever,...Me(r)});class Ec extends Ke{_parse(e){if(this._getType(e)!==ie.undefined){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.void,received:n.parsedType}),ke}return hr(e.data)}}Ec.create=r=>new Ec({typeName:Ee.ZodVoid,...Me(r)});class Zr extends Ke{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ie.array)return X(t,{code:F.invalid_type,expected:ie.array,received:t.parsedType}),ke;if(i.exactLength!==null){const o=t.data.length>i.exactLength.value,c=t.data.length<i.exactLength.value;(o||c)&&(X(t,{code:o?F.too_big:F.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(X(t,{code:F.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(X(t,{code:F.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>i.type._parseAsync(new an(t,o,t.path,c)))).then(o=>ir.mergeArray(n,o));const s=[...t.data].map((o,c)=>i.type._parseSync(new an(t,o,t.path,c)));return ir.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Zr({...this._def,minLength:{value:e,message:xe.toString(t)}})}max(e,t){return new Zr({...this._def,maxLength:{value:e,message:xe.toString(t)}})}length(e,t){return new Zr({...this._def,exactLength:{value:e,message:xe.toString(t)}})}nonempty(e){return this.min(1,e)}}Zr.create=(r,e)=>new Zr({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...Me(e)});function as(r){if(r instanceof Ot){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=ln.create(as(n))}return new Ot({...r._def,shape:()=>e})}else return r instanceof Zr?new Zr({...r._def,type:as(r.element)}):r instanceof ln?ln.create(as(r.unwrap())):r instanceof Jn?Jn.create(as(r.unwrap())):r instanceof cn?cn.create(r.items.map(e=>as(e))):r}class Ot extends Ke{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ot.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ie.object){const h=this._getOrReturnCtx(e);return X(h,{code:F.invalid_type,expected:ie.object,received:h.parsedType}),ke}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof Bn&&this._def.unknownKeys==="strip"))for(const h in i.data)o.includes(h)||c.push(h);const u=[];for(const h of o){const m=s[h],x=i.data[h];u.push({key:{status:"valid",value:h},value:m._parse(new an(i,x,i.path,h)),alwaysSet:h in i.data})}if(this._def.catchall instanceof Bn){const h=this._def.unknownKeys;if(h==="passthrough")for(const m of c)u.push({key:{status:"valid",value:m},value:{status:"valid",value:i.data[m]}});else if(h==="strict")c.length>0&&(X(i,{code:F.unrecognized_keys,keys:c}),n.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const m of c){const x=i.data[m];u.push({key:{status:"valid",value:m},value:h._parse(new an(i,x,i.path,m)),alwaysSet:m in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const h=[];for(const m of u){const x=await m.key,G=await m.value;h.push({key:x,value:G,alwaysSet:m.alwaysSet})}return h}).then(h=>ir.mergeObjectSync(n,h)):ir.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return xe.errToObj,new Ot({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,o,c;const u=(o=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&o!==void 0?o:n.defaultError;return t.code==="unrecognized_keys"?{message:(c=xe.errToObj(e).message)!==null&&c!==void 0?c:u}:{message:u}}}:{}})}strip(){return new Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ot({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ot({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ot({...this._def,catchall:e})}pick(e){const t={};return ot.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}omit(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ot({...this._def,shape:()=>t})}deepPartial(){return as(this)}partial(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ot({...this._def,shape:()=>t})}required(e){const t={};return ot.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ln;)s=s._def.innerType;t[n]=s}}),new Ot({...this._def,shape:()=>t})}keyof(){return S0(ot.objectKeys(this.shape))}}Ot.create=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Me(e)}),Ot.strictCreate=(r,e)=>new Ot({shape:()=>r,unknownKeys:"strict",catchall:Bn.create(),typeName:Ee.ZodObject,...Me(e)}),Ot.lazycreate=(r,e)=>new Ot({shape:r,unknownKeys:"strip",catchall:Bn.create(),typeName:Ee.ZodObject,...Me(e)});class oo extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const c of s)if(c.result.status==="valid")return c.result;for(const c of s)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=s.map(c=>new kr(c.ctx.common.issues));return X(t,{code:F.invalid_union,unionErrors:o}),ke}if(t.common.async)return Promise.all(n.map(async s=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of n){const h={...t,common:{...t.common,issues:[]},parent:null},m=u._parseSync({data:t.data,path:t.path,parent:h});if(m.status==="valid")return m;m.status==="dirty"&&!s&&(s={result:m,ctx:h}),h.common.issues.length&&o.push(h.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const c=o.map(u=>new kr(u));return X(t,{code:F.invalid_union,unionErrors:c}),ke}}get options(){return this._def.options}}oo.create=(r,e)=>new oo({options:r,typeName:Ee.ZodUnion,...Me(e)});const On=r=>r instanceof lo?On(r.schema):r instanceof Wr?On(r.innerType()):r instanceof uo?[r.value]:r instanceof Yn?r.options:r instanceof fo?ot.objectValues(r.enum):r instanceof ho?On(r._def.innerType):r instanceof io?[void 0]:r instanceof so?[null]:r instanceof ln?[void 0,...On(r.unwrap())]:r instanceof Jn?[null,...On(r.unwrap())]:r instanceof bf||r instanceof go?On(r.unwrap()):r instanceof po?On(r._def.innerType):[];class Ic extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.object)return X(t,{code:F.invalid_type,expected:ie.object,received:t.parsedType}),ke;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(X(t,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ke)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const o=On(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new Ic({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Me(n)})}}function wf(r,e){const t=qn(r),n=qn(e);if(r===e)return{valid:!0,data:r};if(t===ie.object&&n===ie.object){const i=ot.objectKeys(e),s=ot.objectKeys(r).filter(c=>i.indexOf(c)!==-1),o={...r,...e};for(const c of s){const u=wf(r[c],e[c]);if(!u.valid)return{valid:!1};o[c]=u.data}return{valid:!0,data:o}}else if(t===ie.array&&n===ie.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<r.length;s++){const o=r[s],c=e[s],u=wf(o,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return t===ie.date&&n===ie.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ao extends Ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=(s,o)=>{if(gf(s)||gf(o))return ke;const c=wf(s.value,o.value);return c.valid?((vf(s)||vf(o))&&t.dirty(),{status:t.value,value:c.data}):(X(n,{code:F.invalid_intersection_types}),ke)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ao.create=(r,e,t)=>new ao({left:r,right:e,typeName:Ee.ZodIntersection,...Me(t)});class cn extends Ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.array)return X(n,{code:F.invalid_type,expected:ie.array,received:n.parsedType}),ke;if(n.data.length<this._def.items.length)return X(n,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&n.data.length>this._def.items.length&&(X(n,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((o,c)=>{const u=this._def.items[c]||this._def.rest;return u?u._parse(new an(n,o,n.path,c)):null}).filter(o=>!!o);return n.common.async?Promise.all(s).then(o=>ir.mergeArray(t,o)):ir.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new cn({...this._def,rest:e})}}cn.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new cn({items:r,typeName:Ee.ZodTuple,rest:null,...Me(e)})};class co extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.object)return X(n,{code:F.invalid_type,expected:ie.object,received:n.parsedType}),ke;const i=[],s=this._def.keyType,o=this._def.valueType;for(const c in n.data)i.push({key:s._parse(new an(n,c,n.path,c)),value:o._parse(new an(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?ir.mergeObjectAsync(t,i):ir.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ke?new co({keyType:e,valueType:t,typeName:Ee.ZodRecord,...Me(n)}):new co({keyType:qr.create(),valueType:e,typeName:Ee.ZodRecord,...Me(t)})}}class kc extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.map)return X(n,{code:F.invalid_type,expected:ie.map,received:n.parsedType}),ke;const i=this._def.keyType,s=this._def.valueType,o=[...n.data.entries()].map(([c,u],h)=>({key:i._parse(new an(n,c,n.path,[h,"key"])),value:s._parse(new an(n,u,n.path,[h,"value"]))}));if(n.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const u of o){const h=await u.key,m=await u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const u of o){const h=u.key,m=u.value;if(h.status==="aborted"||m.status==="aborted")return ke;(h.status==="dirty"||m.status==="dirty")&&t.dirty(),c.set(h.value,m.value)}return{status:t.value,value:c}}}}kc.create=(r,e,t)=>new kc({valueType:e,keyType:r,typeName:Ee.ZodMap,...Me(t)});class Ii extends Ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ie.set)return X(n,{code:F.invalid_type,expected:ie.set,received:n.parsedType}),ke;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(X(n,{code:F.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(X(n,{code:F.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function o(u){const h=new Set;for(const m of u){if(m.status==="aborted")return ke;m.status==="dirty"&&t.dirty(),h.add(m.value)}return{status:t.value,value:h}}const c=[...n.data.values()].map((u,h)=>s._parse(new an(n,u,n.path,h)));return n.common.async?Promise.all(c).then(u=>o(u)):o(c)}min(e,t){return new Ii({...this._def,minSize:{value:e,message:xe.toString(t)}})}max(e,t){return new Ii({...this._def,maxSize:{value:e,message:xe.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ii.create=(r,e)=>new Ii({valueType:r,minSize:null,maxSize:null,typeName:Ee.ZodSet,...Me(e)});class cs extends Ke{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.function)return X(t,{code:F.invalid_type,expected:ie.function,received:t.parsedType}),ke;function n(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_arguments,argumentsError:u}})}function i(c,u){return Ac({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xc(),is].filter(h=>!!h),issueData:{code:F.invalid_return_type,returnTypeError:u}})}const s={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ls){const c=this;return hr(async function(...u){const h=new kr([]),m=await c._def.args.parseAsync(u,s).catch(N=>{throw h.addIssue(n(u,N)),h}),x=await Reflect.apply(o,this,m);return await c._def.returns._def.type.parseAsync(x,s).catch(N=>{throw h.addIssue(i(x,N)),h})})}else{const c=this;return hr(function(...u){const h=c._def.args.safeParse(u,s);if(!h.success)throw new kr([n(u,h.error)]);const m=Reflect.apply(o,this,h.data),x=c._def.returns.safeParse(m,s);if(!x.success)throw new kr([i(m,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new cs({...this._def,args:cn.create(e).rest(Ei.create())})}returns(e){return new cs({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new cs({args:e||cn.create([]).rest(Ei.create()),returns:t||Ei.create(),typeName:Ee.ZodFunction,...Me(n)})}}class lo extends Ke{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}lo.create=(r,e)=>new lo({getter:r,typeName:Ee.ZodLazy,...Me(e)});class uo extends Ke{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return X(t,{received:t.data,code:F.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}uo.create=(r,e)=>new uo({value:r,typeName:Ee.ZodLiteral,...Me(e)});function S0(r,e){return new Yn({values:r,typeName:Ee.ZodEnum,...Me(e)})}class Yn extends Ke{constructor(){super(...arguments),to.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{expected:ot.joinValues(n),received:t.parsedType,code:F.invalid_type}),ke}if(Sc(this,to)||m0(this,to,new Set(this._def.values)),!Sc(this,to).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return X(t,{received:t.data,code:F.invalid_enum_value,options:n}),ke}return hr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Yn.create(e,{...this._def,...t})}exclude(e,t=this._def){return Yn.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}to=new WeakMap,Yn.create=S0;class fo extends Ke{constructor(){super(...arguments),ro.set(this,void 0)}_parse(e){const t=ot.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ie.string&&n.parsedType!==ie.number){const i=ot.objectValues(t);return X(n,{expected:ot.joinValues(i),received:n.parsedType,code:F.invalid_type}),ke}if(Sc(this,ro)||m0(this,ro,new Set(ot.getValidEnumValues(this._def.values))),!Sc(this,ro).has(e.data)){const i=ot.objectValues(t);return X(n,{received:n.data,code:F.invalid_enum_value,options:i}),ke}return hr(e.data)}get enum(){return this._def.values}}ro=new WeakMap,fo.create=(r,e)=>new fo({values:r,typeName:Ee.ZodNativeEnum,...Me(e)});class ls extends Ke{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ie.promise&&t.common.async===!1)return X(t,{code:F.invalid_type,expected:ie.promise,received:t.parsedType}),ke;const n=t.parsedType===ie.promise?t.data:Promise.resolve(t.data);return hr(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ls.create=(r,e)=>new ls({type:r,typeName:Ee.ZodPromise,...Me(e)});class Wr extends Ke{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{X(n,o),o.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(n.data,s);if(n.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return ke;const u=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return u.status==="aborted"?ke:u.status==="dirty"||t.value==="dirty"?ss(u.value):u});{if(t.value==="aborted")return ke;const c=this._def.schema._parseSync({data:o,path:n.path,parent:n});return c.status==="aborted"?ke:c.status==="dirty"||t.value==="dirty"?ss(c.value):c}}if(i.type==="refinement"){const o=c=>{const u=i.refinement(c,s);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===!1){const c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?ke:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?ke:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(i.type==="transform")if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Qs(o))return o;const c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>Qs(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:t.value,value:c})):o);ot.assertNever(i)}}Wr.create=(r,e,t)=>new Wr({schema:r,typeName:Ee.ZodEffects,effect:e,...Me(t)}),Wr.createWithPreprocess=(r,e,t)=>new Wr({schema:e,effect:{type:"preprocess",transform:r},typeName:Ee.ZodEffects,...Me(t)});class ln extends Ke{_parse(e){return this._getType(e)===ie.undefined?hr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ln.create=(r,e)=>new ln({innerType:r,typeName:Ee.ZodOptional,...Me(e)});class Jn extends Ke{_parse(e){return this._getType(e)===ie.null?hr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Jn.create=(r,e)=>new Jn({innerType:r,typeName:Ee.ZodNullable,...Me(e)});class ho extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ie.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ho.create=(r,e)=>new ho({innerType:r,typeName:Ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Me(e)});class po extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return eo(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new kr(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}po.create=(r,e)=>new po({innerType:r,typeName:Ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Me(e)});class Cc extends Ke{_parse(e){if(this._getType(e)!==ie.nan){const n=this._getOrReturnCtx(e);return X(n,{code:F.invalid_type,expected:ie.nan,received:n.parsedType}),ke}return{status:"valid",value:e.data}}}Cc.create=r=>new Cc({typeName:Ee.ZodNaN,...Me(r)});const Cm=Symbol("zod_brand");class bf extends Ke{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class yo extends Ke{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ke:s.status==="dirty"?(t.dirty(),ss(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ke:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new yo({in:e,out:t,typeName:Ee.ZodPipeline})}}class go extends Ke{_parse(e){const t=this._def.innerType._parse(e),n=i=>(Qs(i)&&(i.value=Object.freeze(i.value)),i);return eo(t)?t.then(i=>n(i)):n(t)}unwrap(){return this._def.innerType}}go.create=(r,e)=>new go({innerType:r,typeName:Ee.ZodReadonly,...Me(e)});function _0(r,e={},t){return r?os.create().superRefine((n,i)=>{var s,o;if(!r(n)){const c=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(o=(s=c.fatal)!==null&&s!==void 0?s:t)!==null&&o!==void 0?o:!0,h=typeof c=="string"?{message:c}:c;i.addIssue({code:"custom",...h,fatal:u})}}):os.create()}const Bm={object:Ot.lazycreate};var Ee;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Ee||(Ee={}));const Om=(r,e={message:`Input not instance of ${r.name}`})=>_0(t=>t instanceof r,e),E0=qr.create,I0=Zn.create,Tm=Cc.create,Nm=Wn.create,k0=no.create,Pm=_i.create,jm=_c.create,Rm=io.create,Um=so.create,Dm=os.create,$m=Ei.create,Mm=Bn.create,Vm=Ec.create,Lm=Zr.create,Hm=Ot.create,Fm=Ot.strictCreate,zm=oo.create,Gm=Ic.create,Km=ao.create,qm=cn.create,Zm=co.create,Wm=kc.create,Ym=Ii.create,Jm=cs.create,Xm=lo.create,Qm=uo.create,e1=Yn.create,t1=fo.create,r1=ls.create,C0=Wr.create,n1=ln.create,i1=Jn.create,s1=Wr.createWithPreprocess,o1=yo.create;var Tt=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:fm,getErrorMap:xc,makeIssue:Ac,EMPTY_PATH:hm,addIssueToContext:X,ParseStatus:ir,INVALID:ke,DIRTY:ss,OK:hr,isAborted:gf,isDirty:vf,isValid:Qs,isAsync:eo,get util(){return ot},get objectUtil(){return yf},ZodParsedType:ie,getParsedType:qn,ZodType:Ke,datetimeRegex:A0,ZodString:qr,ZodNumber:Zn,ZodBigInt:Wn,ZodBoolean:no,ZodDate:_i,ZodSymbol:_c,ZodUndefined:io,ZodNull:so,ZodAny:os,ZodUnknown:Ei,ZodNever:Bn,ZodVoid:Ec,ZodArray:Zr,ZodObject:Ot,ZodUnion:oo,ZodDiscriminatedUnion:Ic,ZodIntersection:ao,ZodTuple:cn,ZodRecord:co,ZodMap:kc,ZodSet:Ii,ZodFunction:cs,ZodLazy:lo,ZodLiteral:uo,ZodEnum:Yn,ZodNativeEnum:fo,ZodPromise:ls,ZodEffects:Wr,ZodTransformer:Wr,ZodOptional:ln,ZodNullable:Jn,ZodDefault:ho,ZodCatch:po,ZodNaN:Cc,BRAND:Cm,ZodBranded:bf,ZodPipeline:yo,ZodReadonly:go,custom:_0,Schema:Ke,ZodSchema:Ke,late:Bm,get ZodFirstPartyTypeKind(){return Ee},coerce:{string:r=>qr.create({...r,coerce:!0}),number:r=>Zn.create({...r,coerce:!0}),boolean:r=>no.create({...r,coerce:!0}),bigint:r=>Wn.create({...r,coerce:!0}),date:r=>_i.create({...r,coerce:!0})},any:Dm,array:Lm,bigint:Nm,boolean:k0,date:Pm,discriminatedUnion:Gm,effect:C0,enum:e1,function:Jm,instanceof:Om,intersection:Km,lazy:Xm,literal:Qm,map:Wm,nan:Tm,nativeEnum:t1,never:Mm,null:Um,nullable:i1,number:I0,object:Hm,oboolean:()=>k0().optional(),onumber:()=>I0().optional(),optional:n1,ostring:()=>E0().optional(),pipeline:o1,preprocess:s1,promise:r1,record:Zm,set:Ym,strictObject:Fm,string:E0,symbol:jm,transformer:C0,tuple:qm,undefined:Rm,union:zm,unknown:$m,void:Vm,NEVER:ke,ZodIssueCode:F,quotelessJson:um,ZodError:kr});const Bc=new Uint8Array([48,130,2,17,48,130,1,150,160,3,2,1,2,2,17,0,249,49,117,104,27,144,175,225,29,70,204,180,228,231,248,86,48,10,6,8,42,134,72,206,61,4,3,3,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,30,23,13,49,57,49,48,50,56,49,51,50,56,48,53,90,23,13,52,57,49,48,50,56,49,52,50,56,48,53,90,48,73,49,11,48,9,6,3,85,4,6,19,2,85,83,49,15,48,13,6,3,85,4,10,12,6,65,109,97,122,111,110,49,12,48,10,6,3,85,4,11,12,3,65,87,83,49,27,48,25,6,3,85,4,3,12,18,97,119,115,46,110,105,116,114,111,45,101,110,99,108,97,118,101,115,48,118,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,98,0,4,252,2,84,235,166,8,193,243,104,112,226,154,218,144,190,70,56,50,146,115,110,137,75,255,246,114,217,137,68,75,80,81,229,52,164,177,246,219,227,192,188,88,26,50,183,177,118,7,14,222,18,214,154,63,234,33,27,102,231,82,207,125,209,221,9,95,111,19,112,244,23,8,67,217,220,16,1,33,228,207,99,1,40,9,102,68,135,201,121,98,132,48,77,197,63,244,163,66,48,64,48,15,6,3,85,29,19,1,1,255,4,5,48,3,1,1,255,48,29,6,3,85,29,14,4,22,4,20,144,37,181,13,217,5,71,231,150,195,150,250,114,157,207,153,169,223,75,150,48,14,6,3,85,29,15,1,1,255,4,4,3,2,1,134,48,10,6,8,42,134,72,206,61,4,3,3,3,105,0,48,102,2,49,0,163,127,47,145,161,201,189,94,231,184,98,124,22,152,210,85,3,142,31,3,67,249,91,99,169,98,140,61,57,128,149,69,161,30,188,191,46,59,85,216,174,238,113,180,195,214,173,243,2,49,0,162,243,155,22,5,178,112,40,165,221,75,160,105,181,1,110,101,180,251,222,143,224,6,29,106,83,25,127,156,218,245,217,67,188,97,252,43,235,3,203,111,238,141,35,2,243,223,246]);if(!Bc||Bc.length===0)throw new Error("AWS root certificate is empty or not loaded correctly");const a1=Tt.object({module_id:Tt.string().min(1),digest:Tt.literal("SHA384"),timestamp:Tt.number().min(1677721600),pcrs:Tt.map(Tt.number(),Tt.instanceof(Uint8Array)),certificate:Tt.instanceof(Uint8Array),cabundle:Tt.array(Tt.instanceof(Uint8Array)),public_key:Tt.nullable(Tt.instanceof(Uint8Array)),user_data:Tt.nullable(Tt.instanceof(Uint8Array)),nonce:Tt.nullable(Tt.instanceof(Uint8Array))}),c1=Tt.object({protected:Tt.instanceof(Uint8Array),payload:Tt.instanceof(Uint8Array),signature:Tt.instanceof(Uint8Array)});async function l1(r){try{if(!r)throw new Error("Attestation document is empty.");const e=gs(r),t=bc(e),n=t[0],i=t[2],s=t[3];return c1.parse({protected:n,payload:i,signature:s})}catch(e){throw console.error("Error parsing document data:",e),new Error("Failed to parse document data.")}}async function u1(r){try{const e=bc(r);return a1.parse(e)}catch(e){throw console.error("Error parsing document payload:",e),new Error("Failed to parse document payload.")}}function f1(r,e){const t=["Signature1",r,new Uint8Array(0),e];return gc(t)}async function h1(r,e){try{console.log("SIGNATURE:"),console.log($r(r.signature));const t=f1(r.protected,r.payload),n=await crypto.subtle.digest("SHA-384",t);return console.log("SIGNATURE STRUCTURE DIGEST:"),console.log($r(new Uint8Array(n))),await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},e,r.signature,t)}catch(t){throw console.error("Error verifying signature:",t),t instanceof Error?new Error(`Signature verification failed: ${t.message}`):new Error(`Signature verification failed: ${t}`)}}async function ki(r,e,t){try{const n=await l1(r),i=await u1(n.payload);if(!i.nonce)throw new Error("Attestation document does not have a nonce.");const o=new TextDecoder("utf-8").decode(i.nonce);if(t!==o)throw console.log("Nonce mismatch"),console.log("Provided nonce:",t),console.log("Attestation document nonce:",o),new Error("Attestation document's nonce does not match the provided nonce.");const c=[],u=$r(i.cabundle[0]);if(u!==$r(e))throw console.error("Root cert doesn't match first cert"),console.log("First cert base64:",u),console.log("Trusted root cert base64:",$r(e)),new Error("Root cert does not match first cert in attestation document.");for(let I=0;I<i.cabundle.length;I++){const P=new xi(i.cabundle[I]);c.push(P)}const h=new xi(i.certificate),x=await new Uv({certificates:c}).build(h);console.log("Chain items:",x);const N=new Date().getTime();for(let I=0;I<x.length;I++){const P=x[I];if(console.log("CERT: ",I),console.log(P.subject),console.log("Not before:",P.notBefore),console.log("Not after:",P.notAfter),console.log(P.toString("pem")),P.notBefore.getTime()>N||P.notAfter.getTime()<N)throw new Error("Certificate is expired.");console.log(`Certificate ${I} is not expired.`)}if(x.length!==i.cabundle.length+1)throw new Error("Certificate chain length does not match length of cabundle.");const v=h.publicKey;console.log("PUBLIC KEY:"),console.log($r(new Uint8Array(v.rawData)));const A=await v.export(),O=await h1(n,A);if(console.log("Signature verified:",O),!O)throw new Error("Signature verification failed.");return i}catch(n){throw console.error("Error verifying attestation document:",n),n}}const d1=Tt.object({public_key:Tt.nullable(Tt.instanceof(Uint8Array))});async function p1(r){const e=gs(r),n=bc(e)[2],i=bc(n);return await d1.parse(i)}async function y1(r,e){try{const t=await R1(r,e),n=e||C1();return n&&(n==="http://127.0.0.1:3000"||n==="http://localhost:3000"||n==="http://0.0.0.0:3000")?(console.log("DEV MODE: Using fake attestation document"),await p1(t)):await ki(t,Bc,r)}catch(t){throw t instanceof Error?(console.error("Error verifying attestation document:",t),new Error(`Couldn't process attestation document: ${t.message}`)):(console.error("Error verifying attestation document:",t),new Error("Couldn't process attestation document."))}}function g1(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var B0={exports:{}};const v1=Hy(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(r){(function(e){var t=function(l){var p,d=new Float64Array(16);if(l)for(p=0;p<l.length;p++)d[p]=l[p];return d},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var o=t(),c=t([1]),u=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),x=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),G=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),N=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(l,p,d,a){l[p]=d>>24&255,l[p+1]=d>>16&255,l[p+2]=d>>8&255,l[p+3]=d&255,l[p+4]=a>>24&255,l[p+5]=a>>16&255,l[p+6]=a>>8&255,l[p+7]=a&255}function A(l,p,d,a,g){var S,E=0;for(S=0;S<g;S++)E|=l[p+S]^d[a+S];return(1&E-1>>>8)-1}function O(l,p,d,a){return A(l,p,d,a,16)}function I(l,p,d,a){return A(l,p,d,a,32)}function P(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Ve=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,De=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Ve,_e=De,Le=Oe,Ge=Ne,He=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,Le^=w<<9|w>>>23,w=Le+j|0,Se^=w<<13|w>>>19,w=Se+Le|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=He+L|0,ye^=w<<7|w>>>25,w=ye+He|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,He^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=He+Ge|0,_e^=w<<7|w>>>25,w=_e+He|0,Le^=w<<9|w>>>23,w=Le+_e|0,Ge^=w<<13|w>>>19,w=Ge+Le|0,He^=w<<18|w>>>14;pe=pe+g|0,Se=Se+S|0,re=re+E|0,ye=ye+U|0,me=me+z|0,J=J+we|0,C=C+Q|0,B=B+ft|0,V=V+le|0,j=j+Ce|0,D=D+Be|0,L=L+Ve|0,_e=_e+De|0,Le=Le+Oe|0,Ge=Ge+Ne|0,He=He+Te|0,l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=Se>>>0&255,l[5]=Se>>>8&255,l[6]=Se>>>16&255,l[7]=Se>>>24&255,l[8]=re>>>0&255,l[9]=re>>>8&255,l[10]=re>>>16&255,l[11]=re>>>24&255,l[12]=ye>>>0&255,l[13]=ye>>>8&255,l[14]=ye>>>16&255,l[15]=ye>>>24&255,l[16]=me>>>0&255,l[17]=me>>>8&255,l[18]=me>>>16&255,l[19]=me>>>24&255,l[20]=J>>>0&255,l[21]=J>>>8&255,l[22]=J>>>16&255,l[23]=J>>>24&255,l[24]=C>>>0&255,l[25]=C>>>8&255,l[26]=C>>>16&255,l[27]=C>>>24&255,l[28]=B>>>0&255,l[29]=B>>>8&255,l[30]=B>>>16&255,l[31]=B>>>24&255,l[32]=V>>>0&255,l[33]=V>>>8&255,l[34]=V>>>16&255,l[35]=V>>>24&255,l[36]=j>>>0&255,l[37]=j>>>8&255,l[38]=j>>>16&255,l[39]=j>>>24&255,l[40]=D>>>0&255,l[41]=D>>>8&255,l[42]=D>>>16&255,l[43]=D>>>24&255,l[44]=L>>>0&255,l[45]=L>>>8&255,l[46]=L>>>16&255,l[47]=L>>>24&255,l[48]=_e>>>0&255,l[49]=_e>>>8&255,l[50]=_e>>>16&255,l[51]=_e>>>24&255,l[52]=Le>>>0&255,l[53]=Le>>>8&255,l[54]=Le>>>16&255,l[55]=Le>>>24&255,l[56]=Ge>>>0&255,l[57]=Ge>>>8&255,l[58]=Ge>>>16&255,l[59]=Ge>>>24&255,l[60]=He>>>0&255,l[61]=He>>>8&255,l[62]=He>>>16&255,l[63]=He>>>24&255}function R(l,p,d,a){for(var g=a[0]&255|(a[1]&255)<<8|(a[2]&255)<<16|(a[3]&255)<<24,S=d[0]&255|(d[1]&255)<<8|(d[2]&255)<<16|(d[3]&255)<<24,E=d[4]&255|(d[5]&255)<<8|(d[6]&255)<<16|(d[7]&255)<<24,U=d[8]&255|(d[9]&255)<<8|(d[10]&255)<<16|(d[11]&255)<<24,z=d[12]&255|(d[13]&255)<<8|(d[14]&255)<<16|(d[15]&255)<<24,we=a[4]&255|(a[5]&255)<<8|(a[6]&255)<<16|(a[7]&255)<<24,Q=p[0]&255|(p[1]&255)<<8|(p[2]&255)<<16|(p[3]&255)<<24,ft=p[4]&255|(p[5]&255)<<8|(p[6]&255)<<16|(p[7]&255)<<24,le=p[8]&255|(p[9]&255)<<8|(p[10]&255)<<16|(p[11]&255)<<24,Ce=p[12]&255|(p[13]&255)<<8|(p[14]&255)<<16|(p[15]&255)<<24,Be=a[8]&255|(a[9]&255)<<8|(a[10]&255)<<16|(a[11]&255)<<24,Ve=d[16]&255|(d[17]&255)<<8|(d[18]&255)<<16|(d[19]&255)<<24,De=d[20]&255|(d[21]&255)<<8|(d[22]&255)<<16|(d[23]&255)<<24,Oe=d[24]&255|(d[25]&255)<<8|(d[26]&255)<<16|(d[27]&255)<<24,Ne=d[28]&255|(d[29]&255)<<8|(d[30]&255)<<16|(d[31]&255)<<24,Te=a[12]&255|(a[13]&255)<<8|(a[14]&255)<<16|(a[15]&255)<<24,pe=g,Se=S,re=E,ye=U,me=z,J=we,C=Q,B=ft,V=le,j=Ce,D=Be,L=Ve,_e=De,Le=Oe,Ge=Ne,He=Te,w,Ye=0;Ye<20;Ye+=2)w=pe+_e|0,me^=w<<7|w>>>25,w=me+pe|0,V^=w<<9|w>>>23,w=V+me|0,_e^=w<<13|w>>>19,w=_e+V|0,pe^=w<<18|w>>>14,w=J+Se|0,j^=w<<7|w>>>25,w=j+J|0,Le^=w<<9|w>>>23,w=Le+j|0,Se^=w<<13|w>>>19,w=Se+Le|0,J^=w<<18|w>>>14,w=D+C|0,Ge^=w<<7|w>>>25,w=Ge+D|0,re^=w<<9|w>>>23,w=re+Ge|0,C^=w<<13|w>>>19,w=C+re|0,D^=w<<18|w>>>14,w=He+L|0,ye^=w<<7|w>>>25,w=ye+He|0,B^=w<<9|w>>>23,w=B+ye|0,L^=w<<13|w>>>19,w=L+B|0,He^=w<<18|w>>>14,w=pe+ye|0,Se^=w<<7|w>>>25,w=Se+pe|0,re^=w<<9|w>>>23,w=re+Se|0,ye^=w<<13|w>>>19,w=ye+re|0,pe^=w<<18|w>>>14,w=J+me|0,C^=w<<7|w>>>25,w=C+J|0,B^=w<<9|w>>>23,w=B+C|0,me^=w<<13|w>>>19,w=me+B|0,J^=w<<18|w>>>14,w=D+j|0,L^=w<<7|w>>>25,w=L+D|0,V^=w<<9|w>>>23,w=V+L|0,j^=w<<13|w>>>19,w=j+V|0,D^=w<<18|w>>>14,w=He+Ge|0,_e^=w<<7|w>>>25,w=_e+He|0,Le^=w<<9|w>>>23,w=Le+_e|0,Ge^=w<<13|w>>>19,w=Ge+Le|0,He^=w<<18|w>>>14;l[0]=pe>>>0&255,l[1]=pe>>>8&255,l[2]=pe>>>16&255,l[3]=pe>>>24&255,l[4]=J>>>0&255,l[5]=J>>>8&255,l[6]=J>>>16&255,l[7]=J>>>24&255,l[8]=D>>>0&255,l[9]=D>>>8&255,l[10]=D>>>16&255,l[11]=D>>>24&255,l[12]=He>>>0&255,l[13]=He>>>8&255,l[14]=He>>>16&255,l[15]=He>>>24&255,l[16]=C>>>0&255,l[17]=C>>>8&255,l[18]=C>>>16&255,l[19]=C>>>24&255,l[20]=B>>>0&255,l[21]=B>>>8&255,l[22]=B>>>16&255,l[23]=B>>>24&255,l[24]=V>>>0&255,l[25]=V>>>8&255,l[26]=V>>>16&255,l[27]=V>>>24&255,l[28]=j>>>0&255,l[29]=j>>>8&255,l[30]=j>>>16&255,l[31]=j>>>24&255}function fe(l,p,d,a){P(l,p,d,a)}function qe(l,p,d,a){R(l,p,d,a)}var Je=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Re(l,p,d,a,g,S,E){var U=new Uint8Array(16),z=new Uint8Array(64),we,Q;for(Q=0;Q<16;Q++)U[Q]=0;for(Q=0;Q<8;Q++)U[Q]=S[Q];for(;g>=64;){for(fe(z,U,E,Je),Q=0;Q<64;Q++)l[p+Q]=d[a+Q]^z[Q];for(we=1,Q=8;Q<16;Q++)we=we+(U[Q]&255)|0,U[Q]=we&255,we>>>=8;g-=64,p+=64,a+=64}if(g>0)for(fe(z,U,E,Je),Q=0;Q<g;Q++)l[p+Q]=d[a+Q]^z[Q];return 0}function W(l,p,d,a,g){var S=new Uint8Array(16),E=new Uint8Array(64),U,z;for(z=0;z<16;z++)S[z]=0;for(z=0;z<8;z++)S[z]=a[z];for(;d>=64;){for(fe(E,S,g,Je),z=0;z<64;z++)l[p+z]=E[z];for(U=1,z=8;z<16;z++)U=U+(S[z]&255)|0,S[z]=U&255,U>>>=8;d-=64,p+=64}if(d>0)for(fe(E,S,g,Je),z=0;z<d;z++)l[p+z]=E[z];return 0}function se(l,p,d,a,g){var S=new Uint8Array(32);qe(S,a,g,Je);for(var E=new Uint8Array(8),U=0;U<8;U++)E[U]=a[U+16];return W(l,p,d,E,S)}function oe(l,p,d,a,g,S,E){var U=new Uint8Array(32);qe(U,S,E,Je);for(var z=new Uint8Array(8),we=0;we<8;we++)z[we]=S[we+16];return Re(l,p,d,a,g,z,U)}var Ae=function(l){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var p,d,a,g,S,E,U,z;p=l[0]&255|(l[1]&255)<<8,this.r[0]=p&8191,d=l[2]&255|(l[3]&255)<<8,this.r[1]=(p>>>13|d<<3)&8191,a=l[4]&255|(l[5]&255)<<8,this.r[2]=(d>>>10|a<<6)&7939,g=l[6]&255|(l[7]&255)<<8,this.r[3]=(a>>>7|g<<9)&8191,S=l[8]&255|(l[9]&255)<<8,this.r[4]=(g>>>4|S<<12)&255,this.r[5]=S>>>1&8190,E=l[10]&255|(l[11]&255)<<8,this.r[6]=(S>>>14|E<<2)&8191,U=l[12]&255|(l[13]&255)<<8,this.r[7]=(E>>>11|U<<5)&8065,z=l[14]&255|(l[15]&255)<<8,this.r[8]=(U>>>8|z<<8)&8191,this.r[9]=z>>>5&127,this.pad[0]=l[16]&255|(l[17]&255)<<8,this.pad[1]=l[18]&255|(l[19]&255)<<8,this.pad[2]=l[20]&255|(l[21]&255)<<8,this.pad[3]=l[22]&255|(l[23]&255)<<8,this.pad[4]=l[24]&255|(l[25]&255)<<8,this.pad[5]=l[26]&255|(l[27]&255)<<8,this.pad[6]=l[28]&255|(l[29]&255)<<8,this.pad[7]=l[30]&255|(l[31]&255)<<8};Ae.prototype.blocks=function(l,p,d){for(var a=this.fin?0:2048,g,S,E,U,z,we,Q,ft,le,Ce,Be,Ve,De,Oe,Ne,Te,pe,Se,re,ye=this.h[0],me=this.h[1],J=this.h[2],C=this.h[3],B=this.h[4],V=this.h[5],j=this.h[6],D=this.h[7],L=this.h[8],_e=this.h[9],Le=this.r[0],Ge=this.r[1],He=this.r[2],w=this.r[3],Ye=this.r[4],ht=this.r[5],dt=this.r[6],Ze=this.r[7],lt=this.r[8],ut=this.r[9];d>=16;)g=l[p+0]&255|(l[p+1]&255)<<8,ye+=g&8191,S=l[p+2]&255|(l[p+3]&255)<<8,me+=(g>>>13|S<<3)&8191,E=l[p+4]&255|(l[p+5]&255)<<8,J+=(S>>>10|E<<6)&8191,U=l[p+6]&255|(l[p+7]&255)<<8,C+=(E>>>7|U<<9)&8191,z=l[p+8]&255|(l[p+9]&255)<<8,B+=(U>>>4|z<<12)&8191,V+=z>>>1&8191,we=l[p+10]&255|(l[p+11]&255)<<8,j+=(z>>>14|we<<2)&8191,Q=l[p+12]&255|(l[p+13]&255)<<8,D+=(we>>>11|Q<<5)&8191,ft=l[p+14]&255|(l[p+15]&255)<<8,L+=(Q>>>8|ft<<8)&8191,_e+=ft>>>5|a,le=0,Ce=le,Ce+=ye*Le,Ce+=me*(5*ut),Ce+=J*(5*lt),Ce+=C*(5*Ze),Ce+=B*(5*dt),le=Ce>>>13,Ce&=8191,Ce+=V*(5*ht),Ce+=j*(5*Ye),Ce+=D*(5*w),Ce+=L*(5*He),Ce+=_e*(5*Ge),le+=Ce>>>13,Ce&=8191,Be=le,Be+=ye*Ge,Be+=me*Le,Be+=J*(5*ut),Be+=C*(5*lt),Be+=B*(5*Ze),le=Be>>>13,Be&=8191,Be+=V*(5*dt),Be+=j*(5*ht),Be+=D*(5*Ye),Be+=L*(5*w),Be+=_e*(5*He),le+=Be>>>13,Be&=8191,Ve=le,Ve+=ye*He,Ve+=me*Ge,Ve+=J*Le,Ve+=C*(5*ut),Ve+=B*(5*lt),le=Ve>>>13,Ve&=8191,Ve+=V*(5*Ze),Ve+=j*(5*dt),Ve+=D*(5*ht),Ve+=L*(5*Ye),Ve+=_e*(5*w),le+=Ve>>>13,Ve&=8191,De=le,De+=ye*w,De+=me*He,De+=J*Ge,De+=C*Le,De+=B*(5*ut),le=De>>>13,De&=8191,De+=V*(5*lt),De+=j*(5*Ze),De+=D*(5*dt),De+=L*(5*ht),De+=_e*(5*Ye),le+=De>>>13,De&=8191,Oe=le,Oe+=ye*Ye,Oe+=me*w,Oe+=J*He,Oe+=C*Ge,Oe+=B*Le,le=Oe>>>13,Oe&=8191,Oe+=V*(5*ut),Oe+=j*(5*lt),Oe+=D*(5*Ze),Oe+=L*(5*dt),Oe+=_e*(5*ht),le+=Oe>>>13,Oe&=8191,Ne=le,Ne+=ye*ht,Ne+=me*Ye,Ne+=J*w,Ne+=C*He,Ne+=B*Ge,le=Ne>>>13,Ne&=8191,Ne+=V*Le,Ne+=j*(5*ut),Ne+=D*(5*lt),Ne+=L*(5*Ze),Ne+=_e*(5*dt),le+=Ne>>>13,Ne&=8191,Te=le,Te+=ye*dt,Te+=me*ht,Te+=J*Ye,Te+=C*w,Te+=B*He,le=Te>>>13,Te&=8191,Te+=V*Ge,Te+=j*Le,Te+=D*(5*ut),Te+=L*(5*lt),Te+=_e*(5*Ze),le+=Te>>>13,Te&=8191,pe=le,pe+=ye*Ze,pe+=me*dt,pe+=J*ht,pe+=C*Ye,pe+=B*w,le=pe>>>13,pe&=8191,pe+=V*He,pe+=j*Ge,pe+=D*Le,pe+=L*(5*ut),pe+=_e*(5*lt),le+=pe>>>13,pe&=8191,Se=le,Se+=ye*lt,Se+=me*Ze,Se+=J*dt,Se+=C*ht,Se+=B*Ye,le=Se>>>13,Se&=8191,Se+=V*w,Se+=j*He,Se+=D*Ge,Se+=L*Le,Se+=_e*(5*ut),le+=Se>>>13,Se&=8191,re=le,re+=ye*ut,re+=me*lt,re+=J*Ze,re+=C*dt,re+=B*ht,le=re>>>13,re&=8191,re+=V*Ye,re+=j*w,re+=D*He,re+=L*Ge,re+=_e*Le,le+=re>>>13,re&=8191,le=(le<<2)+le|0,le=le+Ce|0,Ce=le&8191,le=le>>>13,Be+=le,ye=Ce,me=Be,J=Ve,C=De,B=Oe,V=Ne,j=Te,D=pe,L=Se,_e=re,p+=16,d-=16;this.h[0]=ye,this.h[1]=me,this.h[2]=J,this.h[3]=C,this.h[4]=B,this.h[5]=V,this.h[6]=j,this.h[7]=D,this.h[8]=L,this.h[9]=_e},Ae.prototype.finish=function(l,p){var d=new Uint16Array(10),a,g,S,E;if(this.leftover){for(E=this.leftover,this.buffer[E++]=1;E<16;E++)this.buffer[E]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(a=this.h[1]>>>13,this.h[1]&=8191,E=2;E<10;E++)this.h[E]+=a,a=this.h[E]>>>13,this.h[E]&=8191;for(this.h[0]+=a*5,a=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=a,a=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=a,d[0]=this.h[0]+5,a=d[0]>>>13,d[0]&=8191,E=1;E<10;E++)d[E]=this.h[E]+a,a=d[E]>>>13,d[E]&=8191;for(d[9]-=8192,g=(a^1)-1,E=0;E<10;E++)d[E]&=g;for(g=~g,E=0;E<10;E++)this.h[E]=this.h[E]&g|d[E];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,S=this.h[0]+this.pad[0],this.h[0]=S&65535,E=1;E<8;E++)S=(this.h[E]+this.pad[E]|0)+(S>>>16)|0,this.h[E]=S&65535;l[p+0]=this.h[0]>>>0&255,l[p+1]=this.h[0]>>>8&255,l[p+2]=this.h[1]>>>0&255,l[p+3]=this.h[1]>>>8&255,l[p+4]=this.h[2]>>>0&255,l[p+5]=this.h[2]>>>8&255,l[p+6]=this.h[3]>>>0&255,l[p+7]=this.h[3]>>>8&255,l[p+8]=this.h[4]>>>0&255,l[p+9]=this.h[4]>>>8&255,l[p+10]=this.h[5]>>>0&255,l[p+11]=this.h[5]>>>8&255,l[p+12]=this.h[6]>>>0&255,l[p+13]=this.h[6]>>>8&255,l[p+14]=this.h[7]>>>0&255,l[p+15]=this.h[7]>>>8&255},Ae.prototype.update=function(l,p,d){var a,g;if(this.leftover){for(g=16-this.leftover,g>d&&(g=d),a=0;a<g;a++)this.buffer[this.leftover+a]=l[p+a];if(d-=g,p+=g,this.leftover+=g,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(d>=16&&(g=d-d%16,this.blocks(l,p,g),p+=g,d-=g),d){for(a=0;a<d;a++)this.buffer[this.leftover+a]=l[p+a];this.leftover+=d}};function it(l,p,d,a,g,S){var E=new Ae(S);return E.update(d,a,g),E.finish(l,p),0}function It(l,p,d,a,g,S){var E=new Uint8Array(16);return it(E,0,d,a,g,S),O(l,p,E,0)}function Pt(l,p,d,a,g){var S;if(d<32)return-1;for(oe(l,0,p,0,d,a,g),it(l,16,l,32,d-32,l),S=0;S<16;S++)l[S]=0;return 0}function gt(l,p,d,a,g){var S,E=new Uint8Array(32);if(d<32||(se(E,0,32,a,g),It(p,16,p,32,d-32,E)!==0))return-1;for(oe(l,0,p,0,d,a,g),S=0;S<32;S++)l[S]=0;return 0}function Qe(l,p){var d;for(d=0;d<16;d++)l[d]=p[d]|0}function ce(l){var p,d,a=1;for(p=0;p<16;p++)d=l[p]+a+65535,a=Math.floor(d/65536),l[p]=d-a*65536;l[0]+=a-1+37*(a-1)}function Ie(l,p,d){for(var a,g=~(d-1),S=0;S<16;S++)a=g&(l[S]^p[S]),l[S]^=a,p[S]^=a}function wt(l,p){var d,a,g,S=t(),E=t();for(d=0;d<16;d++)E[d]=p[d];for(ce(E),ce(E),ce(E),a=0;a<2;a++){for(S[0]=E[0]-65517,d=1;d<15;d++)S[d]=E[d]-65535-(S[d-1]>>16&1),S[d-1]&=65535;S[15]=E[15]-32767-(S[14]>>16&1),g=S[15]>>16&1,S[14]&=65535,Ie(E,S,1-g)}for(d=0;d<16;d++)l[2*d]=E[d]&255,l[2*d+1]=E[d]>>8}function Vt(l,p){var d=new Uint8Array(32),a=new Uint8Array(32);return wt(d,l),wt(a,p),I(d,0,a,0)}function Lt(l){var p=new Uint8Array(32);return wt(p,l),p[0]&1}function he(l,p){var d;for(d=0;d<16;d++)l[d]=p[2*d]+(p[2*d+1]<<8);l[15]&=32767}function ct(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]+d[a]}function bt(l,p,d){for(var a=0;a<16;a++)l[a]=p[a]-d[a]}function ee(l,p,d){var a,g,S=0,E=0,U=0,z=0,we=0,Q=0,ft=0,le=0,Ce=0,Be=0,Ve=0,De=0,Oe=0,Ne=0,Te=0,pe=0,Se=0,re=0,ye=0,me=0,J=0,C=0,B=0,V=0,j=0,D=0,L=0,_e=0,Le=0,Ge=0,He=0,w=d[0],Ye=d[1],ht=d[2],dt=d[3],Ze=d[4],lt=d[5],ut=d[6],Ht=d[7],At=d[8],Ut=d[9],Dt=d[10],$t=d[11],Kt=d[12],sr=d[13],or=d[14],ar=d[15];a=p[0],S+=a*w,E+=a*Ye,U+=a*ht,z+=a*dt,we+=a*Ze,Q+=a*lt,ft+=a*ut,le+=a*Ht,Ce+=a*At,Be+=a*Ut,Ve+=a*Dt,De+=a*$t,Oe+=a*Kt,Ne+=a*sr,Te+=a*or,pe+=a*ar,a=p[1],E+=a*w,U+=a*Ye,z+=a*ht,we+=a*dt,Q+=a*Ze,ft+=a*lt,le+=a*ut,Ce+=a*Ht,Be+=a*At,Ve+=a*Ut,De+=a*Dt,Oe+=a*$t,Ne+=a*Kt,Te+=a*sr,pe+=a*or,Se+=a*ar,a=p[2],U+=a*w,z+=a*Ye,we+=a*ht,Q+=a*dt,ft+=a*Ze,le+=a*lt,Ce+=a*ut,Be+=a*Ht,Ve+=a*At,De+=a*Ut,Oe+=a*Dt,Ne+=a*$t,Te+=a*Kt,pe+=a*sr,Se+=a*or,re+=a*ar,a=p[3],z+=a*w,we+=a*Ye,Q+=a*ht,ft+=a*dt,le+=a*Ze,Ce+=a*lt,Be+=a*ut,Ve+=a*Ht,De+=a*At,Oe+=a*Ut,Ne+=a*Dt,Te+=a*$t,pe+=a*Kt,Se+=a*sr,re+=a*or,ye+=a*ar,a=p[4],we+=a*w,Q+=a*Ye,ft+=a*ht,le+=a*dt,Ce+=a*Ze,Be+=a*lt,Ve+=a*ut,De+=a*Ht,Oe+=a*At,Ne+=a*Ut,Te+=a*Dt,pe+=a*$t,Se+=a*Kt,re+=a*sr,ye+=a*or,me+=a*ar,a=p[5],Q+=a*w,ft+=a*Ye,le+=a*ht,Ce+=a*dt,Be+=a*Ze,Ve+=a*lt,De+=a*ut,Oe+=a*Ht,Ne+=a*At,Te+=a*Ut,pe+=a*Dt,Se+=a*$t,re+=a*Kt,ye+=a*sr,me+=a*or,J+=a*ar,a=p[6],ft+=a*w,le+=a*Ye,Ce+=a*ht,Be+=a*dt,Ve+=a*Ze,De+=a*lt,Oe+=a*ut,Ne+=a*Ht,Te+=a*At,pe+=a*Ut,Se+=a*Dt,re+=a*$t,ye+=a*Kt,me+=a*sr,J+=a*or,C+=a*ar,a=p[7],le+=a*w,Ce+=a*Ye,Be+=a*ht,Ve+=a*dt,De+=a*Ze,Oe+=a*lt,Ne+=a*ut,Te+=a*Ht,pe+=a*At,Se+=a*Ut,re+=a*Dt,ye+=a*$t,me+=a*Kt,J+=a*sr,C+=a*or,B+=a*ar,a=p[8],Ce+=a*w,Be+=a*Ye,Ve+=a*ht,De+=a*dt,Oe+=a*Ze,Ne+=a*lt,Te+=a*ut,pe+=a*Ht,Se+=a*At,re+=a*Ut,ye+=a*Dt,me+=a*$t,J+=a*Kt,C+=a*sr,B+=a*or,V+=a*ar,a=p[9],Be+=a*w,Ve+=a*Ye,De+=a*ht,Oe+=a*dt,Ne+=a*Ze,Te+=a*lt,pe+=a*ut,Se+=a*Ht,re+=a*At,ye+=a*Ut,me+=a*Dt,J+=a*$t,C+=a*Kt,B+=a*sr,V+=a*or,j+=a*ar,a=p[10],Ve+=a*w,De+=a*Ye,Oe+=a*ht,Ne+=a*dt,Te+=a*Ze,pe+=a*lt,Se+=a*ut,re+=a*Ht,ye+=a*At,me+=a*Ut,J+=a*Dt,C+=a*$t,B+=a*Kt,V+=a*sr,j+=a*or,D+=a*ar,a=p[11],De+=a*w,Oe+=a*Ye,Ne+=a*ht,Te+=a*dt,pe+=a*Ze,Se+=a*lt,re+=a*ut,ye+=a*Ht,me+=a*At,J+=a*Ut,C+=a*Dt,B+=a*$t,V+=a*Kt,j+=a*sr,D+=a*or,L+=a*ar,a=p[12],Oe+=a*w,Ne+=a*Ye,Te+=a*ht,pe+=a*dt,Se+=a*Ze,re+=a*lt,ye+=a*ut,me+=a*Ht,J+=a*At,C+=a*Ut,B+=a*Dt,V+=a*$t,j+=a*Kt,D+=a*sr,L+=a*or,_e+=a*ar,a=p[13],Ne+=a*w,Te+=a*Ye,pe+=a*ht,Se+=a*dt,re+=a*Ze,ye+=a*lt,me+=a*ut,J+=a*Ht,C+=a*At,B+=a*Ut,V+=a*Dt,j+=a*$t,D+=a*Kt,L+=a*sr,_e+=a*or,Le+=a*ar,a=p[14],Te+=a*w,pe+=a*Ye,Se+=a*ht,re+=a*dt,ye+=a*Ze,me+=a*lt,J+=a*ut,C+=a*Ht,B+=a*At,V+=a*Ut,j+=a*Dt,D+=a*$t,L+=a*Kt,_e+=a*sr,Le+=a*or,Ge+=a*ar,a=p[15],pe+=a*w,Se+=a*Ye,re+=a*ht,ye+=a*dt,me+=a*Ze,J+=a*lt,C+=a*ut,B+=a*Ht,V+=a*At,j+=a*Ut,D+=a*Dt,L+=a*$t,_e+=a*Kt,Le+=a*sr,Ge+=a*or,He+=a*ar,S+=38*Se,E+=38*re,U+=38*ye,z+=38*me,we+=38*J,Q+=38*C,ft+=38*B,le+=38*V,Ce+=38*j,Be+=38*D,Ve+=38*L,De+=38*_e,Oe+=38*Le,Ne+=38*Ge,Te+=38*He,g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Ve+g+65535,g=Math.floor(a/65536),Ve=a-g*65536,a=De+g+65535,g=Math.floor(a/65536),De=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),g=1,a=S+g+65535,g=Math.floor(a/65536),S=a-g*65536,a=E+g+65535,g=Math.floor(a/65536),E=a-g*65536,a=U+g+65535,g=Math.floor(a/65536),U=a-g*65536,a=z+g+65535,g=Math.floor(a/65536),z=a-g*65536,a=we+g+65535,g=Math.floor(a/65536),we=a-g*65536,a=Q+g+65535,g=Math.floor(a/65536),Q=a-g*65536,a=ft+g+65535,g=Math.floor(a/65536),ft=a-g*65536,a=le+g+65535,g=Math.floor(a/65536),le=a-g*65536,a=Ce+g+65535,g=Math.floor(a/65536),Ce=a-g*65536,a=Be+g+65535,g=Math.floor(a/65536),Be=a-g*65536,a=Ve+g+65535,g=Math.floor(a/65536),Ve=a-g*65536,a=De+g+65535,g=Math.floor(a/65536),De=a-g*65536,a=Oe+g+65535,g=Math.floor(a/65536),Oe=a-g*65536,a=Ne+g+65535,g=Math.floor(a/65536),Ne=a-g*65536,a=Te+g+65535,g=Math.floor(a/65536),Te=a-g*65536,a=pe+g+65535,g=Math.floor(a/65536),pe=a-g*65536,S+=g-1+37*(g-1),l[0]=S,l[1]=E,l[2]=U,l[3]=z,l[4]=we,l[5]=Q,l[6]=ft,l[7]=le,l[8]=Ce,l[9]=Be,l[10]=Ve,l[11]=De,l[12]=Oe,l[13]=Ne,l[14]=Te,l[15]=pe}function mt(l,p){ee(l,p,p)}function Ft(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=253;a>=0;a--)mt(d,d),a!==2&&a!==4&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function mo(l,p){var d=t(),a;for(a=0;a<16;a++)d[a]=p[a];for(a=250;a>=0;a--)mt(d,d),a!==1&&ee(d,d,p);for(a=0;a<16;a++)l[a]=d[a]}function hs(l,p,d){var a=new Uint8Array(32),g=new Float64Array(80),S,E,U=t(),z=t(),we=t(),Q=t(),ft=t(),le=t();for(E=0;E<31;E++)a[E]=p[E];for(a[31]=p[31]&127|64,a[0]&=248,he(g,d),E=0;E<16;E++)z[E]=g[E],Q[E]=U[E]=we[E]=0;for(U[0]=Q[0]=1,E=254;E>=0;--E)S=a[E>>>3]>>>(E&7)&1,Ie(U,z,S),Ie(we,Q,S),ct(ft,U,we),bt(U,U,we),ct(we,z,Q),bt(z,z,Q),mt(Q,ft),mt(le,U),ee(U,we,U),ee(we,z,ft),ct(ft,U,we),bt(U,U,we),mt(z,U),bt(we,Q,le),ee(U,we,u),ct(U,U,Q),ee(we,we,U),ee(U,Q,le),ee(Q,z,g),mt(z,ft),Ie(U,z,S),Ie(we,Q,S);for(E=0;E<16;E++)g[E+16]=U[E],g[E+32]=we[E],g[E+48]=z[E],g[E+64]=Q[E];var Ce=g.subarray(32),Be=g.subarray(16);return Ft(Ce,Ce),ee(Be,Be,Ce),wt(l,Be),0}function pr(l,p){return hs(l,p,s)}function wo(l,p){return n(p,32),pr(l,p)}function Nn(l,p,d){var a=new Uint8Array(32);return hs(a,d,p),qe(l,i,a,Je)}var bo=Pt,Sf=gt;function xo(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),bo(l,p,d,a,E)}function Dc(l,p,d,a,g,S){var E=new Uint8Array(32);return Nn(E,g,S),Sf(l,p,d,a,E)}var Ao=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function So(l,p,d,a){for(var g=new Int32Array(16),S=new Int32Array(16),E,U,z,we,Q,ft,le,Ce,Be,Ve,De,Oe,Ne,Te,pe,Se,re,ye,me,J,C,B,V,j,D,L,_e=l[0],Le=l[1],Ge=l[2],He=l[3],w=l[4],Ye=l[5],ht=l[6],dt=l[7],Ze=p[0],lt=p[1],ut=p[2],Ht=p[3],At=p[4],Ut=p[5],Dt=p[6],$t=p[7],Kt=0;a>=128;){for(me=0;me<16;me++)J=8*me+Kt,g[me]=d[J+0]<<24|d[J+1]<<16|d[J+2]<<8|d[J+3],S[me]=d[J+4]<<24|d[J+5]<<16|d[J+6]<<8|d[J+7];for(me=0;me<80;me++)if(E=_e,U=Le,z=Ge,we=He,Q=w,ft=Ye,le=ht,Ce=dt,Be=Ze,Ve=lt,De=ut,Oe=Ht,Ne=At,Te=Ut,pe=Dt,Se=$t,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(w>>>14|At<<18)^(w>>>18|At<<14)^(At>>>9|w<<23),B=(At>>>14|w<<18)^(At>>>18|w<<14)^(w>>>9|At<<23),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=w&Ye^~w&ht,B=At&Ut^~At&Dt,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=Ao[me*2],B=Ao[me*2+1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=g[me%16],B=S[me%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,re=D&65535|L<<16,ye=V&65535|j<<16,C=re,B=ye,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=(_e>>>28|Ze<<4)^(Ze>>>2|_e<<30)^(Ze>>>7|_e<<25),B=(Ze>>>28|_e<<4)^(_e>>>2|Ze<<30)^(_e>>>7|Ze<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,C=_e&Le^_e&Ge^Le&Ge,B=Ze&lt^Ze&ut^lt&ut,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,Ce=D&65535|L<<16,Se=V&65535|j<<16,C=we,B=Oe,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=re,B=ye,V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,we=D&65535|L<<16,Oe=V&65535|j<<16,Le=E,Ge=U,He=z,w=we,Ye=Q,ht=ft,dt=le,_e=Ce,lt=Be,ut=Ve,Ht=De,At=Oe,Ut=Ne,Dt=Te,$t=pe,Ze=Se,me%16===15)for(J=0;J<16;J++)C=g[J],B=S[J],V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=g[(J+9)%16],B=S[(J+9)%16],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+1)%16],ye=S[(J+1)%16],C=(re>>>1|ye<<31)^(re>>>8|ye<<24)^re>>>7,B=(ye>>>1|re<<31)^(ye>>>8|re<<24)^(ye>>>7|re<<25),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,re=g[(J+14)%16],ye=S[(J+14)%16],C=(re>>>19|ye<<13)^(ye>>>29|re<<3)^re>>>6,B=(ye>>>19|re<<13)^(re>>>29|ye<<3)^(ye>>>6|re<<26),V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,g[J]=D&65535|L<<16,S[J]=V&65535|j<<16;C=_e,B=Ze,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[0],B=p[0],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[0]=_e=D&65535|L<<16,p[0]=Ze=V&65535|j<<16,C=Le,B=lt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[1],B=p[1],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[1]=Le=D&65535|L<<16,p[1]=lt=V&65535|j<<16,C=Ge,B=ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[2],B=p[2],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[2]=Ge=D&65535|L<<16,p[2]=ut=V&65535|j<<16,C=He,B=Ht,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[3],B=p[3],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[3]=He=D&65535|L<<16,p[3]=Ht=V&65535|j<<16,C=w,B=At,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[4],B=p[4],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[4]=w=D&65535|L<<16,p[4]=At=V&65535|j<<16,C=Ye,B=Ut,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[5],B=p[5],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[5]=Ye=D&65535|L<<16,p[5]=Ut=V&65535|j<<16,C=ht,B=Dt,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[6],B=p[6],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[6]=ht=D&65535|L<<16,p[6]=Dt=V&65535|j<<16,C=dt,B=$t,V=B&65535,j=B>>>16,D=C&65535,L=C>>>16,C=l[7],B=p[7],V+=B&65535,j+=B>>>16,D+=C&65535,L+=C>>>16,j+=V>>>16,D+=j>>>16,L+=D>>>16,l[7]=dt=D&65535|L<<16,p[7]=$t=V&65535|j<<16,Kt+=128,a-=128}return a}function dn(l,p,d){var a=new Int32Array(8),g=new Int32Array(8),S=new Uint8Array(256),E,U=d;for(a[0]=1779033703,a[1]=3144134277,a[2]=1013904242,a[3]=2773480762,a[4]=1359893119,a[5]=2600822924,a[6]=528734635,a[7]=1541459225,g[0]=4089235720,g[1]=2227873595,g[2]=4271175723,g[3]=1595750129,g[4]=2917565137,g[5]=725511199,g[6]=4215389547,g[7]=327033209,So(a,g,p,d),d%=128,E=0;E<d;E++)S[E]=p[U-d+E];for(S[d]=128,d=256-128*(d<112?1:0),S[d-9]=0,v(S,d-8,U/536870912|0,U<<3),So(a,g,S,d),E=0;E<8;E++)v(l,8*E,a[E],g[E]);return 0}function Bi(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t(),we=t(),Q=t();bt(d,l[1],l[0]),bt(Q,p[1],p[0]),ee(d,d,Q),ct(a,l[0],l[1]),ct(Q,p[0],p[1]),ee(a,a,Q),ee(g,l[3],p[3]),ee(g,g,m),ee(S,l[2],p[2]),ct(S,S,S),bt(E,a,d),bt(U,S,g),ct(z,S,g),ct(we,a,d),ee(l[0],E,U),ee(l[1],we,z),ee(l[2],z,U),ee(l[3],E,we)}function ds(l,p,d){var a;for(a=0;a<4;a++)Ie(l[a],p[a],d)}function _o(l,p){var d=t(),a=t(),g=t();Ft(g,p[2]),ee(d,p[0],g),ee(a,p[1],g),wt(l,a),l[31]^=Lt(d)<<7}function Eo(l,p,d){var a,g;for(Qe(l[0],o),Qe(l[1],c),Qe(l[2],c),Qe(l[3],o),g=255;g>=0;--g)a=d[g/8|0]>>(g&7)&1,ds(l,p,a),Bi(p,l),Bi(l,l),ds(l,p,a)}function ps(l,p){var d=[t(),t(),t(),t()];Qe(d[0],x),Qe(d[1],G),Qe(d[2],c),ee(d[3],x,G),Eo(l,d,p)}function Io(l,p,d){var a=new Uint8Array(64),g=[t(),t(),t(),t()],S;for(d||n(p,32),dn(a,p,32),a[0]&=248,a[31]&=127,a[31]|=64,ps(g,a),_o(l,g),S=0;S<32;S++)p[S+32]=l[S];return 0}var pn=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ko(l,p){var d,a,g,S;for(a=63;a>=32;--a){for(d=0,g=a-32,S=a-12;g<S;++g)p[g]+=d-16*p[a]*pn[g-(a-32)],d=Math.floor((p[g]+128)/256),p[g]-=d*256;p[g]+=d,p[a]=0}for(d=0,g=0;g<32;g++)p[g]+=d-(p[31]>>4)*pn[g],d=p[g]>>8,p[g]&=255;for(g=0;g<32;g++)p[g]-=d*pn[g];for(a=0;a<32;a++)p[a+1]+=p[a]>>8,l[a]=p[a]&255}function Co(l){var p=new Float64Array(64),d;for(d=0;d<64;d++)p[d]=l[d];for(d=0;d<64;d++)l[d]=0;ko(l,p)}function $c(l,p,d,a){var g=new Uint8Array(64),S=new Uint8Array(64),E=new Uint8Array(64),U,z,we=new Float64Array(64),Q=[t(),t(),t(),t()];dn(g,a,32),g[0]&=248,g[31]&=127,g[31]|=64;var ft=d+64;for(U=0;U<d;U++)l[64+U]=p[U];for(U=0;U<32;U++)l[32+U]=g[32+U];for(dn(E,l.subarray(32),d+32),Co(E),ps(Q,E),_o(l,Q),U=32;U<64;U++)l[U]=a[U];for(dn(S,l,d+64),Co(S),U=0;U<64;U++)we[U]=0;for(U=0;U<32;U++)we[U]=E[U];for(U=0;U<32;U++)for(z=0;z<32;z++)we[U+z]+=S[U]*g[z];return ko(l.subarray(32),we),ft}function Bo(l,p){var d=t(),a=t(),g=t(),S=t(),E=t(),U=t(),z=t();return Qe(l[2],c),he(l[1],p),mt(g,l[1]),ee(S,g,h),bt(g,g,l[2]),ct(S,l[2],S),mt(E,S),mt(U,E),ee(z,U,E),ee(d,z,g),ee(d,d,S),mo(d,d),ee(d,d,g),ee(d,d,S),ee(d,d,S),ee(l[0],d,S),mt(a,l[0]),ee(a,a,S),Vt(a,g)&&ee(l[0],l[0],N),mt(a,l[0]),ee(a,a,S),Vt(a,g)?-1:(Lt(l[0])===p[31]>>7&&bt(l[0],o,l[0]),ee(l[3],l[0],l[1]),0)}function _(l,p,d,a){var g,S=new Uint8Array(32),E=new Uint8Array(64),U=[t(),t(),t(),t()],z=[t(),t(),t(),t()];if(d<64||Bo(z,a))return-1;for(g=0;g<d;g++)l[g]=p[g];for(g=0;g<32;g++)l[g+32]=a[g];if(dn(E,l,d),Co(E),Eo(U,z,E),ps(z,p.subarray(32)),Bi(U,z),_o(S,U),d-=64,I(p,0,S,0)){for(g=0;g<d;g++)l[g]=0;return-1}for(g=0;g<d;g++)l[g]=p[g+64];return d}var k=32,T=24,K=32,be=16,kt=32,Ct=32,Ue=32,Z=32,te=32,de=T,ve=K,Xe=be,st=64,xt=32,Zt=64,ys=32,Oo=64;e.lowlevel={crypto_core_hsalsa20:qe,crypto_stream_xor:oe,crypto_stream:se,crypto_stream_salsa20_xor:Re,crypto_stream_salsa20:W,crypto_onetimeauth:it,crypto_onetimeauth_verify:It,crypto_verify_16:O,crypto_verify_32:I,crypto_secretbox:Pt,crypto_secretbox_open:gt,crypto_scalarmult:hs,crypto_scalarmult_base:pr,crypto_box_beforenm:Nn,crypto_box_afternm:bo,crypto_box:xo,crypto_box_open:Dc,crypto_box_keypair:wo,crypto_hash:dn,crypto_sign:$c,crypto_sign_keypair:Io,crypto_sign_open:_,crypto_secretbox_KEYBYTES:k,crypto_secretbox_NONCEBYTES:T,crypto_secretbox_ZEROBYTES:K,crypto_secretbox_BOXZEROBYTES:be,crypto_scalarmult_BYTES:kt,crypto_scalarmult_SCALARBYTES:Ct,crypto_box_PUBLICKEYBYTES:Ue,crypto_box_SECRETKEYBYTES:Z,crypto_box_BEFORENMBYTES:te,crypto_box_NONCEBYTES:de,crypto_box_ZEROBYTES:ve,crypto_box_BOXZEROBYTES:Xe,crypto_sign_BYTES:st,crypto_sign_PUBLICKEYBYTES:xt,crypto_sign_SECRETKEYBYTES:Zt,crypto_sign_SEEDBYTES:ys,crypto_hash_BYTES:Oo,gf:t,D:h,L:pn,pack25519:wt,unpack25519:he,M:ee,A:ct,S:mt,Z:bt,pow2523:mo,add:Bi,set25519:Qe,modL:ko,scalarmult:Eo,scalarbase:ps};function Mc(l,p){if(l.length!==k)throw new Error("bad key size");if(p.length!==T)throw new Error("bad nonce size")}function fw(l,p){if(l.length!==Ue)throw new Error("bad public key size");if(p.length!==Z)throw new Error("bad secret key size")}function Br(){for(var l=0;l<arguments.length;l++)if(!(arguments[l]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function xy(l){for(var p=0;p<l.length;p++)l[p]=0}e.randomBytes=function(l){var p=new Uint8Array(l);return n(p,l),p},e.secretbox=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(K+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+K]=l[S];return Pt(g,a,a.length,p,d),g.subarray(be)},e.secretbox.open=function(l,p,d){Br(l,p,d),Mc(d,p);for(var a=new Uint8Array(be+l.length),g=new Uint8Array(a.length),S=0;S<l.length;S++)a[S+be]=l[S];return a.length<32||gt(g,a,a.length,p,d)!==0?null:g.subarray(K)},e.secretbox.keyLength=k,e.secretbox.nonceLength=T,e.secretbox.overheadLength=be,e.scalarMult=function(l,p){if(Br(l,p),l.length!==Ct)throw new Error("bad n size");if(p.length!==kt)throw new Error("bad p size");var d=new Uint8Array(kt);return hs(d,l,p),d},e.scalarMult.base=function(l){if(Br(l),l.length!==Ct)throw new Error("bad n size");var p=new Uint8Array(kt);return pr(p,l),p},e.scalarMult.scalarLength=Ct,e.scalarMult.groupElementLength=kt,e.box=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox(l,p,g)},e.box.before=function(l,p){Br(l,p),fw(l,p);var d=new Uint8Array(te);return Nn(d,l,p),d},e.box.after=e.secretbox,e.box.open=function(l,p,d,a){var g=e.box.before(d,a);return e.secretbox.open(l,p,g)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var l=new Uint8Array(Ue),p=new Uint8Array(Z);return wo(l,p),{publicKey:l,secretKey:p}},e.box.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Z)throw new Error("bad secret key size");var p=new Uint8Array(Ue);return pr(p,l),{publicKey:p,secretKey:new Uint8Array(l)}},e.box.publicKeyLength=Ue,e.box.secretKeyLength=Z,e.box.sharedKeyLength=te,e.box.nonceLength=de,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(l,p){if(Br(l,p),p.length!==Zt)throw new Error("bad secret key size");var d=new Uint8Array(st+l.length);return $c(d,l,l.length,p),d},e.sign.open=function(l,p){if(Br(l,p),p.length!==xt)throw new Error("bad public key size");var d=new Uint8Array(l.length),a=_(d,l,l.length,p);if(a<0)return null;for(var g=new Uint8Array(a),S=0;S<g.length;S++)g[S]=d[S];return g},e.sign.detached=function(l,p){for(var d=e.sign(l,p),a=new Uint8Array(st),g=0;g<a.length;g++)a[g]=d[g];return a},e.sign.detached.verify=function(l,p,d){if(Br(l,p,d),p.length!==st)throw new Error("bad signature size");if(d.length!==xt)throw new Error("bad public key size");var a=new Uint8Array(st+l.length),g=new Uint8Array(st+l.length),S;for(S=0;S<st;S++)a[S]=p[S];for(S=0;S<l.length;S++)a[S+st]=l[S];return _(g,a,a.length,d)>=0},e.sign.keyPair=function(){var l=new Uint8Array(xt),p=new Uint8Array(Zt);return Io(l,p),{publicKey:l,secretKey:p}},e.sign.keyPair.fromSecretKey=function(l){if(Br(l),l.length!==Zt)throw new Error("bad secret key size");for(var p=new Uint8Array(xt),d=0;d<p.length;d++)p[d]=l[32+d];return{publicKey:p,secretKey:new Uint8Array(l)}},e.sign.keyPair.fromSeed=function(l){if(Br(l),l.length!==ys)throw new Error("bad seed size");for(var p=new Uint8Array(xt),d=new Uint8Array(Zt),a=0;a<32;a++)d[a]=l[a];return Io(p,d,!0),{publicKey:p,secretKey:d}},e.sign.publicKeyLength=xt,e.sign.secretKeyLength=Zt,e.sign.seedLength=ys,e.sign.signatureLength=st,e.hash=function(l){Br(l);var p=new Uint8Array(Oo);return dn(p,l,l.length),p},e.hash.hashLength=Oo,e.verify=function(l,p){return Br(l,p),l.length===0||p.length===0||l.length!==p.length?!1:A(l,0,p,0,l.length)===0},e.setPRNG=function(l){n=l},function(){var l=typeof self<"u"?self.crypto||self.msCrypto:null;if(l&&l.getRandomValues){var p=65536;e.setPRNG(function(d,a){var g,S=new Uint8Array(a);for(g=0;g<a;g+=p)l.getRandomValues(S.subarray(g,g+Math.min(a-g,p)));for(g=0;g<a;g++)d[g]=S[g];xy(S)})}else typeof g1<"u"&&(l=v1,l&&l.randomBytes&&e.setPRNG(function(d,a){var g,S=l.randomBytes(a);for(g=0;g<a;g++)d[g]=S[g];xy(S)}))}()})(r.exports?r.exports:self.nacl=self.nacl||{})})(B0);var m1=B0.exports;const O0=Ly(m1);function w1(){return O0.box.keyPair()}async function Ci(r,e){const t=sessionStorage.getItem("sessionKey"),n=sessionStorage.getItem("sessionId");console.groupCollapsed("Attestation");try{if(t&&n&&!r){const o=gs(t);return console.log("Using existing attestation from session storage."),{sessionKey:o,sessionId:n}}const i=window.crypto.randomUUID();console.log("Generated attestation nonce:",i);const s=await y1(i,e);if(s&&s.public_key){console.log("Attestation document verification succeeded");const o=w1();console.log("Generated client key pair");const c=new Uint8Array(s.public_key),{encrypted_session_key:u,session_id:h}=await U1($r(o.publicKey),i,e);console.log("Key exchange completed.");const m=O0.scalarMult(o.secretKey,c),x=gs(u),G=12,N=x.slice(0,G),v=x.slice(G),O=new Hc(m).open(N,v);if(O)return console.log("Session key decrypted successfully"),window.sessionStorage.setItem("sessionKey",$r(O)),window.sessionStorage.setItem("sessionId",h),{sessionKey:O,sessionId:h};throw new Error("Failed to decrypt session key")}else throw new Error("Invalid attestation document")}catch(i){throw console.error("Error verifying attestation:",i),i}finally{console.groupEnd()}}let at="";function b1(r){at=r}async function x1(r,e){return Nt(`${at}/platform/login`,"POST",{email:r,password:e},void 0,"Failed to login")}async function A1(r,e,t,n){return Nt(`${at}/platform/register`,"POST",{email:r,password:e,invite_code:t,name:n},void 0,"Failed to register")}async function S1(r){return Nt(`${at}/platform/logout`,"POST",{refresh_token:r},void 0,"Failed to logout")}async function _1(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Nt(`${at}/platform/refresh`,"POST",e,void 0,"Failed to refresh platform token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing platform token:",t),t}}async function T0(r){return ze(`${at}/platform/orgs`,"POST",{name:r})}async function N0(){return ze(`${at}/platform/orgs`,"GET",void 0)}async function P0(r){return ze(`${at}/platform/orgs/${r}`,"DELETE",void 0)}async function j0(r,e,t){return ze(`${at}/platform/orgs/${r}/projects`,"POST",{name:e,description:t})}async function R0(r){return ze(`${at}/platform/orgs/${r}/projects`,"GET",void 0)}async function U0(r,e){return ze(`${at}/platform/orgs/${r}/projects/${e}`,"GET",void 0)}async function D0(r,e,t){return ze(`${at}/platform/orgs/${r}/projects/${e}`,"PATCH",t)}async function $0(r,e){return ze(`${at}/platform/orgs/${r}/projects/${e}`,"DELETE",void 0)}function E1(r){const e=/^[A-Za-z0-9+/]*[=]{0,2}$/,t=r.length%4===0,n=e.test(r);return t&&n}async function M0(r,e,t,n){if(!E1(n))throw new Error("Secret must be base64 encoded. Use @stablelib/base64's encode function to encode your data.");return ze(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"POST",{key_name:t,secret:n})}async function V0(r,e){return ze(`${at}/platform/orgs/${r}/projects/${e}/secrets`,"GET",void 0)}async function L0(r,e,t){return ze(`${at}/platform/orgs/${r}/projects/${e}/secrets/${t}`,"DELETE",void 0)}async function H0(r,e){return ze(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"GET",void 0)}async function F0(r,e,t){return ze(`${at}/platform/orgs/${r}/projects/${e}/settings/email`,"PUT",t)}async function z0(r,e){return ze(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"GET",void 0)}async function G0(r,e,t){return ze(`${at}/platform/orgs/${r}/projects/${e}/settings/oauth`,"PUT",t)}async function K0(r,e,t){if(!e||e.trim()==="")throw new Error("Email is required");return ze(`${at}/platform/orgs/${r}/invites`,"POST",{email:e,role:t})}async function q0(r){return ze(`${at}/platform/orgs/${r}/invites`,"GET",void 0)}async function Z0(r,e){return ze(`${at}/platform/orgs/${r}/invites/${e}`,"GET",void 0)}async function W0(r,e){return ze(`${at}/platform/orgs/${r}/invites/${e}`,"DELETE",void 0)}async function Y0(r){return ze(`${at}/platform/orgs/${r}/memberships`,"GET",void 0)}async function J0(r,e,t){return ze(`${at}/platform/orgs/${r}/memberships/${e}`,"PATCH",{role:t})}async function X0(r,e){return ze(`${at}/platform/orgs/${r}/memberships/${e}`,"DELETE",void 0)}async function Q0(r){return ze(`${at}/platform/accept_invite/${r}`,"POST",void 0)}async function I1(){return ze(`${at}/platform/me`,"GET",void 0)}async function ey(r){return Nt(`${at}/platform/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Oc(){return ze(`${at}/platform/request_verification`,"POST",void 0,"Failed to request new verification code")}async function ty(r,e){const t={email:r,hashed_secret:e};return Nt(`${at}/platform/password-reset/request`,"POST",t,void 0,"Failed to request platform password reset")}async function ry(r,e,t,n){const i={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n};return Nt(`${at}/platform/password-reset/confirm`,"POST",i,void 0,"Failed to confirm platform password reset")}async function ny(r,e){const t={current_password:r,new_password:e};return ze(`${at}/platform/change-password`,"POST",t,"Failed to change platform password")}async function ze(r,e,t,n){const i=async(s=!1)=>{try{if(s){console.log("Refreshing access token");const u=ti.getRefreshFunction(r);console.log(`Using ${u}`),u==="platformRefreshToken"?await _1():await Tc()}const o=window.localStorage.getItem("access_token");if(!o)throw new Error("No access token available");const c=await iy(r,e,t,o,n);if(c.status===401&&!s)return console.log(`Received 401 for URL ${r}, attempting to refresh token`),i(!0);if(c.error)throw new Error(c.error);if(!c.data)throw new Error("No data received from the server");return c.data}catch(o){throw console.error(o),o}};return i()}async function iy(r,e,t,n,i){const o=ti.resolveEndpoint(r).context==="platform"?ti.platformApiUrl:void 0;let{sessionKey:c,sessionId:u}=await Ci(!1,o);const h=async(x,G=!1)=>{if(G||!c||!u){const P=await Ci(!0,o);c=P.sessionKey,u=P.sessionId}if(!c||!u)throw new Error("Failed to make encrypted API call, no attestation available.");const N=t?JSON.stringify(t):void 0,v=N?Pf(c,N):void 0,A={"Content-Type":"application/json","x-session-id":u};x&&(A.Authorization=`Bearer ${x}`);const O=await fetch(r,{method:e,headers:A,body:v?JSON.stringify({encrypted:v}):void 0}),I={status:O.status};if(O.ok)try{const P=await O.json(),R=jf(c,P.encrypted);I.data=JSON.parse(R)}catch(P){console.error("Error decrypting or parsing response:",P),I.status=500,I.error="Failed to decrypt or parse the response"}else try{const P=await O.json();I.error=P.message||i||`HTTP error! Status: ${O.status}`}catch{I.error=i||`HTTP error! Status: ${O.status}`}return I},m=async(x,G=!1)=>{var N;try{const v=await h(x,G);return(v.status===400||(N=v.error)!=null&&N.includes("Encryption error"))&&!G?(console.log("Encryption error or Bad Request, attempting to renew attestation"),m(x,!0)):v}catch(v){return{status:500,error:v instanceof Error?v.message:"Unknown error occurred"}}};return m(n)}async function Nt(r,e,t,n,i){const s=await iy(r,e,t,n,i);if(s.error)throw new Error(s.error);if(!s.data)throw new Error("No data received from the server");return s.data}let nt="";function k1(r){nt=r}function C1(){return nt}async function B1(r,e,t){return Nt(`${nt}/login`,"POST",{email:r,password:e,client_id:t})}async function O1(r,e,t){return Nt(`${nt}/login`,"POST",{id:r,password:e,client_id:t})}async function T1(r,e,t,n,i){return Nt(`${nt}/register`,"POST",{email:r,password:e,inviteCode:t.toLowerCase(),client_id:n,name:i})}async function N1(r,e,t){return Nt(`${nt}/register`,"POST",{password:r,inviteCode:e.toLowerCase(),client_id:t})}async function Tc(){const r=window.localStorage.getItem("refresh_token");if(!r)throw new Error("No refresh token available");const e={refresh_token:r};try{const t=await Nt(`${nt}/refresh`,"POST",e,void 0,"Failed to refresh token");return window.localStorage.setItem("access_token",t.access_token),window.localStorage.setItem("refresh_token",t.refresh_token),t}catch(t){throw console.error("Error refreshing token:",t),t}}async function P1(){return ze(`${nt}/protected/user`,"GET",void 0,"Failed to fetch user")}async function sy(r,e){return ze(`${nt}/protected/kv/${r}`,"PUT",e,"Failed to put key-value pair")}async function oy(r){return ze(`${nt}/protected/kv/${r}`,"DELETE",void 0,"Failed to delete key-value pair")}async function ay(r){try{return await ze(`${nt}/protected/kv/${r}`,"GET",void 0,"Failed to get key-value pair")}catch(e){console.error(`Error fetching key "${r}":`,e);return}}async function cy(){return ze(`${nt}/protected/kv`,"GET",void 0,"Failed to list key-value pairs")}async function j1(r){const e={refresh_token:r};return Nt(`${nt}/logout`,"POST",e)}async function ly(r){return Nt(`${nt}/verify-email/${r}`,"GET",void 0,void 0,"Failed to verify email")}async function Nc(){return ze(`${nt}/protected/request_verification`,"POST",void 0,"Failed to request new verification code")}async function R1(r,e){const n=await fetch(`${e||nt}/attestation/${r}`);if(!n.ok)throw new Error(`Request failed with status ${n.status}`);return(await n.json()).attestation_document}async function U1(r,e,t){const i=await fetch(`${t||nt}/key_exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_public_key:r,nonce:e})});if(!i.ok)throw new Error("Key exchange failed");return i.json()}async function D1(r,e,t){const n={email:r,hashed_secret:e,client_id:t};return Nt(`${nt}/password-reset/request`,"POST",n,void 0,"Failed to request password reset")}async function $1(r,e,t,n,i){const s={email:r,alphanumeric_code:e,plaintext_secret:t,new_password:n,client_id:i};return Nt(`${nt}/password-reset/confirm`,"POST",s,void 0,"Failed to confirm password reset")}async function uy(r,e){const t={current_password:r,new_password:e};return ze(`${nt}/protected/change_password`,"POST",t,"Failed to change password")}async function M1(r,e){try{return await Nt(`${nt}/auth/github`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate GitHub auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function V1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${nt}/auth/github/callback`,"POST",n,void 0,"GitHub callback failed")}catch(i){throw console.error("Detailed GitHub callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with GitHub."):new Error("Failed to authenticate with GitHub. Please try again."):i}}async function L1(r,e){try{return await Nt(`${nt}/auth/google`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Google auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function H1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${nt}/auth/google/callback`,"POST",n,void 0,"Google callback failed")}catch(i){throw console.error("Detailed Google callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Google."):new Error("Failed to authenticate with Google. Please try again."):i}}async function F1(r,e){try{return await Nt(`${nt}/auth/apple`,"POST",e?{invite_code:e,client_id:r}:{client_id:r},void 0,"Failed to initiate Apple auth")}catch(t){throw t instanceof Error&&t.message.includes("Invalid invite code")?new Error("Invalid invite code. Please check and try again."):t}}async function z1(r,e,t){const n={code:r,state:e,invite_code:t};try{return await Nt(`${nt}/auth/apple/callback`,"POST",n,void 0,"Apple callback failed")}catch(i){throw console.error("Detailed Apple callback error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function G1(r,e,t){const n={...r,client_id:e,...t?{invite_code:t}:{}};try{return await Nt(`${nt}/auth/apple/native`,"POST",n,void 0,"Apple Sign-In failed")}catch(i){throw console.error("Detailed Apple Sign-In error:",i),i instanceof Error?i.message.includes("User exists")||i.message.includes("Email already registered")?new Error("An account with this email already exists. Please sign in using your existing account."):i.message.includes("Invalid invite code")?new Error("Invalid invite code. Please try signing up with a valid invite code."):i.message.includes("User not found")?new Error("User not found. Please sign up first before attempting to log in with Apple."):i.message.includes("No email found")?new Error("Unable to retrieve email from Apple. Please try another sign-in method."):new Error("Failed to authenticate with Apple. Please try again."):i}}async function fy(r){let e=`${nt}/protected/private_key`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),ze(e,"GET",void 0,"Failed to fetch private key")}async function hy(r){let e=`${nt}/protected/private_key_bytes`;const t=[];return r!=null&&r.seed_phrase_derivation_path&&t.push(`seed_phrase_derivation_path=${encodeURIComponent(r.seed_phrase_derivation_path)}`),r!=null&&r.private_key_derivation_path&&t.push(`private_key_derivation_path=${encodeURIComponent(r.private_key_derivation_path)}`),t.length>0&&(e+=`?${t.join("&")}`),ze(e,"GET",void 0,"Failed to fetch private key bytes")}async function dy(r,e,t){const i={message_base64:$r(r),algorithm:e,...t&&Object.keys(t).length>0&&{key_options:t}};return ze(`${nt}/protected/sign_message`,"POST",i,"Failed to sign message")}async function py(r,e){let t=`${nt}/protected/public_key?algorithm=${r}`;return e!=null&&e.seed_phrase_derivation_path&&(t+=`&seed_phrase_derivation_path=${encodeURIComponent(e.seed_phrase_derivation_path)}`),e!=null&&e.private_key_derivation_path&&(t+=`&private_key_derivation_path=${encodeURIComponent(e.private_key_derivation_path)}`),ze(t,"GET",void 0,"Failed to fetch public key")}async function K1(r,e,t){const n={email:r,password:e,...t!==void 0&&{name:t}};return ze(`${nt}/protected/convert_guest`,"POST",n,"Failed to convert guest account")}async function q1(r){return ze(`${nt}/protected/third_party_token`,"POST",r?{audience:r}:{},"Failed to generate third party token")}async function yy(r,e){const t={data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return ze(`${nt}/protected/encrypt`,"POST",t,"Failed to encrypt data")}async function gy(r,e){const t={encrypted_data:r,...e&&Object.keys(e).length>0&&{key_options:e}};return ze(`${nt}/protected/decrypt`,"POST",t,"Failed to decrypt data")}function Z1(){return async(r,e)=>{var n,i;const t=()=>{const s=window.localStorage.getItem("access_token");if(!s)throw new Error("No access token available");return`Bearer ${s}`};try{const s=new Headers(e==null?void 0:e.headers);s.set("Authorization",t());const{sessionKey:o,sessionId:c}=await Ci();if(!o||!c)throw new Error("No session key or ID available");s.set("x-session-id",c);const u={...e,headers:s};if(e!=null&&e.body){const m=Pf(o,e.body);u.body=JSON.stringify({encrypted:m}),s.set("Content-Type","application/json")}let h=await fetch(r,u);if(h.status===401&&(console.warn("Unauthorized, refreshing access token"),await Tc(),s.set("Authorization",t()),u.headers=s,h=await fetch(r,u)),!h.ok){const m=await h.text();throw console.error("Request failed with response status:",h.status," and message:",m),new Error(`Request failed with status ${h.status}: ${m}`)}if((n=h.headers.get("content-type"))!=null&&n.includes("text/event-stream")){const m=(i=h.body)==null?void 0:i.getReader(),x=new TextDecoder;let G="";const N=new ReadableStream({async start(v){for(;;){const{done:A,value:O}=await m.read();if(A)break;const I=x.decode(O);G+=I;let P;for(;P=W1(G);)if(G=G.slice(P.length),P.trim().startsWith("data: ")){const R=P.slice(6).trim();if(R==="[DONE]")v.enqueue(`data: [DONE]
126
126
 
127
- `);else try{console.groupCollapsed("Decrypting chunk"),console.log("Attempting to decrypt, data length:",R.length);const le=Pf(o,R);console.log("Decrypted data length:",le.length),console.log("Decrypted data:",le);try{const Q=JSON.parse(le);console.log("Parsed JSON:",Q),v.enqueue(`data: ${JSON.stringify(Q)}
127
+ `);else try{console.groupCollapsed("Decrypting chunk"),console.log("Attempting to decrypt, data length:",R.length);const fe=jf(o,R);console.log("Decrypted data length:",fe.length),console.log("Decrypted data:",fe);try{const qe=JSON.parse(fe);console.log("Parsed JSON:",qe),v.enqueue(`data: ${JSON.stringify(qe)}
128
128
 
129
- `)}catch(Q){Q instanceof SyntaxError&&(console.log("Failed to parse JSON:",le),v.enqueue(`data: ${le}
129
+ `)}catch(qe){qe instanceof SyntaxError&&(console.log("Failed to parse JSON:",fe),v.enqueue(`data: ${fe}
130
130
 
131
- `))}}catch(le){console.error("Decryption error:",le,"Data:",R),console.log("Skipping corrupted chunk")}finally{console.groupEnd()}}}v.close()}});return new Response(N,{headers:h.headers,status:h.status,statusText:h.statusText})}return h}catch(s){throw console.error("Error during fetch process:",s),s}}}function K1(r){const e=r.indexOf(`
131
+ `))}}catch(fe){console.error("Decryption error:",fe,"Data:",R),console.log("Skipping corrupted chunk")}finally{console.groupEnd()}}}v.close()}});return new Response(N,{headers:h.headers,status:h.status,statusText:h.statusText})}return h}catch(s){throw console.error("Error during fetch process:",s),s}}}function W1(r){const e=r.indexOf(`
132
132
 
133
- `);return e===-1?null:r.slice(0,e+2)}const q1=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],Z1=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"],W1="MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEHiUY9kFWK1GqBGzczohhwEwElXzgWLDZa9R6wBx3JOBocgSt9+UIzZlJbPDjYeGBfDUXh7Z62BG2vVsh2NgclLB5S7A2ucBBtb1wd8vSQHP8jpdPhZX1slauPgbnROIP",Y1={prod:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrProdHistory.json",dev:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrDevHistory.json"};async function J1(){try{const r=new Uint8Array(atob(W1).split("").map(e=>e.charCodeAt(0)));return await crypto.subtle.importKey("spki",r,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"])}catch(r){throw console.error("Error importing verification key:",r),new Error("Failed to import PCR verification key")}}async function X1(r,e){try{const t=(e==null?void 0:e[r])||Y1[r],n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch PCR history: ${n.status}`);return await n.json()}catch(t){throw console.error("Error fetching PCR history:",t),new Error("Failed to fetch PCR history")}}async function Q1(r,e,t){try{const i=new TextEncoder().encode(r),s=new Uint8Array(atob(e).split("").map(o=>o.charCodeAt(0)));return await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},t,s,i)}catch(n){return console.error("Signature verification error:",n),!1}}async function vy(r,e,t){try{const n=await J1(),i=await X1(e,t);for(const s of i)if(s.PCR0===r&&await Q1(s.PCR0,s.signature,n))return{isMatch:!0,text:"PCR0 matches remotely attested value",verifiedAt:new Date(s.timestamp*1e3).toLocaleString()};return null}catch(n){return console.error("PCR remote validation error:",n),null}}async function ew(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],...q1],n=[...(e==null?void 0:e.pcr0DevValues)||[],...Z1];if(t.includes(r))return{isMatch:!0,text:"PCR0 matches a known good value"};if(n.includes(r))return{isMatch:!0,text:"PCR0 matches development enclave"};if((e==null?void 0:e.remoteAttestation)!==!1)try{const s=await vy(r,"prod",e==null?void 0:e.remoteAttestationUrls);if(s)return s;const o=await vy(r,"dev",e==null?void 0:e.remoteAttestationUrls);if(o)return o}catch(s){console.error("Error during remote PCR validation:",s)}return{isMatch:!1,text:"PCR0 does not match a known good value"}}const us=Bc,jc="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function my(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function tw(r){const e=await crypto.subtle.digest("SHA-256",r);return my(new Uint8Array(e))}async function fs(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([m,x])=>({id:m,value:my(x)})).filter(m=>!m.value.match(/^0+$/)),i=n.find(m=>m.id===0);let s=null;i&&(s=await ew(i.value,t));const o=[...e,r.certificate].map(m=>{const x=new xi(m);return{subject:x.subject,notBefore:x.notBefore.toLocaleString(),notAfter:x.notAfter.toLocaleString(),pem:x.toString("pem"),isRoot:x.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new xi(e[0]),h=await tw(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?$r(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:h,validatedPcr0Hash:s}}const xf=ft.createContext({auth:{loading:!0,user:void 0},clientId:"",signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:ay,put:sy,list:cy,del:oy,verifyEmail:ly,requestNewVerificationCode:Nc,requestNewVerificationEmail:Nc,refetchUser:async()=>{},changePassword:uy,refreshAccessToken:Tc,requestPasswordReset:async()=>{},confirmPasswordReset:async()=>{},initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},getPrivateKey:fy,getPrivateKeyBytes:hy,getPublicKey:py,signMessage:dy,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:jc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""}),encryptData:yy,decryptData:gy});function rw({children:r,apiUrl:e,clientId:t,pcrConfig:n={}}){const[i,s]=ft.useState({loading:!0,user:void 0}),[o,c]=ft.useState();ft.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");if(!t||t.trim()==="")throw new Error("OpenSecretProvider requires a non-empty clientId. Please provide a valid project UUID.");k1(e),Promise.resolve().then(()=>kf).then(({apiConfig:Q})=>{const re=Q.platformApiUrl||"";Q.configure(e,re)})},[e,t]),ft.useEffect(()=>{i.user?c(()=>G1()):c(void 0)},[i.user]);async function u(){const Q=window.localStorage.getItem("access_token"),re=window.localStorage.getItem("refresh_token");if(!Q||!re){s({loading:!1,user:void 0});return}try{const Y=await j1();s({loading:!1,user:Y})}catch(Y){console.error("Failed to fetch user:",Y),s({loading:!1,user:void 0})}}ft.useEffect(()=>{u()},[]);async function h(Q,re){console.log("Signing in");try{const{access_token:Y,refresh_token:ye}=await B1(Q,re,t);window.localStorage.setItem("access_token",Y),window.localStorage.setItem("refresh_token",ye),await u()}catch(Y){throw console.error(Y),Y}}async function m(Q,re,Y,ye){try{const{access_token:Ke,refresh_token:dt}=await T1(Q,re,Y,t,ye||null);window.localStorage.setItem("access_token",Ke),window.localStorage.setItem("refresh_token",dt),await u()}catch(Ke){throw console.error(Ke),Ke}}async function x(Q,re){console.log("Signing in Guest");try{const{access_token:Y,refresh_token:ye}=await O1(Q,re,t);window.localStorage.setItem("access_token",Y),window.localStorage.setItem("refresh_token",ye),await u()}catch(Y){throw console.error(Y),Y}}async function G(Q,re){try{const{access_token:Y,refresh_token:ye,id:Ke}=await N1(Q,re,t);return window.localStorage.setItem("access_token",Y),window.localStorage.setItem("refresh_token",ye),await u(),{access_token:Y,refresh_token:ye,id:Ke}}catch(Y){throw console.error(Y),Y}}async function N(Q,re,Y){try{await F1(Q,re,Y),await u()}catch(ye){throw console.error(ye),ye}}async function v(){const Q=window.localStorage.getItem("refresh_token");if(Q)try{await P1(Q)}catch(re){console.error("Error during logout:",re)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),s({loading:!1,user:void 0})}const le={auth:i,clientId:t,signIn:h,signInGuest:x,signOut:v,signUp:m,signUpGuest:G,convertGuestToUserAccount:N,get:ay,put:sy,list:cy,del:oy,refetchUser:u,verifyEmail:ly,requestNewVerificationCode:Nc,requestNewVerificationEmail:Nc,changePassword:uy,refreshAccessToken:Tc,requestPasswordReset:(Q,re)=>D1(Q,re,t),confirmPasswordReset:(Q,re,Y,ye)=>$1(Q,re,Y,ye,t),initiateGitHubAuth:async Q=>{try{return await M1(t,Q)}catch(re){throw console.error("Failed to initiate GitHub auth:",re),re}},handleGitHubCallback:async(Q,re,Y)=>{try{const{access_token:ye,refresh_token:Ke}=await V1(Q,re,Y);window.localStorage.setItem("access_token",ye),window.localStorage.setItem("refresh_token",Ke),await u()}catch(ye){throw console.error("GitHub callback error:",ye),ye}},initiateGoogleAuth:async Q=>{try{return await L1(t,Q)}catch(re){throw console.error("Failed to initiate Google auth:",re),re}},handleGoogleCallback:async(Q,re,Y)=>{try{const{access_token:ye,refresh_token:Ke}=await H1(Q,re,Y);window.localStorage.setItem("access_token",ye),window.localStorage.setItem("refresh_token",Ke),await u()}catch(ye){throw console.error("Google callback error:",ye),ye}},getPrivateKey:fy,getPrivateKeyBytes:hy,getPublicKey:py,signMessage:dy,aiCustomFetch:o||(async()=>new Response),apiUrl:e,pcrConfig:n,getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:jc,getAttestationDocument:async()=>{const Q=window.crypto.randomUUID(),re=await fetch(`${e}/attestation/${Q}`);if(!re.ok)throw new Error("Failed to fetch attestation document");const Y=await re.json(),ye=await ki(Y.attestation_document,us,Q);return fs(ye,ye.cabundle,n)},generateThirdPartyToken:z1,encryptData:yy,decryptData:gy};return ut.jsx(xf.Provider,{value:le,children:r})}const Af=ft.createContext({auth:{loading:!0,developer:void 0},signIn:async()=>{throw new Error("signIn called outside of OpenSecretDeveloper provider")},signUp:async()=>{throw new Error("signUp called outside of OpenSecretDeveloper provider")},signOut:async()=>{throw new Error("signOut called outside of OpenSecretDeveloper provider")},refetchDeveloper:async()=>{throw new Error("refetchDeveloper called outside of OpenSecretDeveloper provider")},verifyEmail:ey,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,requestPasswordReset:ty,confirmPasswordReset:ry,changePassword:ny,pcrConfig:{},getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:jc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretDeveloper provider")},createOrganization:T0,listOrganizations:N0,deleteOrganization:j0,createProject:P0,listProjects:R0,getProject:U0,updateProject:D0,deleteProject:$0,createProjectSecret:M0,listProjectSecrets:V0,deleteProjectSecret:L0,getEmailSettings:H0,updateEmailSettings:F0,getOAuthSettings:z0,updateOAuthSettings:G0,inviteDeveloper:K0,listOrganizationMembers:Y0,listOrganizationInvites:q0,getOrganizationInvite:Z0,deleteOrganizationInvite:W0,updateMemberRole:J0,removeMember:X0,acceptInvite:Q0,apiUrl:""});function nw({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=ft.useState({loading:!0,developer:void 0});ft.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretDeveloper requires a non-empty apiUrl. Please provide a valid API endpoint URL.");b1(e),Promise.resolve().then(()=>kf).then(({apiConfig:m})=>{const x=m.appApiUrl||"";m.configure(x,e)}).catch(m=>{throw console.error("Failed to load apiConfig:",m),new Error("Failed to initialize OpenSecretDeveloper - could not load required dependencies")})},[e]);async function s(){const m=window.localStorage.getItem("access_token"),x=window.localStorage.getItem("refresh_token");if(!m||!x){i({loading:!1,developer:void 0});return}try{const G=await I1();i({loading:!1,developer:{...G.user,organizations:G.organizations}})}catch(G){console.error("Failed to fetch developer:",G),i({loading:!1,developer:void 0})}}const o=async()=>{const m=window.crypto.randomUUID(),x=await fetch(`${e}/attestation/${m}`);if(!x.ok)throw new Error("Failed to fetch attestation document");const G=await x.json(),N=await ki(G.attestation_document,us,m);return fs(N,N.cabundle,t)};ft.useEffect(()=>{s()},[]);async function c(m,x){try{const{access_token:G,refresh_token:N}=await x1(m,x);return window.localStorage.setItem("access_token",G),window.localStorage.setItem("refresh_token",N),await s(),{access_token:G,refresh_token:N,id:"",email:m}}catch(G){throw console.error("Login error:",G),G}}async function u(m,x,G,N){try{const{access_token:v,refresh_token:A}=await A1(m,x,G,N);return window.localStorage.setItem("access_token",v),window.localStorage.setItem("refresh_token",A),await s(),{access_token:v,refresh_token:A,id:"",email:m,name:N}}catch(v){throw console.error("Registration error:",v),v}}const h={auth:n,signIn:c,signUp:u,refetchDeveloper:s,signOut:async()=>{const m=window.localStorage.getItem("refresh_token");if(m)try{await S1(m)}catch(x){console.error("Error during logout:",x)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),i({loading:!1,developer:void 0})},verifyEmail:ey,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,requestPasswordReset:ty,confirmPasswordReset:ry,changePassword:ny,pcrConfig:t,getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:jc,getAttestationDocument:o,createOrganization:T0,listOrganizations:N0,deleteOrganization:j0,createProject:P0,listProjects:R0,getProject:U0,updateProject:D0,deleteProject:$0,createProjectSecret:M0,listProjectSecrets:V0,deleteProjectSecret:L0,getEmailSettings:H0,updateEmailSettings:F0,getOAuthSettings:z0,updateOAuthSettings:G0,inviteDeveloper:K0,listOrganizationMembers:Y0,listOrganizationInvites:q0,getOrganizationInvite:Z0,deleteOrganizationInvite:W0,updateMemberRole:J0,removeMember:X0,acceptInvite:Q0,apiUrl:e};return ut.jsx(Af.Provider,{value:h,children:r})}function iw(){return ft.useContext(xf)}function sw(){return ft.useContext(Af)}function ow(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function aw(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}je.OpenSecretContext=xf,je.OpenSecretDeveloper=nw,je.OpenSecretDeveloperContext=Af,je.OpenSecretProvider=rw,je.apiConfig=ti,je.generateSecureSecret=ow,je.hashSecret=aw,je.useOpenSecret=iw,je.useOpenSecretDeveloper=sw,Object.defineProperty(je,Symbol.toStringTag,{value:"Module"})});
133
+ `);return e===-1?null:r.slice(0,e+2)}const Y1=["eeddbb58f57c38894d6d5af5e575fbe791c5bf3bbcfb5df8da8cfcf0c2e1da1913108e6a762112444740b88c163d7f4b","74ed417f88cb0ca76c4a3d10f278bd010f1d3f95eafb254d4732511bb50e404507a4049b779c5230137e4091a5582271","9043fcab93b972d3c14ad2dc8fa78ca7ad374fc937c02435681772a003f7a72876bc4d578089b5c4cf3fe9b480f1aabb","52c3595b151d93d8b159c257301bfd5aa6f49210de0c55a6cd6df5ebeee44e4206cab950500f5d188f7fa14e6d900b75","91cb67311e910cce68cd5b7d0de77aa40610d87c6681439b44c46c3ff786ae643956ab2c812478a1da8745b259f07a45","859065ac81b81d3735130ba08b8af72a7256b603fefb74faabae25ed28cca6edcaa7c10ea32b5948d675c18a9b0f2b1d","acd82a7d3943e23e95a9dc3ce0b0107ea358d6287f9e3afa245622f7c7e3e0a66142a928b6efcc02f594a95366d3a99d"],J1=["62c0407056217a4c10764ed9045694c29fa93255d3cc04c2f989cdd9a1f8050c8b169714c71f1118ebce2fcc9951d1a9","cb95519905443f9f66f05f63c548b61ad1561a27fd5717b69285861aaea3c3063fe12a2571773b67fea3c6c11b4d8ec6","deb5895831b5e4286f5a2dcf5e9c27383821446f8df2b465f141d10743599be20ba3bb381ce063bf7139cc89f7f61d4c","70ba26c6af1ec3b57ce80e1adcc0ee96d70224d4c7a078f427895cdf68e1c30f09b5ac4c456588d872f3f21ff77c036b","669404ea71435b8f498b48db7816a5c2ab1d258b1a77685b11d84d15a73189504d79c4dee13a658de9f4a0cbfc39cfe8","a791bf92c25ffdfd372660e460a0e238c6778c090672df6509ae4bc065cf8668b6baac6b6a11d554af53ee0ff0172ad5","c4285443b87b9b12a6cea3bef1064ec060f652b235a297095975af8f134e5ed65f92d70d4616fdec80af9dff48bb9f35"],X1="MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEHiUY9kFWK1GqBGzczohhwEwElXzgWLDZa9R6wBx3JOBocgSt9+UIzZlJbPDjYeGBfDUXh7Z62BG2vVsh2NgclLB5S7A2ucBBtb1wd8vSQHP8jpdPhZX1slauPgbnROIP",Q1={prod:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrProdHistory.json",dev:"https://raw.githubusercontent.com/OpenSecretCloud/opensecret/master/pcrDevHistory.json"};async function ew(){try{const r=new Uint8Array(atob(X1).split("").map(e=>e.charCodeAt(0)));return await crypto.subtle.importKey("spki",r,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"])}catch(r){throw console.error("Error importing verification key:",r),new Error("Failed to import PCR verification key")}}async function tw(r,e){try{const t=(e==null?void 0:e[r])||Q1[r],n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch PCR history: ${n.status}`);return await n.json()}catch(t){throw console.error("Error fetching PCR history:",t),new Error("Failed to fetch PCR history")}}async function rw(r,e,t){try{const i=new TextEncoder().encode(r),s=new Uint8Array(atob(e).split("").map(o=>o.charCodeAt(0)));return await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-384"}},t,s,i)}catch(n){return console.error("Signature verification error:",n),!1}}async function vy(r,e,t){try{const n=await ew(),i=await tw(e,t);for(const s of i)if(s.PCR0===r&&await rw(s.PCR0,s.signature,n))return{isMatch:!0,text:"PCR0 matches remotely attested value",verifiedAt:new Date(s.timestamp*1e3).toLocaleString()};return null}catch(n){return console.error("PCR remote validation error:",n),null}}async function nw(r,e){const t=[...(e==null?void 0:e.pcr0Values)||[],...Y1],n=[...(e==null?void 0:e.pcr0DevValues)||[],...J1];if(t.includes(r))return{isMatch:!0,text:"PCR0 matches a known good value"};if(n.includes(r))return{isMatch:!0,text:"PCR0 matches development enclave"};if((e==null?void 0:e.remoteAttestation)!==!1)try{const s=await vy(r,"prod",e==null?void 0:e.remoteAttestationUrls);if(s)return s;const o=await vy(r,"dev",e==null?void 0:e.remoteAttestationUrls);if(o)return o}catch(s){console.error("Error during remote PCR validation:",s)}return{isMatch:!1,text:"PCR0 does not match a known good value"}}const us=Bc,Pc="641a0321a3e244efe456463195d606317ed7cdcc3c1756e09893f3c68f79bb5b";function my(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}async function iw(r){const e=await crypto.subtle.digest("SHA-256",r);return my(new Uint8Array(e))}async function fs(r,e,t){console.log("Raw timestamp:",r.timestamp),console.log("Date object:",new Date(r.timestamp));const n=Array.from(r.pcrs.entries()).map(([m,x])=>({id:m,value:my(x)})).filter(m=>!m.value.match(/^0+$/)),i=n.find(m=>m.id===0);let s=null;i&&(s=await nw(i.value,t));const o=[...e,r.certificate].map(m=>{const x=new xi(m);return{subject:x.subject,notBefore:x.notBefore.toLocaleString(),notAfter:x.notAfter.toLocaleString(),pem:x.toString("pem"),isRoot:x.subject==="C=US, O=Amazon, OU=AWS, CN=aws.nitro-enclaves"}}),c=new TextDecoder,u=new xi(e[0]),h=await iw(u.rawData);return{moduleId:r.module_id,publicKey:r.public_key?$r(r.public_key):null,timestamp:new Date(r.timestamp).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:"short"}),digest:r.digest,pcrs:n,certificates:o,userData:r.user_data?c.decode(r.user_data):null,nonce:r.nonce?c.decode(r.nonce):null,cert0hash:h,validatedPcr0Hash:s}}const xf=yt.createContext({auth:{loading:!0,user:void 0},clientId:"",signIn:async()=>{},signUp:async()=>{},signInGuest:async()=>{},signUpGuest:async()=>({id:"",email:void 0,access_token:"",refresh_token:""}),convertGuestToUserAccount:async()=>{},signOut:async()=>{},get:ay,put:sy,list:cy,del:oy,verifyEmail:ly,requestNewVerificationCode:Nc,requestNewVerificationEmail:Nc,refetchUser:async()=>{},changePassword:uy,refreshAccessToken:Tc,requestPasswordReset:async()=>{},confirmPasswordReset:async()=>{},initiateGitHubAuth:async()=>({auth_url:"",csrf_token:""}),handleGitHubCallback:async()=>{},initiateGoogleAuth:async()=>({auth_url:"",csrf_token:""}),handleGoogleCallback:async()=>{},initiateAppleAuth:async()=>({auth_url:"",state:""}),handleAppleCallback:async()=>{},handleAppleNativeSignIn:async()=>{},getPrivateKey:fy,getPrivateKeyBytes:hy,getPublicKey:py,signMessage:dy,aiCustomFetch:async()=>new Response,apiUrl:"",pcrConfig:{},getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:Pc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretProvider")},generateThirdPartyToken:async()=>({token:""}),encryptData:yy,decryptData:gy});function sw({children:r,apiUrl:e,clientId:t,pcrConfig:n={}}){const[i,s]=yt.useState({loading:!0,user:void 0}),[o,c]=yt.useState();yt.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretProvider requires a non-empty apiUrl. Please provide a valid API endpoint URL.");if(!t||t.trim()==="")throw new Error("OpenSecretProvider requires a non-empty clientId. Please provide a valid project UUID.");k1(e),Promise.resolve().then(()=>kf).then(({apiConfig:W})=>{const se=W.platformApiUrl||"";W.configure(e,se)})},[e,t]),yt.useEffect(()=>{i.user?c(()=>Z1()):c(void 0)},[i.user]);async function u(){const W=window.localStorage.getItem("access_token"),se=window.localStorage.getItem("refresh_token");if(!W||!se){s({loading:!1,user:void 0});return}try{const oe=await P1();s({loading:!1,user:oe})}catch(oe){console.error("Failed to fetch user:",oe),s({loading:!1,user:void 0})}}yt.useEffect(()=>{u()},[]);async function h(W,se){console.log("Signing in");try{const{access_token:oe,refresh_token:Ae}=await B1(W,se,t);window.localStorage.setItem("access_token",oe),window.localStorage.setItem("refresh_token",Ae),await u()}catch(oe){throw console.error(oe),oe}}async function m(W,se,oe,Ae){try{const{access_token:it,refresh_token:It}=await T1(W,se,oe,t,Ae||null);window.localStorage.setItem("access_token",it),window.localStorage.setItem("refresh_token",It),await u()}catch(it){throw console.error(it),it}}async function x(W,se){console.log("Signing in Guest");try{const{access_token:oe,refresh_token:Ae}=await O1(W,se,t);window.localStorage.setItem("access_token",oe),window.localStorage.setItem("refresh_token",Ae),await u()}catch(oe){throw console.error(oe),oe}}async function G(W,se){try{const{access_token:oe,refresh_token:Ae,id:it}=await N1(W,se,t);return window.localStorage.setItem("access_token",oe),window.localStorage.setItem("refresh_token",Ae),await u(),{access_token:oe,refresh_token:Ae,id:it}}catch(oe){throw console.error(oe),oe}}async function N(W,se,oe){try{await K1(W,se,oe),await u()}catch(Ae){throw console.error(Ae),Ae}}async function v(){const W=window.localStorage.getItem("refresh_token");if(W)try{await j1(W)}catch(se){console.error("Error during logout:",se)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),sessionStorage.removeItem("sessionKey"),sessionStorage.removeItem("sessionId"),s({loading:!1,user:void 0})}const Re={auth:i,clientId:t,signIn:h,signInGuest:x,signOut:v,signUp:m,signUpGuest:G,convertGuestToUserAccount:N,get:ay,put:sy,list:cy,del:oy,refetchUser:u,verifyEmail:ly,requestNewVerificationCode:Nc,requestNewVerificationEmail:Nc,changePassword:uy,refreshAccessToken:Tc,requestPasswordReset:(W,se)=>D1(W,se,t),confirmPasswordReset:(W,se,oe,Ae)=>$1(W,se,oe,Ae,t),initiateGitHubAuth:async W=>{try{return await M1(t,W)}catch(se){throw console.error("Failed to initiate GitHub auth:",se),se}},handleGitHubCallback:async(W,se,oe)=>{try{const{access_token:Ae,refresh_token:it}=await V1(W,se,oe);window.localStorage.setItem("access_token",Ae),window.localStorage.setItem("refresh_token",it),await u()}catch(Ae){throw console.error("GitHub callback error:",Ae),Ae}},initiateGoogleAuth:async W=>{try{return await L1(t,W)}catch(se){throw console.error("Failed to initiate Google auth:",se),se}},handleGoogleCallback:async(W,se,oe)=>{try{const{access_token:Ae,refresh_token:it}=await H1(W,se,oe);window.localStorage.setItem("access_token",Ae),window.localStorage.setItem("refresh_token",it),await u()}catch(Ae){throw console.error("Google callback error:",Ae),Ae}},initiateAppleAuth:async W=>{try{return await F1(t,W)}catch(se){throw console.error("Failed to initiate Apple auth:",se),se}},handleAppleCallback:async(W,se,oe)=>{try{const{access_token:Ae,refresh_token:it}=await z1(W,se,oe);window.localStorage.setItem("access_token",Ae),window.localStorage.setItem("refresh_token",it),await u()}catch(Ae){throw console.error("Apple callback error:",Ae),Ae}},handleAppleNativeSignIn:async(W,se)=>{try{const{access_token:oe,refresh_token:Ae}=await G1(W,t,se);window.localStorage.setItem("access_token",oe),window.localStorage.setItem("refresh_token",Ae),await u()}catch(oe){throw console.error("Apple native sign-in error:",oe),oe}},getPrivateKey:fy,getPrivateKeyBytes:hy,getPublicKey:py,signMessage:dy,aiCustomFetch:o||(async()=>new Response),apiUrl:e,pcrConfig:n,getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:Pc,getAttestationDocument:async()=>{const W=window.crypto.randomUUID(),se=await fetch(`${e}/attestation/${W}`);if(!se.ok)throw new Error("Failed to fetch attestation document");const oe=await se.json(),Ae=await ki(oe.attestation_document,us,W);return fs(Ae,Ae.cabundle,n)},generateThirdPartyToken:q1,encryptData:yy,decryptData:gy};return pt.jsx(xf.Provider,{value:Re,children:r})}const Af=yt.createContext({auth:{loading:!0,developer:void 0},signIn:async()=>{throw new Error("signIn called outside of OpenSecretDeveloper provider")},signUp:async()=>{throw new Error("signUp called outside of OpenSecretDeveloper provider")},signOut:async()=>{throw new Error("signOut called outside of OpenSecretDeveloper provider")},refetchDeveloper:async()=>{throw new Error("refetchDeveloper called outside of OpenSecretDeveloper provider")},verifyEmail:ey,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,requestPasswordReset:ty,confirmPasswordReset:ry,changePassword:ny,pcrConfig:{},getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:Pc,getAttestationDocument:async()=>{throw new Error("getAttestationDocument called outside of OpenSecretDeveloper provider")},createOrganization:T0,listOrganizations:N0,deleteOrganization:P0,createProject:j0,listProjects:R0,getProject:U0,updateProject:D0,deleteProject:$0,createProjectSecret:M0,listProjectSecrets:V0,deleteProjectSecret:L0,getEmailSettings:H0,updateEmailSettings:F0,getOAuthSettings:z0,updateOAuthSettings:G0,inviteDeveloper:K0,listOrganizationMembers:Y0,listOrganizationInvites:q0,getOrganizationInvite:Z0,deleteOrganizationInvite:W0,updateMemberRole:J0,removeMember:X0,acceptInvite:Q0,apiUrl:""});function ow({children:r,apiUrl:e,pcrConfig:t={}}){const[n,i]=yt.useState({loading:!0,developer:void 0});yt.useEffect(()=>{if(!e||e.trim()==="")throw new Error("OpenSecretDeveloper requires a non-empty apiUrl. Please provide a valid API endpoint URL.");b1(e),Promise.resolve().then(()=>kf).then(({apiConfig:m})=>{const x=m.appApiUrl||"";m.configure(x,e)}).catch(m=>{throw console.error("Failed to load apiConfig:",m),new Error("Failed to initialize OpenSecretDeveloper - could not load required dependencies")})},[e]);async function s(){const m=window.localStorage.getItem("access_token"),x=window.localStorage.getItem("refresh_token");if(!m||!x){i({loading:!1,developer:void 0});return}try{const G=await I1();i({loading:!1,developer:{...G.user,organizations:G.organizations}})}catch(G){console.error("Failed to fetch developer:",G),i({loading:!1,developer:void 0})}}const o=async()=>{const m=window.crypto.randomUUID(),x=await fetch(`${e}/attestation/${m}`);if(!x.ok)throw new Error("Failed to fetch attestation document");const G=await x.json(),N=await ki(G.attestation_document,us,m);return fs(N,N.cabundle,t)};yt.useEffect(()=>{s()},[]);async function c(m,x){try{const{access_token:G,refresh_token:N}=await x1(m,x);return window.localStorage.setItem("access_token",G),window.localStorage.setItem("refresh_token",N),await s(),{access_token:G,refresh_token:N,id:"",email:m}}catch(G){throw console.error("Login error:",G),G}}async function u(m,x,G,N){try{const{access_token:v,refresh_token:A}=await A1(m,x,G,N);return window.localStorage.setItem("access_token",v),window.localStorage.setItem("refresh_token",A),await s(),{access_token:v,refresh_token:A,id:"",email:m,name:N}}catch(v){throw console.error("Registration error:",v),v}}const h={auth:n,signIn:c,signUp:u,refetchDeveloper:s,signOut:async()=>{const m=window.localStorage.getItem("refresh_token");if(m)try{await S1(m)}catch(x){console.error("Error during logout:",x)}localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),i({loading:!1,developer:void 0})},verifyEmail:ey,requestNewVerificationCode:Oc,requestNewVerificationEmail:Oc,requestPasswordReset:ty,confirmPasswordReset:ry,changePassword:ny,pcrConfig:t,getAttestation:Ci,authenticate:ki,parseAttestationForView:fs,awsRootCertDer:us,expectedRootCertHash:Pc,getAttestationDocument:o,createOrganization:T0,listOrganizations:N0,deleteOrganization:P0,createProject:j0,listProjects:R0,getProject:U0,updateProject:D0,deleteProject:$0,createProjectSecret:M0,listProjectSecrets:V0,deleteProjectSecret:L0,getEmailSettings:H0,updateEmailSettings:F0,getOAuthSettings:z0,updateOAuthSettings:G0,inviteDeveloper:K0,listOrganizationMembers:Y0,listOrganizationInvites:q0,getOrganizationInvite:Z0,deleteOrganizationInvite:W0,updateMemberRole:J0,removeMember:X0,acceptInvite:Q0,apiUrl:e};return pt.jsx(Af.Provider,{value:h,children:r})}function aw(){return yt.useContext(xf)}function cw(){return yt.useContext(Af)}function lw(){const r=new Uint8Array(32);return crypto.getRandomValues(r),Array.from(r,e=>e.toString(16).padStart(2,"0")).join("")}async function uw(r){const t=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}Pe.OpenSecretContext=xf,Pe.OpenSecretDeveloper=ow,Pe.OpenSecretDeveloperContext=Af,Pe.OpenSecretProvider=sw,Pe.apiConfig=ti,Pe.generateSecureSecret=lw,Pe.hashSecret=uw,Pe.useOpenSecret=aw,Pe.useOpenSecretDeveloper=cw,Object.defineProperty(Pe,Symbol.toStringTag,{value:"Module"})});