@limrun/ui 0.9.0-rc.1 → 0.9.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/device-install/apple/client.d.ts +1 -0
- package/dist/core/device-install/apple/provisioning.d.ts +42 -31
- package/dist/core/device-install/apple/relay.d.ts +5 -9
- package/dist/core/device-install/storage/browser-storage.d.ts +19 -0
- package/dist/core/device-install/types.d.ts +2 -2
- package/dist/device-install/index.cjs +1 -9
- package/dist/device-install/index.js +76 -210
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.js +1 -1
- package/dist/device-install-dialog-86RDdoK9.js +2 -0
- package/dist/device-install-dialog-CnyDWf0q.mjs +462 -0
- package/dist/device-install-dialog.css +1 -1
- package/dist/hooks/use-device-install.d.ts +21 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/use-device-install-CbGVvwPp.js +31 -0
- package/dist/use-device-install-j1Gekpl4.mjs +13623 -0
- package/package.json +1 -1
- package/src/components/device-install/device-install-dialog.css +82 -1
- package/src/components/device-install/device-install-dialog.tsx +337 -187
- package/src/core/device-install/apple/client.ts +92 -4
- package/src/core/device-install/apple/provisioning.ts +67 -24
- package/src/core/device-install/apple/relay.ts +121 -205
- package/src/core/device-install/storage/browser-storage.ts +26 -1
- package/src/core/device-install/types.ts +2 -2
- package/src/hooks/use-device-install.ts +748 -60
- package/dist/device-install-dialog-CTwVViYY.js +0 -2
- package/dist/device-install-dialog-zzKJu7SM.mjs +0 -328
- package/dist/use-device-install-CgrOKKyi.mjs +0 -13042
- package/dist/use-device-install-DDKRf6IL.js +0 -23
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";const he=require("react");var Ki=Object.defineProperty,Mi=(t,e)=>{for(var r in e)Ki(t,r,{get:e[r],enumerable:!0})},Dt=self.crypto,Qt={};Mi(Qt,{Hash:()=>Zr,bigintFromBytes:()=>Yt,bitLength:()=>dn,byteLength:()=>hn,bytesFromBigint:()=>We,concatBytes:()=>Ze,constantTimeCompare:()=>vn,fromHex:()=>Gr,hash:()=>He,hashInterleave:()=>yn,modPow:()=>wt,randomBytes:()=>qr,toHex:()=>vt,xorBytes:()=>pn});function dn(t){return t.toString(2).length}function hn(t){return(dn(t)+7)/8|0}function Yt(t){let e=0n;for(let r of t.values())e=(e<<8n)+BigInt(r);return e}function We(t){let e=new Uint8Array(hn(t));for(let r=e.length-1;t>0;r--,t>>=8n)e[r]=Number(t&0xffn);return e}function qr(t){if(t<1)throw new RangeError("numBytes must be >= 1");let e=new Uint8Array(t);return Dt.getRandomValues(e),e}function Hr(t,e){if(e<1n)throw new RangeError("n must be > 0");let r=t%e;return r<0n?r+e:r}function qi(t,e){if(t<1n||e<1n)throw new RangeError("a and b must be > 0");let r=0n,o=1n,p=1n,y=0n;for(;t!==0n;){let f=e/t,a=e%t,g=r-p*f,l=o-y*f;e=t,t=a,r=p,o=y,p=g,y=l}return{g:e,x:r,y:o}}function Hi(t,e){let r=qi(Hr(t,e),e);if(r.g!==1n)throw new RangeError;return Hr(r.x,e)}function wt(t,e,r){if(r<1n)throw new RangeError("n must be > 0");if(r===1n)return 0n;if(t=Hr(t,r),e<0n)return Hi(wt(t,e>=0?e:-e,r),r);let o=1n;for(;e>0;)e%2n===1n&&(o=o*t%r),e=e/2n,t=t**2n%r;return o}function Ze(...t){let e=0;for(let p of t)e+=p.byteLength;let r=new Uint8Array(e),o=0;for(let p of t)r.set(p,o),o+=p.byteLength;return r}function pn(t,e){if(t.length!==e.length)throw new Error("xorBytes: buffers must be same length");let r=t.length,o=new Uint8Array(r);for(let p=0;p<r;p++)o[p]=t[p]^e[p];return o}function vt(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function Gr(t){return Uint8Array.from(t.match(/.{2}/g)?.map(e=>parseInt(e,16))??[])}function vn(t,e){if(t.length!==e.length)return!1;let r=t.length,o=0;for(let p=0;p<r;p++)o|=t[p]^e[p];return o===0}var Zr=(t=>(t[t.SHA1=3]="SHA1",t[t.SHA256=5]="SHA256",t[t.SHA384=6]="SHA384",t[t.SHA512=7]="SHA512",t))(Zr||{});function He(t,e){switch(t){case 3:return Dt.subtle.digest("SHA-1",e);case 5:return Dt.subtle.digest("SHA-256",e);case 6:return Dt.subtle.digest("SHA-384",e);case 7:return Dt.subtle.digest("SHA-512",e)}}async function yn(t,e){let r=new Uint8Array(e,0,e.byteLength);for(var o=0;o<r.length;o++)if(r[o]!==0){(e.byteLength-o)%2===1&&o++,r=new Uint8Array(e,o,e.byteLength-o);break}let p=r.length/2,y=new Uint8Array(p),f=new Uint8Array(p);for(let b=0;b<r.length;b++)y[b]=r[b*2],f[b]=r[b*2+1];let a=new Uint8Array(await He(t,y)),g=new Uint8Array(await He(t,f)),l=new Uint8Array(a.byteLength*2);for(let b=0;b<a.byteLength;b++)l[b*2]=a[b],l[b*2+1]=g[b];return l}var gn=(t=>(t[t.RFC2945=0]="RFC2945",t[t.SRPTools=1]="SRPTools",t[t.GoSRP=2]="GoSRP",t[t.GSA=3]="GSA",t))(gn||{}),Gi=new Map([[1024,{g:2n,N:0xeeaf0ab9adb38dd69c33f80afa8fc5e86072618775ff3c0b9ea2314c9c256576d674df7496ea81d3383b4813d692c6e0e0d5d8e250b98be48e495c1d6089dad15dc7d7b46154d6b6ce8ef4ad69b15d4982559b297bcf1885c529f566660e57ec68edbc3c05726cc02fd4cbf4976eaa9afd5138fe8376435b9fc61d2fc0eb06e3n,n:128}],[1536,{g:2n,N:0x9def3cafb939277ab1f12a8617a47bbbdba51df499ac4c80beeea9614b19cc4d5f4f5f556e27cbde51c6a94be4607a291558903ba0d0f84380b655bb9a22e8dcdf028a7cec67f0d08134b1c8b97989149b609e0be3bab63d47548381dbc5b1fc764e3f4b53dd9da1158bfd3e2b9c8cf56edf019539349627db2fd53d24b7c48665772e437d6c7f8ce442734af7ccb7ae837c264ae3a9beb87f8a2fe9b8b5292e5a021fff5e91479e8ce7a28c2442c6f315180f93499a234dcf76e3fed135f9bbn,n:192}],[2048,{g:2n,N:0xac6bdb41324a9a9bf166de5e1389582faf72b6651987ee07fc3192943db56050a37329cbb4a099ed8193e0757767a13dd52312ab4b03310dcd7f48a9da04fd50e8083969edb767b0cf6095179a163ab3661a05fbd5faaae82918a9962f0b93b855f97993ec975eeaa80d740adbf4ff747359d041d5c33ea71d281e446b14773bca97b43a23fb801676bd207a436c6481f1d2b9078717461a5b9d32e688f87748544523b524b0d57d5ea77a2775d2ecfa032cfbdbf52fb3786160279004e57ae6af874e7303ce53299ccc041c7bc308d82a5698f3a8d0c38271ae35f8e9dbfbb694b5c803d89f7ae435de236d525f54759b65e372fcd68ef20fa7111f9e4aff73n,n:256}],[3072,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffffn,n:384}],[4096,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffffn,n:512}],[6144,{g:5n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffffn,n:768}],[8192,{g:19n,N:0xffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffffn,n:1024}]]);function zi(t=0){t===0&&(t=2048);let e=Gi.get(t);if(!e)throw new Error(`Invalid prime field size ${t}`);return e}function Gt(t,e){let r=We(t);if(r.length>=e)return r;let o=e-r.length,p=new Uint8Array(e);for(let y=0;y<o;y++)p[y]=0;return p.set(r,o),p}var Qi=class{constructor(t,e,r=0){this.m=t,this.h=e,this.pf=zi(r)}pf;async hashInt(t){return Yt(new Uint8Array(await He(this.h,t)))}async verifier(t,e,r){let o=this.m===2?new Uint8Array(await He(this.h,t)):t,p=this.m===2?new Uint8Array(await He(this.h,e)):e,y=this.pf;r||(r=qr(y.n));let f=this.m===2?await this.hashInt(Ze(o,p,r)):await this.hashInt(Ze(r,new Uint8Array(await He(this.h,Ze(o,new Uint8Array([58]),p))))),a=wt(y.g,f,y.N);return new Yi({i:o,s:r,v:We(a),h:this.h,pf:y})}async newClient(t,e,r){let o=this.pf;return r||(r=Yt(qr(o.n))),new Wi({s:this,i:this.m===2?new Uint8Array(await He(this.h,t)):t,p:this.m===2?new Uint8Array(await He(this.h,e)):e,a:r,A:wt(o.g,r,o.N),k:await this.hashInt(Ze(We(o.N),Gt(o.g,Number(o.n))))})}},Yi=class{i;s;v;h;pf;constructor(t){this.i=t.i,this.s=t.s,this.v=t.v,this.h=t.h,this.pf=t.pf}encode(){let t=vt(this.i),e=[this.pf.n.toString(10),this.pf.N.toString(16),this.pf.g.toString(16),this.h.toString(10),t,vt(this.s),vt(this.v)].join(":");return[t,e]}},Wi=class{s;i;p;a;A;k;_K;_M;get K(){return this._K}get M(){return this._M}constructor(t){this.s=t.s,this.i=t.i,this.p=t.p,this.a=t.a,this.A=t.A,this.k=t.k,this._K=new Uint8Array,this._M=new Uint8Array}credentials(){return[vt(this.i),vt(We(this.A))].join(":")}parseServerCredentials(t){let e=t.split(":");if(!e[0]||!e[1])throw new Error("Invalid server public key");let r=Gr(e[0]),o=Gr(e[1]);return[r,o]}async generate(t,e){let r=Yt(e),o=this.s.pf;if(r%o.N===0n)throw new Error("Invalid server public key");let p=await this.s.hashInt(Ze(Gt(this.A,o.n),Gt(r,o.n)));if(p===0n)throw new Error("Invalid server public key");let y=this.s.m===2?await this.s.hashInt(Ze(this.i,this.p,t)):await this.s.hashInt(Ze(t,new Uint8Array(await He(this.s.h,Ze(this.s.m==3?new Uint8Array([]):this.i,new Uint8Array([58]),this.p))))),f=wt(o.g,y,o.N)*this.k,a=r-f,g=this.a+p*y,l=wt(a,g,o.N);return this._K=this.s.m===0?new Uint8Array(await yn(this.s.h,We(l))):new Uint8Array(await He(this.s.h,We(l))),this.s.m===2?this._M=new Uint8Array(await He(this.s.h,Ze(this._K,We(this.A),We(r),this.i,t,We(o.N),We(o.g)))):this._M=new Uint8Array(await He(this.s.h,Ze(pn(new Uint8Array(await He(this.s.h,We(o.N))),new Uint8Array(await He(this.s.h,this.s.m==3?Gt(o.g,o.n):We(o.g)))),new Uint8Array(await He(this.s.h,this.i)),t,We(this.A),We(r),this._K))),vt(this._M)}async generateM2(){if(!this.M)throw new Error("M not generated");return new Uint8Array(await He(this.s.h,Ze(We(this.A),this._M,this._K)))}async serverOk(t){let e=new TextEncoder,r=e.encode(vt(new Uint8Array(await He(this.s.h,Ze(this._K,this.M))))),o=e.encode(t);return vn(r,o)}};const mn=new Qi(gn.GSA,Zr.SHA256,2048);class Cn{constructor(e){this.accountName=e}srpClient;async init(){if(this.srpClient)throw new Error("SRP client is already initialized.");return this.srpClient=await mn.newClient(zr(this.accountName),new Uint8Array),{accountName:this.accountName,protocols:["s2k","s2k_fo"],a:tr(Qt.bytesFromBigint(this.srpClient.A))}}async complete(e,r){if(!this.srpClient)throw new Error("SRP client is not initialized.");if(r.protocol!=="s2k"&&r.protocol!=="s2k_fo")throw new Error(`Unsupported Apple SRP protocol ${r.protocol}.`);const o=va(r.salt),p=va(r.b),y=await ji(r.protocol,e,o,r.iteration);this.srpClient.p=y,await this.srpClient.generate(o,p);const f=await this.srpClient.generateM2();return{accountName:this.accountName,c:r.c,m1:tr(this.srpClient._M),m2:tr(f)}}}async function ji(t,e,r,o){let p=new Uint8Array(await Qt.hash(mn.h,rr(zr(e))));t==="s2k_fo"&&(p=zr(Qt.toHex(p)));const y=await crypto.subtle.importKey("raw",rr(p),{name:"PBKDF2"},!1,["deriveBits"]),f=await crypto.subtle.deriveBits({name:"PBKDF2",hash:{name:"SHA-256"},iterations:o,salt:rr(r)},y,256);return new Uint8Array(f)}function zr(t){return new TextEncoder().encode(t)}function tr(t){let e="";for(const r of t)e+=String.fromCharCode(r);return btoa(e)}function va(t){const e=atob(t),r=new Uint8Array(e.length);for(let o=0;o<e.length;o+=1)r[o]=e.charCodeAt(o);return r}function rr(t){const e=new Uint8Array(t.byteLength);return e.set(t),e.buffer}async function En(t,e){const r=await fetch(Jr(t,"/apple/auth/session",e),{method:"POST",headers:In(e)});if(!r.ok)throw new Error(`Apple relay session failed: HTTP ${r.status} ${await r.text()}`);return await r.json()}async function Qr(t,e,r){const o=await fetch(Jr(t,"/apple/auth/session/delete",r),{method:"POST",headers:Xi(r),body:JSON.stringify({appleSessionId:e})});if(!o.ok)throw new Error(`Apple relay session delete failed: HTTP ${o.status} ${await o.text()}`)}async function yt(t,e,r,o){const p=await fetch($i(t,e,r.url,o),{method:r.method??"GET",headers:{...r.headers??{},...In(o)},body:r.body});return Zi(p)}async function xn(t,e,r,o){return yt(t,e,{method:"POST",url:"https://idmsa.apple.com/appleauth/auth/signin/init",headers:ea(),body:JSON.stringify(r)},o)}async function Sn(t,e,r,o){const p=await Ji(t,e,o);return yt(t,e,{method:"POST",url:"https://idmsa.apple.com/appleauth/auth/signin/complete?isRememberMeEnabled=false",headers:{...ea(),...p?{"X-Apple-HC":p}:{}},body:JSON.stringify(r)},o)}async function bn(t,e,r,o){return yt(t,e,{method:"POST",url:"https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode",headers:ea(),body:JSON.stringify({securityCode:{code:r}})},o)}async function Tn(t,e,r){return yt(t,e,{method:"GET",url:"https://appstoreconnect.apple.com/olympus/v1/session",headers:{Accept:"application/json"}},r)}async function An(t,e,r,o){return yt(t,e,{method:r.method??"GET",url:`https://developer.apple.com/services-account/QH65B2${r.path}`,headers:{Accept:"application/json",...r.payload?{"Content-Type":"application/x-www-form-urlencoded"}:{}},body:r.payload?rs(r.payload):void 0},o)}function Jr(t,e,r){const o=new URL(e,t);return r&&o.searchParams.set("token",r),o}function $i(t,e,r,o){const p=Jr(t,"/apple/relay",o);return p.searchParams.set("appleSessionId",e),p.searchParams.set("url",r),p}function Xi(t){const e={"Content-Type":"application/json"};return t&&(e.Authorization=`Bearer ${t}`),e}function In(t){return t?{Authorization:`Bearer ${t}`}:{}}function ea(){return{Accept:"application/json, text/javascript, */*; q=0.01","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}}async function Zi(t){const e=await t.text();let r;try{r=e?JSON.parse(e):void 0}catch{r=void 0}return{status:t.status,statusText:`${t.status} ${t.statusText}`.trim(),headers:Object.fromEntries(t.headers.entries()),body:r,rawBody:e,bodyBase64:as(new TextEncoder().encode(e))}}async function Ji(t,e,r){const p=(await yt(t,e,{method:"GET",url:"https://appstoreconnect.apple.com/olympus/v1/app/config?hostname=itunesconnect.apple.com",headers:{Accept:"application/json"}},r)).body?.authServiceKey,y=await yt(t,e,{method:"GET",url:`https://idmsa.apple.com/appleauth/auth/signin${p?`?widgetKey=${encodeURIComponent(p)}`:""}`,headers:{Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}},r),f=y.headers?.["x-apple-hc-bits"],a=y.headers?.["x-apple-hc-challenge"];if(!(!f||!a))return es(parseInt(f,10),a)}async function es(t,e){if(!Number.isFinite(t)||t<=0)return;const r=new Date().toISOString().replace(/[-:T.Z]/g,"").slice(0,14);for(let o=0;;o+=1){const p=`1:${t}:${r}:${e}::${o}`,y=new Uint8Array(await crypto.subtle.digest("SHA-1",new TextEncoder().encode(p)));if(ts(y,t))return p}}function ts(t,e){for(const r of t){if(e<=0)return!0;if(e>=8){if(r!==0)return!1;e-=8;continue}return r>>8-e===0}return e<=0}function rs(t){const e=new URLSearchParams;if(!t||typeof t!="object"||Array.isArray(t))return e;for(const[r,o]of Object.entries(t))o!=null&&(typeof o=="string"||typeof o=="number"||typeof o=="boolean"?e.set(r,String(o)):e.set(r,JSON.stringify(o)));return e}function as(t){let e="";for(const r of t)e+=String.fromCharCode(r);return btoa(e)}async function Bn({limbuildApiUrl:t,accountName:e,password:r,token:o}){const{appleSessionId:p}=await En(t,o);try{const y=new Cn(e),f=await xn(t,p,await y.init(),o);if(!f.body)throw new Error("Apple SRP init response did not include a body.");const a=await y.complete(r,f.body),g=await Sn(t,p,{...a,rememberMe:!1,trustTokens:[]},o);return{appleSessionId:p,completeResponse:g,requiresTwoFactor:g.status===409,finishTwoFactor:l=>bn(t,p,l,o),finalize:()=>Tn(t,p,o),close:()=>Qr(t,p,o)}}catch(y){throw await Qr(t,p,o).catch(()=>{}),y}}var ns=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function is(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ss(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function o(){var p=!1;try{p=this instanceof o}catch{}return p?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var p=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,p.get?p:{enumerable:!0,get:function(){return t[o]}})}),r}var ar,ya;function le(){return ya||(ya=1,ar={options:{usePureJavaScript:!1}}),ar}var nr={exports:{}},ir,ga;function os(){if(ga)return ir;ga=1;var t={};ir=t;var e={};t.encode=function(o,p,y){if(typeof p!="string")throw new TypeError('"alphabet" must be a string.');if(y!==void 0&&typeof y!="number")throw new TypeError('"maxline" must be a number.');var f="";if(!(o instanceof Uint8Array))f=r(o,p);else{var a=0,g=p.length,l=p.charAt(0),b=[0];for(a=0;a<o.length;++a){for(var U=0,S=o[a];U<b.length;++U)S+=b[U]<<8,b[U]=S%g,S=S/g|0;for(;S>0;)b.push(S%g),S=S/g|0}for(a=0;o[a]===0&&a<o.length-1;++a)f+=l;for(a=b.length-1;a>=0;--a)f+=p[b[a]]}if(y){var c=new RegExp(".{1,"+y+"}","g");f=f.match(c).join(`\r
|
|
2
|
-
`)}return f},t.decode=function(o,p){if(typeof o!="string")throw new TypeError('"input" must be a string.');if(typeof p!="string")throw new TypeError('"alphabet" must be a string.');var y=e[p];if(!y){y=e[p]=[];for(var f=0;f<p.length;++f)y[p.charCodeAt(f)]=f}o=o.replace(/\s/g,"");for(var a=p.length,g=p.charAt(0),l=[0],f=0;f<o.length;f++){var b=y[o.charCodeAt(f)];if(b===void 0)return;for(var U=0,S=b;U<l.length;++U)S+=l[U]*a,l[U]=S&255,S>>=8;for(;S>0;)l.push(S&255),S>>=8}for(var c=0;o[c]===g&&c<o.length-1;++c)l.push(0);return typeof Buffer<"u"?Buffer.from(l.reverse()):new Uint8Array(l.reverse())};function r(o,p){var y=0,f=p.length,a=p.charAt(0),g=[0];for(y=0;y<o.length();++y){for(var l=0,b=o.at(y);l<g.length;++l)b+=g[l]<<8,g[l]=b%f,b=b/f|0;for(;b>0;)g.push(b%f),b=b/f|0}var U="";for(y=0;o.at(y)===0&&y<o.length()-1;++y)U+=a;for(y=g.length-1;y>=0;--y)U+=p[g[y]];return U}return ir}var ma;function pe(){if(ma)return nr.exports;ma=1;var t=le(),e=os(),r=nr.exports=t.util=t.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){r.nextTick=process.nextTick,typeof setImmediate=="function"?r.setImmediate=setImmediate:r.setImmediate=r.nextTick;return}if(typeof setImmediate=="function"){r.setImmediate=function(){return setImmediate.apply(void 0,arguments)},r.nextTick=function(i){return setImmediate(i)};return}if(r.setImmediate=function(i){setTimeout(i,0)},typeof window<"u"&&typeof window.postMessage=="function"){let i=function(n){if(n.source===window&&n.data===s){n.stopPropagation();var I=h.slice();h.length=0,I.forEach(function(L){L()})}};var s="forge.setImmediate",h=[];r.setImmediate=function(n){h.push(n),h.length===1&&window.postMessage(s,"*")},window.addEventListener("message",i,!0)}if(typeof MutationObserver<"u"){var v=Date.now(),A=!0,_=document.createElement("div"),h=[];new MutationObserver(function(){var n=h.slice();h.length=0,n.forEach(function(I){I()})}).observe(_,{attributes:!0});var d=r.setImmediate;r.setImmediate=function(n){Date.now()-v>15?(v=Date.now(),d(n)):(h.push(n),h.length===1&&_.setAttribute("a",A=!A))}}r.nextTick=r.setImmediate})(),r.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,r.globalScope=(function(){return r.isNodejs?ns:typeof self>"u"?window:self})(),r.isArray=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"},r.isArrayBuffer=function(s){return typeof ArrayBuffer<"u"&&s instanceof ArrayBuffer},r.isArrayBufferView=function(s){return s&&r.isArrayBuffer(s.buffer)&&s.byteLength!==void 0};function o(s){if(!(s===8||s===16||s===24||s===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+s)}r.ByteBuffer=p;function p(s){if(this.data="",this.read=0,typeof s=="string")this.data=s;else if(r.isArrayBuffer(s)||r.isArrayBufferView(s))if(typeof Buffer<"u"&&s instanceof Buffer)this.data=s.toString("binary");else{var h=new Uint8Array(s);try{this.data=String.fromCharCode.apply(null,h)}catch{for(var v=0;v<h.length;++v)this.putByte(h[v])}}else(s instanceof p||typeof s=="object"&&typeof s.data=="string"&&typeof s.read=="number")&&(this.data=s.data,this.read=s.read);this._constructedStringLength=0}r.ByteStringBuffer=p;var y=4096;r.ByteStringBuffer.prototype._optimizeConstructedString=function(s){this._constructedStringLength+=s,this._constructedStringLength>y&&(this.data.substr(0,1),this._constructedStringLength=0)},r.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},r.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},r.ByteStringBuffer.prototype.putByte=function(s){return this.putBytes(String.fromCharCode(s))},r.ByteStringBuffer.prototype.fillWithByte=function(s,h){s=String.fromCharCode(s);for(var v=this.data;h>0;)h&1&&(v+=s),h>>>=1,h>0&&(s+=s);return this.data=v,this._optimizeConstructedString(h),this},r.ByteStringBuffer.prototype.putBytes=function(s){return this.data+=s,this._optimizeConstructedString(s.length),this},r.ByteStringBuffer.prototype.putString=function(s){return this.putBytes(r.encodeUtf8(s))},r.ByteStringBuffer.prototype.putInt16=function(s){return this.putBytes(String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},r.ByteStringBuffer.prototype.putInt24=function(s){return this.putBytes(String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},r.ByteStringBuffer.prototype.putInt32=function(s){return this.putBytes(String.fromCharCode(s>>24&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255))},r.ByteStringBuffer.prototype.putInt16Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255))},r.ByteStringBuffer.prototype.putInt24Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s>>16&255))},r.ByteStringBuffer.prototype.putInt32Le=function(s){return this.putBytes(String.fromCharCode(s&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>24&255))},r.ByteStringBuffer.prototype.putInt=function(s,h){o(h);var v="";do h-=8,v+=String.fromCharCode(s>>h&255);while(h>0);return this.putBytes(v)},r.ByteStringBuffer.prototype.putSignedInt=function(s,h){return s<0&&(s+=2<<h-1),this.putInt(s,h)},r.ByteStringBuffer.prototype.putBuffer=function(s){return this.putBytes(s.getBytes())},r.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},r.ByteStringBuffer.prototype.getInt16=function(){var s=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,s},r.ByteStringBuffer.prototype.getInt24=function(){var s=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,s},r.ByteStringBuffer.prototype.getInt32=function(){var s=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,s},r.ByteStringBuffer.prototype.getInt16Le=function(){var s=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,s},r.ByteStringBuffer.prototype.getInt24Le=function(){var s=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,s},r.ByteStringBuffer.prototype.getInt32Le=function(){var s=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,s},r.ByteStringBuffer.prototype.getInt=function(s){o(s);var h=0;do h=(h<<8)+this.data.charCodeAt(this.read++),s-=8;while(s>0);return h},r.ByteStringBuffer.prototype.getSignedInt=function(s){var h=this.getInt(s),v=2<<s-2;return h>=v&&(h-=v<<1),h},r.ByteStringBuffer.prototype.getBytes=function(s){var h;return s?(s=Math.min(this.length(),s),h=this.data.slice(this.read,this.read+s),this.read+=s):s===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.ByteStringBuffer.prototype.bytes=function(s){return typeof s>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+s)},r.ByteStringBuffer.prototype.at=function(s){return this.data.charCodeAt(this.read+s)},r.ByteStringBuffer.prototype.setAt=function(s,h){return this.data=this.data.substr(0,this.read+s)+String.fromCharCode(h)+this.data.substr(this.read+s+1),this},r.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},r.ByteStringBuffer.prototype.copy=function(){var s=r.createBuffer(this.data);return s.read=this.read,s},r.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},r.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},r.ByteStringBuffer.prototype.truncate=function(s){var h=Math.max(0,this.length()-s);return this.data=this.data.substr(this.read,h),this.read=0,this},r.ByteStringBuffer.prototype.toHex=function(){for(var s="",h=this.read;h<this.data.length;++h){var v=this.data.charCodeAt(h);v<16&&(s+="0"),s+=v.toString(16)}return s},r.ByteStringBuffer.prototype.toString=function(){return r.decodeUtf8(this.bytes())};function f(s,h){h=h||{},this.read=h.readOffset||0,this.growSize=h.growSize||1024;var v=r.isArrayBuffer(s),A=r.isArrayBufferView(s);if(v||A){v?this.data=new DataView(s):this.data=new DataView(s.buffer,s.byteOffset,s.byteLength),this.write="writeOffset"in h?h.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,s!=null&&this.putBytes(s),"writeOffset"in h&&(this.write=h.writeOffset)}r.DataBuffer=f,r.DataBuffer.prototype.length=function(){return this.write-this.read},r.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},r.DataBuffer.prototype.accommodate=function(s,h){if(this.length()>=s)return this;h=Math.max(h||this.growSize,s);var v=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),A=new Uint8Array(this.length()+h);return A.set(v),this.data=new DataView(A.buffer),this},r.DataBuffer.prototype.putByte=function(s){return this.accommodate(1),this.data.setUint8(this.write++,s),this},r.DataBuffer.prototype.fillWithByte=function(s,h){this.accommodate(h);for(var v=0;v<h;++v)this.data.setUint8(s);return this},r.DataBuffer.prototype.putBytes=function(s,h){if(r.isArrayBufferView(s)){var v=new Uint8Array(s.buffer,s.byteOffset,s.byteLength),A=v.byteLength-v.byteOffset;this.accommodate(A);var _=new Uint8Array(this.data.buffer,this.write);return _.set(v),this.write+=A,this}if(r.isArrayBuffer(s)){var v=new Uint8Array(s);this.accommodate(v.byteLength);var _=new Uint8Array(this.data.buffer);return _.set(v,this.write),this.write+=v.byteLength,this}if(s instanceof r.DataBuffer||typeof s=="object"&&typeof s.read=="number"&&typeof s.write=="number"&&r.isArrayBufferView(s.data)){var v=new Uint8Array(s.data.byteLength,s.read,s.length());this.accommodate(v.byteLength);var _=new Uint8Array(s.data.byteLength,this.write);return _.set(v),this.write+=v.byteLength,this}if(s instanceof r.ByteStringBuffer&&(s=s.data,h="binary"),h=h||"binary",typeof s=="string"){var d;if(h==="hex")return this.accommodate(Math.ceil(s.length/2)),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.hex.decode(s,d,this.write),this;if(h==="base64")return this.accommodate(Math.ceil(s.length/4)*3),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.base64.decode(s,d,this.write),this;if(h==="utf8"&&(s=r.encodeUtf8(s),h="binary"),h==="binary"||h==="raw")return this.accommodate(s.length),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.raw.decode(d),this;if(h==="utf16")return this.accommodate(s.length*2),d=new Uint16Array(this.data.buffer,this.write),this.write+=r.text.utf16.encode(d),this;throw new Error("Invalid encoding: "+h)}throw Error("Invalid parameter: "+s)},r.DataBuffer.prototype.putBuffer=function(s){return this.putBytes(s),s.clear(),this},r.DataBuffer.prototype.putString=function(s){return this.putBytes(s,"utf16")},r.DataBuffer.prototype.putInt16=function(s){return this.accommodate(2),this.data.setInt16(this.write,s),this.write+=2,this},r.DataBuffer.prototype.putInt24=function(s){return this.accommodate(3),this.data.setInt16(this.write,s>>8&65535),this.data.setInt8(this.write,s>>16&255),this.write+=3,this},r.DataBuffer.prototype.putInt32=function(s){return this.accommodate(4),this.data.setInt32(this.write,s),this.write+=4,this},r.DataBuffer.prototype.putInt16Le=function(s){return this.accommodate(2),this.data.setInt16(this.write,s,!0),this.write+=2,this},r.DataBuffer.prototype.putInt24Le=function(s){return this.accommodate(3),this.data.setInt8(this.write,s>>16&255),this.data.setInt16(this.write,s>>8&65535,!0),this.write+=3,this},r.DataBuffer.prototype.putInt32Le=function(s){return this.accommodate(4),this.data.setInt32(this.write,s,!0),this.write+=4,this},r.DataBuffer.prototype.putInt=function(s,h){o(h),this.accommodate(h/8);do h-=8,this.data.setInt8(this.write++,s>>h&255);while(h>0);return this},r.DataBuffer.prototype.putSignedInt=function(s,h){return o(h),this.accommodate(h/8),s<0&&(s+=2<<h-1),this.putInt(s,h)},r.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},r.DataBuffer.prototype.getInt16=function(){var s=this.data.getInt16(this.read);return this.read+=2,s},r.DataBuffer.prototype.getInt24=function(){var s=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,s},r.DataBuffer.prototype.getInt32=function(){var s=this.data.getInt32(this.read);return this.read+=4,s},r.DataBuffer.prototype.getInt16Le=function(){var s=this.data.getInt16(this.read,!0);return this.read+=2,s},r.DataBuffer.prototype.getInt24Le=function(){var s=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,s},r.DataBuffer.prototype.getInt32Le=function(){var s=this.data.getInt32(this.read,!0);return this.read+=4,s},r.DataBuffer.prototype.getInt=function(s){o(s);var h=0;do h=(h<<8)+this.data.getInt8(this.read++),s-=8;while(s>0);return h},r.DataBuffer.prototype.getSignedInt=function(s){var h=this.getInt(s),v=2<<s-2;return h>=v&&(h-=v<<1),h},r.DataBuffer.prototype.getBytes=function(s){var h;return s?(s=Math.min(this.length(),s),h=this.data.slice(this.read,this.read+s),this.read+=s):s===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.DataBuffer.prototype.bytes=function(s){return typeof s>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+s)},r.DataBuffer.prototype.at=function(s){return this.data.getUint8(this.read+s)},r.DataBuffer.prototype.setAt=function(s,h){return this.data.setUint8(s,h),this},r.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},r.DataBuffer.prototype.copy=function(){return new r.DataBuffer(this)},r.DataBuffer.prototype.compact=function(){if(this.read>0){var s=new Uint8Array(this.data.buffer,this.read),h=new Uint8Array(s.byteLength);h.set(s),this.data=new DataView(h),this.write-=this.read,this.read=0}return this},r.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},r.DataBuffer.prototype.truncate=function(s){return this.write=Math.max(0,this.length()-s),this.read=Math.min(this.read,this.write),this},r.DataBuffer.prototype.toHex=function(){for(var s="",h=this.read;h<this.data.byteLength;++h){var v=this.data.getUint8(h);v<16&&(s+="0"),s+=v.toString(16)}return s},r.DataBuffer.prototype.toString=function(s){var h=new Uint8Array(this.data,this.read,this.length());if(s=s||"utf8",s==="binary"||s==="raw")return r.binary.raw.encode(h);if(s==="hex")return r.binary.hex.encode(h);if(s==="base64")return r.binary.base64.encode(h);if(s==="utf8")return r.text.utf8.decode(h);if(s==="utf16")return r.text.utf16.decode(h);throw new Error("Invalid encoding: "+s)},r.createBuffer=function(s,h){return h=h||"raw",s!==void 0&&h==="utf8"&&(s=r.encodeUtf8(s)),new r.ByteBuffer(s)},r.fillString=function(s,h){for(var v="";h>0;)h&1&&(v+=s),h>>>=1,h>0&&(s+=s);return v},r.xorBytes=function(s,h,v){for(var A="",_="",d="",i=0,n=0;v>0;--v,++i)_=s.charCodeAt(i)^h.charCodeAt(i),n>=10&&(A+=d,d="",n=0),d+=String.fromCharCode(_),++n;return A+=d,A},r.hexToBytes=function(s){var h="",v=0;for(s.length&!0&&(v=1,h+=String.fromCharCode(parseInt(s[0],16)));v<s.length;v+=2)h+=String.fromCharCode(parseInt(s.substr(v,2),16));return h},r.bytesToHex=function(s){return r.createBuffer(s).toHex()},r.int32ToBytes=function(s){return String.fromCharCode(s>>24&255)+String.fromCharCode(s>>16&255)+String.fromCharCode(s>>8&255)+String.fromCharCode(s&255)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";r.encode64=function(s,h){for(var v="",A="",_,d,i,n=0;n<s.length;)_=s.charCodeAt(n++),d=s.charCodeAt(n++),i=s.charCodeAt(n++),v+=a.charAt(_>>2),v+=a.charAt((_&3)<<4|d>>4),isNaN(d)?v+="==":(v+=a.charAt((d&15)<<2|i>>6),v+=isNaN(i)?"=":a.charAt(i&63)),h&&v.length>h&&(A+=v.substr(0,h)+`\r
|
|
3
|
-
`,v=v.substr(h));return A+=v,A},r.decode64=function(s){s=s.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var h="",v,A,_,d,i=0;i<s.length;)v=g[s.charCodeAt(i++)-43],A=g[s.charCodeAt(i++)-43],_=g[s.charCodeAt(i++)-43],d=g[s.charCodeAt(i++)-43],h+=String.fromCharCode(v<<2|A>>4),_!==64&&(h+=String.fromCharCode((A&15)<<4|_>>2),d!==64&&(h+=String.fromCharCode((_&3)<<6|d)));return h},r.encodeUtf8=function(s){return unescape(encodeURIComponent(s))},r.decodeUtf8=function(s){return decodeURIComponent(escape(s))},r.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},r.binary.raw.encode=function(s){return String.fromCharCode.apply(null,s)},r.binary.raw.decode=function(s,h,v){var A=h;A||(A=new Uint8Array(s.length)),v=v||0;for(var _=v,d=0;d<s.length;++d)A[_++]=s.charCodeAt(d);return h?_-v:A},r.binary.hex.encode=r.bytesToHex,r.binary.hex.decode=function(s,h,v){var A=h;A||(A=new Uint8Array(Math.ceil(s.length/2))),v=v||0;var _=0,d=v;for(s.length&1&&(_=1,A[d++]=parseInt(s[0],16));_<s.length;_+=2)A[d++]=parseInt(s.substr(_,2),16);return h?d-v:A},r.binary.base64.encode=function(s,h){for(var v="",A="",_,d,i,n=0;n<s.byteLength;)_=s[n++],d=s[n++],i=s[n++],v+=a.charAt(_>>2),v+=a.charAt((_&3)<<4|d>>4),isNaN(d)?v+="==":(v+=a.charAt((d&15)<<2|i>>6),v+=isNaN(i)?"=":a.charAt(i&63)),h&&v.length>h&&(A+=v.substr(0,h)+`\r
|
|
4
|
-
`,v=v.substr(h));return A+=v,A},r.binary.base64.decode=function(s,h,v){var A=h;A||(A=new Uint8Array(Math.ceil(s.length/4)*3)),s=s.replace(/[^A-Za-z0-9\+\/\=]/g,""),v=v||0;for(var _,d,i,n,I=0,L=v;I<s.length;)_=g[s.charCodeAt(I++)-43],d=g[s.charCodeAt(I++)-43],i=g[s.charCodeAt(I++)-43],n=g[s.charCodeAt(I++)-43],A[L++]=_<<2|d>>4,i!==64&&(A[L++]=(d&15)<<4|i>>2,n!==64&&(A[L++]=(i&3)<<6|n));return h?L-v:A.subarray(0,L)},r.binary.base58.encode=function(s,h){return r.binary.baseN.encode(s,l,h)},r.binary.base58.decode=function(s,h){return r.binary.baseN.decode(s,l,h)},r.text={utf8:{},utf16:{}},r.text.utf8.encode=function(s,h,v){s=r.encodeUtf8(s);var A=h;A||(A=new Uint8Array(s.length)),v=v||0;for(var _=v,d=0;d<s.length;++d)A[_++]=s.charCodeAt(d);return h?_-v:A},r.text.utf8.decode=function(s){return r.decodeUtf8(String.fromCharCode.apply(null,s))},r.text.utf16.encode=function(s,h,v){var A=h;A||(A=new Uint8Array(s.length*2));var _=new Uint16Array(A.buffer);v=v||0;for(var d=v,i=v,n=0;n<s.length;++n)_[i++]=s.charCodeAt(n),d+=2;return h?d-v:A},r.text.utf16.decode=function(s){return String.fromCharCode.apply(null,new Uint16Array(s.buffer))},r.deflate=function(s,h,v){if(h=r.decode64(s.deflate(r.encode64(h)).rval),v){var A=2,_=h.charCodeAt(1);_&32&&(A=6),h=h.substring(A,h.length-4)}return h},r.inflate=function(s,h,v){var A=s.inflate(r.encode64(h)).rval;return A===null?null:r.decode64(A)};var b=function(s,h,v){if(!s)throw new Error("WebStorage not available.");var A;if(v===null?A=s.removeItem(h):(v=r.encode64(JSON.stringify(v)),A=s.setItem(h,v)),typeof A<"u"&&A.rval!==!0){var _=new Error(A.error.message);throw _.id=A.error.id,_.name=A.error.name,_}},U=function(s,h){if(!s)throw new Error("WebStorage not available.");var v=s.getItem(h);if(s.init)if(v.rval===null){if(v.error){var A=new Error(v.error.message);throw A.id=v.error.id,A.name=v.error.name,A}v=null}else v=v.rval;return v!==null&&(v=JSON.parse(r.decode64(v))),v},S=function(s,h,v,A){var _=U(s,h);_===null&&(_={}),_[v]=A,b(s,h,_)},c=function(s,h,v){var A=U(s,h);return A!==null&&(A=v in A?A[v]:null),A},m=function(s,h,v){var A=U(s,h);if(A!==null&&v in A){delete A[v];var _=!0;for(var d in A){_=!1;break}_&&(A=null),b(s,h,A)}},E=function(s,h){b(s,h,null)},C=function(s,h,v){var A=null;typeof v>"u"&&(v=["web","flash"]);var _,d=!1,i=null;for(var n in v){_=v[n];try{if(_==="flash"||_==="both"){if(h[0]===null)throw new Error("Flash local storage not available.");A=s.apply(this,h),d=_==="flash"}(_==="web"||_==="both")&&(h[0]=localStorage,A=s.apply(this,h),d=!0)}catch(I){i=I}if(d)break}if(!d)throw i;return A};return r.setItem=function(s,h,v,A,_){C(S,arguments,_)},r.getItem=function(s,h,v,A){return C(c,arguments,A)},r.removeItem=function(s,h,v,A){C(m,arguments,A)},r.clearItems=function(s,h,v){C(E,arguments,v)},r.isEmpty=function(s){for(var h in s)if(s.hasOwnProperty(h))return!1;return!0},r.format=function(s){for(var h=/%./g,v,A,_=0,d=[],i=0;v=h.exec(s);){A=s.substring(i,h.lastIndex-2),A.length>0&&d.push(A),i=h.lastIndex;var n=v[0][1];switch(n){case"s":case"o":_<arguments.length?d.push(arguments[_+++1]):d.push("<?>");break;case"%":d.push("%");break;default:d.push("<%"+n+"?>")}}return d.push(s.substring(i)),d.join("")},r.formatNumber=function(s,h,v,A){var _=s,d=isNaN(h=Math.abs(h))?2:h,i=v===void 0?",":v,n=A===void 0?".":A,I=_<0?"-":"",L=parseInt(_=Math.abs(+_||0).toFixed(d),10)+"",O=L.length>3?L.length%3:0;return I+(O?L.substr(0,O)+n:"")+L.substr(O).replace(/(\d{3})(?=\d)/g,"$1"+n)+(d?i+Math.abs(_-L).toFixed(d).slice(2):"")},r.formatSize=function(s){return s>=1073741824?s=r.formatNumber(s/1073741824,2,".","")+" GiB":s>=1048576?s=r.formatNumber(s/1048576,2,".","")+" MiB":s>=1024?s=r.formatNumber(s/1024,0)+" KiB":s=r.formatNumber(s,0)+" bytes",s},r.bytesFromIP=function(s){return s.indexOf(".")!==-1?r.bytesFromIPv4(s):s.indexOf(":")!==-1?r.bytesFromIPv6(s):null},r.bytesFromIPv4=function(s){if(s=s.split("."),s.length!==4)return null;for(var h=r.createBuffer(),v=0;v<s.length;++v){var A=parseInt(s[v],10);if(isNaN(A))return null;h.putByte(A)}return h.getBytes()},r.bytesFromIPv6=function(s){var h=0;s=s.split(":").filter(function(i){return i.length===0&&++h,!0});for(var v=(8-s.length+h)*2,A=r.createBuffer(),_=0;_<8;++_){if(!s[_]||s[_].length===0){A.fillWithByte(0,v),v=0;continue}var d=r.hexToBytes(s[_]);d.length<2&&A.putByte(0),A.putBytes(d)}return A.getBytes()},r.bytesToIP=function(s){return s.length===4?r.bytesToIPv4(s):s.length===16?r.bytesToIPv6(s):null},r.bytesToIPv4=function(s){if(s.length!==4)return null;for(var h=[],v=0;v<s.length;++v)h.push(s.charCodeAt(v));return h.join(".")},r.bytesToIPv6=function(s){if(s.length!==16)return null;for(var h=[],v=[],A=0,_=0;_<s.length;_+=2){for(var d=r.bytesToHex(s[_]+s[_+1]);d[0]==="0"&&d!=="0";)d=d.substr(1);if(d==="0"){var i=v[v.length-1],n=h.length;!i||n!==i.end+1?v.push({start:n,end:n}):(i.end=n,i.end-i.start>v[A].end-v[A].start&&(A=v.length-1))}h.push(d)}if(v.length>0){var I=v[A];I.end-I.start>0&&(h.splice(I.start,I.end-I.start+1,""),I.start===0&&h.unshift(""),I.end===7&&h.push(""))}return h.join(":")},r.estimateCores=function(s,h){if(typeof s=="function"&&(h=s,s={}),s=s||{},"cores"in r&&!s.update)return h(null,r.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return r.cores=navigator.hardwareConcurrency,h(null,r.cores);if(typeof Worker>"u")return r.cores=1,h(null,r.cores);if(typeof Blob>"u")return r.cores=2,h(null,r.cores);var v=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(i){var n=Date.now(),I=n+4;self.postMessage({st:n,et:I})})}).toString(),")()"],{type:"application/javascript"}));A([],5,16);function A(i,n,I){if(n===0){var L=Math.floor(i.reduce(function(O,k){return O+k},0)/i.length);return r.cores=Math.max(1,L),URL.revokeObjectURL(v),h(null,r.cores)}_(I,function(O,k){i.push(d(I,k)),A(i,n-1,I)})}function _(i,n){for(var I=[],L=[],O=0;O<i;++O){var k=new Worker(v);k.addEventListener("message",function(F){if(L.push(F.data),L.length===i){for(var H=0;H<i;++H)I[H].terminate();n(null,L)}}),I.push(k)}for(var O=0;O<i;++O)I[O].postMessage(O)}function d(i,n){for(var I=[],L=0;L<i;++L)for(var O=n[L],k=I[L]=[],F=0;F<i;++F)if(L!==F){var H=n[F];(O.st>H.st&&O.st<H.et||H.st>O.st&&H.st<O.et)&&k.push(F)}return I.reduce(function(q,G){return Math.max(q,G.length)},0)}},nr.exports}var sr,Ca;function ta(){if(Ca)return sr;Ca=1;var t=le();pe(),sr=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(r,o){var p=r;if(typeof p=="string"&&(p=t.cipher.getAlgorithm(p),p&&(p=p())),!p)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:p,key:o,decrypt:!1})},t.cipher.createDecipher=function(r,o){var p=r;if(typeof p=="string"&&(p=t.cipher.getAlgorithm(p),p&&(p=p())),!p)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:p,key:o,decrypt:!0})},t.cipher.registerAlgorithm=function(r,o){r=r.toUpperCase(),t.cipher.algorithms[r]=o},t.cipher.getAlgorithm=function(r){return r=r.toUpperCase(),r in t.cipher.algorithms?t.cipher.algorithms[r]:null};var e=t.cipher.BlockCipher=function(r){this.algorithm=r.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=r.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=r.decrypt,this.algorithm.initialize(r)};return e.prototype.start=function(r){r=r||{};var o={};for(var p in r)o[p]=r[p];o.decrypt=this._decrypt,this._finish=!1,this._input=t.util.createBuffer(),this.output=r.output||t.util.createBuffer(),this.mode.start(o)},e.prototype.update=function(r){for(r&&this._input.putBuffer(r);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},e.prototype.finish=function(r){r&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(p){return r(this.blockSize,p,!1)},this.mode.unpad=function(p){return r(this.blockSize,p,!0)});var o={};return o.decrypt=this._decrypt,o.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,o)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,o))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,o))},sr}var or={exports:{}},Ea;function wn(){if(Ea)return or.exports;Ea=1;var t=le();pe(),t.cipher=t.cipher||{};var e=or.exports=t.cipher.modes=t.cipher.modes||{};e.ecb=function(y){y=y||{},this.name="ECB",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.ecb.prototype.start=function(y){},e.ecb.prototype.encrypt=function(y,f,a){if(y.length()<this.blockSize&&!(a&&y.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=y.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)f.putInt32(this._outBlock[g])},e.ecb.prototype.decrypt=function(y,f,a){if(y.length()<this.blockSize&&!(a&&y.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=y.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)f.putInt32(this._outBlock[g])},e.ecb.prototype.pad=function(y,f){var a=y.length()===this.blockSize?this.blockSize:this.blockSize-y.length();return y.fillWithByte(a,a),!0},e.ecb.prototype.unpad=function(y,f){if(f.overflow>0)return!1;var a=y.length(),g=y.at(a-1);return g>this.blockSize<<2?!1:(y.truncate(g),!0)},e.cbc=function(y){y=y||{},this.name="CBC",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},e.cbc.prototype.start=function(y){if(y.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in y)this._iv=r(y.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(y,f,a){if(y.length()<this.blockSize&&!(a&&y.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=this._prev[g]^y.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)f.putInt32(this._outBlock[g]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(y,f,a){if(y.length()<this.blockSize&&!(a&&y.length()>0))return!0;for(var g=0;g<this._ints;++g)this._inBlock[g]=y.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var g=0;g<this._ints;++g)f.putInt32(this._prev[g]^this._outBlock[g]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(y,f){var a=y.length()===this.blockSize?this.blockSize:this.blockSize-y.length();return y.fillWithByte(a,a),!0},e.cbc.prototype.unpad=function(y,f){if(f.overflow>0)return!1;var a=y.length(),g=y.at(a-1);return g>this.blockSize<<2?!1:(y.truncate(g),!0)},e.cfb=function(y){y=y||{},this.name="CFB",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(y){if(!("iv"in y))throw new Error("Invalid IV parameter.");this._iv=r(y.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(y,f,a){var g=y.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var l=0;l<this._ints;++l)this._inBlock[l]=y.getInt32()^this._outBlock[l],f.putInt32(this._inBlock[l]);return}var b=(this.blockSize-g)%this.blockSize;b>0&&(b=this.blockSize-b),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=y.getInt32()^this._outBlock[l],this._partialOutput.putInt32(this._partialBlock[l]);if(b>0)y.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),b>0&&!a)return f.putBytes(this._partialOutput.getBytes(b-this._partialBytes)),this._partialBytes=b,!0;f.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(y,f,a){var g=y.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var l=0;l<this._ints;++l)this._inBlock[l]=y.getInt32(),f.putInt32(this._inBlock[l]^this._outBlock[l]);return}var b=(this.blockSize-g)%this.blockSize;b>0&&(b=this.blockSize-b),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialBlock[l]=y.getInt32(),this._partialOutput.putInt32(this._partialBlock[l]^this._outBlock[l]);if(b>0)y.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._partialBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),b>0&&!a)return f.putBytes(this._partialOutput.getBytes(b-this._partialBytes)),this._partialBytes=b,!0;f.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.ofb=function(y){y=y||{},this.name="OFB",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(y){if(!("iv"in y))throw new Error("Invalid IV parameter.");this._iv=r(y.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(y,f,a){var g=y.length();if(y.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var l=0;l<this._ints;++l)f.putInt32(y.getInt32()^this._outBlock[l]),this._inBlock[l]=this._outBlock[l];return}var b=(this.blockSize-g)%this.blockSize;b>0&&(b=this.blockSize-b),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(b>0)y.read-=this.blockSize;else for(var l=0;l<this._ints;++l)this._inBlock[l]=this._outBlock[l];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),b>0&&!a)return f.putBytes(this._partialOutput.getBytes(b-this._partialBytes)),this._partialBytes=b,!0;f.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(y){y=y||{},this.name="CTR",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(y){if(!("iv"in y))throw new Error("Invalid IV parameter.");this._iv=r(y.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(y,f,a){var g=y.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize)for(var l=0;l<this._ints;++l)f.putInt32(y.getInt32()^this._outBlock[l]);else{var b=(this.blockSize-g)%this.blockSize;b>0&&(b=this.blockSize-b),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(b>0&&(y.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),b>0&&!a)return f.putBytes(this._partialOutput.getBytes(b-this._partialBytes)),this._partialBytes=b,!0;f.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(y){y=y||{},this.name="GCM",this.cipher=y.cipher,this.blockSize=y.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=t.util.createBuffer(),this._partialBytes=0,this._R=3774873600},e.gcm.prototype.start=function(y){if(!("iv"in y))throw new Error("Invalid IV parameter.");var f=t.util.createBuffer(y.iv);this._cipherLength=0;var a;if("additionalData"in y?a=t.util.createBuffer(y.additionalData):a=t.util.createBuffer(),"tagLength"in y?this._tagLength=y.tagLength:this._tagLength=128,this._tag=null,y.decrypt&&(this._tag=t.util.createBuffer(y.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var g=f.length();if(g===12)this._j0=[f.getInt32(),f.getInt32(),f.getInt32(),1];else{for(this._j0=[0,0,0,0];f.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(p(g*8)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,a=t.util.createBuffer(a),this._aDataLength=p(a.length()*8);var l=a.length()%this.blockSize;for(l&&a.fillWithByte(0,this.blockSize-l),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])},e.gcm.prototype.encrypt=function(y,f,a){var g=y.length();if(g===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&g>=this.blockSize){for(var l=0;l<this._ints;++l)f.putInt32(this._outBlock[l]^=y.getInt32());this._cipherLength+=this.blockSize}else{var b=(this.blockSize-g)%this.blockSize;b>0&&(b=this.blockSize-b),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(b<=0||a){if(a){var U=g%this.blockSize;this._cipherLength+=U,this._partialOutput.truncate(this.blockSize-U)}else this._cipherLength+=this.blockSize;for(var l=0;l<this._ints;++l)this._outBlock[l]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),b>0&&!a)return y.read-=this.blockSize,f.putBytes(this._partialOutput.getBytes(b-this._partialBytes)),this._partialBytes=b,!0;f.putBytes(this._partialOutput.getBytes(g-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},e.gcm.prototype.decrypt=function(y,f,a){var g=y.length();if(g<this.blockSize&&!(a&&g>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=y.getInt32(),this._hashBlock[1]=y.getInt32(),this._hashBlock[2]=y.getInt32(),this._hashBlock[3]=y.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var l=0;l<this._ints;++l)f.putInt32(this._outBlock[l]^this._hashBlock[l]);g<this.blockSize?this._cipherLength+=g%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(y,f){var a=!0;f.decrypt&&f.overflow&&y.truncate(this.blockSize-f.overflow),this.tag=t.util.createBuffer();var g=this._aDataLength.concat(p(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,g);var l=[];this.cipher.encrypt(this._j0,l);for(var b=0;b<this._ints;++b)this.tag.putInt32(this._s[b]^l[b]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),f.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a},e.gcm.prototype.multiply=function(y,f){for(var a=[0,0,0,0],g=f.slice(0),l=0;l<128;++l){var b=y[l/32|0]&1<<31-l%32;b&&(a[0]^=g[0],a[1]^=g[1],a[2]^=g[2],a[3]^=g[3]),this.pow(g,g)}return a},e.gcm.prototype.pow=function(y,f){for(var a=y[3]&1,g=3;g>0;--g)f[g]=y[g]>>>1|(y[g-1]&1)<<31;f[0]=y[0]>>>1,a&&(f[0]^=this._R)},e.gcm.prototype.tableMultiply=function(y){for(var f=[0,0,0,0],a=0;a<32;++a){var g=a/8|0,l=y[g]>>>(7-a%8)*4&15,b=this._m[a][l];f[0]^=b[0],f[1]^=b[1],f[2]^=b[2],f[3]^=b[3]}return f},e.gcm.prototype.ghash=function(y,f,a){return f[0]^=a[0],f[1]^=a[1],f[2]^=a[2],f[3]^=a[3],this.tableMultiply(f)},e.gcm.prototype.generateHashTable=function(y,f){for(var a=8/f,g=4*a,l=16*a,b=new Array(l),U=0;U<l;++U){var S=[0,0,0,0],c=U/g|0,m=(g-1-U%g)*f;S[c]=1<<f-1<<m,b[U]=this.generateSubHashTable(this.multiply(S,y),f)}return b},e.gcm.prototype.generateSubHashTable=function(y,f){var a=1<<f,g=a>>>1,l=new Array(a);l[g]=y.slice(0);for(var b=g>>>1;b>0;)this.pow(l[2*b],l[b]=[]),b>>=1;for(b=2;b<g;){for(var U=1;U<b;++U){var S=l[b],c=l[U];l[b+U]=[S[0]^c[0],S[1]^c[1],S[2]^c[2],S[3]^c[3]]}b*=2}for(l[0]=[0,0,0,0],b=g+1;b<a;++b){var m=l[b^g];l[b]=[y[0]^m[0],y[1]^m[1],y[2]^m[2],y[3]^m[3]]}return l};function r(y,f){if(typeof y=="string"&&(y=t.util.createBuffer(y)),t.util.isArray(y)&&y.length>4){var a=y;y=t.util.createBuffer();for(var g=0;g<a.length;++g)y.putByte(a[g])}if(y.length()<f)throw new Error("Invalid IV length; got "+y.length()+" bytes and expected "+f+" bytes.");if(!t.util.isArray(y)){for(var l=[],b=f/4,g=0;g<b;++g)l.push(y.getInt32());y=l}return y}function o(y){y[y.length-1]=y[y.length-1]+1&4294967295}function p(y){return[y/4294967296|0,y&4294967295]}return or.exports}var ur,xa;function St(){if(xa)return ur;xa=1;var t=le();ta(),wn(),pe(),ur=t.aes=t.aes||{},t.aes.startEncrypting=function(c,m,E,C){var s=S({key:c,output:E,decrypt:!1,mode:C});return s.start(m),s},t.aes.createEncryptionCipher=function(c,m){return S({key:c,output:null,decrypt:!1,mode:m})},t.aes.startDecrypting=function(c,m,E,C){var s=S({key:c,output:E,decrypt:!0,mode:C});return s.start(m),s},t.aes.createDecryptionCipher=function(c,m){return S({key:c,output:null,decrypt:!0,mode:m})},t.aes.Algorithm=function(c,m){r||l();var E=this;E.name=c,E.mode=new m({blockSize:16,cipher:{encrypt:function(C,s){return U(E._w,C,s,!1)},decrypt:function(C,s){return U(E._w,C,s,!0)}}}),E._init=!1},t.aes.Algorithm.prototype.initialize=function(c){if(!this._init){var m=c.key,E;if(typeof m=="string"&&(m.length===16||m.length===24||m.length===32))m=t.util.createBuffer(m);else if(t.util.isArray(m)&&(m.length===16||m.length===24||m.length===32)){E=m,m=t.util.createBuffer();for(var C=0;C<E.length;++C)m.putByte(E[C])}if(!t.util.isArray(m)){E=m,m=[];var s=E.length();if(s===16||s===24||s===32){s=s>>>2;for(var C=0;C<s;++C)m.push(E.getInt32())}}if(!t.util.isArray(m)||!(m.length===4||m.length===6||m.length===8))throw new Error("Invalid key parameter.");var h=this.mode.name,v=["CFB","OFB","CTR","GCM"].indexOf(h)!==-1;this._w=b(m,c.decrypt&&!v),this._init=!0}},t.aes._expandKey=function(c,m){return r||l(),b(c,m)},t.aes._updateBlock=U,e("AES-ECB",t.cipher.modes.ecb),e("AES-CBC",t.cipher.modes.cbc),e("AES-CFB",t.cipher.modes.cfb),e("AES-OFB",t.cipher.modes.ofb),e("AES-CTR",t.cipher.modes.ctr),e("AES-GCM",t.cipher.modes.gcm);function e(c,m){var E=function(){return new t.aes.Algorithm(c,m)};t.cipher.registerAlgorithm(c,E)}var r=!1,o=4,p,y,f,a,g;function l(){r=!0,f=[0,1,2,4,8,16,32,64,128,27,54];for(var c=new Array(256),m=0;m<128;++m)c[m]=m<<1,c[m+128]=m+128<<1^283;p=new Array(256),y=new Array(256),a=new Array(4),g=new Array(4);for(var m=0;m<4;++m)a[m]=new Array(256),g[m]=new Array(256);for(var E=0,C=0,s,h,v,A,_,d,i,m=0;m<256;++m){A=C^C<<1^C<<2^C<<3^C<<4,A=A>>8^A&255^99,p[E]=A,y[A]=E,_=c[A],s=c[E],h=c[s],v=c[h],d=_<<24^A<<16^A<<8^(A^_),i=(s^h^v)<<24^(E^v)<<16^(E^h^v)<<8^(E^s^v);for(var n=0;n<4;++n)a[n][E]=d,g[n][A]=i,d=d<<24|d>>>8,i=i<<24|i>>>8;E===0?E=C=1:(E=s^c[c[c[s^v]]],C^=c[c[C]])}}function b(c,m){for(var E=c.slice(0),C,s=1,h=E.length,v=h+6+1,A=o*v,_=h;_<A;++_)C=E[_-1],_%h===0?(C=p[C>>>16&255]<<24^p[C>>>8&255]<<16^p[C&255]<<8^p[C>>>24]^f[s]<<24,s++):h>6&&_%h===4&&(C=p[C>>>24]<<24^p[C>>>16&255]<<16^p[C>>>8&255]<<8^p[C&255]),E[_]=E[_-h]^C;if(m){var d,i=g[0],n=g[1],I=g[2],L=g[3],O=E.slice(0);A=E.length;for(var _=0,k=A-o;_<A;_+=o,k-=o)if(_===0||_===A-o)O[_]=E[k],O[_+1]=E[k+3],O[_+2]=E[k+2],O[_+3]=E[k+1];else for(var F=0;F<o;++F)d=E[k+F],O[_+(3&-F)]=i[p[d>>>24]]^n[p[d>>>16&255]]^I[p[d>>>8&255]]^L[p[d&255]];E=O}return E}function U(c,m,E,C){var s=c.length/4-1,h,v,A,_,d;C?(h=g[0],v=g[1],A=g[2],_=g[3],d=y):(h=a[0],v=a[1],A=a[2],_=a[3],d=p);var i,n,I,L,O,k,F;i=m[0]^c[0],n=m[C?3:1]^c[1],I=m[2]^c[2],L=m[C?1:3]^c[3];for(var H=3,q=1;q<s;++q)O=h[i>>>24]^v[n>>>16&255]^A[I>>>8&255]^_[L&255]^c[++H],k=h[n>>>24]^v[I>>>16&255]^A[L>>>8&255]^_[i&255]^c[++H],F=h[I>>>24]^v[L>>>16&255]^A[i>>>8&255]^_[n&255]^c[++H],L=h[L>>>24]^v[i>>>16&255]^A[n>>>8&255]^_[I&255]^c[++H],i=O,n=k,I=F;E[0]=d[i>>>24]<<24^d[n>>>16&255]<<16^d[I>>>8&255]<<8^d[L&255]^c[++H],E[C?3:1]=d[n>>>24]<<24^d[I>>>16&255]<<16^d[L>>>8&255]<<8^d[i&255]^c[++H],E[2]=d[I>>>24]<<24^d[L>>>16&255]<<16^d[i>>>8&255]<<8^d[n&255]^c[++H],E[C?1:3]=d[L>>>24]<<24^d[i>>>16&255]<<16^d[n>>>8&255]<<8^d[I&255]^c[++H]}function S(c){c=c||{};var m=(c.mode||"CBC").toUpperCase(),E="AES-"+m,C;c.decrypt?C=t.cipher.createDecipher(E,c.key):C=t.cipher.createCipher(E,c.key);var s=C.start;return C.start=function(h,v){var A=null;v instanceof t.util.ByteBuffer&&(A=v,v={}),v=v||{},v.output=A,v.iv=h,s.call(C,v)},C}return ur}var fr={exports:{}},cr={exports:{}},lr={exports:{}},Sa;function bt(){if(Sa)return lr.exports;Sa=1;var t=le();t.pki=t.pki||{};var e=lr.exports=t.pki.oids=t.oids=t.oids||{};function r(p,y){e[p]=y,e[y]=p}function o(p,y){e[p]=y}return r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("1.3.14.3.2.29","sha1WithRSASignature"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("2.16.840.1.101.3.4.2.4","sha224"),r("2.16.840.1.101.3.4.2.5","sha512-224"),r("2.16.840.1.101.3.4.2.6","sha512-256"),r("1.2.840.113549.2.2","md2"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.4","surname"),r("2.5.4.5","serialNumber"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.12","title"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("2.5.4.42","givenName"),r("2.5.4.65","pseudonym"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping"),lr.exports}var ba;function ot(){if(ba)return cr.exports;ba=1;var t=le();pe(),bt();var e=cr.exports=t.asn1=t.asn1||{};e.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},e.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},e.maxDepth=256,e.create=function(f,a,g,l,b){if(t.util.isArray(l)){for(var U=[],S=0;S<l.length;++S)l[S]!==void 0&&U.push(l[S]);l=U}var c={tagClass:f,type:a,constructed:g,composed:g||t.util.isArray(l),value:l};return b&&"bitStringContents"in b&&(c.bitStringContents=b.bitStringContents,c.original=e.copy(c)),c},e.copy=function(f,a){var g;if(t.util.isArray(f)){g=[];for(var l=0;l<f.length;++l)g.push(e.copy(f[l],a));return g}return typeof f=="string"?f:(g={tagClass:f.tagClass,type:f.type,constructed:f.constructed,composed:f.composed,value:e.copy(f.value,a)},a&&!a.excludeBitStringContents&&(g.bitStringContents=f.bitStringContents),g)},e.equals=function(f,a,g){if(t.util.isArray(f)){if(!t.util.isArray(a)||f.length!==a.length)return!1;for(var l=0;l<f.length;++l)if(!e.equals(f[l],a[l]))return!1;return!0}if(typeof f!=typeof a)return!1;if(typeof f=="string")return f===a;var b=f.tagClass===a.tagClass&&f.type===a.type&&f.constructed===a.constructed&&f.composed===a.composed&&e.equals(f.value,a.value);return g&&g.includeBitStringContents&&(b=b&&f.bitStringContents===a.bitStringContents),b},e.getBerValueLength=function(f){var a=f.getByte();if(a!==128){var g,l=a&128;return l?g=f.getInt((a&127)<<3):g=a,g}};function r(f,a,g){if(g>a){var l=new Error("Too few bytes to parse DER.");throw l.available=f.length(),l.remaining=a,l.requested=g,l}}var o=function(f,a){var g=f.getByte();if(a--,g!==128){var l,b=g&128;if(!b)l=g;else{var U=g&127;r(f,a,U),l=f.getInt(U<<3)}if(l<0)throw new Error("Negative length: "+l);return l}};e.fromDer=function(f,a){a===void 0&&(a={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof a=="boolean"&&(a={strict:a,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in a||(a.strict=!0),"parseAllBytes"in a||(a.parseAllBytes=!0),"decodeBitStrings"in a||(a.decodeBitStrings=!0),"maxDepth"in a||(a.maxDepth=e.maxDepth),typeof f=="string"&&(f=t.util.createBuffer(f));var g=f.length(),l=p(f,f.length(),0,a);if(a.parseAllBytes&&f.length()!==0){var b=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw b.byteCount=g,b.remaining=f.length(),b}return l};function p(f,a,g,l){if(g>=l.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var b;r(f,a,2);var U=f.getByte();a--;var S=U&192,c=U&31;b=f.length();var m=o(f,a);if(a-=b-f.length(),m!==void 0&&m>a){if(l.strict){var E=new Error("Too few bytes to read ASN.1 value.");throw E.available=f.length(),E.remaining=a,E.requested=m,E}m=a}var C,s,h=(U&32)===32;if(h)if(C=[],m===void 0)for(;;){if(r(f,a,2),f.bytes(2)==="\0\0"){f.getBytes(2),a-=2;break}b=f.length(),C.push(p(f,a,g+1,l)),a-=b-f.length()}else for(;m>0;)b=f.length(),C.push(p(f,m,g+1,l)),a-=b-f.length(),m-=b-f.length();if(C===void 0&&S===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&(s=f.bytes(m)),C===void 0&&l.decodeBitStrings&&S===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&m>1){var v=f.read,A=a,_=0;if(c===e.Type.BITSTRING&&(r(f,a,1),_=f.getByte(),a--),_===0)try{b=f.length();var d={strict:!0,decodeBitStrings:!0},i=p(f,a,g+1,d),n=b-f.length();a-=n,c==e.Type.BITSTRING&&n++;var I=i.tagClass;n===m&&(I===e.Class.UNIVERSAL||I===e.Class.CONTEXT_SPECIFIC)&&(C=[i])}catch{}C===void 0&&(f.read=v,a=A)}if(C===void 0){if(m===void 0){if(l.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");m=a}if(c===e.Type.BMPSTRING)for(C="";m>0;m-=2)r(f,a,2),C+=String.fromCharCode(f.getInt16()),a-=2;else C=f.getBytes(m),a-=m}var L=s===void 0?null:{bitStringContents:s};return e.create(S,c,h,C,L)}e.toDer=function(f){var a=t.util.createBuffer(),g=f.tagClass|f.type,l=t.util.createBuffer(),b=!1;if("bitStringContents"in f&&(b=!0,f.original&&(b=e.equals(f,f.original))),b)l.putBytes(f.bitStringContents);else if(f.composed){f.constructed?g|=32:l.putByte(0);for(var U=0;U<f.value.length;++U)f.value[U]!==void 0&&l.putBuffer(e.toDer(f.value[U]))}else if(f.type===e.Type.BMPSTRING)for(var U=0;U<f.value.length;++U)l.putInt16(f.value.charCodeAt(U));else f.type===e.Type.INTEGER&&f.value.length>1&&(f.value.charCodeAt(0)===0&&(f.value.charCodeAt(1)&128)===0||f.value.charCodeAt(0)===255&&(f.value.charCodeAt(1)&128)===128)?l.putBytes(f.value.substr(1)):l.putBytes(f.value);if(a.putByte(g),l.length()<=127)a.putByte(l.length()&127);else{var S=l.length(),c="";do c+=String.fromCharCode(S&255),S=S>>>8;while(S>0);a.putByte(c.length|128);for(var U=c.length-1;U>=0;--U)a.putByte(c.charCodeAt(U))}return a.putBuffer(l),a},e.oidToDer=function(f){var a=f.split("."),g=t.util.createBuffer();g.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var l,b,U,S,c=2;c<a.length;++c){if(l=!0,b=[],U=parseInt(a[c],10),U>4294967295)throw new Error("OID value too large; max is 32-bits.");do S=U&127,U=U>>>7,l||(S|=128),b.push(S),l=!1;while(U>0);for(var m=b.length-1;m>=0;--m)g.putByte(b[m])}return g},e.derToOid=function(f){var a;typeof f=="string"&&(f=t.util.createBuffer(f));var g=f.getByte();a=Math.floor(g/40)+"."+g%40;for(var l=0;f.length()>0;){if(l>70368744177663)throw new Error("OID value too large; max is 53-bits.");g=f.getByte(),l=l*128,g&128?l+=g&127:(a+="."+(l+g),l=0)}return a},e.utcTimeToDate=function(f){var a=new Date,g=parseInt(f.substr(0,2),10);g=g>=50?1900+g:2e3+g;var l=parseInt(f.substr(2,2),10)-1,b=parseInt(f.substr(4,2),10),U=parseInt(f.substr(6,2),10),S=parseInt(f.substr(8,2),10),c=0;if(f.length>11){var m=f.charAt(10),E=10;m!=="+"&&m!=="-"&&(c=parseInt(f.substr(10,2),10),E+=2)}if(a.setUTCFullYear(g,l,b),a.setUTCHours(U,S,c,0),E&&(m=f.charAt(E),m==="+"||m==="-")){var C=parseInt(f.substr(E+1,2),10),s=parseInt(f.substr(E+4,2),10),h=C*60+s;h*=6e4,m==="+"?a.setTime(+a-h):a.setTime(+a+h)}return a},e.generalizedTimeToDate=function(f){var a=new Date,g=parseInt(f.substr(0,4),10),l=parseInt(f.substr(4,2),10)-1,b=parseInt(f.substr(6,2),10),U=parseInt(f.substr(8,2),10),S=parseInt(f.substr(10,2),10),c=parseInt(f.substr(12,2),10),m=0,E=0,C=!1;f.charAt(f.length-1)==="Z"&&(C=!0);var s=f.length-5,h=f.charAt(s);if(h==="+"||h==="-"){var v=parseInt(f.substr(s+1,2),10),A=parseInt(f.substr(s+4,2),10);E=v*60+A,E*=6e4,h==="+"&&(E*=-1),C=!0}return f.charAt(14)==="."&&(m=parseFloat(f.substr(14),10)*1e3),C?(a.setUTCFullYear(g,l,b),a.setUTCHours(U,S,c,m),a.setTime(+a+E)):(a.setFullYear(g,l,b),a.setHours(U,S,c,m)),a},e.dateToUtcTime=function(f){if(typeof f=="string")return f;var a="",g=[];g.push((""+f.getUTCFullYear()).substr(2)),g.push(""+(f.getUTCMonth()+1)),g.push(""+f.getUTCDate()),g.push(""+f.getUTCHours()),g.push(""+f.getUTCMinutes()),g.push(""+f.getUTCSeconds());for(var l=0;l<g.length;++l)g[l].length<2&&(a+="0"),a+=g[l];return a+="Z",a},e.dateToGeneralizedTime=function(f){if(typeof f=="string")return f;var a="",g=[];g.push(""+f.getUTCFullYear()),g.push(""+(f.getUTCMonth()+1)),g.push(""+f.getUTCDate()),g.push(""+f.getUTCHours()),g.push(""+f.getUTCMinutes()),g.push(""+f.getUTCSeconds());for(var l=0;l<g.length;++l)g[l].length<2&&(a+="0"),a+=g[l];return a+="Z",a},e.integerToDer=function(f){var a=t.util.createBuffer();if(f>=-128&&f<128)return a.putSignedInt(f,8);if(f>=-32768&&f<32768)return a.putSignedInt(f,16);if(f>=-8388608&&f<8388608)return a.putSignedInt(f,24);if(f>=-2147483648&&f<2147483648)return a.putSignedInt(f,32);var g=new Error("Integer too large; max is 32-bits.");throw g.integer=f,g},e.derToInteger=function(f){typeof f=="string"&&(f=t.util.createBuffer(f));var a=f.length()*8;if(a>32)throw new Error("Integer too large; max is 32-bits.");return f.getSignedInt(a)},e.validate=function(f,a,g,l){var b=!1;if((f.tagClass===a.tagClass||typeof a.tagClass>"u")&&(f.type===a.type||typeof a.type>"u"))if(f.constructed===a.constructed||typeof a.constructed>"u"){if(b=!0,a.value&&t.util.isArray(a.value))for(var U=0,S=0;b&&S<a.value.length;++S){var c=a.value[S];b=!!c.optional;var m=f.value[U];if(!m){c.optional||(b=!1,l&&l.push("["+a.name+'] Missing required element. Expected tag class "'+c.tagClass+'", type "'+c.type+'"'));continue}var E=typeof c.tagClass<"u"&&typeof c.type<"u";if(E&&(m.tagClass!==c.tagClass||m.type!==c.type))if(c.optional){b=!0;continue}else{b=!1,l&&l.push("["+a.name+"] Tag mismatch. Expected ("+c.tagClass+","+c.type+"), got ("+m.tagClass+","+m.type+")");break}var C=e.validate(m,c,g,l);if(C)++U,b=!0;else if(c.optional)b=!0;else{b=!1;break}}if(b&&g&&(a.capture&&(g[a.capture]=f.value),a.captureAsn1&&(g[a.captureAsn1]=f),a.captureBitStringContents&&"bitStringContents"in f&&(g[a.captureBitStringContents]=f.bitStringContents),a.captureBitStringValue&&"bitStringContents"in f))if(f.bitStringContents.length<2)g[a.captureBitStringValue]="";else{var s=f.bitStringContents.charCodeAt(0);if(s!==0)throw new Error("captureBitStringValue only supported for zero unused bits");g[a.captureBitStringValue]=f.bitStringContents.slice(1)}}else l&&l.push("["+a.name+'] Expected constructed "'+a.constructed+'", got "'+f.constructed+'"');else l&&(f.tagClass!==a.tagClass&&l.push("["+a.name+'] Expected tag class "'+a.tagClass+'", got "'+f.tagClass+'"'),f.type!==a.type&&l.push("["+a.name+'] Expected type "'+a.type+'", got "'+f.type+'"'));return b};var y=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(f,a,g){var l="";a=a||0,g=g||2,a>0&&(l+=`
|
|
5
|
-
`);for(var b="",U=0;U<a*g;++U)b+=" ";switch(l+=b+"Tag: ",f.tagClass){case e.Class.UNIVERSAL:l+="Universal:";break;case e.Class.APPLICATION:l+="Application:";break;case e.Class.CONTEXT_SPECIFIC:l+="Context-Specific:";break;case e.Class.PRIVATE:l+="Private:";break}if(f.tagClass===e.Class.UNIVERSAL)switch(l+=f.type,f.type){case e.Type.NONE:l+=" (None)";break;case e.Type.BOOLEAN:l+=" (Boolean)";break;case e.Type.INTEGER:l+=" (Integer)";break;case e.Type.BITSTRING:l+=" (Bit string)";break;case e.Type.OCTETSTRING:l+=" (Octet string)";break;case e.Type.NULL:l+=" (Null)";break;case e.Type.OID:l+=" (Object Identifier)";break;case e.Type.ODESC:l+=" (Object Descriptor)";break;case e.Type.EXTERNAL:l+=" (External or Instance of)";break;case e.Type.REAL:l+=" (Real)";break;case e.Type.ENUMERATED:l+=" (Enumerated)";break;case e.Type.EMBEDDED:l+=" (Embedded PDV)";break;case e.Type.UTF8:l+=" (UTF8)";break;case e.Type.ROID:l+=" (Relative Object Identifier)";break;case e.Type.SEQUENCE:l+=" (Sequence)";break;case e.Type.SET:l+=" (Set)";break;case e.Type.PRINTABLESTRING:l+=" (Printable String)";break;case e.Type.IA5String:l+=" (IA5String (ASCII))";break;case e.Type.UTCTIME:l+=" (UTC time)";break;case e.Type.GENERALIZEDTIME:l+=" (Generalized time)";break;case e.Type.BMPSTRING:l+=" (BMP String)";break}else l+=f.type;if(l+=`
|
|
6
|
-
`,l+=b+"Constructed: "+f.constructed+`
|
|
7
|
-
`,f.composed){for(var S=0,c="",U=0;U<f.value.length;++U)f.value[U]!==void 0&&(S+=1,c+=e.prettyPrint(f.value[U],a+1,g),U+1<f.value.length&&(c+=","));l+=b+"Sub values: "+S+c}else{if(l+=b+"Value: ",f.type===e.Type.OID){var m=e.derToOid(f.value);l+=m,t.pki&&t.pki.oids&&m in t.pki.oids&&(l+=" ("+t.pki.oids[m]+") ")}if(f.type===e.Type.INTEGER)try{l+=e.derToInteger(f.value)}catch{l+="0x"+t.util.bytesToHex(f.value)}else if(f.type===e.Type.BITSTRING){if(f.value.length>1?l+="0x"+t.util.bytesToHex(f.value.slice(1)):l+="(none)",f.value.length>0){var E=f.value.charCodeAt(0);E==1?l+=" (1 unused bit shown)":E>1&&(l+=" ("+E+" unused bits shown)")}}else if(f.type===e.Type.OCTETSTRING)y.test(f.value)||(l+="("+f.value+") "),l+="0x"+t.util.bytesToHex(f.value);else if(f.type===e.Type.UTF8)try{l+=t.util.decodeUtf8(f.value)}catch(C){if(C.message==="URI malformed")l+="0x"+t.util.bytesToHex(f.value)+" (malformed UTF8)";else throw C}else f.type===e.Type.PRINTABLESTRING||f.type===e.Type.IA5String?l+=f.value:y.test(f.value)?l+="0x"+t.util.bytesToHex(f.value):f.value.length===0?l+="[null]":l+=f.value}return l},cr.exports}var dr={exports:{}},hr,Ta;function dt(){if(Ta)return hr;Ta=1;var t=le();return hr=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},hr}var Aa;function Ut(){if(Aa)return dr.exports;Aa=1;var t=le();dt(),pe();var e=dr.exports=t.hmac=t.hmac||{};return e.create=function(){var r=null,o=null,p=null,y=null,f={};return f.start=function(a,g){if(a!==null)if(typeof a=="string")if(a=a.toLowerCase(),a in t.md.algorithms)o=t.md.algorithms[a].create();else throw new Error('Unknown hash algorithm "'+a+'"');else o=a;if(g===null)g=r;else{if(typeof g=="string")g=t.util.createBuffer(g);else if(t.util.isArray(g)){var l=g;g=t.util.createBuffer();for(var b=0;b<l.length;++b)g.putByte(l[b])}var U=g.length();U>o.blockLength&&(o.start(),o.update(g.bytes()),g=o.digest()),p=t.util.createBuffer(),y=t.util.createBuffer(),U=g.length();for(var b=0;b<U;++b){var l=g.at(b);p.putByte(54^l),y.putByte(92^l)}if(U<o.blockLength)for(var l=o.blockLength-U,b=0;b<l;++b)p.putByte(54),y.putByte(92);r=g,p=p.bytes(),y=y.bytes()}o.start(),o.update(p)},f.update=function(a){o.update(a)},f.getMac=function(){var a=o.digest().bytes();return o.start(),o.update(y),o.update(a),o.digest()},f.digest=f.getMac,f},dr.exports}var pr={exports:{}},Ia;function ra(){if(Ia)return pr.exports;Ia=1;var t=le();dt(),pe();var e=pr.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){f||a();var l=null,b=t.util.createBuffer(),U=new Array(16),S={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return S.start=function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var c=S.messageLengthSize/4,m=0;m<c;++m)S.fullMessageLength.push(0);return b=t.util.createBuffer(),l={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},S},S.start(),S.update=function(c,m){m==="utf8"&&(c=t.util.encodeUtf8(c));var E=c.length;S.messageLength+=E,E=[E/4294967296>>>0,E>>>0];for(var C=S.fullMessageLength.length-1;C>=0;--C)S.fullMessageLength[C]+=E[1],E[1]=E[0]+(S.fullMessageLength[C]/4294967296>>>0),S.fullMessageLength[C]=S.fullMessageLength[C]>>>0,E[0]=E[1]/4294967296>>>0;return b.putBytes(c),g(l,U,b),(b.read>2048||b.length()===0)&&b.compact(),S},S.digest=function(){var c=t.util.createBuffer();c.putBytes(b.bytes());var m=S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize,E=m&S.blockLength-1;c.putBytes(r.substr(0,S.blockLength-E));for(var C,s=0,h=S.fullMessageLength.length-1;h>=0;--h)C=S.fullMessageLength[h]*8+s,s=C/4294967296>>>0,c.putInt32Le(C>>>0);var v={h0:l.h0,h1:l.h1,h2:l.h2,h3:l.h3};g(v,U,c);var A=t.util.createBuffer();return A.putInt32Le(v.h0),A.putInt32Le(v.h1),A.putInt32Le(v.h2),A.putInt32Le(v.h3),A},S};var r=null,o=null,p=null,y=null,f=!1;function a(){r="",r+=t.util.fillString("\0",64),o=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],p=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],y=new Array(64);for(var l=0;l<64;++l)y[l]=Math.floor(Math.abs(Math.sin(l+1))*4294967296);f=!0}function g(l,b,U){for(var S,c,m,E,C,s,h,v,A=U.length();A>=64;){for(c=l.h0,m=l.h1,E=l.h2,C=l.h3,v=0;v<16;++v)b[v]=U.getInt32Le(),s=C^m&(E^C),S=c+s+y[v]+b[v],h=p[v],c=C,C=E,E=m,m+=S<<h|S>>>32-h;for(;v<32;++v)s=E^C&(m^E),S=c+s+y[v]+b[o[v]],h=p[v],c=C,C=E,E=m,m+=S<<h|S>>>32-h;for(;v<48;++v)s=m^E^C,S=c+s+y[v]+b[o[v]],h=p[v],c=C,C=E,E=m,m+=S<<h|S>>>32-h;for(;v<64;++v)s=E^(m|~C),S=c+s+y[v]+b[o[v]],h=p[v],c=C,C=E,E=m,m+=S<<h|S>>>32-h;l.h0=l.h0+c|0,l.h1=l.h1+m|0,l.h2=l.h2+E|0,l.h3=l.h3+C|0,A-=64}}return pr.exports}var vr={exports:{}},Ba;function Nt(){if(Ba)return vr.exports;Ba=1;var t=le();pe();var e=vr.exports=t.pem=t.pem||{};e.encode=function(p,y){y=y||{};var f="-----BEGIN "+p.type+`-----\r
|
|
8
|
-
`,a;if(p.procType&&(a={name:"Proc-Type",values:[String(p.procType.version),p.procType.type]},f+=r(a)),p.contentDomain&&(a={name:"Content-Domain",values:[p.contentDomain]},f+=r(a)),p.dekInfo&&(a={name:"DEK-Info",values:[p.dekInfo.algorithm]},p.dekInfo.parameters&&a.values.push(p.dekInfo.parameters),f+=r(a)),p.headers)for(var g=0;g<p.headers.length;++g)f+=r(p.headers[g]);return p.procType&&(f+=`\r
|
|
9
|
-
`),f+=t.util.encode64(p.body,y.maxline||64)+`\r
|
|
10
|
-
`,f+="-----END "+p.type+`-----\r
|
|
11
|
-
`,f},e.decode=function(p){for(var y=[],f=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,a=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,g=/\r?\n/,l;l=f.exec(p),!!l;){var b=l[1];b==="NEW CERTIFICATE REQUEST"&&(b="CERTIFICATE REQUEST");var U={type:b,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(l[3])};if(y.push(U),!!l[2]){for(var S=l[2].split(g),c=0;l&&c<S.length;){for(var m=S[c].replace(/\s+$/,""),E=c+1;E<S.length;++E){var C=S[E];if(!/\s/.test(C[0]))break;m+=C,c=E}if(l=m.match(a),l){for(var s={name:l[1],values:[]},h=l[2].split(","),v=0;v<h.length;++v)s.values.push(o(h[v]));if(U.procType)if(!U.contentDomain&&s.name==="Content-Domain")U.contentDomain=h[0]||"";else if(!U.dekInfo&&s.name==="DEK-Info"){if(s.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');U.dekInfo={algorithm:h[0],parameters:h[1]||null}}else U.headers.push(s);else{if(s.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(s.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');U.procType={version:h[0],type:h[1]}}}++c}if(U.procType==="ENCRYPTED"&&!U.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(y.length===0)throw new Error("Invalid PEM formatted message.");return y};function r(p){for(var y=p.name+": ",f=[],a=function(S,c){return" "+c},g=0;g<p.values.length;++g)f.push(p.values[g].replace(/^(\S+\r\n)/,a));y+=f.join(",")+`\r
|
|
12
|
-
`;for(var l=0,b=-1,g=0;g<y.length;++g,++l)if(l>65&&b!==-1){var U=y[b];U===","?(++b,y=y.substr(0,b)+`\r
|
|
13
|
-
`+y.substr(b)):y=y.substr(0,b)+`\r
|
|
14
|
-
`+U+y.substr(b+1),l=g-b-1,b=-1,++g}else(y[g]===" "||y[g]===" "||y[g]===",")&&(b=g);return y}function o(p){return p.replace(/^\s+/,"")}return vr.exports}var yr={exports:{}},gr,wa;function $t(){if(wa)return gr;wa=1;var t=le();ta(),wn(),pe(),gr=t.des=t.des||{},t.des.startEncrypting=function(c,m,E,C){var s=S({key:c,output:E,decrypt:!1,mode:C||(m===null?"ECB":"CBC")});return s.start(m),s},t.des.createEncryptionCipher=function(c,m){return S({key:c,output:null,decrypt:!1,mode:m})},t.des.startDecrypting=function(c,m,E,C){var s=S({key:c,output:E,decrypt:!0,mode:C||(m===null?"ECB":"CBC")});return s.start(m),s},t.des.createDecryptionCipher=function(c,m){return S({key:c,output:null,decrypt:!0,mode:m})},t.des.Algorithm=function(c,m){var E=this;E.name=c,E.mode=new m({blockSize:8,cipher:{encrypt:function(C,s){return U(E._keys,C,s,!1)},decrypt:function(C,s){return U(E._keys,C,s,!0)}}}),E._init=!1},t.des.Algorithm.prototype.initialize=function(c){if(!this._init){var m=t.util.createBuffer(c.key);if(this.name.indexOf("3DES")===0&&m.length()!==24)throw new Error("Invalid Triple-DES key size: "+m.length()*8);this._keys=b(m),this._init=!0}},e("DES-ECB",t.cipher.modes.ecb),e("DES-CBC",t.cipher.modes.cbc),e("DES-CFB",t.cipher.modes.cfb),e("DES-OFB",t.cipher.modes.ofb),e("DES-CTR",t.cipher.modes.ctr),e("3DES-ECB",t.cipher.modes.ecb),e("3DES-CBC",t.cipher.modes.cbc),e("3DES-CFB",t.cipher.modes.cfb),e("3DES-OFB",t.cipher.modes.ofb),e("3DES-CTR",t.cipher.modes.ctr);function e(c,m){var E=function(){return new t.des.Algorithm(c,m)};t.cipher.registerAlgorithm(c,E)}var r=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],p=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],y=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],f=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],a=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],g=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],l=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function b(c){for(var m=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],E=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],C=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],h=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],v=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],A=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],_=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],d=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],i=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],n=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],I=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],O=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],k=c.length()>8?3:1,F=[],H=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],q=0,G,Y=0;Y<k;Y++){var X=c.getInt32(),te=c.getInt32();G=(X>>>4^te)&252645135,te^=G,X^=G<<4,G=(te>>>-16^X)&65535,X^=G,te^=G<<-16,G=(X>>>2^te)&858993459,te^=G,X^=G<<2,G=(te>>>-16^X)&65535,X^=G,te^=G<<-16,G=(X>>>1^te)&1431655765,te^=G,X^=G<<1,G=(te>>>8^X)&16711935,X^=G,te^=G<<8,G=(X>>>1^te)&1431655765,te^=G,X^=G<<1,G=X<<8|te>>>20&240,X=te<<24|te<<8&16711680|te>>>8&65280|te>>>24&240,te=G;for(var ie=0;ie<H.length;++ie){H[ie]?(X=X<<2|X>>>26,te=te<<2|te>>>26):(X=X<<1|X>>>27,te=te<<1|te>>>27),X&=-15,te&=-15;var se=m[X>>>28]|E[X>>>24&15]|C[X>>>20&15]|s[X>>>16&15]|h[X>>>12&15]|v[X>>>8&15]|A[X>>>4&15],ae=_[te>>>28]|d[te>>>24&15]|i[te>>>20&15]|n[te>>>16&15]|I[te>>>12&15]|L[te>>>8&15]|O[te>>>4&15];G=(ae>>>16^se)&65535,F[q++]=se^G,F[q++]=ae^G<<16}}return F}function U(c,m,E,C){var s=c.length===32?3:9,h;s===3?h=C?[30,-2,-2]:[0,32,2]:h=C?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var v,A=m[0],_=m[1];v=(A>>>4^_)&252645135,_^=v,A^=v<<4,v=(A>>>16^_)&65535,_^=v,A^=v<<16,v=(_>>>2^A)&858993459,A^=v,_^=v<<2,v=(_>>>8^A)&16711935,A^=v,_^=v<<8,v=(A>>>1^_)&1431655765,_^=v,A^=v<<1,A=A<<1|A>>>31,_=_<<1|_>>>31;for(var d=0;d<s;d+=3){for(var i=h[d+1],n=h[d+2],I=h[d];I!=i;I+=n){var L=_^c[I],O=(_>>>4|_<<28)^c[I+1];v=A,A=_,_=v^(o[L>>>24&63]|y[L>>>16&63]|a[L>>>8&63]|l[L&63]|r[O>>>24&63]|p[O>>>16&63]|f[O>>>8&63]|g[O&63])}v=A,A=_,_=v}A=A>>>1|A<<31,_=_>>>1|_<<31,v=(A>>>1^_)&1431655765,_^=v,A^=v<<1,v=(_>>>8^A)&16711935,A^=v,_^=v<<8,v=(_>>>2^A)&858993459,A^=v,_^=v<<2,v=(A>>>16^_)&65535,_^=v,A^=v<<16,v=(A>>>4^_)&252645135,_^=v,A^=v<<4,E[0]=A,E[1]=_}function S(c){c=c||{};var m=(c.mode||"CBC").toUpperCase(),E="DES-"+m,C;c.decrypt?C=t.cipher.createDecipher(E,c.key):C=t.cipher.createCipher(E,c.key);var s=C.start;return C.start=function(h,v){var A=null;v instanceof t.util.ByteBuffer&&(A=v,v={}),v=v||{},v.output=A,v.iv=h,s.call(C,v)},C}return gr}const us={},fs=Object.freeze(Object.defineProperty({__proto__:null,default:us},Symbol.toStringTag,{value:"Module"})),aa=ss(fs);var mr,Na;function na(){if(Na)return mr;Na=1;var t=le();Ut(),dt(),pe();var e=t.pkcs5=t.pkcs5||{},r;return t.util.isNodejs&&!t.options.usePureJavaScript&&(r=aa),mr=t.pbkdf2=e.pbkdf2=function(o,p,y,f,a,g){if(typeof a=="function"&&(g=a,a=null),t.util.isNodejs&&!t.options.usePureJavaScript&&r.pbkdf2&&(a===null||typeof a!="object")&&(r.pbkdf2Sync.length>4||!a||a==="sha1"))return typeof a!="string"&&(a="sha1"),o=Buffer.from(o,"binary"),p=Buffer.from(p,"binary"),g?r.pbkdf2Sync.length===4?r.pbkdf2(o,p,y,f,function(d,i){if(d)return g(d);g(null,i.toString("binary"))}):r.pbkdf2(o,p,y,f,a,function(d,i){if(d)return g(d);g(null,i.toString("binary"))}):r.pbkdf2Sync.length===4?r.pbkdf2Sync(o,p,y,f).toString("binary"):r.pbkdf2Sync(o,p,y,f,a).toString("binary");if((typeof a>"u"||a===null)&&(a="sha1"),typeof a=="string"){if(!(a in t.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=t.md[a].create()}var l=a.digestLength;if(f>4294967295*l){var b=new Error("Derived key is too long.");if(g)return g(b);throw b}var U=Math.ceil(f/l),S=f-(U-1)*l,c=t.hmac.create();c.start(a,o);var m="",E,C,s;if(!g){for(var h=1;h<=U;++h){c.start(null,null),c.update(p),c.update(t.util.int32ToBytes(h)),E=s=c.digest().getBytes();for(var v=2;v<=y;++v)c.start(null,null),c.update(s),C=c.digest().getBytes(),E=t.util.xorBytes(E,C,l),s=C;m+=h<U?E:E.substr(0,S)}return m}var h=1,v;function A(){if(h>U)return g(null,m);c.start(null,null),c.update(p),c.update(t.util.int32ToBytes(h)),E=s=c.digest().getBytes(),v=2,_()}function _(){if(v<=y)return c.start(null,null),c.update(s),C=c.digest().getBytes(),E=t.util.xorBytes(E,C,l),s=C,++v,t.util.setImmediate(_);m+=h<U?E:E.substr(0,S),++h,A()}A()},mr}var Mt={exports:{}},Cr={exports:{}},Ra;function Nn(){if(Ra)return Cr.exports;Ra=1;var t=le();dt(),pe();var e=Cr.exports=t.sha256=t.sha256||{};t.md.sha256=t.md.algorithms.sha256=e,e.create=function(){o||y();var a=null,g=t.util.createBuffer(),l=new Array(64),b={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return b.start=function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var U=b.messageLengthSize/4,S=0;S<U;++S)b.fullMessageLength.push(0);return g=t.util.createBuffer(),a={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},b},b.start(),b.update=function(U,S){S==="utf8"&&(U=t.util.encodeUtf8(U));var c=U.length;b.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var m=b.fullMessageLength.length-1;m>=0;--m)b.fullMessageLength[m]+=c[1],c[1]=c[0]+(b.fullMessageLength[m]/4294967296>>>0),b.fullMessageLength[m]=b.fullMessageLength[m]>>>0,c[0]=c[1]/4294967296>>>0;return g.putBytes(U),f(a,l,g),(g.read>2048||g.length()===0)&&g.compact(),b},b.digest=function(){var U=t.util.createBuffer();U.putBytes(g.bytes());var S=b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize,c=S&b.blockLength-1;U.putBytes(r.substr(0,b.blockLength-c));for(var m,E,C=b.fullMessageLength[0]*8,s=0;s<b.fullMessageLength.length-1;++s)m=b.fullMessageLength[s+1]*8,E=m/4294967296>>>0,C+=E,U.putInt32(C>>>0),C=m>>>0;U.putInt32(C);var h={h0:a.h0,h1:a.h1,h2:a.h2,h3:a.h3,h4:a.h4,h5:a.h5,h6:a.h6,h7:a.h7};f(h,l,U);var v=t.util.createBuffer();return v.putInt32(h.h0),v.putInt32(h.h1),v.putInt32(h.h2),v.putInt32(h.h3),v.putInt32(h.h4),v.putInt32(h.h5),v.putInt32(h.h6),v.putInt32(h.h7),v},b};var r=null,o=!1,p=null;function y(){r="",r+=t.util.fillString("\0",64),p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],o=!0}function f(a,g,l){for(var b,U,S,c,m,E,C,s,h,v,A,_,d,i,n,I=l.length();I>=64;){for(C=0;C<16;++C)g[C]=l.getInt32();for(;C<64;++C)b=g[C-2],b=(b>>>17|b<<15)^(b>>>19|b<<13)^b>>>10,U=g[C-15],U=(U>>>7|U<<25)^(U>>>18|U<<14)^U>>>3,g[C]=b+g[C-7]+U+g[C-16]|0;for(s=a.h0,h=a.h1,v=a.h2,A=a.h3,_=a.h4,d=a.h5,i=a.h6,n=a.h7,C=0;C<64;++C)c=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7),m=i^_&(d^i),S=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),E=s&h|v&(s^h),b=n+c+m+p[C]+g[C],U=S+E,n=i,i=d,d=_,_=A+b>>>0,A=v,v=h,h=s,s=b+U>>>0;a.h0=a.h0+s|0,a.h1=a.h1+h|0,a.h2=a.h2+v|0,a.h3=a.h3+A|0,a.h4=a.h4+_|0,a.h5=a.h5+d|0,a.h6=a.h6+i|0,a.h7=a.h7+n|0,I-=64}}return Cr.exports}var Er={exports:{}},_a;function Rn(){if(_a)return Er.exports;_a=1;var t=le();pe();var e=null;t.util.isNodejs&&!t.options.usePureJavaScript&&!process.versions["node-webkit"]&&(e=aa);var r=Er.exports=t.prng=t.prng||{};return r.create=function(o){for(var p={plugin:o,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},y=o.md,f=new Array(32),a=0;a<32;++a)f[a]=y.create();p.pools=f,p.pool=0,p.generate=function(S,c){if(!c)return p.generateSync(S);var m=p.plugin.cipher,E=p.plugin.increment,C=p.plugin.formatKey,s=p.plugin.formatSeed,h=t.util.createBuffer();p.key=null,v();function v(A){if(A)return c(A);if(h.length()>=S)return c(null,h.getBytes(S));if(p.generated>1048575&&(p.key=null),p.key===null)return t.util.nextTick(function(){g(v)});var _=m(p.key,p.seed);p.generated+=_.length,h.putBytes(_),p.key=C(m(p.key,E(p.seed))),p.seed=s(m(p.key,p.seed)),t.util.setImmediate(v)}},p.generateSync=function(S){var c=p.plugin.cipher,m=p.plugin.increment,E=p.plugin.formatKey,C=p.plugin.formatSeed;p.key=null;for(var s=t.util.createBuffer();s.length()<S;){p.generated>1048575&&(p.key=null),p.key===null&&l();var h=c(p.key,p.seed);p.generated+=h.length,s.putBytes(h),p.key=E(c(p.key,m(p.seed))),p.seed=C(c(p.key,p.seed))}return s.getBytes(S)};function g(S){if(p.pools[0].messageLength>=32)return b(),S();var c=32-p.pools[0].messageLength<<5;p.seedFile(c,function(m,E){if(m)return S(m);p.collect(E),b(),S()})}function l(){if(p.pools[0].messageLength>=32)return b();var S=32-p.pools[0].messageLength<<5;p.collect(p.seedFileSync(S)),b()}function b(){p.reseeds=p.reseeds===4294967295?0:p.reseeds+1;var S=p.plugin.md.create();S.update(p.keyBytes);for(var c=1,m=0;m<32;++m)p.reseeds%c===0&&(S.update(p.pools[m].digest().getBytes()),p.pools[m].start()),c=c<<1;p.keyBytes=S.digest().getBytes(),S.start(),S.update(p.keyBytes);var E=S.digest().getBytes();p.key=p.plugin.formatKey(p.keyBytes),p.seed=p.plugin.formatSeed(E),p.generated=0}function U(S){var c=null,m=t.util.globalScope,E=m.crypto||m.msCrypto;E&&E.getRandomValues&&(c=function(n){return E.getRandomValues(n)});var C=t.util.createBuffer();if(c)for(;C.length()<S;){var s=Math.max(1,Math.min(S-C.length(),65536)/4),h=new Uint32Array(Math.floor(s));try{c(h);for(var v=0;v<h.length;++v)C.putInt32(h[v])}catch(n){if(!(typeof QuotaExceededError<"u"&&n instanceof QuotaExceededError))throw n}}if(C.length()<S)for(var A,_,d,i=Math.floor(Math.random()*65536);C.length()<S;){_=16807*(i&65535),A=16807*(i>>16),_+=(A&32767)<<16,_+=A>>15,_=(_&2147483647)+(_>>31),i=_&4294967295;for(var v=0;v<3;++v)d=i>>>(v<<3),d^=Math.floor(Math.random()*256),C.putByte(d&255)}return C.getBytes(S)}return e?(p.seedFile=function(S,c){e.randomBytes(S,function(m,E){if(m)return c(m);c(null,E.toString())})},p.seedFileSync=function(S){return e.randomBytes(S).toString()}):(p.seedFile=function(S,c){try{c(null,U(S))}catch(m){c(m)}},p.seedFileSync=U),p.collect=function(S){for(var c=S.length,m=0;m<c;++m)p.pools[p.pool].update(S.substr(m,1)),p.pool=p.pool===31?0:p.pool+1},p.collectInt=function(S,c){for(var m="",E=0;E<c;E+=8)m+=String.fromCharCode(S>>E&255);p.collect(m)},p.registerWorker=function(S){if(S===self)p.seedFile=function(m,E){function C(s){var h=s.data;h.forge&&h.forge.prng&&(self.removeEventListener("message",C),E(h.forge.prng.err,h.forge.prng.bytes))}self.addEventListener("message",C),self.postMessage({forge:{prng:{needed:m}}})};else{var c=function(m){var E=m.data;E.forge&&E.forge.prng&&p.seedFile(E.forge.prng.needed,function(C,s){S.postMessage({forge:{prng:{err:C,bytes:s}}})})};S.addEventListener("message",c)}},p},Er.exports}var Da;function it(){if(Da)return Mt.exports;Da=1;var t=le();return St(),Nn(),Rn(),pe(),(function(){if(t.random&&t.random.getBytes){Mt.exports=t.random;return}(function(e){var r={},o=new Array(4),p=t.util.createBuffer();r.formatKey=function(S){var c=t.util.createBuffer(S);return S=new Array(4),S[0]=c.getInt32(),S[1]=c.getInt32(),S[2]=c.getInt32(),S[3]=c.getInt32(),t.aes._expandKey(S,!1)},r.formatSeed=function(S){var c=t.util.createBuffer(S);return S=new Array(4),S[0]=c.getInt32(),S[1]=c.getInt32(),S[2]=c.getInt32(),S[3]=c.getInt32(),S},r.cipher=function(S,c){return t.aes._updateBlock(S,c,o,!1),p.putInt32(o[0]),p.putInt32(o[1]),p.putInt32(o[2]),p.putInt32(o[3]),p.getBytes()},r.increment=function(S){return++S[3],S},r.md=t.md.sha256;function y(){var S=t.prng.create(r);return S.getBytes=function(c,m){return S.generate(c,m)},S.getBytesSync=function(c){return S.generate(c)},S}var f=y(),a=null,g=t.util.globalScope,l=g.crypto||g.msCrypto;if(l&&l.getRandomValues&&(a=function(S){return l.getRandomValues(S)}),t.options.usePureJavaScript||!t.util.isNodejs&&!a){if(f.collectInt(+new Date,32),typeof navigator<"u"){var b="";for(var U in navigator)try{typeof navigator[U]=="string"&&(b+=navigator[U])}catch{}f.collect(b),b=null}e&&(e().mousemove(function(S){f.collectInt(S.clientX,16),f.collectInt(S.clientY,16)}),e().keypress(function(S){f.collectInt(S.charCode,8)}))}if(!t.random)t.random=f;else for(var U in f)t.random[U]=f[U];t.random.createInstance=y,Mt.exports=t.random})(typeof jQuery<"u"?jQuery:null)})(),Mt.exports}var xr,La;function _n(){if(La)return xr;La=1;var t=le();pe();var e=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],r=[1,2,3,5],o=function(f,a){return f<<a&65535|(f&65535)>>16-a},p=function(f,a){return(f&65535)>>a|f<<16-a&65535};xr=t.rc2=t.rc2||{},t.rc2.expandKey=function(f,a){typeof f=="string"&&(f=t.util.createBuffer(f)),a=a||128;var g=f,l=f.length(),b=a,U=Math.ceil(b/8),S=255>>(b&7),c;for(c=l;c<128;c++)g.putByte(e[g.at(c-1)+g.at(c-l)&255]);for(g.setAt(128-U,e[g.at(128-U)&S]),c=127-U;c>=0;c--)g.setAt(c,e[g.at(c+1)^g.at(c+U)]);return g};var y=function(f,a,g){var l=!1,b=null,U=null,S=null,c,m,E,C,s=[];for(f=t.rc2.expandKey(f,a),E=0;E<64;E++)s.push(f.getInt16Le());g?(c=function(A){for(E=0;E<4;E++)A[E]+=s[C]+(A[(E+3)%4]&A[(E+2)%4])+(~A[(E+3)%4]&A[(E+1)%4]),A[E]=o(A[E],r[E]),C++},m=function(A){for(E=0;E<4;E++)A[E]+=s[A[(E+3)%4]&63]}):(c=function(A){for(E=3;E>=0;E--)A[E]=p(A[E],r[E]),A[E]-=s[C]+(A[(E+3)%4]&A[(E+2)%4])+(~A[(E+3)%4]&A[(E+1)%4]),C--},m=function(A){for(E=3;E>=0;E--)A[E]-=s[A[(E+3)%4]&63]});var h=function(A){var _=[];for(E=0;E<4;E++){var d=b.getInt16Le();S!==null&&(g?d^=S.getInt16Le():S.putInt16Le(d)),_.push(d&65535)}C=g?0:63;for(var i=0;i<A.length;i++)for(var n=0;n<A[i][0];n++)A[i][1](_);for(E=0;E<4;E++)S!==null&&(g?S.putInt16Le(_[E]):_[E]^=S.getInt16Le()),U.putInt16Le(_[E])},v=null;return v={start:function(A,_){A&&typeof A=="string"&&(A=t.util.createBuffer(A)),l=!1,b=t.util.createBuffer(),U=_||new t.util.createBuffer,S=A,v.output=U},update:function(A){for(l||b.putBuffer(A);b.length()>=8;)h([[5,c],[1,m],[6,c],[1,m],[5,c]])},finish:function(A){var _=!0;if(g)if(A)_=A(8,b,!g);else{var d=b.length()===8?8:8-b.length();b.fillWithByte(d,d)}if(_&&(l=!0,v.update()),!g&&(_=b.length()===0,_))if(A)_=A(8,U,!g);else{var i=U.length(),n=U.at(i-1);n>i?_=!1:U.truncate(n)}return _}},v};return t.rc2.startEncrypting=function(f,a,g){var l=t.rc2.createEncryptionCipher(f,128);return l.start(a,g),l},t.rc2.createEncryptionCipher=function(f,a){return y(f,a,!0)},t.rc2.startDecrypting=function(f,a,g){var l=t.rc2.createDecryptionCipher(f,128);return l.start(a,g),l},t.rc2.createDecryptionCipher=function(f,a){return y(f,a,!1)},xr}var Sr,Ua;function Xt(){if(Ua)return Sr;Ua=1;var t=le();Sr=t.jsbn=t.jsbn||{};var e;function r(T,B,P){this.data=[],T!=null&&(typeof T=="number"?this.fromNumber(T,B,P):B==null&&typeof T!="string"?this.fromString(T,256):this.fromString(T,B))}t.jsbn.BigInteger=r;function o(){return new r(null)}function p(T,B,P,M,Q,W){for(;--W>=0;){var ne=B*this.data[T++]+P.data[M]+Q;Q=Math.floor(ne/67108864),P.data[M++]=ne&67108863}return Q}function y(T,B,P,M,Q,W){for(var ne=B&32767,re=B>>15;--W>=0;){var ve=this.data[T]&32767,qe=this.data[T++]>>15,et=re*ve+qe*ne;ve=ne*ve+((et&32767)<<15)+P.data[M]+(Q&1073741823),Q=(ve>>>30)+(et>>>15)+re*qe+(Q>>>30),P.data[M++]=ve&1073741823}return Q}function f(T,B,P,M,Q,W){for(var ne=B&16383,re=B>>14;--W>=0;){var ve=this.data[T]&16383,qe=this.data[T++]>>14,et=re*ve+qe*ne;ve=ne*ve+((et&16383)<<14)+P.data[M]+Q,Q=(ve>>28)+(et>>14)+re*qe,P.data[M++]=ve&268435455}return Q}typeof navigator>"u"?(r.prototype.am=f,e=28):navigator.appName=="Microsoft Internet Explorer"?(r.prototype.am=y,e=30):navigator.appName!="Netscape"?(r.prototype.am=p,e=26):(r.prototype.am=f,e=28),r.prototype.DB=e,r.prototype.DM=(1<<e)-1,r.prototype.DV=1<<e;var a=52;r.prototype.FV=Math.pow(2,a),r.prototype.F1=a-e,r.prototype.F2=2*e-a;var g="0123456789abcdefghijklmnopqrstuvwxyz",l=new Array,b,U;for(b=48,U=0;U<=9;++U)l[b++]=U;for(b=97,U=10;U<36;++U)l[b++]=U;for(b=65,U=10;U<36;++U)l[b++]=U;function S(T){return g.charAt(T)}function c(T,B){var P=l[T.charCodeAt(B)];return P??-1}function m(T){for(var B=this.t-1;B>=0;--B)T.data[B]=this.data[B];T.t=this.t,T.s=this.s}function E(T){this.t=1,this.s=T<0?-1:0,T>0?this.data[0]=T:T<-1?this.data[0]=T+this.DV:this.t=0}function C(T){var B=o();return B.fromInt(T),B}function s(T,B){var P;if(B==16)P=4;else if(B==8)P=3;else if(B==256)P=8;else if(B==2)P=1;else if(B==32)P=5;else if(B==4)P=2;else{this.fromRadix(T,B);return}this.t=0,this.s=0;for(var M=T.length,Q=!1,W=0;--M>=0;){var ne=P==8?T[M]&255:c(T,M);if(ne<0){T.charAt(M)=="-"&&(Q=!0);continue}Q=!1,W==0?this.data[this.t++]=ne:W+P>this.DB?(this.data[this.t-1]|=(ne&(1<<this.DB-W)-1)<<W,this.data[this.t++]=ne>>this.DB-W):this.data[this.t-1]|=ne<<W,W+=P,W>=this.DB&&(W-=this.DB)}P==8&&(T[0]&128)!=0&&(this.s=-1,W>0&&(this.data[this.t-1]|=(1<<this.DB-W)-1<<W)),this.clamp(),Q&&r.ZERO.subTo(this,this)}function h(){for(var T=this.s&this.DM;this.t>0&&this.data[this.t-1]==T;)--this.t}function v(T){if(this.s<0)return"-"+this.negate().toString(T);var B;if(T==16)B=4;else if(T==8)B=3;else if(T==2)B=1;else if(T==32)B=5;else if(T==4)B=2;else return this.toRadix(T);var P=(1<<B)-1,M,Q=!1,W="",ne=this.t,re=this.DB-ne*this.DB%B;if(ne-- >0)for(re<this.DB&&(M=this.data[ne]>>re)>0&&(Q=!0,W=S(M));ne>=0;)re<B?(M=(this.data[ne]&(1<<re)-1)<<B-re,M|=this.data[--ne]>>(re+=this.DB-B)):(M=this.data[ne]>>(re-=B)&P,re<=0&&(re+=this.DB,--ne)),M>0&&(Q=!0),Q&&(W+=S(M));return Q?W:"0"}function A(){var T=o();return r.ZERO.subTo(this,T),T}function _(){return this.s<0?this.negate():this}function d(T){var B=this.s-T.s;if(B!=0)return B;var P=this.t;if(B=P-T.t,B!=0)return this.s<0?-B:B;for(;--P>=0;)if((B=this.data[P]-T.data[P])!=0)return B;return 0}function i(T){var B=1,P;return(P=T>>>16)!=0&&(T=P,B+=16),(P=T>>8)!=0&&(T=P,B+=8),(P=T>>4)!=0&&(T=P,B+=4),(P=T>>2)!=0&&(T=P,B+=2),(P=T>>1)!=0&&(T=P,B+=1),B}function n(){return this.t<=0?0:this.DB*(this.t-1)+i(this.data[this.t-1]^this.s&this.DM)}function I(T,B){var P;for(P=this.t-1;P>=0;--P)B.data[P+T]=this.data[P];for(P=T-1;P>=0;--P)B.data[P]=0;B.t=this.t+T,B.s=this.s}function L(T,B){for(var P=T;P<this.t;++P)B.data[P-T]=this.data[P];B.t=Math.max(this.t-T,0),B.s=this.s}function O(T,B){var P=T%this.DB,M=this.DB-P,Q=(1<<M)-1,W=Math.floor(T/this.DB),ne=this.s<<P&this.DM,re;for(re=this.t-1;re>=0;--re)B.data[re+W+1]=this.data[re]>>M|ne,ne=(this.data[re]&Q)<<P;for(re=W-1;re>=0;--re)B.data[re]=0;B.data[W]=ne,B.t=this.t+W+1,B.s=this.s,B.clamp()}function k(T,B){B.s=this.s;var P=Math.floor(T/this.DB);if(P>=this.t){B.t=0;return}var M=T%this.DB,Q=this.DB-M,W=(1<<M)-1;B.data[0]=this.data[P]>>M;for(var ne=P+1;ne<this.t;++ne)B.data[ne-P-1]|=(this.data[ne]&W)<<Q,B.data[ne-P]=this.data[ne]>>M;M>0&&(B.data[this.t-P-1]|=(this.s&W)<<Q),B.t=this.t-P,B.clamp()}function F(T,B){for(var P=0,M=0,Q=Math.min(T.t,this.t);P<Q;)M+=this.data[P]-T.data[P],B.data[P++]=M&this.DM,M>>=this.DB;if(T.t<this.t){for(M-=T.s;P<this.t;)M+=this.data[P],B.data[P++]=M&this.DM,M>>=this.DB;M+=this.s}else{for(M+=this.s;P<T.t;)M-=T.data[P],B.data[P++]=M&this.DM,M>>=this.DB;M-=T.s}B.s=M<0?-1:0,M<-1?B.data[P++]=this.DV+M:M>0&&(B.data[P++]=M),B.t=P,B.clamp()}function H(T,B){var P=this.abs(),M=T.abs(),Q=P.t;for(B.t=Q+M.t;--Q>=0;)B.data[Q]=0;for(Q=0;Q<M.t;++Q)B.data[Q+P.t]=P.am(0,M.data[Q],B,Q,0,P.t);B.s=0,B.clamp(),this.s!=T.s&&r.ZERO.subTo(B,B)}function q(T){for(var B=this.abs(),P=T.t=2*B.t;--P>=0;)T.data[P]=0;for(P=0;P<B.t-1;++P){var M=B.am(P,B.data[P],T,2*P,0,1);(T.data[P+B.t]+=B.am(P+1,2*B.data[P],T,2*P+1,M,B.t-P-1))>=B.DV&&(T.data[P+B.t]-=B.DV,T.data[P+B.t+1]=1)}T.t>0&&(T.data[T.t-1]+=B.am(P,B.data[P],T,2*P,0,1)),T.s=0,T.clamp()}function G(T,B,P){var M=T.abs();if(!(M.t<=0)){var Q=this.abs();if(Q.t<M.t){B?.fromInt(0),P!=null&&this.copyTo(P);return}P==null&&(P=o());var W=o(),ne=this.s,re=T.s,ve=this.DB-i(M.data[M.t-1]);ve>0?(M.lShiftTo(ve,W),Q.lShiftTo(ve,P)):(M.copyTo(W),Q.copyTo(P));var qe=W.t,et=W.data[qe-1];if(et!=0){var Xe=et*(1<<this.F1)+(qe>1?W.data[qe-2]>>this.F2:0),ft=this.FV/Xe,Ft=(1<<this.F1)/Xe,at=1<<this.F2,nt=P.t,Kt=nt-qe,pt=B??o();for(W.dlShiftTo(Kt,pt),P.compareTo(pt)>=0&&(P.data[P.t++]=1,P.subTo(pt,P)),r.ONE.dlShiftTo(qe,pt),pt.subTo(W,W);W.t<qe;)W.data[W.t++]=0;for(;--Kt>=0;){var er=P.data[--nt]==et?this.DM:Math.floor(P.data[nt]*ft+(P.data[nt-1]+at)*Ft);if((P.data[nt]+=W.am(0,er,P,Kt,0,qe))<er)for(W.dlShiftTo(Kt,pt),P.subTo(pt,P);P.data[nt]<--er;)P.subTo(pt,P)}B!=null&&(P.drShiftTo(qe,B),ne!=re&&r.ZERO.subTo(B,B)),P.t=qe,P.clamp(),ve>0&&P.rShiftTo(ve,P),ne<0&&r.ZERO.subTo(P,P)}}}function Y(T){var B=o();return this.abs().divRemTo(T,null,B),this.s<0&&B.compareTo(r.ZERO)>0&&T.subTo(B,B),B}function X(T){this.m=T}function te(T){return T.s<0||T.compareTo(this.m)>=0?T.mod(this.m):T}function ie(T){return T}function se(T){T.divRemTo(this.m,null,T)}function ae(T,B,P){T.multiplyTo(B,P),this.reduce(P)}function ue(T,B){T.squareTo(B),this.reduce(B)}X.prototype.convert=te,X.prototype.revert=ie,X.prototype.reduce=se,X.prototype.mulTo=ae,X.prototype.sqrTo=ue;function ce(){if(this.t<1)return 0;var T=this.data[0];if((T&1)==0)return 0;var B=T&3;return B=B*(2-(T&15)*B)&15,B=B*(2-(T&255)*B)&255,B=B*(2-((T&65535)*B&65535))&65535,B=B*(2-T*B%this.DV)%this.DV,B>0?this.DV-B:-B}function $(T){this.m=T,this.mp=T.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<T.DB-15)-1,this.mt2=2*T.t}function J(T){var B=o();return T.abs().dlShiftTo(this.m.t,B),B.divRemTo(this.m,null,B),T.s<0&&B.compareTo(r.ZERO)>0&&this.m.subTo(B,B),B}function Ge(T){var B=o();return T.copyTo(B),this.reduce(B),B}function be(T){for(;T.t<=this.mt2;)T.data[T.t++]=0;for(var B=0;B<this.m.t;++B){var P=T.data[B]&32767,M=P*this.mpl+((P*this.mph+(T.data[B]>>15)*this.mpl&this.um)<<15)&T.DM;for(P=B+this.m.t,T.data[P]+=this.m.am(0,M,T,B,0,this.m.t);T.data[P]>=T.DV;)T.data[P]-=T.DV,T.data[++P]++}T.clamp(),T.drShiftTo(this.m.t,T),T.compareTo(this.m)>=0&&T.subTo(this.m,T)}function x(T,B){T.squareTo(B),this.reduce(B)}function D(T,B,P){T.multiplyTo(B,P),this.reduce(P)}$.prototype.convert=J,$.prototype.revert=Ge,$.prototype.reduce=be,$.prototype.mulTo=D,$.prototype.sqrTo=x;function R(){return(this.t>0?this.data[0]&1:this.s)==0}function N(T,B){if(T>4294967295||T<1)return r.ONE;var P=o(),M=o(),Q=B.convert(this),W=i(T)-1;for(Q.copyTo(P);--W>=0;)if(B.sqrTo(P,M),(T&1<<W)>0)B.mulTo(M,Q,P);else{var ne=P;P=M,M=ne}return B.revert(P)}function u(T,B){var P;return T<256||B.isEven()?P=new X(B):P=new $(B),this.exp(T,P)}r.prototype.copyTo=m,r.prototype.fromInt=E,r.prototype.fromString=s,r.prototype.clamp=h,r.prototype.dlShiftTo=I,r.prototype.drShiftTo=L,r.prototype.lShiftTo=O,r.prototype.rShiftTo=k,r.prototype.subTo=F,r.prototype.multiplyTo=H,r.prototype.squareTo=q,r.prototype.divRemTo=G,r.prototype.invDigit=ce,r.prototype.isEven=R,r.prototype.exp=N,r.prototype.toString=v,r.prototype.negate=A,r.prototype.abs=_,r.prototype.compareTo=d,r.prototype.bitLength=n,r.prototype.mod=Y,r.prototype.modPowInt=u,r.ZERO=C(0),r.ONE=C(1);function w(){var T=o();return this.copyTo(T),T}function V(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function K(){return this.t==0?this.s:this.data[0]<<24>>24}function j(){return this.t==0?this.s:this.data[0]<<16>>16}function Z(T){return Math.floor(Math.LN2*this.DB/Math.log(T))}function z(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function ee(T){if(T==null&&(T=10),this.signum()==0||T<2||T>36)return"0";var B=this.chunkSize(T),P=Math.pow(T,B),M=C(P),Q=o(),W=o(),ne="";for(this.divRemTo(M,Q,W);Q.signum()>0;)ne=(P+W.intValue()).toString(T).substr(1)+ne,Q.divRemTo(M,Q,W);return W.intValue().toString(T)+ne}function oe(T,B){this.fromInt(0),B==null&&(B=10);for(var P=this.chunkSize(B),M=Math.pow(B,P),Q=!1,W=0,ne=0,re=0;re<T.length;++re){var ve=c(T,re);if(ve<0){T.charAt(re)=="-"&&this.signum()==0&&(Q=!0);continue}ne=B*ne+ve,++W>=P&&(this.dMultiply(M),this.dAddOffset(ne,0),W=0,ne=0)}W>0&&(this.dMultiply(Math.pow(B,W)),this.dAddOffset(ne,0)),Q&&r.ZERO.subTo(this,this)}function de(T,B,P){if(typeof B=="number")if(T<2)this.fromInt(1);else for(this.fromNumber(T,P),this.testBit(T-1)||this.bitwiseTo(r.ONE.shiftLeft(T-1),ye,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(B);)this.dAddOffset(2,0),this.bitLength()>T&&this.subTo(r.ONE.shiftLeft(T-1),this);else{var M=new Array,Q=T&7;M.length=(T>>3)+1,B.nextBytes(M),Q>0?M[0]&=(1<<Q)-1:M[0]=0,this.fromString(M,256)}}function fe(){var T=this.t,B=new Array;B[0]=this.s;var P=this.DB-T*this.DB%8,M,Q=0;if(T-- >0)for(P<this.DB&&(M=this.data[T]>>P)!=(this.s&this.DM)>>P&&(B[Q++]=M|this.s<<this.DB-P);T>=0;)P<8?(M=(this.data[T]&(1<<P)-1)<<8-P,M|=this.data[--T]>>(P+=this.DB-8)):(M=this.data[T]>>(P-=8)&255,P<=0&&(P+=this.DB,--T)),(M&128)!=0&&(M|=-256),Q==0&&(this.s&128)!=(M&128)&&++Q,(Q>0||M!=this.s)&&(B[Q++]=M);return B}function Ee(T){return this.compareTo(T)==0}function Te(T){return this.compareTo(T)<0?this:T}function Se(T){return this.compareTo(T)>0?this:T}function xe(T,B,P){var M,Q,W=Math.min(T.t,this.t);for(M=0;M<W;++M)P.data[M]=B(this.data[M],T.data[M]);if(T.t<this.t){for(Q=T.s&this.DM,M=W;M<this.t;++M)P.data[M]=B(this.data[M],Q);P.t=this.t}else{for(Q=this.s&this.DM,M=W;M<T.t;++M)P.data[M]=B(Q,T.data[M]);P.t=T.t}P.s=B(this.s,T.s),P.clamp()}function me(T,B){return T&B}function ge(T){var B=o();return this.bitwiseTo(T,me,B),B}function ye(T,B){return T|B}function Ie(T){var B=o();return this.bitwiseTo(T,ye,B),B}function Be(T,B){return T^B}function ze(T){var B=o();return this.bitwiseTo(T,Be,B),B}function Qe(T,B){return T&~B}function je(T){var B=o();return this.bitwiseTo(T,Qe,B),B}function $e(){for(var T=o(),B=0;B<this.t;++B)T.data[B]=this.DM&~this.data[B];return T.t=this.t,T.s=~this.s,T}function Je(T){var B=o();return T<0?this.rShiftTo(-T,B):this.lShiftTo(T,B),B}function tt(T){var B=o();return T<0?this.lShiftTo(-T,B):this.rShiftTo(T,B),B}function st(T){if(T==0)return-1;var B=0;return(T&65535)==0&&(T>>=16,B+=16),(T&255)==0&&(T>>=8,B+=8),(T&15)==0&&(T>>=4,B+=4),(T&3)==0&&(T>>=2,B+=2),(T&1)==0&&++B,B}function ut(){for(var T=0;T<this.t;++T)if(this.data[T]!=0)return T*this.DB+st(this.data[T]);return this.s<0?this.t*this.DB:-1}function ht(T){for(var B=0;T!=0;)T&=T-1,++B;return B}function mt(){for(var T=0,B=this.s&this.DM,P=0;P<this.t;++P)T+=ht(this.data[P]^B);return T}function Tt(T){var B=Math.floor(T/this.DB);return B>=this.t?this.s!=0:(this.data[B]&1<<T%this.DB)!=0}function Rt(T,B){var P=r.ONE.shiftLeft(T);return this.bitwiseTo(P,B,P),P}function Ot(T){return this.changeBit(T,ye)}function we(T){return this.changeBit(T,Qe)}function Ne(T){return this.changeBit(T,Be)}function Re(T,B){for(var P=0,M=0,Q=Math.min(T.t,this.t);P<Q;)M+=this.data[P]+T.data[P],B.data[P++]=M&this.DM,M>>=this.DB;if(T.t<this.t){for(M+=T.s;P<this.t;)M+=this.data[P],B.data[P++]=M&this.DM,M>>=this.DB;M+=this.s}else{for(M+=this.s;P<T.t;)M+=T.data[P],B.data[P++]=M&this.DM,M>>=this.DB;M+=T.s}B.s=M<0?-1:0,M>0?B.data[P++]=M:M<-1&&(B.data[P++]=this.DV+M),B.t=P,B.clamp()}function _e(T){var B=o();return this.addTo(T,B),B}function De(T){var B=o();return this.subTo(T,B),B}function Le(T){var B=o();return this.multiplyTo(T,B),B}function Ue(){var T=o();return this.squareTo(T),T}function ke(T){var B=o();return this.divRemTo(T,B,null),B}function Pe(T){var B=o();return this.divRemTo(T,null,B),B}function Ve(T){var B=o(),P=o();return this.divRemTo(T,B,P),new Array(B,P)}function Oe(T){this.data[this.t]=this.am(0,T-1,this,0,0,this.t),++this.t,this.clamp()}function Fe(T,B){if(T!=0){for(;this.t<=B;)this.data[this.t++]=0;for(this.data[B]+=T;this.data[B]>=this.DV;)this.data[B]-=this.DV,++B>=this.t&&(this.data[this.t++]=0),++this.data[B]}}function Ce(){}function Ae(T){return T}function Ke(T,B,P){T.multiplyTo(B,P)}function Me(T,B){T.squareTo(B)}Ce.prototype.convert=Ae,Ce.prototype.revert=Ae,Ce.prototype.mulTo=Ke,Ce.prototype.sqrTo=Me;function Ti(T){return this.exp(T,new Ce)}function Ai(T,B,P){var M=Math.min(this.t+T.t,B);for(P.s=0,P.t=M;M>0;)P.data[--M]=0;var Q;for(Q=P.t-this.t;M<Q;++M)P.data[M+this.t]=this.am(0,T.data[M],P,M,0,this.t);for(Q=Math.min(T.t,B);M<Q;++M)this.am(0,T.data[M],P,M,0,B-M);P.clamp()}function Ii(T,B,P){--B;var M=P.t=this.t+T.t-B;for(P.s=0;--M>=0;)P.data[M]=0;for(M=Math.max(B-this.t,0);M<T.t;++M)P.data[this.t+M-B]=this.am(B-M,T.data[M],P,0,0,this.t+M-B);P.clamp(),P.drShiftTo(1,P)}function At(T){this.r2=o(),this.q3=o(),r.ONE.dlShiftTo(2*T.t,this.r2),this.mu=this.r2.divide(T),this.m=T}function Bi(T){if(T.s<0||T.t>2*this.m.t)return T.mod(this.m);if(T.compareTo(this.m)<0)return T;var B=o();return T.copyTo(B),this.reduce(B),B}function wi(T){return T}function Ni(T){for(T.drShiftTo(this.m.t-1,this.r2),T.t>this.m.t+1&&(T.t=this.m.t+1,T.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);T.compareTo(this.r2)<0;)T.dAddOffset(1,this.m.t+1);for(T.subTo(this.r2,T);T.compareTo(this.m)>=0;)T.subTo(this.m,T)}function Ri(T,B){T.squareTo(B),this.reduce(B)}function _i(T,B,P){T.multiplyTo(B,P),this.reduce(P)}At.prototype.convert=Bi,At.prototype.revert=wi,At.prototype.reduce=Ni,At.prototype.mulTo=_i,At.prototype.sqrTo=Ri;function Di(T,B){var P=T.bitLength(),M,Q=C(1),W;if(P<=0)return Q;P<18?M=1:P<48?M=3:P<144?M=4:P<768?M=5:M=6,P<8?W=new X(B):B.isEven()?W=new At(B):W=new $(B);var ne=new Array,re=3,ve=M-1,qe=(1<<M)-1;if(ne[1]=W.convert(this),M>1){var et=o();for(W.sqrTo(ne[1],et);re<=qe;)ne[re]=o(),W.mulTo(et,ne[re-2],ne[re]),re+=2}var Xe=T.t-1,ft,Ft=!0,at=o(),nt;for(P=i(T.data[Xe])-1;Xe>=0;){for(P>=ve?ft=T.data[Xe]>>P-ve&qe:(ft=(T.data[Xe]&(1<<P+1)-1)<<ve-P,Xe>0&&(ft|=T.data[Xe-1]>>this.DB+P-ve)),re=M;(ft&1)==0;)ft>>=1,--re;if((P-=re)<0&&(P+=this.DB,--Xe),Ft)ne[ft].copyTo(Q),Ft=!1;else{for(;re>1;)W.sqrTo(Q,at),W.sqrTo(at,Q),re-=2;re>0?W.sqrTo(Q,at):(nt=Q,Q=at,at=nt),W.mulTo(at,ne[ft],Q)}for(;Xe>=0&&(T.data[Xe]&1<<P)==0;)W.sqrTo(Q,at),nt=Q,Q=at,at=nt,--P<0&&(P=this.DB-1,--Xe)}return W.revert(Q)}function Li(T){var B=this.s<0?this.negate():this.clone(),P=T.s<0?T.negate():T.clone();if(B.compareTo(P)<0){var M=B;B=P,P=M}var Q=B.getLowestSetBit(),W=P.getLowestSetBit();if(W<0)return B;for(Q<W&&(W=Q),W>0&&(B.rShiftTo(W,B),P.rShiftTo(W,P));B.signum()>0;)(Q=B.getLowestSetBit())>0&&B.rShiftTo(Q,B),(Q=P.getLowestSetBit())>0&&P.rShiftTo(Q,P),B.compareTo(P)>=0?(B.subTo(P,B),B.rShiftTo(1,B)):(P.subTo(B,P),P.rShiftTo(1,P));return W>0&&P.lShiftTo(W,P),P}function Ui(T){if(T<=0)return 0;var B=this.DV%T,P=this.s<0?T-1:0;if(this.t>0)if(B==0)P=this.data[0]%T;else for(var M=this.t-1;M>=0;--M)P=(B*P+this.data[M])%T;return P}function ki(T){if(this.signum()==0)return r.ZERO;var B=T.isEven();if(this.isEven()&&B||T.signum()==0)return r.ZERO;for(var P=T.clone(),M=this.clone(),Q=C(1),W=C(0),ne=C(0),re=C(1);P.signum()!=0;){for(;P.isEven();)P.rShiftTo(1,P),B?((!Q.isEven()||!W.isEven())&&(Q.addTo(this,Q),W.subTo(T,W)),Q.rShiftTo(1,Q)):W.isEven()||W.subTo(T,W),W.rShiftTo(1,W);for(;M.isEven();)M.rShiftTo(1,M),B?((!ne.isEven()||!re.isEven())&&(ne.addTo(this,ne),re.subTo(T,re)),ne.rShiftTo(1,ne)):re.isEven()||re.subTo(T,re),re.rShiftTo(1,re);P.compareTo(M)>=0?(P.subTo(M,P),B&&Q.subTo(ne,Q),W.subTo(re,W)):(M.subTo(P,M),B&&ne.subTo(Q,ne),re.subTo(W,re))}if(M.compareTo(r.ONE)!=0)return r.ZERO;if(re.compareTo(T)>=0)return re.subtract(T);if(re.signum()<0)re.addTo(T,re);else return re;return re.signum()<0?re.add(T):re}var rt=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Pi=(1<<26)/rt[rt.length-1];function Vi(T){var B,P=this.abs();if(P.t==1&&P.data[0]<=rt[rt.length-1]){for(B=0;B<rt.length;++B)if(P.data[0]==rt[B])return!0;return!1}if(P.isEven())return!1;for(B=1;B<rt.length;){for(var M=rt[B],Q=B+1;Q<rt.length&&M<Pi;)M*=rt[Q++];for(M=P.modInt(M);B<Q;)if(M%rt[B++]==0)return!1}return P.millerRabin(T)}function Oi(T){var B=this.subtract(r.ONE),P=B.getLowestSetBit();if(P<=0)return!1;for(var M=B.shiftRight(P),Q=Fi(),W,ne=0;ne<T;++ne){do W=new r(this.bitLength(),Q);while(W.compareTo(r.ONE)<=0||W.compareTo(B)>=0);var re=W.modPow(M,this);if(re.compareTo(r.ONE)!=0&&re.compareTo(B)!=0){for(var ve=1;ve++<P&&re.compareTo(B)!=0;)if(re=re.modPowInt(2,this),re.compareTo(r.ONE)==0)return!1;if(re.compareTo(B)!=0)return!1}}return!0}function Fi(){return{nextBytes:function(T){for(var B=0;B<T.length;++B)T[B]=Math.floor(Math.random()*256)}}}return r.prototype.chunkSize=Z,r.prototype.toRadix=ee,r.prototype.fromRadix=oe,r.prototype.fromNumber=de,r.prototype.bitwiseTo=xe,r.prototype.changeBit=Rt,r.prototype.addTo=Re,r.prototype.dMultiply=Oe,r.prototype.dAddOffset=Fe,r.prototype.multiplyLowerTo=Ai,r.prototype.multiplyUpperTo=Ii,r.prototype.modInt=Ui,r.prototype.millerRabin=Oi,r.prototype.clone=w,r.prototype.intValue=V,r.prototype.byteValue=K,r.prototype.shortValue=j,r.prototype.signum=z,r.prototype.toByteArray=fe,r.prototype.equals=Ee,r.prototype.min=Te,r.prototype.max=Se,r.prototype.and=ge,r.prototype.or=Ie,r.prototype.xor=ze,r.prototype.andNot=je,r.prototype.not=$e,r.prototype.shiftLeft=Je,r.prototype.shiftRight=tt,r.prototype.getLowestSetBit=ut,r.prototype.bitCount=mt,r.prototype.testBit=Tt,r.prototype.setBit=Ot,r.prototype.clearBit=we,r.prototype.flipBit=Ne,r.prototype.add=_e,r.prototype.subtract=De,r.prototype.multiply=Le,r.prototype.divide=ke,r.prototype.remainder=Pe,r.prototype.divideAndRemainder=Ve,r.prototype.modPow=Di,r.prototype.modInverse=ki,r.prototype.pow=Ti,r.prototype.gcd=Li,r.prototype.isProbablePrime=Vi,r.prototype.square=Ue,Sr}var br={exports:{}},Tr={exports:{}},ka;function kt(){if(ka)return Tr.exports;ka=1;var t=le();dt(),pe();var e=Tr.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){o||p();var f=null,a=t.util.createBuffer(),g=new Array(80),l={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return l.start=function(){l.messageLength=0,l.fullMessageLength=l.messageLength64=[];for(var b=l.messageLengthSize/4,U=0;U<b;++U)l.fullMessageLength.push(0);return a=t.util.createBuffer(),f={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},l},l.start(),l.update=function(b,U){U==="utf8"&&(b=t.util.encodeUtf8(b));var S=b.length;l.messageLength+=S,S=[S/4294967296>>>0,S>>>0];for(var c=l.fullMessageLength.length-1;c>=0;--c)l.fullMessageLength[c]+=S[1],S[1]=S[0]+(l.fullMessageLength[c]/4294967296>>>0),l.fullMessageLength[c]=l.fullMessageLength[c]>>>0,S[0]=S[1]/4294967296>>>0;return a.putBytes(b),y(f,g,a),(a.read>2048||a.length()===0)&&a.compact(),l},l.digest=function(){var b=t.util.createBuffer();b.putBytes(a.bytes());var U=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize,S=U&l.blockLength-1;b.putBytes(r.substr(0,l.blockLength-S));for(var c,m,E=l.fullMessageLength[0]*8,C=0;C<l.fullMessageLength.length-1;++C)c=l.fullMessageLength[C+1]*8,m=c/4294967296>>>0,E+=m,b.putInt32(E>>>0),E=c>>>0;b.putInt32(E);var s={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};y(s,g,b);var h=t.util.createBuffer();return h.putInt32(s.h0),h.putInt32(s.h1),h.putInt32(s.h2),h.putInt32(s.h3),h.putInt32(s.h4),h},l};var r=null,o=!1;function p(){r="",r+=t.util.fillString("\0",64),o=!0}function y(f,a,g){for(var l,b,U,S,c,m,E,C,s=g.length();s>=64;){for(b=f.h0,U=f.h1,S=f.h2,c=f.h3,m=f.h4,C=0;C<16;++C)l=g.getInt32(),a[C]=l,E=c^U&(S^c),l=(b<<5|b>>>27)+E+m+1518500249+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;for(;C<20;++C)l=a[C-3]^a[C-8]^a[C-14]^a[C-16],l=l<<1|l>>>31,a[C]=l,E=c^U&(S^c),l=(b<<5|b>>>27)+E+m+1518500249+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;for(;C<32;++C)l=a[C-3]^a[C-8]^a[C-14]^a[C-16],l=l<<1|l>>>31,a[C]=l,E=U^S^c,l=(b<<5|b>>>27)+E+m+1859775393+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;for(;C<40;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=U^S^c,l=(b<<5|b>>>27)+E+m+1859775393+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;for(;C<60;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=U&S|c&(U^S),l=(b<<5|b>>>27)+E+m+2400959708+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;for(;C<80;++C)l=a[C-6]^a[C-16]^a[C-28]^a[C-32],l=l<<2|l>>>30,a[C]=l,E=U^S^c,l=(b<<5|b>>>27)+E+m+3395469782+l,m=c,c=S,S=(U<<30|U>>>2)>>>0,U=b,b=l;f.h0=f.h0+b|0,f.h1=f.h1+U|0,f.h2=f.h2+S|0,f.h3=f.h3+c|0,f.h4=f.h4+m|0,s-=64}}return Tr.exports}var Pa;function Dn(){if(Pa)return br.exports;Pa=1;var t=le();pe(),it(),kt();var e=br.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(o,p,y){var f,a,g,l;typeof y=="string"?(f=y,a=arguments[3]||void 0,g=arguments[4]||void 0):y&&(f=y.label||void 0,a=y.seed||void 0,g=y.md||void 0,y.mgf1&&y.mgf1.md&&(l=y.mgf1.md)),g?g.start():g=t.md.sha1.create(),l||(l=g);var b=Math.ceil(o.n.bitLength()/8),U=b-2*g.digestLength-2;if(p.length>U){var S=new Error("RSAES-OAEP input message length is too long.");throw S.length=p.length,S.maxLength=U,S}f||(f=""),g.update(f,"raw");for(var c=g.digest(),m="",E=U-p.length,C=0;C<E;C++)m+="\0";var s=c.getBytes()+m+""+p;if(!a)a=t.random.getBytes(g.digestLength);else if(a.length!==g.digestLength){var S=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw S.seedLength=a.length,S.digestLength=g.digestLength,S}var h=r(a,b-g.digestLength-1,l),v=t.util.xorBytes(s,h,s.length),A=r(v,g.digestLength,l),_=t.util.xorBytes(a,A,a.length);return"\0"+_+v},e.decode_rsa_oaep=function(o,p,y){var f,a,g;typeof y=="string"?(f=y,a=arguments[3]||void 0):y&&(f=y.label||void 0,a=y.md||void 0,y.mgf1&&y.mgf1.md&&(g=y.mgf1.md));var l=Math.ceil(o.n.bitLength()/8);if(p.length!==l){var v=new Error("RSAES-OAEP encoded message length is invalid.");throw v.length=p.length,v.expectedLength=l,v}if(a===void 0?a=t.md.sha1.create():a.start(),g||(g=a),l<2*a.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");f||(f=""),a.update(f,"raw");for(var b=a.digest().getBytes(),U=p.charAt(0),S=p.substring(1,a.digestLength+1),c=p.substring(1+a.digestLength),m=r(c,a.digestLength,g),E=t.util.xorBytes(S,m,S.length),C=r(E,l-a.digestLength-1,g),s=t.util.xorBytes(c,C,c.length),h=s.substring(0,a.digestLength),v=U!=="\0",A=0;A<a.digestLength;++A)v|=b.charAt(A)!==h.charAt(A);for(var _=1,d=a.digestLength,i=a.digestLength;i<s.length;i++){var n=s.charCodeAt(i),I=n&1^1,L=_?65534:0;v|=n&L,_=_&I,d+=_}if(v||s.charCodeAt(d)!==1)throw new Error("Invalid RSAES-OAEP padding.");return s.substring(d+1)};function r(o,p,y){y||(y=t.md.sha1.create());for(var f="",a=Math.ceil(p/y.digestLength),g=0;g<a;++g){var l=String.fromCharCode(g>>24&255,g>>16&255,g>>8&255,g&255);y.start(),y.update(o+l),f+=y.digest().getBytes()}return f.substring(0,p)}return br.exports}var qt={exports:{}},Va;function Ln(){if(Va)return qt.exports;Va=1;var t=le();return pe(),Xt(),it(),(function(){if(t.prime){qt.exports=t.prime;return}var e=qt.exports=t.prime=t.prime||{},r=t.jsbn.BigInteger,o=[6,4,2,4,2,4,6,2],p=new r(null);p.fromInt(30);var y=function(S,c){return S|c};e.generateProbablePrime=function(S,c,m){typeof c=="function"&&(m=c,c={}),c=c||{};var E=c.algorithm||"PRIMEINC";typeof E=="string"&&(E={name:E}),E.options=E.options||{};var C=c.prng||t.random,s={nextBytes:function(h){for(var v=C.getBytesSync(h.length),A=0;A<h.length;++A)h[A]=v.charCodeAt(A)}};if(E.name==="PRIMEINC")return f(S,s,E.options,m);throw new Error("Invalid prime generation algorithm: "+E.name)};function f(S,c,m,E){return"workers"in m?l(S,c,m,E):a(S,c,m,E)}function a(S,c,m,E){var C=b(S,c),s=0,h=U(C.bitLength());"millerRabinTests"in m&&(h=m.millerRabinTests);var v=10;"maxBlockTime"in m&&(v=m.maxBlockTime),g(C,S,c,s,h,v,E)}function g(S,c,m,E,C,s,h){var v=+new Date;do{if(S.bitLength()>c&&(S=b(c,m)),S.isProbablePrime(C))return h(null,S);S.dAddOffset(o[E++%8],0)}while(s<0||+new Date-v<s);t.util.setImmediate(function(){g(S,c,m,E,C,s,h)})}function l(S,c,m,E){if(typeof Worker>"u")return a(S,c,m,E);var C=b(S,c),s=m.workers,h=m.workLoad||100,v=h*30/8,A=m.workerScript||"forge/prime.worker.js";if(s===-1)return t.util.estimateCores(function(d,i){d&&(i=2),s=i-1,_()});_();function _(){s=Math.max(1,s);for(var d=[],i=0;i<s;++i)d[i]=new Worker(A);for(var i=0;i<s;++i)d[i].addEventListener("message",I);var n=!1;function I(L){if(!n){var O=L.data;if(O.found){for(var k=0;k<d.length;++k)d[k].terminate();return n=!0,E(null,new r(O.prime,16))}C.bitLength()>S&&(C=b(S,c));var F=C.toString(16);L.target.postMessage({hex:F,workLoad:h}),C.dAddOffset(v,0)}}}}function b(S,c){var m=new r(S,c),E=S-1;return m.testBit(E)||m.bitwiseTo(r.ONE.shiftLeft(E),y,m),m.dAddOffset(31-m.mod(p).byteValue(),0),m}function U(S){return S<=100?27:S<=150?18:S<=200?15:S<=250?12:S<=300?9:S<=350?8:S<=400?7:S<=500?6:S<=600?5:S<=800?4:S<=1250?3:2}})(),qt.exports}var Ar,Oa;function Zt(){if(Oa)return Ar;Oa=1;var t=le();if(ot(),Xt(),bt(),Dn(),Ln(),it(),pe(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.util.isNodejs?aa:null,o=t.asn1,p=t.util;t.pki=t.pki||{},Ar=t.pki.rsa=t.rsa=t.rsa||{};var y=t.pki,f=[6,4,2,4,2,4,6,2],a={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},g={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},l={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},b=t.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},U={name:"DigestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},S=function(i){var n;if(i.algorithm in y.oids)n=y.oids[i.algorithm];else{var I=new Error("Unknown message digest algorithm.");throw I.algorithm=i.algorithm,I}var L=o.oidToDer(n).getBytes(),O=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),k=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);k.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,L)),k.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var F=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,i.digest().getBytes());return O.value.push(k),O.value.push(F),o.toDer(O).getBytes()},c=function(i,n,I){if(I)return i.modPow(n.e,n.n);if(!n.p||!n.q)return i.modPow(n.d,n.n);n.dP||(n.dP=n.d.mod(n.p.subtract(e.ONE))),n.dQ||(n.dQ=n.d.mod(n.q.subtract(e.ONE))),n.qInv||(n.qInv=n.q.modInverse(n.p));var L;do L=new e(t.util.bytesToHex(t.random.getBytes(n.n.bitLength()/8)),16);while(L.compareTo(n.n)>=0||!L.gcd(n.n).equals(e.ONE));i=i.multiply(L.modPow(n.e,n.n)).mod(n.n);for(var O=i.mod(n.p).modPow(n.dP,n.p),k=i.mod(n.q).modPow(n.dQ,n.q);O.compareTo(k)<0;)O=O.add(n.p);var F=O.subtract(k).multiply(n.qInv).mod(n.p).multiply(n.q).add(k);return F=F.multiply(L.modInverse(n.n)).mod(n.n),F};y.rsa.encrypt=function(i,n,I){var L=I,O,k=Math.ceil(n.n.bitLength()/8);I!==!1&&I!==!0?(L=I===2,O=m(i,n,I)):(O=t.util.createBuffer(),O.putBytes(i));for(var F=new e(O.toHex(),16),H=c(F,n,L),q=H.toString(16),G=t.util.createBuffer(),Y=k-Math.ceil(q.length/2);Y>0;)G.putByte(0),--Y;return G.putBytes(t.util.hexToBytes(q)),G.getBytes()},y.rsa.decrypt=function(i,n,I,L){var O=Math.ceil(n.n.bitLength()/8);if(i.length!==O){var k=new Error("Encrypted message length is invalid.");throw k.length=i.length,k.expected=O,k}var F=new e(t.util.createBuffer(i).toHex(),16);if(F.compareTo(n.n)>=0)throw new Error("Encrypted message is invalid.");for(var H=c(F,n,I),q=H.toString(16),G=t.util.createBuffer(),Y=O-Math.ceil(q.length/2);Y>0;)G.putByte(0),--Y;return G.putBytes(t.util.hexToBytes(q)),L!==!1?E(G.getBytes(),n,I):G.getBytes()},y.rsa.createKeyPairGenerationState=function(i,n,I){typeof i=="string"&&(i=parseInt(i,10)),i=i||2048,I=I||{};var L=I.prng||t.random,O={nextBytes:function(H){for(var q=L.getBytesSync(H.length),G=0;G<H.length;++G)H[G]=q.charCodeAt(G)}},k=I.algorithm||"PRIMEINC",F;if(k==="PRIMEINC")F={algorithm:k,state:0,bits:i,rng:O,eInt:n||65537,e:new e(null),p:null,q:null,qBits:i>>1,pBits:i-(i>>1),pqState:0,num:null,keys:null},F.e.fromInt(F.eInt);else throw new Error("Invalid key generation algorithm: "+k);return F},y.rsa.stepKeyPairGenerationState=function(i,n){"algorithm"in i||(i.algorithm="PRIMEINC");var I=new e(null);I.fromInt(30);for(var L=0,O=function(X,te){return X|te},k=+new Date,F,H=0;i.keys===null&&(n<=0||H<n);){if(i.state===0){var q=i.p===null?i.pBits:i.qBits,G=q-1;i.pqState===0?(i.num=new e(q,i.rng),i.num.testBit(G)||i.num.bitwiseTo(e.ONE.shiftLeft(G),O,i.num),i.num.dAddOffset(31-i.num.mod(I).byteValue(),0),L=0,++i.pqState):i.pqState===1?i.num.bitLength()>q?i.pqState=0:i.num.isProbablePrime(h(i.num.bitLength()))?++i.pqState:i.num.dAddOffset(f[L++%8],0):i.pqState===2?i.pqState=i.num.subtract(e.ONE).gcd(i.e).compareTo(e.ONE)===0?3:0:i.pqState===3&&(i.pqState=0,i.p===null?i.p=i.num:i.q=i.num,i.p!==null&&i.q!==null&&++i.state,i.num=null)}else if(i.state===1)i.p.compareTo(i.q)<0&&(i.num=i.p,i.p=i.q,i.q=i.num),++i.state;else if(i.state===2)i.p1=i.p.subtract(e.ONE),i.q1=i.q.subtract(e.ONE),i.phi=i.p1.multiply(i.q1),++i.state;else if(i.state===3)i.phi.gcd(i.e).compareTo(e.ONE)===0?++i.state:(i.p=null,i.q=null,i.state=0);else if(i.state===4)i.n=i.p.multiply(i.q),i.n.bitLength()===i.bits?++i.state:(i.q=null,i.state=0);else if(i.state===5){var Y=i.e.modInverse(i.phi);i.keys={privateKey:y.rsa.setPrivateKey(i.n,i.e,Y,i.p,i.q,Y.mod(i.p1),Y.mod(i.q1),i.q.modInverse(i.p)),publicKey:y.rsa.setPublicKey(i.n,i.e)}}F=+new Date,H+=F-k,k=F}return i.keys!==null},y.rsa.generateKeyPair=function(i,n,I,L){if(arguments.length===1?typeof i=="object"?(I=i,i=void 0):typeof i=="function"&&(L=i,i=void 0):arguments.length===2?typeof i=="number"?typeof n=="function"?(L=n,n=void 0):typeof n!="number"&&(I=n,n=void 0):(I=i,L=n,i=void 0,n=void 0):arguments.length===3&&(typeof n=="number"?typeof I=="function"&&(L=I,I=void 0):(L=I,I=n,n=void 0)),I=I||{},i===void 0&&(i=I.bits||2048),n===void 0&&(n=I.e||65537),!t.options.usePureJavaScript&&!I.prng&&i>=256&&i<=16384&&(n===65537||n===3)){if(L){if(v("generateKeyPair"))return r.generateKeyPair("rsa",{modulusLength:i,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(H,q,G){if(H)return L(H);L(null,{privateKey:y.privateKeyFromPem(G),publicKey:y.publicKeyFromPem(q)})});if(A("generateKey")&&A("exportKey"))return p.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:i,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(H){return p.globalScope.crypto.subtle.exportKey("pkcs8",H.privateKey)}).then(void 0,function(H){L(H)}).then(function(H){if(H){var q=y.privateKeyFromAsn1(o.fromDer(t.util.createBuffer(H)));L(null,{privateKey:q,publicKey:y.setRsaPublicKey(q.n,q.e)})}});if(_("generateKey")&&_("exportKey")){var O=p.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:i,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]);O.oncomplete=function(H){var q=H.target.result,G=p.globalScope.msCrypto.subtle.exportKey("pkcs8",q.privateKey);G.oncomplete=function(Y){var X=Y.target.result,te=y.privateKeyFromAsn1(o.fromDer(t.util.createBuffer(X)));L(null,{privateKey:te,publicKey:y.setRsaPublicKey(te.n,te.e)})},G.onerror=function(Y){L(Y)}},O.onerror=function(H){L(H)};return}}else if(v("generateKeyPairSync")){var k=r.generateKeyPairSync("rsa",{modulusLength:i,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:y.privateKeyFromPem(k.privateKey),publicKey:y.publicKeyFromPem(k.publicKey)}}}var F=y.rsa.createKeyPairGenerationState(i,n,I);if(!L)return y.rsa.stepKeyPairGenerationState(F,0),F.keys;C(F,I,L)},y.setRsaPublicKey=y.rsa.setPublicKey=function(i,n){var I={n:i,e:n};return I.encrypt=function(L,O,k){if(typeof O=="string"?O=O.toUpperCase():O===void 0&&(O="RSAES-PKCS1-V1_5"),O==="RSAES-PKCS1-V1_5")O={encode:function(H,q,G){return m(H,q,2).getBytes()}};else if(O==="RSA-OAEP"||O==="RSAES-OAEP")O={encode:function(H,q){return t.pkcs1.encode_rsa_oaep(q,H,k)}};else if(["RAW","NONE","NULL",null].indexOf(O)!==-1)O={encode:function(H){return H}};else if(typeof O=="string")throw new Error('Unsupported encryption scheme: "'+O+'".');var F=O.encode(L,I,!0);return y.rsa.encrypt(F,I,!0)},I.verify=function(L,O,k,F){typeof k=="string"?k=k.toUpperCase():k===void 0&&(k="RSASSA-PKCS1-V1_5"),F===void 0&&(F={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in F||(F._parseAllDigestBytes=!0),"_skipPaddingChecks"in F||(F._skipPaddingChecks=!1),k==="RSASSA-PKCS1-V1_5"?k={verify:function(q,G){G=E(G,I,!0,void 0,F);var Y=o.fromDer(G,{parseAllBytes:F._parseAllDigestBytes}),X={},te=[];if(!o.validate(Y,U,X,te)||Y.value.length!==2){var ie=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw ie.errors=te,ie}var se=o.derToOid(X.algorithmIdentifier);if(!(se===t.oids.md2||se===t.oids.md5||se===t.oids.sha1||se===t.oids.sha224||se===t.oids.sha256||se===t.oids.sha384||se===t.oids.sha512||se===t.oids["sha512-224"]||se===t.oids["sha512-256"])){var ie=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw ie.oid=se,ie}if((se===t.oids.md2||se===t.oids.md5)&&!("parameters"in X))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifier NULL parameters.");return q===X.digest}}:(k==="NONE"||k==="NULL"||k===null)&&(k={verify:function(q,G){return G=E(G,I,!0,void 0,F),q===G}});var H=y.rsa.decrypt(O,I,!0,!1);return k.verify(L,H,I.n.bitLength())},I},y.setRsaPrivateKey=y.rsa.setPrivateKey=function(i,n,I,L,O,k,F,H){var q={n:i,e:n,d:I,p:L,q:O,dP:k,dQ:F,qInv:H};return q.decrypt=function(G,Y,X){typeof Y=="string"?Y=Y.toUpperCase():Y===void 0&&(Y="RSAES-PKCS1-V1_5");var te=y.rsa.decrypt(G,q,!1,!1);if(Y==="RSAES-PKCS1-V1_5")Y={decode:E};else if(Y==="RSA-OAEP"||Y==="RSAES-OAEP")Y={decode:function(ie,se){return t.pkcs1.decode_rsa_oaep(se,ie,X)}};else if(["RAW","NONE","NULL",null].indexOf(Y)!==-1)Y={decode:function(ie){return ie}};else throw new Error('Unsupported encryption scheme: "'+Y+'".');return Y.decode(te,q,!1)},q.sign=function(G,Y){var X=!1;typeof Y=="string"&&(Y=Y.toUpperCase()),Y===void 0||Y==="RSASSA-PKCS1-V1_5"?(Y={encode:S},X=1):(Y==="NONE"||Y==="NULL"||Y===null)&&(Y={encode:function(){return G}},X=1);var te=Y.encode(G,q.n.bitLength());return y.rsa.encrypt(te,q,X)},q},y.wrapRsaPrivateKey=function(i){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(y.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(i).getBytes())])},y.privateKeyFromAsn1=function(i){var n={},I=[];if(o.validate(i,a,n,I)&&(i=o.fromDer(t.util.createBuffer(n.privateKey))),n={},I=[],!o.validate(i,g,n,I)){var L=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw L.errors=I,L}var O,k,F,H,q,G,Y,X;return O=t.util.createBuffer(n.privateKeyModulus).toHex(),k=t.util.createBuffer(n.privateKeyPublicExponent).toHex(),F=t.util.createBuffer(n.privateKeyPrivateExponent).toHex(),H=t.util.createBuffer(n.privateKeyPrime1).toHex(),q=t.util.createBuffer(n.privateKeyPrime2).toHex(),G=t.util.createBuffer(n.privateKeyExponent1).toHex(),Y=t.util.createBuffer(n.privateKeyExponent2).toHex(),X=t.util.createBuffer(n.privateKeyCoefficient).toHex(),y.setRsaPrivateKey(new e(O,16),new e(k,16),new e(F,16),new e(H,16),new e(q,16),new e(G,16),new e(Y,16),new e(X,16))},y.privateKeyToAsn1=y.privateKeyToRSAPrivateKey=function(i){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.qInv))])},y.publicKeyFromAsn1=function(i){var n={},I=[];if(o.validate(i,b,n,I)){var L=o.derToOid(n.publicKeyOid);if(L!==y.oids.rsaEncryption){var O=new Error("Cannot read public key. Unknown OID.");throw O.oid=L,O}i=n.rsaPublicKey}if(I=[],!o.validate(i,l,n,I)){var O=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw O.errors=I,O}var k=t.util.createBuffer(n.publicKeyModulus).toHex(),F=t.util.createBuffer(n.publicKeyExponent).toHex();return y.setRsaPublicKey(new e(k,16),new e(F,16))},y.publicKeyToAsn1=y.publicKeyToSubjectPublicKeyInfo=function(i){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(y.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[y.publicKeyToRSAPublicKey(i)])])},y.publicKeyToRSAPublicKey=function(i){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,s(i.e))])};function m(i,n,I){var L=t.util.createBuffer(),O=Math.ceil(n.n.bitLength()/8);if(i.length>O-11){var k=new Error("Message is too long for PKCS#1 v1.5 padding.");throw k.length=i.length,k.max=O-11,k}L.putByte(0),L.putByte(I);var F=O-3-i.length,H;if(I===0||I===1){H=I===0?0:255;for(var q=0;q<F;++q)L.putByte(H)}else for(;F>0;){for(var G=0,Y=t.random.getBytes(F),q=0;q<F;++q)H=Y.charCodeAt(q),H===0?++G:L.putByte(H);F=G}return L.putByte(0),L.putBytes(i),L}function E(i,n,I,L,O){var k=Math.ceil(n.n.bitLength()/8),F=t.util.createBuffer(i),H=F.getByte(),q=F.getByte();if(H!==0||I&&q!==0&&q!==1||!I&&q!==2||I&&q===0&&typeof L>"u")throw new Error("Encryption block is invalid.");var G=0;if(q===0){G=k-3-L;for(var Y=0;Y<G;++Y)if(F.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(q===1){for(G=0;F.length()>1;){if(F.getByte()!==255){--F.read;break}++G}if(G<8&&!(O&&O._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(q===2){for(G=0;F.length()>1;){if(F.getByte()===0){--F.read;break}++G}if(G<8&&!(O&&O._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var X=F.getByte();if(X!==0||G!==k-3-F.length())throw new Error("Encryption block is invalid.");return F.getBytes()}function C(i,n,I){typeof n=="function"&&(I=n,n={}),n=n||{};var L={algorithm:{name:n.algorithm||"PRIMEINC",options:{workers:n.workers||2,workLoad:n.workLoad||100,workerScript:n.workerScript}}};"prng"in n&&(L.prng=n.prng),O();function O(){k(i.pBits,function(H,q){if(H)return I(H);if(i.p=q,i.q!==null)return F(H,i.q);k(i.qBits,F)})}function k(H,q){t.prime.generateProbablePrime(H,L,q)}function F(H,q){if(H)return I(H);if(i.q=q,i.p.compareTo(i.q)<0){var G=i.p;i.p=i.q,i.q=G}if(i.p.subtract(e.ONE).gcd(i.e).compareTo(e.ONE)!==0){i.p=null,O();return}if(i.q.subtract(e.ONE).gcd(i.e).compareTo(e.ONE)!==0){i.q=null,k(i.qBits,F);return}if(i.p1=i.p.subtract(e.ONE),i.q1=i.q.subtract(e.ONE),i.phi=i.p1.multiply(i.q1),i.phi.gcd(i.e).compareTo(e.ONE)!==0){i.p=i.q=null,O();return}if(i.n=i.p.multiply(i.q),i.n.bitLength()!==i.bits){i.q=null,k(i.qBits,F);return}var Y=i.e.modInverse(i.phi);i.keys={privateKey:y.rsa.setPrivateKey(i.n,i.e,Y,i.p,i.q,Y.mod(i.p1),Y.mod(i.q1),i.q.modInverse(i.p)),publicKey:y.rsa.setPublicKey(i.n,i.e)},I(null,i.keys)}}function s(i){var n=i.toString(16);n[0]>="8"&&(n="00"+n);var I=t.util.hexToBytes(n);return I.length>1&&(I.charCodeAt(0)===0&&(I.charCodeAt(1)&128)===0||I.charCodeAt(0)===255&&(I.charCodeAt(1)&128)===128)?I.substr(1):I}function h(i){return i<=100?27:i<=150?18:i<=200?15:i<=250?12:i<=300?9:i<=350?8:i<=400?7:i<=500?6:i<=600?5:i<=800?4:i<=1250?3:2}function v(i){return t.util.isNodejs&&typeof r[i]=="function"}function A(i){return typeof p.globalScope<"u"&&typeof p.globalScope.crypto=="object"&&typeof p.globalScope.crypto.subtle=="object"&&typeof p.globalScope.crypto.subtle[i]=="function"}function _(i){return typeof p.globalScope<"u"&&typeof p.globalScope.msCrypto=="object"&&typeof p.globalScope.msCrypto.subtle=="object"&&typeof p.globalScope.msCrypto.subtle[i]=="function"}function d(i){for(var n=t.util.hexToBytes(i.toString(16)),I=new Uint8Array(n.length),L=0;L<n.length;++L)I[L]=n.charCodeAt(L);return I}return Ar}var Ir,Fa;function Un(){if(Fa)return Ir;Fa=1;var t=le();if(St(),ot(),$t(),dt(),bt(),na(),Nt(),it(),_n(),Zt(),pe(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.asn1,o=t.pki=t.pki||{};Ir=o.pbe=t.pbe=t.pbe||{};var p=o.oids,y={name:"EncryptedPrivateKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},f={name:"PBES2Algorithms",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},a={name:"pkcs-12PbeParams",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"iterations"}]};o.encryptPrivateKeyInfo=function(S,c,m){m=m||{},m.saltSize=m.saltSize||8,m.count=m.count||2048,m.algorithm=m.algorithm||"aes128",m.prfAlgorithm=m.prfAlgorithm||"sha1";var E=t.random.getBytesSync(m.saltSize),C=m.count,s=r.integerToDer(C),h,v,A;if(m.algorithm.indexOf("aes")===0||m.algorithm==="des"){var _,d,i;switch(m.algorithm){case"aes128":h=16,_=16,d=p["aes128-CBC"],i=t.aes.createEncryptionCipher;break;case"aes192":h=24,_=16,d=p["aes192-CBC"],i=t.aes.createEncryptionCipher;break;case"aes256":h=32,_=16,d=p["aes256-CBC"],i=t.aes.createEncryptionCipher;break;case"des":h=8,_=8,d=p.desCBC,i=t.des.createEncryptionCipher;break;default:var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=m.algorithm,n}var I="hmacWith"+m.prfAlgorithm.toUpperCase(),L=b(I),O=t.pkcs5.pbkdf2(c,E,C,h,L),k=t.random.getBytesSync(_),F=i(O);F.start(k),F.update(r.toDer(S)),F.finish(),A=F.output.getBytes();var H=U(E,s,h,I);v=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p.pkcs5PBES2).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p.pkcs5PBKDF2).getBytes()),H]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(d).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,k)])])])}else if(m.algorithm==="3des"){h=24;var q=new t.util.ByteBuffer(E),O=o.pbe.generatePkcs12Key(c,q,1,C,h),k=o.pbe.generatePkcs12Key(c,q,2,C,h),F=t.des.createEncryptionCipher(O);F.start(k),F.update(r.toDer(S)),F.finish(),A=F.output.getBytes(),v=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(p["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,E),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,s.getBytes())])])}else{var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=m.algorithm,n}var G=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[v,r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,A)]);return G},o.decryptPrivateKeyInfo=function(S,c){var m=null,E={},C=[];if(!r.validate(S,y,E,C)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=C,s}var h=r.derToOid(E.encryptionOid),v=o.pbe.getCipher(h,E.encryptionParams,c),A=t.util.createBuffer(E.encryptedData);return v.update(A),v.finish()&&(m=r.fromDer(v.output)),m},o.encryptedPrivateKeyToPem=function(S,c){var m={type:"ENCRYPTED PRIVATE KEY",body:r.toDer(S).getBytes()};return t.pem.encode(m,{maxline:c})},o.encryptedPrivateKeyFromPem=function(S){var c=t.pem.decode(S)[0];if(c.type!=="ENCRYPTED PRIVATE KEY"){var m=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw m.headerType=c.type,m}if(c.procType&&c.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return r.fromDer(c.body)},o.encryptRsaPrivateKey=function(S,c,m){if(m=m||{},!m.legacy){var E=o.wrapRsaPrivateKey(o.privateKeyToAsn1(S));return E=o.encryptPrivateKeyInfo(E,c,m),o.encryptedPrivateKeyToPem(E)}var C,s,h,v;switch(m.algorithm){case"aes128":C="AES-128-CBC",h=16,s=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"aes192":C="AES-192-CBC",h=24,s=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"aes256":C="AES-256-CBC",h=32,s=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"3des":C="DES-EDE3-CBC",h=24,s=t.random.getBytesSync(8),v=t.des.createEncryptionCipher;break;case"des":C="DES-CBC",h=8,s=t.random.getBytesSync(8),v=t.des.createEncryptionCipher;break;default:var A=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+m.algorithm+'".');throw A.algorithm=m.algorithm,A}var _=t.pbe.opensslDeriveBytes(c,s.substr(0,8),h),d=v(_);d.start(s),d.update(r.toDer(o.privateKeyToAsn1(S))),d.finish();var i={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:C,parameters:t.util.bytesToHex(s).toUpperCase()},body:d.output.getBytes()};return t.pem.encode(i)},o.decryptRsaPrivateKey=function(S,c){var m=null,E=t.pem.decode(S)[0];if(E.type!=="ENCRYPTED PRIVATE KEY"&&E.type!=="PRIVATE KEY"&&E.type!=="RSA PRIVATE KEY"){var C=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw C.headerType=C,C}if(E.procType&&E.procType.type==="ENCRYPTED"){var s,h;switch(E.dekInfo.algorithm){case"DES-CBC":s=8,h=t.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,h=t.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,h=t.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,h=t.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,h=t.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,h=function(i){return t.rc2.createDecryptionCipher(i,40)};break;case"RC2-64-CBC":s=8,h=function(i){return t.rc2.createDecryptionCipher(i,64)};break;case"RC2-128-CBC":s=16,h=function(i){return t.rc2.createDecryptionCipher(i,128)};break;default:var C=new Error('Could not decrypt private key; unsupported encryption algorithm "'+E.dekInfo.algorithm+'".');throw C.algorithm=E.dekInfo.algorithm,C}var v=t.util.hexToBytes(E.dekInfo.parameters),A=t.pbe.opensslDeriveBytes(c,v.substr(0,8),s),_=h(A);if(_.start(v),_.update(t.util.createBuffer(E.body)),_.finish())m=_.output.getBytes();else return m}else m=E.body;return E.type==="ENCRYPTED PRIVATE KEY"?m=o.decryptPrivateKeyInfo(r.fromDer(m),c):m=r.fromDer(m),m!==null&&(m=o.privateKeyFromAsn1(m)),m},o.pbe.generatePkcs12Key=function(S,c,m,E,C,s){var h,v;if(typeof s>"u"||s===null){if(!("sha1"in t.md))throw new Error('"sha1" hash algorithm unavailable.');s=t.md.sha1.create()}var A=s.digestLength,_=s.blockLength,d=new t.util.ByteBuffer,i=new t.util.ByteBuffer;if(S!=null){for(v=0;v<S.length;v++)i.putInt16(S.charCodeAt(v));i.putInt16(0)}var n=i.length(),I=c.length(),L=new t.util.ByteBuffer;L.fillWithByte(m,_);var O=_*Math.ceil(I/_),k=new t.util.ByteBuffer;for(v=0;v<O;v++)k.putByte(c.at(v%I));var F=_*Math.ceil(n/_),H=new t.util.ByteBuffer;for(v=0;v<F;v++)H.putByte(i.at(v%n));var q=k;q.putBuffer(H);for(var G=Math.ceil(C/A),Y=1;Y<=G;Y++){var X=new t.util.ByteBuffer;X.putBytes(L.bytes()),X.putBytes(q.bytes());for(var te=0;te<E;te++)s.start(),s.update(X.getBytes()),X=s.digest();var ie=new t.util.ByteBuffer;for(v=0;v<_;v++)ie.putByte(X.at(v%A));var se=Math.ceil(I/_)+Math.ceil(n/_),ae=new t.util.ByteBuffer;for(h=0;h<se;h++){var ue=new t.util.ByteBuffer(q.getBytes(_)),ce=511;for(v=ie.length()-1;v>=0;v--)ce=ce>>8,ce+=ie.at(v)+ue.at(v),ue.setAt(v,ce&255);ae.putBuffer(ue)}q=ae,d.putBuffer(X)}return d.truncate(d.length()-C),d},o.pbe.getCipher=function(S,c,m){switch(S){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(S,c,m);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(S,c,m);default:var E=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw E.oid=S,E.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],E}},o.pbe.getCipherForPBES2=function(S,c,m){var E={},C=[];if(!r.validate(c,f,E,C)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=C,s}if(S=r.derToOid(E.kdfOid),S!==o.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=S,s.supportedOids=["pkcs5PBKDF2"],s}if(S=r.derToOid(E.encOid),S!==o.oids["aes128-CBC"]&&S!==o.oids["aes192-CBC"]&&S!==o.oids["aes256-CBC"]&&S!==o.oids["des-EDE3-CBC"]&&S!==o.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=S,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var h=E.kdfSalt,v=t.util.createBuffer(E.kdfIterationCount);v=v.getInt(v.length()<<3);var A,_;switch(o.oids[S]){case"aes128-CBC":A=16,_=t.aes.createDecryptionCipher;break;case"aes192-CBC":A=24,_=t.aes.createDecryptionCipher;break;case"aes256-CBC":A=32,_=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":A=24,_=t.des.createDecryptionCipher;break;case"desCBC":A=8,_=t.des.createDecryptionCipher;break}var d=l(E.prfOid),i=t.pkcs5.pbkdf2(m,h,v,A,d),n=E.encIv,I=_(i);return I.start(n),I},o.pbe.getCipherForPKCS12PBE=function(S,c,m){var E={},C=[];if(!r.validate(c,a,E,C)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=C,s}var h=t.util.createBuffer(E.salt),v=t.util.createBuffer(E.iterations);v=v.getInt(v.length()<<3);var A,_,d;switch(S){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:A=24,_=8,d=t.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:A=5,_=8,d=function(O,k){var F=t.rc2.createDecryptionCipher(O,40);return F.start(k,null),F};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=S,s}var i=l(E.prfOid),n=o.pbe.generatePkcs12Key(m,h,1,v,A,i);i.start();var I=o.pbe.generatePkcs12Key(m,h,2,v,_,i);return d(n,I)},o.pbe.opensslDeriveBytes=function(S,c,m,E){if(typeof E>"u"||E===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');E=t.md.md5.create()}c===null&&(c="");for(var C=[g(E,S+c)],s=16,h=1;s<m;++h,s+=16)C.push(g(E,C[h-1]+S+c));return C.join("").substr(0,m)};function g(S,c){return S.start().update(c).digest().getBytes()}function l(S){var c;if(!S)c="hmacWithSHA1";else if(c=o.oids[r.derToOid(S)],!c){var m=new Error("Unsupported PRF OID.");throw m.oid=S,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}return b(c)}function b(S){var c=t.md;switch(S){case"hmacWithSHA224":c=t.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":S=S.substr(8).toLowerCase();break;default:var m=new Error("Unsupported PRF algorithm.");throw m.algorithm=S,m.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],m}if(!c||!(S in c))throw new Error("Unknown hash algorithm: "+S);return c[S].create()}function U(S,c,m,E){var C=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,S),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,c.getBytes())]);return E!=="hmacWithSHA1"&&C.value.push(r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,t.util.hexToBytes(m.toString(16))),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(o.oids[E]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")])),C}return Ir}var Br={exports:{}},wr={exports:{}},Ka;function kn(){if(Ka)return wr.exports;Ka=1;var t=le();ot(),pe();var e=t.asn1,r=wr.exports=t.pkcs7asn1=t.pkcs7asn1||{};t.pkcs7=t.pkcs7||{},t.pkcs7.asn1=r;var o={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=o;var p={name:"EncryptedContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(p)},r.encryptedDataValidator={name:"EncryptedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"}].concat(p)};var y={name:"SignerInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};return r.signedDataValidator={name:"SignedData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},o,{name:"SignedData.Certificates",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,capture:"signerInfos",optional:!0,value:[y]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:e.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]},wr.exports}var Nr={exports:{}},Rr={exports:{}},Ma;function Pn(){if(Ma)return Rr.exports;Ma=1;var t=le();pe(),t.mgf=t.mgf||{};var e=Rr.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};return e.create=function(r){var o={generate:function(p,y){for(var f=new t.util.ByteBuffer,a=Math.ceil(y/r.digestLength),g=0;g<a;g++){var l=new t.util.ByteBuffer;l.putInt32(g),r.start(),r.update(p+l.getBytes()),f.putBuffer(r.digest())}return f.truncate(f.length()-y),f.getBytes()}};return o},Rr.exports}var _r,qa;function cs(){if(qa)return _r;qa=1;var t=le();return Pn(),_r=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1,_r}var Dr={exports:{}},Ha;function ia(){if(Ha)return Dr.exports;Ha=1;var t=le();it(),pe();var e=Dr.exports=t.pss=t.pss||{};return e.create=function(r){arguments.length===3&&(r={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var o=r.md,p=r.mgf,y=o.digestLength,f=r.salt||null;typeof f=="string"&&(f=t.util.createBuffer(f));var a;if("saltLength"in r)a=r.saltLength;else if(f!==null)a=f.length();else throw new Error("Salt length not specified or specific salt not given.");if(f!==null&&f.length()!==a)throw new Error("Given salt length does not match length of given salt.");var g=r.prng||t.random,l={};return l.encode=function(b,U){var S,c=U-1,m=Math.ceil(c/8),E=b.digest().getBytes();if(m<y+a+2)throw new Error("Message is too long to encrypt.");var C;f===null?C=g.getBytesSync(a):C=f.bytes();var s=new t.util.ByteBuffer;s.fillWithByte(0,8),s.putBytes(E),s.putBytes(C),o.start(),o.update(s.getBytes());var h=o.digest().getBytes(),v=new t.util.ByteBuffer;v.fillWithByte(0,m-a-y-2),v.putByte(1),v.putBytes(C);var A=v.getBytes(),_=m-y-1,d=p.generate(h,_),i="";for(S=0;S<_;S++)i+=String.fromCharCode(A.charCodeAt(S)^d.charCodeAt(S));var n=65280>>8*m-c&255;return i=String.fromCharCode(i.charCodeAt(0)&~n)+i.substr(1),i+h+"¼"},l.verify=function(b,U,S){var c,m=S-1,E=Math.ceil(m/8);if(U=U.substr(-E),E<y+a+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(U.charCodeAt(E-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var C=E-y-1,s=U.substr(0,C),h=U.substr(C,y),v=65280>>8*E-m&255;if((s.charCodeAt(0)&v)!==0)throw new Error("Bits beyond keysize not zero as expected.");var A=p.generate(h,C),_="";for(c=0;c<C;c++)_+=String.fromCharCode(s.charCodeAt(c)^A.charCodeAt(c));_=String.fromCharCode(_.charCodeAt(0)&~v)+_.substr(1);var d=E-y-a-2;for(c=0;c<d;c++)if(_.charCodeAt(c)!==0)throw new Error("Leftmost octets not zero as expected");if(_.charCodeAt(d)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var i=_.substr(-a),n=new t.util.ByteBuffer;n.fillWithByte(0,8),n.putBytes(b),n.putBytes(i),o.start(),o.update(n.getBytes());var I=o.digest().getBytes();return h===I},l},Dr.exports}var Ga;function sa(){if(Ga)return Nr.exports;Ga=1;var t=le();St(),ot(),$t(),dt(),cs(),bt(),Nt(),ia(),Zt(),pe();var e=t.asn1,r=Nr.exports=t.pki=t.pki||{},o=r.oids,p={};p.CN=o.commonName,p.commonName="CN",p.C=o.countryName,p.countryName="C",p.L=o.localityName,p.localityName="L",p.ST=o.stateOrProvinceName,p.stateOrProvinceName="ST",p.O=o.organizationName,p.organizationName="O",p.OU=o.organizationalUnitName,p.organizationalUnitName="OU",p.E=o.emailAddress,p.emailAddress="E";var y=t.pki.rsa.publicKeyValidator,f={name:"Certificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:e.Class.UNIVERSAL,type:e.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:e.Class.UNIVERSAL,type:e.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},y,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},a={name:"rsapss",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:e.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:e.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:e.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:e.Class.UNIVERSAL,type:e.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},g={name:"CertificationRequestInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},y,{name:"CertificationRequestInfo.attributes",tagClass:e.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0}]}]}]},l={name:"CertificationRequest",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[g,{name:"CertificationRequest.signatureAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:e.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};r.RDNAttributesAsArray=function(d,i){for(var n=[],I,L,O,k=0;k<d.value.length;++k){I=d.value[k];for(var F=0;F<I.value.length;++F)O={},L=I.value[F],O.type=e.derToOid(L.value[0].value),O.value=L.value[1].value,O.valueTagClass=L.value[1].type,O.type in o&&(O.name=o[O.type],O.name in p&&(O.shortName=p[O.name])),i&&(i.update(O.type),i.update(O.value)),n.push(O)}return n},r.CRIAttributesAsArray=function(d){for(var i=[],n=0;n<d.length;++n)for(var I=d[n],L=e.derToOid(I.value[0].value),O=I.value[1].value,k=0;k<O.length;++k){var F={};if(F.type=L,F.value=O[k].value,F.valueTagClass=O[k].type,F.type in o&&(F.name=o[F.type],F.name in p&&(F.shortName=p[F.name])),F.type===o.extensionRequest){F.extensions=[];for(var H=0;H<F.value.length;++H)F.extensions.push(r.certificateExtensionFromAsn1(F.value[H]))}i.push(F)}return i};function b(d,i){typeof i=="string"&&(i={shortName:i});for(var n=null,I,L=0;n===null&&L<d.attributes.length;++L)I=d.attributes[L],(i.type&&i.type===I.type||i.name&&i.name===I.name||i.shortName&&i.shortName===I.shortName)&&(n=I);return n}var U=function(d,i,n){var I={};if(d!==o["RSASSA-PSS"])return I;n&&(I={hash:{algorithmOid:o.sha1},mgf:{algorithmOid:o.mgf1,hash:{algorithmOid:o.sha1}},saltLength:20});var L={},O=[];if(!e.validate(i,a,L,O)){var k=new Error("Cannot read RSASSA-PSS parameter block.");throw k.errors=O,k}return L.hashOid!==void 0&&(I.hash=I.hash||{},I.hash.algorithmOid=e.derToOid(L.hashOid)),L.maskGenOid!==void 0&&(I.mgf=I.mgf||{},I.mgf.algorithmOid=e.derToOid(L.maskGenOid),I.mgf.hash=I.mgf.hash||{},I.mgf.hash.algorithmOid=e.derToOid(L.maskGenHashOid)),L.saltLength!==void 0&&(I.saltLength=L.saltLength.charCodeAt(0)),I},S=function(d){switch(o[d.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return t.md.sha1.create();case"md5WithRSAEncryption":return t.md.md5.create();case"sha256WithRSAEncryption":return t.md.sha256.create();case"sha384WithRSAEncryption":return t.md.sha384.create();case"sha512WithRSAEncryption":return t.md.sha512.create();case"RSASSA-PSS":return t.md.sha256.create();default:var i=new Error("Could not compute "+d.type+" digest. Unknown signature OID.");throw i.signatureOid=d.signatureOid,i}},c=function(d){var i=d.certificate,n;switch(i.signatureOid){case o.sha1WithRSAEncryption:case o.sha1WithRSASignature:break;case o["RSASSA-PSS"]:var I,L;if(I=o[i.signatureParameters.mgf.hash.algorithmOid],I===void 0||t.md[I]===void 0){var O=new Error("Unsupported MGF hash function.");throw O.oid=i.signatureParameters.mgf.hash.algorithmOid,O.name=I,O}if(L=o[i.signatureParameters.mgf.algorithmOid],L===void 0||t.mgf[L]===void 0){var O=new Error("Unsupported MGF function.");throw O.oid=i.signatureParameters.mgf.algorithmOid,O.name=L,O}if(L=t.mgf[L].create(t.md[I].create()),I=o[i.signatureParameters.hash.algorithmOid],I===void 0||t.md[I]===void 0){var O=new Error("Unsupported RSASSA-PSS hash function.");throw O.oid=i.signatureParameters.hash.algorithmOid,O.name=I,O}n=t.pss.create(t.md[I].create(),L,i.signatureParameters.saltLength);break}return i.publicKey.verify(d.md.digest().getBytes(),d.signature,n)};r.certificateFromPem=function(d,i,n){var I=t.pem.decode(d)[0];if(I.type!=="CERTIFICATE"&&I.type!=="X509 CERTIFICATE"&&I.type!=="TRUSTED CERTIFICATE"){var L=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw L.headerType=I.type,L}if(I.procType&&I.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=e.fromDer(I.body,n);return r.certificateFromAsn1(O,i)},r.certificateToPem=function(d,i){var n={type:"CERTIFICATE",body:e.toDer(r.certificateToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:i})},r.publicKeyFromPem=function(d){var i=t.pem.decode(d)[0];if(i.type!=="PUBLIC KEY"&&i.type!=="RSA PUBLIC KEY"){var n=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw n.headerType=i.type,n}if(i.procType&&i.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var I=e.fromDer(i.body);return r.publicKeyFromAsn1(I)},r.publicKeyToPem=function(d,i){var n={type:"PUBLIC KEY",body:e.toDer(r.publicKeyToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:i})},r.publicKeyToRSAPublicKeyPem=function(d,i){var n={type:"RSA PUBLIC KEY",body:e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes()};return t.pem.encode(n,{maxline:i})},r.getPublicKeyFingerprint=function(d,i){i=i||{};var n=i.md||t.md.sha1.create(),I=i.type||"RSAPublicKey",L;switch(I){case"RSAPublicKey":L=e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes();break;case"SubjectPublicKeyInfo":L=e.toDer(r.publicKeyToAsn1(d)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+i.type+'".')}n.start(),n.update(L);var O=n.digest();if(i.encoding==="hex"){var k=O.toHex();return i.delimiter?k.match(/.{2}/g).join(i.delimiter):k}else{if(i.encoding==="binary")return O.getBytes();if(i.encoding)throw new Error('Unknown encoding "'+i.encoding+'".')}return O},r.certificationRequestFromPem=function(d,i,n){var I=t.pem.decode(d)[0];if(I.type!=="CERTIFICATE REQUEST"){var L=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw L.headerType=I.type,L}if(I.procType&&I.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var O=e.fromDer(I.body,n);return r.certificationRequestFromAsn1(O,i)},r.certificationRequestToPem=function(d,i){var n={type:"CERTIFICATE REQUEST",body:e.toDer(r.certificationRequestToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:i})},r.createCertificate=function(){var d={};return d.version=2,d.serialNumber="00",d.signatureOid=null,d.signature=null,d.siginfo={},d.siginfo.algorithmOid=null,d.validity={},d.validity.notBefore=new Date,d.validity.notAfter=new Date,d.issuer={},d.issuer.getField=function(i){return b(d.issuer,i)},d.issuer.addField=function(i){E([i]),d.issuer.attributes.push(i)},d.issuer.attributes=[],d.issuer.hash=null,d.subject={},d.subject.getField=function(i){return b(d.subject,i)},d.subject.addField=function(i){E([i]),d.subject.attributes.push(i)},d.subject.attributes=[],d.subject.hash=null,d.extensions=[],d.publicKey=null,d.md=null,d.setSubject=function(i,n){E(i),d.subject.attributes=i,delete d.subject.uniqueId,n&&(d.subject.uniqueId=n),d.subject.hash=null},d.setIssuer=function(i,n){E(i),d.issuer.attributes=i,delete d.issuer.uniqueId,n&&(d.issuer.uniqueId=n),d.issuer.hash=null},d.setExtensions=function(i){for(var n=0;n<i.length;++n)C(i[n],{cert:d});d.extensions=i},d.getExtension=function(i){typeof i=="string"&&(i={name:i});for(var n=null,I,L=0;n===null&&L<d.extensions.length;++L)I=d.extensions[L],(i.id&&I.id===i.id||i.name&&I.name===i.name)&&(n=I);return n},d.sign=function(i,n){d.md=n||t.md.sha1.create();var I=o[d.md.algorithm+"WithRSAEncryption"];if(!I){var L=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw L.algorithm=d.md.algorithm,L}d.signatureOid=d.siginfo.algorithmOid=I,d.tbsCertificate=r.getTBSCertificate(d);var O=e.toDer(d.tbsCertificate);d.md.update(O.getBytes()),d.signature=i.sign(d.md)},d.verify=function(i){var n=!1;if(!d.issued(i)){var I=i.issuer,L=d.subject,O=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw O.expectedIssuer=L.attributes,O.actualIssuer=I.attributes,O}var k=i.md;if(k===null){k=S({signatureOid:i.signatureOid,type:"certificate"});var F=i.tbsCertificate||r.getTBSCertificate(i),H=e.toDer(F);k.update(H.getBytes())}return k!==null&&(n=c({certificate:d,md:k,signature:i.signature})),n},d.isIssuer=function(i){var n=!1,I=d.issuer,L=i.subject;if(I.hash&&L.hash)n=I.hash===L.hash;else if(I.attributes.length===L.attributes.length){n=!0;for(var O,k,F=0;n&&F<I.attributes.length;++F)O=I.attributes[F],k=L.attributes[F],(O.type!==k.type||O.value!==k.value)&&(n=!1)}return n},d.issued=function(i){return i.isIssuer(d)},d.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(d.publicKey,{type:"RSAPublicKey"})},d.verifySubjectKeyIdentifier=function(){for(var i=o.subjectKeyIdentifier,n=0;n<d.extensions.length;++n){var I=d.extensions[n];if(I.id===i){var L=d.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(I.subjectKeyIdentifier)===L}}return!1},d},r.certificateFromAsn1=function(d,i){var n={},I=[];if(!e.validate(d,f,n,I)){var L=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw L.errors=I,L}var O=e.derToOid(n.publicKeyOid);if(O!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var k=r.createCertificate();k.version=n.certVersion?n.certVersion.charCodeAt(0):0;var F=t.util.createBuffer(n.certSerialNumber);k.serialNumber=F.toHex(),k.signatureOid=t.asn1.derToOid(n.certSignatureOid),k.signatureParameters=U(k.signatureOid,n.certSignatureParams,!0),k.siginfo.algorithmOid=t.asn1.derToOid(n.certinfoSignatureOid),k.siginfo.parameters=U(k.siginfo.algorithmOid,n.certinfoSignatureParams,!1),k.signature=n.certSignature;var H=[];if(n.certValidity1UTCTime!==void 0&&H.push(e.utcTimeToDate(n.certValidity1UTCTime)),n.certValidity2GeneralizedTime!==void 0&&H.push(e.generalizedTimeToDate(n.certValidity2GeneralizedTime)),n.certValidity3UTCTime!==void 0&&H.push(e.utcTimeToDate(n.certValidity3UTCTime)),n.certValidity4GeneralizedTime!==void 0&&H.push(e.generalizedTimeToDate(n.certValidity4GeneralizedTime)),H.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(H.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(k.validity.notBefore=H[0],k.validity.notAfter=H[1],k.tbsCertificate=n.tbsCertificate,i){k.md=S({signatureOid:k.signatureOid,type:"certificate"});var q=e.toDer(k.tbsCertificate);k.md.update(q.getBytes())}var G=t.md.sha1.create(),Y=e.toDer(n.certIssuer);G.update(Y.getBytes()),k.issuer.getField=function(ie){return b(k.issuer,ie)},k.issuer.addField=function(ie){E([ie]),k.issuer.attributes.push(ie)},k.issuer.attributes=r.RDNAttributesAsArray(n.certIssuer),n.certIssuerUniqueId&&(k.issuer.uniqueId=n.certIssuerUniqueId),k.issuer.hash=G.digest().toHex();var X=t.md.sha1.create(),te=e.toDer(n.certSubject);return X.update(te.getBytes()),k.subject.getField=function(ie){return b(k.subject,ie)},k.subject.addField=function(ie){E([ie]),k.subject.attributes.push(ie)},k.subject.attributes=r.RDNAttributesAsArray(n.certSubject),n.certSubjectUniqueId&&(k.subject.uniqueId=n.certSubjectUniqueId),k.subject.hash=X.digest().toHex(),n.certExtensions?k.extensions=r.certificateExtensionsFromAsn1(n.certExtensions):k.extensions=[],k.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),k},r.certificateExtensionsFromAsn1=function(d){for(var i=[],n=0;n<d.value.length;++n)for(var I=d.value[n],L=0;L<I.value.length;++L)i.push(r.certificateExtensionFromAsn1(I.value[L]));return i},r.certificateExtensionFromAsn1=function(d){var i={};if(i.id=e.derToOid(d.value[0].value),i.critical=!1,d.value[1].type===e.Type.BOOLEAN?(i.critical=d.value[1].value.charCodeAt(0)!==0,i.value=d.value[2].value):i.value=d.value[1].value,i.id in o){if(i.name=o[i.id],i.name==="keyUsage"){var n=e.fromDer(i.value),I=0,L=0;n.value.length>1&&(I=n.value.charCodeAt(1),L=n.value.length>2?n.value.charCodeAt(2):0),i.digitalSignature=(I&128)===128,i.nonRepudiation=(I&64)===64,i.keyEncipherment=(I&32)===32,i.dataEncipherment=(I&16)===16,i.keyAgreement=(I&8)===8,i.keyCertSign=(I&4)===4,i.cRLSign=(I&2)===2,i.encipherOnly=(I&1)===1,i.decipherOnly=(L&128)===128}else if(i.name==="basicConstraints"){var n=e.fromDer(i.value);n.value.length>0&&n.value[0].type===e.Type.BOOLEAN?i.cA=n.value[0].value.charCodeAt(0)!==0:i.cA=!1;var O=null;n.value.length>0&&n.value[0].type===e.Type.INTEGER?O=n.value[0].value:n.value.length>1&&(O=n.value[1].value),O!==null&&(i.pathLenConstraint=e.derToInteger(O))}else if(i.name==="extKeyUsage")for(var n=e.fromDer(i.value),k=0;k<n.value.length;++k){var F=e.derToOid(n.value[k].value);F in o?i[o[F]]=!0:i[F]=!0}else if(i.name==="nsCertType"){var n=e.fromDer(i.value),I=0;n.value.length>1&&(I=n.value.charCodeAt(1)),i.client=(I&128)===128,i.server=(I&64)===64,i.email=(I&32)===32,i.objsign=(I&16)===16,i.reserved=(I&8)===8,i.sslCA=(I&4)===4,i.emailCA=(I&2)===2,i.objCA=(I&1)===1}else if(i.name==="subjectAltName"||i.name==="issuerAltName"){i.altNames=[];for(var H,n=e.fromDer(i.value),q=0;q<n.value.length;++q){H=n.value[q];var G={type:H.type,value:H.value};switch(i.altNames.push(G),H.type){case 1:case 2:case 6:break;case 7:G.ip=t.util.bytesToIP(H.value);break;case 8:G.oid=e.derToOid(H.value);break}}}else if(i.name==="subjectKeyIdentifier"){var n=e.fromDer(i.value);i.subjectKeyIdentifier=t.util.bytesToHex(n.value)}}return i},r.certificationRequestFromAsn1=function(d,i){var n={},I=[];if(!e.validate(d,l,n,I)){var L=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw L.errors=I,L}var O=e.derToOid(n.publicKeyOid);if(O!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var k=r.createCertificationRequest();if(k.version=n.csrVersion?n.csrVersion.charCodeAt(0):0,k.signatureOid=t.asn1.derToOid(n.csrSignatureOid),k.signatureParameters=U(k.signatureOid,n.csrSignatureParams,!0),k.siginfo.algorithmOid=t.asn1.derToOid(n.csrSignatureOid),k.siginfo.parameters=U(k.siginfo.algorithmOid,n.csrSignatureParams,!1),k.signature=n.csrSignature,k.certificationRequestInfo=n.certificationRequestInfo,i){k.md=S({signatureOid:k.signatureOid,type:"certification request"});var F=e.toDer(k.certificationRequestInfo);k.md.update(F.getBytes())}var H=t.md.sha1.create();return k.subject.getField=function(q){return b(k.subject,q)},k.subject.addField=function(q){E([q]),k.subject.attributes.push(q)},k.subject.attributes=r.RDNAttributesAsArray(n.certificationRequestInfoSubject,H),k.subject.hash=H.digest().toHex(),k.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),k.getAttribute=function(q){return b(k,q)},k.addAttribute=function(q){E([q]),k.attributes.push(q)},k.attributes=r.CRIAttributesAsArray(n.certificationRequestInfoAttributes||[]),k},r.createCertificationRequest=function(){var d={};return d.version=0,d.signatureOid=null,d.signature=null,d.siginfo={},d.siginfo.algorithmOid=null,d.subject={},d.subject.getField=function(i){return b(d.subject,i)},d.subject.addField=function(i){E([i]),d.subject.attributes.push(i)},d.subject.attributes=[],d.subject.hash=null,d.publicKey=null,d.attributes=[],d.getAttribute=function(i){return b(d,i)},d.addAttribute=function(i){E([i]),d.attributes.push(i)},d.md=null,d.setSubject=function(i){E(i),d.subject.attributes=i,d.subject.hash=null},d.setAttributes=function(i){E(i),d.attributes=i},d.sign=function(i,n){d.md=n||t.md.sha1.create();var I=o[d.md.algorithm+"WithRSAEncryption"];if(!I){var L=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw L.algorithm=d.md.algorithm,L}d.signatureOid=d.siginfo.algorithmOid=I,d.certificationRequestInfo=r.getCertificationRequestInfo(d);var O=e.toDer(d.certificationRequestInfo);d.md.update(O.getBytes()),d.signature=i.sign(d.md)},d.verify=function(){var i=!1,n=d.md;if(n===null){n=S({signatureOid:d.signatureOid,type:"certification request"});var I=d.certificationRequestInfo||r.getCertificationRequestInfo(d),L=e.toDer(I);n.update(L.getBytes())}return n!==null&&(i=c({certificate:d,md:n,signature:d.signature})),i},d};function m(d){for(var i=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),n,I,L=d.attributes,O=0;O<L.length;++O){n=L[O];var k=n.value,F=e.Type.PRINTABLESTRING;"valueTagClass"in n&&(F=n.valueTagClass,F===e.Type.UTF8&&(k=t.util.encodeUtf8(k))),I=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(n.type).getBytes()),e.create(e.Class.UNIVERSAL,F,!1,k)])]),i.value.push(I)}return i}function E(d){for(var i,n=0;n<d.length;++n){if(i=d[n],typeof i.name>"u"&&(i.type&&i.type in r.oids?i.name=r.oids[i.type]:i.shortName&&i.shortName in p&&(i.name=r.oids[p[i.shortName]])),typeof i.type>"u")if(i.name&&i.name in r.oids)i.type=r.oids[i.name];else{var I=new Error("Attribute type not specified.");throw I.attribute=i,I}if(typeof i.shortName>"u"&&i.name&&i.name in p&&(i.shortName=p[i.name]),i.type===o.extensionRequest&&(i.valueConstructed=!0,i.valueTagClass=e.Type.SEQUENCE,!i.value&&i.extensions)){i.value=[];for(var L=0;L<i.extensions.length;++L)i.value.push(r.certificateExtensionToAsn1(C(i.extensions[L])))}if(typeof i.value>"u"){var I=new Error("Attribute value not specified.");throw I.attribute=i,I}}}function C(d,i){if(i=i||{},typeof d.name>"u"&&d.id&&d.id in r.oids&&(d.name=r.oids[d.id]),typeof d.id>"u")if(d.name&&d.name in r.oids)d.id=r.oids[d.name];else{var n=new Error("Extension ID not specified.");throw n.extension=d,n}if(typeof d.value<"u")return d;if(d.name==="keyUsage"){var I=0,L=0,O=0;d.digitalSignature&&(L|=128,I=7),d.nonRepudiation&&(L|=64,I=6),d.keyEncipherment&&(L|=32,I=5),d.dataEncipherment&&(L|=16,I=4),d.keyAgreement&&(L|=8,I=3),d.keyCertSign&&(L|=4,I=2),d.cRLSign&&(L|=2,I=1),d.encipherOnly&&(L|=1,I=0),d.decipherOnly&&(O|=128,I=7);var k=String.fromCharCode(I);O!==0?k+=String.fromCharCode(L)+String.fromCharCode(O):L!==0&&(k+=String.fromCharCode(L)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,k)}else if(d.name==="basicConstraints")d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),d.cA&&d.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ")),"pathLenConstraint"in d&&d.value.value.push(e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.pathLenConstraint).getBytes()));else if(d.name==="extKeyUsage"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=d.value.value;for(var H in d)d[H]===!0&&(H in o?F.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(o[H]).getBytes())):H.indexOf(".")!==-1&&F.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(H).getBytes())))}else if(d.name==="nsCertType"){var I=0,L=0;d.client&&(L|=128,I=7),d.server&&(L|=64,I=6),d.email&&(L|=32,I=5),d.objsign&&(L|=16,I=4),d.reserved&&(L|=8,I=3),d.sslCA&&(L|=4,I=2),d.emailCA&&(L|=2,I=1),d.objCA&&(L|=1,I=0);var k=String.fromCharCode(I);L!==0&&(k+=String.fromCharCode(L)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,k)}else if(d.name==="subjectAltName"||d.name==="issuerAltName"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var q,G=0;G<d.altNames.length;++G){q=d.altNames[G];var k=q.value;if(q.type===7&&q.ip){if(k=t.util.bytesFromIP(q.ip),k===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=d,n}}else q.type===8&&(q.oid?k=e.oidToDer(e.oidToDer(q.oid)):k=e.oidToDer(k));d.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,k))}}else if(d.name==="nsComment"&&i.cert){if(!/^[\x00-\x7F]*$/.test(d.comment)||d.comment.length<1||d.comment.length>128)throw new Error('Invalid "nsComment" content.');d.value=e.create(e.Class.UNIVERSAL,e.Type.IA5STRING,!1,d.comment)}else if(d.name==="subjectKeyIdentifier"&&i.cert){var Y=i.cert.generateSubjectKeyIdentifier();d.subjectKeyIdentifier=Y.toHex(),d.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,Y.getBytes())}else if(d.name==="authorityKeyIdentifier"&&i.cert){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var F=d.value.value;if(d.keyIdentifier){var X=d.keyIdentifier===!0?i.cert.generateSubjectKeyIdentifier().getBytes():d.keyIdentifier;F.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,X))}if(d.authorityCertIssuer){var te=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[m(d.authorityCertIssuer===!0?i.cert.issuer:d.authorityCertIssuer)])];F.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,te))}if(d.serialNumber){var ie=t.util.hexToBytes(d.serialNumber===!0?i.cert.serialNumber:d.serialNumber);F.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,ie))}}else if(d.name==="cRLDistributionPoints"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var F=d.value.value,se=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),ae=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),q,G=0;G<d.altNames.length;++G){q=d.altNames[G];var k=q.value;if(q.type===7&&q.ip){if(k=t.util.bytesFromIP(q.ip),k===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=d,n}}else q.type===8&&(q.oid?k=e.oidToDer(e.oidToDer(q.oid)):k=e.oidToDer(k));ae.value.push(e.create(e.Class.CONTEXT_SPECIFIC,q.type,!1,k))}se.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[ae])),F.push(se)}if(typeof d.value>"u"){var n=new Error("Extension value not specified.");throw n.extension=d,n}return d}function s(d,i){switch(d){case o["RSASSA-PSS"]:var n=[];return i.hash.algorithmOid!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])),i.mgf.algorithmOid!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(i.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])])),i.saltLength!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(i.saltLength).getBytes())])),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n);default:return e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")}}function h(d){var i=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(d.attributes.length===0)return i;for(var n=d.attributes,I=0;I<n.length;++I){var L=n[I],O=L.value,k=e.Type.UTF8;"valueTagClass"in L&&(k=L.valueTagClass),k===e.Type.UTF8&&(O=t.util.encodeUtf8(O));var F=!1;"valueConstructed"in L&&(F=L.valueConstructed);var H=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(L.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,k,F,O)])]);i.value.push(H)}return i}var v=new Date("1950-01-01T00:00:00Z"),A=new Date("2050-01-01T00:00:00Z");function _(d){return d>=v&&d<A?e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(d)):e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(d))}return r.getTBSCertificate=function(d){var i=_(d.validity.notBefore),n=_(d.validity.notAfter),I=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.version).getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(d.serialNumber)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.siginfo.algorithmOid).getBytes()),s(d.siginfo.algorithmOid,d.siginfo.parameters)]),m(d.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[i,n]),m(d.subject),r.publicKeyToAsn1(d.publicKey)]);return d.issuer.uniqueId&&I.value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.issuer.uniqueId)])),d.subject.uniqueId&&I.value.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.subject.uniqueId)])),d.extensions.length>0&&I.value.push(r.certificateExtensionsToAsn1(d.extensions)),I},r.getCertificationRequestInfo=function(d){var i=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.version).getBytes()),m(d.subject),r.publicKeyToAsn1(d.publicKey),h(d)]);return i},r.distinguishedNameToAsn1=function(d){return m(d)},r.certificateToAsn1=function(d){var i=d.tbsCertificate||r.getTBSCertificate(d);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[i,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.signatureOid).getBytes()),s(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.certificateExtensionsToAsn1=function(d){var i=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);i.value.push(n);for(var I=0;I<d.length;++I)n.value.push(r.certificateExtensionToAsn1(d[I]));return i},r.certificateExtensionToAsn1=function(d){var i=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);i.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.id).getBytes())),d.critical&&i.value.push(e.create(e.Class.UNIVERSAL,e.Type.BOOLEAN,!1,"ÿ"));var n=d.value;return typeof d.value!="string"&&(n=e.toDer(n).getBytes()),i.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n)),i},r.certificationRequestToAsn1=function(d){var i=d.certificationRequestInfo||r.getCertificationRequestInfo(d);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[i,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.signatureOid).getBytes()),s(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.createCaStore=function(d){var i={certs:{}};i.getIssuer=function(k){var F=n(k.issuer);return F},i.addCertificate=function(k){if(typeof k=="string"&&(k=t.pki.certificateFromPem(k)),I(k.subject),!i.hasCertificate(k))if(k.subject.hash in i.certs){var F=i.certs[k.subject.hash];t.util.isArray(F)||(F=[F]),F.push(k),i.certs[k.subject.hash]=F}else i.certs[k.subject.hash]=k},i.hasCertificate=function(k){typeof k=="string"&&(k=t.pki.certificateFromPem(k));var F=n(k.subject);if(!F)return!1;t.util.isArray(F)||(F=[F]);for(var H=e.toDer(r.certificateToAsn1(k)).getBytes(),q=0;q<F.length;++q){var G=e.toDer(r.certificateToAsn1(F[q])).getBytes();if(H===G)return!0}return!1},i.listAllCertificates=function(){var k=[];for(var F in i.certs)if(i.certs.hasOwnProperty(F)){var H=i.certs[F];if(!t.util.isArray(H))k.push(H);else for(var q=0;q<H.length;++q)k.push(H[q])}return k},i.removeCertificate=function(k){var F;if(typeof k=="string"&&(k=t.pki.certificateFromPem(k)),I(k.subject),!i.hasCertificate(k))return null;var H=n(k.subject);if(!t.util.isArray(H))return F=i.certs[k.subject.hash],delete i.certs[k.subject.hash],F;for(var q=e.toDer(r.certificateToAsn1(k)).getBytes(),G=0;G<H.length;++G){var Y=e.toDer(r.certificateToAsn1(H[G])).getBytes();q===Y&&(F=H[G],H.splice(G,1))}return H.length===0&&delete i.certs[k.subject.hash],F};function n(k){return I(k),i.certs[k.hash]||null}function I(k){if(!k.hash){var F=t.md.sha1.create();k.attributes=r.RDNAttributesAsArray(m(k),F),k.hash=F.digest().toHex()}}if(d)for(var L=0;L<d.length;++L){var O=d[L];i.addCertificate(O)}return i},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(d,i,n){typeof n=="function"&&(n={verify:n}),n=n||{},i=i.slice(0);var I=i.slice(0),L=n.validityCheckDate;typeof L>"u"&&(L=new Date);var O=!0,k=null,F=0;do{var H=i.shift(),q=null,G=!1;if(L&&(L<H.validity.notBefore||L>H.validity.notAfter)&&(k={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:H.validity.notBefore,notAfter:H.validity.notAfter,now:L}),k===null){if(q=i[0]||d.getIssuer(H),q===null&&H.isIssuer(H)&&(G=!0,q=H),q){var Y=q;t.util.isArray(Y)||(Y=[Y]);for(var X=!1;!X&&Y.length>0;){q=Y.shift();try{X=q.verify(H)}catch{}}X||(k={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}k===null&&(!q||G)&&!d.hasCertificate(H)&&(k={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(k===null&&q&&!H.isIssuer(q)&&(k={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),k===null)for(var te={keyUsage:!0,basicConstraints:!0},ie=0;k===null&&ie<H.extensions.length;++ie){var se=H.extensions[ie];se.critical&&!(se.name in te)&&(k={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(k===null&&(!O||i.length===0&&(!q||G))){var ae=H.getExtension("basicConstraints"),ue=H.getExtension("keyUsage");if(ue!==null&&(!ue.keyCertSign||ae===null)&&(k={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:r.certificateError.bad_certificate}),k===null&&ae===null&&(k={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:r.certificateError.bad_certificate}),k===null&&ae!==null&&!ae.cA&&(k={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),k===null&&ue!==null&&"pathLenConstraint"in ae){var ce=F-1;ce>ae.pathLenConstraint&&(k={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}}var $=k===null?!0:k.error,J=n.verify?n.verify($,F,I):$;if(J===!0)k=null;else throw $===!0&&(k={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(J||J===0)&&(typeof J=="object"&&!t.util.isArray(J)?(J.message&&(k.message=J.message),J.error&&(k.error=J.error)):typeof J=="string"&&(k.error=J)),k;O=!1,++F}while(i.length>0);return!0},Nr.exports}var za;function Vn(){if(za)return Br.exports;za=1;var t=le();ot(),Ut(),bt(),kn(),Un(),it(),Zt(),kt(),pe(),sa();var e=t.asn1,r=t.pki,o=Br.exports=t.pkcs12=t.pkcs12||{},p={name:"ContentInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},y={name:"PFX",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"version"},p,{name:"PFX.macData",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",optional:!0,tagClass:e.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},f={name:"SafeBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},a={name:"Attribute",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:e.Class.UNIVERSAL,type:e.Type.SET,constructed:!0,capture:"values"}]},g={name:"CertBag",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:e.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:e.Class.UNIVERSAL,type:e.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function l(E,C,s,h){for(var v=[],A=0;A<E.length;A++)for(var _=0;_<E[A].safeBags.length;_++){var d=E[A].safeBags[_];if(!(h!==void 0&&d.type!==h)){if(C===null){v.push(d);continue}d.attributes[C]!==void 0&&d.attributes[C].indexOf(s)>=0&&v.push(d)}}return v}o.pkcs12FromAsn1=function(E,C,s){typeof C=="string"?(s=C,C=!0):C===void 0&&(C=!0);var h={},v=[];if(!e.validate(E,y,h,v)){var A=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw A.errors=A,A}var _={version:h.version.charCodeAt(0),safeContents:[],getBags:function(q){var G={},Y;return"localKeyId"in q?Y=q.localKeyId:"localKeyIdHex"in q&&(Y=t.util.hexToBytes(q.localKeyIdHex)),Y===void 0&&!("friendlyName"in q)&&"bagType"in q&&(G[q.bagType]=l(_.safeContents,null,null,q.bagType)),Y!==void 0&&(G.localKeyId=l(_.safeContents,"localKeyId",Y,q.bagType)),"friendlyName"in q&&(G.friendlyName=l(_.safeContents,"friendlyName",q.friendlyName,q.bagType)),G},getBagsByFriendlyName:function(q,G){return l(_.safeContents,"friendlyName",q,G)},getBagsByLocalKeyId:function(q,G){return l(_.safeContents,"localKeyId",q,G)}};if(h.version.charCodeAt(0)!==3){var A=new Error("PKCS#12 PFX of version other than 3 not supported.");throw A.version=h.version.charCodeAt(0),A}if(e.derToOid(h.contentType)!==r.oids.data){var A=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw A.oid=e.derToOid(h.contentType),A}var d=h.content.value[0];if(d.tagClass!==e.Class.UNIVERSAL||d.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(d=b(d),h.mac){var i=null,n=0,I=e.derToOid(h.macAlgorithm);switch(I){case r.oids.sha1:i=t.md.sha1.create(),n=20;break;case r.oids.sha256:i=t.md.sha256.create(),n=32;break;case r.oids.sha384:i=t.md.sha384.create(),n=48;break;case r.oids.sha512:i=t.md.sha512.create(),n=64;break;case r.oids.md5:i=t.md.md5.create(),n=16;break}if(i===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+I);var L=new t.util.ByteBuffer(h.macSalt),O="macIterations"in h?parseInt(t.util.bytesToHex(h.macIterations),16):1,k=o.generateKey(s,L,3,O,n,i),F=t.hmac.create();F.start(i,k),F.update(d.value);var H=F.getMac();if(H.getBytes()!==h.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(E.value)&&E.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return U(_,d.value,C,s),_};function b(E){if(E.composed||E.constructed){for(var C=t.util.createBuffer(),s=0;s<E.value.length;++s)C.putBytes(E.value[s].value);E.composed=E.constructed=!1,E.value=C.getBytes()}return E}function U(E,C,s,h){if(C=e.fromDer(C,s),C.tagClass!==e.Class.UNIVERSAL||C.type!==e.Type.SEQUENCE||C.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var v=0;v<C.value.length;v++){var A=C.value[v],_={},d=[];if(!e.validate(A,p,_,d)){var i=new Error("Cannot read ContentInfo.");throw i.errors=d,i}var n={encrypted:!1},I=null,L=_.content.value[0];switch(e.derToOid(_.contentType)){case r.oids.data:if(L.tagClass!==e.Class.UNIVERSAL||L.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");I=b(L).value;break;case r.oids.encryptedData:I=S(L,h),n.encrypted=!0;break;default:var i=new Error("Unsupported PKCS#12 contentType.");throw i.contentType=e.derToOid(_.contentType),i}n.safeBags=c(I,s,h),E.safeContents.push(n)}}function S(E,C){var s={},h=[];if(!e.validate(E,t.pkcs7.asn1.encryptedDataValidator,s,h)){var v=new Error("Cannot read EncryptedContentInfo.");throw v.errors=h,v}var A=e.derToOid(s.contentType);if(A!==r.oids.data){var v=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw v.oid=A,v}A=e.derToOid(s.encAlgorithm);var _=r.pbe.getCipher(A,s.encParameter,C),d=b(s.encryptedContentAsn1),i=t.util.createBuffer(d.value);if(_.update(i),!_.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return _.output.getBytes()}function c(E,C,s){if(!C&&E.length===0)return[];if(E=e.fromDer(E,C),E.tagClass!==e.Class.UNIVERSAL||E.type!==e.Type.SEQUENCE||E.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var h=[],v=0;v<E.value.length;v++){var A=E.value[v],_={},d=[];if(!e.validate(A,f,_,d)){var i=new Error("Cannot read SafeBag.");throw i.errors=d,i}var n={type:e.derToOid(_.bagId),attributes:m(_.bagAttributes)};h.push(n);var I,L,O=_.bagValue.value[0];switch(n.type){case r.oids.pkcs8ShroudedKeyBag:if(O=r.decryptPrivateKeyInfo(O,s),O===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{n.key=r.privateKeyFromAsn1(O)}catch{n.key=null,n.asn1=O}continue;case r.oids.certBag:I=g,L=function(){if(e.derToOid(_.certId)!==r.oids.x509Certificate){var F=new Error("Unsupported certificate type, only X.509 supported.");throw F.oid=e.derToOid(_.certId),F}var H=e.fromDer(_.cert,C);try{n.cert=r.certificateFromAsn1(H,!0)}catch{n.cert=null,n.asn1=H}};break;default:var i=new Error("Unsupported PKCS#12 SafeBag type.");throw i.oid=n.type,i}if(I!==void 0&&!e.validate(O,I,_,d)){var i=new Error("Cannot read PKCS#12 "+I.name);throw i.errors=d,i}L()}return h}function m(E){var C={};if(E!==void 0)for(var s=0;s<E.length;++s){var h={},v=[];if(!e.validate(E[s],a,h,v)){var A=new Error("Cannot read PKCS#12 BagAttribute.");throw A.errors=v,A}var _=e.derToOid(h.oid);if(r.oids[_]!==void 0){C[r.oids[_]]=[];for(var d=0;d<h.values.length;++d)C[r.oids[_]].push(h.values[d].value)}}return C}return o.toPkcs12Asn1=function(E,C,s,h){h=h||{},h.saltSize=h.saltSize||8,h.count=h.count||2048,h.algorithm=h.algorithm||h.encAlgorithm||"aes128","useMac"in h||(h.useMac=!0),"localKeyId"in h||(h.localKeyId=null),"generateLocalKeyId"in h||(h.generateLocalKeyId=!0);var v=h.localKeyId,A;if(v!==null)v=t.util.hexToBytes(v);else if(h.generateLocalKeyId)if(C){var _=t.util.isArray(C)?C[0]:C;typeof _=="string"&&(_=r.certificateFromPem(_));var d=t.md.sha1.create();d.update(e.toDer(r.certificateToAsn1(_)).getBytes()),v=d.digest().getBytes()}else v=t.random.getBytes(20);var i=[];v!==null&&i.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.localKeyId).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,v)])])),"friendlyName"in h&&i.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.friendlyName).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,e.Type.BMPSTRING,!1,h.friendlyName)])])),i.length>0&&(A=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,i));var n=[],I=[];C!==null&&(t.util.isArray(C)?I=C:I=[C]);for(var L=[],O=0;O<I.length;++O){C=I[O],typeof C=="string"&&(C=r.certificateFromPem(C));var k=O===0?A:void 0,F=r.certificateToAsn1(C),H=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.certBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.x509Certificate).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(F).getBytes())])])]),k]);L.push(H)}if(L.length>0){var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,L),G=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(q).getBytes())])]);n.push(G)}var Y=null;if(E!==null){var X=r.wrapRsaPrivateKey(r.privateKeyToAsn1(E));s===null?Y=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.keyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[X]),A]):Y=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(X,s,h)]),A]);var te=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[Y]),ie=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(te).getBytes())])]);n.push(ie)}var se=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n),ae;if(h.useMac){var d=t.md.sha1.create(),ue=new t.util.ByteBuffer(t.random.getBytes(h.saltSize)),ce=h.count,E=o.generateKey(s,ue,3,ce,20),$=t.hmac.create();$.start(d,E),$.update(e.toDer(se).getBytes());var J=$.getMac();ae=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.sha1).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,J.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ue.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(ce).getBytes())])}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(3).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(r.oids.data).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,e.toDer(se).getBytes())])]),ae])},o.generateKey=t.pbe.generatePkcs12Key,Br.exports}var Qa;function On(){if(Qa)return yr.exports;Qa=1;var t=le();ot(),bt(),Un(),Nt(),na(),Vn(),ia(),Zt(),pe(),sa();var e=t.asn1,r=yr.exports=t.pki=t.pki||{};return r.pemToDer=function(o){var p=t.pem.decode(o)[0];if(p.procType&&p.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(p.body)},r.privateKeyFromPem=function(o){var p=t.pem.decode(o)[0];if(p.type!=="PRIVATE KEY"&&p.type!=="RSA PRIVATE KEY"){var y=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw y.headerType=p.type,y}if(p.procType&&p.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var f=e.fromDer(p.body);return r.privateKeyFromAsn1(f)},r.privateKeyToPem=function(o,p){var y={type:"RSA PRIVATE KEY",body:e.toDer(r.privateKeyToAsn1(o)).getBytes()};return t.pem.encode(y,{maxline:p})},r.privateKeyInfoToPem=function(o,p){var y={type:"PRIVATE KEY",body:e.toDer(o).getBytes()};return t.pem.encode(y,{maxline:p})},yr.exports}var Lr,Ya;function Fn(){if(Ya)return Lr;Ya=1;var t=le();ot(),Ut(),ra(),Nt(),On(),it(),kt(),pe();var e=function(x,D,R,N){var u=t.util.createBuffer(),w=x.length>>1,V=w+(x.length&1),K=x.substr(0,V),j=x.substr(w,V),Z=t.util.createBuffer(),z=t.hmac.create();R=D+R;var ee=Math.ceil(N/16),oe=Math.ceil(N/20);z.start("MD5",K);var de=t.util.createBuffer();Z.putBytes(R);for(var fe=0;fe<ee;++fe)z.start(null,null),z.update(Z.getBytes()),Z.putBuffer(z.digest()),z.start(null,null),z.update(Z.bytes()+R),de.putBuffer(z.digest());z.start("SHA1",j);var Ee=t.util.createBuffer();Z.clear(),Z.putBytes(R);for(var fe=0;fe<oe;++fe)z.start(null,null),z.update(Z.getBytes()),Z.putBuffer(z.digest()),z.start(null,null),z.update(Z.bytes()+R),Ee.putBuffer(z.digest());return u.putBytes(t.util.xorBytes(de.getBytes(),Ee.getBytes(),N)),u},r=function(x,D,R){var N=t.hmac.create();N.start("SHA1",x);var u=t.util.createBuffer();return u.putInt32(D[0]),u.putInt32(D[1]),u.putByte(R.type),u.putByte(R.version.major),u.putByte(R.version.minor),u.putInt16(R.length),u.putBytes(R.fragment.bytes()),N.update(u.getBytes()),N.digest().getBytes()},o=function(x,D,R){var N=!1;try{var u=x.deflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(u),D.length=u.length,N=!0}catch{}return N},p=function(x,D,R){var N=!1;try{var u=x.inflate(D.fragment.getBytes());D.fragment=t.util.createBuffer(u),D.length=u.length,N=!0}catch{}return N},y=function(x,D){var R=0;switch(D){case 1:R=x.getByte();break;case 2:R=x.getInt16();break;case 3:R=x.getInt24();break;case 4:R=x.getInt32();break}return t.util.createBuffer(x.getBytes(R))},f=function(x,D,R){x.putInt(R.length(),D<<3),x.putBuffer(R)},a={};a.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},a.SupportedVersions=[a.Versions.TLS_1_1,a.Versions.TLS_1_0],a.Version=a.SupportedVersions[0],a.MaxFragment=15360,a.ConnectionEnd={server:0,client:1},a.PRFAlgorithm={tls_prf_sha256:0},a.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},a.CipherType={stream:0,block:1,aead:2},a.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},a.CompressionMethod={none:0,deflate:1},a.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},a.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},a.Alert={},a.Alert.Level={warning:1,fatal:2},a.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},a.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},a.CipherSuites={},a.getCipherSuite=function(x){var D=null;for(var R in a.CipherSuites){var N=a.CipherSuites[R];if(N.id[0]===x.charCodeAt(0)&&N.id[1]===x.charCodeAt(1)){D=N;break}}return D},a.handleUnexpected=function(x,D){var R=!x.open&&x.entity===a.ConnectionEnd.client;R||x.error(x,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unexpected_message}})},a.handleHelloRequest=function(x,D,R){!x.handshaking&&x.handshakes>0&&(a.queue(x,a.createAlert(x,{level:a.Alert.Level.warning,description:a.Alert.Description.no_renegotiation})),a.flush(x)),x.process()},a.parseHelloMessage=function(x,D,R){var N=null,u=x.entity===a.ConnectionEnd.client;if(R<38)x.error(x,{message:u?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});else{var w=D.fragment,V=w.length();if(N={version:{major:w.getByte(),minor:w.getByte()},random:t.util.createBuffer(w.getBytes(32)),session_id:y(w,1),extensions:[]},u?(N.cipher_suite=w.getBytes(2),N.compression_method=w.getByte()):(N.cipher_suites=y(w,2),N.compression_methods=y(w,1)),V=R-(V-w.length()),V>0){for(var K=y(w,2);K.length()>0;)N.extensions.push({type:[K.getByte(),K.getByte()],data:y(K,2)});if(!u)for(var j=0;j<N.extensions.length;++j){var Z=N.extensions[j];if(Z.type[0]===0&&Z.type[1]===0)for(var z=y(Z.data,2);z.length()>0;){var ee=z.getByte();if(ee!==0)break;x.session.extensions.server_name.serverNameList.push(y(z,2).getBytes())}}}if(x.session.version&&(N.version.major!==x.session.version.major||N.version.minor!==x.session.version.minor))return x.error(x,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});if(u)x.session.cipherSuite=a.getCipherSuite(N.cipher_suite);else for(var oe=t.util.createBuffer(N.cipher_suites.bytes());oe.length()>0&&(x.session.cipherSuite=a.getCipherSuite(oe.getBytes(2)),x.session.cipherSuite===null););if(x.session.cipherSuite===null)return x.error(x,{message:"No cipher suites in common.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure},cipherSuite:t.util.bytesToHex(N.cipher_suite)});u?x.session.compressionMethod=N.compression_method:x.session.compressionMethod=a.CompressionMethod.none}return N},a.createSecurityParameters=function(x,D){var R=x.entity===a.ConnectionEnd.client,N=D.random.bytes(),u=R?x.session.sp.client_random:N,w=R?N:a.createRandom().getBytes();x.session.sp={entity:x.entity,prf_algorithm:a.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:x.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:u,server_random:w}},a.handleServerHello=function(x,D,R){var N=a.parseHelloMessage(x,D,R);if(!x.fail){if(N.version.minor<=x.version.minor)x.version.minor=N.version.minor;else return x.error(x,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});x.session.version=x.version;var u=N.session_id.bytes();u.length>0&&u===x.session.id?(x.expect=c,x.session.resuming=!0,x.session.sp.server_random=N.random.bytes()):(x.expect=l,x.session.resuming=!1,a.createSecurityParameters(x,N)),x.session.id=u,x.process()}},a.handleClientHello=function(x,D,R){var N=a.parseHelloMessage(x,D,R);if(!x.fail){var u=N.session_id.bytes(),w=null;if(x.sessionCache&&(w=x.sessionCache.getSession(u),w===null?u="":(w.version.major!==N.version.major||w.version.minor>N.version.minor)&&(w=null,u="")),u.length===0&&(u=t.random.getBytes(32)),x.session.id=u,x.session.clientHelloVersion=N.version,x.session.sp={},w)x.version=x.session.version=w.version,x.session.sp=w.sp;else{for(var V,K=1;K<a.SupportedVersions.length&&(V=a.SupportedVersions[K],!(V.minor<=N.version.minor));++K);x.version={major:V.major,minor:V.minor},x.session.version=x.version}w!==null?(x.expect=_,x.session.resuming=!0,x.session.sp.client_random=N.random.bytes()):(x.expect=x.verifyClient!==!1?h:v,x.session.resuming=!1,a.createSecurityParameters(x,N)),x.open=!0,a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createServerHello(x)})),x.session.resuming?(a.queue(x,a.createRecord(x,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),x.state.pending=a.createConnectionState(x),x.state.current.write=x.state.pending.write,a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createFinished(x)}))):(a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createCertificate(x)})),x.fail||(a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createServerKeyExchange(x)})),x.verifyClient!==!1&&a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createCertificateRequest(x)})),a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createServerHelloDone(x)})))),a.flush(x),x.process()}},a.handleCertificate=function(x,D,R){if(R<3)return x.error(x,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment,u={certificate_list:y(N,3)},w,V,K=[];try{for(;u.certificate_list.length()>0;)w=y(u.certificate_list,3),V=t.asn1.fromDer(w),w=t.pki.certificateFromAsn1(V,!0),K.push(w)}catch(Z){return x.error(x,{message:"Could not parse certificate list.",cause:Z,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var j=x.entity===a.ConnectionEnd.client;(j||x.verifyClient===!0)&&K.length===0?x.error(x,{message:j?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}}):K.length===0?x.expect=j?b:v:(j?x.session.serverCertificate=K[0]:x.session.clientCertificate=K[0],a.verifyCertificateChain(x,K)&&(x.expect=j?b:v)),x.process()},a.handleServerKeyExchange=function(x,D,R){if(R>0)return x.error(x,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});x.expect=U,x.process()},a.handleClientKeyExchange=function(x,D,R){if(R<48)return x.error(x,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});var N=D.fragment,u={enc_pre_master_secret:y(N,2).getBytes()},w=null;if(x.getPrivateKey)try{w=x.getPrivateKey(x,x.session.serverCertificate),w=t.pki.privateKeyFromPem(w)}catch(j){x.error(x,{message:"Could not get private key.",cause:j,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}if(w===null)return x.error(x,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}});try{var V=x.session.sp;V.pre_master_secret=w.decrypt(u.enc_pre_master_secret);var K=x.session.clientHelloVersion;if(K.major!==V.pre_master_secret.charCodeAt(0)||K.minor!==V.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{V.pre_master_secret=t.random.getBytes(48)}x.expect=_,x.session.clientCertificate!==null&&(x.expect=A),x.process()},a.handleCertificateRequest=function(x,D,R){if(R<3)return x.error(x,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment,u={certificate_types:y(N,1),certificate_authorities:y(N,2)};x.session.certificateRequest=u,x.expect=S,x.process()},a.handleCertificateVerify=function(x,D,R){if(R<2)return x.error(x,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var N=D.fragment;N.read-=4;var u=N.bytes();N.read+=4;var w={signature:y(N,2).getBytes()},V=t.util.createBuffer();V.putBuffer(x.session.md5.digest()),V.putBuffer(x.session.sha1.digest()),V=V.getBytes();try{var K=x.session.clientCertificate;if(!K.publicKey.verify(V,w.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");x.session.md5.update(u),x.session.sha1.update(u)}catch{return x.error(x,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure}})}x.expect=_,x.process()},a.handleServerHelloDone=function(x,D,R){if(R>0)return x.error(x,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.record_overflow}});if(x.serverCertificate===null){var N={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.insufficient_security}},u=0,w=x.verify(x,N.alert.description,u,[]);if(w!==!0)return(w||w===0)&&(typeof w=="object"&&!t.util.isArray(w)?(w.message&&(N.message=w.message),w.alert&&(N.alert.description=w.alert)):typeof w=="number"&&(N.alert.description=w)),x.error(x,N)}x.session.certificateRequest!==null&&(D=a.createRecord(x,{type:a.ContentType.handshake,data:a.createCertificate(x)}),a.queue(x,D)),D=a.createRecord(x,{type:a.ContentType.handshake,data:a.createClientKeyExchange(x)}),a.queue(x,D),x.expect=C;var V=function(K,j){K.session.certificateRequest!==null&&K.session.clientCertificate!==null&&a.queue(K,a.createRecord(K,{type:a.ContentType.handshake,data:a.createCertificateVerify(K,j)})),a.queue(K,a.createRecord(K,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),K.state.pending=a.createConnectionState(K),K.state.current.write=K.state.pending.write,a.queue(K,a.createRecord(K,{type:a.ContentType.handshake,data:a.createFinished(K)})),K.expect=c,a.flush(K),K.process()};if(x.session.certificateRequest===null||x.session.clientCertificate===null)return V(x,null);a.getClientSignature(x,V)},a.handleChangeCipherSpec=function(x,D){if(D.fragment.getByte()!==1)return x.error(x,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var R=x.entity===a.ConnectionEnd.client;(x.session.resuming&&R||!x.session.resuming&&!R)&&(x.state.pending=a.createConnectionState(x)),x.state.current.read=x.state.pending.read,(!x.session.resuming&&R||x.session.resuming&&!R)&&(x.state.pending=null),x.expect=R?m:d,x.process()},a.handleFinished=function(x,D,R){var N=D.fragment;N.read-=4;var u=N.bytes();N.read+=4;var w=D.fragment.getBytes();N=t.util.createBuffer(),N.putBuffer(x.session.md5.digest()),N.putBuffer(x.session.sha1.digest());var V=x.entity===a.ConnectionEnd.client,K=V?"server finished":"client finished",j=x.session.sp,Z=12,z=e;if(N=z(j.master_secret,K,N.getBytes(),Z),N.getBytes()!==w)return x.error(x,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decrypt_error}});x.session.md5.update(u),x.session.sha1.update(u),(x.session.resuming&&V||!x.session.resuming&&!V)&&(a.queue(x,a.createRecord(x,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),x.state.current.write=x.state.pending.write,x.state.pending=null,a.queue(x,a.createRecord(x,{type:a.ContentType.handshake,data:a.createFinished(x)}))),x.expect=V?E:i,x.handshaking=!1,++x.handshakes,x.peerCertificate=V?x.session.serverCertificate:x.session.clientCertificate,a.flush(x),x.isConnected=!0,x.connected(x),x.process()},a.handleAlert=function(x,D){var R=D.fragment,N={level:R.getByte(),description:R.getByte()},u;switch(N.description){case a.Alert.Description.close_notify:u="Connection closed.";break;case a.Alert.Description.unexpected_message:u="Unexpected message.";break;case a.Alert.Description.bad_record_mac:u="Bad record MAC.";break;case a.Alert.Description.decryption_failed:u="Decryption failed.";break;case a.Alert.Description.record_overflow:u="Record overflow.";break;case a.Alert.Description.decompression_failure:u="Decompression failed.";break;case a.Alert.Description.handshake_failure:u="Handshake failure.";break;case a.Alert.Description.bad_certificate:u="Bad certificate.";break;case a.Alert.Description.unsupported_certificate:u="Unsupported certificate.";break;case a.Alert.Description.certificate_revoked:u="Certificate revoked.";break;case a.Alert.Description.certificate_expired:u="Certificate expired.";break;case a.Alert.Description.certificate_unknown:u="Certificate unknown.";break;case a.Alert.Description.illegal_parameter:u="Illegal parameter.";break;case a.Alert.Description.unknown_ca:u="Unknown certificate authority.";break;case a.Alert.Description.access_denied:u="Access denied.";break;case a.Alert.Description.decode_error:u="Decode error.";break;case a.Alert.Description.decrypt_error:u="Decrypt error.";break;case a.Alert.Description.export_restriction:u="Export restriction.";break;case a.Alert.Description.protocol_version:u="Unsupported protocol version.";break;case a.Alert.Description.insufficient_security:u="Insufficient security.";break;case a.Alert.Description.internal_error:u="Internal error.";break;case a.Alert.Description.user_canceled:u="User canceled.";break;case a.Alert.Description.no_renegotiation:u="Renegotiation not supported.";break;default:u="Unknown error.";break}if(N.description===a.Alert.Description.close_notify)return x.close();x.error(x,{message:u,send:!1,origin:x.entity===a.ConnectionEnd.client?"server":"client",alert:N}),x.process()},a.handleHandshake=function(x,D){var R=D.fragment,N=R.getByte(),u=R.getInt24();if(u>R.length())return x.fragmented=D,D.fragment=t.util.createBuffer(),R.read-=4,x.process();x.fragmented=null,R.read-=4;var w=R.bytes(u+4);R.read+=4,N in ae[x.entity][x.expect]?(x.entity===a.ConnectionEnd.server&&!x.open&&!x.fail&&(x.handshaking=!0,x.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:t.md.md5.create(),sha1:t.md.sha1.create()}),N!==a.HandshakeType.hello_request&&N!==a.HandshakeType.certificate_verify&&N!==a.HandshakeType.finished&&(x.session.md5.update(w),x.session.sha1.update(w)),ae[x.entity][x.expect][N](x,D,u)):a.handleUnexpected(x,D)},a.handleApplicationData=function(x,D){x.data.putBuffer(D.fragment),x.dataReady(x),x.process()},a.handleHeartbeat=function(x,D){var R=D.fragment,N=R.getByte(),u=R.getInt16(),w=R.getBytes(u);if(N===a.HeartbeatMessageType.heartbeat_request){if(x.handshaking||u>w.length)return x.process();a.queue(x,a.createRecord(x,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_response,w)})),a.flush(x)}else if(N===a.HeartbeatMessageType.heartbeat_response){if(w!==x.expectedHeartbeatPayload)return x.process();x.heartbeatReceived&&x.heartbeatReceived(x,t.util.createBuffer(w))}x.process()};var g=0,l=1,b=2,U=3,S=4,c=5,m=6,E=7,C=8,s=0,h=1,v=2,A=3,_=4,d=5,i=6,n=a.handleUnexpected,I=a.handleChangeCipherSpec,L=a.handleAlert,O=a.handleHandshake,k=a.handleApplicationData,F=a.handleHeartbeat,H=[];H[a.ConnectionEnd.client]=[[n,L,O,n,F],[n,L,O,n,F],[n,L,O,n,F],[n,L,O,n,F],[n,L,O,n,F],[I,L,n,n,F],[n,L,O,n,F],[n,L,O,k,F],[n,L,O,n,F]],H[a.ConnectionEnd.server]=[[n,L,O,n,F],[n,L,O,n,F],[n,L,O,n,F],[n,L,O,n,F],[I,L,n,n,F],[n,L,O,n,F],[n,L,O,k,F],[n,L,O,n,F]];var q=a.handleHelloRequest,G=a.handleServerHello,Y=a.handleCertificate,X=a.handleServerKeyExchange,te=a.handleCertificateRequest,ie=a.handleServerHelloDone,se=a.handleFinished,ae=[];ae[a.ConnectionEnd.client]=[[n,n,G,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,Y,X,te,ie,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,X,te,ie,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,n,te,ie,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,n,n,ie,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,se],[q,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[q,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n]];var ue=a.handleClientHello,ce=a.handleClientKeyExchange,$=a.handleCertificateVerify;ae[a.ConnectionEnd.server]=[[n,ue,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,Y,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,ce,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,$,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,se],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n]],a.generateKeys=function(x,D){var R=e,N=D.client_random+D.server_random;x.session.resuming||(D.master_secret=R(D.pre_master_secret,"master secret",N,48).bytes(),D.pre_master_secret=null),N=D.server_random+D.client_random;var u=2*D.mac_key_length+2*D.enc_key_length,w=x.version.major===a.Versions.TLS_1_0.major&&x.version.minor===a.Versions.TLS_1_0.minor;w&&(u+=2*D.fixed_iv_length);var V=R(D.master_secret,"key expansion",N,u),K={client_write_MAC_key:V.getBytes(D.mac_key_length),server_write_MAC_key:V.getBytes(D.mac_key_length),client_write_key:V.getBytes(D.enc_key_length),server_write_key:V.getBytes(D.enc_key_length)};return w&&(K.client_write_IV=V.getBytes(D.fixed_iv_length),K.server_write_IV=V.getBytes(D.fixed_iv_length)),K},a.createConnectionState=function(x){var D=x.entity===a.ConnectionEnd.client,R=function(){var w={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(V){return!0},compressionState:null,compressFunction:function(V){return!0},updateSequenceNumber:function(){w.sequenceNumber[1]===4294967295?(w.sequenceNumber[1]=0,++w.sequenceNumber[0]):++w.sequenceNumber[1]}};return w},N={read:R(),write:R()};if(N.read.update=function(w,V){return N.read.cipherFunction(V,N.read)?N.read.compressFunction(w,V,N.read)||w.error(w,{message:"Could not decompress record.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decompression_failure}}):w.error(w,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_record_mac}}),!w.fail},N.write.update=function(w,V){return N.write.compressFunction(w,V,N.write)?N.write.cipherFunction(V,N.write)||w.error(w,{message:"Could not encrypt record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):w.error(w,{message:"Could not compress record.",send:!1,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}),!w.fail},x.session){var u=x.session.sp;switch(x.session.cipherSuite.initSecurityParameters(u),u.keys=a.generateKeys(x,u),N.read.macKey=D?u.keys.server_write_MAC_key:u.keys.client_write_MAC_key,N.write.macKey=D?u.keys.client_write_MAC_key:u.keys.server_write_MAC_key,x.session.cipherSuite.initConnectionState(N,x,u),u.compression_algorithm){case a.CompressionMethod.none:break;case a.CompressionMethod.deflate:N.read.compressFunction=p,N.write.compressFunction=o;break;default:throw new Error("Unsupported compression algorithm.")}}return N},a.createRandom=function(){var x=new Date,D=+x+x.getTimezoneOffset()*6e4,R=t.util.createBuffer();return R.putInt32(D),R.putBytes(t.random.getBytes(28)),R},a.createRecord=function(x,D){if(!D.data)return null;var R={type:D.type,version:{major:x.version.major,minor:x.version.minor},length:D.data.length(),fragment:D.data};return R},a.createAlert=function(x,D){var R=t.util.createBuffer();return R.putByte(D.level),R.putByte(D.description),a.createRecord(x,{type:a.ContentType.alert,data:R})},a.createClientHello=function(x){x.session.clientHelloVersion={major:x.version.major,minor:x.version.minor};for(var D=t.util.createBuffer(),R=0;R<x.cipherSuites.length;++R){var N=x.cipherSuites[R];D.putByte(N.id[0]),D.putByte(N.id[1])}var u=D.length(),w=t.util.createBuffer();w.putByte(a.CompressionMethod.none);var V=w.length(),K=t.util.createBuffer();if(x.virtualHost){var j=t.util.createBuffer();j.putByte(0),j.putByte(0);var Z=t.util.createBuffer();Z.putByte(0),f(Z,2,t.util.createBuffer(x.virtualHost));var z=t.util.createBuffer();f(z,2,Z),f(j,2,z),K.putBuffer(j)}var ee=K.length();ee>0&&(ee+=2);var oe=x.session.id,de=oe.length+1+2+4+28+2+u+1+V+ee,fe=t.util.createBuffer();return fe.putByte(a.HandshakeType.client_hello),fe.putInt24(de),fe.putByte(x.version.major),fe.putByte(x.version.minor),fe.putBytes(x.session.sp.client_random),f(fe,1,t.util.createBuffer(oe)),f(fe,2,D),f(fe,1,w),ee>0&&f(fe,2,K),fe},a.createServerHello=function(x){var D=x.session.id,R=D.length+1+2+4+28+2+1,N=t.util.createBuffer();return N.putByte(a.HandshakeType.server_hello),N.putInt24(R),N.putByte(x.version.major),N.putByte(x.version.minor),N.putBytes(x.session.sp.server_random),f(N,1,t.util.createBuffer(D)),N.putByte(x.session.cipherSuite.id[0]),N.putByte(x.session.cipherSuite.id[1]),N.putByte(x.session.compressionMethod),N},a.createCertificate=function(x){var D=x.entity===a.ConnectionEnd.client,R=null;if(x.getCertificate){var N;D?N=x.session.certificateRequest:N=x.session.extensions.server_name.serverNameList,R=x.getCertificate(x,N)}var u=t.util.createBuffer();if(R!==null)try{t.util.isArray(R)||(R=[R]);for(var w=null,V=0;V<R.length;++V){var K=t.pem.decode(R[V])[0];if(K.type!=="CERTIFICATE"&&K.type!=="X509 CERTIFICATE"&&K.type!=="TRUSTED CERTIFICATE"){var j=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw j.headerType=K.type,j}if(K.procType&&K.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var Z=t.util.createBuffer(K.body);w===null&&(w=t.asn1.fromDer(Z.bytes(),!1));var z=t.util.createBuffer();f(z,3,Z),u.putBuffer(z)}R=t.pki.certificateFromAsn1(w),D?x.session.clientCertificate=R:x.session.serverCertificate=R}catch(de){return x.error(x,{message:"Could not send certificate list.",cause:de,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var ee=3+u.length(),oe=t.util.createBuffer();return oe.putByte(a.HandshakeType.certificate),oe.putInt24(ee),f(oe,3,u),oe},a.createClientKeyExchange=function(x){var D=t.util.createBuffer();D.putByte(x.session.clientHelloVersion.major),D.putByte(x.session.clientHelloVersion.minor),D.putBytes(t.random.getBytes(46));var R=x.session.sp;R.pre_master_secret=D.getBytes();var N=x.session.serverCertificate.publicKey;D=N.encrypt(R.pre_master_secret);var u=D.length+2,w=t.util.createBuffer();return w.putByte(a.HandshakeType.client_key_exchange),w.putInt24(u),w.putInt16(D.length),w.putBytes(D),w},a.createServerKeyExchange=function(x){var D=t.util.createBuffer();return D},a.getClientSignature=function(x,D){var R=t.util.createBuffer();R.putBuffer(x.session.md5.digest()),R.putBuffer(x.session.sha1.digest()),R=R.getBytes(),x.getSignature=x.getSignature||function(N,u,w){var V=null;if(N.getPrivateKey)try{V=N.getPrivateKey(N,N.session.clientCertificate),V=t.pki.privateKeyFromPem(V)}catch(K){N.error(N,{message:"Could not get private key.",cause:K,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}V===null?N.error(N,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}}):u=V.sign(u,null),w(N,u)},x.getSignature(x,R,D)},a.createCertificateVerify=function(x,D){var R=D.length+2,N=t.util.createBuffer();return N.putByte(a.HandshakeType.certificate_verify),N.putInt24(R),N.putInt16(D.length),N.putBytes(D),N},a.createCertificateRequest=function(x){var D=t.util.createBuffer();D.putByte(1);var R=t.util.createBuffer();for(var N in x.caStore.certs){var u=x.caStore.certs[N],w=t.pki.distinguishedNameToAsn1(u.subject),V=t.asn1.toDer(w);R.putInt16(V.length()),R.putBuffer(V)}var K=1+D.length()+2+R.length(),j=t.util.createBuffer();return j.putByte(a.HandshakeType.certificate_request),j.putInt24(K),f(j,1,D),f(j,2,R),j},a.createServerHelloDone=function(x){var D=t.util.createBuffer();return D.putByte(a.HandshakeType.server_hello_done),D.putInt24(0),D},a.createChangeCipherSpec=function(){var x=t.util.createBuffer();return x.putByte(1),x},a.createFinished=function(x){var D=t.util.createBuffer();D.putBuffer(x.session.md5.digest()),D.putBuffer(x.session.sha1.digest());var R=x.entity===a.ConnectionEnd.client,N=x.session.sp,u=12,w=e,V=R?"client finished":"server finished";D=w(N.master_secret,V,D.getBytes(),u);var K=t.util.createBuffer();return K.putByte(a.HandshakeType.finished),K.putInt24(D.length()),K.putBuffer(D),K},a.createHeartbeat=function(x,D,R){typeof R>"u"&&(R=D.length);var N=t.util.createBuffer();N.putByte(x),N.putInt16(R),N.putBytes(D);var u=N.length(),w=Math.max(16,u-R-3);return N.putBytes(t.random.getBytes(w)),N},a.queue=function(x,D){if(D&&!(D.fragment.length()===0&&(D.type===a.ContentType.handshake||D.type===a.ContentType.alert||D.type===a.ContentType.change_cipher_spec))){if(D.type===a.ContentType.handshake){var R=D.fragment.bytes();x.session.md5.update(R),x.session.sha1.update(R),R=null}var N;if(D.fragment.length()<=a.MaxFragment)N=[D];else{N=[];for(var u=D.fragment.bytes();u.length>a.MaxFragment;)N.push(a.createRecord(x,{type:D.type,data:t.util.createBuffer(u.slice(0,a.MaxFragment))})),u=u.slice(a.MaxFragment);u.length>0&&N.push(a.createRecord(x,{type:D.type,data:t.util.createBuffer(u)}))}for(var w=0;w<N.length&&!x.fail;++w){var V=N[w],K=x.state.current.write;K.update(x,V)&&x.records.push(V)}}},a.flush=function(x){for(var D=0;D<x.records.length;++D){var R=x.records[D];x.tlsData.putByte(R.type),x.tlsData.putByte(R.version.major),x.tlsData.putByte(R.version.minor),x.tlsData.putInt16(R.fragment.length()),x.tlsData.putBuffer(x.records[D].fragment)}return x.records=[],x.tlsDataReady(x)};var J=function(x){switch(x){case!0:return!0;case t.pki.certificateError.bad_certificate:return a.Alert.Description.bad_certificate;case t.pki.certificateError.unsupported_certificate:return a.Alert.Description.unsupported_certificate;case t.pki.certificateError.certificate_revoked:return a.Alert.Description.certificate_revoked;case t.pki.certificateError.certificate_expired:return a.Alert.Description.certificate_expired;case t.pki.certificateError.certificate_unknown:return a.Alert.Description.certificate_unknown;case t.pki.certificateError.unknown_ca:return a.Alert.Description.unknown_ca;default:return a.Alert.Description.bad_certificate}},Ge=function(x){switch(x){case!0:return!0;case a.Alert.Description.bad_certificate:return t.pki.certificateError.bad_certificate;case a.Alert.Description.unsupported_certificate:return t.pki.certificateError.unsupported_certificate;case a.Alert.Description.certificate_revoked:return t.pki.certificateError.certificate_revoked;case a.Alert.Description.certificate_expired:return t.pki.certificateError.certificate_expired;case a.Alert.Description.certificate_unknown:return t.pki.certificateError.certificate_unknown;case a.Alert.Description.unknown_ca:return t.pki.certificateError.unknown_ca;default:return t.pki.certificateError.bad_certificate}};a.verifyCertificateChain=function(x,D){try{var R={};for(var N in x.verifyOptions)R[N]=x.verifyOptions[N];R.verify=function(w,V,K){var j=J(w),Z=x.verify(x,w,V,K);if(Z!==!0){if(typeof Z=="object"&&!t.util.isArray(Z)){var z=new Error("The application rejected the certificate.");throw z.send=!0,z.alert={level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate},Z.message&&(z.message=Z.message),Z.alert&&(z.alert.description=Z.alert),z}Z!==w&&(Z=Ge(Z))}return Z},t.pki.verifyCertificateChain(x.caStore,D,R)}catch(w){var u=w;(typeof u!="object"||t.util.isArray(u))&&(u={send:!0,alert:{level:a.Alert.Level.fatal,description:J(w)}}),"send"in u||(u.send=!0),"alert"in u||(u.alert={level:a.Alert.Level.fatal,description:J(u.error)}),x.error(x,u)}return!x.fail},a.createSessionCache=function(x,D){var R=null;if(x&&x.getSession&&x.setSession&&x.order)R=x;else{R={},R.cache=x||{},R.capacity=Math.max(D||100,1),R.order=[];for(var N in x)R.order.length<=D?R.order.push(N):delete x[N];R.getSession=function(u){var w=null,V=null;if(u?V=t.util.bytesToHex(u):R.order.length>0&&(V=R.order[0]),V!==null&&V in R.cache){w=R.cache[V],delete R.cache[V];for(var K in R.order)if(R.order[K]===V){R.order.splice(K,1);break}}return w},R.setSession=function(u,w){if(R.order.length===R.capacity){var V=R.order.shift();delete R.cache[V]}var V=t.util.bytesToHex(u);R.order.push(V),R.cache[V]=w}}return R},a.createConnection=function(x){var D=null;x.caStore?t.util.isArray(x.caStore)?D=t.pki.createCaStore(x.caStore):D=x.caStore:D=t.pki.createCaStore();var R=x.cipherSuites||null;if(R===null){R=[];for(var N in a.CipherSuites)R.push(a.CipherSuites[N])}var u=x.server?a.ConnectionEnd.server:a.ConnectionEnd.client,w=x.sessionCache?a.createSessionCache(x.sessionCache):null,V={version:{major:a.Version.major,minor:a.Version.minor},entity:u,sessionId:x.sessionId,caStore:D,sessionCache:w,cipherSuites:R,connected:x.connected,virtualHost:x.virtualHost||null,verifyClient:x.verifyClient||!1,verify:x.verify||function(z,ee,oe,de){return ee},verifyOptions:x.verifyOptions||{},getCertificate:x.getCertificate||null,getPrivateKey:x.getPrivateKey||null,getSignature:x.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:x.tlsDataReady,dataReady:x.dataReady,heartbeatReceived:x.heartbeatReceived,closed:x.closed,error:function(z,ee){ee.origin=ee.origin||(z.entity===a.ConnectionEnd.client?"client":"server"),ee.send&&(a.queue(z,a.createAlert(z,ee.alert)),a.flush(z));var oe=ee.fatal!==!1;oe&&(z.fail=!0),x.error(z,ee),oe&&z.close(!1)},deflate:x.deflate||null,inflate:x.inflate||null};V.reset=function(z){V.version={major:a.Version.major,minor:a.Version.minor},V.record=null,V.session=null,V.peerCertificate=null,V.state={pending:null,current:null},V.expect=V.entity===a.ConnectionEnd.client?g:s,V.fragmented=null,V.records=[],V.open=!1,V.handshakes=0,V.handshaking=!1,V.isConnected=!1,V.fail=!(z||typeof z>"u"),V.input.clear(),V.tlsData.clear(),V.data.clear(),V.state.current=a.createConnectionState(V)},V.reset();var K=function(z,ee){var oe=ee.type-a.ContentType.change_cipher_spec,de=H[z.entity][z.expect];oe in de?de[oe](z,ee):a.handleUnexpected(z,ee)},j=function(z){var ee=0,oe=z.input,de=oe.length();if(de<5)ee=5-de;else{z.record={type:oe.getByte(),version:{major:oe.getByte(),minor:oe.getByte()},length:oe.getInt16(),fragment:t.util.createBuffer(),ready:!1};var fe=z.record.version.major===z.version.major;fe&&z.session&&z.session.version&&(fe=z.record.version.minor===z.version.minor),fe||z.error(z,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}})}return ee},Z=function(z){var ee=0,oe=z.input,de=oe.length();if(de<z.record.length)ee=z.record.length-de;else{z.record.fragment.putBytes(oe.getBytes(z.record.length)),oe.compact();var fe=z.state.current.read;fe.update(z,z.record)&&(z.fragmented!==null&&(z.fragmented.type===z.record.type?(z.fragmented.fragment.putBuffer(z.record.fragment),z.record=z.fragmented):z.error(z,{message:"Invalid fragmented record.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unexpected_message}})),z.record.ready=!0)}return ee};return V.handshake=function(z){if(V.entity!==a.ConnectionEnd.client)V.error(V,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(V.handshaking)V.error(V,{message:"Handshake already in progress.",fatal:!1});else{V.fail&&!V.open&&V.handshakes===0&&(V.fail=!1),V.handshaking=!0,z=z||"";var ee=null;z.length>0&&(V.sessionCache&&(ee=V.sessionCache.getSession(z)),ee===null&&(z="")),z.length===0&&V.sessionCache&&(ee=V.sessionCache.getSession(),ee!==null&&(z=ee.id)),V.session={id:z,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:t.md.md5.create(),sha1:t.md.sha1.create()},ee&&(V.version=ee.version,V.session.sp=ee.sp),V.session.sp.client_random=a.createRandom().getBytes(),V.open=!0,a.queue(V,a.createRecord(V,{type:a.ContentType.handshake,data:a.createClientHello(V)})),a.flush(V)}},V.process=function(z){var ee=0;return z&&V.input.putBytes(z),V.fail||(V.record!==null&&V.record.ready&&V.record.fragment.isEmpty()&&(V.record=null),V.record===null&&(ee=j(V)),!V.fail&&V.record!==null&&!V.record.ready&&(ee=Z(V)),!V.fail&&V.record!==null&&V.record.ready&&K(V,V.record)),ee},V.prepare=function(z){return a.queue(V,a.createRecord(V,{type:a.ContentType.application_data,data:t.util.createBuffer(z)})),a.flush(V)},V.prepareHeartbeatRequest=function(z,ee){return z instanceof t.util.ByteBuffer&&(z=z.bytes()),typeof ee>"u"&&(ee=z.length),V.expectedHeartbeatPayload=z,a.queue(V,a.createRecord(V,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_request,z,ee)})),a.flush(V)},V.close=function(z){if(!V.fail&&V.sessionCache&&V.session){var ee={id:V.session.id,version:V.session.version,sp:V.session.sp};ee.sp.keys=null,V.sessionCache.setSession(ee.id,ee)}V.open&&(V.open=!1,V.input.clear(),(V.isConnected||V.handshaking)&&(V.isConnected=V.handshaking=!1,a.queue(V,a.createAlert(V,{level:a.Alert.Level.warning,description:a.Alert.Description.close_notify})),a.flush(V)),V.closed(V)),V.reset(z)},V},Lr=t.tls=t.tls||{};for(var be in a)typeof a[be]!="function"&&(t.tls[be]=a[be]);return t.tls.prf_tls1=e,t.tls.hmac_sha1=r,t.tls.createSessionCache=a.createSessionCache,t.tls.createConnection=a.createConnection,Lr}var Wa;function ls(){if(Wa)return fr.exports;Wa=1;var t=le();St(),Fn();var e=fr.exports=t.tls;e.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,g.cipher_type=e.CipherType.block,g.enc_key_length=16,g.block_length=16,g.fixed_iv_length=16,g.record_iv_length=16,g.mac_algorithm=e.MACAlgorithm.hmac_sha1,g.mac_length=20,g.mac_key_length=20},initConnectionState:r},e.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(g){g.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,g.cipher_type=e.CipherType.block,g.enc_key_length=32,g.block_length=16,g.fixed_iv_length=16,g.record_iv_length=16,g.mac_algorithm=e.MACAlgorithm.hmac_sha1,g.mac_length=20,g.mac_key_length=20},initConnectionState:r};function r(g,l,b){var U=l.entity===t.tls.ConnectionEnd.client;g.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",U?b.keys.server_write_key:b.keys.client_write_key),iv:U?b.keys.server_write_IV:b.keys.client_write_IV},g.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",U?b.keys.client_write_key:b.keys.server_write_key),iv:U?b.keys.client_write_IV:b.keys.server_write_IV},g.read.cipherFunction=f,g.write.cipherFunction=o,g.read.macLength=g.write.macLength=b.mac_length,g.read.macFunction=g.write.macFunction=e.hmac_sha1}function o(g,l){var b=!1,U=l.macFunction(l.macKey,l.sequenceNumber,g);g.fragment.putBytes(U),l.updateSequenceNumber();var S;g.version.minor===e.Versions.TLS_1_0.minor?S=l.cipherState.init?null:l.cipherState.iv:S=t.random.getBytesSync(16),l.cipherState.init=!0;var c=l.cipherState.cipher;return c.start({iv:S}),g.version.minor>=e.Versions.TLS_1_1.minor&&c.output.putBytes(S),c.update(g.fragment),c.finish(p)&&(g.fragment=c.output,g.length=g.fragment.length(),b=!0),b}function p(g,l,b){if(!b){var U=g-l.length()%g;l.fillWithByte(U-1,U)}return!0}function y(g,l,b){var U=!0;if(b){for(var S=l.length(),c=l.last(),m=S-1-c;m<S-1;++m)U=U&&l.at(m)==c;U&&l.truncate(c+1)}return U}function f(g,l){var b=!1,U;g.version.minor===e.Versions.TLS_1_0.minor?U=l.cipherState.init?null:l.cipherState.iv:U=g.fragment.getBytes(16),l.cipherState.init=!0;var S=l.cipherState.cipher;S.start({iv:U}),S.update(g.fragment),b=S.finish(y);var c=l.macLength,m=t.random.getBytesSync(c),E=S.output.length();E>=c?(g.fragment=S.output.getBytes(E-c),m=S.output.getBytes(c)):g.fragment=S.output.getBytes(),g.fragment=t.util.createBuffer(g.fragment),g.length=g.fragment.length();var C=l.macFunction(l.macKey,l.sequenceNumber,g);return l.updateSequenceNumber(),b=a(l.macKey,m,C)&&b,b}function a(g,l,b){var U=t.hmac.create();return U.start("SHA1",g),U.update(l),l=U.digest().getBytes(),U.start(null,null),U.update(b),b=U.digest().getBytes(),l===b}return fr.exports}var Ur={exports:{}},ja;function Kn(){if(ja)return Ur.exports;ja=1;var t=le();dt(),pe();var e=Ur.exports=t.sha512=t.sha512||{};t.md.sha512=t.md.algorithms.sha512=e;var r=t.sha384=t.sha512.sha384=t.sha512.sha384||{};r.create=function(){return e.create("SHA-384")},t.md.sha384=t.md.algorithms.sha384=r,t.sha512.sha256=t.sha512.sha256||{create:function(){return e.create("SHA-512/256")}},t.md["sha512/256"]=t.md.algorithms["sha512/256"]=t.sha512.sha256,t.sha512.sha224=t.sha512.sha224||{create:function(){return e.create("SHA-512/224")}},t.md["sha512/224"]=t.md.algorithms["sha512/224"]=t.sha512.sha224,e.create=function(l){if(p||a(),typeof l>"u"&&(l="SHA-512"),!(l in f))throw new Error("Invalid SHA-512 algorithm: "+l);for(var b=f[l],U=null,S=t.util.createBuffer(),c=new Array(80),m=0;m<80;++m)c[m]=new Array(2);var E=64;switch(l){case"SHA-384":E=48;break;case"SHA-512/256":E=32;break;case"SHA-512/224":E=28;break}var C={algorithm:l.replace("-","").toLowerCase(),blockLength:128,digestLength:E,messageLength:0,fullMessageLength:null,messageLengthSize:16};return C.start=function(){C.messageLength=0,C.fullMessageLength=C.messageLength128=[];for(var s=C.messageLengthSize/4,h=0;h<s;++h)C.fullMessageLength.push(0);S=t.util.createBuffer(),U=new Array(b.length);for(var h=0;h<b.length;++h)U[h]=b[h].slice(0);return C},C.start(),C.update=function(s,h){h==="utf8"&&(s=t.util.encodeUtf8(s));var v=s.length;C.messageLength+=v,v=[v/4294967296>>>0,v>>>0];for(var A=C.fullMessageLength.length-1;A>=0;--A)C.fullMessageLength[A]+=v[1],v[1]=v[0]+(C.fullMessageLength[A]/4294967296>>>0),C.fullMessageLength[A]=C.fullMessageLength[A]>>>0,v[0]=v[1]/4294967296>>>0;return S.putBytes(s),g(U,c,S),(S.read>2048||S.length()===0)&&S.compact(),C},C.digest=function(){var s=t.util.createBuffer();s.putBytes(S.bytes());var h=C.fullMessageLength[C.fullMessageLength.length-1]+C.messageLengthSize,v=h&C.blockLength-1;s.putBytes(o.substr(0,C.blockLength-v));for(var A,_,d=C.fullMessageLength[0]*8,i=0;i<C.fullMessageLength.length-1;++i)A=C.fullMessageLength[i+1]*8,_=A/4294967296>>>0,d+=_,s.putInt32(d>>>0),d=A>>>0;s.putInt32(d);for(var n=new Array(U.length),i=0;i<U.length;++i)n[i]=U[i].slice(0);g(n,c,s);var I=t.util.createBuffer(),L;l==="SHA-512"?L=n.length:l==="SHA-384"?L=n.length-2:L=n.length-4;for(var i=0;i<L;++i)I.putInt32(n[i][0]),(i!==L-1||l!=="SHA-512/224")&&I.putInt32(n[i][1]);return I},C};var o=null,p=!1,y=null,f=null;function a(){o="",o+=t.util.fillString("\0",128),y=[[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]],f={},f["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],f["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],f["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],f["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],p=!0}function g(l,b,U){for(var S,c,m,E,C,s,h,v,A,_,d,i,n,I,L,O,k,F,H,q,G,Y,X,te,ie,se,ae,ue,ce,$,J,Ge,be,x,D,R=U.length();R>=128;){for(ce=0;ce<16;++ce)b[ce][0]=U.getInt32()>>>0,b[ce][1]=U.getInt32()>>>0;for(;ce<80;++ce)Ge=b[ce-2],$=Ge[0],J=Ge[1],S=(($>>>19|J<<13)^(J>>>29|$<<3)^$>>>6)>>>0,c=(($<<13|J>>>19)^(J<<3|$>>>29)^($<<26|J>>>6))>>>0,x=b[ce-15],$=x[0],J=x[1],m=(($>>>1|J<<31)^($>>>8|J<<24)^$>>>7)>>>0,E=(($<<31|J>>>1)^($<<24|J>>>8)^($<<25|J>>>7))>>>0,be=b[ce-7],D=b[ce-16],J=c+be[1]+E+D[1],b[ce][0]=S+be[0]+m+D[0]+(J/4294967296>>>0)>>>0,b[ce][1]=J>>>0;for(n=l[0][0],I=l[0][1],L=l[1][0],O=l[1][1],k=l[2][0],F=l[2][1],H=l[3][0],q=l[3][1],G=l[4][0],Y=l[4][1],X=l[5][0],te=l[5][1],ie=l[6][0],se=l[6][1],ae=l[7][0],ue=l[7][1],ce=0;ce<80;++ce)h=((G>>>14|Y<<18)^(G>>>18|Y<<14)^(Y>>>9|G<<23))>>>0,v=((G<<18|Y>>>14)^(G<<14|Y>>>18)^(Y<<23|G>>>9))>>>0,A=(ie^G&(X^ie))>>>0,_=(se^Y&(te^se))>>>0,C=((n>>>28|I<<4)^(I>>>2|n<<30)^(I>>>7|n<<25))>>>0,s=((n<<4|I>>>28)^(I<<30|n>>>2)^(I<<25|n>>>7))>>>0,d=(n&L|k&(n^L))>>>0,i=(I&O|F&(I^O))>>>0,J=ue+v+_+y[ce][1]+b[ce][1],S=ae+h+A+y[ce][0]+b[ce][0]+(J/4294967296>>>0)>>>0,c=J>>>0,J=s+i,m=C+d+(J/4294967296>>>0)>>>0,E=J>>>0,ae=ie,ue=se,ie=X,se=te,X=G,te=Y,J=q+c,G=H+S+(J/4294967296>>>0)>>>0,Y=J>>>0,H=k,q=F,k=L,F=O,L=n,O=I,J=c+E,n=S+m+(J/4294967296>>>0)>>>0,I=J>>>0;J=l[0][1]+I,l[0][0]=l[0][0]+n+(J/4294967296>>>0)>>>0,l[0][1]=J>>>0,J=l[1][1]+O,l[1][0]=l[1][0]+L+(J/4294967296>>>0)>>>0,l[1][1]=J>>>0,J=l[2][1]+F,l[2][0]=l[2][0]+k+(J/4294967296>>>0)>>>0,l[2][1]=J>>>0,J=l[3][1]+q,l[3][0]=l[3][0]+H+(J/4294967296>>>0)>>>0,l[3][1]=J>>>0,J=l[4][1]+Y,l[4][0]=l[4][0]+G+(J/4294967296>>>0)>>>0,l[4][1]=J>>>0,J=l[5][1]+te,l[5][0]=l[5][0]+X+(J/4294967296>>>0)>>>0,l[5][1]=J>>>0,J=l[6][1]+se,l[6][0]=l[6][0]+ie+(J/4294967296>>>0)>>>0,l[6][1]=J>>>0,J=l[7][1]+ue,l[7][0]=l[7][0]+ae+(J/4294967296>>>0)>>>0,l[7][1]=J>>>0,R-=128}}return Ur.exports}var Ht={},$a;function ds(){if($a)return Ht;$a=1;var t=le();ot();var e=t.asn1;return Ht.privateKeyValidator={name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:e.Class.UNIVERSAL,type:e.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},Ht.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:e.Class.UNIVERSAL,type:e.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:e.Class.UNIVERSAL,type:e.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:e.Class.UNIVERSAL,type:e.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]},Ht}var kr,Xa;function hs(){if(Xa)return kr;Xa=1;var t=le();Xt(),it(),Kn(),pe();var e=ds(),r=e.publicKeyValidator,o=e.privateKeyValidator;if(typeof p>"u")var p=t.jsbn.BigInteger;var y=t.util.ByteBuffer,f=typeof Buffer>"u"?Uint8Array:Buffer;t.pki=t.pki||{},kr=t.pki.ed25519=t.ed25519=t.ed25519||{};var a=t.ed25519;a.constants={},a.constants.PUBLIC_KEY_BYTE_LENGTH=32,a.constants.PRIVATE_KEY_BYTE_LENGTH=64,a.constants.SEED_BYTE_LENGTH=32,a.constants.SIGN_BYTE_LENGTH=64,a.constants.HASH_BYTE_LENGTH=64,a.generateKeyPair=function(D){D=D||{};var R=D.seed;if(R===void 0)R=t.random.getBytesSync(a.constants.SEED_BYTE_LENGTH);else if(typeof R=="string"){if(R.length!==a.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+a.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(R instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');R=g({message:R,encoding:"binary"});for(var N=new f(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=new f(a.constants.PRIVATE_KEY_BYTE_LENGTH),w=0;w<32;++w)u[w]=R[w];return h(N,u),{publicKey:N,privateKey:u}},a.privateKeyFromAsn1=function(D){var R={},N=[],u=t.asn1.validate(D,o,R,N);if(!u){var w=new Error("Invalid Key.");throw w.errors=N,w}var V=t.asn1.derToOid(R.privateKeyOid),K=t.oids.EdDSA25519;if(V!==K)throw new Error('Invalid OID "'+V+'"; OID must be "'+K+'".');var j=R.privateKey,Z=g({message:t.asn1.fromDer(j).value,encoding:"binary"});return{privateKeyBytes:Z}},a.publicKeyFromAsn1=function(D){var R={},N=[],u=t.asn1.validate(D,r,R,N);if(!u){var w=new Error("Invalid Key.");throw w.errors=N,w}var V=t.asn1.derToOid(R.publicKeyOid),K=t.oids.EdDSA25519;if(V!==K)throw new Error('Invalid OID "'+V+'"; OID must be "'+K+'".');var j=R.ed25519PublicKey;if(j.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return g({message:j,encoding:"binary"})},a.publicKeyFromPrivateKey=function(D){D=D||{};var R=g({message:D.privateKey,encoding:"binary"});if(R.length!==a.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+a.constants.PRIVATE_KEY_BYTE_LENGTH);for(var N=new f(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=0;u<N.length;++u)N[u]=R[32+u];return N},a.sign=function(D){D=D||{};var R=g(D),N=g({message:D.privateKey,encoding:"binary"});if(N.length===a.constants.SEED_BYTE_LENGTH){var u=a.generateKeyPair({seed:N});N=u.privateKey}else if(N.length!==a.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+a.constants.SEED_BYTE_LENGTH+" or "+a.constants.PRIVATE_KEY_BYTE_LENGTH);var w=new f(a.constants.SIGN_BYTE_LENGTH+R.length);v(w,R,R.length,N);for(var V=new f(a.constants.SIGN_BYTE_LENGTH),K=0;K<V.length;++K)V[K]=w[K];return V},a.verify=function(D){D=D||{};var R=g(D);if(D.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var N=g({message:D.signature,encoding:"binary"});if(N.length!==a.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+a.constants.SIGN_BYTE_LENGTH);var u=g({message:D.publicKey,encoding:"binary"});if(u.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+a.constants.PUBLIC_KEY_BYTE_LENGTH);var w=new f(a.constants.SIGN_BYTE_LENGTH+R.length),V=new f(a.constants.SIGN_BYTE_LENGTH+R.length),K;for(K=0;K<a.constants.SIGN_BYTE_LENGTH;++K)w[K]=N[K];for(K=0;K<R.length;++K)w[K+a.constants.SIGN_BYTE_LENGTH]=R[K];return A(V,w,w.length,u)>=0};function g(D){var R=D.message;if(R instanceof Uint8Array||R instanceof f)return R;var N=D.encoding;if(R===void 0)if(D.md)R=D.md.digest().getBytes(),N="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof R=="string"&&!N)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof R=="string"){if(typeof Buffer<"u")return Buffer.from(R,N);R=new y(R,N)}else if(!(R instanceof y))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var u=new f(R.length()),w=0;w<u.length;++w)u[w]=R.at(w);return u}var l=$(),b=$([1]),U=$([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),S=$([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=$([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=$([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),E=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]),C=$([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function s(D,R){var N=t.md.sha512.create(),u=new y(D);N.update(u.getBytes(R),"binary");var w=N.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(w,"binary");for(var V=new f(a.constants.HASH_BYTE_LENGTH),K=0;K<64;++K)V[K]=w.charCodeAt(K);return V}function h(D,R){var N=[$(),$(),$(),$()],u,w=s(R,32);for(w[0]&=248,w[31]&=127,w[31]|=64,ie(N,w),L(D,N),u=0;u<32;++u)R[u+32]=D[u];return 0}function v(D,R,N,u){var w,V,K=new Float64Array(64),j=[$(),$(),$(),$()],Z=s(u,32);Z[0]&=248,Z[31]&=127,Z[31]|=64;var z=N+64;for(w=0;w<N;++w)D[64+w]=R[w];for(w=0;w<32;++w)D[32+w]=Z[32+w];var ee=s(D.subarray(32),N+32);for(i(ee),ie(j,ee),L(D,j),w=32;w<64;++w)D[w]=u[w];var oe=s(D,N+64);for(i(oe),w=32;w<64;++w)K[w]=0;for(w=0;w<32;++w)K[w]=ee[w];for(w=0;w<32;++w)for(V=0;V<32;V++)K[w+V]+=oe[w]*Z[V];return d(D.subarray(32),K),z}function A(D,R,N,u){var w,V,K=new f(32),j=[$(),$(),$(),$()],Z=[$(),$(),$(),$()];if(V=-1,N<64||k(Z,u)||!_(R,32))return-1;for(w=0;w<N;++w)D[w]=R[w];for(w=0;w<32;++w)D[w+32]=u[w];var z=s(D,N);if(i(z),te(j,Z,z),ie(Z,R.subarray(32)),n(j,Z),L(K,j),N-=64,G(R,0,K,0)){for(w=0;w<N;++w)D[w]=0;return-1}for(w=0;w<N;++w)D[w]=R[w+64];return V=N,V}function _(D,R){var N;for(N=31;N>=0;--N){if(D[R+N]<E[N])return!0;if(D[R+N]>E[N])return!1}return!1}function d(D,R){var N,u,w,V;for(u=63;u>=32;--u){for(N=0,w=u-32,V=u-12;w<V;++w)R[w]+=N-16*R[u]*E[w-(u-32)],N=R[w]+128>>8,R[w]-=N*256;R[w]+=N,R[u]=0}for(N=0,w=0;w<32;++w)R[w]+=N-(R[31]>>4)*E[w],N=R[w]>>8,R[w]&=255;for(w=0;w<32;++w)R[w]-=N*E[w];for(u=0;u<32;++u)R[u+1]+=R[u]>>8,D[u]=R[u]&255}function i(D){for(var R=new Float64Array(64),N=0;N<64;++N)R[N]=D[N],D[N]=0;d(D,R)}function n(D,R){var N=$(),u=$(),w=$(),V=$(),K=$(),j=$(),Z=$(),z=$(),ee=$();Ge(N,D[1],D[0]),Ge(ee,R[1],R[0]),x(N,N,ee),J(u,D[0],D[1]),J(ee,R[0],R[1]),x(u,u,ee),x(w,D[3],R[3]),x(w,w,S),x(V,D[2],R[2]),J(V,V,V),Ge(K,u,N),Ge(j,V,w),J(Z,V,w),J(z,u,N),x(D[0],K,j),x(D[1],z,Z),x(D[2],Z,j),x(D[3],K,z)}function I(D,R,N){for(var u=0;u<4;++u)ce(D[u],R[u],N)}function L(D,R){var N=$(),u=$(),w=$();ae(w,R[2]),x(N,R[0],w),x(u,R[1],w),O(D,u),D[31]^=X(N)<<7}function O(D,R){var N,u,w,V=$(),K=$();for(N=0;N<16;++N)K[N]=R[N];for(ue(K),ue(K),ue(K),u=0;u<2;++u){for(V[0]=K[0]-65517,N=1;N<15;++N)V[N]=K[N]-65535-(V[N-1]>>16&1),V[N-1]&=65535;V[15]=K[15]-32767-(V[14]>>16&1),w=V[15]>>16&1,V[14]&=65535,ce(K,V,1-w)}for(N=0;N<16;N++)D[2*N]=K[N]&255,D[2*N+1]=K[N]>>8}function k(D,R){var N=$(),u=$(),w=$(),V=$(),K=$(),j=$(),Z=$();return se(D[2],b),F(D[1],R),be(w,D[1]),x(V,w,U),Ge(w,w,D[2]),J(V,D[2],V),be(K,V),be(j,K),x(Z,j,K),x(N,Z,w),x(N,N,V),H(N,N),x(N,N,w),x(N,N,V),x(N,N,V),x(D[0],N,V),be(u,D[0]),x(u,u,V),q(u,w)&&x(D[0],D[0],C),be(u,D[0]),x(u,u,V),q(u,w)?-1:(X(D[0])===R[31]>>7&&Ge(D[0],l,D[0]),x(D[3],D[0],D[1]),0)}function F(D,R){var N;for(N=0;N<16;++N)D[N]=R[2*N]+(R[2*N+1]<<8);D[15]&=32767}function H(D,R){var N=$(),u;for(u=0;u<16;++u)N[u]=R[u];for(u=250;u>=0;--u)be(N,N),u!==1&&x(N,N,R);for(u=0;u<16;++u)D[u]=N[u]}function q(D,R){var N=new f(32),u=new f(32);return O(N,D),O(u,R),G(N,0,u,0)}function G(D,R,N,u){return Y(D,R,N,u,32)}function Y(D,R,N,u,w){var V,K=0;for(V=0;V<w;++V)K|=D[R+V]^N[u+V];return(1&K-1>>>8)-1}function X(D){var R=new f(32);return O(R,D),R[0]&1}function te(D,R,N){var u,w;for(se(D[0],l),se(D[1],b),se(D[2],b),se(D[3],l),w=255;w>=0;--w)u=N[w/8|0]>>(w&7)&1,I(D,R,u),n(R,D),n(D,D),I(D,R,u)}function ie(D,R){var N=[$(),$(),$(),$()];se(N[0],c),se(N[1],m),se(N[2],b),x(N[3],c,m),te(D,N,R)}function se(D,R){var N;for(N=0;N<16;N++)D[N]=R[N]|0}function ae(D,R){var N=$(),u;for(u=0;u<16;++u)N[u]=R[u];for(u=253;u>=0;--u)be(N,N),u!==2&&u!==4&&x(N,N,R);for(u=0;u<16;++u)D[u]=N[u]}function ue(D){var R,N,u=1;for(R=0;R<16;++R)N=D[R]+u+65535,u=Math.floor(N/65536),D[R]=N-u*65536;D[0]+=u-1+37*(u-1)}function ce(D,R,N){for(var u,w=~(N-1),V=0;V<16;++V)u=w&(D[V]^R[V]),D[V]^=u,R[V]^=u}function $(D){var R,N=new Float64Array(16);if(D)for(R=0;R<D.length;++R)N[R]=D[R];return N}function J(D,R,N){for(var u=0;u<16;++u)D[u]=R[u]+N[u]}function Ge(D,R,N){for(var u=0;u<16;++u)D[u]=R[u]-N[u]}function be(D,R){x(D,R,R)}function x(D,R,N){var u,w,V=0,K=0,j=0,Z=0,z=0,ee=0,oe=0,de=0,fe=0,Ee=0,Te=0,Se=0,xe=0,me=0,ge=0,ye=0,Ie=0,Be=0,ze=0,Qe=0,je=0,$e=0,Je=0,tt=0,st=0,ut=0,ht=0,mt=0,Tt=0,Rt=0,Ot=0,we=N[0],Ne=N[1],Re=N[2],_e=N[3],De=N[4],Le=N[5],Ue=N[6],ke=N[7],Pe=N[8],Ve=N[9],Oe=N[10],Fe=N[11],Ce=N[12],Ae=N[13],Ke=N[14],Me=N[15];u=R[0],V+=u*we,K+=u*Ne,j+=u*Re,Z+=u*_e,z+=u*De,ee+=u*Le,oe+=u*Ue,de+=u*ke,fe+=u*Pe,Ee+=u*Ve,Te+=u*Oe,Se+=u*Fe,xe+=u*Ce,me+=u*Ae,ge+=u*Ke,ye+=u*Me,u=R[1],K+=u*we,j+=u*Ne,Z+=u*Re,z+=u*_e,ee+=u*De,oe+=u*Le,de+=u*Ue,fe+=u*ke,Ee+=u*Pe,Te+=u*Ve,Se+=u*Oe,xe+=u*Fe,me+=u*Ce,ge+=u*Ae,ye+=u*Ke,Ie+=u*Me,u=R[2],j+=u*we,Z+=u*Ne,z+=u*Re,ee+=u*_e,oe+=u*De,de+=u*Le,fe+=u*Ue,Ee+=u*ke,Te+=u*Pe,Se+=u*Ve,xe+=u*Oe,me+=u*Fe,ge+=u*Ce,ye+=u*Ae,Ie+=u*Ke,Be+=u*Me,u=R[3],Z+=u*we,z+=u*Ne,ee+=u*Re,oe+=u*_e,de+=u*De,fe+=u*Le,Ee+=u*Ue,Te+=u*ke,Se+=u*Pe,xe+=u*Ve,me+=u*Oe,ge+=u*Fe,ye+=u*Ce,Ie+=u*Ae,Be+=u*Ke,ze+=u*Me,u=R[4],z+=u*we,ee+=u*Ne,oe+=u*Re,de+=u*_e,fe+=u*De,Ee+=u*Le,Te+=u*Ue,Se+=u*ke,xe+=u*Pe,me+=u*Ve,ge+=u*Oe,ye+=u*Fe,Ie+=u*Ce,Be+=u*Ae,ze+=u*Ke,Qe+=u*Me,u=R[5],ee+=u*we,oe+=u*Ne,de+=u*Re,fe+=u*_e,Ee+=u*De,Te+=u*Le,Se+=u*Ue,xe+=u*ke,me+=u*Pe,ge+=u*Ve,ye+=u*Oe,Ie+=u*Fe,Be+=u*Ce,ze+=u*Ae,Qe+=u*Ke,je+=u*Me,u=R[6],oe+=u*we,de+=u*Ne,fe+=u*Re,Ee+=u*_e,Te+=u*De,Se+=u*Le,xe+=u*Ue,me+=u*ke,ge+=u*Pe,ye+=u*Ve,Ie+=u*Oe,Be+=u*Fe,ze+=u*Ce,Qe+=u*Ae,je+=u*Ke,$e+=u*Me,u=R[7],de+=u*we,fe+=u*Ne,Ee+=u*Re,Te+=u*_e,Se+=u*De,xe+=u*Le,me+=u*Ue,ge+=u*ke,ye+=u*Pe,Ie+=u*Ve,Be+=u*Oe,ze+=u*Fe,Qe+=u*Ce,je+=u*Ae,$e+=u*Ke,Je+=u*Me,u=R[8],fe+=u*we,Ee+=u*Ne,Te+=u*Re,Se+=u*_e,xe+=u*De,me+=u*Le,ge+=u*Ue,ye+=u*ke,Ie+=u*Pe,Be+=u*Ve,ze+=u*Oe,Qe+=u*Fe,je+=u*Ce,$e+=u*Ae,Je+=u*Ke,tt+=u*Me,u=R[9],Ee+=u*we,Te+=u*Ne,Se+=u*Re,xe+=u*_e,me+=u*De,ge+=u*Le,ye+=u*Ue,Ie+=u*ke,Be+=u*Pe,ze+=u*Ve,Qe+=u*Oe,je+=u*Fe,$e+=u*Ce,Je+=u*Ae,tt+=u*Ke,st+=u*Me,u=R[10],Te+=u*we,Se+=u*Ne,xe+=u*Re,me+=u*_e,ge+=u*De,ye+=u*Le,Ie+=u*Ue,Be+=u*ke,ze+=u*Pe,Qe+=u*Ve,je+=u*Oe,$e+=u*Fe,Je+=u*Ce,tt+=u*Ae,st+=u*Ke,ut+=u*Me,u=R[11],Se+=u*we,xe+=u*Ne,me+=u*Re,ge+=u*_e,ye+=u*De,Ie+=u*Le,Be+=u*Ue,ze+=u*ke,Qe+=u*Pe,je+=u*Ve,$e+=u*Oe,Je+=u*Fe,tt+=u*Ce,st+=u*Ae,ut+=u*Ke,ht+=u*Me,u=R[12],xe+=u*we,me+=u*Ne,ge+=u*Re,ye+=u*_e,Ie+=u*De,Be+=u*Le,ze+=u*Ue,Qe+=u*ke,je+=u*Pe,$e+=u*Ve,Je+=u*Oe,tt+=u*Fe,st+=u*Ce,ut+=u*Ae,ht+=u*Ke,mt+=u*Me,u=R[13],me+=u*we,ge+=u*Ne,ye+=u*Re,Ie+=u*_e,Be+=u*De,ze+=u*Le,Qe+=u*Ue,je+=u*ke,$e+=u*Pe,Je+=u*Ve,tt+=u*Oe,st+=u*Fe,ut+=u*Ce,ht+=u*Ae,mt+=u*Ke,Tt+=u*Me,u=R[14],ge+=u*we,ye+=u*Ne,Ie+=u*Re,Be+=u*_e,ze+=u*De,Qe+=u*Le,je+=u*Ue,$e+=u*ke,Je+=u*Pe,tt+=u*Ve,st+=u*Oe,ut+=u*Fe,ht+=u*Ce,mt+=u*Ae,Tt+=u*Ke,Rt+=u*Me,u=R[15],ye+=u*we,Ie+=u*Ne,Be+=u*Re,ze+=u*_e,Qe+=u*De,je+=u*Le,$e+=u*Ue,Je+=u*ke,tt+=u*Pe,st+=u*Ve,ut+=u*Oe,ht+=u*Fe,mt+=u*Ce,Tt+=u*Ae,Rt+=u*Ke,Ot+=u*Me,V+=38*Ie,K+=38*Be,j+=38*ze,Z+=38*Qe,z+=38*je,ee+=38*$e,oe+=38*Je,de+=38*tt,fe+=38*st,Ee+=38*ut,Te+=38*ht,Se+=38*mt,xe+=38*Tt,me+=38*Rt,ge+=38*Ot,w=1,u=V+w+65535,w=Math.floor(u/65536),V=u-w*65536,u=K+w+65535,w=Math.floor(u/65536),K=u-w*65536,u=j+w+65535,w=Math.floor(u/65536),j=u-w*65536,u=Z+w+65535,w=Math.floor(u/65536),Z=u-w*65536,u=z+w+65535,w=Math.floor(u/65536),z=u-w*65536,u=ee+w+65535,w=Math.floor(u/65536),ee=u-w*65536,u=oe+w+65535,w=Math.floor(u/65536),oe=u-w*65536,u=de+w+65535,w=Math.floor(u/65536),de=u-w*65536,u=fe+w+65535,w=Math.floor(u/65536),fe=u-w*65536,u=Ee+w+65535,w=Math.floor(u/65536),Ee=u-w*65536,u=Te+w+65535,w=Math.floor(u/65536),Te=u-w*65536,u=Se+w+65535,w=Math.floor(u/65536),Se=u-w*65536,u=xe+w+65535,w=Math.floor(u/65536),xe=u-w*65536,u=me+w+65535,w=Math.floor(u/65536),me=u-w*65536,u=ge+w+65535,w=Math.floor(u/65536),ge=u-w*65536,u=ye+w+65535,w=Math.floor(u/65536),ye=u-w*65536,V+=w-1+37*(w-1),w=1,u=V+w+65535,w=Math.floor(u/65536),V=u-w*65536,u=K+w+65535,w=Math.floor(u/65536),K=u-w*65536,u=j+w+65535,w=Math.floor(u/65536),j=u-w*65536,u=Z+w+65535,w=Math.floor(u/65536),Z=u-w*65536,u=z+w+65535,w=Math.floor(u/65536),z=u-w*65536,u=ee+w+65535,w=Math.floor(u/65536),ee=u-w*65536,u=oe+w+65535,w=Math.floor(u/65536),oe=u-w*65536,u=de+w+65535,w=Math.floor(u/65536),de=u-w*65536,u=fe+w+65535,w=Math.floor(u/65536),fe=u-w*65536,u=Ee+w+65535,w=Math.floor(u/65536),Ee=u-w*65536,u=Te+w+65535,w=Math.floor(u/65536),Te=u-w*65536,u=Se+w+65535,w=Math.floor(u/65536),Se=u-w*65536,u=xe+w+65535,w=Math.floor(u/65536),xe=u-w*65536,u=me+w+65535,w=Math.floor(u/65536),me=u-w*65536,u=ge+w+65535,w=Math.floor(u/65536),ge=u-w*65536,u=ye+w+65535,w=Math.floor(u/65536),ye=u-w*65536,V+=w-1+37*(w-1),D[0]=V,D[1]=K,D[2]=j,D[3]=Z,D[4]=z,D[5]=ee,D[6]=oe,D[7]=de,D[8]=fe,D[9]=Ee,D[10]=Te,D[11]=Se,D[12]=xe,D[13]=me,D[14]=ge,D[15]=ye}return kr}var Pr,Za;function ps(){if(Za)return Pr;Za=1;var t=le();pe(),it(),Xt(),Pr=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(o,p){p=p||{};var y=p.prng||t.random,f={};return f.encrypt=function(a,g){var l=Math.ceil(a.n.bitLength()/8),b;do b=new e(t.util.bytesToHex(y.getBytesSync(l)),16).mod(a.n);while(b.compareTo(e.ONE)<=0);b=t.util.hexToBytes(b.toString(16));var U=l-b.length;U>0&&(b=t.util.fillString("\0",U)+b);var S=a.encrypt(b,"NONE"),c=o.generate(b,g);return{encapsulation:S,key:c}},f.decrypt=function(a,g,l){var b=a.decrypt(g,"NONE");return o.generate(b,l)},f},t.kem.kdf1=function(o,p){r(this,o,0,p||o.digestLength)},t.kem.kdf2=function(o,p){r(this,o,1,p||o.digestLength)};function r(o,p,y,f){o.generate=function(a,g){for(var l=new t.util.ByteBuffer,b=Math.ceil(g/f)+y,U=new t.util.ByteBuffer,S=y;S<b;++S){U.putInt32(S),p.start(),p.update(a+U.getBytes());var c=p.digest();l.putBytes(c.getBytes(f))}return l.truncate(l.length()-g),l.getBytes()}}return Pr}var Vr,Ja;function vs(){if(Ja)return Vr;Ja=1;var t=le();pe(),Vr=t.log=t.log||{},t.log.levels=["none","error","warning","info","debug","verbose","max"];var e={},r=[],o=null;t.log.LEVEL_LOCKED=2,t.log.NO_LEVEL_CHECK=4,t.log.INTERPOLATE=8;for(var p=0;p<t.log.levels.length;++p){var y=t.log.levels[p];e[y]={index:p,name:y.toUpperCase()}}t.log.logMessage=function(S){for(var c=e[S.level].index,m=0;m<r.length;++m){var E=r[m];if(E.flags&t.log.NO_LEVEL_CHECK)E.f(S);else{var C=e[E.level].index;c<=C&&E.f(E,S)}}},t.log.prepareStandard=function(S){"standard"in S||(S.standard=e[S.level].name+" ["+S.category+"] "+S.message)},t.log.prepareFull=function(S){if(!("full"in S)){var c=[S.message];c=c.concat([]),S.full=t.util.format.apply(this,c)}},t.log.prepareStandardFull=function(S){"standardFull"in S||(t.log.prepareStandard(S),S.standardFull=S.standard)};for(var f=["error","warning","info","debug","verbose"],p=0;p<f.length;++p)(function(c){t.log[c]=function(m,E){var C=Array.prototype.slice.call(arguments).slice(2),s={timestamp:new Date,level:c,category:m,message:E,arguments:C};t.log.logMessage(s)}})(f[p]);if(t.log.makeLogger=function(S){var c={flags:0,f:S};return t.log.setLevel(c,"none"),c},t.log.setLevel=function(S,c){var m=!1;if(S&&!(S.flags&t.log.LEVEL_LOCKED))for(var E=0;E<t.log.levels.length;++E){var C=t.log.levels[E];if(c==C){S.level=c,m=!0;break}}return m},t.log.lock=function(S,c){typeof c>"u"||c?S.flags|=t.log.LEVEL_LOCKED:S.flags&=~t.log.LEVEL_LOCKED},t.log.addLogger=function(S){r.push(S)},typeof console<"u"&&"log"in console){var a;if(console.error&&console.warn&&console.info&&console.debug){var g={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},l=function(S,c){t.log.prepareStandard(c);var m=g[c.level],E=[c.standard];E=E.concat(c.arguments.slice()),m.apply(console,E)};a=t.log.makeLogger(l)}else{var l=function(c,m){t.log.prepareStandardFull(m),console.log(m.standardFull)};a=t.log.makeLogger(l)}t.log.setLevel(a,"debug"),t.log.addLogger(a),o=a}else console={log:function(){}};if(o!==null&&typeof window<"u"&&window.location){var b=new URL(window.location.href).searchParams;if(b.has("console.level")&&t.log.setLevel(o,b.get("console.level").slice(-1)[0]),b.has("console.lock")){var U=b.get("console.lock").slice(-1)[0];U=="true"&&t.log.lock(o)}}return t.log.consoleLogger=o,Vr}var Or,en;function ys(){return en||(en=1,Or=dt(),ra(),kt(),Nn(),Kn()),Or}var Fr={exports:{}},tn;function gs(){if(tn)return Fr.exports;tn=1;var t=le();St(),ot(),$t(),bt(),Nt(),kn(),it(),pe(),sa();var e=t.asn1,r=Fr.exports=t.pkcs7=t.pkcs7||{};r.messageFromPem=function(c){var m=t.pem.decode(c)[0];if(m.type!=="PKCS7"){var E=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw E.headerType=m.type,E}if(m.procType&&m.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var C=e.fromDer(m.body);return r.messageFromAsn1(C)},r.messageToPem=function(c,m){var E={type:"PKCS7",body:e.toDer(c.toAsn1()).getBytes()};return t.pem.encode(E,{maxline:m})},r.messageFromAsn1=function(c){var m={},E=[];if(!e.validate(c,r.asn1.contentInfoValidator,m,E)){var C=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw C.errors=E,C}var s=e.derToOid(m.contentType),h;switch(s){case t.pki.oids.envelopedData:h=r.createEnvelopedData();break;case t.pki.oids.encryptedData:h=r.createEncryptedData();break;case t.pki.oids.signedData:h=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+s+" is not (yet) supported.")}return h.fromAsn1(m.content.value[0]),h},r.createSignedData=function(){var c=null;return c={type:t.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(C){if(U(c,C,r.asn1.signedDataValidator),c.certificates=[],c.crls=[],c.digestAlgorithmIdentifiers=[],c.contentInfo=null,c.signerInfos=[],c.rawCapture.certificates)for(var s=c.rawCapture.certificates.value,h=0;h<s.length;++h)c.certificates.push(t.pki.certificateFromAsn1(s[h]))},toAsn1:function(){c.contentInfo||c.sign();for(var C=[],s=0;s<c.certificates.length;++s)C.push(t.pki.certificateToAsn1(c.certificates[s]));var h=[],v=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.digestAlgorithmIdentifiers),c.contentInfo])]);return C.length>0&&v.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,C)),h.length>0&&v.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,h)),v.value[0].value.push(e.create(e.Class.UNIVERSAL,e.Type.SET,!0,c.signerInfos)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),v])},addSigner:function(C){var s=C.issuer,h=C.serialNumber;if(C.certificate){var v=C.certificate;typeof v=="string"&&(v=t.pki.certificateFromPem(v)),s=v.issuer.attributes,h=v.serialNumber}var A=C.key;if(!A)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof A=="string"&&(A=t.pki.privateKeyFromPem(A));var _=C.digestAlgorithm||t.pki.oids.sha1;switch(_){case t.pki.oids.sha1:case t.pki.oids.sha256:case t.pki.oids.sha384:case t.pki.oids.sha512:case t.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+_)}var d=C.authenticatedAttributes||[];if(d.length>0){for(var i=!1,n=!1,I=0;I<d.length;++I){var L=d[I];if(!i&&L.type===t.pki.oids.contentType){if(i=!0,n)break;continue}if(!n&&L.type===t.pki.oids.messageDigest){if(n=!0,i)break;continue}}if(!i||!n)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}c.signers.push({key:A,version:1,issuer:s,serialNumber:h,digestAlgorithm:_,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:d,unauthenticatedAttributes:[]})},sign:function(C){if(C=C||{},(typeof c.content!="object"||c.contentInfo===null)&&(c.contentInfo=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes())]),"content"in c)){var s;c.content instanceof t.util.ByteBuffer?s=c.content.bytes():typeof c.content=="string"&&(s=t.util.encodeUtf8(c.content)),C.detached?c.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,s):c.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,s)]))}if(c.signers.length!==0){var h=m();E(h)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(C){typeof C=="string"&&(C=t.pki.certificateFromPem(C)),c.certificates.push(C)},addCertificateRevokationList:function(C){throw new Error("PKCS#7 CRL support not yet implemented.")}},c;function m(){for(var C={},s=0;s<c.signers.length;++s){var h=c.signers[s],v=h.digestAlgorithm;v in C||(C[v]=t.md[t.pki.oids[v]].create()),h.authenticatedAttributes.length===0?h.md=C[v]:h.md=t.md[t.pki.oids[v]].create()}c.digestAlgorithmIdentifiers=[];for(var v in C)c.digestAlgorithmIdentifiers.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(v).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]));return C}function E(C){var s;if(c.detachedContent?s=c.detachedContent:(s=c.contentInfo.value[1],s=s.value[0]),!s)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var h=e.derToOid(c.contentInfo.value[0].value),v=e.toDer(s);v.getByte(),e.getBerValueLength(v),v=v.getBytes();for(var A in C)C[A].start().update(v);for(var _=new Date,d=0;d<c.signers.length;++d){var i=c.signers[d];if(i.authenticatedAttributes.length===0){if(h!==t.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{i.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var n=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]),I=0;I<i.authenticatedAttributes.length;++I){var L=i.authenticatedAttributes[I];L.type===t.pki.oids.messageDigest?L.value=C[i.digestAlgorithm].digest():L.type===t.pki.oids.signingTime&&(L.value||(L.value=_)),n.value.push(l(L)),i.authenticatedAttributesAsn1.value.push(l(L))}v=e.toDer(n).getBytes(),i.md.start().update(v)}i.signature=i.key.sign(i.md,"RSASSA-PKCS1-V1_5")}c.signerInfos=g(c.signers)}},r.createEncryptedData=function(){var c=null;return c={type:t.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){U(c,m,r.asn1.encryptedDataValidator)},decrypt:function(m){m!==void 0&&(c.encryptedContent.key=m),S(c)}},c},r.createEnvelopedData=function(){var c=null;return c={type:t.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:t.pki.oids["aes256-CBC"]},fromAsn1:function(m){var E=U(c,m,r.asn1.envelopedDataValidator);c.recipients=y(E.recipientInfos.value)},toAsn1:function(){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,f(c.recipients)),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,b(c.encryptedContent))])])])},findRecipient:function(m){for(var E=m.issuer.attributes,C=0;C<c.recipients.length;++C){var s=c.recipients[C],h=s.issuer;if(s.serialNumber===m.serialNumber&&h.length===E.length){for(var v=!0,A=0;A<E.length;++A)if(h[A].type!==E[A].type||h[A].value!==E[A].value){v=!1;break}if(v)return s}}return null},decrypt:function(m,E){if(c.encryptedContent.key===void 0&&m!==void 0&&E!==void 0)switch(m.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var C=E.decrypt(m.encryptedContent.content);c.encryptedContent.key=t.util.createBuffer(C);break;default:throw new Error("Unsupported asymmetric cipher, OID "+m.encryptedContent.algorithm)}S(c)},addRecipient:function(m){c.recipients.push({version:0,issuer:m.issuer.attributes,serialNumber:m.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:m.publicKey}})},encrypt:function(m,E){if(c.encryptedContent.content===void 0){E=E||c.encryptedContent.algorithm,m=m||c.encryptedContent.key;var C,s,h;switch(E){case t.pki.oids["aes128-CBC"]:C=16,s=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes192-CBC"]:C=24,s=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes256-CBC"]:C=32,s=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["des-EDE3-CBC"]:C=24,s=8,h=t.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+E)}if(m===void 0)m=t.util.createBuffer(t.random.getBytes(C));else if(m.length()!=C)throw new Error("Symmetric key has wrong length; got "+m.length()+" bytes, expected "+C+".");c.encryptedContent.algorithm=E,c.encryptedContent.key=m,c.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(s));var v=h(m);if(v.start(c.encryptedContent.parameter.copy()),v.update(c.content),!v.finish())throw new Error("Symmetric encryption failed.");c.encryptedContent.content=v.output}for(var A=0;A<c.recipients.length;++A){var _=c.recipients[A];if(_.encryptedContent.content===void 0)switch(_.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:_.encryptedContent.content=_.encryptedContent.key.encrypt(c.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+_.encryptedContent.algorithm)}}}},c};function o(c){var m={},E=[];if(!e.validate(c,r.asn1.recipientInfoValidator,m,E)){var C=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw C.errors=E,C}return{version:m.version.charCodeAt(0),issuer:t.pki.RDNAttributesAsArray(m.issuer),serialNumber:t.util.createBuffer(m.serial).toHex(),encryptedContent:{algorithm:e.derToOid(m.encAlgorithm),parameter:m.encParameter?m.encParameter.value:void 0,content:m.encKey}}}function p(c){return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.encryptedContent.algorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.encryptedContent.content)])}function y(c){for(var m=[],E=0;E<c.length;++E)m.push(o(c[E]));return m}function f(c){for(var m=[],E=0;E<c.length;++E)m.push(p(c[E]));return m}function a(c){var m=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(c.version).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[t.pki.distinguishedNameToAsn1({attributes:c.issuer}),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,t.util.hexToBytes(c.serialNumber))]),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.digestAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])]);if(c.authenticatedAttributesAsn1&&m.value.push(c.authenticatedAttributesAsn1),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.signatureAlgorithm).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])),m.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.signature)),c.unauthenticatedAttributes.length>0){for(var E=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]),C=0;C<c.unauthenticatedAttributes.length;++C){var s=c.unauthenticatedAttributes[C];E.values.push(l(s))}m.value.push(E)}return m}function g(c){for(var m=[],E=0;E<c.length;++E)m.push(a(c[E]));return m}function l(c){var m;if(c.type===t.pki.oids.contentType)m=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.value).getBytes());else if(c.type===t.pki.oids.messageDigest)m=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.value.bytes());else if(c.type===t.pki.oids.signingTime){var E=new Date("1950-01-01T00:00:00Z"),C=new Date("2050-01-01T00:00:00Z"),s=c.value;if(typeof s=="string"){var h=Date.parse(s);isNaN(h)?s.length===13?s=e.utcTimeToDate(s):s=e.generalizedTimeToDate(s):s=new Date(h)}s>=E&&s<C?m=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(s)):m=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(s))}return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[m])])}function b(c){return[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(t.pki.oids.data).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.algorithm).getBytes()),c.parameter?e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.parameter.getBytes()):void 0]),e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.content.getBytes())])]}function U(c,m,E){var C={},s=[];if(!e.validate(m,E,C,s)){var h=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw h.errors=h,h}var v=e.derToOid(C.contentType);if(v!==t.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(C.encryptedContent){var A="";if(t.util.isArray(C.encryptedContent))for(var _=0;_<C.encryptedContent.length;++_){if(C.encryptedContent[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");A+=C.encryptedContent[_].value}else A=C.encryptedContent;c.encryptedContent={algorithm:e.derToOid(C.encAlgorithm),parameter:t.util.createBuffer(C.encParameter.value),content:t.util.createBuffer(A)}}if(C.content){var A="";if(t.util.isArray(C.content))for(var _=0;_<C.content.length;++_){if(C.content[_].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");A+=C.content[_].value}else A=C.content;c.content=t.util.createBuffer(A)}return c.version=C.version.charCodeAt(0),c.rawCapture=C,C}function S(c){if(c.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(c.content===void 0){var m;switch(c.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:m=t.aes.createDecryptionCipher(c.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:m=t.des.createDecryptionCipher(c.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+c.encryptedContent.algorithm)}if(m.start(c.encryptedContent.parameter),m.update(c.encryptedContent.content),!m.finish())throw new Error("Symmetric decryption failed.");c.content=m.output}}return Fr.exports}var Kr={exports:{}},rn;function ms(){if(rn)return Kr.exports;rn=1;var t=le();St(),Ut(),ra(),kt(),pe();var e=Kr.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(y,f,a){a=a||"",f=f||"";var g="ssh-rsa",l=f===""?"none":"aes256-cbc",b="PuTTY-User-Key-File-2: "+g+`\r
|
|
15
|
-
`;b+="Encryption: "+l+`\r
|
|
16
|
-
`,b+="Comment: "+a+`\r
|
|
17
|
-
`;var U=t.util.createBuffer();o(U,g),r(U,y.e),r(U,y.n);var S=t.util.encode64(U.bytes(),64),c=Math.floor(S.length/66)+1;b+="Public-Lines: "+c+`\r
|
|
18
|
-
`,b+=S;var m=t.util.createBuffer();r(m,y.d),r(m,y.p),r(m,y.q),r(m,y.qInv);var E;if(!f)E=t.util.encode64(m.bytes(),64);else{var C=m.length()+16-1;C-=C%16;var s=p(m.bytes());s.truncate(s.length()-C+m.length()),m.putBuffer(s);var h=t.util.createBuffer();h.putBuffer(p("\0\0\0\0",f)),h.putBuffer(p("\0\0\0",f));var v=t.aes.createEncryptionCipher(h.truncate(8),"CBC");v.start(t.util.createBuffer().fillWithByte(0,16)),v.update(m.copy()),v.finish();var A=v.output;A.truncate(16),E=t.util.encode64(A.bytes(),64)}c=Math.floor(E.length/66)+1,b+=`\r
|
|
19
|
-
Private-Lines: `+c+`\r
|
|
20
|
-
`,b+=E;var _=p("putty-private-key-file-mac-key",f),d=t.util.createBuffer();o(d,g),o(d,l),o(d,a),d.putInt32(U.length()),d.putBuffer(U),d.putInt32(m.length()),d.putBuffer(m);var i=t.hmac.create();return i.start("sha1",_),i.update(d.bytes()),b+=`\r
|
|
21
|
-
Private-MAC: `+i.digest().toHex()+`\r
|
|
22
|
-
`,b},e.publicKeyToOpenSSH=function(y,f){var a="ssh-rsa";f=f||"";var g=t.util.createBuffer();return o(g,a),r(g,y.e),r(g,y.n),a+" "+t.util.encode64(g.bytes())+" "+f},e.privateKeyToOpenSSH=function(y,f){return f?t.pki.encryptRsaPrivateKey(y,f,{legacy:!0,algorithm:"aes128"}):t.pki.privateKeyToPem(y)},e.getPublicKeyFingerprint=function(y,f){f=f||{};var a=f.md||t.md.md5.create(),g="ssh-rsa",l=t.util.createBuffer();o(l,g),r(l,y.e),r(l,y.n),a.start(),a.update(l.getBytes());var b=a.digest();if(f.encoding==="hex"){var U=b.toHex();return f.delimiter?U.match(/.{2}/g).join(f.delimiter):U}else{if(f.encoding==="binary")return b.getBytes();if(f.encoding)throw new Error('Unknown encoding "'+f.encoding+'".')}return b};function r(y,f){var a=f.toString(16);a[0]>="8"&&(a="00"+a);var g=t.util.hexToBytes(a);y.putInt32(g.length),y.putBytes(g)}function o(y,f){y.putInt32(f.length),y.putString(f)}function p(){for(var y=t.md.sha1.create(),f=arguments.length,a=0;a<f;++a)y.update(arguments[a]);return y.digest()}return Kr.exports}var Mr,an;function Cs(){return an||(an=1,Mr=le(),St(),ls(),ot(),ta(),$t(),hs(),Ut(),ps(),vs(),ys(),Pn(),na(),Nt(),Dn(),Vn(),gs(),On(),Ln(),Rn(),ia(),it(),_n(),ms(),Fn(),pe()),Mr}var Es=Cs();const xs=is(Es),Mn="limbuild-device-pairing",qn=1,Bt="pairRecords",oa="limbuild-device-signing",ua=1,ct="signingAssets";function lt(t){return(t??"").replace(/-/g,"").replace(/[^a-fA-F0-9]/g,"")}function gt(t){return(t??"").trim()}async function Hn(t){const e=lt(t);if(!e)return;const r=await Pt(Mn,qn,Bt,"udid");return Vt(r.transaction(Bt,"readonly").objectStore(Bt).get(e))}async function Gn(t,e={}){const r=lt(t.udid);if(!r)throw new Error("Cannot store pair record without a UDID.");const o={...t,udid:r,productName:e.productName,updatedAt:new Date().toISOString()},p=await Pt(Mn,qn,Bt,"udid");return await Vt(p.transaction(Bt,"readwrite").objectStore(Bt).put(o)),o}async function zn({deviceUDID:t,bundleID:e}){const r=gt(e);if(!r)return;const o=lt(t),p=await nn(Wr("bundle",r));if(p)return p;if(o){const f=await nn(Wr(o,r));if(f)return f}return(await Qn(r))[0]}async function Yr(){return(await jn()).sort((e,r)=>new Date(r.updatedAt).getTime()-new Date(e.updatedAt).getTime())[0]}async function fa(t){const e=gt(t.bundleID);if(!e)throw new Error("Cannot store signing assets without a bundle ID.");const r=lt(t.deviceUDID),o=Wr("bundle",e),p={...t,id:o,deviceUDID:r||void 0,bundleID:e,updatedAt:new Date().toISOString()},y=await Pt(oa,ua,ct,"id");return await Vt(y.transaction(ct,"readwrite").objectStore(ct).put(p)),p}async function Qn(t){const e=gt(t);return e?(await jn()).filter(o=>o.bundleID===e):[]}function Wt(t,e){const r=lt(e);return!!r&&t.provisionedDevices.some(o=>lt(o)===r)}function Yn(t,e){const r=gt(e),o=gt(t.bundleID);if(!r||!o)return!1;if(o===r||o==="*")return!0;if(!o.endsWith(".*"))return!1;const p=o.slice(0,-1);return r.startsWith(p)}async function Wn(t){const e=new TextDecoder("latin1").decode(await t.arrayBuffer()),r=e.indexOf("<?xml"),o=e.indexOf("</plist>");if(r<0||o<r)throw new Error("Provisioning profile plist not found.");const p=e.slice(r,o+8),y=new DOMParser().parseFromString(p,"application/xml");if(y.querySelector("parsererror"))throw new Error("Provisioning profile plist could not be parsed.");const f=y.querySelector("plist > dict");if(!f)throw new Error("Provisioning profile plist dictionary not found.");const a=ca(f);if(!on(a))throw new Error("Provisioning profile plist has an unexpected shape.");const g=on(a.Entitlements)?a.Entitlements:{},l=_t(g["application-identifier"]),b=Ss(l);return{name:_t(a.Name),uuid:_t(a.UUID),teamID:_t(g["com.apple.developer.team-identifier"])??sn(a.TeamIdentifier)[0],applicationIdentifier:l,bundleID:b,provisionedDevices:sn(a.ProvisionedDevices),expirationDate:_t(a.ExpirationDate)}}async function nn(t){if(!t)return;const e=await Pt(oa,ua,ct,"id");return Vt(e.transaction(ct,"readonly").objectStore(ct).get(t))}async function jn(){const t=await Pt(oa,ua,ct,"id");return Vt(t.transaction(ct,"readonly").objectStore(ct).getAll())}function Wr(t,e){return`${t}:${e}`}function Ss(t){if(!t)return;const e=t.indexOf(".");return e>=0?t.slice(e+1):void 0}function ca(t){switch(t.tagName){case"dict":return bs(t);case"array":return Array.from(t.children).map(ca);case"string":case"date":return t.textContent??"";default:return t.textContent??""}}function bs(t){const e={},r=Array.from(t.children);for(let o=0;o<r.length;o+=2){const p=r[o],y=r[o+1];!p||p.tagName!=="key"||!y||(e[p.textContent??""]=ca(y))}return e}function _t(t){return typeof t=="string"&&t?t:void 0}function sn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function on(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Pt(t,e,r,o){return new Promise((p,y)=>{const f=indexedDB.open(t,e);f.onupgradeneeded=()=>{const a=f.result;a.objectStoreNames.contains(r)||a.createObjectStore(r,{keyPath:o})},f.onsuccess=()=>p(f.result),f.onerror=()=>y(f.error??new Error("Open IndexedDB failed"))})}function Vt(t){return new Promise((e,r)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>r(t.error??new Error("IndexedDB request failed"))})}function $n(){return{method:"POST",path:"/account/listTeams.action",payload:{}}}function Ts({bundleID:t,teamID:e=""}){return Jt("/account/ios/identifiers/listAppIds.action",e,{search:t})}function As({deviceUDID:t,teamID:e=""}){return Jt("/account/ios/device/listDevices.action",e,{search:lt(t)})}function Is(t=""){return Jt("/account/ios/certificate/listCertRequests.action",t)}function Bs({bundleID:t,teamID:e=""}){return Jt("/account/ios/profile/listProvisioningProfiles.action",e,{search:t})}function ws({deviceUDID:t,teamID:e="",name:r="Limrun iPhone"}){return{method:"POST",path:"/account/ios/device/addDevice.action",payload:{teamId:e,name:r,deviceNumber:lt(t),deviceClass:"iphone"}}}function Ns({bundleID:t,teamID:e="",name:r}){return{method:"POST",path:"/account/ios/identifiers/addAppId.action",payload:{teamId:e,name:r??t,identifier:t,type:"explicit"}}}function Rs({csrPEM:t,teamID:e=""}){return{method:"POST",path:"/account/ios/certificate/submitDevelopmentCSR.action",payload:{teamId:e,csrContent:t}}}function _s(t,e=""){return{method:"POST",path:"/account/ios/certificate/downloadCertificateContent.action",payload:{teamId:e,certificateId:t}}}function Ds({bundleID:t,teamID:e="",appIDID:r,certificateID:o,deviceIDs:p,name:y}){return{method:"POST",path:"/account/ios/profile/createProvisioningProfile.action",payload:{teamId:e,appIdId:r,certificateIds:[o],deviceIds:p,distributionMethod:"development",name:y??`Limrun ${t}`,subPlatform:"ios"}}}function Ls(t,e=""){return{method:"POST",path:"/account/ios/profile/downloadProfileContent.action",payload:{teamId:e,provisioningProfileId:t}}}async function Xn({bundleID:t,deviceUDID:e,teamID:r}){const o=await zn({bundleID:t,deviceUDID:e});if(!(!o||!Zn(o,{bundleID:t,deviceUDID:e,teamID:r})))return o}async function Us(t){return fa({...t,certificateFileName:t.certificateID?`${t.certificateID}.p12`:"apple-development.p12",profileFileName:t.profile.uuid?`${t.profile.uuid}.mobileprovision`:"apple-development.mobileprovision"})}function Zn(t,{bundleID:e,deviceUDID:r,teamID:o}){return!Yn(t.profile,e)||o&&t.teamID&&t.teamID!==o||r&&!Wt(t.profile,r)||t.profile.expirationDate&&new Date(t.profile.expirationDate).getTime()<=Date.now()?!1:gt(t.bundleID)===gt(e)}function ks(t){const e=t;return e?.teams?.[0]??e?.provider??e?.availableProviders?.[0]}function Ps(t){const e=t,r=[...e?.teams??[],...e?.provider?[e.provider]:[],...e?.availableProviders??[]],o=new Set;for(const p of r)for(const y of[p.teamId,p.providerId,p.publicProviderId])y!==void 0&&y!==""&&o.add(String(y));return[...o]}function Jt(t,e,r={}){return{method:"POST",path:t,payload:{pageNumber:1,pageSize:200,teamId:e,...r}}}async function Jn(t,e){const r=new URL(`${t}/info`);e&&r.searchParams.set("token",e);const o=await fetch(r.toString(),{headers:e?{Authorization:`Bearer ${e}`}:void 0});if(!o.ok){const p=await o.text();throw new Error(`Info request failed: HTTP ${o.status} ${p}`)}return await o.json()}async function ei({limbuildApiUrl:t,token:e,certificateP12Base64:r,certificatePassword:o,provisioningProfileBase64:p}){const y=new URL(`${t}/exec`);e&&y.searchParams.set("token",e);const f=await fetch(y.toString(),{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify({command:"xcodebuild",xcodebuild:{sdk:"iphoneos"},signing:{certificateP12Base64:r,certificatePassword:o,provisioningProfileBase64:p}})});if(!f.ok){const a=await f.text();throw new Error(`Build request failed: HTTP ${f.status} ${a}`)}return await f.json()}function ti({limbuildApiUrl:t,execId:e,token:r,onLine:o,onStatus:p,onError:y}){const f=new URL(`${t}/exec/${e}/events`);r&&f.searchParams.set("token",r);const a=new EventSource(f.toString());return p("running"),a.addEventListener("command",g=>o({type:"command",data:g.data})),a.addEventListener("stdout",g=>o({type:"stdout",data:g.data})),a.addEventListener("stderr",g=>o({type:"stderr",data:g.data})),a.addEventListener("exitCode",g=>{const l=parseInt(g.data,10);p(l===0?"succeeded":l<0?"cancelled":"failed"),a.close()}),a.onerror=()=>{a.close(),y?.(new Error("Build log stream closed before completion."))},()=>a.close()}const la=1,xt=16,Ye={DeviceHello:1,OpenStream:2,OpenResult:3,StreamData:4,StreamClose:5,InstallProgress:6,Error:7,Ping:8,Pong:9,StartPairing:10,StartInstall:11,PairRecordReady:12};function ri(t){const e=new Uint8Array(xt+t.payload.byteLength),r=new DataView(e.buffer);return r.setUint8(0,la),r.setUint8(1,t.type),r.setUint8(2,0),r.setUint8(3,0),r.setUint32(4,t.requestId),r.setUint32(8,t.streamId),r.setUint32(12,t.payload.byteLength),e.set(t.payload,xt),e}function ai(t){if(t.byteLength<xt)throw new Error(`Relay frame too short: ${t.byteLength}`);const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint8(0);if(r!==la)throw new Error(`Unsupported relay protocol version ${r}`);const o=e.getUint32(12);if(t.byteLength!==xt+o)throw new Error(`Relay frame length mismatch: got ${t.byteLength}, expected ${xt+o}`);return{type:e.getUint8(1),requestId:e.getUint32(4),streamId:e.getUint32(8),payload:t.slice(xt)}}function Et(t){return new TextEncoder().encode(JSON.stringify(t))}function zt(t){return JSON.parse(new TextDecoder().decode(t))}async function ni(){if(!navigator.usb)throw new Error("WebUSB is not available in this browser.");return navigator.usb.requestDevice({filters:[{vendorId:1452}]})}function ii(t){const e=[],r=t.configuration?.configurationValue,o=t.configurations.find(p=>p.configurationValue===r);o&&e.push(...un(o));for(const p of t.configurations)p.configurationValue!==r&&e.push(...un(p));return e}function un(t){const e=[];for(const r of t.interfaces)for(const o of r.alternates)o.interfaceClass===255&&o.interfaceSubclass===254&&o.interfaceProtocol===2&&e.push({configurationValue:t.configurationValue,interfaceNumber:r.interfaceNumber,alternateSetting:o.alternateSetting,endpoints:o.endpoints});return e}async function si(t,e){t.opened||await t.open(),(!t.configuration||t.configuration.configurationValue!==e.configurationValue)&&await t.selectConfiguration(e.configurationValue),await t.claimInterface(e.interfaceNumber),e.alternateSetting!==0&&await t.selectAlternateInterface(e.interfaceNumber,e.alternateSetting)}function oi(t){const e=t.endpoints.find(o=>o.direction==="out"&&o.type==="bulk"),r=t.endpoints.find(o=>o.direction==="in"&&o.type==="bulk");if(!e||!r)throw new Error("Could not find usbmux bulk endpoints.");return{outEndpoint:e,inEndpoint:r}}async function da(t,e,r){const o=await t.transferOut(e.endpointNumber,r);if(o.status!=="ok")throw new Error(`USB transferOut failed: ${o.status}`);r.byteLength%e.packetSize===0&&await t.transferOut(e.endpointNumber,new Uint8Array)}async function ui(t,e,r=16384){const o=await t.transferIn(e.endpointNumber,r);if(o.status!=="ok"||!o.data)throw new Error(`USB transferIn failed: ${o.status}`);return new Uint8Array(o.data.buffer,o.data.byteOffset,o.data.byteLength)}const fi=0,Vs=2,ci=6,Os=4277009102,jr=2,Fs=4,Lt=16,Ks=49152;async function li(t,e){const{inEndpoint:r,outEndpoint:o}=oi(e),p=new Uint8Array(12),y=new DataView(p.buffer);y.setUint32(0,2),y.setUint32(4,0),y.setUint32(8,0),await da(t,o,gi(fi,p));const f=await yi(t,r,1),a=new DataView(f.payload.buffer,f.payload.byteOffset).getUint32(0),g={device:t,candidate:e,inEndpoint:r,outEndpoint:o,muxVersion:a,txSeq:0,rxSeq:65535,nextSport:Ks,streams:new Map,writeChain:Promise.resolve(),closed:!1};return a>=2&&await vi(g,Vs,new Uint8Array([7])),Ms(g),g}async function di(t,e){if(t.closed)throw new Error("usbmux session is closed.");let r,o;const p={session:t,sport:t.nextSport++,dport:e,seq:0,ack:0,queue:[],waiters:[],opened:new Promise((y,f)=>{r=y,o=f}),resolveOpened:r,rejectOpened:o};return t.streams.set($r(e,p.sport),p),await jt(p,jr,new Uint8Array),await p.opened,p}async function hi(t,e){if(t.session.closed)throw new Error("usbmux session is closed.");await jt(t,Lt,e),t.seq+=e.byteLength}async function pi(t){if(t.queue.length>0)return t.queue.shift();if(t.error)throw t.error;return new Promise(e=>{t.waiters.push(e)})}function ha(t){t.closed=!0;for(const e of t.streams.values())for(e.error=new Error("usbmux session closed"),e.rejectOpened(e.error);e.waiters.length>0;)e.waiters.shift()(new Uint8Array);t.streams.clear()}async function jt(t,e,r){const o=new Uint8Array(20+r.byteLength),p=new DataView(o.buffer);p.setUint16(0,t.sport),p.setUint16(2,t.dport),p.setUint32(4,t.seq),p.setUint32(8,t.ack),p.setUint8(12,80),p.setUint8(13,e),p.setUint16(14,512),o.set(r,20),await vi(t.session,ci,o)}async function vi(t,e,r){if(t.closed)throw new Error("usbmux session is closed.");return t.writeChain=t.writeChain.then(async()=>{if(t.closed)return;const o=t.muxVersion>=2?qs(e,r,t.txSeq++,t.rxSeq):gi(e,r);await da(t.device,t.outEndpoint,o)}),t.writeChain}async function Ms(t){try{for(;;){if(t.closed)return;const e=await yi(t.device,t.inEndpoint,t.muxVersion);if(t.closed)return;if(e.rxSeq!==void 0&&(t.rxSeq=e.rxSeq),e.protocol!==ci)continue;const r=Gs(e.payload),o=t.streams.get($r(r.sport,r.dport));if(o){if(r.flags&Fs){for(o.error=new Error(`Device reset stream ${o.dport}`),o.rejectOpened(o.error);o.waiters.length>0;)o.waiters.shift()(new Uint8Array);t.streams.delete($r(o.dport,o.sport));continue}if((r.flags&(jr|Lt))===(jr|Lt)){o.seq+=1,o.ack=r.seq+1,await jt(o,Lt,new Uint8Array),o.resolveOpened();continue}r.payload.byteLength!==0&&(o.ack=r.seq+r.payload.byteLength,await jt(o,Lt,new Uint8Array),o.waiters.length>0?o.waiters.shift()(r.payload):o.queue.push(r.payload))}}}catch{t.closed||ha(t)}}async function yi(t,e,r){for(;;){const o=await ui(t,e),p=Hs(o,r);if(!(r===1&&p.protocol!==fi))return p}}function gi(t,e){const r=new Uint8Array(8+e.byteLength),o=new DataView(r.buffer);return o.setUint32(0,t),o.setUint32(4,r.byteLength),r.set(e,8),r}function qs(t,e,r,o){const p=new Uint8Array(16+e.byteLength),y=new DataView(p.buffer);return y.setUint32(0,t),y.setUint32(4,p.byteLength),y.setUint32(8,Os),y.setUint16(12,r),y.setUint16(14,o),p.set(e,16),p}function Hs(t,e){const r=new DataView(t.buffer,t.byteOffset,t.byteLength),o=r.getUint32(0),p=r.getUint32(4),y=e>=2?16:8;return{protocol:o,length:p,rxSeq:e>=2?r.getUint16(14):void 0,payload:t.slice(y,p)}}function Gs(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=(e.getUint8(12)>>4)*4;return{sport:e.getUint16(0),dport:e.getUint16(2),seq:e.getUint32(4),ack:e.getUint32(8),flags:e.getUint8(13),payload:t.slice(r)}}function $r(t,e){return`${t}:${e}`}class mi{constructor(e,r,o,p){this.webSocketUrl=e,this.session=r,this.deviceHello=o,this.log=p}socket;streams=new Map;frameQueue=Promise.resolve();closed=!1;pairRecordWaiter;async connect(){const e=new WebSocket(this.webSocketUrl);e.binaryType="arraybuffer",this.socket=e,e.onclose=()=>{this.closed=!0,this.log("Relay socket closed"),this.pairRecordWaiter&&(this.pairRecordWaiter.reject(new Error("Relay socket closed")),this.pairRecordWaiter=void 0)},await new Promise((r,o)=>{e.onopen=()=>r(),e.onerror=()=>o(new Error("WebSocket connection failed"))}),e.onmessage=r=>{const o=r.data instanceof ArrayBuffer?new Uint8Array(r.data):new Uint8Array;this.enqueueFrame(o)},await this.send({type:Ye.DeviceHello,requestId:0,streamId:0,payload:Et(this.deviceHello)}),this.log("Connected WebSocket relay")}async startPairing(){const e=new Promise((r,o)=>{this.pairRecordWaiter={resolve:r,reject:o}});return await this.send({type:Ye.StartPairing,requestId:0,streamId:0,payload:Et({})}),this.log("Pairing requested"),e}async startInstall(e){await this.send({type:Ye.StartInstall,requestId:0,streamId:0,payload:Et(e)}),this.log("Installation requested")}close(){this.closed=!0,this.socket?.close()}enqueueFrame(e){this.frameQueue=this.frameQueue.then(()=>this.handleFrame(ai(e))).catch(r=>{this.log("Relay frame handling failed",r instanceof Error?r.message:String(r))})}async handleFrame(e){switch(e.type){case Ye.OpenStream:await this.handleOpenStream(e.requestId,e.streamId,zt(e.payload).port);break;case Ye.StreamData:{const r=this.streams.get(e.streamId);if(!r)throw new Error(`Unknown stream ${e.streamId}`);await hi(r,e.payload);break}case Ye.StreamClose:this.streams.delete(e.streamId);break;case Ye.InstallProgress:this.log(Qs(zt(e.payload).message));break;case Ye.Error:this.handleError(e.payload);break;case Ye.PairRecordReady:this.handlePairRecordReady(zt(e.payload));break;case Ye.Ping:await this.send({type:Ye.Pong,requestId:e.requestId,streamId:0,payload:new Uint8Array});break}}handleError(e){const r=zs(e);this.log("Server error",r),this.pairRecordWaiter&&(this.pairRecordWaiter.reject(new Error(r)),this.pairRecordWaiter=void 0)}handlePairRecordReady(e){this.log("Pair record received",e.udid),this.pairRecordWaiter?.resolve(e),this.pairRecordWaiter=void 0}async handleOpenStream(e,r,o){try{const p=await di(this.session,o);this.streams.set(r,p),await this.send({type:Ye.OpenResult,requestId:e,streamId:r,payload:Et({ok:!0})}),this.log(`Opened device stream ${r} to port ${o}`),this.pumpDeviceToServer(r,p)}catch(p){this.log(`Open device stream ${r} failed`,p instanceof Error?p.message:String(p)),await this.send({type:Ye.OpenResult,requestId:e,streamId:r,payload:Et({ok:!1,error:p instanceof Error?p.message:String(p)})})}}async pumpDeviceToServer(e,r){try{for(;;){const o=await pi(r);if(this.closed)return;await this.send({type:Ye.StreamData,requestId:0,streamId:e,payload:o})}}catch(o){this.log(`Device stream ${e} closed`,o instanceof Error?o.message:String(o)),await this.send({type:Ye.StreamClose,requestId:0,streamId:e,payload:Et({reason:o instanceof Error?o.message:String(o)})})}}async send(e){if(!this.closed){if(!this.socket||this.socket.readyState!==WebSocket.OPEN){this.closed=!0;return}this.socket.send(ri(e))}}}function zs(t){const e=new TextDecoder().decode(t);try{const r=JSON.parse(e);return fn(r.error??e)}catch{return fn(e)}}function fn(t){return t.replace(/libimobiledevice/g,"").trim()}function Qs(t){const e="install status: ";if(!t.startsWith(e))return t;const r=t.slice(e.length),p=new DOMParser().parseFromString(r,"application/xml").querySelector("plist > dict");if(!p)return t;const y=Ys(p),f=y.Status??"Unknown";return`Install progress: ${y.PercentComplete?`${y.PercentComplete}% `:""}${f}`}function Ys(t){const e={},r=Array.from(t.children);for(let o=0;o<r.length;o+=2){const p=r[o],y=r[o+1];!p||p.tagName!=="key"||!y||(e[p.textContent??""]=y.textContent??"")}return e}async function Ci({log:t}){t("Selecting USB device");const e=await ni(),r=js(e);return t("Selected USB device",`${e.manufacturerName??""} ${e.productName??""} ${e.serialNumber??""}`.trim()),r}async function Ei({limbuildApiUrl:t,token:e,log:r,target:o}){const p=pa(t,e);let y;try{y=await Si(p,o,r);const f=await y.startPairing();return{relay:y,pairRecord:f,target:o}}catch(f){throw y?.close(),f}}async function xi({limbuildApiUrl:t,token:e,log:r,target:o,pairRecord:p}){const y=pa(t,e);let f;try{return f=await Si(y,o,r),await f.startInstall(p),f}catch(a){throw f?.close(),a}}async function It(t,e){if(t){if(t.session&&(ha(t.session),t.session=void 0),t.claimedInterfaceNumber!==void 0)try{await t.device.releaseInterface(t.claimedInterfaceNumber),e?.("Released usbmux interface")}catch(r){e?.("USB interface release failed",Xr(r))}finally{t.claimedInterfaceNumber=void 0}if(t.device.opened)try{await t.device.close(),e?.("Closed USB device")}catch(r){e?.("USB device close failed",Xr(r))}}}async function Si(t,e,r){await Ws(e,r);const o=new mi(t,e.session,e.hello,r);return await o.connect(),o}async function Ws(t,e){if(!t.session)try{t.candidate=await $s(t,e),t.session=await li(t.device,t.candidate),e("Created usbmux session")}catch(r){throw await It(t,e),r}}function js(t){return{device:t,candidate:Xs(t),hello:{serialNumber:t.serialNumber,productName:t.productName,manufacturerName:t.manufacturerName,productId:t.productId,vendorId:t.vendorId}}}async function $s(t,e){const r=bi(t.device);if(r.length===0)throw new Error("No Apple usbmux interface found.");let o;for(const p of r)for(const y of[1,2])try{return t.device.opened||await t.device.open(),e("Claiming usbmux interface",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}, alternate ${p.alternateSetting}, attempt ${y}`),await si(t.device,p),t.claimedInterfaceNumber=p.interfaceNumber,e("Claimed usbmux interface",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}`),p}catch(f){o=f,e("USB interface claim failed",`configuration ${p.configurationValue}, interface ${p.interfaceNumber}: ${Xr(f)}`),await Zs(t),await Js(250)}throw o instanceof Error?o:new Error("Unable to claim any Apple usbmux interface.")}function Xs(t){const e=bi(t)[0];if(!e)throw new Error("No Apple usbmux interface found.");return e}function bi(t){const e=ii(t),r=t.configuration?.configurationValue;return[...e.filter(o=>o.configurationValue===r),...e.filter(o=>o.configurationValue!==r)]}function pa(t,e){const r=new URL(t);return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname=`${r.pathname.replace(/\/$/,"")}/device/ws`,e&&r.searchParams.set("token",e),r.toString()}function Xr(t){return t instanceof Error?t.message:String(t)}async function Zs(t){if(t.claimedInterfaceNumber!==void 0){try{await t.device.releaseInterface(t.claimedInterfaceNumber)}catch{}t.claimedInterfaceNumber=void 0}if(t.device.opened)try{await t.device.close()}catch{}}function Js(t){return new Promise(e=>setTimeout(e,t))}const eo={build:"idle",usb:"idle",pair:"idle",install:"idle"};function to({apiUrl:t,token:e}){const[r,o]=he.useState("build"),[p,y]=he.useState(eo),[f,a]=he.useState(),[g,l]=he.useState(),[b,U]=he.useState(),[S,c]=he.useState(["Ready. Start a signed device build, allow USB access, pair this browser, then install."]),[m,E]=he.useState([]),[C,s]=he.useState("idle"),[h,v]=he.useState("idle"),[A,_]=he.useState([]),[d,i]=he.useState(),[n,I]=he.useState(!1),[L,O]=he.useState(),[k,F]=he.useState(),[H,q]=he.useState(!1),[G,Y]=he.useState({}),X=he.useRef(void 0),te=he.useRef(void 0),ie=he.useRef(void 0),se=he.useRef(void 0),ae=he.useCallback((V,K)=>{const j=K?`${V}
|
|
23
|
-
${K}`:V;c(Z=>[j,...Z].slice(0,100))},[]),ue=he.useCallback((V,K)=>{y(j=>({...j,[V]:K}))},[]),ce=he.useCallback(V=>{Y(K=>({...K,...V})),U(void 0)},[]);he.useEffect(()=>{te.current=f},[f]);const $=he.useCallback(async()=>{X.current?.close(),X.current=void 0,await It(te.current,ae)},[ae]);he.useEffect(()=>()=>{ie.current?.(),se.current?.close(),$()},[$]);const J=he.useCallback(async()=>{const V=t?await ro(t,e).catch(()=>{}):void 0;if(V?.lastBuildConfig?.bundleId){const de=await Xn({bundleID:V.lastBuildConfig.bundleId,deviceUDID:f?.hello.serialNumber,teamID:d});if(de)return v("using-cached-profile"),ae("Using cached Apple signing profile",de.bundleID),U(de),de}const K=await Yr();if(K)return ae("Using stored signing assets",K.bundleID),U(K),K;if(!G.certificateFile||!G.provisioningProfileFile||!G.certificatePassword)throw new Error("Upload a certificate, provisioning profile, and certificate password.");ae("Preparing signing assets");const[j,Z,z]=await Promise.all([ln(G.certificateFile),ln(G.provisioningProfileFile),Wn(G.provisioningProfileFile)]);if(f?.hello.serialNumber&&!Wt(z,f.hello.serialNumber))throw new Error("Provisioning profile does not include the selected iPhone.");const ee=z.bundleID??z.applicationIdentifier??G.provisioningProfileFile.name,oe=await fa({deviceUDID:f?.hello.serialNumber,bundleID:ee,certificateP12Base64:j,certificateFileName:G.certificateFile.name,certificatePassword:G.certificatePassword,provisioningProfileBase64:Z,profileFileName:G.provisioningProfileFile.name,profile:z});return U(oe),ae("Signing assets stored locally",ee),oe},[t,ae,d,f?.hello.serialNumber,G,e]),Ge=he.useCallback(async({accountName:V,password:K})=>{if(t){O("build"),F(void 0),v("authenticating");try{await se.current?.close().catch(()=>{});const j=await Bn({limbuildApiUrl:t,token:e,accountName:V,password:K});se.current=j,j.requiresTwoFactor||(await j.finalize(),await cn(t,j.appleSessionId,e,_,i)),v(j.requiresTwoFactor?"two-factor-required":"authenticated"),ae(j.requiresTwoFactor?"Apple ID requires two-factor authentication":"Apple ID authenticated",V)}catch(j){const Z=Ct(j);F(Z),v("error"),ae("Apple ID authentication failed",Z)}finally{O(void 0)}}},[t,ae,e]),be=he.useCallback(async V=>{const K=se.current;if(!K)throw new Error("Start Apple ID login before submitting a two-factor code.");O("build"),F(void 0);try{await K.finishTwoFactor(V),await K.finalize(),t&&await cn(t,K.appleSessionId,e,_,i),v("authenticated"),ae("Apple ID two-factor authentication accepted")}catch(j){const Z=Ct(j);F(Z),v("error"),ae("Apple ID two-factor authentication failed",Z)}finally{O(void 0)}},[t,ae,e]),x=he.useCallback(async()=>{await se.current?.close().catch(()=>{}),se.current=void 0,_([]),i(void 0),v("idle"),ae("Apple ID session cleared")},[ae]),D=he.useCallback(async()=>{if(t){O("build"),F(void 0),o("build"),ue("build","active"),I(!0),E([]),s("queued"),ie.current?.();try{const V=await J();ae("Starting signed device build");const K=await ei({limbuildApiUrl:t,token:e,certificateP12Base64:V.certificateP12Base64,certificatePassword:V.certificatePassword,provisioningProfileBase64:V.provisioningProfileBase64});if(!K.execId)throw new Error("Build request did not return an exec ID.");ae("Signed device build started",K.execId),ie.current=ti({limbuildApiUrl:t,execId:K.execId,token:e,onLine:j=>E(Z=>[...Z,j]),onStatus:j=>{s(j),j==="succeeded"?(ue("build","complete"),o("usb")):(j==="failed"||j==="cancelled")&&ue("build","error")},onError:j=>{const Z=Ct(j);F(Z),ae("Build log stream failed",Z)}})}catch(V){const K=Ct(V);F(K),s("failed"),ue("build","error"),ae("Signed device build failed",K)}finally{O(void 0)}}},[t,ae,J,ue,e]),R=he.useCallback(async()=>{O("usb"),F(void 0),o("usb"),ue("usb","active");try{await $();const V=await Ci({log:ae});a(V),q(!1);const K=await Hn(V.hello.serialNumber);l(K);const j=await Yr();if(j){if(!Wt(j.profile,V.hello.serialNumber))throw new Error("Stored provisioning profile does not include the selected iPhone.");U(j)}ue("usb","complete"),o(K?"install":"pair"),ae(K?"Pair record found":"No pair record found",V.hello.serialNumber)}catch(V){const K=Ct(V);F(K),ue("usb","error"),ae("USB access failed",K)}finally{O(void 0)}},[$,ae,ue]),N=he.useCallback(async()=>{if(!(!t||!f)){O("pair"),F(void 0),q(!1),o("pair"),ue("pair","active");try{await $();const V=await Ei({limbuildApiUrl:t,token:e,log:ae,target:f}),K=await Gn(V.pairRecord,{productName:f.hello.productName});V.relay.close(),await It(f,ae),l(K),q(!1),ue("pair","complete"),o("install"),ae("Device paired","The pair record was stored locally in this browser.")}catch(V){await It(f,ae);const K=Ct(V);q(!0),F("Unlock the iPhone, tap Trust, then confirm the pair record."),ue("pair","error"),ae("Device pairing failed",K)}finally{O(void 0)}}},[t,$,ae,f,ue,e]),u=he.useCallback(async()=>{if(!(!t||!f||!g)){O("install"),F(void 0),o("install"),ue("install","active");try{await $(),X.current=await xi({limbuildApiUrl:t,token:e,log:ae,target:f,pairRecord:g}),ue("install","complete"),ae("Device install started","Installation will continue through the connected iPhone.")}catch(V){await It(f,ae);const K=Ct(V);F(K),ue("install","error"),ae("Device install relay failed",K)}finally{O(void 0)}}},[t,$,ae,g,f,ue,e]),w=he.useCallback(()=>{$(),ae("Device relay stopped")},[$,ae]);return{currentStep:r,stepStatuses:p,device:f?.hello,hasPairRecord:!!g,hasSigningAssets:!!b,pairConfirmationRequired:H,logs:S,buildLogs:m,buildStatus:C,appleSigningStatus:h,appleTeams:A,selectedAppleTeamID:d,buildLogPanelOpen:n,busyAction:L,error:k,canBuild:!!t&&!L,canRequestUSBAccess:!L&&(C==="succeeded"||p.build==="complete"),canPairBrowser:!!t&&!L&&!!f,canInstall:!!t&&!L&&!!f&&!!g,setSigningFiles:ce,setBuildLogPanelOpen:I,startAppleIDLogin:Ge,submitAppleTwoFactorCode:be,setSelectedAppleTeamID:i,clearAppleIDSession:x,startDeviceBuild:D,requestUSBAccess:R,pairBrowser:N,startInstallation:u,stopRelay:w}}async function ro(t,e){return Jn(t,e)}async function cn(t,e,r,o,p){const y=await An(t,e,$n(),r),f=[...y.body?.teams??[],...y.body?.availableProviders??[],...y.body?.provider?[y.body.provider]:[]];o(f);const a=ao(f[0]);a&&p(a)}function ao(t){const e=t?.teamId??t?.providerId??t?.publicProviderId;return e===void 0||e===""?void 0:String(e)}async function ln(t){const e=await t.arrayBuffer();let r="";const o=new Uint8Array(e);for(const p of o)r+=String.fromCharCode(p);return btoa(r)}function Ct(t){return t instanceof Error?t.message:String(t)}exports.AppleGsaSrpClient=Cn;exports.RELAY_HEADER_BYTES=xt;exports.RELAY_PROTOCOL_VERSION=la;exports.RelayClient=mi;exports.RelayMessageType=Ye;exports.claimUsbmux=si;exports.closeDeviceRelayTarget=It;exports.closeUsbmuxSession=ha;exports.createAppleRelaySession=En;exports.createBundleIDRequest=Ns;exports.createDevelopmentProfileRequest=Ds;exports.createUsbmuxSession=li;exports.decodeFrame=ai;exports.decodeJson=zt;exports.deleteAppleRelaySession=Qr;exports.deviceRelayWebSocketUrl=pa;exports.downloadCertificateRequest=_s;exports.downloadProfileRequest=Ls;exports.encodeFrame=ri;exports.encodeJson=Et;exports.fetchLimbuildInfo=Jn;exports.finalizeAppleRelaySession=Tn;exports.findBundleIDRequest=Ts;exports.findDevelopmentCertificatesRequest=Is;exports.findDevelopmentProfilesRequest=Bs;exports.findDeviceRequest=As;exports.findSigningAssetsForBundle=Qn;exports.findUsbmuxCandidates=ii;exports.forge=xs;exports.getBulkEndpoints=oi;exports.getLatestSigningAssets=Yr;exports.getPairRecord=Hn;exports.getReusableAppleSigningAssets=Xn;exports.getSigningAssets=zn;exports.listTeamsRequest=$n;exports.normalizeBundleID=gt;exports.normalizeUDID=lt;exports.openStream=di;exports.parseProvisioningProfile=Wn;exports.profileContainsDevice=Wt;exports.profileMatchesBundleID=Yn;exports.proxyProvisioningRequest=An;exports.proxySrpComplete=Sn;exports.proxySrpInit=xn;exports.proxyTwoFactorCode=bn;exports.putAppleGeneratedSigningAssets=Us;exports.putPairRecord=Gn;exports.putSigningAssets=fa;exports.receiveStreamData=pi;exports.registerDeviceRequest=ws;exports.relayAppleRequest=yt;exports.requestAppleDevice=ni;exports.requestUSBAccess=Ci;exports.selectDeveloperPortalTeam=ks;exports.sendStreamData=hi;exports.startBrowserOwnedAppleIDLogin=Bn;exports.startInstallRelay=xi;exports.startPairingRelay=Ei;exports.startSignedDeviceBuild=ei;exports.storedSigningAssetsReusable=Zn;exports.submitDevelopmentCSRRequest=Rs;exports.teamIDCandidates=Ps;exports.transferIn=ui;exports.transferOutWithZlp=da;exports.useDeviceInstall=to;exports.watchBuildLogEvents=ti;
|