You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
346 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

/*! For license information please see jitsi.js.LICENSE.txt */
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=72)}([,,function(t,e,n){"use strict";e.decode=e.parse=n(14),e.encode=e.stringify=n(15)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(37);Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})}));var i=n(38);Object.keys(i).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return i[t]}})}));var s=n(39);Object.keys(s).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})}));var a=n(9);Object.keys(a).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return a[t]}})}));var o=n(40);Object.keys(o).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return o[t]}})}));var u=n(41);Object.keys(u).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return u[t]}})}));var h=n(42);Object.keys(h).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return h[t]}})}));var c=n(43);Object.keys(c).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return c[t]}})}));var l=n(18);Object.keys(l).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return l[t]}})}));var f=n(44);Object.keys(f).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return f[t]}})}));var d=n(45);Object.keys(d).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return d[t]}})}));var g=n(46);Object.keys(g).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return g[t]}})}));var p=n(10);Object.keys(p).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return p[t]}})}));var v=n(7);Object.keys(v).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return v[t]}})}));var y=n(8);Object.keys(y).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return y[t]}})}));var m=n(20);Object.keys(m).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return m[t]}})}));var x=n(47);Object.keys(x).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return x[t]}})}));var S=n(48);Object.keys(S).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return S[t]}})}));var b=n(49);Object.keys(b).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})}));var E=n(50);Object.keys(E).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return E[t]}})}));var w=n(51);Object.keys(w).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return w[t]}})}));var F=n(52);Object.keys(F).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return F[t]}})}));var A=n(53);Object.keys(A).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return A[t]}})}));var C=n(11);Object.keys(C).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return C[t]}})}));var I=n(54);Object.keys(I).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return I[t]}})}));var P=n(55);Object.keys(P).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return P[t]}})}));var D=n(56);Object.keys(D).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return D[t]}})}));var R=n(19);Object.keys(R).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return R[t]}})}));var T=n(57);Object.keys(T).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return T[t]}})}));var O=n(58);Object.keys(O).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return O[t]}})}));var B=n(59);Object.keys(B).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return B[t]}})}));var H=n(60);Object.keys(H).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return H[t]}})}));var N=n(61);Object.keys(N).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return N[t]}})}));var j=n(12);Object.keys(j).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return j[t]}})}));var _=n(22);Object.keys(_).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return _[t]}})}));var k=n(23);Object.keys(k).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return k[t]}})}));var V=n(24);Object.keys(V).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return V[t]}})}));var L=n(62);Object.keys(L).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return L[t]}})}));var M=n(63);Object.keys(M).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return M[t]}})}));var K=n(21);Object.keys(K).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return K[t]}})}));var q=n(64);Object.keys(q).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return q[t]}})}))},,function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(n,r){function i(){void 0!==s&&t.removeListener("error",s),n([].slice.call(arguments))}var s;"error"!==e&&(s=function(n){t.removeListener(e,i),r(n)},t.once("error",s)),t.once(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var u=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function l(t,e,n,r){var i,s,a,o;if(h(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),a=s[e]),void 0===a)a=s[e]=n,++t._eventsCount;else if("function"==typeof a?a=s[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=c(t))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,o=u,console&&console.warn&&console.warn(o)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function g(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n)e[n]=t[n].listener||t[n];return e}(i):v(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function v(t,e){for(var n=new Array(e),r=0;r<e;++r)n[r]=t[r];return n}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");u=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var u=i[t];if(void 0===u)return!1;if("function"==typeof u)s(u,this,e);else{var h=u.length,c=v(u,h);for(n=0;n<h;++n)s(c[n],this,e)}return!0},o.prototype.addListener=function(t,e){return l(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return l(this,t,e,!0)},o.prototype.once=function(t,e){return h(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return h(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var n,r,i,s,a;if(h(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===e||n[s].listener===e){a=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,a||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return g(this,t,!0)},o.prototype.rawListeners=function(t){return g(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.invertedDirection=function(t){if(t===r.ToWidget)return r.FromWidget;if(t===r.FromWidget)return r.ToWidget;throw new Error("Invalid direction")},e.WidgetApiDirection=void 0,e.WidgetApiDirection=r,function(t){t.ToWidget="toWidget",t.FromWidget="fromWidget"}(r||(e.WidgetApiDirection=r={}))},function(t,e,n){"use strict";var r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.CurrentApiVersions=e.UnstableApiVersion=e.MatrixApiVersion=void 0,e.MatrixApiVersion=r,function(t){t.Prerelease1="0.0.1",t.Prerelease2="0.0.2"}(r||(e.MatrixApiVersion=r={})),e.UnstableApiVersion=i,function(t){t.MSC2762="org.matrix.msc2762",t.MSC2871="org.matrix.msc2871",t.MSC2931="org.matrix.msc2931",t.MSC2974="org.matrix.msc2974"}(i||(e.UnstableApiVersion=i={}));var s=[r.Prerelease1,r.Prerelease2,i.MSC2762,i.MSC2871,i.MSC2931,i.MSC2974];e.CurrentApiVersions=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PostmessageTransport=void 0;var r=n(6),i=n(3);function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){p(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,e,n){return e&&u(t.prototype,e),n&&u(t,n),t}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=g(t);if(e){var i=g(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return f(this,n)}}function f(t,e){return!e||"object"!==s(e)&&"function"!=typeof e?d(t):e}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(t){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var v=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}(n,t);var e=l(n);function n(t,r,i,s){var a;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),(a=e.call(this)).sendDirection=t,a.initialWidgetId=r,a.transportWindow=i,a.inboundWindow=s,p(d(a),"strictOriginCheck",void 0),p(d(a),"targetOrigin",void 0),p(d(a),"timeoutSeconds",10),p(d(a),"_ready",!1),p(d(a),"_widgetId",null),p(d(a),"outboundRequests",new Map),p(d(a),"isStopped",!1),a._widgetId=r,a}return h(n,[{key:"ready",get:function(){return this._ready}},{key:"widgetId",get:function(){return this._widgetId||null}}]),h(n,[{key:"sendInternal",value:function(t){var e=this.targetOrigin||"*";console.log("[PostmessageTransport] Sending object to ".concat(e,": "),t),this.transportWindow.postMessage(t,e)}},{key:"reply",value:function(t,e){return this.sendInternal(o(o({},t),{},{response:e}))}},{key:"send",value:function(t,e){return this.sendComplete(t,e).then((function(t){return t.response}))}},{key:"sendComplete",value:function(t,e){var n=this;if(!this.ready||!this.widgetId)return Promise.reject(new Error("Not ready or unknown widget ID"));var r={api:this.sendDirection,widgetId:this.widgetId,requestId:this.nextRequestId,action:t,data:e};return t===i.WidgetApiToWidgetAction.UpdateVisibility&&(r.visible=e.visible),new Promise((function(t,e){var i=setTimeout((function(){var t=n.outboundRequests.get(r.requestId);t&&(n.outboundRequests.delete(r.requestId),t.reject(new Error("Request timed out")))}),1e3*(n.timeoutSeconds||1));n.outboundRequests.set(r.requestId,{request:r,resolve:function(e){return t(e)},reject:e,timerId:i}),n.sendInternal(r)}))}},{key:"start",value:function(){var t=this;this.inboundWindow.addEventListener("message",(function(e){t.handleMessage(e)})),this._ready=!0}},{key:"stop",value:function(){this._ready=!1,this.isStopped=!0}},{key:"handleMessage",value:function(t){if(!this.isStopped&&t.data&&(!this.strictOriginCheck||t.origin===window.origin)){var e=t.data;if(e.action&&e.requestId&&e.widgetId)if(e.response){if(e.api!==this.sendDirection)return;this.handleResponse(e)}else{var n=e;if(n.api!==(0,i.invertedDirection)(this.sendDirection))return;this.handleRequest(n)}}}},{key:"handleRequest",value:function(t){if(this.widgetId){if(this.widgetId!==t.widgetId)return}else this._widgetId=t.widgetId;this.emit("message",new CustomEvent("message",{detail:t}))}},{key:"handleResponse",value:function(t){if(t.widgetId===this.widgetId){var e=this.outboundRequests.get(t.requestId);if(e)if(this.outboundRequests.delete(t.requestId),clearTimeout(e.timerId),(0,i.isErrorResponse)(t.response)){var n=t.response;e.reject(new Error(n.error.message))}else e.resolve(t)}}},{key:"nextRequestId",get:function(){for(var t="widgetapi-".concat(Date.now()),e=0,n=t;this.outboundRequests.has(n);)n="".concat(t,"-").concat(e++);return this.outboundRequests.set(n,null),n}}]),n}(r.EventEmitter);e.PostmessageTransport=v},function(t,e,n){"use strict";var r,i;Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetApiFromWidgetAction=e.WidgetApiToWidgetAction=void 0,e.WidgetApiToWidgetAction=r,function(t){t.SupportedApiVersions="supported_api_versions",t.Capabilities="capabilities",t.NotifyCapabilities="notify_capabilities",t.TakeScreenshot="screenshot",t.UpdateVisibility="visibility",t.OpenIDCredentials="openid_credentials",t.WidgetConfig="widget_config",t.CloseModalWidget="close_modal",t.ButtonClicked="button_clicked",t.SendEvent="send_event"}(r||(e.WidgetApiToWidgetAction=r={})),e.WidgetApiFromWidgetAction=i,function(t){t.SupportedApiVersions="supported_api_versions",t.ContentLoaded="content_loaded",t.SendSticker="m.sticker",t.UpdateAlwaysOnScreen="set_always_on_screen",t.GetOpenIDCredentials="get_openid",t.CloseModalWidget="close_modal",t.OpenModalWidget="open_modal",t.SetModalButtonEnabled="set_button_enabled",t.SendEvent="send_event",t.MSC2931Navigate="org.matrix.msc2931.navigate",t.MSC2974RenegotiateCapabilities="org.matrix.msc2974.request_capabilities"}(i||(e.WidgetApiFromWidgetAction=i={}))},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.OpenIDRequestState=void 0,e.OpenIDRequestState=r,function(t){t.Allowed="allowed",t.Blocked="blocked",t.PendingUserConfirmation="request"}(r||(e.OpenIDRequestState=r={}))},function(t,e,n){"use strict";function r(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==n.return||n.return()}finally{if(u)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var a;Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetEventCapability=e.EventDirection=void 0,e.EventDirection=a,function(t){t.Send="send",t.Receive="receive"}(a||(e.EventDirection=a={}));var o=function(){function t(e,n,r,i,s){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.direction=e,this.eventType=n,this.isState=r,this.keyStr=i,this.raw=s}var e,n,i;return e=t,i=[{key:"forStateEvent",value:function(e,n,r){n=n.replace(/#/g,"\\#"),r=null!=r?"#".concat(r):"";var i="org.matrix.msc2762.".concat(e,".state_event:").concat(n).concat(r);return t.findEventCapabilities([i])[0]}},{key:"forRoomEvent",value:function(e,n){var r="org.matrix.msc2762.".concat(e,".event:").concat(n);return t.findEventCapabilities([r])[0]}},{key:"forRoomMessageEvent",value:function(e,n){n=null==n?"":n;var r="org.matrix.msc2762.".concat(e,".event:m.room.message#").concat(n);return t.findEventCapabilities([r])[0]}},{key:"findEventCapabilities",value:function(e){var n,i=[],s=r(e);try{for(s.s();!(n=s.n()).done;){var o=n.value,u=null,h=void 0,c=!1;if(o.startsWith("org.matrix.msc2762.send.")?o.startsWith("org.matrix.msc2762.send.event:")?(u=a.Send,h=o.substring("org.matrix.msc2762.send.event:".length)):o.startsWith("org.matrix.msc2762.send.state_event:")&&(u=a.Send,c=!0,h=o.substring("org.matrix.msc2762.send.state_event:".length)):o.startsWith("org.matrix.msc2762.receive.")&&(o.startsWith("org.matrix.msc2762.receive.event:")?(u=a.Receive,h=o.substring("org.matrix.msc2762.receive.event:".length)):o.startsWith("org.matrix.msc2762.receive.state_event:")&&(u=a.Receive,c=!0,h=o.substring("org.matrix.msc2762.receive.state_event:".length))),null!==u){var l=h.startsWith("m.room.message#")||c,f=null;if(h.includes("#")&&l){var d=h.split("#"),g=d.findIndex((function(t){return!t.endsWith("\\")}));h=d.slice(0,g+1).map((function(t){return t.endsWith("\\")?t.substring(0,t.length-1):t})).join("#"),f=d.slice(g+1).join("#")}i.push(new t(u,h,c,f,o))}}}catch(t){s.e(t)}finally{s.f()}return i}}],(n=[{key:"matchesAsStateEvent",value:function(t,e){return!!this.isState&&this.eventType===t&&(null===this.keyStr||this.keyStr===e)}},{key:"matchesAsRoomEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return!this.isState&&this.eventType===t&&("m.room.message"!==this.eventType||null===this.keyStr||this.keyStr===e)}}])&&s(e.prototype,n),i&&s(e,i),t}();e.WidgetEventCapability=o},function(t,e,n){"use strict";let r;n.d(e,"a",(function(){return r})),function(t){t.ClientReady="im.vector.ready",t.HangupCall="im.vector.hangup",t.OpenIntegrationManager="integration_manager_open",t.ViewRoom="io.element.view_room"}(r||(r={}))},function(t,e,n){"use strict";function r(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,n,s){e=e||"&",n=n||"=";var a={};if("string"!=typeof t||0===t.length)return a;var o=/\+/g;t=t.split(e);var u=1e3;s&&"number"==typeof s.maxKeys&&(u=s.maxKeys);var h=t.length;u>0&&h>u&&(h=u);for(var c=0;c<h;++c){var l,f,d,g,p=t[c].replace(o,"%20"),v=p.indexOf(n);v>=0?(l=p.substr(0,v),f=p.substr(v+1)):(l=p,f=""),d=decodeURIComponent(l),g=decodeURIComponent(f),r(a,d)?i(a[d])?a[d].push(g):a[d]=[a[d],g]:a[d]=g}return a};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,n){"use strict";var r=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,n,o){return e=e||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?s(a(t),(function(a){var o=encodeURIComponent(r(a))+n;return i(t[a])?s(t[a],(function(t){return o+encodeURIComponent(r(t))})).join(e):o+encodeURIComponent(r(t[a]))})).join(e):o?encodeURIComponent(r(o))+n+encodeURIComponent(r(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e){if(t.map)return t.map(e);for(var n=[],r=0;r<t.length;r++)n.push(e(t[r],r));return n}var a=Object.keys||function(t){var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.push(n);return e}},,,function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.MatrixWidgetType=void 0,e.MatrixWidgetType=r,function(t){t.Custom="m.custom",t.JitsiMeet="m.jitsi",t.Stickerpicker="m.stickerpicker"}(r||(e.MatrixWidgetType=r={}))},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.BuiltInModalButtonID=void 0,e.BuiltInModalButtonID=r,function(t){t.Close="m.close"}(r||(e.BuiltInModalButtonID=r={}))},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.VideoConferenceCapabilities=e.StickerpickerCapabilities=e.MatrixCapabilities=void 0,e.MatrixCapabilities=r,function(t){t.Screenshots="m.capability.screenshot",t.StickerSending="m.sticker",t.AlwaysOnScreen="m.always_on_screen",t.MSC2931Navigate="org.matrix.msc2931.navigate"}(r||(e.MatrixCapabilities=r={}));var i=[r.StickerSending];e.StickerpickerCapabilities=i;var s=[r.AlwaysOnScreen];e.VideoConferenceCapabilities=s},function(t,e,n){"use strict";function r(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,s=function(){};return{s:s,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return o=t.done,t},e:function(t){u=!0,a=t},f:function(){try{o||null==n.return||n.return()}finally{if(u)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}Object.defineProperty(e,"__esModule",{value:!0}),e.SimpleObservable=void 0;var a=function(){function t(e){var n,r,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),i=[],(r="listeners")in(n=this)?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,e&&this.listeners.push(e)}var e,n,i;return e=t,(n=[{key:"onUpdate",value:function(t){this.listeners.push(t)}},{key:"update",value:function(t){var e,n=r(this.listeners);try{for(n.s();!(e=n.n()).done;)(0,e.value)(t)}catch(t){n.e(t)}finally{n.f()}}},{key:"close",value:function(){this.listeners=[]}}])&&s(e.prototype,n),i&&s(e,i),t}();e.SimpleObservable=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isValidUrl=function(t){if(!t)return!1;try{var e=new URL(t);return"http"===e.protocol||"https"===e.protocol}catch(t){if(t instanceof TypeError)return!1;throw t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertPresent=function(t,e){if(!t[e])throw new Error("".concat(e," is required"))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Widget=void 0;var r=n(23),i=n(3);function s(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var a=function(){function t(e){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.definition=e,!this.definition)throw new Error("Definition is required");(0,r.assertPresent)(e,"id"),(0,r.assertPresent)(e,"creatorUserId"),(0,r.assertPresent)(e,"type"),(0,r.assertPresent)(e,"url")}var e,n,a;return e=t,(n=[{key:"getCompleteUrl",value:function(t){return(0,i.runTemplate)(this.templateUrl,this.definition,t)}},{key:"creatorUserId",get:function(){return this.definition.creatorUserId}},{key:"type",get:function(){return this.definition.type}},{key:"id",get:function(){return this.definition.id}},{key:"name",get:function(){return this.definition.name||null}},{key:"title",get:function(){return this.rawData.title||null}},{key:"templateUrl",get:function(){return this.definition.url}},{key:"origin",get:function(){return new URL(this.templateUrl).origin}},{key:"waitForIframeLoad",get:function(){return!1!==this.definition.waitForIframeLoad&&(this.definition.waitForIframeLoad,!0)}},{key:"rawData",get:function(){return this.definition.data||{}}}])&&s(e.prototype,n),a&&s(e,a),t}();e.Widget=a},,,,,,function(t,e,n){(function(t){var n={userAgent:!1},r={};if(void 0===i)var i={};i.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var i=function(){};if(i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var s;for(s in r)t.prototype[s]=r[s];var a=function(){},o=["toString","valueOf"];try{/MSIE/.test(n.userAgent)&&(a=function(t,e){for(s=0;s<o.length;s+=1){var n=o[s],r=e[n];"function"==typeof r&&r!=Object.prototype[n]&&(t[n]=r)}})}catch(t){}a(t.prototype,r)}}};var s,a,o,u,h,c,l,f,d,g,p,v=v||(s=Math,o=(a={}).lib={},u=o.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var n=new t;return e&&n.mixIn(e),n.hasOwnProperty("init")||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),h=o.WordArray=u.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||l).stringify(this)},concat:function(t){var e=this.words,n=t.words,r=this.sigBytes,i=t.sigBytes;if(this.clamp(),r%4)for(var s=0;s<i;s++){var a=n[s>>>2]>>>24-s%4*8&255;e[r+s>>>2]|=a<<24-(r+s)%4*8}else for(s=0;s<i;s+=4)e[r+s>>>2]=n[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=u.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],n=0;n<t;n+=4)e.push(4294967296*s.random()|0);return new h.init(e,t)}}),c=a.enc={},l=c.Hex={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],i=0;i<n;i++){var s=e[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r+=2)n[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new h.init(n,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,r=[],i=0;i<n;i++){var s=e[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(s))}return r.join("")},parse:function(t){for(var e=t.length,n=[],r=0;r<e;r++)n[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new h.init(n,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=o.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new h.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,n=e.words,r=e.sigBytes,i=this.blockSize,a=r/(4*i),o=(a=t?s.ceil(a):s.max((0|a)-this._minBufferSize,0))*i,u=s.min(4*o,r);if(o){for(var c=0;c<o;c+=i)this._doProcessBlock(n,c);var l=n.splice(0,o);e.sigBytes-=u}return new h.init(l,u)},clone:function(){var t=u.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),o.Hasher=g.extend({cfg:u.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,n){return new t.init(n).finalize(e)}},_createHmacHelper:function(t){return function(e,n){return new p.HMAC.init(t,n).finalize(e)}}}),p=a.algo={},a);!function(t){var e,n=(e=v).lib,r=n.Base,i=n.WordArray;(e=e.x64={}).Word=r.extend({init:function(t,e){this.high=t,this.low=e}}),e.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,n=[],r=0;r<e;r++){var s=t[r];n.push(s.high),n.push(s.low)}return i.create(n,this.sigBytes)},clone:function(){for(var t=r.clone.call(this),e=t.words=this.words.slice(0),n=e.length,i=0;i<n;i++)e[i]=e[i].clone();return t}})}(),v.lib.Cipher||function(t){var e=(d=v).lib,n=e.Base,r=e.WordArray,i=e.BufferedBlockAlgorithm,s=d.enc.Base64,a=d.algo.EvpKDF,o=e.Cipher=i.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,n){this.cfg=this.cfg.extend(n),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,n,r){return("string"==typeof n?g:f).encrypt(t,e,n,r)},decrypt:function(e,n,r){return("string"==typeof n?g:f).decrypt(t,e,n,r)}}}});e.StreamCipher=o.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var u=d.mode={},h=function(t,e,n){var r=this._iv;r?this._iv=void 0:r=this._prevBlock;for(var i=0;i<n;i++)t[e+i]^=r[i]},c=(e.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();c.Encryptor=c.extend({processBlock:function(t,e){var n=this._cipher,r=n.blockSize;h.call(this,t,e,r),n.encryptBlock(t,e),this._prevBlock=t.slice(e,e+r)}}),c.Decryptor=c.extend({processBlock:function(t,e){var n=this._cipher,r=n.blockSize,i=t.slice(e,e+r);n.decryptBlock(t,e),h.call(this,t,e,r),this._prevBlock=i}}),u=u.CBC=c,c=(d.pad={}).Pkcs7={pad:function(t,e){for(var n,i=(n=(n=4*e)-t.sigBytes%n)<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);n=r.create(s,n),t.concat(n)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},e.BlockCipher=o.extend({cfg:o.cfg.extend({mode:u,padding:c}),reset:function(){o.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var n=e.createEncryptor;else n=e.createDecryptor,this._minBufferSize=1;this._mode=n.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(u=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var n=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:n})}},e.SerializableCipher=n.extend({cfg:n.extend({format:u}),encrypt:function(t,e,n,r){r=this.cfg.extend(r);var i=t.createEncryptor(n,r);return e=i.finalize(e),i=i.cfg,l.create({ciphertext:e,key:n,iv:i.iv,algorithm:t,mode:i.mode,padding:i.padding,blockSize:t.blockSize,formatter:r.format})},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),t.createDecryptor(n,r).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,n,i){return i||(i=r.random(8)),t=a.create({keySize:e+n}).compute(t,i),n=r.create(t.words.slice(e),4*n),t.sigBytes=4*e,l.create({key:t,iv:n,salt:i})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,n,r){return n=(r=this.cfg.extend(r)).kdf.execute(n,t.keySize,t.ivSize),r.iv=n.iv,(t=f.encrypt.call(this,t,e,n.key,r)).mixIn(n),t},decrypt:function(t,e,n,r){return r=this.cfg.extend(r),e=this._parse(e,r.format),n=r.kdf.execute(n,t.keySize,t.ivSize,e.salt),r.iv=n.iv,f.decrypt.call(this,t,e,n.key,r)}})}(),function(){for(var t=v,e=t.lib.BlockCipher,n=t.algo,r=[],i=[],s=[],a=[],o=[],u=[],h=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,y=0;for(g=0;256>g;g++){var m=(m=y^y<<1^y<<2^y<<3^y<<4)>>>8^255&m^99;r[p]=m,i[m]=p;var x=d[p],S=d[x],b=d[S],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,a[p]=E<<16|E>>>16,o[p]=E<<8|E>>>24,u[p]=E,E=16843009*b^65537*S^257*x^16843008*p,h[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=x^d[d[d[b^x]]],y^=d[d[y]]):p=y=1}var w=[0,1,2,4,8,16,32,64,128,27,54];n=n.AES=e.extend({_doReset:function(){for(var t=(n=this._key).words,e=n.sigBytes/4,n=4*((this._nRounds=e+6)+1),i=this._keySchedule=[],s=0;s<n;s++)if(s<e)i[s]=t[s];else{var a=i[s-1];s%e?6<e&&4==s%e&&(a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=r[(a=a<<8|a>>>24)>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=w[s/e|0]<<24),i[s]=i[s-e]^a}for(t=this._invKeySchedule=[],e=0;e<n;e++)s=n-e,a=e%4?i[s]:i[s-4],t[e]=4>e||4>=s?a:h[r[a>>>24]]^c[r[a>>>16&255]]^l[r[a>>>8&255]]^f[r[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,o,u,r)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,h,c,l,f,i),n=t[e+1],t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,r,i,s,a,o){for(var u=this._nRounds,h=t[e]^n[0],c=t[e+1]^n[1],l=t[e+2]^n[2],f=t[e+3]^n[3],d=4,g=1;g<u;g++){var p=r[h>>>24]^i[c>>>16&255]^s[l>>>8&255]^a[255&f]^n[d++],v=r[c>>>24]^i[l>>>16&255]^s[f>>>8&255]^a[255&h]^n[d++],y=r[l>>>24]^i[f>>>16&255]^s[h>>>8&255]^a[255&c]^n[d++];f=r[f>>>24]^i[h>>>16&255]^s[c>>>8&255]^a[255&l]^n[d++],h=p,c=v,l=y}p=(o[h>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^n[d++],v=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&h])^n[d++],y=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[h>>>8&255]<<8|o[255&c])^n[d++],f=(o[f>>>24]<<24|o[h>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^n[d++],t[e]=p,t[e+1]=v,t[e+2]=y,t[e+3]=f},keySize:8});t.AES=e._createHelper(n)}(),function(){function t(t,e){var n=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=n,this._lBlock^=n<<t}function e(t,e){var n=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=n,this._rBlock^=n<<t}var n=v,r=(i=n.lib).WordArray,i=i.BlockCipher,s=n.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],u=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],h=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=s.DES=i.extend({_doReset:function(){for(var t=this._key.words,e=[],n=0;56>n;n++){var r=a[n]-1;e[n]=t[r>>>5]>>>31-r%32&1}for(t=this._subKeys=[],r=0;16>r;r++){var i=t[r]=[],s=u[r];for(n=0;24>n;n++)i[n/6|0]|=e[(o[n]-1+s)%28]<<31-n%6,i[4+(n/6|0)]|=e[28+(o[n+24]-1+s)%28]<<31-n%6;for(i[0]=i[0]<<1|i[0]>>>31,n=1;7>n;n++)i[n]>>>=4*(n-1)+3;i[7]=i[7]<<5|i[7]>>>27}for(e=this._invSubKeys=[],n=0;16>n;n++)e[n]=t[15-n]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(n,r,i){this._lBlock=n[r],this._rBlock=n[r+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var a=i[s],o=this._lBlock,u=this._rBlock,l=0,f=0;8>f;f++)l|=h[f][((u^a[f])&c[f])>>>0];this._lBlock=u,this._rBlock=o^l}i=this._lBlock,this._lBlock=this._rBlock,this._rBlock=i,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),n[r]=this._lBlock,n[r+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});n.DES=i._createHelper(l),s=s.TripleDES=i.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(r.create(t.slice(0,2))),this._des2=l.createEncryptor(r.create(t.slice(2,4))),this._des3=l.createEncryptor(r.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),n.TripleDES=i._createHelper(s)}(),function(){var t=v,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,r=this._map;t.clamp(),t=[];for(var i=0;i<n;i+=3)for(var s=(e[i>>>2]>>>24-i%4*8&255)<<16|(e[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|e[i+2>>>2]>>>24-(i+2)%4*8&255,a=0;4>a&&i+.75*a<n;a++)t.push(r.charAt(s>>>6*(3-a)&63));if(e=r.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var n=t.length,r=this._map;(i=r.charAt(64))&&(-1!=(i=t.indexOf(i))&&(n=i));for(var i=[],s=0,a=0;a<n;a++)if(a%4){var o=r.indexOf(t.charAt(a-1))<<a%4*2,u=r.indexOf(t.charAt(a))>>>6-a%4*2;i[s>>>2]|=(o|u)<<24-s%4*8,s++}return e.create(i,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,n,r,i,s,a){return((t=t+(e&n|~e&r)+i+a)<<s|t>>>32-s)+e}function n(t,e,n,r,i,s,a){return((t=t+(e&r|n&~r)+i+a)<<s|t>>>32-s)+e}function r(t,e,n,r,i,s,a){return((t=t+(e^n^r)+i+a)<<s|t>>>32-s)+e}function i(t,e,n,r,i,s,a){return((t=t+(n^(e|~r))+i+a)<<s|t>>>32-s)+e}for(var s=v,a=(u=s.lib).WordArray,o=u.Hasher,u=s.algo,h=[],c=0;64>c;c++)h[c]=4294967296*t.abs(t.sin(c+1))|0;u=u.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var a=0;16>a;a++){var o=t[u=s+a];t[u]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var u=t[s+0],c=(o=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],v=t[s+8],y=t[s+9],m=t[s+10],x=t[s+11],S=t[s+12],b=t[s+13],E=t[s+14],w=t[s+15],F=e(F=a[0],I=a[1],C=a[2],A=a[3],u,7,h[0]),A=e(A,F,I,C,o,12,h[1]),C=e(C,A,F,I,c,17,h[2]),I=e(I,C,A,F,l,22,h[3]);F=e(F,I,C,A,f,7,h[4]),A=e(A,F,I,C,d,12,h[5]),C=e(C,A,F,I,g,17,h[6]),I=e(I,C,A,F,p,22,h[7]),F=e(F,I,C,A,v,7,h[8]),A=e(A,F,I,C,y,12,h[9]),C=e(C,A,F,I,m,17,h[10]),I=e(I,C,A,F,x,22,h[11]),F=e(F,I,C,A,S,7,h[12]),A=e(A,F,I,C,b,12,h[13]),C=e(C,A,F,I,E,17,h[14]),F=n(F,I=e(I,C,A,F,w,22,h[15]),C,A,o,5,h[16]),A=n(A,F,I,C,g,9,h[17]),C=n(C,A,F,I,x,14,h[18]),I=n(I,C,A,F,u,20,h[19]),F=n(F,I,C,A,d,5,h[20]),A=n(A,F,I,C,m,9,h[21]),C=n(C,A,F,I,w,14,h[22]),I=n(I,C,A,F,f,20,h[23]),F=n(F,I,C,A,y,5,h[24]),A=n(A,F,I,C,E,9,h[25]),C=n(C,A,F,I,l,14,h[26]),I=n(I,C,A,F,v,20,h[27]),F=n(F,I,C,A,b,5,h[28]),A=n(A,F,I,C,c,9,h[29]),C=n(C,A,F,I,p,14,h[30]),F=r(F,I=n(I,C,A,F,S,20,h[31]),C,A,d,4,h[32]),A=r(A,F,I,C,v,11,h[33]),C=r(C,A,F,I,x,16,h[34]),I=r(I,C,A,F,E,23,h[35]),F=r(F,I,C,A,o,4,h[36]),A=r(A,F,I,C,f,11,h[37]),C=r(C,A,F,I,p,16,h[38]),I=r(I,C,A,F,m,23,h[39]),F=r(F,I,C,A,b,4,h[40]),A=r(A,F,I,C,u,11,h[41]),C=r(C,A,F,I,l,16,h[42]),I=r(I,C,A,F,g,23,h[43]),F=r(F,I,C,A,y,4,h[44]),A=r(A,F,I,C,S,11,h[45]),C=r(C,A,F,I,w,16,h[46]),F=i(F,I=r(I,C,A,F,c,23,h[47]),C,A,u,6,h[48]),A=i(A,F,I,C,p,10,h[49]),C=i(C,A,F,I,E,15,h[50]),I=i(I,C,A,F,d,21,h[51]),F=i(F,I,C,A,S,6,h[52]),A=i(A,F,I,C,l,10,h[53]),C=i(C,A,F,I,m,15,h[54]),I=i(I,C,A,F,o,21,h[55]),F=i(F,I,C,A,v,6,h[56]),A=i(A,F,I,C,w,10,h[57]),C=i(C,A,F,I,g,15,h[58]),I=i(I,C,A,F,b,21,h[59]),F=i(F,I,C,A,f,6,h[60]),A=i(A,F,I,C,x,10,h[61]),C=i(C,A,F,I,c,15,h[62]),I=i(I,C,A,F,y,21,h[63]);a[0]=a[0]+F|0,a[1]=a[1]+I|0,a[2]=a[2]+C|0,a[3]=a[3]+A|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;n[i>>>5]|=128<<24-i%32;var s=t.floor(r/4294967296);for(n[15+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),n[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(n.length+1),this._process(),n=(e=this._hash).words,r=0;4>r;r++)i=n[r],n[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=o._createHelper(u),s.HmacMD5=o._createHmacHelper(u)}(Math),function(){var t=v,e=(i=t.lib).WordArray,n=i.Hasher,r=[],i=t.algo.SHA1=n.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,i=n[0],s=n[1],a=n[2],o=n[3],u=n[4],h=0;80>h;h++){if(16>h)r[h]=0|t[e+h];else{var c=r[h-3]^r[h-8]^r[h-14]^r[h-16];r[h]=c<<1|c>>>31}c=(i<<5|i>>>27)+u+r[h],c=20>h?c+(1518500249+(s&a|~s&o)):40>h?c+(1859775393+(s^a^o)):60>h?c+((s&a|s&o|a&o)-1894007588):c+((s^a^o)-899497514),u=o,o=a,a=s<<30|s>>>2,s=i,i=c}n[0]=n[0]+i|0,n[1]=n[1]+s|0,n[2]=n[2]+a|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),e[15+(r+64>>>9<<4)]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=n._createHelper(i),t.HmacSHA1=n._createHmacHelper(i)}(),function(t){for(var e=v,n=(i=e.lib).WordArray,r=i.Hasher,i=e.algo,s=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},u=2,h=0;64>h;){var c;t:{c=u;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>h&&(s[h]=o(t.pow(u,.5))),a[h]=o(t.pow(u,1/3)),h++),u++}var d=[];i=i.SHA256=r.extend({_doReset:function(){this._hash=new n.init(s.slice(0))},_doProcessBlock:function(t,e){for(var n=this._hash.words,r=n[0],i=n[1],s=n[2],o=n[3],u=n[4],h=n[5],c=n[6],l=n[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&h^~u&c)+a[f]+d[f],p=((r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22))+(r&i^r&s^i&s),l=c,c=h,h=u,u=o+g|0,o=s,s=i,i=r,r=g+p|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+s|0,n[3]=n[3]+o|0,n[4]=n[4]+u|0,n[5]=n[5]+h|0,n[6]=n[6]+c|0,n[7]=n[7]+l|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[14+(i+64>>>9<<4)]=t.floor(r/4294967296),n[15+(i+64>>>9<<4)]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=r._createHelper(i),e.HmacSHA256=r._createHmacHelper(i)}(Math),function(){var t=v,e=t.lib.WordArray,n=(r=t.algo).SHA256,r=r.SHA224=n.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=n._createHelper(r),t.HmacSHA224=n._createHmacHelper(r)}(),function(){function t(){return r.create.apply(r,arguments)}for(var e=v,n=e.lib.Hasher,r=(s=e.x64).Word,i=s.WordArray,s=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],u=0;80>u;u++)o[u]=t();s=s.SHA512=n.extend({_doReset:function(){this._hash=new i.init([new r.init(1779033703,4089235720),new r.init(3144134277,2227873595),new r.init(1013904242,4271175723),new r.init(2773480762,1595750129),new r.init(1359893119,2917565137),new r.init(2600822924,725511199),new r.init(528734635,4215389547),new r.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var n=(l=this._hash.words)[0],r=l[1],i=l[2],s=l[3],u=l[4],h=l[5],c=l[6],l=l[7],f=n.high,d=n.low,g=r.high,p=r.low,v=i.high,y=i.low,m=s.high,x=s.low,S=u.high,b=u.low,E=h.high,w=h.low,F=c.high,A=c.low,C=l.high,I=l.low,P=f,D=d,R=g,T=p,O=v,B=y,H=m,N=x,j=S,_=b,k=E,V=w,L=F,M=A,K=C,q=I,U=0;80>U;U++){var W=o[U];if(16>U)var z=W.high=0|t[e+2*U],G=W.low=0|t[e+2*U+1];else{z=((G=(z=o[U-15]).high)>>>1|(Y=z.low)<<31)^(G>>>8|Y<<24)^G>>>7;var Y=(Y>>>1|G<<31)^(Y>>>8|G<<24)^(Y>>>7|G<<25),J=((G=(J=o[U-2]).high)>>>19|(X=J.low)<<13)^(G<<3|X>>>29)^G>>>6,X=(X>>>19|G<<13)^(X<<3|G>>>29)^(X>>>6|G<<26),$=(G=o[U-7]).high,Z=(Q=o[U-16]).high,Q=Q.low;z=(z=(z=z+$+((G=Y+G.low)>>>0<Y>>>0?1:0))+J+((G=G+X)>>>0<X>>>0?1:0))+Z+((G=G+Q)>>>0<Q>>>0?1:0);W.high=z,W.low=G}$=j&k^~j&L,Q=_&V^~_&M,W=P&R^P&O^R&O;var tt=D&T^D&B^T&B,et=(Y=(P>>>28|D<<4)^(P<<30|D>>>2)^(P<<25|D>>>7),J=(D>>>28|P<<4)^(D<<30|P>>>2)^(D<<25|P>>>7),(X=a[U]).high),nt=X.low;Z=K+((j>>>14|_<<18)^(j>>>18|_<<14)^(j<<23|_>>>9))+((X=q+((_>>>14|j<<18)^(_>>>18|j<<14)^(_<<23|j>>>9)))>>>0<q>>>0?1:0),K=L,q=M,L=k,M=V,k=j,V=_,j=H+(Z=(Z=(Z=Z+$+((X=X+Q)>>>0<Q>>>0?1:0))+et+((X=X+nt)>>>0<nt>>>0?1:0))+z+((X=X+G)>>>0<G>>>0?1:0))+((_=N+X|0)>>>0<N>>>0?1:0)|0,H=O,N=B,O=R,B=T,R=P,T=D,P=Z+(W=Y+W+((G=J+tt)>>>0<J>>>0?1:0))+((D=X+G|0)>>>0<X>>>0?1:0)|0}d=n.low=d+D,n.high=f+P+(d>>>0<D>>>0?1:0),p=r.low=p+T,r.high=g+R+(p>>>0<T>>>0?1:0),y=i.low=y+B,i.high=v+O+(y>>>0<B>>>0?1:0),x=s.low=x+N,s.high=m+H+(x>>>0<N>>>0?1:0),b=u.low=b+_,u.high=S+j+(b>>>0<_>>>0?1:0),w=h.low=w+V,h.high=E+k+(w>>>0<V>>>0?1:0),A=c.low=A+M,c.high=F+L+(A>>>0<M>>>0?1:0),I=l.low=I+q,l.high=C+K+(I>>>0<q>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;return e[r>>>5]|=128<<24-r%32,e[30+(r+128>>>10<<5)]=Math.floor(n/4294967296),e[31+(r+128>>>10<<5)]=n,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=n._createHelper(s),e.HmacSHA512=n._createHmacHelper(s)}(),function(){var t=v,e=(i=t.x64).Word,n=i.WordArray,r=(i=t.algo).SHA512,i=i.SHA384=r.extend({_doReset:function(){this._hash=new n.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=r._createHelper(i),t.HmacSHA384=r._createHmacHelper(i)}(),function(){var t=v,e=(r=t.lib).WordArray,n=r.Hasher,r=t.algo,i=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),u=e.create([0,1518500249,1859775393,2400959708,2840853838]),h=e.create([1352829926,1548603684,1836072691,2053994217,0]);r=r.RIPEMD160=n.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=0;16>n;n++){var r=t[S=e+n];t[S]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var c,l,f,d,g,p,v,y,m,x,S=this._hash.words,b=(r=u.words,h.words),E=i.words,w=s.words,F=a.words,A=o.words;p=c=S[0],v=l=S[1],y=f=S[2],m=d=S[3],x=g=S[4];var C;for(n=0;80>n;n+=1)C=c+t[e+E[n]]|0,C=16>n?C+((l^f^d)+r[0]):32>n?C+((l&f|~l&d)+r[1]):48>n?C+(((l|~f)^d)+r[2]):64>n?C+((l&d|f&~d)+r[3]):C+((l^(f|~d))+r[4]),C=(C=(C|=0)<<F[n]|C>>>32-F[n])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=C,C=p+t[e+w[n]]|0,C=16>n?C+((v^(y|~m))+b[0]):32>n?C+((v&m|y&~m)+b[1]):48>n?C+(((v|~y)^m)+b[2]):64>n?C+((v&y|~v&m)+b[3]):C+((v^y^m)+b[4]),C=(C=(C|=0)<<A[n]|C>>>32-A[n])+x|0,p=x,x=m,m=y<<10|y>>>22,y=v,v=C;C=S[1]+f+m|0,S[1]=S[2]+d+x|0,S[2]=S[3]+g+p|0,S[3]=S[4]+c+v|0,S[4]=S[0]+l+y|0,S[0]=C},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;for(e[r>>>5]|=128<<24-r%32,e[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,n=0;5>n;n++)r=e[n],e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return t},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=n._createHelper(r),t.HmacRIPEMD160=n._createHmacHelper(r)}(Math),function(){var t=v,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=e.parse(n));var r=t.blockSize,i=4*r;n.sigBytes>i&&(n=t.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),a=this._iKey=n.clone(),o=s.words,u=a.words,h=0;h<r;h++)o[h]^=1549556828,u[h]^=909522486;s.sigBytes=a.sigBytes=i,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=v,n=(t=e.lib).Base,r=t.WordArray,i=(t=e.algo).HMAC,s=t.PBKDF2=n.extend({cfg:n.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var n=this.cfg,s=i.create(n.hasher,t),a=r.create(),o=r.create([1]),u=a.words,h=o.words,c=n.keySize;for(n=n.iterations;u.length<c;){var l=s.update(e).finalize(o);s.reset();for(var f=l.words,d=f.length,g=l,p=1;p<n;p++){g=s.finalize(g),s.reset();for(var v=g.words,y=0;y<d;y++)f[y]^=v[y]}a.concat(l),h[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(t,e,n){return s.create(n).compute(t,e)}}();var y,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function x(t){var e,n,r="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),r+=m.charAt(n>>6)+m.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),r+=m.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),r+=m.charAt(n>>2)+m.charAt((3&n)<<4)),"=";(3&r.length)>0;)r+="=";return r}function S(t){var e,n,r,i="",s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(r=m.indexOf(t.charAt(e)))<0||(0==s?(i+=I(r>>2),n=3&r,s=1):1==s?(i+=I(n<<2|r>>4),n=15&r,s=2):2==s?(i+=I(n),i+=I(r>>2),n=3&r,s=3):(i+=I(n<<2|r>>4),i+=I(15&r),s=0));return 1==s&&(i+=I(n<<2)),i}function b(t){var e,n=S(t),r=new Array;for(e=0;2*e<n.length;++e)r[e]=parseInt(n.substring(2*e,2*e+2),16);return r}function E(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function w(){return new E(null)}"Microsoft Internet Explorer"==n.appName?(E.prototype.am=function(t,e,n,r,i,s){for(var a=32767&e,o=e>>15;--s>=0;){var u=32767&this[t],h=this[t++]>>15,c=o*u+h*a;i=((u=a*u+((32767&c)<<15)+n[r]+(1073741823&i))>>>30)+(c>>>15)+o*h+(i>>>30),n[r++]=1073741823&u}return i},y=30):"Netscape"!=n.appName?(E.prototype.am=function(t,e,n,r,i,s){for(;--s>=0;){var a=e*this[t++]+n[r]+i;i=Math.floor(a/67108864),n[r++]=67108863&a}return i},y=26):(E.prototype.am=function(t,e,n,r,i,s){for(var a=16383&e,o=e>>14;--s>=0;){var u=16383&this[t],h=this[t++]>>14,c=o*u+h*a;i=((u=a*u+((16383&c)<<14)+n[r]+i)>>28)+(c>>14)+o*h,n[r++]=268435455&u}return i},y=28),E.prototype.DB=y,E.prototype.DM=(1<<y)-1,E.prototype.DV=1<<y;E.prototype.FV=Math.pow(2,52),E.prototype.F1=52-y,E.prototype.F2=2*y-52;var F,A,C=new Array;for(F="0".charCodeAt(0),A=0;A<=9;++A)C[F++]=A;for(F="a".charCodeAt(0),A=10;A<36;++A)C[F++]=A;for(F="A".charCodeAt(0),A=10;A<36;++A)C[F++]=A;function I(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function P(t,e){var n=C[t.charCodeAt(e)];return null==n?-1:n}function D(t){var e=w();return e.fromInt(t),e}function R(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}function T(t){this.m=t}function O(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function B(t,e){return t&e}function H(t,e){return t|e}function N(t,e){return t^e}function j(t,e){return t&~e}function _(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function k(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function V(){}function L(t){return t}function M(t){this.r2=w(),this.q3=w(),E.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}T.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},T.prototype.revert=function(t){return t},T.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},T.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},O.prototype.convert=function(t){var e=w();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(E.ZERO)>0&&this.m.subTo(e,e),e},O.prototype.revert=function(t){var e=w();return t.copyTo(e),this.reduce(e),e},O.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},O.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},O.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},E.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},E.prototype.fromString=function(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var r=t.length,i=!1,s=0;--r>=0;){var a=8==n?255&t[r]:P(t,r);a<0?"-"==t.charAt(r)&&(i=!0):(i=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&E.ZERO.subTo(this,this)},E.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},E.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},E.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},E.prototype.lShiftTo=function(t,e){var n,r=t%this.DB,i=this.DB-r,s=(1<<i)-1,a=Math.floor(t/this.DB),o=this.s<<r&this.DM;for(n=this.t-1;n>=0;--n)e[n+a+1]=this[n]>>i|o,o=(this[n]&s)<<r;for(n=a-1;n>=0;--n)e[n]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},E.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,i=this.DB-r,s=(1<<r)-1;e[0]=this[n]>>r;for(var a=n+1;a<this.t;++a)e[a-n-1]|=(this[a]&s)<<i,e[a-n]=this[a]>>r;r>0&&(e[this.t-n-1]|=(this.s&s)<<i),e.t=this.t-n,e.clamp()}},E.prototype.subTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()},E.prototype.multiplyTo=function(t,e){var n=this.abs(),r=t.abs(),i=n.t;for(e.t=i+r.t;--i>=0;)e[i]=0;for(i=0;i<r.t;++i)e[i+n.t]=n.am(0,r[i],e,i,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&E.ZERO.subTo(e,e)},E.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},E.prototype.divRemTo=function(t,e,n){var r=t.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=w());var s=w(),a=this.s,o=t.s,u=this.DB-R(r[r.t-1]);u>0?(r.lShiftTo(u,s),i.lShiftTo(u,n)):(r.copyTo(s),i.copyTo(n));var h=s.t,c=s[h-1];if(0!=c){var l=c*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),f=this.FV/l,d=(1<<this.F1)/l,g=1<<this.F2,p=n.t,v=p-h,y=null==e?w():e;for(s.dlShiftTo(v,y),n.compareTo(y)>=0&&(n[n.t++]=1,n.subTo(y,n)),E.ONE.dlShiftTo(h,y),y.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--v>=0;){var m=n[--p]==c?this.DM:Math.floor(n[p]*f+(n[p-1]+g)*d);if((n[p]+=s.am(0,m,n,v,0,h))<m)for(s.dlShiftTo(v,y),n.subTo(y,n);n[p]<--m;)n.subTo(y,n)}null!=e&&(n.drShiftTo(h,e),a!=o&&E.ZERO.subTo(e,e)),n.t=h,n.clamp(),u>0&&n.rShiftTo(u,n),a<0&&E.ZERO.subTo(n,n)}}},E.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},E.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},E.prototype.exp=function(t,e){if(t>4294967295||t<1)return E.ONE;var n=w(),r=w(),i=e.convert(this),s=R(t)-1;for(i.copyTo(n);--s>=0;)if(e.sqrTo(n,r),(t&1<<s)>0)e.mulTo(r,i,n);else{var a=n;n=r,r=a}return e.revert(n)},E.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var n,r=(1<<e)-1,i=!1,s="",a=this.t,o=this.DB-a*this.DB%e;if(a-- >0)for(o<this.DB&&(n=this[a]>>o)>0&&(i=!0,s=I(n));a>=0;)o<e?(n=(this[a]&(1<<o)-1)<<e-o,n|=this[--a]>>(o+=this.DB-e)):(n=this[a]>>(o-=e)&r,o<=0&&(o+=this.DB,--a)),n>0&&(i=!0),i&&(s+=I(n));return i?s:"0"},E.prototype.negate=function(){var t=w();return E.ZERO.subTo(this,t),t},E.prototype.abs=function(){return this.s<0?this.negate():this},E.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0},E.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},E.prototype.mod=function(t){var e=w();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(E.ZERO)>0&&t.subTo(e,e),e},E.prototype.modPowInt=function(t,e){var n;return n=t<256||e.isEven()?new T(e):new O(e),this.exp(t,n)},E.ZERO=D(0),E.ONE=D(1),V.prototype.convert=L,V.prototype.revert=L,V.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},V.prototype.sqrTo=function(t,e){t.squareTo(e)},M.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=w();return t.copyTo(e),this.reduce(e),e},M.prototype.revert=function(t){return t},M.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},M.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},M.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var K=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/K[K.length-1];function U(){this.i=0,this.j=0,this.S=new Array}E.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},E.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=D(n),i=w(),s=w(),a="";for(this.divRemTo(r,i,s);i.signum()>0;)a=(n+s.intValue()).toString(t).substr(1)+a,i.divRemTo(r,i,s);return s.intValue().toString(t)+a},E.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),r=Math.pow(e,n),i=!1,s=0,a=0,o=0;o<t.length;++o){var u=P(t,o);u<0?"-"==t.charAt(o)&&0==this.signum()&&(i=!0):(a=e*a+u,++s>=n&&(this.dMultiply(r),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),i&&E.ZERO.subTo(this,this)},E.prototype.fromNumber=function(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(E.ONE.shiftLeft(t-1),H,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(E.ONE.shiftLeft(t-1),this);else{var r=new Array,i=7&t;r.length=1+(t>>3),e.nextBytes(r),i>0?r[0]&=(1<<i)-1:r[0]=0,this.fromString(r,256)}},E.prototype.bitwiseTo=function(t,e,n){var r,i,s=Math.min(t.t,this.t);for(r=0;r<s;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(i=t.s&this.DM,r=s;r<this.t;++r)n[r]=e(this[r],i);n.t=this.t}else{for(i=this.s&this.DM,r=s;r<t.t;++r)n[r]=e(i,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},E.prototype.changeBit=function(t,e){var n=E.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n},E.prototype.addTo=function(t,e){for(var n=0,r=0,i=Math.min(t.t,this.t);n<i;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()},E.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},E.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},E.prototype.multiplyLowerTo=function(t,e,n){var r,i=Math.min(this.t+t.t,e);for(n.s=0,n.t=i;i>0;)n[--i]=0;for(r=n.t-this.t;i<r;++i)n[i+this.t]=this.am(0,t[i],n,i,0,this.t);for(r=Math.min(t.t,e);i<r;++i)this.am(0,t[i],n,i,0,e-i);n.clamp()},E.prototype.multiplyUpperTo=function(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)},E.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n},E.prototype.millerRabin=function(t){var e=this.subtract(E.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);(t=t+1>>1)>K.length&&(t=K.length);for(var i=w(),s=0;s<t;++s){i.fromInt(K[Math.floor(Math.random()*K.length)]);var a=i.modPow(r,this);if(0!=a.compareTo(E.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<n&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(E.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},E.prototype.clone=function(){var t=w();return this.copyTo(t),t},E.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},E.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},E.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},E.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},E.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var n,r=this.DB-t*this.DB%8,i=0;if(t-- >0)for(r<this.DB&&(n=this[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this[t]&(1<<r)-1)<<8-r,n|=this[--t]>>(r+=this.DB-8)):(n=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&n)&&(n|=-256),0==i&&(128&this.s)!=(128&n)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e},E.prototype.equals=function(t){return 0==this.compareTo(t)},E.prototype.min=function(t){return this.compareTo(t)<0?this:t},E.prototype.max=function(t){return this.compareTo(t)>0?this:t},E.prototype.and=function(t){var e=w();return this.bitwiseTo(t,B,e),e},E.prototype.or=function(t){var e=w();return this.bitwiseTo(t,H,e),e},E.prototype.xor=function(t){var e=w();return this.bitwiseTo(t,N,e),e},E.prototype.andNot=function(t){var e=w();return this.bitwiseTo(t,j,e),e},E.prototype.not=function(){for(var t=w(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},E.prototype.shiftLeft=function(t){var e=w();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},E.prototype.shiftRight=function(t){var e=w();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},E.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+_(this[t]);return this.s<0?this.t*this.DB:-1},E.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=k(this[n]^e);return t},E.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},E.prototype.setBit=function(t){return this.changeBit(t,H)},E.prototype.clearBit=function(t){return this.changeBit(t,j)},E.prototype.flipBit=function(t){return this.changeBit(t,N)},E.prototype.add=function(t){var e=w();return this.addTo(t,e),e},E.prototype.subtract=function(t){var e=w();return this.subTo(t,e),e},E.prototype.multiply=function(t){var e=w();return this.multiplyTo(t,e),e},E.prototype.divide=function(t){var e=w();return this.divRemTo(t,e,null),e},E.prototype.remainder=function(t){var e=w();return this.divRemTo(t,null,e),e},E.prototype.divideAndRemainder=function(t){var e=w(),n=w();return this.divRemTo(t,e,n),new Array(e,n)},E.prototype.modPow=function(t,e){var n,r,i=t.bitLength(),s=D(1);if(i<=0)return s;n=i<18?1:i<48?3:i<144?4:i<768?5:6,r=i<8?new T(e):e.isEven()?new M(e):new O(e);var a=new Array,o=3,u=n-1,h=(1<<n)-1;if(a[1]=r.convert(this),n>1){var c=w();for(r.sqrTo(a[1],c);o<=h;)a[o]=w(),r.mulTo(c,a[o-2],a[o]),o+=2}var l,f,d=t.t-1,g=!0,p=w();for(i=R(t[d])-1;d>=0;){for(i>=u?l=t[d]>>i-u&h:(l=(t[d]&(1<<i+1)-1)<<u-i,d>0&&(l|=t[d-1]>>this.DB+i-u)),o=n;0==(1&l);)l>>=1,--o;if((i-=o)<0&&(i+=this.DB,--d),g)a[l].copyTo(s),g=!1;else{for(;o>1;)r.sqrTo(s,p),r.sqrTo(p,s),o-=2;o>0?r.sqrTo(s,p):(f=s,s=p,p=f),r.mulTo(p,a[l],s)}for(;d>=0&&0==(t[d]&1<<i);)r.sqrTo(s,p),f=s,s=p,p=f,--i<0&&(i=this.DB-1,--d)}return r.revert(s)},E.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return E.ZERO;for(var n=t.clone(),r=this.clone(),i=D(1),s=D(0),a=D(0),o=D(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(i.isEven()&&s.isEven()||(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),e?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(t,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);n.compareTo(r)>=0?(n.subTo(r,n),e&&i.subTo(a,i),s.subTo(o,s)):(r.subTo(n,r),e&&a.subTo(i,a),o.subTo(s,o))}return 0!=r.compareTo(E.ONE)?E.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},E.prototype.pow=function(t){return this.exp(t,new V)},E.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var i=e.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),n.rShiftTo(s,n));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return s>0&&n.lShiftTo(s,n),n},E.prototype.isProbablePrime=function(t){var e,n=this.abs();if(1==n.t&&n[0]<=K[K.length-1]){for(e=0;e<K.length;++e)if(n[0]==K[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<K.length;){for(var r=K[e],i=e+1;i<K.length&&r<q;)r*=K[i++];for(r=n.modInt(r);e<i;)if(r%K[e++]==0)return!1}return n.millerRabin(t)},E.prototype.square=function(){var t=w();return this.squareTo(t),t},U.prototype.init=function(t){var e,n,r;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[n],this.S[n]=r;this.i=0,this.j=0},U.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var W,z,G;function Y(){!function(t){z[G++]^=255&t,z[G++]^=t>>8&255,z[G++]^=t>>16&255,z[G++]^=t>>24&255,G>=256&&(G-=256)}((new Date).getTime())}if(null==z){var J;if(z=new Array,G=0,void 0!==r&&(void 0!==r.crypto||void 0!==r.msCrypto)){var X=r.crypto||r.msCrypto;if(X.getRandomValues){var $=new Uint8Array(32);for(X.getRandomValues($),J=0;J<32;++J)z[G++]=$[J]}else if("Netscape"==n.appName&&n.appVersion<"5"){var Z=r.crypto.random(32);for(J=0;J<Z.length;++J)z[G++]=255&Z.charCodeAt(J)}}for(;G<256;)J=Math.floor(65536*Math.random()),z[G++]=J>>>8,z[G++]=255&J;G=0,Y()}function Q(){if(null==W){for(Y(),(W=new U).init(z),G=0;G<z.length;++G)z[G]=0;G=0}return W.next()}function tt(){}function et(t,e){return new E(t,e)}function nt(t,e,n){for(var r="",i=0;r.length<e;)r+=n(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return r}function rt(){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 it(t,e,n){for(var r="",i=0;r.length<e;)r+=n(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return r}function st(t,e){this.x=e,this.q=t}function at(t,e,n,r){this.curve=t,this.x=e,this.y=n,this.z=null==r?E.ONE:r,this.zinv=null}function ot(t,e,n){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(n),this.infinity=new at(this,null,null)}tt.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=Q()},rt.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},rt.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=et(t,16),this.e=parseInt(e,16)}},rt.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var n=new Array,r=t.length-1;r>=0&&e>0;){var i=t.charCodeAt(r--);i<128?n[--e]=i:i>127&&i<2048?(n[--e]=63&i|128,n[--e]=i>>6|192):(n[--e]=63&i|128,n[--e]=i>>6&63|128,n[--e]=i>>12|224)}n[--e]=0;for(var s=new tt,a=new Array;e>2;){for(a[0]=0;0==a[0];)s.nextBytes(a);n[--e]=a[0]}return n[--e]=2,n[--e]=0,new E(n)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var n=this.doPublic(e);if(null==n)return null;var r=n.toString(16);return 0==(1&r.length)?r:"0"+r},rt.prototype.encryptOAEP=function(t,e,n){var r=function(t,e,n,r){var i=ht.crypto.MessageDigest,s=ht.crypto.Util,a=null;if(n||(n="sha1"),"string"==typeof n&&(a=i.getCanonicalAlgName(n),r=i.getHashLength(a),n=function(t){return wt(s.hashHex(Ft(t),a))}),t.length+2*r+2>e)throw"Message too long for RSA";var o,u="";for(o=0;o<e-t.length-2*r-2;o+=1)u+="\0";var h=n("")+u+""+t,c=new Array(r);(new tt).nextBytes(c);var l=nt(c,h.length,n),f=[];for(o=0;o<h.length;o+=1)f[o]=h.charCodeAt(o)^l.charCodeAt(o);var d=nt(f,c.length,n),g=[0];for(o=0;o<c.length;o+=1)g[o+1]=c[o]^d.charCodeAt(o);return new E(g.concat(f))}(t,this.n.bitLength()+7>>3,e,n);if(null==r)return null;var i=this.doPublic(r);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},rt.prototype.type="RSA",rt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},rt.prototype.setPrivate=function(t,e,n){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=n;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(n,16)}},rt.prototype.setPrivateEx=function(t,e,n,r,i,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(n,16),this.p=et(r,16),this.q=et(i,16),this.dmp1=et(s,16),this.dmq1=et(a,16),this.coeff=et(o,16)},rt.prototype.generate=function(t,e){var n=new tt,r=t>>1;this.e=parseInt(e,16);for(var i=new E(e,16);;){for(;this.p=new E(t-r,1,n),0!=this.p.subtract(E.ONE).gcd(i).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(r,1,n),0!=this.q.subtract(E.ONE).gcd(i).compareTo(E.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var a=this.p.subtract(E.ONE),o=this.q.subtract(E.ONE),u=a.multiply(o);if(0==u.gcd(i).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=i.modInverse(u),this.dmp1=this.d.mod(a),this.dmq1=this.d.mod(o),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},rt.prototype.decrypt=function(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var e=et(t,16),n=this.doPrivate(e);return null==n?null:function(t,e){for(var n=t.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=e-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var i="";++r<n.length;){var s=255&n[r];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&n[r+1]),++r):(i+=String.fromCharCode((15&s)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return i}(n,this.n.bitLength()+7>>3)},rt.prototype.decryptOAEP=function(t,e,n){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var r=et(t,16),i=this.doPrivate(r);return null==i?null:function(t,e,n,r){var i=ht.crypto.MessageDigest,s=ht.crypto.Util,a=null;for(n||(n="sha1"),"string"==typeof n&&(a=i.getCanonicalAlgName(n),r=i.getHashLength(a),n=function(t){return wt(s.hashHex(Ft(t),a))}),t=t.toByteArray(),o=0;o<t.length;o+=1)t[o]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*r+2)throw"Cipher too short";var o,u=t.substr(1,r),h=t.substr(r+1),c=it(h,r,n),l=[];for(o=0;o<u.length;o+=1)l[o]=u.charCodeAt(o)^c.charCodeAt(o);var f=it(String.fromCharCode.apply(String,l),t.length-r,n),d=[];for(o=0;o<h.length;o+=1)d[o]=h.charCodeAt(o)^f.charCodeAt(o);if((d=String.fromCharCode.apply(String,d)).substr(0,r)!==n(""))throw"Hash mismatch";var g=(d=d.substr(r)).indexOf("");if((-1!=g?d.substr(0,g).lastIndexOf("\0"):-1)+1!=g)throw"Malformed data";return d.substr(g+1)}(i,this.n.bitLength()+7>>3,e,n)},st.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},st.prototype.toBigInteger=function(){return this.x},st.prototype.negate=function(){return new st(this.q,this.x.negate().mod(this.q))},st.prototype.add=function(t){return new st(this.q,this.x.add(t.toBigInteger()).mod(this.q))},st.prototype.subtract=function(t){return new st(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},st.prototype.multiply=function(t){return new st(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},st.prototype.square=function(){return new st(this.q,this.x.square().mod(this.q))},st.prototype.divide=function(t){return new st(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},at.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},at.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},at.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO))},at.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(E.ZERO)&&!this.y.toBigInteger().equals(E.ZERO)},at.prototype.negate=function(){return new at(this.curve,this.x,this.y.negate(),this.z)},at.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),n=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(E.ZERO.equals(n))return E.ZERO.equals(e)?this.twice():this.curve.getInfinity();var r=new E("3"),i=this.x.toBigInteger(),s=this.y.toBigInteger(),a=(t.x.toBigInteger(),t.y.toBigInteger(),n.square()),o=a.multiply(n),u=i.multiply(a),h=e.square().multiply(this.z),c=h.subtract(u.shiftLeft(1)).multiply(t.z).subtract(o).multiply(n).mod(this.curve.q),l=u.multiply(r).multiply(e).subtract(s.multiply(o)).subtract(h.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),f=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new at(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},at.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new E("3"),e=this.x.toBigInteger(),n=this.y.toBigInteger(),r=n.multiply(this.z),i=r.multiply(n).mod(this.curve.q),s=this.curve.a.toBigInteger(),a=e.square().multiply(t);E.ZERO.equals(s)||(a=a.add(this.z.square().multiply(s)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(i)).shiftLeft(1).multiply(r).mod(this.curve.q),u=a.multiply(t).multiply(e).subtract(i.shiftLeft(1)).shiftLeft(2).multiply(i).subtract(a.square().multiply(a)).mod(this.curve.q),h=r.square().multiply(r).shiftLeft(3).mod(this.curve.q);return new at(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(u),h)},at.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,n=t,r=n.multiply(new E("3")),i=this.negate(),s=this,a=this.curve.q.subtract(t),o=a.multiply(new E("3")),u=new at(this.curve,this.x,this.y),h=u.negate();for(e=r.bitLength()-2;e>0;--e){s=s.twice();var c=r.testBit(e);c!=n.testBit(e)&&(s=s.add(c?this:i))}for(e=o.bitLength()-2;e>0;--e){u=u.twice();var l=o.testBit(e);l!=a.testBit(e)&&(u=u.add(l?u:h))}return s},at.prototype.multiplyTwo=function(t,e,n){var r;r=t.bitLength()>n.bitLength()?t.bitLength()-1:n.bitLength()-1;for(var i=this.curve.getInfinity(),s=this.add(e);r>=0;)i=i.twice(),t.testBit(r)?i=n.testBit(r)?i.add(s):i.add(this):n.testBit(r)&&(i=i.add(e)),--r;return i},ot.prototype.getQ=function(){return this.q},ot.prototype.getA=function(){return this.a},ot.prototype.getB=function(){return this.b},ot.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ot.prototype.getInfinity=function(){return this.infinity},ot.prototype.fromBigInteger=function(t){return new st(this.q,t)},ot.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,n=t.substr(2,e),r=t.substr(e+2,e);return new at(this,this.fromBigInteger(new E(n,16)),this.fromBigInteger(new E(r,16)));default:return null}},st.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},at.prototype.getEncoded=function(t){var e=function(t,e){var n=t.toByteArrayUnsigned();if(e<n.length)n=n.slice(n.length-e);else for(;e>n.length;)n.unshift(0);return n},n=this.getX().toBigInteger(),r=this.getY().toBigInteger(),i=e(n,32);return t?r.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(e(r,32))),i},at.decodeFrom=function(t,e){e[0];var n=e.length-1,r=e.slice(1,1+n/2),i=e.slice(1+n/2,1+n);r.unshift(0),i.unshift(0);var s=new E(r),a=new E(i);return new at(t,t.fromBigInteger(s),t.fromBigInteger(a))},at.decodeFromHex=function(t,e){e.substr(0,2);var n=e.length-2,r=e.substr(2,n/2),i=e.substr(2+n/2,n/2),s=new E(r,16),a=new E(i,16);return new at(t,t.fromBigInteger(s),t.fromBigInteger(a))},at.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),n=t.y.subtract(this.y).divide(e),r=n.square().subtract(this.x).subtract(t.x),i=n.multiply(this.x.subtract(r)).subtract(this.y);return new at(this.curve,r,i)},at.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(E.valueOf(2)),e=this.curve.fromBigInteger(E.valueOf(3)),n=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),r=n.square().subtract(this.x.multiply(t)),i=n.multiply(this.x.subtract(r)).subtract(this.y);return new at(this.curve,r,i)},at.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,n=t,r=n.multiply(new E("3")),i=this.negate(),s=this;for(e=r.bitLength()-2;e>0;--e){s=s.twice();var a=r.testBit(e);a!=n.testBit(e)&&(s=s.add2D(a?this:i))}return s},at.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),n=this.curve.getA().toBigInteger(),r=this.curve.getB().toBigInteger(),i=this.curve.getQ(),s=e.multiply(e).mod(i),a=t.multiply(t).multiply(t).add(n.multiply(t)).add(r).mod(i);return s.equals(a)},at.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},at.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),n=this.getY().toBigInteger();if(e.compareTo(E.ONE)<0||e.compareTo(t.subtract(E.ONE))>0)throw new Error("x coordinate out of bounds");if(n.compareTo(E.ONE)<0||n.compareTo(t.subtract(E.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var ut=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),n={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function r(t,e,r){return e?n[e]:String.fromCharCode(parseInt(r,16))}var i=new String(""),s=Object.hasOwnProperty;return function(n,a){var o,u,h=n.match(t),c=h[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var f=[o],d=1-l,g=h.length;d<g;++d){var p;switch((c=h[d]).charCodeAt(0)){default:(p=f[0])[u||p.length]=+c,u=void 0;break;case 34:if(-1!==(c=c.substring(1,c.length-1)).indexOf("\\")&&(c=c.replace(e,r)),p=f[0],!u){if(!(p instanceof Array)){u=c||i;break}u=p.length}p[u]=c,u=void 0;break;case 91:p=f[0],f.unshift(p[u||p.length]=[]),u=void 0;break;case 93:f.shift();break;case 102:(p=f[0])[u||p.length]=!1,u=void 0;break;case 110:(p=f[0])[u||p.length]=null,u=void 0;break;case 116:(p=f[0])[u||p.length]=!0,u=void 0;break;case 123:p=f[0],f.unshift(p[u||p.length]={}),u=void 0;break;case 125:f.shift()}}if(l){if(1!==f.length)throw new Error;o=o[0]}else if(f.length)throw new Error;if(a){var v=function(t,e){var n=t[e];if(n&&"object"==typeof n){var r=null;for(var i in n)if(s.call(n,i)&&n!==t){var o=v(n,i);void 0!==o?n[i]=o:(r||(r=[]),r.push(i))}if(r)for(var u=r.length;--u>=0;)delete n[r[u]]}return a.call(t,e,n)};o=v({"":o},"")}return o}}();void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),ht.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var r="",i=0;i<n;i++)r+="f";e=new E(r,16).xor(t).add(E.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return Pt(t,e)},this.newObject=function(t){var e=ht.asn1,n=e.ASN1Object,r=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,u=e.DERObjectIdentifier,h=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,d=e.DERTeletexString,g=e.DERIA5String,p=e.DERUTCTime,v=e.DERGeneralizedTime,y=e.DERVisibleString,m=e.DERBMPString,x=e.DERSequence,S=e.DERSet,b=e.DERTaggedObject,E=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var w=Object.keys(t);if(1!=w.length)throw new Error("key of param shall be only one.");var F=w[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+F+":"))throw new Error("undefined key: "+F);if("bool"==F)return new r(t[F]);if("int"==F)return new i(t[F]);if("bitstr"==F)return new s(t[F]);if("octstr"==F)return new a(t[F]);if("null"==F)return new o(t[F]);if("oid"==F)return new u(t[F]);if("enum"==F)return new h(t[F]);if("utf8str"==F)return new c(t[F]);if("numstr"==F)return new l(t[F]);if("prnstr"==F)return new f(t[F]);if("telstr"==F)return new d(t[F]);if("ia5str"==F)return new g(t[F]);if("utctime"==F)return new p(t[F]);if("gentime"==F)return new v(t[F]);if("visstr"==F)return new y(t[F]);if("bmpstr"==F)return new m(t[F]);if("asn1"==F)return new n(t[F]);if("seq"==F){for(var A=t[F],C=[],I=0;I<A.length;I++){var P=E(A[I]);C.push(P)}return new x({array:C})}if("set"==F){for(A=t[F],C=[],I=0;I<A.length;I++){P=E(A[I]);C.push(P)}return new S({array:C})}if("tag"==F){var D=t[F];if("[object Array]"===Object.prototype.toString.call(D)&&3==D.length){var R=E(D[2]);return new b({tag:D[0],explicit:D[1],obj:R})}return new b(D)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},ht.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),r=(e=Math.floor(n/40)+"."+n%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(r+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new E(r,2).toString(10),r=""}return e},ht.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=new E(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",a=0;a<i;a++)s+="0";r=s+r;for(a=0;a<r.length-1;a+=7){var o=r.substr(a,7);a!=r.length-7&&(o="1"+o),n+=e(parseInt(o,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);r+=e(s),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);return r},ht.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var n=e.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+n).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},ht.asn1.DERAbstractString=function(t){ht.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},i.lang.extend(ht.asn1.DERAbstractString,ht.asn1.ASN1Object),ht.asn1.DERAbstractTime=function(t){ht.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,n){var r=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var a=s+r(String(i.getMonth()+1),2)+r(String(i.getDate()),2)+r(String(i.getHours()),2)+r(String(i.getMinutes()),2)+r(String(i.getSeconds()),2);if(!0===n){var o=i.getMilliseconds();if(0!=o){var u=r(String(o),3);a=a+"."+(u=u.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=vt(t)},this.setByDateValue=function(t,e,n,r,i,s){var a=new Date(Date.UTC(t,e-1,n,r,i,s,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},i.lang.extend(ht.asn1.DERAbstractTime,ht.asn1.ASN1Object),ht.asn1.DERAbstractStructured=function(t){ht.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},i.lang.extend(ht.asn1.DERAbstractStructured,ht.asn1.ASN1Object),ht.asn1.DERBoolean=function(t){ht.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},i.lang.extend(ht.asn1.DERBoolean,ht.asn1.ASN1Object),ht.asn1.DERInteger=function(t){ht.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ht.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new E(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},i.lang.extend(ht.asn1.DERInteger,ht.asn1.ASN1Object),ht.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ht.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ht.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var r="";for(n=0;n<t.length-1;n+=8){var i=t.substr(n,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},i.lang.extend(ht.asn1.DERBitString,ht.asn1.ASN1Object),ht.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ht.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}ht.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},i.lang.extend(ht.asn1.DEROctetString,ht.asn1.DERAbstractString),ht.asn1.DERNull=function(){ht.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},i.lang.extend(ht.asn1.DERNull,ht.asn1.ASN1Object),ht.asn1.DERObjectIdentifier=function(t){ht.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=Mt(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=ht.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.DERObjectIdentifier,ht.asn1.ASN1Object),ht.asn1.DEREnumerated=function(t){ht.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ht.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new E(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},i.lang.extend(ht.asn1.DEREnumerated,ht.asn1.ASN1Object),ht.asn1.DERUTF8String=function(t){ht.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},i.lang.extend(ht.asn1.DERUTF8String,ht.asn1.DERAbstractString),ht.asn1.DERNumericString=function(t){ht.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},i.lang.extend(ht.asn1.DERNumericString,ht.asn1.DERAbstractString),ht.asn1.DERPrintableString=function(t){ht.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},i.lang.extend(ht.asn1.DERPrintableString,ht.asn1.DERAbstractString),ht.asn1.DERTeletexString=function(t){ht.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},i.lang.extend(ht.asn1.DERTeletexString,ht.asn1.DERAbstractString),ht.asn1.DERIA5String=function(t){ht.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},i.lang.extend(ht.asn1.DERIA5String,ht.asn1.DERAbstractString),ht.asn1.DERVisibleString=function(t){ht.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},i.lang.extend(ht.asn1.DERVisibleString,ht.asn1.DERAbstractString),ht.asn1.DERBMPString=function(t){ht.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},i.lang.extend(ht.asn1.DERBMPString,ht.asn1.DERAbstractString),ht.asn1.DERUTCTime=function(t){ht.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=vt(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=vt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},i.lang.extend(ht.asn1.DERUTCTime,ht.asn1.DERAbstractTime),ht.asn1.DERGeneralizedTime=function(t){ht.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=vt(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=vt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},i.lang.extend(ht.asn1.DERGeneralizedTime,ht.asn1.DERAbstractTime),ht.asn1.DERSequence=function(t){ht.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},i.lang.extend(ht.asn1.DERSequence,ht.asn1.DERAbstractStructured),ht.asn1.DERSet=function(t){ht.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},i.lang.extend(ht.asn1.DERSet,ht.asn1.DERAbstractStructured),ht.asn1.DERTaggedObject=function(t){ht.asn1.DERTaggedObject.superclass.constructor.call(this);var e=ht.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){null!=t.tag&&(this.hT=t.tag),null!=t.explicit&&(this.isExplicit=t.explicit),null!=t.tage&&(this.hT=t.tage,this.isExplicit=!0),null!=t.tagi&&(this.hT=t.tagi,this.isExplicit=!1),null!=t.obj&&(t.obj instanceof e.ASN1Object?(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof t.obj&&(this.asn1Object=e.ASN1Util.newObject(t.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.DERTaggedObject,ht.asn1.ASN1Object);var ht,ct,lt,ft=new function(){};function dt(t){for(var e=new Array,n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function gt(t){for(var e="",n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return e}function pt(t){for(var e="",n=0;n<t.length;n++){var r=t[n].toString(16);1==r.length&&(r="0"+r),e+=r}return e}function vt(t){return pt(dt(t))}function yt(t){return t=(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function mt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function xt(t){return t.length%2==1&&(t="0"+t),yt(x(t))}function St(t){return S(mt(t))}function bt(t){return Ot(_t(t))}function Et(t){return decodeURIComponent(Bt(t))}function wt(t){for(var e="",n=0;n<t.length-1;n+=2)e+=String.fromCharCode(parseInt(t.substr(n,2),16));return e}function Ft(t){for(var e="",n=0;n<t.length;n++)e+=("0"+t.charCodeAt(n).toString(16)).slice(-2);return e}function At(t){return x(t)}function Ct(t){var e=At(t).replace(/(.{64})/g,"$1\r\n");return e=e.replace(/\r\n$/,"")}function It(t){return S(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}function Pt(t,e){return"-----BEGIN "+e+"-----\r\n"+Ct(t)+"\r\n-----END "+e+"-----\r\n"}function Dt(t,e){if(-1==t.indexOf("-----BEGIN "))throw"can't find PEM header: "+e;return It(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function Rt(t){var e,n,r,i,s,a,o,u,h,c,l;if(l=t.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return u=l[1],e=parseInt(u),2===u.length&&(50<=e&&e<100?e=1900+e:0<=e&&e<50&&(e=2e3+e)),n=parseInt(l[2])-1,r=parseInt(l[3]),i=parseInt(l[4]),s=parseInt(l[5]),a=parseInt(l[6]),o=0,""!==(h=l[7])&&(c=(h.substr(1)+"00").substr(0,3),o=parseInt(c)),Date.UTC(e,n,r,i,s,a,o);throw"unsupported zulu format: "+t}function Tt(t){return~~(Rt(t)/1e3)}function Ot(t){return t.replace(/%/g,"")}function Bt(t){return t.replace(/(..)/g,"%$1")}function Ht(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var n=(t=t.toLowerCase()).split(":").length-1;if(n<2)throw e;var r=":".repeat(7-n+2),i=(t=t.replace("::",r)).split(":");if(8!=i.length)throw e;for(var s=0;s<8;s++)i[s]=("0000"+i[s]).slice(-4);return i.join("")}function Nt(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var e=(t=t.toLowerCase()).match(/.{1,4}/g),n=0;n<8;n++)e[n]=e[n].replace(/^0+/,""),""==e[n]&&(e[n]="0");var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null===r)return t.slice(1,-1);var i="";for(n=0;n<r.length;n++)r[n].length>i.length&&(i=r[n]);return(t=t.replace(i,"::")).slice(1,-1)}function jt(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Nt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function _t(t){for(var e=encodeURIComponent(t),n="",r=0;r<e.length;r++)"%"==e[r]?(n+=e.substr(r,3),r+=2):n=n+"%"+vt(e[r]);return n}function kt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Vt(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Lt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,n){var r=parseInt(t);if(r<0||255<r)throw"integer not in range 0-255";return("00"+r.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}}ft.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var n=parseInt(t.substr(e+3,1));return 0==n?-1:0<n&&n<10?n+1:-2},ft.getL=function(t,e){var n=ft.getLblen(t,e);return n<1?"":t.substr(e+2,2*n)},ft.getVblen=function(t,e){var n;return""==(n=ft.getL(t,e))?-1:("8"===n.substr(0,1)?new E(n.substr(2),16):new E(n,16)).intValue()},ft.getVidx=function(t,e){var n=ft.getLblen(t,e);return n<0?n:e+2*(n+1)},ft.getV=function(t,e){var n=ft.getVidx(t,e),r=ft.getVblen(t,e);return t.substr(n,2*r)},ft.getTLV=function(t,e){return t.substr(e,2)+ft.getL(t,e)+ft.getV(t,e)},ft.getTLVblen=function(t,e){return 2+2*ft.getLblen(t,e)+2*ft.getVblen(t,e)},ft.getNextSiblingIdx=function(t,e){return ft.getVidx(t,e)+2*ft.getVblen(t,e)},ft.getChildIdx=function(t,e){var n,r,i,s=ft,a=[];n=s.getVidx(t,e),r=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(n+=2,r-=2),i=0;for(var o=n;i<=r;){var u=s.getTLVblen(t,o);if((i+=u)<=r&&a.push(o),o+=u,i>=r)break}return a},ft.getNthChildIdx=function(t,e,n){return ft.getChildIdx(t,e)[n]},ft.getIdxbyList=function(t,e,n,r){var i,s,a=ft;return 0==n.length?void 0!==r&&t.substr(e,2)!==r?-1:e:(i=n.shift())>=(s=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,s[i],n,r)},ft.getIdxbyListEx=function(t,e,n,r){var i,s,a=ft;if(0==n.length)return void 0!==r&&t.substr(e,2)!==r?-1:e;i=n.shift(),s=a.getChildIdx(t,e);for(var o=0,u=0;u<s.length;u++){var h=t.substr(s[u],2);if("number"==typeof i&&!a.isContextTag(h)&&o==i||"string"==typeof i&&a.isContextTag(h,i))return a.getIdxbyListEx(t,s[u],n,r);a.isContextTag(h)||o++}return-1},ft.getTLVbyList=function(t,e,n,r){var i=ft,s=i.getIdxbyList(t,e,n,r);return-1==s||s>=t.length?null:i.getTLV(t,s)},ft.getTLVbyListEx=function(t,e,n,r){var i=ft,s=i.getIdxbyListEx(t,e,n,r);return-1==s?null:i.getTLV(t,s)},ft.getVbyList=function(t,e,n,r,i){var s,a,o=ft;return-1==(s=o.getIdxbyList(t,e,n,r))||s>=t.length?null:(a=o.getV(t,s),!0===i&&(a=a.substr(2)),a)},ft.getVbyListEx=function(t,e,n,r,i){var s,a,o=ft;return-1==(s=o.getIdxbyListEx(t,e,n,r))?null:(a=o.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(a=a.substr(2)),a)},ft.getInt=function(t,e,n){null==n&&(n=-1);try{var r=t.substr(e,2);if("02"!=r&&"03"!=r)return n;var i=ft.getV(t,e);return"02"==r?parseInt(i,16):Ut(i)}catch(t){return n}},ft.getOID=function(t,e,n){null==n&&(n=null);try{return"06"!=t.substr(e,2)?n:Kt(ft.getV(t,e))}catch(t){return n}},ft.getOIDName=function(t,e,n){null==n&&(n=null);try{var r=ft.getOID(t,e,n);if(r==n)return n;var i=ht.asn1.x509.OID.oid2name(r);return""==i?r:i}catch(t){return n}},ft.getString=function(t,e,n){null==n&&(n=null);try{return wt(ft.getV(t,e))}catch(t){return n}},ft.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},n=[],r=t.substr(0,2),i=parseInt(r,16);n[0]=new String(Math.floor(i/40)),n[1]=new String(i%40);for(var s=t.substr(2),a=[],o=0;o<s.length/2;o++)a.push(parseInt(s.substr(2*o,2),16));var u=[],h="";for(o=0;o<a.length;o++)128&a[o]?h+=e((127&a[o]).toString(2),7):(h+=e((127&a[o]).toString(2),7),u.push(new String(parseInt(h,2))),h="");var c=n.join(".");return u.length>0&&(c=c+"."+u.join(".")),c},ft.dump=function(t,e,n,r){var i=ft,s=i.getV,a=i.dump,o=i.getChildIdx,u=t;t instanceof ht.asn1.ASN1Object&&(u=t.getEncodedHex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===n&&(n=0),void 0===r&&(r="");var c,l=e.ommit_long_octet;if("01"==(c=u.substr(n,2)))return"00"==(f=s(u,n))?r+"BOOLEAN FALSE\n":r+"BOOLEAN TRUE\n";if("02"==c)return r+"INTEGER "+h(f=s(u,n),l)+"\n";if("03"==c){var f=s(u,n);if(i.isASN1HEX(f.substr(2))){var d=r+"BITSTRING, encapsulates\n";return d+=a(f.substr(2),e,0,r+" ")}return r+"BITSTRING "+h(f,l)+"\n"}if("04"==c){f=s(u,n);if(i.isASN1HEX(f)){d=r+"OCTETSTRING, encapsulates\n";return d+=a(f,e,0,r+" ")}return r+"OCTETSTRING "+h(f,l)+"\n"}if("05"==c)return r+"NULL\n";if("06"==c){var g=s(u,n),p=ht.asn1.ASN1Util.oidHexToInt(g),v=ht.asn1.x509.OID.oid2name(p),y=p.replace(/\./g," ");return""!=v?r+"ObjectIdentifier "+v+" ("+y+")\n":r+"ObjectIdentifier ("+y+")\n"}if("0a"==c)return r+"ENUMERATED "+parseInt(s(u,n))+"\n";if("0c"==c)return r+"UTF8String '"+Et(s(u,n))+"'\n";if("13"==c)return r+"PrintableString '"+Et(s(u,n))+"'\n";if("14"==c)return r+"TeletexString '"+Et(s(u,n))+"'\n";if("16"==c)return r+"IA5String '"+Et(s(u,n))+"'\n";if("17"==c)return r+"UTCTime "+Et(s(u,n))+"\n";if("18"==c)return r+"GeneralizedTime "+Et(s(u,n))+"\n";if("1a"==c)return r+"VisualString '"+Et(s(u,n))+"'\n";if("1e"==c)return r+"BMPString '"+Et(s(u,n))+"'\n";if("30"==c){if("3000"==u.substr(n,4))return r+"SEQUENCE {}\n";d=r+"SEQUENCE\n";var m=e;if((2==(b=o(u,n)).length||3==b.length)&&"06"==u.substr(b[0],2)&&"04"==u.substr(b[b.length-1],2)){v=i.oidname(s(u,b[0]));var x=JSON.parse(JSON.stringify(e));x.x509ExtName=v,m=x}for(var S=0;S<b.length;S++)d+=a(u,m,b[S],r+" ");return d}if("31"==c){d=r+"SET\n";var b=o(u,n);for(S=0;S<b.length;S++)d+=a(u,e,b[S],r+" ");return d}if(0!=(128&(c=parseInt(c,16)))){var E=31&c;if(0!=(32&c)){for(d=r+"["+E+"]\n",b=o(u,n),S=0;S<b.length;S++)d+=a(u,e,b[S],r+" ");return d}f=s(u,n);if(ft.isASN1HEX(f)){var d=r+"["+E+"]\n";return d+=a(f,e,0,r+" ")}return("68747470"==f.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==E)&&(f=Et(f)),d=r+"["+E+"] "+f+"\n"}return r+"UNKNOWN("+c+") "+s(u,n)+"\n"},ft.isContextTag=function(t,e){var n,r;t=t.toLowerCase();try{n=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&n);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((r=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&n)&&(31&n)==r))}catch(t){return!1}},ft.isASN1HEX=function(t){var e=ft;if(t.length%2==1)return!1;var n=e.getVblen(t,0),r=t.substr(0,2),i=e.getL(t,0);return t.length-r.length-i.length==2*n},ft.checkStrictDER=function(t,e,n,r,i){var s=ft;if(void 0===n){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!ht.lang.String.isHex(t))throw new Error("not hex string");n=t.length,i=(r=t.length/2)<128?1:Math.ceil(r.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(a>r)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),u=o.length-2-s.getL(t,e).length;if(u!==2*a)throw new Error("V string length and L's value not the same:"+u+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var h=t.substr(e,2);if("02"===h){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=s.getVblen(t,e),f=0,d=s.getChildIdx(t,e),g=0;g<d.length;g++){f+=s.getTLV(t,d[g]).length,s.checkStrictDER(t,d[g],n,r,i)}if(2*l!=f)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+f)}},ft.oidname=function(t){var e=ht.asn1;ht.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var n=e.x509.OID.oid2name(t);return""===n&&(n=t),n},void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),void 0!==ht.asn1.x509&&ht.asn1.x509||(ht.asn1.x509={}),ht.asn1.x509.Certificate=function(t){ht.asn1.x509.Certificate.superclass.constructor.call(this);var e=ht.asn1,n=e.DERBitString,r=e.DERSequence,i=e.x509,s=i.TBSCertificate,a=i.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var n=t.tbsobj.getEncodedHex(),r=new ht.crypto.Signature({alg:e});r.init(t.cakey),r.updateHex(n),t.sighex=r.sign()},this.getPEM=function(){return Pt(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new a({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).getEncodedHex()},null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.Certificate,ht.asn1.ASN1Object),ht.asn1.x509.TBSCertificate=function(t){ht.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=ht.asn1,n=e.x509,r=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,a=n.AlgorithmIdentifier,o=n.Time,u=n.X500Name,h=n.Extensions,c=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var n=2;null!=e.version&&(n=e.version-1);var l=new r({obj:new i({int:n})});t.push(l)}return t.push(new i(e.serial)),t.push(new a({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new s({array:[new o(e.notbefore),new o(e.notafter)]})),t.push(new u(e.subject)),t.push(new c(Wt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new r({tag:"a3",obj:new h(e.ext)})),new ht.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.TBSCertificate,ht.asn1.ASN1Object),ht.asn1.x509.Extensions=function(t){ht.asn1.x509.Extensions.superclass.constructor.call(this);var e=ht.asn1,n=e.DERSequence,r=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var i=this.aParam[e],s=i.extname,a=null;if(null!=i.extn)a=new r.PrivateExtension(i);else if("subjectKeyIdentifier"==s)a=new r.SubjectKeyIdentifier(i);else if("keyUsage"==s)a=new r.KeyUsage(i);else if("subjectAltName"==s)a=new r.SubjectAltName(i);else if("issuerAltName"==s)a=new r.IssuerAltName(i);else if("basicConstraints"==s)a=new r.BasicConstraints(i);else if("cRLDistributionPoints"==s)a=new r.CRLDistributionPoints(i);else if("certificatePolicies"==s)a=new r.CertificatePolicies(i);else if("authorityKeyIdentifier"==s)a=new r.AuthorityKeyIdentifier(i);else if("extKeyUsage"==s)a=new r.ExtKeyUsage(i);else if("authorityInfoAccess"==s)a=new r.AuthorityInfoAccess(i);else if("cRLNumber"==s)a=new r.CRLNumber(i);else if("cRLReason"==s)a=new r.CRLReason(i);else if("ocspNonce"==s)a=new r.OCSPNonce(i);else if("ocspNoCheck"==s)a=new r.OCSPNoCheck(i);else{if("adobeTimeStamp"!=s)throw new Error("extension not supported:"+JSON.stringify(i));a=new r.AdobeTimeStamp(i)}null!=a&&t.push(a)}return new n({array:t}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.Extensions,ht.asn1.ASN1Object),ht.asn1.x509.Extension=function(t){ht.asn1.x509.Extension.superclass.constructor.call(this);var e=ht.asn1,n=e.DERObjectIdentifier,r=e.DEROctetString,i=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new n({oid:this.oid}),e=new r({hex:this.getExtnValueHex()}),a=new Array;return a.push(t),this.critical&&a.push(new i),a.push(e),new s({array:a}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},i.lang.extend(ht.asn1.x509.Extension,ht.asn1.ASN1Object),ht.asn1.x509.KeyUsage=function(t){ht.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Xt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ht.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var n=t.names,r="000000000",i=0;i<n.length;i++)for(var s=0;s<e.length;s++)n[i]===e[s]&&(r=r.substring(0,s)+"1"+r.substring(s+1,r.length));this.asn1ExtnValue=new ht.asn1.DERBitString({bin:r})}},i.lang.extend(ht.asn1.x509.KeyUsage,ht.asn1.x509.Extension),ht.asn1.x509.BasicConstraints=function(t){ht.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=ht.asn1,n=e.DERBoolean,r=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new n),this.pathLen>-1&&t.push(new r({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},i.lang.extend(ht.asn1.x509.BasicConstraints,ht.asn1.x509.Extension),ht.asn1.x509.CRLDistributionPoints=function(t){ht.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ht.asn1,n=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var r=[],i=0;i<t.length;i++)if(t[i]instanceof ht.asn1.ASN1Object)r.push(t[i]);else{var s=new n.DistributionPoint(t[i]);r.push(s)}this.asn1ExtnValue=new e.DERSequence({array:r})},this.setByOneURI=function(t){var e=new n.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},i.lang.extend(ht.asn1.x509.CRLDistributionPoints,ht.asn1.x509.Extension),ht.asn1.x509.DistributionPoint=function(t){ht.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=ht.asn1,n=e.x509.DistributionPointName;this.getEncodedHex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var n=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(n)}return this.hTLV=t.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new n(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new n({full:[{uri:t.fulluri}]})))},i.lang.extend(ht.asn1.x509.DistributionPoint,ht.asn1.ASN1Object),ht.asn1.x509.DistributionPointName=function(t){ht.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=ht.asn1,n=e.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new n({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},i.lang.extend(ht.asn1.x509.DistributionPointName,ht.asn1.ASN1Object),ht.asn1.x509.CertificatePolicies=function(t){ht.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=ht.asn1,n=e.x509,r=e.DERSequence,i=n.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var n=new r({array:t});return this.asn1ExtnValue=n,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.x509.CertificatePolicies,ht.asn1.x509.Extension),ht.asn1.x509.PolicyInformation=function(t){ht.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=ht.asn1,n=e.DERSequence,r=e.DERObjectIdentifier,i=e.x509.PolicyQualifierInfo;this.params=null,this.getEncodedHex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new r(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new i(this.params.array[s]));e.length>0&&t.push(new n({array:e}))}return new n({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.x509.PolicyInformation,ht.asn1.ASN1Object),ht.asn1.x509.PolicyQualifierInfo=function(t){ht.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=ht.asn1,n=e.DERSequence,r=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new n({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new r({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new n({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.x509.PolicyQualifierInfo,ht.asn1.ASN1Object),ht.asn1.x509.UserNotice=function(t){ht.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=ht.asn1.DERSequence,n=(ht.asn1.DERInteger,ht.asn1.x509.DisplayText),r=ht.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new r(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new n(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.x509.UserNotice,ht.asn1.ASN1Object),ht.asn1.x509.NoticeReference=function(t){ht.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=ht.asn1.DERSequence,n=ht.asn1.DERInteger,r=ht.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new r(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,a=0;a<s.length;a++)i.push(new n(s[a]));t.push(new e({array:i}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.x509.NoticeReference,ht.asn1.ASN1Object),ht.asn1.x509.DisplayText=function(t){ht.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},i.lang.extend(ht.asn1.x509.DisplayText,ht.asn1.DERAbstractString),ht.asn1.x509.ExtKeyUsage=function(t){ht.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ht.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var n=0;n<t.length;n++){var r=new e.DERObjectIdentifier(t[n]);this.asn1ExtnValue.appendASN1Object(r)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},i.lang.extend(ht.asn1.x509.ExtKeyUsage,ht.asn1.x509.Extension),ht.asn1.x509.AuthorityKeyIdentifier=function(t){ht.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=ht,n=e.asn1,r=n.DERTaggedObject,i=n.x509.GeneralNames;e.crypto.Util.isKey;this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new r({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new r({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new r({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new n.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new ht.asn1.DEROctetString(t);else if("object"==typeof t&&ht.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Wt.getKey(t));var n=Wt.getKeyID(e);this.asn1KID=new ht.asn1.DEROctetString({hex:n})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new ht.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new ht.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new ht.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new Xt;e.readCertPEM(t);var n=e.getSerialNumberHex();this.asn1CertSN=new ht.asn1.DERInteger({hex:n})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},i.lang.extend(ht.asn1.x509.AuthorityKeyIdentifier,ht.asn1.x509.Extension),ht.asn1.x509.SubjectKeyIdentifier=function(t){ht.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=ht.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&ht.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var n=t;"string"==typeof t&&(n=Wt.getKey(t));var r=Wt.getKeyID(n);this.asn1KID=new ht.asn1.DEROctetString({hex:r})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},i.lang.extend(ht.asn1.x509.SubjectKeyIdentifier,ht.asn1.x509.Extension),ht.asn1.x509.AuthorityInfoAccess=function(t){ht.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,n=ht.asn1,r=n.DERSequence,i=n.DERObjectIdentifier,s=n.x509.GeneralName,a=0;a<t.length;a++){var o,u=t[a];if(void 0!==u.ocsp)o=new r({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:u.ocsp})]});else{if(void 0===u.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(u));o=new r({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}e.push(o)}this.asn1ExtnValue=new r({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},i.lang.extend(ht.asn1.x509.AuthorityInfoAccess,ht.asn1.x509.Extension),ht.asn1.x509.SubjectAltName=function(t){ht.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new ht.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},i.lang.extend(ht.asn1.x509.SubjectAltName,ht.asn1.x509.Extension),ht.asn1.x509.IssuerAltName=function(t){ht.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new ht.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},i.lang.extend(ht.asn1.x509.IssuerAltName,ht.asn1.x509.Extension),ht.asn1.x509.PrivateExtension=function(t){ht.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=ht,n=e.lang.String.isHex,r=e.asn1,i=r.x509.OID.name2oid,s=r.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=i(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&n(t))return t;if("object"==typeof t)try{return s(t).getEncodedHex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.PrivateExtension,ht.asn1.x509.Extension),ht.asn1.x509.CRL=function(t){ht.asn1.x509.CRL.superclass.constructor.call(this);var e=ht.asn1,n=e.DERSequence,r=e.DERBitString,i=e.x509,s=i.AlgorithmIdentifier,a=i.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new a(this.params).getEncodedHex(),e=new ht.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var n=e.sign();this.params.sighex=n},this.getPEM=function(){return Pt(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new a(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).getEncodedHex()},null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.CRL,ht.asn1.ASN1Object),ht.asn1.x509.TBSCertList=function(t){ht.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=ht.asn1,n=e.DERInteger,r=e.DERSequence,i=e.DERTaggedObject,s=(e.DERObjectIdentifier,e.x509),a=s.AlgorithmIdentifier,o=s.Time,u=s.Extensions,h=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,i=0;i<e.length;i++){var s=[new n(e[i].sn),new o(e[i].date)];null!=e[i].ext&&s.push(new u(e[i].ext)),t.push(new r({array:s}))}return new r({array:t})},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new n({int:s});t.push(c)}if(t.push(new a({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new o(e.thisupdate)),null!=e.nextupdate&&t.push(new o(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new u(e.ext);t.push(new i({tag:"a0",explicit:!0,obj:l}))}return new r({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.TBSCertList,ht.asn1.ASN1Object),ht.asn1.x509.CRLEntry=function(t){ht.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ht.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},i.lang.extend(ht.asn1.x509.CRLEntry,ht.asn1.ASN1Object),ht.asn1.x509.CRLNumber=function(t){ht.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ht.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.CRLNumber,ht.asn1.x509.Extension),ht.asn1.x509.CRLReason=function(t){ht.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ht.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.CRLReason,ht.asn1.x509.Extension),ht.asn1.x509.OCSPNonce=function(t){ht.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ht.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.OCSPNonce,ht.asn1.x509.Extension),ht.asn1.x509.OCSPNoCheck=function(t){ht.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ht.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},i.lang.extend(ht.asn1.x509.OCSPNoCheck,ht.asn1.x509.Extension),ht.asn1.x509.AdobeTimeStamp=function(t){ht.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=ht.asn1,n=e.DERInteger,r=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new n(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new r(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.AdobeTimeStamp,ht.asn1.x509.Extension),ht.asn1.x509.X500Name=function(t){ht.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ht.asn1,n=e.x509,r=n.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var n=t.split("/");n.shift();for(var i=[],s=0;s<n.length;s++)if(n[s].match(/^[^=]+=.+$/))i.push(n[s]);else{var a=i.length-1;i[a]=i[a]+"/"+n[s]}for(s=0;s<i.length;s++)this.asn1Array.push(new r({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var r=n.X500Name.ldapToCompat(t);this.setByString(r,e)},this.setByObject=function(t,e){for(var n in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(n)){var i=new r({str:n+"="+t[n],rule:this.sRule});this.asn1Array?this.asn1Array.push(i):this.asn1Array=[i]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new Xt).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new Xt).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var n={array:this.paramArray[t]};"utf8"!=this.sRule&&(n.rule=this.sRule);var i=new r(n);this.asn1Array.push(i)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.X500Name,ht.asn1.ASN1Object),ht.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),(e=e.map((function(t){return t.replace(/,/,"\\,")}))).join(",")},ht.asn1.x509.X500Name.onelineToLDAP=function(t){return ht.asn1.x509.X500Name.compatToLDAP(t)},ht.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),n=!1,r=[],i=0;e.length>0;i++){var s=e.shift();if(!0===n){var a=(r.pop()+","+s).replace(/\\,/g,",");r.push(a),n=!1}else r.push(s);"\\"===s.substr(-1,1)&&(n=!0)}return(r=r.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+r.join("/")},ht.asn1.x509.X500Name.ldapToOneline=function(t){return ht.asn1.x509.X500Name.ldapToCompat(t)},ht.asn1.x509.RDN=function(t){ht.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ht.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new ht.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=ht.asn1.x509.RDN.parseString(t),n=0;n<e.length;n++)this.addByString(e[n])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var n=this.paramArray[t];void 0!==n.rule&&"utf8"!=this.sRule&&(n.rule=this.sRule);var r=new e(n);this.asn1Array.push(r)}var i=new ht.asn1.DERSet({array:this.asn1Array});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.RDN,ht.asn1.ASN1Object),ht.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),n=!1,r=[],i=0;e.length>0;i++){var s=e.shift();if(!0===n){var a=(r.pop()+"+"+s).replace(/\\\+/g,"+");r.push(a),n=!1}else r.push(s);"\\"===s.substr(-1,1)&&(n=!0)}var o=!1,u=[];for(i=0;r.length>0;i++){s=r.shift();if(!0===o){var h=u.pop();if(s.match(/"$/)){a=(h+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(a),o=!1}else u.push(h+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(o=!0)}return u},ht.asn1.x509.AttributeTypeAndValue=function(t){ht.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=ht,n=e.asn1,r=n.DERSequence,i=n.DERUTF8String,s=n.DERPrintableString,a=n.DERTeletexString,o=n.DERIA5String,u=n.DERVisibleString,h=n.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var n=t.match(/^([^=]+)=(.+)$/);if(!n)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(n[1],n[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,n=this.sRule;return"prn"===n?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===n?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,n){void 0!==n&&(this.sRule=n),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=ht.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),n=new r({array:[t,e]});return this.TLV=n.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.AttributeTypeAndValue,ht.asn1.ASN1Object),ht.asn1.x509.SubjectPublicKeyInfo=function(t){ht.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ht,n=e.asn1,r=n.DERInteger,i=n.DERBitString,s=n.DERObjectIdentifier,a=n.DERSequence,o=n.ASN1Util.newObject,u=n.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof rt){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof ht.crypto.ECDSA){var n=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:n}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ht.crypto.DSA){n=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:n});var a=new r({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+a.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},i.lang.extend(ht.asn1.x509.SubjectPublicKeyInfo,ht.asn1.ASN1Object),ht.asn1.x509.Time=function(t){ht.asn1.x509.Time.superclass.constructor.call(this);var e=ht.asn1,n=e.DERUTCTime,r=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new n(this.timeParams):new r(this.timeParams):"utc"==this.type?new n:new r,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},i.lang.extend(ht.asn1.x509.Time,ht.asn1.ASN1Object),ht.asn1.x509.AlgorithmIdentifier=function(t){ht.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ht.asn1,n=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var r in n)r===this.nameAlg&&(t=n[r]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var r=this.nameAlg.toLowerCase();"withdsa"!==r.substr(-7,7)&&"withecdsa"!==r.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},i.lang.extend(ht.asn1.x509.AlgorithmIdentifier,ht.asn1.ASN1Object),ht.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},ht.asn1.x509.GeneralName=function(t){ht.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},n=ht.asn1,r=(n.DERSequence,n.DEROctetString),i=n.DERIA5String,s=n.DERTaggedObject,a=n.ASN1Object,o=n.x509.X500Name,u=Dt;this.explicit=!1,this.setByParam=function(t){var n=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",n=new i({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",n=new i({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",n=new i({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,n="string"==typeof t.dn?new o({str:t.dn}):t.dn instanceof ht.asn1.x509.X500Name?t.dn:new o(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,n=new o({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var h=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certissuer param not cert";(f=new Xt).hex=h;var c=f.getIssuerHex();(n=new a).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;h=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certsubj param not cert";(f=new Xt).hex=h;c=f.getSubjectHex();(n=new a).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Lt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Ht(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}n=new r({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:n})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.x509.GeneralName,ht.asn1.ASN1Object),ht.asn1.x509.GeneralNames=function(t){ht.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ht.asn1;this.setByParamArray=function(t){for(var n=0;n<t.length;n++){var r=new e.x509.GeneralName(t[n]);this.asn1Array.push(r)}},this.getEncodedHex=function(){return new e.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},i.lang.extend(ht.asn1.x509.GeneralNames,ht.asn1.ASN1Object),ht.asn1.x509.OID=new function(t){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",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",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",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1"},this.objCache={},this.name2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],n=new ht.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=n,n},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.atype2oidList[t])throw"AttributeType name undefined: "+t;var e=this.atype2oidList[t],n=new ht.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=n,n}},ht.asn1.x509.OID.oid2name=function(t){var e=ht.asn1.x509.OID.name2oidList;for(var n in e)if(e[n]==t)return n;return""},ht.asn1.x509.OID.oid2atype=function(t){var e=ht.asn1.x509.OID.atype2oidList;for(var n in e)if(e[n]==t)return n;return t},ht.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=ht.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},ht.asn1.x509.X509Util={},ht.asn1.x509.X509Util.newCertPEM=function(t){var e=ht.asn1.x509;e.TBSCertificate;return new(0,e.Certificate)(t).getPEM()},void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),void 0!==ht.asn1.cms&&ht.asn1.cms||(ht.asn1.cms={}),ht.asn1.cms.Attribute=function(t){var e=Error,n=ht.asn1,r=n.DERSequence,i=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.getEncodedHex=function(){var t=new s({oid:this.typeOid}),e=new i({array:this.getValueArray()});return new r({array:[t,e]}).getEncodedHex()}},i.lang.extend(ht.asn1.cms.Attribute,ht.asn1.ASN1Object),ht.asn1.cms.ContentType=function(t){var e=ht.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.ContentType,ht.asn1.cms.Attribute),ht.asn1.cms.MessageDigest=function(t){var e=ht.asn1,n=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new n(this.params)]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.MessageDigest,ht.asn1.cms.Attribute),ht.asn1.cms.SigningTime=function(t){var e=ht.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SigningTime,ht.asn1.cms.Attribute),ht.asn1.cms.SigningCertificate=function(t){var e=Error,n=ht,r=n.asn1,i=r.DERSequence,s=r.cms,a=s.ESSCertID;n.crypto;s.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var n=this.params.array,r=[],s=0;s<n.length;s++){var o=n[s];0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ft.isASN1HEX(o)||(o={cert:o}),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),r.push(new a(o))}var u=new i({array:r});return[new i({array:[u]})]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SigningCertificate,ht.asn1.cms.Attribute),ht.asn1.cms.ESSCertID=function(t){ht.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,n=ht,r=n.asn1,i=r.DEROctetString,s=r.DERSequence,a=r.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,r){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ft.isASN1HEX(t))return t;var i,s,a;if("string"==typeof t)i=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");i=t.cert}if(s=-1!=i.indexOf("-----BEGIN")?Dt(i):i,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?s=Dt(t):ft.isASN1HEX(t)&&(s=t)),null!=t.alg)a=t.alg;else{if(null==r)throw new e("hash alg unspecified");a=r}return n.crypto.Util.hashHex(s,a)},this.getEncodedHex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),n=[];return n.push(new i({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&n.push(new a(t)),new s({array:n}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.ESSCertID,ht.asn1.ASN1Object),ht.asn1.cms.SigningCertificateV2=function(t){var e=Error,n=ht,r=n.asn1,i=r.DERSequence,s=(r.x509,r.cms),a=s.ESSCertIDv2;n.crypto;s.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var n=this.params.array,r=[],s=0;s<n.length;s++){var o=n[s];null==t.alg&&0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ft.isASN1HEX(o)||(o={cert:o}),null==o.alg&&null!=t.alg&&(o.alg=t.alg),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),r.push(new a(o))}var u=new i({array:r});return[new i({array:[u]})]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SigningCertificateV2,ht.asn1.cms.Attribute),ht.asn1.cms.ESSCertIDv2=function(t){ht.asn1.cms.ESSCertIDv2.superclass.constructor.call(this);Error;var e=ht.asn1,n=e.DEROctetString,r=e.DERSequence,i=e.cms.IssuerSerial,s=e.x509.AlgorithmIdentifier;this.params=null,this.getEncodedHex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),a=[];return null!=t.alg&&"sha256"!=t.alg&&a.push(new s({name:t.alg})),a.push(new n({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&a.push(new i(t)),new r({array:a}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.ESSCertIDv2,ht.asn1.cms.ESSCertID),ht.asn1.cms.IssuerSerial=function(t){var e=Error,n=ht.asn1,r=n.DERInteger,i=n.DERSequence,s=n.cms,a=n.x509.GeneralNames,o=Xt;s.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t,n,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var u;u=null!=s.cert?s.cert:s;var h=new o;h.readCertPEM(u),t=h.getIssuer(),n={hex:h.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new e("cert or issuer and serial parameter not specified");t=s.issuer,n=s.serial}var c=new a([{dn:t}]),l=new r(n);return new i({array:[c,l]}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.IssuerSerial,ht.asn1.ASN1Object),ht.asn1.cms.SignerIdentifier=function(t){var e=ht.asn1,n=(e.DERInteger,e.DERSequence,e.cms),r=n.IssuerAndSerialNumber,i=n.SubjectKeyIdentifier;e.x509.X500Name,Error;n.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if("isssn"==t.type)return new r(t).getEncodedHex();if("skid"==t.type)return new i(t).getEncodedHex();throw new Error("wrong property for isssn or skid")},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SignerIdentifier,ht.asn1.ASN1Object),ht.asn1.cms.IssuerAndSerialNumber=function(t){var e=ht.asn1,n=e.DERInteger,r=e.DERSequence,i=e.cms,s=e.x509.X500Name,a=Xt,o=Error;i.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t,e,i=this.params;if("string"==typeof i&&-1!=i.indexOf("-----BEGIN")||null!=i.cert){var u;u=null!=i.cert?i.cert:i;var h=new a;h.readCertPEM(u),t=h.getIssuer(),e={hex:h.getSerialNumberHex()}}else{if(null==i.issuer||!i.serial)throw new o("cert or issuer and serial parameter not specified");t=i.issuer,e=i.serial}var c=new s(t),l=new n(e);return new r({array:[c,l]}).getEncodedHex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.IssuerAndSerialNumber,ht.asn1.ASN1Object),ht.asn1.cms.SubjectKeyIdentifier=function(t){var e=ht.asn1,n=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),r=e.cms,i=(r.IssuerAndSerialName,r.SubjectKeyIdentifier,e.x509.X500Name,Xt),s=Error;r.SubjectKeyIdentifier.superclass.constructor.call(this),this.getEncodedHex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");null!=e.cert?t=new i(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid);return n({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SubjectKeyIdentifier,ht.asn1.ASN1Object),ht.asn1.cms.AttributeList=function(t){var e=Error,n=ht.asn1,r=n.DERSet,i=n.cms;i.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var n=!0;null!=t.sortflag&&(n=t.sortflag);for(var s=t.array,a=[],o=0;o<s.length;o++){var u=s[o],h=u.attr;if("contentType"==h)a.push(new i.ContentType(u));else if("messageDigest"==h)a.push(new i.MessageDigest(u));else if("signingTime"==h)a.push(new i.SigningTime(u));else if("signingCertificate"==h)a.push(new i.SigningCertificate(u));else if("signingCertificateV2"==h)a.push(new i.SigningCertificateV2(u));else if("signaturePolicyIdentifier"==h)a.push(new ht.asn1.cades.SignaturePolicyIdentifier(u));else{if("signatureTimeStamp"!=h&&"timeStampToken"!=h)throw new e("unknown attr: "+h);a.push(new ht.asn1.cades.SignatureTimeStamp(u))}}var c=new r({array:a,sortflag:n});return this.hTLV=c.getEncodedHex(),this.hTLV},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.AttributeList,ht.asn1.ASN1Object),ht.asn1.cms.SignerInfo=function(t){var e=Error,n=ht,r=n.asn1,i=r.DERInteger,s=r.DEROctetString,a=r.DERSequence,o=r.DERTaggedObject,u=r.cms,h=u.SignerIdentifier,c=u.AttributeList,l=(u.ContentType,u.EncapsulatedContentInfo,u.MessageDigest,u.SignedData,r.x509.AlgorithmIdentifier),f=n.crypto,d=Wt;u.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,n=new c(t.sattrs).getEncodedHex(),r=d.getKey(t.signkey),i=new f.Signature({alg:e});i.init(r),i.updateHex(n);var s=i.sign();t.sighex=s},this.getEncodedHex=function(){var t=this.params,n=[];if(n.push(new i({int:t.version})),n.push(new h(t.id)),n.push(new l({name:t.hashalg})),null!=t.sattrs){var r=new c(t.sattrs);try{n.push(new o({tag:"a0",explicit:!1,obj:r}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?n.push(new l({name:t.sigalgfield})):n.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),n.push(new s({hex:t.sighex})),null!=t.uattrs){r=new c(t.uattrs);try{n.push(new o({tag:"a1",explicit:!1,obj:r}))}catch(t){throw new e("si uattr error: "+t)}}return new a({array:n}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SignerInfo,ht.asn1.ASN1Object),ht.asn1.cms.EncapsulatedContentInfo=function(t){var e=ht.asn1,n=e.DERTaggedObject,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=[];if(e.push(new i(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var a=new s(t.content),o=new n({tag:"a0",explicit:!0,obj:a});e.push(o)}return new r({array:e}).getEncodedHex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.EncapsulatedContentInfo,ht.asn1.ASN1Object),ht.asn1.cms.ContentInfo=function(t){var e=ht.asn1,n=e.DERTaggedObject,r=e.DERSequence,i=e.DERObjectIdentifier;e.x509.OID.name2obj;ht.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=[];e.push(new i(t.type));var s=new n({tag:"a0",explicit:!0,obj:t.obj});return e.push(s),new r({array:e}).getEncodedHex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.ContentInfo,ht.asn1.ASN1Object),ht.asn1.cms.SignedData=function(t){Error;var e=ht.asn1,n=(e.ASN1Object,e.DERInteger),r=e.DERSet,i=e.DERSequence,s=(e.DERTaggedObject,e.cms),a=s.EncapsulatedContentInfo,o=s.SignerInfo,u=s.ContentInfo,h=s.CertificateSet,c=s.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;ht.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},n=t.sinfos,r=0;r<n.length;r++){e[n[r].hashalg]=1}t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,n=t.sinfos,r=0;r<n.length;r++){var i=n[r];this._getAttrParamByName(i,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,n=(t.econtent.type,e.content.hex);null==n&&"data"==e.type&&null!=e.content.str&&(n=Ft(e.content.str));for(var r=t.sinfos,i=0;i<r.length;i++){var s=r[i],a=s.hashalg,o=this._getAttrParamByName(s,"messageDigest"),u=ht.crypto.Util.hashHex(n,a);o.hex=u}},this._getAttrParamByName=function(t,e){for(var n=t.sattrs.array,r=0;r<n.length;r++)if(n[r].attr==e)return n[r]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,n=0;n<e.length;n++){var r=e[n],i=1;"skid"==r.id.type&&(i=3),r.version=i}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,n=0;n<e.length;n++){if(null!=e[n].ocsp)return 5}var r=t.sinfos;for(n=0;n<r.length;n++){if(3==t.sinfos[n].version)return 3}return"data"!=t.econtent.type?3:1},this.getEncodedHex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new n({int:t.version}));for(var s=[],u=0;u<t.hashalgs.length;u++){var f=t.hashalgs[u];s.push(new l({name:f}))}e.push(new r({array:s})),e.push(new a(t.econtent)),null!=t.certs&&e.push(new h(t.certs)),null!=t.revinfos&&e.push(new c(t.revinfos));var d=[];for(u=0;u<t.sinfos.length;u++){var g=t.sinfos[u];d.push(new o(g))}return e.push(new r({array:d})),new i({array:e}).getEncodedHex()},this.getContentInfo=function(){return new u({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.SignedData,ht.asn1.ASN1Object),ht.asn1.cms.CertificateSet=function(t){ht.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,n=ht.asn1,r=n.DERTaggedObject,i=n.DERSet,s=n.ASN1Object;this.params=null,this.getEncodedHex=function(){var t,n=this.params,a=[];if(n instanceof Array)t=n;else{if(null==n.array)throw new e("cert array not specified");t=n.array}for(var o=0;o<t.length;o++){var u=Dt(t[o]),h=new s;h.hTLV=u,a.push(h)}var c={array:a};0==n.sortflag&&(c.sortflag=!1);var l=new i(c);return new r({tag:"a0",explicit:!1,obj:l}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.CertificateSet,ht.asn1.ASN1Object),ht.asn1.cms.RevocationInfoChoices=function(t){ht.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],n=0;n<t.length;n++)e.push(new ht.asn1.cms.RevocationInfoChoice(t[n]));return ht.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.RevocationInfoChoices,ht.asn1.ASN1Object),ht.asn1.cms.RevocationInfoChoice=function(t){ht.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=Dt(t.crl)),e}if(null!=t.ocsp)return ht.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new ht.asn1.cms.OtherRevocationFormat(t)}}).getEncodedHex();throw new Error("property crl or ocsp undefined")},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.RevocationInfoChoice,ht.asn1.ASN1Object),ht.asn1.cms.OtherRevocationFormat=function(t){ht.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,n=ht,r=n.asn1.ASN1Util.newObject,i=n.lang.String.isHex;this.params=null,this.getEncodedHex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!i(t.ocsp)||!ft.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return r({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cms.OtherRevocationFormat,ht.asn1.ASN1Object),ht.asn1.cms.CMSUtil=new function(){},ht.asn1.cms.CMSUtil.newSignedData=function(t){return new ht.asn1.cms.SignedData(t)},ht.asn1.cms.CMSUtil.verifySignedData=function(t){var e=ht,n=e.asn1,r=n.cms,i=(r.SignerInfo,r.SignedData,r.SigningTime,r.SigningCertificate,r.SigningCertificateV2,n.cades.SignaturePolicyIdentifier,e.lang.String.isHex),s=ft,a=s.getVbyList,o=s.getTLVbyList,u=s.getIdxbyList,h=s.getChildIdx,c=s.getTLV,l=s.oidname,f=e.crypto.Util.hashHex;void 0===t.cms&&i(t.cms);var d=t.cms,g=function(t,e){var n=e.idx;e.signerid_issuer1=o(t,n,[1,0],"30"),e.signerid_serial1=a(t,n,[1,1],"02"),e.hashalg=l(a(t,n,[2,0],"06"));var r=u(t,n,[3],"a0");e.idxSignedAttrs=r,p(t,e,r);var i=h(t,n).length;if(i<6)throw"malformed SignerInfo";e.sigalg=l(a(t,n,[i-2,0],"06")),e.sigval=a(t,n,[i-1],"04")},p=function(t,e,n){var r=h(t,n);e.signedAttrIdxList=r;for(var i=0;i<r.length;i++){var s,o=r[i],u=a(t,o,[0],"06");"2a864886f70d010905"===u?(s=Et(a(t,o,[1,0])),e.saSigningTime=s):"2a864886f70d010904"===u&&(s=a(t,o,[1,0],"04"),e.saMessageDigest=s)}},v=function(t,e,n,r){n.verifyDetail={};var i=n.verifyDetail,s=e.parse.econtent,a=n.hashalg,o=n.saMessageDigest;i.validMessageDigest=!1,f(s,a)===o&&(i.validMessageDigest=!0),function(t,e,n,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var a=h(t,s),o=0;o<a.length;o++){var u=c(t,a[o]),l=new Xt;l.readCertHex(u),i[o]=l,e.certkeys[o]=l.getPublicKey()}e.certs=i}else i=e.certs;e.cccc=i.length,e.cccci=a.length;for(o=0;o<i.length;o++){var f=l.getIssuerHex(),d=l.getSerialNumberHex();n.signerid_issuer1===f&&n.signerid_serial1===d&&(n.certkey_idx=o)}}(t,e,n),i.validSignatureValue=!1;var u=n.sigalg,l="31"+c(t,n.idxSignedAttrs).substr(2);n.signedattrshex=l;var d=e.certs[n.certkey_idx].getPublicKey(),g=new ht.crypto.Signature({alg:u});g.init(d),g.updateHex(l);var p=g.verify(n.sigval);i.validSignatureValue_isValid=p,!0===p&&(i.validSignatureValue=!0),n.isValid=!1,i.validMessageDigest&&i.validSignatureValue&&(n.isValid=!0)},y={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==a(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=a(t,0,[1,0,2,1,0]),function(t,e){for(var n,r=3;r<6;r++)if(void 0!==(n=u(t,0,[1,0,r]))){var i=t.substr(n,2);"a0"===i&&(e.certsIdx=n),"a1"===i&&(e.revinfosIdx=n),"31"===i&&(e.signerinfosIdx=n)}}(t,e),e.signerInfos=[],function(t,e){var n=e.signerinfosIdx;if(void 0!==n){var r=h(t,n);e.signerInfoIdxList=r;for(var i=0;i<r.length;i++){var s={idx:r[i]};g(t,s),e.signerInfos.push(s)}}}(t,e)}(d,y.parse),function(t,e){for(var n=e.parse.signerInfos,r=n.length,i=!0,s=0;s<r;s++){var a=n[s];v(t,e,a,s),a.isValid||(i=!1)}e.isValid=i}(d,y),y},ht.asn1.cms.CMSParser=function(){var t=Error,e=Xt,n=new e,r=ft,i=r.getV,s=r.getTLV,a=(r.getIdxbyList,r.getTLVbyList),o=r.getTLVbyListEx,u=r.getVbyList,h=r.getVbyListEx,c=r.getChildIdx;this.getCMSSignedData=function(t){var e=a(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=c(t,0),n={},r=i(t,e[0]),a=parseInt(r,16);n.version=a;var u=s(t,e[1]);n.hashalgs=this.getHashAlgArray(u);var h=s(t,e[2]);n.econtent=this.getEContent(h);var l=o(t,0,["[0]"]);null!=l&&(n.certs=this.getCertificateSet(l));o(t,0,["[1]"]);var f=o(t,0,[3]);return n.sinfos=this.getSignerInfos(f),n},this.getHashAlgArray=function(t){for(var n=c(t,0),r=new e,i=[],a=0;a<n.length;a++){var o=s(t,n[a]),u=r.getAlgorithmIdentifierName(o);i.push(u)}return i},this.getEContent=function(t){var e={},n=u(t,0,[0]),r=u(t,0,[1,0]);return e.type=ht.asn1.x509.OID.oid2name(ft.hextooidstr(n)),e.content={hex:r},e},this.getSignerInfos=function(t){for(var e=[],n=c(t,0),r=0;r<n.length;r++){var i=s(t,n[r]),a=this.getSignerInfo(i);e.push(a)}return e},this.getSignerInfo=function(t){var e={},i=c(t,0),a=r.getInt(t,i[0],-1);-1!=a&&(e.version=a);var u=s(t,i[1]),l=this.getIssuerAndSerialNumber(u);e.id=l;var f=s(t,i[2]),d=n.getAlgorithmIdentifierName(f);e.hashalg=d;var g=o(t,0,["[0]"]);if(null!=g){var p=this.getAttributeList(g);e.sattrs=p}var v=o(t,0,[3]),y=n.getAlgorithmIdentifierName(v);e.sigalg=y;var m=h(t,0,[4]);e.sighex=m;var x=o(t,0,["[1]"]);if(null!=x){var S=this.getAttributeList(x);e.uattrs=S}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},r=c(t,0),a=s(t,r[0]);e.issuer=n.getX500Name(a);var o=i(t,r[1]);return e.serial={hex:o},e},this.getAttributeList=function(t){for(var e=[],n=c(t,0),r=0;r<n.length;r++){var i=s(t,n[r]),a=this.getAttribute(i);e.push(a)}return{array:e}},this.getAttribute=function(t){var e={},n=c(t,0),i=r.getOID(t,n[0]),a=ht.asn1.x509.OID.oid2name(i);e.attr=a;var o=s(t,n[1]),u=c(o,0);if(1==u.length)e.valhex=s(o,u[0]);else{for(var h=[],l=0;l<u.length;l++)h.push(s(o,u[l]));e.valhex=h}return"contentType"==a?this.setContentType(e):"messageDigest"==a?this.setMessageDigest(e):"signingTime"==a?this.setSigningTime(e):"signingCertificate"==a?this.setSigningCertificate(e):"signingCertificateV2"==a?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==a&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=r.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=Et(i(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=i(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=c(t.valhex,0);if(e.length>0){for(var n=s(t.valhex,e[0]),r=c(n,0),i=[],a=0;a<r.length;a++){var o=s(n,r[a]),u=this.getESSCertID(o);i.push(u)}t.array=i}if(e.length>1){var h=s(t.valhex,e[1]);t.polhex=h}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var n=c(t.valhex,0);if(n.length>0){var a=r.getOID(t.valhex,n[0]);t.oid=a}if(n.length>1){var o=new e,u=c(t.valhex,n[1]),h=s(t.valhex,u[0]),l=o.getAlgorithmIdentifierName(h);t.alg=l;var f=i(t.valhex,u[1]);t.hash=f}delete t.valhex},this.setSigningCertificateV2=function(t){var e=c(t.valhex,0);if(e.length>0){for(var n=s(t.valhex,e[0]),r=c(n,0),i=[],a=0;a<r.length;a++){var o=s(n,r[a]),u=this.getESSCertIDv2(o);i.push(u)}t.array=i}if(e.length>1){var h=s(t.valhex,e[1]);t.polhex=h}delete t.valhex},this.getESSCertID=function(t){var e={},n=c(t,0);if(n.length>0){var r=i(t,n[0]);e.hash=r}if(n.length>1){var a=s(t,n[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var r={},a=c(e,0);if(a.length<1||3<a.length)throw new t("wrong number of elements");var o=0;if("30"==e.substr(a[0],2)){var u=s(e,a[0]);r.alg=n.getAlgorithmIdentifierName(u),o++}else r.alg="sha256";var h=i(e,a[o]);if(r.hash=h,a.length>o+1){var l=s(e,a[o+1]),f=this.getIssuerSerial(l);r.issuer=f.issuer,r.serial=f.serial}return r},this.getIssuerSerial=function(t){var e={},r=c(t,0),a=s(t,r[0]),o=n.getGeneralNames(a)[0].dn;e.issuer=o;var u=i(t,r[1]);return e.serial={hex:u},e},this.getCertificateSet=function(t){for(var e=c(t,0),n=[],r=0;r<e.length;r++){var i=s(t,e[r]);if("30"==i.substr(0,2)){var a=Pt(i,"CERTIFICATE");n.push(a)}}return{array:n,sortflag:!1}}},void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),void 0!==ht.asn1.tsp&&ht.asn1.tsp||(ht.asn1.tsp={}),ht.asn1.tsp.TimeStampToken=function(t){var e=ht.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.TimeStampToken,ht.asn1.cms.SignedData),ht.asn1.tsp.TSTInfo=function(t){Error;var e=ht.asn1,n=e.DERSequence,r=e.DERInteger,i=e.DERBoolean,s=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,u=e.tsp,h=u.MessageImprint,c=u.Accuracy,l=(e.x509.X500Name,e.x509.GeneralName);if(u.TSTInfo.superclass.constructor.call(this),this.dVersion=new r({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.getEncodedHex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new n({array:t});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new h(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new r(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new i),void 0!==t.nonce&&(this.dNonce=new r(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},i.lang.extend(ht.asn1.tsp.TSTInfo,ht.asn1.ASN1Object),ht.asn1.tsp.Accuracy=function(t){var e=ht.asn1,n=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),n({seq:e}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.Accuracy,ht.asn1.ASN1Object),ht.asn1.tsp.MessageImprint=function(t){var e=ht.asn1,n=e.DERSequence,r=e.DEROctetString,i=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=new i({name:t.alg}),s=new r({hex:t.hash});return new n({array:[e,s]}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.MessageImprint,ht.asn1.ASN1Object),ht.asn1.tsp.TimeStampReq=function(t){var e=ht.asn1,n=e.DERSequence,r=e.DERInteger,i=e.DERBoolean,s=(e.ASN1Object,e.DERObjectIdentifier),a=e.tsp,o=a.MessageImprint;a.TimeStampReq.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=[];return e.push(new r({int:1})),t.messageImprint instanceof ht.asn1.ASN1Object?e.push(t.messageImprint):e.push(new o(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new r(t.nonce)),1==t.certreq&&e.push(new i),new n({array:e}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.TimeStampReq,ht.asn1.ASN1Object),ht.asn1.tsp.TimeStampResp=function(t){var e=ht.asn1,n=e.DERSequence,r=(e.ASN1Object,e.tsp),i=r.PKIStatusInfo;r.TimeStampResp.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,s=[new i(t.statusinfo)];return null!=t.econtent&&s.push(new r.TimeStampToken(t).getContentInfo()),null!=t.tst&&t.tst instanceof e.ASN1Object&&s.push(t.tst),new n({array:s}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.TimeStampResp,ht.asn1.ASN1Object),ht.asn1.tsp.PKIStatusInfo=function(t){var e=Error,n=ht.asn1,r=n.DERSequence,i=n.tsp,s=i.PKIStatus,a=i.PKIFreeText,o=i.PKIFailureInfo;i.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,n=[];if("string"==typeof t)n.push(new s(t));else{if(null==t.status)throw new e("property 'status' unspecified");n.push(new s(t.status)),null!=t.statusstr&&n.push(new a(t.statusstr)),null!=t.failinfo&&n.push(new o(t.failinfo))}return new r({array:n}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.PKIStatusInfo,ht.asn1.ASN1Object),ht.asn1.tsp.PKIStatus=function(t){var e=Error,n=ht.asn1,r=n.DERInteger;n.tsp.PKIStatus.superclass.constructor.call(this);var i={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.getEncodedHex=function(){var t,n=this.params;if("string"==typeof n)try{t=i[n]}catch(t){throw new e("undefined name: "+n)}else{if("number"!=typeof n)throw new e("unsupported params");t=n}return new r({int:t}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.PKIStatus,ht.asn1.ASN1Object),ht.asn1.tsp.PKIFreeText=function(t){var e=Error,n=ht.asn1,r=n.DERSequence,i=n.DERUTF8String;n.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if(!t instanceof Array)throw new e("wrong params: not array");for(var n=[],s=0;s<t.length;s++)n.push(new i({str:t[s]}));return new r({array:n}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.PKIFreeText,ht.asn1.ASN1Object),ht.asn1.tsp.PKIFailureInfo=function(t){var e=Error,n=ht.asn1,r=n.DERBitString,i=n.tsp.PKIFailureInfo,s={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};i.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t,n=this.params;if("string"==typeof n)try{t=s[n]}catch(t){throw new e("undefined name: "+n)}else{if("number"!=typeof n)throw new e("wrong params");t=n}return new r({bin:t.toString(2)}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.tsp.PKIFailureInfo,ht.asn1.ASN1Object),ht.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},ht.asn1.tsp.SimpleTSAAdapter=function(t){var e=ht,n=e.asn1.tsp,r=e.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var i=r(t,e);this.params.econtent.content.messageImprint={alg:e,hash:i},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new n.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.tsp.SimpleTSAAdapter,ht.asn1.tsp.AbstractTSAAdapter),ht.asn1.tsp.FixedTSAAdapter=function(t){var e=ht,n=e.asn1.tsp,r=e.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var i=r(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:i},new n.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},i.lang.extend(ht.asn1.tsp.FixedTSAAdapter,ht.asn1.tsp.AbstractTSAAdapter),ht.asn1.tsp.TSPUtil=new function(){},ht.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new ht.asn1.tsp.TimeStampToken(t)},ht.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){var e=ft,n=e.getChildIdx,r=e.getV,i=e.getTLV,s={certreq:!1},a=n(t,0);if(a.length<2)throw"TimeStampReq must have at least 2 items";var o=i(t,a[1]);s.messageImprint=ht.asn1.tsp.TSPUtil.parseMessageImprint(o);for(var u=2;u<a.length;u++){var h=a[u],c=t.substr(h,2);if("06"==c){var l=r(t,h);s.policy=e.hextooidstr(l)}"02"==c&&(s.nonce=r(t,h)),"01"==c&&(s.certreq=!0)}return s},ht.asn1.tsp.TSPUtil.parseMessageImprint=function(t){var e=ft,n=e.getChildIdx,r=e.getV,i=e.getIdxbyList,s={};if("30"!=t.substr(0,2))throw"head of messageImprint hex shall be '30'";n(t,0);var a=r(t,i(t,0,[0,0])),o=e.hextooidstr(a),u=ht.asn1.x509.OID.oid2name(o);if(""==u)throw"hashAlg name undefined: "+o;var h=u,c=i(t,0,[1]);return s.alg=h,s.hash=r(t,c),s},ht.asn1.tsp.TSPParser=function(){Error;var t=new Xt,e=ft,n=e.getV,r=e.getTLV,i=e.getIdxbyList,s=(e.getTLVbyListEx,e.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=s(t,0);if(1==e.length)return this.getPKIStatusInfo(r(t,e[0]));if(e.length>1){var n=this.getPKIStatusInfo(r(t,e[0])),i=r(t,e[1]),a=this.getToken(i);return a.statusinfo=n,a}},this.getToken=function(t){var e=(new ht.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var n=e.content.hex,r=this.getTSTInfo(n);e.content=r}},this.getTSTInfo=function(e){var i={},a=s(e,0),o=n(e,a[1]);i.policy=Kt(o);var u=r(e,a[2]);i.messageImprint=this.getMessageImprint(u);var h=n(e,a[3]);i.serial={hex:h};var c=n(e,a[4]);i.genTime={str:Et(c)};var l=0;if(a.length>5&&"30"==e.substr(a[5],2)){var f=r(e,a[5]);i.accuracy=this.getAccuracy(f),l++}a.length>5+l&&"01"==e.substr(a[5+l],2)&&("ff"==n(e,a[5+l])&&(i.ordering=!0),l++);if(a.length>5+l&&"02"==e.substr(a[5+l],2)){var d=n(e,a[5+l]);i.nonce={hex:d},l++}if(a.length>5+l&&"a0"==e.substr(a[5+l],2)){var g=r(e,a[5+l]);g="30"+g.substr(2),pGeneralNames=t.getGeneralNames(g);var p=pGeneralNames[0].dn;i.tsa=p,l++}if(a.length>5+l&&"a1"==e.substr(a[5+l],2)){var v=r(e,a[5+l]);v="30"+v.substr(2);var y=t.getExtParamArray(v);i.ext=y,l++}return i},this.getAccuracy=function(t){for(var e={},r=s(t,0),i=0;i<r.length;i++){var a=t.substr(r[i],2),o=n(t,r[i]),u=parseInt(o,16);"02"==a?e.seconds=u:"80"==a?e.millis=u:"81"==a&&(e.micros=u)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var r={},a=(s(t,0),i(t,0,[0,0])),o=n(t,a),u=e.hextooidstr(o),h=ht.asn1.x509.OID.oid2name(u);if(""==h)throw new Error("hashAlg name undefined: "+u);var c=h,l=i(t,0,[1]);return r.alg=c,r.hash=n(t,l),r},this.getPKIStatusInfo=function(t){var e={},i=s(t,0),o=0;try{var u=n(t,i[0]),h=parseInt(u,16);e.status=a[h]}catch(t){}if(i.length>1&&"30"==t.substr(i[1],2)){var c=r(t,i[1]);e.statusstr=this.getPKIFreeText(c),o++}if(i.length>o&&"03"==t.substr(i[1+o],2)){var l=r(t,i[1+o]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var n=[],r=s(t,0),i=0;i<r.length;i++)n.push(e.getString(t,r[i]));return n},this.getPKIFailureInfo=function(t){var n=e.getInt(t,0);return null!=o[n]?o[n]:n}},void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),void 0!==ht.asn1.cades&&ht.asn1.cades||(ht.asn1.cades={}),ht.asn1.cades.SignaturePolicyIdentifier=function(t){var e=ht.asn1.cades,n=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new n(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.SignaturePolicyIdentifier,ht.asn1.cms.Attribute),ht.asn1.cades.SignaturePolicyId=function(t){var e=ht.asn1,n=e.DERSequence,r=e.DERObjectIdentifier,i=(e.x509.AlgorithmIdentifier,e.cades),s=i.SignaturePolicyId,a=i.OtherHashAlgAndValue;s.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,e=[];return e.push(new r(t.oid)),e.push(new a(t)),new n({array:e}).getEncodedHex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.SignaturePolicyId,ht.asn1.ASN1Object),ht.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,n=ht.asn1,r=n.DERSequence,i=n.DEROctetString,s=n.x509.AlgorithmIdentifier;n.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var n=null;if(null!=t.hash)n=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var a=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(a=Dt(t.cert)),n=ht.crypto.Util.hashHex(a,t.alg)}var o=[];return o.push(new s({name:t.alg})),o.push(new i({hex:n})),new r({array:o}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.OtherHashAlgAndValue,ht.asn1.ASN1Object),ht.asn1.cades.OtherHashValue=function(t){ht.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,n=ht,r=(n.lang.String.isHex,n.asn1.DEROctetString);n.crypto.Util.hashHex;this.params=null,this.getEncodedHex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var n=null;if(null!=t.hash)n=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var i=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(i=Dt(t.cert)),n=ht.crypto.Util.hashHex(i,"sha1")}return new r({hex:n}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.OtherHashValue,ht.asn1.ASN1Object),ht.asn1.cades.SignatureTimeStamp=function(t){var e=Error,n=ht,r=n.lang.String.isHex,i=n.asn1,s=i.ASN1Object;i.x509;i.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(r(t.tst))return(i=new s).hTLV=t.tst,[i];if(t.tst instanceof s)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var n=t.res;if(n instanceof s&&(n=n.getEncodedHex()),"string"!=typeof n||!r(n))throw new e("params.res has wrong value");var i;ft.getTLVbyList(n,0,[1]);return(i=new s).hTLV=t.tst,[i]}},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.SignatureTimeStamp,ht.asn1.cms.Attribute),ht.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,n=ht,r=n.asn1,i=r.DERSequence,s=r.cades,a=s.OtherCertID,o=n.lang.String.isHex;s.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,n=[],r=0;r<t.array.length;r++){var s=t.array[r];if("string"==typeof s)if(-1!=s.indexOf("-----BEGIN"))s={cert:s};else{if(!o(s))throw new e("unsupported value: "+s);s={hash:s}}null!=t.alg&&null==s.alg&&(s.alg=t.alg),null!=t.hasis&&null==s.hasis&&(s.hasis=t.hasis);var u=new a(s);n.push(u)}return[new i({array:n})]},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.CompleteCertificateRefs,ht.asn1.cms.Attribute),ht.asn1.cades.OtherCertID=function(t){var e=ht.asn1,n=e.DERSequence,r=e.cms.IssuerSerial,i=e.cades,s=i.OtherHashValue,a=i.OtherHashAlgAndValue;i.OtherCertID.superclass.constructor.call(this),this.params=t,this.getEncodedHex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e=[],i=null;if(i=null!=t.alg?new a(t):new s(t),e.push(i),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var o=new r(t);e.push(o)}return new n({array:e}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.OtherCertID,ht.asn1.ASN1Object),ht.asn1.cades.OtherHash=function(t){Error;var e=ht,n=e.asn1,r=(n.cms,n.cades),i=r.OtherHashAlgAndValue,s=r.OtherHashValue,a=(e.crypto.Util.hashHex,e.lang.String.isHex);r.OtherHash.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:a(t)&&(t={hash:t}));return(null!=t.alg?new i(t):new s(t)).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.cades.OtherHash,ht.asn1.ASN1Object),ht.asn1.cades.CAdESUtil=new function(){},ht.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new ht.asn1.cms.CMSParser).getCMSSignedData(t)},ht.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,n){var r=ft,i=r.getChildIdx,s=r.getTLV,a=r.getV,o=ht.asn1,u=o.ASN1Object,h=o.cms,c=h.AttributeList,l=h.SignerInfo,f={},d=i(t,e);if(6!=d.length)throw"not supported items for SignerInfo (!=6)";var g=d.shift();f.version=s(t,g);var p=d.shift();f.si=s(t,p);var v=d.shift();f.digalg=s(t,v);var y=d.shift();f.sattrs=s(t,y);var m=d.shift();f.sigalg=s(t,m);var x=d.shift();f.sig=s(t,x),f.sigval=a(t,x);var S=null;return f.obj=new l,(S=new u).hTLV=f.version,f.obj.dCMSVersion=S,(S=new u).hTLV=f.si,f.obj.dSignerIdentifier=S,(S=new u).hTLV=f.digalg,f.obj.dDigestAlgorithm=S,(S=new u).hTLV=f.sattrs,f.obj.dSignedAttrs=S,(S=new u).hTLV=f.sigalg,f.obj.dSigAlg=S,(S=new u).hTLV=f.sig,f.obj.dSig=S,f.obj.dUnsignedAttrs=new c,f},void 0!==ht.asn1.csr&&ht.asn1.csr||(ht.asn1.csr={}),ht.asn1.csr.CertificationRequest=function(t){var e=ht.asn1,n=e.DERBitString,r=e.DERSequence,i=e.csr,s=(e.x509,i.CertificationRequestInfo);i.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).getEncodedHex(),e=new ht.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var n=e.sign();this.params.sighex=n},this.getPEM=function(){return Pt(this.getEncodedHex(),"CERTIFICATE REQUEST")},this.getEncodedHex=function(){var t=this.params,e=new ht.asn1.csr.CertificationRequestInfo(this.params),i=new ht.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var s=new n({hex:"00"+t.sighex});return new r({array:[e,i,s]}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.csr.CertificationRequest,ht.asn1.ASN1Object),ht.asn1.csr.CertificationRequestInfo=function(t){var e=ht.asn1,n=(e.DERBitString,e.DERSequence),r=e.DERInteger,i=e.DERUTF8String,s=e.DERTaggedObject,a=e.ASN1Util.newObject,o=e.csr,u=e.x509,h=u.X500Name,c=u.Extensions,l=u.SubjectPublicKeyInfo;o.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.getEncodedHex=function(){var t=this.params,e=[];if(e.push(new r({int:0})),e.push(new h(t.subject)),e.push(new l(Wt.getKey(t.sbjpubkey))),null!=t.extreq){var o=new c(t.extreq),u=a({tag:{tag:"a0",explict:!0,obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[o]}]}}});e.push(u)}else e.push(new s({tag:"a0",explicit:!1,obj:new i({str:""})}));return new n({array:e}).getEncodedHex()},null!=t&&this.setByParam(t)},i.lang.extend(ht.asn1.csr.CertificationRequestInfo,ht.asn1.ASN1Object),ht.asn1.csr.CSRUtil=new function(){},ht.asn1.csr.CSRUtil.newCSRPEM=function(t){return new ht.asn1.csr.CertificationRequest(t).getPEM()},ht.asn1.csr.CSRUtil.getParam=function(t){var e=ft,n=e.getV;_getIdxbyList=e.getIdxbyList,_getTLVbyList=e.getTLVbyList,_getTLVbyListEx=e.getTLVbyListEx,_getVbyListEx=e.getVbyListEx;var r={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var i=Dt(t,"CERTIFICATE REQUEST");try{var s=_getTLVbyListEx(i,0,[0,1]);if("3000"==s)r.subject={};else{var a=new Xt;r.subject=a.getX500Name(s)}}catch(t){}var o=_getTLVbyListEx(i,0,[0,2]),u=Wt.getKey(o,null,"pkcs8pub");r.sbjpubkey=Wt.getPEM(u,"PKCS8PUB");var h,c,l=(h=i,c=_getIdxbyList(h,0,[0,3,0,0],"06"),"2a864886f70d01090e"!=n(h,c)?null:_getTLVbyList(h,0,[0,3,0,1,0],"30"));a=new Xt;null!=l&&(r.extreq=a.getExtParamArray(l));try{var f=_getTLVbyListEx(i,0,[1],"30");a=new Xt;r.sigalg=a.getAlgorithmIdentifierName(f)}catch(t){}try{var d=_getVbyListEx(i,0,[2]);r.sighex=d}catch(t){}return r},void 0!==ht&&ht||(ht={}),void 0!==ht.asn1&&ht.asn1||(ht.asn1={}),void 0!==ht.asn1.ocsp&&ht.asn1.ocsp||(ht.asn1.ocsp={}),ht.asn1.ocsp.DEFAULT_HASH="sha1",ht.asn1.ocsp.OCSPResponse=function(t){ht.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);ht.asn1.DEREnumerated;var e=ht.asn1.ASN1Util.newObject,n=ht.asn1.ocsp.ResponseBytes,r=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:r.indexOf(t)},this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=this.params,r=this._getStatusCode();if(-1==r)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=r)return e({seq:[{enum:{int:r}}]}).getEncodedHex();var i=new n(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:i}}]}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.OCSPResponse,ht.asn1.ASN1Object),ht.asn1.ocsp.ResponseBytes=function(t){ht.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=ht.asn1,n=e.DERSequence,r=e.DERObjectIdentifier,i=e.DEROctetString,s=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new s(t),a=[];return a.push(new r({name:"ocspBasic"})),a.push(new i({hex:e.getEncodedHex()})),new n({array:a}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.ResponseBytes,ht.asn1.ASN1Object),ht.asn1.ocsp.BasicOCSPResponse=function(t){ht.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,n=ht.asn1,r=n.ASN1Object,i=n.DERSequence,s=(n.DERGeneralizedTime,n.DERTaggedObject),a=n.DERBitString,o=(n.x509.Extensions,n.x509.AlgorithmIdentifier),u=n.ocsp;u.ResponderID;_SingleResponseList=u.SingleResponseList,_ResponseData=u.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.getEncodedHex(),n=new ht.crypto.Signature({alg:t.sigalg});n.init(t.reskey),n.updateHex(e),t.sighex=n.sign()},this.getEncodedHex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var n=[];if(n.push(t.tbsresp),n.push(new o({name:t.sigalg})),n.push(new a({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var u=[],h=0;h<t.certs.length;h++){var c=t.certs[h],l=null;if(ft.isASN1HEX(c))l=c;else{if(!c.match(/-----BEGIN/))throw new e("certs["+h+"] not hex or PEM");l=Dt(c)}u.push(new r({tlv:l}))}var f=new i({array:u});n.push(new s({tag:"a0",explicit:!0,obj:f}))}return new i({array:n}).getEncodedHex()},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.BasicOCSPResponse,ht.asn1.ASN1Object),ht.asn1.ocsp.ResponseData=function(t){ht.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,n=ht.asn1,r=n.DERSequence,i=n.DERGeneralizedTime,s=n.DERTaggedObject,a=n.x509.Extensions,o=n.ocsp,u=o.ResponderID;_SingleResponseList=o.SingleResponseList,this.params=null,this.getEncodedHex=function(){var t=this.params;null!=t.respid&&new e("respid not specified"),null!=t.prodat&&new e("prodat not specified"),null!=t.array&&new e("array not specified");var n=[];if(n.push(new u(t.respid)),n.push(new i(t.prodat)),n.push(new _SingleResponseList(t.array)),null!=t.ext){var o=new a(t.ext);n.push(new s({tag:"a1",explicit:!0,obj:o}))}return new r({array:n}).getEncodedHex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.ResponseData,ht.asn1.ASN1Object),ht.asn1.ocsp.ResponderID=function(t){ht.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=ht.asn1,n=e.ASN1Util.newObject,r=e.x509.X500Name;this.params=null,this.getEncodedHex=function(){var t=this.params;if(null!=t.key)return n({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:t.key}}}}).getEncodedHex();if(null!=t.name)return n({tag:{tag:"a1",explicit:!0,obj:new r(t.name)}}).getEncodedHex();throw new Error("key or name not specified")},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.ResponderID,ht.asn1.ASN1Object),ht.asn1.ocsp.SingleResponseList=function(t){ht.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=ht.asn1,n=e.DERSequence,r=e.ocsp.SingleResponse;this.params=null,this.getEncodedHex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],i=0;i<t.length;i++)e.push(new r(t[i]));return new n({array:e}).getEncodedHex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.SingleResponseList,ht.asn1.ASN1Object),ht.asn1.ocsp.SingleResponse=function(t){var e=Error,n=ht.asn1,r=n.DERSequence,i=n.DERGeneralizedTime,s=n.DERTaggedObject,a=n.ocsp,o=a.CertID,u=a.CertStatus,h=n.x509.Extensions;a.SingleResponse.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params,n=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(n.push(new o(t.certid)),n.push(new u(t.status)),n.push(new i(t.thisupdate)),null!=t.nextupdate){var a=new i(t.nextupdate);n.push(new s({tag:"a0",explicit:!0,obj:a}))}if(null!=t.ext){var c=new h(t.ext);n.push(new s({tag:"a1",explicit:!0,obj:c}))}return new r({array:n}).getEncodedHex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.SingleResponse,ht.asn1.ASN1Object),ht.asn1.ocsp.CertID=function(t){var e=ht,n=e.asn1,r=n.DEROctetString,i=n.DERInteger,s=n.DERSequence,a=n.x509.AlgorithmIdentifier,o=n.ocsp,u=o.DEFAULT_HASH,h=e.crypto.Util.hashHex,c=Xt,l=ft;if(o.CertID.superclass.constructor.call(this),this.dHashAlg=null,this.dIssuerNameHash=null,this.dIssuerKeyHash=null,this.dSerialNumber=null,this.setByValue=function(t,e,n,s){void 0===s&&(s=u),this.dHashAlg=new a({name:s}),this.dIssuerNameHash=new r({hex:t}),this.dIssuerKeyHash=new r({hex:e}),this.dSerialNumber=new i({hex:n})},this.setByCert=function(t,e,n){void 0===n&&(n=u);var r=new c;r.readCertPEM(e);var i=new c;i.readCertPEM(t);var s=i.getPublicKeyHex(),a=l.getTLVbyList(s,0,[1,0],"30"),o=r.getSerialNumberHex(),f=h(i.getSubjectHex(),n),d=h(a,n);this.setByValue(f,d,o,n),this.hoge=r.getSerialNumberHex()},this.getEncodedHex=function(){if(null===this.dHashAlg&&null===this.dIssuerNameHash&&null===this.dIssuerKeyHash&&null===this.dSerialNumber)throw"not yet set values";var t=[this.dHashAlg,this.dIssuerNameHash,this.dIssuerKeyHash,this.dSerialNumber],e=new s({array:t});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t){var f=t;if(void 0!==f.issuerCert&&void 0!==f.subjectCert){var d=u;void 0===f.alg&&(d=void 0),this.setByCert(f.issuerCert,f.subjectCert,d)}else{if(void 0===f.issname||void 0===f.isskey||void 0===f.sbjsn)throw new Error("invalid constructor arguments");d=u;void 0===f.alg&&(d=void 0),this.setByValue(f.issname,f.isskey,f.sbjsn,d)}}},i.lang.extend(ht.asn1.ocsp.CertID,ht.asn1.ASN1Object),ht.asn1.ocsp.CertStatus=function(t){ht.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.getEncodedHex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var n={tag:"a1",explicit:!1,obj:{seq:e}};return ht.asn1.ASN1Util.newObject({tag:n}).getEncodedHex()}throw new Error("bad status")},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},i.lang.extend(ht.asn1.ocsp.CertStatus,ht.asn1.ASN1Object),ht.asn1.ocsp.Request=function(t){var e=ht.asn1,n=e.DERSequence,r=e.ocsp;if(r.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.getEncodedHex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new n({array:t});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t){var i=new r.CertID(t);this.dReqCert=i}},i.lang.extend(ht.asn1.ocsp.Request,ht.asn1.ASN1Object),ht.asn1.ocsp.TBSRequest=function(t){var e=ht.asn1,n=e.DERSequence,r=e.ocsp;r.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],n=0;n<t.length;n++){var i=new r.Request(t[0]);e.push(i)}this.dRequestList=e},this.getEncodedHex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new n({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var r=new n({array:t});return this.hTLV=r.getEncodedHex(),this.hTLV},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},i.lang.extend(ht.asn1.ocsp.TBSRequest,ht.asn1.ASN1Object),ht.asn1.ocsp.OCSPRequest=function(t){var e=ht.asn1,n=e.DERSequence,r=e.ocsp;if(r.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.getEncodedHex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new n({array:t});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&void 0!==t.reqList){var i=new r.TBSRequest(t);this.dTbsRequest=i}},i.lang.extend(ht.asn1.ocsp.OCSPRequest,ht.asn1.ASN1Object),ht.asn1.ocsp.OCSPUtil={},ht.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,n){var r=ht.asn1.ocsp;void 0===n&&(n=r.DEFAULT_HASH);var i={alg:n,issuerCert:t,subjectCert:e};return new r.OCSPRequest({reqList:[i]}).getEncodedHex()},ht.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ft,n=e.getVbyList,r=e.getVbyListEx,i=e.getIdxbyList,s=(e.getIdxbyListEx,e.getV),a={};try{var o=r(t,0,[0],"0a");a.responseStatus=parseInt(o,16)}catch(t){}if(0!==a.responseStatus)return a;try{var u=i(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(u,2)?a.certStatus="good":"a1"===t.substr(u,2)?(a.certStatus="revoked",a.revocationTime=Et(n(t,u,[0]))):"82"===t.substr(u,2)&&(a.certStatus="unknown")}catch(t){}try{var h=i(t,0,[1,0,1,0,0,2,0,2]);a.thisUpdate=Et(s(t,h))}catch(t){}try{var c=i(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(c,2)&&(a.nextUpdate=Et(n(t,c,[0])))}catch(t){}return a},ht.asn1.ocsp.OCSPParser=function(){var t=Error,e=Xt,n=new e,r=ft,i=r.getV,s=r.getTLV,a=r.getIdxbyList,o=r.getTLVbyListEx,u=r.getChildIdx;this.getOCSPRequest=function(e){var n=u(e,0);if(1!=n.length&&2!=n.length)throw new t("wrong number elements: "+n.length);return this.getTBSRequest(s(e,n[0]))},this.getTBSRequest=function(t){var e={},r=o(t,0,[0],"30");e.array=this.getRequestList(r);var i=o(t,0,["[2]",0],"30");return null!=i&&(e.ext=n.getExtParamArray(i)),e},this.getRequestList=function(t){for(var e=[],n=u(t,0),r=0;r<n.length;r++){t=s(t,n[r]);e.push(this.getRequest(t))}return e},this.getRequest=function(e){var r=u(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);var i=this.getCertID(s(e,r[0]));if(2==r.length){var o=a(e,0,[1,0]);i.ext=n.getExtParamArray(s(e,o))}return i},this.getCertID=function(n){var r=u(n,0);if(4!=r.length)throw new t("wrong number elements: "+r.length);var a=new e,o={};return o.alg=a.getAlgorithmIdentifierName(s(n,r[0])),o.issname=i(n,r[1]),o.isskey=i(n,r[2]),o.sbjsn=i(n,r[3]),o}},void 0!==ht&&ht||(ht={}),void 0!==ht.lang&&ht.lang||(ht.lang={}),ht.lang.String=function(){},"function"==typeof t?(ct=function(e){return yt(t.from(e,"utf8").toString("base64"))},lt=function(e){return t.from(mt(e),"base64").toString("utf8")}):(ct=function(t){return xt(Ot(_t(t)))},lt=function(t){return decodeURIComponent(Bt(St(t)))}),ht.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},ht.lang.String.isHex=function(t){return kt(t)},ht.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},ht.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=mt(t),ht.lang.String.isBase64(t))},ht.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},ht.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},ht.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},ht.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};function Mt(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",r=parseInt(t,10).toString(2),i=7-r.length%7;7==i&&(i=0);for(var s="",a=0;a<i;a++)s+="0";r=s+r;for(a=0;a<r.length-1;a+=7){var o=r.substr(a,7);a!=r.length-7&&(o="1"+o),n+=e(parseInt(o,2))}return n};try{if(!t.match(/^[0-9.]+$/))return null;var r="",i=t.split("."),s=40*parseInt(i[0],10)+parseInt(i[1],10);r+=e(s),i.splice(0,2);for(var a=0;a<i.length;a++)r+=n(i[a]);return r}catch(t){return null}}function Kt(t){if(!kt(t))return null;try{var e=[],n=t.substr(0,2),r=parseInt(n,16);e[0]=new String(Math.floor(r/40)),e[1]=new String(r%40);for(var i=t.substr(2),s=[],a=0;a<i.length/2;a++)s.push(parseInt(i.substr(2*a,2),16));var o=[],u="";for(a=0;a<s.length;a++)128&s[a]?u+=qt((127&s[a]).toString(2),7):(u+=qt((127&s[a]).toString(2),7),o.push(new String(parseInt(u,2))),u="");var h=e.join(".");return o.length>0&&(h=h+"."+o.join(".")),h}catch(t){return null}}var qt=function(t,e,n){return null==n&&(n="0"),t.length>=e?t:new Array(e-t.length+1).join(n)+t};function Ut(t){try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var n=parseInt(e,16),r=t.substr(2),i=parseInt(r,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-n),parseInt(i,2)}catch(t){return-1}}void 0!==ht&&ht||(ht={}),void 0!==ht.crypto&&ht.crypto||(ht.crypto={}),ht.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:v.algo.MD5,sha1:v.algo.SHA1,sha224:v.algo.SHA224,sha256:v.algo.SHA256,sha384:v.algo.SHA384,sha512:v.algo.SHA512,ripemd160:v.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,n){var r=this.getDigestInfoHex(t,e),i=n/4;if(r.length+22>i)throw"key is too short for SigAlg: keylen="+n+","+e;for(var s="0001",a="00"+r,o="",u=i-s.length-a.length,h=0;h<u;h+=2)o+="ff";return s+o+a},this.hashString=function(t,e){return new ht.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new ht.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof rt||t instanceof ht.crypto.DSA||t instanceof ht.crypto.ECDSA}},ht.crypto.Util.md5=function(t){return new ht.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},ht.crypto.Util.ripemd160=function(t){return new ht.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},ht.crypto.Util.SECURERANDOMGEN=new tt,ht.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return ht.crypto.Util.SECURERANDOMGEN.nextBytes(e),pt(e)},ht.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(ht.crypto.Util.getRandomHexOfNbytes(t),16)},ht.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,n=new Array((t-e)/8+1);return ht.crypto.Util.SECURERANDOMGEN.nextBytes(n),n[0]=(255<<e&255^255)&n[0],pt(n)},ht.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(ht.crypto.Util.getRandomHexOfNbits(t),16)},ht.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var n=ht.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(n))return n}},ht.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var n=t.compareTo(e);if(1==n)throw"biMin is greater than biMax";if(0==n)return t;var r=e.subtract(t);return ht.crypto.Util.getRandomBigIntegerZeroToMax(r).add(t)},ht.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=ht.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=ht.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=ht.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=v.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(v.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=ht.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},ht.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},ht.crypto.MessageDigest.getHashLength=function(t){var e=ht.crypto.MessageDigest,n=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[n])throw"not supported algorithm: "+t;return e.HASHLENGTH[n]},ht.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},ht.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=ht.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var n=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(n)&&"cryptojs"==e){try{var r=ht.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[n];this.mac=v.algo.HMAC.create(r,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+n+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=v.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(v.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=Ft(t)),void(this.pass=v.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=bt(t.utf8)),void 0!==t.rstr&&(e=Ft(t.rstr)),void 0!==t.b64&&(e=S(t.b64)),void 0!==t.b64u&&(e=St(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=v.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=ht.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},ht.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var n="",r=e/4-t.length,i=0;i<r;i++)n+="0";return n+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new ht.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var n=null;try{n=void 0===e?Wt.getKey(t):Wt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===n.isPrivate)this.prvKey=n,this.state="SIGN";else{if(!0!==n.isPublic)throw"init failed.:"+n;this.pubKey=n,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==ht.crypto.ECDSA&&(this.prvKey=new ht.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof rt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof rt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof ht.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof ht.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==ht.crypto.ECDSA&&(this.pubKey=new ht.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof rt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof rt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==ht.crypto.ECDSA&&this.pubKey instanceof ht.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==ht.crypto.DSA&&this.pubKey instanceof ht.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=ht.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Wt.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},ht.crypto.Cipher=function(t){},ht.crypto.Cipher.encrypt=function(t,e,n){if(e instanceof rt&&e.isPublic){var r=ht.crypto.Cipher.getAlgByKeyAndName(e,n);if("RSA"===r)return e.encrypt(t);if("RSAOAEP"===r)return e.encryptOAEP(t,"sha1");var i=r.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.encryptOAEP(t,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+n}throw"Cipher.encrypt: unsupported key or algorithm"},ht.crypto.Cipher.decrypt=function(t,e,n){if(e instanceof rt&&e.isPrivate){var r=ht.crypto.Cipher.getAlgByKeyAndName(e,n);if("RSA"===r)return e.decrypt(t);if("RSAOAEP"===r)return e.decryptOAEP(t,"sha1");var i=r.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.decryptOAEP(t,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+n}throw"Cipher.decrypt: unsupported key or algorithm"},ht.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof rt){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},ht.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"}},void 0!==ht&&ht||(ht={}),void 0!==ht.crypto&&ht.crypto||(ht.crypto={}),ht.crypto.ECDSA=function(t){var e=Error,n=E,r=at,i=ht.crypto.ECDSA,s=ht.crypto.ECParameterDB,a=i.getName,o=ft,u=o.getVbyListEx,h=o.isASN1HEX,c=new tt;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new n(t.bitLength(),c).mod(t.subtract(n.ONE)).add(n.ONE)},this.setNamedCurve=function(t){this.ecparams=s.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keylen/4;if(t.length!==2+2*e)throw"malformed public key hex length";var n={};return n.x=t.substr(2,e),n.y=t.substr(2+e),n},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),n=this.ecparams.G.multiply(e),r=n.getX().toBigInteger(),i=n.getY().toBigInteger(),s=this.ecparams.keylen/4,a=("0000000000"+e.toString(16)).slice(-s),o="04"+("0000000000"+r.toString(16)).slice(-s)+("0000000000"+i.toString(16)).slice(-s);return this.setPrivateKeyHex(a),this.setPublicKeyHex(o),{ecprvhex:a,ecpubhex:o}},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var r=new n(e,16),s=this.ecparams.n,a=new n(t.substring(0,this.ecparams.keylen/4),16);do{var o=this.getBigRandom(s),u=this.ecparams.G.multiply(o).getX().toBigInteger().mod(s)}while(u.compareTo(n.ZERO)<=0);var h=o.modInverse(s).multiply(a.add(r.multiply(u))).mod(s);return i.biRSSigToASN1Sig(u,h)},this.sign=function(t,e){var r=e,i=this.ecparams.n,s=n.fromByteArrayUnsigned(t);do{var a=this.getBigRandom(i),o=this.ecparams.G.multiply(a).getX().toBigInteger().mod(i)}while(o.compareTo(E.ZERO)<=0);var u=a.modInverse(i).multiply(s.add(r.multiply(o))).mod(i);return this.serializeSig(o,u)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,s){try{var a,o,u=i.parseSigHex(e);a=u.r,o=u.s;var h=r.decodeFromHex(this.ecparams.curve,s),c=new n(t.substring(0,this.ecparams.keylen/4),16);return this.verifyRaw(c,a,o,h)}catch(t){return!1}},this.verify=function(t,e,i){var s,a,o;if(Bitcoin.Util.isArray(e)){var u=this.parseSig(e);s=u.r,a=u.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,a=e.s}if(i instanceof at)o=i;else{if(!Bitcoin.Util.isArray(i))throw"Invalid format for pubkey value, must be byte array or ECPointFp";o=r.decodeFrom(this.ecparams.curve,i)}var h=n.fromByteArrayUnsigned(t);return this.verifyRaw(h,s,a,o)},this.verifyRaw=function(t,e,r,i){var s=this.ecparams.n,a=this.ecparams.G;if(e.compareTo(n.ONE)<0||e.compareTo(s)>=0)return!1;if(r.compareTo(n.ONE)<0||r.compareTo(s)>=0)return!1;var o=r.modInverse(s),u=t.multiply(o).mod(s),h=e.multiply(o).mod(s);return a.multiply(u).add(i.multiply(h)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var n=t.toByteArraySigned(),r=e.toByteArraySigned(),i=[];return i.push(2),i.push(n.length),(i=i.concat(n)).push(2),i.push(r.length),(i=i.concat(r)).unshift(i.length),i.unshift(48),i},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var r=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:n.fromByteArrayUnsigned(r),s:n.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var r=this.ecparams.n;return{r:n.fromByteArrayUnsigned(t.slice(1,33)).mod(r),s:n.fromByteArrayUnsigned(t.slice(33,65)).mod(r),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===h(t))throw new Error("not ASN.1 hex string");var e,n,r;try{e=u(t,0,["[0]",0],"06"),n=u(t,0,[1],"04");try{r=u(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(r),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===h(t))throw new e("not ASN.1 hex string");var n,r,i;try{u(t,0,[1,0],"06"),n=u(t,0,[1,1],"06"),r=u(t,0,[2,0,1],"04");try{i=u(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(n),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===h(t))throw new e("not ASN.1 hex string");var n,r;try{u(t,0,[0,0],"06"),n=u(t,0,[0,1],"06"),r=u(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(n),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(r)},this.readCertPubKeyHex=function(t,n){if(!1===h(t))throw new e("not ASN.1 hex string");var r,i;try{r=u(t,0,[0,5,0,1],"06"),i=u(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ht.crypto.ECDSA.parseSigHex=function(t){var e=ht.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},ht.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ft,n=e.getChildIdx,r=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var i=n(t,0);if(2!=i.length)throw new Error("signature shall have two elements");var s=i[0],a=i[1];if("02"!=t.substr(s,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:r(t,s),s:r(t,a)}},ht.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ht.crypto.ECDSA.parseSigHexInHexRS(t),n=e.r,r=e.s;if("00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),"00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),n.length%32==30&&(n="00"+n),r.length%32==30&&(r="00"+r),n.length%32!=0)throw"unknown ECDSA sig r length error";if(r.length%32!=0)throw"unknown ECDSA sig s length error";return n+r},ht.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),n=t.substr(t.length/2);return ht.crypto.ECDSA.hexRSSigToASN1Sig(e,n)},ht.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var n=new E(t,16),r=new E(e,16);return ht.crypto.ECDSA.biRSSigToASN1Sig(n,r)},ht.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var n=ht.asn1,r=new n.DERInteger({bigint:t}),i=new n.DERInteger({bigint:e});return new n.DERSequence({array:[r,i]}).getEncodedHex()},ht.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ht&&ht||(ht={}),void 0!==ht.crypto&&ht.crypto||(ht.crypto={}),ht.crypto.ECParameterDB=new function(){var t={},e={};function n(t){return new E(t,16)}this.getByName=function(n){var r=n;if(void 0!==e[r]&&(r=e[n]),void 0!==t[r])return t[r];throw"unregistered EC curve name: "+r},this.regist=function(r,i,s,a,o,u,h,c,l,f,d,g){t[r]={};var p=n(s),v=n(a),y=n(o),m=n(u),x=n(h),S=new ot(p,v,y),b=S.decodePointHex("04"+c+l);t[r].name=r,t[r].keylen=i,t[r].curve=S,t[r].G=b,t[r].n=m,t[r].h=x,t[r].oid=d,t[r].info=g;for(var E=0;E<f.length;E++)e[f[E]]=r}},ht.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),ht.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),ht.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),ht.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),ht.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),ht.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),ht.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),ht.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),ht.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),ht.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==ht&&ht||(ht={}),void 0!==ht.crypto&&ht.crypto||(ht.crypto={}),ht.crypto.DSA=function(){var t=ft,e=(t.getVbyList,t.getVbyListEx),n=t.isASN1HEX,r=E;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,n,r,i){this.isPrivate=!0,this.p=t,this.q=e,this.g=n,this.y=r,this.x=i},this.setPrivateHex=function(t,e,n,r,i){var s,a,o,u,h;s=new E(t,16),a=new E(e,16),o=new E(n,16),u="string"==typeof r&&r.length>1?new E(r,16):null,h=new E(i,16),this.setPrivate(s,a,o,u,h)},this.setPublic=function(t,e,n,r){this.isPublic=!0,this.p=t,this.q=e,this.g=n,this.y=r,this.x=null},this.setPublicHex=function(t,e,n,r){var i,s,a,o;i=new E(t,16),s=new E(e,16),a=new E(n,16),o=new E(r,16),this.setPublic(i,s,a,o)},this.signWithMessageHash=function(t){var e=this.p,n=this.q,r=this.g,i=(this.y,this.x),s=ht.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),n.subtract(E.ONE)),a=new E(t.substr(0,n.bitLength()/4),16),o=r.modPow(s,e).mod(n),u=s.modInverse(n).multiply(a.add(i.multiply(o))).mod(n);return ht.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:u}}]})},this.verifyWithMessageHash=function(t,e){var n=this.p,r=this.q,i=this.g,s=this.y,a=this.parseASN1Signature(e),o=a[0],u=a[1],h=new E(t.substr(0,r.bitLength()/4),16);if(E.ZERO.compareTo(o)>0||o.compareTo(r)>0)throw"invalid DSA signature";if(E.ZERO.compareTo(u)>=0||u.compareTo(r)>0)throw"invalid DSA signature";var c=u.modInverse(r),l=h.multiply(c).mod(r),f=o.multiply(c).mod(r);return 0==i.modPow(l,n).multiply(s.modPow(f,n)).mod(n).mod(r).compareTo(o)},this.parseASN1Signature=function(t){try{return[new r(e(t,0,[0],"02"),16),new r(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var r,i,s,a,o;if(!1===n(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[1],"02"),i=e(t,0,[2],"02"),s=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(r,i,s,a,o)},this.readPKCS8PrvKeyHex=function(t){var r,i,s,a;if(!1===n(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[1,1,0],"02"),i=e(t,0,[1,1,1],"02"),s=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(r,i,s,null,a)},this.readPKCS8PubKeyHex=function(t){var r,i,s,a;if(!1===n(t))throw new Error("not ASN.1 hex string");try{r=e(t,0,[0,1,0],"02"),i=e(t,0,[0,1,1],"02"),s=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(r,i,s,a)},this.readCertPubKeyHex=function(t,r){var i,s,a,o;if(!1===n(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,5,0,1,0],"02"),s=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(i,s,a,o)}};var Wt=function(){var t=function(t,n,r){return e(v.AES,t,n,r)},e=function(t,e,n,r){var i=v.enc.Hex.parse(e),s=v.enc.Hex.parse(n),a=v.enc.Hex.parse(r),o={};o.key=s,o.iv=a,o.ciphertext=i;var u=t.decrypt(o,s,{iv:a});return v.enc.Hex.stringify(u)},n=function(t,e,n){return r(v.AES,t,e,n)},r=function(t,e,n,r){var i=v.enc.Hex.parse(e),s=v.enc.Hex.parse(n),a=v.enc.Hex.parse(r),o=t.encrypt(i,s,{iv:a}),u=v.enc.Hex.parse(o.toString());return v.enc.Base64.stringify(u)},i={"AES-256-CBC":{proc:t,eproc:n,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:n,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:n,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,n,r){return e(v.TripleDES,t,n,r)},eproc:function(t,e,n){return r(v.TripleDES,t,e,n)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,n,r){return e(v.DES,t,n,r)},eproc:function(t,e,n){return r(v.DES,t,e,n)},keylen:8,ivlen:8}},s=function(t){var e={},n=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));n&&(e.cipher=n[1],e.ivsalt=n[2]);var r=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));r&&(e.type=r[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var a=t.indexOf("-----END");if(-1!=i&&-1!=a){var o=t.substring(i+2*s,a-s);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,n){for(var r=n.substring(0,16),s=v.enc.Hex.parse(r),a=v.enc.Utf8.parse(e),o=i[t].keylen+i[t].ivlen,u="",h=null;;){var c=v.algo.MD5.create();if(null!=h&&c.update(h),c.update(a),c.update(s),h=c.finalize(),(u+=v.enc.Hex.stringify(h)).length>=2*o)break}var l={};return l.keyhex=u.substr(0,2*i[t].keylen),l.ivhex=u.substr(2*i[t].keylen,2*i[t].ivlen),l},o=function(t,e,n,r){var s=v.enc.Base64.parse(t),a=v.enc.Hex.stringify(s);return(0,i[e].proc)(a,n,r)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,n){return a(t,e,n)},decryptKeyB64:function(t,e,n,r){return o(t,e,n,r)},getDecryptedKeyHex:function(t,e){var n=s(t),r=(n.type,n.cipher),i=n.ivsalt,u=n.data,h=a(r,e,i).keyhex;return o(u,r,h,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,n,r,s){var o="";if(void 0!==r&&null!=r||(r="AES-256-CBC"),void 0===i[r])throw"KEYUTIL unsupported algorithm: "+r;void 0!==s&&null!=s||(s=function(t){var e=v.lib.WordArray.random(t);return v.enc.Hex.stringify(e)}(i[r].ivlen).toUpperCase());var u=function(t,e,n,r){return(0,i[e].eproc)(t,n,r)}(e,r,a(r,n,s).keyhex,s);o="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+r+","+s+"\r\n",o+="\r\n",o+=u.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=ft,n=e.getChildIdx,r=e.getV,i={},s=n(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;i.ciphertext=r(t,s[1]);var a=n(t,s[0]);if(2!=a.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+a.length;if("2a864886f70d01050d"!=r(t,a[0]))throw"this only supports pkcs5PBES2";var o=n(t,a[1]);if(2!=a.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+o.length;var u=n(t,o[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=r(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=r(t,u[1]);var h=n(t,o[0]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length;if("2a864886f70d01050c"!=r(t,h[0]))throw"this only supports pkcs5PBKDF2";var c=n(t,h[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;i.pbkdf2Salt=r(t,c[0]);var l=r(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return i},getPBKDF2KeyHexFromParam:function(t,e){var n=v.enc.Hex.parse(t.pbkdf2Salt),r=t.pbkdf2Iter,i=v.PBKDF2(e,n,{keySize:6,iterations:r});return v.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var n=Dt(t,"ENCRYPTED PRIVATE KEY"),r=this.parseHexOfEncryptedPKCS8(n),i=Wt.getPBKDF2KeyHexFromParam(r,e),s={};s.ciphertext=v.enc.Hex.parse(r.ciphertext);var a=v.enc.Hex.parse(i),o=v.enc.Hex.parse(r.encryptionSchemeIV),u=v.TripleDES.decrypt(s,a,{iv:o});return v.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(t,e){var n=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(n)},parsePlainPrivatePKCS8Hex:function(t){var e=ft,n=e.getChildIdx,r=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=n(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var a=n(t,s[1]);if(2!=a.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 private key(code:005)";if(i.algoid=r(t,a[0]),"06"==t.substr(a[1],2)&&(i.algparam=r(t,a[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Dt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,n=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==n.algoid)e=new rt;else if("2a8648ce380401"==n.algoid)e=new ht.crypto.DSA;else{if("2a8648ce3d0201"!=n.algoid)throw"unsupported private key algorithm";e=new ht.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,n=ft.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===n)e=new rt;else if("2a8648ce380401"===n)e=new ht.crypto.DSA;else{if("2a8648ce3d0201"!==n)throw"unsupported PKCS#8 public key hex";e=new ht.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ft,n=e.getChildIdx,r=e.getV,i={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=n(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(i.n=r(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return i.e=r(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=ft,n=e.getChildIdx,r=e.getV,i={algparam:null},s=n(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var a=s[0];if("30"!=t.substr(a,2))throw"malformed PKCS8 public key(code:001)";var o=n(t,a);if(2!=o.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 public key(code:003)";if(i.algoid=r(t,o[0]),"06"==t.substr(o[1],2)?i.algparam=r(t,o[1]):"30"==t.substr(o[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,o[1],[0],"02"),i.algparam.q=e.getVbyList(t,o[1],[1],"02"),i.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return i.key=r(t,s[1]).substr(2),i}}}();Wt.getKey=function(t,e,n){var r=(v=ft).getChildIdx,i=(v.getV,v.getVbyList),s=ht.crypto,a=s.ECDSA,o=s.DSA,u=rt,h=Dt,c=Wt;if(void 0!==u&&t instanceof u)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(t.n,t.e),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(P=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),P;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(P=new u).setPrivate(t.n,t.e,t.d),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(P=new o).setPublic(t.p,t.q,t.g,t.y),P;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(P=new o).setPrivate(t.p,t.q,t.g,t.y,t.x),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(P=new u).setPublic(St(t.n),St(t.e)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(P=new u).setPrivateEx(St(t.n),St(t.e),St(t.d),St(t.p),St(t.q),St(t.dp),St(t.dq),St(t.qi)),P;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(P=new u).setPrivate(St(t.n),St(t.e),St(t.d)),P;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(I=new a({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+St(t.x)).slice(-l)+("0000000000"+St(t.y)).slice(-l);return I.setPublicKeyHex(f),I}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(I=new a({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+St(t.x)).slice(-l)+("0000000000"+St(t.y)).slice(-l);var d=("0000000000"+St(t.d)).slice(-l);return I.setPublicKeyHex(f),I.setPrivateKeyHex(d),I}if("pkcs5prv"===n){var g,p=t,v=ft;if(9===(g=r(p,0)).length)(P=new u).readPKCS5PrvKeyHex(p);else if(6===g.length)(P=new o).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(P=new a).readPKCS5PrvKeyHex(p)}return P}if("pkcs8prv"===n)return P=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===n)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===n)return Xt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Xt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var y=Dt(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(y)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=h(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=i(T=h(t,"DSA PRIVATE KEY"),0,[1],"02"),S=i(T,0,[2],"02"),b=i(T,0,[3],"02"),w=i(T,0,[4],"02"),F=i(T,0,[5],"02");return(P=new o).setPrivate(new E(x,16),new E(S,16),new E(b,16),new E(w,16),new E(F,16)),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){m=h(t,"EC PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),C=new rt;return C.readPKCS5PrvKeyHex(A),C}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I,P=i(T=c.getDecryptedKeyHex(t,e),0,[1],"04"),D=i(T,0,[2,0],"06"),R=i(T,0,[3,0],"03").substr(2);if(void 0===ht.crypto.OID.oidhex2name[D])throw"undefined OID(hex) in KJUR.crypto.OID: "+D;return(I=new a({curve:ht.crypto.OID.oidhex2name[D]})).setPublicKeyHex(R),I.setPrivateKeyHex(P),I.isPublic=!1,I}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var T;x=i(T=c.getDecryptedKeyHex(t,e),0,[1],"02"),S=i(T,0,[2],"02"),b=i(T,0,[3],"02"),w=i(T,0,[4],"02"),F=i(T,0,[5],"02");return(P=new o).setPrivate(new E(x,16),new E(S,16),new E(b,16),new E(w,16),new E(F,16)),P}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Wt.generateKeypair=function(t,e){if("RSA"==t){var n=e;(a=new rt).generate(n,"10001"),a.isPrivate=!0,a.isPublic=!0;var r=new rt,i=a.n.toString(16),s=a.e.toString(16);return r.setPublic(i,s),r.isPrivate=!1,r.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=r,o}if("EC"==t){var a,o,u=e,h=new ht.crypto.ECDSA({curve:u}).generateKeyPairHex();return(a=new ht.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),a.setPrivateKeyHex(h.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(r=new ht.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),r.isPrivate=!1,r.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=r,o}throw"unknown algorithm: "+t},Wt.getPEM=function(t,e,n,r,i,s){var a=ht,o=a.asn1,u=o.DERObjectIdentifier,h=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,f=a.crypto,d=f.DSA,g=f.ECDSA,p=rt;function y(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function x(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Pt(w=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===n||null==n)&&1==t.isPrivate)return Pt(w=y(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===n||null==n)&&1==t.isPrivate){var S=new u({name:t.curveName}).getEncodedHex(),b=m(t).getEncodedHex(),E="";return E+=Pt(S,"EC PARAMETERS"),E+=Pt(b,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===n||null==n)&&1==t.isPrivate)return Pt(w=x(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==n&&null!=n&&1==t.isPrivate){var w=y(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,n,r,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==n&&null!=n&&1==t.isPrivate){w=m(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,n,r,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==n&&null!=n&&1==t.isPrivate){w=x(t).getEncodedHex();return void 0===r&&(r="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,n,r,s)}var F=function(t,e){var n=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:n.pbkdf2Salt}},{int:n.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:n.encryptionSchemeIV}}]}]}]},{octstr:{hex:n.ciphertext}}]}).getEncodedHex()},A=function(t,e){var n=v.lib.WordArray.random(8),r=v.lib.WordArray.random(8),i=v.PBKDF2(e,n,{keySize:6,iterations:100}),s=v.enc.Hex.parse(t),a=v.TripleDES.encrypt(s,i,{iv:r})+"",o={};return o.ciphertext=a,o.pbkdf2Salt=v.enc.Hex.stringify(n),o.pbkdf2Iter=100,o.encryptionSchemeAlg="DES-EDE3-CBC",o.encryptionSchemeIV=v.enc.Hex.stringify(r),o};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var C=y(t).getEncodedHex();w=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===n||null==n?Pt(w,"PRIVATE KEY"):Pt(b=F(w,n),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){C=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),w=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===n||null==n?Pt(w,"PRIVATE KEY"):Pt(b=F(w,n),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){C=new h({bigint:t.x}).getEncodedHex(),w=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:C}}]}).getEncodedHex();return void 0===n||null==n?Pt(w,"PRIVATE KEY"):Pt(b=F(w,n),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Wt.getKeyFromCSRPEM=function(t){var e=Dt(t,"CERTIFICATE REQUEST");return Wt.getKeyFromCSRHex(e)},Wt.getKeyFromCSRHex=function(t){var e=Wt.parseCSRHex(t);return Wt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Wt.parseCSRHex=function(t){var e=ft,n=e.getChildIdx,r=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var a=n(s,0);if(a.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(a[0],2))throw"malformed CSR(code:003)";var o=n(s,a[0]);if(o.length<3)throw"malformed CSR(code:004)";return i.p8pubkeyhex=r(s,o[2]),i},Wt.getKeyID=function(t){var e=Wt,n=ft;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var r=Dt(e.getPEM(t)),i=n.getIdxbyList(r,0,[1]),s=n.getV(r,i).substring(2);return ht.crypto.Util.hashHex(s,"sha1")},Wt.getJWKFromKey=function(t){var e={};if(t instanceof rt&&t.isPrivate)return e.kty="RSA",e.n=xt(t.n.toString(16)),e.e=xt(t.e.toString(16)),e.d=xt(t.d.toString(16)),e.p=xt(t.p.toString(16)),e.q=xt(t.q.toString(16)),e.dp=xt(t.dmp1.toString(16)),e.dq=xt(t.dmq1.toString(16)),e.qi=xt(t.coeff.toString(16)),e;if(t instanceof rt&&t.isPublic)return e.kty="RSA",e.n=xt(t.n.toString(16)),e.e=xt(t.e.toString(16)),e;if(t instanceof ht.crypto.ECDSA&&t.isPrivate){if("P-256"!==(r=t.getShortNISTPCurveName())&&"P-384"!==r)throw"unsupported curve name for JWT: "+r;var n=t.getPublicKeyXYHex();return e.kty="EC",e.crv=r,e.x=xt(n.x),e.y=xt(n.y),e.d=xt(t.prvKeyHex),e}if(t instanceof ht.crypto.ECDSA&&t.isPublic){var r;if("P-256"!==(r=t.getShortNISTPCurveName())&&"P-384"!==r)throw"unsupported curve name for JWT: "+r;n=t.getPublicKeyXYHex();return e.kty="EC",e.crv=r,e.x=xt(n.x),e.y=xt(n.y),e}throw"not supported key object"},rt.getPosArrayOfChildrenFromHex=function(t){return ft.getChildIdx(t,0)},rt.getHexValueArrayOfChildrenFromHex=function(t){var e,n=ft.getV,r=n(t,(e=rt.getPosArrayOfChildrenFromHex(t))[0]),i=n(t,e[1]),s=n(t,e[2]),a=n(t,e[3]),o=n(t,e[4]),u=n(t,e[5]),h=n(t,e[6]),c=n(t,e[7]),l=n(t,e[8]);return(e=new Array).push(r,i,s,a,o,u,h,c,l),e},rt.prototype.readPrivateKeyFromPEMString=function(t){var e=Dt(t),n=rt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8])},rt.prototype.readPKCS5PrvKeyHex=function(t){var e=rt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},rt.prototype.readPKCS8PrvKeyHex=function(t){var e,n,r,i,s,a,o,u,h=ft,c=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),n=c(t,0,[2,0,2],"02"),r=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),u=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,n,r,i,s,a,o,u)},rt.prototype.readPKCS5PubKeyHex=function(t){var e=ft,n=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var r=e.getChildIdx(t,0);if(2!==r.length||"02"!==t.substr(r[0],2)||"02"!==t.substr(r[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=n(t,r[0]),s=n(t,r[1]);this.setPublic(i,s)},rt.prototype.readPKCS8PubKeyHex=function(t){var e=ft;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var n=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(n)},rt.prototype.readCertPubKeyHex=function(t,e){var n,r;(n=new Xt).readCertHex(t),r=n.getPublicKeyHex(),this.readPKCS8PubKeyHex(r)};var zt=new RegExp("[^0-9a-f]","gi");function Gt(t,e){for(var n="",r=e/4-t.length,i=0;i<r;i++)n+="0";return n+t}function Yt(t,e,n){for(var r="",i=0;r.length<e;)r+=wt(n(Ft(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return r}function Jt(t){for(var e in ht.crypto.Util.DIGESTINFOHEAD){var n=ht.crypto.Util.DIGESTINFOHEAD[e],r=n.length;if(t.substring(0,r)==n)return[e,t.substring(r)]}return[]}function Xt(t){var e,n=ft,r=n.getChildIdx,i=n.getV,s=n.getTLV,a=n.getVbyList,o=n.getVbyListEx,u=n.getTLVbyList,h=n.getTLVbyListEx,c=n.getIdxbyList,l=n.getIdxbyListEx,f=n.getVidx,d=n.oidname,g=n.hextooidstr,p=Xt,v=Dt;try{e=ht.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==u(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return o(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var n in e)if(t===e[n])return n;return d(o(t,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return p.hex2dn(this.getIssuerHex())},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 p.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=a(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=a(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return n.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return c(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Wt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return a(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),n=this.getSignatureValueHex(),r=u(this.hex,0,[0],"30"),i=new ht.crypto.Signature({alg:e});return i.init(t),i.updateHex(r),i.verify(n)},this.parseExt=function(t){var e,s,o;if(void 0===t){if(o=this.hex,3!==this.version)return-1;e=c(o,0,[0,7,0],"30"),s=r(o,e)}else{o=Dt(t);var u=c(o,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(o,u))return void(this.aExtInfo=new Array);e=c(o,0,[0,3,0,1,0],"30"),s=r(o,e),this.hex=o}this.aExtInfo=new Array;for(var h=0;h<s.length;h++){var l={critical:!1},d=0;3===r(o,s[h]).length&&(l.critical=!0,d=1),l.oid=n.hextooidstr(a(o,s[h],[0],"06"));var g=c(o,s[h],[1+d]);l.vidx=f(o,g),this.aExtInfo.push(l)}},this.getExtInfo=function(t){var e=this.aExtInfo,n=t;if(t.match(/^[0-9.]+$/)||(n=ht.asn1.x509.OID.name2oid(t)),""!==n)for(var r=0;r<e.length;r++)if(e[r].oid===n)return e[r]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("basicConstraints");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var r={extname:"basicConstraints"};if(e&&(r.critical=!0),"3000"===t)return r;if("30030101ff"===t)return r.cA=!0,r;if("30060101ff02"===t.substr(0,12)){var a=i(t,10),o=parseInt(a,16);return r.cA=!0,r.pathLen=o,r}throw new Error("hExtV parse error: "+t)},this.getExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("keyUsage");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var r={extname:"keyUsage"};return e&&(r.critical=!0),r.names=this.getExtKeyUsageString(t).split(","),r},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=s(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var n="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(n=n.slice(-8)),10==t.length&&(n=n.slice(-16)),""==(n=n.replace(/0+$/,""))&&(n="0"),n},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),n=new Array,r=0;r<e.length;r++)"1"==e.substr(r,1)&&n.push(Xt.KEYUSAGE_NAME[r]);return n.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("subjectKeyIdentifier");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var r={extname:"subjectKeyIdentifier"};e&&(r.critical=!0);var a=i(t,0);return r.kid={hex:a},r},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("authorityKeyIdentifier");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var a={extname:"authorityKeyIdentifier"};e&&(a.critical=!0);for(var o=r(t,0),u=0;u<o.length;u++){var h=t.substr(o[u],2);if("80"===h&&(a.kid={hex:i(t,o[u])}),"a1"===h){var c=s(t,o[u]),l=this.getGeneralNames(c);a.issuer=l[0].dn}"82"===h&&(a.sn={hex:i(t,o[u])})}return a},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("extKeyUsage");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var a={extname:"extKeyUsage",array:[]};e&&(a.critical=!0);for(var o=r(t,0),u=0;u<o.length;u++)a.array.push(d(i(t,o[u])));return a},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,n=s(this.hex,t.vidx);if(""===n)return e;for(var a=r(n,0),o=0;o<a.length;o++)e.push(d(i(n,a[o])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("subjectAltName");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var r={extname:"subjectAltName",array:[]};return e&&(r.critical=!0),r.array=this.getGeneralNames(t),r},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("issuerAltName");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var r={extname:"issuerAltName",array:[]};return e&&(r.critical=!0),r.array=this.getGeneralNames(t),r},this.getGeneralNames=function(t){for(var e=r(t,0),n=[],i=0;i<e.length;i++){var a=this.getGeneralName(s(t,e[i]));void 0!==a&&n.push(a)}return n},this.getGeneralName=function(t){var e=t.substr(0,2),n=i(t,0),r=wt(n);return"81"==e?{rfc822:r}:"82"==e?{dns:r}:"86"==e?{uri:r}:"87"==e?{ip:jt(n)}:"a4"==e?{dn:this.getX500Name(n)}:void 0},this.getExtSubjectAltName2=function(){var t,e,n,a=this.getExtInfo("subjectAltName");if(void 0===a)return a;for(var o=new Array,u=s(this.hex,a.vidx),h=r(u,0),c=0;c<h.length;c++)n=u.substr(h[c],2),t=i(u,h[c]),"81"===n&&(e=Et(t),o.push(["MAIL",e])),"82"===n&&(e=Et(t),o.push(["DNS",e])),"84"===n&&(e=Xt.hex2dn(t,0),o.push(["DN",e])),"86"===n&&(e=Et(t),o.push(["URI",e])),"87"===n&&(e=jt(t),o.push(["IP",e]));return o},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("cRLDistributionPoints");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var i={extname:"cRLDistributionPoints",array:[]};e&&(i.critical=!0);for(var a=r(t,0),o=0;o<a.length;o++){var u=s(t,a[o]);i.array.push(this.getDistributionPoint(u))}return i},this.getDistributionPoint=function(t){for(var e={},n=r(t,0),i=0;i<n.length;i++){var a=t.substr(n[i],2),o=s(t,n[i]);"a0"==a&&(e.dpname=this.getDistributionPointName(o))}return e},this.getDistributionPointName=function(t){for(var e={},n=r(t,0),i=0;i<n.length;i++){var a=t.substr(n[i],2),o=s(t,n[i]);"a0"==a&&(e.full=this.getGeneralNames(o))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var e=new Array,n=r(this.hex,t.vidx),i=0;i<n.length;i++)try{var s=Et(a(this.hex,n[i],[0,0,0],"86"));e.push(s)}catch(t){}return e},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},n=r(this.hex,t.vidx),i=0;i<n.length;i++){var s=a(this.hex,n[i],[0],"06"),o=a(this.hex,n[i],[1],"86");"2b06010505073001"===s&&e.ocsp.push(Et(o)),"2b06010505073002"===s&&e.caissuer.push(Et(o))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("authorityInfoAccess");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var i={extname:"authorityInfoAccess",array:[]};e&&(i.critical=!0);for(var u=r(t,0),h=0;h<u.length;h++){var c=o(t,u[h],[0],"06"),l=Et(a(t,u[h],[1],"86"));if("2b06010505073001"==c)i.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);i.array.push({caissuer:l})}}return i},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("certificatePolicies");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var i={extname:"certificatePolicies",array:[]};e&&(i.critical=!0);for(var a=r(t,0),o=0;o<a.length;o++){var u=s(t,a[o]),h=this.getPolicyInformation(u);i.array.push(h)}return i},this.getPolicyInformation=function(t){var e={},n=a(t,0,[0],"06");e.policyoid=d(n);var i=l(t,0,[1],"30");if(-1!=i){e.array=[];for(var o=r(t,i),u=0;u<o.length;u++){var h=s(t,o[u]),c=this.getPolicyQualifierInfo(h);e.array.push(c)}}return e},this.getPolicyQualifierInfo=function(t){var e={},n=a(t,0,[0],"06");if("2b06010505070201"===n){var r=o(t,0,[1],"16");e.cps=wt(r)}else if("2b06010505070202"===n){var i=u(t,0,[1],"30");e.unotice=this.getUserNotice(i)}return e},this.getUserNotice=function(t){for(var e={},n=r(t,0),i=0;i<n.length;i++){var a=s(t,n[i]);"30"!=a.substr(0,2)&&(e.exptext=this.getDisplayText(a))}return e},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=wt(i(t,0)),e},this.getExtCRLNumber=function(t,e){var n={extname:"cRLNumber"};if(e&&(n.critical=!0),"02"==t.substr(0,2))return n.num={hex:i(t,0)},n;throw new Error("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var n={extname:"cRLReason"};if(e&&(n.critical=!0),"0a"==t.substr(0,2))return n.code=parseInt(i(t,0),16),n;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var n={extname:"ocspNonce"};e&&(n.critical=!0);var r=i(t,0);return n.hex=r,n},this.getExtOcspNoCheck=function(t,e){var n={extname:"ocspNoCheck"};return e&&(n.critical=!0),n},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var n=this.getExtInfo("adobeTimeStamp");if(void 0===n)return;t=s(this.hex,n.vidx),e=n.critical}var i={extname:"adobeTimeStamp"};e&&(i.critical=!0);var a=r(t,0);if(a.length>1){var o=s(t,a[1]),u=this.getGeneralName(o);null!=u.uri&&(i.uri=u.uri)}if(a.length>2){var h=s(t,a[2]);"0101ff"==h&&(i.reqauth=!0),"010100"==h&&(i.reqauth=!1)}return i},this.getX500NameRule=function(t){for(var e=null,n=[],r=0;r<t.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(i[s]);for(r=0;r<n.length;r++){var a=n[r],o=a.ds,u=a.value,h=a.type;if(":"+o,"prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"!=h)return"mixed";if(ht.lang.String.isMail(u))continue;return"mixed"}if("C"==h){if("prn"==o)continue;return"mixed"}if(":"+o,null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getX500Name=function(t){var e=this.getX500NameArray(t);return{array:e,str:this.dnarraytostr(e)}},this.getX500NameArray=function(t){for(var e=[],n=r(t,0),i=0;i<n.length;i++)e.push(this.getRDN(s(t,n[i])));return e},this.getRDN=function(t){for(var e=[],n=r(t,0),i=0;i<n.length;i++)e.push(this.getAttrTypeAndValue(s(t,n[i])));return e},this.getAttrTypeAndValue=function(t){var e={type:null,value:null,ds:null},n=r(t,0),i=a(t,n[0],[],"06"),s=a(t,n[1],[]),o=ht.asn1.ASN1Util.oidHexToInt(i);return e.type=ht.asn1.x509.OID.oid2atype(o),e.value=wt(s),e.ds=this.HEX2STAG[t.substr(n[1],2)],e},this.readCertPEM=function(t){this.readCertHex(v(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{c(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(){var t={};return t.version=this.getVersion(),t.serial={hex:this.getSerialNumberHex()},t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.notbefore=this.getNotBefore(),t.notafter=this.getNotAfter(),t.subject=this.getSubject(),t.sbjpubkey=Pt(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=l(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],n=r(t,0),i=0;i<n.length;i++){var a=s(t,n[i]),o=this.getExtParam(a);null!=o&&e.push(o)}return e},this.getExtParam=function(t){var e=r(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var n=g(a(t,0,[0],"06")),i=!1;3==e&&"0101ff"==u(t,0,[1])&&(i=!0);var s=u(t,0,[e-1,0]),o=void 0;if("2.5.29.14"==n?o=this.getExtSubjectKeyIdentifier(s,i):"2.5.29.15"==n?o=this.getExtKeyUsage(s,i):"2.5.29.17"==n?o=this.getExtSubjectAltName(s,i):"2.5.29.18"==n?o=this.getExtIssuerAltName(s,i):"2.5.29.19"==n?o=this.getExtBasicConstraints(s,i):"2.5.29.31"==n?o=this.getExtCRLDistributionPoints(s,i):"2.5.29.32"==n?o=this.getExtCertificatePolicies(s,i):"2.5.29.35"==n?o=this.getExtAuthorityKeyIdentifier(s,i):"2.5.29.37"==n?o=this.getExtExtKeyUsage(s,i):"1.3.6.1.5.5.7.1.1"==n?o=this.getExtAuthorityInfoAccess(s,i):"2.5.29.20"==n?o=this.getExtCRLNumber(s,i):"2.5.29.21"==n?o=this.getExtCRLReason(s,i):"1.3.6.1.5.5.7.48.1.2"==n?o=this.getExtOcspNonce(s,i):"1.3.6.1.5.5.7.48.1.5"==n?o=this.getExtOcspNoCheck(s,i):"1.2.840.113583.1.1.9.1"==n&&(o=this.getExtAdobeTimeStamp(s,i)),null!=o)return o;var h={extname:n,extn:s};return i&&(h.critical=!0),h},this.findExt=function(t,e){for(var n=0;n<t.length;n++)if(t[n].extname==e)return t[n];return null},this.updateExtCDPFullURI=function(t,e){var n=this.findExt(t,"cRLDistributionPoints");if(null!=n&&null!=n.array)for(var r=n.array,i=0;i<r.length;i++)if(null!=r[i].dpname&&null!=r[i].dpname.full)for(var s=r[i].dpname.full,a=0;a<s.length;a++){var o=s[i];null!=o.uri&&(o.uri=e)}},this.updateExtAIAOCSP=function(t,e){var n=this.findExt(t,"authorityInfoAccess");if(null!=n&&null!=n.array)for(var r=n.array,i=0;i<r.length;i++)null!=r[i].ocsp&&(r[i].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var n=this.findExt(t,"authorityInfoAccess");if(null!=n&&null!=n.array)for(var r=n.array,i=0;i<r.length;i++)null!=r[i].caissuer&&(r[i].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map((function(t){return function(t){return t.map((function(t){return function(t){return t.type+"="+t.value}(t)})).join("+")}(t)})).join("/")},this.getInfo=function(){var t,e,n,r,i=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var a=i.array[s];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e},s=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+Xt.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},a=function(t){for(var e="",n=t.array,r=0;r<n.length;r++){var i=n[r];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+Vt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+Vt(e.e.toString(16))+"\n"),null!=(n=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var o=0;o<n.length;o++){var u=n[o],h=ht.asn1.x509.OID.oid2name(u.oid);""===h&&(h=u.oid);var c="";if(!0===u.critical&&(c="CRITICAL"),t+=" "+h+" "+c+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else if("keyUsage"===h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===h){var f=this.getExtAuthorityKeyIdentifier();void 0!==f.kid&&(t+=" kid="+f.kid.hex+"\n")}else{if("extKeyUsage"===h)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===h)t+=" "+(r=this.getExtSubjectAltName(),JSON.stringify(r.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===h)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===h)t+=a(this.getExtAuthorityInfoAccess());else"certificatePolicies"===h&&(t+=i(this.getExtCertificatePolicies()))}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):ht.lang.String.isHex(t)&&this.readCertHex(t))}rt.prototype.sign=function(t,e){var n=function(t){return ht.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(n,e)},rt.prototype.signWithMessageHash=function(t,e){var n=et(ht.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Gt(this.doPrivate(n).toString(16),this.n.bitLength())},rt.prototype.signPSS=function(t,e,n){var r,i=(r=Ft(t),ht.crypto.Util.hashHex(r,e));return void 0===n&&(n=-1),this.signWithMessageHashPSS(i,e,n)},rt.prototype.signWithMessageHashPSS=function(t,e,n){var r,i=wt(t),s=i.length,a=this.n.bitLength()-1,o=Math.ceil(a/8),u=function(t){return ht.crypto.Util.hashHex(t,e)};if(-1===n||void 0===n)n=s;else if(-2===n)n=o-s-2;else if(n<-2)throw new Error("invalid salt length");if(o<s+n+2)throw new Error("data too long");var h="";n>0&&(h=new Array(n),(new tt).nextBytes(h),h=String.fromCharCode.apply(String,h));var c=wt(u(Ft("\0\0\0\0\0\0\0\0"+i+h))),l=[];for(r=0;r<o-n-s-2;r+=1)l[r]=0;var f=String.fromCharCode.apply(String,l)+""+h,d=Yt(c,f.length,u),g=[];for(r=0;r<f.length;r+=1)g[r]=f.charCodeAt(r)^d.charCodeAt(r);var p=65280>>8*o-a&255;for(g[0]&=~p,r=0;r<s;r++)g.push(c.charCodeAt(r));return g.push(188),Gt(this.doPrivate(new E(g)).toString(16),this.n.bitLength())},rt.prototype.verify=function(t,e){var n=et(e=(e=e.replace(zt,"")).replace(/[ \n]+/g,""),16);if(n.bitLength()>this.n.bitLength())return 0;var r=Jt(this.doPublic(n).toString(16).replace(/^1f+00/,""));if(0==r.length)return!1;var i=r[0];return r[1]==function(t){return ht.crypto.Util.hashString(t,i)}(t)},rt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var n=et(e,16);if(n.bitLength()>this.n.bitLength())return 0;var r=Jt(this.doPublic(n).toString(16).replace(/^1f+00/,""));if(0==r.length)return!1;r[0];return r[1]==t},rt.prototype.verifyPSS=function(t,e,n,r){var i,s=(i=Ft(t),ht.crypto.Util.hashHex(i,n));return void 0===r&&(r=-1),this.verifyWithMessageHashPSS(s,e,n,r)},rt.prototype.verifyWithMessageHashPSS=function(t,e,n,r){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new E(e,16),a=function(t){return ht.crypto.Util.hashHex(t,n)},o=wt(t),u=o.length,h=this.n.bitLength()-1,c=Math.ceil(h/8);if(-1===r||void 0===r)r=u;else if(-2===r)r=c-u-2;else if(r<-2)throw new Error("invalid salt length");if(c<u+r+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(i=0;i<l.length;i+=1)l[i]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var f=(l=String.fromCharCode.apply(String,l)).substr(0,c-u-1),d=l.substr(f.length,u),g=65280>>8*c-h&255;if(0!=(f.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var p=Yt(d,f.length,a),v=[];for(i=0;i<f.length;i+=1)v[i]=f.charCodeAt(i)^p.charCodeAt(i);v[0]&=~g;var y=c-u-r-2;for(i=0;i<y;i+=1)if(0!==v[i])throw new Error("leftmost octets not zero");if(1!==v[y])throw new Error("0x01 marker not found");return d===wt(a(Ft("\0\0\0\0\0\0\0\0"+o+String.fromCharCode.apply(String,v.slice(-r)))))},rt.SALT_LEN_HLEN=-1,rt.SALT_LEN_MAX=-2,rt.SALT_LEN_RECOVER=-2,Xt.hex2dn=function(t,e){if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed DN");for(var n=new Array,r=ft.getChildIdx(t,e),i=0;i<r.length;i++)n.push(Xt.hex2rdn(t,r[i]));return"/"+(n=n.map((function(t){return t.replace("/","\\/")}))).join("/")},Xt.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var n=new Array,r=ft.getChildIdx(t,e),i=0;i<r.length;i++)n.push(Xt.hex2attrTypeValue(t,r[i]));return(n=n.map((function(t){return t.replace("+","\\+")}))).join("+")},Xt.hex2attrTypeValue=function(t,e){var n=ft,r=n.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var i=n.getChildIdx(t,e);2!==i.length||t.substr(i[0],2);var s=r(t,i[0]),a=ht.asn1.ASN1Util.oidHexToInt(s);return ht.asn1.x509.OID.oid2atype(a)+"="+wt(r(t,i[1]))},Xt.getPublicKeyFromCertHex=function(t){var e=new Xt;return e.readCertHex(t),e.getPublicKey()},Xt.getPublicKeyFromCertPEM=function(t){var e=new Xt;return e.readCertPEM(t),e.getPublicKey()},Xt.getPublicKeyInfoPropOfCertPEM=function(t){var e,n,r=ft.getVbyList,i={};return i.algparam=null,(e=new Xt).readCertPEM(t),n=e.getPublicKeyHex(),i.keyhex=r(n,0,[1],"03").substr(2),i.algoid=r(n,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=r(n,0,[0,1],"06")),i},Xt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];void 0!==ht&&ht||(ht={}),void 0!==ht.jws&&ht.jws||(ht.jws={}),ht.jws.JWS=function(){var t=ht.jws.JWS.isSafeJSONString;this.parseJWS=function(e,n){if(void 0===this.parsedJWS||!n&&void 0===this.parsedJWS.sigvalH){var r=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==r)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var i=r[1],s=r[2],a=r[3],o=i+"."+s;if(this.parsedJWS={},this.parsedJWS.headB64U=i,this.parsedJWS.payloadB64U=s,this.parsedJWS.sigvalB64U=a,this.parsedJWS.si=o,!n){var u=St(a),h=et(u,16);this.parsedJWS.sigvalH=u,this.parsedJWS.sigvalBI=h}var c=lt(i),l=lt(s);if(this.parsedJWS.headS=c,this.parsedJWS.payloadS=l,!t(c,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+c}}},ht.jws.JWS.sign=function(t,e,n,r,i){var s,a,o,u=ht,h=u.jws.JWS,c=h.readSafeJSONString,l=h.isSafeJSONString,f=u.crypto,d=(f.ECDSA,f.Mac),g=f.Signature,p=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(a=e,s=p.stringify(a)),"string"==typeof e){if(!l(s=e))throw"JWS Head is not safe JSON string: "+s;a=c(s)}if(o=n,"object"==typeof n&&(o=p.stringify(n)),""!=t&&null!=t||void 0===a.alg||(t=a.alg),""!=t&&null!=t&&void 0===a.alg&&(a.alg=t,s=p.stringify(a)),t!==a.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+a.alg;var v=null;if(void 0===h.jwsalg2sigalg[t])throw"unsupported alg name: "+t;v=h.jwsalg2sigalg[t];var y=ct(s)+"."+ct(o),m="";if("Hmac"==v.substr(0,4)){if(void 0===r)throw"mac key shall be specified for HS* alg";var x=new d({alg:v,prov:"cryptojs",pass:r});x.updateString(y),m=x.doFinal()}else if(-1!=v.indexOf("withECDSA")){(b=new g({alg:v})).init(r,i),b.updateString(y);var S=b.sign();m=ht.crypto.ECDSA.asn1SigToConcatSig(S)}else{var b;if("none"!=v)(b=new g({alg:v})).init(r,i),b.updateString(y),m=b.sign()}return y+"."+xt(m)},ht.jws.JWS.verify=function(t,e,n){var r,i=ht,s=i.jws.JWS,a=s.readSafeJSONString,o=i.crypto,u=o.ECDSA,h=o.Mac,c=o.Signature;r=rt;var l=t.split(".");if(3!==l.length)return!1;var f=l[0]+"."+l[1],d=St(l[2]),g=a(lt(l[0])),p=null,v=null;if(void 0===g.alg)throw"algorithm not specified in header";if((v=(p=g.alg).substr(0,2),null!=n&&"[object Array]"===Object.prototype.toString.call(n)&&n.length>0)&&-1==(":"+n.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Wt.getKey(e)),!("RS"!=v&&"PS"!=v||e instanceof r))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==v&&!(e instanceof u))throw"key shall be a ECDSA obj for ES* algs";var y=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(y=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==y.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new h({alg:y,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=y.indexOf("withECDSA")){var x,S=null;try{S=u.concatSigToASN1Sig(d)}catch(t){return!1}return(x=new c({alg:y})).init(e),x.updateString(f),x.verify(S)}return(x=new c({alg:y})).init(e),x.updateString(f),x.verify(d)},ht.jws.JWS.parse=function(t){var e,n,r,i=t.split("."),s={};if(2!=i.length&&3!=i.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=i[0],n=i[1],3==i.length&&(r=i[2]),s.headerObj=ht.jws.JWS.readSafeJSONString(lt(e)),s.payloadObj=ht.jws.JWS.readSafeJSONString(lt(n)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=lt(n):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==r&&(s.sigHex=St(r)),s},ht.jws.JWS.verifyJWT=function(t,e,n){var r=ht.jws,i=r.JWS,s=i.readSafeJSONString,a=i.inArray,o=i.includedArray,u=t.split("."),h=u[0],c=u[1],l=(St(u[2]),s(lt(h))),f=s(lt(c));if(void 0===l.alg)return!1;if(void 0===n.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,n.alg))return!1;if(void 0!==f.iss&&"object"==typeof n.iss&&!a(f.iss,n.iss))return!1;if(void 0!==f.sub&&"object"==typeof n.sub&&!a(f.sub,n.sub))return!1;if(void 0!==f.aud&&"object"==typeof n.aud)if("string"==typeof f.aud){if(!a(f.aud,n.aud))return!1}else if("object"==typeof f.aud&&!o(f.aud,n.aud))return!1;var d=r.IntDate.getNow();return void 0!==n.verifyAt&&"number"==typeof n.verifyAt&&(d=n.verifyAt),void 0!==n.gracePeriod&&"number"==typeof n.gracePeriod||(n.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+n.gracePeriod<d)&&(!(void 0!==f.nbf&&"number"==typeof f.nbf&&d<f.nbf-n.gracePeriod)&&(!(void 0!==f.iat&&"number"==typeof f.iat&&d<f.iat-n.gracePeriod)&&((void 0===f.jti||void 0===n.jti||f.jti===n.jti)&&!!i.verify(t,e,n.alg))))},ht.jws.JWS.includedArray=function(t,e){var n=ht.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var r=0;r<t.length;r++)if(!n(t[r],e))return!1;return!0},ht.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var n=0;n<e.length;n++)if(e[n]==t)return!0;return!1},ht.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},ht.jws.JWS.isSafeJSONString=function(t,e,n){var r=null;try{return"object"!=typeof(r=ut(t))||r.constructor===Array?0:(e&&(e[n]=r),1)}catch(t){return 0}},ht.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=ut(t))||e.constructor===Array?null:e}catch(t){return null}},ht.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},ht.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e+='"kty":"'+t.kty+'",',e+='"k":"'+t.k+'"}'}var n=Ft(e);return xt(ht.crypto.Util.hashHex(n,"sha256"))},ht.jws.IntDate={},ht.jws.IntDate.get=function(t){var e=ht.jws.IntDate,n=e.getNow,r=e.getZulu;if("now"==t)return n();if("now + 1hour"==t)return n()+3600;if("now + 1day"==t)return n()+86400;if("now + 1month"==t)return n()+2592e3;if("now + 1year"==t)return n()+31536e3;if(t.match(/Z$/))return r(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},ht.jws.IntDate.getZulu=function(t){return Tt(t)},ht.jws.IntDate.getNow=function(){return~~(new Date/1e3)},ht.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},ht.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==ht&&ht||(ht={}),void 0!==ht.jws&&ht.jws||(ht.jws={}),ht.jws.JWSJS=function(){var t=ht.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,n,r){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var i=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=ht.jws.JWS.sign(t,e,this.sPayload,n,r).split(".");s[0],s[2];this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>i&&this.aHeader.pop(),this.aSignature.length>i&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var n=t[e];if(2!==n.length)return!1;if(!1===this.verifyNth(e,n[0],n[1]))return!1}return!0},this.verifyNth=function(e,n,r){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var i=this.aHeader[e],s=this.aSignature[e],a=i+"."+this.sPayload+"."+s,o=!1;try{o=t.verify(a,n,r)}catch(t){return!1}return o},this.readJWSJS=function(t){if("string"==typeof t){var n=e(t);if(null==n)throw"argument is not safe JSON object string";this.aHeader=n.headers,this.sPayload=n.payload,this.aSignature=n.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=tt,e.rng_seed_time=Y,e.BigInteger=E,e.RSAKey=rt,e.ECDSA=ht.crypto.ECDSA,e.DSA=ht.crypto.DSA,e.Signature=ht.crypto.Signature,e.MessageDigest=ht.crypto.MessageDigest,e.Mac=ht.crypto.Mac,e.Cipher=ht.crypto.Cipher,e.KEYUTIL=Wt,e.ASN1HEX=ft,e.X509=Xt,e.X509CRL=function(t){var e=ht.lang.String.isHex,n=ft,r=n.getV,i=n.getTLV,s=n.getVbyList,a=n.getTLVbyList,o=n.getTLVbyListEx,u=n.getIdxbyList,h=n.getIdxbyListEx,c=n.getChildIdx,l=new Xt;this.hex=null,this.posSigAlg=null,this.posRevCert=null,this._setPos=function(){var t=u(this.hex,0,[0,0]),e=this.hex.substr(t,2);if("02"==e)this.posSigAlg=1;else{if("30"!=e)throw new Error("malformed 1st item of TBSCertList: "+e);this.posSigAlg=0}var n,r=u(this.hex,0,[0,this.posSigAlg+3]),i=this.hex.substr(r,2);if("17"==i||"18"==i)n=u(this.hex,0,[0,this.posSigAlg+4]),this.posRevCert=null,-1!=n&&"30"==this.hex.substr(n,2)&&(this.posRevCert=this.posSigAlg+4);else if("30"==i)this.posRevCert=this.posSigAlg+3;else{if("a0"!=i)throw new Error("malformed nextUpdate or revCert tag: "+i);this.posRevCert=null}},this.getVersion=function(){return 0==this.posSigAlg?null:parseInt(s(this.hex,0,[0,0],"02"),16)+1},this.getSignatureAlgorithmField=function(){var t=a(this.hex,0,[0,this.posSigAlg],"30");return l.getAlgorithmIdentifierName(t)},this.getIssuer=function(){var t=a(this.hex,0,[0,this.posSigAlg+1],"30");return l.getX500Name(t)},this.getThisUpdate=function(){var t=s(this.hex,0,[0,this.posSigAlg+2]);return result=wt(t)},this.getNextUpdate=function(){var t=u(this.hex,0,[0,this.posSigAlg+3]),e=this.hex.substr(t,2);return"17"!=e&&"18"!=e?null:wt(r(this.hex,t))},this.getRevCertArray=function(){if(null==this.posRevCert)return null;for(var t=[],e=u(this.hex,0,[0,this.posRevCert]),n=c(this.hex,e),r=0;r<n.length;r++){var s=i(this.hex,n[r]);t.push(this.getRevCert(s))}return t},this.getRevCert=function(t){var e={},n=c(t,0);return e.sn={hex:s(t,0,[0],"02")},e.date=wt(s(t,0,[1])),3==n.length&&(e.ext=l.getExtParamArray(a(t,0,[2]))),e},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),n=this.getSignatureValueHex(),r=a(this.hex,0,[0],"30"),i=new ht.crypto.Signature({alg:e});return i.init(t),i.updateHex(r),i.verify(n)},this.getParam=function(){var t={},e=this.getVersion();null!=e&&(t.version=e),t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.thisupdate=this.getThisUpdate();var n=this.getNextUpdate();null!=n&&(t.nextupdate=n);var r=this.getRevCertArray();if(null!=r&&(t.revcert=r),-1!=h(this.hex,0,[0,"[0]"])){var i=o(this.hex,0,[0,"[0]",0]);t.ext=l.getExtParamArray(i)}return t.sighex=this.getSignatureValueHex(),t},"string"==typeof t&&(e(t)?this.hex=t:t.match(/-----BEGIN X509 CRL/)&&(this.hex=Dt(t)),this._setPos())},e.CryptoJS=v,e.b64tohex=S,e.b64toBA=b,e.ECFieldElementFp=st,e.ECPointFp=at,e.ECCurveFp=ot,e.stoBA=dt,e.BAtos=gt,e.BAtohex=pt,e.stohex=vt,e.stob64=function(t){return x(vt(t))},e.stob64u=function(t){return yt(x(vt(t)))},e.b64utos=function(t){return gt(b(mt(t)))},e.b64tob64u=yt,e.b64utob64=mt,e.hex2b64=x,e.hextob64u=xt,e.b64utohex=St,e.utf8tob64u=ct,e.b64utoutf8=lt,e.utf8tob64=function(t){return x(Ot(_t(t)))},e.b64toutf8=function(t){return decodeURIComponent(Bt(S(t)))},e.utf8tohex=bt,e.hextoutf8=Et,e.hextorstr=wt,e.rstrtohex=Ft,e.hextob64=At,e.hextob64nl=Ct,e.b64nltohex=It,e.hextopem=Pt,e.pemtohex=Dt,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),n=new DataView(e),r=0;r<t.length/2;r++)n.setUint8(r,parseInt(t.substr(2*r,2),16));return e},e.ArrayBuffertohex=function(t){for(var e="",n=new DataView(t),r=0;r<t.byteLength;r++)e+=("00"+n.getUint8(r).toString(16)).slice(-2);return e},e.zulutomsec=Rt,e.zulutosec=Tt,e.zulutodate=function(t){return new Date(Rt(t))},e.datetozulu=function(t,e,n){var r,i=t.getUTCFullYear();if(e){if(i<1950||2049<i)throw"not proper year for UTCTime: "+i;r=(""+i).slice(-2)}else r=("000"+i).slice(-4);if(r+=("0"+(t.getUTCMonth()+1)).slice(-2),r+=("0"+t.getUTCDate()).slice(-2),r+=("0"+t.getUTCHours()).slice(-2),r+=("0"+t.getUTCMinutes()).slice(-2),r+=("0"+t.getUTCSeconds()).slice(-2),n){var s=t.getUTCMilliseconds();0!==s&&(r+="."+(s=(s=("00"+s).slice(-3)).replace(/0+$/g,"")))}return r+="Z"},e.uricmptohex=Ot,e.hextouricmp=Bt,e.ipv6tohex=Ht,e.hextoipv6=Nt,e.hextoip=jt,e.iptohex=function(t){var e="malformed IP address";if(!(t=t.toLowerCase(t)).match(/^[0-9.]+$/)){if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return Ht(t);throw e}var n=t.split(".");if(4!==n.length)throw e;var r="";try{for(var i=0;i<4;i++){r+=("0"+parseInt(n[i]).toString(16)).slice(-2)}return r}catch(t){throw e}},e.encodeURIComponentAll=_t,e.newline_toUnix=function(t){return t=t.replace(/\r\n/gm,"\n")},e.newline_toDos=function(t){return t=(t=t.replace(/\r\n/gm,"\n")).replace(/\n/gm,"\r\n")},e.hextoposhex=Vt,e.intarystrtohex=Lt,e.strdiffidx=function(t,e){var n=t.length;t.length>e.length&&(n=e.length);for(var r=0;r<n;r++)if(t.charCodeAt(r)!=e.charCodeAt(r))return r;return t.length!=e.length?n:-1},e.oidtohex=Mt,e.hextooid=Kt,e.strpad=qt,e.bitstrtoint=Ut,e.inttobitstr=function(t){var e=Number(t).toString(2),n=8-e.length%8;8==n&&(n=0),e+=qt("",n,"0");var r=parseInt(e,2).toString(16);return r.length%2==1&&(r="0"+r),"0"+n+r},e.KJUR=ht,e.crypto=ht.crypto,e.asn1=ht.asn1,e.jws=ht.jws,e.lang=ht.lang}).call(this,n(32).Buffer)},,function(t,e,n){"use strict";(function(t){var r=n(34),i=n(35),s=n(36);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(a()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t}function u(t,e,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(this,t)}return h(this,t,e,n)}function h(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=f(t,e);return t}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|g(e,n),i=(t=o(t,r)).write(e,n);i!==r&&(t=t.slice(0,i));return t}(t,e,n):function(t,e){if(u.isBuffer(e)){var n=0|d(e.length);return 0===(t=o(t,n)).length||e.copy(t,0,0,n),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(r=e.length)!=r?o(t,0):f(t,e);if("Buffer"===e.type&&s(e.data))return f(t,e.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t,e){if(c(e),t=o(t,e<0?0:0|d(e)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n)t[n]=0;return t}function f(t,e){var n=e.length<0?0:0|d(e.length);t=o(t,n);for(var r=0;r<n;r+=1)t[r]=255&e[r];return t}function d(t){if(t>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return M(t).length;default:if(r)return L(t).length;e=(""+e).toLowerCase(),r=!0}}function p(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return D(this,e,n);case"utf8":case"utf-8":return C(this,e,n);case"ascii":return I(this,e,n);case"latin1":case"binary":return P(this,e,n);case"base64":return A(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function v(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){var s,a=1,o=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,o/=2,u/=2,n/=2}function h(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(s=n;s<o;s++)if(h(t,s)===h(e,-1===c?0:s-c)){if(-1===c&&(c=s),s-c+1===u)return c*a}else-1!==c&&(s-=s-c),c=-1}else for(n+u>o&&(n=o-u),s=n;s>=0;s--){for(var l=!0,f=0;f<u;f++)if(h(t,s+f)!==h(e,f)){l=!1;break}if(l)return s}return-1}function x(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var a=0;a<r;++a){var o=parseInt(e.substr(2*a,2),16);if(isNaN(o))return a;t[n+a]=o}return a}function S(t,e,n,r){return K(L(e,t.length-n),t,n,r)}function b(t,e,n,r){return K(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function E(t,e,n,r){return b(t,e,n,r)}function w(t,e,n,r){return K(M(e),t,n,r)}function F(t,e,n,r){return K(function(t,e){for(var n,r,i,s=[],a=0;a<t.length&&!((e-=2)<0);++a)n=t.charCodeAt(a),r=n>>8,i=n%256,s.push(i),s.push(r);return s}(e,t.length-n),t,n,r)}function A(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function C(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var s,a,o,u,h=t[i],c=null,l=h>239?4:h>223?3:h>191?2:1;if(i+l<=n)switch(l){case 1:h<128&&(c=h);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&h)<<6|63&s)>127&&(c=u);break;case 3:s=t[i+1],a=t[i+2],128==(192&s)&&128==(192&a)&&(u=(15&h)<<12|(63&s)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:s=t[i+1],a=t[i+2],o=t[i+3],128==(192&s)&&128==(192&a)&&128==(192&o)&&(u=(15&h)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),i+=l}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=4096));return n}(r)}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t)},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=a(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,n){return h(null,t,e,n)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return function(t,e,n,r){return c(e),e<=0?o(t,e):void 0!==n?"string"==typeof r?o(t,e).fill(n,r):o(t,e).fill(n):o(t,e)}(null,t,e,n)},u.allocUnsafe=function(t){return l(null,t)},u.allocUnsafeSlow=function(t){return l(null,t)},u.isBuffer=function(t){return!(null==t||!t._isBuffer)},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,s=Math.min(n,r);i<s;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var a=t[n];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length}return r},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)v(this,e,e+1);return this},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)v(this,e,e+3),v(this,e+1,e+2);return this},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)v(this,e,e+7),v(this,e+1,e+6),v(this,e+2,e+5),v(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?C(this,0,t):p.apply(this,arguments)},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(e>>>=0),o=Math.min(s,a),h=this.slice(r,i),c=t.slice(e,n),l=0;l<o;++l)if(h[l]!==c[l]){s=h[l],a=c[l];break}return s<a?-1:a<s?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return x(this,t,e,n);case"utf8":case"utf-8":return S(this,t,e,n);case"ascii":return b(this,t,e,n);case"latin1":case"binary":return E(this,t,e,n);case"base64":return w(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function P(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function D(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",s=e;s<n;++s)i+=V(t[s]);return i}function R(t,e,n){for(var r=t.slice(e,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function T(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,n,r,i,s){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function B(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-n,2);i<s;++i)t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function H(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-n,4);i<s;++i)t[n+i]=e>>>8*(r?i:3-i)&255}function N(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(t,e,n,r,s){return s||N(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function _(t,e,n,r,s){return s||N(t,0,n,8),i.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=u.prototype;else{var i=e-t;n=new u(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+t]}return n},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]},u.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],i=1,s=0;++s<e&&(i*=256);)r+=this[t+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=e,i=1,s=this[t+--r];r>0&&(i*=256);)s+=this[t+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},u.prototype.readInt8=function(t,e){return e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||O(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[e]=255&t;++s<n&&(i*=256);)this[e+s]=t/i&255;return e+n},u.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||O(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):H(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):H(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var s=0,a=1,o=0;for(this[e]=255&t;++s<n&&(a*=256);)t<0&&0===o&&0!==this[e+s-1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);O(this,t,e,n,i-1,-i)}var s=n-1,a=1,o=0;for(this[e+s]=255&t;--s>=0&&(a*=256);)t<0&&0===o&&0!==this[e+s+1]&&(o=1),this[e+s]=(t/a>>0)-o&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):H(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):H(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return _(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return _(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,s=r-n;if(this===t&&n<e&&e<r)for(i=s-1;i>=0;--i)t[i+e]=this[i+n];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+s),e);return s},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var s;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s<n;++s)this[s]=t;else{var a=u.isBuffer(t)?t:L(new u(t,r).toString()),o=a.length;for(s=0;s<n-e;++s)this[s+e]=a[s%o]}return this};var k=/[^+\/0-9A-Za-z-_]/g;function V(t){return t<16?"0"+t.toString(16):t.toString(16)}function L(t,e){var n;e=e||1/0;for(var r=t.length,i=null,s=[],a=0;a<r;++a){if((n=t.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function M(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(k,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(5))},,function(t,e,n){"use strict";e.byteLength=function(t){var e=h(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,r=h(t),a=r[0],o=r[1],u=new s(function(t,e,n){return 3*(e+n)/4-n}(0,a,o)),c=0,l=o>0?a-4:a;for(n=0;n<l;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=255&e;2===o&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[c++]=255&e);1===o&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[c++]=e>>8&255,u[c++]=255&e);return u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,s=[],a=0,o=n-i;a<o;a+=16383)s.push(c(t,a,a+16383>o?o:a+16383));1===i?(e=t[n-1],s.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],s.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return s.join("")};for(var r=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,u=a.length;o<u;++o)r[o]=a[o],i[a.charCodeAt(o)]=o;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var i,s,a=[],o=e;o<n;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),a.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,n,r,i){var s,a,o=8*i-r-1,u=(1<<o)-1,h=u>>1,c=-7,l=n?i-1:0,f=n?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=o;c>0;s=256*s+t[e+l],l+=f,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=r;c>0;a=256*a+t[e+l],l+=f,c-=8);if(0===s)s=1-h;else{if(s===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),s-=h}return(d?-1:1)*a*Math.pow(2,s-r)},e.write=function(t,e,n,r,i,s){var a,o,u,h=8*s-i-1,c=(1<<h)-1,l=c>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,g=r?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(o=0,a=c):a+l>=1?(o=(e*u-1)*Math.pow(2,i),a+=l):(o=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+d]=255&o,d+=g,o/=256,i-=8);for(a=a<<i|o,h+=i;h>0;t[n+d]=255&a,d+=g,a/=256,h-=8);t[n+d-g]|=128*p}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetApi=void 0;var r=n(6),i=n(7),s=n(8),a=n(9),o=n(10),u=n(11),h=n(18),c=n(19),l=n(12);function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function v(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=x(t);if(e){var i=x(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return y(this,n)}}function y(t,e){return!e||"object"!==f(e)&&"function"!=typeof e?m(t):e}function m(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function x(t){return(x=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function S(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var b=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}(y,t);var e,n,r,f=v(y);function y(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(d(this,y),(t=f.call(this)).clientOrigin=n,S(m(t),"transport",void 0),S(m(t),"capabilitiesFinished",!1),S(m(t),"supportsMSC2974Renegotiate",!1),S(m(t),"requestedCapabilities",[]),S(m(t),"approvedCapabilities",void 0),S(m(t),"cachedClientVersions",void 0),!window.parent)throw new Error("No parent window. This widget doesn't appear to be embedded properly.");return t.transport=new a.PostmessageTransport(i.WidgetApiDirection.FromWidget,e,window.parent,window),t.transport.targetOrigin=n,t.transport.on("message",t.handleMessage.bind(m(t))),t}return e=y,(n=[{key:"hasCapability",value:function(t){return Array.isArray(this.approvedCapabilities)?this.approvedCapabilities.includes(t):this.requestedCapabilities.includes(t)}},{key:"requestCapability",value:function(t){if(this.capabilitiesFinished&&!this.supportsMSC2974Renegotiate)throw new Error("Capabilities have already been negotiated");this.requestedCapabilities.push(t)}},{key:"requestCapabilities",value:function(t){var e=this;t.forEach((function(t){return e.requestCapability(t)}))}},{key:"requestCapabilityToSendState",value:function(t,e){this.requestCapability(l.WidgetEventCapability.forStateEvent(l.EventDirection.Send,t,e).raw)}},{key:"requestCapabilityToReceiveState",value:function(t,e){this.requestCapability(l.WidgetEventCapability.forStateEvent(l.EventDirection.Receive,t,e).raw)}},{key:"requestCapabilityToSendEvent",value:function(t){this.requestCapability(l.WidgetEventCapability.forRoomEvent(l.EventDirection.Send,t).raw)}},{key:"requestCapabilityToReceiveEvent",value:function(t){this.requestCapability(l.WidgetEventCapability.forRoomEvent(l.EventDirection.Receive,t).raw)}},{key:"requestCapabilityToSendMessage",value:function(t){this.requestCapability(l.WidgetEventCapability.forRoomMessageEvent(l.EventDirection.Send,t).raw)}},{key:"requestCapabilityToReceiveMessage",value:function(t){this.requestCapability(l.WidgetEventCapability.forRoomMessageEvent(l.EventDirection.Receive,t).raw)}},{key:"requestOpenIDConnectToken",value:function(){var t=this;return new Promise((function(e,n){t.transport.sendComplete(o.WidgetApiFromWidgetAction.GetOpenIDCredentials,{}).then((function(r){var i=r.response;i.state===u.OpenIDRequestState.Allowed?e(i):i.state===u.OpenIDRequestState.Blocked?n(new Error("User declined to verify their identity")):i.state===u.OpenIDRequestState.PendingUserConfirmation?t.on("action:".concat(o.WidgetApiToWidgetAction.OpenIDCredentials),(function s(a){a.preventDefault();var h=a.detail;h.data.original_request_id===r.requestId&&(h.data.state===u.OpenIDRequestState.Allowed?(e(h.data),t.transport.reply(h,{})):h.data.state===u.OpenIDRequestState.Blocked?(n(new Error("User declined to verify their identity")),t.transport.reply(h,{})):(n(new Error("Invalid state on reply: "+i.state)),t.transport.reply(h,{error:{message:"Invalid state"}})),t.off("action:".concat(o.WidgetApiToWidgetAction.OpenIDCredentials),s))})):n(new Error("Invalid state: "+i.state))})).catch(n)}))}},{key:"updateRequestedCapabilities",value:function(){return this.transport.send(o.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities,{capabilities:this.requestedCapabilities}).then()}},{key:"sendContentLoaded",value:function(){return this.transport.send(o.WidgetApiFromWidgetAction.ContentLoaded,{}).then()}},{key:"sendSticker",value:function(t){return this.transport.send(o.WidgetApiFromWidgetAction.SendSticker,t).then()}},{key:"setAlwaysOnScreen",value:function(t){return this.transport.send(o.WidgetApiFromWidgetAction.UpdateAlwaysOnScreen,{value:t}).then((function(t){return t.success}))}},{key:"openModalWidget",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:h.MatrixWidgetType.Custom;return this.transport.send(o.WidgetApiFromWidgetAction.OpenModalWidget,{type:i,url:t,name:e,buttons:n,data:r}).then()}},{key:"closeModalWidget",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.transport.send(o.WidgetApiFromWidgetAction.CloseModalWidget,t).then()}},{key:"sendRoomEvent",value:function(t,e){return this.transport.send(o.WidgetApiFromWidgetAction.SendEvent,{type:t,content:e})}},{key:"sendStateEvent",value:function(t,e,n){return this.transport.send(o.WidgetApiFromWidgetAction.SendEvent,{type:t,content:n,state_key:e})}},{key:"setModalButtonEnabled",value:function(t,e){if(t===c.BuiltInModalButtonID.Close)throw new Error("The close button cannot be disabled");return this.transport.send(o.WidgetApiFromWidgetAction.SetModalButtonEnabled,{button:t,enabled:e}).then()}},{key:"navigateTo",value:function(t){if(!t||!t.startsWith("https://matrix.to/#"))throw new Error("Invalid matrix.to URI");return this.transport.send(o.WidgetApiFromWidgetAction.MSC2931Navigate,{uri:t}).then()}},{key:"start",value:function(){var t=this;this.transport.start(),this.getClientVersions().then((function(e){e.includes(s.UnstableApiVersion.MSC2974)&&(t.supportsMSC2974Renegotiate=!0)}))}},{key:"handleMessage",value:function(t){var e=new CustomEvent("action:".concat(t.detail.action),{detail:t.detail,cancelable:!0});if(this.emit("action:".concat(t.detail.action),e),!e.defaultPrevented)switch(t.detail.action){case o.WidgetApiToWidgetAction.SupportedApiVersions:return this.replyVersions(t.detail);case o.WidgetApiToWidgetAction.Capabilities:return this.handleCapabilities(t.detail);case o.WidgetApiToWidgetAction.UpdateVisibility:case o.WidgetApiToWidgetAction.NotifyCapabilities:return this.transport.reply(t.detail,{});default:return this.transport.reply(t.detail,{error:{message:"Unknown or unsupported action: "+t.detail.action}})}}},{key:"replyVersions",value:function(t){this.transport.reply(t,{supported_versions:s.CurrentApiVersions})}},{key:"getClientVersions",value:function(){var t=this;return Array.isArray(this.cachedClientVersions)?Promise.resolve(this.cachedClientVersions):this.transport.send(o.WidgetApiFromWidgetAction.SupportedApiVersions,{}).then((function(e){return t.cachedClientVersions=e.supported_versions,e.supported_versions})).catch((function(t){return console.warn("non-fatal error getting supported client versions: ",t),[]}))}},{key:"handleCapabilities",value:function(t){var e=this;return this.capabilitiesFinished?this.transport.reply(t,{error:{message:"Capability negotiation already completed"}}):this.getClientVersions().then((function(n){return n.includes(s.UnstableApiVersion.MSC2871)?e.once("action:".concat(o.WidgetApiToWidgetAction.NotifyCapabilities),(function(t){e.approvedCapabilities=t.detail.data.approved,e.emit("ready")})):e.emit("ready"),e.capabilitiesFinished=!0,e.transport.reply(t,{capabilities:e.requestedCapabilities})}))}}])&&g(e.prototype,n),r&&g(e,r),y}(r.EventEmitter);e.WidgetApi=b},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ClientWidgetApi=void 0;var r=n(6),i=n(9),s=n(7),a=n(10),o=n(20),u=n(8),h=n(12),c=n(11),l=n(21);function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function d(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function g(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?d(Object(n),!0).forEach((function(e){b(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,e){return(v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=S(t);if(e){var i=S(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m(this,n)}}function m(t,e){return!e||"object"!==f(e)&&"function"!=typeof e?x(t):e}function x(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function S(t){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function b(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var E=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&v(t,e)}(d,t);var e,n,r,f=y(d);function d(t,e,n){var r,a;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,d),(a=f.call(this)).widget=t,a.iframe=e,a.driver=n,b(x(a),"transport",void 0),b(x(a),"capabilitiesFinished",!1),b(x(a),"allowedCapabilities",new Set),b(x(a),"allowedEvents",[]),b(x(a),"isStopped",!1),!(null===(r=e)||void 0===r?void 0:r.contentWindow))throw new Error("No iframe supplied");if(!t)throw new Error("Invalid widget");if(!n)throw new Error("Invalid driver");return a.transport=new i.PostmessageTransport(s.WidgetApiDirection.ToWidget,t.id,e.contentWindow,window),a.transport.targetOrigin=t.origin,a.transport.on("message",a.handleMessage.bind(x(a))),t.waitForIframeLoad&&e.addEventListener("load",a.onIframeLoad.bind(x(a))),a.transport.start(),a}return e=d,(n=[{key:"hasCapability",value:function(t){return this.allowedCapabilities.has(t)}},{key:"canSendRoomEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some((function(n){return n.matchesAsRoomEvent(t,e)&&n.direction===h.EventDirection.Send}))}},{key:"canSendStateEvent",value:function(t,e){return this.allowedEvents.some((function(n){return n.matchesAsStateEvent(t,e)&&n.direction===h.EventDirection.Send}))}},{key:"canReceiveRoomEvent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.allowedEvents.some((function(n){return n.matchesAsRoomEvent(t,e)&&n.direction===h.EventDirection.Receive}))}},{key:"canReceiveStateEvent",value:function(t,e){return this.allowedEvents.some((function(n){return n.matchesAsStateEvent(t,e)&&n.direction===h.EventDirection.Receive}))}},{key:"stop",value:function(){this.isStopped=!0,this.transport.stop()}},{key:"onIframeLoad",value:function(t){this.beginCapabilities(),this.iframe.removeEventListener("onload",this.onIframeLoad.bind(this))}},{key:"beginCapabilities",value:function(){var t,e=this;if(this.capabilitiesFinished)throw new Error("Capabilities exchange already completed");this.emit("preparing"),this.transport.send(a.WidgetApiToWidgetAction.Capabilities,{}).then((function(n){return t=n.capabilities,e.driver.validateCapabilities(new Set(n.capabilities))})).then((function(n){console.log("Widget ".concat(e.widget.id," is allowed capabilities:"),Array.from(n)),e.allowedCapabilities=n,e.allowedEvents=h.WidgetEventCapability.findEventCapabilities(n),e.capabilitiesFinished=!0,e.notifyCapabilities(t),e.emit("ready")}))}},{key:"notifyCapabilities",value:function(t){this.transport.send(a.WidgetApiToWidgetAction.NotifyCapabilities,{requested:t,approved:Array.from(this.allowedCapabilities)}).catch((function(t){console.warn("non-fatal error notifying widget of approved capabilities:",t)}))}},{key:"handleContentLoadedAction",value:function(t){this.widget.waitForIframeLoad?this.transport.reply(t,{error:{message:"Improper sequence: not expecting load event"}}):(this.transport.reply(t,{}),this.beginCapabilities())}},{key:"replyVersions",value:function(t){this.transport.reply(t,{supported_versions:u.CurrentApiVersions})}},{key:"handleCapabilitiesRenegotiate",value:function(t){var e,n=this;this.transport.reply(t,{});var r=(null===(e=t.data)||void 0===e?void 0:e.capabilities)||[],i=new Set(r.filter((function(t){return!n.hasCapability(t)})));if(0===i.size)return this.notifyCapabilities([]);this.driver.validateCapabilities(i).then((function(t){return t.forEach((function(t){return n.allowedCapabilities.add(t)})),h.WidgetEventCapability.findEventCapabilities(t).forEach((function(t){return n.allowedEvents.push(t)})),n.notifyCapabilities(Array.from(i))}))}},{key:"handleNavigate",value:function(t){var e,n,r=this;if(!this.hasCapability(o.MatrixCapabilities.MSC2931Navigate))return this.transport.reply(t,{error:{message:"Missing capability"}});if(!(null===(e=t.data)||void 0===e?void 0:e.uri)||!(null===(n=t.data)||void 0===n?void 0:n.uri.toString().startsWith("https://matrix.to/#")))return this.transport.reply(t,{error:{message:"Invalid matrix.to URI"}});var i=function(e){return console.error("[ClientWidgetApi] Failed to handle navigation: ",e),r.transport.reply(t,{error:{message:"Error handling navigation"}})};try{this.driver.navigate(t.data.uri.toString()).catch((function(t){return i(t)})).then((function(){return r.transport.reply(t,{})}))}catch(t){return i(t)}}},{key:"handleOIDC",value:function(t){var e=this,n=1,r=function(r,i){return i=i||{},n>1?e.transport.send(a.WidgetApiToWidgetAction.OpenIDCredentials,g({state:r,original_request_id:t.requestId},i)):e.transport.reply(t,g({state:r},i))},i=function(i){return console.error("[ClientWidgetApi] Failed to handle OIDC: ",i),n>1?r(c.OpenIDRequestState.Blocked):e.transport.reply(t,{error:{message:i}})},s=new l.SimpleObservable((function(t){return t.state===c.OpenIDRequestState.PendingUserConfirmation&&n>1?(s.close(),i("client provided out-of-phase response to OIDC flow")):t.state===c.OpenIDRequestState.PendingUserConfirmation?(r(t.state),void n++):t.state!==c.OpenIDRequestState.Allowed||t.token?(t.state===c.OpenIDRequestState.Blocked&&(t.token=null),s.close(),r(t.state,t.token)):i("client provided invalid OIDC token for an allowed request")}));this.driver.askOpenID(s)}},{key:"handleSendEvent",value:function(t){var e,n=this;if(!t.data.type)return this.transport.reply(t,{error:{message:"Invalid request - missing event type"}});if(null!==t.data.state_key&&void 0!==t.data.state_key){if(!this.canSendStateEvent(t.data.type,t.data.state_key))return this.transport.reply(t,{error:{message:"Cannot send state events of this type"}});e=this.driver.sendEvent(t.data.type,t.data.content||{},t.data.state_key)}else{var r=t.data.content||{},i=r.msgtype;if(!this.canSendRoomEvent(t.data.type,i))return this.transport.reply(t,{error:{message:"Cannot send room events of this type"}});e=this.driver.sendEvent(t.data.type,r,null)}e.then((function(e){return n.transport.reply(t,{room_id:e.roomId,event_id:e.eventId})})).catch((function(e){return console.error("error sending event: ",e),n.transport.reply(t,{error:{message:"Error sending event"}})}))}},{key:"handleMessage",value:function(t){if(!this.isStopped){var e=new CustomEvent("action:".concat(t.detail.action),{detail:t.detail,cancelable:!0});if(this.emit("action:".concat(t.detail.action),e),!e.defaultPrevented)switch(t.detail.action){case a.WidgetApiFromWidgetAction.ContentLoaded:return this.handleContentLoadedAction(t.detail);case a.WidgetApiFromWidgetAction.SupportedApiVersions:return this.replyVersions(t.detail);case a.WidgetApiFromWidgetAction.SendEvent:return this.handleSendEvent(t.detail);case a.WidgetApiFromWidgetAction.GetOpenIDCredentials:return this.handleOIDC(t.detail);case a.WidgetApiFromWidgetAction.MSC2931Navigate:return this.handleNavigate(t.detail);case a.WidgetApiFromWidgetAction.MSC2974RenegotiateCapabilities:return this.handleCapabilitiesRenegotiate(t.detail);default:return this.transport.reply(t.detail,{error:{message:"Unknown or unsupported action: "+t.detail.action}})}}}},{key:"takeScreenshot",value:function(){return this.transport.send(a.WidgetApiToWidgetAction.TakeScreenshot,{})}},{key:"updateVisibility",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.UpdateVisibility,{visible:t})}},{key:"sendWidgetConfig",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.WidgetConfig,t).then()}},{key:"notifyModalWidgetButtonClicked",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.ButtonClicked,{id:t}).then()}},{key:"notifyModalWidgetClose",value:function(t){return this.transport.send(a.WidgetApiToWidgetAction.CloseModalWidget,t).then()}},{key:"feedEvent",value:function(t){if(void 0!==t.state_key&&null!==t.state_key){if(!this.canReceiveStateEvent(t.type,t.state_key))return Promise.resolve()}else if(!this.canReceiveRoomEvent(t.type,(t.content||{}).msgtype))return Promise.resolve();return this.transport.send(a.WidgetApiToWidgetAction.SendEvent,t).then()}}])&&p(e.prototype,n),r&&p(e,r),d}(r.EventEmitter);e.ClientWidgetApi=E},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isErrorResponse=function(t){if("error"in t){return!!t.error.message}return!1}},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetKind=void 0,e.WidgetKind=r,function(t){t.Room="room",t.Account="account",t.Modal="modal"}(r||(e.WidgetKind=r={}))},function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.ModalButtonKind=void 0,e.ModalButtonKind=r,function(t){t.Primary="m.primary",t.Secondary="m.secondary",t.Warning="m.warning",t.Danger="m.danger",t.Link="m.link"}(r||(e.ModalButtonKind=r={}))},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetParser=void 0;var r=n(24),i=n(22);function s(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,u=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return o=t.done,t},e:function(t){u=!0,s=t},f:function(){try{o||null==n.return||n.return()}finally{if(u)throw s}}}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var u=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n,a;return e=t,a=[{key:"parseAccountData",value:function(e){if(!e)return[];for(var n=[],r=0,i=Object.keys(e);r<i.length;r++){var s=i[r],a=e[s];if(a&&("m.widget"===a.type||"im.vector.modular.widgets"===a.type)&&a.sender&&(a.state_key||a.id)===s){var o={content:a.content,sender:a.sender,type:"m.widget",state_key:s,event_id:"$example",room_id:"!example",origin_server_ts:1},u=t.parseRoomWidget(o);u&&n.push(u)}}return n}},{key:"parseWidgetsFromRoomState",value:function(e){if(!e)return[];var n,r=[],i=s(e);try{for(i.s();!(n=i.n()).done;){var a=n.value,o=t.parseRoomWidget(a);o&&r.push(o)}}catch(t){i.e(t)}finally{i.f()}return r}},{key:"parseRoomWidget",value:function(e){if(!e)return null;if("m.widget"!==e.type&&"im.vector.modular.widgets"!==e.type)return null;var n=e.content||{},r={id:e.state_key,creatorUserId:n.creatorUserId||e.sender,name:n.name,type:n.type,url:n.url,waitForIframeLoad:n.waitForIframeLoad,data:n.data};return t.processEstimatedWidget(r)}},{key:"processEstimatedWidget",value:function(t){return t.id&&t.creatorUserId&&t.type&&(0,i.isValidUrl)(t.url)?new r.Widget(t):null}}],(n=null)&&o(e.prototype,n),a&&o(e,a),t}();e.WidgetParser=u},function(t,e,n){"use strict";function r(t){return null==t?"".concat(t):t.toString()}Object.defineProperty(e,"__esModule",{value:!0}),e.runTemplate=function(t,e,n){for(var i=Object.assign({},e.data,{matrix_room_id:n.widgetRoomId||"",matrix_user_id:n.currentUserId,matrix_display_name:n.userDisplayName||n.currentUserId,matrix_avatar_url:n.userHttpAvatarUrl||"",matrix_widget_id:e.id}),s=t,a=0,o=Object.keys(i);a<o.length;a++){var u=o[a],h="$".concat(u).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(h,"g");s=s.replace(c,encodeURIComponent(r(i[u])))}return s},e.toString=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WidgetDriver=void 0;var r=n(3);function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,n,s;return e=t,(n=[{key:"validateCapabilities",value:function(t){return Promise.resolve(new Set)}},{key:"sendEvent",value:function(t,e){return Promise.reject(new Error("Failed to override function"))}},{key:"askOpenID",value:function(t){t.update({state:r.OpenIDRequestState.Blocked})}},{key:"navigate",value:function(t){throw new Error("Navigation is not implemented")}}])&&i(e.prototype,n),s&&i(e,s),t}();e.WidgetDriver=s},,,,,,,,function(t,e,n){"use strict";n.r(e);var r=n(2),i=n(30),s=n(3),a=n(13);n(73);let o,u,h,c,l,f,d,g,p,v,y,m=!1;function x(){m=!m,document.getElementById("jitsiContainer").style.visibility=m?"unset":"hidden",document.getElementById("joinButtonContainer").style.visibility=m?"hidden":"unset"}!async function(){try{const t=r.parse(window.location.hash.substring(1)),e=Object.assign({},r.parse(window.location.search.substring(1)),t),n=(t,n=!1)=>{if(!(n||e[t]&&"string"==typeof e[t]))throw new Error(`Expected singular ${t} in query string`);return e[t]},m=n("parentUrl",!0),S=n("widgetId",!0),b=n("theme",!0);let E;if(b&&document.body.classList.add("theme-"+b.replace(" ","_")),m&&S){const t=new URL(n("parentUrl")).origin;v=new s.WidgetApi(n("widgetId"),t),v.requestCapabilities(s.VideoConferenceCapabilities),E=Promise.all([new Promise(t=>{v.once("action:"+a.a.ClientReady,e=>{e.preventDefault(),v.transport.reply(e.detail,{}),t()})}),new Promise(t=>{v.once("ready",()=>t())})]),v.start()}else console.warn("No parent URL or no widget ID - assuming no widget API is available");o=n("conferenceDomain"),u=n("conferenceId"),h=n("displayName",!0),c=n("avatarUrl",!0),l=n("userId"),f=n("auth",!0),d=n("roomId",!0),p=n("roomName",!0),v&&(await E,await v.setAlwaysOnScreen(!1),"openidtoken-jwt"===f&&(g=await v.requestOpenIDConnectToken(),console.log("Got OpenID Connect token")),v.on("action:"+a.a.HangupCall,t=>{y&&y.executeCommand("hangup"),v.transport.reply(t.detail,{})})),document.getElementById("joinButton").onclick=()=>function(){let t;if("openidtoken-jwt"===f){var e;if(null===(e=g)||void 0===e||!e.access_token)return console.warn("Expected to have an OpenID credential, cannot initialize widget."),void(document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget");t=function(){const t={iss:o,sub:o,aud:"https://"+o,room:"*",context:{matrix:{token:g.access_token,room_id:d,server_name:g.matrix_server_name},user:{avatar:c,name:h}}};return i.KJUR.jws.JWS.sign("HS256",JSON.stringify({alg:"HS256",typ:"JWT"}),JSON.stringify(t),"notused")}()}x(),v&&v.setAlwaysOnScreen(!0),console.warn("[Jitsi Widget] The next few errors about failing to parse URL parameters are fine if they mention 'external_api' or 'jitsi' in the stack. They're just Jitsi Meet trying to parse our fragment values and not recognizing the options.");const n={width:"100%",height:"100%",parentNode:document.querySelector("#jitsiContainer"),roomName:u,interfaceConfigOverwrite:{SHOW_JITSI_WATERMARK:!1,SHOW_WATERMARK_FOR_GUESTS:!1,MAIN_TOOLBAR_BUTTONS:[],VIDEO_LAYOUT_FIT:"height"},jwt:t};y=new JitsiMeetExternalAPI(o,n),h&&y.executeCommand("displayName",h),c&&y.executeCommand("avatarUrl",c),l&&y.executeCommand("email",l),p&&y.executeCommand("subject",p),y.on("readyToClose",()=>{x(),v&&v.setAlwaysOnScreen(!1),document.getElementById("jitsiContainer").innerHTML="",y=null})}()}catch(t){console.error("Error setting up Jitsi widget",t),document.getElementById("widgetActionContainer").innerText="Failed to load Jitsi widget"}}()},function(t,e,n){}]);
//# sourceMappingURL=jitsi.js.map