18 var _0x0254=['map','User','rawAttributes','fieldName','type','key','role','agent','getOptions','raw','length','sequelize','literal','FIELD(id,','forEach','Pause','push','where','user','userProfileId','Agents','online','extraQueryConditions','UserProfile','getResources','find','filterAgentAttributes','getAgentStatus','includes','voice','voiceStatus','talking','Status','sortAgentsByStatus','pick','getQueues','isValidChannel','outbound','dialActive','dialMethod','startCase','Queues','name','filter','assign','getRealtimeQueues','initializeQueues','catch','lodash','util','../../components/realtime/agents','../../components/realtime/queues','../../components/parsers/qs','../../config/utils','../../mysqldb','../../errors/api','APIBadRequestError','handleError','offset','undefined','count','limit','status','set','Content-Range','json','getAgents','getChannels','query','globalQueueFilter','pauseTypeFilter','pause','*pause','resolve','then','channel','format','Channel\x20parameter\x20%s\x20is\x20invalid','toLowerCase','sort','globalStatus','validateSortParameter','getUpdatedSortOptions','fields','join','order','getAgentIdsByQueues','rows','getSortedAgentsIdsByStatus'];(function(_0x3df312,_0x58719b){var _0x1ed2ac=function(_0x44c1df){while(--_0x44c1df){_0x3df312['push'](_0x3df312['shift']());}};_0x1ed2ac(++_0x58719b);}(_0x0254,0x13b));var _0x4025=function(_0x32658e,_0x3d37db){_0x32658e=_0x32658e-0x0;var _0x325274=_0x0254[_0x32658e];return _0x325274;};'use strict';var _=require(_0x4025('0x0'));var util=require(_0x4025('0x1'));var rta=require(_0x4025('0x2'));var rtq=require(_0x4025('0x3'));var qs=require(_0x4025('0x4'));var utils=require(_0x4025('0x5'));var db=require(_0x4025('0x6'))['db'];var APIBadRequestError=require(_0x4025('0x7'))[_0x4025('0x8')];var APIHandleError=require(_0x4025('0x7'))[_0x4025('0x9')];function respondWithFilteredResult(_0x20d4f1,_0x33bc3d){return function(_0x3e3579){if(_0x3e3579){var _0x1575fb=typeof _0x33bc3d[_0x4025('0xa')]===_0x4025('0xb')&&typeof _0x33bc3d['limit']===_0x4025('0xb');var _0x1cb98a=_0x3e3579['count'];var _0x595f53=_0x1575fb?0x0:_0x33bc3d['offset'];var _0x525299=_0x1575fb?_0x3e3579[_0x4025('0xc')]:_0x33bc3d['offset']+_0x33bc3d[_0x4025('0xd')];var _0x5125a5;if(_0x525299>=_0x1cb98a){_0x525299=_0x1cb98a;_0x5125a5=0xc8;}else{_0x5125a5=0xce;}_0x20d4f1[_0x4025('0xe')](_0x5125a5);return _0x20d4f1[_0x4025('0xf')](_0x4025('0x10'),_0x595f53+'-'+_0x525299+'/'+_0x1cb98a)[_0x4025('0x11')](_0x3e3579);}return null;};}exports[_0x4025('0x12')]=function(_0xa50f00,_0x1bf10f){var _0x5767cd={'count':0x0,'rows':[]};var _0x4c8d9f={};var _0xafb833;var _0x256114=utils[_0x4025('0x13')]();var _0x757928;var _0x37ee2f;var _0x25ba08=_0xa50f00[_0x4025('0x14')][_0x4025('0x15')];var _0x16ac69=_0xa50f00[_0x4025('0x14')]['globalStatusFilter'];var _0x42ff36=_0xa50f00[_0x4025('0x14')][_0x4025('0x16')];var _0xb5d599=_0x16ac69===_0x4025('0x17')||_0x16ac69===_0x4025('0x18')?!![]:![];var _0x419160=[];var _0x1c6171;var _0x537681;Promise[_0x4025('0x19')]()[_0x4025('0x1a')](function(){if(_0xa50f00[_0x4025('0x14')][_0x4025('0x1b')]){if(!utils['isValidChannel'](_0xa50f00[_0x4025('0x14')][_0x4025('0x1b')])){throw new APIBadRequestError(util[_0x4025('0x1c')](_0x4025('0x1d'),_0xa50f00[_0x4025('0x14')][_0x4025('0x1b')]));}_0xafb833=_0xa50f00[_0x4025('0x14')][_0x4025('0x1b')][_0x4025('0x1e')]();}if(!_0xa50f00[_0x4025('0x14')][_0x4025('0x1f')]||!_0xa50f00[_0x4025('0x14')][_0x4025('0x1f')]['includes'](_0x4025('0x20'))){_0xa50f00[_0x4025('0x14')][_0x4025('0x1f')]=rta[_0x4025('0x21')](_0xa50f00[_0x4025('0x14')][_0x4025('0x1f')]);return;}var _0xd6841d=rta[_0x4025('0x22')](_0xa50f00[_0x4025('0x14')]['sort']);_0xa50f00[_0x4025('0x14')][_0x4025('0x1f')]=_0xd6841d[_0x4025('0x23')][_0x4025('0x24')](',');_0x1c6171=_0xd6841d[_0x4025('0x25')];})[_0x4025('0x1a')](function(){if(!_0x25ba08){return[];}return rta[_0x4025('0x26')](_0x25ba08,_0xafb833);})[_0x4025('0x1a')](function(_0x4b10ba){_0x419160=_0x4b10ba;return rta['getRealtimeAgents']();})[_0x4025('0x1a')](function(_0x471d30){_0x37ee2f=_0x471d30[_0x4025('0x27')];if((!_0x16ac69||_0xb5d599)&&!_0x1c6171){return _0x419160;}if(_0x1c6171&&!_0x16ac69){return rta[_0x4025('0x28')](_0x37ee2f,_0x419160,_0x1c6171);}else{return rta['getAgentIdsByStatus'](_0x37ee2f,_0x419160,_0x16ac69);}})[_0x4025('0x1a')](function(_0x5f1d3c){_0x419160=_0x5f1d3c;var _0xafad1e=![];if(_0x419160['length']===0x0){if(_0x25ba08||_0x16ac69){_0xafad1e=!![];}if(_0xb5d599){_0xafad1e=![];}}if(_0xafad1e){return _0x5767cd;}var _0x3fc624=_[_0x4025('0x29')](db[_0x4025('0x2a')][_0x4025('0x2b')],function(_0x4fb8ef){return{'name':_0x4fb8ef[_0x4025('0x2c')],'type':_0x4fb8ef[_0x4025('0x2d')][_0x4025('0x2e')]};});_0xa50f00[_0x4025('0x14')][_0x4025('0x2f')]=_0x4025('0x30');_0x4c8d9f=qs[_0x4025('0x31')](_0x3fc624,_0xa50f00);_0x4c8d9f[_0x4025('0x32')]=!![];var _0x2c0c8e=[];if(_0x419160[_0x4025('0x33')]>0x0){_0x2c0c8e['push']({'id':{'$in':_0x419160}});if(_0x1c6171&&!_0x16ac69){_0x537681=[db[_0x4025('0x34')][_0x4025('0x35')](_0x4025('0x36')+_0x419160+')')];_0x4c8d9f['order']=_0x537681;}}if(_0xb5d599){_0x256114[_0x4025('0x37')](function(_0xd4ff){var _0x2ff8bd=!![];if(_0x16ac69===_0x4025('0x18')&&_0xafb833!==_0xd4ff){_0x2ff8bd=![];}_0x2c0c8e['push']({[_0xd4ff+_0x4025('0x38')]:_0x2ff8bd});});if(_0x42ff36){_0x2c0c8e[_0x4025('0x39')]({'pauseType':_0x42ff36});}}else if(_0x16ac69){_0x256114[_0x4025('0x37')](function(_0x4edbaf){_0x2c0c8e[_0x4025('0x39')]({[_0x4edbaf+'Pause']:![]});});}_0x4c8d9f[_0x4025('0x3a')]=_['merge'](_0x4c8d9f[_0x4025('0x3a')],{'$and':_0x2c0c8e});if(_0xa50f00['user'][_0x4025('0x2f')]==='user'){var _0x47e26e={'params':{'id':_0xa50f00[_0x4025('0x3b')][_0x4025('0x3c')]},'query':{'section':_0x4025('0x3d'),'role':'agent','raw':!![],'ids':_0x419160,'customSorting':_0x537681}};if(_0xa50f00[_0x4025('0x14')][_0x4025('0x3e')]){_0x47e26e[_0x4025('0x14')][_0x4025('0x3e')]=!![];}if(_0xb5d599){_0x47e26e[_0x4025('0x14')][_0x4025('0x3f')]=_0x2c0c8e;}_0x47e26e[_0x4025('0x14')]=Object['assign'](_0x47e26e['query'],_['omit'](_0xa50f00['query'],'id'));return db[_0x4025('0x40')][_0x4025('0x41')](_0x47e26e);}return db[_0x4025('0x2a')]['findAndCountAll'](_0x4c8d9f);})[_0x4025('0x1a')](function(_0x10fdc4){_0x5767cd[_0x4025('0xc')]=_0x10fdc4[_0x4025('0xc')];_0x757928=_0x10fdc4[_0x4025('0x27')];return _0x757928[_0x4025('0x29')](function(_0xc41200){var _0x39accc=_[_0x4025('0x42')](_0x37ee2f,['id',_0xc41200['id']]);if(_0x39accc){var _0x2e8c32=rta[_0x4025('0x43')](_0x39accc);_['merge'](_0xc41200,_0x2e8c32);}_0xc41200[_0x4025('0x20')]=rta[_0x4025('0x44')](_0xc41200);if(_0xc41200[_0x4025('0x20')][_0x4025('0x45')]('pause')){_0x256114['forEach'](function(_0x9aa369){if(_0xc41200[_0x9aa369+_0x4025('0x38')]){if(_0x9aa369===_0x4025('0x46')){if(_0xc41200[_0x4025('0x47')]!==_0x4025('0x48')){_0xc41200[_0x4025('0x47')]=_0x4025('0x17');}}else{_0xc41200[_0x9aa369+_0x4025('0x49')]='pause';}}});}return _0xc41200;});})['then'](function(_0x1f1656){if(!_0x1c6171||_0x537681){return _0x1f1656;}return rta[_0x4025('0x4a')](_0x1f1656,_0x1c6171);})['then'](function(_0x283d6b){var _0x3cb936=rta['getRealtimeAgentsQueryFields']();_0x5767cd['rows']=_0x283d6b[_0x4025('0x29')](function(_0x530802){return _[_0x4025('0x4b')](_0x530802,_0x3cb936);});return _0x5767cd;})[_0x4025('0x1a')](respondWithFilteredResult(_0x1bf10f,_0x4c8d9f))['catch'](APIHandleError(_0x1bf10f));};exports[_0x4025('0x4c')]=function(_0x3faa8b,_0xb3ae82){var _0xcb914b={'count':0x0,'rows':[]};var _0x405b43={};var _0x9a7314;var _0x2282dc;var _0xab62fe;Promise[_0x4025('0x19')]()['then'](function(){if(_0x3faa8b[_0x4025('0x14')][_0x4025('0x1b')]){if(!utils[_0x4025('0x4d')](_0x3faa8b[_0x4025('0x14')][_0x4025('0x1b')])){throw new APIBadRequestError(util['format'](_0x4025('0x1d'),_0x3faa8b[_0x4025('0x14')]['channel']));}_0x9a7314=_0x3faa8b[_0x4025('0x14')][_0x4025('0x1b')][_0x4025('0x1e')]();}var _0x311288=_['startCase'](_0x9a7314)+'Queue';var _0x3f0790=_[_0x4025('0x29')](db[_0x311288][_0x4025('0x2b')],function(_0x2c5e17){return{'name':_0x2c5e17[_0x4025('0x2c')],'type':_0x2c5e17[_0x4025('0x2d')][_0x4025('0x2e')]};});if(!_0x3faa8b[_0x4025('0x14')][_0x4025('0x23')]){var _0x595bff=['id','name'];if(_0x9a7314===_0x4025('0x46')){_0x595bff[_0x4025('0x39')]('type');if(_0x3faa8b[_0x4025('0x14')][_0x4025('0x2d')]===_0x4025('0x4e')){_0x595bff[_0x4025('0x39')]([_0x4025('0x4f'),_0x4025('0x50')]);}}_0x3faa8b[_0x4025('0x14')][_0x4025('0x23')]=_0x595bff['join'](',');}_0x405b43=qs['getOptions'](_0x3f0790,_0x3faa8b);if(_0x3faa8b[_0x4025('0x3b')][_0x4025('0x2f')]==='user'){var _0x230140={'params':{'id':_0x3faa8b[_0x4025('0x3b')][_0x4025('0x3c')]},'query':{'section':_0x9a7314===_0x4025('0x46')&&_0x3faa8b[_0x4025('0x14')][_0x4025('0x2d')]==='outbound'?'QueueCampaigns':_[_0x4025('0x51')](_0x9a7314)+_0x4025('0x52'),'type':_0x3faa8b[_0x4025('0x14')][_0x4025('0x2d')],'nolimit':!![],'sort':_0x4025('0x53'),'filter':_0x3faa8b['query'][_0x4025('0x54')]}};_0x230140[_0x4025('0x14')]=Object[_0x4025('0x55')](_0x230140['query'],_0x3faa8b[_0x4025('0x14')]);delete _0x230140[_0x4025('0x14')]['id'];return db[_0x4025('0x40')][_0x4025('0x41')](_0x230140);}return db[_0x311288]['findAndCountAll'](_0x405b43);})['then'](function(_0x267db1){_0xcb914b[_0x4025('0xc')]=_0x267db1[_0x4025('0xc')];_0x2282dc=_0x267db1[_0x4025('0x27')];return rtq[_0x4025('0x56')](_0x3faa8b,_0x9a7314);})[_0x4025('0x1a')](function(_0x20c199){_0xab62fe=_0x20c199[_0x4025('0x27')];return rtq[_0x4025('0x57')](_0x2282dc,_0xab62fe,_0x9a7314,_0x3faa8b[_0x4025('0x14')]['type']);})[_0x4025('0x1a')](function(_0x15f88b){_0xcb914b[_0x4025('0x27')]=_0x15f88b;return _0xcb914b;})[_0x4025('0x1a')](respondWithFilteredResult(_0xb3ae82,_0x405b43))[_0x4025('0x58')](APIHandleError(_0xb3ae82));};