a138b91b405e9832991e302d4713786f74a35fd0
[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 _0xcf1c=['scheduledAt','unlockAgent','activeContact','linkedid','actioncountonusuch','idContact','swapAdditionalPhones','answertime','[syncHangup][talking][increment]','uniqueid','\x20Queue','connect','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','complete','outboundAnswerCallsDay','total','answered','[16]','Answer','[callProgressDetectingCustomer][logAnswer]','crateCustomerReportQueue','sumDuration','sumBillable','talktime','[syncHangup][talking][decrement]','outboundBusyCallsDay','countbusyretry','Busy','dialBusyRetryFrequency','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','incrementPreviewCounters','NOANSWER','dialNoAnswerRetryFrequency','buildNoAnswerEventPayload','custom:agentnoanswer','[callProgressDetectingCustomer][logNoAnswer]','Global','[callProgressDetectingCustomer][logNoAnswerGlobal]','countnoanswerretry','dialNoAnswerMaxRetry','CONGESTION','countcongestionretry','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','countabandonedretry','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','outboundUnknownCallsDay','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','NoAnswer','[callProgressDetectingAgent][logBusy]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent][logCongestion]','[originated][decrement][callProgressDetectingAgent]','[swapAdditionalPhone]\x20','[incrementPreviewCounters]\x20','checkInBlack','phone','Contact\x20is\x20undefined','Queue','isEmpty','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','active','SIP/%s','reachable','execRun','unlock','unlockContact','disableContact','getContactPreview','recallme','validateContact','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20Backup\x20is\x20not\x20active','[Preview][validateContact][Campaign\x20Active]','Is\x20Valid','execCall','SIP/%s/%s%s','dialPrefix','substring','trim','dialCutDigit','getCallerId','callerid','dialOriginateCallerIdName','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','originatecalleridname','originatecalleridnum','setXMDContactVariables','Contact','merge','toLowerVariables','variables','variablesAction','OriginateError','actionid','lookAgent','logLookAgent','clone','responsetime','rejected','[callProgressDetectingAgent][logAnswer]','pTalking:\x20','cause','statedesc','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','[syncHangup][talking][cause]','destlinkedid','addVariable','keys','variable','value','error','inspect','transfertargetlinkedid','transfererlinkedid','util','uuid','moment','../../../config/logger','actionPreview','../ami','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','../dialer/utils','redis','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','sequence','campaignsPreview','trunks','agents','originateresponse','syncOriginateResponse','hangup','syncHangup','bind','hanguprequest','syncHangupRequest','syncDialEnd','syncNewExten','syncVarSet','syncAttendedTransfer','blindtransfer','syncBlindTransfer','loopCampaigns','emit','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','format','voice_queue_channel:remove','sendMessageOneNotActive','originated','pTalking','available','paused','message','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','name','\x20is\x20not\x20active','CAMPAIGN_STATUS','\x20is\x20deactivated','syncCampaigns','clockClearZombieChannels','hasOwnProperty','dialMethod','preview','clearZombieChannels','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','isNil','actions','[clearZombieChannels][talking]','originated:\x20','queue','dialAnswer','pick','contactId','UserId','VoiceQueueId','ListId','Action','status','channel','updateOriginated','[clearZombieChannel]','decrementTalkink','[Dialer][checkChannel][pTalking][Preview]','loggerError','[Dialer][checkChannel][Preview]','[action]','getContactRecallMe','agentReadyId','then','length','scheduledat','Agent','voicePause','run','catch','[RecallMe]','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','RecallFailedTimeout','createCustomerHistory','[HistoryRecallClose]','createCustomerFinal','logger2','[getContactRecallMe]','setMessage','IsNotLoggedIn','NO_AGENTS_LOGGED','isActive','dialActive','INACTIVE','isTrunkReachable','Trunk','TrunkBackup','UNREACHABLE_TRUNK','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','cloneAction','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact'];(function(_0x181d2d,_0x480cc8){var _0x4a0cfc=function(_0x5e96b1){while(--_0x5e96b1){_0x181d2d['push'](_0x181d2d['shift']());}};_0x4a0cfc(++_0x480cc8);}(_0xcf1c,0x1f0));var _0xccf1=function(_0x57494e,_0x2c4d3d){_0x57494e=_0x57494e-0x0;var _0x4099da=_0xcf1c[_0x57494e];return _0x4099da;};'use strict';var util=require(_0xccf1('0x0'));var _=require('lodash');var uuid=require(_0xccf1('0x1'));var moment=require(_0xccf1('0x2'));var Redis=require('ioredis');var config=require('../../../config/environment');var logger=require(_0xccf1('0x3'))('preview');var loggerAction=require(_0xccf1('0x3'))(_0xccf1('0x4'));var ami=require(_0xccf1('0x5'));var rpcDb=require(_0xccf1('0x6'));var cmHopperAdditionalPhone=require(_0xccf1('0x7'));var Action=require(_0xccf1('0x8'));var ut=require(_0xccf1('0x9'));var utils=require(_0xccf1('0xa'));config[_0xccf1('0xb')]=_[_0xccf1('0xc')](config[_0xccf1('0xb')],{'host':_0xccf1('0xd'),'port':0x18eb});var io=require(_0xccf1('0xe'))(new Redis(config[_0xccf1('0xb')]));var Sequence=function(){};Sequence[_0xccf1('0xf')][_0xccf1('0x10')]=function(_0x106aee){this[_0xccf1('0x11')]=this[_0xccf1('0x11')]?this['tail'][_0xccf1('0x12')](_0x106aee):_0x106aee();};function Preview(_0x32bf48){this[_0xccf1('0x13')]=new Sequence();this[_0xccf1('0x14')]=_0x32bf48['voiceQueues'];this['trunks']=_0x32bf48[_0xccf1('0x15')];this['actions']={};this[_0xccf1('0x16')]=_0x32bf48[_0xccf1('0x16')];this['clockClearZombieChannels']=0x0;ami['on'](_0xccf1('0x17'),this[_0xccf1('0x18')]['bind'](this));ami['on'](_0xccf1('0x19'),this[_0xccf1('0x1a')][_0xccf1('0x1b')](this));ami['on'](_0xccf1('0x1c'),this[_0xccf1('0x1d')][_0xccf1('0x1b')](this));ami['on']('dialend',this[_0xccf1('0x1e')][_0xccf1('0x1b')](this));ami['on']('newexten',this[_0xccf1('0x1f')][_0xccf1('0x1b')](this));ami['on']('varset',this[_0xccf1('0x20')][_0xccf1('0x1b')](this));ami['on']('attendedtransfer',this[_0xccf1('0x21')]['bind'](this));ami['on'](_0xccf1('0x22'),this[_0xccf1('0x23')][_0xccf1('0x1b')](this));this[_0xccf1('0x24')](this[_0xccf1('0x14')]);}function emit(_0x1a2dc0,_0x7ff0b1,_0x3925bc){io['to'](_0x1a2dc0)[_0xccf1('0x25')](_0x7ff0b1,_0x3925bc);}function emitVoiceQueueChannelRemove(_0x158d7a){logger[_0xccf1('0x26')](_0xccf1('0x27'),JSON[_0xccf1('0x28')](_0x158d7a));emit(util[_0xccf1('0x29')]('voice:queue:%s',_0x158d7a['name']),_0xccf1('0x2a'),_0x158d7a);io[_0xccf1('0x25')]('voice_queue_presence:remove',_0x158d7a);}function notSendMessagesQueue(_0x2d20a6){if(_0x2d20a6[_0xccf1('0x2b')]){if(_0x2d20a6[_0xccf1('0x2c')]===0x0&&_0x2d20a6[_0xccf1('0x2d')]===0x0){_0x2d20a6[_0xccf1('0x2b')]=![];_0x2d20a6[_0xccf1('0x2e')]=0x0;_0x2d20a6[_0xccf1('0x2f')]=0x0;_0x2d20a6[_0xccf1('0x30')]=utils['CAMPAIGN_STATUS']['INACTIVE'];ut[_0xccf1('0x31')](_0xccf1('0x32'),_0x2d20a6[_0xccf1('0x33')]+_0xccf1('0x34'));}else{_0x2d20a6[_0xccf1('0x30')]=utils[_0xccf1('0x35')]['DEACTIVATED'];ut[_0xccf1('0x31')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x2d20a6[_0xccf1('0x33')]+_0xccf1('0x36'));}}}Preview[_0xccf1('0xf')][_0xccf1('0x24')]=function(){var _0x1777e5=this;setInterval(function(){_0x1777e5[_0xccf1('0x37')]();},0x7cf);};Preview['prototype']['syncCampaigns']=function(){var _0xa0de3a=this[_0xccf1('0x14')];this[_0xccf1('0x38')]+=0x1;for(var _0x3ac060 in _0xa0de3a){if(_0xa0de3a[_0xccf1('0x39')](_0x3ac060)&&(_0xa0de3a[_0x3ac060][_0xccf1('0x3a')]===_0xccf1('0x3b')||_0xa0de3a[_0x3ac060][_0xccf1('0x3a')]==='booked')&&_0xa0de3a[_0x3ac060]['type']==='outbound'){if(this[_0xccf1('0x38')]>0x7){this[_0xccf1('0x38')]=0x0;this[_0xccf1('0x3c')]();}}if(_0xa0de3a[_0xccf1('0x39')](_0x3ac060)&&_0xa0de3a[_0x3ac060][_0xccf1('0x3a')]===_0xccf1('0x3b')&&_0xa0de3a[_0x3ac060]['type']==='outbound'){if(_0xa0de3a[_0x3ac060]['dialActive']){this['setMessage'](_0xa0de3a[_0x3ac060]);if(_0xa0de3a[_0x3ac060][_0xccf1('0x3d')])this[_0xccf1('0x3e')](_0xa0de3a[_0x3ac060]);}else{notSendMessagesQueue(_0xa0de3a[_0x3ac060]);}}}};Preview[_0xccf1('0xf')][_0xccf1('0x3f')]=function(_0x557c4e){var _0x2d0ea0=this;this['sequence'][_0xccf1('0x10')](function(){if(!_[_0xccf1('0x40')](_0x2d0ea0[_0xccf1('0x41')][_0x557c4e])){loggerAction[_0xccf1('0x26')](_0xccf1('0x42'),_0x557c4e,'Queue',_0x2d0ea0[_0xccf1('0x41')][_0x557c4e]['queue'],_0xccf1('0x43'),JSON[_0xccf1('0x28')](_0x2d0ea0[_0xccf1('0x14')][_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x44')]][_0xccf1('0x2c')]),'pTalking:\x20',JSON[_0xccf1('0x28')](_0x2d0ea0['campaignsPreview'][_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x44')]]['pTalking']),JSON[_0xccf1('0x28')](_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x45')]),JSON['stringify'](_[_0xccf1('0x46')](_0x2d0ea0[_0xccf1('0x41')][_0x557c4e],[_0xccf1('0x47'),_0xccf1('0x48'),_0xccf1('0x49'),_0xccf1('0x4a')])));return ami[_0xccf1('0x4b')]({'action':_0xccf1('0x4c'),'channel':_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x4d')]})['catch'](function(_0x14e650){if(_0x14e650[_0xccf1('0x30')]==='No\x20such\x20channel'){setTimeout(function(){if(_0x2d0ea0[_0xccf1('0x41')][_0x557c4e]){ut[_0xccf1('0x4e')](_0x2d0ea0[_0xccf1('0x14')][_0x2d0ea0[_0xccf1('0x41')][_0x557c4e]['queue']],_0xccf1('0x4f'));if(_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x45')]===!![]){ut[_0xccf1('0x50')](_0x2d0ea0['campaignsPreview'][_0x2d0ea0[_0xccf1('0x41')][_0x557c4e]['queue']],_0xccf1('0x4f'));ut['loggerError'](_0xccf1('0x51')+_0x557c4e,_0x2d0ea0['actions'][_0x557c4e]['queue']);}ut[_0xccf1('0x52')](_0xccf1('0x53')+_0x557c4e,_0x2d0ea0[_0xccf1('0x41')][_0x557c4e][_0xccf1('0x44')]);delete _0x2d0ea0[_0xccf1('0x41')][_0x557c4e];}},0x2328);}});}});};Preview[_0xccf1('0xf')]['clearZombieChannels']=function(){var _0xebabd9=this;loggerAction[_0xccf1('0x26')](_0xccf1('0x54'),_['size'](this[_0xccf1('0x41')]));for(var _0x8a45b5 in this['actions']){if(_0xebabd9[_0xccf1('0x41')][_0xccf1('0x39')](_0x8a45b5)){_0xebabd9[_0xccf1('0x3f')](_0x8a45b5);}}};Preview[_0xccf1('0xf')][_0xccf1('0x3e')]=function(_0x26566f){var _0x4eec26=this;rpcDb[_0xccf1('0x55')](_0x26566f['id'],ut[_0xccf1('0x56')](this[_0xccf1('0x16')]))[_0xccf1('0x57')](function(_0x44fca7){if(!_[_0xccf1('0x40')](_0x44fca7)){for(var _0xc4c7f4=0x0;_0xc4c7f4<_0x44fca7[_0xccf1('0x58')];_0xc4c7f4+=0x1){if(ut['getDiff'](_0x44fca7[_0xc4c7f4][_0xccf1('0x59')])<_0x26566f['dialRecallMeTimeout']*0x3c){if(_0x44fca7[_0xc4c7f4]['Agent']&&!_0x44fca7[_0xc4c7f4][_0xccf1('0x5a')][_0xccf1('0x5b')]){_0x4eec26[_0xccf1('0x5c')](_0x44fca7[_0xc4c7f4]['id'])[_0xccf1('0x57')](ut['logger2']('[RecallMe]'))[_0xccf1('0x5d')](ut['logger2'](_0xccf1('0x5e')));}else{rpcDb['disableContact'](_0x44fca7[_0xc4c7f4]['id']);}}else{var _0x473807=new Action(_0x44fca7[_0xc4c7f4],_0x26566f);_0x473807['starttime']=moment()[_0xccf1('0x29')](_0xccf1('0x5f'));_0x26566f[_0xccf1('0x60')]+=0x1;ut[_0xccf1('0x61')](_0x473807,0x17,_0xccf1('0x62'));if(_0x26566f[_0xccf1('0x63')]){rpcDb[_0xccf1('0x64')](ut[_0xccf1('0x65')](_0x44fca7[_0xc4c7f4]));rpcDb['createCustomerHistory'](_0x473807,'[HistoryDialRecallInQueue][historyCatch]');}else{ut[_0xccf1('0x61')](_0x473807,0x16,_0xccf1('0x66'));rpcDb[_0xccf1('0x67')](_0x473807,_0xccf1('0x68'));rpcDb[_0xccf1('0x69')](_0x473807,_0xccf1('0x68'));}}}}})[_0xccf1('0x5d')](ut[_0xccf1('0x6a')](_0xccf1('0x6b')));};Preview[_0xccf1('0xf')][_0xccf1('0x6c')]=function(_0x118d0a){_0x118d0a[_0xccf1('0x2b')]=!![];if(ut[_0xccf1('0x6d')](_0x118d0a['loggedIn'])){_0x118d0a[_0xccf1('0x30')]=utils[_0xccf1('0x35')][_0xccf1('0x6e')];}else if(!ut[_0xccf1('0x6f')](_0x118d0a[_0xccf1('0x70')])){_0x118d0a[_0xccf1('0x30')]=utils[_0xccf1('0x35')][_0xccf1('0x71')];}else if(!this[_0xccf1('0x72')](_0x118d0a[_0xccf1('0x73')])){if(!this[_0xccf1('0x72')](_0x118d0a[_0xccf1('0x74')])){_0x118d0a['message']=utils[_0xccf1('0x35')][_0xccf1('0x75')];}else{_0x118d0a[_0xccf1('0x30')]=utils[_0xccf1('0x35')]['ACTIVE'];}}else{_0x118d0a[_0xccf1('0x30')]=utils[_0xccf1('0x35')][_0xccf1('0x76')];}};Preview[_0xccf1('0xf')][_0xccf1('0x77')]=function(_0x853e78,_0x52ad06,_0x239960){var _0x383d4e=this;var _0x54625e=this['actions'][_0x52ad06];var _0x474644=this['campaignsPreview'][_0x54625e[_0xccf1('0x44')]];var _0x519016;var _0x21cd51=![];var _0x4ee6f6=0x2;var _0x35e528=0x3;if(_0x474644){switch(_0x239960){case'1':_0x474644[_0xccf1('0x78')]+=0x1;_0x54625e[_0xccf1('0x79')]+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x0,_0xccf1('0x7c'));ami[_0xccf1('0x25')](_0xccf1('0x7d'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0x7f')));rpcDb['createCustomerHistory'](_0x54625e,_0xccf1('0x80'));_0x383d4e[_0xccf1('0x81')](_0x54625e,'0',_0x474644)[_0xccf1('0x57')](function(_0x43621a){_0x21cd51=_0x43621a[_0xccf1('0x82')]==0x1;_0x4ee6f6=_0x474644[_0xccf1('0x83')];_0x35e528=_0x474644[_0xccf1('0x84')];if(!_0x21cd51){if(ut['totalGlobal'](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0xf,'Global');rpcDb['createCustomerFinal'](_0x519016,_0xccf1('0x87'));}else{if(_0x54625e[_0xccf1('0x79')]>=_0x474644[_0xccf1('0x88')]){rpcDb['createCustomerFinal'](_0x54625e,_0xccf1('0x87'));}else{rpcDb[_0xccf1('0x89')](ut[_0xccf1('0x8a')](_0x54625e,'countnosuchnumberretry',_0x474644[_0xccf1('0x83')]),_0x54625e[_0xccf1('0x8b')],_0x54625e[_0xccf1('0x8c')]);}}delete this[_0xccf1('0x41')][_0x853e78[_0xccf1('0x8d')]];}else{_0x54625e['countnosuchnumberretry']++;logger[_0xccf1('0x26')](_0xccf1('0x8e'),_0x54625e[_0xccf1('0x79')]);logger['info']('id',_0x54625e['idContact']);_0x383d4e['incrementPreviewCounters']({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countnosuchnumberretry':_0x54625e[_0xccf1('0x79')]}})['then'](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case'ANSWER':var _0x21fe5b=moment()[_0xccf1('0x29')](_0xccf1('0x5f'));_0x54625e['responsetime']=_0x21fe5b;_0x54625e[_0xccf1('0x91')]=_0x21fe5b;_0x54625e[_0xccf1('0x45')]=!![];_0x474644[_0xccf1('0x2d')]+=0x1;logger[_0xccf1('0x26')](_0xccf1('0x92'),_0x54625e[_0xccf1('0x93')],_0xccf1('0x94'),_0x474644[_0xccf1('0x33')],'pTalking:\x20',_0x474644[_0xccf1('0x2d')]);ami[_0xccf1('0x25')]('custom:agentconnect',ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0x95'),this[_0xccf1('0x14')][_0x54625e['queue']]));if(_0x474644[_0xccf1('0x96')]){ami[_0xccf1('0x25')](_0xccf1('0x97'),ut[_0xccf1('0x98')](_0x54625e));}break;case'16':ami[_0xccf1('0x25')](_0xccf1('0x99'),ut['buildObj'](_0x54625e,'complete',this['campaignsPreview'][_0x54625e[_0xccf1('0x44')]]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x54625e,_0xccf1('0x9a')));_0x474644[_0xccf1('0x9b')]+=0x1;_0x474644[_0xccf1('0x9c')]+=0x1;_0x474644[_0xccf1('0x9d')]+=0x1;ut[_0xccf1('0x50')](_0x474644,_0xccf1('0x9e'));_0x54625e[_0xccf1('0x7a')]=ut['totalGlobal'](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x4,_0xccf1('0x9f'));rpcDb['createCustomerHistory'](_0x54625e,_0xccf1('0xa0'));rpcDb[_0xccf1('0x69')](_0x54625e,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb[_0xccf1('0xa1')](_0x54625e);_0x474644[_0xccf1('0xa2')]+=_0x54625e['talktime'];_0x474644[_0xccf1('0xa3')]+=_0x54625e[_0xccf1('0xa4')];logger['info'](_0xccf1('0xa5'),_0x54625e[_0xccf1('0x93')],_0xccf1('0x94'),_0x474644[_0xccf1('0x33')],'pTalking:\x20',_0x474644['pTalking']);delete this[_0xccf1('0x41')][_0x853e78[_0xccf1('0x8d')]];break;case'BUSY':_0x474644[_0xccf1('0xa6')]+=0x1;_0x54625e[_0xccf1('0xa7')]+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x5,_0xccf1('0xa8'));_0x4ee6f6=_0x474644[_0xccf1('0xa9')];_0x35e528=_0x474644[_0xccf1('0x84')];ami[_0xccf1('0x25')](_0xccf1('0xaa'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0xab')));rpcDb['createCustomerHistory'](_0x54625e,_0xccf1('0xac'));_0x383d4e[_0xccf1('0x81')](_0x54625e,'5',_0x474644)[_0xccf1('0x57')](function(_0x3dcb3b){_0x21cd51=_0x3dcb3b[_0xccf1('0x82')]==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0xf,'Global');rpcDb['createCustomerFinal'](_0x519016,_0xccf1('0xad'));}else{if(_0x54625e[_0xccf1('0xa7')]>=_0x474644[_0xccf1('0xae')]){rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xac'));}else{rpcDb[_0xccf1('0x89')](ut[_0xccf1('0x8a')](_0x54625e,_0xccf1('0xa7'),_0x474644[_0xccf1('0xa9')]),_0x54625e[_0xccf1('0x8b')],_0x54625e['activeContact']);}}}else{_0x54625e[_0xccf1('0xa7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countbusyretry':_0x54625e['countbusyretry']}})[_0xccf1('0x57')](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case _0xccf1('0xb0'):_0x474644['outboundNoAnswerCallsDay']+=0x1;_0x54625e['countnoanswerretry']+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x3,'NoAnswer');_0x4ee6f6=_0x474644[_0xccf1('0xb1')];_0x35e528=_0x474644[_0xccf1('0x84')];var _0x231299=ut[_0xccf1('0xb2')](_0x54625e,_0x474644);ami[_0xccf1('0x25')](_0xccf1('0xb3'),_0x231299);rpcDb[_0xccf1('0x67')](_0x54625e,_0xccf1('0xb4'));_0x383d4e['verifyAdditionalPhones'](_0x54625e,'3',_0x474644)[_0xccf1('0x57')](function(_0x17ad7f){_0x21cd51=_0x17ad7f['additional']==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut['cloneAction'](_0x54625e,0xf,_0xccf1('0xb5'));rpcDb[_0xccf1('0x69')](_0x519016,_0xccf1('0xb6'));}else{if(_0x54625e[_0xccf1('0xb7')]>=_0x474644[_0xccf1('0xb8')]){rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xb4'));}else{rpcDb[_0xccf1('0x89')](ut[_0xccf1('0x8a')](_0x54625e,_0xccf1('0xb7'),_0x474644[_0xccf1('0xb1')]),_0x54625e[_0xccf1('0x8b')],_0x54625e[_0xccf1('0x8c')]);}}}else{_0x54625e[_0xccf1('0xb7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e['idContact'],'field':{'countnoanswerretry':_0x54625e[_0xccf1('0xb7')]}})[_0xccf1('0x57')](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case _0xccf1('0xb9'):_0x474644['outboundCongestionCallsDay']+=0x1;_0x54625e[_0xccf1('0xba')]+=0x1;_0x54625e[_0xccf1('0x7a')]=ut['totalGlobal'](_0x54625e);ut['logCustomer'](_0x54625e,0x8,_0xccf1('0xbb'));_0x4ee6f6=_0x474644[_0xccf1('0xbc')];_0x35e528=_0x474644['callAdditionalPhoneAfterMin'];ami[_0xccf1('0x25')](_0xccf1('0xbd'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0xbe')));rpcDb[_0xccf1('0x67')](_0x54625e,'[callProgressDetectingCustomer][logCongestion]');_0x383d4e[_0xccf1('0x81')](_0x54625e,'8',_0x474644)[_0xccf1('0x57')](function(_0x2dfd79){_0x21cd51=_0x2dfd79[_0xccf1('0x82')]==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut['cloneAction'](_0x54625e,0xf,_0xccf1('0xb5'));rpcDb[_0xccf1('0x69')](_0x519016,_0xccf1('0xbf'));}else{if(_0x54625e['countcongestionretry']>=_0x474644[_0xccf1('0xc0')]){rpcDb['createCustomerFinal'](_0x54625e,_0xccf1('0xc1'));}else{rpcDb[_0xccf1('0x89')](ut[_0xccf1('0x8a')](_0x54625e,_0xccf1('0xba'),_0x474644[_0xccf1('0xa9')]),_0x54625e[_0xccf1('0x8b')],_0x54625e[_0xccf1('0x8c')]);}}}else{_0x54625e['countcongestionretry']++;_0x383d4e['incrementPreviewCounters']({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countcongestionretry':_0x54625e[_0xccf1('0xba')]}})[_0xccf1('0x57')](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case _0xccf1('0xc2'):_0x474644['outboundRejectCallsDay']+=0x1;_0x54625e[_0xccf1('0xc3')]+=0x1;_0x54625e['countglobal']=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x14,_0xccf1('0xc4'));_0x4ee6f6=_0x474644[_0xccf1('0xc5')];_0x35e528=_0x474644[_0xccf1('0x84')];ami[_0xccf1('0x25')](_0xccf1('0xc6'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0xc7')));rpcDb['createCustomerHistory'](_0x54625e,_0xccf1('0xc8'));_0x383d4e[_0xccf1('0x81')](_0x54625e,'20',_0x474644)['then'](function(_0x1bc00b){_0x21cd51=_0x1bc00b['additional']==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0x14,_0xccf1('0xc4'));rpcDb['createCustomerFinal'](_0x519016,_0xccf1('0xc9'));}else{if(_0x54625e[_0xccf1('0xc3')]>=_0x474644[_0xccf1('0xca')]){rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xc9'));}else{rpcDb[_0xccf1('0x89')](ut[_0xccf1('0x8a')](_0x54625e,_0xccf1('0xc3'),_0x474644[_0xccf1('0xc5')]),_0x54625e[_0xccf1('0x8b')],_0x54625e['activeContact']);}}}else{_0x54625e[_0xccf1('0xb7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countnoanswerretry':_0x54625e['countnoanswerretry']}})['then'](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case'ABANDONED':_0x474644['outboundAbandonedCallsDay']+=0x1;_0x54625e[_0xccf1('0xcb')]+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0xb,'Abandoned');rpcDb[_0xccf1('0x67')](_0x54625e,_0xccf1('0xcc'));_0x383d4e['verifyAdditionalPhones'](_0x54625e,'11',_0x474644)[_0xccf1('0x57')](function(_0x188564){_0x21cd51=_0x188564['additional']==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644[_0xccf1('0x85')]){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0xf,_0xccf1('0xb5'));rpcDb[_0xccf1('0x69')](_0x519016,_0xccf1('0xcc'));}else{if(_0x54625e[_0xccf1('0xcd')]>=_0x474644[_0xccf1('0xce')]){rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xcc'));}else{rpcDb[_0xccf1('0x89')](ut['scheduledAt'](_0x54625e,_0xccf1('0xcb'),_0x474644[_0xccf1('0xcf')]),_0x54625e['unlockAgent'],_0x54625e[_0xccf1('0x8c')]);}}}else{_0x54625e[_0xccf1('0xb7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countnoanswerretry':_0x54625e['countnoanswerretry']}})[_0xccf1('0x57')](function(){_0x383d4e['swapAdditionalPhones'](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});break;case'18':_0x474644[_0xccf1('0xd0')]+=0x1;_0x54625e[_0xccf1('0xd1')]+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x12,_0x853e78[_0xccf1('0xd2')]||_0x853e78[_0xccf1('0xd3')]);ami[_0xccf1('0x25')](_0xccf1('0xd4'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0xd5')));rpcDb['createCustomerHistory'](_0x54625e,'[callProgressDetectingCustomer][hangupInAMD]');_0x383d4e[_0xccf1('0x81')](_0x54625e,'18',_0x474644)[_0xccf1('0x57')](function(_0x155077){_0x21cd51=_0x155077[_0xccf1('0x82')]==0x1;if(!_0x21cd51){if(ut[_0xccf1('0x7b')](_0x54625e)>=_0x474644['dialGlobalMaxRetry']){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0x12,'Global');rpcDb['createCustomerFinal'](_0x519016,_0xccf1('0xd6'));}else{rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xd6'));}}else{_0x54625e[_0xccf1('0xb7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countnoanswerretry':_0x54625e['countnoanswerretry']}})[_0xccf1('0x57')](function(){_0x383d4e['swapAdditionalPhones'](_0x54625e,_0x4ee6f6,_0x35e528)['then'](function(){});});}});delete this['actions'][_0x853e78[_0xccf1('0x8d')]];break;case'19':_0x474644['outboundUnknownCallsDay']+=0x1;_0x54625e[_0xccf1('0x7a')]=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0x13,_0x853e78[_0xccf1('0xd2')]||_0x853e78[_0xccf1('0xd3')]);ami['emit'](_0xccf1('0xd4'),ut[_0xccf1('0x7e')](_0x54625e,_0xccf1('0xd5')));rpcDb['createCustomerHistory'](_0x54625e,'[callProgressDetectingCustomer][machine]');_0x383d4e['verifyAdditionalPhones'](_0x54625e,'18',_0x474644)[_0xccf1('0x57')](function(_0x191913){_0x21cd51=_0x191913[_0xccf1('0x82')]==0x1;if(!_0x21cd51){if(ut['totalGlobal'](_0x54625e)>=_0x474644['dialGlobalMaxRetry']){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0xf,'Global');rpcDb['createCustomerFinal'](_0x519016,_0xccf1('0xd7'));}else{rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xd7'));}}else{_0x54625e[_0xccf1('0xb7')]++;_0x383d4e[_0xccf1('0xaf')]({'id':_0x54625e[_0xccf1('0x8f')],'field':{'countnoanswerretry':_0x54625e[_0xccf1('0xb7')]}})[_0xccf1('0x57')](function(){_0x383d4e[_0xccf1('0x90')](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});});}});delete this[_0xccf1('0x41')][_0x853e78[_0xccf1('0x8d')]];break;default:if(_0x54625e['dialAnswer']){ut[_0xccf1('0x50')](_0x474644,_0xccf1('0xd8'));ut[_0xccf1('0x52')](_0xccf1('0xd9')+_0x474644[_0xccf1('0x33')],_0x853e78);}_0x474644[_0xccf1('0xd0')]+=0x1;_0x54625e['countglobal']=ut[_0xccf1('0x7b')](_0x54625e);ut[_0xccf1('0x61')](_0x54625e,0xc,_0x853e78['cause-txt']||_0x853e78[_0xccf1('0xd3')]);_0x4ee6f6=_0x474644[_0xccf1('0xc5')];_0x35e528=_0x474644[_0xccf1('0x84')];rpcDb[_0xccf1('0x67')](_0x54625e,_0xccf1('0xda'));_0x383d4e[_0xccf1('0x81')](_0x54625e,'20',_0x474644)[_0xccf1('0x57')](function(_0x3e35ed){_0x21cd51=_0x3e35ed[_0xccf1('0x82')]==0x1;if(!_0x21cd51){if(ut['totalGlobal'](_0x54625e)>=_0x474644['dialGlobalMaxRetry']){_0x519016=ut[_0xccf1('0x86')](_0x54625e,0xf,'Global');rpcDb[_0xccf1('0x69')](_0x519016,_0xccf1('0xdb'));}else{rpcDb[_0xccf1('0x69')](_0x54625e,_0xccf1('0xdb'));}delete this[_0xccf1('0x41')][_0x853e78[_0xccf1('0x8d')]];}else{_0x383d4e['swapAdditionalPhones'](_0x54625e,_0x4ee6f6,_0x35e528)[_0xccf1('0x57')](function(){});}});}if(!(_0x54625e['dialAnswer']&&_0x239960==='16')){ut[_0xccf1('0x4e')](_0x474644,_0xccf1('0xdc'));logger['info']('[originated][decrement][callProgressDetectingCustomer]',_0x54625e[_0xccf1('0x93')],'\x20Queue',_0x474644['name'],'originated:\x20',_0x474644[_0xccf1('0x2c')]);}if(_0x239960!=='ANSWER'){delete this[_0xccf1('0x41')][_0x853e78[_0xccf1('0x8d')]];delete this['actions'][_0x853e78['destlinkedid']];}_0x474644['queueSummaryCountersUpdated']=!![];}};Preview[_0xccf1('0xf')][_0xccf1('0xdd')]=function(_0x23f7cd,_0x13b78c,_0x103f82){if(_[_0xccf1('0xde')](_0x13b78c)&&_0xccf1('0xdf')!==typeof _0x13b78c){return;}if(_['isUndefined'](_0x103f82)&&_0xccf1('0xdf')!==typeof _0x103f82){return;}switch(_0x103f82[_0xccf1('0xe0')]){case'0':ut[_0xccf1('0xe1')](_0x23f7cd,0x0,'NoSuchNumber');rpcDb[_0xccf1('0xe2')](_0x23f7cd,_0xccf1('0xe3'));break;case'3':ut['logAgent'](_0x23f7cd,0x3,_0xccf1('0xe4'));rpcDb[_0xccf1('0xe2')](_0x23f7cd,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xccf1('0xe1')](_0x23f7cd,0x5,_0xccf1('0xa8'));rpcDb[_0xccf1('0xe2')](_0x23f7cd,_0xccf1('0xe5'));break;case'8':ut[_0xccf1('0xe1')](_0x23f7cd,0x8,_0xccf1('0xbb'));rpcDb[_0xccf1('0xe2')](_0x23f7cd,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0xccf1('0xe1')](_0x23f7cd,0x16,_0xccf1('0xe6'));rpcDb[_0xccf1('0xe2')](_0x23f7cd,_0xccf1('0xe7'));break;default:ut[_0xccf1('0xe1')](_0x23f7cd,0xc,_0x103f82[_0xccf1('0xe0')]);rpcDb[_0xccf1('0xe2')](_0x23f7cd,_0xccf1('0xe8'));}ut[_0xccf1('0x4e')](_0x13b78c,'[callProgressDetectingAgent]');logger[_0xccf1('0x26')](_0xccf1('0xe9'),_0x23f7cd[_0xccf1('0x93')],_0xccf1('0x94'),_0x13b78c[_0xccf1('0x33')],_0xccf1('0x43'),_0x13b78c[_0xccf1('0x2c')]);delete this[_0xccf1('0x41')][_0x23f7cd['uniqueid']];};Preview[_0xccf1('0xf')][_0xccf1('0x81')]=function(_0x230e98,_0x5e3654,_0x41587a){return cmHopperAdditionalPhone[_0xccf1('0x81')](_0x230e98,_0x5e3654,_0x41587a)['catch'](logger[_0xccf1('0x26')]('[verifyAdditionalPhone]\x20'));};Preview[_0xccf1('0xf')][_0xccf1('0x90')]=function(_0x39e723,_0x4a8ddf,_0x487364){return cmHopperAdditionalPhone[_0xccf1('0x90')](_0x39e723,_0x4a8ddf,_0x487364)[_0xccf1('0x5d')](logger[_0xccf1('0x26')](_0xccf1('0xea')));};Preview['prototype']['incrementPreviewCounters']=function(_0x3fefa8){return Promise['resolve']()[_0xccf1('0x57')](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x3fefa8))[_0xccf1('0x5d')](logger['info'](_0xccf1('0xeb')));};Preview[_0xccf1('0xf')][_0xccf1('0xec')]=function(_0x492db7,_0x3b3706,_0x855a9f,_0x51e9cf,_0x58f660){var _0x13f4b3=this;return new Promise(function(_0x2dad5c,_0x28fb5a){if(_['isNil'](_0x3b3706)||_['isNil'](_0x3b3706['Contact'])||_[_0xccf1('0x40')](_0x3b3706[_0xccf1('0xed')])||_[_0xccf1('0x40')](_0x3b3706['VoiceQueueId'])){_0x28fb5a(ut[_0xccf1('0x30')](_0xccf1('0xee'),_0x51e9cf,_0x58f660));return;}var _0x364463=uuid['v4']();var _0x3b4081=_0x13f4b3[_0xccf1('0x14')][_0x3b3706[_0xccf1('0xef')]['name']];var _0x2e36de=_0x855a9f?_0x13f4b3[_0xccf1('0x16')][_0x855a9f]['id']:undefined;_0x13f4b3[_0xccf1('0x41')][_0x364463]=new Action(_0x3b3706,_0x3b4081,_0x364463,_0x855a9f,_0x2e36de);var _0x891af2=_0x13f4b3[_0xccf1('0x41')][_0x364463];_0x891af2[_0xccf1('0x8b')]=_0x51e9cf;_0x891af2[_0xccf1('0x8c')]=_0x58f660;_0x891af2['lookAgent']=_0x855a9f;if(_[_0xccf1('0xf0')](_0x492db7)){_0x13f4b3['execCall'](_0x891af2,_0x3b4081,_0x3b3706,_0x855a9f)['then'](function(_0xfa22da){logger[_0xccf1('0x26')](_0xccf1('0xf1'),_0xccf1('0xf2')+_0x891af2[_0xccf1('0x44')]+_0xccf1('0xf3')+_0x891af2[_0xccf1('0x8f')],JSON[_0xccf1('0x28')](_0xfa22da));ami['emit'](_0xccf1('0xf4'),ut[_0xccf1('0x7e')](_0x891af2,_0xccf1('0xf5'),_0x13f4b3[_0xccf1('0x14')][_0x891af2[_0xccf1('0x44')]]));_0x2dad5c(ut[_0xccf1('0x30')](_0xccf1('0xf6')));})[_0xccf1('0x5d')](function(_0x4318c7){ut[_0xccf1('0x31')](_0xccf1('0xf7'),_0x4318c7);_0x28fb5a(ut['message'](_0xccf1('0xf8'),_0x51e9cf,_0x58f660));});}else{_0x3b4081[_0xccf1('0xf9')]+=0x1;ut['logBlacklist'](_0x891af2);rpcDb[_0xccf1('0xfa')](_0x891af2,_0xccf1('0xfb'));delete _0x13f4b3[_0xccf1('0x41')][_0x364463];_0x28fb5a(ut[_0xccf1('0x30')](_0xccf1('0xfc'),_0x51e9cf,_0x58f660));}});};Preview[_0xccf1('0xf')][_0xccf1('0x72')]=function(_0x1e19f1){return!_['isNil'](_0x1e19f1)&&!_[_0xccf1('0x40')](_0x1e19f1[_0xccf1('0x33')])&&!_['isNil'](_0x1e19f1[_0xccf1('0xfd')])&&_0x1e19f1[_0xccf1('0xfd')]&&!_[_0xccf1('0x40')](this[_0xccf1('0x15')][util[_0xccf1('0x29')]('SIP/%s',_0x1e19f1[_0xccf1('0x33')])])&&!_[_0xccf1('0x40')](this[_0xccf1('0x15')][util[_0xccf1('0x29')](_0xccf1('0xfe'),_0x1e19f1['name'])][_0xccf1('0x4c')])&&(this['trunks'][util['format'](_0xccf1('0xfe'),_0x1e19f1[_0xccf1('0x33')])][_0xccf1('0x4c')]===_0xccf1('0xff')||this['trunks'][util['format'](_0xccf1('0xfe'),_0x1e19f1[_0xccf1('0x33')])]['status']==='unmonitored');};Preview[_0xccf1('0xf')][_0xccf1('0x5c')]=function(_0x42c0a4,_0xb0313d){return this[_0xccf1('0x100')](_0x42c0a4,_0xb0313d)[_0xccf1('0x57')](function(_0x1cfbda){return _['pick'](_0x1cfbda,[_0xccf1('0x30')]);})[_0xccf1('0x5d')](function(_0x120f47){if(_0x120f47[_0xccf1('0x101')]){rpcDb[_0xccf1('0x102')](_0x42c0a4);}if(_0x120f47[_0xccf1('0xfd')]){rpcDb[_0xccf1('0x103')](_0x42c0a4);}throw _['pick'](_0x120f47,[_0xccf1('0x30')]);});};Preview[_0xccf1('0xf')][_0xccf1('0x100')]=function(_0x5259d7,_0x472657){var _0x2aea03=this;var _0x5d7ac3,_0x170937;return rpcDb[_0xccf1('0x104')](_0x5259d7)[_0xccf1('0x57')](function(_0x269f69){if(!_['isNil'](_0x269f69[0x0])){_0x170937=_0x269f69[0x0][_0xccf1('0x105')]?![]:!![];_0x5d7ac3=_0x269f69[0x0][_0xccf1('0x105')]?!![]:![];_0x5d7ac3=_0x472657?!![]:_0x5d7ac3;}var _0x55ac72=_0x2aea03[_0xccf1('0x106')](_0x269f69);if(_0x55ac72['isValid']){rpcDb['checkIsBlackList'](_['pick'](_0x269f69[0x0],[_0xccf1('0x49'),_0xccf1('0xed')]))[_0xccf1('0x57')](function(_0x40dd9c){_0x2aea03['checkInBlack'](_0x40dd9c,_0x269f69[0x0],_0x472657,_0x170937,_0x5d7ac3)[_0xccf1('0x57')](function(_0x3d591d){return _0x3d591d;})['catch'](function(_0x582a92){throw _0x582a92;});})[_0xccf1('0x5d')](function(_0x497859){ut['logger'](_0xccf1('0x107'),_0x497859);throw ut['message'](_0xccf1('0x108'),_0x170937,_0x5d7ac3);});}else{throw ut[_0xccf1('0x30')](_0x55ac72[_0xccf1('0x30')],_0x170937,_0x5d7ac3);}})[_0xccf1('0x5d')](function(_0x1edaff){ut[_0xccf1('0x31')](_0xccf1('0x109'),_0x1edaff);throw ut[_0xccf1('0x30')](_0xccf1('0x108'),![],!![]);});};Preview[_0xccf1('0xf')][_0xccf1('0x106')]=function(_0x3a3928){if(_[_0xccf1('0x40')](_0x3a3928)||_[_0xccf1('0xf0')](_0x3a3928)||!_[_0xccf1('0x40')](_0x3a3928[0x0][_0xccf1('0x5a')])&&_['isNil'](_0x3a3928[0x0]['Agent'][_0xccf1('0x33')])){ut[_0xccf1('0x31')](_0xccf1('0x10a'),_0x3a3928);return{'isValid':![],'message':'Empty\x20Contact'};}var _0x5d7cf4=this[_0xccf1('0x14')][_0x3a3928[0x0][_0xccf1('0xef')]['name']];_0x5d7cf4[_0xccf1('0x30')]=utils[_0xccf1('0x35')][_0xccf1('0x76')];if(_[_0xccf1('0x40')](_0x5d7cf4)){ut[_0xccf1('0x31')]('[Preview][validateContact][Empty\x20Campaign]',_0x5d7cf4);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this[_0xccf1('0x72')](_0x5d7cf4[_0xccf1('0x73')])){ut['logger'](_0xccf1('0x10b'),_0xccf1('0x10c')+_0x5d7cf4[_0xccf1('0x33')]+'\x20Trunk\x20is\x20not\x20active');if(!this[_0xccf1('0x72')](_0x5d7cf4[_0xccf1('0x74')])){ut['logger']('[Preview][validateContact][Trunk\x20not\x20working\x20correctly]',_0x5d7cf4[_0xccf1('0x33')]+_0xccf1('0x10d'));return{'isValid':![],'message':'Trunk\x20not\x20working\x20correctly'};}}if(!ut[_0xccf1('0x6f')](_0x5d7cf4[_0xccf1('0x70')])){ut[_0xccf1('0x31')](_0xccf1('0x10e'),_0x5d7cf4[_0xccf1('0x33')]+'\x20Not\x20Active');return{'isValid':![],'message':_0xccf1('0x10c')+_0x5d7cf4[_0xccf1('0x33')]+'\x20Not\x20Active'};}return{'isValid':!![],'message':_0xccf1('0x10f')};};Preview[_0xccf1('0xf')][_0xccf1('0x110')]=function(_0x59b141,_0xf7b8a7,_0x221560,_0x25a55e){var _0x5920bd=this;return new Promise(function(_0xcd3f70,_0xe108c4){var _0x254ad5=_0x59b141['uniqueid'];var _0x550824=_0x5920bd['isTrunkReachable'](_0xf7b8a7[_0xccf1('0x73')])?util[_0xccf1('0x29')](_0xccf1('0x111'),_0xf7b8a7[_0xccf1('0x73')][_0xccf1('0x33')],_['isNil'](_0xf7b8a7[_0xccf1('0x112')])?'':_0xf7b8a7[_0xccf1('0x112')]['trim']()||'',_0xf7b8a7['dialCutDigit']>0x0?_0x221560[_0xccf1('0xed')][_0xccf1('0x113')](_0xf7b8a7['dialCutDigit']):_0x221560['phone']):util[_0xccf1('0x29')](_0xccf1('0x111'),_[_0xccf1('0x40')](_0xf7b8a7[_0xccf1('0x74')])?_0xf7b8a7['Trunk'][_0xccf1('0x33')]:_0xf7b8a7[_0xccf1('0x74')][_0xccf1('0x33')],_[_0xccf1('0x40')](_0xf7b8a7[_0xccf1('0x112')])?'':_0xf7b8a7[_0xccf1('0x112')][_0xccf1('0x114')]()||'',_0xf7b8a7[_0xccf1('0x115')]>0x0?_0x221560[_0xccf1('0xed')][_0xccf1('0x113')](_0xf7b8a7[_0xccf1('0x115')]):_0x221560['phone']);var _0x530824=_0x5920bd['isTrunkReachable'](_0xf7b8a7[_0xccf1('0x73')])?ut[_0xccf1('0x116')](_0xf7b8a7['Trunk'][_0xccf1('0x117')],_0xf7b8a7[_0xccf1('0x118')],_0xf7b8a7[_0xccf1('0x119')]>0x0?ut[_0xccf1('0x11a')](_0xf7b8a7['dialOriginateCallerIdNumber'],_0xf7b8a7[_0xccf1('0x119')]):_0xf7b8a7[_0xccf1('0x11b')]):ut[_0xccf1('0x116')](_[_0xccf1('0x40')](_0xf7b8a7['TrunkBackup'])?_0xf7b8a7[_0xccf1('0x73')][_0xccf1('0x117')]:_0xf7b8a7[_0xccf1('0x74')]['callerid'],_0xf7b8a7[_0xccf1('0x118')],_0xf7b8a7[_0xccf1('0x119')]>0x0?ut[_0xccf1('0x11a')](_0xf7b8a7[_0xccf1('0x11b')],_0xf7b8a7[_0xccf1('0x119')]):_0xf7b8a7[_0xccf1('0x11b')]);if(_0x530824){_0x59b141[_0xccf1('0x11c')]=ut['extractCalleridName'](_0x530824);_0x59b141[_0xccf1('0x11d')]=ut['extractCalleridNumber'](_0x530824);}var _0x1670e6=ut['addVariables'](_0xf7b8a7,_0x221560,_0x550824,_0x530824,_0x254ad5,_0x59b141);var _0x3a44b2=utils[_0xccf1('0x11e')](_0x221560[_0xccf1('0x11f')]);Object['assign'](_0x1670e6,_0x3a44b2);_[_0xccf1('0x120')](_0x59b141,ut[_0xccf1('0x121')](_0x1670e6));_0x59b141['starttime']=moment()[_0xccf1('0x29')]('YYYY-MM-DD\x20HH:mm:ss');_0xf7b8a7[_0xccf1('0x122')]=_0x1670e6;var _0xea9e8=ut[_0xccf1('0x123')](_0x59b141,_0xf7b8a7,_0x1670e6,_0x59b141[_0xccf1('0x8c')],_0x25a55e);return ami[_0xccf1('0x4b')](_0xea9e8)['then'](function(_0x33cccc){_0xf7b8a7[_0xccf1('0x2c')]+=0x1;logger[_0xccf1('0x26')]('[originated][increment]',_0x254ad5,'\x20Queue',_0xf7b8a7['name'],_0xccf1('0x43'),_0xf7b8a7[_0xccf1('0x2c')]);_0xcd3f70(_0x33cccc);})['catch'](function(_0xb5c68e){ut[_0xccf1('0xe1')](_0x59b141,0xe,_0xccf1('0x124'));rpcDb['createAgentHistory'](_0x59b141,'[originateFailure][logOriginateFailure]');_0xe108c4(_0xb5c68e);});});};Preview[_0xccf1('0xf')][_0xccf1('0x1f')]=function(_0x4b29ff){if(this[_0xccf1('0x41')][_0x4b29ff[_0xccf1('0x8d')]]){this[_0xccf1('0x41')][_0x4b29ff['linkedid']][_0xccf1('0x4d')]=_0x4b29ff[_0xccf1('0x4d')];}};Preview[_0xccf1('0xf')]['syncOriginateResponse']=function(_0xa264a9){var _0x7c16d7=this;var _0x3fd914=this[_0xccf1('0x41')][_0xa264a9[_0xccf1('0x125')]];if(_0x3fd914){if(_0x3fd914['lookAgent']&&this[_0xccf1('0x16')][_0x3fd914[_0xccf1('0x126')]]){ut[_0xccf1('0x127')](_0x3fd914,this[_0xccf1('0x16')][_0x3fd914[_0xccf1('0x126')]][_0xccf1('0x33')],this[_0xccf1('0x16')][_0x3fd914['lookAgent']]['id']);}var _0x159702=_[_0xccf1('0x128')](_0x3fd914);_0x159702[_0xccf1('0x129')]=moment()[_0xccf1('0x29')](_0xccf1('0x5f'));var _0x2e462a=_0x7c16d7[_0xccf1('0x14')][_0x3fd914['queue']];if(ut['isFailure'](_0xa264a9['response'])){if(_0x3fd914[_0xccf1('0x8b')]){rpcDb[_0xccf1('0x102')](_0x3fd914[_0xccf1('0x8f')]);}if(_0x3fd914['activeContact']){rpcDb[_0xccf1('0x103')](_0x3fd914[_0xccf1('0x8f')]);}ami[_0xccf1('0x25')]('custom:agentringnoanswer',ut[_0xccf1('0x7e')](_0x3fd914,_0xccf1('0x12a'),this[_0xccf1('0x14')][_0x3fd914[_0xccf1('0x44')]]));this['callProgressDetectingAgent'](_0x159702,_0x2e462a,_0xa264a9);}else{_0x3fd914['starttime']=moment()[_0xccf1('0x29')](_0xccf1('0x5f'));ut[_0xccf1('0xe1')](_0x159702,0x4,_0xccf1('0x9f'));rpcDb[_0xccf1('0xe2')](_0x159702,_0xccf1('0x12b'));}}};Preview[_0xccf1('0xf')][_0xccf1('0x1a')]=function(_0x3d74e2){var _0xa74426=this[_0xccf1('0x41')][_0x3d74e2[_0xccf1('0x8d')]];var _0x1bc9ea;if(_0xa74426){_0x1bc9ea=this[_0xccf1('0x14')][_0xa74426[_0xccf1('0x44')]];logger[_0xccf1('0x26')]('[syncHangup][talking]',_0x3d74e2['linkedid'],_0xccf1('0x94'),_0x1bc9ea[_0xccf1('0x33')],_0xccf1('0x12c'),_0x1bc9ea['pTalking']);}if(this[_0xccf1('0x41')][_0x3d74e2[_0xccf1('0x8d')]]&&_0x3d74e2[_0xccf1('0x8d')]!==_0x3d74e2[_0xccf1('0x93')]){if(_0x3d74e2[_0xccf1('0x12d')]==='16'&&this[_0xccf1('0x41')][_0x3d74e2[_0xccf1('0x8d')]][_0xccf1('0x45')]){this[_0xccf1('0x77')](_0x3d74e2,_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2[_0xccf1('0x12d')]);}else if(this[_0xccf1('0x41')][_0x3d74e2['linkedid']][_0xccf1('0x45')]){logger[_0xccf1('0x26')]('[syncHangup][talking][cause]',_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2[_0xccf1('0x12d')],_0xccf1('0x94'),_0x1bc9ea['name'],'pTalking:\x20',_0x1bc9ea[_0xccf1('0x2d')]);this[_0xccf1('0x77')](_0x3d74e2,_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2[_0xccf1('0x12d')]);}}else if(_0xa74426&&_[_0xccf1('0x40')](_0xa74426[_0xccf1('0x12e')])&&_0x1bc9ea[_0xccf1('0x12f')]&&_0x3d74e2[_0xccf1('0x8d')]===_0x3d74e2[_0xccf1('0x93')]&&_[_0xccf1('0x40')](_0x3d74e2[_0xccf1('0xe0')])&&_0x3d74e2['cause']==='16'&&_0x3d74e2[_0xccf1('0x130')]==='6'&&_['isUndefined'](_0xa74426[_0xccf1('0x131')])){if(_0xa74426[_0xccf1('0x8b')]){rpcDb[_0xccf1('0x102')](_0xa74426[_0xccf1('0x8f')]);}if(_0xa74426[_0xccf1('0x8c')]){rpcDb[_0xccf1('0x103')](_0xa74426['idContact']);}_0x3d74e2[_0xccf1('0xe0')]='22';this[_0xccf1('0xdd')](_0xa74426,_0x1bc9ea,_0x3d74e2);}else if(_0xa74426&&_0xa74426['transfer']){if(_0x3d74e2[_0xccf1('0x12d')]==='16'&&this[_0xccf1('0x41')][_0x3d74e2[_0xccf1('0x8d')]][_0xccf1('0x45')]){logger['info'](_0xccf1('0x132'),_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2[_0xccf1('0x12d')],_0xccf1('0x94'),_0x1bc9ea[_0xccf1('0x33')],_0xccf1('0x12c'),_0x1bc9ea['pTalking']);this[_0xccf1('0x77')](_0x3d74e2,_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2['cause']);}else if(this['actions'][_0x3d74e2[_0xccf1('0x8d')]]['dialAnswer']){logger[_0xccf1('0x26')](_0xccf1('0x133'),_0x3d74e2['linkedid'],_0x3d74e2[_0xccf1('0x12d')],_0xccf1('0x94'),_0x1bc9ea[_0xccf1('0x33')],_0xccf1('0x12c'),_0x1bc9ea[_0xccf1('0x2d')]);this[_0xccf1('0x77')](_0x3d74e2,_0x3d74e2[_0xccf1('0x8d')],_0x3d74e2['cause']);}}};Preview['prototype'][_0xccf1('0x1e')]=function(_0x339c83){if(this[_0xccf1('0x41')][_0x339c83[_0xccf1('0x134')]]&&_0x339c83[_0xccf1('0x134')]!==_0x339c83['destuniqueid']){this[_0xccf1('0x77')](_0x339c83,_0x339c83['destlinkedid'],_0x339c83[_0xccf1('0xd3')]);}};Preview[_0xccf1('0xf')][_0xccf1('0x1d')]=function(_0x256de6){if(this[_0xccf1('0x41')][_0x256de6[_0xccf1('0x8d')]]&&_0x256de6[_0xccf1('0x8d')]!==_0x256de6[_0xccf1('0x93')]&&!this[_0xccf1('0x41')][_0x256de6[_0xccf1('0x8d')]][_0xccf1('0x45')]){if(_0x256de6['cause']==='1'){this[_0xccf1('0x77')](_0x256de6,_0x256de6['linkedid'],_0x256de6[_0xccf1('0x12d')]);}}};Preview[_0xccf1('0xf')][_0xccf1('0x135')]=function(_0x2f7a46,_0x228de1,_0x4a1684){if(this['actions'][_0x2f7a46]){if(_[_0xccf1('0x40')](this[_0xccf1('0x41')][_0x2f7a46]['variables'])){this[_0xccf1('0x41')][_0x2f7a46][_0xccf1('0x122')]={};}this[_0xccf1('0x41')][_0x2f7a46][_0xccf1('0x122')][_0x228de1]=_0x4a1684;}};Preview[_0xccf1('0xf')]['syncVarSet']=function(_0x3cde0f){try{if(!_[_0xccf1('0x40')](_0x3cde0f)){if(ut['filterKey'](_[_0xccf1('0x136')](_0x3cde0f[_0xccf1('0x137')])[0x0])){this[_0xccf1('0x135')](_0x3cde0f[_0xccf1('0x93')],_[_0xccf1('0x136')](_0x3cde0f[_0xccf1('0x137')])[0x0],_0x3cde0f[_0xccf1('0x138')]);}}}catch(_0x349d6a){logger[_0xccf1('0x139')]('[syncVarSet][Preview]',util[_0xccf1('0x13a')](_0x349d6a,{'showHidden':![],'depth':null}));}};Preview[_0xccf1('0xf')][_0xccf1('0x21')]=function(_0x49eae4){if(_0x49eae4){if(this['actions'][_0x49eae4[_0xccf1('0x13b')]]){this['actions'][_0x49eae4[_0xccf1('0x13b')]][_0xccf1('0x131')]=!![];}}};Preview['prototype']['syncBlindTransfer']=function(_0x56e173){if(_0x56e173){if(this[_0xccf1('0x41')][_0x56e173[_0xccf1('0x13c')]]){this['actions'][_0x56e173[_0xccf1('0x13c')]][_0xccf1('0x131')]=!![];}}};module['exports']=Preview;