c1552b7e538b152b245321401277fd5a1a36e40d
[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 _0x34e8=['newexten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','syncBlindTransfer','loopCampaigns','type','outbound','strategy','answered','loggedIn','pTalking','sumDuration','sumHoldTime','talking','unmanaged','loggedInDb','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','outboundAnswerAgiCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','originated','erlangCalls','erlangCallToSecond','erlangBusyFactor','startPredictive','startProgressive','Trunk','callerid','Interval','voice:queue:%s','name','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','format','voice_queue_channel:remove','sendMessageOneNotActive','available','paused','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','\x20is\x20disactive','syncCampaigns','hasOwnProperty','booked','clearZombieChannels','dialActive','setMessage','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','isNil','actions','[clearZombieChannels][talking]','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','contactId','VoiceQueueId','ListId','status','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','decrementTalkink','loggerError','[action]','size','getContactRecallMe','agentReadyId','then','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','YYYY-MM-DD\x20HH:mm:ss','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','IsNotLoggedIn','AGENTS_NOT_LOGGED','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','callProgressDetectingCustomer','countnosuchnumberretry','totalGlobal','custom:agentnosuchnumber','buildObj','[callProgressDetectingCustomer][logNoSuch]','dialGlobalMaxRetry','cloneAction','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','scheduledAt','dialNoSuchNumberRetryFrequency','unlockAgent','activeContact','linkedid','ANSWER','responsetime','[syncHangup][talking][increment]','uniqueid','\x20Queue','emit','acw','custom:agentConnectPreview','custom:agentcomplete','complete','outboundAnswerCallsDay','total','[16]','countglobal','[callProgressDetectingCustomer][logAnswer]','crateCustomerReportQueue','talktime','sumBillable','[syncHangup][talking][decrement]','BUSY','outboundBusyCallsDay','countbusyretry','Busy','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','Global','dialBusyMaxRetry','rescheduleContact','dialBusyRetryFrequency','outboundNoAnswerCallsDay','countnoanswerretry','noanswer','[callProgressDetectingCustomer][logNoAnswer]','[callProgressDetectingCustomer][logNoAnswerGlobal]','dialNoAnswerMaxRetry','dialNoAnswerRetryFrequency','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','congestion','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','custom:agentreject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','ABANDONED','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','callProgressDetectingAgent','isUndefined','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','NoAnswer','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','Contact','phone','Queue','lookAgent','isEmpty','execCall','\x20IdHopper:\x20','custom:agentcalled','called','Calling','Call\x20failed','[Blacklist][error]','active','SIP/%s','execRun','unlock','unlockContact','getContactPreview','recallme','validateContact','isValid','checkIsBlackList','Contact.phone','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','[Preview][validateContact][Empty\x20Campaign]','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','isActive','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','campaign\x20Name:\x20','Is\x20Valid','SIP/%s/%s%s','trim','dialCutDigit','substring','getCallerId','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','Action','variablesAction','[originated][increment]','OriginateError','syncNewExten','channel','syncOriginateResponse','actionid','logLookAgent','isFailure','rejected','Answer','syncHangup','cause','[syncHangup][talking][cause]','dialQueueProject','channelstate','idContact','transfer','[syncHangup][talking][transfer]','destuniqueid','variables','keys','variable','value','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','exports','util','lodash','bluebird','uuid','md5','ioredis','../../../config/environment','../../../config/logger','preview','actionPreview','./rpcDb','./util/util','redis','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','sequence','campaignsPreview','trunks','agents','clockClearZombieChannels','originateresponse','bind','hangup','syncHangupRequest','syncDialEnd'];(function(_0x2c68e5,_0x573568){var _0x174ab0=function(_0x5a0e1f){while(--_0x5a0e1f){_0x2c68e5['push'](_0x2c68e5['shift']());}};_0x174ab0(++_0x573568);}(_0x34e8,0x12c));var _0x834e=function(_0x12dec7,_0x2ddb55){_0x12dec7=_0x12dec7-0x0;var _0x2720c7=_0x34e8[_0x12dec7];return _0x2720c7;};'use strict';var util=require(_0x834e('0x0'));var _=require(_0x834e('0x1'));var BPromise=require(_0x834e('0x2'));var uuid=require(_0x834e('0x3'));var moment=require('moment');var md5=require(_0x834e('0x4'));var Redis=require(_0x834e('0x5'));var config=require(_0x834e('0x6'));var logger=require(_0x834e('0x7'))(_0x834e('0x8'));var loggerAction=require(_0x834e('0x7'))(_0x834e('0x9'));var ami=require('../ami');var rpcDb=require(_0x834e('0xa'));var Action=require('./action');var ut=require(_0x834e('0xb'));config[_0x834e('0xc')]=_[_0x834e('0xd')](config[_0x834e('0xc')],{'host':_0x834e('0xe'),'port':0x18eb});var io=require(_0x834e('0xf'))(new Redis(config[_0x834e('0xc')]));var Sequence=function(){};Sequence[_0x834e('0x10')][_0x834e('0x11')]=function(_0x186b3b){this[_0x834e('0x12')]=this[_0x834e('0x12')]?this[_0x834e('0x12')][_0x834e('0x13')](_0x186b3b):_0x186b3b();};function Preview(_0x293514){this[_0x834e('0x14')]=new Sequence();this[_0x834e('0x15')]=_0x293514['voiceQueues'];this[_0x834e('0x16')]=_0x293514[_0x834e('0x16')];this['actions']={};this[_0x834e('0x17')]=_0x293514[_0x834e('0x17')];this[_0x834e('0x18')]=0x0;ami['on'](_0x834e('0x19'),this['syncOriginateResponse'][_0x834e('0x1a')](this));ami['on'](_0x834e('0x1b'),this['syncHangup'][_0x834e('0x1a')](this));ami['on']('hanguprequest',this[_0x834e('0x1c')][_0x834e('0x1a')](this));ami['on']('dialend',this[_0x834e('0x1d')][_0x834e('0x1a')](this));ami['on'](_0x834e('0x1e'),this['syncNewExten'][_0x834e('0x1a')](this));ami['on'](_0x834e('0x1f'),this[_0x834e('0x20')][_0x834e('0x1a')](this));ami['on'](_0x834e('0x21'),this[_0x834e('0x22')][_0x834e('0x1a')](this));ami['on']('blindtransfer',this[_0x834e('0x23')][_0x834e('0x1a')](this));this[_0x834e('0x24')](this[_0x834e('0x15')]);}function emit(_0x4ab05d,_0x45a630,_0x62f8f1){io['to'](_0x4ab05d)['emit'](_0x45a630,_0x62f8f1);}function emitCampaignPreview(_0x1b4bdf){if(_0x1b4bdf[_0x834e('0x25')]===_0x834e('0x26')){var _0x5c55ca={'id':_0x1b4bdf['id'],'name':_0x1b4bdf['name'],'strategy':_0x1b4bdf[_0x834e('0x27')],'answered':_0x1b4bdf[_0x834e('0x28')],'available':_0x1b4bdf['available'],'loggedIn':_0x1b4bdf[_0x834e('0x29')],'pTalking':_0x1b4bdf[_0x834e('0x2a')],'sumBillable':_0x1b4bdf['sumBillable'],'sumDuration':_0x1b4bdf[_0x834e('0x2b')],'sumHoldTime':_0x1b4bdf[_0x834e('0x2c')]||0x0,'talking':_0x1b4bdf[_0x834e('0x2d')],'total':_0x1b4bdf['total'],'type':_0x1b4bdf[_0x834e('0x25')],'unmanaged':_0x1b4bdf[_0x834e('0x2e')],'abandoned':_0x1b4bdf['abandoned'],'waiting':_0x1b4bdf['waiting'],'loggedInDb':_0x1b4bdf[_0x834e('0x2f')],'dialActive':_0x1b4bdf['dialActive'],'dialMethod':_0x1b4bdf[_0x834e('0x30')],'dialOriginateCallerIdName':_0x1b4bdf[_0x834e('0x31')],'dialOriginateCallerIdNumber':_0x1b4bdf[_0x834e('0x32')],'dialOriginateTimeout':_0x1b4bdf[_0x834e('0x33')],'dialPrefix':_0x1b4bdf[_0x834e('0x34')],'outboundAnswerAgiCallsDay':_0x1b4bdf[_0x834e('0x35')],'outboundAnswerCallsDay':_0x1b4bdf['outboundAnswerCallsDay'],'outboundBlacklistCallsDay':_0x1b4bdf['outboundBlacklistCallsDay'],'outboundBusyCallsDay':_0x1b4bdf['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0x1b4bdf['outboundCongestionCallsDay'],'outboundDropCallsDayACS':_0x1b4bdf[_0x834e('0x36')],'outboundDropCallsDayCallersExit':_0x1b4bdf[_0x834e('0x37')],'outboundDropCallsDayTimeout':_0x1b4bdf[_0x834e('0x38')],'outboundNoAnswerCallsDay':_0x1b4bdf['outboundNoAnswerCallsDay'],'outboundNoSuchCallsDay':_0x1b4bdf[_0x834e('0x39')],'outboundOriginateFailureCallsDay':_0x1b4bdf[_0x834e('0x3a')],'outboundReCallsDay':_0x1b4bdf[_0x834e('0x3b')],'outboundRejectCallsDay':_0x1b4bdf[_0x834e('0x3c')],'outboundUnknownCallsDay':_0x1b4bdf[_0x834e('0x3d')],'outboundAbandonedCallsDay':_0x1b4bdf[_0x834e('0x3e')],'predictiveIntervalAnsweredCalls':_0x1b4bdf[_0x834e('0x3f')],'predictiveIntervalAvgHoldtime':_0x1b4bdf[_0x834e('0x40')],'predictiveIntervalAvgTalktime':_0x1b4bdf[_0x834e('0x41')],'predictiveIntervalDroppedCallsCallersExit':_0x1b4bdf['predictiveIntervalDroppedCallsCallersExit'],'predictiveIntervalDroppedCallsTimeout':_0x1b4bdf[_0x834e('0x42')],'predictiveIntervalErlangCalls':_0x1b4bdf['predictiveIntervalErlangCalls'],'predictiveIntervalErlangCallsDroppedCalls':_0x1b4bdf[_0x834e('0x43')],'predictiveIntervalHitRate':_0x1b4bdf[_0x834e('0x44')],'predictiveIntervalMultiplicativeFactor':_0x1b4bdf[_0x834e('0x45')],'predictiveIntervalPauses':_0x1b4bdf[_0x834e('0x46')],'predictiveIntervalAvailable':_0x1b4bdf[_0x834e('0x47')],'predictiveIntervalTotalCalls':_0x1b4bdf[_0x834e('0x48')],'message':_0x1b4bdf[_0x834e('0x49')],'originated':_0x1b4bdf[_0x834e('0x4a')],'erlangCalls':_0x1b4bdf[_0x834e('0x4b')],'erlangCallToSecond':_0x1b4bdf[_0x834e('0x4c')],'erlangAbandonmentRate':_0x1b4bdf['erlangAbandonmentRate'],'erlangBusyFactor':_0x1b4bdf[_0x834e('0x4d')],'startPredictive':_0x1b4bdf[_0x834e('0x4e')],'startProgressive':_0x1b4bdf[_0x834e('0x4f')]};if(_0x1b4bdf[_0x834e('0x50')]){_0x5c55ca['Trunk']={'id':_0x1b4bdf[_0x834e('0x50')]['id'],'name':_0x1b4bdf[_0x834e('0x50')]['name'],'active':_0x1b4bdf['Trunk']['active'],'callerid':_0x1b4bdf[_0x834e('0x50')][_0x834e('0x51')]};}if(_0x1b4bdf[_0x834e('0x52')]){_0x5c55ca[_0x834e('0x52')]={'id':_0x1b4bdf[_0x834e('0x52')]['id'],'name':_0x1b4bdf[_0x834e('0x52')]['name']};}var _0x2c2d94=md5(JSON['stringify'](_0x5c55ca));if(_0x1b4bdf[_0x834e('0x4')]!==_0x2c2d94){_0x1b4bdf[_0x834e('0x4')]=_0x2c2d94;emit(util['format'](_0x834e('0x53'),_0x5c55ca[_0x834e('0x54')]),'voice_queue:save',_0x5c55ca);}}}function emitVoiceQueueChannelRemove(_0x481f70){logger[_0x834e('0x55')](_0x834e('0x56'),JSON[_0x834e('0x57')](_0x481f70));emit(util[_0x834e('0x58')](_0x834e('0x53'),_0x481f70['name']),_0x834e('0x59'),_0x481f70);io['emit']('voice_queue_presence:remove',_0x481f70);}function notSendMessagesQueue(_0x1b2edf){if(_0x1b2edf['sendMessageOneNotActive']){if(_0x1b2edf[_0x834e('0x4a')]===0x0&&_0x1b2edf[_0x834e('0x2a')]===0x0){_0x1b2edf[_0x834e('0x5a')]=![];_0x1b2edf[_0x834e('0x5b')]=0x0;_0x1b2edf[_0x834e('0x5c')]=0x0;_0x1b2edf['message']=_0x834e('0x5d');ut[_0x834e('0x5e')](_0x834e('0x5f'),_0x1b2edf['name']+_0x834e('0x60'));}else{_0x1b2edf[_0x834e('0x49')]='IS_DISACTIVED';ut[_0x834e('0x5e')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x1b2edf[_0x834e('0x54')]+_0x834e('0x61'));}emitCampaignPreview(_0x1b2edf);}}Preview['prototype']['loopCampaigns']=function(){var _0x22ea21=this;setInterval(function(){_0x22ea21[_0x834e('0x62')]();},0x7cf);};Preview[_0x834e('0x10')][_0x834e('0x62')]=function(){var _0x8ad264=this[_0x834e('0x15')];this[_0x834e('0x18')]+=0x1;for(var _0x4a3381 in _0x8ad264){if(_0x8ad264[_0x834e('0x63')](_0x4a3381)&&(_0x8ad264[_0x4a3381]['dialMethod']===_0x834e('0x8')||_0x8ad264[_0x4a3381]['dialMethod']===_0x834e('0x64'))&&_0x8ad264[_0x4a3381]['type']===_0x834e('0x26')){if(this[_0x834e('0x18')]>0x7){this['clockClearZombieChannels']=0x0;this[_0x834e('0x65')]();}}if(_0x8ad264[_0x834e('0x63')](_0x4a3381)&&_0x8ad264[_0x4a3381][_0x834e('0x30')]===_0x834e('0x8')&&_0x8ad264[_0x4a3381][_0x834e('0x25')]===_0x834e('0x26')){if(_0x8ad264[_0x4a3381][_0x834e('0x66')]){this[_0x834e('0x67')](_0x8ad264[_0x4a3381]);if(_0x8ad264[_0x4a3381][_0x834e('0x68')])this[_0x834e('0x69')](_0x8ad264[_0x4a3381]);}else{notSendMessagesQueue(_0x8ad264[_0x4a3381]);}}}};Preview['prototype'][_0x834e('0x6a')]=function(_0x6fff27){var _0x47a8a9=this;this[_0x834e('0x14')][_0x834e('0x11')](function(){if(!_[_0x834e('0x6b')](_0x47a8a9[_0x834e('0x6c')][_0x6fff27])){loggerAction[_0x834e('0x55')](_0x834e('0x6d'),_0x6fff27,'Queue',_0x47a8a9['actions'][_0x6fff27][_0x834e('0x6e')],_0x834e('0x6f'),JSON[_0x834e('0x57')](_0x47a8a9[_0x834e('0x15')][_0x47a8a9[_0x834e('0x6c')][_0x6fff27][_0x834e('0x6e')]][_0x834e('0x4a')]),_0x834e('0x70'),JSON[_0x834e('0x57')](_0x47a8a9[_0x834e('0x15')][_0x47a8a9[_0x834e('0x6c')][_0x6fff27][_0x834e('0x6e')]][_0x834e('0x2a')]),JSON[_0x834e('0x57')](_0x47a8a9[_0x834e('0x6c')][_0x6fff27][_0x834e('0x71')]),JSON[_0x834e('0x57')](_[_0x834e('0x72')](_0x47a8a9[_0x834e('0x6c')][_0x6fff27],[_0x834e('0x73'),'UserId',_0x834e('0x74'),_0x834e('0x75')])));return ami['Action']({'action':_0x834e('0x76'),'channel':_0x47a8a9[_0x834e('0x6c')][_0x6fff27]['channel']})[_0x834e('0x77')](function(_0x4ebe40){if(_0x4ebe40[_0x834e('0x49')]===_0x834e('0x78')){setTimeout(function(){if(_0x47a8a9[_0x834e('0x6c')][_0x6fff27]){ut[_0x834e('0x79')](_0x47a8a9[_0x834e('0x15')][_0x47a8a9['actions'][_0x6fff27][_0x834e('0x6e')]],_0x834e('0x7a'));if(_0x47a8a9[_0x834e('0x6c')][_0x6fff27][_0x834e('0x71')]===!![]){ut[_0x834e('0x7b')](_0x47a8a9[_0x834e('0x15')][_0x47a8a9[_0x834e('0x6c')][_0x6fff27][_0x834e('0x6e')]],'[clearZombieChannel]');ut[_0x834e('0x7c')]('[Dialer][checkChannel][pTalking][Preview]'+_0x6fff27,_0x47a8a9[_0x834e('0x6c')][_0x6fff27]['queue']);}ut[_0x834e('0x7c')]('[Dialer][checkChannel][Preview]'+_0x6fff27,_0x47a8a9['actions'][_0x6fff27][_0x834e('0x6e')]);delete _0x47a8a9[_0x834e('0x6c')][_0x6fff27];}},0x2328);}});}});};Preview['prototype']['clearZombieChannels']=function(){var _0x2c8155=this;loggerAction[_0x834e('0x55')](_0x834e('0x7d'),_[_0x834e('0x7e')](this[_0x834e('0x6c')]));for(var _0x315858 in this[_0x834e('0x6c')]){if(_0x2c8155[_0x834e('0x6c')]['hasOwnProperty'](_0x315858)){_0x2c8155[_0x834e('0x6a')](_0x315858);}}};Preview[_0x834e('0x10')]['recallMe']=function(_0x281342){var _0x4e2b22=this;rpcDb[_0x834e('0x7f')](_0x281342['id'],ut[_0x834e('0x80')](this['agents']))[_0x834e('0x81')](function(_0x37ee0e){if(!_[_0x834e('0x6b')](_0x37ee0e)){for(var _0x25f720=0x0;_0x25f720<_0x37ee0e['length'];_0x25f720+=0x1){if(ut[_0x834e('0x82')](_0x37ee0e[_0x25f720][_0x834e('0x83')])<_0x281342[_0x834e('0x84')]*0x3c){if(_0x37ee0e[_0x25f720]['Agent']&&!_0x37ee0e[_0x25f720][_0x834e('0x85')][_0x834e('0x86')]){_0x4e2b22[_0x834e('0x87')](_0x37ee0e[_0x25f720]['id'])[_0x834e('0x81')](ut[_0x834e('0x88')](_0x834e('0x89')))[_0x834e('0x77')](ut[_0x834e('0x88')](_0x834e('0x89')));}else{rpcDb[_0x834e('0x8a')](_0x37ee0e[_0x25f720]['id']);}}else{var _0x1e4310=new Action(_0x37ee0e[_0x25f720],_0x281342);_0x1e4310[_0x834e('0x8b')]=moment()[_0x834e('0x58')](_0x834e('0x8c'));_0x281342[_0x834e('0x3b')]+=0x1;ut[_0x834e('0x8d')](_0x1e4310,0x17,_0x834e('0x8e'));if(_0x281342[_0x834e('0x8f')]){rpcDb[_0x834e('0x90')](ut[_0x834e('0x91')](_0x37ee0e[_0x25f720]));rpcDb[_0x834e('0x92')](_0x1e4310,_0x834e('0x93'));}else{ut['logCustomer'](_0x1e4310,0x16,_0x834e('0x94'));rpcDb[_0x834e('0x92')](_0x1e4310,_0x834e('0x95'));rpcDb[_0x834e('0x96')](_0x1e4310,'[HistoryRecallClose]');}}}}})[_0x834e('0x77')](ut['logger2']('[getContactRecallMe]'));};Preview[_0x834e('0x10')][_0x834e('0x67')]=function(_0x1644dd){_0x1644dd[_0x834e('0x5a')]=!![];if(ut[_0x834e('0x97')](_0x1644dd[_0x834e('0x29')])){_0x1644dd[_0x834e('0x49')]=_0x834e('0x98');}else if(!ut['isActive'](_0x1644dd[_0x834e('0x66')])){_0x1644dd['message']=_0x834e('0x5d');}else if(!this[_0x834e('0x99')](_0x1644dd['Trunk'])){if(!this['isTrunkReachable'](_0x1644dd[_0x834e('0x9a')])){_0x1644dd[_0x834e('0x49')]=_0x834e('0x9b');}else{_0x1644dd[_0x834e('0x49')]=_0x834e('0x9c');}}else{_0x1644dd['message']=_0x834e('0x9c');}emitCampaignPreview(_0x1644dd);};Preview[_0x834e('0x10')][_0x834e('0x9d')]=function(_0x228a60,_0x3181af,_0x28b5c9){var _0x87818b=this;var _0x413d5e=this[_0x834e('0x6c')][_0x3181af];var _0x324f67=this['campaignsPreview'][_0x413d5e[_0x834e('0x6e')]];var _0x2e4d80;if(_0x324f67){switch(_0x28b5c9){case'1':_0x324f67[_0x834e('0x39')]+=0x1;_0x413d5e[_0x834e('0x9e')]+=0x1;_0x413d5e['countglobal']=ut[_0x834e('0x9f')](_0x413d5e);ut['logCustomer'](_0x413d5e,0x0,'NoSuchNumber');ami['emit'](_0x834e('0xa0'),ut[_0x834e('0xa1')](_0x413d5e,'nosuchnumber'));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xa2'));if(ut['totalGlobal'](_0x413d5e)>=_0x324f67[_0x834e('0xa3')]){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,'Global');rpcDb['createCustomerFinal'](_0x2e4d80,_0x834e('0xa5'));}else{if(_0x413d5e[_0x834e('0x9e')]>=_0x324f67[_0x834e('0xa6')]){rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xa5'));}else{rpcDb['rescheduleContact'](ut[_0x834e('0xa7')](_0x413d5e,'countnosuchnumberretry',_0x324f67[_0x834e('0xa8')]),_0x413d5e[_0x834e('0xa9')],_0x413d5e[_0x834e('0xaa')]);}}delete this['actions'][_0x228a60[_0x834e('0xab')]];break;case _0x834e('0xac'):var _0x48521f=moment()[_0x834e('0x58')](_0x834e('0x8c'));_0x413d5e[_0x834e('0xad')]=_0x48521f;_0x413d5e['answertime']=_0x48521f;_0x413d5e[_0x834e('0x71')]=!![];_0x324f67[_0x834e('0x2a')]+=0x1;logger[_0x834e('0x55')](_0x834e('0xae'),_0x413d5e[_0x834e('0xaf')],_0x834e('0xb0'),_0x324f67[_0x834e('0x54')],_0x834e('0x70'),_0x324f67[_0x834e('0x2a')]);ami[_0x834e('0xb1')]('custom:agentconnect',ut['buildObj'](_0x413d5e,'connect',this[_0x834e('0x15')][_0x413d5e[_0x834e('0x6e')]]));if(_0x324f67[_0x834e('0xb2')]){ami[_0x834e('0xb1')](_0x834e('0xb3'),ut['buildAcw'](_0x413d5e));}break;case'16':ami['emit'](_0x834e('0xb4'),ut[_0x834e('0xa1')](_0x413d5e,_0x834e('0xb5'),this[_0x834e('0x15')][_0x413d5e[_0x834e('0x6e')]]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x413d5e,_0x834e('0xb5')));_0x324f67[_0x834e('0xb6')]+=0x1;_0x324f67[_0x834e('0xb7')]+=0x1;_0x324f67['answered']+=0x1;ut[_0x834e('0x7b')](_0x324f67,_0x834e('0xb8'));_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut[_0x834e('0x8d')](_0x413d5e,0x4,'Answer');rpcDb['createCustomerHistory'](_0x413d5e,_0x834e('0xba'));rpcDb[_0x834e('0x96')](_0x413d5e,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb[_0x834e('0xbb')](_0x413d5e);_0x324f67['sumDuration']+=_0x413d5e[_0x834e('0xbc')];_0x324f67[_0x834e('0xbd')]+=_0x413d5e[_0x834e('0xbc')];logger['info'](_0x834e('0xbe'),_0x413d5e['uniqueid'],'\x20Queue',_0x324f67['name'],_0x834e('0x70'),_0x324f67[_0x834e('0x2a')]);delete this[_0x834e('0x6c')][_0x228a60[_0x834e('0xab')]];break;case _0x834e('0xbf'):_0x324f67[_0x834e('0xc0')]+=0x1;_0x413d5e[_0x834e('0xc1')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut['logCustomer'](_0x413d5e,0x5,_0x834e('0xc2'));ami['emit'](_0x834e('0xc3'),ut[_0x834e('0xa1')](_0x413d5e,_0x834e('0xc4')));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xc5'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67['dialGlobalMaxRetry']){_0x2e4d80=ut['cloneAction'](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,'[callProgressDetectingCustomer][logBusyGlobal]');}else{if(_0x413d5e[_0x834e('0xc1')]>=_0x324f67[_0x834e('0xc7')]){rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xc5'));}else{rpcDb[_0x834e('0xc8')](ut['scheduledAt'](_0x413d5e,_0x834e('0xc1'),_0x324f67[_0x834e('0xc9')]),_0x413d5e['unlockAgent'],_0x413d5e['activeContact']);}}break;case'NOANSWER':_0x324f67[_0x834e('0xca')]+=0x1;_0x413d5e[_0x834e('0xcb')]+=0x1;_0x413d5e['countglobal']=ut[_0x834e('0x9f')](_0x413d5e);ut[_0x834e('0x8d')](_0x413d5e,0x3,'NoAnswer');ami[_0x834e('0xb1')]('custom:agentnoanswer',ut['buildObj'](_0x413d5e,_0x834e('0xcc')));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xcd'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67['dialGlobalMaxRetry']){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,_0x834e('0xce'));}else{if(_0x413d5e[_0x834e('0xcb')]>=_0x324f67[_0x834e('0xcf')]){rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xcd'));}else{rpcDb[_0x834e('0xc8')](ut[_0x834e('0xa7')](_0x413d5e,_0x834e('0xcb'),_0x324f67[_0x834e('0xd0')]),_0x413d5e[_0x834e('0xa9')],_0x413d5e[_0x834e('0xaa')]);}}break;case _0x834e('0xd1'):_0x324f67[_0x834e('0xd2')]+=0x1;_0x413d5e[_0x834e('0xd3')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut[_0x834e('0x8d')](_0x413d5e,0x8,_0x834e('0xd4'));ami[_0x834e('0xb1')]('custom:agentcongestion',ut[_0x834e('0xa1')](_0x413d5e,_0x834e('0xd5')));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xd6'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67[_0x834e('0xa3')]){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,'[callProgressDetectingCustomer][logCongestionGlobal]');}else{if(_0x413d5e['countcongestionretry']>=_0x324f67['dialCongestionMaxRetry']){rpcDb[_0x834e('0x96')](_0x413d5e,'[callProgressDetectingCustomer][logCongestion]');}else{rpcDb[_0x834e('0xc8')](ut[_0x834e('0xa7')](_0x413d5e,_0x834e('0xd3'),_0x324f67['dialBusyRetryFrequency']),_0x413d5e[_0x834e('0xa9')],_0x413d5e[_0x834e('0xaa')]);}}break;case _0x834e('0xd7'):_0x324f67[_0x834e('0x3c')]+=0x1;_0x413d5e[_0x834e('0xd8')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut['totalGlobal'](_0x413d5e);ut[_0x834e('0x8d')](_0x413d5e,0x14,_0x834e('0xd9'));ami[_0x834e('0xb1')](_0x834e('0xda'),ut[_0x834e('0xa1')](_0x413d5e,'agentreject'));rpcDb['createCustomerHistory'](_0x413d5e,'[syncHangupRequest][logAgentReject]');if(ut['totalGlobal'](_0x413d5e)>=_0x324f67[_0x834e('0xa3')]){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0x14,'AgentReject');rpcDb[_0x834e('0x96')](_0x2e4d80,_0x834e('0xdb'));}else{if(_0x413d5e['countagentrejectretry']>=_0x324f67[_0x834e('0xdc')]){rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xdb'));}else{rpcDb[_0x834e('0xc8')](ut[_0x834e('0xa7')](_0x413d5e,_0x834e('0xd8'),_0x324f67['dialAgentRejectRetryFrequency']),_0x413d5e['unlockAgent'],_0x413d5e[_0x834e('0xaa')]);}}break;case _0x834e('0xdd'):_0x324f67[_0x834e('0x3e')]+=0x1;_0x413d5e['countabandonedretry']+=0x1;_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut['logCustomer'](_0x413d5e,0xb,_0x834e('0xde'));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xdf'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67['dialGlobalMaxRetry']){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,'Global');rpcDb['createCustomerFinal'](_0x2e4d80,_0x834e('0xdf'));}else{if(_0x413d5e[_0x834e('0xe0')]>=_0x324f67[_0x834e('0xe1')]){rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xdf'));}else{rpcDb[_0x834e('0xc8')](ut['scheduledAt'](_0x413d5e,'countabandonedretry',_0x324f67[_0x834e('0xe2')]),_0x413d5e[_0x834e('0xa9')],_0x413d5e[_0x834e('0xaa')]);}}break;case'18':_0x324f67[_0x834e('0x3d')]+=0x1;_0x413d5e[_0x834e('0xe3')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut['logCustomer'](_0x413d5e,0x12,_0x228a60[_0x834e('0xe4')]||_0x228a60[_0x834e('0xe5')]);ami['emit'](_0x834e('0xe6'),ut[_0x834e('0xa1')](_0x413d5e,_0x834e('0xe7')));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xe8'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67[_0x834e('0xa3')]){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,_0x834e('0xe8'));}else{rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xe8'));}delete this[_0x834e('0x6c')][_0x228a60['linkedid']];break;case'19':_0x324f67[_0x834e('0x3d')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut['totalGlobal'](_0x413d5e);ut[_0x834e('0x8d')](_0x413d5e,0x13,_0x228a60['cause-txt']||_0x228a60[_0x834e('0xe5')]);ami['emit'](_0x834e('0xe6'),ut['buildObj'](_0x413d5e,_0x834e('0xe7')));rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xe9'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67['dialGlobalMaxRetry']){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,_0x834e('0xe9'));}else{rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xe9'));}delete this[_0x834e('0x6c')][_0x228a60[_0x834e('0xab')]];break;default:if(_0x413d5e[_0x834e('0x71')]){ut[_0x834e('0x7b')](_0x324f67,_0x834e('0xea'));ut[_0x834e('0x7c')](_0x834e('0xeb')+_0x324f67[_0x834e('0x54')],_0x228a60);}_0x324f67[_0x834e('0x3d')]+=0x1;_0x413d5e[_0x834e('0xb9')]=ut[_0x834e('0x9f')](_0x413d5e);ut['logCustomer'](_0x413d5e,0xc,_0x228a60['cause-txt']||_0x228a60[_0x834e('0xe5')]);rpcDb[_0x834e('0x92')](_0x413d5e,_0x834e('0xec'));if(ut[_0x834e('0x9f')](_0x413d5e)>=_0x324f67[_0x834e('0xa3')]){_0x2e4d80=ut[_0x834e('0xa4')](_0x413d5e,0xf,_0x834e('0xc6'));rpcDb[_0x834e('0x96')](_0x2e4d80,_0x834e('0xed'));}else{rpcDb[_0x834e('0x96')](_0x413d5e,_0x834e('0xed'));}delete this[_0x834e('0x6c')][_0x228a60['linkedid']];}if(!(_0x413d5e[_0x834e('0x71')]&&_0x28b5c9==='16')){ut['updateOriginated'](_0x324f67,_0x834e('0xee'));logger[_0x834e('0x55')](_0x834e('0xef'),_0x413d5e['uniqueid'],_0x834e('0xb0'),_0x324f67[_0x834e('0x54')],'originated:\x20',_0x324f67['originated']);}if(_0x28b5c9!==_0x834e('0xac')){delete this[_0x834e('0x6c')][_0x228a60['linkedid']];delete this[_0x834e('0x6c')][_0x228a60[_0x834e('0xf0')]];}}};Preview[_0x834e('0x10')][_0x834e('0xf1')]=function(_0x170ec2,_0x5e6fff,_0x4e7545){if(_[_0x834e('0xf2')](_0x5e6fff)&&'object'!==typeof _0x5e6fff){return;}if(_['isUndefined'](_0x4e7545)&&'object'!==typeof _0x4e7545){return;}switch(_0x4e7545[_0x834e('0xf3')]){case'0':ut[_0x834e('0xf4')](_0x170ec2,0x0,'NoSuchNumber');rpcDb[_0x834e('0xf5')](_0x170ec2,_0x834e('0xf6'));break;case'3':ut[_0x834e('0xf4')](_0x170ec2,0x3,_0x834e('0xf7'));rpcDb['createAgentHistory'](_0x170ec2,_0x834e('0xf8'));break;case'5':ut[_0x834e('0xf4')](_0x170ec2,0x5,_0x834e('0xc2'));rpcDb['createAgentHistory'](_0x170ec2,_0x834e('0xf9'));break;case'8':ut['logAgent'](_0x170ec2,0x8,_0x834e('0xd4'));rpcDb['createAgentHistory'](_0x170ec2,_0x834e('0xfa'));break;case'22':ut[_0x834e('0xf4')](_0x170ec2,0x16,'AnswerAGI');rpcDb[_0x834e('0xf5')](_0x170ec2,_0x834e('0xfb'));break;default:ut[_0x834e('0xf4')](_0x170ec2,0xc,_0x4e7545[_0x834e('0xf3')]);rpcDb[_0x834e('0xf5')](_0x170ec2,_0x834e('0xfa'));}ut['updateOriginated'](_0x5e6fff,_0x834e('0xfc'));logger[_0x834e('0x55')](_0x834e('0xfd'),_0x170ec2[_0x834e('0xaf')],_0x834e('0xb0'),_0x5e6fff[_0x834e('0x54')],'originated:\x20',_0x5e6fff[_0x834e('0x4a')]);delete this['actions'][_0x170ec2['uniqueid']];};Preview[_0x834e('0x10')]['checkInBlack']=function(_0x4c5da4,_0xa64f40,_0x27624b,_0x257fed,_0x2e5886){var _0x38fbc4=this;return new BPromise(function(_0x3e0ee6,_0x32959e){if(_[_0x834e('0x6b')](_0xa64f40)||_[_0x834e('0x6b')](_0xa64f40[_0x834e('0xfe')])||_[_0x834e('0x6b')](_0xa64f40[_0x834e('0xfe')][_0x834e('0xff')])||_[_0x834e('0x6b')](_0xa64f40['VoiceQueueId'])){_0x32959e(ut[_0x834e('0x49')]('Contact\x20is\x20undefined',_0x257fed,_0x2e5886));return;}var _0x14167d=uuid['v4']();var _0x373fe7=_0x38fbc4[_0x834e('0x15')][_0xa64f40[_0x834e('0x100')]['name']];var _0x5f558a=_0x27624b?_0x38fbc4[_0x834e('0x17')][_0x27624b]['id']:undefined;_0x38fbc4[_0x834e('0x6c')][_0x14167d]=new Action(_0xa64f40,_0x373fe7,_0x14167d,_0x27624b,_0x5f558a);var _0x5d8466=_0x38fbc4[_0x834e('0x6c')][_0x14167d];_0x5d8466[_0x834e('0xa9')]=_0x257fed;_0x5d8466['activeContact']=_0x2e5886;_0x5d8466[_0x834e('0x101')]=_0x27624b;if(_[_0x834e('0x102')](_0x4c5da4)){_0x38fbc4[_0x834e('0x103')](_0x5d8466,_0x373fe7,_0xa64f40,_0x27624b)[_0x834e('0x81')](function(_0x4e7ad0){logger['info']('[Preview][execCall][success]','Queue:\x20'+_0x5d8466[_0x834e('0x6e')]+_0x834e('0x104')+_0x5d8466['idContact'],JSON[_0x834e('0x57')](_0x4e7ad0));ami['emit'](_0x834e('0x105'),ut[_0x834e('0xa1')](_0x5d8466,_0x834e('0x106'),_0x38fbc4[_0x834e('0x15')][_0x5d8466[_0x834e('0x6e')]]));_0x3e0ee6(ut[_0x834e('0x49')](_0x834e('0x107')));})['catch'](function(_0x12a0f3){ut[_0x834e('0x5e')]('[Preview][execCall][failure]',_0x12a0f3);_0x32959e(ut[_0x834e('0x49')](_0x834e('0x108'),_0x257fed,_0x2e5886));});}else{_0x373fe7['outboundBlacklistCallsDay']+=0x1;ut['logBlacklist'](_0x5d8466);rpcDb['createHistory'](_0x5d8466,_0x834e('0x109'));delete _0x38fbc4[_0x834e('0x6c')][_0x14167d];_0x32959e(ut[_0x834e('0x49')]('Contact\x20in\x20black\x20List',_0x257fed,_0x2e5886));}});};Preview[_0x834e('0x10')][_0x834e('0x99')]=function(_0xbd0346){return!_[_0x834e('0x6b')](_0xbd0346)&&!_[_0x834e('0x6b')](_0xbd0346[_0x834e('0x54')])&&!_[_0x834e('0x6b')](_0xbd0346[_0x834e('0x10a')])&&_0xbd0346[_0x834e('0x10a')]&&!_[_0x834e('0x6b')](this['trunks'][util['format'](_0x834e('0x10b'),_0xbd0346[_0x834e('0x54')])])&&!_[_0x834e('0x6b')](this[_0x834e('0x16')][util[_0x834e('0x58')](_0x834e('0x10b'),_0xbd0346[_0x834e('0x54')])][_0x834e('0x76')])&&(this[_0x834e('0x16')][util[_0x834e('0x58')](_0x834e('0x10b'),_0xbd0346[_0x834e('0x54')])][_0x834e('0x76')]==='reachable'||this[_0x834e('0x16')][util[_0x834e('0x58')](_0x834e('0x10b'),_0xbd0346[_0x834e('0x54')])]['status']==='unmonitored');};Preview['prototype'][_0x834e('0x87')]=function(_0xf98fb4,_0x42fbfe){var _0x23d7e6=this;return new BPromise(function(_0x181ecd,_0x13380f){_0x23d7e6[_0x834e('0x10c')](_0xf98fb4,_0x42fbfe)[_0x834e('0x81')](function(_0x4d15a0){_0x181ecd(_['pick'](_0x4d15a0,['message']));})['catch'](function(_0x2024dd){if(_0x2024dd[_0x834e('0x10d')]){rpcDb[_0x834e('0x10e')](_0xf98fb4);}if(_0x2024dd[_0x834e('0x10a')]){rpcDb[_0x834e('0x8a')](_0xf98fb4);}_0x13380f(_[_0x834e('0x72')](_0x2024dd,[_0x834e('0x49')]));});});};Preview[_0x834e('0x10')][_0x834e('0x10c')]=function(_0x4e6525,_0x4b613c){var _0x4d1545=this;return new BPromise(function(_0x5dc651,_0x11aff8){var _0x17025e,_0x284183;rpcDb[_0x834e('0x10f')](_0x4e6525)[_0x834e('0x81')](function(_0xcb9751){if(!_[_0x834e('0x6b')](_0xcb9751[0x0])){_0x284183=_0xcb9751[0x0][_0x834e('0x110')]?![]:!![];_0x17025e=_0xcb9751[0x0][_0x834e('0x110')]?!![]:![];_0x17025e=_0x4b613c?!![]:_0x17025e;}var _0xcd64c2=_0x4d1545[_0x834e('0x111')](_0xcb9751);if(_0xcd64c2[_0x834e('0x112')]){rpcDb[_0x834e('0x113')](_[_0x834e('0x72')](_0xcb9751[0x0],[_0x834e('0x74'),_0x834e('0x114')]))['then'](function(_0x13f473){_0x4d1545['checkInBlack'](_0x13f473,_0xcb9751[0x0],_0x4b613c,_0x284183,_0x17025e)[_0x834e('0x81')](function(_0x14fe16){_0x5dc651(_0x14fe16);})[_0x834e('0x77')](function(_0x587f9a){_0x11aff8(_0x587f9a);});})[_0x834e('0x77')](function(_0x3d9d85){ut['logger']('[Preview][checkIsBlackList]',_0x3d9d85);_0x11aff8(ut[_0x834e('0x49')](_0x834e('0x115'),_0x284183,_0x17025e));});}else{_0x11aff8(ut[_0x834e('0x49')](_0xcd64c2[_0x834e('0x49')],_0x284183,_0x17025e));}})[_0x834e('0x77')](function(_0x2e9116){ut[_0x834e('0x5e')](_0x834e('0x116'),_0x2e9116);_0x11aff8(ut['message'](_0x834e('0x115'),![],!![]));});});};Preview[_0x834e('0x10')][_0x834e('0x111')]=function(_0x1d4947){if(_[_0x834e('0x6b')](_0x1d4947)||_[_0x834e('0x102')](_0x1d4947)||!_[_0x834e('0x6b')](_0x1d4947[0x0]['Agent'])&&_[_0x834e('0x6b')](_0x1d4947[0x0]['Agent']['name'])){ut[_0x834e('0x5e')](_0x834e('0x117'),_0x1d4947);return{'isValid':![],'message':'Empty\x20Contact'};}var _0x3ce91b=this[_0x834e('0x15')][_0x1d4947[0x0]['Queue'][_0x834e('0x54')]];_0x3ce91b[_0x834e('0x49')]='ACTIVE';if(_['isNil'](_0x3ce91b)){ut[_0x834e('0x5e')](_0x834e('0x118'),_0x3ce91b);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this['isTrunkReachable'](_0x3ce91b[_0x834e('0x50')])){ut[_0x834e('0x5e')]('[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20'+_0x3ce91b['name']+'\x20Trunk\x20is\x20not\x20active');if(!this[_0x834e('0x99')](_0x3ce91b['TrunkBackup'])){ut[_0x834e('0x5e')]('[Preview][validateContact][Trunk\x20not\x20work]',_0x3ce91b[_0x834e('0x54')]+_0x834e('0x119'));return{'isValid':![],'message':_0x834e('0x11a')};}}if(!ut[_0x834e('0x11b')](_0x3ce91b['dialActive'])){ut[_0x834e('0x5e')](_0x834e('0x11c'),_0x3ce91b[_0x834e('0x54')]+_0x834e('0x11d'));return{'isValid':![],'message':_0x834e('0x11e')+_0x3ce91b[_0x834e('0x54')]+_0x834e('0x11d')};}return{'isValid':!![],'message':_0x834e('0x11f')};};Preview[_0x834e('0x10')][_0x834e('0x103')]=function(_0x590e52,_0x40e12e,_0x48f8da,_0x3980c0){var _0x376850=this;return new BPromise(function(_0x2eedc5,_0x31a7ae){var _0x185167=_0x590e52['uniqueid'];var _0x41698e=_0x376850['isTrunkReachable'](_0x40e12e['Trunk'])?util[_0x834e('0x58')](_0x834e('0x120'),_0x40e12e[_0x834e('0x50')]['name'],_[_0x834e('0x6b')](_0x40e12e[_0x834e('0x34')])?'':_0x40e12e[_0x834e('0x34')][_0x834e('0x121')]()||'',_0x40e12e[_0x834e('0x122')]>0x0?_0x48f8da[_0x834e('0xfe')][_0x834e('0xff')][_0x834e('0x123')](_0x40e12e[_0x834e('0x122')]):_0x48f8da[_0x834e('0xfe')][_0x834e('0xff')]):util['format'](_0x834e('0x120'),_[_0x834e('0x6b')](_0x40e12e[_0x834e('0x9a')])?_0x40e12e[_0x834e('0x50')][_0x834e('0x54')]:_0x40e12e[_0x834e('0x9a')]['name'],_[_0x834e('0x6b')](_0x40e12e[_0x834e('0x34')])?'':_0x40e12e[_0x834e('0x34')][_0x834e('0x121')]()||'',_0x40e12e[_0x834e('0x122')]>0x0?_0x48f8da[_0x834e('0xfe')][_0x834e('0xff')][_0x834e('0x123')](_0x40e12e[_0x834e('0x122')]):_0x48f8da[_0x834e('0xfe')]['phone']);var _0x571645=_0x376850[_0x834e('0x99')](_0x40e12e['Trunk'])?ut[_0x834e('0x124')](_0x40e12e[_0x834e('0x50')][_0x834e('0x51')],_0x40e12e[_0x834e('0x31')],_0x40e12e[_0x834e('0x125')]>0x0?ut[_0x834e('0x126')](_0x40e12e['dialOriginateCallerIdNumber'],_0x40e12e[_0x834e('0x125')]):_0x40e12e['dialOriginateCallerIdNumber']):ut['getCallerId'](_['isNil'](_0x40e12e[_0x834e('0x9a')])?_0x40e12e[_0x834e('0x50')]['callerid']:_0x40e12e['TrunkBackup']['callerid'],_0x40e12e[_0x834e('0x31')],_0x40e12e[_0x834e('0x125')]>0x0?ut[_0x834e('0x126')](_0x40e12e['dialOriginateCallerIdNumber'],_0x40e12e[_0x834e('0x125')]):_0x40e12e[_0x834e('0x32')]);if(_0x571645){_0x590e52[_0x834e('0x127')]=ut[_0x834e('0x128')](_0x571645);_0x590e52[_0x834e('0x129')]=ut[_0x834e('0x12a')](_0x571645);}var _0x4e3ba4=ut['addVariables'](_0x40e12e,_0x48f8da,_0x41698e,_0x571645,_0x185167,_0x590e52);_['merge'](_0x590e52,ut['toLowerVariables'](_0x4e3ba4));_0x590e52[_0x834e('0x8b')]=moment()[_0x834e('0x58')](_0x834e('0x8c'));ami[_0x834e('0x12b')](ut[_0x834e('0x12c')](_0x590e52,_0x40e12e,_0x4e3ba4,_0x590e52[_0x834e('0xaa')],_0x3980c0))[_0x834e('0x81')](function(_0x23ddb4){_0x40e12e[_0x834e('0x4a')]+=0x1;logger[_0x834e('0x55')](_0x834e('0x12d'),_0x185167,_0x834e('0xb0'),_0x40e12e[_0x834e('0x54')],_0x834e('0x6f'),_0x40e12e[_0x834e('0x4a')]);_0x2eedc5(_0x23ddb4);})['catch'](function(_0x4f46bf){ut[_0x834e('0xf4')](_0x590e52,0xe,_0x834e('0x12e'));rpcDb[_0x834e('0xf5')](_0x590e52,'[originateFailure][logOriginateFailure]');_0x31a7ae(_0x4f46bf);});});};Preview[_0x834e('0x10')][_0x834e('0x12f')]=function(_0x83d32b){if(this[_0x834e('0x6c')][_0x83d32b[_0x834e('0xab')]]){this[_0x834e('0x6c')][_0x83d32b[_0x834e('0xab')]][_0x834e('0x130')]=_0x83d32b[_0x834e('0x130')];}};Preview['prototype'][_0x834e('0x131')]=function(_0x2e0674){var _0x3b4691=this;var _0x2f1de8=this['actions'][_0x2e0674[_0x834e('0x132')]];if(_0x2f1de8){if(_0x2f1de8[_0x834e('0x101')]&&this[_0x834e('0x17')][_0x2f1de8[_0x834e('0x101')]]){ut[_0x834e('0x133')](_0x2f1de8,this[_0x834e('0x17')][_0x2f1de8[_0x834e('0x101')]][_0x834e('0x54')],this[_0x834e('0x17')][_0x2f1de8['lookAgent']]['id']);}var _0x1dcc9b=_['clone'](_0x2f1de8);_0x1dcc9b[_0x834e('0xad')]=moment()['format'](_0x834e('0x8c'));var _0x32f2f0=_0x3b4691[_0x834e('0x15')][_0x2f1de8[_0x834e('0x6e')]];if(ut[_0x834e('0x134')](_0x2e0674['response'])){if(_0x2f1de8[_0x834e('0xa9')]){rpcDb[_0x834e('0x10e')](_0x2f1de8['idContact']);}if(_0x2f1de8['activeContact']){rpcDb[_0x834e('0x8a')](_0x2f1de8['idContact']);}ami['emit']('custom:agentringnoanswer',ut[_0x834e('0xa1')](_0x2f1de8,_0x834e('0x135'),this[_0x834e('0x15')][_0x2f1de8[_0x834e('0x6e')]]));this[_0x834e('0xf1')](_0x1dcc9b,_0x32f2f0,_0x2e0674);}else{_0x2f1de8[_0x834e('0x8b')]=moment()[_0x834e('0x58')]('YYYY-MM-DD\x20HH:mm:ss');ut[_0x834e('0xf4')](_0x1dcc9b,0x4,_0x834e('0x136'));rpcDb['createAgentHistory'](_0x1dcc9b,'[callProgressDetectingAgent][logAnswer]');}}};Preview[_0x834e('0x10')][_0x834e('0x137')]=function(_0x50d3f5){var _0x5920f3=this;var _0x3a7b1c=this[_0x834e('0x6c')][_0x50d3f5[_0x834e('0xab')]];var _0x599664;if(_0x3a7b1c){_0x599664=this[_0x834e('0x15')][_0x3a7b1c[_0x834e('0x6e')]];logger[_0x834e('0x55')]('[syncHangup][talking]',_0x50d3f5[_0x834e('0xab')],'\x20Queue',_0x599664[_0x834e('0x54')],_0x834e('0x70'),_0x599664[_0x834e('0x2a')]);}if(this[_0x834e('0x6c')][_0x50d3f5[_0x834e('0xab')]]&&_0x50d3f5['linkedid']!==_0x50d3f5[_0x834e('0xaf')]){if(_0x50d3f5[_0x834e('0x138')]==='16'&&this[_0x834e('0x6c')][_0x50d3f5[_0x834e('0xab')]][_0x834e('0x71')]){this['callProgressDetectingCustomer'](_0x50d3f5,_0x50d3f5['linkedid'],_0x50d3f5[_0x834e('0x138')]);}else if(this[_0x834e('0x6c')][_0x50d3f5[_0x834e('0xab')]]['dialAnswer']){logger[_0x834e('0x55')](_0x834e('0x139'),_0x50d3f5[_0x834e('0xab')],_0x50d3f5[_0x834e('0x138')],'\x20Queue',_0x599664[_0x834e('0x54')],_0x834e('0x70'),_0x599664['pTalking']);this[_0x834e('0x9d')](_0x50d3f5,_0x50d3f5[_0x834e('0xab')],_0x50d3f5[_0x834e('0x138')]);}}else if(_0x3a7b1c&&_[_0x834e('0x6b')](_0x3a7b1c['statedesc'])&&_0x599664[_0x834e('0x13a')]&&_0x50d3f5['linkedid']===_0x50d3f5[_0x834e('0xaf')]&&_[_0x834e('0x6b')](_0x50d3f5[_0x834e('0xf3')])&&_0x50d3f5[_0x834e('0x138')]==='16'&&_0x50d3f5[_0x834e('0x13b')]==='6'&&_[_0x834e('0xf2')](_0x3a7b1c['transfer'])){if(_0x3a7b1c['unlockAgent']){rpcDb[_0x834e('0x10e')](_0x3a7b1c[_0x834e('0x13c')]);}if(_0x3a7b1c['activeContact']){rpcDb[_0x834e('0x8a')](_0x3a7b1c['idContact']);}_0x50d3f5[_0x834e('0xf3')]='22';this[_0x834e('0xf1')](_0x3a7b1c,_0x599664,_0x50d3f5);}else if(_0x3a7b1c&&_0x3a7b1c[_0x834e('0x13d')]){if(_0x50d3f5[_0x834e('0x138')]==='16'&&this[_0x834e('0x6c')][_0x50d3f5[_0x834e('0xab')]][_0x834e('0x71')]){logger['info'](_0x834e('0x13e'),_0x50d3f5[_0x834e('0xab')],_0x50d3f5[_0x834e('0x138')],_0x834e('0xb0'),_0x599664[_0x834e('0x54')],'pTalking:\x20',_0x599664[_0x834e('0x2a')]);this[_0x834e('0x9d')](_0x50d3f5,_0x50d3f5[_0x834e('0xab')],_0x50d3f5['cause']);}else if(this['actions'][_0x50d3f5['linkedid']][_0x834e('0x71')]){logger[_0x834e('0x55')](_0x834e('0x139'),_0x50d3f5[_0x834e('0xab')],_0x50d3f5[_0x834e('0x138')],_0x834e('0xb0'),_0x599664[_0x834e('0x54')],_0x834e('0x70'),_0x599664[_0x834e('0x2a')]);this[_0x834e('0x9d')](_0x50d3f5,_0x50d3f5[_0x834e('0xab')],_0x50d3f5['cause']);}}};Preview[_0x834e('0x10')][_0x834e('0x1d')]=function(_0x2a3807){if(this[_0x834e('0x6c')][_0x2a3807[_0x834e('0xf0')]]&&_0x2a3807[_0x834e('0xf0')]!==_0x2a3807[_0x834e('0x13f')]){this[_0x834e('0x9d')](_0x2a3807,_0x2a3807['destlinkedid'],_0x2a3807[_0x834e('0xe5')]);}};Preview[_0x834e('0x10')]['syncHangupRequest']=function(_0x39536e){if(this[_0x834e('0x6c')][_0x39536e[_0x834e('0xab')]]&&_0x39536e[_0x834e('0xab')]!==_0x39536e['uniqueid']&&!this['actions'][_0x39536e[_0x834e('0xab')]]['dialAnswer']){if(_0x39536e[_0x834e('0x138')]==='1'){this[_0x834e('0x9d')](_0x39536e,_0x39536e[_0x834e('0xab')],_0x39536e[_0x834e('0x138')]);}}};Preview[_0x834e('0x10')]['addVariable']=function(_0x2f6633,_0x5a4fbf,_0x4ae94e){if(this[_0x834e('0x6c')][_0x2f6633]){if(_[_0x834e('0x6b')](this[_0x834e('0x6c')][_0x2f6633][_0x834e('0x140')])){this[_0x834e('0x6c')][_0x2f6633][_0x834e('0x140')]={};}this['actions'][_0x2f6633][_0x834e('0x140')][_0x5a4fbf]=_0x4ae94e;}};Preview[_0x834e('0x10')]['syncVarSet']=function(_0x423b03){try{if(!_[_0x834e('0x6b')](_0x423b03)){if(ut['filterKey'](_[_0x834e('0x141')](_0x423b03[_0x834e('0x142')])[0x0])){this['addVariable'](_0x423b03[_0x834e('0xaf')],_[_0x834e('0x141')](_0x423b03[_0x834e('0x142')])[0x0],_0x423b03[_0x834e('0x143')]);}}}catch(_0x34a13d){logger[_0x834e('0x144')](_0x834e('0x145'),util[_0x834e('0x146')](_0x34a13d,{'showHidden':![],'depth':null}));}};Preview[_0x834e('0x10')][_0x834e('0x22')]=function(_0x5944e1){if(_0x5944e1){if(this[_0x834e('0x6c')][_0x5944e1[_0x834e('0x147')]]){this[_0x834e('0x6c')][_0x5944e1[_0x834e('0x147')]][_0x834e('0x13d')]=!![];}}};Preview[_0x834e('0x10')][_0x834e('0x23')]=function(_0x40b75e){if(_0x40b75e){if(this[_0x834e('0x6c')][_0x40b75e[_0x834e('0x148')]]){this[_0x834e('0x6c')][_0x40b75e[_0x834e('0x148')]]['transfer']=!![];}}};module[_0x834e('0x149')]=Preview;