Files
dicom-proxy/public/oidc-client.min.js
2025-03-11 13:16:07 +07:00

2 lines
222 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*! For license information please see oidc-client.min.js.LICENSE.txt */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var i in r)("object"==typeof exports?exports:t)[i]=r[i]}}(window,(function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=45)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n={debug:function(){},info:function(){},warn:function(){},error:function(){}},o=void 0,s=void 0;(e.Log=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.reset=function(){s=3,o=n},t.debug=function(){if(s>=4){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];o.debug.apply(o,Array.from(e))}},t.info=function(){if(s>=3){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];o.info.apply(o,Array.from(e))}},t.warn=function(){if(s>=2){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];o.warn.apply(o,Array.from(e))}},t.error=function(){if(s>=1){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];o.error.apply(o,Array.from(e))}},i(t,null,[{key:"NONE",get:function(){return 0}},{key:"ERROR",get:function(){return 1}},{key:"WARN",get:function(){return 2}},{key:"INFO",get:function(){return 3}},{key:"DEBUG",get:function(){return 4}},{key:"level",get:function(){return s},set:function(t){if(!(0<=t&&t<=4))throw new Error("Invalid log level");s=t}},{key:"logger",get:function(){return o},set:function(t){if(!t.debug&&t.info&&(t.debug=t.info),!(t.debug&&t.info&&t.warn&&t.error))throw new Error("Invalid logger");o=t}}]),t}()).reset()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n={setInterval:function(t){function e(e,r){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t,e){return setInterval(t,e)})),clearInterval:function(t){function e(e){return t.apply(this,arguments)}return e.toString=function(){return t.toString()},e}((function(t){return clearInterval(t)}))},o=!1,s=null;e.Global=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t._testing=function(){o=!0},t.setXMLHttpRequest=function(t){s=t},i(t,null,[{key:"location",get:function(){if(!o)return location}},{key:"localStorage",get:function(){if(!o&&"undefined"!=typeof window)return localStorage}},{key:"sessionStorage",get:function(){if(!o&&"undefined"!=typeof window)return sessionStorage}},{key:"XMLHttpRequest",get:function(){if(!o&&"undefined"!=typeof window)return s||XMLHttpRequest}},{key:"timer",get:function(){if(!o)return n}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UrlUtility=void 0;var i=r(0),n=r(1);e.UrlUtility=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.addQueryParam=function(t,e,r){return t.indexOf("?")<0&&(t+="?"),"?"!==t[t.length-1]&&(t+="&"),t+=encodeURIComponent(e),(t+="=")+encodeURIComponent(r)},t.parseUrlFragment=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.Global;"string"!=typeof t&&(t=r.location.href);var o=t.lastIndexOf(e);o>=0&&(t=t.substr(o+1));for(var s,a={},u=/([^&=]+)=([^&]*)/g,c=0;s=u.exec(t);)if(a[decodeURIComponent(s[1])]=decodeURIComponent(s[2]),c++>50)return i.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",t),{error:"Response exceeded expected number of parameters"};for(var h in a)return a;return{}},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MetadataService=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(17);e.MetadataService=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.JsonService;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e)throw n.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=e,this._jsonService=new r(["application/jwk-set+json"])}return t.prototype.getMetadata=function(){var t=this;return this._settings.metadata?(n.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(n.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then((function(e){return n.Log.debug("MetadataService.getMetadata: json received"),t._settings.metadata=e,e}))):(n.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},t.prototype.getIssuer=function(){return this._getMetadataProperty("issuer")},t.prototype.getAuthorizationEndpoint=function(){return this._getMetadataProperty("authorization_endpoint")},t.prototype.getUserInfoEndpoint=function(){return this._getMetadataProperty("userinfo_endpoint")},t.prototype.getTokenEndpoint=function(){return this._getMetadataProperty("token_endpoint",!0)},t.prototype.getCheckSessionIframe=function(){return this._getMetadataProperty("check_session_iframe",!0)},t.prototype.getEndSessionEndpoint=function(){return this._getMetadataProperty("end_session_endpoint",!0)},t.prototype.getRevocationEndpoint=function(){return this._getMetadataProperty("revocation_endpoint",!0)},t.prototype._getMetadataProperty=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return n.Log.debug("MetadataService.getMetadataProperty for: "+t),this.getMetadata().then((function(r){if(n.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),void 0===r[t]){if(!0===e)return void n.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+t);throw n.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+t),new Error("Metadata does not contain property "+t)}return r[t]}))},t.prototype.getSigningKeys=function(){var t=this;return this._settings.signingKeys?(n.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then((function(e){return n.Log.debug("MetadataService.getSigningKeys: jwks_uri received",e),t._jsonService.getJson(e).then((function(e){if(n.Log.debug("MetadataService.getSigningKeys: key set received",e),!e.keys)throw n.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return t._settings.signingKeys=e.keys,t._settings.signingKeys}))}))},i(t,[{key:"metadataUrl",get:function(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(".well-known/openid-configuration")<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=".well-known/openid-configuration"))),this._metadataUrl}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.State=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=function(t){return t&&t.__esModule?t:{default:t}}(r(14));e.State=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.id,i=e.data,n=e.created;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._id=r||(0,o.default)(),this._data=i,this._created="number"==typeof n&&n>0?n:parseInt(Date.now()/1e3)}return t.prototype.toStorageString=function(){return n.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created})},t.fromStorageString=function(e){return n.Log.debug("State.fromStorageString"),new t(JSON.parse(e))},t.clearStaleState=function(e,r){var i=Date.now()/1e3-r;return e.getAllKeys().then((function(r){n.Log.debug("State.clearStaleState: got keys",r);for(var o=[],s=function(s){var a=r[s];u=e.get(a).then((function(r){var o=!1;if(r)try{var s=t.fromStorageString(r);n.Log.debug("State.clearStaleState: got item from key: ",a,s.created),s.created<=i&&(o=!0)}catch(t){n.Log.error("State.clearStaleState: Error parsing state for key",a,t.message),o=!0}else n.Log.debug("State.clearStaleState: no item in storage for key: ",a),o=!0;if(o)return n.Log.debug("State.clearStaleState: removed item for key: ",a),e.remove(a)})),o.push(u)},a=0;a<r.length;a++){var u;s(a)}return n.Log.debug("State.clearStaleState: waiting on promise count:",o.length),Promise.all(o)}))},i(t,[{key:"id",get:function(){return this._id}},{key:"data",get:function(){return this._data}},{key:"created",get:function(){return this._created}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.WebStorageStateStore=void 0;var i=r(0),n=r(1);e.WebStorageStateStore=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.prefix,i=void 0===r?"oidc.":r,o=e.store,s=void 0===o?n.Global.localStorage:o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._store=s,this._prefix=i}return t.prototype.set=function(t,e){return i.Log.debug("WebStorageStateStore.set",t),t=this._prefix+t,this._store.setItem(t,e),Promise.resolve()},t.prototype.get=function(t){i.Log.debug("WebStorageStateStore.get",t),t=this._prefix+t;var e=this._store.getItem(t);return Promise.resolve(e)},t.prototype.remove=function(t){i.Log.debug("WebStorageStateStore.remove",t),t=this._prefix+t;var e=this._store.getItem(t);return this._store.removeItem(t),Promise.resolve(e)},t.prototype.getAllKeys=function(){i.Log.debug("WebStorageStateStore.getAllKeys");for(var t=[],e=0;e<this._store.length;e++){var r=this._store.key(e);0===r.indexOf(this._prefix)&&t.push(r.substr(this._prefix.length))}return Promise.resolve(t)},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OidcClientSettings=void 0;var i="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},n=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),o=r(0),s=r(5),a=r(44),u=r(3);e.OidcClientSettings=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.authority,n=e.metadataUrl,o=e.metadata,c=e.signingKeys,h=e.client_id,f=e.client_secret,l=e.response_type,p=void 0===l?"id_token":l,g=e.scope,d=void 0===g?"openid":g,v=e.redirect_uri,y=e.post_logout_redirect_uri,m=e.prompt,F=e.display,S=e.max_age,_=e.ui_locales,w=e.acr_values,b=e.resource,E=e.filterProtocolClaims,x=void 0===E||E,A=e.loadUserInfo,P=void 0===A||A,C=e.staleStateAge,k=void 0===C?900:C,R=e.clockSkew,T=void 0===R?300:R,I=e.stateStore,D=void 0===I?new s.WebStorageStateStore:I,B=e.ResponseValidatorCtor,L=void 0===B?a.ResponseValidator:B,N=e.MetadataServiceCtor,U=void 0===N?u.MetadataService:N,O=e.extraQueryParams,H=void 0===O?{}:O;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._authority=r,this._metadataUrl=n,this._metadata=o,this._signingKeys=c,this._client_id=h,this._client_secret=f,this._response_type=p,this._scope=d,this._redirect_uri=v,this._post_logout_redirect_uri=y,this._prompt=m,this._display=F,this._max_age=S,this._ui_locales=_,this._acr_values=w,this._resource=b,this._filterProtocolClaims=!!x,this._loadUserInfo=!!P,this._staleStateAge=k,this._clockSkew=T,this._stateStore=D,this._validator=new L(this),this._metadataService=new U(this),this._extraQueryParams="object"===(void 0===H?"undefined":i(H))?H:{}}return n(t,[{key:"client_id",get:function(){return this._client_id},set:function(t){if(this._client_id)throw o.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=t}},{key:"client_secret",get:function(){return this._client_secret}},{key:"response_type",get:function(){return this._response_type}},{key:"scope",get:function(){return this._scope}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function(){return this._post_logout_redirect_uri}},{key:"prompt",get:function(){return this._prompt}},{key:"display",get:function(){return this._display}},{key:"max_age",get:function(){return this._max_age}},{key:"ui_locales",get:function(){return this._ui_locales}},{key:"acr_values",get:function(){return this._acr_values}},{key:"resource",get:function(){return this._resource}},{key:"authority",get:function(){return this._authority},set:function(t){if(this._authority)throw o.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=t}},{key:"metadataUrl",get:function(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(".well-known/openid-configuration")<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=".well-known/openid-configuration")),this._metadataUrl}},{key:"metadata",get:function(){return this._metadata},set:function(t){this._metadata=t}},{key:"signingKeys",get:function(){return this._signingKeys},set:function(t){this._signingKeys=t}},{key:"filterProtocolClaims",get:function(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function(){return this._loadUserInfo}},{key:"staleStateAge",get:function(){return this._staleStateAge}},{key:"clockSkew",get:function(){return this._clockSkew}},{key:"stateStore",get:function(){return this._stateStore}},{key:"validator",get:function(){return this._validator}},{key:"metadataService",get:function(){return this._metadataService}},{key:"extraQueryParams",get:function(){return this._extraQueryParams},set:function(t){"object"===(void 0===t?"undefined":i(t))?this._extraQueryParams=t:this._extraQueryParams={}}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CordovaPopupWindow=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0);e.CordovaPopupWindow=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._promise=new Promise((function(t,e){r._resolve=t,r._reject=e})),this.features=e.popupWindowFeatures||"location=no,toolbar=no,zoom=no",this.target=e.popupWindowTarget||"_blank",this.redirect_uri=e.startUrl,n.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return t.prototype._isInAppBrowserInstalled=function(t){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some((function(e){return t.hasOwnProperty(e)}))},t.prototype.navigate=function(t){if(t&&t.url){if(!window.cordova)return this._error("cordova is undefined");var e=window.cordova.require("cordova/plugin_list").metadata;if(!1===this._isInAppBrowserInstalled(e))return this._error("InAppBrowser plugin not found");this._popup=cordova.InAppBrowser.open(t.url,this.target,this.features),this._popup?(n.Log.debug("CordovaPopupWindow.navigate: popup successfully created"),this._exitCallbackEvent=this._exitCallback.bind(this),this._loadStartCallbackEvent=this._loadStartCallback.bind(this),this._popup.addEventListener("exit",this._exitCallbackEvent,!1),this._popup.addEventListener("loadstart",this._loadStartCallbackEvent,!1)):this._error("Error opening popup window")}else this._error("No url provided");return this.promise},t.prototype._loadStartCallback=function(t){0===t.url.indexOf(this.redirect_uri)&&this._success({url:t.url})},t.prototype._exitCallback=function(t){this._error(t)},t.prototype._success=function(t){this._cleanup(),n.Log.debug("CordovaPopupWindow: Successful response from cordova popup window"),this._resolve(t)},t.prototype._error=function(t){this._cleanup(),n.Log.error(t),this._reject(new Error(t))},t.prototype.close=function(){this._cleanup()},t.prototype._cleanup=function(){this._popup&&(n.Log.debug("CordovaPopupWindow: cleaning up popup"),this._popup.removeEventListener("exit",this._exitCallbackEvent,!1),this._popup.removeEventListener("loadstart",this._loadStartCallbackEvent,!1),this._popup.close()),this._popup=null},i(t,[{key:"promise",get:function(){return this._promise}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TokenRevocationClient=void 0;var i=r(0),n=r(3),o=r(1);e.TokenRevocationClient=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.XMLHttpRequest,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.MetadataService;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e)throw i.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=e,this._XMLHttpRequestCtor=r,this._metadataService=new s(this._settings)}return t.prototype.revoke=function(t,e){var r=this;if(!t)throw i.Log.error("TokenRevocationClient.revoke: No accessToken provided"),new Error("No accessToken provided.");return this._metadataService.getRevocationEndpoint().then((function(n){if(n){i.Log.error("TokenRevocationClient.revoke: Revoking access token");var o=r._settings.client_id,s=r._settings.client_secret;return r._revoke(n,o,s,t)}if(e)throw i.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")}))},t.prototype._revoke=function(t,e,r,n){var o=this;return new Promise((function(s,a){var u=new o._XMLHttpRequestCtor;u.open("POST",t),u.onload=function(){i.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",u.status),200===u.status?s():a(Error(u.statusText+" ("+u.status+")"))};var c="client_id="+encodeURIComponent(e);r&&(c+="&client_secret="+encodeURIComponent(r)),c+="&token_type_hint="+encodeURIComponent("access_token"),c+="&token="+encodeURIComponent(n),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(c)}))},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CheckSessionIFrame=void 0;var i=r(0);e.CheckSessionIFrame=function(){function t(e,r,i,n){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._callback=e,this._client_id=r,this._url=i,this._interval=n||2e3,this._stopOnError=o;var s=i.indexOf("/",i.indexOf("//")+2);this._frame_origin=i.substr(0,s),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.style.width=0,this._frame.style.height=0,this._frame.src=i}return t.prototype.load=function(){var t=this;return new Promise((function(e){t._frame.onload=function(){e()},window.document.body.appendChild(t._frame),t._boundMessageEvent=t._message.bind(t),window.addEventListener("message",t._boundMessageEvent,!1)}))},t.prototype._message=function(t){t.origin===this._frame_origin&&t.source===this._frame.contentWindow&&("error"===t.data?(i.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===t.data?(i.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):i.Log.debug("CheckSessionIFrame: "+t.data+" message from check session op iframe"))},t.prototype.start=function(t){var e=this;if(this._session_state!==t){i.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=t;var r=function(){e._frame.contentWindow.postMessage(e._client_id+" "+e._session_state,e._frame_origin)};r(),this._timer=window.setInterval(r,this._interval)}},t.prototype.stop=function(){this._session_state=null,this._timer&&(i.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SessionMonitor=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(9);e.SessionMonitor=function(){function t(e){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.CheckSessionIFrame;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e)throw n.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=e,this._CheckSessionIFrameCtor=i,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),this._userManager.getUser().then((function(t){t&&r._start(t)})).catch((function(t){n.Log.error("SessionMonitor ctor: error from getUser:",t.message)}))}return t.prototype._start=function(t){var e=this,r=t.session_state;r&&(this._sub=t.profile.sub,this._sid=t.profile.sid,n.Log.debug("SessionMonitor._start: session_state:",r,", sub:",this._sub),this._checkSessionIFrame?this._checkSessionIFrame.start(r):this._metadataService.getCheckSessionIframe().then((function(t){if(t){n.Log.debug("SessionMonitor._start: Initializing check session iframe");var i=e._client_id,o=e._checkSessionInterval,s=e._stopCheckSessionOnError;e._checkSessionIFrame=new e._CheckSessionIFrameCtor(e._callback.bind(e),i,t,o,s),e._checkSessionIFrame.load().then((function(){e._checkSessionIFrame.start(r)}))}else n.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")})).catch((function(t){n.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",t.message)})))},t.prototype._stop=function(){this._sub=null,this._sid=null,this._checkSessionIFrame&&(n.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop())},t.prototype._callback=function(){var t=this;this._userManager.querySessionStatus().then((function(e){var r=!0;e?e.sub===t._sub?(r=!1,t._checkSessionIFrame.start(e.session_state),e.sid===t._sid?n.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",e.session_state):(n.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",e.session_state),t._userManager.events._raiseUserSessionChanged())):n.Log.debug("SessionMonitor._callback: Different subject signed into OP:",e.sub):n.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),r&&(n.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),t._userManager.events._raiseUserSignedOut())})).catch((function(e){n.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",e.message),t._userManager.events._raiseUserSignedOut()}))},i(t,[{key:"_settings",get:function(){return this._userManager.settings}},{key:"_metadataService",get:function(){return this._userManager.metadataService}},{key:"_client_id",get:function(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function(){return this._settings.stopCheckSessionOnError}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Event=void 0;var i=r(0);e.Event=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._name=e,this._callbacks=[]}return t.prototype.addHandler=function(t){this._callbacks.push(t)},t.prototype.removeHandler=function(t){var e=this._callbacks.findIndex((function(e){return e===t}));e>=0&&this._callbacks.splice(e,1)},t.prototype.raise=function(){i.Log.debug("Event: Raising event: "+this._name);for(var t=0;t<this._callbacks.length;t++){var e;(e=this._callbacks)[t].apply(e,arguments)}},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.AccessTokenEvents=void 0;var i=r(0),n=r(22);e.AccessTokenEvents=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.accessTokenExpiringNotificationTime,i=void 0===r?60:r,o=e.accessTokenExpiringTimer,s=void 0===o?new n.Timer("Access token expiring"):o,a=e.accessTokenExpiredTimer,u=void 0===a?new n.Timer("Access token expired"):a;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._accessTokenExpiringNotificationTime=i,this._accessTokenExpiring=s,this._accessTokenExpired=u}return t.prototype.load=function(t){if(t.access_token&&void 0!==t.expires_in){var e=t.expires_in;if(i.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",e),e>0){var r=e-this._accessTokenExpiringNotificationTime;r<=0&&(r=1),i.Log.debug("AccessTokenEvents.load: registering expiring timer in:",r),this._accessTokenExpiring.init(r)}else i.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var n=e+1;i.Log.debug("AccessTokenEvents.load: registering expired timer in:",n),this._accessTokenExpired.init(n)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},t.prototype.unload=function(){i.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},t.prototype.addAccessTokenExpiring=function(t){this._accessTokenExpiring.addHandler(t)},t.prototype.removeAccessTokenExpiring=function(t){this._accessTokenExpiring.removeHandler(t)},t.prototype.addAccessTokenExpired=function(t){this._accessTokenExpired.addHandler(t)},t.prototype.removeAccessTokenExpired=function(t){this._accessTokenExpired.removeHandler(t)},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.User=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0);e.User=function(){function t(e){var r=e.id_token,i=e.session_state,n=e.access_token,o=e.token_type,s=e.scope,a=e.profile,u=e.expires_at,c=e.state;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id_token=r,this.session_state=i,this.access_token=n,this.token_type=o,this.scope=s,this.profile=a,this.expires_at=u,this.state=c}return t.prototype.toStorageString=function(){return n.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},t.fromStorageString=function(e){return n.Log.debug("User.fromStorageString"),new t(JSON.parse(e))},i(t,[{key:"expires_in",get:function(){if(this.expires_at){var t=parseInt(Date.now()/1e3);return this.expires_at-t}}},{key:"expired",get:function(){var t=this.expires_in;if(void 0!==t)return t<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){for(var t="xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx",e="0123456789abcdef",r=0,i="",n=0;n<32;n++)"-"!==t[n]&&"4"!==t[n]&&(r=16*Math.random()|0),"x"===t[n]?i+=e[r]:"y"===t[n]?(r&=3,i+=e[r|=8]):i+=t[n];return i},t.exports=e.default},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SigninState=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(4),s=function(t){return t&&t.__esModule?t:{default:t}}(r(14));e.SigninState=function(t){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.nonce,n=r.authority,o=r.client_id;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var a=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,arguments[0]));return!0===i?a._nonce=(0,s.default)():i&&(a._nonce=i),a._authority=n,a._client_id=o,a}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.toStorageString=function(){return n.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,nonce:this.nonce,authority:this.authority,client_id:this.client_id})},e.fromStorageString=function(t){return n.Log.debug("SigninState.fromStorageString"),new e(JSON.parse(t))},i(e,[{key:"nonce",get:function(){return this._nonce}},{key:"authority",get:function(){return this._authority}},{key:"client_id",get:function(){return this._client_id}}]),e}(o.State)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorResponse=void 0;var i=r(0);e.ErrorResponse=function(t){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.error,o=r.error_description,s=r.error_uri,a=r.state;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),!n)throw i.Log.error("No error passed to ErrorResponse"),new Error("error");var u=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,o||n));return u.name="ErrorResponse",u.error=n,u.error_description=o,u.error_uri=s,u.state=a,u}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e}(Error)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.JsonService=void 0;var i=r(0),n=r(1);e.JsonService=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.Global.XMLHttpRequest;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e&&Array.isArray(e)?this._contentTypes=e.slice():this._contentTypes=[],this._contentTypes.push("application/json"),this._XMLHttpRequest=r}return t.prototype.getJson=function(t,e){var r=this;if(!t)throw i.Log.error("JsonService.getJson: No url passed"),new Error("url");return i.Log.debug("JsonService.getJson, url: ",t),new Promise((function(n,o){var s=new r._XMLHttpRequest;s.open("GET",t);var a=r._contentTypes;s.onload=function(){if(i.Log.debug("JsonService.getJson: HTTP response received, status",s.status),200===s.status){var e=s.getResponseHeader("Content-Type");if(e&&a.find((function(t){if(e.startsWith(t))return!0})))try{return void n(JSON.parse(s.responseText))}catch(t){return i.Log.error("JsonService.getJson: Error parsing JSON response",t.message),void o(t)}o(Error("Invalid response Content-Type: "+e+", from URL: "+t))}else o(Error(s.statusText+" ("+s.status+")"))},s.onerror=function(){i.Log.error("JsonService.getJson: network error"),o(Error("Network Error"))},e&&(i.Log.debug("JsonService.getJson: token passed, setting Authorization header"),s.setRequestHeader("Authorization","Bearer "+e)),s.send()}))},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.OidcClient=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(6),s=r(16),a=r(35),u=r(34),c=r(33),h=r(32),f=r(15),l=r(4);e.OidcClient=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e instanceof o.OidcClientSettings?this._settings=e:this._settings=new o.OidcClientSettings(e)}return t.prototype.createSigninRequest=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.response_type,i=e.scope,o=e.redirect_uri,s=e.data,u=e.state,c=e.prompt,h=e.display,f=e.max_age,l=e.ui_locales,p=e.id_token_hint,g=e.login_hint,d=e.acr_values,v=e.resource,y=e.request,m=e.request_uri,F=e.extraQueryParams,S=arguments[1];n.Log.debug("OidcClient.createSigninRequest");var _=this._settings.client_id;r=r||this._settings.response_type,i=i||this._settings.scope,o=o||this._settings.redirect_uri,c=c||this._settings.prompt,h=h||this._settings.display,f=f||this._settings.max_age,l=l||this._settings.ui_locales,d=d||this._settings.acr_values,v=v||this._settings.resource,F=F||this._settings.extraQueryParams;var w=this._settings.authority;return this._metadataService.getAuthorizationEndpoint().then((function(e){n.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",e);var b=new a.SigninRequest({url:e,client_id:_,redirect_uri:o,response_type:r,scope:i,data:s||u,authority:w,prompt:c,display:h,max_age:f,ui_locales:l,id_token_hint:p,login_hint:g,acr_values:d,resource:v,request:y,request_uri:m,extraQueryParams:F}),E=b.state;return(S=S||t._stateStore).set(E.id,E.toStorageString()).then((function(){return b}))}))},t.prototype.processSigninResponse=function(t,e){var r=this;n.Log.debug("OidcClient.processSigninResponse");var i=new u.SigninResponse(t);return i.state?(e=e||this._stateStore).remove(i.state).then((function(t){if(!t)throw n.Log.error("OidcClient.processSigninResponse: No matching state found in storage"),new Error("No matching state found in storage");var e=f.SigninState.fromStorageString(t);return n.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),r._validator.validateSigninResponse(e,i)})):(n.Log.error("OidcClient.processSigninResponse: No state in response"),Promise.reject(new Error("No state in response")))},t.prototype.createSignoutRequest=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.id_token_hint,i=e.data,o=e.state,s=e.post_logout_redirect_uri,a=arguments[1];return n.Log.debug("OidcClient.createSignoutRequest"),s=s||this._settings.post_logout_redirect_uri,this._metadataService.getEndSessionEndpoint().then((function(e){if(!e)throw n.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");n.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",e);var u=new c.SignoutRequest({url:e,id_token_hint:r,post_logout_redirect_uri:s,data:i||o}),h=u.state;return h&&(n.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(a=a||t._stateStore).set(h.id,h.toStorageString())),u}))},t.prototype.processSignoutResponse=function(t,e){var r=this;n.Log.debug("OidcClient.processSignoutResponse");var i=new h.SignoutResponse(t);if(!i.state)return n.Log.debug("OidcClient.processSignoutResponse: No state in response"),i.error?(n.Log.warn("OidcClient.processSignoutResponse: Response was error: ",i.error),Promise.reject(new s.ErrorResponse(i))):Promise.resolve(i);var o=i.state;return(e=e||this._stateStore).remove(o).then((function(t){if(!t)throw n.Log.error("OidcClient.processSignoutResponse: No matching state found in storage"),new Error("No matching state found in storage");var e=l.State.fromStorageString(t);return n.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),r._validator.validateSignoutResponse(e,i)}))},t.prototype.clearStaleState=function(t){return n.Log.debug("OidcClient.clearStaleState"),t=t||this._stateStore,l.State.clearStaleState(t,this.settings.staleStateAge)},i(t,[{key:"_stateStore",get:function(){return this.settings.stateStore}},{key:"_validator",get:function(){return this.settings.validator}},{key:"_metadataService",get:function(){return this.settings.metadataService}},{key:"settings",get:function(){return this._settings}},{key:"metadataService",get:function(){return this._metadataService}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CordovaIFrameNavigator=void 0;var i=r(7);e.CordovaIFrameNavigator=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.prepare=function(t){t.popupWindowFeatures="hidden=yes";var e=new i.CordovaPopupWindow(t);return Promise.resolve(e)},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CordovaPopupNavigator=void 0;var i=r(7);e.CordovaPopupNavigator=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.prepare=function(t){var e=new i.CordovaPopupWindow(t);return Promise.resolve(e)},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SilentRenewService=void 0;var i=r(0);e.SilentRenewService=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._userManager=e}return t.prototype.start=function(){this._callback||(this._callback=this._tokenExpiring.bind(this),this._userManager.events.addAccessTokenExpiring(this._callback),this._userManager.getUser().then((function(t){})).catch((function(t){i.Log.error("SilentRenewService.start: Error from getUser:",t.message)})))},t.prototype.stop=function(){this._callback&&(this._userManager.events.removeAccessTokenExpiring(this._callback),delete this._callback)},t.prototype._tokenExpiring=function(){var t=this;this._userManager.signinSilent().then((function(t){i.Log.debug("SilentRenewService._tokenExpiring: Silent token renewal successful")}),(function(e){i.Log.error("SilentRenewService._tokenExpiring: Error from signinSilent:",e.message),t._userManager.events._raiseSilentRenewError(e)}))},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Timer=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(1),s=r(11);e.Timer=function(t){function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.timer,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var s=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,r));return s._timer=i,s._nowFunc=n||function(){return Date.now()/1e3},s}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.init=function(t){t<=0&&(t=1),t=parseInt(t);var e=this.now+t;if(this.expiration===e&&this._timerHandle)n.Log.debug("Timer.init timer "+this._name+" skipping initialization since already initialized for expiration:",this.expiration);else{this.cancel(),n.Log.debug("Timer.init timer "+this._name+" for duration:",t),this._expiration=e;var r=5;t<r&&(r=t),this._timerHandle=this._timer.setInterval(this._callback.bind(this),1e3*r)}},e.prototype.cancel=function(){this._timerHandle&&(n.Log.debug("Timer.cancel: ",this._name),this._timer.clearInterval(this._timerHandle),this._timerHandle=null)},e.prototype._callback=function(){var e=this._expiration-this.now;n.Log.debug("Timer.callback; "+this._name+" timer expires in:",e),this._expiration<=this.now&&(this.cancel(),t.prototype.raise.call(this))},i(e,[{key:"now",get:function(){return parseInt(this._nowFunc())}},{key:"expiration",get:function(){return this._expiration}}]),e}(s.Event)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UserManagerEvents=void 0;var i=r(0),n=r(12),o=r(11);e.UserManagerEvents=function(t){function e(r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var i=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,r));return i._userLoaded=new o.Event("User loaded"),i._userUnloaded=new o.Event("User unloaded"),i._silentRenewError=new o.Event("Silent renew error"),i._userSignedOut=new o.Event("User signed out"),i._userSessionChanged=new o.Event("User session changed"),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.load=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];i.Log.debug("UserManagerEvents.load"),t.prototype.load.call(this,e),r&&this._userLoaded.raise(e)},e.prototype.unload=function(){i.Log.debug("UserManagerEvents.unload"),t.prototype.unload.call(this),this._userUnloaded.raise()},e.prototype.addUserLoaded=function(t){this._userLoaded.addHandler(t)},e.prototype.removeUserLoaded=function(t){this._userLoaded.removeHandler(t)},e.prototype.addUserUnloaded=function(t){this._userUnloaded.addHandler(t)},e.prototype.removeUserUnloaded=function(t){this._userUnloaded.removeHandler(t)},e.prototype.addSilentRenewError=function(t){this._silentRenewError.addHandler(t)},e.prototype.removeSilentRenewError=function(t){this._silentRenewError.removeHandler(t)},e.prototype._raiseSilentRenewError=function(t){i.Log.debug("UserManagerEvents._raiseSilentRenewError",t.message),this._silentRenewError.raise(t)},e.prototype.addUserSignedOut=function(t){this._userSignedOut.addHandler(t)},e.prototype.removeUserSignedOut=function(t){this._userSignedOut.removeHandler(t)},e.prototype._raiseUserSignedOut=function(t){i.Log.debug("UserManagerEvents._raiseUserSignedOut"),this._userSignedOut.raise(t)},e.prototype.addUserSessionChanged=function(t){this._userSessionChanged.addHandler(t)},e.prototype.removeUserSessionChanged=function(t){this._userSessionChanged.removeHandler(t)},e.prototype._raiseUserSessionChanged=function(t){i.Log.debug("UserManagerEvents._raiseUserSessionChanged"),this._userSessionChanged.raise(t)},e}(n.AccessTokenEvents)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IFrameWindow=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0);e.IFrameWindow=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._promise=new Promise((function(t,e){r._resolve=t,r._reject=e})),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.style.width=0,this._frame.style.height=0,window.document.body.appendChild(this._frame)}return t.prototype.navigate=function(t){if(t&&t.url){var e=t.silentRequestTimeout||1e4;n.Log.debug("IFrameWindow.navigate: Using timeout of:",e),this._timer=window.setTimeout(this._timeout.bind(this),e),this._frame.src=t.url}else this._error("No url provided");return this.promise},t.prototype._success=function(t){this._cleanup(),n.Log.debug("IFrameWindow: Successful response from frame window"),this._resolve(t)},t.prototype._error=function(t){this._cleanup(),n.Log.error(t),this._reject(new Error(t))},t.prototype.close=function(){this._cleanup()},t.prototype._cleanup=function(){this._frame&&(n.Log.debug("IFrameWindow: cleanup"),window.removeEventListener("message",this._boundMessageEvent,!1),window.clearTimeout(this._timer),window.document.body.removeChild(this._frame),this._timer=null,this._frame=null,this._boundMessageEvent=null)},t.prototype._timeout=function(){n.Log.debug("IFrameWindow.timeout"),this._error("Frame window timed out")},t.prototype._message=function(t){if(n.Log.debug("IFrameWindow.message"),this._timer&&t.origin===this._origin&&t.source===this._frame.contentWindow){var e=t.data;e?this._success({url:e}):this._error("Invalid response from frame")}},t.notifyParent=function(t){n.Log.debug("IFrameWindow.notifyParent"),window.parent&&window!==window.parent&&(t=t||window.location.href)&&(n.Log.debug("IFrameWindow.notifyParent: posting url message to parent"),window.parent.postMessage(t,location.protocol+"//"+location.host))},i(t,[{key:"promise",get:function(){return this._promise}},{key:"_origin",get:function(){return location.protocol+"//"+location.host}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IFrameNavigator=void 0;var i=r(0),n=r(24);e.IFrameNavigator=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.prepare=function(t){var e=new n.IFrameWindow(t);return Promise.resolve(e)},t.prototype.callback=function(t){i.Log.debug("IFrameNavigator.callback");try{return n.IFrameWindow.notifyParent(t),Promise.resolve()}catch(t){return Promise.reject(t)}},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PopupWindow=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(2);e.PopupWindow=function(){function t(e){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._promise=new Promise((function(t,e){r._resolve=t,r._reject=e}));var i=e.popupWindowTarget||"_blank",o=e.popupWindowFeatures||"location=no,toolbar=no,width=500,height=500,left=100,top=100;";this._popup=window.open("",i,o),this._popup&&(n.Log.debug("PopupWindow.ctor: popup successfully created"),this._checkForPopupClosedTimer=window.setInterval(this._checkForPopupClosed.bind(this),500))}return t.prototype.navigate=function(t){return this._popup?t&&t.url?(n.Log.debug("PopupWindow.navigate: Setting URL in popup"),this._id=t.id,this._id&&(window["popupCallback_"+t.id]=this._callback.bind(this)),this._popup.focus(),this._popup.window.location=t.url):(this._error("PopupWindow.navigate: no url provided"),this._error("No url provided")):this._error("PopupWindow.navigate: Error opening popup window"),this.promise},t.prototype._success=function(t){n.Log.debug("PopupWindow.callback: Successful response from popup window"),this._cleanup(),this._resolve(t)},t.prototype._error=function(t){n.Log.error("PopupWindow.error: ",t),this._cleanup(),this._reject(new Error(t))},t.prototype.close=function(){this._cleanup(!1)},t.prototype._cleanup=function(t){n.Log.debug("PopupWindow.cleanup"),window.clearInterval(this._checkForPopupClosedTimer),this._checkForPopupClosedTimer=null,delete window["popupCallback_"+this._id],this._popup&&!t&&this._popup.close(),this._popup=null},t.prototype._checkForPopupClosed=function(){this._popup&&!this._popup.closed||this._error("Popup window closed")},t.prototype._callback=function(t,e){this._cleanup(e),t?(n.Log.debug("PopupWindow.callback success"),this._success({url:t})):(n.Log.debug("PopupWindow.callback: Invalid response from popup"),this._error("Invalid response from popup"))},t.notifyOpener=function(t,e,r){if(window.opener){if(t=t||window.location.href){var i=o.UrlUtility.parseUrlFragment(t,r);if(i.state){var s="popupCallback_"+i.state,a=window.opener[s];a?(n.Log.debug("PopupWindow.notifyOpener: passing url message to opener"),a(t,e)):n.Log.warn("PopupWindow.notifyOpener: no matching callback found on opener")}else n.Log.warn("PopupWindow.notifyOpener: no state found in response url")}}else n.Log.warn("PopupWindow.notifyOpener: no window.opener. Can't complete notification.")},i(t,[{key:"promise",get:function(){return this._promise}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PopupNavigator=void 0;var i=r(0),n=r(26);e.PopupNavigator=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.prepare=function(t){var e=new n.PopupWindow(t);return Promise.resolve(e)},t.prototype.callback=function(t,e,r){i.Log.debug("PopupNavigator.callback");try{return n.PopupWindow.notifyOpener(t,e,r),Promise.resolve()}catch(t){return Promise.reject(t)}},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RedirectNavigator=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0);e.RedirectNavigator=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.prototype.prepare=function(){return Promise.resolve(this)},t.prototype.navigate=function(t){return t&&t.url?(window.location=t.url,Promise.resolve()):(n.Log.error("RedirectNavigator.navigate: No url provided"),Promise.reject(new Error("No url provided")))},i(t,[{key:"url",get:function(){return window.location.href}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UserManagerSettings=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=(r(0),r(6)),o=r(28),s=r(27),a=r(25),u=r(5),c=r(1);e.UserManagerSettings=function(t){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.popup_redirect_uri,n=r.popup_post_logout_redirect_uri,h=r.popupWindowFeatures,f=r.popupWindowTarget,l=r.silent_redirect_uri,p=r.silentRequestTimeout,g=r.automaticSilentRenew,d=void 0!==g&&g,v=r.includeIdTokenInSilentRenew,y=void 0===v||v,m=r.monitorSession,F=void 0===m||m,S=r.checkSessionInterval,_=void 0===S?2e3:S,w=r.stopCheckSessionOnError,b=void 0===w||w,E=r.revokeAccessTokenOnSignout,x=void 0!==E&&E,A=r.accessTokenExpiringNotificationTime,P=void 0===A?60:A,C=r.redirectNavigator,k=void 0===C?new o.RedirectNavigator:C,R=r.popupNavigator,T=void 0===R?new s.PopupNavigator:R,I=r.iframeNavigator,D=void 0===I?new a.IFrameNavigator:I,B=r.userStore,L=void 0===B?new u.WebStorageStateStore({store:c.Global.sessionStorage}):B;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var N=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,arguments[0]));return N._popup_redirect_uri=i,N._popup_post_logout_redirect_uri=n,N._popupWindowFeatures=h,N._popupWindowTarget=f,N._silent_redirect_uri=l,N._silentRequestTimeout=p,N._automaticSilentRenew=!!d,N._includeIdTokenInSilentRenew=y,N._accessTokenExpiringNotificationTime=P,N._monitorSession=F,N._checkSessionInterval=_,N._stopCheckSessionOnError=b,N._revokeAccessTokenOnSignout=x,N._redirectNavigator=k,N._popupNavigator=T,N._iframeNavigator=D,N._userStore=L,N}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),i(e,[{key:"popup_redirect_uri",get:function(){return this._popup_redirect_uri}},{key:"popup_post_logout_redirect_uri",get:function(){return this._popup_post_logout_redirect_uri}},{key:"popupWindowFeatures",get:function(){return this._popupWindowFeatures}},{key:"popupWindowTarget",get:function(){return this._popupWindowTarget}},{key:"silent_redirect_uri",get:function(){return this._silent_redirect_uri}},{key:"silentRequestTimeout",get:function(){return this._silentRequestTimeout}},{key:"automaticSilentRenew",get:function(){return!(!this.silent_redirect_uri||!this._automaticSilentRenew)}},{key:"includeIdTokenInSilentRenew",get:function(){return this._includeIdTokenInSilentRenew}},{key:"accessTokenExpiringNotificationTime",get:function(){return this._accessTokenExpiringNotificationTime}},{key:"monitorSession",get:function(){return this._monitorSession}},{key:"checkSessionInterval",get:function(){return this._checkSessionInterval}},{key:"stopCheckSessionOnError",get:function(){return this._stopCheckSessionOnError}},{key:"revokeAccessTokenOnSignout",get:function(){return this._revokeAccessTokenOnSignout}},{key:"redirectNavigator",get:function(){return this._redirectNavigator}},{key:"popupNavigator",get:function(){return this._popupNavigator}},{key:"iframeNavigator",get:function(){return this._iframeNavigator}},{key:"userStore",get:function(){return this._userStore}}]),e}(n.OidcClientSettings)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UserManager=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0),o=r(18),s=r(29),a=r(13),u=r(23),c=r(21),h=r(10),f=r(8);e.UserManager=function(t){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.SilentRenewService,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h.SessionMonitor,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:f.TokenRevocationClient;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),r instanceof s.UserManagerSettings||(r=new s.UserManagerSettings(r));var l=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,t.call(this,r));return l._events=new u.UserManagerEvents(r),l._silentRenewService=new i(l),l.settings.automaticSilentRenew&&(n.Log.debug("UserManager.ctor: automaticSilentRenew is configured, setting up silent renew"),l.startSilentRenew()),l.settings.monitorSession&&(n.Log.debug("UserManager.ctor: monitorSession is configured, setting up session monitor"),l._sessionMonitor=new o(l)),l._tokenRevocationClient=new a(l._settings),l}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),e.prototype.getUser=function(){var t=this;return this._loadUser().then((function(e){return e?(n.Log.info("UserManager.getUser: user loaded"),t._events.load(e,!1),e):(n.Log.info("UserManager.getUser: user not found in storage"),null)}))},e.prototype.removeUser=function(){var t=this;return this.storeUser(null).then((function(){n.Log.info("UserManager.removeUser: user removed from storage"),t._events.unload()}))},e.prototype.signinRedirect=function(t){return this._signinStart(t,this._redirectNavigator).then((function(){n.Log.info("UserManager.signinRedirect: successful")}))},e.prototype.signinRedirectCallback=function(t){return this._signinEnd(t||this._redirectNavigator.url).then((function(t){return t&&(t.profile&&t.profile.sub?n.Log.info("UserManager.signinRedirectCallback: successful, signed in sub: ",t.profile.sub):n.Log.info("UserManager.signinRedirectCallback: no sub")),t}))},e.prototype.signinPopup=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.redirect_uri||this.settings.popup_redirect_uri||this.settings.redirect_uri;return e?(t.redirect_uri=e,t.display="popup",this._signin(t,this._popupNavigator,{startUrl:e,popupWindowFeatures:t.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:t.popupWindowTarget||this.settings.popupWindowTarget}).then((function(t){return t&&(t.profile&&t.profile.sub?n.Log.info("UserManager.signinPopup: signinPopup successful, signed in sub: ",t.profile.sub):n.Log.info("UserManager.signinPopup: no sub")),t}))):(n.Log.error("UserManager.signinPopup: No popup_redirect_uri or redirect_uri configured"),Promise.reject(new Error("No popup_redirect_uri or redirect_uri configured")))},e.prototype.signinPopupCallback=function(t){return this._signinCallback(t,this._popupNavigator).then((function(t){return t&&(t.profile&&t.profile.sub?n.Log.info("UserManager.signinPopupCallback: successful, signed in sub: ",t.profile.sub):n.Log.info("UserManager.signinPopupCallback: no sub")),t})).catch((function(t){n.Log.error("UserManager.signinPopupCallback error: "+t&&t.message)}))},e.prototype.signinSilent=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.redirect_uri||this.settings.silent_redirect_uri;return r?(e.redirect_uri=r,e.prompt="none",(e.id_token_hint||!this.settings.includeIdTokenInSilentRenew?Promise.resolve():this._loadUser().then((function(t){e.id_token_hint=t&&t.id_token}))).then((function(){return t._signin(e,t._iframeNavigator,{startUrl:r,silentRequestTimeout:e.silentRequestTimeout||t.settings.silentRequestTimeout})})).then((function(t){return t&&(t.profile&&t.profile.sub?n.Log.info("UserManager.signinSilent: successful, signed in sub: ",t.profile.sub):n.Log.info("UserManager.signinSilent: no sub")),t}))):(n.Log.error("UserManager.signinSilent: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},e.prototype.signinSilentCallback=function(t){return this._signinCallback(t,this._iframeNavigator).then((function(t){return t&&(t.profile&&t.profile.sub?n.Log.info("UserManager.signinSilentCallback: successful, signed in sub: ",t.profile.sub):n.Log.info("UserManager.signinSilentCallback: no sub")),t}))},e.prototype.querySessionStatus=function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.redirect_uri||this.settings.silent_redirect_uri;return r?(e.redirect_uri=r,e.prompt="none",e.response_type="id_token",e.scope="openid",this._signinStart(e,this._iframeNavigator,{startUrl:r,silentRequestTimeout:e.silentRequestTimeout||this.settings.silentRequestTimeout}).then((function(e){return t.processSigninResponse(e.url).then((function(t){if(n.Log.debug("UserManager.querySessionStatus: got signin response"),t.session_state&&t.profile.sub&&t.profile.sid)return n.Log.info("UserManager.querySessionStatus: querySessionStatus success for sub: ",t.profile.sub),{session_state:t.session_state,sub:t.profile.sub,sid:t.profile.sid};n.Log.info("querySessionStatus successful, user not authenticated")}))}))):(n.Log.error("UserManager.querySessionStatus: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},e.prototype._signin=function(t,e){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signinStart(t,e,i).then((function(t){return r._signinEnd(t.url)}))},e.prototype._signinStart=function(t,e){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.prepare(i).then((function(e){return n.Log.debug("UserManager._signinStart: got navigator window handle"),r.createSigninRequest(t).then((function(t){return n.Log.debug("UserManager._signinStart: got signin request"),i.url=t.url,i.id=t.state.id,e.navigate(i)})).catch((function(t){throw e.close&&(n.Log.debug("UserManager._signinStart: Error after preparing navigator, closing navigator window"),e.close()),t}))}))},e.prototype._signinEnd=function(t){var e=this;return this.processSigninResponse(t).then((function(t){n.Log.debug("UserManager._signinEnd: got signin response");var r=new a.User(t);return e.storeUser(r).then((function(){return n.Log.debug("UserManager._signinEnd: user stored"),e._events.load(r),r}))}))},e.prototype._signinCallback=function(t,e){return n.Log.debug("UserManager._signinCallback"),e.callback(t)},e.prototype.signoutRedirect=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.post_logout_redirect_uri||this.settings.post_logout_redirect_uri;return e&&(t.post_logout_redirect_uri=e),this._signoutStart(t,this._redirectNavigator).then((function(){n.Log.info("UserManager.signoutRedirect: successful")}))},e.prototype.signoutRedirectCallback=function(t){return this._signoutEnd(t||this._redirectNavigator.url).then((function(t){return n.Log.info("UserManager.signoutRedirectCallback: successful"),t}))},e.prototype.signoutPopup=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.post_logout_redirect_uri||this.settings.popup_post_logout_redirect_uri||this.settings.post_logout_redirect_uri;return t.post_logout_redirect_uri=e,t.display="popup",t.post_logout_redirect_uri&&(t.state=t.state||{}),this._signout(t,this._popupNavigator,{startUrl:e,popupWindowFeatures:t.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:t.popupWindowTarget||this.settings.popupWindowTarget}).then((function(){n.Log.info("UserManager.signinPopup: successful")}))},e.prototype.signoutPopupCallback=function(t,e){return void 0===e&&"boolean"==typeof t&&(t=null,e=!0),this._popupNavigator.callback(t,e,"?").then((function(){n.Log.info("UserManager.signoutPopupCallback: successful")}))},e.prototype._signout=function(t,e){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signoutStart(t,e,i).then((function(t){return r._signoutEnd(t.url)}))},e.prototype._signoutStart=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return arguments[1].prepare(r).then((function(i){return n.Log.debug("UserManager._signoutStart: got navigator window handle"),e._loadUser().then((function(o){return n.Log.debug("UserManager._signoutStart: loaded current user from storage"),(e._settings.revokeAccessTokenOnSignout?e._revokeInternal(o):Promise.resolve()).then((function(){var s=t.id_token_hint||o&&o.id_token;return s&&(n.Log.debug("UserManager._signoutStart: Setting id_token into signout request"),t.id_token_hint=s),e.removeUser().then((function(){return n.Log.debug("UserManager._signoutStart: user removed, creating signout request"),e.createSignoutRequest(t).then((function(t){return n.Log.debug("UserManager._signoutStart: got signout request"),r.url=t.url,t.state&&(r.id=t.state.id),i.navigate(r)}))}))}))})).catch((function(t){throw i.close&&(n.Log.debug("UserManager._signoutStart: Error after preparing navigator, closing navigator window"),i.close()),t}))}))},e.prototype._signoutEnd=function(t){return this.processSignoutResponse(t).then((function(t){return n.Log.debug("UserManager._signoutEnd: got signout response"),t}))},e.prototype.revokeAccessToken=function(){var t=this;return this._loadUser().then((function(e){return t._revokeInternal(e,!0).then((function(r){if(r)return n.Log.debug("UserManager.revokeAccessToken: removing token properties from user and re-storing"),e.access_token=null,e.expires_at=null,e.token_type=null,t.storeUser(e).then((function(){n.Log.debug("UserManager.revokeAccessToken: user stored"),t._events.load(e)}))}))})).then((function(){n.Log.info("UserManager.revokeAccessToken: access token revoked successfully")}))},e.prototype._revokeInternal=function(t,e){var r=t&&t.access_token;return!r||r.indexOf(".")>=0?(n.Log.debug("UserManager.revokeAccessToken: no need to revoke due to no user, token, or JWT format"),Promise.resolve(!1)):this._tokenRevocationClient.revoke(r,e).then((function(){return!0}))},e.prototype.startSilentRenew=function(){this._silentRenewService.start()},e.prototype.stopSilentRenew=function(){this._silentRenewService.stop()},e.prototype._loadUser=function(){return this._userStore.get(this._userStoreKey).then((function(t){return t?(n.Log.debug("UserManager._loadUser: user storageString loaded"),a.User.fromStorageString(t)):(n.Log.debug("UserManager._loadUser: no user storageString"),null)}))},e.prototype.storeUser=function(t){if(t){n.Log.debug("UserManager.storeUser: storing user");var e=t.toStorageString();return this._userStore.set(this._userStoreKey,e)}return n.Log.debug("storeUser.storeUser: removing user"),this._userStore.remove(this._userStoreKey)},i(e,[{key:"_redirectNavigator",get:function(){return this.settings.redirectNavigator}},{key:"_popupNavigator",get:function(){return this.settings.popupNavigator}},{key:"_iframeNavigator",get:function(){return this.settings.iframeNavigator}},{key:"_userStore",get:function(){return this.settings.userStore}},{key:"events",get:function(){return this._events}},{key:"_userStoreKey",get:function(){return"user:"+this.settings.authority+":"+this.settings.client_id}}]),e}(o.OidcClient)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InMemoryWebStorage=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(0);e.InMemoryWebStorage=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._data={}}return t.prototype.getItem=function(t){return n.Log.debug("InMemoryWebStorage.getItem",t),this._data[t]},t.prototype.setItem=function(t,e){n.Log.debug("InMemoryWebStorage.setItem",t),this._data[t]=e},t.prototype.removeItem=function(t){n.Log.debug("InMemoryWebStorage.removeItem",t),delete this._data[t]},t.prototype.key=function(t){return Object.getOwnPropertyNames(this._data)[t]},i(t,[{key:"length",get:function(){return Object.getOwnPropertyNames(this._data).length}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SignoutResponse=void 0;var i=r(2);e.SignoutResponse=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var r=i.UrlUtility.parseUrlFragment(e,"?");this.error=r.error,this.error_description=r.error_description,this.error_uri=r.error_uri,this.state=r.state}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SignoutRequest=void 0;var i=r(0),n=r(2),o=r(4);e.SignoutRequest=function t(e){var r=e.url,s=e.id_token_hint,a=e.post_logout_redirect_uri,u=e.data;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!r)throw i.Log.error("SignoutRequest.ctor: No url passed"),new Error("url");s&&(r=n.UrlUtility.addQueryParam(r,"id_token_hint",s)),a&&(r=n.UrlUtility.addQueryParam(r,"post_logout_redirect_uri",a),u&&(this.state=new o.State({data:u}),r=n.UrlUtility.addQueryParam(r,"state",this.state.id))),this.url=r}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SigninResponse=void 0;var i=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),n=r(2);e.SigninResponse=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var r=n.UrlUtility.parseUrlFragment(e,"#");this.error=r.error,this.error_description=r.error_description,this.error_uri=r.error_uri,this.state=r.state,this.id_token=r.id_token,this.session_state=r.session_state,this.access_token=r.access_token,this.token_type=r.token_type,this.scope=r.scope,this.profile=void 0;var i=parseInt(r.expires_in);if("number"==typeof i&&i>0){var o=parseInt(Date.now()/1e3);this.expires_at=o+i}}return i(t,[{key:"expires_in",get:function(){if(this.expires_at){var t=parseInt(Date.now()/1e3);return this.expires_at-t}}},{key:"expired",get:function(){var t=this.expires_in;if(void 0!==t)return t<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}},{key:"isOpenIdConnect",get:function(){return this.scopes.indexOf("openid")>=0||!!this.id_token}}]),t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SigninRequest=void 0;var i=r(0),n=r(2),o=r(15);e.SigninRequest=function(){function t(e){var r=e.url,s=e.client_id,a=e.redirect_uri,u=e.response_type,c=e.scope,h=e.authority,f=e.data,l=e.prompt,p=e.display,g=e.max_age,d=e.ui_locales,v=e.id_token_hint,y=e.login_hint,m=e.acr_values,F=e.resource,S=e.request,_=e.request_uri,w=e.extraQueryParams;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!r)throw i.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!s)throw i.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!a)throw i.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!u)throw i.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!c)throw i.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!h)throw i.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var b=t.isOidc(u);this.state=new o.SigninState({nonce:b,data:f,client_id:s,authority:h}),r=n.UrlUtility.addQueryParam(r,"client_id",s),r=n.UrlUtility.addQueryParam(r,"redirect_uri",a),r=n.UrlUtility.addQueryParam(r,"response_type",u),r=n.UrlUtility.addQueryParam(r,"scope",c),r=n.UrlUtility.addQueryParam(r,"state",this.state.id),b&&(r=n.UrlUtility.addQueryParam(r,"nonce",this.state.nonce));var E={prompt:l,display:p,max_age:g,ui_locales:d,id_token_hint:v,login_hint:y,acr_values:m,resource:F,request:S,request_uri:_};for(var x in E)E[x]&&(r=n.UrlUtility.addQueryParam(r,x,E[x]));for(var A in w)r=n.UrlUtility.addQueryParam(r,A,w[A]);this.url=r}return t.isOidc=function(t){return!!t.split(/\s+/g).filter((function(t){return"id_token"===t}))[0]},t.isOAuth=function(t){return!!t.split(/\s+/g).filter((function(t){return"token"===t}))[0]},t}()},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){e.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,u=(1<<a)-1,c=u>>1,h=-7,f=r?n-1:0,l=r?-1:1,p=t[e+f];for(f+=l,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+f],f+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=i;h>0;s=256*s+t[e+f],f+=l,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,i),o-=c}return(p?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,r,i,n,o){var s,a,u,c=8*o-n-1,h=(1<<c)-1,f=h>>1,l=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,g=i?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?l/u:l*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(e*u-1)*Math.pow(2,n),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),s=0));n>=8;t[r+p]=255&a,p+=g,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;t[r+p]=255&s,p+=g,s/=256,c-=8);t[r+p-g]|=128*d}},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){for(var e,r=u(t),i=r[0],s=r[1],a=new o(function(t,e,r){return 3*(e+r)/4-r}(0,i,s)),c=0,h=s>0?i-4:i,f=0;f<h;f+=4)e=n[t.charCodeAt(f)]<<18|n[t.charCodeAt(f+1)]<<12|n[t.charCodeAt(f+2)]<<6|n[t.charCodeAt(f+3)],a[c++]=e>>16&255,a[c++]=e>>8&255,a[c++]=255&e;return 2===s&&(e=n[t.charCodeAt(f)]<<2|n[t.charCodeAt(f+1)]>>4,a[c++]=255&e),1===s&&(e=n[t.charCodeAt(f)]<<10|n[t.charCodeAt(f+1)]<<4|n[t.charCodeAt(f+2)]>>2,a[c++]=e>>8&255,a[c++]=255&e),a},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],s=0,a=r-n;s<a;s+=16383)o.push(h(t,s,s+16383>a?a:s+16383));return 1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"=")),o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t){return i[t>>18&63]+i[t>>12&63]+i[t>>6&63]+i[63&t]}function h(t,e,r){for(var i,n=[],o=e;o<r;o+=3)i=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),n.push(c(i));return n.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";(function(t){var i=r(38),n=r(37),o=r(36);function s(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<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,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return c(this,t,e,r)}function c(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,i){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,r):new Uint8Array(e,r,i),u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=l(t,e),t}(t,e,r,i):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|g(e,r),n=(t=a(t,i)).write(e,r);return n!==i&&(t=t.slice(0,n)),t}(t,e,r):function(t,e){if(u.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||function(t){return t!=t}(e.length)?a(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(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 f(t,e){if(h(e),t=a(t,e<0?0:0|p(e)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().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 r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return M(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(i)return M(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function v(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:y(t,e,r,i,n);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,i,n){var o,s=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){var h=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===u)return h*s}else-1!==h&&(o-=o-h),h=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var f=!0,l=0;l<u;l++)if(c(t,o+l)!==c(e,l)){f=!1;break}if(f)return o}return-1}function m(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function F(t,e,r,i){return K(M(e,t.length-r),t,r,i)}function S(t,e,r,i){return K(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function _(t,e,r,i){return S(t,e,r,i)}function w(t,e,r,i){return K(j(e),t,r,i)}function b(t,e,r,i){return K(function(t,e){for(var r,i,n,o=[],s=0;s<t.length&&!((e-=2)<0);++s)i=(r=t.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(e,t.length-r),t,r,i)}function E(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n<r;){var o,s,a,u,c=t[n],h=null,f=c>239?4:c>223?3:c>191?2:1;if(n+f<=r)switch(f){case 1:c<128&&(h=c);break;case 2:128==(192&(o=t[n+1]))&&(u=(31&c)<<6|63&o)>127&&(h=u);break;case 3:o=t[n+1],s=t[n+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:o=t[n+1],s=t[n+2],a=t[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,f=1):h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h),n+=f}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);for(var r="",i=0;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=A));return r}(i)}e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),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=s(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t},u.from=function(t,e,r){return c(null,t,e,r)},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,r){return function(t,e,r,i){return h(e),e<=0?a(t,e):void 0!==r?"string"==typeof i?a(t,e).fill(r,i):a(t,e).fill(r):a(t,e)}(null,t,e,r)},u.allocUnsafe=function(t){return f(null,t)},u.allocUnsafeSlow=function(t){return f(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 r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?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(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=u.allocUnsafe(e),n=0;for(r=0;r<t.length;++r){var s=t[r];if(!u.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n),n+=s.length}return i},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)d(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)d(this,e,e+3),d(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)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):function(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return P(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}.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="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},u.prototype.compare=function(t,e,r,i,n){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),c=this.slice(i,n),h=t.slice(e,r),f=0;f<a;++f)if(c[f]!==h[f]){o=c[f],s=h[f];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},u.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return F(this,t,e,r);case"ascii":return S(this,t,e,r);case"latin1":case"binary":return _(this,t,e,r);case"base64":return w(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function P(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function C(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function k(t,e,r){var i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=e;o<r;++o)n+=H(t[o]);return n}function R(t,e,r){for(var i=t.slice(e,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function T(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function I(t,e,r,i,n,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function D(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,o=Math.min(t.length-r,2);n<o;++n)t[r+n]=(e&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function B(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,o=Math.min(t.length-r,4);n<o;++n)t[r+n]=e>>>8*(i?n:3-n)&255}function L(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,i,o){return o||L(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function U(t,e,r,i,o){return o||L(t,0,r,8),n.write(t,e,r,i,52,8),r+8}u.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=u.prototype;else{var n=e-t;r=new u(n,void 0);for(var o=0;o<n;++o)r[o]=this[o+t]}return r},u.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||T(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i},u.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||T(t,e,this.length);for(var i=this[t+--e],n=1;e>0&&(n*=256);)i+=this[t+--e]*n;return i},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,r){t|=0,e|=0,r||T(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||T(t,e,this.length);for(var i=e,n=1,o=this[t+--i];i>0&&(n*=256);)o+=this[t+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*e)),o},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 r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},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),n.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),n.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),n.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),n.read(this,t,!1,52,8)},u.prototype.writeUIntLE=function(t,e,r,i){t=+t,e|=0,r|=0,i||I(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[e]=255&t;++o<r&&(n*=256);)this[e+o]=t/n&255;return e+r},u.prototype.writeUIntBE=function(t,e,r,i){t=+t,e|=0,r|=0,i||I(this,t,e,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[e+n]=255&t;--n>=0&&(o*=256);)this[e+n]=t/o&255;return e+r},u.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||I(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,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||I(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):B(this,t,e,!0),e+4},u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||I(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):B(this,t,e,!1),e+4},u.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);I(this,t,e,r,n-1,-n)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);I(this,t,e,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||I(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,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):D(this,t,e,!0),e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||I(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):D(this,t,e,!1),e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||I(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):B(this,t,e,!0),e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||I(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):B(this,t,e,!1),e+4},u.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n,o=i-r;if(this===t&&r<e&&e<i)for(n=o-1;n>=0;--n)t[n+e]=this[n+r];else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)t[n+e]=this[n+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},u.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length){var n=t.charCodeAt(0);n<256&&(t=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=u.isBuffer(t)?t:M(new u(t,i).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var O=/[^+\/0-9A-Za-z-_]/g;function H(t){return t<16?"0"+t.toString(16):t.toString(16)}function M(t,e){var r;e=e||1/0;for(var i=t.length,n=null,o=[],s=0;s<i;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function j(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(O,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function K(t,e,r,i){for(var n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(39))},function(t,e,r){"use strict";(function(t){var r="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},i={userAgent:!1},n={};if(void 0===o)var o={};o.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var n=function(){};if(n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var o;for(o in r)t.prototype[o]=r[o];var s=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(s=function(t,e){for(o=0;o<a.length;o+=1){var r=a[o],i=e[r];"function"==typeof i&&i!=Object.prototype[r]&&(t[r]=i)}})}catch(t){}s(t.prototype,r)}}};var s=s||function(t,e){var r={},i=r.lib={},n=i.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},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)}}}(),o=i.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,n=t.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var s=r[o>>>2]>>>24-o%4*8&255;e[i+o>>>2]|=s<<24-(i+o)%4*8}else for(o=0;o<n;o+=4)e[i+o>>>2]=r[o>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r=[],i=0;i<e;i+=4)r.push(4294967296*t.random()|0);return new o.init(r,e)}}),s=r.enc={},a=s.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new o.init(r,e/2)}},u=s.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new o.init(r,e)}},c=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},h=i.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,i=r.words,n=r.sigBytes,s=this.blockSize,a=n/(4*s),u=(a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0))*s,c=t.min(4*u,n);if(u){for(var h=0;h<u;h+=s)this._doProcessBlock(i,h);var f=i.splice(0,u);r.sigBytes-=c}return new o.init(f,c)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),f=(i.Hasher=h.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){h.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,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new f.HMAC.init(t,r).finalize(e)}}}),r.algo={});return r}(Math);!function(t){var e,r=(e=s).lib,i=r.Base,n=r.WordArray;(e=e.x64={}).Word=i.extend({init:function(t,e){this.high=t,this.low=e}}),e.WordArray=i.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,r=[],i=0;i<e;i++){var o=t[i];r.push(o.high),r.push(o.low)}return n.create(r,this.sigBytes)},clone:function(){for(var t=i.clone.call(this),e=t.words=this.words.slice(0),r=e.length,n=0;n<r;n++)e[n]=e[n].clone();return t}})}(),function(){var t=s,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var n=0;n<r;n+=3)for(var o=(e[n>>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,s=0;4>s&&n+.75*s<r;s++)t.push(i.charAt(o>>>6*(3-s)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(n=i.charAt(64))&&-1!=(n=t.indexOf(n))&&(r=n);for(var n=[],o=0,s=0;s<r;s++)if(s%4){var a=i.indexOf(t.charAt(s-1))<<s%4*2,u=i.indexOf(t.charAt(s))>>>6-s%4*2;n[o>>>2]|=(a|u)<<24-o%4*8,o++}return e.create(n,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){for(var e=s,r=(n=e.lib).WordArray,i=n.Hasher,n=e.algo,o=[],a=[],u=function(t){return 4294967296*(t-(0|t))|0},c=2,h=0;64>h;){var f;t:{f=c;for(var l=t.sqrt(f),p=2;p<=l;p++)if(!(f%p)){f=!1;break t}f=!0}f&&(8>h&&(o[h]=u(t.pow(c,.5))),a[h]=u(t.pow(c,1/3)),h++),c++}var g=[];n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],u=r[4],c=r[5],h=r[6],f=r[7],l=0;64>l;l++){if(16>l)g[l]=0|t[e+l];else{var p=g[l-15],d=g[l-2];g[l]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+g[l-7]+((d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10)+g[l-16]}p=f+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&c^~u&h)+a[l]+g[l],d=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&o^n&o),f=h,h=c,c=u,u=s+p|0,s=o,o=n,n=i,i=p+d|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+u|0,r[5]=r[5]+c|0,r[6]=r[6]+h|0,r[7]=r[7]+f|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=t.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=i._createHelper(n),e.HmacSHA256=i._createHmacHelper(n)}(Math),function(){function t(){return i.create.apply(i,arguments)}for(var e=s,r=e.lib.Hasher,i=(o=e.x64).Word,n=o.WordArray,o=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)],u=[],c=0;80>c;c++)u[c]=t();o=o.SHA512=r.extend({_doReset:function(){this._hash=new n.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(f=this._hash.words)[0],i=f[1],n=f[2],o=f[3],s=f[4],c=f[5],h=f[6],f=f[7],l=r.high,p=r.low,g=i.high,d=i.low,v=n.high,y=n.low,m=o.high,F=o.low,S=s.high,_=s.low,w=c.high,b=c.low,E=h.high,x=h.low,A=f.high,P=f.low,C=l,k=p,R=g,T=d,I=v,D=y,B=m,L=F,N=S,U=_,O=w,H=b,M=E,j=x,K=A,q=P,V=0;80>V;V++){var W=u[V];if(16>V)var J=W.high=0|t[e+2*V],Y=W.low=0|t[e+2*V+1];else{J=((Y=(J=u[V-15]).high)>>>1|(z=J.low)<<31)^(Y>>>8|z<<24)^Y>>>7;var z=(z>>>1|Y<<31)^(z>>>8|Y<<24)^(z>>>7|Y<<25),G=((Y=(G=u[V-2]).high)>>>19|(X=G.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=u[V-7]).high,Q=($=u[V-16]).high,$=$.low;J=(J=(J=J+Z+((Y=z+Y.low)>>>0<z>>>0?1:0))+G+((Y+=X)>>>0<X>>>0?1:0))+Q+((Y+=$)>>>0<$>>>0?1:0),W.high=J,W.low=Y}Z=N&O^~N&M,$=U&H^~U&j,W=C&R^C&I^R&I;var tt=k&T^k&D^T&D,et=(z=(C>>>28|k<<4)^(C<<30|k>>>2)^(C<<25|k>>>7),G=(k>>>28|C<<4)^(k<<30|C>>>2)^(k<<25|C>>>7),(X=a[V]).high),rt=X.low;Q=(Q=(Q=(Q=K+((N>>>14|U<<18)^(N>>>18|U<<14)^(N<<23|U>>>9))+((X=q+((U>>>14|N<<18)^(U>>>18|N<<14)^(U<<23|N>>>9)))>>>0<q>>>0?1:0))+Z+((X+=$)>>>0<$>>>0?1:0))+et+((X+=rt)>>>0<rt>>>0?1:0))+J+((X+=Y)>>>0<Y>>>0?1:0),K=M,q=j,M=O,j=H,O=N,H=U,N=B+Q+((U=L+X|0)>>>0<L>>>0?1:0)|0,B=I,L=D,I=R,D=T,R=C,T=k,C=Q+(W=z+W+((Y=G+tt)>>>0<G>>>0?1:0))+((k=X+Y|0)>>>0<X>>>0?1:0)|0}p=r.low=p+k,r.high=l+C+(p>>>0<k>>>0?1:0),d=i.low=d+T,i.high=g+R+(d>>>0<T>>>0?1:0),y=n.low=y+D,n.high=v+I+(y>>>0<D>>>0?1:0),F=o.low=F+L,o.high=m+B+(F>>>0<L>>>0?1:0),_=s.low=_+U,s.high=S+N+(_>>>0<U>>>0?1:0),b=c.low=b+H,c.high=w+O+(b>>>0<H>>>0?1:0),x=h.low=x+j,h.high=E+M+(x>>>0<j>>>0?1:0),P=f.low=P+q,f.high=A+K+(P>>>0<q>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(o),e.HmacSHA512=r._createHmacHelper(o)}(),function(){var t=s,e=(n=t.x64).Word,r=n.WordArray,i=(n=t.algo).SHA512,n=n.SHA384=i.extend({_doReset:function(){this._hash=new r.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=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(n),t.HmacSHA384=i._createHmacHelper(n)}();var a,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="=";function h(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=u.charAt(r>>6)+u.charAt(63&r);if(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=u.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=u.charAt(r>>2)+u.charAt((3&r)<<4)),c)for(;(3&i.length)>0;)i+=c;return i}function f(t){var e,r,i,n="",o=0;for(e=0;e<t.length&&t.charAt(e)!=c;++e)(i=u.indexOf(t.charAt(e)))<0||(0==o?(n+=F(i>>2),r=3&i,o=1):1==o?(n+=F(r<<2|i>>4),r=15&i,o=2):2==o?(n+=F(r),n+=F(i>>2),r=3&i,o=3):(n+=F(r<<2|i>>4),n+=F(15&i),o=0));return 1==o&&(n+=F(r<<2)),n}function l(t){var e,r=f(t),i=new Array;for(e=0;2*e<r.length;++e)i[e]=parseInt(r.substring(2*e,2*e+2),16);return i}function p(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function g(){return new p(null)}"Microsoft Internet Explorer"==i.appName?(p.prototype.am=function(t,e,r,i,n,o){for(var s=32767&e,a=e>>15;--o>=0;){var u=32767&this[t],c=this[t++]>>15,h=a*u+c*s;n=((u=s*u+((32767&h)<<15)+r[i]+(1073741823&n))>>>30)+(h>>>15)+a*c+(n>>>30),r[i++]=1073741823&u}return n},a=30):"Netscape"!=i.appName?(p.prototype.am=function(t,e,r,i,n,o){for(;--o>=0;){var s=e*this[t++]+r[i]+n;n=Math.floor(s/67108864),r[i++]=67108863&s}return n},a=26):(p.prototype.am=function(t,e,r,i,n,o){for(var s=16383&e,a=e>>14;--o>=0;){var u=16383&this[t],c=this[t++]>>14,h=a*u+c*s;n=((u=s*u+((16383&h)<<14)+r[i]+n)>>28)+(h>>14)+a*c,r[i++]=268435455&u}return n},a=28),p.prototype.DB=a,p.prototype.DM=(1<<a)-1,p.prototype.DV=1<<a,p.prototype.FV=Math.pow(2,52),p.prototype.F1=52-a,p.prototype.F2=2*a-52;var d,v,y="0123456789abcdefghijklmnopqrstuvwxyz",m=new Array;for(d="0".charCodeAt(0),v=0;v<=9;++v)m[d++]=v;for(d="a".charCodeAt(0),v=10;v<36;++v)m[d++]=v;for(d="A".charCodeAt(0),v=10;v<36;++v)m[d++]=v;function F(t){return y.charAt(t)}function S(t,e){var r=m[t.charCodeAt(e)];return null==r?-1:r}function _(t){var e=g();return e.fromInt(t),e}function w(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function b(t){this.m=t}function E(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 x(t,e){return t&e}function A(t,e){return t|e}function P(t,e){return t^e}function C(t,e){return t&~e}function k(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 R(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function T(){}function I(t){return t}function D(t){this.r2=g(),this.q3=g(),p.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}b.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},b.prototype.revert=function(t){return t},b.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},b.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},b.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.convert=function(t){var e=g();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(p.ZERO)>0&&this.m.subTo(e,e),e},E.prototype.revert=function(t){var e=g();return t.copyTo(e),this.reduce(e),e},E.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},E.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},E.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.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},p.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},p.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,n=!1,o=0;--i>=0;){var s=8==r?255&t[i]:S(t,i);s<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),n&&p.ZERO.subTo(this,this)},p.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},p.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},p.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},p.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),a=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+s+1]=this[r]>>n|a,a=(this[r]&o)<<i;for(r=s-1;r>=0;--r)e[r]=0;e[s]=a,e.t=this.t+s+1,e.s=this.s,e.clamp()},p.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;e[0]=this[r]>>i;for(var s=r+1;s<this.t;++s)e[s-r-1]|=(this[s]&o)<<n,e[s-r]=this[s]>>i;i>0&&(e[this.t-r-1]|=(this.s&o)<<n),e.t=this.t-r,e.clamp()}},p.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},p.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&p.ZERO.subTo(e,e)},p.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},p.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=g());var o=g(),s=this.s,a=t.s,u=this.DB-w(i[i.t-1]);u>0?(i.lShiftTo(u,o),n.lShiftTo(u,r)):(i.copyTo(o),n.copyTo(r));var c=o.t,h=o[c-1];if(0!=h){var f=h*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),l=this.FV/f,d=(1<<this.F1)/f,v=1<<this.F2,y=r.t,m=y-c,F=null==e?g():e;for(o.dlShiftTo(m,F),r.compareTo(F)>=0&&(r[r.t++]=1,r.subTo(F,r)),p.ONE.dlShiftTo(c,F),F.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--m>=0;){var S=r[--y]==h?this.DM:Math.floor(r[y]*l+(r[y-1]+v)*d);if((r[y]+=o.am(0,S,r,m,0,c))<S)for(o.dlShiftTo(m,F),r.subTo(F,r);r[y]<--S;)r.subTo(F,r)}null!=e&&(r.drShiftTo(c,e),s!=a&&p.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&p.ZERO.subTo(r,r)}}},p.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},p.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},p.prototype.exp=function(t,e){if(t>4294967295||t<1)return p.ONE;var r=g(),i=g(),n=e.convert(this),o=w(t)-1;for(n.copyTo(r);--o>=0;)if(e.sqrTo(r,i),(t&1<<o)>0)e.mulTo(i,n,r);else{var s=r;r=i,i=s}return e.revert(r)},p.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,n=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(n=!0,o=F(r));s>=0;)a<e?(r=(this[s]&(1<<a)-1)<<e-a,r|=this[--s]>>(a+=this.DB-e)):(r=this[s]>>(a-=e)&i,a<=0&&(a+=this.DB,--s)),r>0&&(n=!0),n&&(o+=F(r));return n?o:"0"},p.prototype.negate=function(){var t=g();return p.ZERO.subTo(this,t),t},p.prototype.abs=function(){return this.s<0?this.negate():this},p.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},p.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+w(this[this.t-1]^this.s&this.DM)},p.prototype.mod=function(t){var e=g();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(p.ZERO)>0&&t.subTo(e,e),e},p.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new b(e):new E(e),this.exp(t,r)},p.ZERO=_(0),p.ONE=_(1),T.prototype.convert=I,T.prototype.revert=I,T.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},T.prototype.sqrTo=function(t,e){t.squareTo(e)},D.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=g();return t.copyTo(e),this.reduce(e),e},D.prototype.revert=function(t){return t},D.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)},D.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},D.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],L=(1<<26)/B[B.length-1];function N(){this.i=0,this.j=0,this.S=new Array}p.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},p.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=_(r),n=g(),o=g(),s="";for(this.divRemTo(i,n,o);n.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,n.divRemTo(i,n,o);return o.intValue().toString(t)+s},p.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),n=!1,o=0,s=0,a=0;a<t.length;++a){var u=S(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(n=!0):(s=e*s+u,++o>=r&&(this.dMultiply(i),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),n&&p.ZERO.subTo(this,this)},p.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(p.ONE.shiftLeft(t-1),A,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(p.ONE.shiftLeft(t-1),this);else{var i=new Array,n=7&t;i.length=1+(t>>3),e.nextBytes(i),n>0?i[0]&=(1<<n)-1:i[0]=0,this.fromString(i,256)}},p.prototype.bitwiseTo=function(t,e,r){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)r[i]=e(n,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},p.prototype.changeBit=function(t,e){var r=p.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},p.prototype.addTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},p.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},p.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]}},p.prototype.multiplyLowerTo=function(t,e,r){var i,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()},p.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},p.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},p.prototype.millerRabin=function(t){var e=this.subtract(p.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>B.length&&(t=B.length);for(var n=g(),o=0;o<t;++o){n.fromInt(B[Math.floor(Math.random()*B.length)]);var s=n.modPow(i,this);if(0!=s.compareTo(p.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<r&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(p.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0},p.prototype.clone=function(){var t=g();return this.copyTo(t),t},p.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]},p.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},p.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},p.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},p.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},p.prototype.equals=function(t){return 0==this.compareTo(t)},p.prototype.min=function(t){return this.compareTo(t)<0?this:t},p.prototype.max=function(t){return this.compareTo(t)>0?this:t},p.prototype.and=function(t){var e=g();return this.bitwiseTo(t,x,e),e},p.prototype.or=function(t){var e=g();return this.bitwiseTo(t,A,e),e},p.prototype.xor=function(t){var e=g();return this.bitwiseTo(t,P,e),e},p.prototype.andNot=function(t){var e=g();return this.bitwiseTo(t,C,e),e},p.prototype.not=function(){for(var t=g(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},p.prototype.shiftLeft=function(t){var e=g();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},p.prototype.shiftRight=function(t){var e=g();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},p.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+k(this[t]);return this.s<0?this.t*this.DB:-1},p.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=R(this[r]^e);return t},p.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)},p.prototype.setBit=function(t){return this.changeBit(t,A)},p.prototype.clearBit=function(t){return this.changeBit(t,C)},p.prototype.flipBit=function(t){return this.changeBit(t,P)},p.prototype.add=function(t){var e=g();return this.addTo(t,e),e},p.prototype.subtract=function(t){var e=g();return this.subTo(t,e),e},p.prototype.multiply=function(t){var e=g();return this.multiplyTo(t,e),e},p.prototype.divide=function(t){var e=g();return this.divRemTo(t,e,null),e},p.prototype.remainder=function(t){var e=g();return this.divRemTo(t,null,e),e},p.prototype.divideAndRemainder=function(t){var e=g(),r=g();return this.divRemTo(t,e,r),new Array(e,r)},p.prototype.modPow=function(t,e){var r,i,n=t.bitLength(),o=_(1);if(n<=0)return o;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new b(e):e.isEven()?new D(e):new E(e);var s=new Array,a=3,u=r-1,c=(1<<r)-1;if(s[1]=i.convert(this),r>1){var h=g();for(i.sqrTo(s[1],h);a<=c;)s[a]=g(),i.mulTo(h,s[a-2],s[a]),a+=2}var f,l,p=t.t-1,d=!0,v=g();for(n=w(t[p])-1;p>=0;){for(n>=u?f=t[p]>>n-u&c:(f=(t[p]&(1<<n+1)-1)<<u-n,p>0&&(f|=t[p-1]>>this.DB+n-u)),a=r;0==(1&f);)f>>=1,--a;if((n-=a)<0&&(n+=this.DB,--p),d)s[f].copyTo(o),d=!1;else{for(;a>1;)i.sqrTo(o,v),i.sqrTo(v,o),a-=2;a>0?i.sqrTo(o,v):(l=o,o=v,v=l),i.mulTo(v,s[f],o)}for(;p>=0&&0==(t[p]&1<<n);)i.sqrTo(o,v),l=o,o=v,v=l,--n<0&&(n=this.DB-1,--p)}return i.revert(o)},p.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return p.ZERO;for(var r=t.clone(),i=this.clone(),n=_(1),o=_(0),s=_(0),a=_(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&n.subTo(s,n),o.subTo(a,o)):(i.subTo(r,i),e&&s.subTo(n,s),a.subTo(o,a))}return 0!=i.compareTo(p.ONE)?p.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},p.prototype.pow=function(t){return this.exp(t,new T)},p.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return e;for(n<o&&(o=n),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},p.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=B[B.length-1]){for(e=0;e<B.length;++e)if(r[0]==B[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<B.length;){for(var i=B[e],n=e+1;n<B.length&&i<L;)i*=B[n++];for(i=r.modInt(i);e<n;)if(i%B[e++]==0)return!1}return r.millerRabin(t)},p.prototype.square=function(){var t=g();return this.squareTo(t),t},N.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},N.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 U,O,H,M=256;function j(){!function(t){O[H++]^=255&t,O[H++]^=t>>8&255,O[H++]^=t>>16&255,O[H++]^=t>>24&255,H>=M&&(H-=M)}((new Date).getTime())}if(null==O){var K;if(O=new Array,H=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var q=n.crypto||n.msCrypto;if(q.getRandomValues){var V=new Uint8Array(32);for(q.getRandomValues(V),K=0;K<32;++K)O[H++]=V[K]}else if("Netscape"==i.appName&&i.appVersion<"5"){var W=n.crypto.random(32);for(K=0;K<W.length;++K)O[H++]=255&W.charCodeAt(K)}}for(;H<M;)K=Math.floor(65536*Math.random()),O[H++]=K>>>8,O[H++]=255&K;H=0,j()}function J(){if(null==U){for(j(),(U=new N).init(O),H=0;H<O.length;++H)O[H]=0;H=0}return U.next()}function Y(){}function z(t,e){return new p(t,e)}function G(t,e,r){for(var i="",n=0;i.length<e;)i+=r(String.fromCharCode.apply(String,t.concat([(4278190080&n)>>24,(16711680&n)>>16,(65280&n)>>8,255&n]))),n+=1;return i}function X(){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 Z(t,e){this.x=e,this.q=t}function Q(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?p.ONE:i,this.zinv=null}function $(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new Q(this,null,null)}Y.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=J()},X.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},X.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=z(t,16),this.e=parseInt(e,16)}},X.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var r=new Array,i=t.length-1;i>=0&&e>0;){var n=t.charCodeAt(i--);n<128?r[--e]=n:n>127&&n<2048?(r[--e]=63&n|128,r[--e]=n>>6|192):(r[--e]=63&n|128,r[--e]=n>>6&63|128,r[--e]=n>>12|224)}r[--e]=0;for(var o=new Y,s=new Array;e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--e]=s[0]}return r[--e]=2,r[--e]=0,new p(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var i=r.toString(16);return 0==(1&i.length)?i:"0"+i},X.prototype.encryptOAEP=function(t,e,r){var i=function(t,e,r,i){var n=tt.crypto.MessageDigest,o=tt.crypto.Util,s=null;if(r||(r="sha1"),"string"==typeof r&&(s=n.getCanonicalAlgName(r),i=n.getHashLength(s),r=function(t){return dt(o.hashHex(vt(t),s))}),t.length+2*i+2>e)throw"Message too long for RSA";var a,u="";for(a=0;a<e-t.length-2*i-2;a+=1)u+="\0";var c=r("")+u+""+t,h=new Array(i);(new Y).nextBytes(h);var f=G(h,c.length,r),l=[];for(a=0;a<c.length;a+=1)l[a]=c.charCodeAt(a)^f.charCodeAt(a);var g=G(l,h.length,r),d=[0];for(a=0;a<h.length;a+=1)d[a+1]=h[a]^g.charCodeAt(a);return new p(d.concat(l))}(t,this.n.bitLength()+7>>3,e,r);if(null==i)return null;var n=this.doPublic(i);if(null==n)return null;var o=n.toString(16);return 0==(1&o.length)?o:"0"+o},X.prototype.type="RSA",Z.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},Z.prototype.toBigInteger=function(){return this.x},Z.prototype.negate=function(){return new Z(this.q,this.x.negate().mod(this.q))},Z.prototype.add=function(t){return new Z(this.q,this.x.add(t.toBigInteger()).mod(this.q))},Z.prototype.subtract=function(t){return new Z(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},Z.prototype.multiply=function(t){return new Z(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},Z.prototype.square=function(){return new Z(this.q,this.x.square().mod(this.q))},Z.prototype.divide=function(t){return new Z(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},Q.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))},Q.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))},Q.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(p.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(p.ZERO))},Q.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(p.ZERO)&&!this.y.toBigInteger().equals(p.ZERO)},Q.prototype.negate=function(){return new Q(this.curve,this.x,this.y.negate(),this.z)},Q.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),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(p.ZERO.equals(r))return p.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new p("3"),n=this.x.toBigInteger(),o=this.y.toBigInteger(),s=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),a=s.multiply(r),u=n.multiply(s),c=e.square().multiply(this.z),h=c.subtract(u.shiftLeft(1)).multiply(t.z).subtract(a).multiply(r).mod(this.curve.q),f=u.multiply(i).multiply(e).subtract(o.multiply(a)).subtract(c.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),l=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new Q(this.curve,this.curve.fromBigInteger(h),this.curve.fromBigInteger(f),l)},Q.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new p("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),n=i.multiply(r).mod(this.curve.q),o=this.curve.a.toBigInteger(),s=e.square().multiply(t);p.ZERO.equals(o)||(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(i).mod(this.curve.q),u=s.multiply(t).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(s.square().multiply(s)).mod(this.curve.q),c=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new Q(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(u),c)},Q.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new p("3")),n=this.negate(),o=this;for(e=i.bitLength()-2;e>0;--e){o=o.twice();var s=i.testBit(e);s!=r.testBit(e)&&(o=o.add(s?this:n))}return o},Q.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var n=this.curve.getInfinity(),o=this.add(e);i>=0;)n=n.twice(),t.testBit(i)?n=r.testBit(i)?n.add(o):n.add(this):r.testBit(i)&&(n=n.add(e)),--i;return n},$.prototype.getQ=function(){return this.q},$.prototype.getA=function(){return this.a},$.prototype.getB=function(){return this.b},$.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},$.prototype.getInfinity=function(){return this.infinity},$.prototype.fromBigInteger=function(t){return new Z(this.q,t)},$.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:default:return null;case 4:case 6:case 7:var e=(t.length-2)/2,r=t.substr(2,e),i=t.substr(e+2,e);return new Q(this,this.fromBigInteger(new p(r,16)),this.fromBigInteger(new p(i,16)))}};var tt,et,rt,it=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"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,r){return e?i[e]:String.fromCharCode(parseInt(r,16))}var o=new String(""),s=Object.hasOwnProperty;return function(i,a){var u,c,h=i.match(t),f=h[0],l=!1;"{"===f?u={}:"["===f?u=[]:(u=[],l=!0);for(var p=[u],g=1-l,d=h.length;g<d;++g){var v;switch((f=h[g]).charCodeAt(0)){default:(v=p[0])[c||v.length]=+f,c=void 0;break;case 34:if(-1!==(f=f.substring(1,f.length-1)).indexOf("\\")&&(f=f.replace(e,n)),v=p[0],!c){if(!(v instanceof Array)){c=f||o;break}c=v.length}v[c]=f,c=void 0;break;case 91:v=p[0],p.unshift(v[c||v.length]=[]),c=void 0;break;case 93:case 125:p.shift();break;case 102:(v=p[0])[c||v.length]=!1,c=void 0;break;case 110:(v=p[0])[c||v.length]=null,c=void 0;break;case 116:(v=p[0])[c||v.length]=!0,c=void 0;break;case 123:v=p[0],p.unshift(v[c||v.length]={}),c=void 0}}if(l){if(1!==p.length)throw new Error;u=u[0]}else if(p.length)throw new Error;return a&&(u=function t(e,i){var n=e[i];if(n&&"object"===(void 0===n?"undefined":r(n))){var o=null;for(var u in n)if(s.call(n,u)&&n!==e){var c=t(n,u);void 0!==c?n[u]=c:(o||(o=[]),o.push(u))}if(o)for(var h=o.length;--h>=0;)delete n[o[h]]}return a.call(e,i,n)}({"":u},"")),u}}(),nt=new function(){};function ot(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}function st(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}function at(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ut(t){return at(ot(t))}function ct(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function ht(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function ft(t){return t.length%2==1&&(t="0"+t),ct(h(t))}function lt(t){return f(ht(t))}function pt(t){return Et(kt(t))}function gt(t){return decodeURIComponent(xt(t))}function dt(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function vt(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function yt(t){return h(t)}function mt(t){var e=yt(t).replace(/(.{64})/g,"$1\r\n");return e.replace(/\r\n$/,"")}function Ft(t){return f(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}function St(t,e){return"-----BEGIN "+e+"-----\r\n"+mt(t)+"\r\n-----END "+e+"-----\r\n"}function _t(t,e){if(-1==t.indexOf("-----BEGIN "))throw"can't find PEM header: "+e;return Ft(t=void 0!==e?(t=t.replace("-----BEGIN "+e+"-----","")).replace("-----END "+e+"-----",""):(t=t.replace(/-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----/,""))}function wt(t){var e,r,i,n,o,s,a,u,c,h,f;if(f=t.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return u=f[1],e=parseInt(u),2===u.length&&(50<=e&&e<100?e=1900+e:0<=e&&e<50&&(e=2e3+e)),r=parseInt(f[2])-1,i=parseInt(f[3]),n=parseInt(f[4]),o=parseInt(f[5]),s=parseInt(f[6]),a=0,""!==(c=f[7])&&(h=(c.substr(1)+"00").substr(0,3),a=parseInt(h)),Date.UTC(e,r,i,n,o,s,a);throw"unsupported zulu format: "+t}function bt(t){return~~(wt(t)/1e3)}function Et(t){return t.replace(/%/g,"")}function xt(t){return t.replace(/(..)/g,"%$1")}function At(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var i=":".repeat(7-r+2),n=(t=t.replace("::",i)).split(":");if(8!=n.length)throw e;for(var o=0;o<8;o++)n[o]=("0000"+n[o]).slice(-4);return n.join("")}function Pt(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var e=(t=t.toLowerCase()).match(/.{1,4}/g),r=0;r<8;r++)e[r]=e[r].replace(/^0+/,""),""==e[r]&&(e[r]="0");var i=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null===i)return t.slice(1,-1);var n="";for(r=0;r<i.length;r++)i[r].length>n.length&&(n=i[r]);return(t=t.replace(n,"::")).slice(1,-1)}function Ct(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?Pt(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 kt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ut(e[i]);return r}function Rt(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}nt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},nt.getL=function(t,e){var r=nt.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},nt.getVblen=function(t,e){var r;return""==(r=nt.getL(t,e))?-1:("8"===r.substr(0,1)?new p(r.substr(2),16):new p(r,16)).intValue()},nt.getVidx=function(t,e){var r=nt.getLblen(t,e);return r<0?r:e+2*(r+1)},nt.getV=function(t,e){var r=nt.getVidx(t,e),i=nt.getVblen(t,e);return t.substr(r,2*i)},nt.getTLV=function(t,e){return t.substr(e,2)+nt.getL(t,e)+nt.getV(t,e)},nt.getNextSiblingIdx=function(t,e){return nt.getVidx(t,e)+2*nt.getVblen(t,e)},nt.getChildIdx=function(t,e){var r=nt,i=new Array,n=r.getVidx(t,e);"03"==t.substr(e,2)?i.push(n+2):i.push(n);for(var o=r.getVblen(t,e),s=n,a=0;;){var u=r.getNextSiblingIdx(t,s);if(null==u||u-n>=2*o)break;if(a>=200)break;i.push(u),s=u,a++}return i},nt.getNthChildIdx=function(t,e,r){return nt.getChildIdx(t,e)[r]},nt.getIdxbyList=function(t,e,r,i){var n,o,s=nt;if(0==r.length){if(void 0!==i&&t.substr(e,2)!==i)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+i;return e}return n=r.shift(),o=s.getChildIdx(t,e),s.getIdxbyList(t,o[n],r,i)},nt.getTLVbyList=function(t,e,r,i){var n=nt,o=n.getIdxbyList(t,e,r);if(void 0===o)throw"can't find nthList object";if(void 0!==i&&t.substr(o,2)!=i)throw"checking tag doesn't match: "+t.substr(o,2)+"!="+i;return n.getTLV(t,o)},nt.getVbyList=function(t,e,r,i,n){var o,s,a=nt;if(void 0===(o=a.getIdxbyList(t,e,r,i)))throw"can't find nthList object";return s=a.getV(t,o),!0===n&&(s=s.substr(2)),s},nt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),n=parseInt(i,16);r[0]=new String(Math.floor(n/40)),r[1]=new String(n%40);for(var o=t.substr(2),s=[],a=0;a<o.length/2;a++)s.push(parseInt(o.substr(2*a,2),16));var u=[],c="";for(a=0;a<s.length;a++)128&s[a]?c+=e((127&s[a]).toString(2),7):(c+=e((127&s[a]).toString(2),7),u.push(new String(parseInt(c,2))),c="");var h=r.join(".");return u.length>0&&(h=h+"."+u.join(".")),h},nt.dump=function(t,e,r,i){var n=nt,o=n.getV,s=n.dump,a=n.getChildIdx,u=t;t instanceof tt.asn1.ASN1Object&&(u=t.getEncodedHex());var c=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===i&&(i="");var h=e.ommit_long_octet;if("01"==u.substr(r,2))return"00"==(f=o(u,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==u.substr(r,2))return i+"INTEGER "+c(f=o(u,r),h)+"\n";if("03"==u.substr(r,2))return i+"BITSTRING "+c(f=o(u,r),h)+"\n";if("04"==u.substr(r,2)){var f=o(u,r);return n.isASN1HEX(f)?(w=i+"OCTETSTRING, encapsulates\n")+s(f,e,0,i+" "):i+"OCTETSTRING "+c(f,h)+"\n"}if("05"==u.substr(r,2))return i+"NULL\n";if("06"==u.substr(r,2)){var l=o(u,r),p=tt.asn1.ASN1Util.oidHexToInt(l),g=tt.asn1.x509.OID.oid2name(p),d=p.replace(/\./g," ");return""!=g?i+"ObjectIdentifier "+g+" ("+d+")\n":i+"ObjectIdentifier ("+d+")\n"}if("0c"==u.substr(r,2))return i+"UTF8String '"+gt(o(u,r))+"'\n";if("13"==u.substr(r,2))return i+"PrintableString '"+gt(o(u,r))+"'\n";if("14"==u.substr(r,2))return i+"TeletexString '"+gt(o(u,r))+"'\n";if("16"==u.substr(r,2))return i+"IA5String '"+gt(o(u,r))+"'\n";if("17"==u.substr(r,2))return i+"UTCTime "+gt(o(u,r))+"\n";if("18"==u.substr(r,2))return i+"GeneralizedTime "+gt(o(u,r))+"\n";if("30"==u.substr(r,2)){if("3000"==u.substr(r,4))return i+"SEQUENCE {}\n";w=i+"SEQUENCE\n";var v=e;if((2==(F=a(u,r)).length||3==F.length)&&"06"==u.substr(F[0],2)&&"04"==u.substr(F[F.length-1],2)){g=n.oidname(o(u,F[0]));var y=JSON.parse(JSON.stringify(e));y.x509ExtName=g,v=y}for(var m=0;m<F.length;m++)w+=s(u,v,F[m],i+" ");return w}if("31"==u.substr(r,2)){w=i+"SET\n";var F=a(u,r);for(m=0;m<F.length;m++)w+=s(u,e,F[m],i+" ");return w}var S=parseInt(u.substr(r,2),16);if(0!=(128&S)){var _=31&S;if(0!=(32&S)){var w=i+"["+_+"]\n";for(F=a(u,r),m=0;m<F.length;m++)w+=s(u,e,F[m],i+" ");return w}return"68747470"==(f=o(u,r)).substr(0,8)&&(f=gt(f)),"subjectAltName"===e.x509ExtName&&2==_&&(f=gt(f)),i+"["+_+"] "+f+"\n"}return i+"UNKNOWN("+u.substr(r,2)+") "+o(u,r)+"\n"},nt.isASN1HEX=function(t){var e=nt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),n=e.getL(t,0);return t.length-i.length-n.length==2*r},nt.oidname=function(t){var e=tt.asn1;tt.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==tt&&tt||(tt={}),void 0!==tt.lang&&tt.lang||(tt.lang={}),tt.lang.String=function(){},"function"==typeof t?(et=function(e){return ct(new t(e,"utf8").toString("base64"))},rt=function(e){return new t(ht(e),"base64").toString("utf8")}):(et=function(t){return ft(Et(kt(t)))},rt=function(t){return decodeURIComponent(xt(lt(t)))}),tt.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},tt.lang.String.isHex=function(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))},tt.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},tt.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=ht(t),tt.lang.String.isBase64(t))},tt.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},void 0!==tt&&tt||(tt={}),void 0!==tt.crypto&&tt.crypto||(tt.crypto={}),tt.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",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:s.algo.MD5,sha1:s.algo.SHA1,sha224:s.algo.SHA224,sha256:s.algo.SHA256,sha384:s.algo.SHA384,sha512:s.algo.SHA512,ripemd160:s.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var i=this.getDigestInfoHex(t,e),n=r/4;if(i.length+22>n)throw"key is too short for SigAlg: keylen="+r+","+e;for(var o="0001",s="00"+i,a="",u=n-4-s.length,c=0;c<u;c+=2)a+="ff";return o+a+s},this.hashString=function(t,e){return new tt.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new tt.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return new tt.crypto.MessageDigest({alg:"sha1",prov:"cryptojs"}).digestString(t)},this.sha256=function(t){return new tt.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"}).digestString(t)},this.sha256Hex=function(t){return new tt.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"}).digestHex(t)},this.sha512=function(t){return new tt.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"}).digestString(t)},this.sha512Hex=function(t){return new tt.crypto.MessageDigest({alg:"sha512",prov:"cryptojs"}).digestHex(t)}},tt.crypto.Util.md5=function(t){return new tt.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},tt.crypto.Util.ripemd160=function(t){return new tt.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},tt.crypto.Util.SECURERANDOMGEN=new Y,tt.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return tt.crypto.Util.SECURERANDOMGEN.nextBytes(e),at(e)},tt.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new p(tt.crypto.Util.getRandomHexOfNbytes(t),16)},tt.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return tt.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],at(r)},tt.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new p(tt.crypto.Util.getRandomHexOfNbits(t),16)},tt.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=tt.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},tt.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";if(0==r)return t;var i=e.subtract(t);return tt.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},tt.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=tt.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=tt.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=tt.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=s.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(s.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=tt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},tt.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},tt.crypto.MessageDigest.getHashLength=function(t){var e=tt.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},tt.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},tt.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=tt.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var i=tt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=s.algo.HMAC.create(i,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=s.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(s.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=vt(t)),void(this.pass=s.enc.Hex.parse(e))}if("object"!=(void 0===t?"undefined":r(t)))throw"KJUR.crypto.Mac unsupported password type: "+t;if(e=null,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=pt(t.utf8)),void 0!==t.rstr&&(e=vt(t.rstr)),void 0!==t.b64&&(e=f(t.b64)),void 0!==t.b64u&&(e=lt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=s.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=tt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},tt.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())},this._zeroPaddingOfSignature=function(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw"provider not supported: "+e;if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new tt.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw"setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t}this.init=function(t,e){var r=null;try{r=void 0===e?Tt.getKey(t):Tt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0!==this.ecprvhex&&void 0!==this.eccurvename){var t=new tt.crypto.ECDSA({curve:this.eccurvename});this.hSign=t.signHex(this.sHashHex,this.ecprvhex)}else if(this.prvKey instanceof X&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof X&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof tt.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof tt.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.ecpubhex&&void 0!==this.eccurvename)return new tt.crypto.ECDSA({curve:this.eccurvename}).verifyHex(this.sHashHex,t,this.ecpubhex);if(this.pubKey instanceof X&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof X&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==tt.crypto.ECDSA&&this.pubKey instanceof tt.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==tt.crypto.DSA&&this.pubKey instanceof tt.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=tt.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=Tt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},tt.crypto.Cipher=function(t){},tt.crypto.Cipher.encrypt=function(t,e,r){if(e instanceof X&&e.isPublic){var i=tt.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===i)return e.encrypt(t);if("RSAOAEP"===i)return e.encryptOAEP(t,"sha1");var n=i.match(/^RSAOAEP(\d+)$/);if(null!==n)return e.encryptOAEP(t,"sha"+n[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},tt.crypto.Cipher.decrypt=function(t,e,r){if(e instanceof X&&e.isPrivate){var i=tt.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===i)return e.decrypt(t);if("RSAOAEP"===i)return e.decryptOAEP(t,"sha1");var n=i.match(/^RSAOAEP(\d+)$/);if(null!==n)return e.decryptOAEP(t,"sha"+n[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},tt.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof X){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},tt.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!==tt&&tt||(tt={}),void 0!==tt.crypto&&tt.crypto||(tt.crypto={}),tt.crypto.ECDSA=function(t){var e=new Y;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new p(t.bitLength(),e).mod(t.subtract(p.ONE)).add(p.ONE)},this.setNamedCurve=function(t){this.ecparams=tt.crypto.ECParameterDB.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 r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},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),r=this.ecparams.G.multiply(e),i=r.getX().toBigInteger(),n=r.getY().toBigInteger(),o=this.ecparams.keylen/4,s=("0000000000"+e.toString(16)).slice(-o),a="04"+("0000000000"+i.toString(16)).slice(-o)+("0000000000"+n.toString(16)).slice(-o);return this.setPrivateKeyHex(s),this.setPublicKeyHex(a),{ecprvhex:s,ecpubhex:a}},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var r=new p(e,16),i=this.ecparams.n,n=new p(t,16);do{var o=this.getBigRandom(i),s=this.ecparams.G.multiply(o).getX().toBigInteger().mod(i)}while(s.compareTo(p.ZERO)<=0);var a=o.modInverse(i).multiply(n.add(r.multiply(s))).mod(i);return tt.crypto.ECDSA.biRSSigToASN1Sig(s,a)},this.sign=function(t,e){var r=e,i=this.ecparams.n,n=p.fromByteArrayUnsigned(t);do{var o=this.getBigRandom(i),s=this.ecparams.G.multiply(o).getX().toBigInteger().mod(i)}while(s.compareTo(p.ZERO)<=0);var a=o.modInverse(i).multiply(n.add(r.multiply(s))).mod(i);return this.serializeSig(s,a)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,r){var i,n,o,s=tt.crypto.ECDSA.parseSigHex(e);i=s.r,n=s.s,o=Q.decodeFromHex(this.ecparams.curve,r);var a=new p(t,16);return this.verifyRaw(a,i,n,o)},this.verify=function(t,e,i){var n,o,s;if(Bitcoin.Util.isArray(e)){var a=this.parseSig(e);n=a.r,o=a.s}else{if("object"!==(void 0===e?"undefined":r(e))||!e.r||!e.s)throw"Invalid value for signature";n=e.r,o=e.s}if(i instanceof Q)s=i;else{if(!Bitcoin.Util.isArray(i))throw"Invalid format for pubkey value, must be byte array or ECPointFp";s=Q.decodeFrom(this.ecparams.curve,i)}var u=p.fromByteArrayUnsigned(t);return this.verifyRaw(u,n,o,s)},this.verifyRaw=function(t,e,r,i){var n=this.ecparams.n,o=this.ecparams.G;if(e.compareTo(p.ONE)<0||e.compareTo(n)>=0)return!1;if(r.compareTo(p.ONE)<0||r.compareTo(n)>=0)return!1;var s=r.modInverse(n),a=t.multiply(s).mod(n),u=e.multiply(s).mod(n);return o.multiply(a).add(i.multiply(u)).getX().toBigInteger().mod(n).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),n=[];return n.push(2),n.push(r.length),(n=n.concat(r)).push(2),n.push(i.length),(n=n.concat(i)).unshift(n.length),n.unshift(48),n},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:p.fromByteArrayUnsigned(r),s:p.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:p.fromByteArrayUnsigned(t.slice(1,33)).mod(r),s:p.fromByteArrayUnsigned(t.slice(33,65)).mod(r),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,r,i,n=nt,o=tt.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{e=s(t,0,[2,0],"06"),r=s(t,0,[1],"04");try{i=s(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=o(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,r,i,n=nt,o=tt.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[1,0],"06"),e=s(t,0,[1,1],"06"),r=s(t,0,[2,0,1],"04");try{i=s(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=o(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,r,i=nt,n=tt.crypto.ECDSA.getName,o=i.getVbyList;if(!1===i.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[0,0],"06"),e=o(t,0,[0,1],"06"),r=o(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=n(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(r)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var r,i,n=nt,o=tt.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{r=s(t,0,[0,e,0,1],"06"),i=s(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=o(r),null===this.curveName)throw"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))},tt.crypto.ECDSA.parseSigHex=function(t){var e=tt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new p(e.r,16),s:new p(e.s,16)}},tt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=nt,r=e.getChildIdx,i=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var n=r(t,0);if(2!=n.length)throw"number of signature ASN.1 sequence elements seem wrong";var o=n[0],s=n[1];if("02"!=t.substr(o,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(s,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:i(t,o),s:i(t,s)}},tt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=tt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw"unknown ECDSA sig r length error";if(i.length%32!=0)throw"unknown ECDSA sig s length error";return r+i},tt.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),r=t.substr(t.length/2);return tt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},tt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new p(t,16),i=new p(e,16);return tt.crypto.ECDSA.biRSSigToASN1Sig(r,i)},tt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=tt.asn1,i=new r.DERInteger({bigint:t}),n=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,n]}).getEncodedHex()},tt.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==tt&&tt||(tt={}),void 0!==tt.crypto&&tt.crypto||(tt.crypto={}),tt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new p(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,n,o,s,a,u,c,h,f,l,p,g){t[i]={};var d=r(o),v=r(s),y=r(a),m=r(u),F=r(c),S=new $(d,v,y),_=S.decodePointHex("04"+h+f);t[i].name=i,t[i].keylen=n,t[i].curve=S,t[i].G=_,t[i].n=m,t[i].h=F,t[i].oid=p,t[i].info=g;for(var w=0;w<l.length;w++)e[l[w]]=i}},tt.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),tt.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),tt.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),tt.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),tt.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),tt.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),tt.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),tt.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),tt.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),tt.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]);var Tt=function(){var t=function(t,r,i){return e(s.AES,t,r,i)},e=function(t,e,r,i){var n=s.enc.Hex.parse(e),o=s.enc.Hex.parse(r),a=s.enc.Hex.parse(i),u={};u.key=o,u.iv=a,u.ciphertext=n;var c=t.decrypt(u,o,{iv:a});return s.enc.Hex.stringify(c)},r=function(t,e,r){return i(s.AES,t,e,r)},i=function(t,e,r,i){var n=s.enc.Hex.parse(e),o=s.enc.Hex.parse(r),a=s.enc.Hex.parse(i),u=t.encrypt(n,o,{iv:a}),c=s.enc.Hex.parse(u.toString());return s.enc.Base64.stringify(c)},n={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(s.TripleDES,t,r,i)},eproc:function(t,e,r){return i(s.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(s.DES,t,r,i)},eproc:function(t,e,r){return i(s.DES,t,e,r)},keylen:8,ivlen:8}},o=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var n=-1,o=0;-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),o=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),o=1);var s=t.indexOf("-----END");if(-1!=n&&-1!=s){var a=t.substring(n+2*o,s-o);a=a.replace(/\s+/g,""),e.data=a}return e},a=function(t,e,r){for(var i=r.substring(0,16),o=s.enc.Hex.parse(i),a=s.enc.Utf8.parse(e),u=n[t].keylen+n[t].ivlen,c="",h=null;;){var f=s.algo.MD5.create();if(null!=h&&f.update(h),f.update(a),f.update(o),h=f.finalize(),(c+=s.enc.Hex.stringify(h)).length>=2*u)break}var l={};return l.keyhex=c.substr(0,2*n[t].keylen),l.ivhex=c.substr(2*n[t].keylen,2*n[t].ivlen),l},u=function(t,e,r,i){var o=s.enc.Base64.parse(t),a=s.enc.Hex.stringify(o);return(0,n[e].proc)(a,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return o(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,i){return u(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=o(t),i=(r.type,r.cipher),n=r.ivsalt,s=r.data,c=a(i,e,n).keyhex;return u(s,i,c,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,o){var u="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===n[i])throw"KEYUTIL unsupported algorithm: "+i;void 0!==o&&null!=o||(o=function(t){var e=s.lib.WordArray.random(t);return s.enc.Hex.stringify(e)}(n[i].ivlen).toUpperCase());var c=function(t,e,r,i){return(0,n[e].eproc)(t,r,i)}(e,i,a(i,r,o).keyhex,o);return u="-----BEGIN "+t+" PRIVATE KEY-----\r\n",u+="Proc-Type: 4,ENCRYPTED\r\n",u+="DEK-Info: "+i+","+o+"\r\n",u+="\r\n",(u+=c.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=nt,r=e.getChildIdx,i=e.getV,n={},o=r(t,0);if(2!=o.length)throw"malformed format: SEQUENCE(0).items != 2: "+o.length;n.ciphertext=i(t,o[1]);var s=r(t,o[0]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+s.length;if("2a864886f70d01050d"!=i(t,s[0]))throw"this only supports pkcs5PBES2";var a=r(t,s[1]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=r(t,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=i(t,u[0]))throw"this only supports TripleDES";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=i(t,u[1]);var c=r(t,a[0]);if(2!=c.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length;if("2a864886f70d01050c"!=i(t,c[0]))throw"this only supports pkcs5PBKDF2";var h=r(t,c[1]);if(h.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+h.length;n.pbkdf2Salt=i(t,h[0]);var f=i(t,h[1]);try{n.pbkdf2Iter=parseInt(f,16)}catch(t){throw"malformed format pbkdf2Iter: "+f}return n},getPBKDF2KeyHexFromParam:function(t,e){var r=s.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,n=s.PBKDF2(e,r,{keySize:6,iterations:i});return s.enc.Hex.stringify(n)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=_t(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),n=Tt.getPBKDF2KeyHexFromParam(i,e),o={};o.ciphertext=s.enc.Hex.parse(i.ciphertext);var a=s.enc.Hex.parse(n),u=s.enc.Hex.parse(i.encryptionSchemeIV),c=s.TripleDES.decrypt(o,a,{iv:u});return s.enc.Hex.stringify(c)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=nt,r=e.getChildIdx,i=e.getV,n={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var o=r(t,0);if(3!=o.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(o[1],2))throw"malformed PKCS8 private key(code:003)";var s=r(t,o[1]);if(2!=s.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(s[0],2))throw"malformed PKCS8 private key(code:005)";if(n.algoid=i(t,s[0]),"06"==t.substr(s[1],2)&&(n.algparam=i(t,s[1])),"04"!=t.substr(o[2],2))throw"malformed PKCS8 private key(code:006)";return n.keyidx=e.getVidx(t,o[2]),n},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=_t(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new X;else if("2a8648ce380401"==r.algoid)e=new tt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw"unsupported private key algorithm";e=new tt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=nt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new X;else if("2a8648ce380401"===r)e=new tt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";e=new tt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=nt,r=e.getChildIdx,i=e.getV,n={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var o=r(t,0);if(2!=o.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(o[0],2))throw"malformed RSA key(code:003)";if(n.n=i(t,o[0]),"02"!=t.substr(o[1],2))throw"malformed RSA key(code:004)";return n.e=i(t,o[1]),n},parsePublicPKCS8Hex:function(t){var e=nt,r=e.getChildIdx,i=e.getV,n={algparam:null},o=r(t,0);if(2!=o.length)throw"outer DERSequence shall have 2 elements: "+o.length;var s=o[0];if("30"!=t.substr(s,2))throw"malformed PKCS8 public key(code:001)";var a=r(t,s);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(n.algoid=i(t,a[0]),"06"==t.substr(a[1],2)?n.algparam=i(t,a[1]):"30"==t.substr(a[1],2)&&(n.algparam={},n.algparam.p=e.getVbyList(t,a[1],[0],"02"),n.algparam.q=e.getVbyList(t,a[1],[1],"02"),n.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(o[1],2))throw"malformed PKCS8 public key(code:004)";return n.key=i(t,o[1]).substr(2),n}}}();Tt.getKey=function(t,e,r){var i,n=(m=nt).getChildIdx,o=(m.getV,m.getVbyList),s=tt.crypto,a=s.ECDSA,u=s.DSA,c=X,h=_t,f=Tt;if(void 0!==c&&t instanceof c)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==u&&t instanceof u)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(k=new c).setPublic(t.n,t.e),k;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(k=new c).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),k;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(k=new c).setPrivate(t.n,t.e,t.d),k;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(k=new u).setPublic(t.p,t.q,t.g,t.y),k;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(k=new u).setPrivate(t.p,t.q,t.g,t.y,t.x),k;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(k=new c).setPublic(lt(t.n),lt(t.e)),k;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(k=new c).setPrivateEx(lt(t.n),lt(t.e),lt(t.d),lt(t.p),lt(t.q),lt(t.dp),lt(t.dq),lt(t.qi)),k;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(k=new c).setPrivate(lt(t.n),lt(t.e),lt(t.d)),k;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new a({curve:t.crv})).ecparams.keylen/4,g="04"+("0000000000"+lt(t.x)).slice(-l)+("0000000000"+lt(t.y)).slice(-l);return C.setPublicKeyHex(g),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new a({curve:t.crv})).ecparams.keylen/4,g="04"+("0000000000"+lt(t.x)).slice(-l)+("0000000000"+lt(t.y)).slice(-l);var d=("0000000000"+lt(t.d)).slice(-l);return C.setPublicKeyHex(g),C.setPrivateKeyHex(d),C}if("pkcs5prv"===r){var v,y=t,m=nt;if(9===(v=n(y,0)).length)(k=new c).readPKCS5PrvKeyHex(y);else if(6===v.length)(k=new u).readPKCS5PrvKeyHex(y);else{if(!(v.length>2&&"04"===y.substr(v[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(k=new a).readPKCS5PrvKeyHex(y)}return k}if("pkcs8prv"===r)return f.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return f._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return Nt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Nt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var F=_t(t,"PUBLIC KEY");return f._getKeyFromPublicPKCS8Hex(F)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=h(t,"RSA PRIVATE KEY");return f.getKey(S,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var _=o(i=h(t,"DSA PRIVATE KEY"),0,[1],"02"),w=o(i,0,[2],"02"),b=o(i,0,[3],"02"),E=o(i,0,[4],"02"),x=o(i,0,[5],"02");return(k=new u).setPrivate(new p(_,16),new p(w,16),new p(b,16),new p(E,16),new p(x,16)),k}if(-1!=t.indexOf("-END PRIVATE KEY-"))return f.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=f.getDecryptedKeyHex(t,e),P=new X;return P.readPKCS5PrvKeyHex(A),P}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,k=o(i=f.getDecryptedKeyHex(t,e),0,[1],"04"),R=o(i,0,[2,0],"06"),T=o(i,0,[3,0],"03").substr(2);if(void 0===tt.crypto.OID.oidhex2name[R])throw"undefined OID(hex) in KJUR.crypto.OID: "+R;return(C=new a({curve:tt.crypto.OID.oidhex2name[R]})).setPublicKeyHex(T),C.setPrivateKeyHex(k),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return _=o(i=f.getDecryptedKeyHex(t,e),0,[1],"02"),w=o(i,0,[2],"02"),b=o(i,0,[3],"02"),E=o(i,0,[4],"02"),x=o(i,0,[5],"02"),(k=new u).setPrivate(new p(_,16),new p(w,16),new p(b,16),new p(E,16),new p(x,16)),k;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return f.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Tt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(s=new X).generate(r,"10001"),s.isPrivate=!0,s.isPublic=!0;var i=new X,n=s.n.toString(16),o=s.e.toString(16);return i.setPublic(n,o),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=i,a}if("EC"==t){var s,a,u=e,c=new tt.crypto.ECDSA({curve:u}).generateKeyPairHex();return(s=new tt.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),s.setPrivateKeyHex(c.ecprvhex),s.isPrivate=!0,s.isPublic=!1,(i=new tt.crypto.ECDSA({curve:u})).setPublicKeyHex(c.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=i,a}throw"unknown algorithm: "+t},Tt.getPEM=function(t,e,r,i,n,o){var a=tt,u=a.asn1,c=u.DERObjectIdentifier,h=u.DERInteger,f=u.ASN1Util.newObject,l=u.x509.SubjectPublicKeyInfo,p=a.crypto,g=p.DSA,d=p.ECDSA,v=X;function y(t){return f({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 f({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function F(t){return f({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!==v&&t instanceof v||void 0!==g&&t instanceof g||void 0!==d&&t instanceof d)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return St(b=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==v&&t instanceof v&&(void 0===r||null==r)&&1==t.isPrivate)return St(b=y(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate){var S=new c({name:t.curveName}).getEncodedHex(),_=m(t).getEncodedHex(),w="";return(w+=St(S,"EC PARAMETERS"))+St(_,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate)return St(b=F(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==v&&t instanceof v&&void 0!==r&&null!=r&&1==t.isPrivate){var b=y(t).getEncodedHex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",b,r,i,o)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return b=m(t).getEncodedHex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",b,r,i,o);if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate)return b=F(t).getEncodedHex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",b,r,i,o);var E=function(t,e){var r=x(t,e);return new f({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},x=function(t,e){var r=s.lib.WordArray.random(8),i=s.lib.WordArray.random(8),n=s.PBKDF2(e,r,{keySize:6,iterations:100}),o=s.enc.Hex.parse(t),a=s.TripleDES.encrypt(o,n,{iv:i})+"",u={};return u.ciphertext=a,u.pbkdf2Salt=s.enc.Hex.stringify(r),u.pbkdf2Iter=100,u.encryptionSchemeAlg="DES-EDE3-CBC",u.encryptionSchemeIV=s.enc.Hex.stringify(i),u};if("PKCS8PRV"==e&&null!=v&&t instanceof v&&1==t.isPrivate){var A=y(t).getEncodedHex();return b=f({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:A}}]}).getEncodedHex(),void 0===r||null==r?St(b,"PRIVATE KEY"):St(_=E(b,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate)return A=new f({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),b=f({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:A}}]}).getEncodedHex(),void 0===r||null==r?St(b,"PRIVATE KEY"):St(_=E(b,r),"ENCRYPTED PRIVATE KEY");if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate)return A=new h({bigint:t.x}).getEncodedHex(),b=f({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:A}}]}).getEncodedHex(),void 0===r||null==r?St(b,"PRIVATE KEY"):St(_=E(b,r),"ENCRYPTED PRIVATE KEY");throw"unsupported object nor format"},Tt.getKeyFromCSRPEM=function(t){var e=_t(t,"CERTIFICATE REQUEST");return Tt.getKeyFromCSRHex(e)},Tt.getKeyFromCSRHex=function(t){var e=Tt.parseCSRHex(t);return Tt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Tt.parseCSRHex=function(t){var e=nt,r=e.getChildIdx,i=e.getTLV,n={},o=t;if("30"!=o.substr(0,2))throw"malformed CSR(code:001)";var s=r(o,0);if(s.length<1)throw"malformed CSR(code:002)";if("30"!=o.substr(s[0],2))throw"malformed CSR(code:003)";var a=r(o,s[0]);if(a.length<3)throw"malformed CSR(code:004)";return n.p8pubkeyhex=i(o,a[2]),n},Tt.getJWKFromKey=function(t){var e={};if(t instanceof X&&t.isPrivate)return e.kty="RSA",e.n=ft(t.n.toString(16)),e.e=ft(t.e.toString(16)),e.d=ft(t.d.toString(16)),e.p=ft(t.p.toString(16)),e.q=ft(t.q.toString(16)),e.dp=ft(t.dmp1.toString(16)),e.dq=ft(t.dmq1.toString(16)),e.qi=ft(t.coeff.toString(16)),e;if(t instanceof X&&t.isPublic)return e.kty="RSA",e.n=ft(t.n.toString(16)),e.e=ft(t.e.toString(16)),e;if(t instanceof tt.crypto.ECDSA&&t.isPrivate){if("P-256"!==(i=t.getShortNISTPCurveName())&&"P-384"!==i)throw"unsupported curve name for JWT: "+i;var r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=i,e.x=ft(r.x),e.y=ft(r.y),e.d=ft(t.prvKeyHex),e}if(t instanceof tt.crypto.ECDSA&&t.isPublic){var i;if("P-256"!==(i=t.getShortNISTPCurveName())&&"P-384"!==i)throw"unsupported curve name for JWT: "+i;return r=t.getPublicKeyXYHex(),e.kty="EC",e.crv=i,e.x=ft(r.x),e.y=ft(r.y),e}throw"not supported key object"},X.getPosArrayOfChildrenFromHex=function(t){return nt.getChildIdx(t,0)},X.getHexValueArrayOfChildrenFromHex=function(t){var e,r=nt.getV,i=r(t,(e=X.getPosArrayOfChildrenFromHex(t))[0]),n=r(t,e[1]),o=r(t,e[2]),s=r(t,e[3]),a=r(t,e[4]),u=r(t,e[5]),c=r(t,e[6]),h=r(t,e[7]),f=r(t,e[8]);return(e=new Array).push(i,n,o,s,a,u,c,h,f),e},X.prototype.readPrivateKeyFromPEMString=function(t){var e=_t(t),r=X.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},X.prototype.readPKCS5PrvKeyHex=function(t){var e=X.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},X.prototype.readPKCS8PrvKeyHex=function(t){var e,r,i,n,o,s,a,u,c=nt,h=c.getVbyList;if(!1===c.isASN1HEX(t))throw"not ASN.1 hex string";try{e=h(t,0,[2,0,1],"02"),r=h(t,0,[2,0,2],"02"),i=h(t,0,[2,0,3],"02"),n=h(t,0,[2,0,4],"02"),o=h(t,0,[2,0,5],"02"),s=h(t,0,[2,0,6],"02"),a=h(t,0,[2,0,7],"02"),u=h(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,r,i,n,o,s,a,u)},X.prototype.readPKCS5PubKeyHex=function(t){var e=nt,r=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw"wrong hex for PKCS#5 public key";var n=r(t,i[0]),o=r(t,i[1]);this.setPublic(n,o)},X.prototype.readPKCS8PubKeyHex=function(t){var e=nt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var r=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},X.prototype.readCertPubKeyHex=function(t,e){var r,i;(r=new Nt).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)};var It=new RegExp("");function Dt(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t}function Bt(t,e,r){for(var i="",n=0;i.length<e;)i+=dt(r(vt(t+String.fromCharCode.apply(String,[(4278190080&n)>>24,(16711680&n)>>16,(65280&n)>>8,255&n])))),n+=1;return i}function Lt(t){for(var e in tt.crypto.Util.DIGESTINFOHEAD){var r=tt.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function Nt(){var t=nt,e=t.getChildIdx,r=t.getV,i=t.getTLV,n=t.getVbyList,o=t.getTLVbyList,s=t.getIdxbyList,a=t.getVidx,u=t.oidname,c=Nt,h=_t;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"!==o(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return n(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return u(n(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return o(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return c.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return o(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return c.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=n(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getNotAfter=function(){var t=n(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return s(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return s(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Tt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return u(n(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return n(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),r=this.getSignatureValueHex(),i=o(this.hex,0,[0],"30"),n=new tt.crypto.Signature({alg:e});return n.init(t),n.updateHex(i),n.verify(r)},this.parseExt=function(){if(3!==this.version)return-1;var r=s(this.hex,0,[0,7,0],"30"),i=e(this.hex,r);this.aExtInfo=new Array;for(var o=0;o<i.length;o++){var u={critical:!1},c=0;3===e(this.hex,i[o]).length&&(u.critical=!0,c=1),u.oid=t.hextooidstr(n(this.hex,i[o],[0],"06"));var h=s(this.hex,i[o],[1+c]);u.vidx=a(this.hex,h),this.aExtInfo.push(u)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=tt.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getExtBasicConstraints=function(){var t=this.getExtInfo("basicConstraints");if(void 0===t)return t;var e=r(this.hex,t.vidx);if(""===e)return{};if("0101ff"===e)return{cA:!0};if("0101ff02"===e.substr(0,8)){var i=r(e,6);return{cA:!0,pathLen:parseInt(i,16)}}throw"basicConstraints parse error"},this.getExtKeyUsageBin=function(){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";var e=r(this.hex,t.vidx);if(e.length%2!=0||e.length<=2)throw"malformed key usage value";var i=parseInt(e.substr(0,2)),n=parseInt(e.substr(2),16).toString(2);return n.substr(0,n.length-i)},this.getExtKeyUsageString=function(){for(var t=this.getExtKeyUsageBin(),e=new Array,r=0;r<t.length;r++)"1"==t.substr(r,1)&&e.push(Nt.KEYUSAGE_NAME[r]);return e.join(",")},this.getExtSubjectKeyIdentifier=function(){var t=this.getExtInfo("subjectKeyIdentifier");return void 0===t?t:r(this.hex,t.vidx)},this.getExtAuthorityKeyIdentifier=function(){var t=this.getExtInfo("authorityKeyIdentifier");if(void 0===t)return t;for(var n={},o=i(this.hex,t.vidx),s=e(o,0),a=0;a<s.length;a++)"80"===o.substr(s[a],2)&&(n.kid=r(o,s[a]));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var n=new Array,o=i(this.hex,t.vidx);if(""===o)return n;for(var s=e(o,0),a=0;a<s.length;a++)n.push(u(r(o,s[a])));return n},this.getExtSubjectAltName=function(){for(var t=this.getExtSubjectAltName2(),e=new Array,r=0;r<t.length;r++)"DNS"===t[r][0]&&e.push(t[r][1]);return e},this.getExtSubjectAltName2=function(){var t,n,o,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,u=i(this.hex,s.vidx),c=e(u,0),h=0;h<c.length;h++)o=u.substr(c[h],2),t=r(u,c[h]),"81"===o&&(n=gt(t),a.push(["MAIL",n])),"82"===o&&(n=gt(t),a.push(["DNS",n])),"84"===o&&(n=Nt.hex2dn(t,0),a.push(["DN",n])),"86"===o&&(n=gt(t),a.push(["URI",n])),"87"===o&&(n=Ct(t),a.push(["IP",n]));return a},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var r=new Array,i=e(this.hex,t.vidx),o=0;o<i.length;o++)try{var s=gt(n(this.hex,i[o],[0,0,0],"86"));r.push(s)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var r={ocsp:[],caissuer:[]},i=e(this.hex,t.vidx),o=0;o<i.length;o++){var s=n(this.hex,i[o],[0],"06"),a=n(this.hex,i[o],[1],"86");"2b06010505073001"===s&&r.ocsp.push(gt(a)),"2b06010505073002"===s&&r.caissuer.push(gt(a))}return r},this.getExtCertificatePolicies=function(){var t=this.getExtInfo("certificatePolicies");if(void 0===t)return t;for(var o=i(this.hex,t.vidx),s=[],a=e(o,0),c=0;c<a.length;c++){var h={},f=e(o,a[c]);if(h.id=u(r(o,f[0])),2===f.length)for(var l=e(o,f[1]),p=0;p<l.length;p++){var g=n(o,l[p],[0],"06");"2b06010505070201"===g?h.cps=gt(n(o,l[p],[1])):"2b06010505070202"===g&&(h.unotice=gt(n(o,l[p],[1,0])))}s.push(h)}return s},this.readCertPEM=function(t){this.readCertHex(h(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{s(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getInfo=function(){var t,e,r;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="+Rt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+Rt(e.e.toString(16))+"\n"),void 0!==(r=this.aExtInfo)&&null!==r){t+="X509v3 Extensions:\n";for(var i=0;i<r.length;i++){var n=r[i],o=tt.asn1.x509.OID.oid2name(n.oid);""===o&&(o=n.oid);var s="";if(!0===n.critical&&(s="CRITICAL"),t+=" "+o+" "+s+":\n","basicConstraints"===o){var a=this.getExtBasicConstraints();void 0===a.cA?t+=" {}\n":(t+=" cA=true",void 0!==a.pathLen&&(t+=", pathLen="+a.pathLen),t+="\n")}else if("keyUsage"===o)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===o)t+=" "+this.getExtSubjectKeyIdentifier()+"\n";else if("authorityKeyIdentifier"===o){var u=this.getExtAuthorityKeyIdentifier();void 0!==u.kid&&(t+=" kid="+u.kid+"\n")}else if("extKeyUsage"===o)t+=" "+this.getExtExtKeyUsageName().join(", ")+"\n";else if("subjectAltName"===o)t+=" "+this.getExtSubjectAltName2()+"\n";else if("cRLDistributionPoints"===o)t+=" "+this.getExtCRLDistributionPointsURI()+"\n";else if("authorityInfoAccess"===o){var c=this.getExtAIAInfo();void 0!==c.ocsp&&(t+=" ocsp: "+c.ocsp.join(",")+"\n"),void 0!==c.caissuer&&(t+=" caissuer: "+c.caissuer.join(",")+"\n")}else if("certificatePolicies"===o)for(var h=this.getExtCertificatePolicies(),f=0;f<h.length;f++)void 0!==h[f].id&&(t+=" policy oid: "+h[f].id+"\n"),void 0!==h[f].cps&&(t+=" cps: "+h[f].cps+"\n")}}return(t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"}}It.compile("[^0-9a-f]","gi"),X.prototype.sign=function(t,e){var r=function(t){return tt.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},X.prototype.signWithMessageHash=function(t,e){var r=z(tt.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Dt(this.doPrivate(r).toString(16),this.n.bitLength())},X.prototype.signPSS=function(t,e,r){var i=function(t){return tt.crypto.Util.hashHex(t,e)}(vt(t));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},X.prototype.signWithMessageHashPSS=function(t,e,r){var i,n=dt(t),o=n.length,s=this.n.bitLength()-1,a=Math.ceil(s/8),u=function(t){return tt.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=o;else if(-2===r)r=a-o-2;else if(r<-2)throw"invalid salt length";if(a<o+r+2)throw"data too long";var c="";r>0&&(c=new Array(r),(new Y).nextBytes(c),c=String.fromCharCode.apply(String,c));var h=dt(u(vt("\0\0\0\0\0\0\0\0"+n+c))),f=[];for(i=0;i<a-r-o-2;i+=1)f[i]=0;var l=String.fromCharCode.apply(String,f)+""+c,g=Bt(h,l.length,u),d=[];for(i=0;i<l.length;i+=1)d[i]=l.charCodeAt(i)^g.charCodeAt(i);var v=65280>>8*a-s&255;for(d[0]&=~v,i=0;i<o;i++)d.push(h.charCodeAt(i));return d.push(188),Dt(this.doPrivate(new p(d)).toString(16),this.n.bitLength())},X.prototype.verify=function(t,e){var r=z(e=(e=e.replace(It,"")).replace(/[ \n]+/g,""),16);if(r.bitLength()>this.n.bitLength())return 0;var i=Lt(this.doPublic(r).toString(16).replace(/^1f+00/,""));if(0==i.length)return!1;var n=i[0];return i[1]==function(t){return tt.crypto.Util.hashString(t,n)}(t)},X.prototype.verifyWithMessageHash=function(t,e){var r=z(e=(e=e.replace(It,"")).replace(/[ \n]+/g,""),16);if(r.bitLength()>this.n.bitLength())return 0;var i=Lt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&(i[0],i[1]==t)},X.prototype.verifyPSS=function(t,e,r,i){var n=function(t){return tt.crypto.Util.hashHex(t,r)}(vt(t));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(n,e,r,i)},X.prototype.verifyWithMessageHashPSS=function(t,e,r,i){var n=new p(e,16);if(n.bitLength()>this.n.bitLength())return!1;var o,s=function(t){return tt.crypto.Util.hashHex(t,r)},a=dt(t),u=a.length,c=this.n.bitLength()-1,h=Math.ceil(c/8);if(-1===i||void 0===i)i=u;else if(-2===i)i=h-u-2;else if(i<-2)throw"invalid salt length";if(h<u+i+2)throw"data too long";var f=this.doPublic(n).toByteArray();for(o=0;o<f.length;o+=1)f[o]&=255;for(;f.length<h;)f.unshift(0);if(188!==f[h-1])throw"encoded message does not end in 0xbc";var l=(f=String.fromCharCode.apply(String,f)).substr(0,h-u-1),g=f.substr(l.length,u),d=65280>>8*h-c&255;if(0!=(l.charCodeAt(0)&d))throw"bits beyond keysize not zero";var v=Bt(g,l.length,s),y=[];for(o=0;o<l.length;o+=1)y[o]=l.charCodeAt(o)^v.charCodeAt(o);y[0]&=~d;var m=h-u-i-2;for(o=0;o<m;o+=1)if(0!==y[o])throw"leftmost octets not zero";if(1!==y[m])throw"0x01 marker not found";return g===dt(s(vt("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-i)))))},X.SALT_LEN_HLEN=-1,X.SALT_LEN_MAX=-2,X.SALT_LEN_RECOVER=-2,Nt.hex2dn=function(t,e){if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw"malformed DN";for(var r=new Array,i=nt.getChildIdx(t,e),n=0;n<i.length;n++)r.push(Nt.hex2rdn(t,i[n]));return"/"+(r=r.map((function(t){return t.replace("/","\\/")}))).join("/")},Nt.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw"malformed RDN";for(var r=new Array,i=nt.getChildIdx(t,e),n=0;n<i.length;n++)r.push(Nt.hex2attrTypeValue(t,i[n]));return(r=r.map((function(t){return t.replace("+","\\+")}))).join("+")},Nt.hex2attrTypeValue=function(t,e){var r=nt,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw"malformed attribute type and value";var n=r.getChildIdx(t,e);2!==n.length||t.substr(n[0],2);var o=i(t,n[0]),s=tt.asn1.ASN1Util.oidHexToInt(o);return tt.asn1.x509.OID.oid2atype(s)+"="+dt(i(t,n[1]))},Nt.getPublicKeyFromCertHex=function(t){var e=new Nt;return e.readCertHex(t),e.getPublicKey()},Nt.getPublicKeyFromCertPEM=function(t){var e=new Nt;return e.readCertPEM(t),e.getPublicKey()},Nt.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=nt.getVbyList,n={algparam:null};return(e=new Nt).readCertPEM(t),r=e.getPublicKeyHex(),n.keyhex=i(r,0,[1],"03").substr(2),n.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===n.algoid&&(n.algparam=i(r,0,[0,1],"06")),n},Nt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==tt&&tt||(tt={}),void 0!==tt.jws&&tt.jws||(tt.jws={}),tt.jws.JWS=function(){var t=tt.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var n=i[1],o=i[2],s=i[3],a=n+"."+o;if(this.parsedJWS={},this.parsedJWS.headB64U=n,this.parsedJWS.payloadB64U=o,this.parsedJWS.sigvalB64U=s,this.parsedJWS.si=a,!r){var u=lt(s),c=z(u,16);this.parsedJWS.sigvalH=u,this.parsedJWS.sigvalBI=c}var h=rt(n),f=rt(o);if(this.parsedJWS.headS=h,this.parsedJWS.payloadS=f,!t(h,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+h}}},tt.jws.JWS.sign=function(t,e,i,n,o){var s,a,u,c=tt,h=c.jws.JWS,f=h.readSafeJSONString,l=h.isSafeJSONString,p=c.crypto,g=(p.ECDSA,p.Mac),d=p.Signature,v=JSON;if("string"!=typeof e&&"object"!=(void 0===e?"undefined":r(e)))throw"spHeader must be JSON string or object: "+e;if("object"==(void 0===e?"undefined":r(e))&&(a=e,s=v.stringify(a)),"string"==typeof e){if(!l(s=e))throw"JWS Head is not safe JSON string: "+s;a=f(s)}if(u=i,"object"==(void 0===i?"undefined":r(i))&&(u=v.stringify(i)),""!=t&&null!=t||void 0===a.alg||(t=a.alg),""!=t&&null!=t&&void 0===a.alg&&(a.alg=t,s=v.stringify(a)),t!==a.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+a.alg;var y=null;if(void 0===h.jwsalg2sigalg[t])throw"unsupported alg name: "+t;y=h.jwsalg2sigalg[t];var m=et(s)+"."+et(u),F="";if("Hmac"==y.substr(0,4)){if(void 0===n)throw"mac key shall be specified for HS* alg";var S=new g({alg:y,prov:"cryptojs",pass:n});S.updateString(m),F=S.doFinal()}else{var _;-1!=y.indexOf("withECDSA")?((_=new d({alg:y})).init(n,o),_.updateString(m),hASN1Sig=_.sign(),F=tt.crypto.ECDSA.asn1SigToConcatSig(hASN1Sig)):"none"!=y&&((_=new d({alg:y})).init(n,o),_.updateString(m),F=_.sign())}return m+"."+ft(F)},tt.jws.JWS.verify=function(t,e,i){var n,o=tt,s=o.jws.JWS,a=s.readSafeJSONString,u=o.crypto,c=u.ECDSA,h=u.Mac,f=u.Signature;void 0!==r(X)&&(n=X);var l=t.split(".");if(3!==l.length)return!1;var p,g=l[0]+"."+l[1],d=lt(l[2]),v=a(rt(l[0])),y=null;if(void 0===v.alg)throw"algorithm not specified in header";if(p=(y=v.alg).substr(0,2),null!=i&&"[object Array]"===Object.prototype.toString.call(i)&&i.length>0&&-1==(":"+i.join(":")+":").indexOf(":"+y+":"))throw"algorithm '"+y+"' not accepted in the list";if("none"!=y&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Tt.getKey(e)),!("RS"!=p&&"PS"!=p||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==p&&!(e instanceof c))throw"key shall be a ECDSA obj for ES* algs";var m=null;if(void 0===s.jwsalg2sigalg[v.alg])throw"unsupported alg name: "+y;if("none"==(m=s.jwsalg2sigalg[y]))throw"not supported";if("Hmac"==m.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var F=new h({alg:m,pass:e});return F.updateString(g),d==F.doFinal()}if(-1!=m.indexOf("withECDSA")){var S,_=null;try{_=c.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new f({alg:m})).init(e),S.updateString(g),S.verify(_)}return(S=new f({alg:m})).init(e),S.updateString(g),S.verify(d)},tt.jws.JWS.parse=function(t){var e,r,i,n=t.split("."),o={};if(2!=n.length&&3!=n.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=n[0],r=n[1],3==n.length&&(i=n[2]),o.headerObj=tt.jws.JWS.readSafeJSONString(rt(e)),o.payloadObj=tt.jws.JWS.readSafeJSONString(rt(r)),o.headerPP=JSON.stringify(o.headerObj,null," "),null==o.payloadObj?o.payloadPP=rt(r):o.payloadPP=JSON.stringify(o.payloadObj,null," "),void 0!==i&&(o.sigHex=lt(i)),o},tt.jws.JWS.verifyJWT=function(t,e,i){var n=tt.jws,o=n.JWS,s=o.readSafeJSONString,a=o.inArray,u=o.includedArray,c=t.split("."),h=c[0],f=c[1],l=(lt(c[2]),s(rt(h))),p=s(rt(f));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,i.alg))return!1;if(void 0!==p.iss&&"object"===r(i.iss)&&!a(p.iss,i.iss))return!1;if(void 0!==p.sub&&"object"===r(i.sub)&&!a(p.sub,i.sub))return!1;if(void 0!==p.aud&&"object"===r(i.aud))if("string"==typeof p.aud){if(!a(p.aud,i.aud))return!1}else if("object"==r(p.aud)&&!u(p.aud,i.aud))return!1;var g=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(g=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==p.exp&&"number"==typeof p.exp&&p.exp+i.gracePeriod<g||void 0!==p.nbf&&"number"==typeof p.nbf&&g<p.nbf-i.gracePeriod||void 0!==p.iat&&"number"==typeof p.iat&&g<p.iat-i.gracePeriod||void 0!==p.jti&&void 0!==i.jti&&p.jti!==i.jti||!o.verify(t,e,i.alg))},tt.jws.JWS.includedArray=function(t,e){var i=tt.jws.JWS.inArray;if(null===t)return!1;if("object"!==(void 0===t?"undefined":r(t)))return!1;if("number"!=typeof t.length)return!1;for(var n=0;n<t.length;n++)if(!i(t[n],e))return!1;return!0},tt.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!==(void 0===e?"undefined":r(e)))return!1;if("number"!=typeof e.length)return!1;for(var i=0;i<e.length;i++)if(e[i]==t)return!0;return!1},tt.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"},tt.jws.JWS.isSafeJSONString=function(t,e,i){var n=null;try{return"object"!=(void 0===(n=it(t))?"undefined":r(n))||n.constructor===Array?0:(e&&(e[i]=n),1)}catch(t){return 0}},tt.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=(void 0===(e=it(t))?"undefined":r(e))||e.constructor===Array?null:e}catch(t){return null}},tt.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]},tt.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 r=vt(e);return ft(tt.crypto.Util.hashHex(r,"sha256"))},tt.jws.IntDate={},tt.jws.IntDate.get=function(t){var e=tt.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},tt.jws.IntDate.getZulu=function(t){return bt(t)},tt.jws.IntDate.getNow=function(){return~~(new Date/1e3)},tt.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},tt.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"},e.SecureRandom=Y,e.rng_seed_time=j,e.BigInteger=p,e.RSAKey=X,e.ECDSA=tt.crypto.ECDSA,e.DSA=tt.crypto.DSA,e.Signature=tt.crypto.Signature,e.MessageDigest=tt.crypto.MessageDigest,e.Mac=tt.crypto.Mac,e.Cipher=tt.crypto.Cipher,e.KEYUTIL=Tt,e.ASN1HEX=nt,e.X509=Nt,e.CryptoJS=s,e.b64tohex=f,e.b64toBA=l,e.stoBA=ot,e.BAtos=st,e.BAtohex=at,e.stohex=ut,e.stob64=function(t){return h(ut(t))},e.stob64u=function(t){return ct(h(ut(t)))},e.b64utos=function(t){return st(l(ht(t)))},e.b64tob64u=ct,e.b64utob64=ht,e.hex2b64=h,e.hextob64u=ft,e.b64utohex=lt,e.utf8tob64u=et,e.b64utoutf8=rt,e.utf8tob64=function(t){return h(Et(kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(xt(f(t)))},e.utf8tohex=pt,e.hextoutf8=gt,e.hextorstr=dt,e.rstrtohex=vt,e.hextob64=yt,e.hextob64nl=mt,e.b64nltohex=Ft,e.hextopem=St,e.pemtohex=_t,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),r=new DataView(e),i=0;i<t.length/2;i++)r.setUint8(i,parseInt(t.substr(2*i,2),16));return e},e.ArrayBuffertohex=function(t){for(var e="",r=new DataView(t),i=0;i<t.byteLength;i++)e+=("00"+r.getUint8(i).toString(16)).slice(-2);return e},e.zulutomsec=wt,e.zulutosec=bt,e.zulutodate=function(t){return new Date(wt(t))},e.datetozulu=function(t,e,r){var i,n=t.getUTCFullYear();if(e){if(n<1950||2049<n)throw"not proper year for UTCTime: "+n;i=(""+n).slice(-2)}else i=("000"+n).slice(-4);if(i+=("0"+(t.getUTCMonth()+1)).slice(-2),i+=("0"+t.getUTCDate()).slice(-2),i+=("0"+t.getUTCHours()).slice(-2),i+=("0"+t.getUTCMinutes()).slice(-2),i+=("0"+t.getUTCSeconds()).slice(-2),r){var o=t.getUTCMilliseconds();0!==o&&(i+="."+(o=(o=("00"+o).slice(-3)).replace(/0+$/g,"")))}return i+"Z"},e.uricmptohex=Et,e.hextouricmp=xt,e.ipv6tohex=At,e.hextoipv6=Pt,e.hextoip=Ct,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 At(t);throw e}var r=t.split(".");if(4!==r.length)throw e;var i="";try{for(var n=0;n<4;n++)i+=("0"+parseInt(r[n]).toString(16)).slice(-2);return i}catch(t){throw e}},e.encodeURIComponentAll=kt,e.newline_toUnix=function(t){return t.replace(/\r\n/gm,"\n")},e.newline_toDos=function(t){return(t=t.replace(/\r\n/gm,"\n")).replace(/\n/gm,"\r\n")},e.hextoposhex=Rt,e.intarystrtohex=function(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,r){var i=parseInt(t);if(i<0||255<i)throw"integer not in range 0-255";return("00"+i.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}},e.strdiffidx=function(t,e){var r=t.length;t.length>e.length&&(r=e.length);for(var i=0;i<r;i++)if(t.charCodeAt(i)!=e.charCodeAt(i))return i;return t.length!=e.length?r:-1},e.KJUR=tt,e.crypto=tt.crypto,e.asn1=tt.asn1,e.jws=tt.jws,e.lang=tt.lang}).call(this,r(40).Buffer)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.JoseUtil=void 0;var i=r(41),n=r(0),o=["RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"];e.JoseUtil=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return t.parseJwt=function(t){n.Log.debug("JoseUtil.parseJwt");try{var e=i.jws.JWS.parse(t);return{header:e.headerObj,payload:e.payloadObj}}catch(t){n.Log.error(t)}},t.validateJwt=function(e,r,o,s,a,u){n.Log.debug("JoseUtil.validateJwt");try{if("RSA"===r.kty)if(r.e&&r.n)r=i.KEYUTIL.getKey(r);else{if(!r.x5c||!r.x5c.length)return n.Log.error("JoseUtil.validateJwt: RSA key missing key material",r),Promise.reject(new Error("RSA key missing key material"));var c=(0,i.b64tohex)(r.x5c[0]);r=i.X509.getPublicKeyFromCertHex(c)}else{if("EC"!==r.kty)return n.Log.error("JoseUtil.validateJwt: Unsupported key type",r&&r.kty),Promise.reject(new Error("Unsupported key type: "+r&&r.kty));if(!(r.crv&&r.x&&r.y))return n.Log.error("JoseUtil.validateJwt: EC key missing key material",r),Promise.reject(new Error("EC key missing key material"));r=i.KEYUTIL.getKey(r)}return t._validateJwt(e,r,o,s,a,u)}catch(e){return n.Log.error(e&&e.message||e),Promise.reject("JWT validation failed")}},t._validateJwt=function(e,r,s,a,u,c){u||(u=0),c||(c=parseInt(Date.now()/1e3));var h=t.parseJwt(e).payload;if(!h.iss)return n.Log.error("JoseUtil._validateJwt: issuer was not provided"),Promise.reject(new Error("issuer was not provided"));if(h.iss!==s)return n.Log.error("JoseUtil._validateJwt: Invalid issuer in token",h.iss),Promise.reject(new Error("Invalid issuer in token: "+h.iss));if(!h.aud)return n.Log.error("JoseUtil._validateJwt: aud was not provided"),Promise.reject(new Error("aud was not provided"));if(!(h.aud===a||Array.isArray(h.aud)&&h.aud.indexOf(a)>=0))return n.Log.error("JoseUtil._validateJwt: Invalid audience in token",h.aud),Promise.reject(new Error("Invalid audience in token: "+h.aud));var f=c+u,l=c-u;if(!h.iat)return n.Log.error("JoseUtil._validateJwt: iat was not provided"),Promise.reject(new Error("iat was not provided"));if(f<h.iat)return n.Log.error("JoseUtil._validateJwt: iat is in the future",h.iat),Promise.reject(new Error("iat is in the future: "+h.iat));if(h.nbf&&f<h.nbf)return n.Log.error("JoseUtil._validateJwt: nbf is in the future",h.nbf),Promise.reject(new Error("nbf is in the future: "+h.nbf));if(!h.exp)return n.Log.error("JoseUtil._validateJwt: exp was not provided"),Promise.reject(new Error("exp was not provided"));if(h.exp<l)return n.Log.error("JoseUtil._validateJwt: exp is in the past",h.exp),Promise.reject(new Error("exp is in the past:"+h.exp));try{if(!i.jws.JWS.verify(e,r,o))return n.Log.error("JoseUtil._validateJwt: signature validation failed"),Promise.reject(new Error("signature validation failed"))}catch(e){return n.Log.error(e&&e.message||e),Promise.reject(new Error("signature validation failed"))}return Promise.resolve()},t.hashString=function(t,e){try{return i.crypto.Util.hashString(t,e)}catch(t){n.Log.error(t)}},t.hexToBase64Url=function(t){try{return(0,i.hextob64u)(t)}catch(t){n.Log.error(t)}},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.UserInfoService=void 0;var i=r(17),n=r(3),o=r(0);e.UserInfoService=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.JsonService,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.MetadataService;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e)throw o.Log.error("UserInfoService.ctor: No settings passed"),new Error("settings");this._settings=e,this._jsonService=new r,this._metadataService=new s(this._settings)}return t.prototype.getClaims=function(t){var e=this;return t?this._metadataService.getUserInfoEndpoint().then((function(r){return o.Log.debug("UserInfoService.getClaims: received userinfo url",r),e._jsonService.getJson(r,t).then((function(t){return o.Log.debug("UserInfoService.getClaims: claims received",t),t}))})):(o.Log.error("UserInfoService.getClaims: No token passed"),Promise.reject(new Error("A token is required")))},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ResponseValidator=void 0;var i=r(0),n=r(3),o=r(43),s=r(16),a=r(42),u=["nonce","at_hash","iat","nbf","exp","aud","iss","c_hash"];e.ResponseValidator=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.MetadataService,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.UserInfoService,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:a.JoseUtil;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e)throw i.Log.error("ResponseValidator.ctor: No settings passed to ResponseValidator"),new Error("settings");this._settings=e,this._metadataService=new r(this._settings),this._userInfoService=new s(this._settings),this._joseUtil=u}return t.prototype.validateSigninResponse=function(t,e){var r=this;return i.Log.debug("ResponseValidator.validateSigninResponse"),this._processSigninParams(t,e).then((function(e){return i.Log.debug("ResponseValidator.validateSigninResponse: state processed"),r._validateTokens(t,e).then((function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: tokens validated"),r._processClaims(t).then((function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: claims processed"),t}))}))}))},t.prototype.validateSignoutResponse=function(t,e){return t.id!==e.state?(i.Log.error("ResponseValidator.validateSignoutResponse: State does not match"),Promise.reject(new Error("State does not match"))):(i.Log.debug("ResponseValidator.validateSignoutResponse: state validated"),e.state=t.data,e.error?(i.Log.warn("ResponseValidator.validateSignoutResponse: Response was error",e.error),Promise.reject(new s.ErrorResponse(e))):Promise.resolve(e))},t.prototype._processSigninParams=function(t,e){if(t.id!==e.state)return i.Log.error("ResponseValidator._processSigninParams: State does not match"),Promise.reject(new Error("State does not match"));if(!t.client_id)return i.Log.error("ResponseValidator._processSigninParams: No client_id on state"),Promise.reject(new Error("No client_id on state"));if(!t.authority)return i.Log.error("ResponseValidator._processSigninParams: No authority on state"),Promise.reject(new Error("No authority on state"));if(this._settings.authority){if(this._settings.authority&&this._settings.authority!==t.authority)return i.Log.error("ResponseValidator._processSigninParams: authority mismatch on settings vs. signin state"),Promise.reject(new Error("authority mismatch on settings vs. signin state"))}else this._settings.authority=t.authority;if(this._settings.client_id){if(this._settings.client_id&&this._settings.client_id!==t.client_id)return i.Log.error("ResponseValidator._processSigninParams: client_id mismatch on settings vs. signin state"),Promise.reject(new Error("client_id mismatch on settings vs. signin state"))}else this._settings.client_id=t.client_id;return i.Log.debug("ResponseValidator._processSigninParams: state validated"),e.state=t.data,e.error?(i.Log.warn("ResponseValidator._processSigninParams: Response was error",e.error),Promise.reject(new s.ErrorResponse(e))):t.nonce&&!e.id_token?(i.Log.error("ResponseValidator._processSigninParams: Expecting id_token in response"),Promise.reject(new Error("No id_token in response"))):!t.nonce&&e.id_token?(i.Log.error("ResponseValidator._processSigninParams: Not expecting id_token in response"),Promise.reject(new Error("Unexpected id_token in response"))):Promise.resolve(e)},t.prototype._processClaims=function(t){var e=this;if(t.isOpenIdConnect){if(i.Log.debug("ResponseValidator._processClaims: response is OIDC, processing claims"),t.profile=this._filterProtocolClaims(t.profile),this._settings.loadUserInfo&&t.access_token)return i.Log.debug("ResponseValidator._processClaims: loading user info"),this._userInfoService.getClaims(t.access_token).then((function(r){return i.Log.debug("ResponseValidator._processClaims: user info claims received from user info endpoint"),r.sub!==t.profile.sub?(i.Log.error("ResponseValidator._processClaims: sub from user info endpoint does not match sub in access_token"),Promise.reject(new Error("sub from user info endpoint does not match sub in access_token"))):(t.profile=e._mergeClaims(t.profile,r),i.Log.debug("ResponseValidator._processClaims: user info claims received, updated profile:",t.profile),t)}));i.Log.debug("ResponseValidator._processClaims: not loading user info")}else i.Log.debug("ResponseValidator._processClaims: response is not OIDC, not processing claims");return Promise.resolve(t)},t.prototype._mergeClaims=function(t,e){var r=Object.assign({},t);for(var i in e){var n=e[i];Array.isArray(n)||(n=[n]);for(var o=0;o<n.length;o++){var s=n[o];r[i]?Array.isArray(r[i])?r[i].indexOf(s)<0&&r[i].push(s):r[i]!==s&&(r[i]=[r[i],s]):r[i]=s}}return r},t.prototype._filterProtocolClaims=function(t){i.Log.debug("ResponseValidator._filterProtocolClaims, incoming claims:",t);var e=Object.assign({},t);return this._settings._filterProtocolClaims?(u.forEach((function(t){delete e[t]})),i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims filtered",e)):i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims not filtered"),e},t.prototype._validateTokens=function(t,e){return e.id_token?e.access_token?(i.Log.debug("ResponseValidator._validateTokens: Validating id_token and access_token"),this._validateIdTokenAndAccessToken(t,e)):(i.Log.debug("ResponseValidator._validateTokens: Validating id_token"),this._validateIdToken(t,e)):(i.Log.debug("ResponseValidator._validateTokens: No id_token to validate"),Promise.resolve(e))},t.prototype._validateIdTokenAndAccessToken=function(t,e){var r=this;return this._validateIdToken(t,e).then((function(t){return r._validateAccessToken(t)}))},t.prototype._validateIdToken=function(t,e){var r=this;if(!t.nonce)return i.Log.error("ResponseValidator._validateIdToken: No nonce on state"),Promise.reject(new Error("No nonce on state"));var n=this._joseUtil.parseJwt(e.id_token);if(!n||!n.header||!n.payload)return i.Log.error("ResponseValidator._validateIdToken: Failed to parse id_token",n),Promise.reject(new Error("Failed to parse id_token"));if(t.nonce!==n.payload.nonce)return i.Log.error("ResponseValidator._validateIdToken: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"));var o=n.header.kid;return this._metadataService.getIssuer().then((function(s){return i.Log.debug("ResponseValidator._validateIdToken: Received issuer"),r._metadataService.getSigningKeys().then((function(a){if(!a)return i.Log.error("ResponseValidator._validateIdToken: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));i.Log.debug("ResponseValidator._validateIdToken: Received signing keys");var u=void 0;if(o)u=a.filter((function(t){return t.kid===o}))[0];else{if((a=r._filterByAlg(a,n.header.alg)).length>1)return i.Log.error("ResponseValidator._validateIdToken: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));u=a[0]}if(!u)return i.Log.error("ResponseValidator._validateIdToken: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var c=t.client_id,h=r._settings.clockSkew;return i.Log.debug("ResponseValidator._validateIdToken: Validaing JWT; using clock skew (in seconds) of: ",h),r._joseUtil.validateJwt(e.id_token,u,s,c,h).then((function(){return i.Log.debug("ResponseValidator._validateIdToken: JWT validation successful"),n.payload.sub?(e.profile=n.payload,e):(i.Log.error("ResponseValidator._validateIdToken: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))}))}))}))},t.prototype._filterByAlg=function(t,e){var r=null;if(e.startsWith("RS"))r="RSA";else if(e.startsWith("PS"))r="PS";else{if(!e.startsWith("ES"))return i.Log.debug("ResponseValidator._filterByAlg: alg not supported: ",e),[];r="EC"}return i.Log.debug("ResponseValidator._filterByAlg: Looking for keys that match kty: ",r),t=t.filter((function(t){return t.kty===r})),i.Log.debug("ResponseValidator._filterByAlg: Number of keys that match kty: ",r,t.length),t},t.prototype._validateAccessToken=function(t){if(!t.profile)return i.Log.error("ResponseValidator._validateAccessToken: No profile loaded from id_token"),Promise.reject(new Error("No profile loaded from id_token"));if(!t.profile.at_hash)return i.Log.error("ResponseValidator._validateAccessToken: No at_hash in id_token"),Promise.reject(new Error("No at_hash in id_token"));if(!t.id_token)return i.Log.error("ResponseValidator._validateAccessToken: No id_token"),Promise.reject(new Error("No id_token"));var e=this._joseUtil.parseJwt(t.id_token);if(!e||!e.header)return i.Log.error("ResponseValidator._validateAccessToken: Failed to parse id_token",e),Promise.reject(new Error("Failed to parse id_token"));var r=e.header.alg;if(!r||5!==r.length)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r),Promise.reject(new Error("Unsupported alg: "+r));var n=r.substr(2,3);if(!n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));if(256!==(n=parseInt(n))&&384!==n&&512!==n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));var o="sha"+n,s=this._joseUtil.hashString(t.access_token,o);if(!s)return i.Log.error("ResponseValidator._validateAccessToken: access_token hash failed:",o),Promise.reject(new Error("Failed to validate at_hash"));var a=s.substr(0,s.length/2),u=this._joseUtil.hexToBase64Url(a);return u!==t.profile.at_hash?(i.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash",u,t.profile.at_hash),Promise.reject(new Error("Failed to validate at_hash"))):(i.Log.debug("ResponseValidator._validateAccessToken: success"),Promise.resolve(t))},t}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),n=r(18),o=r(6),s=r(5),a=r(31),u=r(30),c=r(12),h=r(3),f=r(20),l=r(19),p=r(9),g=r(8),d=r(10),v=r(1),y=r(13);e.default={Log:i.Log,OidcClient:n.OidcClient,OidcClientSettings:o.OidcClientSettings,WebStorageStateStore:s.WebStorageStateStore,InMemoryWebStorage:a.InMemoryWebStorage,UserManager:u.UserManager,AccessTokenEvents:c.AccessTokenEvents,MetadataService:h.MetadataService,CordovaPopupNavigator:f.CordovaPopupNavigator,CordovaIFrameNavigator:l.CordovaIFrameNavigator,CheckSessionIFrame:p.CheckSessionIFrame,TokenRevocationClient:g.TokenRevocationClient,SessionMonitor:d.SessionMonitor,Global:v.Global,User:y.User},t.exports=e.default}])}));