b22d52e9016832e026184afe6f103d5021584abd
[motion2.git] / server / services / ami / preview / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x54ef=['DEACTIVATED','\x20is\x20deactivated','syncCampaigns','campaignsPreview','hasOwnProperty','dialMethod','booked','type','clearZombieChannels','outbound','recallMe','clearZombieChannel','[clearZombieChannels][talking]','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','contactId','UserId','VoiceQueueId','ListId','Action','status','channel','catch','No\x20such\x20channel','updateOriginated','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','[action]','size','getContactRecallMe','agentReadyId','then','length','getDiff','scheduledat','Agent','run','logger2','[RecallMe]','disableContact','starttime','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','setMessage','IsNotLoggedIn','loggedIn','NO_AGENTS_LOGGED','dialActive','isTrunkReachable','Trunk','UNREACHABLE_TRUNK','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','[callProgressDetectingCustomer][logNoSuch]','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','countnosuchnumberretry','dialNoSuchNumberMaxRetry','rescheduleContact','scheduledAt','unlockAgent','activeContact','linkedid','actioncountonusuch','idContact','swapAdditionalPhones','ANSWER','responsetime','[syncHangup][talking][increment]','\x20Queue','custom:agentconnect','buildObj','custom:agentConnectPreview','custom:agentcomplete','complete','total','answered','decrementTalkink','[16]','Answer','[callProgressDetectingCustomer][logAnswer]','crateCustomerReportQueue','sumDuration','talktime','[syncHangup][talking][decrement]','uniqueid','BUSY','countbusyretry','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','verifyAdditionalPhones','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','incrementPreviewCounters','NOANSWER','countnoanswerretry','NoAnswer','dialNoAnswerRetryFrequency','buildNoAnswerEventPayload','custom:agentnoanswer','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestion]','additional','[callProgressDetectingCustomer][logCongestionGlobal]','dialBusyRetryFrequency','outboundRejectCallsDay','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','countagentrejectretry','dialAgentRejectMaxRetry','ABANDONED','outboundAbandonedCallsDay','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','outboundUnknownCallsDay','cause-txt','amd','[callProgressDetectingCustomer][hangupInAMD]','dialstatus','custom:amd','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','queueSummaryCountersUpdated','callProgressDetectingAgent','object','isUndefined','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logNoAnswer]','Busy','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','resolve','isNil','Contact\x20is\x20undefined','lookAgent','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','called','Calling','Call\x20failed','outboundBlacklistCallsDay','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','active','trunks','SIP/%s','reachable','unmonitored','execRun','unlock','unlockContact','getContactPreview','recallme','validateContact','isValid','checkIsBlackList','phone','checkInBlack','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','Queue','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','TrunkBackup','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','isActive','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','SIP/%s/%s%s','dialPrefix','trim','substring','dialCutDigit','getCallerId','callerid','dialOriginateCallerIdName','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','originatecalleridname','extractCalleridName','extractCalleridNumber','addVariables','merge','variablesAction','[originateFailure][logOriginateFailure]','logLookAgent','clone','response','custom:agentringnoanswer','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','[syncHangup][talking][transfer]','syncDialEnd','destuniqueid','addVariable','variables','filterKey','keys','variable','error','transfertargetlinkedid','transfer','syncBlindTransfer','transfererlinkedid','exports','util','lodash','uuid','ioredis','../../../config/environment','../../../config/logger','preview','actionPreview','../ami','./action','./util/util','../dialer/utils','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','sequence','voiceQueues','actions','agents','clockClearZombieChannels','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','loopCampaigns','emit','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','format','voice:queue:%s','name','sendMessageOneNotActive','originated','pTalking','available','paused','message','CAMPAIGN_STATUS','INACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20'];(function(_0x7ee0c5,_0x58a773){var _0x557583=function(_0x19433e){while(--_0x19433e){_0x7ee0c5['push'](_0x7ee0c5['shift']());}};_0x557583(++_0x58a773);}(_0x54ef,0x112));var _0xf54e=function(_0x5f03f0,_0x4d4dca){_0x5f03f0=_0x5f03f0-0x0;var _0x11a08d=_0x54ef[_0x5f03f0];return _0x11a08d;};'use strict';var util=require(_0xf54e('0x0'));var _=require(_0xf54e('0x1'));var uuid=require(_0xf54e('0x2'));var moment=require('moment');var Redis=require(_0xf54e('0x3'));var config=require(_0xf54e('0x4'));var logger=require(_0xf54e('0x5'))(_0xf54e('0x6'));var loggerAction=require(_0xf54e('0x5'))(_0xf54e('0x7'));var ami=require(_0xf54e('0x8'));var rpcDb=require('./rpcDb');var cmHopperAdditionalPhone=require('../rpc/cmHopperAdditionalPhone');var Action=require(_0xf54e('0x9'));var ut=require(_0xf54e('0xa'));var utils=require(_0xf54e('0xb'));config['redis']=_[_0xf54e('0xc')](config['redis'],{'host':_0xf54e('0xd'),'port':0x18eb});var io=require(_0xf54e('0xe'))(new Redis(config['redis']));var Sequence=function(){};Sequence[_0xf54e('0xf')][_0xf54e('0x10')]=function(_0x6b9e61){this[_0xf54e('0x11')]=this['tail']?this[_0xf54e('0x11')][_0xf54e('0x12')](_0x6b9e61):_0x6b9e61();};function Preview(_0x143d66){this[_0xf54e('0x13')]=new Sequence();this['campaignsPreview']=_0x143d66[_0xf54e('0x14')];this['trunks']=_0x143d66['trunks'];this[_0xf54e('0x15')]={};this[_0xf54e('0x16')]=_0x143d66[_0xf54e('0x16')];this[_0xf54e('0x17')]=0x0;ami['on']('originateresponse',this[_0xf54e('0x18')][_0xf54e('0x19')](this));ami['on'](_0xf54e('0x1a'),this[_0xf54e('0x1b')]['bind'](this));ami['on'](_0xf54e('0x1c'),this[_0xf54e('0x1d')][_0xf54e('0x19')](this));ami['on']('dialend',this['syncDialEnd'][_0xf54e('0x19')](this));ami['on'](_0xf54e('0x1e'),this[_0xf54e('0x1f')][_0xf54e('0x19')](this));ami['on'](_0xf54e('0x20'),this[_0xf54e('0x21')][_0xf54e('0x19')](this));ami['on'](_0xf54e('0x22'),this[_0xf54e('0x23')][_0xf54e('0x19')](this));ami['on'](_0xf54e('0x24'),this['syncBlindTransfer']['bind'](this));this[_0xf54e('0x25')](this['campaignsPreview']);}function emit(_0x3e1556,_0x1bfe99,_0x106362){io['to'](_0x3e1556)[_0xf54e('0x26')](_0x1bfe99,_0x106362);}function emitVoiceQueueChannelRemove(_0xf64f12){logger[_0xf54e('0x27')](_0xf54e('0x28'),JSON[_0xf54e('0x29')](_0xf64f12));emit(util[_0xf54e('0x2a')](_0xf54e('0x2b'),_0xf64f12[_0xf54e('0x2c')]),'voice_queue_channel:remove',_0xf64f12);io[_0xf54e('0x26')]('voice_queue_presence:remove',_0xf64f12);}function notSendMessagesQueue(_0x264a8f){if(_0x264a8f[_0xf54e('0x2d')]){if(_0x264a8f[_0xf54e('0x2e')]===0x0&&_0x264a8f[_0xf54e('0x2f')]===0x0){_0x264a8f[_0xf54e('0x2d')]=![];_0x264a8f[_0xf54e('0x30')]=0x0;_0x264a8f[_0xf54e('0x31')]=0x0;_0x264a8f[_0xf54e('0x32')]=utils[_0xf54e('0x33')][_0xf54e('0x34')];ut[_0xf54e('0x35')](_0xf54e('0x36'),_0x264a8f[_0xf54e('0x2c')]+'\x20is\x20not\x20active');}else{_0x264a8f[_0xf54e('0x32')]=utils['CAMPAIGN_STATUS'][_0xf54e('0x37')];ut['logger'](_0xf54e('0x36'),_0x264a8f[_0xf54e('0x2c')]+_0xf54e('0x38'));}}}Preview[_0xf54e('0xf')][_0xf54e('0x25')]=function(){var _0x3993e4=this;setInterval(function(){_0x3993e4[_0xf54e('0x39')]();},0x7cf);};Preview['prototype']['syncCampaigns']=function(){var _0x2f96b1=this[_0xf54e('0x3a')];this[_0xf54e('0x17')]+=0x1;for(var _0x16d00f in _0x2f96b1){if(_0x2f96b1[_0xf54e('0x3b')](_0x16d00f)&&(_0x2f96b1[_0x16d00f][_0xf54e('0x3c')]===_0xf54e('0x6')||_0x2f96b1[_0x16d00f][_0xf54e('0x3c')]===_0xf54e('0x3d'))&&_0x2f96b1[_0x16d00f][_0xf54e('0x3e')]==='outbound'){if(this['clockClearZombieChannels']>0x7){this[_0xf54e('0x17')]=0x0;this[_0xf54e('0x3f')]();}}if(_0x2f96b1['hasOwnProperty'](_0x16d00f)&&_0x2f96b1[_0x16d00f][_0xf54e('0x3c')]===_0xf54e('0x6')&&_0x2f96b1[_0x16d00f][_0xf54e('0x3e')]===_0xf54e('0x40')){if(_0x2f96b1[_0x16d00f]['dialActive']){this['setMessage'](_0x2f96b1[_0x16d00f]);if(_0x2f96b1[_0x16d00f]['dialPreviewAutoRecallMe'])this[_0xf54e('0x41')](_0x2f96b1[_0x16d00f]);}else{notSendMessagesQueue(_0x2f96b1[_0x16d00f]);}}}};Preview[_0xf54e('0xf')][_0xf54e('0x42')]=function(_0x399e68){var _0x29dc39=this;this[_0xf54e('0x13')]['enqueue'](function(){if(!_['isNil'](_0x29dc39['actions'][_0x399e68])){loggerAction[_0xf54e('0x27')](_0xf54e('0x43'),_0x399e68,'Queue',_0x29dc39['actions'][_0x399e68][_0xf54e('0x44')],_0xf54e('0x45'),JSON[_0xf54e('0x29')](_0x29dc39['campaignsPreview'][_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x44')]]['originated']),_0xf54e('0x46'),JSON[_0xf54e('0x29')](_0x29dc39[_0xf54e('0x3a')][_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x44')]][_0xf54e('0x2f')]),JSON['stringify'](_0x29dc39['actions'][_0x399e68][_0xf54e('0x47')]),JSON[_0xf54e('0x29')](_[_0xf54e('0x48')](_0x29dc39['actions'][_0x399e68],[_0xf54e('0x49'),_0xf54e('0x4a'),_0xf54e('0x4b'),_0xf54e('0x4c')])));return ami[_0xf54e('0x4d')]({'action':_0xf54e('0x4e'),'channel':_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x4f')]})[_0xf54e('0x50')](function(_0x2087b3){if(_0x2087b3[_0xf54e('0x32')]===_0xf54e('0x51')){setTimeout(function(){if(_0x29dc39[_0xf54e('0x15')][_0x399e68]){ut[_0xf54e('0x52')](_0x29dc39[_0xf54e('0x3a')][_0x29dc39['actions'][_0x399e68]['queue']],'[clearZombieChannel]');if(_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x47')]===!![]){ut['decrementTalkink'](_0x29dc39[_0xf54e('0x3a')][_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x44')]],'[clearZombieChannel]');ut[_0xf54e('0x53')](_0xf54e('0x54')+_0x399e68,_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x44')]);}ut[_0xf54e('0x53')](_0xf54e('0x55')+_0x399e68,_0x29dc39[_0xf54e('0x15')][_0x399e68][_0xf54e('0x44')]);delete _0x29dc39[_0xf54e('0x15')][_0x399e68];}},0x2328);}});}});};Preview['prototype'][_0xf54e('0x3f')]=function(){var _0x3447fd=this;loggerAction[_0xf54e('0x27')](_0xf54e('0x56'),_[_0xf54e('0x57')](this[_0xf54e('0x15')]));for(var _0x52c47d in this[_0xf54e('0x15')]){if(_0x3447fd['actions'][_0xf54e('0x3b')](_0x52c47d)){_0x3447fd['clearZombieChannel'](_0x52c47d);}}};Preview[_0xf54e('0xf')][_0xf54e('0x41')]=function(_0x2e08b4){var _0x57371d=this;rpcDb[_0xf54e('0x58')](_0x2e08b4['id'],ut[_0xf54e('0x59')](this[_0xf54e('0x16')]))[_0xf54e('0x5a')](function(_0x3a5a87){if(!_['isNil'](_0x3a5a87)){for(var _0x427799=0x0;_0x427799<_0x3a5a87[_0xf54e('0x5b')];_0x427799+=0x1){if(ut[_0xf54e('0x5c')](_0x3a5a87[_0x427799][_0xf54e('0x5d')])<_0x2e08b4['dialRecallMeTimeout']*0x3c){if(_0x3a5a87[_0x427799][_0xf54e('0x5e')]&&!_0x3a5a87[_0x427799][_0xf54e('0x5e')]['voicePause']){_0x57371d[_0xf54e('0x5f')](_0x3a5a87[_0x427799]['id'])[_0xf54e('0x5a')](ut[_0xf54e('0x60')](_0xf54e('0x61')))['catch'](ut[_0xf54e('0x60')](_0xf54e('0x61')));}else{rpcDb[_0xf54e('0x62')](_0x3a5a87[_0x427799]['id']);}}else{var _0xb4654f=new Action(_0x3a5a87[_0x427799],_0x2e08b4);_0xb4654f[_0xf54e('0x63')]=moment()[_0xf54e('0x2a')](_0xf54e('0x64'));_0x2e08b4[_0xf54e('0x65')]+=0x1;ut[_0xf54e('0x66')](_0xb4654f,0x17,_0xf54e('0x67'));if(_0x2e08b4[_0xf54e('0x68')]){rpcDb[_0xf54e('0x69')](ut[_0xf54e('0x6a')](_0x3a5a87[_0x427799]));rpcDb[_0xf54e('0x6b')](_0xb4654f,_0xf54e('0x6c'));}else{ut[_0xf54e('0x66')](_0xb4654f,0x16,_0xf54e('0x6d'));rpcDb[_0xf54e('0x6b')](_0xb4654f,_0xf54e('0x6e'));rpcDb[_0xf54e('0x6f')](_0xb4654f,'[HistoryRecallClose]');}}}}})['catch'](ut[_0xf54e('0x60')](_0xf54e('0x70')));};Preview[_0xf54e('0xf')][_0xf54e('0x71')]=function(_0xba297c){_0xba297c[_0xf54e('0x2d')]=!![];if(ut[_0xf54e('0x72')](_0xba297c[_0xf54e('0x73')])){_0xba297c[_0xf54e('0x32')]=utils[_0xf54e('0x33')][_0xf54e('0x74')];}else if(!ut['isActive'](_0xba297c[_0xf54e('0x75')])){_0xba297c[_0xf54e('0x32')]=utils[_0xf54e('0x33')][_0xf54e('0x34')];}else if(!this[_0xf54e('0x76')](_0xba297c[_0xf54e('0x77')])){if(!this[_0xf54e('0x76')](_0xba297c['TrunkBackup'])){_0xba297c[_0xf54e('0x32')]=utils[_0xf54e('0x33')][_0xf54e('0x78')];}else{_0xba297c['message']=utils[_0xf54e('0x33')]['ACTIVE'];}}else{_0xba297c[_0xf54e('0x32')]=utils[_0xf54e('0x33')][_0xf54e('0x79')];}};Preview['prototype'][_0xf54e('0x7a')]=function(_0x30d10d,_0x2096e5,_0x4e5059){var _0x3744a4=this;var _0x2ec72a=this[_0xf54e('0x15')][_0x2096e5];var _0x55d57f=this['campaignsPreview'][_0x2ec72a[_0xf54e('0x44')]];var _0x9ab4c4;var _0x4f17dd=![];var _0x29743e=0x2;var _0x49fd97=0x3;if(_0x55d57f){switch(_0x4e5059){case'1':_0x55d57f[_0xf54e('0x7b')]+=0x1;_0x2ec72a['countnosuchnumberretry']+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x0,_0xf54e('0x7e'));ami[_0xf54e('0x26')](_0xf54e('0x7f'),ut['buildObj'](_0x2ec72a,'nosuchnumber'));rpcDb[_0xf54e('0x6b')](_0x2ec72a,_0xf54e('0x80'));_0x3744a4['verifyAdditionalPhones'](_0x2ec72a,'0',_0x55d57f)['then'](function(_0x2a5e54){_0x4f17dd=_0x2a5e54['additional']==0x1;_0x29743e=_0x55d57f[_0xf54e('0x81')];_0x49fd97=_0x55d57f[_0xf54e('0x82')];if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f[_0xf54e('0x83')]){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0x86'));}else{if(_0x2ec72a[_0xf54e('0x87')]>=_0x55d57f[_0xf54e('0x88')]){rpcDb[_0xf54e('0x6f')](_0x2ec72a,_0xf54e('0x86'));}else{rpcDb[_0xf54e('0x89')](ut[_0xf54e('0x8a')](_0x2ec72a,'countnosuchnumberretry',_0x55d57f[_0xf54e('0x81')]),_0x2ec72a[_0xf54e('0x8b')],_0x2ec72a[_0xf54e('0x8c')]);}}delete this[_0xf54e('0x15')][_0x30d10d[_0xf54e('0x8d')]];}else{_0x2ec72a['countnosuchnumberretry']++;logger[_0xf54e('0x27')](_0xf54e('0x8e'),_0x2ec72a['countnosuchnumberretry']);logger['info']('id',_0x2ec72a[_0xf54e('0x8f')]);_0x3744a4['incrementPreviewCounters']({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countnosuchnumberretry':_0x2ec72a[_0xf54e('0x87')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)['then'](function(){});});}});break;case _0xf54e('0x91'):var _0x5cdb8c=moment()[_0xf54e('0x2a')](_0xf54e('0x64'));_0x2ec72a[_0xf54e('0x92')]=_0x5cdb8c;_0x2ec72a['answertime']=_0x5cdb8c;_0x2ec72a[_0xf54e('0x47')]=!![];_0x55d57f['pTalking']+=0x1;logger[_0xf54e('0x27')](_0xf54e('0x93'),_0x2ec72a['uniqueid'],_0xf54e('0x94'),_0x55d57f['name'],_0xf54e('0x46'),_0x55d57f[_0xf54e('0x2f')]);ami[_0xf54e('0x26')](_0xf54e('0x95'),ut[_0xf54e('0x96')](_0x2ec72a,'connect',this[_0xf54e('0x3a')][_0x2ec72a[_0xf54e('0x44')]]));if(_0x55d57f['acw']){ami[_0xf54e('0x26')](_0xf54e('0x97'),ut['buildAcw'](_0x2ec72a));}break;case'16':ami[_0xf54e('0x26')](_0xf54e('0x98'),ut[_0xf54e('0x96')](_0x2ec72a,'complete',this[_0xf54e('0x3a')][_0x2ec72a['queue']]));emitVoiceQueueChannelRemove(ut[_0xf54e('0x96')](_0x2ec72a,_0xf54e('0x99')));_0x55d57f['outboundAnswerCallsDay']+=0x1;_0x55d57f[_0xf54e('0x9a')]+=0x1;_0x55d57f[_0xf54e('0x9b')]+=0x1;ut[_0xf54e('0x9c')](_0x55d57f,_0xf54e('0x9d'));_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x4,_0xf54e('0x9e'));rpcDb[_0xf54e('0x6b')](_0x2ec72a,_0xf54e('0x9f'));rpcDb[_0xf54e('0x6f')](_0x2ec72a,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb[_0xf54e('0xa0')](_0x2ec72a);_0x55d57f[_0xf54e('0xa1')]+=_0x2ec72a[_0xf54e('0xa2')];_0x55d57f['sumBillable']+=_0x2ec72a[_0xf54e('0xa2')];logger[_0xf54e('0x27')](_0xf54e('0xa3'),_0x2ec72a[_0xf54e('0xa4')],_0xf54e('0x94'),_0x55d57f[_0xf54e('0x2c')],_0xf54e('0x46'),_0x55d57f['pTalking']);delete this[_0xf54e('0x15')][_0x30d10d[_0xf54e('0x8d')]];break;case _0xf54e('0xa5'):_0x55d57f['outboundBusyCallsDay']+=0x1;_0x2ec72a[_0xf54e('0xa6')]+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x5,'Busy');_0x29743e=_0x55d57f['dialBusyRetryFrequency'];_0x49fd97=_0x55d57f[_0xf54e('0x82')];ami[_0xf54e('0x26')](_0xf54e('0xa7'),ut[_0xf54e('0x96')](_0x2ec72a,_0xf54e('0xa8')));rpcDb[_0xf54e('0x6b')](_0x2ec72a,_0xf54e('0xa9'));_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'5',_0x55d57f)[_0xf54e('0x5a')](function(_0x205b47){_0x4f17dd=_0x205b47['additional']==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f[_0xf54e('0x83')]){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb['createCustomerFinal'](_0x9ab4c4,_0xf54e('0xab'));}else{if(_0x2ec72a[_0xf54e('0xa6')]>=_0x55d57f[_0xf54e('0xac')]){rpcDb[_0xf54e('0x6f')](_0x2ec72a,'[callProgressDetectingCustomer][logBusy]');}else{rpcDb[_0xf54e('0x89')](ut[_0xf54e('0x8a')](_0x2ec72a,_0xf54e('0xa6'),_0x55d57f['dialBusyRetryFrequency']),_0x2ec72a['unlockAgent'],_0x2ec72a[_0xf54e('0x8c')]);}}}else{_0x2ec72a[_0xf54e('0xa6')]++;_0x3744a4[_0xf54e('0xad')]({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countbusyretry':_0x2ec72a[_0xf54e('0xa6')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});break;case _0xf54e('0xae'):_0x55d57f['outboundNoAnswerCallsDay']+=0x1;_0x2ec72a[_0xf54e('0xaf')]+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x3,_0xf54e('0xb0'));_0x29743e=_0x55d57f[_0xf54e('0xb1')];_0x49fd97=_0x55d57f[_0xf54e('0x82')];var _0x9a8f4f=ut[_0xf54e('0xb2')](_0x2ec72a,_0x55d57f);ami[_0xf54e('0x26')](_0xf54e('0xb3'),_0x9a8f4f);rpcDb[_0xf54e('0x6b')](_0x2ec72a,'[callProgressDetectingCustomer][logNoAnswer]');_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'3',_0x55d57f)[_0xf54e('0x5a')](function(_0x59acbc){_0x4f17dd=_0x59acbc['additional']==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f[_0xf54e('0x83')]){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0xb4'));}else{if(_0x2ec72a[_0xf54e('0xaf')]>=_0x55d57f[_0xf54e('0xb5')]){rpcDb[_0xf54e('0x6f')](_0x2ec72a,'[callProgressDetectingCustomer][logNoAnswer]');}else{rpcDb[_0xf54e('0x89')](ut[_0xf54e('0x8a')](_0x2ec72a,_0xf54e('0xaf'),_0x55d57f['dialNoAnswerRetryFrequency']),_0x2ec72a[_0xf54e('0x8b')],_0x2ec72a['activeContact']);}}}else{_0x2ec72a[_0xf54e('0xaf')]++;_0x3744a4['incrementPreviewCounters']({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countnoanswerretry':_0x2ec72a[_0xf54e('0xaf')]}})['then'](function(){_0x3744a4['swapAdditionalPhones'](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});break;case _0xf54e('0xb6'):_0x55d57f[_0xf54e('0xb7')]+=0x1;_0x2ec72a[_0xf54e('0xb8')]+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut['totalGlobal'](_0x2ec72a);ut['logCustomer'](_0x2ec72a,0x8,_0xf54e('0xb9'));_0x29743e=_0x55d57f[_0xf54e('0xba')];_0x49fd97=_0x55d57f[_0xf54e('0x82')];ami[_0xf54e('0x26')](_0xf54e('0xbb'),ut[_0xf54e('0x96')](_0x2ec72a,_0xf54e('0xbc')));rpcDb[_0xf54e('0x6b')](_0x2ec72a,_0xf54e('0xbd'));_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'8',_0x55d57f)['then'](function(_0x31e699){_0x4f17dd=_0x31e699[_0xf54e('0xbe')]==0x1;if(!_0x4f17dd){if(ut['totalGlobal'](_0x2ec72a)>=_0x55d57f['dialGlobalMaxRetry']){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0xbf'));}else{if(_0x2ec72a[_0xf54e('0xb8')]>=_0x55d57f['dialCongestionMaxRetry']){rpcDb[_0xf54e('0x6f')](_0x2ec72a,_0xf54e('0xbd'));}else{rpcDb[_0xf54e('0x89')](ut[_0xf54e('0x8a')](_0x2ec72a,'countcongestionretry',_0x55d57f[_0xf54e('0xc0')]),_0x2ec72a[_0xf54e('0x8b')],_0x2ec72a[_0xf54e('0x8c')]);}}}else{_0x2ec72a[_0xf54e('0xb8')]++;_0x3744a4['incrementPreviewCounters']({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countcongestionretry':_0x2ec72a[_0xf54e('0xb8')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});break;case'CANCEL':_0x55d57f[_0xf54e('0xc1')]+=0x1;_0x2ec72a['countagentrejectretry']+=0x1;_0x2ec72a['countglobal']=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x14,_0xf54e('0xc2'));_0x29743e=_0x55d57f[_0xf54e('0xc3')];_0x49fd97=_0x55d57f[_0xf54e('0x82')];ami[_0xf54e('0x26')](_0xf54e('0xc4'),ut[_0xf54e('0x96')](_0x2ec72a,_0xf54e('0xc5')));rpcDb['createCustomerHistory'](_0x2ec72a,_0xf54e('0xc6'));_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'20',_0x55d57f)[_0xf54e('0x5a')](function(_0x971a3e){_0x4f17dd=_0x971a3e[_0xf54e('0xbe')]==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f['dialGlobalMaxRetry']){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0x14,_0xf54e('0xc2'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0xc7'));}else{if(_0x2ec72a[_0xf54e('0xc8')]>=_0x55d57f[_0xf54e('0xc9')]){rpcDb['createCustomerFinal'](_0x2ec72a,_0xf54e('0xc7'));}else{rpcDb[_0xf54e('0x89')](ut[_0xf54e('0x8a')](_0x2ec72a,_0xf54e('0xc8'),_0x55d57f['dialAgentRejectRetryFrequency']),_0x2ec72a['unlockAgent'],_0x2ec72a[_0xf54e('0x8c')]);}}}else{_0x2ec72a[_0xf54e('0xaf')]++;_0x3744a4[_0xf54e('0xad')]({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countnoanswerretry':_0x2ec72a[_0xf54e('0xaf')]}})[_0xf54e('0x5a')](function(){_0x3744a4['swapAdditionalPhones'](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});break;case _0xf54e('0xca'):_0x55d57f[_0xf54e('0xcb')]+=0x1;_0x2ec72a[_0xf54e('0xcc')]+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut['logCustomer'](_0x2ec72a,0xb,_0xf54e('0xcd'));rpcDb['createCustomerHistory'](_0x2ec72a,_0xf54e('0xce'));_0x3744a4['verifyAdditionalPhones'](_0x2ec72a,'11',_0x55d57f)[_0xf54e('0x5a')](function(_0x27c584){_0x4f17dd=_0x27c584[_0xf54e('0xbe')]==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f[_0xf54e('0x83')]){_0x9ab4c4=ut['cloneAction'](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,'[callProgressDetectingCustomer][logAbandoned]');}else{if(_0x2ec72a[_0xf54e('0xcf')]>=_0x55d57f[_0xf54e('0xd0')]){rpcDb[_0xf54e('0x6f')](_0x2ec72a,_0xf54e('0xce'));}else{rpcDb['rescheduleContact'](ut[_0xf54e('0x8a')](_0x2ec72a,_0xf54e('0xcc'),_0x55d57f['dialAbandonedRetryFrequency']),_0x2ec72a[_0xf54e('0x8b')],_0x2ec72a['activeContact']);}}}else{_0x2ec72a['countnoanswerretry']++;_0x3744a4[_0xf54e('0xad')]({'id':_0x2ec72a['idContact'],'field':{'countnoanswerretry':_0x2ec72a[_0xf54e('0xaf')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});break;case'18':_0x55d57f[_0xf54e('0xd1')]+=0x1;_0x2ec72a['countmachineretry']+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0x12,_0x30d10d[_0xf54e('0xd2')]||_0x30d10d['dialstatus']);ami[_0xf54e('0x26')]('custom:amd',ut[_0xf54e('0x96')](_0x2ec72a,_0xf54e('0xd3')));rpcDb['createCustomerHistory'](_0x2ec72a,_0xf54e('0xd4'));_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'18',_0x55d57f)[_0xf54e('0x5a')](function(_0x23a151){_0x4f17dd=_0x23a151['additional']==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f[_0xf54e('0x83')]){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0x12,'Global');rpcDb['createCustomerFinal'](_0x9ab4c4,_0xf54e('0xd4'));}else{rpcDb['createCustomerFinal'](_0x2ec72a,'[callProgressDetectingCustomer][hangupInAMD]');}}else{_0x2ec72a['countnoanswerretry']++;_0x3744a4[_0xf54e('0xad')]({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countnoanswerretry':_0x2ec72a[_0xf54e('0xaf')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});delete this[_0xf54e('0x15')][_0x30d10d[_0xf54e('0x8d')]];break;case'19':_0x55d57f[_0xf54e('0xd1')]+=0x1;_0x2ec72a['countglobal']=ut[_0xf54e('0x7d')](_0x2ec72a);ut['logCustomer'](_0x2ec72a,0x13,_0x30d10d[_0xf54e('0xd2')]||_0x30d10d[_0xf54e('0xd5')]);ami['emit'](_0xf54e('0xd6'),ut['buildObj'](_0x2ec72a,_0xf54e('0xd3')));rpcDb[_0xf54e('0x6b')](_0x2ec72a,_0xf54e('0xd7'));_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'18',_0x55d57f)[_0xf54e('0x5a')](function(_0x3c499e){_0x4f17dd=_0x3c499e['additional']==0x1;if(!_0x4f17dd){if(ut['totalGlobal'](_0x2ec72a)>=_0x55d57f['dialGlobalMaxRetry']){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,'Global');rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0xd7'));}else{rpcDb[_0xf54e('0x6f')](_0x2ec72a,_0xf54e('0xd7'));}}else{_0x2ec72a[_0xf54e('0xaf')]++;_0x3744a4['incrementPreviewCounters']({'id':_0x2ec72a[_0xf54e('0x8f')],'field':{'countnoanswerretry':_0x2ec72a[_0xf54e('0xaf')]}})[_0xf54e('0x5a')](function(){_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});});}});delete this[_0xf54e('0x15')][_0x30d10d['linkedid']];break;default:if(_0x2ec72a[_0xf54e('0x47')]){ut[_0xf54e('0x9c')](_0x55d57f,_0xf54e('0xd8'));ut[_0xf54e('0x53')](_0xf54e('0xd9')+_0x55d57f['name'],_0x30d10d);}_0x55d57f[_0xf54e('0xd1')]+=0x1;_0x2ec72a[_0xf54e('0x7c')]=ut[_0xf54e('0x7d')](_0x2ec72a);ut[_0xf54e('0x66')](_0x2ec72a,0xc,_0x30d10d[_0xf54e('0xd2')]||_0x30d10d[_0xf54e('0xd5')]);_0x29743e=_0x55d57f[_0xf54e('0xc3')];_0x49fd97=_0x55d57f[_0xf54e('0x82')];rpcDb[_0xf54e('0x6b')](_0x2ec72a,'[callProgressDetectingCustomer][logUnknown]');_0x3744a4[_0xf54e('0xaa')](_0x2ec72a,'20',_0x55d57f)[_0xf54e('0x5a')](function(_0x47d309){_0x4f17dd=_0x47d309['additional']==0x1;if(!_0x4f17dd){if(ut[_0xf54e('0x7d')](_0x2ec72a)>=_0x55d57f['dialGlobalMaxRetry']){_0x9ab4c4=ut[_0xf54e('0x84')](_0x2ec72a,0xf,_0xf54e('0x85'));rpcDb[_0xf54e('0x6f')](_0x9ab4c4,_0xf54e('0xda'));}else{rpcDb['createCustomerFinal'](_0x2ec72a,_0xf54e('0xda'));}delete this[_0xf54e('0x15')][_0x30d10d['linkedid']];}else{_0x3744a4[_0xf54e('0x90')](_0x2ec72a,_0x29743e,_0x49fd97)[_0xf54e('0x5a')](function(){});}});}if(!(_0x2ec72a[_0xf54e('0x47')]&&_0x4e5059==='16')){ut[_0xf54e('0x52')](_0x55d57f,_0xf54e('0xdb'));logger[_0xf54e('0x27')](_0xf54e('0xdc'),_0x2ec72a[_0xf54e('0xa4')],_0xf54e('0x94'),_0x55d57f[_0xf54e('0x2c')],_0xf54e('0x45'),_0x55d57f['originated']);}if(_0x4e5059!=='ANSWER'){delete this[_0xf54e('0x15')][_0x30d10d[_0xf54e('0x8d')]];delete this[_0xf54e('0x15')][_0x30d10d[_0xf54e('0xdd')]];}_0x55d57f[_0xf54e('0xde')]=!![];}};Preview['prototype'][_0xf54e('0xdf')]=function(_0x24b324,_0x3a9def,_0x213dc5){if(_['isUndefined'](_0x3a9def)&&_0xf54e('0xe0')!==typeof _0x3a9def){return;}if(_[_0xf54e('0xe1')](_0x213dc5)&&_0xf54e('0xe0')!==typeof _0x213dc5){return;}switch(_0x213dc5[_0xf54e('0xe2')]){case'0':ut[_0xf54e('0xe3')](_0x24b324,0x0,_0xf54e('0x7e'));rpcDb[_0xf54e('0xe4')](_0x24b324,_0xf54e('0xe5'));break;case'3':ut[_0xf54e('0xe3')](_0x24b324,0x3,_0xf54e('0xb0'));rpcDb[_0xf54e('0xe4')](_0x24b324,_0xf54e('0xe6'));break;case'5':ut[_0xf54e('0xe3')](_0x24b324,0x5,_0xf54e('0xe7'));rpcDb['createAgentHistory'](_0x24b324,_0xf54e('0xe8'));break;case'8':ut['logAgent'](_0x24b324,0x8,'Congestion');rpcDb[_0xf54e('0xe4')](_0x24b324,_0xf54e('0xe9'));break;case'22':ut[_0xf54e('0xe3')](_0x24b324,0x16,_0xf54e('0xea'));rpcDb[_0xf54e('0xe4')](_0x24b324,_0xf54e('0xeb'));break;default:ut[_0xf54e('0xe3')](_0x24b324,0xc,_0x213dc5[_0xf54e('0xe2')]);rpcDb[_0xf54e('0xe4')](_0x24b324,_0xf54e('0xe9'));}ut[_0xf54e('0x52')](_0x3a9def,_0xf54e('0xec'));logger[_0xf54e('0x27')]('[originated][decrement][callProgressDetectingAgent]',_0x24b324[_0xf54e('0xa4')],_0xf54e('0x94'),_0x3a9def[_0xf54e('0x2c')],_0xf54e('0x45'),_0x3a9def[_0xf54e('0x2e')]);delete this['actions'][_0x24b324['uniqueid']];};Preview[_0xf54e('0xf')][_0xf54e('0xaa')]=function(_0x4b6f61,_0x5f0853,_0x3250d0){return cmHopperAdditionalPhone['verifyAdditionalPhones'](_0x4b6f61,_0x5f0853,_0x3250d0)[_0xf54e('0x50')](logger[_0xf54e('0x27')](_0xf54e('0xed')));};Preview[_0xf54e('0xf')][_0xf54e('0x90')]=function(_0x1f9d18,_0x50bff9,_0x39fc7d){return cmHopperAdditionalPhone[_0xf54e('0x90')](_0x1f9d18,_0x50bff9,_0x39fc7d)['catch'](logger[_0xf54e('0x27')](_0xf54e('0xee')));};Preview['prototype'][_0xf54e('0xad')]=function(_0x44b7bd){return Promise[_0xf54e('0xef')]()['then'](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x44b7bd))[_0xf54e('0x50')](logger[_0xf54e('0x27')]('[incrementPreviewCounters]\x20'));};Preview['prototype']['checkInBlack']=function(_0x39027b,_0x32b55f,_0x11fb0c,_0x5072aa,_0x187b1c){var _0x459172=this;return new Promise(function(_0x28d019,_0x3da354){if(_[_0xf54e('0xf0')](_0x32b55f)||_['isNil'](_0x32b55f['Contact'])||_['isNil'](_0x32b55f['phone'])||_['isNil'](_0x32b55f[_0xf54e('0x4b')])){_0x3da354(ut['message'](_0xf54e('0xf1'),_0x5072aa,_0x187b1c));return;}var _0x3e0b67=uuid['v4']();var _0x484691=_0x459172[_0xf54e('0x3a')][_0x32b55f['Queue'][_0xf54e('0x2c')]];var _0x400dc6=_0x11fb0c?_0x459172[_0xf54e('0x16')][_0x11fb0c]['id']:undefined;_0x459172[_0xf54e('0x15')][_0x3e0b67]=new Action(_0x32b55f,_0x484691,_0x3e0b67,_0x11fb0c,_0x400dc6);var _0x3c0755=_0x459172[_0xf54e('0x15')][_0x3e0b67];_0x3c0755[_0xf54e('0x8b')]=_0x5072aa;_0x3c0755['activeContact']=_0x187b1c;_0x3c0755[_0xf54e('0xf2')]=_0x11fb0c;if(_[_0xf54e('0xf3')](_0x39027b)){_0x459172[_0xf54e('0xf4')](_0x3c0755,_0x484691,_0x32b55f,_0x11fb0c)[_0xf54e('0x5a')](function(_0x3733f5){logger['info'](_0xf54e('0xf5'),_0xf54e('0xf6')+_0x3c0755[_0xf54e('0x44')]+_0xf54e('0xf7')+_0x3c0755[_0xf54e('0x8f')],JSON[_0xf54e('0x29')](_0x3733f5));ami['emit']('custom:agentcalled',ut['buildObj'](_0x3c0755,_0xf54e('0xf8'),_0x459172[_0xf54e('0x3a')][_0x3c0755[_0xf54e('0x44')]]));_0x28d019(ut[_0xf54e('0x32')](_0xf54e('0xf9')));})['catch'](function(_0x31b2d6){ut[_0xf54e('0x35')]('[Preview][execCall][failure]',_0x31b2d6);_0x3da354(ut[_0xf54e('0x32')](_0xf54e('0xfa'),_0x5072aa,_0x187b1c));});}else{_0x484691[_0xf54e('0xfb')]+=0x1;ut['logBlacklist'](_0x3c0755);rpcDb[_0xf54e('0xfc')](_0x3c0755,_0xf54e('0xfd'));delete _0x459172[_0xf54e('0x15')][_0x3e0b67];_0x3da354(ut[_0xf54e('0x32')](_0xf54e('0xfe'),_0x5072aa,_0x187b1c));}});};Preview[_0xf54e('0xf')][_0xf54e('0x76')]=function(_0x370e59){return!_['isNil'](_0x370e59)&&!_[_0xf54e('0xf0')](_0x370e59['name'])&&!_[_0xf54e('0xf0')](_0x370e59[_0xf54e('0xff')])&&_0x370e59[_0xf54e('0xff')]&&!_[_0xf54e('0xf0')](this[_0xf54e('0x100')][util[_0xf54e('0x2a')](_0xf54e('0x101'),_0x370e59['name'])])&&!_['isNil'](this['trunks'][util[_0xf54e('0x2a')]('SIP/%s',_0x370e59[_0xf54e('0x2c')])]['status'])&&(this[_0xf54e('0x100')][util[_0xf54e('0x2a')]('SIP/%s',_0x370e59[_0xf54e('0x2c')])][_0xf54e('0x4e')]===_0xf54e('0x102')||this[_0xf54e('0x100')][util[_0xf54e('0x2a')](_0xf54e('0x101'),_0x370e59[_0xf54e('0x2c')])][_0xf54e('0x4e')]===_0xf54e('0x103'));};Preview[_0xf54e('0xf')][_0xf54e('0x5f')]=function(_0x5bc7ed,_0x26e18f){return this[_0xf54e('0x104')](_0x5bc7ed,_0x26e18f)[_0xf54e('0x5a')](function(_0x52226a){return _[_0xf54e('0x48')](_0x52226a,['message']);})[_0xf54e('0x50')](function(_0xc0d72a){if(_0xc0d72a[_0xf54e('0x105')]){rpcDb[_0xf54e('0x106')](_0x5bc7ed);}if(_0xc0d72a[_0xf54e('0xff')]){rpcDb[_0xf54e('0x62')](_0x5bc7ed);}throw _[_0xf54e('0x48')](_0xc0d72a,[_0xf54e('0x32')]);});};Preview[_0xf54e('0xf')][_0xf54e('0x104')]=function(_0x215277,_0x4a2222){var _0x50c424=this;var _0x47e3ae,_0x2bee3e;return rpcDb[_0xf54e('0x107')](_0x215277)[_0xf54e('0x5a')](function(_0x4c249a){if(!_[_0xf54e('0xf0')](_0x4c249a[0x0])){_0x2bee3e=_0x4c249a[0x0][_0xf54e('0x108')]?![]:!![];_0x47e3ae=_0x4c249a[0x0]['recallme']?!![]:![];_0x47e3ae=_0x4a2222?!![]:_0x47e3ae;}var _0x405254=_0x50c424[_0xf54e('0x109')](_0x4c249a);if(_0x405254[_0xf54e('0x10a')]){rpcDb[_0xf54e('0x10b')](_[_0xf54e('0x48')](_0x4c249a[0x0],[_0xf54e('0x4b'),_0xf54e('0x10c')]))['then'](function(_0x5369cd){_0x50c424[_0xf54e('0x10d')](_0x5369cd,_0x4c249a[0x0],_0x4a2222,_0x2bee3e,_0x47e3ae)[_0xf54e('0x5a')](function(_0x2ac04e){return _0x2ac04e;})[_0xf54e('0x50')](function(_0x53ae5c){throw _0x53ae5c;});})[_0xf54e('0x50')](function(_0x37c370){ut['logger'](_0xf54e('0x10e'),_0x37c370);throw ut['message'](_0xf54e('0x10f'),_0x2bee3e,_0x47e3ae);});}else{throw ut[_0xf54e('0x32')](_0x405254[_0xf54e('0x32')],_0x2bee3e,_0x47e3ae);}})[_0xf54e('0x50')](function(_0x4fb1ab){ut[_0xf54e('0x35')]('[Preview][getContactPreview]',_0x4fb1ab);throw ut[_0xf54e('0x32')](_0xf54e('0x10f'),![],!![]);});};Preview[_0xf54e('0xf')][_0xf54e('0x109')]=function(_0x5221d0){if(_['isNil'](_0x5221d0)||_[_0xf54e('0xf3')](_0x5221d0)||!_[_0xf54e('0xf0')](_0x5221d0[0x0][_0xf54e('0x5e')])&&_['isNil'](_0x5221d0[0x0][_0xf54e('0x5e')][_0xf54e('0x2c')])){ut['logger'](_0xf54e('0x110'),_0x5221d0);return{'isValid':![],'message':_0xf54e('0x111')};}var _0x3ea69c=this[_0xf54e('0x3a')][_0x5221d0[0x0][_0xf54e('0x112')][_0xf54e('0x2c')]];_0x3ea69c['message']=utils[_0xf54e('0x33')][_0xf54e('0x79')];if(_[_0xf54e('0xf0')](_0x3ea69c)){ut[_0xf54e('0x35')](_0xf54e('0x113'),_0x3ea69c);return{'isValid':![],'message':_0xf54e('0x114')};}if(!this[_0xf54e('0x76')](_0x3ea69c[_0xf54e('0x77')])){ut[_0xf54e('0x35')](_0xf54e('0x115'),_0xf54e('0x116')+_0x3ea69c[_0xf54e('0x2c')]+_0xf54e('0x117'));if(!this[_0xf54e('0x76')](_0x3ea69c[_0xf54e('0x118')])){ut[_0xf54e('0x35')](_0xf54e('0x115'),_0x3ea69c['name']+_0xf54e('0x119'));return{'isValid':![],'message':_0xf54e('0x11a')};}}if(!ut[_0xf54e('0x11b')](_0x3ea69c['dialActive'])){ut[_0xf54e('0x35')](_0xf54e('0x11c'),_0x3ea69c[_0xf54e('0x2c')]+_0xf54e('0x11d'));return{'isValid':![],'message':_0xf54e('0x116')+_0x3ea69c['name']+_0xf54e('0x11d')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview[_0xf54e('0xf')][_0xf54e('0xf4')]=function(_0x505c0f,_0xcdc5ec,_0x171516,_0x2df876){var _0x4026ea=this;return new Promise(function(_0x1a0fc0,_0x459bbb){var _0x3770f3=_0x505c0f[_0xf54e('0xa4')];var _0x1ad56e=_0x4026ea['isTrunkReachable'](_0xcdc5ec[_0xf54e('0x77')])?util['format'](_0xf54e('0x11e'),_0xcdc5ec[_0xf54e('0x77')]['name'],_[_0xf54e('0xf0')](_0xcdc5ec['dialPrefix'])?'':_0xcdc5ec[_0xf54e('0x11f')][_0xf54e('0x120')]()||'',_0xcdc5ec['dialCutDigit']>0x0?_0x171516[_0xf54e('0x10c')][_0xf54e('0x121')](_0xcdc5ec['dialCutDigit']):_0x171516['phone']):util['format'](_0xf54e('0x11e'),_[_0xf54e('0xf0')](_0xcdc5ec[_0xf54e('0x118')])?_0xcdc5ec[_0xf54e('0x77')][_0xf54e('0x2c')]:_0xcdc5ec[_0xf54e('0x118')][_0xf54e('0x2c')],_[_0xf54e('0xf0')](_0xcdc5ec['dialPrefix'])?'':_0xcdc5ec['dialPrefix'][_0xf54e('0x120')]()||'',_0xcdc5ec[_0xf54e('0x122')]>0x0?_0x171516[_0xf54e('0x10c')][_0xf54e('0x121')](_0xcdc5ec[_0xf54e('0x122')]):_0x171516['phone']);var _0x3aa45f=_0x4026ea['isTrunkReachable'](_0xcdc5ec['Trunk'])?ut[_0xf54e('0x123')](_0xcdc5ec[_0xf54e('0x77')][_0xf54e('0x124')],_0xcdc5ec[_0xf54e('0x125')],_0xcdc5ec[_0xf54e('0x126')]>0x0?ut[_0xf54e('0x127')](_0xcdc5ec[_0xf54e('0x128')],_0xcdc5ec['dialRandomLastDigitCallerIdNumber']):_0xcdc5ec[_0xf54e('0x128')]):ut[_0xf54e('0x123')](_[_0xf54e('0xf0')](_0xcdc5ec[_0xf54e('0x118')])?_0xcdc5ec[_0xf54e('0x77')]['callerid']:_0xcdc5ec[_0xf54e('0x118')][_0xf54e('0x124')],_0xcdc5ec[_0xf54e('0x125')],_0xcdc5ec[_0xf54e('0x126')]>0x0?ut[_0xf54e('0x127')](_0xcdc5ec['dialOriginateCallerIdNumber'],_0xcdc5ec['dialRandomLastDigitCallerIdNumber']):_0xcdc5ec[_0xf54e('0x128')]);if(_0x3aa45f){_0x505c0f[_0xf54e('0x129')]=ut[_0xf54e('0x12a')](_0x3aa45f);_0x505c0f['originatecalleridnum']=ut[_0xf54e('0x12b')](_0x3aa45f);}var _0x2c2833=ut[_0xf54e('0x12c')](_0xcdc5ec,_0x171516,_0x1ad56e,_0x3aa45f,_0x3770f3,_0x505c0f);_[_0xf54e('0x12d')](_0x505c0f,ut['toLowerVariables'](_0x2c2833));_0x505c0f[_0xf54e('0x63')]=moment()[_0xf54e('0x2a')](_0xf54e('0x64'));_0xcdc5ec['variables']=_0x2c2833;var _0x34db40=ut[_0xf54e('0x12e')](_0x505c0f,_0xcdc5ec,_0x2c2833,_0x505c0f[_0xf54e('0x8c')],_0x2df876);return ami[_0xf54e('0x4d')](_0x34db40)[_0xf54e('0x5a')](function(_0x123f93){_0xcdc5ec[_0xf54e('0x2e')]+=0x1;logger[_0xf54e('0x27')]('[originated][increment]',_0x3770f3,_0xf54e('0x94'),_0xcdc5ec[_0xf54e('0x2c')],_0xf54e('0x45'),_0xcdc5ec[_0xf54e('0x2e')]);_0x1a0fc0(_0x123f93);})['catch'](function(_0x47b07a){ut['logAgent'](_0x505c0f,0xe,'OriginateError');rpcDb[_0xf54e('0xe4')](_0x505c0f,_0xf54e('0x12f'));_0x459bbb(_0x47b07a);});});};Preview[_0xf54e('0xf')]['syncNewExten']=function(_0x5a84b8){if(this[_0xf54e('0x15')][_0x5a84b8['linkedid']]){this[_0xf54e('0x15')][_0x5a84b8['linkedid']][_0xf54e('0x4f')]=_0x5a84b8[_0xf54e('0x4f')];}};Preview[_0xf54e('0xf')]['syncOriginateResponse']=function(_0x14ead8){var _0x260b7a=this;var _0x1487be=this[_0xf54e('0x15')][_0x14ead8['actionid']];if(_0x1487be){if(_0x1487be[_0xf54e('0xf2')]&&this[_0xf54e('0x16')][_0x1487be[_0xf54e('0xf2')]]){ut[_0xf54e('0x130')](_0x1487be,this[_0xf54e('0x16')][_0x1487be[_0xf54e('0xf2')]]['name'],this[_0xf54e('0x16')][_0x1487be['lookAgent']]['id']);}var _0x4d406a=_[_0xf54e('0x131')](_0x1487be);_0x4d406a['responsetime']=moment()[_0xf54e('0x2a')](_0xf54e('0x64'));var _0x56411c=_0x260b7a['campaignsPreview'][_0x1487be[_0xf54e('0x44')]];if(ut['isFailure'](_0x14ead8[_0xf54e('0x132')])){if(_0x1487be[_0xf54e('0x8b')]){rpcDb['unlockContact'](_0x1487be[_0xf54e('0x8f')]);}if(_0x1487be['activeContact']){rpcDb[_0xf54e('0x62')](_0x1487be[_0xf54e('0x8f')]);}ami['emit'](_0xf54e('0x133'),ut[_0xf54e('0x96')](_0x1487be,_0xf54e('0x134'),this[_0xf54e('0x3a')][_0x1487be[_0xf54e('0x44')]]));this[_0xf54e('0xdf')](_0x4d406a,_0x56411c,_0x14ead8);}else{_0x1487be[_0xf54e('0x63')]=moment()[_0xf54e('0x2a')](_0xf54e('0x64'));ut['logAgent'](_0x4d406a,0x4,'Answer');rpcDb[_0xf54e('0xe4')](_0x4d406a,_0xf54e('0x135'));}}};Preview[_0xf54e('0xf')][_0xf54e('0x1b')]=function(_0x53d6cb){var _0x143b50=this[_0xf54e('0x15')][_0x53d6cb['linkedid']];var _0x3b25f4;if(_0x143b50){_0x3b25f4=this[_0xf54e('0x3a')][_0x143b50[_0xf54e('0x44')]];logger[_0xf54e('0x27')](_0xf54e('0x136'),_0x53d6cb[_0xf54e('0x8d')],_0xf54e('0x94'),_0x3b25f4[_0xf54e('0x2c')],_0xf54e('0x46'),_0x3b25f4[_0xf54e('0x2f')]);}if(this[_0xf54e('0x15')][_0x53d6cb['linkedid']]&&_0x53d6cb['linkedid']!==_0x53d6cb[_0xf54e('0xa4')]){if(_0x53d6cb[_0xf54e('0x137')]==='16'&&this[_0xf54e('0x15')][_0x53d6cb[_0xf54e('0x8d')]][_0xf54e('0x47')]){this[_0xf54e('0x7a')](_0x53d6cb,_0x53d6cb['linkedid'],_0x53d6cb[_0xf54e('0x137')]);}else if(this[_0xf54e('0x15')][_0x53d6cb['linkedid']][_0xf54e('0x47')]){logger[_0xf54e('0x27')](_0xf54e('0x138'),_0x53d6cb[_0xf54e('0x8d')],_0x53d6cb['cause'],'\x20Queue',_0x3b25f4[_0xf54e('0x2c')],_0xf54e('0x46'),_0x3b25f4[_0xf54e('0x2f')]);this[_0xf54e('0x7a')](_0x53d6cb,_0x53d6cb['linkedid'],_0x53d6cb['cause']);}}else if(_0x143b50&&_[_0xf54e('0xf0')](_0x143b50[_0xf54e('0x139')])&&_0x3b25f4[_0xf54e('0x13a')]&&_0x53d6cb['linkedid']===_0x53d6cb[_0xf54e('0xa4')]&&_[_0xf54e('0xf0')](_0x53d6cb[_0xf54e('0xe2')])&&_0x53d6cb[_0xf54e('0x137')]==='16'&&_0x53d6cb['channelstate']==='6'&&_[_0xf54e('0xe1')](_0x143b50['transfer'])){if(_0x143b50[_0xf54e('0x8b')]){rpcDb[_0xf54e('0x106')](_0x143b50[_0xf54e('0x8f')]);}if(_0x143b50[_0xf54e('0x8c')]){rpcDb['disableContact'](_0x143b50[_0xf54e('0x8f')]);}_0x53d6cb[_0xf54e('0xe2')]='22';this[_0xf54e('0xdf')](_0x143b50,_0x3b25f4,_0x53d6cb);}else if(_0x143b50&&_0x143b50['transfer']){if(_0x53d6cb[_0xf54e('0x137')]==='16'&&this[_0xf54e('0x15')][_0x53d6cb[_0xf54e('0x8d')]]['dialAnswer']){logger[_0xf54e('0x27')](_0xf54e('0x13b'),_0x53d6cb[_0xf54e('0x8d')],_0x53d6cb[_0xf54e('0x137')],_0xf54e('0x94'),_0x3b25f4[_0xf54e('0x2c')],_0xf54e('0x46'),_0x3b25f4[_0xf54e('0x2f')]);this[_0xf54e('0x7a')](_0x53d6cb,_0x53d6cb[_0xf54e('0x8d')],_0x53d6cb[_0xf54e('0x137')]);}else if(this[_0xf54e('0x15')][_0x53d6cb[_0xf54e('0x8d')]][_0xf54e('0x47')]){logger[_0xf54e('0x27')](_0xf54e('0x138'),_0x53d6cb[_0xf54e('0x8d')],_0x53d6cb[_0xf54e('0x137')],'\x20Queue',_0x3b25f4[_0xf54e('0x2c')],_0xf54e('0x46'),_0x3b25f4[_0xf54e('0x2f')]);this[_0xf54e('0x7a')](_0x53d6cb,_0x53d6cb[_0xf54e('0x8d')],_0x53d6cb[_0xf54e('0x137')]);}}};Preview[_0xf54e('0xf')][_0xf54e('0x13c')]=function(_0x429793){if(this[_0xf54e('0x15')][_0x429793[_0xf54e('0xdd')]]&&_0x429793[_0xf54e('0xdd')]!==_0x429793[_0xf54e('0x13d')]){this[_0xf54e('0x7a')](_0x429793,_0x429793[_0xf54e('0xdd')],_0x429793[_0xf54e('0xd5')]);}};Preview['prototype'][_0xf54e('0x1d')]=function(_0x28a3f8){if(this[_0xf54e('0x15')][_0x28a3f8[_0xf54e('0x8d')]]&&_0x28a3f8['linkedid']!==_0x28a3f8[_0xf54e('0xa4')]&&!this[_0xf54e('0x15')][_0x28a3f8['linkedid']][_0xf54e('0x47')]){if(_0x28a3f8[_0xf54e('0x137')]==='1'){this[_0xf54e('0x7a')](_0x28a3f8,_0x28a3f8[_0xf54e('0x8d')],_0x28a3f8[_0xf54e('0x137')]);}}};Preview[_0xf54e('0xf')][_0xf54e('0x13e')]=function(_0x22f8ad,_0x269670,_0x17801c){if(this['actions'][_0x22f8ad]){if(_[_0xf54e('0xf0')](this[_0xf54e('0x15')][_0x22f8ad][_0xf54e('0x13f')])){this[_0xf54e('0x15')][_0x22f8ad][_0xf54e('0x13f')]={};}this[_0xf54e('0x15')][_0x22f8ad][_0xf54e('0x13f')][_0x269670]=_0x17801c;}};Preview['prototype'][_0xf54e('0x21')]=function(_0x397e6c){try{if(!_[_0xf54e('0xf0')](_0x397e6c)){if(ut[_0xf54e('0x140')](_[_0xf54e('0x141')](_0x397e6c[_0xf54e('0x142')])[0x0])){this[_0xf54e('0x13e')](_0x397e6c[_0xf54e('0xa4')],_[_0xf54e('0x141')](_0x397e6c[_0xf54e('0x142')])[0x0],_0x397e6c['value']);}}}catch(_0xb1e536){logger[_0xf54e('0x143')]('[syncVarSet][Preview]',util['inspect'](_0xb1e536,{'showHidden':![],'depth':null}));}};Preview[_0xf54e('0xf')][_0xf54e('0x23')]=function(_0x232195){if(_0x232195){if(this[_0xf54e('0x15')][_0x232195[_0xf54e('0x144')]]){this[_0xf54e('0x15')][_0x232195[_0xf54e('0x144')]][_0xf54e('0x145')]=!![];}}};Preview[_0xf54e('0xf')][_0xf54e('0x146')]=function(_0x56b18a){if(_0x56b18a){if(this[_0xf54e('0x15')][_0x56b18a[_0xf54e('0x147')]]){this['actions'][_0x56b18a['transfererlinkedid']][_0xf54e('0x145')]=!![];}}};module[_0xf54e('0x148')]=Preview;