85474919bc5735596ce7a4adc92b155f73517134
[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 _0xd8b0=['[callProgressDetectingCustomer][logNoSuch]','dialGlobalMaxRetry','cloneAction','Global','countnosuchnumberretry','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','dialNoSuchNumberRetryFrequency','unlockAgent','activeContact','linkedid','YYYY-MM-DD\x20HH:mm:ss','responsetime','[syncHangup][talking][increment]','uniqueid','\x20Queue','connect','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','complete','outboundAnswerCallsDay','total','countglobal','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','[syncHangup][talking][decrement]','outboundBusyCallsDay','countbusyretry','Busy','busy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','dialBusyRetryFrequency','NOANSWER','countnoanswerretry','custom:agentnoanswer','noanswer','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerMaxRetry','dialNoAnswerRetryFrequency','CONGESTION','countcongestionretry','Congestion','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','CANCEL','countagentrejectretry','AgentReject','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','ABANDONED','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','dialAbandonedMaxRety','decrementTalkink','[default]','cause-txt','dialstatus','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','updateOriginated','[callProgressDetectingCustomer]','ANSWER','isUndefined','object','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','reason','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','checkInBlack','Contact','phone','VoiceQueueId','Contact\x20is\x20undefined','Queue','lookAgent','isEmpty','execCall','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Calling','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','SIP/%s','reachable','unmonitored','unlock','execRun','recallme','validateContact','isValid','checkIsBlackList','Contact.phone','[Preview][getContactPreview]','Call\x20unsuccessful','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','Empty\x20Campaign','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','[Preview][validateContact][Trunk\x20not\x20work]','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','trim','dialCutDigit','substring','getCallerId','dialRandomLastDigitCallerIdNumber','dialOriginateCallerIdNumber','getCallerIdRandom','originatecalleridname','addVariables','merge','toLowerVariables','variablesAction','[originated][increment]','OriginateError','channel','actionid','logLookAgent','clone','isFailure','unlockContact','idContact','custom:agentringnoanswer','rejected','callProgressDetectingAgent','Answer','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','transfer','[syncHangup][talking][transfer]','destlinkedid','destuniqueid','addVariable','variables','filterKey','keys','variable','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','exports','util','lodash','md5','ioredis','../../../config/environment','../../../config/logger','preview','../ami','./rpcDb','./action','redis','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','sequence','campaignsPreview','voiceQueues','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','loopCampaigns','type','strategy','answered','available','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','talking','unmanaged','waiting','dialActive','dialMethod','dialOriginateCallerIdName','dialPrefix','outboundAnswerAgiCallsDay','outboundBlacklistCallsDay','outboundCongestionCallsDay','outboundDropCallsDayCallersExit','outboundNoAnswerCallsDay','outboundOriginateFailureCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','originated','erlangCalls','erlangCallToSecond','erlangBusyFactor','startPredictive','Trunk','name','active','callerid','Interval','stringify','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','format','voice:queue:%s','sendMessageOneNotActive','paused','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20disactive','syncCampaigns','outbound','hasOwnProperty','setMessage','clearZombieChannel','[clearZombieChannels][talking]','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','contactId','ListId','Action','status','catch','No\x20such\x20channel','[clearZombieChannel]','loggerError','[Dialer][checkChannel][pTalking][Preview]','clearZombieChannels','size','recallMe','agentReadyId','then','isNil','length','getDiff','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','createCustomerHistory','createCustomerFinal','[HistoryRecallClose]','[getContactRecallMe]','IsNotLoggedIn','isActive','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','totalGlobal','NoSuchNumber','emit','custom:agentnosuchnumber','buildObj','nosuchnumber'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xd8b0,0xad));var _0x0d8b=function(_0xa464c9,_0x7c86d8){_0xa464c9=_0xa464c9-0x0;var _0x3d73c4=_0xd8b0[_0xa464c9];return _0x3d73c4;};'use strict';var util=require(_0x0d8b('0x0'));var _=require(_0x0d8b('0x1'));var BPromise=require('bluebird');var uuid=require('uuid');var moment=require('moment');var md5=require(_0x0d8b('0x2'));var Redis=require(_0x0d8b('0x3'));var config=require(_0x0d8b('0x4'));var logger=require(_0x0d8b('0x5'))(_0x0d8b('0x6'));var loggerAction=require('../../../config/logger')('actionPreview');var ami=require(_0x0d8b('0x7'));var rpcDb=require(_0x0d8b('0x8'));var Action=require(_0x0d8b('0x9'));var ut=require('./util/util');config[_0x0d8b('0xa')]=_[_0x0d8b('0xb')](config['redis'],{'host':_0x0d8b('0xc'),'port':0x18eb});var io=require(_0x0d8b('0xd'))(new Redis(config[_0x0d8b('0xa')]));var Sequence=function(){};Sequence[_0x0d8b('0xe')][_0x0d8b('0xf')]=function(_0x1cac62){this[_0x0d8b('0x10')]=this[_0x0d8b('0x10')]?this['tail'][_0x0d8b('0x11')](_0x1cac62):_0x1cac62();};function Preview(_0x4e0269){this[_0x0d8b('0x12')]=new Sequence();this[_0x0d8b('0x13')]=_0x4e0269[_0x0d8b('0x14')];this[_0x0d8b('0x15')]=_0x4e0269[_0x0d8b('0x15')];this[_0x0d8b('0x16')]={};this[_0x0d8b('0x17')]=_0x4e0269[_0x0d8b('0x17')];this[_0x0d8b('0x18')]=0x0;ami['on'](_0x0d8b('0x19'),this[_0x0d8b('0x1a')][_0x0d8b('0x1b')](this));ami['on'](_0x0d8b('0x1c'),this[_0x0d8b('0x1d')]['bind'](this));ami['on'](_0x0d8b('0x1e'),this[_0x0d8b('0x1f')][_0x0d8b('0x1b')](this));ami['on'](_0x0d8b('0x20'),this[_0x0d8b('0x21')]['bind'](this));ami['on'](_0x0d8b('0x22'),this[_0x0d8b('0x23')][_0x0d8b('0x1b')](this));ami['on'](_0x0d8b('0x24'),this[_0x0d8b('0x25')][_0x0d8b('0x1b')](this));ami['on'](_0x0d8b('0x26'),this[_0x0d8b('0x27')]['bind'](this));ami['on'](_0x0d8b('0x28'),this[_0x0d8b('0x29')][_0x0d8b('0x1b')](this));this[_0x0d8b('0x2a')](this[_0x0d8b('0x13')]);}function emit(_0x5b709c,_0x393beb,_0x352c17){io['to'](_0x5b709c)['emit'](_0x393beb,_0x352c17);}function emitCampaignPreview(_0x4f0a1a){if(_0x4f0a1a[_0x0d8b('0x2b')]==='outbound'){var _0x56c729={'id':_0x4f0a1a['id'],'name':_0x4f0a1a['name'],'strategy':_0x4f0a1a[_0x0d8b('0x2c')],'answered':_0x4f0a1a[_0x0d8b('0x2d')],'available':_0x4f0a1a[_0x0d8b('0x2e')],'loggedIn':_0x4f0a1a[_0x0d8b('0x2f')],'pTalking':_0x4f0a1a[_0x0d8b('0x30')],'sumBillable':_0x4f0a1a[_0x0d8b('0x31')],'sumDuration':_0x4f0a1a[_0x0d8b('0x32')],'sumHoldTime':_0x4f0a1a[_0x0d8b('0x33')]||0x0,'talking':_0x4f0a1a[_0x0d8b('0x34')],'total':_0x4f0a1a['total'],'type':_0x4f0a1a[_0x0d8b('0x2b')],'unmanaged':_0x4f0a1a[_0x0d8b('0x35')],'abandoned':_0x4f0a1a['abandoned'],'waiting':_0x4f0a1a[_0x0d8b('0x36')],'loggedInDb':_0x4f0a1a['loggedInDb'],'dialActive':_0x4f0a1a[_0x0d8b('0x37')],'dialMethod':_0x4f0a1a[_0x0d8b('0x38')],'dialOriginateCallerIdName':_0x4f0a1a[_0x0d8b('0x39')],'dialOriginateCallerIdNumber':_0x4f0a1a['dialOriginateCallerIdNumber'],'dialOriginateTimeout':_0x4f0a1a['dialOriginateTimeout'],'dialPrefix':_0x4f0a1a[_0x0d8b('0x3a')],'outboundAnswerAgiCallsDay':_0x4f0a1a[_0x0d8b('0x3b')],'outboundAnswerCallsDay':_0x4f0a1a['outboundAnswerCallsDay'],'outboundBlacklistCallsDay':_0x4f0a1a[_0x0d8b('0x3c')],'outboundBusyCallsDay':_0x4f0a1a['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0x4f0a1a[_0x0d8b('0x3d')],'outboundDropCallsDayACS':_0x4f0a1a['outboundDropCallsDayACS'],'outboundDropCallsDayCallersExit':_0x4f0a1a[_0x0d8b('0x3e')],'outboundDropCallsDayTimeout':_0x4f0a1a['outboundDropCallsDayTimeout'],'outboundNoAnswerCallsDay':_0x4f0a1a[_0x0d8b('0x3f')],'outboundNoSuchCallsDay':_0x4f0a1a['outboundNoSuchCallsDay'],'outboundOriginateFailureCallsDay':_0x4f0a1a[_0x0d8b('0x40')],'outboundReCallsDay':_0x4f0a1a['outboundReCallsDay'],'outboundRejectCallsDay':_0x4f0a1a[_0x0d8b('0x41')],'outboundUnknownCallsDay':_0x4f0a1a[_0x0d8b('0x42')],'outboundAbandonedCallsDay':_0x4f0a1a[_0x0d8b('0x43')],'predictiveIntervalAnsweredCalls':_0x4f0a1a['predictiveIntervalAnsweredCalls'],'predictiveIntervalAvgHoldtime':_0x4f0a1a['predictiveIntervalAvgHoldtime'],'predictiveIntervalAvgTalktime':_0x4f0a1a['predictiveIntervalAvgTalktime'],'predictiveIntervalDroppedCallsCallersExit':_0x4f0a1a[_0x0d8b('0x44')],'predictiveIntervalDroppedCallsTimeout':_0x4f0a1a['predictiveIntervalDroppedCallsTimeout'],'predictiveIntervalErlangCalls':_0x4f0a1a[_0x0d8b('0x45')],'predictiveIntervalErlangCallsDroppedCalls':_0x4f0a1a['predictiveIntervalErlangCallsDroppedCalls'],'predictiveIntervalHitRate':_0x4f0a1a['predictiveIntervalHitRate'],'predictiveIntervalMultiplicativeFactor':_0x4f0a1a[_0x0d8b('0x46')],'predictiveIntervalPauses':_0x4f0a1a[_0x0d8b('0x47')],'predictiveIntervalAvailable':_0x4f0a1a[_0x0d8b('0x48')],'predictiveIntervalTotalCalls':_0x4f0a1a[_0x0d8b('0x49')],'message':_0x4f0a1a[_0x0d8b('0x4a')],'originated':_0x4f0a1a[_0x0d8b('0x4b')],'erlangCalls':_0x4f0a1a[_0x0d8b('0x4c')],'erlangCallToSecond':_0x4f0a1a[_0x0d8b('0x4d')],'erlangAbandonmentRate':_0x4f0a1a['erlangAbandonmentRate'],'erlangBusyFactor':_0x4f0a1a[_0x0d8b('0x4e')],'startPredictive':_0x4f0a1a[_0x0d8b('0x4f')],'startProgressive':_0x4f0a1a['startProgressive']};if(_0x4f0a1a[_0x0d8b('0x50')]){_0x56c729[_0x0d8b('0x50')]={'id':_0x4f0a1a[_0x0d8b('0x50')]['id'],'name':_0x4f0a1a['Trunk'][_0x0d8b('0x51')],'active':_0x4f0a1a[_0x0d8b('0x50')][_0x0d8b('0x52')],'callerid':_0x4f0a1a[_0x0d8b('0x50')][_0x0d8b('0x53')]};}if(_0x4f0a1a['Interval']){_0x56c729[_0x0d8b('0x54')]={'id':_0x4f0a1a[_0x0d8b('0x54')]['id'],'name':_0x4f0a1a['Interval'][_0x0d8b('0x51')]};}var _0x3cc3ee=md5(JSON[_0x0d8b('0x55')](_0x56c729));if(_0x4f0a1a[_0x0d8b('0x2')]!==_0x3cc3ee){_0x4f0a1a[_0x0d8b('0x2')]=_0x3cc3ee;emit(util['format']('voice:queue:%s',_0x56c729[_0x0d8b('0x51')]),'voice_queue:save',_0x56c729);}}}function emitVoiceQueueChannelRemove(_0x531c55){logger[_0x0d8b('0x56')](_0x0d8b('0x57'),JSON[_0x0d8b('0x55')](_0x531c55));emit(util[_0x0d8b('0x58')](_0x0d8b('0x59'),_0x531c55[_0x0d8b('0x51')]),'voice_queue_channel:remove',_0x531c55);}function notSendMessagesQueue(_0x6e5bab){if(_0x6e5bab[_0x0d8b('0x5a')]){if(_0x6e5bab[_0x0d8b('0x4b')]===0x0&&_0x6e5bab[_0x0d8b('0x30')]===0x0){_0x6e5bab[_0x0d8b('0x5a')]=![];_0x6e5bab[_0x0d8b('0x2e')]=0x0;_0x6e5bab[_0x0d8b('0x5b')]=0x0;_0x6e5bab['message']=_0x0d8b('0x5c');ut[_0x0d8b('0x5d')](_0x0d8b('0x5e'),_0x6e5bab[_0x0d8b('0x51')]+'\x20is\x20not\x20active');}else{_0x6e5bab[_0x0d8b('0x4a')]='IS_DISACTIVED';ut[_0x0d8b('0x5d')](_0x0d8b('0x5e'),_0x6e5bab[_0x0d8b('0x51')]+_0x0d8b('0x5f'));}emitCampaignPreview(_0x6e5bab);}}Preview[_0x0d8b('0xe')][_0x0d8b('0x2a')]=function(){var _0x1ff17d=this;setInterval(function(){_0x1ff17d[_0x0d8b('0x60')]();},0x7cf);};Preview[_0x0d8b('0xe')][_0x0d8b('0x60')]=function(){var _0x482069=this['campaignsPreview'];this['clockClearZombieChannels']+=0x1;for(var _0x4d0811 in _0x482069){if(_0x482069['hasOwnProperty'](_0x4d0811)&&(_0x482069[_0x4d0811][_0x0d8b('0x38')]===_0x0d8b('0x6')||_0x482069[_0x4d0811][_0x0d8b('0x38')]==='booked')&&_0x482069[_0x4d0811]['type']===_0x0d8b('0x61')){if(this[_0x0d8b('0x18')]>0x7){this[_0x0d8b('0x18')]=0x0;this['clearZombieChannels']();}}if(_0x482069[_0x0d8b('0x62')](_0x4d0811)&&_0x482069[_0x4d0811][_0x0d8b('0x38')]==='preview'&&_0x482069[_0x4d0811]['type']===_0x0d8b('0x61')){if(_0x482069[_0x4d0811]['dialActive']){this[_0x0d8b('0x63')](_0x482069[_0x4d0811]);this['recallMe'](_0x482069[_0x4d0811]);}else{notSendMessagesQueue(_0x482069[_0x4d0811]);}}}};Preview['prototype'][_0x0d8b('0x64')]=function(_0x194f17){var _0x5a75c7=this;this['sequence']['enqueue'](function(){if(!_['isNil'](_0x5a75c7[_0x0d8b('0x16')][_0x194f17])){loggerAction[_0x0d8b('0x56')](_0x0d8b('0x65'),_0x194f17,'Queue',_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x66')],_0x0d8b('0x67'),JSON[_0x0d8b('0x55')](_0x5a75c7[_0x0d8b('0x13')][_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x66')]][_0x0d8b('0x4b')]),_0x0d8b('0x68'),JSON[_0x0d8b('0x55')](_0x5a75c7[_0x0d8b('0x13')][_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x66')]][_0x0d8b('0x30')]),JSON[_0x0d8b('0x55')](_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x69')]),JSON[_0x0d8b('0x55')](_[_0x0d8b('0x6a')](_0x5a75c7['actions'][_0x194f17],[_0x0d8b('0x6b'),'UserId','VoiceQueueId',_0x0d8b('0x6c')])));return ami[_0x0d8b('0x6d')]({'action':_0x0d8b('0x6e'),'channel':_0x5a75c7[_0x0d8b('0x16')][_0x194f17]['channel']})[_0x0d8b('0x6f')](function(_0x1106d6){if(_0x1106d6[_0x0d8b('0x4a')]===_0x0d8b('0x70')){setTimeout(function(){if(_0x5a75c7[_0x0d8b('0x16')][_0x194f17]){ut['updateOriginated'](_0x5a75c7['campaignsPreview'][_0x5a75c7['actions'][_0x194f17]['queue']],_0x0d8b('0x71'));if(_0x5a75c7[_0x0d8b('0x16')][_0x194f17]['dialAnswer']===!![]){ut['decrementTalkink'](_0x5a75c7[_0x0d8b('0x13')][_0x5a75c7[_0x0d8b('0x16')][_0x194f17]['queue']],'[clearZombieChannel]');ut[_0x0d8b('0x72')](_0x0d8b('0x73')+_0x194f17,_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x66')]);}ut[_0x0d8b('0x72')]('[Dialer][checkChannel][Preview]'+_0x194f17,_0x5a75c7[_0x0d8b('0x16')][_0x194f17][_0x0d8b('0x66')]);delete _0x5a75c7['actions'][_0x194f17];}},0x2328);}});}});};Preview['prototype'][_0x0d8b('0x74')]=function(){var _0x3f2d95=this;loggerAction['info']('[action]',_[_0x0d8b('0x75')](this[_0x0d8b('0x16')]));for(var _0x377027 in this[_0x0d8b('0x16')]){if(_0x3f2d95['actions'][_0x0d8b('0x62')](_0x377027)){_0x3f2d95['clearZombieChannel'](_0x377027);}}};Preview['prototype'][_0x0d8b('0x76')]=function(_0x44043b){var _0x54aa03=this;rpcDb['getContactRecallMe'](_0x44043b['id'],ut[_0x0d8b('0x77')](this[_0x0d8b('0x17')]))[_0x0d8b('0x78')](function(_0x2c1eb0){if(!_[_0x0d8b('0x79')](_0x2c1eb0)){for(var _0xb66e76=0x0;_0xb66e76<_0x2c1eb0[_0x0d8b('0x7a')];_0xb66e76+=0x1){if(ut[_0x0d8b('0x7b')](_0x2c1eb0[_0xb66e76]['scheduledat'])<_0x44043b[_0x0d8b('0x7c')]*0x3c){if(_0x2c1eb0[_0xb66e76][_0x0d8b('0x7d')]&&!_0x2c1eb0[_0xb66e76][_0x0d8b('0x7d')][_0x0d8b('0x7e')]){_0x54aa03[_0x0d8b('0x7f')](_0x2c1eb0[_0xb66e76]['id'])[_0x0d8b('0x78')](ut[_0x0d8b('0x80')](_0x0d8b('0x81')))[_0x0d8b('0x6f')](ut['logger2'](_0x0d8b('0x81')));}else{rpcDb[_0x0d8b('0x82')](_0x2c1eb0[_0xb66e76]['id']);}}else{var _0x180b7b=new Action(_0x2c1eb0[_0xb66e76],_0x44043b);_0x180b7b[_0x0d8b('0x83')]=moment()[_0x0d8b('0x58')]('YYYY-MM-DD\x20HH:mm:ss');_0x44043b[_0x0d8b('0x84')]+=0x1;ut[_0x0d8b('0x85')](_0x180b7b,0x17,_0x0d8b('0x86'));if(_0x44043b[_0x0d8b('0x87')]){rpcDb[_0x0d8b('0x88')](ut['createBody'](_0x2c1eb0[_0xb66e76]));rpcDb['createCustomerHistory'](_0x180b7b,_0x0d8b('0x89'));}else{ut[_0x0d8b('0x85')](_0x180b7b,0x16,_0x0d8b('0x8a'));rpcDb[_0x0d8b('0x8b')](_0x180b7b,'[HistoryRecallClose]');rpcDb[_0x0d8b('0x8c')](_0x180b7b,_0x0d8b('0x8d'));}}}}})[_0x0d8b('0x6f')](ut['logger2'](_0x0d8b('0x8e')));};Preview['prototype'][_0x0d8b('0x63')]=function(_0x3ed63e){_0x3ed63e[_0x0d8b('0x5a')]=!![];if(ut[_0x0d8b('0x8f')](_0x3ed63e[_0x0d8b('0x2f')])){_0x3ed63e[_0x0d8b('0x4a')]='AGENTS_NOT_LOGGED';}else if(!ut[_0x0d8b('0x90')](_0x3ed63e['dialActive'])){_0x3ed63e[_0x0d8b('0x4a')]=_0x0d8b('0x5c');}else if(!this[_0x0d8b('0x91')](_0x3ed63e[_0x0d8b('0x50')])){if(!this['isTrunkReachable'](_0x3ed63e[_0x0d8b('0x92')])){_0x3ed63e[_0x0d8b('0x4a')]=_0x0d8b('0x93');}else{_0x3ed63e[_0x0d8b('0x4a')]=_0x0d8b('0x94');}}else{_0x3ed63e[_0x0d8b('0x4a')]=_0x0d8b('0x94');}emitCampaignPreview(_0x3ed63e);};Preview[_0x0d8b('0xe')][_0x0d8b('0x95')]=function(_0x34affb,_0x57e39a,_0x4ee1e8){var _0x6388ae=this;var _0x3eb647=this['actions'][_0x57e39a];var _0xb1aa96=this['campaignsPreview'][_0x3eb647['queue']];var _0x22ee20;if(_0xb1aa96){switch(_0x4ee1e8){case'1':_0xb1aa96[_0x0d8b('0x96')]+=0x1;_0x3eb647['countnosuchnumberretry']+=0x1;_0x3eb647['countglobal']=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0x0,_0x0d8b('0x98'));ami[_0x0d8b('0x99')](_0x0d8b('0x9a'),ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0x9c')));rpcDb['createCustomerHistory'](_0x3eb647,_0x0d8b('0x9d'));if(ut['totalGlobal'](_0x3eb647)>=_0xb1aa96[_0x0d8b('0x9e')]){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0xf,_0x0d8b('0xa0'));rpcDb[_0x0d8b('0x8c')](_0x22ee20,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{if(_0x3eb647[_0x0d8b('0xa1')]>=_0xb1aa96['dialNoSuchNumberMaxRetry']){rpcDb[_0x0d8b('0x8c')](_0x3eb647,_0x0d8b('0xa2'));}else{rpcDb[_0x0d8b('0xa3')](ut[_0x0d8b('0xa4')](_0x3eb647,_0x0d8b('0xa1'),_0xb1aa96[_0x0d8b('0xa5')]),_0x3eb647[_0x0d8b('0xa6')],_0x3eb647[_0x0d8b('0xa7')]);}}delete this[_0x0d8b('0x16')][_0x34affb[_0x0d8b('0xa8')]];break;case'ANSWER':var _0x1436b3=moment()['format'](_0x0d8b('0xa9'));_0x3eb647[_0x0d8b('0xaa')]=_0x1436b3;_0x3eb647['answertime']=_0x1436b3;_0x3eb647[_0x0d8b('0x69')]=!![];_0xb1aa96['pTalking']+=0x1;logger[_0x0d8b('0x56')](_0x0d8b('0xab'),_0x3eb647[_0x0d8b('0xac')],_0x0d8b('0xad'),_0xb1aa96[_0x0d8b('0x51')],_0x0d8b('0x68'),_0xb1aa96[_0x0d8b('0x30')]);ami[_0x0d8b('0x99')]('custom:agentconnect',ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0xae'),this['campaignsPreview'][_0x3eb647[_0x0d8b('0x66')]]));if(_0xb1aa96[_0x0d8b('0xaf')]){ami[_0x0d8b('0x99')](_0x0d8b('0xb0'),ut[_0x0d8b('0xb1')](_0x3eb647));}break;case'16':ami[_0x0d8b('0x99')](_0x0d8b('0xb2'),ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0xb3'),this[_0x0d8b('0x13')][_0x3eb647[_0x0d8b('0x66')]]));emitVoiceQueueChannelRemove(ut[_0x0d8b('0x9b')](_0x3eb647,'complete'));_0xb1aa96[_0x0d8b('0xb4')]+=0x1;_0xb1aa96[_0x0d8b('0xb5')]+=0x1;_0xb1aa96[_0x0d8b('0x2d')]+=0x1;ut['decrementTalkink'](_0xb1aa96,'[16]');_0x3eb647[_0x0d8b('0xb6')]=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0x4,'Answer');rpcDb['createCustomerHistory'](_0x3eb647,_0x0d8b('0xb7'));rpcDb[_0x0d8b('0x8c')](_0x3eb647,_0x0d8b('0xb8'));rpcDb[_0x0d8b('0xb9')](_0x3eb647);_0xb1aa96[_0x0d8b('0x32')]+=_0x3eb647[_0x0d8b('0xba')];_0xb1aa96[_0x0d8b('0x31')]+=_0x3eb647[_0x0d8b('0xba')];logger[_0x0d8b('0x56')](_0x0d8b('0xbb'),_0x3eb647[_0x0d8b('0xac')],_0x0d8b('0xad'),_0xb1aa96[_0x0d8b('0x51')],'pTalking:\x20',_0xb1aa96[_0x0d8b('0x30')]);delete this[_0x0d8b('0x16')][_0x34affb['linkedid']];break;case'BUSY':_0xb1aa96[_0x0d8b('0xbc')]+=0x1;_0x3eb647[_0x0d8b('0xbd')]+=0x1;_0x3eb647[_0x0d8b('0xb6')]=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0x5,_0x0d8b('0xbe'));ami['emit']('custom:agentbusy',ut['buildObj'](_0x3eb647,_0x0d8b('0xbf')));rpcDb[_0x0d8b('0x8b')](_0x3eb647,_0x0d8b('0xc0'));if(ut[_0x0d8b('0x97')](_0x3eb647)>=_0xb1aa96[_0x0d8b('0x9e')]){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0xf,'Global');rpcDb[_0x0d8b('0x8c')](_0x22ee20,_0x0d8b('0xc1'));}else{if(_0x3eb647['countbusyretry']>=_0xb1aa96[_0x0d8b('0xc2')]){rpcDb['createCustomerFinal'](_0x3eb647,_0x0d8b('0xc0'));}else{rpcDb[_0x0d8b('0xa3')](ut[_0x0d8b('0xa4')](_0x3eb647,_0x0d8b('0xbd'),_0xb1aa96[_0x0d8b('0xc3')]),_0x3eb647[_0x0d8b('0xa6')],_0x3eb647[_0x0d8b('0xa7')]);}}break;case _0x0d8b('0xc4'):_0xb1aa96[_0x0d8b('0x3f')]+=0x1;_0x3eb647[_0x0d8b('0xc5')]+=0x1;_0x3eb647[_0x0d8b('0xb6')]=ut[_0x0d8b('0x97')](_0x3eb647);ut['logCustomer'](_0x3eb647,0x3,'NoAnswer');ami[_0x0d8b('0x99')](_0x0d8b('0xc6'),ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0xc7')));rpcDb[_0x0d8b('0x8b')](_0x3eb647,_0x0d8b('0xc8'));if(ut[_0x0d8b('0x97')](_0x3eb647)>=_0xb1aa96['dialGlobalMaxRetry']){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0xf,'Global');rpcDb[_0x0d8b('0x8c')](_0x22ee20,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0x3eb647['countnoanswerretry']>=_0xb1aa96[_0x0d8b('0xc9')]){rpcDb[_0x0d8b('0x8c')](_0x3eb647,_0x0d8b('0xc8'));}else{rpcDb[_0x0d8b('0xa3')](ut[_0x0d8b('0xa4')](_0x3eb647,_0x0d8b('0xc5'),_0xb1aa96[_0x0d8b('0xca')]),_0x3eb647[_0x0d8b('0xa6')],_0x3eb647[_0x0d8b('0xa7')]);}}break;case _0x0d8b('0xcb'):_0xb1aa96[_0x0d8b('0x3d')]+=0x1;_0x3eb647[_0x0d8b('0xcc')]+=0x1;_0x3eb647['countglobal']=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0x8,_0x0d8b('0xcd'));ami['emit']('custom:agentcongestion',ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0xce')));rpcDb[_0x0d8b('0x8b')](_0x3eb647,_0x0d8b('0xcf'));if(ut[_0x0d8b('0x97')](_0x3eb647)>=_0xb1aa96[_0x0d8b('0x9e')]){_0x22ee20=ut['cloneAction'](_0x3eb647,0xf,_0x0d8b('0xa0'));rpcDb[_0x0d8b('0x8c')](_0x22ee20,_0x0d8b('0xd0'));}else{if(_0x3eb647[_0x0d8b('0xcc')]>=_0xb1aa96[_0x0d8b('0xd1')]){rpcDb['createCustomerFinal'](_0x3eb647,'[callProgressDetectingCustomer][logCongestion]');}else{rpcDb[_0x0d8b('0xa3')](ut[_0x0d8b('0xa4')](_0x3eb647,_0x0d8b('0xcc'),_0xb1aa96['dialBusyRetryFrequency']),_0x3eb647[_0x0d8b('0xa6')],_0x3eb647[_0x0d8b('0xa7')]);}}break;case _0x0d8b('0xd2'):_0xb1aa96['outboundRejectCallsDay']+=0x1;_0x3eb647[_0x0d8b('0xd3')]+=0x1;_0x3eb647[_0x0d8b('0xb6')]=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0x14,_0x0d8b('0xd4'));ami[_0x0d8b('0x99')](_0x0d8b('0xd5'),ut[_0x0d8b('0x9b')](_0x3eb647,_0x0d8b('0xd6')));rpcDb['createCustomerHistory'](_0x3eb647,_0x0d8b('0xd7'));if(ut[_0x0d8b('0x97')](_0x3eb647)>=_0xb1aa96[_0x0d8b('0x9e')]){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0x14,_0x0d8b('0xd4'));rpcDb[_0x0d8b('0x8c')](_0x22ee20,_0x0d8b('0xd8'));}else{if(_0x3eb647[_0x0d8b('0xd3')]>=_0xb1aa96[_0x0d8b('0xd9')]){rpcDb['createCustomerFinal'](_0x3eb647,'[callProgressDetectingCustomer][logAgentReject]');}else{rpcDb[_0x0d8b('0xa3')](ut[_0x0d8b('0xa4')](_0x3eb647,_0x0d8b('0xd3'),_0xb1aa96[_0x0d8b('0xda')]),_0x3eb647['unlockAgent'],_0x3eb647[_0x0d8b('0xa7')]);}}break;case _0x0d8b('0xdb'):_0xb1aa96['outboundAbandonedCallsDay']+=0x1;_0x3eb647[_0x0d8b('0xdc')]+=0x1;_0x3eb647['countglobal']=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0xb,_0x0d8b('0xdd'));rpcDb[_0x0d8b('0x8b')](_0x3eb647,_0x0d8b('0xde'));if(ut[_0x0d8b('0x97')](_0x3eb647)>=_0xb1aa96[_0x0d8b('0x9e')]){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0xf,'Global');rpcDb[_0x0d8b('0x8c')](_0x22ee20,'[callProgressDetectingCustomer][logAbandoned]');}else{if(_0x3eb647['countabandonedetry']>=_0xb1aa96[_0x0d8b('0xdf')]){rpcDb['createCustomerFinal'](_0x3eb647,_0x0d8b('0xde'));}else{rpcDb[_0x0d8b('0xa3')](ut['scheduledAt'](_0x3eb647,_0x0d8b('0xdc'),_0xb1aa96['dialAbandonedRetryFrequency']),_0x3eb647['unlockAgent'],_0x3eb647[_0x0d8b('0xa7')]);}}break;default:if(_0x3eb647[_0x0d8b('0x69')]){ut[_0x0d8b('0xe0')](_0xb1aa96,_0x0d8b('0xe1'));ut[_0x0d8b('0x72')]('[Dialer][decrementTalkink][no\x20Hangup][Preview]'+_0xb1aa96['name'],_0x34affb);}_0xb1aa96[_0x0d8b('0x42')]+=0x1;_0x3eb647[_0x0d8b('0xb6')]=ut[_0x0d8b('0x97')](_0x3eb647);ut[_0x0d8b('0x85')](_0x3eb647,0xc,_0x34affb[_0x0d8b('0xe2')]||_0x34affb[_0x0d8b('0xe3')]);rpcDb[_0x0d8b('0x8b')](_0x3eb647,_0x0d8b('0xe4'));if(ut['totalGlobal'](_0x3eb647)>=_0xb1aa96['dialGlobalMaxRetry']){_0x22ee20=ut[_0x0d8b('0x9f')](_0x3eb647,0xf,_0x0d8b('0xa0'));rpcDb['createCustomerFinal'](_0x22ee20,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb['createCustomerFinal'](_0x3eb647,_0x0d8b('0xe5'));}delete this[_0x0d8b('0x16')][_0x34affb[_0x0d8b('0xa8')]];}if(!(_0x3eb647['dialAnswer']&&_0x4ee1e8==='16')){ut[_0x0d8b('0xe6')](_0xb1aa96,_0x0d8b('0xe7'));logger[_0x0d8b('0x56')]('[originated][decrement][callProgressDetectingCustomer]',_0x3eb647[_0x0d8b('0xac')],'\x20Queue',_0xb1aa96[_0x0d8b('0x51')],'originated:\x20',_0xb1aa96[_0x0d8b('0x4b')]);}if(_0x4ee1e8!==_0x0d8b('0xe8')){delete this[_0x0d8b('0x16')][_0x34affb[_0x0d8b('0xa8')]];delete this[_0x0d8b('0x16')][_0x34affb['destlinkedid']];}}};Preview[_0x0d8b('0xe')]['callProgressDetectingAgent']=function(_0x2d010e,_0x4bd01c,_0x165baa){if(_['isUndefined'](_0x4bd01c)&&'object'!==typeof _0x4bd01c){return;}if(_[_0x0d8b('0xe9')](_0x165baa)&&_0x0d8b('0xea')!==typeof _0x165baa){return;}switch(_0x165baa['reason']){case'0':ut[_0x0d8b('0xeb')](_0x2d010e,0x0,_0x0d8b('0x98'));rpcDb[_0x0d8b('0xec')](_0x2d010e,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut['logAgent'](_0x2d010e,0x3,'NoAnswer');rpcDb[_0x0d8b('0xec')](_0x2d010e,_0x0d8b('0xed'));break;case'5':ut[_0x0d8b('0xeb')](_0x2d010e,0x5,_0x0d8b('0xbe'));rpcDb[_0x0d8b('0xec')](_0x2d010e,_0x0d8b('0xee'));break;case'8':ut[_0x0d8b('0xeb')](_0x2d010e,0x8,_0x0d8b('0xcd'));rpcDb[_0x0d8b('0xec')](_0x2d010e,_0x0d8b('0xef'));break;case'22':ut['logAgent'](_0x2d010e,0x16,_0x0d8b('0xf0'));rpcDb[_0x0d8b('0xec')](_0x2d010e,_0x0d8b('0xf1'));break;default:ut['logAgent'](_0x2d010e,0xc,_0x165baa[_0x0d8b('0xf2')]);rpcDb[_0x0d8b('0xec')](_0x2d010e,_0x0d8b('0xef'));}ut[_0x0d8b('0xe6')](_0x4bd01c,_0x0d8b('0xf3'));logger[_0x0d8b('0x56')](_0x0d8b('0xf4'),_0x2d010e[_0x0d8b('0xac')],_0x0d8b('0xad'),_0x4bd01c[_0x0d8b('0x51')],_0x0d8b('0x67'),_0x4bd01c[_0x0d8b('0x4b')]);delete this['actions'][_0x2d010e[_0x0d8b('0xac')]];};Preview[_0x0d8b('0xe')][_0x0d8b('0xf5')]=function(_0x31baaf,_0x590889,_0x55215b,_0x11e5c2,_0x853bee){var _0x222deb=this;return new BPromise(function(_0x59698d,_0x4e2323){if(_['isNil'](_0x590889)||_[_0x0d8b('0x79')](_0x590889['Contact'])||_[_0x0d8b('0x79')](_0x590889[_0x0d8b('0xf6')][_0x0d8b('0xf7')])||_[_0x0d8b('0x79')](_0x590889[_0x0d8b('0xf8')])){_0x4e2323(ut[_0x0d8b('0x4a')](_0x0d8b('0xf9'),_0x11e5c2,_0x853bee));return;}var _0x16994f=uuid['v4']();var _0x5dbe4c=_0x222deb[_0x0d8b('0x13')][_0x590889[_0x0d8b('0xfa')][_0x0d8b('0x51')]];var _0x6b4a65=_0x55215b?_0x222deb['agents'][_0x55215b]['id']:undefined;_0x222deb[_0x0d8b('0x16')][_0x16994f]=new Action(_0x590889,_0x5dbe4c,_0x16994f,_0x55215b,_0x6b4a65);var _0x62fedf=_0x222deb[_0x0d8b('0x16')][_0x16994f];_0x62fedf[_0x0d8b('0xa6')]=_0x11e5c2;_0x62fedf['activeContact']=_0x853bee;_0x62fedf[_0x0d8b('0xfb')]=_0x55215b;if(_[_0x0d8b('0xfc')](_0x31baaf)){_0x222deb[_0x0d8b('0xfd')](_0x62fedf,_0x5dbe4c,_0x590889,_0x55215b)[_0x0d8b('0x78')](function(_0x572329){logger[_0x0d8b('0x56')]('[Preview][execCall][success]',_0x0d8b('0xfe')+_0x62fedf['queue']+_0x0d8b('0xff')+_0x62fedf['idContact'],JSON[_0x0d8b('0x55')](_0x572329));ami['emit'](_0x0d8b('0x100'),ut['buildObj'](_0x62fedf,_0x0d8b('0x101'),_0x222deb['campaignsPreview'][_0x62fedf[_0x0d8b('0x66')]]));_0x59698d(ut['message'](_0x0d8b('0x102')));})[_0x0d8b('0x6f')](function(_0x507587){ut['logger']('[Preview][execCall][failure]',_0x507587);_0x4e2323(ut[_0x0d8b('0x4a')]('Call\x20failed',_0x11e5c2,_0x853bee));});}else{_0x5dbe4c[_0x0d8b('0x3c')]+=0x1;ut['logBlacklist'](_0x62fedf);rpcDb[_0x0d8b('0x103')](_0x62fedf,_0x0d8b('0x104'));delete _0x222deb[_0x0d8b('0x16')][_0x16994f];_0x4e2323(ut[_0x0d8b('0x4a')](_0x0d8b('0x105'),_0x11e5c2,_0x853bee));}});};Preview[_0x0d8b('0xe')]['isTrunkReachable']=function(_0x58d013){return!_[_0x0d8b('0x79')](_0x58d013)&&!_['isNil'](_0x58d013[_0x0d8b('0x51')])&&!_[_0x0d8b('0x79')](_0x58d013[_0x0d8b('0x52')])&&_0x58d013['active']&&!_[_0x0d8b('0x79')](this['trunks'][util[_0x0d8b('0x58')](_0x0d8b('0x106'),_0x58d013[_0x0d8b('0x51')])])&&!_[_0x0d8b('0x79')](this['trunks'][util[_0x0d8b('0x58')](_0x0d8b('0x106'),_0x58d013[_0x0d8b('0x51')])]['status'])&&(this[_0x0d8b('0x15')][util['format'](_0x0d8b('0x106'),_0x58d013[_0x0d8b('0x51')])][_0x0d8b('0x6e')]===_0x0d8b('0x107')||this[_0x0d8b('0x15')][util[_0x0d8b('0x58')](_0x0d8b('0x106'),_0x58d013[_0x0d8b('0x51')])][_0x0d8b('0x6e')]===_0x0d8b('0x108'));};Preview[_0x0d8b('0xe')][_0x0d8b('0x7f')]=function(_0x50b987,_0x3c2fb9){var _0xb816d7=this;return new BPromise(function(_0x4f5d39,_0x2cc63a){_0xb816d7['execRun'](_0x50b987,_0x3c2fb9)[_0x0d8b('0x78')](function(_0x4a04c6){_0x4f5d39(_[_0x0d8b('0x6a')](_0x4a04c6,['message']));})['catch'](function(_0x124219){if(_0x124219[_0x0d8b('0x109')]){rpcDb['unlockContact'](_0x50b987);}if(_0x124219['active']){rpcDb['disableContact'](_0x50b987);}_0x2cc63a(_['pick'](_0x124219,[_0x0d8b('0x4a')]));});});};Preview[_0x0d8b('0xe')][_0x0d8b('0x10a')]=function(_0x29e8e6,_0x233ff0){var _0x21329f=this;return new BPromise(function(_0x3d8a14,_0x44ac53){var _0x53de32,_0x19e8d4;rpcDb['getContactPreview'](_0x29e8e6)[_0x0d8b('0x78')](function(_0x4e1f1a){if(!_[_0x0d8b('0x79')](_0x4e1f1a[0x0])){_0x19e8d4=_0x4e1f1a[0x0][_0x0d8b('0x10b')]?![]:!![];_0x53de32=_0x4e1f1a[0x0][_0x0d8b('0x10b')]?!![]:![];_0x53de32=_0x233ff0?!![]:_0x53de32;}var _0x2d90af=_0x21329f[_0x0d8b('0x10c')](_0x4e1f1a);if(_0x2d90af[_0x0d8b('0x10d')]){rpcDb[_0x0d8b('0x10e')](_[_0x0d8b('0x6a')](_0x4e1f1a[0x0],[_0x0d8b('0xf8'),_0x0d8b('0x10f')]))[_0x0d8b('0x78')](function(_0x36527c){_0x21329f[_0x0d8b('0xf5')](_0x36527c,_0x4e1f1a[0x0],_0x233ff0,_0x19e8d4,_0x53de32)['then'](function(_0x479d59){_0x3d8a14(_0x479d59);})['catch'](function(_0x4111e6){_0x44ac53(_0x4111e6);});})[_0x0d8b('0x6f')](function(_0x4c69a3){ut[_0x0d8b('0x5d')]('[Preview][checkIsBlackList]',_0x4c69a3);_0x44ac53(ut[_0x0d8b('0x4a')]('Call\x20unsuccessful',_0x19e8d4,_0x53de32));});}else{_0x44ac53(ut[_0x0d8b('0x4a')](_0x2d90af[_0x0d8b('0x4a')],_0x19e8d4,_0x53de32));}})[_0x0d8b('0x6f')](function(_0x3e7cc7){ut[_0x0d8b('0x5d')](_0x0d8b('0x110'),_0x3e7cc7);_0x44ac53(ut['message'](_0x0d8b('0x111'),![],!![]));});});};Preview['prototype'][_0x0d8b('0x10c')]=function(_0x66040){if(_[_0x0d8b('0x79')](_0x66040)||_[_0x0d8b('0xfc')](_0x66040)||!_[_0x0d8b('0x79')](_0x66040[0x0]['Agent'])&&_[_0x0d8b('0x79')](_0x66040[0x0][_0x0d8b('0x7d')]['name'])){ut[_0x0d8b('0x5d')](_0x0d8b('0x112'),_0x66040);return{'isValid':![],'message':_0x0d8b('0x113')};}var _0x2f90e0=this['campaignsPreview'][_0x66040[0x0][_0x0d8b('0xfa')]['name']];_0x2f90e0[_0x0d8b('0x4a')]='ACTIVE';if(_[_0x0d8b('0x79')](_0x2f90e0)){ut[_0x0d8b('0x5d')]('[Preview][validateContact][Empty\x20Campaign]',_0x2f90e0);return{'isValid':![],'message':_0x0d8b('0x114')};}if(!this[_0x0d8b('0x91')](_0x2f90e0[_0x0d8b('0x50')])){ut[_0x0d8b('0x5d')]('[Preview][validateContact][Trunk\x20not\x20work]',_0x0d8b('0x115')+_0x2f90e0['name']+_0x0d8b('0x116'));if(!this[_0x0d8b('0x91')](_0x2f90e0['TrunkBackup'])){ut[_0x0d8b('0x5d')](_0x0d8b('0x117'),_0x2f90e0[_0x0d8b('0x51')]+_0x0d8b('0x118'));return{'isValid':![],'message':_0x0d8b('0x119')};}}if(!ut[_0x0d8b('0x90')](_0x2f90e0[_0x0d8b('0x37')])){ut[_0x0d8b('0x5d')]('[Preview][validateContact][Campaign\x20Active]',_0x2f90e0[_0x0d8b('0x51')]+'\x20Not\x20Active');return{'isValid':![],'message':_0x0d8b('0x115')+_0x2f90e0[_0x0d8b('0x51')]+_0x0d8b('0x11a')};}return{'isValid':!![],'message':_0x0d8b('0x11b')};};Preview[_0x0d8b('0xe')][_0x0d8b('0xfd')]=function(_0x331bc5,_0x1660d5,_0x1a987a,_0x53bfe5){var _0x2f8682=this;return new BPromise(function(_0x3106e9,_0x4cd83e){var _0x2703f1=_0x331bc5[_0x0d8b('0xac')];var _0x4aa208=_0x2f8682[_0x0d8b('0x91')](_0x1660d5[_0x0d8b('0x50')])?util[_0x0d8b('0x58')](_0x0d8b('0x11c'),_0x1660d5[_0x0d8b('0x50')][_0x0d8b('0x51')],_[_0x0d8b('0x79')](_0x1660d5[_0x0d8b('0x3a')])?'':_0x1660d5['dialPrefix'][_0x0d8b('0x11d')]()||'',_0x1660d5[_0x0d8b('0x11e')]>0x0?_0x1a987a[_0x0d8b('0xf6')][_0x0d8b('0xf7')][_0x0d8b('0x11f')](_0x1660d5[_0x0d8b('0x11e')]):_0x1a987a[_0x0d8b('0xf6')][_0x0d8b('0xf7')]):util[_0x0d8b('0x58')](_0x0d8b('0x11c'),_[_0x0d8b('0x79')](_0x1660d5['TrunkBackup'])?_0x1660d5['Trunk']['name']:_0x1660d5['TrunkBackup']['name'],_['isNil'](_0x1660d5[_0x0d8b('0x3a')])?'':_0x1660d5['dialPrefix'][_0x0d8b('0x11d')]()||'',_0x1660d5[_0x0d8b('0x11e')]>0x0?_0x1a987a[_0x0d8b('0xf6')][_0x0d8b('0xf7')][_0x0d8b('0x11f')](_0x1660d5[_0x0d8b('0x11e')]):_0x1a987a[_0x0d8b('0xf6')][_0x0d8b('0xf7')]);var _0x352485=_0x2f8682[_0x0d8b('0x91')](_0x1660d5[_0x0d8b('0x50')])?ut[_0x0d8b('0x120')](_0x1660d5['Trunk'][_0x0d8b('0x53')],_0x1660d5['dialOriginateCallerIdName'],_0x1660d5[_0x0d8b('0x121')]>0x0?ut['getCallerIdRandom'](_0x1660d5[_0x0d8b('0x122')],_0x1660d5[_0x0d8b('0x121')]):_0x1660d5[_0x0d8b('0x122')]):ut[_0x0d8b('0x120')](_[_0x0d8b('0x79')](_0x1660d5['TrunkBackup'])?_0x1660d5[_0x0d8b('0x50')][_0x0d8b('0x53')]:_0x1660d5['TrunkBackup'][_0x0d8b('0x53')],_0x1660d5['dialOriginateCallerIdName'],_0x1660d5['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x0d8b('0x123')](_0x1660d5[_0x0d8b('0x122')],_0x1660d5[_0x0d8b('0x121')]):_0x1660d5[_0x0d8b('0x122')]);if(_0x352485){_0x331bc5[_0x0d8b('0x124')]=ut['extractCalleridName'](_0x352485);_0x331bc5['originatecalleridnum']=ut['extractCalleridNumber'](_0x352485);}var _0x18e6be=ut[_0x0d8b('0x125')](_0x1660d5,_0x1a987a,_0x4aa208,_0x352485,_0x2703f1,_0x331bc5);_[_0x0d8b('0x126')](_0x331bc5,ut[_0x0d8b('0x127')](_0x18e6be));_0x331bc5[_0x0d8b('0x83')]=moment()[_0x0d8b('0x58')]('YYYY-MM-DD\x20HH:mm:ss');ami[_0x0d8b('0x6d')](ut[_0x0d8b('0x128')](_0x331bc5,_0x1660d5,_0x18e6be,_0x331bc5['activeContact'],_0x53bfe5))[_0x0d8b('0x78')](function(_0x28fa83){_0x1660d5[_0x0d8b('0x4b')]+=0x1;logger[_0x0d8b('0x56')](_0x0d8b('0x129'),_0x2703f1,'\x20Queue',_0x1660d5['name'],_0x0d8b('0x67'),_0x1660d5[_0x0d8b('0x4b')]);_0x3106e9(_0x28fa83);})['catch'](function(_0x3c5a61){ut[_0x0d8b('0xeb')](_0x331bc5,0xe,_0x0d8b('0x12a'));rpcDb['createAgentHistory'](_0x331bc5,'[originateFailure][logOriginateFailure]');_0x4cd83e(_0x3c5a61);});});};Preview[_0x0d8b('0xe')][_0x0d8b('0x23')]=function(_0x598e67){if(this['actions'][_0x598e67[_0x0d8b('0xa8')]]){this['actions'][_0x598e67[_0x0d8b('0xa8')]]['channel']=_0x598e67[_0x0d8b('0x12b')];}};Preview[_0x0d8b('0xe')]['syncOriginateResponse']=function(_0x3411d9){var _0x5d9ab5=this;var _0x31d9fb=this[_0x0d8b('0x16')][_0x3411d9[_0x0d8b('0x12c')]];if(_0x31d9fb){if(_0x31d9fb[_0x0d8b('0xfb')]&&this[_0x0d8b('0x17')][_0x31d9fb['lookAgent']]){ut[_0x0d8b('0x12d')](_0x31d9fb,this[_0x0d8b('0x17')][_0x31d9fb[_0x0d8b('0xfb')]]['name'],this[_0x0d8b('0x17')][_0x31d9fb['lookAgent']]['id']);}var _0x270338=_[_0x0d8b('0x12e')](_0x31d9fb);_0x270338['responsetime']=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');var _0x24705e=_0x5d9ab5[_0x0d8b('0x13')][_0x31d9fb['queue']];if(ut[_0x0d8b('0x12f')](_0x3411d9['response'])){if(_0x31d9fb[_0x0d8b('0xa6')]){rpcDb[_0x0d8b('0x130')](_0x31d9fb[_0x0d8b('0x131')]);}if(_0x31d9fb[_0x0d8b('0xa7')]){rpcDb[_0x0d8b('0x82')](_0x31d9fb[_0x0d8b('0x131')]);}ami[_0x0d8b('0x99')](_0x0d8b('0x132'),ut['buildObj'](_0x31d9fb,_0x0d8b('0x133'),this['campaignsPreview'][_0x31d9fb['queue']]));this[_0x0d8b('0x134')](_0x270338,_0x24705e,_0x3411d9);}else{_0x31d9fb[_0x0d8b('0x83')]=moment()[_0x0d8b('0x58')](_0x0d8b('0xa9'));ut[_0x0d8b('0xeb')](_0x270338,0x4,_0x0d8b('0x135'));rpcDb[_0x0d8b('0xec')](_0x270338,'[callProgressDetectingAgent][logAnswer]');}}};Preview[_0x0d8b('0xe')]['syncHangup']=function(_0x5d3cd5){var _0x3bdb03=this;var _0x5f4e06=this[_0x0d8b('0x16')][_0x5d3cd5['linkedid']];var _0x4a9bc0;if(_0x5f4e06){_0x4a9bc0=this[_0x0d8b('0x13')][_0x5f4e06[_0x0d8b('0x66')]];logger[_0x0d8b('0x56')](_0x0d8b('0x136'),_0x5d3cd5[_0x0d8b('0xa8')],_0x0d8b('0xad'),_0x4a9bc0['name'],'pTalking:\x20',_0x4a9bc0[_0x0d8b('0x30')]);}if(this[_0x0d8b('0x16')][_0x5d3cd5[_0x0d8b('0xa8')]]&&_0x5d3cd5[_0x0d8b('0xa8')]!==_0x5d3cd5[_0x0d8b('0xac')]){if(_0x5d3cd5[_0x0d8b('0x137')]==='16'&&this[_0x0d8b('0x16')][_0x5d3cd5[_0x0d8b('0xa8')]][_0x0d8b('0x69')]){this[_0x0d8b('0x95')](_0x5d3cd5,_0x5d3cd5[_0x0d8b('0xa8')],_0x5d3cd5[_0x0d8b('0x137')]);}else if(this[_0x0d8b('0x16')][_0x5d3cd5['linkedid']]['dialAnswer']){logger['info'](_0x0d8b('0x138'),_0x5d3cd5[_0x0d8b('0xa8')],_0x5d3cd5[_0x0d8b('0x137')],_0x0d8b('0xad'),_0x4a9bc0[_0x0d8b('0x51')],_0x0d8b('0x68'),_0x4a9bc0[_0x0d8b('0x30')]);this[_0x0d8b('0x95')](_0x5d3cd5,_0x5d3cd5[_0x0d8b('0xa8')],_0x5d3cd5[_0x0d8b('0x137')]);}}else if(_0x5f4e06&&_[_0x0d8b('0x79')](_0x5f4e06[_0x0d8b('0x139')])&&_0x4a9bc0[_0x0d8b('0x13a')]&&_0x5d3cd5[_0x0d8b('0xa8')]===_0x5d3cd5[_0x0d8b('0xac')]&&_[_0x0d8b('0x79')](_0x5d3cd5[_0x0d8b('0xf2')])&&_0x5d3cd5['cause']==='16'&&_0x5d3cd5['channelstate']==='6'&&_[_0x0d8b('0xe9')](_0x5f4e06['transfer'])){if(_0x5f4e06['unlockAgent']){rpcDb['unlockContact'](_0x5f4e06[_0x0d8b('0x131')]);}if(_0x5f4e06[_0x0d8b('0xa7')]){rpcDb[_0x0d8b('0x82')](_0x5f4e06[_0x0d8b('0x131')]);}_0x5d3cd5[_0x0d8b('0xf2')]='22';this['callProgressDetectingAgent'](_0x5f4e06,_0x4a9bc0,_0x5d3cd5);}else if(_0x5f4e06&&_0x5f4e06[_0x0d8b('0x13b')]){if(_0x5d3cd5[_0x0d8b('0x137')]==='16'&&this[_0x0d8b('0x16')][_0x5d3cd5[_0x0d8b('0xa8')]]['dialAnswer']){logger['info'](_0x0d8b('0x13c'),_0x5d3cd5['linkedid'],_0x5d3cd5[_0x0d8b('0x137')],_0x0d8b('0xad'),_0x4a9bc0[_0x0d8b('0x51')],_0x0d8b('0x68'),_0x4a9bc0[_0x0d8b('0x30')]);this[_0x0d8b('0x95')](_0x5d3cd5,_0x5d3cd5['linkedid'],_0x5d3cd5[_0x0d8b('0x137')]);}else if(this['actions'][_0x5d3cd5[_0x0d8b('0xa8')]][_0x0d8b('0x69')]){logger[_0x0d8b('0x56')](_0x0d8b('0x138'),_0x5d3cd5['linkedid'],_0x5d3cd5['cause'],'\x20Queue',_0x4a9bc0['name'],_0x0d8b('0x68'),_0x4a9bc0[_0x0d8b('0x30')]);this[_0x0d8b('0x95')](_0x5d3cd5,_0x5d3cd5[_0x0d8b('0xa8')],_0x5d3cd5[_0x0d8b('0x137')]);}}};Preview[_0x0d8b('0xe')]['syncDialEnd']=function(_0x495456){if(this['actions'][_0x495456['destlinkedid']]&&_0x495456[_0x0d8b('0x13d')]!==_0x495456[_0x0d8b('0x13e')]){this['callProgressDetectingCustomer'](_0x495456,_0x495456[_0x0d8b('0x13d')],_0x495456[_0x0d8b('0xe3')]);}};Preview[_0x0d8b('0xe')][_0x0d8b('0x1f')]=function(_0x289b7e){if(this[_0x0d8b('0x16')][_0x289b7e[_0x0d8b('0xa8')]]&&_0x289b7e['linkedid']!==_0x289b7e[_0x0d8b('0xac')]&&!this[_0x0d8b('0x16')][_0x289b7e[_0x0d8b('0xa8')]]['dialAnswer']){if(_0x289b7e[_0x0d8b('0x137')]==='1'){this[_0x0d8b('0x95')](_0x289b7e,_0x289b7e[_0x0d8b('0xa8')],_0x289b7e[_0x0d8b('0x137')]);}}};Preview[_0x0d8b('0xe')][_0x0d8b('0x13f')]=function(_0x2e3310,_0x1742bd,_0x843725){if(this['actions'][_0x2e3310]){if(_['isNil'](this['actions'][_0x2e3310][_0x0d8b('0x140')])){this[_0x0d8b('0x16')][_0x2e3310][_0x0d8b('0x140')]={};}this[_0x0d8b('0x16')][_0x2e3310][_0x0d8b('0x140')][_0x1742bd]=_0x843725;}};Preview[_0x0d8b('0xe')][_0x0d8b('0x25')]=function(_0x1c88ce){try{if(!_[_0x0d8b('0x79')](_0x1c88ce)){if(ut[_0x0d8b('0x141')](_['keys'](_0x1c88ce['variable'])[0x0])){this[_0x0d8b('0x13f')](_0x1c88ce[_0x0d8b('0xac')],_[_0x0d8b('0x142')](_0x1c88ce[_0x0d8b('0x143')])[0x0],_0x1c88ce['value']);}}}catch(_0x5f467e){logger[_0x0d8b('0x144')](_0x0d8b('0x145'),util[_0x0d8b('0x146')](_0x5f467e,{'showHidden':![],'depth':null}));}};Preview[_0x0d8b('0xe')][_0x0d8b('0x27')]=function(_0x51240b){if(_0x51240b){if(this['actions'][_0x51240b[_0x0d8b('0x147')]]){this[_0x0d8b('0x16')][_0x51240b[_0x0d8b('0x147')]][_0x0d8b('0x13b')]=!![];}}};Preview['prototype'][_0x0d8b('0x29')]=function(_0x22e3aa){if(_0x22e3aa){if(this[_0x0d8b('0x16')][_0x22e3aa[_0x0d8b('0x148')]]){this[_0x0d8b('0x16')][_0x22e3aa[_0x0d8b('0x148')]]['transfer']=!![];}}};module[_0x0d8b('0x149')]=Preview;