diff --git a/Documentation.md b/Documentation.md index 26a0ca00..471bb524 100644 --- a/Documentation.md +++ b/Documentation.md @@ -27,18 +27,18 @@ Amazon Connect Streams API works. ### Upgrading to the Latest Version of the CCP (AKA /ccp-v2)? If you are migrating to the new CCP, we encourage you to upgrade to the latest version of this repository. You should also upgrade to [the latest version of RTC-JS](https://github.com/aws/connect-rtc-js) as well, if you are using it. For a complete migration guide to the new CCP, and to fully understand the differences when using Streams with the new CCP, please see this post: https://docs.aws.amazon.com/connect/latest/adminguide/upgrade-to-latest-ccp.html. Also see: https://docs.aws.amazon.com/connect/latest/adminguide/upgrade-ccp-streams-api.html. -### Whitelisting -The first step to using the Streams API is to whitelist the pages you wish to embed. +### Allowlisting +The first step to using the Streams API is to allowlist the pages you wish to embed. For our customer's security, we require that all domains which embed the CCP for -a particular instance are explicitly whitelisted. Each domain entry identifies +a particular instance are explicitly allowlisted. Each domain entry identifies the protocol scheme, host, and port. Any pages hosted behind the same protocol scheme, host, and port will be allowed to embed the CCP components which are required to use the Streams library. -To whitelist your pages: +To allowlist your pages: 1. Login to your AWS Account, then navigate to the Amazon Connect console. -2. Choose the instance alias of the instance to whitelist +2. Choose the instance alias of the instance to allowlist pages for to load the settings Overview page for your instance. 3. Choose "Application integration" link on the left. 4. Choose "+ Add Origin", then enter a domain URL, e.g. @@ -46,9 +46,9 @@ To whitelist your pages: website is hosted on a non-standard port. #### A few things to note: -* Whitelisted domains must be HTTPS. +* Allowlisted domains must be HTTPS. * All of the pages that attempt to initialize the Streams library must be hosted - on domains that are whitelisted as per the previous steps. + on domains that are allowlisted as per the previous steps. * All open tabs that contain an initialized Streams library or any other CCP tabs opened will be synchronized. This means that state changes made in one open window will be communicated to all open windows. @@ -244,20 +244,20 @@ connect.core.onViewContact(function(event) { // ... }); ``` -Subscribes a callback that executes whenever the currently selected contact on the CCP changes. +Subscribes a callback that starts whenever the currently selected contact on the CCP changes. The callback is called when the contact changes in the UI (i.e. via `click` events) or via `connect.core.viewContact()`. ### `connect.core.onAuthFail()` ```js connect.core.onAuthFail(function() { /* ... */ }); ``` -Subscribes a callback that executes whenever authentication fails (e.g. SAML authentication). +Subscribes a callback that starts whenever authentication fails (e.g. SAML authentication). ### `connect.core.onAccessDenied()` ```js connect.core.onAccessDenied(function() { /* ... */ }); ``` -Subscribes a callback that executes whenever authorization fails (i.e. access denied). +Subscribes a callback that starts whenever authorization fails (i.e. access denied). ### `connect.core.getWebSocketManager()` ```js @@ -643,7 +643,7 @@ Subscribe a method to be invoked when the contact is pending. This event is expe ```js contact.onConnecting(function(contact) { /* ... */ }); ``` -Subscribe a method to be invoked when the contact is connecting. This works with chat and softphone contacts. This event happens when a call or chat comes in, before accepting (there is an exception for queue callbacks, in which onConnecting's handler is executed after the callback is accepted). Note that once the contact has been accepted, the `onAccepted` handler will be triggered. +Subscribe a method to be invoked when the contact is connecting. This works with chat and softphone contacts. This event happens when a call or chat comes in, before accepting (there is an exception for queue callbacks, in which onConnecting's handler is started after the callback is accepted). Note that once the contact has been accepted, the `onAccepted` handler will be triggered. ### `contact.onAccepted()` ```js diff --git a/README.md b/README.md index 712d84f2..2d16317d 100644 --- a/README.md +++ b/README.md @@ -35,18 +35,18 @@ $ make ### Upgrading to the OmniChannel CCP (AKA CCPv2)? If you are migrating to the new CCP, we encourage you to upgrade to the latest version of this repository. You should also upgrade to [the latest version of RTC-JS](https://github.com/aws/connect-rtc-js) as well, if you are using it. For a complete migration guide to the new CCP, and to fully understand the differences when using Streams with the new CCP, please see this post: https://docs.aws.amazon.com/connect/latest/adminguide/upgrade-to-latest-ccp.html -### Whitelisting -The first step to using Streams is to whitelist the pages you wish to embed. +### Allowlisting +The first step to using Streams is to allowlist the pages you wish to embed. For our customer's security, we require that all domains which embed the CCP for -a particular instance are explicitly whitelisted. Each domain entry identifies +a particular instance are explicitly allowlisted. Each domain entry identifies the protocol scheme, host, and port. Any pages hosted behind the same protocol scheme, host, and port will be allowed to embed the CCP components which are required to use the Streams library. -To whitelist your pages: +To allowlist your pages: 1. Login to your AWS Account, then navigate to the Amazon Connect console. -2. Click the instance name of the instance for which you would like to whitelist +2. Click the instance name of the instance for which you would like to allowlist pages to load the settings page for your instance. 3. Click the "Application integration" link on the left. 4. Click "+ Add Origin", then enter a domain URL, e.g. @@ -54,9 +54,9 @@ To whitelist your pages: website is hosted on a non-standard port. #### A few things to note: -* Whitelisted domains must be HTTPS. +* Allowlisted domains must be HTTPS. * All of the pages that attempt to initialize the Streams library must be hosted - on domains that are whitelisted as per the above steps. + on domains that are allowlisted as per the above steps. * All open tabs that contain an initialized Streams library or any other CCP tabs opened will be synchronized. This means that state changes made in one open window will be communicated to all open windows. diff --git a/package-lock.json b/package-lock.json index fa296752..2a0dafcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "amazon-connect-streams", - "version": "1.4.9", + "version": "1.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/release/connect-streams-min.js b/release/connect-streams-min.js index cd78b595..c3821ccf 100644 --- a/release/connect-streams-min.js +++ b/release/connect-streams-min.js @@ -1 +1 @@ -!function i(s,a,c){function u(t,e){if(!a[t]){if(!s[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var o=a[t]={exports:{}};s[t][0].call(o.exports,function(e){return u(s[t][1][e]||e)},o,o.exports,i,s,a,c)}return a[t].exports}for(var l="function"==typeof require&&require,e=0;ee.BLOCK_SIZE&&((r=new e).update(n),n=r.digest())}var o=new Uint8Array(e.BLOCK_SIZE);return o.set(n),o}(e,t),r=new Uint8Array(e.BLOCK_SIZE);r.set(n);for(var o=0;o>>32-o)+n&4294967295}function s(e,t,n,r,o,i,s){return c(t&n|~t&r,e,t,o,i,s)}function u(e,t,n,r,o,i,s){return c(t&r|n&~r,e,t,o,i,s)}function l(e,t,n,r,o,i,s){return c(t^n^r,e,t,o,i,s)}function p(e,t,n,r,o,i,s){return c(n^(t|~r),e,t,o,i,s)}(t.exports=r).BLOCK_SIZE=64,r.prototype.update=function(e){if(o.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=o.convertToBuffer(e),n=0,r=t.byteLength;for(this.bytesHashed+=r;0>>0,!0),t.setUint32(60,Math.floor(r/4294967296),!0),this.hashBuffer(),this.finished=!0}for(var i=new DataView(new ArrayBuffer(16)),o=0;o<4;o++)i.setUint32(4*o,this.state[o],!0);var s=new a(i.buffer,i.byteOffset,i.byteLength);return e?s.toString(e):s},r.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=s(n=t[0],i=t[1],o=t[2],r=t[3],e.getUint32(0,!0),7,3614090360),r=s(r,n,i,o,e.getUint32(4,!0),12,3905402710),o=s(o,r,n,i,e.getUint32(8,!0),17,606105819),i=s(i,o,r,n,e.getUint32(12,!0),22,3250441966);n=s(n,i,o,r,e.getUint32(16,!0),7,4118548399),r=s(r,n,i,o,e.getUint32(20,!0),12,1200080426),o=s(o,r,n,i,e.getUint32(24,!0),17,2821735955),i=s(i,o,r,n,e.getUint32(28,!0),22,4249261313),n=s(n,i,o,r,e.getUint32(32,!0),7,1770035416),r=s(r,n,i,o,e.getUint32(36,!0),12,2336552879),o=s(o,r,n,i,e.getUint32(40,!0),17,4294925233),i=s(i,o,r,n,e.getUint32(44,!0),22,2304563134),n=s(n,i,o,r,e.getUint32(48,!0),7,1804603682),r=s(r,n,i,o,e.getUint32(52,!0),12,4254626195),o=s(o,r,n,i,e.getUint32(56,!0),17,2792965006),n=u(n,i=s(i,o,r,n,e.getUint32(60,!0),22,1236535329),o,r,e.getUint32(4,!0),5,4129170786),r=u(r,n,i,o,e.getUint32(24,!0),9,3225465664),o=u(o,r,n,i,e.getUint32(44,!0),14,643717713),i=u(i,o,r,n,e.getUint32(0,!0),20,3921069994),n=u(n,i,o,r,e.getUint32(20,!0),5,3593408605),r=u(r,n,i,o,e.getUint32(40,!0),9,38016083),o=u(o,r,n,i,e.getUint32(60,!0),14,3634488961),i=u(i,o,r,n,e.getUint32(16,!0),20,3889429448),n=u(n,i,o,r,e.getUint32(36,!0),5,568446438),r=u(r,n,i,o,e.getUint32(56,!0),9,3275163606),o=u(o,r,n,i,e.getUint32(12,!0),14,4107603335),i=u(i,o,r,n,e.getUint32(32,!0),20,1163531501),n=u(n,i,o,r,e.getUint32(52,!0),5,2850285829),r=u(r,n,i,o,e.getUint32(8,!0),9,4243563512),o=u(o,r,n,i,e.getUint32(28,!0),14,1735328473),n=l(n,i=u(i,o,r,n,e.getUint32(48,!0),20,2368359562),o,r,e.getUint32(20,!0),4,4294588738),r=l(r,n,i,o,e.getUint32(32,!0),11,2272392833),o=l(o,r,n,i,e.getUint32(44,!0),16,1839030562),i=l(i,o,r,n,e.getUint32(56,!0),23,4259657740),n=l(n,i,o,r,e.getUint32(4,!0),4,2763975236),r=l(r,n,i,o,e.getUint32(16,!0),11,1272893353),o=l(o,r,n,i,e.getUint32(28,!0),16,4139469664),i=l(i,o,r,n,e.getUint32(40,!0),23,3200236656),n=l(n,i,o,r,e.getUint32(52,!0),4,681279174),r=l(r,n,i,o,e.getUint32(0,!0),11,3936430074),o=l(o,r,n,i,e.getUint32(12,!0),16,3572445317),i=l(i,o,r,n,e.getUint32(24,!0),23,76029189),n=l(n,i,o,r,e.getUint32(36,!0),4,3654602809),r=l(r,n,i,o,e.getUint32(48,!0),11,3873151461),o=l(o,r,n,i,e.getUint32(60,!0),16,530742520),n=p(n,i=l(i,o,r,n,e.getUint32(8,!0),23,3299628645),o,r,e.getUint32(0,!0),6,4096336452),r=p(r,n,i,o,e.getUint32(28,!0),10,1126891415),o=p(o,r,n,i,e.getUint32(56,!0),15,2878612391),i=p(i,o,r,n,e.getUint32(20,!0),21,4237533241),n=p(n,i,o,r,e.getUint32(48,!0),6,1700485571),r=p(r,n,i,o,e.getUint32(12,!0),10,2399980690),o=p(o,r,n,i,e.getUint32(40,!0),15,4293915773),i=p(i,o,r,n,e.getUint32(4,!0),21,2240044497),n=p(n,i,o,r,e.getUint32(32,!0),6,1873313359),r=p(r,n,i,o,e.getUint32(60,!0),10,4264355552),o=p(o,r,n,i,e.getUint32(24,!0),15,2734768916),i=p(i,o,r,n,e.getUint32(52,!0),21,1309151649),n=p(n,i,o,r,e.getUint32(16,!0),6,4149444226),r=p(r,n,i,o,e.getUint32(44,!0),10,3174756917),o=p(o,r,n,i,e.getUint32(8,!0),15,718787259),i=p(i,o,r,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=i+t[1]&4294967295,t[2]=o+t[2]&4294967295,t[3]=r+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":80}],14:[function(e,t,n){var o=e("buffer/").Buffer,r=e("./browserHashUtils");new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53);function i(){this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=new Uint32Array(80),this.offset=0,this.shift=24,this.totalLength=0}(t.exports=i).BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=(e=r.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n>t);var n=new o(20),r=new DataView(n.buffer);return r.setUint32(0,this.h0,!1),r.setUint32(4,this.h1,!1),r.setUint32(8,this.h2,!1),r.setUint32(12,this.h3,!1),r.setUint32(16,this.h4,!1),e?n.toString(e):n},i.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}for(var n,r,o=this.h0,i=this.h1,s=this.h2,a=this.h3,c=this.h4,e=0;e<80;e++){r=e<20?(n=a^i&(s^a),1518500249):e<40?(n=i^s^a,1859775393):e<60?(n=i&s|a&(i|s),2400959708):(n=i^s^a,3395469782);var u=(o<<5|o>>>27)+n+c+r+(0|this.block[e]),c=a,a=s,s=i<<30|i>>>2,i=o,o=u}for(this.h0=this.h0+o|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+a|0,this.h4=this.h4+c|0,e=this.offset=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":80}],15:[function(e,t,n){var s=e("buffer/").Buffer,r=e("./browserHashUtils"),m=new Uint32Array([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]),o=Math.pow(2,53)-1;function i(){this.state=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}(t.exports=i).BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=0,n=(e=r.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>o)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;0>>24&255,i[4*o+1]=this.state[o]>>>16&255,i[4*o+2]=this.state[o]>>>8&255,i[4*o+3]=this.state[o]>>>0&255;return e?i.toString(e):i},i.prototype.hashBuffer=function(){for(var e,t,n,r=this.buffer,o=this.state,i=o[0],s=o[1],a=o[2],c=o[3],u=o[4],l=o[5],p=o[6],h=o[7],f=0;f<64;f++){f<16?this.temp[f]=(255&r[4*f])<<24|(255&r[4*f+1])<<16|(255&r[4*f+2])<<8|255&r[4*f+3]:(e=((t=this.temp[f-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10,n=((t=this.temp[f-15])>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,this.temp[f]=(e+this.temp[f-7]|0)+(n+this.temp[f-16]|0));var d=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&l^~u&p)|0)+(h+(m[f]+this.temp[f]|0)|0)|0,g=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&s^i&a^s&a)|0,h=p,p=l,l=u,u=c+d|0,c=a,a=s,s=i,i=d+g|0}o[0]+=i,o[1]+=s,o[2]+=a,o[3]+=c,o[4]+=u,o[5]+=l,o[6]+=p,o[7]+=h}},{"./browserHashUtils":11,"buffer/":80}],16:[function(r,o,e){(function(e){var t=r("./util");t.crypto.lib=r("./browserCryptoLib"),t.Buffer=r("buffer/").Buffer,t.url=r("url/"),t.querystring=r("querystring/"),t.realClock=r("./realclock/browserClock"),t.environment="js",t.createEventStream=r("./event-stream/buffered-create-event-stream").createEventStream,t.isBrowser=function(){return!0},t.isNode=function(){return!1};var n=r("./core");o.exports=n,r("./credentials"),r("./credentials/credential_provider_chain"),r("./credentials/temporary_credentials"),r("./credentials/chainable_temporary_credentials"),r("./credentials/web_identity_credentials"),r("./credentials/cognito_identity_credentials"),r("./credentials/saml_credentials"),n.XML.Parser=r("./xml/browser_parser"),r("./http/xhr"),void 0===e&&(e={browser:!0})}).call(this,r("_process"))},{"./browserCryptoLib":10,"./core":18,"./credentials":19,"./credentials/chainable_temporary_credentials":20,"./credentials/cognito_identity_credentials":21,"./credentials/credential_provider_chain":22,"./credentials/saml_credentials":23,"./credentials/temporary_credentials":24,"./credentials/web_identity_credentials":25,"./event-stream/buffered-create-event-stream":27,"./http/xhr":35,"./realclock/browserClock":52,"./util":71,"./xml/browser_parser":72,_process:85,"buffer/":80,"querystring/":92,"url/":94}],17:[function(e,t,n){var r,i=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),i.Config=i.util.inherit({constructor:function(n){void 0===n&&(n={}),n=this.extractCredentials(n),i.util.each.call(this,this.keys,function(e,t){this.set(e,n[e],t)})},getCredentials:function(t){var e,n=this;function r(e){t(e,e?null:n.credentials)}function o(e,t){return new i.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}n.credentials?"function"==typeof n.credentials.get?n.credentials.get(function(e){r(e=e&&o("Could not load credentials from "+n.credentials.constructor.name,e))}):(e=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(e=o("Missing credentials")),r(e)):n.credentialProvider?n.credentialProvider.resolve(function(e,t){e=e&&o("Could not load credentials from any providers",e),n.credentials=t,r(e)}):r(o("No credentials to load"))},update:function(e,n){n=n||!1,e=this.extractCredentials(e),i.util.each.call(this,e,function(e,t){(n||Object.prototype.hasOwnProperty.call(this.keys,e)||i.Service.hasService(e))&&this.set(e,t)})},loadFromPath:function(e){this.clear();var n=JSON.parse(i.util.readFileSync(e)),t=new i.FileSystemCredentials(e),r=new i.CredentialProviderChain;return r.providers.unshift(t),r.resolve(function(e,t){if(e)throw e;n.credentials=t}),this.constructor(n),this},clear:function(){i.util.each.call(this,this.keys,function(e){delete this[e]}),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"==typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=i.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:!1,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:null},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=i.util.copy(e)).credentials=new i.Credentials(e)),e},setPromisesDependency:function(e){null===(r=e)&&"function"==typeof Promise&&(r=Promise);var t=[i.Request,i.Credentials,i.CredentialProviderChain];i.S3&&(t.push(i.S3),i.S3.ManagedUpload&&t.push(i.S3.ManagedUpload)),i.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),i.config=new i.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var r={util:e("./util")};({}).toString(),(t.exports=r).util.update(r,{VERSION:"2.553.0",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},apiLoader:e("./api_loader"),EndpointCache:e("../vendor/endpoint-cache").EndpointCache}),e("./sequential_executor"),e("./service"),e("./config"),e("./http"),e("./event_listeners"),e("./request"),e("./response"),e("./resource_waiter"),e("./signers/request_signer"),e("./param_validator"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",function(){return new r.EndpointCache(r.config.endpointCacheSize)},!0)},{"../vendor/endpoint-cache":103,"./api_loader":9,"./config":17,"./event_listeners":33,"./http":34,"./json/builder":36,"./json/parser":37,"./model/api":38,"./model/operation":40,"./model/paginator":41,"./model/resource_waiter":42,"./model/shape":43,"./param_validator":44,"./protocol/json":46,"./protocol/query":47,"./protocol/rest":48,"./protocol/rest_json":49,"./protocol/rest_xml":50,"./request":55,"./resource_waiter":56,"./response":57,"./sequential_executor":58,"./service":59,"./signers/request_signer":63,"./util":71,"./xml/builder":73}],19:[function(e,t,n){var o=e("./core");o.Credentials=o.util.inherit({constructor:function(e,t,n){var r;o.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof e?(r=e.credentials||e,this.accessKeyId=r.accessKeyId,this.secretAccessKey=r.secretAccessKey,this.sessionToken=r.sessionToken):(this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n)},expiryWindow:15,needsRefresh:function(){var e=o.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||(this.expired||!this.accessKeyId||!this.secretAccessKey)},get:function(t){var n=this;this.needsRefresh()?this.refresh(function(e){e||(n.expired=!1),t&&t(e)}):t&&t()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,n){var r=this;1===r.refreshCallbacks.push(e)&&r.load(function(t){o.util.arrayEach(r.refreshCallbacks,function(e){n?e(t):o.util.defer(function(){e(t)})}),r.refreshCallbacks.length=0})},load:function(e){e()}}),o.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=o.util.promisifyMethod("get",e),this.prototype.refreshPromise=o.util.promisifyMethod("refresh",e)},o.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},o.util.addPromises(o.Credentials)},{"./core":18}],20:[function(e,t,n){var i=e("../core"),r=e("../../clients/sts");i.ChainableTemporaryCredentials=i.util.inherit(i.Credentials,{constructor:function(e){i.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=i.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new i.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=i.util.merge({params:t,credentials:e.masterCredentials||i.config.credentials},e.stsConfig||{});this.service=new r(n)},refresh:function(e){this.coalesceRefresh(e||i.util.fn.callback)},load:function(r){var o=this,i=o.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode(function(e,t){var n={};e?r(e):(t&&(n.TokenCode=t),o.service[i](n,function(e,t){e||o.service.credentialsFrom(t,o),r(e)}))})},getTokenCode:function(r){var o=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,function(e,t){if(e){var n=e;return e instanceof Error&&(n=e.message),void r(i.util.error(new Error("Error fetching MFA token: "+n),{code:o.errorCode}))}r(null,t)}):r(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var r=e("../core"),o=e("../../clients/cognitoidentity"),i=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(t){var n=this;n.createClients(),n.data=null,n._identityId=null,n.getId(function(e){e?(n.clearIdOnNotAuthorized(e),t(e)):n.params.RoleArn?n.getCredentialsFromSTS(t):n.getCredentialsForIdentity(t)})},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(n){var r=this;if("string"==typeof r.params.IdentityId)return n(null,r.params.IdentityId);r.cognito.getId(function(e,t){!e&&t.IdentityId?(r.params.IdentityId=t.IdentityId,n(null,t.IdentityId)):n(e)})},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(n){var r=this;r.cognito.getCredentialsForIdentity(function(e,t){e?r.clearIdOnNotAuthorized(e):(r.cacheId(t),r.data=t,r.loadCredentials(r.data,r)),n(e)})},getCredentialsFromSTS:function(n){var r=this;r.cognito.getOpenIdToken(function(e,t){e?(r.clearIdOnNotAuthorized(e),n(e)):(r.cacheId(t),r.params.WebIdentityToken=t.Token,r.webIdentityCredentials.refresh(function(e){e||(r.data=r.webIdentityCredentials.data,r.sts.credentialsFrom(r.data,r)),n(e)}))})},loadCachedId:function(){var e,t,n=this;r.util.isBrowser()&&!n.params.IdentityId&&((e=n.getStorage("id"))&&n.params.Logins?(t=Object.keys(n.params.Logins),0!==(n.getStorage("providers")||"").split(",").filter(function(e){return-1!==t.indexOf(e)}).length&&(n.params.IdentityId=e)):e&&(n.params.IdentityId=e))},createClients:function(){var e,t=this._clientConfig;this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,t),this.cognito||((e=r.util.merge({},t)).params=this.params,this.cognito=new o(e)),this.sts=this.sts||new i(t)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.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+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(e){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"==typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(e){return{}}}()})},{"../../clients/cognitoidentity":7,"../../clients/sts":8,"../core":18}],22:[function(e,t,n){var a=e("../core");a.CredentialProviderChain=a.util.inherit(a.Credentials,{constructor:function(e){this.providers=e||a.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var o,i,s=this;if(0===s.providers.length)return e(new Error("No providers")),s;return 1===s.resolveCallbacks.push(e)&&(o=0,i=s.providers.slice(0),function t(n,r){if(!n&&r||o===i.length)return a.util.arrayEach(s.resolveCallbacks,function(e){e(n,r)}),void(s.resolveCallbacks.length=0);var e=i[o++];(r="function"==typeof e?e.call():e).get?r.get(function(e){t(e,e?null:r)}):t(null,r)}()),s}}),a.CredentialProviderChain.defaultProviders=[],a.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=a.util.promisifyMethod("resolve",e)},a.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},a.util.addPromises(a.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.service.assumeRoleWithSAML(function(e,t){e||r.service.credentialsFrom(t,r),n(e)})},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.masterCredentials.get(function(){r.service.config.credentials=r.masterCredentials,(r.params.RoleArn?r.service.assumeRole:r.service.getSessionToken).call(r.service,function(e,t){e||r.service.credentialsFrom(t,r),n(e)})})},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.service.assumeRoleWithWebIdentity(function(e,t){r.data=null,e||(r.data=t,r.service.credentialsFrom(t,r)),n(e)})},createClients:function(){var e;this.service||((e=r.util.merge({},this._clientConfig)).params=this.params,this.service=new o(e))}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){(function(i){var p=e("./core"),h=e("./util"),s=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function f(e){var t=e.service,n=t.api||{},r={};return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function d(e,t){var n={};return function r(o,i,s){s&&null!=i&&"structure"===s.type&&s.required&&0=this.HEADERS_RECEIVED&&!u&&(s.statusCode=c.status,s.headers=o.parseHeaders(c.getAllResponseHeaders()),s.emit("headers",s.statusCode,s.headers,c.statusText),u=!0),this.readyState===this.DONE&&o.finishRequest(c,s)},!1),c.upload.addEventListener("progress",function(e){s.emit("sendProgress",e)}),c.addEventListener("progress",function(e){s.emit("receiveProgress",e)},!1),c.addEventListener("timeout",function(){r(l.util.error(new Error("Timeout"),{code:"TimeoutError"}))},!1),c.addEventListener("error",function(){r(l.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},!1),c.addEventListener("abort",function(){r(l.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))},!1),n(s),c.open(t.method,a,!1!==e.xhrAsync),l.util.each(t.headers,function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&c.setRequestHeader(e,t)}),e.timeout&&!1!==e.xhrAsync&&(c.timeout=e.timeout),e.xhrWithCredentials&&(c.withCredentials=!0);try{c.responseType="arraybuffer"}catch(e){}try{t.body?c.send(t.body):c.send()}catch(e){if(!t.body||"object"!=typeof t.body.buffer)throw e;c.send(t.body.buffer)}return s},parseHeaders:function(e){var r={};return l.util.arrayEach(e.split(/\r?\n/),function(e){var t=e.split(":",1)[0],n=e.substring(t.length+2);0= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,r){if(null==e)return!1;for(var o=!1,i=0;i=t.maxRetries&&(n.MaxRetriesExceeded=1),u.emit("apiCall",[n]))})},setupRequestListeners:function(){},getSignerClass:function(e){var t,n=null,r="";return e&&(r=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===r||"v4-unsigned-body"===r?"v4":this.api.signatureVersion,l.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return l.EventListeners.Query;case"json":return l.EventListeners.Json;case"rest-json":return l.EventListeners.RestJson;case"rest-xml":return l.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e){return l.util.calculateRetryDelay(e,this.config.retryDelayOptions)},retryableError:function(e){return!!this.timeoutError(e)||(!!this.networkingError(e)||(!!this.expiredCredentialsError(e)||(!!this.throttledError(e)||500<=e.statusCode)))},networkingError:function(e){return"NetworkingError"===e.code},timeoutError:function(e){return"TimeoutError"===e.code},expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},clockSkewError:function(e){switch(e.code){case"RequestTimeTooSkewed":case"RequestExpired":case"InvalidSignatureException":case"SignatureDoesNotMatch":case"AuthFailure":case"RequestInTheFuture":return!0;default:return!1}},getSkewCorrectedDate:function(){return new Date(Date.now()+this.config.systemClockOffset)},applyClockOffset:function(e){e&&(this.config.systemClockOffset=e-Date.now())},isClockSkewed:function(e){if(e)return 3e4<=Math.abs(this.getSkewCorrectedDate().getTime()-e)},throttledError:function(e){if(429===e.statusCode)return!0;switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":case"ThrottlingException":case"RequestLimitExceeded":case"RequestThrottled":case"RequestThrottledException":case"TooManyRequestsException":case"TransactionInProgressException":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;var t=e;return t=(t=(t=t.replace(/\{service\}/g,this.api.endpointPrefix)).replace(/\{region\}/g,this.config.region)).replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new l.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(n)return n;if(t){var r=new Error;throw l.util.error(r,"No pagination configuration for "+e)}return null}}),l.util.update(l.Service,{defineMethods:function(e){l.util.each(e.prototype.api.operations,function(n){e.prototype[n]||("none"===e.prototype.api.operations[n].authtype?e.prototype[n]=function(e,t){return this.makeUnauthenticatedRequest(n,e,t)}:e.prototype[n]=function(e,t){return this.makeRequest(n,e,t)})})},defineService:function(e,t,n){l.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var r,o,i,s=a(l.Service,n||{});return"string"==typeof e?(l.Service.addVersions(s,t),r=s.serviceIdentifier||e,s.serviceIdentifier=r):(s.prototype.api=e,l.Service.defineMethods(s)),l.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&l.util.clientSideMonitoring&&(o=l.util.clientSideMonitoring.Publisher,i=(0,l.util.clientSideMonitoring.configProvider)(),this.prototype.publisher=new o(i),i.enabled&&(l.Service._clientSideMonitoring=!0)),l.SequentialExecutor.call(s.prototype),l.Service.addDefaultMonitoringListeners(s.prototype),s},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=n.length)return r.push(null);var t=o+e;t>n.length&&(t=n.length),r.push(n.slice(o,t)),o=t},r},concat:function(e){for(var t,n=0,r=0,o=0;o>>8^t[255&(n^e.readUInt8(r))];return(-1^n)>>>0},hmac:function(e,t,n,r){return"buffer"===(n=n||"binary")&&(n=void 0),r=r||"sha256","string"==typeof t&&(t=l.buffer.toBuffer(t)),l.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return l.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return l.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var o=l.crypto.createHash(e);"buffer"===(n=n||"binary")&&(n=void 0),"string"==typeof t&&(t=l.buffer.toBuffer(t));var i=l.arraySliceFn(t),s=l.Buffer.isBuffer(t);if(l.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(s=!0),r&&"object"==typeof t&&"function"==typeof t.on&&!s)t.on("data",function(e){o.update(e)}),t.on("error",function(e){r(e)}),t.on("end",function(){r(null,o.digest(n))});else{if(!r||!i||s||"undefined"==typeof FileReader){l.isBrowser()&&"object"==typeof t&&!s&&(t=new l.Buffer(new Uint8Array(t)));var a=o.update(t).digest(n);return r&&r(null,a),a}var c=0,u=new FileReader;u.onerror=function(){r(new Error("Failed to read data."))},u.onload=function(){var e=new l.Buffer(new Uint8Array(u.result));o.update(e),c+=e.length,u._continueReading()},u._continueReading=function(){var e;c>=t.size?r(null,o.digest(n)):((e=c+524288)>t.size&&(e=t.size),u.readAsArrayBuffer(i.call(t,c,e)))},u._continueReading()}},toHex:function(e){for(var t=[],n=0;n/g,">").replace(/"/g,""")}}},{}],75:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">")}}},{}],76:[function(e,t,n){var a=e("./escape-attribute").escapeAttribute;function r(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}r.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},r.prototype.addChildNode=function(e){return this.children.push(e),this},r.prototype.removeAttribute=function(e){return delete this.attributes[e],this},r.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,r=0,o=Object.keys(n);r"+this.children.map(function(e){return e.toString()}).join("")+"":"/>")},t.exports={XmlNode:r}},{"./escape-attribute":74}],77:[function(e,t,n){var r=e("./escape-element").escapeElement;function o(e){this.value=e}o.prototype.toString=function(){return r(""+this.value)},t.exports={XmlText:o}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=p(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=p(e),o=r[0],i=r[1],s=new l(function(e,t){return 3*(e+t)/4-t}(o,i)),a=0,c=0>16&255,s[a++]=t>>8&255,s[a++]=255&t;2===i&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,s[a++]=255&t);1===i&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,s[a++]=t>>8&255,s[a++]=255&t);return s},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,o=[],i=0,s=n-r;i>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}(r));return o.join("")}(e,i,s>2]+a[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(a[t>>10]+a[t>>4&63]+a[t<<2&63]+"="));return o.join("")};for(var a=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=r.length;o=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function f(e,t){if(p.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(r)return k(e).length;t=(""+t).toLowerCase(),r=!0}}function t(e,t,n){var r,o,i,s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return function(e,t,n){var r=e.length;(!t||t<0)&&(t=0);(!n||n<0||r=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=p.from(t,r)),p.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,o);if("number"==typeof t)return t&=255,p.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,o){var i=1,s=e.length,a=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s/=i=2,a/=2,n/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o)for(var u=-1,l=n;l>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function b(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rt&&(e+=" ... ")),""},p.prototype.compare=function(e,t,n,r,o){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(o<=r&&n<=t)return 0;if(o<=r)return-1;if(n<=t)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(r,o),u=e.slice(t,n),l=0;lthis.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var i,s,a,c,u,l,p=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var o=e.length-n;(!r||o<(r=Number(r)))&&(r=o);var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2e.length)throw new RangeError("Index out of range")}function T(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function w(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function _(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,r,o){return o||_(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function I(e,t,n,r,o){return o||_(e,0,n,8),i.write(e,t,n,r,52,8),n+8}p.prototype.slice=function(e,t){var n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):n>>8):T(this,e,t,!0),t+2},p.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},p.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),p.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):w(this,e,t,!0),t+4},p.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},p.prototype.writeIntLE=function(e,t,n,r){var o;e=+e,t|=0,r||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},p.prototype.writeIntBE=function(e,t,n,r){var o;e=+e,t|=0,r||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=n-1,s=1,a=0;for(this[t+i]=255&e;0<=--i&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},p.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,127,-128),p.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},p.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),p.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},p.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},p.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),p.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},p.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},p.prototype.writeFloatLE=function(e,t,n){return A(this,e,t,!0,n)},p.prototype.writeFloatBE=function(e,t,n){return A(this,e,t,!1,n)},p.prototype.writeDoubleLE=function(e,t,n){return I(this,e,t,!0,n)},p.prototype.writeDoubleBE=function(e,t,n){return I(this,e,t,!1,n)},p.prototype.copy=function(e,t,n,r){if(n=n||0,r||0===r||(r=this.length),t>=e.length&&(t=e.length),t=t||0,0=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function N(e){return a.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function x(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O("buffer").Buffer)},{"base64-js":78,buffer:80,ieee754:82,isarray:83}],81:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function c(e){return"function"==typeof e}function u(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}((t.exports=r).EventEmitter=r).prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,i,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var a=new Error('Uncaught, unspecified "error" event. ('+t+")");throw a.context=t,a}if(l(n=this._events[e]))return!1;if(c(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(u(n))for(o=Array.prototype.slice.call(arguments,1),r=(s=n.slice()).length,i=0;in&&(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()),this},r.prototype.once=function(e,t){if(!c(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,o,i;if(!c(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(o=(n=this._events[e]).length,r=-1,n===t||c(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(u(n)){for(i=o;0>1,l=-7,p=n?o-1:0,h=n?-1:1,f=e[t+p];for(p+=h,i=f&(1<<-l)-1,f>>=-l,l+=a;0>=-l,l+=r;0>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),2<=(t+=1<=s+p?h/c:h*Math.pow(2,1-p))*c&&(s++,c/=2),l<=s+p?(a=0,s=l):1<=s+p?(a=(t*c-1)*Math.pow(2,o),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),s=0));8<=o;e[n+f]=255&a,f+=d,a/=256,o-=8);for(s=s<":!0,"=":!0,"!":!0},F={" ":!0,"\t":!0,"\n":!0};function j(e){return"0"<=e&&e<="9"||"-"===e}function r(){}r.prototype={tokenize:function(e){var t,n,r,o,i=[];for(this._current=0;this._current"===n?"="===e[this._current]?(this._current++,{type:P,value:">=",start:t}):{type:"GT",value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:"EQ",value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t=this._current,n=e.length;"`"!==e[this._current]&&this._current= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=v-b,w=Math.floor,_=String.fromCharCode;function A(e){throw RangeError(p[e])}function f(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function d(e,t){var n=e.split("@"),r="";return 1>>10&1023|55296),e=56320|1023&e),t+=_(e)}).join("")}function k(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function N(e,t,n){var r=0;for(e=n?w(e/a):e>>1,e+=w(e/t);h*E>>1w((y-f)/i))&&A("overflow"),f+=a*i,!(a<(c=s<=g?b:g+E<=s?E:s-g));s+=v)i>w(y/(u=v-c))&&A("overflow"),i*=u;g=N(f-o,t=p.length+1,0==o),w(f/t)>y-d&&A("overflow"),d+=w(f/t),f%=t,p.splice(f++,0,d)}return R(p)}function m(e){for(var t,n,r,o,i,s,a,c,u,l,p,h=[],f=(e=I(e)).length,d=C,g=S,m=t=0;mw((y-t)/(u=n+1))&&A("overflow"),t+=(o-d)*u,d=o,m=0;my&&A("overflow"),c==d){for(i=t,s=v;!(i<(a=s<=g?b:g+E<=s?E:s-g));s+=v)p=i-a,l=v-a,h.push(_(k(a+p%l,0))),i=w(p/l);h.push(_(k(i,0))),g=N(t,u,n==r),t=0,++n}++t,++d}return h.join("")}if(o={version:"1.3.2",ucs2:{decode:I,encode:R},decode:g,encode:m,toASCII:function(e){return d(e,function(e){return u.test(e)?"xn--"+m(e):e})},toUnicode:function(e){return d(e,function(e){return c.test(e)?g(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return o});else if(t&&n)if(O.exports==t)n.exports=o;else for(i in o)o.hasOwnProperty(i)&&(t[i]=o[i]);else e.punycode=o}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],87:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var i=/\+/g;e=e.split(t);var s=1e3;r&&"number"==typeof r.maxKeys&&(s=r.maxKeys);var a=e.length;0",'"',"`"," ","\r","\n","\t"]),L=["'"].concat(o),P=["%","/","?",";","#"].concat(L),M=["/","?","#"],D=/^[a-z0-9A-Z_-]{0,63}$/,U=/^([a-z0-9A-Z_-]{0,63})(.*)$/,q={javascript:!0,"javascript:":!0},F={javascript:!0,"javascript:":!0},j={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},B=e("querystring");function i(e,t,n){if(e&&a(e)&&e instanceof v)return e;var r=new v;return r.parse(e,t,n),r}function H(e){return"string"==typeof e}function a(e){return"object"==typeof e&&null!==e}function b(e){return null===e}v.prototype.parse=function(e,t,n){if(!H(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r,o,i=(i=e).trim(),s=O.exec(i);if(s&&(r=(s=s[0]).toLowerCase(),this.protocol=r,i=i.substr(s.length)),(n||s||i.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(o="//"===i.substr(0,2))||s&&F[s]||(i=i.substr(2),this.slashes=!0)),!F[s]&&(o||s&&!j[s])){for(var a,c,u=-1,l=0;l>>((3&t)<<3)&255;return o})},{}],101:[function(e,t,n){var d,g,m=e("./lib/rng"),y=e("./lib/bytesToUuid"),v=0,b=0;t.exports=function(e,t,n){var r,o=t&&n||0,i=t||[],s=(e=e||{}).node||d,a=void 0!==e.clockseq?e.clockseq:g;null!=s&&null!=a||(r=m(),null==s&&(s=d=[1|r[0],r[1],r[2],r[3],r[4],r[5]]),null==a&&(a=g=16383&(r[6]<<8|r[7])));var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:b+1,l=c-v+(u-b)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||v>>24&255,i[o++]=p>>>16&255,i[o++]=p>>>8&255,i[o++]=255&p;var h=c/4294967296*1e4&268435455;i[o++]=h>>>8&255,i[o++]=255&h,i[o++]=h>>>24&15|16,i[o++]=h>>>16&255,i[o++]=a>>>8|128,i[o++]=255&a;for(var f=0;f<6;++f)i[o+f]=s[f];return t||y(i)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var s=e("./lib/rng"),a=e("./lib/bytesToUuid");t.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;++i)t[r+i]=o[i];return t||a(o)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils/LRU"),o=(Object.defineProperty(i.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),i.prototype.put=function(e,t){var n="string"!=typeof e?i.getKeyString(e):e,r=this.populateValue(t);this.cache.put(n,r)},i.prototype.get=function(e){var t="string"!=typeof e?i.getKeyString(e):e,n=Date.now(),r=this.cache.get(t);if(r)for(var o=0;o>>=0;break;case"x":r=r.toString(16);break;case"X":r=r.toString(16).toUpperCase()}r=/[def]/.test(i[8])&&i[3]&&0<=r?"+"+r:r,a=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",c=i[6]-String(r).length,s=i[6]?function(e,t){for(var n=[];0=this._logLevel&&(c[e.level]>=this._echoLevel&&r[e.getLevel()](e.toString()),e.line=this._lineCount++)},u.prototype.clearObjects=function(){for(var e=0;e=r._logLevel}));var i=new a.Blob([JSON.stringify(o,void 0,4)],["text/plain"]),s=document.createElement("a"),t=t||"agent-log";s.href=a.URL.createObjectURL(i),s.download=t+".txt",document.body.appendChild(s),s.click(),document.body.removeChild(s)},u.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,a.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},u.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,function(){0=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout(function(){t(--n)},s):o(e)}).catch(function(e){o(e)})}(t)})},connect.backoff=function(r,o,i,s){connect.assertTrue(connect.isFunction(r),"func must be a Function");var a=this;r({success:function(e){s&&s.success&&s.success(e)},failure:function(e,t){var n;0>",e)},u.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},u.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var r=this,e=this.subMap.getSubscriptions("<>"),o=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&connect.getLog().trace("Publishing event: %s",t),e.concat(o).forEach(function(e){try{e.f(n||null,t,r)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e)}})},u.prototype.bridge=function(){var n=this;return function(e,t){n.trigger(t,e)}},u.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach(function(e){e.unsubscribe()})},connect.EventBus=u,connect.EventFactory=e,connect.EventType=t,connect.AgentEvents=r,connect.ConnnectionEvents=s,connect.ContactEvents=i,connect.WebSocketEvents=o,connect.MasterTopics=n}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;function r(){}r.prototype.send=function(e){throw new connect.NotImplementedError},r.prototype.onMessage=function(e){throw new connect.NotImplementedError};function o(){r.call(this)}((o.prototype=Object.create(r.prototype)).constructor=o).prototype.onMessage=function(e){},o.prototype.send=function(e){};function e(e,t){r.call(this),this.window=e,this.domain=t||"*"}((e.prototype=Object.create(r.prototype)).constructor=e).prototype.send=function(e){this.window.postMessage(e,this.domain)},e.prototype.onMessage=function(e){this.window.addEventListener("message",e)};function i(e,t,n){r.call(this),this.input=e,this.output=t,this.domain=n||"*"}((i.prototype=Object.create(r.prototype)).constructor=i).prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(e){this.input.addEventListener("message",e)};function t(e){r.call(this),this.port=e,this.id=connect.randomId()}((t.prototype=Object.create(r.prototype)).constructor=t).prototype.send=function(e){this.port.postMessage(e)},t.prototype.onMessage=function(e){this.port.addEventListener("message",e)},t.prototype.getId=function(){return this.id};function n(e){r.call(this),this.streamMap=e?connect.index(e,function(e){return e.getId()}):{},this.messageListeners=[]}((n.prototype=Object.create(r.prototype)).constructor=n).prototype.send=function(t){this.getStreams().forEach(function(e){try{e.send(t)}catch(e){}})},n.prototype.onMessage=function(t){this.messageListeners.push(t),this.getStreams().forEach(function(e){e.onMessage(t)})},n.prototype.addStream=function(t){this.streamMap[t.getId()]=t,this.messageListeners.forEach(function(e){t.onMessage(e)})},n.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},n.prototype.getStreams=function(e){return connect.values(this.streamMap)},n.prototype.getStreamForPort=function(t){return connect.find(this.getStreams(),function(e){return e.port===t})};function s(e,t,n){this.name=e,this.upstream=t||new o,this.downstream=n||new o,this.downstreamBus=new connect.EventBus,this.upstreamBus=new connect.EventBus,this.upstream.onMessage(connect.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(connect.hitch(this,this._dispatchEvent,this.downstreamBus))}s.prototype.onUpstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.upstreamBus.subscribe(e,t)},s.prototype.onAllUpstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},s.prototype.onDownstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.downstreamBus.subscribe(e,t)},s.prototype.onAllDownstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},s.prototype.sendUpstream=function(e,t){connect.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:t})},s.prototype.sendDownstream=function(e,t){connect.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:t})},s.prototype._dispatchEvent=function(e,t){var n=t.data;n.event&&e.trigger(n.event,n.data)},s.prototype.passUpstream=function(){var n=this;return function(e,t){n.upstream.send({event:t,data:e})}},s.prototype.passDownstream=function(){var n=this;return function(e,t){n.downstream.send({event:t,data:e})}},s.prototype.shutdown=function(){this.upstreamBus.unsubscribeAll(),this.downstreamBus.unsubscribeAll()};function a(e,t,n,r){s.call(this,e,new i(t,n.contentWindow,r||"*"),null)}(a.prototype=Object.create(s.prototype)).constructor=a,connect.Stream=r,connect.NullStream=o,connect.WindowStream=e,connect.WindowIOStream=i,connect.PortStream=t,connect.StreamMultiplexer=n,connect.Conduit=s,connect.IFrameConduit=a}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect,connect.ClientMethods=connect.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","clearContact","completeContact","destroyContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport"]),connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);function i(){}i.EMPTY_CALLBACKS={success:function(){},failure:function(){}},i.prototype.call=function(e,t,n){connect.assertNotNull(e,"method");var r=t||{},o=n||i.EMPTY_CALLBACKS;this._callImpl(e,r,o)},i.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};function e(){i.call(this)}((e.prototype=Object.create(i.prototype)).constructor=e).prototype._callImpl=function(e,t,n){var r;n&&n.failure&&(r=connect.sprintf("No such method exists on NULL client: %s",e),n.failure(new connect.ValueError(r),{message:r}))};function t(e,t,n){i.call(this),this.conduit=e,this.requestEvent=t,this.responseEvent=n,this._requestIdCallbacksMap={},this.conduit.onUpstream(n,connect.hitch(this,this._handleResponse))}((t.prototype=Object.create(i.prototype)).constructor=t).prototype._callImpl=function(e,t,n){var r=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[r.requestId]=n,this.conduit.sendUpstream(r.event,r)},t.prototype._getCallbacksForRequest=function(e){var t=this._requestIdCallbacksMap[e]||null;return null!=t&&delete this._requestIdCallbacksMap[e],t},t.prototype._handleResponse=function(e){var t=this._getCallbacksForRequest(e.requestId);null!=t&&(e.err&&t.failure?t.failure(e.err,e.data):t.success&&t.success(e.data))};function n(e){t.call(this,e,connect.EventType.API_REQUEST,connect.EventType.API_RESPONSE)}(n.prototype=Object.create(t.prototype)).constructor=n;function r(e){t.call(this,e,connect.EventType.MASTER_REQUEST,connect.EventType.MASTER_RESPONSE)}(r.prototype=Object.create(t.prototype)).constructor=r;function o(e,t,n){connect.assertNotNull(e,"authToken"),connect.assertNotNull(t,"region"),i.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=t,this.authToken=e;var r=n||connect.getBaseUrl()+"/connect/api",o=new AWS.Endpoint(r);this.client=new AWS.Connect({endpoint:o})}((o.prototype=Object.create(i.prototype)).constructor=o).prototype._callImpl=function(r,e,o){var t,n=this,i=connect.getLog();connect.contains(this.client,r)?(e=this._translateParams(r,e),i.trace("AWSClient: --\x3e Calling operation '%s'",r),this.client[r](e).on("build",function(e){e.httpRequest.headers["X-Amz-Bearer"]=n.authToken}).send(function(e,t){try{var n;e?(e.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION?o.authFailure():!o.accessDenied||e.code!==connect.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==e.statusCode?((n={}).type=e.code,n.message=e.message,n.stack=e.stack?e.stack.split("\n"):[],o.failure(n,t)):o.accessDenied(),i.trace("AWSClient: <-- Operation '%s' failed: %s",r,JSON.stringify(e))):(i.trace("AWSClient: <-- Operation '%s' succeeded.",r).withObject(t),o.success(t))}catch(e){connect.getLog().error("Failed to handle AWS API request for method %s",r).withException(e)}})):(t=connect.sprintf("No such method exists on AWS client: %s",r),o.failure(new connect.ValueError(t),{message:t}))},o.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT},o.prototype._translateParams=function(e,t){switch(e){case connect.ClientMethods.UPDATE_AGENT_CONFIGURATION:t.configuration=this._translateAgentConfiguration(t.configuration);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:t.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(t.softphoneStreamStatistics);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:t.report=this._translateSoftphoneCallReport(t.report)}return this._requiresAuthenticationParam(e)&&(t.authentication={authToken:this.authToken}),t},o.prototype._translateAgentConfiguration=function(e){return{name:e.name,softphoneEnabled:e.softphoneEnabled,softphoneAutoAccept:e.softphoneAutoAccept,extension:e.extension,routingProfile:this._translateRoutingProfile(e.routingProfile),agentPreferences:e.agentPreferences}},o.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},o.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},o.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach(function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)}),e},o.prototype._translateSoftphoneCallReport=function(e){return"handshakingTimeMillis"in e&&(e.handshakeTimeMillis=e.handshakingTimeMillis,delete e.handshakingTimeMillis),"preTalkingTimeMillis"in e&&(e.preTalkTimeMillis=e.preTalkingTimeMillis,delete e.preTalkingTimeMillis),"handshakingFailure"in e&&(e.handshakeFailure=e.handshakingFailure,delete e.handshakingFailure),"talkingTimeMillis"in e&&(e.talkTimeMillis=e.talkingTimeMillis,delete e.talkingTimeMillis),e.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(e.softphoneStreamStatistics),e},connect.ClientBase=i,connect.NullClient=e,connect.UpstreamConduitClient=n,connect.UpstreamConduitMasterClient=r,connect.AWSClient=o}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;function r(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t}r.prototype.getAssociations=function(e){throw connect.NotImplementedError()},r.prototype.getFromState=function(){return this.fromState},r.prototype.getToState=function(){return this.toState};function e(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"associations"),r.call(this,e,t),this.associations=n}((e.prototype=Object.create(r.prototype)).constructor=e).prototype.getAssociations=function(e){return this.associations};function i(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"closure"),connect.assertTrue(connect.isFunction(n),"closure must be a function"),r.call(this,e,t),this.closure=n}((i.prototype=Object.create(r.prototype)).constructor=i).prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};function s(){this.fromMap={}}s.ANY="<>",s.prototype.assoc=function(t,n,r){var o=this;if(!t)throw new Error("fromStateObj is not defined.");if(!n)throw new Error("toStateObj is not defined.");if(!r)throw new Error("assocObj is not defined.");return t instanceof Array?t.forEach(function(e){o.assoc(e,n,r)}):n instanceof Array?n.forEach(function(e){o.assoc(t,e,r)}):"function"==typeof r?this._addAssociation(new i(t,n,r)):r instanceof Array?this._addAssociation(new e(t,n,r)):this._addAssociation(new e(t,n,[r])),this},s.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var r=[],o=this.fromMap[s.ANY]||{},i=this.fromMap[t]||{};return r=(r=r.concat(this._getAssociationsFromMap(o,e,t,n))).concat(this._getAssociationsFromMap(i,e,t,n))},s.prototype._addAssociation=function(e){var t=this.fromMap[e.getFromState()];((t=t||(this.fromMap[e.getFromState()]={}))[e.getToState()]||(t[e.getToState()]=[])).push(e)},s.prototype._getAssociationsFromMap=function(e,n,t,r){return(e[s.ANY]||[]).concat(e[r]||[]).reduce(function(e,t){return e.concat(t.getAssociations(n))},[])},connect.EventGraph=s}(),function(){var n=this;connect=n.connect||{},n.connect=connect,n.lily=connect,connect.AgentStateType=connect.makeEnum(["init","routable","not_routable","offline"]),connect.AgentStatusType=connect.AgentStateType,connect.AgentAvailStates=connect.makeEnum(["Init","Busy","AfterCallWork","CallingCustomer","Dialing","Joining","PendingAvailable","PendingBusy"]),connect.AgentErrorStates=connect.makeEnum(["Error","AgentHungUp","BadAddressAgent","BadAddressCustomer","Default","FailedConnectAgent","FailedConnectCustomer","LineEngagedAgent","LineEngagedCustomer","MissedCallAgent","MissedCallCustomer","MultipleCcpWindows","RealtimeCommunicationError"]),connect.EndpointType=connect.makeEnum(["phone_number","agent","queue"]),connect.AddressType=connect.EndpointType,connect.ConnectionType=connect.makeEnum(["agent","inbound","outbound","monitoring"]),connect.ConnectionStateType=connect.makeEnum(["init","connecting","connected","hold","disconnected"]),connect.ConnectionStatusType=connect.ConnectionStateType,connect.CONNECTION_ACTIVE_STATES=connect.set([connect.ConnectionStateType.CONNECTING,connect.ConnectionStateType.CONNECTED,connect.ConnectionStateType.HOLD]),connect.ContactStateType=connect.makeEnum(["init","incoming","pending","connecting","connected","missed","error","ended"]),connect.ContactStatusType=connect.ContactStateType,connect.CONTACT_ACTIVE_STATES=connect.makeEnum(["incoming","pending","connecting","connected"]),connect.ContactType=connect.makeEnum(["voice","queue_callback","chat"]),connect.ChannelType=connect.makeEnum(["VOICE","CHAT"]),connect.MediaType=connect.makeEnum(["softphone","chat"]),connect.SoftphoneCallType=connect.makeEnum(["audio_video","video_only","audio_only","none"]),connect.SoftphoneErrorTypes=connect.makeEnum(["unsupported_browser","microphone_not_shared","signalling_handshake_failure","signalling_connection_failure","ice_collection_timeout","user_busy_error","webrtc_error","realtime_communication_error","other"]),connect.CTIExceptions=connect.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException"]);function e(){if(!connect.agent.initialized)throw new connect.StateError("The agent is not yet initialized!")}e.prototype._getData=function(){return connect.core.getAgentDataProvider().getAgentData()},e.prototype._createContactAPI=function(e){return new connect.Contact(e.contactId)},e.prototype.onContactPending=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.CONTACT_PENDING,e)},e.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.REFRESH,e)},e.prototype.onRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ROUTABLE,e)},e.prototype.onNotRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.NOT_ROUTABLE,e)},e.prototype.onOffline=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.OFFLINE,e)},e.prototype.onError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ERROR,e)},e.prototype.onSoftphoneError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.SOFTPHONE_ERROR,e)},e.prototype.onWebSocketConnectionLost=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e)},e.prototype.onWebSocketConnectionGained=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED,e)},e.prototype.onAfterCallWork=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ACW,e)},e.prototype.onStateChange=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.STATE_CHANGE,e)},e.prototype.onMuteToggle=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.MUTE_TOGGLE,e)},e.prototype.mute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!0}})},e.prototype.unmute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!1}})},e.prototype.getState=function(){return this._getData().snapshot.state},e.prototype.getAvailabilityState=function(){return this._getData().snapshot.agentAvailabilityState},e.prototype.getStatus=e.prototype.getState,e.prototype.getStatusDuration=e.prototype.getStateDuration=function(){return connect.now()-this._getData().snapshot.state.startTimestamp.getTime()+connect.core.getSkew()},e.prototype.getPermissions=function(){return this.getConfiguration().permissions},e.prototype.getContacts=function(t){var n=this;return this._getData().snapshot.contacts.map(function(e){return n._createContactAPI(e)}).filter(function(e){return!t||e.getType()===t})},e.prototype.getConfiguration=function(){return this._getData().configuration},e.prototype.getAgentStates=function(){return this.getConfiguration().agentStates},e.prototype.getRoutingProfile=function(){return this.getConfiguration().routingProfile},e.prototype.getChannelConcurrency=function(e){var t=(t=this.getRoutingProfile().channelConcurrencyMap)||Object.keys(connect.ChannelType).reduce(function(e,t){return e[connect.ChannelType[t]]=1,e},{});return e?t[e]||0:t},e.prototype.getName=function(){return this.getConfiguration().name},e.prototype.getExtension=function(){return this.getConfiguration().extension},e.prototype.getDialableCountries=function(){return this.getConfiguration().dialableCountries},e.prototype.isSoftphoneEnabled=function(){return this.getConfiguration().softphoneEnabled},e.prototype.setConfiguration=function(e,t){connect.core.getClient().call(connect.ClientMethods.UPDATE_AGENT_CONFIGURATION,{configuration:connect.assertNotNull(e,"configuration")},{success:function(e){connect.core.getUpstream().sendUpstream(connect.EventType.RELOAD_AGENT_CONFIGURATION),t.success&&t.success(e)},failure:t&&t.failure})},e.prototype.setStatus=e.prototype.setState=function(e,t){connect.core.getClient().call(connect.ClientMethods.PUT_AGENT_STATE,{state:connect.assertNotNull(e,"state")},t)},e.prototype.connect=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:connect.assertNotNull(r,"endpoint"),queueARN:t&&(t.queueARN||t.queueId)||this.getRoutingProfile().defaultOutboundQueue.queueARN},t&&{success:t.success,failure:t.failure})},e.prototype.getAllQueueARNs=function(){return this.getConfiguration().routingProfile.queues.map(function(e){return e.queueARN})},e.prototype.getAddresses=e.prototype.getEndpoints=function(n,r,e){var o=this,t=connect.core.getClient();connect.assertNotNull(r,"callbacks"),connect.assertNotNull(r.success,"callbacks.success");var i=e||{};i.endpoints=i.endpoints||[],i.maxResults=i.maxResults||connect.DEFAULT_BATCH_SIZE,connect.isArray(n)||(n=[n]),t.call(connect.ClientMethods.GET_ENDPOINTS,{queueARNs:n,nextToken:i.nextToken||null,maxResults:i.maxResults},{success:function(e){var t;e.nextToken?o.getEndpoints(n,r,{nextToken:e.nextToken,maxResults:i.maxResults,endpoints:i.endpoints.concat(e.endpoints)}):(i.endpoints=i.endpoints.concat(e.endpoints),t=i.endpoints.map(function(e){return new connect.Endpoint(e)}),r.success({endpoints:t,addresses:t}))},failure:r.failure})},e.prototype.toSnapshot=function(){return new connect.AgentSnapshot(this._getData())};function t(e){connect.Agent.call(this),this.agentData=e}((t.prototype=Object.create(e.prototype)).constructor=t).prototype._getData=function(){return this.agentData},t.prototype._createContactAPI=function(e){return new connect.ContactSnapshot(e)};function r(e){this.contactId=e}r.prototype._getData=function(){return connect.core.getAgentDataProvider().getContactData(this.getContactId())},r.prototype._createConnectionAPI=function(e){return this.getType()===connect.ContactType.CHAT?new connect.ChatConnection(this.contactId,e.connectionId):new connect.VoiceConnection(this.contactId,e.connectionId)},r.prototype.getEventName=function(e){return connect.core.getContactEventName(e,this.getContactId())},r.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.REFRESH),e)},r.prototype.onIncoming=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.INCOMING),e)},r.prototype.onConnecting=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTING),e)},r.prototype.onPending=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.PENDING),e)},r.prototype.onAccepted=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACCEPTED),e)},r.prototype.onMissed=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.MISSED),e)},r.prototype.onEnded=function(e){var t=connect.core.getEventBus();t.subscribe(this.getEventName(connect.ContactEvents.ENDED),e),t.subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},r.prototype.onDestroy=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},r.prototype.onACW=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACW),e)},r.prototype.onConnected=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTED),e)},r.prototype.getContactId=function(){return this.contactId},r.prototype.getInitialContactId=r.prototype.getOriginalContactId=function(){return this._getData().initialContactId},r.prototype.getType=function(){return this._getData().type},r.prototype.getContactDuration=function(){return this._getData().contactDuration},r.prototype.getStatus=r.prototype.getState=function(){return this._getData().state},r.prototype.getStatusDuration=r.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},r.prototype.getQueue=function(){return this._getData().queue},r.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},r.prototype.getConnections=function(){var t=this;return this._getData().connections.map(function(e){return t.getType()===connect.ContactType.CHAT?new connect.ChatConnection(t.contactId,e.connectionId):new connect.VoiceConnection(t.contactId,e.connectionId)})},r.prototype.getInitialConnection=function(){return connect.find(this.getConnections(),function(e){return e.isInitialConnection()})||null},r.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},r.prototype.getThirdPartyConnections=function(){return this.getConnections().filter(function(e){return!e.isInitialConnection()&&e.getType()!==connect.ConnectionType.AGENT})},r.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter(function(e){return e.isActive()})[0]||null},r.prototype.getAgentConnection=function(){return connect.find(this.getConnections(),function(e){var t=e.getType();return t===connect.ConnectionType.AGENT||t===connect.ConnectionType.MONITORING})},r.prototype.getAttributes=function(){return this._getData().attributes},r.prototype.isSoftphoneCall=function(){return null!=connect.find(this.getConnections(),function(e){return null!=e.getSoftphoneMediaInfo()})},r.prototype.isInbound=function(){var e=this.getInitialConnection();return!!e&&e.getType()===connect.ConnectionType.INBOUND},r.prototype.isConnected=function(){return this.getStatus().type===connect.ContactStateType.CONNECTED},r.prototype.accept=function(n){var e=connect.core.getClient(),r=this,o=this.getContactId();e.call(connect.ClientMethods.ACCEPT_CONTACT,{contactId:o},{success:function(e){var t=connect.core.getUpstream();t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(o)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,r.getContactId()),data:new connect.Contact(o)}),n&&n.success&&n.success(e)},failure:n?n.failure:null})},r.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONTACT,{contactId:this.getContactId()},e)},r.prototype.complete=function(e){connect.core.getClient().call(connect.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},r.prototype.clear=function(e){connect.core.getClient().call(connect.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},r.prototype.notifyIssue=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:t},n)},r.prototype.addConnection=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:r},t)},r.prototype.toggleActiveConnections=function(e){var t,n=connect.core.getClient(),r=null,o=connect.find(this.getConnections(),function(e){return e.getStatus().type===connect.ConnectionStateType.HOLD});null!=o?r=o.getConnectionId():0<(t=this.getConnections().filter(function(e){return e.isActive()})).length&&(r=t[0].getConnectionId()),n.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:r},e)},r.prototype.sendSoftphoneMetrics=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,softphoneStreamStatistics:e},t)},r.prototype.sendSoftphoneReport=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e},t)},r.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},r.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};function o(e){connect.Contact.call(this,e.contactId),this.contactData=e}((o.prototype=Object.create(r.prototype)).constructor=o).prototype._getData=function(){return this.contactData},o.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};function i(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()}i.prototype._getData=function(){return connect.core.getAgentDataProvider().getConnectionData(this.getContactId(),this.getConnectionId())},i.prototype.getContactId=function(){return this.contactId},i.prototype.getConnectionId=function(){return this.connectionId},i.prototype.getAddress=i.prototype.getEndpoint=function(){return new connect.Endpoint(this._getData().endpoint)},i.prototype.getStatus=i.prototype.getState=function(){return this._getData().state},i.prototype.getStatusDuration=i.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},i.prototype.getType=function(){return this._getData().type},i.prototype.isInitialConnection=function(){return this._getData().initial},i.prototype.isActive=function(){return connect.contains(connect.CONNECTION_ACTIVE_STATES,this.getStatus().type)},i.prototype.isConnected=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTED},i.prototype.isConnecting=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTING},i.prototype.isOnHold=function(){return this.getStatus().type===connect.ConnectionStateType.HOLD},i.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},i.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},i.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.sendDigits=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},t)},i.prototype.hold=function(e){connect.core.getClient().call(connect.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.resume=function(e){connect.core.getClient().call(connect.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.toSnapshot=function(){return new connect.ConnectionSnapshot(this._getData())},i.prototype._initMediaController=function(){this.getMediaInfo()&&connect.core.mediaFactory.get(this).catch(function(){})},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING};function s(e,t){i.call(this,e,t)}((s.prototype=Object.create(i.prototype)).constructor=s).prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaType=function(){return connect.MediaType.SOFTPHONE},s.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)};function a(e,t){i.call(this,e,t)}((a.prototype=Object.create(i.prototype)).constructor=a).prototype.getMediaInfo=function(){var t=this._getData().chatMediaInfo;if(t){var e=connect.core.getAgentDataProvider().getContactData(this.contactId),n={contactId:this.contactId,initialContactId:e.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:connect.hitch(this,this.getConnectionToken)};if(t.connectionData)try{n.participantToken=JSON.parse(t.connectionData).ConnectionAuthenticationToken}catch(e){connect.getLog().error(connect.LogComponent.CHAT,"Connection data is invalid").withObject(t).withException(e),n.participantToken=null}return n.participantToken=n.participantToken||null,n.originalInfo=this._getData().chatMediaInfo,n}return null},a.prototype.getConnectionToken=function(){client=connect.core.getClient();var e=connect.core.getAgentDataProvider().getContactData(this.contactId),r={transportType:connect.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:e.initialContactId||this.contactId};return new Promise(function(t,n){client.call(connect.ClientMethods.CREATE_TRANSPORT,r,{success:function(e){connect.getLog().info("getConnectionToken succeeded"),t(e)},failure:function(e,t){connect.getLog().error("getConnectionToken failed").withObject({err:e,data:t}),n(Error("getConnectionToken failed"))}})})},a.prototype.getMediaType=function(){return connect.MediaType.CHAT},a.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},a.prototype._initMediaController=function(){this._isAgentConnectionType()&&connect.core.mediaFactory.get(this).catch(function(){})};function c(e){connect.Connection.call(this,e.contactId,e.connectionId),this.connectionData=e}((c.prototype=Object.create(i.prototype)).constructor=c).prototype._getData=function(){return this.connectionData},c.prototype._initMediaController=function(){};function u(e){var t=e||{};this.endpointARN=t.endpointId||t.endpointARN||null,this.endpointId=this.endpointARN,this.type=t.type||null,this.name=t.name||null,this.phoneNumber=t.phoneNumber||null,this.agentLogin=t.agentLogin||null,this.queue=t.queue||null}u.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},u.byPhoneNumber=function(e,t){return new u({type:connect.EndpointType.PHONE_NUMBER,phoneNumber:e,name:t||null})};function l(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n}l.prototype.getErrorType=function(){return this.errorType},l.prototype.getErrorMessage=function(){return this.errorMessage},l.prototype.getEndPointUrl=function(){return this.endPointUrl},connect.agent=function(e){var t=connect.core.getEventBus().subscribe(connect.AgentEvents.INIT,e);return connect.agent.initialized&&e(new connect.Agent),t},connect.agent.initialized=!1,connect.contact=function(e){return connect.core.getEventBus().subscribe(connect.ContactEvents.INIT,e)},connect.onWebsocketInitFailure=function(e){var t=connect.core.getEventBus().subscribe(connect.WebSocketEvents.INIT_FAILURE,e);return connect.webSocketInitFailed&&e(),t},connect.ifMaster=function(e,t,n){if(connect.assertNotNull(e,"A topic must be provided."),connect.assertNotNull(t,"A true callback must be provided."),!connect.core.masterClient)return connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),void(n&&n());connect.core.getMasterClient().call(connect.MasterMethods.CHECK_MASTER,{topic:e},{success:function(e){e.isMaster?t():n&&n()}})},connect.becomeMaster=function(e){connect.assertNotNull(e,"A topic must be provided."),connect.core.getMasterClient().call(connect.MasterMethods.BECOME_MASTER,{topic:e})},connect.Agent=e,connect.AgentSnapshot=t,connect.Contact=r,connect.ContactSnapshot=o,connect.Connection=s,connect.BaseConnection=i,connect.VoiceConnection=s,connect.ChatConnection=a,connect.ConnectionSnapshot=c,connect.Endpoint=u,connect.Address=u,connect.SoftphoneError=l}(),function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2)}([function(e,t,n){"use strict";var r=n(1);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return i.assertTrue(null!==e&&void 0!==o(e),Object(r.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&0=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||"";return"DEBUG"===this._logsDestination?this.consoleLoggerWrapper:new y(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||d.DEBUG,this._clientLogger=t.logger||null,this._logsDestination="NULL",t.debug&&(this._logsDestination="DEBUG"),t.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),S),m=(h(E,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),E),y=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(b,m),h(b,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n>>0).toString(8);break;case"s":n=String(n),n=o.precision?n.substring(0,o.precision):n;break;case"t":n=String(!!n),n=o.precision?n.substring(0,o.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=o.precision?n.substring(0,o.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=o.precision?n.substring(0,o.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}d.json.test(o.type)?h+=n:(!d.number.test(o.type)||c&&!o.sign?u="":(u=c?"+":"-",n=n.toString().replace(d.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",a=o.width-(u+n).length,i=o.width&&0t.packetsLost?e.packetsLost-t.packetsLost:0,o=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new O(e.timestamp,r,o,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new O(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},x=function(e,t){u=r(u),l=r(l),function(e,t,n,r){t.streamStats=[L(n,i),L(r,s)];var o={callStartTime:t.sessionStartTime,callEndTime:t.sessionEndTime,gumTimeMillis:t.gumTimeMillis,initializationTimeMillis:t.initializationTimeMillis,iceCollectionTimeMillis:t.iceCollectionTimeMillis,signallingConnectTimeMillis:t.signallingConnectTimeMillis,handshakingTimeMillis:t.handshakingTimeMillis,preTalkingTimeMillis:t.preTalkingTimeMillis,talkingTimeMillis:t.talkingTimeMillis,cleanupTimeMillis:t.cleanupTimeMillis,iceCollectionFailure:t.iceCollectionFailure,signallingConnectionFailure:t.signallingConnectionFailure,handshakingFailure:t.handshakingFailure,gumOtherFailure:t.gumOtherFailure,gumTimeoutFailure:t.gumTimeoutFailure,createOfferFailure:t.createOfferFailure,setLocalDescriptionFailure:t.setLocalDescriptionFailure,userBusyFailure:t.userBusyFailure,invalidRemoteSDPFailure:t.invalidRemoteSDPFailure,noRemoteIceCandidateFailure:t.noRemoteIceCandidateFailure,setRemoteDescriptionFailure:t.setRemoteDescriptionFailure,softphoneStreamStatistics:t.streamStats};e.sendSoftphoneReport(o,{success:function(){h.info("sendSoftphoneReport success"+JSON.stringify(o))},failure:function(e){h.error("sendSoftphoneReport failed.").withObject(e)}})}(e,t,L(a,i),L(c,s)),n(e)},O=function(e,t,n,r,o,i,s){this.softphoneStreamType=r,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=o,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},L=function(e,t){return new O((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},P=function(e){this._originalLogger=e;var r=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),t="";e.forEach(function(){t+=" %s"}),n.apply(r._originalLogger,[connect.LogComponent.SOFTPHONE,t].concat(e))}}};P.prototype.debug=function(){this._tee(1,this._originalLogger.debug)(arguments)},P.prototype.info=function(){this._tee(2,this._originalLogger.info)(arguments)},P.prototype.log=function(){this._tee(3,this._originalLogger.log)(arguments)},P.prototype.warn=function(){this._tee(4,this._originalLogger.warn)(arguments)},P.prototype.error=function(){this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var a;h=new P(connect.getLog()),connect.RtcPeerConnectionFactory&&(a=new connect.RtcPeerConnectionFactory(h,connect.core.getWebSocketManager(),g,connect.hitch(this,t,{transportType:"softphone",softphoneClientId:g}),connect.hitch(this,C))),A()||C(f.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ","");S({success:function(e){connect.isFirefoxBrowser()&&connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){C(e,"Your microphone is not enabled in your browser. ","")}});y(),this.ringtoneEngine=null;var c="true"===e.cleanMultipleSessions,u={},l={};this.getSession=function(e){return u[e]};function p(n){var r;u.hasOwnProperty(n)&&(r=u[n],new Promise(function(e,t){delete u[n],delete l[n],r.hangup()}).catch(function(e){lily.getLog().warn("Clean up the session locally "+n,e.message)}))}function n(n,r){var e,t,o,i,s;!u[r]||(e=n).getStatus().type!==connect.ContactStatusType.ENDED&&e.getStatus().type!==connect.ContactStatusType.ERROR&&e.getStatus().type!==connect.ContactStatusType.MISSED||p(r),!n.isSoftphoneCall()||l[r]||n.getStatus().type!==connect.ContactStatusType.CONNECTING&&n.getStatus().type!==connect.ContactStatusType.INCOMING||(l[r]=!0,h.info("Softphone call detected:","contactId "+n.getContactId(),"agent connectionId "+r),function(e){if(0e.BLOCK_SIZE&&((r=new e).update(n),n=r.digest())}var o=new Uint8Array(e.BLOCK_SIZE);return o.set(n),o}(e,t),r=new Uint8Array(e.BLOCK_SIZE);r.set(n);for(var o=0;o>>32-o)+n&4294967295}function s(e,t,n,r,o,i,s){return c(t&n|~t&r,e,t,o,i,s)}function u(e,t,n,r,o,i,s){return c(t&r|n&~r,e,t,o,i,s)}function l(e,t,n,r,o,i,s){return c(t^n^r,e,t,o,i,s)}function p(e,t,n,r,o,i,s){return c(n^(t|~r),e,t,o,i,s)}(t.exports=r).BLOCK_SIZE=64,r.prototype.update=function(e){if(o.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=o.convertToBuffer(e),n=0,r=t.byteLength;for(this.bytesHashed+=r;0>>0,!0),t.setUint32(60,Math.floor(r/4294967296),!0),this.hashBuffer(),this.finished=!0}for(var i=new DataView(new ArrayBuffer(16)),o=0;o<4;o++)i.setUint32(4*o,this.state[o],!0);var s=new a(i.buffer,i.byteOffset,i.byteLength);return e?s.toString(e):s},r.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=s(n=t[0],i=t[1],o=t[2],r=t[3],e.getUint32(0,!0),7,3614090360),r=s(r,n,i,o,e.getUint32(4,!0),12,3905402710),o=s(o,r,n,i,e.getUint32(8,!0),17,606105819),i=s(i,o,r,n,e.getUint32(12,!0),22,3250441966);n=s(n,i,o,r,e.getUint32(16,!0),7,4118548399),r=s(r,n,i,o,e.getUint32(20,!0),12,1200080426),o=s(o,r,n,i,e.getUint32(24,!0),17,2821735955),i=s(i,o,r,n,e.getUint32(28,!0),22,4249261313),n=s(n,i,o,r,e.getUint32(32,!0),7,1770035416),r=s(r,n,i,o,e.getUint32(36,!0),12,2336552879),o=s(o,r,n,i,e.getUint32(40,!0),17,4294925233),i=s(i,o,r,n,e.getUint32(44,!0),22,2304563134),n=s(n,i,o,r,e.getUint32(48,!0),7,1804603682),r=s(r,n,i,o,e.getUint32(52,!0),12,4254626195),o=s(o,r,n,i,e.getUint32(56,!0),17,2792965006),n=u(n,i=s(i,o,r,n,e.getUint32(60,!0),22,1236535329),o,r,e.getUint32(4,!0),5,4129170786),r=u(r,n,i,o,e.getUint32(24,!0),9,3225465664),o=u(o,r,n,i,e.getUint32(44,!0),14,643717713),i=u(i,o,r,n,e.getUint32(0,!0),20,3921069994),n=u(n,i,o,r,e.getUint32(20,!0),5,3593408605),r=u(r,n,i,o,e.getUint32(40,!0),9,38016083),o=u(o,r,n,i,e.getUint32(60,!0),14,3634488961),i=u(i,o,r,n,e.getUint32(16,!0),20,3889429448),n=u(n,i,o,r,e.getUint32(36,!0),5,568446438),r=u(r,n,i,o,e.getUint32(56,!0),9,3275163606),o=u(o,r,n,i,e.getUint32(12,!0),14,4107603335),i=u(i,o,r,n,e.getUint32(32,!0),20,1163531501),n=u(n,i,o,r,e.getUint32(52,!0),5,2850285829),r=u(r,n,i,o,e.getUint32(8,!0),9,4243563512),o=u(o,r,n,i,e.getUint32(28,!0),14,1735328473),n=l(n,i=u(i,o,r,n,e.getUint32(48,!0),20,2368359562),o,r,e.getUint32(20,!0),4,4294588738),r=l(r,n,i,o,e.getUint32(32,!0),11,2272392833),o=l(o,r,n,i,e.getUint32(44,!0),16,1839030562),i=l(i,o,r,n,e.getUint32(56,!0),23,4259657740),n=l(n,i,o,r,e.getUint32(4,!0),4,2763975236),r=l(r,n,i,o,e.getUint32(16,!0),11,1272893353),o=l(o,r,n,i,e.getUint32(28,!0),16,4139469664),i=l(i,o,r,n,e.getUint32(40,!0),23,3200236656),n=l(n,i,o,r,e.getUint32(52,!0),4,681279174),r=l(r,n,i,o,e.getUint32(0,!0),11,3936430074),o=l(o,r,n,i,e.getUint32(12,!0),16,3572445317),i=l(i,o,r,n,e.getUint32(24,!0),23,76029189),n=l(n,i,o,r,e.getUint32(36,!0),4,3654602809),r=l(r,n,i,o,e.getUint32(48,!0),11,3873151461),o=l(o,r,n,i,e.getUint32(60,!0),16,530742520),n=p(n,i=l(i,o,r,n,e.getUint32(8,!0),23,3299628645),o,r,e.getUint32(0,!0),6,4096336452),r=p(r,n,i,o,e.getUint32(28,!0),10,1126891415),o=p(o,r,n,i,e.getUint32(56,!0),15,2878612391),i=p(i,o,r,n,e.getUint32(20,!0),21,4237533241),n=p(n,i,o,r,e.getUint32(48,!0),6,1700485571),r=p(r,n,i,o,e.getUint32(12,!0),10,2399980690),o=p(o,r,n,i,e.getUint32(40,!0),15,4293915773),i=p(i,o,r,n,e.getUint32(4,!0),21,2240044497),n=p(n,i,o,r,e.getUint32(32,!0),6,1873313359),r=p(r,n,i,o,e.getUint32(60,!0),10,4264355552),o=p(o,r,n,i,e.getUint32(24,!0),15,2734768916),i=p(i,o,r,n,e.getUint32(52,!0),21,1309151649),n=p(n,i,o,r,e.getUint32(16,!0),6,4149444226),r=p(r,n,i,o,e.getUint32(44,!0),10,3174756917),o=p(o,r,n,i,e.getUint32(8,!0),15,718787259),i=p(i,o,r,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=i+t[1]&4294967295,t[2]=o+t[2]&4294967295,t[3]=r+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":80}],14:[function(e,t,n){var o=e("buffer/").Buffer,r=e("./browserHashUtils");new Uint32Array([1518500249,1859775393,-1894007588,-899497514]),Math.pow(2,53);function i(){this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=new Uint32Array(80),this.offset=0,this.shift=24,this.totalLength=0}(t.exports=i).BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=(e=r.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n>t);var n=new o(20),r=new DataView(n.buffer);return r.setUint32(0,this.h0,!1),r.setUint32(4,this.h1,!1),r.setUint32(8,this.h2,!1),r.setUint32(12,this.h3,!1),r.setUint32(16,this.h4,!1),e?n.toString(e):n},i.prototype.processBlock=function(){for(var e=16;e<80;e++){var t=this.block[e-3]^this.block[e-8]^this.block[e-14]^this.block[e-16];this.block[e]=t<<1|t>>>31}for(var n,r,o=this.h0,i=this.h1,s=this.h2,a=this.h3,c=this.h4,e=0;e<80;e++){r=e<20?(n=a^i&(s^a),1518500249):e<40?(n=i^s^a,1859775393):e<60?(n=i&s|a&(i|s),2400959708):(n=i^s^a,3395469782);var u=(o<<5|o>>>27)+n+c+r+(0|this.block[e]),c=a,a=s,s=i<<30|i>>>2,i=o,o=u}for(this.h0=this.h0+o|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+a|0,this.h4=this.h4+c|0,e=this.offset=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":80}],15:[function(e,t,n){var s=e("buffer/").Buffer,r=e("./browserHashUtils"),m=new Uint32Array([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]),o=Math.pow(2,53)-1;function i(){this.state=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}(t.exports=i).BLOCK_SIZE=64,i.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");if(r.isEmptyData(e))return this;var t=0,n=(e=r.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>o)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;0>>24&255,i[4*o+1]=this.state[o]>>>16&255,i[4*o+2]=this.state[o]>>>8&255,i[4*o+3]=this.state[o]>>>0&255;return e?i.toString(e):i},i.prototype.hashBuffer=function(){for(var e,t,n,r=this.buffer,o=this.state,i=o[0],s=o[1],a=o[2],c=o[3],u=o[4],l=o[5],p=o[6],h=o[7],f=0;f<64;f++){f<16?this.temp[f]=(255&r[4*f])<<24|(255&r[4*f+1])<<16|(255&r[4*f+2])<<8|255&r[4*f+3]:(e=((t=this.temp[f-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10,n=((t=this.temp[f-15])>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,this.temp[f]=(e+this.temp[f-7]|0)+(n+this.temp[f-16]|0));var d=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&l^~u&p)|0)+(h+(m[f]+this.temp[f]|0)|0)|0,g=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&s^i&a^s&a)|0,h=p,p=l,l=u,u=c+d|0,c=a,a=s,s=i,i=d+g|0}o[0]+=i,o[1]+=s,o[2]+=a,o[3]+=c,o[4]+=u,o[5]+=l,o[6]+=p,o[7]+=h}},{"./browserHashUtils":11,"buffer/":80}],16:[function(r,o,e){(function(e){var t=r("./util");t.crypto.lib=r("./browserCryptoLib"),t.Buffer=r("buffer/").Buffer,t.url=r("url/"),t.querystring=r("querystring/"),t.realClock=r("./realclock/browserClock"),t.environment="js",t.createEventStream=r("./event-stream/buffered-create-event-stream").createEventStream,t.isBrowser=function(){return!0},t.isNode=function(){return!1};var n=r("./core");o.exports=n,r("./credentials"),r("./credentials/credential_provider_chain"),r("./credentials/temporary_credentials"),r("./credentials/chainable_temporary_credentials"),r("./credentials/web_identity_credentials"),r("./credentials/cognito_identity_credentials"),r("./credentials/saml_credentials"),n.XML.Parser=r("./xml/browser_parser"),r("./http/xhr"),void 0===e&&(e={browser:!0})}).call(this,r("_process"))},{"./browserCryptoLib":10,"./core":18,"./credentials":19,"./credentials/chainable_temporary_credentials":20,"./credentials/cognito_identity_credentials":21,"./credentials/credential_provider_chain":22,"./credentials/saml_credentials":23,"./credentials/temporary_credentials":24,"./credentials/web_identity_credentials":25,"./event-stream/buffered-create-event-stream":27,"./http/xhr":35,"./realclock/browserClock":52,"./util":71,"./xml/browser_parser":72,_process:85,"buffer/":80,"querystring/":92,"url/":94}],17:[function(e,t,n){var r,i=e("./core");e("./credentials"),e("./credentials/credential_provider_chain"),i.Config=i.util.inherit({constructor:function(n){void 0===n&&(n={}),n=this.extractCredentials(n),i.util.each.call(this,this.keys,function(e,t){this.set(e,n[e],t)})},getCredentials:function(t){var e,n=this;function r(e){t(e,e?null:n.credentials)}function o(e,t){return new i.util.error(t||new Error,{code:"CredentialsError",message:e,name:"CredentialsError"})}n.credentials?"function"==typeof n.credentials.get?n.credentials.get(function(e){r(e=e&&o("Could not load credentials from "+n.credentials.constructor.name,e))}):(e=null,n.credentials.accessKeyId&&n.credentials.secretAccessKey||(e=o("Missing credentials")),r(e)):n.credentialProvider?n.credentialProvider.resolve(function(e,t){e=e&&o("Could not load credentials from any providers",e),n.credentials=t,r(e)}):r(o("No credentials to load"))},update:function(e,n){n=n||!1,e=this.extractCredentials(e),i.util.each.call(this,e,function(e,t){(n||Object.prototype.hasOwnProperty.call(this.keys,e)||i.Service.hasService(e))&&this.set(e,t)})},loadFromPath:function(e){this.clear();var n=JSON.parse(i.util.readFileSync(e)),t=new i.FileSystemCredentials(e),r=new i.CredentialProviderChain;return r.providers.unshift(t),r.resolve(function(e,t){if(e)throw e;n.credentials=t}),this.constructor(n),this},clear:function(){i.util.each.call(this,this.keys,function(e){delete this[e]}),this.set("credentials",void 0),this.set("credentialProvider",void 0)},set:function(e,t,n){void 0===t?(void 0===n&&(n=this.keys[e]),this[e]="function"==typeof n?n.call(this):n):"httpOptions"===e&&this[e]?this[e]=i.util.merge(this[e],t):this[e]=t},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:void 0,httpOptions:{timeout:12e4},maxRetries:void 0,maxRedirects:10,paramValidation:!0,sslEnabled:!0,s3ForcePathStyle:!1,s3BucketEndpoint:!1,s3DisableBodySigning:!0,computeChecksums:!0,convertResponseTypes:!0,correctClockSkew:!1,customUserAgent:null,dynamoDbCrc32:!0,systemClockOffset:0,signatureVersion:null,signatureCache:!0,retryDelayOptions:{},useAccelerateEndpoint:!1,clientSideMonitoring:!1,endpointDiscoveryEnabled:!1,endpointCacheSize:1e3,hostPrefixEnabled:!0,stsRegionalEndpoints:null},extractCredentials:function(e){return e.accessKeyId&&e.secretAccessKey&&((e=i.util.copy(e)).credentials=new i.Credentials(e)),e},setPromisesDependency:function(e){null===(r=e)&&"function"==typeof Promise&&(r=Promise);var t=[i.Request,i.Credentials,i.CredentialProviderChain];i.S3&&(t.push(i.S3),i.S3.ManagedUpload&&t.push(i.S3.ManagedUpload)),i.util.addPromises(t,r)},getPromisesDependency:function(){return r}}),i.config=new i.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var r={util:e("./util")};({}).toString(),(t.exports=r).util.update(r,{VERSION:"2.553.0",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},apiLoader:e("./api_loader"),EndpointCache:e("../vendor/endpoint-cache").EndpointCache}),e("./sequential_executor"),e("./service"),e("./config"),e("./http"),e("./event_listeners"),e("./request"),e("./response"),e("./resource_waiter"),e("./signers/request_signer"),e("./param_validator"),r.events=new r.SequentialExecutor,r.util.memoizedProperty(r,"endpointCache",function(){return new r.EndpointCache(r.config.endpointCacheSize)},!0)},{"../vendor/endpoint-cache":103,"./api_loader":9,"./config":17,"./event_listeners":33,"./http":34,"./json/builder":36,"./json/parser":37,"./model/api":38,"./model/operation":40,"./model/paginator":41,"./model/resource_waiter":42,"./model/shape":43,"./param_validator":44,"./protocol/json":46,"./protocol/query":47,"./protocol/rest":48,"./protocol/rest_json":49,"./protocol/rest_xml":50,"./request":55,"./resource_waiter":56,"./response":57,"./sequential_executor":58,"./service":59,"./signers/request_signer":63,"./util":71,"./xml/builder":73}],19:[function(e,t,n){var o=e("./core");o.Credentials=o.util.inherit({constructor:function(e,t,n){var r;o.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof e?(r=e.credentials||e,this.accessKeyId=r.accessKeyId,this.secretAccessKey=r.secretAccessKey,this.sessionToken=r.sessionToken):(this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n)},expiryWindow:15,needsRefresh:function(){var e=o.util.date.getDate().getTime(),t=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&t>this.expireTime)||(this.expired||!this.accessKeyId||!this.secretAccessKey)},get:function(t){var n=this;this.needsRefresh()?this.refresh(function(e){e||(n.expired=!1),t&&t(e)}):t&&t()},refresh:function(e){this.expired=!1,e()},coalesceRefresh:function(e,n){var r=this;1===r.refreshCallbacks.push(e)&&r.load(function(t){o.util.arrayEach(r.refreshCallbacks,function(e){n?e(t):o.util.defer(function(){e(t)})}),r.refreshCallbacks.length=0})},load:function(e){e()}}),o.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=o.util.promisifyMethod("get",e),this.prototype.refreshPromise=o.util.promisifyMethod("refresh",e)},o.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},o.util.addPromises(o.Credentials)},{"./core":18}],20:[function(e,t,n){var i=e("../core"),r=e("../../clients/sts");i.ChainableTemporaryCredentials=i.util.inherit(i.Credentials,{constructor:function(e){i.Credentials.call(this),e=e||{},this.errorCode="ChainableTemporaryCredentialsProviderFailure",this.expired=!0,this.tokenCodeFn=null;var t=i.util.copy(e.params)||{};if(t.RoleArn&&(t.RoleSessionName=t.RoleSessionName||"temporary-credentials"),t.SerialNumber){if(!e.tokenCodeFn||"function"!=typeof e.tokenCodeFn)throw new i.util.error(new Error("tokenCodeFn must be a function when params.SerialNumber is given"),{code:this.errorCode});this.tokenCodeFn=e.tokenCodeFn}var n=i.util.merge({params:t,credentials:e.masterCredentials||i.config.credentials},e.stsConfig||{});this.service=new r(n)},refresh:function(e){this.coalesceRefresh(e||i.util.fn.callback)},load:function(r){var o=this,i=o.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode(function(e,t){var n={};e?r(e):(t&&(n.TokenCode=t),o.service[i](n,function(e,t){e||o.service.credentialsFrom(t,o),r(e)}))})},getTokenCode:function(r){var o=this;this.tokenCodeFn?this.tokenCodeFn(this.service.config.params.SerialNumber,function(e,t){if(e){var n=e;return e instanceof Error&&(n=e.message),void r(i.util.error(new Error("Error fetching MFA token: "+n),{code:o.errorCode}))}r(null,t)}):r(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var r=e("../core"),o=e("../../clients/cognitoidentity"),i=e("../../clients/sts");r.CognitoIdentityCredentials=r.util.inherit(r.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=r.util.copy(t||{}),this.loadCachedId();var n=this;Object.defineProperty(this,"identityId",{get:function(){return n.loadCachedId(),n._identityId||n.params.IdentityId},set:function(e){n._identityId=e}})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(t){var n=this;n.createClients(),n.data=null,n._identityId=null,n.getId(function(e){e?(n.clearIdOnNotAuthorized(e),t(e)):n.params.RoleArn?n.getCredentialsFromSTS(t):n.getCredentialsForIdentity(t)})},clearCachedId:function(){this._identityId=null,delete this.params.IdentityId;var e=this.params.IdentityPoolId,t=this.params.LoginId||"";delete this.storage[this.localStorageKey.id+e+t],delete this.storage[this.localStorageKey.providers+e+t]},clearIdOnNotAuthorized:function(e){"NotAuthorizedException"==e.code&&this.clearCachedId()},getId:function(n){var r=this;if("string"==typeof r.params.IdentityId)return n(null,r.params.IdentityId);r.cognito.getId(function(e,t){!e&&t.IdentityId?(r.params.IdentityId=t.IdentityId,n(null,t.IdentityId)):n(e)})},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(n){var r=this;r.cognito.getCredentialsForIdentity(function(e,t){e?r.clearIdOnNotAuthorized(e):(r.cacheId(t),r.data=t,r.loadCredentials(r.data,r)),n(e)})},getCredentialsFromSTS:function(n){var r=this;r.cognito.getOpenIdToken(function(e,t){e?(r.clearIdOnNotAuthorized(e),n(e)):(r.cacheId(t),r.params.WebIdentityToken=t.Token,r.webIdentityCredentials.refresh(function(e){e||(r.data=r.webIdentityCredentials.data,r.sts.credentialsFrom(r.data,r)),n(e)}))})},loadCachedId:function(){var e,t,n=this;r.util.isBrowser()&&!n.params.IdentityId&&((e=n.getStorage("id"))&&n.params.Logins?(t=Object.keys(n.params.Logins),0!==(n.getStorage("providers")||"").split(",").filter(function(e){return-1!==t.indexOf(e)}).length&&(n.params.IdentityId=e)):e&&(n.params.IdentityId=e))},createClients:function(){var e,t=this._clientConfig;this.webIdentityCredentials=this.webIdentityCredentials||new r.WebIdentityCredentials(this.params,t),this.cognito||((e=r.util.merge({},t)).params=this.params,this.cognito=new o(e)),this.sts=this.sts||new i(t)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,r.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+(this.params.LoginId||"")]},setStorage:function(e,t){try{this.storage[this.localStorageKey[e]+this.params.IdentityPoolId+(this.params.LoginId||"")]=t}catch(e){}},storage:function(){try{var e=r.util.isBrowser()&&null!==window.localStorage&&"object"==typeof window.localStorage?window.localStorage:{};return e["aws.test-storage"]="foobar",delete e["aws.test-storage"],e}catch(e){return{}}}()})},{"../../clients/cognitoidentity":7,"../../clients/sts":8,"../core":18}],22:[function(e,t,n){var a=e("../core");a.CredentialProviderChain=a.util.inherit(a.Credentials,{constructor:function(e){this.providers=e||a.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var o,i,s=this;if(0===s.providers.length)return e(new Error("No providers")),s;return 1===s.resolveCallbacks.push(e)&&(o=0,i=s.providers.slice(0),function t(n,r){if(!n&&r||o===i.length)return a.util.arrayEach(s.resolveCallbacks,function(e){e(n,r)}),void(s.resolveCallbacks.length=0);var e=i[o++];(r="function"==typeof e?e.call():e).get?r.get(function(e){t(e,e?null:r)}):t(null,r)}()),s}}),a.CredentialProviderChain.defaultProviders=[],a.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=a.util.promisifyMethod("resolve",e)},a.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},a.util.addPromises(a.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.SAMLCredentials=r.util.inherit(r.Credentials,{constructor:function(e){r.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.service.assumeRoleWithSAML(function(e,t){e||r.service.credentialsFrom(t,r),n(e)})},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.TemporaryCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.loadMasterCredentials(t),this.expired=!0,this.params=e||{},this.params.RoleArn&&(this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials")},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.masterCredentials.get(function(){r.service.config.credentials=r.masterCredentials,(r.params.RoleArn?r.service.assumeRole:r.service.getSessionToken).call(r.service,function(e,t){e||r.service.credentialsFrom(t,r),n(e)})})},loadMasterCredentials:function(e){for(this.masterCredentials=e||r.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new r.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new o({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var r=e("../core"),o=e("../../clients/sts");r.WebIdentityCredentials=r.util.inherit(r.Credentials,{constructor:function(e,t){r.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=r.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||r.util.fn.callback)},load:function(n){var r=this;r.createClients(),r.service.assumeRoleWithWebIdentity(function(e,t){r.data=null,e||(r.data=t,r.service.credentialsFrom(t,r)),n(e)})},createClients:function(){var e;this.service||((e=r.util.merge({},this._clientConfig)).params=this.params,this.service=new o(e))}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){(function(i){var p=e("./core"),h=e("./util"),s=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function f(e){var t=e.service,n=t.api||{},r={};return t.config.region&&(r.region=t.config.region),n.serviceId&&(r.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(r.accessKeyId=t.config.credentials.accessKeyId),r}function d(e,t){var n={};return function r(o,i,s){s&&null!=i&&"structure"===s.type&&s.required&&0=this.HEADERS_RECEIVED&&!u&&(s.statusCode=c.status,s.headers=o.parseHeaders(c.getAllResponseHeaders()),s.emit("headers",s.statusCode,s.headers,c.statusText),u=!0),this.readyState===this.DONE&&o.finishRequest(c,s)},!1),c.upload.addEventListener("progress",function(e){s.emit("sendProgress",e)}),c.addEventListener("progress",function(e){s.emit("receiveProgress",e)},!1),c.addEventListener("timeout",function(){r(l.util.error(new Error("Timeout"),{code:"TimeoutError"}))},!1),c.addEventListener("error",function(){r(l.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},!1),c.addEventListener("abort",function(){r(l.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))},!1),n(s),c.open(t.method,a,!1!==e.xhrAsync),l.util.each(t.headers,function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&c.setRequestHeader(e,t)}),e.timeout&&!1!==e.xhrAsync&&(c.timeout=e.timeout),e.xhrWithCredentials&&(c.withCredentials=!0);try{c.responseType="arraybuffer"}catch(e){}try{t.body?c.send(t.body):c.send()}catch(e){if(!t.body||"object"!=typeof t.body.buffer)throw e;c.send(t.body.buffer)}return s},parseHeaders:function(e){var r={};return l.util.arrayEach(e.split(/\r?\n/),function(e){var t=e.split(":",1)[0],n=e.substring(t.length+2);0= 1, but found "'+t+'" for '+n)},validatePattern:function(e,t,n){this.validation.pattern&&void 0!==e.pattern&&(new RegExp(e.pattern).test(t)||this.fail("PatternMatchError",'Provided value "'+t+'" does not match regex pattern /'+e.pattern+"/ for "+n))},validateRange:function(e,t,n,r){this.validation.min&&void 0!==e.min&&t= "+e.min+", but found "+t+" for "+n),this.validation.max&&void 0!==e.max&&t>e.max&&this.fail("MaxRangeError","Expected "+r+" <= "+e.max+", but found "+t+" for "+n)},validateEnum:function(e,t,n){this.validation.enum&&void 0!==e.enum&&-1===e.enum.indexOf(t)&&this.fail("EnumError","Found string value of "+t+", but expected "+e.enum.join("|")+" for "+n)},validateType:function(e,t,n,r){if(null==e)return!1;for(var o=!1,i=0;i=t.maxRetries&&(n.MaxRetriesExceeded=1),u.emit("apiCall",[n]))})},setupRequestListeners:function(){},getSignerClass:function(e){var t,n=null,r="";return e&&(r=(n=(e.service.api.operations||{})[e.operation]||null)?n.authtype:""),t=this.config.signatureVersion?this.config.signatureVersion:"v4"===r||"v4-unsigned-body"===r?"v4":this.api.signatureVersion,l.Signers.RequestSigner.getVersion(t)},serviceInterface:function(){switch(this.api.protocol){case"ec2":case"query":return l.EventListeners.Query;case"json":return l.EventListeners.Json;case"rest-json":return l.EventListeners.RestJson;case"rest-xml":return l.EventListeners.RestXml}if(this.api.protocol)throw new Error("Invalid service `protocol' "+this.api.protocol+" in API config")},successfulResponse:function(e){return e.httpResponse.statusCode<300},numRetries:function(){return void 0!==this.config.maxRetries?this.config.maxRetries:this.defaultRetryCount},retryDelays:function(e){return l.util.calculateRetryDelay(e,this.config.retryDelayOptions)},retryableError:function(e){return!!this.timeoutError(e)||(!!this.networkingError(e)||(!!this.expiredCredentialsError(e)||(!!this.throttledError(e)||500<=e.statusCode)))},networkingError:function(e){return"NetworkingError"===e.code},timeoutError:function(e){return"TimeoutError"===e.code},expiredCredentialsError:function(e){return"ExpiredTokenException"===e.code},clockSkewError:function(e){switch(e.code){case"RequestTimeTooSkewed":case"RequestExpired":case"InvalidSignatureException":case"SignatureDoesNotMatch":case"AuthFailure":case"RequestInTheFuture":return!0;default:return!1}},getSkewCorrectedDate:function(){return new Date(Date.now()+this.config.systemClockOffset)},applyClockOffset:function(e){e&&(this.config.systemClockOffset=e-Date.now())},isClockSkewed:function(e){if(e)return 3e4<=Math.abs(this.getSkewCorrectedDate().getTime()-e)},throttledError:function(e){if(429===e.statusCode)return!0;switch(e.code){case"ProvisionedThroughputExceededException":case"Throttling":case"ThrottlingException":case"RequestLimitExceeded":case"RequestThrottled":case"RequestThrottledException":case"TooManyRequestsException":case"TransactionInProgressException":return!0;default:return!1}},endpointFromTemplate:function(e){if("string"!=typeof e)return e;var t=e;return t=(t=(t=t.replace(/\{service\}/g,this.api.endpointPrefix)).replace(/\{region\}/g,this.config.region)).replace(/\{scheme\}/g,this.config.sslEnabled?"https":"http")},setEndpoint:function(e){this.endpoint=new l.Endpoint(e,this.config)},paginationConfig:function(e,t){var n=this.api.operations[e].paginator;if(n)return n;if(t){var r=new Error;throw l.util.error(r,"No pagination configuration for "+e)}return null}}),l.util.update(l.Service,{defineMethods:function(e){l.util.each(e.prototype.api.operations,function(n){e.prototype[n]||("none"===e.prototype.api.operations[n].authtype?e.prototype[n]=function(e,t){return this.makeUnauthenticatedRequest(n,e,t)}:e.prototype[n]=function(e,t){return this.makeRequest(n,e,t)})})},defineService:function(e,t,n){l.Service._serviceMap[e]=!0,Array.isArray(t)||(n=t,t=[]);var r,o,i,s=a(l.Service,n||{});return"string"==typeof e?(l.Service.addVersions(s,t),r=s.serviceIdentifier||e,s.serviceIdentifier=r):(s.prototype.api=e,l.Service.defineMethods(s)),l.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&l.util.clientSideMonitoring&&(o=l.util.clientSideMonitoring.Publisher,i=(0,l.util.clientSideMonitoring.configProvider)(),this.prototype.publisher=new o(i),i.enabled&&(l.Service._clientSideMonitoring=!0)),l.SequentialExecutor.call(s.prototype),l.Service.addDefaultMonitoringListeners(s.prototype),s},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=n.length)return r.push(null);var t=o+e;t>n.length&&(t=n.length),r.push(n.slice(o,t)),o=t},r},concat:function(e){for(var t,n=0,r=0,o=0;o>>8^t[255&(n^e.readUInt8(r))];return(-1^n)>>>0},hmac:function(e,t,n,r){return"buffer"===(n=n||"binary")&&(n=void 0),r=r||"sha256","string"==typeof t&&(t=l.buffer.toBuffer(t)),l.crypto.lib.createHmac(r,e).update(t).digest(n)},md5:function(e,t,n){return l.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return l.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,r){var o=l.crypto.createHash(e);"buffer"===(n=n||"binary")&&(n=void 0),"string"==typeof t&&(t=l.buffer.toBuffer(t));var i=l.arraySliceFn(t),s=l.Buffer.isBuffer(t);if(l.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(s=!0),r&&"object"==typeof t&&"function"==typeof t.on&&!s)t.on("data",function(e){o.update(e)}),t.on("error",function(e){r(e)}),t.on("end",function(){r(null,o.digest(n))});else{if(!r||!i||s||"undefined"==typeof FileReader){l.isBrowser()&&"object"==typeof t&&!s&&(t=new l.Buffer(new Uint8Array(t)));var a=o.update(t).digest(n);return r&&r(null,a),a}var c=0,u=new FileReader;u.onerror=function(){r(new Error("Failed to read data."))},u.onload=function(){var e=new l.Buffer(new Uint8Array(u.result));o.update(e),c+=e.length,u._continueReading()},u._continueReading=function(){var e;c>=t.size?r(null,o.digest(n)):((e=c+524288)>t.size&&(e=t.size),u.readAsArrayBuffer(i.call(t,c,e)))},u._continueReading()}},toHex:function(e){for(var t=[],n=0;n/g,">").replace(/"/g,""")}}},{}],75:[function(e,t,n){t.exports={escapeElement:function(e){return e.replace(/&/g,"&").replace(//g,">")}}},{}],76:[function(e,t,n){var a=e("./escape-attribute").escapeAttribute;function r(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}r.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},r.prototype.addChildNode=function(e){return this.children.push(e),this},r.prototype.removeAttribute=function(e){return delete this.attributes[e],this},r.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,r=0,o=Object.keys(n);r"+this.children.map(function(e){return e.toString()}).join("")+"":"/>")},t.exports={XmlNode:r}},{"./escape-attribute":74}],77:[function(e,t,n){var r=e("./escape-element").escapeElement;function o(e){this.value=e}o.prototype.toString=function(){return r(""+this.value)},t.exports={XmlText:o}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=p(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=p(e),o=r[0],i=r[1],s=new l(function(e,t){return 3*(e+t)/4-t}(o,i)),a=0,c=0>16&255,s[a++]=t>>8&255,s[a++]=255&t;2===i&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,s[a++]=255&t);1===i&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,s[a++]=t>>8&255,s[a++]=255&t);return s},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,o=[],i=0,s=n-r;i>18&63]+a[e>>12&63]+a[e>>6&63]+a[63&e]}(r));return o.join("")}(e,i,s>2]+a[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],o.push(a[t>>10]+a[t>>4&63]+a[t<<2&63]+"="));return o.join("")};for(var a=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,i=r.length;o=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function f(e,t){if(p.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return N(e).length;default:if(r)return k(e).length;t=(""+t).toLowerCase(),r=!0}}function t(e,t,n){var r,o,i,s=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return function(e,t,n){var r=e.length;(!t||t<0)&&(t=0);(!n||n<0||r=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=p.from(t,r)),p.isBuffer(t))return 0===t.length?-1:m(e,t,n,r,o);if("number"==typeof t)return t&=255,p.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):m(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,r,o){var i=1,s=e.length,a=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s/=i=2,a/=2,n/=2}function c(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(o)for(var u=-1,l=n;l>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function b(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o>>10&1023|55296),l=56320|1023&l),r.push(l),o+=p}return function(e){var t=e.length;if(t<=E)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rt&&(e+=" ... ")),""},p.prototype.compare=function(e,t,n,r,o){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(o<=r&&n<=t)return 0;if(o<=r)return-1;if(n<=t)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),c=this.slice(r,o),u=e.slice(t,n),l=0;lthis.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var i,s,a,c,u,l,p=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var o=e.length-n;(!r||o<(r=Number(r)))&&(r=o);var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");i/2e.length)throw new RangeError("Index out of range")}function T(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function w(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function _(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,r,o){return o||_(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function I(e,t,n,r,o){return o||_(e,0,n,8),i.write(e,t,n,r,52,8),n+8}p.prototype.slice=function(e,t){var n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):n>>8):T(this,e,t,!0),t+2},p.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,65535,0),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},p.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),p.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):w(this,e,t,!0),t+4},p.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,4294967295,0),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},p.prototype.writeIntLE=function(e,t,n,r){var o;e=+e,t|=0,r||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},p.prototype.writeIntBE=function(e,t,n,r){var o;e=+e,t|=0,r||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var i=n-1,s=1,a=0;for(this[t+i]=255&e;0<=--i&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},p.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,1,127,-128),p.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},p.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),p.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):T(this,e,t,!0),t+2},p.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,2,32767,-32768),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):T(this,e,t,!1),t+2},p.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),p.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},p.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),p.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):w(this,e,t,!1),t+4},p.prototype.writeFloatLE=function(e,t,n){return A(this,e,t,!0,n)},p.prototype.writeFloatBE=function(e,t,n){return A(this,e,t,!1,n)},p.prototype.writeDoubleLE=function(e,t,n){return I(this,e,t,!0,n)},p.prototype.writeDoubleBE=function(e,t,n){return I(this,e,t,!1,n)},p.prototype.copy=function(e,t,n,r){if(n=n||0,r||0===r||(r=this.length),t>=e.length&&(t=e.length),t=t||0,0=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(a=t;a>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function N(e){return a.toByteArray(function(e){var t;if((e=((t=e).trim?t.trim():t.replace(/^\s+|\s+$/g,"")).replace(R,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function x(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O("buffer").Buffer)},{"base64-js":78,buffer:80,ieee754:82,isarray:83}],81:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function c(e){return"function"==typeof e}function u(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}((t.exports=r).EventEmitter=r).prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,o,i,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||u(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var a=new Error('Uncaught, unspecified "error" event. ('+t+")");throw a.context=t,a}if(l(n=this._events[e]))return!1;if(c(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(u(n))for(o=Array.prototype.slice.call(arguments,1),r=(s=n.slice()).length,i=0;in&&(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()),this},r.prototype.once=function(e,t){if(!c(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,o,i;if(!c(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(o=(n=this._events[e]).length,r=-1,n===t||c(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(u(n)){for(i=o;0>1,l=-7,p=n?o-1:0,h=n?-1:1,f=e[t+p];for(p+=h,i=f&(1<<-l)-1,f>>=-l,l+=a;0>=-l,l+=r;0>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),2<=(t+=1<=s+p?h/c:h*Math.pow(2,1-p))*c&&(s++,c/=2),l<=s+p?(a=0,s=l):1<=s+p?(a=(t*c-1)*Math.pow(2,o),s+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),s=0));8<=o;e[n+f]=255&a,f+=d,a/=256,o-=8);for(s=s<":!0,"=":!0,"!":!0},F={" ":!0,"\t":!0,"\n":!0};function j(e){return"0"<=e&&e<="9"||"-"===e}function r(){}r.prototype={tokenize:function(e){var t,n,r,o,i=[];for(this._current=0;this._current"===n?"="===e[this._current]?(this._current++,{type:P,value:">=",start:t}):{type:"GT",value:">",start:t}:"="===n&&"="===e[this._current]?(this._current++,{type:"EQ",value:"==",start:t}):void 0},_consumeLiteral:function(e){this._current++;for(var t=this._current,n=e.length;"`"!==e[this._current]&&this._current= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=v-b,w=Math.floor,_=String.fromCharCode;function A(e){throw RangeError(p[e])}function f(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function d(e,t){var n=e.split("@"),r="";return 1>>10&1023|55296),e=56320|1023&e),t+=_(e)}).join("")}function k(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function N(e,t,n){var r=0;for(e=n?w(e/a):e>>1,e+=w(e/t);h*E>>1w((y-f)/i))&&A("overflow"),f+=a*i,!(a<(c=s<=g?b:g+E<=s?E:s-g));s+=v)i>w(y/(u=v-c))&&A("overflow"),i*=u;g=N(f-o,t=p.length+1,0==o),w(f/t)>y-d&&A("overflow"),d+=w(f/t),f%=t,p.splice(f++,0,d)}return R(p)}function m(e){for(var t,n,r,o,i,s,a,c,u,l,p,h=[],f=(e=I(e)).length,d=C,g=S,m=t=0;mw((y-t)/(u=n+1))&&A("overflow"),t+=(o-d)*u,d=o,m=0;my&&A("overflow"),c==d){for(i=t,s=v;!(i<(a=s<=g?b:g+E<=s?E:s-g));s+=v)p=i-a,l=v-a,h.push(_(k(a+p%l,0))),i=w(p/l);h.push(_(k(i,0))),g=N(t,u,n==r),t=0,++n}++t,++d}return h.join("")}if(o={version:"1.3.2",ucs2:{decode:I,encode:R},decode:g,encode:m,toASCII:function(e){return d(e,function(e){return u.test(e)?"xn--"+m(e):e})},toUnicode:function(e){return d(e,function(e){return c.test(e)?g(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return o});else if(t&&n)if(O.exports==t)n.exports=o;else for(i in o)o.hasOwnProperty(i)&&(t[i]=o[i]);else e.punycode=o}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],87:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;var i=/\+/g;e=e.split(t);var s=1e3;r&&"number"==typeof r.maxKeys&&(s=r.maxKeys);var a=e.length;0",'"',"`"," ","\r","\n","\t"]),L=["'"].concat(o),P=["%","/","?",";","#"].concat(L),M=["/","?","#"],D=/^[a-z0-9A-Z_-]{0,63}$/,U=/^([a-z0-9A-Z_-]{0,63})(.*)$/,q={javascript:!0,"javascript:":!0},F={javascript:!0,"javascript:":!0},j={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},B=e("querystring");function i(e,t,n){if(e&&a(e)&&e instanceof v)return e;var r=new v;return r.parse(e,t,n),r}function H(e){return"string"==typeof e}function a(e){return"object"==typeof e&&null!==e}function b(e){return null===e}v.prototype.parse=function(e,t,n){if(!H(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r,o,i=(i=e).trim(),s=O.exec(i);if(s&&(r=(s=s[0]).toLowerCase(),this.protocol=r,i=i.substr(s.length)),(n||s||i.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(o="//"===i.substr(0,2))||s&&F[s]||(i=i.substr(2),this.slashes=!0)),!F[s]&&(o||s&&!j[s])){for(var a,c,u=-1,l=0;l>>((3&t)<<3)&255;return o})},{}],101:[function(e,t,n){var d,g,m=e("./lib/rng"),y=e("./lib/bytesToUuid"),v=0,b=0;t.exports=function(e,t,n){var r,o=t&&n||0,i=t||[],s=(e=e||{}).node||d,a=void 0!==e.clockseq?e.clockseq:g;null!=s&&null!=a||(r=m(),null==s&&(s=d=[1|r[0],r[1],r[2],r[3],r[4],r[5]]),null==a&&(a=g=16383&(r[6]<<8|r[7])));var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:b+1,l=c-v+(u-b)/1e4;if(l<0&&void 0===e.clockseq&&(a=a+1&16383),(l<0||v>>24&255,i[o++]=p>>>16&255,i[o++]=p>>>8&255,i[o++]=255&p;var h=c/4294967296*1e4&268435455;i[o++]=h>>>8&255,i[o++]=255&h,i[o++]=h>>>24&15|16,i[o++]=h>>>16&255,i[o++]=a>>>8|128,i[o++]=255&a;for(var f=0;f<6;++f)i[o+f]=s[f];return t||y(i)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var s=e("./lib/rng"),a=e("./lib/bytesToUuid");t.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||s)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var i=0;i<16;++i)t[r+i]=o[i];return t||a(o)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e("./utils/LRU"),o=(Object.defineProperty(i.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),i.prototype.put=function(e,t){var n="string"!=typeof e?i.getKeyString(e):e,r=this.populateValue(t);this.cache.put(n,r)},i.prototype.get=function(e){var t="string"!=typeof e?i.getKeyString(e):e,n=Date.now(),r=this.cache.get(t);if(r)for(var o=0;o>>=0;break;case"x":r=r.toString(16);break;case"X":r=r.toString(16).toUpperCase()}r=/[def]/.test(i[8])&&i[3]&&0<=r?"+"+r:r,a=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",c=i[6]-String(r).length,s=i[6]?function(e,t){for(var n=[];0=this._logLevel&&(c[e.level]>=this._echoLevel&&r[e.getLevel()](e.toString()),e.line=this._lineCount++)},u.prototype.clearObjects=function(){for(var e=0;e=r._logLevel}));var i=new a.Blob([JSON.stringify(o,void 0,4)],["text/plain"]),s=document.createElement("a"),t=t||"agent-log";s.href=a.URL.createObjectURL(i),s.download=t+".txt",document.body.appendChild(s),s.click(),document.body.removeChild(s)},u.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,a.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},u.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,function(){0=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout(function(){t(--n)},s):o(e)}).catch(function(e){o(e)})}(t)})},connect.backoff=function(r,o,i,s){connect.assertTrue(connect.isFunction(r),"func must be a Function");var a=this;r({success:function(e){s&&s.success&&s.success(e)},failure:function(e,t){var n;0>",e)},u.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},u.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var r=this,e=this.subMap.getSubscriptions("<>"),o=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&connect.getLog().trace("Publishing event: %s",t),e.concat(o).forEach(function(e){try{e.f(n||null,t,r)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e)}})},u.prototype.bridge=function(){var n=this;return function(e,t){n.trigger(t,e)}},u.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach(function(e){e.unsubscribe()})},connect.EventBus=u,connect.EventFactory=e,connect.EventType=t,connect.AgentEvents=r,connect.ConnnectionEvents=s,connect.ContactEvents=i,connect.WebSocketEvents=o,connect.MasterTopics=n}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;function r(){}r.prototype.send=function(e){throw new connect.NotImplementedError},r.prototype.onMessage=function(e){throw new connect.NotImplementedError};function o(){r.call(this)}((o.prototype=Object.create(r.prototype)).constructor=o).prototype.onMessage=function(e){},o.prototype.send=function(e){};function e(e,t){r.call(this),this.window=e,this.domain=t||"*"}((e.prototype=Object.create(r.prototype)).constructor=e).prototype.send=function(e){this.window.postMessage(e,this.domain)},e.prototype.onMessage=function(e){this.window.addEventListener("message",e)};function i(e,t,n){r.call(this),this.input=e,this.output=t,this.domain=n||"*"}((i.prototype=Object.create(r.prototype)).constructor=i).prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(e){this.input.addEventListener("message",e)};function t(e){r.call(this),this.port=e,this.id=connect.randomId()}((t.prototype=Object.create(r.prototype)).constructor=t).prototype.send=function(e){this.port.postMessage(e)},t.prototype.onMessage=function(e){this.port.addEventListener("message",e)},t.prototype.getId=function(){return this.id};function n(e){r.call(this),this.streamMap=e?connect.index(e,function(e){return e.getId()}):{},this.messageListeners=[]}((n.prototype=Object.create(r.prototype)).constructor=n).prototype.send=function(t){this.getStreams().forEach(function(e){try{e.send(t)}catch(e){}})},n.prototype.onMessage=function(t){this.messageListeners.push(t),this.getStreams().forEach(function(e){e.onMessage(t)})},n.prototype.addStream=function(t){this.streamMap[t.getId()]=t,this.messageListeners.forEach(function(e){t.onMessage(e)})},n.prototype.removeStream=function(e){delete this.streamMap[e.getId()]},n.prototype.getStreams=function(e){return connect.values(this.streamMap)},n.prototype.getStreamForPort=function(t){return connect.find(this.getStreams(),function(e){return e.port===t})};function s(e,t,n){this.name=e,this.upstream=t||new o,this.downstream=n||new o,this.downstreamBus=new connect.EventBus,this.upstreamBus=new connect.EventBus,this.upstream.onMessage(connect.hitch(this,this._dispatchEvent,this.upstreamBus)),this.downstream.onMessage(connect.hitch(this,this._dispatchEvent,this.downstreamBus))}s.prototype.onUpstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.upstreamBus.subscribe(e,t)},s.prototype.onAllUpstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.upstreamBus.subscribeAll(e)},s.prototype.onDownstream=function(e,t){return connect.assertNotNull(e,"eventName"),connect.assertNotNull(t,"f"),connect.assertTrue(connect.isFunction(t),"f must be a function"),this.downstreamBus.subscribe(e,t)},s.prototype.onAllDownstream=function(e){return connect.assertNotNull(e,"f"),connect.assertTrue(connect.isFunction(e),"f must be a function"),this.downstreamBus.subscribeAll(e)},s.prototype.sendUpstream=function(e,t){connect.assertNotNull(e,"eventName"),this.upstream.send({event:e,data:t})},s.prototype.sendDownstream=function(e,t){connect.assertNotNull(e,"eventName"),this.downstream.send({event:e,data:t})},s.prototype._dispatchEvent=function(e,t){var n=t.data;n.event&&e.trigger(n.event,n.data)},s.prototype.passUpstream=function(){var n=this;return function(e,t){n.upstream.send({event:t,data:e})}},s.prototype.passDownstream=function(){var n=this;return function(e,t){n.downstream.send({event:t,data:e})}},s.prototype.shutdown=function(){this.upstreamBus.unsubscribeAll(),this.downstreamBus.unsubscribeAll()};function a(e,t,n,r){s.call(this,e,new i(t,n.contentWindow,r||"*"),null)}(a.prototype=Object.create(s.prototype)).constructor=a,connect.Stream=r,connect.NullStream=o,connect.WindowStream=e,connect.WindowIOStream=i,connect.PortStream=t,connect.StreamMultiplexer=n,connect.Conduit=s,connect.IFrameConduit=a}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect,connect.ClientMethods=connect.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","clearContact","completeContact","destroyContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport"]),connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);function i(){}i.EMPTY_CALLBACKS={success:function(){},failure:function(){}},i.prototype.call=function(e,t,n){connect.assertNotNull(e,"method");var r=t||{},o=n||i.EMPTY_CALLBACKS;this._callImpl(e,r,o)},i.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};function e(){i.call(this)}((e.prototype=Object.create(i.prototype)).constructor=e).prototype._callImpl=function(e,t,n){var r;n&&n.failure&&(r=connect.sprintf("No such method exists on NULL client: %s",e),n.failure(new connect.ValueError(r),{message:r}))};function t(e,t,n){i.call(this),this.conduit=e,this.requestEvent=t,this.responseEvent=n,this._requestIdCallbacksMap={},this.conduit.onUpstream(n,connect.hitch(this,this._handleResponse))}((t.prototype=Object.create(i.prototype)).constructor=t).prototype._callImpl=function(e,t,n){var r=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[r.requestId]=n,this.conduit.sendUpstream(r.event,r)},t.prototype._getCallbacksForRequest=function(e){var t=this._requestIdCallbacksMap[e]||null;return null!=t&&delete this._requestIdCallbacksMap[e],t},t.prototype._handleResponse=function(e){var t=this._getCallbacksForRequest(e.requestId);null!=t&&(e.err&&t.failure?t.failure(e.err,e.data):t.success&&t.success(e.data))};function n(e){t.call(this,e,connect.EventType.API_REQUEST,connect.EventType.API_RESPONSE)}(n.prototype=Object.create(t.prototype)).constructor=n;function r(e){t.call(this,e,connect.EventType.MASTER_REQUEST,connect.EventType.MASTER_RESPONSE)}(r.prototype=Object.create(t.prototype)).constructor=r;function o(e,t,n){connect.assertNotNull(e,"authToken"),connect.assertNotNull(t,"region"),i.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=t,this.authToken=e;var r=n||connect.getBaseUrl()+"/connect/api",o=new AWS.Endpoint(r);this.client=new AWS.Connect({endpoint:o})}((o.prototype=Object.create(i.prototype)).constructor=o).prototype._callImpl=function(r,e,o){var t,n=this,i=connect.getLog();connect.contains(this.client,r)?(e=this._translateParams(r,e),i.trace("AWSClient: --\x3e Calling operation '%s'",r),this.client[r](e).on("build",function(e){e.httpRequest.headers["X-Amz-Bearer"]=n.authToken}).send(function(e,t){try{var n;e?(e.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION?o.authFailure():!o.accessDenied||e.code!==connect.CTIExceptions.ACCESS_DENIED_EXCEPTION&&403!==e.statusCode?((n={}).type=e.code,n.message=e.message,n.stack=e.stack?e.stack.split("\n"):[],o.failure(n,t)):o.accessDenied(),i.trace("AWSClient: <-- Operation '%s' failed: %s",r,JSON.stringify(e))):(i.trace("AWSClient: <-- Operation '%s' succeeded.",r).withObject(t),o.success(t))}catch(e){connect.getLog().error("Failed to handle AWS API request for method %s",r).withException(e)}})):(t=connect.sprintf("No such method exists on AWS client: %s",r),o.failure(new connect.ValueError(t),{message:t}))},o.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT},o.prototype._translateParams=function(e,t){switch(e){case connect.ClientMethods.UPDATE_AGENT_CONFIGURATION:t.configuration=this._translateAgentConfiguration(t.configuration);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS:t.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(t.softphoneStreamStatistics);break;case connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT:t.report=this._translateSoftphoneCallReport(t.report)}return this._requiresAuthenticationParam(e)&&(t.authentication={authToken:this.authToken}),t},o.prototype._translateAgentConfiguration=function(e){return{name:e.name,softphoneEnabled:e.softphoneEnabled,softphoneAutoAccept:e.softphoneAutoAccept,extension:e.extension,routingProfile:this._translateRoutingProfile(e.routingProfile),agentPreferences:e.agentPreferences}},o.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},o.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},o.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach(function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)}),e},o.prototype._translateSoftphoneCallReport=function(e){return"handshakingTimeMillis"in e&&(e.handshakeTimeMillis=e.handshakingTimeMillis,delete e.handshakingTimeMillis),"preTalkingTimeMillis"in e&&(e.preTalkTimeMillis=e.preTalkingTimeMillis,delete e.preTalkingTimeMillis),"handshakingFailure"in e&&(e.handshakeFailure=e.handshakingFailure,delete e.handshakingFailure),"talkingTimeMillis"in e&&(e.talkTimeMillis=e.talkingTimeMillis,delete e.talkingTimeMillis),e.softphoneStreamStatistics=this._translateSoftphoneStreamStatistics(e.softphoneStreamStatistics),e},connect.ClientBase=i,connect.NullClient=e,connect.UpstreamConduitClient=n,connect.UpstreamConduitMasterClient=r,connect.AWSClient=o}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;function r(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t}r.prototype.getAssociations=function(e){throw connect.NotImplementedError()},r.prototype.getFromState=function(){return this.fromState},r.prototype.getToState=function(){return this.toState};function e(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"associations"),r.call(this,e,t),this.associations=n}((e.prototype=Object.create(r.prototype)).constructor=e).prototype.getAssociations=function(e){return this.associations};function i(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"closure"),connect.assertTrue(connect.isFunction(n),"closure must be a function"),r.call(this,e,t),this.closure=n}((i.prototype=Object.create(r.prototype)).constructor=i).prototype.getAssociations=function(e){return this.closure(e,this.getFromState(),this.getToState())};function s(){this.fromMap={}}s.ANY="<>",s.prototype.assoc=function(t,n,r){var o=this;if(!t)throw new Error("fromStateObj is not defined.");if(!n)throw new Error("toStateObj is not defined.");if(!r)throw new Error("assocObj is not defined.");return t instanceof Array?t.forEach(function(e){o.assoc(e,n,r)}):n instanceof Array?n.forEach(function(e){o.assoc(t,e,r)}):"function"==typeof r?this._addAssociation(new i(t,n,r)):r instanceof Array?this._addAssociation(new e(t,n,r)):this._addAssociation(new e(t,n,[r])),this},s.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var r=[],o=this.fromMap[s.ANY]||{},i=this.fromMap[t]||{};return r=(r=r.concat(this._getAssociationsFromMap(o,e,t,n))).concat(this._getAssociationsFromMap(i,e,t,n))},s.prototype._addAssociation=function(e){var t=this.fromMap[e.getFromState()];((t=t||(this.fromMap[e.getFromState()]={}))[e.getToState()]||(t[e.getToState()]=[])).push(e)},s.prototype._getAssociationsFromMap=function(e,n,t,r){return(e[s.ANY]||[]).concat(e[r]||[]).reduce(function(e,t){return e.concat(t.getAssociations(n))},[])},connect.EventGraph=s}(),function(){var n=this;connect=n.connect||{},n.connect=connect,n.lily=connect,connect.AgentStateType=connect.makeEnum(["init","routable","not_routable","offline"]),connect.AgentStatusType=connect.AgentStateType,connect.AgentAvailStates=connect.makeEnum(["Init","Busy","AfterCallWork","CallingCustomer","Dialing","Joining","PendingAvailable","PendingBusy"]),connect.AgentErrorStates=connect.makeEnum(["Error","AgentHungUp","BadAddressAgent","BadAddressCustomer","Default","FailedConnectAgent","FailedConnectCustomer","LineEngagedAgent","LineEngagedCustomer","MissedCallAgent","MissedCallCustomer","MultipleCcpWindows","RealtimeCommunicationError"]),connect.EndpointType=connect.makeEnum(["phone_number","agent","queue"]),connect.AddressType=connect.EndpointType,connect.ConnectionType=connect.makeEnum(["agent","inbound","outbound","monitoring"]),connect.ConnectionStateType=connect.makeEnum(["init","connecting","connected","hold","disconnected"]),connect.ConnectionStatusType=connect.ConnectionStateType,connect.CONNECTION_ACTIVE_STATES=connect.set([connect.ConnectionStateType.CONNECTING,connect.ConnectionStateType.CONNECTED,connect.ConnectionStateType.HOLD]),connect.ContactStateType=connect.makeEnum(["init","incoming","pending","connecting","connected","missed","error","ended"]),connect.ContactStatusType=connect.ContactStateType,connect.CONTACT_ACTIVE_STATES=connect.makeEnum(["incoming","pending","connecting","connected"]),connect.ContactType=connect.makeEnum(["voice","queue_callback","chat"]),connect.ChannelType=connect.makeEnum(["VOICE","CHAT"]),connect.MediaType=connect.makeEnum(["softphone","chat"]),connect.SoftphoneCallType=connect.makeEnum(["audio_video","video_only","audio_only","none"]),connect.SoftphoneErrorTypes=connect.makeEnum(["unsupported_browser","microphone_not_shared","signalling_handshake_failure","signalling_connection_failure","ice_collection_timeout","user_busy_error","webrtc_error","realtime_communication_error","other"]),connect.CTIExceptions=connect.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException"]);function e(){if(!connect.agent.initialized)throw new connect.StateError("The agent is not yet initialized!")}e.prototype._getData=function(){return connect.core.getAgentDataProvider().getAgentData()},e.prototype._createContactAPI=function(e){return new connect.Contact(e.contactId)},e.prototype.onContactPending=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.CONTACT_PENDING,e)},e.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.REFRESH,e)},e.prototype.onRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ROUTABLE,e)},e.prototype.onNotRoutable=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.NOT_ROUTABLE,e)},e.prototype.onOffline=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.OFFLINE,e)},e.prototype.onError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ERROR,e)},e.prototype.onSoftphoneError=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.SOFTPHONE_ERROR,e)},e.prototype.onWebSocketConnectionLost=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e)},e.prototype.onWebSocketConnectionGained=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED,e)},e.prototype.onAfterCallWork=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ACW,e)},e.prototype.onStateChange=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.STATE_CHANGE,e)},e.prototype.onMuteToggle=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.MUTE_TOGGLE,e)},e.prototype.mute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!0}})},e.prototype.unmute=function(){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.EventType.MUTE,data:{mute:!1}})},e.prototype.getState=function(){return this._getData().snapshot.state},e.prototype.getAvailabilityState=function(){return this._getData().snapshot.agentAvailabilityState},e.prototype.getStatus=e.prototype.getState,e.prototype.getStatusDuration=e.prototype.getStateDuration=function(){return connect.now()-this._getData().snapshot.state.startTimestamp.getTime()+connect.core.getSkew()},e.prototype.getPermissions=function(){return this.getConfiguration().permissions},e.prototype.getContacts=function(t){var n=this;return this._getData().snapshot.contacts.map(function(e){return n._createContactAPI(e)}).filter(function(e){return!t||e.getType()===t})},e.prototype.getConfiguration=function(){return this._getData().configuration},e.prototype.getAgentStates=function(){return this.getConfiguration().agentStates},e.prototype.getRoutingProfile=function(){return this.getConfiguration().routingProfile},e.prototype.getChannelConcurrency=function(e){var t=(t=this.getRoutingProfile().channelConcurrencyMap)||Object.keys(connect.ChannelType).reduce(function(e,t){return e[connect.ChannelType[t]]=1,e},{});return e?t[e]||0:t},e.prototype.getName=function(){return this.getConfiguration().name},e.prototype.getExtension=function(){return this.getConfiguration().extension},e.prototype.getDialableCountries=function(){return this.getConfiguration().dialableCountries},e.prototype.isSoftphoneEnabled=function(){return this.getConfiguration().softphoneEnabled},e.prototype.setConfiguration=function(e,t){connect.core.getClient().call(connect.ClientMethods.UPDATE_AGENT_CONFIGURATION,{configuration:connect.assertNotNull(e,"configuration")},{success:function(e){connect.core.getUpstream().sendUpstream(connect.EventType.RELOAD_AGENT_CONFIGURATION),t.success&&t.success(e)},failure:t&&t.failure})},e.prototype.setStatus=e.prototype.setState=function(e,t){connect.core.getClient().call(connect.ClientMethods.PUT_AGENT_STATE,{state:connect.assertNotNull(e,"state")},t)},e.prototype.connect=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:connect.assertNotNull(r,"endpoint"),queueARN:t&&(t.queueARN||t.queueId)||this.getRoutingProfile().defaultOutboundQueue.queueARN},t&&{success:t.success,failure:t.failure})},e.prototype.getAllQueueARNs=function(){return this.getConfiguration().routingProfile.queues.map(function(e){return e.queueARN})},e.prototype.getAddresses=e.prototype.getEndpoints=function(n,r,e){var o=this,t=connect.core.getClient();connect.assertNotNull(r,"callbacks"),connect.assertNotNull(r.success,"callbacks.success");var i=e||{};i.endpoints=i.endpoints||[],i.maxResults=i.maxResults||connect.DEFAULT_BATCH_SIZE,connect.isArray(n)||(n=[n]),t.call(connect.ClientMethods.GET_ENDPOINTS,{queueARNs:n,nextToken:i.nextToken||null,maxResults:i.maxResults},{success:function(e){var t;e.nextToken?o.getEndpoints(n,r,{nextToken:e.nextToken,maxResults:i.maxResults,endpoints:i.endpoints.concat(e.endpoints)}):(i.endpoints=i.endpoints.concat(e.endpoints),t=i.endpoints.map(function(e){return new connect.Endpoint(e)}),r.success({endpoints:t,addresses:t}))},failure:r.failure})},e.prototype.toSnapshot=function(){return new connect.AgentSnapshot(this._getData())};function t(e){connect.Agent.call(this),this.agentData=e}((t.prototype=Object.create(e.prototype)).constructor=t).prototype._getData=function(){return this.agentData},t.prototype._createContactAPI=function(e){return new connect.ContactSnapshot(e)};function r(e){this.contactId=e}r.prototype._getData=function(){return connect.core.getAgentDataProvider().getContactData(this.getContactId())},r.prototype._createConnectionAPI=function(e){return this.getType()===connect.ContactType.CHAT?new connect.ChatConnection(this.contactId,e.connectionId):new connect.VoiceConnection(this.contactId,e.connectionId)},r.prototype.getEventName=function(e){return connect.core.getContactEventName(e,this.getContactId())},r.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.REFRESH),e)},r.prototype.onIncoming=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.INCOMING),e)},r.prototype.onConnecting=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTING),e)},r.prototype.onPending=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.PENDING),e)},r.prototype.onAccepted=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACCEPTED),e)},r.prototype.onMissed=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.MISSED),e)},r.prototype.onEnded=function(e){var t=connect.core.getEventBus();t.subscribe(this.getEventName(connect.ContactEvents.ENDED),e),t.subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},r.prototype.onDestroy=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},r.prototype.onACW=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACW),e)},r.prototype.onConnected=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTED),e)},r.prototype.getContactId=function(){return this.contactId},r.prototype.getInitialContactId=r.prototype.getOriginalContactId=function(){return this._getData().initialContactId},r.prototype.getType=function(){return this._getData().type},r.prototype.getContactDuration=function(){return this._getData().contactDuration},r.prototype.getStatus=r.prototype.getState=function(){return this._getData().state},r.prototype.getStatusDuration=r.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},r.prototype.getQueue=function(){return this._getData().queue},r.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},r.prototype.getConnections=function(){var t=this;return this._getData().connections.map(function(e){return t.getType()===connect.ContactType.CHAT?new connect.ChatConnection(t.contactId,e.connectionId):new connect.VoiceConnection(t.contactId,e.connectionId)})},r.prototype.getInitialConnection=function(){return connect.find(this.getConnections(),function(e){return e.isInitialConnection()})||null},r.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},r.prototype.getThirdPartyConnections=function(){return this.getConnections().filter(function(e){return!e.isInitialConnection()&&e.getType()!==connect.ConnectionType.AGENT})},r.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter(function(e){return e.isActive()})[0]||null},r.prototype.getAgentConnection=function(){return connect.find(this.getConnections(),function(e){var t=e.getType();return t===connect.ConnectionType.AGENT||t===connect.ConnectionType.MONITORING})},r.prototype.getAttributes=function(){return this._getData().attributes},r.prototype.isSoftphoneCall=function(){return null!=connect.find(this.getConnections(),function(e){return null!=e.getSoftphoneMediaInfo()})},r.prototype.isInbound=function(){var e=this.getInitialConnection();return!!e&&e.getType()===connect.ConnectionType.INBOUND},r.prototype.isConnected=function(){return this.getStatus().type===connect.ContactStateType.CONNECTED},r.prototype.accept=function(n){var e=connect.core.getClient(),r=this,o=this.getContactId();e.call(connect.ClientMethods.ACCEPT_CONTACT,{contactId:o},{success:function(e){var t=connect.core.getUpstream();t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(o)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,r.getContactId()),data:new connect.Contact(o)}),n&&n.success&&n.success(e)},failure:n?n.failure:null})},r.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONTACT,{contactId:this.getContactId()},e)},r.prototype.complete=function(e){connect.core.getClient().call(connect.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},r.prototype.clear=function(e){connect.core.getClient().call(connect.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},r.prototype.notifyIssue=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:t},n)},r.prototype.addConnection=function(e,t){var n=connect.core.getClient(),r=new connect.Endpoint(e);delete r.endpointId,n.call(connect.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:r},t)},r.prototype.toggleActiveConnections=function(e){var t,n=connect.core.getClient(),r=null,o=connect.find(this.getConnections(),function(e){return e.getStatus().type===connect.ConnectionStateType.HOLD});null!=o?r=o.getConnectionId():0<(t=this.getConnections().filter(function(e){return e.isActive()})).length&&(r=t[0].getConnectionId()),n.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:r},e)},r.prototype.sendSoftphoneMetrics=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,softphoneStreamStatistics:e},t)},r.prototype.sendSoftphoneReport=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e},t)},r.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},r.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};function o(e){connect.Contact.call(this,e.contactId),this.contactData=e}((o.prototype=Object.create(r.prototype)).constructor=o).prototype._getData=function(){return this.contactData},o.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};function i(e,t){this.contactId=e,this.connectionId=t,this._initMediaController()}i.prototype._getData=function(){return connect.core.getAgentDataProvider().getConnectionData(this.getContactId(),this.getConnectionId())},i.prototype.getContactId=function(){return this.contactId},i.prototype.getConnectionId=function(){return this.connectionId},i.prototype.getAddress=i.prototype.getEndpoint=function(){return new connect.Endpoint(this._getData().endpoint)},i.prototype.getStatus=i.prototype.getState=function(){return this._getData().state},i.prototype.getStatusDuration=i.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},i.prototype.getType=function(){return this._getData().type},i.prototype.isInitialConnection=function(){return this._getData().initial},i.prototype.isActive=function(){return connect.contains(connect.CONNECTION_ACTIVE_STATES,this.getStatus().type)},i.prototype.isConnected=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTED},i.prototype.isConnecting=function(){return this.getStatus().type===connect.ConnectionStateType.CONNECTING},i.prototype.isOnHold=function(){return this.getStatus().type===connect.ConnectionStateType.HOLD},i.prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},i.prototype.getMonitorInfo=function(){return this._getData().monitoringInfo},i.prototype.destroy=function(e){connect.core.getClient().call(connect.ClientMethods.DESTROY_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.sendDigits=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_DIGITS,{contactId:this.getContactId(),connectionId:this.getConnectionId(),digits:e},t)},i.prototype.hold=function(e){connect.core.getClient().call(connect.ClientMethods.HOLD_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.resume=function(e){connect.core.getClient().call(connect.ClientMethods.RESUME_CONNECTION,{contactId:this.getContactId(),connectionId:this.getConnectionId()},e)},i.prototype.toSnapshot=function(){return new connect.ConnectionSnapshot(this._getData())},i.prototype._initMediaController=function(){this.getMediaInfo()&&connect.core.mediaFactory.get(this).catch(function(){})},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING},i.prototype._isAgentConnectionType=function(){var e=this.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING};function s(e,t){i.call(this,e,t)}((s.prototype=Object.create(i.prototype)).constructor=s).prototype.getSoftphoneMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaInfo=function(){return this._getData().softphoneMediaInfo},s.prototype.getMediaType=function(){return connect.MediaType.SOFTPHONE},s.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)};function a(e,t){i.call(this,e,t)}((a.prototype=Object.create(i.prototype)).constructor=a).prototype.getMediaInfo=function(){var t=this._getData().chatMediaInfo;if(t){var e=connect.core.getAgentDataProvider().getContactData(this.contactId),n={contactId:this.contactId,initialContactId:e.initialContactId||this.contactId,participantId:this.connectionId,getConnectionToken:connect.hitch(this,this.getConnectionToken)};if(t.connectionData)try{n.participantToken=JSON.parse(t.connectionData).ConnectionAuthenticationToken}catch(e){connect.getLog().error(connect.LogComponent.CHAT,"Connection data is invalid").withObject(t).withException(e),n.participantToken=null}return n.participantToken=n.participantToken||null,n.originalInfo=this._getData().chatMediaInfo,n}return null},a.prototype.getConnectionToken=function(){client=connect.core.getClient();var e=connect.core.getAgentDataProvider().getContactData(this.contactId),r={transportType:connect.TRANSPORT_TYPES.CHAT_TOKEN,participantId:this.connectionId,contactId:e.initialContactId||this.contactId};return new Promise(function(t,n){client.call(connect.ClientMethods.CREATE_TRANSPORT,r,{success:function(e){connect.getLog().info("getConnectionToken succeeded"),t(e)},failure:function(e,t){connect.getLog().error("getConnectionToken failed").withObject({err:e,data:t}),n(Error("getConnectionToken failed"))}})})},a.prototype.getMediaType=function(){return connect.MediaType.CHAT},a.prototype.getMediaController=function(){return connect.core.mediaFactory.get(this)},a.prototype._initMediaController=function(){this._isAgentConnectionType()&&connect.core.mediaFactory.get(this).catch(function(){})};function c(e){connect.Connection.call(this,e.contactId,e.connectionId),this.connectionData=e}((c.prototype=Object.create(i.prototype)).constructor=c).prototype._getData=function(){return this.connectionData},c.prototype._initMediaController=function(){};function u(e){var t=e||{};this.endpointARN=t.endpointId||t.endpointARN||null,this.endpointId=this.endpointARN,this.type=t.type||null,this.name=t.name||null,this.phoneNumber=t.phoneNumber||null,this.agentLogin=t.agentLogin||null,this.queue=t.queue||null}u.prototype.stripPhoneNumber=function(){return this.phoneNumber?this.phoneNumber.replace(/sip:([^@]*)@.*/,"$1"):""},u.byPhoneNumber=function(e,t){return new u({type:connect.EndpointType.PHONE_NUMBER,phoneNumber:e,name:t||null})};function l(e,t,n){this.errorType=e,this.errorMessage=t,this.endPointUrl=n}l.prototype.getErrorType=function(){return this.errorType},l.prototype.getErrorMessage=function(){return this.errorMessage},l.prototype.getEndPointUrl=function(){return this.endPointUrl},connect.agent=function(e){var t=connect.core.getEventBus().subscribe(connect.AgentEvents.INIT,e);return connect.agent.initialized&&e(new connect.Agent),t},connect.agent.initialized=!1,connect.contact=function(e){return connect.core.getEventBus().subscribe(connect.ContactEvents.INIT,e)},connect.onWebsocketInitFailure=function(e){var t=connect.core.getEventBus().subscribe(connect.WebSocketEvents.INIT_FAILURE,e);return connect.webSocketInitFailed&&e(),t},connect.ifMaster=function(e,t,n){if(connect.assertNotNull(e,"A topic must be provided."),connect.assertNotNull(t,"A true callback must be provided."),!connect.core.masterClient)return connect.getLog().warn("We can't be the master for topic '%s' because there is no master client!",e),void(n&&n());connect.core.getMasterClient().call(connect.MasterMethods.CHECK_MASTER,{topic:e},{success:function(e){e.isMaster?t():n&&n()}})},connect.becomeMaster=function(e){connect.assertNotNull(e,"A topic must be provided."),connect.core.getMasterClient().call(connect.MasterMethods.BECOME_MASTER,{topic:e})},connect.Agent=e,connect.AgentSnapshot=t,connect.Contact=r,connect.ContactSnapshot=o,connect.Connection=s,connect.BaseConnection=i,connect.VoiceConnection=s,connect.ChatConnection=a,connect.ConnectionSnapshot=c,connect.Endpoint=u,connect.Address=u,connect.SoftphoneError=l}(),function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=2)}([function(e,t,n){"use strict";var r=n(1);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var i={assertTrue:function(e,t){if(!e)throw new Error(t)},assertNotNull:function(e,t){return i.assertTrue(null!==e&&void 0!==o(e),Object(r.sprintf)("%s must be provided",t||"A value")),e},isNonEmptyString:function(e){return"string"==typeof e&&0=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var t=e.prefix||"";return"DEBUG"===this._logsDestination?this.consoleLoggerWrapper:new y(t)}},{key:"updateLoggerConfig",value:function(e){var t=e||{};this._level=t.level||d.DEBUG,this._clientLogger=t.logger||null,this._logsDestination="NULL",t.debug&&(this._logsDestination="DEBUG"),t.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),S),m=(h(E,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),E),y=(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(b,m),h(b,[{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n>>0).toString(8);break;case"s":n=String(n),n=o.precision?n.substring(0,o.precision):n;break;case"t":n=String(!!n),n=o.precision?n.substring(0,o.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=o.precision?n.substring(0,o.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=o.precision?n.substring(0,o.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}d.json.test(o.type)?h+=n:(!d.number.test(o.type)||c&&!o.sign?u="":(u=c?"+":"-",n=n.toString().replace(d.sign,"")),s=o.pad_char?"0"===o.pad_char?"0":o.pad_char.charAt(1):" ",a=o.width-(u+n).length,i=o.width&&0t.packetsLost?e.packetsLost-t.packetsLost:0,o=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new O(e.timestamp,r,o,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new O(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},x=function(e,t){u=r(u),l=r(l),function(e,t,n,r){t.streamStats=[L(n,i),L(r,s)];var o={callStartTime:t.sessionStartTime,callEndTime:t.sessionEndTime,gumTimeMillis:t.gumTimeMillis,initializationTimeMillis:t.initializationTimeMillis,iceCollectionTimeMillis:t.iceCollectionTimeMillis,signallingConnectTimeMillis:t.signallingConnectTimeMillis,handshakingTimeMillis:t.handshakingTimeMillis,preTalkingTimeMillis:t.preTalkingTimeMillis,talkingTimeMillis:t.talkingTimeMillis,cleanupTimeMillis:t.cleanupTimeMillis,iceCollectionFailure:t.iceCollectionFailure,signallingConnectionFailure:t.signallingConnectionFailure,handshakingFailure:t.handshakingFailure,gumOtherFailure:t.gumOtherFailure,gumTimeoutFailure:t.gumTimeoutFailure,createOfferFailure:t.createOfferFailure,setLocalDescriptionFailure:t.setLocalDescriptionFailure,userBusyFailure:t.userBusyFailure,invalidRemoteSDPFailure:t.invalidRemoteSDPFailure,noRemoteIceCandidateFailure:t.noRemoteIceCandidateFailure,setRemoteDescriptionFailure:t.setRemoteDescriptionFailure,softphoneStreamStatistics:t.streamStats};e.sendSoftphoneReport(o,{success:function(){h.info("sendSoftphoneReport success"+JSON.stringify(o))},failure:function(e){h.error("sendSoftphoneReport failed.").withObject(e)}})}(e,t,L(a,i),L(c,s)),n(e)},O=function(e,t,n,r,o,i,s){this.softphoneStreamType=r,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=o,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},L=function(e,t){return new O((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},P=function(e){this._originalLogger=e;var r=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),t="";e.forEach(function(){t+=" %s"}),n.apply(r._originalLogger,[connect.LogComponent.SOFTPHONE,t].concat(e))}}};P.prototype.debug=function(){this._tee(1,this._originalLogger.debug)(arguments)},P.prototype.info=function(){this._tee(2,this._originalLogger.info)(arguments)},P.prototype.log=function(){this._tee(3,this._originalLogger.log)(arguments)},P.prototype.warn=function(){this._tee(4,this._originalLogger.warn)(arguments)},P.prototype.error=function(){this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var a;h=new P(connect.getLog()),connect.RtcPeerConnectionFactory&&(a=new connect.RtcPeerConnectionFactory(h,connect.core.getWebSocketManager(),g,connect.hitch(this,t,{transportType:"softphone",softphoneClientId:g}),connect.hitch(this,C))),A()||C(f.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ","");S({success:function(e){connect.isFirefoxBrowser()&&connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){C(e,"Your microphone is not enabled in your browser. ","")}});y(),this.ringtoneEngine=null;var c="true"===e.cleanMultipleSessions,u={},l={};this.getSession=function(e){return u[e]};function p(n){var r;u.hasOwnProperty(n)&&(r=u[n],new Promise(function(e,t){delete u[n],delete l[n],r.hangup()}).catch(function(e){lily.getLog().warn("Clean up the session locally "+n,e.message)}))}function n(n,r){var e,t,o,i,s;!u[r]||(e=n).getStatus().type!==connect.ContactStatusType.ENDED&&e.getStatus().type!==connect.ContactStatusType.ERROR&&e.getStatus().type!==connect.ContactStatusType.MISSED||p(r),!n.isSoftphoneCall()||l[r]||n.getStatus().type!==connect.ContactStatusType.CONNECTING&&n.getStatus().type!==connect.ContactStatusType.INCOMING||(l[r]=!0,h.info("Softphone call detected:","contactId "+n.getContactId(),"agent connectionId "+r),function(e){if(00},assertIsList:function(e,n){if(!Array.isArray(e))throw new Error(n+" is not an array")},isFunction:function(e){return!!(e&&e.constructor&&e.call&&e.apply)},isObject:function(e){return!("object"!==o(e)||null===e)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e}},c=new RegExp("^(wss://)\\w*");i.validWSUrl=function(e){return c.test(e)},i.getSubscriptionResponse=function(e,n,t){return{topic:e,content:{status:n?"success":"failure",topics:t}}},i.assertIsObject=function(e,n){if(!i.isObject(e))throw new Error(n+" is not an object!")},i.addJitter=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;n=Math.min(n,1);var t=Math.random()>.5?1:-1;return Math.floor(e+t*e*Math.random()*n)},i.isNetworkOnline=function(){return navigator.onLine};var s=i,a="NULL",u="CLIENT_LOGGER",l="DEBUG",f="aws/subscribe",p="aws/unsubscribe",d="aws/heartbeat",b="connected",g="disconnected";function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function S(e,n){return!n||"object"!==y(n)&&"function"!=typeof n?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):n}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function v(e,n){return(v=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function h(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function m(e,n){for(var t=0;t=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){var n=e.prefix||"";return this._logsDestination===l?this.consoleLoggerWrapper:new N(n)}},{key:"updateLoggerConfig",value:function(e){var n=e||{};this._level=n.level||I.DEBUG,this._clientLogger=n.logger||null,this._logsDestination=a,n.debug&&(this._logsDestination=l),n.logger&&(this._logsDestination=u)}}]),e}(),O=function(){function e(){h(this,e)}return w(e,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),e}(),N=function(e){function n(e){var t;return h(this,n),(t=S(this,k(n).call(this))).prefix=e||"",t}return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&v(e,n)}(n,O),w(n,[{key:"debug",value:function(){for(var e=arguments.length,n=new Array(e),t=0;t0&&void 0!==arguments[0]?arguments[0]:"";e.debug("["+n+"] Primary WebSocket: "+k(t.primary)+" | Secondary WebSocket: "+k(t.secondary))},h=function(e,n){return e&&e.readyState===n},m=function(e){return h(e,WebSocket.OPEN)},w=function(e){return null===e||void 0===e.readyState||h(e,WebSocket.CLOSED)},C=function(){return null!==t.secondary?t.secondary:t.primary},I=function(){return m(C())},T=function(){if(o.pendingResponse)return e.warn("Heartbeat response not received"),clearInterval(o.intervalHandle),o.pendingResponse=!1,void A();I()?(e.debug("Sending heartbeat"),C().send(H(d)),o.pendingResponse=!0):(e.warn("Failed to send heartbeat since WebSocket is not open"),v("sendHeartBeat"),A())},O=function(){r.exponentialBackOffTime=1e3,o.pendingResponse=!1,r.reconnectWebSocket=!0,clearTimeout(r.lifeTimeTimeoutHandle),clearInterval(o.intervalHandle),clearTimeout(r.exponentialTimeoutHandle),clearTimeout(r.webSocketInitCheckerTimeoutId)},N=function(){u.consecutiveFailedSubscribeAttempts=0,u.consecutiveNoResponseRequest=0,clearInterval(u.responseCheckIntervalId),clearInterval(u.reSubscribeIntervalId)},_=function(){try{e.info("WebSocket connection established!"),v("webSocketOnOpen"),r.connState=b,null===t.secondary&&S(i.connectionGain),O(),0===a.subscribed.size&&m(t.secondary)&&j(t.primary,"[Primary WebSocket] Closing WebSocket"),(a.subscribed.size>0||a.pending.size>0)&&(m(t.secondary)&&e.info("Subscribing secondary websocket to topics of primary websocket"),a.subscribed.forEach(function(e){a.subscriptionHistory.add(e),a.pending.add(e)}),a.subscribed.clear(),x()),T(),o.intervalHandle=setInterval(T,1e4),r.lifeTimeTimeoutHandle=setTimeout(function(){e.debug("Starting scheduled WebSocket manager reconnect"),A()},1e3*c.connConfig.webSocketTransport.transportLifeTimeInSeconds)}catch(n){e.error("Error after establishing WebSocket connection",n)}},E=function(n){e.info("Socket connection is closed",n),v("webSocketOnClose before-cleanup"),w(t.primary)&&(t.primary=null),w(t.secondary)&&(t.secondary=null),r.reconnectWebSocket&&(m(t.primary)||m(t.secondary)?w(t.primary)&&m(t.secondary)&&(e.info("[Primary] WebSocket Cleanly Closed"),t.primary=t.secondary,t.secondary=null):(e.warn("Neither primary websocket and nor secondary websocket have open connections, attempting to re-establish connection"),r.connState!==g?S(i.connectionLost):e.info("Ignoring connectionLost callback invocation"),r.connState=g,A()),v("webSocketOnClose after-cleanup"))},L=function(n){v("webSocketOnError"),e.error("WebSocketManager Error, error_event: ",n),A()},F=function(n){var r=JSON.parse(n.data);switch(r.topic){case f:if(e.debug("Subscription Message received from webSocket server",n.data),u.requestCompleted=!0,u.consecutiveNoResponseRequest=0,"success"===r.content.status)u.consecutiveFailedSubscribeAttempts=0,r.content.topics.forEach(function(e){a.subscriptionHistory.delete(e),a.pending.delete(e),a.subscribed.add(e)}),0===a.subscriptionHistory.size?m(t.secondary)&&(e.info("Successfully subscribed secondary websocket to all topics of primary websocket"),j(t.primary,"[Primary WebSocket] Closing WebSocket")):x(),S(i.subscriptionUpdate,r);else{if(clearInterval(u.reSubscribeIntervalId),++u.consecutiveFailedSubscribeAttempts,5===u.consecutiveFailedSubscribeAttempts)return S(i.subscriptionFailure,r),void(u.consecutiveFailedSubscribeAttempts=0);u.reSubscribeIntervalId=setInterval(function(){x()},500)}break;case d:e.debug("Heartbeat response received"),o.pendingResponse=!1;break;default:if(r.topic){if(e.debug("Message received for topic "+r.topic),m(t.primary)&&m(t.secondary)&&0===a.subscriptionHistory.size&&this===t.primary)return void e.warn("Ignoring Message for Topic "+r.topic+", to avoid duplicates");if(0===i.allMessage.size&&0===i.topic.size)return void e.warn("No registered callback listener for Topic",r.topic);S(i.allMessage,r),i.topic.has(r.topic)&&S(i.topic.get(r.topic),r)}else r.message?e.warn("WebSocketManager Message Error",r):e.warn("Invalid incoming message",r)}},x=function n(){if(u.consecutiveNoResponseRequest>3)return e.warn("Ignoring subscribePendingTopics since we have exhausted max subscription retries with no response"),void S(i.subscriptionFailure,s.getSubscriptionResponse(f,!1,Array.from(a.pending)));I()?(clearInterval(u.responseCheckIntervalId),C().send(H(f,{topics:Array.from(a.pending)})),u.requestCompleted=!1,u.responseCheckIntervalId=setInterval(function(){u.requestCompleted||(++u.consecutiveNoResponseRequest,n())},1e3)):e.warn("Ignoring subscribePendingTopics call since Default WebSocket is not open")},j=function(n,t){h(n,WebSocket.CONNECTING)||h(n,WebSocket.OPEN)?n.close(1e3,t):e.warn("Ignoring WebSocket Close request, WebSocket State: "+k(n))},R=function(e){j(t.primary,"[Primary] WebSocket "+e),j(t.secondary,"[Secondary] WebSocket "+e)},M=function(){var n=s.addJitter(r.exponentialBackOffTime,.3);Date.now()+n<=c.connConfig.urlConnValidTime?(e.debug("Scheduling WebSocket reinitialization, after delay "+n+" ms"),r.exponentialTimeoutHandle=setTimeout(function(){return D()},n),r.exponentialBackOffTime*=2):(e.warn("WebSocket URL is cannot be used to establish connection"),A())},P=function(){O(),N(),e.error("WebSocket Initialization failed"),r.websocketInitFailed=!0,R("Terminating WebSocket Manager"),clearInterval(y),S(i.initFailure)},H=function(e,n){return JSON.stringify({topic:e,content:n})},G=function(n){return!!(s.isObject(n)&&s.isObject(n.webSocketTransport)&&s.isNonEmptyString(n.webSocketTransport.url)&&s.validWSUrl(n.webSocketTransport.url)&&1e3*n.webSocketTransport.transportLifeTimeInSeconds>=36e5)||(e.error("Invalid WebSocket Connection Configuration",n),!1)},A=function n(){if(s.isNetworkOnline())if(r.websocketInitFailed)e.debug("WebSocket Init had failed, ignoring this getWebSocketConnConfig request");else{if(c.promiseCompleted)return O(),e.info("Fetching new WebSocket connection configuration"),c.promiseCompleted=!1,c.promiseHandle=i.getWebSocketTransport(),c.promiseHandle.then(function(n){return c.promiseCompleted=!0,e.debug("Successfully fetched webSocket connection configuration",n),G(n)?(c.connConfig=n,c.connConfig.urlConnValidTime=Date.now()+85e3,D()):(P(),{webSocketConnectionFailed:!0})},function(t){return c.promiseCompleted=!0,e.error("Failed to fetch webSocket connection configuration",t),setTimeout(function(){return n()},s.addJitter(5e3,.3)),{webSocketConnectionFailed:!0}});e.debug("There is an ongoing getWebSocketConnConfig request, this request will be ignored")}else e.info("Network offline, ignoring this getWebSocketConnConfig request")},D=function(){if(r.websocketInitFailed)return e.info("web-socket initializing had failed, aborting re-init"),{webSocketConnectionFailed:!0};if(!s.isNetworkOnline())return e.warn("System is offline aborting web-socket init"),{webSocketConnectionFailed:!0};e.info("Initializing Websocket Manager"),v("initWebSocket");try{if(G(c.connConfig)){var n=null;return m(t.primary)?(e.debug("Primary Socket connection is already open"),h(t.secondary,WebSocket.CONNECTING)||(e.debug("Establishing a secondary web-socket connection"),t.secondary=U()),n=t.secondary):(h(t.primary,WebSocket.CONNECTING)||(e.debug("Establishing a primary web-socket connection"),t.primary=U()),n=t.primary),r.webSocketInitCheckerTimeoutId=setTimeout(function(){m(n)||M()},1e3),{webSocketConnectionFailed:!1}}}catch(n){return e.error("Error Initializing web-socket-manager",n),P(),{webSocketConnectionFailed:!0}}},U=function(){var e=new WebSocket(c.connConfig.webSocketTransport.url);return e.addEventListener("open",_),e.addEventListener("message",F),e.addEventListener("error",L),e.addEventListener("close",E),e};this.init=function(n){if(s.assertTrue(s.isFunction(n),"transportHandle must be a function"),null===i.getWebSocketTransport)return i.getWebSocketTransport=n,A();e.warn("Web Socket Manager was already initialized")},this.onInitFailure=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.initFailure.add(e),r.websocketInitFailed&&e(),function(){return i.initFailure.delete(e)}},this.onConnectionGain=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.connectionGain.add(e),I()&&e(),function(){return i.connectionGain.delete(e)}},this.onConnectionLost=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.connectionLost.add(e),r.connState===g&&e(),function(){return i.connectionLost.delete(e)}},this.onSubscriptionUpdate=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.subscriptionUpdate.add(e),function(){return i.subscriptionUpdate.delete(e)}},this.onSubscriptionFailure=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.subscriptionFailure.add(e),function(){return i.subscriptionFailure.delete(e)}},this.onMessage=function(e,n){return s.assertNotNull(e,"topicName"),s.assertTrue(s.isFunction(n),"cb must be a function"),i.topic.has(e)?i.topic.get(e).add(n):i.topic.set(e,new Set([n])),function(){return i.topic.get(e).delete(n)}},this.onAllMessage=function(e){return s.assertTrue(s.isFunction(e),"cb must be a function"),i.allMessage.add(e),function(){return i.allMessage.delete(e)}},this.subscribeTopics=function(e){s.assertNotNull(e,"topics"),s.assertIsList(e),e.forEach(function(e){a.subscribed.has(e)||a.pending.add(e)}),u.consecutiveNoResponseRequest=0,x()},this.sendMessage=function(n){if(s.assertIsObject(n,"payload"),void 0===n.topic||l.has(n.topic))e.warn("Cannot send message, Invalid topic",n);else{try{n=JSON.stringify(n)}catch(t){return void e.warn("Error stringify message",n)}I()?C().send(n):e.warn("Cannot send message, web socket connection is not open")}},this.closeWebSocket=function(){O(),N(),r.reconnectWebSocket=!1,clearInterval(y),R("User request to close WebSocket")}},L={create:function(){return new E},setGlobalConfig:function(e){var n=e.loggerConfig;W.updateLoggerConfig(n)},LogLevel:I,Logger:C}},function(e,n,t){var r;!function(){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function i(e){return function(e,n){var t,r,c,s,a,u,l,f,p,d=1,b=e.length,g="";for(r=0;r=0),s.type){case"b":t=parseInt(t,10).toString(2);break;case"c":t=String.fromCharCode(parseInt(t,10));break;case"d":case"i":t=parseInt(t,10);break;case"j":t=JSON.stringify(t,null,s.width?parseInt(s.width):0);break;case"e":t=s.precision?parseFloat(t).toExponential(s.precision):parseFloat(t).toExponential();break;case"f":t=s.precision?parseFloat(t).toFixed(s.precision):parseFloat(t);break;case"g":t=s.precision?String(Number(t.toPrecision(s.precision))):parseFloat(t);break;case"o":t=(parseInt(t,10)>>>0).toString(8);break;case"s":t=String(t),t=s.precision?t.substring(0,s.precision):t;break;case"t":t=String(!!t),t=s.precision?t.substring(0,s.precision):t;break;case"T":t=Object.prototype.toString.call(t).slice(8,-1).toLowerCase(),t=s.precision?t.substring(0,s.precision):t;break;case"u":t=parseInt(t,10)>>>0;break;case"v":t=t.valueOf(),t=s.precision?t.substring(0,s.precision):t;break;case"x":t=(parseInt(t,10)>>>0).toString(16);break;case"X":t=(parseInt(t,10)>>>0).toString(16).toUpperCase()}o.json.test(s.type)?g+=t:(!o.number.test(s.type)||f&&!s.sign?p="":(p=f?"+":"-",t=t.toString().replace(o.sign,"")),u=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",l=s.width-(p+t).length,a=s.width&&l>0?u.repeat(l):"",g+=s.align?p+t+a:"0"===u?p+a+t:a+p+t)}return g}(function(e){if(s[e])return s[e];var n,t=e,r=[],i=0;for(;t;){if(null!==(n=o.text.exec(t)))r.push(n[0]);else if(null!==(n=o.modulo.exec(t)))r.push("%");else{if(null===(n=o.placeholder.exec(t)))throw new SyntaxError("[sprintf] unexpected placeholder");if(n[2]){i|=1;var c=[],a=n[2],u=[];if(null===(u=o.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(c.push(u[1]);""!==(a=a.substring(u[0].length));)if(null!==(u=o.key_access.exec(a)))c.push(u[1]);else{if(null===(u=o.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");c.push(u[1])}n[2]=c}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push({placeholder:n[0],param_no:n[1],keys:n[2],sign:n[3],pad_char:n[4],align:n[5],width:n[6],precision:n[7],type:n[8]})}t=t.substring(n[0].length)}return s[e]=r}(e),arguments)}function c(e,n){return i.apply(null,[e].concat(n||[]))}var s=Object.create(null);n.sprintf=i,n.vsprintf=c,"undefined"!=typeof window&&(window.sprintf=i,window.vsprintf=c,void 0===(r=function(){return{sprintf:i,vsprintf:c}}.call(n,t,n,e))||(e.exports=r))}()},function(e,n,t){"use strict";t.r(n),function(e){t.d(n,"WebSocketManager",function(){return o});var r=t(0);e.connect=e.connect||{},connect.WebSocketManager=r.a;var o=r.a}.call(this,t(3))},function(e,n){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t}]); //# sourceMappingURL=amazon-connect-websocket-manager.js.map + /* * Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * @@ -24547,7 +24548,7 @@ connect.core.initialized = false; - connect.version = "1.4.9"; + connect.version = "1.5.0"; connect.DEFAULT_BATCH_SIZE = 500; @@ -25928,7 +25929,7 @@ // Error! our state doesn't match, tear it all down. for (var connectionId in rtcSessions) { if (rtcSessions.hasOwnProperty(connectionId)) { - // Log an error for the session we are about to kill. + // Log an error for the session we are about to end. publishMultipleSessionsEvent(HANG_UP_MULTIPLE_SESSIONS_EVENT, rtcSessions[connectionId].callId, connectionId); destroySession(connectionId); } diff --git a/src/api.js b/src/api.js index 3ac96d2b..d101458c 100644 --- a/src/api.js +++ b/src/api.js @@ -1137,9 +1137,9 @@ }; /** - * Execute the given function asynchronously only if the shared worker + * Starts the given function asynchronously only if the shared worker * says we are the master for the given topic. If there is no master for - * the given topic, we become the master and execute the function. + * the given topic, we become the master and start the function. * * @param topic The master topic we are concerned about. * @param f_true The callback to be invoked if we are the master. diff --git a/src/index.d.ts b/src/index.d.ts index c36b758b..1acafe48 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -97,7 +97,7 @@ declare namespace connect { viewContact(contactId: string): void; /** - * Subscribes a callback that executes whenever the currently selected contact on the CCP changes. + * Subscribes a callback that starts whenever the currently selected contact on the CCP changes. * The callback is called when the contact changes in the UI (i.e. via `click` events) or via `connect.core.viewContact()`. * * @param callback A callback that will receive a `ViewContactEvent` object. @@ -105,16 +105,16 @@ declare namespace connect { onViewContact(callback: ViewContactCallback): void; /** - * Subscribes a callback that executes whenever authentication fails (e.g. SAML authentication). + * Subscribes a callback that starts whenever authentication fails (e.g. SAML authentication). * - * @param callback A callback that will execute whenever authentication fails. + * @param callback A callback that will start whenever authentication fails. */ onAuthFail(callback: SuccessFailCallback): void; /** - * Subscribes a callback that executes whenever authorization fails (i.e. access denied). + * Subscribes a callback that starts whenever authorization fails (i.e. access denied). * - * @param callback A callback that will execute whenever access is denied. + * @param callback A callback that will start whenever access is denied. */ onAccessDenied(callback: SuccessFailCallback): void; @@ -403,10 +403,10 @@ declare namespace connect { type SuccessFailCallback = (...args: T) => void; interface SuccessFailOptions { - /** A callback that executes when the operation completes successfully. */ + /** A callback that starts when the operation completes successfully. */ readonly success?: SuccessFailCallback; - /** A callback that executes when the operation has an error. */ + /** A callback that starts when the operation has an error. */ readonly failure?: SuccessFailCallback<[string]>; } @@ -783,7 +783,7 @@ declare namespace connect { /** * Subscribe a method to be invoked when the contact is connecting. * This works with chat and softphone contacts. - * This event happens when a call or chat comes in, before accepting (there is an exception for queue callbacks, in which onConnecting's handler is executed after the callback is accepted). + * This event happens when a call or chat comes in, before accepting (there is an exception for queue callbacks, in which onConnecting's handler is started after the callback is accepted). * Note that once the contact has been accepted, the `onAccepted` handler will be triggered. * * @param callback A callback to receive the `Contact` API object instance. diff --git a/src/softphone.js b/src/softphone.js index 20150e06..0ff997da 100644 --- a/src/softphone.js +++ b/src/softphone.js @@ -134,7 +134,7 @@ // Error! our state doesn't match, tear it all down. for (var connectionId in rtcSessions) { if (rtcSessions.hasOwnProperty(connectionId)) { - // Log an error for the session we are about to kill. + // Log an error for the session we are about to end. publishMultipleSessionsEvent(HANG_UP_MULTIPLE_SESSIONS_EVENT, rtcSessions[connectionId].callId, connectionId); destroySession(connectionId); }