Built motion from commit b0a9a629.|2.6.33
[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 _0xc35e=['custom:agentConnectPreview','channelAgent','custom:agentcomplete','complete','outboundAnswerCallsDay','answered','[16]','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','sumBillable','[syncHangup][talking][decrement]','\x20Queue','outboundBusyCallsDay','countbusyretry','Busy','dialBusyRetryFrequency','busy','verifyAdditionalPhones','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','unlockAgent','NOANSWER','outboundNoAnswerCallsDay','countnoanswerretry','NoAnswer','buildNoAnswerEventPayload','[callProgressDetectingCustomer][logNoAnswer]','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','incrementPreviewCounters','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','dialCongestionRetryFrequency','congestion','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','outboundRejectCallsDay','countagentrejectretry','agentreject','AgentReject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','ABANDONED','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','dialAbandonedMaxRety','dialAbandonedRetryFrequency','countmachineretry','cause-txt','dialstatus','custom:amd','[callProgressDetectingCustomer][hangupInAMD]','outboundUnknownCallsDay','amd','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalking][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknownGlobal]','decrementOriginate','[callProgressDetectingCustomer]','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','[swapAdditionalPhone]\x20','[incrementPreviewCounters]\x20','checkInBlack','Contact','phone','lookAgent','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','createHistory','[Blacklist][error]','active','SIP/%s','reachable','unmonitored','run','execRun','getContactPreview','recallme','isValid','checkIsBlackList','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','validateContact','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','ACTIVE','[Preview][validateContact][Empty\x20Campaign]','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','Trunk\x20not\x20working\x20correctly','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','trim','dialCutDigit','dialPrefix','substring','getCallerId','callerid','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','dialOriginateCallerIdName','originatecalleridname','extractCalleridName','extractCalleridNumber','addVariables','setXMDContactVariables','assign','toLowerVariables','starttime','variablesAction','Action','[originated][increment]','[originateFailure][logOriginateFailure]','actionid','clone','isFailure','response','custom:agentringnoanswer','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','dialQueueProject','channelstate','transfer','unlockContact','callProgressDetectingAgent','[syncHangup][talking][transfer]','[syncHangup][talking][cause]','destlinkedid','destuniqueid','addVariable','variables','keys','variable','value','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','util','lodash','uuid','moment','ioredis','../../../config/environment','preview','../../../config/logger','actionPreview','../ami','../rpc/cmHopperAdditionalPhone','./util/util','../dialer/utils','redis','defaults','localhost','socket.io-emitter','enqueue','tail','finally','sequence','campaignsPreview','trunks','actions','agents','syncOriginateResponse','bind','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','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','\x20is\x20not\x20active','DEACTIVATED','[CampaignPreview]\x20Campaign\x20Queue:\x20','prototype','loopCampaigns','syncCampaigns','clockClearZombieChannels','hasOwnProperty','dialMethod','booked','clearZombieChannels','type','outbound','dialActive','setMessage','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','isNil','[clearZombieChannels][talking]','Queue','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','UserId','VoiceQueueId','status','channel','catch','No\x20such\x20channel','decrementTalking','[clearZombieChannel]','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','size','getContactRecallMe','agentReadyId','then','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','logger2','[RecallMe]','disableContact','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','loggedIn','isActive','Trunk','isTrunkReachable','TrunkBackup','callProgressDetectingCustomer','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','buildObj','[callProgressDetectingCustomer][logNoSuch]','additional','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','activeContact','linkedid','actioncountonusuch','idContact','swapAdditionalPhones','ANSWER','[syncHangup][talking][increment]','uniqueid','connect','acw'];(function(_0x31216b,_0x4ccdaf){var _0x24a7b3=function(_0x5977db){while(--_0x5977db){_0x31216b['push'](_0x31216b['shift']());}};_0x24a7b3(++_0x4ccdaf);}(_0xc35e,0x1e9));var _0xec35=function(_0x130375,_0x4cee28){_0x130375=_0x130375-0x0;var _0x457d9e=_0xc35e[_0x130375];return _0x457d9e;};'use strict';var util=require(_0xec35('0x0'));var _=require(_0xec35('0x1'));var uuid=require(_0xec35('0x2'));var moment=require(_0xec35('0x3'));var Redis=require(_0xec35('0x4'));var config=require(_0xec35('0x5'));var logger=require('../../../config/logger')(_0xec35('0x6'));var loggerAction=require(_0xec35('0x7'))(_0xec35('0x8'));var ami=require(_0xec35('0x9'));var rpcDb=require('./rpcDb');var cmHopperAdditionalPhone=require(_0xec35('0xa'));var Action=require('./action');var ut=require(_0xec35('0xb'));var utils=require(_0xec35('0xc'));config[_0xec35('0xd')]=_[_0xec35('0xe')](config[_0xec35('0xd')],{'host':_0xec35('0xf'),'port':0x18eb});var io=require(_0xec35('0x10'))(new Redis(config[_0xec35('0xd')]));var Sequence=function(){};Sequence['prototype'][_0xec35('0x11')]=function(_0x4acd5d){this[_0xec35('0x12')]=this[_0xec35('0x12')]?this[_0xec35('0x12')][_0xec35('0x13')](_0x4acd5d):_0x4acd5d();};function Preview(_0x4f2510){this[_0xec35('0x14')]=new Sequence();this[_0xec35('0x15')]=_0x4f2510['voiceQueues'];this[_0xec35('0x16')]=_0x4f2510['trunks'];this[_0xec35('0x17')]={};this['agents']=_0x4f2510[_0xec35('0x18')];this['clockClearZombieChannels']=0x0;ami['on']('originateresponse',this[_0xec35('0x19')][_0xec35('0x1a')](this));ami['on']('hangup',this[_0xec35('0x1b')][_0xec35('0x1a')](this));ami['on'](_0xec35('0x1c'),this[_0xec35('0x1d')][_0xec35('0x1a')](this));ami['on'](_0xec35('0x1e'),this[_0xec35('0x1f')][_0xec35('0x1a')](this));ami['on'](_0xec35('0x20'),this[_0xec35('0x21')][_0xec35('0x1a')](this));ami['on'](_0xec35('0x22'),this[_0xec35('0x23')]['bind'](this));ami['on'](_0xec35('0x24'),this[_0xec35('0x25')][_0xec35('0x1a')](this));ami['on'](_0xec35('0x26'),this[_0xec35('0x27')]['bind'](this));this['loopCampaigns'](this[_0xec35('0x15')]);}function emit(_0x51f949,_0x434dce,_0x19512a){io['to'](_0x51f949)[_0xec35('0x28')](_0x434dce,_0x19512a);}function emitVoiceQueueChannelRemove(_0x33b180){logger[_0xec35('0x29')](_0xec35('0x2a'),JSON[_0xec35('0x2b')](_0x33b180));emit(util[_0xec35('0x2c')](_0xec35('0x2d'),_0x33b180[_0xec35('0x2e')]),'voice_queue_channel:remove',_0x33b180);io[_0xec35('0x28')]('voice_queue_presence:remove',_0x33b180);}function notSendMessagesQueue(_0x148553){if(_0x148553[_0xec35('0x2f')]){if(_0x148553[_0xec35('0x30')]===0x0&&_0x148553[_0xec35('0x31')]===0x0){_0x148553[_0xec35('0x2f')]=![];_0x148553[_0xec35('0x32')]=0x0;_0x148553[_0xec35('0x33')]=0x0;_0x148553[_0xec35('0x34')]=utils[_0xec35('0x35')][_0xec35('0x36')];ut[_0xec35('0x37')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x148553[_0xec35('0x2e')]+_0xec35('0x38'));}else{_0x148553['message']=utils[_0xec35('0x35')][_0xec35('0x39')];ut[_0xec35('0x37')](_0xec35('0x3a'),_0x148553[_0xec35('0x2e')]+'\x20is\x20deactivated');}}}Preview[_0xec35('0x3b')][_0xec35('0x3c')]=function(){var _0x2528d7=this;setInterval(function(){_0x2528d7[_0xec35('0x3d')]();},0x7cf);};Preview[_0xec35('0x3b')][_0xec35('0x3d')]=function(){var _0xb23958=this[_0xec35('0x15')];this[_0xec35('0x3e')]+=0x1;for(var _0x130d2d in _0xb23958){if(_0xb23958[_0xec35('0x3f')](_0x130d2d)&&(_0xb23958[_0x130d2d][_0xec35('0x40')]===_0xec35('0x6')||_0xb23958[_0x130d2d][_0xec35('0x40')]===_0xec35('0x41'))&&_0xb23958[_0x130d2d]['type']==='outbound'){if(this['clockClearZombieChannels']>0x7){this[_0xec35('0x3e')]=0x0;this[_0xec35('0x42')]();}}if(_0xb23958['hasOwnProperty'](_0x130d2d)&&_0xb23958[_0x130d2d][_0xec35('0x40')]==='preview'&&_0xb23958[_0x130d2d][_0xec35('0x43')]===_0xec35('0x44')){if(_0xb23958[_0x130d2d][_0xec35('0x45')]){this[_0xec35('0x46')](_0xb23958[_0x130d2d]);if(_0xb23958[_0x130d2d][_0xec35('0x47')])this[_0xec35('0x48')](_0xb23958[_0x130d2d]);}else{notSendMessagesQueue(_0xb23958[_0x130d2d]);}}}};Preview[_0xec35('0x3b')][_0xec35('0x49')]=function(_0xb46ca5){var _0x93529=this;this['sequence'][_0xec35('0x11')](function(){if(!_[_0xec35('0x4a')](_0x93529[_0xec35('0x17')][_0xb46ca5])){loggerAction[_0xec35('0x29')](_0xec35('0x4b'),_0xb46ca5,_0xec35('0x4c'),_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x4d')],_0xec35('0x4e'),JSON[_0xec35('0x2b')](_0x93529['campaignsPreview'][_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x4d')]][_0xec35('0x30')]),_0xec35('0x4f'),JSON[_0xec35('0x2b')](_0x93529[_0xec35('0x15')][_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x4d')]]['pTalking']),JSON[_0xec35('0x2b')](_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x50')]),JSON[_0xec35('0x2b')](_[_0xec35('0x51')](_0x93529[_0xec35('0x17')][_0xb46ca5],['contactId',_0xec35('0x52'),_0xec35('0x53'),'ListId'])));return ami['Action']({'action':_0xec35('0x54'),'channel':_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x55')]})[_0xec35('0x56')](function(_0x28238e){if(_0x28238e['message']===_0xec35('0x57')){setTimeout(function(){if(_0x93529[_0xec35('0x17')][_0xb46ca5]){utils['decrementOriginate'](_0x93529['campaignsPreview'][_0x93529['actions'][_0xb46ca5][_0xec35('0x4d')]],'[clearZombieChannel]');if(_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x50')]===!![]){ut[_0xec35('0x58')](_0x93529[_0xec35('0x15')][_0x93529[_0xec35('0x17')][_0xb46ca5][_0xec35('0x4d')]],_0xec35('0x59'));ut[_0xec35('0x5a')](_0xec35('0x5b')+_0xb46ca5,_0x93529[_0xec35('0x17')][_0xb46ca5]['queue']);}ut[_0xec35('0x5a')](_0xec35('0x5c')+_0xb46ca5,_0x93529[_0xec35('0x17')][_0xb46ca5]['queue']);delete _0x93529[_0xec35('0x17')][_0xb46ca5];}},0x2328);}});}});};Preview[_0xec35('0x3b')][_0xec35('0x42')]=function(){var _0x4dac1b=this;loggerAction['info']('[action]',_[_0xec35('0x5d')](this[_0xec35('0x17')]));for(var _0x2f1d3e in this[_0xec35('0x17')]){if(_0x4dac1b[_0xec35('0x17')][_0xec35('0x3f')](_0x2f1d3e)){_0x4dac1b['clearZombieChannel'](_0x2f1d3e);}}};Preview[_0xec35('0x3b')][_0xec35('0x48')]=function(_0x935ada){var _0x292a25=this;rpcDb[_0xec35('0x5e')](_0x935ada['id'],ut[_0xec35('0x5f')](this[_0xec35('0x18')]))[_0xec35('0x60')](function(_0x32c41c){if(!_[_0xec35('0x4a')](_0x32c41c)){for(var _0x59ddf1=0x0;_0x59ddf1<_0x32c41c[_0xec35('0x61')];_0x59ddf1+=0x1){if(ut[_0xec35('0x62')](_0x32c41c[_0x59ddf1][_0xec35('0x63')])<_0x935ada[_0xec35('0x64')]*0x3c){if(_0x32c41c[_0x59ddf1]['Agent']&&!_0x32c41c[_0x59ddf1][_0xec35('0x65')]['voicePause']){_0x292a25['run'](_0x32c41c[_0x59ddf1]['id'])[_0xec35('0x60')](ut[_0xec35('0x66')](_0xec35('0x67')))['catch'](ut['logger2']('[RecallMe]'));}else{rpcDb[_0xec35('0x68')](_0x32c41c[_0x59ddf1]['id']);}}else{var _0x512dae=new Action(_0x32c41c[_0x59ddf1],_0x935ada);_0x512dae['starttime']=moment()['format'](_0xec35('0x69'));_0x935ada[_0xec35('0x6a')]+=0x1;ut[_0xec35('0x6b')](_0x512dae,0x17,_0xec35('0x6c'));if(_0x935ada[_0xec35('0x6d')]){rpcDb[_0xec35('0x6e')](ut[_0xec35('0x6f')](_0x32c41c[_0x59ddf1]));rpcDb[_0xec35('0x70')](_0x512dae,_0xec35('0x71'));}else{ut['logCustomer'](_0x512dae,0x16,_0xec35('0x72'));rpcDb[_0xec35('0x70')](_0x512dae,_0xec35('0x73'));rpcDb[_0xec35('0x74')](_0x512dae,_0xec35('0x73'));}}}}})[_0xec35('0x56')](ut[_0xec35('0x66')](_0xec35('0x75')));};Preview['prototype'][_0xec35('0x46')]=function(_0x38f550){_0x38f550[_0xec35('0x2f')]=!![];if(ut['IsNotLoggedIn'](_0x38f550[_0xec35('0x76')])){_0x38f550[_0xec35('0x34')]=utils['CAMPAIGN_STATUS']['NO_AGENTS_LOGGED'];}else if(!ut[_0xec35('0x77')](_0x38f550[_0xec35('0x45')])){_0x38f550['message']=utils[_0xec35('0x35')][_0xec35('0x36')];}else if(!this['isTrunkReachable'](_0x38f550[_0xec35('0x78')])){if(!this[_0xec35('0x79')](_0x38f550[_0xec35('0x7a')])){_0x38f550[_0xec35('0x34')]=utils[_0xec35('0x35')]['UNREACHABLE_TRUNK'];}else{_0x38f550[_0xec35('0x34')]=utils[_0xec35('0x35')]['ACTIVE'];}}else{_0x38f550[_0xec35('0x34')]=utils[_0xec35('0x35')]['ACTIVE'];}};Preview[_0xec35('0x3b')][_0xec35('0x7b')]=function(_0x5f2026,_0x240369,_0x15876b){var _0x17a81f=this;var _0x3a739a=this[_0xec35('0x17')][_0x240369];var _0x5decba=this[_0xec35('0x15')][_0x3a739a[_0xec35('0x4d')]];var _0x252fc8;var _0x1b7c31=![];var _0xfd3f41=0x2;var _0x6605ea=0x3;if(_0x5decba){switch(_0x15876b){case'1':_0x5decba['outboundNoSuchCallsDay']+=0x1;_0x3a739a[_0xec35('0x7c')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0x0,_0xec35('0x7f'));ami[_0xec35('0x28')]('custom:agentnosuchnumber',ut[_0xec35('0x80')](_0x3a739a,'nosuchnumber'));rpcDb[_0xec35('0x70')](_0x3a739a,_0xec35('0x81'));_0x17a81f['verifyAdditionalPhones'](_0x3a739a,'0',_0x5decba)[_0xec35('0x60')](function(_0x53658b){_0x1b7c31=_0x53658b[_0xec35('0x82')]==0x1;_0xfd3f41=_0x5decba[_0xec35('0x83')];_0x6605ea=_0x5decba[_0xec35('0x84')];if(!_0x1b7c31){if(ut['totalGlobal'](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0xf,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0x88'));}else{if(_0x3a739a['countnosuchnumberretry']>=_0x5decba['dialNoSuchNumberMaxRetry']){rpcDb['createCustomerFinal'](_0x3a739a,_0xec35('0x88'));}else{rpcDb[_0xec35('0x89')](ut[_0xec35('0x8a')](_0x3a739a,_0xec35('0x7c'),_0x5decba[_0xec35('0x83')]),_0x3a739a['unlockAgent'],_0x3a739a[_0xec35('0x8b')]);}}delete this[_0xec35('0x17')][_0x5f2026[_0xec35('0x8c')]];}else{_0x3a739a[_0xec35('0x7c')]++;logger['info'](_0xec35('0x8d'),_0x3a739a[_0xec35('0x7c')]);logger[_0xec35('0x29')]('id',_0x3a739a[_0xec35('0x8e')]);_0x17a81f['incrementPreviewCounters']({'id':_0x3a739a['idContact'],'field':{'countnosuchnumberretry':_0x3a739a['countnosuchnumberretry']}})[_0xec35('0x60')](function(){_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)['then'](function(){});});}});break;case _0xec35('0x90'):var _0x42e4ea=moment()['format'](_0xec35('0x69'));_0x3a739a['responsetime']=_0x42e4ea;_0x3a739a['answertime']=_0x42e4ea;_0x3a739a[_0xec35('0x50')]=!![];_0x5decba[_0xec35('0x31')]+=0x1;logger['info'](_0xec35('0x91'),_0x3a739a[_0xec35('0x92')],'\x20Queue',_0x5decba[_0xec35('0x2e')],_0xec35('0x4f'),_0x5decba[_0xec35('0x31')]);ami[_0xec35('0x28')]('custom:agentconnect',ut['buildObj'](_0x3a739a,_0xec35('0x93'),this[_0xec35('0x15')][_0x3a739a[_0xec35('0x4d')]]));if(_0x5decba[_0xec35('0x94')]||_0x5decba['mandatoryDisposition']){ami[_0xec35('0x28')](_0xec35('0x95'),{'queue':_0x3a739a['queue'],'interface':_0x3a739a[_0xec35('0x96')],'uniqueid':_0x3a739a[_0xec35('0x92')]});}break;case'16':ami[_0xec35('0x28')](_0xec35('0x97'),ut[_0xec35('0x80')](_0x3a739a,_0xec35('0x98'),this[_0xec35('0x15')][_0x3a739a[_0xec35('0x4d')]]));emitVoiceQueueChannelRemove(ut[_0xec35('0x80')](_0x3a739a,_0xec35('0x98')));_0x5decba[_0xec35('0x99')]+=0x1;_0x5decba['total']+=0x1;_0x5decba[_0xec35('0x9a')]+=0x1;ut[_0xec35('0x58')](_0x5decba,_0xec35('0x9b'));_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0x4,_0xec35('0x9c'));rpcDb[_0xec35('0x70')](_0x3a739a,_0xec35('0x9d'));rpcDb[_0xec35('0x74')](_0x3a739a,_0xec35('0x9e'));rpcDb[_0xec35('0x9f')](_0x3a739a);_0x5decba['sumDuration']+=_0x3a739a[_0xec35('0xa0')];_0x5decba[_0xec35('0xa1')]+=_0x3a739a[_0xec35('0xa0')];logger[_0xec35('0x29')](_0xec35('0xa2'),_0x3a739a[_0xec35('0x92')],_0xec35('0xa3'),_0x5decba[_0xec35('0x2e')],'pTalking:\x20',_0x5decba[_0xec35('0x31')]);delete this[_0xec35('0x17')][_0x5f2026[_0xec35('0x8c')]];break;case'BUSY':_0x5decba[_0xec35('0xa4')]+=0x1;_0x3a739a[_0xec35('0xa5')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0x5,_0xec35('0xa6'));_0xfd3f41=_0x5decba[_0xec35('0xa7')];_0x6605ea=_0x5decba['callAdditionalPhoneAfterMin'];ami[_0xec35('0x28')]('custom:agentbusy',ut[_0xec35('0x80')](_0x3a739a,_0xec35('0xa8')));rpcDb['createCustomerHistory'](_0x3a739a,'[callProgressDetectingCustomer][logBusy]');_0x17a81f[_0xec35('0xa9')](_0x3a739a,'5',_0x5decba)[_0xec35('0x60')](function(_0x33e883){_0x1b7c31=_0x33e883[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0xf,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0xaa'));}else{if(_0x3a739a[_0xec35('0xa5')]>=_0x5decba[_0xec35('0xab')]){rpcDb[_0xec35('0x74')](_0x3a739a,'[callProgressDetectingCustomer][logBusy]');}else{rpcDb[_0xec35('0x89')](ut[_0xec35('0x8a')](_0x3a739a,_0xec35('0xa5'),_0x5decba[_0xec35('0xa7')]),_0x3a739a[_0xec35('0xac')],_0x3a739a[_0xec35('0x8b')]);}}}else{_0x3a739a[_0xec35('0xa5')]++;_0x17a81f['incrementPreviewCounters']({'id':_0x3a739a[_0xec35('0x8e')],'field':{'countbusyretry':_0x3a739a[_0xec35('0xa5')]}})['then'](function(){_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});});}});break;case _0xec35('0xad'):_0x5decba[_0xec35('0xae')]+=0x1;_0x3a739a[_0xec35('0xaf')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut['totalGlobal'](_0x3a739a);ut['logCustomer'](_0x3a739a,0x3,_0xec35('0xb0'));_0xfd3f41=_0x5decba['dialNoAnswerRetryFrequency'];_0x6605ea=_0x5decba[_0xec35('0x84')];var _0xae9f24=ut[_0xec35('0xb1')](_0x3a739a,_0x5decba);ami['emit']('custom:agentnoanswer',_0xae9f24);rpcDb[_0xec35('0x70')](_0x3a739a,_0xec35('0xb2'));_0x17a81f[_0xec35('0xa9')](_0x3a739a,'3',_0x5decba)[_0xec35('0x60')](function(_0x3a4c8d){_0x1b7c31=_0x3a4c8d[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0xf,'Global');rpcDb['createCustomerFinal'](_0x252fc8,_0xec35('0xb3'));}else{if(_0x3a739a[_0xec35('0xaf')]>=_0x5decba[_0xec35('0xb4')]){rpcDb['createCustomerFinal'](_0x3a739a,_0xec35('0xb2'));}else{rpcDb['rescheduleContact'](ut[_0xec35('0x8a')](_0x3a739a,_0xec35('0xaf'),_0x5decba['dialNoAnswerRetryFrequency']),_0x3a739a[_0xec35('0xac')],_0x3a739a['activeContact']);}}}else{_0x3a739a[_0xec35('0xaf')]++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a[_0xec35('0x8e')],'field':{'countnoanswerretry':_0x3a739a['countnoanswerretry']}})[_0xec35('0x60')](function(){_0x17a81f['swapAdditionalPhones'](_0x3a739a,_0xfd3f41,_0x6605ea)['then'](function(){});});}});break;case _0xec35('0xb6'):_0x5decba[_0xec35('0xb7')]+=0x1;_0x3a739a[_0xec35('0xb8')]+=0x1;_0x3a739a['countglobal']=ut[_0xec35('0x7e')](_0x3a739a);ut['logCustomer'](_0x3a739a,0x8,_0xec35('0xb9'));_0xfd3f41=_0x5decba[_0xec35('0xba')];_0x6605ea=_0x5decba['callAdditionalPhoneAfterMin'];ami[_0xec35('0x28')]('custom:agentcongestion',ut[_0xec35('0x80')](_0x3a739a,_0xec35('0xbb')));rpcDb[_0xec35('0x70')](_0x3a739a,'[callProgressDetectingCustomer][logCongestion]');_0x17a81f['verifyAdditionalPhones'](_0x3a739a,'8',_0x5decba)['then'](function(_0x393551){_0x1b7c31=_0x393551[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut['cloneAction'](_0x3a739a,0xf,'Global');rpcDb['createCustomerFinal'](_0x252fc8,'[callProgressDetectingCustomer][logCongestionGlobal]');}else{if(_0x3a739a['countcongestionretry']>=_0x5decba[_0xec35('0xbc')]){rpcDb[_0xec35('0x74')](_0x3a739a,_0xec35('0xbd'));}else{rpcDb[_0xec35('0x89')](ut[_0xec35('0x8a')](_0x3a739a,_0xec35('0xb8'),_0x5decba[_0xec35('0xa7')]),_0x3a739a['unlockAgent'],_0x3a739a[_0xec35('0x8b')]);}}}else{_0x3a739a[_0xec35('0xb8')]++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a[_0xec35('0x8e')],'field':{'countcongestionretry':_0x3a739a[_0xec35('0xb8')]}})['then'](function(){_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});});}});break;case'CANCEL':_0x5decba[_0xec35('0xbe')]+=0x1;_0x3a739a[_0xec35('0xbf')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0x14,'AgentReject');_0xfd3f41=_0x5decba['dialAgentRejectRetryFrequency'];_0x6605ea=_0x5decba['callAdditionalPhoneAfterMin'];ami[_0xec35('0x28')]('custom:agentreject',ut[_0xec35('0x80')](_0x3a739a,_0xec35('0xc0')));rpcDb[_0xec35('0x70')](_0x3a739a,'[syncHangupRequest][logAgentReject]');_0x17a81f[_0xec35('0xa9')](_0x3a739a,'20',_0x5decba)['then'](function(_0x181966){_0x1b7c31=_0x181966[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0x14,_0xec35('0xc1'));rpcDb['createCustomerFinal'](_0x252fc8,_0xec35('0xc2'));}else{if(_0x3a739a[_0xec35('0xbf')]>=_0x5decba[_0xec35('0xc3')]){rpcDb[_0xec35('0x74')](_0x3a739a,_0xec35('0xc2'));}else{rpcDb[_0xec35('0x89')](ut[_0xec35('0x8a')](_0x3a739a,'countagentrejectretry',_0x5decba[_0xec35('0xc4')]),_0x3a739a[_0xec35('0xac')],_0x3a739a['activeContact']);}}}else{_0x3a739a[_0xec35('0xaf')]++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a[_0xec35('0x8e')],'field':{'countnoanswerretry':_0x3a739a[_0xec35('0xaf')]}})[_0xec35('0x60')](function(){_0x17a81f['swapAdditionalPhones'](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});});}});break;case _0xec35('0xc5'):_0x5decba['outboundAbandonedCallsDay']+=0x1;_0x3a739a[_0xec35('0xc6')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut['logCustomer'](_0x3a739a,0xb,_0xec35('0xc7'));rpcDb[_0xec35('0x70')](_0x3a739a,_0xec35('0xc8'));_0x17a81f[_0xec35('0xa9')](_0x3a739a,'11',_0x5decba)[_0xec35('0x60')](function(_0xb3c8d){_0x1b7c31=_0xb3c8d[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba['dialGlobalMaxRetry']){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0xf,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0xc8'));}else{if(_0x3a739a['countabandonedetry']>=_0x5decba[_0xec35('0xc9')]){rpcDb['createCustomerFinal'](_0x3a739a,'[callProgressDetectingCustomer][logAbandoned]');}else{rpcDb['rescheduleContact'](ut['scheduledAt'](_0x3a739a,'countabandonedretry',_0x5decba[_0xec35('0xca')]),_0x3a739a[_0xec35('0xac')],_0x3a739a[_0xec35('0x8b')]);}}}else{_0x3a739a['countnoanswerretry']++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a['idContact'],'field':{'countnoanswerretry':_0x3a739a[_0xec35('0xaf')]}})[_0xec35('0x60')](function(){_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});});}});break;case'18':_0x5decba['outboundUnknownCallsDay']+=0x1;_0x3a739a[_0xec35('0xcb')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut['logCustomer'](_0x3a739a,0x12,_0x5f2026[_0xec35('0xcc')]||_0x5f2026[_0xec35('0xcd')]);ami[_0xec35('0x28')](_0xec35('0xce'),ut['buildObj'](_0x3a739a,'amd'));rpcDb[_0xec35('0x70')](_0x3a739a,'[callProgressDetectingCustomer][hangupInAMD]');_0x17a81f[_0xec35('0xa9')](_0x3a739a,'18',_0x5decba)[_0xec35('0x60')](function(_0x4e7cda){_0x1b7c31=_0x4e7cda['additional']==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut['cloneAction'](_0x3a739a,0x12,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0xcf'));}else{rpcDb[_0xec35('0x74')](_0x3a739a,_0xec35('0xcf'));}}else{_0x3a739a[_0xec35('0xaf')]++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a[_0xec35('0x8e')],'field':{'countnoanswerretry':_0x3a739a['countnoanswerretry']}})[_0xec35('0x60')](function(){_0x17a81f['swapAdditionalPhones'](_0x3a739a,_0xfd3f41,_0x6605ea)['then'](function(){});});}});delete this['actions'][_0x5f2026[_0xec35('0x8c')]];break;case'19':_0x5decba[_0xec35('0xd0')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0x13,_0x5f2026[_0xec35('0xcc')]||_0x5f2026[_0xec35('0xcd')]);ami[_0xec35('0x28')](_0xec35('0xce'),ut[_0xec35('0x80')](_0x3a739a,_0xec35('0xd1')));rpcDb['createCustomerHistory'](_0x3a739a,_0xec35('0xd2'));_0x17a81f[_0xec35('0xa9')](_0x3a739a,'18',_0x5decba)[_0xec35('0x60')](function(_0x277b62){_0x1b7c31=_0x277b62[_0xec35('0x82')]==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba[_0xec35('0x85')]){_0x252fc8=ut['cloneAction'](_0x3a739a,0xf,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0xd2'));}else{rpcDb[_0xec35('0x74')](_0x3a739a,'[callProgressDetectingCustomer][machine]');}}else{_0x3a739a[_0xec35('0xaf')]++;_0x17a81f[_0xec35('0xb5')]({'id':_0x3a739a['idContact'],'field':{'countnoanswerretry':_0x3a739a[_0xec35('0xaf')]}})['then'](function(){_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});});}});delete this[_0xec35('0x17')][_0x5f2026['linkedid']];break;default:if(_0x3a739a[_0xec35('0x50')]){ut[_0xec35('0x58')](_0x5decba,_0xec35('0xd3'));ut['loggerError'](_0xec35('0xd4')+_0x5decba[_0xec35('0x2e')],_0x5f2026);}_0x5decba[_0xec35('0xd0')]+=0x1;_0x3a739a[_0xec35('0x7d')]=ut[_0xec35('0x7e')](_0x3a739a);ut[_0xec35('0x6b')](_0x3a739a,0xc,_0x5f2026['cause-txt']||_0x5f2026['dialstatus']);_0xfd3f41=_0x5decba[_0xec35('0xc4')];_0x6605ea=_0x5decba[_0xec35('0x84')];rpcDb[_0xec35('0x70')](_0x3a739a,'[callProgressDetectingCustomer][logUnknown]');_0x17a81f[_0xec35('0xa9')](_0x3a739a,'20',_0x5decba)['then'](function(_0x52dc36){_0x1b7c31=_0x52dc36['additional']==0x1;if(!_0x1b7c31){if(ut[_0xec35('0x7e')](_0x3a739a)>=_0x5decba['dialGlobalMaxRetry']){_0x252fc8=ut[_0xec35('0x86')](_0x3a739a,0xf,_0xec35('0x87'));rpcDb[_0xec35('0x74')](_0x252fc8,_0xec35('0xd5'));}else{rpcDb[_0xec35('0x74')](_0x3a739a,_0xec35('0xd5'));}delete this[_0xec35('0x17')][_0x5f2026['linkedid']];}else{_0x17a81f[_0xec35('0x8f')](_0x3a739a,_0xfd3f41,_0x6605ea)[_0xec35('0x60')](function(){});}});}if(!(_0x3a739a[_0xec35('0x50')]&&_0x15876b==='16')){utils[_0xec35('0xd6')](_0x5decba,_0xec35('0xd7'));logger[_0xec35('0x29')]('[originated][decrement][callProgressDetectingCustomer]',_0x3a739a[_0xec35('0x92')],_0xec35('0xa3'),_0x5decba[_0xec35('0x2e')],_0xec35('0x4e'),_0x5decba[_0xec35('0x30')]);}if(_0x15876b!==_0xec35('0x90')){delete this[_0xec35('0x17')][_0x5f2026[_0xec35('0x8c')]];delete this[_0xec35('0x17')][_0x5f2026['destlinkedid']];}_0x5decba['queueSummaryCountersUpdated']=!![];}};Preview[_0xec35('0x3b')]['callProgressDetectingAgent']=function(_0x27ac84,_0x11c684,_0x3d1dff){if(_[_0xec35('0xd8')](_0x11c684)&&_0xec35('0xd9')!==typeof _0x11c684){return;}if(_[_0xec35('0xd8')](_0x3d1dff)&&_0xec35('0xd9')!==typeof _0x3d1dff){return;}switch(_0x3d1dff[_0xec35('0xda')]){case'0':ut[_0xec35('0xdb')](_0x27ac84,0x0,_0xec35('0x7f'));rpcDb[_0xec35('0xdc')](_0x27ac84,_0xec35('0xdd'));break;case'3':ut[_0xec35('0xdb')](_0x27ac84,0x3,'NoAnswer');rpcDb[_0xec35('0xdc')](_0x27ac84,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xec35('0xdb')](_0x27ac84,0x5,_0xec35('0xa6'));rpcDb['createAgentHistory'](_0x27ac84,'[callProgressDetectingAgent][logBusy]');break;case'8':ut[_0xec35('0xdb')](_0x27ac84,0x8,_0xec35('0xb9'));rpcDb[_0xec35('0xdc')](_0x27ac84,_0xec35('0xde'));break;case'22':ut['logAgent'](_0x27ac84,0x16,'AnswerAGI');rpcDb['createAgentHistory'](_0x27ac84,_0xec35('0xdf'));break;default:ut[_0xec35('0xdb')](_0x27ac84,0xc,_0x3d1dff[_0xec35('0xda')]);rpcDb[_0xec35('0xdc')](_0x27ac84,_0xec35('0xde'));}utils[_0xec35('0xd6')](_0x11c684,_0xec35('0xe0'));logger[_0xec35('0x29')](_0xec35('0xe1'),_0x27ac84['uniqueid'],'\x20Queue',_0x11c684[_0xec35('0x2e')],'originated:\x20',_0x11c684['originated']);delete this[_0xec35('0x17')][_0x27ac84[_0xec35('0x92')]];};Preview['prototype'][_0xec35('0xa9')]=function(_0x100c17,_0x29645a,_0x2e51d9){return cmHopperAdditionalPhone[_0xec35('0xa9')](_0x100c17,_0x29645a,_0x2e51d9)[_0xec35('0x56')](logger['info']('[verifyAdditionalPhone]\x20'));};Preview[_0xec35('0x3b')][_0xec35('0x8f')]=function(_0x260e96,_0x1d7013,_0x3b1356){return cmHopperAdditionalPhone[_0xec35('0x8f')](_0x260e96,_0x1d7013,_0x3b1356)[_0xec35('0x56')](logger[_0xec35('0x29')](_0xec35('0xe2')));};Preview[_0xec35('0x3b')][_0xec35('0xb5')]=function(_0x421517){return Promise['resolve']()[_0xec35('0x60')](cmHopperAdditionalPhone[_0xec35('0xb5')](_0x421517))[_0xec35('0x56')](logger[_0xec35('0x29')](_0xec35('0xe3')));};Preview[_0xec35('0x3b')][_0xec35('0xe4')]=function(_0x518bd3,_0x3c9996,_0x397646,_0x539d80,_0x6e3697){var _0xad725f=this;return new Promise(function(_0x58f0b4,_0x28bf7d){if(_[_0xec35('0x4a')](_0x3c9996)||_['isNil'](_0x3c9996[_0xec35('0xe5')])||_[_0xec35('0x4a')](_0x3c9996[_0xec35('0xe6')])||_[_0xec35('0x4a')](_0x3c9996[_0xec35('0x53')])){_0x28bf7d(ut[_0xec35('0x34')]('Contact\x20is\x20undefined',_0x539d80,_0x6e3697));return;}var _0x1d4b98=uuid['v4']();var _0x5a4d73=_0xad725f[_0xec35('0x15')][_0x3c9996[_0xec35('0x4c')][_0xec35('0x2e')]];var _0x2d10ab=_0x397646?_0xad725f[_0xec35('0x18')][_0x397646]['id']:undefined;_0xad725f['actions'][_0x1d4b98]=new Action(_0x3c9996,_0x5a4d73,_0x1d4b98,_0x397646,_0x2d10ab);var _0x1e3940=_0xad725f[_0xec35('0x17')][_0x1d4b98];_0x1e3940[_0xec35('0xac')]=_0x539d80;_0x1e3940[_0xec35('0x8b')]=_0x6e3697;_0x1e3940[_0xec35('0xe7')]=_0x397646;if(_[_0xec35('0xe8')](_0x518bd3)){_0xad725f[_0xec35('0xe9')](_0x1e3940,_0x5a4d73,_0x3c9996,_0x397646)['then'](function(_0x45eac4){logger[_0xec35('0x29')](_0xec35('0xea'),_0xec35('0xeb')+_0x1e3940[_0xec35('0x4d')]+_0xec35('0xec')+_0x1e3940[_0xec35('0x8e')],JSON[_0xec35('0x2b')](_0x45eac4));ami[_0xec35('0x28')](_0xec35('0xed'),ut[_0xec35('0x80')](_0x1e3940,_0xec35('0xee'),_0xad725f[_0xec35('0x15')][_0x1e3940['queue']]));_0x58f0b4(ut['message'](_0xec35('0xef')));})['catch'](function(_0x415e0b){ut[_0xec35('0x37')](_0xec35('0xf0'),_0x415e0b);_0x28bf7d(ut[_0xec35('0x34')](_0xec35('0xf1'),_0x539d80,_0x6e3697));});}else{_0x5a4d73[_0xec35('0xf2')]+=0x1;ut['logBlacklist'](_0x1e3940);rpcDb[_0xec35('0xf3')](_0x1e3940,_0xec35('0xf4'));delete _0xad725f[_0xec35('0x17')][_0x1d4b98];_0x28bf7d(ut[_0xec35('0x34')]('Contact\x20in\x20black\x20List',_0x539d80,_0x6e3697));}});};Preview['prototype'][_0xec35('0x79')]=function(_0x4496a4){return!_[_0xec35('0x4a')](_0x4496a4)&&!_[_0xec35('0x4a')](_0x4496a4['name'])&&!_[_0xec35('0x4a')](_0x4496a4[_0xec35('0xf5')])&&_0x4496a4[_0xec35('0xf5')]&&!_[_0xec35('0x4a')](this[_0xec35('0x16')][util['format'](_0xec35('0xf6'),_0x4496a4['name'])])&&!_[_0xec35('0x4a')](this[_0xec35('0x16')][util[_0xec35('0x2c')](_0xec35('0xf6'),_0x4496a4[_0xec35('0x2e')])]['status'])&&(this[_0xec35('0x16')][util[_0xec35('0x2c')](_0xec35('0xf6'),_0x4496a4[_0xec35('0x2e')])][_0xec35('0x54')]===_0xec35('0xf7')||this['trunks'][util['format'](_0xec35('0xf6'),_0x4496a4['name'])][_0xec35('0x54')]===_0xec35('0xf8'));};Preview[_0xec35('0x3b')][_0xec35('0xf9')]=function(_0x54585d,_0x39fe47){return this[_0xec35('0xfa')](_0x54585d,_0x39fe47)['then'](function(_0x41616e){return _[_0xec35('0x51')](_0x41616e,[_0xec35('0x34')]);})[_0xec35('0x56')](function(_0x3524ec){if(_0x3524ec['unlock']){rpcDb['unlockContact'](_0x54585d);}if(_0x3524ec[_0xec35('0xf5')]){rpcDb['disableContact'](_0x54585d);}throw _['pick'](_0x3524ec,[_0xec35('0x34')]);});};Preview['prototype'][_0xec35('0xfa')]=function(_0x2cbffa,_0x39a1c7){var _0x1c11b7=this;var _0x3978e8,_0x377d9c;return rpcDb[_0xec35('0xfb')](_0x2cbffa)[_0xec35('0x60')](function(_0x1ae16d){if(!_[_0xec35('0x4a')](_0x1ae16d[0x0])){_0x377d9c=_0x1ae16d[0x0][_0xec35('0xfc')]?![]:!![];_0x3978e8=_0x1ae16d[0x0][_0xec35('0xfc')]?!![]:![];_0x3978e8=_0x39a1c7?!![]:_0x3978e8;}var _0x46a597=_0x1c11b7['validateContact'](_0x1ae16d);if(_0x46a597[_0xec35('0xfd')]){rpcDb[_0xec35('0xfe')](_[_0xec35('0x51')](_0x1ae16d[0x0],[_0xec35('0x53'),_0xec35('0xe6')]))[_0xec35('0x60')](function(_0x1022be){_0x1c11b7['checkInBlack'](_0x1022be,_0x1ae16d[0x0],_0x39a1c7,_0x377d9c,_0x3978e8)[_0xec35('0x60')](function(_0x30838a){return _0x30838a;})[_0xec35('0x56')](function(_0x20ef14){throw _0x20ef14;});})[_0xec35('0x56')](function(_0x2a7ead){ut['logger'](_0xec35('0xff'),_0x2a7ead);throw ut[_0xec35('0x34')](_0xec35('0x100'),_0x377d9c,_0x3978e8);});}else{throw ut['message'](_0x46a597[_0xec35('0x34')],_0x377d9c,_0x3978e8);}})[_0xec35('0x56')](function(_0x41da60){ut[_0xec35('0x37')](_0xec35('0x101'),_0x41da60);throw ut[_0xec35('0x34')](_0xec35('0x100'),![],!![]);});};Preview[_0xec35('0x3b')][_0xec35('0x102')]=function(_0x414aaf){if(_[_0xec35('0x4a')](_0x414aaf)||_[_0xec35('0xe8')](_0x414aaf)||!_['isNil'](_0x414aaf[0x0][_0xec35('0x65')])&&_[_0xec35('0x4a')](_0x414aaf[0x0][_0xec35('0x65')]['name'])){ut[_0xec35('0x37')](_0xec35('0x103'),_0x414aaf);return{'isValid':![],'message':_0xec35('0x104')};}var _0x5a278f=this['campaignsPreview'][_0x414aaf[0x0]['Queue'][_0xec35('0x2e')]];_0x5a278f[_0xec35('0x34')]=utils[_0xec35('0x35')][_0xec35('0x105')];if(_['isNil'](_0x5a278f)){ut['logger'](_0xec35('0x106'),_0x5a278f);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this[_0xec35('0x79')](_0x5a278f[_0xec35('0x78')])){ut[_0xec35('0x37')](_0xec35('0x107'),_0xec35('0x108')+_0x5a278f[_0xec35('0x2e')]+'\x20Trunk\x20is\x20not\x20active');if(!this['isTrunkReachable'](_0x5a278f[_0xec35('0x7a')])){ut['logger'](_0xec35('0x107'),_0x5a278f[_0xec35('0x2e')]+'\x20Trunk\x20Backup\x20is\x20not\x20active');return{'isValid':![],'message':_0xec35('0x109')};}}if(!ut[_0xec35('0x77')](_0x5a278f[_0xec35('0x45')])){ut[_0xec35('0x37')]('[Preview][validateContact][Campaign\x20Active]',_0x5a278f[_0xec35('0x2e')]+_0xec35('0x10a'));return{'isValid':![],'message':_0xec35('0x108')+_0x5a278f['name']+_0xec35('0x10a')};}return{'isValid':!![],'message':_0xec35('0x10b')};};Preview[_0xec35('0x3b')][_0xec35('0xe9')]=function(_0x2a8c5c,_0x1eb89a,_0x336a4,_0x289d33){var _0x2a4af6=this;return new Promise(function(_0x3e52e7,_0x4cdf8e){var _0xcb5f33=_0x2a8c5c[_0xec35('0x92')];var _0x205ff4=_0x2a4af6[_0xec35('0x79')](_0x1eb89a['Trunk'])?util['format'](_0xec35('0x10c'),_0x1eb89a[_0xec35('0x78')][_0xec35('0x2e')],_[_0xec35('0x4a')](_0x1eb89a['dialPrefix'])?'':_0x1eb89a['dialPrefix'][_0xec35('0x10d')]()||'',_0x1eb89a['dialCutDigit']>0x0?_0x336a4[_0xec35('0xe6')]['substring'](_0x1eb89a[_0xec35('0x10e')]):_0x336a4[_0xec35('0xe6')]):util['format'](_0xec35('0x10c'),_[_0xec35('0x4a')](_0x1eb89a['TrunkBackup'])?_0x1eb89a[_0xec35('0x78')][_0xec35('0x2e')]:_0x1eb89a[_0xec35('0x7a')][_0xec35('0x2e')],_[_0xec35('0x4a')](_0x1eb89a[_0xec35('0x10f')])?'':_0x1eb89a['dialPrefix']['trim']()||'',_0x1eb89a[_0xec35('0x10e')]>0x0?_0x336a4['phone'][_0xec35('0x110')](_0x1eb89a[_0xec35('0x10e')]):_0x336a4[_0xec35('0xe6')]);var _0x38632c=_0x2a4af6[_0xec35('0x79')](_0x1eb89a[_0xec35('0x78')])?ut[_0xec35('0x111')](_0x1eb89a[_0xec35('0x78')][_0xec35('0x112')],_0x1eb89a['dialOriginateCallerIdName'],_0x1eb89a[_0xec35('0x113')]>0x0?ut[_0xec35('0x114')](_0x1eb89a[_0xec35('0x115')],_0x1eb89a[_0xec35('0x113')]):_0x1eb89a[_0xec35('0x115')]):ut[_0xec35('0x111')](_[_0xec35('0x4a')](_0x1eb89a[_0xec35('0x7a')])?_0x1eb89a[_0xec35('0x78')][_0xec35('0x112')]:_0x1eb89a['TrunkBackup'][_0xec35('0x112')],_0x1eb89a[_0xec35('0x116')],_0x1eb89a['dialRandomLastDigitCallerIdNumber']>0x0?ut['getCallerIdRandom'](_0x1eb89a[_0xec35('0x115')],_0x1eb89a[_0xec35('0x113')]):_0x1eb89a[_0xec35('0x115')]);if(_0x38632c){_0x2a8c5c[_0xec35('0x117')]=ut[_0xec35('0x118')](_0x38632c);_0x2a8c5c['originatecalleridnum']=ut[_0xec35('0x119')](_0x38632c);}var _0x48de6c=ut[_0xec35('0x11a')](_0x1eb89a,_0x336a4,_0x205ff4,_0x38632c,_0xcb5f33,_0x2a8c5c);var _0x397a3b=utils[_0xec35('0x11b')](_0x336a4[_0xec35('0xe5')]);Object[_0xec35('0x11c')](_0x48de6c,_0x397a3b);_['merge'](_0x2a8c5c,ut[_0xec35('0x11d')](_0x48de6c));_0x2a8c5c[_0xec35('0x11e')]=moment()[_0xec35('0x2c')](_0xec35('0x69'));_0x1eb89a['variables']=_0x48de6c;var _0x11ce32=ut[_0xec35('0x11f')](_0x2a8c5c,_0x1eb89a,_0x48de6c,_0x2a8c5c[_0xec35('0x8b')],_0x289d33);return ami[_0xec35('0x120')](_0x11ce32)[_0xec35('0x60')](function(_0x52a8ad){_0x1eb89a[_0xec35('0x30')]+=0x1;logger[_0xec35('0x29')](_0xec35('0x121'),_0xcb5f33,_0xec35('0xa3'),_0x1eb89a['name'],_0xec35('0x4e'),_0x1eb89a['originated']);_0x3e52e7(_0x52a8ad);})[_0xec35('0x56')](function(_0x4722c8){ut['logAgent'](_0x2a8c5c,0xe,'OriginateError');rpcDb['createAgentHistory'](_0x2a8c5c,_0xec35('0x122'));_0x4cdf8e(_0x4722c8);});});};Preview['prototype'][_0xec35('0x21')]=function(_0x48e77a){if(this['actions'][_0x48e77a[_0xec35('0x8c')]]){this[_0xec35('0x17')][_0x48e77a[_0xec35('0x8c')]][_0xec35('0x55')]=_0x48e77a[_0xec35('0x55')];}};Preview[_0xec35('0x3b')][_0xec35('0x19')]=function(_0x894377){var _0x19db6d=this;var _0x44e809=this['actions'][_0x894377[_0xec35('0x123')]];if(_0x44e809){if(_0x44e809[_0xec35('0xe7')]&&this[_0xec35('0x18')][_0x44e809[_0xec35('0xe7')]]){ut['logLookAgent'](_0x44e809,this[_0xec35('0x18')][_0x44e809[_0xec35('0xe7')]][_0xec35('0x2e')],this[_0xec35('0x18')][_0x44e809[_0xec35('0xe7')]]['id']);}var _0x41570e=_[_0xec35('0x124')](_0x44e809);_0x41570e['responsetime']=moment()[_0xec35('0x2c')](_0xec35('0x69'));var _0x4a6cfb=_0x19db6d[_0xec35('0x15')][_0x44e809['queue']];if(ut[_0xec35('0x125')](_0x894377[_0xec35('0x126')])){if(_0x44e809['unlockAgent']){rpcDb['unlockContact'](_0x44e809[_0xec35('0x8e')]);}if(_0x44e809['activeContact']){rpcDb[_0xec35('0x68')](_0x44e809[_0xec35('0x8e')]);}ami['emit'](_0xec35('0x127'),ut[_0xec35('0x80')](_0x44e809,_0xec35('0x128'),this[_0xec35('0x15')][_0x44e809[_0xec35('0x4d')]]));this['callProgressDetectingAgent'](_0x41570e,_0x4a6cfb,_0x894377);}else{_0x44e809[_0xec35('0x11e')]=moment()[_0xec35('0x2c')](_0xec35('0x69'));ut['logAgent'](_0x41570e,0x4,'Answer');rpcDb[_0xec35('0xdc')](_0x41570e,_0xec35('0x129'));}}};Preview[_0xec35('0x3b')][_0xec35('0x1b')]=function(_0x90e5c7){var _0x1fa86a=this['actions'][_0x90e5c7[_0xec35('0x8c')]];var _0x576538;if(_0x1fa86a){_0x576538=this[_0xec35('0x15')][_0x1fa86a[_0xec35('0x4d')]];logger[_0xec35('0x29')](_0xec35('0x12a'),_0x90e5c7['linkedid'],_0xec35('0xa3'),_0x576538[_0xec35('0x2e')],_0xec35('0x4f'),_0x576538[_0xec35('0x31')]);}if(this['actions'][_0x90e5c7['linkedid']]&&_0x90e5c7[_0xec35('0x8c')]!==_0x90e5c7[_0xec35('0x92')]){if(_0x90e5c7['cause']==='16'&&this[_0xec35('0x17')][_0x90e5c7['linkedid']][_0xec35('0x50')]){this[_0xec35('0x7b')](_0x90e5c7,_0x90e5c7['linkedid'],_0x90e5c7['cause']);}else if(this[_0xec35('0x17')][_0x90e5c7[_0xec35('0x8c')]][_0xec35('0x50')]){logger[_0xec35('0x29')]('[syncHangup][talking][cause]',_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')],'\x20Queue',_0x576538['name'],_0xec35('0x4f'),_0x576538[_0xec35('0x31')]);this[_0xec35('0x7b')](_0x90e5c7,_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')]);}}else if(_0x1fa86a&&_[_0xec35('0x4a')](_0x1fa86a['statedesc'])&&_0x576538[_0xec35('0x12c')]&&_0x90e5c7['linkedid']===_0x90e5c7[_0xec35('0x92')]&&_[_0xec35('0x4a')](_0x90e5c7[_0xec35('0xda')])&&_0x90e5c7[_0xec35('0x12b')]==='16'&&_0x90e5c7[_0xec35('0x12d')]==='6'&&_[_0xec35('0xd8')](_0x1fa86a[_0xec35('0x12e')])){if(_0x1fa86a['unlockAgent']){rpcDb[_0xec35('0x12f')](_0x1fa86a[_0xec35('0x8e')]);}if(_0x1fa86a['activeContact']){rpcDb['disableContact'](_0x1fa86a[_0xec35('0x8e')]);}_0x90e5c7[_0xec35('0xda')]='22';this[_0xec35('0x130')](_0x1fa86a,_0x576538,_0x90e5c7);}else if(_0x1fa86a&&_0x1fa86a[_0xec35('0x12e')]){if(_0x90e5c7[_0xec35('0x12b')]==='16'&&this[_0xec35('0x17')][_0x90e5c7[_0xec35('0x8c')]][_0xec35('0x50')]){logger[_0xec35('0x29')](_0xec35('0x131'),_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')],_0xec35('0xa3'),_0x576538[_0xec35('0x2e')],_0xec35('0x4f'),_0x576538[_0xec35('0x31')]);this[_0xec35('0x7b')](_0x90e5c7,_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')]);}else if(this[_0xec35('0x17')][_0x90e5c7[_0xec35('0x8c')]][_0xec35('0x50')]){logger[_0xec35('0x29')](_0xec35('0x132'),_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')],_0xec35('0xa3'),_0x576538[_0xec35('0x2e')],_0xec35('0x4f'),_0x576538[_0xec35('0x31')]);this[_0xec35('0x7b')](_0x90e5c7,_0x90e5c7[_0xec35('0x8c')],_0x90e5c7[_0xec35('0x12b')]);}}};Preview['prototype']['syncDialEnd']=function(_0x43a5d1){if(this[_0xec35('0x17')][_0x43a5d1[_0xec35('0x133')]]&&_0x43a5d1['destlinkedid']!==_0x43a5d1[_0xec35('0x134')]){this[_0xec35('0x7b')](_0x43a5d1,_0x43a5d1[_0xec35('0x133')],_0x43a5d1[_0xec35('0xcd')]);}};Preview[_0xec35('0x3b')][_0xec35('0x1d')]=function(_0x42dc68){if(this[_0xec35('0x17')][_0x42dc68[_0xec35('0x8c')]]&&_0x42dc68[_0xec35('0x8c')]!==_0x42dc68[_0xec35('0x92')]&&!this['actions'][_0x42dc68[_0xec35('0x8c')]]['dialAnswer']){if(_0x42dc68['cause']==='1'){this[_0xec35('0x7b')](_0x42dc68,_0x42dc68[_0xec35('0x8c')],_0x42dc68[_0xec35('0x12b')]);}}};Preview[_0xec35('0x3b')][_0xec35('0x135')]=function(_0x23f6aa,_0x3c9a70,_0x46e897){if(this[_0xec35('0x17')][_0x23f6aa]){if(_[_0xec35('0x4a')](this[_0xec35('0x17')][_0x23f6aa][_0xec35('0x136')])){this[_0xec35('0x17')][_0x23f6aa]['variables']={};}this['actions'][_0x23f6aa][_0xec35('0x136')][_0x3c9a70]=_0x46e897;}};Preview[_0xec35('0x3b')][_0xec35('0x23')]=function(_0x113621){try{if(!_[_0xec35('0x4a')](_0x113621)){if(ut['filterKey'](_[_0xec35('0x137')](_0x113621[_0xec35('0x138')])[0x0])){this[_0xec35('0x135')](_0x113621['uniqueid'],_[_0xec35('0x137')](_0x113621[_0xec35('0x138')])[0x0],_0x113621[_0xec35('0x139')]);}}}catch(_0x2fb55b){logger[_0xec35('0x13a')](_0xec35('0x13b'),util[_0xec35('0x13c')](_0x2fb55b,{'showHidden':![],'depth':null}));}};Preview['prototype'][_0xec35('0x25')]=function(_0x3652fb){if(_0x3652fb){if(this[_0xec35('0x17')][_0x3652fb['transfertargetlinkedid']]){this[_0xec35('0x17')][_0x3652fb[_0xec35('0x13d')]][_0xec35('0x12e')]=!![];}}};Preview[_0xec35('0x3b')][_0xec35('0x27')]=function(_0x1d89e5){if(_0x1d89e5){if(this[_0xec35('0x17')][_0x1d89e5[_0xec35('0x13e')]]){this[_0xec35('0x17')][_0x1d89e5[_0xec35('0x13e')]][_0xec35('0x12e')]=!![];}}};module['exports']=Preview;