18 var _0x9055=['getRealtimeQueues','initializeQueues','lodash','util','../../components/realtime/agents','../../components/realtime/queues','../../components/parsers/qs','../../config/utils','../../mysqldb','APIBadRequestError','../../errors/api','handleError','undefined','limit','offset','count','set','Content-Range','json','getAgents','getChannels','query','globalQueueFilter','globalStatusFilter','pauseTypeFilter','pause','resolve','then','channel','isValidChannel','format','Channel\x20parameter\x20%s\x20is\x20invalid','toLowerCase','sort','globalStatus','validateSortParameter','fields','order','getAgentIdsByQueues','getRealtimeAgents','rows','getAgentIdsByStatus','length','User','rawAttributes','fieldName','type','role','agent','push','literal','FIELD(id,','forEach','Pause','where','user','userProfileId','Agents','online','extraQueryConditions','assign','UserProfile','getResources','findAndCountAll','find','filterAgentAttributes','includes','voice','voiceStatus','talking','Status','sortAgentsByStatus','getRealtimeAgentsQueryFields','catch','getQueues','Queue','map','key','name','outbound','dialActive','join','QueueCampaigns','startCase','Queues','filter'];(function(_0x178e48,_0x3c9509){var _0x440d7e=function(_0xc2f8a0){while(--_0xc2f8a0){_0x178e48['push'](_0x178e48['shift']());}};_0x440d7e(++_0x3c9509);}(_0x9055,0xae));var _0x5905=function(_0x57dd36,_0x4d84bf){_0x57dd36=_0x57dd36-0x0;var _0x1314a1=_0x9055[_0x57dd36];return _0x1314a1;};'use strict';var _=require(_0x5905('0x0'));var util=require(_0x5905('0x1'));var rta=require(_0x5905('0x2'));var rtq=require(_0x5905('0x3'));var qs=require(_0x5905('0x4'));var utils=require(_0x5905('0x5'));var db=require(_0x5905('0x6'))['db'];var APIBadRequestError=require('../../errors/api')[_0x5905('0x7')];var APIHandleError=require(_0x5905('0x8'))[_0x5905('0x9')];function respondWithFilteredResult(_0x2ae382,_0x5b22ba){return function(_0x51ea36){if(_0x51ea36){var _0x2daa88=typeof _0x5b22ba['offset']===_0x5905('0xa')&&typeof _0x5b22ba[_0x5905('0xb')]===_0x5905('0xa');var _0x3e7eb8=_0x51ea36['count'];var _0x19168c=_0x2daa88?0x0:_0x5b22ba[_0x5905('0xc')];var _0x1d83c0=_0x2daa88?_0x51ea36[_0x5905('0xd')]:_0x5b22ba[_0x5905('0xc')]+_0x5b22ba[_0x5905('0xb')];var _0xc114d5;if(_0x1d83c0>=_0x3e7eb8){_0x1d83c0=_0x3e7eb8;_0xc114d5=0xc8;}else{_0xc114d5=0xce;}_0x2ae382['status'](_0xc114d5);return _0x2ae382[_0x5905('0xe')](_0x5905('0xf'),_0x19168c+'-'+_0x1d83c0+'/'+_0x3e7eb8)[_0x5905('0x10')](_0x51ea36);}return null;};}exports[_0x5905('0x11')]=function(_0x278397,_0x4aff2d){var _0x18899e={'count':0x0,'rows':[]};var _0x33fba3={};var _0x245c55;var _0x303be9=utils[_0x5905('0x12')]();var _0x47b613;var _0x567ade;var _0x34bc31=_0x278397[_0x5905('0x13')][_0x5905('0x14')];var _0x14bb2c=_0x278397[_0x5905('0x13')][_0x5905('0x15')];var _0x29e3b8=_0x278397[_0x5905('0x13')][_0x5905('0x16')];var _0x1faa7d=_0x14bb2c===_0x5905('0x17')||_0x14bb2c==='*pause'?!![]:![];var _0xf8a530=[];var _0x31b7d2;var _0x14e922;Promise[_0x5905('0x18')]()[_0x5905('0x19')](function(){if(_0x278397[_0x5905('0x13')][_0x5905('0x1a')]){if(!utils[_0x5905('0x1b')](_0x278397['query'][_0x5905('0x1a')])){throw new APIBadRequestError(util[_0x5905('0x1c')](_0x5905('0x1d'),_0x278397[_0x5905('0x13')]['channel']));}_0x245c55=_0x278397[_0x5905('0x13')][_0x5905('0x1a')][_0x5905('0x1e')]();}if(!_0x278397[_0x5905('0x13')][_0x5905('0x1f')]||!_0x278397[_0x5905('0x13')]['sort']['includes'](_0x5905('0x20'))){_0x278397[_0x5905('0x13')][_0x5905('0x1f')]=rta[_0x5905('0x21')](_0x278397[_0x5905('0x13')][_0x5905('0x1f')]);return;}var _0x4bf35d=rta['getUpdatedSortOptions'](_0x278397['query'][_0x5905('0x1f')]);_0x278397[_0x5905('0x13')][_0x5905('0x1f')]=_0x4bf35d[_0x5905('0x22')]['join'](',');_0x31b7d2=_0x4bf35d[_0x5905('0x23')];})[_0x5905('0x19')](function(){if(!_0x34bc31){return[];}return rta[_0x5905('0x24')](_0x34bc31,_0x245c55);})['then'](function(_0x2120e9){_0xf8a530=_0x2120e9;return rta[_0x5905('0x25')]();})[_0x5905('0x19')](function(_0x2c5474){_0x567ade=_0x2c5474[_0x5905('0x26')];if((!_0x14bb2c||_0x1faa7d)&&!_0x31b7d2){return _0xf8a530;}if(_0x31b7d2&&!_0x14bb2c){return rta['getSortedAgentsIdsByStatus'](_0x567ade,_0xf8a530,_0x31b7d2);}else{return rta[_0x5905('0x27')](_0x567ade,_0xf8a530,_0x14bb2c);}})[_0x5905('0x19')](function(_0x44cefa){_0xf8a530=_0x44cefa;var _0x4e4e5c=![];if(_0xf8a530[_0x5905('0x28')]===0x0){if(_0x34bc31||_0x14bb2c){_0x4e4e5c=!![];}if(_0x1faa7d){_0x4e4e5c=![];}}if(_0x4e4e5c){return _0x18899e;}var _0x2f4490=_['map'](db[_0x5905('0x29')][_0x5905('0x2a')],function(_0xba4340){return{'name':_0xba4340[_0x5905('0x2b')],'type':_0xba4340[_0x5905('0x2c')]['key']};});_0x278397[_0x5905('0x13')][_0x5905('0x2d')]=_0x5905('0x2e');_0x33fba3=qs['getOptions'](_0x2f4490,_0x278397);_0x33fba3['raw']=!![];var _0x538076=[];if(_0xf8a530[_0x5905('0x28')]>0x0){_0x538076[_0x5905('0x2f')]({'id':{'$in':_0xf8a530}});if(_0x31b7d2&&!_0x14bb2c){_0x14e922=[db['sequelize'][_0x5905('0x30')](_0x5905('0x31')+_0xf8a530+')')];_0x33fba3[_0x5905('0x23')]=_0x14e922;}}if(_0x1faa7d){_0x303be9['forEach'](function(_0x49ba22){var _0x42af22=!![];if(_0x14bb2c==='*pause'&&_0x245c55!==_0x49ba22){_0x42af22=![];}_0x538076[_0x5905('0x2f')]({[_0x49ba22+'Pause']:_0x42af22});});if(_0x29e3b8){_0x538076[_0x5905('0x2f')]({'pauseType':_0x29e3b8});}}else if(_0x14bb2c){_0x303be9[_0x5905('0x32')](function(_0x550c1c){_0x538076[_0x5905('0x2f')]({[_0x550c1c+_0x5905('0x33')]:![]});});}_0x33fba3[_0x5905('0x34')]=_['merge'](_0x33fba3[_0x5905('0x34')],{'$and':_0x538076});if(_0x278397[_0x5905('0x35')][_0x5905('0x2d')]===_0x5905('0x35')){var _0x196d60={'params':{'id':_0x278397[_0x5905('0x35')][_0x5905('0x36')]},'query':{'section':_0x5905('0x37'),'role':_0x5905('0x2e'),'raw':!![],'ids':_0xf8a530,'customSorting':_0x14e922}};if(_0x278397[_0x5905('0x13')][_0x5905('0x38')]){_0x196d60[_0x5905('0x13')][_0x5905('0x38')]=!![];}if(_0x1faa7d){_0x196d60[_0x5905('0x13')][_0x5905('0x39')]=_0x538076;}_0x196d60[_0x5905('0x13')]=Object[_0x5905('0x3a')](_0x196d60[_0x5905('0x13')],_0x278397[_0x5905('0x13')]);return db[_0x5905('0x3b')][_0x5905('0x3c')](_0x196d60);}return db[_0x5905('0x29')][_0x5905('0x3d')](_0x33fba3);})['then'](function(_0x55e18c){_0x18899e[_0x5905('0xd')]=_0x55e18c[_0x5905('0xd')];_0x47b613=_0x55e18c[_0x5905('0x26')];return _0x47b613['map'](function(_0xbe09e5){var _0x2273ff=_[_0x5905('0x3e')](_0x567ade,['id',_0xbe09e5['id']]);if(_0x2273ff){var _0x3f8a5d=rta[_0x5905('0x3f')](_0x2273ff);_['merge'](_0xbe09e5,_0x3f8a5d);}_0xbe09e5['globalStatus']=rta['getAgentStatus'](_0xbe09e5);if(_0xbe09e5[_0x5905('0x20')][_0x5905('0x40')](_0x5905('0x17'))){_0x303be9[_0x5905('0x32')](function(_0x57df5e){if(_0xbe09e5[_0x57df5e+_0x5905('0x33')]){if(_0x57df5e===_0x5905('0x41')){if(_0xbe09e5[_0x5905('0x42')]!==_0x5905('0x43')){_0xbe09e5[_0x5905('0x42')]='pause';}}else{_0xbe09e5[_0x57df5e+_0x5905('0x44')]=_0x5905('0x17');}}});}return _0xbe09e5;});})[_0x5905('0x19')](function(_0x433165){if(!_0x31b7d2||_0x14e922){return _0x433165;}return rta[_0x5905('0x45')](_0x433165,_0x31b7d2);})[_0x5905('0x19')](function(_0x30def2){var _0x35d63f=rta[_0x5905('0x46')]();_0x18899e[_0x5905('0x26')]=_0x30def2['map'](function(_0x986774){return _['pick'](_0x986774,_0x35d63f);});return _0x18899e;})['then'](respondWithFilteredResult(_0x4aff2d,_0x33fba3))[_0x5905('0x47')](APIHandleError(_0x4aff2d));};exports[_0x5905('0x48')]=function(_0x3045a7,_0x242dc7){var _0x3b4a19={'count':0x0,'rows':[]};var _0x9fae92={};var _0x8aab2e;var _0x1dacbe;var _0xa45f09;Promise[_0x5905('0x18')]()['then'](function(){if(_0x3045a7[_0x5905('0x13')]['channel']){if(!utils[_0x5905('0x1b')](_0x3045a7[_0x5905('0x13')][_0x5905('0x1a')])){throw new APIBadRequestError(util[_0x5905('0x1c')]('Channel\x20parameter\x20%s\x20is\x20invalid',_0x3045a7[_0x5905('0x13')][_0x5905('0x1a')]));}_0x8aab2e=_0x3045a7[_0x5905('0x13')]['channel']['toLowerCase']();}var _0x1335e4=_['startCase'](_0x8aab2e)+_0x5905('0x49');var _0x4a3872=_[_0x5905('0x4a')](db[_0x1335e4][_0x5905('0x2a')],function(_0x4bbc3b){return{'name':_0x4bbc3b['fieldName'],'type':_0x4bbc3b[_0x5905('0x2c')][_0x5905('0x4b')]};});if(!_0x3045a7['query']['fields']){var _0x2fec51=['id',_0x5905('0x4c')];if(_0x8aab2e===_0x5905('0x41')){_0x2fec51[_0x5905('0x2f')]('type');if(_0x3045a7['query'][_0x5905('0x2c')]===_0x5905('0x4d')){_0x2fec51[_0x5905('0x2f')]([_0x5905('0x4e'),'dialMethod']);}}_0x3045a7[_0x5905('0x13')][_0x5905('0x22')]=_0x2fec51[_0x5905('0x4f')](',');}_0x9fae92=qs['getOptions'](_0x4a3872,_0x3045a7);if(_0x3045a7['user'][_0x5905('0x2d')]===_0x5905('0x35')){var _0x78e6a0={'params':{'id':_0x3045a7[_0x5905('0x35')]['userProfileId']},'query':{'section':_0x8aab2e===_0x5905('0x41')&&_0x3045a7['query'][_0x5905('0x2c')]===_0x5905('0x4d')?_0x5905('0x50'):_[_0x5905('0x51')](_0x8aab2e)+_0x5905('0x52'),'type':_0x3045a7[_0x5905('0x13')][_0x5905('0x2c')],'nolimit':!![],'sort':_0x5905('0x4c'),'filter':_0x3045a7['query'][_0x5905('0x53')]}};_0x78e6a0[_0x5905('0x13')]=Object['assign'](_0x78e6a0[_0x5905('0x13')],_0x3045a7[_0x5905('0x13')]);delete _0x78e6a0[_0x5905('0x13')]['id'];return db[_0x5905('0x3b')][_0x5905('0x3c')](_0x78e6a0);}return db[_0x1335e4][_0x5905('0x3d')](_0x9fae92);})[_0x5905('0x19')](function(_0x17a1c0){_0x3b4a19[_0x5905('0xd')]=_0x17a1c0['count'];_0x1dacbe=_0x17a1c0[_0x5905('0x26')];return rtq[_0x5905('0x54')](_0x3045a7,_0x8aab2e);})[_0x5905('0x19')](function(_0x53c7ec){_0xa45f09=_0x53c7ec[_0x5905('0x26')];return rtq[_0x5905('0x55')](_0x1dacbe,_0xa45f09,_0x8aab2e,_0x3045a7[_0x5905('0x13')]['type']);})[_0x5905('0x19')](function(_0x524739){_0x3b4a19[_0x5905('0x26')]=_0x524739;return _0x3b4a19;})['then'](respondWithFilteredResult(_0x242dc7,_0x9fae92))[_0x5905('0x47')](APIHandleError(_0x242dc7));};