7d7fb2d63d7394a9a024e0c5ccee833f03d21bf2
[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 _0x40ff=['IsNotLoggedIn','isActive','dialActive','Trunk','isTrunkReachable','TrunkBackup','ACTIVE','callProgressDetectingCustomer','countnosuchnumberretry','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','dialNoSuchNumberRetryFrequency','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','unlockAgent','activeContact','linkedid','actioncountonusuch','idContact','swapAdditionalPhones','ANSWER','responsetime','answertime','uniqueid','\x20Queue','pTalking:\x20','custom:agentconnect','buildObj','mandatoryDisposition','custom:agentConnectPreview','channelAgent','custom:agentcomplete','complete','outboundAnswerCallsDay','answered','[16]','countglobal','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','sumDuration','talktime','[syncHangup][talking][decrement]','BUSY','outboundBusyCallsDay','Busy','dialBusyRetryFrequency','callAdditionalPhoneAfterMin','custom:agentbusy','[callProgressDetectingCustomer][logBusyGlobal]','countbusyretry','incrementPreviewCounters','NOANSWER','outboundNoAnswerCallsDay','countnoanswerretry','NoAnswer','dialNoAnswerRetryFrequency','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','rescheduleContact','scheduledAt','CONGESTION','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','[callProgressDetectingCustomer][logCongestion]','dialCongestionMaxRetry','countcongestionretry','CANCEL','dialAgentRejectRetryFrequency','custom:agentreject','[syncHangupRequest][logAgentReject]','AgentReject','[callProgressDetectingCustomer][logAgentReject]','countagentrejectretry','dialAgentRejectMaxRetry','ABANDONED','outboundAbandonedCallsDay','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','outboundUnknownCallsDay','countmachineretry','cause-txt','dialstatus','custom:amd','[callProgressDetectingCustomer][hangupInAMD]','amd','[callProgressDetectingCustomer][machine]','[default]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','queueSummaryCountersUpdated','callProgressDetectingAgent','isUndefined','object','logAgent','createAgentHistory','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent][logAnswerAGI]','reason','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','resolve','[incrementPreviewCounters]\x20','checkInBlack','lookAgent','isEmpty','execCall','Queue:\x20','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','logBlacklist','createHistory','[Blacklist][error]','active','trunks','SIP/%s','reachable','unmonitored','run','execRun','pick','unlock','unlockContact','getContactPreview','recallme','validateContact','checkIsBlackList','VoiceQueueId','phone','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','\x20Trunk\x20is\x20not\x20active','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','campaign\x20Name:\x20','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialPrefix','trim','dialCutDigit','callerid','dialOriginateCallerIdName','dialRandomLastDigitCallerIdNumber','dialOriginateCallerIdNumber','getCallerId','getCallerIdRandom','originatecalleridname','extractCalleridName','extractCalleridNumber','addVariables','setXMDContactVariables','merge','toLowerVariables','variables','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','syncOriginateResponse','actionid','logLookAgent','clone','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','destuniqueid','addVariable','filterKey','keys','variable','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','exports','lodash','uuid','ioredis','../../../config/logger','actionPreview','../ami','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','redis','localhost','prototype','enqueue','tail','finally','sequence','campaignsPreview','voiceQueues','actions','agents','clockClearZombieChannels','bind','hangup','syncHangup','syncHangupRequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','loopCampaigns','emit','info','stringify','format','voice:queue:%s','name','voice_queue_presence:remove','sendMessageOneNotActive','originated','pTalking','paused','CAMPAIGN_STATUS','INACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','message','DEACTIVATED','\x20is\x20deactivated','syncCampaigns','dialMethod','booked','clearZombieChannels','preview','type','outbound','setMessage','recallMe','clearZombieChannel','isNil','Queue','queue','originated:\x20','dialAnswer','contactId','UserId','ListId','Action','status','channel','catch','No\x20such\x20channel','decrementOriginate','[clearZombieChannel]','decrementTalking','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','[action]','size','hasOwnProperty','getContactRecallMe','agentReadyId','then','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','logger2','[RecallMe]','disableContact','starttime','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','RecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','logCustomer','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]'];(function(_0x25e2c9,_0x503114){var _0x1e5b99=function(_0xb9a1fb){while(--_0xb9a1fb){_0x25e2c9['push'](_0x25e2c9['shift']());}};_0x1e5b99(++_0x503114);}(_0x40ff,0xd0));var _0xf40f=function(_0x207a27,_0x4dc9fc){_0x207a27=_0x207a27-0x0;var _0x41de7f=_0x40ff[_0x207a27];return _0x41de7f;};'use strict';var util=require('util');var _=require(_0xf40f('0x0'));var uuid=require(_0xf40f('0x1'));var moment=require('moment');var Redis=require(_0xf40f('0x2'));var config=require('../../../config/environment');var logger=require('../../../config/logger')('preview');var loggerAction=require(_0xf40f('0x3'))(_0xf40f('0x4'));var ami=require(_0xf40f('0x5'));var rpcDb=require(_0xf40f('0x6'));var cmHopperAdditionalPhone=require(_0xf40f('0x7'));var Action=require(_0xf40f('0x8'));var ut=require(_0xf40f('0x9'));var utils=require('../dialer/utils');config[_0xf40f('0xa')]=_['defaults'](config[_0xf40f('0xa')],{'host':_0xf40f('0xb'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xf40f('0xa')]));var Sequence=function(){};Sequence[_0xf40f('0xc')][_0xf40f('0xd')]=function(_0x4f1ecd){this['tail']=this['tail']?this[_0xf40f('0xe')][_0xf40f('0xf')](_0x4f1ecd):_0x4f1ecd();};function Preview(_0x440a63){this[_0xf40f('0x10')]=new Sequence();this[_0xf40f('0x11')]=_0x440a63[_0xf40f('0x12')];this['trunks']=_0x440a63['trunks'];this[_0xf40f('0x13')]={};this[_0xf40f('0x14')]=_0x440a63[_0xf40f('0x14')];this[_0xf40f('0x15')]=0x0;ami['on']('originateresponse',this['syncOriginateResponse'][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x17'),this[_0xf40f('0x18')][_0xf40f('0x16')](this));ami['on']('hanguprequest',this[_0xf40f('0x19')][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x1a'),this[_0xf40f('0x1b')][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x1c'),this[_0xf40f('0x1d')][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x1e'),this[_0xf40f('0x1f')][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x20'),this[_0xf40f('0x21')][_0xf40f('0x16')](this));ami['on'](_0xf40f('0x22'),this['syncBlindTransfer'][_0xf40f('0x16')](this));this[_0xf40f('0x23')](this['campaignsPreview']);}function emit(_0x3201fa,_0x31aebd,_0x5874a4){io['to'](_0x3201fa)[_0xf40f('0x24')](_0x31aebd,_0x5874a4);}function emitVoiceQueueChannelRemove(_0x59833f){logger[_0xf40f('0x25')]('[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event',JSON[_0xf40f('0x26')](_0x59833f));emit(util[_0xf40f('0x27')](_0xf40f('0x28'),_0x59833f[_0xf40f('0x29')]),'voice_queue_channel:remove',_0x59833f);io[_0xf40f('0x24')](_0xf40f('0x2a'),_0x59833f);}function notSendMessagesQueue(_0x52318d){if(_0x52318d[_0xf40f('0x2b')]){if(_0x52318d[_0xf40f('0x2c')]===0x0&&_0x52318d[_0xf40f('0x2d')]===0x0){_0x52318d[_0xf40f('0x2b')]=![];_0x52318d['available']=0x0;_0x52318d[_0xf40f('0x2e')]=0x0;_0x52318d['message']=utils[_0xf40f('0x2f')][_0xf40f('0x30')];ut[_0xf40f('0x31')](_0xf40f('0x32'),_0x52318d[_0xf40f('0x29')]+_0xf40f('0x33'));}else{_0x52318d[_0xf40f('0x34')]=utils[_0xf40f('0x2f')][_0xf40f('0x35')];ut[_0xf40f('0x31')](_0xf40f('0x32'),_0x52318d[_0xf40f('0x29')]+_0xf40f('0x36'));}}}Preview[_0xf40f('0xc')][_0xf40f('0x23')]=function(){var _0x52d67a=this;setInterval(function(){_0x52d67a['syncCampaigns']();},0x7cf);};Preview['prototype'][_0xf40f('0x37')]=function(){var _0x7f816e=this[_0xf40f('0x11')];this[_0xf40f('0x15')]+=0x1;for(var _0x95ce3 in _0x7f816e){if(_0x7f816e['hasOwnProperty'](_0x95ce3)&&(_0x7f816e[_0x95ce3][_0xf40f('0x38')]==='preview'||_0x7f816e[_0x95ce3][_0xf40f('0x38')]===_0xf40f('0x39'))&&_0x7f816e[_0x95ce3]['type']==='outbound'){if(this[_0xf40f('0x15')]>0x7){this['clockClearZombieChannels']=0x0;this[_0xf40f('0x3a')]();}}if(_0x7f816e['hasOwnProperty'](_0x95ce3)&&_0x7f816e[_0x95ce3]['dialMethod']===_0xf40f('0x3b')&&_0x7f816e[_0x95ce3][_0xf40f('0x3c')]===_0xf40f('0x3d')){if(_0x7f816e[_0x95ce3]['dialActive']){this[_0xf40f('0x3e')](_0x7f816e[_0x95ce3]);if(_0x7f816e[_0x95ce3]['dialPreviewAutoRecallMe'])this[_0xf40f('0x3f')](_0x7f816e[_0x95ce3]);}else{notSendMessagesQueue(_0x7f816e[_0x95ce3]);}}}};Preview[_0xf40f('0xc')][_0xf40f('0x40')]=function(_0x2bca5d){var _0x4e543b=this;this[_0xf40f('0x10')]['enqueue'](function(){if(!_[_0xf40f('0x41')](_0x4e543b[_0xf40f('0x13')][_0x2bca5d])){loggerAction[_0xf40f('0x25')]('[clearZombieChannels][talking]',_0x2bca5d,_0xf40f('0x42'),_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x43')],_0xf40f('0x44'),JSON['stringify'](_0x4e543b[_0xf40f('0x11')][_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x43')]][_0xf40f('0x2c')]),'pTalking:\x20',JSON[_0xf40f('0x26')](_0x4e543b[_0xf40f('0x11')][_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x43')]][_0xf40f('0x2d')]),JSON[_0xf40f('0x26')](_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x45')]),JSON[_0xf40f('0x26')](_['pick'](_0x4e543b[_0xf40f('0x13')][_0x2bca5d],[_0xf40f('0x46'),_0xf40f('0x47'),'VoiceQueueId',_0xf40f('0x48')])));return ami[_0xf40f('0x49')]({'action':_0xf40f('0x4a'),'channel':_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x4b')]})[_0xf40f('0x4c')](function(_0x503af1){if(_0x503af1[_0xf40f('0x34')]===_0xf40f('0x4d')){setTimeout(function(){if(_0x4e543b[_0xf40f('0x13')][_0x2bca5d]){utils[_0xf40f('0x4e')](_0x4e543b[_0xf40f('0x11')][_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x43')]],_0xf40f('0x4f'));if(_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x45')]===!![]){ut[_0xf40f('0x50')](_0x4e543b[_0xf40f('0x11')][_0x4e543b[_0xf40f('0x13')][_0x2bca5d]['queue']],_0xf40f('0x4f'));ut[_0xf40f('0x51')](_0xf40f('0x52')+_0x2bca5d,_0x4e543b[_0xf40f('0x13')][_0x2bca5d]['queue']);}ut[_0xf40f('0x51')](_0xf40f('0x53')+_0x2bca5d,_0x4e543b[_0xf40f('0x13')][_0x2bca5d][_0xf40f('0x43')]);delete _0x4e543b['actions'][_0x2bca5d];}},0x2328);}});}});};Preview['prototype'][_0xf40f('0x3a')]=function(){var _0x3eea0f=this;loggerAction['info'](_0xf40f('0x54'),_[_0xf40f('0x55')](this[_0xf40f('0x13')]));for(var _0x359398 in this[_0xf40f('0x13')]){if(_0x3eea0f[_0xf40f('0x13')][_0xf40f('0x56')](_0x359398)){_0x3eea0f[_0xf40f('0x40')](_0x359398);}}};Preview[_0xf40f('0xc')][_0xf40f('0x3f')]=function(_0x58972d){var _0x27de23=this;rpcDb[_0xf40f('0x57')](_0x58972d['id'],ut[_0xf40f('0x58')](this[_0xf40f('0x14')]))[_0xf40f('0x59')](function(_0x508402){if(!_[_0xf40f('0x41')](_0x508402)){for(var _0x3b80f4=0x0;_0x3b80f4<_0x508402['length'];_0x3b80f4+=0x1){if(ut[_0xf40f('0x5a')](_0x508402[_0x3b80f4][_0xf40f('0x5b')])<_0x58972d[_0xf40f('0x5c')]*0x3c){if(_0x508402[_0x3b80f4]['Agent']&&!_0x508402[_0x3b80f4][_0xf40f('0x5d')][_0xf40f('0x5e')]){_0x27de23['run'](_0x508402[_0x3b80f4]['id'])[_0xf40f('0x59')](ut[_0xf40f('0x5f')](_0xf40f('0x60')))['catch'](ut[_0xf40f('0x5f')](_0xf40f('0x60')));}else{rpcDb[_0xf40f('0x61')](_0x508402[_0x3b80f4]['id']);}}else{var _0x563df3=new Action(_0x508402[_0x3b80f4],_0x58972d);_0x563df3[_0xf40f('0x62')]=moment()[_0xf40f('0x27')](_0xf40f('0x63'));_0x58972d[_0xf40f('0x64')]+=0x1;ut['logCustomer'](_0x563df3,0x17,_0xf40f('0x65'));if(_0x58972d['dialRecallInQueue']){rpcDb[_0xf40f('0x66')](ut[_0xf40f('0x67')](_0x508402[_0x3b80f4]));rpcDb[_0xf40f('0x68')](_0x563df3,_0xf40f('0x69'));}else{ut[_0xf40f('0x6a')](_0x563df3,0x16,_0xf40f('0x6b'));rpcDb[_0xf40f('0x68')](_0x563df3,_0xf40f('0x6c'));rpcDb[_0xf40f('0x6d')](_0x563df3,'[HistoryRecallClose]');}}}}})[_0xf40f('0x4c')](ut[_0xf40f('0x5f')](_0xf40f('0x6e')));};Preview[_0xf40f('0xc')][_0xf40f('0x3e')]=function(_0x39e29b){_0x39e29b[_0xf40f('0x2b')]=!![];if(ut[_0xf40f('0x6f')](_0x39e29b['loggedIn'])){_0x39e29b[_0xf40f('0x34')]=utils[_0xf40f('0x2f')]['NO_AGENTS_LOGGED'];}else if(!ut[_0xf40f('0x70')](_0x39e29b[_0xf40f('0x71')])){_0x39e29b[_0xf40f('0x34')]=utils[_0xf40f('0x2f')]['INACTIVE'];}else if(!this['isTrunkReachable'](_0x39e29b[_0xf40f('0x72')])){if(!this[_0xf40f('0x73')](_0x39e29b[_0xf40f('0x74')])){_0x39e29b[_0xf40f('0x34')]=utils[_0xf40f('0x2f')]['UNREACHABLE_TRUNK'];}else{_0x39e29b['message']=utils[_0xf40f('0x2f')]['ACTIVE'];}}else{_0x39e29b[_0xf40f('0x34')]=utils[_0xf40f('0x2f')][_0xf40f('0x75')];}};Preview[_0xf40f('0xc')][_0xf40f('0x76')]=function(_0x54f780,_0x6b9bb7,_0x3dcd34){var _0x414165=this;var _0x3bf62f=this[_0xf40f('0x13')][_0x6b9bb7];var _0xc089c4=this[_0xf40f('0x11')][_0x3bf62f[_0xf40f('0x43')]];var _0x5aa502;var _0x1dd912=![];var _0x31dbd4=0x2;var _0x3b83e9=0x3;if(_0xc089c4){switch(_0x3dcd34){case'1':_0xc089c4['outboundNoSuchCallsDay']+=0x1;_0x3bf62f[_0xf40f('0x77')]+=0x1;_0x3bf62f['countglobal']=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x0,_0xf40f('0x79'));ami[_0xf40f('0x24')](_0xf40f('0x7a'),ut['buildObj'](_0x3bf62f,_0xf40f('0x7b')));rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0x7c'));_0x414165[_0xf40f('0x7d')](_0x3bf62f,'0',_0xc089c4)[_0xf40f('0x59')](function(_0xa3a813){_0x1dd912=_0xa3a813[_0xf40f('0x7e')]==0x1;_0x31dbd4=_0xc089c4[_0xf40f('0x7f')];_0x3b83e9=_0xc089c4['callAdditionalPhoneAfterMin'];if(!_0x1dd912){if(ut[_0xf40f('0x78')](_0x3bf62f)>=_0xc089c4[_0xf40f('0x80')]){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,_0xf40f('0x83'));}else{if(_0x3bf62f[_0xf40f('0x77')]>=_0xc089c4[_0xf40f('0x84')]){rpcDb['createCustomerFinal'](_0x3bf62f,_0xf40f('0x83'));}else{rpcDb['rescheduleContact'](ut['scheduledAt'](_0x3bf62f,'countnosuchnumberretry',_0xc089c4[_0xf40f('0x7f')]),_0x3bf62f[_0xf40f('0x85')],_0x3bf62f[_0xf40f('0x86')]);}}delete this[_0xf40f('0x13')][_0x54f780[_0xf40f('0x87')]];}else{_0x3bf62f[_0xf40f('0x77')]++;logger[_0xf40f('0x25')](_0xf40f('0x88'),_0x3bf62f[_0xf40f('0x77')]);logger[_0xf40f('0x25')]('id',_0x3bf62f[_0xf40f('0x89')]);_0x414165['incrementPreviewCounters']({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnosuchnumberretry':_0x3bf62f['countnosuchnumberretry']}})[_0xf40f('0x59')](function(){_0x414165[_0xf40f('0x8a')](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});});}});break;case _0xf40f('0x8b'):var _0x17c9a7=moment()['format'](_0xf40f('0x63'));_0x3bf62f[_0xf40f('0x8c')]=_0x17c9a7;_0x3bf62f[_0xf40f('0x8d')]=_0x17c9a7;_0x3bf62f[_0xf40f('0x45')]=!![];_0xc089c4['pTalking']+=0x1;logger[_0xf40f('0x25')]('[syncHangup][talking][increment]',_0x3bf62f[_0xf40f('0x8e')],_0xf40f('0x8f'),_0xc089c4[_0xf40f('0x29')],_0xf40f('0x90'),_0xc089c4['pTalking']);ami['emit'](_0xf40f('0x91'),ut[_0xf40f('0x92')](_0x3bf62f,'connect',this['campaignsPreview'][_0x3bf62f[_0xf40f('0x43')]]));if(_0xc089c4['acw']||_0xc089c4[_0xf40f('0x93')]){ami[_0xf40f('0x24')](_0xf40f('0x94'),{'queue':_0x3bf62f[_0xf40f('0x43')],'interface':_0x3bf62f[_0xf40f('0x95')],'uniqueid':_0x3bf62f[_0xf40f('0x8e')]});}break;case'16':ami[_0xf40f('0x24')](_0xf40f('0x96'),ut[_0xf40f('0x92')](_0x3bf62f,_0xf40f('0x97'),this[_0xf40f('0x11')][_0x3bf62f[_0xf40f('0x43')]]));emitVoiceQueueChannelRemove(ut[_0xf40f('0x92')](_0x3bf62f,'complete'));_0xc089c4[_0xf40f('0x98')]+=0x1;_0xc089c4['total']+=0x1;_0xc089c4[_0xf40f('0x99')]+=0x1;ut[_0xf40f('0x50')](_0xc089c4,_0xf40f('0x9a'));_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x4,_0xf40f('0x9c'));rpcDb['createCustomerHistory'](_0x3bf62f,_0xf40f('0x9d'));rpcDb['createCustomerFinal'](_0x3bf62f,_0xf40f('0x9e'));rpcDb['crateCustomerReportQueue'](_0x3bf62f);_0xc089c4[_0xf40f('0x9f')]+=_0x3bf62f['talktime'];_0xc089c4['sumBillable']+=_0x3bf62f[_0xf40f('0xa0')];logger['info'](_0xf40f('0xa1'),_0x3bf62f[_0xf40f('0x8e')],'\x20Queue',_0xc089c4[_0xf40f('0x29')],_0xf40f('0x90'),_0xc089c4[_0xf40f('0x2d')]);delete this[_0xf40f('0x13')][_0x54f780['linkedid']];break;case _0xf40f('0xa2'):_0xc089c4[_0xf40f('0xa3')]+=0x1;_0x3bf62f['countbusyretry']+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut['totalGlobal'](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x5,_0xf40f('0xa4'));_0x31dbd4=_0xc089c4[_0xf40f('0xa5')];_0x3b83e9=_0xc089c4[_0xf40f('0xa6')];ami['emit'](_0xf40f('0xa7'),ut['buildObj'](_0x3bf62f,'busy'));rpcDb[_0xf40f('0x68')](_0x3bf62f,'[callProgressDetectingCustomer][logBusy]');_0x414165[_0xf40f('0x7d')](_0x3bf62f,'5',_0xc089c4)[_0xf40f('0x59')](function(_0x4d31c9){_0x1dd912=_0x4d31c9[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut[_0xf40f('0x78')](_0x3bf62f)>=_0xc089c4['dialGlobalMaxRetry']){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,_0xf40f('0xa8'));}else{if(_0x3bf62f[_0xf40f('0xa9')]>=_0xc089c4['dialBusyMaxRetry']){rpcDb[_0xf40f('0x6d')](_0x3bf62f,'[callProgressDetectingCustomer][logBusy]');}else{rpcDb['rescheduleContact'](ut['scheduledAt'](_0x3bf62f,_0xf40f('0xa9'),_0xc089c4[_0xf40f('0xa5')]),_0x3bf62f[_0xf40f('0x85')],_0x3bf62f[_0xf40f('0x86')]);}}}else{_0x3bf62f['countbusyretry']++;_0x414165[_0xf40f('0xaa')]({'id':_0x3bf62f['idContact'],'field':{'countbusyretry':_0x3bf62f[_0xf40f('0xa9')]}})['then'](function(){_0x414165['swapAdditionalPhones'](_0x3bf62f,_0x31dbd4,_0x3b83e9)['then'](function(){});});}});break;case _0xf40f('0xab'):_0xc089c4[_0xf40f('0xac')]+=0x1;_0x3bf62f[_0xf40f('0xad')]+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x3,_0xf40f('0xae'));_0x31dbd4=_0xc089c4[_0xf40f('0xaf')];_0x3b83e9=_0xc089c4['callAdditionalPhoneAfterMin'];var _0x38b79a=ut['buildNoAnswerEventPayload'](_0x3bf62f,_0xc089c4);ami[_0xf40f('0x24')]('custom:agentnoanswer',_0x38b79a);rpcDb[_0xf40f('0x68')](_0x3bf62f,'[callProgressDetectingCustomer][logNoAnswer]');_0x414165['verifyAdditionalPhones'](_0x3bf62f,'3',_0xc089c4)[_0xf40f('0x59')](function(_0x24f1b3){_0x1dd912=_0x24f1b3['additional']==0x1;if(!_0x1dd912){if(ut['totalGlobal'](_0x3bf62f)>=_0xc089c4['dialGlobalMaxRetry']){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,_0xf40f('0xb0'));}else{if(_0x3bf62f[_0xf40f('0xad')]>=_0xc089c4[_0xf40f('0xb1')]){rpcDb[_0xf40f('0x6d')](_0x3bf62f,_0xf40f('0xb2'));}else{rpcDb[_0xf40f('0xb3')](ut[_0xf40f('0xb4')](_0x3bf62f,'countnoanswerretry',_0xc089c4[_0xf40f('0xaf')]),_0x3bf62f[_0xf40f('0x85')],_0x3bf62f[_0xf40f('0x86')]);}}}else{_0x3bf62f[_0xf40f('0xad')]++;_0x414165[_0xf40f('0xaa')]({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnoanswerretry':_0x3bf62f[_0xf40f('0xad')]}})[_0xf40f('0x59')](function(){_0x414165[_0xf40f('0x8a')](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});});}});break;case _0xf40f('0xb5'):_0xc089c4['outboundCongestionCallsDay']+=0x1;_0x3bf62f['countcongestionretry']+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x8,_0xf40f('0xb6'));_0x31dbd4=_0xc089c4[_0xf40f('0xb7')];_0x3b83e9=_0xc089c4[_0xf40f('0xa6')];ami[_0xf40f('0x24')](_0xf40f('0xb8'),ut[_0xf40f('0x92')](_0x3bf62f,'congestion'));rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0xb9'));_0x414165[_0xf40f('0x7d')](_0x3bf62f,'8',_0xc089c4)[_0xf40f('0x59')](function(_0x267ff7){_0x1dd912=_0x267ff7[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut['totalGlobal'](_0x3bf62f)>=_0xc089c4['dialGlobalMaxRetry']){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,'[callProgressDetectingCustomer][logCongestionGlobal]');}else{if(_0x3bf62f['countcongestionretry']>=_0xc089c4[_0xf40f('0xba')]){rpcDb[_0xf40f('0x6d')](_0x3bf62f,_0xf40f('0xb9'));}else{rpcDb['rescheduleContact'](ut[_0xf40f('0xb4')](_0x3bf62f,_0xf40f('0xbb'),_0xc089c4[_0xf40f('0xa5')]),_0x3bf62f[_0xf40f('0x85')],_0x3bf62f[_0xf40f('0x86')]);}}}else{_0x3bf62f[_0xf40f('0xbb')]++;_0x414165['incrementPreviewCounters']({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countcongestionretry':_0x3bf62f[_0xf40f('0xbb')]}})[_0xf40f('0x59')](function(){_0x414165['swapAdditionalPhones'](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});});}});break;case _0xf40f('0xbc'):_0xc089c4['outboundRejectCallsDay']+=0x1;_0x3bf62f['countagentrejectretry']+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x14,'AgentReject');_0x31dbd4=_0xc089c4[_0xf40f('0xbd')];_0x3b83e9=_0xc089c4[_0xf40f('0xa6')];ami[_0xf40f('0x24')](_0xf40f('0xbe'),ut[_0xf40f('0x92')](_0x3bf62f,'agentreject'));rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0xbf'));_0x414165[_0xf40f('0x7d')](_0x3bf62f,'20',_0xc089c4)[_0xf40f('0x59')](function(_0x291e52){_0x1dd912=_0x291e52[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut[_0xf40f('0x78')](_0x3bf62f)>=_0xc089c4['dialGlobalMaxRetry']){_0x5aa502=ut['cloneAction'](_0x3bf62f,0x14,_0xf40f('0xc0'));rpcDb['createCustomerFinal'](_0x5aa502,_0xf40f('0xc1'));}else{if(_0x3bf62f[_0xf40f('0xc2')]>=_0xc089c4[_0xf40f('0xc3')]){rpcDb['createCustomerFinal'](_0x3bf62f,_0xf40f('0xc1'));}else{rpcDb[_0xf40f('0xb3')](ut[_0xf40f('0xb4')](_0x3bf62f,_0xf40f('0xc2'),_0xc089c4['dialAgentRejectRetryFrequency']),_0x3bf62f[_0xf40f('0x85')],_0x3bf62f[_0xf40f('0x86')]);}}}else{_0x3bf62f[_0xf40f('0xad')]++;_0x414165[_0xf40f('0xaa')]({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnoanswerretry':_0x3bf62f[_0xf40f('0xad')]}})[_0xf40f('0x59')](function(){_0x414165['swapAdditionalPhones'](_0x3bf62f,_0x31dbd4,_0x3b83e9)['then'](function(){});});}});break;case _0xf40f('0xc4'):_0xc089c4[_0xf40f('0xc5')]+=0x1;_0x3bf62f[_0xf40f('0xc6')]+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0xb,_0xf40f('0xc7'));rpcDb['createCustomerHistory'](_0x3bf62f,_0xf40f('0xc8'));_0x414165[_0xf40f('0x7d')](_0x3bf62f,'11',_0xc089c4)[_0xf40f('0x59')](function(_0x2a87c1){_0x1dd912=_0x2a87c1[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut['totalGlobal'](_0x3bf62f)>=_0xc089c4['dialGlobalMaxRetry']){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,'Global');rpcDb['createCustomerFinal'](_0x5aa502,_0xf40f('0xc8'));}else{if(_0x3bf62f[_0xf40f('0xc9')]>=_0xc089c4['dialAbandonedMaxRety']){rpcDb[_0xf40f('0x6d')](_0x3bf62f,_0xf40f('0xc8'));}else{rpcDb[_0xf40f('0xb3')](ut[_0xf40f('0xb4')](_0x3bf62f,'countabandonedretry',_0xc089c4['dialAbandonedRetryFrequency']),_0x3bf62f['unlockAgent'],_0x3bf62f['activeContact']);}}}else{_0x3bf62f[_0xf40f('0xad')]++;_0x414165[_0xf40f('0xaa')]({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnoanswerretry':_0x3bf62f[_0xf40f('0xad')]}})['then'](function(){_0x414165[_0xf40f('0x8a')](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});});}});break;case'18':_0xc089c4[_0xf40f('0xca')]+=0x1;_0x3bf62f[_0xf40f('0xcb')]+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut['totalGlobal'](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x12,_0x54f780[_0xf40f('0xcc')]||_0x54f780[_0xf40f('0xcd')]);ami['emit'](_0xf40f('0xce'),ut['buildObj'](_0x3bf62f,'amd'));rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0xcf'));_0x414165[_0xf40f('0x7d')](_0x3bf62f,'18',_0xc089c4)['then'](function(_0x5169c5){_0x1dd912=_0x5169c5[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut[_0xf40f('0x78')](_0x3bf62f)>=_0xc089c4[_0xf40f('0x80')]){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0x12,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,_0xf40f('0xcf'));}else{rpcDb['createCustomerFinal'](_0x3bf62f,_0xf40f('0xcf'));}}else{_0x3bf62f[_0xf40f('0xad')]++;_0x414165['incrementPreviewCounters']({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnoanswerretry':_0x3bf62f[_0xf40f('0xad')]}})[_0xf40f('0x59')](function(){_0x414165[_0xf40f('0x8a')](_0x3bf62f,_0x31dbd4,_0x3b83e9)['then'](function(){});});}});delete this['actions'][_0x54f780[_0xf40f('0x87')]];break;case'19':_0xc089c4[_0xf40f('0xca')]+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut[_0xf40f('0x78')](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0x13,_0x54f780[_0xf40f('0xcc')]||_0x54f780[_0xf40f('0xcd')]);ami[_0xf40f('0x24')]('custom:amd',ut[_0xf40f('0x92')](_0x3bf62f,_0xf40f('0xd0')));rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0xd1'));_0x414165['verifyAdditionalPhones'](_0x3bf62f,'18',_0xc089c4)[_0xf40f('0x59')](function(_0xa350fd){_0x1dd912=_0xa350fd['additional']==0x1;if(!_0x1dd912){if(ut[_0xf40f('0x78')](_0x3bf62f)>=_0xc089c4[_0xf40f('0x80')]){_0x5aa502=ut[_0xf40f('0x81')](_0x3bf62f,0xf,'Global');rpcDb[_0xf40f('0x6d')](_0x5aa502,'[callProgressDetectingCustomer][machine]');}else{rpcDb['createCustomerFinal'](_0x3bf62f,_0xf40f('0xd1'));}}else{_0x3bf62f[_0xf40f('0xad')]++;_0x414165[_0xf40f('0xaa')]({'id':_0x3bf62f[_0xf40f('0x89')],'field':{'countnoanswerretry':_0x3bf62f[_0xf40f('0xad')]}})['then'](function(){_0x414165[_0xf40f('0x8a')](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});});}});delete this[_0xf40f('0x13')][_0x54f780['linkedid']];break;default:if(_0x3bf62f[_0xf40f('0x45')]){ut[_0xf40f('0x50')](_0xc089c4,_0xf40f('0xd2'));ut[_0xf40f('0x51')]('[Dialer][decrementTalking][no\x20Hangup][Preview]'+_0xc089c4['name'],_0x54f780);}_0xc089c4[_0xf40f('0xca')]+=0x1;_0x3bf62f[_0xf40f('0x9b')]=ut['totalGlobal'](_0x3bf62f);ut[_0xf40f('0x6a')](_0x3bf62f,0xc,_0x54f780[_0xf40f('0xcc')]||_0x54f780[_0xf40f('0xcd')]);_0x31dbd4=_0xc089c4[_0xf40f('0xbd')];_0x3b83e9=_0xc089c4[_0xf40f('0xa6')];rpcDb[_0xf40f('0x68')](_0x3bf62f,_0xf40f('0xd3'));_0x414165['verifyAdditionalPhones'](_0x3bf62f,'20',_0xc089c4)[_0xf40f('0x59')](function(_0x35c42c){_0x1dd912=_0x35c42c[_0xf40f('0x7e')]==0x1;if(!_0x1dd912){if(ut['totalGlobal'](_0x3bf62f)>=_0xc089c4[_0xf40f('0x80')]){_0x5aa502=ut['cloneAction'](_0x3bf62f,0xf,_0xf40f('0x82'));rpcDb[_0xf40f('0x6d')](_0x5aa502,_0xf40f('0xd4'));}else{rpcDb[_0xf40f('0x6d')](_0x3bf62f,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0xf40f('0x13')][_0x54f780[_0xf40f('0x87')]];}else{_0x414165['swapAdditionalPhones'](_0x3bf62f,_0x31dbd4,_0x3b83e9)[_0xf40f('0x59')](function(){});}});}if(!(_0x3bf62f['dialAnswer']&&_0x3dcd34==='16')){utils[_0xf40f('0x4e')](_0xc089c4,_0xf40f('0xd5'));logger['info'](_0xf40f('0xd6'),_0x3bf62f[_0xf40f('0x8e')],'\x20Queue',_0xc089c4[_0xf40f('0x29')],'originated:\x20',_0xc089c4[_0xf40f('0x2c')]);}if(_0x3dcd34!==_0xf40f('0x8b')){delete this[_0xf40f('0x13')][_0x54f780[_0xf40f('0x87')]];delete this[_0xf40f('0x13')][_0x54f780[_0xf40f('0xd7')]];}_0xc089c4[_0xf40f('0xd8')]=!![];}};Preview['prototype'][_0xf40f('0xd9')]=function(_0xc5b1cb,_0xea5eb1,_0x2e429d){if(_[_0xf40f('0xda')](_0xea5eb1)&&_0xf40f('0xdb')!==typeof _0xea5eb1){return;}if(_[_0xf40f('0xda')](_0x2e429d)&&_0xf40f('0xdb')!==typeof _0x2e429d){return;}switch(_0x2e429d['reason']){case'0':ut[_0xf40f('0xdc')](_0xc5b1cb,0x0,_0xf40f('0x79'));rpcDb[_0xf40f('0xdd')](_0xc5b1cb,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut[_0xf40f('0xdc')](_0xc5b1cb,0x3,_0xf40f('0xae'));rpcDb[_0xf40f('0xdd')](_0xc5b1cb,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xf40f('0xdc')](_0xc5b1cb,0x5,'Busy');rpcDb[_0xf40f('0xdd')](_0xc5b1cb,_0xf40f('0xde'));break;case'8':ut[_0xf40f('0xdc')](_0xc5b1cb,0x8,'Congestion');rpcDb[_0xf40f('0xdd')](_0xc5b1cb,_0xf40f('0xdf'));break;case'22':ut[_0xf40f('0xdc')](_0xc5b1cb,0x16,'AnswerAGI');rpcDb[_0xf40f('0xdd')](_0xc5b1cb,_0xf40f('0xe0'));break;default:ut[_0xf40f('0xdc')](_0xc5b1cb,0xc,_0x2e429d[_0xf40f('0xe1')]);rpcDb['createAgentHistory'](_0xc5b1cb,_0xf40f('0xdf'));}utils[_0xf40f('0x4e')](_0xea5eb1,'[callProgressDetectingAgent]');logger[_0xf40f('0x25')](_0xf40f('0xe2'),_0xc5b1cb['uniqueid'],_0xf40f('0x8f'),_0xea5eb1[_0xf40f('0x29')],_0xf40f('0x44'),_0xea5eb1[_0xf40f('0x2c')]);delete this[_0xf40f('0x13')][_0xc5b1cb['uniqueid']];};Preview['prototype']['verifyAdditionalPhones']=function(_0xbcd73b,_0x327fd1,_0x12ff27){return cmHopperAdditionalPhone['verifyAdditionalPhones'](_0xbcd73b,_0x327fd1,_0x12ff27)['catch'](logger[_0xf40f('0x25')](_0xf40f('0xe3')));};Preview[_0xf40f('0xc')]['swapAdditionalPhones']=function(_0x410b5d,_0x2c6bc8,_0x2dc1e0){return cmHopperAdditionalPhone[_0xf40f('0x8a')](_0x410b5d,_0x2c6bc8,_0x2dc1e0)['catch'](logger[_0xf40f('0x25')](_0xf40f('0xe4')));};Preview['prototype'][_0xf40f('0xaa')]=function(_0x56ec97){return Promise[_0xf40f('0xe5')]()[_0xf40f('0x59')](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x56ec97))[_0xf40f('0x4c')](logger[_0xf40f('0x25')](_0xf40f('0xe6')));};Preview[_0xf40f('0xc')][_0xf40f('0xe7')]=function(_0x3b29dc,_0x1314f5,_0x267d57,_0x380209,_0x34244c){var _0x41c2d9=this;return new Promise(function(_0x35f205,_0x224b20){if(_[_0xf40f('0x41')](_0x1314f5)||_[_0xf40f('0x41')](_0x1314f5['Contact'])||_['isNil'](_0x1314f5['phone'])||_[_0xf40f('0x41')](_0x1314f5['VoiceQueueId'])){_0x224b20(ut[_0xf40f('0x34')]('Contact\x20is\x20undefined',_0x380209,_0x34244c));return;}var _0x632003=uuid['v4']();var _0xa02459=_0x41c2d9[_0xf40f('0x11')][_0x1314f5['Queue']['name']];var _0x22521=_0x267d57?_0x41c2d9[_0xf40f('0x14')][_0x267d57]['id']:undefined;_0x41c2d9[_0xf40f('0x13')][_0x632003]=new Action(_0x1314f5,_0xa02459,_0x632003,_0x267d57,_0x22521);var _0x4e994a=_0x41c2d9['actions'][_0x632003];_0x4e994a['unlockAgent']=_0x380209;_0x4e994a['activeContact']=_0x34244c;_0x4e994a[_0xf40f('0xe8')]=_0x267d57;if(_[_0xf40f('0xe9')](_0x3b29dc)){_0x41c2d9[_0xf40f('0xea')](_0x4e994a,_0xa02459,_0x1314f5,_0x267d57)[_0xf40f('0x59')](function(_0x58c679){logger[_0xf40f('0x25')]('[Preview][execCall][success]',_0xf40f('0xeb')+_0x4e994a[_0xf40f('0x43')]+'\x20IdHopper:\x20'+_0x4e994a[_0xf40f('0x89')],JSON[_0xf40f('0x26')](_0x58c679));ami[_0xf40f('0x24')]('custom:agentcalled',ut[_0xf40f('0x92')](_0x4e994a,_0xf40f('0xec'),_0x41c2d9[_0xf40f('0x11')][_0x4e994a['queue']]));_0x35f205(ut[_0xf40f('0x34')](_0xf40f('0xed')));})[_0xf40f('0x4c')](function(_0x583d28){ut[_0xf40f('0x31')](_0xf40f('0xee'),_0x583d28);_0x224b20(ut[_0xf40f('0x34')](_0xf40f('0xef'),_0x380209,_0x34244c));});}else{_0xa02459[_0xf40f('0xf0')]+=0x1;ut[_0xf40f('0xf1')](_0x4e994a);rpcDb[_0xf40f('0xf2')](_0x4e994a,_0xf40f('0xf3'));delete _0x41c2d9[_0xf40f('0x13')][_0x632003];_0x224b20(ut[_0xf40f('0x34')]('Contact\x20in\x20black\x20List',_0x380209,_0x34244c));}});};Preview[_0xf40f('0xc')][_0xf40f('0x73')]=function(_0x546fba){return!_[_0xf40f('0x41')](_0x546fba)&&!_['isNil'](_0x546fba[_0xf40f('0x29')])&&!_[_0xf40f('0x41')](_0x546fba[_0xf40f('0xf4')])&&_0x546fba[_0xf40f('0xf4')]&&!_['isNil'](this[_0xf40f('0xf5')][util['format'](_0xf40f('0xf6'),_0x546fba[_0xf40f('0x29')])])&&!_['isNil'](this[_0xf40f('0xf5')][util[_0xf40f('0x27')]('SIP/%s',_0x546fba[_0xf40f('0x29')])][_0xf40f('0x4a')])&&(this[_0xf40f('0xf5')][util[_0xf40f('0x27')]('SIP/%s',_0x546fba[_0xf40f('0x29')])][_0xf40f('0x4a')]===_0xf40f('0xf7')||this['trunks'][util[_0xf40f('0x27')]('SIP/%s',_0x546fba['name'])][_0xf40f('0x4a')]===_0xf40f('0xf8'));};Preview[_0xf40f('0xc')][_0xf40f('0xf9')]=function(_0x4dc76b,_0x9896cb){return this[_0xf40f('0xfa')](_0x4dc76b,_0x9896cb)[_0xf40f('0x59')](function(_0x515c4d){return _[_0xf40f('0xfb')](_0x515c4d,[_0xf40f('0x34')]);})[_0xf40f('0x4c')](function(_0x397077){if(_0x397077[_0xf40f('0xfc')]){rpcDb[_0xf40f('0xfd')](_0x4dc76b);}if(_0x397077['active']){rpcDb[_0xf40f('0x61')](_0x4dc76b);}throw _[_0xf40f('0xfb')](_0x397077,[_0xf40f('0x34')]);});};Preview[_0xf40f('0xc')][_0xf40f('0xfa')]=function(_0x72f9ec,_0xff3d4b){var _0x149ed9=this;var _0x20fae9,_0x272e27;return rpcDb[_0xf40f('0xfe')](_0x72f9ec)['then'](function(_0x11a9bc){if(!_[_0xf40f('0x41')](_0x11a9bc[0x0])){_0x272e27=_0x11a9bc[0x0][_0xf40f('0xff')]?![]:!![];_0x20fae9=_0x11a9bc[0x0][_0xf40f('0xff')]?!![]:![];_0x20fae9=_0xff3d4b?!![]:_0x20fae9;}var _0x361821=_0x149ed9[_0xf40f('0x100')](_0x11a9bc);if(_0x361821['isValid']){rpcDb[_0xf40f('0x101')](_[_0xf40f('0xfb')](_0x11a9bc[0x0],[_0xf40f('0x102'),_0xf40f('0x103')]))['then'](function(_0x555ed6){_0x149ed9[_0xf40f('0xe7')](_0x555ed6,_0x11a9bc[0x0],_0xff3d4b,_0x272e27,_0x20fae9)['then'](function(_0x52db5d){return _0x52db5d;})['catch'](function(_0x47421d){throw _0x47421d;});})['catch'](function(_0x5805dc){ut[_0xf40f('0x31')](_0xf40f('0x104'),_0x5805dc);throw ut[_0xf40f('0x34')](_0xf40f('0x105'),_0x272e27,_0x20fae9);});}else{throw ut[_0xf40f('0x34')](_0x361821[_0xf40f('0x34')],_0x272e27,_0x20fae9);}})[_0xf40f('0x4c')](function(_0x3884b1){ut['logger'](_0xf40f('0x106'),_0x3884b1);throw ut['message'](_0xf40f('0x105'),![],!![]);});};Preview[_0xf40f('0xc')][_0xf40f('0x100')]=function(_0x352941){if(_[_0xf40f('0x41')](_0x352941)||_['isEmpty'](_0x352941)||!_['isNil'](_0x352941[0x0][_0xf40f('0x5d')])&&_['isNil'](_0x352941[0x0][_0xf40f('0x5d')]['name'])){ut[_0xf40f('0x31')](_0xf40f('0x107'),_0x352941);return{'isValid':![],'message':_0xf40f('0x108')};}var _0x7f01e3=this[_0xf40f('0x11')][_0x352941[0x0][_0xf40f('0x42')][_0xf40f('0x29')]];_0x7f01e3[_0xf40f('0x34')]=utils[_0xf40f('0x2f')][_0xf40f('0x75')];if(_['isNil'](_0x7f01e3)){ut['logger'](_0xf40f('0x109'),_0x7f01e3);return{'isValid':![],'message':_0xf40f('0x10a')};}if(!this[_0xf40f('0x73')](_0x7f01e3[_0xf40f('0x72')])){ut[_0xf40f('0x31')]('[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20'+_0x7f01e3[_0xf40f('0x29')]+_0xf40f('0x10b'));if(!this[_0xf40f('0x73')](_0x7f01e3[_0xf40f('0x74')])){ut[_0xf40f('0x31')](_0xf40f('0x10c'),_0x7f01e3[_0xf40f('0x29')]+_0xf40f('0x10d'));return{'isValid':![],'message':_0xf40f('0x10e')};}}if(!ut[_0xf40f('0x70')](_0x7f01e3[_0xf40f('0x71')])){ut[_0xf40f('0x31')]('[Preview][validateContact][Campaign\x20Active]',_0x7f01e3[_0xf40f('0x29')]+'\x20Not\x20Active');return{'isValid':![],'message':_0xf40f('0x10f')+_0x7f01e3[_0xf40f('0x29')]+_0xf40f('0x110')};}return{'isValid':!![],'message':_0xf40f('0x111')};};Preview[_0xf40f('0xc')]['execCall']=function(_0x5eeae3,_0xcf3b8e,_0x20c99e,_0x44d99a){var _0x314dd2=this;return new Promise(function(_0x1b0843,_0x59d225){var _0x5560e0=_0x5eeae3['uniqueid'];var _0x56f68b=_0x314dd2[_0xf40f('0x73')](_0xcf3b8e[_0xf40f('0x72')])?util[_0xf40f('0x27')](_0xf40f('0x112'),_0xcf3b8e[_0xf40f('0x72')][_0xf40f('0x29')],_[_0xf40f('0x41')](_0xcf3b8e[_0xf40f('0x113')])?'':_0xcf3b8e['dialPrefix'][_0xf40f('0x114')]()||'',_0xcf3b8e[_0xf40f('0x115')]>0x0?_0x20c99e['phone']['substring'](_0xcf3b8e['dialCutDigit']):_0x20c99e[_0xf40f('0x103')]):util[_0xf40f('0x27')](_0xf40f('0x112'),_[_0xf40f('0x41')](_0xcf3b8e[_0xf40f('0x74')])?_0xcf3b8e[_0xf40f('0x72')]['name']:_0xcf3b8e['TrunkBackup'][_0xf40f('0x29')],_[_0xf40f('0x41')](_0xcf3b8e['dialPrefix'])?'':_0xcf3b8e[_0xf40f('0x113')][_0xf40f('0x114')]()||'',_0xcf3b8e['dialCutDigit']>0x0?_0x20c99e['phone']['substring'](_0xcf3b8e[_0xf40f('0x115')]):_0x20c99e[_0xf40f('0x103')]);var _0x4b93f5=_0x314dd2['isTrunkReachable'](_0xcf3b8e[_0xf40f('0x72')])?ut['getCallerId'](_0xcf3b8e[_0xf40f('0x72')][_0xf40f('0x116')],_0xcf3b8e[_0xf40f('0x117')],_0xcf3b8e[_0xf40f('0x118')]>0x0?ut['getCallerIdRandom'](_0xcf3b8e[_0xf40f('0x119')],_0xcf3b8e[_0xf40f('0x118')]):_0xcf3b8e['dialOriginateCallerIdNumber']):ut[_0xf40f('0x11a')](_[_0xf40f('0x41')](_0xcf3b8e[_0xf40f('0x74')])?_0xcf3b8e[_0xf40f('0x72')][_0xf40f('0x116')]:_0xcf3b8e[_0xf40f('0x74')][_0xf40f('0x116')],_0xcf3b8e['dialOriginateCallerIdName'],_0xcf3b8e[_0xf40f('0x118')]>0x0?ut[_0xf40f('0x11b')](_0xcf3b8e['dialOriginateCallerIdNumber'],_0xcf3b8e[_0xf40f('0x118')]):_0xcf3b8e[_0xf40f('0x119')]);if(_0x4b93f5){_0x5eeae3[_0xf40f('0x11c')]=ut[_0xf40f('0x11d')](_0x4b93f5);_0x5eeae3['originatecalleridnum']=ut[_0xf40f('0x11e')](_0x4b93f5);}var _0x196b56=ut[_0xf40f('0x11f')](_0xcf3b8e,_0x20c99e,_0x56f68b,_0x4b93f5,_0x5560e0,_0x5eeae3);var _0x44f6c4=utils[_0xf40f('0x120')](_0x20c99e['Contact']);Object['assign'](_0x196b56,_0x44f6c4);_[_0xf40f('0x121')](_0x5eeae3,ut[_0xf40f('0x122')](_0x196b56));_0x5eeae3['starttime']=moment()[_0xf40f('0x27')](_0xf40f('0x63'));_0xcf3b8e[_0xf40f('0x123')]=_0x196b56;var _0x18f13f=ut['variablesAction'](_0x5eeae3,_0xcf3b8e,_0x196b56,_0x5eeae3[_0xf40f('0x86')],_0x44d99a);return ami['Action'](_0x18f13f)[_0xf40f('0x59')](function(_0x28f62d){_0xcf3b8e['originated']+=0x1;logger[_0xf40f('0x25')](_0xf40f('0x124'),_0x5560e0,'\x20Queue',_0xcf3b8e[_0xf40f('0x29')],_0xf40f('0x44'),_0xcf3b8e[_0xf40f('0x2c')]);_0x1b0843(_0x28f62d);})[_0xf40f('0x4c')](function(_0x1f3528){ut['logAgent'](_0x5eeae3,0xe,_0xf40f('0x125'));rpcDb[_0xf40f('0xdd')](_0x5eeae3,_0xf40f('0x126'));_0x59d225(_0x1f3528);});});};Preview['prototype']['syncNewExten']=function(_0x147478){if(this[_0xf40f('0x13')][_0x147478[_0xf40f('0x87')]]){this[_0xf40f('0x13')][_0x147478[_0xf40f('0x87')]][_0xf40f('0x4b')]=_0x147478[_0xf40f('0x4b')];}};Preview[_0xf40f('0xc')][_0xf40f('0x127')]=function(_0xccce21){var _0x25fdcb=this;var _0x5a6636=this[_0xf40f('0x13')][_0xccce21[_0xf40f('0x128')]];if(_0x5a6636){if(_0x5a6636[_0xf40f('0xe8')]&&this[_0xf40f('0x14')][_0x5a6636[_0xf40f('0xe8')]]){ut[_0xf40f('0x129')](_0x5a6636,this[_0xf40f('0x14')][_0x5a6636[_0xf40f('0xe8')]][_0xf40f('0x29')],this['agents'][_0x5a6636[_0xf40f('0xe8')]]['id']);}var _0x18a714=_[_0xf40f('0x12a')](_0x5a6636);_0x18a714['responsetime']=moment()[_0xf40f('0x27')](_0xf40f('0x63'));var _0x4af3ea=_0x25fdcb[_0xf40f('0x11')][_0x5a6636['queue']];if(ut['isFailure'](_0xccce21['response'])){if(_0x5a6636[_0xf40f('0x85')]){rpcDb[_0xf40f('0xfd')](_0x5a6636[_0xf40f('0x89')]);}if(_0x5a6636['activeContact']){rpcDb[_0xf40f('0x61')](_0x5a6636[_0xf40f('0x89')]);}ami[_0xf40f('0x24')]('custom:agentringnoanswer',ut['buildObj'](_0x5a6636,_0xf40f('0x12b'),this[_0xf40f('0x11')][_0x5a6636[_0xf40f('0x43')]]));this[_0xf40f('0xd9')](_0x18a714,_0x4af3ea,_0xccce21);}else{_0x5a6636[_0xf40f('0x62')]=moment()['format'](_0xf40f('0x63'));ut['logAgent'](_0x18a714,0x4,_0xf40f('0x9c'));rpcDb[_0xf40f('0xdd')](_0x18a714,_0xf40f('0x12c'));}}};Preview['prototype'][_0xf40f('0x18')]=function(_0x63d344){var _0x4f114e=this[_0xf40f('0x13')][_0x63d344[_0xf40f('0x87')]];var _0xab2c0a;if(_0x4f114e){_0xab2c0a=this[_0xf40f('0x11')][_0x4f114e['queue']];logger[_0xf40f('0x25')](_0xf40f('0x12d'),_0x63d344['linkedid'],_0xf40f('0x8f'),_0xab2c0a[_0xf40f('0x29')],'pTalking:\x20',_0xab2c0a[_0xf40f('0x2d')]);}if(this[_0xf40f('0x13')][_0x63d344['linkedid']]&&_0x63d344['linkedid']!==_0x63d344[_0xf40f('0x8e')]){if(_0x63d344[_0xf40f('0x12e')]==='16'&&this['actions'][_0x63d344[_0xf40f('0x87')]][_0xf40f('0x45')]){this[_0xf40f('0x76')](_0x63d344,_0x63d344[_0xf40f('0x87')],_0x63d344[_0xf40f('0x12e')]);}else if(this[_0xf40f('0x13')][_0x63d344[_0xf40f('0x87')]][_0xf40f('0x45')]){logger[_0xf40f('0x25')](_0xf40f('0x12f'),_0x63d344['linkedid'],_0x63d344[_0xf40f('0x12e')],'\x20Queue',_0xab2c0a['name'],_0xf40f('0x90'),_0xab2c0a[_0xf40f('0x2d')]);this[_0xf40f('0x76')](_0x63d344,_0x63d344[_0xf40f('0x87')],_0x63d344['cause']);}}else if(_0x4f114e&&_[_0xf40f('0x41')](_0x4f114e[_0xf40f('0x130')])&&_0xab2c0a[_0xf40f('0x131')]&&_0x63d344[_0xf40f('0x87')]===_0x63d344[_0xf40f('0x8e')]&&_[_0xf40f('0x41')](_0x63d344[_0xf40f('0xe1')])&&_0x63d344[_0xf40f('0x12e')]==='16'&&_0x63d344[_0xf40f('0x132')]==='6'&&_[_0xf40f('0xda')](_0x4f114e[_0xf40f('0x133')])){if(_0x4f114e[_0xf40f('0x85')]){rpcDb[_0xf40f('0xfd')](_0x4f114e['idContact']);}if(_0x4f114e['activeContact']){rpcDb[_0xf40f('0x61')](_0x4f114e['idContact']);}_0x63d344[_0xf40f('0xe1')]='22';this[_0xf40f('0xd9')](_0x4f114e,_0xab2c0a,_0x63d344);}else if(_0x4f114e&&_0x4f114e['transfer']){if(_0x63d344[_0xf40f('0x12e')]==='16'&&this['actions'][_0x63d344['linkedid']][_0xf40f('0x45')]){logger[_0xf40f('0x25')](_0xf40f('0x134'),_0x63d344[_0xf40f('0x87')],_0x63d344[_0xf40f('0x12e')],_0xf40f('0x8f'),_0xab2c0a[_0xf40f('0x29')],_0xf40f('0x90'),_0xab2c0a[_0xf40f('0x2d')]);this[_0xf40f('0x76')](_0x63d344,_0x63d344[_0xf40f('0x87')],_0x63d344['cause']);}else if(this['actions'][_0x63d344['linkedid']][_0xf40f('0x45')]){logger[_0xf40f('0x25')]('[syncHangup][talking][cause]',_0x63d344['linkedid'],_0x63d344[_0xf40f('0x12e')],_0xf40f('0x8f'),_0xab2c0a[_0xf40f('0x29')],_0xf40f('0x90'),_0xab2c0a['pTalking']);this[_0xf40f('0x76')](_0x63d344,_0x63d344[_0xf40f('0x87')],_0x63d344['cause']);}}};Preview[_0xf40f('0xc')][_0xf40f('0x1b')]=function(_0x22f48e){if(this[_0xf40f('0x13')][_0x22f48e[_0xf40f('0xd7')]]&&_0x22f48e[_0xf40f('0xd7')]!==_0x22f48e[_0xf40f('0x135')]){this[_0xf40f('0x76')](_0x22f48e,_0x22f48e['destlinkedid'],_0x22f48e[_0xf40f('0xcd')]);}};Preview[_0xf40f('0xc')]['syncHangupRequest']=function(_0x33255f){if(this['actions'][_0x33255f['linkedid']]&&_0x33255f[_0xf40f('0x87')]!==_0x33255f[_0xf40f('0x8e')]&&!this[_0xf40f('0x13')][_0x33255f[_0xf40f('0x87')]][_0xf40f('0x45')]){if(_0x33255f['cause']==='1'){this[_0xf40f('0x76')](_0x33255f,_0x33255f[_0xf40f('0x87')],_0x33255f[_0xf40f('0x12e')]);}}};Preview['prototype'][_0xf40f('0x136')]=function(_0x5c7e1d,_0x5df1e2,_0x44da08){if(this['actions'][_0x5c7e1d]){if(_[_0xf40f('0x41')](this[_0xf40f('0x13')][_0x5c7e1d][_0xf40f('0x123')])){this[_0xf40f('0x13')][_0x5c7e1d][_0xf40f('0x123')]={};}this[_0xf40f('0x13')][_0x5c7e1d]['variables'][_0x5df1e2]=_0x44da08;}};Preview['prototype'][_0xf40f('0x1f')]=function(_0x51c03f){try{if(!_[_0xf40f('0x41')](_0x51c03f)){if(ut[_0xf40f('0x137')](_[_0xf40f('0x138')](_0x51c03f[_0xf40f('0x139')])[0x0])){this[_0xf40f('0x136')](_0x51c03f[_0xf40f('0x8e')],_[_0xf40f('0x138')](_0x51c03f['variable'])[0x0],_0x51c03f['value']);}}}catch(_0x1c9ab2){logger['error'](_0xf40f('0x13a'),util[_0xf40f('0x13b')](_0x1c9ab2,{'showHidden':![],'depth':null}));}};Preview[_0xf40f('0xc')][_0xf40f('0x21')]=function(_0x222a45){if(_0x222a45){if(this[_0xf40f('0x13')][_0x222a45[_0xf40f('0x13c')]]){this[_0xf40f('0x13')][_0x222a45[_0xf40f('0x13c')]][_0xf40f('0x133')]=!![];}}};Preview[_0xf40f('0xc')]['syncBlindTransfer']=function(_0x282196){if(_0x282196){if(this[_0xf40f('0x13')][_0x282196[_0xf40f('0x13d')]]){this[_0xf40f('0x13')][_0x282196[_0xf40f('0x13d')]][_0xf40f('0x133')]=!![];}}};module[_0xf40f('0x13e')]=Preview;