7ab3de4f3472e969d9a4ff6af16e5c80ec72f0b2
[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 _0x9f8b=['[syncHangupRequest][logAgentReject]','AgentReject','dialAgentRejectMaxRetry','[callProgressDetectingCustomer][logAgentReject]','ABANDONED','countabandonedretry','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','cause-txt','dialstatus','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','updateOriginated','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logBusy]','Congestion','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent][logAnswerAGI]','checkInBlack','Contact','Contact\x20is\x20undefined','lookAgent','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','idContact','custom:agentcalled','called','Calling','[Preview][execCall][failure]','logBlacklist','Contact\x20in\x20black\x20List','SIP/%s','status','reachable','unmonitored','execRun','unlock','unlockContact','getContactPreview','recallme','isValid','checkIsBlackList','Contact.phone','[Preview][checkIsBlackList]','[Preview][getContactPreview]','Call\x20unsuccessful','[Preview][validateContact][Empty\x20Contact]','[Preview][validateContact][Empty\x20Campaign]','\x20Trunk\x20is\x20not\x20active','[Preview][validateContact][Trunk\x20not\x20work]','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','[Preview][validateContact][Campaign\x20Active]','campaign\x20Name:\x20','\x20Not\x20Active','SIP/%s/%s%s','dialCutDigit','substring','trim','phone','callerid','dialOriginateCallerIdName','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','getCallerId','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','merge','toLowerVariables','starttime','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','actionid','logLookAgent','clone','response','custom:agentringnoanswer','rejected','[callProgressDetectingAgent][logAnswer]','syncHangup','[syncHangup][talking]','cause','[syncHangup][talking][cause]','channelstate','transfer','disableContact','[syncHangup][talking][transfer]','syncDialEnd','destuniqueid','syncHangupRequest','addVariable','variables','keys','variable','error','[syncVarSet][Preview]','syncAttendedTransfer','transfertargetlinkedid','transfererlinkedid','exports','util','lodash','bluebird','uuid','moment','md5','ioredis','../../../config/environment','../../../config/logger','preview','actionPreview','./action','redis','localhost','prototype','tail','sequence','campaignsPreview','voiceQueues','trunks','agents','clockClearZombieChannels','syncOriginateResponse','bind','hangup','hanguprequest','dialend','syncNewExten','varset','attendedtransfer','blindtransfer','syncBlindTransfer','loopCampaigns','emit','type','name','strategy','answered','available','loggedIn','pTalking','sumHoldTime','total','unmanaged','abandoned','waiting','loggedInDb','dialActive','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundDropCallsDayACS','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','originated','erlangCalls','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','active','Interval','stringify','voice:queue:%s','voice_queue:save','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','format','voice_queue_channel:remove','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','\x20is\x20disactive','syncCampaigns','dialMethod','clearZombieChannels','hasOwnProperty','outbound','setMessage','recallMe','clearZombieChannel','enqueue','isNil','actions','Queue','queue','originated:\x20','dialAnswer','pick','contactId','UserId','VoiceQueueId','Action','channel','catch','No\x20such\x20channel','[clearZombieChannel]','decrementTalkink','loggerError','[Dialer][checkChannel][Preview]','[action]','size','getContactRecallMe','agentReadyId','then','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','logger2','[RecallMe]','YYYY-MM-DD\x20HH:mm:ss','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','RecallFailedTimeout','createCustomerHistory','[HistoryRecallClose]','sendMessageOneNotActive','AGENTS_NOT_LOGGED','isActive','isTrunkReachable','TrunkBackup','ACTIVE','callProgressDetectingCustomer','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','cloneAction','createCustomerFinal','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','activeContact','linkedid','ANSWER','responsetime','answertime','[syncHangup][talking][increment]','\x20Queue','custom:agentconnect','connect','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','Answer','[callProgressDetectingCustomer][logAnswer]','sumDuration','talktime','sumBillable','[syncHangup][talking][decrement]','uniqueid','pTalking:\x20','BUSY','countbusyretry','Busy','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','dialGlobalMaxRetry','Global','dialBusyMaxRetry','rescheduleContact','scheduledAt','unlockAgent','NOANSWER','countnoanswerretry','NoAnswer','custom:agentnoanswer','noanswer','[callProgressDetectingCustomer][logNoAnswerGlobal]','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerRetryFrequency','CONGESTION','outboundCongestionCallsDay','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','countcongestionretry','dialCongestionMaxRetry','dialBusyRetryFrequency','CANCEL','countagentrejectretry','custom:agentreject','agentreject'];(function(_0x565c49,_0x54acd0){var _0x20ca34=function(_0x42f7e1){while(--_0x42f7e1){_0x565c49['push'](_0x565c49['shift']());}};_0x20ca34(++_0x54acd0);}(_0x9f8b,0x77));var _0xb9f8=function(_0x33bad8,_0xa77a59){_0x33bad8=_0x33bad8-0x0;var _0xed1658=_0x9f8b[_0x33bad8];return _0xed1658;};'use strict';var util=require(_0xb9f8('0x0'));var _=require(_0xb9f8('0x1'));var BPromise=require(_0xb9f8('0x2'));var uuid=require(_0xb9f8('0x3'));var moment=require(_0xb9f8('0x4'));var md5=require(_0xb9f8('0x5'));var Redis=require(_0xb9f8('0x6'));var config=require(_0xb9f8('0x7'));var logger=require(_0xb9f8('0x8'))(_0xb9f8('0x9'));var loggerAction=require(_0xb9f8('0x8'))(_0xb9f8('0xa'));var ami=require('../ami');var rpcDb=require('./rpcDb');var Action=require(_0xb9f8('0xb'));var ut=require('./util/util');config[_0xb9f8('0xc')]=_['defaults'](config[_0xb9f8('0xc')],{'host':_0xb9f8('0xd'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config['redis']));var Sequence=function(){};Sequence[_0xb9f8('0xe')]['enqueue']=function(_0x29402e){this[_0xb9f8('0xf')]=this[_0xb9f8('0xf')]?this[_0xb9f8('0xf')]['finally'](_0x29402e):_0x29402e();};function Preview(_0x125d99){this[_0xb9f8('0x10')]=new Sequence();this[_0xb9f8('0x11')]=_0x125d99[_0xb9f8('0x12')];this[_0xb9f8('0x13')]=_0x125d99[_0xb9f8('0x13')];this['actions']={};this[_0xb9f8('0x14')]=_0x125d99[_0xb9f8('0x14')];this[_0xb9f8('0x15')]=0x0;ami['on']('originateresponse',this[_0xb9f8('0x16')][_0xb9f8('0x17')](this));ami['on'](_0xb9f8('0x18'),this['syncHangup']['bind'](this));ami['on'](_0xb9f8('0x19'),this['syncHangupRequest']['bind'](this));ami['on'](_0xb9f8('0x1a'),this['syncDialEnd'][_0xb9f8('0x17')](this));ami['on']('newexten',this[_0xb9f8('0x1b')][_0xb9f8('0x17')](this));ami['on'](_0xb9f8('0x1c'),this['syncVarSet'][_0xb9f8('0x17')](this));ami['on'](_0xb9f8('0x1d'),this['syncAttendedTransfer'][_0xb9f8('0x17')](this));ami['on'](_0xb9f8('0x1e'),this[_0xb9f8('0x1f')][_0xb9f8('0x17')](this));this[_0xb9f8('0x20')](this[_0xb9f8('0x11')]);}function emit(_0x13730c,_0x4109d4,_0x94f5a7){io['to'](_0x13730c)[_0xb9f8('0x21')](_0x4109d4,_0x94f5a7);}function emitCampaignPreview(_0x1d31b4){if(_0x1d31b4[_0xb9f8('0x22')]==='outbound'){var _0x5117f7={'id':_0x1d31b4['id'],'name':_0x1d31b4[_0xb9f8('0x23')],'strategy':_0x1d31b4[_0xb9f8('0x24')],'answered':_0x1d31b4[_0xb9f8('0x25')],'available':_0x1d31b4[_0xb9f8('0x26')],'loggedIn':_0x1d31b4[_0xb9f8('0x27')],'pTalking':_0x1d31b4[_0xb9f8('0x28')],'sumBillable':_0x1d31b4['sumBillable'],'sumDuration':_0x1d31b4['sumDuration'],'sumHoldTime':_0x1d31b4[_0xb9f8('0x29')]||0x0,'talking':_0x1d31b4['talking'],'total':_0x1d31b4[_0xb9f8('0x2a')],'type':_0x1d31b4[_0xb9f8('0x22')],'unmanaged':_0x1d31b4[_0xb9f8('0x2b')],'abandoned':_0x1d31b4[_0xb9f8('0x2c')],'waiting':_0x1d31b4[_0xb9f8('0x2d')],'loggedInDb':_0x1d31b4[_0xb9f8('0x2e')],'dialActive':_0x1d31b4[_0xb9f8('0x2f')],'dialMethod':_0x1d31b4['dialMethod'],'dialOriginateCallerIdName':_0x1d31b4['dialOriginateCallerIdName'],'dialOriginateCallerIdNumber':_0x1d31b4['dialOriginateCallerIdNumber'],'dialOriginateTimeout':_0x1d31b4['dialOriginateTimeout'],'dialPrefix':_0x1d31b4[_0xb9f8('0x30')],'outboundAnswerAgiCallsDay':_0x1d31b4[_0xb9f8('0x31')],'outboundAnswerCallsDay':_0x1d31b4[_0xb9f8('0x32')],'outboundBlacklistCallsDay':_0x1d31b4[_0xb9f8('0x33')],'outboundBusyCallsDay':_0x1d31b4['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0x1d31b4['outboundCongestionCallsDay'],'outboundDropCallsDayACS':_0x1d31b4[_0xb9f8('0x34')],'outboundDropCallsDayCallersExit':_0x1d31b4['outboundDropCallsDayCallersExit'],'outboundDropCallsDayTimeout':_0x1d31b4[_0xb9f8('0x35')],'outboundNoAnswerCallsDay':_0x1d31b4[_0xb9f8('0x36')],'outboundNoSuchCallsDay':_0x1d31b4[_0xb9f8('0x37')],'outboundOriginateFailureCallsDay':_0x1d31b4[_0xb9f8('0x38')],'outboundReCallsDay':_0x1d31b4[_0xb9f8('0x39')],'outboundRejectCallsDay':_0x1d31b4[_0xb9f8('0x3a')],'outboundUnknownCallsDay':_0x1d31b4[_0xb9f8('0x3b')],'outboundAbandonedCallsDay':_0x1d31b4[_0xb9f8('0x3c')],'predictiveIntervalAnsweredCalls':_0x1d31b4[_0xb9f8('0x3d')],'predictiveIntervalAvgHoldtime':_0x1d31b4[_0xb9f8('0x3e')],'predictiveIntervalAvgTalktime':_0x1d31b4[_0xb9f8('0x3f')],'predictiveIntervalDroppedCallsCallersExit':_0x1d31b4[_0xb9f8('0x40')],'predictiveIntervalDroppedCallsTimeout':_0x1d31b4[_0xb9f8('0x41')],'predictiveIntervalErlangCalls':_0x1d31b4[_0xb9f8('0x42')],'predictiveIntervalErlangCallsDroppedCalls':_0x1d31b4[_0xb9f8('0x43')],'predictiveIntervalHitRate':_0x1d31b4['predictiveIntervalHitRate'],'predictiveIntervalMultiplicativeFactor':_0x1d31b4[_0xb9f8('0x44')],'predictiveIntervalPauses':_0x1d31b4[_0xb9f8('0x45')],'predictiveIntervalAvailable':_0x1d31b4[_0xb9f8('0x46')],'predictiveIntervalTotalCalls':_0x1d31b4[_0xb9f8('0x47')],'message':_0x1d31b4[_0xb9f8('0x48')],'originated':_0x1d31b4[_0xb9f8('0x49')],'erlangCalls':_0x1d31b4[_0xb9f8('0x4a')],'erlangCallToSecond':_0x1d31b4['erlangCallToSecond'],'erlangAbandonmentRate':_0x1d31b4[_0xb9f8('0x4b')],'erlangBusyFactor':_0x1d31b4[_0xb9f8('0x4c')],'startPredictive':_0x1d31b4[_0xb9f8('0x4d')],'startProgressive':_0x1d31b4[_0xb9f8('0x4e')]};if(_0x1d31b4[_0xb9f8('0x4f')]){_0x5117f7[_0xb9f8('0x4f')]={'id':_0x1d31b4['Trunk']['id'],'name':_0x1d31b4['Trunk'][_0xb9f8('0x23')],'active':_0x1d31b4['Trunk'][_0xb9f8('0x50')],'callerid':_0x1d31b4[_0xb9f8('0x4f')]['callerid']};}if(_0x1d31b4[_0xb9f8('0x51')]){_0x5117f7[_0xb9f8('0x51')]={'id':_0x1d31b4[_0xb9f8('0x51')]['id'],'name':_0x1d31b4[_0xb9f8('0x51')][_0xb9f8('0x23')]};}var _0x5576d8=md5(JSON[_0xb9f8('0x52')](_0x5117f7));if(_0x1d31b4[_0xb9f8('0x5')]!==_0x5576d8){_0x1d31b4[_0xb9f8('0x5')]=_0x5576d8;emit(util['format'](_0xb9f8('0x53'),_0x5117f7[_0xb9f8('0x23')]),_0xb9f8('0x54'),_0x5117f7);}}}function emitVoiceQueueChannelRemove(_0x1cdb8c){logger[_0xb9f8('0x55')](_0xb9f8('0x56'),JSON['stringify'](_0x1cdb8c));emit(util[_0xb9f8('0x57')](_0xb9f8('0x53'),_0x1cdb8c['name']),_0xb9f8('0x58'),_0x1cdb8c);}function notSendMessagesQueue(_0x323887){if(_0x323887['sendMessageOneNotActive']){if(_0x323887[_0xb9f8('0x49')]===0x0&&_0x323887[_0xb9f8('0x28')]===0x0){_0x323887['sendMessageOneNotActive']=![];_0x323887[_0xb9f8('0x26')]=0x0;_0x323887['paused']=0x0;_0x323887[_0xb9f8('0x48')]=_0xb9f8('0x59');ut[_0xb9f8('0x5a')](_0xb9f8('0x5b'),_0x323887['name']+_0xb9f8('0x5c'));}else{_0x323887[_0xb9f8('0x48')]='IS_DISACTIVED';ut[_0xb9f8('0x5a')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x323887[_0xb9f8('0x23')]+_0xb9f8('0x5d'));}emitCampaignPreview(_0x323887);}}Preview['prototype'][_0xb9f8('0x20')]=function(){var _0x4f9e05=this;setInterval(function(){_0x4f9e05[_0xb9f8('0x5e')]();},0x7cf);};Preview[_0xb9f8('0xe')][_0xb9f8('0x5e')]=function(){var _0x31969c=this['campaignsPreview'];this[_0xb9f8('0x15')]+=0x1;for(var _0x2f4878 in _0x31969c){if(_0x31969c['hasOwnProperty'](_0x2f4878)&&(_0x31969c[_0x2f4878][_0xb9f8('0x5f')]===_0xb9f8('0x9')||_0x31969c[_0x2f4878][_0xb9f8('0x5f')]==='booked')&&_0x31969c[_0x2f4878][_0xb9f8('0x22')]==='outbound'){if(this[_0xb9f8('0x15')]>0x7){this['clockClearZombieChannels']=0x0;this[_0xb9f8('0x60')]();}}if(_0x31969c[_0xb9f8('0x61')](_0x2f4878)&&_0x31969c[_0x2f4878][_0xb9f8('0x5f')]===_0xb9f8('0x9')&&_0x31969c[_0x2f4878]['type']===_0xb9f8('0x62')){if(_0x31969c[_0x2f4878]['dialActive']){this[_0xb9f8('0x63')](_0x31969c[_0x2f4878]);this[_0xb9f8('0x64')](_0x31969c[_0x2f4878]);}else{notSendMessagesQueue(_0x31969c[_0x2f4878]);}}}};Preview[_0xb9f8('0xe')][_0xb9f8('0x65')]=function(_0x1582c1){var _0x4a50d3=this;this[_0xb9f8('0x10')][_0xb9f8('0x66')](function(){if(!_[_0xb9f8('0x67')](_0x4a50d3[_0xb9f8('0x68')][_0x1582c1])){loggerAction['info']('[clearZombieChannels][talking]',_0x1582c1,_0xb9f8('0x69'),_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6a')],_0xb9f8('0x6b'),JSON[_0xb9f8('0x52')](_0x4a50d3[_0xb9f8('0x11')][_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6a')]][_0xb9f8('0x49')]),'pTalking:\x20',JSON['stringify'](_0x4a50d3['campaignsPreview'][_0x4a50d3[_0xb9f8('0x68')][_0x1582c1]['queue']]['pTalking']),JSON[_0xb9f8('0x52')](_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6c')]),JSON[_0xb9f8('0x52')](_[_0xb9f8('0x6d')](_0x4a50d3[_0xb9f8('0x68')][_0x1582c1],[_0xb9f8('0x6e'),_0xb9f8('0x6f'),_0xb9f8('0x70'),'ListId'])));return ami[_0xb9f8('0x71')]({'action':'status','channel':_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x72')]})[_0xb9f8('0x73')](function(_0x1701f3){if(_0x1701f3[_0xb9f8('0x48')]===_0xb9f8('0x74')){setTimeout(function(){if(_0x4a50d3[_0xb9f8('0x68')][_0x1582c1]){ut['updateOriginated'](_0x4a50d3['campaignsPreview'][_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6a')]],_0xb9f8('0x75'));if(_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6c')]===!![]){ut[_0xb9f8('0x76')](_0x4a50d3['campaignsPreview'][_0x4a50d3[_0xb9f8('0x68')][_0x1582c1]['queue']],_0xb9f8('0x75'));ut[_0xb9f8('0x77')]('[Dialer][checkChannel][pTalking][Preview]'+_0x1582c1,_0x4a50d3['actions'][_0x1582c1]['queue']);}ut[_0xb9f8('0x77')](_0xb9f8('0x78')+_0x1582c1,_0x4a50d3[_0xb9f8('0x68')][_0x1582c1][_0xb9f8('0x6a')]);delete _0x4a50d3[_0xb9f8('0x68')][_0x1582c1];}},0x2328);}});}});};Preview[_0xb9f8('0xe')]['clearZombieChannels']=function(){var _0x164dc9=this;loggerAction[_0xb9f8('0x55')](_0xb9f8('0x79'),_[_0xb9f8('0x7a')](this[_0xb9f8('0x68')]));for(var _0x17ab68 in this[_0xb9f8('0x68')]){if(_0x164dc9[_0xb9f8('0x68')][_0xb9f8('0x61')](_0x17ab68)){_0x164dc9[_0xb9f8('0x65')](_0x17ab68);}}};Preview[_0xb9f8('0xe')][_0xb9f8('0x64')]=function(_0x541d13){var _0x2c203c=this;rpcDb[_0xb9f8('0x7b')](_0x541d13['id'],ut[_0xb9f8('0x7c')](this[_0xb9f8('0x14')]))[_0xb9f8('0x7d')](function(_0x187506){if(!_[_0xb9f8('0x67')](_0x187506)){for(var _0x5f19ea=0x0;_0x5f19ea<_0x187506['length'];_0x5f19ea+=0x1){if(ut[_0xb9f8('0x7e')](_0x187506[_0x5f19ea][_0xb9f8('0x7f')])<_0x541d13[_0xb9f8('0x80')]*0x3c){if(_0x187506[_0x5f19ea][_0xb9f8('0x81')]&&!_0x187506[_0x5f19ea]['Agent'][_0xb9f8('0x82')]){_0x2c203c['run'](_0x187506[_0x5f19ea]['id'])[_0xb9f8('0x7d')](ut[_0xb9f8('0x83')](_0xb9f8('0x84')))['catch'](ut[_0xb9f8('0x83')](_0xb9f8('0x84')));}else{rpcDb['disableContact'](_0x187506[_0x5f19ea]['id']);}}else{var _0x383076=new Action(_0x187506[_0x5f19ea],_0x541d13);_0x383076['starttime']=moment()[_0xb9f8('0x57')](_0xb9f8('0x85'));_0x541d13[_0xb9f8('0x39')]+=0x1;ut[_0xb9f8('0x86')](_0x383076,0x17,_0xb9f8('0x87'));if(_0x541d13[_0xb9f8('0x88')]){rpcDb[_0xb9f8('0x89')](ut['createBody'](_0x187506[_0x5f19ea]));rpcDb['createCustomerHistory'](_0x383076,'[HistoryDialRecallInQueue][historyCatch]');}else{ut[_0xb9f8('0x86')](_0x383076,0x16,_0xb9f8('0x8a'));rpcDb[_0xb9f8('0x8b')](_0x383076,_0xb9f8('0x8c'));rpcDb['createCustomerFinal'](_0x383076,'[HistoryRecallClose]');}}}}})[_0xb9f8('0x73')](ut['logger2']('[getContactRecallMe]'));};Preview[_0xb9f8('0xe')]['setMessage']=function(_0x2daf95){_0x2daf95[_0xb9f8('0x8d')]=!![];if(ut['IsNotLoggedIn'](_0x2daf95[_0xb9f8('0x27')])){_0x2daf95[_0xb9f8('0x48')]=_0xb9f8('0x8e');}else if(!ut[_0xb9f8('0x8f')](_0x2daf95['dialActive'])){_0x2daf95[_0xb9f8('0x48')]=_0xb9f8('0x59');}else if(!this[_0xb9f8('0x90')](_0x2daf95[_0xb9f8('0x4f')])){if(!this['isTrunkReachable'](_0x2daf95[_0xb9f8('0x91')])){_0x2daf95[_0xb9f8('0x48')]='TRUNK_IS_NOT_REACHABLE';}else{_0x2daf95['message']=_0xb9f8('0x92');}}else{_0x2daf95['message']=_0xb9f8('0x92');}emitCampaignPreview(_0x2daf95);};Preview[_0xb9f8('0xe')][_0xb9f8('0x93')]=function(_0x1353b7,_0x280563,_0x23dddd){var _0x5e79b3=this;var _0x5784f4=this[_0xb9f8('0x68')][_0x280563];var _0x39f1f5=this[_0xb9f8('0x11')][_0x5784f4[_0xb9f8('0x6a')]];var _0xf3417d;if(_0x39f1f5){switch(_0x23dddd){case'1':_0x39f1f5[_0xb9f8('0x37')]+=0x1;_0x5784f4[_0xb9f8('0x94')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x0,_0xb9f8('0x97'));ami[_0xb9f8('0x21')](_0xb9f8('0x98'),ut[_0xb9f8('0x99')](_0x5784f4,'nosuchnumber'));rpcDb[_0xb9f8('0x8b')](_0x5784f4,'[callProgressDetectingCustomer][logNoSuch]');if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5['dialGlobalMaxRetry']){_0xf3417d=ut[_0xb9f8('0x9a')](_0x5784f4,0xf,'Global');rpcDb[_0xb9f8('0x9b')](_0xf3417d,_0xb9f8('0x9c'));}else{if(_0x5784f4['countnosuchnumberretry']>=_0x39f1f5[_0xb9f8('0x9d')]){rpcDb[_0xb9f8('0x9b')](_0x5784f4,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{rpcDb['rescheduleContact'](ut['scheduledAt'](_0x5784f4,_0xb9f8('0x94'),_0x39f1f5['dialNoSuchNumberRetryFrequency']),_0x5784f4['unlockAgent'],_0x5784f4[_0xb9f8('0x9e')]);}}delete this[_0xb9f8('0x68')][_0x1353b7[_0xb9f8('0x9f')]];break;case _0xb9f8('0xa0'):var _0x5389ca=moment()[_0xb9f8('0x57')]('YYYY-MM-DD\x20HH:mm:ss');_0x5784f4[_0xb9f8('0xa1')]=_0x5389ca;_0x5784f4[_0xb9f8('0xa2')]=_0x5389ca;_0x5784f4['dialAnswer']=!![];_0x39f1f5[_0xb9f8('0x28')]+=0x1;logger[_0xb9f8('0x55')](_0xb9f8('0xa3'),_0x5784f4['uniqueid'],_0xb9f8('0xa4'),_0x39f1f5[_0xb9f8('0x23')],'pTalking:\x20',_0x39f1f5['pTalking']);ami['emit'](_0xb9f8('0xa5'),ut['buildObj'](_0x5784f4,_0xb9f8('0xa6')));if(_0x39f1f5[_0xb9f8('0xa7')]){ami[_0xb9f8('0x21')](_0xb9f8('0xa8'),ut[_0xb9f8('0xa9')](_0x5784f4));}break;case'16':ami[_0xb9f8('0x21')](_0xb9f8('0xaa'),ut['buildObj'](_0x5784f4,'complete'));emitVoiceQueueChannelRemove(ut['buildObj'](_0x5784f4,'complete'));_0x39f1f5[_0xb9f8('0x32')]+=0x1;_0x39f1f5[_0xb9f8('0x2a')]+=0x1;_0x39f1f5['answered']+=0x1;ut[_0xb9f8('0x76')](_0x39f1f5,'[16]');_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x4,_0xb9f8('0xab'));rpcDb[_0xb9f8('0x8b')](_0x5784f4,_0xb9f8('0xac'));rpcDb[_0xb9f8('0x9b')](_0x5784f4,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb['crateCustomerReportQueue'](_0x5784f4);_0x39f1f5[_0xb9f8('0xad')]+=_0x5784f4[_0xb9f8('0xae')];_0x39f1f5[_0xb9f8('0xaf')]+=_0x5784f4[_0xb9f8('0xae')];logger['info'](_0xb9f8('0xb0'),_0x5784f4[_0xb9f8('0xb1')],_0xb9f8('0xa4'),_0x39f1f5[_0xb9f8('0x23')],_0xb9f8('0xb2'),_0x39f1f5[_0xb9f8('0x28')]);delete this[_0xb9f8('0x68')][_0x1353b7[_0xb9f8('0x9f')]];break;case _0xb9f8('0xb3'):_0x39f1f5['outboundBusyCallsDay']+=0x1;_0x5784f4[_0xb9f8('0xb4')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x5,_0xb9f8('0xb5'));ami['emit'](_0xb9f8('0xb6'),ut['buildObj'](_0x5784f4,_0xb9f8('0xb7')));rpcDb['createCustomerHistory'](_0x5784f4,_0xb9f8('0xb8'));if(ut['totalGlobal'](_0x5784f4)>=_0x39f1f5[_0xb9f8('0xb9')]){_0xf3417d=ut[_0xb9f8('0x9a')](_0x5784f4,0xf,_0xb9f8('0xba'));rpcDb[_0xb9f8('0x9b')](_0xf3417d,'[callProgressDetectingCustomer][logBusyGlobal]');}else{if(_0x5784f4[_0xb9f8('0xb4')]>=_0x39f1f5[_0xb9f8('0xbb')]){rpcDb['createCustomerFinal'](_0x5784f4,_0xb9f8('0xb8'));}else{rpcDb[_0xb9f8('0xbc')](ut[_0xb9f8('0xbd')](_0x5784f4,'countbusyretry',_0x39f1f5['dialBusyRetryFrequency']),_0x5784f4[_0xb9f8('0xbe')],_0x5784f4['activeContact']);}}break;case _0xb9f8('0xbf'):_0x39f1f5[_0xb9f8('0x36')]+=0x1;_0x5784f4[_0xb9f8('0xc0')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x3,_0xb9f8('0xc1'));ami[_0xb9f8('0x21')](_0xb9f8('0xc2'),ut[_0xb9f8('0x99')](_0x5784f4,_0xb9f8('0xc3')));rpcDb['createCustomerHistory'](_0x5784f4,'[callProgressDetectingCustomer][logNoAnswer]');if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5[_0xb9f8('0xb9')]){_0xf3417d=ut['cloneAction'](_0x5784f4,0xf,'Global');rpcDb[_0xb9f8('0x9b')](_0xf3417d,_0xb9f8('0xc4'));}else{if(_0x5784f4[_0xb9f8('0xc0')]>=_0x39f1f5['dialNoAnswerMaxRetry']){rpcDb[_0xb9f8('0x9b')](_0x5784f4,_0xb9f8('0xc5'));}else{rpcDb[_0xb9f8('0xbc')](ut[_0xb9f8('0xbd')](_0x5784f4,_0xb9f8('0xc0'),_0x39f1f5[_0xb9f8('0xc6')]),_0x5784f4[_0xb9f8('0xbe')],_0x5784f4[_0xb9f8('0x9e')]);}}break;case _0xb9f8('0xc7'):_0x39f1f5[_0xb9f8('0xc8')]+=0x1;_0x5784f4['countcongestionretry']+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut['totalGlobal'](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x8,'Congestion');ami[_0xb9f8('0x21')]('custom:agentcongestion',ut[_0xb9f8('0x99')](_0x5784f4,_0xb9f8('0xc9')));rpcDb[_0xb9f8('0x8b')](_0x5784f4,_0xb9f8('0xca'));if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5[_0xb9f8('0xb9')]){_0xf3417d=ut[_0xb9f8('0x9a')](_0x5784f4,0xf,_0xb9f8('0xba'));rpcDb[_0xb9f8('0x9b')](_0xf3417d,_0xb9f8('0xcb'));}else{if(_0x5784f4[_0xb9f8('0xcc')]>=_0x39f1f5[_0xb9f8('0xcd')]){rpcDb[_0xb9f8('0x9b')](_0x5784f4,_0xb9f8('0xca'));}else{rpcDb[_0xb9f8('0xbc')](ut[_0xb9f8('0xbd')](_0x5784f4,_0xb9f8('0xcc'),_0x39f1f5[_0xb9f8('0xce')]),_0x5784f4[_0xb9f8('0xbe')],_0x5784f4[_0xb9f8('0x9e')]);}}break;case _0xb9f8('0xcf'):_0x39f1f5[_0xb9f8('0x3a')]+=0x1;_0x5784f4[_0xb9f8('0xd0')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0x14,'AgentReject');ami[_0xb9f8('0x21')](_0xb9f8('0xd1'),ut['buildObj'](_0x5784f4,_0xb9f8('0xd2')));rpcDb[_0xb9f8('0x8b')](_0x5784f4,_0xb9f8('0xd3'));if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5['dialGlobalMaxRetry']){_0xf3417d=ut[_0xb9f8('0x9a')](_0x5784f4,0x14,_0xb9f8('0xd4'));rpcDb[_0xb9f8('0x9b')](_0xf3417d,'[callProgressDetectingCustomer][logAgentReject]');}else{if(_0x5784f4['countagentrejectretry']>=_0x39f1f5[_0xb9f8('0xd5')]){rpcDb[_0xb9f8('0x9b')](_0x5784f4,_0xb9f8('0xd6'));}else{rpcDb['rescheduleContact'](ut[_0xb9f8('0xbd')](_0x5784f4,_0xb9f8('0xd0'),_0x39f1f5['dialAgentRejectRetryFrequency']),_0x5784f4[_0xb9f8('0xbe')],_0x5784f4['activeContact']);}}break;case _0xb9f8('0xd7'):_0x39f1f5[_0xb9f8('0x3c')]+=0x1;_0x5784f4[_0xb9f8('0xd8')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut[_0xb9f8('0x96')](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0xb,'Abandoned');rpcDb[_0xb9f8('0x8b')](_0x5784f4,_0xb9f8('0xd9'));if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5['dialGlobalMaxRetry']){_0xf3417d=ut[_0xb9f8('0x9a')](_0x5784f4,0xf,_0xb9f8('0xba'));rpcDb[_0xb9f8('0x9b')](_0xf3417d,_0xb9f8('0xd9'));}else{if(_0x5784f4[_0xb9f8('0xda')]>=_0x39f1f5[_0xb9f8('0xdb')]){rpcDb['createCustomerFinal'](_0x5784f4,'[callProgressDetectingCustomer][logAbandoned]');}else{rpcDb[_0xb9f8('0xbc')](ut[_0xb9f8('0xbd')](_0x5784f4,_0xb9f8('0xd8'),_0x39f1f5[_0xb9f8('0xdc')]),_0x5784f4[_0xb9f8('0xbe')],_0x5784f4[_0xb9f8('0x9e')]);}}break;default:if(_0x5784f4['dialAnswer']){ut['decrementTalkink'](_0x39f1f5,_0xb9f8('0xdd'));ut['loggerError'](_0xb9f8('0xde')+_0x39f1f5[_0xb9f8('0x23')],_0x1353b7);}_0x39f1f5[_0xb9f8('0x3b')]+=0x1;_0x5784f4[_0xb9f8('0x95')]=ut['totalGlobal'](_0x5784f4);ut[_0xb9f8('0x86')](_0x5784f4,0xc,_0x1353b7[_0xb9f8('0xdf')]||_0x1353b7[_0xb9f8('0xe0')]);rpcDb[_0xb9f8('0x8b')](_0x5784f4,_0xb9f8('0xe1'));if(ut[_0xb9f8('0x96')](_0x5784f4)>=_0x39f1f5[_0xb9f8('0xb9')]){_0xf3417d=ut['cloneAction'](_0x5784f4,0xf,_0xb9f8('0xba'));rpcDb[_0xb9f8('0x9b')](_0xf3417d,_0xb9f8('0xe2'));}else{rpcDb[_0xb9f8('0x9b')](_0x5784f4,_0xb9f8('0xe2'));}delete this[_0xb9f8('0x68')][_0x1353b7[_0xb9f8('0x9f')]];}if(!(_0x5784f4[_0xb9f8('0x6c')]&&_0x23dddd==='16')){ut[_0xb9f8('0xe3')](_0x39f1f5,_0xb9f8('0xe4'));logger['info'](_0xb9f8('0xe5'),_0x5784f4[_0xb9f8('0xb1')],_0xb9f8('0xa4'),_0x39f1f5['name'],_0xb9f8('0x6b'),_0x39f1f5['originated']);}if(_0x23dddd!=='ANSWER'){delete this[_0xb9f8('0x68')][_0x1353b7[_0xb9f8('0x9f')]];delete this['actions'][_0x1353b7[_0xb9f8('0xe6')]];}}};Preview['prototype'][_0xb9f8('0xe7')]=function(_0x44a7b1,_0x1801fd,_0x26bc37){if(_['isUndefined'](_0x1801fd)&&'object'!==typeof _0x1801fd){return;}if(_[_0xb9f8('0xe8')](_0x26bc37)&&_0xb9f8('0xe9')!==typeof _0x26bc37){return;}switch(_0x26bc37[_0xb9f8('0xea')]){case'0':ut[_0xb9f8('0xeb')](_0x44a7b1,0x0,_0xb9f8('0x97'));rpcDb[_0xb9f8('0xec')](_0x44a7b1,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut['logAgent'](_0x44a7b1,0x3,'NoAnswer');rpcDb[_0xb9f8('0xec')](_0x44a7b1,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut['logAgent'](_0x44a7b1,0x5,'Busy');rpcDb[_0xb9f8('0xec')](_0x44a7b1,_0xb9f8('0xed'));break;case'8':ut[_0xb9f8('0xeb')](_0x44a7b1,0x8,_0xb9f8('0xee'));rpcDb['createAgentHistory'](_0x44a7b1,_0xb9f8('0xef'));break;case'22':ut['logAgent'](_0x44a7b1,0x16,'AnswerAGI');rpcDb['createAgentHistory'](_0x44a7b1,_0xb9f8('0xf0'));break;default:ut[_0xb9f8('0xeb')](_0x44a7b1,0xc,_0x26bc37[_0xb9f8('0xea')]);rpcDb[_0xb9f8('0xec')](_0x44a7b1,_0xb9f8('0xef'));}ut[_0xb9f8('0xe3')](_0x1801fd,'[callProgressDetectingAgent]');logger[_0xb9f8('0x55')]('[originated][decrement][callProgressDetectingAgent]',_0x44a7b1[_0xb9f8('0xb1')],'\x20Queue',_0x1801fd[_0xb9f8('0x23')],_0xb9f8('0x6b'),_0x1801fd[_0xb9f8('0x49')]);delete this[_0xb9f8('0x68')][_0x44a7b1[_0xb9f8('0xb1')]];};Preview[_0xb9f8('0xe')][_0xb9f8('0xf1')]=function(_0x6ad902,_0x31c163,_0x164c38,_0x319455,_0x114206){var _0x30919e=this;return new BPromise(function(_0x162e6a,_0x2b64cf){if(_[_0xb9f8('0x67')](_0x31c163)||_[_0xb9f8('0x67')](_0x31c163['Contact'])||_[_0xb9f8('0x67')](_0x31c163[_0xb9f8('0xf2')]['phone'])||_[_0xb9f8('0x67')](_0x31c163[_0xb9f8('0x70')])){_0x2b64cf(ut[_0xb9f8('0x48')](_0xb9f8('0xf3'),_0x319455,_0x114206));return;}var _0xb4e6cb=uuid['v4']();var _0x11c51b=_0x30919e['campaignsPreview'][_0x31c163['Queue'][_0xb9f8('0x23')]];var _0x5bb2cb=_0x164c38?_0x30919e[_0xb9f8('0x14')][_0x164c38]['id']:undefined;_0x30919e[_0xb9f8('0x68')][_0xb4e6cb]=new Action(_0x31c163,_0x11c51b,_0xb4e6cb,_0x164c38,_0x5bb2cb);var _0x1226a2=_0x30919e['actions'][_0xb4e6cb];_0x1226a2[_0xb9f8('0xbe')]=_0x319455;_0x1226a2[_0xb9f8('0x9e')]=_0x114206;_0x1226a2[_0xb9f8('0xf4')]=_0x164c38;if(_[_0xb9f8('0xf5')](_0x6ad902)){_0x30919e[_0xb9f8('0xf6')](_0x1226a2,_0x11c51b,_0x31c163,_0x164c38)['then'](function(_0x2af519){logger[_0xb9f8('0x55')](_0xb9f8('0xf7'),_0xb9f8('0xf8')+_0x1226a2['queue']+'\x20IdHopper:\x20'+_0x1226a2[_0xb9f8('0xf9')],JSON['stringify'](_0x2af519));ami['emit'](_0xb9f8('0xfa'),ut[_0xb9f8('0x99')](_0x1226a2,_0xb9f8('0xfb')));_0x162e6a(ut[_0xb9f8('0x48')](_0xb9f8('0xfc')));})[_0xb9f8('0x73')](function(_0x6801b8){ut['logger'](_0xb9f8('0xfd'),_0x6801b8);_0x2b64cf(ut[_0xb9f8('0x48')]('Call\x20failed',_0x319455,_0x114206));});}else{_0x11c51b[_0xb9f8('0x33')]+=0x1;ut[_0xb9f8('0xfe')](_0x1226a2);rpcDb['createHistory'](_0x1226a2,'[Blacklist][error]');delete _0x30919e['actions'][_0xb4e6cb];_0x2b64cf(ut['message'](_0xb9f8('0xff'),_0x319455,_0x114206));}});};Preview['prototype'][_0xb9f8('0x90')]=function(_0x1f015){return!_['isNil'](_0x1f015)&&!_['isNil'](_0x1f015[_0xb9f8('0x23')])&&!_[_0xb9f8('0x67')](_0x1f015[_0xb9f8('0x50')])&&_0x1f015[_0xb9f8('0x50')]&&!_[_0xb9f8('0x67')](this['trunks'][util['format'](_0xb9f8('0x100'),_0x1f015[_0xb9f8('0x23')])])&&!_[_0xb9f8('0x67')](this[_0xb9f8('0x13')][util[_0xb9f8('0x57')]('SIP/%s',_0x1f015[_0xb9f8('0x23')])][_0xb9f8('0x101')])&&(this[_0xb9f8('0x13')][util[_0xb9f8('0x57')](_0xb9f8('0x100'),_0x1f015[_0xb9f8('0x23')])][_0xb9f8('0x101')]===_0xb9f8('0x102')||this[_0xb9f8('0x13')][util[_0xb9f8('0x57')]('SIP/%s',_0x1f015[_0xb9f8('0x23')])][_0xb9f8('0x101')]===_0xb9f8('0x103'));};Preview[_0xb9f8('0xe')]['run']=function(_0x114055,_0x398d43){var _0xc85df5=this;return new BPromise(function(_0xb798b5,_0x33d608){_0xc85df5[_0xb9f8('0x104')](_0x114055,_0x398d43)[_0xb9f8('0x7d')](function(_0x4956c8){_0xb798b5(_[_0xb9f8('0x6d')](_0x4956c8,['message']));})[_0xb9f8('0x73')](function(_0x149a24){if(_0x149a24[_0xb9f8('0x105')]){rpcDb[_0xb9f8('0x106')](_0x114055);}if(_0x149a24[_0xb9f8('0x50')]){rpcDb['disableContact'](_0x114055);}_0x33d608(_['pick'](_0x149a24,[_0xb9f8('0x48')]));});});};Preview[_0xb9f8('0xe')][_0xb9f8('0x104')]=function(_0x1eccc9,_0x17c5ae){var _0xa51e91=this;return new BPromise(function(_0xd21b29,_0x5af9d3){var _0xc0a1b,_0x2d2c07;rpcDb[_0xb9f8('0x107')](_0x1eccc9)[_0xb9f8('0x7d')](function(_0x45cf81){if(!_[_0xb9f8('0x67')](_0x45cf81[0x0])){_0x2d2c07=_0x45cf81[0x0][_0xb9f8('0x108')]?![]:!![];_0xc0a1b=_0x45cf81[0x0][_0xb9f8('0x108')]?!![]:![];_0xc0a1b=_0x17c5ae?!![]:_0xc0a1b;}var _0x27c42f=_0xa51e91['validateContact'](_0x45cf81);if(_0x27c42f[_0xb9f8('0x109')]){rpcDb[_0xb9f8('0x10a')](_[_0xb9f8('0x6d')](_0x45cf81[0x0],['VoiceQueueId',_0xb9f8('0x10b')]))[_0xb9f8('0x7d')](function(_0x42c471){_0xa51e91[_0xb9f8('0xf1')](_0x42c471,_0x45cf81[0x0],_0x17c5ae,_0x2d2c07,_0xc0a1b)[_0xb9f8('0x7d')](function(_0x16c043){_0xd21b29(_0x16c043);})[_0xb9f8('0x73')](function(_0x43c31b){_0x5af9d3(_0x43c31b);});})[_0xb9f8('0x73')](function(_0x4a6c92){ut['logger'](_0xb9f8('0x10c'),_0x4a6c92);_0x5af9d3(ut[_0xb9f8('0x48')]('Call\x20unsuccessful',_0x2d2c07,_0xc0a1b));});}else{_0x5af9d3(ut[_0xb9f8('0x48')](_0x27c42f[_0xb9f8('0x48')],_0x2d2c07,_0xc0a1b));}})[_0xb9f8('0x73')](function(_0x36fd53){ut[_0xb9f8('0x5a')](_0xb9f8('0x10d'),_0x36fd53);_0x5af9d3(ut[_0xb9f8('0x48')](_0xb9f8('0x10e'),![],!![]));});});};Preview[_0xb9f8('0xe')]['validateContact']=function(_0x4b69c1){if(_[_0xb9f8('0x67')](_0x4b69c1)||_[_0xb9f8('0xf5')](_0x4b69c1)||!_[_0xb9f8('0x67')](_0x4b69c1[0x0][_0xb9f8('0x81')])&&_[_0xb9f8('0x67')](_0x4b69c1[0x0][_0xb9f8('0x81')][_0xb9f8('0x23')])){ut['logger'](_0xb9f8('0x10f'),_0x4b69c1);return{'isValid':![],'message':'Empty\x20Contact'};}var _0x24e900=this[_0xb9f8('0x11')][_0x4b69c1[0x0]['Queue'][_0xb9f8('0x23')]];_0x24e900[_0xb9f8('0x48')]=_0xb9f8('0x92');if(_[_0xb9f8('0x67')](_0x24e900)){ut[_0xb9f8('0x5a')](_0xb9f8('0x110'),_0x24e900);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this[_0xb9f8('0x90')](_0x24e900[_0xb9f8('0x4f')])){ut['logger']('[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20'+_0x24e900[_0xb9f8('0x23')]+_0xb9f8('0x111'));if(!this['isTrunkReachable'](_0x24e900[_0xb9f8('0x91')])){ut[_0xb9f8('0x5a')](_0xb9f8('0x112'),_0x24e900['name']+_0xb9f8('0x113'));return{'isValid':![],'message':_0xb9f8('0x114')};}}if(!ut[_0xb9f8('0x8f')](_0x24e900[_0xb9f8('0x2f')])){ut[_0xb9f8('0x5a')](_0xb9f8('0x115'),_0x24e900[_0xb9f8('0x23')]+'\x20Not\x20Active');return{'isValid':![],'message':_0xb9f8('0x116')+_0x24e900[_0xb9f8('0x23')]+_0xb9f8('0x117')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview['prototype'][_0xb9f8('0xf6')]=function(_0x48a195,_0x29273e,_0xab0492,_0x454f62){var _0x1164a6=this;return new BPromise(function(_0x25d346,_0x32b04f){var _0x932d1=_0x48a195['uniqueid'];var _0x5efd62=_0x1164a6[_0xb9f8('0x90')](_0x29273e[_0xb9f8('0x4f')])?util[_0xb9f8('0x57')](_0xb9f8('0x118'),_0x29273e[_0xb9f8('0x4f')][_0xb9f8('0x23')],_['isNil'](_0x29273e['dialPrefix'])?'':_0x29273e[_0xb9f8('0x30')]['trim']()||'',_0x29273e[_0xb9f8('0x119')]>0x0?_0xab0492['Contact']['phone'][_0xb9f8('0x11a')](_0x29273e['dialCutDigit']):_0xab0492[_0xb9f8('0xf2')]['phone']):util[_0xb9f8('0x57')]('SIP/%s/%s%s',_[_0xb9f8('0x67')](_0x29273e[_0xb9f8('0x91')])?_0x29273e[_0xb9f8('0x4f')][_0xb9f8('0x23')]:_0x29273e['TrunkBackup'][_0xb9f8('0x23')],_[_0xb9f8('0x67')](_0x29273e[_0xb9f8('0x30')])?'':_0x29273e[_0xb9f8('0x30')][_0xb9f8('0x11b')]()||'',_0x29273e[_0xb9f8('0x119')]>0x0?_0xab0492[_0xb9f8('0xf2')][_0xb9f8('0x11c')][_0xb9f8('0x11a')](_0x29273e[_0xb9f8('0x119')]):_0xab0492['Contact']['phone']);var _0x15b4c5=_0x1164a6[_0xb9f8('0x90')](_0x29273e[_0xb9f8('0x4f')])?ut['getCallerId'](_0x29273e[_0xb9f8('0x4f')][_0xb9f8('0x11d')],_0x29273e[_0xb9f8('0x11e')],_0x29273e[_0xb9f8('0x11f')]>0x0?ut[_0xb9f8('0x120')](_0x29273e[_0xb9f8('0x121')],_0x29273e[_0xb9f8('0x11f')]):_0x29273e[_0xb9f8('0x121')]):ut[_0xb9f8('0x122')](_[_0xb9f8('0x67')](_0x29273e[_0xb9f8('0x91')])?_0x29273e['Trunk']['callerid']:_0x29273e[_0xb9f8('0x91')][_0xb9f8('0x11d')],_0x29273e[_0xb9f8('0x11e')],_0x29273e[_0xb9f8('0x11f')]>0x0?ut[_0xb9f8('0x120')](_0x29273e['dialOriginateCallerIdNumber'],_0x29273e[_0xb9f8('0x11f')]):_0x29273e[_0xb9f8('0x121')]);if(_0x15b4c5){_0x48a195[_0xb9f8('0x123')]=ut[_0xb9f8('0x124')](_0x15b4c5);_0x48a195[_0xb9f8('0x125')]=ut[_0xb9f8('0x126')](_0x15b4c5);}var _0x48e3dd=ut['addVariables'](_0x29273e,_0xab0492,_0x5efd62,_0x15b4c5,_0x932d1,_0x48a195);_[_0xb9f8('0x127')](_0x48a195,ut[_0xb9f8('0x128')](_0x48e3dd));_0x48a195[_0xb9f8('0x129')]=moment()[_0xb9f8('0x57')](_0xb9f8('0x85'));ami[_0xb9f8('0x71')](ut[_0xb9f8('0x12a')](_0x48a195,_0x29273e,_0x48e3dd,_0x48a195[_0xb9f8('0x9e')],_0x454f62))[_0xb9f8('0x7d')](function(_0x54d952){_0x29273e[_0xb9f8('0x49')]+=0x1;logger[_0xb9f8('0x55')](_0xb9f8('0x12b'),_0x932d1,_0xb9f8('0xa4'),_0x29273e[_0xb9f8('0x23')],_0xb9f8('0x6b'),_0x29273e['originated']);_0x25d346(_0x54d952);})[_0xb9f8('0x73')](function(_0x4974d2){ut[_0xb9f8('0xeb')](_0x48a195,0xe,_0xb9f8('0x12c'));rpcDb[_0xb9f8('0xec')](_0x48a195,_0xb9f8('0x12d'));_0x32b04f(_0x4974d2);});});};Preview[_0xb9f8('0xe')][_0xb9f8('0x1b')]=function(_0x3a1c15){if(this[_0xb9f8('0x68')][_0x3a1c15[_0xb9f8('0x9f')]]){this[_0xb9f8('0x68')][_0x3a1c15['linkedid']][_0xb9f8('0x72')]=_0x3a1c15[_0xb9f8('0x72')];}};Preview['prototype'][_0xb9f8('0x16')]=function(_0x5e93e5){var _0x42f9d3=this;var _0x407a8d=this['actions'][_0x5e93e5[_0xb9f8('0x12e')]];if(_0x407a8d){if(_0x407a8d['lookAgent']&&this[_0xb9f8('0x14')][_0x407a8d[_0xb9f8('0xf4')]]){ut[_0xb9f8('0x12f')](_0x407a8d,this[_0xb9f8('0x14')][_0x407a8d[_0xb9f8('0xf4')]][_0xb9f8('0x23')],this[_0xb9f8('0x14')][_0x407a8d['lookAgent']]['id']);}var _0x512374=_[_0xb9f8('0x130')](_0x407a8d);_0x512374['responsetime']=moment()[_0xb9f8('0x57')](_0xb9f8('0x85'));var _0x3eb0cb=_0x42f9d3[_0xb9f8('0x11')][_0x407a8d[_0xb9f8('0x6a')]];if(ut['isFailure'](_0x5e93e5[_0xb9f8('0x131')])){if(_0x407a8d[_0xb9f8('0xbe')]){rpcDb[_0xb9f8('0x106')](_0x407a8d[_0xb9f8('0xf9')]);}if(_0x407a8d['activeContact']){rpcDb['disableContact'](_0x407a8d[_0xb9f8('0xf9')]);}ami[_0xb9f8('0x21')](_0xb9f8('0x132'),ut['buildObj'](_0x407a8d,_0xb9f8('0x133')));this[_0xb9f8('0xe7')](_0x512374,_0x3eb0cb,_0x5e93e5);}else{_0x407a8d[_0xb9f8('0x129')]=moment()[_0xb9f8('0x57')](_0xb9f8('0x85'));ut[_0xb9f8('0xeb')](_0x512374,0x4,'Answer');rpcDb['createAgentHistory'](_0x512374,_0xb9f8('0x134'));}}};Preview['prototype'][_0xb9f8('0x135')]=function(_0x32af63){var _0x12bca0=this;var _0x88b610=this['actions'][_0x32af63[_0xb9f8('0x9f')]];var _0x9dfaf7;if(_0x88b610){_0x9dfaf7=this[_0xb9f8('0x11')][_0x88b610['queue']];logger[_0xb9f8('0x55')](_0xb9f8('0x136'),_0x32af63[_0xb9f8('0x9f')],_0xb9f8('0xa4'),_0x9dfaf7['name'],'pTalking:\x20',_0x9dfaf7[_0xb9f8('0x28')]);}if(this[_0xb9f8('0x68')][_0x32af63[_0xb9f8('0x9f')]]&&_0x32af63['linkedid']!==_0x32af63[_0xb9f8('0xb1')]){if(_0x32af63[_0xb9f8('0x137')]==='16'&&this[_0xb9f8('0x68')][_0x32af63[_0xb9f8('0x9f')]][_0xb9f8('0x6c')]){this[_0xb9f8('0x93')](_0x32af63,_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')]);}else if(this[_0xb9f8('0x68')][_0x32af63['linkedid']][_0xb9f8('0x6c')]){logger['info'](_0xb9f8('0x138'),_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')],_0xb9f8('0xa4'),_0x9dfaf7['name'],_0xb9f8('0xb2'),_0x9dfaf7[_0xb9f8('0x28')]);this[_0xb9f8('0x93')](_0x32af63,_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')]);}}else if(_0x88b610&&_[_0xb9f8('0x67')](_0x88b610['statedesc'])&&_0x9dfaf7['dialQueueProject']&&_0x32af63[_0xb9f8('0x9f')]===_0x32af63[_0xb9f8('0xb1')]&&_[_0xb9f8('0x67')](_0x32af63[_0xb9f8('0xea')])&&_0x32af63[_0xb9f8('0x137')]==='16'&&_0x32af63[_0xb9f8('0x139')]==='6'&&_[_0xb9f8('0xe8')](_0x88b610[_0xb9f8('0x13a')])){if(_0x88b610[_0xb9f8('0xbe')]){rpcDb[_0xb9f8('0x106')](_0x88b610['idContact']);}if(_0x88b610[_0xb9f8('0x9e')]){rpcDb[_0xb9f8('0x13b')](_0x88b610[_0xb9f8('0xf9')]);}_0x32af63[_0xb9f8('0xea')]='22';this[_0xb9f8('0xe7')](_0x88b610,_0x9dfaf7,_0x32af63);}else if(_0x88b610&&_0x88b610[_0xb9f8('0x13a')]){if(_0x32af63['cause']==='16'&&this[_0xb9f8('0x68')][_0x32af63[_0xb9f8('0x9f')]]['dialAnswer']){logger[_0xb9f8('0x55')](_0xb9f8('0x13c'),_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')],'\x20Queue',_0x9dfaf7[_0xb9f8('0x23')],_0xb9f8('0xb2'),_0x9dfaf7[_0xb9f8('0x28')]);this[_0xb9f8('0x93')](_0x32af63,_0x32af63[_0xb9f8('0x9f')],_0x32af63['cause']);}else if(this[_0xb9f8('0x68')][_0x32af63['linkedid']]['dialAnswer']){logger[_0xb9f8('0x55')](_0xb9f8('0x138'),_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')],_0xb9f8('0xa4'),_0x9dfaf7[_0xb9f8('0x23')],_0xb9f8('0xb2'),_0x9dfaf7[_0xb9f8('0x28')]);this[_0xb9f8('0x93')](_0x32af63,_0x32af63[_0xb9f8('0x9f')],_0x32af63[_0xb9f8('0x137')]);}}};Preview[_0xb9f8('0xe')][_0xb9f8('0x13d')]=function(_0x8328ff){if(this[_0xb9f8('0x68')][_0x8328ff[_0xb9f8('0xe6')]]&&_0x8328ff[_0xb9f8('0xe6')]!==_0x8328ff[_0xb9f8('0x13e')]){this[_0xb9f8('0x93')](_0x8328ff,_0x8328ff[_0xb9f8('0xe6')],_0x8328ff[_0xb9f8('0xe0')]);}};Preview[_0xb9f8('0xe')][_0xb9f8('0x13f')]=function(_0x26389c){if(this[_0xb9f8('0x68')][_0x26389c[_0xb9f8('0x9f')]]&&_0x26389c['linkedid']!==_0x26389c['uniqueid']&&!this['actions'][_0x26389c[_0xb9f8('0x9f')]][_0xb9f8('0x6c')]){if(_0x26389c[_0xb9f8('0x137')]==='1'){this[_0xb9f8('0x93')](_0x26389c,_0x26389c['linkedid'],_0x26389c[_0xb9f8('0x137')]);}}};Preview[_0xb9f8('0xe')][_0xb9f8('0x140')]=function(_0x20baa1,_0x4835b2,_0x348961){if(this['actions'][_0x20baa1]){if(_[_0xb9f8('0x67')](this[_0xb9f8('0x68')][_0x20baa1][_0xb9f8('0x141')])){this[_0xb9f8('0x68')][_0x20baa1][_0xb9f8('0x141')]={};}this[_0xb9f8('0x68')][_0x20baa1][_0xb9f8('0x141')][_0x4835b2]=_0x348961;}};Preview[_0xb9f8('0xe')]['syncVarSet']=function(_0x387b96){try{if(!_[_0xb9f8('0x67')](_0x387b96)){if(ut['filterKey'](_[_0xb9f8('0x142')](_0x387b96[_0xb9f8('0x143')])[0x0])){this['addVariable'](_0x387b96[_0xb9f8('0xb1')],_[_0xb9f8('0x142')](_0x387b96[_0xb9f8('0x143')])[0x0],_0x387b96['value']);}}}catch(_0x1d2630){logger[_0xb9f8('0x144')](_0xb9f8('0x145'),util['inspect'](_0x1d2630,{'showHidden':![],'depth':null}));}};Preview['prototype'][_0xb9f8('0x146')]=function(_0x4f13c1){if(_0x4f13c1){if(this[_0xb9f8('0x68')][_0x4f13c1[_0xb9f8('0x147')]]){this[_0xb9f8('0x68')][_0x4f13c1[_0xb9f8('0x147')]][_0xb9f8('0x13a')]=!![];}}};Preview[_0xb9f8('0xe')]['syncBlindTransfer']=function(_0x279d95){if(_0x279d95){if(this[_0xb9f8('0x68')][_0x279d95[_0xb9f8('0x148')]]){this[_0xb9f8('0x68')][_0x279d95[_0xb9f8('0x148')]][_0xb9f8('0x13a')]=!![];}}};module[_0xb9f8('0x149')]=Preview;