@koredev/kore-web-sdk 11.28.1-rc.fbdaaa2 → 11.29.0-rc.94e8aec
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/esm/kore-web-sdk-chat.min.js +1 -1
- package/dist/esm/kore-web-sdk-headless.min.js +1 -1
- package/dist/esm/kore-web-sdk-widgets.js +1 -1
- package/dist/esm/plugins/agent-desktop.js +1 -1
- package/dist/esm/plugins/kore-graph-templates-plugin.js +1 -1
- package/dist/esm/plugins/kore-i18n.js +1 -1
- package/dist/esm/plugins/v2-kore-web-sdk-widgets.js +1 -1
- package/dist/plugins/i18n.d.ts +46 -0
- package/dist/umd/kore-web-sdk-umd-chat.min.js +1 -1
- package/dist/umd/kore-web-sdk-umd-headless.min.js +1 -1
- package/dist/umd/kore-web-sdk-umd-widgets.js +1 -1
- package/dist/umd/plugins/agent-desktop-umd.js +1 -1
- package/dist/umd/plugins/kore-graph-templates-plugin-umd.js +1 -1
- package/dist/umd/plugins/kore-i18n.js +1 -1
- package/dist/umd/plugins/v2-kore-web-sdk-widgets.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={};function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}e.amdO={},e.d=(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var r=void 0,s=0;s<o.length;s++)i(o[s]);return i}({"/KoreBot.js":[function(e,t,n){var o,r=e("./index.js"),s=e("events"),a=e("inherits"),c=e(15),u=(o=e("lodash").bind?e("lodash"):_).bind,l=o.isFunction,f=r.CLIENT_EVENTS.RTM,h=r.RTM_EVENTS,p=r.CLIENT_EVENTS.WEB,d=e("./jstz.js"),m=o.noop;"undefined"!=typeof window&&(window.kore=window.kore||{},window.kore.botsdk=window.kore.botsdk||{},window.kore.botsdk.logger=window.kore.botsdk.logger||e("debug"),window.messageHistoryLimit=10);var g=e("debug")("botsdk:KoreBot");function y(){s.call(this),this.WebClient=null,this.RtmClient=null,this.options={},this.accessToken=null,this.initialized=!1,this.clients=r,this.latestId=null,this.oldestId=null,this.EventEmitter=s,this.lodash=o,this.bind=u,this.isFunction=l,this.RTM_EVENTS=h,this.RTM_CLIENT_EVENTS=f,this.jstz=d,this.noop=m,this.debug=g,this.userLocation=v,this.historyOffset=0,this.previousHistoryLoading=!1,this.paginatedScrollDataAvailable=!0,this._chatHistoryLoaded=!1}var v={city:"",country:"",latitude:0,longitude:0,street:""};a(y,s),y.prototype.emit=function(){arguments&&"history"===arguments[0]&&this.historySyncInProgress?(this.historySyncInProgress=!1,arguments[2]="historysync",this.cbBotChatHistory(arguments)):!window._chatHistoryLoaded&&arguments&&"history"===arguments[0]&&(this._chatHistoryLoaded=!0,this.cbBotChatHistory(arguments)),this.EventEmitter.prototype.emit.apply(this,arguments)},y.prototype.fetchUserLocation=function(){if(""===v.country){var e=this.options;navigator.geolocation.getCurrentPosition(function(t){if(e.googleMapsAPIKey){var n=t.coords.latitude,o=t.coords.longitude;v.latitude=n,v.longitude=o;var r=new XMLHttpRequest,s="https://maps.googleapis.com/maps/api/geocode/json?latlng="+n+","+o+"&sensor=true&key="+e.googleMapsAPIKey;r.open("GET",s,!0),r.onreadystatechange=function(){if(4==r.readyState&&200==r.status){var e=JSON.parse(r.responseText);"undefined"!=typeof Storage&&(0==e.results.length?e=JSON.parse(localStorage.getItem("locationData")):localStorage.setItem("locationData",JSON.stringify(e)));var t=[];for(e.results&&e.results.length&&e.results[0].address_components&&(t=e.results[0].address_components),i=0;i<t.length;i++){var n=t[i].types;"locality,political"==n?v.city=t[i].long_name:"country,political"==n?v.country=t[i].long_name:"political,sublocality,sublocality_level_2"==n&&(v.street=t[i].long_name)}}},r.send()}else console.warn("please provide google maps API key")})}},y.prototype.sendMessage=function(e,t){if(g("sending message to bot"),this.initialized)if(e.resourceid=e.resourceid||"/bot.message",e.botInfo=this.options.botInfo||{},e.client=this.options.client||"sdk",e.meta={timezone:d.jstz.determine().name(),locale:window.navigator.userLanguage||window.navigator.language},0!==v.latitude&&0!==v.longitude&&(e.meta.location=v),this.emit("beforeWSSendMessage",e),this.RtmClient)this.RtmClient.sendMessage(e,t);else{t&&t(new Error("ws not connected or reconnecting, unable to send message"))}else t&&t(new Error("Bot is Initializing...Please try again"))},y.prototype.sendMessageViaWebhook=function(e,t,n){var o=this.WebClient,i=this;e.opts={authorization:"bearer "+this.options.webhookConfig.token},o.makeAPICall(this.options.webhookConfig.webhookURL,e,function(e,o){e?n(o):(o.pollId&&i.startPollForWebhookResponse(o.pollId,t),t(i.convertWebhookResposeToMessages(o)))})},y.prototype.getBotMetaData=function(e,t){var n=this.WebClient,o=this,i={};i.opts={authorization:"bearer "+this.options.webhookConfig.token,type:"GET"},n.makeAPICall("botmeta/"+o.options.botInfo.taskBotId,i,function(n,i){n?t(i):(o.options.botInfo.icon=i.icon,e(i))})},y.prototype.convertWebhookResposeToMessages=function(e){var t,n=e.text,o=[],i=this.options.botInfo.icon;function r(e){try{e=JSON.parse(e)}catch(t){return e}return e}if("v2"===e._v&&(n=e.data),n instanceof Array)console.log("it is array"),n.forEach(function(e,n){var s=(new Date).getTime()+n,a=r(e.val||e);t={type:"bot_response",messageId:e.messageId||s,icon:i,createdOn:e.createdOn,message:[{type:"text",cInfo:{body:e.val||e,attachments:""},component:{}}]},a.payload?(t.message[0].component.payload=a.payload,t.message[0].component.type=a.type):a.text?(t.message[0].component.payload={text:a.text},t.message[0].component.type="template"):(t.message[0].component.payload={text:a},t.message[0].component.type="text"),t.message[0].component&&t.message[0].component.payload&&t.message[0].component.payload.text&&(t.message[0].cInfo.body=t.message[0].component.payload.text),t.message[0].component&&t.message[0].component.payload&&(t.message[0].component.payload.videoUrl||t.message[0].component.payload.audioUrl)&&(t.message[0].cInfo.body=t.message[0].component.payload.text||""),o.push(t)});else{console.log("its Object");var s=(new Date).getTime();t={type:"bot_response",messageId:entry.messageId||s,createdOn:entry.createdOn,icon:i,message:[{type:"text",cInfo:{body:r(n),attachments:""},component:r(n)}]},o.push(t)}return o},y.prototype.startPollForWebhookResponse=function(e,t){var n=this,o=n.options.koreAPIUrl,i=(o=o.substring(0,o.length-5))+"/chatbot/v2/webhook/"+n.options.webhookConfig.streamId+"/poll/"+e,r=this.WebClient,s={};s.opts={authorization:"bearer "+this.options.webhookConfig.token,type:"GET"},r.makeAPICall(i,s,function(e,o){e||(o.pollId&&setTimeout(function(){n.startPollForWebhookResponse(o.pollId,t)},1e3),o.data&&t(n.convertWebhookResposeToMessages(o)))})},y.prototype.onMessage=function(e){g("on message from bot/self"),"bot"===e.from&&"bot_response"===e.type&&(this.latestId=e.messageId||this.latestId,this.oldestId=this.oldestId||e.messageId),this.sendAck(e),this.emit(h.MESSAGE,e)},y.prototype.sendAck=function(e){var t,n;if(null!==(t=this.options)&&void 0!==t&&null!==(t=t.enableAck)&&void 0!==t&&t.delivery&&(e.data&&"bot_response"==(null===(n=JSON.parse(e.data))||void 0===n?void 0:n.type))){var o,i={};i.clientMessageId=JSON.parse(e.data).timestamp,i.type="ack",i.replyto=JSON.parse(e.data).timestamp,i.status="delivered",i.key=null===(o=JSON.parse(e.data))||void 0===o?void 0:o.key,this.RtmClient.sendMessage(i,function(e){console.log("Error occurred in sending ack: ",e)})}},y.prototype.close=function(){g("request to close ws connection"),this.RtmClient&&this.RtmClient._close()},y.prototype.destroy=function(){this.RtmClient&&this.RtmClient._close(),this._chatHistoryLoaded=!1,this.removeAllListeners()},y.prototype.onForwardHistory=function(e,t){g("on forward history");var n,o={};if(o.moreAvailable=t.moreAvailable,this.paginatedScrollDataAvailable=t.moreAvailable,o.messages=[],o.forward=!0,o.afterMessageId=this.latestId,t.messages&&t.messages.length>0)for(n=0;n<t.messages.length;n++){var i,r,s,a,c={};if(c.messageId=t.messages[n]._id,this.oldestId=this.oldestId||t.messages[n]._id,this.latestId=t.messages[n]._id||this.latestId,"incoming"===t.messages[n].type)c.from="self",c.type="user_message",c.messageId=(null===(a=t.messages[n])||void 0===a?void 0:a.userMsgId)||c.messageId;else c.from="bot",c.type="bot_response";var u,l=0;if(t.messages[n].components&&t.messages[n].components.length>0)for(c.message=[],l=0;l<t.messages[n].components.length;l++){var f,h={};if(h.type=t.messages[n].components[l].cT,"text"===h.type)if(h.cInfo={},h.cInfo.body=t.messages[n].components[l].data&&t.messages[n].components[l].data.text,t.messages[n].tags&&t.messages[n].tags.altText&&t.messages[n].tags.altText.length>0)h.cInfo.body=(null===(f=t.messages[n].tags.altText[0])||void 0===f?void 0:f.value)||h.cInfo.body;c.message[l]=h}if(c.createdOn=t.messages[n].createdOn,null!==(i=t.messages[n])&&void 0!==i&&i.author){var p,d,m,y;if(c.author={},null!==(p=t.messages[n])&&void 0!==p&&null!==(p=p.author)&&void 0!==p&&p.firstName)c.author.firstName=null===(m=t.messages[n])||void 0===m||null===(m=m.author)||void 0===m?void 0:m.firstName;if(null!==(d=t.messages[n])&&void 0!==d&&null!==(d=d.author)&&void 0!==d&&d.lastName)c.author.lastName=null===(y=t.messages[n])||void 0===y||null===(y=y.author)||void 0===y?void 0:y.lastName}if(null!==(r=t.messages[n])&&void 0!==r&&r.lang)c.botLanguage=null===(u=t.messages[n])||void 0===u?void 0:u.lang;null!==(s=t.messages[n])&&void 0!==s&&s.sessionId&&(c.sessionId=t.messages[n].sessionId),o.messages[n]=c}this.emit("history",o)},y.prototype.onBackWardHistory=function(e,t){g("on backword history");var n,o={};if(o.moreAvailable=null==t?void 0:t.moreAvailable,this.paginatedScrollDataAvailable=null==t?void 0:t.moreAvailable,o.messages=[],o.backward=!0,o.beforeMessageId=this.oldestId,null!=t&&t.messages&&t.messages.length>0)for(n=0;n<t.messages.length;n++){var i,r,s,a,c={};if(c.messageId=t.messages[n]._id,this.oldestId=t.messages[n]._id||this.oldestId,this.latestId=this.latestId||t.messages[n]._id,"incoming"===t.messages[n].type)c.from="self",c.type="user_message",c.messageId=(null===(a=t.messages[n])||void 0===a?void 0:a.userMsgId)||c.messageId;else c.from="bot",c.type="bot_response",c.icon=t.icon;var u,l,f,h=0;if(t.messages[n].components&&t.messages[n].components.length>0)for(c.message=[],h=0;h<t.messages[n].components.length;h++){var p,d={};if(d.type=t.messages[n].components[h].cT,"text"===d.type)if(d.cInfo={},d.cInfo.body=t.messages[n].components[h].data&&t.messages[n].components[h].data.text,t.messages[n].tags&&t.messages[n].tags.altText&&t.messages[n].tags.altText.length>0)d.cInfo.body=(null===(p=t.messages[n].tags.altText[0])||void 0===p?void 0:p.value)||d.cInfo.body;c.message[h]=d}if(c.createdOn=t.messages[n].createdOn,null!==(i=t.messages[n])&&void 0!==i&&i.author)c.author={},c.author.firstName=null===(u=t.messages[n])||void 0===u||null===(u=u.author)||void 0===u?void 0:u.firstName,c.author.lastName=null===(l=t.messages[n])||void 0===l||null===(l=l.author)||void 0===l?void 0:l.lastName;if(null!==(r=t.messages[n])&&void 0!==r&&r.lang)c.botLanguage=null===(f=t.messages[n])||void 0===f?void 0:f.lang;null!==(s=t.messages[n])&&void 0!==s&&s.sessionId&&(c.sessionId=t.messages[n].sessionId),o.messages[n]=c}this.emit("history",o)},y.prototype.getHistory=function(e,t){g("get history"),e=e||{},"undefined"!=typeof window&&(e.limit=e.limit||window.messageHistoryLimit||10);var n={};n.forward=e.forward,n.limit=e.limit||10,e.forHistorySync?n.offset=0:(n.offset=this.historyOffset,this.historyOffset=this.historyOffset+(e.limit?e.limit:10)),n.forward?this.latestId&&(n.msgId=this.latestId):this.previousHistoryLoading||this.oldestId&&(n.msgId=this.oldestId),n.botInfo=this.options.botInfo,n.authorization="bearer "+this.WebClient.user.accessToken,t&&t.webhookConfig&&t.webhookConfig.enable&&(n.authorization="bearer "+this.options.webhookConfig.token),e.forHistorySync&&(this.historySyncInProgress=!0,delete n.msgId),n.forward?this.WebClient.history.history(n,u(this.onForwardHistory,this),t):this.WebClient.history.history(n,u(this.onBackWardHistory,this),t)},y.prototype.sync=function(e){},y.prototype.onOpenWSConnection=function(e){g("opened WS Connection"),this.initialized=!0,this.options.loadHistory&&!this._chatHistoryLoaded&&this.getHistory({limit:this.options.messageHistoryLimit}),this.emit(f.RTM_CONNECTION_OPENED,{})},y.prototype.onLogIn=function(e,t){var n=this;g("sign-in/anonymous user onLogin"),e?this.cbErrorToClient&&(t&&t.errors&&t.errors[0]&&t.errors[0].msg?this.cbErrorToClient(t.errors[0].msg):this.cbErrorToClient(e.message)):(this.accessToken=t.authorization.accessToken,this.options.accessToken=this.accessToken,this.WebClient.user.accessToken=this.accessToken,this.userInfo=t,this.cbBotDetails(t,this.options.botInfo),this.RtmClient=new r.KoreRtmClient({},this.options),this.RtmClient.on(p.API_FAILURE,function(e){n.emit(p.API_FAILURE,e)}),this.RtmClient.on("reconnect_event",function(e){n.emit("reconnected",e)}),this.RtmClient.on("before_ws_con",function(e){n.emit("before_ws_connection",e)}),this.emit("rtm_client_initialized"),this.emit(p.JWT_GRANT_SUCCESS,{jwtgrantsuccess:t}),(this.options.openSocket||this.options.autoConnect||"v2"==this.options.botInfo.uiVersion)&&this.logInComplete())},y.prototype.logInComplete=function(){if(this.RtmClient){this.RtmClient.start({botInfo:this.options.botInfo}),0===this.RtmClient.listenerCount(h.MESSAGE)&&this.RtmClient.on(h.MESSAGE,u(this.onMessage,this)),0===this.RtmClient.listenerCount(f.RTM_CONNECTION_OPENED)&&this.RtmClient.on(f.RTM_CONNECTION_OPENED,u(this.onOpenWSConnection,this));var e=this;Object.keys(f).forEach(function(t){0===e.RtmClient.listenerCount(f[t])&&e.RtmClient.on(f[t],function(n){e.emit("rtm:"+f[t],n)})})}},y.prototype.logIn=function(e,t){var n=this;e?(g("error in assertionFn %s",e),console.error("error in assertionFn",e&&e.stack)):(g("signed-in user login"),this.options=t,this.claims=t.assertion,this.WebClient=new r.KoreWebClient({},this.options),this.WebClient.claims=this.claims,this.cbErrorToClient=t.handleError||m,this.cbBotDetails=t.botDetails||m,this.cbBotChatHistory=t.chatHistory||m,this.WebClient.on(p.API_FAILURE,function(e){n.emit(p.API_FAILURE,e)}),this.options.webhookConfig&&this.options.webhookConfig.enable?(this.options.webhookConfig.token=this.options.assertion,this.emit(p.WEB_HOOK_READY),this.options.loadHistory&&!this._chatHistoryLoaded?this.getHistory({limit:this.options.messageHistoryLimit},t):this.emit(p.WEB_HOOK_RECONNECTED)):this.WebClient.login.login({assertion:t.assertion,botInfo:this.options.botInfo},u(this.onLogIn,this)))},y.prototype.init=function(e,t){(t=t||10)>100&&(t=100),"undefined"!=typeof window&&(window.messageHistoryLimit=t||10),e=e||{},this.options=e,this.oldestId=null,this.RtmClient=null,e.test?(g("test is true"),l(e.koreAnonymousFn)?e.koreAnonymousFn.call(this,e):(g("koreAnonymousFn is not a function"),console.error("koreAnonymousFn is not a function"))):(g("test is false"),l(e.assertionFn)?e.assertionFn(e,u(this.logIn,this)):(g("assertion is not a function"),console.error("assertion is not a function"))),e.loadHistory?this.paginatedScrollDataAvailable=!0:this.paginatedScrollDataAvailable=!1,this.reWriteWebhookConfig(e)},y.prototype.reWriteWebhookConfig=function(e){if(e&&e.webhookConfig&&e.webhookConfig.enable){var t=e.botInfo.taskBotId,n="ivr",o=e.webhookConfig.webhookURL,i="hookInstance/";o.indexOf(i)>-1&&(n=o.substring(o.indexOf(i)+13,o.length)),e.webhookConfig.streamId=t,e.webhookConfig.channelType=n}},t.exports.instance=function(){var e=new y;return e.KoreBot=y,e.KoreRTMClient=r.KoreRtmClient,Object.keys(c).forEach(function(t){e[t]=c[t]}),e}},{"./index.js":1,"./jstz.js":2,debug:21,events:30,inherits:23,lodash:24}],1:[function(e,t,n){var o=e("./lib/clients/events");t.exports={KoreWebClient:e("./lib/clients/web/client"),KoreRtmClient:e("./lib/clients/rtm/client"),CLIENT_EVENTS:{WEB:o.CLIENT_EVENTS.WEB,RTM:o.CLIENT_EVENTS.RTM},RTM_EVENTS:o.RTM_EVENTS,RTM_MESSAGE_SUBTYPES:o.RTM_MESSAGE_SUBTYPES}},{"./lib/clients/events":5,"./lib/clients/rtm/client":9,"./lib/clients/web/client":18}],2:[function(e,t,n){var o,i,r,s,a,c;o=this,i=function(e){var t=-e.getTimezoneOffset();return null!==t?t:0},r=function(e,t,n){var o=new Date;return void 0!==e&&o.setFullYear(e),o.setDate(n),o.setMonth(t),o},s=function(e){return i(r(e,0,2))},a=function(e){return i(r(e,5,2))},(c={determine:function(){var e,t,n,o=(e=s(),t=a(),(n=s()-a())<0?e+",1":n>0?t+",1,s":e+",0");return new c.TimeZone(c.olson.timezones[o])},date_is_dst:function(e){return(e.getMonth()>7?a(e.getFullYear()):s(e.getFullYear()))-i(e)!==0},dst_start_for:function(e){var t=new Date(2010,6,15,1,0,0,0);return{"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,9,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2012,9,21,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2012,2,10,2,0,0,0),"America/New_York":new Date(2012,2,10,7,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Asia/Gaza":new Date(2009,2,28,0,30,0,0),"Africa/Cairo":new Date(2009,3,25,0,30,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,11,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0),"Europe/Moscow":t,"Asia/Yekaterinburg":t,"Asia/Omsk":t,"Asia/Krasnoyarsk":t,"Asia/Irkutsk":t,"Asia/Yakutsk":t,"Asia/Vladivostok":t,"Asia/Kamchatka":t,"Europe/Minsk":t,"Australia/Perth":new Date(2008,10,1,1,0,0,0)}[e]}}).TimeZone=function(e){var t={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Asia/Gaza"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"],"Asia/Dubai":["Europe/Moscow"],"Asia/Dhaka":["Asia/Yekaterinburg"],"Asia/Jakarta":["Asia/Omsk"],"Asia/Shanghai":["Asia/Krasnoyarsk","Australia/Perth"],"Asia/Tokyo":["Asia/Irkutsk"],"Australia/Brisbane":["Asia/Yakutsk"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Tarawa":["Asia/Kamchatka"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"],"Asia/Baghdad":["Europe/Minsk"]},n=e;return void 0!==t[n]&&function(){for(var e=t[n],o=e.length,i=0,r=e[0];i<o;i+=1)if(r=e[i],c.date_is_dst(c.dst_start_for(r)))return void(n=r)}(),{name:function(){return n}}},c.olson={},c.olson.timezones={"-720,0":"Etc/GMT+12","-660,0":"Pacific/Pago_Pago","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier","-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Santiago","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo","-120,0":"Etc/GMT+2","-120,1":"Etc/GMT+2","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"Etc/UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka","360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland","720,0":"Pacific/Tarawa","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},void 0!==n?n.jstz=c:o.jstz=c},{}],3:[function(e,t,n){var o=e("events"),i=e("async"),r=(e("lodash").bind?e("lodash"):_).bind,s=e("inherits"),a=e("retry"),c=e("url-join"),u=e("./events/client").WEB,l=e("./helpers"),f=e("./transports/request").requestTransport;function h(e,t){o.call(this),this._token=e,this.koreAPIUrl=t.koreAPIUrl||"https://app.kore.com/api/",this.reWriteSocketURL=t.reWriteSocketURL,this.transport=t.transport||f,this.userAgent,this._requestQueue=i.priorityQueue(r(this._callTransport,this),t.maxRequestConcurrency),this._createFacets()}s(h,o),h.prototype.emit=function(){h.super_.prototype.emit.apply(this,arguments)},h.prototype._createFacets=function(){},h.prototype._callTransport=function(e,t){var n=e.args,o=e.cb,i=this,r=a.operation(this.retryConfig);i._activeRetryOp=r;var s=function e(s,a,c,l){if(i._currentRequest=null,i._activeRetryOp===r){var f,h;if(s){if(r.retry(s)){var p,d;if(s)p={msg:s.message||"An unkown error occurred",code:0};else p=(null==l||null===(d=l.errors)||void 0===d?void 0:d[0])||(null==l?void 0:l.errors)||l;return void i.emit("api_failure",{type:"XHRObj",responseError:p,request:n})}i._activeRetryOp=null,o(r.mainError(),null)}if(200!==c)if(429===c)i._requestQueue.pause(),f=parseInt(a["Retry-After"],10),setTimeout(function(){i.transport(n,e),i._requestQueue.resume()},1e3*f),i.emit(u.RATE_LIMITED,f);else{var m,g;if(s)m={msg:s.message||"An unknown error occurred",code:0};else m=(null==l||null===(g=l.errors)||void 0===g?void 0:g[0])||(null==l?void 0:l.errors)||l;if(i.emit("api_failure",{type:"XHRObj",responseError:m,request:n}),h=new Error("Unable to process request, received bad "+c+" error"),401!==c){if(r.retry(h))return void o(h,l);o(h,l)}else o(h,l)}else i._activeRetryOp=null,o(null,l);t()}};r.attempt(function(){i._activeRetryOp===r&&(i._currentRequest=i.transport(n,s))})},h.prototype.makeAPICall=function(e,t,n){var o=l.getAPICallArgs(this._token,t,n),i={url:/^((http|https):\/\/)/.test(e)?e:c(this.koreAPIUrl,e),data:o.data,headers:{"User-Agent":this.userAgent,"content-type":"application/json"}};t&&t.opts&&t.opts.authorization&&(i.headers.Authorization=t.opts.authorization,delete i.data.authorization),t&&t.opts&&t.opts["x-rtm-v"]&&(i.headers["x-rtm-v"]=t.opts["x-rtm-v"],delete i.data["x-rtm-v"]),this._requestQueue.push({args:i,cb:o.cb})},t.exports=h},{"./events/client":4,"./helpers":8,"./transports/request":10,async:19,events:30,inherits:23,lodash:24,retry:26,"url-join":29}],4:[function(e,t,n){t.exports.WEB={RATE_LIMITED:"rate_limited",WEB_HOOK_READY:"webhook_ready",WEB_HOOK_RECONNECTED:"webhook_reconnected",JWT_GRANT_SUCCESS:"jwtgrantsuccess",API_FAILURE:"api_failure"},t.exports.RTM={CONNECTING:"connecting",AUTHENTICATED:"authenticated",WS_OPENING:"ws_opening",WS_OPENED:"ws_opened",RTM_CONNECTION_OPENED:"open",DISCONNECT:"disconnect",UNABLE_TO_RTM_START:"unable_to_rtm_start",WS_CLOSE:"ws_close",WS_ERROR:"ws_error",ATTEMPTING_RECONNECT:"attempting_reconnect",RAW_MESSAGE:"raw_message"}},{}],5:[function(e,t,n){t.exports={CLIENT_EVENTS:{WEB:e("./client").WEB,RTM:e("./client").RTM},RTM_EVENTS:e("./rtm").EVENTS,RTM_MESSAGE_SUBTYPES:e("./rtm").MESSAGE_SUBTYPES}},{"./client":4,"./rtm":6}],6:[function(e,t,n){t.exports.EVENTS={HELLO:"hello",MESSAGE:"message"},t.exports.MESSAGE_SUBTYPES={BOT_MESSAGE:"bot_message",ME_MESSAGE:"me_message"}},{}],7:[function(e,t,n){var o=e("./rtm").EVENTS;t.exports.makeMessageEventWithSubtype=function(e,t){return[o.MESSAGE,e].join(t||"::")}},{"./rtm":6}],8:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).assign,r=o.isFunction,s=o.isUndefined,a=o.isString,c=o.forEach,u=function(e,t){var n=i({},e&&e.opts||{});return c(e||{},function(e,t){s(e)||null===e||"opts"===t||("attachments"===t?a(e)?n[t]=e:n[t]=JSON.stringify(e):n[t]=e)}),t&&(n.token=t),n};t.exports.getData=u,t.exports.getAPICallArgs=function(e,t,n){var o,i;return 1===arguments.length?(i=noop,o=u({},e)):2===arguments.length?r(arguments[1])?(i=arguments[1],o=u({},e)):(i=noop,o=u(t,e)):3===arguments.length&&(i=n||noop,o=u(t,e)),{cb:i,data:o}}},{lodash:24}],9:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).bind,r=o.cloneDeep,s=o.contains,a=e("inherits"),c=o.isUndefined,u=e("debug")("botsdk:KoreRTMClient"),l=e("../events/rtm").EVENTS,f=["pong",l.HELLO],h=["not_authed","invalid_auth","account_inactive","token_expired"],p=e("../events/client").RTM,d=e("../client"),m=e("../web/apis").RtmApi,g=e("../events/utils").makeMessageEventWithSubtype,y=e("../transports/ws");p=e(4);function v(e,t){var n=t||{};n.maxRequestConcurrency=1,d.call(this,e,n),this._socketFn=n.socketFn||y,this.ws=void 0,this.RECONNECTION_BACKOFF=n.reconnectionBackoff||3e3,this.MAX_PONG_INTERVAL=n.maxPongInterval||1e4,this.WS_PING_INTERVAL=n.wsPingInterval||5e3,this.cbResetWindow=n.resetWindow||noop,this.autoReconnect=!1!==n.autoReconnect,this.connected=!1,this.authenticated=!1,this.activeUserId=void 0,this._pendingMessages={},this._connAttempts=0,this._connecting=!1,this._reconnecting=n.maintainContext||!1,n.forceReconnecting&&(this._reconnecting=!0,n.forceReconnecting=!1),n.hasOwnProperty("_reconnecting")&&n._reconnecting&&(this._reconnecting=n._reconnecting,n._reconnecting=!1),this.user={},this.user.accessToken=n.accessToken,this.assertion=null==n?void 0:n.assertion,this.botInfo=n.botInfo||{},this.CLIENT_EVENTS=p.RTM,this.$=n.$,this.debug=u,this.socketConfig=(null==n?void 0:n.webSocketConfig)||{},this.retryConfig=n.retryConfig||{retries:n.maxReconnectionAPIAttempts||5,factor:2},this.enableSecureRTM=!1!==n.enableSecureRTM,this.secureChannel=null;var o=n.secureChannel;if(o&&o.pinnedPublicKeyPem&&"function"==typeof n.secureChannelFactory){var i=this;this.secureChannel=n.secureChannelFactory({config:{pinnedPublicKeyPem:o.pinnedPublicKeyPem,expectedSigningKeyId:o.expectedSigningKeyId},rawSend:function(e){return i.rawSend(e)}})}}a(v,d),v.prototype._createFacets=function(){v.super_.prototype._createFacets.call(this),this._rtm=new m(this)},v.prototype.start=function(e){this._connecting||(this.emit(p.CONNECTING),this._connecting=!0,(e=e||{botInfo:this.botInfo}).authorization="bearer "+this.user.accessToken,this.enableSecureRTM&&(e["x-rtm-v"]=1),this._rtm.start(e,i(this._onStart,this)))},v.prototype.nextMessageId=function(){return this._messageId=this._messageId||1,this._messageId++},v.prototype._onStart=function(e,t){var n,o,i,r=this,a=!!this._reconnecting;if(this._connecting=!1,this._reconnecting=!1,t&&t.errors&&("TOKEN_EXPIRED"===t.errors[0].code||401===t.errors[0].code||"token expired"===t.errors[0].msg)){var c={forceReconnect:!0,isReconnect:!0};this.cbResetWindow(c),c.error="token_expired"}e||!t.url?(u("error or no url in response %s",e||"no url"),this.emit(p.UNABLE_TO_RTM_START,e||t.error),t&&s(h,t.error)&&this.disconnect("unrecoverable failure connecting to the RTM API",t.error)):(this.socketConfig&&null!==(n=this.socketConfig)&&void 0!==n&&n.socketUrl&&null!==(o=this.socketConfig)&&void 0!==o&&null!==(o=o.socketUrl)&&void 0!==o&&o.queryParams&&Object.keys(this.socketConfig.socketUrl.queryParams).length>0?a?(t.url=t.url+"&ConnectionMode=Reconnect",Object.keys(this.socketConfig.socketUrl.queryParams).forEach(function(e){e&&"ConnectionMode"!==e&&r.socketConfig.socketUrl.queryParams[e]&&(t.url=t.url+"&"+e+"="+r.socketConfig.socketUrl.queryParams[e])})):Object.keys(this.socketConfig.socketUrl.queryParams).forEach(function(e){e&&r.socketConfig.socketUrl.queryParams[e]&&(t.url=t.url+"&"+e+"="+r.socketConfig.socketUrl.queryParams[e])}):a&&(t.url=t.url+"&isReconnect=true"),a||"true"!=window.sessionStorage.getItem("isReconnect")||(t.url=t.url+"&isReconnect=true"),"true"==window.sessionStorage.getItem("debugLogEnabled")&&(t.url=t.url+"&isDebugging=true"),this.authenticated=!0,this.emit(p.AUTHENTICATED,t),this.emit("reconnect_event",{reconnected:a}),this.emit("before_ws_con",{data:t,isImplicitReconnect:a}),this.connect(t.url,(null===(i=t)||void 0===i?void 0:i.nonce)||""))},v.prototype.cleanup=function(){if(this._activeRetryOp=null,this._currentRequest){try{this._currentRequest.abort()}catch(e){console.log("Error aborting request",e)}this._currentRequest=null}this._requestQueue&&this._requestQueue.kill()},v.prototype._close=function(){this.autoReconnect=!1,this._safeDisconnect()},v.prototype._safeDisconnect=function(){this.ws&&this.ws.close(),this.authenticated=!1,this.connected=!1},v.prototype.reWriteURL=function(e){if(this.reWriteSocketURL){var t=document.createElement("a");t.href=e,this.reWriteSocketURL.protocol&&(t.protocol=this.reWriteSocketURL.protocol),this.reWriteSocketURL.hostname&&(t.hostname=this.reWriteSocketURL.hostname),this.reWriteSocketURL.port&&(t.port=this.reWriteSocketURL.port),e=t.href}return e},v.prototype.connect=function(e,t){u("connecting"),this.emit(p.WS_OPENING,{}),e=this.reWriteURL(e);var n=[];this.enableSecureRTM&&this.assertion&&t&&(n.push("x-rtm-v|1"),n.push("jwt|"+this.assertion),n.push("nonce|"+t)),this.ws=this._socketFn(e,n),this.ws.onopen=i(this.handleWsOpen,this),this.ws.onmessage=i(this.handleWsMessage,this),this.ws.onerror=i(this.handleWsError,this),this.ws.onclose=i(this.handleWsClose,this),this.ws.onping=i(this.handleWsPing,this)},v.prototype.disconnect=function(e,t){u("disconnecting"),this.emit(p.DISCONNECT,e,t),this.autoReconnect=!1,this._safeDisconnect()},v.prototype.reconnect=function(){u("reconnecting"),console.log("in reconnect"),this._reconnecting||(this._reconnecting=!0,this.emit(p.ATTEMPTING_RECONNECT),this._safeDisconnect(),this._connAttempts++,setTimeout(i(this.start,this),this._connAttempts*this.RECONNECTION_BACKOFF))},v.prototype.handleWsOpen=function(){u("connected"),this.connected=!0,this.emit("open",{data:{}}),this._connAttempts=0},v.prototype.handleWsMessage=function(e){var t,n=this;if(this.secureChannel){var o=e&&"string"==typeof e.data?e.data:"string"==typeof e?e:null,i=null;if(o)try{i=JSON.parse(o)}catch(e){i=null}if(i&&this.secureChannel.isRelevant(i))return void this.secureChannel.processIncoming(i).then(function(e){if(e&&!e.handled){var t=void 0!==e.plaintext?e.plaintext:i;n.emit("message",{data:JSON.stringify(t)})}}).catch(function(){})}this.emit("message",e);try{t=JSON.parse(e)}catch(e){return}s(f,t.type)?this._handleWsMessageInternal(t.type,t):this._handleWsMessageViaEventHandler(t.type,t)},v.prototype._handleWsMessageInternal=function(e,t){e===l.HELLO&&this._handleHello()},v.prototype._handleWsMessageViaEventHandler=function(e,t){var n;if(e===l.MESSAGE&&(n=t.reply_to)){if(!this._pendingMessages[n])return;delete this._pendingMessages[n]}this.emit(e,t),e!==l.MESSAGE||c(t.subtype)||this.emit(g(t.subtype),t)},v.prototype.handleWsError=function(e){u("web socket error::%s",e),this.emit("api_failure",{type:"socketError",responseError:e,request:""}),this.emit(p.WS_ERROR,e)},v.prototype.handleWsClose=function(e,t){this.connected=!1,this.secureChannel&&this.secureChannel.reset("ws_close"),this.emit(p.WS_CLOSE,e,t),this.autoReconnect?this._connecting||this.reconnect():(u("websocket closed with auto-reconnect false on the RTM client"),this.disconnect("websocket closed with auto-reconnect false on the RTM client"))},v.prototype.handleWsPing=function(){this.ws.pong&&this.ws.pong()},v.prototype._handleHello=function(){this.connected=!0,this.emit(p.RTM_CONNECTION_OPENED)},v.prototype.sendMessage=function(e,t){this.send(e,t)},v.prototype.send=function(e,t){var n=this;this.secureChannel?Promise.resolve(this.secureChannel.processOutgoing(e)).then(function(e){n.rawSend(e,t)},function(e){c(t)||t(e instanceof Error?e:new Error(String(e&&e.message||e)))}):this.rawSend(e,t)},v.prototype.rawSend=function(e,t){var n,o,i=r(e);this.connected&&!this._reconnecting?(i.id=i.clientMessageId||this.nextMessageId(),n=JSON.stringify(i),this._pendingMessages[i.id]=i,this.ws.send(n,void 0,function(e){c(e),c(t)||t(e)})):(u(o="ws not connected or reconnecting, unable to send message"),c(t)||t(new Error(o)))},t.exports=v},{"../client":3,"../events/client":4,"../events/rtm":6,"../events/utils":7,"../transports/ws":11,"../web/apis":15,debug:21,inherits:23,lodash:24}],10:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).has,r=o.partial,s=e("browser-request"),a=function(e,t,n,o){t?e(t,n&&n.headers||{},n&&n.statusCode||null,o):e(t,n.headers,n.statusCode,o)};t.exports.requestTransport=function(e,t){var n=function(e){var t={url:e.url,headers:e.headers};return i(e.data,"file")?t.formData=e.data:t.json=e.data,t}(e);e.data&&e.data.type&&"GET"===e.data.type?s.get(n,r(a,t)):s.post(n,r(a,t))}},{"browser-request":20,lodash:24}],11:[function(e,t,n){t.exports=function(e,t){return t&&t.length>0?new WebSocket(e,t):new WebSocket(e)}},{}],12:[function(e,t,n){t.exports=function(){}},{}],13:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="anonymouslogin",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.login=function(e,t){var n={opts:e=e||{}};return this.client.makeAPICall("/oAuth/token/jwtgrant/anonymous",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],14:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="history",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.history=function(e,t,n){var o={opts:e=e||{},type:"GET"},i="/botmessages/rtm";n&&n.webhookConfig&&n.webhookConfig.enable&&(i="/chathistory/"+n.webhookConfig.streamId+"/"+n.webhookConfig.channelType);var r=!1,s="?";return e.botInfo&&e.botInfo.taskBotId&&(!1===r?(i+=s+"botId="+e.botInfo.taskBotId,s="&",r=!0):i+=s+"botId="+e.botInfo.taskBotId,delete e.botInfo),e.offset&&(!1===r?(i+=s+"offset="+e.offset,s="&",r=!0):i+=s+"offset="+e.offset,delete e.offset),e.limit&&(!1===r?(i+=s+"limit="+e.limit,s="&",r=!0):i+=s+"limit="+e.limit,delete e.limit),e.forward&&(!1===r?(i+=s+"forward="+e.forward,s="&",r=!0):i+=s+"forward="+e.forward,delete e.forward),e.msgId&&(!1===r?(i+=s+"msgId="+e.msgId,s="&",r=!0):i+=s+"msgId="+e.msgId,delete e.msgId),this.client.makeAPICall(i,o,t)},t.exports=i},{"./BaseApi":12,inherits:23}],15:[function(e,t,n){t.exports={RtmApi:e("./rtm.js"),LogInApi:e("./login.js"),AnonymousLogin:e("./anonymouslogin.js"),HistoryApi:e("./history.js")}},{"./anonymouslogin.js":13,"./history.js":14,"./login.js":16,"./rtm.js":17}],16:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="login",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.login=function(e,t){var n={opts:e=e||{}};return this.client.makeAPICall("/oAuth/token/jwtgrant",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],17:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="rtm",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.start=function(e,t){e.language=localStorage.currentBotLanguage||"en";var n={opts:e};return this.client.makeAPICall("/rtm/start",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],18:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).bind,r=o.forEach,s=e("inherits"),a=e("../client"),c=e("./apis/index");function u(e,t){var n=t||{};a.call(this,e,n),this.claims=t.claims,this.retryConfig=n.retryConfig||{retries:n.maxReconnectionAPIAttempts||5,factor:3.9},this.user={}}s(u,a),u.prototype._createFacets=function(){var e;u.super_.prototype._createFacets.call(this),i(this.makeAPICall,this),r(c,function(t){this[(e=new t(this)).name]=e},this)},t.exports=u},{"../client":3,"./apis/index":15,inherits:23,lodash:24}],19:[function(n,o,i){(function(n,i){!function(){var r,s={};function a(){}function c(e){return e}function u(e){return!!e}function l(e){return!e}var f="object"===("undefined"==typeof self?"undefined":t(self))&&self.self===self&&self||"object"===t(i)&&i.global===i&&i||this;function h(e){return function(){if(null===e)throw new Error("Callback was already called.");e.apply(this,arguments),e=null}}function p(e){return function(){null!==e&&(e.apply(this,arguments),e=null)}}null!=f&&(r=f.async),s.noConflict=function(){return f.async=r,s};var d=Object.prototype.toString,m=Array.isArray||function(e){return"[object Array]"===d.call(e)};function g(e){return m(e)||"number"==typeof e.length&&e.length>=0&&e.length%1==0}function y(e,t){for(var n=-1,o=e.length;++n<o;)t(e[n],n,e)}function v(e,t){for(var n=-1,o=e.length,i=Array(o);++n<o;)i[n]=t(e[n],n,e);return i}function b(e){return v(Array(e),function(e,t){return t})}function _(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var w=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};function A(e){var t,n,o=-1;return g(e)?(t=e.length,function(){return++o<t?o:null}):(n=w(e),t=n.length,function(){return++o<t?n[o]:null})}function E(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),o=Array(n),i=0;i<n;i++)o[i]=arguments[i+t];switch(t){case 0:return e.call(this,o);case 1:return e.call(this,arguments[0],o)}}}function k(e){return function(t,n,o){return e(t,o)}}var C="function"==typeof setImmediate&&setImmediate,T=C?function(e){C(e)}:function(e){setTimeout(e,0)};function I(e){return function(t,n,o){o=p(o||a);var i=A(t=t||[]);if(e<=0)return o(null);var r=!1,s=0,c=!1;!function a(){if(r&&s<=0)return o(null);for(;s<e&&!c;){var u=i();if(null===u)return r=!0,void(s<=0&&o(null));s+=1,n(t[u],u,h(function(e){s-=1,e?(o(e),c=!0):a()}))}}()}}function S(e){return function(t,n,o){return e(s.eachOf,t,n,o)}}function O(e){return function(t,n,o,i){return e(I(n),t,o,i)}}function R(e){return function(t,n,o){return e(s.eachOfSeries,t,n,o)}}function x(e,t,n,o){o=p(o||a);var i=g(t=t||[])?[]:{};e(t,function(e,t,o){n(e,function(e,n){i[t]=n,o(e)})},function(e){o(e,i)})}function N(e,t,n,o){var i=[];e(t,function(e,t,o){n(e,function(n){n&&i.push({index:t,value:e}),o()})},function(){o(v(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})}function M(e,t,n,o){N(e,t,function(e,t){n(e,function(e){t(!e)})},o)}function L(e,t,n){return function(o,i,r,s){function a(){s&&s(n(!1,void 0))}function c(e,o,i){if(!s)return i();r(e,function(o){s&&t(o)&&(s(n(!0,e)),s=r=!1),i()})}arguments.length>3?e(o,i,c,a):(s=r,r=i,e(o,c,a))}}function P(e,t){return t}function D(e,t,n){n=n||a;var o=g(t)?[]:{};e(t,function(e,t,n){e(E(function(e,i){i.length<=1&&(i=i[0]),o[t]=i,n(e)}))},function(e){n(e,o)})}function j(e,t,n,o){var i=[];e(t,function(e,t,o){n(e,function(e,t){i=i.concat(t||[]),o(e)})},function(e){o(e,i)})}function W(e,t,n){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");function o(e,t,n,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");if(e.started=!0,m(t)||(t=[t]),0===t.length&&e.idle())return s.setImmediate(function(){e.drain()});y(t,function(t){var i={data:t,callback:o||a};n?e.tasks.unshift(i):e.tasks.push(i),e.tasks.length===e.concurrency&&e.saturated()}),s.setImmediate(e.process)}function i(e,t){return function(){r-=1;var n=!1,o=arguments;y(t,function(e){y(c,function(t,o){t!==e||n||(c.splice(o,1),n=!0)}),e.callback.apply(e,o)}),e.tasks.length+r===0&&e.drain(),e.process()}}var r=0,c=[],u={tasks:[],concurrency:t,payload:n,saturated:a,empty:a,drain:a,started:!1,paused:!1,push:function(e,t){o(u,e,!1,t)},kill:function(){u.drain=a,u.tasks=[]},unshift:function(e,t){o(u,e,!0,t)},process:function(){for(;!u.paused&&r<u.concurrency&&u.tasks.length;){var t=u.payload?u.tasks.splice(0,u.payload):u.tasks.splice(0,u.tasks.length),n=v(t,function(e){return e.data});0===u.tasks.length&&u.empty(),r+=1,c.push(t[0]);var o=h(i(u,t));e(n,o)}},length:function(){return u.tasks.length},running:function(){return r},workersList:function(){return c},idle:function(){return u.tasks.length+r===0},pause:function(){u.paused=!0},resume:function(){if(!1!==u.paused){u.paused=!1;for(var e=Math.min(u.concurrency,u.tasks.length),t=1;t<=e;t++)s.setImmediate(u.process)}}};return u}function B(e){return E(function(n,o){n.apply(null,o.concat([E(function(n,o){"object"===("undefined"==typeof console?"undefined":t(console))&&(n?console.error&&console.error(n):console[e]&&y(o,function(t){console[e](t)}))})]))})}function U(e){return function(t,n,o){e(b(t),n,o)}}function H(e){return E(function(t,n){var o=E(function(n){var o=this,i=n.pop();return e(t,function(e,t,i){e.apply(o,n.concat([i]))},i)});return n.length?o.apply(this,n):o})}function q(e){return E(function(t){var n=t.pop();t.push(function(){var e=arguments;o?s.setImmediate(function(){n.apply(null,e)}):n.apply(null,e)});var o=!0;e.apply(this,t),o=!1})}"object"===t(n)&&"function"==typeof n.nextTick?s.nextTick=n.nextTick:s.nextTick=T,s.setImmediate=C?T:s.nextTick,s.forEach=s.each=function(e,t,n){return s.eachOf(e,k(t),n)},s.forEachSeries=s.eachSeries=function(e,t,n){return s.eachOfSeries(e,k(t),n)},s.forEachLimit=s.eachLimit=function(e,t,n,o){return I(t)(e,k(n),o)},s.forEachOf=s.eachOf=function(e,t,n){n=p(n||a);for(var o,i=A(e=e||[]),r=0;null!=(o=i());)r+=1,t(e[o],o,h(s));function s(e){r--,e?n(e):null===o&&r<=0&&n(null)}0===r&&n(null)},s.forEachOfSeries=s.eachOfSeries=function(e,t,n){n=p(n||a);var o=A(e=e||[]),i=o();!function r(){var a=!0;if(null===i)return n(null);t(e[i],i,h(function(e){if(e)n(e);else{if(null===(i=o()))return n(null);a?s.setImmediate(r):r()}})),a=!1}()},s.forEachOfLimit=s.eachOfLimit=function(e,t,n,o){I(t)(e,n,o)},s.map=S(x),s.mapSeries=R(x),s.mapLimit=O(x),s.inject=s.foldl=s.reduce=function(e,t,n,o){s.eachOfSeries(e,function(e,o,i){n(t,e,function(e,n){t=n,i(e)})},function(e){o(e,t)})},s.foldr=s.reduceRight=function(e,t,n,o){var i=v(e,c).reverse();s.reduce(i,t,n,o)},s.transform=function(e,t,n,o){3===arguments.length&&(o=n,n=t,t=m(e)?[]:{}),s.eachOf(e,function(e,o,i){n(t,e,o,i)},function(e){o(e,t)})},s.select=s.filter=S(N),s.selectLimit=s.filterLimit=O(N),s.selectSeries=s.filterSeries=R(N),s.reject=S(M),s.rejectLimit=O(M),s.rejectSeries=R(M),s.any=s.some=L(s.eachOf,u,c),s.someLimit=L(s.eachOfLimit,u,c),s.all=s.every=L(s.eachOf,l,l),s.everyLimit=L(s.eachOfLimit,l,l),s.detect=L(s.eachOf,c,P),s.detectSeries=L(s.eachOfSeries,c,P),s.detectLimit=L(s.eachOfLimit,c,P),s.sortBy=function(e,t,n){function o(e,t){var n=e.criteria,o=t.criteria;return n<o?-1:n>o?1:0}s.map(e,function(e,n){t(e,function(t,o){t?n(t):n(null,{value:e,criteria:o})})},function(e,t){if(e)return n(e);n(null,v(t.sort(o),function(e){return e.value}))})},s.auto=function(e,t,n){"function"==typeof arguments[1]&&(n=t,t=null),n=p(n||a);var o=w(e),i=o.length;if(!i)return n(null);t||(t=i);var r={},c=0,u=!1,l=[];function f(e){l.unshift(e)}function h(){i--,y(l.slice(0),function(e){e()})}f(function(){i||n(null,r)}),y(o,function(o){if(!u){for(var i,a=m(e[o])?e[o]:[e[o]],p=E(function(e,t){if(c--,t.length<=1&&(t=t[0]),e){var i={};l=function(e,t){i[t]=e},y(w(a=r),function(e){l(a[e],e)}),i[o]=t,u=!0,n(e,i)}else r[o]=t,s.setImmediate(h);var a,l}),d=a.slice(0,a.length-1),g=d.length;g--;){if(!(i=e[d[g]]))throw new Error("Has nonexistent dependency in "+d.join(", "));if(m(i)&&_(i,o)>=0)throw new Error("Has cyclic dependencies")}v()?(c++,a[a.length-1](p,r)):f(function e(){v()&&(c++,(t=_(l,e))>=0&&l.splice(t,1),a[a.length-1](p,r));var t})}function v(){return c<t&&(e=function(e,t){return e&&r.hasOwnProperty(t)},n=!0,y(d,function(t,o,i){n=e(n,t,o,i)}),n)&&!r.hasOwnProperty(o);var e,n}})},s.retry=function(e,n,o){var i=[],r={times:5,interval:0};var a=arguments.length;if(a<1||a>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");function c(e,t){function n(e,n){return function(o){e(function(e,t){o(!e||n,{err:e,result:t})},t)}}function o(e){return function(t){setTimeout(function(){t(null)},e)}}for(;r.times;){var a=!(r.times-=1);i.push(n(r.task,a)),!a&&r.interval>0&&i.push(o(r.interval))}s.series(i,function(t,n){n=n[n.length-1],(e||r.callback)(n.err,n.result)})}return a<=2&&"function"==typeof e&&(o=n,n=e),"function"!=typeof e&&function(e,n){if("number"==typeof n)e.times=parseInt(n,10)||5;else{if("object"!==t(n))throw new Error("Unsupported argument type for 'times': "+t(n));e.times=parseInt(n.times,10)||5,e.interval=parseInt(n.interval,10)||0}}(r,e),r.callback=o,r.task=n,r.callback?c():c},s.waterfall=function(e,t){if(t=p(t||a),!m(e)){var n=new Error("First argument to waterfall must be an array of functions");return t(n)}if(!e.length)return t();!function e(n){return E(function(o,i){if(o)t.apply(null,[o].concat(i));else{var r=n.next();r?i.push(e(r)):i.push(t),q(n).apply(null,i)}})}(s.iterator(e))()},s.parallel=function(e,t){D(s.eachOf,e,t)},s.parallelLimit=function(e,t,n){D(I(t),e,n)},s.series=function(e,t){D(s.eachOfSeries,e,t)},s.iterator=function(e){return function t(n){function o(){return e.length&&e[n].apply(null,arguments),o.next()}return o.next=function(){return n<e.length-1?t(n+1):null},o}(0)},s.apply=E(function(e,t){return E(function(n){return e.apply(null,t.concat(n))})}),s.concat=S(j),s.concatSeries=R(j),s.whilst=function(e,t,n){if(n=n||a,e()){var o=E(function(i,r){i?n(i):e.apply(this,r)?t(o):n.apply(null,[null].concat(r))});t(o)}else n(null)},s.doWhilst=function(e,t,n){var o=0;return s.whilst(function(){return++o<=1||t.apply(this,arguments)},e,n)},s.until=function(e,t,n){return s.whilst(function(){return!e.apply(this,arguments)},t,n)},s.doUntil=function(e,t,n){return s.doWhilst(e,function(){return!t.apply(this,arguments)},n)},s.during=function(e,t,n){n=n||a;var o=E(function(t,o){t?n(t):(o.push(i),e.apply(this,o))}),i=function(e,i){e?n(e):i?t(o):n(null)};e(i)},s.doDuring=function(e,t,n){var o=0;s.during(function(e){o++<1?e(null,!0):t.apply(this,arguments)},e,n)},s.queue=function(e,t){return W(function(t,n){e(t[0],n)},t,1)},s.priorityQueue=function(e,t){function n(e,t){return e.priority-t.priority}var o=s.queue(e,t);return o.push=function(e,t,i){!function(e,t,o,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");if(e.started=!0,m(t)||(t=[t]),0===t.length)return s.setImmediate(function(){e.drain()});y(t,function(t){var r={data:t,priority:o,callback:"function"==typeof i?i:a};e.tasks.splice(function(e,t,n){for(var o=-1,i=e.length-1;o<i;){var r=o+(i-o+1>>>1);n(t,e[r])>=0?o=r:i=r-1}return o}(e.tasks,r,n)+1,0,r),e.tasks.length===e.concurrency&&e.saturated(),s.setImmediate(e.process)})}(o,e,t,i)},delete o.unshift,o},s.cargo=function(e,t){return W(e,1,t)},s.log=B("log"),s.dir=B("dir"),s.memoize=function(e,t){var n={},o={},i=Object.prototype.hasOwnProperty;t=t||c;var r=E(function(r){var a=r.pop(),c=t.apply(null,r);i.call(n,c)?s.setImmediate(function(){a.apply(null,n[c])}):i.call(o,c)?o[c].push(a):(o[c]=[a],e.apply(null,r.concat([E(function(e){n[c]=e;var t=o[c];delete o[c];for(var i=0,r=t.length;i<r;i++)t[i].apply(null,e)})])))});return r.memo=n,r.unmemoized=e,r},s.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},s.times=U(s.map),s.timesSeries=U(s.mapSeries),s.timesLimit=function(e,t,n,o){return s.mapLimit(b(e),t,n,o)},s.seq=function(){var e=arguments;return E(function(t){var n=this,o=t[t.length-1];"function"==typeof o?t.pop():o=a,s.reduce(e,t,function(e,t,o){t.apply(n,e.concat([E(function(e,t){o(e,t)})]))},function(e,t){o.apply(n,[e].concat(t))})})},s.compose=function(){return s.seq.apply(null,Array.prototype.reverse.call(arguments))},s.applyEach=H(s.eachOf),s.applyEachSeries=H(s.eachOfSeries),s.forever=function(e,t){var n=h(t||a),o=q(e);!function e(t){if(t)return n(t);o(e)}()},s.ensureAsync=q,s.constant=E(function(e){var t=[null].concat(e);return function(e){return e.apply(this,t)}}),s.wrapSync=s.asyncify=function(e){return E(function(n){var o,i,r,s=n.pop();try{o=e.apply(this,n)}catch(e){return s(e)}("function"===(r=t(i=o))||"object"===r&&i)&&"function"==typeof o.then?o.then(function(e){s(null,e)}).catch(function(e){s(e.message?e:new Error(e))}):s(null,o)})},"object"===t(o)&&o.exports?o.exports=s:"function"==typeof define&&e.amdO?define([],function(){return s}):f.async=s}()}).call(this,n("_process"),void 0!==e.g?e.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:31}],20:[function(n,o,i){var r,s;r=this,s=function(){var e=XMLHttpRequest;if(!e)throw new Error("missing XMLHttpRequest");function n(t,s){if("function"!=typeof s)throw new Error("Bad callback given: "+s);if(!t)throw new Error("No options given");var a=t.onResponse;if((t="string"==typeof t?{uri:t}:JSON.parse(JSON.stringify(t))).onResponse=a,t.verbose&&(n.log=function(){var e,t,n={},o=["trace","debug","info","warn","error"];for(t=0;t<o.length;t++)n[e=o[t]]=i,"undefined"!=typeof console&&console&&console[e]&&(n[e]=r(console,e));return n}()),t.url&&(t.uri=t.url,delete t.url),!t.uri&&""!==t.uri)throw new Error("options.uri is a required argument");if("string"!=typeof t.uri)throw new Error("options.uri must be a string");for(var c=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],u=0;u<c.length;u++)if(t[c[u]])throw new Error("options."+c[u]+" is not supported");if(t.callback=s,t.method=t.method||"GET",t.headers=t.headers||{},t.body=t.body||null,t.timeout=t.timeout||n.DEFAULT_TIMEOUT,t.headers.host)throw new Error("Options.headers.host is not supported");t.json&&(t.headers.accept=t.headers.accept||"application/json","GET"!==t.method&&(t.headers["content-type"]="application/json"),"boolean"!=typeof t.json?t.body=JSON.stringify(t.json):"string"!=typeof t.body&&(t.body=JSON.stringify(t.body)));var l=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(t.qs){var f="string"==typeof t.qs?t.qs:l(t.qs);-1!==t.uri.indexOf("?")?t.uri=t.uri+"&"+f:t.uri=t.uri+"?"+f}if(t.form){if("string"==typeof t.form)throw"form name unsupported";if("POST"===t.method){var h=(t.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(t.headers["content-type"]=h,h){case"application/x-www-form-urlencoded":t.body=l(t.form).replace(/%20/g,"+");break;case"multipart/form-data":var p=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var o in e)e.hasOwnProperty(o)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+o+'"\n\n'+e[o]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t}(t.form);t.body=p.body,t.headers["content-type"]=p.type;break;default:throw new Error("unsupported encoding:"+h)}}}return t.onResponse=t.onResponse||i,!0===t.onResponse&&(t.onResponse=s,t.callback=i),!t.headers.authorization&&t.auth&&(t.headers.authorization="Basic "+function(e){var t,n,o,i,r,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,u="",l=[];if(!e)return e;do{t=(r=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,n=r>>12&63,o=r>>6&63,i=63&r,l[c++]=s.charAt(t)+s.charAt(n)+s.charAt(o)+s.charAt(i)}while(a<e.length);switch(u=l.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(t.auth.username+":"+t.auth.password)),function(t){var i=new e,r=!1,s=function(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(e){(t=document.createElement("a")).href="",t=t.href}var o=n.exec(t.toLowerCase())||[],i=n.exec(e.toLowerCase());return!(!i||i[1]==o[1]&&i[2]==o[2]&&(i[3]||("http:"===i[1]?80:443))==(o[3]||("http:"===o[1]?80:443)))}(t.uri),a="withCredentials"in i;if(o+=1,i.seq_id=o,i.id=o+": "+t.method+" "+t.uri,i._id=i.id,s&&!a){var c=new Error("Browser does not support cross-origin request: "+t.uri);return c.cors="unsupported",t.callback(c,i)}function u(){r=!0;var e=new Error("ETIMEDOUT");return e.code="ETIMEDOUT",e.duration=t.timeout,n.log.error("Timeout",{id:i._id,milliseconds:t.timeout}),t.callback(e,i)}i.timeoutTimer=setTimeout(u,t.timeout);var l={response:!1,loading:!1,end:!1};for(var f in i.onreadystatechange=h,i.open(t.method,t.uri,!0),t.headers)i.setRequestHeader(f,t.headers[f]);return s&&(i.withCredentials=!!t.withCredentials),i.send(t.body),i;function h(t){if(r)return n.log.debug("Ignoring timed out state change",{state:i.readyState,id:i.id});n.log.debug("State change",{state:i.readyState,id:i.id,timed_out:r}),i.readyState===e.OPENED?n.log.debug("Request started",{id:i.id}):i.readyState===e.HEADERS_RECEIVED?p():i.readyState===e.LOADING?(p(),d()):i.readyState===e.DONE&&(p(),d(),m())}function p(){if(!l.response){if(l.response=!0,n.log.debug("Got response",{id:i.id,status:i.status}),clearTimeout(i.timeoutTimer),i.statusCode=i.status,s&&0==i.statusCode){var e=new Error("Request rejected: "+t.uri);return e.cors="rejected",l.loading=!0,l.end=!0,t.callback(e,i)}t.onResponse(null,i)}}function d(){l.loading||(l.loading=!0,n.log.debug("Response body loading",{id:i.id}))}function m(){if(!l.end){if(l.end=!0,n.log.debug("Request done",{id:i.id}),i.body=i.responseText,t.json)try{i.body=JSON.parse(i.responseText)}catch(e){return t.callback(e,i)}t.callback(null,i,i.body)}}}(t)}n.log={trace:i,debug:i,info:i,warn:i,error:i};var o=0;function i(){}function r(e,n){return function(o,i){return"object"===t(i)&&(o+=" "+JSON.stringify(i)),e[n].call(e,o)}}return n.withCredentials=!1,n.DEFAULT_TIMEOUT=12e4,n.defaults=function(e,t){var o=function(t){return function(n,o){for(var i in n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n)),e)void 0===n[i]&&(n[i]=e[i]);return t(n,o)}},i=o(n);return i.get=o(n.get),i.post=o(n.post),i.put=o(n.put),i.head=o(n.head),i},["get","put","post","head"].forEach(function(e){var t=e.toUpperCase();n[e.toLowerCase()]=function(e){"string"==typeof e?e={method:t,uri:e}:(e=JSON.parse(JSON.stringify(e))).method=t;var o=[e].concat(Array.prototype.slice.apply(arguments,[1]));return n.apply(this,o)}}),n.couch=function(e,t){return"string"==typeof e&&(e={uri:e}),e.json=!0,e.body&&(e.json=e.body),delete e.body,t=t||i,n(e,function(e,n,o){if(e)return t(e,n,o);if((n.statusCode<200||n.statusCode>299)&&o.error){for(var i in e=new Error("CouchDB error: "+(o.error.reason||o.error.error)),o)e[i]=o[i];return t(e,n,o)}return t(e,n,o)})},n},"function"==typeof define&&e.amdO||"object"===t(i)?o.exports=s():r.returnExports=s()},{}],21:[function(e,n,o){function i(){var e;try{e=o.storage.debug}catch(e){}return e}(o=n.exports=e("./debug")).log=function(){return"object"===("undefined"==typeof console?"undefined":t(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},o.formatArgs=function(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+o.humanize(this.diff),!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,r=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(r=i))}),e.splice(r,0,n),e},o.save=function(e){try{null==e?o.storage.removeItem("debug"):o.storage.debug=e}catch(e){}},o.load=i,o.useColors=function(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31},o.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),o.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],o.formatters.j=function(e){return JSON.stringify(e)},o.enable(i())},{"./debug":22}],22:[function(e,t,n){n=t.exports=function(e){function t(){}function r(){var e=r,t=+new Date,s=t-(o||t);e.diff=s,e.prev=o,e.curr=t,o=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=n.colors[i++%n.colors.length]);var a=Array.prototype.slice.call(arguments);a[0]=n.coerce(a[0]),"string"!=typeof a[0]&&(a=["%o"].concat(a));var c=0;a[0]=a[0].replace(/%([a-z%])/g,function(t,o){if("%%"===t)return t;c++;var i=n.formatters[o];if("function"==typeof i){var r=a[c];t=i.call(e,r),a.splice(c,1),c--}return t}),"function"==typeof n.formatArgs&&(a=n.formatArgs.apply(e,a)),(r.log||n.log||console.log.bind(console)).apply(e,a)}t.enabled=!1,r.enabled=!0;var s=n.enabled(e)?r:t;return s.namespace=e,s},n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),o=t.length,i=0;i<o;i++)t[i]&&("-"===(e=t[i].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){var t,o;for(t=0,o=n.skips.length;t<o;t++)if(n.skips[t].test(e))return!1;for(t=0,o=n.names.length;t<o;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var o,i=0},{ms:25}],23:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],24:[function(e,n,o){function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}function r(e,t,n){if(null!=e){var o=void 0!==n?t.bind(n):t;if(Array.isArray(e))for(var i=0;i<e.length;i++)o(e[i],i,e);else for(var r=Object.keys(e),s=0;s<r.length;s++)o(e[r[s]],r[s],e)}}function s(e,t){if(null==e)return!1;if(Array.isArray(e))return-1!==e.indexOf(t);if("string"==typeof e)return-1!==e.indexOf(t);for(var n=Object.keys(e),o=0;o<n.length;o++)if(e[n[o]]===t)return!0;return!1}var a={bind:function(e,t){var n=Array.prototype.slice.call(arguments,2);return function(){var o=n.concat(Array.prototype.slice.call(arguments));return e.apply(t,o)}},isFunction:function(e){return"function"==typeof e},isUndefined:function(e){return void 0===e},isString:function(e){return"string"==typeof e},noop:function(){},assign:i,extend:i,has:function(e,t){return null!=e&&Object.prototype.hasOwnProperty.call(e,t)},forEach:r,each:r,includes:s,contains:s,partial:function(e){var t=Array.prototype.slice.call(arguments,1);return function(){var n=t.concat(Array.prototype.slice.call(arguments));return e.apply(this,n)}},cloneDeep:function(e){if("function"==typeof structuredClone)try{return structuredClone(e)}catch(e){}return JSON.parse(JSON.stringify(e))},debounce:function(e,t){var n;return function(){var o=this,i=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(o,i)},t)}},throttle:function(e,t){var n,o=0;return function(){var i=this,r=arguments,s=Date.now(),a=t-(s-o);clearTimeout(n),a<=0?(o=s,e.apply(i,r)):n=setTimeout(function(){o=Date.now(),e.apply(i,r)},a)}},merge:function e(n){for(var o=1;o<arguments.length;o++){var i=arguments[o];if(null!=i)for(var r=Object.keys(i),s=0;s<r.length;s++){var a=r[s],c=i[a];c&&"object"===t(c)&&!Array.isArray(c)?("object"===t(n[a])&&null!==n[a]||(n[a]={}),e(n[a],c)):n[a]=c}}return n}};n.exports=a},{}],25:[function(e,t,n){var o=1e3,i=60*o,r=60*i,s=24*r,a=365.25*s;function c(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){return t=t||{},"string"==typeof e?function(e){if((e=""+e).length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*r;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}(e):t.long?c(n=e,s,"day")||c(n,r,"hour")||c(n,i,"minute")||c(n,o,"second")||n+" ms":function(e){return e>=s?Math.round(e/s)+"d":e>=r?Math.round(e/r)+"h":e>=i?Math.round(e/i)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}(e);var n}},{}],26:[function(e,t,n){t.exports=e("./lib/retry")},{"./lib/retry":27}],27:[function(e,t,n){var o=e("./retry_operation");n.operation=function(e){var t=!1;e&&!0===e.forever&&(t=!0);var i=n.timeouts(e);return new o(i,t)},n.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return o.sort(function(e,t){return e-t}),o},n.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},n.wrap=function(e,t,o){if(t instanceof Array&&(o=t,t=null),!o)for(var i in o=[],e)"function"==typeof e[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],a=e[s];e[s]=function(){var o=n.operation(t),i=Array.prototype.slice.call(arguments),r=i.pop();i.push(function(e){o.retry(e)||(e&&(arguments[0]=o.mainError()),r.apply(this,arguments))}),o.attempt(function(){a.apply(e,i)})},e[s].options=t}}},{"./retry_operation":28}],28:[function(e,t,n){function o(e,t){this._timeouts=e,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,t&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=o,o.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;this._errors.push(e);var t=this._timeouts.shift();if(void 0===t){if(!this._cachedTimeouts)return!1;this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),t=this._timeouts.shift()}var n=this;return setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout)),n._fn(n._attempts)},t),!0},o.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._fn(this._attempts)},o.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},o.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},o.prototype.start=o.prototype.try,o.prototype.errors=function(){return this._errors},o.prototype.attempts=function(){return this._attempts},o.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t}},{}],29:[function(e,t,n){t.exports=function(){var e=[].slice.call(arguments,0).join("/");return e.replace(/[\/]+/g,"/").replace(/\/\?/g,"?").replace(/\/\#/g,"#").replace(/\:\//g,"://")}},{}],30:[function(e,n,o){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"object"===t(e)&&null!==e}function a(e){return void 0===e}n.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.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},i.prototype.emit=function(e){var t,n,o,i,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(a(n=this._events[e]))return!1;if(r(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:i=Array.prototype.slice.call(arguments,1),n.apply(this,i)}else if(s(n))for(i=Array.prototype.slice.call(arguments,1),o=(u=n.slice()).length,c=0;c<o;c++)u[c].apply(this,i);return!0},i.prototype.addListener=function(e,t){var n;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(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},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){if(!r(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},i.prototype.removeListener=function(e,t){var n,o,i,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=(n=this._events[e]).length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=a;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],31:[function(e,t,n){var o,i=t.exports={},r=[],s=!1,a=-1;function c(){s=!1,o.length?r=o.concat(r):a=-1,r.length&&u()}function u(){if(!s){var e=setTimeout(c);s=!0;for(var t=r.length;t;){for(o=r,r=[];++a<t;)o&&o[a].run();a=-1,t=r.length}o=null,s=!1,clearTimeout(e)}}function l(e,t){this.fun=e,this.array=t}function f(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];r.push(new l(e,t)),1!==r.length||s||setTimeout(u,0)},l.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=f,i.addListener=f,i.once=f,i.off=f,i.removeListener=f,i.removeAllListeners=f,i.emit=f,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}]},{},[]),o=function(){return n("/KoreBot.js").instance()};export{o as createBotInstance};
|
|
1
|
+
var e={};function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}e.amdO={},e.d=(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n=function e(t,n,o){function i(s,a){if(!n[s]){if(!t[s]){if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return i(n||e)},u,u.exports,e,t,n,o)}return n[s].exports}for(var r=void 0,s=0;s<o.length;s++)i(o[s]);return i}({"/KoreBot.js":[function(e,t,n){var o,r=e("./index.js"),s=e("events"),a=e("inherits"),c=e(15),u=(o=e("lodash").bind?e("lodash"):_).bind,l=o.isFunction,f=r.CLIENT_EVENTS.RTM,h=r.RTM_EVENTS,p=r.CLIENT_EVENTS.WEB,d=e("./jstz.js"),m=o.noop;"undefined"!=typeof window&&(window.kore=window.kore||{},window.kore.botsdk=window.kore.botsdk||{},window.kore.botsdk.logger=window.kore.botsdk.logger||e("debug"),window.messageHistoryLimit=10);var g=e("debug")("botsdk:KoreBot");function y(){s.call(this),this.WebClient=null,this.RtmClient=null,this.options={},this.accessToken=null,this.initialized=!1,this.clients=r,this.latestId=null,this.oldestId=null,this.EventEmitter=s,this.lodash=o,this.bind=u,this.isFunction=l,this.RTM_EVENTS=h,this.RTM_CLIENT_EVENTS=f,this.jstz=d,this.noop=m,this.debug=g,this.userLocation=v,this.historyOffset=0,this.previousHistoryLoading=!1,this.paginatedScrollDataAvailable=!0,this._chatHistoryLoaded=!1}var v={city:"",country:"",latitude:0,longitude:0,street:""};a(y,s),y.prototype.emit=function(){arguments&&"history"===arguments[0]&&this.historySyncInProgress?(this.historySyncInProgress=!1,arguments[2]="historysync",this.cbBotChatHistory(arguments)):!window._chatHistoryLoaded&&arguments&&"history"===arguments[0]&&(this._chatHistoryLoaded=!0,this.cbBotChatHistory(arguments)),this.EventEmitter.prototype.emit.apply(this,arguments)},y.prototype.fetchUserLocation=function(){if(""===v.country){var e=this.options;navigator.geolocation.getCurrentPosition(function(t){if(e.googleMapsAPIKey){var n=t.coords.latitude,o=t.coords.longitude;v.latitude=n,v.longitude=o;var r=new XMLHttpRequest,s="https://maps.googleapis.com/maps/api/geocode/json?latlng="+n+","+o+"&sensor=true&key="+e.googleMapsAPIKey;r.open("GET",s,!0),r.onreadystatechange=function(){if(4==r.readyState&&200==r.status){var e=JSON.parse(r.responseText);"undefined"!=typeof Storage&&(0==e.results.length?e=JSON.parse(localStorage.getItem("locationData")):localStorage.setItem("locationData",JSON.stringify(e)));var t=[];for(e.results&&e.results.length&&e.results[0].address_components&&(t=e.results[0].address_components),i=0;i<t.length;i++){var n=t[i].types;"locality,political"==n?v.city=t[i].long_name:"country,political"==n?v.country=t[i].long_name:"political,sublocality,sublocality_level_2"==n&&(v.street=t[i].long_name)}}},r.send()}else console.warn("please provide google maps API key")})}},y.prototype.sendMessage=function(e,t){if(g("sending message to bot"),this.initialized)if(e.resourceid=e.resourceid||"/bot.message",e.botInfo=this.options.botInfo||{},e.client=this.options.client||"sdk",e.meta={timezone:d.jstz.determine().name(),locale:window.navigator.userLanguage||window.navigator.language},0!==v.latitude&&0!==v.longitude&&(e.meta.location=v),this.emit("beforeWSSendMessage",e),this.RtmClient)this.RtmClient.sendMessage(e,t);else{t&&t(new Error("ws not connected or reconnecting, unable to send message"))}else t&&t(new Error("Bot is Initializing...Please try again"))},y.prototype.sendMessageViaWebhook=function(e,t,n){var o=this.WebClient,i=this;e.opts={authorization:"bearer "+this.options.webhookConfig.token},o.makeAPICall(this.options.webhookConfig.webhookURL,e,function(e,o){e?n(o):(o.pollId&&i.startPollForWebhookResponse(o.pollId,t),t(i.convertWebhookResposeToMessages(o)))})},y.prototype.getBotMetaData=function(e,t){var n=this.WebClient,o=this,i={};i.opts={authorization:"bearer "+this.options.webhookConfig.token,type:"GET"},n.makeAPICall("botmeta/"+o.options.botInfo.taskBotId,i,function(n,i){n?t(i):(o.options.botInfo.icon=i.icon,e(i))})},y.prototype.convertWebhookResposeToMessages=function(e){var t,n=e.text,o=[],i=this.options.botInfo.icon;function r(e){try{e=JSON.parse(e)}catch(t){return e}return e}if("v2"===e._v&&(n=e.data),n instanceof Array)console.log("it is array"),n.forEach(function(e,n){var s=(new Date).getTime()+n,a=r(e.val||e);t={type:"bot_response",messageId:e.messageId||s,icon:i,createdOn:e.createdOn,message:[{type:"text",cInfo:{body:e.val||e,attachments:""},component:{}}]},a.payload?(t.message[0].component.payload=a.payload,t.message[0].component.type=a.type):a.text?(t.message[0].component.payload={text:a.text},t.message[0].component.type="template"):(t.message[0].component.payload={text:a},t.message[0].component.type="text"),t.message[0].component&&t.message[0].component.payload&&t.message[0].component.payload.text&&(t.message[0].cInfo.body=t.message[0].component.payload.text),t.message[0].component&&t.message[0].component.payload&&(t.message[0].component.payload.videoUrl||t.message[0].component.payload.audioUrl)&&(t.message[0].cInfo.body=t.message[0].component.payload.text||""),o.push(t)});else{console.log("its Object");var s=(new Date).getTime();t={type:"bot_response",messageId:entry.messageId||s,createdOn:entry.createdOn,icon:i,message:[{type:"text",cInfo:{body:r(n),attachments:""},component:r(n)}]},o.push(t)}return o},y.prototype.startPollForWebhookResponse=function(e,t){var n=this,o=n.options.koreAPIUrl,i=(o=o.substring(0,o.length-5))+"/chatbot/v2/webhook/"+n.options.webhookConfig.streamId+"/poll/"+e,r=this.WebClient,s={};s.opts={authorization:"bearer "+this.options.webhookConfig.token,type:"GET"},r.makeAPICall(i,s,function(e,o){e||(o.pollId&&setTimeout(function(){n.startPollForWebhookResponse(o.pollId,t)},1e3),o.data&&t(n.convertWebhookResposeToMessages(o)))})},y.prototype.onMessage=function(e){g("on message from bot/self"),"bot"===e.from&&"bot_response"===e.type&&(this.latestId=e.messageId||this.latestId,this.oldestId=this.oldestId||e.messageId),this.sendAck(e),this.emit(h.MESSAGE,e)},y.prototype.sendAck=function(e){var t,n;if(null!==(t=this.options)&&void 0!==t&&null!==(t=t.enableAck)&&void 0!==t&&t.delivery&&(e.data&&"bot_response"==(null===(n=JSON.parse(e.data))||void 0===n?void 0:n.type))){var o,i={};i.clientMessageId=JSON.parse(e.data).timestamp,i.type="ack",i.replyto=JSON.parse(e.data).timestamp,i.status="delivered",i.key=null===(o=JSON.parse(e.data))||void 0===o?void 0:o.key,this.RtmClient.sendMessage(i,function(e){console.log("Error occurred in sending ack: ",e)})}},y.prototype.close=function(){g("request to close ws connection"),this.RtmClient&&this.RtmClient._close()},y.prototype.destroy=function(){this.RtmClient&&this.RtmClient._close(),this._chatHistoryLoaded=!1,this.removeAllListeners()},y.prototype.onForwardHistory=function(e,t){g("on forward history");var n,o={};if(o.moreAvailable=t.moreAvailable,this.paginatedScrollDataAvailable=t.moreAvailable,o.messages=[],o.forward=!0,o.afterMessageId=this.latestId,t.messages&&t.messages.length>0)for(n=0;n<t.messages.length;n++){var i,r,s,a,c,u={};if(u.messageId=t.messages[n]._id,this.oldestId=this.oldestId||t.messages[n]._id,this.latestId=t.messages[n]._id||this.latestId,"incoming"===t.messages[n].type)u.from="self",u.type="user_message",u.messageId=(null===(c=t.messages[n])||void 0===c?void 0:c.userMsgId)||u.messageId;else u.from="bot",u.type="bot_response";var l,f=0;if(t.messages[n].components&&t.messages[n].components.length>0)for(u.message=[],f=0;f<t.messages[n].components.length;f++){var h,p={};if(p.type=t.messages[n].components[f].cT,"text"===p.type)if(p.cInfo={},p.cInfo.body=t.messages[n].components[f].data&&t.messages[n].components[f].data.text,t.messages[n].tags&&t.messages[n].tags.altText&&t.messages[n].tags.altText.length>0)p.cInfo.body=(null===(h=t.messages[n].tags.altText[0])||void 0===h?void 0:h.value)||p.cInfo.body;u.message[f]=p}if(null!==(i=this.options)&&void 0!==i&&null!==(i=i.attachments)&&void 0!==i&&null!==(i=i.history)&&void 0!==i&&i.showUserUploadedFiles&&"incoming"===t.messages[n].type){var d,m,y,v=null===(d=t.messages[n].channels)||void 0===d||null===(d=d[0])||void 0===d?void 0:d.attachments;null!==(m=v)&&void 0!==m&&m.length&&null!==(y=u.message)&&void 0!==y&&y[0]&&(u.type="currentUser",u.message[0].cInfo=u.message[0].cInfo||{body:""},u.message[0].cInfo.attachments=v)}if(u.createdOn=t.messages[n].createdOn,null!==(r=t.messages[n])&&void 0!==r&&r.author){var b,_,w,A;if(u.author={},null!==(b=t.messages[n])&&void 0!==b&&null!==(b=b.author)&&void 0!==b&&b.firstName)u.author.firstName=null===(w=t.messages[n])||void 0===w||null===(w=w.author)||void 0===w?void 0:w.firstName;if(null!==(_=t.messages[n])&&void 0!==_&&null!==(_=_.author)&&void 0!==_&&_.lastName)u.author.lastName=null===(A=t.messages[n])||void 0===A||null===(A=A.author)||void 0===A?void 0:A.lastName}if(null!==(s=t.messages[n])&&void 0!==s&&s.lang)u.botLanguage=null===(l=t.messages[n])||void 0===l?void 0:l.lang;null!==(a=t.messages[n])&&void 0!==a&&a.sessionId&&(u.sessionId=t.messages[n].sessionId),o.messages[n]=u}this.emit("history",o)},y.prototype.onBackWardHistory=function(e,t){g("on backword history");var n,o={};if(o.moreAvailable=null==t?void 0:t.moreAvailable,this.paginatedScrollDataAvailable=null==t?void 0:t.moreAvailable,o.messages=[],o.backward=!0,o.beforeMessageId=this.oldestId,null!=t&&t.messages&&t.messages.length>0)for(n=0;n<t.messages.length;n++){var i,r,s,a,c,u={};if(u.messageId=t.messages[n]._id,this.oldestId=t.messages[n]._id||this.oldestId,this.latestId=this.latestId||t.messages[n]._id,"incoming"===t.messages[n].type)u.from="self",u.type="user_message",u.messageId=(null===(c=t.messages[n])||void 0===c?void 0:c.userMsgId)||u.messageId;else u.from="bot",u.type="bot_response",u.icon=t.icon;var l,f,h,p=0;if(t.messages[n].components&&t.messages[n].components.length>0)for(u.message=[],p=0;p<t.messages[n].components.length;p++){var d,m={};if(m.type=t.messages[n].components[p].cT,"text"===m.type)if(m.cInfo={},m.cInfo.body=t.messages[n].components[p].data&&t.messages[n].components[p].data.text,t.messages[n].tags&&t.messages[n].tags.altText&&t.messages[n].tags.altText.length>0)m.cInfo.body=(null===(d=t.messages[n].tags.altText[0])||void 0===d?void 0:d.value)||m.cInfo.body;u.message[p]=m}if(null!==(i=this.options)&&void 0!==i&&null!==(i=i.attachments)&&void 0!==i&&null!==(i=i.history)&&void 0!==i&&i.showUserUploadedFiles&&"incoming"===t.messages[n].type){var y,v,b,_=null===(y=t.messages[n].channels)||void 0===y||null===(y=y[0])||void 0===y?void 0:y.attachments;null!==(v=_)&&void 0!==v&&v.length&&null!==(b=u.message)&&void 0!==b&&b[0]&&(u.type="currentUser",u.message[0].cInfo=u.message[0].cInfo||{body:""},u.message[0].cInfo.attachments=_)}if(u.createdOn=t.messages[n].createdOn,null!==(r=t.messages[n])&&void 0!==r&&r.author)u.author={},u.author.firstName=null===(l=t.messages[n])||void 0===l||null===(l=l.author)||void 0===l?void 0:l.firstName,u.author.lastName=null===(f=t.messages[n])||void 0===f||null===(f=f.author)||void 0===f?void 0:f.lastName;if(null!==(s=t.messages[n])&&void 0!==s&&s.lang)u.botLanguage=null===(h=t.messages[n])||void 0===h?void 0:h.lang;null!==(a=t.messages[n])&&void 0!==a&&a.sessionId&&(u.sessionId=t.messages[n].sessionId),o.messages[n]=u}this.emit("history",o)},y.prototype.getHistory=function(e,t){g("get history"),e=e||{},"undefined"!=typeof window&&(e.limit=e.limit||window.messageHistoryLimit||10);var n={};n.forward=e.forward,n.limit=e.limit||10,e.forHistorySync?n.offset=0:(n.offset=this.historyOffset,this.historyOffset=this.historyOffset+(e.limit?e.limit:10)),n.forward?this.latestId&&(n.msgId=this.latestId):this.previousHistoryLoading||this.oldestId&&(n.msgId=this.oldestId),n.botInfo=this.options.botInfo,n.authorization="bearer "+this.WebClient.user.accessToken,t&&t.webhookConfig&&t.webhookConfig.enable&&(n.authorization="bearer "+this.options.webhookConfig.token),e.forHistorySync&&(this.historySyncInProgress=!0,delete n.msgId),n.forward?this.WebClient.history.history(n,u(this.onForwardHistory,this),t):this.WebClient.history.history(n,u(this.onBackWardHistory,this),t)},y.prototype.sync=function(e){},y.prototype.onOpenWSConnection=function(e){g("opened WS Connection"),this.initialized=!0,this.options.loadHistory&&!this._chatHistoryLoaded&&this.getHistory({limit:this.options.messageHistoryLimit}),this.emit(f.RTM_CONNECTION_OPENED,{})},y.prototype.onLogIn=function(e,t){var n=this;g("sign-in/anonymous user onLogin"),e?this.cbErrorToClient&&(t&&t.errors&&t.errors[0]&&t.errors[0].msg?this.cbErrorToClient(t.errors[0].msg):this.cbErrorToClient(e.message)):(this.accessToken=t.authorization.accessToken,this.options.accessToken=this.accessToken,this.WebClient.user.accessToken=this.accessToken,this.userInfo=t,this.cbBotDetails(t,this.options.botInfo),this.RtmClient=new r.KoreRtmClient({},this.options),this.RtmClient.on(p.API_FAILURE,function(e){n.emit(p.API_FAILURE,e)}),this.RtmClient.on("reconnect_event",function(e){n.emit("reconnected",e)}),this.RtmClient.on("before_ws_con",function(e){n.emit("before_ws_connection",e)}),this.emit("rtm_client_initialized"),this.emit(p.JWT_GRANT_SUCCESS,{jwtgrantsuccess:t}),(this.options.openSocket||this.options.autoConnect||"v2"==this.options.botInfo.uiVersion)&&this.logInComplete())},y.prototype.logInComplete=function(){if(this.RtmClient){this.RtmClient.start({botInfo:this.options.botInfo}),0===this.RtmClient.listenerCount(h.MESSAGE)&&this.RtmClient.on(h.MESSAGE,u(this.onMessage,this)),0===this.RtmClient.listenerCount(f.RTM_CONNECTION_OPENED)&&this.RtmClient.on(f.RTM_CONNECTION_OPENED,u(this.onOpenWSConnection,this));var e=this;Object.keys(f).forEach(function(t){0===e.RtmClient.listenerCount(f[t])&&e.RtmClient.on(f[t],function(n){e.emit("rtm:"+f[t],n)})})}},y.prototype.logIn=function(e,t){var n=this;e?(g("error in assertionFn %s",e),console.error("error in assertionFn",e&&e.stack)):(g("signed-in user login"),this.options=t,this.claims=t.assertion,this.WebClient=new r.KoreWebClient({},this.options),this.WebClient.claims=this.claims,this.cbErrorToClient=t.handleError||m,this.cbBotDetails=t.botDetails||m,this.cbBotChatHistory=t.chatHistory||m,this.WebClient.on(p.API_FAILURE,function(e){n.emit(p.API_FAILURE,e)}),this.options.webhookConfig&&this.options.webhookConfig.enable?(this.options.webhookConfig.token=this.options.assertion,this.emit(p.WEB_HOOK_READY),this.options.loadHistory&&!this._chatHistoryLoaded?this.getHistory({limit:this.options.messageHistoryLimit},t):this.emit(p.WEB_HOOK_RECONNECTED)):this.WebClient.login.login({assertion:t.assertion,botInfo:this.options.botInfo},u(this.onLogIn,this)))},y.prototype.init=function(e,t){(t=t||10)>100&&(t=100),"undefined"!=typeof window&&(window.messageHistoryLimit=t||10),e=e||{},this.options=e,this.oldestId=null,this.RtmClient=null,e.test?(g("test is true"),l(e.koreAnonymousFn)?e.koreAnonymousFn.call(this,e):(g("koreAnonymousFn is not a function"),console.error("koreAnonymousFn is not a function"))):(g("test is false"),l(e.assertionFn)?e.assertionFn(e,u(this.logIn,this)):(g("assertion is not a function"),console.error("assertion is not a function"))),e.loadHistory?this.paginatedScrollDataAvailable=!0:this.paginatedScrollDataAvailable=!1,this.reWriteWebhookConfig(e)},y.prototype.reWriteWebhookConfig=function(e){if(e&&e.webhookConfig&&e.webhookConfig.enable){var t=e.botInfo.taskBotId,n="ivr",o=e.webhookConfig.webhookURL,i="hookInstance/";o.indexOf(i)>-1&&(n=o.substring(o.indexOf(i)+13,o.length)),e.webhookConfig.streamId=t,e.webhookConfig.channelType=n}},t.exports.instance=function(){var e=new y;return e.KoreBot=y,e.KoreRTMClient=r.KoreRtmClient,Object.keys(c).forEach(function(t){e[t]=c[t]}),e}},{"./index.js":1,"./jstz.js":2,debug:21,events:30,inherits:23,lodash:24}],1:[function(e,t,n){var o=e("./lib/clients/events");t.exports={KoreWebClient:e("./lib/clients/web/client"),KoreRtmClient:e("./lib/clients/rtm/client"),CLIENT_EVENTS:{WEB:o.CLIENT_EVENTS.WEB,RTM:o.CLIENT_EVENTS.RTM},RTM_EVENTS:o.RTM_EVENTS,RTM_MESSAGE_SUBTYPES:o.RTM_MESSAGE_SUBTYPES}},{"./lib/clients/events":5,"./lib/clients/rtm/client":9,"./lib/clients/web/client":18}],2:[function(e,t,n){var o,i,r,s,a,c;o=this,i=function(e){var t=-e.getTimezoneOffset();return null!==t?t:0},r=function(e,t,n){var o=new Date;return void 0!==e&&o.setFullYear(e),o.setDate(n),o.setMonth(t),o},s=function(e){return i(r(e,0,2))},a=function(e){return i(r(e,5,2))},(c={determine:function(){var e,t,n,o=(e=s(),t=a(),(n=s()-a())<0?e+",1":n>0?t+",1,s":e+",0");return new c.TimeZone(c.olson.timezones[o])},date_is_dst:function(e){return(e.getMonth()>7?a(e.getFullYear()):s(e.getFullYear()))-i(e)!==0},dst_start_for:function(e){var t=new Date(2010,6,15,1,0,0,0);return{"America/Denver":new Date(2011,2,13,3,0,0,0),"America/Mazatlan":new Date(2011,3,3,3,0,0,0),"America/Chicago":new Date(2011,2,13,3,0,0,0),"America/Mexico_City":new Date(2011,3,3,3,0,0,0),"America/Asuncion":new Date(2012,9,7,3,0,0,0),"America/Santiago":new Date(2012,9,3,3,0,0,0),"America/Campo_Grande":new Date(2012,9,21,5,0,0,0),"America/Montevideo":new Date(2011,9,2,3,0,0,0),"America/Sao_Paulo":new Date(2011,9,16,5,0,0,0),"America/Los_Angeles":new Date(2011,2,13,8,0,0,0),"America/Santa_Isabel":new Date(2011,3,5,8,0,0,0),"America/Havana":new Date(2012,2,10,2,0,0,0),"America/New_York":new Date(2012,2,10,7,0,0,0),"Asia/Beirut":new Date(2011,2,27,1,0,0,0),"Europe/Helsinki":new Date(2011,2,27,4,0,0,0),"Europe/Istanbul":new Date(2011,2,28,5,0,0,0),"Asia/Damascus":new Date(2011,3,1,2,0,0,0),"Asia/Jerusalem":new Date(2011,3,1,6,0,0,0),"Asia/Gaza":new Date(2009,2,28,0,30,0,0),"Africa/Cairo":new Date(2009,3,25,0,30,0,0),"Pacific/Auckland":new Date(2011,8,26,7,0,0,0),"Pacific/Fiji":new Date(2010,11,29,23,0,0,0),"America/Halifax":new Date(2011,2,13,6,0,0,0),"America/Goose_Bay":new Date(2011,2,13,2,1,0,0),"America/Miquelon":new Date(2011,2,13,5,0,0,0),"America/Godthab":new Date(2011,2,27,1,0,0,0),"Europe/Moscow":t,"Asia/Yekaterinburg":t,"Asia/Omsk":t,"Asia/Krasnoyarsk":t,"Asia/Irkutsk":t,"Asia/Yakutsk":t,"Asia/Vladivostok":t,"Asia/Kamchatka":t,"Europe/Minsk":t,"Australia/Perth":new Date(2008,10,1,1,0,0,0)}[e]}}).TimeZone=function(e){var t={"America/Denver":["America/Denver","America/Mazatlan"],"America/Chicago":["America/Chicago","America/Mexico_City"],"America/Santiago":["America/Santiago","America/Asuncion","America/Campo_Grande"],"America/Montevideo":["America/Montevideo","America/Sao_Paulo"],"Asia/Beirut":["Asia/Beirut","Europe/Helsinki","Europe/Istanbul","Asia/Damascus","Asia/Jerusalem","Asia/Gaza"],"Pacific/Auckland":["Pacific/Auckland","Pacific/Fiji"],"America/Los_Angeles":["America/Los_Angeles","America/Santa_Isabel"],"America/New_York":["America/Havana","America/New_York"],"America/Halifax":["America/Goose_Bay","America/Halifax"],"America/Godthab":["America/Miquelon","America/Godthab"],"Asia/Dubai":["Europe/Moscow"],"Asia/Dhaka":["Asia/Yekaterinburg"],"Asia/Jakarta":["Asia/Omsk"],"Asia/Shanghai":["Asia/Krasnoyarsk","Australia/Perth"],"Asia/Tokyo":["Asia/Irkutsk"],"Australia/Brisbane":["Asia/Yakutsk"],"Pacific/Noumea":["Asia/Vladivostok"],"Pacific/Tarawa":["Asia/Kamchatka"],"Africa/Johannesburg":["Asia/Gaza","Africa/Cairo"],"Asia/Baghdad":["Europe/Minsk"]},n=e;return void 0!==t[n]&&function(){for(var e=t[n],o=e.length,i=0,r=e[0];i<o;i+=1)if(r=e[i],c.date_is_dst(c.dst_start_for(r)))return void(n=r)}(),{name:function(){return n}}},c.olson={},c.olson.timezones={"-720,0":"Etc/GMT+12","-660,0":"Pacific/Pago_Pago","-600,1":"America/Adak","-600,0":"Pacific/Honolulu","-570,0":"Pacific/Marquesas","-540,0":"Pacific/Gambier","-540,1":"America/Anchorage","-480,1":"America/Los_Angeles","-480,0":"Pacific/Pitcairn","-420,0":"America/Phoenix","-420,1":"America/Denver","-360,0":"America/Guatemala","-360,1":"America/Chicago","-360,1,s":"Pacific/Easter","-300,0":"America/Bogota","-300,1":"America/New_York","-270,0":"America/Caracas","-240,1":"America/Halifax","-240,0":"America/Santo_Domingo","-240,1,s":"America/Santiago","-210,1":"America/St_Johns","-180,1":"America/Godthab","-180,0":"America/Argentina/Buenos_Aires","-180,1,s":"America/Montevideo","-120,0":"Etc/GMT+2","-120,1":"Etc/GMT+2","-60,1":"Atlantic/Azores","-60,0":"Atlantic/Cape_Verde","0,0":"Etc/UTC","0,1":"Europe/London","60,1":"Europe/Berlin","60,0":"Africa/Lagos","60,1,s":"Africa/Windhoek","120,1":"Asia/Beirut","120,0":"Africa/Johannesburg","180,0":"Asia/Baghdad","180,1":"Europe/Moscow","210,1":"Asia/Tehran","240,0":"Asia/Dubai","240,1":"Asia/Baku","270,0":"Asia/Kabul","300,1":"Asia/Yekaterinburg","300,0":"Asia/Karachi","330,0":"Asia/Kolkata","345,0":"Asia/Kathmandu","360,0":"Asia/Dhaka","360,1":"Asia/Omsk","390,0":"Asia/Rangoon","420,1":"Asia/Krasnoyarsk","420,0":"Asia/Jakarta","480,0":"Asia/Shanghai","480,1":"Asia/Irkutsk","525,0":"Australia/Eucla","525,1,s":"Australia/Eucla","540,1":"Asia/Yakutsk","540,0":"Asia/Tokyo","570,0":"Australia/Darwin","570,1,s":"Australia/Adelaide","600,0":"Australia/Brisbane","600,1":"Asia/Vladivostok","600,1,s":"Australia/Sydney","630,1,s":"Australia/Lord_Howe","660,1":"Asia/Kamchatka","660,0":"Pacific/Noumea","690,0":"Pacific/Norfolk","720,1,s":"Pacific/Auckland","720,0":"Pacific/Tarawa","765,1,s":"Pacific/Chatham","780,0":"Pacific/Tongatapu","780,1,s":"Pacific/Apia","840,0":"Pacific/Kiritimati"},void 0!==n?n.jstz=c:o.jstz=c},{}],3:[function(e,t,n){var o=e("events"),i=e("async"),r=(e("lodash").bind?e("lodash"):_).bind,s=e("inherits"),a=e("retry"),c=e("url-join"),u=e("./events/client").WEB,l=e("./helpers"),f=e("./transports/request").requestTransport;function h(e,t){o.call(this),this._token=e,this.koreAPIUrl=t.koreAPIUrl||"https://app.kore.com/api/",this.reWriteSocketURL=t.reWriteSocketURL,this.transport=t.transport||f,this.userAgent,this._requestQueue=i.priorityQueue(r(this._callTransport,this),t.maxRequestConcurrency),this._createFacets()}s(h,o),h.prototype.emit=function(){h.super_.prototype.emit.apply(this,arguments)},h.prototype._createFacets=function(){},h.prototype._callTransport=function(e,t){var n=e.args,o=e.cb,i=this,r=a.operation(this.retryConfig);i._activeRetryOp=r;var s=function e(s,a,c,l){if(i._currentRequest=null,i._activeRetryOp===r){var f,h;if(s){if(r.retry(s)){var p,d;if(s)p={msg:s.message||"An unkown error occurred",code:0};else p=(null==l||null===(d=l.errors)||void 0===d?void 0:d[0])||(null==l?void 0:l.errors)||l;return void i.emit("api_failure",{type:"XHRObj",responseError:p,request:n})}i._activeRetryOp=null,o(r.mainError(),null)}if(200!==c)if(429===c)i._requestQueue.pause(),f=parseInt(a["Retry-After"],10),setTimeout(function(){i.transport(n,e),i._requestQueue.resume()},1e3*f),i.emit(u.RATE_LIMITED,f);else{var m,g;if(s)m={msg:s.message||"An unknown error occurred",code:0};else m=(null==l||null===(g=l.errors)||void 0===g?void 0:g[0])||(null==l?void 0:l.errors)||l;if(i.emit("api_failure",{type:"XHRObj",responseError:m,request:n}),h=new Error("Unable to process request, received bad "+c+" error"),401!==c){if(r.retry(h))return void o(h,l);o(h,l)}else o(h,l)}else i._activeRetryOp=null,o(null,l);t()}};r.attempt(function(){i._activeRetryOp===r&&(i._currentRequest=i.transport(n,s))})},h.prototype.makeAPICall=function(e,t,n){var o=l.getAPICallArgs(this._token,t,n),i={url:/^((http|https):\/\/)/.test(e)?e:c(this.koreAPIUrl,e),data:o.data,headers:{"User-Agent":this.userAgent,"content-type":"application/json"}};t&&t.opts&&t.opts.authorization&&(i.headers.Authorization=t.opts.authorization,delete i.data.authorization),t&&t.opts&&t.opts["x-rtm-v"]&&(i.headers["x-rtm-v"]=t.opts["x-rtm-v"],delete i.data["x-rtm-v"]),this._requestQueue.push({args:i,cb:o.cb})},t.exports=h},{"./events/client":4,"./helpers":8,"./transports/request":10,async:19,events:30,inherits:23,lodash:24,retry:26,"url-join":29}],4:[function(e,t,n){t.exports.WEB={RATE_LIMITED:"rate_limited",WEB_HOOK_READY:"webhook_ready",WEB_HOOK_RECONNECTED:"webhook_reconnected",JWT_GRANT_SUCCESS:"jwtgrantsuccess",API_FAILURE:"api_failure"},t.exports.RTM={CONNECTING:"connecting",AUTHENTICATED:"authenticated",WS_OPENING:"ws_opening",WS_OPENED:"ws_opened",RTM_CONNECTION_OPENED:"open",DISCONNECT:"disconnect",UNABLE_TO_RTM_START:"unable_to_rtm_start",WS_CLOSE:"ws_close",WS_ERROR:"ws_error",ATTEMPTING_RECONNECT:"attempting_reconnect",RAW_MESSAGE:"raw_message"}},{}],5:[function(e,t,n){t.exports={CLIENT_EVENTS:{WEB:e("./client").WEB,RTM:e("./client").RTM},RTM_EVENTS:e("./rtm").EVENTS,RTM_MESSAGE_SUBTYPES:e("./rtm").MESSAGE_SUBTYPES}},{"./client":4,"./rtm":6}],6:[function(e,t,n){t.exports.EVENTS={HELLO:"hello",MESSAGE:"message"},t.exports.MESSAGE_SUBTYPES={BOT_MESSAGE:"bot_message",ME_MESSAGE:"me_message"}},{}],7:[function(e,t,n){var o=e("./rtm").EVENTS;t.exports.makeMessageEventWithSubtype=function(e,t){return[o.MESSAGE,e].join(t||"::")}},{"./rtm":6}],8:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).assign,r=o.isFunction,s=o.isUndefined,a=o.isString,c=o.forEach,u=function(e,t){var n=i({},e&&e.opts||{});return c(e||{},function(e,t){s(e)||null===e||"opts"===t||("attachments"===t?a(e)?n[t]=e:n[t]=JSON.stringify(e):n[t]=e)}),t&&(n.token=t),n};t.exports.getData=u,t.exports.getAPICallArgs=function(e,t,n){var o,i;return 1===arguments.length?(i=noop,o=u({},e)):2===arguments.length?r(arguments[1])?(i=arguments[1],o=u({},e)):(i=noop,o=u(t,e)):3===arguments.length&&(i=n||noop,o=u(t,e)),{cb:i,data:o}}},{lodash:24}],9:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).bind,r=o.cloneDeep,s=o.contains,a=e("inherits"),c=o.isUndefined,u=e("debug")("botsdk:KoreRTMClient"),l=e("../events/rtm").EVENTS,f=["pong",l.HELLO],h=["not_authed","invalid_auth","account_inactive","token_expired"],p=e("../events/client").RTM,d=e("../client"),m=e("../web/apis").RtmApi,g=e("../events/utils").makeMessageEventWithSubtype,y=e("../transports/ws");p=e(4);function v(e,t){var n=t||{};n.maxRequestConcurrency=1,d.call(this,e,n),this._socketFn=n.socketFn||y,this.ws=void 0,this.RECONNECTION_BACKOFF=n.reconnectionBackoff||3e3,this.MAX_PONG_INTERVAL=n.maxPongInterval||1e4,this.WS_PING_INTERVAL=n.wsPingInterval||5e3,this.cbResetWindow=n.resetWindow||noop,this.autoReconnect=!1!==n.autoReconnect,this.connected=!1,this.authenticated=!1,this.activeUserId=void 0,this._pendingMessages={},this._connAttempts=0,this._connecting=!1,this._reconnecting=n.maintainContext||!1,n.forceReconnecting&&(this._reconnecting=!0,n.forceReconnecting=!1),n.hasOwnProperty("_reconnecting")&&n._reconnecting&&(this._reconnecting=n._reconnecting,n._reconnecting=!1),this.user={},this.user.accessToken=n.accessToken,this.assertion=null==n?void 0:n.assertion,this.botInfo=n.botInfo||{},this.CLIENT_EVENTS=p.RTM,this.$=n.$,this.debug=u,this.socketConfig=(null==n?void 0:n.webSocketConfig)||{},this.retryConfig=n.retryConfig||{retries:n.maxReconnectionAPIAttempts||5,factor:2},this.enableSecureRTM=!1!==n.enableSecureRTM,this.secureChannel=null;var o=n.secureChannel;if(o&&o.pinnedPublicKeyPem&&"function"==typeof n.secureChannelFactory){var i=this;this.secureChannel=n.secureChannelFactory({config:{pinnedPublicKeyPem:o.pinnedPublicKeyPem,expectedSigningKeyId:o.expectedSigningKeyId},rawSend:function(e){return i.rawSend(e)}})}}a(v,d),v.prototype._createFacets=function(){v.super_.prototype._createFacets.call(this),this._rtm=new m(this)},v.prototype.start=function(e){this._connecting||(this.emit(p.CONNECTING),this._connecting=!0,(e=e||{botInfo:this.botInfo}).authorization="bearer "+this.user.accessToken,this.enableSecureRTM&&(e["x-rtm-v"]=1),this._rtm.start(e,i(this._onStart,this)))},v.prototype.nextMessageId=function(){return this._messageId=this._messageId||1,this._messageId++},v.prototype._onStart=function(e,t){var n,o,i,r=this,a=!!this._reconnecting;if(this._connecting=!1,this._reconnecting=!1,t&&t.errors&&("TOKEN_EXPIRED"===t.errors[0].code||401===t.errors[0].code||"token expired"===t.errors[0].msg)){var c={forceReconnect:!0,isReconnect:!0};this.cbResetWindow(c),c.error="token_expired"}e||!t.url?(u("error or no url in response %s",e||"no url"),this.emit(p.UNABLE_TO_RTM_START,e||t.error),t&&s(h,t.error)&&this.disconnect("unrecoverable failure connecting to the RTM API",t.error)):(this.socketConfig&&null!==(n=this.socketConfig)&&void 0!==n&&n.socketUrl&&null!==(o=this.socketConfig)&&void 0!==o&&null!==(o=o.socketUrl)&&void 0!==o&&o.queryParams&&Object.keys(this.socketConfig.socketUrl.queryParams).length>0?a?(t.url=t.url+"&ConnectionMode=Reconnect",Object.keys(this.socketConfig.socketUrl.queryParams).forEach(function(e){e&&"ConnectionMode"!==e&&r.socketConfig.socketUrl.queryParams[e]&&(t.url=t.url+"&"+e+"="+r.socketConfig.socketUrl.queryParams[e])})):Object.keys(this.socketConfig.socketUrl.queryParams).forEach(function(e){e&&r.socketConfig.socketUrl.queryParams[e]&&(t.url=t.url+"&"+e+"="+r.socketConfig.socketUrl.queryParams[e])}):a&&(t.url=t.url+"&isReconnect=true"),a||"true"!=window.sessionStorage.getItem("isReconnect")||(t.url=t.url+"&isReconnect=true"),"true"==window.sessionStorage.getItem("debugLogEnabled")&&(t.url=t.url+"&isDebugging=true"),this.authenticated=!0,this.emit(p.AUTHENTICATED,t),this.emit("reconnect_event",{reconnected:a}),this.emit("before_ws_con",{data:t,isImplicitReconnect:a}),this.connect(t.url,(null===(i=t)||void 0===i?void 0:i.nonce)||""))},v.prototype.cleanup=function(){if(this._activeRetryOp=null,this._currentRequest){try{this._currentRequest.abort()}catch(e){console.log("Error aborting request",e)}this._currentRequest=null}this._requestQueue&&this._requestQueue.kill()},v.prototype._close=function(){this.autoReconnect=!1,this._safeDisconnect()},v.prototype._safeDisconnect=function(){this.ws&&this.ws.close(),this.authenticated=!1,this.connected=!1},v.prototype.reWriteURL=function(e){if(this.reWriteSocketURL){var t=document.createElement("a");t.href=e,this.reWriteSocketURL.protocol&&(t.protocol=this.reWriteSocketURL.protocol),this.reWriteSocketURL.hostname&&(t.hostname=this.reWriteSocketURL.hostname),this.reWriteSocketURL.port&&(t.port=this.reWriteSocketURL.port),e=t.href}return e},v.prototype.connect=function(e,t){u("connecting"),this.emit(p.WS_OPENING,{}),e=this.reWriteURL(e);var n=[];this.enableSecureRTM&&this.assertion&&t&&(n.push("x-rtm-v|1"),n.push("jwt|"+this.assertion),n.push("nonce|"+t)),this.ws=this._socketFn(e,n),this.ws.onopen=i(this.handleWsOpen,this),this.ws.onmessage=i(this.handleWsMessage,this),this.ws.onerror=i(this.handleWsError,this),this.ws.onclose=i(this.handleWsClose,this),this.ws.onping=i(this.handleWsPing,this)},v.prototype.disconnect=function(e,t){u("disconnecting"),this.emit(p.DISCONNECT,e,t),this.autoReconnect=!1,this._safeDisconnect()},v.prototype.reconnect=function(){u("reconnecting"),console.log("in reconnect"),this._reconnecting||(this._reconnecting=!0,this.emit(p.ATTEMPTING_RECONNECT),this._safeDisconnect(),this._connAttempts++,setTimeout(i(this.start,this),this._connAttempts*this.RECONNECTION_BACKOFF))},v.prototype.handleWsOpen=function(){u("connected"),this.connected=!0,this.emit("open",{data:{}}),this._connAttempts=0},v.prototype.handleWsMessage=function(e){var t,n=this;if(this.secureChannel){var o=e&&"string"==typeof e.data?e.data:"string"==typeof e?e:null,i=null;if(o)try{i=JSON.parse(o)}catch(e){i=null}if(i&&this.secureChannel.isRelevant(i))return void this.secureChannel.processIncoming(i).then(function(e){if(e&&!e.handled){var t=void 0!==e.plaintext?e.plaintext:i;n.emit("message",{data:JSON.stringify(t)})}}).catch(function(){})}this.emit("message",e);try{t=JSON.parse(e)}catch(e){return}s(f,t.type)?this._handleWsMessageInternal(t.type,t):this._handleWsMessageViaEventHandler(t.type,t)},v.prototype._handleWsMessageInternal=function(e,t){e===l.HELLO&&this._handleHello()},v.prototype._handleWsMessageViaEventHandler=function(e,t){var n;if(e===l.MESSAGE&&(n=t.reply_to)){if(!this._pendingMessages[n])return;delete this._pendingMessages[n]}this.emit(e,t),e!==l.MESSAGE||c(t.subtype)||this.emit(g(t.subtype),t)},v.prototype.handleWsError=function(e){u("web socket error::%s",e),this.emit("api_failure",{type:"socketError",responseError:e,request:""}),this.emit(p.WS_ERROR,e)},v.prototype.handleWsClose=function(e,t){this.connected=!1,this.secureChannel&&this.secureChannel.reset("ws_close"),this.emit(p.WS_CLOSE,e,t),this.autoReconnect?this._connecting||this.reconnect():(u("websocket closed with auto-reconnect false on the RTM client"),this.disconnect("websocket closed with auto-reconnect false on the RTM client"))},v.prototype.handleWsPing=function(){this.ws.pong&&this.ws.pong()},v.prototype._handleHello=function(){this.connected=!0,this.emit(p.RTM_CONNECTION_OPENED)},v.prototype.sendMessage=function(e,t){this.send(e,t)},v.prototype.send=function(e,t){var n=this;this.secureChannel?Promise.resolve(this.secureChannel.processOutgoing(e)).then(function(e){n.rawSend(e,t)},function(e){c(t)||t(e instanceof Error?e:new Error(String(e&&e.message||e)))}):this.rawSend(e,t)},v.prototype.rawSend=function(e,t){var n,o,i=r(e);this.connected&&!this._reconnecting?(i.id=i.clientMessageId||this.nextMessageId(),n=JSON.stringify(i),this._pendingMessages[i.id]=i,this.ws.send(n,void 0,function(e){c(e),c(t)||t(e)})):(u(o="ws not connected or reconnecting, unable to send message"),c(t)||t(new Error(o)))},t.exports=v},{"../client":3,"../events/client":4,"../events/rtm":6,"../events/utils":7,"../transports/ws":11,"../web/apis":15,debug:21,inherits:23,lodash:24}],10:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).has,r=o.partial,s=e("browser-request"),a=function(e,t,n,o){t?e(t,n&&n.headers||{},n&&n.statusCode||null,o):e(t,n.headers,n.statusCode,o)};t.exports.requestTransport=function(e,t){var n=function(e){var t={url:e.url,headers:e.headers};return i(e.data,"file")?t.formData=e.data:t.json=e.data,t}(e);e.data&&e.data.type&&"GET"===e.data.type?s.get(n,r(a,t)):s.post(n,r(a,t))}},{"browser-request":20,lodash:24}],11:[function(e,t,n){t.exports=function(e,t){return t&&t.length>0?new WebSocket(e,t):new WebSocket(e)}},{}],12:[function(e,t,n){t.exports=function(){}},{}],13:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="anonymouslogin",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.login=function(e,t){var n={opts:e=e||{}};return this.client.makeAPICall("/oAuth/token/jwtgrant/anonymous",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],14:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="history",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.history=function(e,t,n){var o={opts:e=e||{},type:"GET"},i="/botmessages/rtm";n&&n.webhookConfig&&n.webhookConfig.enable&&(i="/chathistory/"+n.webhookConfig.streamId+"/"+n.webhookConfig.channelType);var r=!1,s="?";return e.botInfo&&e.botInfo.taskBotId&&(!1===r?(i+=s+"botId="+e.botInfo.taskBotId,s="&",r=!0):i+=s+"botId="+e.botInfo.taskBotId,delete e.botInfo),e.offset&&(!1===r?(i+=s+"offset="+e.offset,s="&",r=!0):i+=s+"offset="+e.offset,delete e.offset),e.limit&&(!1===r?(i+=s+"limit="+e.limit,s="&",r=!0):i+=s+"limit="+e.limit,delete e.limit),e.forward&&(!1===r?(i+=s+"forward="+e.forward,s="&",r=!0):i+=s+"forward="+e.forward,delete e.forward),e.msgId&&(!1===r?(i+=s+"msgId="+e.msgId,s="&",r=!0):i+=s+"msgId="+e.msgId,delete e.msgId),this.client.makeAPICall(i,o,t)},t.exports=i},{"./BaseApi":12,inherits:23}],15:[function(e,t,n){t.exports={RtmApi:e("./rtm.js"),LogInApi:e("./login.js"),AnonymousLogin:e("./anonymouslogin.js"),HistoryApi:e("./history.js")}},{"./anonymouslogin.js":13,"./history.js":14,"./login.js":16,"./rtm.js":17}],16:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="login",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.login=function(e,t){var n={opts:e=e||{}};return this.client.makeAPICall("/oAuth/token/jwtgrant",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],17:[function(e,t,n){var o=e("./BaseApi");function i(e){this.name="rtm",this.client=e,this.BaseApi=o}e("inherits")(i,o),i.prototype.start=function(e,t){e.language=localStorage.currentBotLanguage||"en";var n={opts:e};return this.client.makeAPICall("/rtm/start",n,t)},t.exports=i},{"./BaseApi":12,inherits:23}],18:[function(e,t,n){var o,i=(o=e("lodash").bind?e("lodash"):_).bind,r=o.forEach,s=e("inherits"),a=e("../client"),c=e("./apis/index");function u(e,t){var n=t||{};a.call(this,e,n),this.claims=t.claims,this.retryConfig=n.retryConfig||{retries:n.maxReconnectionAPIAttempts||5,factor:3.9},this.user={}}s(u,a),u.prototype._createFacets=function(){var e;u.super_.prototype._createFacets.call(this),i(this.makeAPICall,this),r(c,function(t){this[(e=new t(this)).name]=e},this)},t.exports=u},{"../client":3,"./apis/index":15,inherits:23,lodash:24}],19:[function(n,o,i){(function(n,i){!function(){var r,s={};function a(){}function c(e){return e}function u(e){return!!e}function l(e){return!e}var f="object"===("undefined"==typeof self?"undefined":t(self))&&self.self===self&&self||"object"===t(i)&&i.global===i&&i||this;function h(e){return function(){if(null===e)throw new Error("Callback was already called.");e.apply(this,arguments),e=null}}function p(e){return function(){null!==e&&(e.apply(this,arguments),e=null)}}null!=f&&(r=f.async),s.noConflict=function(){return f.async=r,s};var d=Object.prototype.toString,m=Array.isArray||function(e){return"[object Array]"===d.call(e)};function g(e){return m(e)||"number"==typeof e.length&&e.length>=0&&e.length%1==0}function y(e,t){for(var n=-1,o=e.length;++n<o;)t(e[n],n,e)}function v(e,t){for(var n=-1,o=e.length,i=Array(o);++n<o;)i[n]=t(e[n],n,e);return i}function b(e){return v(Array(e),function(e,t){return t})}function _(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var w=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};function A(e){var t,n,o=-1;return g(e)?(t=e.length,function(){return++o<t?o:null}):(n=w(e),t=n.length,function(){return++o<t?n[o]:null})}function E(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),o=Array(n),i=0;i<n;i++)o[i]=arguments[i+t];switch(t){case 0:return e.call(this,o);case 1:return e.call(this,arguments[0],o)}}}function k(e){return function(t,n,o){return e(t,o)}}var I="function"==typeof setImmediate&&setImmediate,C=I?function(e){I(e)}:function(e){setTimeout(e,0)};function T(e){return function(t,n,o){o=p(o||a);var i=A(t=t||[]);if(e<=0)return o(null);var r=!1,s=0,c=!1;!function a(){if(r&&s<=0)return o(null);for(;s<e&&!c;){var u=i();if(null===u)return r=!0,void(s<=0&&o(null));s+=1,n(t[u],u,h(function(e){s-=1,e?(o(e),c=!0):a()}))}}()}}function S(e){return function(t,n,o){return e(s.eachOf,t,n,o)}}function O(e){return function(t,n,o,i){return e(T(n),t,o,i)}}function R(e){return function(t,n,o){return e(s.eachOfSeries,t,n,o)}}function x(e,t,n,o){o=p(o||a);var i=g(t=t||[])?[]:{};e(t,function(e,t,o){n(e,function(e,n){i[t]=n,o(e)})},function(e){o(e,i)})}function N(e,t,n,o){var i=[];e(t,function(e,t,o){n(e,function(n){n&&i.push({index:t,value:e}),o()})},function(){o(v(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})}function M(e,t,n,o){N(e,t,function(e,t){n(e,function(e){t(!e)})},o)}function L(e,t,n){return function(o,i,r,s){function a(){s&&s(n(!1,void 0))}function c(e,o,i){if(!s)return i();r(e,function(o){s&&t(o)&&(s(n(!0,e)),s=r=!1),i()})}arguments.length>3?e(o,i,c,a):(s=r,r=i,e(o,c,a))}}function P(e,t){return t}function D(e,t,n){n=n||a;var o=g(t)?[]:{};e(t,function(e,t,n){e(E(function(e,i){i.length<=1&&(i=i[0]),o[t]=i,n(e)}))},function(e){n(e,o)})}function j(e,t,n,o){var i=[];e(t,function(e,t,o){n(e,function(e,t){i=i.concat(t||[]),o(e)})},function(e){o(e,i)})}function W(e,t,n){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");function o(e,t,n,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");if(e.started=!0,m(t)||(t=[t]),0===t.length&&e.idle())return s.setImmediate(function(){e.drain()});y(t,function(t){var i={data:t,callback:o||a};n?e.tasks.unshift(i):e.tasks.push(i),e.tasks.length===e.concurrency&&e.saturated()}),s.setImmediate(e.process)}function i(e,t){return function(){r-=1;var n=!1,o=arguments;y(t,function(e){y(c,function(t,o){t!==e||n||(c.splice(o,1),n=!0)}),e.callback.apply(e,o)}),e.tasks.length+r===0&&e.drain(),e.process()}}var r=0,c=[],u={tasks:[],concurrency:t,payload:n,saturated:a,empty:a,drain:a,started:!1,paused:!1,push:function(e,t){o(u,e,!1,t)},kill:function(){u.drain=a,u.tasks=[]},unshift:function(e,t){o(u,e,!0,t)},process:function(){for(;!u.paused&&r<u.concurrency&&u.tasks.length;){var t=u.payload?u.tasks.splice(0,u.payload):u.tasks.splice(0,u.tasks.length),n=v(t,function(e){return e.data});0===u.tasks.length&&u.empty(),r+=1,c.push(t[0]);var o=h(i(u,t));e(n,o)}},length:function(){return u.tasks.length},running:function(){return r},workersList:function(){return c},idle:function(){return u.tasks.length+r===0},pause:function(){u.paused=!0},resume:function(){if(!1!==u.paused){u.paused=!1;for(var e=Math.min(u.concurrency,u.tasks.length),t=1;t<=e;t++)s.setImmediate(u.process)}}};return u}function U(e){return E(function(n,o){n.apply(null,o.concat([E(function(n,o){"object"===("undefined"==typeof console?"undefined":t(console))&&(n?console.error&&console.error(n):console[e]&&y(o,function(t){console[e](t)}))})]))})}function B(e){return function(t,n,o){e(b(t),n,o)}}function H(e){return E(function(t,n){var o=E(function(n){var o=this,i=n.pop();return e(t,function(e,t,i){e.apply(o,n.concat([i]))},i)});return n.length?o.apply(this,n):o})}function q(e){return E(function(t){var n=t.pop();t.push(function(){var e=arguments;o?s.setImmediate(function(){n.apply(null,e)}):n.apply(null,e)});var o=!0;e.apply(this,t),o=!1})}"object"===t(n)&&"function"==typeof n.nextTick?s.nextTick=n.nextTick:s.nextTick=C,s.setImmediate=I?C:s.nextTick,s.forEach=s.each=function(e,t,n){return s.eachOf(e,k(t),n)},s.forEachSeries=s.eachSeries=function(e,t,n){return s.eachOfSeries(e,k(t),n)},s.forEachLimit=s.eachLimit=function(e,t,n,o){return T(t)(e,k(n),o)},s.forEachOf=s.eachOf=function(e,t,n){n=p(n||a);for(var o,i=A(e=e||[]),r=0;null!=(o=i());)r+=1,t(e[o],o,h(s));function s(e){r--,e?n(e):null===o&&r<=0&&n(null)}0===r&&n(null)},s.forEachOfSeries=s.eachOfSeries=function(e,t,n){n=p(n||a);var o=A(e=e||[]),i=o();!function r(){var a=!0;if(null===i)return n(null);t(e[i],i,h(function(e){if(e)n(e);else{if(null===(i=o()))return n(null);a?s.setImmediate(r):r()}})),a=!1}()},s.forEachOfLimit=s.eachOfLimit=function(e,t,n,o){T(t)(e,n,o)},s.map=S(x),s.mapSeries=R(x),s.mapLimit=O(x),s.inject=s.foldl=s.reduce=function(e,t,n,o){s.eachOfSeries(e,function(e,o,i){n(t,e,function(e,n){t=n,i(e)})},function(e){o(e,t)})},s.foldr=s.reduceRight=function(e,t,n,o){var i=v(e,c).reverse();s.reduce(i,t,n,o)},s.transform=function(e,t,n,o){3===arguments.length&&(o=n,n=t,t=m(e)?[]:{}),s.eachOf(e,function(e,o,i){n(t,e,o,i)},function(e){o(e,t)})},s.select=s.filter=S(N),s.selectLimit=s.filterLimit=O(N),s.selectSeries=s.filterSeries=R(N),s.reject=S(M),s.rejectLimit=O(M),s.rejectSeries=R(M),s.any=s.some=L(s.eachOf,u,c),s.someLimit=L(s.eachOfLimit,u,c),s.all=s.every=L(s.eachOf,l,l),s.everyLimit=L(s.eachOfLimit,l,l),s.detect=L(s.eachOf,c,P),s.detectSeries=L(s.eachOfSeries,c,P),s.detectLimit=L(s.eachOfLimit,c,P),s.sortBy=function(e,t,n){function o(e,t){var n=e.criteria,o=t.criteria;return n<o?-1:n>o?1:0}s.map(e,function(e,n){t(e,function(t,o){t?n(t):n(null,{value:e,criteria:o})})},function(e,t){if(e)return n(e);n(null,v(t.sort(o),function(e){return e.value}))})},s.auto=function(e,t,n){"function"==typeof arguments[1]&&(n=t,t=null),n=p(n||a);var o=w(e),i=o.length;if(!i)return n(null);t||(t=i);var r={},c=0,u=!1,l=[];function f(e){l.unshift(e)}function h(){i--,y(l.slice(0),function(e){e()})}f(function(){i||n(null,r)}),y(o,function(o){if(!u){for(var i,a=m(e[o])?e[o]:[e[o]],p=E(function(e,t){if(c--,t.length<=1&&(t=t[0]),e){var i={};l=function(e,t){i[t]=e},y(w(a=r),function(e){l(a[e],e)}),i[o]=t,u=!0,n(e,i)}else r[o]=t,s.setImmediate(h);var a,l}),d=a.slice(0,a.length-1),g=d.length;g--;){if(!(i=e[d[g]]))throw new Error("Has nonexistent dependency in "+d.join(", "));if(m(i)&&_(i,o)>=0)throw new Error("Has cyclic dependencies")}v()?(c++,a[a.length-1](p,r)):f(function e(){v()&&(c++,(t=_(l,e))>=0&&l.splice(t,1),a[a.length-1](p,r));var t})}function v(){return c<t&&(e=function(e,t){return e&&r.hasOwnProperty(t)},n=!0,y(d,function(t,o,i){n=e(n,t,o,i)}),n)&&!r.hasOwnProperty(o);var e,n}})},s.retry=function(e,n,o){var i=[],r={times:5,interval:0};var a=arguments.length;if(a<1||a>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");function c(e,t){function n(e,n){return function(o){e(function(e,t){o(!e||n,{err:e,result:t})},t)}}function o(e){return function(t){setTimeout(function(){t(null)},e)}}for(;r.times;){var a=!(r.times-=1);i.push(n(r.task,a)),!a&&r.interval>0&&i.push(o(r.interval))}s.series(i,function(t,n){n=n[n.length-1],(e||r.callback)(n.err,n.result)})}return a<=2&&"function"==typeof e&&(o=n,n=e),"function"!=typeof e&&function(e,n){if("number"==typeof n)e.times=parseInt(n,10)||5;else{if("object"!==t(n))throw new Error("Unsupported argument type for 'times': "+t(n));e.times=parseInt(n.times,10)||5,e.interval=parseInt(n.interval,10)||0}}(r,e),r.callback=o,r.task=n,r.callback?c():c},s.waterfall=function(e,t){if(t=p(t||a),!m(e)){var n=new Error("First argument to waterfall must be an array of functions");return t(n)}if(!e.length)return t();!function e(n){return E(function(o,i){if(o)t.apply(null,[o].concat(i));else{var r=n.next();r?i.push(e(r)):i.push(t),q(n).apply(null,i)}})}(s.iterator(e))()},s.parallel=function(e,t){D(s.eachOf,e,t)},s.parallelLimit=function(e,t,n){D(T(t),e,n)},s.series=function(e,t){D(s.eachOfSeries,e,t)},s.iterator=function(e){return function t(n){function o(){return e.length&&e[n].apply(null,arguments),o.next()}return o.next=function(){return n<e.length-1?t(n+1):null},o}(0)},s.apply=E(function(e,t){return E(function(n){return e.apply(null,t.concat(n))})}),s.concat=S(j),s.concatSeries=R(j),s.whilst=function(e,t,n){if(n=n||a,e()){var o=E(function(i,r){i?n(i):e.apply(this,r)?t(o):n.apply(null,[null].concat(r))});t(o)}else n(null)},s.doWhilst=function(e,t,n){var o=0;return s.whilst(function(){return++o<=1||t.apply(this,arguments)},e,n)},s.until=function(e,t,n){return s.whilst(function(){return!e.apply(this,arguments)},t,n)},s.doUntil=function(e,t,n){return s.doWhilst(e,function(){return!t.apply(this,arguments)},n)},s.during=function(e,t,n){n=n||a;var o=E(function(t,o){t?n(t):(o.push(i),e.apply(this,o))}),i=function(e,i){e?n(e):i?t(o):n(null)};e(i)},s.doDuring=function(e,t,n){var o=0;s.during(function(e){o++<1?e(null,!0):t.apply(this,arguments)},e,n)},s.queue=function(e,t){return W(function(t,n){e(t[0],n)},t,1)},s.priorityQueue=function(e,t){function n(e,t){return e.priority-t.priority}var o=s.queue(e,t);return o.push=function(e,t,i){!function(e,t,o,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");if(e.started=!0,m(t)||(t=[t]),0===t.length)return s.setImmediate(function(){e.drain()});y(t,function(t){var r={data:t,priority:o,callback:"function"==typeof i?i:a};e.tasks.splice(function(e,t,n){for(var o=-1,i=e.length-1;o<i;){var r=o+(i-o+1>>>1);n(t,e[r])>=0?o=r:i=r-1}return o}(e.tasks,r,n)+1,0,r),e.tasks.length===e.concurrency&&e.saturated(),s.setImmediate(e.process)})}(o,e,t,i)},delete o.unshift,o},s.cargo=function(e,t){return W(e,1,t)},s.log=U("log"),s.dir=U("dir"),s.memoize=function(e,t){var n={},o={},i=Object.prototype.hasOwnProperty;t=t||c;var r=E(function(r){var a=r.pop(),c=t.apply(null,r);i.call(n,c)?s.setImmediate(function(){a.apply(null,n[c])}):i.call(o,c)?o[c].push(a):(o[c]=[a],e.apply(null,r.concat([E(function(e){n[c]=e;var t=o[c];delete o[c];for(var i=0,r=t.length;i<r;i++)t[i].apply(null,e)})])))});return r.memo=n,r.unmemoized=e,r},s.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},s.times=B(s.map),s.timesSeries=B(s.mapSeries),s.timesLimit=function(e,t,n,o){return s.mapLimit(b(e),t,n,o)},s.seq=function(){var e=arguments;return E(function(t){var n=this,o=t[t.length-1];"function"==typeof o?t.pop():o=a,s.reduce(e,t,function(e,t,o){t.apply(n,e.concat([E(function(e,t){o(e,t)})]))},function(e,t){o.apply(n,[e].concat(t))})})},s.compose=function(){return s.seq.apply(null,Array.prototype.reverse.call(arguments))},s.applyEach=H(s.eachOf),s.applyEachSeries=H(s.eachOfSeries),s.forever=function(e,t){var n=h(t||a),o=q(e);!function e(t){if(t)return n(t);o(e)}()},s.ensureAsync=q,s.constant=E(function(e){var t=[null].concat(e);return function(e){return e.apply(this,t)}}),s.wrapSync=s.asyncify=function(e){return E(function(n){var o,i,r,s=n.pop();try{o=e.apply(this,n)}catch(e){return s(e)}("function"===(r=t(i=o))||"object"===r&&i)&&"function"==typeof o.then?o.then(function(e){s(null,e)}).catch(function(e){s(e.message?e:new Error(e))}):s(null,o)})},"object"===t(o)&&o.exports?o.exports=s:"function"==typeof define&&e.amdO?define([],function(){return s}):f.async=s}()}).call(this,n("_process"),void 0!==e.g?e.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:31}],20:[function(n,o,i){var r,s;r=this,s=function(){var e=XMLHttpRequest;if(!e)throw new Error("missing XMLHttpRequest");function n(t,s){if("function"!=typeof s)throw new Error("Bad callback given: "+s);if(!t)throw new Error("No options given");var a=t.onResponse;if((t="string"==typeof t?{uri:t}:JSON.parse(JSON.stringify(t))).onResponse=a,t.verbose&&(n.log=function(){var e,t,n={},o=["trace","debug","info","warn","error"];for(t=0;t<o.length;t++)n[e=o[t]]=i,"undefined"!=typeof console&&console&&console[e]&&(n[e]=r(console,e));return n}()),t.url&&(t.uri=t.url,delete t.url),!t.uri&&""!==t.uri)throw new Error("options.uri is a required argument");if("string"!=typeof t.uri)throw new Error("options.uri must be a string");for(var c=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],u=0;u<c.length;u++)if(t[c[u]])throw new Error("options."+c[u]+" is not supported");if(t.callback=s,t.method=t.method||"GET",t.headers=t.headers||{},t.body=t.body||null,t.timeout=t.timeout||n.DEFAULT_TIMEOUT,t.headers.host)throw new Error("Options.headers.host is not supported");t.json&&(t.headers.accept=t.headers.accept||"application/json","GET"!==t.method&&(t.headers["content-type"]="application/json"),"boolean"!=typeof t.json?t.body=JSON.stringify(t.json):"string"!=typeof t.body&&(t.body=JSON.stringify(t.body)));var l=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")};if(t.qs){var f="string"==typeof t.qs?t.qs:l(t.qs);-1!==t.uri.indexOf("?")?t.uri=t.uri+"&"+f:t.uri=t.uri+"?"+f}if(t.form){if("string"==typeof t.form)throw"form name unsupported";if("POST"===t.method){var h=(t.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(t.headers["content-type"]=h,h){case"application/x-www-form-urlencoded":t.body=l(t.form).replace(/%20/g,"+");break;case"multipart/form-data":var p=function(e){var t={};t.boundry="-------------------------------"+Math.floor(1e9*Math.random());var n=[];for(var o in e)e.hasOwnProperty(o)&&n.push("--"+t.boundry+'\nContent-Disposition: form-data; name="'+o+'"\n\n'+e[o]+"\n");return n.push("--"+t.boundry+"--"),t.body=n.join(""),t.length=t.body.length,t.type="multipart/form-data; boundary="+t.boundry,t}(t.form);t.body=p.body,t.headers["content-type"]=p.type;break;default:throw new Error("unsupported encoding:"+h)}}}return t.onResponse=t.onResponse||i,!0===t.onResponse&&(t.onResponse=s,t.callback=i),!t.headers.authorization&&t.auth&&(t.headers.authorization="Basic "+function(e){var t,n,o,i,r,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,c=0,u="",l=[];if(!e)return e;do{t=(r=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,n=r>>12&63,o=r>>6&63,i=63&r,l[c++]=s.charAt(t)+s.charAt(n)+s.charAt(o)+s.charAt(i)}while(a<e.length);switch(u=l.join(""),e.length%3){case 1:u=u.slice(0,-2)+"==";break;case 2:u=u.slice(0,-1)+"="}return u}(t.auth.username+":"+t.auth.password)),function(t){var i=new e,r=!1,s=function(e){var t,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{t=location.href}catch(e){(t=document.createElement("a")).href="",t=t.href}var o=n.exec(t.toLowerCase())||[],i=n.exec(e.toLowerCase());return!(!i||i[1]==o[1]&&i[2]==o[2]&&(i[3]||("http:"===i[1]?80:443))==(o[3]||("http:"===o[1]?80:443)))}(t.uri),a="withCredentials"in i;if(o+=1,i.seq_id=o,i.id=o+": "+t.method+" "+t.uri,i._id=i.id,s&&!a){var c=new Error("Browser does not support cross-origin request: "+t.uri);return c.cors="unsupported",t.callback(c,i)}function u(){r=!0;var e=new Error("ETIMEDOUT");return e.code="ETIMEDOUT",e.duration=t.timeout,n.log.error("Timeout",{id:i._id,milliseconds:t.timeout}),t.callback(e,i)}i.timeoutTimer=setTimeout(u,t.timeout);var l={response:!1,loading:!1,end:!1};for(var f in i.onreadystatechange=h,i.open(t.method,t.uri,!0),t.headers)i.setRequestHeader(f,t.headers[f]);return s&&(i.withCredentials=!!t.withCredentials),i.send(t.body),i;function h(t){if(r)return n.log.debug("Ignoring timed out state change",{state:i.readyState,id:i.id});n.log.debug("State change",{state:i.readyState,id:i.id,timed_out:r}),i.readyState===e.OPENED?n.log.debug("Request started",{id:i.id}):i.readyState===e.HEADERS_RECEIVED?p():i.readyState===e.LOADING?(p(),d()):i.readyState===e.DONE&&(p(),d(),m())}function p(){if(!l.response){if(l.response=!0,n.log.debug("Got response",{id:i.id,status:i.status}),clearTimeout(i.timeoutTimer),i.statusCode=i.status,s&&0==i.statusCode){var e=new Error("Request rejected: "+t.uri);return e.cors="rejected",l.loading=!0,l.end=!0,t.callback(e,i)}t.onResponse(null,i)}}function d(){l.loading||(l.loading=!0,n.log.debug("Response body loading",{id:i.id}))}function m(){if(!l.end){if(l.end=!0,n.log.debug("Request done",{id:i.id}),i.body=i.responseText,t.json)try{i.body=JSON.parse(i.responseText)}catch(e){return t.callback(e,i)}t.callback(null,i,i.body)}}}(t)}n.log={trace:i,debug:i,info:i,warn:i,error:i};var o=0;function i(){}function r(e,n){return function(o,i){return"object"===t(i)&&(o+=" "+JSON.stringify(i)),e[n].call(e,o)}}return n.withCredentials=!1,n.DEFAULT_TIMEOUT=12e4,n.defaults=function(e,t){var o=function(t){return function(n,o){for(var i in n="string"==typeof n?{uri:n}:JSON.parse(JSON.stringify(n)),e)void 0===n[i]&&(n[i]=e[i]);return t(n,o)}},i=o(n);return i.get=o(n.get),i.post=o(n.post),i.put=o(n.put),i.head=o(n.head),i},["get","put","post","head"].forEach(function(e){var t=e.toUpperCase();n[e.toLowerCase()]=function(e){"string"==typeof e?e={method:t,uri:e}:(e=JSON.parse(JSON.stringify(e))).method=t;var o=[e].concat(Array.prototype.slice.apply(arguments,[1]));return n.apply(this,o)}}),n.couch=function(e,t){return"string"==typeof e&&(e={uri:e}),e.json=!0,e.body&&(e.json=e.body),delete e.body,t=t||i,n(e,function(e,n,o){if(e)return t(e,n,o);if((n.statusCode<200||n.statusCode>299)&&o.error){for(var i in e=new Error("CouchDB error: "+(o.error.reason||o.error.error)),o)e[i]=o[i];return t(e,n,o)}return t(e,n,o)})},n},"function"==typeof define&&e.amdO||"object"===t(i)?o.exports=s():r.returnExports=s()},{}],21:[function(e,n,o){function i(){var e;try{e=o.storage.debug}catch(e){}return e}(o=n.exports=e("./debug")).log=function(){return"object"===("undefined"==typeof console?"undefined":t(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},o.formatArgs=function(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+o.humanize(this.diff),!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,r=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(r=i))}),e.splice(r,0,n),e},o.save=function(e){try{null==e?o.storage.removeItem("debug"):o.storage.debug=e}catch(e){}},o.load=i,o.useColors=function(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31},o.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),o.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],o.formatters.j=function(e){return JSON.stringify(e)},o.enable(i())},{"./debug":22}],22:[function(e,t,n){n=t.exports=function(e){function t(){}function r(){var e=r,t=+new Date,s=t-(o||t);e.diff=s,e.prev=o,e.curr=t,o=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=n.colors[i++%n.colors.length]);var a=Array.prototype.slice.call(arguments);a[0]=n.coerce(a[0]),"string"!=typeof a[0]&&(a=["%o"].concat(a));var c=0;a[0]=a[0].replace(/%([a-z%])/g,function(t,o){if("%%"===t)return t;c++;var i=n.formatters[o];if("function"==typeof i){var r=a[c];t=i.call(e,r),a.splice(c,1),c--}return t}),"function"==typeof n.formatArgs&&(a=n.formatArgs.apply(e,a)),(r.log||n.log||console.log.bind(console)).apply(e,a)}t.enabled=!1,r.enabled=!0;var s=n.enabled(e)?r:t;return s.namespace=e,s},n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),o=t.length,i=0;i<o;i++)t[i]&&("-"===(e=t[i].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){var t,o;for(t=0,o=n.skips.length;t<o;t++)if(n.skips[t].test(e))return!1;for(t=0,o=n.names.length;t<o;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var o,i=0},{ms:25}],23:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],24:[function(e,n,o){function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}function r(e,t,n){if(null!=e){var o=void 0!==n?t.bind(n):t;if(Array.isArray(e))for(var i=0;i<e.length;i++)o(e[i],i,e);else for(var r=Object.keys(e),s=0;s<r.length;s++)o(e[r[s]],r[s],e)}}function s(e,t){if(null==e)return!1;if(Array.isArray(e))return-1!==e.indexOf(t);if("string"==typeof e)return-1!==e.indexOf(t);for(var n=Object.keys(e),o=0;o<n.length;o++)if(e[n[o]]===t)return!0;return!1}var a={bind:function(e,t){var n=Array.prototype.slice.call(arguments,2);return function(){var o=n.concat(Array.prototype.slice.call(arguments));return e.apply(t,o)}},isFunction:function(e){return"function"==typeof e},isUndefined:function(e){return void 0===e},isString:function(e){return"string"==typeof e},noop:function(){},assign:i,extend:i,has:function(e,t){return null!=e&&Object.prototype.hasOwnProperty.call(e,t)},forEach:r,each:r,includes:s,contains:s,partial:function(e){var t=Array.prototype.slice.call(arguments,1);return function(){var n=t.concat(Array.prototype.slice.call(arguments));return e.apply(this,n)}},cloneDeep:function(e){if("function"==typeof structuredClone)try{return structuredClone(e)}catch(e){}return JSON.parse(JSON.stringify(e))},debounce:function(e,t){var n;return function(){var o=this,i=arguments;clearTimeout(n),n=setTimeout(function(){e.apply(o,i)},t)}},throttle:function(e,t){var n,o=0;return function(){var i=this,r=arguments,s=Date.now(),a=t-(s-o);clearTimeout(n),a<=0?(o=s,e.apply(i,r)):n=setTimeout(function(){o=Date.now(),e.apply(i,r)},a)}},merge:function e(n){for(var o=1;o<arguments.length;o++){var i=arguments[o];if(null!=i)for(var r=Object.keys(i),s=0;s<r.length;s++){var a=r[s],c=i[a];c&&"object"===t(c)&&!Array.isArray(c)?("object"===t(n[a])&&null!==n[a]||(n[a]={}),e(n[a],c)):n[a]=c}}return n}};n.exports=a},{}],25:[function(e,t,n){var o=1e3,i=60*o,r=60*i,s=24*r,a=365.25*s;function c(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){return t=t||{},"string"==typeof e?function(e){if((e=""+e).length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*r;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}(e):t.long?c(n=e,s,"day")||c(n,r,"hour")||c(n,i,"minute")||c(n,o,"second")||n+" ms":function(e){return e>=s?Math.round(e/s)+"d":e>=r?Math.round(e/r)+"h":e>=i?Math.round(e/i)+"m":e>=o?Math.round(e/o)+"s":e+"ms"}(e);var n}},{}],26:[function(e,t,n){t.exports=e("./lib/retry")},{"./lib/retry":27}],27:[function(e,t,n){var o=e("./retry_operation");n.operation=function(e){var t=!1;e&&!0===e.forever&&(t=!0);var i=n.timeouts(e);return new o(i,t)},n.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<t.retries;i++)o.push(this.createTimeout(i,t));return o.sort(function(e,t){return e-t}),o},n.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,o=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout)},n.wrap=function(e,t,o){if(t instanceof Array&&(o=t,t=null),!o)for(var i in o=[],e)"function"==typeof e[i]&&o.push(i);for(var r=0;r<o.length;r++){var s=o[r],a=e[s];e[s]=function(){var o=n.operation(t),i=Array.prototype.slice.call(arguments),r=i.pop();i.push(function(e){o.retry(e)||(e&&(arguments[0]=o.mainError()),r.apply(this,arguments))}),o.attempt(function(){a.apply(e,i)})},e[s].options=t}}},{"./retry_operation":28}],28:[function(e,t,n){function o(e,t){this._timeouts=e,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,t&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=o,o.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;this._errors.push(e);var t=this._timeouts.shift();if(void 0===t){if(!this._cachedTimeouts)return!1;this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),t=this._timeouts.shift()}var n=this;return setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout)),n._fn(n._attempts)},t),!0},o.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._fn(this._attempts)},o.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},o.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},o.prototype.start=o.prototype.try,o.prototype.errors=function(){return this._errors},o.prototype.attempts=function(){return this._attempts},o.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,o=0;o<this._errors.length;o++){var i=this._errors[o],r=i.message,s=(e[r]||0)+1;e[r]=s,s>=n&&(t=i,n=s)}return t}},{}],29:[function(e,t,n){t.exports=function(){var e=[].slice.call(arguments,0).join("/");return e.replace(/[\/]+/g,"/").replace(/\/\?/g,"?").replace(/\/\#/g,"#").replace(/\:\//g,"://")}},{}],30:[function(e,n,o){function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"object"===t(e)&&null!==e}function a(e){return void 0===e}n.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.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},i.prototype.emit=function(e){var t,n,o,i,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(a(n=this._events[e]))return!1;if(r(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:i=Array.prototype.slice.call(arguments,1),n.apply(this,i)}else if(s(n))for(i=Array.prototype.slice.call(arguments,1),o=(u=n.slice()).length,c=0;c<o;c++)u[c].apply(this,i);return!0},i.prototype.addListener=function(e,t){var n;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?s(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,s(this._events[e])&&!this._events[e].warned&&(n=a(this._maxListeners)?i.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(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},i.prototype.on=i.prototype.addListener,i.prototype.once=function(e,t){if(!r(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},i.prototype.removeListener=function(e,t){var n,o,i,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=(n=this._events[e]).length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=a;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},i.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},i.listenerCount=function(e,t){return e.listenerCount(t)}},{}],31:[function(e,t,n){var o,i=t.exports={},r=[],s=!1,a=-1;function c(){s=!1,o.length?r=o.concat(r):a=-1,r.length&&u()}function u(){if(!s){var e=setTimeout(c);s=!0;for(var t=r.length;t;){for(o=r,r=[];++a<t;)o&&o[a].run();a=-1,t=r.length}o=null,s=!1,clearTimeout(e)}}function l(e,t){this.fun=e,this.array=t}function f(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];r.push(new l(e,t)),1!==r.length||s||setTimeout(u,0)},l.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=f,i.addListener=f,i.once=f,i.off=f,i.removeListener=f,i.removeAllListeners=f,i.emit=f,i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}]},{},[]),o=function(){return n("/KoreBot.js").instance()};export{o as createBotInstance};
|