@realsee/five 5.0.0-alpha.39 → 5.0.0-alpha.40

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.
Files changed (74) hide show
  1. package/docs/classes/five.Camera.html +4 -4
  2. package/docs/classes/five.Five.html +4 -4
  3. package/docs/classes/five.HashCubeTexture.html +4 -4
  4. package/docs/classes/five.InternalWebGLRenderer.html +4 -4
  5. package/docs/classes/five.Model.html +4 -4
  6. package/docs/classes/five.NetworkSubscribe.html +4 -4
  7. package/docs/classes/five.PBMContainer.html +4 -4
  8. package/docs/classes/five.PBMGroup.html +4 -4
  9. package/docs/classes/five.PBMMaterial.html +4 -4
  10. package/docs/classes/five.PBMMesh.html +4 -4
  11. package/docs/classes/five.Scene.html +4 -4
  12. package/docs/classes/five.Subscribe.html +4 -4
  13. package/docs/classes/gltf_loader.GLTFLoader.html +4 -4
  14. package/docs/classes/gltf_loader.GLTFObject.html +4 -4
  15. package/docs/classes/line.Line.html +4 -4
  16. package/docs/classes/line.LineGeometry.html +4 -4
  17. package/docs/classes/line.LineMaterial.html +4 -4
  18. package/docs/classes/line.LineSegmentsGeometry.html +4 -4
  19. package/docs/classes/line.THREE_Line2.html +4 -4
  20. package/docs/classes/line.THREE_LineSegments2.html +4 -4
  21. package/docs/classes/react.Store.html +4 -4
  22. package/docs/classes/server.Model.html +4 -4
  23. package/docs/classes/server.PBMGroup.html +4 -4
  24. package/docs/classes/server.PBMMesh.html +4 -4
  25. package/docs/classes/sticker.Sticker.html +4 -4
  26. package/docs/index.html +4 -4
  27. package/docs/interfaces/five.AddableObject.html +4 -4
  28. package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +4 -4
  29. package/docs/interfaces/five.EventCallback.html +4 -4
  30. package/docs/interfaces/five.FiveInitArgs.html +4 -4
  31. package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +4 -4
  32. package/docs/interfaces/five.ImageOptions.html +4 -4
  33. package/docs/interfaces/five.IntersectMeshInterface.html +4 -4
  34. package/docs/interfaces/five.Intersection.html +4 -4
  35. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +4 -4
  36. package/docs/interfaces/five.ModelEventCallback.html +4 -4
  37. package/docs/interfaces/five.MovePanoOptions.html +4 -4
  38. package/docs/interfaces/five.PBMParameters.html +4 -4
  39. package/docs/interfaces/five.PanoCircleMeshInterface.html +4 -4
  40. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +4 -4
  41. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +4 -4
  42. package/docs/interfaces/five.Pose.html +4 -4
  43. package/docs/interfaces/five.Scissor.html +4 -4
  44. package/docs/interfaces/five.State.html +4 -4
  45. package/docs/interfaces/five.SubscribeMixinType.emit.html +4 -4
  46. package/docs/interfaces/five.SubscribeMixinType.hasListener.html +4 -4
  47. package/docs/interfaces/five.SubscribeMixinType.off.html +4 -4
  48. package/docs/interfaces/five.SubscribeMixinType.on.html +4 -4
  49. package/docs/interfaces/five.SubscribeMixinType.once.html +4 -4
  50. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +4 -4
  51. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +4 -4
  52. package/docs/interfaces/gltf_loader.GLTF.html +4 -4
  53. package/docs/interfaces/react.FiveActionReactCallbacks.html +4 -4
  54. package/docs/interfaces/react.FiveInjectionTypes.html +4 -4
  55. package/docs/interfaces/react.PropTypeOfFiveFeatures.html +4 -4
  56. package/docs/interfaces/server.Intersection.html +4 -4
  57. package/docs/interfaces/server.ModelEventCallback.html +4 -4
  58. package/docs/interfaces/sticker.IntersectionLike.html +4 -4
  59. package/docs/modules/five.SubscribeMixinType.html +4 -4
  60. package/docs/modules/five.html +4 -4
  61. package/docs/modules/gltf_loader.html +4 -4
  62. package/docs/modules/line.html +4 -4
  63. package/docs/modules/react.html +4 -4
  64. package/docs/modules/server.html +4 -4
  65. package/docs/modules/sticker.html +4 -4
  66. package/docs/modules.html +4 -4
  67. package/five/index.js +2 -2
  68. package/gltf-loader/index.js +1 -1
  69. package/line/index.js +1 -1
  70. package/package.json +1 -1
  71. package/react/index.js +1 -1
  72. package/server/index.js +2 -2
  73. package/sticker/index.js +1 -1
  74. package/umd/five.js +1 -1
package/five/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @realsee/five
3
3
  *
4
4
  * Generated: 2021-09-26
5
- * Version: 5.0.0-alpha.39
5
+ * Version: 5.0.0-alpha.40
6
6
  *
7
7
  * Terms:
8
8
  * Realsee SDK License Agreement
@@ -364,7 +364,7 @@ var U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";functio
364
364
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
365
365
  function J(e,t){return new f(e,t)}function $(e,t,i){for(var n="",r=0;n.length<t;)n+=i(String.fromCharCode.apply(String,e.concat([(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ee(){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 te(e,t,i){for(var n="",r=0;n.length<t;)n+=i(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n}function ie(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);1==n.length&&(n="0"+n),t+=n}return t}function ne(e){return ie(function(e){for(var t=new Array,i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}(e))}function re(e){return e.length%4==2?e+="==":e.length%4==3&&(e+="="),e=(e=e.replace(/-/g,"+")).replace(/_/g,"/")}function se(e){return e.length%2==1&&(e="0"+e),function(e){return(e=(e=e.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}(Q(e))}function oe(e){return _(re(e))}function ae(e){return function(e){return e.replace(/%/g,"")}(function(e){for(var t=encodeURIComponent(e),i="",n=0;n<t.length;n++)"%"==t[n]?(i+=t.substr(n,3),n+=2):i=i+"%"+ne(t[n]);return i}(e))}function ue(e){return decodeURIComponent(function(e){return e.replace(/(..)/g,"%$1")}(e))}function ce(e){for(var t="",i=0;i<e.length-1;i+=2)t+=String.fromCharCode(parseInt(e.substr(i,2),16));return t}function le(e){for(var t="",i=0;i<e.length;i++)t+=("0"+e.charCodeAt(i).toString(16)).slice(-2);return t}function he(e){var t=function(e){return Q(e)}(e).replace(/(.{64})/g,"$1\r\n");return t=t.replace(/\r\n$/,"")}function de(e,t){return"-----BEGIN "+t+"-----\r\n"+he(e)+"\r\n-----END "+t+"-----\r\n"}function Ae(e,t){if(-1==e.indexOf("-----BEGIN "))throw"can't find PEM header: "+t;return function(e){return _(e.replace(/[^0-9A-Za-z\/+=]*/g,""))}(e=void 0!==t?(e=e.replace(new RegExp("^[^]*-----BEGIN "+t+"-----"),"")).replace(new RegExp("-----END "+t+"-----[^]*$"),""):(e=e.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function pe(e){var t="malformed hex value";if(!e.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(8!=e.length)return 32==e.length?function(e){if(!e.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var t=(e=e.toLowerCase()).match(/.{1,4}/g),i=0;i<8;i++)t[i]=t[i].replace(/^0+/,""),""==t[i]&&(t[i]="0");var n=(e=":"+t.join(":")+":").match(/:(0:){2,}/g);if(null===n)return e.slice(1,-1);var r="";for(i=0;i<n.length;i++)n[i].length>r.length&&(r=n[i]);return(e=e.replace(r,"::")).slice(1,-1)}(e):e;try{return parseInt(e.substr(0,2),16)+"."+parseInt(e.substr(2,2),16)+"."+parseInt(e.substr(4,2),16)+"."+parseInt(e.substr(6,2),16)}catch(e){throw t}}function Me(e){return e.match(/.{4}/g).map((function(e){var t=parseInt(e.substr(0,2),16),i=parseInt(e.substr(2),16);if(0==t&i<128)return String.fromCharCode(i);if(t<8){var n=128|63&i;return ue((192|(7&t)<<3|(192&i)>>6).toString(16)+n.toString(16))}n=128|(15&t)<<2|(192&i)>>6;var r=128|63&i;return ue((224|(240&t)>>4).toString(16)+n.toString(16)+r.toString(16))})).join("")}function fe(e){return!(e.length%2!=0||!e.match(/^[0-9a-f]+$/)&&!e.match(/^[0-9A-F]+$/))}function ge(e){return e.length%2==1?"0"+e:e.substr(0,1)>"7"?"00"+e:e}K.prototype.nextBytes=function(e){var t;for(t=0;t<e.length;++t)e[t]=X()},ee.prototype.doPublic=function(e){return e.modPowInt(this.e,this.n)},ee.prototype.setPublic=function(e,t){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof e)this.n=e,this.e=t;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA public key";this.n=J(e,16),this.e=parseInt(t,16)}},ee.prototype.encrypt=function(e){var t=function(e,t){if(t<e.length+11)throw"Message too long for RSA";for(var i=new Array,n=e.length-1;n>=0&&t>0;){var r=e.charCodeAt(n--);r<128?i[--t]=r:r>127&&r<2048?(i[--t]=63&r|128,i[--t]=r>>6|192):(i[--t]=63&r|128,i[--t]=r>>6&63|128,i[--t]=r>>12|224)}i[--t]=0;for(var s=new K,o=new Array;t>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--t]=o[0]}return i[--t]=2,i[--t]=0,new f(i)}(e,this.n.bitLength()+7>>3);if(null==t)return null;var i=this.doPublic(t);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ee.prototype.encryptOAEP=function(e,t,i){var n=function(e,t,i,n){var r=A.crypto.MessageDigest,s=A.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(e){return ce(s.hashHex(le(e),o))}),e.length+2*n+2>t)throw"Message too long for RSA";var a,u="";for(a=0;a<t-e.length-2*n-2;a+=1)u+="\0";var c=i("")+u+""+e,l=new Array(n);(new K).nextBytes(l);var h=$(l,c.length,i),d=[];for(a=0;a<c.length;a+=1)d[a]=c.charCodeAt(a)^h.charCodeAt(a);var p=$(d,l.length,i),M=[0];for(a=0;a<l.length;a+=1)M[a+1]=l[a]^p.charCodeAt(a);return new f(M.concat(d))}(e,this.n.bitLength()+7>>3,t,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ee.prototype.type="RSA",ee.prototype.doPrivate=function(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),i=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(i)<0;)t=t.add(this.p);return t.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ee.prototype.setPrivate=function(e,t,i){if(this.isPrivate=!0,"string"!=typeof e)this.n=e,this.e=t,this.d=i;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA private key";this.n=J(e,16),this.e=parseInt(t,16),this.d=J(i,16)}},ee.prototype.setPrivateEx=function(e,t,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==e)throw"RSASetPrivateEx N == null";if(null==t)throw"RSASetPrivateEx E == null";if(0==e.length)throw"RSASetPrivateEx N.length == 0";if(0==t.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=J(e,16),this.e=parseInt(t,16),this.d=J(i,16),this.p=J(n,16),this.q=J(r,16),this.dmp1=J(s,16),this.dmq1=J(o,16),this.coeff=J(a,16)},ee.prototype.generate=function(e,t){var i=new K,n=e>>1;this.e=parseInt(t,16);for(var r=new f(t,16);;){for(;this.p=new f(e-n,1,i),0!=this.p.subtract(f.ONE).gcd(r).compareTo(f.ONE)||!this.p.isProbablePrime(10););for(;this.q=new f(n,1,i),0!=this.q.subtract(f.ONE).gcd(r).compareTo(f.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(f.ONE),a=this.q.subtract(f.ONE),u=o.multiply(a);if(0==u.gcd(r).compareTo(f.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==e)){this.d=r.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},ee.prototype.decrypt=function(e){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var t=J(e,16),i=this.doPrivate(t);return null==i?null:
366
366
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
367
- function(e,t){for(var i=e.toByteArray(),n=0;n<i.length&&0==i[n];)++n;if(i.length-n!=t-1||2!=i[n])return null;for(++n;0!=i[n];)if(++n>=i.length)return null;for(var r="";++n<i.length;){var s=255&i[n];s<128?r+=String.fromCharCode(s):s>191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ee.prototype.decryptOAEP=function(e,t,i){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=J(e,16),r=this.doPrivate(n);return null==r?null:function(e,t,i,n){var r=A.crypto.MessageDigest,s=A.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(e){return ce(s.hashHex(le(e),o))}),e=e.toByteArray(),a=0;a<e.length;a+=1)e[a]&=255;for(;e.length<t;)e.unshift(0);if((e=String.fromCharCode.apply(String,e)).length<2*n+2)throw"Cipher too short";var a,u=e.substr(1,n),c=e.substr(n+1),l=te(c,n,i),h=[];for(a=0;a<u.length;a+=1)h[a]=u.charCodeAt(a)^l.charCodeAt(a);var d=te(String.fromCharCode.apply(String,h),e.length-n,i),p=[];for(a=0;a<c.length;a+=1)p[a]=c.charCodeAt(a)^d.charCodeAt(a);if((p=String.fromCharCode.apply(String,p)).substr(0,n)!==i(""))throw"Hash mismatch";var M=(p=p.substr(n)).indexOf("");if((-1!=M?p.substr(0,M).lastIndexOf("\0"):-1)+1!=M)throw"Malformed data";return p.substr(M+1)}(r,this.n.bitLength()+7>>3,t,i)},void 0!==A.lang&&A.lang||(A.lang={}),A.lang.String=function(){},A.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},A.lang.String.isHex=function(e){return fe(e)},A.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},A.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=re(e),A.lang.String.isBase64(e))},A.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},A.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},A.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},A.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var ye=function(e,t,i){return null==i&&(i="0"),e.length>=t?e:new Array(t-e.length+1).join(i)+e};function ve(e,t){var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==A.crypto&&A.crypto||(A.crypto={}),A.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:M.algo.MD5,sha1:M.algo.SHA1,sha224:M.algo.SHA224,sha256:M.algo.SHA256,sha384:M.algo.SHA384,sha512:M.algo.SHA512,ripemd160:M.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,i){var n=this.getDigestInfoHex(e,t),r=i/4;if(n.length+22>r)throw"key is too short for SigAlg: keylen="+i+","+t;for(var s="0001",o="00"+n,a="",u=r-s.length-o.length,c=0;c<u;c+=2)a+="ff";return s+a+o},this.hashString=function(e,t){return new A.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new A.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof ee||e instanceof A.crypto.DSA||e instanceof A.crypto.ECDSA}},A.crypto.Util.md5=function(e){return new A.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},A.crypto.Util.ripemd160=function(e){return new A.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},A.crypto.Util.SECURERANDOMGEN=new K,A.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return A.crypto.Util.SECURERANDOMGEN.nextBytes(t),ie(t)},A.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new f(A.crypto.Util.getRandomHexOfNbytes(e),16)},A.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,i=new Array((e-t)/8+1);return A.crypto.Util.SECURERANDOMGEN.nextBytes(i),i[0]=(255<<t&255^255)&i[0],ie(i)},A.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new f(A.crypto.Util.getRandomHexOfNbits(e),16)},A.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var i=A.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(i))return i}},A.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var i=e.compareTo(t);if(1==i)throw"biMin is greater than biMax";if(0==i)return e;var n=t.subtract(e);return A.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},A.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=A.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=A.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=M.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(M.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},A.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},A.crypto.MessageDigest.getHashLength=function(e){var t=A.crypto.MessageDigest,i=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[i])throw"not supported algorithm: "+e;return t.HASHLENGTH[i]},A.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},A.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=A.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var i=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)&&"cryptojs"==t){try{var n=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i];this.mac=M.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+i+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=M.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(M.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=le(e)),void(this.pass=M.enc.Hex.parse(t))}if("object"!=typeof e)throw"KJUR.crypto.Mac unsupported password type: "+e;t=null;if(void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=ae(e.utf8)),void 0!==e.rstr&&(t=le(e.rstr)),void 0!==e.b64&&(t=_(e.b64)),void 0!==e.b64u&&(t=oe(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=M.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},A.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new A.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var i=null;try{i=void 0===t?Ie.getKey(e):Ie.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===i.isPrivate)this.prvKey=i,this.state="SIGN";else{if(!0!==i.isPublic)throw"init failed.:"+i;this.pubKey=i,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==A.crypto.ECDSA&&(this.prvKey=new A.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof ee&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof ee&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof A.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof A.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==A.crypto.ECDSA&&(this.pubKey=new A.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof ee&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof ee&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==A.crypto.ECDSA&&this.pubKey instanceof A.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==A.crypto.DSA&&this.pubKey instanceof A.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=Ie.getKey(e.prvkeypem);this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},A.crypto.Cipher=function(e){},A.crypto.Cipher.encrypt=function(e,t,i){if(t instanceof ee&&t.isPublic){var n=A.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.encryptOAEP(e,"sha"+r[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.encrypt: unsupported key or algorithm"},A.crypto.Cipher.decrypt=function(e,t,i){if(t instanceof ee&&t.isPrivate){var n=A.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.decryptOAEP(e,"sha"+r[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.decrypt: unsupported key or algorithm"},A.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof ee){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},A.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 me,Ne,De,we,Te,xe,Ee,je,Ie=(me=function(e,t,i){return Ne(M.AES,e,t,i)},Ne=function(e,t,i,n){var r=M.enc.Hex.parse(t),s=M.enc.Hex.parse(i),o=M.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var u=e.decrypt(a,s,{iv:o});return M.enc.Hex.stringify(u)},De=function(e,t,i){return we(M.AES,e,t,i)},we=function(e,t,i,n){var r=M.enc.Hex.parse(t),s=M.enc.Hex.parse(i),o=M.enc.Hex.parse(n),a=e.encrypt(r,s,{iv:o}),u=M.enc.Hex.parse(a.toString());return M.enc.Base64.stringify(u)},Te={"AES-256-CBC":{proc:me,eproc:De,keylen:32,ivlen:16},"AES-192-CBC":{proc:me,eproc:De,keylen:24,ivlen:16},"AES-128-CBC":{proc:me,eproc:De,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,t,i){return Ne(M.TripleDES,e,t,i)},eproc:function(e,t,i){return we(M.TripleDES,e,t,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,t,i){return Ne(M.DES,e,t,i)},eproc:function(e,t,i){return we(M.DES,e,t,i)},keylen:8,ivlen:8}},xe=function(e){var t={},i=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(t.cipher=i[1],t.ivsalt=i[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var r=-1,s=0;-1!=e.indexOf("\r\n\r\n")&&(r=e.indexOf("\r\n\r\n"),s=2),-1!=e.indexOf("\n\n")&&(r=e.indexOf("\n\n"),s=1);var o=e.indexOf("-----END");if(-1!=r&&-1!=o){var a=e.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),t.data=a}return t},Ee=function(e,t,i){for(var n=i.substring(0,16),r=M.enc.Hex.parse(n),s=M.enc.Utf8.parse(t),o=Te[e].keylen+Te[e].ivlen,a="",u=null;;){var c=M.algo.MD5.create();if(null!=u&&c.update(u),c.update(s),c.update(r),u=c.finalize(),(a+=M.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=a.substr(0,2*Te[e].keylen),l.ivhex=a.substr(2*Te[e].keylen,2*Te[e].ivlen),l},je=function(e,t,i,n){var r=M.enc.Base64.parse(e),s=M.enc.Hex.stringify(r);return(0,Te[t].proc)(s,i,n)},{version:"1.0.0",parsePKCS5PEM:function(e){return xe(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,i){return Ee(e,t,i)},decryptKeyB64:function(e,t,i,n){return je(e,t,i,n)},getDecryptedKeyHex:function(e,t){var i=xe(e);i.type;var n=i.cipher,r=i.ivsalt,s=i.data,o=Ee(n,t,r).keyhex;return je(s,n,o,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,i,n,r){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===Te[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==r&&null!=r||(r=function(e){var t=M.lib.WordArray.random(e);return M.enc.Hex.stringify(t)}(Te[n].ivlen).toUpperCase());var o=function(e,t,i,n){return(0,Te[t].eproc)(e,i,n)}(t,n,Ee(n,i,r).keyhex,r);return s="-----BEGIN "+e+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+r+"\r\n",s+="\r\n",s+=o.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={},s=i(e,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(e,s[1]);var o=i(e,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(e,o[0]))throw"this only supports pkcs5PBES2";var a=i(e,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=i(e,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(e,u[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(e,u[1]);var c=i(e,a[0]);if(2!=c.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length;if("2a864886f70d01050c"!=n(e,c[0]))throw"this only supports pkcs5PBKDF2";var l=i(e,c[1]);if(l.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length;r.pbkdf2Salt=n(e,l[0]);var h=n(e,l[1]);try{r.pbkdf2Iter=parseInt(h,16)}catch(e){throw"malformed format pbkdf2Iter: "+h}return r},getPBKDF2KeyHexFromParam:function(e,t){var i=M.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,r=M.PBKDF2(t,i,{keySize:6,iterations:n});return M.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var i=Ae(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ie.getPBKDF2KeyHexFromParam(n,t),s={};s.ciphertext=M.enc.Hex.parse(n.ciphertext);var o=M.enc.Hex.parse(r),a=M.enc.Hex.parse(n.encryptionSchemeIV),u=M.TripleDES.decrypt(s,o,{iv:a});return M.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(e,t){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=i(e,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=i(e,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(r.algoid=n(e,o[0]),"06"==e.substr(o[1],2)&&(r.algparam=n(e,o[1])),"04"!=e.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return r.keyidx=t.getVidx(e,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=Ae(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,i=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==i.algoid)t=new ee;else if("2a8648ce380401"==i.algoid)t=new A.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";t=new A.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,i=ze.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===i)t=new ee;else if("2a8648ce380401"===i)t=new A.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";t=new A.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={};if("30"!=e.substr(0,2))throw"malformed RSA key(code:001)";var s=i(e,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=e.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(e,s[0]),"02"!=e.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(e,s[1]),r},parsePublicPKCS8Hex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={algparam:null},s=i(e,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=e.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(e,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=e.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?r.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(r.algparam={},r.algparam.p=t.getVbyList(e,a[1],[0],"02"),r.algparam.q=t.getVbyList(e,a[1],[1],"02"),r.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(e,s[1]).substr(2),r}});Ie.getKey=function(e,t,i){var n=(y=ze).getChildIdx;y.getV;var r=y.getVbyList,s=A.crypto,o=s.ECDSA,a=s.DSA,u=ee,c=Ae,l=Ie;if(void 0!==u&&e instanceof u)return e;if(void 0!==o&&e instanceof o)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new o({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new o({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(z=new u).setPublic(e.n,e.e),z;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(z=new u).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),z;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(z=new u).setPrivate(e.n,e.e,e.d),z;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(z=new a).setPublic(e.p,e.q,e.g,e.y),z;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(z=new a).setPrivate(e.p,e.q,e.g,e.y,e.x),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(z=new u).setPublic(oe(e.n),oe(e.e)),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(z=new u).setPrivateEx(oe(e.n),oe(e.e),oe(e.d),oe(e.p),oe(e.q),oe(e.dp),oe(e.dq),oe(e.qi)),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(z=new u).setPrivate(oe(e.n),oe(e.e),oe(e.d)),z;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var h=(I=new o({curve:e.crv})).ecparams.keylen/4,d="04"+("0000000000"+oe(e.x)).slice(-h)+("0000000000"+oe(e.y)).slice(-h);return I.setPublicKeyHex(d),I}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){h=(I=new o({curve:e.crv})).ecparams.keylen/4,d="04"+("0000000000"+oe(e.x)).slice(-h)+("0000000000"+oe(e.y)).slice(-h);var p=("0000000000"+oe(e.d)).slice(-h);return I.setPublicKeyHex(d),I.setPrivateKeyHex(p),I}if("pkcs5prv"===i){var M,g=e,y=ze;if(9===(M=n(g,0)).length)(z=new u).readPKCS5PrvKeyHex(g);else if(6===M.length)(z=new a).readPKCS5PrvKeyHex(g);else{if(!(M.length>2&&"04"===g.substr(M[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(z=new o).readPKCS5PrvKeyHex(g)}return z}if("pkcs8prv"===i)return z=l.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===i)return l._getKeyFromPublicPKCS8Hex(e);if("x509pub"===i)return Oe.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return Oe.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var v=Ae(e,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(v)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var m=c(e,"RSA PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var N=r(S=c(e,"DSA PRIVATE KEY"),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(z=new a).setPrivate(new f(N,16),new f(D,16),new f(w,16),new f(T,16),new f(x,16)),z}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){m=c(e,"EC PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=e.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var E=l.getDecryptedKeyHex(e,t),j=new ee;return j.readPKCS5PrvKeyHex(E),j}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var I,z=r(S=l.getDecryptedKeyHex(e,t),0,[1],"04"),b=r(S,0,[2,0],"06"),L=r(S,0,[3,0],"03").substr(2);if(void 0===A.crypto.OID.oidhex2name[b])throw"undefined OID(hex) in KJUR.crypto.OID: "+b;return(I=new o({curve:A.crypto.OID.oidhex2name[b]})).setPublicKeyHex(L),I.setPrivateKeyHex(z),I.isPublic=!1,I}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var S;N=r(S=l.getDecryptedKeyHex(e,t),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(z=new a).setPrivate(new f(N,16),new f(D,16),new f(w,16),new f(T,16),new f(x,16)),z}if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},Ie.generateKeypair=function(e,t){if("RSA"==e){var i=t;(o=new ee).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ee,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==e){var o,a,u=t,c=new A.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new A.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),o.setPrivateKeyHex(c.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new A.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+e},Ie.getPEM=function(e,t,i,n,r,s){var o=A,a=o.asn1,u=a.DERObjectIdentifier,c=a.DERInteger,l=a.ASN1Util.newObject,h=a.x509.SubjectPublicKeyInfo,d=o.crypto,p=d.DSA,f=d.ECDSA,g=ee;function y(e){return l({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function v(e){return l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function m(e){return l({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==p&&e instanceof p||void 0!==f&&e instanceof f)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return de(T=new h(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===i||null==i)&&1==e.isPrivate)return de(T=y(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===i||null==i)&&1==e.isPrivate){var N=new u({name:e.curveName}).getEncodedHex(),D=v(e).getEncodedHex(),w="";return w+=de(N,"EC PARAMETERS"),w+=de(D,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==p&&e instanceof p&&(void 0===i||null==i)&&1==e.isPrivate)return de(T=m(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==i&&null!=i&&1==e.isPrivate){var T=y(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",T,i,n,s)}if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==i&&null!=i&&1==e.isPrivate){T=v(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",T,i,n,s)}if("PKCS5PRV"==t&&void 0!==p&&e instanceof p&&void 0!==i&&null!=i&&1==e.isPrivate){T=m(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",T,i,n,s)}var x=function(e,t){var i=E(e,t);return new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},E=function(e,t){var i=M.lib.WordArray.random(8),n=M.lib.WordArray.random(8),r=M.PBKDF2(t,i,{keySize:6,iterations:100}),s=M.enc.Hex.parse(e),o=M.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=M.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=M.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var j=y(e).getEncodedHex();T=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate){j=new l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),T=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==p&&e instanceof p&&1==e.isPrivate){j=new c({bigint:e.x}).getEncodedHex(),T=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Ie.getKeyFromCSRPEM=function(e){var t=Ae(e,"CERTIFICATE REQUEST");return Ie.getKeyFromCSRHex(t)},Ie.getKeyFromCSRHex=function(e){var t=Ie.parseCSRHex(e);return Ie.getKey(t.p8pubkeyhex,null,"pkcs8pub")},Ie.parseCSRHex=function(e){var t=ze,i=t.getChildIdx,n=t.getTLV,r={},s=e;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(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=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ie.getKeyID=function(e){var t=Ie,i=ze;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=Ae(t.getPEM(e)),r=i.getIdxbyList(n,0,[1]),s=i.getV(n,r).substring(2);return A.crypto.Util.hashHex(s,"sha1")},Ie.getJWKFromKey=function(e){var t={};if(e instanceof ee&&e.isPrivate)return t.kty="RSA",t.n=se(e.n.toString(16)),t.e=se(e.e.toString(16)),t.d=se(e.d.toString(16)),t.p=se(e.p.toString(16)),t.q=se(e.q.toString(16)),t.dp=se(e.dmp1.toString(16)),t.dq=se(e.dmq1.toString(16)),t.qi=se(e.coeff.toString(16)),t;if(e instanceof ee&&e.isPublic)return t.kty="RSA",t.n=se(e.n.toString(16)),t.e=se(e.e.toString(16)),t;if(e instanceof A.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=se(i.x),t.y=se(i.y),t.d=se(e.prvKeyHex),t}if(e instanceof A.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=se(i.x),t.y=se(i.y),t}throw"not supported key object"},void 0!==A.asn1&&A.asn1||(A.asn1={}),A.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var i=t.substr(1).length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r<i;r++)n+="f";t=new f(n,16).xor(e).add(f.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return de(e,t)},this.newObject=function(e){var t=A.asn1,i=t.ASN1Object,n=t.DERBoolean,r=t.DERInteger,s=t.DERBitString,o=t.DEROctetString,a=t.DERNull,u=t.DERObjectIdentifier,c=t.DEREnumerated,l=t.DERUTF8String,h=t.DERNumericString,d=t.DERPrintableString,p=t.DERTeletexString,M=t.DERIA5String,f=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERVisibleString,v=t.DERBMPString,m=t.DERSequence,N=t.DERSet,D=t.DERTaggedObject,w=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var T=Object.keys(e);if(1!=T.length)throw new Error("key of param shall be only one.");var x=T[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+x+":"))throw new Error("undefined key: "+x);if("bool"==x)return new n(e[x]);if("int"==x)return new r(e[x]);if("bitstr"==x)return new s(e[x]);if("octstr"==x)return new o(e[x]);if("null"==x)return new a(e[x]);if("oid"==x)return new u(e[x]);if("enum"==x)return new c(e[x]);if("utf8str"==x)return new l(e[x]);if("numstr"==x)return new h(e[x]);if("prnstr"==x)return new d(e[x]);if("telstr"==x)return new p(e[x]);if("ia5str"==x)return new M(e[x]);if("utctime"==x)return new f(e[x]);if("gentime"==x)return new g(e[x]);if("visstr"==x)return new y(e[x]);if("bmpstr"==x)return new v(e[x]);if("asn1"==x)return new i(e[x]);if("seq"==x){for(var E=e[x],j=[],I=0;I<E.length;I++){var z=w(E[I]);j.push(z)}return new m({array:j})}if("set"==x){for(E=e[x],j=[],I=0;I<E.length;I++){z=w(E[I]);j.push(z)}return new N({array:j})}if("tag"==x){var b=e[x];if("[object Array]"===Object.prototype.toString.call(b)&&3==b.length){var L=w(b[2]);return new D({tag:b[0],explicit:b[1],obj:L})}return new D(b)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},A.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",i=parseInt(e.substr(0,2),16),n=(t=Math.floor(i/40)+"."+i%40,""),r=2;r<e.length;r+=2){var s=("00000000"+parseInt(e.substr(r,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))t=t+"."+new f(n,2).toString(10),n=""}return t},A.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=new f(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var s="",o=0;o<r;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),i+=t(parseInt(a,2))}return i};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",r=e.split("."),s=40*parseInt(r[0])+parseInt(r[1]);n+=t(s),r.splice(0,2);for(var o=0;o<r.length;o++)n+=i(r[o]);return n},A.asn1.ASN1Object=function(e){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 e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var i=t.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+i).toString(16)+t},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(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},A.asn1.DERAbstractString=function(e){A.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ae(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},p.lang.extend(A.asn1.DERAbstractString,A.asn1.ASN1Object),A.asn1.DERAbstractTime=function(e){A.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,i){var n=this.zeroPadding,r=this.localDateToUTC(e),s=String(r.getFullYear());"utc"==t&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ne(e)},this.setByDateValue=function(e,t,i,n,r,s){var o=new Date(Date.UTC(e,t-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(A.asn1.DERAbstractTime,A.asn1.ASN1Object),A.asn1.DERAbstractStructured=function(e){A.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},p.lang.extend(A.asn1.DERAbstractStructured,A.asn1.ASN1Object),A.asn1.DERBoolean=function(e){A.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},p.lang.extend(A.asn1.DERBoolean,A.asn1.ASN1Object),A.asn1.DERInteger=function(e){A.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=A.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new f(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},p.lang.extend(A.asn1.DERInteger,A.asn1.ASN1Object),A.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}A.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var i="0"+e;this.hTLV=null,this.isModified=!0,this.hV=i+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var i=0;i<=t;i++)e+="0";var n="";for(i=0;i<e.length-1;i+=8){var r=e.substr(i,8),s=parseInt(r,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",i=0;i<e.length;i++)1==e[i]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},p.lang.extend(A.asn1.DERBitString,A.asn1.ASN1Object),A.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}A.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},p.lang.extend(A.asn1.DEROctetString,A.asn1.DERAbstractString),A.asn1.DERNull=function(){A.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(A.asn1.DERNull,A.asn1.ASN1Object),A.asn1.DERObjectIdentifier=function(e){A.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=parseInt(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var s="",o=0;o<r;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),i+=t(parseInt(a,2))}return i};try{if(!e.match(/^[0-9.]+$/))return null;var n="",r=e.split("."),s=40*parseInt(r[0],10)+parseInt(r[1],10);n+=t(s),r.splice(0,2);for(var o=0;o<r.length;o++)n+=i(r[o]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=A.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},p.lang.extend(A.asn1.DERObjectIdentifier,A.asn1.ASN1Object),A.asn1.DEREnumerated=function(e){A.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=A.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new f(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},p.lang.extend(A.asn1.DEREnumerated,A.asn1.ASN1Object),A.asn1.DERUTF8String=function(e){A.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},p.lang.extend(A.asn1.DERUTF8String,A.asn1.DERAbstractString),A.asn1.DERNumericString=function(e){A.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},p.lang.extend(A.asn1.DERNumericString,A.asn1.DERAbstractString),A.asn1.DERPrintableString=function(e){A.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},p.lang.extend(A.asn1.DERPrintableString,A.asn1.DERAbstractString),A.asn1.DERTeletexString=function(e){A.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},p.lang.extend(A.asn1.DERTeletexString,A.asn1.DERAbstractString),A.asn1.DERIA5String=function(e){A.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},p.lang.extend(A.asn1.DERIA5String,A.asn1.DERAbstractString),A.asn1.DERVisibleString=function(e){A.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},p.lang.extend(A.asn1.DERVisibleString,A.asn1.DERAbstractString),A.asn1.DERBMPString=function(e){A.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},p.lang.extend(A.asn1.DERBMPString,A.asn1.DERAbstractString),A.asn1.DERUTCTime=function(e){A.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=ne(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=ne(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},p.lang.extend(A.asn1.DERUTCTime,A.asn1.DERAbstractTime),A.asn1.DERGeneralizedTime=function(e){A.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ne(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=ne(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},p.lang.extend(A.asn1.DERGeneralizedTime,A.asn1.DERAbstractTime),A.asn1.DERSequence=function(e){A.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},p.lang.extend(A.asn1.DERSequence,A.asn1.DERAbstractStructured),A.asn1.DERSet=function(e){A.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var i=this.asn1Array[t];e.push(i.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},p.lang.extend(A.asn1.DERSet,A.asn1.DERAbstractStructured),A.asn1.DERTaggedObject=function(e){A.asn1.DERTaggedObject.superclass.constructor.call(this);var t=A.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,i){this.hT=t,this.isExplicit=e,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof e.obj&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},p.lang.extend(A.asn1.DERTaggedObject,A.asn1.ASN1Object);var ze=new function(){};function be(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e}function Le(e,t,i){for(var n="",r=0;n.length<t;)n+=ce(i(le(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Se(e){for(var t in A.crypto.Util.DIGESTINFOHEAD){var i=A.crypto.Util.DIGESTINFOHEAD[t],n=i.length;if(e.substring(0,n)==i)return[t,e.substring(n)]}return[]}function Oe(e){var t,i=ze,n=i.getChildIdx,r=i.getV,s=i.getTLV,o=i.getVbyList,a=i.getVbyListEx,u=i.getTLVbyList,c=i.getTLVbyListEx,l=i.getIdxbyList,h=i.getIdxbyListEx,d=i.getVidx,p=i.getInt,M=i.oidname,f=i.hextooidstr,g=Ae;try{t=A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}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 e=u(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=u(e,0,[0]),i=p(t,0);if(i<0||2<i)throw new Error("malformed version field");return this.version=i+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 e=c(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var i in t)if(e===t[i])return i;return M(a(e,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 e=o(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getNotAfter=function(){var e=o(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getPublicKeyHex=function(){return i.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return l(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return Ie.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),i=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),r=new A.crypto.Signature({alg:t});return r.init(e),r.updateHex(n),r.verify(i)},this.parseExt=function(e){var t,s,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=l(a,0,[0,7,0],"30"),s=n(a,t)}else{a=Ae(e);var u=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=r(a,u))return void(this.aExtInfo=new Array);t=l(a,0,[0,3,0,1,0],"30"),s=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var c=0;c<s.length;c++){var h={critical:!1},A=0;3===n(a,s[c]).length&&(h.critical=!0,A=1),h.oid=i.hextooidstr(o(a,s[c],[0],"06"));var p=l(a,s[c],[1+A]);h.vidx=d(a,p),this.aExtInfo.push(h)}},this.getExtInfo=function(e){var t=this.aExtInfo,i=e;if(e.match(/^[0-9.]+$/)||(i=A.asn1.x509.OID.name2oid(e)),""!==i)for(var n=0;n<t.length;n++)if(t[n].oid===i)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("basicConstraints");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var o=r(e,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("keyUsage");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=s(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var i="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(i=i.slice(-8)),10==e.length&&(i=i.slice(-16)),""==(i=i.replace(/0+$/,""))&&(i="0"),i},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),i=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&i.push(Oe.KEYUSAGE_NAME[n]);return i.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectKeyIdentifier");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var o=r(e,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityKeyIdentifier");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var o={extname:"authorityKeyIdentifier"};t&&(o.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++){var c=e.substr(a[u],2);if("80"===c&&(o.kid={hex:r(e,a[u])}),"a1"===c){var l=s(e,a[u]),h=this.getGeneralNames(l);o.issuer=h[0].dn}"82"===c&&(o.sn={hex:r(e,a[u])})}return o},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("extKeyUsage");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var o={extname:"extKeyUsage",array:[]};t&&(o.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++)o.array.push(M(r(e,a[u])));return o},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,i=s(this.hex,e.vidx);if(""===i)return t;for(var o=n(i,0),a=0;a<o.length;a++)t.push(M(r(i,o[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectAltName");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("issuerAltName");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),i=[],r=0;r<t.length;r++){var o=this.getGeneralName(s(e,t[r]));void 0!==o&&i.push(o)}return i},this.getGeneralName=function(e){var t=e.substr(0,2),i=r(e,0),n=ce(i);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:pe(i)}:"a4"==t?{dn:this.getX500Name(i)}:void 0},this.getExtSubjectAltName2=function(){var e,t,i,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),c=n(u,0),l=0;l<c.length;l++)i=u.substr(c[l],2),e=r(u,c[l]),"81"===i&&(t=ue(e),a.push(["MAIL",t])),"82"===i&&(t=ue(e),a.push(["DNS",t])),"84"===i&&(t=Oe.hex2dn(e,0),a.push(["DN",t])),"86"===i&&(t=ue(e),a.push(["URI",t])),"87"===i&&(t=pe(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("cRLDistributionPoints");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"cRLDistributionPoints",array:[]};t&&(r.critical=!0);for(var o=n(e,0),a=0;a<o.length;a++){var u=s(e,o[a]);r.array.push(this.getDistributionPoint(u))}return r},this.getDistributionPoint=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=e.substr(i[r],2),a=s(e,i[r]);"a0"==o&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=e.substr(i[r],2),a=s(e,i[r]);"a0"==o&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,i=n(this.hex,e.vidx),r=0;r<i.length;r++)try{var s=ue(o(this.hex,i[r],[0,0,0],"86"));t.push(s)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},i=n(this.hex,e.vidx),r=0;r<i.length;r++){var s=o(this.hex,i[r],[0],"06"),a=o(this.hex,i[r],[1],"86");"2b06010505073001"===s&&t.ocsp.push(ue(a)),"2b06010505073002"===s&&t.caissuer.push(ue(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityInfoAccess");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"authorityInfoAccess",array:[]};t&&(r.critical=!0);for(var u=n(e,0),c=0;c<u.length;c++){var l=a(e,u[c],[0],"06"),h=ue(o(e,u[c],[1],"86"));if("2b06010505073001"==l)r.array.push({ocsp:h});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);r.array.push({caissuer:h})}}return r},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("certificatePolicies");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"certificatePolicies",array:[]};t&&(r.critical=!0);for(var o=n(e,0),a=0;a<o.length;a++){var u=s(e,o[a]),c=this.getPolicyInformation(u);r.array.push(c)}return r},this.getPolicyInformation=function(e){var t={},i=o(e,0,[0],"06");t.policyoid=M(i);var r=h(e,0,[1],"30");if(-1!=r){t.array=[];for(var a=n(e,r),u=0;u<a.length;u++){var c=s(e,a[u]),l=this.getPolicyQualifierInfo(c);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},i=o(e,0,[0],"06");if("2b06010505070201"===i){var n=a(e,0,[1],"16");t.cps=ce(n)}else if("2b06010505070202"===i){var r=u(e,0,[1],"30");t.unotice=this.getUserNotice(r)}return t},this.getUserNotice=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=s(e,i[r]);"30"!=o.substr(0,2)&&(t.exptext=this.getDisplayText(o))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=ce(r(e,0)),t},this.getExtCRLNumber=function(e,t){var i={extname:"cRLNumber"};if(t&&(i.critical=!0),"02"==e.substr(0,2))return i.num={hex:r(e,0)},i;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var i={extname:"cRLReason"};if(t&&(i.critical=!0),"0a"==e.substr(0,2))return i.code=parseInt(r(e,0),16),i;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var i={extname:"ocspNonce"};t&&(i.critical=!0);var n=r(e,0);return i.hex=n,i},this.getExtOcspNoCheck=function(e,t){var i={extname:"ocspNoCheck"};return t&&(i.critical=!0),i},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("adobeTimeStamp");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"adobeTimeStamp"};t&&(r.critical=!0);var o=n(e,0);if(o.length>1){var a=s(e,o[1]),u=this.getGeneralName(a);null!=u.uri&&(r.uri=u.uri)}if(o.length>2){var c=s(e,o[2]);"0101ff"==c&&(r.reqauth=!0),"010100"==c&&(r.reqauth=!1)}return r},this.getX500NameRule=function(e){for(var t=null,i=[],n=0;n<e.length;n++)for(var r=e[n],s=0;s<r.length;s++)i.push(r[s]);for(n=0;n<i.length;n++){var o=i[n],a=o.ds,u=o.value,c=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=c)return"mixed";if(A.lang.String.isMail(u))continue;return"mixed"}if("C"==c){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getRDN(s(e,i[r])));return t},this.getRDN=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getAttrTypeAndValue(s(e,i[r])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},i=n(e,0),r=o(e,i[0],[],"06"),s=o(e,i[1],[]),a=A.asn1.ASN1Util.oidHexToInt(r);return t.type=A.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(i[1],2)],"bmp"!=t.ds?t.value=ue(s):t.value=Me(s),t},this.readCertPEM=function(e){this.readCertHex(g(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=de(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&(-1!=h(this.hex,0,[0,"[3]"])&&(e=c(this.hex,0,[0,"[3]",0],"30")));for(var t=[],i=n(e,0),r=0;r<i.length;r++){var o=s(e,i[r]),a=this.getExtParam(o);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var i=f(o(e,0,[0],"06")),r=!1;3==t&&"0101ff"==u(e,0,[1])&&(r=!0);var s=u(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==i?a=this.getExtSubjectKeyIdentifier(s,r):"2.5.29.15"==i?a=this.getExtKeyUsage(s,r):"2.5.29.17"==i?a=this.getExtSubjectAltName(s,r):"2.5.29.18"==i?a=this.getExtIssuerAltName(s,r):"2.5.29.19"==i?a=this.getExtBasicConstraints(s,r):"2.5.29.31"==i?a=this.getExtCRLDistributionPoints(s,r):"2.5.29.32"==i?a=this.getExtCertificatePolicies(s,r):"2.5.29.35"==i?a=this.getExtAuthorityKeyIdentifier(s,r):"2.5.29.37"==i?a=this.getExtExtKeyUsage(s,r):"1.3.6.1.5.5.7.1.1"==i?a=this.getExtAuthorityInfoAccess(s,r):"2.5.29.20"==i?a=this.getExtCRLNumber(s,r):"2.5.29.21"==i?a=this.getExtCRLReason(s,r):"1.3.6.1.5.5.7.48.1.2"==i?a=this.getExtOcspNonce(s,r):"1.3.6.1.5.5.7.48.1.5"==i?a=this.getExtOcspNoCheck(s,r):"1.2.840.113583.1.1.9.1"==i&&(a=this.getExtAdobeTimeStamp(s,r)),null!=a)return a;var c={extname:i,extn:s};return r&&(c.critical=!0),c},this.findExt=function(e,t){for(var i=0;i<e.length;i++)if(e[i].extname==t)return e[i];return null},this.updateExtCDPFullURI=function(e,t){var i=this.findExt(e,"cRLDistributionPoints");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)if(null!=n[r].dpname&&null!=n[r].dpname.full)for(var s=n[r].dpname.full,o=0;o<s.length;o++){var a=s[r];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].ocsp&&(n[r].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].caissuer&&(n[r].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map((function(e){return function(e){return e.map((function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")})).join("+")}(e).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var e,t,i,n,r=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];if(t+=" policy oid: "+r.policyoid+"\n",void 0!==r.array)for(var s=0;s<r.array.length;s++){var o=r.array[s];void 0!==o.cps&&(t+=" cps: "+o.cps+"\n")}}return t},s=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];try{void 0!==r.dpname.full[0].uri&&(t+=" "+r.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==r.dname.full[0].dn.hex&&(t+=" "+Oe.hex2dn(r.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},o=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];void 0!==r.caissuer&&(t+=" caissuer: "+r.caissuer+"\n"),void 0!==r.ocsp&&(t+=" ocsp: "+r.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+ge(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+ge(t.e.toString(16))+"\n"),null!=(i=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<i.length;a++){var u=i[a],c=A.asn1.x509.OID.oid2name(u.oid);""===c&&(c=u.oid);var l="";if(!0===u.critical&&(l="CRITICAL"),e+=" "+c+" "+l+":\n","basicConstraints"===c){var h=this.getExtBasicConstraints();void 0===h.cA?e+=" {}\n":(e+=" cA=true",void 0!==h.pathLen&&(e+=", pathLen="+h.pathLen),e+="\n")}else if("keyUsage"===c)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===c)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===c){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(e+=" kid="+d.kid.hex+"\n")}else{if("extKeyUsage"===c)e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===c)e+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===c)e+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===c)e+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===c&&(e+=r(this.getExtCertificatePolicies()))}}}return e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",e+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):A.lang.String.isHex(e)&&this.readCertHex(e))}function Ce(e){return M.SHA256(e).toString()}ze.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var i=parseInt(e.substr(t+3,1));return 0==i?-1:0<i&&i<10?i+1:-2},ze.getL=function(e,t){var i=ze.getLblen(e,t);return i<1?"":e.substr(t+2,2*i)},ze.getVblen=function(e,t){var i;return""==(i=ze.getL(e,t))?-1:("8"===i.substr(0,1)?new f(i.substr(2),16):new f(i,16)).intValue()},ze.getVidx=function(e,t){var i=ze.getLblen(e,t);return i<0?i:t+2*(i+1)},ze.getV=function(e,t){var i=ze.getVidx(e,t),n=ze.getVblen(e,t);return e.substr(i,2*n)},ze.getTLV=function(e,t){return e.substr(t,2)+ze.getL(e,t)+ze.getV(e,t)},ze.getTLVblen=function(e,t){return 2+2*ze.getLblen(e,t)+2*ze.getVblen(e,t)},ze.getNextSiblingIdx=function(e,t){return ze.getVidx(e,t)+2*ze.getVblen(e,t)},ze.getChildIdx=function(e,t){var i,n,r,s=ze,o=[];i=s.getVidx(e,t),n=2*s.getVblen(e,t),"03"==e.substr(t,2)&&(i+=2,n-=2),r=0;for(var a=i;r<=n;){var u=s.getTLVblen(e,a);if((r+=u)<=n&&o.push(a),a+=u,r>=n)break}return o},ze.getNthChildIdx=function(e,t,i){return ze.getChildIdx(e,t)[i]},ze.getIdxbyList=function(e,t,i,n){var r,s,o=ze;return 0==i.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(r=i.shift())>=(s=o.getChildIdx(e,t)).length?-1:o.getIdxbyList(e,s[r],i,n)},ze.getIdxbyListEx=function(e,t,i,n){var r,s,o=ze;if(0==i.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;r=i.shift(),s=o.getChildIdx(e,t);for(var a=0,u=0;u<s.length;u++){var c=e.substr(s[u],2);if("number"==typeof r&&!o.isContextTag(c)&&a==r||"string"==typeof r&&o.isContextTag(c,r))return o.getIdxbyListEx(e,s[u],i,n);o.isContextTag(c)||a++}return-1},ze.getTLVbyList=function(e,t,i,n){var r=ze,s=r.getIdxbyList(e,t,i,n);return-1==s||s>=e.length?null:r.getTLV(e,s)},ze.getTLVbyListEx=function(e,t,i,n){var r=ze,s=r.getIdxbyListEx(e,t,i,n);return-1==s?null:r.getTLV(e,s)},ze.getVbyList=function(e,t,i,n,r){var s,o,a=ze;return-1==(s=a.getIdxbyList(e,t,i,n))||s>=e.length?null:(o=a.getV(e,s),!0===r&&(o=o.substr(2)),o)},ze.getVbyListEx=function(e,t,i,n,r){var s,o,a=ze;return-1==(s=a.getIdxbyListEx(e,t,i,n))?null:(o=a.getV(e,s),"03"==e.substr(s,2)&&!1!==r&&(o=o.substr(2)),o)},ze.getInt=function(e,t,i){null==i&&(i=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return i;var r=ze.getV(e,t);return"02"==n?parseInt(r,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var i=parseInt(t,16),n=e.substr(2),r=parseInt(n,16).toString(2);return"0"==r&&(r="00000000"),r=r.slice(0,0-i),parseInt(r,2)}catch(e){return-1}}(r)}catch(e){return i}},ze.getOID=function(e,t,i){null==i&&(i=null);try{return"06"!=e.substr(t,2)?i:function(e){if(!fe(e))return null;try{var t=[],i=e.substr(0,2),n=parseInt(i,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var r=e.substr(2),s=[],o=0;o<r.length/2;o++)s.push(parseInt(r.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=ye((127&s[o]).toString(2),7):(u+=ye((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var c=t.join(".");return a.length>0&&(c=c+"."+a.join(".")),c}catch(e){return null}}(ze.getV(e,t))}catch(e){return i}},ze.getOIDName=function(e,t,i){null==i&&(i=null);try{var n=ze.getOID(e,t,i);if(n==i)return i;var r=A.asn1.x509.OID.oid2name(n);return""==r?n:r}catch(e){return i}},ze.getString=function(e,t,i){null==i&&(i=null);try{return ce(ze.getV(e,t))}catch(e){return i}},ze.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},i=[],n=e.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=e.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],c="";for(a=0;a<o.length;a++)128&o[a]?c+=t((127&o[a]).toString(2),7):(c+=t((127&o[a]).toString(2),7),u.push(new String(parseInt(c,2))),c="");var l=i.join(".");return u.length>0&&(l=l+"."+u.join(".")),l},ze.dump=function(e,t,i,n){var r=ze,s=r.getV,o=r.dump,a=r.getChildIdx,u=e;e instanceof A.asn1.ASN1Object&&(u=e.getEncodedHex());var c=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var l,h=t.ommit_long_octet;if("01"==(l=u.substr(i,2)))return"00"==(d=s(u,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==l)return n+"INTEGER "+c(d=s(u,i),h)+"\n";if("03"==l){var d=s(u,i);if(r.isASN1HEX(d.substr(2))){var p=n+"BITSTRING, encapsulates\n";return p+=o(d.substr(2),t,0,n+" ")}return n+"BITSTRING "+c(d,h)+"\n"}if("04"==l){d=s(u,i);if(r.isASN1HEX(d)){p=n+"OCTETSTRING, encapsulates\n";return p+=o(d,t,0,n+" ")}return n+"OCTETSTRING "+c(d,h)+"\n"}if("05"==l)return n+"NULL\n";if("06"==l){var M=s(u,i),f=A.asn1.ASN1Util.oidHexToInt(M),g=A.asn1.x509.OID.oid2name(f),y=f.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==l)return n+"ENUMERATED "+parseInt(s(u,i))+"\n";if("0c"==l)return n+"UTF8String '"+ue(s(u,i))+"'\n";if("13"==l)return n+"PrintableString '"+ue(s(u,i))+"'\n";if("14"==l)return n+"TeletexString '"+ue(s(u,i))+"'\n";if("16"==l)return n+"IA5String '"+ue(s(u,i))+"'\n";if("17"==l)return n+"UTCTime "+ue(s(u,i))+"\n";if("18"==l)return n+"GeneralizedTime "+ue(s(u,i))+"\n";if("1a"==l)return n+"VisualString '"+ue(s(u,i))+"'\n";if("1e"==l)return n+"BMPString '"+Me(s(u,i))+"'\n";if("30"==l){if("3000"==u.substr(i,4))return n+"SEQUENCE {}\n";p=n+"SEQUENCE\n";var v=t;if((2==(D=a(u,i)).length||3==D.length)&&"06"==u.substr(D[0],2)&&"04"==u.substr(D[D.length-1],2)){g=r.oidname(s(u,D[0]));var m=JSON.parse(JSON.stringify(t));m.x509ExtName=g,v=m}for(var N=0;N<D.length;N++)p+=o(u,v,D[N],n+" ");return p}if("31"==l){p=n+"SET\n";var D=a(u,i);for(N=0;N<D.length;N++)p+=o(u,t,D[N],n+" ");return p}if(0!=(128&(l=parseInt(l,16)))){var w=31&l;if(0!=(32&l)){for(p=n+"["+w+"]\n",D=a(u,i),N=0;N<D.length;N++)p+=o(u,t,D[N],n+" ");return p}d=s(u,i);if(ze.isASN1HEX(d)){var p=n+"["+w+"]\n";return p+=o(d,t,0,n+" ")}return("68747470"==d.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==w)&&(d=ue(d)),p=n+"["+w+"] "+d+"\n"}return n+"UNKNOWN("+l+") "+s(u,i)+"\n"},ze.isContextTag=function(e,t){var i,n;e=e.toLowerCase();try{i=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&i);try{return null!=t.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(t.substr(1,t.length-1),10))>31)&&(128==(192&i)&&(31&i)==n))}catch(e){return!1}},ze.isASN1HEX=function(e){var t=ze;if(e.length%2==1)return!1;var i=t.getVblen(e,0),n=e.substr(0,2),r=t.getL(e,0);return e.length-n.length-r.length==2*i},ze.checkStrictDER=function(e,t,i,n,r){var s=ze;if(void 0===i){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!A.lang.String.isHex(e))throw new Error("not hex string");i=e.length,r=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(e,t).length>2*r)throw new Error("L of TLV too long: idx="+t);var o=s.getVblen(e,t);if(o>n)throw new Error("value of L too long than hex: idx="+t);var a=s.getTLV(e,t),u=a.length-2-s.getL(e,t).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var c=e.substr(t,2);if("02"===c){var l=s.getVidx(e,t);if("00"==e.substr(l,2)&&e.charCodeAt(l+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(c,16)){for(var h=s.getVblen(e,t),d=0,p=s.getChildIdx(e,t),M=0;M<p.length;M++){d+=s.getTLV(e,p[M]).length,s.checkStrictDER(e,p[M],i,n,r)}if(2*h!=d)throw new Error("sum of children's TLV length and L unmatch: "+2*h+"!="+d)}},ze.oidname=function(e){var t=A.asn1;A.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var i=t.x509.OID.oid2name(e);return""===i&&(i=e),i},void 0!==A.asn1&&A.asn1||(A.asn1={}),void 0!==A.asn1.x509&&A.asn1.x509||(A.asn1.x509={}),A.asn1.x509.Certificate=function(e){A.asn1.x509.Certificate.superclass.constructor.call(this);var t=A.asn1,i=t.DERBitString,n=t.DERSequence,r=t.x509,s=r.TBSCertificate,o=r.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=this.params,t=e.sigalg;null!=e.sigalg.name&&(t=e.sigalg.name);var i=e.tbsobj.getEncodedHex(),n=new A.crypto.Signature({alg:t});n.init(e.cakey),n.updateHex(i),e.sighex=n.sign()},this.getPEM=function(){return de(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var e=this.params;if(null!=e.tbsobj&&null!=e.tbsobj||(e.tbsobj=new s(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new o({name:e.sigalg})),t.push(new i({hex:"00"+e.sighex})),new n({array:t}).getEncodedHex()},null!=e&&(this.params=e)},ve(A.asn1.x509.Certificate,A.asn1.ASN1Object),A.asn1.x509.TBSCertificate=function(e){A.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=A.asn1,i=t.x509,n=t.DERTaggedObject,r=t.DERInteger,s=t.DERSequence,o=i.AlgorithmIdentifier,a=i.Time,u=i.X500Name,c=i.Extensions,l=i.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(e){this.params=e},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version||1!=t.version){var i=2;null!=t.version&&(i=t.version-1);var h=new n({obj:new r({int:i})});e.push(h)}return e.push(new r(t.serial)),e.push(new o({name:t.sigalg})),e.push(new u(t.issuer)),e.push(new s({array:[new a(t.notbefore),new a(t.notafter)]})),e.push(new u(t.subject)),e.push(new l(Ie.getKey(t.sbjpubkey))),void 0!==t.ext&&t.ext.length>0&&e.push(new n({tag:"a3",obj:new c(t.ext)})),new A.asn1.DERSequence({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.TBSCertificate,A.asn1.ASN1Object),A.asn1.x509.Extensions=function(e){A.asn1.x509.Extensions.superclass.constructor.call(this);var t=A.asn1,i=t.DERSequence,n=t.x509;this.aParam=[],this.setByParam=function(e){this.aParam=e},this.getEncodedHex=function(){for(var e=[],t=0;t<this.aParam.length;t++){var r=this.aParam[t],s=r.extname,o=null;if(null!=r.extn)o=new n.PrivateExtension(r);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(r);else if("keyUsage"==s)o=new n.KeyUsage(r);else if("subjectAltName"==s)o=new n.SubjectAltName(r);else if("issuerAltName"==s)o=new n.IssuerAltName(r);else if("basicConstraints"==s)o=new n.BasicConstraints(r);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(r);else if("certificatePolicies"==s)o=new n.CertificatePolicies(r);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(r);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(r);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(r);else if("cRLNumber"==s)o=new n.CRLNumber(r);else if("cRLReason"==s)o=new n.CRLReason(r);else if("ocspNonce"==s)o=new n.OCSPNonce(r);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(r);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(r);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(r));o=new n.SubjectDirectoryAttributes(r)}null!=o&&e.push(o)}return new i({array:e}).getEncodedHex()},null!=e&&this.setByParam(e)},ve(A.asn1.x509.Extensions,A.asn1.ASN1Object),A.asn1.x509.Extension=function(e){A.asn1.x509.Extension.superclass.constructor.call(this);var t=A.asn1,i=t.DERObjectIdentifier,n=t.DEROctetString;t.DERBitString;var r=t.DERBoolean,s=t.DERSequence;this.getEncodedHex=function(){var e=new i({oid:this.oid}),t=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(e),this.critical&&o.push(new r),o.push(t),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==e&&void 0!==e.critical&&(this.critical=e.critical)},ve(A.asn1.x509.Extension,A.asn1.ASN1Object),A.asn1.x509.KeyUsage=function(e){A.asn1.x509.KeyUsage.superclass.constructor.call(this,e);var t=Oe.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==e&&(void 0!==e.bin&&(this.asn1ExtnValue=new A.asn1.DERBitString(e)),void 0!==e.names&&void 0!==e.names.length)){for(var i=e.names,n="000000000",r=0;r<i.length;r++)for(var s=0;s<t.length;s++)i[r]===t[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new A.asn1.DERBitString({bin:n})}},ve(A.asn1.x509.KeyUsage,A.asn1.x509.Extension),A.asn1.x509.BasicConstraints=function(e){A.asn1.x509.BasicConstraints.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERBoolean,n=t.DERInteger,r=t.DERSequence;this.getExtnValueHex=function(){var e=new Array;this.cA&&e.push(new i),this.pathLen>-1&&e.push(new n({int:this.pathLen}));var t=new r({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==e&&(void 0!==e.cA&&(this.cA=e.cA),void 0!==e.pathLen&&(this.pathLen=e.pathLen))},ve(A.asn1.x509.BasicConstraints,A.asn1.x509.Extension),A.asn1.x509.CRLDistributionPoints=function(e){A.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=A.asn1,i=t.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(e){for(var n=[],r=0;r<e.length;r++)if(e[r]instanceof A.asn1.ASN1Object)n.push(e[r]);else{var s=new i.DistributionPoint(e[r]);n.push(s)}this.asn1ExtnValue=new t.DERSequence({array:n})},this.setByOneURI=function(e){var t=new i.DistributionPoint({fulluri:e});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==e&&(void 0!==e.array?this.setByDPArray(e.array):void 0!==e.uri&&this.setByOneURI(e.uri))},ve(A.asn1.x509.CRLDistributionPoints,A.asn1.x509.Extension),A.asn1.x509.DistributionPoint=function(e){A.asn1.x509.DistributionPoint.superclass.constructor.call(this);var t=A.asn1,i=t.x509.DistributionPointName;this.getEncodedHex=function(){var e=new t.DERSequence;if(null!=this.asn1DP){var i=new t.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});e.appendASN1Object(i)}return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.dpobj?this.asn1DP=e.dpobj:void 0!==e.dpname?this.asn1DP=new i(e.dpname):void 0!==e.fulluri&&(this.asn1DP=new i({full:[{uri:e.fulluri}]})))},ve(A.asn1.x509.DistributionPoint,A.asn1.ASN1Object),A.asn1.x509.DistributionPointName=function(e){A.asn1.x509.DistributionPointName.superclass.constructor.call(this);var t=A.asn1,i=t.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new i({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==e)if(t.x509.GeneralNames.prototype.isPrototypeOf(e))this.type="full",this.tag="a0",this.asn1V=e;else{if(void 0===e.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new t.x509.GeneralNames(e.full)}},ve(A.asn1.x509.DistributionPointName,A.asn1.ASN1Object),A.asn1.x509.CertificatePolicies=function(e){A.asn1.x509.CertificatePolicies.superclass.constructor.call(this,e);var t=A.asn1,i=t.x509,n=t.DERSequence,r=i.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++)e.push(new r(this.params.array[t]));var i=new n({array:e});return this.asn1ExtnValue=i,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==e&&(this.params=e)},ve(A.asn1.x509.CertificatePolicies,A.asn1.x509.Extension),A.asn1.x509.PolicyInformation=function(e){A.asn1.x509.PolicyInformation.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.DERObjectIdentifier,r=t.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 e=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var t=[],s=0;s<this.params.array.length;s++)t.push(new r(this.params.array[s]));t.length>0&&e.push(new i({array:t}))}return new i({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.PolicyInformation,A.asn1.ASN1Object),A.asn1.x509.PolicyQualifierInfo=function(e){A.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.DERIA5String,r=t.DERObjectIdentifier,s=t.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==e&&(this.params=e)},ve(A.asn1.x509.PolicyQualifierInfo,A.asn1.ASN1Object),A.asn1.x509.UserNotice=function(e){A.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=A.asn1.DERSequence;A.asn1.DERInteger;var i=A.asn1.x509.DisplayText,n=A.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var e=[];return void 0!==this.params.noticeref&&e.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&e.push(new i(this.params.exptext)),new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.UserNotice,A.asn1.ASN1Object),A.asn1.x509.NoticeReference=function(e){A.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,i=A.asn1.DERInteger,n=A.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var e=[];if(void 0!==this.params.org&&e.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var r=[],s=this.params.noticenum,o=0;o<s.length;o++)r.push(new i(s[o]));e.push(new t({array:r}))}if(0==e.length)throw new Error("parameter is empty");return new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.NoticeReference,A.asn1.ASN1Object),A.asn1.x509.DisplayText=function(e){A.asn1.x509.DisplayText.superclass.constructor.call(this,e),this.hT="0c",void 0!==e&&("ia5"===e.type?this.hT="16":"vis"===e.type?this.hT="1a":"bmp"===e.type&&(this.hT="1e"))},ve(A.asn1.x509.DisplayText,A.asn1.DERAbstractString),A.asn1.x509.ExtKeyUsage=function(e){A.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,e);var t=A.asn1;this.setPurposeArray=function(e){this.asn1ExtnValue=new t.DERSequence;for(var i=0;i<e.length;i++){var n=new t.DERObjectIdentifier(e[i]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==e&&void 0!==e.array&&this.setPurposeArray(e.array)},ve(A.asn1.x509.ExtKeyUsage,A.asn1.x509.Extension),A.asn1.x509.AuthorityKeyIdentifier=function(e){A.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,e);var t=A,i=t.asn1,n=i.DERTaggedObject,r=i.x509.GeneralNames;t.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var e=new Array;this.asn1KID&&e.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&e.push(new n({explicit:!1,tag:"a1",obj:new r([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&e.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var t=new i.DERSequence({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new A.asn1.DEROctetString(e);else if("object"==typeof e&&A.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN ")){var t=e;"string"==typeof e&&(t=Ie.getKey(e));var i=Ie.getKeyID(t);this.asn1KID=new A.asn1.DEROctetString({hex:i})}},this.setCertIssuerByParam=function(e){void 0!==e.str||void 0!==e.ldapstr||void 0!==e.hex||void 0!==e.certsubject||void 0!==e.certissuer?this.asn1CertIssuer=new A.asn1.x509.X500Name(e):"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&-1!=e.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new A.asn1.x509.X500Name({certissuer:e}))},this.setCertSNByParam=function(e){if(void 0!==e.str||void 0!==e.bigint||void 0!==e.hex)this.asn1CertSN=new A.asn1.DERInteger(e);else if("string"==typeof e&&-1!=e.indexOf("BEGIN ")&&e.indexOf("CERTIFICATE")){var t=new Oe;t.readCertPEM(e);var i=t.getSerialNumberHex();this.asn1CertSN=new A.asn1.DERInteger({hex:i})}},this.oid="2.5.29.35",void 0!==e&&(void 0!==e.kid&&this.setKIDByParam(e.kid),void 0!==e.issuer&&this.setCertIssuerByParam(e.issuer),void 0!==e.sn&&this.setCertSNByParam(e.sn),void 0!==e.issuersn&&"string"==typeof e.issuersn&&-1!=e.issuersn.indexOf("BEGIN ")&&e.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(e.issuersn),this.setCertIssuerByParam(e.issuersn)))},ve(A.asn1.x509.AuthorityKeyIdentifier,A.asn1.x509.Extension),A.asn1.x509.SubjectKeyIdentifier=function(e){A.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,e);var t=A.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new t(e);else if("object"==typeof e&&A.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN")){var i=e;"string"==typeof e&&(i=Ie.getKey(e));var n=Ie.getKeyID(i);this.asn1KID=new A.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==e&&void 0!==e.kid&&this.setKIDByParam(e.kid)},ve(A.asn1.x509.SubjectKeyIdentifier,A.asn1.x509.Extension),A.asn1.x509.AuthorityInfoAccess=function(e){A.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,e),this.setAccessDescriptionArray=function(e){for(var t=new Array,i=A.asn1,n=i.DERSequence,r=i.DERObjectIdentifier,s=i.x509.GeneralName,o=0;o<e.length;o++){var a,u=e[o];if(void 0!==u.ocsp)a=new n({array:[new r({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 r({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}t.push(a)}this.asn1ExtnValue=new n({array:t})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==e&&void 0!==e.array&&this.setAccessDescriptionArray(e.array)},ve(A.asn1.x509.AuthorityInfoAccess,A.asn1.x509.Extension),A.asn1.x509.SubjectAltName=function(e){A.asn1.x509.SubjectAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new A.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},ve(A.asn1.x509.SubjectAltName,A.asn1.x509.Extension),A.asn1.x509.IssuerAltName=function(e){A.asn1.x509.IssuerAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new A.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},ve(A.asn1.x509.IssuerAltName,A.asn1.x509.Extension),A.asn1.x509.SubjectDirectoryAttributes=function(e){A.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.ASN1Util.newObject,r=t.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++){var s=this.params.array[t],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=r(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=r(s.attr),o.seq[1].set[0]={prnstr:s.str}}e.push(new n(o))}var a=new i({array:e});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==e&&(this.params=e)},ve(A.asn1.x509.SubjectDirectoryAttributes,A.asn1.x509.Extension),A.asn1.x509.PrivateExtension=function(e){A.asn1.x509.PrivateExtension.superclass.constructor.call(this,e);var t=A,i=t.lang.String.isHex,n=t.asn1,r=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(e){this.oid=r(e.extname),this.params=e},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var e=this.params.extn;if("string"==typeof e&&i(e))return e;if("object"==typeof e)try{return s(e).getEncodedHex()}catch(e){}throw new Error("unsupported extn value")},null!=e&&this.setByParam(e)},ve(A.asn1.x509.PrivateExtension,A.asn1.x509.Extension),A.asn1.x509.CRL=function(e){A.asn1.x509.CRL.superclass.constructor.call(this);var t=A.asn1,i=t.DERSequence,n=t.DERBitString,r=t.x509,s=r.AlgorithmIdentifier,o=r.TBSCertList;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=new o(this.params).getEncodedHex(),t=new A.crypto.Signature({alg:this.params.sigalg});t.init(this.params.cakey),t.updateHex(e);var i=t.sign();this.params.sighex=i},this.getPEM=function(){return de(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var e=this.params;if(null==e.tbsobj&&(e.tbsobj=new o(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new s({name:e.sigalg})),t.push(new n({hex:"00"+e.sighex})),new i({array:t}).getEncodedHex()},null!=e&&(this.params=e)},ve(A.asn1.x509.CRL,A.asn1.ASN1Object),A.asn1.x509.TBSCertList=function(e){A.asn1.x509.TBSCertList.superclass.constructor.call(this);var t=A.asn1,i=t.DERInteger,n=t.DERSequence,r=t.DERTaggedObject;t.DERObjectIdentifier;var s=t.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,c=s.X500Name;this.params=null,this.setByParam=function(e){this.params=e},this.getRevCertSequence=function(){for(var e=[],t=this.params.revcert,r=0;r<t.length;r++){var s=[new i(t[r].sn),new a(t[r].date)];null!=t[r].ext&&s.push(new u(t[r].ext)),e.push(new n({array:s}))}return new n({array:e})},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version){var s=t.version-1,l=new i({int:s});e.push(l)}if(e.push(new o({name:t.sigalg})),e.push(new c(t.issuer)),e.push(new a(t.thisupdate)),null!=t.nextupdate&&e.push(new a(t.nextupdate)),null!=t.revcert&&e.push(this.getRevCertSequence()),null!=t.ext){var h=new u(t.ext);e.push(new r({tag:"a0",explicit:!0,obj:h}))}return new n({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.TBSCertList,A.asn1.ASN1Object),A.asn1.x509.CRLEntry=function(e){A.asn1.x509.CRLEntry.superclass.constructor.call(this);var t=A.asn1;this.setCertSerial=function(e){this.sn=new t.DERInteger(e)},this.setRevocationDate=function(e){this.time=new t.x509.Time(e)},this.getEncodedHex=function(){var e=new t.DERSequence({array:[this.sn,this.time]});return this.TLV=e.getEncodedHex(),this.TLV},void 0!==e&&(void 0!==e.time&&this.setRevocationDate(e.time),void 0!==e.sn&&this.setCertSerial(e.sn))},ve(A.asn1.x509.CRLEntry,A.asn1.ASN1Object),A.asn1.x509.CRLNumber=function(e){A.asn1.x509.CRLNumber.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=e&&(this.params=e)},ve(A.asn1.x509.CRLNumber,A.asn1.x509.Extension),A.asn1.x509.CRLReason=function(e){A.asn1.x509.CRLReason.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=e&&(this.params=e)},ve(A.asn1.x509.CRLReason,A.asn1.x509.Extension),A.asn1.x509.OCSPNonce=function(e){A.asn1.x509.OCSPNonce.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=e&&(this.params=e)},ve(A.asn1.x509.OCSPNonce,A.asn1.x509.Extension),A.asn1.x509.OCSPNoCheck=function(e){A.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=e&&(this.params=e)},ve(A.asn1.x509.OCSPNoCheck,A.asn1.x509.Extension),A.asn1.x509.AdobeTimeStamp=function(e){A.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERInteger,n=t.DERBoolean,r=t.DERSequence,s=t.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var e=this.params,t=[new i(1)];return t.push(new s({uri:e.uri})),null!=e.reqauth&&t.push(new n(e.reqauth)),this.asn1ExtnValue=new r({array:t}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.AdobeTimeStamp,A.asn1.x509.Extension),A.asn1.x509.X500Name=function(e){A.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.asn1,i=t.x509,n=i.RDN;this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.split("/");i.shift();for(var r=[],s=0;s<i.length;s++)if(i[s].match(/^[^=]+=.+$/))r.push(i[s]);else{var o=r.length-1;r[o]=r[o]+"/"+i[s]}for(s=0;s<r.length;s++)this.asn1Array.push(new n({str:r[s],rule:this.sRule}))},this.setByLdapString=function(e,t){void 0!==t&&(this.sRule=t);var n=i.X500Name.ldapToCompat(e);this.setByString(n,t)},this.setByObject=function(e,t){for(var i in void 0!==t&&(this.sRule=t),e)if(e.hasOwnProperty(i)){var r=new n({str:i+"="+e[i],rule:this.sRule});this.asn1Array?this.asn1Array.push(r):this.asn1Array=[r]}},this.setByParam=function(e){var t;(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.array)?this.paramArray=e.array:void 0!==e.str?this.setByString(e.str):void 0!==e.ldapstr?this.setByLdapString(e.ldapstr):void 0!==e.hex?this.hTLV=e.hex:void 0!==e.certissuer?((t=new Oe).readCertPEM(e.certissuer),this.hTLV=t.getIssuerHex()):void 0!==e.certsubject?((t=new Oe).readCertPEM(e.certsubject),this.hTLV=t.getSubjectHex()):"object"==typeof e&&void 0===e.certsubject&&void 0===e.certissuer&&this.setByObject(e)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i={array:this.paramArray[e]};"utf8"!=this.sRule&&(i.rule=this.sRule);var r=new n(i);this.asn1Array.push(r)}var s=new t.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.X500Name,A.asn1.ASN1Object),A.asn1.x509.X500Name.compatToLDAP=function(e){if("/"!==e.substr(0,1))throw"malformed input";var t=(e=e.substr(1)).split("/");return t.reverse(),(t=t.map((function(e){return e.replace(/,/,"\\,")}))).join(",")},A.asn1.x509.X500Name.onelineToLDAP=function(e){return A.asn1.x509.X500Name.compatToLDAP(e)},A.asn1.x509.X500Name.ldapToCompat=function(e){for(var t=e.split(","),i=!1,n=[],r=0;t.length>0;r++){var s=t.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(e){return e.replace("/","\\/")}))).reverse(),"/"+n.join("/")},A.asn1.x509.X500Name.ldapToOneline=function(e){return A.asn1.x509.X500Name.ldapToCompat(e)},A.asn1.x509.RDN=function(e){A.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.asn1.x509.AttributeTypeAndValue;this.setByParam=function(e){void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.str&&this.addByMultiValuedString(e.str),void 0!==e.array&&(this.paramArray=e.array)},this.addByString=function(e){this.asn1Array.push(new A.asn1.x509.AttributeTypeAndValue({str:e,rule:this.sRule}))},this.addByMultiValuedString=function(e){for(var t=A.asn1.x509.RDN.parseString(e),i=0;i<t.length;i++)this.addByString(t[i])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i=this.paramArray[e];void 0!==i.rule&&"utf8"!=this.sRule&&(i.rule=this.sRule);var n=new t(i);this.asn1Array.push(n)}var r=new A.asn1.DERSet({array:this.asn1Array});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.RDN,A.asn1.ASN1Object),A.asn1.x509.RDN.parseString=function(e){for(var t=e.split(/\+/),i=!1,n=[],r=0;t.length>0;r++){var s=t.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,u=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var c=u.pop();if(s.match(/"$/)){o=(c+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(c+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},A.asn1.x509.AttributeTypeAndValue=function(e){A.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=A,i=t.asn1,n=i.DERSequence,r=i.DERUTF8String,s=i.DERPrintableString,o=i.DERTeletexString,a=i.DERIA5String,u=i.DERVisibleString,c=i.DERBMPString,l=t.lang.String.isMail,h=t.lang.String.isPrintable;this.setByParam=function(e){if(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.ds&&(this.dsType=e.ds),void 0===e.value&&void 0!==e.str){var t=e.str.match(/^([^=]+)=(.+)$/);if(!t)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=t[1],this.sValue=t[2]}else this.sType=e.type,this.sValue=e.value},this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.match(/^([^=]+)=(.+)$/);if(!i)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(i[1],i[2])},this._getDsType=function(){var e=this.sType,t=this.sValue,i=this.sRule;return"prn"===i?"CN"==e&&l(t)?"ia5":h(t)?"prn":"utf8":"utf8"===i?"CN"==e&&l(t)?"ia5":"C"==e?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(e,t,i){void 0!==i&&(this.sRule=i),this.sType=e,this.sValue=t},this.getValueObj=function(e,t){if("utf8"==e)return new r({str:t});if("prn"==e)return new s({str:t});if("tel"==e)return new o({str:t});if("ia5"==e)return new a({str:t});if("vis"==e)return new u({str:t});if("bmp"==e)return new c({str:t});throw new Error("unsupported directory string type: type="+e+" value="+t)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var e=A.asn1.x509.OID.atype2obj(this.sType),t=this.getValueObj(this.dsType,this.sValue),i=new n({array:[e,t]});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.AttributeTypeAndValue,A.asn1.ASN1Object),A.asn1.x509.SubjectPublicKeyInfo=function(e){A.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=A,i=t.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,u=i.x509.AlgorithmIdentifier,c=t.crypto;c.ECDSA,c.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 e=this.getASN1Object();return this.hTLV=e.getEncodedHex(),this.hTLV},this.setPubKey=function(e){try{if(e instanceof ee){var t=a({seq:[{int:{bigint:e.n}},{int:{int:e.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+t})}}catch(e){}try{if(e instanceof A.crypto.ECDSA){var i=new s({name:e.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+e.pubKeyHex})}}catch(e){}try{if(e instanceof A.crypto.DSA){i=new a({seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:i});var o=new n({bigint:e.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(e){}},void 0!==e&&this.setPubKey(e)},ve(A.asn1.x509.SubjectPublicKeyInfo,A.asn1.ASN1Object),A.asn1.x509.Time=function(e){A.asn1.x509.Time.superclass.constructor.call(this);var t=A.asn1,i=t.DERUTCTime,n=t.DERGeneralizedTime;this.setTimeParams=function(e){this.timeParams=e},this.getEncodedHex=function(){var e=null;return e=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=e.getEncodedHex(),this.TLV},this.type="utc",void 0!==e&&(void 0!==e.type?this.type=e.type:void 0!==e.str&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)},ve(A.asn1.x509.Time,A.asn1.ASN1Object),A.asn1.x509.AlgorithmIdentifier=function(e){A.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=A.asn1,i=t.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 e=null;for(var n in i)n===this.nameAlg&&(e=i[n]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=t.x509.OID.name2obj(this.nameAlg));var r=[this.asn1Alg];null!==this.asn1Params&&r.push(this.asn1Params);var s=new t.DERSequence({array:r});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.name&&(this.nameAlg=e.name),void 0!==e.asn1params&&(this.asn1Params=e.asn1params),void 0!==e.paramempty&&(this.paramEmpty=e.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 t.DERNull)}},ve(A.asn1.x509.AlgorithmIdentifier,A.asn1.ASN1Object),A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},A.asn1.x509.GeneralName=function(e){A.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=A.asn1;i.DERSequence;var n=i.DEROctetString,r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,u=Ae;this.explicit=!1,this.setByParam=function(e){var i=null;if(void 0!==e){if(void 0!==e.rfc822&&(this.type="rfc822",i=new r({str:e[this.type]})),void 0!==e.dns&&(this.type="dns",i=new r({str:e[this.type]})),void 0!==e.uri&&(this.type="uri",i=new r({str:e[this.type]})),void 0!==e.dn&&(this.type="dn",this.explicit=!0,i="string"==typeof e.dn?new a({str:e.dn}):e.dn instanceof A.asn1.x509.X500Name?e.dn:new a(e.dn)),void 0!==e.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:e.ldapdn})),void 0!==e.certissuer){this.type="dn",this.explicit=!0;var c=null;if((h=e.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=h.indexOf("-----BEGIN ")&&(c=u(h)),null==c)throw"certissuer param not cert";(d=new Oe).hex=c;var l=d.getIssuerHex();(i=new o).hTLV=l}if(void 0!==e.certsubj){this.type="dn",this.explicit=!0;var h,d;c=null;if((h=e.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=h.indexOf("-----BEGIN ")&&(c=u(h)),null==c)throw"certsubj param not cert";(d=new Oe).hex=c;l=d.getSubjectHex();(i=new o).hTLV=l}if(void 0!==e.ip){this.type="ip",this.explicit=!1;var p,M=e.ip,f="malformed IP address";if(M.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(p=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map((function(e,t,i){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(e){throw"malformed integer array string: "+e}}("["+M.split(".").join(",")+"]")).length)throw f}else if(M.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))p=function(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var i=(e=e.toLowerCase()).split(":").length-1;if(i<2)throw t;var n=":".repeat(7-i+2),r=(e=e.replace("::",n)).split(":");if(8!=r.length)throw t;for(var s=0;s<8;s++)r[s]=("0000"+r[s]).slice(-4);return r.join("")}(M);else{if(!M.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw f;p=M}i=new n({hex:p})}if(null==this.type)throw"unsupported type in params="+e;this.asn1Obj=new s({explicit:this.explicit,tag:t[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.GeneralName,A.asn1.ASN1Object),A.asn1.x509.GeneralNames=function(e){A.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=A.asn1;this.setByParamArray=function(e){for(var i=0;i<e.length;i++){var n=new t.x509.GeneralName(e[i]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new t.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==e&&this.setByParamArray(e)},ve(A.asn1.x509.GeneralNames,A.asn1.ASN1Object),A.asn1.x509.OID=new function(e){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(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var t=this.name2oidList[e],i=new A.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var t;if(e.match(/^\d+\.\d+\.[0-9.]+$/))t=e;else if(void 0!==this.atype2oidList[e])t=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw"AttributeType name undefined: "+e;t=this.name2oidList[e]}var i=new A.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i}},A.asn1.x509.OID.oid2name=function(e){var t=A.asn1.x509.OID.name2oidList;for(var i in t)if(t[i]==e)return i;return""},A.asn1.x509.OID.oid2atype=function(e){var t=A.asn1.x509.OID.atype2oidList;for(var i in t)if(t[i]==e)return i;return e},A.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=A.asn1.x509.OID.name2oidList;return void 0===t[e]?"":t[e]},A.asn1.x509.X509Util={},A.asn1.x509.X509Util.newCertPEM=function(e){var t=A.asn1.x509;return t.TBSCertificate,new(0,t.Certificate)(e).getPEM()},ee.getPosArrayOfChildrenFromHex=function(e){return ze.getChildIdx(e,0)},ee.getHexValueArrayOfChildrenFromHex=function(e){var t,i=ze.getV,n=i(e,(t=ee.getPosArrayOfChildrenFromHex(e))[0]),r=i(e,t[1]),s=i(e,t[2]),o=i(e,t[3]),a=i(e,t[4]),u=i(e,t[5]),c=i(e,t[6]),l=i(e,t[7]),h=i(e,t[8]);return(t=new Array).push(n,r,s,o,a,u,c,l,h),t},ee.prototype.readPrivateKeyFromPEMString=function(e){var t=Ae(e),i=ee.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ee.prototype.readPKCS5PrvKeyHex=function(e){var t=ee.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},ee.prototype.readPKCS8PrvKeyHex=function(e){var t,i,n,r,s,o,a,u,c=ze,l=c.getVbyListEx;if(!1===c.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),i=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),r=l(e,0,[2,0,4],"02"),s=l(e,0,[2,0,5],"02"),o=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),u=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,i,n,r,s,o,a,u)},ee.prototype.readPKCS5PubKeyHex=function(e){var t=ze,i=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var r=i(e,n[0]),s=i(e,n[1]);this.setPublic(r,s)},ee.prototype.readPKCS8PubKeyHex=function(e){var t=ze;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var i=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(i)},ee.prototype.readCertPubKeyHex=function(e,t){var i,n;(i=new Oe).readCertHex(e),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},ee.prototype.sign=function(e,t){var i,n=(i=e,A.crypto.Util.hashString(i,t));return this.signWithMessageHash(n,t)},ee.prototype.signWithMessageHash=function(e,t){var i=J(A.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return be(this.doPrivate(i).toString(16),this.n.bitLength())},ee.prototype.signPSS=function(e,t,i){var n,r=(n=le(e),A.crypto.Util.hashHex(n,t));return void 0===i&&(i=-1),this.signWithMessageHashPSS(r,t,i)},ee.prototype.signWithMessageHashPSS=function(e,t,i){var n,r=ce(e),s=r.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(e){return A.crypto.Util.hashHex(e,t)};if(-1===i||void 0===i)i=s;else if(-2===i)i=a-s-2;else if(i<-2)throw new Error("invalid salt length");if(a<s+i+2)throw new Error("data too long");var c="";i>0&&(c=new Array(i),(new K).nextBytes(c),c=String.fromCharCode.apply(String,c));var l=ce(u(le("\0\0\0\0\0\0\0\0"+r+c))),h=[];for(n=0;n<a-i-s-2;n+=1)h[n]=0;var d=String.fromCharCode.apply(String,h)+""+c,p=Le(l,d.length,u),M=[];for(n=0;n<d.length;n+=1)M[n]=d.charCodeAt(n)^p.charCodeAt(n);var g=65280>>8*a-o&255;for(M[0]&=~g,n=0;n<s;n++)M.push(l.charCodeAt(n));return M.push(188),be(this.doPrivate(new f(M)).toString(16),this.n.bitLength())},ee.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var i=J(t,16),n=this.n.bitLength();if(i.bitLength()>n)return!1;var r=this.doPublic(i).toString(16);if(r.length+3!=n/4)return!1;var s=Se(r.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=e,A.crypto.Util.hashString(o,a))},ee.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=J(t,16);if(i.bitLength()>this.n.bitLength())return 0;var n=Se(this.doPublic(i).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},ee.prototype.verifyPSS=function(e,t,i,n){var r=function(e){return A.crypto.Util.hashHex(e,i)}(le(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(r,t,i,n)},ee.prototype.verifyWithMessageHashPSS=function(e,t,i,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r,s=new f(t,16),o=function(e){return A.crypto.Util.hashHex(e,i)},a=ce(e),u=a.length,c=this.n.bitLength()-1,l=Math.ceil(c/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=l-u-2;else if(n<-2)throw new Error("invalid salt length");if(l<u+n+2)throw new Error("data too long");var h=this.doPublic(s).toByteArray();for(r=0;r<h.length;r+=1)h[r]&=255;for(;h.length<l;)h.unshift(0);if(188!==h[l-1])throw new Error("encoded message does not end in 0xbc");var d=(h=String.fromCharCode.apply(String,h)).substr(0,l-u-1),p=h.substr(d.length,u),M=65280>>8*l-c&255;if(0!=(d.charCodeAt(0)&M))throw new Error("bits beyond keysize not zero");var g=Le(p,d.length,o),y=[];for(r=0;r<d.length;r+=1)y[r]=d.charCodeAt(r)^g.charCodeAt(r);y[0]&=~M;var v=l-u-n-2;for(r=0;r<v;r+=1)if(0!==y[r])throw new Error("leftmost octets not zero");if(1!==y[v])throw new Error("0x01 marker not found");return p===ce(o(le("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},ee.SALT_LEN_HLEN=-1,ee.SALT_LEN_MAX=-2,ee.SALT_LEN_RECOVER=-2,Oe.hex2dn=function(e,t){void 0===t&&(t=0);var i=new Oe;return ze.getTLV(e,t),i.getX500Name(e).str},Oe.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var i=new Array,n=ze.getChildIdx(e,t),r=0;r<n.length;r++)i.push(Oe.hex2attrTypeValue(e,n[r]));return(i=i.map((function(e){return e.replace("+","\\+")}))).join("+")},Oe.hex2attrTypeValue=function(e,t){var i=ze,n=i.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var r=i.getChildIdx(e,t);2!==r.length||e.substr(r[0],2);var s=n(e,r[0]),o=A.asn1.ASN1Util.oidHexToInt(s);return A.asn1.x509.OID.oid2atype(o)+"="+ce(n(e,r[1]))},Oe.getPublicKeyFromCertHex=function(e){var t=new Oe;return t.readCertHex(e),t.getPublicKey()},Oe.getPublicKeyFromCertPEM=function(e){var t=new Oe;return t.readCertPEM(e),t.getPublicKey()},Oe.getPublicKeyInfoPropOfCertPEM=function(e){var t,i,n=ze.getVbyList,r={};return r.algparam=null,(t=new Oe).readCertPEM(e),i=t.getPublicKeyHex(),r.keyhex=n(i,0,[1],"03").substr(2),r.algoid=n(i,0,[0,0],"06"),"2a8648ce3d0201"===r.algoid&&(r.algparam=n(i,0,[0,1],"06")),r},Oe.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var Pe,ke=[(Pe=new Oe,Pe.readCertPEM(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}(":::::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:::::")),Pe)];function Be(e,t){var i=e.getIssuerHex();if(i===e.getSubjectHex())return e.verifySignature(e.getPublicKey());var n=function(e,t){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r.getSubjectHex()===e)return r}}(i,t);return!!n&&(!1!==e.verifySignature(n.getPublicKey())&&Be(n,t))}function Ue(e){return e.getIssuerHex()!==e.getSubjectHex()&&Be(e,ke)}!function(e){var t=new Oe;"string"==typeof e?t.readCertPEM(e):t.readCertHex(e.hex);var i=Ue(t);ke.push(t)}(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}(":::::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 Qe=2*Math.PI;function _e(e){return(e%Qe+Qe)%Qe}var Re=function(e){function i(t){var i=e.call(this,t,1,.1,1e3)||this;return i.pose={longitude:0,latitude:0,fov:t,offset:new a.Vector3},i.computePose(),i}return t.__extends(i,e),i.prototype.computePose=function(){var e=this.getWorldDirection(new a.Vector3);this.pose.longitude=_e(-Math.atan2(e.x,-e.z)),this.pose.latitude=-Math.asin(e.y/1),this.pose.fov=this.fov,this.pose.offset.copy(this.position)},i.prototype.setFromPose=function(e){var t,i,n,r,s=_e(null!==(t=e.longitude)&&void 0!==t?t:this.pose.longitude),o=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,null!==(i=e.latitude)&&void 0!==i?i:this.pose.latitude)),u=null!==(n=e.fov)&&void 0!==n?n:this.pose.fov,c=null!==(r=e.offset)&&void 0!==r?r:this.pose.offset;this.position.copy(c);var l=Math.abs(Math.cos(o)),h=new a.Vector3(-Math.sin(s)*l,-Math.sin(o),-Math.cos(s)*l);this.lookAt(c.clone().add(h)),this.fov!==u&&(this.fov=u,this.updateProjectionMatrix()),this.updateMatrixWorld(),this.pose.longitude=s,this.pose.latitude=o,this.pose.fov=u,this.pose.offset.copy(c)},i.prototype.copyPose=function(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,offset:this.pose.offset.clone()}},i}(a.PerspectiveCamera),Ye=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.add=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.add.apply(this,t)},i.prototype.remove=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.remove.apply(this,t)},i}(a.Scene),Fe=function(e){function i(t){var i=t.preserveDrawingBuffer,n=void 0===i||i,r=t.backgroundColor,s=void 0===r?1579548:r,o=t.backgroundAlpha,u=void 0===o?1:o,c=t.pixelRatio,l=void 0===c?1:c,h=t.antialias,d=void 0!==h&&h,A=e.call(this,{antialias:d,preserveDrawingBuffer:n,alpha:u<1})||this;return A.setPixelRatio(l),A.setClearColor(s,u),A.outputEncoding=a.sRGBEncoding,A.autoClear=!0,A}return t.__extends(i,e),i}(a.WebGLRenderer);function Ve(e){return null==e}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]}function Ge(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function qe(){return(Ge()+Ge()+"-"+Ge()+"-4"+Ge().substr(0,3)+"-"+Ge()+"-"+Ge()+Ge()+Ge()).toLowerCase()}var We="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),Ze="undefined"!=typeof performance?function(){return We+performance.now()}:function(){return Date.now()},Xe=function(){if("undefined"!=typeof window){var e=window;return e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||e.msRequestAnimationFrame||function(e){return setTimeout(e,16)}}return function(e){return setTimeout(e,16)}}();function Ke(e,t){void 0===e&&(e=He),void 0===t&&(t=0),Xe(t<=0?e:function(){return Ke(e,t-1)})}function Je(e,i){void 0===e&&(e=He);for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var s=!1,o=function(r){e.call.apply(e,t.__spreadArray([i,r],n,!1)),s||"function"!=typeof o||Xe(o)};return Xe(o),function(){o=null,s=!0}}var $e=0;function et(e){$e&&e($e);var t=Ze();Xe((function(){e($e=Ze()-t)}))}et(He);var tt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t.needsRender=!0,t}return t.__extends(i,e),i}(a.Mesh),it=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.needsRender=!0,t}return t.__extends(i,e),i.prototype.getTransparent=function(){var e;return this.traverse((function(t){void 0===e&&t instanceof tt&&t.material.forEach((function(t){void 0===e&&1===t.uniforms.originOpacity.value&&(e=t.transparent)}))})),null!=e&&e},i.prototype.setTransparent=function(e){this.traverse((function(t){t instanceof tt&&t.material.forEach((function(t){1===t.uniforms.originOpacity.value&&(t.transparent=e)}))}))},i.prototype.getMaterial=function(){var e=null;return this.traverse((function(t){if(null===e&&t instanceof tt){var i=t.material[0];e={pano0Map:i.pano0Map,pano0Matrix:i.pano0Matrix,pano1Map:i.pano1Map,pano1Matrix:i.pano1Matrix,modelAlpha:i.modelAlpha,progress:i.progress,useBlackTransition:i.useBlackTransition,perspToOrtho:i.perspToOrtho,opacity:i.opacity,pano0DepthMap:i.pano0DepthMap,panoVideoMap:i.panoVideoMap,panoVideoSize:i.panoVideoSize,panoVideoMatrix:i.panoVideoMatrix,panoVideoAlpha:i.panoVideoAlpha,panoTileMap:i.panoTileMap,panoTileMappings:i.panoTileMappings}}})),e},i.prototype.setMaterial=function(e){this.traverse((function(t){t instanceof tt&&t.material.forEach((function(t){void 0!==e.pano0Map&&(t.pano0Map=e.pano0Map),void 0!==e.pano0Matrix&&(t.pano0Matrix=e.pano0Matrix),void 0!==e.pano1Map&&(t.pano1Map=e.pano1Map),void 0!==e.pano1Matrix&&(t.pano1Matrix=e.pano1Matrix),void 0!==e.modelAlpha&&(t.modelAlpha=e.modelAlpha),void 0!==e.progress&&(t.progress=e.progress),void 0!==e.useBlackTransition&&(t.useBlackTransition=e.useBlackTransition),void 0!==e.perspToOrtho&&(t.perspToOrtho=e.perspToOrtho),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.pano0DepthMap&&(t.pano0DepthMap=e.pano0DepthMap),void 0!==e.panoVideoMap&&(t.panoVideoMap=e.panoVideoMap),void 0!==e.panoVideoSize&&(t.panoVideoSize=e.panoVideoSize),void 0!==e.panoVideoMatrix&&(t.panoVideoMatrix=e.panoVideoMatrix),void 0!==e.panoVideoAlpha&&(t.panoVideoAlpha=e.panoVideoAlpha),void 0!==e.panoTileMap&&(t.panoTileMap=e.panoTileMap),void 0!==e.panoTileMappings&&(t.panoTileMappings=e.panoTileMappings)}))}))},i.prototype.disposeMaterial=function(){this.traverse((function(e){if(e instanceof tt){var t=[];e.material.forEach((function(e){var i=e.uniforms;Object.keys(i).map((function(e){if(["pano0Map","pano1Map","pano0DepthMap","panoVideoMap","panoTileMap"].indexOf(e)>=0)i[e].value=null;else{var n=i[e].value;n&&"function"==typeof n.dispose&&-1===t.indexOf(n)&&(i[e].value=null,t.push(n))}})),e.dispose()})),t.forEach((function(e){return e.dispose()}))}}))},i.prototype.disposeGeometry=function(){this.traverse((function(e){e instanceof tt&&e.geometry.dispose()}))},i}(a.Group),nt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t}return t.__extends(i,e),i}(it),rt=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("n\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{H{vs|z-znA-}n{|=ZnvH{vs|z-znA-}n{|>ZnvH{vs|z-rp@-z|qryPr{rH{vs|z-sy|n-}r}a|\\u|Hn\bv{t-rp@-}n{|=a|crrHn\bv{t-rp@-}n{|>a|crrH0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq-5b`Rl]N[\\=lQR]aUlZN]6--n\bv{t-rp@-pnzrna|crrH0r{qvs0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|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--rp@-|yq]|vv|{-J-5z|qryZnv-7-n{s|zrq6;\b\tH--0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq-5b`Rl]N[\\=lQR]aUlZN]6----pnzrna|crr-J-|yq]|vv|{-:-pnzrn]|vv|{H--0r{qvs--}n{|=a|crr-J-5|yq]|vv|{-:-}n{|=Znvh@j;\b\t6-7-zn@5}n{|=Znv6H--}n{|>a|crr-J-5|yq]|vv|{-:-}n{|>Znvh@j;\b\t6-7-zn@5}n{|>Znv6H--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--rp@-pnzrn[|zny-J-5z|qrycvrZnv-7-rpA5=;=9-=;=9->;=9-=;=66;\b\tH--sy|n-|u|Qvn{pr-J-zn5=;=>9-q|5pnzrn[|zny9-z|qryPr{r-:-pnzrn]|vv|{66H--tyl]|vv|{;-J-zv5-tyl]|vv|{;9-tyl]|vv|{;-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H--tyl]|vv|{;\b-J-zv5-tyl]|vv|{;\b9-tyl]|vv|{;\b-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H\f"),st=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("{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-|vtv{\\}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-nz}yrPor-}n{|=Zn}H{vs|z-nz}yrPor-}n{|>Zn}H{vs|z-nz}yrPor-}n{|=Qr}uZn}H{vs|z-rp?-}n{|cvqr|`v\trH{vs|z-znA-}n{|cvqr|ZnvH{vs|z-sy|n-}n{|cvqr|Ny}unH{vs|z-nz}yr?Q-}n{|cvqr|Zn}H0vs-qrsv{rq5b`RlaVYR6--{vs|z-nz}yr?Q-}n{|avyrZn}H--{vs|z-rpA-}n{|avyrPyv}Zn}}v{thaVYRlZN]]V[TlYR[TaUjH--{vs|z-rpA-}n{|avyrQnNZn}}v{thaVYRlZN]]V[TlYR[TaUjH0r{qvs0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq5b`Rl]N[\\=lQR]aUlZN]6--n\bv{t-rp@-pnzrna|crrH0r{qvsn\bv{t-rp@-}n{|=a|crrHn\bv{t-rp@-}n{|>a|crrH0v{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{K0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=9-=;=9-=;=9->;=60qrsv{r-]Vl?-C;?E@>EB?rp?-|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-<-]Vl?9-urn-<-]V6H\f|vq-znv{56-\n--rpA-qvssrP|y|-J-rpA5qvssr9-|vtv{\\}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--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=Zn}9-}n{|=a|crr6H--0vs-qrsv{rq5b`RlaVYR6----rp?-vyrlp||q-J-|P||q5}n{|=a|crr6H----rpA-vyrlpyv}H----rpA-vyrlqnNH----rp?-vyrlH----sy|n-vyrlny}unH----0}ntzn-{|yyly||}lnH----s|-5v{-v-J-=H-v-I-aVYRlZN]]V[TlYR[TaUH-v886-\n------vyrlpyv}-J-}n{|avyrPyv}Zn}}v{thvjH------vyrlqnN-J-}n{|avyrQnNZn}}v{thvjH------vyrl;-J-5vyrlp||q;-:-vyrlpyv}h=j6-<-vyrlpyv}h?jH------vyrl;\b-J-5vyrlp||q;\b-:-vyrlpyv}h>j6-<-vyrlpyv}h@jH------vyrlny}un-J-5>;=-:-r}5=;B9-no5vyrl;-:-=;B666-7-5>;=-:-r}5=;B9-no5vyrl;\b-:-=;B666H------vyrl;-J-vyrlqnNh=j-8-vyrl;-7-vyrlqnNh?jH------vyrl;\b-J-vyrlqnNh>j-8-vyrl;\b-7-vyrlqnNh@jH------vyrlny}un-J-prvy5vyrlny}un-7-vyrlqnNh?j6H------}n{|=P|y|-J-zv5}n{|=P|y|9-rr?Q5}n{|avyrZn}9-vyrl69-vyrlny}un6H----\f----0}ntzn-{|yyly||}lr{q--0r{qvs--rpA-}n{|>P|y|-J-rrPor5}n{|>Zn}9-}n{|>a|crr6H--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----0vs-qrsv{rq5b`Rl]N[\\=lQR]aUlZN]6------rpA-}n{|=Qr}uP|y|-J-rrPor5}n{|=Qr}uZn}9-pnzrna|crr6H------sy|n-qrynQvn{pr=-J-no5{}npx_TONa|Qr}u5}n{|=Qr}uP|y|6-7->=;=-:-yr{tu5}n{|=a|crr66H------sy|n-ynry-J-pynz}5}|tr-7-5>;=-8-qrynQvn{pr=-7-=;FB69-=;=9->;=6H----0ryr------sy|n-ynry-J-}|trH----0r{qvs----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-ynry6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\lZN]6----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|ZnvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|`v\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|`v\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|Zn}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|Ny}un6H--0r{qvs--tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H--tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H\f"),ot=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.hash=qe(),t.meta=[null,null,null,null,null,null],t}return t.__extends(i,e),i}(a.CubeTexture);function at(){return"undefined"==typeof document?{}:document.createElementNS("http://www.w3.org/1999/xhtml","img")}var ut=at();ut.width=ut.height=8;var ct=new a.Texture(ut),lt=new ot([ut,ut,ut,ut,ut,ut]);ct.dispose=lt.dispose=function(){};var ht=Object.assign({modelAlpha:new a.Uniform(0),originOpacity:new a.Uniform(1),progress:new a.Uniform(0),pano0Map:new a.Uniform(null),pano0Matrix:new a.Uniform(new a.Matrix4),pano1Map:new a.Uniform(null),pano1Matrix:new a.Uniform(new a.Matrix4),pano0DepthMap:new a.Uniform(null),panoVideoMap:new a.Uniform(null),panoVideoSize:new a.Uniform(new a.Vector2),panoVideoMatrix:new a.Uniform(new a.Matrix4),panoVideoAlpha:new a.Uniform(0),modelCenter:new a.Uniform(new a.Vector3),perspToOrtho:new a.Uniform(0),panoTileMap:new a.Uniform(null),panoTileClipMappings:new a.Uniform([]),panoTileDrawAtMappings:new a.Uniform([])},{exposure:new a.Uniform(1),emissive:new a.Uniform(new a.Color(0)),emissiveMap:new a.Uniform(null),specular:new a.Uniform(new a.Color(1118481)),specularMap:new a.Uniform(null),normalMap:new a.Uniform(null),bumpMap:new a.Uniform(null),shininess:new a.Uniform(30)},a.UniformsLib.common,a.UniformsLib.lights),dt=function(e){function i(t){var i,n,r,s,o,u,c,l,h,d,A,p,M,f,g,y;void 0===t&&(t={});var v=e.call(this,{vertexShader:rt,fragmentShader:st,uniforms:a.UniformsUtils.clone(ht),defines:{USE_MAP:!0,USE_UV:!0,USE_TILE:!1,TILE_MAPPING_LENGTH:0,USE_BLACK_TRANSITION:!1,USE_PANO0_DEPTH_MAP:!1,USE_PANO_VIDEO_MAP:!1},lights:!0})||this;return Object.defineProperties(v,{pano0Map:{get:function(){var e=this.uniforms.pano0Map.value;return e===lt?null:e},set:function(e){this.uniforms.pano0Map.value=null===e?lt:e}},pano0Matrix:{get:function(){return this.uniforms.pano0Matrix.value.clone()},set:function(e){this.uniforms.pano0Matrix.value.copy(e)}},pano1Map:{get:function(){var e=this.uniforms.pano1Map.value;return e===lt?null:e},set:function(e){this.uniforms.pano1Map.value=null===e?lt:e}},pano1Matrix:{get:function(){return this.uniforms.pano1Matrix.value.clone()},set:function(e){this.uniforms.pano1Matrix.value.copy(e)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(e){this.uniforms.modelAlpha.value=e}},progress:{get:function(){return this.uniforms.progress.value},set:function(e){this.uniforms.progress.value=e}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(e){this.defines.USE_BLACK_TRANSITION!==e&&(this.defines.USE_BLACK_TRANSITION=e,this.needsUpdate=!0)}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},perspToOrtho:{get:function(){return this.uniforms.perspToOrtho.value},set:function(e){this.uniforms.perspToOrtho.value=e}},pano0DepthMap:{get:function(){return this.uniforms.pano0DepthMap.value},set:function(e){this.uniforms.pano0DepthMap.value=e;var t=null!==e;t!==this.defines.USE_PANO0_DEPTH_MAP&&(this.defines.USE_PANO0_DEPTH_MAP=t,this.needsUpdate=!0)}},panoVideoMap:{get:function(){return this.uniforms.panoVideoMap.value},set:function(e){this.uniforms.panoVideoMap.value=e;var t=null!==e;t!==this.defines.USE_PANO_VIDEO_MAP&&(this.defines.USE_PANO_VIDEO_MAP=t,this.needsUpdate=!0)}},panoVideoSize:{get:function(){return this.uniforms.panoVideoSize.value.clone()},set:function(e){this.uniforms.panoVideoSize.value.copy(e)}},panoVideoMatrix:{get:function(){return this.uniforms.panoVideoMatrix.value.clone()},set:function(e){this.uniforms.panoVideoMatrix.value.copy(e)}},panoVideoAlpha:{get:function(){return this.uniforms.panoVideoAlpha.value},set:function(e){this.uniforms.panoVideoAlpha.value=e}},panoTileMap:{get:function(){return this.uniforms.panoTileMap.value},set:function(e){this.uniforms.panoTileMap.value=e;var t=null!==e;t!==this.defines.USE_TILE&&(this.defines.USE_TILE=t,this.needsUpdate=!0)}},panoTileMappings:{get:function(){var e=this.uniforms.panoTileClipMappings.value,t=this.uniforms.panoTileDrawAtMappings.value;if(null===e)return null;for(var i=[],n=0;n<e.length;n++)i[n]=[e[n].clone(),t[n].clone()];return i},set:function(e){var t=this.defines.TILE_MAPPING_LENGTH;if(null===e)this.uniforms.panoTileClipMappings.value=null,this.uniforms.panoTileDrawAtMappings.value=null;else{for(var i=[],n=[],r=0;r<e.length;r++)i[r]=e[r][0].clone(),n[r]=e[r][1].clone();this.uniforms.panoTileClipMappings.value=i,this.uniforms.panoTileDrawAtMappings.value=n}var s=null!==e?e.length:0;s!==t&&(this.defines.TILE_MAPPING_LENGTH=s,this.needsUpdate=!0)}}}),v.pano0Map=null!==(i=t.pano0Map)&&void 0!==i?i:lt,v.pano0Matrix=null!==(n=t.pano0Matrix)&&void 0!==n?n:new a.Matrix4,v.pano1Map=null!==(r=t.pano1Map)&&void 0!==r?r:lt,v.pano1Matrix=null!==(s=t.pano1Matrix)&&void 0!==s?s:new a.Matrix4,v.modelAlpha=null!==(o=t.modelAlpha)&&void 0!==o?o:1,v.progress=null!==(u=t.progress)&&void 0!==u?u:0,v.useBlackTransition=null!==(c=t.useBlackTransition)&&void 0!==c&&c,v.perspToOrtho=null!==(l=t.perspToOrtho)&&void 0!==l?l:0,v.opacity=null!==(h=t.opacity)&&void 0!==h?h:1,v.pano0DepthMap=null!==(d=t.pano0DepthMap)&&void 0!==d?d:null,v.panoVideoSize=null!==(A=t.panoVideoSize)&&void 0!==A?A:new a.Vector2,v.panoVideoMap=null!==(p=t.panoVideoMap)&&void 0!==p?p:null,v.panoVideoMatrix=null!==(M=t.panoVideoMatrix)&&void 0!==M?M:new a.Matrix4,v.panoVideoAlpha=null!==(f=t.panoVideoAlpha)&&void 0!==f?f:0,v.panoTileMap=null!==(g=t.panoTileMap)&&void 0!==g?g:null,v.panoTileMappings=null!==(y=t.panoTileMappings)&&void 0!==y?y:null,v}return t.__extends(i,e),i}(a.ShaderMaterial),At=new a.Vector3(0,0,0),pt=function(e){function i(t,i){void 0===i&&(i=At);var n=e.call(this)||this,r=new a.BoxBufferGeometry(t.max.x-t.min.x+2*i.x,t.max.y-t.min.y+2*i.y,t.max.z-t.min.z+2*i.z,1,1);r.groups.length=0,r.groups.push({start:0,count:36,materialIndex:0}),r.applyMatrix4((new a.Matrix4).makeScale(-1,1,1));var s=new dt;s.defines.USE_MAP=!1,s.defines.USE_UV=!1,s.uniforms.diffuse.value=new a.Color(16777215);var o=new tt(r,[s]);return o.floorIndex=-1,o.position.copy(t.getCenter(new a.Vector3)),o.frustumCulled=!1,n.add(o),n}return t.__extends(i,e),i.prototype.dispose=function(){this.disposeMaterial(),this.disposeGeometry()},i}(nt);function Mt(e,t){return void 0===t&&(t=At),new pt(e,t)}var ft,gt,yt,vt,mt={};mt.EPSILON=1e-6,mt.BVHVector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},mt.BVHVector3.prototype={constructor:mt.BVHVector3,copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setFromArray:function(e,t){this.x=e[t],this.y=e[t+1],this.z=e[t+2]},add:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},cross:function(e){var t=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-t*e.z,this.z=t*e.y-i*e.x,this},crossVectors:function(e,t){var i=e.x,n=e.y,r=e.z,s=t.x,o=t.y,a=t.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this},clone:function(){return new mt.BVHVector3(this.x,this.y,this.z)}},mt.BVH=function(e,t){this._trianglesArray=e,this._maxTrianglesPerNode=t||10,this._bboxArray=this.calcBoundingBoxes(e),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var i=e.length/9,n=this.calcExtents(0,i,mt.EPSILON);this._rootNode=new mt.BVHNode(n[0],n[1],0,i,0),this._nodesToSplit=[this._rootNode]},mt.BVH.prototype.splitNode=function(e){if(e){var t=0,i=function(){t++;var n=this._nodesToSplit.pop();n?(this._splitNode(n),t%255==0?setTimeout(i):i()):(t=0,e())}.bind(this);i()}else for(;this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},mt.BVH.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit=null},mt.BVH.prototype.intersectRay=function(e,t,i){for(var n,r=[this._rootNode],s=[],o=[],a=new mt.BVHVector3(1/t.x,1/t.y,1/t.z);r.length>0;){var u=r.pop();if(mt.BVH.intersectNodeBox(e,a,u))for(u._node0&&r.push(u._node0),u._node1&&r.push(u._node1),n=u._startIndex;n<u._endIndex;n++)s.push(this._bboxArray[7*n])}var c=new mt.BVHVector3,l=new mt.BVHVector3,h=new mt.BVHVector3,d=new mt.BVHVector3(e.x,e.y,e.z),A=new mt.BVHVector3(t.x,t.y,t.z);for(n=0;n<s.length;n++){var p=s[n];c.setFromArray(this._trianglesArray,9*p),l.setFromArray(this._trianglesArray,9*p+3),h.setFromArray(this._trianglesArray,9*p+6);var M=mt.BVH.intersectRayTriangle(c,l,h,d,A,i);M&&o.push({triangle:[c.clone(),l.clone(),h.clone()],triangleIndex:p,intersectionPoint:M})}return o},mt.BVH.prototype.calcBoundingBoxes=function(e){for(var t,i,n,r,s,o,a,u,c,l,h,d,A,p,M,f=e.length/9,g=new Float32Array(7*f),y=0;y<f;y++)t=e[9*y],i=e[9*y+1],n=e[9*y+2],r=e[9*y+3],s=e[9*y+4],o=e[9*y+5],a=e[9*y+6],u=e[9*y+7],c=e[9*y+8],l=Math.min(Math.min(t,r),a),h=Math.min(Math.min(i,s),u),d=Math.min(Math.min(n,o),c),A=Math.max(Math.max(t,r),a),p=Math.max(Math.max(i,s),u),M=Math.max(Math.max(n,o),c),mt.BVH.setBox(g,y,y,l,h,d,A,p,M);return g},mt.BVH.prototype.calcExtents=function(e,t,i){if(i=i||0,e>=t)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];for(var n=Number.MAX_VALUE,r=Number.MAX_VALUE,s=Number.MAX_VALUE,o=-Number.MAX_VALUE,a=-Number.MAX_VALUE,u=-Number.MAX_VALUE,c=e;c<t;c++)n=Math.min(this._bboxArray[7*c+1],n),r=Math.min(this._bboxArray[7*c+2],r),s=Math.min(this._bboxArray[7*c+3],s),o=Math.max(this._bboxArray[7*c+4],o),a=Math.max(this._bboxArray[7*c+5],a),u=Math.max(this._bboxArray[7*c+6],u);return[{x:n-i,y:r-i,z:s-i},{x:o+i,y:a+i,z:u+i}]},mt.BVH.prototype._splitNode=function(e){if(!(e.elementCount()<=this._maxTrianglesPerNode||0===e.elementCount())){var t=e._startIndex,i=e._endIndex,n=[[],[],[]],r=[[],[],[]],s=[e.centerX(),e.centerY(),e.centerZ()],o=[e._extentsMax.x-e._extentsMin.x,e._extentsMax.y-e._extentsMin.y,e._extentsMax.z-e._extentsMin.z],a=[];a.length=3;for(var u=t;u<i;u++){a[0]=.5*(this._bboxArray[7*u+1]+this._bboxArray[7*u+4]),a[1]=.5*(this._bboxArray[7*u+2]+this._bboxArray[7*u+5]),a[2]=.5*(this._bboxArray[7*u+3]+this._bboxArray[7*u+6]);for(var c=0;c<3;c++)a[c]<s[c]?n[c].push(u):r[c].push(u)}var l=[];if(l.length=3,l[0]=0===n[0].length||0===r[0].length,l[1]=0===n[1].length||0===r[1].length,l[2]=0===n[2].length||0===r[2].length,!(l[0]&&l[1]&&l[2])){var h,d,A=[0,1,2];for(A.sort((function(e,t){return o[t]-o[e]})),c=0;c<3;c++){var p=A[c];if(!l[p]){h=n[p],d=r[p];break}}var M,f=t,g=f+h.length,y=g,v=i,m=e._startIndex,N=h.concat(d);for(u=0;u<N.length;u++)M=N[u],mt.BVH.copyBox(this._bboxArray,M,this._bboxHelper,m),m++;var D=this._bboxHelper.subarray(7*e._startIndex,7*e._endIndex);this._bboxArray.set(D,7*e._startIndex);var w=this.calcExtents(f,g,mt.EPSILON),T=this.calcExtents(y,v,mt.EPSILON),x=new mt.BVHNode(w[0],w[1],f,g,e._level+1),E=new mt.BVHNode(T[0],T[1],y,v,e._level+1);e._node0=x,e._node1=E,e.clearShapes(),this._nodesToSplit.push(x),this._nodesToSplit.push(E)}}},mt.BVH._calcTValues=function(e,t,i,n){var r={min:0,max:0};return n>=0?(r.min=(e-i)*n,r.max=(t-i)*n):(r.min=(t-i)*n,r.max=(e-i)*n),r},mt.BVH.intersectNodeBox=function(e,t,i){var n=mt.BVH._calcTValues(i._extentsMin.x,i._extentsMax.x,e.x,t.x),r=mt.BVH._calcTValues(i._extentsMin.y,i._extentsMax.y,e.y,t.y);if(n.min>r.max||r.min>n.max)return!1;(r.min>n.min||n.min!=n.min)&&(n.min=r.min),(r.max<n.max||n.max!=n.max)&&(n.max=r.max);var s=mt.BVH._calcTValues(i._extentsMin.z,i._extentsMax.z,e.z,t.z);return!(n.min>s.max||s.min>n.max)&&((s.min>n.min||n.min!=n.min)&&(n.min=s.min),(s.max<n.max||n.max!=n.max)&&(n.max=s.max),!(n.max<0))},mt.BVH.intersectRayTriangle=(ft=new mt.BVHVector3,gt=new mt.BVHVector3,yt=new mt.BVHVector3,vt=new mt.BVHVector3,function(e,t,i,n,r,s){gt.subVectors(t,e),yt.subVectors(i,e),vt.crossVectors(gt,yt);var o,a=r.dot(vt);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}ft.subVectors(n,e);var u=o*r.dot(yt.crossVectors(ft,yt));if(u<0)return null;var c=o*r.dot(gt.cross(ft));if(c<0)return null;if(u+c>a)return null;var l=-o*ft.dot(vt);if(l<0)return null;var h=l/a;return(new mt.BVHVector3).copy(r).multiplyScalar(h).add(n)}),mt.BVH.setBox=function(e,t,i,n,r,s,o,a,u){e[7*t]=i,e[7*t+1]=n,e[7*t+2]=r,e[7*t+3]=s,e[7*t+4]=o,e[7*t+5]=a,e[7*t+6]=u},mt.BVH.copyBox=function(e,t,i,n){i[7*n]=e[7*t],i[7*n+1]=e[7*t+1],i[7*n+2]=e[7*t+2],i[7*n+3]=e[7*t+3],i[7*n+4]=e[7*t+4],i[7*n+5]=e[7*t+5],i[7*n+6]=e[7*t+6]},mt.BVH.getBox=function(e,t,i){i.triangleId=e[7*t],i.minX=e[7*t+1],i.minY=e[7*t+2],i.minZ=e[7*t+3],i.maxX=e[7*t+4],i.maxY=e[7*t+5],i.maxZ=e[7*t+6]},mt.BVHNode=function(e,t,i,n,r){this._extentsMin=e,this._extentsMax=t,this._startIndex=i,this._endIndex=n,this._level=r,this._node0=null,this._node1=null},mt.BVHNode.prototype.elementCount=function(){return this._endIndex-this._startIndex},mt.BVHNode.prototype.centerX=function(){return.5*(this._extentsMin.x+this._extentsMax.x)},mt.BVHNode.prototype.centerY=function(){return.5*(this._extentsMin.y+this._extentsMax.y)},mt.BVHNode.prototype.centerZ=function(){return.5*(this._extentsMin.z+this._extentsMax.z)},mt.BVHNode.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1},mt.BVHNode.calcBoundingSphereRadius=function(e,t){var i=.5*(e.x+t.x),n=.5*(e.y+t.y),r=.5*(e.z+t.z),s=(i-e.x)*(i-e.x)+(n-e.y)*(n-e.y)+(r-e.z)*(r-e.z),o=(i-t.x)*(i-t.x)+(n-t.y)*(n-t.y)+(r-t.z)*(r-t.z);return Math.sqrt(Math.max(s,o))};var Nt=mt.BVH;var Dt,wt=(Dt="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<"+Dt+">$":Symbol(Dt));function Tt(e){return e[wt]||(e[wt]={}),e[wt]}var xt=function(){function e(){}return e.prototype.hasListener=function(e){var t=Tt(this);return t&&t[e]&&t[e].length>0},e.prototype.on=function(e,t,i){var n=this,r=Tt(this);return r[e]||(r[e]=[]),r[e].push([t,i||!1]),function(){return n.off(e,t)}},e.prototype.once=function(e,t){return this.on(e,t,!0)},e.prototype.off=function(e,t){if(void 0!==e){var i,n=Tt(this);if(n[e]||(n[e]=[]),void 0!==t){for(var r=0;r<n[e].length&&n[e][r][0]!==t;r++);r<n[e].length&&n[e].splice(r,1)}else n[e].length=0}else(i=this)[wt]||delete i[wt]},e.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=!1,r=Tt(this),s=r[e]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],c=u[0],l=u[1],h=void 0!==l&&l,d=c.apply(void 0,t);h&&this.off(e,c),!1===d&&(n=!0)}return n},e}();function Et(e){Object.freeze(e);var t="function"==typeof e,i=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach((function(n){!i.call(e,n)||t&&("caller"===n||"callee"===n||"arguments"===n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||Et(e[n])})),e}var jt=/^([^.]+)(\.([^.]+))*$/;function It(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function zt(e,t){return jt.test(e)&&function(e){if("*"===e)return/^(.+)$/i;var t="^"+e.split(".").map((function(e){return"*"===e?"([^.]+)":e})).join(".")+"$";return new RegExp(t,"i")}(e).test(t)}var bt=Et(JSON.parse(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("h--/y|pnyu|/9--/xr;p|z/9-------/7;xr;p|z/9-------/7;7;xr;p|z/9--/yvn{wvn;p|z/9--/7;yvn{wvn;p|z/9--/7;7;yvn{wvn;p|z/9--/rnyrr;p|z/9--/7;rnyrr;p|z/9--/7;7;rnyrr;p|z/9--/rnyrr;p{/9---/7;rnyrr;p{/9---/7;7;rnyrr;p{/9--/uv;p|z/9--/7;uv;p|z/9--/7;7;uv;p|z/9--/uv;p{/9---/7;uv;p{/9---/7;7;uv;p{/9--/ywpq{;p|z/9----/7;ywpq{;p|z/9----/7;7;ywpq{;p|z/j"))),Lt=function(e){function i(t,i){var n=e.call(this,"[NETWORK]: response error(status: "+i+"): "+t)||this;return n.httpStatus=i,n}return t.__extends(i,e),i}(Error),St=function(e){function i(t){return e.call(this,"[NETWORK]: request abort: "+t)||this}return t.__extends(i,e),i}(Error),Ot=function(e){function i(t,i){return e.call(this,"[NETWORK]: request timeout("+i+"ms): "+t)||this}return t.__extends(i,e),i}(Error),Ct=function(e){function i(t,i){return e.call(this,"[NETWORK]: request forbidden: "+t+", "+i)||this}return t.__extends(i,e),i}(Error);var Pt=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i}(xt);function kt(e,t,i,n){void 0===t&&(t={}),void 0===i&&(i=He),void 0===n&&(n=He);var r,s=t.allowHosts?bt.concat(t.allowHosts):bt.slice(),o=(r=e.match(/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/))?r[2]:location.hostname;if(0!==location.hostname.length&&!It(location.hostname)&&0===bt.filter((function(e){return zt(e,location.hostname)})).length&&!It(o)&&0===s.filter((function(e){return zt(e,o)})).length){var a=He,u=new Ct(e,"request host("+o+") is not allowed");return Ke((function(){var n;i(u,null),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"forbidden",u.message)})),{abort:a}}var c=function(e){for(var t=0,i=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i];t<i.length;t++){var n=i[t],r=e.match(n);if(r)return"jsonp_"+r[1]}return null}(e);if(c){var l=window,h=null,d=!1,A=Ze(),p=document.createElement("script");return l[c]=function(n){var r,s=Ze(),o=s-A;if(delete l[c],p.parentNode&&p.parentNode.removeChild(p),null!==h&&(window.clearTimeout(h),h=null),!0!==d){if(0!==n.indexOf("data:")){var a=new Lt(e,500);return i(a,null),void(null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"error",a.message))}var u=n.split(","),M=(u[0].match(/:(.*?);/)||[])[1],f=u[1];if("arraybuffer"===t.responseType||"blob"===t.responseType){for(var g=atob(u[1]),y=g.length,v=new Uint8Array(y),m=0;m<y;m++)v[m]=g.charCodeAt(m);f="arraybuffer"===t.responseType?v.buffer:new Blob([v],{type:M})}var N={body:f,meta:{source:e,requestTime:A,responseTime:s,costs:o,headers:{}}};Ke((function(){var n;i(null,N),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"ok",JSON.stringify(N.meta))})),d=!0}},p.src=e,document.body.appendChild(p),"number"==typeof t.timeout&&(h=window.setTimeout((function(){var n;if(h=null,!0!==d){var r=new Ot(e,t.timeout||NaN);i(r,null),d=!0,null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"timeout",r.message)}}),t.timeout)),{abort:function(){var n;if(delete l[c],p.parentNode&&p.parentNode.removeChild(p),null!==h&&(window.clearTimeout(h),h=null),!0!==d){var r=new St(e);i(r,null),d=!0,null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"abort",r.message)}}}}var M=Ze(),f=!1,g=new XMLHttpRequest,y=function(){g&&(g.removeEventListener("timeout",v,!1),g.removeEventListener("progress",m,!1),g.removeEventListener("abort",N,!1),g.removeEventListener("load",D,!1),g.removeEventListener("error",w,!1)),g=null,y=He},v=function(){var n,r=new Ot(e,t.timeout||NaN);i(r,null),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"timeout",r.message)},m=function(e){if(!0!==f&&e.lengthComputable){var t=e.loaded,i=e.total;n(t/i,t,i)}},N=function(){var n;if(!0!==f){var r=new St(e);i(r,null),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"abort",r.message)}},D=function(){var n,r=Ze(),s=r-M,o=function(e){if(!e)return{};for(var t={},i=e.trim().split("\n"),n=0;n<i.length;n++){var r=i[n],s=r.indexOf(":"),o=r.slice(0,s).trim().toLowerCase(),a=r.slice(s+1).trim();a&&(t[o]?t[o]+=", "+a:t[o]=a)}return t}(this.getAllResponseHeaders()),a={body:this.response,meta:{source:e,requestTime:M,responseTime:r,costs:s,headers:o}};i(null,a),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"ok",JSON.stringify(a.meta))},w=function(){var n,r=new Lt(e,this.status);i(r,null),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"error",r.message),f=!0,y()};return g.addEventListener("timeout",v,!1),g.addEventListener("progress",m,!1),g.addEventListener("abort",N,!1),g.addEventListener("load",D,!1),g.addEventListener("error",w,!1),t.responseType&&(g.responseType=t.responseType),"number"==typeof t.timeout&&(g.timeout=t.timeout),g.open("GET",e,!0),g.send(null),{abort:N}}kt.async=function(e,t){return new Promise((function(i,n){kt(e,t,(function(e,t){e?n(e):i(t)}))}))};var Bt={};function Ut(e,t){if(void 0===t&&(t={}),"function"==typeof t.transform)return t.transform(e,t);if(e.indexOf("//vrlab-public.ljcdn.com")>=0&&(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),/\.(jpg|png)$/.test(e))){var i=t.size,n=t.quality,r=t.format;if(i||n||r){var s="?imageMogr2";n&&(s+="/quality/"+n),i&&(s+="/thumbnail/"+i+"x"),r&&(s+="/format/"+r),e=e.replace("//vrlab-public.ljcdn.com","//vrlab-image4.ljcdn.com")+s}}return e}var Qt=function(){function e(e){void 0===e&&(e={}),this.allowHosts=e.allowHosts,this.networkSubscribe=e.networkSubscribe}return e.prototype.load=function(e,t,i,n){return void 0===t&&(t=He),void 0===i&&(i=He),void 0===n&&(n=He),this.loadToImage(at(),e,t,i,n)},e.prototype.loadToImage=function(e,t,i,n,r){if(void 0===i&&(i=He),void 0===r&&(r=He),e.src)throw new Error("image is loaded");var s={responseType:"blob",allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe};kt(t,s,(function(n,s){n?r(n):(e.onload=function(){i(e),e.onload=e.onerror=function(){}},e.onerror=function(){r(new Error("image parse error "+t)),e.onload=e.onerror=function(){}},e.src=URL.createObjectURL(s.body))}))},e}(),_t=null,Rt=!1,Yt=[];function Ft(e){if(void 0===e&&(e=!1),e||!Rt)if(_t)Rt=!1;else{Rt=!0;var t=Yt.shift();if(t){try{t()}catch(e){}Ke((function(){return Ft(!0)}))}else Rt=!1}}function Vt(){_t=null,Ft()}function Ht(){(_t||0!==Yt.length)&&(_t&&clearTimeout(_t),_t=window.setTimeout(Vt,200))}function Gt(e){return new Promise((function(t){Yt.push((function(){return t(e())})),Ft()}))}var qt,Wt={computeTangents:function(e){var t=e.index,i=e.attributes;if(null!==t&&void 0!==i.position&&void 0!==i.normal&&void 0!==i.uv){var n=t.array,r=i.position.array,s=i.normal.array,o=i.uv.array,u=r.length/3;void 0===i.tangent&&e.setAttribute("tangent",new a.BufferAttribute(new Float32Array(4*u),4));for(var c=i.tangent.array,l=[],h=[],d=0;d<u;d++)l[d]=new a.Vector3,h[d]=new a.Vector3;var A=new a.Vector3,p=new a.Vector3,M=new a.Vector3,f=new a.Vector2,g=new a.Vector2,y=new a.Vector2,v=new a.Vector3,m=new a.Vector3,N=e.groups;0===N.length&&(N=[{start:0,count:n.length}]);d=0;for(var D=N.length;d<D;++d)for(var w=O=(S=N[d]).start,T=O+S.count;w<T;w+=3)C(n[w+0],n[w+1],n[w+2]);var x,E,j,I=new a.Vector3,z=new a.Vector3,b=new a.Vector3,L=new a.Vector3;for(d=0,D=N.length;d<D;++d){var S,O;for(w=O=(S=N[d]).start,T=O+S.count;w<T;w+=3)P(n[w+0]),P(n[w+1]),P(n[w+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function C(e,t,i){A.fromArray(r,3*e),p.fromArray(r,3*t),M.fromArray(r,3*i),f.fromArray(o,2*e),g.fromArray(o,2*t),y.fromArray(o,2*i);var n=p.x-A.x,s=M.x-A.x,a=p.y-A.y,u=M.y-A.y,c=p.z-A.z,d=M.z-A.z,N=g.x-f.x,D=y.x-f.x,w=g.y-f.y,T=y.y-f.y,x=1/(N*T-D*w);v.set((T*n-w*s)*x,(T*a-w*u)*x,(T*c-w*d)*x),m.set((N*s-D*n)*x,(N*u-D*a)*x,(N*d-D*c)*x),l[e].add(v),l[t].add(v),l[i].add(v),h[e].add(m),h[t].add(m),h[i].add(m)}function P(e){b.fromArray(s,3*e),L.copy(b),E=l[e],I.copy(E),I.sub(b.multiplyScalar(b.dot(E))).normalize(),z.crossVectors(L,E),j=z.dot(h[e]),x=j<0?-1:1,c[4*e]=I.x,c[4*e+1]=I.y,c[4*e+2]=I.z,c[4*e+3]=x}},mergeBufferGeometries:function(e,t){for(var i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),s={},o={},u=new a.BufferGeometry,c=0,l=0;l<e.length;++l){var h=e[l];if(i!==(null!==h.index))return null;for(var d in h.attributes){if(!n.has(d))return null;void 0===s[d]&&(s[d]=[]),s[d].push(h.attributes[d])}for(var d in h.morphAttributes){if(!r.has(d))return null;void 0===o[d]&&(o[d]=[]),o[d].push(h.morphAttributes[d])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(h.userData),t){var A;if(i)A=h.index.count;else{if(void 0===h.attributes.position)return null;A=h.attributes.position.count}u.addGroup(c,A,l),c+=A}}if(i){var p=0,M=[];for(l=0;l<e.length;++l){for(var f=e[l].index,g=0;g<f.count;++g)M.push(f.getX(g)+p);p+=e[l].attributes.position.count}u.setIndex(M)}for(var d in s){var y=this.mergeBufferAttributes(s[d]);if(!y)return null;u.setAttribute(d,y)}for(var d in o){var v=o[d][0].length;if(0===v)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[d]=[];for(l=0;l<v;++l){var m=[];for(g=0;g<o[d].length;++g)m.push(o[d][g][l]);var N=this.mergeBufferAttributes(m);if(!N)return null;u.morphAttributes[d].push(N)}}return u},mergeBufferAttributes:function(e){for(var t,i,n,r=0,s=0;s<e.length;++s){var o=e[s];if(o.isInterleavedBufferAttribute)return null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return null;r+=o.array.length}var u=new t(r),c=0;for(s=0;s<e.length;++s)u.set(e[s].array,c),c+=e[s].array.length;return new a.BufferAttribute(u,i,n)},interleaveAttributes:function(e){for(var t,i=0,n=0,r=0,s=e.length;r<s;++r){var o=e[r];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;i+=o.array.length,n+=o.itemSize}var u=new a.InterleavedBuffer(new t(i),n),c=0,l=[],h=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"],A=0;for(s=e.length;A<s;A++){var p=(o=e[A]).itemSize,M=o.count,f=new a.InterleavedBufferAttribute(u,p,c,o.normalized);l.push(f),c+=p;for(var g=0;g<M;g++)for(var y=0;y<p;y++)f[d[y]](g,o[h[y]](g))}return l},estimateBytesUsed:function(e){var t=0;for(var i in e.attributes){var n=e.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0},mergeVertices:function(e,t){void 0===t&&(t=1e-4),t=Math.max(t,Number.EPSILON);for(var i={},n=e.getIndex(),r=e.getAttribute("position"),s=n?n.count:r.count,o=0,u=Object.keys(e.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],A=0,p=u.length;A<p;A++){c[m=u[A]]=[],(T=e.morphAttributes[m])&&(l[m]=new Array(T.length).fill().map((function(){return[]})))}var M=Math.log10(1/t),f=Math.pow(10,M);for(A=0;A<s;A++){var g=n?n.getX(A):A,y="",v=0;for(p=u.length;v<p;v++)for(var m=u[v],N=(w=e.getAttribute(m)).itemSize,D=0;D<N;D++)y+=~~(w[d[D]](g)*f)+",";if(y in i)h.push(i[y]);else{for(v=0,p=u.length;v<p;v++){m=u[v];var w=e.getAttribute(m),T=e.morphAttributes[m],x=(N=w.itemSize,c[m]),E=l[m];for(D=0;D<N;D++){var j=d[D];if(x.push(w[j](g)),T)for(var I=0,z=T.length;I<z;I++)E[I].push(T[I][j](g))}}i[y]=o,h.push(o),o++}}var b=e.clone();for(A=0,p=u.length;A<p;A++){m=u[A];var L=e.getAttribute(m),S=new L.array.constructor(c[m]);w=new a.BufferAttribute(S,L.itemSize,L.normalized);if(b.setAttribute(m,w),m in l)for(v=0;v<l[m].length;v++){var O=e.morphAttributes[m][v],C=(S=new O.array.constructor(l[m][v]),new a.BufferAttribute(S,O.itemSize,O.normalized));b.morphAttributes[m][v]=C}}return b.setIndex(h),b}};var Zt='\nvar config, transcoderPending, _BasisFile;\nself.onmessage = function(e) {\n var message = e.data;\n switch (message.type) {\n case "init":\n config = message.config;\n init(message.transcoderBinary);\n break;\n case "transcode":\n transcoderPending.then(function() {\n try {\n var result = transcode(message.buffer);\n var width = result.width;\n var height = result.height;\n var hasAlpha = result.hasAlpha;\n var mipmaps = result.mipmaps;\n var format = result.format;\n var buffers = [];\n for (var i = 0; i < mipmaps.length; ++i) {\n buffers.push(mipmaps[i].data.buffer);\n }\n self.postMessage({ type: "transcode", id: message.id, width, height, hasAlpha, mipmaps, format }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n }\n });\n break;\n default: break;\n }\n};\n\nfunction init(wasmBinary) {\n var BasisModule;\n transcoderPending = new Promise(function(resolve) {\n BasisModule = { wasmBinary, onRuntimeInitialized: resolve };\n BASIS(BasisModule); // eslint-disable-line no-undef\n }).then(function() {\n _BasisFile = BasisModule.BasisFile;\n BasisModule.initializeBasis();\n self.postMessage({ type: "initialized" });\n });\n}\n\nfunction transcode(buffer) {\n var basisFile = new _BasisFile(new Uint8Array(buffer));\n var width = basisFile.getImageWidth(0, 0);\n var height = basisFile.getImageHeight(0, 0);\n var levels = basisFile.getNumLevels(0);\n var hasAlpha = basisFile.getHasAlpha();\n function cleanup() {\n basisFile.close();\n basisFile.delete();\n }\n if (!hasAlpha) {\n switch (config.format) {\n case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA\n config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;\n break;\n default: break;\n }\n }\n if (!width || !height || !levels) {\n cleanup();\n throw new Error("BasisTextureLoader: Invalid .basis file");\n }\n if (!basisFile.startTranscoding()) {\n cleanup();\n throw new Error("BasisTextureLoader: .startTranscoding failed");\n }\n var mipmaps = [];\n for (var mip = 0; mip < levels; mip++) {\n var mipWidth = basisFile.getImageWidth(0, mip);\n var mipHeight = basisFile.getImageHeight(0, mip);\n var dst = new Uint8Array(basisFile.getImageTranscodedSizeInBytes(0, mip, config.format));\n var status = basisFile.transcodeImage(dst, 0, mip, config.format, 0, hasAlpha);\n if (!status) {\n cleanup();\n throw new Error("BasisTextureLoader: .transcodeImage failed.");\n }\n mipmaps.push({ data: dst, width: mipWidth, height: mipHeight });\n }\n cleanup();\n return { width, height, hasAlpha, mipmaps, format: config.format };\n}\n',Xt={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7_M6_OPAQUE_ONLY:6,cTFBC7_M5:7,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16},Kt={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779},Jt=((qt={})[Xt.cTFBC1]=Kt.COMPRESSED_RGB_S3TC_DXT1_EXT,qt[Xt.cTFBC3]=Kt.COMPRESSED_RGBA_S3TC_DXT5_EXT,qt),$t=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.allowHosts=t.allowHosts,i.networkSubscribe=t.networkSubscribe,i}return t.__extends(i,e),i.setTranscoderPath=function(e){return this.transcoderPath=e,this},i.setWorkerLimit=function(e){return this.workerLimit=e,this},i.isInitialized=function(){return 0!==this.workerPool.filter((function(e){return e._initialized})).length},i.detectSupport=function(e){var t=this.workerConfig;if(t.astcSupported=!!e.extensions.get("WEBGL_compressed_texture_astc"),t.bptcSupported=!!e.extensions.get("EXT_texture_compression_bptc"),t.etcSupported=!!e.extensions.get("WEBGL_compressed_texture_etc1"),t.dxtSupported=!!e.extensions.get("WEBGL_compressed_texture_s3tc"),t.pvrtcSupported=!!e.extensions.get("WEBGL_compressed_texture_pvrtc")||!!e.extensions.get("WEBKIT_WEBGL_compressed_texture_pvrtc"),t.astcSupported)t.format=i.BASIS_FORMAT.cTFASTC_4x4;else if(t.bptcSupported)t.format=i.BASIS_FORMAT.cTFBC7_M5;else if(t.dxtSupported)t.format=i.BASIS_FORMAT.cTFBC3;else if(t.pvrtcSupported)t.format=i.BASIS_FORMAT.cTFPVRTC1_4_RGBA;else{if(!t.etcSupported)throw new Error("BasisTextureLoader: No suitable compressed texture format found.");t.format=i.BASIS_FORMAT.cTFETC1}return this},i.prototype.load=function(e,t,n,r){return kt(e,{responseType:"arraybuffer",allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe},(function(n,s){if(n)r(n);else{var o=function(e){return t(e,s.meta)},a=s.body;if(i.taskCache.has(a))return i.taskCache.get(a).promise.then(o).catch(r);i._createTexture(a,e).then(o).catch(r)}}),n)},i._createTexture=function(e,t){var n,r,s=this,o=e.byteLength,u=this._allocateWorker(o).then((function(t){return n=t,r=s.workerNextTaskID++,new Promise((function(t,i){n._callbacks[r]={resolve:t,reject:i},n.postMessage({type:"transcode",id:r,buffer:e},[e])}))})).then((function(e){var t,i=s.workerConfig,n=e.width,r=e.height,o=e.mipmaps;switch(e.format){case Xt.cTFASTC_4x4:t=new a.CompressedTexture(o,n,r,a.RGBA_ASTC_4x4_Format);break;case Xt.cTFBC1:case Xt.cTFBC3:t=new a.CompressedTexture(o,n,r,Jt[i.format],a.UnsignedByteType);break;case Xt.cTFETC1:t=new a.CompressedTexture(o,n,r,a.RGB_ETC1_Format);break;case Xt.cTFPVRTC1_4_RGB:t=new a.CompressedTexture(o,n,r,a.RGB_PVRTC_4BPPV1_Format);break;case Xt.cTFPVRTC1_4_RGBA:t=new a.CompressedTexture(o,n,r,a.RGBA_PVRTC_4BPPV1_Format);break;default:throw new Error("BasisTextureLoader: No supported format available.")}return t.minFilter=1===o.length?a.LinearFilter:a.LinearMipmapLinearFilter,t.magFilter=a.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t}));return u.catch((function(){return!0})).then((function(){n&&r&&(n._taskLoad-=o,delete n._callbacks[r])})),i.taskCache.set(e,{url:t,promise:u}),u},i._initTranscoder=function(){var e=this;if(!this.transcoderPending){var t=new a.FileLoader;t.setPath(this.transcoderPath);var i=new Promise((function(e,i){t.load("basis_transcoder.js",e,void 0,i)})),n=new a.FileLoader;n.setPath(this.transcoderPath),n.setResponseType("arraybuffer");var r=new Promise((function(e,t){n.load("basis_transcoder.wasm",e,void 0,t)}));this.transcoderPending=Promise.all([i,r]).then((function(t){var i=t[0],n=t[1],r=["/* basis_transcoder.js */",i,"/* worker */",Zt].join("\n");e.workerSourceURL=URL.createObjectURL(new Blob([r])),e.transcoderBinary=n}))}return this.transcoderPending},i._allocateWorker=function(e){var t=this;return this._initTranscoder().then((function(){if(t.workerPool.length<t.workerLimit){var i=function(e){var t=new Worker(e);return Object.assign(t,{_callbacks:{},_initialized:!1,_taskLoad:0})}(t.workerSourceURL);i._callbacks={},i._initialized=!1,i._taskLoad=0,i.postMessage({type:"init",config:t.workerConfig,transcoderBinary:t.transcoderBinary}),i.onmessage=function(e){var t=e.data;switch(t.type){case"initialized":i._initialized=!0,console.log("BasisTextureLoader: basis loader initialized");break;case"transcode":i._callbacks[t.id].resolve(t);break;case"error":i._callbacks[t.id].reject(t);break;default:console.error('BasisTextureLoader: Unexpected message, "'+t.type+'"')}},t.workerPool.push(i)}else t.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n=t.workerPool[t.workerPool.length-1];return n._taskLoad+=e,n}))},i.prototype.dispose=function(){for(var e=0;e<i.workerPool.length;e++)i.workerPool[e].terminate();return i.workerPool.length=0,this},i.taskCache=new WeakMap,i.BASIS_FORMAT=Xt,i.DXT_FORMAT=Kt,i.DXT_FORMAT_MAP=Jt,i.transcoderPath="https://vrlab-public.ljcdn.com/release/static/image/release/five/basis/",i.transcoderBinary=null,i.transcoderPending=null,i.workerLimit=1,i.workerPool=[],i.workerNextTaskID=1,i.workerSourceURL="",i.workerConfig={format:null,astcSupported:!1,bptcSupported:!1,etcSupported:!1,dxtSupported:!1,pvrtcSupported:!1},i}(a.Loader),ei=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function ti(e,t){return new a.BufferAttribute(e,t)}function ii(e){var t=e.match(/(group|floor)-?(\d+)/);return t?parseInt(t[2],10):0}function ni(e){var t=e.match(/(chunk)-?(\d+)/);return t?parseInt(t[2],10):0}function ri(e){var t=e.indices,i=e.vertices,n=e.uvs,r=new a.BufferGeometry;return r.setIndex(ti(new Uint32Array(t),1)),r.setAttribute("position",ti(new Float32Array(i),3)),Ve(n)||r.setAttribute("uv",ti(new Float32Array(n),2)),r.applyMatrix4(ei),r.computeVertexNormals(),r}function si(e,t,i,n){var r=$t.isInitialized();e=Ut(e,Object.assign({key:"texture",basisLoaderInitialized:r},t));var s=new $t({allowHosts:i,networkSubscribe:n});if(/\.basis(\?|$)/.test(e)){var o={sourceFile:e,needsUpdate:!0,wrapS:a.ClampToEdgeWrapping,wrapT:a.ClampToEdgeWrapping,minFilter:a.LinearFilter};return new Promise((function(t,i){s.load(e,(function(e){t(Object.assign(e,o))}),(function(){}),(function(e){i(e)}))}))}var u={sourceFile:e,needsUpdate:!0,wrapS:a.ClampToEdgeWrapping,wrapT:a.ClampToEdgeWrapping,minFilter:a.LinearFilter},c=new Qt({allowHosts:i,networkSubscribe:n});return new Promise((function(t,i){c.load(e,(function(e){var i=new a.Texture(e),n=i.dispose;i.dispose=function(){n.call(i),/^blob\:/.test(e.src)&&URL.revokeObjectURL(e.src)},t(Object.assign(i,u))}),He,(function(e){return i(e)}))}))}function oi(e){var t=new dt;return e.catch((function(){return null})).then((function(e){t.uniforms.map.value=e,t.uniforms.exposure.value=3.3})),t}var ai=u.parse("\nmessage Model {\n repeated Chunk chunks = 1;\n}\nmessage Chunk {\n required Vertices vertices = 1;\n required Faces faces = 2;\n required string name = 3;\n optional string texture = 4;\n}\nmessage Vertices {\n repeated float xyz = 1 [packed=true];\n repeated float uvs = 2 [packed=true];\n}\nmessage Faces {\n repeated uint32 indices = 1 [packed=true];\n}\n").root.lookup("Model");function ui(e,t,i,n,r,s,o){void 0===r&&(r={});for(var u=0,c=e;u<c.length;u++){var l=c[u];l.chunkName=ni(l.name),l.floorName=ii(l.name),l.texture&&(l.texture=i[l.chunkName]=i[l.chunkName]||t+l.texture)}e.sort((function(e,t){return 1e3*e.floorName+e.chunkName-(1e3*t.floorName+t.chunkName)}));var h=[],d=[],A=Promise.resolve();return(A=(A=A.then((function(){return Gt((function(){for(var t=0;t<e.length;t++){var i=e[t],u=ii(i.name),c=h[u]=h[u]||{geometries:[],materials:[]},l=ri({vertices:i.vertices.xyz,uvs:i.vertices.uvs,indices:i.faces.indices});if(l.name="model_geo_chunk_"+t,c.geometries.push(l),i.texture){(d=oi(i.texture in r?r[i.texture]:r[i.texture]=si(i.texture,n,s,o))).name="model_mtl_chunk_"+t,c.materials.push(d)}else{var d;(d=new dt).defines.USE_MAP=!1,d.uniforms.color.value=new a.Color(16777215),d.name="model_mtl_chunk_"+t,c.materials.push(d)}}}))}))).then((function(){return Gt((function(){for(var e=0;e<h.length;e++){var t=h[e];if(t){var i=Wt.mergeBufferGeometries(t.geometries,!0);t.geometries.forEach((function(e){return e.dispose()}));var n=new tt(i,t.materials);n.floorIndex=e,n.name="model_floor_"+e,d.push(n)}}}))}))).then((function(){var e=Object.keys(r).map((function(e){return r[e].then((function(){}))}));return Promise.all(e).then((function(){return d}))}))}function ci(e,t){return!1!==(e=Object.assign({},e)).autoResize&&(t>96?e.size=Math.min(e.size||1/0,100):t>48?e.size=Math.min(e.size||1/0,200):t>24?e.size=Math.min(e.size||1/0,400):t>12&&(e.size=Math.min(e.size||1/0,800))),e}var li={OutWindow:function(){this._windowSize=0}};li.OutWindow.prototype.create=function(e){this._buffer&&this._windowSize===e||(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},li.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(0!==e){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},li.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},li.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},li.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},li.OutWindow.prototype.copyBlock=function(e,t){var i=this._pos-e-1;for(i<0&&(i+=this._windowSize);t--;)i>=this._windowSize&&(i=0),this._buffer[this._pos++]=this._buffer[i++],this._pos>=this._windowSize&&this.flush()},li.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},li.OutWindow.prototype.getByte=function(e){var t=this._pos-e-1;return t<0&&(t+=this._windowSize),this._buffer[t]},li.RangeDecoder=function(){},li.RangeDecoder.prototype.setStream=function(e){this._stream=e},li.RangeDecoder.prototype.releaseStream=function(){this._stream=null},li.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},li.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t,i=0,n=e;n--;)this._range>>>=1,t=this._code-this._range>>>31,this._code-=this._range&t-1,i=i<<1|1-t,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return i},li.RangeDecoder.prototype.decodeBit=function(e,t){var i=e[t],n=(this._range>>>11)*i;return(2147483648^this._code)<(2147483648^n)?(this._range=n,e[t]+=2048-i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,e[t]-=i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},li.initBitModels=function(e,t){for(;t--;)e[t]=1024},li.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},li.BitTreeDecoder.prototype.init=function(){li.initBitModels(this._models,1<<this._numBitLevels)},li.BitTreeDecoder.prototype.decode=function(e){for(var t=1,i=this._numBitLevels;i--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},li.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t,i=1,n=0,r=0;r<this._numBitLevels;++r)i=i<<1|(t=e.decodeBit(this._models,i)),n|=t<<r;return n},li.reverseDecode2=function(e,t,i,n){for(var r,s=1,o=0,a=0;a<n;++a)s=s<<1|(r=i.decodeBit(e,t+s)),o|=r<<a;return o},li.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new li.BitTreeDecoder(8),this._numPosStates=0},li.LenDecoder.prototype.create=function(e){for(;this._numPosStates<e;++this._numPosStates)this._lowCoder[this._numPosStates]=new li.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new li.BitTreeDecoder(3)},li.LenDecoder.prototype.init=function(){var e=this._numPosStates;for(li.initBitModels(this._choice,2);e--;)this._lowCoder[e].init(),this._midCoder[e].init();this._highCoder.init()},li.LenDecoder.prototype.decode=function(e,t){return 0===e.decodeBit(this._choice,0)?this._lowCoder[t].decode(e):0===e.decodeBit(this._choice,1)?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},li.Decoder2=function(){this._decoders=[]},li.Decoder2.prototype.init=function(){li.initBitModels(this._decoders,768)},li.Decoder2.prototype.decodeNormal=function(e){var t=1;do{t=t<<1|e.decodeBit(this._decoders,t)}while(t<256);return 255&t},li.Decoder2.prototype.decodeWithMatchByte=function(e,t){var i,n,r=1;do{if(i=t>>7&1,t<<=1,r=r<<1|(n=e.decodeBit(this._decoders,(1+i<<8)+r)),i!==n){for(;r<256;)r=r<<1|e.decodeBit(this._decoders,r);break}}while(r<256);return 255&r},li.LiteralDecoder=function(){},li.LiteralDecoder.prototype.create=function(e,t){var i;if(!this._coders||this._numPrevBits!==t||this._numPosBits!==e)for(this._numPosBits=e,this._posMask=(1<<e)-1,this._numPrevBits=t,this._coders=[],i=1<<this._numPrevBits+this._numPosBits;i--;)this._coders[i]=new li.Decoder2},li.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},li.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((255&t)>>>8-this._numPrevBits)]},li.Decoder=function(){this._outWindow=new li.OutWindow,this._rangeDecoder=new li.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new li.BitTreeDecoder(4),this._lenDecoder=new li.LenDecoder,this._repLenDecoder=new li.LenDecoder,this._literalDecoder=new li.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new li.BitTreeDecoder(6),this._posSlotDecoder[1]=new li.BitTreeDecoder(6),this._posSlotDecoder[2]=new li.BitTreeDecoder(6),this._posSlotDecoder[3]=new li.BitTreeDecoder(6)},li.Decoder.prototype.setDictionarySize=function(e){return!(e<0)&&(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},li.Decoder.prototype.setLcLpPb=function(e,t,i){var n=1<<i;return!(e>8||t>4||i>4)&&(this._literalDecoder.create(t,e),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},li.Decoder.prototype.init=function(){var e=4;for(this._outWindow.init(!1),li.initBitModels(this._isMatchDecoders,192),li.initBitModels(this._isRep0LongDecoders,192),li.initBitModels(this._isRepDecoders,12),li.initBitModels(this._isRepG0Decoders,12),li.initBitModels(this._isRepG1Decoders,12),li.initBitModels(this._isRepG2Decoders,12),li.initBitModels(this._posDecoders,114),this._literalDecoder.init();e--;)this._posSlotDecoder[e].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},li.Decoder.prototype.decode=function(e,t,i){var n,r,s,o,a,u,c=0,l=0,h=0,d=0,A=0,p=0,M=0;for(this._rangeDecoder.setStream(e),this._outWindow.setStream(t),this.init();i<0||p<i;)if(n=p&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(c<<4)+n))r=this._literalDecoder.getDecoder(p++,M),M=c>=7?r.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(l)):r.decodeNormal(this._rangeDecoder),this._outWindow.putByte(M),c=c<4?0:c-(c<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,c))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,c)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(c<<4)+n)&&(c=c<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,c)?o=h:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,c)?o=d:(o=A,A=d),d=h),h=l,l=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),c=c<7?8:11);else if(A=d,d=h,h=l,s=2+this._lenDecoder.decode(this._rangeDecoder,n),c=c<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(l=(2|1&a)<<(u=(a>>1)-1),a<14)l+=li.reverseDecode2(this._posDecoders,l-a-1,this._rangeDecoder,u);else if(l+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(l+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===l)break;return!1}}else l=a;if(l>=p||l>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(l,s),p+=s,M=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},li.Decoder.prototype.setDecoderProperties=function(e){var t,i,n,r,s;return!(e.size<5)&&(i=(t=e.readByte())%9,n=(t=~~(t/9))%5,r=~~(t/5),!!this.setLcLpPb(i,n,r)&&(s=e.readByte(),s|=e.readByte()<<8,s|=e.readByte()<<16,s+=16777216*e.readByte(),this.setDictionarySize(s)))},li.decompress=function(e,t,i,n){var r=new li.Decoder;if(!r.setDecoderProperties(e))throw"Incorrect stream properties";if(!r.decode(t,i,n))throw"Error in data stream";return!0},li.decompressFile=function(e,t){var i,n=new li.Decoder;if(!n.setDecoderProperties(e))throw"Incorrect stream properties";if(i=e.readByte(),i|=e.readByte()<<8,i|=e.readByte()<<16,i+=16777216*e.readByte(),e.readByte(),e.readByte(),e.readByte(),e.readByte(),!n.decode(e,t,i))throw"Error in data stream";return!0};var hi="undefined"!=typeof Worker&&"undefined"!=typeof Blob,di="";if(hi)try{var Ai=new Blob(['\n self.onmessage = function (event) {\n var Packet = event.data;\n var Result = null;\n try {\n if (!Packet.PacketID) {\n throw new Error(\'No incoming id.\');\n }\n if (!Packet.Data) {\n throw new Error(\'No input data.\');\n }\n if (Packet.Type == \'compress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n // C: encoding data\n Result = Util.compressFile(Packet.Data, null, Packet.Level, null);\n } else if (Packet.Type == \'decompress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n var inStream = {\n data: Packet.Data,\n offset: 0,\n readByte () {\n return this.data[this.offset++];\n }\n };\n var partLength = inStream.data.length;\n var outStream = {\n data: [],\n offset: 0,\n writeByte (value) {\n var partIndex = Math.floor(this.offset / partLength);\n if (!this.data[partIndex]) {\n this.data[partIndex] = new Uint8Array(partLength);\n }\n this.data[partIndex][this.offset % partLength] = value;\n this.offset++;\n }\n }\n // C: decoding data\n\n LZMA.decompressFile(inStream, outStream);\n Result = new Uint8Array(outStream.offset)\n for (var i = 0; i < outStream.offset; i++) {\n Result[i] = outStream.data[Math.floor(i / partLength)][i % partLength];\n }\n }\n postMessage({ PacketID: Packet.PacketID, Result, Error: null }, [Result.buffer]);\n } catch (error) {\n postMessage({ PacketID: Packet.PacketID, Error: error.toString() });\n }\n };\n\n\n /*\n Copyright (c) 2011 Juan Mellado\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the "Software"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n /*\n References:\n - "LZMA SDK" by Igor Pavlov\n http://www.7-zip.org/sdk.html\n */\n\n var LZMA = LZMA || {};\n\n LZMA.OutWindow = function(){\n this._windowSize = 0;\n };\n\n LZMA.OutWindow.prototype.create = function(windowSize){\n if ( (!this._buffer) || (this._windowSize !== windowSize) ){\n this._buffer = [];\n }\n this._windowSize = windowSize;\n this._pos = 0;\n this._streamPos = 0;\n };\n\n LZMA.OutWindow.prototype.flush = function(){\n var size = this._pos - this._streamPos;\n if (size !== 0){\n while(size --){\n this._stream.writeByte(this._buffer[this._streamPos ++]);\n }\n if (this._pos >= this._windowSize){\n this._pos = 0;\n }\n this._streamPos = this._pos;\n }\n };\n\n LZMA.OutWindow.prototype.releaseStream = function(){\n this.flush();\n this._stream = null;\n };\n\n LZMA.OutWindow.prototype.setStream = function(stream){\n this.releaseStream();\n this._stream = stream;\n };\n\n LZMA.OutWindow.prototype.init = function(solid){\n if (!solid){\n this._streamPos = 0;\n this._pos = 0;\n }\n };\n\n LZMA.OutWindow.prototype.copyBlock = function(distance, len){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n while(len --){\n if (pos >= this._windowSize){\n pos = 0;\n }\n this._buffer[this._pos ++] = this._buffer[pos ++];\n if (this._pos >= this._windowSize){\n this.flush();\n }\n }\n };\n\n LZMA.OutWindow.prototype.putByte = function(b){\n this._buffer[this._pos ++] = b;\n if (this._pos >= this._windowSize){\n this.flush();\n }\n };\n\n LZMA.OutWindow.prototype.getByte = function(distance){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n return this._buffer[pos];\n };\n\n LZMA.RangeDecoder = function(){\n };\n\n LZMA.RangeDecoder.prototype.setStream = function(stream){\n this._stream = stream;\n };\n\n LZMA.RangeDecoder.prototype.releaseStream = function(){\n this._stream = null;\n };\n\n LZMA.RangeDecoder.prototype.init = function(){\n var i = 5;\n\n this._code = 0;\n this._range = -1;\n\n while(i --){\n this._code = (this._code << 8) | this._stream.readByte();\n }\n };\n\n LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits){\n var result = 0, i = numTotalBits, t;\n\n while(i --){\n this._range >>>= 1;\n t = (this._code - this._range) >>> 31;\n this._code -= this._range & (t - 1);\n result = (result << 1) | (1 - t);\n\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n }\n\n return result;\n };\n\n LZMA.RangeDecoder.prototype.decodeBit = function(probs, index){\n var prob = probs[index],\n newBound = (this._range >>> 11) * prob;\n\n if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ){\n this._range = newBound;\n probs[index] += (2048 - prob) >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 0;\n }\n\n this._range -= newBound;\n this._code -= newBound;\n probs[index] -= prob >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 1;\n };\n\n LZMA.initBitModels = function(probs, len){\n while(len --){\n probs[len] = 1024;\n }\n };\n\n LZMA.BitTreeDecoder = function(numBitLevels){\n this._models = [];\n this._numBitLevels = numBitLevels;\n };\n\n LZMA.BitTreeDecoder.prototype.init = function(){\n LZMA.initBitModels(this._models, 1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){\n var m = 1, i = this._numBitLevels;\n\n while(i --){\n m = (m << 1) | rangeDecoder.decodeBit(this._models, m);\n }\n return m - (1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < this._numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(this._models, m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(models, startIndex + m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.LenDecoder = function(){\n this._choice = [];\n this._lowCoder = [];\n this._midCoder = [];\n this._highCoder = new LZMA.BitTreeDecoder(8);\n this._numPosStates = 0;\n };\n\n LZMA.LenDecoder.prototype.create = function(numPosStates){\n for (; this._numPosStates < numPosStates; ++ this._numPosStates){\n this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n }\n };\n\n LZMA.LenDecoder.prototype.init = function(){\n var i = this._numPosStates;\n LZMA.initBitModels(this._choice, 2);\n while(i --){\n this._lowCoder[i].init();\n this._midCoder[i].init();\n }\n this._highCoder.init();\n };\n\n LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState){\n if (rangeDecoder.decodeBit(this._choice, 0) === 0){\n return this._lowCoder[posState].decode(rangeDecoder);\n }\n if (rangeDecoder.decodeBit(this._choice, 1) === 0){\n return 8 + this._midCoder[posState].decode(rangeDecoder);\n }\n return 16 + this._highCoder.decode(rangeDecoder);\n };\n\n LZMA.Decoder2 = function(){\n this._decoders = [];\n };\n\n LZMA.Decoder2.prototype.init = function(){\n LZMA.initBitModels(this._decoders, 0x300);\n };\n\n LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){\n var symbol = 1;\n\n do{\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte){\n var symbol = 1, matchBit, bit;\n\n do{\n matchBit = (matchByte >> 7) & 1;\n matchByte <<= 1;\n bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);\n symbol = (symbol << 1) | bit;\n if (matchBit !== bit){\n while(symbol < 0x100){\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }\n break;\n }\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.LiteralDecoder = function(){\n };\n\n LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){\n var i;\n\n if (this._coders\n && (this._numPrevBits === numPrevBits)\n && (this._numPosBits === numPosBits) ){\n return;\n }\n this._numPosBits = numPosBits;\n this._posMask = (1 << numPosBits) - 1;\n this._numPrevBits = numPrevBits;\n\n this._coders = [];\n\n i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i] = new LZMA.Decoder2();\n }\n };\n\n LZMA.LiteralDecoder.prototype.init = function(){\n var i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i].init();\n }\n };\n\n LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte){\n return this._coders[( (pos & this._posMask) << this._numPrevBits)\n + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )];\n };\n\n LZMA.Decoder = function(){\n this._outWindow = new LZMA.OutWindow();\n this._rangeDecoder = new LZMA.RangeDecoder();\n this._isMatchDecoders = [];\n this._isRepDecoders = [];\n this._isRepG0Decoders = [];\n this._isRepG1Decoders = [];\n this._isRepG2Decoders = [];\n this._isRep0LongDecoders = [];\n this._posSlotDecoder = [];\n this._posDecoders = [];\n this._posAlignDecoder = new LZMA.BitTreeDecoder(4);\n this._lenDecoder = new LZMA.LenDecoder();\n this._repLenDecoder = new LZMA.LenDecoder();\n this._literalDecoder = new LZMA.LiteralDecoder();\n this._dictionarySize = -1;\n this._dictionarySizeCheck = -1;\n\n this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);\n };\n\n LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize){\n if (dictionarySize < 0){\n return false;\n }\n if (this._dictionarySize !== dictionarySize){\n this._dictionarySize = dictionarySize;\n this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);\n this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );\n }\n return true;\n };\n\n LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){\n var numPosStates = 1 << pb;\n\n if (lc > 8 || lp > 4 || pb > 4){\n return false;\n }\n\n this._literalDecoder.create(lp, lc);\n\n this._lenDecoder.create(numPosStates);\n this._repLenDecoder.create(numPosStates);\n this._posStateMask = numPosStates - 1;\n\n return true;\n };\n\n LZMA.Decoder.prototype.init = function(){\n var i = 4;\n\n this._outWindow.init(false);\n\n LZMA.initBitModels(this._isMatchDecoders, 192);\n LZMA.initBitModels(this._isRep0LongDecoders, 192);\n LZMA.initBitModels(this._isRepDecoders, 12);\n LZMA.initBitModels(this._isRepG0Decoders, 12);\n LZMA.initBitModels(this._isRepG1Decoders, 12);\n LZMA.initBitModels(this._isRepG2Decoders, 12);\n LZMA.initBitModels(this._posDecoders, 114);\n\n this._literalDecoder.init();\n\n while(i --){\n this._posSlotDecoder[i].init();\n }\n\n this._lenDecoder.init();\n this._repLenDecoder.init();\n this._posAlignDecoder.init();\n this._rangeDecoder.init();\n };\n\n LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize){\n var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,\n posState, decoder2, len, distance, posSlot, numDirectBits;\n\n this._rangeDecoder.setStream(inStream);\n this._outWindow.setStream(outStream);\n\n this.init();\n\n while(outSize < 0 || nowPos64 < outSize){\n posState = nowPos64 & this._posStateMask;\n\n if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0){\n decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);\n\n if (state >= 7){\n prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );\n }else{\n prevByte = decoder2.decodeNormal(this._rangeDecoder);\n }\n this._outWindow.putByte(prevByte);\n\n state = state < 4? 0: state - (state < 10? 3: 6);\n\n }else{\n\n if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){\n len = 0;\n if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){\n if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0){\n state = state < 7? 9: 11;\n len = 1;\n }\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){\n distance = rep1;\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){\n distance = rep2;\n }else{\n distance = rep3;\n rep3 = rep2;\n }\n rep2 = rep1;\n }\n rep1 = rep0;\n rep0 = distance;\n }\n if (len === 0){\n len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 8: 11;\n }\n }else{\n rep3 = rep2;\n rep2 = rep1;\n rep1 = rep0;\n\n len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 7: 10;\n\n posSlot = this._posSlotDecoder[len <= 5? len - 2: 3].decode(this._rangeDecoder);\n if (posSlot >= 4){\n\n numDirectBits = (posSlot >> 1) - 1;\n rep0 = (2 | (posSlot & 1) ) << numDirectBits;\n\n if (posSlot < 14){\n rep0 += LZMA.reverseDecode2(this._posDecoders,\n rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);\n }else{\n rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;\n rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);\n if (rep0 < 0){\n if (rep0 === -1){\n break;\n }\n return false;\n }\n }\n }else{\n rep0 = posSlot;\n }\n }\n\n if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){\n return false;\n }\n\n this._outWindow.copyBlock(rep0, len);\n nowPos64 += len;\n prevByte = this._outWindow.getByte(0);\n }\n }\n\n this._outWindow.flush();\n this._outWindow.releaseStream();\n this._rangeDecoder.releaseStream();\n\n return true;\n };\n\n LZMA.Decoder.prototype.setDecoderProperties = function(properties){\n var value, lc, lp, pb, dictionarySize;\n\n if (properties.size < 5){\n return false;\n }\n\n value = properties.readByte();\n lc = value % 9;\n value = ~~(value / 9);\n lp = value % 5;\n pb = ~~(value / 5);\n\n if ( !this.setLcLpPb(lc, lp, pb) ){\n return false;\n }\n\n dictionarySize = properties.readByte();\n dictionarySize |= properties.readByte() << 8;\n dictionarySize |= properties.readByte() << 16;\n dictionarySize += properties.readByte() * 16777216;\n\n return this.setDictionarySize(dictionarySize);\n };\n\n LZMA.decompress = function(properties, inStream, outStream, outSize){\n var decoder = new LZMA.Decoder();\n\n if ( !decoder.setDecoderProperties(properties) ){\n throw "Incorrect stream properties";\n }\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n\n LZMA.decompressFile = function(inStream, outStream){\n var decoder = new LZMA.Decoder(), outSize;\n\n if ( !decoder.setDecoderProperties(inStream) ){\n throw "Incorrect stream properties";\n }\n\n outSize = inStream.readByte();\n outSize |= inStream.readByte() << 8;\n outSize |= inStream.readByte() << 16;\n outSize += inStream.readByte() * 16777216;\n\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n'],{type:"text/javascript"});di=URL.createObjectURL(Ai)}catch(e){}var pi=function(){function e(){var e=this;if(this.callCounter=0,this.requests=[],!hi)throw new Error("LZMACaller cannot work in this broswer.");var t=this.worker=new Worker(di);t.onmessage=function(t){var i,n,r=t.data,s=r.PacketID,o=r.Result,a=r.Error;a?null===(n=e.requests[s])||void 0===n||n.onCompleteCallback(new Error(a)):null===(i=e.requests[s])||void 0===i||i.onCompleteCallback(null,o),delete e.requests[s]},t.onerror=function(e){return console.error(e)}}return e.prototype.compress=function(e,t,i){var n=++this.callCounter;this.requests[n]={onCompleteCallback:i},this.worker.postMessage({Type:"compress",PacketID:n,Data:e,Level:t},[e.buffer])},e.prototype.decompress=function(e,t){var i=++this.callCounter;this.requests[i]={onCompleteCallback:t},this.worker.postMessage({Type:"decompress",PacketID:i,Data:e},[e.buffer])},e.prototype.terminate=function(){this.worker.terminate()},e.support=hi,e}();function Mi(e){return Array.prototype.reduce.call(e,(function(e,t,i){return e|t<<8*i}),0)}function fi(e){for(var t=new Uint8Array(e),i=Mi(t.slice(0,4)),n=[],r=[],s=4+4*i,o=0;o<i;o++)r[o]=Mi(t.slice(4+4*o,8+4*o)),n[o]=o===i-1?t.subarray(s,s+r[o]):t.slice(s,s+r[o]),s+=r[o];return pi.support?function(e){for(var t=[],i=e.length,n=function(i){t.push(new Promise((function(t,n){var r=new pi;r.decompress(e[i],(function(e,i){if(r.terminate(),e)return n(e);t(i)}))})))},r=0;r<i;r++)n(r);return Promise.all(t)}(n):Promise.resolve(function(e){for(var t,i=[],n=e.length,r=function(n){var r={data:e[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=r.data.length,o={data:[],offset:0,writeByte:function(e){var t=Math.floor(this.offset/s);this.data[t]||(this.data[t]=new Uint8Array(s)),this.data[t][this.offset%s]=e,this.offset++}};li.decompressFile(r,o),t=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)t[a]=o.data[Math.floor(a/s)][a%s];i.push(t)},s=0;s<n;s++)r(s);return i}(n))}function gi(e){return 0===e.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(e)}var yi=u.parse("\nmessage Model {\n repeated Mesh meshes = 1;\n}\nmessage Mesh {\n required string name = 1;\n repeated Chunk chunks = 2;\n repeated Matrix matrix = 3;\n}\nmessage Matrix {\n repeated float elements = 1;\n}\nmessage Chunk {\n required Geometry geometry = 2;\n repeated Material material = 3;\n}\nmessage Geometry {\n required Position position = 1;\n optional UV uv = 2;\n optional UV uv2 = 3;\n required Normal normal = 4;\n repeated Group groups = 5;\n}\nmessage Position {\n repeated float array = 1[packed=true];\n}\nmessage UV {\n repeated float array = 1[packed=true];\n}\nmessage Normal {\n repeated float array = 1[packed=true];\n}\nmessage Group {\n required uint32 start = 1;\n required uint32 count = 2;\n required uint32 materialIndex = 3;\n}\nmessage Material {\n optional Color kd = 1;\n optional Color ks = 2;\n optional Color ke = 3;\n optional string mapkd = 4;\n optional string mapks = 5;\n optional string mapke = 6;\n optional string norm = 7;\n optional string mapbump = 8;\n optional string bump = 9;\n optional string mapd = 10;\n optional float ns = 11;\n optional float d = 12;\n optional float tr = 13;\n optional string mapkdrepeat = 14;\n}\nmessage Color {\n repeated float rgb = 1;\n}\n").root.lookup("Model");var vi={};function mi(e,t,i,n,r){var s,o=[],u=[];function c(e,s,o){var c=function(e){var t=e.position,i=e.normal,n=e.uv,r=e.uv2,s=e.groups,o=new a.BufferGeometry;return o.setAttribute("position",new a.BufferAttribute(new Float32Array(t.array),3)),i&&o.setAttribute("normal",new a.BufferAttribute(new Float32Array(i.array),3)),n&&o.setAttribute("uv",new a.BufferAttribute(new Float32Array(n.array),2)),r&&o.setAttribute("uv2",new a.BufferAttribute(new Float32Array(r.array),2)),s.forEach((function(e){return o.addGroup(e.start,e.count,e.materialIndex)})),o}(e);c.applyMatrix4(o);var l=new a.Vector3,h=new a.Quaternion,d=new a.Vector3;o.decompose(l,h,d),d.x*d.y*d.z<0&&c.attributes.normal&&c.attributes.position&&c.attributes.uv&&function(e){for(var t=[0,0,0],i=0;i<e.attributes.normal.array.length/9;i++)t[0]=e.attributes.normal.array[9*i],t[1]=e.attributes.normal.array[9*i+1],t[2]=e.attributes.normal.array[9*i+2],e.attributes.normal.array[9*i]=e.attributes.normal.array[9*i+6],e.attributes.normal.array[9*i+1]=e.attributes.normal.array[9*i+7],e.attributes.normal.array[9*i+2]=e.attributes.normal.array[9*i+8],e.attributes.normal.array[9*i+6]=t[0],e.attributes.normal.array[9*i+7]=t[1],e.attributes.normal.array[9*i+8]=t[2];for(i=0;i<e.attributes.position.array.length/9;i++)t[0]=e.attributes.position.array[9*i],t[1]=e.attributes.position.array[9*i+1],t[2]=e.attributes.position.array[9*i+2],e.attributes.position.array[9*i]=e.attributes.position.array[9*i+6],e.attributes.position.array[9*i+1]=e.attributes.position.array[9*i+7],e.attributes.position.array[9*i+2]=e.attributes.position.array[9*i+8],e.attributes.position.array[9*i+6]=t[0],e.attributes.position.array[9*i+7]=t[1],e.attributes.position.array[9*i+8]=t[2];for(i=0;i<e.attributes.uv.array.length/6;i++)t[0]=e.attributes.uv.array[6*i],t[1]=e.attributes.uv.array[6*i+1],e.attributes.uv.array[6*i]=e.attributes.uv.array[6*i+4],e.attributes.uv.array[6*i+1]=e.attributes.uv.array[6*i+5],e.attributes.uv.array[6*i+4]=t[0],e.attributes.uv.array[6*i+5]=t[1];e.attributes.normal.needsUpdate=!0,e.attributes.position.needsUpdate=!0,e.attributes.uv.needsUpdate=!0}(c);var A=s.map((function(e){var s=function(e,t,i,n,r){var s={sourceFile:null,needsUpdate:!0,wrapS:a.RepeatWrapping,wrapT:a.RepeatWrapping};function o(e,o){return vi[e]?Promise.resolve(vi[e]):new Promise((function(u,c){var l=new Qt({allowHosts:n,networkSubscribe:r});gi(e)||(e=t+e),-1!==(e=(e=e.replace(/\/\/vrlab-image\d*.ljcdn.com\//,"//vrlab-public.ljcdn.com/")).split("?")[0]).indexOf(".png")&&(e=e.split(".png")[0]+".png"),-1!==e.indexOf(".jpg")&&(e=e.split(".jpg")[0]+".jpg"),0===e.indexOf("//")&&(e="https:"+e),e=Ut(e,Object.assign({key:"texture"},i,{size:64})),l.load(e,(function(t){var i=new a.Texture(t),n=i.dispose;i.dispose=function(){n.call(i),/^blob\:/.test(t.src)&&URL.revokeObjectURL(t.src)},o&&Object.assign(i.repeat,o),Object.assign(i,s,{sourceFile:e}),i.updateMatrix(),vi[e]=i,u(i)}),He,(function(e){return c(e.error)}))}))}var u=[],c=new dt,l=c.uniforms;l.exposure.value=4.3;var h,d=c.defines;if(d.USE_MAP=!1,d.USE_UV=!1,e.hasOwnProperty("kd")&&(l.diffuse.value=(new a.Color).fromArray(e.kd.rgb)),e.hasOwnProperty("mapkd")){var A=void 0;if(e.mapkdrepeat){var p=e.mapkdrepeat.split(/\s+/).map((function(e){return Number(e)})),M=p[0],f=p[1];A=new a.Vector2(M,f)}u.push(o(e.mapkd,A).then((function(e){d.USE_MAP=!0,d.USE_UV=!0,l.map.value=e,l.uvTransform.value=e.matrix})).catch((function(e){})))}return e.hasOwnProperty("ks")&&(l.specular.value=(new a.Color).fromArray(e.ks.rgb)),e.hasOwnProperty("mapks")&&u.push(o(e.mapks).then((function(e){l.specularMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ke")&&(l.emissive.value=(new a.Color).fromArray(e.ke.rgb)),e.hasOwnProperty("mapke")&&u.push(o(e.mapke).then((function(e){l.emissiveMap.value=e})).catch((function(e){}))),e.hasOwnProperty("norm")&&u.push(o(e.norm).then((function(e){l.normalMap.value=e})).catch((function(e){}))),e.hasOwnProperty("mapbump")&&u.push(o(e.mapbump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("bump")&&u.push(o(e.bump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ns")&&(l.shininess.value=e.ns),e.hasOwnProperty("d")&&(h=e.d)>=0&&h<1&&(l.originOpacity.value=h),e.hasOwnProperty("tr")&&(h=1-e.tr)>=0&&h<1&&(l.originOpacity.value=h),l.originOpacity.value<1&&(c.transparent=!0),{material:c,textureReady:Promise.all(u).then((function(){}))}}(e,t,i,n,r),o=s.material,c=s.textureReady;return u.push(c),o}));return new tt(c,A)}return(s=e,yi.decode(s)).meshes.forEach((function(e){var t=e.name,i=e.chunks,n=e.matrix;"Ceiling"!==t&&"CeilingDrop"!==t&&n.map((function(e){var n,r=new a.Matrix4;if(r.elements=e.elements,1===i.length){var s=i[0],u=s.geometry,l=s.material;n=c(u,l,r)}else n=new nt,i.forEach((function(e,t){var i=c(e.geometry,e.material,r);i.name="chunk"+t,n.add(i)}));n.floorIndex=0,n.name=t,o.push(n)}))})),Promise.all(u).catch((function(){})).then((function(){return o}))}function Ni(){Object.keys(vi).forEach((function(e){vi[e].dispose(),delete vi[e]}))}function Di(e){var i;return new((i=a.Triangle).bind.apply(i,t.__spreadArray([void 0],e.map((function(e){return new a.Vector3(e.x,e.y,e.z)})),!1)))}var wi={at3d:function(e,t){for(var i=ci(t.imageOptions,e.textures.length),n={},r=0,s=e.textures;r<s.length;r++){var o=s[r];n[o]=si(o,i,t.allowHosts,t.networkSubscribe)}var a={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return kt.async(e.file,a)})).then((function(e){return fi(e.body)})).then((function(e){return Gt((function(){for(var t=[],i=0,n=e;i<n.length;i++){var r=n[i],s=ai.decode(r);t.push.apply(t,s.chunks)}return t}))})).then((function(r){return Gt((function(){return ui(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},pbm:function(e,t){for(var i=ci(t.imageOptions,e.textures.length),n={},r=0,s=e.textures;r<s.length;r++){var o=s[r];n[o]=si(o,i,t.allowHosts,t.networkSubscribe)}var a={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return kt.async(e.file,a)})).then((function(e){return Gt((function(){var t=new Uint8Array(e.body),i=ai.decode(t);return[].concat(i.chunks)}))})).then((function(r){return Gt((function(){return ui(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},dome:function(e,t){var i={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return Ni()})).then((function(){return kt.async(e.file,i)})).then((function(i){return mi(new Uint8Array(i.body),e.textureBase,t.imageOptions,t.allowHosts,t.networkSubscribe)}))},domez:function(e,t){var i={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return Ni()})).then((function(){return kt.async(e.file,i)})).then((function(e){return fi(e.body)})).then((function(e){var t=e.reduce((function(e,t){return e+t.length}),0),i=new Uint8Array(t),n=0;return e.forEach((function(e){i.set(e,n),n+=e.length})),i})).then((function(i){return mi(i,e.textureBase,t.imageOptions,t.allowHosts,t.networkSubscribe)}))}},Ti=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.empty=!1,i.name="model",i.loaded=!1,i.bvhs=[],i.bounding=new a.Box3,i.shownFloor=null,i.floorLength=0,i.networkSubscribe=t.networkSubscribe,i.allowHosts=t.allowHosts,i}return t.__extends(i,e),Object.defineProperty(i.prototype,"shownfloor",{get:function(){return this.shownFloor},enumerable:!1,configurable:!0}),i.prototype.getEdges=function(e){var t;void 0===e&&(e=30/180*Math.PI);for(var i=Math.cos(e),n=[],r=0,s=this.children;r<s.length;r++){var o=s[r];if(o instanceof tt){for(var u={},c=["a","b","c"],l=Wt.mergeVertices(o.geometry),h=l.getAttribute("position").array,d=(null===(t=l.getIndex())||void 0===t?void 0:t.array)||[],A=[],p=[],M=0,f=h.length;M<f;M+=3)A.push(new a.Vector3(h[M],h[M+1],h[M+2]));for(M=0,f=d.length;M<f;M+=3){var g=d[M],y=d[M+1],v=d[M+2],m=(new a.Vector3).crossVectors(A[y].clone().sub(A[g]),A[v].clone().sub(A[g])).normalize();p.push({a:g,b:y,c:v,normal:m})}for(M=0,f=p.length;M<f;M++)for(var N=p[M],D=0;D<3;D++){var w=N[c[D]],T=N[c[(D+1)%3]],x=[Math.min(w,T),Math.max(w,T)];void 0===u[E=x[0]+"-"+x[1]]?u[E]={index1:x[0],index2:x[1],face1:M}:u[E].face2=M}for(var E in u){var j=u[E];if(void 0===j.face2||p[j.face1].normal.dot(p[j.face2].normal)<=i){var I=A[j.index1],z=A[j.index2];n.push(new a.Line3(I,z))}}l.dispose(),A.length=0,p.length=0}}return n},i.prototype.hasFloors=function(){return this.hasFloors_()},i.prototype.hasFloors_=function(){var e=[];return this.traverse((function(t){t instanceof tt&&(e[t.floorIndex]=!0)})),e.length},i.prototype.show=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=this.shownFloor,r=null,s=null!==(e=t[1])&&void 0!==e?e:.1,o=0!==t.length;this.shownFloor=r=o?t[0]:null,this.traverse((function(e){e instanceof tt&&e.material.forEach((function(t){null===r||r===e.floorIndex?t.opacity=1:t.opacity=s}))})),n!==this.shownFloor&&this.emit("shownFloorChange",this.shownFloor,this.floorLength),this.needsRender=!0},i.prototype.intersectRaycaster=function(e,t){var i=e.ray,n=i.origin,r=i.direction;if(Ve(t))if(Ve(this.shownFloor)){var s=this.floorLength;t=[];for(var o=0;o<s;o++)t.push(o)}else t=[this.shownFloor];var u=[],c=[];Array.isArray(t)?c.push.apply(c,t):c.push(t);for(var l=function(t){var i=h.bvhs&&h.bvhs[t];if(i){(s=i.intersectRay(n,r,!0).map((function(e){var t=e.intersectionPoint,i=e.triangle,r=new a.Vector3(t.x,t.y,t.z);return{point:r,face:{normal:Di(i).getNormal(new a.Vector3)},distance:n.distanceTo(r)}}))).length&&u.push.apply(u,s)}else{var s,o=[];h.traverse((function(e){e instanceof tt&&e.floorIndex===t&&o.push(e)})),(s=e.intersectObjects(o).map((function(e){var t=e.face?{normal:e.face.normal}:void 0;return{point:e.point,face:t,distance:e.distance}}))).length&&u.push.apply(u,s)}},h=this,d=0,A=c;d<A.length;d++){l(A[d])}return u.filter((function(t){var i=t.distance;return i<=e.far&&i>=e.near})).sort((function(e,t){return e.distance-t.distance}))},i.prototype.buildBVH=function(){var e=this,t=[];this.traverse((function(e){e instanceof tt&&(t[e.floorIndex]=t[e.floorIndex]||[],t[e.floorIndex].push(e.geometry))}));var i=t.map((function(e){var t=e.reduce((function(e,t){return e+(t.index?t.index.array.length:t.attributes.position.array.length)}),0),i=new Float32Array(3*t);return e.reduce((function(e,t){for(var n=t.index?t.index.array:null,r=t.attributes.position.array,s=n?n.length:r.length/3,o=0;o<s;o++){var a=3*(e+o),u=n?3*n[o]:3*o;i[a+0]=r[u+0],i[a+1]=r[u+1],i[a+2]=r[u+2]}return e+s}),0),new Nt(i,5)}));return this.bvhs=[],Promise.all(i.map((function(e){return new Promise((function(t){return e.splitNode(t)}))}))).then((function(){e.bvhs=i,e.bvhs.loaded=!0,e.emit("bvhLoaded")}))},i.prototype.load=function(e,t){var i=this;if(void 0===t&&(t={}),!0===this.loaded)throw new Error("[MODEL LOAD ERROR]: model cannot load twice.");var n=function(e,t){void 0===t&&(t=[]);var i=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(e);if(!i)return"";for(var n=0,r=String(i[1]).trim().split(".").slice(1).reverse();n<r.length;n++){var s=r[n],o=t.indexOf(s);if(o>=0)return t[o]}return""}(e.file,Object.keys(wi)),r=wi[n];if(!r)throw new Error("[MODEL LOAD ERROR]: file type("+n+") does not support.");return r(e,{imageOptions:t,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe}).then((function(e){for(var t=[],n=0,r=e;n<r.length;n++){(c=r[n]).traverse((function(e){e instanceof tt&&(e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),t.push(e.geometry.boundingBox))})),i.add(c)}i.floorLength=i.hasFloors_(),i.bounding=function(e){for(var t=new a.Box3,i=0,n=e;i<n.length;i++){var r=n[i];t.union(r)}return t}(t);for(var s=i.bounding.getCenter(new a.Vector3),o=0,u=e;o<u.length;o++){var c;(c=u[o]).traverse((function(e){e instanceof tt&&e.material.forEach((function(e){e.uniforms.modelCenter.value=s}))}))}t.length=0,i.emit("geometryLoaded"),i.emit("materialLoaded"),i.loaded=!0,Ke((function(){return i.emit("loaded")}))})).catch((function(e){return i.emit("error",e),Promise.reject(e)}))},i.prototype.dispose=function(){for(this.off(),this.disposeGeometry(),this.disposeMaterial();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},i}(it);function xi(e){switch(e.getError()){case e.INVALID_ENUM:return new Error("webgl error: INVALID_ENUM");case e.INVALID_VALUE:return new Error("webgl error: INVALID_VALUE");case e.INVALID_OPERATION:return new Error("webgl error: INVALID_OPERATION");case e.INVALID_FRAMEBUFFER_OPERATION:return new Error("webgl error: INVALID_FRAMEBUFFER_OPERATION");case e.OUT_OF_MEMORY:return new Error("webgl error: OUT_OF_MEMORY");case e.CONTEXT_LOST_WEBGL:return new Error("webgl error: CONTEXT_LOST_WEBGL");default:return null}}Object.assign(Ti.prototype,{on:xt.prototype.on,once:xt.prototype.once,off:xt.prototype.off,emit:xt.prototype.emit,hasListener:xt.prototype.hasListener});var Ei=c.default.Tween,ji=c.default.Easing;function Ii(e,t,i,n){void 0===n&&(n=ji.Linear.None);var r=[],s=[],o=[],a=[],u=Object.assign(new Ei(e).to(t,i).easing(n),{completed:!1,onCancel:function(e){return r.push(e),u},destroy:function(){if(u.stop(),Object.assign(this,{_onStartCallback:null,_onUpdateCallback:null,_onCompleteCallback:null,_onStopCallback:null}),!u.completed)for(var e=0,t=r;e<t.length;e++){(0,t[e])()}r.length=0,c()}});Object.assign(u,{onStart:function(e){return s.push(e),u},onUpdate:function(e){return o.push(e),u},onComplete:function(e){return a.push(e),u},_onStartCallback:function(e){for(var t=0,i=s;t<i.length;t++){(0,i[t])(e)}},_onUpdateCallback:function(e,t){for(var i=0,n=o;i<n.length;i++){(0,n[i])(e,t)}1===t&&0===u._repeat&&(u.completed=!0)},_onCompleteCallback:function(e){for(var t=0,i=a;t<i.length;t++){(0,i[t])(e)}}}),Ke((function(){return u.start()}));var c=Je((function(e){!1===u.update(e)&&c()}));return u}function zi(e,t){return Ii({progress:0},{progress:1},e,t)}var bi=2*Math.PI;function Li(e){return(e%bi+bi)%bi}var Si=Math.PI,Oi=2*Si;function Ci(e,t,i){return e+(t-e)*i}function Pi(e,t,i){return e=Li(e),Ci((t=Li(t))-e>Si?e+Oi:e-t>Si?e-Oi:e,t,i)}function ki(e,t,i){if(e===t)return t;var n=t-e;return Math.abs(n)<=i?t:e+(n>0?1:-1)*i}function Bi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=[];e=e.map((function(e){return e.trim()})).filter((function(e){return e.length>0&&!/^\/+$/.test(e)}));for(var n=0;n<e.length;n++){var r=0===n,s=n===e.length-1,o=e[n];r||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),i.push(o)}return i.join("/")}function Ui(e){return e instanceof Error}function Qi(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var i,n,r;if(Array.isArray(e)){if((i=e.length)!=t.length)return!1;for(n=i;0!=n--;)if(!Qi(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=i;0!=n--;){var s=r[n];if(!Qi(e[s],t[s]))return!1}return!0}return e!=e&&t!=t}function _i(e){return"number"==typeof e}function Ri(e,t){void 0===t&&(t=!1);var i=typeof e;if("string"===i)return JSON.stringify(e);if(!0===e)return"true";if(!1===e)return"false";if(null===e)return"null";if(e instanceof Array){for(var n="[",r=e.length-1,s=0;s<r;s++)n+=Ri(e[s],!1)+",";return r>-1&&(n+=Ri(e[s],!1)),n+"]"}if(e instanceof Object){if("function"==typeof e.toJSON)return Ri(e.toJSON(),t);var o=Object.keys(e).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],c=Ri(e[u],!0);void 0!==c&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+c),s++}return"{"+n+"}"}switch(i){case"function":case"undefined":return t?void 0:null;case"number":return 0;default:return isFinite(e)?e:null}}function Yi(e){return String(Ri(e,!1))}function Fi(e){var t,i,n,r=JSON.parse(e),s="undefined"!=typeof location?location.hostname:"",o=Date.now();if("object"!=typeof r)return new Error("input is not an object");if(0===s.length||It(s)||bt.filter((function(e){return zt(e,s)})).length>0){var a=String(null!==(t=r.certificate)&&void 0!==t?t:"");if(a){var u=new Oe;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var c=String(null!==(i=r.certificate)&&void 0!==i?i:"");if(!c)return new Error("certificate is not existed.");var l=new Oe;l.readCertPEM(c);var h=String(null!==(n=r._signature)&&void 0!==n?n:"");if(!h)return new Error("signature is not existed.");if(!1===function(e,t,i){var n=new Oe;if("string"==typeof i?n.readCertPEM(i):n.readCertHex(i.hex),!1===Ue(n))return!1;var r=new ee;return r.readCertPubKeyHex(n.hex,6),!!r.verify(e,_(t))}(Yi(function(e,t){for(var i={},n=0,r=Object.keys(e);n<r.length;n++){var s=r[n];-1===t.indexOf(s)&&(i[s]=e[s])}return i}(r,["_signature"])),h,l))return new Error("signature verify failed.");var d=new Date("string"==typeof r.expire_at&&/^\d+$/.test(r.expire_at)?Number(r.expire_at):r.expire_at);return o<d.getTime()?0===(Array.isArray(r.allow_hosts)?r.allow_hosts:[]).filter((function(e){return zt(e,s)})).length?function(e){return new Error("host("+JSON.stringify(e)+") is not allowed.")}(s):{issuer:l.getSubjectString()}:function(e){return new Error("date("+e.toString()+") expired.")}(d)}var Vi=new WeakMap;function Hi(e,t,i){var n,r,s=JSON.stringify(t),o=JSON.stringify(e),u=Fi(o);e=JSON.parse(o),t=JSON.parse(s);var c={workCode:"",expire:new Date,allowHosts:[],uuid:qe(),initial:{mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},observers:[],issuer:u instanceof Error?"none":u.issuer,raw:{work:e,options:t}},l=null!==(n=e.base_url)&&void 0!==n?n:"";l&&"/"!==l[l.length-1]&&(l+="/");var h=function(e,n){var r,s=e;!0===t.jsonp&&(s=(s=e.replace(/([\?\#].*)?$/i,""))+"."+Ce(""+s).slice(0,7)+".jsonp");if(!0===t.shortPath){var o=s.replace(l,"").split("."),a=null!==(r=o.shift())&&void 0!==r?r:"",u=o.join(".");s=Bi(l,Ce(a))+(u?"."+u:"")}var c=s.replace(l,"");return t.baseURL&&(s=Bi(t.baseURL,c)),i&&i(e,s,c,n),s},d=function(t,i){var n,r,s,o,a,u,c=t;if(!gi(t)){var d=null!==(u=null!==(o=null!==(r=null===(n=e.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==r?r:null===(s=e.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=e.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";d&&(d=Bi(d,String(i))),c=Bi(d,c)}return gi(c)||(c=Bi(l,c)),h(c,"panorama")},A=function(e){var t=e;return gi(t)||(t=Bi(l,e)),h(t,"model")},p=function(e,t){void 0===t&&(t="");var i=e;return gi(i)||(i=Bi(t,i)),gi(i)||(i=Bi(l,i)),h(i,"texture")};if(c.workCode=null!==(r=String(e.work_code||e.code||e.workCode))&&void 0!==r?r:"",c.expire=new Date("string"==typeof e.expire_at&&/^\d+$/.test(e.expire_at)?Number(e.expire_at):e.expire_at),c.allowHosts=e.allow_hosts||[],Ui(u))return u;if(e.initial&&("Floorplan"!==e.initial.mode&&"Topview"!==e.initial.mode&&"Panorama"!==e.initial.mode&&"VRPanorama"!==e.initial.mode&&"Model"!==e.initial.mode&&"DepthPanorama"!==e.initial.mode||(c.initial.mode=e.initial.mode),_i(e.initial.latitude)&&(c.initial.latitude=e.initial.latitude),_i(e.initial.longitude)?c.initial.longitude=e.initial.longitude:_i(e.initial.heading)&&(c.initial.longitude=-(360*(e.initial.heading-.25)+90)/180*Math.PI),_i(e.initial.fov)&&(c.initial.fov=e.initial.fov),_i(e.initial.panoIndex)?c.initial.panoIndex=e.initial.panoIndex:_i(e.initial.pano_index)?c.initial.panoIndex=e.initial.pano_index:_i(e.initial.pano)&&(c.initial.panoIndex=e.initial.pano)),Ui(u))return u;if(e.model){var M={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.model.bvh?M.bvh=e.model.bvh:"boolean"==typeof e.bvh&&(M.bvh=e.bvh),"boolean"==typeof e.model.async?M.async=e.model.async:"boolean"==typeof e.modelAsync&&(M.async=e.modelAsync),e.model.file?M.file=A(e.model.file):e.model.file_url&&(M.file=A(e.model.file_url)),e.model.textureBase?M.textureBase=e.model.textureBase:e.model.material_base_url&&(M.textureBase=e.model.material_base_url),Array.isArray(e.model.textures)?M.textures=e.model.textures.map((function(e){return p(e,M.textureBase)})):Array.isArray(e.model.material_textures)&&(M.textures=e.model.material_textures.map((function(e){return p(e,M.textureBase)}))),M.file&&(c.model=M)}if(Ui(u))return u;if(e.observers&&Array.isArray(e.observers)){var f=[];e.panorama&&(Array.isArray(e.panorama)?f=e.panorama:Array.isArray(e.panorama.list)?f=e.panorama.list:Array.isArray(e.panorama.info)&&(f=e.panorama.info));for(var g=0;g<e.observers.length;g++){var y={},v=e.observers[g];if(!v)break;var m=f[g]||{};v=Object.assign({},v,m,{active:!1!==v.active&&!1!==m.active}),y.panoIndex=g,y.active=!1!==v.active,y.loadable=!0===v.loadable,y.images={up:d(v.images?v.images.up:v.up,g),down:d(v.images?v.images.down:v.down,g),right:d(v.images?v.images.right:v.right,g),left:d(v.images?v.images.left:v.left,g),front:d(v.images?v.images.front:v.front,g),back:d(v.images?v.images.back:v.back,g)};var N=v.images?v.images.depth:v.depth;N&&(y.images.depth=d(N,g));var D=v.images?v.images.tiles:v.tiles;if(D&&(y.images.tiles=d(D,g)),v.position instanceof a.Vector3)y.position=v.position.clone();else{if(!Array.isArray(v.position))break;y.position=(new a.Vector3).fromArray(v.position)}if(v.standingPosition instanceof a.Vector3)y.standingPosition=v.standingPosition.clone();else if(Array.isArray(v.standingPosition))y.standingPosition=(new a.Vector3).fromArray(v.standingPosition);else if(v.standing_position instanceof a.Vector3)y.standingPosition=v.standing_position.clone();else{if(!Array.isArray(v.standing_position))break;y.standingPosition=(new a.Vector3).fromArray(v.standing_position)}if(v.quaternion instanceof a.Quaternion)y.quaternion=v.quaternion.clone();else if(Array.isArray(v.quaternion))y.quaternion=(new a.Quaternion).fromArray(v.quaternion);else{if(!v.quaternion)break;var w=v.quaternion,T=w.x,x=w.y,E=w.z,j=w.w;y.quaternion=new a.Quaternion(T,x,E,j)}if(Array.isArray(v.accessibleNodes)?y.accessibleNodes=v.accessibleNodes.slice():Array.isArray(v.accessible_nodes)&&(y.accessibleNodes=v.accessible_nodes.slice()),Array.isArray(v.visibleNodes)?y.visibleNodes=v.visibleNodes.slice():Array.isArray(v.visible_nodes)&&(y.visibleNodes=v.visible_nodes.slice()),_i(v.floorIndex)?y.floorIndex=v.floorIndex:_i(v.floor_index)?y.floorIndex=v.floor_index:y.floorIndex=0,v.video){var I={};"string"==typeof v.video.source&&(I.source=v.video.source),v.video.matrix instanceof a.Matrix4?I.matrix=v.video.matrix.clone():Array.isArray(v.video.matrix)&&(I.matrix=(new a.Matrix4).fromArray(v.video.matrix)),v.video.size instanceof a.Vector2?I.size=v.video.size.clone():Array.isArray(v.video.size)&&(I.size=(new a.Vector2).fromArray(v.video.size)),I.source&&I.matrix&&I.size&&(y.video=I)}c.observers[g]=y}}if(Ui(u))return u;for(var z=0,b=c.observers;z<b.length;z++){if(!(y=b[z]).accessibleNodes){y.accessibleNodes=[];for(var L=0;L<c.observers.length;L++)c.observers[L]!==y&&y.accessibleNodes.push(L)}if(!y.visibleNodes){y.visibleNodes=[];for(L=0;L<c.observers.length;L++)c.observers[L]!==y&&y.visibleNodes.push(L)}}if(Ui(u))return u;var S=Et(c);return Vi.set(S,{work:o,options:s}),S}function Gi(e,t,i){"string"==typeof e&&"{"===e.trim()[0]&&(e=JSON.parse(e));var n=Vi.get(e);if(n){if(t&&!Qi(JSON.parse(n.options),t))throw new Error("[PARSE FAILED]: work is parsed with different options.");return e}var r=Hi(e,null!=t?t:{},i);if(Ui(r))throw new Error("[PARSE FAILED]: "+r.message);return r}var qi=function(e){return Number(e)};function Wi(e,t,i){var n;void 0===t&&(t=qi),void 0===i&&(i=!1);for(var r,s=1/0,o=0,a=e;o<a.length;o++){var u=a[o],c=t(u);c<=s&&(r=(n=[u,c])[0],s=n[1])}return i?[r,s]:r}
367
+ function(e,t){for(var i=e.toByteArray(),n=0;n<i.length&&0==i[n];)++n;if(i.length-n!=t-1||2!=i[n])return null;for(++n;0!=i[n];)if(++n>=i.length)return null;for(var r="";++n<i.length;){var s=255&i[n];s<128?r+=String.fromCharCode(s):s>191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ee.prototype.decryptOAEP=function(e,t,i){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=J(e,16),r=this.doPrivate(n);return null==r?null:function(e,t,i,n){var r=A.crypto.MessageDigest,s=A.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(e){return ce(s.hashHex(le(e),o))}),e=e.toByteArray(),a=0;a<e.length;a+=1)e[a]&=255;for(;e.length<t;)e.unshift(0);if((e=String.fromCharCode.apply(String,e)).length<2*n+2)throw"Cipher too short";var a,u=e.substr(1,n),c=e.substr(n+1),l=te(c,n,i),h=[];for(a=0;a<u.length;a+=1)h[a]=u.charCodeAt(a)^l.charCodeAt(a);var d=te(String.fromCharCode.apply(String,h),e.length-n,i),p=[];for(a=0;a<c.length;a+=1)p[a]=c.charCodeAt(a)^d.charCodeAt(a);if((p=String.fromCharCode.apply(String,p)).substr(0,n)!==i(""))throw"Hash mismatch";var M=(p=p.substr(n)).indexOf("");if((-1!=M?p.substr(0,M).lastIndexOf("\0"):-1)+1!=M)throw"Malformed data";return p.substr(M+1)}(r,this.n.bitLength()+7>>3,t,i)},void 0!==A.lang&&A.lang||(A.lang={}),A.lang.String=function(){},A.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},A.lang.String.isHex=function(e){return fe(e)},A.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},A.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=re(e),A.lang.String.isBase64(e))},A.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},A.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},A.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},A.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var ye=function(e,t,i){return null==i&&(i="0"),e.length>=t?e:new Array(t-e.length+1).join(i)+e};function ve(e,t){var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==A.crypto&&A.crypto||(A.crypto={}),A.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:M.algo.MD5,sha1:M.algo.SHA1,sha224:M.algo.SHA224,sha256:M.algo.SHA256,sha384:M.algo.SHA384,sha512:M.algo.SHA512,ripemd160:M.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,i){var n=this.getDigestInfoHex(e,t),r=i/4;if(n.length+22>r)throw"key is too short for SigAlg: keylen="+i+","+t;for(var s="0001",o="00"+n,a="",u=r-s.length-o.length,c=0;c<u;c+=2)a+="ff";return s+a+o},this.hashString=function(e,t){return new A.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new A.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof ee||e instanceof A.crypto.DSA||e instanceof A.crypto.ECDSA}},A.crypto.Util.md5=function(e){return new A.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},A.crypto.Util.ripemd160=function(e){return new A.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},A.crypto.Util.SECURERANDOMGEN=new K,A.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return A.crypto.Util.SECURERANDOMGEN.nextBytes(t),ie(t)},A.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new f(A.crypto.Util.getRandomHexOfNbytes(e),16)},A.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,i=new Array((e-t)/8+1);return A.crypto.Util.SECURERANDOMGEN.nextBytes(i),i[0]=(255<<t&255^255)&i[0],ie(i)},A.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new f(A.crypto.Util.getRandomHexOfNbits(e),16)},A.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var i=A.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(i))return i}},A.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var i=e.compareTo(t);if(1==i)throw"biMin is greater than biMax";if(0==i)return e;var n=t.subtract(e);return A.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},A.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=A.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=A.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=M.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(M.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},A.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},A.crypto.MessageDigest.getHashLength=function(e){var t=A.crypto.MessageDigest,i=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[i])throw"not supported algorithm: "+e;return t.HASHLENGTH[i]},A.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},A.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=A.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var i=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)&&"cryptojs"==t){try{var n=A.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i];this.mac=M.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+i+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=M.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(M.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=le(e)),void(this.pass=M.enc.Hex.parse(t))}if("object"!=typeof e)throw"KJUR.crypto.Mac unsupported password type: "+e;t=null;if(void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=ae(e.utf8)),void 0!==e.rstr&&(t=le(e.rstr)),void 0!==e.b64&&(t=_(e.b64)),void 0!==e.b64u&&(t=oe(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=M.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},A.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new A.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var i=null;try{i=void 0===t?Ie.getKey(e):Ie.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===i.isPrivate)this.prvKey=i,this.state="SIGN";else{if(!0!==i.isPublic)throw"init failed.:"+i;this.pubKey=i,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==A.crypto.ECDSA&&(this.prvKey=new A.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof ee&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof ee&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof A.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof A.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==A.crypto.ECDSA&&(this.pubKey=new A.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof ee&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof ee&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==A.crypto.ECDSA&&this.pubKey instanceof A.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==A.crypto.DSA&&this.pubKey instanceof A.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){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(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=A.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=Ie.getKey(e.prvkeypem);this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},A.crypto.Cipher=function(e){},A.crypto.Cipher.encrypt=function(e,t,i){if(t instanceof ee&&t.isPublic){var n=A.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.encryptOAEP(e,"sha"+r[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.encrypt: unsupported key or algorithm"},A.crypto.Cipher.decrypt=function(e,t,i){if(t instanceof ee&&t.isPrivate){var n=A.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.decryptOAEP(e,"sha"+r[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.decrypt: unsupported key or algorithm"},A.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof ee){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},A.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 me,Ne,De,we,Te,xe,Ee,je,Ie=(me=function(e,t,i){return Ne(M.AES,e,t,i)},Ne=function(e,t,i,n){var r=M.enc.Hex.parse(t),s=M.enc.Hex.parse(i),o=M.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var u=e.decrypt(a,s,{iv:o});return M.enc.Hex.stringify(u)},De=function(e,t,i){return we(M.AES,e,t,i)},we=function(e,t,i,n){var r=M.enc.Hex.parse(t),s=M.enc.Hex.parse(i),o=M.enc.Hex.parse(n),a=e.encrypt(r,s,{iv:o}),u=M.enc.Hex.parse(a.toString());return M.enc.Base64.stringify(u)},Te={"AES-256-CBC":{proc:me,eproc:De,keylen:32,ivlen:16},"AES-192-CBC":{proc:me,eproc:De,keylen:24,ivlen:16},"AES-128-CBC":{proc:me,eproc:De,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,t,i){return Ne(M.TripleDES,e,t,i)},eproc:function(e,t,i){return we(M.TripleDES,e,t,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,t,i){return Ne(M.DES,e,t,i)},eproc:function(e,t,i){return we(M.DES,e,t,i)},keylen:8,ivlen:8}},xe=function(e){var t={},i=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(t.cipher=i[1],t.ivsalt=i[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var r=-1,s=0;-1!=e.indexOf("\r\n\r\n")&&(r=e.indexOf("\r\n\r\n"),s=2),-1!=e.indexOf("\n\n")&&(r=e.indexOf("\n\n"),s=1);var o=e.indexOf("-----END");if(-1!=r&&-1!=o){var a=e.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),t.data=a}return t},Ee=function(e,t,i){for(var n=i.substring(0,16),r=M.enc.Hex.parse(n),s=M.enc.Utf8.parse(t),o=Te[e].keylen+Te[e].ivlen,a="",u=null;;){var c=M.algo.MD5.create();if(null!=u&&c.update(u),c.update(s),c.update(r),u=c.finalize(),(a+=M.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=a.substr(0,2*Te[e].keylen),l.ivhex=a.substr(2*Te[e].keylen,2*Te[e].ivlen),l},je=function(e,t,i,n){var r=M.enc.Base64.parse(e),s=M.enc.Hex.stringify(r);return(0,Te[t].proc)(s,i,n)},{version:"1.0.0",parsePKCS5PEM:function(e){return xe(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,i){return Ee(e,t,i)},decryptKeyB64:function(e,t,i,n){return je(e,t,i,n)},getDecryptedKeyHex:function(e,t){var i=xe(e);i.type;var n=i.cipher,r=i.ivsalt,s=i.data,o=Ee(n,t,r).keyhex;return je(s,n,o,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,i,n,r){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===Te[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==r&&null!=r||(r=function(e){var t=M.lib.WordArray.random(e);return M.enc.Hex.stringify(t)}(Te[n].ivlen).toUpperCase());var o=function(e,t,i,n){return(0,Te[t].eproc)(e,i,n)}(t,n,Ee(n,i,r).keyhex,r);return s="-----BEGIN "+e+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+r+"\r\n",s+="\r\n",s+=o.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={},s=i(e,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(e,s[1]);var o=i(e,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(e,o[0]))throw"this only supports pkcs5PBES2";var a=i(e,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=i(e,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(e,u[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(e,u[1]);var c=i(e,a[0]);if(2!=c.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length;if("2a864886f70d01050c"!=n(e,c[0]))throw"this only supports pkcs5PBKDF2";var l=i(e,c[1]);if(l.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length;r.pbkdf2Salt=n(e,l[0]);var h=n(e,l[1]);try{r.pbkdf2Iter=parseInt(h,16)}catch(e){throw"malformed format pbkdf2Iter: "+h}return r},getPBKDF2KeyHexFromParam:function(e,t){var i=M.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,r=M.PBKDF2(t,i,{keySize:6,iterations:n});return M.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var i=Ae(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ie.getPBKDF2KeyHexFromParam(n,t),s={};s.ciphertext=M.enc.Hex.parse(n.ciphertext);var o=M.enc.Hex.parse(r),a=M.enc.Hex.parse(n.encryptionSchemeIV),u=M.TripleDES.decrypt(s,o,{iv:a});return M.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(e,t){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=i(e,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=i(e,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(r.algoid=n(e,o[0]),"06"==e.substr(o[1],2)&&(r.algparam=n(e,o[1])),"04"!=e.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return r.keyidx=t.getVidx(e,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=Ae(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,i=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==i.algoid)t=new ee;else if("2a8648ce380401"==i.algoid)t=new A.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";t=new A.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,i=ze.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===i)t=new ee;else if("2a8648ce380401"===i)t=new A.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";t=new A.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={};if("30"!=e.substr(0,2))throw"malformed RSA key(code:001)";var s=i(e,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=e.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(e,s[0]),"02"!=e.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(e,s[1]),r},parsePublicPKCS8Hex:function(e){var t=ze,i=t.getChildIdx,n=t.getV,r={algparam:null},s=i(e,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=e.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(e,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=e.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?r.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(r.algparam={},r.algparam.p=t.getVbyList(e,a[1],[0],"02"),r.algparam.q=t.getVbyList(e,a[1],[1],"02"),r.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(e,s[1]).substr(2),r}});Ie.getKey=function(e,t,i){var n=(y=ze).getChildIdx;y.getV;var r=y.getVbyList,s=A.crypto,o=s.ECDSA,a=s.DSA,u=ee,c=Ae,l=Ie;if(void 0!==u&&e instanceof u)return e;if(void 0!==o&&e instanceof o)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new o({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new o({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(z=new u).setPublic(e.n,e.e),z;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(z=new u).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),z;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(z=new u).setPrivate(e.n,e.e,e.d),z;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(z=new a).setPublic(e.p,e.q,e.g,e.y),z;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(z=new a).setPrivate(e.p,e.q,e.g,e.y,e.x),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(z=new u).setPublic(oe(e.n),oe(e.e)),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(z=new u).setPrivateEx(oe(e.n),oe(e.e),oe(e.d),oe(e.p),oe(e.q),oe(e.dp),oe(e.dq),oe(e.qi)),z;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(z=new u).setPrivate(oe(e.n),oe(e.e),oe(e.d)),z;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var h=(I=new o({curve:e.crv})).ecparams.keylen/4,d="04"+("0000000000"+oe(e.x)).slice(-h)+("0000000000"+oe(e.y)).slice(-h);return I.setPublicKeyHex(d),I}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){h=(I=new o({curve:e.crv})).ecparams.keylen/4,d="04"+("0000000000"+oe(e.x)).slice(-h)+("0000000000"+oe(e.y)).slice(-h);var p=("0000000000"+oe(e.d)).slice(-h);return I.setPublicKeyHex(d),I.setPrivateKeyHex(p),I}if("pkcs5prv"===i){var M,g=e,y=ze;if(9===(M=n(g,0)).length)(z=new u).readPKCS5PrvKeyHex(g);else if(6===M.length)(z=new a).readPKCS5PrvKeyHex(g);else{if(!(M.length>2&&"04"===g.substr(M[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(z=new o).readPKCS5PrvKeyHex(g)}return z}if("pkcs8prv"===i)return z=l.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===i)return l._getKeyFromPublicPKCS8Hex(e);if("x509pub"===i)return Oe.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return Oe.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var v=Ae(e,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(v)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var m=c(e,"RSA PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var N=r(S=c(e,"DSA PRIVATE KEY"),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(z=new a).setPrivate(new f(N,16),new f(D,16),new f(w,16),new f(T,16),new f(x,16)),z}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){m=c(e,"EC PRIVATE KEY");return l.getKey(m,null,"pkcs5prv")}if(-1!=e.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var E=l.getDecryptedKeyHex(e,t),j=new ee;return j.readPKCS5PrvKeyHex(E),j}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var I,z=r(S=l.getDecryptedKeyHex(e,t),0,[1],"04"),b=r(S,0,[2,0],"06"),L=r(S,0,[3,0],"03").substr(2);if(void 0===A.crypto.OID.oidhex2name[b])throw"undefined OID(hex) in KJUR.crypto.OID: "+b;return(I=new o({curve:A.crypto.OID.oidhex2name[b]})).setPublicKeyHex(L),I.setPrivateKeyHex(z),I.isPublic=!1,I}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var S;N=r(S=l.getDecryptedKeyHex(e,t),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(z=new a).setPrivate(new f(N,16),new f(D,16),new f(w,16),new f(T,16),new f(x,16)),z}if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},Ie.generateKeypair=function(e,t){if("RSA"==e){var i=t;(o=new ee).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ee,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==e){var o,a,u=t,c=new A.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new A.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),o.setPrivateKeyHex(c.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new A.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+e},Ie.getPEM=function(e,t,i,n,r,s){var o=A,a=o.asn1,u=a.DERObjectIdentifier,c=a.DERInteger,l=a.ASN1Util.newObject,h=a.x509.SubjectPublicKeyInfo,d=o.crypto,p=d.DSA,f=d.ECDSA,g=ee;function y(e){return l({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function v(e){return l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function m(e){return l({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==p&&e instanceof p||void 0!==f&&e instanceof f)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return de(T=new h(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===i||null==i)&&1==e.isPrivate)return de(T=y(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===i||null==i)&&1==e.isPrivate){var N=new u({name:e.curveName}).getEncodedHex(),D=v(e).getEncodedHex(),w="";return w+=de(N,"EC PARAMETERS"),w+=de(D,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==p&&e instanceof p&&(void 0===i||null==i)&&1==e.isPrivate)return de(T=m(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==i&&null!=i&&1==e.isPrivate){var T=y(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",T,i,n,s)}if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==i&&null!=i&&1==e.isPrivate){T=v(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",T,i,n,s)}if("PKCS5PRV"==t&&void 0!==p&&e instanceof p&&void 0!==i&&null!=i&&1==e.isPrivate){T=m(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",T,i,n,s)}var x=function(e,t){var i=E(e,t);return new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},E=function(e,t){var i=M.lib.WordArray.random(8),n=M.lib.WordArray.random(8),r=M.PBKDF2(t,i,{keySize:6,iterations:100}),s=M.enc.Hex.parse(e),o=M.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=M.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=M.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var j=y(e).getEncodedHex();T=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate){j=new l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),T=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==p&&e instanceof p&&1==e.isPrivate){j=new c({bigint:e.x}).getEncodedHex(),T=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?de(T,"PRIVATE KEY"):de(D=x(T,i),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Ie.getKeyFromCSRPEM=function(e){var t=Ae(e,"CERTIFICATE REQUEST");return Ie.getKeyFromCSRHex(t)},Ie.getKeyFromCSRHex=function(e){var t=Ie.parseCSRHex(e);return Ie.getKey(t.p8pubkeyhex,null,"pkcs8pub")},Ie.parseCSRHex=function(e){var t=ze,i=t.getChildIdx,n=t.getTLV,r={},s=e;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(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=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ie.getKeyID=function(e){var t=Ie,i=ze;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=Ae(t.getPEM(e)),r=i.getIdxbyList(n,0,[1]),s=i.getV(n,r).substring(2);return A.crypto.Util.hashHex(s,"sha1")},Ie.getJWKFromKey=function(e){var t={};if(e instanceof ee&&e.isPrivate)return t.kty="RSA",t.n=se(e.n.toString(16)),t.e=se(e.e.toString(16)),t.d=se(e.d.toString(16)),t.p=se(e.p.toString(16)),t.q=se(e.q.toString(16)),t.dp=se(e.dmp1.toString(16)),t.dq=se(e.dmq1.toString(16)),t.qi=se(e.coeff.toString(16)),t;if(e instanceof ee&&e.isPublic)return t.kty="RSA",t.n=se(e.n.toString(16)),t.e=se(e.e.toString(16)),t;if(e instanceof A.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=se(i.x),t.y=se(i.y),t.d=se(e.prvKeyHex),t}if(e instanceof A.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=se(i.x),t.y=se(i.y),t}throw"not supported key object"},void 0!==A.asn1&&A.asn1||(A.asn1={}),A.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var i=t.substr(1).length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r<i;r++)n+="f";t=new f(n,16).xor(e).add(f.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return de(e,t)},this.newObject=function(e){var t=A.asn1,i=t.ASN1Object,n=t.DERBoolean,r=t.DERInteger,s=t.DERBitString,o=t.DEROctetString,a=t.DERNull,u=t.DERObjectIdentifier,c=t.DEREnumerated,l=t.DERUTF8String,h=t.DERNumericString,d=t.DERPrintableString,p=t.DERTeletexString,M=t.DERIA5String,f=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERVisibleString,v=t.DERBMPString,m=t.DERSequence,N=t.DERSet,D=t.DERTaggedObject,w=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var T=Object.keys(e);if(1!=T.length)throw new Error("key of param shall be only one.");var x=T[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+x+":"))throw new Error("undefined key: "+x);if("bool"==x)return new n(e[x]);if("int"==x)return new r(e[x]);if("bitstr"==x)return new s(e[x]);if("octstr"==x)return new o(e[x]);if("null"==x)return new a(e[x]);if("oid"==x)return new u(e[x]);if("enum"==x)return new c(e[x]);if("utf8str"==x)return new l(e[x]);if("numstr"==x)return new h(e[x]);if("prnstr"==x)return new d(e[x]);if("telstr"==x)return new p(e[x]);if("ia5str"==x)return new M(e[x]);if("utctime"==x)return new f(e[x]);if("gentime"==x)return new g(e[x]);if("visstr"==x)return new y(e[x]);if("bmpstr"==x)return new v(e[x]);if("asn1"==x)return new i(e[x]);if("seq"==x){for(var E=e[x],j=[],I=0;I<E.length;I++){var z=w(E[I]);j.push(z)}return new m({array:j})}if("set"==x){for(E=e[x],j=[],I=0;I<E.length;I++){z=w(E[I]);j.push(z)}return new N({array:j})}if("tag"==x){var b=e[x];if("[object Array]"===Object.prototype.toString.call(b)&&3==b.length){var L=w(b[2]);return new D({tag:b[0],explicit:b[1],obj:L})}return new D(b)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},A.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",i=parseInt(e.substr(0,2),16),n=(t=Math.floor(i/40)+"."+i%40,""),r=2;r<e.length;r+=2){var s=("00000000"+parseInt(e.substr(r,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))t=t+"."+new f(n,2).toString(10),n=""}return t},A.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=new f(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var s="",o=0;o<r;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),i+=t(parseInt(a,2))}return i};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",r=e.split("."),s=40*parseInt(r[0])+parseInt(r[1]);n+=t(s),r.splice(0,2);for(var o=0;o<r.length;o++)n+=i(r[o]);return n},A.asn1.ASN1Object=function(e){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 e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var i=t.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+i).toString(16)+t},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(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},A.asn1.DERAbstractString=function(e){A.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ae(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},p.lang.extend(A.asn1.DERAbstractString,A.asn1.ASN1Object),A.asn1.DERAbstractTime=function(e){A.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,i){var n=this.zeroPadding,r=this.localDateToUTC(e),s=String(r.getFullYear());"utc"==t&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ne(e)},this.setByDateValue=function(e,t,i,n,r,s){var o=new Date(Date.UTC(e,t-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(A.asn1.DERAbstractTime,A.asn1.ASN1Object),A.asn1.DERAbstractStructured=function(e){A.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},p.lang.extend(A.asn1.DERAbstractStructured,A.asn1.ASN1Object),A.asn1.DERBoolean=function(e){A.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},p.lang.extend(A.asn1.DERBoolean,A.asn1.ASN1Object),A.asn1.DERInteger=function(e){A.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=A.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new f(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},p.lang.extend(A.asn1.DERInteger,A.asn1.ASN1Object),A.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}A.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var i="0"+e;this.hTLV=null,this.isModified=!0,this.hV=i+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var i=0;i<=t;i++)e+="0";var n="";for(i=0;i<e.length-1;i+=8){var r=e.substr(i,8),s=parseInt(r,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",i=0;i<e.length;i++)1==e[i]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},p.lang.extend(A.asn1.DERBitString,A.asn1.ASN1Object),A.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=A.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}A.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},p.lang.extend(A.asn1.DEROctetString,A.asn1.DERAbstractString),A.asn1.DERNull=function(){A.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(A.asn1.DERNull,A.asn1.ASN1Object),A.asn1.DERObjectIdentifier=function(e){A.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=parseInt(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var s="",o=0;o<r;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),i+=t(parseInt(a,2))}return i};try{if(!e.match(/^[0-9.]+$/))return null;var n="",r=e.split("."),s=40*parseInt(r[0],10)+parseInt(r[1],10);n+=t(s),r.splice(0,2);for(var o=0;o<r.length;o++)n+=i(r[o]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=A.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},p.lang.extend(A.asn1.DERObjectIdentifier,A.asn1.ASN1Object),A.asn1.DEREnumerated=function(e){A.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=A.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new f(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},p.lang.extend(A.asn1.DEREnumerated,A.asn1.ASN1Object),A.asn1.DERUTF8String=function(e){A.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},p.lang.extend(A.asn1.DERUTF8String,A.asn1.DERAbstractString),A.asn1.DERNumericString=function(e){A.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},p.lang.extend(A.asn1.DERNumericString,A.asn1.DERAbstractString),A.asn1.DERPrintableString=function(e){A.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},p.lang.extend(A.asn1.DERPrintableString,A.asn1.DERAbstractString),A.asn1.DERTeletexString=function(e){A.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},p.lang.extend(A.asn1.DERTeletexString,A.asn1.DERAbstractString),A.asn1.DERIA5String=function(e){A.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},p.lang.extend(A.asn1.DERIA5String,A.asn1.DERAbstractString),A.asn1.DERVisibleString=function(e){A.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},p.lang.extend(A.asn1.DERVisibleString,A.asn1.DERAbstractString),A.asn1.DERBMPString=function(e){A.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},p.lang.extend(A.asn1.DERBMPString,A.asn1.DERAbstractString),A.asn1.DERUTCTime=function(e){A.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=ne(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=ne(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},p.lang.extend(A.asn1.DERUTCTime,A.asn1.DERAbstractTime),A.asn1.DERGeneralizedTime=function(e){A.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ne(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=ne(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},p.lang.extend(A.asn1.DERGeneralizedTime,A.asn1.DERAbstractTime),A.asn1.DERSequence=function(e){A.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},p.lang.extend(A.asn1.DERSequence,A.asn1.DERAbstractStructured),A.asn1.DERSet=function(e){A.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var i=this.asn1Array[t];e.push(i.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},p.lang.extend(A.asn1.DERSet,A.asn1.DERAbstractStructured),A.asn1.DERTaggedObject=function(e){A.asn1.DERTaggedObject.superclass.constructor.call(this);var t=A.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,i){this.hT=t,this.isExplicit=e,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof e.obj&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},p.lang.extend(A.asn1.DERTaggedObject,A.asn1.ASN1Object);var ze=new function(){};function be(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e}function Le(e,t,i){for(var n="",r=0;n.length<t;)n+=ce(i(le(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Se(e){for(var t in A.crypto.Util.DIGESTINFOHEAD){var i=A.crypto.Util.DIGESTINFOHEAD[t],n=i.length;if(e.substring(0,n)==i)return[t,e.substring(n)]}return[]}function Oe(e){var t,i=ze,n=i.getChildIdx,r=i.getV,s=i.getTLV,o=i.getVbyList,a=i.getVbyListEx,u=i.getTLVbyList,c=i.getTLVbyListEx,l=i.getIdxbyList,h=i.getIdxbyListEx,d=i.getVidx,p=i.getInt,M=i.oidname,f=i.hextooidstr,g=Ae;try{t=A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}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 e=u(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=u(e,0,[0]),i=p(t,0);if(i<0||2<i)throw new Error("malformed version field");return this.version=i+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 e=c(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var i in t)if(e===t[i])return i;return M(a(e,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 e=o(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getNotAfter=function(){var e=o(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getPublicKeyHex=function(){return i.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return l(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return Ie.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),i=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),r=new A.crypto.Signature({alg:t});return r.init(e),r.updateHex(n),r.verify(i)},this.parseExt=function(e){var t,s,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=l(a,0,[0,7,0],"30"),s=n(a,t)}else{a=Ae(e);var u=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=r(a,u))return void(this.aExtInfo=new Array);t=l(a,0,[0,3,0,1,0],"30"),s=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var c=0;c<s.length;c++){var h={critical:!1},A=0;3===n(a,s[c]).length&&(h.critical=!0,A=1),h.oid=i.hextooidstr(o(a,s[c],[0],"06"));var p=l(a,s[c],[1+A]);h.vidx=d(a,p),this.aExtInfo.push(h)}},this.getExtInfo=function(e){var t=this.aExtInfo,i=e;if(e.match(/^[0-9.]+$/)||(i=A.asn1.x509.OID.name2oid(e)),""!==i)for(var n=0;n<t.length;n++)if(t[n].oid===i)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("basicConstraints");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var o=r(e,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("keyUsage");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=s(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var i="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(i=i.slice(-8)),10==e.length&&(i=i.slice(-16)),""==(i=i.replace(/0+$/,""))&&(i="0"),i},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),i=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&i.push(Oe.KEYUSAGE_NAME[n]);return i.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectKeyIdentifier");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var o=r(e,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityKeyIdentifier");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var o={extname:"authorityKeyIdentifier"};t&&(o.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++){var c=e.substr(a[u],2);if("80"===c&&(o.kid={hex:r(e,a[u])}),"a1"===c){var l=s(e,a[u]),h=this.getGeneralNames(l);o.issuer=h[0].dn}"82"===c&&(o.sn={hex:r(e,a[u])})}return o},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("extKeyUsage");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var o={extname:"extKeyUsage",array:[]};t&&(o.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++)o.array.push(M(r(e,a[u])));return o},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,i=s(this.hex,e.vidx);if(""===i)return t;for(var o=n(i,0),a=0;a<o.length;a++)t.push(M(r(i,o[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectAltName");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("issuerAltName");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),i=[],r=0;r<t.length;r++){var o=this.getGeneralName(s(e,t[r]));void 0!==o&&i.push(o)}return i},this.getGeneralName=function(e){var t=e.substr(0,2),i=r(e,0),n=ce(i);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:pe(i)}:"a4"==t?{dn:this.getX500Name(i)}:void 0},this.getExtSubjectAltName2=function(){var e,t,i,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),c=n(u,0),l=0;l<c.length;l++)i=u.substr(c[l],2),e=r(u,c[l]),"81"===i&&(t=ue(e),a.push(["MAIL",t])),"82"===i&&(t=ue(e),a.push(["DNS",t])),"84"===i&&(t=Oe.hex2dn(e,0),a.push(["DN",t])),"86"===i&&(t=ue(e),a.push(["URI",t])),"87"===i&&(t=pe(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("cRLDistributionPoints");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"cRLDistributionPoints",array:[]};t&&(r.critical=!0);for(var o=n(e,0),a=0;a<o.length;a++){var u=s(e,o[a]);r.array.push(this.getDistributionPoint(u))}return r},this.getDistributionPoint=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=e.substr(i[r],2),a=s(e,i[r]);"a0"==o&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=e.substr(i[r],2),a=s(e,i[r]);"a0"==o&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,i=n(this.hex,e.vidx),r=0;r<i.length;r++)try{var s=ue(o(this.hex,i[r],[0,0,0],"86"));t.push(s)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},i=n(this.hex,e.vidx),r=0;r<i.length;r++){var s=o(this.hex,i[r],[0],"06"),a=o(this.hex,i[r],[1],"86");"2b06010505073001"===s&&t.ocsp.push(ue(a)),"2b06010505073002"===s&&t.caissuer.push(ue(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityInfoAccess");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"authorityInfoAccess",array:[]};t&&(r.critical=!0);for(var u=n(e,0),c=0;c<u.length;c++){var l=a(e,u[c],[0],"06"),h=ue(o(e,u[c],[1],"86"));if("2b06010505073001"==l)r.array.push({ocsp:h});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);r.array.push({caissuer:h})}}return r},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("certificatePolicies");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"certificatePolicies",array:[]};t&&(r.critical=!0);for(var o=n(e,0),a=0;a<o.length;a++){var u=s(e,o[a]),c=this.getPolicyInformation(u);r.array.push(c)}return r},this.getPolicyInformation=function(e){var t={},i=o(e,0,[0],"06");t.policyoid=M(i);var r=h(e,0,[1],"30");if(-1!=r){t.array=[];for(var a=n(e,r),u=0;u<a.length;u++){var c=s(e,a[u]),l=this.getPolicyQualifierInfo(c);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},i=o(e,0,[0],"06");if("2b06010505070201"===i){var n=a(e,0,[1],"16");t.cps=ce(n)}else if("2b06010505070202"===i){var r=u(e,0,[1],"30");t.unotice=this.getUserNotice(r)}return t},this.getUserNotice=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var o=s(e,i[r]);"30"!=o.substr(0,2)&&(t.exptext=this.getDisplayText(o))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=ce(r(e,0)),t},this.getExtCRLNumber=function(e,t){var i={extname:"cRLNumber"};if(t&&(i.critical=!0),"02"==e.substr(0,2))return i.num={hex:r(e,0)},i;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var i={extname:"cRLReason"};if(t&&(i.critical=!0),"0a"==e.substr(0,2))return i.code=parseInt(r(e,0),16),i;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var i={extname:"ocspNonce"};t&&(i.critical=!0);var n=r(e,0);return i.hex=n,i},this.getExtOcspNoCheck=function(e,t){var i={extname:"ocspNoCheck"};return t&&(i.critical=!0),i},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("adobeTimeStamp");if(void 0===i)return;e=s(this.hex,i.vidx),t=i.critical}var r={extname:"adobeTimeStamp"};t&&(r.critical=!0);var o=n(e,0);if(o.length>1){var a=s(e,o[1]),u=this.getGeneralName(a);null!=u.uri&&(r.uri=u.uri)}if(o.length>2){var c=s(e,o[2]);"0101ff"==c&&(r.reqauth=!0),"010100"==c&&(r.reqauth=!1)}return r},this.getX500NameRule=function(e){for(var t=null,i=[],n=0;n<e.length;n++)for(var r=e[n],s=0;s<r.length;s++)i.push(r[s]);for(n=0;n<i.length;n++){var o=i[n],a=o.ds,u=o.value,c=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=c)return"mixed";if(A.lang.String.isMail(u))continue;return"mixed"}if("C"==c){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getRDN(s(e,i[r])));return t},this.getRDN=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getAttrTypeAndValue(s(e,i[r])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},i=n(e,0),r=o(e,i[0],[],"06"),s=o(e,i[1],[]),a=A.asn1.ASN1Util.oidHexToInt(r);return t.type=A.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(i[1],2)],"bmp"!=t.ds?t.value=ue(s):t.value=Me(s),t},this.readCertPEM=function(e){this.readCertHex(g(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=de(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&(-1!=h(this.hex,0,[0,"[3]"])&&(e=c(this.hex,0,[0,"[3]",0],"30")));for(var t=[],i=n(e,0),r=0;r<i.length;r++){var o=s(e,i[r]),a=this.getExtParam(o);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var i=f(o(e,0,[0],"06")),r=!1;3==t&&"0101ff"==u(e,0,[1])&&(r=!0);var s=u(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==i?a=this.getExtSubjectKeyIdentifier(s,r):"2.5.29.15"==i?a=this.getExtKeyUsage(s,r):"2.5.29.17"==i?a=this.getExtSubjectAltName(s,r):"2.5.29.18"==i?a=this.getExtIssuerAltName(s,r):"2.5.29.19"==i?a=this.getExtBasicConstraints(s,r):"2.5.29.31"==i?a=this.getExtCRLDistributionPoints(s,r):"2.5.29.32"==i?a=this.getExtCertificatePolicies(s,r):"2.5.29.35"==i?a=this.getExtAuthorityKeyIdentifier(s,r):"2.5.29.37"==i?a=this.getExtExtKeyUsage(s,r):"1.3.6.1.5.5.7.1.1"==i?a=this.getExtAuthorityInfoAccess(s,r):"2.5.29.20"==i?a=this.getExtCRLNumber(s,r):"2.5.29.21"==i?a=this.getExtCRLReason(s,r):"1.3.6.1.5.5.7.48.1.2"==i?a=this.getExtOcspNonce(s,r):"1.3.6.1.5.5.7.48.1.5"==i?a=this.getExtOcspNoCheck(s,r):"1.2.840.113583.1.1.9.1"==i&&(a=this.getExtAdobeTimeStamp(s,r)),null!=a)return a;var c={extname:i,extn:s};return r&&(c.critical=!0),c},this.findExt=function(e,t){for(var i=0;i<e.length;i++)if(e[i].extname==t)return e[i];return null},this.updateExtCDPFullURI=function(e,t){var i=this.findExt(e,"cRLDistributionPoints");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)if(null!=n[r].dpname&&null!=n[r].dpname.full)for(var s=n[r].dpname.full,o=0;o<s.length;o++){var a=s[r];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].ocsp&&(n[r].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].caissuer&&(n[r].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map((function(e){return function(e){return e.map((function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")})).join("+")}(e).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var e,t,i,n,r=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];if(t+=" policy oid: "+r.policyoid+"\n",void 0!==r.array)for(var s=0;s<r.array.length;s++){var o=r.array[s];void 0!==o.cps&&(t+=" cps: "+o.cps+"\n")}}return t},s=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];try{void 0!==r.dpname.full[0].uri&&(t+=" "+r.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==r.dname.full[0].dn.hex&&(t+=" "+Oe.hex2dn(r.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},o=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];void 0!==r.caissuer&&(t+=" caissuer: "+r.caissuer+"\n"),void 0!==r.ocsp&&(t+=" ocsp: "+r.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+ge(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+ge(t.e.toString(16))+"\n"),null!=(i=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<i.length;a++){var u=i[a],c=A.asn1.x509.OID.oid2name(u.oid);""===c&&(c=u.oid);var l="";if(!0===u.critical&&(l="CRITICAL"),e+=" "+c+" "+l+":\n","basicConstraints"===c){var h=this.getExtBasicConstraints();void 0===h.cA?e+=" {}\n":(e+=" cA=true",void 0!==h.pathLen&&(e+=", pathLen="+h.pathLen),e+="\n")}else if("keyUsage"===c)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===c)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===c){var d=this.getExtAuthorityKeyIdentifier();void 0!==d.kid&&(e+=" kid="+d.kid.hex+"\n")}else{if("extKeyUsage"===c)e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===c)e+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===c)e+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===c)e+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===c&&(e+=r(this.getExtCertificatePolicies()))}}}return e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",e+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):A.lang.String.isHex(e)&&this.readCertHex(e))}function Ce(e){return M.SHA256(e).toString()}ze.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var i=parseInt(e.substr(t+3,1));return 0==i?-1:0<i&&i<10?i+1:-2},ze.getL=function(e,t){var i=ze.getLblen(e,t);return i<1?"":e.substr(t+2,2*i)},ze.getVblen=function(e,t){var i;return""==(i=ze.getL(e,t))?-1:("8"===i.substr(0,1)?new f(i.substr(2),16):new f(i,16)).intValue()},ze.getVidx=function(e,t){var i=ze.getLblen(e,t);return i<0?i:t+2*(i+1)},ze.getV=function(e,t){var i=ze.getVidx(e,t),n=ze.getVblen(e,t);return e.substr(i,2*n)},ze.getTLV=function(e,t){return e.substr(t,2)+ze.getL(e,t)+ze.getV(e,t)},ze.getTLVblen=function(e,t){return 2+2*ze.getLblen(e,t)+2*ze.getVblen(e,t)},ze.getNextSiblingIdx=function(e,t){return ze.getVidx(e,t)+2*ze.getVblen(e,t)},ze.getChildIdx=function(e,t){var i,n,r,s=ze,o=[];i=s.getVidx(e,t),n=2*s.getVblen(e,t),"03"==e.substr(t,2)&&(i+=2,n-=2),r=0;for(var a=i;r<=n;){var u=s.getTLVblen(e,a);if((r+=u)<=n&&o.push(a),a+=u,r>=n)break}return o},ze.getNthChildIdx=function(e,t,i){return ze.getChildIdx(e,t)[i]},ze.getIdxbyList=function(e,t,i,n){var r,s,o=ze;return 0==i.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(r=i.shift())>=(s=o.getChildIdx(e,t)).length?-1:o.getIdxbyList(e,s[r],i,n)},ze.getIdxbyListEx=function(e,t,i,n){var r,s,o=ze;if(0==i.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;r=i.shift(),s=o.getChildIdx(e,t);for(var a=0,u=0;u<s.length;u++){var c=e.substr(s[u],2);if("number"==typeof r&&!o.isContextTag(c)&&a==r||"string"==typeof r&&o.isContextTag(c,r))return o.getIdxbyListEx(e,s[u],i,n);o.isContextTag(c)||a++}return-1},ze.getTLVbyList=function(e,t,i,n){var r=ze,s=r.getIdxbyList(e,t,i,n);return-1==s||s>=e.length?null:r.getTLV(e,s)},ze.getTLVbyListEx=function(e,t,i,n){var r=ze,s=r.getIdxbyListEx(e,t,i,n);return-1==s?null:r.getTLV(e,s)},ze.getVbyList=function(e,t,i,n,r){var s,o,a=ze;return-1==(s=a.getIdxbyList(e,t,i,n))||s>=e.length?null:(o=a.getV(e,s),!0===r&&(o=o.substr(2)),o)},ze.getVbyListEx=function(e,t,i,n,r){var s,o,a=ze;return-1==(s=a.getIdxbyListEx(e,t,i,n))?null:(o=a.getV(e,s),"03"==e.substr(s,2)&&!1!==r&&(o=o.substr(2)),o)},ze.getInt=function(e,t,i){null==i&&(i=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return i;var r=ze.getV(e,t);return"02"==n?parseInt(r,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var i=parseInt(t,16),n=e.substr(2),r=parseInt(n,16).toString(2);return"0"==r&&(r="00000000"),r=r.slice(0,0-i),parseInt(r,2)}catch(e){return-1}}(r)}catch(e){return i}},ze.getOID=function(e,t,i){null==i&&(i=null);try{return"06"!=e.substr(t,2)?i:function(e){if(!fe(e))return null;try{var t=[],i=e.substr(0,2),n=parseInt(i,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var r=e.substr(2),s=[],o=0;o<r.length/2;o++)s.push(parseInt(r.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=ye((127&s[o]).toString(2),7):(u+=ye((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var c=t.join(".");return a.length>0&&(c=c+"."+a.join(".")),c}catch(e){return null}}(ze.getV(e,t))}catch(e){return i}},ze.getOIDName=function(e,t,i){null==i&&(i=null);try{var n=ze.getOID(e,t,i);if(n==i)return i;var r=A.asn1.x509.OID.oid2name(n);return""==r?n:r}catch(e){return i}},ze.getString=function(e,t,i){null==i&&(i=null);try{return ce(ze.getV(e,t))}catch(e){return i}},ze.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},i=[],n=e.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=e.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],c="";for(a=0;a<o.length;a++)128&o[a]?c+=t((127&o[a]).toString(2),7):(c+=t((127&o[a]).toString(2),7),u.push(new String(parseInt(c,2))),c="");var l=i.join(".");return u.length>0&&(l=l+"."+u.join(".")),l},ze.dump=function(e,t,i,n){var r=ze,s=r.getV,o=r.dump,a=r.getChildIdx,u=e;e instanceof A.asn1.ASN1Object&&(u=e.getEncodedHex());var c=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var l,h=t.ommit_long_octet;if("01"==(l=u.substr(i,2)))return"00"==(d=s(u,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==l)return n+"INTEGER "+c(d=s(u,i),h)+"\n";if("03"==l){var d=s(u,i);if(r.isASN1HEX(d.substr(2))){var p=n+"BITSTRING, encapsulates\n";return p+=o(d.substr(2),t,0,n+" ")}return n+"BITSTRING "+c(d,h)+"\n"}if("04"==l){d=s(u,i);if(r.isASN1HEX(d)){p=n+"OCTETSTRING, encapsulates\n";return p+=o(d,t,0,n+" ")}return n+"OCTETSTRING "+c(d,h)+"\n"}if("05"==l)return n+"NULL\n";if("06"==l){var M=s(u,i),f=A.asn1.ASN1Util.oidHexToInt(M),g=A.asn1.x509.OID.oid2name(f),y=f.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==l)return n+"ENUMERATED "+parseInt(s(u,i))+"\n";if("0c"==l)return n+"UTF8String '"+ue(s(u,i))+"'\n";if("13"==l)return n+"PrintableString '"+ue(s(u,i))+"'\n";if("14"==l)return n+"TeletexString '"+ue(s(u,i))+"'\n";if("16"==l)return n+"IA5String '"+ue(s(u,i))+"'\n";if("17"==l)return n+"UTCTime "+ue(s(u,i))+"\n";if("18"==l)return n+"GeneralizedTime "+ue(s(u,i))+"\n";if("1a"==l)return n+"VisualString '"+ue(s(u,i))+"'\n";if("1e"==l)return n+"BMPString '"+Me(s(u,i))+"'\n";if("30"==l){if("3000"==u.substr(i,4))return n+"SEQUENCE {}\n";p=n+"SEQUENCE\n";var v=t;if((2==(D=a(u,i)).length||3==D.length)&&"06"==u.substr(D[0],2)&&"04"==u.substr(D[D.length-1],2)){g=r.oidname(s(u,D[0]));var m=JSON.parse(JSON.stringify(t));m.x509ExtName=g,v=m}for(var N=0;N<D.length;N++)p+=o(u,v,D[N],n+" ");return p}if("31"==l){p=n+"SET\n";var D=a(u,i);for(N=0;N<D.length;N++)p+=o(u,t,D[N],n+" ");return p}if(0!=(128&(l=parseInt(l,16)))){var w=31&l;if(0!=(32&l)){for(p=n+"["+w+"]\n",D=a(u,i),N=0;N<D.length;N++)p+=o(u,t,D[N],n+" ");return p}d=s(u,i);if(ze.isASN1HEX(d)){var p=n+"["+w+"]\n";return p+=o(d,t,0,n+" ")}return("68747470"==d.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==w)&&(d=ue(d)),p=n+"["+w+"] "+d+"\n"}return n+"UNKNOWN("+l+") "+s(u,i)+"\n"},ze.isContextTag=function(e,t){var i,n;e=e.toLowerCase();try{i=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&i);try{return null!=t.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(t.substr(1,t.length-1),10))>31)&&(128==(192&i)&&(31&i)==n))}catch(e){return!1}},ze.isASN1HEX=function(e){var t=ze;if(e.length%2==1)return!1;var i=t.getVblen(e,0),n=e.substr(0,2),r=t.getL(e,0);return e.length-n.length-r.length==2*i},ze.checkStrictDER=function(e,t,i,n,r){var s=ze;if(void 0===i){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!A.lang.String.isHex(e))throw new Error("not hex string");i=e.length,r=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(e,t).length>2*r)throw new Error("L of TLV too long: idx="+t);var o=s.getVblen(e,t);if(o>n)throw new Error("value of L too long than hex: idx="+t);var a=s.getTLV(e,t),u=a.length-2-s.getL(e,t).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var c=e.substr(t,2);if("02"===c){var l=s.getVidx(e,t);if("00"==e.substr(l,2)&&e.charCodeAt(l+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(c,16)){for(var h=s.getVblen(e,t),d=0,p=s.getChildIdx(e,t),M=0;M<p.length;M++){d+=s.getTLV(e,p[M]).length,s.checkStrictDER(e,p[M],i,n,r)}if(2*h!=d)throw new Error("sum of children's TLV length and L unmatch: "+2*h+"!="+d)}},ze.oidname=function(e){var t=A.asn1;A.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var i=t.x509.OID.oid2name(e);return""===i&&(i=e),i},void 0!==A.asn1&&A.asn1||(A.asn1={}),void 0!==A.asn1.x509&&A.asn1.x509||(A.asn1.x509={}),A.asn1.x509.Certificate=function(e){A.asn1.x509.Certificate.superclass.constructor.call(this);var t=A.asn1,i=t.DERBitString,n=t.DERSequence,r=t.x509,s=r.TBSCertificate,o=r.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=this.params,t=e.sigalg;null!=e.sigalg.name&&(t=e.sigalg.name);var i=e.tbsobj.getEncodedHex(),n=new A.crypto.Signature({alg:t});n.init(e.cakey),n.updateHex(i),e.sighex=n.sign()},this.getPEM=function(){return de(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var e=this.params;if(null!=e.tbsobj&&null!=e.tbsobj||(e.tbsobj=new s(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new o({name:e.sigalg})),t.push(new i({hex:"00"+e.sighex})),new n({array:t}).getEncodedHex()},null!=e&&(this.params=e)},ve(A.asn1.x509.Certificate,A.asn1.ASN1Object),A.asn1.x509.TBSCertificate=function(e){A.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=A.asn1,i=t.x509,n=t.DERTaggedObject,r=t.DERInteger,s=t.DERSequence,o=i.AlgorithmIdentifier,a=i.Time,u=i.X500Name,c=i.Extensions,l=i.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(e){this.params=e},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version||1!=t.version){var i=2;null!=t.version&&(i=t.version-1);var h=new n({obj:new r({int:i})});e.push(h)}return e.push(new r(t.serial)),e.push(new o({name:t.sigalg})),e.push(new u(t.issuer)),e.push(new s({array:[new a(t.notbefore),new a(t.notafter)]})),e.push(new u(t.subject)),e.push(new l(Ie.getKey(t.sbjpubkey))),void 0!==t.ext&&t.ext.length>0&&e.push(new n({tag:"a3",obj:new c(t.ext)})),new A.asn1.DERSequence({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.TBSCertificate,A.asn1.ASN1Object),A.asn1.x509.Extensions=function(e){A.asn1.x509.Extensions.superclass.constructor.call(this);var t=A.asn1,i=t.DERSequence,n=t.x509;this.aParam=[],this.setByParam=function(e){this.aParam=e},this.getEncodedHex=function(){for(var e=[],t=0;t<this.aParam.length;t++){var r=this.aParam[t],s=r.extname,o=null;if(null!=r.extn)o=new n.PrivateExtension(r);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(r);else if("keyUsage"==s)o=new n.KeyUsage(r);else if("subjectAltName"==s)o=new n.SubjectAltName(r);else if("issuerAltName"==s)o=new n.IssuerAltName(r);else if("basicConstraints"==s)o=new n.BasicConstraints(r);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(r);else if("certificatePolicies"==s)o=new n.CertificatePolicies(r);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(r);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(r);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(r);else if("cRLNumber"==s)o=new n.CRLNumber(r);else if("cRLReason"==s)o=new n.CRLReason(r);else if("ocspNonce"==s)o=new n.OCSPNonce(r);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(r);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(r);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(r));o=new n.SubjectDirectoryAttributes(r)}null!=o&&e.push(o)}return new i({array:e}).getEncodedHex()},null!=e&&this.setByParam(e)},ve(A.asn1.x509.Extensions,A.asn1.ASN1Object),A.asn1.x509.Extension=function(e){A.asn1.x509.Extension.superclass.constructor.call(this);var t=A.asn1,i=t.DERObjectIdentifier,n=t.DEROctetString;t.DERBitString;var r=t.DERBoolean,s=t.DERSequence;this.getEncodedHex=function(){var e=new i({oid:this.oid}),t=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(e),this.critical&&o.push(new r),o.push(t),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==e&&void 0!==e.critical&&(this.critical=e.critical)},ve(A.asn1.x509.Extension,A.asn1.ASN1Object),A.asn1.x509.KeyUsage=function(e){A.asn1.x509.KeyUsage.superclass.constructor.call(this,e);var t=Oe.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==e&&(void 0!==e.bin&&(this.asn1ExtnValue=new A.asn1.DERBitString(e)),void 0!==e.names&&void 0!==e.names.length)){for(var i=e.names,n="000000000",r=0;r<i.length;r++)for(var s=0;s<t.length;s++)i[r]===t[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new A.asn1.DERBitString({bin:n})}},ve(A.asn1.x509.KeyUsage,A.asn1.x509.Extension),A.asn1.x509.BasicConstraints=function(e){A.asn1.x509.BasicConstraints.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERBoolean,n=t.DERInteger,r=t.DERSequence;this.getExtnValueHex=function(){var e=new Array;this.cA&&e.push(new i),this.pathLen>-1&&e.push(new n({int:this.pathLen}));var t=new r({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==e&&(void 0!==e.cA&&(this.cA=e.cA),void 0!==e.pathLen&&(this.pathLen=e.pathLen))},ve(A.asn1.x509.BasicConstraints,A.asn1.x509.Extension),A.asn1.x509.CRLDistributionPoints=function(e){A.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=A.asn1,i=t.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(e){for(var n=[],r=0;r<e.length;r++)if(e[r]instanceof A.asn1.ASN1Object)n.push(e[r]);else{var s=new i.DistributionPoint(e[r]);n.push(s)}this.asn1ExtnValue=new t.DERSequence({array:n})},this.setByOneURI=function(e){var t=new i.DistributionPoint({fulluri:e});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==e&&(void 0!==e.array?this.setByDPArray(e.array):void 0!==e.uri&&this.setByOneURI(e.uri))},ve(A.asn1.x509.CRLDistributionPoints,A.asn1.x509.Extension),A.asn1.x509.DistributionPoint=function(e){A.asn1.x509.DistributionPoint.superclass.constructor.call(this);var t=A.asn1,i=t.x509.DistributionPointName;this.getEncodedHex=function(){var e=new t.DERSequence;if(null!=this.asn1DP){var i=new t.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});e.appendASN1Object(i)}return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.dpobj?this.asn1DP=e.dpobj:void 0!==e.dpname?this.asn1DP=new i(e.dpname):void 0!==e.fulluri&&(this.asn1DP=new i({full:[{uri:e.fulluri}]})))},ve(A.asn1.x509.DistributionPoint,A.asn1.ASN1Object),A.asn1.x509.DistributionPointName=function(e){A.asn1.x509.DistributionPointName.superclass.constructor.call(this);var t=A.asn1,i=t.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new i({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==e)if(t.x509.GeneralNames.prototype.isPrototypeOf(e))this.type="full",this.tag="a0",this.asn1V=e;else{if(void 0===e.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new t.x509.GeneralNames(e.full)}},ve(A.asn1.x509.DistributionPointName,A.asn1.ASN1Object),A.asn1.x509.CertificatePolicies=function(e){A.asn1.x509.CertificatePolicies.superclass.constructor.call(this,e);var t=A.asn1,i=t.x509,n=t.DERSequence,r=i.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++)e.push(new r(this.params.array[t]));var i=new n({array:e});return this.asn1ExtnValue=i,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==e&&(this.params=e)},ve(A.asn1.x509.CertificatePolicies,A.asn1.x509.Extension),A.asn1.x509.PolicyInformation=function(e){A.asn1.x509.PolicyInformation.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.DERObjectIdentifier,r=t.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 e=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var t=[],s=0;s<this.params.array.length;s++)t.push(new r(this.params.array[s]));t.length>0&&e.push(new i({array:t}))}return new i({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.PolicyInformation,A.asn1.ASN1Object),A.asn1.x509.PolicyQualifierInfo=function(e){A.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.DERIA5String,r=t.DERObjectIdentifier,s=t.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==e&&(this.params=e)},ve(A.asn1.x509.PolicyQualifierInfo,A.asn1.ASN1Object),A.asn1.x509.UserNotice=function(e){A.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=A.asn1.DERSequence;A.asn1.DERInteger;var i=A.asn1.x509.DisplayText,n=A.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var e=[];return void 0!==this.params.noticeref&&e.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&e.push(new i(this.params.exptext)),new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.UserNotice,A.asn1.ASN1Object),A.asn1.x509.NoticeReference=function(e){A.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=A.asn1.DERSequence,i=A.asn1.DERInteger,n=A.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var e=[];if(void 0!==this.params.org&&e.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var r=[],s=this.params.noticenum,o=0;o<s.length;o++)r.push(new i(s[o]));e.push(new t({array:r}))}if(0==e.length)throw new Error("parameter is empty");return new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},ve(A.asn1.x509.NoticeReference,A.asn1.ASN1Object),A.asn1.x509.DisplayText=function(e){A.asn1.x509.DisplayText.superclass.constructor.call(this,e),this.hT="0c",void 0!==e&&("ia5"===e.type?this.hT="16":"vis"===e.type?this.hT="1a":"bmp"===e.type&&(this.hT="1e"))},ve(A.asn1.x509.DisplayText,A.asn1.DERAbstractString),A.asn1.x509.ExtKeyUsage=function(e){A.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,e);var t=A.asn1;this.setPurposeArray=function(e){this.asn1ExtnValue=new t.DERSequence;for(var i=0;i<e.length;i++){var n=new t.DERObjectIdentifier(e[i]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==e&&void 0!==e.array&&this.setPurposeArray(e.array)},ve(A.asn1.x509.ExtKeyUsage,A.asn1.x509.Extension),A.asn1.x509.AuthorityKeyIdentifier=function(e){A.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,e);var t=A,i=t.asn1,n=i.DERTaggedObject,r=i.x509.GeneralNames;t.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var e=new Array;this.asn1KID&&e.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&e.push(new n({explicit:!1,tag:"a1",obj:new r([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&e.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var t=new i.DERSequence({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new A.asn1.DEROctetString(e);else if("object"==typeof e&&A.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN ")){var t=e;"string"==typeof e&&(t=Ie.getKey(e));var i=Ie.getKeyID(t);this.asn1KID=new A.asn1.DEROctetString({hex:i})}},this.setCertIssuerByParam=function(e){void 0!==e.str||void 0!==e.ldapstr||void 0!==e.hex||void 0!==e.certsubject||void 0!==e.certissuer?this.asn1CertIssuer=new A.asn1.x509.X500Name(e):"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&-1!=e.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new A.asn1.x509.X500Name({certissuer:e}))},this.setCertSNByParam=function(e){if(void 0!==e.str||void 0!==e.bigint||void 0!==e.hex)this.asn1CertSN=new A.asn1.DERInteger(e);else if("string"==typeof e&&-1!=e.indexOf("BEGIN ")&&e.indexOf("CERTIFICATE")){var t=new Oe;t.readCertPEM(e);var i=t.getSerialNumberHex();this.asn1CertSN=new A.asn1.DERInteger({hex:i})}},this.oid="2.5.29.35",void 0!==e&&(void 0!==e.kid&&this.setKIDByParam(e.kid),void 0!==e.issuer&&this.setCertIssuerByParam(e.issuer),void 0!==e.sn&&this.setCertSNByParam(e.sn),void 0!==e.issuersn&&"string"==typeof e.issuersn&&-1!=e.issuersn.indexOf("BEGIN ")&&e.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(e.issuersn),this.setCertIssuerByParam(e.issuersn)))},ve(A.asn1.x509.AuthorityKeyIdentifier,A.asn1.x509.Extension),A.asn1.x509.SubjectKeyIdentifier=function(e){A.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,e);var t=A.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new t(e);else if("object"==typeof e&&A.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN")){var i=e;"string"==typeof e&&(i=Ie.getKey(e));var n=Ie.getKeyID(i);this.asn1KID=new A.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==e&&void 0!==e.kid&&this.setKIDByParam(e.kid)},ve(A.asn1.x509.SubjectKeyIdentifier,A.asn1.x509.Extension),A.asn1.x509.AuthorityInfoAccess=function(e){A.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,e),this.setAccessDescriptionArray=function(e){for(var t=new Array,i=A.asn1,n=i.DERSequence,r=i.DERObjectIdentifier,s=i.x509.GeneralName,o=0;o<e.length;o++){var a,u=e[o];if(void 0!==u.ocsp)a=new n({array:[new r({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 r({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}t.push(a)}this.asn1ExtnValue=new n({array:t})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==e&&void 0!==e.array&&this.setAccessDescriptionArray(e.array)},ve(A.asn1.x509.AuthorityInfoAccess,A.asn1.x509.Extension),A.asn1.x509.SubjectAltName=function(e){A.asn1.x509.SubjectAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new A.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},ve(A.asn1.x509.SubjectAltName,A.asn1.x509.Extension),A.asn1.x509.IssuerAltName=function(e){A.asn1.x509.IssuerAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new A.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},ve(A.asn1.x509.IssuerAltName,A.asn1.x509.Extension),A.asn1.x509.SubjectDirectoryAttributes=function(e){A.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERSequence,n=t.ASN1Util.newObject,r=t.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++){var s=this.params.array[t],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=r(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=r(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=r(s.attr),o.seq[1].set[0]={prnstr:s.str}}e.push(new n(o))}var a=new i({array:e});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==e&&(this.params=e)},ve(A.asn1.x509.SubjectDirectoryAttributes,A.asn1.x509.Extension),A.asn1.x509.PrivateExtension=function(e){A.asn1.x509.PrivateExtension.superclass.constructor.call(this,e);var t=A,i=t.lang.String.isHex,n=t.asn1,r=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(e){this.oid=r(e.extname),this.params=e},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var e=this.params.extn;if("string"==typeof e&&i(e))return e;if("object"==typeof e)try{return s(e).getEncodedHex()}catch(e){}throw new Error("unsupported extn value")},null!=e&&this.setByParam(e)},ve(A.asn1.x509.PrivateExtension,A.asn1.x509.Extension),A.asn1.x509.CRL=function(e){A.asn1.x509.CRL.superclass.constructor.call(this);var t=A.asn1,i=t.DERSequence,n=t.DERBitString,r=t.x509,s=r.AlgorithmIdentifier,o=r.TBSCertList;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=new o(this.params).getEncodedHex(),t=new A.crypto.Signature({alg:this.params.sigalg});t.init(this.params.cakey),t.updateHex(e);var i=t.sign();this.params.sighex=i},this.getPEM=function(){return de(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var e=this.params;if(null==e.tbsobj&&(e.tbsobj=new o(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new s({name:e.sigalg})),t.push(new n({hex:"00"+e.sighex})),new i({array:t}).getEncodedHex()},null!=e&&(this.params=e)},ve(A.asn1.x509.CRL,A.asn1.ASN1Object),A.asn1.x509.TBSCertList=function(e){A.asn1.x509.TBSCertList.superclass.constructor.call(this);var t=A.asn1,i=t.DERInteger,n=t.DERSequence,r=t.DERTaggedObject;t.DERObjectIdentifier;var s=t.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,c=s.X500Name;this.params=null,this.setByParam=function(e){this.params=e},this.getRevCertSequence=function(){for(var e=[],t=this.params.revcert,r=0;r<t.length;r++){var s=[new i(t[r].sn),new a(t[r].date)];null!=t[r].ext&&s.push(new u(t[r].ext)),e.push(new n({array:s}))}return new n({array:e})},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version){var s=t.version-1,l=new i({int:s});e.push(l)}if(e.push(new o({name:t.sigalg})),e.push(new c(t.issuer)),e.push(new a(t.thisupdate)),null!=t.nextupdate&&e.push(new a(t.nextupdate)),null!=t.revcert&&e.push(this.getRevCertSequence()),null!=t.ext){var h=new u(t.ext);e.push(new r({tag:"a0",explicit:!0,obj:h}))}return new n({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.TBSCertList,A.asn1.ASN1Object),A.asn1.x509.CRLEntry=function(e){A.asn1.x509.CRLEntry.superclass.constructor.call(this);var t=A.asn1;this.setCertSerial=function(e){this.sn=new t.DERInteger(e)},this.setRevocationDate=function(e){this.time=new t.x509.Time(e)},this.getEncodedHex=function(){var e=new t.DERSequence({array:[this.sn,this.time]});return this.TLV=e.getEncodedHex(),this.TLV},void 0!==e&&(void 0!==e.time&&this.setRevocationDate(e.time),void 0!==e.sn&&this.setCertSerial(e.sn))},ve(A.asn1.x509.CRLEntry,A.asn1.ASN1Object),A.asn1.x509.CRLNumber=function(e){A.asn1.x509.CRLNumber.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=e&&(this.params=e)},ve(A.asn1.x509.CRLNumber,A.asn1.x509.Extension),A.asn1.x509.CRLReason=function(e){A.asn1.x509.CRLReason.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=e&&(this.params=e)},ve(A.asn1.x509.CRLReason,A.asn1.x509.Extension),A.asn1.x509.OCSPNonce=function(e){A.asn1.x509.OCSPNonce.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=e&&(this.params=e)},ve(A.asn1.x509.OCSPNonce,A.asn1.x509.Extension),A.asn1.x509.OCSPNoCheck=function(e){A.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new A.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=e&&(this.params=e)},ve(A.asn1.x509.OCSPNoCheck,A.asn1.x509.Extension),A.asn1.x509.AdobeTimeStamp=function(e){A.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,e);var t=A.asn1,i=t.DERInteger,n=t.DERBoolean,r=t.DERSequence,s=t.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var e=this.params,t=[new i(1)];return t.push(new s({uri:e.uri})),null!=e.reqauth&&t.push(new n(e.reqauth)),this.asn1ExtnValue=new r({array:t}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.AdobeTimeStamp,A.asn1.x509.Extension),A.asn1.x509.X500Name=function(e){A.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.asn1,i=t.x509,n=i.RDN;this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.split("/");i.shift();for(var r=[],s=0;s<i.length;s++)if(i[s].match(/^[^=]+=.+$/))r.push(i[s]);else{var o=r.length-1;r[o]=r[o]+"/"+i[s]}for(s=0;s<r.length;s++)this.asn1Array.push(new n({str:r[s],rule:this.sRule}))},this.setByLdapString=function(e,t){void 0!==t&&(this.sRule=t);var n=i.X500Name.ldapToCompat(e);this.setByString(n,t)},this.setByObject=function(e,t){for(var i in void 0!==t&&(this.sRule=t),e)if(e.hasOwnProperty(i)){var r=new n({str:i+"="+e[i],rule:this.sRule});this.asn1Array?this.asn1Array.push(r):this.asn1Array=[r]}},this.setByParam=function(e){var t;(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.array)?this.paramArray=e.array:void 0!==e.str?this.setByString(e.str):void 0!==e.ldapstr?this.setByLdapString(e.ldapstr):void 0!==e.hex?this.hTLV=e.hex:void 0!==e.certissuer?((t=new Oe).readCertPEM(e.certissuer),this.hTLV=t.getIssuerHex()):void 0!==e.certsubject?((t=new Oe).readCertPEM(e.certsubject),this.hTLV=t.getSubjectHex()):"object"==typeof e&&void 0===e.certsubject&&void 0===e.certissuer&&this.setByObject(e)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i={array:this.paramArray[e]};"utf8"!=this.sRule&&(i.rule=this.sRule);var r=new n(i);this.asn1Array.push(r)}var s=new t.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.X500Name,A.asn1.ASN1Object),A.asn1.x509.X500Name.compatToLDAP=function(e){if("/"!==e.substr(0,1))throw"malformed input";var t=(e=e.substr(1)).split("/");return t.reverse(),(t=t.map((function(e){return e.replace(/,/,"\\,")}))).join(",")},A.asn1.x509.X500Name.onelineToLDAP=function(e){return A.asn1.x509.X500Name.compatToLDAP(e)},A.asn1.x509.X500Name.ldapToCompat=function(e){for(var t=e.split(","),i=!1,n=[],r=0;t.length>0;r++){var s=t.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(e){return e.replace("/","\\/")}))).reverse(),"/"+n.join("/")},A.asn1.x509.X500Name.ldapToOneline=function(e){return A.asn1.x509.X500Name.ldapToCompat(e)},A.asn1.x509.RDN=function(e){A.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=A.asn1.x509.AttributeTypeAndValue;this.setByParam=function(e){void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.str&&this.addByMultiValuedString(e.str),void 0!==e.array&&(this.paramArray=e.array)},this.addByString=function(e){this.asn1Array.push(new A.asn1.x509.AttributeTypeAndValue({str:e,rule:this.sRule}))},this.addByMultiValuedString=function(e){for(var t=A.asn1.x509.RDN.parseString(e),i=0;i<t.length;i++)this.addByString(t[i])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i=this.paramArray[e];void 0!==i.rule&&"utf8"!=this.sRule&&(i.rule=this.sRule);var n=new t(i);this.asn1Array.push(n)}var r=new A.asn1.DERSet({array:this.asn1Array});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.RDN,A.asn1.ASN1Object),A.asn1.x509.RDN.parseString=function(e){for(var t=e.split(/\+/),i=!1,n=[],r=0;t.length>0;r++){var s=t.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,u=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var c=u.pop();if(s.match(/"$/)){o=(c+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(c+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},A.asn1.x509.AttributeTypeAndValue=function(e){A.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=A,i=t.asn1,n=i.DERSequence,r=i.DERUTF8String,s=i.DERPrintableString,o=i.DERTeletexString,a=i.DERIA5String,u=i.DERVisibleString,c=i.DERBMPString,l=t.lang.String.isMail,h=t.lang.String.isPrintable;this.setByParam=function(e){if(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.ds&&(this.dsType=e.ds),void 0===e.value&&void 0!==e.str){var t=e.str.match(/^([^=]+)=(.+)$/);if(!t)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=t[1],this.sValue=t[2]}else this.sType=e.type,this.sValue=e.value},this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.match(/^([^=]+)=(.+)$/);if(!i)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(i[1],i[2])},this._getDsType=function(){var e=this.sType,t=this.sValue,i=this.sRule;return"prn"===i?"CN"==e&&l(t)?"ia5":h(t)?"prn":"utf8":"utf8"===i?"CN"==e&&l(t)?"ia5":"C"==e?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(e,t,i){void 0!==i&&(this.sRule=i),this.sType=e,this.sValue=t},this.getValueObj=function(e,t){if("utf8"==e)return new r({str:t});if("prn"==e)return new s({str:t});if("tel"==e)return new o({str:t});if("ia5"==e)return new a({str:t});if("vis"==e)return new u({str:t});if("bmp"==e)return new c({str:t});throw new Error("unsupported directory string type: type="+e+" value="+t)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var e=A.asn1.x509.OID.atype2obj(this.sType),t=this.getValueObj(this.dsType,this.sValue),i=new n({array:[e,t]});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.AttributeTypeAndValue,A.asn1.ASN1Object),A.asn1.x509.SubjectPublicKeyInfo=function(e){A.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=A,i=t.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,u=i.x509.AlgorithmIdentifier,c=t.crypto;c.ECDSA,c.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 e=this.getASN1Object();return this.hTLV=e.getEncodedHex(),this.hTLV},this.setPubKey=function(e){try{if(e instanceof ee){var t=a({seq:[{int:{bigint:e.n}},{int:{int:e.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+t})}}catch(e){}try{if(e instanceof A.crypto.ECDSA){var i=new s({name:e.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+e.pubKeyHex})}}catch(e){}try{if(e instanceof A.crypto.DSA){i=new a({seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:i});var o=new n({bigint:e.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(e){}},void 0!==e&&this.setPubKey(e)},ve(A.asn1.x509.SubjectPublicKeyInfo,A.asn1.ASN1Object),A.asn1.x509.Time=function(e){A.asn1.x509.Time.superclass.constructor.call(this);var t=A.asn1,i=t.DERUTCTime,n=t.DERGeneralizedTime;this.setTimeParams=function(e){this.timeParams=e},this.getEncodedHex=function(){var e=null;return e=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=e.getEncodedHex(),this.TLV},this.type="utc",void 0!==e&&(void 0!==e.type?this.type=e.type:void 0!==e.str&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)},ve(A.asn1.x509.Time,A.asn1.ASN1Object),A.asn1.x509.AlgorithmIdentifier=function(e){A.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=A.asn1,i=t.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 e=null;for(var n in i)n===this.nameAlg&&(e=i[n]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=t.x509.OID.name2obj(this.nameAlg));var r=[this.asn1Alg];null!==this.asn1Params&&r.push(this.asn1Params);var s=new t.DERSequence({array:r});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.name&&(this.nameAlg=e.name),void 0!==e.asn1params&&(this.asn1Params=e.asn1params),void 0!==e.paramempty&&(this.paramEmpty=e.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 t.DERNull)}},ve(A.asn1.x509.AlgorithmIdentifier,A.asn1.ASN1Object),A.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},A.asn1.x509.GeneralName=function(e){A.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=A.asn1;i.DERSequence;var n=i.DEROctetString,r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,u=Ae;this.explicit=!1,this.setByParam=function(e){var i=null;if(void 0!==e){if(void 0!==e.rfc822&&(this.type="rfc822",i=new r({str:e[this.type]})),void 0!==e.dns&&(this.type="dns",i=new r({str:e[this.type]})),void 0!==e.uri&&(this.type="uri",i=new r({str:e[this.type]})),void 0!==e.dn&&(this.type="dn",this.explicit=!0,i="string"==typeof e.dn?new a({str:e.dn}):e.dn instanceof A.asn1.x509.X500Name?e.dn:new a(e.dn)),void 0!==e.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:e.ldapdn})),void 0!==e.certissuer){this.type="dn",this.explicit=!0;var c=null;if((h=e.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=h.indexOf("-----BEGIN ")&&(c=u(h)),null==c)throw"certissuer param not cert";(d=new Oe).hex=c;var l=d.getIssuerHex();(i=new o).hTLV=l}if(void 0!==e.certsubj){this.type="dn",this.explicit=!0;var h,d;c=null;if((h=e.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=h.indexOf("-----BEGIN ")&&(c=u(h)),null==c)throw"certsubj param not cert";(d=new Oe).hex=c;l=d.getSubjectHex();(i=new o).hTLV=l}if(void 0!==e.ip){this.type="ip",this.explicit=!1;var p,M=e.ip,f="malformed IP address";if(M.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(p=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map((function(e,t,i){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(e){throw"malformed integer array string: "+e}}("["+M.split(".").join(",")+"]")).length)throw f}else if(M.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))p=function(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var i=(e=e.toLowerCase()).split(":").length-1;if(i<2)throw t;var n=":".repeat(7-i+2),r=(e=e.replace("::",n)).split(":");if(8!=r.length)throw t;for(var s=0;s<8;s++)r[s]=("0000"+r[s]).slice(-4);return r.join("")}(M);else{if(!M.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw f;p=M}i=new n({hex:p})}if(null==this.type)throw"unsupported type in params="+e;this.asn1Obj=new s({explicit:this.explicit,tag:t[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==e&&this.setByParam(e)},ve(A.asn1.x509.GeneralName,A.asn1.ASN1Object),A.asn1.x509.GeneralNames=function(e){A.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=A.asn1;this.setByParamArray=function(e){for(var i=0;i<e.length;i++){var n=new t.x509.GeneralName(e[i]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new t.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==e&&this.setByParamArray(e)},ve(A.asn1.x509.GeneralNames,A.asn1.ASN1Object),A.asn1.x509.OID=new function(e){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(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var t=this.name2oidList[e],i=new A.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var t;if(e.match(/^\d+\.\d+\.[0-9.]+$/))t=e;else if(void 0!==this.atype2oidList[e])t=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw"AttributeType name undefined: "+e;t=this.name2oidList[e]}var i=new A.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i}},A.asn1.x509.OID.oid2name=function(e){var t=A.asn1.x509.OID.name2oidList;for(var i in t)if(t[i]==e)return i;return""},A.asn1.x509.OID.oid2atype=function(e){var t=A.asn1.x509.OID.atype2oidList;for(var i in t)if(t[i]==e)return i;return e},A.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=A.asn1.x509.OID.name2oidList;return void 0===t[e]?"":t[e]},A.asn1.x509.X509Util={},A.asn1.x509.X509Util.newCertPEM=function(e){var t=A.asn1.x509;return t.TBSCertificate,new(0,t.Certificate)(e).getPEM()},ee.getPosArrayOfChildrenFromHex=function(e){return ze.getChildIdx(e,0)},ee.getHexValueArrayOfChildrenFromHex=function(e){var t,i=ze.getV,n=i(e,(t=ee.getPosArrayOfChildrenFromHex(e))[0]),r=i(e,t[1]),s=i(e,t[2]),o=i(e,t[3]),a=i(e,t[4]),u=i(e,t[5]),c=i(e,t[6]),l=i(e,t[7]),h=i(e,t[8]);return(t=new Array).push(n,r,s,o,a,u,c,l,h),t},ee.prototype.readPrivateKeyFromPEMString=function(e){var t=Ae(e),i=ee.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ee.prototype.readPKCS5PrvKeyHex=function(e){var t=ee.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},ee.prototype.readPKCS8PrvKeyHex=function(e){var t,i,n,r,s,o,a,u,c=ze,l=c.getVbyListEx;if(!1===c.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),i=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),r=l(e,0,[2,0,4],"02"),s=l(e,0,[2,0,5],"02"),o=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),u=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,i,n,r,s,o,a,u)},ee.prototype.readPKCS5PubKeyHex=function(e){var t=ze,i=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var r=i(e,n[0]),s=i(e,n[1]);this.setPublic(r,s)},ee.prototype.readPKCS8PubKeyHex=function(e){var t=ze;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var i=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(i)},ee.prototype.readCertPubKeyHex=function(e,t){var i,n;(i=new Oe).readCertHex(e),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},ee.prototype.sign=function(e,t){var i,n=(i=e,A.crypto.Util.hashString(i,t));return this.signWithMessageHash(n,t)},ee.prototype.signWithMessageHash=function(e,t){var i=J(A.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return be(this.doPrivate(i).toString(16),this.n.bitLength())},ee.prototype.signPSS=function(e,t,i){var n,r=(n=le(e),A.crypto.Util.hashHex(n,t));return void 0===i&&(i=-1),this.signWithMessageHashPSS(r,t,i)},ee.prototype.signWithMessageHashPSS=function(e,t,i){var n,r=ce(e),s=r.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(e){return A.crypto.Util.hashHex(e,t)};if(-1===i||void 0===i)i=s;else if(-2===i)i=a-s-2;else if(i<-2)throw new Error("invalid salt length");if(a<s+i+2)throw new Error("data too long");var c="";i>0&&(c=new Array(i),(new K).nextBytes(c),c=String.fromCharCode.apply(String,c));var l=ce(u(le("\0\0\0\0\0\0\0\0"+r+c))),h=[];for(n=0;n<a-i-s-2;n+=1)h[n]=0;var d=String.fromCharCode.apply(String,h)+""+c,p=Le(l,d.length,u),M=[];for(n=0;n<d.length;n+=1)M[n]=d.charCodeAt(n)^p.charCodeAt(n);var g=65280>>8*a-o&255;for(M[0]&=~g,n=0;n<s;n++)M.push(l.charCodeAt(n));return M.push(188),be(this.doPrivate(new f(M)).toString(16),this.n.bitLength())},ee.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var i=J(t,16),n=this.n.bitLength();if(i.bitLength()>n)return!1;var r=this.doPublic(i).toString(16);if(r.length+3!=n/4)return!1;var s=Se(r.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=e,A.crypto.Util.hashString(o,a))},ee.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=J(t,16);if(i.bitLength()>this.n.bitLength())return 0;var n=Se(this.doPublic(i).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},ee.prototype.verifyPSS=function(e,t,i,n){var r=function(e){return A.crypto.Util.hashHex(e,i)}(le(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(r,t,i,n)},ee.prototype.verifyWithMessageHashPSS=function(e,t,i,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r,s=new f(t,16),o=function(e){return A.crypto.Util.hashHex(e,i)},a=ce(e),u=a.length,c=this.n.bitLength()-1,l=Math.ceil(c/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=l-u-2;else if(n<-2)throw new Error("invalid salt length");if(l<u+n+2)throw new Error("data too long");var h=this.doPublic(s).toByteArray();for(r=0;r<h.length;r+=1)h[r]&=255;for(;h.length<l;)h.unshift(0);if(188!==h[l-1])throw new Error("encoded message does not end in 0xbc");var d=(h=String.fromCharCode.apply(String,h)).substr(0,l-u-1),p=h.substr(d.length,u),M=65280>>8*l-c&255;if(0!=(d.charCodeAt(0)&M))throw new Error("bits beyond keysize not zero");var g=Le(p,d.length,o),y=[];for(r=0;r<d.length;r+=1)y[r]=d.charCodeAt(r)^g.charCodeAt(r);y[0]&=~M;var v=l-u-n-2;for(r=0;r<v;r+=1)if(0!==y[r])throw new Error("leftmost octets not zero");if(1!==y[v])throw new Error("0x01 marker not found");return p===ce(o(le("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},ee.SALT_LEN_HLEN=-1,ee.SALT_LEN_MAX=-2,ee.SALT_LEN_RECOVER=-2,Oe.hex2dn=function(e,t){void 0===t&&(t=0);var i=new Oe;return ze.getTLV(e,t),i.getX500Name(e).str},Oe.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var i=new Array,n=ze.getChildIdx(e,t),r=0;r<n.length;r++)i.push(Oe.hex2attrTypeValue(e,n[r]));return(i=i.map((function(e){return e.replace("+","\\+")}))).join("+")},Oe.hex2attrTypeValue=function(e,t){var i=ze,n=i.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var r=i.getChildIdx(e,t);2!==r.length||e.substr(r[0],2);var s=n(e,r[0]),o=A.asn1.ASN1Util.oidHexToInt(s);return A.asn1.x509.OID.oid2atype(o)+"="+ce(n(e,r[1]))},Oe.getPublicKeyFromCertHex=function(e){var t=new Oe;return t.readCertHex(e),t.getPublicKey()},Oe.getPublicKeyFromCertPEM=function(e){var t=new Oe;return t.readCertPEM(e),t.getPublicKey()},Oe.getPublicKeyInfoPropOfCertPEM=function(e){var t,i,n=ze.getVbyList,r={};return r.algparam=null,(t=new Oe).readCertPEM(e),i=t.getPublicKeyHex(),r.keyhex=n(i,0,[1],"03").substr(2),r.algoid=n(i,0,[0,0],"06"),"2a8648ce3d0201"===r.algoid&&(r.algparam=n(i,0,[0,1],"06")),r},Oe.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var Pe,ke=[(Pe=new Oe,Pe.readCertPEM(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}(":::::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:::::")),Pe)];function Be(e,t){var i=e.getIssuerHex();if(i===e.getSubjectHex())return e.verifySignature(e.getPublicKey());var n=function(e,t){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r.getSubjectHex()===e)return r}}(i,t);return!!n&&(!1!==e.verifySignature(n.getPublicKey())&&Be(n,t))}function Ue(e){return e.getIssuerHex()!==e.getSubjectHex()&&Be(e,ke)}!function(e){var t=new Oe;"string"==typeof e?t.readCertPEM(e):t.readCertHex(e.hex);var i=Ue(t);ke.push(t)}(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}(":::::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 Qe=2*Math.PI;function _e(e){return(e%Qe+Qe)%Qe}var Re=function(e){function i(t){var i=e.call(this,t,1,.1,1e3)||this;return i.pose={longitude:0,latitude:0,fov:t,offset:new a.Vector3},i.computePose(),i}return t.__extends(i,e),i.prototype.computePose=function(){var e=this.getWorldDirection(new a.Vector3);this.pose.longitude=_e(-Math.atan2(e.x,-e.z)),this.pose.latitude=-Math.asin(e.y/1),this.pose.fov=this.fov,this.pose.offset.copy(this.position)},i.prototype.setFromPose=function(e){var t,i,n,r,s=_e(null!==(t=e.longitude)&&void 0!==t?t:this.pose.longitude),o=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,null!==(i=e.latitude)&&void 0!==i?i:this.pose.latitude)),u=null!==(n=e.fov)&&void 0!==n?n:this.pose.fov,c=null!==(r=e.offset)&&void 0!==r?r:this.pose.offset;this.position.copy(c);var l=Math.abs(Math.cos(o)),h=new a.Vector3(-Math.sin(s)*l,-Math.sin(o),-Math.cos(s)*l);this.lookAt(c.clone().add(h)),this.fov!==u&&(this.fov=u,this.updateProjectionMatrix()),this.updateMatrixWorld(),this.pose.longitude=s,this.pose.latitude=o,this.pose.fov=u,this.pose.offset.copy(c)},i.prototype.copyPose=function(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,offset:this.pose.offset.clone()}},i}(a.PerspectiveCamera),Ye=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.add=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.add.apply(this,t)},i.prototype.remove=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.remove.apply(this,t)},i}(a.Scene),Fe=function(e){function i(t){var i=t.preserveDrawingBuffer,n=void 0===i||i,r=t.backgroundColor,s=void 0===r?1579548:r,o=t.backgroundAlpha,u=void 0===o?1:o,c=t.pixelRatio,l=void 0===c?1:c,h=t.antialias,d=void 0!==h&&h,A=e.call(this,{antialias:d,preserveDrawingBuffer:n,alpha:u<1})||this;return A.setPixelRatio(l),A.setClearColor(s,u),A.outputEncoding=a.sRGBEncoding,A.autoClear=!0,A}return t.__extends(i,e),i}(a.WebGLRenderer);function Ve(e){return null==e}function He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]}function Ge(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function qe(){return(Ge()+Ge()+"-"+Ge()+"-4"+Ge().substr(0,3)+"-"+Ge()+"-"+Ge()+Ge()+Ge()).toLowerCase()}var We="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),Ze="undefined"!=typeof performance?function(){return We+performance.now()}:function(){return Date.now()},Xe=function(){if("undefined"!=typeof window){var e=window;return e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||e.msRequestAnimationFrame||function(e){return setTimeout(e,16)}}return function(e){return setTimeout(e,16)}}();function Ke(e,t){void 0===e&&(e=He),void 0===t&&(t=0),Xe(t<=0?e:function(){return Ke(e,t-1)})}function Je(e,i){void 0===e&&(e=He);for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var s=!1,o=function(r){e.call.apply(e,t.__spreadArray([i,r],n,!1)),s||"function"!=typeof o||Xe(o)};return Xe(o),function(){o=null,s=!0}}var $e=0;function et(e){$e&&e($e);var t=Ze();Xe((function(){e($e=Ze()-t)}))}et(He);var tt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t.needsRender=!0,t}return t.__extends(i,e),i}(a.Mesh),it=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.needsRender=!0,t}return t.__extends(i,e),i.prototype.getTransparent=function(){var e;return this.traverse((function(t){void 0===e&&t instanceof tt&&t.material.forEach((function(t){void 0===e&&1===t.uniforms.originOpacity.value&&(e=t.transparent)}))})),null!=e&&e},i.prototype.setTransparent=function(e){this.traverse((function(t){t instanceof tt&&t.material.forEach((function(t){1===t.uniforms.originOpacity.value&&(t.transparent=e)}))}))},i.prototype.getMaterial=function(){var e=null;return this.traverse((function(t){if(null===e&&t instanceof tt){var i=t.material[0];e={pano0Map:i.pano0Map,pano0Matrix:i.pano0Matrix,pano1Map:i.pano1Map,pano1Matrix:i.pano1Matrix,modelAlpha:i.modelAlpha,progress:i.progress,useBlackTransition:i.useBlackTransition,perspToOrtho:i.perspToOrtho,opacity:i.opacity,pano0DepthMap:i.pano0DepthMap,panoVideoMap:i.panoVideoMap,panoVideoSize:i.panoVideoSize,panoVideoMatrix:i.panoVideoMatrix,panoVideoAlpha:i.panoVideoAlpha,panoTileMap:i.panoTileMap,panoTileMappings:i.panoTileMappings}}})),e},i.prototype.setMaterial=function(e){this.traverse((function(t){t instanceof tt&&t.material.forEach((function(t){void 0!==e.pano0Map&&(t.pano0Map=e.pano0Map),void 0!==e.pano0Matrix&&(t.pano0Matrix=e.pano0Matrix),void 0!==e.pano1Map&&(t.pano1Map=e.pano1Map),void 0!==e.pano1Matrix&&(t.pano1Matrix=e.pano1Matrix),void 0!==e.modelAlpha&&(t.modelAlpha=e.modelAlpha),void 0!==e.progress&&(t.progress=e.progress),void 0!==e.useBlackTransition&&(t.useBlackTransition=e.useBlackTransition),void 0!==e.perspToOrtho&&(t.perspToOrtho=e.perspToOrtho),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.pano0DepthMap&&(t.pano0DepthMap=e.pano0DepthMap),void 0!==e.panoVideoMap&&(t.panoVideoMap=e.panoVideoMap),void 0!==e.panoVideoSize&&(t.panoVideoSize=e.panoVideoSize),void 0!==e.panoVideoMatrix&&(t.panoVideoMatrix=e.panoVideoMatrix),void 0!==e.panoVideoAlpha&&(t.panoVideoAlpha=e.panoVideoAlpha),void 0!==e.panoTileMap&&(t.panoTileMap=e.panoTileMap),void 0!==e.panoTileMappings&&(t.panoTileMappings=e.panoTileMappings)}))}))},i.prototype.disposeMaterial=function(){this.traverse((function(e){if(e instanceof tt){var t=[];e.material.forEach((function(e){var i=e.uniforms;Object.keys(i).map((function(e){if(["pano0Map","pano1Map","pano0DepthMap","panoVideoMap","panoTileMap"].indexOf(e)>=0)i[e].value=null;else{var n=i[e].value;n&&"function"==typeof n.dispose&&-1===t.indexOf(n)&&(i[e].value=null,t.push(n))}})),e.dispose()})),t.forEach((function(e){return e.dispose()}))}}))},i.prototype.disposeGeometry=function(){this.traverse((function(e){e instanceof tt&&e.geometry.dispose()}))},i}(a.Group),nt=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t}return t.__extends(i,e),i}(it),rt=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("n\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{H{vs|z-znA-}n{|=ZnvH{vs|z-znA-}n{|>ZnvH{vs|z-rp@-z|qryPr{rH{vs|z-sy|n-}r}a|\\u|Hn\bv{t-rp@-}n{|=a|crrHn\bv{t-rp@-}n{|>a|crrH0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq-5b`Rl]N[\\=lQR]aUlZN]6--n\bv{t-rp@-pnzrna|crrH0r{qvs0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|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--rp@-|yq]|vv|{-J-5z|qryZnv-7-n{s|zrq6;\b\tH--0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq-5b`Rl]N[\\=lQR]aUlZN]6----pnzrna|crr-J-|yq]|vv|{-:-pnzrn]|vv|{H--0r{qvs--}n{|=a|crr-J-5|yq]|vv|{-:-}n{|=Znvh@j;\b\t6-7-zn@5}n{|=Znv6H--}n{|>a|crr-J-5|yq]|vv|{-:-}n{|>Znvh@j;\b\t6-7-zn@5}n{|>Znv6H--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--rp@-pnzrn[|zny-J-5z|qrycvrZnv-7-rpA5=;=9-=;=9->;=9-=;=66;\b\tH--sy|n-|u|Qvn{pr-J-zn5=;=>9-q|5pnzrn[|zny9-z|qryPr{r-:-pnzrn]|vv|{66H--tyl]|vv|{;-J-zv5-tyl]|vv|{;9-tyl]|vv|{;-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H--tyl]|vv|{;\b-J-zv5-tyl]|vv|{;\b9-tyl]|vv|{;\b-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H\f"),st=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("{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-|vtv{\\}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-nz}yrPor-}n{|=Zn}H{vs|z-nz}yrPor-}n{|>Zn}H{vs|z-nz}yrPor-}n{|=Qr}uZn}H{vs|z-rp?-}n{|cvqr|`v\trH{vs|z-znA-}n{|cvqr|ZnvH{vs|z-sy|n-}n{|cvqr|Ny}unH{vs|z-nz}yr?Q-}n{|cvqr|Zn}H0vs-qrsv{rq5b`RlaVYR6--{vs|z-nz}yr?Q-}n{|avyrZn}H--{vs|z-rpA-}n{|avyrPyv}Zn}}v{thaVYRlZN]]V[TlYR[TaUjH--{vs|z-rpA-}n{|avyrQnNZn}}v{thaVYRlZN]]V[TlYR[TaUjH0r{qvs0vs-.qrsv{rq5b`RlOYNPXla_N[`VaV\\[6-33-qrsv{rq5b`Rl]N[\\=lQR]aUlZN]6--n\bv{t-rp@-pnzrna|crrH0r{qvsn\bv{t-rp@-}n{|=a|crrHn\bv{t-rp@-}n{|>a|crrH0v{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{K0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=9-=;=9-=;=9->;=60qrsv{r-]Vl?-C;?E@>EB?rp?-|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-<-]Vl?9-urn-<-]V6H\f|vq-znv{56-\n--rpA-qvssrP|y|-J-rpA5qvssr9-|vtv{\\}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--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=Zn}9-}n{|=a|crr6H--0vs-qrsv{rq5b`RlaVYR6----rp?-vyrlp||q-J-|P||q5}n{|=a|crr6H----rpA-vyrlpyv}H----rpA-vyrlqnNH----rp?-vyrlH----sy|n-vyrlny}unH----0}ntzn-{|yyly||}lnH----s|-5v{-v-J-=H-v-I-aVYRlZN]]V[TlYR[TaUH-v886-\n------vyrlpyv}-J-}n{|avyrPyv}Zn}}v{thvjH------vyrlqnN-J-}n{|avyrQnNZn}}v{thvjH------vyrl;-J-5vyrlp||q;-:-vyrlpyv}h=j6-<-vyrlpyv}h?jH------vyrl;\b-J-5vyrlp||q;\b-:-vyrlpyv}h>j6-<-vyrlpyv}h@jH------vyrlny}un-J-5>;=-:-r}5=;B9-no5vyrl;-:-=;B666-7-5>;=-:-r}5=;B9-no5vyrl;\b-:-=;B666H------vyrl;-J-vyrlqnNh=j-8-vyrl;-7-vyrlqnNh?jH------vyrl;\b-J-vyrlqnNh>j-8-vyrl;\b-7-vyrlqnNh@jH------vyrlny}un-J-prvy5vyrlny}un-7-vyrlqnNh?j6H------}n{|=P|y|-J-zv5}n{|=P|y|9-rr?Q5}n{|avyrZn}9-vyrl69-vyrlny}un6H----\f----0}ntzn-{|yyly||}lr{q--0r{qvs--rpA-}n{|>P|y|-J-rrPor5}n{|>Zn}9-}n{|>a|crr6H--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----0vs-qrsv{rq5b`Rl]N[\\=lQR]aUlZN]6------rpA-}n{|=Qr}uP|y|-J-rrPor5}n{|=Qr}uZn}9-pnzrna|crr6H------sy|n-qrynQvn{pr=-J-no5{}npx_TONa|Qr}u5}n{|=Qr}uP|y|6-7->=;=-:-yr{tu5}n{|=a|crr66H------sy|n-ynry-J-pynz}5}|tr-7-5>;=-8-qrynQvn{pr=-7-=;FB69-=;=9->;=6H----0ryr------sy|n-ynry-J-}|trH----0r{qvs----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-ynry6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\lZN]6----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|ZnvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|`v\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|`v\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|Zn}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|Ny}un6H--0r{qvs--tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H--tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H\f"),ot=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.hash=qe(),t.meta=[null,null,null,null,null,null],t}return t.__extends(i,e),i}(a.CubeTexture);function at(){return"undefined"==typeof document?{}:document.createElementNS("http://www.w3.org/1999/xhtml","img")}var ut=at();ut.width=ut.height=8;var ct=new a.Texture(ut),lt=new ot([ut,ut,ut,ut,ut,ut]);ct.dispose=lt.dispose=function(){};var ht=Object.assign({modelAlpha:new a.Uniform(0),originOpacity:new a.Uniform(1),progress:new a.Uniform(0),pano0Map:new a.Uniform(null),pano0Matrix:new a.Uniform(new a.Matrix4),pano1Map:new a.Uniform(null),pano1Matrix:new a.Uniform(new a.Matrix4),pano0DepthMap:new a.Uniform(null),panoVideoMap:new a.Uniform(null),panoVideoSize:new a.Uniform(new a.Vector2),panoVideoMatrix:new a.Uniform(new a.Matrix4),panoVideoAlpha:new a.Uniform(0),modelCenter:new a.Uniform(new a.Vector3),perspToOrtho:new a.Uniform(0),panoTileMap:new a.Uniform(null),panoTileClipMappings:new a.Uniform([]),panoTileDrawAtMappings:new a.Uniform([])},{exposure:new a.Uniform(1),emissive:new a.Uniform(new a.Color(0)),emissiveMap:new a.Uniform(null),specular:new a.Uniform(new a.Color(1118481)),specularMap:new a.Uniform(null),normalMap:new a.Uniform(null),bumpMap:new a.Uniform(null),shininess:new a.Uniform(30)},a.UniformsLib.common,a.UniformsLib.lights),dt=function(e){function i(t){var i,n,r,s,o,u,c,l,h,d,A,p,M,f,g,y;void 0===t&&(t={});var v=e.call(this,{vertexShader:rt,fragmentShader:st,uniforms:a.UniformsUtils.clone(ht),defines:{USE_MAP:!0,USE_UV:!0,USE_TILE:!1,TILE_MAPPING_LENGTH:0,USE_BLACK_TRANSITION:!1,USE_PANO0_DEPTH_MAP:!1,USE_PANO_VIDEO_MAP:!1},lights:!0})||this;return Object.defineProperties(v,{pano0Map:{get:function(){var e=this.uniforms.pano0Map.value;return e===lt?null:e},set:function(e){this.uniforms.pano0Map.value=null===e?lt:e}},pano0Matrix:{get:function(){return this.uniforms.pano0Matrix.value.clone()},set:function(e){this.uniforms.pano0Matrix.value.copy(e)}},pano1Map:{get:function(){var e=this.uniforms.pano1Map.value;return e===lt?null:e},set:function(e){this.uniforms.pano1Map.value=null===e?lt:e}},pano1Matrix:{get:function(){return this.uniforms.pano1Matrix.value.clone()},set:function(e){this.uniforms.pano1Matrix.value.copy(e)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(e){this.uniforms.modelAlpha.value=e}},progress:{get:function(){return this.uniforms.progress.value},set:function(e){this.uniforms.progress.value=e}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(e){this.defines.USE_BLACK_TRANSITION!==e&&(this.defines.USE_BLACK_TRANSITION=e,this.needsUpdate=!0)}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},perspToOrtho:{get:function(){return this.uniforms.perspToOrtho.value},set:function(e){this.uniforms.perspToOrtho.value=e}},pano0DepthMap:{get:function(){return this.uniforms.pano0DepthMap.value},set:function(e){this.uniforms.pano0DepthMap.value=e;var t=null!==e;t!==this.defines.USE_PANO0_DEPTH_MAP&&(this.defines.USE_PANO0_DEPTH_MAP=t,this.needsUpdate=!0)}},panoVideoMap:{get:function(){return this.uniforms.panoVideoMap.value},set:function(e){this.uniforms.panoVideoMap.value=e;var t=null!==e;t!==this.defines.USE_PANO_VIDEO_MAP&&(this.defines.USE_PANO_VIDEO_MAP=t,this.needsUpdate=!0)}},panoVideoSize:{get:function(){return this.uniforms.panoVideoSize.value.clone()},set:function(e){this.uniforms.panoVideoSize.value.copy(e)}},panoVideoMatrix:{get:function(){return this.uniforms.panoVideoMatrix.value.clone()},set:function(e){this.uniforms.panoVideoMatrix.value.copy(e)}},panoVideoAlpha:{get:function(){return this.uniforms.panoVideoAlpha.value},set:function(e){this.uniforms.panoVideoAlpha.value=e}},panoTileMap:{get:function(){return this.uniforms.panoTileMap.value},set:function(e){this.uniforms.panoTileMap.value=e;var t=null!==e;t!==this.defines.USE_TILE&&(this.defines.USE_TILE=t,this.needsUpdate=!0)}},panoTileMappings:{get:function(){var e=this.uniforms.panoTileClipMappings.value,t=this.uniforms.panoTileDrawAtMappings.value;if(null===e)return null;for(var i=[],n=0;n<e.length;n++)i[n]=[e[n].clone(),t[n].clone()];return i},set:function(e){var t=this.defines.TILE_MAPPING_LENGTH;if(null===e)this.uniforms.panoTileClipMappings.value=null,this.uniforms.panoTileDrawAtMappings.value=null;else{for(var i=[],n=[],r=0;r<e.length;r++)i[r]=e[r][0].clone(),n[r]=e[r][1].clone();this.uniforms.panoTileClipMappings.value=i,this.uniforms.panoTileDrawAtMappings.value=n}var s=null!==e?e.length:0;s!==t&&(this.defines.TILE_MAPPING_LENGTH=s,this.needsUpdate=!0)}}}),v.pano0Map=null!==(i=t.pano0Map)&&void 0!==i?i:lt,v.pano0Matrix=null!==(n=t.pano0Matrix)&&void 0!==n?n:new a.Matrix4,v.pano1Map=null!==(r=t.pano1Map)&&void 0!==r?r:lt,v.pano1Matrix=null!==(s=t.pano1Matrix)&&void 0!==s?s:new a.Matrix4,v.modelAlpha=null!==(o=t.modelAlpha)&&void 0!==o?o:1,v.progress=null!==(u=t.progress)&&void 0!==u?u:0,v.useBlackTransition=null!==(c=t.useBlackTransition)&&void 0!==c&&c,v.perspToOrtho=null!==(l=t.perspToOrtho)&&void 0!==l?l:0,v.opacity=null!==(h=t.opacity)&&void 0!==h?h:1,v.pano0DepthMap=null!==(d=t.pano0DepthMap)&&void 0!==d?d:null,v.panoVideoSize=null!==(A=t.panoVideoSize)&&void 0!==A?A:new a.Vector2,v.panoVideoMap=null!==(p=t.panoVideoMap)&&void 0!==p?p:null,v.panoVideoMatrix=null!==(M=t.panoVideoMatrix)&&void 0!==M?M:new a.Matrix4,v.panoVideoAlpha=null!==(f=t.panoVideoAlpha)&&void 0!==f?f:0,v.panoTileMap=null!==(g=t.panoTileMap)&&void 0!==g?g:null,v.panoTileMappings=null!==(y=t.panoTileMappings)&&void 0!==y?y:null,v}return t.__extends(i,e),i}(a.ShaderMaterial),At=new a.Vector3(0,0,0),pt=function(e){function i(t,i){void 0===i&&(i=At);var n=e.call(this)||this,r=new a.BoxBufferGeometry(t.max.x-t.min.x+2*i.x,t.max.y-t.min.y+2*i.y,t.max.z-t.min.z+2*i.z,1,1);r.groups.length=0,r.groups.push({start:0,count:36,materialIndex:0}),r.applyMatrix4((new a.Matrix4).makeScale(-1,1,1));var s=new dt;s.defines.USE_MAP=!1,s.defines.USE_UV=!1,s.uniforms.diffuse.value=new a.Color(16777215);var o=new tt(r,[s]);return o.floorIndex=-1,o.position.copy(t.getCenter(new a.Vector3)),o.frustumCulled=!1,n.add(o),n}return t.__extends(i,e),i.prototype.dispose=function(){this.disposeMaterial(),this.disposeGeometry()},i}(nt);function Mt(e,t){return void 0===t&&(t=At),new pt(e,t)}var ft,gt,yt,vt,mt={};mt.EPSILON=1e-6,mt.BVHVector3=function(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0},mt.BVHVector3.prototype={constructor:mt.BVHVector3,copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setFromArray:function(e,t){this.x=e[t],this.y=e[t+1],this.z=e[t+2]},add:function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},cross:function(e){var t=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-t*e.z,this.z=t*e.y-i*e.x,this},crossVectors:function(e,t){var i=e.x,n=e.y,r=e.z,s=t.x,o=t.y,a=t.z;return this.x=n*a-r*o,this.y=r*s-i*a,this.z=i*o-n*s,this},clone:function(){return new mt.BVHVector3(this.x,this.y,this.z)}},mt.BVH=function(e,t){this._trianglesArray=e,this._maxTrianglesPerNode=t||10,this._bboxArray=this.calcBoundingBoxes(e),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var i=e.length/9,n=this.calcExtents(0,i,mt.EPSILON);this._rootNode=new mt.BVHNode(n[0],n[1],0,i,0),this._nodesToSplit=[this._rootNode]},mt.BVH.prototype.splitNode=function(e){if(e){var t=0,i=function(){t++;var n=this._nodesToSplit.pop();n?(this._splitNode(n),t%255==0?setTimeout(i):i()):(t=0,e())}.bind(this);i()}else for(;this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},mt.BVH.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit=null},mt.BVH.prototype.intersectRay=function(e,t,i){for(var n,r=[this._rootNode],s=[],o=[],a=new mt.BVHVector3(1/t.x,1/t.y,1/t.z);r.length>0;){var u=r.pop();if(mt.BVH.intersectNodeBox(e,a,u))for(u._node0&&r.push(u._node0),u._node1&&r.push(u._node1),n=u._startIndex;n<u._endIndex;n++)s.push(this._bboxArray[7*n])}var c=new mt.BVHVector3,l=new mt.BVHVector3,h=new mt.BVHVector3,d=new mt.BVHVector3(e.x,e.y,e.z),A=new mt.BVHVector3(t.x,t.y,t.z);for(n=0;n<s.length;n++){var p=s[n];c.setFromArray(this._trianglesArray,9*p),l.setFromArray(this._trianglesArray,9*p+3),h.setFromArray(this._trianglesArray,9*p+6);var M=mt.BVH.intersectRayTriangle(c,l,h,d,A,i);M&&o.push({triangle:[c.clone(),l.clone(),h.clone()],triangleIndex:p,intersectionPoint:M})}return o},mt.BVH.prototype.calcBoundingBoxes=function(e){for(var t,i,n,r,s,o,a,u,c,l,h,d,A,p,M,f=e.length/9,g=new Float32Array(7*f),y=0;y<f;y++)t=e[9*y],i=e[9*y+1],n=e[9*y+2],r=e[9*y+3],s=e[9*y+4],o=e[9*y+5],a=e[9*y+6],u=e[9*y+7],c=e[9*y+8],l=Math.min(Math.min(t,r),a),h=Math.min(Math.min(i,s),u),d=Math.min(Math.min(n,o),c),A=Math.max(Math.max(t,r),a),p=Math.max(Math.max(i,s),u),M=Math.max(Math.max(n,o),c),mt.BVH.setBox(g,y,y,l,h,d,A,p,M);return g},mt.BVH.prototype.calcExtents=function(e,t,i){if(i=i||0,e>=t)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];for(var n=Number.MAX_VALUE,r=Number.MAX_VALUE,s=Number.MAX_VALUE,o=-Number.MAX_VALUE,a=-Number.MAX_VALUE,u=-Number.MAX_VALUE,c=e;c<t;c++)n=Math.min(this._bboxArray[7*c+1],n),r=Math.min(this._bboxArray[7*c+2],r),s=Math.min(this._bboxArray[7*c+3],s),o=Math.max(this._bboxArray[7*c+4],o),a=Math.max(this._bboxArray[7*c+5],a),u=Math.max(this._bboxArray[7*c+6],u);return[{x:n-i,y:r-i,z:s-i},{x:o+i,y:a+i,z:u+i}]},mt.BVH.prototype._splitNode=function(e){if(!(e.elementCount()<=this._maxTrianglesPerNode||0===e.elementCount())){var t=e._startIndex,i=e._endIndex,n=[[],[],[]],r=[[],[],[]],s=[e.centerX(),e.centerY(),e.centerZ()],o=[e._extentsMax.x-e._extentsMin.x,e._extentsMax.y-e._extentsMin.y,e._extentsMax.z-e._extentsMin.z],a=[];a.length=3;for(var u=t;u<i;u++){a[0]=.5*(this._bboxArray[7*u+1]+this._bboxArray[7*u+4]),a[1]=.5*(this._bboxArray[7*u+2]+this._bboxArray[7*u+5]),a[2]=.5*(this._bboxArray[7*u+3]+this._bboxArray[7*u+6]);for(var c=0;c<3;c++)a[c]<s[c]?n[c].push(u):r[c].push(u)}var l=[];if(l.length=3,l[0]=0===n[0].length||0===r[0].length,l[1]=0===n[1].length||0===r[1].length,l[2]=0===n[2].length||0===r[2].length,!(l[0]&&l[1]&&l[2])){var h,d,A=[0,1,2];for(A.sort((function(e,t){return o[t]-o[e]})),c=0;c<3;c++){var p=A[c];if(!l[p]){h=n[p],d=r[p];break}}var M,f=t,g=f+h.length,y=g,v=i,m=e._startIndex,N=h.concat(d);for(u=0;u<N.length;u++)M=N[u],mt.BVH.copyBox(this._bboxArray,M,this._bboxHelper,m),m++;var D=this._bboxHelper.subarray(7*e._startIndex,7*e._endIndex);this._bboxArray.set(D,7*e._startIndex);var w=this.calcExtents(f,g,mt.EPSILON),T=this.calcExtents(y,v,mt.EPSILON),x=new mt.BVHNode(w[0],w[1],f,g,e._level+1),E=new mt.BVHNode(T[0],T[1],y,v,e._level+1);e._node0=x,e._node1=E,e.clearShapes(),this._nodesToSplit.push(x),this._nodesToSplit.push(E)}}},mt.BVH._calcTValues=function(e,t,i,n){var r={min:0,max:0};return n>=0?(r.min=(e-i)*n,r.max=(t-i)*n):(r.min=(t-i)*n,r.max=(e-i)*n),r},mt.BVH.intersectNodeBox=function(e,t,i){var n=mt.BVH._calcTValues(i._extentsMin.x,i._extentsMax.x,e.x,t.x),r=mt.BVH._calcTValues(i._extentsMin.y,i._extentsMax.y,e.y,t.y);if(n.min>r.max||r.min>n.max)return!1;(r.min>n.min||n.min!=n.min)&&(n.min=r.min),(r.max<n.max||n.max!=n.max)&&(n.max=r.max);var s=mt.BVH._calcTValues(i._extentsMin.z,i._extentsMax.z,e.z,t.z);return!(n.min>s.max||s.min>n.max)&&((s.min>n.min||n.min!=n.min)&&(n.min=s.min),(s.max<n.max||n.max!=n.max)&&(n.max=s.max),!(n.max<0))},mt.BVH.intersectRayTriangle=(ft=new mt.BVHVector3,gt=new mt.BVHVector3,yt=new mt.BVHVector3,vt=new mt.BVHVector3,function(e,t,i,n,r,s){gt.subVectors(t,e),yt.subVectors(i,e),vt.crossVectors(gt,yt);var o,a=r.dot(vt);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}ft.subVectors(n,e);var u=o*r.dot(yt.crossVectors(ft,yt));if(u<0)return null;var c=o*r.dot(gt.cross(ft));if(c<0)return null;if(u+c>a)return null;var l=-o*ft.dot(vt);if(l<0)return null;var h=l/a;return(new mt.BVHVector3).copy(r).multiplyScalar(h).add(n)}),mt.BVH.setBox=function(e,t,i,n,r,s,o,a,u){e[7*t]=i,e[7*t+1]=n,e[7*t+2]=r,e[7*t+3]=s,e[7*t+4]=o,e[7*t+5]=a,e[7*t+6]=u},mt.BVH.copyBox=function(e,t,i,n){i[7*n]=e[7*t],i[7*n+1]=e[7*t+1],i[7*n+2]=e[7*t+2],i[7*n+3]=e[7*t+3],i[7*n+4]=e[7*t+4],i[7*n+5]=e[7*t+5],i[7*n+6]=e[7*t+6]},mt.BVH.getBox=function(e,t,i){i.triangleId=e[7*t],i.minX=e[7*t+1],i.minY=e[7*t+2],i.minZ=e[7*t+3],i.maxX=e[7*t+4],i.maxY=e[7*t+5],i.maxZ=e[7*t+6]},mt.BVHNode=function(e,t,i,n,r){this._extentsMin=e,this._extentsMax=t,this._startIndex=i,this._endIndex=n,this._level=r,this._node0=null,this._node1=null},mt.BVHNode.prototype.elementCount=function(){return this._endIndex-this._startIndex},mt.BVHNode.prototype.centerX=function(){return.5*(this._extentsMin.x+this._extentsMax.x)},mt.BVHNode.prototype.centerY=function(){return.5*(this._extentsMin.y+this._extentsMax.y)},mt.BVHNode.prototype.centerZ=function(){return.5*(this._extentsMin.z+this._extentsMax.z)},mt.BVHNode.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1},mt.BVHNode.calcBoundingSphereRadius=function(e,t){var i=.5*(e.x+t.x),n=.5*(e.y+t.y),r=.5*(e.z+t.z),s=(i-e.x)*(i-e.x)+(n-e.y)*(n-e.y)+(r-e.z)*(r-e.z),o=(i-t.x)*(i-t.x)+(n-t.y)*(n-t.y)+(r-t.z)*(r-t.z);return Math.sqrt(Math.max(s,o))};var Nt=mt.BVH;var Dt,wt=(Dt="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<"+Dt+">$":Symbol(Dt));function Tt(e){return e[wt]||(e[wt]={}),e[wt]}var xt=function(){function e(){}return e.prototype.hasListener=function(e){var t=Tt(this);return t&&t[e]&&t[e].length>0},e.prototype.on=function(e,t,i){var n=this,r=Tt(this);return r[e]||(r[e]=[]),r[e].push([t,i||!1]),function(){return n.off(e,t)}},e.prototype.once=function(e,t){return this.on(e,t,!0)},e.prototype.off=function(e,t){if(void 0!==e){var i,n=Tt(this);if(n[e]||(n[e]=[]),void 0!==t){for(var r=0;r<n[e].length&&n[e][r][0]!==t;r++);r<n[e].length&&n[e].splice(r,1)}else n[e].length=0}else(i=this)[wt]||delete i[wt]},e.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=!1,r=Tt(this),s=r[e]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],c=u[0],l=u[1],h=void 0!==l&&l,d=c.apply(void 0,t);h&&this.off(e,c),!1===d&&(n=!0)}return n},e}();function Et(e){Object.freeze(e);var t="function"==typeof e,i=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach((function(n){!i.call(e,n)||t&&("caller"===n||"callee"===n||"arguments"===n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||Et(e[n])})),e}var jt=/^([^.]+)(\.([^.]+))*$/;function It(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function zt(e,t){return jt.test(e)&&function(e){if("*"===e)return/^(.+)$/i;var t="^"+e.split(".").map((function(e){return"*"===e?"([^.]+)":e})).join(".")+"$";return new RegExp(t,"i")}(e).test(t)}var bt=Et(JSON.parse(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,s="";return arguments[r].split(s).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(s)}("h--/y|pnyu|/9--/xr;p|z/9-------/7;xr;p|z/9-------/7;7;xr;p|z/9--/yvn{wvn;p|z/9--/7;yvn{wvn;p|z/9--/7;7;yvn{wvn;p|z/9--/rnyrr;p|z/9--/7;rnyrr;p|z/9--/7;7;rnyrr;p|z/9--/rnyrr;p{/9---/7;rnyrr;p{/9---/7;7;rnyrr;p{/9--/uv;p|z/9--/7;uv;p|z/9--/7;7;uv;p|z/9--/uv;p{/9---/7;uv;p{/9---/7;7;uv;p{/9--/ywpq{;p|z/9----/7;ywpq{;p|z/9----/7;7;ywpq{;p|z/j"))),Lt=function(e){function i(t,i){var n=e.call(this,"[NETWORK]: response error(status: "+i+"): "+t)||this;return n.httpStatus=i,n}return t.__extends(i,e),i}(Error),St=function(e){function i(t){return e.call(this,"[NETWORK]: request abort: "+t)||this}return t.__extends(i,e),i}(Error),Ot=function(e){function i(t,i){return e.call(this,"[NETWORK]: request timeout("+i+"ms): "+t)||this}return t.__extends(i,e),i}(Error),Ct=function(e){function i(t,i){return e.call(this,"[NETWORK]: request forbidden: "+t+", "+i)||this}return t.__extends(i,e),i}(Error);var Pt=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i}(xt);function kt(e,t,i,n){void 0===t&&(t={}),void 0===i&&(i=He),void 0===n&&(n=He);var r,s=t.allowHosts?bt.concat(t.allowHosts):bt.slice(),o=(r=e.match(/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/))?r[2]:location.hostname;if(0!==location.hostname.length&&!It(location.hostname)&&0===bt.filter((function(e){return zt(e,location.hostname)})).length&&!It(o)&&0===s.filter((function(e){return zt(e,o)})).length){var a=He,u=new Ct(e,"request host("+o+") is not allowed");return Ke((function(){var n;i(u,null),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"forbidden",u.message)})),{abort:a}}var c=function(e){for(var t=0,i=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i];t<i.length;t++){var n=i[t],r=e.match(n);if(r)return"jsonp_"+r[1]}return null}(e);if(c){var l=window,h=null,d=!1,A=Ze(),p=document.createElement("script");return l[c]=function(n){var r,s=Ze(),o=s-A;if(delete l[c],p.parentNode&&p.parentNode.removeChild(p),null!==h&&(window.clearTimeout(h),h=null),!0!==d){if(0!==n.indexOf("data:")){var a=new Lt(e,500);return i(a,null),void(null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"error",a.message))}var u=n.split(","),M=(u[0].match(/:(.*?);/)||[])[1],f=u[1];if("arraybuffer"===t.responseType||"blob"===t.responseType){for(var g=atob(u[1]),y=g.length,v=new Uint8Array(y),m=0;m<y;m++)v[m]=g.charCodeAt(m);f="arraybuffer"===t.responseType?v.buffer:new Blob([v],{type:M})}var N={body:f,meta:{source:e,requestTime:A,responseTime:s,costs:o,headers:{}}};Ke((function(){var n;i(null,N),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"ok",JSON.stringify(N.meta))})),d=!0}},p.src=e,document.body.appendChild(p),"number"==typeof t.timeout&&(h=window.setTimeout((function(){var n;if(h=null,!0!==d){var r=new Ot(e,t.timeout||NaN);i(r,null),d=!0,null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"timeout",r.message)}}),t.timeout)),{abort:function(){var n;if(delete l[c],p.parentNode&&p.parentNode.removeChild(p),null!==h&&(window.clearTimeout(h),h=null),!0!==d){var r=new St(e);i(r,null),d=!0,null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"abort",r.message)}}}}var M=Ze(),f=!1,g=new XMLHttpRequest,y=function(){g&&(g.removeEventListener("timeout",v,!1),g.removeEventListener("progress",m,!1),g.removeEventListener("abort",N,!1),g.removeEventListener("load",D,!1),g.removeEventListener("error",w,!1)),g=null,y=He},v=function(){var n,r=new Ot(e,t.timeout||NaN);i(r,null),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"timeout",r.message)},m=function(e){if(!0!==f&&e.lengthComputable){var t=e.loaded,i=e.total;n(t/i,t,i)}},N=function(){var n;if(!0!==f){var r=new St(e);i(r,null),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"abort",r.message)}},D=function(){var n,r=Ze(),s=r-M,o=function(e){if(!e)return{};for(var t={},i=e.trim().split("\n"),n=0;n<i.length;n++){var r=i[n],s=r.indexOf(":"),o=r.slice(0,s).trim().toLowerCase(),a=r.slice(s+1).trim();a&&(t[o]?t[o]+=", "+a:t[o]=a)}return t}(this.getAllResponseHeaders()),a={body:this.response,meta:{source:e,requestTime:M,responseTime:r,costs:s,headers:o}};i(null,a),f=!0,y(),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"ok",JSON.stringify(a.meta))},w=function(){var n,r=new Lt(e,this.status);i(r,null),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"error",r.message),f=!0,y()};return g.addEventListener("timeout",v,!1),g.addEventListener("progress",m,!1),g.addEventListener("abort",N,!1),g.addEventListener("load",D,!1),g.addEventListener("error",w,!1),t.responseType&&(g.responseType=t.responseType),"number"==typeof t.timeout&&(g.timeout=t.timeout),g.open("GET",e,!0),g.send(null),{abort:N}}kt.async=function(e,t){return new Promise((function(i,n){kt(e,t,(function(e,t){e?n(e):i(t)}))}))};var Bt={};function Ut(e,t){if(void 0===t&&(t={}),"function"==typeof t.transform)return t.transform(e,t);if(e.indexOf("//vrlab-public.ljcdn.com")>=0&&(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),/\.(jpg|png)$/.test(e))){var i=t.size,n=t.quality,r=t.format;if(i||n||r){var s="?imageMogr2";n&&(s+="/quality/"+n),i&&(s+="/thumbnail/"+i+"x"),r&&(s+="/format/"+r),e=e.replace("//vrlab-public.ljcdn.com","//vrlab-image4.ljcdn.com")+s}}return e}var Qt=function(){function e(e){void 0===e&&(e={}),this.allowHosts=e.allowHosts,this.networkSubscribe=e.networkSubscribe}return e.prototype.load=function(e,t,i,n){return void 0===t&&(t=He),void 0===i&&(i=He),void 0===n&&(n=He),this.loadToImage(at(),e,t,i,n)},e.prototype.loadToImage=function(e,t,i,n,r){if(void 0===i&&(i=He),void 0===r&&(r=He),e.src)throw new Error("image is loaded");var s={responseType:"blob",allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe};kt(t,s,(function(n,s){n?r(n):(e.onload=function(){i(e),e.onload=e.onerror=function(){}},e.onerror=function(){r(new Error("image parse error "+t)),e.onload=e.onerror=function(){}},e.src=URL.createObjectURL(s.body))}))},e}(),_t=null,Rt=!1,Yt=[];function Ft(e){if(void 0===e&&(e=!1),e||!Rt)if(_t)Rt=!1;else{Rt=!0;var t=Yt.shift();if(t){try{t()}catch(e){}Ke((function(){return Ft(!0)}))}else Rt=!1}}function Vt(){_t=null,Ft()}function Ht(){(_t||0!==Yt.length)&&(_t&&clearTimeout(_t),_t=window.setTimeout(Vt,200))}function Gt(e){return new Promise((function(t){Yt.push((function(){return t(e())})),Ft()}))}var qt,Wt={computeTangents:function(e){var t=e.index,i=e.attributes;if(null!==t&&void 0!==i.position&&void 0!==i.normal&&void 0!==i.uv){var n=t.array,r=i.position.array,s=i.normal.array,o=i.uv.array,u=r.length/3;void 0===i.tangent&&e.setAttribute("tangent",new a.BufferAttribute(new Float32Array(4*u),4));for(var c=i.tangent.array,l=[],h=[],d=0;d<u;d++)l[d]=new a.Vector3,h[d]=new a.Vector3;var A=new a.Vector3,p=new a.Vector3,M=new a.Vector3,f=new a.Vector2,g=new a.Vector2,y=new a.Vector2,v=new a.Vector3,m=new a.Vector3,N=e.groups;0===N.length&&(N=[{start:0,count:n.length}]);d=0;for(var D=N.length;d<D;++d)for(var w=O=(S=N[d]).start,T=O+S.count;w<T;w+=3)C(n[w+0],n[w+1],n[w+2]);var x,E,j,I=new a.Vector3,z=new a.Vector3,b=new a.Vector3,L=new a.Vector3;for(d=0,D=N.length;d<D;++d){var S,O;for(w=O=(S=N[d]).start,T=O+S.count;w<T;w+=3)P(n[w+0]),P(n[w+1]),P(n[w+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function C(e,t,i){A.fromArray(r,3*e),p.fromArray(r,3*t),M.fromArray(r,3*i),f.fromArray(o,2*e),g.fromArray(o,2*t),y.fromArray(o,2*i);var n=p.x-A.x,s=M.x-A.x,a=p.y-A.y,u=M.y-A.y,c=p.z-A.z,d=M.z-A.z,N=g.x-f.x,D=y.x-f.x,w=g.y-f.y,T=y.y-f.y,x=1/(N*T-D*w);v.set((T*n-w*s)*x,(T*a-w*u)*x,(T*c-w*d)*x),m.set((N*s-D*n)*x,(N*u-D*a)*x,(N*d-D*c)*x),l[e].add(v),l[t].add(v),l[i].add(v),h[e].add(m),h[t].add(m),h[i].add(m)}function P(e){b.fromArray(s,3*e),L.copy(b),E=l[e],I.copy(E),I.sub(b.multiplyScalar(b.dot(E))).normalize(),z.crossVectors(L,E),j=z.dot(h[e]),x=j<0?-1:1,c[4*e]=I.x,c[4*e+1]=I.y,c[4*e+2]=I.z,c[4*e+3]=x}},mergeBufferGeometries:function(e,t){for(var i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),s={},o={},u=new a.BufferGeometry,c=0,l=0;l<e.length;++l){var h=e[l];if(i!==(null!==h.index))return null;for(var d in h.attributes){if(!n.has(d))return null;void 0===s[d]&&(s[d]=[]),s[d].push(h.attributes[d])}for(var d in h.morphAttributes){if(!r.has(d))return null;void 0===o[d]&&(o[d]=[]),o[d].push(h.morphAttributes[d])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(h.userData),t){var A;if(i)A=h.index.count;else{if(void 0===h.attributes.position)return null;A=h.attributes.position.count}u.addGroup(c,A,l),c+=A}}if(i){var p=0,M=[];for(l=0;l<e.length;++l){for(var f=e[l].index,g=0;g<f.count;++g)M.push(f.getX(g)+p);p+=e[l].attributes.position.count}u.setIndex(M)}for(var d in s){var y=this.mergeBufferAttributes(s[d]);if(!y)return null;u.setAttribute(d,y)}for(var d in o){var v=o[d][0].length;if(0===v)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[d]=[];for(l=0;l<v;++l){var m=[];for(g=0;g<o[d].length;++g)m.push(o[d][g][l]);var N=this.mergeBufferAttributes(m);if(!N)return null;u.morphAttributes[d].push(N)}}return u},mergeBufferAttributes:function(e){for(var t,i,n,r=0,s=0;s<e.length;++s){var o=e[s];if(o.isInterleavedBufferAttribute)return null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return null;r+=o.array.length}var u=new t(r),c=0;for(s=0;s<e.length;++s)u.set(e[s].array,c),c+=e[s].array.length;return new a.BufferAttribute(u,i,n)},interleaveAttributes:function(e){for(var t,i=0,n=0,r=0,s=e.length;r<s;++r){var o=e[r];if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;i+=o.array.length,n+=o.itemSize}var u=new a.InterleavedBuffer(new t(i),n),c=0,l=[],h=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"],A=0;for(s=e.length;A<s;A++){var p=(o=e[A]).itemSize,M=o.count,f=new a.InterleavedBufferAttribute(u,p,c,o.normalized);l.push(f),c+=p;for(var g=0;g<M;g++)for(var y=0;y<p;y++)f[d[y]](g,o[h[y]](g))}return l},estimateBytesUsed:function(e){var t=0;for(var i in e.attributes){var n=e.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0},mergeVertices:function(e,t){void 0===t&&(t=1e-4),t=Math.max(t,Number.EPSILON);for(var i={},n=e.getIndex(),r=e.getAttribute("position"),s=n?n.count:r.count,o=0,u=Object.keys(e.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],A=0,p=u.length;A<p;A++){c[m=u[A]]=[],(T=e.morphAttributes[m])&&(l[m]=new Array(T.length).fill().map((function(){return[]})))}var M=Math.log10(1/t),f=Math.pow(10,M);for(A=0;A<s;A++){var g=n?n.getX(A):A,y="",v=0;for(p=u.length;v<p;v++)for(var m=u[v],N=(w=e.getAttribute(m)).itemSize,D=0;D<N;D++)y+=~~(w[d[D]](g)*f)+",";if(y in i)h.push(i[y]);else{for(v=0,p=u.length;v<p;v++){m=u[v];var w=e.getAttribute(m),T=e.morphAttributes[m],x=(N=w.itemSize,c[m]),E=l[m];for(D=0;D<N;D++){var j=d[D];if(x.push(w[j](g)),T)for(var I=0,z=T.length;I<z;I++)E[I].push(T[I][j](g))}}i[y]=o,h.push(o),o++}}var b=e.clone();for(A=0,p=u.length;A<p;A++){m=u[A];var L=e.getAttribute(m),S=new L.array.constructor(c[m]);w=new a.BufferAttribute(S,L.itemSize,L.normalized);if(b.setAttribute(m,w),m in l)for(v=0;v<l[m].length;v++){var O=e.morphAttributes[m][v],C=(S=new O.array.constructor(l[m][v]),new a.BufferAttribute(S,O.itemSize,O.normalized));b.morphAttributes[m][v]=C}}return b.setIndex(h),b}};var Zt='\nvar config, transcoderPending, _BasisFile;\nself.onmessage = function(e) {\n var message = e.data;\n switch (message.type) {\n case "init":\n config = message.config;\n init(message.transcoderBinary);\n break;\n case "transcode":\n transcoderPending.then(function() {\n try {\n var result = transcode(message.buffer);\n var width = result.width;\n var height = result.height;\n var hasAlpha = result.hasAlpha;\n var mipmaps = result.mipmaps;\n var format = result.format;\n var buffers = [];\n for (var i = 0; i < mipmaps.length; ++i) {\n buffers.push(mipmaps[i].data.buffer);\n }\n self.postMessage({ type: "transcode", id: message.id, width, height, hasAlpha, mipmaps, format }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n }\n });\n break;\n default: break;\n }\n};\n\nfunction init(wasmBinary) {\n var BasisModule;\n transcoderPending = new Promise(function(resolve) {\n BasisModule = { wasmBinary, onRuntimeInitialized: resolve };\n BASIS(BasisModule); // eslint-disable-line no-undef\n }).then(function() {\n _BasisFile = BasisModule.BasisFile;\n BasisModule.initializeBasis();\n self.postMessage({ type: "initialized" });\n });\n}\n\nfunction transcode(buffer) {\n var basisFile = new _BasisFile(new Uint8Array(buffer));\n var width = basisFile.getImageWidth(0, 0);\n var height = basisFile.getImageHeight(0, 0);\n var levels = basisFile.getNumLevels(0);\n var hasAlpha = basisFile.getHasAlpha();\n function cleanup() {\n basisFile.close();\n basisFile.delete();\n }\n if (!hasAlpha) {\n switch (config.format) {\n case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA\n config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;\n break;\n default: break;\n }\n }\n if (!width || !height || !levels) {\n cleanup();\n throw new Error("BasisTextureLoader: Invalid .basis file");\n }\n if (!basisFile.startTranscoding()) {\n cleanup();\n throw new Error("BasisTextureLoader: .startTranscoding failed");\n }\n var mipmaps = [];\n for (var mip = 0; mip < levels; mip++) {\n var mipWidth = basisFile.getImageWidth(0, mip);\n var mipHeight = basisFile.getImageHeight(0, mip);\n var dst = new Uint8Array(basisFile.getImageTranscodedSizeInBytes(0, mip, config.format));\n var status = basisFile.transcodeImage(dst, 0, mip, config.format, 0, hasAlpha);\n if (!status) {\n cleanup();\n throw new Error("BasisTextureLoader: .transcodeImage failed.");\n }\n mipmaps.push({ data: dst, width: mipWidth, height: mipHeight });\n }\n cleanup();\n return { width, height, hasAlpha, mipmaps, format: config.format };\n}\n',Xt={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7_M6_OPAQUE_ONLY:6,cTFBC7_M5:7,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16},Kt={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779},Jt=((qt={})[Xt.cTFBC1]=Kt.COMPRESSED_RGB_S3TC_DXT1_EXT,qt[Xt.cTFBC3]=Kt.COMPRESSED_RGBA_S3TC_DXT5_EXT,qt),$t=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.allowHosts=t.allowHosts,i.networkSubscribe=t.networkSubscribe,i}return t.__extends(i,e),i.setTranscoderPath=function(e){return this.transcoderPath=e,this},i.setWorkerLimit=function(e){return this.workerLimit=e,this},i.isInitialized=function(){return 0!==this.workerPool.filter((function(e){return e._initialized})).length},i.detectSupport=function(e){var t=this.workerConfig;if(t.astcSupported=!!e.extensions.get("WEBGL_compressed_texture_astc"),t.bptcSupported=!!e.extensions.get("EXT_texture_compression_bptc"),t.etcSupported=!!e.extensions.get("WEBGL_compressed_texture_etc1"),t.dxtSupported=!!e.extensions.get("WEBGL_compressed_texture_s3tc"),t.pvrtcSupported=!!e.extensions.get("WEBGL_compressed_texture_pvrtc")||!!e.extensions.get("WEBKIT_WEBGL_compressed_texture_pvrtc"),t.astcSupported)t.format=i.BASIS_FORMAT.cTFASTC_4x4;else if(t.bptcSupported)t.format=i.BASIS_FORMAT.cTFBC7_M5;else if(t.dxtSupported)t.format=i.BASIS_FORMAT.cTFBC3;else if(t.pvrtcSupported)t.format=i.BASIS_FORMAT.cTFPVRTC1_4_RGBA;else{if(!t.etcSupported)throw new Error("BasisTextureLoader: No suitable compressed texture format found.");t.format=i.BASIS_FORMAT.cTFETC1}return this},i.prototype.load=function(e,t,n,r){return kt(e,{responseType:"arraybuffer",allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe},(function(n,s){if(n)r(n);else{var o=function(e){return t(e,s.meta)},a=s.body;if(i.taskCache.has(a))return i.taskCache.get(a).promise.then(o).catch(r);i._createTexture(a,e).then(o).catch(r)}}),n)},i._createTexture=function(e,t){var n,r,s=this,o=e.byteLength,u=this._allocateWorker(o).then((function(t){return n=t,r=s.workerNextTaskID++,new Promise((function(t,i){n._callbacks[r]={resolve:t,reject:i},n.postMessage({type:"transcode",id:r,buffer:e},[e])}))})).then((function(e){var t,i=s.workerConfig,n=e.width,r=e.height,o=e.mipmaps;switch(e.format){case Xt.cTFASTC_4x4:t=new a.CompressedTexture(o,n,r,a.RGBA_ASTC_4x4_Format);break;case Xt.cTFBC1:case Xt.cTFBC3:t=new a.CompressedTexture(o,n,r,Jt[i.format],a.UnsignedByteType);break;case Xt.cTFETC1:t=new a.CompressedTexture(o,n,r,a.RGB_ETC1_Format);break;case Xt.cTFPVRTC1_4_RGB:t=new a.CompressedTexture(o,n,r,a.RGB_PVRTC_4BPPV1_Format);break;case Xt.cTFPVRTC1_4_RGBA:t=new a.CompressedTexture(o,n,r,a.RGBA_PVRTC_4BPPV1_Format);break;default:throw new Error("BasisTextureLoader: No supported format available.")}return t.minFilter=1===o.length?a.LinearFilter:a.LinearMipmapLinearFilter,t.magFilter=a.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t}));return u.catch((function(){return!0})).then((function(){n&&r&&(n._taskLoad-=o,delete n._callbacks[r])})),i.taskCache.set(e,{url:t,promise:u}),u},i._initTranscoder=function(){var e=this;if(!this.transcoderPending){var t=new a.FileLoader;t.setPath(this.transcoderPath);var i=new Promise((function(e,i){t.load("basis_transcoder.js",e,void 0,i)})),n=new a.FileLoader;n.setPath(this.transcoderPath),n.setResponseType("arraybuffer");var r=new Promise((function(e,t){n.load("basis_transcoder.wasm",e,void 0,t)}));this.transcoderPending=Promise.all([i,r]).then((function(t){var i=t[0],n=t[1],r=["/* basis_transcoder.js */",i,"/* worker */",Zt].join("\n");e.workerSourceURL=URL.createObjectURL(new Blob([r])),e.transcoderBinary=n}))}return this.transcoderPending},i._allocateWorker=function(e){var t=this;return this._initTranscoder().then((function(){if(t.workerPool.length<t.workerLimit){var i=function(e){var t=new Worker(e);return Object.assign(t,{_callbacks:{},_initialized:!1,_taskLoad:0})}(t.workerSourceURL);i._callbacks={},i._initialized=!1,i._taskLoad=0,i.postMessage({type:"init",config:t.workerConfig,transcoderBinary:t.transcoderBinary}),i.onmessage=function(e){var t=e.data;switch(t.type){case"initialized":i._initialized=!0,console.log("BasisTextureLoader: basis loader initialized");break;case"transcode":i._callbacks[t.id].resolve(t);break;case"error":i._callbacks[t.id].reject(t);break;default:console.error('BasisTextureLoader: Unexpected message, "'+t.type+'"')}},t.workerPool.push(i)}else t.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n=t.workerPool[t.workerPool.length-1];return n._taskLoad+=e,n}))},i.prototype.dispose=function(){for(var e=0;e<i.workerPool.length;e++)i.workerPool[e].terminate();return i.workerPool.length=0,this},i.taskCache=new WeakMap,i.BASIS_FORMAT=Xt,i.DXT_FORMAT=Kt,i.DXT_FORMAT_MAP=Jt,i.transcoderPath="https://vrlab-public.ljcdn.com/release/static/image/release/five/basis/",i.transcoderBinary=null,i.transcoderPending=null,i.workerLimit=1,i.workerPool=[],i.workerNextTaskID=1,i.workerSourceURL="",i.workerConfig={format:null,astcSupported:!1,bptcSupported:!1,etcSupported:!1,dxtSupported:!1,pvrtcSupported:!1},i}(a.Loader),ei=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function ti(e,t){return new a.BufferAttribute(e,t)}function ii(e){var t=e.match(/(group|floor)-?(\d+)/);return t?parseInt(t[2],10):0}function ni(e){var t=e.match(/(chunk)-?(\d+)/);return t?parseInt(t[2],10):0}function ri(e){var t=e.indices,i=e.vertices,n=e.uvs,r=new a.BufferGeometry;return r.setIndex(ti(new Uint32Array(t),1)),r.setAttribute("position",ti(new Float32Array(i),3)),Ve(n)||r.setAttribute("uv",ti(new Float32Array(n),2)),r.applyMatrix4(ei),r.computeVertexNormals(),r}function si(e,t,i,n){var r=$t.isInitialized();e=Ut(e,Object.assign({key:"texture",basisLoaderInitialized:r},t));var s=new $t({allowHosts:i,networkSubscribe:n});if(/\.basis(\?|$)/.test(e)){var o={sourceFile:e,needsUpdate:!0,wrapS:a.ClampToEdgeWrapping,wrapT:a.ClampToEdgeWrapping,minFilter:a.LinearFilter};return new Promise((function(t,i){s.load(e,(function(e){t(Object.assign(e,o))}),(function(){}),(function(e){i(e)}))}))}var u={sourceFile:e,needsUpdate:!0,wrapS:a.ClampToEdgeWrapping,wrapT:a.ClampToEdgeWrapping,minFilter:a.LinearFilter},c=new Qt({allowHosts:i,networkSubscribe:n});return new Promise((function(t,i){c.load(e,(function(e){var i=new a.Texture(e),n=i.dispose;i.dispose=function(){n.call(i),/^blob\:/.test(e.src)&&URL.revokeObjectURL(e.src)},t(Object.assign(i,u))}),He,(function(e){return i(e)}))}))}function oi(e){var t=new dt;return e.catch((function(){return null})).then((function(e){t.uniforms.map.value=e,t.uniforms.exposure.value=3.3})),t}var ai=u.parse("\nmessage Model {\n repeated Chunk chunks = 1;\n}\nmessage Chunk {\n required Vertices vertices = 1;\n required Faces faces = 2;\n required string name = 3;\n optional string texture = 4;\n}\nmessage Vertices {\n repeated float xyz = 1 [packed=true];\n repeated float uvs = 2 [packed=true];\n}\nmessage Faces {\n repeated uint32 indices = 1 [packed=true];\n}\n").root.lookup("Model");function ui(e,t,i,n,r,s,o){void 0===r&&(r={});for(var u=0,c=e;u<c.length;u++){var l=c[u];l.chunkName=ni(l.name),l.floorName=ii(l.name),l.texture&&(l.texture=i[l.chunkName]=i[l.chunkName]||t+l.texture)}e.sort((function(e,t){return 1e3*e.floorName+e.chunkName-(1e3*t.floorName+t.chunkName)}));var h=[],d=[],A=Promise.resolve();return(A=(A=A.then((function(){return Gt((function(){for(var t=0;t<e.length;t++){var i=e[t],u=ii(i.name),c=h[u]=h[u]||{geometries:[],materials:[]},l=ri({vertices:i.vertices.xyz,uvs:i.vertices.uvs,indices:i.faces.indices});if(l.name="model_geo_chunk_"+t,c.geometries.push(l),i.texture){(d=oi(i.texture in r?r[i.texture]:r[i.texture]=si(i.texture,n,s,o))).name="model_mtl_chunk_"+t,c.materials.push(d)}else{var d;(d=new dt).defines.USE_MAP=!1,d.uniforms.color.value=new a.Color(16777215),d.name="model_mtl_chunk_"+t,c.materials.push(d)}}}))}))).then((function(){return Gt((function(){for(var e=0;e<h.length;e++){var t=h[e];if(t){var i=Wt.mergeBufferGeometries(t.geometries,!0);t.geometries.forEach((function(e){return e.dispose()}));var n=new tt(i,t.materials);n.floorIndex=e,n.name="model_floor_"+e,d.push(n)}}}))}))).then((function(){var e=Object.keys(r).map((function(e){return r[e].then((function(){}))}));return Promise.all(e).then((function(){return d}))}))}function ci(e,t){return!1!==(e=Object.assign({},e)).autoResize&&(t>96?e.size=Math.min(e.size||1/0,100):t>48?e.size=Math.min(e.size||1/0,200):t>24?e.size=Math.min(e.size||1/0,400):t>12&&(e.size=Math.min(e.size||1/0,800))),e}var li={OutWindow:function(){this._windowSize=0}};li.OutWindow.prototype.create=function(e){this._buffer&&this._windowSize===e||(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},li.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(0!==e){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},li.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},li.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},li.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},li.OutWindow.prototype.copyBlock=function(e,t){var i=this._pos-e-1;for(i<0&&(i+=this._windowSize);t--;)i>=this._windowSize&&(i=0),this._buffer[this._pos++]=this._buffer[i++],this._pos>=this._windowSize&&this.flush()},li.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},li.OutWindow.prototype.getByte=function(e){var t=this._pos-e-1;return t<0&&(t+=this._windowSize),this._buffer[t]},li.RangeDecoder=function(){},li.RangeDecoder.prototype.setStream=function(e){this._stream=e},li.RangeDecoder.prototype.releaseStream=function(){this._stream=null},li.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},li.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t,i=0,n=e;n--;)this._range>>>=1,t=this._code-this._range>>>31,this._code-=this._range&t-1,i=i<<1|1-t,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return i},li.RangeDecoder.prototype.decodeBit=function(e,t){var i=e[t],n=(this._range>>>11)*i;return(2147483648^this._code)<(2147483648^n)?(this._range=n,e[t]+=2048-i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,e[t]-=i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},li.initBitModels=function(e,t){for(;t--;)e[t]=1024},li.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},li.BitTreeDecoder.prototype.init=function(){li.initBitModels(this._models,1<<this._numBitLevels)},li.BitTreeDecoder.prototype.decode=function(e){for(var t=1,i=this._numBitLevels;i--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},li.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t,i=1,n=0,r=0;r<this._numBitLevels;++r)i=i<<1|(t=e.decodeBit(this._models,i)),n|=t<<r;return n},li.reverseDecode2=function(e,t,i,n){for(var r,s=1,o=0,a=0;a<n;++a)s=s<<1|(r=i.decodeBit(e,t+s)),o|=r<<a;return o},li.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new li.BitTreeDecoder(8),this._numPosStates=0},li.LenDecoder.prototype.create=function(e){for(;this._numPosStates<e;++this._numPosStates)this._lowCoder[this._numPosStates]=new li.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new li.BitTreeDecoder(3)},li.LenDecoder.prototype.init=function(){var e=this._numPosStates;for(li.initBitModels(this._choice,2);e--;)this._lowCoder[e].init(),this._midCoder[e].init();this._highCoder.init()},li.LenDecoder.prototype.decode=function(e,t){return 0===e.decodeBit(this._choice,0)?this._lowCoder[t].decode(e):0===e.decodeBit(this._choice,1)?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},li.Decoder2=function(){this._decoders=[]},li.Decoder2.prototype.init=function(){li.initBitModels(this._decoders,768)},li.Decoder2.prototype.decodeNormal=function(e){var t=1;do{t=t<<1|e.decodeBit(this._decoders,t)}while(t<256);return 255&t},li.Decoder2.prototype.decodeWithMatchByte=function(e,t){var i,n,r=1;do{if(i=t>>7&1,t<<=1,r=r<<1|(n=e.decodeBit(this._decoders,(1+i<<8)+r)),i!==n){for(;r<256;)r=r<<1|e.decodeBit(this._decoders,r);break}}while(r<256);return 255&r},li.LiteralDecoder=function(){},li.LiteralDecoder.prototype.create=function(e,t){var i;if(!this._coders||this._numPrevBits!==t||this._numPosBits!==e)for(this._numPosBits=e,this._posMask=(1<<e)-1,this._numPrevBits=t,this._coders=[],i=1<<this._numPrevBits+this._numPosBits;i--;)this._coders[i]=new li.Decoder2},li.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},li.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((255&t)>>>8-this._numPrevBits)]},li.Decoder=function(){this._outWindow=new li.OutWindow,this._rangeDecoder=new li.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new li.BitTreeDecoder(4),this._lenDecoder=new li.LenDecoder,this._repLenDecoder=new li.LenDecoder,this._literalDecoder=new li.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new li.BitTreeDecoder(6),this._posSlotDecoder[1]=new li.BitTreeDecoder(6),this._posSlotDecoder[2]=new li.BitTreeDecoder(6),this._posSlotDecoder[3]=new li.BitTreeDecoder(6)},li.Decoder.prototype.setDictionarySize=function(e){return!(e<0)&&(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},li.Decoder.prototype.setLcLpPb=function(e,t,i){var n=1<<i;return!(e>8||t>4||i>4)&&(this._literalDecoder.create(t,e),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},li.Decoder.prototype.init=function(){var e=4;for(this._outWindow.init(!1),li.initBitModels(this._isMatchDecoders,192),li.initBitModels(this._isRep0LongDecoders,192),li.initBitModels(this._isRepDecoders,12),li.initBitModels(this._isRepG0Decoders,12),li.initBitModels(this._isRepG1Decoders,12),li.initBitModels(this._isRepG2Decoders,12),li.initBitModels(this._posDecoders,114),this._literalDecoder.init();e--;)this._posSlotDecoder[e].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},li.Decoder.prototype.decode=function(e,t,i){var n,r,s,o,a,u,c=0,l=0,h=0,d=0,A=0,p=0,M=0;for(this._rangeDecoder.setStream(e),this._outWindow.setStream(t),this.init();i<0||p<i;)if(n=p&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(c<<4)+n))r=this._literalDecoder.getDecoder(p++,M),M=c>=7?r.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(l)):r.decodeNormal(this._rangeDecoder),this._outWindow.putByte(M),c=c<4?0:c-(c<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,c))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,c)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(c<<4)+n)&&(c=c<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,c)?o=h:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,c)?o=d:(o=A,A=d),d=h),h=l,l=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),c=c<7?8:11);else if(A=d,d=h,h=l,s=2+this._lenDecoder.decode(this._rangeDecoder,n),c=c<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(l=(2|1&a)<<(u=(a>>1)-1),a<14)l+=li.reverseDecode2(this._posDecoders,l-a-1,this._rangeDecoder,u);else if(l+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(l+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===l)break;return!1}}else l=a;if(l>=p||l>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(l,s),p+=s,M=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},li.Decoder.prototype.setDecoderProperties=function(e){var t,i,n,r,s;return!(e.size<5)&&(i=(t=e.readByte())%9,n=(t=~~(t/9))%5,r=~~(t/5),!!this.setLcLpPb(i,n,r)&&(s=e.readByte(),s|=e.readByte()<<8,s|=e.readByte()<<16,s+=16777216*e.readByte(),this.setDictionarySize(s)))},li.decompress=function(e,t,i,n){var r=new li.Decoder;if(!r.setDecoderProperties(e))throw"Incorrect stream properties";if(!r.decode(t,i,n))throw"Error in data stream";return!0},li.decompressFile=function(e,t){var i,n=new li.Decoder;if(!n.setDecoderProperties(e))throw"Incorrect stream properties";if(i=e.readByte(),i|=e.readByte()<<8,i|=e.readByte()<<16,i+=16777216*e.readByte(),e.readByte(),e.readByte(),e.readByte(),e.readByte(),!n.decode(e,t,i))throw"Error in data stream";return!0};var hi="undefined"!=typeof Worker&&"undefined"!=typeof Blob,di="";if(hi)try{var Ai=new Blob(['\n self.onmessage = function (event) {\n var Packet = event.data;\n var Result = null;\n try {\n if (!Packet.PacketID) {\n throw new Error(\'No incoming id.\');\n }\n if (!Packet.Data) {\n throw new Error(\'No input data.\');\n }\n if (Packet.Type == \'compress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n // C: encoding data\n Result = Util.compressFile(Packet.Data, null, Packet.Level, null);\n } else if (Packet.Type == \'decompress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n var inStream = {\n data: Packet.Data,\n offset: 0,\n readByte () {\n return this.data[this.offset++];\n }\n };\n var partLength = inStream.data.length;\n var outStream = {\n data: [],\n offset: 0,\n writeByte (value) {\n var partIndex = Math.floor(this.offset / partLength);\n if (!this.data[partIndex]) {\n this.data[partIndex] = new Uint8Array(partLength);\n }\n this.data[partIndex][this.offset % partLength] = value;\n this.offset++;\n }\n }\n // C: decoding data\n\n LZMA.decompressFile(inStream, outStream);\n Result = new Uint8Array(outStream.offset)\n for (var i = 0; i < outStream.offset; i++) {\n Result[i] = outStream.data[Math.floor(i / partLength)][i % partLength];\n }\n }\n postMessage({ PacketID: Packet.PacketID, Result, Error: null }, [Result.buffer]);\n } catch (error) {\n postMessage({ PacketID: Packet.PacketID, Error: error.toString() });\n }\n };\n\n\n /*\n Copyright (c) 2011 Juan Mellado\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the "Software"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n /*\n References:\n - "LZMA SDK" by Igor Pavlov\n http://www.7-zip.org/sdk.html\n */\n\n var LZMA = LZMA || {};\n\n LZMA.OutWindow = function(){\n this._windowSize = 0;\n };\n\n LZMA.OutWindow.prototype.create = function(windowSize){\n if ( (!this._buffer) || (this._windowSize !== windowSize) ){\n this._buffer = [];\n }\n this._windowSize = windowSize;\n this._pos = 0;\n this._streamPos = 0;\n };\n\n LZMA.OutWindow.prototype.flush = function(){\n var size = this._pos - this._streamPos;\n if (size !== 0){\n while(size --){\n this._stream.writeByte(this._buffer[this._streamPos ++]);\n }\n if (this._pos >= this._windowSize){\n this._pos = 0;\n }\n this._streamPos = this._pos;\n }\n };\n\n LZMA.OutWindow.prototype.releaseStream = function(){\n this.flush();\n this._stream = null;\n };\n\n LZMA.OutWindow.prototype.setStream = function(stream){\n this.releaseStream();\n this._stream = stream;\n };\n\n LZMA.OutWindow.prototype.init = function(solid){\n if (!solid){\n this._streamPos = 0;\n this._pos = 0;\n }\n };\n\n LZMA.OutWindow.prototype.copyBlock = function(distance, len){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n while(len --){\n if (pos >= this._windowSize){\n pos = 0;\n }\n this._buffer[this._pos ++] = this._buffer[pos ++];\n if (this._pos >= this._windowSize){\n this.flush();\n }\n }\n };\n\n LZMA.OutWindow.prototype.putByte = function(b){\n this._buffer[this._pos ++] = b;\n if (this._pos >= this._windowSize){\n this.flush();\n }\n };\n\n LZMA.OutWindow.prototype.getByte = function(distance){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n return this._buffer[pos];\n };\n\n LZMA.RangeDecoder = function(){\n };\n\n LZMA.RangeDecoder.prototype.setStream = function(stream){\n this._stream = stream;\n };\n\n LZMA.RangeDecoder.prototype.releaseStream = function(){\n this._stream = null;\n };\n\n LZMA.RangeDecoder.prototype.init = function(){\n var i = 5;\n\n this._code = 0;\n this._range = -1;\n\n while(i --){\n this._code = (this._code << 8) | this._stream.readByte();\n }\n };\n\n LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits){\n var result = 0, i = numTotalBits, t;\n\n while(i --){\n this._range >>>= 1;\n t = (this._code - this._range) >>> 31;\n this._code -= this._range & (t - 1);\n result = (result << 1) | (1 - t);\n\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n }\n\n return result;\n };\n\n LZMA.RangeDecoder.prototype.decodeBit = function(probs, index){\n var prob = probs[index],\n newBound = (this._range >>> 11) * prob;\n\n if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ){\n this._range = newBound;\n probs[index] += (2048 - prob) >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 0;\n }\n\n this._range -= newBound;\n this._code -= newBound;\n probs[index] -= prob >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 1;\n };\n\n LZMA.initBitModels = function(probs, len){\n while(len --){\n probs[len] = 1024;\n }\n };\n\n LZMA.BitTreeDecoder = function(numBitLevels){\n this._models = [];\n this._numBitLevels = numBitLevels;\n };\n\n LZMA.BitTreeDecoder.prototype.init = function(){\n LZMA.initBitModels(this._models, 1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){\n var m = 1, i = this._numBitLevels;\n\n while(i --){\n m = (m << 1) | rangeDecoder.decodeBit(this._models, m);\n }\n return m - (1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < this._numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(this._models, m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(models, startIndex + m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.LenDecoder = function(){\n this._choice = [];\n this._lowCoder = [];\n this._midCoder = [];\n this._highCoder = new LZMA.BitTreeDecoder(8);\n this._numPosStates = 0;\n };\n\n LZMA.LenDecoder.prototype.create = function(numPosStates){\n for (; this._numPosStates < numPosStates; ++ this._numPosStates){\n this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n }\n };\n\n LZMA.LenDecoder.prototype.init = function(){\n var i = this._numPosStates;\n LZMA.initBitModels(this._choice, 2);\n while(i --){\n this._lowCoder[i].init();\n this._midCoder[i].init();\n }\n this._highCoder.init();\n };\n\n LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState){\n if (rangeDecoder.decodeBit(this._choice, 0) === 0){\n return this._lowCoder[posState].decode(rangeDecoder);\n }\n if (rangeDecoder.decodeBit(this._choice, 1) === 0){\n return 8 + this._midCoder[posState].decode(rangeDecoder);\n }\n return 16 + this._highCoder.decode(rangeDecoder);\n };\n\n LZMA.Decoder2 = function(){\n this._decoders = [];\n };\n\n LZMA.Decoder2.prototype.init = function(){\n LZMA.initBitModels(this._decoders, 0x300);\n };\n\n LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){\n var symbol = 1;\n\n do{\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte){\n var symbol = 1, matchBit, bit;\n\n do{\n matchBit = (matchByte >> 7) & 1;\n matchByte <<= 1;\n bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);\n symbol = (symbol << 1) | bit;\n if (matchBit !== bit){\n while(symbol < 0x100){\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }\n break;\n }\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.LiteralDecoder = function(){\n };\n\n LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){\n var i;\n\n if (this._coders\n && (this._numPrevBits === numPrevBits)\n && (this._numPosBits === numPosBits) ){\n return;\n }\n this._numPosBits = numPosBits;\n this._posMask = (1 << numPosBits) - 1;\n this._numPrevBits = numPrevBits;\n\n this._coders = [];\n\n i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i] = new LZMA.Decoder2();\n }\n };\n\n LZMA.LiteralDecoder.prototype.init = function(){\n var i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i].init();\n }\n };\n\n LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte){\n return this._coders[( (pos & this._posMask) << this._numPrevBits)\n + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )];\n };\n\n LZMA.Decoder = function(){\n this._outWindow = new LZMA.OutWindow();\n this._rangeDecoder = new LZMA.RangeDecoder();\n this._isMatchDecoders = [];\n this._isRepDecoders = [];\n this._isRepG0Decoders = [];\n this._isRepG1Decoders = [];\n this._isRepG2Decoders = [];\n this._isRep0LongDecoders = [];\n this._posSlotDecoder = [];\n this._posDecoders = [];\n this._posAlignDecoder = new LZMA.BitTreeDecoder(4);\n this._lenDecoder = new LZMA.LenDecoder();\n this._repLenDecoder = new LZMA.LenDecoder();\n this._literalDecoder = new LZMA.LiteralDecoder();\n this._dictionarySize = -1;\n this._dictionarySizeCheck = -1;\n\n this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);\n };\n\n LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize){\n if (dictionarySize < 0){\n return false;\n }\n if (this._dictionarySize !== dictionarySize){\n this._dictionarySize = dictionarySize;\n this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);\n this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );\n }\n return true;\n };\n\n LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){\n var numPosStates = 1 << pb;\n\n if (lc > 8 || lp > 4 || pb > 4){\n return false;\n }\n\n this._literalDecoder.create(lp, lc);\n\n this._lenDecoder.create(numPosStates);\n this._repLenDecoder.create(numPosStates);\n this._posStateMask = numPosStates - 1;\n\n return true;\n };\n\n LZMA.Decoder.prototype.init = function(){\n var i = 4;\n\n this._outWindow.init(false);\n\n LZMA.initBitModels(this._isMatchDecoders, 192);\n LZMA.initBitModels(this._isRep0LongDecoders, 192);\n LZMA.initBitModels(this._isRepDecoders, 12);\n LZMA.initBitModels(this._isRepG0Decoders, 12);\n LZMA.initBitModels(this._isRepG1Decoders, 12);\n LZMA.initBitModels(this._isRepG2Decoders, 12);\n LZMA.initBitModels(this._posDecoders, 114);\n\n this._literalDecoder.init();\n\n while(i --){\n this._posSlotDecoder[i].init();\n }\n\n this._lenDecoder.init();\n this._repLenDecoder.init();\n this._posAlignDecoder.init();\n this._rangeDecoder.init();\n };\n\n LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize){\n var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,\n posState, decoder2, len, distance, posSlot, numDirectBits;\n\n this._rangeDecoder.setStream(inStream);\n this._outWindow.setStream(outStream);\n\n this.init();\n\n while(outSize < 0 || nowPos64 < outSize){\n posState = nowPos64 & this._posStateMask;\n\n if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0){\n decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);\n\n if (state >= 7){\n prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );\n }else{\n prevByte = decoder2.decodeNormal(this._rangeDecoder);\n }\n this._outWindow.putByte(prevByte);\n\n state = state < 4? 0: state - (state < 10? 3: 6);\n\n }else{\n\n if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){\n len = 0;\n if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){\n if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0){\n state = state < 7? 9: 11;\n len = 1;\n }\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){\n distance = rep1;\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){\n distance = rep2;\n }else{\n distance = rep3;\n rep3 = rep2;\n }\n rep2 = rep1;\n }\n rep1 = rep0;\n rep0 = distance;\n }\n if (len === 0){\n len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 8: 11;\n }\n }else{\n rep3 = rep2;\n rep2 = rep1;\n rep1 = rep0;\n\n len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 7: 10;\n\n posSlot = this._posSlotDecoder[len <= 5? len - 2: 3].decode(this._rangeDecoder);\n if (posSlot >= 4){\n\n numDirectBits = (posSlot >> 1) - 1;\n rep0 = (2 | (posSlot & 1) ) << numDirectBits;\n\n if (posSlot < 14){\n rep0 += LZMA.reverseDecode2(this._posDecoders,\n rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);\n }else{\n rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;\n rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);\n if (rep0 < 0){\n if (rep0 === -1){\n break;\n }\n return false;\n }\n }\n }else{\n rep0 = posSlot;\n }\n }\n\n if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){\n return false;\n }\n\n this._outWindow.copyBlock(rep0, len);\n nowPos64 += len;\n prevByte = this._outWindow.getByte(0);\n }\n }\n\n this._outWindow.flush();\n this._outWindow.releaseStream();\n this._rangeDecoder.releaseStream();\n\n return true;\n };\n\n LZMA.Decoder.prototype.setDecoderProperties = function(properties){\n var value, lc, lp, pb, dictionarySize;\n\n if (properties.size < 5){\n return false;\n }\n\n value = properties.readByte();\n lc = value % 9;\n value = ~~(value / 9);\n lp = value % 5;\n pb = ~~(value / 5);\n\n if ( !this.setLcLpPb(lc, lp, pb) ){\n return false;\n }\n\n dictionarySize = properties.readByte();\n dictionarySize |= properties.readByte() << 8;\n dictionarySize |= properties.readByte() << 16;\n dictionarySize += properties.readByte() * 16777216;\n\n return this.setDictionarySize(dictionarySize);\n };\n\n LZMA.decompress = function(properties, inStream, outStream, outSize){\n var decoder = new LZMA.Decoder();\n\n if ( !decoder.setDecoderProperties(properties) ){\n throw "Incorrect stream properties";\n }\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n\n LZMA.decompressFile = function(inStream, outStream){\n var decoder = new LZMA.Decoder(), outSize;\n\n if ( !decoder.setDecoderProperties(inStream) ){\n throw "Incorrect stream properties";\n }\n\n outSize = inStream.readByte();\n outSize |= inStream.readByte() << 8;\n outSize |= inStream.readByte() << 16;\n outSize += inStream.readByte() * 16777216;\n\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n'],{type:"text/javascript"});di=URL.createObjectURL(Ai)}catch(e){}var pi=function(){function e(){var e=this;if(this.callCounter=0,this.requests=[],!hi)throw new Error("LZMACaller cannot work in this broswer.");var t=this.worker=new Worker(di);t.onmessage=function(t){var i,n,r=t.data,s=r.PacketID,o=r.Result,a=r.Error;a?null===(n=e.requests[s])||void 0===n||n.onCompleteCallback(new Error(a)):null===(i=e.requests[s])||void 0===i||i.onCompleteCallback(null,o),delete e.requests[s]},t.onerror=function(e){return console.error(e)}}return e.prototype.compress=function(e,t,i){var n=++this.callCounter;this.requests[n]={onCompleteCallback:i},this.worker.postMessage({Type:"compress",PacketID:n,Data:e,Level:t},[e.buffer])},e.prototype.decompress=function(e,t){var i=++this.callCounter;this.requests[i]={onCompleteCallback:t},this.worker.postMessage({Type:"decompress",PacketID:i,Data:e},[e.buffer])},e.prototype.terminate=function(){this.worker.terminate()},e.support=hi,e}();function Mi(e){return Array.prototype.reduce.call(e,(function(e,t,i){return e|t<<8*i}),0)}function fi(e){for(var t=new Uint8Array(e),i=Mi(t.slice(0,4)),n=[],r=[],s=4+4*i,o=0;o<i;o++)r[o]=Mi(t.slice(4+4*o,8+4*o)),n[o]=o===i-1?t.subarray(s,s+r[o]):t.slice(s,s+r[o]),s+=r[o];return pi.support?function(e){for(var t=[],i=e.length,n=function(i){t.push(new Promise((function(t,n){var r=new pi;r.decompress(e[i],(function(e,i){if(r.terminate(),e)return n(e);t(i)}))})))},r=0;r<i;r++)n(r);return Promise.all(t)}(n):Promise.resolve(function(e){for(var t,i=[],n=e.length,r=function(n){var r={data:e[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=r.data.length,o={data:[],offset:0,writeByte:function(e){var t=Math.floor(this.offset/s);this.data[t]||(this.data[t]=new Uint8Array(s)),this.data[t][this.offset%s]=e,this.offset++}};li.decompressFile(r,o),t=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)t[a]=o.data[Math.floor(a/s)][a%s];i.push(t)},s=0;s<n;s++)r(s);return i}(n))}function gi(e){return 0===e.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(e)}var yi=u.parse("\nmessage Model {\n repeated Mesh meshes = 1;\n}\nmessage Mesh {\n required string name = 1;\n repeated Chunk chunks = 2;\n repeated Matrix matrix = 3;\n}\nmessage Matrix {\n repeated float elements = 1;\n}\nmessage Chunk {\n required Geometry geometry = 2;\n repeated Material material = 3;\n}\nmessage Geometry {\n required Position position = 1;\n optional UV uv = 2;\n optional UV uv2 = 3;\n required Normal normal = 4;\n repeated Group groups = 5;\n}\nmessage Position {\n repeated float array = 1[packed=true];\n}\nmessage UV {\n repeated float array = 1[packed=true];\n}\nmessage Normal {\n repeated float array = 1[packed=true];\n}\nmessage Group {\n required uint32 start = 1;\n required uint32 count = 2;\n required uint32 materialIndex = 3;\n}\nmessage Material {\n optional Color kd = 1;\n optional Color ks = 2;\n optional Color ke = 3;\n optional string mapkd = 4;\n optional string mapks = 5;\n optional string mapke = 6;\n optional string norm = 7;\n optional string mapbump = 8;\n optional string bump = 9;\n optional string mapd = 10;\n optional float ns = 11;\n optional float d = 12;\n optional float tr = 13;\n optional string mapkdrepeat = 14;\n}\nmessage Color {\n repeated float rgb = 1;\n}\n").root.lookup("Model");var vi={};function mi(e,t,i,n,r){var s,o=[],u=[];function c(e,s,o){var c=function(e){var t=e.position,i=e.normal,n=e.uv,r=e.uv2,s=e.groups,o=new a.BufferGeometry;return o.setAttribute("position",new a.BufferAttribute(new Float32Array(t.array),3)),i&&o.setAttribute("normal",new a.BufferAttribute(new Float32Array(i.array),3)),n&&o.setAttribute("uv",new a.BufferAttribute(new Float32Array(n.array),2)),r&&o.setAttribute("uv2",new a.BufferAttribute(new Float32Array(r.array),2)),s.forEach((function(e){return o.addGroup(e.start,e.count,e.materialIndex)})),o}(e);c.applyMatrix4(o);var l=new a.Vector3,h=new a.Quaternion,d=new a.Vector3;o.decompose(l,h,d),d.x*d.y*d.z<0&&c.attributes.normal&&c.attributes.position&&c.attributes.uv&&function(e){for(var t=[0,0,0],i=0;i<e.attributes.normal.array.length/9;i++)t[0]=e.attributes.normal.array[9*i],t[1]=e.attributes.normal.array[9*i+1],t[2]=e.attributes.normal.array[9*i+2],e.attributes.normal.array[9*i]=e.attributes.normal.array[9*i+6],e.attributes.normal.array[9*i+1]=e.attributes.normal.array[9*i+7],e.attributes.normal.array[9*i+2]=e.attributes.normal.array[9*i+8],e.attributes.normal.array[9*i+6]=t[0],e.attributes.normal.array[9*i+7]=t[1],e.attributes.normal.array[9*i+8]=t[2];for(i=0;i<e.attributes.position.array.length/9;i++)t[0]=e.attributes.position.array[9*i],t[1]=e.attributes.position.array[9*i+1],t[2]=e.attributes.position.array[9*i+2],e.attributes.position.array[9*i]=e.attributes.position.array[9*i+6],e.attributes.position.array[9*i+1]=e.attributes.position.array[9*i+7],e.attributes.position.array[9*i+2]=e.attributes.position.array[9*i+8],e.attributes.position.array[9*i+6]=t[0],e.attributes.position.array[9*i+7]=t[1],e.attributes.position.array[9*i+8]=t[2];for(i=0;i<e.attributes.uv.array.length/6;i++)t[0]=e.attributes.uv.array[6*i],t[1]=e.attributes.uv.array[6*i+1],e.attributes.uv.array[6*i]=e.attributes.uv.array[6*i+4],e.attributes.uv.array[6*i+1]=e.attributes.uv.array[6*i+5],e.attributes.uv.array[6*i+4]=t[0],e.attributes.uv.array[6*i+5]=t[1];e.attributes.normal.needsUpdate=!0,e.attributes.position.needsUpdate=!0,e.attributes.uv.needsUpdate=!0}(c);var A=s.map((function(e){var s=function(e,t,i,n,r){var s={sourceFile:null,needsUpdate:!0,wrapS:a.RepeatWrapping,wrapT:a.RepeatWrapping};function o(e,o){return vi[e]?Promise.resolve(vi[e]):new Promise((function(u,c){var l=new Qt({allowHosts:n,networkSubscribe:r});gi(e)||(e=t+e),-1!==(e=(e=e.replace(/\/\/vrlab-image\d*.ljcdn.com\//,"//vrlab-public.ljcdn.com/")).split("?")[0]).indexOf(".png")&&(e=e.split(".png")[0]+".png"),-1!==e.indexOf(".jpg")&&(e=e.split(".jpg")[0]+".jpg"),0===e.indexOf("//")&&(e="https:"+e),e=Ut(e,Object.assign({key:"texture"},i,{size:64})),l.load(e,(function(t){var i=new a.Texture(t),n=i.dispose;i.dispose=function(){n.call(i),/^blob\:/.test(t.src)&&URL.revokeObjectURL(t.src)},o&&Object.assign(i.repeat,o),Object.assign(i,s,{sourceFile:e}),i.updateMatrix(),vi[e]=i,u(i)}),He,(function(e){return c(e.error)}))}))}var u=[],c=new dt,l=c.uniforms;l.exposure.value=4.3;var h,d=c.defines;if(d.USE_MAP=!1,d.USE_UV=!1,e.hasOwnProperty("kd")&&(l.diffuse.value=(new a.Color).fromArray(e.kd.rgb)),e.hasOwnProperty("mapkd")){var A=void 0;if(e.mapkdrepeat){var p=e.mapkdrepeat.split(/\s+/).map((function(e){return Number(e)})),M=p[0],f=p[1];A=new a.Vector2(M,f)}u.push(o(e.mapkd,A).then((function(e){d.USE_MAP=!0,d.USE_UV=!0,l.map.value=e,l.uvTransform.value=e.matrix})).catch((function(e){})))}return e.hasOwnProperty("ks")&&(l.specular.value=(new a.Color).fromArray(e.ks.rgb)),e.hasOwnProperty("mapks")&&u.push(o(e.mapks).then((function(e){l.specularMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ke")&&(l.emissive.value=(new a.Color).fromArray(e.ke.rgb)),e.hasOwnProperty("mapke")&&u.push(o(e.mapke).then((function(e){l.emissiveMap.value=e})).catch((function(e){}))),e.hasOwnProperty("norm")&&u.push(o(e.norm).then((function(e){l.normalMap.value=e})).catch((function(e){}))),e.hasOwnProperty("mapbump")&&u.push(o(e.mapbump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("bump")&&u.push(o(e.bump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ns")&&(l.shininess.value=e.ns),e.hasOwnProperty("d")&&(h=e.d)>=0&&h<1&&(l.originOpacity.value=h),e.hasOwnProperty("tr")&&(h=1-e.tr)>=0&&h<1&&(l.originOpacity.value=h),l.originOpacity.value<1&&(c.transparent=!0),{material:c,textureReady:Promise.all(u).then((function(){}))}}(e,t,i,n,r),o=s.material,c=s.textureReady;return u.push(c),o}));return new tt(c,A)}return(s=e,yi.decode(s)).meshes.forEach((function(e){var t=e.name,i=e.chunks,n=e.matrix;"Ceiling"!==t&&"CeilingDrop"!==t&&n.map((function(e){var n,r=new a.Matrix4;if(r.elements=e.elements,1===i.length){var s=i[0],u=s.geometry,l=s.material;n=c(u,l,r)}else n=new nt,i.forEach((function(e,t){var i=c(e.geometry,e.material,r);i.name="chunk"+t,n.add(i)}));n.floorIndex=0,n.name=t,o.push(n)}))})),Promise.all(u).catch((function(){})).then((function(){return o}))}function Ni(){Object.keys(vi).forEach((function(e){vi[e].dispose(),delete vi[e]}))}function Di(e){var i;return new((i=a.Triangle).bind.apply(i,t.__spreadArray([void 0],e.map((function(e){return new a.Vector3(e.x,e.y,e.z)})),!1)))}var wi={at3d:function(e,t){for(var i=ci(t.imageOptions,e.textures.length),n={},r=0,s=e.textures;r<s.length;r++){var o=s[r];n[o]=si(o,i,t.allowHosts,t.networkSubscribe)}var a={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return kt.async(e.file,a)})).then((function(e){return fi(e.body)})).then((function(e){return Gt((function(){for(var t=[],i=0,n=e;i<n.length;i++){var r=n[i],s=ai.decode(r);t.push.apply(t,s.chunks)}return t}))})).then((function(r){return Gt((function(){return ui(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},pbm:function(e,t){for(var i=ci(t.imageOptions,e.textures.length),n={},r=0,s=e.textures;r<s.length;r++){var o=s[r];n[o]=si(o,i,t.allowHosts,t.networkSubscribe)}var a={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return kt.async(e.file,a)})).then((function(e){return Gt((function(){var t=new Uint8Array(e.body),i=ai.decode(t);return[].concat(i.chunks)}))})).then((function(r){return Gt((function(){return ui(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},dome:function(e,t){var i={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return Ni()})).then((function(){return kt.async(e.file,i)})).then((function(i){return mi(new Uint8Array(i.body),e.textureBase,t.imageOptions,t.allowHosts,t.networkSubscribe)}))},domez:function(e,t){var i={responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe};return Promise.resolve().then((function(){return Ni()})).then((function(){return kt.async(e.file,i)})).then((function(e){return fi(e.body)})).then((function(e){var t=e.reduce((function(e,t){return e+t.length}),0),i=new Uint8Array(t),n=0;return e.forEach((function(e){i.set(e,n),n+=e.length})),i})).then((function(i){return mi(i,e.textureBase,t.imageOptions,t.allowHosts,t.networkSubscribe)}))}},Ti=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.empty=!1,i.name="model",i.loaded=!1,i.bvhs=[],i.bounding=new a.Box3,i.shownFloor=null,i.floorLength=0,i.networkSubscribe=t.networkSubscribe,i.allowHosts=t.allowHosts,i}return t.__extends(i,e),Object.defineProperty(i.prototype,"shownfloor",{get:function(){return this.shownFloor},enumerable:!1,configurable:!0}),i.prototype.getEdges=function(e){var t;void 0===e&&(e=30/180*Math.PI);for(var i=Math.cos(e),n=[],r=0,s=this.children;r<s.length;r++){var o=s[r];if(o instanceof tt){for(var u={},c=["a","b","c"],l=Wt.mergeVertices(o.geometry),h=l.getAttribute("position").array,d=(null===(t=l.getIndex())||void 0===t?void 0:t.array)||[],A=[],p=[],M=0,f=h.length;M<f;M+=3)A.push(new a.Vector3(h[M],h[M+1],h[M+2]));for(M=0,f=d.length;M<f;M+=3){var g=d[M],y=d[M+1],v=d[M+2],m=(new a.Vector3).crossVectors(A[y].clone().sub(A[g]),A[v].clone().sub(A[g])).normalize();p.push({a:g,b:y,c:v,normal:m})}for(M=0,f=p.length;M<f;M++)for(var N=p[M],D=0;D<3;D++){var w=N[c[D]],T=N[c[(D+1)%3]],x=[Math.min(w,T),Math.max(w,T)];void 0===u[E=x[0]+"-"+x[1]]?u[E]={index1:x[0],index2:x[1],face1:M}:u[E].face2=M}for(var E in u){var j=u[E];if(void 0===j.face2||p[j.face1].normal.dot(p[j.face2].normal)<=i){var I=A[j.index1],z=A[j.index2];n.push(new a.Line3(I,z))}}l.dispose(),A.length=0,p.length=0}}return n},i.prototype.hasFloors=function(){return this.hasFloors_()},i.prototype.hasFloors_=function(){var e=[];return this.traverse((function(t){t instanceof tt&&(e[t.floorIndex]=!0)})),e.length},i.prototype.show=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=this.shownFloor,r=null,s=null!==(e=t[1])&&void 0!==e?e:.1,o=0!==t.length;this.shownFloor=r=o?t[0]:null,this.traverse((function(e){e instanceof tt&&e.material.forEach((function(t){null===r||r===e.floorIndex?t.opacity=1:t.opacity=s}))})),n!==this.shownFloor&&this.emit("shownFloorChange",this.shownFloor,this.floorLength),this.needsRender=!0},i.prototype.intersectRaycaster=function(e,t){var i=e.ray,n=i.origin,r=i.direction;if(Ve(t))if(Ve(this.shownFloor)){var s=this.floorLength;t=[];for(var o=0;o<s;o++)t.push(o)}else t=[this.shownFloor];var u=[],c=[];Array.isArray(t)?c.push.apply(c,t):c.push(t);for(var l=function(t){var i=h.bvhs&&h.bvhs[t];if(i){(s=i.intersectRay(n,r,!0).map((function(e){var t=e.intersectionPoint,i=e.triangle,r=new a.Vector3(t.x,t.y,t.z);return{point:r,face:{normal:Di(i).getNormal(new a.Vector3)},distance:n.distanceTo(r)}}))).length&&u.push.apply(u,s)}else{var s,o=[];h.traverse((function(e){e instanceof tt&&e.floorIndex===t&&o.push(e)})),(s=e.intersectObjects(o).map((function(e){var t=e.face?{normal:e.face.normal}:void 0;return{point:e.point,face:t,distance:e.distance}}))).length&&u.push.apply(u,s)}},h=this,d=0,A=c;d<A.length;d++){l(A[d])}return u.filter((function(t){var i=t.distance;return i<=e.far&&i>=e.near})).sort((function(e,t){return e.distance-t.distance}))},i.prototype.buildBVH=function(){var e=this,t=[];this.traverse((function(e){e instanceof tt&&(t[e.floorIndex]=t[e.floorIndex]||[],t[e.floorIndex].push(e.geometry))}));var i=t.map((function(e){var t=e.reduce((function(e,t){return e+(t.index?t.index.array.length:t.attributes.position.array.length)}),0),i=new Float32Array(3*t);return e.reduce((function(e,t){for(var n=t.index?t.index.array:null,r=t.attributes.position.array,s=n?n.length:r.length/3,o=0;o<s;o++){var a=3*(e+o),u=n?3*n[o]:3*o;i[a+0]=r[u+0],i[a+1]=r[u+1],i[a+2]=r[u+2]}return e+s}),0),new Nt(i,5)}));return this.bvhs=[],Promise.all(i.map((function(e){return new Promise((function(t){return e.splitNode(t)}))}))).then((function(){e.bvhs=i,e.bvhs.loaded=!0,e.emit("bvhLoaded")}))},i.prototype.load=function(e,t){var i=this;if(void 0===t&&(t={}),!0===this.loaded)throw new Error("[MODEL LOAD ERROR]: model cannot load twice.");var n=function(e,t){void 0===t&&(t=[]);var i=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(e);if(!i)return"";for(var n=0,r=String(i[1]).trim().split(".").slice(1).reverse();n<r.length;n++){var s=r[n],o=t.indexOf(s);if(o>=0)return t[o]}return""}(e.file,Object.keys(wi)),r=wi[n];if(!r)throw new Error("[MODEL LOAD ERROR]: file type("+n+") does not support.");return r(e,{imageOptions:t,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe}).then((function(e){for(var t=[],n=0,r=e;n<r.length;n++){(c=r[n]).traverse((function(e){e instanceof tt&&(e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),t.push(e.geometry.boundingBox))})),i.add(c)}i.floorLength=i.hasFloors_(),i.bounding=function(e){for(var t=new a.Box3,i=0,n=e;i<n.length;i++){var r=n[i];t.union(r)}return t}(t);for(var s=i.bounding.getCenter(new a.Vector3),o=0,u=e;o<u.length;o++){var c;(c=u[o]).traverse((function(e){e instanceof tt&&e.material.forEach((function(e){e.uniforms.modelCenter.value=s}))}))}t.length=0,i.emit("geometryLoaded"),i.emit("materialLoaded"),i.loaded=!0,Ke((function(){return i.emit("loaded")}))})).catch((function(e){return i.emit("error",e),Promise.reject(e)}))},i.prototype.dispose=function(){for(this.off(),this.disposeGeometry(),this.disposeMaterial();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},i}(it);function xi(e){switch(e.getError()){case e.INVALID_ENUM:return new Error("webgl error: INVALID_ENUM");case e.INVALID_VALUE:return new Error("webgl error: INVALID_VALUE");case e.INVALID_OPERATION:return new Error("webgl error: INVALID_OPERATION");case e.INVALID_FRAMEBUFFER_OPERATION:return new Error("webgl error: INVALID_FRAMEBUFFER_OPERATION");case e.OUT_OF_MEMORY:return new Error("webgl error: OUT_OF_MEMORY");case e.CONTEXT_LOST_WEBGL:return new Error("webgl error: CONTEXT_LOST_WEBGL");default:return null}}Object.assign(Ti.prototype,{on:xt.prototype.on,once:xt.prototype.once,off:xt.prototype.off,emit:xt.prototype.emit,hasListener:xt.prototype.hasListener});var Ei=c.default.Tween,ji=c.default.Easing;function Ii(e,t,i,n){void 0===n&&(n=ji.Linear.None);var r=[],s=[],o=[],a=[],u=Object.assign(new Ei(e).to(t,i).easing(n),{completed:!1,onCancel:function(e){return r.push(e),u},destroy:function(){if(u.stop(),Object.assign(this,{_onStartCallback:null,_onUpdateCallback:null,_onCompleteCallback:null,_onStopCallback:null}),!u.completed)for(var e=0,t=r;e<t.length;e++){(0,t[e])()}r.length=0,c()}});Object.assign(u,{onStart:function(e){return s.push(e),u},onUpdate:function(e){return o.push(e),u},onComplete:function(e){return a.push(e),u},_onStartCallback:function(e){for(var t=0,i=s;t<i.length;t++){(0,i[t])(e)}},_onUpdateCallback:function(e,t){for(var i=0,n=o;i<n.length;i++){(0,n[i])(e,t)}1===t&&0===u._repeat&&(u.completed=!0)},_onCompleteCallback:function(e){for(var t=0,i=a;t<i.length;t++){(0,i[t])(e)}}}),Ke((function(){return u.start()}));var c=Je((function(e){!1===u.update(e)&&c()}));return u}function zi(e,t){return Ii({progress:0},{progress:1},e,t)}var bi=2*Math.PI;function Li(e){return(e%bi+bi)%bi}var Si=Math.PI,Oi=2*Si;function Ci(e,t,i){return e+(t-e)*i}function Pi(e,t,i){return e=Li(e),Ci((t=Li(t))-e>Si?e+Oi:e-t>Si?e-Oi:e,t,i)}function ki(e,t,i){if(e===t)return t;var n=t-e;return Math.abs(n)<=i?t:e+(n>0?1:-1)*i}function Bi(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=[];e=e.map((function(e){return e.trim()})).filter((function(e){return e.length>0&&!/^\/+$/.test(e)}));for(var n=0;n<e.length;n++){var r=0===n,s=n===e.length-1,o=e[n];r||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),i.push(o)}return i.join("/")}function Ui(e){return e instanceof Error}function Qi(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var i,n,r;if(Array.isArray(e)){if((i=e.length)!=t.length)return!1;for(n=i;0!=n--;)if(!Qi(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=i;0!=n--;){var s=r[n];if(!Qi(e[s],t[s]))return!1}return!0}return e!=e&&t!=t}function _i(e){return"number"==typeof e}function Ri(e,t){void 0===t&&(t=!1);var i=typeof e;if("string"===i)return JSON.stringify(e);if(!0===e)return"true";if(!1===e)return"false";if(null===e)return"null";if(e instanceof Array){for(var n="[",r=e.length-1,s=0;s<r;s++)n+=Ri(e[s],!1)+",";return r>-1&&(n+=Ri(e[s],!1)),n+"]"}if(e instanceof Object){if("function"==typeof e.toJSON)return Ri(e.toJSON(),t);var o=Object.keys(e).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],c=Ri(e[u],!0);void 0!==c&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+c),s++}return"{"+n+"}"}switch(i){case"function":case"undefined":return t?void 0:null;case"number":return 0;default:return isFinite(e)?e:null}}function Yi(e){return String(Ri(e,!1))}function Fi(e){var t,i,n,r=JSON.parse(e),s="undefined"!=typeof location?location.hostname:"",o=Date.now();if("object"!=typeof r)return new Error("input is not an object");if(0===s.length||It(s)||bt.filter((function(e){return zt(e,s)})).length>0){var a=String(null!==(t=r.certificate)&&void 0!==t?t:"");if(a){var u=new Oe;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var c=String(null!==(i=r.certificate)&&void 0!==i?i:"");if(!c)return new Error("certificate is not existed.");var l=new Oe;l.readCertPEM(c);var h=String(null!==(n=r._signature)&&void 0!==n?n:"");if(!h)return new Error("signature is not existed.");if(!1===function(e,t,i){var n=new Oe;if("string"==typeof i?n.readCertPEM(i):n.readCertHex(i.hex),!1===Ue(n))return!1;var r=new ee;return r.readCertPubKeyHex(n.hex,6),!!r.verify(e,_(t))}(Yi(function(e,t){for(var i={},n=0,r=Object.keys(e);n<r.length;n++){var s=r[n];-1===t.indexOf(s)&&(i[s]=e[s])}return i}(r,["_signature"])),h,l))return new Error("signature verify failed.");var d=new Date("string"==typeof r.expire_at&&/^\d+$/.test(r.expire_at)?Number(r.expire_at):r.expire_at);return o<d.getTime()?0===(Array.isArray(r.allow_hosts)?r.allow_hosts:[]).filter((function(e){return zt(e,s)})).length?function(e){return new Error("host("+JSON.stringify(e)+") is not allowed.")}(s):{issuer:l.getSubjectString()}:function(e){return new Error("date("+e.toString()+") expired.")}(d)}var Vi=new WeakMap;function Hi(e,t,i){var n,r,s=JSON.stringify(t),o=JSON.stringify(e),u=Fi(o);e=JSON.parse(o),t=JSON.parse(s);var c={workCode:"",expire:new Date,allowHosts:[],uuid:qe(),initial:{mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},observers:[],issuer:u instanceof Error?"none":u.issuer,raw:{work:e,options:t}},l=null!==(n=e.base_url)&&void 0!==n?n:"";l&&"/"!==l[l.length-1]&&(l+="/");var h=function(e,n){var r,s=e;!0===t.jsonp&&(s=(s=e.replace(/([\?\#].*)?$/i,""))+"."+Ce(""+s).slice(0,7)+".jsonp");if(!0===t.shortPath){var o=s.replace(l,"").split("."),a=null!==(r=o.shift())&&void 0!==r?r:"",u=o.join(".");s=Bi(l,Ce(a))+(u?"."+u:"")}var c=s.replace(l,"");return t.baseURL&&(s=Bi(t.baseURL,c)),i&&i(e,s,c,n),s},d=function(t,i){var n,r,s,o,a,u,c=t;if(!gi(t)){var d=null!==(u=null!==(o=null!==(r=null===(n=e.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==r?r:null===(s=e.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=e.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";d&&(d=Bi(d,String(i))),c=Bi(d,c)}return gi(c)||(c=Bi(l,c)),h(c,"panorama")},A=function(e){var t=e;return gi(t)||(t=Bi(l,e)),h(t,"model")},p=function(e,t){void 0===t&&(t="");var i=e;return gi(i)||(i=Bi(t,i)),gi(i)||(i=Bi(l,i)),h(i,"texture")};if(c.workCode=null!==(r=String(e.work_code||e.code||e.vr_code||e.workCode))&&void 0!==r?r:"",c.expire=new Date("string"==typeof e.expire_at&&/^\d+$/.test(e.expire_at)?Number(e.expire_at):e.expire_at),c.allowHosts=e.allow_hosts||[],Ui(u))return u;if(e.initial&&("Floorplan"!==e.initial.mode&&"Topview"!==e.initial.mode&&"Panorama"!==e.initial.mode&&"VRPanorama"!==e.initial.mode&&"Model"!==e.initial.mode&&"DepthPanorama"!==e.initial.mode||(c.initial.mode=e.initial.mode),_i(e.initial.latitude)&&(c.initial.latitude=e.initial.latitude),_i(e.initial.longitude)?c.initial.longitude=e.initial.longitude:_i(e.initial.heading)&&(c.initial.longitude=-(360*(e.initial.heading-.25)+90)/180*Math.PI),_i(e.initial.fov)&&(c.initial.fov=e.initial.fov),_i(e.initial.panoIndex)?c.initial.panoIndex=e.initial.panoIndex:_i(e.initial.pano_index)?c.initial.panoIndex=e.initial.pano_index:_i(e.initial.pano)&&(c.initial.panoIndex=e.initial.pano)),Ui(u))return u;if(e.model){var M={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.model.bvh?M.bvh=e.model.bvh:"boolean"==typeof e.bvh&&(M.bvh=e.bvh),"boolean"==typeof e.model.async?M.async=e.model.async:"boolean"==typeof e.modelAsync&&(M.async=e.modelAsync),e.model.file?M.file=A(e.model.file):e.model.file_url&&(M.file=A(e.model.file_url)),e.model.textureBase?M.textureBase=e.model.textureBase:e.model.material_base_url&&(M.textureBase=e.model.material_base_url),Array.isArray(e.model.textures)?M.textures=e.model.textures.map((function(e){return p(e,M.textureBase)})):Array.isArray(e.model.material_textures)&&(M.textures=e.model.material_textures.map((function(e){return p(e,M.textureBase)}))),M.file&&(c.model=M)}if(Ui(u))return u;if(e.observers&&Array.isArray(e.observers)){var f=[];e.panorama&&(Array.isArray(e.panorama)?f=e.panorama:Array.isArray(e.panorama.list)?f=e.panorama.list:Array.isArray(e.panorama.info)&&(f=e.panorama.info));for(var g=0;g<e.observers.length;g++){var y={},v=e.observers[g];if(!v)break;var m=f[g]||{};v=Object.assign({},v,m,{active:!1!==v.active&&!1!==m.active}),y.panoIndex=g,y.active=!1!==v.active,y.loadable=!0===v.loadable,y.images={up:d(v.images?v.images.up:v.up,g),down:d(v.images?v.images.down:v.down,g),right:d(v.images?v.images.right:v.right,g),left:d(v.images?v.images.left:v.left,g),front:d(v.images?v.images.front:v.front,g),back:d(v.images?v.images.back:v.back,g)};var N=v.images?v.images.depth:v.depth;N&&(y.images.depth=d(N,g));var D=v.images?v.images.tiles:v.tiles;if(D&&(y.images.tiles=d(D,g)),v.position instanceof a.Vector3)y.position=v.position.clone();else{if(!Array.isArray(v.position))break;y.position=(new a.Vector3).fromArray(v.position)}if(v.standingPosition instanceof a.Vector3)y.standingPosition=v.standingPosition.clone();else if(Array.isArray(v.standingPosition))y.standingPosition=(new a.Vector3).fromArray(v.standingPosition);else if(v.standing_position instanceof a.Vector3)y.standingPosition=v.standing_position.clone();else{if(!Array.isArray(v.standing_position))break;y.standingPosition=(new a.Vector3).fromArray(v.standing_position)}if(v.quaternion instanceof a.Quaternion)y.quaternion=v.quaternion.clone();else if(Array.isArray(v.quaternion))y.quaternion=(new a.Quaternion).fromArray(v.quaternion);else{if(!v.quaternion)break;var w=v.quaternion,T=w.x,x=w.y,E=w.z,j=w.w;y.quaternion=new a.Quaternion(T,x,E,j)}if(Array.isArray(v.accessibleNodes)?y.accessibleNodes=v.accessibleNodes.slice():Array.isArray(v.accessible_nodes)&&(y.accessibleNodes=v.accessible_nodes.slice()),Array.isArray(v.visibleNodes)?y.visibleNodes=v.visibleNodes.slice():Array.isArray(v.visible_nodes)&&(y.visibleNodes=v.visible_nodes.slice()),_i(v.floorIndex)?y.floorIndex=v.floorIndex:_i(v.floor_index)?y.floorIndex=v.floor_index:y.floorIndex=0,v.video){var I={};"string"==typeof v.video.source&&(I.source=v.video.source),v.video.matrix instanceof a.Matrix4?I.matrix=v.video.matrix.clone():Array.isArray(v.video.matrix)&&(I.matrix=(new a.Matrix4).fromArray(v.video.matrix)),v.video.size instanceof a.Vector2?I.size=v.video.size.clone():Array.isArray(v.video.size)&&(I.size=(new a.Vector2).fromArray(v.video.size)),I.source&&I.matrix&&I.size&&(y.video=I)}c.observers[g]=y}}if(Ui(u))return u;for(var z=0,b=c.observers;z<b.length;z++){if(!(y=b[z]).accessibleNodes){y.accessibleNodes=[];for(var L=0;L<c.observers.length;L++)c.observers[L]!==y&&y.accessibleNodes.push(L)}if(!y.visibleNodes){y.visibleNodes=[];for(L=0;L<c.observers.length;L++)c.observers[L]!==y&&y.visibleNodes.push(L)}}if(Ui(u))return u;var S=Et(c);return Vi.set(S,{work:o,options:s}),S}function Gi(e,t,i){"string"==typeof e&&"{"===e.trim()[0]&&(e=JSON.parse(e));var n=Vi.get(e);if(n){if(t&&!Qi(JSON.parse(n.options),t))throw new Error("[PARSE FAILED]: work is parsed with different options.");return e}var r=Hi(e,null!=t?t:{},i);if(Ui(r))throw new Error("[PARSE FAILED]: "+r.message);return r}var qi=function(e){return Number(e)};function Wi(e,t,i){var n;void 0===t&&(t=qi),void 0===i&&(i=!1);for(var r,s=1/0,o=0,a=e;o<a.length;o++){var u=a[o],c=t(u);c<=s&&(r=(n=[u,c])[0],s=n[1])}return i?[r,s]:r}
368
368
  /*! Hammer.JS - v2.0.7 - 2016-04-22
369
369
  * http://hammerjs.github.io/
370
370
  *