4e9d7995602560c06e7e56e3c7d6da118cbc1e31
[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 _0x5075=['[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','outboundAbandonedCallsDay','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','countabandonedretry','dialAbandonedRetryFrequency','outboundUnknownCallsDay','countmachineretry','dialstatus','[callProgressDetectingCustomer][hangupInAMD]','cause-txt','custom:amd','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','destlinkedid','isUndefined','object','reason','NoSuchNumber','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','NoAnswer','[callProgressDetectingAgent][logNoAnswer]','logAgent','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','resolve','[swapAdditionalPhone]\x20','[incrementPreviewCounters]\x20','checkInBlack','Contact','phone','Contact\x20is\x20undefined','execCall','[Preview][execCall][success]','Queue:\x20','called','Calling','[Preview][execCall][failure]','createHistory','Contact\x20in\x20black\x20List','SIP/%s','reachable','unmonitored','execRun','unlock','unlockContact','getContactPreview','recallme','validateContact','isValid','checkIsBlackList','Call\x20unsuccessful','isEmpty','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','campaign\x20Name:\x20','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','\x20Trunk\x20Backup\x20is\x20not\x20active','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialCutDigit','substring','trim','getCallerId','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','originatecalleridnum','variablesAction','OriginateError','[originateFailure][logOriginateFailure]','channel','actionid','lookAgent','logLookAgent','clone','response','custom:agentringnoanswer','rejected','callProgressDetectingAgent','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','destuniqueid','addVariable','variables','filterKey','variable','keys','value','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','syncBlindTransfer','transfererlinkedid','util','lodash','bluebird','uuid','moment','md5','ioredis','../../../config/logger','preview','./rpcDb','../rpc/cmHopperAdditionalPhone','./util/util','redis','defaults','socket.io-emitter','prototype','enqueue','tail','finally','campaignsPreview','voiceQueues','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','bind','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','loopCampaigns','type','outbound','name','strategy','answered','available','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','talking','total','unmanaged','waiting','dialActive','dialMethod','dialOriginateTimeout','dialPrefix','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','startProgressive','Trunk','active','callerid','Interval','stringify','format','voice:queue:%s','voice_queue:save','info','voice_queue_channel:remove','emit','voice_queue_presence:remove','sendMessageOneNotActive','originated','paused','NOT_ACTIVE','logger','DEACTIVATED','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20deactivated','syncCampaigns','hasOwnProperty','booked','clearZombieChannels','setMessage','recallMe','clearZombieChannel','[clearZombieChannels][talking]','Queue','queue','originated:\x20','pick','contactId','UserId','VoiceQueueId','Action','status','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','[action]','getContactRecallMe','agentReadyId','then','isNil','getDiff','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createCustomerHistory','RecallFailedTimeout','createCustomerFinal','[HistoryRecallClose]','[getContactRecallMe]','IsNotLoggedIn','AGENTS_NOT_LOGGED','isActive','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','callProgressDetectingCustomer','countnosuchnumberretry','countglobal','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','dialNoSuchNumberRetryFrequency','totalGlobal','dialGlobalMaxRetry','cloneAction','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact','unlockAgent','activeContact','linkedid','actioncountonusuch','idContact','incrementPreviewCounters','swapAdditionalPhones','ANSWER','YYYY-MM-DD\x20HH:mm:ss','responsetime','answertime','dialAnswer','[syncHangup][talking][increment]','\x20Queue','custom:agentconnect','connect','custom:agentConnectPreview','buildAcw','complete','decrementTalkink','[16]','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','uniqueid','pTalking:\x20','BUSY','countbusyretry','Busy','dialBusyRetryFrequency','callAdditionalPhoneAfterMin','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','Global','[callProgressDetectingCustomer][logBusyGlobal]','scheduledAt','custom:agentnoanswer','noanswer','[callProgressDetectingCustomer][logNoAnswer]','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','countnoanswerretry','countcongestionretry','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject'];(function(_0x5a7f64,_0x347d57){var _0x3d30f1=function(_0x4bd1d6){while(--_0x4bd1d6){_0x5a7f64['push'](_0x5a7f64['shift']());}};_0x3d30f1(++_0x347d57);}(_0x5075,0x73));var _0x5507=function(_0x30ba85,_0x503490){_0x30ba85=_0x30ba85-0x0;var _0x58b533=_0x5075[_0x30ba85];return _0x58b533;};'use strict';var util=require(_0x5507('0x0'));var _=require(_0x5507('0x1'));var BPromise=require(_0x5507('0x2'));var uuid=require(_0x5507('0x3'));var moment=require(_0x5507('0x4'));var md5=require(_0x5507('0x5'));var Redis=require(_0x5507('0x6'));var config=require('../../../config/environment');var logger=require(_0x5507('0x7'))(_0x5507('0x8'));var loggerAction=require(_0x5507('0x7'))('actionPreview');var ami=require('../ami');var rpcDb=require(_0x5507('0x9'));var cmHopperAdditionalPhone=require(_0x5507('0xa'));var Action=require('./action');var ut=require(_0x5507('0xb'));config[_0x5507('0xc')]=_[_0x5507('0xd')](config['redis'],{'host':'localhost','port':0x18eb});var io=require(_0x5507('0xe'))(new Redis(config[_0x5507('0xc')]));var Sequence=function(){};Sequence[_0x5507('0xf')][_0x5507('0x10')]=function(_0x50d6f5){this[_0x5507('0x11')]=this[_0x5507('0x11')]?this['tail'][_0x5507('0x12')](_0x50d6f5):_0x50d6f5();};function Preview(_0x5fbe08){this['sequence']=new Sequence();this[_0x5507('0x13')]=_0x5fbe08[_0x5507('0x14')];this[_0x5507('0x15')]=_0x5fbe08[_0x5507('0x15')];this[_0x5507('0x16')]={};this[_0x5507('0x17')]=_0x5fbe08['agents'];this[_0x5507('0x18')]=0x0;ami['on'](_0x5507('0x19'),this[_0x5507('0x1a')][_0x5507('0x1b')](this));ami['on']('hangup',this[_0x5507('0x1c')][_0x5507('0x1b')](this));ami['on'](_0x5507('0x1d'),this[_0x5507('0x1e')][_0x5507('0x1b')](this));ami['on'](_0x5507('0x1f'),this[_0x5507('0x20')][_0x5507('0x1b')](this));ami['on'](_0x5507('0x21'),this[_0x5507('0x22')][_0x5507('0x1b')](this));ami['on'](_0x5507('0x23'),this[_0x5507('0x24')]['bind'](this));ami['on'](_0x5507('0x25'),this[_0x5507('0x26')][_0x5507('0x1b')](this));ami['on'](_0x5507('0x27'),this['syncBlindTransfer'][_0x5507('0x1b')](this));this[_0x5507('0x28')](this[_0x5507('0x13')]);}function emit(_0x3ca1f7,_0x68397c,_0x1be8b1){io['to'](_0x3ca1f7)['emit'](_0x68397c,_0x1be8b1);}function emitCampaignPreview(_0x475970){if(_0x475970[_0x5507('0x29')]===_0x5507('0x2a')){var _0xa3e2cf={'id':_0x475970['id'],'name':_0x475970[_0x5507('0x2b')],'strategy':_0x475970[_0x5507('0x2c')],'answered':_0x475970[_0x5507('0x2d')],'available':_0x475970[_0x5507('0x2e')],'loggedIn':_0x475970[_0x5507('0x2f')],'pTalking':_0x475970[_0x5507('0x30')],'sumBillable':_0x475970[_0x5507('0x31')],'sumDuration':_0x475970[_0x5507('0x32')],'sumHoldTime':_0x475970[_0x5507('0x33')]||0x0,'talking':_0x475970[_0x5507('0x34')],'total':_0x475970[_0x5507('0x35')],'type':_0x475970['type'],'unmanaged':_0x475970[_0x5507('0x36')],'abandoned':_0x475970['abandoned'],'waiting':_0x475970[_0x5507('0x37')],'loggedInDb':_0x475970['loggedInDb'],'dialActive':_0x475970[_0x5507('0x38')],'dialMethod':_0x475970[_0x5507('0x39')],'dialOriginateCallerIdName':_0x475970['dialOriginateCallerIdName'],'dialOriginateCallerIdNumber':_0x475970['dialOriginateCallerIdNumber'],'dialOriginateTimeout':_0x475970[_0x5507('0x3a')],'dialPrefix':_0x475970[_0x5507('0x3b')],'outboundAnswerAgiCallsDay':_0x475970['outboundAnswerAgiCallsDay'],'outboundAnswerCallsDay':_0x475970[_0x5507('0x3c')],'outboundBlacklistCallsDay':_0x475970[_0x5507('0x3d')],'outboundBusyCallsDay':_0x475970[_0x5507('0x3e')],'outboundCongestionCallsDay':_0x475970[_0x5507('0x3f')],'outboundDropCallsDayACS':_0x475970[_0x5507('0x40')],'outboundDropCallsDayCallersExit':_0x475970[_0x5507('0x41')],'outboundDropCallsDayTimeout':_0x475970['outboundDropCallsDayTimeout'],'outboundNoAnswerCallsDay':_0x475970[_0x5507('0x42')],'outboundNoSuchCallsDay':_0x475970[_0x5507('0x43')],'outboundOriginateFailureCallsDay':_0x475970[_0x5507('0x44')],'outboundReCallsDay':_0x475970[_0x5507('0x45')],'outboundRejectCallsDay':_0x475970[_0x5507('0x46')],'outboundUnknownCallsDay':_0x475970['outboundUnknownCallsDay'],'outboundAbandonedCallsDay':_0x475970['outboundAbandonedCallsDay'],'predictiveIntervalAnsweredCalls':_0x475970[_0x5507('0x47')],'predictiveIntervalAvgHoldtime':_0x475970[_0x5507('0x48')],'predictiveIntervalAvgTalktime':_0x475970[_0x5507('0x49')],'predictiveIntervalDroppedCallsCallersExit':_0x475970[_0x5507('0x4a')],'predictiveIntervalDroppedCallsTimeout':_0x475970['predictiveIntervalDroppedCallsTimeout'],'predictiveIntervalErlangCalls':_0x475970[_0x5507('0x4b')],'predictiveIntervalErlangCallsDroppedCalls':_0x475970[_0x5507('0x4c')],'predictiveIntervalHitRate':_0x475970[_0x5507('0x4d')],'predictiveIntervalMultiplicativeFactor':_0x475970[_0x5507('0x4e')],'predictiveIntervalPauses':_0x475970[_0x5507('0x4f')],'predictiveIntervalAvailable':_0x475970[_0x5507('0x50')],'predictiveIntervalTotalCalls':_0x475970[_0x5507('0x51')],'message':_0x475970[_0x5507('0x52')],'originated':_0x475970['originated'],'erlangCalls':_0x475970[_0x5507('0x53')],'erlangCallToSecond':_0x475970[_0x5507('0x54')],'erlangAbandonmentRate':_0x475970[_0x5507('0x55')],'erlangBusyFactor':_0x475970['erlangBusyFactor'],'startPredictive':_0x475970['startPredictive'],'startProgressive':_0x475970[_0x5507('0x56')]};if(_0x475970[_0x5507('0x57')]){_0xa3e2cf[_0x5507('0x57')]={'id':_0x475970[_0x5507('0x57')]['id'],'name':_0x475970[_0x5507('0x57')]['name'],'active':_0x475970['Trunk'][_0x5507('0x58')],'callerid':_0x475970[_0x5507('0x57')][_0x5507('0x59')]};}if(_0x475970[_0x5507('0x5a')]){_0xa3e2cf['Interval']={'id':_0x475970['Interval']['id'],'name':_0x475970[_0x5507('0x5a')]['name']};}var _0x304daf=md5(JSON[_0x5507('0x5b')](_0xa3e2cf));if(_0x475970[_0x5507('0x5')]!==_0x304daf){_0x475970[_0x5507('0x5')]=_0x304daf;emit(util[_0x5507('0x5c')](_0x5507('0x5d'),_0xa3e2cf[_0x5507('0x2b')]),_0x5507('0x5e'),_0xa3e2cf);}}}function emitVoiceQueueChannelRemove(_0x44502c){logger[_0x5507('0x5f')]('[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event',JSON['stringify'](_0x44502c));emit(util['format']('voice:queue:%s',_0x44502c[_0x5507('0x2b')]),_0x5507('0x60'),_0x44502c);io[_0x5507('0x61')](_0x5507('0x62'),_0x44502c);}function notSendMessagesQueue(_0x2b32a5){if(_0x2b32a5[_0x5507('0x63')]){if(_0x2b32a5[_0x5507('0x64')]===0x0&&_0x2b32a5[_0x5507('0x30')]===0x0){_0x2b32a5[_0x5507('0x63')]=![];_0x2b32a5[_0x5507('0x2e')]=0x0;_0x2b32a5[_0x5507('0x65')]=0x0;_0x2b32a5[_0x5507('0x52')]=_0x5507('0x66');ut[_0x5507('0x67')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x2b32a5['name']+'\x20is\x20not\x20active');}else{_0x2b32a5[_0x5507('0x52')]=_0x5507('0x68');ut[_0x5507('0x67')](_0x5507('0x69'),_0x2b32a5[_0x5507('0x2b')]+_0x5507('0x6a'));}emitCampaignPreview(_0x2b32a5);}}Preview[_0x5507('0xf')][_0x5507('0x28')]=function(){var _0x3dd253=this;setInterval(function(){_0x3dd253[_0x5507('0x6b')]();},0x7cf);};Preview[_0x5507('0xf')][_0x5507('0x6b')]=function(){var _0x24d7b5=this[_0x5507('0x13')];this[_0x5507('0x18')]+=0x1;for(var _0x8bad16 in _0x24d7b5){if(_0x24d7b5[_0x5507('0x6c')](_0x8bad16)&&(_0x24d7b5[_0x8bad16][_0x5507('0x39')]===_0x5507('0x8')||_0x24d7b5[_0x8bad16]['dialMethod']===_0x5507('0x6d'))&&_0x24d7b5[_0x8bad16][_0x5507('0x29')]==='outbound'){if(this['clockClearZombieChannels']>0x7){this[_0x5507('0x18')]=0x0;this[_0x5507('0x6e')]();}}if(_0x24d7b5[_0x5507('0x6c')](_0x8bad16)&&_0x24d7b5[_0x8bad16][_0x5507('0x39')]===_0x5507('0x8')&&_0x24d7b5[_0x8bad16]['type']===_0x5507('0x2a')){if(_0x24d7b5[_0x8bad16][_0x5507('0x38')]){this[_0x5507('0x6f')](_0x24d7b5[_0x8bad16]);if(_0x24d7b5[_0x8bad16]['dialPreviewAutoRecallMe'])this[_0x5507('0x70')](_0x24d7b5[_0x8bad16]);}else{notSendMessagesQueue(_0x24d7b5[_0x8bad16]);}}}};Preview[_0x5507('0xf')][_0x5507('0x71')]=function(_0x472faa){var _0xe6bca7=this;this['sequence'][_0x5507('0x10')](function(){if(!_['isNil'](_0xe6bca7[_0x5507('0x16')][_0x472faa])){loggerAction[_0x5507('0x5f')](_0x5507('0x72'),_0x472faa,_0x5507('0x73'),_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')],_0x5507('0x75'),JSON[_0x5507('0x5b')](_0xe6bca7['campaignsPreview'][_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')]]['originated']),'pTalking:\x20',JSON['stringify'](_0xe6bca7[_0x5507('0x13')][_0xe6bca7['actions'][_0x472faa][_0x5507('0x74')]]['pTalking']),JSON[_0x5507('0x5b')](_0xe6bca7['actions'][_0x472faa]['dialAnswer']),JSON[_0x5507('0x5b')](_[_0x5507('0x76')](_0xe6bca7[_0x5507('0x16')][_0x472faa],[_0x5507('0x77'),_0x5507('0x78'),_0x5507('0x79'),'ListId'])));return ami[_0x5507('0x7a')]({'action':_0x5507('0x7b'),'channel':_0xe6bca7[_0x5507('0x16')][_0x472faa]['channel']})[_0x5507('0x7c')](function(_0xe4b14c){if(_0xe4b14c[_0x5507('0x52')]===_0x5507('0x7d')){setTimeout(function(){if(_0xe6bca7[_0x5507('0x16')][_0x472faa]){ut[_0x5507('0x7e')](_0xe6bca7[_0x5507('0x13')][_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')]],_0x5507('0x7f'));if(_0xe6bca7[_0x5507('0x16')][_0x472faa]['dialAnswer']===!![]){ut['decrementTalkink'](_0xe6bca7[_0x5507('0x13')][_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')]],_0x5507('0x7f'));ut[_0x5507('0x80')](_0x5507('0x81')+_0x472faa,_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')]);}ut[_0x5507('0x80')](_0x5507('0x82')+_0x472faa,_0xe6bca7[_0x5507('0x16')][_0x472faa][_0x5507('0x74')]);delete _0xe6bca7[_0x5507('0x16')][_0x472faa];}},0x2328);}});}});};Preview[_0x5507('0xf')][_0x5507('0x6e')]=function(){var _0x15082b=this;loggerAction['info'](_0x5507('0x83'),_['size'](this['actions']));for(var _0x42be15 in this[_0x5507('0x16')]){if(_0x15082b[_0x5507('0x16')][_0x5507('0x6c')](_0x42be15)){_0x15082b['clearZombieChannel'](_0x42be15);}}};Preview[_0x5507('0xf')][_0x5507('0x70')]=function(_0x314d4e){var _0x34276a=this;rpcDb[_0x5507('0x84')](_0x314d4e['id'],ut[_0x5507('0x85')](this['agents']))[_0x5507('0x86')](function(_0x46e589){if(!_[_0x5507('0x87')](_0x46e589)){for(var _0x4e9801=0x0;_0x4e9801<_0x46e589['length'];_0x4e9801+=0x1){if(ut[_0x5507('0x88')](_0x46e589[_0x4e9801]['scheduledat'])<_0x314d4e[_0x5507('0x89')]*0x3c){if(_0x46e589[_0x4e9801][_0x5507('0x8a')]&&!_0x46e589[_0x4e9801]['Agent'][_0x5507('0x8b')]){_0x34276a[_0x5507('0x8c')](_0x46e589[_0x4e9801]['id'])[_0x5507('0x86')](ut[_0x5507('0x8d')](_0x5507('0x8e')))[_0x5507('0x7c')](ut[_0x5507('0x8d')](_0x5507('0x8e')));}else{rpcDb[_0x5507('0x8f')](_0x46e589[_0x4e9801]['id']);}}else{var _0x7afa6b=new Action(_0x46e589[_0x4e9801],_0x314d4e);_0x7afa6b[_0x5507('0x90')]=moment()[_0x5507('0x5c')]('YYYY-MM-DD\x20HH:mm:ss');_0x314d4e[_0x5507('0x45')]+=0x1;ut[_0x5507('0x91')](_0x7afa6b,0x17,_0x5507('0x92'));if(_0x314d4e[_0x5507('0x93')]){rpcDb[_0x5507('0x94')](ut['createBody'](_0x46e589[_0x4e9801]));rpcDb[_0x5507('0x95')](_0x7afa6b,'[HistoryDialRecallInQueue][historyCatch]');}else{ut[_0x5507('0x91')](_0x7afa6b,0x16,_0x5507('0x96'));rpcDb[_0x5507('0x95')](_0x7afa6b,'[HistoryRecallClose]');rpcDb[_0x5507('0x97')](_0x7afa6b,_0x5507('0x98'));}}}}})[_0x5507('0x7c')](ut['logger2'](_0x5507('0x99')));};Preview['prototype'][_0x5507('0x6f')]=function(_0x5545ad){_0x5545ad['sendMessageOneNotActive']=!![];if(ut[_0x5507('0x9a')](_0x5545ad[_0x5507('0x2f')])){_0x5545ad[_0x5507('0x52')]=_0x5507('0x9b');}else if(!ut[_0x5507('0x9c')](_0x5545ad[_0x5507('0x38')])){_0x5545ad['message']='NOT_ACTIVE';}else if(!this[_0x5507('0x9d')](_0x5545ad[_0x5507('0x57')])){if(!this[_0x5507('0x9d')](_0x5545ad[_0x5507('0x9e')])){_0x5545ad['message']=_0x5507('0x9f');}else{_0x5545ad[_0x5507('0x52')]=_0x5507('0xa0');}}else{_0x5545ad[_0x5507('0x52')]=_0x5507('0xa0');}emitCampaignPreview(_0x5545ad);};Preview[_0x5507('0xf')][_0x5507('0xa1')]=function(_0x5dc6d9,_0x3802dd,_0xfdbbe5){var _0x327a63=this;var _0x57e2d9=this[_0x5507('0x16')][_0x3802dd];var _0x4d3f1a=this['campaignsPreview'][_0x57e2d9['queue']];var _0x1fef49;var _0x158f22=![];var _0xb622bd=0x2;var _0x10e409=0x3;if(_0x4d3f1a){switch(_0xfdbbe5){case'1':_0x4d3f1a[_0x5507('0x43')]+=0x1;_0x57e2d9[_0x5507('0xa2')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut['totalGlobal'](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x0,'NoSuchNumber');ami[_0x5507('0x61')](_0x5507('0xa4'),ut[_0x5507('0xa5')](_0x57e2d9,_0x5507('0xa6')));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xa7'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'0',_0x4d3f1a)[_0x5507('0x86')](function(_0x2f8164){_0x158f22=_0x2f8164[_0x5507('0xa9')]==0x1;_0xb622bd=_0x4d3f1a[_0x5507('0xaa')];_0x10e409=_0x4d3f1a['callAdditionalPhoneAfterMin'];if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a[_0x5507('0xac')]){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0xf,'Global');rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xae'));}else{if(_0x57e2d9['countnosuchnumberretry']>=_0x4d3f1a[_0x5507('0xaf')]){rpcDb['createCustomerFinal'](_0x57e2d9,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{rpcDb[_0x5507('0xb0')](ut['scheduledAt'](_0x57e2d9,_0x5507('0xa2'),_0x4d3f1a[_0x5507('0xaa')]),_0x57e2d9[_0x5507('0xb1')],_0x57e2d9[_0x5507('0xb2')]);}}delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0xb3')]];}else{_0x57e2d9['countnosuchnumberretry']++;logger[_0x5507('0x5f')](_0x5507('0xb4'),_0x57e2d9[_0x5507('0xa2')]);logger[_0x5507('0x5f')]('id',_0x57e2d9[_0x5507('0xb5')]);_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnosuchnumberretry':_0x57e2d9[_0x5507('0xa2')]}})[_0x5507('0x86')](function(){_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});break;case _0x5507('0xb8'):var _0x4985e9=moment()[_0x5507('0x5c')](_0x5507('0xb9'));_0x57e2d9[_0x5507('0xba')]=_0x4985e9;_0x57e2d9[_0x5507('0xbb')]=_0x4985e9;_0x57e2d9[_0x5507('0xbc')]=!![];_0x4d3f1a[_0x5507('0x30')]+=0x1;logger['info'](_0x5507('0xbd'),_0x57e2d9['uniqueid'],_0x5507('0xbe'),_0x4d3f1a['name'],'pTalking:\x20',_0x4d3f1a[_0x5507('0x30')]);ami[_0x5507('0x61')](_0x5507('0xbf'),ut[_0x5507('0xa5')](_0x57e2d9,_0x5507('0xc0'),this['campaignsPreview'][_0x57e2d9[_0x5507('0x74')]]));if(_0x4d3f1a['acw']){ami[_0x5507('0x61')](_0x5507('0xc1'),ut[_0x5507('0xc2')](_0x57e2d9));}break;case'16':ami[_0x5507('0x61')]('custom:agentcomplete',ut[_0x5507('0xa5')](_0x57e2d9,_0x5507('0xc3'),this[_0x5507('0x13')][_0x57e2d9['queue']]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x57e2d9,_0x5507('0xc3')));_0x4d3f1a[_0x5507('0x3c')]+=0x1;_0x4d3f1a[_0x5507('0x35')]+=0x1;_0x4d3f1a[_0x5507('0x2d')]+=0x1;ut[_0x5507('0xc4')](_0x4d3f1a,_0x5507('0xc5'));_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x4,_0x5507('0xc6'));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xc7'));rpcDb['createCustomerFinal'](_0x57e2d9,_0x5507('0xc8'));rpcDb[_0x5507('0xc9')](_0x57e2d9);_0x4d3f1a[_0x5507('0x32')]+=_0x57e2d9[_0x5507('0xca')];_0x4d3f1a[_0x5507('0x31')]+=_0x57e2d9[_0x5507('0xca')];logger[_0x5507('0x5f')]('[syncHangup][talking][decrement]',_0x57e2d9[_0x5507('0xcb')],_0x5507('0xbe'),_0x4d3f1a[_0x5507('0x2b')],_0x5507('0xcc'),_0x4d3f1a['pTalking']);delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0xb3')]];break;case _0x5507('0xcd'):_0x4d3f1a[_0x5507('0x3e')]+=0x1;_0x57e2d9[_0x5507('0xce')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut['logCustomer'](_0x57e2d9,0x5,_0x5507('0xcf'));_0xb622bd=_0x4d3f1a[_0x5507('0xd0')];_0x10e409=_0x4d3f1a[_0x5507('0xd1')];ami[_0x5507('0x61')](_0x5507('0xd2'),ut['buildObj'](_0x57e2d9,_0x5507('0xd3')));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xd4'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'5',_0x4d3f1a)[_0x5507('0x86')](function(_0x2b37f3){_0x158f22=_0x2b37f3[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a[_0x5507('0xac')]){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0xf,_0x5507('0xd5'));rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xd6'));}else{if(_0x57e2d9['countbusyretry']>=_0x4d3f1a['dialBusyMaxRetry']){rpcDb['createCustomerFinal'](_0x57e2d9,_0x5507('0xd4'));}else{rpcDb[_0x5507('0xb0')](ut[_0x5507('0xd7')](_0x57e2d9,_0x5507('0xce'),_0x4d3f1a[_0x5507('0xd0')]),_0x57e2d9['unlockAgent'],_0x57e2d9[_0x5507('0xb2')]);}}}else{_0x57e2d9[_0x5507('0xce')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9['idContact'],'field':{'countbusyretry':_0x57e2d9[_0x5507('0xce')]}})['then'](function(){_0x327a63['swapAdditionalPhones'](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});break;case'NOANSWER':_0x4d3f1a[_0x5507('0x42')]+=0x1;_0x57e2d9['countnoanswerretry']+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x3,'NoAnswer');_0xb622bd=_0x4d3f1a['dialNoAnswerRetryFrequency'];_0x10e409=_0x4d3f1a[_0x5507('0xd1')];ami[_0x5507('0x61')](_0x5507('0xd8'),ut['buildObj'](_0x57e2d9,_0x5507('0xd9')));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xda'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'3',_0x4d3f1a)['then'](function(_0x4fe16e){_0x158f22=_0x4fe16e[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a['dialGlobalMaxRetry']){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0xf,_0x5507('0xd5'));rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xdb'));}else{if(_0x57e2d9['countnoanswerretry']>=_0x4d3f1a[_0x5507('0xdc')]){rpcDb[_0x5507('0x97')](_0x57e2d9,'[callProgressDetectingCustomer][logNoAnswer]');}else{rpcDb[_0x5507('0xb0')](ut[_0x5507('0xd7')](_0x57e2d9,_0x5507('0xdd'),_0x4d3f1a['dialNoAnswerRetryFrequency']),_0x57e2d9[_0x5507('0xb1')],_0x57e2d9[_0x5507('0xb2')]);}}}else{_0x57e2d9['countnoanswerretry']++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnoanswerretry':_0x57e2d9['countnoanswerretry']}})[_0x5507('0x86')](function(){_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});break;case'CONGESTION':_0x4d3f1a[_0x5507('0x3f')]+=0x1;_0x57e2d9[_0x5507('0xde')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x8,_0x5507('0xdf'));_0xb622bd=_0x4d3f1a[_0x5507('0xe0')];_0x10e409=_0x4d3f1a['callAdditionalPhoneAfterMin'];ami[_0x5507('0x61')](_0x5507('0xe1'),ut[_0x5507('0xa5')](_0x57e2d9,_0x5507('0xe2')));rpcDb['createCustomerHistory'](_0x57e2d9,'[callProgressDetectingCustomer][logCongestion]');_0x327a63[_0x5507('0xa8')](_0x57e2d9,'8',_0x4d3f1a)['then'](function(_0x395a4a){_0x158f22=_0x395a4a[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a['dialGlobalMaxRetry']){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0xf,_0x5507('0xd5'));rpcDb['createCustomerFinal'](_0x1fef49,_0x5507('0xe3'));}else{if(_0x57e2d9[_0x5507('0xde')]>=_0x4d3f1a[_0x5507('0xe4')]){rpcDb[_0x5507('0x97')](_0x57e2d9,_0x5507('0xe5'));}else{rpcDb[_0x5507('0xb0')](ut['scheduledAt'](_0x57e2d9,_0x5507('0xde'),_0x4d3f1a[_0x5507('0xd0')]),_0x57e2d9['unlockAgent'],_0x57e2d9[_0x5507('0xb2')]);}}}else{_0x57e2d9[_0x5507('0xde')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countcongestionretry':_0x57e2d9[_0x5507('0xde')]}})[_0x5507('0x86')](function(){_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});break;case _0x5507('0xe6'):_0x4d3f1a[_0x5507('0x46')]+=0x1;_0x57e2d9[_0x5507('0xe7')]+=0x1;_0x57e2d9['countglobal']=ut[_0x5507('0xab')](_0x57e2d9);ut['logCustomer'](_0x57e2d9,0x14,_0x5507('0xe8'));_0xb622bd=_0x4d3f1a[_0x5507('0xe9')];_0x10e409=_0x4d3f1a[_0x5507('0xd1')];ami[_0x5507('0x61')](_0x5507('0xea'),ut[_0x5507('0xa5')](_0x57e2d9,_0x5507('0xeb')));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xec'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'20',_0x4d3f1a)[_0x5507('0x86')](function(_0x1d3fca){_0x158f22=_0x1d3fca[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a['dialGlobalMaxRetry']){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0x14,_0x5507('0xe8'));rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xed'));}else{if(_0x57e2d9[_0x5507('0xe7')]>=_0x4d3f1a[_0x5507('0xee')]){rpcDb[_0x5507('0x97')](_0x57e2d9,_0x5507('0xed'));}else{rpcDb[_0x5507('0xb0')](ut[_0x5507('0xd7')](_0x57e2d9,_0x5507('0xe7'),_0x4d3f1a[_0x5507('0xe9')]),_0x57e2d9[_0x5507('0xb1')],_0x57e2d9[_0x5507('0xb2')]);}}}else{_0x57e2d9[_0x5507('0xdd')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnoanswerretry':_0x57e2d9[_0x5507('0xdd')]}})[_0x5507('0x86')](function(){_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)['then'](function(){});});}});break;case'ABANDONED':_0x4d3f1a[_0x5507('0xef')]+=0x1;_0x57e2d9['countabandonedretry']+=0x1;_0x57e2d9['countglobal']=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0xb,_0x5507('0xf0'));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xf1'));_0x327a63['verifyAdditionalPhones'](_0x57e2d9,'11',_0x4d3f1a)['then'](function(_0x347201){_0x158f22=_0x347201[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut['totalGlobal'](_0x57e2d9)>=_0x4d3f1a[_0x5507('0xac')]){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0xf,_0x5507('0xd5'));rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xf1'));}else{if(_0x57e2d9[_0x5507('0xf2')]>=_0x4d3f1a[_0x5507('0xf3')]){rpcDb[_0x5507('0x97')](_0x57e2d9,_0x5507('0xf1'));}else{rpcDb[_0x5507('0xb0')](ut[_0x5507('0xd7')](_0x57e2d9,_0x5507('0xf4'),_0x4d3f1a[_0x5507('0xf5')]),_0x57e2d9[_0x5507('0xb1')],_0x57e2d9['activeContact']);}}}else{_0x57e2d9[_0x5507('0xdd')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnoanswerretry':_0x57e2d9[_0x5507('0xdd')]}})[_0x5507('0x86')](function(){_0x327a63['swapAdditionalPhones'](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});break;case'18':_0x4d3f1a[_0x5507('0xf6')]+=0x1;_0x57e2d9[_0x5507('0xf7')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x12,_0x5dc6d9['cause-txt']||_0x5dc6d9[_0x5507('0xf8')]);ami[_0x5507('0x61')]('custom:amd',ut[_0x5507('0xa5')](_0x57e2d9,'amd'));rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xf9'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'18',_0x4d3f1a)['then'](function(_0x45d3c0){_0x158f22=_0x45d3c0[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a[_0x5507('0xac')]){_0x1fef49=ut[_0x5507('0xad')](_0x57e2d9,0x12,_0x5507('0xd5'));rpcDb[_0x5507('0x97')](_0x1fef49,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0x5507('0x97')](_0x57e2d9,_0x5507('0xf9'));}}else{_0x57e2d9[_0x5507('0xdd')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnoanswerretry':_0x57e2d9[_0x5507('0xdd')]}})[_0x5507('0x86')](function(){_0x327a63['swapAdditionalPhones'](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0xb3')]];break;case'19':_0x4d3f1a[_0x5507('0xf6')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut[_0x5507('0xab')](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0x13,_0x5dc6d9[_0x5507('0xfa')]||_0x5dc6d9['dialstatus']);ami[_0x5507('0x61')](_0x5507('0xfb'),ut['buildObj'](_0x57e2d9,'amd'));rpcDb[_0x5507('0x95')](_0x57e2d9,'[callProgressDetectingCustomer][machine]');_0x327a63[_0x5507('0xa8')](_0x57e2d9,'18',_0x4d3f1a)[_0x5507('0x86')](function(_0x3224fa){_0x158f22=_0x3224fa[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a[_0x5507('0xac')]){_0x1fef49=ut['cloneAction'](_0x57e2d9,0xf,'Global');rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0xfc'));}else{rpcDb[_0x5507('0x97')](_0x57e2d9,'[callProgressDetectingCustomer][machine]');}}else{_0x57e2d9[_0x5507('0xdd')]++;_0x327a63[_0x5507('0xb6')]({'id':_0x57e2d9[_0x5507('0xb5')],'field':{'countnoanswerretry':_0x57e2d9[_0x5507('0xdd')]}})[_0x5507('0x86')](function(){_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(){});});}});delete this[_0x5507('0x16')][_0x5dc6d9['linkedid']];break;default:if(_0x57e2d9['dialAnswer']){ut[_0x5507('0xc4')](_0x4d3f1a,_0x5507('0xfd'));ut[_0x5507('0x80')](_0x5507('0xfe')+_0x4d3f1a[_0x5507('0x2b')],_0x5dc6d9);}_0x4d3f1a[_0x5507('0xf6')]+=0x1;_0x57e2d9[_0x5507('0xa3')]=ut['totalGlobal'](_0x57e2d9);ut[_0x5507('0x91')](_0x57e2d9,0xc,_0x5dc6d9[_0x5507('0xfa')]||_0x5dc6d9[_0x5507('0xf8')]);_0xb622bd=_0x4d3f1a[_0x5507('0xe9')];_0x10e409=_0x4d3f1a[_0x5507('0xd1')];rpcDb[_0x5507('0x95')](_0x57e2d9,_0x5507('0xff'));_0x327a63[_0x5507('0xa8')](_0x57e2d9,'20',_0x4d3f1a)[_0x5507('0x86')](function(_0xf9db83){_0x158f22=_0xf9db83[_0x5507('0xa9')]==0x1;if(!_0x158f22){if(ut[_0x5507('0xab')](_0x57e2d9)>=_0x4d3f1a['dialGlobalMaxRetry']){_0x1fef49=ut['cloneAction'](_0x57e2d9,0xf,_0x5507('0xd5'));rpcDb[_0x5507('0x97')](_0x1fef49,_0x5507('0x100'));}else{rpcDb[_0x5507('0x97')](_0x57e2d9,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0xb3')]];}else{_0x327a63[_0x5507('0xb7')](_0x57e2d9,_0xb622bd,_0x10e409)[_0x5507('0x86')](function(_0x1f7cad){});}});}if(!(_0x57e2d9[_0x5507('0xbc')]&&_0xfdbbe5==='16')){ut[_0x5507('0x7e')](_0x4d3f1a,_0x5507('0x101'));logger[_0x5507('0x5f')]('[originated][decrement][callProgressDetectingCustomer]',_0x57e2d9[_0x5507('0xcb')],_0x5507('0xbe'),_0x4d3f1a[_0x5507('0x2b')],_0x5507('0x75'),_0x4d3f1a['originated']);}if(_0xfdbbe5!==_0x5507('0xb8')){delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0xb3')]];delete this[_0x5507('0x16')][_0x5dc6d9[_0x5507('0x102')]];}}};Preview[_0x5507('0xf')]['callProgressDetectingAgent']=function(_0xf09b75,_0x23cb62,_0x3326c0){if(_[_0x5507('0x103')](_0x23cb62)&&_0x5507('0x104')!==typeof _0x23cb62){return;}if(_['isUndefined'](_0x3326c0)&&'object'!==typeof _0x3326c0){return;}switch(_0x3326c0[_0x5507('0x105')]){case'0':ut['logAgent'](_0xf09b75,0x0,_0x5507('0x106'));rpcDb[_0x5507('0x107')](_0xf09b75,_0x5507('0x108'));break;case'3':ut['logAgent'](_0xf09b75,0x3,_0x5507('0x109'));rpcDb[_0x5507('0x107')](_0xf09b75,_0x5507('0x10a'));break;case'5':ut[_0x5507('0x10b')](_0xf09b75,0x5,_0x5507('0xcf'));rpcDb[_0x5507('0x107')](_0xf09b75,'[callProgressDetectingAgent][logBusy]');break;case'8':ut[_0x5507('0x10b')](_0xf09b75,0x8,'Congestion');rpcDb[_0x5507('0x107')](_0xf09b75,_0x5507('0x10c'));break;case'22':ut[_0x5507('0x10b')](_0xf09b75,0x16,_0x5507('0x10d'));rpcDb[_0x5507('0x107')](_0xf09b75,_0x5507('0x10e'));break;default:ut[_0x5507('0x10b')](_0xf09b75,0xc,_0x3326c0[_0x5507('0x105')]);rpcDb[_0x5507('0x107')](_0xf09b75,_0x5507('0x10c'));}ut['updateOriginated'](_0x23cb62,_0x5507('0x10f'));logger[_0x5507('0x5f')]('[originated][decrement][callProgressDetectingAgent]',_0xf09b75[_0x5507('0xcb')],_0x5507('0xbe'),_0x23cb62['name'],_0x5507('0x75'),_0x23cb62[_0x5507('0x64')]);delete this['actions'][_0xf09b75[_0x5507('0xcb')]];};Preview[_0x5507('0xf')]['verifyAdditionalPhones']=function(_0x469029,_0x12ebfd,_0x3ccadc){return BPromise[_0x5507('0x110')]()[_0x5507('0x86')](cmHopperAdditionalPhone[_0x5507('0xa8')](_0x469029,_0x12ebfd,_0x3ccadc))[_0x5507('0x7c')](logger[_0x5507('0x5f')]('[verifyAdditionalPhone]\x20'));};Preview[_0x5507('0xf')]['swapAdditionalPhones']=function(_0x452bfa,_0x224f38,_0x29f05e){return BPromise[_0x5507('0x110')]()[_0x5507('0x86')](cmHopperAdditionalPhone['swapAdditionalPhones'](_0x452bfa,_0x224f38,_0x29f05e))['catch'](logger[_0x5507('0x5f')](_0x5507('0x111')));};Preview[_0x5507('0xf')][_0x5507('0xb6')]=function(_0x61cda9){return BPromise[_0x5507('0x110')]()[_0x5507('0x86')](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x61cda9))['catch'](logger[_0x5507('0x5f')](_0x5507('0x112')));};Preview['prototype'][_0x5507('0x113')]=function(_0x934751,_0xb41ee6,_0x58d38d,_0x37bc1e,_0x425651){var _0x36b495=this;return new BPromise(function(_0x3c8a2e,_0x2cbfe4){if(_[_0x5507('0x87')](_0xb41ee6)||_[_0x5507('0x87')](_0xb41ee6[_0x5507('0x114')])||_[_0x5507('0x87')](_0xb41ee6[_0x5507('0x115')])||_[_0x5507('0x87')](_0xb41ee6[_0x5507('0x79')])){_0x2cbfe4(ut[_0x5507('0x52')](_0x5507('0x116'),_0x37bc1e,_0x425651));return;}var _0x471b58=uuid['v4']();var _0xcdee4c=_0x36b495[_0x5507('0x13')][_0xb41ee6[_0x5507('0x73')][_0x5507('0x2b')]];var _0x41edf4=_0x58d38d?_0x36b495[_0x5507('0x17')][_0x58d38d]['id']:undefined;_0x36b495[_0x5507('0x16')][_0x471b58]=new Action(_0xb41ee6,_0xcdee4c,_0x471b58,_0x58d38d,_0x41edf4);var _0x47219f=_0x36b495[_0x5507('0x16')][_0x471b58];_0x47219f[_0x5507('0xb1')]=_0x37bc1e;_0x47219f[_0x5507('0xb2')]=_0x425651;_0x47219f['lookAgent']=_0x58d38d;if(_['isEmpty'](_0x934751)){_0x36b495[_0x5507('0x117')](_0x47219f,_0xcdee4c,_0xb41ee6,_0x58d38d)[_0x5507('0x86')](function(_0xb93472){logger['info'](_0x5507('0x118'),_0x5507('0x119')+_0x47219f[_0x5507('0x74')]+'\x20IdHopper:\x20'+_0x47219f[_0x5507('0xb5')],JSON['stringify'](_0xb93472));ami[_0x5507('0x61')]('custom:agentcalled',ut[_0x5507('0xa5')](_0x47219f,_0x5507('0x11a'),_0x36b495['campaignsPreview'][_0x47219f[_0x5507('0x74')]]));_0x3c8a2e(ut['message'](_0x5507('0x11b')));})[_0x5507('0x7c')](function(_0xd810e0){ut[_0x5507('0x67')](_0x5507('0x11c'),_0xd810e0);_0x2cbfe4(ut[_0x5507('0x52')]('Call\x20failed',_0x37bc1e,_0x425651));});}else{_0xcdee4c[_0x5507('0x3d')]+=0x1;ut['logBlacklist'](_0x47219f);rpcDb[_0x5507('0x11d')](_0x47219f,'[Blacklist][error]');delete _0x36b495[_0x5507('0x16')][_0x471b58];_0x2cbfe4(ut[_0x5507('0x52')](_0x5507('0x11e'),_0x37bc1e,_0x425651));}});};Preview[_0x5507('0xf')]['isTrunkReachable']=function(_0x4af82f){return!_[_0x5507('0x87')](_0x4af82f)&&!_[_0x5507('0x87')](_0x4af82f[_0x5507('0x2b')])&&!_[_0x5507('0x87')](_0x4af82f[_0x5507('0x58')])&&_0x4af82f[_0x5507('0x58')]&&!_['isNil'](this[_0x5507('0x15')][util[_0x5507('0x5c')](_0x5507('0x11f'),_0x4af82f['name'])])&&!_[_0x5507('0x87')](this[_0x5507('0x15')][util[_0x5507('0x5c')](_0x5507('0x11f'),_0x4af82f[_0x5507('0x2b')])]['status'])&&(this[_0x5507('0x15')][util[_0x5507('0x5c')](_0x5507('0x11f'),_0x4af82f[_0x5507('0x2b')])][_0x5507('0x7b')]===_0x5507('0x120')||this[_0x5507('0x15')][util[_0x5507('0x5c')](_0x5507('0x11f'),_0x4af82f[_0x5507('0x2b')])][_0x5507('0x7b')]===_0x5507('0x121'));};Preview[_0x5507('0xf')][_0x5507('0x8c')]=function(_0x5b872e,_0x17d50d){var _0x58a766=this;return new BPromise(function(_0x4ed046,_0x17bd86){_0x58a766[_0x5507('0x122')](_0x5b872e,_0x17d50d)[_0x5507('0x86')](function(_0xfba365){_0x4ed046(_[_0x5507('0x76')](_0xfba365,[_0x5507('0x52')]));})['catch'](function(_0x3c1d0e){if(_0x3c1d0e[_0x5507('0x123')]){rpcDb[_0x5507('0x124')](_0x5b872e);}if(_0x3c1d0e[_0x5507('0x58')]){rpcDb['disableContact'](_0x5b872e);}_0x17bd86(_[_0x5507('0x76')](_0x3c1d0e,[_0x5507('0x52')]));});});};Preview[_0x5507('0xf')]['execRun']=function(_0x107ddc,_0x25096b){var _0x2a6f25=this;return new BPromise(function(_0x55923d,_0x9b15cf){var _0x3ed22e,_0x403cda;rpcDb[_0x5507('0x125')](_0x107ddc)[_0x5507('0x86')](function(_0x5a1eae){if(!_['isNil'](_0x5a1eae[0x0])){_0x403cda=_0x5a1eae[0x0][_0x5507('0x126')]?![]:!![];_0x3ed22e=_0x5a1eae[0x0][_0x5507('0x126')]?!![]:![];_0x3ed22e=_0x25096b?!![]:_0x3ed22e;}var _0xd4afca=_0x2a6f25[_0x5507('0x127')](_0x5a1eae);if(_0xd4afca[_0x5507('0x128')]){rpcDb[_0x5507('0x129')](_[_0x5507('0x76')](_0x5a1eae[0x0],[_0x5507('0x79'),_0x5507('0x115')]))[_0x5507('0x86')](function(_0xcb8ab4){_0x2a6f25[_0x5507('0x113')](_0xcb8ab4,_0x5a1eae[0x0],_0x25096b,_0x403cda,_0x3ed22e)['then'](function(_0x5ca9c2){_0x55923d(_0x5ca9c2);})[_0x5507('0x7c')](function(_0x59345a){_0x9b15cf(_0x59345a);});})[_0x5507('0x7c')](function(_0xf936c1){ut[_0x5507('0x67')]('[Preview][checkIsBlackList]',_0xf936c1);_0x9b15cf(ut[_0x5507('0x52')](_0x5507('0x12a'),_0x403cda,_0x3ed22e));});}else{_0x9b15cf(ut[_0x5507('0x52')](_0xd4afca[_0x5507('0x52')],_0x403cda,_0x3ed22e));}})[_0x5507('0x7c')](function(_0x46293e){ut[_0x5507('0x67')]('[Preview][getContactPreview]',_0x46293e);_0x9b15cf(ut[_0x5507('0x52')]('Call\x20unsuccessful',![],!![]));});});};Preview[_0x5507('0xf')][_0x5507('0x127')]=function(_0x28d687){if(_[_0x5507('0x87')](_0x28d687)||_[_0x5507('0x12b')](_0x28d687)||!_[_0x5507('0x87')](_0x28d687[0x0][_0x5507('0x8a')])&&_[_0x5507('0x87')](_0x28d687[0x0][_0x5507('0x8a')][_0x5507('0x2b')])){ut[_0x5507('0x67')](_0x5507('0x12c'),_0x28d687);return{'isValid':![],'message':_0x5507('0x12d')};}var _0x16b8e2=this[_0x5507('0x13')][_0x28d687[0x0][_0x5507('0x73')][_0x5507('0x2b')]];_0x16b8e2[_0x5507('0x52')]=_0x5507('0xa0');if(_['isNil'](_0x16b8e2)){ut['logger']('[Preview][validateContact][Empty\x20Campaign]',_0x16b8e2);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this['isTrunkReachable'](_0x16b8e2['Trunk'])){ut[_0x5507('0x67')]('[Preview][validateContact][Trunk\x20not\x20working\x20correctly]',_0x5507('0x12e')+_0x16b8e2[_0x5507('0x2b')]+'\x20Trunk\x20is\x20not\x20active');if(!this[_0x5507('0x9d')](_0x16b8e2[_0x5507('0x9e')])){ut[_0x5507('0x67')](_0x5507('0x12f'),_0x16b8e2[_0x5507('0x2b')]+_0x5507('0x130'));return{'isValid':![],'message':'Trunk\x20not\x20working\x20correctly'};}}if(!ut[_0x5507('0x9c')](_0x16b8e2[_0x5507('0x38')])){ut[_0x5507('0x67')](_0x5507('0x131'),_0x16b8e2['name']+_0x5507('0x132'));return{'isValid':![],'message':'campaign\x20Name:\x20'+_0x16b8e2[_0x5507('0x2b')]+'\x20Not\x20Active'};}return{'isValid':!![],'message':_0x5507('0x133')};};Preview[_0x5507('0xf')]['execCall']=function(_0x27bc36,_0x30f2e4,_0x13a38f,_0x1998c7){var _0x3d3abe=this;return new BPromise(function(_0x5ab197,_0x27c05a){var _0x492aba=_0x27bc36[_0x5507('0xcb')];var _0x58f9a1=_0x3d3abe[_0x5507('0x9d')](_0x30f2e4[_0x5507('0x57')])?util[_0x5507('0x5c')](_0x5507('0x134'),_0x30f2e4[_0x5507('0x57')][_0x5507('0x2b')],_[_0x5507('0x87')](_0x30f2e4[_0x5507('0x3b')])?'':_0x30f2e4[_0x5507('0x3b')]['trim']()||'',_0x30f2e4[_0x5507('0x135')]>0x0?_0x13a38f[_0x5507('0x115')][_0x5507('0x136')](_0x30f2e4['dialCutDigit']):_0x13a38f[_0x5507('0x115')]):util[_0x5507('0x5c')](_0x5507('0x134'),_[_0x5507('0x87')](_0x30f2e4[_0x5507('0x9e')])?_0x30f2e4['Trunk']['name']:_0x30f2e4['TrunkBackup'][_0x5507('0x2b')],_[_0x5507('0x87')](_0x30f2e4['dialPrefix'])?'':_0x30f2e4['dialPrefix'][_0x5507('0x137')]()||'',_0x30f2e4[_0x5507('0x135')]>0x0?_0x13a38f[_0x5507('0x115')][_0x5507('0x136')](_0x30f2e4[_0x5507('0x135')]):_0x13a38f['phone']);var _0x7ad067=_0x3d3abe[_0x5507('0x9d')](_0x30f2e4[_0x5507('0x57')])?ut[_0x5507('0x138')](_0x30f2e4[_0x5507('0x57')][_0x5507('0x59')],_0x30f2e4[_0x5507('0x139')],_0x30f2e4['dialRandomLastDigitCallerIdNumber']>0x0?ut['getCallerIdRandom'](_0x30f2e4[_0x5507('0x13a')],_0x30f2e4[_0x5507('0x13b')]):_0x30f2e4[_0x5507('0x13a')]):ut[_0x5507('0x138')](_['isNil'](_0x30f2e4[_0x5507('0x9e')])?_0x30f2e4['Trunk'][_0x5507('0x59')]:_0x30f2e4['TrunkBackup'][_0x5507('0x59')],_0x30f2e4['dialOriginateCallerIdName'],_0x30f2e4[_0x5507('0x13b')]>0x0?ut[_0x5507('0x13c')](_0x30f2e4['dialOriginateCallerIdNumber'],_0x30f2e4[_0x5507('0x13b')]):_0x30f2e4[_0x5507('0x13a')]);if(_0x7ad067){_0x27bc36['originatecalleridname']=ut['extractCalleridName'](_0x7ad067);_0x27bc36[_0x5507('0x13d')]=ut['extractCalleridNumber'](_0x7ad067);}var _0x260571=ut['addVariables'](_0x30f2e4,_0x13a38f,_0x58f9a1,_0x7ad067,_0x492aba,_0x27bc36);_['merge'](_0x27bc36,ut['toLowerVariables'](_0x260571));_0x27bc36[_0x5507('0x90')]=moment()[_0x5507('0x5c')](_0x5507('0xb9'));ami[_0x5507('0x7a')](ut[_0x5507('0x13e')](_0x27bc36,_0x30f2e4,_0x260571,_0x27bc36['activeContact'],_0x1998c7))[_0x5507('0x86')](function(_0x2ad13e){_0x30f2e4['originated']+=0x1;logger['info']('[originated][increment]',_0x492aba,_0x5507('0xbe'),_0x30f2e4[_0x5507('0x2b')],_0x5507('0x75'),_0x30f2e4['originated']);_0x5ab197(_0x2ad13e);})[_0x5507('0x7c')](function(_0x521d46){ut[_0x5507('0x10b')](_0x27bc36,0xe,_0x5507('0x13f'));rpcDb[_0x5507('0x107')](_0x27bc36,_0x5507('0x140'));_0x27c05a(_0x521d46);});});};Preview[_0x5507('0xf')]['syncNewExten']=function(_0x594ed6){if(this[_0x5507('0x16')][_0x594ed6[_0x5507('0xb3')]]){this[_0x5507('0x16')][_0x594ed6[_0x5507('0xb3')]][_0x5507('0x141')]=_0x594ed6[_0x5507('0x141')];}};Preview[_0x5507('0xf')][_0x5507('0x1a')]=function(_0xb42d70){var _0x587f88=this;var _0x50225a=this[_0x5507('0x16')][_0xb42d70[_0x5507('0x142')]];if(_0x50225a){if(_0x50225a['lookAgent']&&this['agents'][_0x50225a[_0x5507('0x143')]]){ut[_0x5507('0x144')](_0x50225a,this[_0x5507('0x17')][_0x50225a[_0x5507('0x143')]][_0x5507('0x2b')],this[_0x5507('0x17')][_0x50225a[_0x5507('0x143')]]['id']);}var _0x188830=_[_0x5507('0x145')](_0x50225a);_0x188830['responsetime']=moment()['format'](_0x5507('0xb9'));var _0x5cce7e=_0x587f88[_0x5507('0x13')][_0x50225a[_0x5507('0x74')]];if(ut['isFailure'](_0xb42d70[_0x5507('0x146')])){if(_0x50225a['unlockAgent']){rpcDb['unlockContact'](_0x50225a[_0x5507('0xb5')]);}if(_0x50225a[_0x5507('0xb2')]){rpcDb[_0x5507('0x8f')](_0x50225a[_0x5507('0xb5')]);}ami['emit'](_0x5507('0x147'),ut[_0x5507('0xa5')](_0x50225a,_0x5507('0x148'),this[_0x5507('0x13')][_0x50225a[_0x5507('0x74')]]));this[_0x5507('0x149')](_0x188830,_0x5cce7e,_0xb42d70);}else{_0x50225a[_0x5507('0x90')]=moment()['format'](_0x5507('0xb9'));ut['logAgent'](_0x188830,0x4,_0x5507('0xc6'));rpcDb[_0x5507('0x107')](_0x188830,_0x5507('0x14a'));}}};Preview[_0x5507('0xf')][_0x5507('0x1c')]=function(_0x59347c){var _0x1b0fcd=this;var _0x162e83=this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]];var _0x524b4b;if(_0x162e83){_0x524b4b=this[_0x5507('0x13')][_0x162e83[_0x5507('0x74')]];logger[_0x5507('0x5f')](_0x5507('0x14b'),_0x59347c[_0x5507('0xb3')],_0x5507('0xbe'),_0x524b4b[_0x5507('0x2b')],_0x5507('0xcc'),_0x524b4b['pTalking']);}if(this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]]&&_0x59347c['linkedid']!==_0x59347c[_0x5507('0xcb')]){if(_0x59347c['cause']==='16'&&this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]][_0x5507('0xbc')]){this[_0x5507('0xa1')](_0x59347c,_0x59347c[_0x5507('0xb3')],_0x59347c[_0x5507('0x14c')]);}else if(this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]][_0x5507('0xbc')]){logger[_0x5507('0x5f')](_0x5507('0x14d'),_0x59347c[_0x5507('0xb3')],_0x59347c['cause'],'\x20Queue',_0x524b4b['name'],_0x5507('0xcc'),_0x524b4b['pTalking']);this['callProgressDetectingCustomer'](_0x59347c,_0x59347c[_0x5507('0xb3')],_0x59347c['cause']);}}else if(_0x162e83&&_[_0x5507('0x87')](_0x162e83['statedesc'])&&_0x524b4b[_0x5507('0x14e')]&&_0x59347c['linkedid']===_0x59347c['uniqueid']&&_[_0x5507('0x87')](_0x59347c[_0x5507('0x105')])&&_0x59347c[_0x5507('0x14c')]==='16'&&_0x59347c[_0x5507('0x14f')]==='6'&&_[_0x5507('0x103')](_0x162e83[_0x5507('0x150')])){if(_0x162e83['unlockAgent']){rpcDb[_0x5507('0x124')](_0x162e83['idContact']);}if(_0x162e83[_0x5507('0xb2')]){rpcDb['disableContact'](_0x162e83['idContact']);}_0x59347c[_0x5507('0x105')]='22';this[_0x5507('0x149')](_0x162e83,_0x524b4b,_0x59347c);}else if(_0x162e83&&_0x162e83[_0x5507('0x150')]){if(_0x59347c[_0x5507('0x14c')]==='16'&&this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]][_0x5507('0xbc')]){logger[_0x5507('0x5f')](_0x5507('0x151'),_0x59347c[_0x5507('0xb3')],_0x59347c[_0x5507('0x14c')],_0x5507('0xbe'),_0x524b4b[_0x5507('0x2b')],_0x5507('0xcc'),_0x524b4b[_0x5507('0x30')]);this['callProgressDetectingCustomer'](_0x59347c,_0x59347c[_0x5507('0xb3')],_0x59347c['cause']);}else if(this[_0x5507('0x16')][_0x59347c[_0x5507('0xb3')]]['dialAnswer']){logger[_0x5507('0x5f')](_0x5507('0x14d'),_0x59347c[_0x5507('0xb3')],_0x59347c[_0x5507('0x14c')],_0x5507('0xbe'),_0x524b4b[_0x5507('0x2b')],'pTalking:\x20',_0x524b4b[_0x5507('0x30')]);this['callProgressDetectingCustomer'](_0x59347c,_0x59347c['linkedid'],_0x59347c['cause']);}}};Preview[_0x5507('0xf')][_0x5507('0x20')]=function(_0x1d1026){if(this[_0x5507('0x16')][_0x1d1026[_0x5507('0x102')]]&&_0x1d1026[_0x5507('0x102')]!==_0x1d1026[_0x5507('0x152')]){this['callProgressDetectingCustomer'](_0x1d1026,_0x1d1026['destlinkedid'],_0x1d1026['dialstatus']);}};Preview['prototype'][_0x5507('0x1e')]=function(_0x358fe1){if(this['actions'][_0x358fe1[_0x5507('0xb3')]]&&_0x358fe1[_0x5507('0xb3')]!==_0x358fe1[_0x5507('0xcb')]&&!this[_0x5507('0x16')][_0x358fe1['linkedid']][_0x5507('0xbc')]){if(_0x358fe1[_0x5507('0x14c')]==='1'){this[_0x5507('0xa1')](_0x358fe1,_0x358fe1['linkedid'],_0x358fe1[_0x5507('0x14c')]);}}};Preview[_0x5507('0xf')][_0x5507('0x153')]=function(_0x2b874d,_0x52d25f,_0x5f4aad){if(this[_0x5507('0x16')][_0x2b874d]){if(_['isNil'](this[_0x5507('0x16')][_0x2b874d][_0x5507('0x154')])){this[_0x5507('0x16')][_0x2b874d][_0x5507('0x154')]={};}this[_0x5507('0x16')][_0x2b874d][_0x5507('0x154')][_0x52d25f]=_0x5f4aad;}};Preview[_0x5507('0xf')]['syncVarSet']=function(_0x54b044){try{if(!_[_0x5507('0x87')](_0x54b044)){if(ut[_0x5507('0x155')](_['keys'](_0x54b044[_0x5507('0x156')])[0x0])){this[_0x5507('0x153')](_0x54b044[_0x5507('0xcb')],_[_0x5507('0x157')](_0x54b044[_0x5507('0x156')])[0x0],_0x54b044[_0x5507('0x158')]);}}}catch(_0xc3a062){logger[_0x5507('0x159')](_0x5507('0x15a'),util[_0x5507('0x15b')](_0xc3a062,{'showHidden':![],'depth':null}));}};Preview[_0x5507('0xf')][_0x5507('0x26')]=function(_0x1b4923){if(_0x1b4923){if(this[_0x5507('0x16')][_0x1b4923[_0x5507('0x15c')]]){this[_0x5507('0x16')][_0x1b4923['transfertargetlinkedid']][_0x5507('0x150')]=!![];}}};Preview[_0x5507('0xf')][_0x5507('0x15d')]=function(_0x569635){if(_0x569635){if(this['actions'][_0x569635[_0x5507('0x15e')]]){this[_0x5507('0x16')][_0x569635[_0x5507('0x15e')]][_0x5507('0x150')]=!![];}}};module['exports']=Preview;