iflow-engine-base 3.9.211 → 3.9.222

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,22 @@
1
- (function(o,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("three"),require("@mkkellogg/gaussian-splats-3d")):typeof define=="function"&&define.amd?define(["exports","three","@mkkellogg/gaussian-splats-3d"],u):(o=typeof globalThis<"u"?globalThis:o||self,u(o.Gaussian={},o.THREE,o.GaussianSplats3D))})(this,(function(o,u,x){"use strict";function I(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const d=I(u),T=I(x);var l=(n=>(n.LoadStart="gaussian-load-start",n.LoadProgress="gaussian-load-progress",n.Loaded="gaussian-loaded",n.LoadError="gaussian-load-error",n.SceneRemoved="gaussian-scene-removed",n.FpsUpdated="gaussian-fps-updated",n.ViewChanged="gaussian-view-changed",n))(l||{});class P{listeners=new Map;on(e,t){const i=String(e);this.listeners.has(i)||this.listeners.set(i,[]),this.listeners.get(i).push(t)}off(e,t){const i=String(e),r=this.listeners.get(i);if(!r)return;const s=r.indexOf(t);s!==-1&&r.splice(s,1),r.length===0&&this.listeners.delete(i)}trigger(e,t){const i=this.listeners.get(String(e));!i||i.length===0||[...i].forEach(r=>{try{r(t)}catch(s){console.error(`[EventModuleGaussian] event handler failed: ${e}`,s)}})}clear(){this.listeners.clear()}dispose(){this.clear()}}class O{scene;constructor(e){this.scene=new d.Scene,e&&(this.scene.background=new d.Color(e))}getScene(){return this.scene}setBackgroundColor(e){this.scene.background=e==null?null:new d.Color(e)}dispose(){this.scene.clear(),this.scene.background=null,this.scene.environment=null}}class z{camera;container;cameraUp;initialLookAt;constructor(e,t,i,r){this.container=e,this.cameraUp=t,this.initialLookAt=r,this.camera=this.createCamera(i)}createCamera(e){const t=Math.max(this.container.clientWidth,1),i=Math.max(this.container.clientHeight,1),r=new d.PerspectiveCamera(65,t/i,.1,5e3);return r.position.fromArray(e),r.up.fromArray(this.cameraUp).normalize(),r.lookAt(new d.Vector3().fromArray(this.initialLookAt)),r.updateProjectionMatrix(),r}getCamera(){return this.camera}updateAspectRatio(e,t){this.camera.aspect=Math.max(e,1)/Math.max(t,1),this.camera.updateProjectionMatrix()}reset(e,t){e&&this.camera.position.fromArray(e),this.camera.lookAt(new d.Vector3().fromArray(t??this.initialLookAt)),this.camera.updateMatrixWorld(!0)}dispose(){this.camera=null}}const L="iflowbim.cn",U=512,F=128,D=150,_=38,w=290,S=190;class K{THREE;text;scene;camera;material;sprites=[];size;viewportWidth=0;viewportHeight=0;constructor(e,t=L){this.THREE=e,this.text=t,this.scene=new e.Scene,this.camera=new e.OrthographicCamera(0,1,1,0,-10,10),this.material=new e.SpriteMaterial({map:new e.CanvasTexture(this.createTextTexture()),transparent:!0,opacity:.46,depthTest:!1,depthWrite:!1,toneMapped:!1}),this.size=new e.Vector2}render(e){}dispose(){this.material.map?.dispose?.(),this.material.dispose?.(),this.sprites.length=0}createTextTexture(){const e=document.createElement("canvas");e.width=U,e.height=F;const t=e.getContext("2d");return t&&(t.clearRect(0,0,e.width,e.height),t.textAlign="center",t.textBaseline="middle",t.font="600 54px Arial, Helvetica, sans-serif",t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.20)",t.fillStyle="rgba(255, 255, 255, 0.24)",t.strokeText(this.text,e.width/2,e.height/2),t.fillText(this.text,e.width/2,e.height/2)),e}updateLayout(e,t){if(e===this.viewportWidth&&t===this.viewportHeight)return;this.viewportWidth=e,this.viewportHeight=t,this.camera.left=-e/2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=-t/2,this.camera.updateProjectionMatrix();const i=Math.ceil(e/w)+2,r=Math.ceil(t/S)+2,s=i*r;this.ensureSpriteCount(s);let a=0;const h=-e/2-w/2,R=-t/2-S/2;for(let c=0;c<r;c+=1)for(let g=0;g<i;g+=1){const y=this.sprites[a],oe=h+g*w+c%2*(w/2),ce=R+c*S;y.position.set(oe,ce,0),y.visible=!0,a+=1}for(let c=a;c<this.sprites.length;c+=1)this.sprites[c].visible=!1}ensureSpriteCount(e){for(;this.sprites.length<e;){const t=new this.THREE.Sprite(this.material);t.scale.set(D,_,1),t.rotation.z=-.32,t.renderOrder=999999,this.scene.add(t),this.sprites.push(t)}}}class W{renderer;viewer;container;animationId=null;isRenderingPaused=!0;fpsFrameCount=0;fpsLastTime=performance.now();fpsInfo={fps:0,frameTimeMs:0,minFps:0};watermark;onBeforeRenderCallback;onAfterRenderCallback;onFpsUpdatedCallback;constructor(e,t,i,r){this.container=e,this.renderer=this.createRenderer(r.antialias),this.watermark=new K(d),this.viewer=new T.Viewer({selfDrivenMode:!1,renderer:this.renderer,camera:i,threeScene:t,rootElement:e,useBuiltInControls:!0,cameraUp:r.cameraUp,initialCameraPosition:r.initialCameraPosition,initialCameraLookAt:r.initialCameraLookAt,sharedMemoryForWorkers:r.sharedMemoryForWorkers,gpuAcceleratedSort:r.gpuAcceleratedSort,sphericalHarmonicsDegree:r.sphericalHarmonicsDegree,...r.viewerOptions??{}})}createRenderer(e){const t=new d.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1});return t.setSize(Math.max(this.container.clientWidth,1),Math.max(this.container.clientHeight,1)),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}setOnFpsUpdated(e){this.onFpsUpdatedCallback=e}startRenderLoop(){this.animationId===null&&(this.isRenderingPaused=!1,this.animate())}animate(){if(this.isRenderingPaused){this.animationId=null;return}this.animationId=requestAnimationFrame(()=>this.animate()),this.render()}render(){this.onBeforeRenderCallback?.(),this.viewer.update(this.renderer),this.viewer.render(),this.watermark.render(this.renderer),this.onAfterRenderCallback?.(),this.updateFps()}updateFps(){this.fpsFrameCount++;const e=performance.now(),t=e-this.fpsLastTime;if(t<1e3)return;const i=Math.round(this.fpsFrameCount*1e3/t);this.fpsInfo={fps:i,frameTimeMs:i>0?1e3/i:0,minFps:this.fpsInfo.minFps===0?i:Math.min(this.fpsInfo.minFps,i)},this.fpsFrameCount=0,this.fpsLastTime=e,this.onFpsUpdatedCallback?.({...this.fpsInfo})}resetFpsStats(){this.fpsInfo={fps:0,frameTimeMs:0,minFps:0},this.fpsFrameCount=0,this.fpsLastTime=performance.now()}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(){this.isRenderingPaused&&this.startRenderLoop()}isRenderingPausedState(){return this.isRenderingPaused}resize(e,t){this.renderer.setSize(Math.max(e,1),Math.max(t,1)),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getViewer(){return this.viewer}getRenderer(){return this.renderer}getDomElement(){return this.renderer.domElement}getFpsInfo(){return{...this.fpsInfo}}async dispose(){this.pauseRendering(),await this.viewer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.watermark.dispose(),this.renderer.dispose(),this.renderer.forceContextLoss()}}const H={identity:[0,0,0,1],"x-90":[-.7071068,0,0,.7071068],x90:[.7071068,0,0,.7071068],x180:[1,0,0,0],"y-90":[0,-.7071068,0,.7071068],y90:[0,.7071068,0,.7071068],"z-90":[0,0,-.7071068,.7071068],z90:[0,0,.7071068,.7071068],z180:[0,0,1,0]};class G{orientationPreset;constructor(e="x180"){this.orientationPreset=e}setOrientationPreset(e){this.orientationPreset=e}getOrientationPreset(){return this.orientationPreset}getOrientationRotation(){return[...H[this.orientationPreset]]}active(){}disActive(){}update(){}dispose(){}}function B(n,e){return`${n}#${e}`}class j{viewer;getDefaultRotation;scenes=new Map;constructor(e,t){this.viewer=e,this.getDefaultRotation=t}async loadModel(e,t={}){const i=this.viewer.getSceneCount(),r={showLoadingUI:!0,progressiveLoad:!1,position:[0,0,0],rotation:this.getDefaultRotation(),scale:[1,1,1],...t};await this.viewer.addSplatScene(e,r);const s={id:r.id??B(e,i),name:r.name??e.split(/[\\/]/).pop()??e,url:e,index:i,options:r};return this.scenes.set(s.id,s),s}async loadModels(e){const t=[];for(const i of e)t.push(await this.loadModel(i.url,i.options));return t}async unloadModel(e,t=!0){const i=this.scenes.get(e);i&&(await this.viewer.removeSplatScene(i.index,t),this.scenes.delete(e),this.reindexScenesAfterRemove(i.index))}getModel(e){return this.scenes.get(e)}getAllModels(){return Array.from(this.scenes.values())}getRawSplatScene(e){const t=typeof e=="number"?e:this.scenes.get(e)?.index;return t==null?void 0:this.viewer.getSplatScene(t)}async clear(e=!1){const t=this.getAllModels().map(i=>i.index);t.length>0&&await this.viewer.removeSplatScenes(t,e),this.scenes.clear()}reindexScenesAfterRemove(e){this.scenes.forEach(t=>{t.index>e&&(t.index-=1)})}}const p={version:"3.9.21"}.version;function v(){const n=globalThis.crypto?.subtle;if(!n)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return n}function m(n){return new TextEncoder().encode(n)}function f(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}function E(n){let e="";return n.forEach(t=>{e+=String.fromCharCode(t)}),btoa(e)}function V(n){const e=n.getUTCFullYear(),t=String(n.getUTCMonth()+1).padStart(2,"0"),i=String(n.getUTCDate()).padStart(2,"0");return`${e}${t}${i}`}async function $(n){const e=await v().digest("SHA-256",f(m(n)));return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function N(n,e){const t=v(),i=await t.importKey("raw",f(n),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return t.sign("HMAC",i,f(m(e)))}function q(n){return m([n.appId,n.engineType,n.requestDate,String(n.timestamp),n.nonce].join("|"))}async function J(n){const e=v(),t=new Date,i=t.getTime(),r=V(t),s=globalThis.crypto.randomUUID(),a=globalThis.crypto.getRandomValues(new Uint8Array(12)),h=await $(n.appSecret),R=await N(m(h),r),c=await e.importKey("raw",R,"AES-GCM",!1,["encrypt"]),g=JSON.stringify({appKey:n.appKey,appSecret:n.appSecret}),y=await e.encrypt({name:"AES-GCM",iv:a,additionalData:f(q({appId:n.appId,engineType:n.engineType,requestDate:r,timestamp:i,nonce:s})),tagLength:128},c,f(m(g)));return{appId:n.appId,engineType:n.engineType,requestDate:r,timestamp:i,nonce:s,iv:E(a),cipherText:E(new Uint8Array(y)),sdkVersion:n.sdkVersion,origin:n.origin,product:n.product}}const A=new Map;function M(n){return n.replace(/\/+$/,"")}function k(n){if(n)return n;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function X(n,e){return JSON.stringify({endpoint:M(n.endpoint),token:n.token??"",appId:n.appId??"",appKey:n.appKey??"",appSecret:n.appSecret??"",origin:k(n.origin)??"",product:n.product??"",engineType:e,sdkVersion:p})}async function C(n,e,t){const i=typeof AbortController<"u"?new AbortController:void 0,r=i?setTimeout(()=>i.abort(),t):void 0;try{const s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:i?.signal}),a=await s.json().catch(()=>({}));if(!s.ok){const h=a?.error?.message??a?.message??`SDK authentication failed with status ${s.status}`;throw new Error(h)}return a}finally{r!=null&&clearTimeout(r)}}async function Y(n,e){const t=await C(`${M(n.endpoint)}/oauth/sdk-verify`,{sdkToken:n.token,engineType:e,sdkVersion:p,origin:k(n.origin),product:n.product},n.timeoutMs??8e3);return t.sdkToken=n.token,t}async function Q(n,e){const t=await J({appId:n.appId,appKey:n.appKey,appSecret:n.appSecret,engineType:e,sdkVersion:p,origin:k(n.origin),product:n.product}),i=await C(`${M(n.endpoint)}/oauth/sdk-token/secure`,t,n.timeoutMs??8e3),r=await C(`${M(n.endpoint)}/oauth/sdk-verify`,{sdkToken:i.sdkToken,engineType:e,sdkVersion:p,origin:k(n.origin),product:n.product},n.timeoutMs??8e3);return r.sdkToken=i.sdkToken,r}async function Z(n,e){const t=n?.sdkAuth;if(!t)return null;if(!t.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!t.token&&!(t.appId&&t.appKey&&t.appSecret))return null;const i=X(t,e),r=A.get(i);if(r){const a=await r;return n&&(n.__sdkAuthSession=a),a}const s=(t.token?Y(t,e):Q(t,e)).then(a=>{if(a.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return n&&(n.__sdkAuthSession=a),a}).catch(a=>{throw A.delete(i),a});return A.set(i,s),s}function ee(n){return n.replace(/\/+$/,"")}async function te(n,e,t){const i=typeof AbortController<"u"?new AbortController:void 0,r=i?setTimeout(()=>i.abort(),t):void 0;try{const s=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:i?.signal}),a=await s.json().catch(()=>({}));if(!s.ok){const h=a?.error?.message??a?.message??`ViewToken resolve failed with status ${s.status}`;throw new Error(h)}return a}finally{r!=null&&clearTimeout(r)}}function ne(n){switch(n){case"2d":return"cad_model";case"720":return"panorama";case"gis":return"gis_scene";case"gaussian":return"gaussian_model";case"3d":default:return"model"}}function ie(n){return{models:[{modelType:n.toLowerCase().endsWith(".json")?"3dtiles":"glb",url:n}]}}function re(n,e){return{applicationId:0,engineType:e,assetCategory:ne(e),url:n,urls:[n],info:e==="gis"?ie(n):void 0}}async function se(n,e,t){const i=n?.sdkAuth;if(!i?.endpoint)return re(e,t);let r;(i.token||i.appId&&i.appKey&&i.appSecret)&&(r=(await Z(n,t))?.sdkToken);const s={viewToken:e,engineType:t};return r&&(s.sdkToken=r),te(`${ee(i.endpoint)}/models/view-token/resolve`,s,i.timeoutMs??8e3)}class b{eventModule;sceneModule;cameraModule;renderModule;controlModule;loaderModule;isInitialized=!1;options;version=p;constructor(e){this.options=e,this.initialize(e)}initialize(e){const t={containerId:e.containerId,cameraUp:e.cameraUp??[0,1,0],initialCameraPosition:e.initialCameraPosition??[0,0,6],initialCameraLookAt:e.initialCameraLookAt??[0,0,0],backgroundColor:e.backgroundColor,antialias:e.antialias??!1,showLoadingUI:e.showLoadingUI??!0,sharedMemoryForWorkers:e.sharedMemoryForWorkers??!1,gpuAcceleratedSort:e.gpuAcceleratedSort??!1,sphericalHarmonicsDegree:e.sphericalHarmonicsDegree??0,orientationPreset:e.orientationPreset??"x180",viewerOptions:e.viewerOptions},i=document.getElementById(t.containerId);if(!i)throw new Error(`Container with id "${t.containerId}" not found`);this.eventModule=new P,this.sceneModule=new O(t.backgroundColor),this.cameraModule=new z(i,t.cameraUp,t.initialCameraPosition,t.initialCameraLookAt),this.controlModule=new G(t.orientationPreset),this.renderModule=new W(i,this.sceneModule.getScene(),this.cameraModule.getCamera(),t),this.loaderModule=new j(this.renderModule.getViewer(),()=>this.controlModule.getOrientationRotation()),this.renderModule.setOnBeforeRender(()=>{this.controlModule.update()}),this.renderModule.setOnFpsUpdated(r=>{this.eventModule.trigger(l.FpsUpdated,r)}),this.renderModule.startRenderLoop(),this.isInitialized=!0}async loadModel(e,t={}){this.checkInitialized(),this.eventModule.trigger(l.LoadStart,{url:e,name:t.name});try{const i=await this.loaderModule.loadModel(e,{showLoadingUI:!0,...t,onProgress:(r,s,a)=>{this.eventModule.trigger(l.LoadProgress,{url:e,name:t.name,progress:r}),t.onProgress?.(r,s,a)}});return this.eventModule.trigger(l.Loaded,{url:e,name:i.name,progress:100}),i}catch(i){throw this.eventModule.trigger(l.LoadError,{url:e,name:t.name,error:i instanceof Error?i:new Error(String(i))}),i}}async loadModelByViewToken(e,t={}){const i=await se(this.options,e,"gaussian");if(i.assetCategory==="composite_model"&&i.urls.length>1)throw new Error("EngineKernelGaussian: composite_model viewToken is not supported");return this.loadModel(i.url,t)}async unloadModel(e){this.checkInitialized(),await this.loaderModule.unloadModel(e,!1),this.eventModule.trigger(l.SceneRemoved,{id:e})}setOrientationPreset(e){this.checkInitialized(),this.controlModule.setOrientationPreset(e)}getOrientationPreset(){return this.checkInitialized(),this.controlModule.getOrientationPreset()}resize(e,t){this.checkInitialized();const i=this.renderModule.getDomElement(),r=e??i.parentElement?.clientWidth??i.clientWidth,s=t??i.parentElement?.clientHeight??i.clientHeight;this.renderModule.resize(r,s),this.cameraModule.updateAspectRatio(r,s)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering()}resetFpsStats(){this.checkInitialized(),this.renderModule.resetFpsStats()}getFpsInfo(){return this.checkInitialized(),this.renderModule.getFpsInfo()}on(e,t){this.checkInitialized(),this.eventModule.on(e,t)}off(e,t){this.checkInitialized(),this.eventModule.off(e,t)}getVersion(){return this.version}async dispose(){this.isInitialized&&(await this.loaderModule.clear(!1),await this.renderModule.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1)}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernelGaussian: Not initialized")}}function ae(n){return new b(n)}o.GaussianSplats3D=T,o.EngineKernelGaussian=b,o.EventTypeGaussian=l,o.createEngineGaussian=ae,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(Ze,St){typeof exports=="object"&&typeof module<"u"?St(exports,require("three"),require("@mkkellogg/gaussian-splats-3d")):typeof define=="function"&&define.amd?define(["exports","three","@mkkellogg/gaussian-splats-3d"],St):(Ze=typeof globalThis<"u"?globalThis:Ze||self,St(Ze.Gaussian={},Ze.THREE,Ze.GaussianSplats3D))})(this,(function(Ze,St,vn){"use strict";function ta(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const lt=ta(St),ra=ta(vn);var ft=(t=>(t.LoadStart="gaussian-load-start",t.LoadProgress="gaussian-load-progress",t.Loaded="gaussian-loaded",t.LoadError="gaussian-load-error",t.SceneRemoved="gaussian-scene-removed",t.FpsUpdated="gaussian-fps-updated",t.ViewChanged="gaussian-view-changed",t))(ft||{});class yn{listeners=new Map;on(e,r){const o=String(e);this.listeners.has(o)||this.listeners.set(o,[]),this.listeners.get(o).push(r)}off(e,r){const o=String(e),E=this.listeners.get(o);if(!E)return;const y=E.indexOf(r);y!==-1&&E.splice(y,1),E.length===0&&this.listeners.delete(o)}trigger(e,r){const o=this.listeners.get(String(e));!o||o.length===0||[...o].forEach(E=>{try{E(r)}catch(y){console.error(`[EventModuleGaussian] event handler failed: ${e}`,y)}})}clear(){this.listeners.clear()}dispose(){this.clear()}}class mn{scene;constructor(e){this.scene=new lt.Scene,e&&(this.scene.background=new lt.Color(e))}getScene(){return this.scene}setBackgroundColor(e){this.scene.background=e==null?null:new lt.Color(e)}dispose(){this.scene.clear(),this.scene.background=null,this.scene.environment=null}}class Cn{camera;container;cameraUp;initialLookAt;constructor(e,r,o,E){this.container=e,this.cameraUp=r,this.initialLookAt=E,this.camera=this.createCamera(o)}createCamera(e){const r=Math.max(this.container.clientWidth,1),o=Math.max(this.container.clientHeight,1),E=new lt.PerspectiveCamera(65,r/o,.1,5e3);return E.position.fromArray(e),E.up.fromArray(this.cameraUp).normalize(),E.lookAt(new lt.Vector3().fromArray(this.initialLookAt)),E.updateProjectionMatrix(),E}getCamera(){return this.camera}updateAspectRatio(e,r){this.camera.aspect=Math.max(e,1)/Math.max(r,1),this.camera.updateProjectionMatrix()}reset(e,r){e&&this.camera.position.fromArray(e),this.camera.lookAt(new lt.Vector3().fromArray(r??this.initialLookAt)),this.camera.updateMatrixWorld(!0)}dispose(){this.camera=null}}const En="iflowbim.cn",xn=512,Sn=128,Tn=150,An=38,kt=290,$t=190;class In{THREE;text;scene;camera;material;sprites=[];size;viewportWidth=0;viewportHeight=0;constructor(e,r=En){this.THREE=e,this.text=r,this.scene=new e.Scene,this.camera=new e.OrthographicCamera(0,1,1,0,-10,10),this.material=new e.SpriteMaterial({map:new e.CanvasTexture(this.createTextTexture()),transparent:!0,opacity:.46,depthTest:!1,depthWrite:!1,toneMapped:!1}),this.size=new e.Vector2}render(e){}dispose(){this.material.map?.dispose?.(),this.material.dispose?.(),this.sprites.length=0}createTextTexture(){const e=document.createElement("canvas");e.width=xn,e.height=Sn;const r=e.getContext("2d");return r&&(r.clearRect(0,0,e.width,e.height),r.textAlign="center",r.textBaseline="middle",r.font="600 54px Arial, Helvetica, sans-serif",r.lineWidth=3,r.strokeStyle="rgba(0, 0, 0, 0.20)",r.fillStyle="rgba(255, 255, 255, 0.24)",r.strokeText(this.text,e.width/2,e.height/2),r.fillText(this.text,e.width/2,e.height/2)),e}updateLayout(e,r){if(e===this.viewportWidth&&r===this.viewportHeight)return;this.viewportWidth=e,this.viewportHeight=r,this.camera.left=-e/2,this.camera.right=e/2,this.camera.top=r/2,this.camera.bottom=-r/2,this.camera.updateProjectionMatrix();const o=Math.ceil(e/kt)+2,E=Math.ceil(r/$t)+2,y=o*E;this.ensureSpriteCount(y);let f=0;const a=-e/2-kt/2,p=-r/2-$t/2;for(let l=0;l<E;l+=1)for(let S=0;S<o;S+=1){const R=this.sprites[f],x=a+S*kt+l%2*(kt/2),c=p+l*$t;R.position.set(x,c,0),R.visible=!0,f+=1}for(let l=f;l<this.sprites.length;l+=1)this.sprites[l].visible=!1}ensureSpriteCount(e){for(;this.sprites.length<e;){const r=new this.THREE.Sprite(this.material);r.scale.set(Tn,An,1),r.rotation.z=-.32,r.renderOrder=999999,this.scene.add(r),this.sprites.push(r)}}}class Bn{renderer;viewer;container;animationId=null;isRenderingPaused=!0;fpsFrameCount=0;fpsLastTime=performance.now();fpsInfo={fps:0,frameTimeMs:0,minFps:0};watermark;onBeforeRenderCallback;onAfterRenderCallback;onFpsUpdatedCallback;constructor(e,r,o,E){this.container=e,this.renderer=this.createRenderer(E.antialias),this.watermark=new In(lt),this.viewer=new ra.Viewer({selfDrivenMode:!1,renderer:this.renderer,camera:o,threeScene:r,rootElement:e,useBuiltInControls:!0,cameraUp:E.cameraUp,initialCameraPosition:E.initialCameraPosition,initialCameraLookAt:E.initialCameraLookAt,sharedMemoryForWorkers:E.sharedMemoryForWorkers,gpuAcceleratedSort:E.gpuAcceleratedSort,sphericalHarmonicsDegree:E.sphericalHarmonicsDegree,...E.viewerOptions??{}})}createRenderer(e){const r=new lt.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1});return r.setSize(Math.max(this.container.clientWidth,1),Math.max(this.container.clientHeight,1)),r.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(r.domElement),r}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}setOnFpsUpdated(e){this.onFpsUpdatedCallback=e}startRenderLoop(){this.animationId===null&&(this.isRenderingPaused=!1,this.animate())}animate(){if(this.isRenderingPaused){this.animationId=null;return}this.animationId=requestAnimationFrame(()=>this.animate()),this.render()}render(){this.onBeforeRenderCallback?.(),this.viewer.update(this.renderer),this.viewer.render(),this.watermark.render(this.renderer),this.onAfterRenderCallback?.(),this.updateFps()}updateFps(){this.fpsFrameCount++;const e=performance.now(),r=e-this.fpsLastTime;if(r<1e3)return;const o=Math.round(this.fpsFrameCount*1e3/r);this.fpsInfo={fps:o,frameTimeMs:o>0?1e3/o:0,minFps:this.fpsInfo.minFps===0?o:Math.min(this.fpsInfo.minFps,o)},this.fpsFrameCount=0,this.fpsLastTime=e,this.onFpsUpdatedCallback?.({...this.fpsInfo})}resetFpsStats(){this.fpsInfo={fps:0,frameTimeMs:0,minFps:0},this.fpsFrameCount=0,this.fpsLastTime=performance.now()}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(){this.isRenderingPaused&&this.startRenderLoop()}isRenderingPausedState(){return this.isRenderingPaused}resize(e,r){this.renderer.setSize(Math.max(e,1),Math.max(r,1)),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getViewer(){return this.viewer}getRenderer(){return this.renderer}getDomElement(){return this.renderer.domElement}getFpsInfo(){return{...this.fpsInfo}}async dispose(){this.pauseRendering(),await this.viewer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.watermark.dispose(),this.renderer.dispose(),this.renderer.forceContextLoss()}}const bn={identity:[0,0,0,1],"x-90":[-.7071068,0,0,.7071068],x90:[.7071068,0,0,.7071068],x180:[1,0,0,0],"y-90":[0,-.7071068,0,.7071068],y90:[0,.7071068,0,.7071068],"z-90":[0,0,-.7071068,.7071068],z90:[0,0,.7071068,.7071068],z180:[0,0,1,0]};class wn{orientationPreset;constructor(e="x180"){this.orientationPreset=e}setOrientationPreset(e){this.orientationPreset=e}getOrientationPreset(){return this.orientationPreset}getOrientationRotation(){return[...bn[this.orientationPreset]]}active(){}disActive(){}update(){}dispose(){}}function _n(t,e){return`${t}#${e}`}class Rn{viewer;getDefaultRotation;scenes=new Map;constructor(e,r){this.viewer=e,this.getDefaultRotation=r}async loadModel(e,r={}){const o=this.viewer.getSceneCount(),E={showLoadingUI:!0,progressiveLoad:!1,position:[0,0,0],rotation:this.getDefaultRotation(),scale:[1,1,1],...r};await this.viewer.addSplatScene(e,E);const y={id:E.id??_n(e,o),name:E.name??e.split(/[\\/]/).pop()??e,url:e,index:o,options:E};return this.scenes.set(y.id,y),y}async loadModels(e){const r=[];for(const o of e)r.push(await this.loadModel(o.url,o.options));return r}async unloadModel(e,r=!0){const o=this.scenes.get(e);o&&(await this.viewer.removeSplatScene(o.index,r),this.scenes.delete(e),this.reindexScenesAfterRemove(o.index))}getModel(e){return this.scenes.get(e)}getAllModels(){return Array.from(this.scenes.values())}getRawSplatScene(e){const r=typeof e=="number"?e:this.scenes.get(e)?.index;return r==null?void 0:this.viewer.getSplatScene(r)}async clear(e=!1){const r=this.getAllModels().map(o=>o.index);r.length>0&&await this.viewer.removeSplatScenes(r,e),this.scenes.clear()}reindexScenesAfterRemove(e){this.scenes.forEach(r=>{r.index>e&&(r.index-=1)})}}const Tt={version:"3.9.222"}.version;function Zt(){const t=globalThis.crypto?.subtle;if(!t)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return t}function At(t){return new TextEncoder().encode(t)}function It(t){return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}function aa(t){let e="";return t.forEach(r=>{e+=String.fromCharCode(r)}),btoa(e)}function Nn(t){const e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),o=String(t.getUTCDate()).padStart(2,"0");return`${e}${r}${o}`}async function Ln(t){const e=await Zt().digest("SHA-256",It(At(t)));return Array.from(new Uint8Array(e)).map(r=>r.toString(16).padStart(2,"0")).join("")}async function kn(t,e){const r=Zt(),o=await r.importKey("raw",It(t),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return r.sign("HMAC",o,It(At(e)))}function Un(t){return At([t.appId,t.engineType,t.requestDate,String(t.timestamp),t.nonce].join("|"))}async function Dn(t){const e=Zt(),r=new Date,o=r.getTime(),E=Nn(r),y=globalThis.crypto.randomUUID(),f=globalThis.crypto.getRandomValues(new Uint8Array(12)),a=await Ln(t.appSecret),p=await kn(At(a),E),l=await e.importKey("raw",p,"AES-GCM",!1,["encrypt"]),S=JSON.stringify({appKey:t.appKey,appSecret:t.appSecret}),R=await e.encrypt({name:"AES-GCM",iv:f,additionalData:It(Un({appId:t.appId,engineType:t.engineType,requestDate:E,timestamp:o,nonce:y})),tagLength:128},l,It(At(S)));return{appId:t.appId,engineType:t.engineType,requestDate:E,timestamp:o,nonce:y,iv:aa(f),cipherText:aa(new Uint8Array(R)),sdkVersion:t.sdkVersion,origin:t.origin,product:t.product}}const Jt=new Map;function Ut(t){return t.replace(/\/+$/,"")}function Dt(t){if(t)return t;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function Pn(t,e){return JSON.stringify({endpoint:Ut(t.endpoint),token:t.token??"",appId:t.appId??"",appKey:t.appKey??"",appSecret:t.appSecret??"",origin:Dt(t.origin)??"",product:t.product??"",engineType:e,sdkVersion:Tt})}async function er(t,e,r){const o=typeof AbortController<"u"?new AbortController:void 0,E=o?setTimeout(()=>o.abort(),r):void 0;try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?.signal}),f=await y.json().catch(()=>({}));if(!y.ok){const a=f?.error?.message??f?.message??`SDK authentication failed with status ${y.status}`;throw new Error(a)}return f}finally{E!=null&&clearTimeout(E)}}async function Vn(t,e){const r=await er(`${Ut(t.endpoint)}/oauth/sdk-verify`,{sdkToken:t.token,engineType:e,sdkVersion:Tt,origin:Dt(t.origin),product:t.product},t.timeoutMs??8e3);return r.sdkToken=t.token,r}async function On(t,e){const r=await Dn({appId:t.appId,appKey:t.appKey,appSecret:t.appSecret,engineType:e,sdkVersion:Tt,origin:Dt(t.origin),product:t.product}),o=await er(`${Ut(t.endpoint)}/oauth/sdk-token/secure`,r,t.timeoutMs??8e3),E=await er(`${Ut(t.endpoint)}/oauth/sdk-verify`,{sdkToken:o.sdkToken,engineType:e,sdkVersion:Tt,origin:Dt(t.origin),product:t.product},t.timeoutMs??8e3);return E.sdkToken=o.sdkToken,E}async function Mn(t,e){const r=t?.sdkAuth;if(!r)return null;if(!r.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!r.token&&!(r.appId&&r.appKey&&r.appSecret))return null;const o=Pn(r,e),E=Jt.get(o);if(E){const f=await E;return t&&(t.__sdkAuthSession=f),f}const y=(r.token?Vn(r,e):On(r,e)).then(f=>{if(f.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return t&&(t.__sdkAuthSession=f),f}).catch(f=>{throw Jt.delete(o),f});return Jt.set(o,y),y}function Kn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function na(t){if(typeof t!="number")throw new TypeError("number expected, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError("positive integer expected, got "+t)}function Qe(t,e,r=""){const o=Kn(t),E=t?.length,y=e!==void 0;if(!o||y&&E!==e){const f=r&&`"${r}" `,a=y?` of length ${e}`:"",p=o?`length=${E}`:`type=${typeof t}`,l=f+"expected Uint8Array"+a+", got "+p;throw o?new RangeError(l):new TypeError(l)}return t}function ia(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Fn(t,e,r=!1){Qe(t,void 0,"output");const o=e.outputLen;if(t.length<o)throw new RangeError("digestInto() expects output buffer of length at least "+o);if(r&&!Bt(t))throw new Error("invalid output, must be aligned")}function qn(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function pt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ct(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Pt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const tr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,sa=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,xe=tr?t=>t:t=>sa(t)>>>0,rr=tr?t=>t:t=>{for(let e=0;e<t.length;e++)t[e]=sa(t[e]);return t};function Hn(t,e){if(t.length!==e.length)return!1;let r=0;for(let o=0;o<t.length;o++)r|=t[o]^e[o];return r===0}function Gn(t,e,r){const o=e,E=r||(()=>[]),y=(a,p)=>o(p,...E(a)).update(a).digest(),f=o(new Uint8Array(t),...E(new Uint8Array(0)));return y.outputLen=f.outputLen,y.blockLen=f.blockLen,y.create=(a,...p)=>o(a,...p),y}const zn=(t,e)=>{function r(o,...E){if(Qe(o,void 0,"key"),t.nonceLength!==void 0){const S=E[0];Qe(S,t.varSizeNonce?void 0:t.nonceLength,"nonce")}const y=t.tagLength;y&&E[1]!==void 0&&Qe(E[1],void 0,"AAD");const f=e(o,...E),a=(S,R)=>{if(R!==void 0){if(S!==2)throw new Error("cipher output not supported");Qe(R,void 0,"output")}};let p=!1;return{encrypt(S,R){if(p)throw new Error("cannot encrypt() twice with same key + nonce");return p=!0,Qe(S),a(f.encrypt.length,R),f.encrypt(S,R)},decrypt(S,R){if(Qe(S),y&&S.length<y)throw new Error('"ciphertext" expected length bigger than tagLength='+y);return a(f.decrypt.length,R),f.decrypt(S,R)}}}return Object.assign(r,t),r};function Qn(t,e,r=!0){if(e===void 0)return new Uint8Array(t);if(Qe(e,void 0,"output"),e.length!==t)throw new Error('"output" expected Uint8Array of length '+t+", got: "+e.length);if(r&&!Bt(e))throw new Error("invalid output, must be aligned");return e}function Wn(t,e,r){na(t),na(e);const o=new Uint8Array(16),E=Pt(o);return E.setBigUint64(0,BigInt(e),r),E.setBigUint64(8,BigInt(t),r),o}function Bt(t){return t.byteOffset%4===0}function bt(t){return Uint8Array.from(Qe(t))}const mt=16,oa=new Uint8Array(16),wt=pt(oa),Yn=225,Xn=(t,e,r,o)=>{const E=o&1;return{s3:r<<31|o>>>1,s2:e<<31|r>>>1,s1:t<<31|e>>>1,s0:t>>>1^Yn<<24&-(E&1)}},Vt=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255|0,jn=t=>t>64*1024?8:t>1024?4:2;class $n{blockLen=mt;outputLen=mt;s0=0;s1=0;s2=0;s3=0;finished=!1;destroyed=!1;t;W;windowSize;constructor(e,r){Qe(e,16,"key"),e=bt(e);const o=Pt(e);let E=o.getUint32(0,!1),y=o.getUint32(4,!1),f=o.getUint32(8,!1),a=o.getUint32(12,!1);const p=[];for(let g=0;g<128;g++)p.push({s0:Vt(E),s1:Vt(y),s2:Vt(f),s3:Vt(a)}),{s0:E,s1:y,s2:f,s3:a}=Xn(E,y,f,a);const l=jn(r||1024);if(![1,2,4,8].includes(l))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;const R=128/l,x=this.windowSize=2**l,c=[];for(let g=0;g<R;g++)for(let C=0;C<x;C++){let m=0,i=0,h=0,v=0;for(let I=0;I<l;I++){if(!(C>>>l-I-1&1))continue;const{s0:d,s1:s,s2:n,s3:B}=p[l*g+I];m^=d,i^=s,h^=n,v^=B}c.push({s0:m,s1:i,s2:h,s3:v})}this.t=c}_updateBlock(e,r,o,E){e^=this.s0,r^=this.s1,o^=this.s2,E^=this.s3;const{W:y,t:f,windowSize:a}=this;let p=0,l=0,S=0,R=0;const x=(1<<y)-1;let c=0;for(const g of[e,r,o,E])for(let C=0;C<4;C++){const m=g>>>8*C&255;for(let i=8/y-1;i>=0;i--){const h=m>>>y*i&x,{s0:v,s1:I,s2:N,s3:d}=f[c*a+h];p^=v,l^=I,S^=N,R^=d,c+=1}}this.s0=p,this.s1=l,this.s2=S,this.s3=R}update(e){ia(this),Qe(e),e=bt(e);const r=pt(e),o=Math.floor(e.length/mt),E=e.length%mt;for(let y=0;y<o;y++)this._updateBlock(xe(r[y*4+0]),xe(r[y*4+1]),xe(r[y*4+2]),xe(r[y*4+3]));return E&&(oa.set(e.subarray(o*mt)),this._updateBlock(xe(wt[0]),xe(wt[1]),xe(wt[2]),xe(wt[3])),ct(wt)),this}destroy(){this.destroyed=!0;const{t:e}=this;for(const r of e)r.s0=0,r.s1=0,r.s2=0,r.s3=0}digestInto(e){ia(this),Fn(e,this,!0),this.finished=!0;const{s0:r,s1:o,s2:E,s3:y}=this,f=pt(e);f[0]=r,f[1]=o,f[2]=E,f[3]=y,rr(f)}digest(){const e=new Uint8Array(mt);return this.digestInto(e),this.destroy(),e}}const ua=Gn(16,(t,e)=>new $n(t,e),t=>[t.length]),ar=16,Zn=4,Ot=new Uint8Array(ar),Jn=283;function ei(t){if(![16,24,32].includes(t.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+t.length)}function nr(t){return t<<1^Jn&-(t>>7)}function la(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(e&1),t=nr(t);return r}const ti=(()=>{const t=new Uint8Array(256);for(let r=0,o=1;r<256;r++,o^=nr(o))t[r]=o;const e=new Uint8Array(256);e[0]=99;for(let r=0;r<255;r++){let o=t[255-r];o|=o<<8,e[t[r]]=(o^o>>4^o>>5^o>>6^o>>7^99)&255}return ct(t),e})(),ri=t=>t<<24|t>>>8,ir=t=>t<<8|t>>>24;function ai(t,e){if(t.length!==256)throw new Error("Wrong sbox length");const r=new Uint32Array(256).map((l,S)=>e(t[S])),o=r.map(ir),E=o.map(ir),y=E.map(ir),f=new Uint32Array(256*256),a=new Uint32Array(256*256),p=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let S=0;S<256;S++){const R=l*256+S;f[R]=r[l]^o[S],a[R]=E[l]^y[S],p[R]=t[l]<<8|t[S]}return{sbox:t,sbox2:p,T0:r,T1:o,T2:E,T3:y,T01:f,T23:a}}const fa=ai(ti,t=>la(t,3)<<24|t<<16|t<<8|la(t,2)),ni=(()=>{const t=new Uint8Array(16);for(let e=0,r=1;e<16;e++,r=nr(r))t[e]=r;return t})();function ii(t){Qe(t);const e=t.length;ei(t);const{sbox2:r}=fa,o=[];(!tr||!Bt(t))&&o.push(t=bt(t));const E=rr(pt(t)),y=E.length,f=p=>_t(r,p,p,p,p),a=new Uint32Array(e+28);a.set(E);for(let p=y;p<a.length;p++){let l=a[p-1];p%y===0?l=f(ri(l))^ni[p/y-1]:y>6&&p%y===4&&(l=f(l)),a[p]=a[p-y]^l}return ct(...o),a}function Mt(t,e,r,o,E,y){return t[r<<8&65280|o>>>8&255]^e[E>>>8&65280|y>>>24&255]}function _t(t,e,r,o,E){return t[e&255|r&65280]|t[o>>>16&255|E>>>16&65280]<<16}function ca(t,e,r,o,E){const{sbox2:y,T01:f,T23:a}=fa;let p=0;e^=t[p++],r^=t[p++],o^=t[p++],E^=t[p++];const l=t.length/4-2;for(let g=0;g<l;g++){const C=t[p++]^Mt(f,a,e,r,o,E),m=t[p++]^Mt(f,a,r,o,E,e),i=t[p++]^Mt(f,a,o,E,e,r),h=t[p++]^Mt(f,a,E,e,r,o);e=C,r=m,o=i,E=h}const S=t[p++]^_t(y,e,r,o,E),R=t[p++]^_t(y,r,o,E,e),x=t[p++]^_t(y,o,E,e,r),c=t[p++]^_t(y,E,e,r,o);return{s0:S,s1:R,s2:x,s3:c}}function Kt(t,e,r,o,E){Qe(r,ar,"nonce"),Qe(o),E=Qn(o.length,E);const y=r,f=pt(y),a=Pt(y),p=pt(o),l=pt(E),S=e?0:12,R=o.length;let x=a.getUint32(S,e),{s0:c,s1:g,s2:C,s3:m}=ca(t,xe(f[0]),xe(f[1]),xe(f[2]),xe(f[3]));for(let h=0;h+4<=p.length;h+=4)l[h+0]=p[h+0]^xe(c),l[h+1]=p[h+1]^xe(g),l[h+2]=p[h+2]^xe(C),l[h+3]=p[h+3]^xe(m),x=x+1>>>0,a.setUint32(S,x,e),{s0:c,s1:g,s2:C,s3:m}=ca(t,xe(f[0]),xe(f[1]),xe(f[2]),xe(f[3]));const i=ar*Math.floor(p.length/Zn);if(i<R){const h=new Uint32Array([c,g,C,m]);rr(h);const v=qn(h);for(let I=i,N=0;I<R;I++,N++)E[I]=o[I]^v[N];ct(h)}return E}function si(t,e,r,o,E){const y=E?E.length:0,f=t.create(r,o.length+y);E&&f.update(E);const a=Wn(8*o.length,8*y,e);f.update(o),f.update(a);const p=f.digest();return ct(a),p}const oi=zn({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,r,o){if(r.length<8)throw new Error("aes/gcm: invalid nonce length");const E=16;function y(a,p,l){const S=si(ua,!1,a,l,o);for(let R=0;R<p.length;R++)S[R]^=p[R];return S}function f(){const a=ii(e),p=Ot.slice(),l=Ot.slice();if(Kt(a,!1,l,l,p),r.length===12)l.set(r);else{const R=Ot.slice();Pt(R).setBigUint64(8,BigInt(r.length*8),!1);const c=ua.create(p).update(r).update(R);c.digestInto(l),c.destroy()}const S=Kt(a,!1,l,Ot);return{xk:a,authKey:p,counter:l,tagMask:S}}return{encrypt(a){const{xk:p,authKey:l,counter:S,tagMask:R}=f(),x=new Uint8Array(a.length+E),c=[p,l,S,R];Bt(a)||c.push(a=bt(a)),Kt(p,!1,S,a,x.subarray(0,a.length));const g=y(l,R,x.subarray(0,x.length-E));return c.push(g),x.set(g,a.length),ct(...c),x},decrypt(a){const{xk:p,authKey:l,counter:S,tagMask:R}=f(),x=[p,l,R,S];Bt(a)||x.push(a=bt(a));const c=a.subarray(0,-E),g=a.subarray(-E),C=y(l,R,c);if(x.push(C),!Hn(C,g))throw ct(...x),new Error("aes/gcm: invalid ghash tag");const m=Kt(p,!1,S,c);return ct(...x),m}}});var ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function li(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function o(){var E=!1;try{E=this instanceof o}catch{}return E?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 E=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,E.get?E:{enumerable:!0,get:function(){return t[o]}})}),r}var sr,da;function ue(){return da||(da=1,sr={options:{usePureJavaScript:!1}}),sr}var or={exports:{}},ur,ha;function fi(){if(ha)return ur;ha=1;var t={};ur=t;var e={};t.encode=function(o,E,y){if(typeof E!="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,E);else{var a=0,p=E.length,l=E.charAt(0),S=[0];for(a=0;a<o.length;++a){for(var R=0,x=o[a];R<S.length;++R)x+=S[R]<<8,S[R]=x%p,x=x/p|0;for(;x>0;)S.push(x%p),x=x/p|0}for(a=0;o[a]===0&&a<o.length-1;++a)f+=l;for(a=S.length-1;a>=0;--a)f+=E[S[a]]}if(y){var c=new RegExp(".{1,"+y+"}","g");f=f.match(c).join(`\r
2
+ `)}return f},t.decode=function(o,E){if(typeof o!="string")throw new TypeError('"input" must be a string.');if(typeof E!="string")throw new TypeError('"alphabet" must be a string.');var y=e[E];if(!y){y=e[E]=[];for(var f=0;f<E.length;++f)y[E.charCodeAt(f)]=f}o=o.replace(/\s/g,"");for(var a=E.length,p=E.charAt(0),l=[0],f=0;f<o.length;f++){var S=y[o.charCodeAt(f)];if(S===void 0)return;for(var R=0,x=S;R<l.length;++R)x+=l[R]*a,l[R]=x&255,x>>=8;for(;x>0;)l.push(x&255),x>>=8}for(var c=0;o[c]===p&&c<o.length-1;++c)l.push(0);return typeof Buffer<"u"?Buffer.from(l.reverse()):new Uint8Array(l.reverse())};function r(o,E){var y=0,f=E.length,a=E.charAt(0),p=[0];for(y=0;y<o.length();++y){for(var l=0,S=o.at(y);l<p.length;++l)S+=p[l]<<8,p[l]=S%f,S=S/f|0;for(;S>0;)p.push(S%f),S=S/f|0}var R="";for(y=0;o.at(y)===0&&y<o.length()-1;++y)R+=a;for(y=p.length-1;y>=0;--y)R+=E[p[y]];return R}return ur}var pa;function ce(){if(pa)return or.exports;pa=1;var t=ue(),e=fi(),r=or.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(s){return setImmediate(s)};return}if(r.setImmediate=function(s){setTimeout(s,0)},typeof window<"u"&&typeof window.postMessage=="function"){let s=function(n){if(n.source===window&&n.data===i){n.stopPropagation();var B=h.slice();h.length=0,B.forEach(function(U){U()})}};var i="forge.setImmediate",h=[];r.setImmediate=function(n){h.push(n),h.length===1&&window.postMessage(i,"*")},window.addEventListener("message",s,!0)}if(typeof MutationObserver<"u"){var v=Date.now(),I=!0,N=document.createElement("div"),h=[];new MutationObserver(function(){var n=h.slice();h.length=0,n.forEach(function(B){B()})}).observe(N,{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&&N.setAttribute("a",I=!I))}}r.nextTick=r.setImmediate})(),r.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,r.globalScope=(function(){return r.isNodejs?ui:typeof self>"u"?window:self})(),r.isArray=Array.isArray||function(i){return Object.prototype.toString.call(i)==="[object Array]"},r.isArrayBuffer=function(i){return typeof ArrayBuffer<"u"&&i instanceof ArrayBuffer},r.isArrayBufferView=function(i){return i&&r.isArrayBuffer(i.buffer)&&i.byteLength!==void 0};function o(i){if(!(i===8||i===16||i===24||i===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+i)}r.ByteBuffer=E;function E(i){if(this.data="",this.read=0,typeof i=="string")this.data=i;else if(r.isArrayBuffer(i)||r.isArrayBufferView(i))if(typeof Buffer<"u"&&i instanceof Buffer)this.data=i.toString("binary");else{var h=new Uint8Array(i);try{this.data=String.fromCharCode.apply(null,h)}catch{for(var v=0;v<h.length;++v)this.putByte(h[v])}}else(i instanceof E||typeof i=="object"&&typeof i.data=="string"&&typeof i.read=="number")&&(this.data=i.data,this.read=i.read);this._constructedStringLength=0}r.ByteStringBuffer=E;var y=4096;r.ByteStringBuffer.prototype._optimizeConstructedString=function(i){this._constructedStringLength+=i,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(i){return this.putBytes(String.fromCharCode(i))},r.ByteStringBuffer.prototype.fillWithByte=function(i,h){i=String.fromCharCode(i);for(var v=this.data;h>0;)h&1&&(v+=i),h>>>=1,h>0&&(i+=i);return this.data=v,this._optimizeConstructedString(h),this},r.ByteStringBuffer.prototype.putBytes=function(i){return this.data+=i,this._optimizeConstructedString(i.length),this},r.ByteStringBuffer.prototype.putString=function(i){return this.putBytes(r.encodeUtf8(i))},r.ByteStringBuffer.prototype.putInt16=function(i){return this.putBytes(String.fromCharCode(i>>8&255)+String.fromCharCode(i&255))},r.ByteStringBuffer.prototype.putInt24=function(i){return this.putBytes(String.fromCharCode(i>>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i&255))},r.ByteStringBuffer.prototype.putInt32=function(i){return this.putBytes(String.fromCharCode(i>>24&255)+String.fromCharCode(i>>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i&255))},r.ByteStringBuffer.prototype.putInt16Le=function(i){return this.putBytes(String.fromCharCode(i&255)+String.fromCharCode(i>>8&255))},r.ByteStringBuffer.prototype.putInt24Le=function(i){return this.putBytes(String.fromCharCode(i&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i>>16&255))},r.ByteStringBuffer.prototype.putInt32Le=function(i){return this.putBytes(String.fromCharCode(i&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i>>16&255)+String.fromCharCode(i>>24&255))},r.ByteStringBuffer.prototype.putInt=function(i,h){o(h);var v="";do h-=8,v+=String.fromCharCode(i>>h&255);while(h>0);return this.putBytes(v)},r.ByteStringBuffer.prototype.putSignedInt=function(i,h){return i<0&&(i+=2<<h-1),this.putInt(i,h)},r.ByteStringBuffer.prototype.putBuffer=function(i){return this.putBytes(i.getBytes())},r.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},r.ByteStringBuffer.prototype.getInt16=function(){var i=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,i},r.ByteStringBuffer.prototype.getInt24=function(){var i=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,i},r.ByteStringBuffer.prototype.getInt32=function(){var i=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,i},r.ByteStringBuffer.prototype.getInt16Le=function(){var i=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,i},r.ByteStringBuffer.prototype.getInt24Le=function(){var i=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,i},r.ByteStringBuffer.prototype.getInt32Le=function(){var i=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,i},r.ByteStringBuffer.prototype.getInt=function(i){o(i);var h=0;do h=(h<<8)+this.data.charCodeAt(this.read++),i-=8;while(i>0);return h},r.ByteStringBuffer.prototype.getSignedInt=function(i){var h=this.getInt(i),v=2<<i-2;return h>=v&&(h-=v<<1),h},r.ByteStringBuffer.prototype.getBytes=function(i){var h;return i?(i=Math.min(this.length(),i),h=this.data.slice(this.read,this.read+i),this.read+=i):i===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.ByteStringBuffer.prototype.bytes=function(i){return typeof i>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+i)},r.ByteStringBuffer.prototype.at=function(i){return this.data.charCodeAt(this.read+i)},r.ByteStringBuffer.prototype.setAt=function(i,h){return this.data=this.data.substr(0,this.read+i)+String.fromCharCode(h)+this.data.substr(this.read+i+1),this},r.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},r.ByteStringBuffer.prototype.copy=function(){var i=r.createBuffer(this.data);return i.read=this.read,i},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(i){var h=Math.max(0,this.length()-i);return this.data=this.data.substr(this.read,h),this.read=0,this},r.ByteStringBuffer.prototype.toHex=function(){for(var i="",h=this.read;h<this.data.length;++h){var v=this.data.charCodeAt(h);v<16&&(i+="0"),i+=v.toString(16)}return i},r.ByteStringBuffer.prototype.toString=function(){return r.decodeUtf8(this.bytes())};function f(i,h){h=h||{},this.read=h.readOffset||0,this.growSize=h.growSize||1024;var v=r.isArrayBuffer(i),I=r.isArrayBufferView(i);if(v||I){v?this.data=new DataView(i):this.data=new DataView(i.buffer,i.byteOffset,i.byteLength),this.write="writeOffset"in h?h.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,i!=null&&this.putBytes(i),"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(i,h){if(this.length()>=i)return this;h=Math.max(h||this.growSize,i);var v=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),I=new Uint8Array(this.length()+h);return I.set(v),this.data=new DataView(I.buffer),this},r.DataBuffer.prototype.putByte=function(i){return this.accommodate(1),this.data.setUint8(this.write++,i),this},r.DataBuffer.prototype.fillWithByte=function(i,h){this.accommodate(h);for(var v=0;v<h;++v)this.data.setUint8(i);return this},r.DataBuffer.prototype.putBytes=function(i,h){if(r.isArrayBufferView(i)){var v=new Uint8Array(i.buffer,i.byteOffset,i.byteLength),I=v.byteLength-v.byteOffset;this.accommodate(I);var N=new Uint8Array(this.data.buffer,this.write);return N.set(v),this.write+=I,this}if(r.isArrayBuffer(i)){var v=new Uint8Array(i);this.accommodate(v.byteLength);var N=new Uint8Array(this.data.buffer);return N.set(v,this.write),this.write+=v.byteLength,this}if(i instanceof r.DataBuffer||typeof i=="object"&&typeof i.read=="number"&&typeof i.write=="number"&&r.isArrayBufferView(i.data)){var v=new Uint8Array(i.data.byteLength,i.read,i.length());this.accommodate(v.byteLength);var N=new Uint8Array(i.data.byteLength,this.write);return N.set(v),this.write+=v.byteLength,this}if(i instanceof r.ByteStringBuffer&&(i=i.data,h="binary"),h=h||"binary",typeof i=="string"){var d;if(h==="hex")return this.accommodate(Math.ceil(i.length/2)),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.hex.decode(i,d,this.write),this;if(h==="base64")return this.accommodate(Math.ceil(i.length/4)*3),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.base64.decode(i,d,this.write),this;if(h==="utf8"&&(i=r.encodeUtf8(i),h="binary"),h==="binary"||h==="raw")return this.accommodate(i.length),d=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.raw.decode(d),this;if(h==="utf16")return this.accommodate(i.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: "+i)},r.DataBuffer.prototype.putBuffer=function(i){return this.putBytes(i),i.clear(),this},r.DataBuffer.prototype.putString=function(i){return this.putBytes(i,"utf16")},r.DataBuffer.prototype.putInt16=function(i){return this.accommodate(2),this.data.setInt16(this.write,i),this.write+=2,this},r.DataBuffer.prototype.putInt24=function(i){return this.accommodate(3),this.data.setInt16(this.write,i>>8&65535),this.data.setInt8(this.write,i>>16&255),this.write+=3,this},r.DataBuffer.prototype.putInt32=function(i){return this.accommodate(4),this.data.setInt32(this.write,i),this.write+=4,this},r.DataBuffer.prototype.putInt16Le=function(i){return this.accommodate(2),this.data.setInt16(this.write,i,!0),this.write+=2,this},r.DataBuffer.prototype.putInt24Le=function(i){return this.accommodate(3),this.data.setInt8(this.write,i>>16&255),this.data.setInt16(this.write,i>>8&65535,!0),this.write+=3,this},r.DataBuffer.prototype.putInt32Le=function(i){return this.accommodate(4),this.data.setInt32(this.write,i,!0),this.write+=4,this},r.DataBuffer.prototype.putInt=function(i,h){o(h),this.accommodate(h/8);do h-=8,this.data.setInt8(this.write++,i>>h&255);while(h>0);return this},r.DataBuffer.prototype.putSignedInt=function(i,h){return o(h),this.accommodate(h/8),i<0&&(i+=2<<h-1),this.putInt(i,h)},r.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},r.DataBuffer.prototype.getInt16=function(){var i=this.data.getInt16(this.read);return this.read+=2,i},r.DataBuffer.prototype.getInt24=function(){var i=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,i},r.DataBuffer.prototype.getInt32=function(){var i=this.data.getInt32(this.read);return this.read+=4,i},r.DataBuffer.prototype.getInt16Le=function(){var i=this.data.getInt16(this.read,!0);return this.read+=2,i},r.DataBuffer.prototype.getInt24Le=function(){var i=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,i},r.DataBuffer.prototype.getInt32Le=function(){var i=this.data.getInt32(this.read,!0);return this.read+=4,i},r.DataBuffer.prototype.getInt=function(i){o(i);var h=0;do h=(h<<8)+this.data.getInt8(this.read++),i-=8;while(i>0);return h},r.DataBuffer.prototype.getSignedInt=function(i){var h=this.getInt(i),v=2<<i-2;return h>=v&&(h-=v<<1),h},r.DataBuffer.prototype.getBytes=function(i){var h;return i?(i=Math.min(this.length(),i),h=this.data.slice(this.read,this.read+i),this.read+=i):i===0?h="":(h=this.read===0?this.data:this.data.slice(this.read),this.clear()),h},r.DataBuffer.prototype.bytes=function(i){return typeof i>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+i)},r.DataBuffer.prototype.at=function(i){return this.data.getUint8(this.read+i)},r.DataBuffer.prototype.setAt=function(i,h){return this.data.setUint8(i,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 i=new Uint8Array(this.data.buffer,this.read),h=new Uint8Array(i.byteLength);h.set(i),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(i){return this.write=Math.max(0,this.length()-i),this.read=Math.min(this.read,this.write),this},r.DataBuffer.prototype.toHex=function(){for(var i="",h=this.read;h<this.data.byteLength;++h){var v=this.data.getUint8(h);v<16&&(i+="0"),i+=v.toString(16)}return i},r.DataBuffer.prototype.toString=function(i){var h=new Uint8Array(this.data,this.read,this.length());if(i=i||"utf8",i==="binary"||i==="raw")return r.binary.raw.encode(h);if(i==="hex")return r.binary.hex.encode(h);if(i==="base64")return r.binary.base64.encode(h);if(i==="utf8")return r.text.utf8.decode(h);if(i==="utf16")return r.text.utf16.decode(h);throw new Error("Invalid encoding: "+i)},r.createBuffer=function(i,h){return h=h||"raw",i!==void 0&&h==="utf8"&&(i=r.encodeUtf8(i)),new r.ByteBuffer(i)},r.fillString=function(i,h){for(var v="";h>0;)h&1&&(v+=i),h>>>=1,h>0&&(i+=i);return v},r.xorBytes=function(i,h,v){for(var I="",N="",d="",s=0,n=0;v>0;--v,++s)N=i.charCodeAt(s)^h.charCodeAt(s),n>=10&&(I+=d,d="",n=0),d+=String.fromCharCode(N),++n;return I+=d,I},r.hexToBytes=function(i){var h="",v=0;for(i.length&!0&&(v=1,h+=String.fromCharCode(parseInt(i[0],16)));v<i.length;v+=2)h+=String.fromCharCode(parseInt(i.substr(v,2),16));return h},r.bytesToHex=function(i){return r.createBuffer(i).toHex()},r.int32ToBytes=function(i){return String.fromCharCode(i>>24&255)+String.fromCharCode(i>>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i&255)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=[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(i,h){for(var v="",I="",N,d,s,n=0;n<i.length;)N=i.charCodeAt(n++),d=i.charCodeAt(n++),s=i.charCodeAt(n++),v+=a.charAt(N>>2),v+=a.charAt((N&3)<<4|d>>4),isNaN(d)?v+="==":(v+=a.charAt((d&15)<<2|s>>6),v+=isNaN(s)?"=":a.charAt(s&63)),h&&v.length>h&&(I+=v.substr(0,h)+`\r
3
+ `,v=v.substr(h));return I+=v,I},r.decode64=function(i){i=i.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var h="",v,I,N,d,s=0;s<i.length;)v=p[i.charCodeAt(s++)-43],I=p[i.charCodeAt(s++)-43],N=p[i.charCodeAt(s++)-43],d=p[i.charCodeAt(s++)-43],h+=String.fromCharCode(v<<2|I>>4),N!==64&&(h+=String.fromCharCode((I&15)<<4|N>>2),d!==64&&(h+=String.fromCharCode((N&3)<<6|d)));return h},r.encodeUtf8=function(i){return unescape(encodeURIComponent(i))},r.decodeUtf8=function(i){return decodeURIComponent(escape(i))},r.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:e.encode,decode:e.decode}},r.binary.raw.encode=function(i){return String.fromCharCode.apply(null,i)},r.binary.raw.decode=function(i,h,v){var I=h;I||(I=new Uint8Array(i.length)),v=v||0;for(var N=v,d=0;d<i.length;++d)I[N++]=i.charCodeAt(d);return h?N-v:I},r.binary.hex.encode=r.bytesToHex,r.binary.hex.decode=function(i,h,v){var I=h;I||(I=new Uint8Array(Math.ceil(i.length/2))),v=v||0;var N=0,d=v;for(i.length&1&&(N=1,I[d++]=parseInt(i[0],16));N<i.length;N+=2)I[d++]=parseInt(i.substr(N,2),16);return h?d-v:I},r.binary.base64.encode=function(i,h){for(var v="",I="",N,d,s,n=0;n<i.byteLength;)N=i[n++],d=i[n++],s=i[n++],v+=a.charAt(N>>2),v+=a.charAt((N&3)<<4|d>>4),isNaN(d)?v+="==":(v+=a.charAt((d&15)<<2|s>>6),v+=isNaN(s)?"=":a.charAt(s&63)),h&&v.length>h&&(I+=v.substr(0,h)+`\r
4
+ `,v=v.substr(h));return I+=v,I},r.binary.base64.decode=function(i,h,v){var I=h;I||(I=new Uint8Array(Math.ceil(i.length/4)*3)),i=i.replace(/[^A-Za-z0-9\+\/\=]/g,""),v=v||0;for(var N,d,s,n,B=0,U=v;B<i.length;)N=p[i.charCodeAt(B++)-43],d=p[i.charCodeAt(B++)-43],s=p[i.charCodeAt(B++)-43],n=p[i.charCodeAt(B++)-43],I[U++]=N<<2|d>>4,s!==64&&(I[U++]=(d&15)<<4|s>>2,n!==64&&(I[U++]=(s&3)<<6|n));return h?U-v:I.subarray(0,U)},r.binary.base58.encode=function(i,h){return r.binary.baseN.encode(i,l,h)},r.binary.base58.decode=function(i,h){return r.binary.baseN.decode(i,l,h)},r.text={utf8:{},utf16:{}},r.text.utf8.encode=function(i,h,v){i=r.encodeUtf8(i);var I=h;I||(I=new Uint8Array(i.length)),v=v||0;for(var N=v,d=0;d<i.length;++d)I[N++]=i.charCodeAt(d);return h?N-v:I},r.text.utf8.decode=function(i){return r.decodeUtf8(String.fromCharCode.apply(null,i))},r.text.utf16.encode=function(i,h,v){var I=h;I||(I=new Uint8Array(i.length*2));var N=new Uint16Array(I.buffer);v=v||0;for(var d=v,s=v,n=0;n<i.length;++n)N[s++]=i.charCodeAt(n),d+=2;return h?d-v:I},r.text.utf16.decode=function(i){return String.fromCharCode.apply(null,new Uint16Array(i.buffer))},r.deflate=function(i,h,v){if(h=r.decode64(i.deflate(r.encode64(h)).rval),v){var I=2,N=h.charCodeAt(1);N&32&&(I=6),h=h.substring(I,h.length-4)}return h},r.inflate=function(i,h,v){var I=i.inflate(r.encode64(h)).rval;return I===null?null:r.decode64(I)};var S=function(i,h,v){if(!i)throw new Error("WebStorage not available.");var I;if(v===null?I=i.removeItem(h):(v=r.encode64(JSON.stringify(v)),I=i.setItem(h,v)),typeof I<"u"&&I.rval!==!0){var N=new Error(I.error.message);throw N.id=I.error.id,N.name=I.error.name,N}},R=function(i,h){if(!i)throw new Error("WebStorage not available.");var v=i.getItem(h);if(i.init)if(v.rval===null){if(v.error){var I=new Error(v.error.message);throw I.id=v.error.id,I.name=v.error.name,I}v=null}else v=v.rval;return v!==null&&(v=JSON.parse(r.decode64(v))),v},x=function(i,h,v,I){var N=R(i,h);N===null&&(N={}),N[v]=I,S(i,h,N)},c=function(i,h,v){var I=R(i,h);return I!==null&&(I=v in I?I[v]:null),I},g=function(i,h,v){var I=R(i,h);if(I!==null&&v in I){delete I[v];var N=!0;for(var d in I){N=!1;break}N&&(I=null),S(i,h,I)}},C=function(i,h){S(i,h,null)},m=function(i,h,v){var I=null;typeof v>"u"&&(v=["web","flash"]);var N,d=!1,s=null;for(var n in v){N=v[n];try{if(N==="flash"||N==="both"){if(h[0]===null)throw new Error("Flash local storage not available.");I=i.apply(this,h),d=N==="flash"}(N==="web"||N==="both")&&(h[0]=localStorage,I=i.apply(this,h),d=!0)}catch(B){s=B}if(d)break}if(!d)throw s;return I};return r.setItem=function(i,h,v,I,N){m(x,arguments,N)},r.getItem=function(i,h,v,I){return m(c,arguments,I)},r.removeItem=function(i,h,v,I){m(g,arguments,I)},r.clearItems=function(i,h,v){m(C,arguments,v)},r.isEmpty=function(i){for(var h in i)if(i.hasOwnProperty(h))return!1;return!0},r.format=function(i){for(var h=/%./g,v,I,N=0,d=[],s=0;v=h.exec(i);){I=i.substring(s,h.lastIndex-2),I.length>0&&d.push(I),s=h.lastIndex;var n=v[0][1];switch(n){case"s":case"o":N<arguments.length?d.push(arguments[N+++1]):d.push("<?>");break;case"%":d.push("%");break;default:d.push("<%"+n+"?>")}}return d.push(i.substring(s)),d.join("")},r.formatNumber=function(i,h,v,I){var N=i,d=isNaN(h=Math.abs(h))?2:h,s=v===void 0?",":v,n=I===void 0?".":I,B=N<0?"-":"",U=parseInt(N=Math.abs(+N||0).toFixed(d),10)+"",O=U.length>3?U.length%3:0;return B+(O?U.substr(0,O)+n:"")+U.substr(O).replace(/(\d{3})(?=\d)/g,"$1"+n)+(d?s+Math.abs(N-U).toFixed(d).slice(2):"")},r.formatSize=function(i){return i>=1073741824?i=r.formatNumber(i/1073741824,2,".","")+" GiB":i>=1048576?i=r.formatNumber(i/1048576,2,".","")+" MiB":i>=1024?i=r.formatNumber(i/1024,0)+" KiB":i=r.formatNumber(i,0)+" bytes",i},r.bytesFromIP=function(i){return i.indexOf(".")!==-1?r.bytesFromIPv4(i):i.indexOf(":")!==-1?r.bytesFromIPv6(i):null},r.bytesFromIPv4=function(i){if(i=i.split("."),i.length!==4)return null;for(var h=r.createBuffer(),v=0;v<i.length;++v){var I=parseInt(i[v],10);if(isNaN(I))return null;h.putByte(I)}return h.getBytes()},r.bytesFromIPv6=function(i){var h=0;i=i.split(":").filter(function(s){return s.length===0&&++h,!0});for(var v=(8-i.length+h)*2,I=r.createBuffer(),N=0;N<8;++N){if(!i[N]||i[N].length===0){I.fillWithByte(0,v),v=0;continue}var d=r.hexToBytes(i[N]);d.length<2&&I.putByte(0),I.putBytes(d)}return I.getBytes()},r.bytesToIP=function(i){return i.length===4?r.bytesToIPv4(i):i.length===16?r.bytesToIPv6(i):null},r.bytesToIPv4=function(i){if(i.length!==4)return null;for(var h=[],v=0;v<i.length;++v)h.push(i.charCodeAt(v));return h.join(".")},r.bytesToIPv6=function(i){if(i.length!==16)return null;for(var h=[],v=[],I=0,N=0;N<i.length;N+=2){for(var d=r.bytesToHex(i[N]+i[N+1]);d[0]==="0"&&d!=="0";)d=d.substr(1);if(d==="0"){var s=v[v.length-1],n=h.length;!s||n!==s.end+1?v.push({start:n,end:n}):(s.end=n,s.end-s.start>v[I].end-v[I].start&&(I=v.length-1))}h.push(d)}if(v.length>0){var B=v[I];B.end-B.start>0&&(h.splice(B.start,B.end-B.start+1,""),B.start===0&&h.unshift(""),B.end===7&&h.push(""))}return h.join(":")},r.estimateCores=function(i,h){if(typeof i=="function"&&(h=i,i={}),i=i||{},"cores"in r&&!i.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(s){var n=Date.now(),B=n+4;self.postMessage({st:n,et:B})})}).toString(),")()"],{type:"application/javascript"}));I([],5,16);function I(s,n,B){if(n===0){var U=Math.floor(s.reduce(function(O,P){return O+P},0)/s.length);return r.cores=Math.max(1,U),URL.revokeObjectURL(v),h(null,r.cores)}N(B,function(O,P){s.push(d(B,P)),I(s,n-1,B)})}function N(s,n){for(var B=[],U=[],O=0;O<s;++O){var P=new Worker(v);P.addEventListener("message",function(M){if(U.push(M.data),U.length===s){for(var q=0;q<s;++q)B[q].terminate();n(null,U)}}),B.push(P)}for(var O=0;O<s;++O)B[O].postMessage(O)}function d(s,n){for(var B=[],U=0;U<s;++U)for(var O=n[U],P=B[U]=[],M=0;M<s;++M)if(U!==M){var q=n[M];(O.st>q.st&&O.st<q.et||q.st>O.st&&q.st<O.et)&&P.push(M)}return B.reduce(function(F,G){return Math.max(F,G.length)},0)}},or.exports}var lr,ga;function fr(){if(ga)return lr;ga=1;var t=ue();ce(),lr=t.cipher=t.cipher||{},t.cipher.algorithms=t.cipher.algorithms||{},t.cipher.createCipher=function(r,o){var E=r;if(typeof E=="string"&&(E=t.cipher.getAlgorithm(E),E&&(E=E())),!E)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:E,key:o,decrypt:!1})},t.cipher.createDecipher=function(r,o){var E=r;if(typeof E=="string"&&(E=t.cipher.getAlgorithm(E),E&&(E=E())),!E)throw new Error("Unsupported algorithm: "+r);return new t.cipher.BlockCipher({algorithm:E,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 E in r)o[E]=r[E];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(E){return r(this.blockSize,E,!1)},this.mode.unpad=function(E){return r(this.blockSize,E,!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))},lr}var cr={exports:{}},va;function ya(){if(va)return cr.exports;va=1;var t=ue();ce(),t.cipher=t.cipher||{};var e=cr.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 p=0;p<this._ints;++p)this._inBlock[p]=y.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var p=0;p<this._ints;++p)f.putInt32(this._outBlock[p])},e.ecb.prototype.decrypt=function(y,f,a){if(y.length()<this.blockSize&&!(a&&y.length()>0))return!0;for(var p=0;p<this._ints;++p)this._inBlock[p]=y.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var p=0;p<this._ints;++p)f.putInt32(this._outBlock[p])},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(),p=y.at(a-1);return p>this.blockSize<<2?!1:(y.truncate(p),!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 p=0;p<this._ints;++p)this._inBlock[p]=this._prev[p]^y.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var p=0;p<this._ints;++p)f.putInt32(this._outBlock[p]);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 p=0;p<this._ints;++p)this._inBlock[p]=y.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var p=0;p<this._ints;++p)f.putInt32(this._prev[p]^this._outBlock[p]);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(),p=y.at(a-1);return p>this.blockSize<<2?!1:(y.truncate(p),!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 p=y.length();if(p===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&p>=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 S=(this.blockSize-p)%this.blockSize;S>0&&(S=this.blockSize-S),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(S>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),S>0&&!a)return f.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;f.putBytes(this._partialOutput.getBytes(p-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(y,f,a){var p=y.length();if(p===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&p>=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 S=(this.blockSize-p)%this.blockSize;S>0&&(S=this.blockSize-S),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(S>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),S>0&&!a)return f.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;f.putBytes(this._partialOutput.getBytes(p-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 p=y.length();if(y.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&p>=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 S=(this.blockSize-p)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(S>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),S>0&&!a)return f.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;f.putBytes(this._partialOutput.getBytes(p-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 p=y.length();if(p===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&p>=this.blockSize)for(var l=0;l<this._ints;++l)f.putInt32(y.getInt32()^this._outBlock[l]);else{var S=(this.blockSize-p)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(S>0&&(y.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!a)return f.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;f.putBytes(this._partialOutput.getBytes(p-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 p=f.length();if(p===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(E(p*8)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,a=t.util.createBuffer(a),this._aDataLength=E(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 p=y.length();if(p===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&p>=this.blockSize){for(var l=0;l<this._ints;++l)f.putInt32(this._outBlock[l]^=y.getInt32());this._cipherLength+=this.blockSize}else{var S=(this.blockSize-p)%this.blockSize;S>0&&(S=this.blockSize-S),this._partialOutput.clear();for(var l=0;l<this._ints;++l)this._partialOutput.putInt32(y.getInt32()^this._outBlock[l]);if(S<=0||a){if(a){var R=p%this.blockSize;this._cipherLength+=R,this._partialOutput.truncate(this.blockSize-R)}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),S>0&&!a)return y.read-=this.blockSize,f.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;f.putBytes(this._partialOutput.getBytes(p-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 p=y.length();if(p<this.blockSize&&!(a&&p>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]);p<this.blockSize?this._cipherLength+=p%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 p=this._aDataLength.concat(E(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,p);var l=[];this.cipher.encrypt(this._j0,l);for(var S=0;S<this._ints;++S)this.tag.putInt32(this._s[S]^l[S]);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],p=f.slice(0),l=0;l<128;++l){var S=y[l/32|0]&1<<31-l%32;S&&(a[0]^=p[0],a[1]^=p[1],a[2]^=p[2],a[3]^=p[3]),this.pow(p,p)}return a},e.gcm.prototype.pow=function(y,f){for(var a=y[3]&1,p=3;p>0;--p)f[p]=y[p]>>>1|(y[p-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 p=a/8|0,l=y[p]>>>(7-a%8)*4&15,S=this._m[a][l];f[0]^=S[0],f[1]^=S[1],f[2]^=S[2],f[3]^=S[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,p=4*a,l=16*a,S=new Array(l),R=0;R<l;++R){var x=[0,0,0,0],c=R/p|0,g=(p-1-R%p)*f;x[c]=1<<f-1<<g,S[R]=this.generateSubHashTable(this.multiply(x,y),f)}return S},e.gcm.prototype.generateSubHashTable=function(y,f){var a=1<<f,p=a>>>1,l=new Array(a);l[p]=y.slice(0);for(var S=p>>>1;S>0;)this.pow(l[2*S],l[S]=[]),S>>=1;for(S=2;S<p;){for(var R=1;R<S;++R){var x=l[S],c=l[R];l[S+R]=[x[0]^c[0],x[1]^c[1],x[2]^c[2],x[3]^c[3]]}S*=2}for(l[0]=[0,0,0,0],S=p+1;S<a;++S){var g=l[S^p];l[S]=[y[0]^g[0],y[1]^g[1],y[2]^g[2],y[3]^g[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 p=0;p<a.length;++p)y.putByte(a[p])}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=[],S=f/4,p=0;p<S;++p)l.push(y.getInt32());y=l}return y}function o(y){y[y.length-1]=y[y.length-1]+1&4294967295}function E(y){return[y/4294967296|0,y&4294967295]}return cr.exports}var dr,ma;function gt(){if(ma)return dr;ma=1;var t=ue();fr(),ya(),ce(),dr=t.aes=t.aes||{},t.aes.startEncrypting=function(c,g,C,m){var i=x({key:c,output:C,decrypt:!1,mode:m});return i.start(g),i},t.aes.createEncryptionCipher=function(c,g){return x({key:c,output:null,decrypt:!1,mode:g})},t.aes.startDecrypting=function(c,g,C,m){var i=x({key:c,output:C,decrypt:!0,mode:m});return i.start(g),i},t.aes.createDecryptionCipher=function(c,g){return x({key:c,output:null,decrypt:!0,mode:g})},t.aes.Algorithm=function(c,g){r||l();var C=this;C.name=c,C.mode=new g({blockSize:16,cipher:{encrypt:function(m,i){return R(C._w,m,i,!1)},decrypt:function(m,i){return R(C._w,m,i,!0)}}}),C._init=!1},t.aes.Algorithm.prototype.initialize=function(c){if(!this._init){var g=c.key,C;if(typeof g=="string"&&(g.length===16||g.length===24||g.length===32))g=t.util.createBuffer(g);else if(t.util.isArray(g)&&(g.length===16||g.length===24||g.length===32)){C=g,g=t.util.createBuffer();for(var m=0;m<C.length;++m)g.putByte(C[m])}if(!t.util.isArray(g)){C=g,g=[];var i=C.length();if(i===16||i===24||i===32){i=i>>>2;for(var m=0;m<i;++m)g.push(C.getInt32())}}if(!t.util.isArray(g)||!(g.length===4||g.length===6||g.length===8))throw new Error("Invalid key parameter.");var h=this.mode.name,v=["CFB","OFB","CTR","GCM"].indexOf(h)!==-1;this._w=S(g,c.decrypt&&!v),this._init=!0}},t.aes._expandKey=function(c,g){return r||l(),S(c,g)},t.aes._updateBlock=R,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,g){var C=function(){return new t.aes.Algorithm(c,g)};t.cipher.registerAlgorithm(c,C)}var r=!1,o=4,E,y,f,a,p;function l(){r=!0,f=[0,1,2,4,8,16,32,64,128,27,54];for(var c=new Array(256),g=0;g<128;++g)c[g]=g<<1,c[g+128]=g+128<<1^283;E=new Array(256),y=new Array(256),a=new Array(4),p=new Array(4);for(var g=0;g<4;++g)a[g]=new Array(256),p[g]=new Array(256);for(var C=0,m=0,i,h,v,I,N,d,s,g=0;g<256;++g){I=m^m<<1^m<<2^m<<3^m<<4,I=I>>8^I&255^99,E[C]=I,y[I]=C,N=c[I],i=c[C],h=c[i],v=c[h],d=N<<24^I<<16^I<<8^(I^N),s=(i^h^v)<<24^(C^v)<<16^(C^h^v)<<8^(C^i^v);for(var n=0;n<4;++n)a[n][C]=d,p[n][I]=s,d=d<<24|d>>>8,s=s<<24|s>>>8;C===0?C=m=1:(C=i^c[c[c[i^v]]],m^=c[c[m]])}}function S(c,g){for(var C=c.slice(0),m,i=1,h=C.length,v=h+6+1,I=o*v,N=h;N<I;++N)m=C[N-1],N%h===0?(m=E[m>>>16&255]<<24^E[m>>>8&255]<<16^E[m&255]<<8^E[m>>>24]^f[i]<<24,i++):h>6&&N%h===4&&(m=E[m>>>24]<<24^E[m>>>16&255]<<16^E[m>>>8&255]<<8^E[m&255]),C[N]=C[N-h]^m;if(g){var d,s=p[0],n=p[1],B=p[2],U=p[3],O=C.slice(0);I=C.length;for(var N=0,P=I-o;N<I;N+=o,P-=o)if(N===0||N===I-o)O[N]=C[P],O[N+1]=C[P+3],O[N+2]=C[P+2],O[N+3]=C[P+1];else for(var M=0;M<o;++M)d=C[P+M],O[N+(3&-M)]=s[E[d>>>24]]^n[E[d>>>16&255]]^B[E[d>>>8&255]]^U[E[d&255]];C=O}return C}function R(c,g,C,m){var i=c.length/4-1,h,v,I,N,d;m?(h=p[0],v=p[1],I=p[2],N=p[3],d=y):(h=a[0],v=a[1],I=a[2],N=a[3],d=E);var s,n,B,U,O,P,M;s=g[0]^c[0],n=g[m?3:1]^c[1],B=g[2]^c[2],U=g[m?1:3]^c[3];for(var q=3,F=1;F<i;++F)O=h[s>>>24]^v[n>>>16&255]^I[B>>>8&255]^N[U&255]^c[++q],P=h[n>>>24]^v[B>>>16&255]^I[U>>>8&255]^N[s&255]^c[++q],M=h[B>>>24]^v[U>>>16&255]^I[s>>>8&255]^N[n&255]^c[++q],U=h[U>>>24]^v[s>>>16&255]^I[n>>>8&255]^N[B&255]^c[++q],s=O,n=P,B=M;C[0]=d[s>>>24]<<24^d[n>>>16&255]<<16^d[B>>>8&255]<<8^d[U&255]^c[++q],C[m?3:1]=d[n>>>24]<<24^d[B>>>16&255]<<16^d[U>>>8&255]<<8^d[s&255]^c[++q],C[2]=d[B>>>24]<<24^d[U>>>16&255]<<16^d[s>>>8&255]<<8^d[n&255]^c[++q],C[m?1:3]=d[U>>>24]<<24^d[s>>>16&255]<<16^d[n>>>8&255]<<8^d[B&255]^c[++q]}function x(c){c=c||{};var g=(c.mode||"CBC").toUpperCase(),C="AES-"+g,m;c.decrypt?m=t.cipher.createDecipher(C,c.key):m=t.cipher.createCipher(C,c.key);var i=m.start;return m.start=function(h,v){var I=null;v instanceof t.util.ByteBuffer&&(I=v,v={}),v=v||{},v.output=I,v.iv=h,i.call(m,v)},m}return dr}var hr={exports:{}},pr={exports:{}},gr={exports:{}},Ca;function vt(){if(Ca)return gr.exports;Ca=1;var t=ue();t.pki=t.pki||{};var e=gr.exports=t.pki.oids=t.oids=t.oids||{};function r(E,y){e[E]=y,e[y]=E}function o(E,y){e[E]=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"),gr.exports}var Ea;function nt(){if(Ea)return pr.exports;Ea=1;var t=ue();ce(),vt();var e=pr.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,p,l,S){if(t.util.isArray(l)){for(var R=[],x=0;x<l.length;++x)l[x]!==void 0&&R.push(l[x]);l=R}var c={tagClass:f,type:a,constructed:p,composed:p||t.util.isArray(l),value:l};return S&&"bitStringContents"in S&&(c.bitStringContents=S.bitStringContents,c.original=e.copy(c)),c},e.copy=function(f,a){var p;if(t.util.isArray(f)){p=[];for(var l=0;l<f.length;++l)p.push(e.copy(f[l],a));return p}return typeof f=="string"?f:(p={tagClass:f.tagClass,type:f.type,constructed:f.constructed,composed:f.composed,value:e.copy(f.value,a)},a&&!a.excludeBitStringContents&&(p.bitStringContents=f.bitStringContents),p)},e.equals=function(f,a,p){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 S=f.tagClass===a.tagClass&&f.type===a.type&&f.constructed===a.constructed&&f.composed===a.composed&&e.equals(f.value,a.value);return p&&p.includeBitStringContents&&(S=S&&f.bitStringContents===a.bitStringContents),S},e.getBerValueLength=function(f){var a=f.getByte();if(a!==128){var p,l=a&128;return l?p=f.getInt((a&127)<<3):p=a,p}};function r(f,a,p){if(p>a){var l=new Error("Too few bytes to parse DER.");throw l.available=f.length(),l.remaining=a,l.requested=p,l}}var o=function(f,a){var p=f.getByte();if(a--,p!==128){var l,S=p&128;if(!S)l=p;else{var R=p&127;r(f,a,R),l=f.getInt(R<<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 p=f.length(),l=E(f,f.length(),0,a);if(a.parseAllBytes&&f.length()!==0){var S=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw S.byteCount=p,S.remaining=f.length(),S}return l};function E(f,a,p,l){if(p>=l.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var S;r(f,a,2);var R=f.getByte();a--;var x=R&192,c=R&31;S=f.length();var g=o(f,a);if(a-=S-f.length(),g!==void 0&&g>a){if(l.strict){var C=new Error("Too few bytes to read ASN.1 value.");throw C.available=f.length(),C.remaining=a,C.requested=g,C}g=a}var m,i,h=(R&32)===32;if(h)if(m=[],g===void 0)for(;;){if(r(f,a,2),f.bytes(2)==="\0\0"){f.getBytes(2),a-=2;break}S=f.length(),m.push(E(f,a,p+1,l)),a-=S-f.length()}else for(;g>0;)S=f.length(),m.push(E(f,g,p+1,l)),a-=S-f.length(),g-=S-f.length();if(m===void 0&&x===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&(i=f.bytes(g)),m===void 0&&l.decodeBitStrings&&x===e.Class.UNIVERSAL&&c===e.Type.BITSTRING&&g>1){var v=f.read,I=a,N=0;if(c===e.Type.BITSTRING&&(r(f,a,1),N=f.getByte(),a--),N===0)try{S=f.length();var d={strict:!0,decodeBitStrings:!0},s=E(f,a,p+1,d),n=S-f.length();a-=n,c==e.Type.BITSTRING&&n++;var B=s.tagClass;n===g&&(B===e.Class.UNIVERSAL||B===e.Class.CONTEXT_SPECIFIC)&&(m=[s])}catch{}m===void 0&&(f.read=v,a=I)}if(m===void 0){if(g===void 0){if(l.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");g=a}if(c===e.Type.BMPSTRING)for(m="";g>0;g-=2)r(f,a,2),m+=String.fromCharCode(f.getInt16()),a-=2;else m=f.getBytes(g),a-=g}var U=i===void 0?null:{bitStringContents:i};return e.create(x,c,h,m,U)}e.toDer=function(f){var a=t.util.createBuffer(),p=f.tagClass|f.type,l=t.util.createBuffer(),S=!1;if("bitStringContents"in f&&(S=!0,f.original&&(S=e.equals(f,f.original))),S)l.putBytes(f.bitStringContents);else if(f.composed){f.constructed?p|=32:l.putByte(0);for(var R=0;R<f.value.length;++R)f.value[R]!==void 0&&l.putBuffer(e.toDer(f.value[R]))}else if(f.type===e.Type.BMPSTRING)for(var R=0;R<f.value.length;++R)l.putInt16(f.value.charCodeAt(R));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(p),l.length()<=127)a.putByte(l.length()&127);else{var x=l.length(),c="";do c+=String.fromCharCode(x&255),x=x>>>8;while(x>0);a.putByte(c.length|128);for(var R=c.length-1;R>=0;--R)a.putByte(c.charCodeAt(R))}return a.putBuffer(l),a},e.oidToDer=function(f){var a=f.split("."),p=t.util.createBuffer();p.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var l,S,R,x,c=2;c<a.length;++c){if(l=!0,S=[],R=parseInt(a[c],10),R>4294967295)throw new Error("OID value too large; max is 32-bits.");do x=R&127,R=R>>>7,l||(x|=128),S.push(x),l=!1;while(R>0);for(var g=S.length-1;g>=0;--g)p.putByte(S[g])}return p},e.derToOid=function(f){var a;typeof f=="string"&&(f=t.util.createBuffer(f));var p=f.getByte();a=Math.floor(p/40)+"."+p%40;for(var l=0;f.length()>0;){if(l>70368744177663)throw new Error("OID value too large; max is 53-bits.");p=f.getByte(),l=l*128,p&128?l+=p&127:(a+="."+(l+p),l=0)}return a},e.utcTimeToDate=function(f){var a=new Date,p=parseInt(f.substr(0,2),10);p=p>=50?1900+p:2e3+p;var l=parseInt(f.substr(2,2),10)-1,S=parseInt(f.substr(4,2),10),R=parseInt(f.substr(6,2),10),x=parseInt(f.substr(8,2),10),c=0;if(f.length>11){var g=f.charAt(10),C=10;g!=="+"&&g!=="-"&&(c=parseInt(f.substr(10,2),10),C+=2)}if(a.setUTCFullYear(p,l,S),a.setUTCHours(R,x,c,0),C&&(g=f.charAt(C),g==="+"||g==="-")){var m=parseInt(f.substr(C+1,2),10),i=parseInt(f.substr(C+4,2),10),h=m*60+i;h*=6e4,g==="+"?a.setTime(+a-h):a.setTime(+a+h)}return a},e.generalizedTimeToDate=function(f){var a=new Date,p=parseInt(f.substr(0,4),10),l=parseInt(f.substr(4,2),10)-1,S=parseInt(f.substr(6,2),10),R=parseInt(f.substr(8,2),10),x=parseInt(f.substr(10,2),10),c=parseInt(f.substr(12,2),10),g=0,C=0,m=!1;f.charAt(f.length-1)==="Z"&&(m=!0);var i=f.length-5,h=f.charAt(i);if(h==="+"||h==="-"){var v=parseInt(f.substr(i+1,2),10),I=parseInt(f.substr(i+4,2),10);C=v*60+I,C*=6e4,h==="+"&&(C*=-1),m=!0}return f.charAt(14)==="."&&(g=parseFloat(f.substr(14),10)*1e3),m?(a.setUTCFullYear(p,l,S),a.setUTCHours(R,x,c,g),a.setTime(+a+C)):(a.setFullYear(p,l,S),a.setHours(R,x,c,g)),a},e.dateToUtcTime=function(f){if(typeof f=="string")return f;var a="",p=[];p.push((""+f.getUTCFullYear()).substr(2)),p.push(""+(f.getUTCMonth()+1)),p.push(""+f.getUTCDate()),p.push(""+f.getUTCHours()),p.push(""+f.getUTCMinutes()),p.push(""+f.getUTCSeconds());for(var l=0;l<p.length;++l)p[l].length<2&&(a+="0"),a+=p[l];return a+="Z",a},e.dateToGeneralizedTime=function(f){if(typeof f=="string")return f;var a="",p=[];p.push(""+f.getUTCFullYear()),p.push(""+(f.getUTCMonth()+1)),p.push(""+f.getUTCDate()),p.push(""+f.getUTCHours()),p.push(""+f.getUTCMinutes()),p.push(""+f.getUTCSeconds());for(var l=0;l<p.length;++l)p[l].length<2&&(a+="0"),a+=p[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 p=new Error("Integer too large; max is 32-bits.");throw p.integer=f,p},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,p,l){var S=!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(S=!0,a.value&&t.util.isArray(a.value))for(var R=0,x=0;S&&x<a.value.length;++x){var c=a.value[x];S=!!c.optional;var g=f.value[R];if(!g){c.optional||(S=!1,l&&l.push("["+a.name+'] Missing required element. Expected tag class "'+c.tagClass+'", type "'+c.type+'"'));continue}var C=typeof c.tagClass<"u"&&typeof c.type<"u";if(C&&(g.tagClass!==c.tagClass||g.type!==c.type))if(c.optional){S=!0;continue}else{S=!1,l&&l.push("["+a.name+"] Tag mismatch. Expected ("+c.tagClass+","+c.type+"), got ("+g.tagClass+","+g.type+")");break}var m=e.validate(g,c,p,l);if(m)++R,S=!0;else if(c.optional)S=!0;else{S=!1;break}}if(S&&p&&(a.capture&&(p[a.capture]=f.value),a.captureAsn1&&(p[a.captureAsn1]=f),a.captureBitStringContents&&"bitStringContents"in f&&(p[a.captureBitStringContents]=f.bitStringContents),a.captureBitStringValue&&"bitStringContents"in f))if(f.bitStringContents.length<2)p[a.captureBitStringValue]="";else{var i=f.bitStringContents.charCodeAt(0);if(i!==0)throw new Error("captureBitStringValue only supported for zero unused bits");p[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 S};var y=/[^\\u0000-\\u00ff]/;return e.prettyPrint=function(f,a,p){var l="";a=a||0,p=p||2,a>0&&(l+=`
5
+ `);for(var S="",R=0;R<a*p;++R)S+=" ";switch(l+=S+"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+=S+"Constructed: "+f.constructed+`
7
+ `,f.composed){for(var x=0,c="",R=0;R<f.value.length;++R)f.value[R]!==void 0&&(x+=1,c+=e.prettyPrint(f.value[R],a+1,p),R+1<f.value.length&&(c+=","));l+=S+"Sub values: "+x+c}else{if(l+=S+"Value: ",f.type===e.Type.OID){var g=e.derToOid(f.value);l+=g,t.pki&&t.pki.oids&&g in t.pki.oids&&(l+=" ("+t.pki.oids[g]+") ")}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 C=f.value.charCodeAt(0);C==1?l+=" (1 unused bit shown)":C>1&&(l+=" ("+C+" 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(m){if(m.message==="URI malformed")l+="0x"+t.util.bytesToHex(f.value)+" (malformed UTF8)";else throw m}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},pr.exports}var vr={exports:{}},yr,xa;function st(){if(xa)return yr;xa=1;var t=ue();return yr=t.md=t.md||{},t.md.algorithms=t.md.algorithms||{},yr}var Sa;function Rt(){if(Sa)return vr.exports;Sa=1;var t=ue();st(),ce();var e=vr.exports=t.hmac=t.hmac||{};return e.create=function(){var r=null,o=null,E=null,y=null,f={};return f.start=function(a,p){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(p===null)p=r;else{if(typeof p=="string")p=t.util.createBuffer(p);else if(t.util.isArray(p)){var l=p;p=t.util.createBuffer();for(var S=0;S<l.length;++S)p.putByte(l[S])}var R=p.length();R>o.blockLength&&(o.start(),o.update(p.bytes()),p=o.digest()),E=t.util.createBuffer(),y=t.util.createBuffer(),R=p.length();for(var S=0;S<R;++S){var l=p.at(S);E.putByte(54^l),y.putByte(92^l)}if(R<o.blockLength)for(var l=o.blockLength-R,S=0;S<l;++S)E.putByte(54),y.putByte(92);r=p,E=E.bytes(),y=y.bytes()}o.start(),o.update(E)},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},vr.exports}var mr={exports:{}},Ta;function Cr(){if(Ta)return mr.exports;Ta=1;var t=ue();st(),ce();var e=mr.exports=t.md5=t.md5||{};t.md.md5=t.md.algorithms.md5=e,e.create=function(){f||a();var l=null,S=t.util.createBuffer(),R=new Array(16),x={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return x.start=function(){x.messageLength=0,x.fullMessageLength=x.messageLength64=[];for(var c=x.messageLengthSize/4,g=0;g<c;++g)x.fullMessageLength.push(0);return S=t.util.createBuffer(),l={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},x},x.start(),x.update=function(c,g){g==="utf8"&&(c=t.util.encodeUtf8(c));var C=c.length;x.messageLength+=C,C=[C/4294967296>>>0,C>>>0];for(var m=x.fullMessageLength.length-1;m>=0;--m)x.fullMessageLength[m]+=C[1],C[1]=C[0]+(x.fullMessageLength[m]/4294967296>>>0),x.fullMessageLength[m]=x.fullMessageLength[m]>>>0,C[0]=C[1]/4294967296>>>0;return S.putBytes(c),p(l,R,S),(S.read>2048||S.length()===0)&&S.compact(),x},x.digest=function(){var c=t.util.createBuffer();c.putBytes(S.bytes());var g=x.fullMessageLength[x.fullMessageLength.length-1]+x.messageLengthSize,C=g&x.blockLength-1;c.putBytes(r.substr(0,x.blockLength-C));for(var m,i=0,h=x.fullMessageLength.length-1;h>=0;--h)m=x.fullMessageLength[h]*8+i,i=m/4294967296>>>0,c.putInt32Le(m>>>0);var v={h0:l.h0,h1:l.h1,h2:l.h2,h3:l.h3};p(v,R,c);var I=t.util.createBuffer();return I.putInt32Le(v.h0),I.putInt32Le(v.h1),I.putInt32Le(v.h2),I.putInt32Le(v.h3),I},x};var r=null,o=null,E=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],E=[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 p(l,S,R){for(var x,c,g,C,m,i,h,v,I=R.length();I>=64;){for(c=l.h0,g=l.h1,C=l.h2,m=l.h3,v=0;v<16;++v)S[v]=R.getInt32Le(),i=m^g&(C^m),x=c+i+y[v]+S[v],h=E[v],c=m,m=C,C=g,g+=x<<h|x>>>32-h;for(;v<32;++v)i=C^m&(g^C),x=c+i+y[v]+S[o[v]],h=E[v],c=m,m=C,C=g,g+=x<<h|x>>>32-h;for(;v<48;++v)i=g^C^m,x=c+i+y[v]+S[o[v]],h=E[v],c=m,m=C,C=g,g+=x<<h|x>>>32-h;for(;v<64;++v)i=C^(g|~m),x=c+i+y[v]+S[o[v]],h=E[v],c=m,m=C,C=g,g+=x<<h|x>>>32-h;l.h0=l.h0+c|0,l.h1=l.h1+g|0,l.h2=l.h2+C|0,l.h3=l.h3+m|0,I-=64}}return mr.exports}var Er={exports:{}},Aa;function Ct(){if(Aa)return Er.exports;Aa=1;var t=ue();ce();var e=Er.exports=t.pem=t.pem||{};e.encode=function(E,y){y=y||{};var f="-----BEGIN "+E.type+`-----\r
8
+ `,a;if(E.procType&&(a={name:"Proc-Type",values:[String(E.procType.version),E.procType.type]},f+=r(a)),E.contentDomain&&(a={name:"Content-Domain",values:[E.contentDomain]},f+=r(a)),E.dekInfo&&(a={name:"DEK-Info",values:[E.dekInfo.algorithm]},E.dekInfo.parameters&&a.values.push(E.dekInfo.parameters),f+=r(a)),E.headers)for(var p=0;p<E.headers.length;++p)f+=r(E.headers[p]);return E.procType&&(f+=`\r
9
+ `),f+=t.util.encode64(E.body,y.maxline||64)+`\r
10
+ `,f+="-----END "+E.type+`-----\r
11
+ `,f},e.decode=function(E){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^:]+)/,p=/\r?\n/,l;l=f.exec(E),!!l;){var S=l[1];S==="NEW CERTIFICATE REQUEST"&&(S="CERTIFICATE REQUEST");var R={type:S,procType:null,contentDomain:null,dekInfo:null,headers:[],body:t.util.decode64(l[3])};if(y.push(R),!!l[2]){for(var x=l[2].split(p),c=0;l&&c<x.length;){for(var g=x[c].replace(/\s+$/,""),C=c+1;C<x.length;++C){var m=x[C];if(!/\s/.test(m[0]))break;g+=m,c=C}if(l=g.match(a),l){for(var i={name:l[1],values:[]},h=l[2].split(","),v=0;v<h.length;++v)i.values.push(o(h[v]));if(R.procType)if(!R.contentDomain&&i.name==="Content-Domain")R.contentDomain=h[0]||"";else if(!R.dekInfo&&i.name==="DEK-Info"){if(i.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');R.dekInfo={algorithm:h[0],parameters:h[1]||null}}else R.headers.push(i);else{if(i.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(i.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');R.procType={version:h[0],type:h[1]}}}++c}if(R.procType==="ENCRYPTED"&&!R.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(E){for(var y=E.name+": ",f=[],a=function(x,c){return" "+c},p=0;p<E.values.length;++p)f.push(E.values[p].replace(/^(\S+\r\n)/,a));y+=f.join(",")+`\r
12
+ `;for(var l=0,S=-1,p=0;p<y.length;++p,++l)if(l>65&&S!==-1){var R=y[S];R===","?(++S,y=y.substr(0,S)+`\r
13
+ `+y.substr(S)):y=y.substr(0,S)+`\r
14
+ `+R+y.substr(S+1),l=p-S-1,S=-1,++p}else(y[p]===" "||y[p]===" "||y[p]===",")&&(S=p);return y}function o(E){return E.replace(/^\s+/,"")}return Er.exports}var xr={exports:{}},Sr,Ia;function Ft(){if(Ia)return Sr;Ia=1;var t=ue();fr(),ya(),ce(),Sr=t.des=t.des||{},t.des.startEncrypting=function(c,g,C,m){var i=x({key:c,output:C,decrypt:!1,mode:m||(g===null?"ECB":"CBC")});return i.start(g),i},t.des.createEncryptionCipher=function(c,g){return x({key:c,output:null,decrypt:!1,mode:g})},t.des.startDecrypting=function(c,g,C,m){var i=x({key:c,output:C,decrypt:!0,mode:m||(g===null?"ECB":"CBC")});return i.start(g),i},t.des.createDecryptionCipher=function(c,g){return x({key:c,output:null,decrypt:!0,mode:g})},t.des.Algorithm=function(c,g){var C=this;C.name=c,C.mode=new g({blockSize:8,cipher:{encrypt:function(m,i){return R(C._keys,m,i,!1)},decrypt:function(m,i){return R(C._keys,m,i,!0)}}}),C._init=!1},t.des.Algorithm.prototype.initialize=function(c){if(!this._init){var g=t.util.createBuffer(c.key);if(this.name.indexOf("3DES")===0&&g.length()!==24)throw new Error("Invalid Triple-DES key size: "+g.length()*8);this._keys=S(g),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,g){var C=function(){return new t.des.Algorithm(c,g)};t.cipher.registerAlgorithm(c,C)}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],E=[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],p=[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 S(c){for(var g=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],C=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],m=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[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],I=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],N=[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],s=[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],B=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],U=[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],P=c.length()>8?3:1,M=[],q=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],F=0,G,W=0;W<P;W++){var X=c.getInt32(),ee=c.getInt32();G=(X>>>4^ee)&252645135,ee^=G,X^=G<<4,G=(ee>>>-16^X)&65535,X^=G,ee^=G<<-16,G=(X>>>2^ee)&858993459,ee^=G,X^=G<<2,G=(ee>>>-16^X)&65535,X^=G,ee^=G<<-16,G=(X>>>1^ee)&1431655765,ee^=G,X^=G<<1,G=(ee>>>8^X)&16711935,X^=G,ee^=G<<8,G=(X>>>1^ee)&1431655765,ee^=G,X^=G<<1,G=X<<8|ee>>>20&240,X=ee<<24|ee<<8&16711680|ee>>>8&65280|ee>>>24&240,ee=G;for(var ne=0;ne<q.length;++ne){q[ne]?(X=X<<2|X>>>26,ee=ee<<2|ee>>>26):(X=X<<1|X>>>27,ee=ee<<1|ee>>>27),X&=-15,ee&=-15;var ie=g[X>>>28]|C[X>>>24&15]|m[X>>>20&15]|i[X>>>16&15]|h[X>>>12&15]|v[X>>>8&15]|I[X>>>4&15],de=N[ee>>>28]|d[ee>>>24&15]|s[ee>>>20&15]|n[ee>>>16&15]|B[ee>>>12&15]|U[ee>>>8&15]|O[ee>>>4&15];G=(de>>>16^ie)&65535,M[F++]=ie^G,M[F++]=de^G<<16}}return M}function R(c,g,C,m){var i=c.length===32?3:9,h;i===3?h=m?[30,-2,-2]:[0,32,2]:h=m?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var v,I=g[0],N=g[1];v=(I>>>4^N)&252645135,N^=v,I^=v<<4,v=(I>>>16^N)&65535,N^=v,I^=v<<16,v=(N>>>2^I)&858993459,I^=v,N^=v<<2,v=(N>>>8^I)&16711935,I^=v,N^=v<<8,v=(I>>>1^N)&1431655765,N^=v,I^=v<<1,I=I<<1|I>>>31,N=N<<1|N>>>31;for(var d=0;d<i;d+=3){for(var s=h[d+1],n=h[d+2],B=h[d];B!=s;B+=n){var U=N^c[B],O=(N>>>4|N<<28)^c[B+1];v=I,I=N,N=v^(o[U>>>24&63]|y[U>>>16&63]|a[U>>>8&63]|l[U&63]|r[O>>>24&63]|E[O>>>16&63]|f[O>>>8&63]|p[O&63])}v=I,I=N,N=v}I=I>>>1|I<<31,N=N>>>1|N<<31,v=(I>>>1^N)&1431655765,N^=v,I^=v<<1,v=(N>>>8^I)&16711935,I^=v,N^=v<<8,v=(N>>>2^I)&858993459,I^=v,N^=v<<2,v=(I>>>16^N)&65535,N^=v,I^=v<<16,v=(I>>>4^N)&252645135,N^=v,I^=v<<4,C[0]=I,C[1]=N}function x(c){c=c||{};var g=(c.mode||"CBC").toUpperCase(),C="DES-"+g,m;c.decrypt?m=t.cipher.createDecipher(C,c.key):m=t.cipher.createCipher(C,c.key);var i=m.start;return m.start=function(h,v){var I=null;v instanceof t.util.ByteBuffer&&(I=v,v={}),v=v||{},v.output=I,v.iv=h,i.call(m,v)},m}return Sr}const Tr=li(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Ar,Ba;function Ir(){if(Ba)return Ar;Ba=1;var t=ue();Rt(),st(),ce();var e=t.pkcs5=t.pkcs5||{},r;return t.util.isNodejs&&!t.options.usePureJavaScript&&(r=Tr),Ar=t.pbkdf2=e.pbkdf2=function(o,E,y,f,a,p){if(typeof a=="function"&&(p=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"),E=Buffer.from(E,"binary"),p?r.pbkdf2Sync.length===4?r.pbkdf2(o,E,y,f,function(d,s){if(d)return p(d);p(null,s.toString("binary"))}):r.pbkdf2(o,E,y,f,a,function(d,s){if(d)return p(d);p(null,s.toString("binary"))}):r.pbkdf2Sync.length===4?r.pbkdf2Sync(o,E,y,f).toString("binary"):r.pbkdf2Sync(o,E,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 S=new Error("Derived key is too long.");if(p)return p(S);throw S}var R=Math.ceil(f/l),x=f-(R-1)*l,c=t.hmac.create();c.start(a,o);var g="",C,m,i;if(!p){for(var h=1;h<=R;++h){c.start(null,null),c.update(E),c.update(t.util.int32ToBytes(h)),C=i=c.digest().getBytes();for(var v=2;v<=y;++v)c.start(null,null),c.update(i),m=c.digest().getBytes(),C=t.util.xorBytes(C,m,l),i=m;g+=h<R?C:C.substr(0,x)}return g}var h=1,v;function I(){if(h>R)return p(null,g);c.start(null,null),c.update(E),c.update(t.util.int32ToBytes(h)),C=i=c.digest().getBytes(),v=2,N()}function N(){if(v<=y)return c.start(null,null),c.update(i),m=c.digest().getBytes(),C=t.util.xorBytes(C,m,l),i=m,++v,t.util.setImmediate(N);g+=h<R?C:C.substr(0,x),++h,I()}I()},Ar}var qt={exports:{}},Br={exports:{}},ba;function wa(){if(ba)return Br.exports;ba=1;var t=ue();st(),ce();var e=Br.exports=t.sha256=t.sha256||{};t.md.sha256=t.md.algorithms.sha256=e,e.create=function(){o||y();var a=null,p=t.util.createBuffer(),l=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return S.start=function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var R=S.messageLengthSize/4,x=0;x<R;++x)S.fullMessageLength.push(0);return p=t.util.createBuffer(),a={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},S},S.start(),S.update=function(R,x){x==="utf8"&&(R=t.util.encodeUtf8(R));var c=R.length;S.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var g=S.fullMessageLength.length-1;g>=0;--g)S.fullMessageLength[g]+=c[1],c[1]=c[0]+(S.fullMessageLength[g]/4294967296>>>0),S.fullMessageLength[g]=S.fullMessageLength[g]>>>0,c[0]=c[1]/4294967296>>>0;return p.putBytes(R),f(a,l,p),(p.read>2048||p.length()===0)&&p.compact(),S},S.digest=function(){var R=t.util.createBuffer();R.putBytes(p.bytes());var x=S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize,c=x&S.blockLength-1;R.putBytes(r.substr(0,S.blockLength-c));for(var g,C,m=S.fullMessageLength[0]*8,i=0;i<S.fullMessageLength.length-1;++i)g=S.fullMessageLength[i+1]*8,C=g/4294967296>>>0,m+=C,R.putInt32(m>>>0),m=g>>>0;R.putInt32(m);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,R);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},S};var r=null,o=!1,E=null;function y(){r="€",r+=t.util.fillString("\0",64),E=[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,p,l){for(var S,R,x,c,g,C,m,i,h,v,I,N,d,s,n,B=l.length();B>=64;){for(m=0;m<16;++m)p[m]=l.getInt32();for(;m<64;++m)S=p[m-2],S=(S>>>17|S<<15)^(S>>>19|S<<13)^S>>>10,R=p[m-15],R=(R>>>7|R<<25)^(R>>>18|R<<14)^R>>>3,p[m]=S+p[m-7]+R+p[m-16]|0;for(i=a.h0,h=a.h1,v=a.h2,I=a.h3,N=a.h4,d=a.h5,s=a.h6,n=a.h7,m=0;m<64;++m)c=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),g=s^N&(d^s),x=(i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10),C=i&h|v&(i^h),S=n+c+g+E[m]+p[m],R=x+C,n=s,s=d,d=N,N=I+S>>>0,I=v,v=h,h=i,i=S+R>>>0;a.h0=a.h0+i|0,a.h1=a.h1+h|0,a.h2=a.h2+v|0,a.h3=a.h3+I|0,a.h4=a.h4+N|0,a.h5=a.h5+d|0,a.h6=a.h6+s|0,a.h7=a.h7+n|0,B-=64}}return Br.exports}var br={exports:{}},_a;function Ra(){if(_a)return br.exports;_a=1;var t=ue();ce();var e=null;t.util.isNodejs&&!t.options.usePureJavaScript&&!process.versions["node-webkit"]&&(e=Tr);var r=br.exports=t.prng=t.prng||{};return r.create=function(o){for(var E={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();E.pools=f,E.pool=0,E.generate=function(x,c){if(!c)return E.generateSync(x);var g=E.plugin.cipher,C=E.plugin.increment,m=E.plugin.formatKey,i=E.plugin.formatSeed,h=t.util.createBuffer();E.key=null,v();function v(I){if(I)return c(I);if(h.length()>=x)return c(null,h.getBytes(x));if(E.generated>1048575&&(E.key=null),E.key===null)return t.util.nextTick(function(){p(v)});var N=g(E.key,E.seed);E.generated+=N.length,h.putBytes(N),E.key=m(g(E.key,C(E.seed))),E.seed=i(g(E.key,E.seed)),t.util.setImmediate(v)}},E.generateSync=function(x){var c=E.plugin.cipher,g=E.plugin.increment,C=E.plugin.formatKey,m=E.plugin.formatSeed;E.key=null;for(var i=t.util.createBuffer();i.length()<x;){E.generated>1048575&&(E.key=null),E.key===null&&l();var h=c(E.key,E.seed);E.generated+=h.length,i.putBytes(h),E.key=C(c(E.key,g(E.seed))),E.seed=m(c(E.key,E.seed))}return i.getBytes(x)};function p(x){if(E.pools[0].messageLength>=32)return S(),x();var c=32-E.pools[0].messageLength<<5;E.seedFile(c,function(g,C){if(g)return x(g);E.collect(C),S(),x()})}function l(){if(E.pools[0].messageLength>=32)return S();var x=32-E.pools[0].messageLength<<5;E.collect(E.seedFileSync(x)),S()}function S(){E.reseeds=E.reseeds===4294967295?0:E.reseeds+1;var x=E.plugin.md.create();x.update(E.keyBytes);for(var c=1,g=0;g<32;++g)E.reseeds%c===0&&(x.update(E.pools[g].digest().getBytes()),E.pools[g].start()),c=c<<1;E.keyBytes=x.digest().getBytes(),x.start(),x.update(E.keyBytes);var C=x.digest().getBytes();E.key=E.plugin.formatKey(E.keyBytes),E.seed=E.plugin.formatSeed(C),E.generated=0}function R(x){var c=null,g=t.util.globalScope,C=g.crypto||g.msCrypto;C&&C.getRandomValues&&(c=function(n){return C.getRandomValues(n)});var m=t.util.createBuffer();if(c)for(;m.length()<x;){var i=Math.max(1,Math.min(x-m.length(),65536)/4),h=new Uint32Array(Math.floor(i));try{c(h);for(var v=0;v<h.length;++v)m.putInt32(h[v])}catch(n){if(!(typeof QuotaExceededError<"u"&&n instanceof QuotaExceededError))throw n}}if(m.length()<x)for(var I,N,d,s=Math.floor(Math.random()*65536);m.length()<x;){N=16807*(s&65535),I=16807*(s>>16),N+=(I&32767)<<16,N+=I>>15,N=(N&2147483647)+(N>>31),s=N&4294967295;for(var v=0;v<3;++v)d=s>>>(v<<3),d^=Math.floor(Math.random()*256),m.putByte(d&255)}return m.getBytes(x)}return e?(E.seedFile=function(x,c){e.randomBytes(x,function(g,C){if(g)return c(g);c(null,C.toString())})},E.seedFileSync=function(x){return e.randomBytes(x).toString()}):(E.seedFile=function(x,c){try{c(null,R(x))}catch(g){c(g)}},E.seedFileSync=R),E.collect=function(x){for(var c=x.length,g=0;g<c;++g)E.pools[E.pool].update(x.substr(g,1)),E.pool=E.pool===31?0:E.pool+1},E.collectInt=function(x,c){for(var g="",C=0;C<c;C+=8)g+=String.fromCharCode(x>>C&255);E.collect(g)},E.registerWorker=function(x){if(x===self)E.seedFile=function(g,C){function m(i){var h=i.data;h.forge&&h.forge.prng&&(self.removeEventListener("message",m),C(h.forge.prng.err,h.forge.prng.bytes))}self.addEventListener("message",m),self.postMessage({forge:{prng:{needed:g}}})};else{var c=function(g){var C=g.data;C.forge&&C.forge.prng&&E.seedFile(C.forge.prng.needed,function(m,i){x.postMessage({forge:{prng:{err:m,bytes:i}}})})};x.addEventListener("message",c)}},E},br.exports}var Na;function Je(){if(Na)return qt.exports;Na=1;var t=ue();return gt(),wa(),Ra(),ce(),(function(){if(t.random&&t.random.getBytes){qt.exports=t.random;return}(function(e){var r={},o=new Array(4),E=t.util.createBuffer();r.formatKey=function(x){var c=t.util.createBuffer(x);return x=new Array(4),x[0]=c.getInt32(),x[1]=c.getInt32(),x[2]=c.getInt32(),x[3]=c.getInt32(),t.aes._expandKey(x,!1)},r.formatSeed=function(x){var c=t.util.createBuffer(x);return x=new Array(4),x[0]=c.getInt32(),x[1]=c.getInt32(),x[2]=c.getInt32(),x[3]=c.getInt32(),x},r.cipher=function(x,c){return t.aes._updateBlock(x,c,o,!1),E.putInt32(o[0]),E.putInt32(o[1]),E.putInt32(o[2]),E.putInt32(o[3]),E.getBytes()},r.increment=function(x){return++x[3],x},r.md=t.md.sha256;function y(){var x=t.prng.create(r);return x.getBytes=function(c,g){return x.generate(c,g)},x.getBytesSync=function(c){return x.generate(c)},x}var f=y(),a=null,p=t.util.globalScope,l=p.crypto||p.msCrypto;if(l&&l.getRandomValues&&(a=function(x){return l.getRandomValues(x)}),t.options.usePureJavaScript||!t.util.isNodejs&&!a){if(f.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var R in navigator)try{typeof navigator[R]=="string"&&(S+=navigator[R])}catch{}f.collect(S),S=null}e&&(e().mousemove(function(x){f.collectInt(x.clientX,16),f.collectInt(x.clientY,16)}),e().keypress(function(x){f.collectInt(x.charCode,8)}))}if(!t.random)t.random=f;else for(var R in f)t.random[R]=f[R];t.random.createInstance=y,qt.exports=t.random})(typeof jQuery<"u"?jQuery:null)})(),qt.exports}var wr,La;function ka(){if(La)return wr;La=1;var t=ue();ce();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},E=function(f,a){return(f&65535)>>a|f<<16-a&65535};wr=t.rc2=t.rc2||{},t.rc2.expandKey=function(f,a){typeof f=="string"&&(f=t.util.createBuffer(f)),a=a||128;var p=f,l=f.length(),S=a,R=Math.ceil(S/8),x=255>>(S&7),c;for(c=l;c<128;c++)p.putByte(e[p.at(c-1)+p.at(c-l)&255]);for(p.setAt(128-R,e[p.at(128-R)&x]),c=127-R;c>=0;c--)p.setAt(c,e[p.at(c+1)^p.at(c+R)]);return p};var y=function(f,a,p){var l=!1,S=null,R=null,x=null,c,g,C,m,i=[];for(f=t.rc2.expandKey(f,a),C=0;C<64;C++)i.push(f.getInt16Le());p?(c=function(I){for(C=0;C<4;C++)I[C]+=i[m]+(I[(C+3)%4]&I[(C+2)%4])+(~I[(C+3)%4]&I[(C+1)%4]),I[C]=o(I[C],r[C]),m++},g=function(I){for(C=0;C<4;C++)I[C]+=i[I[(C+3)%4]&63]}):(c=function(I){for(C=3;C>=0;C--)I[C]=E(I[C],r[C]),I[C]-=i[m]+(I[(C+3)%4]&I[(C+2)%4])+(~I[(C+3)%4]&I[(C+1)%4]),m--},g=function(I){for(C=3;C>=0;C--)I[C]-=i[I[(C+3)%4]&63]});var h=function(I){var N=[];for(C=0;C<4;C++){var d=S.getInt16Le();x!==null&&(p?d^=x.getInt16Le():x.putInt16Le(d)),N.push(d&65535)}m=p?0:63;for(var s=0;s<I.length;s++)for(var n=0;n<I[s][0];n++)I[s][1](N);for(C=0;C<4;C++)x!==null&&(p?x.putInt16Le(N[C]):N[C]^=x.getInt16Le()),R.putInt16Le(N[C])},v=null;return v={start:function(I,N){I&&typeof I=="string"&&(I=t.util.createBuffer(I)),l=!1,S=t.util.createBuffer(),R=N||new t.util.createBuffer,x=I,v.output=R},update:function(I){for(l||S.putBuffer(I);S.length()>=8;)h([[5,c],[1,g],[6,c],[1,g],[5,c]])},finish:function(I){var N=!0;if(p)if(I)N=I(8,S,!p);else{var d=S.length()===8?8:8-S.length();S.fillWithByte(d,d)}if(N&&(l=!0,v.update()),!p&&(N=S.length()===0,N))if(I)N=I(8,R,!p);else{var s=R.length(),n=R.at(s-1);n>s?N=!1:R.truncate(n)}return N}},v};return t.rc2.startEncrypting=function(f,a,p){var l=t.rc2.createEncryptionCipher(f,128);return l.start(a,p),l},t.rc2.createEncryptionCipher=function(f,a){return y(f,a,!0)},t.rc2.startDecrypting=function(f,a,p){var l=t.rc2.createDecryptionCipher(f,128);return l.start(a,p),l},t.rc2.createDecryptionCipher=function(f,a){return y(f,a,!1)},wr}var _r,Ua;function Ht(){if(Ua)return _r;Ua=1;var t=ue();_r=t.jsbn=t.jsbn||{};var e;function r(A,b,D){this.data=[],A!=null&&(typeof A=="number"?this.fromNumber(A,b,D):b==null&&typeof A!="string"?this.fromString(A,256):this.fromString(A,b))}t.jsbn.BigInteger=r;function o(){return new r(null)}function E(A,b,D,K,Q,Y){for(;--Y>=0;){var re=b*this.data[A++]+D.data[K]+Q;Q=Math.floor(re/67108864),D.data[K++]=re&67108863}return Q}function y(A,b,D,K,Q,Y){for(var re=b&32767,J=b>>15;--Y>=0;){var he=this.data[A]&32767,Fe=this.data[A++]>>15,$e=J*he+Fe*re;he=re*he+(($e&32767)<<15)+D.data[K]+(Q&1073741823),Q=(he>>>30)+($e>>>15)+J*Fe+(Q>>>30),D.data[K++]=he&1073741823}return Q}function f(A,b,D,K,Q,Y){for(var re=b&16383,J=b>>14;--Y>=0;){var he=this.data[A]&16383,Fe=this.data[A++]>>14,$e=J*he+Fe*re;he=re*he+(($e&16383)<<14)+D.data[K]+Q,Q=(he>>28)+($e>>14)+J*Fe,D.data[K++]=he&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=E,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 p="0123456789abcdefghijklmnopqrstuvwxyz",l=new Array,S,R;for(S=48,R=0;R<=9;++R)l[S++]=R;for(S=97,R=10;R<36;++R)l[S++]=R;for(S=65,R=10;R<36;++R)l[S++]=R;function x(A){return p.charAt(A)}function c(A,b){var D=l[A.charCodeAt(b)];return D??-1}function g(A){for(var b=this.t-1;b>=0;--b)A.data[b]=this.data[b];A.t=this.t,A.s=this.s}function C(A){this.t=1,this.s=A<0?-1:0,A>0?this.data[0]=A:A<-1?this.data[0]=A+this.DV:this.t=0}function m(A){var b=o();return b.fromInt(A),b}function i(A,b){var D;if(b==16)D=4;else if(b==8)D=3;else if(b==256)D=8;else if(b==2)D=1;else if(b==32)D=5;else if(b==4)D=2;else{this.fromRadix(A,b);return}this.t=0,this.s=0;for(var K=A.length,Q=!1,Y=0;--K>=0;){var re=D==8?A[K]&255:c(A,K);if(re<0){A.charAt(K)=="-"&&(Q=!0);continue}Q=!1,Y==0?this.data[this.t++]=re:Y+D>this.DB?(this.data[this.t-1]|=(re&(1<<this.DB-Y)-1)<<Y,this.data[this.t++]=re>>this.DB-Y):this.data[this.t-1]|=re<<Y,Y+=D,Y>=this.DB&&(Y-=this.DB)}D==8&&(A[0]&128)!=0&&(this.s=-1,Y>0&&(this.data[this.t-1]|=(1<<this.DB-Y)-1<<Y)),this.clamp(),Q&&r.ZERO.subTo(this,this)}function h(){for(var A=this.s&this.DM;this.t>0&&this.data[this.t-1]==A;)--this.t}function v(A){if(this.s<0)return"-"+this.negate().toString(A);var b;if(A==16)b=4;else if(A==8)b=3;else if(A==2)b=1;else if(A==32)b=5;else if(A==4)b=2;else return this.toRadix(A);var D=(1<<b)-1,K,Q=!1,Y="",re=this.t,J=this.DB-re*this.DB%b;if(re-- >0)for(J<this.DB&&(K=this.data[re]>>J)>0&&(Q=!0,Y=x(K));re>=0;)J<b?(K=(this.data[re]&(1<<J)-1)<<b-J,K|=this.data[--re]>>(J+=this.DB-b)):(K=this.data[re]>>(J-=b)&D,J<=0&&(J+=this.DB,--re)),K>0&&(Q=!0),Q&&(Y+=x(K));return Q?Y:"0"}function I(){var A=o();return r.ZERO.subTo(this,A),A}function N(){return this.s<0?this.negate():this}function d(A){var b=this.s-A.s;if(b!=0)return b;var D=this.t;if(b=D-A.t,b!=0)return this.s<0?-b:b;for(;--D>=0;)if((b=this.data[D]-A.data[D])!=0)return b;return 0}function s(A){var b=1,D;return(D=A>>>16)!=0&&(A=D,b+=16),(D=A>>8)!=0&&(A=D,b+=8),(D=A>>4)!=0&&(A=D,b+=4),(D=A>>2)!=0&&(A=D,b+=2),(D=A>>1)!=0&&(A=D,b+=1),b}function n(){return this.t<=0?0:this.DB*(this.t-1)+s(this.data[this.t-1]^this.s&this.DM)}function B(A,b){var D;for(D=this.t-1;D>=0;--D)b.data[D+A]=this.data[D];for(D=A-1;D>=0;--D)b.data[D]=0;b.t=this.t+A,b.s=this.s}function U(A,b){for(var D=A;D<this.t;++D)b.data[D-A]=this.data[D];b.t=Math.max(this.t-A,0),b.s=this.s}function O(A,b){var D=A%this.DB,K=this.DB-D,Q=(1<<K)-1,Y=Math.floor(A/this.DB),re=this.s<<D&this.DM,J;for(J=this.t-1;J>=0;--J)b.data[J+Y+1]=this.data[J]>>K|re,re=(this.data[J]&Q)<<D;for(J=Y-1;J>=0;--J)b.data[J]=0;b.data[Y]=re,b.t=this.t+Y+1,b.s=this.s,b.clamp()}function P(A,b){b.s=this.s;var D=Math.floor(A/this.DB);if(D>=this.t){b.t=0;return}var K=A%this.DB,Q=this.DB-K,Y=(1<<K)-1;b.data[0]=this.data[D]>>K;for(var re=D+1;re<this.t;++re)b.data[re-D-1]|=(this.data[re]&Y)<<Q,b.data[re-D]=this.data[re]>>K;K>0&&(b.data[this.t-D-1]|=(this.s&Y)<<Q),b.t=this.t-D,b.clamp()}function M(A,b){for(var D=0,K=0,Q=Math.min(A.t,this.t);D<Q;)K+=this.data[D]-A.data[D],b.data[D++]=K&this.DM,K>>=this.DB;if(A.t<this.t){for(K-=A.s;D<this.t;)K+=this.data[D],b.data[D++]=K&this.DM,K>>=this.DB;K+=this.s}else{for(K+=this.s;D<A.t;)K-=A.data[D],b.data[D++]=K&this.DM,K>>=this.DB;K-=A.s}b.s=K<0?-1:0,K<-1?b.data[D++]=this.DV+K:K>0&&(b.data[D++]=K),b.t=D,b.clamp()}function q(A,b){var D=this.abs(),K=A.abs(),Q=D.t;for(b.t=Q+K.t;--Q>=0;)b.data[Q]=0;for(Q=0;Q<K.t;++Q)b.data[Q+D.t]=D.am(0,K.data[Q],b,Q,0,D.t);b.s=0,b.clamp(),this.s!=A.s&&r.ZERO.subTo(b,b)}function F(A){for(var b=this.abs(),D=A.t=2*b.t;--D>=0;)A.data[D]=0;for(D=0;D<b.t-1;++D){var K=b.am(D,b.data[D],A,2*D,0,1);(A.data[D+b.t]+=b.am(D+1,2*b.data[D],A,2*D+1,K,b.t-D-1))>=b.DV&&(A.data[D+b.t]-=b.DV,A.data[D+b.t+1]=1)}A.t>0&&(A.data[A.t-1]+=b.am(D,b.data[D],A,2*D,0,1)),A.s=0,A.clamp()}function G(A,b,D){var K=A.abs();if(!(K.t<=0)){var Q=this.abs();if(Q.t<K.t){b?.fromInt(0),D!=null&&this.copyTo(D);return}D==null&&(D=o());var Y=o(),re=this.s,J=A.s,he=this.DB-s(K.data[K.t-1]);he>0?(K.lShiftTo(he,Y),Q.lShiftTo(he,D)):(K.copyTo(Y),Q.copyTo(D));var Fe=Y.t,$e=Y.data[Fe-1];if($e!=0){var Xe=$e*(1<<this.F1)+(Fe>1?Y.data[Fe-2]>>this.F2:0),ut=this.FV/Xe,Xt=(1<<this.F1)/Xe,rt=1<<this.F2,at=D.t,jt=at-Fe,ht=b??o();for(Y.dlShiftTo(jt,ht),D.compareTo(ht)>=0&&(D.data[D.t++]=1,D.subTo(ht,D)),r.ONE.dlShiftTo(Fe,ht),ht.subTo(Y,Y);Y.t<Fe;)Y.data[Y.t++]=0;for(;--jt>=0;){var ea=D.data[--at]==$e?this.DM:Math.floor(D.data[at]*ut+(D.data[at-1]+rt)*Xt);if((D.data[at]+=Y.am(0,ea,D,jt,0,Fe))<ea)for(Y.dlShiftTo(jt,ht),D.subTo(ht,D);D.data[at]<--ea;)D.subTo(ht,D)}b!=null&&(D.drShiftTo(Fe,b),re!=J&&r.ZERO.subTo(b,b)),D.t=Fe,D.clamp(),he>0&&D.rShiftTo(he,D),re<0&&r.ZERO.subTo(D,D)}}}function W(A){var b=o();return this.abs().divRemTo(A,null,b),this.s<0&&b.compareTo(r.ZERO)>0&&A.subTo(b,b),b}function X(A){this.m=A}function ee(A){return A.s<0||A.compareTo(this.m)>=0?A.mod(this.m):A}function ne(A){return A}function ie(A){A.divRemTo(this.m,null,A)}function de(A,b,D){A.multiplyTo(b,D),this.reduce(D)}function ge(A,b){A.squareTo(b),this.reduce(b)}X.prototype.convert=ee,X.prototype.revert=ne,X.prototype.reduce=ie,X.prototype.mulTo=de,X.prototype.sqrTo=ge;function le(){if(this.t<1)return 0;var A=this.data[0];if((A&1)==0)return 0;var b=A&3;return b=b*(2-(A&15)*b)&15,b=b*(2-(A&255)*b)&255,b=b*(2-((A&65535)*b&65535))&65535,b=b*(2-A*b%this.DV)%this.DV,b>0?this.DV-b:-b}function j(A){this.m=A,this.mp=A.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<A.DB-15)-1,this.mt2=2*A.t}function $(A){var b=o();return A.abs().dlShiftTo(this.m.t,b),b.divRemTo(this.m,null,b),A.s<0&&b.compareTo(r.ZERO)>0&&this.m.subTo(b,b),b}function ze(A){var b=o();return A.copyTo(b),this.reduce(b),b}function qe(A){for(;A.t<=this.mt2;)A.data[A.t++]=0;for(var b=0;b<this.m.t;++b){var D=A.data[b]&32767,K=D*this.mpl+((D*this.mph+(A.data[b]>>15)*this.mpl&this.um)<<15)&A.DM;for(D=b+this.m.t,A.data[D]+=this.m.am(0,K,A,b,0,this.m.t);A.data[D]>=A.DV;)A.data[D]-=A.DV,A.data[++D]++}A.clamp(),A.drShiftTo(this.m.t,A),A.compareTo(this.m)>=0&&A.subTo(this.m,A)}function T(A,b){A.squareTo(b),this.reduce(b)}function k(A,b,D){A.multiplyTo(b,D),this.reduce(D)}j.prototype.convert=$,j.prototype.revert=ze,j.prototype.reduce=qe,j.prototype.mulTo=k,j.prototype.sqrTo=T;function L(){return(this.t>0?this.data[0]&1:this.s)==0}function _(A,b){if(A>4294967295||A<1)return r.ONE;var D=o(),K=o(),Q=b.convert(this),Y=s(A)-1;for(Q.copyTo(D);--Y>=0;)if(b.sqrTo(D,K),(A&1<<Y)>0)b.mulTo(K,Q,D);else{var re=D;D=K,K=re}return b.revert(D)}function u(A,b){var D;return A<256||b.isEven()?D=new X(b):D=new j(b),this.exp(A,D)}r.prototype.copyTo=g,r.prototype.fromInt=C,r.prototype.fromString=i,r.prototype.clamp=h,r.prototype.dlShiftTo=B,r.prototype.drShiftTo=U,r.prototype.lShiftTo=O,r.prototype.rShiftTo=P,r.prototype.subTo=M,r.prototype.multiplyTo=q,r.prototype.squareTo=F,r.prototype.divRemTo=G,r.prototype.invDigit=le,r.prototype.isEven=L,r.prototype.exp=_,r.prototype.toString=v,r.prototype.negate=I,r.prototype.abs=N,r.prototype.compareTo=d,r.prototype.bitLength=n,r.prototype.mod=W,r.prototype.modPowInt=u,r.ZERO=m(0),r.ONE=m(1);function w(){var A=o();return this.copyTo(A),A}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 H(){return this.t==0?this.s:this.data[0]<<24>>24}function ae(){return this.t==0?this.s:this.data[0]<<16>>16}function te(A){return Math.floor(Math.LN2*this.DB/Math.log(A))}function z(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function Z(A){if(A==null&&(A=10),this.signum()==0||A<2||A>36)return"0";var b=this.chunkSize(A),D=Math.pow(A,b),K=m(D),Q=o(),Y=o(),re="";for(this.divRemTo(K,Q,Y);Q.signum()>0;)re=(D+Y.intValue()).toString(A).substr(1)+re,Q.divRemTo(K,Q,Y);return Y.intValue().toString(A)+re}function se(A,b){this.fromInt(0),b==null&&(b=10);for(var D=this.chunkSize(b),K=Math.pow(b,D),Q=!1,Y=0,re=0,J=0;J<A.length;++J){var he=c(A,J);if(he<0){A.charAt(J)=="-"&&this.signum()==0&&(Q=!0);continue}re=b*re+he,++Y>=D&&(this.dMultiply(K),this.dAddOffset(re,0),Y=0,re=0)}Y>0&&(this.dMultiply(Math.pow(b,Y)),this.dAddOffset(re,0)),Q&&r.ZERO.subTo(this,this)}function fe(A,b,D){if(typeof b=="number")if(A<2)this.fromInt(1);else for(this.fromNumber(A,D),this.testBit(A-1)||this.bitwiseTo(r.ONE.shiftLeft(A-1),pe,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>A&&this.subTo(r.ONE.shiftLeft(A-1),this);else{var K=new Array,Q=A&7;K.length=(A>>3)+1,b.nextBytes(K),Q>0?K[0]&=(1<<Q)-1:K[0]=0,this.fromString(K,256)}}function oe(){var A=this.t,b=new Array;b[0]=this.s;var D=this.DB-A*this.DB%8,K,Q=0;if(A-- >0)for(D<this.DB&&(K=this.data[A]>>D)!=(this.s&this.DM)>>D&&(b[Q++]=K|this.s<<this.DB-D);A>=0;)D<8?(K=(this.data[A]&(1<<D)-1)<<8-D,K|=this.data[--A]>>(D+=this.DB-8)):(K=this.data[A]>>(D-=8)&255,D<=0&&(D+=this.DB,--A)),(K&128)!=0&&(K|=-256),Q==0&&(this.s&128)!=(K&128)&&++Q,(Q>0||K!=this.s)&&(b[Q++]=K);return b}function Ce(A){return this.compareTo(A)==0}function Te(A){return this.compareTo(A)<0?this:A}function Se(A){return this.compareTo(A)>0?this:A}function Ee(A,b,D){var K,Q,Y=Math.min(A.t,this.t);for(K=0;K<Y;++K)D.data[K]=b(this.data[K],A.data[K]);if(A.t<this.t){for(Q=A.s&this.DM,K=Y;K<this.t;++K)D.data[K]=b(this.data[K],Q);D.t=this.t}else{for(Q=this.s&this.DM,K=Y;K<A.t;++K)D.data[K]=b(Q,A.data[K]);D.t=A.t}D.s=b(this.s,A.s),D.clamp()}function ye(A,b){return A&b}function ve(A){var b=o();return this.bitwiseTo(A,ye,b),b}function pe(A,b){return A|b}function Ie(A){var b=o();return this.bitwiseTo(A,pe,b),b}function Be(A,b){return A^b}function He(A){var b=o();return this.bitwiseTo(A,Be,b),b}function Ge(A,b){return A&~b}function We(A){var b=o();return this.bitwiseTo(A,Ge,b),b}function Ye(){for(var A=o(),b=0;b<this.t;++b)A.data[b]=this.DM&~this.data[b];return A.t=this.t,A.s=~this.s,A}function je(A){var b=o();return A<0?this.rShiftTo(-A,b):this.lShiftTo(A,b),b}function et(A){var b=o();return A<0?this.lShiftTo(-A,b):this.rShiftTo(A,b),b}function it(A){if(A==0)return-1;var b=0;return(A&65535)==0&&(A>>=16,b+=16),(A&255)==0&&(A>>=8,b+=8),(A&15)==0&&(A>>=4,b+=4),(A&3)==0&&(A>>=2,b+=2),(A&1)==0&&++b,b}function ot(){for(var A=0;A<this.t;++A)if(this.data[A]!=0)return A*this.DB+it(this.data[A]);return this.s<0?this.t*this.DB:-1}function dt(A){for(var b=0;A!=0;)A&=A-1,++b;return b}function yt(){for(var A=0,b=this.s&this.DM,D=0;D<this.t;++D)A+=dt(this.data[D]^b);return A}function Et(A){var b=Math.floor(A/this.DB);return b>=this.t?this.s!=0:(this.data[b]&1<<A%this.DB)!=0}function Lt(A,b){var D=r.ONE.shiftLeft(A);return this.bitwiseTo(D,b,D),D}function Yt(A){return this.changeBit(A,pe)}function be(A){return this.changeBit(A,Ge)}function we(A){return this.changeBit(A,Be)}function _e(A,b){for(var D=0,K=0,Q=Math.min(A.t,this.t);D<Q;)K+=this.data[D]+A.data[D],b.data[D++]=K&this.DM,K>>=this.DB;if(A.t<this.t){for(K+=A.s;D<this.t;)K+=this.data[D],b.data[D++]=K&this.DM,K>>=this.DB;K+=this.s}else{for(K+=this.s;D<A.t;)K+=A.data[D],b.data[D++]=K&this.DM,K>>=this.DB;K+=A.s}b.s=K<0?-1:0,K>0?b.data[D++]=K:K<-1&&(b.data[D++]=this.DV+K),b.t=D,b.clamp()}function Re(A){var b=o();return this.addTo(A,b),b}function Ne(A){var b=o();return this.subTo(A,b),b}function Le(A){var b=o();return this.multiplyTo(A,b),b}function ke(){var A=o();return this.squareTo(A),A}function Ue(A){var b=o();return this.divRemTo(A,b,null),b}function De(A){var b=o();return this.divRemTo(A,null,b),b}function Pe(A){var b=o(),D=o();return this.divRemTo(A,b,D),new Array(b,D)}function Ve(A){this.data[this.t]=this.am(0,A-1,this,0,0,this.t),++this.t,this.clamp()}function Oe(A,b){if(A!=0){for(;this.t<=b;)this.data[this.t++]=0;for(this.data[b]+=A;this.data[b]>=this.DV;)this.data[b]-=this.DV,++b>=this.t&&(this.data[this.t++]=0),++this.data[b]}}function me(){}function Ae(A){return A}function Me(A,b,D){A.multiplyTo(b,D)}function Ke(A,b){A.squareTo(b)}me.prototype.convert=Ae,me.prototype.revert=Ae,me.prototype.mulTo=Me,me.prototype.sqrTo=Ke;function Pi(A){return this.exp(A,new me)}function Vi(A,b,D){var K=Math.min(this.t+A.t,b);for(D.s=0,D.t=K;K>0;)D.data[--K]=0;var Q;for(Q=D.t-this.t;K<Q;++K)D.data[K+this.t]=this.am(0,A.data[K],D,K,0,this.t);for(Q=Math.min(A.t,b);K<Q;++K)this.am(0,A.data[K],D,K,0,b-K);D.clamp()}function Oi(A,b,D){--b;var K=D.t=this.t+A.t-b;for(D.s=0;--K>=0;)D.data[K]=0;for(K=Math.max(b-this.t,0);K<A.t;++K)D.data[this.t+K-b]=this.am(b-K,A.data[K],D,0,0,this.t+K-b);D.clamp(),D.drShiftTo(1,D)}function xt(A){this.r2=o(),this.q3=o(),r.ONE.dlShiftTo(2*A.t,this.r2),this.mu=this.r2.divide(A),this.m=A}function Mi(A){if(A.s<0||A.t>2*this.m.t)return A.mod(this.m);if(A.compareTo(this.m)<0)return A;var b=o();return A.copyTo(b),this.reduce(b),b}function Ki(A){return A}function Fi(A){for(A.drShiftTo(this.m.t-1,this.r2),A.t>this.m.t+1&&(A.t=this.m.t+1,A.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);A.compareTo(this.r2)<0;)A.dAddOffset(1,this.m.t+1);for(A.subTo(this.r2,A);A.compareTo(this.m)>=0;)A.subTo(this.m,A)}function qi(A,b){A.squareTo(b),this.reduce(b)}function Hi(A,b,D){A.multiplyTo(b,D),this.reduce(D)}xt.prototype.convert=Mi,xt.prototype.revert=Ki,xt.prototype.reduce=Fi,xt.prototype.mulTo=Hi,xt.prototype.sqrTo=qi;function Gi(A,b){var D=A.bitLength(),K,Q=m(1),Y;if(D<=0)return Q;D<18?K=1:D<48?K=3:D<144?K=4:D<768?K=5:K=6,D<8?Y=new X(b):b.isEven()?Y=new xt(b):Y=new j(b);var re=new Array,J=3,he=K-1,Fe=(1<<K)-1;if(re[1]=Y.convert(this),K>1){var $e=o();for(Y.sqrTo(re[1],$e);J<=Fe;)re[J]=o(),Y.mulTo($e,re[J-2],re[J]),J+=2}var Xe=A.t-1,ut,Xt=!0,rt=o(),at;for(D=s(A.data[Xe])-1;Xe>=0;){for(D>=he?ut=A.data[Xe]>>D-he&Fe:(ut=(A.data[Xe]&(1<<D+1)-1)<<he-D,Xe>0&&(ut|=A.data[Xe-1]>>this.DB+D-he)),J=K;(ut&1)==0;)ut>>=1,--J;if((D-=J)<0&&(D+=this.DB,--Xe),Xt)re[ut].copyTo(Q),Xt=!1;else{for(;J>1;)Y.sqrTo(Q,rt),Y.sqrTo(rt,Q),J-=2;J>0?Y.sqrTo(Q,rt):(at=Q,Q=rt,rt=at),Y.mulTo(rt,re[ut],Q)}for(;Xe>=0&&(A.data[Xe]&1<<D)==0;)Y.sqrTo(Q,rt),at=Q,Q=rt,rt=at,--D<0&&(D=this.DB-1,--Xe)}return Y.revert(Q)}function zi(A){var b=this.s<0?this.negate():this.clone(),D=A.s<0?A.negate():A.clone();if(b.compareTo(D)<0){var K=b;b=D,D=K}var Q=b.getLowestSetBit(),Y=D.getLowestSetBit();if(Y<0)return b;for(Q<Y&&(Y=Q),Y>0&&(b.rShiftTo(Y,b),D.rShiftTo(Y,D));b.signum()>0;)(Q=b.getLowestSetBit())>0&&b.rShiftTo(Q,b),(Q=D.getLowestSetBit())>0&&D.rShiftTo(Q,D),b.compareTo(D)>=0?(b.subTo(D,b),b.rShiftTo(1,b)):(D.subTo(b,D),D.rShiftTo(1,D));return Y>0&&D.lShiftTo(Y,D),D}function Qi(A){if(A<=0)return 0;var b=this.DV%A,D=this.s<0?A-1:0;if(this.t>0)if(b==0)D=this.data[0]%A;else for(var K=this.t-1;K>=0;--K)D=(b*D+this.data[K])%A;return D}function Wi(A){if(this.signum()==0)return r.ZERO;var b=A.isEven();if(this.isEven()&&b||A.signum()==0)return r.ZERO;for(var D=A.clone(),K=this.clone(),Q=m(1),Y=m(0),re=m(0),J=m(1);D.signum()!=0;){for(;D.isEven();)D.rShiftTo(1,D),b?((!Q.isEven()||!Y.isEven())&&(Q.addTo(this,Q),Y.subTo(A,Y)),Q.rShiftTo(1,Q)):Y.isEven()||Y.subTo(A,Y),Y.rShiftTo(1,Y);for(;K.isEven();)K.rShiftTo(1,K),b?((!re.isEven()||!J.isEven())&&(re.addTo(this,re),J.subTo(A,J)),re.rShiftTo(1,re)):J.isEven()||J.subTo(A,J),J.rShiftTo(1,J);D.compareTo(K)>=0?(D.subTo(K,D),b&&Q.subTo(re,Q),Y.subTo(J,Y)):(K.subTo(D,K),b&&re.subTo(Q,re),J.subTo(Y,J))}if(K.compareTo(r.ONE)!=0)return r.ZERO;if(J.compareTo(A)>=0)return J.subtract(A);if(J.signum()<0)J.addTo(A,J);else return J;return J.signum()<0?J.add(A):J}var tt=[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],Yi=(1<<26)/tt[tt.length-1];function Xi(A){var b,D=this.abs();if(D.t==1&&D.data[0]<=tt[tt.length-1]){for(b=0;b<tt.length;++b)if(D.data[0]==tt[b])return!0;return!1}if(D.isEven())return!1;for(b=1;b<tt.length;){for(var K=tt[b],Q=b+1;Q<tt.length&&K<Yi;)K*=tt[Q++];for(K=D.modInt(K);b<Q;)if(K%tt[b++]==0)return!1}return D.millerRabin(A)}function ji(A){var b=this.subtract(r.ONE),D=b.getLowestSetBit();if(D<=0)return!1;for(var K=b.shiftRight(D),Q=$i(),Y,re=0;re<A;++re){do Y=new r(this.bitLength(),Q);while(Y.compareTo(r.ONE)<=0||Y.compareTo(b)>=0);var J=Y.modPow(K,this);if(J.compareTo(r.ONE)!=0&&J.compareTo(b)!=0){for(var he=1;he++<D&&J.compareTo(b)!=0;)if(J=J.modPowInt(2,this),J.compareTo(r.ONE)==0)return!1;if(J.compareTo(b)!=0)return!1}}return!0}function $i(){return{nextBytes:function(A){for(var b=0;b<A.length;++b)A[b]=Math.floor(Math.random()*256)}}}return r.prototype.chunkSize=te,r.prototype.toRadix=Z,r.prototype.fromRadix=se,r.prototype.fromNumber=fe,r.prototype.bitwiseTo=Ee,r.prototype.changeBit=Lt,r.prototype.addTo=_e,r.prototype.dMultiply=Ve,r.prototype.dAddOffset=Oe,r.prototype.multiplyLowerTo=Vi,r.prototype.multiplyUpperTo=Oi,r.prototype.modInt=Qi,r.prototype.millerRabin=ji,r.prototype.clone=w,r.prototype.intValue=V,r.prototype.byteValue=H,r.prototype.shortValue=ae,r.prototype.signum=z,r.prototype.toByteArray=oe,r.prototype.equals=Ce,r.prototype.min=Te,r.prototype.max=Se,r.prototype.and=ve,r.prototype.or=Ie,r.prototype.xor=He,r.prototype.andNot=We,r.prototype.not=Ye,r.prototype.shiftLeft=je,r.prototype.shiftRight=et,r.prototype.getLowestSetBit=ot,r.prototype.bitCount=yt,r.prototype.testBit=Et,r.prototype.setBit=Yt,r.prototype.clearBit=be,r.prototype.flipBit=we,r.prototype.add=Re,r.prototype.subtract=Ne,r.prototype.multiply=Le,r.prototype.divide=Ue,r.prototype.remainder=De,r.prototype.divideAndRemainder=Pe,r.prototype.modPow=Gi,r.prototype.modInverse=Wi,r.prototype.pow=Pi,r.prototype.gcd=zi,r.prototype.isProbablePrime=Xi,r.prototype.square=ke,_r}var Rr={exports:{}},Nr={exports:{}},Da;function Nt(){if(Da)return Nr.exports;Da=1;var t=ue();st(),ce();var e=Nr.exports=t.sha1=t.sha1||{};t.md.sha1=t.md.algorithms.sha1=e,e.create=function(){o||E();var f=null,a=t.util.createBuffer(),p=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 S=l.messageLengthSize/4,R=0;R<S;++R)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(S,R){R==="utf8"&&(S=t.util.encodeUtf8(S));var x=S.length;l.messageLength+=x,x=[x/4294967296>>>0,x>>>0];for(var c=l.fullMessageLength.length-1;c>=0;--c)l.fullMessageLength[c]+=x[1],x[1]=x[0]+(l.fullMessageLength[c]/4294967296>>>0),l.fullMessageLength[c]=l.fullMessageLength[c]>>>0,x[0]=x[1]/4294967296>>>0;return a.putBytes(S),y(f,p,a),(a.read>2048||a.length()===0)&&a.compact(),l},l.digest=function(){var S=t.util.createBuffer();S.putBytes(a.bytes());var R=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize,x=R&l.blockLength-1;S.putBytes(r.substr(0,l.blockLength-x));for(var c,g,C=l.fullMessageLength[0]*8,m=0;m<l.fullMessageLength.length-1;++m)c=l.fullMessageLength[m+1]*8,g=c/4294967296>>>0,C+=g,S.putInt32(C>>>0),C=c>>>0;S.putInt32(C);var i={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4};y(i,p,S);var h=t.util.createBuffer();return h.putInt32(i.h0),h.putInt32(i.h1),h.putInt32(i.h2),h.putInt32(i.h3),h.putInt32(i.h4),h},l};var r=null,o=!1;function E(){r="€",r+=t.util.fillString("\0",64),o=!0}function y(f,a,p){for(var l,S,R,x,c,g,C,m,i=p.length();i>=64;){for(S=f.h0,R=f.h1,x=f.h2,c=f.h3,g=f.h4,m=0;m<16;++m)l=p.getInt32(),a[m]=l,C=c^R&(x^c),l=(S<<5|S>>>27)+C+g+1518500249+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;for(;m<20;++m)l=a[m-3]^a[m-8]^a[m-14]^a[m-16],l=l<<1|l>>>31,a[m]=l,C=c^R&(x^c),l=(S<<5|S>>>27)+C+g+1518500249+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;for(;m<32;++m)l=a[m-3]^a[m-8]^a[m-14]^a[m-16],l=l<<1|l>>>31,a[m]=l,C=R^x^c,l=(S<<5|S>>>27)+C+g+1859775393+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;for(;m<40;++m)l=a[m-6]^a[m-16]^a[m-28]^a[m-32],l=l<<2|l>>>30,a[m]=l,C=R^x^c,l=(S<<5|S>>>27)+C+g+1859775393+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;for(;m<60;++m)l=a[m-6]^a[m-16]^a[m-28]^a[m-32],l=l<<2|l>>>30,a[m]=l,C=R&x|c&(R^x),l=(S<<5|S>>>27)+C+g+2400959708+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;for(;m<80;++m)l=a[m-6]^a[m-16]^a[m-28]^a[m-32],l=l<<2|l>>>30,a[m]=l,C=R^x^c,l=(S<<5|S>>>27)+C+g+3395469782+l,g=c,c=x,x=(R<<30|R>>>2)>>>0,R=S,S=l;f.h0=f.h0+S|0,f.h1=f.h1+R|0,f.h2=f.h2+x|0,f.h3=f.h3+c|0,f.h4=f.h4+g|0,i-=64}}return Nr.exports}var Pa;function Va(){if(Pa)return Rr.exports;Pa=1;var t=ue();ce(),Je(),Nt();var e=Rr.exports=t.pkcs1=t.pkcs1||{};e.encode_rsa_oaep=function(o,E,y){var f,a,p,l;typeof y=="string"?(f=y,a=arguments[3]||void 0,p=arguments[4]||void 0):y&&(f=y.label||void 0,a=y.seed||void 0,p=y.md||void 0,y.mgf1&&y.mgf1.md&&(l=y.mgf1.md)),p?p.start():p=t.md.sha1.create(),l||(l=p);var S=Math.ceil(o.n.bitLength()/8),R=S-2*p.digestLength-2;if(E.length>R){var x=new Error("RSAES-OAEP input message length is too long.");throw x.length=E.length,x.maxLength=R,x}f||(f=""),p.update(f,"raw");for(var c=p.digest(),g="",C=R-E.length,m=0;m<C;m++)g+="\0";var i=c.getBytes()+g+""+E;if(!a)a=t.random.getBytes(p.digestLength);else if(a.length!==p.digestLength){var x=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw x.seedLength=a.length,x.digestLength=p.digestLength,x}var h=r(a,S-p.digestLength-1,l),v=t.util.xorBytes(i,h,i.length),I=r(v,p.digestLength,l),N=t.util.xorBytes(a,I,a.length);return"\0"+N+v},e.decode_rsa_oaep=function(o,E,y){var f,a,p;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&&(p=y.mgf1.md));var l=Math.ceil(o.n.bitLength()/8);if(E.length!==l){var v=new Error("RSAES-OAEP encoded message length is invalid.");throw v.length=E.length,v.expectedLength=l,v}if(a===void 0?a=t.md.sha1.create():a.start(),p||(p=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 S=a.digest().getBytes(),R=E.charAt(0),x=E.substring(1,a.digestLength+1),c=E.substring(1+a.digestLength),g=r(c,a.digestLength,p),C=t.util.xorBytes(x,g,x.length),m=r(C,l-a.digestLength-1,p),i=t.util.xorBytes(c,m,c.length),h=i.substring(0,a.digestLength),v=R!=="\0",I=0;I<a.digestLength;++I)v|=S.charAt(I)!==h.charAt(I);for(var N=1,d=a.digestLength,s=a.digestLength;s<i.length;s++){var n=i.charCodeAt(s),B=n&1^1,U=N?65534:0;v|=n&U,N=N&B,d+=N}if(v||i.charCodeAt(d)!==1)throw new Error("Invalid RSAES-OAEP padding.");return i.substring(d+1)};function r(o,E,y){y||(y=t.md.sha1.create());for(var f="",a=Math.ceil(E/y.digestLength),p=0;p<a;++p){var l=String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,p&255);y.start(),y.update(o+l),f+=y.digest().getBytes()}return f.substring(0,E)}return Rr.exports}var Gt={exports:{}},Oa;function Ma(){if(Oa)return Gt.exports;Oa=1;var t=ue();return ce(),Ht(),Je(),(function(){if(t.prime){Gt.exports=t.prime;return}var e=Gt.exports=t.prime=t.prime||{},r=t.jsbn.BigInteger,o=[6,4,2,4,2,4,6,2],E=new r(null);E.fromInt(30);var y=function(x,c){return x|c};e.generateProbablePrime=function(x,c,g){typeof c=="function"&&(g=c,c={}),c=c||{};var C=c.algorithm||"PRIMEINC";typeof C=="string"&&(C={name:C}),C.options=C.options||{};var m=c.prng||t.random,i={nextBytes:function(h){for(var v=m.getBytesSync(h.length),I=0;I<h.length;++I)h[I]=v.charCodeAt(I)}};if(C.name==="PRIMEINC")return f(x,i,C.options,g);throw new Error("Invalid prime generation algorithm: "+C.name)};function f(x,c,g,C){return"workers"in g?l(x,c,g,C):a(x,c,g,C)}function a(x,c,g,C){var m=S(x,c),i=0,h=R(m.bitLength());"millerRabinTests"in g&&(h=g.millerRabinTests);var v=10;"maxBlockTime"in g&&(v=g.maxBlockTime),p(m,x,c,i,h,v,C)}function p(x,c,g,C,m,i,h){var v=+new Date;do{if(x.bitLength()>c&&(x=S(c,g)),x.isProbablePrime(m))return h(null,x);x.dAddOffset(o[C++%8],0)}while(i<0||+new Date-v<i);t.util.setImmediate(function(){p(x,c,g,C,m,i,h)})}function l(x,c,g,C){if(typeof Worker>"u")return a(x,c,g,C);var m=S(x,c),i=g.workers,h=g.workLoad||100,v=h*30/8,I=g.workerScript||"forge/prime.worker.js";if(i===-1)return t.util.estimateCores(function(d,s){d&&(s=2),i=s-1,N()});N();function N(){i=Math.max(1,i);for(var d=[],s=0;s<i;++s)d[s]=new Worker(I);for(var s=0;s<i;++s)d[s].addEventListener("message",B);var n=!1;function B(U){if(!n){var O=U.data;if(O.found){for(var P=0;P<d.length;++P)d[P].terminate();return n=!0,C(null,new r(O.prime,16))}m.bitLength()>x&&(m=S(x,c));var M=m.toString(16);U.target.postMessage({hex:M,workLoad:h}),m.dAddOffset(v,0)}}}}function S(x,c){var g=new r(x,c),C=x-1;return g.testBit(C)||g.bitwiseTo(r.ONE.shiftLeft(C),y,g),g.dAddOffset(31-g.mod(E).byteValue(),0),g}function R(x){return x<=100?27:x<=150?18:x<=200?15:x<=250?12:x<=300?9:x<=350?8:x<=400?7:x<=500?6:x<=600?5:x<=800?4:x<=1250?3:2}})(),Gt.exports}var Lr,Ka;function zt(){if(Ka)return Lr;Ka=1;var t=ue();if(nt(),Ht(),vt(),Va(),Ma(),Je(),ce(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.util.isNodejs?Tr:null,o=t.asn1,E=t.util;t.pki=t.pki||{},Lr=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"}]},p={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"}]},S=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"}]}]},R={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"}]},x=function(s){var n;if(s.algorithm in y.oids)n=y.oids[s.algorithm];else{var B=new Error("Unknown message digest algorithm.");throw B.algorithm=s.algorithm,B}var U=o.oidToDer(n).getBytes(),O=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),P=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);P.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,U)),P.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var M=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,s.digest().getBytes());return O.value.push(P),O.value.push(M),o.toDer(O).getBytes()},c=function(s,n,B){if(B)return s.modPow(n.e,n.n);if(!n.p||!n.q)return s.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 U;do U=new e(t.util.bytesToHex(t.random.getBytes(n.n.bitLength()/8)),16);while(U.compareTo(n.n)>=0||!U.gcd(n.n).equals(e.ONE));s=s.multiply(U.modPow(n.e,n.n)).mod(n.n);for(var O=s.mod(n.p).modPow(n.dP,n.p),P=s.mod(n.q).modPow(n.dQ,n.q);O.compareTo(P)<0;)O=O.add(n.p);var M=O.subtract(P).multiply(n.qInv).mod(n.p).multiply(n.q).add(P);return M=M.multiply(U.modInverse(n.n)).mod(n.n),M};y.rsa.encrypt=function(s,n,B){var U=B,O,P=Math.ceil(n.n.bitLength()/8);B!==!1&&B!==!0?(U=B===2,O=g(s,n,B)):(O=t.util.createBuffer(),O.putBytes(s));for(var M=new e(O.toHex(),16),q=c(M,n,U),F=q.toString(16),G=t.util.createBuffer(),W=P-Math.ceil(F.length/2);W>0;)G.putByte(0),--W;return G.putBytes(t.util.hexToBytes(F)),G.getBytes()},y.rsa.decrypt=function(s,n,B,U){var O=Math.ceil(n.n.bitLength()/8);if(s.length!==O){var P=new Error("Encrypted message length is invalid.");throw P.length=s.length,P.expected=O,P}var M=new e(t.util.createBuffer(s).toHex(),16);if(M.compareTo(n.n)>=0)throw new Error("Encrypted message is invalid.");for(var q=c(M,n,B),F=q.toString(16),G=t.util.createBuffer(),W=O-Math.ceil(F.length/2);W>0;)G.putByte(0),--W;return G.putBytes(t.util.hexToBytes(F)),U!==!1?C(G.getBytes(),n,B):G.getBytes()},y.rsa.createKeyPairGenerationState=function(s,n,B){typeof s=="string"&&(s=parseInt(s,10)),s=s||2048,B=B||{};var U=B.prng||t.random,O={nextBytes:function(q){for(var F=U.getBytesSync(q.length),G=0;G<q.length;++G)q[G]=F.charCodeAt(G)}},P=B.algorithm||"PRIMEINC",M;if(P==="PRIMEINC")M={algorithm:P,state:0,bits:s,rng:O,eInt:n||65537,e:new e(null),p:null,q:null,qBits:s>>1,pBits:s-(s>>1),pqState:0,num:null,keys:null},M.e.fromInt(M.eInt);else throw new Error("Invalid key generation algorithm: "+P);return M},y.rsa.stepKeyPairGenerationState=function(s,n){"algorithm"in s||(s.algorithm="PRIMEINC");var B=new e(null);B.fromInt(30);for(var U=0,O=function(X,ee){return X|ee},P=+new Date,M,q=0;s.keys===null&&(n<=0||q<n);){if(s.state===0){var F=s.p===null?s.pBits:s.qBits,G=F-1;s.pqState===0?(s.num=new e(F,s.rng),s.num.testBit(G)||s.num.bitwiseTo(e.ONE.shiftLeft(G),O,s.num),s.num.dAddOffset(31-s.num.mod(B).byteValue(),0),U=0,++s.pqState):s.pqState===1?s.num.bitLength()>F?s.pqState=0:s.num.isProbablePrime(h(s.num.bitLength()))?++s.pqState:s.num.dAddOffset(f[U++%8],0):s.pqState===2?s.pqState=s.num.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)===0?3:0:s.pqState===3&&(s.pqState=0,s.p===null?s.p=s.num:s.q=s.num,s.p!==null&&s.q!==null&&++s.state,s.num=null)}else if(s.state===1)s.p.compareTo(s.q)<0&&(s.num=s.p,s.p=s.q,s.q=s.num),++s.state;else if(s.state===2)s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),++s.state;else if(s.state===3)s.phi.gcd(s.e).compareTo(e.ONE)===0?++s.state:(s.p=null,s.q=null,s.state=0);else if(s.state===4)s.n=s.p.multiply(s.q),s.n.bitLength()===s.bits?++s.state:(s.q=null,s.state=0);else if(s.state===5){var W=s.e.modInverse(s.phi);s.keys={privateKey:y.rsa.setPrivateKey(s.n,s.e,W,s.p,s.q,W.mod(s.p1),W.mod(s.q1),s.q.modInverse(s.p)),publicKey:y.rsa.setPublicKey(s.n,s.e)}}M=+new Date,q+=M-P,P=M}return s.keys!==null},y.rsa.generateKeyPair=function(s,n,B,U){if(arguments.length===1?typeof s=="object"?(B=s,s=void 0):typeof s=="function"&&(U=s,s=void 0):arguments.length===2?typeof s=="number"?typeof n=="function"?(U=n,n=void 0):typeof n!="number"&&(B=n,n=void 0):(B=s,U=n,s=void 0,n=void 0):arguments.length===3&&(typeof n=="number"?typeof B=="function"&&(U=B,B=void 0):(U=B,B=n,n=void 0)),B=B||{},s===void 0&&(s=B.bits||2048),n===void 0&&(n=B.e||65537),!t.options.usePureJavaScript&&!B.prng&&s>=256&&s<=16384&&(n===65537||n===3)){if(U){if(v("generateKeyPair"))return r.generateKeyPair("rsa",{modulusLength:s,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(q,F,G){if(q)return U(q);U(null,{privateKey:y.privateKeyFromPem(G),publicKey:y.publicKeyFromPem(F)})});if(I("generateKey")&&I("exportKey"))return E.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(q){return E.globalScope.crypto.subtle.exportKey("pkcs8",q.privateKey)}).then(void 0,function(q){U(q)}).then(function(q){if(q){var F=y.privateKeyFromAsn1(o.fromDer(t.util.createBuffer(q)));U(null,{privateKey:F,publicKey:y.setRsaPublicKey(F.n,F.e)})}});if(N("generateKey")&&N("exportKey")){var O=E.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:d(n),hash:{name:"SHA-256"}},!0,["sign","verify"]);O.oncomplete=function(q){var F=q.target.result,G=E.globalScope.msCrypto.subtle.exportKey("pkcs8",F.privateKey);G.oncomplete=function(W){var X=W.target.result,ee=y.privateKeyFromAsn1(o.fromDer(t.util.createBuffer(X)));U(null,{privateKey:ee,publicKey:y.setRsaPublicKey(ee.n,ee.e)})},G.onerror=function(W){U(W)}},O.onerror=function(q){U(q)};return}}else if(v("generateKeyPairSync")){var P=r.generateKeyPairSync("rsa",{modulusLength:s,publicExponent:n,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:y.privateKeyFromPem(P.privateKey),publicKey:y.publicKeyFromPem(P.publicKey)}}}var M=y.rsa.createKeyPairGenerationState(s,n,B);if(!U)return y.rsa.stepKeyPairGenerationState(M,0),M.keys;m(M,B,U)},y.setRsaPublicKey=y.rsa.setPublicKey=function(s,n){var B={n:s,e:n};return B.encrypt=function(U,O,P){if(typeof O=="string"?O=O.toUpperCase():O===void 0&&(O="RSAES-PKCS1-V1_5"),O==="RSAES-PKCS1-V1_5")O={encode:function(q,F,G){return g(q,F,2).getBytes()}};else if(O==="RSA-OAEP"||O==="RSAES-OAEP")O={encode:function(q,F){return t.pkcs1.encode_rsa_oaep(F,q,P)}};else if(["RAW","NONE","NULL",null].indexOf(O)!==-1)O={encode:function(q){return q}};else if(typeof O=="string")throw new Error('Unsupported encryption scheme: "'+O+'".');var M=O.encode(U,B,!0);return y.rsa.encrypt(M,B,!0)},B.verify=function(U,O,P,M){typeof P=="string"?P=P.toUpperCase():P===void 0&&(P="RSASSA-PKCS1-V1_5"),M===void 0&&(M={_parseAllDigestBytes:!0,_skipPaddingChecks:!1}),"_parseAllDigestBytes"in M||(M._parseAllDigestBytes=!0),"_skipPaddingChecks"in M||(M._skipPaddingChecks=!1),P==="RSASSA-PKCS1-V1_5"?P={verify:function(F,G){G=C(G,B,!0,void 0,M);var W=o.fromDer(G,{parseAllBytes:M._parseAllDigestBytes}),X={},ee=[];if(!o.validate(W,R,X,ee)||W.value.length!==2){var ne=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw ne.errors=ee,ne}var ie=o.derToOid(X.algorithmIdentifier);if(!(ie===t.oids.md2||ie===t.oids.md5||ie===t.oids.sha1||ie===t.oids.sha224||ie===t.oids.sha256||ie===t.oids.sha384||ie===t.oids.sha512||ie===t.oids["sha512-224"]||ie===t.oids["sha512-256"])){var ne=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw ne.oid=ie,ne}if((ie===t.oids.md2||ie===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 F===X.digest}}:(P==="NONE"||P==="NULL"||P===null)&&(P={verify:function(F,G){return G=C(G,B,!0,void 0,M),F===G}});var q=y.rsa.decrypt(O,B,!0,!1);return P.verify(U,q,B.n.bitLength())},B},y.setRsaPrivateKey=y.rsa.setPrivateKey=function(s,n,B,U,O,P,M,q){var F={n:s,e:n,d:B,p:U,q:O,dP:P,dQ:M,qInv:q};return F.decrypt=function(G,W,X){typeof W=="string"?W=W.toUpperCase():W===void 0&&(W="RSAES-PKCS1-V1_5");var ee=y.rsa.decrypt(G,F,!1,!1);if(W==="RSAES-PKCS1-V1_5")W={decode:C};else if(W==="RSA-OAEP"||W==="RSAES-OAEP")W={decode:function(ne,ie){return t.pkcs1.decode_rsa_oaep(ie,ne,X)}};else if(["RAW","NONE","NULL",null].indexOf(W)!==-1)W={decode:function(ne){return ne}};else throw new Error('Unsupported encryption scheme: "'+W+'".');return W.decode(ee,F,!1)},F.sign=function(G,W){var X=!1;typeof W=="string"&&(W=W.toUpperCase()),W===void 0||W==="RSASSA-PKCS1-V1_5"?(W={encode:x},X=1):(W==="NONE"||W==="NULL"||W===null)&&(W={encode:function(){return G}},X=1);var ee=W.encode(G,F.n.bitLength());return y.rsa.encrypt(ee,F,X)},F},y.wrapRsaPrivateKey=function(s){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(s).getBytes())])},y.privateKeyFromAsn1=function(s){var n={},B=[];if(o.validate(s,a,n,B)&&(s=o.fromDer(t.util.createBuffer(n.privateKey))),n={},B=[],!o.validate(s,p,n,B)){var U=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw U.errors=B,U}var O,P,M,q,F,G,W,X;return O=t.util.createBuffer(n.privateKeyModulus).toHex(),P=t.util.createBuffer(n.privateKeyPublicExponent).toHex(),M=t.util.createBuffer(n.privateKeyPrivateExponent).toHex(),q=t.util.createBuffer(n.privateKeyPrime1).toHex(),F=t.util.createBuffer(n.privateKeyPrime2).toHex(),G=t.util.createBuffer(n.privateKeyExponent1).toHex(),W=t.util.createBuffer(n.privateKeyExponent2).toHex(),X=t.util.createBuffer(n.privateKeyCoefficient).toHex(),y.setRsaPrivateKey(new e(O,16),new e(P,16),new e(M,16),new e(q,16),new e(F,16),new e(G,16),new e(W,16),new e(X,16))},y.privateKeyToAsn1=y.privateKeyToRSAPrivateKey=function(s){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,i(s.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.qInv))])},y.publicKeyFromAsn1=function(s){var n={},B=[];if(o.validate(s,S,n,B)){var U=o.derToOid(n.publicKeyOid);if(U!==y.oids.rsaEncryption){var O=new Error("Cannot read public key. Unknown OID.");throw O.oid=U,O}s=n.rsaPublicKey}if(B=[],!o.validate(s,l,n,B)){var O=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw O.errors=B,O}var P=t.util.createBuffer(n.publicKeyModulus).toHex(),M=t.util.createBuffer(n.publicKeyExponent).toHex();return y.setRsaPublicKey(new e(P,16),new e(M,16))},y.publicKeyToAsn1=y.publicKeyToSubjectPublicKeyInfo=function(s){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(s)])])},y.publicKeyToRSAPublicKey=function(s){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,i(s.e))])};function g(s,n,B){var U=t.util.createBuffer(),O=Math.ceil(n.n.bitLength()/8);if(s.length>O-11){var P=new Error("Message is too long for PKCS#1 v1.5 padding.");throw P.length=s.length,P.max=O-11,P}U.putByte(0),U.putByte(B);var M=O-3-s.length,q;if(B===0||B===1){q=B===0?0:255;for(var F=0;F<M;++F)U.putByte(q)}else for(;M>0;){for(var G=0,W=t.random.getBytes(M),F=0;F<M;++F)q=W.charCodeAt(F),q===0?++G:U.putByte(q);M=G}return U.putByte(0),U.putBytes(s),U}function C(s,n,B,U,O){var P=Math.ceil(n.n.bitLength()/8),M=t.util.createBuffer(s),q=M.getByte(),F=M.getByte();if(q!==0||B&&F!==0&&F!==1||!B&&F!==2||B&&F===0&&typeof U>"u")throw new Error("Encryption block is invalid.");var G=0;if(F===0){G=P-3-U;for(var W=0;W<G;++W)if(M.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(F===1){for(G=0;M.length()>1;){if(M.getByte()!==255){--M.read;break}++G}if(G<8&&!(O&&O._skipPaddingChecks))throw new Error("Encryption block is invalid.")}else if(F===2){for(G=0;M.length()>1;){if(M.getByte()===0){--M.read;break}++G}if(G<8&&!(O&&O._skipPaddingChecks))throw new Error("Encryption block is invalid.")}var X=M.getByte();if(X!==0||G!==P-3-M.length())throw new Error("Encryption block is invalid.");return M.getBytes()}function m(s,n,B){typeof n=="function"&&(B=n,n={}),n=n||{};var U={algorithm:{name:n.algorithm||"PRIMEINC",options:{workers:n.workers||2,workLoad:n.workLoad||100,workerScript:n.workerScript}}};"prng"in n&&(U.prng=n.prng),O();function O(){P(s.pBits,function(q,F){if(q)return B(q);if(s.p=F,s.q!==null)return M(q,s.q);P(s.qBits,M)})}function P(q,F){t.prime.generateProbablePrime(q,U,F)}function M(q,F){if(q)return B(q);if(s.q=F,s.p.compareTo(s.q)<0){var G=s.p;s.p=s.q,s.q=G}if(s.p.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.p=null,O();return}if(s.q.subtract(e.ONE).gcd(s.e).compareTo(e.ONE)!==0){s.q=null,P(s.qBits,M);return}if(s.p1=s.p.subtract(e.ONE),s.q1=s.q.subtract(e.ONE),s.phi=s.p1.multiply(s.q1),s.phi.gcd(s.e).compareTo(e.ONE)!==0){s.p=s.q=null,O();return}if(s.n=s.p.multiply(s.q),s.n.bitLength()!==s.bits){s.q=null,P(s.qBits,M);return}var W=s.e.modInverse(s.phi);s.keys={privateKey:y.rsa.setPrivateKey(s.n,s.e,W,s.p,s.q,W.mod(s.p1),W.mod(s.q1),s.q.modInverse(s.p)),publicKey:y.rsa.setPublicKey(s.n,s.e)},B(null,s.keys)}}function i(s){var n=s.toString(16);n[0]>="8"&&(n="00"+n);var B=t.util.hexToBytes(n);return B.length>1&&(B.charCodeAt(0)===0&&(B.charCodeAt(1)&128)===0||B.charCodeAt(0)===255&&(B.charCodeAt(1)&128)===128)?B.substr(1):B}function h(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}function v(s){return t.util.isNodejs&&typeof r[s]=="function"}function I(s){return typeof E.globalScope<"u"&&typeof E.globalScope.crypto=="object"&&typeof E.globalScope.crypto.subtle=="object"&&typeof E.globalScope.crypto.subtle[s]=="function"}function N(s){return typeof E.globalScope<"u"&&typeof E.globalScope.msCrypto=="object"&&typeof E.globalScope.msCrypto.subtle=="object"&&typeof E.globalScope.msCrypto.subtle[s]=="function"}function d(s){for(var n=t.util.hexToBytes(s.toString(16)),B=new Uint8Array(n.length),U=0;U<n.length;++U)B[U]=n.charCodeAt(U);return B}return Lr}var kr,Fa;function qa(){if(Fa)return kr;Fa=1;var t=ue();if(gt(),nt(),Ft(),st(),vt(),Ir(),Ct(),Je(),ka(),zt(),ce(),typeof e>"u")var e=t.jsbn.BigInteger;var r=t.asn1,o=t.pki=t.pki||{};kr=o.pbe=t.pbe=t.pbe||{};var E=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(x,c,g){g=g||{},g.saltSize=g.saltSize||8,g.count=g.count||2048,g.algorithm=g.algorithm||"aes128",g.prfAlgorithm=g.prfAlgorithm||"sha1";var C=t.random.getBytesSync(g.saltSize),m=g.count,i=r.integerToDer(m),h,v,I;if(g.algorithm.indexOf("aes")===0||g.algorithm==="des"){var N,d,s;switch(g.algorithm){case"aes128":h=16,N=16,d=E["aes128-CBC"],s=t.aes.createEncryptionCipher;break;case"aes192":h=24,N=16,d=E["aes192-CBC"],s=t.aes.createEncryptionCipher;break;case"aes256":h=32,N=16,d=E["aes256-CBC"],s=t.aes.createEncryptionCipher;break;case"des":h=8,N=8,d=E.desCBC,s=t.des.createEncryptionCipher;break;default:var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=g.algorithm,n}var B="hmacWith"+g.prfAlgorithm.toUpperCase(),U=S(B),O=t.pkcs5.pbkdf2(c,C,m,h,U),P=t.random.getBytesSync(N),M=s(O);M.start(P),M.update(r.toDer(x)),M.finish(),I=M.output.getBytes();var q=R(C,i,h,B);v=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(E.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(E.pkcs5PBKDF2).getBytes()),q]),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,P)])])])}else if(g.algorithm==="3des"){h=24;var F=new t.util.ByteBuffer(C),O=o.pbe.generatePkcs12Key(c,F,1,m,h),P=o.pbe.generatePkcs12Key(c,F,2,m,h),M=t.des.createEncryptionCipher(O);M.start(P),M.update(r.toDer(x)),M.finish(),I=M.output.getBytes(),v=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(E["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,C),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,i.getBytes())])])}else{var n=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw n.algorithm=g.algorithm,n}var G=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[v,r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,I)]);return G},o.decryptPrivateKeyInfo=function(x,c){var g=null,C={},m=[];if(!r.validate(x,y,C,m)){var i=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=m,i}var h=r.derToOid(C.encryptionOid),v=o.pbe.getCipher(h,C.encryptionParams,c),I=t.util.createBuffer(C.encryptedData);return v.update(I),v.finish()&&(g=r.fromDer(v.output)),g},o.encryptedPrivateKeyToPem=function(x,c){var g={type:"ENCRYPTED PRIVATE KEY",body:r.toDer(x).getBytes()};return t.pem.encode(g,{maxline:c})},o.encryptedPrivateKeyFromPem=function(x){var c=t.pem.decode(x)[0];if(c.type!=="ENCRYPTED PRIVATE KEY"){var g=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw g.headerType=c.type,g}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(x,c,g){if(g=g||{},!g.legacy){var C=o.wrapRsaPrivateKey(o.privateKeyToAsn1(x));return C=o.encryptPrivateKeyInfo(C,c,g),o.encryptedPrivateKeyToPem(C)}var m,i,h,v;switch(g.algorithm){case"aes128":m="AES-128-CBC",h=16,i=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"aes192":m="AES-192-CBC",h=24,i=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"aes256":m="AES-256-CBC",h=32,i=t.random.getBytesSync(16),v=t.aes.createEncryptionCipher;break;case"3des":m="DES-EDE3-CBC",h=24,i=t.random.getBytesSync(8),v=t.des.createEncryptionCipher;break;case"des":m="DES-CBC",h=8,i=t.random.getBytesSync(8),v=t.des.createEncryptionCipher;break;default:var I=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+g.algorithm+'".');throw I.algorithm=g.algorithm,I}var N=t.pbe.opensslDeriveBytes(c,i.substr(0,8),h),d=v(N);d.start(i),d.update(r.toDer(o.privateKeyToAsn1(x))),d.finish();var s={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:m,parameters:t.util.bytesToHex(i).toUpperCase()},body:d.output.getBytes()};return t.pem.encode(s)},o.decryptRsaPrivateKey=function(x,c){var g=null,C=t.pem.decode(x)[0];if(C.type!=="ENCRYPTED PRIVATE KEY"&&C.type!=="PRIVATE KEY"&&C.type!=="RSA PRIVATE KEY"){var m=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw m.headerType=m,m}if(C.procType&&C.procType.type==="ENCRYPTED"){var i,h;switch(C.dekInfo.algorithm){case"DES-CBC":i=8,h=t.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,h=t.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,h=t.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,h=t.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,h=t.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,h=function(s){return t.rc2.createDecryptionCipher(s,40)};break;case"RC2-64-CBC":i=8,h=function(s){return t.rc2.createDecryptionCipher(s,64)};break;case"RC2-128-CBC":i=16,h=function(s){return t.rc2.createDecryptionCipher(s,128)};break;default:var m=new Error('Could not decrypt private key; unsupported encryption algorithm "'+C.dekInfo.algorithm+'".');throw m.algorithm=C.dekInfo.algorithm,m}var v=t.util.hexToBytes(C.dekInfo.parameters),I=t.pbe.opensslDeriveBytes(c,v.substr(0,8),i),N=h(I);if(N.start(v),N.update(t.util.createBuffer(C.body)),N.finish())g=N.output.getBytes();else return g}else g=C.body;return C.type==="ENCRYPTED PRIVATE KEY"?g=o.decryptPrivateKeyInfo(r.fromDer(g),c):g=r.fromDer(g),g!==null&&(g=o.privateKeyFromAsn1(g)),g},o.pbe.generatePkcs12Key=function(x,c,g,C,m,i){var h,v;if(typeof i>"u"||i===null){if(!("sha1"in t.md))throw new Error('"sha1" hash algorithm unavailable.');i=t.md.sha1.create()}var I=i.digestLength,N=i.blockLength,d=new t.util.ByteBuffer,s=new t.util.ByteBuffer;if(x!=null){for(v=0;v<x.length;v++)s.putInt16(x.charCodeAt(v));s.putInt16(0)}var n=s.length(),B=c.length(),U=new t.util.ByteBuffer;U.fillWithByte(g,N);var O=N*Math.ceil(B/N),P=new t.util.ByteBuffer;for(v=0;v<O;v++)P.putByte(c.at(v%B));var M=N*Math.ceil(n/N),q=new t.util.ByteBuffer;for(v=0;v<M;v++)q.putByte(s.at(v%n));var F=P;F.putBuffer(q);for(var G=Math.ceil(m/I),W=1;W<=G;W++){var X=new t.util.ByteBuffer;X.putBytes(U.bytes()),X.putBytes(F.bytes());for(var ee=0;ee<C;ee++)i.start(),i.update(X.getBytes()),X=i.digest();var ne=new t.util.ByteBuffer;for(v=0;v<N;v++)ne.putByte(X.at(v%I));var ie=Math.ceil(B/N)+Math.ceil(n/N),de=new t.util.ByteBuffer;for(h=0;h<ie;h++){var ge=new t.util.ByteBuffer(F.getBytes(N)),le=511;for(v=ne.length()-1;v>=0;v--)le=le>>8,le+=ne.at(v)+ge.at(v),ge.setAt(v,le&255);de.putBuffer(ge)}F=de,d.putBuffer(X)}return d.truncate(d.length()-m),d},o.pbe.getCipher=function(x,c,g){switch(x){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(x,c,g);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(x,c,g);default:var C=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw C.oid=x,C.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],C}},o.pbe.getCipherForPBES2=function(x,c,g){var C={},m=[];if(!r.validate(c,f,C,m)){var i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=m,i}if(x=r.derToOid(C.kdfOid),x!==o.oids.pkcs5PBKDF2){var i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw i.oid=x,i.supportedOids=["pkcs5PBKDF2"],i}if(x=r.derToOid(C.encOid),x!==o.oids["aes128-CBC"]&&x!==o.oids["aes192-CBC"]&&x!==o.oids["aes256-CBC"]&&x!==o.oids["des-EDE3-CBC"]&&x!==o.oids.desCBC){var i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw i.oid=x,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i}var h=C.kdfSalt,v=t.util.createBuffer(C.kdfIterationCount);v=v.getInt(v.length()<<3);var I,N;switch(o.oids[x]){case"aes128-CBC":I=16,N=t.aes.createDecryptionCipher;break;case"aes192-CBC":I=24,N=t.aes.createDecryptionCipher;break;case"aes256-CBC":I=32,N=t.aes.createDecryptionCipher;break;case"des-EDE3-CBC":I=24,N=t.des.createDecryptionCipher;break;case"desCBC":I=8,N=t.des.createDecryptionCipher;break}var d=l(C.prfOid),s=t.pkcs5.pbkdf2(g,h,v,I,d),n=C.encIv,B=N(s);return B.start(n),B},o.pbe.getCipherForPKCS12PBE=function(x,c,g){var C={},m=[];if(!r.validate(c,a,C,m)){var i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw i.errors=m,i}var h=t.util.createBuffer(C.salt),v=t.util.createBuffer(C.iterations);v=v.getInt(v.length()<<3);var I,N,d;switch(x){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:I=24,N=8,d=t.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:I=5,N=8,d=function(O,P){var M=t.rc2.createDecryptionCipher(O,40);return M.start(P,null),M};break;default:var i=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw i.oid=x,i}var s=l(C.prfOid),n=o.pbe.generatePkcs12Key(g,h,1,v,I,s);s.start();var B=o.pbe.generatePkcs12Key(g,h,2,v,N,s);return d(n,B)},o.pbe.opensslDeriveBytes=function(x,c,g,C){if(typeof C>"u"||C===null){if(!("md5"in t.md))throw new Error('"md5" hash algorithm unavailable.');C=t.md.md5.create()}c===null&&(c="");for(var m=[p(C,x+c)],i=16,h=1;i<g;++h,i+=16)m.push(p(C,m[h-1]+x+c));return m.join("").substr(0,g)};function p(x,c){return x.start().update(c).digest().getBytes()}function l(x){var c;if(!x)c="hmacWithSHA1";else if(c=o.oids[r.derToOid(x)],!c){var g=new Error("Unsupported PRF OID.");throw g.oid=x,g.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],g}return S(c)}function S(x){var c=t.md;switch(x){case"hmacWithSHA224":c=t.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":x=x.substr(8).toLowerCase();break;default:var g=new Error("Unsupported PRF algorithm.");throw g.algorithm=x,g.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],g}if(!c||!(x in c))throw new Error("Unknown hash algorithm: "+x);return c[x].create()}function R(x,c,g,C){var m=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,x),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,c.getBytes())]);return C!=="hmacWithSHA1"&&m.value.push(r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,t.util.hexToBytes(g.toString(16))),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(o.oids[C]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")])),m}return kr}var Ur={exports:{}},Dr={exports:{}},Ha;function Ga(){if(Ha)return Dr.exports;Ha=1;var t=ue();nt(),ce();var e=t.asn1,r=Dr.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 E={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(E)},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(E)};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"}]},Dr.exports}var Pr={exports:{}},Vr={exports:{}},za;function Qa(){if(za)return Vr.exports;za=1;var t=ue();ce(),t.mgf=t.mgf||{};var e=Vr.exports=t.mgf.mgf1=t.mgf1=t.mgf1||{};return e.create=function(r){var o={generate:function(E,y){for(var f=new t.util.ByteBuffer,a=Math.ceil(y/r.digestLength),p=0;p<a;p++){var l=new t.util.ByteBuffer;l.putInt32(p),r.start(),r.update(E+l.getBytes()),f.putBuffer(r.digest())}return f.truncate(f.length()-y),f.getBytes()}};return o},Vr.exports}var Or,Wa;function ci(){if(Wa)return Or;Wa=1;var t=ue();return Qa(),Or=t.mgf=t.mgf||{},t.mgf.mgf1=t.mgf1,Or}var Mr={exports:{}},Ya;function Kr(){if(Ya)return Mr.exports;Ya=1;var t=ue();Je(),ce();var e=Mr.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,E=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 p=r.prng||t.random,l={};return l.encode=function(S,R){var x,c=R-1,g=Math.ceil(c/8),C=S.digest().getBytes();if(g<y+a+2)throw new Error("Message is too long to encrypt.");var m;f===null?m=p.getBytesSync(a):m=f.bytes();var i=new t.util.ByteBuffer;i.fillWithByte(0,8),i.putBytes(C),i.putBytes(m),o.start(),o.update(i.getBytes());var h=o.digest().getBytes(),v=new t.util.ByteBuffer;v.fillWithByte(0,g-a-y-2),v.putByte(1),v.putBytes(m);var I=v.getBytes(),N=g-y-1,d=E.generate(h,N),s="";for(x=0;x<N;x++)s+=String.fromCharCode(I.charCodeAt(x)^d.charCodeAt(x));var n=65280>>8*g-c&255;return s=String.fromCharCode(s.charCodeAt(0)&~n)+s.substr(1),s+h+"¼"},l.verify=function(S,R,x){var c,g=x-1,C=Math.ceil(g/8);if(R=R.substr(-C),C<y+a+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(R.charCodeAt(C-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var m=C-y-1,i=R.substr(0,m),h=R.substr(m,y),v=65280>>8*C-g&255;if((i.charCodeAt(0)&v)!==0)throw new Error("Bits beyond keysize not zero as expected.");var I=E.generate(h,m),N="";for(c=0;c<m;c++)N+=String.fromCharCode(i.charCodeAt(c)^I.charCodeAt(c));N=String.fromCharCode(N.charCodeAt(0)&~v)+N.substr(1);var d=C-y-a-2;for(c=0;c<d;c++)if(N.charCodeAt(c)!==0)throw new Error("Leftmost octets not zero as expected");if(N.charCodeAt(d)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var s=N.substr(-a),n=new t.util.ByteBuffer;n.fillWithByte(0,8),n.putBytes(S),n.putBytes(s),o.start(),o.update(n.getBytes());var B=o.digest().getBytes();return h===B},l},Mr.exports}var Xa;function Fr(){if(Xa)return Pr.exports;Xa=1;var t=ue();gt(),nt(),Ft(),st(),ci(),vt(),Ct(),Kr(),zt(),ce();var e=t.asn1,r=Pr.exports=t.pki=t.pki||{},o=r.oids,E={};E.CN=o.commonName,E.commonName="CN",E.C=o.countryName,E.countryName="C",E.L=o.localityName,E.localityName="L",E.ST=o.stateOrProvinceName,E.stateOrProvinceName="ST",E.O=o.organizationName,E.organizationName="O",E.OU=o.organizationalUnitName,E.organizationalUnitName="OU",E.E=o.emailAddress,E.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"}]}]},p={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:[p,{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,s){for(var n=[],B,U,O,P=0;P<d.value.length;++P){B=d.value[P];for(var M=0;M<B.value.length;++M)O={},U=B.value[M],O.type=e.derToOid(U.value[0].value),O.value=U.value[1].value,O.valueTagClass=U.value[1].type,O.type in o&&(O.name=o[O.type],O.name in E&&(O.shortName=E[O.name])),s&&(s.update(O.type),s.update(O.value)),n.push(O)}return n},r.CRIAttributesAsArray=function(d){for(var s=[],n=0;n<d.length;++n)for(var B=d[n],U=e.derToOid(B.value[0].value),O=B.value[1].value,P=0;P<O.length;++P){var M={};if(M.type=U,M.value=O[P].value,M.valueTagClass=O[P].type,M.type in o&&(M.name=o[M.type],M.name in E&&(M.shortName=E[M.name])),M.type===o.extensionRequest){M.extensions=[];for(var q=0;q<M.value.length;++q)M.extensions.push(r.certificateExtensionFromAsn1(M.value[q]))}s.push(M)}return s};function S(d,s){typeof s=="string"&&(s={shortName:s});for(var n=null,B,U=0;n===null&&U<d.attributes.length;++U)B=d.attributes[U],(s.type&&s.type===B.type||s.name&&s.name===B.name||s.shortName&&s.shortName===B.shortName)&&(n=B);return n}var R=function(d,s,n){var B={};if(d!==o["RSASSA-PSS"])return B;n&&(B={hash:{algorithmOid:o.sha1},mgf:{algorithmOid:o.mgf1,hash:{algorithmOid:o.sha1}},saltLength:20});var U={},O=[];if(!e.validate(s,a,U,O)){var P=new Error("Cannot read RSASSA-PSS parameter block.");throw P.errors=O,P}return U.hashOid!==void 0&&(B.hash=B.hash||{},B.hash.algorithmOid=e.derToOid(U.hashOid)),U.maskGenOid!==void 0&&(B.mgf=B.mgf||{},B.mgf.algorithmOid=e.derToOid(U.maskGenOid),B.mgf.hash=B.mgf.hash||{},B.mgf.hash.algorithmOid=e.derToOid(U.maskGenHashOid)),U.saltLength!==void 0&&(B.saltLength=U.saltLength.charCodeAt(0)),B},x=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 s=new Error("Could not compute "+d.type+" digest. Unknown signature OID.");throw s.signatureOid=d.signatureOid,s}},c=function(d){var s=d.certificate,n;switch(s.signatureOid){case o.sha1WithRSAEncryption:case o.sha1WithRSASignature:break;case o["RSASSA-PSS"]:var B,U;if(B=o[s.signatureParameters.mgf.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported MGF hash function.");throw O.oid=s.signatureParameters.mgf.hash.algorithmOid,O.name=B,O}if(U=o[s.signatureParameters.mgf.algorithmOid],U===void 0||t.mgf[U]===void 0){var O=new Error("Unsupported MGF function.");throw O.oid=s.signatureParameters.mgf.algorithmOid,O.name=U,O}if(U=t.mgf[U].create(t.md[B].create()),B=o[s.signatureParameters.hash.algorithmOid],B===void 0||t.md[B]===void 0){var O=new Error("Unsupported RSASSA-PSS hash function.");throw O.oid=s.signatureParameters.hash.algorithmOid,O.name=B,O}n=t.pss.create(t.md[B].create(),U,s.signatureParameters.saltLength);break}return s.publicKey.verify(d.md.digest().getBytes(),d.signature,n)};r.certificateFromPem=function(d,s,n){var B=t.pem.decode(d)[0];if(B.type!=="CERTIFICATE"&&B.type!=="X509 CERTIFICATE"&&B.type!=="TRUSTED CERTIFICATE"){var U=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw U.headerType=B.type,U}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var O=e.fromDer(B.body,n);return r.certificateFromAsn1(O,s)},r.certificateToPem=function(d,s){var n={type:"CERTIFICATE",body:e.toDer(r.certificateToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyFromPem=function(d){var s=t.pem.decode(d)[0];if(s.type!=="PUBLIC KEY"&&s.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=s.type,n}if(s.procType&&s.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var B=e.fromDer(s.body);return r.publicKeyFromAsn1(B)},r.publicKeyToPem=function(d,s){var n={type:"PUBLIC KEY",body:e.toDer(r.publicKeyToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.publicKeyToRSAPublicKeyPem=function(d,s){var n={type:"RSA PUBLIC KEY",body:e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes()};return t.pem.encode(n,{maxline:s})},r.getPublicKeyFingerprint=function(d,s){s=s||{};var n=s.md||t.md.sha1.create(),B=s.type||"RSAPublicKey",U;switch(B){case"RSAPublicKey":U=e.toDer(r.publicKeyToRSAPublicKey(d)).getBytes();break;case"SubjectPublicKeyInfo":U=e.toDer(r.publicKeyToAsn1(d)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+s.type+'".')}n.start(),n.update(U);var O=n.digest();if(s.encoding==="hex"){var P=O.toHex();return s.delimiter?P.match(/.{2}/g).join(s.delimiter):P}else{if(s.encoding==="binary")return O.getBytes();if(s.encoding)throw new Error('Unknown encoding "'+s.encoding+'".')}return O},r.certificationRequestFromPem=function(d,s,n){var B=t.pem.decode(d)[0];if(B.type!=="CERTIFICATE REQUEST"){var U=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw U.headerType=B.type,U}if(B.procType&&B.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var O=e.fromDer(B.body,n);return r.certificationRequestFromAsn1(O,s)},r.certificationRequestToPem=function(d,s){var n={type:"CERTIFICATE REQUEST",body:e.toDer(r.certificationRequestToAsn1(d)).getBytes()};return t.pem.encode(n,{maxline:s})},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(s){return S(d.issuer,s)},d.issuer.addField=function(s){C([s]),d.issuer.attributes.push(s)},d.issuer.attributes=[],d.issuer.hash=null,d.subject={},d.subject.getField=function(s){return S(d.subject,s)},d.subject.addField=function(s){C([s]),d.subject.attributes.push(s)},d.subject.attributes=[],d.subject.hash=null,d.extensions=[],d.publicKey=null,d.md=null,d.setSubject=function(s,n){C(s),d.subject.attributes=s,delete d.subject.uniqueId,n&&(d.subject.uniqueId=n),d.subject.hash=null},d.setIssuer=function(s,n){C(s),d.issuer.attributes=s,delete d.issuer.uniqueId,n&&(d.issuer.uniqueId=n),d.issuer.hash=null},d.setExtensions=function(s){for(var n=0;n<s.length;++n)m(s[n],{cert:d});d.extensions=s},d.getExtension=function(s){typeof s=="string"&&(s={name:s});for(var n=null,B,U=0;n===null&&U<d.extensions.length;++U)B=d.extensions[U],(s.id&&B.id===s.id||s.name&&B.name===s.name)&&(n=B);return n},d.sign=function(s,n){d.md=n||t.md.sha1.create();var B=o[d.md.algorithm+"WithRSAEncryption"];if(!B){var U=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw U.algorithm=d.md.algorithm,U}d.signatureOid=d.siginfo.algorithmOid=B,d.tbsCertificate=r.getTBSCertificate(d);var O=e.toDer(d.tbsCertificate);d.md.update(O.getBytes()),d.signature=s.sign(d.md)},d.verify=function(s){var n=!1;if(!d.issued(s)){var B=s.issuer,U=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=U.attributes,O.actualIssuer=B.attributes,O}var P=s.md;if(P===null){P=x({signatureOid:s.signatureOid,type:"certificate"});var M=s.tbsCertificate||r.getTBSCertificate(s),q=e.toDer(M);P.update(q.getBytes())}return P!==null&&(n=c({certificate:d,md:P,signature:s.signature})),n},d.isIssuer=function(s){var n=!1,B=d.issuer,U=s.subject;if(B.hash&&U.hash)n=B.hash===U.hash;else if(B.attributes.length===U.attributes.length){n=!0;for(var O,P,M=0;n&&M<B.attributes.length;++M)O=B.attributes[M],P=U.attributes[M],(O.type!==P.type||O.value!==P.value)&&(n=!1)}return n},d.issued=function(s){return s.isIssuer(d)},d.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(d.publicKey,{type:"RSAPublicKey"})},d.verifySubjectKeyIdentifier=function(){for(var s=o.subjectKeyIdentifier,n=0;n<d.extensions.length;++n){var B=d.extensions[n];if(B.id===s){var U=d.generateSubjectKeyIdentifier().getBytes();return t.util.hexToBytes(B.subjectKeyIdentifier)===U}}return!1},d},r.certificateFromAsn1=function(d,s){var n={},B=[];if(!e.validate(d,f,n,B)){var U=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw U.errors=B,U}var O=e.derToOid(n.publicKeyOid);if(O!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var P=r.createCertificate();P.version=n.certVersion?n.certVersion.charCodeAt(0):0;var M=t.util.createBuffer(n.certSerialNumber);P.serialNumber=M.toHex(),P.signatureOid=t.asn1.derToOid(n.certSignatureOid),P.signatureParameters=R(P.signatureOid,n.certSignatureParams,!0),P.siginfo.algorithmOid=t.asn1.derToOid(n.certinfoSignatureOid),P.siginfo.parameters=R(P.siginfo.algorithmOid,n.certinfoSignatureParams,!1),P.signature=n.certSignature;var q=[];if(n.certValidity1UTCTime!==void 0&&q.push(e.utcTimeToDate(n.certValidity1UTCTime)),n.certValidity2GeneralizedTime!==void 0&&q.push(e.generalizedTimeToDate(n.certValidity2GeneralizedTime)),n.certValidity3UTCTime!==void 0&&q.push(e.utcTimeToDate(n.certValidity3UTCTime)),n.certValidity4GeneralizedTime!==void 0&&q.push(e.generalizedTimeToDate(n.certValidity4GeneralizedTime)),q.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(q.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(P.validity.notBefore=q[0],P.validity.notAfter=q[1],P.tbsCertificate=n.tbsCertificate,s){P.md=x({signatureOid:P.signatureOid,type:"certificate"});var F=e.toDer(P.tbsCertificate);P.md.update(F.getBytes())}var G=t.md.sha1.create(),W=e.toDer(n.certIssuer);G.update(W.getBytes()),P.issuer.getField=function(ne){return S(P.issuer,ne)},P.issuer.addField=function(ne){C([ne]),P.issuer.attributes.push(ne)},P.issuer.attributes=r.RDNAttributesAsArray(n.certIssuer),n.certIssuerUniqueId&&(P.issuer.uniqueId=n.certIssuerUniqueId),P.issuer.hash=G.digest().toHex();var X=t.md.sha1.create(),ee=e.toDer(n.certSubject);return X.update(ee.getBytes()),P.subject.getField=function(ne){return S(P.subject,ne)},P.subject.addField=function(ne){C([ne]),P.subject.attributes.push(ne)},P.subject.attributes=r.RDNAttributesAsArray(n.certSubject),n.certSubjectUniqueId&&(P.subject.uniqueId=n.certSubjectUniqueId),P.subject.hash=X.digest().toHex(),n.certExtensions?P.extensions=r.certificateExtensionsFromAsn1(n.certExtensions):P.extensions=[],P.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),P},r.certificateExtensionsFromAsn1=function(d){for(var s=[],n=0;n<d.value.length;++n)for(var B=d.value[n],U=0;U<B.value.length;++U)s.push(r.certificateExtensionFromAsn1(B.value[U]));return s},r.certificateExtensionFromAsn1=function(d){var s={};if(s.id=e.derToOid(d.value[0].value),s.critical=!1,d.value[1].type===e.Type.BOOLEAN?(s.critical=d.value[1].value.charCodeAt(0)!==0,s.value=d.value[2].value):s.value=d.value[1].value,s.id in o){if(s.name=o[s.id],s.name==="keyUsage"){var n=e.fromDer(s.value),B=0,U=0;n.value.length>1&&(B=n.value.charCodeAt(1),U=n.value.length>2?n.value.charCodeAt(2):0),s.digitalSignature=(B&128)===128,s.nonRepudiation=(B&64)===64,s.keyEncipherment=(B&32)===32,s.dataEncipherment=(B&16)===16,s.keyAgreement=(B&8)===8,s.keyCertSign=(B&4)===4,s.cRLSign=(B&2)===2,s.encipherOnly=(B&1)===1,s.decipherOnly=(U&128)===128}else if(s.name==="basicConstraints"){var n=e.fromDer(s.value);n.value.length>0&&n.value[0].type===e.Type.BOOLEAN?s.cA=n.value[0].value.charCodeAt(0)!==0:s.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&&(s.pathLenConstraint=e.derToInteger(O))}else if(s.name==="extKeyUsage")for(var n=e.fromDer(s.value),P=0;P<n.value.length;++P){var M=e.derToOid(n.value[P].value);M in o?s[o[M]]=!0:s[M]=!0}else if(s.name==="nsCertType"){var n=e.fromDer(s.value),B=0;n.value.length>1&&(B=n.value.charCodeAt(1)),s.client=(B&128)===128,s.server=(B&64)===64,s.email=(B&32)===32,s.objsign=(B&16)===16,s.reserved=(B&8)===8,s.sslCA=(B&4)===4,s.emailCA=(B&2)===2,s.objCA=(B&1)===1}else if(s.name==="subjectAltName"||s.name==="issuerAltName"){s.altNames=[];for(var q,n=e.fromDer(s.value),F=0;F<n.value.length;++F){q=n.value[F];var G={type:q.type,value:q.value};switch(s.altNames.push(G),q.type){case 1:case 2:case 6:break;case 7:G.ip=t.util.bytesToIP(q.value);break;case 8:G.oid=e.derToOid(q.value);break}}}else if(s.name==="subjectKeyIdentifier"){var n=e.fromDer(s.value);s.subjectKeyIdentifier=t.util.bytesToHex(n.value)}}return s},r.certificationRequestFromAsn1=function(d,s){var n={},B=[];if(!e.validate(d,l,n,B)){var U=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw U.errors=B,U}var O=e.derToOid(n.publicKeyOid);if(O!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var P=r.createCertificationRequest();if(P.version=n.csrVersion?n.csrVersion.charCodeAt(0):0,P.signatureOid=t.asn1.derToOid(n.csrSignatureOid),P.signatureParameters=R(P.signatureOid,n.csrSignatureParams,!0),P.siginfo.algorithmOid=t.asn1.derToOid(n.csrSignatureOid),P.siginfo.parameters=R(P.siginfo.algorithmOid,n.csrSignatureParams,!1),P.signature=n.csrSignature,P.certificationRequestInfo=n.certificationRequestInfo,s){P.md=x({signatureOid:P.signatureOid,type:"certification request"});var M=e.toDer(P.certificationRequestInfo);P.md.update(M.getBytes())}var q=t.md.sha1.create();return P.subject.getField=function(F){return S(P.subject,F)},P.subject.addField=function(F){C([F]),P.subject.attributes.push(F)},P.subject.attributes=r.RDNAttributesAsArray(n.certificationRequestInfoSubject,q),P.subject.hash=q.digest().toHex(),P.publicKey=r.publicKeyFromAsn1(n.subjectPublicKeyInfo),P.getAttribute=function(F){return S(P,F)},P.addAttribute=function(F){C([F]),P.attributes.push(F)},P.attributes=r.CRIAttributesAsArray(n.certificationRequestInfoAttributes||[]),P},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(s){return S(d.subject,s)},d.subject.addField=function(s){C([s]),d.subject.attributes.push(s)},d.subject.attributes=[],d.subject.hash=null,d.publicKey=null,d.attributes=[],d.getAttribute=function(s){return S(d,s)},d.addAttribute=function(s){C([s]),d.attributes.push(s)},d.md=null,d.setSubject=function(s){C(s),d.subject.attributes=s,d.subject.hash=null},d.setAttributes=function(s){C(s),d.attributes=s},d.sign=function(s,n){d.md=n||t.md.sha1.create();var B=o[d.md.algorithm+"WithRSAEncryption"];if(!B){var U=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw U.algorithm=d.md.algorithm,U}d.signatureOid=d.siginfo.algorithmOid=B,d.certificationRequestInfo=r.getCertificationRequestInfo(d);var O=e.toDer(d.certificationRequestInfo);d.md.update(O.getBytes()),d.signature=s.sign(d.md)},d.verify=function(){var s=!1,n=d.md;if(n===null){n=x({signatureOid:d.signatureOid,type:"certification request"});var B=d.certificationRequestInfo||r.getCertificationRequestInfo(d),U=e.toDer(B);n.update(U.getBytes())}return n!==null&&(s=c({certificate:d,md:n,signature:d.signature})),s},d};function g(d){for(var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),n,B,U=d.attributes,O=0;O<U.length;++O){n=U[O];var P=n.value,M=e.Type.PRINTABLESTRING;"valueTagClass"in n&&(M=n.valueTagClass,M===e.Type.UTF8&&(P=t.util.encodeUtf8(P))),B=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,M,!1,P)])]),s.value.push(B)}return s}function C(d){for(var s,n=0;n<d.length;++n){if(s=d[n],typeof s.name>"u"&&(s.type&&s.type in r.oids?s.name=r.oids[s.type]:s.shortName&&s.shortName in E&&(s.name=r.oids[E[s.shortName]])),typeof s.type>"u")if(s.name&&s.name in r.oids)s.type=r.oids[s.name];else{var B=new Error("Attribute type not specified.");throw B.attribute=s,B}if(typeof s.shortName>"u"&&s.name&&s.name in E&&(s.shortName=E[s.name]),s.type===o.extensionRequest&&(s.valueConstructed=!0,s.valueTagClass=e.Type.SEQUENCE,!s.value&&s.extensions)){s.value=[];for(var U=0;U<s.extensions.length;++U)s.value.push(r.certificateExtensionToAsn1(m(s.extensions[U])))}if(typeof s.value>"u"){var B=new Error("Attribute value not specified.");throw B.attribute=s,B}}}function m(d,s){if(s=s||{},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 B=0,U=0,O=0;d.digitalSignature&&(U|=128,B=7),d.nonRepudiation&&(U|=64,B=6),d.keyEncipherment&&(U|=32,B=5),d.dataEncipherment&&(U|=16,B=4),d.keyAgreement&&(U|=8,B=3),d.keyCertSign&&(U|=4,B=2),d.cRLSign&&(U|=2,B=1),d.encipherOnly&&(U|=1,B=0),d.decipherOnly&&(O|=128,B=7);var P=String.fromCharCode(B);O!==0?P+=String.fromCharCode(U)+String.fromCharCode(O):U!==0&&(P+=String.fromCharCode(U)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,P)}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 M=d.value.value;for(var q in d)d[q]===!0&&(q in o?M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(o[q]).getBytes())):q.indexOf(".")!==-1&&M.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(q).getBytes())))}else if(d.name==="nsCertType"){var B=0,U=0;d.client&&(U|=128,B=7),d.server&&(U|=64,B=6),d.email&&(U|=32,B=5),d.objsign&&(U|=16,B=4),d.reserved&&(U|=8,B=3),d.sslCA&&(U|=4,B=2),d.emailCA&&(U|=2,B=1),d.objCA&&(U|=1,B=0);var P=String.fromCharCode(B);U!==0&&(P+=String.fromCharCode(U)),d.value=e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,P)}else if(d.name==="subjectAltName"||d.name==="issuerAltName"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var F,G=0;G<d.altNames.length;++G){F=d.altNames[G];var P=F.value;if(F.type===7&&F.ip){if(P=t.util.bytesFromIP(F.ip),P===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=d,n}}else F.type===8&&(F.oid?P=e.oidToDer(e.oidToDer(F.oid)):P=e.oidToDer(P));d.value.value.push(e.create(e.Class.CONTEXT_SPECIFIC,F.type,!1,P))}}else if(d.name==="nsComment"&&s.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"&&s.cert){var W=s.cert.generateSubjectKeyIdentifier();d.subjectKeyIdentifier=W.toHex(),d.value=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,W.getBytes())}else if(d.name==="authorityKeyIdentifier"&&s.cert){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);var M=d.value.value;if(d.keyIdentifier){var X=d.keyIdentifier===!0?s.cert.generateSubjectKeyIdentifier().getBytes():d.keyIdentifier;M.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!1,X))}if(d.authorityCertIssuer){var ee=[e.create(e.Class.CONTEXT_SPECIFIC,4,!0,[g(d.authorityCertIssuer===!0?s.cert.issuer:d.authorityCertIssuer)])];M.push(e.create(e.Class.CONTEXT_SPECIFIC,1,!0,ee))}if(d.serialNumber){var ne=t.util.hexToBytes(d.serialNumber===!0?s.cert.serialNumber:d.serialNumber);M.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!1,ne))}}else if(d.name==="cRLDistributionPoints"){d.value=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);for(var M=d.value.value,ie=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]),de=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]),F,G=0;G<d.altNames.length;++G){F=d.altNames[G];var P=F.value;if(F.type===7&&F.ip){if(P=t.util.bytesFromIP(F.ip),P===null){var n=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw n.extension=d,n}}else F.type===8&&(F.oid?P=e.oidToDer(e.oidToDer(F.oid)):P=e.oidToDer(P));de.value.push(e.create(e.Class.CONTEXT_SPECIFIC,F.type,!1,P))}ie.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[de])),M.push(ie)}if(typeof d.value>"u"){var n=new Error("Extension value not specified.");throw n.extension=d,n}return d}function i(d,s){switch(d){case o["RSASSA-PSS"]:var n=[];return s.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(s.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])),s.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(s.mgf.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(s.mgf.hash.algorithmOid).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.NULL,!1,"")])])])),s.saltLength!==void 0&&n.push(e.create(e.Class.CONTEXT_SPECIFIC,2,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(s.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 s=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);if(d.attributes.length===0)return s;for(var n=d.attributes,B=0;B<n.length;++B){var U=n[B],O=U.value,P=e.Type.UTF8;"valueTagClass"in U&&(P=U.valueTagClass),P===e.Type.UTF8&&(O=t.util.encodeUtf8(O));var M=!1;"valueConstructed"in U&&(M=U.valueConstructed);var q=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(U.type).getBytes()),e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[e.create(e.Class.UNIVERSAL,P,M,O)])]);s.value.push(q)}return s}var v=new Date("1950-01-01T00:00:00Z"),I=new Date("2050-01-01T00:00:00Z");function N(d){return d>=v&&d<I?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 s=N(d.validity.notBefore),n=N(d.validity.notAfter),B=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()),i(d.siginfo.algorithmOid,d.siginfo.parameters)]),g(d.issuer),e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,n]),g(d.subject),r.publicKeyToAsn1(d.publicKey)]);return d.issuer.uniqueId&&B.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&&B.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&&B.value.push(r.certificateExtensionsToAsn1(d.extensions)),B},r.getCertificationRequestInfo=function(d){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(d.version).getBytes()),g(d.subject),r.publicKeyToAsn1(d.publicKey),h(d)]);return s},r.distinguishedNameToAsn1=function(d){return g(d)},r.certificateToAsn1=function(d){var s=d.tbsCertificate||r.getTBSCertificate(d);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.signatureOid).getBytes()),i(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.certificateExtensionsToAsn1=function(d){var s=e.create(e.Class.CONTEXT_SPECIFIC,3,!0,[]),n=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);s.value.push(n);for(var B=0;B<d.length;++B)n.value.push(r.certificateExtensionToAsn1(d[B]));return s},r.certificateExtensionToAsn1=function(d){var s=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[]);s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.id).getBytes())),d.critical&&s.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()),s.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,n)),s},r.certificationRequestToAsn1=function(d){var s=d.certificationRequestInfo||r.getCertificationRequestInfo(d);return e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[s,e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(d.signatureOid).getBytes()),i(d.signatureOid,d.signatureParameters)]),e.create(e.Class.UNIVERSAL,e.Type.BITSTRING,!1,"\0"+d.signature)])},r.createCaStore=function(d){var s={certs:{}};s.getIssuer=function(P){var M=n(P.issuer);return M},s.addCertificate=function(P){if(typeof P=="string"&&(P=t.pki.certificateFromPem(P)),B(P.subject),!s.hasCertificate(P))if(P.subject.hash in s.certs){var M=s.certs[P.subject.hash];t.util.isArray(M)||(M=[M]),M.push(P),s.certs[P.subject.hash]=M}else s.certs[P.subject.hash]=P},s.hasCertificate=function(P){typeof P=="string"&&(P=t.pki.certificateFromPem(P));var M=n(P.subject);if(!M)return!1;t.util.isArray(M)||(M=[M]);for(var q=e.toDer(r.certificateToAsn1(P)).getBytes(),F=0;F<M.length;++F){var G=e.toDer(r.certificateToAsn1(M[F])).getBytes();if(q===G)return!0}return!1},s.listAllCertificates=function(){var P=[];for(var M in s.certs)if(s.certs.hasOwnProperty(M)){var q=s.certs[M];if(!t.util.isArray(q))P.push(q);else for(var F=0;F<q.length;++F)P.push(q[F])}return P},s.removeCertificate=function(P){var M;if(typeof P=="string"&&(P=t.pki.certificateFromPem(P)),B(P.subject),!s.hasCertificate(P))return null;var q=n(P.subject);if(!t.util.isArray(q))return M=s.certs[P.subject.hash],delete s.certs[P.subject.hash],M;for(var F=e.toDer(r.certificateToAsn1(P)).getBytes(),G=0;G<q.length;++G){var W=e.toDer(r.certificateToAsn1(q[G])).getBytes();F===W&&(M=q[G],q.splice(G,1))}return q.length===0&&delete s.certs[P.subject.hash],M};function n(P){return B(P),s.certs[P.hash]||null}function B(P){if(!P.hash){var M=t.md.sha1.create();P.attributes=r.RDNAttributesAsArray(g(P),M),P.hash=M.digest().toHex()}}if(d)for(var U=0;U<d.length;++U){var O=d[U];s.addCertificate(O)}return s},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,s,n){typeof n=="function"&&(n={verify:n}),n=n||{},s=s.slice(0);var B=s.slice(0),U=n.validityCheckDate;typeof U>"u"&&(U=new Date);var O=!0,P=null,M=0;do{var q=s.shift(),F=null,G=!1;if(U&&(U<q.validity.notBefore||U>q.validity.notAfter)&&(P={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:q.validity.notBefore,notAfter:q.validity.notAfter,now:U}),P===null){if(F=s[0]||d.getIssuer(q),F===null&&q.isIssuer(q)&&(G=!0,F=q),F){var W=F;t.util.isArray(W)||(W=[W]);for(var X=!1;!X&&W.length>0;){F=W.shift();try{X=F.verify(q)}catch{}}X||(P={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}P===null&&(!F||G)&&!d.hasCertificate(q)&&(P={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(P===null&&F&&!q.isIssuer(F)&&(P={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),P===null)for(var ee={keyUsage:!0,basicConstraints:!0},ne=0;P===null&&ne<q.extensions.length;++ne){var ie=q.extensions[ne];ie.critical&&!(ie.name in ee)&&(P={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(P===null&&(!O||s.length===0&&(!F||G))){var de=q.getExtension("basicConstraints"),ge=q.getExtension("keyUsage");if(ge!==null&&(!ge.keyCertSign||de===null)&&(P={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}),P===null&&de===null&&(P={message:"Certificate is missing basicConstraints extension and cannot be used as a CA.",error:r.certificateError.bad_certificate}),P===null&&de!==null&&!de.cA&&(P={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),P===null&&ge!==null&&"pathLenConstraint"in de){var le=M-1;le>de.pathLenConstraint&&(P={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}}var j=P===null?!0:P.error,$=n.verify?n.verify(j,M,B):j;if($===!0)P=null;else throw j===!0&&(P={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),($||$===0)&&(typeof $=="object"&&!t.util.isArray($)?($.message&&(P.message=$.message),$.error&&(P.error=$.error)):typeof $=="string"&&(P.error=$)),P;O=!1,++M}while(s.length>0);return!0},Pr.exports}var ja;function $a(){if(ja)return Ur.exports;ja=1;var t=ue();nt(),Rt(),vt(),Ga(),qa(),Je(),zt(),Nt(),ce(),Fr();var e=t.asn1,r=t.pki,o=Ur.exports=t.pkcs12=t.pkcs12||{},E={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"},E,{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"}]},p={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(C,m,i,h){for(var v=[],I=0;I<C.length;I++)for(var N=0;N<C[I].safeBags.length;N++){var d=C[I].safeBags[N];if(!(h!==void 0&&d.type!==h)){if(m===null){v.push(d);continue}d.attributes[m]!==void 0&&d.attributes[m].indexOf(i)>=0&&v.push(d)}}return v}o.pkcs12FromAsn1=function(C,m,i){typeof m=="string"?(i=m,m=!0):m===void 0&&(m=!0);var h={},v=[];if(!e.validate(C,y,h,v)){var I=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw I.errors=I,I}var N={version:h.version.charCodeAt(0),safeContents:[],getBags:function(F){var G={},W;return"localKeyId"in F?W=F.localKeyId:"localKeyIdHex"in F&&(W=t.util.hexToBytes(F.localKeyIdHex)),W===void 0&&!("friendlyName"in F)&&"bagType"in F&&(G[F.bagType]=l(N.safeContents,null,null,F.bagType)),W!==void 0&&(G.localKeyId=l(N.safeContents,"localKeyId",W,F.bagType)),"friendlyName"in F&&(G.friendlyName=l(N.safeContents,"friendlyName",F.friendlyName,F.bagType)),G},getBagsByFriendlyName:function(F,G){return l(N.safeContents,"friendlyName",F,G)},getBagsByLocalKeyId:function(F,G){return l(N.safeContents,"localKeyId",F,G)}};if(h.version.charCodeAt(0)!==3){var I=new Error("PKCS#12 PFX of version other than 3 not supported.");throw I.version=h.version.charCodeAt(0),I}if(e.derToOid(h.contentType)!==r.oids.data){var I=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw I.oid=e.derToOid(h.contentType),I}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=S(d),h.mac){var s=null,n=0,B=e.derToOid(h.macAlgorithm);switch(B){case r.oids.sha1:s=t.md.sha1.create(),n=20;break;case r.oids.sha256:s=t.md.sha256.create(),n=32;break;case r.oids.sha384:s=t.md.sha384.create(),n=48;break;case r.oids.sha512:s=t.md.sha512.create(),n=64;break;case r.oids.md5:s=t.md.md5.create(),n=16;break}if(s===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+B);var U=new t.util.ByteBuffer(h.macSalt),O="macIterations"in h?parseInt(t.util.bytesToHex(h.macIterations),16):1,P=o.generateKey(i,U,3,O,n,s),M=t.hmac.create();M.start(s,P),M.update(d.value);var q=M.getMac();if(q.getBytes()!==h.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}else if(Array.isArray(C.value)&&C.value.length>2)throw new Error("Invalid PKCS#12. macData field present but MAC was not validated.");return R(N,d.value,m,i),N};function S(C){if(C.composed||C.constructed){for(var m=t.util.createBuffer(),i=0;i<C.value.length;++i)m.putBytes(C.value[i].value);C.composed=C.constructed=!1,C.value=m.getBytes()}return C}function R(C,m,i,h){if(m=e.fromDer(m,i),m.tagClass!==e.Class.UNIVERSAL||m.type!==e.Type.SEQUENCE||m.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var v=0;v<m.value.length;v++){var I=m.value[v],N={},d=[];if(!e.validate(I,E,N,d)){var s=new Error("Cannot read ContentInfo.");throw s.errors=d,s}var n={encrypted:!1},B=null,U=N.content.value[0];switch(e.derToOid(N.contentType)){case r.oids.data:if(U.tagClass!==e.Class.UNIVERSAL||U.type!==e.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");B=S(U).value;break;case r.oids.encryptedData:B=x(U,h),n.encrypted=!0;break;default:var s=new Error("Unsupported PKCS#12 contentType.");throw s.contentType=e.derToOid(N.contentType),s}n.safeBags=c(B,i,h),C.safeContents.push(n)}}function x(C,m){var i={},h=[];if(!e.validate(C,t.pkcs7.asn1.encryptedDataValidator,i,h)){var v=new Error("Cannot read EncryptedContentInfo.");throw v.errors=h,v}var I=e.derToOid(i.contentType);if(I!==r.oids.data){var v=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw v.oid=I,v}I=e.derToOid(i.encAlgorithm);var N=r.pbe.getCipher(I,i.encParameter,m),d=S(i.encryptedContentAsn1),s=t.util.createBuffer(d.value);if(N.update(s),!N.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return N.output.getBytes()}function c(C,m,i){if(!m&&C.length===0)return[];if(C=e.fromDer(C,m),C.tagClass!==e.Class.UNIVERSAL||C.type!==e.Type.SEQUENCE||C.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var h=[],v=0;v<C.value.length;v++){var I=C.value[v],N={},d=[];if(!e.validate(I,f,N,d)){var s=new Error("Cannot read SafeBag.");throw s.errors=d,s}var n={type:e.derToOid(N.bagId),attributes:g(N.bagAttributes)};h.push(n);var B,U,O=N.bagValue.value[0];switch(n.type){case r.oids.pkcs8ShroudedKeyBag:if(O=r.decryptPrivateKeyInfo(O,i),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:B=p,U=function(){if(e.derToOid(N.certId)!==r.oids.x509Certificate){var M=new Error("Unsupported certificate type, only X.509 supported.");throw M.oid=e.derToOid(N.certId),M}var q=e.fromDer(N.cert,m);try{n.cert=r.certificateFromAsn1(q,!0)}catch{n.cert=null,n.asn1=q}};break;default:var s=new Error("Unsupported PKCS#12 SafeBag type.");throw s.oid=n.type,s}if(B!==void 0&&!e.validate(O,B,N,d)){var s=new Error("Cannot read PKCS#12 "+B.name);throw s.errors=d,s}U()}return h}function g(C){var m={};if(C!==void 0)for(var i=0;i<C.length;++i){var h={},v=[];if(!e.validate(C[i],a,h,v)){var I=new Error("Cannot read PKCS#12 BagAttribute.");throw I.errors=v,I}var N=e.derToOid(h.oid);if(r.oids[N]!==void 0){m[r.oids[N]]=[];for(var d=0;d<h.values.length;++d)m[r.oids[N]].push(h.values[d].value)}}return m}return o.toPkcs12Asn1=function(C,m,i,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,I;if(v!==null)v=t.util.hexToBytes(v);else if(h.generateLocalKeyId)if(m){var N=t.util.isArray(m)?m[0]:m;typeof N=="string"&&(N=r.certificateFromPem(N));var d=t.md.sha1.create();d.update(e.toDer(r.certificateToAsn1(N)).getBytes()),v=d.digest().getBytes()}else v=t.random.getBytes(20);var s=[];v!==null&&s.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&&s.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)])])),s.length>0&&(I=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,s));var n=[],B=[];m!==null&&(t.util.isArray(m)?B=m:B=[m]);for(var U=[],O=0;O<B.length;++O){m=B[O],typeof m=="string"&&(m=r.certificateFromPem(m));var P=O===0?I:void 0,M=r.certificateToAsn1(m),q=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(M).getBytes())])])]),P]);U.push(q)}if(U.length>0){var F=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,U),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(F).getBytes())])]);n.push(G)}var W=null;if(C!==null){var X=r.wrapRsaPrivateKey(r.privateKeyToAsn1(C));i===null?W=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]),I]):W=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,i,h)]),I]);var ee=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,[W]),ne=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(ee).getBytes())])]);n.push(ne)}var ie=e.create(e.Class.UNIVERSAL,e.Type.SEQUENCE,!0,n),de;if(h.useMac){var d=t.md.sha1.create(),ge=new t.util.ByteBuffer(t.random.getBytes(h.saltSize)),le=h.count,C=o.generateKey(i,ge,3,le,20),j=t.hmac.create();j.start(d,C),j.update(e.toDer(ie).getBytes());var $=j.getMac();de=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,$.getBytes())]),e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,ge.getBytes()),e.create(e.Class.UNIVERSAL,e.Type.INTEGER,!1,e.integerToDer(le).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(ie).getBytes())])]),de])},o.generateKey=t.pbe.generatePkcs12Key,Ur.exports}var Za;function Ja(){if(Za)return xr.exports;Za=1;var t=ue();nt(),vt(),qa(),Ct(),Ir(),$a(),Kr(),zt(),ce(),Fr();var e=t.asn1,r=xr.exports=t.pki=t.pki||{};return r.pemToDer=function(o){var E=t.pem.decode(o)[0];if(E.procType&&E.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return t.util.createBuffer(E.body)},r.privateKeyFromPem=function(o){var E=t.pem.decode(o)[0];if(E.type!=="PRIVATE KEY"&&E.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=E.type,y}if(E.procType&&E.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var f=e.fromDer(E.body);return r.privateKeyFromAsn1(f)},r.privateKeyToPem=function(o,E){var y={type:"RSA PRIVATE KEY",body:e.toDer(r.privateKeyToAsn1(o)).getBytes()};return t.pem.encode(y,{maxline:E})},r.privateKeyInfoToPem=function(o,E){var y={type:"PRIVATE KEY",body:e.toDer(o).getBytes()};return t.pem.encode(y,{maxline:E})},xr.exports}var qr,en;function tn(){if(en)return qr;en=1;var t=ue();nt(),Rt(),Cr(),Ct(),Ja(),Je(),Nt(),ce();var e=function(T,k,L,_){var u=t.util.createBuffer(),w=T.length>>1,V=w+(T.length&1),H=T.substr(0,V),ae=T.substr(w,V),te=t.util.createBuffer(),z=t.hmac.create();L=k+L;var Z=Math.ceil(_/16),se=Math.ceil(_/20);z.start("MD5",H);var fe=t.util.createBuffer();te.putBytes(L);for(var oe=0;oe<Z;++oe)z.start(null,null),z.update(te.getBytes()),te.putBuffer(z.digest()),z.start(null,null),z.update(te.bytes()+L),fe.putBuffer(z.digest());z.start("SHA1",ae);var Ce=t.util.createBuffer();te.clear(),te.putBytes(L);for(var oe=0;oe<se;++oe)z.start(null,null),z.update(te.getBytes()),te.putBuffer(z.digest()),z.start(null,null),z.update(te.bytes()+L),Ce.putBuffer(z.digest());return u.putBytes(t.util.xorBytes(fe.getBytes(),Ce.getBytes(),_)),u},r=function(T,k,L){var _=t.hmac.create();_.start("SHA1",T);var u=t.util.createBuffer();return u.putInt32(k[0]),u.putInt32(k[1]),u.putByte(L.type),u.putByte(L.version.major),u.putByte(L.version.minor),u.putInt16(L.length),u.putBytes(L.fragment.bytes()),_.update(u.getBytes()),_.digest().getBytes()},o=function(T,k,L){var _=!1;try{var u=T.deflate(k.fragment.getBytes());k.fragment=t.util.createBuffer(u),k.length=u.length,_=!0}catch{}return _},E=function(T,k,L){var _=!1;try{var u=T.inflate(k.fragment.getBytes());k.fragment=t.util.createBuffer(u),k.length=u.length,_=!0}catch{}return _},y=function(T,k){var L=0;switch(k){case 1:L=T.getByte();break;case 2:L=T.getInt16();break;case 3:L=T.getInt24();break;case 4:L=T.getInt32();break}return t.util.createBuffer(T.getBytes(L))},f=function(T,k,L){T.putInt(L.length(),k<<3),T.putBuffer(L)},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(T){var k=null;for(var L in a.CipherSuites){var _=a.CipherSuites[L];if(_.id[0]===T.charCodeAt(0)&&_.id[1]===T.charCodeAt(1)){k=_;break}}return k},a.handleUnexpected=function(T,k){var L=!T.open&&T.entity===a.ConnectionEnd.client;L||T.error(T,{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(T,k,L){!T.handshaking&&T.handshakes>0&&(a.queue(T,a.createAlert(T,{level:a.Alert.Level.warning,description:a.Alert.Description.no_renegotiation})),a.flush(T)),T.process()},a.parseHelloMessage=function(T,k,L){var _=null,u=T.entity===a.ConnectionEnd.client;if(L<38)T.error(T,{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=k.fragment,V=w.length();if(_={version:{major:w.getByte(),minor:w.getByte()},random:t.util.createBuffer(w.getBytes(32)),session_id:y(w,1),extensions:[]},u?(_.cipher_suite=w.getBytes(2),_.compression_method=w.getByte()):(_.cipher_suites=y(w,2),_.compression_methods=y(w,1)),V=L-(V-w.length()),V>0){for(var H=y(w,2);H.length()>0;)_.extensions.push({type:[H.getByte(),H.getByte()],data:y(H,2)});if(!u)for(var ae=0;ae<_.extensions.length;++ae){var te=_.extensions[ae];if(te.type[0]===0&&te.type[1]===0)for(var z=y(te.data,2);z.length()>0;){var Z=z.getByte();if(Z!==0)break;T.session.extensions.server_name.serverNameList.push(y(z,2).getBytes())}}}if(T.session.version&&(_.version.major!==T.session.version.major||_.version.minor!==T.session.version.minor))return T.error(T,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});if(u)T.session.cipherSuite=a.getCipherSuite(_.cipher_suite);else for(var se=t.util.createBuffer(_.cipher_suites.bytes());se.length()>0&&(T.session.cipherSuite=a.getCipherSuite(se.getBytes(2)),T.session.cipherSuite===null););if(T.session.cipherSuite===null)return T.error(T,{message:"No cipher suites in common.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure},cipherSuite:t.util.bytesToHex(_.cipher_suite)});u?T.session.compressionMethod=_.compression_method:T.session.compressionMethod=a.CompressionMethod.none}return _},a.createSecurityParameters=function(T,k){var L=T.entity===a.ConnectionEnd.client,_=k.random.bytes(),u=L?T.session.sp.client_random:_,w=L?_:a.createRandom().getBytes();T.session.sp={entity:T.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:T.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:u,server_random:w}},a.handleServerHello=function(T,k,L){var _=a.parseHelloMessage(T,k,L);if(!T.fail){if(_.version.minor<=T.version.minor)T.version.minor=_.version.minor;else return T.error(T,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}});T.session.version=T.version;var u=_.session_id.bytes();u.length>0&&u===T.session.id?(T.expect=c,T.session.resuming=!0,T.session.sp.server_random=_.random.bytes()):(T.expect=l,T.session.resuming=!1,a.createSecurityParameters(T,_)),T.session.id=u,T.process()}},a.handleClientHello=function(T,k,L){var _=a.parseHelloMessage(T,k,L);if(!T.fail){var u=_.session_id.bytes(),w=null;if(T.sessionCache&&(w=T.sessionCache.getSession(u),w===null?u="":(w.version.major!==_.version.major||w.version.minor>_.version.minor)&&(w=null,u="")),u.length===0&&(u=t.random.getBytes(32)),T.session.id=u,T.session.clientHelloVersion=_.version,T.session.sp={},w)T.version=T.session.version=w.version,T.session.sp=w.sp;else{for(var V,H=1;H<a.SupportedVersions.length&&(V=a.SupportedVersions[H],!(V.minor<=_.version.minor));++H);T.version={major:V.major,minor:V.minor},T.session.version=T.version}w!==null?(T.expect=N,T.session.resuming=!0,T.session.sp.client_random=_.random.bytes()):(T.expect=T.verifyClient!==!1?h:v,T.session.resuming=!1,a.createSecurityParameters(T,_)),T.open=!0,a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createServerHello(T)})),T.session.resuming?(a.queue(T,a.createRecord(T,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),T.state.pending=a.createConnectionState(T),T.state.current.write=T.state.pending.write,a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createFinished(T)}))):(a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createCertificate(T)})),T.fail||(a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createServerKeyExchange(T)})),T.verifyClient!==!1&&a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createCertificateRequest(T)})),a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createServerHelloDone(T)})))),a.flush(T),T.process()}},a.handleCertificate=function(T,k,L){if(L<3)return T.error(T,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var _=k.fragment,u={certificate_list:y(_,3)},w,V,H=[];try{for(;u.certificate_list.length()>0;)w=y(u.certificate_list,3),V=t.asn1.fromDer(w),w=t.pki.certificateFromAsn1(V,!0),H.push(w)}catch(te){return T.error(T,{message:"Could not parse certificate list.",cause:te,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var ae=T.entity===a.ConnectionEnd.client;(ae||T.verifyClient===!0)&&H.length===0?T.error(T,{message:ae?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}}):H.length===0?T.expect=ae?S:v:(ae?T.session.serverCertificate=H[0]:T.session.clientCertificate=H[0],a.verifyCertificateChain(T,H)&&(T.expect=ae?S:v)),T.process()},a.handleServerKeyExchange=function(T,k,L){if(L>0)return T.error(T,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});T.expect=R,T.process()},a.handleClientKeyExchange=function(T,k,L){if(L<48)return T.error(T,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.unsupported_certificate}});var _=k.fragment,u={enc_pre_master_secret:y(_,2).getBytes()},w=null;if(T.getPrivateKey)try{w=T.getPrivateKey(T,T.session.serverCertificate),w=t.pki.privateKeyFromPem(w)}catch(ae){T.error(T,{message:"Could not get private key.",cause:ae,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}if(w===null)return T.error(T,{message:"No private key set.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}});try{var V=T.session.sp;V.pre_master_secret=w.decrypt(u.enc_pre_master_secret);var H=T.session.clientHelloVersion;if(H.major!==V.pre_master_secret.charCodeAt(0)||H.minor!==V.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{V.pre_master_secret=t.random.getBytes(48)}T.expect=N,T.session.clientCertificate!==null&&(T.expect=I),T.process()},a.handleCertificateRequest=function(T,k,L){if(L<3)return T.error(T,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var _=k.fragment,u={certificate_types:y(_,1),certificate_authorities:y(_,2)};T.session.certificateRequest=u,T.expect=x,T.process()},a.handleCertificateVerify=function(T,k,L){if(L<2)return T.error(T,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var _=k.fragment;_.read-=4;var u=_.bytes();_.read+=4;var w={signature:y(_,2).getBytes()},V=t.util.createBuffer();V.putBuffer(T.session.md5.digest()),V.putBuffer(T.session.sha1.digest()),V=V.getBytes();try{var H=T.session.clientCertificate;if(!H.publicKey.verify(V,w.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");T.session.md5.update(u),T.session.sha1.update(u)}catch{return T.error(T,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.handshake_failure}})}T.expect=N,T.process()},a.handleServerHelloDone=function(T,k,L){if(L>0)return T.error(T,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.record_overflow}});if(T.serverCertificate===null){var _={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=T.verify(T,_.alert.description,u,[]);if(w!==!0)return(w||w===0)&&(typeof w=="object"&&!t.util.isArray(w)?(w.message&&(_.message=w.message),w.alert&&(_.alert.description=w.alert)):typeof w=="number"&&(_.alert.description=w)),T.error(T,_)}T.session.certificateRequest!==null&&(k=a.createRecord(T,{type:a.ContentType.handshake,data:a.createCertificate(T)}),a.queue(T,k)),k=a.createRecord(T,{type:a.ContentType.handshake,data:a.createClientKeyExchange(T)}),a.queue(T,k),T.expect=m;var V=function(H,ae){H.session.certificateRequest!==null&&H.session.clientCertificate!==null&&a.queue(H,a.createRecord(H,{type:a.ContentType.handshake,data:a.createCertificateVerify(H,ae)})),a.queue(H,a.createRecord(H,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),H.state.pending=a.createConnectionState(H),H.state.current.write=H.state.pending.write,a.queue(H,a.createRecord(H,{type:a.ContentType.handshake,data:a.createFinished(H)})),H.expect=c,a.flush(H),H.process()};if(T.session.certificateRequest===null||T.session.clientCertificate===null)return V(T,null);a.getClientSignature(T,V)},a.handleChangeCipherSpec=function(T,k){if(k.fragment.getByte()!==1)return T.error(T,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.illegal_parameter}});var L=T.entity===a.ConnectionEnd.client;(T.session.resuming&&L||!T.session.resuming&&!L)&&(T.state.pending=a.createConnectionState(T)),T.state.current.read=T.state.pending.read,(!T.session.resuming&&L||T.session.resuming&&!L)&&(T.state.pending=null),T.expect=L?g:d,T.process()},a.handleFinished=function(T,k,L){var _=k.fragment;_.read-=4;var u=_.bytes();_.read+=4;var w=k.fragment.getBytes();_=t.util.createBuffer(),_.putBuffer(T.session.md5.digest()),_.putBuffer(T.session.sha1.digest());var V=T.entity===a.ConnectionEnd.client,H=V?"server finished":"client finished",ae=T.session.sp,te=12,z=e;if(_=z(ae.master_secret,H,_.getBytes(),te),_.getBytes()!==w)return T.error(T,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.decrypt_error}});T.session.md5.update(u),T.session.sha1.update(u),(T.session.resuming&&V||!T.session.resuming&&!V)&&(a.queue(T,a.createRecord(T,{type:a.ContentType.change_cipher_spec,data:a.createChangeCipherSpec()})),T.state.current.write=T.state.pending.write,T.state.pending=null,a.queue(T,a.createRecord(T,{type:a.ContentType.handshake,data:a.createFinished(T)}))),T.expect=V?C:s,T.handshaking=!1,++T.handshakes,T.peerCertificate=V?T.session.serverCertificate:T.session.clientCertificate,a.flush(T),T.isConnected=!0,T.connected(T),T.process()},a.handleAlert=function(T,k){var L=k.fragment,_={level:L.getByte(),description:L.getByte()},u;switch(_.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(_.description===a.Alert.Description.close_notify)return T.close();T.error(T,{message:u,send:!1,origin:T.entity===a.ConnectionEnd.client?"server":"client",alert:_}),T.process()},a.handleHandshake=function(T,k){var L=k.fragment,_=L.getByte(),u=L.getInt24();if(u>L.length())return T.fragmented=k,k.fragment=t.util.createBuffer(),L.read-=4,T.process();T.fragmented=null,L.read-=4;var w=L.bytes(u+4);L.read+=4,_ in de[T.entity][T.expect]?(T.entity===a.ConnectionEnd.server&&!T.open&&!T.fail&&(T.handshaking=!0,T.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()}),_!==a.HandshakeType.hello_request&&_!==a.HandshakeType.certificate_verify&&_!==a.HandshakeType.finished&&(T.session.md5.update(w),T.session.sha1.update(w)),de[T.entity][T.expect][_](T,k,u)):a.handleUnexpected(T,k)},a.handleApplicationData=function(T,k){T.data.putBuffer(k.fragment),T.dataReady(T),T.process()},a.handleHeartbeat=function(T,k){var L=k.fragment,_=L.getByte(),u=L.getInt16(),w=L.getBytes(u);if(_===a.HeartbeatMessageType.heartbeat_request){if(T.handshaking||u>w.length)return T.process();a.queue(T,a.createRecord(T,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_response,w)})),a.flush(T)}else if(_===a.HeartbeatMessageType.heartbeat_response){if(w!==T.expectedHeartbeatPayload)return T.process();T.heartbeatReceived&&T.heartbeatReceived(T,t.util.createBuffer(w))}T.process()};var p=0,l=1,S=2,R=3,x=4,c=5,g=6,C=7,m=8,i=0,h=1,v=2,I=3,N=4,d=5,s=6,n=a.handleUnexpected,B=a.handleChangeCipherSpec,U=a.handleAlert,O=a.handleHandshake,P=a.handleApplicationData,M=a.handleHeartbeat,q=[];q[a.ConnectionEnd.client]=[[n,U,O,n,M],[n,U,O,n,M],[n,U,O,n,M],[n,U,O,n,M],[n,U,O,n,M],[B,U,n,n,M],[n,U,O,n,M],[n,U,O,P,M],[n,U,O,n,M]],q[a.ConnectionEnd.server]=[[n,U,O,n,M],[n,U,O,n,M],[n,U,O,n,M],[n,U,O,n,M],[B,U,n,n,M],[n,U,O,n,M],[n,U,O,P,M],[n,U,O,n,M]];var F=a.handleHelloRequest,G=a.handleServerHello,W=a.handleCertificate,X=a.handleServerKeyExchange,ee=a.handleCertificateRequest,ne=a.handleServerHelloDone,ie=a.handleFinished,de=[];de[a.ConnectionEnd.client]=[[n,n,G,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,W,X,ee,ne,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,X,ee,ne,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,n,ee,ne,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,n,n,ne,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,ie],[F,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n],[F,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n]];var ge=a.handleClientHello,le=a.handleClientKeyExchange,j=a.handleCertificateVerify;de[a.ConnectionEnd.server]=[[n,ge,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,W,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,le,n,n,n,n],[n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,j,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,ie],[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(T,k){var L=e,_=k.client_random+k.server_random;T.session.resuming||(k.master_secret=L(k.pre_master_secret,"master secret",_,48).bytes(),k.pre_master_secret=null),_=k.server_random+k.client_random;var u=2*k.mac_key_length+2*k.enc_key_length,w=T.version.major===a.Versions.TLS_1_0.major&&T.version.minor===a.Versions.TLS_1_0.minor;w&&(u+=2*k.fixed_iv_length);var V=L(k.master_secret,"key expansion",_,u),H={client_write_MAC_key:V.getBytes(k.mac_key_length),server_write_MAC_key:V.getBytes(k.mac_key_length),client_write_key:V.getBytes(k.enc_key_length),server_write_key:V.getBytes(k.enc_key_length)};return w&&(H.client_write_IV=V.getBytes(k.fixed_iv_length),H.server_write_IV=V.getBytes(k.fixed_iv_length)),H},a.createConnectionState=function(T){var k=T.entity===a.ConnectionEnd.client,L=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},_={read:L(),write:L()};if(_.read.update=function(w,V){return _.read.cipherFunction(V,_.read)?_.read.compressFunction(w,V,_.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},_.write.update=function(w,V){return _.write.compressFunction(w,V,_.write)?_.write.cipherFunction(V,_.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},T.session){var u=T.session.sp;switch(T.session.cipherSuite.initSecurityParameters(u),u.keys=a.generateKeys(T,u),_.read.macKey=k?u.keys.server_write_MAC_key:u.keys.client_write_MAC_key,_.write.macKey=k?u.keys.client_write_MAC_key:u.keys.server_write_MAC_key,T.session.cipherSuite.initConnectionState(_,T,u),u.compression_algorithm){case a.CompressionMethod.none:break;case a.CompressionMethod.deflate:_.read.compressFunction=E,_.write.compressFunction=o;break;default:throw new Error("Unsupported compression algorithm.")}}return _},a.createRandom=function(){var T=new Date,k=+T+T.getTimezoneOffset()*6e4,L=t.util.createBuffer();return L.putInt32(k),L.putBytes(t.random.getBytes(28)),L},a.createRecord=function(T,k){if(!k.data)return null;var L={type:k.type,version:{major:T.version.major,minor:T.version.minor},length:k.data.length(),fragment:k.data};return L},a.createAlert=function(T,k){var L=t.util.createBuffer();return L.putByte(k.level),L.putByte(k.description),a.createRecord(T,{type:a.ContentType.alert,data:L})},a.createClientHello=function(T){T.session.clientHelloVersion={major:T.version.major,minor:T.version.minor};for(var k=t.util.createBuffer(),L=0;L<T.cipherSuites.length;++L){var _=T.cipherSuites[L];k.putByte(_.id[0]),k.putByte(_.id[1])}var u=k.length(),w=t.util.createBuffer();w.putByte(a.CompressionMethod.none);var V=w.length(),H=t.util.createBuffer();if(T.virtualHost){var ae=t.util.createBuffer();ae.putByte(0),ae.putByte(0);var te=t.util.createBuffer();te.putByte(0),f(te,2,t.util.createBuffer(T.virtualHost));var z=t.util.createBuffer();f(z,2,te),f(ae,2,z),H.putBuffer(ae)}var Z=H.length();Z>0&&(Z+=2);var se=T.session.id,fe=se.length+1+2+4+28+2+u+1+V+Z,oe=t.util.createBuffer();return oe.putByte(a.HandshakeType.client_hello),oe.putInt24(fe),oe.putByte(T.version.major),oe.putByte(T.version.minor),oe.putBytes(T.session.sp.client_random),f(oe,1,t.util.createBuffer(se)),f(oe,2,k),f(oe,1,w),Z>0&&f(oe,2,H),oe},a.createServerHello=function(T){var k=T.session.id,L=k.length+1+2+4+28+2+1,_=t.util.createBuffer();return _.putByte(a.HandshakeType.server_hello),_.putInt24(L),_.putByte(T.version.major),_.putByte(T.version.minor),_.putBytes(T.session.sp.server_random),f(_,1,t.util.createBuffer(k)),_.putByte(T.session.cipherSuite.id[0]),_.putByte(T.session.cipherSuite.id[1]),_.putByte(T.session.compressionMethod),_},a.createCertificate=function(T){var k=T.entity===a.ConnectionEnd.client,L=null;if(T.getCertificate){var _;k?_=T.session.certificateRequest:_=T.session.extensions.server_name.serverNameList,L=T.getCertificate(T,_)}var u=t.util.createBuffer();if(L!==null)try{t.util.isArray(L)||(L=[L]);for(var w=null,V=0;V<L.length;++V){var H=t.pem.decode(L[V])[0];if(H.type!=="CERTIFICATE"&&H.type!=="X509 CERTIFICATE"&&H.type!=="TRUSTED CERTIFICATE"){var ae=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw ae.headerType=H.type,ae}if(H.procType&&H.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var te=t.util.createBuffer(H.body);w===null&&(w=t.asn1.fromDer(te.bytes(),!1));var z=t.util.createBuffer();f(z,3,te),u.putBuffer(z)}L=t.pki.certificateFromAsn1(w),k?T.session.clientCertificate=L:T.session.serverCertificate=L}catch(fe){return T.error(T,{message:"Could not send certificate list.",cause:fe,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.bad_certificate}})}var Z=3+u.length(),se=t.util.createBuffer();return se.putByte(a.HandshakeType.certificate),se.putInt24(Z),f(se,3,u),se},a.createClientKeyExchange=function(T){var k=t.util.createBuffer();k.putByte(T.session.clientHelloVersion.major),k.putByte(T.session.clientHelloVersion.minor),k.putBytes(t.random.getBytes(46));var L=T.session.sp;L.pre_master_secret=k.getBytes();var _=T.session.serverCertificate.publicKey;k=_.encrypt(L.pre_master_secret);var u=k.length+2,w=t.util.createBuffer();return w.putByte(a.HandshakeType.client_key_exchange),w.putInt24(u),w.putInt16(k.length),w.putBytes(k),w},a.createServerKeyExchange=function(T){var k=t.util.createBuffer();return k},a.getClientSignature=function(T,k){var L=t.util.createBuffer();L.putBuffer(T.session.md5.digest()),L.putBuffer(T.session.sha1.digest()),L=L.getBytes(),T.getSignature=T.getSignature||function(_,u,w){var V=null;if(_.getPrivateKey)try{V=_.getPrivateKey(_,_.session.clientCertificate),V=t.pki.privateKeyFromPem(V)}catch(H){_.error(_,{message:"Could not get private key.",cause:H,send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.internal_error}})}V===null?_.error(_,{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(_,u)},T.getSignature(T,L,k)},a.createCertificateVerify=function(T,k){var L=k.length+2,_=t.util.createBuffer();return _.putByte(a.HandshakeType.certificate_verify),_.putInt24(L),_.putInt16(k.length),_.putBytes(k),_},a.createCertificateRequest=function(T){var k=t.util.createBuffer();k.putByte(1);var L=t.util.createBuffer();for(var _ in T.caStore.certs){var u=T.caStore.certs[_],w=t.pki.distinguishedNameToAsn1(u.subject),V=t.asn1.toDer(w);L.putInt16(V.length()),L.putBuffer(V)}var H=1+k.length()+2+L.length(),ae=t.util.createBuffer();return ae.putByte(a.HandshakeType.certificate_request),ae.putInt24(H),f(ae,1,k),f(ae,2,L),ae},a.createServerHelloDone=function(T){var k=t.util.createBuffer();return k.putByte(a.HandshakeType.server_hello_done),k.putInt24(0),k},a.createChangeCipherSpec=function(){var T=t.util.createBuffer();return T.putByte(1),T},a.createFinished=function(T){var k=t.util.createBuffer();k.putBuffer(T.session.md5.digest()),k.putBuffer(T.session.sha1.digest());var L=T.entity===a.ConnectionEnd.client,_=T.session.sp,u=12,w=e,V=L?"client finished":"server finished";k=w(_.master_secret,V,k.getBytes(),u);var H=t.util.createBuffer();return H.putByte(a.HandshakeType.finished),H.putInt24(k.length()),H.putBuffer(k),H},a.createHeartbeat=function(T,k,L){typeof L>"u"&&(L=k.length);var _=t.util.createBuffer();_.putByte(T),_.putInt16(L),_.putBytes(k);var u=_.length(),w=Math.max(16,u-L-3);return _.putBytes(t.random.getBytes(w)),_},a.queue=function(T,k){if(k&&!(k.fragment.length()===0&&(k.type===a.ContentType.handshake||k.type===a.ContentType.alert||k.type===a.ContentType.change_cipher_spec))){if(k.type===a.ContentType.handshake){var L=k.fragment.bytes();T.session.md5.update(L),T.session.sha1.update(L),L=null}var _;if(k.fragment.length()<=a.MaxFragment)_=[k];else{_=[];for(var u=k.fragment.bytes();u.length>a.MaxFragment;)_.push(a.createRecord(T,{type:k.type,data:t.util.createBuffer(u.slice(0,a.MaxFragment))})),u=u.slice(a.MaxFragment);u.length>0&&_.push(a.createRecord(T,{type:k.type,data:t.util.createBuffer(u)}))}for(var w=0;w<_.length&&!T.fail;++w){var V=_[w],H=T.state.current.write;H.update(T,V)&&T.records.push(V)}}},a.flush=function(T){for(var k=0;k<T.records.length;++k){var L=T.records[k];T.tlsData.putByte(L.type),T.tlsData.putByte(L.version.major),T.tlsData.putByte(L.version.minor),T.tlsData.putInt16(L.fragment.length()),T.tlsData.putBuffer(T.records[k].fragment)}return T.records=[],T.tlsDataReady(T)};var $=function(T){switch(T){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}},ze=function(T){switch(T){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(T,k){try{var L={};for(var _ in T.verifyOptions)L[_]=T.verifyOptions[_];L.verify=function(w,V,H){var ae=$(w),te=T.verify(T,w,V,H);if(te!==!0){if(typeof te=="object"&&!t.util.isArray(te)){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},te.message&&(z.message=te.message),te.alert&&(z.alert.description=te.alert),z}te!==w&&(te=ze(te))}return te},t.pki.verifyCertificateChain(T.caStore,k,L)}catch(w){var u=w;(typeof u!="object"||t.util.isArray(u))&&(u={send:!0,alert:{level:a.Alert.Level.fatal,description:$(w)}}),"send"in u||(u.send=!0),"alert"in u||(u.alert={level:a.Alert.Level.fatal,description:$(u.error)}),T.error(T,u)}return!T.fail},a.createSessionCache=function(T,k){var L=null;if(T&&T.getSession&&T.setSession&&T.order)L=T;else{L={},L.cache=T||{},L.capacity=Math.max(k||100,1),L.order=[];for(var _ in T)L.order.length<=k?L.order.push(_):delete T[_];L.getSession=function(u){var w=null,V=null;if(u?V=t.util.bytesToHex(u):L.order.length>0&&(V=L.order[0]),V!==null&&V in L.cache){w=L.cache[V],delete L.cache[V];for(var H in L.order)if(L.order[H]===V){L.order.splice(H,1);break}}return w},L.setSession=function(u,w){if(L.order.length===L.capacity){var V=L.order.shift();delete L.cache[V]}var V=t.util.bytesToHex(u);L.order.push(V),L.cache[V]=w}}return L},a.createConnection=function(T){var k=null;T.caStore?t.util.isArray(T.caStore)?k=t.pki.createCaStore(T.caStore):k=T.caStore:k=t.pki.createCaStore();var L=T.cipherSuites||null;if(L===null){L=[];for(var _ in a.CipherSuites)L.push(a.CipherSuites[_])}var u=T.server?a.ConnectionEnd.server:a.ConnectionEnd.client,w=T.sessionCache?a.createSessionCache(T.sessionCache):null,V={version:{major:a.Version.major,minor:a.Version.minor},entity:u,sessionId:T.sessionId,caStore:k,sessionCache:w,cipherSuites:L,connected:T.connected,virtualHost:T.virtualHost||null,verifyClient:T.verifyClient||!1,verify:T.verify||function(z,Z,se,fe){return Z},verifyOptions:T.verifyOptions||{},getCertificate:T.getCertificate||null,getPrivateKey:T.getPrivateKey||null,getSignature:T.getSignature||null,input:t.util.createBuffer(),tlsData:t.util.createBuffer(),data:t.util.createBuffer(),tlsDataReady:T.tlsDataReady,dataReady:T.dataReady,heartbeatReceived:T.heartbeatReceived,closed:T.closed,error:function(z,Z){Z.origin=Z.origin||(z.entity===a.ConnectionEnd.client?"client":"server"),Z.send&&(a.queue(z,a.createAlert(z,Z.alert)),a.flush(z));var se=Z.fatal!==!1;se&&(z.fail=!0),T.error(z,Z),se&&z.close(!1)},deflate:T.deflate||null,inflate:T.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?p:i,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 H=function(z,Z){var se=Z.type-a.ContentType.change_cipher_spec,fe=q[z.entity][z.expect];se in fe?fe[se](z,Z):a.handleUnexpected(z,Z)},ae=function(z){var Z=0,se=z.input,fe=se.length();if(fe<5)Z=5-fe;else{z.record={type:se.getByte(),version:{major:se.getByte(),minor:se.getByte()},length:se.getInt16(),fragment:t.util.createBuffer(),ready:!1};var oe=z.record.version.major===z.version.major;oe&&z.session&&z.session.version&&(oe=z.record.version.minor===z.version.minor),oe||z.error(z,{message:"Incompatible TLS version.",send:!0,alert:{level:a.Alert.Level.fatal,description:a.Alert.Description.protocol_version}})}return Z},te=function(z){var Z=0,se=z.input,fe=se.length();if(fe<z.record.length)Z=z.record.length-fe;else{z.record.fragment.putBytes(se.getBytes(z.record.length)),se.compact();var oe=z.state.current.read;oe.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 Z};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 Z=null;z.length>0&&(V.sessionCache&&(Z=V.sessionCache.getSession(z)),Z===null&&(z="")),z.length===0&&V.sessionCache&&(Z=V.sessionCache.getSession(),Z!==null&&(z=Z.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()},Z&&(V.version=Z.version,V.session.sp=Z.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 Z=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&&(Z=ae(V)),!V.fail&&V.record!==null&&!V.record.ready&&(Z=te(V)),!V.fail&&V.record!==null&&V.record.ready&&H(V,V.record)),Z},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,Z){return z instanceof t.util.ByteBuffer&&(z=z.bytes()),typeof Z>"u"&&(Z=z.length),V.expectedHeartbeatPayload=z,a.queue(V,a.createRecord(V,{type:a.ContentType.heartbeat,data:a.createHeartbeat(a.HeartbeatMessageType.heartbeat_request,z,Z)})),a.flush(V)},V.close=function(z){if(!V.fail&&V.sessionCache&&V.session){var Z={id:V.session.id,version:V.session.version,sp:V.session.sp};Z.sp.keys=null,V.sessionCache.setSession(Z.id,Z)}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},qr=t.tls=t.tls||{};for(var qe in a)typeof a[qe]!="function"&&(t.tls[qe]=a[qe]);return t.tls.prf_tls1=e,t.tls.hmac_sha1=r,t.tls.createSessionCache=a.createSessionCache,t.tls.createConnection=a.createConnection,qr}var rn;function di(){if(rn)return hr.exports;rn=1;var t=ue();gt(),tn();var e=hr.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(p){p.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,p.cipher_type=e.CipherType.block,p.enc_key_length=16,p.block_length=16,p.fixed_iv_length=16,p.record_iv_length=16,p.mac_algorithm=e.MACAlgorithm.hmac_sha1,p.mac_length=20,p.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(p){p.bulk_cipher_algorithm=e.BulkCipherAlgorithm.aes,p.cipher_type=e.CipherType.block,p.enc_key_length=32,p.block_length=16,p.fixed_iv_length=16,p.record_iv_length=16,p.mac_algorithm=e.MACAlgorithm.hmac_sha1,p.mac_length=20,p.mac_key_length=20},initConnectionState:r};function r(p,l,S){var R=l.entity===t.tls.ConnectionEnd.client;p.read.cipherState={init:!1,cipher:t.cipher.createDecipher("AES-CBC",R?S.keys.server_write_key:S.keys.client_write_key),iv:R?S.keys.server_write_IV:S.keys.client_write_IV},p.write.cipherState={init:!1,cipher:t.cipher.createCipher("AES-CBC",R?S.keys.client_write_key:S.keys.server_write_key),iv:R?S.keys.client_write_IV:S.keys.server_write_IV},p.read.cipherFunction=f,p.write.cipherFunction=o,p.read.macLength=p.write.macLength=S.mac_length,p.read.macFunction=p.write.macFunction=e.hmac_sha1}function o(p,l){var S=!1,R=l.macFunction(l.macKey,l.sequenceNumber,p);p.fragment.putBytes(R),l.updateSequenceNumber();var x;p.version.minor===e.Versions.TLS_1_0.minor?x=l.cipherState.init?null:l.cipherState.iv:x=t.random.getBytesSync(16),l.cipherState.init=!0;var c=l.cipherState.cipher;return c.start({iv:x}),p.version.minor>=e.Versions.TLS_1_1.minor&&c.output.putBytes(x),c.update(p.fragment),c.finish(E)&&(p.fragment=c.output,p.length=p.fragment.length(),S=!0),S}function E(p,l,S){if(!S){var R=p-l.length()%p;l.fillWithByte(R-1,R)}return!0}function y(p,l,S){var R=!0;if(S){for(var x=l.length(),c=l.last(),g=x-1-c;g<x-1;++g)R=R&&l.at(g)==c;R&&l.truncate(c+1)}return R}function f(p,l){var S=!1,R;p.version.minor===e.Versions.TLS_1_0.minor?R=l.cipherState.init?null:l.cipherState.iv:R=p.fragment.getBytes(16),l.cipherState.init=!0;var x=l.cipherState.cipher;x.start({iv:R}),x.update(p.fragment),S=x.finish(y);var c=l.macLength,g=t.random.getBytesSync(c),C=x.output.length();C>=c?(p.fragment=x.output.getBytes(C-c),g=x.output.getBytes(c)):p.fragment=x.output.getBytes(),p.fragment=t.util.createBuffer(p.fragment),p.length=p.fragment.length();var m=l.macFunction(l.macKey,l.sequenceNumber,p);return l.updateSequenceNumber(),S=a(l.macKey,g,m)&&S,S}function a(p,l,S){var R=t.hmac.create();return R.start("SHA1",p),R.update(l),l=R.digest().getBytes(),R.start(null,null),R.update(S),S=R.digest().getBytes(),l===S}return hr.exports}var Hr={exports:{}},an;function nn(){if(an)return Hr.exports;an=1;var t=ue();st(),ce();var e=Hr.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(E||a(),typeof l>"u"&&(l="SHA-512"),!(l in f))throw new Error("Invalid SHA-512 algorithm: "+l);for(var S=f[l],R=null,x=t.util.createBuffer(),c=new Array(80),g=0;g<80;++g)c[g]=new Array(2);var C=64;switch(l){case"SHA-384":C=48;break;case"SHA-512/256":C=32;break;case"SHA-512/224":C=28;break}var m={algorithm:l.replace("-","").toLowerCase(),blockLength:128,digestLength:C,messageLength:0,fullMessageLength:null,messageLengthSize:16};return m.start=function(){m.messageLength=0,m.fullMessageLength=m.messageLength128=[];for(var i=m.messageLengthSize/4,h=0;h<i;++h)m.fullMessageLength.push(0);x=t.util.createBuffer(),R=new Array(S.length);for(var h=0;h<S.length;++h)R[h]=S[h].slice(0);return m},m.start(),m.update=function(i,h){h==="utf8"&&(i=t.util.encodeUtf8(i));var v=i.length;m.messageLength+=v,v=[v/4294967296>>>0,v>>>0];for(var I=m.fullMessageLength.length-1;I>=0;--I)m.fullMessageLength[I]+=v[1],v[1]=v[0]+(m.fullMessageLength[I]/4294967296>>>0),m.fullMessageLength[I]=m.fullMessageLength[I]>>>0,v[0]=v[1]/4294967296>>>0;return x.putBytes(i),p(R,c,x),(x.read>2048||x.length()===0)&&x.compact(),m},m.digest=function(){var i=t.util.createBuffer();i.putBytes(x.bytes());var h=m.fullMessageLength[m.fullMessageLength.length-1]+m.messageLengthSize,v=h&m.blockLength-1;i.putBytes(o.substr(0,m.blockLength-v));for(var I,N,d=m.fullMessageLength[0]*8,s=0;s<m.fullMessageLength.length-1;++s)I=m.fullMessageLength[s+1]*8,N=I/4294967296>>>0,d+=N,i.putInt32(d>>>0),d=I>>>0;i.putInt32(d);for(var n=new Array(R.length),s=0;s<R.length;++s)n[s]=R[s].slice(0);p(n,c,i);var B=t.util.createBuffer(),U;l==="SHA-512"?U=n.length:l==="SHA-384"?U=n.length-2:U=n.length-4;for(var s=0;s<U;++s)B.putInt32(n[s][0]),(s!==U-1||l!=="SHA-512/224")&&B.putInt32(n[s][1]);return B},m};var o=null,E=!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]],E=!0}function p(l,S,R){for(var x,c,g,C,m,i,h,v,I,N,d,s,n,B,U,O,P,M,q,F,G,W,X,ee,ne,ie,de,ge,le,j,$,ze,qe,T,k,L=R.length();L>=128;){for(le=0;le<16;++le)S[le][0]=R.getInt32()>>>0,S[le][1]=R.getInt32()>>>0;for(;le<80;++le)ze=S[le-2],j=ze[0],$=ze[1],x=((j>>>19|$<<13)^($>>>29|j<<3)^j>>>6)>>>0,c=((j<<13|$>>>19)^($<<3|j>>>29)^(j<<26|$>>>6))>>>0,T=S[le-15],j=T[0],$=T[1],g=((j>>>1|$<<31)^(j>>>8|$<<24)^j>>>7)>>>0,C=((j<<31|$>>>1)^(j<<24|$>>>8)^(j<<25|$>>>7))>>>0,qe=S[le-7],k=S[le-16],$=c+qe[1]+C+k[1],S[le][0]=x+qe[0]+g+k[0]+($/4294967296>>>0)>>>0,S[le][1]=$>>>0;for(n=l[0][0],B=l[0][1],U=l[1][0],O=l[1][1],P=l[2][0],M=l[2][1],q=l[3][0],F=l[3][1],G=l[4][0],W=l[4][1],X=l[5][0],ee=l[5][1],ne=l[6][0],ie=l[6][1],de=l[7][0],ge=l[7][1],le=0;le<80;++le)h=((G>>>14|W<<18)^(G>>>18|W<<14)^(W>>>9|G<<23))>>>0,v=((G<<18|W>>>14)^(G<<14|W>>>18)^(W<<23|G>>>9))>>>0,I=(ne^G&(X^ne))>>>0,N=(ie^W&(ee^ie))>>>0,m=((n>>>28|B<<4)^(B>>>2|n<<30)^(B>>>7|n<<25))>>>0,i=((n<<4|B>>>28)^(B<<30|n>>>2)^(B<<25|n>>>7))>>>0,d=(n&U|P&(n^U))>>>0,s=(B&O|M&(B^O))>>>0,$=ge+v+N+y[le][1]+S[le][1],x=de+h+I+y[le][0]+S[le][0]+($/4294967296>>>0)>>>0,c=$>>>0,$=i+s,g=m+d+($/4294967296>>>0)>>>0,C=$>>>0,de=ne,ge=ie,ne=X,ie=ee,X=G,ee=W,$=F+c,G=q+x+($/4294967296>>>0)>>>0,W=$>>>0,q=P,F=M,P=U,M=O,U=n,O=B,$=c+C,n=x+g+($/4294967296>>>0)>>>0,B=$>>>0;$=l[0][1]+B,l[0][0]=l[0][0]+n+($/4294967296>>>0)>>>0,l[0][1]=$>>>0,$=l[1][1]+O,l[1][0]=l[1][0]+U+($/4294967296>>>0)>>>0,l[1][1]=$>>>0,$=l[2][1]+M,l[2][0]=l[2][0]+P+($/4294967296>>>0)>>>0,l[2][1]=$>>>0,$=l[3][1]+F,l[3][0]=l[3][0]+q+($/4294967296>>>0)>>>0,l[3][1]=$>>>0,$=l[4][1]+W,l[4][0]=l[4][0]+G+($/4294967296>>>0)>>>0,l[4][1]=$>>>0,$=l[5][1]+ee,l[5][0]=l[5][0]+X+($/4294967296>>>0)>>>0,l[5][1]=$>>>0,$=l[6][1]+ie,l[6][0]=l[6][0]+ne+($/4294967296>>>0)>>>0,l[6][1]=$>>>0,$=l[7][1]+ge,l[7][0]=l[7][0]+de+($/4294967296>>>0)>>>0,l[7][1]=$>>>0,L-=128}}return Hr.exports}var Qt={},sn;function hi(){if(sn)return Qt;sn=1;var t=ue();nt();var e=t.asn1;return Qt.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"}]},Qt.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"}]},Qt}var Gr,on;function pi(){if(on)return Gr;on=1;var t=ue();Ht(),Je(),nn(),ce();var e=hi(),r=e.publicKeyValidator,o=e.privateKeyValidator;if(typeof E>"u")var E=t.jsbn.BigInteger;var y=t.util.ByteBuffer,f=typeof Buffer>"u"?Uint8Array:Buffer;t.pki=t.pki||{},Gr=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(k){k=k||{};var L=k.seed;if(L===void 0)L=t.random.getBytesSync(a.constants.SEED_BYTE_LENGTH);else if(typeof L=="string"){if(L.length!==a.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+a.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(L instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');L=p({message:L,encoding:"binary"});for(var _=new f(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=new f(a.constants.PRIVATE_KEY_BYTE_LENGTH),w=0;w<32;++w)u[w]=L[w];return h(_,u),{publicKey:_,privateKey:u}},a.privateKeyFromAsn1=function(k){var L={},_=[],u=t.asn1.validate(k,o,L,_);if(!u){var w=new Error("Invalid Key.");throw w.errors=_,w}var V=t.asn1.derToOid(L.privateKeyOid),H=t.oids.EdDSA25519;if(V!==H)throw new Error('Invalid OID "'+V+'"; OID must be "'+H+'".');var ae=L.privateKey,te=p({message:t.asn1.fromDer(ae).value,encoding:"binary"});return{privateKeyBytes:te}},a.publicKeyFromAsn1=function(k){var L={},_=[],u=t.asn1.validate(k,r,L,_);if(!u){var w=new Error("Invalid Key.");throw w.errors=_,w}var V=t.asn1.derToOid(L.publicKeyOid),H=t.oids.EdDSA25519;if(V!==H)throw new Error('Invalid OID "'+V+'"; OID must be "'+H+'".');var ae=L.ed25519PublicKey;if(ae.length!==a.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return p({message:ae,encoding:"binary"})},a.publicKeyFromPrivateKey=function(k){k=k||{};var L=p({message:k.privateKey,encoding:"binary"});if(L.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 _=new f(a.constants.PUBLIC_KEY_BYTE_LENGTH),u=0;u<_.length;++u)_[u]=L[32+u];return _},a.sign=function(k){k=k||{};var L=p(k),_=p({message:k.privateKey,encoding:"binary"});if(_.length===a.constants.SEED_BYTE_LENGTH){var u=a.generateKeyPair({seed:_});_=u.privateKey}else if(_.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+L.length);v(w,L,L.length,_);for(var V=new f(a.constants.SIGN_BYTE_LENGTH),H=0;H<V.length;++H)V[H]=w[H];return V},a.verify=function(k){k=k||{};var L=p(k);if(k.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var _=p({message:k.signature,encoding:"binary"});if(_.length!==a.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+a.constants.SIGN_BYTE_LENGTH);var u=p({message:k.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+L.length),V=new f(a.constants.SIGN_BYTE_LENGTH+L.length),H;for(H=0;H<a.constants.SIGN_BYTE_LENGTH;++H)w[H]=_[H];for(H=0;H<L.length;++H)w[H+a.constants.SIGN_BYTE_LENGTH]=L[H];return I(V,w,w.length,u)>=0};function p(k){var L=k.message;if(L instanceof Uint8Array||L instanceof f)return L;var _=k.encoding;if(L===void 0)if(k.md)L=k.md.digest().getBytes(),_="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof L=="string"&&!_)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof L=="string"){if(typeof Buffer<"u")return Buffer.from(L,_);L=new y(L,_)}else if(!(L 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(L.length()),w=0;w<u.length;++w)u[w]=L.at(w);return u}var l=j(),S=j([1]),R=j([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=j([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=j([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),g=j([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),C=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]),m=j([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function i(k,L){var _=t.md.sha512.create(),u=new y(k);_.update(u.getBytes(L),"binary");var w=_.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(w,"binary");for(var V=new f(a.constants.HASH_BYTE_LENGTH),H=0;H<64;++H)V[H]=w.charCodeAt(H);return V}function h(k,L){var _=[j(),j(),j(),j()],u,w=i(L,32);for(w[0]&=248,w[31]&=127,w[31]|=64,ne(_,w),U(k,_),u=0;u<32;++u)L[u+32]=k[u];return 0}function v(k,L,_,u){var w,V,H=new Float64Array(64),ae=[j(),j(),j(),j()],te=i(u,32);te[0]&=248,te[31]&=127,te[31]|=64;var z=_+64;for(w=0;w<_;++w)k[64+w]=L[w];for(w=0;w<32;++w)k[32+w]=te[32+w];var Z=i(k.subarray(32),_+32);for(s(Z),ne(ae,Z),U(k,ae),w=32;w<64;++w)k[w]=u[w];var se=i(k,_+64);for(s(se),w=32;w<64;++w)H[w]=0;for(w=0;w<32;++w)H[w]=Z[w];for(w=0;w<32;++w)for(V=0;V<32;V++)H[w+V]+=se[w]*te[V];return d(k.subarray(32),H),z}function I(k,L,_,u){var w,V,H=new f(32),ae=[j(),j(),j(),j()],te=[j(),j(),j(),j()];if(V=-1,_<64||P(te,u)||!N(L,32))return-1;for(w=0;w<_;++w)k[w]=L[w];for(w=0;w<32;++w)k[w+32]=u[w];var z=i(k,_);if(s(z),ee(ae,te,z),ne(te,L.subarray(32)),n(ae,te),U(H,ae),_-=64,G(L,0,H,0)){for(w=0;w<_;++w)k[w]=0;return-1}for(w=0;w<_;++w)k[w]=L[w+64];return V=_,V}function N(k,L){var _;for(_=31;_>=0;--_){if(k[L+_]<C[_])return!0;if(k[L+_]>C[_])return!1}return!1}function d(k,L){var _,u,w,V;for(u=63;u>=32;--u){for(_=0,w=u-32,V=u-12;w<V;++w)L[w]+=_-16*L[u]*C[w-(u-32)],_=L[w]+128>>8,L[w]-=_*256;L[w]+=_,L[u]=0}for(_=0,w=0;w<32;++w)L[w]+=_-(L[31]>>4)*C[w],_=L[w]>>8,L[w]&=255;for(w=0;w<32;++w)L[w]-=_*C[w];for(u=0;u<32;++u)L[u+1]+=L[u]>>8,k[u]=L[u]&255}function s(k){for(var L=new Float64Array(64),_=0;_<64;++_)L[_]=k[_],k[_]=0;d(k,L)}function n(k,L){var _=j(),u=j(),w=j(),V=j(),H=j(),ae=j(),te=j(),z=j(),Z=j();ze(_,k[1],k[0]),ze(Z,L[1],L[0]),T(_,_,Z),$(u,k[0],k[1]),$(Z,L[0],L[1]),T(u,u,Z),T(w,k[3],L[3]),T(w,w,x),T(V,k[2],L[2]),$(V,V,V),ze(H,u,_),ze(ae,V,w),$(te,V,w),$(z,u,_),T(k[0],H,ae),T(k[1],z,te),T(k[2],te,ae),T(k[3],H,z)}function B(k,L,_){for(var u=0;u<4;++u)le(k[u],L[u],_)}function U(k,L){var _=j(),u=j(),w=j();de(w,L[2]),T(_,L[0],w),T(u,L[1],w),O(k,u),k[31]^=X(_)<<7}function O(k,L){var _,u,w,V=j(),H=j();for(_=0;_<16;++_)H[_]=L[_];for(ge(H),ge(H),ge(H),u=0;u<2;++u){for(V[0]=H[0]-65517,_=1;_<15;++_)V[_]=H[_]-65535-(V[_-1]>>16&1),V[_-1]&=65535;V[15]=H[15]-32767-(V[14]>>16&1),w=V[15]>>16&1,V[14]&=65535,le(H,V,1-w)}for(_=0;_<16;_++)k[2*_]=H[_]&255,k[2*_+1]=H[_]>>8}function P(k,L){var _=j(),u=j(),w=j(),V=j(),H=j(),ae=j(),te=j();return ie(k[2],S),M(k[1],L),qe(w,k[1]),T(V,w,R),ze(w,w,k[2]),$(V,k[2],V),qe(H,V),qe(ae,H),T(te,ae,H),T(_,te,w),T(_,_,V),q(_,_),T(_,_,w),T(_,_,V),T(_,_,V),T(k[0],_,V),qe(u,k[0]),T(u,u,V),F(u,w)&&T(k[0],k[0],m),qe(u,k[0]),T(u,u,V),F(u,w)?-1:(X(k[0])===L[31]>>7&&ze(k[0],l,k[0]),T(k[3],k[0],k[1]),0)}function M(k,L){var _;for(_=0;_<16;++_)k[_]=L[2*_]+(L[2*_+1]<<8);k[15]&=32767}function q(k,L){var _=j(),u;for(u=0;u<16;++u)_[u]=L[u];for(u=250;u>=0;--u)qe(_,_),u!==1&&T(_,_,L);for(u=0;u<16;++u)k[u]=_[u]}function F(k,L){var _=new f(32),u=new f(32);return O(_,k),O(u,L),G(_,0,u,0)}function G(k,L,_,u){return W(k,L,_,u,32)}function W(k,L,_,u,w){var V,H=0;for(V=0;V<w;++V)H|=k[L+V]^_[u+V];return(1&H-1>>>8)-1}function X(k){var L=new f(32);return O(L,k),L[0]&1}function ee(k,L,_){var u,w;for(ie(k[0],l),ie(k[1],S),ie(k[2],S),ie(k[3],l),w=255;w>=0;--w)u=_[w/8|0]>>(w&7)&1,B(k,L,u),n(L,k),n(k,k),B(k,L,u)}function ne(k,L){var _=[j(),j(),j(),j()];ie(_[0],c),ie(_[1],g),ie(_[2],S),T(_[3],c,g),ee(k,_,L)}function ie(k,L){var _;for(_=0;_<16;_++)k[_]=L[_]|0}function de(k,L){var _=j(),u;for(u=0;u<16;++u)_[u]=L[u];for(u=253;u>=0;--u)qe(_,_),u!==2&&u!==4&&T(_,_,L);for(u=0;u<16;++u)k[u]=_[u]}function ge(k){var L,_,u=1;for(L=0;L<16;++L)_=k[L]+u+65535,u=Math.floor(_/65536),k[L]=_-u*65536;k[0]+=u-1+37*(u-1)}function le(k,L,_){for(var u,w=~(_-1),V=0;V<16;++V)u=w&(k[V]^L[V]),k[V]^=u,L[V]^=u}function j(k){var L,_=new Float64Array(16);if(k)for(L=0;L<k.length;++L)_[L]=k[L];return _}function $(k,L,_){for(var u=0;u<16;++u)k[u]=L[u]+_[u]}function ze(k,L,_){for(var u=0;u<16;++u)k[u]=L[u]-_[u]}function qe(k,L){T(k,L,L)}function T(k,L,_){var u,w,V=0,H=0,ae=0,te=0,z=0,Z=0,se=0,fe=0,oe=0,Ce=0,Te=0,Se=0,Ee=0,ye=0,ve=0,pe=0,Ie=0,Be=0,He=0,Ge=0,We=0,Ye=0,je=0,et=0,it=0,ot=0,dt=0,yt=0,Et=0,Lt=0,Yt=0,be=_[0],we=_[1],_e=_[2],Re=_[3],Ne=_[4],Le=_[5],ke=_[6],Ue=_[7],De=_[8],Pe=_[9],Ve=_[10],Oe=_[11],me=_[12],Ae=_[13],Me=_[14],Ke=_[15];u=L[0],V+=u*be,H+=u*we,ae+=u*_e,te+=u*Re,z+=u*Ne,Z+=u*Le,se+=u*ke,fe+=u*Ue,oe+=u*De,Ce+=u*Pe,Te+=u*Ve,Se+=u*Oe,Ee+=u*me,ye+=u*Ae,ve+=u*Me,pe+=u*Ke,u=L[1],H+=u*be,ae+=u*we,te+=u*_e,z+=u*Re,Z+=u*Ne,se+=u*Le,fe+=u*ke,oe+=u*Ue,Ce+=u*De,Te+=u*Pe,Se+=u*Ve,Ee+=u*Oe,ye+=u*me,ve+=u*Ae,pe+=u*Me,Ie+=u*Ke,u=L[2],ae+=u*be,te+=u*we,z+=u*_e,Z+=u*Re,se+=u*Ne,fe+=u*Le,oe+=u*ke,Ce+=u*Ue,Te+=u*De,Se+=u*Pe,Ee+=u*Ve,ye+=u*Oe,ve+=u*me,pe+=u*Ae,Ie+=u*Me,Be+=u*Ke,u=L[3],te+=u*be,z+=u*we,Z+=u*_e,se+=u*Re,fe+=u*Ne,oe+=u*Le,Ce+=u*ke,Te+=u*Ue,Se+=u*De,Ee+=u*Pe,ye+=u*Ve,ve+=u*Oe,pe+=u*me,Ie+=u*Ae,Be+=u*Me,He+=u*Ke,u=L[4],z+=u*be,Z+=u*we,se+=u*_e,fe+=u*Re,oe+=u*Ne,Ce+=u*Le,Te+=u*ke,Se+=u*Ue,Ee+=u*De,ye+=u*Pe,ve+=u*Ve,pe+=u*Oe,Ie+=u*me,Be+=u*Ae,He+=u*Me,Ge+=u*Ke,u=L[5],Z+=u*be,se+=u*we,fe+=u*_e,oe+=u*Re,Ce+=u*Ne,Te+=u*Le,Se+=u*ke,Ee+=u*Ue,ye+=u*De,ve+=u*Pe,pe+=u*Ve,Ie+=u*Oe,Be+=u*me,He+=u*Ae,Ge+=u*Me,We+=u*Ke,u=L[6],se+=u*be,fe+=u*we,oe+=u*_e,Ce+=u*Re,Te+=u*Ne,Se+=u*Le,Ee+=u*ke,ye+=u*Ue,ve+=u*De,pe+=u*Pe,Ie+=u*Ve,Be+=u*Oe,He+=u*me,Ge+=u*Ae,We+=u*Me,Ye+=u*Ke,u=L[7],fe+=u*be,oe+=u*we,Ce+=u*_e,Te+=u*Re,Se+=u*Ne,Ee+=u*Le,ye+=u*ke,ve+=u*Ue,pe+=u*De,Ie+=u*Pe,Be+=u*Ve,He+=u*Oe,Ge+=u*me,We+=u*Ae,Ye+=u*Me,je+=u*Ke,u=L[8],oe+=u*be,Ce+=u*we,Te+=u*_e,Se+=u*Re,Ee+=u*Ne,ye+=u*Le,ve+=u*ke,pe+=u*Ue,Ie+=u*De,Be+=u*Pe,He+=u*Ve,Ge+=u*Oe,We+=u*me,Ye+=u*Ae,je+=u*Me,et+=u*Ke,u=L[9],Ce+=u*be,Te+=u*we,Se+=u*_e,Ee+=u*Re,ye+=u*Ne,ve+=u*Le,pe+=u*ke,Ie+=u*Ue,Be+=u*De,He+=u*Pe,Ge+=u*Ve,We+=u*Oe,Ye+=u*me,je+=u*Ae,et+=u*Me,it+=u*Ke,u=L[10],Te+=u*be,Se+=u*we,Ee+=u*_e,ye+=u*Re,ve+=u*Ne,pe+=u*Le,Ie+=u*ke,Be+=u*Ue,He+=u*De,Ge+=u*Pe,We+=u*Ve,Ye+=u*Oe,je+=u*me,et+=u*Ae,it+=u*Me,ot+=u*Ke,u=L[11],Se+=u*be,Ee+=u*we,ye+=u*_e,ve+=u*Re,pe+=u*Ne,Ie+=u*Le,Be+=u*ke,He+=u*Ue,Ge+=u*De,We+=u*Pe,Ye+=u*Ve,je+=u*Oe,et+=u*me,it+=u*Ae,ot+=u*Me,dt+=u*Ke,u=L[12],Ee+=u*be,ye+=u*we,ve+=u*_e,pe+=u*Re,Ie+=u*Ne,Be+=u*Le,He+=u*ke,Ge+=u*Ue,We+=u*De,Ye+=u*Pe,je+=u*Ve,et+=u*Oe,it+=u*me,ot+=u*Ae,dt+=u*Me,yt+=u*Ke,u=L[13],ye+=u*be,ve+=u*we,pe+=u*_e,Ie+=u*Re,Be+=u*Ne,He+=u*Le,Ge+=u*ke,We+=u*Ue,Ye+=u*De,je+=u*Pe,et+=u*Ve,it+=u*Oe,ot+=u*me,dt+=u*Ae,yt+=u*Me,Et+=u*Ke,u=L[14],ve+=u*be,pe+=u*we,Ie+=u*_e,Be+=u*Re,He+=u*Ne,Ge+=u*Le,We+=u*ke,Ye+=u*Ue,je+=u*De,et+=u*Pe,it+=u*Ve,ot+=u*Oe,dt+=u*me,yt+=u*Ae,Et+=u*Me,Lt+=u*Ke,u=L[15],pe+=u*be,Ie+=u*we,Be+=u*_e,He+=u*Re,Ge+=u*Ne,We+=u*Le,Ye+=u*ke,je+=u*Ue,et+=u*De,it+=u*Pe,ot+=u*Ve,dt+=u*Oe,yt+=u*me,Et+=u*Ae,Lt+=u*Me,Yt+=u*Ke,V+=38*Ie,H+=38*Be,ae+=38*He,te+=38*Ge,z+=38*We,Z+=38*Ye,se+=38*je,fe+=38*et,oe+=38*it,Ce+=38*ot,Te+=38*dt,Se+=38*yt,Ee+=38*Et,ye+=38*Lt,ve+=38*Yt,w=1,u=V+w+65535,w=Math.floor(u/65536),V=u-w*65536,u=H+w+65535,w=Math.floor(u/65536),H=u-w*65536,u=ae+w+65535,w=Math.floor(u/65536),ae=u-w*65536,u=te+w+65535,w=Math.floor(u/65536),te=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=se+w+65535,w=Math.floor(u/65536),se=u-w*65536,u=fe+w+65535,w=Math.floor(u/65536),fe=u-w*65536,u=oe+w+65535,w=Math.floor(u/65536),oe=u-w*65536,u=Ce+w+65535,w=Math.floor(u/65536),Ce=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=Ee+w+65535,w=Math.floor(u/65536),Ee=u-w*65536,u=ye+w+65535,w=Math.floor(u/65536),ye=u-w*65536,u=ve+w+65535,w=Math.floor(u/65536),ve=u-w*65536,u=pe+w+65535,w=Math.floor(u/65536),pe=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=H+w+65535,w=Math.floor(u/65536),H=u-w*65536,u=ae+w+65535,w=Math.floor(u/65536),ae=u-w*65536,u=te+w+65535,w=Math.floor(u/65536),te=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=se+w+65535,w=Math.floor(u/65536),se=u-w*65536,u=fe+w+65535,w=Math.floor(u/65536),fe=u-w*65536,u=oe+w+65535,w=Math.floor(u/65536),oe=u-w*65536,u=Ce+w+65535,w=Math.floor(u/65536),Ce=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=Ee+w+65535,w=Math.floor(u/65536),Ee=u-w*65536,u=ye+w+65535,w=Math.floor(u/65536),ye=u-w*65536,u=ve+w+65535,w=Math.floor(u/65536),ve=u-w*65536,u=pe+w+65535,w=Math.floor(u/65536),pe=u-w*65536,V+=w-1+37*(w-1),k[0]=V,k[1]=H,k[2]=ae,k[3]=te,k[4]=z,k[5]=Z,k[6]=se,k[7]=fe,k[8]=oe,k[9]=Ce,k[10]=Te,k[11]=Se,k[12]=Ee,k[13]=ye,k[14]=ve,k[15]=pe}return Gr}var zr,un;function gi(){if(un)return zr;un=1;var t=ue();ce(),Je(),Ht(),zr=t.kem=t.kem||{};var e=t.jsbn.BigInteger;t.kem.rsa={},t.kem.rsa.create=function(o,E){E=E||{};var y=E.prng||t.random,f={};return f.encrypt=function(a,p){var l=Math.ceil(a.n.bitLength()/8),S;do S=new e(t.util.bytesToHex(y.getBytesSync(l)),16).mod(a.n);while(S.compareTo(e.ONE)<=0);S=t.util.hexToBytes(S.toString(16));var R=l-S.length;R>0&&(S=t.util.fillString("\0",R)+S);var x=a.encrypt(S,"NONE"),c=o.generate(S,p);return{encapsulation:x,key:c}},f.decrypt=function(a,p,l){var S=a.decrypt(p,"NONE");return o.generate(S,l)},f},t.kem.kdf1=function(o,E){r(this,o,0,E||o.digestLength)},t.kem.kdf2=function(o,E){r(this,o,1,E||o.digestLength)};function r(o,E,y,f){o.generate=function(a,p){for(var l=new t.util.ByteBuffer,S=Math.ceil(p/f)+y,R=new t.util.ByteBuffer,x=y;x<S;++x){R.putInt32(x),E.start(),E.update(a+R.getBytes());var c=E.digest();l.putBytes(c.getBytes(f))}return l.truncate(l.length()-p),l.getBytes()}}return zr}var Qr,ln;function vi(){if(ln)return Qr;ln=1;var t=ue();ce(),Qr=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 E=0;E<t.log.levels.length;++E){var y=t.log.levels[E];e[y]={index:E,name:y.toUpperCase()}}t.log.logMessage=function(x){for(var c=e[x.level].index,g=0;g<r.length;++g){var C=r[g];if(C.flags&t.log.NO_LEVEL_CHECK)C.f(x);else{var m=e[C.level].index;c<=m&&C.f(C,x)}}},t.log.prepareStandard=function(x){"standard"in x||(x.standard=e[x.level].name+" ["+x.category+"] "+x.message)},t.log.prepareFull=function(x){if(!("full"in x)){var c=[x.message];c=c.concat([]),x.full=t.util.format.apply(this,c)}},t.log.prepareStandardFull=function(x){"standardFull"in x||(t.log.prepareStandard(x),x.standardFull=x.standard)};for(var f=["error","warning","info","debug","verbose"],E=0;E<f.length;++E)(function(c){t.log[c]=function(g,C){var m=Array.prototype.slice.call(arguments).slice(2),i={timestamp:new Date,level:c,category:g,message:C,arguments:m};t.log.logMessage(i)}})(f[E]);if(t.log.makeLogger=function(x){var c={flags:0,f:x};return t.log.setLevel(c,"none"),c},t.log.setLevel=function(x,c){var g=!1;if(x&&!(x.flags&t.log.LEVEL_LOCKED))for(var C=0;C<t.log.levels.length;++C){var m=t.log.levels[C];if(c==m){x.level=c,g=!0;break}}return g},t.log.lock=function(x,c){typeof c>"u"||c?x.flags|=t.log.LEVEL_LOCKED:x.flags&=~t.log.LEVEL_LOCKED},t.log.addLogger=function(x){r.push(x)},typeof console<"u"&&"log"in console){var a;if(console.error&&console.warn&&console.info&&console.debug){var p={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},l=function(x,c){t.log.prepareStandard(c);var g=p[c.level],C=[c.standard];C=C.concat(c.arguments.slice()),g.apply(console,C)};a=t.log.makeLogger(l)}else{var l=function(c,g){t.log.prepareStandardFull(g),console.log(g.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 S=new URL(window.location.href).searchParams;if(S.has("console.level")&&t.log.setLevel(o,S.get("console.level").slice(-1)[0]),S.has("console.lock")){var R=S.get("console.lock").slice(-1)[0];R=="true"&&t.log.lock(o)}}return t.log.consoleLogger=o,Qr}var Wr,fn;function yi(){return fn||(fn=1,Wr=st(),Cr(),Nt(),wa(),nn()),Wr}var Yr={exports:{}},cn;function mi(){if(cn)return Yr.exports;cn=1;var t=ue();gt(),nt(),Ft(),vt(),Ct(),Ga(),Je(),ce(),Fr();var e=t.asn1,r=Yr.exports=t.pkcs7=t.pkcs7||{};r.messageFromPem=function(c){var g=t.pem.decode(c)[0];if(g.type!=="PKCS7"){var C=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw C.headerType=g.type,C}if(g.procType&&g.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var m=e.fromDer(g.body);return r.messageFromAsn1(m)},r.messageToPem=function(c,g){var C={type:"PKCS7",body:e.toDer(c.toAsn1()).getBytes()};return t.pem.encode(C,{maxline:g})},r.messageFromAsn1=function(c){var g={},C=[];if(!e.validate(c,r.asn1.contentInfoValidator,g,C)){var m=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw m.errors=C,m}var i=e.derToOid(g.contentType),h;switch(i){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 "+i+" is not (yet) supported.")}return h.fromAsn1(g.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(m){if(R(c,m,r.asn1.signedDataValidator),c.certificates=[],c.crls=[],c.digestAlgorithmIdentifiers=[],c.contentInfo=null,c.signerInfos=[],c.rawCapture.certificates)for(var i=c.rawCapture.certificates.value,h=0;h<i.length;++h)c.certificates.push(t.pki.certificateFromAsn1(i[h]))},toAsn1:function(){c.contentInfo||c.sign();for(var m=[],i=0;i<c.certificates.length;++i)m.push(t.pki.certificateToAsn1(c.certificates[i]));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 m.length>0&&v.value[0].value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,m)),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(m){var i=m.issuer,h=m.serialNumber;if(m.certificate){var v=m.certificate;typeof v=="string"&&(v=t.pki.certificateFromPem(v)),i=v.issuer.attributes,h=v.serialNumber}var I=m.key;if(!I)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof I=="string"&&(I=t.pki.privateKeyFromPem(I));var N=m.digestAlgorithm||t.pki.oids.sha1;switch(N){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: "+N)}var d=m.authenticatedAttributes||[];if(d.length>0){for(var s=!1,n=!1,B=0;B<d.length;++B){var U=d[B];if(!s&&U.type===t.pki.oids.contentType){if(s=!0,n)break;continue}if(!n&&U.type===t.pki.oids.messageDigest){if(n=!0,s)break;continue}}if(!s||!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:I,version:1,issuer:i,serialNumber:h,digestAlgorithm:N,signatureAlgorithm:t.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:d,unauthenticatedAttributes:[]})},sign:function(m){if(m=m||{},(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 i;c.content instanceof t.util.ByteBuffer?i=c.content.bytes():typeof c.content=="string"&&(i=t.util.encodeUtf8(c.content)),m.detached?c.detachedContent=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,i):c.contentInfo.value.push(e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,i)]))}if(c.signers.length!==0){var h=g();C(h)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(m){typeof m=="string"&&(m=t.pki.certificateFromPem(m)),c.certificates.push(m)},addCertificateRevokationList:function(m){throw new Error("PKCS#7 CRL support not yet implemented.")}},c;function g(){for(var m={},i=0;i<c.signers.length;++i){var h=c.signers[i],v=h.digestAlgorithm;v in m||(m[v]=t.md[t.pki.oids[v]].create()),h.authenticatedAttributes.length===0?h.md=m[v]:h.md=t.md[t.pki.oids[v]].create()}c.digestAlgorithmIdentifiers=[];for(var v in m)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 m}function C(m){var i;if(c.detachedContent?i=c.detachedContent:(i=c.contentInfo.value[1],i=i.value[0]),!i)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(i);v.getByte(),e.getBerValueLength(v),v=v.getBytes();for(var I in m)m[I].start().update(v);for(var N=new Date,d=0;d<c.signers.length;++d){var s=c.signers[d];if(s.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{s.authenticatedAttributesAsn1=e.create(e.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var n=e.create(e.Class.UNIVERSAL,e.Type.SET,!0,[]),B=0;B<s.authenticatedAttributes.length;++B){var U=s.authenticatedAttributes[B];U.type===t.pki.oids.messageDigest?U.value=m[s.digestAlgorithm].digest():U.type===t.pki.oids.signingTime&&(U.value||(U.value=N)),n.value.push(l(U)),s.authenticatedAttributesAsn1.value.push(l(U))}v=e.toDer(n).getBytes(),s.md.start().update(v)}s.signature=s.key.sign(s.md,"RSASSA-PKCS1-V1_5")}c.signerInfos=p(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(g){R(c,g,r.asn1.encryptedDataValidator)},decrypt:function(g){g!==void 0&&(c.encryptedContent.key=g),x(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(g){var C=R(c,g,r.asn1.envelopedDataValidator);c.recipients=y(C.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,S(c.encryptedContent))])])])},findRecipient:function(g){for(var C=g.issuer.attributes,m=0;m<c.recipients.length;++m){var i=c.recipients[m],h=i.issuer;if(i.serialNumber===g.serialNumber&&h.length===C.length){for(var v=!0,I=0;I<C.length;++I)if(h[I].type!==C[I].type||h[I].value!==C[I].value){v=!1;break}if(v)return i}}return null},decrypt:function(g,C){if(c.encryptedContent.key===void 0&&g!==void 0&&C!==void 0)switch(g.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:case t.pki.oids.desCBC:var m=C.decrypt(g.encryptedContent.content);c.encryptedContent.key=t.util.createBuffer(m);break;default:throw new Error("Unsupported asymmetric cipher, OID "+g.encryptedContent.algorithm)}x(c)},addRecipient:function(g){c.recipients.push({version:0,issuer:g.issuer.attributes,serialNumber:g.serialNumber,encryptedContent:{algorithm:t.pki.oids.rsaEncryption,key:g.publicKey}})},encrypt:function(g,C){if(c.encryptedContent.content===void 0){C=C||c.encryptedContent.algorithm,g=g||c.encryptedContent.key;var m,i,h;switch(C){case t.pki.oids["aes128-CBC"]:m=16,i=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes192-CBC"]:m=24,i=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["aes256-CBC"]:m=32,i=16,h=t.aes.createEncryptionCipher;break;case t.pki.oids["des-EDE3-CBC"]:m=24,i=8,h=t.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+C)}if(g===void 0)g=t.util.createBuffer(t.random.getBytes(m));else if(g.length()!=m)throw new Error("Symmetric key has wrong length; got "+g.length()+" bytes, expected "+m+".");c.encryptedContent.algorithm=C,c.encryptedContent.key=g,c.encryptedContent.parameter=t.util.createBuffer(t.random.getBytes(i));var v=h(g);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 I=0;I<c.recipients.length;++I){var N=c.recipients[I];if(N.encryptedContent.content===void 0)switch(N.encryptedContent.algorithm){case t.pki.oids.rsaEncryption:N.encryptedContent.content=N.encryptedContent.key.encrypt(c.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+N.encryptedContent.algorithm)}}}},c};function o(c){var g={},C=[];if(!e.validate(c,r.asn1.recipientInfoValidator,g,C)){var m=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw m.errors=C,m}return{version:g.version.charCodeAt(0),issuer:t.pki.RDNAttributesAsArray(g.issuer),serialNumber:t.util.createBuffer(g.serial).toHex(),encryptedContent:{algorithm:e.derToOid(g.encAlgorithm),parameter:g.encParameter?g.encParameter.value:void 0,content:g.encKey}}}function E(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 g=[],C=0;C<c.length;++C)g.push(o(c[C]));return g}function f(c){for(var g=[],C=0;C<c.length;++C)g.push(E(c[C]));return g}function a(c){var g=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&&g.value.push(c.authenticatedAttributesAsn1),g.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,"")])),g.value.push(e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.signature)),c.unauthenticatedAttributes.length>0){for(var C=e.create(e.Class.CONTEXT_SPECIFIC,1,!0,[]),m=0;m<c.unauthenticatedAttributes.length;++m){var i=c.unauthenticatedAttributes[m];C.values.push(l(i))}g.value.push(C)}return g}function p(c){for(var g=[],C=0;C<c.length;++C)g.push(a(c[C]));return g}function l(c){var g;if(c.type===t.pki.oids.contentType)g=e.create(e.Class.UNIVERSAL,e.Type.OID,!1,e.oidToDer(c.value).getBytes());else if(c.type===t.pki.oids.messageDigest)g=e.create(e.Class.UNIVERSAL,e.Type.OCTETSTRING,!1,c.value.bytes());else if(c.type===t.pki.oids.signingTime){var C=new Date("1950-01-01T00:00:00Z"),m=new Date("2050-01-01T00:00:00Z"),i=c.value;if(typeof i=="string"){var h=Date.parse(i);isNaN(h)?i.length===13?i=e.utcTimeToDate(i):i=e.generalizedTimeToDate(i):i=new Date(h)}i>=C&&i<m?g=e.create(e.Class.UNIVERSAL,e.Type.UTCTIME,!1,e.dateToUtcTime(i)):g=e.create(e.Class.UNIVERSAL,e.Type.GENERALIZEDTIME,!1,e.dateToGeneralizedTime(i))}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,[g])])}function S(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 R(c,g,C){var m={},i=[];if(!e.validate(g,C,m,i)){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(m.contentType);if(v!==t.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(m.encryptedContent){var I="";if(t.util.isArray(m.encryptedContent))for(var N=0;N<m.encryptedContent.length;++N){if(m.encryptedContent[N].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");I+=m.encryptedContent[N].value}else I=m.encryptedContent;c.encryptedContent={algorithm:e.derToOid(m.encAlgorithm),parameter:t.util.createBuffer(m.encParameter.value),content:t.util.createBuffer(I)}}if(m.content){var I="";if(t.util.isArray(m.content))for(var N=0;N<m.content.length;++N){if(m.content[N].type!==e.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");I+=m.content[N].value}else I=m.content;c.content=t.util.createBuffer(I)}return c.version=m.version.charCodeAt(0),c.rawCapture=m,m}function x(c){if(c.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(c.content===void 0){var g;switch(c.encryptedContent.algorithm){case t.pki.oids["aes128-CBC"]:case t.pki.oids["aes192-CBC"]:case t.pki.oids["aes256-CBC"]:g=t.aes.createDecryptionCipher(c.encryptedContent.key);break;case t.pki.oids.desCBC:case t.pki.oids["des-EDE3-CBC"]:g=t.des.createDecryptionCipher(c.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+c.encryptedContent.algorithm)}if(g.start(c.encryptedContent.parameter),g.update(c.encryptedContent.content),!g.finish())throw new Error("Symmetric decryption failed.");c.content=g.output}}return Yr.exports}var Xr={exports:{}},dn;function Ci(){if(dn)return Xr.exports;dn=1;var t=ue();gt(),Rt(),Cr(),Nt(),ce();var e=Xr.exports=t.ssh=t.ssh||{};e.privateKeyToPutty=function(y,f,a){a=a||"",f=f||"";var p="ssh-rsa",l=f===""?"none":"aes256-cbc",S="PuTTY-User-Key-File-2: "+p+`\r
15
+ `;S+="Encryption: "+l+`\r
16
+ `,S+="Comment: "+a+`\r
17
+ `;var R=t.util.createBuffer();o(R,p),r(R,y.e),r(R,y.n);var x=t.util.encode64(R.bytes(),64),c=Math.floor(x.length/66)+1;S+="Public-Lines: "+c+`\r
18
+ `,S+=x;var g=t.util.createBuffer();r(g,y.d),r(g,y.p),r(g,y.q),r(g,y.qInv);var C;if(!f)C=t.util.encode64(g.bytes(),64);else{var m=g.length()+16-1;m-=m%16;var i=E(g.bytes());i.truncate(i.length()-m+g.length()),g.putBuffer(i);var h=t.util.createBuffer();h.putBuffer(E("\0\0\0\0",f)),h.putBuffer(E("\0\0\0",f));var v=t.aes.createEncryptionCipher(h.truncate(8),"CBC");v.start(t.util.createBuffer().fillWithByte(0,16)),v.update(g.copy()),v.finish();var I=v.output;I.truncate(16),C=t.util.encode64(I.bytes(),64)}c=Math.floor(C.length/66)+1,S+=`\r
19
+ Private-Lines: `+c+`\r
20
+ `,S+=C;var N=E("putty-private-key-file-mac-key",f),d=t.util.createBuffer();o(d,p),o(d,l),o(d,a),d.putInt32(R.length()),d.putBuffer(R),d.putInt32(g.length()),d.putBuffer(g);var s=t.hmac.create();return s.start("sha1",N),s.update(d.bytes()),S+=`\r
21
+ Private-MAC: `+s.digest().toHex()+`\r
22
+ `,S},e.publicKeyToOpenSSH=function(y,f){var a="ssh-rsa";f=f||"";var p=t.util.createBuffer();return o(p,a),r(p,y.e),r(p,y.n),a+" "+t.util.encode64(p.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(),p="ssh-rsa",l=t.util.createBuffer();o(l,p),r(l,y.e),r(l,y.n),a.start(),a.update(l.getBytes());var S=a.digest();if(f.encoding==="hex"){var R=S.toHex();return f.delimiter?R.match(/.{2}/g).join(f.delimiter):R}else{if(f.encoding==="binary")return S.getBytes();if(f.encoding)throw new Error('Unknown encoding "'+f.encoding+'".')}return S};function r(y,f){var a=f.toString(16);a[0]>="8"&&(a="00"+a);var p=t.util.hexToBytes(a);y.putInt32(p.length),y.putBytes(p)}function o(y,f){y.putInt32(f.length),y.putString(f)}function E(){for(var y=t.md.sha1.create(),f=arguments.length,a=0;a<f;++a)y.update(arguments[a]);return y.digest()}return Xr.exports}var jr,hn;function Ei(){return hn||(hn=1,jr=ue(),gt(),di(),nt(),fr(),Ft(),pi(),Rt(),gi(),vi(),yi(),Qa(),Ir(),Ct(),Va(),$a(),mi(),Ja(),Ma(),Ra(),Kr(),Je(),ka(),Ci(),tn(),ce()),jr}var $r=Ei();const xi="evtrsa1",Zr=new Map;function pn(t){return t.replace(/\/+$/,"")}function Si(t){return new TextEncoder().encode(t)}function Wt(t){let e="";return t.forEach(r=>{e+=String.fromCharCode(r)}),btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}async function Ti(t,e){const r=typeof AbortController<"u"?new AbortController:void 0,o=r?setTimeout(()=>r.abort(),e):void 0;try{const E=await fetch(t,{method:"GET",headers:{Accept:"application/json"},signal:r?.signal}),y=await E.json().catch(()=>({}));if(!E.ok){const f=y?.error?.message??y?.message??`ViewToken public key request failed with status ${E.status}`;throw new Error(f)}return y}finally{o!=null&&clearTimeout(o)}}function Jr(t){const e=globalThis.crypto;if(!e?.getRandomValues)throw new Error("[BimEngine] crypto.getRandomValues is required to encrypt viewToken");return e.getRandomValues(new Uint8Array(t))}function Ai(t){let e="";return t.forEach(r=>{e+=String.fromCharCode(r)}),e}function Ii(t){const e=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)e[r]=t.charCodeAt(r)&255;return e}async function Bi(t,e){const r=`${pn(t)}/models/view-token/public-key`,o=await Ti(r,e);if(o.algorithm!=="RSA-OAEP-256"||!o.publicKey)throw new Error("[BimEngine] OpenAPI returned an invalid viewToken public key");return $r.pki.publicKeyFromPem(o.publicKey)}function bi(t,e){const r=pn(t),o=Zr.get(r);if(o)return o;const E=Bi(t,e).catch(y=>{throw Zr.delete(r),y});return Zr.set(r,E),E}async function wi(t,e,r){const o=await bi(t,r),E=Jr(32),y=Jr(12),f=Jr(16),a=JSON.stringify({viewToken:e,timestamp:Date.now(),nonce:Wt(f)}),p=o.encrypt(Ai(E),"RSA-OAEP",{md:$r.md.sha256.create(),mgf1:{md:$r.md.sha256.create()}}),l=oi(E,y).encrypt(Si(a));return[xi,Wt(Ii(p)),Wt(y),Wt(l)].join(".")}function _i(t){return t.replace(/\/+$/,"")}async function Ri(t,e,r){const o=typeof AbortController<"u"?new AbortController:void 0,E=o?setTimeout(()=>o.abort(),r):void 0;try{const y=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?.signal}),f=await y.json().catch(()=>({}));if(!y.ok){const a=f?.error?.message??f?.message??`ViewToken resolve failed with status ${y.status}`;throw new Error(a)}return f}finally{E!=null&&clearTimeout(E)}}function Ni(t){switch(t){case"2d":return"cad_model";case"720":return"panorama";case"gis":return"gis_scene";case"gaussian":return"gaussian_model";case"3d":default:return"model"}}function Li(t){return{models:[{modelType:t.toLowerCase().endsWith(".json")?"3dtiles":"glb",url:t}]}}function ki(t,e){return{applicationId:0,engineType:e,assetCategory:Ni(e),url:t,urls:[t],info:e==="gis"?Li(t):void 0}}async function Ui(t,e,r){const o=t?.sdkAuth;if(!o?.endpoint)return ki(e,r);let E;(o.token||o.appId&&o.appKey&&o.appSecret)&&(E=(await Mn(t,r))?.sdkToken);const f={viewToken:await wi(o.endpoint,e,o.timeoutMs??8e3),engineType:r};return E&&(f.sdkToken=E),Ri(`${_i(o.endpoint)}/models/view-token/resolve`,f,o.timeoutMs??8e3)}class gn{eventModule;sceneModule;cameraModule;renderModule;controlModule;loaderModule;isInitialized=!1;options;version=Tt;constructor(e){this.options=e,this.initialize(e)}initialize(e){const r={containerId:e.containerId,cameraUp:e.cameraUp??[0,1,0],initialCameraPosition:e.initialCameraPosition??[0,0,6],initialCameraLookAt:e.initialCameraLookAt??[0,0,0],backgroundColor:e.backgroundColor,antialias:e.antialias??!1,showLoadingUI:e.showLoadingUI??!0,sharedMemoryForWorkers:e.sharedMemoryForWorkers??!1,gpuAcceleratedSort:e.gpuAcceleratedSort??!1,sphericalHarmonicsDegree:e.sphericalHarmonicsDegree??0,orientationPreset:e.orientationPreset??"x180",viewerOptions:e.viewerOptions},o=document.getElementById(r.containerId);if(!o)throw new Error(`Container with id "${r.containerId}" not found`);this.eventModule=new yn,this.sceneModule=new mn(r.backgroundColor),this.cameraModule=new Cn(o,r.cameraUp,r.initialCameraPosition,r.initialCameraLookAt),this.controlModule=new wn(r.orientationPreset),this.renderModule=new Bn(o,this.sceneModule.getScene(),this.cameraModule.getCamera(),r),this.loaderModule=new Rn(this.renderModule.getViewer(),()=>this.controlModule.getOrientationRotation()),this.renderModule.setOnBeforeRender(()=>{this.controlModule.update()}),this.renderModule.setOnFpsUpdated(E=>{this.eventModule.trigger(ft.FpsUpdated,E)}),this.renderModule.startRenderLoop(),this.isInitialized=!0}async loadModel(e,r={}){this.checkInitialized(),this.eventModule.trigger(ft.LoadStart,{url:e,name:r.name});try{const o=await this.loaderModule.loadModel(e,{showLoadingUI:!0,...r,onProgress:(E,y,f)=>{this.eventModule.trigger(ft.LoadProgress,{url:e,name:r.name,progress:E}),r.onProgress?.(E,y,f)}});return this.eventModule.trigger(ft.Loaded,{url:e,name:o.name,progress:100}),o}catch(o){throw this.eventModule.trigger(ft.LoadError,{url:e,name:r.name,error:o instanceof Error?o:new Error(String(o))}),o}}async loadModelByViewToken(e,r={}){const o=await Ui(this.options,e,"gaussian");if(o.assetCategory==="composite_model"&&o.urls.length>1)throw new Error("EngineKernelGaussian: composite_model viewToken is not supported");return this.loadModel(o.url,r)}async unloadModel(e){this.checkInitialized(),await this.loaderModule.unloadModel(e,!1),this.eventModule.trigger(ft.SceneRemoved,{id:e})}setOrientationPreset(e){this.checkInitialized(),this.controlModule.setOrientationPreset(e)}getOrientationPreset(){return this.checkInitialized(),this.controlModule.getOrientationPreset()}resize(e,r){this.checkInitialized();const o=this.renderModule.getDomElement(),E=e??o.parentElement?.clientWidth??o.clientWidth,y=r??o.parentElement?.clientHeight??o.clientHeight;this.renderModule.resize(E,y),this.cameraModule.updateAspectRatio(E,y)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering()}resetFpsStats(){this.checkInitialized(),this.renderModule.resetFpsStats()}getFpsInfo(){return this.checkInitialized(),this.renderModule.getFpsInfo()}on(e,r){this.checkInitialized(),this.eventModule.on(e,r)}off(e,r){this.checkInitialized(),this.eventModule.off(e,r)}getVersion(){return this.version}async dispose(){this.isInitialized&&(await this.loaderModule.clear(!1),await this.renderModule.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1)}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernelGaussian: Not initialized")}}function Di(t){return new gn(t)}Ze.GaussianSplats3D=ra,Ze.EngineKernelGaussian=gn,Ze.EventTypeGaussian=ft,Ze.createEngineGaussian=Di,Object.defineProperty(Ze,Symbol.toStringTag,{value:"Module"})}));