// AWS SDK for JavaScript v2.1.10 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // License at https://sdk.amazonaws.com/js/BUNDLE_LICENSE.txt !function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;athis.expireTime?!0:this.expired||!this.accessKeyId||!this.secretAccessKey},get:function(e){var t=this;this.needsRefresh()?this.refresh(function(r){r||(t.expired=!1),e&&e(r)}):e&&e()},refresh:function(e){this.expired=!1,e()}})},{"./core":3}],5:[function(e){var t=e("../core");t.CognitoIdentityCredentials=t.util.inherit(t.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e){t.Credentials.call(this),this.expired=!0,this.webIdentityCredentials=new t.WebIdentityCredentials(e),this.cognito=new t.CognitoIdentity({params:e}),this.sts=new t.STS,this.params=e,this.data=null,this.identityId=null,this.loadCachedId()},refresh:function(e){var t=this;t.data=null,t.identityId=null,t.getId(function(r){r?(t.clearCachedId(),e(r)):t.params.RoleArn?t.getCredentialsFromSTS(e):t.getCredentialsForIdentity(e)})},clearCachedId:function(){var e=this.params.IdentityPoolId;delete this.storage[this.localStorageKey.id+e],delete this.storage[this.localStorageKey.providers+e]},getId:function(e){var t=this;return"string"==typeof t.params.IdentityId?e(null,t.params.IdentityId):void t.cognito.getId(function(r,n){!r&&n.IdentityId?(t.params.IdentityId=n.IdentityId,e(null,n.IdentityId)):e(r)})},loadCredentials:function(e,t){e&&t&&(t.expired=!1,t.accessKeyId=e.Credentials.AccessKeyId,t.secretAccessKey=e.Credentials.SecretKey,t.sessionToken=e.Credentials.SessionToken,t.expireTime=e.Credentials.Expiration)},getCredentialsForIdentity:function(e){var t=this;t.cognito.getCredentialsForIdentity(function(r,n){r?t.clearCachedId():(t.cacheId(n),t.data=n,t.loadCredentials(t.data,t)),e(r)})},getCredentialsFromSTS:function(e){var t=this;t.cognito.getOpenIdToken(function(r,n){r?(t.clearCachedId(),e(r)):(t.cacheId(n),t.params.WebIdentityToken=n.Token,t.webIdentityCredentials.refresh(function(r){r?t.clearCachedId():(t.data=t.webIdentityCredentials.data,t.sts.credentialsFrom(t.data,t)),e(r)}))})},loadCachedId:function(){var e=this;if(t.util.isBrowser()&&!e.params.IdentityId){var r=e.getStorage("id");if(r&&e.params.Logins){var n=Object.keys(e.params.Logins),i=(e.getStorage("providers")||"").split(","),o=i.filter(function(e){return-1!==n.indexOf(e)});0!==o.length&&(e.params.IdentityId=r)}else r&&(e.params.IdentityId=r)}},cacheId:function(e){this.identityId=e.IdentityId,this.params.IdentityId=this.identityId,t.util.isBrowser()&&(this.setStorage("id",e.IdentityId),this.params.Logins&&this.setStorage("providers",Object.keys(this.params.Logins).join(",")))},getStorage:function(e){return this.storage[this.localStorageKey[e]+this.params.IdentityPoolId]},setStorage:function(e,t){this.storage[this.localStorageKey[e]+this.params.IdentityPoolId]=t},storage:function(){try{return t.util.isBrowser()&&"object"==typeof window.localStorage?window.localStorage:{}}catch(e){return{}}}()})},{"../core":3}],6:[function(e){var t=e("../core");t.CredentialProviderChain=t.util.inherit(t.Credentials,{constructor:function(e){this.providers=e?e:t.CredentialProviderChain.defaultProviders.slice(0)},resolve:function(e){function t(i,o){if(!i&&o||r===n.length)return void e(i,o);var a=n[r++];o="function"==typeof a?a.call():a,o.get?o.get(function(e){t(e,e?null:o)}):t(null,o)}if(0===this.providers.length)return e(new Error("No providers")),this;var r=0,n=this.providers.slice(0);return t(),this}}),t.CredentialProviderChain.defaultProviders=[]},{"../core":3}],7:[function(e){var t=e("../core");t.SAMLCredentials=t.util.inherit(t.Credentials,{constructor:function(e){t.Credentials.call(this),this.expired=!0,this.params=e,this.service=new t.STS({params:this.params})},refresh:function(e){var t=this;e||(e=function(e){if(e)throw e}),t.service.assumeRoleWithSAML(function(r,n){r||t.service.credentialsFrom(n,t),e(r)})}})},{"../core":3}],8:[function(e){var t=e("../core");t.TemporaryCredentials=t.util.inherit(t.Credentials,{constructor:function(e){t.Credentials.call(this),this.loadMasterCredentials(),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials"),this.service=new t.STS({params:this.params})},refresh:function(e){var t=this;e||(e=function(e){if(e)throw e}),t.service.config.credentials=t.masterCredentials;var r=t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken;r.call(t.service,function(r,n){r||t.service.credentialsFrom(n,t),e(r)})},loadMasterCredentials:function(){for(this.masterCredentials=t.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials}})},{"../core":3}],9:[function(e){var t=e("../core");t.WebIdentityCredentials=t.util.inherit(t.Credentials,{constructor:function(e){t.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.service=new t.STS({params:this.params}),this.data=null},refresh:function(e){var t=this;e||(e=function(e){if(e)throw e}),t.service.assumeRoleWithWebIdentity(function(r,n){t.data=null,r||(t.data=n,t.service.credentialsFrom(n,t)),e(r)})}})},{"../core":3}],10:[function(e){var t=e("./core"),r=e("./sequential_executor");t.EventListeners={Core:{}},t.EventListeners={Core:(new r).addNamedListeners(function(e,r){r("VALIDATE_CREDENTIALS","validate",function(e,r){return e.service.api.signatureVersion?void e.service.config.getCredentials(function(n){n&&(e.response.error=t.util.error(n,{code:"CredentialsError",message:"Missing credentials in config"})),r()}):r()}),e("VALIDATE_REGION","validate",function(e){e.service.config.region||e.service.isGlobalEndpoint||(e.response.error=t.util.error(new Error,{code:"ConfigError",message:"Missing region in config"}))}),e("VALIDATE_PARAMETERS","validate",function(e){var r=e.service.api.operations[e.operation].input;(new t.ParamValidator).validate(r,e.params)}),e("SET_CONTENT_LENGTH","afterBuild",function(e){if(void 0===e.httpRequest.headers["Content-Length"]){var r=t.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=r}}),e("SET_HTTP_HOST","afterBuild",function(e){e.httpRequest.headers.Host=e.httpRequest.endpoint.host}),e("RESTART","restart",function(){var e=this.response.error;e&&e.retryable&&(this.response.retryCount=600?this.emit("sign",[this],function(e){e?r(e):a()}):a()}),e("HTTP_HEADERS","httpHeaders",function(e,r,n){n.httpResponse.statusCode=e,n.httpResponse.headers=r,n.httpResponse.body=new t.util.Buffer(""),n.httpResponse.buffers=[],n.httpResponse.numBytes=0}),e("HTTP_DATA","httpData",function(e,r){if(e){if(t.util.isNode()){r.httpResponse.numBytes+=e.length;var n=r.httpResponse.headers["content-length"],i={loaded:r.httpResponse.numBytes,total:n};r.request.emit("httpDownloadProgress",[i,r])}r.httpResponse.buffers.push(new t.util.Buffer(e))}}),e("HTTP_DONE","httpDone",function(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var r=t.util.buffer.concat(e.httpResponse.buffers);e.httpResponse.body=r}delete e.httpResponse.numBytes,delete e.httpResponse.buffers}),e("FINALIZE_ERROR","retry",function(e){e.httpResponse.statusCode&&(e.error.statusCode=e.httpResponse.statusCode,void 0===e.error.retryable&&(e.error.retryable=this.service.retryableError(e.error,this)))}),e("INVALIDATE_CREDENTIALS","retry",function(e){if(e.error)switch(e.error.code){case"RequestExpired":case"ExpiredTokenException":case"ExpiredToken":e.error.retryable=!0,e.request.service.config.credentials.expired=!0}}),e("EXPIRED_SIGNATURE","retry",function(e){var t=e.error;t&&"string"==typeof t.code&&"string"==typeof t.message&&t.code.match(/Signature/)&&t.message.match(/expired/)&&(e.error.retryable=!0)}),e("REDIRECT","retry",function(e){e.error&&e.error.statusCode>=300&&e.error.statusCode<400&&e.httpResponse.headers.location&&(this.httpRequest.endpoint=new t.Endpoint(e.httpResponse.headers.location),this.httpRequest.headers.Host=this.httpRequest.endpoint.host,e.error.redirect=!0,e.error.retryable=!0)}),e("RETRY_CHECK","retry",function(e){if(e.error)if(e.error.redirect&&e.redirectCount=this.HEADERS_RECEIVED&&!l){try{p.responseType="arraybuffer"}catch(e){}u.statusCode=p.status,u.headers=a.parseHeaders(p.getAllResponseHeaders()),u.emit("headers",u.statusCode,u.headers),l=!0}this.readyState===this.DONE&&a.finishRequest(p,u)},!1),p.upload.addEventListener("progress",function(e){u.emit("sendProgress",e)}),p.addEventListener("progress",function(e){u.emit("receiveProgress",e)},!1),p.addEventListener("timeout",function(){o(t.util.error(new Error("Timeout"),{code:"TimeoutError"}))},!1),p.addEventListener("error",function(){o(t.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},!1),i(u),p.open(e.method,c,n.xhrAsync!==!1),t.util.each(e.headers,function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&p.setRequestHeader(e,t)}),n.timeout&&n.xhrAsync!==!1&&(p.timeout=n.timeout),n.xhrWithCredentials&&(p.withCredentials=!0);try{p.send(e.body)}catch(m){if(!e.body||"object"!=typeof e.body.buffer)throw m;p.send(e.body.buffer)}return u},parseHeaders:function(e){var r={};return t.util.arrayEach(e.split(/\r?\n/),function(e){var t=e.split(":",1)[0],n=e.substring(t.length+2);t.length>0&&(r[t]=n)}),r},finishRequest:function(e,r){var n;if("arraybuffer"===e.responseType&&e.response){var i=e.response;n=new t.util.Buffer(i.byteLength);for(var o=new Uint8Array(i),a=0;a1)){if(1===this.errors.length)throw this.errors[0];return!0}var i=this.errors.join("\n* ");if(this.errors.length>1)throw i="There were "+this.errors.length+" validation errors:\n* "+i,t.util.error(new Error(i),{code:"MultipleValidationErrors",errors:this.errors})},validateStructure:function(e,t,r){this.validateType(r,t,["object"],"structure");for(var n,i=0;e.required&&i0){var n=JSON.parse(r.body.toString());(n.__type||n.code)&&(t.code=(n.__type||n.code).split("#").pop()),t.message="RequestEntityTooLarge"===t.code?"Request body must be less than 1 MB":n.message||n.Message||null}else t.statusCode=r.statusCode,t.message=r.statusCode.toString();e.error=o.error(new Error,t)}function i(e){var t=e.httpResponse.body.toString()||"{}";if(e.request.service.config.convertResponseTypes===!1)e.data=JSON.parse(t);else{var r=e.request.service.api.operations[e.request.operation],n=r.output||{},i=new s;e.data=i.parse(t,n)}}var o=e("../util"),a=e("../json/builder"),s=e("../json/parser");t.exports={buildRequest:r,extractError:n,extractData:i}},{"../json/builder":13,"../json/parser":14,"../util":49}],23:[function(e,t){function r(e){var t=e.service.api.operations[e.operation],r=e.httpRequest;r.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8",r.params={Version:e.service.api.apiVersion,Action:t.name};var n=new s;n.serialize(e.params,t.input,function(e,t){r.params[e]=t}),r.body=a.queryParamsToString(r.params)}function n(e){var t,r=e.httpResponse.body.toString();t=r.match("=0?"&":"?";var a=[];u.arrayEach(Object.keys(i).sort(),function(e){Array.isArray(i[e])||(i[e]=[i[e]]);for(var t=0;t0){t=new a.XML.Parser;var l=t.parse(n.toString(),o);s.update(e.data,l)}}var a=e("../core"),s=e("../util"),u=e("./rest");t.exports={buildRequest:n,extractError:i,extractData:o}},{"../core":3,"../util":49,"./rest":24}],27:[function(e,t){function r(){}function n(e){return e.isQueryName||"ec2"!==e.api.protocol?e.name:e.name[0].toUpperCase()+e.name.substr(1)}function i(e,t,r,i){u.each(r.members,function(r,o){var a=t[r];if(null!==a&&void 0!==a){var u=n(o);u=e?e+"."+u:u,s(u,a,o,i)}})}function o(e,t,r,n){var i=1;u.each(t,function(t,o){var a=r.flattened?".":".entry.",u=a+i++ +".",c=u+(r.key.name||"key"),p=u+(r.value.name||"value");s(e+c,t,r.key,n),s(e+p,o,r.value,n)})}function a(e,t,r,i){var o=r.member||{};return 0===t.length?void i.call(this,e,null):void u.arrayEach(t,function(t,a){var u="."+(a+1);if("ec2"===r.api.protocol)u+="";else if(r.flattened){if(o.name){var c=e.split(".");c.pop(),c.push(n(o)),e=c.join(".")}}else u=".member"+u;s(e+u,t,o,i)})}function s(e,t,r,n){null!==t&&void 0!==t&&("structure"===r.type?i(e,t,r,n):"list"===r.type?a(e,t,r,n):"map"===r.type?o(e,t,r,n):n(e,r.toWireFormat(t).toString()))}var u=e("../util");r.prototype.serialize=function(e,t,r){i("",e,t,r)},t.exports=r},{"../util":49}],28:[function(e,t){function r(e){if(!e)return null;var t=e.split("-");return t.length<3?null:t.slice(0,t.length-2).join("-")+"-*"}function n(e){var t=e.config.region,n=r(t),i=e.api.endpointPrefix;return[[t,i],[n,i],[t,"*"],[n,"*"],["*",i],["*","*"]].map(function(e){return e[0]&&e[1]?e.join("/"):null})}function i(e,t){a.each(t,function(t,r){"globalEndpoint"!==t&&(void 0===e.config[t]||null===e.config[t])&&(e.config[t]=r)})}function o(e){for(var t=n(e),r=0;re){r.removeListener("httpData",n.EventListeners.Core.HTTP_DATA),r.removeListener("httpError",n.EventListeners.Core.HTTP_ERROR),r.on("httpError",function(e){a.error=e,a.error.retryable=!1});var s=a.httpResponse.createUnbufferedStream();o?(s.on("data",function(e){i.emit("data",e)}),s.on("end",function(){i.emit("end")})):(s.on("readable",function(){var e;do e=s.read(),null!==e&&i.push(e);while(null!==e);i.read(0)}),s.on("end",function(){i.push(null)})),s.on("error",function(e){i.emit("error",e)})}}),this.on("error",function(e){i.emit("error",e)}),i},emitEvent:function(e,t,r){"function"==typeof t&&(r=t,t=null),r||(r=function(){}),t||(t=this.eventParameters(e,this.response));var i=n.SequentialExecutor.prototype.emit;i.call(this,e,t,function(e){e&&(this.response.error=e),r.call(this,e)})},eventParameters:function(e){switch(e){case"restart":case"validate":case"sign":case"build":case"afterValidate":case"afterBuild":return[this];case"error":return[this.response.error,this.response];default:return[this.response]}},presign:function(e,t){return t||"function"!=typeof e||(t=e,e=null),(new n.Signers.Presign).sign(this.toGet(),e,t)},toUnauthenticated:function(){return this.removeListener("validate",n.EventListeners.Core.VALIDATE_CREDENTIALS),this.removeListener("sign",n.EventListeners.Core.SIGN),this.toGet()},toGet:function(){return("query"===this.service.api.protocol||"ec2"===this.service.api.protocol)&&(this.removeListener("build",this.buildAsGet),this.addListener("build",this.buildAsGet)),this},buildAsGet:function(e){e.httpRequest.method="GET",e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body,e.httpRequest.body="",delete e.httpRequest.headers["Content-Length"],delete e.httpRequest.headers["Content-Type"]}}),n.util.mixin(n.Request,n.SequentialExecutor)}).call(this,e("FWaASH"))},{"./core":3,"./state_machine":48,FWaASH:63}],31:[function(e){var t=e("./core"),r=t.util.inherit;t.ResourceWaiter=r({constructor:function(e,r){this.service=e,this.state=r,"object"==typeof this.state&&t.util.each.call(this,this.state,function(e,t){this.state=e,this.expectedValue=t}),this.loadWaiterConfig(this.state),this.expectedValue||(this.expectedValue=this.config.successValue)},service:null,state:null,expectedValue:null,config:null,waitDone:!1,Listeners:{retry:(new t.SequentialExecutor).addNamedListeners(function(e){e("RETRY_CHECK","retry",function(e){var t=e.request._waiter;e.error&&"ResourceNotReady"===e.error.code&&(e.error.retryDelay=1e3*t.config.interval)})}),output:(new t.SequentialExecutor).addNamedListeners(function(e){e("CHECK_OUT_ERROR","extractError",function(e){e.error&&e.request._waiter.setError(e,!0)}),e("CHECK_OUTPUT","extractData",function(e){var t=e.request._waiter,r=t.checkSuccess(e);r?e.error=null:t.setError(e,null===r?!1:!0)})}),error:(new t.SequentialExecutor).addNamedListeners(function(e){e("CHECK_ERROR","extractError",function(e){var t=e.request._waiter,r=t.checkError(e);r?(e.error=null,e.data={},e.request.removeAllListeners("extractData")):t.setError(e,null===r?!1:!0)}),e("CHECK_ERR_OUTPUT","extractData",function(e){e.request._waiter.setError(e,!0)})})},wait:function(e,t){"function"==typeof e&&(t=e,e=void 0);var r=this.service.makeRequest(this.config.operation,e),n=this.Listeners[this.config.successType];return r._waiter=this,r.response.maxRetries=this.config.maxAttempts,r.addListeners(this.Listeners.retry),n&&r.addListeners(n),t&&r.send(t),r},setError:function(e,r){e.data=null,e.error=t.util.error(e.error||new Error,{code:"ResourceNotReady",message:"Resource is not in the state "+this.state,retryable:r})},checkSuccess:function(e){if(!this.config.successPath)return e.httpResponse.statusCode<300;var r=t.util.jamespath.find(this.config.successPath,e.data);return this.config.failureValue&&this.config.failureValue.indexOf(r)>=0?null:this.expectedValue?r===this.expectedValue:r?!0:!1},checkError:function(e){var t=this.config.successValue;return"number"==typeof t?e.httpResponse.statusCode===t:e.error&&e.error.code===t},loadWaiterConfig:function(e,r){if(!this.service.api.waiters[e]){if(r)return;throw new t.util.error(new Error,{code:"StateNotFoundError",message:"State "+e+" not found."})}this.config=this.service.api.waiters[e];var n=this.config;!function(){n.successType=n.successType||n.acceptorType,n.successPath=n.successPath||n.acceptorPath,n.successValue=n.successValue||n.acceptorValue,n.failureType=n.failureType||n.acceptorType,n.failurePath=n.failurePath||n.acceptorPath,n.failureValue=n.failureValue||n.acceptorValue}()}})},{"./core":3}],32:[function(e){var t=e("./core"),r=t.util.inherit;t.Response=r({constructor:function(e){this.request=e,this.data=null,this.error=null,this.retryCount=0,this.redirectCount=0,this.httpResponse=new t.HttpResponse,e&&(this.maxRetries=e.service.numRetries(),this.maxRedirects=e.service.config.maxRedirects)},nextPage:function(e){var r,n=this.request.service,i=this.request.operation;try{r=n.paginationConfig(i,!0)}catch(o){this.error=o}if(!this.hasNextPage()){if(e)e(this.error,null);else if(this.error)throw this.error;return null}var a=t.util.copy(this.request.params);if(this.nextPageTokens){var s=r.inputToken;"string"==typeof s&&(s=[s]);for(var u=0;ue.partSize&&(e.partSize=r)}else e.totalBytes=void 0},isDoneChunking:!1,partPos:0,totalChunkedBytes:0,totalUploadedBytes:0,totalBytes:void 0,numParts:0,totalPartNumbers:0,activeParts:0,doneParts:0,parts:null,completeInfo:null,failed:!1,multipartReq:null,partBuffer:null,fillBuffer:function(){for(var e=this,t=n(e.body);e.activeParts=e.queueSize)){var t=e.body.read(e.partSize-e.partBuffer.length)||e.body.read();t&&(e.partBuffer=r.util.Buffer.concat([e.partBuffer,t]),e.totalChunkedBytes+=t.length),e.partBuffer.length>=e.partSize?(e.nextChunk(e.partBuffer.slice(0,e.partSize)),e.partBuffer=e.partBuffer.slice(e.partSize)):e.isDoneChunking&&(e.totalBytes=e.totalChunkedBytes,e.partBuffer.length>0&&(e.numParts++,e.nextChunk(e.partBuffer)),e.partBuffer=new r.util.Buffer(0)),e.body.read(0)}},nextChunk:function(e){var t=this;if(t.failed)return null;var r=++t.totalPartNumbers;if(t.isDoneChunking&&1===r){var n=t.service.putObject({Body:e});return n._managedUpload=t,n.on("httpUploadProgress",t.progress).send(t.finishSinglePart),null}t.activeParts++,t.service.config.params.UploadId?t.uploadPart(e,r):t.multipartReq?t.queueChunks(e,r):(t.multipartReq=t.service.createMultipartUpload(),t.multipartReq.on("success",function(e){t.service.config.params.UploadId=e.data.UploadId,t.multipartReq=null}),t.queueChunks(e,r),t.multipartReq.on("error",function(e){t.cleanup(e)}),t.multipartReq.send())},uploadPart:function(e,t){var n=this,i={Body:e,ContentLength:r.util.string.byteLength(e),PartNumber:t},o={ETag:null,PartNumber:t};n.completeInfo.push(o);var a=n.service.uploadPart(i);n.parts[t]=a,a._lastUploadedBytes=0,a._managedUpload=n,a.on("httpUploadProgress",n.progress),a.send(function(e,t){if(delete n.parts[i.PartNumber],n.activeParts--,!(e||t&&t.ETag)){var a="No access to ETag property on response.";r.util.isBrowser()&&(a+=" Check CORS configuration to expose ETag header."),e=r.util.error(new Error(a),{code:"ETagMissing",retryable:!1})}return e?n.cleanup(e):(o.ETag=t.ETag,n.doneParts++,void(n.isDoneChunking&&n.doneParts===n.numParts?n.finishMultiPart():n.fillQueue.call(n)))})},queueChunks:function(e,t){var r=this;r.multipartReq.on("success",function(){r.uploadPart(e,t)})},cleanup:function(e){var t=this;t.failed||("function"==typeof t.body.removeAllListeners&&"function"==typeof t.body.resume&&(t.body.removeAllListeners("readable"),t.body.removeAllListeners("end"),t.body.resume()),t.service.config.params.UploadId&&!t.leavePartsOnError&&t.service.abortMultipartUpload().send(),r.util.each(t.parts,function(e,t){t.removeAllListeners("complete"),t.abort()}),t.parts={},t.callback(e),t.failed=!0)},finishMultiPart:function(){var e=this,t={MultipartUpload:{Parts:e.completeInfo}};e.service.completeMultipartUpload(t,function(t,r){return t?e.cleanup(t):void e.callback(t,r)})},finishSinglePart:function(e,t){var n=this.request._managedUpload,i=this.request.httpRequest,o=r.util.urlFormat(i.endpoint);return e?n.callback(e):(t.Location=o.substr(0,o.length-1)+i.path,void n.callback(e,t))},progress:function(e){var t=this._managedUpload;"putObject"===this.operation?e.part=1:(t.totalUploadedBytes+=e.loaded-this._lastUploadedBytes,this._lastUploadedBytes=e.loaded,e={loaded:t.totalUploadedBytes,total:t.totalBytes,part:this.params.PartNumber}),t.emit("httpUploadProgress",[e])}}),r.util.mixin(r.S3.ManagedUpload,r.SequentialExecutor),t.exports=r.S3.ManagedUpload},{"../core":3}],34:[function(e,t){var r=e("./core");r.SequentialExecutor=r.util.inherit({constructor:function(){this._events={}},listeners:function(e){return this._events[e]?this._events[e].slice(0):[]},on:function(e,t){return this._events[e]?this._events[e].push(t):this._events[e]=[t],this},onAsync:function(e,t){return t._isAsync=!0,this.on(e,t)},removeListener:function(e,t){var r=this._events[e];if(r){for(var n=r.length,i=-1,o=0;n>o;++o)r[o]===t&&(i=o);i>-1&&r.splice(i,1)}return this},removeAllListeners:function(e){return e?delete this._events[e]:this._events={},this},emit:function(e,t,r){r||(r=function(){});var n=this.listeners(e),i=n.length;return this.callListeners(n,t,r),i>0},callListeners:function(e,t,r){function n(n){n?r.call(i,n):i.callListeners(e,t,r)}for(var i=this;e.length>0;){var o=e.shift();if(o._isAsync)return void o.apply(i,t.concat([n]));o.apply(i,t)}r.call(i)},addListeners:function(e){var t=this;return e._events&&(e=e._events),r.util.each(e,function(e,n){"function"==typeof n&&(n=[n]),r.util.arrayEach(n,function(r){t.on(e,r)})}),t},addNamedListener:function(e,t,r){return this[e]=r,this.addListener(t,r),this},addNamedAsyncListener:function(e,t,r){return r._isAsync=!0,this.addNamedListener(e,t,r)},addNamedListeners:function(e){var t=this;return e(function(){t.addNamedListener.apply(t,arguments)},function(){t.addNamedAsyncListener.apply(t,arguments)}),this}}),r.SequentialExecutor.prototype.addListener=r.SequentialExecutor.prototype.on,t.exports=r.SequentialExecutor},{"./core":3}],35:[function(e){var t=e("./core"),r=e("./model/api"),n=e("./region_config"),i=t.util.inherit;t.Service=i({constructor:function(e){if(!this.loadServiceClass)throw t.util.error(new Error,"Service must be constructed with `new' operator");var r=this.loadServiceClass(e||{});return r?new r(e):void this.initialize(e)},initialize:function(e){var r=t.config[this.serviceIdentifier];this.config=new t.Config(t.config),r&&this.config.update(r,!0),e&&this.config.update(e,!0),this.validateService(),this.config.endpoint||n(this),this.config.endpoint=this.endpointFromTemplate(this.config.endpoint),this.setEndpoint(this.config.endpoint)},validateService:function(){},loadServiceClass:function(e){var r=e;if(t.util.isEmpty(this.api)){if(r.apiConfig)return t.Service.defineServiceApi(this.constructor,r.apiConfig);if(this.constructor.services){r=new t.Config(t.config),r.update(e,!0);var n=r.apiVersions[this.constructor.serviceIdentifier];return n=n||r.apiVersion,this.getLatestServiceClass(n)}return null}return null},getLatestServiceClass:function(e){return e=this.getLatestServiceVersion(e),null===this.constructor.services[e]&&t.Service.defineServiceApi(this.constructor,e),this.constructor.services[e]},getLatestServiceVersion:function(e){if(!this.constructor.services||0===this.constructor.services.length)throw new Error("No services defined on "+this.constructor.serviceIdentifier);if(e?t.util.isType(e,Date)&&(e=t.util.date.iso8601(e).split("T")[0]):e="latest",Object.hasOwnProperty(this.constructor.services,e))return e;for(var r=Object.keys(this.constructor.services).sort(),n=null,i=r.length-1;i>=0;i--)if("*"!==r[i][r[i].length-1]&&(n=r[i]),r[i].substr(0,10)<=e)return n;throw new Error("Could not find "+this.constructor.serviceIdentifier+" API to satisfy version constraint `"+e+"'")},api:{},defaultRetryCount:3,makeRequest:function(e,r,n){if("function"==typeof r&&(n=r,r=null),r=r||{},this.config.params){var i=this.api.operations[e];i&&(r=t.util.copy(r),t.util.each(this.config.params,function(e,t){i.input.members[e]&&(void 0===r[e]||null===r[e])&&(r[e]=t)}))}var o=new t.Request(this,e,r);return this.addAllRequestListeners(o),n&&o.send(n),o},makeUnauthenticatedRequest:function(e,t,r){"function"==typeof t&&(r=t,t={});var n=this.makeRequest(e,t).toUnauthenticated();return r?n.send(r):n},waitFor:function(e,r,n){var i=new t.ResourceWaiter(this,e);return i.wait(r,n)},addAllRequestListeners:function(e){for(var r=[t.events,t.EventListeners.Core,this.serviceInterface(),t.EventListeners.CorePost],n=0;nr;++r)t[r]=30*Math.pow(2,r);return t},retryableError:function(e){return this.networkingError(e)?!0:this.expiredCredentialsError(e)?!0:this.throttledError(e)?!0:e.statusCode>=500?!0:!1},networkingError:function(e){return"NetworkingError"===e.code },expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},throttledError:function(e){switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;var t=e;return t=t.replace(/\{service\}/g,this.api.endpointPrefix),t=t.replace(/\{region\}/g,this.config.region),t=t.replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new t.Endpoint(e,this.config)},paginationConfig:function(e,r){var n=this.api.operations[e].paginator;if(!n){if(r){var i=new Error;throw t.util.error(i,"No pagination configuration for "+e)}return null}return n}}),t.util.update(t.Service,{defineMethods:function(e){t.util.each(e.prototype.api.operations,function(t){e.prototype[t]||(e.prototype[t]=function(e,r){return this.makeRequest(t,e,r)})})},defineService:function(e,r,n){t.Service._serviceMap[e]=!0,Array.isArray(r)||(n=r,r=[]);var o=i(t.Service,n||{});if("string"==typeof e){t.Service.addVersions(o,r);var a=o.serviceIdentifier||e;o.serviceIdentifier=a}else o.prototype.api=e,t.Service.defineMethods(o);return o},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var r=0;rr;++r)t.push(0===r?0:50*Math.pow(2,r-1));return t}})},{"../core":3}],38:[function(e){var t=e("../core");e("../s3/managed_upload"),t.util.update(t.S3.prototype,{validateService:function(){if(this.config.region||(this.config.region="us-east-1"),!this.config.endpoint&&this.config.s3BucketEndpoint){var e="An endpoint must be provided when configuring `s3BucketEndpoint` to true.";throw t.util.error(new Error,{name:"InvalidEndpoint",message:e})}},setupRequestListeners:function(e){e.addListener("validate",this.validateScheme),e.addListener("validate",this.validateBucketEndpoint),e.addListener("build",this.addContentType),e.addListener("build",this.populateURI),e.addListener("build",this.computeContentMd5),e.onAsync("build",this.computeSha256),e.addListener("build",this.computeSseCustomerKeyMd5),e.addListener("afterBuild",this.addExpect100Continue),e.removeListener("validate",t.EventListeners.Core.VALIDATE_REGION),e.addListener("extractError",this.extractError),e.addListener("extractData",this.extractData),e.addListener("beforePresign",this.prepareSignedUrl)},validateScheme:function(e){var r=e.params,n=e.httpRequest.endpoint.protocol,i=r.SSECustomerKey||r.CopySourceSSECustomerKey;if(i&&"https:"!==n){var o="Cannot send SSE keys over HTTP. Set 'sslEnabled'to 'true' in your configuration";throw t.util.error(new Error,{code:"ConfigError",message:o})}},validateBucketEndpoint:function(e){if(!e.params.Bucket&&e.service.config.s3BucketEndpoint){var r="Cannot send requests to root API with `s3BucketEndpoint` set.";throw t.util.error(new Error,{code:"ConfigError",message:r})}},populateURI:function(e){var t=e.httpRequest,r=e.params.Bucket;if(r&&!e.service.pathStyleBucketName(r)){if(!e.service.config.s3BucketEndpoint){t.endpoint.hostname=r+"."+t.endpoint.hostname;var n=t.endpoint.port;t.endpoint.host=80!==n&&443!==n?t.endpoint.hostname+":"+t.endpoint.port:t.endpoint.hostname}t.virtualHostedBucket=r,t.path=t.path.replace(new RegExp("/"+r),""),"/"!==t.path[0]&&(t.path="/"+t.path)}},addExpect100Continue:function(e){var r=e.httpRequest.headers["Content-Length"];t.util.isNode()&&r>=1048576&&(e.httpRequest.headers.Expect="100-continue")},addContentType:function(e){var r=e.httpRequest;if("GET"===r.method||"HEAD"===r.method)return void delete r.headers["Content-Type"];r.headers["Content-Type"]||(r.headers["Content-Type"]="application/octet-stream");var n=r.headers["Content-Type"];if(t.util.isBrowser())if("string"!=typeof r.body||n.match(/;\s*charset=/)){var i=function(e,t,r){return t+r.toUpperCase()};r.headers["Content-Type"]=n.replace(/(;\s*charset=)(.+)$/,i)}else{var o="; charset=UTF-8";r.headers["Content-Type"]+=o}},computableChecksumOperations:{putBucketCors:!0,putBucketLifecycle:!0,putBucketTagging:!0,deleteObjects:!0},willComputeChecksums:function(e){if(this.computableChecksumOperations[e.operation])return!0;if(!this.config.computeChecksums)return!1;if(!t.util.Buffer.isBuffer(e.httpRequest.body)&&"string"!=typeof e.httpRequest.body)return!1;var r=e.service.api.operations[e.operation].input.members;return e.service.getSignerClass(e)===t.Signers.V4&&r.ContentMD5&&!r.ContentMD5.required?!1:r.ContentMD5&&!e.params.ContentMD5?!0:void 0},computeContentMd5:function(e){if(e.service.willComputeChecksums(e)){var r=t.util.crypto.md5(e.httpRequest.body,"base64");e.httpRequest.headers["Content-MD5"]=r}},computeSha256:function(e,r){if(e.service.getSignerClass(e)===t.Signers.V4){var n=e.httpRequest.body||"";if(t.util.isNode()){var i=t.util.nodeRequire("stream").Stream,o=t.util.nodeRequire("fs");if(n instanceof i){if("string"!=typeof n.path)return void r(new Error("Non-file stream objects are not supported with SigV4 in AWS.S3"));n=o.createReadStream(n.path)}}t.util.crypto.sha256(n,"hex",function(t,n){t||(e.httpRequest.headers["X-Amz-Content-Sha256"]=n),r(t)})}else r()},computeSseCustomerKeyMd5:function(e){var r=["x-amz-server-side-encryption-customer-key","x-amz-copy-source-server-side-encryption-customer-key"];t.util.arrayEach(r,function(r){if(e.httpRequest.headers[r]){var n=e.httpRequest.headers[r],i=r+"-MD5";if(e.httpRequest.headers[r]=t.util.base64.encode(n),!e.httpRequest.headers[i]){var o=t.util.crypto.md5(n,"base64");e.httpRequest.headers[i]=o}}})},pathStyleBucketName:function(e){return this.config.s3ForcePathStyle?!0:this.config.s3BucketEndpoint?!1:this.dnsCompatibleBucketName(e)?this.config.sslEnabled&&e.match(/\./)?!0:!1:!0},dnsCompatibleBucketName:function(e){var t=e,r=new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/),n=new RegExp(/(\d+\.){3}\d+/),i=new RegExp(/\.\./);return!t.match(r)||t.match(n)||t.match(i)?!1:!0},successfulResponse:function(e){var t=e.request,r=e.httpResponse;return"completeMultipartUpload"===t.operation&&r.body.toString().match("")?!1:r.statusCode<300},retryableError:function(e,r){if("completeMultipartUpload"===r.operation&&200===e.statusCode)return!0;if(e&&"RequestTimeout"===e.code)return!0;var n=t.Service.prototype.retryableError;return n.call(this,e,r)},extractData:function(e){var t=e.request;if("getBucketLocation"===t.operation){var r=e.httpResponse.body.toString().match(/>(.+)<\/Location/);r&&(delete e.data._,e.data.LocationConstraint=r[1])}},extractError:function(e){var r={304:"NotModified",403:"Forbidden",400:"BadRequest",404:"NotFound"},n=e.httpResponse.statusCode,i=e.httpResponse.body||"";if(r[n]&&0===i.length)e.error=t.util.error(new Error,{code:r[e.httpResponse.statusCode],message:null});else{var o=(new t.XML.Parser).parse(i.toString());e.error=t.util.error(new Error,{code:o.Code||n,message:o.Message||null})}},getSignedUrl:function(e,r,n){r=t.util.copy(r||{});var i=r.Expires||900;delete r.Expires;var o=this.makeRequest(e,r);return o.presign(i,n)},prepareSignedUrl:function(e){e.addListener("validate",e.service.noPresignedContentLength),e.removeListener("build",e.service.addContentType),e.params.Body||(e.removeListener("build",e.service.computeContentMd5),e.removeListener("build",e.service.computeSha256))},noPresignedContentLength:function(e){if(void 0!==e.params.ContentLength)throw t.util.error(new Error,{code:"UnexpectedParameter",message:"ContentLength is not supported in pre-signed URLs."})},createBucket:function(e,t){e||(e={});var r=this.endpoint.hostname;return r===this.api.globalEndpoint||e.CreateBucketConfiguration||(e.CreateBucketConfiguration={LocationConstraint:this.config.region}),this.makeRequest("createBucket",e,t)},upload:function(e,r,n){"function"==typeof r&&void 0===n&&(n=r,r=null),r=r||{},r=t.util.merge(r||{},{service:this,params:e});var i=new t.S3.ManagedUpload(r);return"function"==typeof n&&i.send(n),i}})},{"../core":3,"../s3/managed_upload":33}],39:[function(e){var t=e("../core");t.util.update(t.SQS.prototype,{setupRequestListeners:function(e){e.addListener("build",this.buildEndpoint),e.service.config.computeChecksums&&("sendMessage"===e.operation?e.addListener("extractData",this.verifySendMessageChecksum):"sendMessageBatch"===e.operation?e.addListener("extractData",this.verifySendMessageBatchChecksum):"receiveMessage"===e.operation&&e.addListener("extractData",this.verifyReceiveMessageChecksum))},verifySendMessageChecksum:function(e){if(e.data){var t=e.data.MD5OfMessageBody,r=this.params.MessageBody,n=this.service.calculateChecksum(r);if(n!==t){var i='Got "'+e.data.MD5OfMessageBody+'", expecting "'+n+'".';this.service.throwInvalidChecksumError(e,[e.data.MessageId],i)}}},verifySendMessageBatchChecksum:function(e){if(e.data){var r=this.service,n={},i=[],o=[];t.util.arrayEach(e.data.Successful,function(e){n[e.Id]=e}),t.util.arrayEach(this.params.Entries,function(e){if(n[e.Id]){var t=n[e.Id].MD5OfMessageBody,a=e.MessageBody;r.isChecksumValid(t,a)||(i.push(e.Id),o.push(n[e.Id].MessageId))}}),i.length>0&&r.throwInvalidChecksumError(e,o,"Invalid messages: "+i.join(", "))}},verifyReceiveMessageChecksum:function(e){if(e.data){var r=this.service,n=[];t.util.arrayEach(e.data.Messages,function(e){var t=e.MD5OfBody,i=e.Body;r.isChecksumValid(t,i)||n.push(e.MessageId)}),n.length>0&&r.throwInvalidChecksumError(e,n,"Invalid messages: "+n.join(", "))}},throwInvalidChecksumError:function(e,r,n){e.error=t.util.error(new Error,{retryable:!0,code:"InvalidChecksum",messageIds:r,message:e.request.operation+" returned an invalid MD5 response. "+n})},isChecksumValid:function(e,t){return this.calculateChecksum(t)===e},calculateChecksum:function(e){return t.util.crypto.md5(e,"hex")},buildEndpoint:function(e){var r=e.httpRequest.params.QueueUrl;if(r){e.httpRequest.endpoint=new t.Endpoint(r);var n=e.httpRequest.endpoint.host.match(/^sqs\.(.+?)\./);n&&(e.httpRequest.region=n[1])}}})},{"../core":3}],40:[function(e){var t=e("../core");t.util.update(t.STS.prototype,{credentialsFrom:function(e,r){return e?(r||(r=new t.TemporaryCredentials),r.expired=!1,r.accessKeyId=e.Credentials.AccessKeyId,r.secretAccessKey=e.Credentials.SecretAccessKey,r.sessionToken=e.Credentials.SessionToken,r.expireTime=e.Credentials.Expiration,r):null},assumeRoleWithWebIdentity:function(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithWebIdentity",e,t)},assumeRoleWithSAML:function(e,t){return this.makeUnauthenticatedRequest("assumeRoleWithSAML",e,t)}})},{"../core":3}],41:[function(e,t){function r(e){var t=e.httpRequest.headers[a];if(delete e.httpRequest.headers["User-Agent"],delete e.httpRequest.headers["X-Amz-User-Agent"],e.service.getSignerClass()===i.Signers.V4){if(t>604800){var r="Presigning does not support expiry time greater than a week with SigV4 signing.";throw i.util.error(new Error,{code:"InvalidExpiryTime",message:r,retryable:!1})}e.httpRequest.headers[a]=t}else{if(e.service.getSignerClass()!==i.Signers.S3)throw i.util.error(new Error,{message:"Presigning only supports S3 or SigV4 signing.",code:"UnsupportedSigner",retryable:!1});e.httpRequest.headers[a]=parseInt(i.util.date.unixTimestamp()+t,10).toString()}}function n(e){var t=e.httpRequest.endpoint,r=i.util.urlParse(e.httpRequest.path),n={};r.search&&(n=i.util.queryStringParse(r.search.substr(1))),i.util.each(e.httpRequest.headers,function(e,t){e===a&&(e="Expires"),n[e]=t}),delete e.httpRequest.headers[a];var o=n.Authorization.split(" ");if("AWS"===o[0])o=o[1].split(":"),n.AWSAccessKeyId=o[0],n.Signature=o[1];else if("AWS4-HMAC-SHA256"===o[0]){o.shift();var s=o.join(" "),u=s.match(/Signature=(.*?)(?:,|\s|\r?\n|$)/)[1];n["X-Amz-Signature"]=u,delete n.Expires}delete n.Authorization,delete n.Host,t.pathname=r.pathname,t.search=i.util.queryParamsToString(n)}var i=e("../core"),o=i.util.inherit,a="presigned-expires";i.Signers.Presign=o({sign:function(e,t,o){if(e.httpRequest.headers[a]=t||3600,e.on("build",r),e.on("sign",n),e.removeListener("afterBuild",i.EventListeners.Core.SET_CONTENT_LENGTH),e.emit("beforePresign",[e]),!o){if(e.build(),e.response.error)throw e.response.error;return i.util.urlFormat(e.httpRequest.endpoint)}e.build(function(){this.response.error?o(this.response.error):o(null,i.util.urlFormat(e.httpRequest.endpoint))})}}),t.exports=i.Signers.Presign},{"../core":3}],42:[function(e){var t=e("../core"),r=t.util.inherit;t.Signers.RequestSigner=r({constructor:function(e){this.request=e}}),t.Signers.RequestSigner.getVersion=function(e){switch(e){case"v2":return t.Signers.V2;case"v3":return t.Signers.V3;case"v4":return t.Signers.V4;case"s3":return t.Signers.S3;case"v3https":return t.Signers.V3Https}throw new Error("Unknown signing version "+e)},e("./v2"),e("./v3"),e("./v3https"),e("./v4"),e("./s3"),e("./presign")},{"../core":3,"./presign":41,"./s3":43,"./v2":44,"./v3":45,"./v3https":46,"./v4":47}],43:[function(e,t){var r=e("../core"),n=r.util.inherit;r.Signers.S3=n(r.Signers.RequestSigner,{subResources:{acl:1,cors:1,lifecycle:1,"delete":1,location:1,logging:1,notification:1,partNumber:1,policy:1,requestPayment:1,restore:1,tagging:1,torrent:1,uploadId:1,uploads:1,versionId:1,versioning:1,versions:1,website:1},responseHeaders:{"response-content-type":1,"response-content-language":1,"response-expires":1,"response-cache-control":1,"response-content-disposition":1,"response-content-encoding":1},addAuthorization:function(e,t){this.request.headers["presigned-expires"]||(this.request.headers["X-Amz-Date"]=r.util.date.rfc822(t)),e.sessionToken&&(this.request.headers["x-amz-security-token"]=e.sessionToken);var n=this.sign(e.secretAccessKey,this.stringToSign()),i="AWS "+e.accessKeyId+":"+n;this.request.headers.Authorization=i},stringToSign:function(){var e=this.request,t=[];t.push(e.method),t.push(e.headers["Content-MD5"]||""),t.push(e.headers["Content-Type"]||""),t.push(e.headers["presigned-expires"]||"");var r=this.canonicalizedAmzHeaders();return r&&t.push(r),t.push(this.canonicalizedResource()),t.join("\n")},canonicalizedAmzHeaders:function(){var e=[];r.util.each(this.request.headers,function(t){t.match(/^x-amz-/i)&&e.push(t)}),e.sort(function(e,t){return e.toLowerCase()=0?"&":"?";this.request.path+=a+r.util.queryParamsToString(i)},authorization:function(e,t){var r=[],n=this.credentialString(t);return r.push(this.algorithm+" Credential="+e.accessKeyId+"/"+n),r.push("SignedHeaders="+this.signedHeaders()),r.push("Signature="+this.signature(e,t)),r.join(", ")},signature:function(e,t){var n=i[this.serviceName],o=t.substr(0,8);if(!n||n.akid!==e.accessKeyId||n.region!==this.request.region||n.date!==o){var a=e.secretAccessKey,s=r.util.crypto.hmac("AWS4"+a,o,"buffer"),u=r.util.crypto.hmac(s,this.request.region,"buffer"),c=r.util.crypto.hmac(u,this.serviceName,"buffer"),p=r.util.crypto.hmac(c,"aws4_request","buffer");i[this.serviceName]={region:this.request.region,date:o,key:p,akid:e.accessKeyId}}var l=i[this.serviceName].key;return r.util.crypto.hmac(l,this.stringToSign(t),"hex")},stringToSign:function(e){var t=[];return t.push("AWS4-HMAC-SHA256"),t.push(e),t.push(this.credentialString(e)),t.push(this.hexEncodedHash(this.canonicalString())),t.join("\n")},canonicalString:function(){var e=[],t=this.request.pathname();return"s3"!==this.serviceName&&(t=r.util.uriEscapePath(t)),e.push(this.request.method),e.push(t),e.push(this.request.search()),e.push(this.canonicalHeaders()+"\n"),e.push(this.signedHeaders()),e.push(this.hexEncodedBodyHash()),e.join("\n")},canonicalHeaders:function(){var e=[];r.util.each.call(this,this.request.headers,function(t,r){e.push([t,r])}),e.sort(function(e,t){return e[0].toLowerCase()=e.length)return t.push(null);var i=r+n;i>e.length&&(i=e.length),t.push(e.slice(r,i)),r=i},t},concat:function(e){var t,r=0,n=0,i=null;for(t=0;tn&&(n=e.length+n),r.push(e[n])}}),n=r),0===n.length?a.abort:void 0}),n.length>0?(r=n,a.abort):void 0}),r},find:function(e,t){return a.jamespath.query(e,t)[0]}},date:{getDate:function(){return n||(n=e("./core")),n.config.systemClockOffset?new Date((new Date).getTime()+n.config.systemClockOffset):new Date},iso8601:function(e){return void 0===e&&(e=a.date.getDate()),e.toISOString()},rfc822:function(e){return void 0===e&&(e=a.date.getDate()),e.toUTCString()},unixTimestamp:function(e){return void 0===e&&(e=a.date.getDate()),e.getTime()/1e3},from:function(e){return new Date("number"==typeof e?1e3*e:e)},format:function(e,t){return t||(t="iso8601"),a.date[t](a.date.from(e))},parseTimestamp:function(e){if("number"==typeof e)return new Date(1e3*e);if(e.match(/^\d+$/))return new Date(1e3*e);if(e.match(/^\d{4}/))return new Date(e);if(e.match(/^\w{3},/))return new Date(e);throw a.error(new Error("unhandled timestamp format: "+e),{code:"TimestampParserError"})}},crypto:{crc32Table:[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],crc32:function(e){var t=a.crypto.crc32Table,r=-1;"string"==typeof e&&(e=new o(e));for(var n=0;n>>8^t[255&(r^i)]}return(-1^r)>>>0},hmac:function(e,t,r,n){return r||(r="binary"),"buffer"===r&&(r=void 0),n||(n="sha256"),"string"==typeof t&&(t=new o(t)),i.createHmac(n,e).update(t).digest(r)},md5:function(e,t,r){return a.crypto.hash("md5",e,t,r)},sha256:function(e,t,r){return a.crypto.hash("sha256",e,t,r)},hash:function(e,t,r,n){var i=a.crypto.createHash(e);r||(r="binary"),"buffer"===r&&(r=void 0),"string"==typeof t&&(t=new o(t));var s=a.arraySliceFn(t),u=o.isBuffer(t);if(n&&"object"==typeof t&&"function"==typeof t.on&&!u)t.on("data",function(e){i.update(e)}),t.on("error",function(e){n(e)}),t.on("end",function(){n(null,i.digest(r))});else{if(!n||!s||u||"undefined"==typeof FileReader){a.isBrowser()&&"object"==typeof t&&!u&&(t=new o(new Uint8Array(t)));var c=i.update(t).digest(r);return n&&n(null,c),c}var p=0,l=524288,m=new FileReader;m.onerror=function(){n(new Error("Failed to read data."))},m.onload=function(){var e=new o(new Uint8Array(m.result));i.update(e),p+=e.length,m._continueReading()},m._continueReading=function(){if(p>=t.size)return void n(null,i.digest(r));var e=p+l;e>t.size&&(e=t.size),m.readAsArrayBuffer(s.call(t,p,e))},m._continueReading()}},toHex:function(e){for(var t=[],r=0;rs;s++)a[s]=n.isBuffer(e)?e.readUInt8(s):e[s];else if("string"===i)a.write(e,0,t);else if("number"===i&&!n._useTypedArrays&&!r)for(s=0;o>s;s++)a[s]=0;return a}function i(e,t,r,i){r=Number(r)||0;var o=e.length-r;i?(i=Number(i),i>o&&(i=o)):i=o;var a=t.length;F(a%2===0,"Invalid hex string"),i>a/2&&(i=a/2);for(var s=0;i>s;s++){var u=parseInt(t.substr(2*s,2),16);F(!isNaN(u),"Invalid hex string"),e[r+s]=u}return n._charsWritten=2*s,s}function o(e,t,r,i){var o=n._charsWritten=_(B(t),e,r,i);return o}function a(e,t,r,i){var o=n._charsWritten=_(L(t),e,r,i);return o}function s(e,t,r,n){return a(e,t,r,n)}function u(e,t,r,i){var o=n._charsWritten=_(U(t),e,r,i);return o}function c(e,t,r,i){var o=n._charsWritten=_(D(t),e,r,i);return o}function p(e,t,r){return V.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function l(e,t,r){var n="",i="";r=Math.min(e.length,r);for(var o=t;r>o;o++)e[o]<=127?(n+=z(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return n+z(i)}function m(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function d(e,t,r){return m(e,t,r)}function h(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=t;r>o;o++)i+=M(e[o]);return i}function y(e,t,r){for(var n=e.slice(t,r),i="",o=0;o=i)){var o;return r?(o=e[t],i>t+1&&(o|=e[t+1]<<8)):(o=e[t]<<8,i>t+1&&(o|=e[t+1])),o}}function g(e,t,r,n){n||(F("boolean"==typeof r,"missing or invalid endian"),F(void 0!==t&&null!==t,"missing offset"),F(t+3=i)){var o;return r?(i>t+2&&(o=e[t+2]<<16),i>t+1&&(o|=e[t+1]<<8),o|=e[t],i>t+3&&(o+=e[t+3]<<24>>>0)):(i>t+1&&(o=e[t+1]<<16),i>t+2&&(o|=e[t+2]<<8),i>t+3&&(o|=e[t+3]),o+=e[t]<<24>>>0),o}}function b(e,t,r,n){n||(F("boolean"==typeof r,"missing or invalid endian"),F(void 0!==t&&null!==t,"missing offset"),F(t+1=i)){var o=f(e,t,r,!0),a=32768&o;return a?-1*(65535-o+1):o}}function v(e,t,r,n){n||(F("boolean"==typeof r,"missing or invalid endian"),F(void 0!==t&&null!==t,"missing offset"),F(t+3=i)){var o=g(e,t,r,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function S(e,t,r,n){return n||(F("boolean"==typeof r,"missing or invalid endian"),F(t+3=o))for(var a=0,s=Math.min(o-r,2);s>a;a++)e[r+a]=(t&255<<8*(n?a:1-a))>>>8*(n?a:1-a)}function C(e,t,r,n,i){i||(F(void 0!==t&&null!==t,"missing value"),F("boolean"==typeof n,"missing or invalid endian"),F(void 0!==r&&null!==r,"missing offset"),F(r+3=o))for(var a=0,s=Math.min(o-r,4);s>a;a++)e[r+a]=t>>>8*(n?a:3-a)&255}function E(e,t,r,n,i){i||(F(void 0!==t&&null!==t,"missing value"),F("boolean"==typeof n,"missing or invalid endian"),F(void 0!==r&&null!==r,"missing offset"),F(r+1=o||(t>=0?I(e,t,r,n,i):I(e,65535+t+1,r,n,i))}function x(e,t,r,n,i){i||(F(void 0!==t&&null!==t,"missing value"),F("boolean"==typeof n,"missing or invalid endian"),F(void 0!==r&&null!==r,"missing offset"),F(r+3=o||(t>=0?C(e,t,r,n,i):C(e,4294967295+t+1,r,n,i))}function k(e,t,r,n,i){i||(F(void 0!==t&&null!==t,"missing value"),F("boolean"==typeof n,"missing or invalid endian"),F(void 0!==r&&null!==r,"missing offset"),F(r+3=o||H.write(e,t,r,n,23,4)}function q(e,t,r,n,i){i||(F(void 0!==t&&null!==t,"missing value"),F("boolean"==typeof n,"missing or invalid endian"),F(void 0!==r&&null!==r,"missing offset"),F(r+7=o||H.write(e,t,r,n,52,8)}function A(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function w(e,t,r){return"number"!=typeof e?r:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function T(e){return e=~~Math.ceil(+e),0>e?0:e}function R(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function P(e){return R(e)||n.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function M(e){return 16>e?"0"+e.toString(16):e.toString(16)}function B(e){for(var t=[],r=0;r=n)t.push(e.charCodeAt(r));else{var i=r;n>=55296&&57343>=n&&r++;for(var o=encodeURIComponent(e.slice(i,r+1)).substr(1).split("%"),a=0;a>8,n=t%256,i.push(n),i.push(r);return i}function U(e){return V.toByteArray(e)}function _(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function O(e,t){F("number"==typeof e,"cannot write a non-number as a number"),F(e>=0,"specified a negative value for writing an unsigned value"),F(t>=e,"value is larger than maximum value for type"),F(Math.floor(e)===e,"value has a fractional component")}function K(e,t,r){F("number"==typeof e,"cannot write a non-number as a number"),F(t>=e,"value larger than maximum allowed value"),F(e>=r,"value smaller than minimum allowed value"),F(Math.floor(e)===e,"value has a fractional component")}function j(e,t,r){F("number"==typeof e,"cannot write a non-number as a number"),F(t>=e,"value larger than maximum allowed value"),F(e>=r,"value smaller than minimum allowed value")}function F(e,t){if(!e)throw new Error(t||"Failed assertion")}var V=e("base64-js"),H=e("ieee754");r.Buffer=n,r.SlowBuffer=n,r.INSPECT_MAX_BYTES=50,n.poolSize=8192,n._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(r){return!1}}(),n.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.isBuffer=function(e){return!(null===e||void 0===e||!e._isBuffer)},n.byteLength=function(e,t){var r;switch(e+="",t||"utf8"){case"hex":r=e.length/2;break;case"utf8":case"utf-8":r=B(e).length;break;case"ascii":case"binary":case"raw":r=e.length;break;case"base64":r=U(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*e.length;break;default:throw new Error("Unknown encoding")}return r},n.concat=function(e,t){if(F(R(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new n(0);if(1===e.length)return e[0];var r;if("number"!=typeof t)for(t=0,r=0;rl&&(r=l)):r=l,n=String(n||"utf8").toLowerCase();var m;switch(n){case"hex":m=i(this,e,t,r);break;case"utf8":case"utf-8":m=o(this,e,t,r);break;case"ascii":m=a(this,e,t,r);break;case"binary":m=s(this,e,t,r);break;case"base64":m=u(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":m=c(this,e,t,r);break;default:throw new Error("Unknown encoding")}return m},n.prototype.toString=function(e,t,r){var n=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,r=void 0!==r?Number(r):r=n.length,r===t)return"";var i;switch(e){case"hex":i=h(n,t,r);break;case"utf8":case"utf-8":i=l(n,t,r);break;case"ascii":i=m(n,t,r);break;case"binary":i=d(n,t,r);break;case"base64":i=p(n,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=y(n,t,r);break;default:throw new Error("Unknown encoding")}return i},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.copy=function(e,t,r,i){var o=this;if(r||(r=0),i||0===i||(i=this.length),t||(t=0),i!==r&&0!==e.length&&0!==o.length){F(i>=r,"sourceEnd < sourceStart"),F(t>=0&&t=0&&r=0&&i<=o.length,"sourceEnd out of bounds"),i>this.length&&(i=this.length),e.length-ta||!n._useTypedArrays)for(var s=0;a>s;s++)e[s+t]=this[s+r];else e._set(this.subarray(r,r+a),t)}},n.prototype.slice=function(e,t){var r=this.length;if(e=w(e,r,0),t=w(t,r,r),n._useTypedArrays)return n._augment(this.subarray(e,t));for(var i=t-e,o=new n(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+e];return o},n.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},n.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},n.prototype.readUInt8=function(e,t){return t||(F(void 0!==e&&null!==e,"missing offset"),F(e=this.length?void 0:this[e]},n.prototype.readUInt16LE=function(e,t){return f(this,e,!0,t)},n.prototype.readUInt16BE=function(e,t){return f(this,e,!1,t)},n.prototype.readUInt32LE=function(e,t){return g(this,e,!0,t)},n.prototype.readUInt32BE=function(e,t){return g(this,e,!1,t)},n.prototype.readInt8=function(e,t){if(t||(F(void 0!==e&&null!==e,"missing offset"),F(e=this.length)){var r=128&this[e];return r?-1*(255-this[e]+1):this[e]}},n.prototype.readInt16LE=function(e,t){return b(this,e,!0,t)},n.prototype.readInt16BE=function(e,t){return b(this,e,!1,t)},n.prototype.readInt32LE=function(e,t){return v(this,e,!0,t)},n.prototype.readInt32BE=function(e,t){return v(this,e,!1,t)},n.prototype.readFloatLE=function(e,t){return S(this,e,!0,t)},n.prototype.readFloatBE=function(e,t){return S(this,e,!1,t)},n.prototype.readDoubleLE=function(e,t){return N(this,e,!0,t)},n.prototype.readDoubleBE=function(e,t){return N(this,e,!1,t)},n.prototype.writeUInt8=function(e,t,r){r||(F(void 0!==e&&null!==e,"missing value"),F(void 0!==t&&null!==t,"missing offset"),F(t=this.length||(this[t]=e)},n.prototype.writeUInt16LE=function(e,t,r){I(this,e,t,!0,r)},n.prototype.writeUInt16BE=function(e,t,r){I(this,e,t,!1,r)},n.prototype.writeUInt32LE=function(e,t,r){C(this,e,t,!0,r)},n.prototype.writeUInt32BE=function(e,t,r){C(this,e,t,!1,r)},n.prototype.writeInt8=function(e,t,r){r||(F(void 0!==e&&null!==e,"missing value"),F(void 0!==t&&null!==t,"missing offset"),F(t=this.length||(e>=0?this.writeUInt8(e,t,r):this.writeUInt8(255+e+1,t,r))},n.prototype.writeInt16LE=function(e,t,r){E(this,e,t,!0,r)},n.prototype.writeInt16BE=function(e,t,r){E(this,e,t,!1,r)},n.prototype.writeInt32LE=function(e,t,r){x(this,e,t,!0,r)},n.prototype.writeInt32BE=function(e,t,r){x(this,e,t,!1,r)},n.prototype.writeFloatLE=function(e,t,r){k(this,e,t,!0,r)},n.prototype.writeFloatBE=function(e,t,r){k(this,e,t,!1,r)},n.prototype.writeDoubleLE=function(e,t,r){q(this,e,t,!0,r)},n.prototype.writeDoubleBE=function(e,t,r){q(this,e,t,!1,r)},n.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),"string"==typeof e&&(e=e.charCodeAt(0)),F("number"==typeof e&&!isNaN(e),"value is not a number"),F(r>=t,"end < start"),r!==t&&0!==this.length){F(t>=0&&t=0&&r<=this.length,"end out of bounds");for(var n=t;r>n;n++)this[n]=e}},n.prototype.inspect=function(){for(var e=[],t=this.length,n=0;t>n;n++)if(e[n]=M(this[n]),n===r.INSPECT_MAX_BYTES){e[n+1]="...";break}return""},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n._useTypedArrays)return new n(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var W=n.prototype;n._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=W.get,e.set=W.set,e.write=W.write,e.toString=W.toString,e.toLocaleString=W.toString,e.toJSON=W.toJSON,e.copy=W.copy,e.slice=W.slice,e.readUInt8=W.readUInt8,e.readUInt16LE=W.readUInt16LE,e.readUInt16BE=W.readUInt16BE,e.readUInt32LE=W.readUInt32LE,e.readUInt32BE=W.readUInt32BE,e.readInt8=W.readInt8,e.readInt16LE=W.readInt16LE,e.readInt16BE=W.readInt16BE,e.readInt32LE=W.readInt32LE,e.readInt32BE=W.readInt32BE,e.readFloatLE=W.readFloatLE,e.readFloatBE=W.readFloatBE,e.readDoubleLE=W.readDoubleLE,e.readDoubleBE=W.readDoubleBE,e.writeUInt8=W.writeUInt8,e.writeUInt16LE=W.writeUInt16LE,e.writeUInt16BE=W.writeUInt16BE,e.writeUInt32LE=W.writeUInt32LE,e.writeUInt32BE=W.writeUInt32BE,e.writeInt8=W.writeInt8,e.writeInt16LE=W.writeInt16LE,e.writeInt16BE=W.writeInt16BE,e.writeInt32LE=W.writeInt32LE,e.writeInt32BE=W.writeInt32BE,e.writeFloatLE=W.writeFloatLE,e.writeFloatBE=W.writeFloatBE,e.writeDoubleLE=W.writeDoubleLE,e.writeDoubleBE=W.writeDoubleBE,e.fill=W.fill,e.inspect=W.inspect,e.toArrayBuffer=W.toArrayBuffer,e}},{"base64-js":53,ieee754:54}],53:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===a||t===l?62:t===s||t===m?63:u>t?-1:u+10>t?t-u+26+26:p+26>t?t-p:c+26>t?t-c+26:void 0}function r(e){function r(e){c[l++]=e}var n,i,a,s,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=e.length;u="="===e.charAt(p-2)?2:"="===e.charAt(p-1)?1:0,c=new o(3*e.length/4-u),a=u>0?e.length-4:e.length;var l=0;for(n=0,i=0;a>n;n+=4,i+=3)s=t(e.charAt(n))<<18|t(e.charAt(n+1))<<12|t(e.charAt(n+2))<<6|t(e.charAt(n+3)),r((16711680&s)>>16),r((65280&s)>>8),r(255&s);return 2===u?(s=t(e.charAt(n))<<2|t(e.charAt(n+1))>>4,r(255&s)):1===u&&(s=t(e.charAt(n))<<10|t(e.charAt(n+1))<<4|t(e.charAt(n+2))>>2,r(s>>8&255),r(255&s)),c}function i(e){function t(e){return n.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,a,s=e.length%3,u="";for(i=0,a=e.length-s;a>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=r(o);switch(s){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),s="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),p="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],54:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,p=-7,l=r?i-1:0,m=r?-1:1,d=e[t+l];for(l+=m,o=d&(1<<-p)-1,d>>=-p,p+=s;p>0;o=256*o+e[t+l],l+=m,p-=8);for(a=o&(1<<-p)-1,o>>=-p,p+=n;p>0;a=256*a+e[t+l],l+=m,p-=8);if(0===o)o=1-c;else{if(o===u)return a?0/0:1/0*(d?-1:1);a+=Math.pow(2,n),o-=c}return(d?-1:1)*a*Math.pow(2,o-n)},r.write=function(e,t,r,n,i,o){var a,s,u,c=8*o-i-1,p=(1<>1,m=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,h=n?1:-1,y=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(s=isNaN(t)?1:0,a=p):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),t+=a+l>=1?m/u:m*Math.pow(2,1-l),t*u>=2&&(a++,u/=2),a+l>=p?(s=0,a=p):a+l>=1?(s=(t*u-1)*Math.pow(2,i),a+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=h,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=h,a/=256,c-=8);e[r+d-h]|=128*y}},{}],55:[function(e,t){function r(e,t){if(e.length%a!==0){var r=e.length+(a-e.length%a);e=o.concat([e,s],r)}for(var n=[],i=t?e.readInt32BE:e.readInt32LE,u=0;ud?t=e(t):t.lengtho;o++)n[o]=54^t[o],i[o]=92^t[o];var a=e(s.concat([n,r]));return e(s.concat([i,a]))}function i(e,t){e=e||"sha1";var r=m[e],i=[],a=0;return r||o("algorithm:",e,"is not yet supported"),{update:function(e){return s.isBuffer(e)||(e=new s(e)),i.push(e),a+=e.length,this},digest:function(e){var o=s.concat(i),a=t?n(r,t,o):r(o);return i=null,e?a.toString(e):a}}}function o(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function a(e,t){for(var r in e)t(e[r],r)}var s=e("buffer").Buffer,u=e("./sha"),c=e("./sha256"),p=e("./rng"),l=e("./md5"),m={sha1:u,sha256:c,md5:l},d=64,h=new s(d);h.fill(0),r.createHash=function(e){return i(e)},r.createHmac=function(e,t){return i(e,t)},r.randomBytes=function(e,t){if(!t||!t.call)return new s(p(e));try{t.call(this,void 0,new s(p(e)))}catch(r){t(r)}},a(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(e){r[e]=function(){o("sorry,",e,"is not implemented yet")}})},{"./md5":57,"./rng":58,"./sha":59,"./sha256":60,buffer:52}],57:[function(e,t){function r(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,c=-1732584194,p=271733878,l=0;l>16)+(t>>16)+(r>>16);return n<<16|65535&r}function c(e,t){return e<>>32-t}var p=e("./helpers");t.exports=function(e){return p.hash(e,r,16)}},{"./helpers":55}],58:[function(e,t){!function(){var e,r,n=this;e=function(e){for(var t,t,r=new Array(e),n=0;e>n;n++)0==(3&n)&&(t=4294967296*Math.random()),r[n]=t>>>((3&n)<<3)&255;return r},n.crypto&&crypto.getRandomValues&&(r=function(e){var t=new Uint8Array(e);return crypto.getRandomValues(t),t}),t.exports=r||e}()},{}],59:[function(e,t){function r(e,t){e[t>>5]|=128<<24-t%32,e[(t+64>>9<<4)+15]=t;for(var r=Array(80),s=1732584193,u=-271733879,c=-1732584194,p=271733878,l=-1009589776,m=0;mb;b++){r[b]=16>b?e[m+b]:a(r[b-3]^r[b-8]^r[b-14]^r[b-16],1);var v=o(o(a(s,5),n(b,u,c,p)),o(o(l,r[b]),i(b)));l=p,p=c,c=a(u,30),u=s,s=v}s=o(s,d),u=o(u,h),c=o(c,y),p=o(p,f),l=o(l,g)}return Array(s,u,c,p,l)}function n(e,t,r,n){return 20>e?t&r|~t&n:40>e?t^r^n:60>e?t&r|t&n|r&n:t^r^n}function i(e){return 20>e?1518500249:40>e?1859775393:60>e?-1894007588:-899497514}function o(e,t){var r=(65535&e)+(65535&t),n=(e>>16)+(t>>16)+(r>>16);return n<<16|65535&r}function a(e,t){return e<>>32-t}var s=e("./helpers");t.exports=function(e){return s.hash(e,r,20,!0)}},{"./helpers":55}],60:[function(e,t){var r=e("./helpers"),n=function(e,t){var r=(65535&e)+(65535&t),n=(e>>16)+(t>>16)+(r>>16);return n<<16|65535&r},i=function(e,t){return e>>>t|e<<32-t},o=function(e,t){return e>>>t},a=function(e,t,r){return e&t^~e&r},s=function(e,t,r){return e&t^e&r^t&r},u=function(e){return i(e,2)^i(e,13)^i(e,22)},c=function(e){return i(e,6)^i(e,11)^i(e,25)},p=function(e){return i(e,7)^i(e,18)^o(e,3)},l=function(e){return i(e,17)^i(e,19)^o(e,10)},m=function(e,t){var r,i,o,m,d,h,y,f,g,b,v,S,N=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),I=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),C=new Array(64);e[t>>5]|=128<<24-t%32,e[(t+64>>9<<4)+15]=t;for(var g=0;gb;b++)C[b]=16>b?e[b+g]:n(n(n(l(C[b-2]),C[b-7]),p(C[b-15])),C[b-16]),v=n(n(n(n(f,c(d)),a(d,h,y)),N[b]),C[b]),S=n(u(r),s(r,i,o)),f=y,y=h,h=d,d=n(m,v),m=o,o=i,i=r,r=n(v,S);I[0]=n(r,I[0]),I[1]=n(i,I[1]),I[2]=n(o,I[2]),I[3]=n(m,I[3]),I[4]=n(d,I[4]),I[5]=n(h,I[5]),I[6]=n(y,I[6]),I[7]=n(f,I[7])}return I};t.exports=function(e){return r.hash(e,m,32,!0)}},{"./helpers":55}],61:[function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,i,s,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[e],a(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,s=new Array(i-1),u=1;i>u;u++)s[u-1]=arguments[u];r.apply(this,s)}else if(o(r)){for(i=arguments.length,s=new Array(i-1),u=1;i>u;u++)s[u-1]=arguments[u];for(c=r.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,s) }return!0},r.prototype.addListener=function(e,t){var i;if(!n(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),i||(i=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var i=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,i,a,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,i=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(s=a;s-->0;)if(r[s]===t||r[s].listener&&r[s].listener===t){i=s;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.listenerCount=function(e,t){var r;return r=e._events&&e._events[t]?n(e._events[t])?1:e._events[t].length:0}},{}],62:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],63:[function(e,t){function r(){}var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var r=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=r,n.addListener=r,n.once=r,n.off=r,n.removeListener=r,n.removeAllListeners=r,n.emit=r,n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],64:[function(e,t,r){(function(e){!function(n){function i(e){throw RangeError(M[e])}function o(e,t){for(var r=e.length;r--;)e[r]=t(e[r]);return e}function a(e,t){return o(e.split(P),t).join(".")}function s(e){for(var t,r,n=[],i=0,o=e.length;o>i;)t=e.charCodeAt(i++),t>=55296&&56319>=t&&o>i?(r=e.charCodeAt(i++),56320==(64512&r)?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),i--)):n.push(t);return n}function u(e){return o(e,function(e){var t="";return e>65535&&(e-=65536,t+=D(e>>>10&1023|55296),e=56320|1023&e),t+=D(e)}).join("")}function c(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:I}function p(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function l(e,t,r){var n=0;for(e=r?L(e/k):e>>1,e+=L(e/t);e>B*E>>1;n+=I)e=L(e/B);return L(n+(B+1)*e/(e+x))}function m(e){var t,r,n,o,a,s,p,m,d,h,y=[],f=e.length,g=0,b=A,v=q;for(r=e.lastIndexOf(w),0>r&&(r=0),n=0;r>n;++n)e.charCodeAt(n)>=128&&i("not-basic"),y.push(e.charCodeAt(n));for(o=r>0?r+1:0;f>o;){for(a=g,s=1,p=I;o>=f&&i("invalid-input"),m=c(e.charCodeAt(o++)),(m>=I||m>L((N-g)/s))&&i("overflow"),g+=m*s,d=v>=p?C:p>=v+E?E:p-v,!(d>m);p+=I)h=I-d,s>L(N/h)&&i("overflow"),s*=h;t=y.length+1,v=l(g-a,t,0==a),L(g/t)>N-b&&i("overflow"),b+=L(g/t),g%=t,y.splice(g++,0,b)}return u(y)}function d(e){var t,r,n,o,a,u,c,m,d,h,y,f,g,b,v,S=[];for(e=s(e),f=e.length,t=A,r=0,a=q,u=0;f>u;++u)y=e[u],128>y&&S.push(D(y));for(n=o=S.length,o&&S.push(w);f>n;){for(c=N,u=0;f>u;++u)y=e[u],y>=t&&c>y&&(c=y);for(g=n+1,c-t>L((N-r)/g)&&i("overflow"),r+=(c-t)*g,t=c,u=0;f>u;++u)if(y=e[u],t>y&&++r>N&&i("overflow"),y==t){for(m=r,d=I;h=a>=d?C:d>=a+E?E:d-a,!(h>m);d+=I)v=m-h,b=I-h,S.push(D(p(h+v%b,0))),m=L(v/b);S.push(D(p(m,0))),a=l(r,g,n==o),r=0,++n}++r,++t}return S.join("")}function h(e){return a(e,function(e){return T.test(e)?m(e.slice(4).toLowerCase()):e})}function y(e){return a(e,function(e){return R.test(e)?"xn--"+d(e):e})}var f="object"==typeof r&&r,g="object"==typeof t&&t&&t.exports==f&&t,b="object"==typeof e&&e;(b.global===b||b.window===b)&&(n=b);var v,S,N=2147483647,I=36,C=1,E=26,x=38,k=700,q=72,A=128,w="-",T=/^xn--/,R=/[^ -~]/,P=/\x2E|\u3002|\uFF0E|\uFF61/g,M={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},B=I-C,L=Math.floor,D=String.fromCharCode;if(v={version:"1.2.4",ucs2:{decode:s,encode:u},decode:m,encode:d,toASCII:y,toUnicode:h},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return v});else if(f&&!f.nodeType)if(g)g.exports=v;else for(S in v)v.hasOwnProperty(S)&&(f[S]=v[S]);else n.punycode=v}(this)}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],65:[function(e,t){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,i,o){t=t||"&",i=i||"=";var a={};if("string"!=typeof e||0===e.length)return a;var s=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var p=0;c>p;++p){var l,m,d,h,y=e[p].replace(s,"%20"),f=y.indexOf(i);f>=0?(l=y.substr(0,f),m=y.substr(f+1)):(l=y,m=""),d=decodeURIComponent(l),h=decodeURIComponent(m),r(a,d)?n(a[d])?a[d].push(h):a[d]=[a[d],h]:a[d]=h}return a};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],66:[function(e,t){"use strict";function r(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n",'"',"`"," ","\r","\n"," "],f=["{","}","|","\\","^","`"].concat(y),g=["'"].concat(f),b=["%","/","?",";","#"].concat(g),v=["/","?","#"],S=255,N=/^[a-z0-9A-Z_-]{0,63}$/,I=/^([a-z0-9A-Z_-]{0,63})(.*)$/,C={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},k=e("querystring");n.prototype.parse=function(e,t,r){if(!u(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var n=e;n=n.trim();var i=d.exec(n);if(i){i=i[0];var o=i.toLowerCase();this.protocol=o,n=n.substr(i.length)}if(r||i||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===n.substr(0,2);!a||i&&E[i]||(n=n.substr(2),this.slashes=!0)}if(!E[i]&&(a||i&&!x[i])){for(var s=-1,c=0;cp)&&(s=p)}var l,h;h=-1===s?n.lastIndexOf("@"):n.lastIndexOf("@",s),-1!==h&&(l=n.slice(0,h),n=n.slice(h+1),this.auth=decodeURIComponent(l)),s=-1;for(var c=0;cp)&&(s=p)}-1===s&&(s=n.length),this.host=n.slice(0,s),n=n.slice(s),this.parseHost(),this.hostname=this.hostname||"";var y="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!y)for(var f=this.hostname.split(/\./),c=0,q=f.length;q>c;c++){var A=f[c];if(A&&!A.match(N)){for(var w="",T=0,R=A.length;R>T;T++)w+=A.charCodeAt(T)>127?"x":A[T];if(!w.match(N)){var P=f.slice(0,c),M=f.slice(c+1),B=A.match(I);B&&(P.push(B[1]),M.unshift(B[2])),M.length&&(n="/"+M.join(".")+n),this.hostname=P.join(".");break}}}if(this.hostname=this.hostname.length>S?"":this.hostname.toLowerCase(),!y){for(var L=this.hostname.split("."),D=[],c=0;cc;c++){var O=g[c],K=encodeURIComponent(O);K===O&&(K=escape(O)),n=n.split(O).join(K)}var j=n.indexOf("#");-1!==j&&(this.hash=n.substr(j),n=n.slice(0,j));var F=n.indexOf("?");if(-1!==F?(this.search=n.substr(F),this.query=n.substr(F+1),t&&(this.query=k.parse(this.query)),n=n.slice(0,F)):t&&(this.search="",this.query={}),n&&(this.pathname=n),x[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var _=this.pathname||"",U=this.search||"";this.path=_+U}return this.href=this.format(),this},n.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&c(this.query)&&Object.keys(this.query).length&&(o=k.stringify(this.query));var a=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&i!==!1?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),a=a.replace("#","%23"),t+i+r+a+n},n.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},n.prototype.resolveObject=function(e){if(u(e)){var t=new n;t.parse(e,!1,!0),e=t}var r=new n;if(Object.keys(this).forEach(function(e){r[e]=this[e]},this),r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol)return Object.keys(e).forEach(function(t){"protocol"!==t&&(r[t]=e[t])}),x[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r;if(e.protocol&&e.protocol!==r.protocol){if(!x[e.protocol])return Object.keys(e).forEach(function(t){r[t]=e[t]}),r.href=r.format(),r;if(r.protocol=e.protocol,e.host||E[e.protocol])r.pathname=e.pathname;else{for(var i=(e.pathname||"").split("/");i.length&&!(e.host=i.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==i[0]&&i.unshift(""),i.length<2&&i.unshift(""),r.pathname=i.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var o=r.pathname||"",a=r.search||"";r.path=o+a}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var s=r.pathname&&"/"===r.pathname.charAt(0),c=e.host||e.pathname&&"/"===e.pathname.charAt(0),m=c||s||r.host&&e.pathname,d=m,h=r.pathname&&r.pathname.split("/")||[],i=e.pathname&&e.pathname.split("/")||[],y=r.protocol&&!x[r.protocol];if(y&&(r.hostname="",r.port=null,r.host&&(""===h[0]?h[0]=r.host:h.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===i[0]?i[0]=e.host:i.unshift(e.host)),e.host=null),m=m&&(""===i[0]||""===h[0])),c)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,h=i;else if(i.length)h||(h=[]),h.pop(),h=h.concat(i),r.search=e.search,r.query=e.query;else if(!l(e.search)){if(y){r.hostname=r.host=h.shift();var f=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;f&&(r.auth=f.shift(),r.host=r.hostname=f.shift())}return r.search=e.search,r.query=e.query,p(r.pathname)&&p(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!h.length)return r.pathname=null,r.path=r.search?"/"+r.search:null,r.href=r.format(),r;for(var g=h.slice(-1)[0],b=(r.host||e.host)&&("."===g||".."===g)||""===g,v=0,S=h.length;S>=0;S--)g=h[S],"."==g?h.splice(S,1):".."===g?(h.splice(S,1),v++):v&&(h.splice(S,1),v--);if(!m&&!d)for(;v--;v)h.unshift("..");!m||""===h[0]||h[0]&&"/"===h[0].charAt(0)||h.unshift(""),b&&"/"!==h.join("/").substr(-1)&&h.push("");var N=""===h[0]||h[0]&&"/"===h[0].charAt(0);if(y){r.hostname=r.host=N?"":h.length?h.shift():"";var f=r.host&&r.host.indexOf("@")>0?r.host.split("@"):!1;f&&(r.auth=f.shift(),r.host=r.hostname=f.shift())}return m=m||r.host&&h.length,m&&!N&&h.unshift(""),h.length?r.pathname=h.join("/"):(r.pathname=null,r.path=null),p(r.pathname)&&p(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var e=this.host,t=h.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{punycode:64,querystring:67}],69:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],70:[function(e,t,r){(function(t,n){function i(e,t){var n={seen:[],stylize:a};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),y(t)?n.showHidden=t:t&&r._extend(n,t),N(n.showHidden)&&(n.showHidden=!1),N(n.depth)&&(n.depth=2),N(n.colors)&&(n.colors=!1),N(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,e,n.depth)}function o(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function a(e){return e}function s(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,n){if(e.customInspect&&t&&k(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(n,e);return v(i)||(i=u(e,i,n)),i}var o=c(e,t);if(o)return o;var a=Object.keys(t),y=s(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),x(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(t);if(0===a.length){if(k(t)){var f=t.name?": "+t.name:"";return e.stylize("[Function"+f+"]","special")}if(I(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(x(t))return p(t)}var g="",b=!1,S=["{","}"];if(h(t)&&(b=!0,S=["[","]"]),k(t)){var N=t.name?": "+t.name:"";g=" [Function"+N+"]"}if(I(t)&&(g=" "+RegExp.prototype.toString.call(t)),E(t)&&(g=" "+Date.prototype.toUTCString.call(t)),x(t)&&(g=" "+p(t)),0===a.length&&(!b||0==t.length))return S[0]+g+S[1];if(0>n)return I(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var C;return C=b?l(e,t,n,y,a):a.map(function(r){return m(e,t,n,y,r,b)}),e.seen.pop(),d(C,g,S)}function c(e,t){if(N(t))return e.stylize("undefined","undefined");if(v(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return b(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):f(t)?e.stylize("null","null"):void 0}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i){for(var o=[],a=0,s=t.length;s>a;++a)o.push(R(t,String(a))?m(e,t,r,n,String(a),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(m(e,t,r,n,i,!0))}),o}function m(e,t,r,n,i,o){var a,s,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),R(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(s=f(r)?u(e,c.value,null):u(e,c.value,r-1),s.indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),N(a)){if(o&&i.match(/^\d+$/))return s;a=JSON.stringify(""+i),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function h(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function f(e){return null===e}function g(e){return null==e}function b(e){return"number"==typeof e}function v(e){return"string"==typeof e}function S(e){return"symbol"==typeof e}function N(e){return void 0===e}function I(e){return C(e)&&"[object RegExp]"===A(e)}function C(e){return"object"==typeof e&&null!==e}function E(e){return C(e)&&"[object Date]"===A(e)}function x(e){return C(e)&&("[object Error]"===A(e)||e instanceof Error)}function k(e){return"function"==typeof e}function q(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function A(e){return Object.prototype.toString.call(e)}function w(e){return 10>e?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[w(e.getHours()),w(e.getMinutes()),w(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var P=/%[sdj%]/g;r.format=function(e){if(!v(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}}),s=n[r];o>r;s=n[++r])a+=f(s)||!C(s)?" "+s:" "+i(s);return a},r.deprecate=function(e,i){function o(){if(!a){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),a=!0}return e.apply(this,arguments)}if(N(n.process))return function(){return r.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var a=!1;return o};var M,B={};r.debuglog=function(e){if(N(M)&&(M=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!B[e])if(new RegExp("\\b"+e+"\\b","i").test(M)){var n=t.pid;B[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else B[e]=function(){};return B[e]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=h,r.isBoolean=y,r.isNull=f,r.isNullOrUndefined=g,r.isNumber=b,r.isString=v,r.isSymbol=S,r.isUndefined=N,r.isRegExp=I,r.isObject=C,r.isDate=E,r.isError=x,r.isFunction=k,r.isPrimitive=q,r.isBuffer=e("./support/isBuffer");var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",T(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!C(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(this,e("FWaASH"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":69,FWaASH:63,inherits:62}],71:[function(e,t){(function(){var r,n;n=e("./XMLFragment"),r=function(){function e(e,t,r){var i,o,a;if(this.children=[],this.rootObject=null,this.is(e,"Object")&&(a=[e,t],t=a[0],r=a[1],e=null),null!=e&&(e=""+e||"",null==t&&(t={version:"1.0"})),null!=t&&null==t.version)throw new Error("Version number is required");if(null!=t){if(t.version=""+t.version||"",!t.version.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+t.version);if(i={version:t.version},null!=t.encoding){if(t.encoding=""+t.encoding||"",!t.encoding.match(/[A-Za-z](?:[A-Za-z0-9._-]|-)*/))throw new Error("Invalid encoding: "+t.encoding);i.encoding=t.encoding}null!=t.standalone&&(i.standalone=t.standalone?"yes":"no"),o=new n(this,"?xml",i),this.children.push(o)}null!=r&&(i={},null!=e&&(i.name=e),null!=r.ext&&(r.ext=""+r.ext||"",i.ext=r.ext),o=new n(this,"!DOCTYPE",i),this.children.push(o)),null!=e&&this.begin(e)}return e.prototype.begin=function(t,r,i){var o,a;if(null==t)throw new Error("Root element needs a name");return this.rootObject&&(this.children=[],this.rootObject=null),null!=r?(o=new e(t,r,i),o.root()):(t=""+t||"",a=new n(this,t,{}),a.isRoot=!0,a.documentObject=this,this.children.push(a),this.rootObject=a,a)},e.prototype.root=function(){return this.rootObject},e.prototype.end=function(e){return toString(e)},e.prototype.toString=function(e){var t,r,n,i,o;for(r="",o=this.children,n=0,i=o.length;i>n;n++)t=o[n],r+=t.toString(e);return r},e.prototype.is=function(e,t){var r;return r=Object.prototype.toString.call(e).slice(8,-1),null!=e&&r===t},e}(),t.exports=r}).call(this)},{"./XMLFragment":72}],72:[function(e,t){(function(){var e,r={}.hasOwnProperty;e=function(){function e(e,t,r,n){this.isRoot=!1,this.documentObject=null,this.parent=e,this.name=t,this.attributes=r,this.value=n,this.children=[]}return e.prototype.element=function(t,n,i){var o,a,s,u,c;if(null==t)throw new Error("Missing element name");t=""+t||"",this.assertLegalChar(t),null==n&&(n={}),this.is(n,"String")&&this.is(i,"Object")?(u=[i,n],n=u[0],i=u[1]):this.is(n,"String")&&(c=[{},n],n=c[0],i=c[1]);for(a in n)r.call(n,a)&&(s=n[a],s=""+s||"",n[a]=this.escape(s));return o=new e(this,t,n),null!=i&&(i=""+i||"",i=this.escape(i),this.assertLegalChar(i),o.raw(i)),this.children.push(o),o},e.prototype.insertBefore=function(t,n,i){var o,a,s,u,c,p;if(this.isRoot)throw new Error("Cannot insert elements at root level");if(null==t)throw new Error("Missing element name");t=""+t||"",this.assertLegalChar(t),null==n&&(n={}),this.is(n,"String")&&this.is(i,"Object")?(c=[i,n],n=c[0],i=c[1]):this.is(n,"String")&&(p=[{},n],n=p[0],i=p[1]);for(s in n)r.call(n,s)&&(u=n[s],u=""+u||"",n[s]=this.escape(u));return o=new e(this.parent,t,n),null!=i&&(i=""+i||"",i=this.escape(i),this.assertLegalChar(i),o.raw(i)),a=this.parent.children.indexOf(this),this.parent.children.splice(a,0,o),o},e.prototype.insertAfter=function(t,n,i){var o,a,s,u,c,p;if(this.isRoot)throw new Error("Cannot insert elements at root level");if(null==t)throw new Error("Missing element name");t=""+t||"",this.assertLegalChar(t),null==n&&(n={}),this.is(n,"String")&&this.is(i,"Object")?(c=[i,n],n=c[0],i=c[1]):this.is(n,"String")&&(p=[{},n],n=p[0],i=p[1]);for(s in n)r.call(n,s)&&(u=n[s],u=""+u||"",n[s]=this.escape(u));return o=new e(this.parent,t,n),null!=i&&(i=""+i||"",i=this.escape(i),this.assertLegalChar(i),o.raw(i)),a=this.parent.children.indexOf(this),this.parent.children.splice(a+1,0,o),o},e.prototype.remove=function(){var e,t;if(this.isRoot)throw new Error("Cannot remove the root element");return e=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[e,e-e+1].concat(t=[])),t,this.parent},e.prototype.text=function(t){var r;if(null==t)throw new Error("Missing element text");return t=""+t||"",t=this.escape(t),this.assertLegalChar(t),r=new e(this,"",{},t),this.children.push(r),this},e.prototype.cdata=function(t){var r;if(null==t)throw new Error("Missing CDATA text");if(t=""+t||"",this.assertLegalChar(t),t.match(/]]>/))throw new Error("Invalid CDATA text: "+t);return r=new e(this,"",{},""),this.children.push(r),this},e.prototype.comment=function(t){var r;if(null==t)throw new Error("Missing comment text");if(t=""+t||"",t=this.escape(t),this.assertLegalChar(t),t.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+t);return r=new e(this,"",{},""),this.children.push(r),this},e.prototype.raw=function(t){var r;if(null==t)throw new Error("Missing raw text");return t=""+t||"",r=new e(this,"",{},t),this.children.push(r),this},e.prototype.up=function(){if(this.isRoot)throw new Error("This node has no parent. Use doc() if you need to get the document object.");return this.parent},e.prototype.root=function(){var e;if(this.isRoot)return this;for(e=this.parent;!e.isRoot;)e=e.parent;return e},e.prototype.document=function(){return this.root().documentObject},e.prototype.end=function(e){return this.document().toString(e)},e.prototype.prev=function(){var e;if(this.isRoot)throw new Error("Root node has no siblings");if(e=this.parent.children.indexOf(this),1>e)throw new Error("Already at the first node");return this.parent.children[e-1]},e.prototype.next=function(){var e;if(this.isRoot)throw new Error("Root node has no siblings");if(e=this.parent.children.indexOf(this),-1===e||e===this.parent.children.length-1)throw new Error("Already at the last node");return this.parent.children[e+1]},e.prototype.clone=function(t){var r;return r=new e(this.parent,this.name,this.attributes,this.value),t&&this.children.forEach(function(e){var n;return n=e.clone(t),n.parent=r,r.children.push(n)}),r},e.prototype.importXMLBuilder=function(e){var t;return t=e.root().clone(!0),t.parent=this,this.children.push(t),t.isRoot=!1,this},e.prototype.attribute=function(e,t){var r;if(null==e)throw new Error("Missing attribute name");if(null==t)throw new Error("Missing attribute value");return e=""+e||"",t=""+t||"",null==(r=this.attributes)&&(this.attributes={}),this.attributes[e]=this.escape(t),this},e.prototype.removeAttribute=function(e){if(null==e)throw new Error("Missing attribute name");return e=""+e||"",delete this.attributes[e],this},e.prototype.toString=function(e,t){var r,n,i,o,a,s,u,c,p,l,m,d;s=null!=e&&e.pretty||!1,o=null!=e&&e.indent||" ",a=null!=e&&e.newline||"\n",t||(t=0),c=new Array(t+1).join(o),u="",s&&(u+=c),u+=null==this.value?"<"+this.name:""+this.value,m=this.attributes;for(r in m)n=m[r],u+="!DOCTYPE"===this.name?" "+n:" "+r+'="'+n+'"';if(0===this.children.length)null==this.value&&(u+="?xml"===this.name?"?>":"!DOCTYPE"===this.name?">":"/>"),s&&(u+=a);else if(s&&1===this.children.length&&this.children[0].value)u+=">",u+=this.children[0].value,u+="",u+=a;else{for(u+=">",s&&(u+=a),d=this.children,p=0,l=d.length;l>p;p++)i=d[p],u+=i.toString(e,t+1);s&&(u+=c),u+="",s&&(u+=a)}return u},e.prototype.escape=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},e.prototype.assertLegalChar=function(e){var t,r;if(t=/[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/,r=e.match(t))throw new Error("Invalid character ("+r+") in string: "+e)},e.prototype.is=function(e,t){var r;return r=Object.prototype.toString.call(e).slice(8,-1),null!=e&&r===t},e.prototype.ele=function(e,t,r){return this.element(e,t,r)},e.prototype.txt=function(e){return this.text(e)},e.prototype.dat=function(e){return this.cdata(e)},e.prototype.att=function(e,t){return this.attribute(e,t)},e.prototype.com=function(e){return this.comment(e)},e.prototype.doc=function(){return this.document()},e.prototype.e=function(e,t,r){return this.element(e,t,r)},e.prototype.t=function(e){return this.text(e)},e.prototype.d=function(e){return this.cdata(e)},e.prototype.a=function(e,t){return this.attribute(e,t)},e.prototype.c=function(e){return this.comment(e)},e.prototype.r=function(e){return this.raw(e)},e.prototype.u=function(){return this.up()},e}(),t.exports=e}).call(this)},{}],73:[function(e,t){(function(){var r;r=e("./XMLBuilder"),t.exports.create=function(e,t,n){return null!=e?new r(e,t,n).root():new r}}).call(this)},{"./XMLBuilder":71}]},{},[1]);