@realsee/five 5.0.0-alpha.171 → 5.0.0-alpha.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/assets/search.js +1 -1
- package/docs/classes/five.AnimationFrameLoop.html +1 -1
- package/docs/classes/five.BVH.html +1 -1
- package/docs/classes/five.BVHIntersect.html +1 -1
- package/docs/classes/five.BVHNode.html +1 -1
- package/docs/classes/five.BVHVector3.html +1 -1
- package/docs/classes/five.Camera.html +1 -1
- package/docs/classes/five.Clipper.html +1 -1
- package/docs/classes/five.Five.html +12 -12
- package/docs/classes/five.InternalWebGLRenderer.html +1 -1
- package/docs/classes/five.IntersectMesh.html +1 -1
- package/docs/classes/five.Model.html +1 -1
- package/docs/classes/five.NetworkSubscribe.html +1 -1
- package/docs/classes/five.PBMContainer.html +1 -1
- package/docs/classes/five.PBMGroup.html +1 -1
- package/docs/classes/five.PBMMaterial.html +1 -1
- package/docs/classes/five.PBMMesh.html +1 -1
- package/docs/classes/five.PanoCircleMesh.html +1 -1
- package/docs/classes/five.PanoCircleMeshCustom.html +1 -1
- package/docs/classes/five.PanoCircleMeshSolid.html +1 -1
- package/docs/classes/five.Scene.html +1 -1
- package/docs/classes/five.Subscribe.html +1 -1
- package/docs/classes/five.TextureLoader.html +1 -1
- package/docs/classes/five.Tile3D.html +1 -1
- package/docs/classes/five.Tile3DModel.html +1 -1
- package/docs/classes/five.TileBoundingSphere.html +1 -1
- package/docs/classes/five.TileCacheNode.html +1 -1
- package/docs/classes/five.TileCubeTextureTarget.html +1 -1
- package/docs/classes/five.TileCullingVolume.html +1 -1
- package/docs/classes/five.TileOrientedBoundingBox.html +1 -1
- package/docs/classes/five.TileRequestScheduler.html +1 -1
- package/docs/classes/five.Tileset3D.html +1 -1
- package/docs/classes/five.Tileset3DTraverser.html +1 -1
- package/docs/classes/five.TilesetCache.html +1 -1
- package/docs/classes/five.Work.html +7 -5
- package/docs/classes/five.XRButton.html +1 -1
- package/docs/classes/gltf_loader.DDSLoader.html +1 -1
- package/docs/classes/gltf_loader.DRACOLoader.html +1 -1
- package/docs/classes/gltf_loader.GLTFLoader.html +1 -1
- package/docs/classes/gltf_loader.GLTFObject.html +1 -1
- package/docs/classes/gltf_loader.GLTFParser.html +1 -1
- package/docs/classes/gltf_loader.THREEGLTFLoader.html +1 -1
- package/docs/classes/line.Line.html +1 -1
- package/docs/classes/line.LineGeometry.html +1 -1
- package/docs/classes/line.LineMaterial.html +1 -1
- package/docs/classes/line.LineSegmentsGeometry.html +1 -1
- package/docs/classes/line.THREE_Line2.html +1 -1
- package/docs/classes/line.THREE_LineSegments2.html +1 -1
- package/docs/classes/react.Store.html +1 -1
- package/docs/classes/server.BVH.html +1 -1
- package/docs/classes/server.BVHIntersect.html +1 -1
- package/docs/classes/server.BVHNode.html +1 -1
- package/docs/classes/server.BVHVector3.html +1 -1
- package/docs/classes/server.Model.html +1 -1
- package/docs/classes/server.PBMContainer.html +1 -1
- package/docs/classes/server.PBMGroup.html +1 -1
- package/docs/classes/server.PBMMesh.html +1 -1
- package/docs/classes/sticker.Sticker.html +1 -1
- package/docs/classes/vfx.Airflow.html +1 -1
- package/docs/classes/vfx.Flame.html +1 -1
- package/docs/classes/vfx.Particle.html +1 -1
- package/docs/classes/vfx.SpotLight.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/five.AddableObject.html +9 -1
- package/docs/interfaces/five.AnimationFrame.html +1 -1
- package/docs/interfaces/five.CameraPose.html +1 -1
- package/docs/interfaces/five.ClipperParameter.html +1 -1
- package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.EventCallback.html +1 -1
- package/docs/interfaces/five.FiveInitArgs.html +1 -1
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ImageOptions.html +1 -1
- package/docs/interfaces/five.ImageURLMappings.html +1 -1
- package/docs/interfaces/five.ImageURLOptions.html +1 -1
- package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
- package/docs/interfaces/five.Intersection.html +1 -1
- package/docs/interfaces/five.MapviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.ModelEventCallback.html +1 -1
- package/docs/interfaces/five.MotionKeyframe.html +1 -1
- package/docs/interfaces/five.MovePanoOptions.html +1 -1
- package/docs/interfaces/five.NetworkOptions.html +1 -1
- package/docs/interfaces/five.PBMPanoPicture.html +1 -1
- package/docs/interfaces/five.PBMParameters.html +1 -1
- package/docs/interfaces/five.PanoCircleMeshCustomOptions.html +1 -1
- package/docs/interfaces/five.PanoCircleMeshInterface.html +1 -1
- package/docs/interfaces/five.PanoCircleMeshOptions.html +1 -1
- package/docs/interfaces/five.PanoCircleMeshSolidOptions.html +1 -1
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +6 -6
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.Pose.html +1 -1
- package/docs/interfaces/five.Scissor.html +1 -1
- package/docs/interfaces/five.State.html +1 -1
- package/docs/interfaces/five.SubscribeMixinType.emit.html +1 -1
- package/docs/interfaces/five.SubscribeMixinType.hasListener.html +1 -1
- package/docs/interfaces/five.SubscribeMixinType.off.html +1 -1
- package/docs/interfaces/five.SubscribeMixinType.on.html +1 -1
- package/docs/interfaces/five.SubscribeMixinType.once.html +1 -1
- package/docs/interfaces/five.TextureOptions.html +1 -1
- package/docs/interfaces/five.Tile3DModelLoaderOptions.html +1 -1
- package/docs/interfaces/five.TileBoundingVolume.html +1 -1
- package/docs/interfaces/five.TileContent.html +1 -1
- package/docs/interfaces/five.TileCubeNode.html +1 -1
- package/docs/interfaces/five.TileCubeTree.html +1 -1
- package/docs/interfaces/five.Tileset3dOptions.html +1 -1
- package/docs/interfaces/five.TilesetJSON.html +1 -1
- package/docs/interfaces/five.TilesetJSONNode.html +1 -1
- package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +1 -1
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +6 -6
- package/docs/interfaces/five.WebXRSelectParams.html +1 -1
- package/docs/interfaces/five.WorkCubeImage.html +1 -1
- package/docs/interfaces/five.WorkImage.html +1 -1
- package/docs/interfaces/five.WorkInitial.html +1 -1
- package/docs/interfaces/five.WorkModel.html +1 -1
- package/docs/interfaces/five.WorkModelTiles.html +1 -1
- package/docs/interfaces/five.WorkObserver.html +1 -1
- package/docs/interfaces/five.WorkTile.html +1 -1
- package/docs/interfaces/five.WorkVideo.html +1 -1
- package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +6 -6
- package/docs/interfaces/gltf_loader.DDS.html +1 -1
- package/docs/interfaces/gltf_loader.GLTF.html +1 -1
- package/docs/interfaces/gltf_loader.GLTFReference.html +1 -1
- package/docs/interfaces/gltf_loader.THREEGLTF.html +1 -1
- package/docs/interfaces/react.FiveActionReactCallbacks.html +1 -1
- package/docs/interfaces/react.FiveInjectionTypes.html +1 -1
- package/docs/interfaces/react.PropTypeOfFiveFeatures.html +1 -1
- package/docs/interfaces/server.Intersection.html +1 -1
- package/docs/interfaces/server.ModelEventCallback.html +1 -1
- package/docs/interfaces/sticker.IntersectionLike.html +1 -1
- package/docs/interfaces/vfx.ParticleArgs.html +1 -1
- package/docs/interfaces/vfx.ParticleTweenKeyframe.html +1 -1
- package/docs/interfaces/vue.FiveActionVueCallbacks.html +1 -1
- package/docs/modules/five.SubscribeMixinType.html +1 -1
- package/docs/modules/five.html +2 -2
- package/docs/modules/gltf_loader.html +1 -1
- package/docs/modules/line.html +1 -1
- package/docs/modules/react.html +1 -1
- package/docs/modules/server.html +1 -1
- package/docs/modules/sticker.html +1 -1
- package/docs/modules/vfx.html +1 -1
- package/docs/modules/vue.html +1 -1
- package/docs/modules.html +1 -1
- package/five/index.d.ts +6 -0
- package/five/index.js +6 -6
- package/gltf-loader/index.js +3 -3
- package/line/index.js +3 -3
- package/package.json +1 -1
- package/react/index.js +2 -2
- package/server/index.d.ts +2 -0
- package/server/index.js +7 -7
- package/sticker/index.js +3 -3
- package/umd/five-gltf-loader.js +1 -1
- package/umd/five-line.js +1 -1
- package/umd/five-sticker.js +1 -1
- package/umd/five.js +1 -1
- package/vfx/index.js +2 -2
- package/vue/index.js +2 -2
package/server/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @realsee/five
|
|
3
3
|
*
|
|
4
|
-
* Generated: 2022-12-
|
|
5
|
-
* Version: 5.0.0-alpha.
|
|
4
|
+
* Generated: 2022-12-16
|
|
5
|
+
* Version: 5.0.0-alpha.173
|
|
6
6
|
*
|
|
7
7
|
* Terms:
|
|
8
8
|
* Realsee SDK License Agreement
|
|
@@ -354,14 +354,14 @@ Code licensed under the BSD License:
|
|
|
354
354
|
http://developer.yahoo.com/yui/license.html
|
|
355
355
|
version: 2.9.0
|
|
356
356
|
*/
|
|
357
|
-
p.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var i;for(i in r)t.prototype[i]=r[i];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test("undefined"!=typeof navigator?navigator.userAgent:"node")&&(s=function(t,e){for(i=0;i<o.length;i+=1){var r=o[i],n=e[r];"function"==typeof n&&n!=Object.prototype[r]&&(t[r]=n)}})}catch(t){}s(t.prototype,r)}}},"undefined"!=typeof navigator&&"Microsoft Internet Explorer"==navigator.appName?(v.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=a*u+h*o;i=((u=o*u+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+a*h+(i>>>30),r[n++]=1073741823&u}return i},l=30):"undefined"!=typeof navigator&&"Netscape"!=navigator.appName?(v.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},l=26):(v.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=a*u+h*o;i=((u=o*u+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+a*h,r[n++]=268435455&u}return i},l=28),v.prototype.DB=l,v.prototype.DM=(1<<l)-1,v.prototype.DV=1<<l;v.prototype.FV=Math.pow(2,52),v.prototype.F1=52-l,v.prototype.F2=2*l-52;var y,m,x=new Array;for(y="0".charCodeAt(0),m=0;m<=9;++m)x[y++]=m;for(y="a".charCodeAt(0),m=10;m<36;++m)x[y++]=m;for(y="A".charCodeAt(0),m=10;m<36;++m)x[y++]=m;function b(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function S(t,e){var r=x[t.charCodeAt(e)];return null==r?-1:r}function E(t){var e=g();return e.fromInt(t),e}function w(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function A(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function N(t,e){return t&e}function D(t,e){return t|e}function R(t,e){return t^e}function T(t,e){return t&~e}function C(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function I(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function O(){}function H(t){return t}function _(t){this.r2=g(),this.q3=g(),v.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}A.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},A.prototype.revert=function(t){return t},A.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},A.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},A.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=g();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(v.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=g();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},v.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},v.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},v.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=8==r?255&t[n]:S(t,n);o<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&v.ZERO.subTo(this,this)},v.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},v.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},v.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},v.prototype.lShiftTo=function(t,e){var r,n=t%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},v.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},v.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},v.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&v.ZERO.subTo(e,e)},v.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},v.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=g());var s=g(),o=this.s,a=t.s,u=this.DB-w(n[n.t-1]);u>0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var h=s.t,c=s[h-1];if(0!=c){var l=c*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),f=this.FV/l,p=(1<<this.F1)/l,d=1<<this.F2,y=r.t,m=y-h,x=null==e?g():e;for(s.dlShiftTo(m,x),r.compareTo(x)>=0&&(r[r.t++]=1,r.subTo(x,r)),v.ONE.dlShiftTo(h,x),x.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--m>=0;){var b=r[--y]==c?this.DM:Math.floor(r[y]*f+(r[y-1]+d)*p);if((r[y]+=s.am(0,b,r,m,0,h))<b)for(s.dlShiftTo(m,x),r.subTo(x,r);r[y]<--b;)r.subTo(x,r)}null!=e&&(r.drShiftTo(h,e),o!=a&&v.ZERO.subTo(e,e)),r.t=h,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&v.ZERO.subTo(r,r)}}},v.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},v.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},v.prototype.exp=function(t,e){if(t>4294967295||t<1)return v.ONE;var r=g(),n=g(),i=e.convert(this),s=w(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)},v.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=b(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=b(r));return i?s:"0"},v.prototype.negate=function(){var t=g();return v.ZERO.subTo(this,t),t},v.prototype.abs=function(){return this.s<0?this.negate():this},v.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},v.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+w(this[this.t-1]^this.s&this.DM)},v.prototype.mod=function(t){var e=g();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(v.ZERO)>0&&t.subTo(e,e),e},v.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new A(e):new P(e),this.exp(t,r)},v.ZERO=E(0),v.ONE=E(1),O.prototype.convert=H,O.prototype.revert=H,O.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},O.prototype.sqrTo=function(t,e){t.squareTo(e)},_.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=g();return t.copyTo(e),this.reduce(e),e},_.prototype.revert=function(t){return t},_.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},_.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},_.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var B=[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],V=(1<<26)/B[B.length-1];v.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},v.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=E(r),i=g(),s=g(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o},v.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var u=S(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(o=e*o+u,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&v.ZERO.subTo(this,this)},v.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(v.ONE.shiftLeft(t-1),D,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(v.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},v.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},v.prototype.changeBit=function(t,e){var r=v.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},v.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},v.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},v.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},v.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},v.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},v.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},v.prototype.millerRabin=function(t){var e=this.subtract(v.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>B.length&&(t=B.length);for(var i=g(),s=0;s<t;++s){i.fromInt(B[Math.floor(Math.random()*B.length)]);var o=i.modPow(n,this);if(0!=o.compareTo(v.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(v.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},v.prototype.clone=
|
|
357
|
+
p.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var i;for(i in r)t.prototype[i]=r[i];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test("undefined"!=typeof navigator?navigator.userAgent:"node")&&(s=function(t,e){for(i=0;i<o.length;i+=1){var r=o[i],n=e[r];"function"==typeof n&&n!=Object.prototype[r]&&(t[r]=n)}})}catch(t){}s(t.prototype,r)}}},"undefined"!=typeof navigator&&"Microsoft Internet Explorer"==navigator.appName?(v.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=a*u+h*o;i=((u=o*u+((32767&c)<<15)+r[n]+(1073741823&i))>>>30)+(c>>>15)+a*h+(i>>>30),r[n++]=1073741823&u}return i},l=30):"undefined"!=typeof navigator&&"Netscape"!=navigator.appName?(v.prototype.am=function(t,e,r,n,i,s){for(;--s>=0;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},l=26):(v.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=a*u+h*o;i=((u=o*u+((16383&c)<<14)+r[n]+i)>>28)+(c>>14)+a*h,r[n++]=268435455&u}return i},l=28),v.prototype.DB=l,v.prototype.DM=(1<<l)-1,v.prototype.DV=1<<l;v.prototype.FV=Math.pow(2,52),v.prototype.F1=52-l,v.prototype.F2=2*l-52;var y,m,x=new Array;for(y="0".charCodeAt(0),m=0;m<=9;++m)x[y++]=m;for(y="a".charCodeAt(0),m=10;m<36;++m)x[y++]=m;for(y="A".charCodeAt(0),m=10;m<36;++m)x[y++]=m;function b(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function S(t,e){var r=x[t.charCodeAt(e)];return null==r?-1:r}function E(t){var e=g();return e.fromInt(t),e}function w(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function A(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function N(t,e){return t&e}function D(t,e){return t|e}function R(t,e){return t^e}function T(t,e){return t&~e}function C(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function I(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function O(){}function _(t){return t}function H(t){this.r2=g(),this.q3=g(),v.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}A.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},A.prototype.revert=function(t){return t},A.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},A.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},A.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=g();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(v.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=g();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},v.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},v.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},v.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=8==r?255&t[n]:S(t,n);o<0?"-"==t.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&v.ZERO.subTo(this,this)},v.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},v.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},v.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},v.prototype.lShiftTo=function(t,e){var r,n=t%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},v.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;n>0&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},v.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:n>0&&(e[r++]=n),e.t=r,e.clamp()},v.prototype.multiplyTo=function(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e[i]=0;for(i=0;i<n.t;++i)e[i+r.t]=r.am(0,n[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&v.ZERO.subTo(e,e)},v.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},v.prototype.divRemTo=function(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=g());var s=g(),o=this.s,a=t.s,u=this.DB-w(n[n.t-1]);u>0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var h=s.t,c=s[h-1];if(0!=c){var l=c*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),f=this.FV/l,p=(1<<this.F1)/l,d=1<<this.F2,y=r.t,m=y-h,x=null==e?g():e;for(s.dlShiftTo(m,x),r.compareTo(x)>=0&&(r[r.t++]=1,r.subTo(x,r)),v.ONE.dlShiftTo(h,x),x.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--m>=0;){var b=r[--y]==c?this.DM:Math.floor(r[y]*f+(r[y-1]+d)*p);if((r[y]+=s.am(0,b,r,m,0,h))<b)for(s.dlShiftTo(m,x),r.subTo(x,r);r[y]<--b;)r.subTo(x,r)}null!=e&&(r.drShiftTo(h,e),o!=a&&v.ZERO.subTo(e,e)),r.t=h,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&v.ZERO.subTo(r,r)}}},v.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},v.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},v.prototype.exp=function(t,e){if(t>4294967295||t<1)return v.ONE;var r=g(),n=g(),i=e.convert(this),s=w(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)},v.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=b(r));o>=0;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=b(r));return i?s:"0"},v.prototype.negate=function(){var t=g();return v.ZERO.subTo(this,t),t},v.prototype.abs=function(){return this.s<0?this.negate():this},v.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},v.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+w(this[this.t-1]^this.s&this.DM)},v.prototype.mod=function(t){var e=g();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(v.ZERO)>0&&t.subTo(e,e),e},v.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new A(e):new P(e),this.exp(t,r)},v.ZERO=E(0),v.ONE=E(1),O.prototype.convert=_,O.prototype.revert=_,O.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},O.prototype.sqrTo=function(t,e){t.squareTo(e)},H.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=g();return t.copyTo(e),this.reduce(e),e},H.prototype.revert=function(t){return t},H.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},H.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},H.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var B=[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],V=(1<<26)/B[B.length-1];v.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},v.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=E(r),i=g(),s=g(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o},v.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var u=S(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(i=!0):(o=e*o+u,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&v.ZERO.subTo(this,this)},v.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(v.ONE.shiftLeft(t-1),D,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(v.ONE.shiftLeft(t-1),this);else{var n=new Array,i=7&t;n.length=1+(t>>3),e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},v.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},v.prototype.changeBit=function(t,e){var r=v.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},v.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},v.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},v.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},v.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},v.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},v.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this[n])%t;return r},v.prototype.millerRabin=function(t){var e=this.subtract(v.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var n=e.shiftRight(r);(t=t+1>>1)>B.length&&(t=B.length);for(var i=g(),s=0;s<t;++s){i.fromInt(B[Math.floor(Math.random()*B.length)]);var o=i.modPow(n,this);if(0!=o.compareTo(v.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(v.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},v.prototype.clone=
|
|
358
358
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
359
|
-
function(){var t=g();return this.copyTo(t),t},v.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},v.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},v.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},v.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},v.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},v.prototype.equals=function(t){return 0==this.compareTo(t)},v.prototype.min=function(t){return this.compareTo(t)<0?this:t},v.prototype.max=function(t){return this.compareTo(t)>0?this:t},v.prototype.and=function(t){var e=g();return this.bitwiseTo(t,N,e),e},v.prototype.or=function(t){var e=g();return this.bitwiseTo(t,D,e),e},v.prototype.xor=function(t){var e=g();return this.bitwiseTo(t,R,e),e},v.prototype.andNot=function(t){var e=g();return this.bitwiseTo(t,T,e),e},v.prototype.not=function(){for(var t=g(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},v.prototype.shiftLeft=function(t){var e=g();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},v.prototype.shiftRight=function(t){var e=g();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},v.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+C(this[t]);return this.s<0?this.t*this.DB:-1},v.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=I(this[r]^e);return t},v.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},v.prototype.setBit=function(t){return this.changeBit(t,D)},v.prototype.clearBit=function(t){return this.changeBit(t,T)},v.prototype.flipBit=function(t){return this.changeBit(t,R)},v.prototype.add=function(t){var e=g();return this.addTo(t,e),e},v.prototype.subtract=function(t){var e=g();return this.subTo(t,e),e},v.prototype.multiply=function(t){var e=g();return this.multiplyTo(t,e),e},v.prototype.divide=function(t){var e=g();return this.divRemTo(t,e,null),e},v.prototype.remainder=function(t){var e=g();return this.divRemTo(t,null,e),e},v.prototype.divideAndRemainder=function(t){var e=g(),r=g();return this.divRemTo(t,e,r),new Array(e,r)},v.prototype.modPow=function(t,e){var r,n,i=t.bitLength(),s=E(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new A(e):e.isEven()?new
|
|
359
|
+
function(){var t=g();return this.copyTo(t),t},v.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},v.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},v.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},v.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},v.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(e[i++]=r);return e},v.prototype.equals=function(t){return 0==this.compareTo(t)},v.prototype.min=function(t){return this.compareTo(t)<0?this:t},v.prototype.max=function(t){return this.compareTo(t)>0?this:t},v.prototype.and=function(t){var e=g();return this.bitwiseTo(t,N,e),e},v.prototype.or=function(t){var e=g();return this.bitwiseTo(t,D,e),e},v.prototype.xor=function(t){var e=g();return this.bitwiseTo(t,R,e),e},v.prototype.andNot=function(t){var e=g();return this.bitwiseTo(t,T,e),e},v.prototype.not=function(){for(var t=g(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},v.prototype.shiftLeft=function(t){var e=g();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},v.prototype.shiftRight=function(t){var e=g();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},v.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+C(this[t]);return this.s<0?this.t*this.DB:-1},v.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=I(this[r]^e);return t},v.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},v.prototype.setBit=function(t){return this.changeBit(t,D)},v.prototype.clearBit=function(t){return this.changeBit(t,T)},v.prototype.flipBit=function(t){return this.changeBit(t,R)},v.prototype.add=function(t){var e=g();return this.addTo(t,e),e},v.prototype.subtract=function(t){var e=g();return this.subTo(t,e),e},v.prototype.multiply=function(t){var e=g();return this.multiplyTo(t,e),e},v.prototype.divide=function(t){var e=g();return this.divRemTo(t,e,null),e},v.prototype.remainder=function(t){var e=g();return this.divRemTo(t,null,e),e},v.prototype.divideAndRemainder=function(t){var e=g(),r=g();return this.divRemTo(t,e,r),new Array(e,r)},v.prototype.modPow=function(t,e){var r,n,i=t.bitLength(),s=E(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new A(e):e.isEven()?new H(e):new P(e);var o=new Array,a=3,u=r-1,h=(1<<r)-1;if(o[1]=n.convert(this),r>1){var c=g();for(n.sqrTo(o[1],c);a<=h;)o[a]=g(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,p=t.t-1,d=!0,v=g();for(i=w(t[p])-1;p>=0;){for(i>=u?l=t[p]>>i-u&h:(l=(t[p]&(1<<i+1)-1)<<u-i,p>0&&(l|=t[p-1]>>this.DB+i-u)),a=r;0==(1&l);)l>>=1,--a;if((i-=a)<0&&(i+=this.DB,--p),d)o[l].copyTo(s),d=!1;else{for(;a>1;)n.sqrTo(s,v),n.sqrTo(v,s),a-=2;a>0?n.sqrTo(s,v):(f=s,s=v,v=f),n.mulTo(v,o[l],s)}for(;p>=0&&0==(t[p]&1<<i);)n.sqrTo(s,v),f=s,s=v,v=f,--i<0&&(i=this.DB-1,--p)}return n.revert(s)},v.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return v.ZERO;for(var r=t.clone(),n=this.clone(),i=E(1),s=E(0),o=E(0),a=E(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(i.isEven()&&s.isEven()||(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(r,n),e&&o.subTo(i,o),a.subTo(s,a))}return 0!=n.compareTo(v.ONE)?v.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},v.prototype.pow=function(t){return this.exp(t,new O)},v.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},v.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e<B.length;++e)if(r[0]==B[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<B.length;){for(var n=B[e],i=e+1;i<B.length&&n<V;)n*=B[i++];for(n=r.modInt(n);e<i;)if(n%B[e++]==0)return!1}return r.millerRabin(t)},v.prototype.square=function(){var t=g();return this.squareTo(t),t};
|
|
360
360
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
361
|
-
var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function
|
|
361
|
+
var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function z(t){var e,r,n="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),n+=j.charAt(r>>6)+j.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),n+=j.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),n+=j.charAt(r>>2)+j.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function q(t){var e,r,n,i="",s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(n=j.indexOf(t.charAt(e)))<0||(0==s?(i+=b(n>>2),r=3&n,s=1):1==s?(i+=b(r<<2|n>>4),r=15&n,s=2):2==s?(i+=b(r),i+=b(n>>2),r=3&n,s=3):(i+=b(r<<2|n>>4),i+=b(15&n),s=0));return 1==s&&(i+=b(r<<2)),i}
|
|
362
362
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */function k(){this.i=0,this.j=0,this.S=new Array}k.prototype.init=function(t){var e,r,n;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,n=this.S[e],this.S[e]=this.S[r],this.S[r]=n;this.i=0,this.j=0},k.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var K,L,M;
|
|
363
363
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */function U(){var t;t=(new Date).getTime(),L[M++]^=255&t,L[M++]^=t>>8&255,L[M++]^=t>>16&255,L[M++]^=t>>24&255,M>=256&&(M-=256)}if(null==L){var F;if(L=new Array,M=0,"undefined"!=typeof window&&(void 0!==window.crypto||void 0!==window.msCrypto)){var Y=window.crypto||window.msCrypto;if(Y.getRandomValues){var Q=new Uint8Array(32);for(Y.getRandomValues(Q),F=0;F<32;++F)L[M++]=Q[F]}else if("undefined"!=typeof navigator&&"Netscape"==navigator.appName&&navigator.appVersion<"5"){var Z=window.crypto.random(32);for(F=0;F<Z.length;++F)L[M++]=255&Z.charCodeAt(F)}}for(;M<256;)F=Math.floor(65536*Math.random()),L[M++]=F>>>8,L[M++]=255&F;M=0,U()}function G(){if(null==K){for(U(),(K=new k).init(L),M=0;M<L.length;++M)L[M]=0;M=0}return K.next()}function W(){}
|
|
364
364
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
365
|
-
function X(t,e){return new v(t,e)}function J(t,e,r){for(var n="",i=0;n.length<e;)n+=r(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function $(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function tt(t,e,r){for(var n="",i=0;n.length<e;)n+=r(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return n}function et(t){for(var e="",r=0;r<t.length;r++){var n=t[r].toString(16);1==n.length&&(n="0"+n),e+=n}return e}function rt(t){return et(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function nt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function it(t){return t.length%2==1&&(t="0"+t),function(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}(
|
|
365
|
+
function X(t,e){return new v(t,e)}function J(t,e,r){for(var n="",i=0;n.length<e;)n+=r(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function $(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function tt(t,e,r){for(var n="",i=0;n.length<e;)n+=r(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return n}function et(t){for(var e="",r=0;r<t.length;r++){var n=t[r].toString(16);1==n.length&&(n="0"+n),e+=n}return e}function rt(t){return et(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function nt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function it(t){return t.length%2==1&&(t="0"+t),function(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}(z(t))}function st(t){return q(nt(t))}function ot(t){return function(t){return t.replace(/%/g,"")}(function(t){for(var e=encodeURIComponent(t),r="",n=0;n<e.length;n++)"%"==e[n]?(r+=e.substr(n,3),n+=2):r=r+"%"+rt(e[n]);return r}(t))}function at(t){return decodeURIComponent(function(t){return t.replace(/(..)/g,"%$1")}(t))}function ut(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function ht(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function ct(t){var e=function(t){return z(t)}(t).replace(/(.{64})/g,"$1\r\n");return e=e.replace(/\r\n$/,"")}function lt(t,e){return"-----BEGIN "+e+"-----\r\n"+ct(t)+"\r\n-----END "+e+"-----\r\n"}function ft(t,e){if(-1==t.indexOf("-----BEGIN "))throw"can't find PEM header: "+e;return function(t){return q(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function pt(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?function(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var e=(t=t.toLowerCase()).match(/.{1,4}/g),r=0;r<8;r++)e[r]=e[r].replace(/^0+/,""),""==e[r]&&(e[r]="0");var n=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null===n)return t.slice(1,-1);var i="";for(r=0;r<n.length;r++)n[r].length>i.length&&(i=n[r]);return(t=t.replace(i,"::")).slice(1,-1)}(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function dt(t){return t.match(/.{4}/g).map((function(t){var e=parseInt(t.substr(0,2),16),r=parseInt(t.substr(2),16);if(0==e&r<128)return String.fromCharCode(r);if(e<8){var n=128|63&r;return at((192|(7&e)<<3|(192&r)>>6).toString(16)+n.toString(16))}n=128|(15&e)<<2|(192&r)>>6;var i=128|63&r;return at((224|(240&e)>>4).toString(16)+n.toString(16)+i.toString(16))})).join("")}function vt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function gt(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}W.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=G()},$.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},$.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=X(t,16),this.e=parseInt(e,16)}},$.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var r=new Array,n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new W,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new v(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n},$.prototype.encryptOAEP=function(t,e,r){var n=function(t,e,r,n){var i=f.crypto.MessageDigest,s=f.crypto.Util,o=null;if(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ut(s.hashHex(ht(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,u="";for(a=0;a<e-t.length-2*n-2;a+=1)u+="\0";var h=r("")+u+""+t,c=new Array(n);(new W).nextBytes(c);var l=J(c,h.length,r),p=[];for(a=0;a<h.length;a+=1)p[a]=h.charCodeAt(a)^l.charCodeAt(a);var d=J(p,c.length,r),g=[0];for(a=0;a<c.length;a+=1)g[a+1]=c[a]^d.charCodeAt(a);return new v(g.concat(p))}(t,this.n.bitLength()+7>>3,e,r);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},$.prototype.type="RSA",$.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},$.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=X(t,16),this.e=parseInt(e,16),this.d=X(r,16)}},$.prototype.setPrivateEx=function(t,e,r,n,i,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=X(t,16),this.e=parseInt(e,16),this.d=X(r,16),this.p=X(n,16),this.q=X(i,16),this.dmp1=X(s,16),this.dmq1=X(o,16),this.coeff=X(a,16)},$.prototype.generate=function(t,e){var r=new W,n=t>>1;this.e=parseInt(e,16);for(var i=new v(e,16);;){for(;this.p=new v(t-n,1,r),0!=this.p.subtract(v.ONE).gcd(i).compareTo(v.ONE)||!this.p.isProbablePrime(10););for(;this.q=new v(n,1,r),0!=this.q.subtract(v.ONE).gcd(i).compareTo(v.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(v.ONE),a=this.q.subtract(v.ONE),u=o.multiply(a);if(0==u.gcd(i).compareTo(v.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=i.modInverse(u),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},$.prototype.decrypt=function(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var e=X(t,16),r=this.doPrivate(e);return null==r?null:
|
|
366
366
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
367
|
-
function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},$.prototype.decryptOAEP=function(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=X(t,16),i=this.doPrivate(n);return null==i?null:function(t,e,r,n){var i=f.crypto.MessageDigest,s=f.crypto.Util,o=null;for(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ut(s.hashHex(ht(t),o))}),t=t.toByteArray(),a=0;a<t.length;a+=1)t[a]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*n+2)throw"Cipher too short";var a,u=t.substr(1,n),h=t.substr(n+1),c=tt(h,n,r),l=[];for(a=0;a<u.length;a+=1)l[a]=u.charCodeAt(a)^c.charCodeAt(a);var p=tt(String.fromCharCode.apply(String,l),t.length-n,r),d=[];for(a=0;a<h.length;a+=1)d[a]=h.charCodeAt(a)^p.charCodeAt(a);if((d=String.fromCharCode.apply(String,d)).substr(0,n)!==r(""))throw"Hash mismatch";var v=(d=d.substr(n)).indexOf("");if((-1!=v?d.substr(0,v).lastIndexOf("\0"):-1)+1!=v)throw"Malformed data";return d.substr(v+1)}(i,this.n.bitLength()+7>>3,e,r)},void 0!==f.lang&&f.lang||(f.lang={}),f.lang.String=function(){},f.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},f.lang.String.isHex=function(t){return vt(t)},f.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},f.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=nt(t),f.lang.String.isBase64(t))},f.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},f.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},f.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},f.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var yt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function mt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==f.crypto&&f.crypto||(f.crypto={}),f.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:d.algo.MD5,sha1:d.algo.SHA1,sha224:d.algo.SHA224,sha256:d.algo.SHA256,sha384:d.algo.SHA384,sha512:d.algo.SHA512,ripemd160:d.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var n=this.getDigestInfoHex(t,e),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",o="00"+n,a="",u=i-s.length-o.length,h=0;h<u;h+=2)a+="ff";return s+a+o},this.hashString=function(t,e){return new f.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new f.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof $||t instanceof f.crypto.DSA||t instanceof f.crypto.ECDSA}},f.crypto.Util.md5=function(t){return new f.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},f.crypto.Util.ripemd160=function(t){return new f.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},f.crypto.Util.SECURERANDOMGEN=new W,f.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return f.crypto.Util.SECURERANDOMGEN.nextBytes(e),et(e)},f.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new v(f.crypto.Util.getRandomHexOfNbytes(t),16)},f.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return f.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],et(r)},f.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new v(f.crypto.Util.getRandomHexOfNbits(t),16)},f.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=f.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},f.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";if(0==r)return t;var n=e.subtract(t);return f.crypto.Util.getRandomBigIntegerZeroToMax(n).add(t)},f.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=f.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=f.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=f.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=d.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(d.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},f.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},f.crypto.MessageDigest.getHashLength=function(t){var e=f.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},f.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},f.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=f.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var n=f.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=d.algo.HMAC.create(n,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=d.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(d.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=ht(t)),void(this.pass=d.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=ot(t.utf8)),void 0!==t.rstr&&(e=ht(t.rstr)),void 0!==t.b64&&(e=z(t.b64)),void 0!==t.b64u&&(e=st(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=d.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},f.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new f.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Dt.getKey(t):Dt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==f.crypto.ECDSA&&(this.prvKey=new f.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof $&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof $&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof f.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof f.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==f.crypto.ECDSA&&(this.pubKey=new f.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof $&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof $&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==f.crypto.ECDSA&&this.pubKey instanceof f.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==f.crypto.DSA&&this.pubKey instanceof f.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Dt.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},f.crypto.Cipher=function(t){},f.crypto.Cipher.encrypt=function(t,e,r){if(e instanceof $&&e.isPublic){var n=f.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.encrypt(t);if("RSAOAEP"===n)return e.encryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.encryptOAEP(t,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},f.crypto.Cipher.decrypt=function(t,e,r){if(e instanceof $&&e.isPrivate){var n=f.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.decrypt(t);if("RSAOAEP"===n)return e.decryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.decryptOAEP(t,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},f.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof $){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},f.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}};var xt,bt,St,Et,wt,At,Pt,Nt,Dt=(xt=function(t,e,r){return bt(d.AES,t,e,r)},bt=function(t,e,r,n){var i=d.enc.Hex.parse(e),s=d.enc.Hex.parse(r),o=d.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=i;var u=t.decrypt(a,s,{iv:o});return d.enc.Hex.stringify(u)},St=function(t,e,r){return Et(d.AES,t,e,r)},Et=function(t,e,r,n){var i=d.enc.Hex.parse(e),s=d.enc.Hex.parse(r),o=d.enc.Hex.parse(n),a=t.encrypt(i,s,{iv:o}),u=d.enc.Hex.parse(a.toString());return d.enc.Base64.stringify(u)},wt={"AES-256-CBC":{proc:xt,eproc:St,keylen:32,ivlen:16},"AES-192-CBC":{proc:xt,eproc:St,keylen:24,ivlen:16},"AES-128-CBC":{proc:xt,eproc:St,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,r){return bt(d.TripleDES,t,e,r)},eproc:function(t,e,r){return Et(d.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,r){return bt(d.DES,t,e,r)},eproc:function(t,e,r){return Et(d.DES,t,e,r)},keylen:8,ivlen:8}},At=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=i&&-1!=o){var a=t.substring(i+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},Pt=function(t,e,r){for(var n=r.substring(0,16),i=d.enc.Hex.parse(n),s=d.enc.Utf8.parse(e),o=wt[t].keylen+wt[t].ivlen,a="",u=null;;){var h=d.algo.MD5.create();if(null!=u&&h.update(u),h.update(s),h.update(i),u=h.finalize(),(a+=d.enc.Hex.stringify(u)).length>=2*o)break}var c={};return c.keyhex=a.substr(0,2*wt[t].keylen),c.ivhex=a.substr(2*wt[t].keylen,2*wt[t].ivlen),c},Nt=function(t,e,r,n){var i=d.enc.Base64.parse(t),s=d.enc.Hex.stringify(i);return(0,wt[e].proc)(s,r,n)},{version:"1.0.0",parsePKCS5PEM:function(t){return At(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return Pt(t,e,r)},decryptKeyB64:function(t,e,r,n){return Nt(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=At(t),n=r.cipher,i=r.ivsalt,s=r.data,o=Pt(n,e,i).keyhex;return Nt(s,n,o,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,i){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===wt[n])throw"KEYUTIL unsupported algorithm: "+n;if(void 0===i||null==i){var o=function(t){var e=d.lib.WordArray.random(t);return d.enc.Hex.stringify(e)}(wt[n].ivlen);i=o.toUpperCase()}var a=function(t,e,r,n){return(0,wt[e].eproc)(t,r,n)}(e,n,Pt(n,r,i).keyhex,i);return s="-----BEGIN "+t+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+i+"\r\n",s+="\r\n",s+=a.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;i.ciphertext=n(t,s[1]);var o=r(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=r(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=r(t,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,u[1]);var h=r(t,a[0]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length;if("2a864886f70d01050c"!=n(t,h[0]))throw"this only supports pkcs5PBKDF2";var c=r(t,h[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;i.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=d.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=d.PBKDF2(e,r,{keySize:6,iterations:n});return d.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=ft(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=Dt.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=d.enc.Hex.parse(n.ciphertext);var o=d.enc.Hex.parse(i),a=d.enc.Hex.parse(n.encryptionSchemeIV),u=d.TripleDES.decrypt(s,o,{iv:a});return d.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(i.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=ft(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new $;else if("2a8648ce380401"==r.algoid)e=new f.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw"unsupported private key algorithm";e=new f.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=Rt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new $;else if("2a8648ce380401"===r)e=new f.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";e=new f.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=r(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=r(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?i.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,a[1],[0],"02"),i.algparam.q=e.getVbyList(t,a[1],[1],"02"),i.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return i.key=n(t,s[1]).substr(2),i}});Dt.getKey=function(t,e,r){var n=(m=Rt).getChildIdx;m.getV;var i=m.getVbyList,s=f.crypto,o=s.ECDSA,a=s.DSA,u=$,h=ft,c=Dt;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(t.n,t.e),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(T=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(T=new u).setPrivate(t.n,t.e,t.d),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(T=new a).setPublic(t.p,t.q,t.g,t.y),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(T=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(st(t.n),st(t.e)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(T=new u).setPrivateEx(st(t.n),st(t.e),st(t.d),st(t.p),st(t.q),st(t.dp),st(t.dq),st(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(st(t.n),st(t.e),st(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(R=new o({curve:t.crv})).ecparams.keylen/4,p="04"+("0000000000"+st(t.x)).slice(-l)+("0000000000"+st(t.y)).slice(-l);return R.setPublicKeyHex(p),R}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(R=new o({curve:t.crv})).ecparams.keylen/4,p="04"+("0000000000"+st(t.x)).slice(-l)+("0000000000"+st(t.y)).slice(-l);var d=("0000000000"+st(t.d)).slice(-l);return R.setPublicKeyHex(p),R.setPrivateKeyHex(d),R}if("pkcs5prv"===r){var g,y=t,m=Rt;if(9===(g=n(y,0)).length)(T=new u).readPKCS5PrvKeyHex(y);else if(6===g.length)(T=new a).readPKCS5PrvKeyHex(y);else{if(!(g.length>2&&"04"===y.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(T=new o).readPKCS5PrvKeyHex(y)}return T}if("pkcs8prv"===r)return T=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return Ot.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Ot.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var x=ft(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(x)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var b=h(t,"RSA PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=i(O=h(t,"DSA PRIVATE KEY"),0,[1],"02"),E=i(O,0,[2],"02"),w=i(O,0,[3],"02"),A=i(O,0,[4],"02"),P=i(O,0,[5],"02");return(T=new a).setPrivate(new v(S,16),new v(E,16),new v(w,16),new v(A,16),new v(P,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){b=h(t,"EC PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var N=c.getDecryptedKeyHex(t,e),D=new $;return D.readPKCS5PrvKeyHex(N),D}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R,T=i(O=c.getDecryptedKeyHex(t,e),0,[1],"04"),C=i(O,0,[2,0],"06"),I=i(O,0,[3,0],"03").substr(2);if(void 0===f.crypto.OID.oidhex2name[C])throw"undefined OID(hex) in KJUR.crypto.OID: "+C;return(R=new o({curve:f.crypto.OID.oidhex2name[C]})).setPublicKeyHex(I),R.setPrivateKeyHex(T),R.isPublic=!1,R}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var O;S=i(O=c.getDecryptedKeyHex(t,e),0,[1],"02"),E=i(O,0,[2],"02"),w=i(O,0,[3],"02"),A=i(O,0,[4],"02"),P=i(O,0,[5],"02");return(T=new a).setPrivate(new v(S,16),new v(E,16),new v(w,16),new v(A,16),new v(P,16)),T}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Dt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new $).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new $,i=o.n.toString(16),s=o.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,u=e,h=new f.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new f.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),o.setPrivateKeyHex(h.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new f.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Dt.getPEM=function(t,e,r,n,i,s){var o=f,a=o.asn1,u=a.DERObjectIdentifier,h=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,p=o.crypto,v=p.DSA,g=p.ECDSA,y=$;function m(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function x(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function b(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==y&&t instanceof y||void 0!==v&&t instanceof v||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return lt(A=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==y&&t instanceof y&&(void 0===r||null==r)&&1==t.isPrivate)return lt(A=m(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var S=new u({name:t.curveName}).getEncodedHex(),E=x(t).getEncodedHex(),w="";return w+=lt(S,"EC PARAMETERS"),w+=lt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==v&&t instanceof v&&(void 0===r||null==r)&&1==t.isPrivate)return lt(A=b(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==y&&t instanceof y&&void 0!==r&&null!=r&&1==t.isPrivate){var A=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate){A=x(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==v&&t instanceof v&&void 0!==r&&null!=r&&1==t.isPrivate){A=b(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,n,s)}var P=function(t,e){var r=N(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},N=function(t,e){var r=d.lib.WordArray.random(8),n=d.lib.WordArray.random(8),i=d.PBKDF2(e,r,{keySize:6,iterations:100}),s=d.enc.Hex.parse(t),o=d.TripleDES.encrypt(s,i,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=d.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=d.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=y&&t instanceof y&&1==t.isPrivate){var D=m(t).getEncodedHex();A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){D=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==v&&t instanceof v&&1==t.isPrivate){D=new h({bigint:t.x}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Dt.getKeyFromCSRPEM=function(t){var e=ft(t,"CERTIFICATE REQUEST");return Dt.getKeyFromCSRHex(e)},Dt.getKeyFromCSRHex=function(t){var e=Dt.parseCSRHex(t);return Dt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Dt.parseCSRHex=function(t){var e=Rt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=r(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=r(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return i.p8pubkeyhex=n(s,a[2]),i},Dt.getKeyID=function(t){var e=Dt,r=Rt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=ft(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return f.crypto.Util.hashHex(s,"sha1")},Dt.getJWKFromKey=function(t){var e={};if(t instanceof $&&t.isPrivate)return e.kty="RSA",e.n=it(t.n.toString(16)),e.e=it(t.e.toString(16)),e.d=it(t.d.toString(16)),e.p=it(t.p.toString(16)),e.q=it(t.q.toString(16)),e.dp=it(t.dmp1.toString(16)),e.dq=it(t.dmq1.toString(16)),e.qi=it(t.coeff.toString(16)),e;if(t instanceof $&&t.isPublic)return e.kty="RSA",e.n=it(t.n.toString(16)),e.e=it(t.e.toString(16)),e;if(t instanceof f.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=it(r.x),e.y=it(r.y),e.d=it(t.prvKeyHex),e}if(t instanceof f.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=it(r.x),e.y=it(r.y),e}throw"not supported key object"},void 0!==f.asn1&&f.asn1||(f.asn1={}),f.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new v(n,16).xor(t).add(v.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return lt(t,e)},this.newObject=function(t){var e=f.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,u=e.DERObjectIdentifier,h=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,p=e.DERPrintableString,d=e.DERTeletexString,v=e.DERIA5String,g=e.DERUTCTime,y=e.DERGeneralizedTime,m=e.DERVisibleString,x=e.DERBMPString,b=e.DERSequence,S=e.DERSet,E=e.DERTaggedObject,w=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var P=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":"))throw new Error("undefined key: "+P);if("bool"==P)return new n(t[P]);if("int"==P)return new i(t[P]);if("bitstr"==P)return new s(t[P]);if("octstr"==P)return new o(t[P]);if("null"==P)return new a(t[P]);if("oid"==P)return new u(t[P]);if("enum"==P)return new h(t[P]);if("utf8str"==P)return new c(t[P]);if("numstr"==P)return new l(t[P]);if("prnstr"==P)return new p(t[P]);if("telstr"==P)return new d(t[P]);if("ia5str"==P)return new v(t[P]);if("utctime"==P)return new g(t[P]);if("gentime"==P)return new y(t[P]);if("visstr"==P)return new m(t[P]);if("bmpstr"==P)return new x(t[P]);if("asn1"==P)return new r(t[P]);if("seq"==P){for(var N=t[P],D=[],R=0;R<N.length;R++){var T=w(N[R]);D.push(T)}return new b({array:D})}if("set"==P){for(N=t[P],D=[],R=0;R<N.length;R++){T=w(N[R]);D.push(T)}return new S({array:D})}if("tag"==P){var C=t[P];if("[object Array]"===Object.prototype.toString.call(C)&&3==C.length){var I=w(C[2]);return new E({tag:C[0],explicit:C[1],obj:I})}return new E(C)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},f.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new v(n,2).toString(10),n=""}return e},f.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new v(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";n=s+n;for(o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},f.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},f.asn1.DERAbstractString=function(t){f.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=ot(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},p.lang.extend(f.asn1.DERAbstractString,f.asn1.ASN1Object),f.asn1.DERAbstractTime=function(t){f.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=rt(t)},this.setByDateValue=function(t,e,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(f.asn1.DERAbstractTime,f.asn1.ASN1Object),f.asn1.DERAbstractStructured=function(t){f.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},p.lang.extend(f.asn1.DERAbstractStructured,f.asn1.ASN1Object),f.asn1.DERBoolean=function(t){f.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},p.lang.extend(f.asn1.DERBoolean,f.asn1.ASN1Object),f.asn1.DERInteger=function(t){f.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=f.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(f.asn1.DERInteger,f.asn1.ASN1Object),f.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=f.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}f.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},p.lang.extend(f.asn1.DERBitString,f.asn1.ASN1Object),f.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=f.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}f.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},p.lang.extend(f.asn1.DEROctetString,f.asn1.DERAbstractString),f.asn1.DERNull=function(){f.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(f.asn1.DERNull,f.asn1.ASN1Object),f.asn1.DERObjectIdentifier=function(t){f.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=parseInt(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var n="",i=t.split("."),s=40*parseInt(i[0],10)+parseInt(i[1],10);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=f.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},p.lang.extend(f.asn1.DERObjectIdentifier,f.asn1.ASN1Object),f.asn1.DEREnumerated=function(t){f.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=f.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(f.asn1.DEREnumerated,f.asn1.ASN1Object),f.asn1.DERUTF8String=function(t){f.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},p.lang.extend(f.asn1.DERUTF8String,f.asn1.DERAbstractString),f.asn1.DERNumericString=function(t){f.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},p.lang.extend(f.asn1.DERNumericString,f.asn1.DERAbstractString),f.asn1.DERPrintableString=function(t){f.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},p.lang.extend(f.asn1.DERPrintableString,f.asn1.DERAbstractString),f.asn1.DERTeletexString=function(t){f.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},p.lang.extend(f.asn1.DERTeletexString,f.asn1.DERAbstractString),f.asn1.DERIA5String=function(t){f.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},p.lang.extend(f.asn1.DERIA5String,f.asn1.DERAbstractString),f.asn1.DERVisibleString=function(t){f.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},p.lang.extend(f.asn1.DERVisibleString,f.asn1.DERAbstractString),f.asn1.DERBMPString=function(t){f.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},p.lang.extend(f.asn1.DERBMPString,f.asn1.DERAbstractString),f.asn1.DERUTCTime=function(t){f.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=rt(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=rt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},p.lang.extend(f.asn1.DERUTCTime,f.asn1.DERAbstractTime),f.asn1.DERGeneralizedTime=function(t){f.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=rt(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=rt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},p.lang.extend(f.asn1.DERGeneralizedTime,f.asn1.DERAbstractTime),f.asn1.DERSequence=function(t){f.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},p.lang.extend(f.asn1.DERSequence,f.asn1.DERAbstractStructured),f.asn1.DERSet=function(t){f.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},p.lang.extend(f.asn1.DERSet,f.asn1.DERAbstractStructured),f.asn1.DERTaggedObject=function(t){f.asn1.DERTaggedObject.superclass.constructor.call(this);var e=f.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){null!=t.tag&&(this.hT=t.tag),null!=t.explicit&&(this.isExplicit=t.explicit),null!=t.tage&&(this.hT=t.tage,this.isExplicit=!0),null!=t.tagi&&(this.hT=t.tagi,this.isExplicit=!1),null!=t.obj&&(t.obj instanceof e.ASN1Object?(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof t.obj&&(this.asn1Object=e.ASN1Util.newObject(t.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=t&&this.setByParam(t)},p.lang.extend(f.asn1.DERTaggedObject,f.asn1.ASN1Object);var Rt=new function(){};function Tt(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t}function Ct(t,e,r){for(var n="",i=0;n.length<e;)n+=ut(r(ht(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function It(t){for(var e in f.crypto.Util.DIGESTINFOHEAD){var r=f.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function Ot(t){var e,r=Rt,n=r.getChildIdx,i=r.getV,s=r.getTLV,o=r.getVbyList,a=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,c=r.getIdxbyList,l=r.getIdxbyListEx,p=r.getVidx,d=r.getInt,v=r.oidname,g=r.hextooidstr,y=ft;try{e=f.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=d(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return v(a(t,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return u(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=o(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return c(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Dt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),i=new f.crypto.Signature({alg:e});return i.init(t),i.updateHex(n),i.verify(r)},this.parseExt=function(t){var e,s,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=c(a,0,[0,7,0],"30"),s=n(a,e)}else{a=ft(t);var u=c(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,u))return void(this.aExtInfo=new Array);e=c(a,0,[0,3,0,1,0],"30"),s=n(a,e),this.hex=a}this.aExtInfo=new Array;for(var h=0;h<s.length;h++){var l={critical:!1},f=0;3===n(a,s[h]).length&&(l.critical=!0,f=1),l.oid=r.hextooidstr(o(a,s[h],[0],"06"));var d=c(a,s[h],[1+f]);l.vidx=p(a,d),this.aExtInfo.push(l)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=f.asn1.x509.OID.name2oid(t)),""!==r)for(var n=0;n<e.length;n++)if(e[n].oid===r)return e[n]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"basicConstraints"};if(e&&(n.critical=!0),"3000"===t)return n;if("30030101ff"===t)return n.cA=!0,n;if("30060101ff02"===t.substr(0,12)){var o=i(t,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+t)},this.getExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("keyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"keyUsage"};return e&&(n.critical=!0),n.names=this.getExtKeyUsageString(t).split(","),n},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=s(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,n=0;n<e.length;n++)"1"==e.substr(n,1)&&r.push(Ot.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectKeyIdentifier"};e&&(n.critical=!0);var o=i(t,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"authorityKeyIdentifier"};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++){var h=t.substr(a[u],2);if("80"===h&&(o.kid={hex:i(t,a[u])}),"a1"===h){var c=s(t,a[u]),l=this.getGeneralNames(c);o.issuer=l[0].dn}"82"===h&&(o.sn={hex:i(t,a[u])})}return o},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"extKeyUsage",array:[]};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++)o.array.push(v(i(t,a[u])));return o},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=s(this.hex,t.vidx);if(""===r)return e;for(var o=n(r,0),a=0;a<o.length;a++)e.push(v(i(r,o[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"issuerAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getGeneralNames=function(t){for(var e=n(t,0),r=[],i=0;i<e.length;i++){var o=this.getGeneralName(s(t,e[i]));void 0!==o&&r.push(o)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=i(t,0),n=ut(r);return"81"==e?{rfc822:n}:"82"==e?{dns:n}:"86"==e?{uri:n}:"87"==e?{ip:pt(r)}:"a4"==e?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),h=n(u,0),c=0;c<h.length;c++)r=u.substr(h[c],2),t=i(u,h[c]),"81"===r&&(e=at(t),a.push(["MAIL",e])),"82"===r&&(e=at(t),a.push(["DNS",e])),"84"===r&&(e=Ot.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=at(t),a.push(["URI",e])),"87"===r&&(e=pt(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"cRLDistributionPoints",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]);i.array.push(this.getDistributionPoint(u))}return i},this.getDistributionPoint=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var e=new Array,r=n(this.hex,t.vidx),i=0;i<r.length;i++)try{var s=at(o(this.hex,r[i],[0,0,0],"86"));e.push(s)}catch(t){}return e},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=n(this.hex,t.vidx),i=0;i<r.length;i++){var s=o(this.hex,r[i],[0],"06"),a=o(this.hex,r[i],[1],"86");"2b06010505073001"===s&&e.ocsp.push(at(a)),"2b06010505073002"===s&&e.caissuer.push(at(a))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"authorityInfoAccess",array:[]};e&&(i.critical=!0);for(var u=n(t,0),h=0;h<u.length;h++){var c=a(t,u[h],[0],"06"),l=at(o(t,u[h],[1],"86"));if("2b06010505073001"==c)i.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);i.array.push({caissuer:l})}}return i},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"certificatePolicies",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]),h=this.getPolicyInformation(u);i.array.push(h)}return i},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=v(r);var i=l(t,0,[1],"30");if(-1!=i){e.array=[];for(var a=n(t,i),u=0;u<a.length;u++){var h=s(t,a[u]),c=this.getPolicyQualifierInfo(h);e.array.push(c)}}return e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var n=a(t,0,[1],"16");e.cps=ut(n)}else if("2b06010505070202"===r){var i=u(t,0,[1],"30");e.unotice=this.getUserNotice(i)}return e},this.getUserNotice=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]);"30"!=o.substr(0,2)&&(e.exptext=this.getDisplayText(o))}return e},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=ut(i(t,0)),e},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:i(t,0)},r;throw new Error("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(i(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var n=i(t,0);return r.hex=n,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"adobeTimeStamp"};e&&(i.critical=!0);var o=n(t,0);if(o.length>1){var a=s(t,o[1]),u=this.getGeneralName(a);null!=u.uri&&(i.uri=u.uri)}if(o.length>2){var h=s(t,o[2]);"0101ff"==h&&(i.reqauth=!0),"010100"==h&&(i.reqauth=!1)}return i},this.getX500NameRule=function(t){for(var e=null,r=[],n=0;n<t.length;n++)for(var i=t[n],s=0;s<i.length;s++)r.push(i[s]);for(n=0;n<r.length;n++){var o=r[n],a=o.ds,u=o.value,h=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=h)return"mixed";if(f.lang.String.isMail(u))continue;return"mixed"}if("C"==h){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getX500Name=function(t){var e=this.getX500NameArray(t);return{array:e,str:this.dnarraytostr(e)}},this.getX500NameArray=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getRDN(s(t,r[i])));return e},this.getRDN=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getAttrTypeAndValue(s(t,r[i])));return e},this.getAttrTypeAndValue=function(t){var e={type:null,value:null,ds:null},r=n(t,0),i=o(t,r[0],[],"06"),s=o(t,r[1],[]),a=f.asn1.ASN1Util.oidHexToInt(i);return e.type=f.asn1.x509.OID.oid2atype(a),e.ds=this.HEX2STAG[t.substr(r[1],2)],"bmp"!=e.ds?e.value=at(s):e.value=dt(s),e},this.readCertPEM=function(t){this.readCertHex(y(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{c(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(){var t={};return t.version=this.getVersion(),t.serial={hex:this.getSerialNumberHex()},t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.notbefore=this.getNotBefore(),t.notafter=this.getNotAfter(),t.subject=this.getSubject(),t.sbjpubkey=lt(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=l(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]),a=this.getExtParam(o);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=n(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=g(o(t,0,[0],"06")),i=!1;3==e&&"0101ff"==u(t,0,[1])&&(i=!0);var s=u(t,0,[e-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(s,i):"2.5.29.15"==r?a=this.getExtKeyUsage(s,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(s,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(s,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(s,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(s,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(s,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(s,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(s,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(s,i):"2.5.29.20"==r?a=this.getExtCRLNumber(s,i):"2.5.29.21"==r?a=this.getExtCRLReason(s,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(s,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(s,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(s,i)),null!=a)return a;var h={extname:r,extn:s};return i&&(h.critical=!0),h},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var s=n[i].dpname.full,o=0;o<s.length;o++){var a=s[i];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map((function(t){return function(t){return t.map((function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")})).join("+")}(t).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var t,e,r,n,i=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var o=i.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+Ot.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+gt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+gt(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var u=r[a],h=f.asn1.x509.OID.oid2name(u.oid);""===h&&(h=u.oid);var c="";if(!0===u.critical&&(c="CRITICAL"),t+=" "+h+" "+c+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else if("keyUsage"===h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===h){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else{if("extKeyUsage"===h)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===h)t+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===h)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===h)t+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===h&&(t+=i(this.getExtCertificatePolicies()))}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):f.lang.String.isHex(t)&&this.readCertHex(t))}function Ht(t){return d.SHA256(t).toString()}Rt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},Rt.getL=function(t,e){var r=Rt.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},Rt.getVblen=function(t,e){var r;return""==(r=Rt.getL(t,e))?-1:("8"===r.substr(0,1)?new v(r.substr(2),16):new v(r,16)).intValue()},Rt.getVidx=function(t,e){var r=Rt.getLblen(t,e);return r<0?r:e+2*(r+1)},Rt.getV=function(t,e){var r=Rt.getVidx(t,e),n=Rt.getVblen(t,e);return t.substr(r,2*n)},Rt.getTLV=function(t,e){return t.substr(e,2)+Rt.getL(t,e)+Rt.getV(t,e)},Rt.getTLVblen=function(t,e){return 2+2*Rt.getLblen(t,e)+2*Rt.getVblen(t,e)},Rt.getNextSiblingIdx=function(t,e){return Rt.getVidx(t,e)+2*Rt.getVblen(t,e)},Rt.getChildIdx=function(t,e){var r,n,i,s=Rt,o=[];r=s.getVidx(t,e),n=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var u=s.getTLVblen(t,a);if((i+=u)<=n&&o.push(a),a+=u,i>=n)break}return o},Rt.getNthChildIdx=function(t,e,r){return Rt.getChildIdx(t,e)[r]},Rt.getIdxbyList=function(t,e,r,n){var i,s,o=Rt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[i],r,n)},Rt.getIdxbyListEx=function(t,e,r,n){var i,s,o=Rt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=o.getChildIdx(t,e);for(var a=0,u=0;u<s.length;u++){var h=t.substr(s[u],2);if("number"==typeof i&&!o.isContextTag(h)&&a==i||"string"==typeof i&&o.isContextTag(h,i))return o.getIdxbyListEx(t,s[u],r,n);o.isContextTag(h)||a++}return-1},Rt.getTLVbyList=function(t,e,r,n){var i=Rt,s=i.getIdxbyList(t,e,r,n);return-1==s||s>=t.length?null:i.getTLV(t,s)},Rt.getTLVbyListEx=function(t,e,r,n){var i=Rt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},Rt.getVbyList=function(t,e,r,n,i){var s,o,a=Rt;return-1==(s=a.getIdxbyList(t,e,r,n))||s>=t.length?null:(o=a.getV(t,s),!0===i&&(o=o.substr(2)),o)},Rt.getVbyListEx=function(t,e,r,n,i){var s,o,a=Rt;return-1==(s=a.getIdxbyListEx(t,e,r,n))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(o=o.substr(2)),o)},Rt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=Rt.getV(t,e);return"02"==n?parseInt(i,16):function(t){try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16),n=t.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(t){return-1}}(i)}catch(t){return r}},Rt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:function(t){if(!vt(t))return null;try{var e=[],r=t.substr(0,2),n=parseInt(r,16);e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40);for(var i=t.substr(2),s=[],o=0;o<i.length/2;o++)s.push(parseInt(i.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=yt((127&s[o]).toString(2),7):(u+=yt((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var h=e.join(".");return a.length>0&&(h=h+"."+a.join(".")),h}catch(t){return null}}(Rt.getV(t,e))}catch(t){return r}},Rt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=Rt.getOID(t,e,r);if(n==r)return r;var i=f.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},Rt.getString=function(t,e,r){null==r&&(r=null);try{return ut(Rt.getV(t,e))}catch(t){return r}},Rt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],h="";for(a=0;a<o.length;a++)128&o[a]?h+=e((127&o[a]).toString(2),7):(h+=e((127&o[a]).toString(2),7),u.push(new String(parseInt(h,2))),h="");var c=r.join(".");return u.length>0&&(c=c+"."+u.join(".")),c},Rt.dump=function(t,e,r,n){var i=Rt,s=i.getV,o=i.dump,a=i.getChildIdx,u=t;t instanceof f.asn1.ASN1Object&&(u=t.getEncodedHex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var c,l=e.ommit_long_octet;if("01"==(c=u.substr(r,2)))return"00"==(p=s(u,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==c)return n+"INTEGER "+h(p=s(u,r),l)+"\n";if("03"==c){var p=s(u,r);if(i.isASN1HEX(p.substr(2))){var d=n+"BITSTRING, encapsulates\n";return d+=o(p.substr(2),e,0,n+" ")}return n+"BITSTRING "+h(p,l)+"\n"}if("04"==c){p=s(u,r);if(i.isASN1HEX(p)){d=n+"OCTETSTRING, encapsulates\n";return d+=o(p,e,0,n+" ")}return n+"OCTETSTRING "+h(p,l)+"\n"}if("05"==c)return n+"NULL\n";if("06"==c){var v=s(u,r),g=f.asn1.ASN1Util.oidHexToInt(v),y=f.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=y?n+"ObjectIdentifier "+y+" ("+m+")\n":n+"ObjectIdentifier ("+m+")\n"}if("0a"==c)return n+"ENUMERATED "+parseInt(s(u,r))+"\n";if("0c"==c)return n+"UTF8String '"+at(s(u,r))+"'\n";if("13"==c)return n+"PrintableString '"+at(s(u,r))+"'\n";if("14"==c)return n+"TeletexString '"+at(s(u,r))+"'\n";if("16"==c)return n+"IA5String '"+at(s(u,r))+"'\n";if("17"==c)return n+"UTCTime "+at(s(u,r))+"\n";if("18"==c)return n+"GeneralizedTime "+at(s(u,r))+"\n";if("1a"==c)return n+"VisualString '"+at(s(u,r))+"'\n";if("1e"==c)return n+"BMPString '"+dt(s(u,r))+"'\n";if("30"==c){if("3000"==u.substr(r,4))return n+"SEQUENCE {}\n";d=n+"SEQUENCE\n";var x=e;if((2==(E=a(u,r)).length||3==E.length)&&"06"==u.substr(E[0],2)&&"04"==u.substr(E[E.length-1],2)){y=i.oidname(s(u,E[0]));var b=JSON.parse(JSON.stringify(e));b.x509ExtName=y,x=b}for(var S=0;S<E.length;S++)d+=o(u,x,E[S],n+" ");return d}if("31"==c){d=n+"SET\n";var E=a(u,r);for(S=0;S<E.length;S++)d+=o(u,e,E[S],n+" ");return d}if(0!=(128&(c=parseInt(c,16)))){var w=31&c;if(0!=(32&c)){for(d=n+"["+w+"]\n",E=a(u,r),S=0;S<E.length;S++)d+=o(u,e,E[S],n+" ");return d}p=s(u,r);if(Rt.isASN1HEX(p)){var d=n+"["+w+"]\n";return d+=o(p,e,0,n+" ")}return("68747470"==p.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==w)&&(p=at(p)),d=n+"["+w+"] "+p+"\n"}return n+"UNKNOWN("+c+") "+s(u,r)+"\n"},Rt.isContextTag=function(t,e){var r,n;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},Rt.isASN1HEX=function(t){var e=Rt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},Rt.checkStrictDER=function(t,e,r,n,i){var s=Rt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!f.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>n)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),u=a.length-2-s.getL(t,e).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var h=t.substr(e,2);if("02"===h){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=s.getVblen(t,e),p=0,d=s.getChildIdx(t,e),v=0;v<d.length;v++){p+=s.getTLV(t,d[v]).length,s.checkStrictDER(t,d[v],r,n,i)}if(2*l!=p)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+p)}},Rt.oidname=function(t){var e=f.asn1;f.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==f.asn1&&f.asn1||(f.asn1={}),void 0!==f.asn1.x509&&f.asn1.x509||(f.asn1.x509={}),f.asn1.x509.Certificate=function(t){f.asn1.x509.Certificate.superclass.constructor.call(this);var e=f.asn1,r=e.DERBitString,n=e.DERSequence,i=e.x509,s=i.TBSCertificate,o=i.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.getEncodedHex(),n=new f.crypto.Signature({alg:e});n.init(t.cakey),n.updateHex(r),t.sighex=n.sign()},this.getPEM=function(){return lt(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).getEncodedHex()},null!=t&&(this.params=t)},mt(f.asn1.x509.Certificate,f.asn1.ASN1Object),f.asn1.x509.TBSCertificate=function(t){f.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=f.asn1,r=e.x509,n=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,u=r.X500Name,h=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new n({obj:new i({int:r})});t.push(l)}return t.push(new i(e.serial)),t.push(new o({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new u(e.subject)),t.push(new c(Dt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new n({tag:"a3",obj:new h(e.ext)})),new f.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.TBSCertificate,f.asn1.ASN1Object),f.asn1.x509.Extensions=function(t){f.asn1.x509.Extensions.superclass.constructor.call(this);var e=f.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var i=this.aParam[e],s=i.extname,o=null;if(null!=i.extn)o=new n.PrivateExtension(i);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(i);else if("keyUsage"==s)o=new n.KeyUsage(i);else if("subjectAltName"==s)o=new n.SubjectAltName(i);else if("issuerAltName"==s)o=new n.IssuerAltName(i);else if("basicConstraints"==s)o=new n.BasicConstraints(i);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(i);else if("certificatePolicies"==s)o=new n.CertificatePolicies(i);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(i);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(i);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(i);else if("cRLNumber"==s)o=new n.CRLNumber(i);else if("cRLReason"==s)o=new n.CRLReason(i);else if("ocspNonce"==s)o=new n.OCSPNonce(i);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(i);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(i);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(i));o=new n.SubjectDirectoryAttributes(i)}null!=o&&t.push(o)}return new r({array:t}).getEncodedHex()},null!=t&&this.setByParam(t)},mt(f.asn1.x509.Extensions,f.asn1.ASN1Object),f.asn1.x509.Extension=function(t){f.asn1.x509.Extension.superclass.constructor.call(this);var e=f.asn1,r=e.DERObjectIdentifier,n=e.DEROctetString;e.DERBitString;var i=e.DERBoolean,s=e.DERSequence;this.getEncodedHex=function(){var t=new r({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new i),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},mt(f.asn1.x509.Extension,f.asn1.ASN1Object),f.asn1.x509.KeyUsage=function(t){f.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Ot.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new f.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var r=t.names,n="000000000",i=0;i<r.length;i++)for(var s=0;s<e.length;s++)r[i]===e[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new f.asn1.DERBitString({bin:n})}},mt(f.asn1.x509.KeyUsage,f.asn1.x509.Extension),f.asn1.x509.BasicConstraints=function(t){f.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},mt(f.asn1.x509.BasicConstraints,f.asn1.x509.Extension),f.asn1.x509.CRLDistributionPoints=function(t){f.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=f.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var n=[],i=0;i<t.length;i++)if(t[i]instanceof f.asn1.ASN1Object)n.push(t[i]);else{var s=new r.DistributionPoint(t[i]);n.push(s)}this.asn1ExtnValue=new e.DERSequence({array:n})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},mt(f.asn1.x509.CRLDistributionPoints,f.asn1.x509.Extension),f.asn1.x509.DistributionPoint=function(t){f.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=f.asn1,r=e.x509.DistributionPointName;this.getEncodedHex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},mt(f.asn1.x509.DistributionPoint,f.asn1.ASN1Object),f.asn1.x509.DistributionPointName=function(t){f.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=f.asn1,r=e.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},mt(f.asn1.x509.DistributionPointName,f.asn1.ASN1Object),f.asn1.x509.CertificatePolicies=function(t){f.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=f.asn1,r=e.x509,n=e.DERSequence,i=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var r=new n({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},mt(f.asn1.x509.CertificatePolicies,f.asn1.x509.Extension),f.asn1.x509.PolicyInformation=function(t){f.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,i=e.x509.PolicyQualifierInfo;this.params=null,this.getEncodedHex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new i(this.params.array[s]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.PolicyInformation,f.asn1.ASN1Object),f.asn1.x509.PolicyQualifierInfo=function(t){f.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},mt(f.asn1.x509.PolicyQualifierInfo,f.asn1.ASN1Object),f.asn1.x509.UserNotice=function(t){f.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=f.asn1.DERSequence;f.asn1.DERInteger;var r=f.asn1.x509.DisplayText,n=f.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.UserNotice,f.asn1.ASN1Object),f.asn1.x509.NoticeReference=function(t){f.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=f.asn1.DERSequence,r=f.asn1.DERInteger,n=f.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,o=0;o<s.length;o++)i.push(new r(s[o]));t.push(new e({array:i}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.NoticeReference,f.asn1.ASN1Object),f.asn1.x509.DisplayText=function(t){f.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},mt(f.asn1.x509.DisplayText,f.asn1.DERAbstractString),f.asn1.x509.ExtKeyUsage=function(t){f.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=f.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var n=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},mt(f.asn1.x509.ExtKeyUsage,f.asn1.x509.Extension),f.asn1.x509.AuthorityKeyIdentifier=function(t){f.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=f,r=e.asn1,n=r.DERTaggedObject,i=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new n({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new f.asn1.DEROctetString(t);else if("object"==typeof t&&f.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Dt.getKey(t));var r=Dt.getKeyID(e);this.asn1KID=new f.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new f.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new f.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new f.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new Ot;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new f.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},mt(f.asn1.x509.AuthorityKeyIdentifier,f.asn1.x509.Extension),f.asn1.x509.SubjectKeyIdentifier=function(t){f.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=f.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&f.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Dt.getKey(t));var n=Dt.getKeyID(r);this.asn1KID=new f.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},mt(f.asn1.x509.SubjectKeyIdentifier,f.asn1.x509.Extension),f.asn1.x509.AuthorityInfoAccess=function(t){f.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=f.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,u=t[o];if(void 0!==u.ocsp)a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:u.ocsp})]});else{if(void 0===u.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(u));a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}e.push(a)}this.asn1ExtnValue=new n({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},mt(f.asn1.x509.AuthorityInfoAccess,f.asn1.x509.Extension),f.asn1.x509.SubjectAltName=function(t){f.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new f.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},mt(f.asn1.x509.SubjectAltName,f.asn1.x509.Extension),f.asn1.x509.IssuerAltName=function(t){f.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new f.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},mt(f.asn1.x509.IssuerAltName,f.asn1.x509.Extension),f.asn1.x509.SubjectDirectoryAttributes=function(t){f.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.ASN1Util.newObject,i=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new n(o))}var a=new r({array:t});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},mt(f.asn1.x509.SubjectDirectoryAttributes,f.asn1.x509.Extension),f.asn1.x509.PrivateExtension=function(t){f.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=f,r=e.lang.String.isHex,n=e.asn1,i=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=i(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return s(t).getEncodedHex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},mt(f.asn1.x509.PrivateExtension,f.asn1.x509.Extension),f.asn1.x509.CRL=function(t){f.asn1.x509.CRL.superclass.constructor.call(this);var e=f.asn1,r=e.DERSequence,n=e.DERBitString,i=e.x509,s=i.AlgorithmIdentifier,o=i.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).getEncodedHex(),e=new f.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return lt(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).getEncodedHex()},null!=t&&(this.params=t)},mt(f.asn1.x509.CRL,f.asn1.ASN1Object),f.asn1.x509.TBSCertList=function(t){f.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=f.asn1,r=e.DERInteger,n=e.DERSequence,i=e.DERTaggedObject;e.DERObjectIdentifier;var s=e.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,h=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,i=0;i<e.length;i++){var s=[new r(e[i].sn),new a(e[i].date)];null!=e[i].ext&&s.push(new u(e[i].ext)),t.push(new n({array:s}))}return new n({array:t})},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new r({int:s});t.push(c)}if(t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new u(e.ext);t.push(new i({tag:"a0",explicit:!0,obj:l}))}return new n({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.TBSCertList,f.asn1.ASN1Object),f.asn1.x509.CRLEntry=function(t){f.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=f.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},mt(f.asn1.x509.CRLEntry,f.asn1.ASN1Object),f.asn1.x509.CRLNumber=function(t){f.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},mt(f.asn1.x509.CRLNumber,f.asn1.x509.Extension),f.asn1.x509.CRLReason=function(t){f.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},mt(f.asn1.x509.CRLReason,f.asn1.x509.Extension),f.asn1.x509.OCSPNonce=function(t){f.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},mt(f.asn1.x509.OCSPNonce,f.asn1.x509.Extension),f.asn1.x509.OCSPNoCheck=function(t){f.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},mt(f.asn1.x509.OCSPNoCheck,f.asn1.x509.Extension),f.asn1.x509.AdobeTimeStamp=function(t){f.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERInteger,n=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new n(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.AdobeTimeStamp,f.asn1.x509.Extension),f.asn1.x509.X500Name=function(t){f.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=f.asn1,r=e.x509,n=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var i=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))i.push(r[s]);else{var o=i.length-1;i[o]=i[o]+"/"+r[s]}for(s=0;s<i.length;s++)this.asn1Array.push(new n({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var n=r.X500Name.ldapToCompat(t);this.setByString(n,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var i=new n({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(i):this.asn1Array=[i]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new Ot).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new Ot).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new n(r);this.asn1Array.push(i)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.X500Name,f.asn1.ASN1Object),f.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),(e=e.map((function(t){return t.replace(/,/,"\\,")}))).join(",")},f.asn1.x509.X500Name.onelineToLDAP=function(t){return f.asn1.x509.X500Name.compatToLDAP(t)},f.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},f.asn1.x509.X500Name.ldapToOneline=function(t){return f.asn1.x509.X500Name.ldapToCompat(t)},f.asn1.x509.RDN=function(t){f.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=f.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new f.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=f.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var n=new e(r);this.asn1Array.push(n)}var i=new f.asn1.DERSet({array:this.asn1Array});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.RDN,f.asn1.ASN1Object),f.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,u=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===a){var h=u.pop();if(s.match(/"$/)){o=(h+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(h+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},f.asn1.x509.AttributeTypeAndValue=function(t){f.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=f,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,h=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=f.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.AttributeTypeAndValue,f.asn1.ASN1Object),f.asn1.x509.SubjectPublicKeyInfo=function(t){f.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=f,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,u=r.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof $){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof f.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof f.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:r});var o=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},mt(f.asn1.x509.SubjectPublicKeyInfo,f.asn1.ASN1Object),f.asn1.x509.Time=function(t){f.asn1.x509.Time.superclass.constructor.call(this);var e=f.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},mt(f.asn1.x509.Time,f.asn1.ASN1Object),f.asn1.x509.AlgorithmIdentifier=function(t){f.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=f.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},mt(f.asn1.x509.AlgorithmIdentifier,f.asn1.ASN1Object),f.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},f.asn1.x509.GeneralName=function(t){f.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},r=f.asn1;r.DERSequence;var n=r.DEROctetString,i=r.DERIA5String,s=r.DERTaggedObject,o=r.ASN1Object,a=r.x509.X500Name,u=ft;this.explicit=!1,this.setByParam=function(t){var r=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",r=new i({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",r=new i({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",r=new i({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,r="string"==typeof t.dn?new a({str:t.dn}):t.dn instanceof f.asn1.x509.X500Name?t.dn:new a(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,r=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var h=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certissuer param not cert";(p=new Ot).hex=h;var c=p.getIssuerHex();(r=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,p;h=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certsubj param not cert";(p=new Ot).hex=h;c=p.getSubjectHex();(r=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,v=t.ip,g="malformed IP address";if(v.match(/^[0-9.]+[.][0-9.]+$/)){if(d=function(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,r){var n=parseInt(t);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}}("["+v.split(".").join(",")+"]"),8!==d.length)throw g}else if(v.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=function(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var n=":".repeat(7-r+2),i=(t=t.replace("::",n)).split(":");if(8!=i.length)throw e;for(var s=0;s<8;s++)i[s]=("0000"+i[s]).slice(-4);return i.join("")}(v);else{if(!v.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw g;d=v}r=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:r})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.GeneralName,f.asn1.ASN1Object),f.asn1.x509.GeneralNames=function(t){f.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=f.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var n=new e.x509.GeneralName(t[r]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new e.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},mt(f.asn1.x509.GeneralNames,f.asn1.ASN1Object),f.asn1.x509.OID=new function(t){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1"},this.objCache={},this.name2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],r=new f.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];var e;if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw"AttributeType name undefined: "+t;e=this.name2oidList[t]}var r=new f.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r}},f.asn1.x509.OID.oid2name=function(t){var e=f.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},f.asn1.x509.OID.oid2atype=function(t){var e=f.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},f.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=f.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},f.asn1.x509.X509Util={},f.asn1.x509.X509Util.newCertPEM=function(t){var e=f.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},$.getPosArrayOfChildrenFromHex=function(t){return Rt.getChildIdx(t,0)},$.getHexValueArrayOfChildrenFromHex=function(t){var e,r=Rt.getV,n=r(t,(e=$.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),u=r(t,e[5]),h=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(n,i,s,o,a,u,h,c,l),e},$.prototype.readPrivateKeyFromPEMString=function(t){var e=ft(t),r=$.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},$.prototype.readPKCS5PrvKeyHex=function(t){var e=$.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},$.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,o,a,u,h=Rt,c=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),u=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,o,a,u)},$.prototype.readPKCS5PubKeyHex=function(t){var e=Rt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},$.prototype.readPKCS8PubKeyHex=function(t){var e=Rt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},$.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new Ot).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},$.prototype.sign=function(t,e){var r,n=(r=t,f.crypto.Util.hashString(r,e));return this.signWithMessageHash(n,e)},$.prototype.signWithMessageHash=function(t,e){var r=X(f.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Tt(this.doPrivate(r).toString(16),this.n.bitLength())},$.prototype.signPSS=function(t,e,r){var n,i=(n=ht(t),f.crypto.Util.hashHex(n,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},$.prototype.signWithMessageHashPSS=function(t,e,r){var n,i=ut(t),s=i.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(t){return f.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var h="";r>0&&(h=new Array(r),(new W).nextBytes(h),h=String.fromCharCode.apply(String,h));var c=ut(u(ht("\0\0\0\0\0\0\0\0"+i+h))),l=[];for(n=0;n<a-r-s-2;n+=1)l[n]=0;var p=String.fromCharCode.apply(String,l)+""+h,d=Ct(c,p.length,u),g=[];for(n=0;n<p.length;n+=1)g[n]=p.charCodeAt(n)^d.charCodeAt(n);var y=65280>>8*a-o&255;for(g[0]&=~y,n=0;n<s;n++)g.push(c.charCodeAt(n));return g.push(188),Tt(this.doPrivate(new v(g)).toString(16),this.n.bitLength())},$.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=X(e,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=It(i.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=t,f.crypto.Util.hashString(o,a))},$.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=X(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=It(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==t)},$.prototype.verifyPSS=function(t,e,r,n){var i=function(t){return f.crypto.Util.hashHex(t,r)}(ht(t));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,e,r,n)},$.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new v(e,16),o=function(t){return f.crypto.Util.hashHex(t,r)},a=ut(t),u=a.length,h=this.n.bitLength()-1,c=Math.ceil(h/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=c-u-2;else if(n<-2)throw new Error("invalid salt length");if(c<u+n+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(i=0;i<l.length;i+=1)l[i]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var p=(l=String.fromCharCode.apply(String,l)).substr(0,c-u-1),d=l.substr(p.length,u),g=65280>>8*c-h&255;if(0!=(p.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var y=Ct(d,p.length,o),m=[];for(i=0;i<p.length;i+=1)m[i]=p.charCodeAt(i)^y.charCodeAt(i);m[0]&=~g;var x=c-u-n-2;for(i=0;i<x;i+=1)if(0!==m[i])throw new Error("leftmost octets not zero");if(1!==m[x])throw new Error("0x01 marker not found");return d===ut(o(ht("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,m.slice(-n)))))},$.SALT_LEN_HLEN=-1,$.SALT_LEN_MAX=-2,$.SALT_LEN_RECOVER=-2,Ot.hex2dn=function(t,e){void 0===e&&(e=0);var r=new Ot;return Rt.getTLV(t,e),r.getX500Name(t).str},Ot.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,n=Rt.getChildIdx(t,e),i=0;i<n.length;i++)r.push(Ot.hex2attrTypeValue(t,n[i]));return(r=r.map((function(t){return t.replace("+","\\+")}))).join("+")},Ot.hex2attrTypeValue=function(t,e){var r=Rt,n=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(t,e);2!==i.length||t.substr(i[0],2);var s=n(t,i[0]),o=f.asn1.ASN1Util.oidHexToInt(s);return f.asn1.x509.OID.oid2atype(o)+"="+ut(n(t,i[1]))},Ot.getPublicKeyFromCertHex=function(t){var e=new Ot;return e.readCertHex(t),e.getPublicKey()},Ot.getPublicKeyFromCertPEM=function(t){var e=new Ot;return e.readCertPEM(t),e.getPublicKey()},Ot.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,n=Rt.getVbyList,i={};return i.algparam=null,(e=new Ot).readCertPEM(t),r=e.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},Ot.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var _t,Bt=[(_t=new Ot,_t.readCertPEM(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@\tPPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\\QN>Z\tN\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@ebN[bqx=ng?\tS^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFoFgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP\tP>}A^VP}Ex\bUZa=syDw}>Ya8wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr\tsof[wA}e{\\z}w[YDQ|dt=wC\tNvbRZ@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`N\0RXt^Z}vEpdC=\bY?=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac\tZ\tguf\bF]DCP?znNYf\tuaYu[`=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB\tD8{B>\\sPYbEU\tFQXz\0@`zsqgfD\0[WY\bPeZc}\t\0bx?Rfed}BUe|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YBY`Ffg=sY>{t<fu]xrFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=EnO}Pud8TA\t?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V\tOUwY=>X[\\E`tW[8}VwpFBQcnrPF}yUtd8<Doe_\b[oOVUep@pYY\0cegY{r\t?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<StX\tNx\0\b\t\0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V\tCVrRVtAAc[\tQp|d|tqoQ=T|XX\t=u\\N8XNCx\\aU>wz\tX<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ\tP\bZ\b\\YNNSZ_\\w^|TsD8db\t_\tY\\o^Cw>Z\0x\\^aN]wWf\bA}\tC^d_{ZC@\by]gY@E\tBFY?OsaqbDcVgQbZeFc\tovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z\tZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),_t)];function Vt(t,e){var r=t.getIssuerHex();if(r===t.getSubjectHex())return t.verifySignature(t.getPublicKey());var n=function(t,e){for(var r=0,n=e;r<n.length;r++){var i=n[r];if(i.getSubjectHex()===t)return i}}(r,e);return!!n&&(!1!==t.verifySignature(n.getPublicKey())&&Vt(n,e))}function jt(t){return t.getIssuerHex()!==t.getSubjectHex()&&Vt(t,Bt)}!function(t){var e=new Ot;"string"==typeof t?e.readCertPEM(t):e.readCertHex(t.hex);var r=jt(e);Bt.push(e)}(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU\tPPONrtNVONtVWNW=_SVw\tVE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ\t[QSnS=\b[aNBZQZ\\aZ\t[QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tRbZOVTN>bRPtYoTyuoz}}f`Bwo?=RQN\\Ot[cONZO>Wyfd\tgdbRaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdyndB{^T}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F\tSAe`tn[t\tu\b8^a]qx\bE_^ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQFO=Yw\0_TePCOFV@|N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{]\tb=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r\tAo\0\tF`fdzCnRtq\br\t\b8eBp=Z\\TRaadc}@Eub`quuNqAdF\0aUay{}x>tgVz`\t_YBFwu_q?egt8v[o\x008\twTQcrA\t<z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw\tXDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYPdWV]OE^\bOFwA}<uXoO}_NDz8aonzWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT|\tOZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO\td_D}eBb?Uq^b\t[y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zUxOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`FyWadZcAD\tpeXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx\ta[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef`\t?^x>X}esa{>\\r?eE]CC_cZ[vQs\t\t>gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC>>gvb}ACd\t``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc\tXSq\t{\0DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy\tRNRg@NZCaaq8?`\t^`?ryD\t=obzw?E]Ou]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug8^f[YQAWad8FNqxFQE?ZOo\t}RnO\bsQc\txyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var qt=function(t,e){return qt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},qt(t,e)};function zt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}qt(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var kt=function(){return kt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},kt.apply(this,arguments)};function Kt(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}var Lt,Mt,Ut,Ft,Yt=function(){function t(t,e,r){this.x=t,this.y=e,this.z=r}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},t.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){var e=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-r*t.x,this},t.prototype.crossVectors=function(t,e){var r=t.x,n=t.y,i=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*s-r*a,this.z=r*o-n*s,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t}(),Qt=function(){function t(t,e,r,n){this.extents=t,this.startIndex=e,this.endIndex=r,this.level=n,this.node0=null,this.node1=null}return t.prototype.clearShapes=function(){this.startIndex=-1,this.endIndex=-1},t}(),Zt=(Lt=new Yt(0,0,0),Mt=new Yt(0,0,0),Ut=new Yt(0,0,0),Ft=new Yt(0,0,0),function(t,e,r,n,i,s){Mt.subVectors(e,t),Ut.subVectors(r,t),Ft.crossVectors(Mt,Ut);var o,a=i.dot(Ft);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Lt.subVectors(n,t);var u=o*i.dot(Ut.crossVectors(Lt,Ut));if(u<0)return null;var h=o*i.dot(Mt.cross(Lt));if(h<0)return null;if(u+h>a)return null;var c=-o*Lt.dot(Ft);if(c<0)return null;var l=c/a;return new Yt(0,0,0).copy(i).multiplyScalar(l).add(n)}),Gt=function(t,e){this.min=t,this.max=e};function Wt(t,e,r){var n=new Gt(0,0);e.x>=0?(n.min=(r.extents[0]-t.x)*e.x,n.max=(r.extents[3]-t.x)*e.x):(n.min=(r.extents[3]-t.x)*e.x,n.max=(r.extents[0]-t.x)*e.x);var i=new Gt(0,0);if(e.y>=0?(i.min=(r.extents[1]-t.y)*e.y,i.max=(r.extents[4]-t.y)*e.y):(i.min=(r.extents[4]-t.y)*e.y,i.max=(r.extents[1]-t.y)*e.y),n.min>i.max||i.min>n.max)return!1;i.min>n.min&&(n.min=i.min),i.max<n.max&&(n.max=i.max);var s=new Gt(0,0);return e.z>=0?(s.min=(r.extents[2]-t.z)*e.z,s.max=(r.extents[5]-t.z)*e.z):(s.min=(r.extents[5]-t.z)*e.z,s.max=(r.extents[2]-t.z)*e.z),!(n.min>s.max||s.min>n.max)&&(s.min>n.min&&(n.min=s.min),s.max<n.max&&(n.max=s.max),!(n.max<0))}var Xt=[0,0,0,0,0,0];function Jt(t,e,r,n,i){if(r>=n)return Xt;var s,o=r,a=6*t[o],u=e[a],h=e[a+1],c=e[a+2],l=e[a+3],f=e[a+4],p=e[a+5];for(++o;o<n;o++)(s=e[a=6*t[o]])<u&&(u=s),(s=e[a+1])<h&&(h=s),(s=e[a+2])<c&&(c=s),(s=e[a+3])>l&&(l=s),(s=e[a+4])>f&&(f=s),(s=e[a+5])>p&&(p=s);return[u-i,h-i,c-i,l+i,f+i,p+i]}var $t=function(t,e,r){this.triangle=t,this.triangleIndex=e,this.intersectionPoint=r},te=function(){function t(t,e){this.trianglesArray=t,this.maxTrianglesPerNode=e;var r,n,i,s,o,a,u=t.length/9,h=new Uint32Array(u),c=new Float32Array(6*u);r=s=t[0],n=o=t[1],i=a=t[2];for(var l=0,f=void 0,p=void 0,d=void 0,v=void 0,g=void 0,y=void 0,m=void 0,x=void 0,b=void 0;l<u;l++)x=6*l,f=v=t[b=9*l],(m=t[b+3])<f?f=m:m>v&&(v=m),(m=t[b+6])<f?f=m:m>v&&(v=m),f<r&&(r=f),v>s&&(s=v),p=g=t[b+1],(m=t[b+4])<p?p=m:m>g&&(g=m),(m=t[b+7])<p?p=m:m>g&&(g=m),p<n&&(n=p),g>o&&(o=g),d=y=t[b+2],(m=t[b+5])<d?d=m:m>y&&(y=m),(m=t[b+8])<d?d=m:m>y&&(y=m),d<i&&(i=d),y>a&&(a=y),h[l]=l,c[x]=f,c[x+1]=p,c[x+2]=d,c[x+3]=v,c[x+4]=g,c[x+5]=y;this.offsetArray=h,this.bboxArray=c,this.rootNode=new Qt([r,n,i,s,o,a],0,u,0),this.nodesToSplit=[],u>this.maxTrianglesPerNode&&this.nodesToSplit.push(this.rootNode),this.splitNode()}return t.prototype.splitNode=function(){var t,e=this.offsetArray,r=this.bboxArray,n=this.maxTrianglesPerNode,i=this.nodesToSplit;function s(t){var s=t.startIndex,o=t.endIndex,a=t.extents,u=[0,1,2],h=[a[3]-a[0],a[4]-a[1],a[5]-a[2]];u.sort((function(t,e){return h[e]-h[t]}));for(var c=0;c<3;c++){for(var l=u[c],f=a[l]+a[l+3],p=s,d=o-1,v=null;p<d;)null===v?r[6*e[p]+l]+r[6*e[p]+l+3]<f?p++:v=e[p]:(r[6*e[d]+l]+r[6*e[d]+l+3]>=f||(e[p]=e[d],e[d]=v,v=null,p++),d--);if(!(p<=s)){var g=Jt(e,r,s,p,1e-6),y=new Qt(g,s,p,t.level+1);t.node0=y,y.endIndex-y.startIndex>n&&i.push(y);var m=Jt(e,r,p,o,1e-6),x=new Qt(m,p,o,t.level+1);return t.node1=x,x.endIndex-x.startIndex>n&&i.push(x),void t.clearShapes()}}}for(;t=i.shift();)s(t)},t.prototype.intersectRay=function(t,e,r){for(var n=[this.rootNode],i=[],s=[],o=new Yt(1/e.x,1/e.y,1/e.z);n.length>0;){var a=n.pop();if(Wt(t,o,a)){a.node0&&n.push(a.node0),a.node1&&n.push(a.node1);for(var u=a.startIndex;u<a.endIndex;u++)i.push(this.offsetArray[u])}}for(var h=new Yt(0,0,0),c=new Yt(0,0,0),l=new Yt(0,0,0),f=new Yt(t.x,t.y,t.z),p=new Yt(e.x,e.y,e.z),d=(u=0,void 0),v=void 0;u<i.length;u++){v=9*(d=i[u]),h.set(this.trianglesArray[v],this.trianglesArray[v+1],this.trianglesArray[v+2]),c.set(this.trianglesArray[v+3],this.trianglesArray[v+3+1],this.trianglesArray[v+3+2]),l.set(this.trianglesArray[v+6],this.trianglesArray[v+6+1],this.trianglesArray[v+6+2]);var g=Zt(h,c,l,f,p,r);if(g){var y=new $t([h.clone(),c.clone(),l.clone()],d,g);s.push(y)}}return s},t.prototype.dispose=function(){this.trianglesArray=new Float32Array,this.bboxArray=new Float32Array,this.offsetArray=new Uint32Array,this.rootNode=null,this.nodesToSplit.length=0},t}(),ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return zt(e,t),e}(o.Mesh);function re(t,e){for(var r=0,n=t.children;r<n.length;r++){var i=n[r];!1!==e(i)&&re(i,e)}}function ne(){}var ie=new o.BoxBufferGeometry(1,1,1,1,1);ie.deleteAttribute("uv"),ie.deleteAttribute("normal"),ie.groups=[],ie.scale(-1,1,1);var se,oe=new o.ShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\nvarying vec3 worldPosition;\nvoid main() {\n vec4 transform = vec4(position, 1.0);\n worldPosition = (modelMatrix * transform).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * transform;\n}\n",fragmentShader:"\nuniform samplerCube map;\nvarying vec3 worldPosition;\nvoid main() {\n gl_FragColor = textureCube(map, worldPosition);\n}\n",depthTest:!1,depthWrite:!1,stencilWrite:!1,blending:o.NoBlending,lights:!1});function ae(t,e,r){var n=new o.Scene,i=new o.Mesh(ie,oe);oe.uniforms.map.value=t,n.add(i);var s=r.autoClear;r.autoClear=!1,new o.CubeCamera(.1,2,e).update(r,n),r.autoClear=s,oe.uniforms.map.value=null}var ue=null!==(se=Math.SQRT1_2)&&void 0!==se?se:Math.sqrt(2),he={up:new o.Quaternion(ue,0,0,ue),down:new o.Quaternion(-ue,0,0,ue),left:new o.Quaternion(0,ue,0,ue),right:new o.Quaternion(0,-ue,0,ue),front:new o.Quaternion(0,0,0,1),back:new o.Quaternion(0,1,0,0)},ce=function(){var t=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),e=new Float32Array([0,0,1,0,0,1,1,1]),r=new Uint8Array([0,1,2,1,3,2]),n=new o.BufferGeometry;return n.setAttribute("position",new o.BufferAttribute(t,3)),n.setAttribute("uv",new o.BufferAttribute(e,2)),n.setIndex(new o.BufferAttribute(r,1)),n}();var le,fe=(le="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<".concat(le,">$"):Symbol(le));function pe(t){return t[fe]||(t[fe]={}),t[fe]}var de=function(){function t(){}return t.prototype.hasListener=function(t){var e=pe(this);return e&&e[t]&&e[t].length>0},t.prototype.on=function(t,e,r){var n=this,i=pe(this);return i[t]||(i[t]=[]),i[t].push([e,r||!1]),function(){return n.off(t,e)}},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.off=function(t,e){if(void 0!==t){var r,n=pe(this);if(n[t]||(n[t]=[]),void 0!==e){for(var i=0;i<n[t].length&&n[t][i][0]!==e;i++);i<n[t].length&&n[t].splice(i,1)}else n[t].length=0}else(r=this)[fe]||delete r[fe]},t.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=!1,i=pe(this),s=i[t]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],h=u[0],c=u[1],l=void 0!==c&&c,f=h.apply(void 0,e);l&&this.off(t,h),!1===f&&(n=!0)}return n},t}(),ve="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),ge="undefined"!=typeof performance?function(){return ve+performance.now()}:function(){return Date.now()};function ye(t){Object.freeze(t);var e="function"==typeof t,r=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(t).forEach((function(n){!r.call(t,n)||e&&("caller"===n||"callee"===n||"arguments"===n)||null===t[n]||"object"!=typeof t[n]&&"function"!=typeof t[n]||Object.isFrozen(t[n])||ye(t[n])})),t}var me=/^([^.]+)(\.([^.]+))*$/;function xe(t,e){return me.test(t)&&me.test(e)&&function(t,e){if("*"===t)return!0;var r=t.split(".").reverse(),n=e.split(".").reverse();if(r.length<=1)return t===e;for(var i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(t,e)}var be=ye(JSON.parse(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/pnyp{|qr;vr/j")));!function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request proxy error(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}zt(e,t)}(Error),function(t){function e(e,r,n){var i=t.call(this,"[NETWORK]: response error(type: ".concat(r,", status: ").concat(n,"): ").concat(e))||this;return i.httpStatus=n,i}zt(e,t)}(Error),function(t){function e(e,r){return t.call(this,"[NETWORK]: request abort(type: ".concat(r,"): ").concat(e))||this}zt(e,t)}(Error),function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request timeout(type: ".concat(r,", timeout: ").concat(n,"ms): ").concat(e))||this}zt(e,t)}(Error),function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request forbidden(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}zt(e,t)}(Error),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}zt(e,t)}(de);var Se=function(){if("undefined"!=typeof window){var t=window;return t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(t){return setTimeout(t,16)}}return function(t){return setTimeout(t,16)}}(),Ee=16;!function(){function t(){this.frames=[],this.stoped=!1,this.time=ge(),this.context=null,this.loop=this.loop.bind(this),this.loop()}Object.defineProperty(t,"shared",{get:function(){return this.sharedInstance||(this.sharedInstance=new t),this.sharedInstance},enumerable:!1,configurable:!0}),t.getFrameTime=function(){return Ee},t.prototype.loop=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!this.stoped){var r=ge(),n=r-this.time;this.time=r;var i=[];Ee=n;for(var s=0,o=this.frames;s<o.length;s++){var a=o[s];if(a.delay>0)a.delay=a.delay-1;else{try{a.callback.apply(a,Kt([r,n],t,!1))}catch(t){console.error(t)}a.once&&i.push(a)}}i.length>0&&(this.frames=this.frames.filter((function(t){return-1===i.indexOf(t)}))),this.requestAnimationFrame(this.loop)}},t.prototype.setContext=function(t){this.cancelAnimationFrame(this.requestId),this.context=t,this.requestId=this.requestAnimationFrame(this.loop)},t.prototype.getContext=function(){return this.context},t.prototype.requestAnimationFrame=function(t){return this.context?this.context.requestAnimationFrame(t):Se(t)},t.prototype.cancelAnimationFrame=function(t){this.context?this.context.cancelAnimationFrame(t):function(t){var e;if("undefined"!=typeof window){var r=window;e=r.cancelAnimationFrame||r.mozCancelAnimationFrame||r.webkitCancelAnimationFrame||r.msCancelAnimationFrame||function(t){return window.clearTimeout(t)}}else e=function(t){return window.clearTimeout(t)};e(t)}(this.loop),this.requestId=null},t.prototype.remove=function(t){var e=this.frames.indexOf(t);e>=0&&this.frames.splice(e,1)},t.prototype.add=function(t,e,r,n){var i=this;void 0===e&&(e=!1),void 0===r&&(r=0),void 0===n&&(n=5);var s={callback:t,once:e,delay:r,order:n};return this.frames.push(s),this.frames.sort((function(t,e){return t.order-e.order})),function(){return i.remove(s)}},t.prototype.disponse=function(){this.stoped=!0,this.frames.length=0}}(),new o.WebGLRenderTarget(1,1),new o.OrthographicCamera(-1,1,1,-1,0,1);var we=new o.BufferGeometry;we.setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),we.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2));var Ae,Pe=new o.Mesh(we);(new o.Scene).add(Pe),new o.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0));\n }\n ",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1}),new o.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform samplerCube map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0, 0));\n }\n ",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1});var Ne=3,De=33779;(Ae={})[2]=33776,Ae[Ne]=De;Object.assign(window,{cubeRenderTargetPool:[]});var Re=function(){function t(t,e,r,n,i){this.tileTree=e,this.tileSources=r,this.options=n,this.renderer=i,this.name="",this.needsRender=!1,this.disposed=!1,this.loadedCubeNodes=new Set,this.loadingCubeNodes=new Set,this.baseCubeTexture=null,this._cubeRenderTarget=null,this.textures=[],this.baseCubeTexture=t}return Object.defineProperty(t.prototype,"cubeRenderTarget",{get:function(){return this._cubeRenderTarget},set:function(t){var e,r,n,i,s;if(null===t)throw new Error("cannot set cubeRenderTarget to null.");t.width!==this.options.textureSize&&t.setSize(this.options.textureSize,this.options.textureSize),t.texture.format=null!==(e=this.options.format)&&void 0!==e?e:o.RGBAFormat,t.texture.minFilter=null!==(r=this.options.minFilter)&&void 0!==r?r:o.LinearFilter,t.texture.magFilter=null!==(n=this.options.magFilter)&&void 0!==n?n:o.LinearFilter,t.texture.wrapS=null!==(i=this.options.wrapS)&&void 0!==i?i:o.ClampToEdgeWrapping,t.texture.wrapT=null!==(s=this.options.wrapT)&&void 0!==s?s:o.ClampToEdgeWrapping,this.baseCubeTexture&&(ae(this.baseCubeTexture,t,this.renderer),this.baseCubeTexture.dispose(),this.baseCubeTexture=null),this._cubeRenderTarget&&ae(this._cubeRenderTarget.texture,t,this.renderer),this._cubeRenderTarget=t},enumerable:!1,configurable:!0}),t.prototype.requestTile=function(t){var e,r,n,i,s,a,u=this,h=this.tileSources.filter((function(e){return e.level===t.level}))[0];if(h){var c=h.size,l=Math.pow(2,t.level)*t.position.y,f=Math.pow(2,t.level)*t.position.x,p="".concat((null!==(n=null===(r=null===(e=this.options.imageURL)||void 0===e?void 0:e.options)||void 0===r?void 0:r.key)&&void 0!==n?n:"pano.0").replace(/^pano/,"pano_tile"),".").concat(t.face,".").concat(t.level,".").concat(l,".").concat(f),d=kt(kt({},null!==(s=null===(i=this.options.imageURL)||void 0===i?void 0:i.options)&&void 0!==s?s:{basisLoaderInitialized:!1,key:"unknown"}),{key:p,size:c*t.size===this.options.tileImageSize?void 0:this.options.tileImageSize,quality:void 0,cut:[c*t.position.x,c*t.position.y,c*t.size,c*t.size]});this.loadingCubeNodes.add(t),this.options.textureLoader.loadTexture(h[t.face],{imageURL:{transform:null===(a=this.options.imageURL)||void 0===a?void 0:a.transform,options:kt({},d)},format:o.RGBAFormat,preInit:!1,viaAjax:!1}).then((function(e){u.disposed?e.body.dispose():(u.textures.push({face:t.face,level:t.level,position:t.position,size:new o.Vector2(t.size,t.size),texture:e.body}),u.loadedCubeNodes.add(t))})).catch(ne).then((function(){u.disposed||u.loadingCubeNodes.delete(t)}))}else this.loadedCubeNodes.add(t)},t.prototype.update=function(t,e){var r=this;if(!this.disposed){var n=[];re(this.tileTree,(function(i){return!r.loadingCubeNodes.has(i)&&(!(i.level>e)&&(!!t.intersectsBox(i.box)&&(r.loadedCubeNodes.has(i)?void 0:(n.push(i),!1))))}));for(var i=0,s=n;i<s.length;i++){var a=s[i];this.requestTile(a)}if(this.cubeRenderTarget&&this.textures.length){var u=this.textures.splice(0,4);!function(t,e,r){var n=new o.Scene,i=new o.Group;i.scale.set(1,1,-1),n.add(i);for(var s=0,a=t;s<a.length;s++){var u=a[s],h=new o.ShaderMaterial({uniforms:{map:{value:u.texture}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform sampler2D map;\nvarying vec2 vUv;\nvoid main() {\n gl_FragColor = texture2D(map, vUv);\n}\n",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1}),c=new o.Group,l=new o.Mesh(ce,h);l.position.set(u.position.x+u.size.x/2-.5,1-(u.position.y+u.size.y/2)-.5,-.5),l.scale.set(u.size.x,u.size.y,1),c.quaternion.copy(he[u.face]),c.add(l),i.add(c)}var f=r.autoClear;r.autoClear=!1,new o.CubeCamera(.1,2,e).update(r,n),r.autoClear=f;for(var p=0,d=[];p<d.length;p++)(h=d[p]).uniforms.map.value=null,h.dispose()}(u,this.cubeRenderTarget,this.renderer),this.needsRender=!0;for(var h=0,c=u;h<c.length;h++){c[h].texture.dispose()}}}},Object.defineProperty(t.prototype,"tilePending",{get:function(){return this.loadingCubeNodes.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){if(!this._cubeRenderTarget)throw new Error("cubeRenderTarget never set.");return this._cubeRenderTarget.texture},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){if(!this.disposed){this.disposed=!0,this.baseCubeTexture&&(this.baseCubeTexture.dispose(),this.baseCubeTexture=null),this.loadingCubeNodes.clear(),this.loadedCubeNodes.clear();for(var t=0,e=this.textures;t<e.length;t++){e[t].texture.dispose()}this.textures.length=0}},t}(),Te=function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("n\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{Hn\bv{t-rpA-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|l}nlrrK0v{pyqr-Iunq|zn}l}nlrrK|vq-znv{56-\n--0v{pyqr-IlrrK--0v{pyqr-I?lrrK--0v{pyqr-Ip|y|lrrK--0v{pyqr-Iortv{{|znylrrK--0v{pyqr-Iqrsny{|znylrrK--rpA-n{s|zrq-J-rpA5}|vv|{9->;=6H--rpA-z]|vv|{-J-z|qrycvrZnv-7-n{s|zrqH--[|zny-J-{|znyv\tr5n{s|zrq[|zny6H--cvr]|vv|{-J-:z]|vv|{;\b\tH--|yq]|vv|{-J-z|qryZnv-7-n{s|zrqH--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--0v{pyqr-Iunq|zn}lrrK\f"),Ce=function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=EC9-=;>=C9-=;>AF9->;=60qrsv{r-aNb-C;?E@>EB?{vs|z-nz}yrPor-}n{|=lzn}H{vs|z-znA-}n{|=lznvH0vs-qrsv{rq5b`RlYbZV[N[PR6--{vs|z-nz}yrPor-}n{|=lyzv{n{prZn}H0r{qvs{vs|z-nz}yrPor-}n{|>lzn}H{vs|z-znA-}n{|>lznvH0vs-qrsv{rq5b`RlYbZV[N[PR6--{vs|z-nz}yrPor-}n{|>lyzv{n{prZn}H0r{qvs{vs|z-rp@-qvssrH{vs|z-rp@-rzvvrH{vs|z-rp@-}rpynH{vs|z-sy|n-uv{v{rH{vs|z-sy|n-r}|rH{vs|z-sy|n-|}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-sy|n-sy||V{qrH0vs-qrsv{rq5b`RlNYYlP\\Y\\_6{vs|z-rp@-z|qryP|y|V{s|H0r{qvs0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6--{vs|z-rp?-}n{|cvqr|lv\trH--{vs|z-znA-}n{|cvqr|lznvH--{vs|z-sy|n-}n{|cvqr|lny}unH--{vs|z-nz}yr?Q-}n{|cvqr|lzn}H0r{qvs0vs-qrsv{rq5b`RlPYV]SY\\\\_6--{vs|z-rp@-sy||V{s|H0r{qvsn\bv{t-rpA-|yq]|vv|{H0vs-qrsv{rq5b`RlPbaR_6--0vs-[bZlPYV]]V[TlN__NflYR[TaU-K-=----{vs|z-rpA-pyv}}r]yn{rNn\bh-[bZlPYV]]V[TlN__NflYR[TaU-jH----{vs|z-sy|n-pyv}}rSy||h[bZlPYV]]V[TlN__NflYR[TaUjH--0r{qvs0r{qvs0v{pyqr-Ip|zz|{K0v{pyqr-I}npxv{tK0v{pyqr-Ip|y|l}nlsntzr{K0v{pyqr-Il}nlsntzr{K0v{pyqr-I?l}nlsntzr{K0v{pyqr-Izn}l}nlsntzr{K0v{pyqr-Iny}unzn}l}nlsntzr{K0v{pyqr-In|zn}l}nlsntzr{K0v{pyqr-Iyvtuzn}l}nlsntzr{K0v{pyqr-Irzvvrzn}l}nlsntzr{K0v{pyqr-Ir{zn}l}nlsntzr{K0v{pyqr-Itnqvr{zn}l}nlsntzr{K0v{pyqr-Is|tl}nlsntzr{K0v{pyqr-IoqsK0v{pyqr-Iyvtul}nlortv{K0v{pyqr-Iyvtul}u|{tl}nlsntzr{K0v{pyqr-Iunq|zn}l}nlsntzr{Krp?-|P||q5rp@-rp|6-\n--sy|n--J-yr{tu5rp|6H--sy|n-urn-J-np|5rp|;\b-<-6H--sy|n-}uv-J-nn{5rp|;9-rp|;\t6H--r{-rp?5=;B-8-}uv-<-aNb9-urn-<-]V6H\f|vq-znv{56-\n--0vs-qrsv{rq5b`RlNYYlP\\Y\\_6----tylSntP|y|-J-rpA5z|qryP|y|V{s|;9z|qryP|y|V{s|;t9z|qryP|y|V{s|;o9>;=6H----r{H--0r{qvsvs-5q|5cvr]|vv|{9-[|zny6-I-=;=6-\n----qvpnqH--\f--<<前置裁切计算--0vs-qrsv{rq5b`RlPbaR_6----rpA-}yn{rH----s|5-v{-v-J-=H-v-I-[bZlPYV]]V[TlO\\eH-v886\n------o||y-pyv}}rq-J-rH------sy|n-pr{Sy||V{qr-J-pyv}}rSy||hvjH------s|-5-v{-w-J-=H-w-I-CH-w-88-6-\n--------}yn{r-J-pyv}}r]yn{rNn\bh-v-7-C-8-w-jH--------pyv}}rq-J-5-q|5-cvr]|vv|{9-}yn{r;\b\t-6-K-}yn{r;-6-33-pyv}}rqH------\f------vs5-pyv}}rq-33-5pr{Sy||V{qr-JJ-:>;=-\v\v-pr{Sy||V{qr-JJ-sy||V{qr66-\n--------qvpnqH------\fH----\f--0r{qvs--<<楼层切割计算--0vs-qrsv{rq5b`RlPYV]SY\\\\_6----vs-5|yq]|vv|{;\b-I-sy||V{s|;-\v\v-|yq]|vv|{;\b-K-sy||V{s|;t6-\n------qvpnqH----\f--0r{qvs--rpA-qvssrP|y|-J-rpA5qvssr;to9-|}npv\b6H--_rsyrprqYvtu-rsyrprqYvtu-J-_rsyrprqYvtu5rp@5=;=69-rp@5=;=69-rp@5=;=69-rp@5=;=66H--rp@-|nyRzvvr_nqvn{pr-J-rzvvrH--0v{pyqr-Izn}lsntzr{K--0v{pyqr-Ip|y|lsntzr{K--0v{pyqr-Iny}unzn}lsntzr{K--0v{pyqr-Iny}unrlsntzr{K--0v{pyqr-I}rpynzn}lsntzr{K--0v{pyqr-I{|znylsntzr{lortv{K--0v{pyqr-I{|znylsntzr{lzn}K--0v{pyqr-Irzvvrzn}lsntzr{K--0v{pyqr-Iyvtul}u|{tlsntzr{K--0v{pyqr-Iyvtulsntzr{lortv{K--<<-调整曝光值--vnqvn{pr-J-vnqvn{pr-7-r}|rH--0v{pyqr-Iyvtulsntzr{lzn}K--0v{pyqr-Iyvtulsntzr{lr{qK--0v{pyqr-In|zn}lsntzr{K--<<-减少方向光对模型的影响--rp@-|t|v{tYvtu-J-5rsyrprqYvtu;qvrpQvssr-7-=;?6-8----rsyrprqYvtu;v{qvrpQvssr-8----rsyrprqYvtu;v{qvrp`}rpyn-8----|nyRzvvr_nqvn{prH--<<-修复黑色面片的问题--vs-5|t|v{tYvtu;-K-=;=-\v\v-|t|v{tYvtu;t-K-=;=-\v\v-|t|v{tYvtu;o-K-=;=6-\n----tylSntP|y|-J-rpA5|t|v{tYvtu9-qvssrP|y|;n6H--\f-ryr-\n----tylSntP|y|-J-rpA5OYNPXlP\\Y\\_;\b\t9-qvssrP|y|;n6H--\f--rp@-}n{|=a|crr-J-5|yq]|vv|{;\b\t-:-}n{|=lznvh@j;\b\t6-7-zn@5}n{|=lznv6H--rp@-}n{|>a|crr-J-5|yq]|vv|{;\b\t-:-}n{|>lznvh@j;\b\t6-7-zn@5}n{|>lznv6H--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=lzn}9-}n{|=a|crr6H--rpA-}n{|>P|y|-J-rrPor5}n{|>lzn}9-}n{|>a|crr6H--0vs-qrsv{rq5b`RlYbZV[N[PR6----}n{|=P|y|;n-J->;=-:-rrPor5}n{|=lyzv{n{prZn}9-}n{|=a|crr6;H----}n{|>P|y|;n-J->;=-:-rrPor5}n{|>lyzv{n{prZn}9-}n{|>a|crr6;H--0r{qvs--0vs-qrsv{rq5b`RlOYNPXla_N[`VaV\\[6----sy|n-oynpx]|tr-J-np|5:?;=-7-}|tr-8->;=6H----}n{|P|y|-J-zv5}n{|=P|y|9-OYNPXlP\\Y\\_9-zv{5>;=9-oynpx]|tr66H----}n{|P|y|-J-zv5}n{|P|y|9-}n{|>P|y|9-zn5=;=9-oynpx]|tr-:-?;=66H--0ryr----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-}|tr6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6----rp@-pnzrna|crr-J-|yq]|vv|{;\b\t-:-pnzrn]|vv|{H----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|lznvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|lv\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|lv\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|lzn}9-6H----sy|n-znpu-J-5>;=-:-r}5=;=9-zn}P||q;\t66-7-5>;=-:-r}5=;B9-no5;-:-=;B666-7-5>;=-:-r}5=;B9-no5;\b-:-=;B666H----sy|n-ny}un-J-pynz}5=;=9->;=9-B;=-7-5>;=-:-pynz}5qvn{pr59-rp?5=;B9-=;B66-<-=;BB-9-=;=9->;=666H----}n{|P|y|-J-zv5}n{|P|y|9-vqr|P|y|9-znpu-7-ny}un-7-}n{|cvqr|lny}un6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\l\\]NPVaf6----tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H----tylSntP|y|;n-J-|}npv\bH--0ryr----tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H----tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H--0r{qvs\f"),Ie=new o.WebGLCubeRenderTarget(1).texture;Ie.name="EMPTY_TEXTURE";var Oe=Object.assign({modelAlpha:new o.Uniform(0),progress:new o.Uniform(0),pano0_map:new o.Uniform(Ie),pano0_luminanceMap:new o.Uniform(null),pano0_matrix:new o.Uniform(new o.Matrix4),pano1_map:new o.Uniform(Ie),pano1_luminanceMap:new o.Uniform(null),pano1_matrix:new o.Uniform(new o.Matrix4),floorIndex:-1,floorInfo:new o.Vector3(0,0,0),clipperPlanesArray:new Float32Array,clipperFloors:[],modelColorInfo:new o.Uniform(null)},{exposure:new o.Uniform(1),emissive:new o.Uniform(new o.Color(0)),emissiveMap:new o.Uniform(null),specular:new o.Uniform(new o.Color(1118481)),specularMap:new o.Uniform(null),normalMap:new o.Uniform(null),bumpMap:new o.Uniform(null),shininess:new o.Uniform(30)},o.UniformsUtils.clone(o.UniformsLib.common),o.UniformsUtils.clone(o.UniformsLib.lights)),He=function(t){function e(e){void 0===e&&(e={});var r,n,i,s,a,u,h,c,l,f=this;f=t.call(this,{vertexShader:Te,fragmentShader:Ce,uniforms:o.UniformsUtils.clone(Oe),defines:{USE_MAP:!0,USE_UV:!0,USE_LUMINANCE:!1,USE_PANO_OPACITY:!1,USE_BLACK_TRANSITION:!1,USE_PANO_VIDEO:!1,USE_ALL_COLOR:!1,USE_CLIPFLOOR:!1,USE_CUTER:!1,NUM_CLIPPING_ARRAY_LENGTH:0,NUM_CLIPPING_BOX:0},blending:o.NoBlending,lights:!0})||this;var p=null,d=null;return Object.defineProperties(f,{pano0:{get:function(){return p},set:function(t){p=t,null===t?(this.uniforms.pano0_map.value=Ie,this.uniforms.pano0_luminanceMap.value=null,this.uniforms.pano0_matrix.value.identity()):(this.uniforms.pano0_map.value=t.map instanceof Re?t.map.texture:t.map,this.uniforms.pano0_luminanceMap.value=t.luminanceMap instanceof Re?t.luminanceMap.texture:t.luminanceMap,this.uniforms.pano0_matrix.value.copy(t.matrix));var e=null!==this.uniforms.pano0_luminanceMap.value&&null!==this.uniforms.pano1_luminanceMap.value;this.defines.USE_LUMINANCE!==e&&(this.defines.USE_LUMINANCE=e,this.needsUpdate=!0)}},pano1:{get:function(){return d},set:function(t){d=t,null===t?(this.uniforms.pano1_map.value=Ie,this.uniforms.pano1_luminanceMap.value=null,this.uniforms.pano1_matrix.value.identity()):(this.uniforms.pano1_map.value=t.map instanceof Re?t.map.texture:t.map,this.uniforms.pano1_luminanceMap.value=t.luminanceMap instanceof Re?t.luminanceMap.texture:t.luminanceMap,this.uniforms.pano1_matrix.value.copy(t.matrix));var e=null!==this.uniforms.pano0_luminanceMap.value&&null!==this.uniforms.pano1_luminanceMap.value;this.defines.USE_LUMINANCE!==e&&(this.defines.USE_LUMINANCE=e,this.needsUpdate=!0)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(t){this.uniforms.modelAlpha.value=t}},progress:{get:function(){return this.uniforms.progress.value},set:function(t){this.uniforms.progress.value=t}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(t){this.defines.USE_BLACK_TRANSITION!==t&&(this.defines.USE_BLACK_TRANSITION=t,this.needsUpdate=!0)}},modelColorInfo:{get:function(){return this.uniforms.modelColorInfo.value},set:function(t){null===t?this.defines.USE_ALL_COLOR=!1:(this.defines.USE_ALL_COLOR=!0,this.uniforms.modelColorInfo.value=t),this.needsUpdate=!0}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t;var e=t<1?o.NormalBlending:o.NoBlending;e!==this.blending&&(this.blending=e,this.needsUpdate=!0)}},floorIndex:{get:function(){return this.uniforms.floorIndex.value},set:function(t){this.uniforms.floorIndex.value=t}},floorInfo:{get:function(){return this.uniforms.floorInfo.value},set:function(t){t&&t.equals(new o.Vector3(0,0,0))&&(this.defines.USE_CLIPFLOOR=!1,this.needsUpdate=!0),t&&!t.equals(new o.Vector3(0,0,0))&&(this.defines.USE_CLIPFLOOR=!0,this.uniforms.floorInfo.value=t,this.needsUpdate=!0)}},clippers:{get:function(){return this._clippers},set:function(t){this._clippers=t}},clipperPlanesArray:{get:function(){return this.uniforms.clipperPlanesArray.value},set:function(t){if(t instanceof Float32Array&&t.length>0&&t.length%6==0){var e=t.length/4;this.defines.USE_CUTER=!0,this.defines.NUM_CLIPPING_ARRAY_LENGTH=e,this.defines.NUM_CLIPPING_BOX=e/6,this.uniforms.clipperPlanesArray.value=t,this.needsUpdate=!0}else this.defines.USE_CUTER=!1,this.defines.NUM_CLIPPING_ARRAY_LENGTH=0,this.defines.NUM_CLIPPING_BOX=0,this.uniforms.clipperPlanesArray.value=new Float32Array,this.needsUpdate=!0}},clipperFloors:{get:function(){return this.uniforms.clipperFloors.value},set:function(t){this.uniforms.clipperFloors.value=t}}}),f.pano0=null!==(r=e.pano0)&&void 0!==r?r:null,f.pano1=null!==(n=e.pano1)&&void 0!==n?n:null,f.modelAlpha=null!==(i=e.modelAlpha)&&void 0!==i?i:1,f.progress=null!==(s=e.progress)&&void 0!==s?s:0,f.useBlackTransition=null!==(a=e.useBlackTransition)&&void 0!==a&&a,f.modelColorInfo=null!==(u=e.modelColorInfo)&&void 0!==u?u:null,f.opacity=null!==(h=e.opacity)&&void 0!==h?h:1,f.originOpacity=1,f.floorIndex=null!==(c=e.floorIndex)&&void 0!==c?c:-1,f.floorInfo=null!==(l=e.floorInfo)&&void 0!==l?l:null,f.clippers=null,f.clipperPlanesArray=null,f.clipperFloors=null,f}return zt(e,t),e}(o.ShaderMaterial);function _e(t){return new Promise((function(e,r){(/^https\:/.test(t)?u.default:a.default).get(t,(function(t){var n=[];t.on("data",(function(t){return n.push(t)})),t.on("end",(function(){e(Buffer.concat(n).buffer)})),t.on("error",(function(t){return r(t)}))})).on("error",(function(t){return r(t)}))}))}const Be=h.Reader,Ve=h.util,je=h.roots["@REALSEE/FIVE:five/server/model/proto/pbm.proto"]||(h.roots["@REALSEE/FIVE:five/server/model/proto/pbm.proto"]={}),qe=je.Model=(()=>{function t(t){if(this.chunks=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.chunks=Ve.emptyArray,t.prototype.createAt=Ve.Long?Ve.Long.fromBits(0,0,!0):0,t.prototype.description="",t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(je.Chunk.decode(t,t.uint32()));break;case 2:n.createAt=t.uint64();break;case 3:n.description=t.string();break;default:t.skipType(7&e)}}return n},t})();je.Chunk=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.vertices=null,t.prototype.faces=null,t.prototype.name="",t.prototype.texture="",t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.vertices=je.Vertices.decode(t,t.uint32());break;case 2:n.faces=je.Faces.decode(t,t.uint32());break;case 3:n.name=t.string();break;case 4:n.texture=t.string();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("vertices"))throw Ve.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw Ve.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw Ve.ProtocolError("missing required 'name'",{instance:n});return n},t})(),je.Vertices=(()=>{function t(t){if(this.xyz=[],this.uvs=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.xyz=Ve.emptyArray,t.prototype.uvs=Ve.emptyArray,t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Vertices;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.xyz.push(t.float())}else n.xyz.push(t.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.uvs.push(t.float())}else n.uvs.push(t.float());break;default:t.skipType(7&e)}}return n},t})(),je.Faces=(()=>{function t(t){if(this.indices=[],this.normals=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.indices=Ve.emptyArray,t.prototype.normals=Ve.emptyArray,t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Faces;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.indices.push(t.uint32())}else n.indices.push(t.uint32());break;case 2:if(n.normals&&n.normals.length||(n.normals=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.normals.push(t.float())}else n.normals.push(t.float());break;default:t.skipType(7&e)}}return n},t})();var ze=(new o.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1).elements;function ke(t){var e=t.match(/(group|floor)-?(\d+)/);return e?parseInt(e[2],10):0}function Ke(t){var e=t.match(/(chunk)-?(\d+)/);return e?parseInt(e[2],10):0}function Le(t){var e,r;return 1e6*ke(t.name)+1e3*Ke(t.name)+(e=t.name,(r=e.match(/(sub)-?(\d+)/))?parseInt(r[2],10):0)}function Me(t){for(var e=function(t){for(var e,r,n,i="number"==typeof t.createAt?t.createAt:null===t.createAt||void 0===t.createAt?0:t.createAt.toNumber(),s=null!==(e=t.description)&&void 0!==e?e:"",o=[],a=!0,u=0,h=t.chunks;u<h.length;u++)if(!(rt=h[u]).faces.normals||0===rt.faces.normals.length){a=!1;break}for(var c=t.chunks.sort((function(t,e){return Le(t)-Le(e)})),l=[],f=0,p=c;f<p.length;f++){var d=ke((rt=p[f]).name);l[d]||(l[d]=[]),l[d].push(rt)}for(var v=0;v<l.length;v++){var g=l[v];if(g)if(a){for(var y=0,m=0;m<g.length;m++)y+=(rt=g[m]).faces.indices.length;for(var x=3*y,b=2*y,S=3*y,E=new ArrayBuffer(4*x+4*b+4*S),w=new Float32Array(E,0,x),A=new Float32Array(E,4*x,b),P=new Float32Array(E,4*x+4*b,S),N=[],D=[1/0,1/0,1/0,-1/0,-1/0,-1/0],R=0,T=0;T<g.length;T++){var C=[1/0,1/0,1/0,-1/0,-1/0,-1/0],I=(rt=g[T]).vertices.xyz,O=rt.vertices.uvs,H=rt.faces.indices,_=rt.faces.normals,B=H.length;for(m=0;m<B;m++){var V=H[m],j=I[3*V],q=I[3*V+1],z=I[3*V+2],k=1/(ze[3]*j+ze[7]*q+ze[11]*z+ze[15]),K=(ze[0]*j+ze[4]*q+ze[8]*z+ze[12])*k,L=(ze[1]*j+ze[5]*q+ze[9]*z+ze[13])*k,M=(ze[2]*j+ze[6]*q+ze[10]*z+ze[14])*k;w[3*R+3*m]=K,w[3*R+3*m+1]=L,w[3*R+3*m+2]=M,A[2*R+2*m]=O[2*V],A[2*R+2*m+1]=O[2*V+1];var U=3*Math.floor(m/3),F=_[U],Y=_[U+1],Q=_[U+2],Z=1/(ze[3]*F+ze[7]*Y+ze[11]*Q+ze[15]),G=(ze[0]*F+ze[4]*Y+ze[8]*Q+ze[12])*Z,W=(ze[1]*F+ze[5]*Y+ze[9]*Q+ze[13])*Z,X=(ze[2]*F+ze[6]*Y+ze[10]*Q+ze[14])*Z;P[3*R+3*m]=G,P[3*R+3*m+1]=W,P[3*R+3*m+2]=X,K<C[0]&&(C[0]=K),L<C[1]&&(C[1]=L),M<C[2]&&(C[2]=M),K>C[3]&&(C[3]=K),L>C[4]&&(C[4]=L),M>C[5]&&(C[5]=M)}C[0]<D[0]&&(D[0]=C[0]),C[1]<D[1]&&(D[1]=C[1]),C[2]<D[2]&&(D[2]=C[2]),C[3]>D[3]&&(D[3]=C[3]),C[4]>D[4]&&(D[4]=C[4]),C[5]>D[5]&&(D[5]=C[5]),N.push({materialIndex:T,name:rt.name,chunkName:Ke(rt.name),start:R,count:rt.faces.indices.length,texture:null!==(r=rt.texture)&&void 0!==r?r:void 0}),R+=B}o.push({createAt:i,description:s,floorIndex:v,vertices:w,uvs:A,indices:null,normals:P,groups:N,extents:D})}else{y=0;var J=0;for(m=0;m<g.length;m++)J+=(rt=g[m]).vertices.xyz.length/3,y+=rt.faces.indices.length;x=3*J,b=2*J,S=3*J;var $=y,tt=(E=new ArrayBuffer(4*x+4*b+4*S+4*$),w=new Float32Array(E,0,x),A=new Float32Array(E,4*x,b),P=new Float32Array(E,4*x+4*b,S),new Uint32Array(E,4*x+4*b+4*S,$)),et=(N=[],D=[1/0,1/0,1/0,-1/0,-1/0,-1/0],0);for(R=0,T=0;T<g.length;T++){C=[1/0,1/0,1/0,-1/0,-1/0,-1/0],I=(rt=g[T]).vertices.xyz,O=rt.vertices.uvs,H=rt.faces.indices;var rt,nt=I.length/3;for(B=H.length,m=0;m<nt;m++)j=I[3*m],q=I[3*m+1],z=I[3*m+2],k=1/(ze[3]*j+ze[7]*q+ze[11]*z+ze[15]),K=(ze[0]*j+ze[4]*q+ze[8]*z+ze[12])*k,L=(ze[1]*j+ze[5]*q+ze[9]*z+ze[13])*k,M=(ze[2]*j+ze[6]*q+ze[10]*z+ze[14])*k,w[3*R+3*m]=K,w[3*R+3*m+1]=L,w[3*R+3*m+2]=M,A[2*R+2*m]=O[2*m],A[2*R+2*m+1]=O[2*m+1],K<C[0]&&(C[0]=K),L<C[1]&&(C[1]=L),M<C[2]&&(C[2]=M),K>C[3]&&(C[3]=K),L>C[4]&&(C[4]=L),M>C[5]&&(C[5]=M);for(C[0]<D[0]&&(D[0]=C[0]),C[1]<D[1]&&(D[1]=C[1]),C[2]<D[2]&&(D[2]=C[2]),C[3]>D[3]&&(D[3]=C[3]),C[4]>D[4]&&(D[4]=C[4]),C[5]>D[5]&&(D[5]=C[5]),m=0;m<B;m++)tt[et+m]=R+H[m];N.push({materialIndex:T,name:rt.name,chunkName:Ke(rt.name),start:et,count:rt.faces.indices.length,texture:null!==(n=rt.texture)&&void 0!==n?n:void 0}),R+=nt,et+=B}for(m=0;m<y;m+=3){var it,st,ot,at,ut,ht,ct,lt,ft,pt,dt,vt,gt,yt,mt,xt;F=void 0,Y=void 0,Q=void 0,it=3*tt[m],st=3*tt[m+1],ot=3*tt[m+2],at=w[it],ut=w[it+1],ht=w[it+2],ct=w[st],lt=w[st+1],ft=w[st+2],pt=w[ot],F=(vt=w[ot+1]-lt)*(xt=ht-ft)-(gt=w[ot+2]-ft)*(mt=ut-lt),Y=gt*(yt=at-ct)-(dt=pt-ct)*xt,Q=dt*mt-vt*yt,P[it]+=F,P[it+1]+=Y,P[it+2]+=Q,P[st]+=F,P[st+1]+=Y,P[st+2]+=Q,P[ot]+=F,P[ot+1]+=Y,P[ot+2]+=Q}o.push({createAt:i,description:s,floorIndex:v,vertices:w,uvs:A,indices:tt,normals:P,groups:N,extents:D})}}return o}(t),r=0,n="",i=[],s=0,a=e;s<a.length;s++){var u=a[s],h=u.createAt,c=u.description,l=u.floorIndex,f=u.vertices,p=u.uvs,d=u.indices,v=u.normals,g=u.groups,y=u.extents,m=new o.Box3;m.min.x=y[0],m.min.y=y[1],m.min.z=y[2],m.max.x=y[3],m.max.y=y[4],m.max.z=y[5];var x=new o.BufferGeometry;x.setAttribute("position",new o.BufferAttribute(f,3)),x.setAttribute("uv",new o.BufferAttribute(p,2)),x.setAttribute("normal",new o.BufferAttribute(v,3)),d&&x.setIndex(new o.BufferAttribute(d,1)),x.boundingBox=m,x.boundingSphere=m.getBoundingSphere(new o.Sphere);for(var b=0,S=g;b<S.length;b++){var E=S[b];x.addGroup(E.start,E.count,E.materialIndex)}for(var w=[],A=0,P=g;A<P.length;A++){E=P[A];var N=new He;w.push(N),N.defines.USE_MAP=!1,N.uniforms.diffuse.value=new o.Color(16777215),N.uniforms.floorIndex.value=l}var D=new ee(x,w);D.name="model_floor_"+l,D.floorIndex=l,D.userData.createAt=h,D.userData.description=c,r=h,n=c,i.push(D)}return{createAt:r,description:n,objects:i}}var Ue={};function Fe(t){return Array.prototype.reduce.call(t,(function(t,e,r){return t|e<<8*r}),0)}function Ye(t){for(var e=new Uint8Array(t),r=Fe(e.slice(0,4)),n=[],i=[],s=4+4*r,o=0;o<r;o++)i[o]=Fe(e.slice(4+4*o,8+4*o)),n[o]=o===r-1?e.subarray(s,s+i[o]):e.slice(s,s+i[o]),s+=i[o];return Promise.resolve(function(t){for(var e,r=[],n=t.length,i=function(n){var i={data:t[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=i.data.length,o={data:[],offset:0,writeByte:function(t){var e=Math.floor(this.offset/s);this.data[e]||(this.data[e]=new Uint8Array(s)),this.data[e][this.offset%s]=t,this.offset++}};Ue.decompressFile(i,o),e=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)e[a]=o.data[Math.floor(a/s)][a%s];r.push(e)},s=0;s<n;s++)i(s);return r}(n))}Ue.OutWindow=function(){this._windowSize=0},Ue.OutWindow.prototype.create=function(t){this._buffer&&this._windowSize===t||(this._buffer=[]),this._windowSize=t,this._pos=0,this._streamPos=0},Ue.OutWindow.prototype.flush=function(){var t=this._pos-this._streamPos;if(0!==t){for(;t--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},Ue.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},Ue.OutWindow.prototype.setStream=function(t){this.releaseStream(),this._stream=t},Ue.OutWindow.prototype.init=function(t){t||(this._streamPos=0,this._pos=0)},Ue.OutWindow.prototype.copyBlock=function(t,e){var r=this._pos-t-1;for(r<0&&(r+=this._windowSize);e--;)r>=this._windowSize&&(r=0),this._buffer[this._pos++]=this._buffer[r++],this._pos>=this._windowSize&&this.flush()},Ue.OutWindow.prototype.putByte=function(t){this._buffer[this._pos++]=t,this._pos>=this._windowSize&&this.flush()},Ue.OutWindow.prototype.getByte=function(t){var e=this._pos-t-1;return e<0&&(e+=this._windowSize),this._buffer[e]},Ue.RangeDecoder=function(){},Ue.RangeDecoder.prototype.setStream=function(t){this._stream=t},Ue.RangeDecoder.prototype.releaseStream=function(){this._stream=null},Ue.RangeDecoder.prototype.init=function(){var t=5;for(this._code=0,this._range=-1;t--;)this._code=this._code<<8|this._stream.readByte()},Ue.RangeDecoder.prototype.decodeDirectBits=function(t){for(var e,r=0,n=t;n--;)this._range>>>=1,e=this._code-this._range>>>31,this._code-=this._range&e-1,r=r<<1|1-e,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return r},Ue.RangeDecoder.prototype.decodeBit=function(t,e){var r=t[e],n=(this._range>>>11)*r;return(2147483648^this._code)<(2147483648^n)?(this._range=n,t[e]+=2048-r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,t[e]-=r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},Ue.initBitModels=function(t,e){for(;e--;)t[e]=1024},Ue.BitTreeDecoder=function(t){this._models=[],this._numBitLevels=t},Ue.BitTreeDecoder.prototype.init=function(){Ue.initBitModels(this._models,1<<this._numBitLevels)},Ue.BitTreeDecoder.prototype.decode=function(t){for(var e=1,r=this._numBitLevels;r--;)e=e<<1|t.decodeBit(this._models,e);return e-(1<<this._numBitLevels)},Ue.BitTreeDecoder.prototype.reverseDecode=function(t){for(var e,r=1,n=0,i=0;i<this._numBitLevels;++i)r=r<<1|(e=t.decodeBit(this._models,r)),n|=e<<i;return n},Ue.reverseDecode2=function(t,e,r,n){for(var i,s=1,o=0,a=0;a<n;++a)s=s<<1|(i=r.decodeBit(t,e+s)),o|=i<<a;return o},Ue.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new Ue.BitTreeDecoder(8),this._numPosStates=0},Ue.LenDecoder.prototype.create=function(t){for(;this._numPosStates<t;++this._numPosStates)this._lowCoder[this._numPosStates]=new Ue.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new Ue.BitTreeDecoder(3)},Ue.LenDecoder.prototype.init=function(){var t=this._numPosStates;for(Ue.initBitModels(this._choice,2);t--;)this._lowCoder[t].init(),this._midCoder[t].init();this._highCoder.init()},Ue.LenDecoder.prototype.decode=function(t,e){return 0===t.decodeBit(this._choice,0)?this._lowCoder[e].decode(t):0===t.decodeBit(this._choice,1)?8+this._midCoder[e].decode(t):16+this._highCoder.decode(t)},Ue.Decoder2=function(){this._decoders=[]},Ue.Decoder2.prototype.init=function(){Ue.initBitModels(this._decoders,768)},Ue.Decoder2.prototype.decodeNormal=function(t){var e=1;do{e=e<<1|t.decodeBit(this._decoders,e)}while(e<256);return 255&e},Ue.Decoder2.prototype.decodeWithMatchByte=function(t,e){var r,n,i=1;do{if(r=e>>7&1,e<<=1,i=i<<1|(n=t.decodeBit(this._decoders,(1+r<<8)+i)),r!==n){for(;i<256;)i=i<<1|t.decodeBit(this._decoders,i);break}}while(i<256);return 255&i},Ue.LiteralDecoder=function(){},Ue.LiteralDecoder.prototype.create=function(t,e){var r;if(!this._coders||this._numPrevBits!==e||this._numPosBits!==t)for(this._numPosBits=t,this._posMask=(1<<t)-1,this._numPrevBits=e,this._coders=[],r=1<<this._numPrevBits+this._numPosBits;r--;)this._coders[r]=new Ue.Decoder2},Ue.LiteralDecoder.prototype.init=function(){for(var t=1<<this._numPrevBits+this._numPosBits;t--;)this._coders[t].init()},Ue.LiteralDecoder.prototype.getDecoder=function(t,e){return this._coders[((t&this._posMask)<<this._numPrevBits)+((255&e)>>>8-this._numPrevBits)]},Ue.Decoder=function(){this._outWindow=new Ue.OutWindow,this._rangeDecoder=new Ue.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new Ue.BitTreeDecoder(4),this._lenDecoder=new Ue.LenDecoder,this._repLenDecoder=new Ue.LenDecoder,this._literalDecoder=new Ue.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[1]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[2]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[3]=new Ue.BitTreeDecoder(6)},Ue.Decoder.prototype.setDictionarySize=function(t){return!(t<0)&&(this._dictionarySize!==t&&(this._dictionarySize=t,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},Ue.Decoder.prototype.setLcLpPb=function(t,e,r){var n=1<<r;return!(t>8||e>4||r>4)&&(this._literalDecoder.create(e,t),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},Ue.Decoder.prototype.init=function(){var t=4;for(this._outWindow.init(!1),Ue.initBitModels(this._isMatchDecoders,192),Ue.initBitModels(this._isRep0LongDecoders,192),Ue.initBitModels(this._isRepDecoders,12),Ue.initBitModels(this._isRepG0Decoders,12),Ue.initBitModels(this._isRepG1Decoders,12),Ue.initBitModels(this._isRepG2Decoders,12),Ue.initBitModels(this._posDecoders,114),this._literalDecoder.init();t--;)this._posSlotDecoder[t].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},Ue.Decoder.prototype.decode=function(t,e,r){var n,i,s,o,a,u,h=0,c=0,l=0,f=0,p=0,d=0,v=0;for(this._rangeDecoder.setStream(t),this._outWindow.setStream(e),this.init();r<0||d<r;)if(n=d&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(h<<4)+n))i=this._literalDecoder.getDecoder(d++,v),v=h>=7?i.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(c)):i.decodeNormal(this._rangeDecoder),this._outWindow.putByte(v),h=h<4?0:h-(h<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,h))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,h)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(h<<4)+n)&&(h=h<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,h)?o=l:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,h)?o=f:(o=p,p=f),f=l),l=c,c=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),h=h<7?8:11);else if(p=f,f=l,l=c,s=2+this._lenDecoder.decode(this._rangeDecoder,n),h=h<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(c=(2|1&a)<<(u=(a>>1)-1),a<14)c+=Ue.reverseDecode2(this._posDecoders,c-a-1,this._rangeDecoder,u);else if(c+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(c+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===c)break;return!1}}else c=a;if(c>=d||c>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(c,s),d+=s,v=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},Ue.Decoder.prototype.setDecoderProperties=function(t){var e,r,n,i,s;return!(t.size<5)&&(r=(e=t.readByte())%9,n=(e=~~(e/9))%5,i=~~(e/5),!!this.setLcLpPb(r,n,i)&&(s=t.readByte(),s|=t.readByte()<<8,s|=t.readByte()<<16,s+=16777216*t.readByte(),this.setDictionarySize(s)))},Ue.decompress=function(t,e,r,n){var i=new Ue.Decoder;if(!i.setDecoderProperties(t))throw"Incorrect stream properties";if(!i.decode(e,r,n))throw"Error in data stream";return!0},Ue.decompressFile=function(t,e){var r,n=new Ue.Decoder;if(!n.setDecoderProperties(t))throw"Incorrect stream properties";if(r=t.readByte(),r|=t.readByte()<<8,r|=t.readByte()<<16,r+=16777216*t.readByte(),t.readByte(),t.readByte(),t.readByte(),t.readByte(),!n.decode(t,e,r))throw"Error in data stream";return!0};var Qe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return zt(e,t),e.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof ee&&t.geometry.dispose()}))},e}(o.Group);const Ze=h.Reader,Ge=h.util,We=h.roots["@REALSEE/FIVE:five/server/model/proto/dome.proto"]||(h.roots["@REALSEE/FIVE:five/server/model/proto/dome.proto"]={}),Xe=We.Model=(()=>{function t(t){if(this.meshes=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.meshes=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Model;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(We.Mesh.decode(t,t.uint32()));else t.skipType(7&e)}return n},t})();We.Mesh=(()=>{function t(t){if(this.chunks=[],this.matrix=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.chunks=Ge.emptyArray,t.prototype.matrix=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Mesh;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.name=t.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(We.Chunk.decode(t,t.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(We.Matrix.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("name"))throw Ge.ProtocolError("missing required 'name'",{instance:n});return n},t})(),We.Matrix=(()=>{function t(t){if(this.elements=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elements=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Matrix;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.elements&&n.elements.length||(n.elements=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.elements.push(t.float())}else n.elements.push(t.float());else t.skipType(7&e)}return n},t})(),We.Chunk=(()=>{function t(t){if(this.material=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.geometry=null,t.prototype.material=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 2:n.geometry=We.Geometry.decode(t,t.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(We.Material.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("geometry"))throw Ge.ProtocolError("missing required 'geometry'",{instance:n});return n},t})(),We.Geometry=(()=>{function t(t){if(this.groups=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.position=null,t.prototype.uv=null,t.prototype.uv2=null,t.prototype.normal=null,t.prototype.groups=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Geometry;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.position=We.Position.decode(t,t.uint32());break;case 2:n.uv=We.UV.decode(t,t.uint32());break;case 3:n.uv2=We.UV.decode(t,t.uint32());break;case 4:n.normal=We.Normal.decode(t,t.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(We.Group.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("position"))throw Ge.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw Ge.ProtocolError("missing required 'normal'",{instance:n});return n},t})(),We.Position=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Position;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.UV=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.UV;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.Normal=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Normal;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.Group=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.start=0,t.prototype.count=0,t.prototype.materialIndex=0,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Group;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.start=t.uint32();break;case 2:n.count=t.uint32();break;case 3:n.materialIndex=t.uint32();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("start"))throw Ge.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw Ge.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw Ge.ProtocolError("missing required 'materialIndex'",{instance:n});return n},t})(),We.Material=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.kd=null,t.prototype.ks=null,t.prototype.ke=null,t.prototype.mapkd="",t.prototype.mapks="",t.prototype.mapke="",t.prototype.norm="",t.prototype.mapbump="",t.prototype.bump="",t.prototype.mapd="",t.prototype.ns=0,t.prototype.d=0,t.prototype.tr=0,t.prototype.mapkdrepeat="",t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Material;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.kd=We.Color.decode(t,t.uint32());break;case 2:n.ks=We.Color.decode(t,t.uint32());break;case 3:n.ke=We.Color.decode(t,t.uint32());break;case 4:n.mapkd=t.string();break;case 5:n.mapks=t.string();break;case 6:n.mapke=t.string();break;case 7:n.norm=t.string();break;case 8:n.mapbump=t.string();break;case 9:n.bump=t.string();break;case 10:n.mapd=t.string();break;case 11:n.ns=t.float();break;case 12:n.d=t.float();break;case 13:n.tr=t.float();break;case 14:n.mapkdrepeat=t.string();break;default:t.skipType(7&e)}}return n},t})(),We.Color=(()=>{function t(t){if(this.rgb=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.rgb=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Color;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.rgb.push(t.float())}else n.rgb.push(t.float());else t.skipType(7&e)}return n},t})();var Je={};function $e(t){var e,r=[];function n(t,e,r){var n=function(t){var e=t.position,r=t.normal,n=t.uv,i=t.uv2,s=t.groups,a=new o.BufferGeometry;return a.setAttribute("position",new o.BufferAttribute(new Float32Array(e.array),3)),r&&a.setAttribute("normal",new o.BufferAttribute(new Float32Array(r.array),3)),n&&a.setAttribute("uv",new o.BufferAttribute(new Float32Array(n.array),2)),i&&a.setAttribute("uv2",new o.BufferAttribute(new Float32Array(i.array),2)),s.forEach((function(t){return a.addGroup(t.start,t.count,t.materialIndex)})),a}(t);n.applyMatrix4(r);var i=new o.Vector3,s=new o.Quaternion,a=new o.Vector3;return r.decompose(i,s,a),a.x*a.y*a.z<0&&n.attributes.normal&&n.attributes.position&&n.attributes.uv&&function(t){for(var e=[0,0,0],r=0;r<t.attributes.normal.array.length/9;r++)e[0]=t.attributes.normal.array[9*r],e[1]=t.attributes.normal.array[9*r+1],e[2]=t.attributes.normal.array[9*r+2],t.attributes.normal.array[9*r]=t.attributes.normal.array[9*r+6],t.attributes.normal.array[9*r+1]=t.attributes.normal.array[9*r+7],t.attributes.normal.array[9*r+2]=t.attributes.normal.array[9*r+8],t.attributes.normal.array[9*r+6]=e[0],t.attributes.normal.array[9*r+7]=e[1],t.attributes.normal.array[9*r+8]=e[2];for(r=0;r<t.attributes.position.array.length/9;r++)e[0]=t.attributes.position.array[9*r],e[1]=t.attributes.position.array[9*r+1],e[2]=t.attributes.position.array[9*r+2],t.attributes.position.array[9*r]=t.attributes.position.array[9*r+6],t.attributes.position.array[9*r+1]=t.attributes.position.array[9*r+7],t.attributes.position.array[9*r+2]=t.attributes.position.array[9*r+8],t.attributes.position.array[9*r+6]=e[0],t.attributes.position.array[9*r+7]=e[1],t.attributes.position.array[9*r+8]=e[2];for(r=0;r<t.attributes.uv.array.length/6;r++)e[0]=t.attributes.uv.array[6*r],e[1]=t.attributes.uv.array[6*r+1],t.attributes.uv.array[6*r]=t.attributes.uv.array[6*r+4],t.attributes.uv.array[6*r+1]=t.attributes.uv.array[6*r+5],t.attributes.uv.array[6*r+4]=e[0],t.attributes.uv.array[6*r+5]=e[1];t.attributes.normal.needsUpdate=!0,t.attributes.position.needsUpdate=!0,t.attributes.uv.needsUpdate=!0}(n),new ee(n)}return(e=t,Xe.decode(e).meshes).forEach((function(t){var e=t.name,i=t.chunks,s=t.matrix;"Ceiling"!==e&&"CeilingDrop"!==e&&s.map((function(t){var s,a=new o.Matrix4;if(a.elements=t.elements,1===i.length){var u=i[0],h=u.geometry;u.material;s=n(h,0,a)}else s=new Qe,i.forEach((function(t,e){var r=t.geometry,i=(t.material,n(r,0,a));i.name="chunk"+e,s.add(i)}));s.floorIndex=0,s.name=e,r.push(s)}))})),{objects:r,createAt:0,description:""}}function tr(){Object.keys(Je).forEach((function(t){Je[t].dispose(),delete Je[t]}))}function er(t){return null==t}var rr=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.needsRender=!0,e}return zt(e,t),e.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof ee&&t.geometry.dispose()}))},e}(o.Group),nr=function(t,e){void 0===e&&(e=1e-4),e=Math.max(e,Number.EPSILON);for(var r={},n=t.getIndex(),i=t.getAttribute("position"),s=n?n.count:i.count,a=0,u=Object.keys(t.attributes),h={},c={},l=[],f=["getX","getY","getZ","getW"],p=0,d=u.length;p<d;p++){h[b=u[p]]=[],(A=t.morphAttributes[b])&&(c[b]=new Array(A.length).fill().map((function(){return[]})))}var v=Math.log10(1/e),g=Math.pow(10,v);for(p=0;p<s;p++){var y=n?n.getX(p):p,m="",x=0;for(d=u.length;x<d;x++)for(var b=u[x],S=(w=t.getAttribute(b)).itemSize,E=0;E<S;E++)m+="".concat(~~(w[f[E]](y)*g),",");if(m in r)l.push(r[m]);else{for(x=0,d=u.length;x<d;x++){b=u[x];var w=t.getAttribute(b),A=t.morphAttributes[b],P=(S=w.itemSize,h[b]),N=c[b];for(E=0;E<S;E++){var D=f[E];if(P.push(w[D](y)),A)for(var R=0,T=A.length;R<T;R++)N[R].push(A[R][D](y))}}r[m]=a,l.push(a),a++}}var C=t.clone();for(p=0,d=u.length;p<d;p++){b=u[p];var I=t.getAttribute(b),O=new I.array.constructor(h[b]);w=new o.BufferAttribute(O,I.itemSize,I.normalized);if(C.setAttribute(b,w),b in c)for(x=0;x<c[b].length;x++){var H=t.morphAttributes[b][x],_=(O=new H.array.constructor(c[b][x]),new o.BufferAttribute(O,H.itemSize,H.normalized));C.morphAttributes[b][x]=_}}return C.setIndex(l),C};function ir(t){var e;return new((e=o.Triangle).bind.apply(e,Kt([void 0],t.map((function(t){return new o.Vector3(t.x,t.y,t.z)})),!1)))}var sr={at3d:function(t){return Promise.resolve().then((function(){return _e(t.file)})).then((function(t){return Ye(t)})).then((function(t){for(var e,r={chunks:[],createAt:void 0,description:void 0},n=0,i=t;n<i.length;n++){var s=i[n],o=qe.decode(s);o.chunks.length&&((e=r.chunks).push.apply(e,o.chunks),r.createAt=o.createAt,r.description=o.description)}return r})).then((function(t){return Me(t)}))},pbm:function(t){return Promise.resolve().then((function(){return _e(t.file)})).then((function(t){var e=new Uint8Array(t);return qe.decode(e)})).then((function(t){return Me(t)}))},dome:function(t){return Promise.resolve().then((function(){return tr()})).then((function(){return _e(t.file)})).then((function(t){return $e(new Uint8Array(t))}))},domez:function(t){return Promise.resolve().then((function(){return tr()})).then((function(){return _e(t.file)})).then((function(t){return Ye(t)})).then((function(t){var e=t.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(e),n=0;return t.forEach((function(t){r.set(t,n),n+=t.length})),r})).then((function(t){return $e(t)}))}},or=function(t){function e(){var e=t.call(this)||this;return e.empty=!1,e.name="model",e.loaded=!1,e.bvhs=[],e.bounding=new o.Box3,e.shownfloor=null,e.floorLength=0,e}return zt(e,t),e.prototype.getEdges=function(t){var e;void 0===t&&(t=30/180*Math.PI);for(var r=Math.cos(t),n=[],i=0,s=this.children;i<s.length;i++){var a=s[i];if(a instanceof ee){for(var u={},h=["a","b","c"],c=nr(a.geometry),l=c.getAttribute("position").array,f=(null===(e=c.getIndex())||void 0===e?void 0:e.array)||[],p=[],d=[],v=0,g=l.length;v<g;v+=3)p.push(new o.Vector3(l[v],l[v+1],l[v+2]));for(v=0,g=f.length;v<g;v+=3){var y=f[v],m=f[v+1],x=f[v+2],b=(new o.Vector3).crossVectors(p[m].clone().sub(p[y]),p[x].clone().sub(p[y])).normalize();d.push({a:y,b:m,c:x,normal:b})}for(v=0,g=d.length;v<g;v++)for(var S=d[v],E=0;E<3;E++){var w=S[h[E]],A=S[h[(E+1)%3]],P=[Math.min(w,A),Math.max(w,A)];void 0===u[N=P[0]+"-"+P[1]]?u[N]={index1:P[0],index2:P[1],face1:v}:u[N].face2=v}for(var N in u){var D=u[N];if(void 0===D.face2||d[D.face1].normal.dot(d[D.face2].normal)<=r){var R=p[D.index1],T=p[D.index2];n.push(new o.Line3(R,T))}}c.dispose(),p.length=0,d.length=0}}return n},e.prototype.hasFloors=function(){return this.hasFloors_()},e.prototype.hasFloors_=function(){var t=[];return this.traverse((function(e){e instanceof ee&&(t[e.floorIndex]=!0)})),t.length},e.prototype.show=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=0!==t.length;this.shownfloor=r?t[0]:null,this.needsRender=!0},e.prototype.intersectRaycaster=function(t,e){var r=t.ray,n=r.origin,i=r.direction;if(er(e))if(er(this.shownfloor)){var s=this.hasFloors();e=[];for(var a=0;a<s;a++)e.push(a)}else e=[this.shownfloor];var u=[],h=[];Array.isArray(e)?h.push.apply(h,e):h.push(e);for(var c=function(e){var r=l.bvhs&&l.bvhs[e];if(r){var s=new Yt(n.x,n.y,n.z),a=new Yt(i.x,i.y,i.z),h=r.intersectRay(s,a,!0).map((function(t){var e=t.intersectionPoint,r=t.triangle,i=new o.Vector3(e.x,e.y,e.z);return{point:i,face:{normal:ir(r).getNormal(new o.Vector3)},distance:n.distanceTo(i)}}));h.length&&u.push.apply(u,h)}else{var c=[];l.traverse((function(t){t instanceof ee&&t.floorIndex===e&&c.push(t)})),(h=t.intersectObjects(c).map((function(t){var e=t.face?{normal:t.face.normal}:void 0;return{point:t.point,face:e,distance:t.distance}}))).length&&u.push.apply(u,h)}},l=this,f=0,p=h;f<p.length;f++){c(p[f])}return u.filter((function(e){var r=e.distance;return r<=t.far&&r>=t.near})).sort((function(t,e){return t.distance-e.distance}))},e.prototype.buildBVH=function(){var t,e=[];this.traverse((function(t){t instanceof ee&&(e[t.floorIndex]=e[t.floorIndex]||[],e[t.floorIndex].push(t.geometry))}));var r=e.map((function(t){var e=t.reduce((function(t,e){return t+(e.index?e.index.array.length:e.attributes.position.array.length)}),0),r=new Float32Array(3*e);return t.reduce((function(t,e){for(var n=e.index?e.index.array:null,i=e.attributes.position.array,s=n?n.length:i.length/3,o=0;o<s;o++){var a=3*(t+o),u=n?3*n[o]:3*o;r[a+0]=i[u+0],r[a+1]=i[u+1],r[a+2]=i[u+2]}return t+s}),0),new te(r,10)}));this.bvhs.length=0,(t=this.bvhs).push.apply(t,r),this.bvhs.loaded=!0,this.emit("bvhLoaded")},e.prototype.load=function(t){var e=this;if(!0===this.loaded)throw new Error("model 只能被 load 一次");var r=sr[function(t,e){void 0===e&&(e=[]);var r=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(t);if(r)for(var n=String(r[1]).trim().split("."),i=0,s=e;i<s.length;i++){var o=s[i];if(n.indexOf(o)>=0)return o}}(t.file,Object.keys(sr))||""];if(!r)throw new Error("文件类型错误");return r(t).then((function(t){var r=t.createAt,n=t.description,i=t.objects;e.userData.createAt=r,e.userData.description=n,e.bounding.makeEmpty();for(var s=e.originModel=new rr,o=0,a=i;o<a.length;o++){var u=a[o];u.traverse((function(t){if(t instanceof ee){var r=t.geometry;r.boundingBox||r.computeBoundingBox(),r.boundingSphere||r.computeBoundingSphere(),e.bounding.union(r.boundingBox)}})),s.add(u)}e.add(s),e.floorLength=e.hasFloors_(),e.emit("geometryLoaded"),e.emit("loaded"),e.loaded=!0})).catch((function(t){return e.emit("error",t),Promise.reject(t)}))},e.prototype.dispose=function(){for(this.off(),this.disposeGeometry();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},e}(Qe);Object.assign(or.prototype,{on:de.prototype.on,once:de.prototype.once,off:de.prototype.off,emit:de.prototype.emit,hasListener:de.prototype.hasListener});function ar(t,e,r){return t<e?e:t>r?r:t}function ur(t){return 0===t.indexOf("//")||/^[0-9a-z]+\:/i.test(t)}function hr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=[];t=t.map((function(t){return(null!=t?t:"").trim()})).filter((function(t){return t.length>0&&!/^\/+$/.test(t)}));for(var n=0;n<t.length;n++){var i=0===n,s=n===t.length-1,o=t[n];i||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),r.push(o)}return r.join("/")}function cr(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var r,n,i;if(Array.isArray(t)){if((r=t.length)!=e.length)return!1;for(n=r;0!=n--;)if(!cr(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;0!=n--;){var s=i[n];if(!cr(t[s],e[s]))return!1}return!0}return t!=t&&e!=e}function lr(t){return"number"==typeof t}var fr=function(){return new Error("Invalid input.")},pr=function(){return new Error("Invalid certificate.")},dr=function(){return new Error("Invalid signature.")};function vr(t,e){void 0===e&&(e=!1);var r=typeof t;if("string"===r)return JSON.stringify(t);if(!0===t)return"true";if(!1===t)return"false";if(null===t)return"null";if(t instanceof Array){for(var n="[",i=t.length-1,s=0;s<i;s++)n+=vr(t[s],!1)+",";return i>-1&&(n+=vr(t[s],!1)),n+"]"}if(t instanceof Object){if("function"==typeof t.toJSON)return vr(t.toJSON(),e);var o=Object.keys(t).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],h=vr(t[u],!0);void 0!==h&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+h),s++}return"{"+n+"}"}switch(r){case"function":case"undefined":return e?void 0:null;case"number":return 0;default:return isFinite(t)?t:null}}function gr(t){return String(vr(t,!1))}function yr(t){var e,r,n;if(Array.isArray(t)){var i,s,o=void 0;if(t.length<=0)return fr();for(var a=function(e){var r=yr(t[e]);if(r instanceof Error)return{value:r};if(o){if(o!==r.issuer)return{value:pr()}}else o=r.issuer;i?r.expire.getTime()<i.getTime()&&(i=r.expire):i=r.expire,s=s?s.filter((function(t){return-1!==r.allowHosts.indexOf(t)})):r.allowHosts},u=0;u<t.length;u++){var h=a(u);if("object"==typeof h)return h.value}return ye({issuer:o,expire:i,allowHosts:s})}var c=JSON.parse(t),l="undefined"!=typeof location?location.hostname:"",f=Date.now();if("object"!=typeof c)return fr();var p=new Date("string"==typeof c.expire_at&&/^\d+$/.test(c.expire_at)?Number(c.expire_at):c.expire_at),d=Array.isArray(c.allow_hosts)?c.allow_hosts:[];if(0===l.length||/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(l)||be.filter((function(t){return xe(t,l)})).length>0){var v=String(null!==(e=c.certificate)&&void 0!==e?e:"");if(v){var g=new Ot;return g.readCertPEM(v),ye({issuer:g.getSubjectString(),expire:p,allowHosts:d})}return ye({issuer:"none",expire:p,allowHosts:d})}var y=String(null!==(r=c.certificate)&&void 0!==r?r:"");if(!y)return pr();var m=new Ot;m.readCertPEM(y);var x=String(null!==(n=c._signature)&&void 0!==n?n:"");if(!x)return dr();var b=gr(function(t,e){for(var r={},n=0,i=Object.keys(t);n<i.length;n++){var s=i[n];-1===e.indexOf(s)&&(r[s]=t[s])}return r}(c,["_signature"]));return!1===function(t,e,r){var n=new Ot;if("string"==typeof r?n.readCertPEM(r):n.readCertHex(r.hex),!1===jt(n))return!1;var i=new $;return i.readCertPubKeyHex(n.hex,6),!!i.verify(t,z(e))}(b,x,m)?dr():f<p.getTime()?0===d.filter((function(t){return xe(t,l)})).length?function(t){return new Error("host(".concat(JSON.stringify(t),") is not allowed."))}(l):ye({issuer:m.getSubjectString(),expire:p,allowHosts:d}):function(t){return new Error("date(".concat(t.toString(),") expired."))}(p)}var mr=new WeakMap,xr=function(){function t(){this.name="",this.workCode="",this.expire=new Date,this.allowHosts=[],this.initial={mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},this.observers=[],this.issuer="none",this.raw={works:[""],options:""}}return t.prototype.toJSON=function(){return this.raw.works},t.parse=wr,t}();function br(t){return null==t?"null":Array.isArray(t)?"array":"object"==typeof t?"dict":"value"}function Sr(t,e){var r=br(t),n=br(e);if("null"===n)return t;if("value"===n)return e;if(n!==r)return JSON.parse(JSON.stringify(e));if("array"===n)for(var i=0;i<e.length;i++)t[i]=Sr(t[i],e[i]);else if("dict"===n)for(var s in e)t[s]=Sr(t[s],e[s]);return t}function Er(t,e,r){for(var n,i=JSON.stringify(e),s=[],a=0,u=[].concat(t);a<u.length;a++){var h=u[a];h instanceof xr?s.push.apply(s,h.raw.works):"string"==typeof h?s.push(h):s.push(JSON.stringify(h))}var c=yr(s);if(c instanceof Error)return c;e=JSON.parse(i),t=s.map((function(t){return JSON.parse(t)})).reduce((function(t,e){return Sr(t,e)}));var l=new xr;if(c instanceof Error)return c;l.issuer=c.issuer,l.expire=c.expire,l.allowHosts=c.allowHosts,l.raw={works:s,options:i};var f=null!==(n=t.base_url)&&void 0!==n?n:"";f&&"/"!==f[f.length-1]&&(f+="/");var p=function(t,e){return 0===t.indexOf(e)},d=function(t,n){var i,s=t;if(!0===e.jsonp){s=t.replace(/([\?\#].*)?$/i,"");var o=Ht("".concat(s)).slice(0,7);s="".concat(s,".").concat(o,".jsonp")}if(!0===e.shortPath){var a=s.replace(f,"").split("."),u=null!==(i=a.shift())&&void 0!==i?i:"",h=a.join(".");s=hr(f,Ht(u))+(h?"."+h:"")}var c=s.replace(f,"");return e.baseURL&&(s=hr(e.baseURL,c)),r&&r(t,s,c,n),s},v=function(e,r){var n,i,s,o,a,u,h=e;if(!ur(e)){var c=null!==(u=null!==(o=null!==(i=null===(n=t.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==i?i:null===(s=t.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=t.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";c&&(c=hr(c,String(r))),h=hr(c,h)}return ur(h)||(h=hr(f,h)),p(h,f)||console.warn("".concat(h," is not start with base_url(").concat(f,").")),d(h,"panorama")},g=function(t){var e=t;return ur(e)||(e=hr(f,t)),p(e,f)||console.warn("".concat(e," is not start with base_url(").concat(f,").")),d(e,"model")},y=function(t,e){void 0===e&&(e="");var r=t;return ur(r)||(r=hr(e,r)),ur(r)||(r=hr(f,r)),p(r,f)||console.warn("".concat(r," is not start with base_url(").concat(f,").")),d(r,"texture")};if(c instanceof Error)return c;if(l.workCode=String(t.work_code||t.code||t.vr_code||t.workCode),l.name=String(t.name),c instanceof Error)return c;if(t.model){var m={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.modelBvh?m.bvh=e.modelBvh:"boolean"==typeof t.model.bvh?m.bvh=t.model.bvh:"boolean"==typeof t.bvh&&(m.bvh=t.bvh),t.model.file?m.file=g(t.model.file):t.model.file_url&&(m.file=g(t.model.file_url)),t.model.textureBase?m.textureBase=y("",t.model.textureBase):t.model.material_base_url?m.textureBase=y("",t.model.material_base_url):m.file&&(m.textureBase=m.file.split("/").slice(0,-1).join("/").replace("/model/","/materials/")),Array.isArray(t.model.textures)?m.textures=t.model.textures.map((function(e){var r,n;return y(e,null!==(n=null!==(r=t.model.textureBase)&&void 0!==r?r:t.model.material_base_url)&&void 0!==n?n:"")})):Array.isArray(t.model.material_textures)&&(m.textures=t.model.material_textures.map((function(e){var r,n;return y(e,null!==(n=null!==(r=t.model.textureBase)&&void 0!==r?r:t.model.material_base_url)&&void 0!==n?n:"")}))),t.model.tiles&&(m.tiles=t.model.tiles),m.file&&(l.model=m)}if(c instanceof Error)return c;if(t.observers&&Array.isArray(t.observers)){var x=[];t.panorama&&(Array.isArray(t.panorama)?x=t.panorama:Array.isArray(t.panorama.list)?x=t.panorama.list:Array.isArray(t.panorama.info)&&(x=t.panorama.info));for(var b=0;b<t.observers.length;b++){var S={},E=t.observers[b];if(!E)break;var w=x[b];if(!w)break;E=Object.assign({},E,w,{active:!1!==E.active&&!1!==w.active}),S.panoIndex=b,S.active=!1!==E.active,S.loadable=!0===E.loadable,S.images={up:v(E.images?E.images.up:E.up,b),down:v(E.images?E.images.down:E.down,b),right:v(E.images?E.images.right:E.right,b),left:v(E.images?E.images.left:E.left,b),front:v(E.images?E.images.front:E.front,b),back:v(E.images?E.images.back:E.back,b)};var A=E.images?E.images.depth:E.depth;A&&(S.images.depth=v(A,b));var P=E.images?E.images.luminance:E.luminance;P&&(S.images.luminance={up:v(P.up,b),down:v(P.down,b),right:v(P.right,b),left:v(P.left,b),front:v(P.front,b),back:v(P.back,b)});var N=E.images?E.images.tiles:E.tiles;if(N){for(var D=[],R=function(t){var e,r=t.match(/\/cube_(\d+)\//);if(r){var n=Number(r[1]);if(0==((e=n)&e-1)&&0!==e)return n}return!1},T=function(t,e){return t.replace(/\/cube_(\d+)\//,(function(){return"/cube_".concat(e,"/")}))},C=0,I=N;C<I.length;C++){var O=I[C];if("number"==typeof O){var H=O,_=R(S.images.front);if(!1===_)continue;if((K=Math.max(_,512*Math.pow(2,H)))>2048){var B=T(S.images.up,K),V=T(S.images.down,K),j=T(S.images.right,K),q=T(S.images.left,K),z=T(S.images.front,K),k=T(S.images.back,K);D.push({level:H,size:K,up:B,down:V,right:j,left:q,front:z,back:k})}else{B=S.images.up,V=S.images.down,j=S.images.right,q=S.images.left,z=S.images.front,k=S.images.back;D.push({level:H,size:K,up:B,down:V,right:j,left:q,front:z,back:k})}}else{var K;if("number"!=typeof(H=O.level))continue;if("number"!=typeof(K=O.size))continue;B=v(O.up,b),V=v(O.down,b),j=v(O.right,b),q=v(O.left,b),z=v(O.front,b),k=v(O.back,b);D.push({level:H,size:K,up:B,down:V,right:j,left:q,front:z,back:k})}}D.sort((function(t,e){return t.level-e.level})),S.images.tiles=D}if(E.position instanceof o.Vector3)S.position=E.position.clone();else{if(!Array.isArray(E.position))break;S.position=(new o.Vector3).fromArray(E.position)}if(E.standingPosition instanceof o.Vector3)S.standingPosition=E.standingPosition.clone();else if(Array.isArray(E.standingPosition))S.standingPosition=(new o.Vector3).fromArray(E.standingPosition);else if(E.standing_position instanceof o.Vector3)S.standingPosition=E.standing_position.clone();else{if(!Array.isArray(E.standing_position))break;S.standingPosition=(new o.Vector3).fromArray(E.standing_position)}if(E.quaternion instanceof o.Quaternion)S.quaternion=E.quaternion.clone();else if(Array.isArray(E.quaternion))S.quaternion=(new o.Quaternion).fromArray(E.quaternion);else{if(!E.quaternion)break;var L=E.quaternion,M=L.x,U=L.y,F=L.z,Y=L.w;S.quaternion=new o.Quaternion(M,U,F,Y)}if(Array.isArray(E.accessibleNodes)?S.accessibleNodes=E.accessibleNodes.slice():Array.isArray(E.accessible_nodes)&&(S.accessibleNodes=E.accessible_nodes.slice()),Array.isArray(E.visibleNodes)?S.visibleNodes=E.visibleNodes.slice():Array.isArray(E.visible_nodes)&&(S.visibleNodes=E.visible_nodes.slice()),lr(E.floorIndex)?S.floorIndex=E.floorIndex:lr(E.floor_index)?S.floorIndex=E.floor_index:S.floorIndex=0,E.video){var Q={};"string"==typeof E.video.source&&(Q.source=E.video.source),E.video.matrix instanceof o.Matrix4?Q.matrix=E.video.matrix.clone():Array.isArray(E.video.matrix)&&(Q.matrix=(new o.Matrix4).fromArray(E.video.matrix)),E.video.size instanceof o.Vector2?Q.size=E.video.size.clone():Array.isArray(E.video.size)&&(Q.size=(new o.Vector2).fromArray(E.video.size)),Q.source&&Q.matrix&&Q.size&&(S.video=Q)}l.observers[b]=S}}if(c instanceof Error)return c;for(var Z=0,G=l.observers;Z<G.length;Z++){if((S=G[Z]).accessibleNodes)S.accessibleNodes=S.accessibleNodes.filter((function(t){return t<l.observers.length}));else{S.accessibleNodes=[];for(var W=0;W<l.observers.length;W++)l.observers[W]!==S&&S.accessibleNodes.push(W)}if(S.visibleNodes)S.visibleNodes=S.visibleNodes.filter((function(t){return t<l.observers.length}));else{S.visibleNodes=[];for(W=0;W<l.observers.length;W++)l.observers[W]!==S&&S.visibleNodes.push(W)}}if(c instanceof Error)return c;if(t.initial)if("Floorplan"!==t.initial.mode&&"Topview"!==t.initial.mode&&"Panorama"!==t.initial.mode&&"VRPanorama"!==t.initial.mode&&"Model"!==t.initial.mode&&"DepthPanorama"!==t.initial.mode||(l.initial.mode=t.initial.mode),lr(t.initial.latitude)&&(l.initial.latitude=t.initial.latitude),lr(t.initial.longitude)?l.initial.longitude=t.initial.longitude:lr(t.initial.heading)&&(l.initial.longitude=-(360*(t.initial.heading-.25)+90)/180*Math.PI),lr(t.initial.fov)&&(l.initial.fov=t.initial.fov),lr(t.initial.panoIndex)){var X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.panoIndex,0,X)}else if(lr(t.initial.pano_index)){X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.pano_index,0,X)}else if(lr(t.initial.pano)){X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.pano,0,X)}if(c instanceof Error)return c;var J=ye(l);return mr.set(J,{works:s,options:i}),J}function wr(t,e,r){"string"==typeof t&&"{"===t.trim()[0]&&(t=JSON.parse(t));var n=mr.get(t);if(n){if(e&&!cr(JSON.parse(n.options),e))throw new Error("[PARSE FAILED]: work is parsed with different options.");return t}var i=Er(t,null!=e?e:{},r);if(i instanceof Error)throw new Error("[PARSE FAILED]: "+i.message+"\nError work input:\n"+JSON.stringify(t));return i}exports.BVH=te,exports.BVHIntersect=$t,exports.BVHNode=Qt,exports.BVHVector3=Yt,exports.Model=or,exports.PBMContainer=rr,exports.PBMGroup=Qe,exports.PBMMesh=ee,exports.Subscribe=de,exports.Work=xr,exports.parseWork=wr;
|
|
367
|
+
function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},$.prototype.decryptOAEP=function(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=X(t,16),i=this.doPrivate(n);return null==i?null:function(t,e,r,n){var i=f.crypto.MessageDigest,s=f.crypto.Util,o=null;for(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ut(s.hashHex(ht(t),o))}),t=t.toByteArray(),a=0;a<t.length;a+=1)t[a]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*n+2)throw"Cipher too short";var a,u=t.substr(1,n),h=t.substr(n+1),c=tt(h,n,r),l=[];for(a=0;a<u.length;a+=1)l[a]=u.charCodeAt(a)^c.charCodeAt(a);var p=tt(String.fromCharCode.apply(String,l),t.length-n,r),d=[];for(a=0;a<h.length;a+=1)d[a]=h.charCodeAt(a)^p.charCodeAt(a);if((d=String.fromCharCode.apply(String,d)).substr(0,n)!==r(""))throw"Hash mismatch";var v=(d=d.substr(n)).indexOf("");if((-1!=v?d.substr(0,v).lastIndexOf("\0"):-1)+1!=v)throw"Malformed data";return d.substr(v+1)}(i,this.n.bitLength()+7>>3,e,r)},void 0!==f.lang&&f.lang||(f.lang={}),f.lang.String=function(){},f.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},f.lang.String.isHex=function(t){return vt(t)},f.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},f.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=nt(t),f.lang.String.isBase64(t))},f.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},f.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},f.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},f.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var yt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function mt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==f.crypto&&f.crypto||(f.crypto={}),f.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:d.algo.MD5,sha1:d.algo.SHA1,sha224:d.algo.SHA224,sha256:d.algo.SHA256,sha384:d.algo.SHA384,sha512:d.algo.SHA512,ripemd160:d.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var n=this.getDigestInfoHex(t,e),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",o="00"+n,a="",u=i-s.length-o.length,h=0;h<u;h+=2)a+="ff";return s+a+o},this.hashString=function(t,e){return new f.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new f.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof $||t instanceof f.crypto.DSA||t instanceof f.crypto.ECDSA}},f.crypto.Util.md5=function(t){return new f.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},f.crypto.Util.ripemd160=function(t){return new f.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},f.crypto.Util.SECURERANDOMGEN=new W,f.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return f.crypto.Util.SECURERANDOMGEN.nextBytes(e),et(e)},f.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new v(f.crypto.Util.getRandomHexOfNbytes(t),16)},f.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return f.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],et(r)},f.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new v(f.crypto.Util.getRandomHexOfNbits(t),16)},f.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=f.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},f.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";if(0==r)return t;var n=e.subtract(t);return f.crypto.Util.getRandomBigIntegerZeroToMax(n).add(t)},f.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=f.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=f.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=f.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=d.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(d.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},f.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},f.crypto.MessageDigest.getHashLength=function(t){var e=f.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},f.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},f.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=f.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var n=f.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=d.algo.HMAC.create(n,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=d.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(d.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=ht(t)),void(this.pass=d.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=ot(t.utf8)),void 0!==t.rstr&&(e=ht(t.rstr)),void 0!==t.b64&&(e=q(t.b64)),void 0!==t.b64u&&(e=st(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=d.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},f.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new f.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Dt.getKey(t):Dt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==f.crypto.ECDSA&&(this.prvKey=new f.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof $&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof $&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof f.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof f.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==f.crypto.ECDSA&&(this.pubKey=new f.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof $&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof $&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==f.crypto.ECDSA&&this.pubKey instanceof f.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==f.crypto.DSA&&this.pubKey instanceof f.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=f.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Dt.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},f.crypto.Cipher=function(t){},f.crypto.Cipher.encrypt=function(t,e,r){if(e instanceof $&&e.isPublic){var n=f.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.encrypt(t);if("RSAOAEP"===n)return e.encryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.encryptOAEP(t,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},f.crypto.Cipher.decrypt=function(t,e,r){if(e instanceof $&&e.isPrivate){var n=f.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.decrypt(t);if("RSAOAEP"===n)return e.decryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.decryptOAEP(t,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},f.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof $){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},f.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}};var xt,bt,St,Et,wt,At,Pt,Nt,Dt=(xt=function(t,e,r){return bt(d.AES,t,e,r)},bt=function(t,e,r,n){var i=d.enc.Hex.parse(e),s=d.enc.Hex.parse(r),o=d.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=i;var u=t.decrypt(a,s,{iv:o});return d.enc.Hex.stringify(u)},St=function(t,e,r){return Et(d.AES,t,e,r)},Et=function(t,e,r,n){var i=d.enc.Hex.parse(e),s=d.enc.Hex.parse(r),o=d.enc.Hex.parse(n),a=t.encrypt(i,s,{iv:o}),u=d.enc.Hex.parse(a.toString());return d.enc.Base64.stringify(u)},wt={"AES-256-CBC":{proc:xt,eproc:St,keylen:32,ivlen:16},"AES-192-CBC":{proc:xt,eproc:St,keylen:24,ivlen:16},"AES-128-CBC":{proc:xt,eproc:St,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,r){return bt(d.TripleDES,t,e,r)},eproc:function(t,e,r){return Et(d.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,r){return bt(d.DES,t,e,r)},eproc:function(t,e,r){return Et(d.DES,t,e,r)},keylen:8,ivlen:8}},At=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=i&&-1!=o){var a=t.substring(i+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},Pt=function(t,e,r){for(var n=r.substring(0,16),i=d.enc.Hex.parse(n),s=d.enc.Utf8.parse(e),o=wt[t].keylen+wt[t].ivlen,a="",u=null;;){var h=d.algo.MD5.create();if(null!=u&&h.update(u),h.update(s),h.update(i),u=h.finalize(),(a+=d.enc.Hex.stringify(u)).length>=2*o)break}var c={};return c.keyhex=a.substr(0,2*wt[t].keylen),c.ivhex=a.substr(2*wt[t].keylen,2*wt[t].ivlen),c},Nt=function(t,e,r,n){var i=d.enc.Base64.parse(t),s=d.enc.Hex.stringify(i);return(0,wt[e].proc)(s,r,n)},{version:"1.0.0",parsePKCS5PEM:function(t){return At(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return Pt(t,e,r)},decryptKeyB64:function(t,e,r,n){return Nt(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=At(t),n=r.cipher,i=r.ivsalt,s=r.data,o=Pt(n,e,i).keyhex;return Nt(s,n,o,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,i){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===wt[n])throw"KEYUTIL unsupported algorithm: "+n;if(void 0===i||null==i){var o=function(t){var e=d.lib.WordArray.random(t);return d.enc.Hex.stringify(e)}(wt[n].ivlen);i=o.toUpperCase()}var a=function(t,e,r,n){return(0,wt[e].eproc)(t,r,n)}(e,n,Pt(n,r,i).keyhex,i);return s="-----BEGIN "+t+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+i+"\r\n",s+="\r\n",s+=a.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;i.ciphertext=n(t,s[1]);var o=r(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=r(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=r(t,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,u[1]);var h=r(t,a[0]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length;if("2a864886f70d01050c"!=n(t,h[0]))throw"this only supports pkcs5PBKDF2";var c=r(t,h[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;i.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=d.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=d.PBKDF2(e,r,{keySize:6,iterations:n});return d.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=ft(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=Dt.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=d.enc.Hex.parse(n.ciphertext);var o=d.enc.Hex.parse(i),a=d.enc.Hex.parse(n.encryptionSchemeIV),u=d.TripleDES.decrypt(s,o,{iv:a});return d.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(i.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=ft(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new $;else if("2a8648ce380401"==r.algoid)e=new f.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw"unsupported private key algorithm";e=new f.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=Rt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new $;else if("2a8648ce380401"===r)e=new f.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";e=new f.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=r(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=Rt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=r(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?i.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,a[1],[0],"02"),i.algparam.q=e.getVbyList(t,a[1],[1],"02"),i.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return i.key=n(t,s[1]).substr(2),i}});Dt.getKey=function(t,e,r){var n=(m=Rt).getChildIdx;m.getV;var i=m.getVbyList,s=f.crypto,o=s.ECDSA,a=s.DSA,u=$,h=ft,c=Dt;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(t.n,t.e),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(T=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(T=new u).setPrivate(t.n,t.e,t.d),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(T=new a).setPublic(t.p,t.q,t.g,t.y),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(T=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(st(t.n),st(t.e)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(T=new u).setPrivateEx(st(t.n),st(t.e),st(t.d),st(t.p),st(t.q),st(t.dp),st(t.dq),st(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(st(t.n),st(t.e),st(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(R=new o({curve:t.crv})).ecparams.keylen/4,p="04"+("0000000000"+st(t.x)).slice(-l)+("0000000000"+st(t.y)).slice(-l);return R.setPublicKeyHex(p),R}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(R=new o({curve:t.crv})).ecparams.keylen/4,p="04"+("0000000000"+st(t.x)).slice(-l)+("0000000000"+st(t.y)).slice(-l);var d=("0000000000"+st(t.d)).slice(-l);return R.setPublicKeyHex(p),R.setPrivateKeyHex(d),R}if("pkcs5prv"===r){var g,y=t,m=Rt;if(9===(g=n(y,0)).length)(T=new u).readPKCS5PrvKeyHex(y);else if(6===g.length)(T=new a).readPKCS5PrvKeyHex(y);else{if(!(g.length>2&&"04"===y.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(T=new o).readPKCS5PrvKeyHex(y)}return T}if("pkcs8prv"===r)return T=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return Ot.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Ot.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var x=ft(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(x)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var b=h(t,"RSA PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=i(O=h(t,"DSA PRIVATE KEY"),0,[1],"02"),E=i(O,0,[2],"02"),w=i(O,0,[3],"02"),A=i(O,0,[4],"02"),P=i(O,0,[5],"02");return(T=new a).setPrivate(new v(S,16),new v(E,16),new v(w,16),new v(A,16),new v(P,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){b=h(t,"EC PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var N=c.getDecryptedKeyHex(t,e),D=new $;return D.readPKCS5PrvKeyHex(N),D}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R,T=i(O=c.getDecryptedKeyHex(t,e),0,[1],"04"),C=i(O,0,[2,0],"06"),I=i(O,0,[3,0],"03").substr(2);if(void 0===f.crypto.OID.oidhex2name[C])throw"undefined OID(hex) in KJUR.crypto.OID: "+C;return(R=new o({curve:f.crypto.OID.oidhex2name[C]})).setPublicKeyHex(I),R.setPrivateKeyHex(T),R.isPublic=!1,R}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var O;S=i(O=c.getDecryptedKeyHex(t,e),0,[1],"02"),E=i(O,0,[2],"02"),w=i(O,0,[3],"02"),A=i(O,0,[4],"02"),P=i(O,0,[5],"02");return(T=new a).setPrivate(new v(S,16),new v(E,16),new v(w,16),new v(A,16),new v(P,16)),T}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Dt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new $).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new $,i=o.n.toString(16),s=o.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,u=e,h=new f.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new f.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),o.setPrivateKeyHex(h.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new f.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Dt.getPEM=function(t,e,r,n,i,s){var o=f,a=o.asn1,u=a.DERObjectIdentifier,h=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,p=o.crypto,v=p.DSA,g=p.ECDSA,y=$;function m(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function x(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function b(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==y&&t instanceof y||void 0!==v&&t instanceof v||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return lt(A=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==y&&t instanceof y&&(void 0===r||null==r)&&1==t.isPrivate)return lt(A=m(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var S=new u({name:t.curveName}).getEncodedHex(),E=x(t).getEncodedHex(),w="";return w+=lt(S,"EC PARAMETERS"),w+=lt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==v&&t instanceof v&&(void 0===r||null==r)&&1==t.isPrivate)return lt(A=b(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==y&&t instanceof y&&void 0!==r&&null!=r&&1==t.isPrivate){var A=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate){A=x(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==v&&t instanceof v&&void 0!==r&&null!=r&&1==t.isPrivate){A=b(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,n,s)}var P=function(t,e){var r=N(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},N=function(t,e){var r=d.lib.WordArray.random(8),n=d.lib.WordArray.random(8),i=d.PBKDF2(e,r,{keySize:6,iterations:100}),s=d.enc.Hex.parse(t),o=d.TripleDES.encrypt(s,i,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=d.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=d.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=y&&t instanceof y&&1==t.isPrivate){var D=m(t).getEncodedHex();A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){D=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==v&&t instanceof v&&1==t.isPrivate){D=new h({bigint:t.x}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:D}}]}).getEncodedHex();return void 0===r||null==r?lt(A,"PRIVATE KEY"):lt(E=P(A,r),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Dt.getKeyFromCSRPEM=function(t){var e=ft(t,"CERTIFICATE REQUEST");return Dt.getKeyFromCSRHex(e)},Dt.getKeyFromCSRHex=function(t){var e=Dt.parseCSRHex(t);return Dt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Dt.parseCSRHex=function(t){var e=Rt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=r(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=r(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return i.p8pubkeyhex=n(s,a[2]),i},Dt.getKeyID=function(t){var e=Dt,r=Rt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=ft(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return f.crypto.Util.hashHex(s,"sha1")},Dt.getJWKFromKey=function(t){var e={};if(t instanceof $&&t.isPrivate)return e.kty="RSA",e.n=it(t.n.toString(16)),e.e=it(t.e.toString(16)),e.d=it(t.d.toString(16)),e.p=it(t.p.toString(16)),e.q=it(t.q.toString(16)),e.dp=it(t.dmp1.toString(16)),e.dq=it(t.dmq1.toString(16)),e.qi=it(t.coeff.toString(16)),e;if(t instanceof $&&t.isPublic)return e.kty="RSA",e.n=it(t.n.toString(16)),e.e=it(t.e.toString(16)),e;if(t instanceof f.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=it(r.x),e.y=it(r.y),e.d=it(t.prvKeyHex),e}if(t instanceof f.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=it(r.x),e.y=it(r.y),e}throw"not supported key object"},void 0!==f.asn1&&f.asn1||(f.asn1={}),f.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new v(n,16).xor(t).add(v.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return lt(t,e)},this.newObject=function(t){var e=f.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,u=e.DERObjectIdentifier,h=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,p=e.DERPrintableString,d=e.DERTeletexString,v=e.DERIA5String,g=e.DERUTCTime,y=e.DERGeneralizedTime,m=e.DERVisibleString,x=e.DERBMPString,b=e.DERSequence,S=e.DERSet,E=e.DERTaggedObject,w=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var P=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":"))throw new Error("undefined key: "+P);if("bool"==P)return new n(t[P]);if("int"==P)return new i(t[P]);if("bitstr"==P)return new s(t[P]);if("octstr"==P)return new o(t[P]);if("null"==P)return new a(t[P]);if("oid"==P)return new u(t[P]);if("enum"==P)return new h(t[P]);if("utf8str"==P)return new c(t[P]);if("numstr"==P)return new l(t[P]);if("prnstr"==P)return new p(t[P]);if("telstr"==P)return new d(t[P]);if("ia5str"==P)return new v(t[P]);if("utctime"==P)return new g(t[P]);if("gentime"==P)return new y(t[P]);if("visstr"==P)return new m(t[P]);if("bmpstr"==P)return new x(t[P]);if("asn1"==P)return new r(t[P]);if("seq"==P){for(var N=t[P],D=[],R=0;R<N.length;R++){var T=w(N[R]);D.push(T)}return new b({array:D})}if("set"==P){for(N=t[P],D=[],R=0;R<N.length;R++){T=w(N[R]);D.push(T)}return new S({array:D})}if("tag"==P){var C=t[P];if("[object Array]"===Object.prototype.toString.call(C)&&3==C.length){var I=w(C[2]);return new E({tag:C[0],explicit:C[1],obj:I})}return new E(C)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},f.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new v(n,2).toString(10),n=""}return e},f.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new v(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";n=s+n;for(o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},f.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},f.asn1.DERAbstractString=function(t){f.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=ot(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},p.lang.extend(f.asn1.DERAbstractString,f.asn1.ASN1Object),f.asn1.DERAbstractTime=function(t){f.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=rt(t)},this.setByDateValue=function(t,e,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(f.asn1.DERAbstractTime,f.asn1.ASN1Object),f.asn1.DERAbstractStructured=function(t){f.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},p.lang.extend(f.asn1.DERAbstractStructured,f.asn1.ASN1Object),f.asn1.DERBoolean=function(t){f.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},p.lang.extend(f.asn1.DERBoolean,f.asn1.ASN1Object),f.asn1.DERInteger=function(t){f.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=f.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(f.asn1.DERInteger,f.asn1.ASN1Object),f.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=f.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}f.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},p.lang.extend(f.asn1.DERBitString,f.asn1.ASN1Object),f.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=f.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}f.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},p.lang.extend(f.asn1.DEROctetString,f.asn1.DERAbstractString),f.asn1.DERNull=function(){f.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(f.asn1.DERNull,f.asn1.ASN1Object),f.asn1.DERObjectIdentifier=function(t){f.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=parseInt(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var n="",i=t.split("."),s=40*parseInt(i[0],10)+parseInt(i[1],10);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=f.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},p.lang.extend(f.asn1.DERObjectIdentifier,f.asn1.ASN1Object),f.asn1.DEREnumerated=function(t){f.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=f.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(f.asn1.DEREnumerated,f.asn1.ASN1Object),f.asn1.DERUTF8String=function(t){f.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},p.lang.extend(f.asn1.DERUTF8String,f.asn1.DERAbstractString),f.asn1.DERNumericString=function(t){f.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},p.lang.extend(f.asn1.DERNumericString,f.asn1.DERAbstractString),f.asn1.DERPrintableString=function(t){f.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},p.lang.extend(f.asn1.DERPrintableString,f.asn1.DERAbstractString),f.asn1.DERTeletexString=function(t){f.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},p.lang.extend(f.asn1.DERTeletexString,f.asn1.DERAbstractString),f.asn1.DERIA5String=function(t){f.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},p.lang.extend(f.asn1.DERIA5String,f.asn1.DERAbstractString),f.asn1.DERVisibleString=function(t){f.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},p.lang.extend(f.asn1.DERVisibleString,f.asn1.DERAbstractString),f.asn1.DERBMPString=function(t){f.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},p.lang.extend(f.asn1.DERBMPString,f.asn1.DERAbstractString),f.asn1.DERUTCTime=function(t){f.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=rt(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=rt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},p.lang.extend(f.asn1.DERUTCTime,f.asn1.DERAbstractTime),f.asn1.DERGeneralizedTime=function(t){f.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=rt(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=rt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},p.lang.extend(f.asn1.DERGeneralizedTime,f.asn1.DERAbstractTime),f.asn1.DERSequence=function(t){f.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},p.lang.extend(f.asn1.DERSequence,f.asn1.DERAbstractStructured),f.asn1.DERSet=function(t){f.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},p.lang.extend(f.asn1.DERSet,f.asn1.DERAbstractStructured),f.asn1.DERTaggedObject=function(t){f.asn1.DERTaggedObject.superclass.constructor.call(this);var e=f.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){null!=t.tag&&(this.hT=t.tag),null!=t.explicit&&(this.isExplicit=t.explicit),null!=t.tage&&(this.hT=t.tage,this.isExplicit=!0),null!=t.tagi&&(this.hT=t.tagi,this.isExplicit=!1),null!=t.obj&&(t.obj instanceof e.ASN1Object?(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof t.obj&&(this.asn1Object=e.ASN1Util.newObject(t.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=t&&this.setByParam(t)},p.lang.extend(f.asn1.DERTaggedObject,f.asn1.ASN1Object);var Rt=new function(){};function Tt(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t}function Ct(t,e,r){for(var n="",i=0;n.length<e;)n+=ut(r(ht(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function It(t){for(var e in f.crypto.Util.DIGESTINFOHEAD){var r=f.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function Ot(t){var e,r=Rt,n=r.getChildIdx,i=r.getV,s=r.getTLV,o=r.getVbyList,a=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,c=r.getIdxbyList,l=r.getIdxbyListEx,p=r.getVidx,d=r.getInt,v=r.oidname,g=r.hextooidstr,y=ft;try{e=f.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=d(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return v(a(t,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return u(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=o(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return c(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Dt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),i=new f.crypto.Signature({alg:e});return i.init(t),i.updateHex(n),i.verify(r)},this.parseExt=function(t){var e,s,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=c(a,0,[0,7,0],"30"),s=n(a,e)}else{a=ft(t);var u=c(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,u))return void(this.aExtInfo=new Array);e=c(a,0,[0,3,0,1,0],"30"),s=n(a,e),this.hex=a}this.aExtInfo=new Array;for(var h=0;h<s.length;h++){var l={critical:!1},f=0;3===n(a,s[h]).length&&(l.critical=!0,f=1),l.oid=r.hextooidstr(o(a,s[h],[0],"06"));var d=c(a,s[h],[1+f]);l.vidx=p(a,d),this.aExtInfo.push(l)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=f.asn1.x509.OID.name2oid(t)),""!==r)for(var n=0;n<e.length;n++)if(e[n].oid===r)return e[n]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"basicConstraints"};if(e&&(n.critical=!0),"3000"===t)return n;if("30030101ff"===t)return n.cA=!0,n;if("30060101ff02"===t.substr(0,12)){var o=i(t,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+t)},this.getExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("keyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"keyUsage"};return e&&(n.critical=!0),n.names=this.getExtKeyUsageString(t).split(","),n},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=s(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,n=0;n<e.length;n++)"1"==e.substr(n,1)&&r.push(Ot.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectKeyIdentifier"};e&&(n.critical=!0);var o=i(t,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"authorityKeyIdentifier"};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++){var h=t.substr(a[u],2);if("80"===h&&(o.kid={hex:i(t,a[u])}),"a1"===h){var c=s(t,a[u]),l=this.getGeneralNames(c);o.issuer=l[0].dn}"82"===h&&(o.sn={hex:i(t,a[u])})}return o},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"extKeyUsage",array:[]};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++)o.array.push(v(i(t,a[u])));return o},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=s(this.hex,t.vidx);if(""===r)return e;for(var o=n(r,0),a=0;a<o.length;a++)e.push(v(i(r,o[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"issuerAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getGeneralNames=function(t){for(var e=n(t,0),r=[],i=0;i<e.length;i++){var o=this.getGeneralName(s(t,e[i]));void 0!==o&&r.push(o)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=i(t,0),n=ut(r);return"81"==e?{rfc822:n}:"82"==e?{dns:n}:"86"==e?{uri:n}:"87"==e?{ip:pt(r)}:"a4"==e?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),h=n(u,0),c=0;c<h.length;c++)r=u.substr(h[c],2),t=i(u,h[c]),"81"===r&&(e=at(t),a.push(["MAIL",e])),"82"===r&&(e=at(t),a.push(["DNS",e])),"84"===r&&(e=Ot.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=at(t),a.push(["URI",e])),"87"===r&&(e=pt(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"cRLDistributionPoints",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]);i.array.push(this.getDistributionPoint(u))}return i},this.getDistributionPoint=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var e=new Array,r=n(this.hex,t.vidx),i=0;i<r.length;i++)try{var s=at(o(this.hex,r[i],[0,0,0],"86"));e.push(s)}catch(t){}return e},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=n(this.hex,t.vidx),i=0;i<r.length;i++){var s=o(this.hex,r[i],[0],"06"),a=o(this.hex,r[i],[1],"86");"2b06010505073001"===s&&e.ocsp.push(at(a)),"2b06010505073002"===s&&e.caissuer.push(at(a))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"authorityInfoAccess",array:[]};e&&(i.critical=!0);for(var u=n(t,0),h=0;h<u.length;h++){var c=a(t,u[h],[0],"06"),l=at(o(t,u[h],[1],"86"));if("2b06010505073001"==c)i.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);i.array.push({caissuer:l})}}return i},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"certificatePolicies",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]),h=this.getPolicyInformation(u);i.array.push(h)}return i},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=v(r);var i=l(t,0,[1],"30");if(-1!=i){e.array=[];for(var a=n(t,i),u=0;u<a.length;u++){var h=s(t,a[u]),c=this.getPolicyQualifierInfo(h);e.array.push(c)}}return e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var n=a(t,0,[1],"16");e.cps=ut(n)}else if("2b06010505070202"===r){var i=u(t,0,[1],"30");e.unotice=this.getUserNotice(i)}return e},this.getUserNotice=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]);"30"!=o.substr(0,2)&&(e.exptext=this.getDisplayText(o))}return e},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=ut(i(t,0)),e},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:i(t,0)},r;throw new Error("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(i(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var n=i(t,0);return r.hex=n,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"adobeTimeStamp"};e&&(i.critical=!0);var o=n(t,0);if(o.length>1){var a=s(t,o[1]),u=this.getGeneralName(a);null!=u.uri&&(i.uri=u.uri)}if(o.length>2){var h=s(t,o[2]);"0101ff"==h&&(i.reqauth=!0),"010100"==h&&(i.reqauth=!1)}return i},this.getX500NameRule=function(t){for(var e=null,r=[],n=0;n<t.length;n++)for(var i=t[n],s=0;s<i.length;s++)r.push(i[s]);for(n=0;n<r.length;n++){var o=r[n],a=o.ds,u=o.value,h=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=h)return"mixed";if(f.lang.String.isMail(u))continue;return"mixed"}if("C"==h){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getX500Name=function(t){var e=this.getX500NameArray(t);return{array:e,str:this.dnarraytostr(e)}},this.getX500NameArray=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getRDN(s(t,r[i])));return e},this.getRDN=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getAttrTypeAndValue(s(t,r[i])));return e},this.getAttrTypeAndValue=function(t){var e={type:null,value:null,ds:null},r=n(t,0),i=o(t,r[0],[],"06"),s=o(t,r[1],[]),a=f.asn1.ASN1Util.oidHexToInt(i);return e.type=f.asn1.x509.OID.oid2atype(a),e.ds=this.HEX2STAG[t.substr(r[1],2)],"bmp"!=e.ds?e.value=at(s):e.value=dt(s),e},this.readCertPEM=function(t){this.readCertHex(y(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{c(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(){var t={};return t.version=this.getVersion(),t.serial={hex:this.getSerialNumberHex()},t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.notbefore=this.getNotBefore(),t.notafter=this.getNotAfter(),t.subject=this.getSubject(),t.sbjpubkey=lt(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=l(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]),a=this.getExtParam(o);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=n(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=g(o(t,0,[0],"06")),i=!1;3==e&&"0101ff"==u(t,0,[1])&&(i=!0);var s=u(t,0,[e-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(s,i):"2.5.29.15"==r?a=this.getExtKeyUsage(s,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(s,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(s,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(s,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(s,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(s,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(s,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(s,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(s,i):"2.5.29.20"==r?a=this.getExtCRLNumber(s,i):"2.5.29.21"==r?a=this.getExtCRLReason(s,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(s,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(s,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(s,i)),null!=a)return a;var h={extname:r,extn:s};return i&&(h.critical=!0),h},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var s=n[i].dpname.full,o=0;o<s.length;o++){var a=s[i];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map((function(t){return function(t){return t.map((function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")})).join("+")}(t).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var t,e,r,n,i=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var o=i.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+Ot.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+gt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+gt(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var u=r[a],h=f.asn1.x509.OID.oid2name(u.oid);""===h&&(h=u.oid);var c="";if(!0===u.critical&&(c="CRITICAL"),t+=" "+h+" "+c+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else if("keyUsage"===h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===h){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else{if("extKeyUsage"===h)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===h)t+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===h)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===h)t+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===h&&(t+=i(this.getExtCertificatePolicies()))}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):f.lang.String.isHex(t)&&this.readCertHex(t))}function _t(t){return d.SHA256(t).toString()}Rt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},Rt.getL=function(t,e){var r=Rt.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},Rt.getVblen=function(t,e){var r;return""==(r=Rt.getL(t,e))?-1:("8"===r.substr(0,1)?new v(r.substr(2),16):new v(r,16)).intValue()},Rt.getVidx=function(t,e){var r=Rt.getLblen(t,e);return r<0?r:e+2*(r+1)},Rt.getV=function(t,e){var r=Rt.getVidx(t,e),n=Rt.getVblen(t,e);return t.substr(r,2*n)},Rt.getTLV=function(t,e){return t.substr(e,2)+Rt.getL(t,e)+Rt.getV(t,e)},Rt.getTLVblen=function(t,e){return 2+2*Rt.getLblen(t,e)+2*Rt.getVblen(t,e)},Rt.getNextSiblingIdx=function(t,e){return Rt.getVidx(t,e)+2*Rt.getVblen(t,e)},Rt.getChildIdx=function(t,e){var r,n,i,s=Rt,o=[];r=s.getVidx(t,e),n=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var u=s.getTLVblen(t,a);if((i+=u)<=n&&o.push(a),a+=u,i>=n)break}return o},Rt.getNthChildIdx=function(t,e,r){return Rt.getChildIdx(t,e)[r]},Rt.getIdxbyList=function(t,e,r,n){var i,s,o=Rt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[i],r,n)},Rt.getIdxbyListEx=function(t,e,r,n){var i,s,o=Rt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=o.getChildIdx(t,e);for(var a=0,u=0;u<s.length;u++){var h=t.substr(s[u],2);if("number"==typeof i&&!o.isContextTag(h)&&a==i||"string"==typeof i&&o.isContextTag(h,i))return o.getIdxbyListEx(t,s[u],r,n);o.isContextTag(h)||a++}return-1},Rt.getTLVbyList=function(t,e,r,n){var i=Rt,s=i.getIdxbyList(t,e,r,n);return-1==s||s>=t.length?null:i.getTLV(t,s)},Rt.getTLVbyListEx=function(t,e,r,n){var i=Rt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},Rt.getVbyList=function(t,e,r,n,i){var s,o,a=Rt;return-1==(s=a.getIdxbyList(t,e,r,n))||s>=t.length?null:(o=a.getV(t,s),!0===i&&(o=o.substr(2)),o)},Rt.getVbyListEx=function(t,e,r,n,i){var s,o,a=Rt;return-1==(s=a.getIdxbyListEx(t,e,r,n))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(o=o.substr(2)),o)},Rt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=Rt.getV(t,e);return"02"==n?parseInt(i,16):function(t){try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16),n=t.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(t){return-1}}(i)}catch(t){return r}},Rt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:function(t){if(!vt(t))return null;try{var e=[],r=t.substr(0,2),n=parseInt(r,16);e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40);for(var i=t.substr(2),s=[],o=0;o<i.length/2;o++)s.push(parseInt(i.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=yt((127&s[o]).toString(2),7):(u+=yt((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var h=e.join(".");return a.length>0&&(h=h+"."+a.join(".")),h}catch(t){return null}}(Rt.getV(t,e))}catch(t){return r}},Rt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=Rt.getOID(t,e,r);if(n==r)return r;var i=f.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},Rt.getString=function(t,e,r){null==r&&(r=null);try{return ut(Rt.getV(t,e))}catch(t){return r}},Rt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],h="";for(a=0;a<o.length;a++)128&o[a]?h+=e((127&o[a]).toString(2),7):(h+=e((127&o[a]).toString(2),7),u.push(new String(parseInt(h,2))),h="");var c=r.join(".");return u.length>0&&(c=c+"."+u.join(".")),c},Rt.dump=function(t,e,r,n){var i=Rt,s=i.getV,o=i.dump,a=i.getChildIdx,u=t;t instanceof f.asn1.ASN1Object&&(u=t.getEncodedHex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var c,l=e.ommit_long_octet;if("01"==(c=u.substr(r,2)))return"00"==(p=s(u,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==c)return n+"INTEGER "+h(p=s(u,r),l)+"\n";if("03"==c){var p=s(u,r);if(i.isASN1HEX(p.substr(2))){var d=n+"BITSTRING, encapsulates\n";return d+=o(p.substr(2),e,0,n+" ")}return n+"BITSTRING "+h(p,l)+"\n"}if("04"==c){p=s(u,r);if(i.isASN1HEX(p)){d=n+"OCTETSTRING, encapsulates\n";return d+=o(p,e,0,n+" ")}return n+"OCTETSTRING "+h(p,l)+"\n"}if("05"==c)return n+"NULL\n";if("06"==c){var v=s(u,r),g=f.asn1.ASN1Util.oidHexToInt(v),y=f.asn1.x509.OID.oid2name(g),m=g.replace(/\./g," ");return""!=y?n+"ObjectIdentifier "+y+" ("+m+")\n":n+"ObjectIdentifier ("+m+")\n"}if("0a"==c)return n+"ENUMERATED "+parseInt(s(u,r))+"\n";if("0c"==c)return n+"UTF8String '"+at(s(u,r))+"'\n";if("13"==c)return n+"PrintableString '"+at(s(u,r))+"'\n";if("14"==c)return n+"TeletexString '"+at(s(u,r))+"'\n";if("16"==c)return n+"IA5String '"+at(s(u,r))+"'\n";if("17"==c)return n+"UTCTime "+at(s(u,r))+"\n";if("18"==c)return n+"GeneralizedTime "+at(s(u,r))+"\n";if("1a"==c)return n+"VisualString '"+at(s(u,r))+"'\n";if("1e"==c)return n+"BMPString '"+dt(s(u,r))+"'\n";if("30"==c){if("3000"==u.substr(r,4))return n+"SEQUENCE {}\n";d=n+"SEQUENCE\n";var x=e;if((2==(E=a(u,r)).length||3==E.length)&&"06"==u.substr(E[0],2)&&"04"==u.substr(E[E.length-1],2)){y=i.oidname(s(u,E[0]));var b=JSON.parse(JSON.stringify(e));b.x509ExtName=y,x=b}for(var S=0;S<E.length;S++)d+=o(u,x,E[S],n+" ");return d}if("31"==c){d=n+"SET\n";var E=a(u,r);for(S=0;S<E.length;S++)d+=o(u,e,E[S],n+" ");return d}if(0!=(128&(c=parseInt(c,16)))){var w=31&c;if(0!=(32&c)){for(d=n+"["+w+"]\n",E=a(u,r),S=0;S<E.length;S++)d+=o(u,e,E[S],n+" ");return d}p=s(u,r);if(Rt.isASN1HEX(p)){var d=n+"["+w+"]\n";return d+=o(p,e,0,n+" ")}return("68747470"==p.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==w)&&(p=at(p)),d=n+"["+w+"] "+p+"\n"}return n+"UNKNOWN("+c+") "+s(u,r)+"\n"},Rt.isContextTag=function(t,e){var r,n;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},Rt.isASN1HEX=function(t){var e=Rt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},Rt.checkStrictDER=function(t,e,r,n,i){var s=Rt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!f.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>n)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),u=a.length-2-s.getL(t,e).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var h=t.substr(e,2);if("02"===h){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=s.getVblen(t,e),p=0,d=s.getChildIdx(t,e),v=0;v<d.length;v++){p+=s.getTLV(t,d[v]).length,s.checkStrictDER(t,d[v],r,n,i)}if(2*l!=p)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+p)}},Rt.oidname=function(t){var e=f.asn1;f.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==f.asn1&&f.asn1||(f.asn1={}),void 0!==f.asn1.x509&&f.asn1.x509||(f.asn1.x509={}),f.asn1.x509.Certificate=function(t){f.asn1.x509.Certificate.superclass.constructor.call(this);var e=f.asn1,r=e.DERBitString,n=e.DERSequence,i=e.x509,s=i.TBSCertificate,o=i.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.getEncodedHex(),n=new f.crypto.Signature({alg:e});n.init(t.cakey),n.updateHex(r),t.sighex=n.sign()},this.getPEM=function(){return lt(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).getEncodedHex()},null!=t&&(this.params=t)},mt(f.asn1.x509.Certificate,f.asn1.ASN1Object),f.asn1.x509.TBSCertificate=function(t){f.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=f.asn1,r=e.x509,n=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,u=r.X500Name,h=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new n({obj:new i({int:r})});t.push(l)}return t.push(new i(e.serial)),t.push(new o({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new u(e.subject)),t.push(new c(Dt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new n({tag:"a3",obj:new h(e.ext)})),new f.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.TBSCertificate,f.asn1.ASN1Object),f.asn1.x509.Extensions=function(t){f.asn1.x509.Extensions.superclass.constructor.call(this);var e=f.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var i=this.aParam[e],s=i.extname,o=null;if(null!=i.extn)o=new n.PrivateExtension(i);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(i);else if("keyUsage"==s)o=new n.KeyUsage(i);else if("subjectAltName"==s)o=new n.SubjectAltName(i);else if("issuerAltName"==s)o=new n.IssuerAltName(i);else if("basicConstraints"==s)o=new n.BasicConstraints(i);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(i);else if("certificatePolicies"==s)o=new n.CertificatePolicies(i);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(i);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(i);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(i);else if("cRLNumber"==s)o=new n.CRLNumber(i);else if("cRLReason"==s)o=new n.CRLReason(i);else if("ocspNonce"==s)o=new n.OCSPNonce(i);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(i);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(i);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(i));o=new n.SubjectDirectoryAttributes(i)}null!=o&&t.push(o)}return new r({array:t}).getEncodedHex()},null!=t&&this.setByParam(t)},mt(f.asn1.x509.Extensions,f.asn1.ASN1Object),f.asn1.x509.Extension=function(t){f.asn1.x509.Extension.superclass.constructor.call(this);var e=f.asn1,r=e.DERObjectIdentifier,n=e.DEROctetString;e.DERBitString;var i=e.DERBoolean,s=e.DERSequence;this.getEncodedHex=function(){var t=new r({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new i),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},mt(f.asn1.x509.Extension,f.asn1.ASN1Object),f.asn1.x509.KeyUsage=function(t){f.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Ot.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new f.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var r=t.names,n="000000000",i=0;i<r.length;i++)for(var s=0;s<e.length;s++)r[i]===e[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new f.asn1.DERBitString({bin:n})}},mt(f.asn1.x509.KeyUsage,f.asn1.x509.Extension),f.asn1.x509.BasicConstraints=function(t){f.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},mt(f.asn1.x509.BasicConstraints,f.asn1.x509.Extension),f.asn1.x509.CRLDistributionPoints=function(t){f.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=f.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var n=[],i=0;i<t.length;i++)if(t[i]instanceof f.asn1.ASN1Object)n.push(t[i]);else{var s=new r.DistributionPoint(t[i]);n.push(s)}this.asn1ExtnValue=new e.DERSequence({array:n})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},mt(f.asn1.x509.CRLDistributionPoints,f.asn1.x509.Extension),f.asn1.x509.DistributionPoint=function(t){f.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=f.asn1,r=e.x509.DistributionPointName;this.getEncodedHex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},mt(f.asn1.x509.DistributionPoint,f.asn1.ASN1Object),f.asn1.x509.DistributionPointName=function(t){f.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=f.asn1,r=e.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},mt(f.asn1.x509.DistributionPointName,f.asn1.ASN1Object),f.asn1.x509.CertificatePolicies=function(t){f.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=f.asn1,r=e.x509,n=e.DERSequence,i=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var r=new n({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},mt(f.asn1.x509.CertificatePolicies,f.asn1.x509.Extension),f.asn1.x509.PolicyInformation=function(t){f.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,i=e.x509.PolicyQualifierInfo;this.params=null,this.getEncodedHex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new i(this.params.array[s]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.PolicyInformation,f.asn1.ASN1Object),f.asn1.x509.PolicyQualifierInfo=function(t){f.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},mt(f.asn1.x509.PolicyQualifierInfo,f.asn1.ASN1Object),f.asn1.x509.UserNotice=function(t){f.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=f.asn1.DERSequence;f.asn1.DERInteger;var r=f.asn1.x509.DisplayText,n=f.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.UserNotice,f.asn1.ASN1Object),f.asn1.x509.NoticeReference=function(t){f.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=f.asn1.DERSequence,r=f.asn1.DERInteger,n=f.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,o=0;o<s.length;o++)i.push(new r(s[o]));t.push(new e({array:i}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},mt(f.asn1.x509.NoticeReference,f.asn1.ASN1Object),f.asn1.x509.DisplayText=function(t){f.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},mt(f.asn1.x509.DisplayText,f.asn1.DERAbstractString),f.asn1.x509.ExtKeyUsage=function(t){f.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=f.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var n=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},mt(f.asn1.x509.ExtKeyUsage,f.asn1.x509.Extension),f.asn1.x509.AuthorityKeyIdentifier=function(t){f.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=f,r=e.asn1,n=r.DERTaggedObject,i=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new n({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new f.asn1.DEROctetString(t);else if("object"==typeof t&&f.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Dt.getKey(t));var r=Dt.getKeyID(e);this.asn1KID=new f.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new f.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new f.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new f.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new Ot;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new f.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},mt(f.asn1.x509.AuthorityKeyIdentifier,f.asn1.x509.Extension),f.asn1.x509.SubjectKeyIdentifier=function(t){f.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=f.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&f.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Dt.getKey(t));var n=Dt.getKeyID(r);this.asn1KID=new f.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},mt(f.asn1.x509.SubjectKeyIdentifier,f.asn1.x509.Extension),f.asn1.x509.AuthorityInfoAccess=function(t){f.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=f.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,u=t[o];if(void 0!==u.ocsp)a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:u.ocsp})]});else{if(void 0===u.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(u));a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}e.push(a)}this.asn1ExtnValue=new n({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},mt(f.asn1.x509.AuthorityInfoAccess,f.asn1.x509.Extension),f.asn1.x509.SubjectAltName=function(t){f.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new f.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},mt(f.asn1.x509.SubjectAltName,f.asn1.x509.Extension),f.asn1.x509.IssuerAltName=function(t){f.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new f.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},mt(f.asn1.x509.IssuerAltName,f.asn1.x509.Extension),f.asn1.x509.SubjectDirectoryAttributes=function(t){f.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERSequence,n=e.ASN1Util.newObject,i=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new n(o))}var a=new r({array:t});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},mt(f.asn1.x509.SubjectDirectoryAttributes,f.asn1.x509.Extension),f.asn1.x509.PrivateExtension=function(t){f.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=f,r=e.lang.String.isHex,n=e.asn1,i=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=i(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return s(t).getEncodedHex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},mt(f.asn1.x509.PrivateExtension,f.asn1.x509.Extension),f.asn1.x509.CRL=function(t){f.asn1.x509.CRL.superclass.constructor.call(this);var e=f.asn1,r=e.DERSequence,n=e.DERBitString,i=e.x509,s=i.AlgorithmIdentifier,o=i.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).getEncodedHex(),e=new f.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return lt(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).getEncodedHex()},null!=t&&(this.params=t)},mt(f.asn1.x509.CRL,f.asn1.ASN1Object),f.asn1.x509.TBSCertList=function(t){f.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=f.asn1,r=e.DERInteger,n=e.DERSequence,i=e.DERTaggedObject;e.DERObjectIdentifier;var s=e.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,h=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,i=0;i<e.length;i++){var s=[new r(e[i].sn),new a(e[i].date)];null!=e[i].ext&&s.push(new u(e[i].ext)),t.push(new n({array:s}))}return new n({array:t})},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new r({int:s});t.push(c)}if(t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new u(e.ext);t.push(new i({tag:"a0",explicit:!0,obj:l}))}return new n({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.TBSCertList,f.asn1.ASN1Object),f.asn1.x509.CRLEntry=function(t){f.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=f.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},mt(f.asn1.x509.CRLEntry,f.asn1.ASN1Object),f.asn1.x509.CRLNumber=function(t){f.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},mt(f.asn1.x509.CRLNumber,f.asn1.x509.Extension),f.asn1.x509.CRLReason=function(t){f.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},mt(f.asn1.x509.CRLReason,f.asn1.x509.Extension),f.asn1.x509.OCSPNonce=function(t){f.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},mt(f.asn1.x509.OCSPNonce,f.asn1.x509.Extension),f.asn1.x509.OCSPNoCheck=function(t){f.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new f.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},mt(f.asn1.x509.OCSPNoCheck,f.asn1.x509.Extension),f.asn1.x509.AdobeTimeStamp=function(t){f.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=f.asn1,r=e.DERInteger,n=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new n(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.AdobeTimeStamp,f.asn1.x509.Extension),f.asn1.x509.X500Name=function(t){f.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=f.asn1,r=e.x509,n=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var i=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))i.push(r[s]);else{var o=i.length-1;i[o]=i[o]+"/"+r[s]}for(s=0;s<i.length;s++)this.asn1Array.push(new n({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var n=r.X500Name.ldapToCompat(t);this.setByString(n,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var i=new n({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(i):this.asn1Array=[i]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new Ot).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new Ot).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new n(r);this.asn1Array.push(i)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.X500Name,f.asn1.ASN1Object),f.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),(e=e.map((function(t){return t.replace(/,/,"\\,")}))).join(",")},f.asn1.x509.X500Name.onelineToLDAP=function(t){return f.asn1.x509.X500Name.compatToLDAP(t)},f.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},f.asn1.x509.X500Name.ldapToOneline=function(t){return f.asn1.x509.X500Name.ldapToCompat(t)},f.asn1.x509.RDN=function(t){f.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=f.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new f.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=f.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var n=new e(r);this.asn1Array.push(n)}var i=new f.asn1.DERSet({array:this.asn1Array});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.RDN,f.asn1.ASN1Object),f.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,u=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===a){var h=u.pop();if(s.match(/"$/)){o=(h+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(h+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},f.asn1.x509.AttributeTypeAndValue=function(t){f.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=f,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,h=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=f.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.AttributeTypeAndValue,f.asn1.ASN1Object),f.asn1.x509.SubjectPublicKeyInfo=function(t){f.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=f,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,u=r.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof $){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof f.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof f.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:r});var o=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},mt(f.asn1.x509.SubjectPublicKeyInfo,f.asn1.ASN1Object),f.asn1.x509.Time=function(t){f.asn1.x509.Time.superclass.constructor.call(this);var e=f.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},mt(f.asn1.x509.Time,f.asn1.ASN1Object),f.asn1.x509.AlgorithmIdentifier=function(t){f.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=f.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},mt(f.asn1.x509.AlgorithmIdentifier,f.asn1.ASN1Object),f.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},f.asn1.x509.GeneralName=function(t){f.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},r=f.asn1;r.DERSequence;var n=r.DEROctetString,i=r.DERIA5String,s=r.DERTaggedObject,o=r.ASN1Object,a=r.x509.X500Name,u=ft;this.explicit=!1,this.setByParam=function(t){var r=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",r=new i({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",r=new i({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",r=new i({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,r="string"==typeof t.dn?new a({str:t.dn}):t.dn instanceof f.asn1.x509.X500Name?t.dn:new a(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,r=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var h=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certissuer param not cert";(p=new Ot).hex=h;var c=p.getIssuerHex();(r=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,p;h=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certsubj param not cert";(p=new Ot).hex=h;c=p.getSubjectHex();(r=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,v=t.ip,g="malformed IP address";if(v.match(/^[0-9.]+[.][0-9.]+$/)){if(d=function(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,r){var n=parseInt(t);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}}("["+v.split(".").join(",")+"]"),8!==d.length)throw g}else if(v.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=function(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var n=":".repeat(7-r+2),i=(t=t.replace("::",n)).split(":");if(8!=i.length)throw e;for(var s=0;s<8;s++)i[s]=("0000"+i[s]).slice(-4);return i.join("")}(v);else{if(!v.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw g;d=v}r=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:r})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},mt(f.asn1.x509.GeneralName,f.asn1.ASN1Object),f.asn1.x509.GeneralNames=function(t){f.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=f.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var n=new e.x509.GeneralName(t[r]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new e.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},mt(f.asn1.x509.GeneralNames,f.asn1.ASN1Object),f.asn1.x509.OID=new function(t){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1"},this.objCache={},this.name2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],r=new f.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];var e;if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw"AttributeType name undefined: "+t;e=this.name2oidList[t]}var r=new f.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r}},f.asn1.x509.OID.oid2name=function(t){var e=f.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},f.asn1.x509.OID.oid2atype=function(t){var e=f.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},f.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=f.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},f.asn1.x509.X509Util={},f.asn1.x509.X509Util.newCertPEM=function(t){var e=f.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},$.getPosArrayOfChildrenFromHex=function(t){return Rt.getChildIdx(t,0)},$.getHexValueArrayOfChildrenFromHex=function(t){var e,r=Rt.getV,n=r(t,(e=$.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),u=r(t,e[5]),h=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(n,i,s,o,a,u,h,c,l),e},$.prototype.readPrivateKeyFromPEMString=function(t){var e=ft(t),r=$.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},$.prototype.readPKCS5PrvKeyHex=function(t){var e=$.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},$.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,o,a,u,h=Rt,c=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),u=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,o,a,u)},$.prototype.readPKCS5PubKeyHex=function(t){var e=Rt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},$.prototype.readPKCS8PubKeyHex=function(t){var e=Rt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},$.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new Ot).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},$.prototype.sign=function(t,e){var r,n=(r=t,f.crypto.Util.hashString(r,e));return this.signWithMessageHash(n,e)},$.prototype.signWithMessageHash=function(t,e){var r=X(f.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Tt(this.doPrivate(r).toString(16),this.n.bitLength())},$.prototype.signPSS=function(t,e,r){var n,i=(n=ht(t),f.crypto.Util.hashHex(n,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},$.prototype.signWithMessageHashPSS=function(t,e,r){var n,i=ut(t),s=i.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(t){return f.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var h="";r>0&&(h=new Array(r),(new W).nextBytes(h),h=String.fromCharCode.apply(String,h));var c=ut(u(ht("\0\0\0\0\0\0\0\0"+i+h))),l=[];for(n=0;n<a-r-s-2;n+=1)l[n]=0;var p=String.fromCharCode.apply(String,l)+""+h,d=Ct(c,p.length,u),g=[];for(n=0;n<p.length;n+=1)g[n]=p.charCodeAt(n)^d.charCodeAt(n);var y=65280>>8*a-o&255;for(g[0]&=~y,n=0;n<s;n++)g.push(c.charCodeAt(n));return g.push(188),Tt(this.doPrivate(new v(g)).toString(16),this.n.bitLength())},$.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=X(e,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=It(i.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=t,f.crypto.Util.hashString(o,a))},$.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=X(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=It(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==t)},$.prototype.verifyPSS=function(t,e,r,n){var i=function(t){return f.crypto.Util.hashHex(t,r)}(ht(t));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,e,r,n)},$.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new v(e,16),o=function(t){return f.crypto.Util.hashHex(t,r)},a=ut(t),u=a.length,h=this.n.bitLength()-1,c=Math.ceil(h/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=c-u-2;else if(n<-2)throw new Error("invalid salt length");if(c<u+n+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(i=0;i<l.length;i+=1)l[i]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var p=(l=String.fromCharCode.apply(String,l)).substr(0,c-u-1),d=l.substr(p.length,u),g=65280>>8*c-h&255;if(0!=(p.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var y=Ct(d,p.length,o),m=[];for(i=0;i<p.length;i+=1)m[i]=p.charCodeAt(i)^y.charCodeAt(i);m[0]&=~g;var x=c-u-n-2;for(i=0;i<x;i+=1)if(0!==m[i])throw new Error("leftmost octets not zero");if(1!==m[x])throw new Error("0x01 marker not found");return d===ut(o(ht("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,m.slice(-n)))))},$.SALT_LEN_HLEN=-1,$.SALT_LEN_MAX=-2,$.SALT_LEN_RECOVER=-2,Ot.hex2dn=function(t,e){void 0===e&&(e=0);var r=new Ot;return Rt.getTLV(t,e),r.getX500Name(t).str},Ot.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,n=Rt.getChildIdx(t,e),i=0;i<n.length;i++)r.push(Ot.hex2attrTypeValue(t,n[i]));return(r=r.map((function(t){return t.replace("+","\\+")}))).join("+")},Ot.hex2attrTypeValue=function(t,e){var r=Rt,n=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(t,e);2!==i.length||t.substr(i[0],2);var s=n(t,i[0]),o=f.asn1.ASN1Util.oidHexToInt(s);return f.asn1.x509.OID.oid2atype(o)+"="+ut(n(t,i[1]))},Ot.getPublicKeyFromCertHex=function(t){var e=new Ot;return e.readCertHex(t),e.getPublicKey()},Ot.getPublicKeyFromCertPEM=function(t){var e=new Ot;return e.readCertPEM(t),e.getPublicKey()},Ot.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,n=Rt.getVbyList,i={};return i.algparam=null,(e=new Ot).readCertPEM(t),r=e.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},Ot.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var Ht,Bt=[(Ht=new Ot,Ht.readCertPEM(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@\tPPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\\QN>Z\tN\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@ebN[bqx=ng?\tS^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFoFgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP\tP>}A^VP}Ex\bUZa=syDw}>Ya8wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr\tsof[wA}e{\\z}w[YDQ|dt=wC\tNvbRZ@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`N\0RXt^Z}vEpdC=\bY?=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac\tZ\tguf\bF]DCP?znNYf\tuaYu[`=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB\tD8{B>\\sPYbEU\tFQXz\0@`zsqgfD\0[WY\bPeZc}\t\0bx?Rfed}BUe|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YBY`Ffg=sY>{t<fu]xrFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=EnO}Pud8TA\t?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V\tOUwY=>X[\\E`tW[8}VwpFBQcnrPF}yUtd8<Doe_\b[oOVUep@pYY\0cegY{r\t?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<StX\tNx\0\b\t\0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V\tCVrRVtAAc[\tQp|d|tqoQ=T|XX\t=u\\N8XNCx\\aU>wz\tX<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ\tP\bZ\b\\YNNSZ_\\w^|TsD8db\t_\tY\\o^Cw>Z\0x\\^aN]wWf\bA}\tC^d_{ZC@\by]gY@E\tBFY?OsaqbDcVgQbZeFc\tovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z\tZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),Ht)];function Vt(t,e){var r=t.getIssuerHex();if(r===t.getSubjectHex())return t.verifySignature(t.getPublicKey());var n=function(t,e){for(var r=0,n=e;r<n.length;r++){var i=n[r];if(i.getSubjectHex()===t)return i}}(r,e);return!!n&&(!1!==t.verifySignature(n.getPublicKey())&&Vt(n,e))}function jt(t){return t.getIssuerHex()!==t.getSubjectHex()&&Vt(t,Bt)}!function(t){var e=new Ot;"string"==typeof t?e.readCertPEM(t):e.readCertHex(t.hex);var r=jt(e);Bt.push(e)}(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU\tPPONrtNVONtVWNW=_SVw\tVE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ\t[QSnS=\b[aNBZQZ\\aZ\t[QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tRbZOVTN>bRPtYoTyuoz}}f`Bwo?=RQN\\Ot[cONZO>Wyfd\tgdbRaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdyndB{^T}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F\tSAe`tn[t\tu\b8^a]qx\bE_^ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQFO=Yw\0_TePCOFV@|N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{]\tb=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r\tAo\0\tF`fdzCnRtq\br\t\b8eBp=Z\\TRaadc}@Eub`quuNqAdF\0aUay{}x>tgVz`\t_YBFwu_q?egt8v[o\x008\twTQcrA\t<z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw\tXDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYPdWV]OE^\bOFwA}<uXoO}_NDz8aonzWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT|\tOZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO\td_D}eBb?Uq^b\t[y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zUxOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`FyWadZcAD\tpeXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx\ta[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef`\t?^x>X}esa{>\\r?eE]CC_cZ[vQs\t\t>gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC>>gvb}ACd\t``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc\tXSq\t{\0DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy\tRNRg@NZCaaq8?`\t^`?ryD\t=obzw?E]Ou]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug8^f[YQAWad8FNqxFQE?ZOo\t}RnO\bsQc\txyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var zt=function(t,e){return zt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},zt(t,e)};function qt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}zt(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var kt=function(){return kt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},kt.apply(this,arguments)};function Kt(t,e,r){if(r||2===arguments.length)for(var n,i=0,s=e.length;i<s;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}var Lt,Mt,Ut,Ft,Yt=function(){function t(t,e,r){this.x=t,this.y=e,this.z=r}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},t.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){var e=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-r*t.x,this},t.prototype.crossVectors=function(t,e){var r=t.x,n=t.y,i=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*s-r*a,this.z=r*o-n*s,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t}(),Qt=function(){function t(t,e,r,n){this.extents=t,this.startIndex=e,this.endIndex=r,this.level=n,this.node0=null,this.node1=null}return t.prototype.clearShapes=function(){this.startIndex=-1,this.endIndex=-1},t}(),Zt=(Lt=new Yt(0,0,0),Mt=new Yt(0,0,0),Ut=new Yt(0,0,0),Ft=new Yt(0,0,0),function(t,e,r,n,i,s){Mt.subVectors(e,t),Ut.subVectors(r,t),Ft.crossVectors(Mt,Ut);var o,a=i.dot(Ft);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Lt.subVectors(n,t);var u=o*i.dot(Ut.crossVectors(Lt,Ut));if(u<0)return null;var h=o*i.dot(Mt.cross(Lt));if(h<0)return null;if(u+h>a)return null;var c=-o*Lt.dot(Ft);if(c<0)return null;var l=c/a;return new Yt(0,0,0).copy(i).multiplyScalar(l).add(n)}),Gt=function(t,e){this.min=t,this.max=e};function Wt(t,e,r){var n=new Gt(0,0);e.x>=0?(n.min=(r.extents[0]-t.x)*e.x,n.max=(r.extents[3]-t.x)*e.x):(n.min=(r.extents[3]-t.x)*e.x,n.max=(r.extents[0]-t.x)*e.x);var i=new Gt(0,0);if(e.y>=0?(i.min=(r.extents[1]-t.y)*e.y,i.max=(r.extents[4]-t.y)*e.y):(i.min=(r.extents[4]-t.y)*e.y,i.max=(r.extents[1]-t.y)*e.y),n.min>i.max||i.min>n.max)return!1;i.min>n.min&&(n.min=i.min),i.max<n.max&&(n.max=i.max);var s=new Gt(0,0);return e.z>=0?(s.min=(r.extents[2]-t.z)*e.z,s.max=(r.extents[5]-t.z)*e.z):(s.min=(r.extents[5]-t.z)*e.z,s.max=(r.extents[2]-t.z)*e.z),!(n.min>s.max||s.min>n.max)&&(s.min>n.min&&(n.min=s.min),s.max<n.max&&(n.max=s.max),!(n.max<0))}var Xt=[0,0,0,0,0,0];function Jt(t,e,r,n,i){if(r>=n)return Xt;var s,o=r,a=6*t[o],u=e[a],h=e[a+1],c=e[a+2],l=e[a+3],f=e[a+4],p=e[a+5];for(++o;o<n;o++)(s=e[a=6*t[o]])<u&&(u=s),(s=e[a+1])<h&&(h=s),(s=e[a+2])<c&&(c=s),(s=e[a+3])>l&&(l=s),(s=e[a+4])>f&&(f=s),(s=e[a+5])>p&&(p=s);return[u-i,h-i,c-i,l+i,f+i,p+i]}var $t=function(t,e,r){this.triangle=t,this.triangleIndex=e,this.intersectionPoint=r},te=function(){function t(t,e){this.trianglesArray=t,this.maxTrianglesPerNode=e;var r,n,i,s,o,a,u=t.length/9,h=new Uint32Array(u),c=new Float32Array(6*u);r=s=t[0],n=o=t[1],i=a=t[2];for(var l=0,f=void 0,p=void 0,d=void 0,v=void 0,g=void 0,y=void 0,m=void 0,x=void 0,b=void 0;l<u;l++)x=6*l,f=v=t[b=9*l],(m=t[b+3])<f?f=m:m>v&&(v=m),(m=t[b+6])<f?f=m:m>v&&(v=m),f<r&&(r=f),v>s&&(s=v),p=g=t[b+1],(m=t[b+4])<p?p=m:m>g&&(g=m),(m=t[b+7])<p?p=m:m>g&&(g=m),p<n&&(n=p),g>o&&(o=g),d=y=t[b+2],(m=t[b+5])<d?d=m:m>y&&(y=m),(m=t[b+8])<d?d=m:m>y&&(y=m),d<i&&(i=d),y>a&&(a=y),h[l]=l,c[x]=f,c[x+1]=p,c[x+2]=d,c[x+3]=v,c[x+4]=g,c[x+5]=y;this.offsetArray=h,this.bboxArray=c,this.rootNode=new Qt([r,n,i,s,o,a],0,u,0),this.nodesToSplit=[],u>this.maxTrianglesPerNode&&this.nodesToSplit.push(this.rootNode),this.splitNode()}return t.prototype.splitNode=function(){var t,e=this.offsetArray,r=this.bboxArray,n=this.maxTrianglesPerNode,i=this.nodesToSplit;function s(t){var s=t.startIndex,o=t.endIndex,a=t.extents,u=[0,1,2],h=[a[3]-a[0],a[4]-a[1],a[5]-a[2]];u.sort((function(t,e){return h[e]-h[t]}));for(var c=0;c<3;c++){for(var l=u[c],f=a[l]+a[l+3],p=s,d=o-1,v=null;p<d;)null===v?r[6*e[p]+l]+r[6*e[p]+l+3]<f?p++:v=e[p]:(r[6*e[d]+l]+r[6*e[d]+l+3]>=f||(e[p]=e[d],e[d]=v,v=null,p++),d--);if(!(p<=s)){var g=Jt(e,r,s,p,1e-6),y=new Qt(g,s,p,t.level+1);t.node0=y,y.endIndex-y.startIndex>n&&i.push(y);var m=Jt(e,r,p,o,1e-6),x=new Qt(m,p,o,t.level+1);return t.node1=x,x.endIndex-x.startIndex>n&&i.push(x),void t.clearShapes()}}}for(;t=i.shift();)s(t)},t.prototype.intersectRay=function(t,e,r){for(var n=[this.rootNode],i=[],s=[],o=new Yt(1/e.x,1/e.y,1/e.z);n.length>0;){var a=n.pop();if(Wt(t,o,a)){a.node0&&n.push(a.node0),a.node1&&n.push(a.node1);for(var u=a.startIndex;u<a.endIndex;u++)i.push(this.offsetArray[u])}}for(var h=new Yt(0,0,0),c=new Yt(0,0,0),l=new Yt(0,0,0),f=new Yt(t.x,t.y,t.z),p=new Yt(e.x,e.y,e.z),d=(u=0,void 0),v=void 0;u<i.length;u++){v=9*(d=i[u]),h.set(this.trianglesArray[v],this.trianglesArray[v+1],this.trianglesArray[v+2]),c.set(this.trianglesArray[v+3],this.trianglesArray[v+3+1],this.trianglesArray[v+3+2]),l.set(this.trianglesArray[v+6],this.trianglesArray[v+6+1],this.trianglesArray[v+6+2]);var g=Zt(h,c,l,f,p,r);if(g){var y=new $t([h.clone(),c.clone(),l.clone()],d,g);s.push(y)}}return s},t.prototype.dispose=function(){this.trianglesArray=new Float32Array,this.bboxArray=new Float32Array,this.offsetArray=new Uint32Array,this.rootNode=null,this.nodesToSplit.length=0},t}(),ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return qt(e,t),e}(o.Mesh);function re(t,e){for(var r=0,n=t.children;r<n.length;r++){var i=n[r];!1!==e(i)&&re(i,e)}}function ne(){}var ie=new o.BoxBufferGeometry(1,1,1,1,1);ie.deleteAttribute("uv"),ie.deleteAttribute("normal"),ie.groups=[],ie.scale(-1,1,1);var se,oe=new o.ShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\nvarying vec3 worldPosition;\nvoid main() {\n vec4 transform = vec4(position, 1.0);\n worldPosition = (modelMatrix * transform).xyz;\n gl_Position = projectionMatrix * modelViewMatrix * transform;\n}\n",fragmentShader:"\nuniform samplerCube map;\nvarying vec3 worldPosition;\nvoid main() {\n gl_FragColor = textureCube(map, worldPosition);\n}\n",depthTest:!1,depthWrite:!1,stencilWrite:!1,blending:o.NoBlending,lights:!1});function ae(t,e,r){var n=new o.Scene,i=new o.Mesh(ie,oe);oe.uniforms.map.value=t,n.add(i);var s=r.autoClear;r.autoClear=!1,new o.CubeCamera(.1,2,e).update(r,n),r.autoClear=s,oe.uniforms.map.value=null}var ue=null!==(se=Math.SQRT1_2)&&void 0!==se?se:Math.sqrt(2),he={up:new o.Quaternion(ue,0,0,ue),down:new o.Quaternion(-ue,0,0,ue),left:new o.Quaternion(0,ue,0,ue),right:new o.Quaternion(0,-ue,0,ue),front:new o.Quaternion(0,0,0,1),back:new o.Quaternion(0,1,0,0)},ce=function(){var t=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),e=new Float32Array([0,0,1,0,0,1,1,1]),r=new Uint8Array([0,1,2,1,3,2]),n=new o.BufferGeometry;return n.setAttribute("position",new o.BufferAttribute(t,3)),n.setAttribute("uv",new o.BufferAttribute(e,2)),n.setIndex(new o.BufferAttribute(r,1)),n}();var le,fe=(le="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<".concat(le,">$"):Symbol(le));function pe(t){return t[fe]||(t[fe]={}),t[fe]}var de=function(){function t(){}return t.prototype.hasListener=function(t){var e=pe(this);return e&&e[t]&&e[t].length>0},t.prototype.on=function(t,e,r){var n=this,i=pe(this);return i[t]||(i[t]=[]),i[t].push([e,r||!1]),function(){return n.off(t,e)}},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.off=function(t,e){if(void 0!==t){var r,n=pe(this);if(n[t]||(n[t]=[]),void 0!==e){for(var i=0;i<n[t].length&&n[t][i][0]!==e;i++);i<n[t].length&&n[t].splice(i,1)}else n[t].length=0}else(r=this)[fe]||delete r[fe]},t.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=!1,i=pe(this),s=i[t]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],h=u[0],c=u[1],l=void 0!==c&&c,f=h.apply(void 0,e);l&&this.off(t,h),!1===f&&(n=!0)}return n},t}(),ve="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),ge="undefined"!=typeof performance?function(){return ve+performance.now()}:function(){return Date.now()};function ye(t){Object.freeze(t);var e="function"==typeof t,r=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(t).forEach((function(n){!r.call(t,n)||e&&("caller"===n||"callee"===n||"arguments"===n)||null===t[n]||"object"!=typeof t[n]&&"function"!=typeof t[n]||Object.isFrozen(t[n])||ye(t[n])})),t}var me=/^([^.]+)(\.([^.]+))*$/;function xe(t,e){return me.test(t)&&me.test(e)&&function(t,e){if("*"===t)return!0;var r=t.split(".").reverse(),n=e.split(".").reverse();if(r.length<=1)return t===e;for(var i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(t,e)}var be=ye(JSON.parse(function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/pnyp{|qr;vr/j")));!function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request proxy error(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}qt(e,t)}(Error),function(t){function e(e,r,n){var i=t.call(this,"[NETWORK]: response error(type: ".concat(r,", status: ").concat(n,"): ").concat(e))||this;return i.httpStatus=n,i}qt(e,t)}(Error),function(t){function e(e,r){return t.call(this,"[NETWORK]: request abort(type: ".concat(r,"): ").concat(e))||this}qt(e,t)}(Error),function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request timeout(type: ".concat(r,", timeout: ").concat(n,"ms): ").concat(e))||this}qt(e,t)}(Error),function(t){function e(e,r,n){return t.call(this,"[NETWORK]: request forbidden(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}qt(e,t)}(Error),function(t){function e(){return null!==t&&t.apply(this,arguments)||this}qt(e,t)}(de);var Se=function(){if("undefined"!=typeof window){var t=window;return t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(t){return setTimeout(t,16)}}return function(t){return setTimeout(t,16)}}(),Ee=16;!function(){function t(){this.frames=[],this.stoped=!1,this.time=ge(),this.context=null,this.loop=this.loop.bind(this),this.loop()}Object.defineProperty(t,"shared",{get:function(){return this.sharedInstance||(this.sharedInstance=new t),this.sharedInstance},enumerable:!1,configurable:!0}),t.getFrameTime=function(){return Ee},t.prototype.loop=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!this.stoped){var r=ge(),n=r-this.time;this.time=r;var i=[];Ee=n;for(var s=0,o=this.frames;s<o.length;s++){var a=o[s];if(a.delay>0)a.delay=a.delay-1;else{try{a.callback.apply(a,Kt([r,n],t,!1))}catch(t){console.error(t)}a.once&&i.push(a)}}i.length>0&&(this.frames=this.frames.filter((function(t){return-1===i.indexOf(t)}))),this.requestAnimationFrame(this.loop)}},t.prototype.setContext=function(t){this.cancelAnimationFrame(this.requestId),this.context=t,this.requestId=this.requestAnimationFrame(this.loop)},t.prototype.getContext=function(){return this.context},t.prototype.requestAnimationFrame=function(t){return this.context?this.context.requestAnimationFrame(t):Se(t)},t.prototype.cancelAnimationFrame=function(t){this.context?this.context.cancelAnimationFrame(t):function(t){var e;if("undefined"!=typeof window){var r=window;e=r.cancelAnimationFrame||r.mozCancelAnimationFrame||r.webkitCancelAnimationFrame||r.msCancelAnimationFrame||function(t){return window.clearTimeout(t)}}else e=function(t){return window.clearTimeout(t)};e(t)}(this.loop),this.requestId=null},t.prototype.remove=function(t){var e=this.frames.indexOf(t);e>=0&&this.frames.splice(e,1)},t.prototype.add=function(t,e,r,n){var i=this;void 0===e&&(e=!1),void 0===r&&(r=0),void 0===n&&(n=5);var s={callback:t,once:e,delay:r,order:n};return this.frames.push(s),this.frames.sort((function(t,e){return t.order-e.order})),function(){return i.remove(s)}},t.prototype.disponse=function(){this.stoped=!0,this.frames.length=0}}(),new o.WebGLRenderTarget(1,1),new o.OrthographicCamera(-1,1,1,-1,0,1);var we=new o.BufferGeometry;we.setAttribute("position",new o.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),we.setAttribute("uv",new o.Float32BufferAttribute([0,2,0,0,2,0],2));var Ae,Pe=new o.Mesh(we);(new o.Scene).add(Pe),new o.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0));\n }\n ",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1}),new o.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform samplerCube map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0, 0));\n }\n ",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1});var Ne=3,De=33779;(Ae={})[2]=33776,Ae[Ne]=De;Object.assign(window,{cubeRenderTargetPool:[]});var Re=function(){function t(t,e,r,n,i){this.tileTree=e,this.tileSources=r,this.options=n,this.renderer=i,this.name="",this.needsRender=!1,this.disposed=!1,this.loadedCubeNodes=new Set,this.loadingCubeNodes=new Set,this.baseCubeTexture=null,this._cubeRenderTarget=null,this.textures=[],this.baseCubeTexture=t}return Object.defineProperty(t.prototype,"cubeRenderTarget",{get:function(){return this._cubeRenderTarget},set:function(t){var e,r,n,i,s;if(null===t)throw new Error("cannot set cubeRenderTarget to null.");t.width!==this.options.textureSize&&t.setSize(this.options.textureSize,this.options.textureSize),t.texture.format=null!==(e=this.options.format)&&void 0!==e?e:o.RGBAFormat,t.texture.minFilter=null!==(r=this.options.minFilter)&&void 0!==r?r:o.LinearFilter,t.texture.magFilter=null!==(n=this.options.magFilter)&&void 0!==n?n:o.LinearFilter,t.texture.wrapS=null!==(i=this.options.wrapS)&&void 0!==i?i:o.ClampToEdgeWrapping,t.texture.wrapT=null!==(s=this.options.wrapT)&&void 0!==s?s:o.ClampToEdgeWrapping,this.baseCubeTexture&&(ae(this.baseCubeTexture,t,this.renderer),this.baseCubeTexture.dispose(),this.baseCubeTexture=null),this._cubeRenderTarget&&ae(this._cubeRenderTarget.texture,t,this.renderer),this._cubeRenderTarget=t},enumerable:!1,configurable:!0}),t.prototype.requestTile=function(t){var e,r,n,i,s,a,u=this,h=this.tileSources.filter((function(e){return e.level===t.level}))[0];if(h){var c=h.size,l=Math.pow(2,t.level)*t.position.y,f=Math.pow(2,t.level)*t.position.x,p="".concat((null!==(n=null===(r=null===(e=this.options.imageURL)||void 0===e?void 0:e.options)||void 0===r?void 0:r.key)&&void 0!==n?n:"pano.0").replace(/^pano/,"pano_tile"),".").concat(t.face,".").concat(t.level,".").concat(l,".").concat(f),d=kt(kt({},null!==(s=null===(i=this.options.imageURL)||void 0===i?void 0:i.options)&&void 0!==s?s:{basisLoaderInitialized:!1,key:"unknown"}),{key:p,size:c*t.size===this.options.tileImageSize?void 0:this.options.tileImageSize,quality:void 0,cut:[c*t.position.x,c*t.position.y,c*t.size,c*t.size]});this.loadingCubeNodes.add(t),this.options.textureLoader.loadTexture(h[t.face],{imageURL:{transform:null===(a=this.options.imageURL)||void 0===a?void 0:a.transform,options:kt({},d)},format:o.RGBAFormat,preInit:!1,viaAjax:!1}).then((function(e){u.disposed?e.body.dispose():(u.textures.push({face:t.face,level:t.level,position:t.position,size:new o.Vector2(t.size,t.size),texture:e.body}),u.loadedCubeNodes.add(t))})).catch(ne).then((function(){u.disposed||u.loadingCubeNodes.delete(t)}))}else this.loadedCubeNodes.add(t)},t.prototype.update=function(t,e){var r=this;if(!this.disposed){var n=[];re(this.tileTree,(function(i){return!r.loadingCubeNodes.has(i)&&(!(i.level>e)&&(!!t.intersectsBox(i.box)&&(r.loadedCubeNodes.has(i)?void 0:(n.push(i),!1))))}));for(var i=0,s=n;i<s.length;i++){var a=s[i];this.requestTile(a)}if(this.cubeRenderTarget&&this.textures.length){var u=this.textures.splice(0,4);!function(t,e,r){var n=new o.Scene,i=new o.Group;i.scale.set(1,1,-1),n.add(i);for(var s=0,a=t;s<a.length;s++){var u=a[s],h=new o.ShaderMaterial({uniforms:{map:{value:u.texture}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n",fragmentShader:"\nuniform sampler2D map;\nvarying vec2 vUv;\nvoid main() {\n gl_FragColor = texture2D(map, vUv);\n}\n",depthTest:!1,depthWrite:!1,blending:o.NoBlending,lights:!1}),c=new o.Group,l=new o.Mesh(ce,h);l.position.set(u.position.x+u.size.x/2-.5,1-(u.position.y+u.size.y/2)-.5,-.5),l.scale.set(u.size.x,u.size.y,1),c.quaternion.copy(he[u.face]),c.add(l),i.add(c)}var f=r.autoClear;r.autoClear=!1,new o.CubeCamera(.1,2,e).update(r,n),r.autoClear=f;for(var p=0,d=[];p<d.length;p++)(h=d[p]).uniforms.map.value=null,h.dispose()}(u,this.cubeRenderTarget,this.renderer),this.needsRender=!0;for(var h=0,c=u;h<c.length;h++){c[h].texture.dispose()}}}},Object.defineProperty(t.prototype,"tilePending",{get:function(){return this.loadingCubeNodes.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){if(!this._cubeRenderTarget)throw new Error("cubeRenderTarget never set.");return this._cubeRenderTarget.texture},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){if(!this.disposed){this.disposed=!0,this.baseCubeTexture&&(this.baseCubeTexture.dispose(),this.baseCubeTexture=null),this.loadingCubeNodes.clear(),this.loadedCubeNodes.clear();for(var t=0,e=this.textures;t<e.length;t++){e[t].texture.dispose()}this.textures.length=0}},t}(),Te=function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("n\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{Hn\bv{t-rpA-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|l}nlrrK0v{pyqr-Iunq|zn}l}nlrrK|vq-znv{56-\n--0v{pyqr-IlrrK--0v{pyqr-I?lrrK--0v{pyqr-Ip|y|lrrK--0v{pyqr-Iortv{{|znylrrK--0v{pyqr-Iqrsny{|znylrrK--rpA-n{s|zrq-J-rpA5}|vv|{9->;=6H--rpA-z]|vv|{-J-z|qrycvrZnv-7-n{s|zrqH--[|zny-J-{|znyv\tr5n{s|zrq[|zny6H--cvr]|vv|{-J-:z]|vv|{;\b\tH--|yq]|vv|{-J-z|qryZnv-7-n{s|zrqH--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--0v{pyqr-Iunq|zn}lrrK\f"),Ce=function(){var t=113,e=126,r=0,n="";return arguments[r].split(n).map((function(n){return n.charCodeAt(r)>e?n:String.fromCharCode((n.charCodeAt(r)+t)%e)})).join(n)}("0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=EC9-=;>=C9-=;>AF9->;=60qrsv{r-aNb-C;?E@>EB?{vs|z-nz}yrPor-}n{|=lzn}H{vs|z-znA-}n{|=lznvH0vs-qrsv{rq5b`RlYbZV[N[PR6--{vs|z-nz}yrPor-}n{|=lyzv{n{prZn}H0r{qvs{vs|z-nz}yrPor-}n{|>lzn}H{vs|z-znA-}n{|>lznvH0vs-qrsv{rq5b`RlYbZV[N[PR6--{vs|z-nz}yrPor-}n{|>lyzv{n{prZn}H0r{qvs{vs|z-rp@-qvssrH{vs|z-rp@-rzvvrH{vs|z-rp@-}rpynH{vs|z-sy|n-uv{v{rH{vs|z-sy|n-r}|rH{vs|z-sy|n-|}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-sy|n-sy||V{qrH0vs-qrsv{rq5b`RlNYYlP\\Y\\_6{vs|z-rp@-z|qryP|y|V{s|H0r{qvs0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6--{vs|z-rp?-}n{|cvqr|lv\trH--{vs|z-znA-}n{|cvqr|lznvH--{vs|z-sy|n-}n{|cvqr|lny}unH--{vs|z-nz}yr?Q-}n{|cvqr|lzn}H0r{qvs0vs-qrsv{rq5b`RlPYV]SY\\\\_6--{vs|z-rp@-sy||V{s|H0r{qvsn\bv{t-rpA-|yq]|vv|{H0vs-qrsv{rq5b`RlPbaR_6--0vs-[bZlPYV]]V[TlN__NflYR[TaU-K-=----{vs|z-rpA-pyv}}r]yn{rNn\bh-[bZlPYV]]V[TlN__NflYR[TaU-jH----{vs|z-sy|n-pyv}}rSy||h[bZlPYV]]V[TlN__NflYR[TaUjH--0r{qvs0r{qvs0v{pyqr-Ip|zz|{K0v{pyqr-I}npxv{tK0v{pyqr-Ip|y|l}nlsntzr{K0v{pyqr-Il}nlsntzr{K0v{pyqr-I?l}nlsntzr{K0v{pyqr-Izn}l}nlsntzr{K0v{pyqr-Iny}unzn}l}nlsntzr{K0v{pyqr-In|zn}l}nlsntzr{K0v{pyqr-Iyvtuzn}l}nlsntzr{K0v{pyqr-Irzvvrzn}l}nlsntzr{K0v{pyqr-Ir{zn}l}nlsntzr{K0v{pyqr-Itnqvr{zn}l}nlsntzr{K0v{pyqr-Is|tl}nlsntzr{K0v{pyqr-IoqsK0v{pyqr-Iyvtul}nlortv{K0v{pyqr-Iyvtul}u|{tl}nlsntzr{K0v{pyqr-Iunq|zn}l}nlsntzr{Krp?-|P||q5rp@-rp|6-\n--sy|n--J-yr{tu5rp|6H--sy|n-urn-J-np|5rp|;\b-<-6H--sy|n-}uv-J-nn{5rp|;9-rp|;\t6H--r{-rp?5=;B-8-}uv-<-aNb9-urn-<-]V6H\f|vq-znv{56-\n--0vs-qrsv{rq5b`RlNYYlP\\Y\\_6----tylSntP|y|-J-rpA5z|qryP|y|V{s|;9z|qryP|y|V{s|;t9z|qryP|y|V{s|;o9>;=6H----r{H--0r{qvsvs-5q|5cvr]|vv|{9-[|zny6-I-=;=6-\n----qvpnqH--\f--<<前置裁切计算--0vs-qrsv{rq5b`RlPbaR_6----rpA-}yn{rH----s|5-v{-v-J-=H-v-I-[bZlPYV]]V[TlO\\eH-v886\n------o||y-pyv}}rq-J-rH------sy|n-pr{Sy||V{qr-J-pyv}}rSy||hvjH------s|-5-v{-w-J-=H-w-I-CH-w-88-6-\n--------}yn{r-J-pyv}}r]yn{rNn\bh-v-7-C-8-w-jH--------pyv}}rq-J-5-q|5-cvr]|vv|{9-}yn{r;\b\t-6-K-}yn{r;-6-33-pyv}}rqH------\f------vs5-pyv}}rq-33-5pr{Sy||V{qr-JJ-:>;=-\v\v-pr{Sy||V{qr-JJ-sy||V{qr66-\n--------qvpnqH------\fH----\f--0r{qvs--<<楼层切割计算--0vs-qrsv{rq5b`RlPYV]SY\\\\_6----vs-5|yq]|vv|{;\b-I-sy||V{s|;-\v\v-|yq]|vv|{;\b-K-sy||V{s|;t6-\n------qvpnqH----\f--0r{qvs--rpA-qvssrP|y|-J-rpA5qvssr;to9-|}npv\b6H--_rsyrprqYvtu-rsyrprqYvtu-J-_rsyrprqYvtu5rp@5=;=69-rp@5=;=69-rp@5=;=69-rp@5=;=66H--rp@-|nyRzvvr_nqvn{pr-J-rzvvrH--0v{pyqr-Izn}lsntzr{K--0v{pyqr-Ip|y|lsntzr{K--0v{pyqr-Iny}unzn}lsntzr{K--0v{pyqr-Iny}unrlsntzr{K--0v{pyqr-I}rpynzn}lsntzr{K--0v{pyqr-I{|znylsntzr{lortv{K--0v{pyqr-I{|znylsntzr{lzn}K--0v{pyqr-Irzvvrzn}lsntzr{K--0v{pyqr-Iyvtul}u|{tlsntzr{K--0v{pyqr-Iyvtulsntzr{lortv{K--<<-调整曝光值--vnqvn{pr-J-vnqvn{pr-7-r}|rH--0v{pyqr-Iyvtulsntzr{lzn}K--0v{pyqr-Iyvtulsntzr{lr{qK--0v{pyqr-In|zn}lsntzr{K--<<-减少方向光对模型的影响--rp@-|t|v{tYvtu-J-5rsyrprqYvtu;qvrpQvssr-7-=;?6-8----rsyrprqYvtu;v{qvrpQvssr-8----rsyrprqYvtu;v{qvrp`}rpyn-8----|nyRzvvr_nqvn{prH--<<-修复黑色面片的问题--vs-5|t|v{tYvtu;-K-=;=-\v\v-|t|v{tYvtu;t-K-=;=-\v\v-|t|v{tYvtu;o-K-=;=6-\n----tylSntP|y|-J-rpA5|t|v{tYvtu9-qvssrP|y|;n6H--\f-ryr-\n----tylSntP|y|-J-rpA5OYNPXlP\\Y\\_;\b\t9-qvssrP|y|;n6H--\f--rp@-}n{|=a|crr-J-5|yq]|vv|{;\b\t-:-}n{|=lznvh@j;\b\t6-7-zn@5}n{|=lznv6H--rp@-}n{|>a|crr-J-5|yq]|vv|{;\b\t-:-}n{|>lznvh@j;\b\t6-7-zn@5}n{|>lznv6H--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=lzn}9-}n{|=a|crr6H--rpA-}n{|>P|y|-J-rrPor5}n{|>lzn}9-}n{|>a|crr6H--0vs-qrsv{rq5b`RlYbZV[N[PR6----}n{|=P|y|;n-J->;=-:-rrPor5}n{|=lyzv{n{prZn}9-}n{|=a|crr6;H----}n{|>P|y|;n-J->;=-:-rrPor5}n{|>lyzv{n{prZn}9-}n{|>a|crr6;H--0r{qvs--0vs-qrsv{rq5b`RlOYNPXla_N[`VaV\\[6----sy|n-oynpx]|tr-J-np|5:?;=-7-}|tr-8->;=6H----}n{|P|y|-J-zv5}n{|=P|y|9-OYNPXlP\\Y\\_9-zv{5>;=9-oynpx]|tr66H----}n{|P|y|-J-zv5}n{|P|y|9-}n{|>P|y|9-zn5=;=9-oynpx]|tr-:-?;=66H--0ryr----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-}|tr6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6----rp@-pnzrna|crr-J-|yq]|vv|{;\b\t-:-pnzrn]|vv|{H----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|lznvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|lv\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|lv\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|lzn}9-6H----sy|n-znpu-J-5>;=-:-r}5=;=9-zn}P||q;\t66-7-5>;=-:-r}5=;B9-no5;-:-=;B666-7-5>;=-:-r}5=;B9-no5;\b-:-=;B666H----sy|n-ny}un-J-pynz}5=;=9->;=9-B;=-7-5>;=-:-pynz}5qvn{pr59-rp?5=;B9-=;B66-<-=;BB-9-=;=9->;=666H----}n{|P|y|-J-zv5}n{|P|y|9-vqr|P|y|9-znpu-7-ny}un-7-}n{|cvqr|lny}un6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\l\\]NPVaf6----tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H----tylSntP|y|;n-J-|}npv\bH--0ryr----tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H----tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H--0r{qvs\f"),Ie=new o.WebGLCubeRenderTarget(1).texture;Ie.name="EMPTY_TEXTURE";var Oe=Object.assign({modelAlpha:new o.Uniform(0),progress:new o.Uniform(0),pano0_map:new o.Uniform(Ie),pano0_luminanceMap:new o.Uniform(null),pano0_matrix:new o.Uniform(new o.Matrix4),pano1_map:new o.Uniform(Ie),pano1_luminanceMap:new o.Uniform(null),pano1_matrix:new o.Uniform(new o.Matrix4),floorIndex:new o.Uniform(-1),floorInfo:new o.Uniform(null),clipperPlanesArray:new o.Uniform(new Float32Array),clipperFloors:new o.Uniform([]),modelColorInfo:new o.Uniform(null)},{exposure:new o.Uniform(1),emissive:new o.Uniform(new o.Color(0)),emissiveMap:new o.Uniform(null),specular:new o.Uniform(new o.Color(1118481)),specularMap:new o.Uniform(null),normalMap:new o.Uniform(null),bumpMap:new o.Uniform(null),shininess:new o.Uniform(30)},o.UniformsUtils.clone(o.UniformsLib.common),o.UniformsUtils.clone(o.UniformsLib.lights)),_e=function(t){function e(e){void 0===e&&(e={});var r,n,i,s,a,u,h,c,l,f=this;f=t.call(this,{vertexShader:Te,fragmentShader:Ce,uniforms:o.UniformsUtils.clone(Oe),defines:{USE_MAP:!0,USE_UV:!0,USE_LUMINANCE:!1,USE_PANO_OPACITY:!1,USE_BLACK_TRANSITION:!1,USE_PANO_VIDEO:!1,USE_ALL_COLOR:!1,USE_CLIPFLOOR:!1,USE_CUTER:!1,NUM_CLIPPING_ARRAY_LENGTH:0,NUM_CLIPPING_BOX:0},blending:o.NoBlending,lights:!0})||this;var p=null,d=null;return Object.defineProperties(f,{pano0:{get:function(){return p},set:function(t){p=t,null===t?(this.uniforms.pano0_map.value=Ie,this.uniforms.pano0_luminanceMap.value=null,this.uniforms.pano0_matrix.value.identity()):(this.uniforms.pano0_map.value=t.map instanceof Re?t.map.texture:t.map,this.uniforms.pano0_luminanceMap.value=t.luminanceMap instanceof Re?t.luminanceMap.texture:t.luminanceMap,this.uniforms.pano0_matrix.value.copy(t.matrix));var e=null!==this.uniforms.pano0_luminanceMap.value&&null!==this.uniforms.pano1_luminanceMap.value;this.defines.USE_LUMINANCE!==e&&(this.defines.USE_LUMINANCE=e,this.needsUpdate=!0)}},pano1:{get:function(){return d},set:function(t){d=t,null===t?(this.uniforms.pano1_map.value=Ie,this.uniforms.pano1_luminanceMap.value=null,this.uniforms.pano1_matrix.value.identity()):(this.uniforms.pano1_map.value=t.map instanceof Re?t.map.texture:t.map,this.uniforms.pano1_luminanceMap.value=t.luminanceMap instanceof Re?t.luminanceMap.texture:t.luminanceMap,this.uniforms.pano1_matrix.value.copy(t.matrix));var e=null!==this.uniforms.pano0_luminanceMap.value&&null!==this.uniforms.pano1_luminanceMap.value;this.defines.USE_LUMINANCE!==e&&(this.defines.USE_LUMINANCE=e,this.needsUpdate=!0)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(t){this.uniforms.modelAlpha.value=t}},progress:{get:function(){return this.uniforms.progress.value},set:function(t){this.uniforms.progress.value=t}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(t){this.defines.USE_BLACK_TRANSITION!==t&&(this.defines.USE_BLACK_TRANSITION=t,this.needsUpdate=!0)}},modelColorInfo:{get:function(){return this.uniforms.modelColorInfo.value},set:function(t){this.uniforms.modelColorInfo.value=t;var e=null!==t;this.defines.USE_ALL_COLOR!==e&&(this.defines.USE_ALL_COLOR=e,this.needsUpdate=!0)}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t;var e=t<1?o.NormalBlending:o.NoBlending;e!==this.blending&&(this.blending=e,this.needsUpdate=!0)}},floorIndex:{get:function(){return this.uniforms.floorIndex.value},set:function(t){this.uniforms.floorIndex.value=t}},floorInfo:{get:function(){return this.uniforms.floorInfo.value},set:function(t){var e,r=this.defines.USE_CLIPFLOOR;t&&!t.equals(new o.Vector3(0,0,0))?(e=!0,this.uniforms.floorInfo.value=t):(e=!1,this.uniforms.floorInfo.value=null),r!==e&&(this.defines.USE_CLIPFLOOR=e,this.needsUpdate=!0)}},clippers:{get:function(){return this._clippers},set:function(t){this._clippers=t}},clipperPlanesArray:{get:function(){return this.uniforms.clipperPlanesArray.value},set:function(t){var e=!1;if(t instanceof Float32Array&&t.length>0&&t.length%6==0){var r=t.length/4;!0!==this.defines.USE_CUTER&&(this.defines.USE_CUTER=!0,e=!0),this.defines.NUM_CLIPPING_ARRAY_LENGTH!==r&&(this.defines.NUM_CLIPPING_ARRAY_LENGTH=r,e=!0),this.defines.NUM_CLIPPING_BOX!==r/6&&(this.defines.NUM_CLIPPING_BOX=r/6,e=!0),this.uniforms.clipperPlanesArray.value=t}else!1!==this.defines.USE_CUTER&&(this.defines.USE_CUTER=!1,e=!0),0!==this.defines.NUM_CLIPPING_ARRAY_LENGTH&&(this.defines.NUM_CLIPPING_ARRAY_LENGTH=0,e=!0),0!==this.defines.NUM_CLIPPING_BOX&&(this.defines.NUM_CLIPPING_BOX=0,e=!0),this.uniforms.clipperPlanesArray.value=new Float32Array;e&&(this.needsUpdate=!0)}},clipperFloors:{get:function(){return this.uniforms.clipperFloors.value},set:function(t){this.uniforms.clipperFloors.value=t}}}),f.pano0=null!==(r=e.pano0)&&void 0!==r?r:null,f.pano1=null!==(n=e.pano1)&&void 0!==n?n:null,f.modelAlpha=null!==(i=e.modelAlpha)&&void 0!==i?i:1,f.progress=null!==(s=e.progress)&&void 0!==s?s:0,f.useBlackTransition=null!==(a=e.useBlackTransition)&&void 0!==a&&a,f.modelColorInfo=null!==(u=e.modelColorInfo)&&void 0!==u?u:null,f.opacity=null!==(h=e.opacity)&&void 0!==h?h:1,f.originOpacity=1,f.floorIndex=null!==(c=e.floorIndex)&&void 0!==c?c:-1,f.floorInfo=null!==(l=e.floorInfo)&&void 0!==l?l:null,f.clippers=null,f.clipperPlanesArray=null,f.clipperFloors=null,f}return qt(e,t),e}(o.ShaderMaterial);function He(t){return new Promise((function(e,r){(/^https\:/.test(t)?u.default:a.default).get(t,(function(t){var n=[];t.on("data",(function(t){return n.push(t)})),t.on("end",(function(){e(Buffer.concat(n).buffer)})),t.on("error",(function(t){return r(t)}))})).on("error",(function(t){return r(t)}))}))}const Be=h.Reader,Ve=h.util,je=h.roots["@REALSEE/FIVE:five/server/model/proto/pbm.proto"]||(h.roots["@REALSEE/FIVE:five/server/model/proto/pbm.proto"]={}),ze=je.Model=(()=>{function t(t){if(this.chunks=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.chunks=Ve.emptyArray,t.prototype.createAt=Ve.Long?Ve.Long.fromBits(0,0,!0):0,t.prototype.description="",t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(je.Chunk.decode(t,t.uint32()));break;case 2:n.createAt=t.uint64();break;case 3:n.description=t.string();break;default:t.skipType(7&e)}}return n},t})();je.Chunk=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.vertices=null,t.prototype.faces=null,t.prototype.name="",t.prototype.texture="",t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.vertices=je.Vertices.decode(t,t.uint32());break;case 2:n.faces=je.Faces.decode(t,t.uint32());break;case 3:n.name=t.string();break;case 4:n.texture=t.string();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("vertices"))throw Ve.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw Ve.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw Ve.ProtocolError("missing required 'name'",{instance:n});return n},t})(),je.Vertices=(()=>{function t(t){if(this.xyz=[],this.uvs=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.xyz=Ve.emptyArray,t.prototype.uvs=Ve.emptyArray,t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Vertices;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.xyz.push(t.float())}else n.xyz.push(t.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.uvs.push(t.float())}else n.uvs.push(t.float());break;default:t.skipType(7&e)}}return n},t})(),je.Faces=(()=>{function t(t){if(this.indices=[],this.normals=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.indices=Ve.emptyArray,t.prototype.normals=Ve.emptyArray,t.decode=function(t,e){t instanceof Be||(t=Be.create(t));let r=void 0===e?t.len:t.pos+e,n=new je.Faces;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.indices.push(t.uint32())}else n.indices.push(t.uint32());break;case 2:if(n.normals&&n.normals.length||(n.normals=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.normals.push(t.float())}else n.normals.push(t.float());break;default:t.skipType(7&e)}}return n},t})();var qe=(new o.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1).elements;function ke(t){var e=t.match(/(group|floor)-?(\d+)/);return e?parseInt(e[2],10):0}function Ke(t){var e=t.match(/(chunk)-?(\d+)/);return e?parseInt(e[2],10):0}function Le(t){var e,r;return 1e6*ke(t.name)+1e3*Ke(t.name)+(e=t.name,(r=e.match(/(sub)-?(\d+)/))?parseInt(r[2],10):0)}function Me(t){for(var e=function(t){for(var e,r,n,i="number"==typeof t.createAt?t.createAt:null===t.createAt||void 0===t.createAt?0:t.createAt.toNumber(),s=null!==(e=t.description)&&void 0!==e?e:"",o=[],a=!0,u=0,h=t.chunks;u<h.length;u++)if(!(rt=h[u]).faces.normals||0===rt.faces.normals.length){a=!1;break}for(var c=t.chunks.sort((function(t,e){return Le(t)-Le(e)})),l=[],f=0,p=c;f<p.length;f++){var d=ke((rt=p[f]).name);l[d]||(l[d]=[]),l[d].push(rt)}for(var v=0;v<l.length;v++){var g=l[v];if(g)if(a){for(var y=0,m=0;m<g.length;m++)y+=(rt=g[m]).faces.indices.length;for(var x=3*y,b=2*y,S=3*y,E=new ArrayBuffer(4*x+4*b+4*S),w=new Float32Array(E,0,x),A=new Float32Array(E,4*x,b),P=new Float32Array(E,4*x+4*b,S),N=[],D=[1/0,1/0,1/0,-1/0,-1/0,-1/0],R=0,T=0;T<g.length;T++){var C=[1/0,1/0,1/0,-1/0,-1/0,-1/0],I=(rt=g[T]).vertices.xyz,O=rt.vertices.uvs,_=rt.faces.indices,H=rt.faces.normals,B=_.length;for(m=0;m<B;m++){var V=_[m],j=I[3*V],z=I[3*V+1],q=I[3*V+2],k=1/(qe[3]*j+qe[7]*z+qe[11]*q+qe[15]),K=(qe[0]*j+qe[4]*z+qe[8]*q+qe[12])*k,L=(qe[1]*j+qe[5]*z+qe[9]*q+qe[13])*k,M=(qe[2]*j+qe[6]*z+qe[10]*q+qe[14])*k;w[3*R+3*m]=K,w[3*R+3*m+1]=L,w[3*R+3*m+2]=M,A[2*R+2*m]=O[2*V],A[2*R+2*m+1]=O[2*V+1];var U=3*Math.floor(m/3),F=H[U],Y=H[U+1],Q=H[U+2],Z=1/(qe[3]*F+qe[7]*Y+qe[11]*Q+qe[15]),G=(qe[0]*F+qe[4]*Y+qe[8]*Q+qe[12])*Z,W=(qe[1]*F+qe[5]*Y+qe[9]*Q+qe[13])*Z,X=(qe[2]*F+qe[6]*Y+qe[10]*Q+qe[14])*Z;P[3*R+3*m]=G,P[3*R+3*m+1]=W,P[3*R+3*m+2]=X,K<C[0]&&(C[0]=K),L<C[1]&&(C[1]=L),M<C[2]&&(C[2]=M),K>C[3]&&(C[3]=K),L>C[4]&&(C[4]=L),M>C[5]&&(C[5]=M)}C[0]<D[0]&&(D[0]=C[0]),C[1]<D[1]&&(D[1]=C[1]),C[2]<D[2]&&(D[2]=C[2]),C[3]>D[3]&&(D[3]=C[3]),C[4]>D[4]&&(D[4]=C[4]),C[5]>D[5]&&(D[5]=C[5]),N.push({materialIndex:T,name:rt.name,chunkName:Ke(rt.name),start:R,count:rt.faces.indices.length,texture:null!==(r=rt.texture)&&void 0!==r?r:void 0}),R+=B}o.push({createAt:i,description:s,floorIndex:v,vertices:w,uvs:A,indices:null,normals:P,groups:N,extents:D})}else{y=0;var J=0;for(m=0;m<g.length;m++)J+=(rt=g[m]).vertices.xyz.length/3,y+=rt.faces.indices.length;x=3*J,b=2*J,S=3*J;var $=y,tt=(E=new ArrayBuffer(4*x+4*b+4*S+4*$),w=new Float32Array(E,0,x),A=new Float32Array(E,4*x,b),P=new Float32Array(E,4*x+4*b,S),new Uint32Array(E,4*x+4*b+4*S,$)),et=(N=[],D=[1/0,1/0,1/0,-1/0,-1/0,-1/0],0);for(R=0,T=0;T<g.length;T++){C=[1/0,1/0,1/0,-1/0,-1/0,-1/0],I=(rt=g[T]).vertices.xyz,O=rt.vertices.uvs,_=rt.faces.indices;var rt,nt=I.length/3;for(B=_.length,m=0;m<nt;m++)j=I[3*m],z=I[3*m+1],q=I[3*m+2],k=1/(qe[3]*j+qe[7]*z+qe[11]*q+qe[15]),K=(qe[0]*j+qe[4]*z+qe[8]*q+qe[12])*k,L=(qe[1]*j+qe[5]*z+qe[9]*q+qe[13])*k,M=(qe[2]*j+qe[6]*z+qe[10]*q+qe[14])*k,w[3*R+3*m]=K,w[3*R+3*m+1]=L,w[3*R+3*m+2]=M,A[2*R+2*m]=O[2*m],A[2*R+2*m+1]=O[2*m+1],K<C[0]&&(C[0]=K),L<C[1]&&(C[1]=L),M<C[2]&&(C[2]=M),K>C[3]&&(C[3]=K),L>C[4]&&(C[4]=L),M>C[5]&&(C[5]=M);for(C[0]<D[0]&&(D[0]=C[0]),C[1]<D[1]&&(D[1]=C[1]),C[2]<D[2]&&(D[2]=C[2]),C[3]>D[3]&&(D[3]=C[3]),C[4]>D[4]&&(D[4]=C[4]),C[5]>D[5]&&(D[5]=C[5]),m=0;m<B;m++)tt[et+m]=R+_[m];N.push({materialIndex:T,name:rt.name,chunkName:Ke(rt.name),start:et,count:rt.faces.indices.length,texture:null!==(n=rt.texture)&&void 0!==n?n:void 0}),R+=nt,et+=B}for(m=0;m<y;m+=3){var it,st,ot,at,ut,ht,ct,lt,ft,pt,dt,vt,gt,yt,mt,xt;F=void 0,Y=void 0,Q=void 0,it=3*tt[m],st=3*tt[m+1],ot=3*tt[m+2],at=w[it],ut=w[it+1],ht=w[it+2],ct=w[st],lt=w[st+1],ft=w[st+2],pt=w[ot],F=(vt=w[ot+1]-lt)*(xt=ht-ft)-(gt=w[ot+2]-ft)*(mt=ut-lt),Y=gt*(yt=at-ct)-(dt=pt-ct)*xt,Q=dt*mt-vt*yt,P[it]+=F,P[it+1]+=Y,P[it+2]+=Q,P[st]+=F,P[st+1]+=Y,P[st+2]+=Q,P[ot]+=F,P[ot+1]+=Y,P[ot+2]+=Q}o.push({createAt:i,description:s,floorIndex:v,vertices:w,uvs:A,indices:tt,normals:P,groups:N,extents:D})}}return o}(t),r=0,n="",i=[],s=0,a=e;s<a.length;s++){var u=a[s],h=u.createAt,c=u.description,l=u.floorIndex,f=u.vertices,p=u.uvs,d=u.indices,v=u.normals,g=u.groups,y=u.extents,m=new o.Box3;m.min.x=y[0],m.min.y=y[1],m.min.z=y[2],m.max.x=y[3],m.max.y=y[4],m.max.z=y[5];var x=new o.BufferGeometry;x.setAttribute("position",new o.BufferAttribute(f,3)),x.setAttribute("uv",new o.BufferAttribute(p,2)),x.setAttribute("normal",new o.BufferAttribute(v,3)),d&&x.setIndex(new o.BufferAttribute(d,1)),x.boundingBox=m,x.boundingSphere=m.getBoundingSphere(new o.Sphere);for(var b=0,S=g;b<S.length;b++){var E=S[b];x.addGroup(E.start,E.count,E.materialIndex)}for(var w=[],A=0,P=g;A<P.length;A++){E=P[A];var N=new _e;w.push(N),N.defines.USE_MAP=!1,N.uniforms.diffuse.value=new o.Color(16777215),N.uniforms.floorIndex.value=l}var D=new ee(x,w);D.name="model_floor_"+l,D.floorIndex=l,D.userData.createAt=h,D.userData.description=c,r=h,n=c,i.push(D)}return{createAt:r,description:n,objects:i}}var Ue={};function Fe(t){return Array.prototype.reduce.call(t,(function(t,e,r){return t|e<<8*r}),0)}function Ye(t){for(var e=new Uint8Array(t),r=Fe(e.slice(0,4)),n=[],i=[],s=4+4*r,o=0;o<r;o++)i[o]=Fe(e.slice(4+4*o,8+4*o)),n[o]=o===r-1?e.subarray(s,s+i[o]):e.slice(s,s+i[o]),s+=i[o];return Promise.resolve(function(t){for(var e,r=[],n=t.length,i=function(n){var i={data:t[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=i.data.length,o={data:[],offset:0,writeByte:function(t){var e=Math.floor(this.offset/s);this.data[e]||(this.data[e]=new Uint8Array(s)),this.data[e][this.offset%s]=t,this.offset++}};Ue.decompressFile(i,o),e=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)e[a]=o.data[Math.floor(a/s)][a%s];r.push(e)},s=0;s<n;s++)i(s);return r}(n))}Ue.OutWindow=function(){this._windowSize=0},Ue.OutWindow.prototype.create=function(t){this._buffer&&this._windowSize===t||(this._buffer=[]),this._windowSize=t,this._pos=0,this._streamPos=0},Ue.OutWindow.prototype.flush=function(){var t=this._pos-this._streamPos;if(0!==t){for(;t--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},Ue.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},Ue.OutWindow.prototype.setStream=function(t){this.releaseStream(),this._stream=t},Ue.OutWindow.prototype.init=function(t){t||(this._streamPos=0,this._pos=0)},Ue.OutWindow.prototype.copyBlock=function(t,e){var r=this._pos-t-1;for(r<0&&(r+=this._windowSize);e--;)r>=this._windowSize&&(r=0),this._buffer[this._pos++]=this._buffer[r++],this._pos>=this._windowSize&&this.flush()},Ue.OutWindow.prototype.putByte=function(t){this._buffer[this._pos++]=t,this._pos>=this._windowSize&&this.flush()},Ue.OutWindow.prototype.getByte=function(t){var e=this._pos-t-1;return e<0&&(e+=this._windowSize),this._buffer[e]},Ue.RangeDecoder=function(){},Ue.RangeDecoder.prototype.setStream=function(t){this._stream=t},Ue.RangeDecoder.prototype.releaseStream=function(){this._stream=null},Ue.RangeDecoder.prototype.init=function(){var t=5;for(this._code=0,this._range=-1;t--;)this._code=this._code<<8|this._stream.readByte()},Ue.RangeDecoder.prototype.decodeDirectBits=function(t){for(var e,r=0,n=t;n--;)this._range>>>=1,e=this._code-this._range>>>31,this._code-=this._range&e-1,r=r<<1|1-e,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return r},Ue.RangeDecoder.prototype.decodeBit=function(t,e){var r=t[e],n=(this._range>>>11)*r;return(2147483648^this._code)<(2147483648^n)?(this._range=n,t[e]+=2048-r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,t[e]-=r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},Ue.initBitModels=function(t,e){for(;e--;)t[e]=1024},Ue.BitTreeDecoder=function(t){this._models=[],this._numBitLevels=t},Ue.BitTreeDecoder.prototype.init=function(){Ue.initBitModels(this._models,1<<this._numBitLevels)},Ue.BitTreeDecoder.prototype.decode=function(t){for(var e=1,r=this._numBitLevels;r--;)e=e<<1|t.decodeBit(this._models,e);return e-(1<<this._numBitLevels)},Ue.BitTreeDecoder.prototype.reverseDecode=function(t){for(var e,r=1,n=0,i=0;i<this._numBitLevels;++i)r=r<<1|(e=t.decodeBit(this._models,r)),n|=e<<i;return n},Ue.reverseDecode2=function(t,e,r,n){for(var i,s=1,o=0,a=0;a<n;++a)s=s<<1|(i=r.decodeBit(t,e+s)),o|=i<<a;return o},Ue.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new Ue.BitTreeDecoder(8),this._numPosStates=0},Ue.LenDecoder.prototype.create=function(t){for(;this._numPosStates<t;++this._numPosStates)this._lowCoder[this._numPosStates]=new Ue.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new Ue.BitTreeDecoder(3)},Ue.LenDecoder.prototype.init=function(){var t=this._numPosStates;for(Ue.initBitModels(this._choice,2);t--;)this._lowCoder[t].init(),this._midCoder[t].init();this._highCoder.init()},Ue.LenDecoder.prototype.decode=function(t,e){return 0===t.decodeBit(this._choice,0)?this._lowCoder[e].decode(t):0===t.decodeBit(this._choice,1)?8+this._midCoder[e].decode(t):16+this._highCoder.decode(t)},Ue.Decoder2=function(){this._decoders=[]},Ue.Decoder2.prototype.init=function(){Ue.initBitModels(this._decoders,768)},Ue.Decoder2.prototype.decodeNormal=function(t){var e=1;do{e=e<<1|t.decodeBit(this._decoders,e)}while(e<256);return 255&e},Ue.Decoder2.prototype.decodeWithMatchByte=function(t,e){var r,n,i=1;do{if(r=e>>7&1,e<<=1,i=i<<1|(n=t.decodeBit(this._decoders,(1+r<<8)+i)),r!==n){for(;i<256;)i=i<<1|t.decodeBit(this._decoders,i);break}}while(i<256);return 255&i},Ue.LiteralDecoder=function(){},Ue.LiteralDecoder.prototype.create=function(t,e){var r;if(!this._coders||this._numPrevBits!==e||this._numPosBits!==t)for(this._numPosBits=t,this._posMask=(1<<t)-1,this._numPrevBits=e,this._coders=[],r=1<<this._numPrevBits+this._numPosBits;r--;)this._coders[r]=new Ue.Decoder2},Ue.LiteralDecoder.prototype.init=function(){for(var t=1<<this._numPrevBits+this._numPosBits;t--;)this._coders[t].init()},Ue.LiteralDecoder.prototype.getDecoder=function(t,e){return this._coders[((t&this._posMask)<<this._numPrevBits)+((255&e)>>>8-this._numPrevBits)]},Ue.Decoder=function(){this._outWindow=new Ue.OutWindow,this._rangeDecoder=new Ue.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new Ue.BitTreeDecoder(4),this._lenDecoder=new Ue.LenDecoder,this._repLenDecoder=new Ue.LenDecoder,this._literalDecoder=new Ue.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[1]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[2]=new Ue.BitTreeDecoder(6),this._posSlotDecoder[3]=new Ue.BitTreeDecoder(6)},Ue.Decoder.prototype.setDictionarySize=function(t){return!(t<0)&&(this._dictionarySize!==t&&(this._dictionarySize=t,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},Ue.Decoder.prototype.setLcLpPb=function(t,e,r){var n=1<<r;return!(t>8||e>4||r>4)&&(this._literalDecoder.create(e,t),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},Ue.Decoder.prototype.init=function(){var t=4;for(this._outWindow.init(!1),Ue.initBitModels(this._isMatchDecoders,192),Ue.initBitModels(this._isRep0LongDecoders,192),Ue.initBitModels(this._isRepDecoders,12),Ue.initBitModels(this._isRepG0Decoders,12),Ue.initBitModels(this._isRepG1Decoders,12),Ue.initBitModels(this._isRepG2Decoders,12),Ue.initBitModels(this._posDecoders,114),this._literalDecoder.init();t--;)this._posSlotDecoder[t].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},Ue.Decoder.prototype.decode=function(t,e,r){var n,i,s,o,a,u,h=0,c=0,l=0,f=0,p=0,d=0,v=0;for(this._rangeDecoder.setStream(t),this._outWindow.setStream(e),this.init();r<0||d<r;)if(n=d&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(h<<4)+n))i=this._literalDecoder.getDecoder(d++,v),v=h>=7?i.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(c)):i.decodeNormal(this._rangeDecoder),this._outWindow.putByte(v),h=h<4?0:h-(h<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,h))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,h)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(h<<4)+n)&&(h=h<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,h)?o=l:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,h)?o=f:(o=p,p=f),f=l),l=c,c=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),h=h<7?8:11);else if(p=f,f=l,l=c,s=2+this._lenDecoder.decode(this._rangeDecoder,n),h=h<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(c=(2|1&a)<<(u=(a>>1)-1),a<14)c+=Ue.reverseDecode2(this._posDecoders,c-a-1,this._rangeDecoder,u);else if(c+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(c+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===c)break;return!1}}else c=a;if(c>=d||c>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(c,s),d+=s,v=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},Ue.Decoder.prototype.setDecoderProperties=function(t){var e,r,n,i,s;return!(t.size<5)&&(r=(e=t.readByte())%9,n=(e=~~(e/9))%5,i=~~(e/5),!!this.setLcLpPb(r,n,i)&&(s=t.readByte(),s|=t.readByte()<<8,s|=t.readByte()<<16,s+=16777216*t.readByte(),this.setDictionarySize(s)))},Ue.decompress=function(t,e,r,n){var i=new Ue.Decoder;if(!i.setDecoderProperties(t))throw"Incorrect stream properties";if(!i.decode(e,r,n))throw"Error in data stream";return!0},Ue.decompressFile=function(t,e){var r,n=new Ue.Decoder;if(!n.setDecoderProperties(t))throw"Incorrect stream properties";if(r=t.readByte(),r|=t.readByte()<<8,r|=t.readByte()<<16,r+=16777216*t.readByte(),t.readByte(),t.readByte(),t.readByte(),t.readByte(),!n.decode(t,e,r))throw"Error in data stream";return!0};var Qe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return qt(e,t),e.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof ee&&t.geometry.dispose()}))},e}(o.Group);const Ze=h.Reader,Ge=h.util,We=h.roots["@REALSEE/FIVE:five/server/model/proto/dome.proto"]||(h.roots["@REALSEE/FIVE:five/server/model/proto/dome.proto"]={}),Xe=We.Model=(()=>{function t(t){if(this.meshes=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.meshes=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Model;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(We.Mesh.decode(t,t.uint32()));else t.skipType(7&e)}return n},t})();We.Mesh=(()=>{function t(t){if(this.chunks=[],this.matrix=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.chunks=Ge.emptyArray,t.prototype.matrix=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Mesh;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.name=t.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(We.Chunk.decode(t,t.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(We.Matrix.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("name"))throw Ge.ProtocolError("missing required 'name'",{instance:n});return n},t})(),We.Matrix=(()=>{function t(t){if(this.elements=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elements=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Matrix;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.elements&&n.elements.length||(n.elements=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.elements.push(t.float())}else n.elements.push(t.float());else t.skipType(7&e)}return n},t})(),We.Chunk=(()=>{function t(t){if(this.material=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.geometry=null,t.prototype.material=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 2:n.geometry=We.Geometry.decode(t,t.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(We.Material.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("geometry"))throw Ge.ProtocolError("missing required 'geometry'",{instance:n});return n},t})(),We.Geometry=(()=>{function t(t){if(this.groups=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.position=null,t.prototype.uv=null,t.prototype.uv2=null,t.prototype.normal=null,t.prototype.groups=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Geometry;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.position=We.Position.decode(t,t.uint32());break;case 2:n.uv=We.UV.decode(t,t.uint32());break;case 3:n.uv2=We.UV.decode(t,t.uint32());break;case 4:n.normal=We.Normal.decode(t,t.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(We.Group.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("position"))throw Ge.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw Ge.ProtocolError("missing required 'normal'",{instance:n});return n},t})(),We.Position=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Position;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.UV=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.UV;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.Normal=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Normal;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());else t.skipType(7&e)}return n},t})(),We.Group=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.start=0,t.prototype.count=0,t.prototype.materialIndex=0,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Group;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.start=t.uint32();break;case 2:n.count=t.uint32();break;case 3:n.materialIndex=t.uint32();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("start"))throw Ge.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw Ge.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw Ge.ProtocolError("missing required 'materialIndex'",{instance:n});return n},t})(),We.Material=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.kd=null,t.prototype.ks=null,t.prototype.ke=null,t.prototype.mapkd="",t.prototype.mapks="",t.prototype.mapke="",t.prototype.norm="",t.prototype.mapbump="",t.prototype.bump="",t.prototype.mapd="",t.prototype.ns=0,t.prototype.d=0,t.prototype.tr=0,t.prototype.mapkdrepeat="",t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Material;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.kd=We.Color.decode(t,t.uint32());break;case 2:n.ks=We.Color.decode(t,t.uint32());break;case 3:n.ke=We.Color.decode(t,t.uint32());break;case 4:n.mapkd=t.string();break;case 5:n.mapks=t.string();break;case 6:n.mapke=t.string();break;case 7:n.norm=t.string();break;case 8:n.mapbump=t.string();break;case 9:n.bump=t.string();break;case 10:n.mapd=t.string();break;case 11:n.ns=t.float();break;case 12:n.d=t.float();break;case 13:n.tr=t.float();break;case 14:n.mapkdrepeat=t.string();break;default:t.skipType(7&e)}}return n},t})(),We.Color=(()=>{function t(t){if(this.rgb=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.rgb=Ge.emptyArray,t.decode=function(t,e){t instanceof Ze||(t=Ze.create(t));let r=void 0===e?t.len:t.pos+e,n=new We.Color;for(;t.pos<r;){let e=t.uint32();if(e>>>3==1)if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.rgb.push(t.float())}else n.rgb.push(t.float());else t.skipType(7&e)}return n},t})();var Je={};function $e(t){var e,r=[];function n(t,e,r){var n=function(t){var e=t.position,r=t.normal,n=t.uv,i=t.uv2,s=t.groups,a=new o.BufferGeometry;return a.setAttribute("position",new o.BufferAttribute(new Float32Array(e.array),3)),r&&a.setAttribute("normal",new o.BufferAttribute(new Float32Array(r.array),3)),n&&a.setAttribute("uv",new o.BufferAttribute(new Float32Array(n.array),2)),i&&a.setAttribute("uv2",new o.BufferAttribute(new Float32Array(i.array),2)),s.forEach((function(t){return a.addGroup(t.start,t.count,t.materialIndex)})),a}(t);n.applyMatrix4(r);var i=new o.Vector3,s=new o.Quaternion,a=new o.Vector3;return r.decompose(i,s,a),a.x*a.y*a.z<0&&n.attributes.normal&&n.attributes.position&&n.attributes.uv&&function(t){for(var e=[0,0,0],r=0;r<t.attributes.normal.array.length/9;r++)e[0]=t.attributes.normal.array[9*r],e[1]=t.attributes.normal.array[9*r+1],e[2]=t.attributes.normal.array[9*r+2],t.attributes.normal.array[9*r]=t.attributes.normal.array[9*r+6],t.attributes.normal.array[9*r+1]=t.attributes.normal.array[9*r+7],t.attributes.normal.array[9*r+2]=t.attributes.normal.array[9*r+8],t.attributes.normal.array[9*r+6]=e[0],t.attributes.normal.array[9*r+7]=e[1],t.attributes.normal.array[9*r+8]=e[2];for(r=0;r<t.attributes.position.array.length/9;r++)e[0]=t.attributes.position.array[9*r],e[1]=t.attributes.position.array[9*r+1],e[2]=t.attributes.position.array[9*r+2],t.attributes.position.array[9*r]=t.attributes.position.array[9*r+6],t.attributes.position.array[9*r+1]=t.attributes.position.array[9*r+7],t.attributes.position.array[9*r+2]=t.attributes.position.array[9*r+8],t.attributes.position.array[9*r+6]=e[0],t.attributes.position.array[9*r+7]=e[1],t.attributes.position.array[9*r+8]=e[2];for(r=0;r<t.attributes.uv.array.length/6;r++)e[0]=t.attributes.uv.array[6*r],e[1]=t.attributes.uv.array[6*r+1],t.attributes.uv.array[6*r]=t.attributes.uv.array[6*r+4],t.attributes.uv.array[6*r+1]=t.attributes.uv.array[6*r+5],t.attributes.uv.array[6*r+4]=e[0],t.attributes.uv.array[6*r+5]=e[1];t.attributes.normal.needsUpdate=!0,t.attributes.position.needsUpdate=!0,t.attributes.uv.needsUpdate=!0}(n),new ee(n)}return(e=t,Xe.decode(e).meshes).forEach((function(t){var e=t.name,i=t.chunks,s=t.matrix;"Ceiling"!==e&&"CeilingDrop"!==e&&s.map((function(t){var s,a=new o.Matrix4;if(a.elements=t.elements,1===i.length){var u=i[0],h=u.geometry;u.material;s=n(h,0,a)}else s=new Qe,i.forEach((function(t,e){var r=t.geometry,i=(t.material,n(r,0,a));i.name="chunk"+e,s.add(i)}));s.floorIndex=0,s.name=e,r.push(s)}))})),{objects:r,createAt:0,description:""}}function tr(){Object.keys(Je).forEach((function(t){Je[t].dispose(),delete Je[t]}))}function er(t){return null==t}var rr=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.needsRender=!0,e}return qt(e,t),e.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof ee&&t.geometry.dispose()}))},e}(o.Group),nr=function(t,e){void 0===e&&(e=1e-4),e=Math.max(e,Number.EPSILON);for(var r={},n=t.getIndex(),i=t.getAttribute("position"),s=n?n.count:i.count,a=0,u=Object.keys(t.attributes),h={},c={},l=[],f=["getX","getY","getZ","getW"],p=0,d=u.length;p<d;p++){h[b=u[p]]=[],(A=t.morphAttributes[b])&&(c[b]=new Array(A.length).fill().map((function(){return[]})))}var v=Math.log10(1/e),g=Math.pow(10,v);for(p=0;p<s;p++){var y=n?n.getX(p):p,m="",x=0;for(d=u.length;x<d;x++)for(var b=u[x],S=(w=t.getAttribute(b)).itemSize,E=0;E<S;E++)m+="".concat(~~(w[f[E]](y)*g),",");if(m in r)l.push(r[m]);else{for(x=0,d=u.length;x<d;x++){b=u[x];var w=t.getAttribute(b),A=t.morphAttributes[b],P=(S=w.itemSize,h[b]),N=c[b];for(E=0;E<S;E++){var D=f[E];if(P.push(w[D](y)),A)for(var R=0,T=A.length;R<T;R++)N[R].push(A[R][D](y))}}r[m]=a,l.push(a),a++}}var C=t.clone();for(p=0,d=u.length;p<d;p++){b=u[p];var I=t.getAttribute(b),O=new I.array.constructor(h[b]);w=new o.BufferAttribute(O,I.itemSize,I.normalized);if(C.setAttribute(b,w),b in c)for(x=0;x<c[b].length;x++){var _=t.morphAttributes[b][x],H=(O=new _.array.constructor(c[b][x]),new o.BufferAttribute(O,_.itemSize,_.normalized));C.morphAttributes[b][x]=H}}return C.setIndex(l),C};function ir(t){var e;return new((e=o.Triangle).bind.apply(e,Kt([void 0],t.map((function(t){return new o.Vector3(t.x,t.y,t.z)})),!1)))}var sr={at3d:function(t){return Promise.resolve().then((function(){return He(t.file)})).then((function(t){return Ye(t)})).then((function(t){for(var e,r={chunks:[],createAt:void 0,description:void 0},n=0,i=t;n<i.length;n++){var s=i[n],o=ze.decode(s);o.chunks.length&&((e=r.chunks).push.apply(e,o.chunks),r.createAt=o.createAt,r.description=o.description)}return r})).then((function(t){return Me(t)}))},pbm:function(t){return Promise.resolve().then((function(){return He(t.file)})).then((function(t){var e=new Uint8Array(t);return ze.decode(e)})).then((function(t){return Me(t)}))},dome:function(t){return Promise.resolve().then((function(){return tr()})).then((function(){return He(t.file)})).then((function(t){return $e(new Uint8Array(t))}))},domez:function(t){return Promise.resolve().then((function(){return tr()})).then((function(){return He(t.file)})).then((function(t){return Ye(t)})).then((function(t){var e=t.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(e),n=0;return t.forEach((function(t){r.set(t,n),n+=t.length})),r})).then((function(t){return $e(t)}))}},or=function(t){function e(){var e=t.call(this)||this;return e.empty=!1,e.name="model",e.loaded=!1,e.bvhs=[],e.bounding=new o.Box3,e.shownfloor=null,e.floorLength=0,e}return qt(e,t),e.prototype.getEdges=function(t){var e;void 0===t&&(t=30/180*Math.PI);for(var r=Math.cos(t),n=[],i=0,s=this.children;i<s.length;i++){var a=s[i];if(a instanceof ee){for(var u={},h=["a","b","c"],c=nr(a.geometry),l=c.getAttribute("position").array,f=(null===(e=c.getIndex())||void 0===e?void 0:e.array)||[],p=[],d=[],v=0,g=l.length;v<g;v+=3)p.push(new o.Vector3(l[v],l[v+1],l[v+2]));for(v=0,g=f.length;v<g;v+=3){var y=f[v],m=f[v+1],x=f[v+2],b=(new o.Vector3).crossVectors(p[m].clone().sub(p[y]),p[x].clone().sub(p[y])).normalize();d.push({a:y,b:m,c:x,normal:b})}for(v=0,g=d.length;v<g;v++)for(var S=d[v],E=0;E<3;E++){var w=S[h[E]],A=S[h[(E+1)%3]],P=[Math.min(w,A),Math.max(w,A)];void 0===u[N=P[0]+"-"+P[1]]?u[N]={index1:P[0],index2:P[1],face1:v}:u[N].face2=v}for(var N in u){var D=u[N];if(void 0===D.face2||d[D.face1].normal.dot(d[D.face2].normal)<=r){var R=p[D.index1],T=p[D.index2];n.push(new o.Line3(R,T))}}c.dispose(),p.length=0,d.length=0}}return n},e.prototype.hasFloors=function(){return this.hasFloors_()},e.prototype.hasFloors_=function(){var t=[];return this.traverse((function(e){e instanceof ee&&(t[e.floorIndex]=!0)})),t.length},e.prototype.show=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=0!==t.length;this.shownfloor=r?t[0]:null,this.needsRender=!0},e.prototype.intersectRaycaster=function(t,e){var r=t.ray,n=r.origin,i=r.direction;if(er(e))if(er(this.shownfloor)){var s=this.hasFloors();e=[];for(var a=0;a<s;a++)e.push(a)}else e=[this.shownfloor];var u=[],h=[];Array.isArray(e)?h.push.apply(h,e):h.push(e);for(var c=function(e){var r=l.bvhs&&l.bvhs[e];if(r){var s=new Yt(n.x,n.y,n.z),a=new Yt(i.x,i.y,i.z),h=r.intersectRay(s,a,!0).map((function(t){var e=t.intersectionPoint,r=t.triangle,i=new o.Vector3(e.x,e.y,e.z);return{point:i,face:{normal:ir(r).getNormal(new o.Vector3)},distance:n.distanceTo(i)}}));h.length&&u.push.apply(u,h)}else{var c=[];l.traverse((function(t){t instanceof ee&&t.floorIndex===e&&c.push(t)})),(h=t.intersectObjects(c).map((function(t){var e=t.face?{normal:t.face.normal}:void 0;return{point:t.point,face:e,distance:t.distance}}))).length&&u.push.apply(u,h)}},l=this,f=0,p=h;f<p.length;f++){c(p[f])}return u.filter((function(e){var r=e.distance;return r<=t.far&&r>=t.near})).sort((function(t,e){return t.distance-e.distance}))},e.prototype.buildBVH=function(){var t,e=[];this.traverse((function(t){t instanceof ee&&(e[t.floorIndex]=e[t.floorIndex]||[],e[t.floorIndex].push(t.geometry))}));var r=e.map((function(t){var e=t.reduce((function(t,e){return t+(e.index?e.index.array.length:e.attributes.position.array.length)}),0),r=new Float32Array(3*e);return t.reduce((function(t,e){for(var n=e.index?e.index.array:null,i=e.attributes.position.array,s=n?n.length:i.length/3,o=0;o<s;o++){var a=3*(t+o),u=n?3*n[o]:3*o;r[a+0]=i[u+0],r[a+1]=i[u+1],r[a+2]=i[u+2]}return t+s}),0),new te(r,10)}));this.bvhs.length=0,(t=this.bvhs).push.apply(t,r),this.bvhs.loaded=!0,this.emit("bvhLoaded")},e.prototype.load=function(t){var e=this;if(!0===this.loaded)throw new Error("model 只能被 load 一次");var r=sr[function(t,e){void 0===e&&(e=[]);var r=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(t);if(r)for(var n=String(r[1]).trim().split("."),i=0,s=e;i<s.length;i++){var o=s[i];if(n.indexOf(o)>=0)return o}}(t.file,Object.keys(sr))||""];if(!r)throw new Error("文件类型错误");return r(t).then((function(t){var r=t.createAt,n=t.description,i=t.objects;e.userData.createAt=r,e.userData.description=n,e.bounding.makeEmpty();for(var s=e.originModel=new rr,o=0,a=i;o<a.length;o++){var u=a[o];u.traverse((function(t){if(t instanceof ee){var r=t.geometry;r.boundingBox||r.computeBoundingBox(),r.boundingSphere||r.computeBoundingSphere(),e.bounding.union(r.boundingBox)}})),s.add(u)}e.add(s),e.floorLength=e.hasFloors_(),e.emit("geometryLoaded"),e.emit("loaded"),e.loaded=!0})).catch((function(t){return e.emit("error",t),Promise.reject(t)}))},e.prototype.dispose=function(){for(this.off(),this.disposeGeometry();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},e}(Qe);Object.assign(or.prototype,{on:de.prototype.on,once:de.prototype.once,off:de.prototype.off,emit:de.prototype.emit,hasListener:de.prototype.hasListener});function ar(t,e,r){return t<e?e:t>r?r:t}function ur(t){return 0===t.indexOf("//")||/^[0-9a-z]+\:/i.test(t)}function hr(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=[];t=t.map((function(t){return(null!=t?t:"").trim()})).filter((function(t){return t.length>0&&!/^\/+$/.test(t)}));for(var n=0;n<t.length;n++){var i=0===n,s=n===t.length-1,o=t[n];i||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),r.push(o)}return r.join("/")}function cr(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var r,n,i;if(Array.isArray(t)){if((r=t.length)!=e.length)return!1;for(n=r;0!=n--;)if(!cr(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;0!=n--;){var s=i[n];if(!cr(t[s],e[s]))return!1}return!0}return t!=t&&e!=e}function lr(t){return"number"==typeof t}var fr=function(){return new Error("Invalid input.")},pr=function(){return new Error("Invalid certificate.")},dr=function(){return new Error("Invalid signature.")};function vr(t,e){void 0===e&&(e=!1);var r=typeof t;if("string"===r)return JSON.stringify(t);if(!0===t)return"true";if(!1===t)return"false";if(null===t)return"null";if(t instanceof Array){for(var n="[",i=t.length-1,s=0;s<i;s++)n+=vr(t[s],!1)+",";return i>-1&&(n+=vr(t[s],!1)),n+"]"}if(t instanceof Object){if("function"==typeof t.toJSON)return vr(t.toJSON(),e);var o=Object.keys(t).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],h=vr(t[u],!0);void 0!==h&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+h),s++}return"{"+n+"}"}switch(r){case"function":case"undefined":return e?void 0:null;case"number":return 0;default:return isFinite(t)?t:null}}function gr(t){return String(vr(t,!1))}function yr(t){var e,r,n;if(Array.isArray(t)){var i,s,o=void 0;if(t.length<=0)return fr();for(var a=function(e){var r=yr(t[e]);if(r instanceof Error)return{value:r};if(o){if(o!==r.issuer)return{value:pr()}}else o=r.issuer;i?r.expire.getTime()<i.getTime()&&(i=r.expire):i=r.expire,s=s?s.filter((function(t){return-1!==r.allowHosts.indexOf(t)})):r.allowHosts},u=0;u<t.length;u++){var h=a(u);if("object"==typeof h)return h.value}return ye({issuer:o,expire:i,allowHosts:s})}var c=JSON.parse(t),l="undefined"!=typeof location?location.hostname:"",f=Date.now();if("object"!=typeof c)return fr();var p=new Date("string"==typeof c.expire_at&&/^\d+$/.test(c.expire_at)?Number(c.expire_at):c.expire_at),d=Array.isArray(c.allow_hosts)?c.allow_hosts:[];if(0===l.length||/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(l)||be.filter((function(t){return xe(t,l)})).length>0){var v=String(null!==(e=c.certificate)&&void 0!==e?e:"");if(v){var g=new Ot;return g.readCertPEM(v),ye({issuer:g.getSubjectString(),expire:p,allowHosts:d})}return ye({issuer:"none",expire:p,allowHosts:d})}var y=String(null!==(r=c.certificate)&&void 0!==r?r:"");if(!y)return pr();var m=new Ot;m.readCertPEM(y);var x=String(null!==(n=c._signature)&&void 0!==n?n:"");if(!x)return dr();var b=gr(function(t,e){for(var r={},n=0,i=Object.keys(t);n<i.length;n++){var s=i[n];-1===e.indexOf(s)&&(r[s]=t[s])}return r}(c,["_signature"]));return!1===function(t,e,r){var n=new Ot;if("string"==typeof r?n.readCertPEM(r):n.readCertHex(r.hex),!1===jt(n))return!1;var i=new $;return i.readCertPubKeyHex(n.hex,6),!!i.verify(t,q(e))}(b,x,m)?dr():f<p.getTime()?0===d.filter((function(t){return xe(t,l)})).length?function(t){return new Error("host(".concat(JSON.stringify(t),") is not allowed."))}(l):ye({issuer:m.getSubjectString(),expire:p,allowHosts:d}):function(t){return new Error("date(".concat(t.toString(),") expired."))}(p)}var mr=new WeakMap,xr=function(){function t(){this.name="",this.workCode="",this.expire=new Date,this.allowHosts=[],this.initial={mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},this.observers=[],this.boundingBox=new o.Box3,this.issuer="none",this.raw={works:[""],options:""}}return t.prototype.toJSON=function(){return this.raw.works},t.parse=wr,t}();function br(t){return null==t?"null":Array.isArray(t)?"array":"object"==typeof t?"dict":"value"}function Sr(t,e){var r=br(t),n=br(e);if("null"===n)return t;if("value"===n)return e;if(n!==r)return JSON.parse(JSON.stringify(e));if("array"===n)for(var i=0;i<e.length;i++)t[i]=Sr(t[i],e[i]);else if("dict"===n)for(var s in e)t[s]=Sr(t[s],e[s]);return t}function Er(t,e,r){for(var n,i=JSON.stringify(e),s=[],a=0,u=[].concat(t);a<u.length;a++){var h=u[a];h instanceof xr?s.push.apply(s,h.raw.works):"string"==typeof h?s.push(h):s.push(JSON.stringify(h))}var c=yr(s);if(c instanceof Error)return c;e=JSON.parse(i),t=s.map((function(t){return JSON.parse(t)})).reduce((function(t,e){return Sr(t,e)}));var l=new xr;if(c instanceof Error)return c;l.issuer=c.issuer,l.expire=c.expire,l.allowHosts=c.allowHosts,l.raw={works:s,options:i};var f=null!==(n=t.base_url)&&void 0!==n?n:"";f&&"/"!==f[f.length-1]&&(f+="/");var p=function(t,e){return 0===t.indexOf(e)},d=function(t,n){var i,s=t;if(!0===e.jsonp){s=t.replace(/([\?\#].*)?$/i,"");var o=_t("".concat(s)).slice(0,7);s="".concat(s,".").concat(o,".jsonp")}if(!0===e.shortPath){var a=s.replace(f,"").split("."),u=null!==(i=a.shift())&&void 0!==i?i:"",h=a.join(".");s=hr(f,_t(u))+(h?"."+h:"")}var c=s.replace(f,"");return e.baseURL&&(s=hr(e.baseURL,c)),r&&r(t,s,c,n),s},v=function(e,r){var n,i,s,o,a,u,h=e;if(!ur(e)){var c=null!==(u=null!==(o=null!==(i=null===(n=t.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==i?i:null===(s=t.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=t.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";c&&(c=hr(c,String(r))),h=hr(c,h)}return ur(h)||(h=hr(f,h)),p(h,f)||console.warn("".concat(h," is not start with base_url(").concat(f,").")),d(h,"panorama")},g=function(t){var e=t;return ur(e)||(e=hr(f,t)),p(e,f)||console.warn("".concat(e," is not start with base_url(").concat(f,").")),d(e,"model")},y=function(t,e){void 0===e&&(e="");var r=t;return ur(r)||(r=hr(e,r)),ur(r)||(r=hr(f,r)),p(r,f)||console.warn("".concat(r," is not start with base_url(").concat(f,").")),d(r,"texture")};if(c instanceof Error)return c;if(l.workCode=String(t.work_code||t.code||t.vr_code||t.workCode),l.name=String(t.name),c instanceof Error)return c;if(t.model){var m={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.modelBvh?m.bvh=e.modelBvh:"boolean"==typeof t.model.bvh?m.bvh=t.model.bvh:"boolean"==typeof t.bvh&&(m.bvh=t.bvh),t.model.file?m.file=g(t.model.file):t.model.file_url&&(m.file=g(t.model.file_url)),t.model.textureBase?m.textureBase=y("",t.model.textureBase):t.model.material_base_url?m.textureBase=y("",t.model.material_base_url):m.file&&(m.textureBase=m.file.split("/").slice(0,-1).join("/").replace("/model/","/materials/")),Array.isArray(t.model.textures)?m.textures=t.model.textures.map((function(e){var r,n;return y(e,null!==(n=null!==(r=t.model.textureBase)&&void 0!==r?r:t.model.material_base_url)&&void 0!==n?n:"")})):Array.isArray(t.model.material_textures)&&(m.textures=t.model.material_textures.map((function(e){var r,n;return y(e,null!==(n=null!==(r=t.model.textureBase)&&void 0!==r?r:t.model.material_base_url)&&void 0!==n?n:"")}))),t.model.tiles&&(m.tiles=t.model.tiles),m.file&&(l.model=m)}if(c instanceof Error)return c;if(t.observers&&Array.isArray(t.observers)){var x=[];t.panorama&&(Array.isArray(t.panorama)?x=t.panorama:Array.isArray(t.panorama.list)?x=t.panorama.list:Array.isArray(t.panorama.info)&&(x=t.panorama.info));for(var b=0;b<t.observers.length;b++){var S={},E=t.observers[b];if(!E)break;var w=x[b];if(!w)break;E=Object.assign({},E,w,{active:!1!==E.active&&!1!==w.active}),S.panoIndex=b,S.active=!1!==E.active,S.loadable=!0===E.loadable,S.images={up:v(E.images?E.images.up:E.up,b),down:v(E.images?E.images.down:E.down,b),right:v(E.images?E.images.right:E.right,b),left:v(E.images?E.images.left:E.left,b),front:v(E.images?E.images.front:E.front,b),back:v(E.images?E.images.back:E.back,b)};var A=E.images?E.images.depth:E.depth;A&&(S.images.depth=v(A,b));var P=E.images?E.images.luminance:E.luminance;P&&(S.images.luminance={up:v(P.up,b),down:v(P.down,b),right:v(P.right,b),left:v(P.left,b),front:v(P.front,b),back:v(P.back,b)});var N=E.images?E.images.tiles:E.tiles;if(N){for(var D=[],R=function(t){var e,r=t.match(/\/cube_(\d+)\//);if(r){var n=Number(r[1]);if(0==((e=n)&e-1)&&0!==e)return n}return!1},T=function(t,e){return t.replace(/\/cube_(\d+)\//,(function(){return"/cube_".concat(e,"/")}))},C=0,I=N;C<I.length;C++){var O=I[C];if("number"==typeof O){var _=O,H=R(S.images.front);if(!1===H)continue;if((K=Math.max(H,512*Math.pow(2,_)))>2048){var B=T(S.images.up,K),V=T(S.images.down,K),j=T(S.images.right,K),z=T(S.images.left,K),q=T(S.images.front,K),k=T(S.images.back,K);D.push({level:_,size:K,up:B,down:V,right:j,left:z,front:q,back:k})}else{B=S.images.up,V=S.images.down,j=S.images.right,z=S.images.left,q=S.images.front,k=S.images.back;D.push({level:_,size:K,up:B,down:V,right:j,left:z,front:q,back:k})}}else{var K;if("number"!=typeof(_=O.level))continue;if("number"!=typeof(K=O.size))continue;B=v(O.up,b),V=v(O.down,b),j=v(O.right,b),z=v(O.left,b),q=v(O.front,b),k=v(O.back,b);D.push({level:_,size:K,up:B,down:V,right:j,left:z,front:q,back:k})}}D.sort((function(t,e){return t.level-e.level})),S.images.tiles=D}if(E.position instanceof o.Vector3)S.position=E.position.clone();else{if(!Array.isArray(E.position))break;S.position=(new o.Vector3).fromArray(E.position)}if(E.standingPosition instanceof o.Vector3)S.standingPosition=E.standingPosition.clone();else if(Array.isArray(E.standingPosition))S.standingPosition=(new o.Vector3).fromArray(E.standingPosition);else if(E.standing_position instanceof o.Vector3)S.standingPosition=E.standing_position.clone();else{if(!Array.isArray(E.standing_position))break;S.standingPosition=(new o.Vector3).fromArray(E.standing_position)}if(E.quaternion instanceof o.Quaternion)S.quaternion=E.quaternion.clone();else if(Array.isArray(E.quaternion))S.quaternion=(new o.Quaternion).fromArray(E.quaternion);else{if(!E.quaternion)break;var L=E.quaternion,M=L.x,U=L.y,F=L.z,Y=L.w;S.quaternion=new o.Quaternion(M,U,F,Y)}if(Array.isArray(E.accessibleNodes)?S.accessibleNodes=E.accessibleNodes.slice():Array.isArray(E.accessible_nodes)&&(S.accessibleNodes=E.accessible_nodes.slice()),Array.isArray(E.visibleNodes)?S.visibleNodes=E.visibleNodes.slice():Array.isArray(E.visible_nodes)&&(S.visibleNodes=E.visible_nodes.slice()),lr(E.floorIndex)?S.floorIndex=E.floorIndex:lr(E.floor_index)?S.floorIndex=E.floor_index:S.floorIndex=0,E.video){var Q={};"string"==typeof E.video.source&&(Q.source=E.video.source),E.video.matrix instanceof o.Matrix4?Q.matrix=E.video.matrix.clone():Array.isArray(E.video.matrix)&&(Q.matrix=(new o.Matrix4).fromArray(E.video.matrix)),E.video.size instanceof o.Vector2?Q.size=E.video.size.clone():Array.isArray(E.video.size)&&(Q.size=(new o.Vector2).fromArray(E.video.size)),Q.source&&Q.matrix&&Q.size&&(S.video=Q)}l.observers[b]=S}}if(c instanceof Error)return c;for(var Z=0,G=l.observers;Z<G.length;Z++){if((S=G[Z]).accessibleNodes)S.accessibleNodes=S.accessibleNodes.filter((function(t){return t<l.observers.length}));else{S.accessibleNodes=[];for(var W=0;W<l.observers.length;W++)l.observers[W]!==S&&S.accessibleNodes.push(W)}if(S.visibleNodes)S.visibleNodes=S.visibleNodes.filter((function(t){return t<l.observers.length}));else{S.visibleNodes=[];for(W=0;W<l.observers.length;W++)l.observers[W]!==S&&S.visibleNodes.push(W)}}if(c instanceof Error)return c;if(t.initial)if("Floorplan"!==t.initial.mode&&"Topview"!==t.initial.mode&&"Panorama"!==t.initial.mode&&"VRPanorama"!==t.initial.mode&&"Model"!==t.initial.mode&&"DepthPanorama"!==t.initial.mode||(l.initial.mode=t.initial.mode),lr(t.initial.latitude)&&(l.initial.latitude=t.initial.latitude),lr(t.initial.longitude)?l.initial.longitude=t.initial.longitude:lr(t.initial.heading)&&(l.initial.longitude=-(360*(t.initial.heading-.25)+90)/180*Math.PI),lr(t.initial.fov)&&(l.initial.fov=t.initial.fov),lr(t.initial.panoIndex)){var X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.panoIndex,0,X)}else if(lr(t.initial.pano_index)){X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.pano_index,0,X)}else if(lr(t.initial.pano)){X=l.observers.length>0?l.observers.length-1:0;l.initial.panoIndex=ar(t.initial.pano,0,X)}if(c instanceof Error)return c;l.boundingBox.makeEmpty();for(var J=0,$=l.observers;J<$.length;J++){S=$[J];l.boundingBox.expandByPoint(S.standingPosition),l.boundingBox.expandByPoint((new o.Vector3).fromArray([S.position.x,2*S.position.y-S.standingPosition.y,S.position.z]))}if(c instanceof Error)return c;var tt=ye(l);return mr.set(tt,{works:s,options:i}),tt}function wr(t,e,r){"string"==typeof t&&"{"===t.trim()[0]&&(t=JSON.parse(t));var n=mr.get(t);if(n){if(e&&!cr(JSON.parse(n.options),e))throw new Error("[PARSE FAILED]: work is parsed with different options.");return t}var i=Er(t,null!=e?e:{},r);if(i instanceof Error)throw new Error("[PARSE FAILED]: "+i.message+"\nError work input:\n"+JSON.stringify(t));return i}exports.BVH=te,exports.BVHIntersect=$t,exports.BVHNode=Qt,exports.BVHVector3=Yt,exports.Model=or,exports.PBMContainer=rr,exports.PBMGroup=Qe,exports.PBMMesh=ee,exports.Subscribe=de,exports.Work=xr,exports.parseWork=wr;
|