From 64764e5df00ab96220daf5ab9fba79afe023bb6c Mon Sep 17 00:00:00 2001 From: "Seiya Kobayashizzd93@PJCM" Date: Tue, 12 Oct 2021 17:22:27 -0400 Subject: [PATCH] Resolve updateVoiceIdSpeakerId after _updateSpeakerIdInLcms resolves --- package-lock.json | 2 +- package.json | 2 +- release/connect-streams-min.js | 2 +- release/connect-streams.js | 11 ++++++++--- src/api.js | 9 +++++++-- test/unit/voiceid.spec.js | 25 ++++++++++++++++++++++++- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe46d5c3..47be0f07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "amazon-connect-streams", - "version": "1.7.3", + "version": "1.7.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6d728ab4..dab869c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amazon-connect-streams", - "version": "1.7.3", + "version": "1.7.4", "description": "Amazon Connect Streams Library", "engines": { "node": ">=12.0.0" diff --git a/release/connect-streams-min.js b/release/connect-streams-min.js index 47e2eff8..8e05682f 100644 --- a/release/connect-streams-min.js +++ b/release/connect-streams-min.js @@ -1 +1 @@ -!function o(r,i,s){function c(t,e){if(!i[t]){if(!r[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(a)return a(t,!0);throw(n=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",n}n=i[t]={exports:{}},r[t][0].call(n.exports,function(e){return c(r[t][1][e]||e)},n,n.exports,o,r,i,s)}return i[t].exports}for(var a="function"==typeof require&&require,e=0;ee.BLOCK_SIZE&&((t=new e).update(n),n=t.digest());e=new Uint8Array(e.BLOCK_SIZE);return e.set(n),e}(e,t),o=new Uint8Array(e.BLOCK_SIZE);o.set(n);for(var r=0;r>>32-r)+n&4294967295}function a(e,t,n,o,r,i,s){return c(t&n|~t&o,e,t,r,i,s)}function u(e,t,n,o,r,i,s){return c(t&o|n&~o,e,t,r,i,s)}function l(e,t,n,o,r,i,s){return c(t^n^o,e,t,r,i,s)}function p(e,t,n,o,r,i,s){return c(n^(t|~o),e,t,r,i,s)}(t.exports=o).BLOCK_SIZE=64,o.prototype.update=function(e){if(r.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=r.convertToBuffer(e),n=0,o=t.byteLength;for(this.bytesHashed+=o;0>>0,!0),t.setUint32(60,Math.floor(o/4294967296),!0),this.hashBuffer(),this.finished=!0}for(var i=new DataView(new ArrayBuffer(16)),r=0;r<4;r++)i.setUint32(4*r,this.state[r],!0);o=new s(i.buffer,i.byteOffset,i.byteLength);return e?o.toString(e):o},o.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=a(n=t[0],i=t[1],r=t[2],o=t[3],e.getUint32(0,!0),7,3614090360),o=a(o,n,i,r,e.getUint32(4,!0),12,3905402710),r=a(r,o,n,i,e.getUint32(8,!0),17,606105819),i=a(i,r,o,n,e.getUint32(12,!0),22,3250441966);n=a(n,i,r,o,e.getUint32(16,!0),7,4118548399),o=a(o,n,i,r,e.getUint32(20,!0),12,1200080426),r=a(r,o,n,i,e.getUint32(24,!0),17,2821735955),i=a(i,r,o,n,e.getUint32(28,!0),22,4249261313),n=a(n,i,r,o,e.getUint32(32,!0),7,1770035416),o=a(o,n,i,r,e.getUint32(36,!0),12,2336552879),r=a(r,o,n,i,e.getUint32(40,!0),17,4294925233),i=a(i,r,o,n,e.getUint32(44,!0),22,2304563134),n=a(n,i,r,o,e.getUint32(48,!0),7,1804603682),o=a(o,n,i,r,e.getUint32(52,!0),12,4254626195),r=a(r,o,n,i,e.getUint32(56,!0),17,2792965006),n=u(n,i=a(i,r,o,n,e.getUint32(60,!0),22,1236535329),r,o,e.getUint32(4,!0),5,4129170786),o=u(o,n,i,r,e.getUint32(24,!0),9,3225465664),r=u(r,o,n,i,e.getUint32(44,!0),14,643717713),i=u(i,r,o,n,e.getUint32(0,!0),20,3921069994),n=u(n,i,r,o,e.getUint32(20,!0),5,3593408605),o=u(o,n,i,r,e.getUint32(40,!0),9,38016083),r=u(r,o,n,i,e.getUint32(60,!0),14,3634488961),i=u(i,r,o,n,e.getUint32(16,!0),20,3889429448),n=u(n,i,r,o,e.getUint32(36,!0),5,568446438),o=u(o,n,i,r,e.getUint32(56,!0),9,3275163606),r=u(r,o,n,i,e.getUint32(12,!0),14,4107603335),i=u(i,r,o,n,e.getUint32(32,!0),20,1163531501),n=u(n,i,r,o,e.getUint32(52,!0),5,2850285829),o=u(o,n,i,r,e.getUint32(8,!0),9,4243563512),r=u(r,o,n,i,e.getUint32(28,!0),14,1735328473),n=l(n,i=u(i,r,o,n,e.getUint32(48,!0),20,2368359562),r,o,e.getUint32(20,!0),4,4294588738),o=l(o,n,i,r,e.getUint32(32,!0),11,2272392833),r=l(r,o,n,i,e.getUint32(44,!0),16,1839030562),i=l(i,r,o,n,e.getUint32(56,!0),23,4259657740),n=l(n,i,r,o,e.getUint32(4,!0),4,2763975236),o=l(o,n,i,r,e.getUint32(16,!0),11,1272893353),r=l(r,o,n,i,e.getUint32(28,!0),16,4139469664),i=l(i,r,o,n,e.getUint32(40,!0),23,3200236656),n=l(n,i,r,o,e.getUint32(52,!0),4,681279174),o=l(o,n,i,r,e.getUint32(0,!0),11,3936430074),r=l(r,o,n,i,e.getUint32(12,!0),16,3572445317),i=l(i,r,o,n,e.getUint32(24,!0),23,76029189),n=l(n,i,r,o,e.getUint32(36,!0),4,3654602809),o=l(o,n,i,r,e.getUint32(48,!0),11,3873151461),r=l(r,o,n,i,e.getUint32(60,!0),16,530742520),n=p(n,i=l(i,r,o,n,e.getUint32(8,!0),23,3299628645),r,o,e.getUint32(0,!0),6,4096336452),o=p(o,n,i,r,e.getUint32(28,!0),10,1126891415),r=p(r,o,n,i,e.getUint32(56,!0),15,2878612391),i=p(i,r,o,n,e.getUint32(20,!0),21,4237533241),n=p(n,i,r,o,e.getUint32(48,!0),6,1700485571),o=p(o,n,i,r,e.getUint32(12,!0),10,2399980690),r=p(r,o,n,i,e.getUint32(40,!0),15,4293915773),i=p(i,r,o,n,e.getUint32(4,!0),21,2240044497),n=p(n,i,r,o,e.getUint32(32,!0),6,1873313359),o=p(o,n,i,r,e.getUint32(60,!0),10,4264355552),r=p(r,o,n,i,e.getUint32(24,!0),15,2734768916),i=p(i,r,o,n,e.getUint32(52,!0),21,1309151649),n=p(n,i,r,o,e.getUint32(16,!0),6,4149444226),o=p(o,n,i,r,e.getUint32(44,!0),10,3174756917),r=p(r,o,n,i,e.getUint32(8,!0),15,718787259),i=p(i,r,o,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=i+t[1]&4294967295,t[2]=r+t[2]&4294967295,t[3]=o+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":81}],14:[function(e,t,n){var r=e("buffer/").Buffer,o=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(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n>t);var n=new r(20),o=new DataView(n.buffer);return o.setUint32(0,this.h0,!1),o.setUint32(4,this.h1,!1),o.setUint32(8,this.h2,!1),o.setUint32(12,this.h3,!1),o.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,o=this.h0,r=this.h1,i=this.h2,s=this.h3,c=this.h4,e=0;e<80;e++)var a=e<20?(n=s^r&(i^s),1518500249):e<40?(n=r^i^s,1859775393):e<60?(n=r&i|s&(r|i),2400959708):(n=r^i^s,3395469782),a=(o<<5|o>>>27)+n+c+a+(0|this.block[e]),c=s,s=i,i=r<<30|r>>>2,r=o,o=a;for(this.h0=this.h0+o|0,this.h1=this.h1+r|0,this.h2=this.h2+i|0,this.h3=this.h3+s|0,this.h4=this.h4+c|0,e=this.offset=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":81}],15:[function(e,t,n){var s=e("buffer/").Buffer,o=e("./browserHashUtils"),d=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]),r=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(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>r)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;0>>24&255,i[4*r+1]=this.state[r]>>>16&255,i[4*r+2]=this.state[r]>>>8&255,i[4*r+3]=this.state[r]>>>0&255;return e?i.toString(e):i},i.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],i=t[3],s=t[4],c=t[5],a=t[6],u=t[7],l=0;l<64;l++){l<16?this.temp[l]=(255&e[4*l])<<24|(255&e[4*l+1])<<16|(255&e[4*l+2])<<8|255&e[4*l+3]:(p=((h=this.temp[l-2])>>>17|h<<15)^(h>>>19|h<<13)^h>>>10,h=this.temp[l-15],this.temp[l]=(p+this.temp[l-7]|0)+(((h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3)+this.temp[l-16]|0));var p=(((s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+(s&c^~s&a)|0)+(u+(d[l]+this.temp[l]|0)|0)|0,h=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&r^o&r)|0,u=a,a=c,c=s,s=i+p|0,i=r,r=o,o=n,n=p+h|0}t[0]+=n,t[1]+=o,t[2]+=r,t[3]+=i,t[4]+=s,t[5]+=c,t[6]+=a,t[7]+=u}},{"./browserHashUtils":11,"buffer/":81}],16:[function(n,o,e){!function(e){!function(){var e=n("./util");e.crypto.lib=n("./browserCryptoLib"),e.Buffer=n("buffer/").Buffer,e.url=n("url/"),e.querystring=n("querystring/"),e.realClock=n("./realclock/browserClock"),e.environment="js",e.createEventStream=n("./event-stream/buffered-create-event-stream").createEventStream,e.isBrowser=function(){return!0},e.isNode=function(){return!1};var t,e=n("./core");o.exports=e,n("./credentials"),n("./credentials/credential_provider_chain"),n("./credentials/temporary_credentials"),n("./credentials/chainable_temporary_credentials"),n("./credentials/web_identity_credentials"),n("./credentials/cognito_identity_credentials"),n("./credentials/saml_credentials"),e.XML.Parser=n("./xml/browser_parser"),n("./http/xhr"),void 0===t&&(t={browser:!0})}.call(this)}.call(this,n("_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:86,"buffer/":81,"querystring/":92,"url/":94}],17:[function(e,t,n){var o,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 o(e){t(e,e?null:n.credentials)}function r(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){o(e=e&&r("Could not load credentials from "+n.credentials.constructor.name,e))}):(e=null,o(e=!n.credentials.accessKeyId||!n.credentials.secretAccessKey?r("Missing credentials"):e)):n.credentialProvider?n.credentialProvider.resolve(function(e,t){e=e&&r("Could not load credentials from any providers",e),n.credentials=t,o(e)}):o(r("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),e=new i.CredentialProviderChain;return e.providers.unshift(t),e.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===(o=e)&&"function"==typeof Promise&&(o=Promise);e=[i.Request,i.Credentials,i.CredentialProviderChain];i.S3&&(e.push(i.S3),i.S3.ManagedUpload&&e.push(i.S3.ManagedUpload)),i.util.addPromises(e,o)},getPromisesDependency:function(){return o}}),i.config=new i.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var o={util:e("./util")};({}).toString(),(t.exports=o).util.update(o,{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"),o.events=new o.SequentialExecutor,o.util.memoizedProperty(o,"endpointCache",function(){return new o.EndpointCache(o.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 r=e("./core");r.Credentials=r.util.inherit({constructor:function(){var e;r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof arguments[0]?(e=arguments[0].credentials||arguments[0],this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken):(this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2])},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),e=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&e>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 o=this;1===o.refreshCallbacks.push(e)&&o.load(function(t){r.util.arrayEach(o.refreshCallbacks,function(e){n?e(t):r.util.defer(function(){e(t)})}),o.refreshCallbacks.length=0})},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":18}],20:[function(e,t,n){var i=e("../core"),o=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}e=i.util.merge({params:t,credentials:e.masterCredentials||i.config.credentials},e.stsConfig||{});this.service=new o(e)},refresh:function(e){this.coalesceRefresh(e||i.util.fn.callback)},load:function(o){var r=this,i=r.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode(function(e,t){var n={};e?o(e):(t&&(n.TokenCode=t),r.service[i](n,function(e,t){e||r.service.credentialsFrom(t,r),o(e)}))})},getTokenCode:function(o){var r=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 o(i.util.error(new Error("Error fetching MFA token: "+n),{code:r.errorCode}))}o(null,t)}):o(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var o=e("../core"),r=e("../../clients/cognitoidentity"),i=e("../../clients/sts");o.CognitoIdentityCredentials=o.util.inherit(o.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=o.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||o.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 o=this;if("string"==typeof o.params.IdentityId)return n(null,o.params.IdentityId);o.cognito.getId(function(e,t){!e&&t.IdentityId?(o.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 o=this;o.cognito.getCredentialsForIdentity(function(e,t){e?o.clearIdOnNotAuthorized(e):(o.cacheId(t),o.data=t,o.loadCredentials(o.data,o)),n(e)})},getCredentialsFromSTS:function(n){var o=this;o.cognito.getOpenIdToken(function(e,t){e?(o.clearIdOnNotAuthorized(e),n(e)):(o.cacheId(t),o.params.WebIdentityToken=t.Token,o.webIdentityCredentials.refresh(function(e){e||(o.data=o.webIdentityCredentials.data,o.sts.credentialsFrom(o.data,o)),n(e)}))})},loadCachedId:function(){var e,t,n=this;o.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 o.WebIdentityCredentials(this.params,t),this.cognito||((e=o.util.merge({},t)).params=this.params,this.cognito=new r(e)),this.sts=this.sts||new i(t)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,o.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=o.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 c=e("../core");c.CredentialProviderChain=c.util.inherit(c.Credentials,{constructor:function(e){this.providers=e||c.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var r,i,s=this;return 0===s.providers.length?e(new Error("No providers")):1===s.resolveCallbacks.push(e)&&(r=0,i=s.providers.slice(0),function t(n,o){if(!n&&o||r===i.length)return c.util.arrayEach(s.resolveCallbacks,function(e){e(n,o)}),void(s.resolveCallbacks.length=0);var e=i[r++];(o="function"==typeof e?e.call():e).get?o.get(function(e){t(e,e?null:o)}):t(null,o)}()),s}}),c.CredentialProviderChain.defaultProviders=[],c.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=c.util.promisifyMethod("resolve",e)},c.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},c.util.addPromises(c.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.SAMLCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.service.assumeRoleWithSAML(function(e,t){e||o.service.credentialsFrom(t,o),n(e)})},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.TemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.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||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.masterCredentials.get(function(){o.service.config.credentials=o.masterCredentials,(o.params.RoleArn?o.service.assumeRole:o.service.getSessionToken).call(o.service,function(e,t){e||o.service.credentialsFrom(t,o),n(e)})})},loadMasterCredentials:function(e){for(this.masterCredentials=e||o.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new o.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.WebIdentityCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=o.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.service.assumeRoleWithWebIdentity(function(e,t){o.data=null,e||(o.data=t,o.service.credentialsFrom(t,o)),n(e)})},createClients:function(){var e;this.service||((e=o.util.merge({},this._clientConfig)).params=this.params,this.service=new r(e))}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){!function(a){!function(){var u=e("./core"),l=e("./util"),o=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function p(e){var t=e.service,n=t.api||{},e=(n.operations,{});return t.config.region&&(e.region=t.config.region),n.serviceId&&(e.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(e.accessKeyId=t.config.credentials.accessKeyId),e}function h(e,t){var n={};return function o(r,i,s){s&&null!=i&&"structure"===s.type&&s.required&&0=this.HEADERS_RECEIVED&&!u&&(s.statusCode=a.status,s.headers=r.parseHeaders(a.getAllResponseHeaders()),s.emit("headers",s.statusCode,s.headers,a.statusText),u=!0),this.readyState===this.DONE&&r.finishRequest(a,s)},!1),a.upload.addEventListener("progress",function(e){s.emit("sendProgress",e)}),a.addEventListener("progress",function(e){s.emit("receiveProgress",e)},!1),a.addEventListener("timeout",function(){o(l.util.error(new Error("Timeout"),{code:"TimeoutError"}))},!1),a.addEventListener("error",function(){o(l.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},!1),a.addEventListener("abort",function(){o(l.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))},!1),n(s),a.open(t.method,c,!1!==e.xhrAsync),l.util.each(t.headers,function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&a.setRequestHeader(e,t)}),e.timeout&&!1!==e.xhrAsync&&(a.timeout=e.timeout),e.xhrWithCredentials&&(a.withCredentials=!0);try{a.responseType="arraybuffer"}catch(e){}try{t.body?a.send(t.body):a.send()}catch(e){if(!t.body||"object"!=typeof t.body.buffer)throw e;a.send(t.body.buffer)}return s},parseHeaders:function(e){var n={};return l.util.arrayEach(e.split(/\r?\n/),function(e){var t=e.split(":",1)[0],e=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,o){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 "+o+" <= "+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,o){if(null==e)return!1;for(var r=!1,i=0;i=e.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t]))})},setupRequestListeners:function(e){},getSignerClass:function(e){var t=null,n="";return e&&(n=(t=(e.service.api.operations||{})[e.operation]||null)?t.authtype:""),n=this.config.signatureVersion||("v4"===n||"v4-unsigned-body"===n?"v4":this.api.signatureVersion),l.Signers.RequestSigner.getVersion(n)},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;return e=(e=(e=e.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){t=new Error;throw l.util.error(t,"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 o,n=s(l.Service,n||{});return"string"==typeof e?(l.Service.addVersions(n,t),o=n.serviceIdentifier||e,n.serviceIdentifier=o):(n.prototype.api=e,l.Service.defineMethods(n)),l.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&l.util.clientSideMonitoring&&(o=l.util.clientSideMonitoring.Publisher,e=(0,l.util.clientSideMonitoring.configProvider)(),this.prototype.publisher=new o(e),e.enabled&&(l.Service._clientSideMonitoring=!0)),l.SequentialExecutor.call(n.prototype),l.Service.addDefaultMonitoringListeners(n.prototype),n},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=t.length)return n.push(null);e=o+e;e>t.length&&(e=t.length),n.push(t.slice(o,e)),o=e},n},concat:function(e){for(var t,n=0,o=0,r=0;r>>8^t[255&(n^e.readUInt8(o))];return(-1^n)>>>0},hmac:function(e,t,n,o){return"buffer"===(n=n||"binary")&&(n=void 0),o=o||"sha256","string"==typeof t&&(t=u.buffer.toBuffer(t)),u.crypto.lib.createHmac(o,e).update(t).digest(n)},md5:function(e,t,n){return u.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return u.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,o){var r=u.crypto.createHash(e);"buffer"===(n=n||"binary")&&(n=void 0),"string"==typeof t&&(t=u.buffer.toBuffer(t));var i=u.arraySliceFn(t),e=u.Buffer.isBuffer(t);if(u.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(e=!0),o&&"object"==typeof t&&"function"==typeof t.on&&!e)t.on("data",function(e){r.update(e)}),t.on("error",function(e){o(e)}),t.on("end",function(){o(null,r.digest(n))});else{if(!o||!i||e||"undefined"==typeof FileReader){u.isBrowser()&&"object"==typeof t&&!e&&(t=new u.Buffer(new Uint8Array(t)));e=r.update(t).digest(n);return o&&o(null,e),e}var s=0,c=new FileReader;c.onerror=function(){o(new Error("Failed to read data."))},c.onload=function(){var e=new u.Buffer(new Uint8Array(c.result));r.update(e),s+=e.length,c._continueReading()},c._continueReading=function(){var e;s>=t.size?o(null,r.digest(n)):((e=s+524288)>t.size&&(e=t.size),c.readAsArrayBuffer(i.call(t,s,e)))},c._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 c=e("./escape-attribute").escapeAttribute;function o(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}o.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},o.prototype.addChildNode=function(e){return this.children.push(e),this},o.prototype.removeAttribute=function(e){return delete this.attributes[e],this},o.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,o=0,r=Object.keys(n);o"+this.children.map(function(e){return e.toString()}).join("")+"":"/>")},t.exports={XmlNode:o}},{"./escape-attribute":74}],77:[function(e,t,n){var o=e("./escape-element").escapeElement;function r(e){this.value=e}r.prototype.toString=function(){return o(""+this.value)},t.exports={XmlText:r}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),e=t[0],t=t[1];return 3*(e+t)/4-t},n.toByteArray=function(e){var t,n,o=l(e),r=o[0],o=o[1],i=new u(function(e,t){return 3*(e+t)/4-t}(r,o)),s=0,c=0>16&255,i[s++]=t>>8&255,i[s++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,i[s++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,i[s++]=t>>8&255,i[s++]=255&t);return i},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,r=[],i=0,s=n-o;i>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}(o));return r.join("")}(e,i,s>2]+c[t<<4&63]+"==")):2==o&&(t=(e[n-2]<<8)+e[n-1],r.push(c[t>>10]+c[t>>4&63]+c[t<<2&63]+"="));return r.join("")};for(var c=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,i=o.length;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=y-1,E=Math.floor,S=String.fromCharCode;function b(e){throw RangeError(p[e])}function d(e,t){for(var n=e.length,o=[];n--;)o[n]=t(e[n]);return o}function f(e,t){var n=e.split("@"),o="";return 1>>10&1023|55296),e=56320|1023&e),t+=S(e)}).join("")}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function I(e,t,n){var o=0;for(e=n?E(e/c):e>>1,e+=E(e/t);h*v>>1E((m-l)/i))&&b("overflow"),l+=c*i,!(c<(c=s<=h?1:h+v<=s?v:s-h));s+=y)i>E(m/(c=y-c))&&b("overflow"),i*=c;h=I(l-r,t=a.length+1,0==r),E(l/t)>m-p&&b("overflow"),p+=E(l/t),l%=t,a.splice(l++,0,p)}return g(a)}function A(e){for(var t,n,o,r,i,s,c,a,u,l,p=[],h=(e=C(e)).length,d=128,f=72,g=t=0;gE((m-t)/(a=n+1))&&b("overflow"),t+=(r-d)*a,d=r,g=0;gm&&b("overflow"),c==d){for(i=t,s=y;!(i<(u=s<=f?1:f+v<=s?v:s-f));s+=y)p.push(S(T(u+(l=i-u)%(u=y-u),0))),i=E(l/u);p.push(S(T(i,0))),f=I(t,a,n==o),t=0,++n}++t,++d}return p.join("")}if(r={version:"1.3.2",ucs2:{decode:C,encode:g},decode:_,encode:A,toASCII:function(e){return f(e,function(e){return u.test(e)?"xn--"+A(e):e})},toUnicode:function(e){return f(e,function(e){return a.test(e)?_(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return r});else if(t&&n)if(R.exports==t)n.exports=r;else for(i in r)r.hasOwnProperty(i)&&(t[i]=r[i]);else e.punycode=r}(this)}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],81:[function(L,e,D){!function(e,t){!function(){"use strict";var c=L("base64-js"),i=L("ieee754"),s=L("isarray");function n(){return p.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function r(e,t){if(n()=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function d(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;var n=(e="string"!=typeof e?""+e:e).length;if(0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(e).length;default:if(o)return N(e).length;t=(""+t).toLowerCase(),o=!0}}function t(e,t,n){var o,r,i,s=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?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 o=e.length;(!t||t<0)&&(t=0);(!n||n<0||o=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=p.from(t,o)),p.isBuffer(t))return 0===t.length?-1:m(e,t,n,o,r);if("number"==typeof t)return t&=255,p.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,o,r){var i=1,s=e.length,c=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s/=i=2,c/=2,n/=2}function a(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(r)for(var u=-1,l=n;l>8,o=o%256,r.push(o),r.push(n);return r}(t,e.length-n),e,n,o)}function E(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r>>10&1023|55296),l=56320|1023&l),o.push(l),r+=p}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var n="",o=0;for(;ot&&(e+=" ... ")),""},p.prototype.compare=function(e,t,n,o,r){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=e?e.length:0),void 0===o&&(o=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(r<=o&&n<=t)return 0;if(r<=o)return-1;if(n<=t)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),a=this.slice(o,r),u=e.slice(t,n),l=0;lthis.length)throw new RangeError("Attempt to write outside buffer bounds");o=o||"utf8";for(var i,s,c,a=!1;;)switch(o){case"hex":return function(e,t,n,o){n=Number(n)||0;var r=e.length-n;if((!o||r<(o=Number(o)))&&(o=r),(r=t.length)%2!=0)throw new TypeError("Invalid hex string");r/2e.length)throw new RangeError("Index out of range")}function T(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r>>8*(o?r:1-r)}function I(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r>>8*(o?r:3-r)&255}function _(e,t,n,o){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,o,r){return r||_(e,0,n,4),i.write(e,t,n,o,23,4),n+4}function w(e,t,n,o,r){return r||_(e,0,n,8),i.write(e,t,n,o,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):I(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):I(this,e,t,!1),t+4},p.prototype.writeIntLE=function(e,t,n,o){e=+e,t|=0,o||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var r=0,i=1,s=0;for(this[t]=255&e;++r>0)-s&255;return t+n},p.prototype.writeIntBE=function(e,t,n,o){e=+e,t|=0,o||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var r=n-1,i=1,s=0;for(this[t+r]=255&e;0<=--r&&(i*=256);)e<0&&0===s&&0!==this[t+r+1]&&(s=1),this[t+r]=(e/i>>0)-s&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)),this[t]=255&(e=e<0?255+e+1: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):I(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):I(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 w(this,e,t,!0,n)},p.prototype.writeDoubleBE=function(e,t,n){return w(this,e,t,!1,n)},p.prototype.copy=function(e,t,n,o){if(n=n||0,o||0===o||(o=this.length),t>=e.length&&(t=e.length),(o=0=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length);var r,i=(o=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(c=t;c>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 k(e){return c.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 O(e,t,n,o){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},L("buffer").Buffer)},{"base64-js":78,buffer:81,ieee754:83,isarray:84}],82:[function(e,t,n){function o(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function a(e){return"function"==typeof e}function u(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}((t.exports=o).EventEmitter=o).prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.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},o.prototype.emit=function(e){var t,n,o,r,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 c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(l(n=this._events[e]))return!1;if(a(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:r=Array.prototype.slice.call(arguments,1),n.apply(this,r)}else if(u(n))for(r=Array.prototype.slice.call(arguments,1),o=(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},o.prototype.once=function(e,t){if(!a(t))throw TypeError("listener must be a function");var n=!1;function o(){this.removeListener(e,o),n||(n=!0,t.apply(this,arguments))}return o.listener=t,this.on(e,o),this},o.prototype.removeListener=function(e,t){var n,o,r,i;if(!a(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=(n=this._events[e]).length,o=-1,n===t||a(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(u(n)){for(i=r;0>1,l=-7,p=n?r-1:0,h=n?-1:1,n=e[t+p];for(p+=h,i=n&(1<<-l)-1,n>>=-l,l+=c;0>=-l,l+=o;0>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?1:-1,i=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),2<=(t+=1<=s+l?p/o:p*Math.pow(2,1-l))*o&&(s++,o/=2),u<=s+l?(c=0,s=u):1<=s+l?(c=(t*o-1)*Math.pow(2,r),s+=l):(c=t*Math.pow(2,l-1)*Math.pow(2,r),s=0));8<=r;e[n+h]=255&c,h+=d,c/=256,r-=8);for(s=s<":!0,"=":!0,"!":!0},P={" ":!0,"\t":!0,"\n":!0};function x(e){return"0"<=e&&e<="9"||"-"===e}function n(){}n.prototype={tokenize:function(e){var t,n,o,r=[];for(this._current=0;this._current"===n?"="===e[this._current]?(this._current++,{type:k,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",'"',"`"," ","\r","\n","\t"]),R=["'"].concat(n),N=["%","/","?",";","#"].concat(R),k=["/","?","#"],O=/^[a-z0-9A-Z_-]{0,63}$/,L=/^([a-z0-9A-Z_-]{0,63})(.*)$/,D={javascript:!0,"javascript:":!0},P={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},M=e("querystring");function r(e,t,n){if(e&&s(e)&&e instanceof h)return e;var o=new h;return o.parse(e,t,n),o}function U(e){return"string"==typeof e}function s(e){return"object"==typeof e&&null!==e}function d(e){return null===e}h.prototype.parse=function(e,t,n){if(!U(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o,r,i=(i=e).trim(),e=w.exec(i);if(e&&(o=(e=e[0]).toLowerCase(),this.protocol=o,i=i.substr(e.length)),(n||e||i.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(r="//"===i.substr(0,2))||e&&P[e]||(i=i.substr(2),this.slashes=!0)),!P[e]&&(r||e&&!x[e])){for(var s=-1,c=0;c>>((3&t)<<3)&255;return r})},{}],101:[function(e,t,n){var l,p,h=e("./lib/rng"),d=e("./lib/bytesToUuid"),f=0,g=0;t.exports=function(e,t,n){var o=t&&n||0,r=t||[],i=(e=e||{}).node||l,s=void 0!==e.clockseq?e.clockseq:p;null!=i&&null!=s||(a=h(),null==i&&(i=l=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=p=16383&(a[6]<<8|a[7])));var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),n=void 0!==e.nsecs?e.nsecs:g+1,a=c-f+(n-g)/1e4;if(a<0&&void 0===e.clockseq&&(s=s+1&16383),1e4<=(n=(a<0||f>>24&255,r[o++]=n>>>16&255,r[o++]=n>>>8&255,r[o++]=255&n,c=c/4294967296*1e4&268435455,r[o++]=c>>>8&255,r[o++]=255&c,r[o++]=c>>>24&15|16,r[o++]=c>>>16&255,r[o++]=s>>>8|128,r[o++]=255&s;for(var u=0;u<6;++u)r[o+u]=i[u];return t||d(r)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var s=e("./lib/rng"),c=e("./lib/bytesToUuid");t.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||s)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var i=0;i<16;++i)t[o+i]=r[i];return t||c(r)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./utils/LRU"),e=(Object.defineProperty(i.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),i.prototype.put=function(e,t){e="string"!=typeof e?i.getKeyString(e):e,t=this.populateValue(t);this.cache.put(e,t)},i.prototype.get=function(e){var t="string"!=typeof e?i.getKeyString(e):e,n=Date.now(),o=this.cache.get(t);if(o)for(var r=0;r>>=0;break;case"x":o=o.toString(16);break;case"X":o=o.toString(16).toUpperCase()}o=/[def]/.test(i[8])&&i[3]&&0<=o?"+"+o:o,s=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",c=i[6]-String(o).length,c=i[6]?function(e,t){for(var n=[];0=this._logLevel&&(s[e.level]>=this._echoLevel&&c[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.sendInternalLogEntryToServer=function(e){this._serverBoundInternalLogs.push(e),e.level in s&&s[e.level]>=this._logLevel&&(s[e.level]>=this._echoLevel&&c[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=o._logLevel}));n=new r.Blob([JSON.stringify(e,void 0,4)],["text/plain"]),e=document.createElement("a"),t=t||"agent-log";e.href=r.URL.createObjectURL(n),e.download=t+".txt",document.body.appendChild(e),e.click(),document.body.removeChild(e)},l.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,r.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,function(){0{try{n[t]=e[t]}catch(e){connect.getLog().info("deepcopyCrossOriginEvent failed on key: ",t).sendInternalLogToServer()}}),connect.deepcopy(n)},connect.getBaseUrl=function(){var e=a.location;return connect.sprintf("%s//%s:%s",e.protocol,e.hostname,e.port)},connect.getUrlWithProtocol=function(e){var t=a.location.protocol;return e.substr(0,t.length)!==t?connect.sprintf("%s//%s",t,e):e},connect.isFramed=function(){try{return window.self!==window.top}catch(e){return!0}},connect.hasOtherConnectedCCPs=function(){return 1o(e)).catch(()=>o({})):1!==n&&(e.status>=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout(function(){t(--n)},s):r(e)}).catch(function(e){r(e)})}(t)})},connect.backoff=function(o,r,i,s){connect.assertTrue(connect.isFunction(o),"func must be a Function");var c=this;o({success:function(e){s&&s.success&&s.success(e)},failure:function(e,t){var n;0>",e)},d.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},d.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var o=this,e=this.subMap.getSubscriptions("<>"),r=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&t!==connect.EventType.SERVER_BOUND_INTERNAL_LOG&&connect.getLog().trace("Publishing event: %s",t).sendInternalLogToServer(),t.startsWith(connect.ContactEvents.ACCEPTED)&&n&&n.contactId&&!(n instanceof connect.Contact)&&(n=new connect.Contact(n.contactId)),e.concat(r).forEach(function(e){try{e.f(n||null,t,o)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e).sendInternalLogToServer()}})},d.prototype.bridge=function(){var n=this;return function(e,t){n.trigger(t,e)}},d.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach(function(e){e.unsubscribe()})},connect.EventBus=d,connect.EventFactory=e,connect.EventType=t,connect.AgentEvents=o,connect.ConfigurationEvents=u,connect.ConnectionEvents=a,connect.ConnnectionEvents=a,connect.ContactEvents=i,connect.ChannelViewEvents=s,connect.TaskEvents=c,connect.VoiceIdEvents=l,connect.WebSocketEvents=r,connect.MasterTopics=n}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;var o=function(){};o.prototype.send=function(e){throw new connect.NotImplementedError},o.prototype.onMessage=function(e){throw new connect.NotImplementedError};var r=function(){o.call(this)};r.prototype=Object.create(o.prototype),(r.prototype.constructor=r).prototype.onMessage=function(e){},r.prototype.send=function(e){};function e(e,t){o.call(this),this.window=e,this.domain=t||"*"}((e.prototype=Object.create(o.prototype)).constructor=e).prototype.send=function(e){this.window.postMessage(e,this.domain)},e.prototype.onMessage=function(e){this.window.addEventListener("message",e)};var i=function(e,t,n){o.call(this),this.input=e,this.output=t,this.domain=n||"*"};i.prototype=Object.create(o.prototype),(i.prototype.constructor=i).prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(t){this.input.addEventListener("message",e=>{e.source===this.output?t(e):connect.getLog().warn("[Window IO Stream] message event came from somewhere other than the CCP iFrame").withCrossOriginEventObject(e).sendInternalLogToServer()})};function t(e){o.call(this),this.port=e,this.id=connect.randomId()}((t.prototype=Object.create(o.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){o.call(this),this.streamMap=e?connect.index(e,function(e){return e.getId()}):{},this.messageListeners=[]}((n.prototype=Object.create(o.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})};var s=function(e,t,n){this.name=e,this.upstream=t||new r,this.downstream=n||new r,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){t=t.data;t.event&&e.trigger(t.event,t.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 c(e,t,n,o){s.call(this,e,new i(t,n.contentWindow,o||"*"),null)}(c.prototype=Object.create(s.prototype)).constructor=c,connect.Stream=o,connect.NullStream=r,connect.WindowStream=e,connect.WindowIOStream=i,connect.PortStream=t,connect.StreamMultiplexer=n,connect.Conduit=s,connect.IFrameConduit=c}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect,connect.ClientMethods=connect.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","createTaskContact","clearContact","completeContact","destroyContact","rejectContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport"]),connect.AgentAppClientMethods={GET_CONTACT:"AgentAppService.Lcms.getContact",DELETE_SPEAKER:"AgentAppService.VoiceId.deleteSpeaker",ENROLL_BY_SESSION:"AgentAppService.VoiceId.enrollBySession",EVALUATE_SESSION:"AgentAppService.VoiceId.evaluateSession",DESCRIBE_SPEAKER:"AgentAppService.VoiceId.describeSpeaker",OPT_OUT_SPEAKER:"AgentAppService.VoiceId.optOutSpeaker",UPDATE_VOICE_ID_DATA:"AgentAppService.Lcms.updateVoiceIdData",DESCRIBE_SESSION:"AgentAppService.VoiceId.describeSession",UPDATE_SESSION:"AgentAppService.VoiceId.updateSession",START_VOICE_ID_SESSION:"AgentAppService.Nasa.startVoiceIdSession",LIST_INTEGRATION_ASSOCIATIONS:"AgentAppService.Acs.listIntegrationAssociations"},connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);var o=function(){};o.EMPTY_CALLBACKS={success:function(){},failure:function(){}},o.prototype.call=function(e,t,n){connect.assertNotNull(e,"method");n=n||o.EMPTY_CALLBACKS;this._callImpl(e,t||{},n)},o.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};function e(){o.call(this)}((e.prototype=Object.create(o.prototype)).constructor=e).prototype._callImpl=function(e,t,n){n&&n.failure&&(e=connect.sprintf("No such method exists on NULL client: %s",e),n.failure(new connect.ValueError(e),{message:e}))};var t=function(e,t,n){o.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(o.prototype),(t.prototype.constructor=t).prototype._callImpl=function(e,t,n){t=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[t.requestId]=n,this.conduit.sendUpstream(t.event,t)},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 i(e,t,n){connect.assertNotNull(e,"authCookieName"),connect.assertNotNull(t,"authToken"),connect.assertNotNull(n,"endpoint"),o.call(this),this.endpointUrl=connect.getUrlWithProtocol(n),this.authToken=t,this.authCookieName=e}((i.prototype=Object.create(o.prototype)).constructor=i).prototype._callImpl=function(e,t,c){var n={};n[this.authCookieName]=this.authToken;n={method:"post",body:JSON.stringify(t||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(n)}};connect.fetch(this.endpointUrl,n).then(function(e){c.success(e)}).catch(function(o){const r=o.body.getReader();let i="";const s=new TextDecoder;r.read().then(function e({done:t,value:n}){if(t){t=JSON.parse(i);return t.status=o.status,void c.failure(t)}return i+=s.decode(n),r.read().then(e)})})};function s(e,t,n){connect.assertNotNull(e,"authToken"),connect.assertNotNull(t,"region"),o.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=t,this.authToken=e,e=connect.getBaseUrl(),e=n||(e.includes(".awsapps.com")?e+"/connect/api":e+"/api"),e=new AWS.Endpoint(e),this.client=new AWS.Connect({endpoint:e})}((s.prototype=Object.create(o.prototype)).constructor=s).prototype._callImpl=function(o,e,r){var t=this,i=connect.getLog();connect.contains(this.client,o)?(e=this._translateParams(o,e),i.trace("AWSClient: --\x3e Calling operation '%s'",o).sendInternalLogToServer(),this.client[o](e).on("build",function(e){e.httpRequest.headers["X-Amz-Bearer"]=t.authToken}).send(function(e,t){try{var n;e?(e.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION?r.authFailure():!r.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"):[],r.failure(n,t)):r.accessDenied(),i.trace("AWSClient: <-- Operation '%s' failed: %s",o,JSON.stringify(e)).sendInternalLogToServer()):(i.trace("AWSClient: <-- Operation '%s' succeeded.",o).withObject(t).sendInternalLogToServer(),r.success(t))}catch(e){connect.getLog().error("Failed to handle AWS API request for method %s",o).withException(e).sendInternalLogToServer()}})):(e=connect.sprintf("No such method exists on AWS client: %s",o),r.failure(new connect.ValueError(e),{message:e}))},s.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT&&e!==connect.ClientMethods.REJECT_CONTACT&&e!==connect.ClientMethods.CREATE_TASK_CONTACT},s.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},s.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}},s.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},s.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},s.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach(function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)}),e},s.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=o,connect.NullClient=e,connect.UpstreamConduitClient=n,connect.UpstreamConduitMasterClient=r,connect.AWSClient=s,connect.AgentAppClient=i}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;var o=function(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t};o.prototype.getAssociations=function(e){throw connect.NotImplementedError()},o.prototype.getFromState=function(){return this.fromState},o.prototype.getToState=function(){return this.toState};function e(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"associations"),o.call(this,e,t),this.associations=n}((e.prototype=Object.create(o.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"),o.call(this,e,t),this.closure=n}((i.prototype=Object.create(o.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,o){var r=this;if(!t)throw new Error("fromStateObj is not defined.");if(!n)throw new Error("toStateObj is not defined.");if(!o)throw new Error("assocObj is not defined.");return t instanceof Array?t.forEach(function(e){r.assoc(e,n,o)}):n instanceof Array?n.forEach(function(e){r.assoc(t,e,o)}):"function"==typeof o?this._addAssociation(new i(t,n,o)):o instanceof Array?this._addAssociation(new e(t,n,o)):this._addAssociation(new e(t,n,[o])),this},s.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var o=[],r=this.fromMap[s.ANY]||{},i=this.fromMap[t]||{};return o=(o=o.concat(this._getAssociationsFromMap(r,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,o){return(e[s.ANY]||[]).concat(e[o]||[]).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","InvalidLocale","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","task"]),connect.ContactInitiationMethod=connect.makeEnum(["inbound","outbound","transfer","queue_transfer","callback","api","disconnect"]),connect.ChannelType=connect.makeEnum(["VOICE","CHAT","TASK"]),connect.MediaType=connect.makeEnum(["softphone","chat","task"]),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.VoiceIdErrorTypes=connect.makeEnum(["no_speaker_id_found","speaker_id_not_enrolled","get_speaker_id_failed","get_speaker_status_failed","opt_out_speaker_failed","opt_out_speaker_in_lcms_failed","delete_speaker_failed","start_session_failed","evaluate_speaker_failed","session_not_exists","describe_session_failed","enroll_speaker_failed","update_speaker_id_failed","update_speaker_id_in_lcms_failed","not_supported_on_conference_calls","enroll_speaker_timeout","evaluate_speaker_timeout","get_domain_id_failed","no_domain_id_found"]),connect.CTIExceptions=connect.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException","QuotaExceededException"]),connect.VoiceIdStreamingStatus=connect.makeEnum(["ONGOING","ENDED","PENDING_CONFIGURATION"]),connect.VoiceIdAuthenticationDecision=connect.makeEnum(["ACCEPT","REJECT","NOT_ENOUGH_SPEECH","SPEAKER_NOT_ENROLLED","SPEAKER_OPTED_OUT","SPEAKER_ID_NOT_PROVIDED","SPEAKER_EXPIRED"]),connect.VoiceIdFraudDetectionDecision=connect.makeEnum(["NOT_ENOUGH_SPEECH","HIGH_RISK","LOW_RISK"]),connect.ContactFlowAuthenticationDecision=connect.makeEnum(["Authenticated","NotAuthenticated","Inconclusive","NotEnrolled","OptedOut","NotEnabled","Error"]),connect.ContactFlowFraudDetectionDecision=connect.makeEnum(["HighRisk","LowRisk","Inconclusive","NotEnabled","Error"]),connect.VoiceIdEnrollmentRequestStatus=connect.makeEnum(["NOT_ENOUGH_SPEECH","IN_PROGRESS","COMPLETED","FAILED"]),connect.VoiceIdSpeakerStatus=connect.makeEnum(["OPTED_OUT","ENROLLED"]),connect.VoiceIdConstants={EVALUATE_SESSION_DELAY:1e4,EVALUATION_MAX_POLL_TIMES:24,EVALUATION_POLLING_INTERVAL:5e3,ENROLLMENT_MAX_POLL_TIMES:120,ENROLLMENT_POLLING_INTERVAL:5e3,START_SESSION_DELAY:8e3},connect.AgentPermissions={OUTBOUND_CALL:"outboundCall",VOICE_ID:"voiceId"};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.onLocalMediaStreamCreated=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,e)},e.prototype.onSpeakerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,e)},e.prototype.onMicrophoneDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,e)},e.prototype.onRingerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.RINGER_DEVICE_CHANGED,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.setSpeakerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_SPEAKER_DEVICE,data:{deviceId:e}})},e.prototype.setMicrophoneDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_MICROPHONE_DEVICE,data:{deviceId:e}})},e.prototype.setRingerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_RINGER_DEVICE,data:{deviceId:e}})},e.prototype.getState=function(){return this._getData().snapshot.state},e.prototype.getNextState=function(){return this._getData().snapshot.nextState},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"TASK"!==t&&(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){var n=connect.core.getClient();e&&e.agentPreferences&&!connect.isValidLocale(e.agentPreferences.locale)?t&&t.failure&&t.failure(connect.AgentErrorStates.INVALID_LOCALE):n.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.setState=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.PUT_AGENT_STATE,{state:connect.assertNotNull(e,"state"),enqueueNextState:n&&!!n.enqueueNextState},t)},e.prototype.onEnqueuedNextState=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ENQUEUED_NEXT_STATE,e)},e.prototype.setStatus=e.prototype.setState,e.prototype.connect=function(e,t){var n=connect.core.getClient(),e=new connect.Endpoint(e);delete e.endpointId,n.call(connect.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:connect.assertNotNull(e,"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.getEndpoints=function(t,n,e){var o=this,r=connect.core.getClient();connect.assertNotNull(n,"callbacks"),connect.assertNotNull(n.success,"callbacks.success");var i=e||{};i.endpoints=i.endpoints||[],i.maxResults=i.maxResults||connect.DEFAULT_BATCH_SIZE,connect.isArray(t)||(t=[t]),r.call(connect.ClientMethods.GET_ENDPOINTS,{queueARNs:t,nextToken:i.nextToken||null,maxResults:i.maxResults},{success:function(e){e.nextToken?o.getEndpoints(t,n,{nextToken:e.nextToken,maxResults:i.maxResults,endpoints:i.endpoints.concat(e.endpoints)}):(i.endpoints=i.endpoints.concat(e.endpoints),e=i.endpoints.map(function(e){return new connect.Endpoint(e)}),n.success({endpoints:e,addresses:e}))},failure:n.failure})},e.prototype.getAddresses=e.prototype.getEndpoints,e.prototype._getResourceId=function(){queueArns=this.getAllQueueARNs();for(var e of queueArns){e=e.match(/\/agent\/([^/]+)/);if(e)return e[1]}return new Error("Agent.prototype._getResourceId: queueArns did not contain agentResourceId: ",queueArns)},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 o(e){this.contactId=e}o.prototype._getData=function(){return connect.core.getAgentDataProvider().getContactData(this.getContactId())},o.prototype._createConnectionAPI=function(e){return new(this.getType()===connect.ContactType.CHAT?connect.ChatConnection:this.getType()===connect.ContactType.TASK?connect.TaskConnection:connect.VoiceConnection)(this.contactId,e.connectionId)},o.prototype.getEventName=function(e){return connect.core.getContactEventName(e,this.getContactId())},o.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.REFRESH),e)},o.prototype.onIncoming=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.INCOMING),e)},o.prototype.onConnecting=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTING),e)},o.prototype.onPending=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.PENDING),e)},o.prototype.onAccepted=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACCEPTED),e)},o.prototype.onMissed=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.MISSED),e)},o.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)},o.prototype.onDestroy=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},o.prototype.onACW=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACW),e)},o.prototype.onConnected=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTED),e)},o.prototype.onError=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ERROR),e)},o.prototype.getContactId=function(){return this.contactId},o.prototype.getInitialContactId=o.prototype.getOriginalContactId=function(){return this._getData().initialContactId},o.prototype.getType=function(){return this._getData().type},o.prototype.getContactDuration=function(){return this._getData().contactDuration},o.prototype.getStatus=o.prototype.getState=function(){return this._getData().state},o.prototype.getStatusDuration=o.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},o.prototype.getQueue=function(){return this._getData().queue},o.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},o.prototype.getConnections=function(){var t=this;return this._getData().connections.map(function(e){return new(t.getType()===connect.ContactType.CHAT?connect.ChatConnection:t.getType()===connect.ContactType.TASK?connect.TaskConnection:connect.VoiceConnection)(t.contactId,e.connectionId)})},o.prototype.getInitialConnection=function(){return connect.find(this.getConnections(),function(e){return e.isInitialConnection()})||null},o.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},o.prototype.getThirdPartyConnections=function(){return this.getConnections().filter(function(e){return!e.isInitialConnection()&&e.getType()!==connect.ConnectionType.AGENT})},o.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter(function(e){return e.isActive()})[0]||null},o.prototype.getAgentConnection=function(){return connect.find(this.getConnections(),function(e){e=e.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING})},o.prototype.getName=function(){return this._getData().name},o.prototype.getContactMetadata=function(){return this._getData().contactMetadata},o.prototype.getDescription=function(){return this._getData().description},o.prototype.getReferences=function(){return this._getData().references},o.prototype.getAttributes=function(){return this._getData().attributes},o.prototype.getContactFeatures=function(){return this._getData().contactFeatures},o.prototype.isSoftphoneCall=function(){return null!=connect.find(this.getConnections(),function(e){return null!=e.getSoftphoneMediaInfo()})},o.prototype._isInbound=function(){return this._getData().initiationMethod!==connect.ContactInitiationMethod.OUTBOUND},o.prototype.isInbound=function(){var e=this.getInitialConnection();return e.getMediaType()===connect.MediaType.TASK?this._isInbound():!!e&&e.getType()===connect.ConnectionType.INBOUND},o.prototype.isConnected=function(){return this.getStatus().type===connect.ContactStateType.CONNECTED},o.prototype.accept=function(n){var e=connect.core.getClient(),o=this,r=this.getContactId();e.call(connect.ClientMethods.ACCEPT_CONTACT,{contactId:r},{success:function(e){var t=connect.core.getUpstream();t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(r)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,o.getContactId()),data:new connect.Contact(r)});t=new connect.Contact(r);connect.isFirefoxBrowser()&&t.isSoftphoneCall()&&connect.core.triggerReadyToStartSessionEvent(),n&&n.success&&n.success(e)},failure:n?n.failure:null})},o.prototype.destroy=function(){connect.getLog().warn("contact.destroy() has been deprecated.")},o.prototype.reject=function(e){connect.core.getClient().call(connect.ClientMethods.REJECT_CONTACT,{contactId:this.getContactId()},e)},o.prototype.complete=function(e){connect.core.getClient().call(connect.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},o.prototype.clear=function(e){connect.core.getClient().call(connect.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},o.prototype.notifyIssue=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:t},n)},o.prototype.addConnection=function(e,t){var n=connect.core.getClient(),e=new connect.Endpoint(e);delete e.endpointId,n.call(connect.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:e},t)},o.prototype.toggleActiveConnections=function(e){var t=connect.core.getClient(),n=null,o=connect.find(this.getConnections(),function(e){return e.getStatus().type===connect.ConnectionStateType.HOLD});null!=o?n=o.getConnectionId():0<(o=this.getConnections().filter(function(e){return e.isActive()})).length&&(n=o[0].getConnectionId()),t.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:n},e)},o.prototype.sendSoftphoneMetrics=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,softphoneStreamStatistics:e},t),connect.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:n.ccpVersion,stats:e})},o.prototype.sendSoftphoneReport=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e},t),connect.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e})},o.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},o.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};function r(e){connect.Contact.call(this,e.contactId),this.contactData=e}((r.prototype=Object.create(o.prototype)).constructor=r).prototype._getData=function(){return this.contactData},r.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};var i=function(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.getEndpoint=function(){return new connect.Endpoint(this._getData().endpoint)},i.prototype.getAddress=i.prototype.getEndpoint,i.prototype.getState=function(){return this._getData().state},i.prototype.getStatus=i.prototype.getState,i.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},i.prototype.getStatusDuration=i.prototype.getStateDuration,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};var s=function(e){this.contactId=e};s.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise(function(n,o){t.call(connect.AgentAppClientMethods.GET_CONTACT,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),awsAccountId:connect.core.getAgentDataProvider().getAWSAccountId()},{success:function(e){var t;e.contactData.customerId?(t={speakerId:e.contactData.customerId},connect.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),n(t)):(t=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call"),o(t))},failure:function(e){connect.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(e)}})})},s.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var n=connect.core.getClient();return new Promise(function(o,r){e.getSpeakerId().then(function(t){e.getDomainId().then(function(e){n.call(connect.AgentAppClientMethods.DESCRIBE_SPEAKER,{SpeakerId:connect.assertNotNull(t.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){var t=JSON.parse(e);switch(t.status){case 400:case 404:var n=t;n.type=n.type||connect.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,connect.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),o(n);break;default:connect.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();n=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);r(n)}}})}).catch(function(e){r(e)})}).catch(function(e){r(e)})})},s.prototype._optOutSpeakerInLcms=function(e){var o=this,r=connect.core.getClient();return new Promise(function(t,n){r.call(connect.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,{ContactId:o.contactId,InstanceId:connect.core.getAgentDataProvider().getInstanceId(),AWSAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),CustomerId:connect.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0}},{success:function(e){connect.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),t(e)},failure:function(e){connect.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);n(e)}})})},s.prototype.optOutSpeaker=function(){var i=this;i.checkConferenceCall();var s=connect.core.getClient();return new Promise(function(o,r){i.getSpeakerId().then(function(n){i.getDomainId().then(function(e){var t=n.speakerId;s.call(connect.AgentAppClientMethods.OPT_OUT_SPEAKER,{SpeakerId:connect.assertNotNull(t,"speakerId"),DomainId:e},{success:function(e){i._optOutSpeakerInLcms(t).catch(function(){}),connect.getLog().info("optOutSpeaker succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){connect.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);r(e)}})}).catch(function(e){r(e)})}).catch(function(e){r(e)})})},s.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var r=connect.core.getClient();return new Promise(function(n,o){e.getSpeakerId().then(function(t){e.getDomainId().then(function(e){r.call(connect.AgentAppClientMethods.DELETE_SPEAKER,{SpeakerId:connect.assertNotNull(t.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){connect.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(e)}})}).catch(function(e){o(e)})}).catch(function(e){o(e)})})},s.prototype.startSession=function(){var o=this;o.checkConferenceCall();var r=connect.core.getClient();return new Promise(function(t,n){o.getDomainId().then(function(e){r.call(connect.AgentAppClientMethods.START_VOICE_ID_SESSION,{contactId:o.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),customerAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:e},{success:function(e){e.sessionId?t(e):(connect.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer(),e=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api"),n(e))},failure:function(e){connect.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);n(e)}})}).catch(function(e){n(e)})})},s.prototype.evaluateSpeaker=function(e){var i=this;i.checkConferenceCall();var t=connect.core.getClient(),s=connect.core.getAgentDataProvider().getContactData(this.contactId),c=0;return new Promise(function(n,o){function r(){i.getDomainId().then(function(e){t.call(connect.AgentAppClientMethods.EVALUATE_SESSION,{SessionNameOrId:s.initialContactId||this.contactId,DomainId:e},{success:function(e){if(++c=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){e=e.prefix||"";return"DEBUG"===this._logsDestination?this.consoleLoggerWrapper:new y(e)}},{key:"updateLoggerConfig",value:function(e){e=e||{};this._level=e.level||f.DEBUG,this._clientLogger=e.logger||null,this._logsDestination="NULL",e.debug&&(this._logsDestination="DEBUG"),e.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),b),m=(h(S,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),S),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)}(E,m),h(E,[{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=r.precision?n.substring(0,r.precision):n;break;case"t":n=String(!!n),n=r.precision?n.substring(0,r.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=r.precision?n.substring(0,r.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=r.precision?n.substring(0,r.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(r.type)?p+=n:(!d.number.test(r.type)||c&&!r.sign?a="":(a=c?"+":"-",n=n.toString().replace(d.sign,"")),i=r.pad_char?"0"===r.pad_char?"0":r.pad_char.charAt(1):" ",s=r.width-(a+n).length,s=r.width&&0t.packetsLost?e.packetsLost-t.packetsLost:0,t=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,o,t,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},U=function(e){return null!==e&&window.clearInterval(e),null},F=function(e,t){c=U(c),a=U(a),d(e,t,B(o,i),B(r,s)),h(e)},q=function(e,t,n,o,r,i,s){this.softphoneStreamType=o,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=r,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},B=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},j=function(e){this._originalLogger=e;var o=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),t="";return e.forEach(function(){t+=" %s"}),n.apply(o._originalLogger,[connect.LogComponent.SOFTPHONE,t].concat(e))}}};j.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},j.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},j.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},j.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},j.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var i,n=this;(g=new j(connect.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),connect.RtcPeerConnectionFactory&&(i=new connect.RtcPeerConnectionFactory(g,connect.core.getWebSocketManager(),E,connect.hitch(n,S,{transportType:"softphone",softphoneClientId:E}),connect.hitch(n,N))),D()||N(m.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ","");R({success:function(e){connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){N(e,"Your microphone is not enabled in your browser. ","")}});C(),T(),I(),this.ringtoneEngine=null;var s={},c={};this.onInitContactSub={};var a=!(this.onInitContactSub.unsubscribe=function(){}),u=null,l=null,o=function(e,t){a=!0,u=e,l=t},p=function(){a=!1,l=u=null};this.getSession=function(e){return s[e]},this.replaceLocalMediaTrack=function(e,t){var n=v[e].stream;n&&(e=n.getAudioTracks()[0],t.enabled=e.enabled,e.enabled=!1,n.removeTrack(e),n.addTrack(t))};var r=function(e){return e.getStatus().type===connect.ContactStatusType.ENDED||e.getStatus().type===connect.ContactStatusType.ERROR||e.getStatus().type===connect.ContactStatusType.MISSED},h=function(n){var o;s.hasOwnProperty(n)&&(o=s[n],new Promise(function(e,t){delete s[n],delete c[n],o.hangup()}).catch(function(e){lily.getLog().warn("Clean up the session locally "+n,e.message).sendInternalLogToServer()}))};this.startSession=function(e,t){var n,o=a?u:e,r=a?l:t;o&&r&&(p(),c[r]=!0,g.info("Softphone call detected:","contactId "+o.getContactId(),"agent connectionId "+r).sendInternalLogToServer(),function(e){if(0o&&n.handleSendLogsRequest(n.logsBuffer)}),this.conduit.onDownstream(connect.EventType.CONFIGURE,function(e){e.authToken&&e.authToken!==n.initData.authToken&&(n.initData=e,connect.core.init(e),t?connect.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(connect.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),connect.WebSocketManager.setGlobalConfig({loggerConfig:{logger:connect.getLog()}}),(t=connect.WebSocketManager.create()).onInitFailure(function(){n.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE)}),t.onConnectionOpen(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_OPEN,e)}),t.onConnectionClose(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_CLOSE,e)}),t.onConnectionGain(function(){n.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED),n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_GAIN)}),t.onConnectionLost(function(e){n.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_LOST,e)}),t.onSubscriptionUpdate(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_UPDATE,e)}),t.onSubscriptionFailure(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_FAILURE,e)}),t.onAllMessage(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.ALL_MESSAGE,e)}),n.conduit.onDownstream(connect.WebSocketEvents.SEND,function(e){t.sendMessage(e)}),n.conduit.onDownstream(connect.WebSocketEvents.SUBSCRIBE,function(e){t.subscribeTopics(e)}),t.init(connect.hitch(n,n.getWebSocketUrl)).then(function(e){e&&!e.webSocketConnectionFailed?(connect.getLog().info("Kicking off agent polling").sendInternalLogToServer(),n.pollForAgent(),connect.getLog().info("Kicking off config polling").sendInternalLogToServer(),n.pollForAgentConfiguration({repeatForever:!0}),connect.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),r.setInterval(connect.hitch(n,n.checkAuthToken),i)):connect.webSocketInitFailed||(n.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE),connect.webSocketInitFailed=!0)})))}),this.conduit.onDownstream(connect.EventType.TERMINATE,function(){n.handleSendLogsRequest(n.logsBuffer),connect.core.terminate(),n.conduit.sendDownstream(connect.EventType.TERMINATED)}),this.conduit.onDownstream(connect.EventType.SYNCHRONIZE,function(){n.conduit.sendDownstream(connect.EventType.ACKNOWLEDGE)}),this.conduit.onDownstream(connect.EventType.BROADCAST,function(e){n.conduit.sendDownstream(e.event,e.data)}),r.onconnect=function(e){var e=e.ports[0],t=new connect.PortStream(e);n.multiplexer.addStream(t),e.start();e=new connect.Conduit(t.getId(),null,t);e.sendDownstream(connect.EventType.ACKNOWLEDGE,{id:t.getId()}),n.portConduitMap[t.getId()]=e,n.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(n.portConduitMap).length}),null!==n.agent&&n.updateAgent(),e.onDownstream(connect.EventType.API_REQUEST,connect.hitch(n,n.handleAPIRequest,e)),e.onDownstream(connect.EventType.MASTER_REQUEST,connect.hitch(n,n.handleMasterRequest,e,t.getId())),e.onDownstream(connect.EventType.RELOAD_AGENT_CONFIGURATION,connect.hitch(n,n.pollForAgentConfiguration)),e.onDownstream(connect.EventType.CLOSE,function(){n.multiplexer.removeStream(t),delete n.portConduitMap[t.getId()],n.masterCoord.removeMaster(t.getId()),n.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(n.portConduitMap).length})})}}t.prototype.pollForAgent=function(){var n=this,e=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:n.nextToken,timeout:3e4},{success:function(t){try{n.agent=n.agent||{},n.agent.snapshot=t.snapshot,n.agent.snapshot.localTimestamp=connect.now(),n.agent.snapshot.skew=n.agent.snapshot.snapshotTimestamp-n.agent.snapshot.localTimestamp,n.nextToken=t.nextToken,connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(t).sendInternalLogToServer(),n.updateAgent()}catch(e){connect.getLog().error("Long poll failed to update agent.").withObject(t).withException(e).sendInternalLogToServer()}finally{r.setTimeout(connect.hitch(n,n.pollForAgent),100)}},failure:function(e,t){try{connect.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:e,data:t})}finally{r.setTimeout(connect.hitch(n,n.pollForAgent),5e3)}},authFailure:function(){e()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentConfiguration=function(e){var n=this,o=e||{},t=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(e){e=e.configuration;n.pollForAgentPermissions(e),n.pollForAgentStates(e),n.pollForDialableCountryCodes(e),n.pollForRoutingProfileQueues(e),o.repeatForever&&r.setTimeout(connect.hitch(n,n.pollForAgentConfiguration,o),3e4)},failure:function(e,t){try{connect.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:e,data:t})}finally{o.repeatForever&&r.setTimeout(connect.hitch(n,n.pollForAgentConfiguration),3e4,o)}},authFailure:function(){t()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentStates=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForAgentStates(t,{states:(o.states||[]).concat(e.states),nextToken:e.nextToken,maxResults:o.maxResults}):(t.agentStates=(o.states||[]).concat(e.states),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentPermissions=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForAgentPermissions(t,{permissions:(o.permissions||[]).concat(e.permissions),nextToken:e.nextToken,maxResults:o.maxResults}):(t.permissions=(o.permissions||[]).concat(e.permissions),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForDialableCountryCodes=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForDialableCountryCodes(t,{countryCodes:(o.countryCodes||[]).concat(e.countryCodes),nextToken:e.nextToken,maxResults:o.maxResults}):(t.dialableCountries=(o.countryCodes||[]).concat(e.countryCodes),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForRoutingProfileQueues=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:t.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForRoutingProfileQueues(t,{countryCodes:(o.queues||[]).concat(e.queues),nextToken:e.nextToken,maxResults:o.maxResults}):(t.routingProfile.queues=(o.queues||[]).concat(e.queues),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.handleAPIRequest=function(n,o){var r=this;this.client.call(o.method,o.params,{success:function(e){e=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,o,e);n.sendDownstream(e.event,e)},failure:function(e,t){t=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,o,t,JSON.stringify(e));n.sendDownstream(t.event,t),connect.getLog().error("'%s' API request failed",o.method).withObject({request:r.filterAuthToken(o),response:t}).withException(e).sendInternalLogToServer()},authFailure:connect.hitch(r,r.handleAuthFail)})},t.prototype.handleMasterRequest=function(e,t,n){var o=this.conduit,r=null;switch(n.method){case connect.MasterMethods.BECOME_MASTER:var i=this.masterCoord.getMaster(n.params.topic),s=Boolean(i)&&i!==t;this.masterCoord.setMaster(n.params.topic,t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:t,takeOver:s,topic:n.params.topic}),s&&o.sendDownstream(r.event,r);break;case connect.MasterMethods.CHECK_MASTER:(i=this.masterCoord.getMaster(n.params.topic))||n.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(n.params.topic,t),i=t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:i,isMaster:t===i,topic:n.params.topic});break;default:throw new Error("Unknown master method: "+n.method)}e.sendDownstream(r.event,r)},t.prototype.updateAgentConfiguration=function(e){e.permissions&&e.dialableCountries&&e.agentStates&&e.routingProfile.queues?(this.agent=this.agent||{},this.agent.configuration=e,this.updateAgent()):connect.getLog().trace("Waiting to update agent configuration until all config data has been fetched.").sendInternalLogToServer()},t.prototype.updateAgent=function(){this.agent?this.agent.snapshot?this.agent.configuration?(this.agent.snapshot.status=this.agent.state,this.agent.snapshot.contacts&&1e.BLOCK_SIZE&&((t=new e).update(n),n=t.digest());e=new Uint8Array(e.BLOCK_SIZE);return e.set(n),e}(e,t),o=new Uint8Array(e.BLOCK_SIZE);o.set(n);for(var r=0;r>>32-r)+n&4294967295}function a(e,t,n,o,r,i,s){return c(t&n|~t&o,e,t,r,i,s)}function u(e,t,n,o,r,i,s){return c(t&o|n&~o,e,t,r,i,s)}function l(e,t,n,o,r,i,s){return c(t^n^o,e,t,r,i,s)}function p(e,t,n,o,r,i,s){return c(n^(t|~o),e,t,r,i,s)}(t.exports=o).BLOCK_SIZE=64,o.prototype.update=function(e){if(r.isEmptyData(e))return this;if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=r.convertToBuffer(e),n=0,o=t.byteLength;for(this.bytesHashed+=o;0>>0,!0),t.setUint32(60,Math.floor(o/4294967296),!0),this.hashBuffer(),this.finished=!0}for(var i=new DataView(new ArrayBuffer(16)),r=0;r<4;r++)i.setUint32(4*r,this.state[r],!0);o=new s(i.buffer,i.byteOffset,i.byteLength);return e?o.toString(e):o},o.prototype.hashBuffer=function(){var e=this.buffer,t=this.state,n=a(n=t[0],i=t[1],r=t[2],o=t[3],e.getUint32(0,!0),7,3614090360),o=a(o,n,i,r,e.getUint32(4,!0),12,3905402710),r=a(r,o,n,i,e.getUint32(8,!0),17,606105819),i=a(i,r,o,n,e.getUint32(12,!0),22,3250441966);n=a(n,i,r,o,e.getUint32(16,!0),7,4118548399),o=a(o,n,i,r,e.getUint32(20,!0),12,1200080426),r=a(r,o,n,i,e.getUint32(24,!0),17,2821735955),i=a(i,r,o,n,e.getUint32(28,!0),22,4249261313),n=a(n,i,r,o,e.getUint32(32,!0),7,1770035416),o=a(o,n,i,r,e.getUint32(36,!0),12,2336552879),r=a(r,o,n,i,e.getUint32(40,!0),17,4294925233),i=a(i,r,o,n,e.getUint32(44,!0),22,2304563134),n=a(n,i,r,o,e.getUint32(48,!0),7,1804603682),o=a(o,n,i,r,e.getUint32(52,!0),12,4254626195),r=a(r,o,n,i,e.getUint32(56,!0),17,2792965006),n=u(n,i=a(i,r,o,n,e.getUint32(60,!0),22,1236535329),r,o,e.getUint32(4,!0),5,4129170786),o=u(o,n,i,r,e.getUint32(24,!0),9,3225465664),r=u(r,o,n,i,e.getUint32(44,!0),14,643717713),i=u(i,r,o,n,e.getUint32(0,!0),20,3921069994),n=u(n,i,r,o,e.getUint32(20,!0),5,3593408605),o=u(o,n,i,r,e.getUint32(40,!0),9,38016083),r=u(r,o,n,i,e.getUint32(60,!0),14,3634488961),i=u(i,r,o,n,e.getUint32(16,!0),20,3889429448),n=u(n,i,r,o,e.getUint32(36,!0),5,568446438),o=u(o,n,i,r,e.getUint32(56,!0),9,3275163606),r=u(r,o,n,i,e.getUint32(12,!0),14,4107603335),i=u(i,r,o,n,e.getUint32(32,!0),20,1163531501),n=u(n,i,r,o,e.getUint32(52,!0),5,2850285829),o=u(o,n,i,r,e.getUint32(8,!0),9,4243563512),r=u(r,o,n,i,e.getUint32(28,!0),14,1735328473),n=l(n,i=u(i,r,o,n,e.getUint32(48,!0),20,2368359562),r,o,e.getUint32(20,!0),4,4294588738),o=l(o,n,i,r,e.getUint32(32,!0),11,2272392833),r=l(r,o,n,i,e.getUint32(44,!0),16,1839030562),i=l(i,r,o,n,e.getUint32(56,!0),23,4259657740),n=l(n,i,r,o,e.getUint32(4,!0),4,2763975236),o=l(o,n,i,r,e.getUint32(16,!0),11,1272893353),r=l(r,o,n,i,e.getUint32(28,!0),16,4139469664),i=l(i,r,o,n,e.getUint32(40,!0),23,3200236656),n=l(n,i,r,o,e.getUint32(52,!0),4,681279174),o=l(o,n,i,r,e.getUint32(0,!0),11,3936430074),r=l(r,o,n,i,e.getUint32(12,!0),16,3572445317),i=l(i,r,o,n,e.getUint32(24,!0),23,76029189),n=l(n,i,r,o,e.getUint32(36,!0),4,3654602809),o=l(o,n,i,r,e.getUint32(48,!0),11,3873151461),r=l(r,o,n,i,e.getUint32(60,!0),16,530742520),n=p(n,i=l(i,r,o,n,e.getUint32(8,!0),23,3299628645),r,o,e.getUint32(0,!0),6,4096336452),o=p(o,n,i,r,e.getUint32(28,!0),10,1126891415),r=p(r,o,n,i,e.getUint32(56,!0),15,2878612391),i=p(i,r,o,n,e.getUint32(20,!0),21,4237533241),n=p(n,i,r,o,e.getUint32(48,!0),6,1700485571),o=p(o,n,i,r,e.getUint32(12,!0),10,2399980690),r=p(r,o,n,i,e.getUint32(40,!0),15,4293915773),i=p(i,r,o,n,e.getUint32(4,!0),21,2240044497),n=p(n,i,r,o,e.getUint32(32,!0),6,1873313359),o=p(o,n,i,r,e.getUint32(60,!0),10,4264355552),r=p(r,o,n,i,e.getUint32(24,!0),15,2734768916),i=p(i,r,o,n,e.getUint32(52,!0),21,1309151649),n=p(n,i,r,o,e.getUint32(16,!0),6,4149444226),o=p(o,n,i,r,e.getUint32(44,!0),10,3174756917),r=p(r,o,n,i,e.getUint32(8,!0),15,718787259),i=p(i,r,o,n,e.getUint32(36,!0),21,3951481745),t[0]=n+t[0]&4294967295,t[1]=i+t[1]&4294967295,t[2]=r+t[2]&4294967295,t[3]=o+t[3]&4294967295}},{"./browserHashUtils":11,"buffer/":81}],14:[function(e,t,n){var r=e("buffer/").Buffer,o=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(o.isEmptyData(e))return this;var t=(e=o.convertToBuffer(e)).length;this.totalLength+=8*t;for(var n=0;n>t);var n=new r(20),o=new DataView(n.buffer);return o.setUint32(0,this.h0,!1),o.setUint32(4,this.h1,!1),o.setUint32(8,this.h2,!1),o.setUint32(12,this.h3,!1),o.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,o=this.h0,r=this.h1,i=this.h2,s=this.h3,c=this.h4,e=0;e<80;e++)var a=e<20?(n=s^r&(i^s),1518500249):e<40?(n=r^i^s,1859775393):e<60?(n=r&i|s&(r|i),2400959708):(n=r^i^s,3395469782),a=(o<<5|o>>>27)+n+c+a+(0|this.block[e]),c=s,s=i,i=r<<30|r>>>2,r=o,o=a;for(this.h0=this.h0+o|0,this.h1=this.h1+r|0,this.h2=this.h2+i|0,this.h3=this.h3+s|0,this.h4=this.h4+c|0,e=this.offset=0;e<16;e++)this.block[e]=0}},{"./browserHashUtils":11,"buffer/":81}],15:[function(e,t,n){var s=e("buffer/").Buffer,o=e("./browserHashUtils"),d=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]),r=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(o.isEmptyData(e))return this;var t=0,n=(e=o.convertToBuffer(e)).byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>r)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;0>>24&255,i[4*r+1]=this.state[r]>>>16&255,i[4*r+2]=this.state[r]>>>8&255,i[4*r+3]=this.state[r]>>>0&255;return e?i.toString(e):i},i.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],o=t[1],r=t[2],i=t[3],s=t[4],c=t[5],a=t[6],u=t[7],l=0;l<64;l++){l<16?this.temp[l]=(255&e[4*l])<<24|(255&e[4*l+1])<<16|(255&e[4*l+2])<<8|255&e[4*l+3]:(p=((h=this.temp[l-2])>>>17|h<<15)^(h>>>19|h<<13)^h>>>10,h=this.temp[l-15],this.temp[l]=(p+this.temp[l-7]|0)+(((h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3)+this.temp[l-16]|0));var p=(((s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7))+(s&c^~s&a)|0)+(u+(d[l]+this.temp[l]|0)|0)|0,h=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&r^o&r)|0,u=a,a=c,c=s,s=i+p|0,i=r,r=o,o=n,n=p+h|0}t[0]+=n,t[1]+=o,t[2]+=r,t[3]+=i,t[4]+=s,t[5]+=c,t[6]+=a,t[7]+=u}},{"./browserHashUtils":11,"buffer/":81}],16:[function(n,o,e){!function(e){!function(){var e=n("./util");e.crypto.lib=n("./browserCryptoLib"),e.Buffer=n("buffer/").Buffer,e.url=n("url/"),e.querystring=n("querystring/"),e.realClock=n("./realclock/browserClock"),e.environment="js",e.createEventStream=n("./event-stream/buffered-create-event-stream").createEventStream,e.isBrowser=function(){return!0},e.isNode=function(){return!1};var t,e=n("./core");o.exports=e,n("./credentials"),n("./credentials/credential_provider_chain"),n("./credentials/temporary_credentials"),n("./credentials/chainable_temporary_credentials"),n("./credentials/web_identity_credentials"),n("./credentials/cognito_identity_credentials"),n("./credentials/saml_credentials"),e.XML.Parser=n("./xml/browser_parser"),n("./http/xhr"),void 0===t&&(t={browser:!0})}.call(this)}.call(this,n("_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:86,"buffer/":81,"querystring/":92,"url/":94}],17:[function(e,t,n){var o,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 o(e){t(e,e?null:n.credentials)}function r(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){o(e=e&&r("Could not load credentials from "+n.credentials.constructor.name,e))}):(e=null,o(e=!n.credentials.accessKeyId||!n.credentials.secretAccessKey?r("Missing credentials"):e)):n.credentialProvider?n.credentialProvider.resolve(function(e,t){e=e&&r("Could not load credentials from any providers",e),n.credentials=t,o(e)}):o(r("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),e=new i.CredentialProviderChain;return e.providers.unshift(t),e.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===(o=e)&&"function"==typeof Promise&&(o=Promise);e=[i.Request,i.Credentials,i.CredentialProviderChain];i.S3&&(e.push(i.S3),i.S3.ManagedUpload&&e.push(i.S3.ManagedUpload)),i.util.addPromises(e,o)},getPromisesDependency:function(){return o}}),i.config=new i.Config},{"./core":18,"./credentials":19,"./credentials/credential_provider_chain":22}],18:[function(e,t,n){var o={util:e("./util")};({}).toString(),(t.exports=o).util.update(o,{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"),o.events=new o.SequentialExecutor,o.util.memoizedProperty(o,"endpointCache",function(){return new o.EndpointCache(o.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 r=e("./core");r.Credentials=r.util.inherit({constructor:function(){var e;r.util.hideProperties(this,["secretAccessKey"]),this.expired=!1,this.expireTime=null,this.refreshCallbacks=[],1===arguments.length&&"object"==typeof arguments[0]?(e=arguments[0].credentials||arguments[0],this.accessKeyId=e.accessKeyId,this.secretAccessKey=e.secretAccessKey,this.sessionToken=e.sessionToken):(this.accessKeyId=arguments[0],this.secretAccessKey=arguments[1],this.sessionToken=arguments[2])},expiryWindow:15,needsRefresh:function(){var e=r.util.date.getDate().getTime(),e=new Date(e+1e3*this.expiryWindow);return!!(this.expireTime&&e>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 o=this;1===o.refreshCallbacks.push(e)&&o.load(function(t){r.util.arrayEach(o.refreshCallbacks,function(e){n?e(t):r.util.defer(function(){e(t)})}),o.refreshCallbacks.length=0})},load:function(e){e()}}),r.Credentials.addPromisesToClass=function(e){this.prototype.getPromise=r.util.promisifyMethod("get",e),this.prototype.refreshPromise=r.util.promisifyMethod("refresh",e)},r.Credentials.deletePromisesFromClass=function(){delete this.prototype.getPromise,delete this.prototype.refreshPromise},r.util.addPromises(r.Credentials)},{"./core":18}],20:[function(e,t,n){var i=e("../core"),o=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}e=i.util.merge({params:t,credentials:e.masterCredentials||i.config.credentials},e.stsConfig||{});this.service=new o(e)},refresh:function(e){this.coalesceRefresh(e||i.util.fn.callback)},load:function(o){var r=this,i=r.service.config.params.RoleArn?"assumeRole":"getSessionToken";this.getTokenCode(function(e,t){var n={};e?o(e):(t&&(n.TokenCode=t),r.service[i](n,function(e,t){e||r.service.credentialsFrom(t,r),o(e)}))})},getTokenCode:function(o){var r=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 o(i.util.error(new Error("Error fetching MFA token: "+n),{code:r.errorCode}))}o(null,t)}):o(null)}})},{"../../clients/sts":8,"../core":18}],21:[function(e,t,n){var o=e("../core"),r=e("../../clients/cognitoidentity"),i=e("../../clients/sts");o.CognitoIdentityCredentials=o.util.inherit(o.Credentials,{localStorageKey:{id:"aws.cognito.identity-id.",providers:"aws.cognito.identity-providers."},constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.data=null,this._identityId=null,this._clientConfig=o.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||o.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 o=this;if("string"==typeof o.params.IdentityId)return n(null,o.params.IdentityId);o.cognito.getId(function(e,t){!e&&t.IdentityId?(o.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 o=this;o.cognito.getCredentialsForIdentity(function(e,t){e?o.clearIdOnNotAuthorized(e):(o.cacheId(t),o.data=t,o.loadCredentials(o.data,o)),n(e)})},getCredentialsFromSTS:function(n){var o=this;o.cognito.getOpenIdToken(function(e,t){e?(o.clearIdOnNotAuthorized(e),n(e)):(o.cacheId(t),o.params.WebIdentityToken=t.Token,o.webIdentityCredentials.refresh(function(e){e||(o.data=o.webIdentityCredentials.data,o.sts.credentialsFrom(o.data,o)),n(e)}))})},loadCachedId:function(){var e,t,n=this;o.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 o.WebIdentityCredentials(this.params,t),this.cognito||((e=o.util.merge({},t)).params=this.params,this.cognito=new r(e)),this.sts=this.sts||new i(t)},cacheId:function(e){this._identityId=e.IdentityId,this.params.IdentityId=this._identityId,o.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=o.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 c=e("../core");c.CredentialProviderChain=c.util.inherit(c.Credentials,{constructor:function(e){this.providers=e||c.CredentialProviderChain.defaultProviders.slice(0),this.resolveCallbacks=[]},resolve:function(e){var r,i,s=this;return 0===s.providers.length?e(new Error("No providers")):1===s.resolveCallbacks.push(e)&&(r=0,i=s.providers.slice(0),function t(n,o){if(!n&&o||r===i.length)return c.util.arrayEach(s.resolveCallbacks,function(e){e(n,o)}),void(s.resolveCallbacks.length=0);var e=i[r++];(o="function"==typeof e?e.call():e).get?o.get(function(e){t(e,e?null:o)}):t(null,o)}()),s}}),c.CredentialProviderChain.defaultProviders=[],c.CredentialProviderChain.addPromisesToClass=function(e){this.prototype.resolvePromise=c.util.promisifyMethod("resolve",e)},c.CredentialProviderChain.deletePromisesFromClass=function(){delete this.prototype.resolvePromise},c.util.addPromises(c.CredentialProviderChain)},{"../core":18}],23:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.SAMLCredentials=o.util.inherit(o.Credentials,{constructor:function(e){o.Credentials.call(this),this.expired=!0,this.params=e},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.service.assumeRoleWithSAML(function(e,t){e||o.service.credentialsFrom(t,o),n(e)})},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],24:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.TemporaryCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.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||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.masterCredentials.get(function(){o.service.config.credentials=o.masterCredentials,(o.params.RoleArn?o.service.assumeRole:o.service.getSessionToken).call(o.service,function(e,t){e||o.service.credentialsFrom(t,o),n(e)})})},loadMasterCredentials:function(e){for(this.masterCredentials=e||o.config.credentials;this.masterCredentials.masterCredentials;)this.masterCredentials=this.masterCredentials.masterCredentials;"function"!=typeof this.masterCredentials.get&&(this.masterCredentials=new o.Credentials(this.masterCredentials))},createClients:function(){this.service=this.service||new r({params:this.params})}})},{"../../clients/sts":8,"../core":18}],25:[function(e,t,n){var o=e("../core"),r=e("../../clients/sts");o.WebIdentityCredentials=o.util.inherit(o.Credentials,{constructor:function(e,t){o.Credentials.call(this),this.expired=!0,this.params=e,this.params.RoleSessionName=this.params.RoleSessionName||"web-identity",this.data=null,this._clientConfig=o.util.copy(t||{})},refresh:function(e){this.coalesceRefresh(e||o.util.fn.callback)},load:function(n){var o=this;o.createClients(),o.service.assumeRoleWithWebIdentity(function(e,t){o.data=null,e||(o.data=t,o.service.credentialsFrom(t,o)),n(e)})},createClients:function(){var e;this.service||((e=o.util.merge({},this._clientConfig)).params=this.params,this.service=new r(e))}})},{"../../clients/sts":8,"../core":18}],26:[function(e,t,n){!function(a){!function(){var u=e("./core"),l=e("./util"),o=["AWS_ENABLE_ENDPOINT_DISCOVERY","AWS_ENDPOINT_DISCOVERY_ENABLED"];function p(e){var t=e.service,n=t.api||{},e=(n.operations,{});return t.config.region&&(e.region=t.config.region),n.serviceId&&(e.serviceId=n.serviceId),t.config.credentials.accessKeyId&&(e.accessKeyId=t.config.credentials.accessKeyId),e}function h(e,t){var n={};return function o(r,i,s){s&&null!=i&&"structure"===s.type&&s.required&&0=this.HEADERS_RECEIVED&&!u&&(s.statusCode=a.status,s.headers=r.parseHeaders(a.getAllResponseHeaders()),s.emit("headers",s.statusCode,s.headers,a.statusText),u=!0),this.readyState===this.DONE&&r.finishRequest(a,s)},!1),a.upload.addEventListener("progress",function(e){s.emit("sendProgress",e)}),a.addEventListener("progress",function(e){s.emit("receiveProgress",e)},!1),a.addEventListener("timeout",function(){o(l.util.error(new Error("Timeout"),{code:"TimeoutError"}))},!1),a.addEventListener("error",function(){o(l.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},!1),a.addEventListener("abort",function(){o(l.util.error(new Error("Request aborted"),{code:"RequestAbortedError"}))},!1),n(s),a.open(t.method,c,!1!==e.xhrAsync),l.util.each(t.headers,function(e,t){"Content-Length"!==e&&"User-Agent"!==e&&"Host"!==e&&a.setRequestHeader(e,t)}),e.timeout&&!1!==e.xhrAsync&&(a.timeout=e.timeout),e.xhrWithCredentials&&(a.withCredentials=!0);try{a.responseType="arraybuffer"}catch(e){}try{t.body?a.send(t.body):a.send()}catch(e){if(!t.body||"object"!=typeof t.body.buffer)throw e;a.send(t.body.buffer)}return s},parseHeaders:function(e){var n={};return l.util.arrayEach(e.split(/\r?\n/),function(e){var t=e.split(":",1)[0],e=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,o){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 "+o+" <= "+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,o){if(null==e)return!1;for(var r=!1,i=0;i=e.maxRetries&&(t.MaxRetriesExceeded=1),u.emit("apiCall",[t]))})},setupRequestListeners:function(e){},getSignerClass:function(e){var t=null,n="";return e&&(n=(t=(e.service.api.operations||{})[e.operation]||null)?t.authtype:""),n=this.config.signatureVersion||("v4"===n||"v4-unsigned-body"===n?"v4":this.api.signatureVersion),l.Signers.RequestSigner.getVersion(n)},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;return e=(e=(e=e.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){t=new Error;throw l.util.error(t,"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 o,n=s(l.Service,n||{});return"string"==typeof e?(l.Service.addVersions(n,t),o=n.serviceIdentifier||e,n.serviceIdentifier=o):(n.prototype.api=e,l.Service.defineMethods(n)),l.SequentialExecutor.call(this.prototype),!this.prototype.publisher&&l.util.clientSideMonitoring&&(o=l.util.clientSideMonitoring.Publisher,e=(0,l.util.clientSideMonitoring.configProvider)(),this.prototype.publisher=new o(e),e.enabled&&(l.Service._clientSideMonitoring=!0)),l.SequentialExecutor.call(n.prototype),l.Service.addDefaultMonitoringListeners(n.prototype),n},addVersions:function(e,t){Array.isArray(t)||(t=[t]),e.services=e.services||{};for(var n=0;n=t.length)return n.push(null);e=o+e;e>t.length&&(e=t.length),n.push(t.slice(o,e)),o=e},n},concat:function(e){for(var t,n=0,o=0,r=0;r>>8^t[255&(n^e.readUInt8(o))];return(-1^n)>>>0},hmac:function(e,t,n,o){return"buffer"===(n=n||"binary")&&(n=void 0),o=o||"sha256","string"==typeof t&&(t=u.buffer.toBuffer(t)),u.crypto.lib.createHmac(o,e).update(t).digest(n)},md5:function(e,t,n){return u.crypto.hash("md5",e,t,n)},sha256:function(e,t,n){return u.crypto.hash("sha256",e,t,n)},hash:function(e,t,n,o){var r=u.crypto.createHash(e);"buffer"===(n=n||"binary")&&(n=void 0),"string"==typeof t&&(t=u.buffer.toBuffer(t));var i=u.arraySliceFn(t),e=u.Buffer.isBuffer(t);if(u.isBrowser()&&"undefined"!=typeof ArrayBuffer&&t&&t.buffer instanceof ArrayBuffer&&(e=!0),o&&"object"==typeof t&&"function"==typeof t.on&&!e)t.on("data",function(e){r.update(e)}),t.on("error",function(e){o(e)}),t.on("end",function(){o(null,r.digest(n))});else{if(!o||!i||e||"undefined"==typeof FileReader){u.isBrowser()&&"object"==typeof t&&!e&&(t=new u.Buffer(new Uint8Array(t)));e=r.update(t).digest(n);return o&&o(null,e),e}var s=0,c=new FileReader;c.onerror=function(){o(new Error("Failed to read data."))},c.onload=function(){var e=new u.Buffer(new Uint8Array(c.result));r.update(e),s+=e.length,c._continueReading()},c._continueReading=function(){var e;s>=t.size?o(null,r.digest(n)):((e=s+524288)>t.size&&(e=t.size),c.readAsArrayBuffer(i.call(t,s,e)))},c._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 c=e("./escape-attribute").escapeAttribute;function o(e,t){void 0===t&&(t=[]),this.name=e,this.children=t,this.attributes={}}o.prototype.addAttribute=function(e,t){return this.attributes[e]=t,this},o.prototype.addChildNode=function(e){return this.children.push(e),this},o.prototype.removeAttribute=function(e){return delete this.attributes[e],this},o.prototype.toString=function(){for(var e=Boolean(this.children.length),t="<"+this.name,n=this.attributes,o=0,r=Object.keys(n);o"+this.children.map(function(e){return e.toString()}).join("")+"":"/>")},t.exports={XmlNode:o}},{"./escape-attribute":74}],77:[function(e,t,n){var o=e("./escape-element").escapeElement;function r(e){this.value=e}r.prototype.toString=function(){return o(""+this.value)},t.exports={XmlText:r}},{"./escape-element":75}],78:[function(e,t,n){"use strict";n.byteLength=function(e){var t=l(e),e=t[0],t=t[1];return 3*(e+t)/4-t},n.toByteArray=function(e){var t,n,o=l(e),r=o[0],o=o[1],i=new u(function(e,t){return 3*(e+t)/4-t}(r,o)),s=0,c=0>16&255,i[s++]=t>>8&255,i[s++]=255&t;2===o&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,i[s++]=255&t);1===o&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,i[s++]=t>>8&255,i[s++]=255&t);return i},n.fromByteArray=function(e){for(var t,n=e.length,o=n%3,r=[],i=0,s=n-o;i>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}(o));return r.join("")}(e,i,s>2]+c[t<<4&63]+"==")):2==o&&(t=(e[n-2]<<8)+e[n-1],r.push(c[t>>10]+c[t>>4&63]+c[t<<2&63]+"="));return r.join("")};for(var c=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,i=o.length;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},h=y-1,E=Math.floor,S=String.fromCharCode;function b(e){throw RangeError(p[e])}function d(e,t){for(var n=e.length,o=[];n--;)o[n]=t(e[n]);return o}function f(e,t){var n=e.split("@"),o="";return 1>>10&1023|55296),e=56320|1023&e),t+=S(e)}).join("")}function T(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function I(e,t,n){var o=0;for(e=n?E(e/c):e>>1,e+=E(e/t);h*v>>1E((m-l)/i))&&b("overflow"),l+=c*i,!(c<(c=s<=h?1:h+v<=s?v:s-h));s+=y)i>E(m/(c=y-c))&&b("overflow"),i*=c;h=I(l-r,t=a.length+1,0==r),E(l/t)>m-p&&b("overflow"),p+=E(l/t),l%=t,a.splice(l++,0,p)}return g(a)}function A(e){for(var t,n,o,r,i,s,c,a,u,l,p=[],h=(e=C(e)).length,d=128,f=72,g=t=0;gE((m-t)/(a=n+1))&&b("overflow"),t+=(r-d)*a,d=r,g=0;gm&&b("overflow"),c==d){for(i=t,s=y;!(i<(u=s<=f?1:f+v<=s?v:s-f));s+=y)p.push(S(T(u+(l=i-u)%(u=y-u),0))),i=E(l/u);p.push(S(T(i,0))),f=I(t,a,n==o),t=0,++n}++t,++d}return p.join("")}if(r={version:"1.3.2",ucs2:{decode:C,encode:g},decode:_,encode:A,toASCII:function(e){return f(e,function(e){return u.test(e)?"xn--"+A(e):e})},toUnicode:function(e){return f(e,function(e){return a.test(e)?_(e.slice(4).toLowerCase()):e})}},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return r});else if(t&&n)if(R.exports==t)n.exports=r;else for(i in r)r.hasOwnProperty(i)&&(t[i]=r[i]);else e.punycode=r}(this)}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],81:[function(L,e,D){!function(e,t){!function(){"use strict";var c=L("base64-js"),i=L("ieee754"),s=L("isarray");function n(){return p.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function r(e,t){if(n()=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function d(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;var n=(e="string"!=typeof e?""+e:e).length;if(0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(e).length;default:if(o)return N(e).length;t=(""+t).toLowerCase(),o=!0}}function t(e,t,n){var o,r,i,s=!1;if((t=void 0===t||t<0?0:t)>this.length)return"";if((n=void 0===n||n>this.length?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 o=e.length;(!t||t<0)&&(t=0);(!n||n<0||o=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=p.from(t,o)),p.isBuffer(t))return 0===t.length?-1:m(e,t,n,o,r);if("number"==typeof t)return t&=255,p.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?(r?Uint8Array.prototype.indexOf:Uint8Array.prototype.lastIndexOf).call(e,t,n):m(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function m(e,t,n,o,r){var i=1,s=e.length,c=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s/=i=2,c/=2,n/=2}function a(e,t){return 1===i?e[t]:e.readUInt16BE(t*i)}if(r)for(var u=-1,l=n;l>8,o=o%256,r.push(o),r.push(n);return r}(t,e.length-n),e,n,o)}function E(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r>>10&1023|55296),l=56320|1023&l),o.push(l),r+=p}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var n="",o=0;for(;ot&&(e+=" ... ")),""},p.prototype.compare=function(e,t,n,o,r){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===n&&(n=e?e.length:0),void 0===o&&(o=0),void 0===r&&(r=this.length),(t=void 0===t?0:t)<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(r<=o&&n<=t)return 0;if(r<=o)return-1;if(n<=t)return 1;if(this===e)return 0;for(var i=(r>>>=0)-(o>>>=0),s=(n>>>=0)-(t>>>=0),c=Math.min(i,s),a=this.slice(o,r),u=e.slice(t,n),l=0;lthis.length)throw new RangeError("Attempt to write outside buffer bounds");o=o||"utf8";for(var i,s,c,a=!1;;)switch(o){case"hex":return function(e,t,n,o){n=Number(n)||0;var r=e.length-n;if((!o||r<(o=Number(o)))&&(o=r),(r=t.length)%2!=0)throw new TypeError("Invalid hex string");r/2e.length)throw new RangeError("Index out of range")}function T(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r>>8*(o?r:1-r)}function I(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r>>8*(o?r:3-r)&255}function _(e,t,n,o){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function A(e,t,n,o,r){return r||_(e,0,n,4),i.write(e,t,n,o,23,4),n+4}function w(e,t,n,o,r){return r||_(e,0,n,8),i.write(e,t,n,o,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):I(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):I(this,e,t,!1),t+4},p.prototype.writeIntLE=function(e,t,n,o){e=+e,t|=0,o||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var r=0,i=1,s=0;for(this[t]=255&e;++r>0)-s&255;return t+n},p.prototype.writeIntBE=function(e,t,n,o){e=+e,t|=0,o||C(this,e,t,n,(o=Math.pow(2,8*n-1))-1,-o);var r=n-1,i=1,s=0;for(this[t+r]=255&e;0<=--r&&(i*=256);)e<0&&0===s&&0!==this[t+r+1]&&(s=1),this[t+r]=(e/i>>0)-s&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)),this[t]=255&(e=e<0?255+e+1: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):I(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):I(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 w(this,e,t,!0,n)},p.prototype.writeDoubleBE=function(e,t,n){return w(this,e,t,!1,n)},p.prototype.copy=function(e,t,n,o){if(n=n||0,o||0===o||(o=this.length),t>=e.length&&(t=e.length),(o=0=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length);var r,i=(o=e.length-t>>=0,n=void 0===n?this.length:n>>>0,"number"==typeof(e=e||0))for(c=t;c>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 k(e){return c.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 O(e,t,n,o){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}.call(this)}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},L("buffer").Buffer)},{"base64-js":78,buffer:81,ieee754:83,isarray:84}],82:[function(e,t,n){function o(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function a(e){return"function"==typeof e}function u(e){return"object"==typeof e&&null!==e}function l(e){return void 0===e}((t.exports=o).EventEmitter=o).prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.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},o.prototype.emit=function(e){var t,n,o,r,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 c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(l(n=this._events[e]))return!1;if(a(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:r=Array.prototype.slice.call(arguments,1),n.apply(this,r)}else if(u(n))for(r=Array.prototype.slice.call(arguments,1),o=(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},o.prototype.once=function(e,t){if(!a(t))throw TypeError("listener must be a function");var n=!1;function o(){this.removeListener(e,o),n||(n=!0,t.apply(this,arguments))}return o.listener=t,this.on(e,o),this},o.prototype.removeListener=function(e,t){var n,o,r,i;if(!a(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=(n=this._events[e]).length,o=-1,n===t||a(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(u(n)){for(i=r;0>1,l=-7,p=n?r-1:0,h=n?-1:1,n=e[t+p];for(p+=h,i=n&(1<<-l)-1,n>>=-l,l+=c;0>=-l,l+=o;0>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?1:-1,i=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),2<=(t+=1<=s+l?p/o:p*Math.pow(2,1-l))*o&&(s++,o/=2),u<=s+l?(c=0,s=u):1<=s+l?(c=(t*o-1)*Math.pow(2,r),s+=l):(c=t*Math.pow(2,l-1)*Math.pow(2,r),s=0));8<=r;e[n+h]=255&c,h+=d,c/=256,r-=8);for(s=s<":!0,"=":!0,"!":!0},P={" ":!0,"\t":!0,"\n":!0};function x(e){return"0"<=e&&e<="9"||"-"===e}function n(){}n.prototype={tokenize:function(e){var t,n,o,r=[];for(this._current=0;this._current"===n?"="===e[this._current]?(this._current++,{type:k,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",'"',"`"," ","\r","\n","\t"]),R=["'"].concat(n),N=["%","/","?",";","#"].concat(R),k=["/","?","#"],O=/^[a-z0-9A-Z_-]{0,63}$/,L=/^([a-z0-9A-Z_-]{0,63})(.*)$/,D={javascript:!0,"javascript:":!0},P={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},M=e("querystring");function r(e,t,n){if(e&&s(e)&&e instanceof h)return e;var o=new h;return o.parse(e,t,n),o}function U(e){return"string"==typeof e}function s(e){return"object"==typeof e&&null!==e}function d(e){return null===e}h.prototype.parse=function(e,t,n){if(!U(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o,r,i=(i=e).trim(),e=w.exec(i);if(e&&(o=(e=e[0]).toLowerCase(),this.protocol=o,i=i.substr(e.length)),(n||e||i.match(/^\/\/[^@\/]+@[^@\/]+/))&&(!(r="//"===i.substr(0,2))||e&&P[e]||(i=i.substr(2),this.slashes=!0)),!P[e]&&(r||e&&!x[e])){for(var s=-1,c=0;c>>((3&t)<<3)&255;return r})},{}],101:[function(e,t,n){var l,p,h=e("./lib/rng"),d=e("./lib/bytesToUuid"),f=0,g=0;t.exports=function(e,t,n){var o=t&&n||0,r=t||[],i=(e=e||{}).node||l,s=void 0!==e.clockseq?e.clockseq:p;null!=i&&null!=s||(a=h(),null==i&&(i=l=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=p=16383&(a[6]<<8|a[7])));var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),n=void 0!==e.nsecs?e.nsecs:g+1,a=c-f+(n-g)/1e4;if(a<0&&void 0===e.clockseq&&(s=s+1&16383),1e4<=(n=(a<0||f>>24&255,r[o++]=n>>>16&255,r[o++]=n>>>8&255,r[o++]=255&n,c=c/4294967296*1e4&268435455,r[o++]=c>>>8&255,r[o++]=255&c,r[o++]=c>>>24&15|16,r[o++]=c>>>16&255,r[o++]=s>>>8|128,r[o++]=255&s;for(var u=0;u<6;++u)r[o+u]=i[u];return t||d(r)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],102:[function(e,t,n){var s=e("./lib/rng"),c=e("./lib/bytesToUuid");t.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||s)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var i=0;i<16;++i)t[o+i]=r[i];return t||c(r)}},{"./lib/bytesToUuid":99,"./lib/rng":100}],103:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o=e("./utils/LRU"),e=(Object.defineProperty(i.prototype,"size",{get:function(){return this.cache.length},enumerable:!0,configurable:!0}),i.prototype.put=function(e,t){e="string"!=typeof e?i.getKeyString(e):e,t=this.populateValue(t);this.cache.put(e,t)},i.prototype.get=function(e){var t="string"!=typeof e?i.getKeyString(e):e,n=Date.now(),o=this.cache.get(t);if(o)for(var r=0;r>>=0;break;case"x":o=o.toString(16);break;case"X":o=o.toString(16).toUpperCase()}o=/[def]/.test(i[8])&&i[3]&&0<=o?"+"+o:o,s=i[4]?"0"==i[4]?"0":i[4].charAt(1):" ",c=i[6]-String(o).length,c=i[6]?function(e,t){for(var n=[];0=this._logLevel&&(s[e.level]>=this._echoLevel&&c[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.sendInternalLogEntryToServer=function(e){this._serverBoundInternalLogs.push(e),e.level in s&&s[e.level]>=this._logLevel&&(s[e.level]>=this._echoLevel&&c[e.getLevel()](e.toString()),e.line=this._lineCount++)},l.prototype.clearObjects=function(){for(var e=0;e=o._logLevel}));n=new r.Blob([JSON.stringify(e,void 0,4)],["text/plain"]),e=document.createElement("a"),t=t||"agent-log";e.href=r.URL.createObjectURL(n),e.download=t+".txt",document.body.appendChild(e),e.click(),document.body.removeChild(e)},l.prototype.scheduleUpstreamLogPush=function(e){connect.upstreamLogPushScheduled||(connect.upstreamLogPushScheduled=!0,r.setInterval(connect.hitch(this,this.reportMasterLogsUpStream,e),5e3))},l.prototype.reportMasterLogsUpStream=function(e){var t=this._logsToPush.slice();this._logsToPush=[],connect.ifMaster(connect.MasterTopics.SEND_LOGS,function(){0{try{n[t]=e[t]}catch(e){connect.getLog().info("deepcopyCrossOriginEvent failed on key: ",t).sendInternalLogToServer()}}),connect.deepcopy(n)},connect.getBaseUrl=function(){var e=a.location;return connect.sprintf("%s//%s:%s",e.protocol,e.hostname,e.port)},connect.getUrlWithProtocol=function(e){var t=a.location.protocol;return e.substr(0,t.length)!==t?connect.sprintf("%s//%s",t,e):e},connect.isFramed=function(){try{return window.self!==window.top}catch(e){return!0}},connect.hasOtherConnectedCCPs=function(){return 1o(e)).catch(()=>o({})):1!==n&&(e.status>=connect.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR||e.status===connect.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)?setTimeout(function(){t(--n)},s):r(e)}).catch(function(e){r(e)})}(t)})},connect.backoff=function(o,r,i,s){connect.assertTrue(connect.isFunction(o),"func must be a Function");var c=this;o({success:function(e){s&&s.success&&s.success(e)},failure:function(e,t){var n;0>",e)},d.prototype.getSubscriptions=function(e){return this.subMap.getSubscriptions(e)},d.prototype.trigger=function(t,n){connect.assertNotNull(t,"eventName");var o=this,e=this.subMap.getSubscriptions("<>"),r=this.subMap.getSubscriptions(t);this.logEvents&&t!==connect.EventType.LOG&&t!==connect.EventType.MASTER_RESPONSE&&t!==connect.EventType.API_METRIC&&t!==connect.EventType.SERVER_BOUND_INTERNAL_LOG&&connect.getLog().trace("Publishing event: %s",t).sendInternalLogToServer(),t.startsWith(connect.ContactEvents.ACCEPTED)&&n&&n.contactId&&!(n instanceof connect.Contact)&&(n=new connect.Contact(n.contactId)),e.concat(r).forEach(function(e){try{e.f(n||null,t,o)}catch(e){connect.getLog().error("'%s' event handler failed.",t).withException(e).sendInternalLogToServer()}})},d.prototype.bridge=function(){var n=this;return function(e,t){n.trigger(t,e)}},d.prototype.unsubscribeAll=function(){this.subMap.getAllSubscriptions().forEach(function(e){e.unsubscribe()})},connect.EventBus=d,connect.EventFactory=e,connect.EventType=t,connect.AgentEvents=o,connect.ConfigurationEvents=u,connect.ConnectionEvents=a,connect.ConnnectionEvents=a,connect.ContactEvents=i,connect.ChannelViewEvents=s,connect.TaskEvents=c,connect.VoiceIdEvents=l,connect.WebSocketEvents=r,connect.MasterTopics=n}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;var o=function(){};o.prototype.send=function(e){throw new connect.NotImplementedError},o.prototype.onMessage=function(e){throw new connect.NotImplementedError};var r=function(){o.call(this)};r.prototype=Object.create(o.prototype),(r.prototype.constructor=r).prototype.onMessage=function(e){},r.prototype.send=function(e){};function e(e,t){o.call(this),this.window=e,this.domain=t||"*"}((e.prototype=Object.create(o.prototype)).constructor=e).prototype.send=function(e){this.window.postMessage(e,this.domain)},e.prototype.onMessage=function(e){this.window.addEventListener("message",e)};var i=function(e,t,n){o.call(this),this.input=e,this.output=t,this.domain=n||"*"};i.prototype=Object.create(o.prototype),(i.prototype.constructor=i).prototype.send=function(e){this.output.postMessage(e,this.domain)},i.prototype.onMessage=function(t){this.input.addEventListener("message",e=>{e.source===this.output?t(e):connect.getLog().warn("[Window IO Stream] message event came from somewhere other than the CCP iFrame").withCrossOriginEventObject(e).sendInternalLogToServer()})};function t(e){o.call(this),this.port=e,this.id=connect.randomId()}((t.prototype=Object.create(o.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){o.call(this),this.streamMap=e?connect.index(e,function(e){return e.getId()}):{},this.messageListeners=[]}((n.prototype=Object.create(o.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})};var s=function(e,t,n){this.name=e,this.upstream=t||new r,this.downstream=n||new r,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){t=t.data;t.event&&e.trigger(t.event,t.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 c(e,t,n,o){s.call(this,e,new i(t,n.contentWindow,o||"*"),null)}(c.prototype=Object.create(s.prototype)).constructor=c,connect.Stream=o,connect.NullStream=r,connect.WindowStream=e,connect.WindowIOStream=i,connect.PortStream=t,connect.StreamMultiplexer=n,connect.Conduit=s,connect.IFrameConduit=c}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect,connect.ClientMethods=connect.makeEnum(["getAgentSnapshot","putAgentState","getAgentStates","getDialableCountryCodes","getRoutingProfileQueues","getAgentPermissions","getAgentConfiguration","updateAgentConfiguration","acceptContact","createOutboundContact","createTaskContact","clearContact","completeContact","destroyContact","rejectContact","notifyContactIssue","updateContactAttributes","createAdditionalConnection","destroyConnection","holdConnection","resumeConnection","toggleActiveConnections","conferenceConnections","sendClientLogs","sendDigits","sendSoftphoneCallReport","sendSoftphoneCallMetrics","getEndpoints","getNewAuthToken","createTransport"]),connect.AgentAppClientMethods={GET_CONTACT:"AgentAppService.Lcms.getContact",DELETE_SPEAKER:"AgentAppService.VoiceId.deleteSpeaker",ENROLL_BY_SESSION:"AgentAppService.VoiceId.enrollBySession",EVALUATE_SESSION:"AgentAppService.VoiceId.evaluateSession",DESCRIBE_SPEAKER:"AgentAppService.VoiceId.describeSpeaker",OPT_OUT_SPEAKER:"AgentAppService.VoiceId.optOutSpeaker",UPDATE_VOICE_ID_DATA:"AgentAppService.Lcms.updateVoiceIdData",DESCRIBE_SESSION:"AgentAppService.VoiceId.describeSession",UPDATE_SESSION:"AgentAppService.VoiceId.updateSession",START_VOICE_ID_SESSION:"AgentAppService.Nasa.startVoiceIdSession",LIST_INTEGRATION_ASSOCIATIONS:"AgentAppService.Acs.listIntegrationAssociations"},connect.MasterMethods=connect.makeEnum(["becomeMaster","checkMaster"]);var o=function(){};o.EMPTY_CALLBACKS={success:function(){},failure:function(){}},o.prototype.call=function(e,t,n){connect.assertNotNull(e,"method");n=n||o.EMPTY_CALLBACKS;this._callImpl(e,t||{},n)},o.prototype._callImpl=function(e,t,n){throw new connect.NotImplementedError};function e(){o.call(this)}((e.prototype=Object.create(o.prototype)).constructor=e).prototype._callImpl=function(e,t,n){n&&n.failure&&(e=connect.sprintf("No such method exists on NULL client: %s",e),n.failure(new connect.ValueError(e),{message:e}))};var t=function(e,t,n){o.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(o.prototype),(t.prototype.constructor=t).prototype._callImpl=function(e,t,n){t=connect.EventFactory.createRequest(this.requestEvent,e,t);this._requestIdCallbacksMap[t.requestId]=n,this.conduit.sendUpstream(t.event,t)},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 i(e,t,n){connect.assertNotNull(e,"authCookieName"),connect.assertNotNull(t,"authToken"),connect.assertNotNull(n,"endpoint"),o.call(this),this.endpointUrl=connect.getUrlWithProtocol(n),this.authToken=t,this.authCookieName=e}((i.prototype=Object.create(o.prototype)).constructor=i).prototype._callImpl=function(e,t,c){var n={};n[this.authCookieName]=this.authToken;n={method:"post",body:JSON.stringify(t||{}),headers:{Accept:"application/json","Content-Type":"application/json","X-Amz-target":e,"X-Amz-Bearer":JSON.stringify(n)}};connect.fetch(this.endpointUrl,n).then(function(e){c.success(e)}).catch(function(o){const r=o.body.getReader();let i="";const s=new TextDecoder;r.read().then(function e({done:t,value:n}){if(t){t=JSON.parse(i);return t.status=o.status,void c.failure(t)}return i+=s.decode(n),r.read().then(e)})})};function s(e,t,n){connect.assertNotNull(e,"authToken"),connect.assertNotNull(t,"region"),o.call(this),AWS.config.credentials=new AWS.Credentials({}),AWS.config.region=t,this.authToken=e,e=connect.getBaseUrl(),e=n||(e.includes(".awsapps.com")?e+"/connect/api":e+"/api"),e=new AWS.Endpoint(e),this.client=new AWS.Connect({endpoint:e})}((s.prototype=Object.create(o.prototype)).constructor=s).prototype._callImpl=function(o,e,r){var t=this,i=connect.getLog();connect.contains(this.client,o)?(e=this._translateParams(o,e),i.trace("AWSClient: --\x3e Calling operation '%s'",o).sendInternalLogToServer(),this.client[o](e).on("build",function(e){e.httpRequest.headers["X-Amz-Bearer"]=t.authToken}).send(function(e,t){try{var n;e?(e.code===connect.CTIExceptions.UNAUTHORIZED_EXCEPTION?r.authFailure():!r.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"):[],r.failure(n,t)):r.accessDenied(),i.trace("AWSClient: <-- Operation '%s' failed: %s",o,JSON.stringify(e)).sendInternalLogToServer()):(i.trace("AWSClient: <-- Operation '%s' succeeded.",o).withObject(t).sendInternalLogToServer(),r.success(t))}catch(e){connect.getLog().error("Failed to handle AWS API request for method %s",o).withException(e).sendInternalLogToServer()}})):(e=connect.sprintf("No such method exists on AWS client: %s",o),r.failure(new connect.ValueError(e),{message:e}))},s.prototype._requiresAuthenticationParam=function(e){return e!==connect.ClientMethods.COMPLETE_CONTACT&&e!==connect.ClientMethods.CLEAR_CONTACT&&e!==connect.ClientMethods.REJECT_CONTACT&&e!==connect.ClientMethods.CREATE_TASK_CONTACT},s.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},s.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}},s.prototype._translateRoutingProfile=function(e){return{name:e.name,routingProfileARN:e.routingProfileARN,defaultOutboundQueue:this._translateQueue(e.defaultOutboundQueue)}},s.prototype._translateQueue=function(e){return{queueARN:e.queueARN,name:e.name}},s.prototype._translateSoftphoneStreamStatistics=function(e){return e.forEach(function(e){"packetsCount"in e&&(e.packetCount=e.packetsCount,delete e.packetsCount)}),e},s.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=o,connect.NullClient=e,connect.UpstreamConduitClient=n,connect.UpstreamConduitMasterClient=r,connect.AWSClient=s,connect.AgentAppClient=i}(),function(){connect=this.connect||{},this.connect=connect,this.lily=connect;var o=function(e,t){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),this.fromState=e,this.toState=t};o.prototype.getAssociations=function(e){throw connect.NotImplementedError()},o.prototype.getFromState=function(){return this.fromState},o.prototype.getToState=function(){return this.toState};function e(e,t,n){connect.assertNotNull(e,"fromState"),connect.assertNotNull(t,"toState"),connect.assertNotNull(n,"associations"),o.call(this,e,t),this.associations=n}((e.prototype=Object.create(o.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"),o.call(this,e,t),this.closure=n}((i.prototype=Object.create(o.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,o){var r=this;if(!t)throw new Error("fromStateObj is not defined.");if(!n)throw new Error("toStateObj is not defined.");if(!o)throw new Error("assocObj is not defined.");return t instanceof Array?t.forEach(function(e){r.assoc(e,n,o)}):n instanceof Array?n.forEach(function(e){r.assoc(t,e,o)}):"function"==typeof o?this._addAssociation(new i(t,n,o)):o instanceof Array?this._addAssociation(new e(t,n,o)):this._addAssociation(new e(t,n,[o])),this},s.prototype.getAssociations=function(e,t,n){connect.assertNotNull(t,"fromState"),connect.assertNotNull(n,"toState");var o=[],r=this.fromMap[s.ANY]||{},i=this.fromMap[t]||{};return o=(o=o.concat(this._getAssociationsFromMap(r,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,o){return(e[s.ANY]||[]).concat(e[o]||[]).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","InvalidLocale","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","task"]),connect.ContactInitiationMethod=connect.makeEnum(["inbound","outbound","transfer","queue_transfer","callback","api","disconnect"]),connect.ChannelType=connect.makeEnum(["VOICE","CHAT","TASK"]),connect.MediaType=connect.makeEnum(["softphone","chat","task"]),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.VoiceIdErrorTypes=connect.makeEnum(["no_speaker_id_found","speaker_id_not_enrolled","get_speaker_id_failed","get_speaker_status_failed","opt_out_speaker_failed","opt_out_speaker_in_lcms_failed","delete_speaker_failed","start_session_failed","evaluate_speaker_failed","session_not_exists","describe_session_failed","enroll_speaker_failed","update_speaker_id_failed","update_speaker_id_in_lcms_failed","not_supported_on_conference_calls","enroll_speaker_timeout","evaluate_speaker_timeout","get_domain_id_failed","no_domain_id_found"]),connect.CTIExceptions=connect.makeEnum(["AccessDeniedException","InvalidStateException","BadEndpointException","InvalidAgentARNException","InvalidConfigurationException","InvalidContactTypeException","PaginationException","RefreshTokenExpiredException","SendDataFailedException","UnauthorizedException","QuotaExceededException"]),connect.VoiceIdStreamingStatus=connect.makeEnum(["ONGOING","ENDED","PENDING_CONFIGURATION"]),connect.VoiceIdAuthenticationDecision=connect.makeEnum(["ACCEPT","REJECT","NOT_ENOUGH_SPEECH","SPEAKER_NOT_ENROLLED","SPEAKER_OPTED_OUT","SPEAKER_ID_NOT_PROVIDED","SPEAKER_EXPIRED"]),connect.VoiceIdFraudDetectionDecision=connect.makeEnum(["NOT_ENOUGH_SPEECH","HIGH_RISK","LOW_RISK"]),connect.ContactFlowAuthenticationDecision=connect.makeEnum(["Authenticated","NotAuthenticated","Inconclusive","NotEnrolled","OptedOut","NotEnabled","Error"]),connect.ContactFlowFraudDetectionDecision=connect.makeEnum(["HighRisk","LowRisk","Inconclusive","NotEnabled","Error"]),connect.VoiceIdEnrollmentRequestStatus=connect.makeEnum(["NOT_ENOUGH_SPEECH","IN_PROGRESS","COMPLETED","FAILED"]),connect.VoiceIdSpeakerStatus=connect.makeEnum(["OPTED_OUT","ENROLLED"]),connect.VoiceIdConstants={EVALUATE_SESSION_DELAY:1e4,EVALUATION_MAX_POLL_TIMES:24,EVALUATION_POLLING_INTERVAL:5e3,ENROLLMENT_MAX_POLL_TIMES:120,ENROLLMENT_POLLING_INTERVAL:5e3,START_SESSION_DELAY:8e3},connect.AgentPermissions={OUTBOUND_CALL:"outboundCall",VOICE_ID:"voiceId"};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.onLocalMediaStreamCreated=function(e){connect.core.getUpstream().onUpstream(connect.AgentEvents.LOCAL_MEDIA_STREAM_CREATED,e)},e.prototype.onSpeakerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.SPEAKER_DEVICE_CHANGED,e)},e.prototype.onMicrophoneDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.MICROPHONE_DEVICE_CHANGED,e)},e.prototype.onRingerDeviceChanged=function(e){connect.core.getUpstream().onUpstream(connect.ConfigurationEvents.RINGER_DEVICE_CHANGED,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.setSpeakerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_SPEAKER_DEVICE,data:{deviceId:e}})},e.prototype.setMicrophoneDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_MICROPHONE_DEVICE,data:{deviceId:e}})},e.prototype.setRingerDevice=function(e){connect.core.getUpstream().sendUpstream(connect.EventType.BROADCAST,{event:connect.ConfigurationEvents.SET_RINGER_DEVICE,data:{deviceId:e}})},e.prototype.getState=function(){return this._getData().snapshot.state},e.prototype.getNextState=function(){return this._getData().snapshot.nextState},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"TASK"!==t&&(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){var n=connect.core.getClient();e&&e.agentPreferences&&!connect.isValidLocale(e.agentPreferences.locale)?t&&t.failure&&t.failure(connect.AgentErrorStates.INVALID_LOCALE):n.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.setState=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.PUT_AGENT_STATE,{state:connect.assertNotNull(e,"state"),enqueueNextState:n&&!!n.enqueueNextState},t)},e.prototype.onEnqueuedNextState=function(e){connect.core.getEventBus().subscribe(connect.AgentEvents.ENQUEUED_NEXT_STATE,e)},e.prototype.setStatus=e.prototype.setState,e.prototype.connect=function(e,t){var n=connect.core.getClient(),e=new connect.Endpoint(e);delete e.endpointId,n.call(connect.ClientMethods.CREATE_OUTBOUND_CONTACT,{endpoint:connect.assertNotNull(e,"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.getEndpoints=function(t,n,e){var o=this,r=connect.core.getClient();connect.assertNotNull(n,"callbacks"),connect.assertNotNull(n.success,"callbacks.success");var i=e||{};i.endpoints=i.endpoints||[],i.maxResults=i.maxResults||connect.DEFAULT_BATCH_SIZE,connect.isArray(t)||(t=[t]),r.call(connect.ClientMethods.GET_ENDPOINTS,{queueARNs:t,nextToken:i.nextToken||null,maxResults:i.maxResults},{success:function(e){e.nextToken?o.getEndpoints(t,n,{nextToken:e.nextToken,maxResults:i.maxResults,endpoints:i.endpoints.concat(e.endpoints)}):(i.endpoints=i.endpoints.concat(e.endpoints),e=i.endpoints.map(function(e){return new connect.Endpoint(e)}),n.success({endpoints:e,addresses:e}))},failure:n.failure})},e.prototype.getAddresses=e.prototype.getEndpoints,e.prototype._getResourceId=function(){queueArns=this.getAllQueueARNs();for(var e of queueArns){e=e.match(/\/agent\/([^/]+)/);if(e)return e[1]}return new Error("Agent.prototype._getResourceId: queueArns did not contain agentResourceId: ",queueArns)},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 o(e){this.contactId=e}o.prototype._getData=function(){return connect.core.getAgentDataProvider().getContactData(this.getContactId())},o.prototype._createConnectionAPI=function(e){return new(this.getType()===connect.ContactType.CHAT?connect.ChatConnection:this.getType()===connect.ContactType.TASK?connect.TaskConnection:connect.VoiceConnection)(this.contactId,e.connectionId)},o.prototype.getEventName=function(e){return connect.core.getContactEventName(e,this.getContactId())},o.prototype.onRefresh=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.REFRESH),e)},o.prototype.onIncoming=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.INCOMING),e)},o.prototype.onConnecting=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTING),e)},o.prototype.onPending=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.PENDING),e)},o.prototype.onAccepted=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACCEPTED),e)},o.prototype.onMissed=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.MISSED),e)},o.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)},o.prototype.onDestroy=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.DESTROYED),e)},o.prototype.onACW=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ACW),e)},o.prototype.onConnected=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.CONNECTED),e)},o.prototype.onError=function(e){connect.core.getEventBus().subscribe(this.getEventName(connect.ContactEvents.ERROR),e)},o.prototype.getContactId=function(){return this.contactId},o.prototype.getInitialContactId=o.prototype.getOriginalContactId=function(){return this._getData().initialContactId},o.prototype.getType=function(){return this._getData().type},o.prototype.getContactDuration=function(){return this._getData().contactDuration},o.prototype.getStatus=o.prototype.getState=function(){return this._getData().state},o.prototype.getStatusDuration=o.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},o.prototype.getQueue=function(){return this._getData().queue},o.prototype.getQueueTimestamp=function(){return this._getData().queueTimestamp},o.prototype.getConnections=function(){var t=this;return this._getData().connections.map(function(e){return new(t.getType()===connect.ContactType.CHAT?connect.ChatConnection:t.getType()===connect.ContactType.TASK?connect.TaskConnection:connect.VoiceConnection)(t.contactId,e.connectionId)})},o.prototype.getInitialConnection=function(){return connect.find(this.getConnections(),function(e){return e.isInitialConnection()})||null},o.prototype.getActiveInitialConnection=function(){var e=this.getInitialConnection();return null!=e&&e.isActive()?e:null},o.prototype.getThirdPartyConnections=function(){return this.getConnections().filter(function(e){return!e.isInitialConnection()&&e.getType()!==connect.ConnectionType.AGENT})},o.prototype.getSingleActiveThirdPartyConnection=function(){return this.getThirdPartyConnections().filter(function(e){return e.isActive()})[0]||null},o.prototype.getAgentConnection=function(){return connect.find(this.getConnections(),function(e){e=e.getType();return e===connect.ConnectionType.AGENT||e===connect.ConnectionType.MONITORING})},o.prototype.getName=function(){return this._getData().name},o.prototype.getContactMetadata=function(){return this._getData().contactMetadata},o.prototype.getDescription=function(){return this._getData().description},o.prototype.getReferences=function(){return this._getData().references},o.prototype.getAttributes=function(){return this._getData().attributes},o.prototype.getContactFeatures=function(){return this._getData().contactFeatures},o.prototype.isSoftphoneCall=function(){return null!=connect.find(this.getConnections(),function(e){return null!=e.getSoftphoneMediaInfo()})},o.prototype._isInbound=function(){return this._getData().initiationMethod!==connect.ContactInitiationMethod.OUTBOUND},o.prototype.isInbound=function(){var e=this.getInitialConnection();return e.getMediaType()===connect.MediaType.TASK?this._isInbound():!!e&&e.getType()===connect.ConnectionType.INBOUND},o.prototype.isConnected=function(){return this.getStatus().type===connect.ContactStateType.CONNECTED},o.prototype.accept=function(n){var e=connect.core.getClient(),o=this,r=this.getContactId();e.call(connect.ClientMethods.ACCEPT_CONTACT,{contactId:r},{success:function(e){var t=connect.core.getUpstream();t.sendUpstream(connect.EventType.BROADCAST,{event:connect.ContactEvents.ACCEPTED,data:new connect.Contact(r)}),t.sendUpstream(connect.EventType.BROADCAST,{event:connect.core.getContactEventName(connect.ContactEvents.ACCEPTED,o.getContactId()),data:new connect.Contact(r)});t=new connect.Contact(r);connect.isFirefoxBrowser()&&t.isSoftphoneCall()&&connect.core.triggerReadyToStartSessionEvent(),n&&n.success&&n.success(e)},failure:n?n.failure:null})},o.prototype.destroy=function(){connect.getLog().warn("contact.destroy() has been deprecated.")},o.prototype.reject=function(e){connect.core.getClient().call(connect.ClientMethods.REJECT_CONTACT,{contactId:this.getContactId()},e)},o.prototype.complete=function(e){connect.core.getClient().call(connect.ClientMethods.COMPLETE_CONTACT,{contactId:this.getContactId()},e)},o.prototype.clear=function(e){connect.core.getClient().call(connect.ClientMethods.CLEAR_CONTACT,{contactId:this.getContactId()},e)},o.prototype.notifyIssue=function(e,t,n){connect.core.getClient().call(connect.ClientMethods.NOTIFY_CONTACT_ISSUE,{contactId:this.getContactId(),issueCode:e,description:t},n)},o.prototype.addConnection=function(e,t){var n=connect.core.getClient(),e=new connect.Endpoint(e);delete e.endpointId,n.call(connect.ClientMethods.CREATE_ADDITIONAL_CONNECTION,{contactId:this.getContactId(),endpoint:e},t)},o.prototype.toggleActiveConnections=function(e){var t=connect.core.getClient(),n=null,o=connect.find(this.getConnections(),function(e){return e.getStatus().type===connect.ConnectionStateType.HOLD});null!=o?n=o.getConnectionId():0<(o=this.getConnections().filter(function(e){return e.isActive()})).length&&(n=o[0].getConnectionId()),t.call(connect.ClientMethods.TOGGLE_ACTIVE_CONNECTIONS,{contactId:this.getContactId(),connectionId:n},e)},o.prototype.sendSoftphoneMetrics=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_METRICS,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,softphoneStreamStatistics:e},t),connect.publishSoftphoneStats({contactId:this.getContactId(),ccpVersion:n.ccpVersion,stats:e})},o.prototype.sendSoftphoneReport=function(e,t){connect.core.getClient().call(connect.ClientMethods.SEND_SOFTPHONE_CALL_REPORT,{contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e},t),connect.publishSoftphoneReport({contactId:this.getContactId(),ccpVersion:n.ccpVersion,report:e})},o.prototype.conferenceConnections=function(e){connect.core.getClient().call(connect.ClientMethods.CONFERENCE_CONNECTIONS,{contactId:this.getContactId()},e)},o.prototype.toSnapshot=function(){return new connect.ContactSnapshot(this._getData())};function r(e){connect.Contact.call(this,e.contactId),this.contactData=e}((r.prototype=Object.create(o.prototype)).constructor=r).prototype._getData=function(){return this.contactData},r.prototype._createConnectionAPI=function(e){return new connect.ConnectionSnapshot(e)};var i=function(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.getEndpoint=function(){return new connect.Endpoint(this._getData().endpoint)},i.prototype.getAddress=i.prototype.getEndpoint,i.prototype.getState=function(){return this._getData().state},i.prototype.getStatus=i.prototype.getState,i.prototype.getStateDuration=function(){return connect.now()-this._getData().state.timestamp.getTime()+connect.core.getSkew()},i.prototype.getStatusDuration=i.prototype.getStateDuration,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};var s=function(e){this.contactId=e};s.prototype.getSpeakerId=function(){var e=this;e.checkConferenceCall();var t=connect.core.getClient();return new Promise(function(n,o){t.call(connect.AgentAppClientMethods.GET_CONTACT,{contactId:e.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),awsAccountId:connect.core.getAgentDataProvider().getAWSAccountId()},{success:function(e){var t;e.contactData.customerId?(t={speakerId:e.contactData.customerId},connect.getLog().info("getSpeakerId succeeded").withObject(e).sendInternalLogToServer(),n(t)):(t=connect.VoiceIdError(connect.VoiceIdErrorTypes.NO_SPEAKER_ID_FOUND,"No speakerId assotiated with this call"),o(t))},failure:function(e){connect.getLog().error("Get SpeakerId failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_ID_FAILED,"Get SpeakerId failed",e);o(e)}})})},s.prototype.getSpeakerStatus=function(){var e=this;e.checkConferenceCall();var n=connect.core.getClient();return new Promise(function(o,r){e.getSpeakerId().then(function(t){e.getDomainId().then(function(e){n.call(connect.AgentAppClientMethods.DESCRIBE_SPEAKER,{SpeakerId:connect.assertNotNull(t.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("getSpeakerStatus succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){var t=JSON.parse(e);switch(t.status){case 400:case 404:var n=t;n.type=n.type||connect.VoiceIdErrorTypes.SPEAKER_ID_NOT_ENROLLED,connect.getLog().info("Speaker is not enrolled.").sendInternalLogToServer(),o(n);break;default:connect.getLog().error("getSpeakerStatus failed").withObject({err:e}).sendInternalLogToServer();n=connect.VoiceIdError(connect.VoiceIdErrorTypes.GET_SPEAKER_STATUS_FAILED,"Get SpeakerStatus failed",e);r(n)}}})}).catch(function(e){r(e)})}).catch(function(e){r(e)})})},s.prototype._optOutSpeakerInLcms=function(e){var o=this,r=connect.core.getClient();return new Promise(function(t,n){r.call(connect.AgentAppClientMethods.UPDATE_VOICE_ID_DATA,{ContactId:o.contactId,InstanceId:connect.core.getAgentDataProvider().getInstanceId(),AWSAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),CustomerId:connect.assertNotNull(e,"speakerId"),VoiceIdResult:{SpeakerOptedOut:!0}},{success:function(e){connect.getLog().info("optOutSpeakerInLcms succeeded").withObject(e).sendInternalLogToServer(),t(e)},failure:function(e){connect.getLog().error("optOutSpeakerInLcms failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_IN_LCMS_FAILED,"optOutSpeakerInLcms failed",e);n(e)}})})},s.prototype.optOutSpeaker=function(){var i=this;i.checkConferenceCall();var s=connect.core.getClient();return new Promise(function(o,r){i.getSpeakerId().then(function(n){i.getDomainId().then(function(e){var t=n.speakerId;s.call(connect.AgentAppClientMethods.OPT_OUT_SPEAKER,{SpeakerId:connect.assertNotNull(t,"speakerId"),DomainId:e},{success:function(e){i._optOutSpeakerInLcms(t).catch(function(){}),connect.getLog().info("optOutSpeaker succeeded").withObject(e).sendInternalLogToServer(),o(e)},failure:function(e){connect.getLog().error("optOutSpeaker failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.OPT_OUT_SPEAKER_FAILED,"optOutSpeaker failed.",e);r(e)}})}).catch(function(e){r(e)})}).catch(function(e){r(e)})})},s.prototype.deleteSpeaker=function(){var e=this;e.checkConferenceCall();var r=connect.core.getClient();return new Promise(function(n,o){e.getSpeakerId().then(function(t){e.getDomainId().then(function(e){r.call(connect.AgentAppClientMethods.DELETE_SPEAKER,{SpeakerId:connect.assertNotNull(t.speakerId,"speakerId"),DomainId:e},{success:function(e){connect.getLog().info("deleteSpeaker succeeded").withObject(e).sendInternalLogToServer(),n(e)},failure:function(e){connect.getLog().error("deleteSpeaker failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.DELETE_SPEAKER_FAILED,"deleteSpeaker failed.",e);o(e)}})}).catch(function(e){o(e)})}).catch(function(e){o(e)})})},s.prototype.startSession=function(){var o=this;o.checkConferenceCall();var r=connect.core.getClient();return new Promise(function(t,n){o.getDomainId().then(function(e){r.call(connect.AgentAppClientMethods.START_VOICE_ID_SESSION,{contactId:o.contactId,instanceId:connect.core.getAgentDataProvider().getInstanceId(),customerAccountId:connect.core.getAgentDataProvider().getAWSAccountId(),clientToken:AWS.util.uuid.v4(),domainId:e},{success:function(e){e.sessionId?t(e):(connect.getLog().error("startVoiceIdSession failed, no session id returned").withObject({data:e}).sendInternalLogToServer(),e=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"No session id returned from start session api"),n(e))},failure:function(e){connect.getLog().error("startVoiceIdSession failed").withObject({err:e}).sendInternalLogToServer();e=connect.VoiceIdError(connect.VoiceIdErrorTypes.START_SESSION_FAILED,"startVoiceIdSession failed",e);n(e)}})}).catch(function(e){n(e)})})},s.prototype.evaluateSpeaker=function(e){var i=this;i.checkConferenceCall();var t=connect.core.getClient(),s=connect.core.getAgentDataProvider().getContactData(this.contactId),c=0;return new Promise(function(n,o){function r(){i.getDomainId().then(function(e){t.call(connect.AgentAppClientMethods.EVALUATE_SESSION,{SessionNameOrId:s.initialContactId||this.contactId,DomainId:e},{success:function(e){if(++c=this._level}},{key:"hasClientLogger",value:function(){return null!==this._clientLogger}},{key:"getLogger",value:function(e){e=e.prefix||"";return"DEBUG"===this._logsDestination?this.consoleLoggerWrapper:new y(e)}},{key:"updateLoggerConfig",value:function(e){e=e||{};this._level=e.level||f.DEBUG,this._clientLogger=e.logger||null,this._logsDestination="NULL",e.debug&&(this._logsDestination="DEBUG"),e.logger&&(this._logsDestination="CLIENT_LOGGER")}}]),b),m=(h(S,[{key:"debug",value:function(){}},{key:"info",value:function(){}},{key:"warn",value:function(){}},{key:"error",value:function(){}}]),S),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)}(E,m),h(E,[{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=r.precision?n.substring(0,r.precision):n;break;case"t":n=String(!!n),n=r.precision?n.substring(0,r.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=r.precision?n.substring(0,r.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=r.precision?n.substring(0,r.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(r.type)?p+=n:(!d.number.test(r.type)||c&&!r.sign?a="":(a=c?"+":"-",n=n.toString().replace(d.sign,"")),i=r.pad_char?"0"===r.pad_char?"0":r.pad_char.charAt(1):" ",s=r.width-(a+n).length,s=r.width&&0t.packetsLost?e.packetsLost-t.packetsLost:0,t=e.packetsCount>t.packetsCount?e.packetsCount-t.packetsCount:0;return new q(e.timestamp,o,t,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)}return new q(e.timestamp,e.packetsLost,e.packetsCount,n,e.audioLevel,e.jbMilliseconds,e.rttMilliseconds)},U=function(e){return null!==e&&window.clearInterval(e),null},F=function(e,t){c=U(c),a=U(a),d(e,t,B(o,i),B(r,s)),h(e)},q=function(e,t,n,o,r,i,s){this.softphoneStreamType=o,this.timestamp=e,this.packetsLost=t,this.packetsCount=n,this.audioLevel=r,this.jitterBufferMillis=i,this.roundTripTimeMillis=s},B=function(e,t){return new q((e=e||{}).timestamp,e.packetsLost,e.packetsCount,t,e.audioLevel)},j=function(e){this._originalLogger=e;var o=this;this._tee=function(e,n){return function(){var e=Array.prototype.slice.call(arguments[0]),t="";return e.forEach(function(){t+=" %s"}),n.apply(o._originalLogger,[connect.LogComponent.SOFTPHONE,t].concat(e))}}};j.prototype.debug=function(){return this._tee(1,this._originalLogger.debug)(arguments)},j.prototype.info=function(){return this._tee(2,this._originalLogger.info)(arguments)},j.prototype.log=function(){return this._tee(3,this._originalLogger.log)(arguments)},j.prototype.warn=function(){return this._tee(4,this._originalLogger.warn)(arguments)},j.prototype.error=function(){return this._tee(5,this._originalLogger.error)(arguments)},connect.SoftphoneManager=function(e){var i,n=this;(g=new j(connect.getLog())).info("[Softphone Manager] softphone manager initialization has begun").sendInternalLogToServer(),connect.RtcPeerConnectionFactory&&(i=new connect.RtcPeerConnectionFactory(g,connect.core.getWebSocketManager(),E,connect.hitch(n,S,{transportType:"softphone",softphoneClientId:E}),connect.hitch(n,N))),D()||N(m.UNSUPPORTED_BROWSER,"Connect does not support this browser. Some functionality may not work. ","");R({success:function(e){connect.core.setSoftphoneUserMediaStream(e)},failure:function(e){N(e,"Your microphone is not enabled in your browser. ","")}});C(),T(),I(),this.ringtoneEngine=null;var s={},c={};this.onInitContactSub={};var a=!(this.onInitContactSub.unsubscribe=function(){}),u=null,l=null,o=function(e,t){a=!0,u=e,l=t},p=function(){a=!1,l=u=null};this.getSession=function(e){return s[e]},this.replaceLocalMediaTrack=function(e,t){var n=v[e].stream;n&&(e=n.getAudioTracks()[0],t.enabled=e.enabled,e.enabled=!1,n.removeTrack(e),n.addTrack(t))};var r=function(e){return e.getStatus().type===connect.ContactStatusType.ENDED||e.getStatus().type===connect.ContactStatusType.ERROR||e.getStatus().type===connect.ContactStatusType.MISSED},h=function(n){var o;s.hasOwnProperty(n)&&(o=s[n],new Promise(function(e,t){delete s[n],delete c[n],o.hangup()}).catch(function(e){lily.getLog().warn("Clean up the session locally "+n,e.message).sendInternalLogToServer()}))};this.startSession=function(e,t){var n,o=a?u:e,r=a?l:t;o&&r&&(p(),c[r]=!0,g.info("Softphone call detected:","contactId "+o.getContactId(),"agent connectionId "+r).sendInternalLogToServer(),function(e){if(0o&&n.handleSendLogsRequest(n.logsBuffer)}),this.conduit.onDownstream(connect.EventType.CONFIGURE,function(e){e.authToken&&e.authToken!==n.initData.authToken&&(n.initData=e,connect.core.init(e),t?connect.getLog().info("Not Initializing a new WebsocketManager instance, since one already exists").sendInternalLogToServer():(connect.getLog().info("Creating a new Websocket connection for CCP").sendInternalLogToServer(),connect.WebSocketManager.setGlobalConfig({loggerConfig:{logger:connect.getLog()}}),(t=connect.WebSocketManager.create()).onInitFailure(function(){n.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE)}),t.onConnectionOpen(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_OPEN,e)}),t.onConnectionClose(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_CLOSE,e)}),t.onConnectionGain(function(){n.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_GAINED),n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_GAIN)}),t.onConnectionLost(function(e){n.conduit.sendDownstream(connect.AgentEvents.WEBSOCKET_CONNECTION_LOST,e),n.conduit.sendDownstream(connect.WebSocketEvents.CONNECTION_LOST,e)}),t.onSubscriptionUpdate(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_UPDATE,e)}),t.onSubscriptionFailure(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.SUBSCRIPTION_FAILURE,e)}),t.onAllMessage(function(e){n.conduit.sendDownstream(connect.WebSocketEvents.ALL_MESSAGE,e)}),n.conduit.onDownstream(connect.WebSocketEvents.SEND,function(e){t.sendMessage(e)}),n.conduit.onDownstream(connect.WebSocketEvents.SUBSCRIBE,function(e){t.subscribeTopics(e)}),t.init(connect.hitch(n,n.getWebSocketUrl)).then(function(e){e&&!e.webSocketConnectionFailed?(connect.getLog().info("Kicking off agent polling").sendInternalLogToServer(),n.pollForAgent(),connect.getLog().info("Kicking off config polling").sendInternalLogToServer(),n.pollForAgentConfiguration({repeatForever:!0}),connect.getLog().info("Kicking off auth token polling").sendInternalLogToServer(),r.setInterval(connect.hitch(n,n.checkAuthToken),i)):connect.webSocketInitFailed||(n.conduit.sendDownstream(connect.WebSocketEvents.INIT_FAILURE),connect.webSocketInitFailed=!0)})))}),this.conduit.onDownstream(connect.EventType.TERMINATE,function(){n.handleSendLogsRequest(n.logsBuffer),connect.core.terminate(),n.conduit.sendDownstream(connect.EventType.TERMINATED)}),this.conduit.onDownstream(connect.EventType.SYNCHRONIZE,function(){n.conduit.sendDownstream(connect.EventType.ACKNOWLEDGE)}),this.conduit.onDownstream(connect.EventType.BROADCAST,function(e){n.conduit.sendDownstream(e.event,e.data)}),r.onconnect=function(e){var e=e.ports[0],t=new connect.PortStream(e);n.multiplexer.addStream(t),e.start();e=new connect.Conduit(t.getId(),null,t);e.sendDownstream(connect.EventType.ACKNOWLEDGE,{id:t.getId()}),n.portConduitMap[t.getId()]=e,n.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(n.portConduitMap).length}),null!==n.agent&&n.updateAgent(),e.onDownstream(connect.EventType.API_REQUEST,connect.hitch(n,n.handleAPIRequest,e)),e.onDownstream(connect.EventType.MASTER_REQUEST,connect.hitch(n,n.handleMasterRequest,e,t.getId())),e.onDownstream(connect.EventType.RELOAD_AGENT_CONFIGURATION,connect.hitch(n,n.pollForAgentConfiguration)),e.onDownstream(connect.EventType.CLOSE,function(){n.multiplexer.removeStream(t),delete n.portConduitMap[t.getId()],n.masterCoord.removeMaster(t.getId()),n.conduit.sendDownstream(connect.EventType.UPDATE_CONNECTED_CCPS,{length:Object.keys(n.portConduitMap).length})})}}t.prototype.pollForAgent=function(){var n=this,e=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_SNAPSHOT,{nextToken:n.nextToken,timeout:3e4},{success:function(t){try{n.agent=n.agent||{},n.agent.snapshot=t.snapshot,n.agent.snapshot.localTimestamp=connect.now(),n.agent.snapshot.skew=n.agent.snapshot.snapshotTimestamp-n.agent.snapshot.localTimestamp,n.nextToken=t.nextToken,connect.getLog().trace("GET_AGENT_SNAPSHOT succeeded.").withObject(t).sendInternalLogToServer(),n.updateAgent()}catch(e){connect.getLog().error("Long poll failed to update agent.").withObject(t).withException(e).sendInternalLogToServer()}finally{r.setTimeout(connect.hitch(n,n.pollForAgent),100)}},failure:function(e,t){try{connect.getLog().error("Failed to get agent data.").sendInternalLogToServer().withObject({err:e,data:t})}finally{r.setTimeout(connect.hitch(n,n.pollForAgent),5e3)}},authFailure:function(){e()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentConfiguration=function(e){var n=this,o=e||{},t=connect.hitch(n,n.handleAuthFail);this.client.call(connect.ClientMethods.GET_AGENT_CONFIGURATION,{},{success:function(e){e=e.configuration;n.pollForAgentPermissions(e),n.pollForAgentStates(e),n.pollForDialableCountryCodes(e),n.pollForRoutingProfileQueues(e),o.repeatForever&&r.setTimeout(connect.hitch(n,n.pollForAgentConfiguration,o),3e4)},failure:function(e,t){try{connect.getLog().error("Failed to fetch agent configuration data.").sendInternalLogToServer().withObject({err:e,data:t})}finally{o.repeatForever&&r.setTimeout(connect.hitch(n,n.pollForAgentConfiguration),3e4,o)}},authFailure:function(){t()},accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentStates=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_STATES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForAgentStates(t,{states:(o.states||[]).concat(e.states),nextToken:e.nextToken,maxResults:o.maxResults}):(t.agentStates=(o.states||[]).concat(e.states),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch agent states list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForAgentPermissions=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_AGENT_PERMISSIONS,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForAgentPermissions(t,{permissions:(o.permissions||[]).concat(e.permissions),nextToken:e.nextToken,maxResults:o.maxResults}):(t.permissions=(o.permissions||[]).concat(e.permissions),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch agent permissions list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForDialableCountryCodes=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_DIALABLE_COUNTRY_CODES,{nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForDialableCountryCodes(t,{countryCodes:(o.countryCodes||[]).concat(e.countryCodes),nextToken:e.nextToken,maxResults:o.maxResults}):(t.dialableCountries=(o.countryCodes||[]).concat(e.countryCodes),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch dialable country codes list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.pollForRoutingProfileQueues=function(t,e){var n=this,o=e||{};o.maxResults=o.maxResults||connect.DEFAULT_BATCH_SIZE,this.client.call(connect.ClientMethods.GET_ROUTING_PROFILE_QUEUES,{routingProfileARN:t.routingProfile.routingProfileARN,nextToken:o.nextToken||null,maxResults:o.maxResults},{success:function(e){e.nextToken?n.pollForRoutingProfileQueues(t,{countryCodes:(o.queues||[]).concat(e.queues),nextToken:e.nextToken,maxResults:o.maxResults}):(t.routingProfile.queues=(o.queues||[]).concat(e.queues),n.updateAgentConfiguration(t))},failure:function(e,t){connect.getLog().error("Failed to fetch routing profile queues list.").sendInternalLogToServer().withObject({err:e,data:t})},authFailure:connect.hitch(n,n.handleAuthFail),accessDenied:connect.hitch(n,n.handleAccessDenied)})},t.prototype.handleAPIRequest=function(n,o){var r=this;this.client.call(o.method,o.params,{success:function(e){e=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,o,e);n.sendDownstream(e.event,e)},failure:function(e,t){t=connect.EventFactory.createResponse(connect.EventType.API_RESPONSE,o,t,JSON.stringify(e));n.sendDownstream(t.event,t),connect.getLog().error("'%s' API request failed",o.method).withObject({request:r.filterAuthToken(o),response:t}).withException(e).sendInternalLogToServer()},authFailure:connect.hitch(r,r.handleAuthFail)})},t.prototype.handleMasterRequest=function(e,t,n){var o=this.conduit,r=null;switch(n.method){case connect.MasterMethods.BECOME_MASTER:var i=this.masterCoord.getMaster(n.params.topic),s=Boolean(i)&&i!==t;this.masterCoord.setMaster(n.params.topic,t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:t,takeOver:s,topic:n.params.topic}),s&&o.sendDownstream(r.event,r);break;case connect.MasterMethods.CHECK_MASTER:(i=this.masterCoord.getMaster(n.params.topic))||n.params.shouldNotBecomeMasterIfNone||(this.masterCoord.setMaster(n.params.topic,t),i=t),r=connect.EventFactory.createResponse(connect.EventType.MASTER_RESPONSE,n,{masterId:i,isMaster:t===i,topic:n.params.topic});break;default:throw new Error("Unknown master method: "+n.method)}e.sendDownstream(r.event,r)},t.prototype.updateAgentConfiguration=function(e){e.permissions&&e.dialableCountries&&e.agentStates&&e.routingProfile.queues?(this.agent=this.agent||{},this.agent.configuration=e,this.updateAgent()):connect.getLog().trace("Waiting to update agent configuration until all config data has been fetched.").sendInternalLogToServer()},t.prototype.updateAgent=function(){this.agent?this.agent.snapshot?this.agent.configuration?(this.agent.snapshot.status=this.agent.state,this.agent.snapshot.contacts&&1 { connect.core.getClient.restore(); }); - it('should get rejected when no speakerId without calling backend', async () => { + it('should get rejected without calling backend when no speakerId is passed in', async () => { const response = { data: 'fakeData' }; @@ -1198,6 +1198,29 @@ describe('VoiceId', () => { expect(error.type).to.equal(connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_FAILED); connect.core.getClient.restore(); }); + + it('should get rejected when _updateSpeakerIdInLcms api call fails', async () => { + const response = 'fakeData'; + sinon.stub(connect.core, 'getClient').callsFake(() => ({ + call: (endpoint, params, callbacks) => { + callbacks.success(response); + } + })); + const voiceId = new connect.VoiceId(contactId); + voiceId.checkConferenceCall = sinon.stub(); + voiceId.getDomainId = sinon.stub().callsFake(() => Promise.resolve(domainId)); + voiceId._updateSpeakerIdInLcms = sinon.stub().callsFake(() => Promise.reject({ type: connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_IN_LCMS_FAILED })); + + let obj, error; + try { + obj = await voiceId.updateSpeakerIdInVoiceId(speakerId); + } catch (e) { + error = e; + } + expect(obj).to.be.a('undefined'); + expect(error.type).to.equal(connect.VoiceIdErrorTypes.UPDATE_SPEAKER_ID_IN_LCMS_FAILED); + connect.core.getClient.restore(); + }); }); describe('syncSpeakerId', () => {