Built motion from commit efa66e19.|2.6.22
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 9759d47..67cd0d4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x11f1=['getInteractions','Contact','User','Owner','internal','Tag','color','tag','timezone','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','License','increment','push','all','some','server/files/chat/iframe.js','stringify','x-forwarded-for','x-real-ip','connection','alignment','verticalAlignment','addApplications','transaction','ChatApplication','bulkCreate','findAndCountAll','getApplications','chatProactiveAction','addProactiveActions','online','false','offlineForm','onlineForm','items','fromKey','ChatOfflineMessage','addAgents','emit','userChatWebsite:save','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','ChatWebsites','stack','name','send','index','mandatoryDispositionPause','rawAttributes','fieldName','type','map','query','filters','model','attributes','length','nolimit','order','sort','where','pick','merge','VIRTUAL','ChatWebsite','count','includeAll','include','rows','catch','show','params','Pause','keys','intersection','fields','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','Disposition','getDispositions','hasOwnProperty','removeDispositions','ids','addAnswer','CannedAnswer','filter','findAll','removeAnswers','sitepic','file','filename','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','server/files/images/logos/default_logo.png','../../config/license/util','getLicense','custom','isNil','existsSync','root','server/files/images/logos/','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','download','getSystemAvatar','notify','user-agent-parser','setUA','headers','user-agent','chat','CmContact','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','Applications','account','applications','priority','asc','cf-connecting-ip','first','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','firstName','contact','messageId','created','autoclose','*,*,*,*','ChatMessage','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','defaults','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','MailAccount','findOne','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','omit'];(function(_0x5327da,_0xb7d219){var _0x46c142=function(_0x145cbc){while(--_0x145cbc){_0x5327da['push'](_0x5327da['shift']());}};_0x46c142(++_0xb7d219);}(_0x11f1,0x155));var _0x111f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x11f1[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x111f('0x0'));var rimraf=require(_0x111f('0x1'));var zipdir=require(_0x111f('0x2'));var jsonpatch=require(_0x111f('0x3'));var rp=require(_0x111f('0x4'));var moment=require(_0x111f('0x5'));var BPromise=require(_0x111f('0x6'));var Mustache=require(_0x111f('0x7'));var util=require(_0x111f('0x8'));var path=require(_0x111f('0x9'));var sox=require(_0x111f('0xa'));var csv=require(_0x111f('0xb'));var ejs=require(_0x111f('0xc'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x111f('0xd'));var jsforce=require(_0x111f('0xe'));var deskjs=require(_0x111f('0xf'));var toCsv=require(_0x111f('0xb'));var querystring=require('querystring');var Papa=require(_0x111f('0x10'));var Redis=require('ioredis');var authService=require(_0x111f('0x11'));var qs=require(_0x111f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x111f('0x13'))(_0x111f('0x14'));var utils=require(_0x111f('0x15'));var config=require(_0x111f('0x16'));var db=require(_0x111f('0x17'))['db'];config[_0x111f('0x18')]=_['defaults'](config[_0x111f('0x18')],{'host':_0x111f('0x19'),'port':0x18eb});var socket=require(_0x111f('0x1a'))(new Redis(config[_0x111f('0x18')]));require(_0x111f('0x1b'))[_0x111f('0x1c')](socket);var jayson=require(_0x111f('0x1d'));var client=jayson[_0x111f('0x1e')][_0x111f('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x111f('0x1f')]({'port':0x232a});var client9003=jayson['client'][_0x111f('0x1f')]({'port':0x232b});function checkPasswordPattern(_0x4ef14e,_0x296e98,_0x411fd5){if(_0x411fd5){var _0x1e70d3=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1e70d3[_0x111f('0x20')](_0x296e98)){return _0x4ef14e;}else{throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x23'));}}else{return _0x4ef14e;}}function respondWithRpcPromise(_0x357892,_0x2b9289,_0x12ab00,_0x27d3d6){return new BPromise(function(_0x2198c3,_0x15d0b3){var _0x293a31=_0x27d3d6||client;return _0x293a31[_0x111f('0x24')](_0x357892,_0x12ab00)[_0x111f('0x25')](function(_0x4433a5){logger[_0x111f('0x26')](_0x111f('0x27'),_0x2b9289,_0x111f('0x28'));logger[_0x111f('0x29')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'),JSON['stringify'](_0x4433a5));if(_0x4433a5['error']){if(_0x4433a5[_0x111f('0x2a')][_0x111f('0x2b')]===0x1f4){logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')]['message']);return _0x15d0b3(_0x4433a5['error'][_0x111f('0x2c')]);}logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')][_0x111f('0x2c')]);return _0x2198c3(_0x4433a5[_0x111f('0x2a')]['message']);}else{logger[_0x111f('0x26')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'));_0x2198c3(_0x4433a5[_0x111f('0x2d')][_0x111f('0x2c')]);}})['catch'](function(_0x131257){logger[_0x111f('0x2a')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x131257);_0x15d0b3(_0x131257);});});}function respondWithStatusCode(_0x40f509,_0x3520bb){_0x3520bb=_0x3520bb||0xcc;return function(_0x37d261){if(_0x37d261){return _0x40f509[_0x111f('0x2e')](_0x3520bb);}return _0x40f509[_0x111f('0x2f')](_0x3520bb)[_0x111f('0x30')]();};}function respondWithResult(_0x5c86c2,_0x578a39){_0x578a39=_0x578a39||0xc8;return function(_0x35f4f9){if(_0x35f4f9){return _0x5c86c2[_0x111f('0x2f')](_0x578a39)[_0x111f('0x31')](_0x35f4f9);}};}function respondWithFilteredResult(_0x140cff,_0x5a3320){return function(_0x1e587e){if(_0x1e587e){var _0x320387=_0x1e587e['count'],_0xad0ee7=_0x5a3320[_0x111f('0x32')],_0x8c2cfe=_0x5a3320[_0x111f('0x32')]+_0x5a3320[_0x111f('0x33')],_0x4b4e7e;if(_0x8c2cfe>=_0x320387){_0x8c2cfe=_0x320387;_0x4b4e7e=0xc8;}else{_0x4b4e7e=0xce;}_0x140cff['status'](_0x4b4e7e);return _0x140cff[_0x111f('0x34')](_0x111f('0x35'),_0xad0ee7+'-'+_0x8c2cfe+'/'+_0x320387)['json'](_0x1e587e);}return null;};}function patchUpdates(_0x300d69){return function(_0x34698a){try{jsonpatch[_0x111f('0x36')](_0x34698a,_0x300d69,!![]);}catch(_0x279ad8){return BPromise[_0x111f('0x37')](_0x279ad8);}return _0x34698a[_0x111f('0x38')]();};}function saveUpdates(_0x4495d8,_0x564347){return function(_0xcc7d12){if(_0xcc7d12){return _0xcc7d12[_0x111f('0x39')](_0x4495d8)[_0x111f('0x25')](function(_0x209ae9){return _0x209ae9;});}return null;};}function removeEntity(_0x545abf,_0x1d60bd){return function(_0x3a6ded){if(_0x3a6ded){return _0x3a6ded[_0x111f('0x3a')]()[_0x111f('0x25')](function(){var _0x44d970=_0x3a6ded[_0x111f('0x3b')]({'plain':!![]});var _0xddb61a=_0x111f('0x3c');return db['UserProfileResource'][_0x111f('0x3a')]({'where':{'type':_0xddb61a,'resourceId':_0x44d970['id']}})[_0x111f('0x25')](function(){return _0x3a6ded;});})[_0x111f('0x25')](function(){_0x545abf[_0x111f('0x2f')](0xcc)[_0x111f('0x30')]();});}};}function handleEntityNotFound(_0x10d4cb,_0x34b493){return function(_0xfabe20){if(!_0xfabe20){_0x10d4cb[_0x111f('0x2e')](0x194);}return _0xfabe20;};}function handleError(_0x496be7,_0x1e5279){_0x1e5279=_0x1e5279||0x1f4;return function(_0x24faca){logger[_0x111f('0x2a')](_0x24faca[_0x111f('0x3d')]);if(_0x24faca[_0x111f('0x3e')]){delete _0x24faca['name'];}_0x496be7['status'](_0x1e5279)[_0x111f('0x3f')](_0x24faca);};}exports[_0x111f('0x40')]=function(_0xb8bfd7,_0x4f04a3){var _0x49f5e2={'include':[{'model':db['Pause'],'as':_0x111f('0x41')}]},_0x4e0209={},_0x4095b4={'count':0x0,'rows':[]};var _0x18e2b7=_['map'](db['ChatWebsite'][_0x111f('0x42')],function(_0x139b21){return{'name':_0x139b21[_0x111f('0x43')],'type':_0x139b21[_0x111f('0x44')]['key']};});_0x4e0209['model']=_[_0x111f('0x45')](_0x18e2b7,_0x111f('0x3e'));_0x4e0209['query']=_['keys'](_0xb8bfd7[_0x111f('0x46')]);_0x4e0209[_0x111f('0x47')]=_['intersection'](_0x4e0209[_0x111f('0x48')],_0x4e0209[_0x111f('0x46')]);_0x49f5e2[_0x111f('0x49')]=_['intersection'](_0x4e0209[_0x111f('0x48')],qs['fields'](_0xb8bfd7[_0x111f('0x46')]['fields']));_0x49f5e2[_0x111f('0x49')]=_0x49f5e2['attributes'][_0x111f('0x4a')]?_0x49f5e2['attributes']:_0x4e0209[_0x111f('0x48')];if(!_0xb8bfd7[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x49f5e2['limit']=qs[_0x111f('0x33')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x33')]);_0x49f5e2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0xb8bfd7[_0x111f('0x46')]['offset']);}_0x49f5e2[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x4d')]);_0x49f5e2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0xb8bfd7[_0x111f('0x46')],_0x4e0209['filters']));if(_0xb8bfd7[_0x111f('0x46')]['filter']){_0x49f5e2['where']=_[_0x111f('0x50')](_0x49f5e2['where'],{'$or':_['map'](_0x18e2b7,function(_0x190ad7){if(_0x190ad7['type']!==_0x111f('0x51')){var _0x965192={};_0x965192[_0x190ad7[_0x111f('0x3e')]]={'$like':'%'+_0xb8bfd7['query']['filter']+'%'};return _0x965192;}})});}_0x49f5e2=_[_0x111f('0x50')]({},_0x49f5e2,_0xb8bfd7['options']);var _0x43a3a8={'where':_0x49f5e2[_0x111f('0x4e')]};return db[_0x111f('0x52')]['count'](_0x43a3a8)[_0x111f('0x25')](function(_0x1e008f){_0x4095b4[_0x111f('0x53')]=_0x1e008f;if(_0xb8bfd7[_0x111f('0x46')][_0x111f('0x54')]){_0x49f5e2[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x52')]['findAll'](_0x49f5e2);})[_0x111f('0x25')](function(_0x2c8b30){_0x4095b4[_0x111f('0x56')]=_0x2c8b30;return _0x4095b4;})['then'](respondWithFilteredResult(_0x4f04a3,_0x49f5e2))[_0x111f('0x57')](handleError(_0x4f04a3,null));};exports[_0x111f('0x58')]=function(_0x17a37a,_0x11dd5e){var _0xac4a93={'raw':![],'where':{'id':_0x17a37a[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]},_0x3ca6c8={};_0x3ca6c8[_0x111f('0x48')]=_[_0x111f('0x5b')](db['ChatWebsite'][_0x111f('0x42')]);_0x3ca6c8[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x17a37a[_0x111f('0x46')]);_0x3ca6c8[_0x111f('0x47')]=_['intersection'](_0x3ca6c8['model'],_0x3ca6c8[_0x111f('0x46')]);_0xac4a93['attributes']=_[_0x111f('0x5c')](_0x3ca6c8[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x17a37a[_0x111f('0x46')][_0x111f('0x5d')]));_0xac4a93[_0x111f('0x49')]=_0xac4a93[_0x111f('0x49')]['length']?_0xac4a93[_0x111f('0x49')]:_0x3ca6c8[_0x111f('0x48')];if(_0x17a37a[_0x111f('0x46')][_0x111f('0x54')]){_0xac4a93[_0x111f('0x55')]=[{'all':!![]}];}_0xac4a93=_[_0x111f('0x50')]({},_0xac4a93,_0x17a37a[_0x111f('0x5e')]);return db[_0x111f('0x52')]['find'](_0xac4a93)[_0x111f('0x25')](handleEntityNotFound(_0x11dd5e,null))[_0x111f('0x25')](respondWithResult(_0x11dd5e,null))[_0x111f('0x57')](handleError(_0x11dd5e,null));};exports[_0x111f('0x5f')]=function(_0x1be243,_0x102ce5){return db[_0x111f('0x52')][_0x111f('0x5f')](_0x1be243[_0x111f('0x60')],{})[_0x111f('0x25')](function(_0x7b6d2e){var _0x12b0d4=_0x1be243[_0x111f('0x61')][_0x111f('0x3b')]({'plain':!![]});if(!_0x12b0d4)throw new Error(_0x111f('0x62'));if(_0x12b0d4[_0x111f('0x63')]==='user'){var _0x4f1700=_0x7b6d2e[_0x111f('0x3b')]({'plain':!![]});var _0x5c0ba8=_0x111f('0x3c');return db[_0x111f('0x64')][_0x111f('0x65')]({'where':{'name':_0x5c0ba8,'userProfileId':_0x12b0d4[_0x111f('0x66')]},'raw':!![]})[_0x111f('0x25')](function(_0x14bf55){if(_0x14bf55&&_0x14bf55[_0x111f('0x67')]===0x0){return db[_0x111f('0x68')][_0x111f('0x5f')]({'name':_0x4f1700[_0x111f('0x3e')],'resourceId':_0x4f1700['id'],'type':_0x14bf55[_0x111f('0x3e')],'sectionId':_0x14bf55['id']},{})[_0x111f('0x25')](function(){return _0x7b6d2e;});}else{return _0x7b6d2e;}})[_0x111f('0x57')](function(_0x15e819){logger[_0x111f('0x2a')](_0x111f('0x69'),_0x15e819);throw _0x15e819;});}return _0x7b6d2e;})['then'](respondWithResult(_0x102ce5,0xc9))[_0x111f('0x57')](handleError(_0x102ce5,null));};exports['update']=function(_0xe193e,_0x501125){if(_0xe193e[_0x111f('0x60')]['id']){delete _0xe193e['body']['id'];}return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0xe193e[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]})['then'](handleEntityNotFound(_0x501125,null))[_0x111f('0x25')](saveUpdates(_0xe193e[_0x111f('0x60')],null))['then'](respondWithResult(_0x501125,null))[_0x111f('0x57')](handleError(_0x501125,null));};exports[_0x111f('0x3a')]=function(_0x4c9354,_0x1b82ef){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4c9354[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1b82ef,null))[_0x111f('0x25')](removeEntity(_0x1b82ef,null))[_0x111f('0x57')](handleError(_0x1b82ef,null));};exports[_0x111f('0x6a')]=function(_0x3c8b53,_0x1635ef){return db[_0x111f('0x52')][_0x111f('0x6a')]()[_0x111f('0x25')](respondWithResult(_0x1635ef,null))[_0x111f('0x57')](handleError(_0x1635ef,null));};exports['addDisposition']=function(_0x50ee6e,_0x41054a,_0x2b7f8c){if(_0x50ee6e[_0x111f('0x60')]['id']){delete _0x50ee6e['body']['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x50ee6e['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x41054a,null))[_0x111f('0x25')](function(_0x5b49fe){if(_0x5b49fe){_0x50ee6e[_0x111f('0x60')][_0x111f('0x6b')]=_0x5b49fe['id'];return db[_0x111f('0x6c')][_0x111f('0x5f')](_0x50ee6e[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x41054a,null))[_0x111f('0x57')](handleError(_0x41054a,null));};exports[_0x111f('0x6d')]=function(_0x8b6c13,_0x2ccec1,_0x3df3f2){var _0x1becd2={'raw':![],'where':{}};var _0x3af9a8={};var _0xeb9353={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x8b6c13[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x2ccec1,null))['then'](function(_0x40a8d5){if(_0x40a8d5){_0x3af9a8[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x6c')][_0x111f('0x42')]);_0x3af9a8['query']=_[_0x111f('0x5b')](_0x8b6c13[_0x111f('0x46')]);_0x3af9a8[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x3af9a8[_0x111f('0x48')],_0x3af9a8['query']);_0x1becd2['attributes']=_['intersection'](_0x3af9a8[_0x111f('0x48')],qs['fields'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x5d')]));_0x1becd2[_0x111f('0x49')]=_0x1becd2['attributes']['length']?_0x1becd2['attributes']:_0x3af9a8['model'];if(!_0x8b6c13[_0x111f('0x46')][_0x111f('0x6e')]('nolimit')){_0x1becd2['limit']=qs[_0x111f('0x33')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x33')]);_0x1becd2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x32')]);}_0x1becd2[_0x111f('0x4c')]=qs['sort'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x4d')]);_0x1becd2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x8b6c13[_0x111f('0x46')],_0x3af9a8[_0x111f('0x47')]));_0x1becd2[_0x111f('0x4e')][_0x111f('0x6b')]=_0x40a8d5['id'];if(_0x8b6c13[_0x111f('0x46')]['filter']){_0x1becd2['where']=_[_0x111f('0x50')](_0x1becd2['where'],{'$or':_[_0x111f('0x45')](_0x1becd2[_0x111f('0x49')],function(_0x13ac34){var _0x4aae13={};_0x4aae13[_0x13ac34]={'$like':'%'+_0x8b6c13[_0x111f('0x46')]['filter']+'%'};return _0x4aae13;})});}_0x1becd2=_['merge']({},_0x1becd2,_0x8b6c13[_0x111f('0x5e')]);return db[_0x111f('0x6c')][_0x111f('0x53')]({'where':_0x1becd2[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x2e5102){_0xeb9353[_0x111f('0x53')]=_0x2e5102;if(_0x8b6c13[_0x111f('0x46')][_0x111f('0x54')]){_0x1becd2['include']=[{'all':!![]}];}return db[_0x111f('0x6c')]['findAll'](_0x1becd2);})['then'](function(_0x1254b4){_0xeb9353[_0x111f('0x56')]=_0x1254b4;return _0xeb9353;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x2ccec1,_0x1becd2))['catch'](handleError(_0x2ccec1,null));};exports[_0x111f('0x6f')]=function(_0x5c4c0d,_0x25b3d6,_0x3ba80b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5c4c0d[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x25b3d6,null))[_0x111f('0x25')](function(_0x5699a4){if(_0x5699a4){return _0x5699a4[_0x111f('0x6f')](_0x5c4c0d['query'][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x25b3d6,null))['catch'](handleError(_0x25b3d6,null));};exports[_0x111f('0x71')]=function(_0x229752,_0x333239,_0x582132){if(_0x229752[_0x111f('0x60')]['id']){delete _0x229752['body']['id'];}return db[_0x111f('0x52')]['find']({'where':{'id':_0x229752[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x333239,null))[_0x111f('0x25')](function(_0x5211f8){if(_0x5211f8){_0x229752[_0x111f('0x60')][_0x111f('0x6b')]=_0x5211f8['id'];return db[_0x111f('0x72')][_0x111f('0x5f')](_0x229752[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x333239,null))[_0x111f('0x57')](handleError(_0x333239,null));};exports['getAnswers']=function(_0x41a0f8,_0x22662b,_0x6942a){var _0x2c0869={'raw':![],'where':{}};var _0x21be68={};var _0x201528={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x41a0f8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x22662b,null))[_0x111f('0x25')](function(_0x259870){if(_0x259870){_0x21be68[_0x111f('0x48')]=_['keys'](db[_0x111f('0x72')][_0x111f('0x42')]);_0x21be68['query']=_[_0x111f('0x5b')](_0x41a0f8[_0x111f('0x46')]);_0x21be68[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x21be68[_0x111f('0x48')],_0x21be68[_0x111f('0x46')]);_0x2c0869[_0x111f('0x49')]=_['intersection'](_0x21be68[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x5d')]));_0x2c0869[_0x111f('0x49')]=_0x2c0869['attributes'][_0x111f('0x4a')]?_0x2c0869[_0x111f('0x49')]:_0x21be68[_0x111f('0x48')];if(!_0x41a0f8['query'][_0x111f('0x6e')]('nolimit')){_0x2c0869[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x33')]);_0x2c0869[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x41a0f8['query']['offset']);}_0x2c0869[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x4d')]);_0x2c0869[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x41a0f8[_0x111f('0x46')],_0x21be68['filters']));_0x2c0869[_0x111f('0x4e')][_0x111f('0x6b')]=_0x259870['id'];if(_0x41a0f8[_0x111f('0x46')]['filter']){_0x2c0869[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x2c0869[_0x111f('0x4e')],{'$or':_['map'](_0x2c0869['attributes'],function(_0x2f2744){var _0x3d6f9b={};_0x3d6f9b[_0x2f2744]={'$like':'%'+_0x41a0f8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x3d6f9b;})});}_0x2c0869=_[_0x111f('0x50')]({},_0x2c0869,_0x41a0f8['options']);return db['CannedAnswer'][_0x111f('0x53')]({'where':_0x2c0869[_0x111f('0x4e')]})['then'](function(_0x444251){_0x201528['count']=_0x444251;if(_0x41a0f8[_0x111f('0x46')][_0x111f('0x54')]){_0x2c0869[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x72')][_0x111f('0x74')](_0x2c0869);})[_0x111f('0x25')](function(_0x426625){_0x201528[_0x111f('0x56')]=_0x426625;return _0x201528;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x22662b,_0x2c0869))['catch'](handleError(_0x22662b,null));};exports[_0x111f('0x75')]=function(_0x1997c0,_0x4b45c2,_0x222c4b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1997c0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x4b45c2,null))['then'](function(_0x392380){if(_0x392380){return _0x392380[_0x111f('0x75')](_0x1997c0[_0x111f('0x46')][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x4b45c2,null))[_0x111f('0x57')](handleError(_0x4b45c2,null));};exports['addLogo']=function(_0x3caec3,_0x3aeef9,_0x587cd2){_0x3caec3['body'][_0x111f('0x76')]=_0x3caec3[_0x111f('0x77')][_0x111f('0x78')];return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0x3caec3[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x3aeef9,null))[_0x111f('0x25')](saveUpdates(_0x3caec3['body'],null))[_0x111f('0x25')](respondWithResult(_0x3aeef9,null))[_0x111f('0x57')](handleError(_0x3aeef9,null));};exports['addAvatar']=function(_0x5b1e6f,_0x58657f,_0x3874a9){_0x5b1e6f[_0x111f('0x60')][_0x111f('0x79')]=_0x5b1e6f[_0x111f('0x77')]['filename'];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5b1e6f['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x58657f,null))[_0x111f('0x25')](saveUpdates(_0x5b1e6f['body'],null))[_0x111f('0x25')](respondWithResult(_0x58657f,null))[_0x111f('0x57')](handleError(_0x58657f,null));};exports[_0x111f('0x7a')]=function(_0x4d8cf2,_0x1eb294,_0xce005d){_0x4d8cf2[_0x111f('0x60')][_0x111f('0x7b')]=_0x4d8cf2['file'][_0x111f('0x78')];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d8cf2['params']['id']}})['then'](handleEntityNotFound(_0x1eb294,null))[_0x111f('0x25')](saveUpdates(_0x4d8cf2[_0x111f('0x60')],null))[_0x111f('0x25')](respondWithResult(_0x1eb294,null))['catch'](handleError(_0x1eb294,null));};exports[_0x111f('0x7c')]=function(_0x202576,_0x428b40,_0x19ff3a){_0x202576[_0x111f('0x60')][_0x111f('0x7d')]=_0x202576[_0x111f('0x77')][_0x111f('0x78')];return db[_0x111f('0x52')]['find']({'where':{'id':_0x202576[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x428b40,null))[_0x111f('0x25')](saveUpdates(_0x202576['body'],null))['then'](respondWithResult(_0x428b40,null))['catch'](handleError(_0x428b40,null));};exports[_0x111f('0x7e')]=function(_0x25789a,_0x5444af,_0x1de9c0){var _0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x80'));var _0x4c0a14={'where':{'id':_0x25789a[_0x111f('0x59')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x3c4d18=![];return require(_0x111f('0x81'))[_0x111f('0x82')]()[_0x111f('0x25')](function(_0x19548c){if(_0x19548c){_0x3c4d18=_0x19548c[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')](_0x4c0a14);})[_0x111f('0x25')](handleEntityNotFound(_0x5444af,null))[_0x111f('0x25')](function(_0x5b2c07){if(_0x5b2c07){if(!_[_0x111f('0x84')](_0x5b2c07['sitepic'])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],'server/files/images/logos/',_0x5b2c07[_0x111f('0x76')]))&&_0x3c4d18){_0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x87'),_0x5b2c07['sitepic']);}}return _0x5444af['download'](_0x19185e);}})['catch'](handleError(_0x5444af,null));};exports['getAvatar']=function(_0x32ed7a,_0x4131f8,_0x54e6a1){var _0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x88'));var _0x2d9475={'where':{'id':_0x32ed7a[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x79')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x2d9475)[_0x111f('0x25')](handleEntityNotFound(_0x4131f8,null))[_0x111f('0x25')](function(_0x513871){if(_0x513871){if(!_[_0x111f('0x84')](_0x513871[_0x111f('0x79')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871['agentAvatar']))){_0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871[_0x111f('0x79')]);}}return _0x4131f8['download'](_0x142dcd);}})[_0x111f('0x57')](handleError(_0x4131f8,null));};exports[_0x111f('0x8a')]=function(_0x18fdb9,_0xd3698f,_0x59d2a1){var _0x1a6a07=path[_0x111f('0x7f')](config['root'],_0x111f('0x8b'));var _0x594a3c={'where':{'id':_0x18fdb9[_0x111f('0x59')]['id']},'attributes':['id','customerAvatar',_0x111f('0x8c')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x594a3c)[_0x111f('0x25')](handleEntityNotFound(_0xd3698f,null))[_0x111f('0x25')](function(_0x4af0f2){if(_0x4af0f2){if(!_[_0x111f('0x84')](_0x4af0f2[_0x111f('0x7b')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]))&&_0x4af0f2[_0x111f('0x8c')]){_0x1a6a07=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]);}}return _0xd3698f[_0x111f('0x8d')](_0x1a6a07);}})[_0x111f('0x57')](handleError(_0xd3698f,null));};exports[_0x111f('0x8e')]=function(_0x7d8ed8,_0x148fe3,_0x279862){var _0x8d2cbc=path[_0x111f('0x7f')](config['root'],'server/files/images/avatars/system_avatar.png');var _0x5579fc={'where':{'id':_0x7d8ed8[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x7d')],'raw':!![]};return db[_0x111f('0x52')]['find'](_0x5579fc)[_0x111f('0x25')](handleEntityNotFound(_0x148fe3,null))[_0x111f('0x25')](function(_0x539089){if(_0x539089){if(!_[_0x111f('0x84')](_0x539089['systemAvatar'])){if(fs['existsSync'](path[_0x111f('0x7f')](config['root'],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]))){_0x8d2cbc=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]);}}return _0x148fe3[_0x111f('0x8d')](_0x8d2cbc);}})[_0x111f('0x57')](handleError(_0x148fe3,null));};exports[_0x111f('0x8f')]=function(_0x500949,_0x36a51a,_0x2be27d){var _0x16aef9=require(_0x111f('0x90'));var _0x1aeab8=new _0x16aef9();var _0x1e78d6=_0x1aeab8[_0x111f('0x91')](_0x500949[_0x111f('0x92')][_0x111f('0x93')])['getResult']();var _0x213bc6={'body':_0x500949[_0x111f('0x60')],'channel':_0x111f('0x94')};var _0x442bab=[];var _0x483197=[];var _0x91ceb2={};var _0x16459c=![];return db[_0x111f('0x95')][_0x111f('0x6a')]()['then'](function(_0xcbe2e3){if(!_0xcbe2e3){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x96'));}_0x442bab=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99')]);_0x483197=_['difference'](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99'),_0x111f('0x9a'),_0x111f('0x9b')]);if(_0x500949[_0x111f('0x60')]['id']){delete _0x500949[_0x111f('0x60')]['id'];}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x9c')])){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x9d'));}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x60')])||_0x500949[_0x111f('0x60')]['body']===''){throw new db[(_0x111f('0x21'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x500949[_0x111f('0x60')][_0x111f('0x9e')])){throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9f')+_0x483197);}if(!_[_0x111f('0xa0')](_0x483197,_0x500949['body'][_0x111f('0x9e')])){throw new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xa1')+_0x483197);}_0x91ceb2[_0x500949['body']['mapKey']]=_0x500949[_0x111f('0x60')]['from'];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x500949[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xa2')],'as':_0x111f('0xa3'),'include':[{'model':db['CmContact'],'as':_0x111f('0xa4'),'where':_0x91ceb2,'limit':0x1,'order':[[_0x111f('0x99'),_0x111f('0xa5')]]}]},{'model':db['ChatApplication'],'as':_0x111f('0xa6')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x54e24e){if(_0x54e24e&&_0x54e24e[_0x111f('0xa3')]){_0x213bc6[_0x111f('0xa7')]=_0x54e24e;_0x213bc6['applications']=_0x54e24e[_0x111f('0xa6')];_0x213bc6['list']=_0x54e24e[_0x111f('0xa3')];_0x213bc6[_0x111f('0xa8')]=_['orderBy'](_0x213bc6[_0x111f('0xa8')],[_0x111f('0xa9')],[_0x111f('0xaa')]);if(_0x213bc6['account'][_0x111f('0xa6')]){delete _0x213bc6['account']['Applications'];}if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')]&&_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')][_0x111f('0xa4')][_0x111f('0x4a')]){return _0x213bc6['account'][_0x111f('0xa3')][_0x111f('0xa4')][0x0];}var _0x43f798=_['defaults'](_0x500949[_0x111f('0x60')],{'firstName':_0x500949[_0x111f('0x60')][_0x111f('0x9c')],'ListId':_0x54e24e[_0x111f('0x9b')]});_0x43f798[_0x500949[_0x111f('0x60')][_0x111f('0x9e')]]=_0x500949[_0x111f('0x60')]['from'];return db['CmContact'][_0x111f('0x5f')](_0x43f798,{'fields':_0x442bab,'raw':!![]});}})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x2ff9d1){_0x213bc6['contact']=_0x2ff9d1;var _0x2b6d8f=_0x500949['body']['customerIp'];if(_0x500949[_0x111f('0x92')][_0x111f('0xab')]){_0x2b6d8f=_0x500949[_0x111f('0x92')][_0x111f('0xab')];}else if(_0x500949['headers']['x-forwarded-for']){_0x2b6d8f=_[_0x111f('0xac')](_0x500949[_0x111f('0x92')]['x-forwarded-for']['split'](','));}if(_0x2ff9d1){var _0x29fd80={'ContactId':_0x2ff9d1['id'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'from':(_0x2ff9d1['firstName']||'')+'\x20'+(_0x2ff9d1['lastName']||''),'customerIp':_0x2b6d8f,'customerPort':_0x500949[_0x111f('0x92')][_0x111f('0xad')]?_0x500949[_0x111f('0x92')]['x-real-port']:null,'referer':_0x500949[_0x111f('0x60')][_0x111f('0xae')],'browserName':_0x1e78d6[_0x111f('0xaf')]['name']&&_0x1e78d6[_0x111f('0xaf')][_0x111f('0xb0')]?util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6[_0x111f('0xaf')][_0x111f('0x3e')],_0x1e78d6[_0x111f('0xaf')]['version']):_0x111f('0xb3'),'browserVersion':_0x1e78d6[_0x111f('0xaf')]['version']||_0x111f('0xb3'),'osName':util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6['os'][_0x111f('0x3e')],_0x1e78d6['os'][_0x111f('0xb0')]),'osVersion':_0x1e78d6['os']['version'],'deviceModel':_0x1e78d6[_0x111f('0xb4')]['model']&&_0x1e78d6[_0x111f('0xb4')]['vendor']?util[_0x111f('0xb1')](_0x111f('0xb5'),_0x1e78d6[_0x111f('0xb4')][_0x111f('0x48')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0x44')]):null,'deviceVendor':_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],'deviceType':_0x1e78d6[_0x111f('0xb4')]['type'],'formData':JSON['stringify'](_0x500949[_0x111f('0x60')])};var _0xbe839e={'ChatWebsiteId':_0x500949['params']['id'],'closed':![]};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]){_0xbe839e[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];return db[_0x111f('0xb8')]['find']({'where':_0xbe839e})[_0x111f('0x25')](function(_0x2db594){if(_0x2db594){return[_0x2db594,![]];}_0x29fd80[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];_0x29fd80[_0x111f('0xb9')]=_0x500949[_0x111f('0x60')]['externalUrl'];return db[_0x111f('0xb8')][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x573cf8){return[_0x573cf8,!![]];});});}_0xbe839e[_0x111f('0xba')]=_0x2ff9d1['id'];if(_0x500949[_0x111f('0x60')][_0x111f('0xbb')]&&_0x500949[_0x111f('0x60')]['interaction']['id']){_0xbe839e['id']=_0x500949[_0x111f('0x60')][_0x111f('0xbb')]['id'];return db[_0x111f('0xb8')][_0x111f('0x65')]({'where':_0xbe839e})['then'](function(_0x227391){if(_0x227391){return[_0x227391,![]];}return db['ChatInteraction'][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x1ec50d){return[_0x1ec50d,!![]];});});}return db[_0x111f('0xb8')]['create'](_0x29fd80)[_0x111f('0x25')](function(_0x5db274){return[_0x5db274,!![]];});}})[_0x111f('0xbc')](function(_0x18d9a1,_0x2bddca){if(_0x18d9a1){_0x16459c=_0x2bddca;if(!_0x2bddca){var _0x4fc016={'from':(_0x213bc6['contact'][_0x111f('0xbd')]||'')+'\x20'+(_0x213bc6[_0x111f('0xbe')]['lastName']||'')};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]&&_0x500949[_0x111f('0x60')][_0x111f('0xbf')]&&_0x500949['body']['threadId']!=_0x500949['body'][_0x111f('0xbf')]){_0x4fc016[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xbf')];}return _0x18d9a1[_0x111f('0x39')](_0x4fc016);}else{return _0x18d9a1;}}})[_0x111f('0x25')](function(_0x5ec6f4){_0x213bc6[_0x111f('0xbb')]=_0x5ec6f4[_0x111f('0x3b')]({'plain':!![]});_0x213bc6[_0x111f('0xbb')][_0x111f('0xc0')]=_0x16459c;if(_0x213bc6['interaction'][_0x111f('0xc0')]){if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc1')]){_0x213bc6['applications']['push']({'id':0x0,'priority':_0x213bc6['applications'][_0x111f('0x4a')]+0x1,'app':'close','appdata':'unmanaged','interval':_0x111f('0xc2')});}}return db[_0x111f('0xc3')][_0x111f('0x5f')]({'body':_0x500949[_0x111f('0x60')]['body'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'ChatInteractionId':_0x5ec6f4['id'],'direction':'in','ContactId':_0x213bc6[_0x111f('0xbe')]['id'],'AttachmentId':_0x500949[_0x111f('0x60')]['AttachmentId']});})[_0x111f('0x25')](function(_0xcfe194){_0x213bc6[_0x111f('0x2c')]=_0xcfe194;if(_0x213bc6['interaction']['UserId']){return db['User']['find']({'attributes':['id',_0x111f('0x3e')],'where':{'id':_0x213bc6[_0x111f('0xbb')][_0x111f('0xc4')]}})['then'](function(_0x1d4625){if(_0x1d4625){_0x213bc6[_0x111f('0xa8')][_0x111f('0xc5')]({'id':0x0,'priority':0x0,'app':_0x111f('0xc6'),'appdata':_0x1d4625[_0x111f('0x3e')]+','+(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc7')]||0xa),'interval':_0x111f('0xc2')});_0x213bc6[_0x111f('0xc8')]=!![];}return respondWithRpcPromise(_0x111f('0xc9'),_0x111f('0xca'),_0x213bc6);});}return respondWithRpcPromise(_0x111f('0xc9'),'startRouting',_0x213bc6);})[_0x111f('0x25')](function(_0x1fca61){respondWithRpcPromise(_0x111f('0xcb'),_0x111f('0xcb'),{'event':_0x111f('0x8f'),'message':_0x1fca61},client9002);return _0x1fca61;})[_0x111f('0x25')](respondWithResult(_0x36a51a,null))['catch'](handleError(_0x36a51a,null));};exports['offline']=function(_0x1fdf5f,_0x103227,_0x2f1787){var _0x489f1f,_0x506099,_0x347b17;var _0x3dd51c=[];var _0x57c1c0=[];var _0x44445a={};return db[_0x111f('0x95')][_0x111f('0x6a')]()[_0x111f('0x25')](function(_0x5b5f5e){if(!_0x5b5f5e){throw new db[(_0x111f('0x21'))]['ValidationError']('no\x20available\x20attributes');}_0x57c1c0=_[_0x111f('0x97')](_['keys'](_0x5b5f5e),[_0x111f('0x98'),_0x111f('0x99')]);_0x3dd51c=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0x5b5f5e),[_0x111f('0x98'),'updatedAt','CompanyId',_0x111f('0x9b')]);if(_0x1fdf5f[_0x111f('0x60')]['id']){delete _0x1fdf5f[_0x111f('0x60')]['id'];}if(_['isNil'](_0x1fdf5f['body'][_0x111f('0x9c')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9d')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')])||_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')]===''){throw _0x103227[_0x111f('0x2f')](0x1f4)['send'](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0xcc')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0xce')+_0x3dd51c));}if(!_[_0x111f('0xa0')](_0x3dd51c,_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xcf')+_0x3dd51c));}_0x44445a[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1fdf5f[_0x111f('0x59')]['id']},'include':[{'model':db['CmList'],'as':_0x111f('0xa3')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x103227,null))[_0x111f('0x25')](function(_0x11c478){if(_0x11c478&&_0x11c478[_0x111f('0xa3')]){_0x506099=_0x11c478;var _0x1bd0d6=_[_0x111f('0xd0')](_0x1fdf5f[_0x111f('0x60')],{'firstName':_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')],'phone':_0x1fdf5f[_0x111f('0x60')]['from'],'ListId':_0x11c478[_0x111f('0x9b')]});_0x1bd0d6[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];return db[_0x111f('0x95')][_0x111f('0xd1')]({'where':_0x44445a,'defaults':_0x1bd0d6});}})[_0x111f('0xbc')](function(_0x3d03ec){if(_0x3d03ec){_0x347b17=_0x3d03ec;var _0x5e80a8=fs[_0x111f('0xd2')](path['join'](config['root'],'server/files/templates/chatOfflineMessage.ejs'),_0x111f('0xd3'));var _0x5a48f6=ejs[_0x111f('0xd4')](_0x5e80a8,{'body':_[_0x111f('0xd5')](_0x1fdf5f[_0x111f('0x60')]['body']),'bodyTitle':_0x506099[_0x111f('0xd6')]});return db['ChatOfflineMessage'][_0x111f('0x5f')]({'body':_0x5a48f6,'ContactId':_0x3d03ec['id'],'ChatWebsiteId':_0x506099['id']});}})['then'](function(_0xfa9928){if(_0xfa9928){_0x489f1f=_0xfa9928;return db[_0x111f('0xd7')][_0x111f('0xd8')]({'where':{'service':!![]},'include':[{'model':db[_0x111f('0xd9')],'as':_0x111f('0xda'),'raw':!![]}]});}})[_0x111f('0x25')](function(_0x37b61e){if(_0x37b61e&&_0x37b61e[_0x111f('0xda')]&&_0x506099[_0x111f('0xdb')]){var _0x36e810={'tls':{'rejectUnauthorized':![]}};if(_0x37b61e[_0x111f('0xda')]['service']){_0x36e810[_0x111f('0xdc')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdc')];}else{_0x36e810[_0x111f('0xdd')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdd')];_0x36e810[_0x111f('0xde')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xde')];_0x36e810['secure']=_0x37b61e['Smtp'][_0x111f('0xdf')];}if(_0x37b61e[_0x111f('0xda')]['authentication']){_0x36e810[_0x111f('0xe0')]={'user':_0x37b61e[_0x111f('0xda')][_0x111f('0x61')],'pass':_0x37b61e[_0x111f('0xda')][_0x111f('0xe1')]};}return respondWithRpcPromise(_0x111f('0xe2'),_0x111f('0xe3'),{'account':_0x36e810,'message':{'from':util[_0x111f('0xb1')](_0x111f('0xe4'),_0x37b61e[_0x111f('0x3e')],_0x37b61e[_0x111f('0xe5')]||_0x37b61e[_0x111f('0xda')][_0x111f('0x61')]),'to':_0x506099[_0x111f('0xdb')],'subject':_0x506099[_0x111f('0xe6')],'text':_0x489f1f[_0x111f('0x60')]}},client9003)[_0x111f('0x25')](function(){return _0x489f1f;})[_0x111f('0x57')](function(_0x3036ae){console[_0x111f('0x2a')](_0x3036ae);});}})[_0x111f('0x25')](function(){if(_0x489f1f){return _0x489f1f;}})[_0x111f('0x25')](respondWithResult(_0x103227,null))[_0x111f('0x57')](handleError(_0x103227,null));};exports[_0x111f('0xe7')]=function(_0x14c2cd,_0x1a531d,_0xf7b1fc){return db['ChatInteraction']['find']({'where':{'id':_0x14c2cd[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1a531d,null))[_0x111f('0x25')](function(_0x4c49e9){if(_0x4c49e9){return _0x4c49e9[_0x111f('0xe7')](_0x14c2cd[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x14c2cd['body'],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x1a531d,null))[_0x111f('0x57')](handleError(_0x1a531d,null));};exports[_0x111f('0xe9')]=function(_0x5a84a0,_0xa63817,_0x55028a){var _0x3a99e7={'raw':![],'where':{}};var _0xe8a28f={};var _0x4a08bd={'count':0x0,'rows':[]};return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x5a84a0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0xa63817,null))[_0x111f('0x25')](function(_0x1960a2){if(_0x1960a2){_0xe8a28f[_0x111f('0x48')]=_['keys'](db['ChatInteraction'][_0x111f('0x42')]);_0xe8a28f[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a84a0[_0x111f('0x46')]);_0xe8a28f[_0x111f('0x47')]=_[_0x111f('0x5c')](_0xe8a28f['model'],_0xe8a28f['query']);_0x3a99e7[_0x111f('0x49')]=_['intersection'](_0xe8a28f[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x5d')]));_0x3a99e7['attributes']=_0x3a99e7[_0x111f('0x49')]['length']?_0x3a99e7['attributes']:_0xe8a28f[_0x111f('0x48')];if(!_0x5a84a0[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x3a99e7[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x33')]);_0x3a99e7[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x32')]);}_0x3a99e7[_0x111f('0x4c')]=qs['sort'](_0x5a84a0[_0x111f('0x46')]['sort']);_0x3a99e7[_0x111f('0x4e')]=qs['filters'](_['pick'](_0x5a84a0['query'],_0xe8a28f[_0x111f('0x47')]));_0x3a99e7[_0x111f('0x4e')][_0x111f('0x6b')]=_0x1960a2['id'];if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]){_0x3a99e7[_0x111f('0x4e')]=_['merge'](_0x3a99e7[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x3a99e7[_0x111f('0x49')],function(_0xb2762d){var _0x512fbb={};_0x512fbb[_0xb2762d]={'$like':'%'+_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x512fbb;})});}_0x3a99e7=_[_0x111f('0x50')]({},_0x3a99e7,_0x5a84a0['options']);return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':_0x3a99e7[_0x111f('0x4e')]})['then'](function(_0x58a277){_0x4a08bd['count']=_0x58a277;if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x54')]){_0x3a99e7[_0x111f('0x55')]=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]},{'model':db[_0x111f('0xeb')],'as':_0x111f('0xec'),'attributes':[_0x111f('0x3e'),'fullname',_0x111f('0xed')],'required':![]},{'model':db[_0x111f('0xee')],'as':'Tags','attributes':['id','name',_0x111f('0xef')],'where':_0x5a84a0[_0x111f('0x46')]['tag']?{'id':_0x5a84a0['query'][_0x111f('0xf0')]}:undefined,'required':_0x5a84a0[_0x111f('0x46')]['tag']?!![]:![]}];}return db[_0x111f('0xb8')][_0x111f('0x74')](_0x3a99e7);})['then'](function(_0x20f724){_0x4a08bd[_0x111f('0x56')]=_0x20f724;return _0x4a08bd;});}})['then'](respondWithFilteredResult(_0xa63817,_0x3a99e7))[_0x111f('0x57')](handleError(_0xa63817,null));};function iftimePromise(_0x161139,_0x279c5b){return respondWithRpcPromise('Command','getSnippet',{'command':_0x279c5b[_0x111f('0xf1')]?util[_0x111f('0xb1')]('iftime\x20%s,%s',_0x161139[_0x111f('0xf2')],_0x279c5b[_0x111f('0xf1')]):util[_0x111f('0xb1')](_0x111f('0xf3'),_0x161139[_0x111f('0xf2')])},client9002)['then'](function(_0x13cbd4){var _0xca5f7=_0x13cbd4&&_0x13cbd4[_0x111f('0xf4')](_0x111f('0xf5'))>=0x0?!![]:![];logger[_0x111f('0x26')](_0x111f('0xf6'),_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],_0xca5f7?_0x111f('0xf7'):_0x111f('0xf8'),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return _0xca5f7;})[_0x111f('0x57')](function(_0x12408b){logger[_0x111f('0x2a')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],util[_0x111f('0xfa')](_0x12408b,{'showHidden':![],'depth':null}),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return![];});}exports['getSnippet']=function(_0x4d5c65,_0x5603ba,_0xa528f8){var _0x39d2be=0x0;var _0x54c0b1=0x0;var _0x213570=![];var _0x317933;var _0xd4495e;return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d5c65[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xfb')],'as':_0x111f('0xfb'),'include':[{'model':db['Interval'],'as':_0x111f('0xfc'),'attributes':['id',_0x111f('0xf2')],'raw':!![]}]}]})[_0x111f('0x25')](handleEntityNotFound(_0x5603ba,null))['then'](function(_0x1e09e7){if(_0x1e09e7){_0x317933=_0x1e09e7;return _0x1e09e7[_0x111f('0xfd')]({'raw':!![]});}})[_0x111f('0x25')](function(_0x25a764){if(_0x317933){if(_0x25a764){_0xd4495e=_0x25a764;}}return require('../../config/license/util')[_0x111f('0x82')]();})['then'](function(_0x1b471a){if(_0x1b471a){_0x54c0b1=_0x1b471a[_0x111f('0xfe')];_0x213570=_0x1b471a[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':{'closed':![]}});})[_0x111f('0x25')](function(_0x968278){_0x39d2be=_0x968278;if(_0x54c0b1&&_0x968278>_0x54c0b1){return db[_0x111f('0xff')][_0x111f('0xd8')]({'where':{'id':0x1}})['then'](function(_0x4ee2b2){if(_0x4ee2b2){_0x4ee2b2[_0x111f('0x100')]('chatLicenseExceeded');}});}})[_0x111f('0x25')](function(){if(_0x317933[_0x111f('0xfb')]&&_0x317933[_0x111f('0xfb')][_0x111f('0xfc')]){var _0x2ac058=[];for(var _0x257020=0x0;_0x257020<_0x317933['Interval']['Intervals']['length'];_0x257020++){var _0x4a4687=_0x317933[_0x111f('0xfb')][_0x111f('0xfc')][_0x257020][_0x111f('0x3b')]({'plain':!![]});_0x2ac058[_0x111f('0x101')](iftimePromise(_0x4a4687,_0x317933));}return BPromise[_0x111f('0x102')](_0x2ac058)[_0x111f('0x25')](function(_0x3887dc){return _[_0x111f('0x103')](_0x3887dc);});}else{return!![];}})[_0x111f('0x25')](function(_0x5130e6){var _0x236140=fs['readFileSync'](path['join'](config[_0x111f('0x86')],_0x111f('0x104')),_0x111f('0xd3'));var _0x45cb99={'remote':_0x317933['remote'],'query':querystring[_0x111f('0x105')](_[_0x111f('0x50')](_0x317933[_0x111f('0x3b')]({'plain':!![]}),{'customerIp':_0x4d5c65[_0x111f('0x92')][_0x111f('0x106')]||_0x4d5c65[_0x111f('0x92')][_0x111f('0x107')]||_0x4d5c65[_0x111f('0x108')]['remoteAddress']||_0x4d5c65['ip'],'referer':_0x4d5c65[_0x111f('0x92')][_0x111f('0xae')],'openedInteractions':_0x39d2be,'maxInteractions':_0x54c0b1,'virtual':_0x213570['virtual'],'online':_0x5130e6,'custom':_0x213570}))['replace'](/'/g,'\x5c\x27')};_0x5603ba['send'](ejs['render'](Mustache['render'](_0x236140,_0x45cb99),{'proactiveActions':_0xd4495e,'alignment':_0x317933[_0x111f('0x109')],'verticalAlignment':_0x317933[_0x111f('0x10a')],'div_color':_0x317933[_0x111f('0xef')],'text_color':_0x317933['textColor']}));})[_0x111f('0x57')](handleError(_0x5603ba,null));};exports[_0x111f('0x10b')]=function(_0x14fba6,_0x363bfe,_0x38a347){return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x14fba6[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x363bfe,null))['then'](function(_0x5a46a2){if(_0x5a46a2){return db['sequelize'][_0x111f('0x10c')](function(_0x528038){return db['ChatApplication'][_0x111f('0x3a')]({'where':{'ChatWebsiteId':_0x14fba6[_0x111f('0x59')]['id']},'transaction':_0x528038})['then'](function(_0xb2fc2c){var _0x3a8f2f=_[_0x111f('0x45')](_0x14fba6['body'],function(_0x2030b0){_0x2030b0[_0x111f('0x6b')]=_0x14fba6[_0x111f('0x59')]['id'];return _0x2030b0;});return db[_0x111f('0x10d')][_0x111f('0x10e')](_0x3a8f2f,{'transaction':_0x528038});});})[_0x111f('0x25')](function(){return db[_0x111f('0x10d')][_0x111f('0x10f')]({'where':{'ChatWebsiteId':_0x14fba6['params']['id']},'order':_0x111f('0xa9')});});}})[_0x111f('0x25')](respondWithResult(_0x363bfe,null))[_0x111f('0x57')](handleError(_0x363bfe,null));};exports[_0x111f('0x110')]=function(_0x323ebf,_0x12e53f,_0x338ff5){var _0x50a4d4={};var _0xc38494={};var _0x53580d;var _0x127476;return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x323ebf[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x12e53f,null))[_0x111f('0x25')](function(_0x54f1a0){if(_0x54f1a0){_0x53580d=_0x54f1a0;_0xc38494[_0x111f('0x48')]=_['keys'](db['ChatApplication'][_0x111f('0x42')]);_0xc38494[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x323ebf[_0x111f('0x46')]);_0xc38494['filters']=_['intersection'](_0xc38494[_0x111f('0x48')],_0xc38494[_0x111f('0x46')]);_0x50a4d4[_0x111f('0x49')]=_[_0x111f('0x5c')](_0xc38494[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x323ebf['query']['fields']));_0x50a4d4['attributes']=_0x50a4d4[_0x111f('0x49')][_0x111f('0x4a')]?_0x50a4d4['attributes']:_0xc38494[_0x111f('0x48')];_0x50a4d4[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x323ebf[_0x111f('0x46')][_0x111f('0x4d')]);_0x50a4d4['where']=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x323ebf[_0x111f('0x46')],_0xc38494[_0x111f('0x47')]));if(_0x323ebf[_0x111f('0x46')][_0x111f('0x73')]){_0x50a4d4[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x50a4d4[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x50a4d4['attributes'],function(_0x267901){var _0x4f1d99={};_0x4f1d99[_0x267901]={'$like':'%'+_0x323ebf['query'][_0x111f('0x73')]+'%'};return _0x4f1d99;})});}_0x50a4d4=_[_0x111f('0x50')]({},_0x50a4d4,_0x323ebf[_0x111f('0x5e')]);return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x4e6ea6){if(_0x4e6ea6){_0x127476=_0x4e6ea6[_0x111f('0x4a')];if(!_0x323ebf['query'][_0x111f('0x6e')]('nolimit')){_0x50a4d4[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x323ebf[_0x111f('0x46')]['limit']);_0x50a4d4[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x323ebf[_0x111f('0x46')]['offset']);}return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x2ede1c){if(_0x2ede1c){return _0x2ede1c?{'count':_0x127476,'rows':_0x2ede1c}:null;}})[_0x111f('0x25')](respondWithResult(_0x12e53f,null))['catch'](handleError(_0x12e53f,null));};exports['addProactiveActions']=function(_0x36b00e,_0x281b77,_0x34bc51){return db[_0x111f('0x111')][_0x111f('0x65')]({'where':{'id':_0x36b00e[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x281b77,null))[_0x111f('0x25')](function(_0x5b9f56){if(_0x5b9f56){return _0x5b9f56[_0x111f('0x112')](_0x36b00e[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x36b00e[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x281b77,null))['catch'](handleError(_0x281b77,null));};exports[_0x111f('0xfd')]=function(_0x2b7760,_0x171271,_0x2c1aec){var _0x5a6d6a={};var _0x5dbc0e={};var _0x111c11;var _0x47d1d5;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2b7760[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x171271,null))[_0x111f('0x25')](function(_0x31112d){if(_0x31112d){_0x111c11=_0x31112d;_0x5dbc0e['model']=_[_0x111f('0x5b')](db['ChatProactiveAction']['rawAttributes']);_0x5dbc0e[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2b7760[_0x111f('0x46')]);_0x5dbc0e['filters']=_['intersection'](_0x5dbc0e['model'],_0x5dbc0e[_0x111f('0x46')]);_0x5a6d6a[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x5dbc0e['model'],qs['fields'](_0x2b7760['query'][_0x111f('0x5d')]));_0x5a6d6a['attributes']=_0x5a6d6a[_0x111f('0x49')]['length']?_0x5a6d6a[_0x111f('0x49')]:_0x5dbc0e[_0x111f('0x48')];_0x5a6d6a['order']=qs['sort'](_0x2b7760['query'][_0x111f('0x4d')]);_0x5a6d6a[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2b7760[_0x111f('0x46')],_0x5dbc0e['filters']));if(_0x2b7760['query']['filter']){_0x5a6d6a[_0x111f('0x4e')]=_['merge'](_0x5a6d6a[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x5a6d6a[_0x111f('0x49')],function(_0xadc0ae){var _0x2a0bd6={};_0x2a0bd6[_0xadc0ae]={'$like':'%'+_0x2b7760[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x2a0bd6;})});}_0x5a6d6a=_['merge']({},_0x5a6d6a,_0x2b7760[_0x111f('0x5e')]);return _0x111c11['getProactiveActions'](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x2c7397){if(_0x2c7397){_0x47d1d5=_0x2c7397[_0x111f('0x4a')];if(!_0x2b7760[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x5a6d6a['limit']=qs[_0x111f('0x33')](_0x2b7760[_0x111f('0x46')]['limit']);_0x5a6d6a[_0x111f('0x32')]=qs['offset'](_0x2b7760[_0x111f('0x46')][_0x111f('0x32')]);}return _0x111c11[_0x111f('0xfd')](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x310ebd){if(_0x310ebd){return _0x310ebd?{'count':_0x47d1d5,'rows':_0x310ebd}:null;}})[_0x111f('0x25')](respondWithResult(_0x171271,null))[_0x111f('0x57')](handleError(_0x171271,null));};exports['getFields']=function(_0xc181d1,_0x5f4b15,_0x3cd12e){var _0x51ad5=_0xc181d1[_0x111f('0x46')][_0x111f('0x113')]===_0x111f('0x114')?_0x111f('0x115'):_0x111f('0x116');return db[_0x111f('0x52')]['find']({'attributes':['id',_0x51ad5],'where':{'id':_0xc181d1[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x5f4b15,null))[_0x111f('0x25')](function(_0x505398){if(_0x505398){var _0x232927=_0x505398[_0x51ad5];var _0x43348f=_0x232927&&_0x232927[_0x111f('0x117')]?_0x232927[_0x111f('0x117')]:[];_0x5f4b15[_0x111f('0x3f')]({'fromKey':_[_0x111f('0x84')](_0x232927[_0x111f('0x118')])?undefined:_0x232927['fromKey'],'count':_0x43348f[_0x111f('0x4a')],'rows':_0x43348f});}})[_0x111f('0x57')](handleError(_0x5f4b15,null));};exports['getOfflineMessages']=function(_0x5a79dd,_0x13f9e2,_0x1ff8e9){var _0x15fceb={'raw':![],'where':{}};var _0x177146={};var _0xd73d20={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x5a79dd['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x13f9e2,null))['then'](function(_0x523a1e){if(_0x523a1e){_0x177146[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x119')][_0x111f('0x42')]);_0x177146[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a79dd[_0x111f('0x46')]);_0x177146[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],_0x177146[_0x111f('0x46')]);_0x15fceb[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],qs['fields'](_0x5a79dd[_0x111f('0x46')][_0x111f('0x5d')]));_0x15fceb[_0x111f('0x49')]=_0x15fceb['attributes']['length']?_0x15fceb['attributes']:_0x177146[_0x111f('0x48')];if(!_0x5a79dd[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x15fceb['limit']=qs[_0x111f('0x33')](_0x5a79dd['query'][_0x111f('0x33')]);_0x15fceb[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a79dd['query'][_0x111f('0x32')]);}_0x15fceb[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x5a79dd[_0x111f('0x46')][_0x111f('0x4d')]);_0x15fceb['where']=qs['filters'](_['pick'](_0x5a79dd['query'],_0x177146[_0x111f('0x47')]));_0x15fceb['where'][_0x111f('0x6b')]=_0x523a1e['id'];if(_0x5a79dd[_0x111f('0x46')]['filter']){_0x15fceb['where']=_[_0x111f('0x50')](_0x15fceb[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x15fceb[_0x111f('0x49')],function(_0x5be102){var _0x218be9={};_0x218be9[_0x5be102]={'$like':'%'+_0x5a79dd[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x218be9;})});}_0x15fceb=_[_0x111f('0x50')]({},_0x15fceb,_0x5a79dd[_0x111f('0x5e')]);return db['ChatOfflineMessage'][_0x111f('0x53')]({'where':_0x15fceb[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x211421){_0xd73d20['count']=_0x211421;if(_0x5a79dd[_0x111f('0x46')][_0x111f('0x54')]){_0x15fceb[_0x111f('0x55')]=[{'all':!![]}];}else{_0x15fceb['include']=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]}];}return db['ChatOfflineMessage'][_0x111f('0x74')](_0x15fceb);})[_0x111f('0x25')](function(_0x35f237){_0xd73d20[_0x111f('0x56')]=_0x35f237;return _0xd73d20;});}})['then'](respondWithFilteredResult(_0x13f9e2,_0x15fceb))[_0x111f('0x57')](handleError(_0x13f9e2,null));};exports[_0x111f('0x11a')]=function(_0x59f90f,_0x3fabb4,_0x55f535){return db[_0x111f('0x52')]['find']({'where':{'id':_0x59f90f[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x3fabb4,null))['then'](function(_0x544e64){if(_0x544e64){return _0x544e64[_0x111f('0x11a')](_0x59f90f['body'][_0x111f('0x70')],_['omit'](_0x59f90f[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{})[_0x111f('0xbc')](function(_0x4e31e8){for(var _0xf6b279=0x0;_0xf6b279<_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0x111f('0x4a')];_0xf6b279+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11c'),{'UserId':_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0xf6b279],'ChatWebsiteId':_0x59f90f[_0x111f('0x59')]['id']});}return _0x4e31e8;});}})[_0x111f('0x25')](respondWithResult(_0x3fabb4,null))[_0x111f('0x57')](handleError(_0x3fabb4,null));};exports['removeAgents']=function(_0x20d9f5,_0x40e0ed,_0x7d61ab){return db['ChatWebsite']['find']({'where':{'id':_0x20d9f5[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x40e0ed,null))['then'](function(_0x3d0202){if(_0x3d0202){return _0x3d0202['removeAgents'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])[_0x111f('0x25')](function(){if(_['isArray'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])){for(var _0x3e460b=0x0;_0x3e460b<_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]['length'];_0x3e460b+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')]['ids'][_0x3e460b]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}}else{socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}});}})[_0x111f('0x25')](respondWithStatusCode(_0x40e0ed,null))[_0x111f('0x57')](handleError(_0x40e0ed,null));};exports[_0x111f('0x11e')]=function(_0x2134c8,_0x7e36f6,_0x4784b2){var _0x46bf50={};var _0x993fde={};var _0x4555be;var _0x5b2601;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2134c8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x7e36f6,null))[_0x111f('0x25')](function(_0x5da68c){if(_0x5da68c){_0x4555be=_0x5da68c;_0x993fde['model']=_['keys'](db[_0x111f('0xeb')][_0x111f('0x42')]);_0x993fde[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2134c8[_0x111f('0x46')]);_0x993fde[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],_0x993fde[_0x111f('0x46')]);_0x46bf50[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x5d')]));_0x46bf50['attributes']=_0x46bf50[_0x111f('0x49')][_0x111f('0x4a')]?_0x46bf50['attributes']:_0x993fde[_0x111f('0x48')];_0x46bf50['order']=qs[_0x111f('0x4d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x4d')]);_0x46bf50[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2134c8[_0x111f('0x46')],_0x993fde['filters']));if(_0x2134c8['query'][_0x111f('0x73')]){_0x46bf50[_0x111f('0x4e')]=_['merge'](_0x46bf50[_0x111f('0x4e')],{'$or':_['map'](_0x46bf50[_0x111f('0x49')],function(_0x777234){var _0x397fc3={};_0x397fc3[_0x777234]={'$like':'%'+_0x2134c8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x397fc3;})});}_0x46bf50=_[_0x111f('0x50')]({},_0x46bf50,_0x2134c8[_0x111f('0x5e')]);return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x1f97c8){if(_0x1f97c8){_0x5b2601=_0x1f97c8[_0x111f('0x4a')];if(!_0x2134c8[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x46bf50[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x2134c8[_0x111f('0x46')]['limit']);_0x46bf50[_0x111f('0x32')]=qs['offset'](_0x2134c8[_0x111f('0x46')][_0x111f('0x32')]);}return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x4c1464){if(_0x4c1464){return _0x4c1464?{'count':_0x5b2601,'rows':_0x4c1464}:null;}})[_0x111f('0x25')](respondWithResult(_0x7e36f6,null))[_0x111f('0x57')](handleError(_0x7e36f6,null));};
\ No newline at end of file
+var _0x88b3=['mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','List','Contacts','ChatApplication','Applications','Interval','Intervals','account','applications','orderBy','priority','asc','ListId','contact','headers','threadId','ChatInteraction','externalUrl','ContactId','interaction','lastName','messageId','created','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','queueId','ChatQueue','queue','startRouting','EventManager','offline','files','no\x20available\x20attributes','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','mimetype','server','attachments','offline-chat','openNewInteraction','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOffline','getSmtpOptions','SendMail','sendMail','email','forwardOfflineAddress','offlineMessageSubject','originalname','toPairsIn','mapValues','subjectOffline','MailAccountId','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','Tag','Tags','color','tag','findAll','getProactiveActions','../../config/license/util','chatLicenseExceeded','URL','3.5.0','remote','connection','remoteAddress','virtual','replace','alignment','verticalAlignment','textButtonColor','hideWhenOffline','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','finally','json','getApplications','chatProactiveAction','addProactiveActions','ChatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','util','path','ejs','fs-extra','lodash','html-to-text','ioredis','url','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../errors/api','APINotFoundError','handleError','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','http','client','then','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','sendStatus','end','status','offset','limit','undefined','count','set','Content-Range','update','destroy','stack','name','send','Command','getSnippet','timezone','iftime\x20%s,%s','interval','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','No\x20timezone','catch','inspect','map','get','all','some','user-agent-parser','user-agent','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','x-real-port','referer','browser','version','%s\x20%s','unknown','format','device','model','%s\x20%s\x20%s','vendor','type','index','Pause','mandatoryDispositionPause','ChatWebsite','fieldName','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','rows','show','params','rawAttributes','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatWebsites','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','hasOwnProperty','pick','removeDispositions','CannedAnswer','getAnswers','removeAnswers','ids','addLogo','sitepic','file','addAvatar','addCustomerAvatar','customerAvatar','filename','addSystemAvatar','systemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','getLicense','custom','join','download','getAvatar','agentAvatar','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','isNil','existsSync','server/files/images/avatars/system_avatar.png','notify','chat','CmContact','Sequelize','ValidationError','difference','createdAt','updatedAt','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes'];(function(_0x1af07b,_0x1aa449){var _0x300ad6=function(_0x3b6cef){while(--_0x3b6cef){_0x1af07b['push'](_0x1af07b['shift']());}};_0x300ad6(++_0x1aa449);}(_0x88b3,0x86));var _0x388b=function(_0x591e93,_0x2cdfb6){_0x591e93=_0x591e93-0x0;var _0x369ab0=_0x88b3[_0x591e93];return _0x369ab0;};'use strict';var Mustache=require(_0x388b('0x0'));var util=require(_0x388b('0x1'));var path=require(_0x388b('0x2'));var ejs=require(_0x388b('0x3'));var fs=require('fs');var fs_extra=require(_0x388b('0x4'));var _=require(_0x388b('0x5'));var querystring=require('querystring');var htmlToText=require(_0x388b('0x6'));var Redis=require(_0x388b('0x7'));var jayson=require('jayson/promise');var url=require(_0x388b('0x8'));var qs=require(_0x388b('0x9'));var logger=require(_0x388b('0xa'))(_0x388b('0xb'));var config=require(_0x388b('0xc'));var APIOutOfIntervalError=require(_0x388b('0xd'))['APIOutOfIntervalError'];var APINotFoundError=require(_0x388b('0xd'))[_0x388b('0xe')];var APIHandleError=require(_0x388b('0xd'))[_0x388b('0xf')];var db=require(_0x388b('0x10'))['db'];config[_0x388b('0x11')]=_[_0x388b('0x12')](config[_0x388b('0x11')],{'host':_0x388b('0x13'),'port':0x18eb});var socket=require(_0x388b('0x14'))(new Redis(config[_0x388b('0x11')]));require(_0x388b('0x15'))[_0x388b('0x16')](socket);var client=jayson['client'][_0x388b('0x17')]({'port':0x232c});var client9002=jayson['client'][_0x388b('0x17')]({'port':0x232a});var client9003=jayson[_0x388b('0x18')][_0x388b('0x17')]({'port':0x232b});var client9001=jayson['client'][_0x388b('0x17')]({'port':0x2329});function respondWithRpcPromise(_0x363ed7,_0x123d77,_0x4a2850,_0x485ac6){return new Promise(function(_0x54d761,_0x1b3071){var _0x6c11a2=_0x485ac6||client;return _0x6c11a2['request'](_0x363ed7,_0x4a2850)[_0x388b('0x19')](function(_0x3afbe4){logger['info'](_0x388b('0x1a'),_0x123d77,_0x388b('0x1b'));logger[_0x388b('0x1c')](_0x388b('0x1d'),_0x123d77,_0x388b('0x1b'),JSON[_0x388b('0x1e')](_0x3afbe4));if(_0x3afbe4[_0x388b('0x1f')]){if(_0x3afbe4[_0x388b('0x1f')][_0x388b('0x20')]===0x1f4){logger[_0x388b('0x1f')](_0x388b('0x1a'),_0x123d77,_0x3afbe4[_0x388b('0x1f')][_0x388b('0x21')]);return _0x1b3071(_0x3afbe4[_0x388b('0x1f')][_0x388b('0x21')]);}logger[_0x388b('0x1f')](_0x388b('0x1a'),_0x123d77,_0x3afbe4[_0x388b('0x1f')][_0x388b('0x21')]);return _0x54d761(_0x3afbe4[_0x388b('0x1f')]['message']);}else{logger[_0x388b('0x22')](_0x388b('0x1a'),_0x123d77,'request\x20sent');_0x54d761(_0x3afbe4[_0x388b('0x23')][_0x388b('0x21')]);}})['catch'](function(_0x4aa28c){logger[_0x388b('0x1f')]('ChatWebsite,\x20%s,\x20%s',_0x123d77,_0x4aa28c);_0x1b3071(_0x4aa28c);});});}function respondWithStatusCode(_0x2c7b2d,_0x380f0f){_0x380f0f=_0x380f0f||0xcc;return function(_0x3c1e1f){if(_0x3c1e1f){return _0x2c7b2d[_0x388b('0x24')](_0x380f0f);}return _0x2c7b2d['status'](_0x380f0f)[_0x388b('0x25')]();};}function respondWithResult(_0x1d8d16,_0x168734){_0x168734=_0x168734||0xc8;return function(_0x2b1942){if(_0x2b1942){return _0x1d8d16[_0x388b('0x26')](_0x168734)['json'](_0x2b1942);}};}function respondWithFilteredResult(_0x111ed1,_0x4f2147){return function(_0x5d2284){if(_0x5d2284){var _0x4bd187=typeof _0x4f2147[_0x388b('0x27')]==='undefined'&&typeof _0x4f2147[_0x388b('0x28')]===_0x388b('0x29');var _0x31db60=_0x5d2284[_0x388b('0x2a')];var _0x36c0f3=_0x4bd187?0x0:_0x4f2147[_0x388b('0x27')];var _0x5855b4=_0x4bd187?_0x5d2284['count']:_0x4f2147[_0x388b('0x27')]+_0x4f2147[_0x388b('0x28')];var _0x56f7c2;if(_0x5855b4>=_0x31db60){_0x5855b4=_0x31db60;_0x56f7c2=0xc8;}else{_0x56f7c2=0xce;}_0x111ed1['status'](_0x56f7c2);return _0x111ed1[_0x388b('0x2b')](_0x388b('0x2c'),_0x36c0f3+'-'+_0x5855b4+'/'+_0x31db60)['json'](_0x5d2284);}return null;};}function saveUpdates(_0x544d27){return function(_0x3a6959){if(_0x3a6959){return _0x3a6959[_0x388b('0x2d')](_0x544d27)[_0x388b('0x19')](function(_0x3d55b3){return _0x3d55b3;});}return null;};}function removeEntity(_0xcf6463){return function(_0x28e6f6){if(_0x28e6f6){return _0x28e6f6[_0x388b('0x2e')]()[_0x388b('0x19')](function(){var _0x822ef2=_0x28e6f6['get']({'plain':!![]});var _0x7eaa1f='ChatWebsites';return db['UserProfileResource'][_0x388b('0x2e')]({'where':{'type':_0x7eaa1f,'resourceId':_0x822ef2['id']}})['then'](function(){return _0x28e6f6;});})[_0x388b('0x19')](function(){_0xcf6463[_0x388b('0x26')](0xcc)[_0x388b('0x25')]();});}};}function handleEntityNotFound(_0x56dd53){return function(_0xa1ae87){if(!_0xa1ae87){_0x56dd53[_0x388b('0x24')](0x194);}return _0xa1ae87;};}function handleError(_0x2a6bb5,_0x47b945){_0x47b945=_0x47b945||0x1f4;return function(_0x681863){logger[_0x388b('0x1f')](_0x681863[_0x388b('0x2f')]);if(_0x681863[_0x388b('0x30')]){delete _0x681863[_0x388b('0x30')];}_0x2a6bb5[_0x388b('0x26')](_0x47b945)[_0x388b('0x31')](_0x681863);};}function iftimePromise(_0x31727b,_0x35121e){return respondWithRpcPromise(_0x388b('0x32'),_0x388b('0x33'),{'command':_0x35121e[_0x388b('0x34')]?util['format'](_0x388b('0x35'),_0x31727b[_0x388b('0x36')],_0x35121e['timezone']):util['format']('iftime\x20%s',_0x31727b[_0x388b('0x36')])},client9002)[_0x388b('0x19')](function(_0x5260b0){var _0x21bbd2=_0x5260b0&&_0x5260b0[_0x388b('0x37')]('true')>=0x0?!![]:![];logger[_0x388b('0x22')](_0x388b('0x38'),_0x35121e['id'],_0x31727b['id'],_0x31727b[_0x388b('0x36')],_0x21bbd2?'ONLINE':'OFFLINE',_0x35121e['timezone']?_0x35121e[_0x388b('0x34')]:_0x388b('0x39'));return _0x21bbd2;})[_0x388b('0x3a')](function(_0x5bb798){logger[_0x388b('0x1f')](_0x388b('0x38'),_0x35121e['id'],_0x31727b['id'],_0x31727b[_0x388b('0x36')],util[_0x388b('0x3b')](_0x5bb798,{'showHidden':![],'depth':null}),_0x35121e[_0x388b('0x34')]?_0x35121e['timezone']:'No\x20timezone');return![];});}function checkWebsiteIntervals(_0x2b1d7b){var _0x2ae7f9=_[_0x388b('0x3c')](_0x2b1d7b['Interval']['Intervals'],function(_0x52dc0c){var _0x219fe9=_0x52dc0c[_0x388b('0x3d')]({'plain':!![]});return iftimePromise(_0x219fe9,_0x2b1d7b);});return Promise[_0x388b('0x3e')](_0x2ae7f9)[_0x388b('0x19')](function(_0x4352dd){return _[_0x388b('0x3f')](_0x4352dd);});}function createInteractionObject(_0xb0117b,_0x17be7a,_0x3b4dcd,_0x14fa62){var _0x4ac17a=require(_0x388b('0x40'));var _0x1555ca=new _0x4ac17a();var _0x1d39c1=_0x1555ca['setUA'](_0x3b4dcd[_0x388b('0x41')])['getResult']();var _0x5dcdc1=_0x17be7a[_0x388b('0x42')];if(_0x3b4dcd[_0x388b('0x43')]){_0x5dcdc1=_0x3b4dcd['cf-connecting-ip'];}else if(_0x3b4dcd[_0x388b('0x44')]){_0x5dcdc1=_['first'](_0x3b4dcd['x-forwarded-for'][_0x388b('0x45')](','));}return{'ContactId':_0x14fa62['id'],'ChatWebsiteId':_0xb0117b,'from':(_0x14fa62[_0x388b('0x46')]||'')+'\x20'+(_0x14fa62['lastName']||''),'customerIp':_0x5dcdc1,'customerPort':_0x3b4dcd[_0x388b('0x47')]?_0x3b4dcd['x-real-port']:null,'referer':_0x17be7a[_0x388b('0x48')],'browserName':_0x1d39c1[_0x388b('0x49')][_0x388b('0x30')]&&_0x1d39c1['browser'][_0x388b('0x4a')]?util['format'](_0x388b('0x4b'),_0x1d39c1['browser'][_0x388b('0x30')],_0x1d39c1[_0x388b('0x49')][_0x388b('0x4a')]):_0x388b('0x4c'),'browserVersion':_0x1d39c1[_0x388b('0x49')]['version']||_0x388b('0x4c'),'osName':util[_0x388b('0x4d')](_0x388b('0x4b'),_0x1d39c1['os'][_0x388b('0x30')],_0x1d39c1['os'][_0x388b('0x4a')]),'osVersion':_0x1d39c1['os'][_0x388b('0x4a')],'deviceModel':_0x1d39c1[_0x388b('0x4e')][_0x388b('0x4f')]&&_0x1d39c1[_0x388b('0x4e')]['vendor']?util[_0x388b('0x4d')](_0x388b('0x50'),_0x1d39c1[_0x388b('0x4e')][_0x388b('0x4f')],_0x1d39c1[_0x388b('0x4e')][_0x388b('0x51')],_0x1d39c1['device'][_0x388b('0x52')]):null,'deviceVendor':_0x1d39c1[_0x388b('0x4e')][_0x388b('0x51')],'deviceType':_0x1d39c1[_0x388b('0x4e')][_0x388b('0x52')],'formData':JSON[_0x388b('0x1e')](_0x17be7a)};}exports[_0x388b('0x53')]=function(_0x5948f9,_0x1d02f4){var _0xb2199d={'include':[{'model':db[_0x388b('0x54')],'as':_0x388b('0x55')}]},_0x35df25={},_0x723d3e={'count':0x0,'rows':[]};var _0x1e5cc2=_['map'](db[_0x388b('0x56')]['rawAttributes'],function(_0x22e318){return{'name':_0x22e318[_0x388b('0x57')],'type':_0x22e318['type']['key']};});_0x35df25[_0x388b('0x4f')]=_[_0x388b('0x3c')](_0x1e5cc2,_0x388b('0x30'));_0x35df25['query']=_[_0x388b('0x58')](_0x5948f9[_0x388b('0x59')]);_0x35df25[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x35df25['model'],_0x35df25[_0x388b('0x59')]);_0xb2199d[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x35df25[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x5948f9[_0x388b('0x59')][_0x388b('0x5d')]));_0xb2199d[_0x388b('0x5c')]=_0xb2199d[_0x388b('0x5c')][_0x388b('0x5e')]?_0xb2199d[_0x388b('0x5c')]:_0x35df25[_0x388b('0x4f')];if(!_0x5948f9[_0x388b('0x59')]['hasOwnProperty'](_0x388b('0x5f'))){_0xb2199d[_0x388b('0x28')]=qs['limit'](_0x5948f9[_0x388b('0x59')]['limit']);_0xb2199d[_0x388b('0x27')]=qs[_0x388b('0x27')](_0x5948f9['query'][_0x388b('0x27')]);}_0xb2199d[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x5948f9[_0x388b('0x59')][_0x388b('0x61')]);_0xb2199d[_0x388b('0x62')]=qs[_0x388b('0x5a')](_['pick'](_0x5948f9['query'],_0x35df25[_0x388b('0x5a')]),_0x1e5cc2);if(_0x5948f9['query'][_0x388b('0x63')]){_0xb2199d[_0x388b('0x62')]=_['merge'](_0xb2199d[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x1e5cc2,function(_0x96e162){if(_0x96e162[_0x388b('0x52')]!==_0x388b('0x64')){var _0x457c9a={};_0x457c9a[_0x96e162[_0x388b('0x30')]]={'$like':'%'+_0x5948f9[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x457c9a;}})});}_0xb2199d=_[_0x388b('0x65')]({},_0xb2199d,_0x5948f9[_0x388b('0x66')]);var _0x1e7f89={'where':_0xb2199d[_0x388b('0x62')]};return db['ChatWebsite']['count'](_0x1e7f89)[_0x388b('0x19')](function(_0x550bfb){_0x723d3e[_0x388b('0x2a')]=_0x550bfb;if(_0x5948f9['query'][_0x388b('0x67')]){_0xb2199d[_0x388b('0x68')]=[{'all':!![]}];}return db['ChatWebsite']['findAll'](_0xb2199d);})[_0x388b('0x19')](function(_0x21f683){_0x723d3e[_0x388b('0x69')]=_0x21f683;return _0x723d3e;})[_0x388b('0x19')](respondWithFilteredResult(_0x1d02f4,_0xb2199d))[_0x388b('0x3a')](handleError(_0x1d02f4,null));};exports[_0x388b('0x6a')]=function(_0x56f72b,_0x4906ad){var _0x550ef5={'raw':![],'where':{'id':_0x56f72b[_0x388b('0x6b')]['id']},'include':[{'model':db[_0x388b('0x54')],'as':_0x388b('0x55')}]},_0x4f5b3b={};_0x4f5b3b['model']=_[_0x388b('0x58')](db['ChatWebsite'][_0x388b('0x6c')]);_0x4f5b3b[_0x388b('0x59')]=_[_0x388b('0x58')](_0x56f72b['query']);_0x4f5b3b[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x4f5b3b[_0x388b('0x4f')],_0x4f5b3b[_0x388b('0x59')]);_0x550ef5[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x4f5b3b[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x56f72b[_0x388b('0x59')][_0x388b('0x5d')]));_0x550ef5[_0x388b('0x5c')]=_0x550ef5[_0x388b('0x5c')]['length']?_0x550ef5[_0x388b('0x5c')]:_0x4f5b3b[_0x388b('0x4f')];if(_0x56f72b[_0x388b('0x59')][_0x388b('0x67')]){_0x550ef5['include']=[{'all':!![]}];}_0x550ef5=_[_0x388b('0x65')]({},_0x550ef5,_0x56f72b[_0x388b('0x66')]);return db[_0x388b('0x56')]['find'](_0x550ef5)[_0x388b('0x19')](handleEntityNotFound(_0x4906ad,null))[_0x388b('0x19')](respondWithResult(_0x4906ad,null))[_0x388b('0x3a')](handleError(_0x4906ad,null));};exports[_0x388b('0x6d')]=function(_0x37b9f9,_0x486d1e){return db[_0x388b('0x56')][_0x388b('0x6d')](_0x37b9f9[_0x388b('0x6e')],{})['then'](function(_0x5f14af){var _0xf9c306=_0x37b9f9[_0x388b('0x6f')]['get']({'plain':!![]});if(!_0xf9c306)throw new Error(_0x388b('0x70'));if(_0xf9c306[_0x388b('0x71')]===_0x388b('0x6f')){var _0x49432a=_0x5f14af[_0x388b('0x3d')]({'plain':!![]});var _0x8fbf00=_0x388b('0x72');return db['UserProfileSection'][_0x388b('0x73')]({'where':{'name':_0x8fbf00,'userProfileId':_0xf9c306['userProfileId']},'raw':!![]})['then'](function(_0x3dd818){if(_0x3dd818&&_0x3dd818[_0x388b('0x74')]===0x0){return db['UserProfileResource'][_0x388b('0x6d')]({'name':_0x49432a[_0x388b('0x30')],'resourceId':_0x49432a['id'],'type':_0x3dd818['name'],'sectionId':_0x3dd818['id']},{})['then'](function(){return _0x5f14af;});}else{return _0x5f14af;}})[_0x388b('0x3a')](function(_0x5449f7){logger[_0x388b('0x1f')](_0x388b('0x75'),_0x5449f7);throw _0x5449f7;});}return _0x5f14af;})[_0x388b('0x19')](respondWithResult(_0x486d1e,0xc9))['catch'](handleError(_0x486d1e,null));};exports[_0x388b('0x2d')]=function(_0x298185,_0x9fb867){if(_0x298185[_0x388b('0x6e')]['id']){delete _0x298185['body']['id'];}return db['ChatWebsite'][_0x388b('0x73')]({'where':{'id':_0x298185[_0x388b('0x6b')]['id']},'include':[{'model':db[_0x388b('0x54')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x9fb867,null))[_0x388b('0x19')](saveUpdates(_0x298185[_0x388b('0x6e')],null))[_0x388b('0x19')](respondWithResult(_0x9fb867,null))[_0x388b('0x3a')](handleError(_0x9fb867,null));};exports[_0x388b('0x2e')]=function(_0x2398ec,_0x454bd9){return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x2398ec['params']['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x454bd9,null))[_0x388b('0x19')](removeEntity(_0x454bd9,null))[_0x388b('0x3a')](handleError(_0x454bd9,null));};exports[_0x388b('0x76')]=function(_0x281776,_0x4c98dd){return db[_0x388b('0x56')]['describe']()[_0x388b('0x19')](respondWithResult(_0x4c98dd,null))[_0x388b('0x3a')](handleError(_0x4c98dd,null));};exports[_0x388b('0x77')]=function(_0x2091aa,_0x4a6856){if(_0x2091aa[_0x388b('0x6e')]['id']){delete _0x2091aa[_0x388b('0x6e')]['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x2091aa[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x4a6856,null))[_0x388b('0x19')](function(_0x55fdcf){if(_0x55fdcf){_0x2091aa[_0x388b('0x6e')][_0x388b('0x78')]=_0x55fdcf['id'];return db[_0x388b('0x79')][_0x388b('0x6d')](_0x2091aa[_0x388b('0x6e')]);}})[_0x388b('0x19')](respondWithResult(_0x4a6856,null))[_0x388b('0x3a')](handleError(_0x4a6856,null));};exports[_0x388b('0x7a')]=function(_0x27ec9e,_0x5e1d57){var _0x59b2be={'raw':![],'where':{}};var _0x2e0cbe={};var _0x556596={'count':0x0,'rows':[]};return db[_0x388b('0x56')][_0x388b('0x7b')]({'where':{'id':_0x27ec9e[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x5e1d57,null))[_0x388b('0x19')](function(_0x465818){if(_0x465818){_0x2e0cbe[_0x388b('0x4f')]=_['keys'](db[_0x388b('0x79')][_0x388b('0x6c')]);_0x2e0cbe[_0x388b('0x59')]=_[_0x388b('0x58')](_0x27ec9e[_0x388b('0x59')]);_0x2e0cbe[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x2e0cbe[_0x388b('0x4f')],_0x2e0cbe[_0x388b('0x59')]);_0x59b2be['attributes']=_[_0x388b('0x5b')](_0x2e0cbe[_0x388b('0x4f')],qs['fields'](_0x27ec9e[_0x388b('0x59')][_0x388b('0x5d')]));_0x59b2be['attributes']=_0x59b2be[_0x388b('0x5c')][_0x388b('0x5e')]?_0x59b2be[_0x388b('0x5c')]:_0x2e0cbe['model'];if(!_0x27ec9e[_0x388b('0x59')][_0x388b('0x7c')](_0x388b('0x5f'))){_0x59b2be[_0x388b('0x28')]=qs['limit'](_0x27ec9e[_0x388b('0x59')]['limit']);_0x59b2be[_0x388b('0x27')]=qs[_0x388b('0x27')](_0x27ec9e[_0x388b('0x59')]['offset']);}_0x59b2be[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x27ec9e['query'][_0x388b('0x61')]);_0x59b2be[_0x388b('0x62')]=qs[_0x388b('0x5a')](_[_0x388b('0x7d')](_0x27ec9e[_0x388b('0x59')],_0x2e0cbe[_0x388b('0x5a')]));_0x59b2be['where'][_0x388b('0x78')]=_0x465818['id'];if(_0x27ec9e[_0x388b('0x59')][_0x388b('0x63')]){_0x59b2be[_0x388b('0x62')]=_[_0x388b('0x65')](_0x59b2be[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x59b2be['attributes'],function(_0xc080a0){var _0x195cc1={};_0x195cc1[_0xc080a0]={'$like':'%'+_0x27ec9e[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x195cc1;})});}_0x59b2be=_[_0x388b('0x65')]({},_0x59b2be,_0x27ec9e[_0x388b('0x66')]);return db['Disposition'][_0x388b('0x2a')]({'where':_0x59b2be[_0x388b('0x62')]})['then'](function(_0x525553){_0x556596['count']=_0x525553;if(_0x27ec9e[_0x388b('0x59')][_0x388b('0x67')]){_0x59b2be['include']=[{'all':!![]}];}return db[_0x388b('0x79')]['findAll'](_0x59b2be);})[_0x388b('0x19')](function(_0x2535fb){_0x556596[_0x388b('0x69')]=_0x2535fb;return _0x556596;});}})[_0x388b('0x19')](respondWithFilteredResult(_0x5e1d57,_0x59b2be))[_0x388b('0x3a')](handleError(_0x5e1d57,null));};exports['removeDispositions']=function(_0x9a674c,_0x106ef2){return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x9a674c['params']['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x106ef2,null))[_0x388b('0x19')](function(_0x62f2a4){if(_0x62f2a4){return _0x62f2a4[_0x388b('0x7e')](_0x9a674c['query']['ids']);}})[_0x388b('0x19')](respondWithStatusCode(_0x106ef2,null))[_0x388b('0x3a')](handleError(_0x106ef2,null));};exports['addAnswer']=function(_0x4bdd92,_0x399474){if(_0x4bdd92[_0x388b('0x6e')]['id']){delete _0x4bdd92[_0x388b('0x6e')]['id'];}return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x4bdd92[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x399474,null))[_0x388b('0x19')](function(_0x5867f0){if(_0x5867f0){_0x4bdd92[_0x388b('0x6e')]['ChatWebsiteId']=_0x5867f0['id'];return db[_0x388b('0x7f')]['create'](_0x4bdd92[_0x388b('0x6e')]);}})[_0x388b('0x19')](respondWithResult(_0x399474,null))[_0x388b('0x3a')](handleError(_0x399474,null));};exports[_0x388b('0x80')]=function(_0x207d0f,_0x538fe4){var _0x55f01f={'raw':![],'where':{}};var _0x1dbcfb={};var _0xf242f9={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x207d0f[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x538fe4,null))[_0x388b('0x19')](function(_0x3bbb30){if(_0x3bbb30){_0x1dbcfb['model']=_[_0x388b('0x58')](db[_0x388b('0x7f')]['rawAttributes']);_0x1dbcfb[_0x388b('0x59')]=_[_0x388b('0x58')](_0x207d0f[_0x388b('0x59')]);_0x1dbcfb[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x1dbcfb[_0x388b('0x4f')],_0x1dbcfb['query']);_0x55f01f[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x1dbcfb[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x207d0f[_0x388b('0x59')][_0x388b('0x5d')]));_0x55f01f[_0x388b('0x5c')]=_0x55f01f[_0x388b('0x5c')][_0x388b('0x5e')]?_0x55f01f[_0x388b('0x5c')]:_0x1dbcfb[_0x388b('0x4f')];if(!_0x207d0f[_0x388b('0x59')][_0x388b('0x7c')](_0x388b('0x5f'))){_0x55f01f[_0x388b('0x28')]=qs[_0x388b('0x28')](_0x207d0f[_0x388b('0x59')]['limit']);_0x55f01f[_0x388b('0x27')]=qs[_0x388b('0x27')](_0x207d0f['query'][_0x388b('0x27')]);}_0x55f01f[_0x388b('0x60')]=qs['sort'](_0x207d0f[_0x388b('0x59')]['sort']);_0x55f01f[_0x388b('0x62')]=qs[_0x388b('0x5a')](_['pick'](_0x207d0f[_0x388b('0x59')],_0x1dbcfb[_0x388b('0x5a')]));_0x55f01f['where'][_0x388b('0x78')]=_0x3bbb30['id'];if(_0x207d0f[_0x388b('0x59')][_0x388b('0x63')]){_0x55f01f[_0x388b('0x62')]=_[_0x388b('0x65')](_0x55f01f[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x55f01f[_0x388b('0x5c')],function(_0x33744b){var _0x53f77e={};_0x53f77e[_0x33744b]={'$like':'%'+_0x207d0f[_0x388b('0x59')]['filter']+'%'};return _0x53f77e;})});}_0x55f01f=_[_0x388b('0x65')]({},_0x55f01f,_0x207d0f[_0x388b('0x66')]);return db[_0x388b('0x7f')]['count']({'where':_0x55f01f[_0x388b('0x62')]})[_0x388b('0x19')](function(_0x48c684){_0xf242f9['count']=_0x48c684;if(_0x207d0f[_0x388b('0x59')][_0x388b('0x67')]){_0x55f01f[_0x388b('0x68')]=[{'all':!![]}];}return db[_0x388b('0x7f')]['findAll'](_0x55f01f);})['then'](function(_0x45ba1c){_0xf242f9['rows']=_0x45ba1c;return _0xf242f9;});}})[_0x388b('0x19')](respondWithFilteredResult(_0x538fe4,_0x55f01f))[_0x388b('0x3a')](handleError(_0x538fe4,null));};exports['removeAnswers']=function(_0x10dcb5,_0x472fad){return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x10dcb5[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x472fad,null))['then'](function(_0x39806d){if(_0x39806d){return _0x39806d[_0x388b('0x81')](_0x10dcb5[_0x388b('0x59')][_0x388b('0x82')]);}})[_0x388b('0x19')](respondWithStatusCode(_0x472fad,null))[_0x388b('0x3a')](handleError(_0x472fad,null));};exports[_0x388b('0x83')]=function(_0x1fc73c,_0x4a4cb5){_0x1fc73c[_0x388b('0x6e')][_0x388b('0x84')]=_0x1fc73c[_0x388b('0x85')]['filename'];return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x1fc73c[_0x388b('0x6b')]['id']}})['then'](handleEntityNotFound(_0x4a4cb5,null))['then'](saveUpdates(_0x1fc73c[_0x388b('0x6e')],null))['then'](respondWithResult(_0x4a4cb5,null))['catch'](handleError(_0x4a4cb5,null));};exports[_0x388b('0x86')]=function(_0x13f5f0,_0x7ce16f){_0x13f5f0[_0x388b('0x6e')]['agentAvatar']=_0x13f5f0[_0x388b('0x85')]['filename'];return db['ChatWebsite'][_0x388b('0x73')]({'where':{'id':_0x13f5f0[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x7ce16f,null))[_0x388b('0x19')](saveUpdates(_0x13f5f0['body'],null))[_0x388b('0x19')](respondWithResult(_0x7ce16f,null))[_0x388b('0x3a')](handleError(_0x7ce16f,null));};exports[_0x388b('0x87')]=function(_0x21f142,_0x49b4a1){_0x21f142[_0x388b('0x6e')][_0x388b('0x88')]=_0x21f142[_0x388b('0x85')][_0x388b('0x89')];return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x21f142[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x49b4a1,null))[_0x388b('0x19')](saveUpdates(_0x21f142[_0x388b('0x6e')],null))['then'](respondWithResult(_0x49b4a1,null))['catch'](handleError(_0x49b4a1,null));};exports[_0x388b('0x8a')]=function(_0x5d95c5,_0x3faca0){_0x5d95c5[_0x388b('0x6e')][_0x388b('0x8b')]=_0x5d95c5[_0x388b('0x85')][_0x388b('0x89')];return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x5d95c5[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x3faca0,null))['then'](saveUpdates(_0x5d95c5[_0x388b('0x6e')],null))[_0x388b('0x19')](respondWithResult(_0x3faca0,null))[_0x388b('0x3a')](handleError(_0x3faca0,null));};exports[_0x388b('0x8c')]=function(_0x2cce99,_0x69d385){var _0x3c4b01=path['join'](config[_0x388b('0x8d')],_0x388b('0x8e'));var _0x26b421={'where':{'id':_0x2cce99['params']['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x35fd42=![];return require('../../config/license/util')[_0x388b('0x8f')]()['then'](function(_0x2adb6b){if(_0x2adb6b){_0x35fd42=_0x2adb6b[_0x388b('0x90')];}})['then'](function(){return db[_0x388b('0x56')]['find'](_0x26b421);})[_0x388b('0x19')](handleEntityNotFound(_0x69d385,null))[_0x388b('0x19')](function(_0x5cb69e){if(_0x5cb69e){if(!_['isNil'](_0x5cb69e[_0x388b('0x84')])){if(fs['existsSync'](path['join'](config['root'],'server/files/images/logos/',_0x5cb69e[_0x388b('0x84')]))&&_0x35fd42){_0x3c4b01=path[_0x388b('0x91')](config['root'],'server/files/images/logos/',_0x5cb69e[_0x388b('0x84')]);}}return _0x69d385[_0x388b('0x92')](_0x3c4b01);}})[_0x388b('0x3a')](handleError(_0x69d385,null));};exports[_0x388b('0x93')]=function(_0x275ffe,_0x188d4a){var _0x4b71aa=path[_0x388b('0x91')](config['root'],'server/files/images/avatars/default_avatar.png');var _0x58552b={'where':{'id':_0x275ffe[_0x388b('0x6b')]['id']},'attributes':['id',_0x388b('0x94')],'raw':!![]};return db[_0x388b('0x56')]['find'](_0x58552b)[_0x388b('0x19')](handleEntityNotFound(_0x188d4a,null))['then'](function(_0x28d75e){if(_0x28d75e){if(!_['isNil'](_0x28d75e[_0x388b('0x94')])){if(fs['existsSync'](path[_0x388b('0x91')](config[_0x388b('0x8d')],'server/files/images/avatars/',_0x28d75e['agentAvatar']))){_0x4b71aa=path['join'](config['root'],_0x388b('0x95'),_0x28d75e[_0x388b('0x94')]);}}return _0x188d4a['download'](_0x4b71aa);}})['catch'](handleError(_0x188d4a,null));};exports[_0x388b('0x96')]=function(_0x54226f,_0x305b48){var _0x417ceb=path[_0x388b('0x91')](config[_0x388b('0x8d')],_0x388b('0x97'));var _0x4bb03b={'where':{'id':_0x54226f[_0x388b('0x6b')]['id']},'attributes':['id',_0x388b('0x88'),_0x388b('0x98')],'raw':!![]};return db[_0x388b('0x56')]['find'](_0x4bb03b)[_0x388b('0x19')](handleEntityNotFound(_0x305b48,null))['then'](function(_0x48d597){if(_0x48d597){if(!_[_0x388b('0x99')](_0x48d597[_0x388b('0x88')])){if(fs[_0x388b('0x9a')](path[_0x388b('0x91')](config[_0x388b('0x8d')],'server/files/images/avatars/',_0x48d597[_0x388b('0x88')]))&&_0x48d597[_0x388b('0x98')]){_0x417ceb=path[_0x388b('0x91')](config[_0x388b('0x8d')],_0x388b('0x95'),_0x48d597[_0x388b('0x88')]);}}return _0x305b48[_0x388b('0x92')](_0x417ceb);}})[_0x388b('0x3a')](handleError(_0x305b48,null));};exports['getSystemAvatar']=function(_0x29d1bc,_0x261038){var _0xac028c=path[_0x388b('0x91')](config['root'],_0x388b('0x9b'));var _0x40ac6f={'where':{'id':_0x29d1bc[_0x388b('0x6b')]['id']},'attributes':['id',_0x388b('0x8b')],'raw':!![]};return db['ChatWebsite'][_0x388b('0x73')](_0x40ac6f)[_0x388b('0x19')](handleEntityNotFound(_0x261038,null))['then'](function(_0x2aaf95){if(_0x2aaf95){if(!_[_0x388b('0x99')](_0x2aaf95[_0x388b('0x8b')])){if(fs[_0x388b('0x9a')](path[_0x388b('0x91')](config['root'],_0x388b('0x95'),_0x2aaf95['systemAvatar']))){_0xac028c=path['join'](config['root'],'server/files/images/avatars/',_0x2aaf95[_0x388b('0x8b')]);}}return _0x261038[_0x388b('0x92')](_0xac028c);}})['catch'](handleError(_0x261038,null));};exports[_0x388b('0x9c')]=function(_0x459184,_0x22d3e6){var _0xbffb73={'body':_0x459184[_0x388b('0x6e')],'channel':_0x388b('0x9d')};var _0x32d7c4=[];var _0x178439=[];var _0x3a65d7={};var _0x596b4a=![];return db[_0x388b('0x9e')][_0x388b('0x76')]()[_0x388b('0x19')](function(_0x5480fb){if(!_0x5480fb){throw new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))]('no\x20available\x20attributes');}_0x32d7c4=_[_0x388b('0xa1')](_[_0x388b('0x58')](_0x5480fb),[_0x388b('0xa2'),'updatedAt']);_0x178439=_[_0x388b('0xa1')](_[_0x388b('0x58')](_0x5480fb),[_0x388b('0xa2'),_0x388b('0xa3'),'CompanyId','ListId']);if(_0x459184['body']['id']){delete _0x459184[_0x388b('0x6e')]['id'];}if(_[_0x388b('0x99')](_0x459184['body']['from'])){throw new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xa4'));}if(_[_0x388b('0x99')](_0x459184[_0x388b('0x6e')][_0x388b('0x6e')])||_0x459184[_0x388b('0x6e')][_0x388b('0x6e')]===''){throw new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xa5'));}if(_[_0x388b('0x99')](_0x459184[_0x388b('0x6e')][_0x388b('0xa6')])){throw new db['Sequelize'][(_0x388b('0xa0'))](_0x388b('0xa7')+_0x178439);}if(!_[_0x388b('0xa8')](_0x178439,_0x459184['body'][_0x388b('0xa6')])){throw new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xa9')+_0x178439);}_0x3a65d7[_0x459184[_0x388b('0x6e')][_0x388b('0xa6')]]=_0x459184[_0x388b('0x6e')][_0x388b('0xaa')];})[_0x388b('0x19')](function(){return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0x459184['params']['id']},'include':[{'model':db[_0x388b('0xab')],'as':_0x388b('0xac'),'include':[{'model':db[_0x388b('0x9e')],'as':_0x388b('0xad'),'where':_0x3a65d7,'limit':0x1,'order':[[_0x388b('0xa3'),'DESC']]}]},{'model':db[_0x388b('0xae')],'as':_0x388b('0xaf')},{'model':db[_0x388b('0xb0')],'as':_0x388b('0xb0'),'include':[{'model':db[_0x388b('0xb0')],'as':_0x388b('0xb1'),'attributes':['id',_0x388b('0x36')],'raw':!![]}]}]});})['then'](function(_0x38fc8d){if(!_0x38fc8d)throw new APINotFoundError(util['format']('Chat\x20Website\x20with\x20id\x20%s\x20not\x20found',_0x459184[_0x388b('0x6b')]['id']));if(!_0x38fc8d[_0x388b('0xb0')]||!_0x38fc8d[_0x388b('0xb0')][_0x388b('0xb1')])return[_0x38fc8d,!![]];return[_0x38fc8d,checkWebsiteIntervals(_0x38fc8d)];})['spread'](function(_0x4d0cc8,_0x22b2d6){if(!_0x22b2d6)throw new APIOutOfIntervalError();if(!_0x4d0cc8[_0x388b('0xac')])return;_0xbffb73[_0x388b('0xb2')]=_0x4d0cc8;_0xbffb73['list']=_0x4d0cc8['List'];_0xbffb73[_0x388b('0xb3')]=_[_0x388b('0xb4')](_0x4d0cc8[_0x388b('0xaf')],[_0x388b('0xb5')],[_0x388b('0xb6')]);if(_0xbffb73[_0x388b('0xb2')][_0x388b('0xaf')]){delete _0xbffb73[_0x388b('0xb2')][_0x388b('0xaf')];}if(_0xbffb73[_0x388b('0xb2')]['List']&&_0xbffb73[_0x388b('0xb2')]['List']['Contacts'][_0x388b('0x5e')]){return _0xbffb73[_0x388b('0xb2')][_0x388b('0xac')]['Contacts'][0x0];}var _0x5f4bbf=_[_0x388b('0x12')](_0x459184[_0x388b('0x6e')],{'firstName':_0x459184[_0x388b('0x6e')]['from'],'ListId':_0x4d0cc8[_0x388b('0xb7')]});_0x5f4bbf[_0x459184[_0x388b('0x6e')]['mapKey']]=_0x459184[_0x388b('0x6e')][_0x388b('0xaa')];return db[_0x388b('0x9e')][_0x388b('0x6d')](_0x5f4bbf,{'fields':_0x32d7c4,'raw':!![]});})[_0x388b('0x19')](function(_0x5c32c4){_0xbffb73[_0x388b('0xb8')]=_0x5c32c4;var _0x1ac952=createInteractionObject(_0x459184[_0x388b('0x6b')]['id'],_0x459184['body'],_0x459184[_0x388b('0xb9')],_0x5c32c4);var _0x330a30={'ChatWebsiteId':_0x459184[_0x388b('0x6b')]['id'],'closed':![]};if(_0x459184[_0x388b('0x6e')][_0x388b('0xba')]){_0x330a30[_0x388b('0xba')]=_0x459184[_0x388b('0x6e')][_0x388b('0xba')];return db[_0x388b('0xbb')][_0x388b('0x73')]({'where':_0x330a30})[_0x388b('0x19')](function(_0x14d0c1){if(_0x14d0c1){_0x596b4a=!![];return _0x14d0c1;}_0x1ac952[_0x388b('0xba')]=_0x459184[_0x388b('0x6e')]['threadId'];_0x1ac952[_0x388b('0xbc')]=_0x459184['body'][_0x388b('0xbc')];return db[_0x388b('0xbb')][_0x388b('0x6d')](_0x1ac952);});}_0x330a30[_0x388b('0xbd')]=_0x5c32c4['id'];if(_0x459184[_0x388b('0x6e')][_0x388b('0xbe')]&&_0x459184['body'][_0x388b('0xbe')]['id']){_0x330a30['id']=_0x459184[_0x388b('0x6e')][_0x388b('0xbe')]['id'];return db[_0x388b('0xbb')]['find']({'where':_0x330a30})['then'](function(_0x35454b){if(_0x35454b){_0x596b4a=!![];return _0x35454b;}return db[_0x388b('0xbb')][_0x388b('0x6d')](_0x1ac952);});}return db['ChatInteraction'][_0x388b('0x6d')](_0x1ac952);})['then'](function(_0x441c27){if(!_0x596b4a)return _0x441c27;var _0x46ec2b={'from':(_0xbffb73[_0x388b('0xb8')][_0x388b('0x46')]||'')+'\x20'+(_0xbffb73[_0x388b('0xb8')][_0x388b('0xbf')]||'')};if(_0x459184[_0x388b('0x6e')][_0x388b('0xba')]&&_0x459184[_0x388b('0x6e')][_0x388b('0xc0')]&&_0x459184[_0x388b('0x6e')][_0x388b('0xba')]!=_0x459184['body']['messageId']){_0x46ec2b[_0x388b('0xba')]=_0x459184[_0x388b('0x6e')][_0x388b('0xc0')];}return _0x441c27[_0x388b('0x2d')](_0x46ec2b);})[_0x388b('0x19')](function(_0x4a8a73){_0xbffb73[_0x388b('0xbe')]=_0x4a8a73[_0x388b('0x3d')]({'plain':!![]});_0xbffb73['interaction'][_0x388b('0xc1')]=!_0x596b4a;if(_0xbffb73[_0x388b('0xbe')][_0x388b('0xc1')]){if(_0xbffb73['account']['autoclose']){_0xbffb73[_0x388b('0xb3')]['push']({'id':0x0,'priority':_0xbffb73['applications'][_0x388b('0x5e')]+0x1,'app':_0x388b('0xc2'),'appdata':_0x388b('0xc3'),'interval':_0x388b('0xc4')});}}return db[_0x388b('0xc5')][_0x388b('0x6d')]({'body':_0x459184['body'][_0x388b('0x6e')],'ChatWebsiteId':_0x459184[_0x388b('0x6b')]['id'],'ChatInteractionId':_0x4a8a73['id'],'direction':'in','ContactId':_0xbffb73[_0x388b('0xb8')]['id'],'AttachmentId':_0x459184[_0x388b('0x6e')][_0x388b('0xc6')]});})['then'](function(_0x73c13b){_0xbffb73[_0x388b('0x21')]=_0x73c13b;if(!_0xbffb73[_0x388b('0xbe')][_0x388b('0xc7')]){return;}return db['User'][_0x388b('0x73')]({'attributes':['id',_0x388b('0x30')],'where':{'id':_0xbffb73[_0x388b('0xbe')][_0x388b('0xc7')]}});})[_0x388b('0x19')](function(_0x4c70e4){if(_0x4c70e4){_0xbffb73['applications'][_0x388b('0xc8')]({'id':0x0,'priority':0x0,'app':_0x388b('0xc9'),'appdata':_0x4c70e4['name']+','+(_0xbffb73['account'][_0x388b('0xca')]||0xa),'interval':_0x388b('0xc4')});_0xbffb73[_0x388b('0xcb')]=!![];}if(!_0xbffb73['interaction'][_0x388b('0xcc')]){return;}return db[_0x388b('0xcd')][_0x388b('0x73')]({'attributes':['id',_0x388b('0x30')],'where':{'id':_0xbffb73[_0x388b('0xbe')][_0x388b('0xcc')]}});})['then'](function(_0xf04731){if(_0xf04731){_0xbffb73['applications'][_0x388b('0xc8')]({'id':0x0,'priority':0x1,'app':_0x388b('0xce'),'appdata':_0xf04731[_0x388b('0x30')]+','+(_0xbffb73[_0x388b('0xb2')]['waitForTheAssignedQueue']||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise('Start',_0x388b('0xcf'),_0xbffb73);})[_0x388b('0x19')](function(_0x32ecd1){respondWithRpcPromise('EventManager',_0x388b('0xd0'),{'event':_0x388b('0x9c'),'message':_0x32ecd1},client9002);return _0x32ecd1;})[_0x388b('0x19')](respondWithResult(_0x22d3e6,null))[_0x388b('0x3a')](APIHandleError(_0x22d3e6));};exports[_0x388b('0xd1')]=function(_0xe0da4e,_0x12b5b5){var _0x44260d,_0x30ceed,_0xdc7027;var _0x5cc823=[];var _0x45150f={};var _0x402c16=_0xe0da4e[_0x388b('0xd2')]||[];var _0xe485ee=[];var _0x2cd440;return db[_0x388b('0x9e')]['describe']()[_0x388b('0x19')](function(_0x1b087d){if(!_0x1b087d){throw new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xd3'));}_0x5cc823=_[_0x388b('0xa1')](_[_0x388b('0x58')](_0x1b087d),['createdAt',_0x388b('0xa3'),'CompanyId',_0x388b('0xb7')]);if(_0xe0da4e[_0x388b('0x6e')]['id']){delete _0xe0da4e[_0x388b('0x6e')]['id'];}if(_[_0x388b('0x99')](_0xe0da4e[_0x388b('0x6e')][_0x388b('0xaa')])){throw _0x12b5b5[_0x388b('0x26')](0x1f4)[_0x388b('0x31')](new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xa4')));}if(_[_0x388b('0x99')](_0xe0da4e[_0x388b('0x6e')][_0x388b('0x6e')])||_0xe0da4e[_0x388b('0x6e')][_0x388b('0x6e')]===''){throw _0x12b5b5[_0x388b('0x26')](0x1f4)[_0x388b('0x31')](new db[(_0x388b('0x9f'))]['ValidationError'](_0x388b('0xa5')));}if(_[_0x388b('0x99')](_0xe0da4e[_0x388b('0x6e')][_0x388b('0xd4')])){throw _0x12b5b5[_0x388b('0x26')](0x1f4)[_0x388b('0x31')](new db[(_0x388b('0x9f'))][(_0x388b('0xa0'))](_0x388b('0xd5')+_0x5cc823));}if(!_[_0x388b('0xa8')](_0x5cc823,_0xe0da4e[_0x388b('0x6e')][_0x388b('0xd4')])){throw _0x12b5b5['status'](0x1f4)[_0x388b('0x31')](new db[(_0x388b('0x9f'))]['ValidationError'](_0x388b('0xd6')+_0x5cc823));}_0x45150f[_0xe0da4e['body'][_0x388b('0xd4')]]=_0xe0da4e[_0x388b('0x6e')]['from'];})['then'](function(){return db[_0x388b('0x56')][_0x388b('0x73')]({'where':{'id':_0xe0da4e[_0x388b('0x6b')]['id']},'include':[{'model':db['CmList'],'as':_0x388b('0xac')},{'model':db['MailAccount'],'as':_0x388b('0xd7')}]});})[_0x388b('0x19')](handleEntityNotFound(_0x12b5b5,null))['then'](function(_0x5d4866){if(_0x5d4866&&_0x5d4866[_0x388b('0xac')]){_0x30ceed=_0x5d4866;var _0x3bb1ad=_[_0x388b('0x12')](_0xe0da4e[_0x388b('0x6e')],{'firstName':_0xe0da4e[_0x388b('0x6e')]['from'],'phone':_0xe0da4e['body']['from'],'ListId':_0x5d4866[_0x388b('0xb7')]});_0x3bb1ad[_0xe0da4e[_0x388b('0x6e')]['mapKeyOffline']]=_0xe0da4e[_0x388b('0x6e')][_0x388b('0xaa')];return db['CmContact'][_0x388b('0xd8')]({'where':_0x45150f,'defaults':_0x3bb1ad});}})[_0x388b('0xd9')](function(_0xb94cb9){if(_0xb94cb9){_0xdc7027=_0xb94cb9;var _0x4a29c5=fs[_0x388b('0xda')](path[_0x388b('0x91')](config[_0x388b('0x8d')],_0x388b('0xdb')),_0x388b('0xdc'));var _0x2498ae=ejs[_0x388b('0xdd')](_0x4a29c5,{'body':_[_0x388b('0xde')](_0xe0da4e['body'][_0x388b('0x6e')]),'bodyTitle':_0x30ceed[_0x388b('0xdf')]});return db[_0x388b('0xe0')][_0x388b('0x6d')]({'body':_0x2498ae,'plainBody':htmlToText['fromString'](_0x2498ae),'ContactId':_0xb94cb9['id'],'ChatWebsiteId':_0x30ceed['id']});}})[_0x388b('0x19')](function(_0x1f6d63){_0x2cd440=_0x1f6d63;if(_0x402c16['length']){var _0x3cc5e7=_0x402c16['map'](function(_0x5a856b){return{'name':_0x5a856b['originalname'],'basename':_0x5a856b[_0x388b('0x89')],'type':_0x5a856b[_0x388b('0xe1')],'ChatOfflineMessageId':_0x1f6d63['id']};});_0xe485ee=_0x3cc5e7[_0x388b('0x3c')](_0x58f2ed=>{var _0x1bd2b0={'filename':_0x58f2ed[_0x388b('0x30')],'path':path['join'](config[_0x388b('0x8d')],_0x388b('0xe2'),_0x388b('0xd2'),_0x388b('0xe3'),_0x388b('0xe4'),_0x58f2ed['basename'])};return _0x1bd2b0;});if(!_0x30ceed[_0x388b('0xe5')]){return db['sequelize'][_0x388b('0xe6')](function(_0x31d93b){return db[_0x388b('0xe7')][_0x388b('0xe8')](_0x3cc5e7,{'transaction':_0x31d93b});});}}})['then'](function(){if(_0x2cd440){_0x44260d=_0x2cd440;return db[_0x388b('0xd7')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x388b('0xe9')],'as':_0x388b('0xea'),'raw':!![],'include':[{'model':db[_0x388b('0xeb')],'as':_0x388b('0xeb'),'raw':!![]}]}]});}})[_0x388b('0x19')](function(_0x2035a7){if(_0x2035a7&&_0x2035a7[_0x388b('0xea')]&&_0x30ceed[_0x388b('0xec')]&&_0x30ceed['forwardOfflineAddress']){var _0x50f465=_0x2035a7[_0x388b('0xed')]();return respondWithRpcPromise(_0x388b('0xee'),_0x388b('0xef'),{'account':_0x50f465,'message':{'from':util[_0x388b('0x4d')]('\x22%s\x22\x20<%s>',_0x2035a7[_0x388b('0x30')],_0x2035a7[_0x388b('0xf0')]||_0x2035a7[_0x388b('0xea')][_0x388b('0x6f')]),'to':_0x30ceed[_0x388b('0xf1')],'subject':_0x30ceed[_0x388b('0xf2')],'html':_0x44260d[_0x388b('0x6e')],'attachments':_0xe485ee}},client9003)[_0x388b('0x19')](function(){return _0x44260d;})[_0x388b('0x3a')](function(_0x25d497){logger[_0x388b('0x1f')](_0x25d497);});}})[_0x388b('0x19')](function(){if(_0x30ceed&&_0x30ceed[_0x388b('0xe5')]&&_0x30ceed['MailAccountId']){var _0x2d10fc=[];if(_0x402c16[_0x388b('0x5e')]){_0x2d10fc=_0x402c16[_0x388b('0x3c')](function(_0x2ce104){return{'name':_0x2ce104[_0x388b('0xf3')],'basename':_0x2ce104[_0x388b('0x89')],'type':_0x2ce104[_0x388b('0xe1')],'ChatOfflineMessageId':_0x2cd440['id']};});}var _0xcf242a;if(!_[_0x388b('0x99')](_0x30ceed['subjectOffline'])){var _0x50ecb4=_['map'](_0xe0da4e['body'],function(_0x559c30){return _0x559c30;});var _0x1d966f=_[_0x388b('0xf4')](_0x50ecb4)[0x0];var _0x3b34df=_[_0x388b('0xf5')](_0x1d966f,function(_0x5ac974){return _0x5ac974;});_0xcf242a=_0x3b34df[0x1][_0x30ceed[_0x388b('0xf6')]];}var _0x567532={'from':_0xdc7027[_0x388b('0xf0')],'firstName':_0xdc7027[_0x388b('0x46')],'lastName':_0xdc7027[_0x388b('0xbf')],'mapKey':'email','message':{'from':_0xdc7027[_0x388b('0xf0')],'to':_0x30ceed['MailAccount']['email'],'cc':'','subject':_[_0x388b('0x99')](_0xcf242a)?_0x30ceed[_0x388b('0xf2')]:_0xcf242a,'messageId':'','sentAt':new Date(),'attach':_0x2d10fc[_0x388b('0x5e')],'attachments':_0x2d10fc,'originChannel':'Chat','ChatWebsiteId':_0x30ceed['id'],'ChatOfflineMessageId':_0x44260d['id'],'originTo':_0x30ceed['MailAccount'][_0x388b('0xf0')]},'body':_0x44260d[_0x388b('0x6e')]};var _0x44fdab={'account':{'id':_0x30ceed[_0x388b('0xf7')]},'body':_0x567532,'log':_0x388b('0xf8')};return respondWithRpcPromise(_0x388b('0xf8'),_0x388b('0xf9'),_0x44fdab,client9001)[_0x388b('0x19')](function(){return _0x44260d;})[_0x388b('0x3a')](function(_0x3b3f8a){logger[_0x388b('0x1f')](_0x3b3f8a);});}return;})['then'](function(){if(_0x44260d){return _0x44260d;}})[_0x388b('0x19')](respondWithResult(_0x12b5b5,null))['catch'](function(){for(var _0x389e5c of _0x402c16){var _0x370b99=path[_0x388b('0x91')](config[_0x388b('0x8d')],_0x388b('0xe2'),_0x388b('0xd2'),_0x388b('0xe3'),'offline-chat',_0x389e5c[_0x388b('0x89')]);fs_extra[_0x388b('0xfa')](_0x370b99)[_0x388b('0x3a')](function(_0x4c74f7){logger[_0x388b('0x1f')](_0x388b('0xfb'),_0x370b99,_0x4c74f7);});}});};exports[_0x388b('0xfc')]=function(_0x1064f8,_0x2e070a){return db[_0x388b('0xbb')][_0x388b('0x73')]({'where':{'id':_0x1064f8[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x2e070a,null))[_0x388b('0x19')](function(_0x29039b){if(_0x29039b){return _0x29039b[_0x388b('0xfc')](_0x1064f8['body'][_0x388b('0x82')],_[_0x388b('0xfd')](_0x1064f8[_0x388b('0x6e')],[_0x388b('0x82'),'id'])||{});}})['then'](respondWithResult(_0x2e070a,null))['catch'](handleError(_0x2e070a,null));};exports[_0x388b('0xfe')]=function(_0x32f176,_0x257114){var _0x13bcf2={'raw':![],'where':{}};var _0x46aaf4={};var _0x9b3879={'count':0x0,'rows':[]};return db[_0x388b('0x56')][_0x388b('0x7b')]({'where':{'id':_0x32f176[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x257114,null))[_0x388b('0x19')](function(_0x4e7c9d){if(_0x4e7c9d){_0x46aaf4[_0x388b('0x4f')]=_['keys'](db['ChatInteraction']['rawAttributes']);_0x46aaf4['query']=_[_0x388b('0x58')](_0x32f176[_0x388b('0x59')]);_0x46aaf4['filters']=_[_0x388b('0x5b')](_0x46aaf4['model'],_0x46aaf4[_0x388b('0x59')]);_0x13bcf2['attributes']=_[_0x388b('0x5b')](_0x46aaf4['model'],qs[_0x388b('0x5d')](_0x32f176[_0x388b('0x59')]['fields']));_0x13bcf2[_0x388b('0x5c')]=_0x13bcf2[_0x388b('0x5c')]['length']?_0x13bcf2['attributes']:_0x46aaf4[_0x388b('0x4f')];if(!_0x32f176['query'][_0x388b('0x7c')](_0x388b('0x5f'))){_0x13bcf2[_0x388b('0x28')]=qs[_0x388b('0x28')](_0x32f176['query'][_0x388b('0x28')]);_0x13bcf2['offset']=qs[_0x388b('0x27')](_0x32f176[_0x388b('0x59')][_0x388b('0x27')]);}_0x13bcf2[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x32f176[_0x388b('0x59')][_0x388b('0x61')]);_0x13bcf2[_0x388b('0x62')]=qs[_0x388b('0x5a')](_[_0x388b('0x7d')](_0x32f176['query'],_0x46aaf4[_0x388b('0x5a')]));_0x13bcf2[_0x388b('0x62')][_0x388b('0x78')]=_0x4e7c9d['id'];if(_0x32f176[_0x388b('0x59')]['filter']){_0x13bcf2[_0x388b('0x62')]=_[_0x388b('0x65')](_0x13bcf2[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x13bcf2['attributes'],function(_0x4035d9){var _0x27b320={};_0x27b320[_0x4035d9]={'$like':'%'+_0x32f176[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x27b320;})});}_0x13bcf2=_[_0x388b('0x65')]({},_0x13bcf2,_0x32f176['options']);return db[_0x388b('0xbb')][_0x388b('0x2a')]({'where':_0x13bcf2[_0x388b('0x62')]})['then'](function(_0x24ec04){_0x9b3879[_0x388b('0x2a')]=_0x24ec04;if(_0x32f176[_0x388b('0x59')][_0x388b('0x67')]){_0x13bcf2[_0x388b('0x68')]=[{'model':db['CmContact'],'as':_0x388b('0xff'),'required':![]},{'model':db[_0x388b('0x100')],'as':_0x388b('0x101'),'attributes':[_0x388b('0x30'),'fullname','internal'],'required':![]},{'model':db[_0x388b('0x102')],'as':_0x388b('0x103'),'attributes':['id',_0x388b('0x30'),_0x388b('0x104')],'where':_0x32f176[_0x388b('0x59')][_0x388b('0x105')]?{'id':_0x32f176[_0x388b('0x59')]['tag']}:undefined,'required':_0x32f176[_0x388b('0x59')][_0x388b('0x105')]?!![]:![]}];}return db[_0x388b('0xbb')][_0x388b('0x106')](_0x13bcf2);})['then'](function(_0x58151c){_0x9b3879[_0x388b('0x69')]=_0x58151c;return _0x9b3879;});}})[_0x388b('0x19')](respondWithFilteredResult(_0x257114,_0x13bcf2))['catch'](handleError(_0x257114,null));};exports[_0x388b('0x33')]=function(_0x1ccd61,_0x5dc0bc){var _0x3a96f5=0x0;var _0x553d6b=0x0;var _0x2b8ec9=![];var _0x363266;var _0x44a7fc;return db['ChatWebsite'][_0x388b('0x73')]({'where':{'id':_0x1ccd61['params']['id']},'include':[{'model':db[_0x388b('0xb0')],'as':'Interval','include':[{'model':db[_0x388b('0xb0')],'as':_0x388b('0xb1'),'attributes':['id',_0x388b('0x36')]}]}]})[_0x388b('0x19')](handleEntityNotFound(_0x5dc0bc,null))[_0x388b('0x19')](function(_0x3df634){if(_0x3df634){_0x363266=_0x3df634;return _0x3df634[_0x388b('0x107')]({'raw':!![]});}})[_0x388b('0x19')](function(_0x158b27){if(_0x363266){if(_0x158b27){_0x44a7fc=_0x158b27;}}return require(_0x388b('0x108'))[_0x388b('0x8f')]();})[_0x388b('0x19')](function(_0x4534ec){if(_0x4534ec){_0x553d6b=_0x4534ec['virtual'];_0x2b8ec9=_0x4534ec[_0x388b('0x90')];}})[_0x388b('0x19')](function(){return db[_0x388b('0xbb')][_0x388b('0x2a')]({'where':{'closed':![]}});})[_0x388b('0x19')](function(_0x8e8dc2){_0x3a96f5=_0x8e8dc2;if(_0x553d6b&&_0x8e8dc2>_0x553d6b){return db['License'][_0x388b('0x7b')]({'where':{'id':0x1}})[_0x388b('0x19')](function(_0x1569ca){if(_0x1569ca){_0x1569ca['increment'](_0x388b('0x109'));}});}})[_0x388b('0x19')](function(){if(!_0x363266['Interval']||!_0x363266['Interval'][_0x388b('0xb1')])return!![];return checkWebsiteIntervals(_0x363266);})[_0x388b('0x19')](function(_0x97cd3d){var _0x4955a7=fs[_0x388b('0xda')](path['join'](config[_0x388b('0x8d')],'server/files/chat/iframe.ejs'),'utf8');var _0x5ec9b4=new url[(_0x388b('0x10a'))](_0x363266['address'])['origin'];var _0x13a852=_0x388b('0x10b');var _0x2af9f3=![];var _0x42e41e={'chatVersion':_0x13a852,'chatWebsiteAddressOrigin':_0x5ec9b4,'remote':_0x363266[_0x388b('0x10c')],'query':querystring[_0x388b('0x1e')](_[_0x388b('0x65')](_0x363266[_0x388b('0x3d')]({'plain':!![]}),{'customerIp':_0x1ccd61['headers']['x-forwarded-for']||_0x1ccd61[_0x388b('0xb9')]['x-real-ip']||_0x1ccd61[_0x388b('0x10d')][_0x388b('0x10e')]||_0x1ccd61['ip'],'referer':_0x1ccd61[_0x388b('0xb9')][_0x388b('0x48')],'openedInteractions':_0x3a96f5,'maxInteractions':_0x553d6b,'virtual':_0x2b8ec9[_0x388b('0x10f')],'online':_0x97cd3d,'custom':_0x2b8ec9}))[_0x388b('0x110')](/'/g,'\x5c\x27')};_0x5dc0bc['send'](ejs['render'](Mustache['render'](_0x4955a7,_0x42e41e),{'proactiveActions':_0x44a7fc,'alignment':_0x363266[_0x388b('0x111')],'verticalAlignment':_0x363266[_0x388b('0x112')],'div_color':_0x363266['color'],'labelText':_0x363266['labelText'],'text_color':_0x363266['textColor'],'text_button_color':_0x363266[_0x388b('0x113')],'button_color':_0x363266['color_button'],'background_color':_0x363266['backgroundColor'],'hideWhenOffline':_0x363266[_0x388b('0x114')],'intervalId':_0x363266['IntervalId'],'isDevelopment':_0x2af9f3,'chatVersion':_0x13a852}));})[_0x388b('0x3a')](handleError(_0x5dc0bc,null));};exports['addApplications']=function(_0x77713c,_0x124b1c){var _0x3a4c17=_0x77713c[_0x388b('0x6b')]['id'];var _0x40bea8=_0x77713c[_0x388b('0x6e')];var _0x50bc31=0xc8;var _0xfacb86=null;return db[_0x388b('0x115')][_0x388b('0xe6')]({'isolationLevel':db[_0x388b('0x115')][_0x388b('0x116')][_0x388b('0x117')][_0x388b('0x118')]},function(_0x2f8733){return db[_0x388b('0x56')]['findOne']({'where':{'id':_0x3a4c17},'transaction':_0x2f8733})[_0x388b('0x19')](function(_0x299e01){if(_0x299e01){return db[_0x388b('0xae')][_0x388b('0x2e')]({'where':{'ChatWebsiteId':_0x3a4c17},'transaction':_0x2f8733})['then'](function(){var _0x73f86c=_[_0x388b('0x3c')](_0x40bea8,function(_0x58d159){_0x58d159[_0x388b('0x78')]=_0x3a4c17;return _0x58d159;});return db[_0x388b('0xae')][_0x388b('0xe8')](_0x73f86c,{'transaction':_0x2f8733});});}else{_0x50bc31=0x194;_0xfacb86=[];}});})[_0x388b('0x19')](function(){if(_0x50bc31!==0x194){return db[_0x388b('0xae')][_0x388b('0x119')]({'where':{'ChatWebsiteId':_0x3a4c17},'order':_0x388b('0xb5')})['then'](function(_0x2f58e9){_0xfacb86=_0x2f58e9;});}})['catch'](function(_0x45a287){_0x50bc31=0x1f4;logger[_0x388b('0x1f')](_0x45a287['stack']);if(_0x45a287[_0x388b('0x30')]){delete _0x45a287[_0x388b('0x30')];}_0xfacb86=_0x45a287;})[_0x388b('0x11a')](function(){if(_0xfacb86===null){_0x124b1c['sendStatus'](_0x50bc31);}else{if(_0x50bc31===0x1f4){_0x124b1c['status'](_0x50bc31)[_0x388b('0x31')](_0xfacb86);}else{_0x124b1c[_0x388b('0x26')](_0x50bc31)[_0x388b('0x11b')](_0xfacb86);}}});};exports[_0x388b('0x11c')]=function(_0x4fa514,_0x465321){var _0xc6a29={};var _0x833f89={};var _0x31c7cd;var _0x1f4269;return db[_0x388b('0x56')]['findOne']({'where':{'id':_0x4fa514['params']['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x465321,null))[_0x388b('0x19')](function(_0x1abbea){if(_0x1abbea){_0x31c7cd=_0x1abbea;_0x833f89[_0x388b('0x4f')]=_[_0x388b('0x58')](db[_0x388b('0xae')]['rawAttributes']);_0x833f89[_0x388b('0x59')]=_[_0x388b('0x58')](_0x4fa514[_0x388b('0x59')]);_0x833f89['filters']=_['intersection'](_0x833f89[_0x388b('0x4f')],_0x833f89[_0x388b('0x59')]);_0xc6a29[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x833f89['model'],qs[_0x388b('0x5d')](_0x4fa514[_0x388b('0x59')][_0x388b('0x5d')]));_0xc6a29[_0x388b('0x5c')]=_0xc6a29['attributes'][_0x388b('0x5e')]?_0xc6a29[_0x388b('0x5c')]:_0x833f89['model'];_0xc6a29[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x4fa514['query'][_0x388b('0x61')]);_0xc6a29[_0x388b('0x62')]=qs[_0x388b('0x5a')](_[_0x388b('0x7d')](_0x4fa514[_0x388b('0x59')],_0x833f89['filters']));if(_0x4fa514[_0x388b('0x59')][_0x388b('0x63')]){_0xc6a29[_0x388b('0x62')]=_[_0x388b('0x65')](_0xc6a29[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0xc6a29['attributes'],function(_0x531287){var _0xd4cd63={};_0xd4cd63[_0x531287]={'$like':'%'+_0x4fa514[_0x388b('0x59')]['filter']+'%'};return _0xd4cd63;})});}_0xc6a29=_[_0x388b('0x65')]({},_0xc6a29,_0x4fa514['options']);return _0x31c7cd[_0x388b('0x11c')](_0xc6a29);}})['then'](function(_0x536d0a){if(_0x536d0a){_0x1f4269=_0x536d0a['length'];if(!_0x4fa514[_0x388b('0x59')][_0x388b('0x7c')](_0x388b('0x5f'))){_0xc6a29[_0x388b('0x28')]=qs[_0x388b('0x28')](_0x4fa514['query']['limit']);_0xc6a29[_0x388b('0x27')]=qs['offset'](_0x4fa514[_0x388b('0x59')][_0x388b('0x27')]);}return _0x31c7cd[_0x388b('0x11c')](_0xc6a29);}})[_0x388b('0x19')](function(_0x3f6e08){if(_0x3f6e08){return _0x3f6e08?{'count':_0x1f4269,'rows':_0x3f6e08}:null;}})['then'](respondWithResult(_0x465321,null))[_0x388b('0x3a')](handleError(_0x465321,null));};exports['addProactiveActions']=function(_0x400049,_0x5d1ac2){return db[_0x388b('0x11d')][_0x388b('0x73')]({'where':{'id':_0x400049[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x5d1ac2,null))[_0x388b('0x19')](function(_0x46d778){if(_0x46d778){return _0x46d778[_0x388b('0x11e')](_0x400049[_0x388b('0x6e')][_0x388b('0x82')],_[_0x388b('0xfd')](_0x400049[_0x388b('0x6e')],['ids','id'])||{});}})['then'](respondWithResult(_0x5d1ac2,null))[_0x388b('0x3a')](handleError(_0x5d1ac2,null));};exports[_0x388b('0x107')]=function(_0x28193b,_0x12da2e){var _0x48b713={};var _0x20a763={};var _0x5bdaff;var _0x4bd332;return db[_0x388b('0x56')][_0x388b('0x7b')]({'where':{'id':_0x28193b['params']['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x12da2e,null))[_0x388b('0x19')](function(_0x1acea7){if(_0x1acea7){_0x5bdaff=_0x1acea7;_0x20a763[_0x388b('0x4f')]=_[_0x388b('0x58')](db[_0x388b('0x11f')][_0x388b('0x6c')]);_0x20a763[_0x388b('0x59')]=_['keys'](_0x28193b[_0x388b('0x59')]);_0x20a763[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x20a763[_0x388b('0x4f')],_0x20a763[_0x388b('0x59')]);_0x48b713['attributes']=_['intersection'](_0x20a763[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x28193b[_0x388b('0x59')]['fields']));_0x48b713[_0x388b('0x5c')]=_0x48b713[_0x388b('0x5c')][_0x388b('0x5e')]?_0x48b713[_0x388b('0x5c')]:_0x20a763[_0x388b('0x4f')];_0x48b713[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x28193b[_0x388b('0x59')]['sort']);_0x48b713[_0x388b('0x62')]=qs['filters'](_[_0x388b('0x7d')](_0x28193b[_0x388b('0x59')],_0x20a763[_0x388b('0x5a')]));if(_0x28193b['query'][_0x388b('0x63')]){_0x48b713[_0x388b('0x62')]=_[_0x388b('0x65')](_0x48b713[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x48b713['attributes'],function(_0xe164d7){var _0x226344={};_0x226344[_0xe164d7]={'$like':'%'+_0x28193b[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x226344;})});}_0x48b713=_[_0x388b('0x65')]({},_0x48b713,_0x28193b['options']);return _0x5bdaff['getProactiveActions'](_0x48b713);}})[_0x388b('0x19')](function(_0x186550){if(_0x186550){_0x4bd332=_0x186550[_0x388b('0x5e')];if(!_0x28193b[_0x388b('0x59')][_0x388b('0x7c')]('nolimit')){_0x48b713['limit']=qs[_0x388b('0x28')](_0x28193b['query'][_0x388b('0x28')]);_0x48b713['offset']=qs[_0x388b('0x27')](_0x28193b[_0x388b('0x59')][_0x388b('0x27')]);}return _0x5bdaff['getProactiveActions'](_0x48b713);}})[_0x388b('0x19')](function(_0x27a1bb){if(_0x27a1bb){return _0x27a1bb?{'count':_0x4bd332,'rows':_0x27a1bb}:null;}})[_0x388b('0x19')](respondWithResult(_0x12da2e,null))[_0x388b('0x3a')](handleError(_0x12da2e,null));};exports[_0x388b('0x120')]=function(_0x4ac00d,_0x2604d5){var _0x30cd98=_0x4ac00d[_0x388b('0x59')][_0x388b('0x121')]===_0x388b('0x122')?_0x388b('0x123'):_0x388b('0x124');return db[_0x388b('0x56')][_0x388b('0x73')]({'attributes':['id',_0x30cd98],'where':{'id':_0x4ac00d[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x2604d5,null))[_0x388b('0x19')](function(_0x241892){if(_0x241892){var _0xfa97f0=_0x241892[_0x30cd98];var _0x5bd2a9=_0xfa97f0&&_0xfa97f0[_0x388b('0x125')]?_0xfa97f0[_0x388b('0x125')]:[];_0x2604d5['send']({'fromKey':_['isNil'](_0xfa97f0[_0x388b('0x126')])?undefined:_0xfa97f0[_0x388b('0x126')],'count':_0x5bd2a9[_0x388b('0x5e')],'rows':_0x5bd2a9});}})[_0x388b('0x3a')](handleError(_0x2604d5,null));};exports[_0x388b('0x127')]=function(_0x4b9251,_0x336e62){var _0x4796fa={'raw':![],'where':{}};var _0x252891={};var _0x3389cf={'count':0x0,'rows':[]};return db[_0x388b('0x56')][_0x388b('0x7b')]({'where':{'id':_0x4b9251[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x336e62,null))[_0x388b('0x19')](function(_0x13d224){if(_0x13d224){_0x252891['model']=_[_0x388b('0x58')](db['ChatOfflineMessage'][_0x388b('0x6c')]);_0x252891[_0x388b('0x59')]=_[_0x388b('0x58')](_0x4b9251[_0x388b('0x59')]);_0x252891[_0x388b('0x5a')]=_['intersection'](_0x252891[_0x388b('0x4f')],_0x252891[_0x388b('0x59')]);_0x4796fa[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x252891[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x4b9251[_0x388b('0x59')]['fields']));_0x4796fa['attributes']=_0x4796fa['attributes'][_0x388b('0x5e')]?_0x4796fa[_0x388b('0x5c')]:_0x252891[_0x388b('0x4f')];if(!_0x4b9251[_0x388b('0x59')][_0x388b('0x7c')](_0x388b('0x5f'))){_0x4796fa[_0x388b('0x28')]=qs[_0x388b('0x28')](_0x4b9251['query']['limit']);_0x4796fa[_0x388b('0x27')]=qs['offset'](_0x4b9251[_0x388b('0x59')]['offset']);}_0x4796fa[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x4b9251[_0x388b('0x59')][_0x388b('0x61')]);_0x4796fa[_0x388b('0x62')]=qs[_0x388b('0x5a')](_[_0x388b('0x7d')](_0x4b9251[_0x388b('0x59')],_0x252891['filters']));_0x4796fa[_0x388b('0x62')][_0x388b('0x78')]=_0x13d224['id'];if(_0x4b9251[_0x388b('0x59')][_0x388b('0x63')]){_0x4796fa[_0x388b('0x62')]=_[_0x388b('0x65')](_0x4796fa[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x4796fa[_0x388b('0x5c')],function(_0x21cd83){var _0x377395={};_0x377395[_0x21cd83]={'$like':'%'+_0x4b9251[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x377395;})});}_0x4796fa=_[_0x388b('0x65')]({},_0x4796fa,_0x4b9251[_0x388b('0x66')]);return db['ChatOfflineMessage']['count']({'where':_0x4796fa[_0x388b('0x62')]})[_0x388b('0x19')](function(_0x2b6dc3){_0x3389cf['count']=_0x2b6dc3;if(_0x4b9251[_0x388b('0x59')]['includeAll']){_0x4796fa[_0x388b('0x68')]=[{'all':!![]}];}else{_0x4796fa[_0x388b('0x68')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x388b('0xe7')],'as':'Attachments','required':![]}];}return db[_0x388b('0xe0')][_0x388b('0x106')](_0x4796fa);})[_0x388b('0x19')](function(_0xd1da65){_0x3389cf[_0x388b('0x69')]=_0xd1da65;return _0x3389cf;});}})[_0x388b('0x19')](respondWithFilteredResult(_0x336e62,_0x4796fa))[_0x388b('0x3a')](handleError(_0x336e62,null));};exports[_0x388b('0x128')]=function(_0x6b83f1,_0x5f85ce){return db[_0x388b('0x56')]['find']({'where':{'id':_0x6b83f1[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x5f85ce,null))[_0x388b('0x19')](function(_0x57872a){if(_0x57872a){return _0x57872a[_0x388b('0x128')](_0x6b83f1[_0x388b('0x6e')]['ids'],_[_0x388b('0xfd')](_0x6b83f1['body'],['ids','id'])||{})[_0x388b('0xd9')](function(_0x5a2faa){for(var _0x281aec=0x0;_0x281aec<_0x6b83f1['body']['ids'][_0x388b('0x5e')];_0x281aec+=0x1){socket[_0x388b('0x129')](_0x388b('0x12a'),{'UserId':Number(_0x6b83f1['body'][_0x388b('0x82')][_0x281aec]),'ChatWebsiteId':Number(_0x6b83f1[_0x388b('0x6b')]['id'])});}return _0x5a2faa;});}})[_0x388b('0x19')](respondWithResult(_0x5f85ce,null))[_0x388b('0x3a')](handleError(_0x5f85ce,null));};exports[_0x388b('0x12b')]=function(_0x3d4269,_0x5b51b4){return db['ChatWebsite'][_0x388b('0x73')]({'where':{'id':_0x3d4269[_0x388b('0x6b')]['id']}})['then'](handleEntityNotFound(_0x5b51b4,null))['then'](function(_0x5845ba){if(_0x5845ba){return _0x5845ba[_0x388b('0x12b')](_0x3d4269[_0x388b('0x59')][_0x388b('0x82')])['then'](function(){if(_[_0x388b('0x12c')](_0x3d4269['query'][_0x388b('0x82')])){for(var _0x6ea01f=0x0;_0x6ea01f<_0x3d4269[_0x388b('0x59')][_0x388b('0x82')][_0x388b('0x5e')];_0x6ea01f+=0x1){socket[_0x388b('0x129')]('userChatWebsite:remove',{'UserId':Number(_0x3d4269['query'][_0x388b('0x82')][_0x6ea01f]),'ChatWebsiteId':Number(_0x3d4269[_0x388b('0x6b')]['id'])});}}else{socket['emit'](_0x388b('0x12d'),{'UserId':Number(_0x3d4269[_0x388b('0x59')][_0x388b('0x82')]),'ChatWebsiteId':Number(_0x3d4269[_0x388b('0x6b')]['id'])});}});}})[_0x388b('0x19')](respondWithStatusCode(_0x5b51b4,null))[_0x388b('0x3a')](handleError(_0x5b51b4,null));};exports[_0x388b('0x12e')]=function(_0x1597dc,_0x4ac9c9){var _0x32b996={};var _0x5ce35c={};var _0x1863dd;var _0x4dc0d4;return db[_0x388b('0x56')]['findOne']({'where':{'id':_0x1597dc[_0x388b('0x6b')]['id']}})[_0x388b('0x19')](handleEntityNotFound(_0x4ac9c9,null))['then'](function(_0x249523){if(_0x249523){_0x1863dd=_0x249523;_0x5ce35c[_0x388b('0x4f')]=_['keys'](db[_0x388b('0x100')]['rawAttributes']);_0x5ce35c[_0x388b('0x59')]=_['keys'](_0x1597dc[_0x388b('0x59')]);_0x5ce35c[_0x388b('0x5a')]=_[_0x388b('0x5b')](_0x5ce35c['model'],_0x5ce35c[_0x388b('0x59')]);_0x32b996[_0x388b('0x5c')]=_[_0x388b('0x5b')](_0x5ce35c[_0x388b('0x4f')],qs[_0x388b('0x5d')](_0x1597dc[_0x388b('0x59')][_0x388b('0x5d')]));_0x32b996[_0x388b('0x5c')]=_0x32b996[_0x388b('0x5c')][_0x388b('0x5e')]?_0x32b996[_0x388b('0x5c')]:_0x5ce35c['model'];_0x32b996[_0x388b('0x60')]=qs[_0x388b('0x61')](_0x1597dc[_0x388b('0x59')][_0x388b('0x61')]);_0x32b996[_0x388b('0x62')]=qs[_0x388b('0x5a')](_[_0x388b('0x7d')](_0x1597dc[_0x388b('0x59')],_0x5ce35c[_0x388b('0x5a')]));if(_0x1597dc[_0x388b('0x59')][_0x388b('0x63')]){_0x32b996[_0x388b('0x62')]=_[_0x388b('0x65')](_0x32b996[_0x388b('0x62')],{'$or':_[_0x388b('0x3c')](_0x32b996[_0x388b('0x5c')],function(_0x266ed7){var _0x479ac2={};_0x479ac2[_0x266ed7]={'$like':'%'+_0x1597dc[_0x388b('0x59')][_0x388b('0x63')]+'%'};return _0x479ac2;})});}_0x32b996=_[_0x388b('0x65')]({},_0x32b996,_0x1597dc[_0x388b('0x66')]);return _0x1863dd[_0x388b('0x12e')](_0x32b996);}})[_0x388b('0x19')](function(_0xfc7779){if(_0xfc7779){_0x4dc0d4=_0xfc7779[_0x388b('0x5e')];if(!_0x1597dc[_0x388b('0x59')][_0x388b('0x7c')](_0x388b('0x5f'))){_0x32b996[_0x388b('0x28')]=qs['limit'](_0x1597dc[_0x388b('0x59')][_0x388b('0x28')]);_0x32b996[_0x388b('0x27')]=qs[_0x388b('0x27')](_0x1597dc[_0x388b('0x59')]['offset']);}return _0x1863dd[_0x388b('0x12e')](_0x32b996);}})[_0x388b('0x19')](function(_0x51a574){if(_0x51a574){return _0x51a574?{'count':_0x4dc0d4,'rows':_0x51a574}:null;}})[_0x388b('0x19')](respondWithResult(_0x4ac9c9,null))[_0x388b('0x3a')](handleError(_0x4ac9c9,null));};
\ No newline at end of file