07a1ddc7931163a4f3ee44f2be79cdfea0ad0c90
[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 _0xa70a=['sumBillable','[syncHangup][talking][decrement]','linkedid','BUSY','outboundBusyCallsDay','dialBusyRetryFrequency','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','verifyAdditionalPhones','countbusyretry','dialBusyMaxRetry','scheduledAt','incrementPreviewCounters','outboundNoAnswerCallsDay','dialNoAnswerRetryFrequency','custom:agentnoanswer','[callProgressDetectingCustomer][logNoAnswer]','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','countnoanswerretry','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','congestion','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','ABANDONED','outboundAbandonedCallsDay','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','outboundUnknownCallsDay','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalking][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','callProgressDetectingAgent','isUndefined','object','reason','logAgent','NoSuchNumber','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','NoAnswer','[callProgressDetectingAgent][logNoAnswer]','Busy','[callProgressDetectingAgent][logBusy]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent][logCongestion]','decrementOriginate','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','\x20Queue','originated:\x20','[incrementPreviewCounters]\x20','checkInBlack','Contact','phone','isEmpty','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','logBlacklist','active','SIP/%s','execRun','unlock','unlockContact','getContactPreview','recallme','validateContact','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','execCall','SIP/%s/%s%s','dialPrefix','trim','substring','dialCutDigit','getCallerId','callerid','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','addVariables','assign','merge','toLowerVariables','starttime','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','syncOriginateResponse','actionid','lookAgent','logLookAgent','clone','response','custom:agentringnoanswer','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','callProgressDetectingCustomer','statedesc','dialQueueProject','transfer','[syncHangup][talking][transfer]','[syncHangup][talking][cause]','syncHangupRequest','addVariable','variables','filterKey','keys','variable','value','error','[syncVarSet][Preview]','inspect','syncAttendedTransfer','transfertargetlinkedid','syncBlindTransfer','transfererlinkedid','exports','util','uuid','ioredis','../../../config/logger','actionPreview','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','redis','localhost','socket.io-emitter','enqueue','tail','sequence','campaignsPreview','voiceQueues','trunks','agents','clockClearZombieChannels','originateresponse','bind','hangup','syncHangup','hanguprequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','blindtransfer','loopCampaigns','emit','stringify','format','voice:queue:%s','name','voice_queue_channel:remove','voice_queue_presence:remove','sendMessageOneNotActive','originated','available','paused','CAMPAIGN_STATUS','INACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','DEACTIVATED','prototype','syncCampaigns','preview','dialMethod','booked','type','outbound','clearZombieChannels','hasOwnProperty','dialActive','dialPreviewAutoRecallMe','clearZombieChannel','isNil','actions','[clearZombieChannels][talking]','Queue','queue','pTalking:\x20','pTalking','dialAnswer','pick','contactId','UserId','VoiceQueueId','ListId','status','channel','message','No\x20such\x20channel','[clearZombieChannel]','decrementTalking','loggerError','[Dialer][checkChannel][Preview]','info','[action]','size','getContactRecallMe','agentReadyId','then','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','catch','disableContact','YYYY-MM-DD\x20HH:mm:ss','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','createCustomerFinal','[HistoryRecallClose]','[getContactRecallMe]','setMessage','IsNotLoggedIn','loggedIn','NO_AGENTS_LOGGED','isActive','isTrunkReachable','Trunk','TrunkBackup','ACTIVE','outboundNoSuchCallsDay','countnosuchnumberretry','totalGlobal','custom:agentnosuchnumber','buildObj','nosuchnumber','additional','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact','unlockAgent','activeContact','idContact','swapAdditionalPhones','ANSWER','responsetime','answertime','[syncHangup][talking][increment]','uniqueid','custom:agentconnect','connect','mandatoryDisposition','custom:agentConnectPreview','channelAgent','complete','total','answered','countglobal','Answer','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','sumDuration','talktime'];(function(_0x354cd1,_0x297ac1){var _0x4ccd02=function(_0x431fd0){while(--_0x431fd0){_0x354cd1['push'](_0x354cd1['shift']());}};_0x4ccd02(++_0x297ac1);}(_0xa70a,0xaa));var _0xaa70=function(_0xa76870,_0x3b3c93){_0xa76870=_0xa76870-0x0;var _0x4caa58=_0xa70a[_0xa76870];return _0x4caa58;};'use strict';var util=require(_0xaa70('0x0'));var _=require('lodash');var uuid=require(_0xaa70('0x1'));var moment=require('moment');var Redis=require(_0xaa70('0x2'));var config=require('../../../config/environment');var logger=require(_0xaa70('0x3'))('preview');var loggerAction=require(_0xaa70('0x3'))(_0xaa70('0x4'));var ami=require('../ami');var rpcDb=require(_0xaa70('0x5'));var cmHopperAdditionalPhone=require(_0xaa70('0x6'));var Action=require(_0xaa70('0x7'));var ut=require(_0xaa70('0x8'));var utils=require('../dialer/utils');config[_0xaa70('0x9')]=_['defaults'](config[_0xaa70('0x9')],{'host':_0xaa70('0xa'),'port':0x18eb});var io=require(_0xaa70('0xb'))(new Redis(config[_0xaa70('0x9')]));var Sequence=function(){};Sequence['prototype'][_0xaa70('0xc')]=function(_0x2379fd){this[_0xaa70('0xd')]=this[_0xaa70('0xd')]?this[_0xaa70('0xd')]['finally'](_0x2379fd):_0x2379fd();};function Preview(_0x17048f){this[_0xaa70('0xe')]=new Sequence();this[_0xaa70('0xf')]=_0x17048f[_0xaa70('0x10')];this[_0xaa70('0x11')]=_0x17048f[_0xaa70('0x11')];this['actions']={};this[_0xaa70('0x12')]=_0x17048f[_0xaa70('0x12')];this[_0xaa70('0x13')]=0x0;ami['on'](_0xaa70('0x14'),this['syncOriginateResponse'][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x16'),this[_0xaa70('0x17')][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x18'),this['syncHangupRequest'][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x19'),this[_0xaa70('0x1a')][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x1b'),this[_0xaa70('0x1c')][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x1d'),this[_0xaa70('0x1e')]['bind'](this));ami['on'](_0xaa70('0x1f'),this['syncAttendedTransfer'][_0xaa70('0x15')](this));ami['on'](_0xaa70('0x20'),this['syncBlindTransfer']['bind'](this));this[_0xaa70('0x21')](this['campaignsPreview']);}function emit(_0x3915c6,_0x46f948,_0x59c209){io['to'](_0x3915c6)[_0xaa70('0x22')](_0x46f948,_0x59c209);}function emitVoiceQueueChannelRemove(_0x126b14){logger['info']('[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event',JSON[_0xaa70('0x23')](_0x126b14));emit(util[_0xaa70('0x24')](_0xaa70('0x25'),_0x126b14[_0xaa70('0x26')]),_0xaa70('0x27'),_0x126b14);io[_0xaa70('0x22')](_0xaa70('0x28'),_0x126b14);}function notSendMessagesQueue(_0x36f819){if(_0x36f819[_0xaa70('0x29')]){if(_0x36f819[_0xaa70('0x2a')]===0x0&&_0x36f819['pTalking']===0x0){_0x36f819['sendMessageOneNotActive']=![];_0x36f819[_0xaa70('0x2b')]=0x0;_0x36f819[_0xaa70('0x2c')]=0x0;_0x36f819['message']=utils[_0xaa70('0x2d')][_0xaa70('0x2e')];ut[_0xaa70('0x2f')](_0xaa70('0x30'),_0x36f819[_0xaa70('0x26')]+'\x20is\x20not\x20active');}else{_0x36f819['message']=utils[_0xaa70('0x2d')][_0xaa70('0x31')];ut[_0xaa70('0x2f')](_0xaa70('0x30'),_0x36f819['name']+'\x20is\x20deactivated');}}}Preview[_0xaa70('0x32')][_0xaa70('0x21')]=function(){var _0x15a373=this;setInterval(function(){_0x15a373[_0xaa70('0x33')]();},0x7cf);};Preview[_0xaa70('0x32')][_0xaa70('0x33')]=function(){var _0x2aa9d7=this[_0xaa70('0xf')];this['clockClearZombieChannels']+=0x1;for(var _0x4d3544 in _0x2aa9d7){if(_0x2aa9d7['hasOwnProperty'](_0x4d3544)&&(_0x2aa9d7[_0x4d3544]['dialMethod']===_0xaa70('0x34')||_0x2aa9d7[_0x4d3544][_0xaa70('0x35')]===_0xaa70('0x36'))&&_0x2aa9d7[_0x4d3544][_0xaa70('0x37')]===_0xaa70('0x38')){if(this[_0xaa70('0x13')]>0x7){this['clockClearZombieChannels']=0x0;this[_0xaa70('0x39')]();}}if(_0x2aa9d7[_0xaa70('0x3a')](_0x4d3544)&&_0x2aa9d7[_0x4d3544]['dialMethod']===_0xaa70('0x34')&&_0x2aa9d7[_0x4d3544][_0xaa70('0x37')]===_0xaa70('0x38')){if(_0x2aa9d7[_0x4d3544][_0xaa70('0x3b')]){this['setMessage'](_0x2aa9d7[_0x4d3544]);if(_0x2aa9d7[_0x4d3544][_0xaa70('0x3c')])this['recallMe'](_0x2aa9d7[_0x4d3544]);}else{notSendMessagesQueue(_0x2aa9d7[_0x4d3544]);}}}};Preview[_0xaa70('0x32')][_0xaa70('0x3d')]=function(_0x2b3fc5){var _0xe24fe3=this;this['sequence'][_0xaa70('0xc')](function(){if(!_[_0xaa70('0x3e')](_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5])){loggerAction['info'](_0xaa70('0x40'),_0x2b3fc5,_0xaa70('0x41'),_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x42')],'originated:\x20',JSON[_0xaa70('0x23')](_0xe24fe3[_0xaa70('0xf')][_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x42')]][_0xaa70('0x2a')]),_0xaa70('0x43'),JSON[_0xaa70('0x23')](_0xe24fe3[_0xaa70('0xf')][_0xe24fe3['actions'][_0x2b3fc5][_0xaa70('0x42')]][_0xaa70('0x44')]),JSON[_0xaa70('0x23')](_0xe24fe3['actions'][_0x2b3fc5][_0xaa70('0x45')]),JSON[_0xaa70('0x23')](_[_0xaa70('0x46')](_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5],[_0xaa70('0x47'),_0xaa70('0x48'),_0xaa70('0x49'),_0xaa70('0x4a')])));return ami['Action']({'action':_0xaa70('0x4b'),'channel':_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x4c')]})['catch'](function(_0x43fbb0){if(_0x43fbb0[_0xaa70('0x4d')]===_0xaa70('0x4e')){setTimeout(function(){if(_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5]){utils['decrementOriginate'](_0xe24fe3[_0xaa70('0xf')][_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x42')]],_0xaa70('0x4f'));if(_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x45')]===!![]){ut[_0xaa70('0x50')](_0xe24fe3['campaignsPreview'][_0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5][_0xaa70('0x42')]],_0xaa70('0x4f'));ut['loggerError']('[Dialer][checkChannel][pTalking][Preview]'+_0x2b3fc5,_0xe24fe3['actions'][_0x2b3fc5][_0xaa70('0x42')]);}ut[_0xaa70('0x51')](_0xaa70('0x52')+_0x2b3fc5,_0xe24fe3['actions'][_0x2b3fc5][_0xaa70('0x42')]);delete _0xe24fe3[_0xaa70('0x3f')][_0x2b3fc5];}},0x2328);}});}});};Preview['prototype'][_0xaa70('0x39')]=function(){var _0x37081e=this;loggerAction[_0xaa70('0x53')](_0xaa70('0x54'),_[_0xaa70('0x55')](this['actions']));for(var _0x3eaad2 in this['actions']){if(_0x37081e[_0xaa70('0x3f')][_0xaa70('0x3a')](_0x3eaad2)){_0x37081e['clearZombieChannel'](_0x3eaad2);}}};Preview[_0xaa70('0x32')]['recallMe']=function(_0x24092d){var _0x13d68a=this;rpcDb[_0xaa70('0x56')](_0x24092d['id'],ut[_0xaa70('0x57')](this[_0xaa70('0x12')]))[_0xaa70('0x58')](function(_0x195d00){if(!_[_0xaa70('0x3e')](_0x195d00)){for(var _0x47982c=0x0;_0x47982c<_0x195d00[_0xaa70('0x59')];_0x47982c+=0x1){if(ut[_0xaa70('0x5a')](_0x195d00[_0x47982c][_0xaa70('0x5b')])<_0x24092d[_0xaa70('0x5c')]*0x3c){if(_0x195d00[_0x47982c][_0xaa70('0x5d')]&&!_0x195d00[_0x47982c][_0xaa70('0x5d')][_0xaa70('0x5e')]){_0x13d68a[_0xaa70('0x5f')](_0x195d00[_0x47982c]['id'])[_0xaa70('0x58')](ut[_0xaa70('0x60')](_0xaa70('0x61')))[_0xaa70('0x62')](ut[_0xaa70('0x60')](_0xaa70('0x61')));}else{rpcDb[_0xaa70('0x63')](_0x195d00[_0x47982c]['id']);}}else{var _0x5cb857=new Action(_0x195d00[_0x47982c],_0x24092d);_0x5cb857['starttime']=moment()['format'](_0xaa70('0x64'));_0x24092d['outboundReCallsDay']+=0x1;ut[_0xaa70('0x65')](_0x5cb857,0x17,_0xaa70('0x66'));if(_0x24092d[_0xaa70('0x67')]){rpcDb[_0xaa70('0x68')](ut[_0xaa70('0x69')](_0x195d00[_0x47982c]));rpcDb[_0xaa70('0x6a')](_0x5cb857,_0xaa70('0x6b'));}else{ut['logCustomer'](_0x5cb857,0x16,_0xaa70('0x6c'));rpcDb['createCustomerHistory'](_0x5cb857,'[HistoryRecallClose]');rpcDb[_0xaa70('0x6d')](_0x5cb857,_0xaa70('0x6e'));}}}}})['catch'](ut['logger2'](_0xaa70('0x6f')));};Preview[_0xaa70('0x32')][_0xaa70('0x70')]=function(_0x248020){_0x248020[_0xaa70('0x29')]=!![];if(ut[_0xaa70('0x71')](_0x248020[_0xaa70('0x72')])){_0x248020[_0xaa70('0x4d')]=utils[_0xaa70('0x2d')][_0xaa70('0x73')];}else if(!ut[_0xaa70('0x74')](_0x248020[_0xaa70('0x3b')])){_0x248020[_0xaa70('0x4d')]=utils[_0xaa70('0x2d')][_0xaa70('0x2e')];}else if(!this[_0xaa70('0x75')](_0x248020[_0xaa70('0x76')])){if(!this['isTrunkReachable'](_0x248020[_0xaa70('0x77')])){_0x248020[_0xaa70('0x4d')]=utils['CAMPAIGN_STATUS']['UNREACHABLE_TRUNK'];}else{_0x248020[_0xaa70('0x4d')]=utils[_0xaa70('0x2d')][_0xaa70('0x78')];}}else{_0x248020[_0xaa70('0x4d')]=utils[_0xaa70('0x2d')]['ACTIVE'];}};Preview[_0xaa70('0x32')]['callProgressDetectingCustomer']=function(_0x58c48e,_0x812213,_0x230939){var _0x5ed060=this;var _0x25b54d=this[_0xaa70('0x3f')][_0x812213];var _0x347937=this[_0xaa70('0xf')][_0x25b54d[_0xaa70('0x42')]];var _0x3d73b0;var _0x583740=![];var _0x29209c=0x2;var _0x9b428d=0x3;if(_0x347937){switch(_0x230939){case'1':_0x347937[_0xaa70('0x79')]+=0x1;_0x25b54d[_0xaa70('0x7a')]+=0x1;_0x25b54d['countglobal']=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x0,'NoSuchNumber');ami['emit'](_0xaa70('0x7c'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0x7e')));rpcDb['createCustomerHistory'](_0x25b54d,'[callProgressDetectingCustomer][logNoSuch]');_0x5ed060['verifyAdditionalPhones'](_0x25b54d,'0',_0x347937)[_0xaa70('0x58')](function(_0x3eb3c3){_0x583740=_0x3eb3c3[_0xaa70('0x7f')]==0x1;_0x29209c=_0x347937[_0xaa70('0x80')];_0x9b428d=_0x347937[_0xaa70('0x81')];if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,_0xaa70('0x84'));rpcDb['createCustomerFinal'](_0x3d73b0,_0xaa70('0x85'));}else{if(_0x25b54d[_0xaa70('0x7a')]>=_0x347937[_0xaa70('0x86')]){rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0x85'));}else{rpcDb[_0xaa70('0x87')](ut['scheduledAt'](_0x25b54d,_0xaa70('0x7a'),_0x347937[_0xaa70('0x80')]),_0x25b54d[_0xaa70('0x88')],_0x25b54d[_0xaa70('0x89')]);}}delete this[_0xaa70('0x3f')][_0x58c48e['linkedid']];}else{_0x25b54d[_0xaa70('0x7a')]++;logger[_0xaa70('0x53')]('actioncountonusuch',_0x25b54d[_0xaa70('0x7a')]);logger[_0xaa70('0x53')]('id',_0x25b54d[_0xaa70('0x8a')]);_0x5ed060['incrementPreviewCounters']({'id':_0x25b54d[_0xaa70('0x8a')],'field':{'countnosuchnumberretry':_0x25b54d[_0xaa70('0x7a')]}})[_0xaa70('0x58')](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case _0xaa70('0x8c'):var _0x28fb8e=moment()[_0xaa70('0x24')](_0xaa70('0x64'));_0x25b54d[_0xaa70('0x8d')]=_0x28fb8e;_0x25b54d[_0xaa70('0x8e')]=_0x28fb8e;_0x25b54d['dialAnswer']=!![];_0x347937[_0xaa70('0x44')]+=0x1;logger[_0xaa70('0x53')](_0xaa70('0x8f'),_0x25b54d[_0xaa70('0x90')],'\x20Queue',_0x347937[_0xaa70('0x26')],'pTalking:\x20',_0x347937[_0xaa70('0x44')]);ami[_0xaa70('0x22')](_0xaa70('0x91'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0x92'),this[_0xaa70('0xf')][_0x25b54d[_0xaa70('0x42')]]));if(_0x347937['acw']||_0x347937[_0xaa70('0x93')]){ami['emit'](_0xaa70('0x94'),{'queue':_0x25b54d['queue'],'interface':_0x25b54d[_0xaa70('0x95')],'uniqueid':_0x25b54d[_0xaa70('0x90')]});}break;case'16':ami[_0xaa70('0x22')]('custom:agentcomplete',ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0x96'),this[_0xaa70('0xf')][_0x25b54d[_0xaa70('0x42')]]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x25b54d,_0xaa70('0x96')));_0x347937['outboundAnswerCallsDay']+=0x1;_0x347937[_0xaa70('0x97')]+=0x1;_0x347937[_0xaa70('0x98')]+=0x1;ut['decrementTalking'](_0x347937,'[16]');_0x25b54d[_0xaa70('0x99')]=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x4,_0xaa70('0x9a'));rpcDb[_0xaa70('0x6a')](_0x25b54d,'[callProgressDetectingCustomer][logAnswer]');rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0x9b'));rpcDb[_0xaa70('0x9c')](_0x25b54d);_0x347937[_0xaa70('0x9d')]+=_0x25b54d[_0xaa70('0x9e')];_0x347937[_0xaa70('0x9f')]+=_0x25b54d[_0xaa70('0x9e')];logger[_0xaa70('0x53')](_0xaa70('0xa0'),_0x25b54d[_0xaa70('0x90')],'\x20Queue',_0x347937[_0xaa70('0x26')],_0xaa70('0x43'),_0x347937[_0xaa70('0x44')]);delete this['actions'][_0x58c48e[_0xaa70('0xa1')]];break;case _0xaa70('0xa2'):_0x347937[_0xaa70('0xa3')]+=0x1;_0x25b54d['countbusyretry']+=0x1;_0x25b54d[_0xaa70('0x99')]=ut['totalGlobal'](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x5,'Busy');_0x29209c=_0x347937[_0xaa70('0xa4')];_0x9b428d=_0x347937[_0xaa70('0x81')];ami[_0xaa70('0x22')](_0xaa70('0xa5'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0xa6')));rpcDb[_0xaa70('0x6a')](_0x25b54d,_0xaa70('0xa7'));_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'5',_0x347937)[_0xaa70('0x58')](function(_0x34f2d4){_0x583740=_0x34f2d4['additional']==0x1;if(!_0x583740){if(ut['totalGlobal'](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,_0xaa70('0x84'));rpcDb['createCustomerFinal'](_0x3d73b0,'[callProgressDetectingCustomer][logBusyGlobal]');}else{if(_0x25b54d[_0xaa70('0xa9')]>=_0x347937[_0xaa70('0xaa')]){rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xa7'));}else{rpcDb[_0xaa70('0x87')](ut[_0xaa70('0xab')](_0x25b54d,_0xaa70('0xa9'),_0x347937[_0xaa70('0xa4')]),_0x25b54d[_0xaa70('0x88')],_0x25b54d[_0xaa70('0x89')]);}}}else{_0x25b54d[_0xaa70('0xa9')]++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d[_0xaa70('0x8a')],'field':{'countbusyretry':_0x25b54d[_0xaa70('0xa9')]}})[_0xaa70('0x58')](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case'NOANSWER':_0x347937[_0xaa70('0xad')]+=0x1;_0x25b54d['countnoanswerretry']+=0x1;_0x25b54d[_0xaa70('0x99')]=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x3,'NoAnswer');_0x29209c=_0x347937[_0xaa70('0xae')];_0x9b428d=_0x347937[_0xaa70('0x81')];var _0x39fe44=ut['buildNoAnswerEventPayload'](_0x25b54d,_0x347937);ami['emit'](_0xaa70('0xaf'),_0x39fe44);rpcDb['createCustomerHistory'](_0x25b54d,_0xaa70('0xb0'));_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'3',_0x347937)['then'](function(_0x4f0758){_0x583740=_0x4f0758[_0xaa70('0x7f')]==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,'Global');rpcDb[_0xaa70('0x6d')](_0x3d73b0,_0xaa70('0xb1'));}else{if(_0x25b54d['countnoanswerretry']>=_0x347937[_0xaa70('0xb2')]){rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xb0'));}else{rpcDb['rescheduleContact'](ut[_0xaa70('0xab')](_0x25b54d,_0xaa70('0xb3'),_0x347937[_0xaa70('0xae')]),_0x25b54d[_0xaa70('0x88')],_0x25b54d[_0xaa70('0x89')]);}}}else{_0x25b54d[_0xaa70('0xb3')]++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d[_0xaa70('0x8a')],'field':{'countnoanswerretry':_0x25b54d[_0xaa70('0xb3')]}})['then'](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case _0xaa70('0xb4'):_0x347937[_0xaa70('0xb5')]+=0x1;_0x25b54d[_0xaa70('0xb6')]+=0x1;_0x25b54d[_0xaa70('0x99')]=ut['totalGlobal'](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x8,_0xaa70('0xb7'));_0x29209c=_0x347937[_0xaa70('0xb8')];_0x9b428d=_0x347937[_0xaa70('0x81')];ami[_0xaa70('0x22')](_0xaa70('0xb9'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0xba')));rpcDb['createCustomerHistory'](_0x25b54d,'[callProgressDetectingCustomer][logCongestion]');_0x5ed060['verifyAdditionalPhones'](_0x25b54d,'8',_0x347937)[_0xaa70('0x58')](function(_0x3db512){_0x583740=_0x3db512[_0xaa70('0x7f')]==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937['dialGlobalMaxRetry']){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,'Global');rpcDb['createCustomerFinal'](_0x3d73b0,'[callProgressDetectingCustomer][logCongestionGlobal]');}else{if(_0x25b54d[_0xaa70('0xb6')]>=_0x347937[_0xaa70('0xbb')]){rpcDb['createCustomerFinal'](_0x25b54d,_0xaa70('0xbc'));}else{rpcDb[_0xaa70('0x87')](ut[_0xaa70('0xab')](_0x25b54d,_0xaa70('0xb6'),_0x347937[_0xaa70('0xa4')]),_0x25b54d['unlockAgent'],_0x25b54d[_0xaa70('0x89')]);}}}else{_0x25b54d[_0xaa70('0xb6')]++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d['idContact'],'field':{'countcongestionretry':_0x25b54d[_0xaa70('0xb6')]}})[_0xaa70('0x58')](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case _0xaa70('0xbd'):_0x347937['outboundRejectCallsDay']+=0x1;_0x25b54d[_0xaa70('0xbe')]+=0x1;_0x25b54d['countglobal']=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x14,_0xaa70('0xbf'));_0x29209c=_0x347937[_0xaa70('0xc0')];_0x9b428d=_0x347937['callAdditionalPhoneAfterMin'];ami[_0xaa70('0x22')](_0xaa70('0xc1'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0xc2')));rpcDb[_0xaa70('0x6a')](_0x25b54d,'[syncHangupRequest][logAgentReject]');_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'20',_0x347937)[_0xaa70('0x58')](function(_0x6be523){_0x583740=_0x6be523[_0xaa70('0x7f')]==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut['cloneAction'](_0x25b54d,0x14,_0xaa70('0xbf'));rpcDb[_0xaa70('0x6d')](_0x3d73b0,_0xaa70('0xc3'));}else{if(_0x25b54d[_0xaa70('0xbe')]>=_0x347937[_0xaa70('0xc4')]){rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xc3'));}else{rpcDb[_0xaa70('0x87')](ut['scheduledAt'](_0x25b54d,_0xaa70('0xbe'),_0x347937['dialAgentRejectRetryFrequency']),_0x25b54d[_0xaa70('0x88')],_0x25b54d['activeContact']);}}}else{_0x25b54d[_0xaa70('0xb3')]++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d['idContact'],'field':{'countnoanswerretry':_0x25b54d[_0xaa70('0xb3')]}})[_0xaa70('0x58')](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case _0xaa70('0xc5'):_0x347937[_0xaa70('0xc6')]+=0x1;_0x25b54d[_0xaa70('0xc7')]+=0x1;_0x25b54d[_0xaa70('0x99')]=ut['totalGlobal'](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0xb,_0xaa70('0xc8'));rpcDb[_0xaa70('0x6a')](_0x25b54d,_0xaa70('0xc9'));_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'11',_0x347937)[_0xaa70('0x58')](function(_0x150f3a){_0x583740=_0x150f3a['additional']==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,_0xaa70('0x84'));rpcDb[_0xaa70('0x6d')](_0x3d73b0,_0xaa70('0xc9'));}else{if(_0x25b54d[_0xaa70('0xca')]>=_0x347937[_0xaa70('0xcb')]){rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xc9'));}else{rpcDb['rescheduleContact'](ut[_0xaa70('0xab')](_0x25b54d,_0xaa70('0xc7'),_0x347937[_0xaa70('0xcc')]),_0x25b54d[_0xaa70('0x88')],_0x25b54d['activeContact']);}}}else{_0x25b54d['countnoanswerretry']++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d[_0xaa70('0x8a')],'field':{'countnoanswerretry':_0x25b54d[_0xaa70('0xb3')]}})['then'](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});break;case'18':_0x347937['outboundUnknownCallsDay']+=0x1;_0x25b54d[_0xaa70('0xcd')]+=0x1;_0x25b54d[_0xaa70('0x99')]=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0x12,_0x58c48e[_0xaa70('0xce')]||_0x58c48e[_0xaa70('0xcf')]);ami[_0xaa70('0x22')](_0xaa70('0xd0'),ut[_0xaa70('0x7d')](_0x25b54d,_0xaa70('0xd1')));rpcDb[_0xaa70('0x6a')](_0x25b54d,_0xaa70('0xd2'));_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'18',_0x347937)[_0xaa70('0x58')](function(_0x291724){_0x583740=_0x291724[_0xaa70('0x7f')]==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937['dialGlobalMaxRetry']){_0x3d73b0=ut['cloneAction'](_0x25b54d,0x12,'Global');rpcDb[_0xaa70('0x6d')](_0x3d73b0,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xd2'));}}else{_0x25b54d['countnoanswerretry']++;_0x5ed060['incrementPreviewCounters']({'id':_0x25b54d[_0xaa70('0x8a')],'field':{'countnoanswerretry':_0x25b54d[_0xaa70('0xb3')]}})[_0xaa70('0x58')](function(){_0x5ed060['swapAdditionalPhones'](_0x25b54d,_0x29209c,_0x9b428d)[_0xaa70('0x58')](function(){});});}});delete this['actions'][_0x58c48e['linkedid']];break;case'19':_0x347937[_0xaa70('0xd3')]+=0x1;_0x25b54d['countglobal']=ut[_0xaa70('0x7b')](_0x25b54d);ut['logCustomer'](_0x25b54d,0x13,_0x58c48e[_0xaa70('0xce')]||_0x58c48e[_0xaa70('0xcf')]);ami['emit']('custom:amd',ut[_0xaa70('0x7d')](_0x25b54d,'amd'));rpcDb[_0xaa70('0x6a')](_0x25b54d,_0xaa70('0xd4'));_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'18',_0x347937)['then'](function(_0x52da8e){_0x583740=_0x52da8e[_0xaa70('0x7f')]==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut[_0xaa70('0x83')](_0x25b54d,0xf,_0xaa70('0x84'));rpcDb['createCustomerFinal'](_0x3d73b0,_0xaa70('0xd4'));}else{rpcDb[_0xaa70('0x6d')](_0x25b54d,'[callProgressDetectingCustomer][machine]');}}else{_0x25b54d[_0xaa70('0xb3')]++;_0x5ed060[_0xaa70('0xac')]({'id':_0x25b54d['idContact'],'field':{'countnoanswerretry':_0x25b54d[_0xaa70('0xb3')]}})[_0xaa70('0x58')](function(){_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)['then'](function(){});});}});delete this['actions'][_0x58c48e[_0xaa70('0xa1')]];break;default:if(_0x25b54d[_0xaa70('0x45')]){ut[_0xaa70('0x50')](_0x347937,_0xaa70('0xd5'));ut[_0xaa70('0x51')](_0xaa70('0xd6')+_0x347937[_0xaa70('0x26')],_0x58c48e);}_0x347937[_0xaa70('0xd3')]+=0x1;_0x25b54d['countglobal']=ut[_0xaa70('0x7b')](_0x25b54d);ut[_0xaa70('0x65')](_0x25b54d,0xc,_0x58c48e[_0xaa70('0xce')]||_0x58c48e[_0xaa70('0xcf')]);_0x29209c=_0x347937[_0xaa70('0xc0')];_0x9b428d=_0x347937['callAdditionalPhoneAfterMin'];rpcDb[_0xaa70('0x6a')](_0x25b54d,'[callProgressDetectingCustomer][logUnknown]');_0x5ed060[_0xaa70('0xa8')](_0x25b54d,'20',_0x347937)[_0xaa70('0x58')](function(_0x36f54e){_0x583740=_0x36f54e['additional']==0x1;if(!_0x583740){if(ut[_0xaa70('0x7b')](_0x25b54d)>=_0x347937[_0xaa70('0x82')]){_0x3d73b0=ut['cloneAction'](_0x25b54d,0xf,'Global');rpcDb[_0xaa70('0x6d')](_0x3d73b0,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb[_0xaa70('0x6d')](_0x25b54d,_0xaa70('0xd7'));}delete this[_0xaa70('0x3f')][_0x58c48e[_0xaa70('0xa1')]];}else{_0x5ed060[_0xaa70('0x8b')](_0x25b54d,_0x29209c,_0x9b428d)['then'](function(){});}});}if(!(_0x25b54d[_0xaa70('0x45')]&&_0x230939==='16')){utils['decrementOriginate'](_0x347937,_0xaa70('0xd8'));logger[_0xaa70('0x53')](_0xaa70('0xd9'),_0x25b54d[_0xaa70('0x90')],'\x20Queue',_0x347937[_0xaa70('0x26')],'originated:\x20',_0x347937['originated']);}if(_0x230939!==_0xaa70('0x8c')){delete this[_0xaa70('0x3f')][_0x58c48e[_0xaa70('0xa1')]];delete this[_0xaa70('0x3f')][_0x58c48e[_0xaa70('0xda')]];}_0x347937['queueSummaryCountersUpdated']=!![];}};Preview[_0xaa70('0x32')][_0xaa70('0xdb')]=function(_0x124e0e,_0x256532,_0x4e02c8){if(_[_0xaa70('0xdc')](_0x256532)&&_0xaa70('0xdd')!==typeof _0x256532){return;}if(_[_0xaa70('0xdc')](_0x4e02c8)&&_0xaa70('0xdd')!==typeof _0x4e02c8){return;}switch(_0x4e02c8[_0xaa70('0xde')]){case'0':ut[_0xaa70('0xdf')](_0x124e0e,0x0,_0xaa70('0xe0'));rpcDb[_0xaa70('0xe1')](_0x124e0e,_0xaa70('0xe2'));break;case'3':ut[_0xaa70('0xdf')](_0x124e0e,0x3,_0xaa70('0xe3'));rpcDb[_0xaa70('0xe1')](_0x124e0e,_0xaa70('0xe4'));break;case'5':ut['logAgent'](_0x124e0e,0x5,_0xaa70('0xe5'));rpcDb['createAgentHistory'](_0x124e0e,_0xaa70('0xe6'));break;case'8':ut[_0xaa70('0xdf')](_0x124e0e,0x8,'Congestion');rpcDb[_0xaa70('0xe1')](_0x124e0e,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0xaa70('0xdf')](_0x124e0e,0x16,_0xaa70('0xe7'));rpcDb[_0xaa70('0xe1')](_0x124e0e,_0xaa70('0xe8'));break;default:ut[_0xaa70('0xdf')](_0x124e0e,0xc,_0x4e02c8['reason']);rpcDb[_0xaa70('0xe1')](_0x124e0e,_0xaa70('0xe9'));}utils[_0xaa70('0xea')](_0x256532,_0xaa70('0xeb'));logger[_0xaa70('0x53')](_0xaa70('0xec'),_0x124e0e[_0xaa70('0x90')],_0xaa70('0xed'),_0x256532[_0xaa70('0x26')],_0xaa70('0xee'),_0x256532[_0xaa70('0x2a')]);delete this[_0xaa70('0x3f')][_0x124e0e[_0xaa70('0x90')]];};Preview['prototype'][_0xaa70('0xa8')]=function(_0x3c5a58,_0x221db6,_0x562fc5){return cmHopperAdditionalPhone[_0xaa70('0xa8')](_0x3c5a58,_0x221db6,_0x562fc5)[_0xaa70('0x62')](logger[_0xaa70('0x53')]('[verifyAdditionalPhone]\x20'));};Preview[_0xaa70('0x32')]['swapAdditionalPhones']=function(_0x579a94,_0x10e155,_0x1d035d){return cmHopperAdditionalPhone[_0xaa70('0x8b')](_0x579a94,_0x10e155,_0x1d035d)[_0xaa70('0x62')](logger[_0xaa70('0x53')]('[swapAdditionalPhone]\x20'));};Preview['prototype'][_0xaa70('0xac')]=function(_0x4456d5){return Promise['resolve']()['then'](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x4456d5))['catch'](logger['info'](_0xaa70('0xef')));};Preview[_0xaa70('0x32')][_0xaa70('0xf0')]=function(_0x1c40ae,_0x3a7e47,_0x6fce62,_0x22b97f,_0x28dad2){var _0x31699e=this;return new Promise(function(_0x3fe7a7,_0x15afc7){if(_[_0xaa70('0x3e')](_0x3a7e47)||_['isNil'](_0x3a7e47[_0xaa70('0xf1')])||_[_0xaa70('0x3e')](_0x3a7e47[_0xaa70('0xf2')])||_[_0xaa70('0x3e')](_0x3a7e47[_0xaa70('0x49')])){_0x15afc7(ut[_0xaa70('0x4d')]('Contact\x20is\x20undefined',_0x22b97f,_0x28dad2));return;}var _0x35234e=uuid['v4']();var _0x5c9535=_0x31699e[_0xaa70('0xf')][_0x3a7e47[_0xaa70('0x41')]['name']];var _0x2274f1=_0x6fce62?_0x31699e['agents'][_0x6fce62]['id']:undefined;_0x31699e[_0xaa70('0x3f')][_0x35234e]=new Action(_0x3a7e47,_0x5c9535,_0x35234e,_0x6fce62,_0x2274f1);var _0x525884=_0x31699e[_0xaa70('0x3f')][_0x35234e];_0x525884[_0xaa70('0x88')]=_0x22b97f;_0x525884[_0xaa70('0x89')]=_0x28dad2;_0x525884['lookAgent']=_0x6fce62;if(_[_0xaa70('0xf3')](_0x1c40ae)){_0x31699e['execCall'](_0x525884,_0x5c9535,_0x3a7e47,_0x6fce62)['then'](function(_0x4252e3){logger[_0xaa70('0x53')]('[Preview][execCall][success]',_0xaa70('0xf4')+_0x525884[_0xaa70('0x42')]+_0xaa70('0xf5')+_0x525884['idContact'],JSON['stringify'](_0x4252e3));ami[_0xaa70('0x22')](_0xaa70('0xf6'),ut[_0xaa70('0x7d')](_0x525884,_0xaa70('0xf7'),_0x31699e[_0xaa70('0xf')][_0x525884[_0xaa70('0x42')]]));_0x3fe7a7(ut[_0xaa70('0x4d')](_0xaa70('0xf8')));})[_0xaa70('0x62')](function(_0x1e9993){ut[_0xaa70('0x2f')](_0xaa70('0xf9'),_0x1e9993);_0x15afc7(ut[_0xaa70('0x4d')](_0xaa70('0xfa'),_0x22b97f,_0x28dad2));});}else{_0x5c9535[_0xaa70('0xfb')]+=0x1;ut[_0xaa70('0xfc')](_0x525884);rpcDb['createHistory'](_0x525884,'[Blacklist][error]');delete _0x31699e[_0xaa70('0x3f')][_0x35234e];_0x15afc7(ut[_0xaa70('0x4d')]('Contact\x20in\x20black\x20List',_0x22b97f,_0x28dad2));}});};Preview['prototype'][_0xaa70('0x75')]=function(_0xc5041c){return!_['isNil'](_0xc5041c)&&!_[_0xaa70('0x3e')](_0xc5041c['name'])&&!_[_0xaa70('0x3e')](_0xc5041c[_0xaa70('0xfd')])&&_0xc5041c[_0xaa70('0xfd')]&&!_[_0xaa70('0x3e')](this[_0xaa70('0x11')][util[_0xaa70('0x24')](_0xaa70('0xfe'),_0xc5041c[_0xaa70('0x26')])])&&!_[_0xaa70('0x3e')](this[_0xaa70('0x11')][util['format'](_0xaa70('0xfe'),_0xc5041c[_0xaa70('0x26')])][_0xaa70('0x4b')])&&(this['trunks'][util[_0xaa70('0x24')]('SIP/%s',_0xc5041c[_0xaa70('0x26')])]['status']==='reachable'||this['trunks'][util[_0xaa70('0x24')](_0xaa70('0xfe'),_0xc5041c[_0xaa70('0x26')])][_0xaa70('0x4b')]==='unmonitored');};Preview[_0xaa70('0x32')][_0xaa70('0x5f')]=function(_0x15ce8f,_0x6ff7a5){return this[_0xaa70('0xff')](_0x15ce8f,_0x6ff7a5)['then'](function(_0x1e917b){return _['pick'](_0x1e917b,[_0xaa70('0x4d')]);})[_0xaa70('0x62')](function(_0x42da84){if(_0x42da84[_0xaa70('0x100')]){rpcDb[_0xaa70('0x101')](_0x15ce8f);}if(_0x42da84[_0xaa70('0xfd')]){rpcDb[_0xaa70('0x63')](_0x15ce8f);}throw _[_0xaa70('0x46')](_0x42da84,[_0xaa70('0x4d')]);});};Preview[_0xaa70('0x32')][_0xaa70('0xff')]=function(_0x431ae5,_0x412ba2){var _0x229c25=this;var _0x4daa37,_0x38dcf7;return rpcDb[_0xaa70('0x102')](_0x431ae5)['then'](function(_0x2f9e21){if(!_['isNil'](_0x2f9e21[0x0])){_0x38dcf7=_0x2f9e21[0x0][_0xaa70('0x103')]?![]:!![];_0x4daa37=_0x2f9e21[0x0][_0xaa70('0x103')]?!![]:![];_0x4daa37=_0x412ba2?!![]:_0x4daa37;}var _0x3a28c0=_0x229c25[_0xaa70('0x104')](_0x2f9e21);if(_0x3a28c0['isValid']){rpcDb['checkIsBlackList'](_[_0xaa70('0x46')](_0x2f9e21[0x0],[_0xaa70('0x49'),'phone']))[_0xaa70('0x58')](function(_0x55c837){_0x229c25[_0xaa70('0xf0')](_0x55c837,_0x2f9e21[0x0],_0x412ba2,_0x38dcf7,_0x4daa37)['then'](function(_0x4be1f5){return _0x4be1f5;})[_0xaa70('0x62')](function(_0xd03a04){throw _0xd03a04;});})[_0xaa70('0x62')](function(_0x22791a){ut['logger'](_0xaa70('0x105'),_0x22791a);throw ut[_0xaa70('0x4d')](_0xaa70('0x106'),_0x38dcf7,_0x4daa37);});}else{throw ut[_0xaa70('0x4d')](_0x3a28c0[_0xaa70('0x4d')],_0x38dcf7,_0x4daa37);}})[_0xaa70('0x62')](function(_0x505ae1){ut[_0xaa70('0x2f')](_0xaa70('0x107'),_0x505ae1);throw ut[_0xaa70('0x4d')](_0xaa70('0x106'),![],!![]);});};Preview[_0xaa70('0x32')][_0xaa70('0x104')]=function(_0x598587){if(_[_0xaa70('0x3e')](_0x598587)||_['isEmpty'](_0x598587)||!_[_0xaa70('0x3e')](_0x598587[0x0][_0xaa70('0x5d')])&&_[_0xaa70('0x3e')](_0x598587[0x0][_0xaa70('0x5d')][_0xaa70('0x26')])){ut[_0xaa70('0x2f')](_0xaa70('0x108'),_0x598587);return{'isValid':![],'message':_0xaa70('0x109')};}var _0x5bf999=this['campaignsPreview'][_0x598587[0x0][_0xaa70('0x41')][_0xaa70('0x26')]];_0x5bf999[_0xaa70('0x4d')]=utils[_0xaa70('0x2d')][_0xaa70('0x78')];if(_[_0xaa70('0x3e')](_0x5bf999)){ut[_0xaa70('0x2f')](_0xaa70('0x10a'),_0x5bf999);return{'isValid':![],'message':_0xaa70('0x10b')};}if(!this[_0xaa70('0x75')](_0x5bf999[_0xaa70('0x76')])){ut[_0xaa70('0x2f')]('[Preview][validateContact][Trunk\x20not\x20working\x20correctly]',_0xaa70('0x10c')+_0x5bf999['name']+_0xaa70('0x10d'));if(!this['isTrunkReachable'](_0x5bf999[_0xaa70('0x77')])){ut[_0xaa70('0x2f')]('[Preview][validateContact][Trunk\x20not\x20working\x20correctly]',_0x5bf999[_0xaa70('0x26')]+_0xaa70('0x10e'));return{'isValid':![],'message':'Trunk\x20not\x20working\x20correctly'};}}if(!ut['isActive'](_0x5bf999[_0xaa70('0x3b')])){ut['logger'](_0xaa70('0x10f'),_0x5bf999[_0xaa70('0x26')]+_0xaa70('0x110'));return{'isValid':![],'message':_0xaa70('0x10c')+_0x5bf999[_0xaa70('0x26')]+_0xaa70('0x110')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview[_0xaa70('0x32')][_0xaa70('0x111')]=function(_0x32fa75,_0x5af470,_0x5bc6fb,_0x1998ac){var _0x422035=this;return new Promise(function(_0x2253f0,_0x1124b2){var _0xc9a96b=_0x32fa75[_0xaa70('0x90')];var _0x431988=_0x422035[_0xaa70('0x75')](_0x5af470['Trunk'])?util[_0xaa70('0x24')](_0xaa70('0x112'),_0x5af470[_0xaa70('0x76')]['name'],_[_0xaa70('0x3e')](_0x5af470[_0xaa70('0x113')])?'':_0x5af470[_0xaa70('0x113')][_0xaa70('0x114')]()||'',_0x5af470['dialCutDigit']>0x0?_0x5bc6fb[_0xaa70('0xf2')][_0xaa70('0x115')](_0x5af470['dialCutDigit']):_0x5bc6fb['phone']):util[_0xaa70('0x24')]('SIP/%s/%s%s',_[_0xaa70('0x3e')](_0x5af470[_0xaa70('0x77')])?_0x5af470[_0xaa70('0x76')][_0xaa70('0x26')]:_0x5af470[_0xaa70('0x77')][_0xaa70('0x26')],_[_0xaa70('0x3e')](_0x5af470['dialPrefix'])?'':_0x5af470[_0xaa70('0x113')][_0xaa70('0x114')]()||'',_0x5af470[_0xaa70('0x116')]>0x0?_0x5bc6fb[_0xaa70('0xf2')][_0xaa70('0x115')](_0x5af470[_0xaa70('0x116')]):_0x5bc6fb['phone']);var _0x2229b7=_0x422035['isTrunkReachable'](_0x5af470[_0xaa70('0x76')])?ut[_0xaa70('0x117')](_0x5af470[_0xaa70('0x76')][_0xaa70('0x118')],_0x5af470[_0xaa70('0x119')],_0x5af470['dialRandomLastDigitCallerIdNumber']>0x0?ut['getCallerIdRandom'](_0x5af470[_0xaa70('0x11a')],_0x5af470['dialRandomLastDigitCallerIdNumber']):_0x5af470[_0xaa70('0x11a')]):ut[_0xaa70('0x117')](_[_0xaa70('0x3e')](_0x5af470[_0xaa70('0x77')])?_0x5af470[_0xaa70('0x76')][_0xaa70('0x118')]:_0x5af470[_0xaa70('0x77')]['callerid'],_0x5af470[_0xaa70('0x119')],_0x5af470[_0xaa70('0x11b')]>0x0?ut[_0xaa70('0x11c')](_0x5af470['dialOriginateCallerIdNumber'],_0x5af470['dialRandomLastDigitCallerIdNumber']):_0x5af470[_0xaa70('0x11a')]);if(_0x2229b7){_0x32fa75[_0xaa70('0x11d')]=ut[_0xaa70('0x11e')](_0x2229b7);_0x32fa75[_0xaa70('0x11f')]=ut[_0xaa70('0x120')](_0x2229b7);}var _0x4f3306=ut[_0xaa70('0x121')](_0x5af470,_0x5bc6fb,_0x431988,_0x2229b7,_0xc9a96b,_0x32fa75);var _0x510c17=utils['setXMDContactVariables'](_0x5bc6fb[_0xaa70('0xf1')]);Object[_0xaa70('0x122')](_0x4f3306,_0x510c17);_[_0xaa70('0x123')](_0x32fa75,ut[_0xaa70('0x124')](_0x4f3306));_0x32fa75[_0xaa70('0x125')]=moment()['format'](_0xaa70('0x64'));_0x5af470['variables']=_0x4f3306;var _0x1552d8=ut[_0xaa70('0x126')](_0x32fa75,_0x5af470,_0x4f3306,_0x32fa75[_0xaa70('0x89')],_0x1998ac);return ami['Action'](_0x1552d8)[_0xaa70('0x58')](function(_0x3a6580){_0x5af470[_0xaa70('0x2a')]+=0x1;logger[_0xaa70('0x53')](_0xaa70('0x127'),_0xc9a96b,_0xaa70('0xed'),_0x5af470[_0xaa70('0x26')],_0xaa70('0xee'),_0x5af470[_0xaa70('0x2a')]);_0x2253f0(_0x3a6580);})[_0xaa70('0x62')](function(_0x58b27d){ut[_0xaa70('0xdf')](_0x32fa75,0xe,_0xaa70('0x128'));rpcDb[_0xaa70('0xe1')](_0x32fa75,_0xaa70('0x129'));_0x1124b2(_0x58b27d);});});};Preview['prototype'][_0xaa70('0x1c')]=function(_0x3b31cf){if(this[_0xaa70('0x3f')][_0x3b31cf[_0xaa70('0xa1')]]){this[_0xaa70('0x3f')][_0x3b31cf[_0xaa70('0xa1')]][_0xaa70('0x4c')]=_0x3b31cf[_0xaa70('0x4c')];}};Preview[_0xaa70('0x32')][_0xaa70('0x12a')]=function(_0x45ce39){var _0x3b279b=this;var _0x54af10=this[_0xaa70('0x3f')][_0x45ce39[_0xaa70('0x12b')]];if(_0x54af10){if(_0x54af10[_0xaa70('0x12c')]&&this['agents'][_0x54af10[_0xaa70('0x12c')]]){ut[_0xaa70('0x12d')](_0x54af10,this[_0xaa70('0x12')][_0x54af10[_0xaa70('0x12c')]][_0xaa70('0x26')],this[_0xaa70('0x12')][_0x54af10[_0xaa70('0x12c')]]['id']);}var _0x5aa667=_[_0xaa70('0x12e')](_0x54af10);_0x5aa667[_0xaa70('0x8d')]=moment()[_0xaa70('0x24')](_0xaa70('0x64'));var _0xb1baed=_0x3b279b['campaignsPreview'][_0x54af10[_0xaa70('0x42')]];if(ut['isFailure'](_0x45ce39[_0xaa70('0x12f')])){if(_0x54af10[_0xaa70('0x88')]){rpcDb[_0xaa70('0x101')](_0x54af10[_0xaa70('0x8a')]);}if(_0x54af10[_0xaa70('0x89')]){rpcDb[_0xaa70('0x63')](_0x54af10[_0xaa70('0x8a')]);}ami[_0xaa70('0x22')](_0xaa70('0x130'),ut['buildObj'](_0x54af10,'rejected',this['campaignsPreview'][_0x54af10[_0xaa70('0x42')]]));this[_0xaa70('0xdb')](_0x5aa667,_0xb1baed,_0x45ce39);}else{_0x54af10[_0xaa70('0x125')]=moment()[_0xaa70('0x24')](_0xaa70('0x64'));ut[_0xaa70('0xdf')](_0x5aa667,0x4,_0xaa70('0x9a'));rpcDb[_0xaa70('0xe1')](_0x5aa667,_0xaa70('0x131'));}}};Preview[_0xaa70('0x32')][_0xaa70('0x17')]=function(_0x29cd4e){var _0xed3ec8=this[_0xaa70('0x3f')][_0x29cd4e['linkedid']];var _0xe47cdd;if(_0xed3ec8){_0xe47cdd=this[_0xaa70('0xf')][_0xed3ec8[_0xaa70('0x42')]];logger[_0xaa70('0x53')](_0xaa70('0x132'),_0x29cd4e[_0xaa70('0xa1')],_0xaa70('0xed'),_0xe47cdd[_0xaa70('0x26')],'pTalking:\x20',_0xe47cdd[_0xaa70('0x44')]);}if(this[_0xaa70('0x3f')][_0x29cd4e[_0xaa70('0xa1')]]&&_0x29cd4e[_0xaa70('0xa1')]!==_0x29cd4e[_0xaa70('0x90')]){if(_0x29cd4e[_0xaa70('0x133')]==='16'&&this[_0xaa70('0x3f')][_0x29cd4e[_0xaa70('0xa1')]]['dialAnswer']){this[_0xaa70('0x134')](_0x29cd4e,_0x29cd4e[_0xaa70('0xa1')],_0x29cd4e[_0xaa70('0x133')]);}else if(this['actions'][_0x29cd4e['linkedid']]['dialAnswer']){logger['info']('[syncHangup][talking][cause]',_0x29cd4e['linkedid'],_0x29cd4e[_0xaa70('0x133')],'\x20Queue',_0xe47cdd['name'],'pTalking:\x20',_0xe47cdd[_0xaa70('0x44')]);this[_0xaa70('0x134')](_0x29cd4e,_0x29cd4e['linkedid'],_0x29cd4e[_0xaa70('0x133')]);}}else if(_0xed3ec8&&_[_0xaa70('0x3e')](_0xed3ec8[_0xaa70('0x135')])&&_0xe47cdd[_0xaa70('0x136')]&&_0x29cd4e[_0xaa70('0xa1')]===_0x29cd4e[_0xaa70('0x90')]&&_[_0xaa70('0x3e')](_0x29cd4e[_0xaa70('0xde')])&&_0x29cd4e[_0xaa70('0x133')]==='16'&&_0x29cd4e['channelstate']==='6'&&_[_0xaa70('0xdc')](_0xed3ec8[_0xaa70('0x137')])){if(_0xed3ec8[_0xaa70('0x88')]){rpcDb[_0xaa70('0x101')](_0xed3ec8[_0xaa70('0x8a')]);}if(_0xed3ec8[_0xaa70('0x89')]){rpcDb[_0xaa70('0x63')](_0xed3ec8['idContact']);}_0x29cd4e['reason']='22';this['callProgressDetectingAgent'](_0xed3ec8,_0xe47cdd,_0x29cd4e);}else if(_0xed3ec8&&_0xed3ec8[_0xaa70('0x137')]){if(_0x29cd4e[_0xaa70('0x133')]==='16'&&this[_0xaa70('0x3f')][_0x29cd4e[_0xaa70('0xa1')]][_0xaa70('0x45')]){logger[_0xaa70('0x53')](_0xaa70('0x138'),_0x29cd4e[_0xaa70('0xa1')],_0x29cd4e[_0xaa70('0x133')],_0xaa70('0xed'),_0xe47cdd[_0xaa70('0x26')],_0xaa70('0x43'),_0xe47cdd['pTalking']);this[_0xaa70('0x134')](_0x29cd4e,_0x29cd4e['linkedid'],_0x29cd4e[_0xaa70('0x133')]);}else if(this[_0xaa70('0x3f')][_0x29cd4e[_0xaa70('0xa1')]][_0xaa70('0x45')]){logger[_0xaa70('0x53')](_0xaa70('0x139'),_0x29cd4e[_0xaa70('0xa1')],_0x29cd4e[_0xaa70('0x133')],_0xaa70('0xed'),_0xe47cdd['name'],'pTalking:\x20',_0xe47cdd[_0xaa70('0x44')]);this[_0xaa70('0x134')](_0x29cd4e,_0x29cd4e[_0xaa70('0xa1')],_0x29cd4e[_0xaa70('0x133')]);}}};Preview[_0xaa70('0x32')][_0xaa70('0x1a')]=function(_0xd8e43d){if(this[_0xaa70('0x3f')][_0xd8e43d[_0xaa70('0xda')]]&&_0xd8e43d[_0xaa70('0xda')]!==_0xd8e43d['destuniqueid']){this[_0xaa70('0x134')](_0xd8e43d,_0xd8e43d['destlinkedid'],_0xd8e43d[_0xaa70('0xcf')]);}};Preview[_0xaa70('0x32')][_0xaa70('0x13a')]=function(_0x299ded){if(this[_0xaa70('0x3f')][_0x299ded[_0xaa70('0xa1')]]&&_0x299ded[_0xaa70('0xa1')]!==_0x299ded[_0xaa70('0x90')]&&!this['actions'][_0x299ded[_0xaa70('0xa1')]][_0xaa70('0x45')]){if(_0x299ded['cause']==='1'){this[_0xaa70('0x134')](_0x299ded,_0x299ded[_0xaa70('0xa1')],_0x299ded[_0xaa70('0x133')]);}}};Preview[_0xaa70('0x32')][_0xaa70('0x13b')]=function(_0x46e4df,_0x43859a,_0x4ff338){if(this[_0xaa70('0x3f')][_0x46e4df]){if(_[_0xaa70('0x3e')](this[_0xaa70('0x3f')][_0x46e4df][_0xaa70('0x13c')])){this['actions'][_0x46e4df][_0xaa70('0x13c')]={};}this[_0xaa70('0x3f')][_0x46e4df][_0xaa70('0x13c')][_0x43859a]=_0x4ff338;}};Preview['prototype']['syncVarSet']=function(_0x3ce89f){try{if(!_[_0xaa70('0x3e')](_0x3ce89f)){if(ut[_0xaa70('0x13d')](_[_0xaa70('0x13e')](_0x3ce89f[_0xaa70('0x13f')])[0x0])){this['addVariable'](_0x3ce89f[_0xaa70('0x90')],_[_0xaa70('0x13e')](_0x3ce89f['variable'])[0x0],_0x3ce89f[_0xaa70('0x140')]);}}}catch(_0x3bf967){logger[_0xaa70('0x141')](_0xaa70('0x142'),util[_0xaa70('0x143')](_0x3bf967,{'showHidden':![],'depth':null}));}};Preview[_0xaa70('0x32')][_0xaa70('0x144')]=function(_0x15d15a){if(_0x15d15a){if(this[_0xaa70('0x3f')][_0x15d15a[_0xaa70('0x145')]]){this[_0xaa70('0x3f')][_0x15d15a[_0xaa70('0x145')]]['transfer']=!![];}}};Preview[_0xaa70('0x32')][_0xaa70('0x146')]=function(_0x5d05db){if(_0x5d05db){if(this[_0xaa70('0x3f')][_0x5d05db[_0xaa70('0x147')]]){this[_0xaa70('0x3f')][_0x5d05db['transfererlinkedid']][_0xaa70('0x137')]=!![];}}};module[_0xaa70('0x148')]=Preview;