Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index cfc8a77..b9ed79d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdfdf=['headers','user-agent','chat','CmContact','difference','createdAt','updatedAt','ListId','from','Sequelize','ValidationError','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','DESC','ChatApplication','Applications','account','applications','list','orderBy','priority','contact','customerIp','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','unknown','%s\x20%s','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','push','close','unmanaged','ChatMessage','AttachmentId','UserId','User','unshift','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','Start','startRouting','EventManager','notify','offline','files','no\x20available\x20attributes','CompanyId','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','CmList','findOrCreate','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','fromString','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','MailAccount','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','email','offlineMessageSubject','MailAccountId','mimetype','subjectOffline','mapValues','Chat','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','getInteractions','Owner','fullname','internal','Tags','color','tag','Command','timezone','iftime\x20%s','interval','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','inspect','No\x20timezone','Interval','Intervals','../../config/license/util','getLicense','virtual','License','increment','chatLicenseExceeded','all','some','readFileSync','server/files/chat/iframe.ejs','address','origin','3.1.0','remote','x-real-ip','connection','remoteAddress','replace','alignment','verticalAlignment','labelText','textColor','textButtonColor','color_button','backgroundColor','hideWhenOffline','addApplications','ISOLATION_LEVELS','READ_COMMITTED','finally','getApplications','omit','getProactiveActions','ChatProactiveAction','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','ChatOfflineMessage','Contact','Attachments','addAgents','removeAgents','isArray','emit','getAgents','mustache','path','ejs','fs-extra','lodash','querystring','ioredis','../../config/logger','../../config/environment','url','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','html-to-text','jayson/promise','client','http','request','info','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','ChatWebsite,\x20%s,\x20%s','message','error','result','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','update','then','destroy','get','ChatWebsites','UserProfileResource','stack','name','send','index','Pause','map','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','filters','pick','filter','where','merge','VIRTUAL','options','ChatWebsite','includeAll','findAll','rows','catch','show','mandatoryDispositionPause','include','create','user','role','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','params','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','rawAttributes','order','removeDispositions','addAnswer','CannedAnswer','getAnswers','removeAnswers','ids','addLogo','file','addAvatar','agentAvatar','filename','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','custom','isNil','sitepic','existsSync','join','server/files/images/logos/','getAvatar','server/files/images/avatars/','download','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA'];(function(_0x1881cd,_0x3b1e96){var _0x549812=function(_0x6d0ee){while(--_0x6d0ee){_0x1881cd['push'](_0x1881cd['shift']());}};_0x549812(++_0x3b1e96);}(_0xdfdf,0x1e0));var _0xfdfd=function(_0x6aebf,_0xbf7ebc){_0x6aebf=_0x6aebf-0x0;var _0x362e4e=_0xdfdf[_0x6aebf];return _0x362e4e;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0xfdfd('0x0'));var util=require('util');var path=require(_0xfdfd('0x1'));var ejs=require(_0xfdfd('0x2'));var fs=require('fs');var fs_extra=require(_0xfdfd('0x3'));var _=require(_0xfdfd('0x4'));var querystring=require(_0xfdfd('0x5'));var Redis=require(_0xfdfd('0x6'));var qs=require('../../components/parsers/qs');var logger=require(_0xfdfd('0x7'))('api');var config=require(_0xfdfd('0x8'));var url=require(_0xfdfd('0x9'));var db=require('../../mysqldb')['db'];config[_0xfdfd('0xa')]=_[_0xfdfd('0xb')](config['redis'],{'host':_0xfdfd('0xc'),'port':0x18eb});var socket=require(_0xfdfd('0xd'))(new Redis(config[_0xfdfd('0xa')]));require(_0xfdfd('0xe'))[_0xfdfd('0xf')](socket);var htmlToText=require(_0xfdfd('0x10'));var jayson=require(_0xfdfd('0x11'));var client=jayson[_0xfdfd('0x12')][_0xfdfd('0x13')]({'port':0x232c});var client9002=jayson[_0xfdfd('0x12')]['http']({'port':0x232a});var client9003=jayson[_0xfdfd('0x12')][_0xfdfd('0x13')]({'port':0x232b});var client9001=jayson[_0xfdfd('0x12')][_0xfdfd('0x13')]({'port':0x2329});function respondWithRpcPromise(_0x4952af,_0x1f75e6,_0x3db2a8,_0x38265d){return new BPromise(function(_0x4d9ae9,_0x19b7ef){var _0x16be1d=_0x38265d||client;return _0x16be1d[_0xfdfd('0x14')](_0x4952af,_0x3db2a8)['then'](function(_0x485a4b){logger[_0xfdfd('0x15')]('ChatWebsite,\x20%s,\x20%s',_0x1f75e6,'request\x20sent');logger[_0xfdfd('0x16')](_0xfdfd('0x17'),_0x1f75e6,'request\x20sent',JSON[_0xfdfd('0x18')](_0x485a4b));if(_0x485a4b['error']){if(_0x485a4b['error']['code']===0x1f4){logger['error'](_0xfdfd('0x19'),_0x1f75e6,_0x485a4b['error'][_0xfdfd('0x1a')]);return _0x19b7ef(_0x485a4b[_0xfdfd('0x1b')]['message']);}logger[_0xfdfd('0x1b')](_0xfdfd('0x19'),_0x1f75e6,_0x485a4b[_0xfdfd('0x1b')]['message']);return _0x4d9ae9(_0x485a4b['error'][_0xfdfd('0x1a')]);}else{logger[_0xfdfd('0x15')](_0xfdfd('0x19'),_0x1f75e6,'request\x20sent');_0x4d9ae9(_0x485a4b[_0xfdfd('0x1c')]['message']);}})['catch'](function(_0x4ebdaf){logger['error']('ChatWebsite,\x20%s,\x20%s',_0x1f75e6,_0x4ebdaf);_0x19b7ef(_0x4ebdaf);});});}function respondWithStatusCode(_0x5214f0,_0x5998a6){_0x5998a6=_0x5998a6||0xcc;return function(_0x73cde9){if(_0x73cde9){return _0x5214f0[_0xfdfd('0x1d')](_0x5998a6);}return _0x5214f0[_0xfdfd('0x1e')](_0x5998a6)[_0xfdfd('0x1f')]();};}function respondWithResult(_0x162593,_0x16bd58){_0x16bd58=_0x16bd58||0xc8;return function(_0xd73093){if(_0xd73093){return _0x162593[_0xfdfd('0x1e')](_0x16bd58)[_0xfdfd('0x20')](_0xd73093);}};}function respondWithFilteredResult(_0x1363d0,_0x54958f){return function(_0x144e0b){if(_0x144e0b){var _0x52a7bb=typeof _0x54958f[_0xfdfd('0x21')]===_0xfdfd('0x22')&&typeof _0x54958f[_0xfdfd('0x23')]===_0xfdfd('0x22');var _0x87a69c=_0x144e0b[_0xfdfd('0x24')];var _0x2a0789=_0x52a7bb?0x0:_0x54958f[_0xfdfd('0x21')];var _0x4a396a=_0x52a7bb?_0x144e0b[_0xfdfd('0x24')]:_0x54958f['offset']+_0x54958f['limit'];var _0x4afe43;if(_0x4a396a>=_0x87a69c){_0x4a396a=_0x87a69c;_0x4afe43=0xc8;}else{_0x4afe43=0xce;}_0x1363d0['status'](_0x4afe43);return _0x1363d0['set'](_0xfdfd('0x25'),_0x2a0789+'-'+_0x4a396a+'/'+_0x87a69c)[_0xfdfd('0x20')](_0x144e0b);}return null;};}function saveUpdates(_0x107af8){return function(_0x2de3ee){if(_0x2de3ee){return _0x2de3ee[_0xfdfd('0x26')](_0x107af8)[_0xfdfd('0x27')](function(_0x1a1f38){return _0x1a1f38;});}return null;};}function removeEntity(_0x5016ac){return function(_0x11aef2){if(_0x11aef2){return _0x11aef2[_0xfdfd('0x28')]()[_0xfdfd('0x27')](function(){var _0x3e9758=_0x11aef2[_0xfdfd('0x29')]({'plain':!![]});var _0x303fc0=_0xfdfd('0x2a');return db[_0xfdfd('0x2b')]['destroy']({'where':{'type':_0x303fc0,'resourceId':_0x3e9758['id']}})[_0xfdfd('0x27')](function(){return _0x11aef2;});})['then'](function(){_0x5016ac[_0xfdfd('0x1e')](0xcc)[_0xfdfd('0x1f')]();});}};}function handleEntityNotFound(_0x40631c){return function(_0x2f223a){if(!_0x2f223a){_0x40631c[_0xfdfd('0x1d')](0x194);}return _0x2f223a;};}function handleError(_0x2d90b4,_0x23c83d){_0x23c83d=_0x23c83d||0x1f4;return function(_0x3a5b2e){logger[_0xfdfd('0x1b')](_0x3a5b2e[_0xfdfd('0x2c')]);if(_0x3a5b2e[_0xfdfd('0x2d')]){delete _0x3a5b2e['name'];}_0x2d90b4['status'](_0x23c83d)[_0xfdfd('0x2e')](_0x3a5b2e);};}exports[_0xfdfd('0x2f')]=function(_0x5d311a,_0x5d1285){var _0x4acd3e={'include':[{'model':db[_0xfdfd('0x30')],'as':'mandatoryDispositionPause'}]},_0x247a09={},_0x282e9a={'count':0x0,'rows':[]};var _0x4e4bc5=_[_0xfdfd('0x31')](db['ChatWebsite']['rawAttributes'],function(_0xb9cd83){return{'name':_0xb9cd83[_0xfdfd('0x32')],'type':_0xb9cd83[_0xfdfd('0x33')][_0xfdfd('0x34')]};});_0x247a09[_0xfdfd('0x35')]=_[_0xfdfd('0x31')](_0x4e4bc5,'name');_0x247a09[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x5d311a[_0xfdfd('0x36')]);_0x247a09['filters']=_[_0xfdfd('0x38')](_0x247a09[_0xfdfd('0x35')],_0x247a09[_0xfdfd('0x36')]);_0x4acd3e[_0xfdfd('0x39')]=_[_0xfdfd('0x38')](_0x247a09['model'],qs['fields'](_0x5d311a['query'][_0xfdfd('0x3a')]));_0x4acd3e[_0xfdfd('0x39')]=_0x4acd3e[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x4acd3e[_0xfdfd('0x39')]:_0x247a09[_0xfdfd('0x35')];if(!_0x5d311a['query'][_0xfdfd('0x3c')](_0xfdfd('0x3d'))){_0x4acd3e['limit']=qs[_0xfdfd('0x23')](_0x5d311a[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x4acd3e[_0xfdfd('0x21')]=qs['offset'](_0x5d311a[_0xfdfd('0x36')][_0xfdfd('0x21')]);}_0x4acd3e['order']=qs['sort'](_0x5d311a['query'][_0xfdfd('0x3e')]);_0x4acd3e['where']=qs[_0xfdfd('0x3f')](_[_0xfdfd('0x40')](_0x5d311a[_0xfdfd('0x36')],_0x247a09['filters']),_0x4e4bc5);if(_0x5d311a[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x4acd3e[_0xfdfd('0x42')]=_[_0xfdfd('0x43')](_0x4acd3e[_0xfdfd('0x42')],{'$or':_[_0xfdfd('0x31')](_0x4e4bc5,function(_0x3ebe64){if(_0x3ebe64['type']!==_0xfdfd('0x44')){var _0x5c4959={};_0x5c4959[_0x3ebe64[_0xfdfd('0x2d')]]={'$like':'%'+_0x5d311a[_0xfdfd('0x36')]['filter']+'%'};return _0x5c4959;}})});}_0x4acd3e=_[_0xfdfd('0x43')]({},_0x4acd3e,_0x5d311a[_0xfdfd('0x45')]);var _0x56e165={'where':_0x4acd3e['where']};return db[_0xfdfd('0x46')][_0xfdfd('0x24')](_0x56e165)[_0xfdfd('0x27')](function(_0x3e65b8){_0x282e9a[_0xfdfd('0x24')]=_0x3e65b8;if(_0x5d311a[_0xfdfd('0x36')][_0xfdfd('0x47')]){_0x4acd3e['include']=[{'all':!![]}];}return db[_0xfdfd('0x46')][_0xfdfd('0x48')](_0x4acd3e);})[_0xfdfd('0x27')](function(_0x4476f3){_0x282e9a[_0xfdfd('0x49')]=_0x4476f3;return _0x282e9a;})['then'](respondWithFilteredResult(_0x5d1285,_0x4acd3e))[_0xfdfd('0x4a')](handleError(_0x5d1285,null));};exports[_0xfdfd('0x4b')]=function(_0x3b7cf3,_0x427356){var _0x27269b={'raw':![],'where':{'id':_0x3b7cf3['params']['id']},'include':[{'model':db[_0xfdfd('0x30')],'as':_0xfdfd('0x4c')}]},_0x5c0e59={};_0x5c0e59[_0xfdfd('0x35')]=_[_0xfdfd('0x37')](db['ChatWebsite']['rawAttributes']);_0x5c0e59[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x3b7cf3[_0xfdfd('0x36')]);_0x5c0e59[_0xfdfd('0x3f')]=_[_0xfdfd('0x38')](_0x5c0e59['model'],_0x5c0e59['query']);_0x27269b[_0xfdfd('0x39')]=_['intersection'](_0x5c0e59[_0xfdfd('0x35')],qs['fields'](_0x3b7cf3[_0xfdfd('0x36')]['fields']));_0x27269b[_0xfdfd('0x39')]=_0x27269b[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x27269b[_0xfdfd('0x39')]:_0x5c0e59['model'];if(_0x3b7cf3[_0xfdfd('0x36')][_0xfdfd('0x47')]){_0x27269b[_0xfdfd('0x4d')]=[{'all':!![]}];}_0x27269b=_[_0xfdfd('0x43')]({},_0x27269b,_0x3b7cf3[_0xfdfd('0x45')]);return db['ChatWebsite']['find'](_0x27269b)[_0xfdfd('0x27')](handleEntityNotFound(_0x427356,null))[_0xfdfd('0x27')](respondWithResult(_0x427356,null))['catch'](handleError(_0x427356,null));};exports[_0xfdfd('0x4e')]=function(_0x304bcc,_0x30f1fa){return db[_0xfdfd('0x46')][_0xfdfd('0x4e')](_0x304bcc['body'],{})[_0xfdfd('0x27')](function(_0x4eaf9d){var _0x427751=_0x304bcc[_0xfdfd('0x4f')]['get']({'plain':!![]});if(!_0x427751)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x427751[_0xfdfd('0x50')]===_0xfdfd('0x4f')){var _0x7355a7=_0x4eaf9d[_0xfdfd('0x29')]({'plain':!![]});var _0xec2e3=_0xfdfd('0x2a');return db['UserProfileSection'][_0xfdfd('0x51')]({'where':{'name':_0xec2e3,'userProfileId':_0x427751[_0xfdfd('0x52')]},'raw':!![]})[_0xfdfd('0x27')](function(_0x1314db){if(_0x1314db&&_0x1314db[_0xfdfd('0x53')]===0x0){return db[_0xfdfd('0x2b')]['create']({'name':_0x7355a7['name'],'resourceId':_0x7355a7['id'],'type':_0x1314db[_0xfdfd('0x2d')],'sectionId':_0x1314db['id']},{})[_0xfdfd('0x27')](function(){return _0x4eaf9d;});}else{return _0x4eaf9d;}})['catch'](function(_0x479a43){logger[_0xfdfd('0x1b')](_0xfdfd('0x54'),_0x479a43);throw _0x479a43;});}return _0x4eaf9d;})[_0xfdfd('0x27')](respondWithResult(_0x30f1fa,0xc9))[_0xfdfd('0x4a')](handleError(_0x30f1fa,null));};exports[_0xfdfd('0x26')]=function(_0x13d89f,_0x2774fc){if(_0x13d89f[_0xfdfd('0x55')]['id']){delete _0x13d89f[_0xfdfd('0x55')]['id'];}return db['ChatWebsite'][_0xfdfd('0x51')]({'where':{'id':_0x13d89f[_0xfdfd('0x56')]['id']},'include':[{'model':db[_0xfdfd('0x30')],'as':_0xfdfd('0x4c')}]})[_0xfdfd('0x27')](handleEntityNotFound(_0x2774fc,null))['then'](saveUpdates(_0x13d89f[_0xfdfd('0x55')],null))[_0xfdfd('0x27')](respondWithResult(_0x2774fc,null))[_0xfdfd('0x4a')](handleError(_0x2774fc,null));};exports['destroy']=function(_0x498ca1,_0x49fd7d){return db['ChatWebsite'][_0xfdfd('0x51')]({'where':{'id':_0x498ca1[_0xfdfd('0x56')]['id']}})['then'](handleEntityNotFound(_0x49fd7d,null))[_0xfdfd('0x27')](removeEntity(_0x49fd7d,null))[_0xfdfd('0x4a')](handleError(_0x49fd7d,null));};exports['describe']=function(_0x5cc6b5,_0x23ae53){return db['ChatWebsite'][_0xfdfd('0x57')]()['then'](respondWithResult(_0x23ae53,null))[_0xfdfd('0x4a')](handleError(_0x23ae53,null));};exports[_0xfdfd('0x58')]=function(_0x283b50,_0x34de54){if(_0x283b50[_0xfdfd('0x55')]['id']){delete _0x283b50['body']['id'];}return db['ChatWebsite'][_0xfdfd('0x51')]({'where':{'id':_0x283b50['params']['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x34de54,null))[_0xfdfd('0x27')](function(_0x3a1ee8){if(_0x3a1ee8){_0x283b50[_0xfdfd('0x55')][_0xfdfd('0x59')]=_0x3a1ee8['id'];return db[_0xfdfd('0x5a')][_0xfdfd('0x4e')](_0x283b50['body']);}})['then'](respondWithResult(_0x34de54,null))[_0xfdfd('0x4a')](handleError(_0x34de54,null));};exports[_0xfdfd('0x5b')]=function(_0x435c03,_0x57b75c){var _0x470d43={'raw':![],'where':{}};var _0x58f2df={};var _0xc1650a={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xfdfd('0x5c')]({'where':{'id':_0x435c03[_0xfdfd('0x56')]['id']}})['then'](handleEntityNotFound(_0x57b75c,null))[_0xfdfd('0x27')](function(_0x18c0a7){if(_0x18c0a7){_0x58f2df[_0xfdfd('0x35')]=_[_0xfdfd('0x37')](db[_0xfdfd('0x5a')][_0xfdfd('0x5d')]);_0x58f2df[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x435c03[_0xfdfd('0x36')]);_0x58f2df['filters']=_[_0xfdfd('0x38')](_0x58f2df[_0xfdfd('0x35')],_0x58f2df['query']);_0x470d43[_0xfdfd('0x39')]=_[_0xfdfd('0x38')](_0x58f2df[_0xfdfd('0x35')],qs['fields'](_0x435c03['query'][_0xfdfd('0x3a')]));_0x470d43['attributes']=_0x470d43[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x470d43['attributes']:_0x58f2df['model'];if(!_0x435c03['query']['hasOwnProperty'](_0xfdfd('0x3d'))){_0x470d43['limit']=qs['limit'](_0x435c03[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x470d43[_0xfdfd('0x21')]=qs[_0xfdfd('0x21')](_0x435c03[_0xfdfd('0x36')][_0xfdfd('0x21')]);}_0x470d43[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x435c03['query'][_0xfdfd('0x3e')]);_0x470d43[_0xfdfd('0x42')]=qs['filters'](_[_0xfdfd('0x40')](_0x435c03[_0xfdfd('0x36')],_0x58f2df[_0xfdfd('0x3f')]));_0x470d43['where'][_0xfdfd('0x59')]=_0x18c0a7['id'];if(_0x435c03[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x470d43['where']=_[_0xfdfd('0x43')](_0x470d43[_0xfdfd('0x42')],{'$or':_[_0xfdfd('0x31')](_0x470d43[_0xfdfd('0x39')],function(_0xef4892){var _0xfedcad={};_0xfedcad[_0xef4892]={'$like':'%'+_0x435c03[_0xfdfd('0x36')][_0xfdfd('0x41')]+'%'};return _0xfedcad;})});}_0x470d43=_[_0xfdfd('0x43')]({},_0x470d43,_0x435c03[_0xfdfd('0x45')]);return db[_0xfdfd('0x5a')]['count']({'where':_0x470d43[_0xfdfd('0x42')]})[_0xfdfd('0x27')](function(_0x283e94){_0xc1650a[_0xfdfd('0x24')]=_0x283e94;if(_0x435c03['query'][_0xfdfd('0x47')]){_0x470d43[_0xfdfd('0x4d')]=[{'all':!![]}];}return db['Disposition'][_0xfdfd('0x48')](_0x470d43);})['then'](function(_0x1a30bc){_0xc1650a[_0xfdfd('0x49')]=_0x1a30bc;return _0xc1650a;});}})['then'](respondWithFilteredResult(_0x57b75c,_0x470d43))['catch'](handleError(_0x57b75c,null));};exports[_0xfdfd('0x5f')]=function(_0x25e527,_0x810511){return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x25e527[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x810511,null))[_0xfdfd('0x27')](function(_0x5e0609){if(_0x5e0609){return _0x5e0609[_0xfdfd('0x5f')](_0x25e527[_0xfdfd('0x36')]['ids']);}})[_0xfdfd('0x27')](respondWithStatusCode(_0x810511,null))[_0xfdfd('0x4a')](handleError(_0x810511,null));};exports[_0xfdfd('0x60')]=function(_0x29e30f,_0x416a52){if(_0x29e30f[_0xfdfd('0x55')]['id']){delete _0x29e30f[_0xfdfd('0x55')]['id'];}return db[_0xfdfd('0x46')]['find']({'where':{'id':_0x29e30f['params']['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x416a52,null))[_0xfdfd('0x27')](function(_0x9675d3){if(_0x9675d3){_0x29e30f['body'][_0xfdfd('0x59')]=_0x9675d3['id'];return db[_0xfdfd('0x61')][_0xfdfd('0x4e')](_0x29e30f[_0xfdfd('0x55')]);}})[_0xfdfd('0x27')](respondWithResult(_0x416a52,null))['catch'](handleError(_0x416a52,null));};exports[_0xfdfd('0x62')]=function(_0xe724c3,_0x3e8e69){var _0x1d7ef3={'raw':![],'where':{}};var _0x2c5979={};var _0x4a581b={'count':0x0,'rows':[]};return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0xe724c3[_0xfdfd('0x56')]['id']}})['then'](handleEntityNotFound(_0x3e8e69,null))[_0xfdfd('0x27')](function(_0x494c9f){if(_0x494c9f){_0x2c5979['model']=_[_0xfdfd('0x37')](db[_0xfdfd('0x61')]['rawAttributes']);_0x2c5979[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0xe724c3[_0xfdfd('0x36')]);_0x2c5979[_0xfdfd('0x3f')]=_[_0xfdfd('0x38')](_0x2c5979[_0xfdfd('0x35')],_0x2c5979['query']);_0x1d7ef3[_0xfdfd('0x39')]=_['intersection'](_0x2c5979[_0xfdfd('0x35')],qs['fields'](_0xe724c3[_0xfdfd('0x36')][_0xfdfd('0x3a')]));_0x1d7ef3[_0xfdfd('0x39')]=_0x1d7ef3[_0xfdfd('0x39')]['length']?_0x1d7ef3['attributes']:_0x2c5979['model'];if(!_0xe724c3[_0xfdfd('0x36')][_0xfdfd('0x3c')]('nolimit')){_0x1d7ef3[_0xfdfd('0x23')]=qs['limit'](_0xe724c3['query']['limit']);_0x1d7ef3[_0xfdfd('0x21')]=qs[_0xfdfd('0x21')](_0xe724c3['query']['offset']);}_0x1d7ef3[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0xe724c3[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x1d7ef3[_0xfdfd('0x42')]=qs[_0xfdfd('0x3f')](_['pick'](_0xe724c3[_0xfdfd('0x36')],_0x2c5979[_0xfdfd('0x3f')]));_0x1d7ef3[_0xfdfd('0x42')]['ChatWebsiteId']=_0x494c9f['id'];if(_0xe724c3[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x1d7ef3[_0xfdfd('0x42')]=_[_0xfdfd('0x43')](_0x1d7ef3[_0xfdfd('0x42')],{'$or':_[_0xfdfd('0x31')](_0x1d7ef3['attributes'],function(_0x373239){var _0xd8a3f8={};_0xd8a3f8[_0x373239]={'$like':'%'+_0xe724c3[_0xfdfd('0x36')]['filter']+'%'};return _0xd8a3f8;})});}_0x1d7ef3=_[_0xfdfd('0x43')]({},_0x1d7ef3,_0xe724c3[_0xfdfd('0x45')]);return db[_0xfdfd('0x61')][_0xfdfd('0x24')]({'where':_0x1d7ef3[_0xfdfd('0x42')]})[_0xfdfd('0x27')](function(_0x5798ba){_0x4a581b[_0xfdfd('0x24')]=_0x5798ba;if(_0xe724c3['query'][_0xfdfd('0x47')]){_0x1d7ef3['include']=[{'all':!![]}];}return db[_0xfdfd('0x61')]['findAll'](_0x1d7ef3);})[_0xfdfd('0x27')](function(_0x580bfa){_0x4a581b[_0xfdfd('0x49')]=_0x580bfa;return _0x4a581b;});}})['then'](respondWithFilteredResult(_0x3e8e69,_0x1d7ef3))['catch'](handleError(_0x3e8e69,null));};exports[_0xfdfd('0x63')]=function(_0xc7fa98,_0x3e81f6){return db[_0xfdfd('0x46')]['find']({'where':{'id':_0xc7fa98[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x3e81f6,null))[_0xfdfd('0x27')](function(_0x2081d2){if(_0x2081d2){return _0x2081d2[_0xfdfd('0x63')](_0xc7fa98[_0xfdfd('0x36')][_0xfdfd('0x64')]);}})[_0xfdfd('0x27')](respondWithStatusCode(_0x3e81f6,null))['catch'](handleError(_0x3e81f6,null));};exports[_0xfdfd('0x65')]=function(_0x18a252,_0x123273){_0x18a252[_0xfdfd('0x55')]['sitepic']=_0x18a252[_0xfdfd('0x66')]['filename'];return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x18a252[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x123273,null))['then'](saveUpdates(_0x18a252[_0xfdfd('0x55')],null))[_0xfdfd('0x27')](respondWithResult(_0x123273,null))[_0xfdfd('0x4a')](handleError(_0x123273,null));};exports[_0xfdfd('0x67')]=function(_0x498050,_0x2d3256){_0x498050[_0xfdfd('0x55')][_0xfdfd('0x68')]=_0x498050[_0xfdfd('0x66')][_0xfdfd('0x69')];return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x498050[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x2d3256,null))[_0xfdfd('0x27')](saveUpdates(_0x498050[_0xfdfd('0x55')],null))[_0xfdfd('0x27')](respondWithResult(_0x2d3256,null))[_0xfdfd('0x4a')](handleError(_0x2d3256,null));};exports[_0xfdfd('0x6a')]=function(_0x24798f,_0x140641){_0x24798f['body'][_0xfdfd('0x6b')]=_0x24798f[_0xfdfd('0x66')][_0xfdfd('0x69')];return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x24798f['params']['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x140641,null))[_0xfdfd('0x27')](saveUpdates(_0x24798f[_0xfdfd('0x55')],null))['then'](respondWithResult(_0x140641,null))[_0xfdfd('0x4a')](handleError(_0x140641,null));};exports[_0xfdfd('0x6c')]=function(_0x5e31f9,_0x450461){_0x5e31f9[_0xfdfd('0x55')][_0xfdfd('0x6d')]=_0x5e31f9[_0xfdfd('0x66')][_0xfdfd('0x69')];return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x5e31f9[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x450461,null))[_0xfdfd('0x27')](saveUpdates(_0x5e31f9['body'],null))[_0xfdfd('0x27')](respondWithResult(_0x450461,null))[_0xfdfd('0x4a')](handleError(_0x450461,null));};exports[_0xfdfd('0x6e')]=function(_0x19d10d,_0xe65366){var _0x42f7ed=path['join'](config[_0xfdfd('0x6f')],_0xfdfd('0x70'));var _0x36d6f9={'where':{'id':_0x19d10d[_0xfdfd('0x56')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x19823d=![];return require('../../config/license/util')['getLicense']()[_0xfdfd('0x27')](function(_0x74e492){if(_0x74e492){_0x19823d=_0x74e492[_0xfdfd('0x71')];}})[_0xfdfd('0x27')](function(){return db[_0xfdfd('0x46')][_0xfdfd('0x51')](_0x36d6f9);})[_0xfdfd('0x27')](handleEntityNotFound(_0xe65366,null))[_0xfdfd('0x27')](function(_0x53ff12){if(_0x53ff12){if(!_[_0xfdfd('0x72')](_0x53ff12[_0xfdfd('0x73')])){if(fs[_0xfdfd('0x74')](path['join'](config[_0xfdfd('0x6f')],'server/files/images/logos/',_0x53ff12['sitepic']))&&_0x19823d){_0x42f7ed=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x76'),_0x53ff12[_0xfdfd('0x73')]);}}return _0xe65366['download'](_0x42f7ed);}})[_0xfdfd('0x4a')](handleError(_0xe65366,null));};exports[_0xfdfd('0x77')]=function(_0x534601,_0x2cd1a5){var _0x2b1546=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],'server/files/images/avatars/default_avatar.png');var _0x3a5851={'where':{'id':_0x534601['params']['id']},'attributes':['id',_0xfdfd('0x68')],'raw':!![]};return db[_0xfdfd('0x46')][_0xfdfd('0x51')](_0x3a5851)['then'](handleEntityNotFound(_0x2cd1a5,null))[_0xfdfd('0x27')](function(_0x30e281){if(_0x30e281){if(!_[_0xfdfd('0x72')](_0x30e281[_0xfdfd('0x68')])){if(fs[_0xfdfd('0x74')](path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x78'),_0x30e281[_0xfdfd('0x68')]))){_0x2b1546=path[_0xfdfd('0x75')](config['root'],_0xfdfd('0x78'),_0x30e281['agentAvatar']);}}return _0x2cd1a5[_0xfdfd('0x79')](_0x2b1546);}})['catch'](handleError(_0x2cd1a5,null));};exports[_0xfdfd('0x7a')]=function(_0x4b1fb2,_0xa60cf3){var _0x149a71=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x7b'));var _0x1e7fac={'where':{'id':_0x4b1fb2['params']['id']},'attributes':['id',_0xfdfd('0x6b'),_0xfdfd('0x7c')],'raw':!![]};return db[_0xfdfd('0x46')]['find'](_0x1e7fac)['then'](handleEntityNotFound(_0xa60cf3,null))['then'](function(_0x138fbc){if(_0x138fbc){if(!_['isNil'](_0x138fbc[_0xfdfd('0x6b')])){if(fs[_0xfdfd('0x74')](path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x78'),_0x138fbc[_0xfdfd('0x6b')]))&&_0x138fbc['showCustomerAvatar']){_0x149a71=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x78'),_0x138fbc['customerAvatar']);}}return _0xa60cf3[_0xfdfd('0x79')](_0x149a71);}})[_0xfdfd('0x4a')](handleError(_0xa60cf3,null));};exports['getSystemAvatar']=function(_0x2f4013,_0x2ef81a){var _0x2f3f01=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x7d'));var _0x58840c={'where':{'id':_0x2f4013[_0xfdfd('0x56')]['id']},'attributes':['id',_0xfdfd('0x6d')],'raw':!![]};return db[_0xfdfd('0x46')][_0xfdfd('0x51')](_0x58840c)['then'](handleEntityNotFound(_0x2ef81a,null))[_0xfdfd('0x27')](function(_0x1be010){if(_0x1be010){if(!_[_0xfdfd('0x72')](_0x1be010[_0xfdfd('0x6d')])){if(fs[_0xfdfd('0x74')](path[_0xfdfd('0x75')](config['root'],'server/files/images/avatars/',_0x1be010[_0xfdfd('0x6d')]))){_0x2f3f01=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x78'),_0x1be010[_0xfdfd('0x6d')]);}}return _0x2ef81a['download'](_0x2f3f01);}})[_0xfdfd('0x4a')](handleError(_0x2ef81a,null));};exports['notify']=function(_0x18d286,_0x200458){var _0x222b17=require(_0xfdfd('0x7e'));var _0x4f15ec=new _0x222b17();var _0x93e267=_0x4f15ec[_0xfdfd('0x7f')](_0x18d286[_0xfdfd('0x80')][_0xfdfd('0x81')])['getResult']();var _0x282c1f={'body':_0x18d286[_0xfdfd('0x55')],'channel':_0xfdfd('0x82')};var _0x120b5e=[];var _0x33a3b6=[];var _0x30ec08={};var _0x622486=![];return db[_0xfdfd('0x83')]['describe']()[_0xfdfd('0x27')](function(_0x3000e9){if(!_0x3000e9){throw new db['Sequelize']['ValidationError']('no\x20available\x20attributes');}_0x120b5e=_[_0xfdfd('0x84')](_[_0xfdfd('0x37')](_0x3000e9),[_0xfdfd('0x85'),_0xfdfd('0x86')]);_0x33a3b6=_['difference'](_[_0xfdfd('0x37')](_0x3000e9),['createdAt',_0xfdfd('0x86'),'CompanyId',_0xfdfd('0x87')]);if(_0x18d286['body']['id']){delete _0x18d286['body']['id'];}if(_[_0xfdfd('0x72')](_0x18d286['body'][_0xfdfd('0x88')])){throw new db[(_0xfdfd('0x89'))][(_0xfdfd('0x8a'))]('from\x20is\x20mandatory');}if(_[_0xfdfd('0x72')](_0x18d286['body'][_0xfdfd('0x55')])||_0x18d286[_0xfdfd('0x55')]['body']===''){throw new db['Sequelize'][(_0xfdfd('0x8a'))](_0xfdfd('0x8b'));}if(_[_0xfdfd('0x72')](_0x18d286['body'][_0xfdfd('0x8c')])){throw new db['Sequelize']['ValidationError'](_0xfdfd('0x8d')+_0x33a3b6);}if(!_[_0xfdfd('0x8e')](_0x33a3b6,_0x18d286[_0xfdfd('0x55')][_0xfdfd('0x8c')])){throw new db[(_0xfdfd('0x89'))][(_0xfdfd('0x8a'))](_0xfdfd('0x8f')+_0x33a3b6);}_0x30ec08[_0x18d286[_0xfdfd('0x55')]['mapKey']]=_0x18d286['body'][_0xfdfd('0x88')];})[_0xfdfd('0x27')](function(){return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x18d286[_0xfdfd('0x56')]['id']},'include':[{'model':db['CmList'],'as':_0xfdfd('0x90'),'include':[{'model':db[_0xfdfd('0x83')],'as':_0xfdfd('0x91'),'where':_0x30ec08,'limit':0x1,'order':[['updatedAt',_0xfdfd('0x92')]]}]},{'model':db[_0xfdfd('0x93')],'as':_0xfdfd('0x94')}]});})[_0xfdfd('0x27')](handleEntityNotFound(_0x200458,null))['then'](function(_0x5ad72c){if(_0x5ad72c&&_0x5ad72c[_0xfdfd('0x90')]){_0x282c1f[_0xfdfd('0x95')]=_0x5ad72c;_0x282c1f[_0xfdfd('0x96')]=_0x5ad72c[_0xfdfd('0x94')];_0x282c1f[_0xfdfd('0x97')]=_0x5ad72c[_0xfdfd('0x90')];_0x282c1f[_0xfdfd('0x96')]=_[_0xfdfd('0x98')](_0x282c1f[_0xfdfd('0x96')],[_0xfdfd('0x99')],['asc']);if(_0x282c1f[_0xfdfd('0x95')]['Applications']){delete _0x282c1f['account'][_0xfdfd('0x94')];}if(_0x282c1f[_0xfdfd('0x95')]['List']&&_0x282c1f[_0xfdfd('0x95')][_0xfdfd('0x90')][_0xfdfd('0x91')]['length']){return _0x282c1f['account'][_0xfdfd('0x90')][_0xfdfd('0x91')][0x0];}var _0x242cbe=_[_0xfdfd('0xb')](_0x18d286['body'],{'firstName':_0x18d286[_0xfdfd('0x55')]['from'],'ListId':_0x5ad72c[_0xfdfd('0x87')]});_0x242cbe[_0x18d286[_0xfdfd('0x55')][_0xfdfd('0x8c')]]=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0x88')];return db['CmContact'][_0xfdfd('0x4e')](_0x242cbe,{'fields':_0x120b5e,'raw':!![]});}})['then'](handleEntityNotFound(_0x200458,null))[_0xfdfd('0x27')](function(_0x1bdf80){_0x282c1f[_0xfdfd('0x9a')]=_0x1bdf80;var _0x246760=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0x9b')];if(_0x18d286[_0xfdfd('0x80')]['cf-connecting-ip']){_0x246760=_0x18d286[_0xfdfd('0x80')]['cf-connecting-ip'];}else if(_0x18d286[_0xfdfd('0x80')][_0xfdfd('0x9c')]){_0x246760=_[_0xfdfd('0x9d')](_0x18d286['headers'][_0xfdfd('0x9c')][_0xfdfd('0x9e')](','));}if(_0x1bdf80){var _0x301dce={'ContactId':_0x1bdf80['id'],'ChatWebsiteId':_0x18d286[_0xfdfd('0x56')]['id'],'from':(_0x1bdf80[_0xfdfd('0x9f')]||'')+'\x20'+(_0x1bdf80[_0xfdfd('0xa0')]||''),'customerIp':_0x246760,'customerPort':_0x18d286['headers'][_0xfdfd('0xa1')]?_0x18d286[_0xfdfd('0x80')]['x-real-port']:null,'referer':_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xa2')],'browserName':_0x93e267[_0xfdfd('0xa3')][_0xfdfd('0x2d')]&&_0x93e267['browser'][_0xfdfd('0xa4')]?util[_0xfdfd('0xa5')]('%s\x20%s',_0x93e267[_0xfdfd('0xa3')][_0xfdfd('0x2d')],_0x93e267[_0xfdfd('0xa3')][_0xfdfd('0xa4')]):'unknown','browserVersion':_0x93e267[_0xfdfd('0xa3')][_0xfdfd('0xa4')]||_0xfdfd('0xa6'),'osName':util[_0xfdfd('0xa5')](_0xfdfd('0xa7'),_0x93e267['os'][_0xfdfd('0x2d')],_0x93e267['os']['version']),'osVersion':_0x93e267['os']['version'],'deviceModel':_0x93e267[_0xfdfd('0xa8')][_0xfdfd('0x35')]&&_0x93e267['device'][_0xfdfd('0xa9')]?util[_0xfdfd('0xa5')](_0xfdfd('0xaa'),_0x93e267[_0xfdfd('0xa8')][_0xfdfd('0x35')],_0x93e267['device']['vendor'],_0x93e267[_0xfdfd('0xa8')][_0xfdfd('0x33')]):null,'deviceVendor':_0x93e267['device'][_0xfdfd('0xa9')],'deviceType':_0x93e267[_0xfdfd('0xa8')][_0xfdfd('0x33')],'formData':JSON[_0xfdfd('0x18')](_0x18d286[_0xfdfd('0x55')])};var _0x2da49b={'ChatWebsiteId':_0x18d286['params']['id'],'closed':![]};if(_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xab')]){_0x2da49b[_0xfdfd('0xab')]=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xab')];return db[_0xfdfd('0xac')][_0xfdfd('0x51')]({'where':_0x2da49b})[_0xfdfd('0x27')](function(_0xf4107d){if(_0xf4107d){return[_0xf4107d,![]];}_0x301dce['threadId']=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xab')];_0x301dce[_0xfdfd('0xad')]=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xad')];return db[_0xfdfd('0xac')][_0xfdfd('0x4e')](_0x301dce)['then'](function(_0x3a7ad2){return[_0x3a7ad2,!![]];});});}_0x2da49b[_0xfdfd('0xae')]=_0x1bdf80['id'];if(_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xaf')]&&_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xaf')]['id']){_0x2da49b['id']=_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xaf')]['id'];return db['ChatInteraction']['find']({'where':_0x2da49b})[_0xfdfd('0x27')](function(_0x3e15cf){if(_0x3e15cf){return[_0x3e15cf,![]];}return db[_0xfdfd('0xac')][_0xfdfd('0x4e')](_0x301dce)['then'](function(_0x451e95){return[_0x451e95,!![]];});});}return db[_0xfdfd('0xac')][_0xfdfd('0x4e')](_0x301dce)[_0xfdfd('0x27')](function(_0x3d94e2){return[_0x3d94e2,!![]];});}})[_0xfdfd('0xb0')](function(_0x125313,_0x22612a){if(_0x125313){_0x622486=_0x22612a;if(!_0x22612a){var _0x549a62={'from':(_0x282c1f[_0xfdfd('0x9a')][_0xfdfd('0x9f')]||'')+'\x20'+(_0x282c1f[_0xfdfd('0x9a')][_0xfdfd('0xa0')]||'')};if(_0x18d286['body'][_0xfdfd('0xab')]&&_0x18d286['body'][_0xfdfd('0xb1')]&&_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xab')]!=_0x18d286['body']['messageId']){_0x549a62['threadId']=_0x18d286['body'][_0xfdfd('0xb1')];}return _0x125313['update'](_0x549a62);}else{return _0x125313;}}})['then'](function(_0x2ddf46){_0x282c1f[_0xfdfd('0xaf')]=_0x2ddf46[_0xfdfd('0x29')]({'plain':!![]});_0x282c1f[_0xfdfd('0xaf')][_0xfdfd('0xb2')]=_0x622486;if(_0x282c1f[_0xfdfd('0xaf')][_0xfdfd('0xb2')]){if(_0x282c1f['account']['autoclose']){_0x282c1f['applications'][_0xfdfd('0xb3')]({'id':0x0,'priority':_0x282c1f[_0xfdfd('0x96')]['length']+0x1,'app':_0xfdfd('0xb4'),'appdata':_0xfdfd('0xb5'),'interval':'*,*,*,*'});}}return db[_0xfdfd('0xb6')][_0xfdfd('0x4e')]({'body':_0x18d286['body']['body'],'ChatWebsiteId':_0x18d286[_0xfdfd('0x56')]['id'],'ChatInteractionId':_0x2ddf46['id'],'direction':'in','ContactId':_0x282c1f['contact']['id'],'AttachmentId':_0x18d286[_0xfdfd('0x55')][_0xfdfd('0xb7')]});})['then'](function(_0x3b4a6b){_0x282c1f[_0xfdfd('0x1a')]=_0x3b4a6b;if(_0x282c1f[_0xfdfd('0xaf')][_0xfdfd('0xb8')]){return db[_0xfdfd('0xb9')][_0xfdfd('0x51')]({'attributes':['id',_0xfdfd('0x2d')],'where':{'id':_0x282c1f[_0xfdfd('0xaf')]['UserId']}})[_0xfdfd('0x27')](function(_0x5703db){if(_0x5703db){_0x282c1f[_0xfdfd('0x96')][_0xfdfd('0xba')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x5703db[_0xfdfd('0x2d')]+','+(_0x282c1f[_0xfdfd('0x95')][_0xfdfd('0xbb')]||0xa),'interval':_0xfdfd('0xbc')});_0x282c1f[_0xfdfd('0xbd')]=!![];}return respondWithRpcPromise(_0xfdfd('0xbe'),_0xfdfd('0xbf'),_0x282c1f);});}return respondWithRpcPromise(_0xfdfd('0xbe'),_0xfdfd('0xbf'),_0x282c1f);})[_0xfdfd('0x27')](function(_0x384a57){respondWithRpcPromise(_0xfdfd('0xc0'),_0xfdfd('0xc0'),{'event':_0xfdfd('0xc1'),'message':_0x384a57},client9002);return _0x384a57;})[_0xfdfd('0x27')](respondWithResult(_0x200458,null))[_0xfdfd('0x4a')](handleError(_0x200458,null));};exports[_0xfdfd('0xc2')]=function(_0x59c1fb,_0x24cd3c){var _0x1cfd52,_0x381883,_0x648db3;var _0x22b21a=[];var _0x412474={};var _0x58e396=_0x59c1fb[_0xfdfd('0xc3')]||[];var _0x5b9209=[];var _0x4bcabd;return db[_0xfdfd('0x83')]['describe']()['then'](function(_0x4e8e8d){if(!_0x4e8e8d){throw new db[(_0xfdfd('0x89'))][(_0xfdfd('0x8a'))](_0xfdfd('0xc4'));}_0x22b21a=_['difference'](_[_0xfdfd('0x37')](_0x4e8e8d),[_0xfdfd('0x85'),'updatedAt',_0xfdfd('0xc5'),'ListId']);if(_0x59c1fb['body']['id']){delete _0x59c1fb[_0xfdfd('0x55')]['id'];}if(_['isNil'](_0x59c1fb['body'][_0xfdfd('0x88')])){throw _0x24cd3c[_0xfdfd('0x1e')](0x1f4)[_0xfdfd('0x2e')](new db[(_0xfdfd('0x89'))]['ValidationError']('from\x20is\x20mandatory'));}if(_['isNil'](_0x59c1fb[_0xfdfd('0x55')][_0xfdfd('0x55')])||_0x59c1fb[_0xfdfd('0x55')]['body']===''){throw _0x24cd3c[_0xfdfd('0x1e')](0x1f4)[_0xfdfd('0x2e')](new db['Sequelize'][(_0xfdfd('0x8a'))](_0xfdfd('0x8b')));}if(_[_0xfdfd('0x72')](_0x59c1fb['body']['mapKeyOffline'])){throw _0x24cd3c['status'](0x1f4)[_0xfdfd('0x2e')](new db[(_0xfdfd('0x89'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x22b21a));}if(!_[_0xfdfd('0x8e')](_0x22b21a,_0x59c1fb[_0xfdfd('0x55')]['mapKeyOffline'])){throw _0x24cd3c[_0xfdfd('0x1e')](0x1f4)[_0xfdfd('0x2e')](new db[(_0xfdfd('0x89'))]['ValidationError'](_0xfdfd('0xc6')+_0x22b21a));}_0x412474[_0x59c1fb['body'][_0xfdfd('0xc7')]]=_0x59c1fb[_0xfdfd('0x55')]['from'];})[_0xfdfd('0x27')](function(){return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x59c1fb[_0xfdfd('0x56')]['id']},'include':[{'model':db[_0xfdfd('0xc8')],'as':_0xfdfd('0x90')},{'model':db['MailAccount'],'as':'MailAccount'}]});})[_0xfdfd('0x27')](handleEntityNotFound(_0x24cd3c,null))[_0xfdfd('0x27')](function(_0x5e9970){if(_0x5e9970&&_0x5e9970[_0xfdfd('0x90')]){_0x381883=_0x5e9970;var _0x203c13=_[_0xfdfd('0xb')](_0x59c1fb[_0xfdfd('0x55')],{'firstName':_0x59c1fb[_0xfdfd('0x55')][_0xfdfd('0x88')],'phone':_0x59c1fb[_0xfdfd('0x55')][_0xfdfd('0x88')],'ListId':_0x5e9970[_0xfdfd('0x87')]});_0x203c13[_0x59c1fb[_0xfdfd('0x55')]['mapKeyOffline']]=_0x59c1fb[_0xfdfd('0x55')][_0xfdfd('0x88')];return db['CmContact'][_0xfdfd('0xc9')]({'where':_0x412474,'defaults':_0x203c13});}})[_0xfdfd('0xb0')](function(_0x5a7589){if(_0x5a7589){_0x648db3=_0x5a7589;var _0x53b01f=fs['readFileSync'](path['join'](config[_0xfdfd('0x6f')],_0xfdfd('0xca')),_0xfdfd('0xcb'));var _0x26e9b7=ejs[_0xfdfd('0xcc')](_0x53b01f,{'body':_[_0xfdfd('0xcd')](_0x59c1fb[_0xfdfd('0x55')][_0xfdfd('0x55')]),'bodyTitle':_0x381883[_0xfdfd('0xce')]});return db['ChatOfflineMessage'][_0xfdfd('0x4e')]({'body':_0x26e9b7,'plainBody':htmlToText[_0xfdfd('0xcf')](_0x26e9b7),'ContactId':_0x5a7589['id'],'ChatWebsiteId':_0x381883['id']});}})['then'](function(_0x28091b){_0x4bcabd=_0x28091b;if(_0x58e396[_0xfdfd('0x3b')]){var _0x52d93b=_0x58e396[_0xfdfd('0x31')](function(_0x198047){return{'name':_0x198047['originalname'],'basename':_0x198047[_0xfdfd('0x69')],'type':_0x198047['mimetype'],'ChatOfflineMessageId':_0x28091b['id']};});_0x5b9209=_0x52d93b['map'](_0x11440a=>{var _0x8ec378={'filename':_0x11440a[_0xfdfd('0x2d')],'path':path['join'](config[_0xfdfd('0x6f')],_0xfdfd('0xd0'),'files',_0xfdfd('0xd1'),_0xfdfd('0xd2'),_0x11440a[_0xfdfd('0xd3')])};return _0x8ec378;});if(!_0x381883[_0xfdfd('0xd4')]){return db[_0xfdfd('0xd5')][_0xfdfd('0xd6')](function(_0x34567d){return db[_0xfdfd('0xd7')][_0xfdfd('0xd8')](_0x52d93b,{'transaction':_0x34567d});});}}})[_0xfdfd('0x27')](function(){if(_0x4bcabd){_0x1cfd52=_0x4bcabd;return db[_0xfdfd('0xd9')][_0xfdfd('0x5c')]({'where':{'service':!![]},'include':[{'model':db[_0xfdfd('0xda')],'as':_0xfdfd('0xdb'),'raw':!![],'include':[{'model':db[_0xfdfd('0xdc')],'as':_0xfdfd('0xdc'),'raw':!![]}]}]});}})[_0xfdfd('0x27')](function(_0x5a5030){if(_0x5a5030&&_0x5a5030[_0xfdfd('0xdb')]&&_0x381883[_0xfdfd('0xdd')]&&_0x381883[_0xfdfd('0xde')]){var _0xe502c2=_0x5a5030[_0xfdfd('0xdf')]();return respondWithRpcPromise(_0xfdfd('0xe0'),'sendMail',{'account':_0xe502c2,'message':{'from':util[_0xfdfd('0xa5')]('\x22%s\x22\x20<%s>',_0x5a5030[_0xfdfd('0x2d')],_0x5a5030[_0xfdfd('0xe1')]||_0x5a5030[_0xfdfd('0xdb')][_0xfdfd('0x4f')]),'to':_0x381883[_0xfdfd('0xde')],'subject':_0x381883[_0xfdfd('0xe2')],'html':_0x1cfd52[_0xfdfd('0x55')],'attachments':_0x5b9209}},client9003)[_0xfdfd('0x27')](function(){return _0x1cfd52;})[_0xfdfd('0x4a')](function(_0x420ed8){logger['error'](_0x420ed8);});}})[_0xfdfd('0x27')](function(){if(_0x381883&&_0x381883[_0xfdfd('0xd4')]&&_0x381883[_0xfdfd('0xe3')]){var _0x28ebed=[];if(_0x58e396['length']){_0x28ebed=_0x58e396['map'](function(_0x406c43){return{'name':_0x406c43['originalname'],'basename':_0x406c43[_0xfdfd('0x69')],'type':_0x406c43[_0xfdfd('0xe4')],'ChatOfflineMessageId':_0x4bcabd['id']};});}var _0x1e92b2;if(!_[_0xfdfd('0x72')](_0x381883[_0xfdfd('0xe5')])){var _0x51a3f2=_['map'](_0x59c1fb[_0xfdfd('0x55')],function(_0xe22bfa){return _0xe22bfa;});var _0x3c3532=_['toPairsIn'](_0x51a3f2)[0x0];var _0x59d717=_[_0xfdfd('0xe6')](_0x3c3532,function(_0xfe89d9){return _0xfe89d9;});_0x1e92b2=_0x59d717[0x1][_0x381883['subjectOffline']];}var _0x52cdcd={'from':_0x648db3[_0xfdfd('0xe1')],'firstName':_0x648db3[_0xfdfd('0x9f')],'lastName':_0x648db3[_0xfdfd('0xa0')],'mapKey':_0xfdfd('0xe1'),'message':{'from':_0x648db3['email'],'to':_0x381883[_0xfdfd('0xd9')][_0xfdfd('0xe1')],'cc':'','subject':_[_0xfdfd('0x72')](_0x1e92b2)?_0x381883[_0xfdfd('0xe2')]:_0x1e92b2,'messageId':'','sentAt':new Date(),'attach':_0x28ebed[_0xfdfd('0x3b')],'attachments':_0x28ebed,'originChannel':_0xfdfd('0xe7'),'ChatWebsiteId':_0x381883['id'],'ChatOfflineMessageId':_0x1cfd52['id'],'originTo':_0x381883[_0xfdfd('0xd9')][_0xfdfd('0xe1')]},'body':_0x1cfd52[_0xfdfd('0x55')]};var _0x52ff96={'account':{'id':_0x381883[_0xfdfd('0xe3')]},'body':_0x52cdcd,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xfdfd('0xe8'),_0xfdfd('0xe9'),_0x52ff96,client9001)[_0xfdfd('0x27')](function(){return _0x1cfd52;})[_0xfdfd('0x4a')](function(_0x4aba97){logger['error'](_0x4aba97);});}return;})[_0xfdfd('0x27')](function(){if(_0x1cfd52){return _0x1cfd52;}})[_0xfdfd('0x27')](respondWithResult(_0x24cd3c,null))[_0xfdfd('0x4a')](function(_0x42578f){logger[_0xfdfd('0x1b')]('catch',_0x42578f);for(var _0x44c75e of _0x58e396){var _0x264f88=path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],'server',_0xfdfd('0xc3'),_0xfdfd('0xd1'),_0xfdfd('0xd2'),_0x44c75e['filename']);fs_extra[_0xfdfd('0xea')](_0x264f88)[_0xfdfd('0x4a')](function(_0x5c518a){logger['error'](_0xfdfd('0xeb'),_0x264f88,_0x5c518a);});}});};exports[_0xfdfd('0xec')]=function(_0x5195d4,_0x48eedb){return db[_0xfdfd('0xac')][_0xfdfd('0x51')]({'where':{'id':_0x5195d4[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x48eedb,null))[_0xfdfd('0x27')](function(_0x349138){if(_0x349138){return _0x349138[_0xfdfd('0xec')](_0x5195d4[_0xfdfd('0x55')][_0xfdfd('0x64')],_['omit'](_0x5195d4['body'],[_0xfdfd('0x64'),'id'])||{});}})[_0xfdfd('0x27')](respondWithResult(_0x48eedb,null))[_0xfdfd('0x4a')](handleError(_0x48eedb,null));};exports[_0xfdfd('0xed')]=function(_0x46cd5e,_0x521b04){var _0x40efe5={'raw':![],'where':{}};var _0x5c63fc={};var _0x4e17d2={'count':0x0,'rows':[]};return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0x46cd5e[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x521b04,null))[_0xfdfd('0x27')](function(_0x3e22f8){if(_0x3e22f8){_0x5c63fc[_0xfdfd('0x35')]=_['keys'](db[_0xfdfd('0xac')][_0xfdfd('0x5d')]);_0x5c63fc[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x46cd5e[_0xfdfd('0x36')]);_0x5c63fc[_0xfdfd('0x3f')]=_['intersection'](_0x5c63fc['model'],_0x5c63fc[_0xfdfd('0x36')]);_0x40efe5['attributes']=_[_0xfdfd('0x38')](_0x5c63fc['model'],qs['fields'](_0x46cd5e[_0xfdfd('0x36')]['fields']));_0x40efe5[_0xfdfd('0x39')]=_0x40efe5[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x40efe5['attributes']:_0x5c63fc[_0xfdfd('0x35')];if(!_0x46cd5e['query'][_0xfdfd('0x3c')]('nolimit')){_0x40efe5[_0xfdfd('0x23')]=qs[_0xfdfd('0x23')](_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x40efe5[_0xfdfd('0x21')]=qs[_0xfdfd('0x21')](_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0x21')]);}_0x40efe5[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x40efe5[_0xfdfd('0x42')]=qs['filters'](_[_0xfdfd('0x40')](_0x46cd5e[_0xfdfd('0x36')],_0x5c63fc[_0xfdfd('0x3f')]));_0x40efe5[_0xfdfd('0x42')][_0xfdfd('0x59')]=_0x3e22f8['id'];if(_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x40efe5[_0xfdfd('0x42')]=_[_0xfdfd('0x43')](_0x40efe5['where'],{'$or':_[_0xfdfd('0x31')](_0x40efe5[_0xfdfd('0x39')],function(_0x18016e){var _0x46f31e={};_0x46f31e[_0x18016e]={'$like':'%'+_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0x41')]+'%'};return _0x46f31e;})});}_0x40efe5=_['merge']({},_0x40efe5,_0x46cd5e[_0xfdfd('0x45')]);return db[_0xfdfd('0xac')]['count']({'where':_0x40efe5[_0xfdfd('0x42')]})['then'](function(_0x2478ac){_0x4e17d2[_0xfdfd('0x24')]=_0x2478ac;if(_0x46cd5e['query'][_0xfdfd('0x47')]){_0x40efe5[_0xfdfd('0x4d')]=[{'model':db[_0xfdfd('0x83')],'as':'Contact','required':![]},{'model':db[_0xfdfd('0xb9')],'as':_0xfdfd('0xee'),'attributes':[_0xfdfd('0x2d'),_0xfdfd('0xef'),_0xfdfd('0xf0')],'required':![]},{'model':db['Tag'],'as':_0xfdfd('0xf1'),'attributes':['id','name',_0xfdfd('0xf2')],'where':_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0xf3')]?{'id':_0x46cd5e[_0xfdfd('0x36')][_0xfdfd('0xf3')]}:undefined,'required':_0x46cd5e['query'][_0xfdfd('0xf3')]?!![]:![]}];}return db['ChatInteraction'][_0xfdfd('0x48')](_0x40efe5);})[_0xfdfd('0x27')](function(_0x3092a4){_0x4e17d2['rows']=_0x3092a4;return _0x4e17d2;});}})[_0xfdfd('0x27')](respondWithFilteredResult(_0x521b04,_0x40efe5))[_0xfdfd('0x4a')](handleError(_0x521b04,null));};function iftimePromise(_0x4828e4,_0x450437){return respondWithRpcPromise(_0xfdfd('0xf4'),'getSnippet',{'command':_0x450437[_0xfdfd('0xf5')]?util[_0xfdfd('0xa5')]('iftime\x20%s,%s',_0x4828e4['interval'],_0x450437[_0xfdfd('0xf5')]):util[_0xfdfd('0xa5')](_0xfdfd('0xf6'),_0x4828e4[_0xfdfd('0xf7')])},client9002)['then'](function(_0x3fa2ec){var _0xc7153=_0x3fa2ec&&_0x3fa2ec['indexOf']('true')>=0x0?!![]:![];logger['info'](_0xfdfd('0xf8'),_0x450437['id'],_0x4828e4['id'],_0x4828e4[_0xfdfd('0xf7')],_0xc7153?_0xfdfd('0xf9'):_0xfdfd('0xfa'),_0x450437[_0xfdfd('0xf5')]?_0x450437[_0xfdfd('0xf5')]:'No\x20timezone');return _0xc7153;})[_0xfdfd('0x4a')](function(_0x1fd92a){logger[_0xfdfd('0x1b')](_0xfdfd('0xf8'),_0x450437['id'],_0x4828e4['id'],_0x4828e4[_0xfdfd('0xf7')],util[_0xfdfd('0xfb')](_0x1fd92a,{'showHidden':![],'depth':null}),_0x450437[_0xfdfd('0xf5')]?_0x450437['timezone']:_0xfdfd('0xfc'));return![];});}exports['getSnippet']=function(_0x3656c3,_0x2efbdc){var _0x1c7402=0x0;var _0x1a7438=0x0;var _0x487dc1=![];var _0x35f79c;var _0x2a2a93;return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x3656c3[_0xfdfd('0x56')]['id']},'include':[{'model':db[_0xfdfd('0xfd')],'as':_0xfdfd('0xfd'),'include':[{'model':db[_0xfdfd('0xfd')],'as':_0xfdfd('0xfe'),'attributes':['id',_0xfdfd('0xf7')],'raw':!![]}]}]})[_0xfdfd('0x27')](handleEntityNotFound(_0x2efbdc,null))[_0xfdfd('0x27')](function(_0xb959bc){if(_0xb959bc){_0x35f79c=_0xb959bc;return _0xb959bc['getProactiveActions']({'raw':!![]});}})[_0xfdfd('0x27')](function(_0x29a848){if(_0x35f79c){if(_0x29a848){_0x2a2a93=_0x29a848;}}return require(_0xfdfd('0xff'))[_0xfdfd('0x100')]();})['then'](function(_0x5c20dc){if(_0x5c20dc){_0x1a7438=_0x5c20dc[_0xfdfd('0x101')];_0x487dc1=_0x5c20dc[_0xfdfd('0x71')];}})[_0xfdfd('0x27')](function(){return db[_0xfdfd('0xac')][_0xfdfd('0x24')]({'where':{'closed':![]}});})['then'](function(_0xc79749){_0x1c7402=_0xc79749;if(_0x1a7438&&_0xc79749>_0x1a7438){return db[_0xfdfd('0x102')][_0xfdfd('0x5c')]({'where':{'id':0x1}})[_0xfdfd('0x27')](function(_0x327484){if(_0x327484){_0x327484[_0xfdfd('0x103')](_0xfdfd('0x104'));}});}})[_0xfdfd('0x27')](function(){if(_0x35f79c[_0xfdfd('0xfd')]&&_0x35f79c[_0xfdfd('0xfd')]['Intervals']){var _0x525aa4=[];for(var _0xf2770=0x0;_0xf2770<_0x35f79c[_0xfdfd('0xfd')][_0xfdfd('0xfe')][_0xfdfd('0x3b')];_0xf2770++){var _0x23ef03=_0x35f79c['Interval'][_0xfdfd('0xfe')][_0xf2770]['get']({'plain':!![]});_0x525aa4[_0xfdfd('0xb3')](iftimePromise(_0x23ef03,_0x35f79c));}return BPromise[_0xfdfd('0x105')](_0x525aa4)[_0xfdfd('0x27')](function(_0x2163cc){return _[_0xfdfd('0x106')](_0x2163cc);});}else{return!![];}})[_0xfdfd('0x27')](function(_0x210b36){var _0x3ecd48=fs[_0xfdfd('0x107')](path[_0xfdfd('0x75')](config[_0xfdfd('0x6f')],_0xfdfd('0x108')),_0xfdfd('0xcb'));var _0x4d02b4=new url['URL'](_0x35f79c[_0xfdfd('0x109')])[_0xfdfd('0x10a')];var _0x2f6b78=_0xfdfd('0x10b');var _0x1d06f2=![];var _0x2c9a12={'chatVersion':_0x2f6b78,'chatWebsiteAddressOrigin':_0x4d02b4,'remote':_0x35f79c[_0xfdfd('0x10c')],'query':querystring[_0xfdfd('0x18')](_[_0xfdfd('0x43')](_0x35f79c[_0xfdfd('0x29')]({'plain':!![]}),{'customerIp':_0x3656c3['headers'][_0xfdfd('0x9c')]||_0x3656c3[_0xfdfd('0x80')][_0xfdfd('0x10d')]||_0x3656c3[_0xfdfd('0x10e')][_0xfdfd('0x10f')]||_0x3656c3['ip'],'referer':_0x3656c3['headers']['referer'],'openedInteractions':_0x1c7402,'maxInteractions':_0x1a7438,'virtual':_0x487dc1[_0xfdfd('0x101')],'online':_0x210b36,'custom':_0x487dc1}))[_0xfdfd('0x110')](/'/g,'\x5c\x27')};_0x2efbdc[_0xfdfd('0x2e')](ejs[_0xfdfd('0xcc')](Mustache['render'](_0x3ecd48,_0x2c9a12),{'proactiveActions':_0x2a2a93,'alignment':_0x35f79c[_0xfdfd('0x111')],'verticalAlignment':_0x35f79c[_0xfdfd('0x112')],'div_color':_0x35f79c[_0xfdfd('0xf2')],'labelText':_0x35f79c[_0xfdfd('0x113')],'text_color':_0x35f79c[_0xfdfd('0x114')],'text_button_color':_0x35f79c[_0xfdfd('0x115')],'button_color':_0x35f79c[_0xfdfd('0x116')],'background_color':_0x35f79c[_0xfdfd('0x117')],'hideWhenOffline':_0x35f79c[_0xfdfd('0x118')],'intervalId':_0x35f79c['IntervalId'],'isDevelopment':_0x1d06f2,'chatVersion':_0x2f6b78}));})[_0xfdfd('0x4a')](handleError(_0x2efbdc,null));};exports[_0xfdfd('0x119')]=function(_0x4f5280,_0x3541ff){var _0x15ac3d=_0x4f5280[_0xfdfd('0x56')]['id'];var _0x5d2358=_0x4f5280['body'];var _0x4bed71=0xc8;var _0x343bd3=null;return db['sequelize'][_0xfdfd('0xd6')]({'isolationLevel':db[_0xfdfd('0xd5')]['Transaction'][_0xfdfd('0x11a')][_0xfdfd('0x11b')]},function(_0x5109f9){return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0x15ac3d},'transaction':_0x5109f9})['then'](function(_0x12d119){if(_0x12d119){return db[_0xfdfd('0x93')][_0xfdfd('0x28')]({'where':{'ChatWebsiteId':_0x15ac3d},'transaction':_0x5109f9})['then'](function(){var _0x6baa8f=_[_0xfdfd('0x31')](_0x5d2358,function(_0x133e3e){_0x133e3e[_0xfdfd('0x59')]=_0x15ac3d;return _0x133e3e;});return db['ChatApplication'][_0xfdfd('0xd8')](_0x6baa8f,{'transaction':_0x5109f9});});}else{_0x4bed71=0x194;_0x343bd3=[];}});})['then'](function(){if(_0x4bed71!==0x194){return db[_0xfdfd('0x93')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x15ac3d},'order':_0xfdfd('0x99')})['then'](function(_0x556c03){_0x343bd3=_0x556c03;});}})[_0xfdfd('0x4a')](function(_0x55d026){_0x4bed71=0x1f4;logger[_0xfdfd('0x1b')](_0x55d026[_0xfdfd('0x2c')]);if(_0x55d026[_0xfdfd('0x2d')]){delete _0x55d026[_0xfdfd('0x2d')];}_0x343bd3=_0x55d026;})[_0xfdfd('0x11c')](function(){if(_0x343bd3===null){_0x3541ff[_0xfdfd('0x1d')](_0x4bed71);}else{if(_0x4bed71===0x1f4){_0x3541ff[_0xfdfd('0x1e')](_0x4bed71)[_0xfdfd('0x2e')](_0x343bd3);}else{_0x3541ff[_0xfdfd('0x1e')](_0x4bed71)[_0xfdfd('0x20')](_0x343bd3);}}});};exports[_0xfdfd('0x11d')]=function(_0x18b65e,_0x1e4cf5){var _0x1aa118={};var _0x4d4432={};var _0x52f279;var _0x410753;return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0x18b65e[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x1e4cf5,null))['then'](function(_0xc6ab3e){if(_0xc6ab3e){_0x52f279=_0xc6ab3e;_0x4d4432[_0xfdfd('0x35')]=_[_0xfdfd('0x37')](db[_0xfdfd('0x93')][_0xfdfd('0x5d')]);_0x4d4432[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x18b65e[_0xfdfd('0x36')]);_0x4d4432[_0xfdfd('0x3f')]=_['intersection'](_0x4d4432[_0xfdfd('0x35')],_0x4d4432[_0xfdfd('0x36')]);_0x1aa118['attributes']=_['intersection'](_0x4d4432[_0xfdfd('0x35')],qs[_0xfdfd('0x3a')](_0x18b65e[_0xfdfd('0x36')][_0xfdfd('0x3a')]));_0x1aa118['attributes']=_0x1aa118['attributes']['length']?_0x1aa118['attributes']:_0x4d4432[_0xfdfd('0x35')];_0x1aa118[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x18b65e[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x1aa118[_0xfdfd('0x42')]=qs['filters'](_[_0xfdfd('0x40')](_0x18b65e[_0xfdfd('0x36')],_0x4d4432['filters']));if(_0x18b65e['query'][_0xfdfd('0x41')]){_0x1aa118['where']=_[_0xfdfd('0x43')](_0x1aa118['where'],{'$or':_[_0xfdfd('0x31')](_0x1aa118[_0xfdfd('0x39')],function(_0x1790ca){var _0x18470e={};_0x18470e[_0x1790ca]={'$like':'%'+_0x18b65e[_0xfdfd('0x36')][_0xfdfd('0x41')]+'%'};return _0x18470e;})});}_0x1aa118=_[_0xfdfd('0x43')]({},_0x1aa118,_0x18b65e[_0xfdfd('0x45')]);return _0x52f279[_0xfdfd('0x11d')](_0x1aa118);}})['then'](function(_0x3bca92){if(_0x3bca92){_0x410753=_0x3bca92[_0xfdfd('0x3b')];if(!_0x18b65e[_0xfdfd('0x36')][_0xfdfd('0x3c')](_0xfdfd('0x3d'))){_0x1aa118[_0xfdfd('0x23')]=qs[_0xfdfd('0x23')](_0x18b65e[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x1aa118[_0xfdfd('0x21')]=qs[_0xfdfd('0x21')](_0x18b65e[_0xfdfd('0x36')]['offset']);}return _0x52f279[_0xfdfd('0x11d')](_0x1aa118);}})[_0xfdfd('0x27')](function(_0x4391a4){if(_0x4391a4){return _0x4391a4?{'count':_0x410753,'rows':_0x4391a4}:null;}})['then'](respondWithResult(_0x1e4cf5,null))['catch'](handleError(_0x1e4cf5,null));};exports['addProactiveActions']=function(_0x474727,_0x52f507){return db['chatProactiveAction'][_0xfdfd('0x51')]({'where':{'id':_0x474727[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x52f507,null))['then'](function(_0x353aef){if(_0x353aef){return _0x353aef['addProactiveActions'](_0x474727[_0xfdfd('0x55')][_0xfdfd('0x64')],_[_0xfdfd('0x11e')](_0x474727[_0xfdfd('0x55')],['ids','id'])||{});}})[_0xfdfd('0x27')](respondWithResult(_0x52f507,null))[_0xfdfd('0x4a')](handleError(_0x52f507,null));};exports[_0xfdfd('0x11f')]=function(_0x5932ff,_0x306970){var _0x332d51={};var _0xbec890={};var _0x52eaac;var _0x2ce6fb;return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0x5932ff['params']['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x306970,null))[_0xfdfd('0x27')](function(_0x2ee742){if(_0x2ee742){_0x52eaac=_0x2ee742;_0xbec890['model']=_[_0xfdfd('0x37')](db[_0xfdfd('0x120')][_0xfdfd('0x5d')]);_0xbec890[_0xfdfd('0x36')]=_['keys'](_0x5932ff[_0xfdfd('0x36')]);_0xbec890[_0xfdfd('0x3f')]=_[_0xfdfd('0x38')](_0xbec890[_0xfdfd('0x35')],_0xbec890['query']);_0x332d51[_0xfdfd('0x39')]=_['intersection'](_0xbec890[_0xfdfd('0x35')],qs[_0xfdfd('0x3a')](_0x5932ff[_0xfdfd('0x36')]['fields']));_0x332d51['attributes']=_0x332d51[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x332d51['attributes']:_0xbec890['model'];_0x332d51[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x5932ff[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x332d51[_0xfdfd('0x42')]=qs[_0xfdfd('0x3f')](_[_0xfdfd('0x40')](_0x5932ff['query'],_0xbec890[_0xfdfd('0x3f')]));if(_0x5932ff[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x332d51[_0xfdfd('0x42')]=_['merge'](_0x332d51[_0xfdfd('0x42')],{'$or':_[_0xfdfd('0x31')](_0x332d51['attributes'],function(_0x58673c){var _0x715c03={};_0x715c03[_0x58673c]={'$like':'%'+_0x5932ff['query']['filter']+'%'};return _0x715c03;})});}_0x332d51=_[_0xfdfd('0x43')]({},_0x332d51,_0x5932ff[_0xfdfd('0x45')]);return _0x52eaac[_0xfdfd('0x11f')](_0x332d51);}})[_0xfdfd('0x27')](function(_0x4fe45e){if(_0x4fe45e){_0x2ce6fb=_0x4fe45e['length'];if(!_0x5932ff[_0xfdfd('0x36')][_0xfdfd('0x3c')]('nolimit')){_0x332d51[_0xfdfd('0x23')]=qs[_0xfdfd('0x23')](_0x5932ff[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x332d51[_0xfdfd('0x21')]=qs[_0xfdfd('0x21')](_0x5932ff['query'][_0xfdfd('0x21')]);}return _0x52eaac[_0xfdfd('0x11f')](_0x332d51);}})[_0xfdfd('0x27')](function(_0x28f8d5){if(_0x28f8d5){return _0x28f8d5?{'count':_0x2ce6fb,'rows':_0x28f8d5}:null;}})['then'](respondWithResult(_0x306970,null))['catch'](handleError(_0x306970,null));};exports['getFields']=function(_0x1fa73f,_0x430971){var _0x1f6449=_0x1fa73f[_0xfdfd('0x36')][_0xfdfd('0x121')]===_0xfdfd('0x122')?_0xfdfd('0x123'):_0xfdfd('0x124');return db[_0xfdfd('0x46')]['find']({'attributes':['id',_0x1f6449],'where':{'id':_0x1fa73f[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x430971,null))[_0xfdfd('0x27')](function(_0x3cbdf4){if(_0x3cbdf4){var _0x1c3961=_0x3cbdf4[_0x1f6449];var _0x32117f=_0x1c3961&&_0x1c3961[_0xfdfd('0x125')]?_0x1c3961[_0xfdfd('0x125')]:[];_0x430971['send']({'fromKey':_['isNil'](_0x1c3961['fromKey'])?undefined:_0x1c3961[_0xfdfd('0x126')],'count':_0x32117f['length'],'rows':_0x32117f});}})['catch'](handleError(_0x430971,null));};exports[_0xfdfd('0x127')]=function(_0x247e12,_0x11c504){var _0x42d987={'raw':![],'where':{}};var _0x6444c={};var _0x598017={'count':0x0,'rows':[]};return db[_0xfdfd('0x46')][_0xfdfd('0x5c')]({'where':{'id':_0x247e12[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x11c504,null))[_0xfdfd('0x27')](function(_0x1cb968){if(_0x1cb968){_0x6444c['model']=_['keys'](db[_0xfdfd('0x128')]['rawAttributes']);_0x6444c[_0xfdfd('0x36')]=_['keys'](_0x247e12['query']);_0x6444c[_0xfdfd('0x3f')]=_['intersection'](_0x6444c[_0xfdfd('0x35')],_0x6444c[_0xfdfd('0x36')]);_0x42d987[_0xfdfd('0x39')]=_[_0xfdfd('0x38')](_0x6444c[_0xfdfd('0x35')],qs[_0xfdfd('0x3a')](_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x3a')]));_0x42d987[_0xfdfd('0x39')]=_0x42d987[_0xfdfd('0x39')][_0xfdfd('0x3b')]?_0x42d987[_0xfdfd('0x39')]:_0x6444c[_0xfdfd('0x35')];if(!_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x3c')]('nolimit')){_0x42d987[_0xfdfd('0x23')]=qs[_0xfdfd('0x23')](_0x247e12[_0xfdfd('0x36')]['limit']);_0x42d987[_0xfdfd('0x21')]=qs['offset'](_0x247e12[_0xfdfd('0x36')]['offset']);}_0x42d987[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x42d987[_0xfdfd('0x42')]=qs[_0xfdfd('0x3f')](_[_0xfdfd('0x40')](_0x247e12[_0xfdfd('0x36')],_0x6444c['filters']));_0x42d987['where']['ChatWebsiteId']=_0x1cb968['id'];if(_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x42d987['where']=_[_0xfdfd('0x43')](_0x42d987[_0xfdfd('0x42')],{'$or':_['map'](_0x42d987['attributes'],function(_0x4124a3){var _0x237629={};_0x237629[_0x4124a3]={'$like':'%'+_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x41')]+'%'};return _0x237629;})});}_0x42d987=_[_0xfdfd('0x43')]({},_0x42d987,_0x247e12[_0xfdfd('0x45')]);return db[_0xfdfd('0x128')]['count']({'where':_0x42d987[_0xfdfd('0x42')]})[_0xfdfd('0x27')](function(_0x267afd){_0x598017[_0xfdfd('0x24')]=_0x267afd;if(_0x247e12[_0xfdfd('0x36')][_0xfdfd('0x47')]){_0x42d987[_0xfdfd('0x4d')]=[{'all':!![]}];}else{_0x42d987[_0xfdfd('0x4d')]=[{'model':db[_0xfdfd('0x83')],'as':_0xfdfd('0x129'),'required':![]},{'model':db[_0xfdfd('0xd7')],'as':_0xfdfd('0x12a'),'required':![]}];}return db['ChatOfflineMessage'][_0xfdfd('0x48')](_0x42d987);})[_0xfdfd('0x27')](function(_0x54b132){_0x598017[_0xfdfd('0x49')]=_0x54b132;return _0x598017;});}})[_0xfdfd('0x27')](respondWithFilteredResult(_0x11c504,_0x42d987))['catch'](handleError(_0x11c504,null));};exports['addAgents']=function(_0x122bda,_0x29eced){return db[_0xfdfd('0x46')][_0xfdfd('0x51')]({'where':{'id':_0x122bda[_0xfdfd('0x56')]['id']}})['then'](handleEntityNotFound(_0x29eced,null))[_0xfdfd('0x27')](function(_0x53a06c){if(_0x53a06c){return _0x53a06c[_0xfdfd('0x12b')](_0x122bda[_0xfdfd('0x55')][_0xfdfd('0x64')],_[_0xfdfd('0x11e')](_0x122bda[_0xfdfd('0x55')],['ids','id'])||{})['spread'](function(_0x32bfad){for(var _0x3953c0=0x0;_0x3953c0<_0x122bda[_0xfdfd('0x55')][_0xfdfd('0x64')][_0xfdfd('0x3b')];_0x3953c0+=0x1){socket['emit']('userChatWebsite:save',{'UserId':Number(_0x122bda[_0xfdfd('0x55')][_0xfdfd('0x64')][_0x3953c0]),'ChatWebsiteId':Number(_0x122bda[_0xfdfd('0x56')]['id'])});}return _0x32bfad;});}})[_0xfdfd('0x27')](respondWithResult(_0x29eced,null))[_0xfdfd('0x4a')](handleError(_0x29eced,null));};exports[_0xfdfd('0x12c')]=function(_0x12c32a,_0x245ac1){return db['ChatWebsite']['find']({'where':{'id':_0x12c32a[_0xfdfd('0x56')]['id']}})[_0xfdfd('0x27')](handleEntityNotFound(_0x245ac1,null))[_0xfdfd('0x27')](function(_0x1d7dec){if(_0x1d7dec){return _0x1d7dec[_0xfdfd('0x12c')](_0x12c32a['query']['ids'])[_0xfdfd('0x27')](function(){if(_[_0xfdfd('0x12d')](_0x12c32a[_0xfdfd('0x36')]['ids'])){for(var _0x261cef=0x0;_0x261cef<_0x12c32a['query']['ids'][_0xfdfd('0x3b')];_0x261cef+=0x1){socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x12c32a[_0xfdfd('0x36')][_0xfdfd('0x64')][_0x261cef]),'ChatWebsiteId':Number(_0x12c32a['params']['id'])});}}else{socket[_0xfdfd('0x12e')]('userChatWebsite:remove',{'UserId':Number(_0x12c32a['query']['ids']),'ChatWebsiteId':Number(_0x12c32a[_0xfdfd('0x56')]['id'])});}});}})[_0xfdfd('0x27')](respondWithStatusCode(_0x245ac1,null))[_0xfdfd('0x4a')](handleError(_0x245ac1,null));};exports[_0xfdfd('0x12f')]=function(_0x25c849,_0x365d5c){var _0x4e4057={};var _0x4656cb={};var _0x568bca;var _0x827539;return db['ChatWebsite'][_0xfdfd('0x5c')]({'where':{'id':_0x25c849[_0xfdfd('0x56')]['id']}})['then'](handleEntityNotFound(_0x365d5c,null))[_0xfdfd('0x27')](function(_0x2fa15a){if(_0x2fa15a){_0x568bca=_0x2fa15a;_0x4656cb[_0xfdfd('0x35')]=_[_0xfdfd('0x37')](db[_0xfdfd('0xb9')]['rawAttributes']);_0x4656cb[_0xfdfd('0x36')]=_[_0xfdfd('0x37')](_0x25c849['query']);_0x4656cb['filters']=_[_0xfdfd('0x38')](_0x4656cb[_0xfdfd('0x35')],_0x4656cb[_0xfdfd('0x36')]);_0x4e4057[_0xfdfd('0x39')]=_[_0xfdfd('0x38')](_0x4656cb[_0xfdfd('0x35')],qs['fields'](_0x25c849[_0xfdfd('0x36')][_0xfdfd('0x3a')]));_0x4e4057['attributes']=_0x4e4057[_0xfdfd('0x39')]['length']?_0x4e4057[_0xfdfd('0x39')]:_0x4656cb[_0xfdfd('0x35')];_0x4e4057[_0xfdfd('0x5e')]=qs[_0xfdfd('0x3e')](_0x25c849[_0xfdfd('0x36')][_0xfdfd('0x3e')]);_0x4e4057[_0xfdfd('0x42')]=qs[_0xfdfd('0x3f')](_['pick'](_0x25c849[_0xfdfd('0x36')],_0x4656cb[_0xfdfd('0x3f')]));if(_0x25c849[_0xfdfd('0x36')][_0xfdfd('0x41')]){_0x4e4057[_0xfdfd('0x42')]=_[_0xfdfd('0x43')](_0x4e4057['where'],{'$or':_[_0xfdfd('0x31')](_0x4e4057['attributes'],function(_0x325e88){var _0x730e6c={};_0x730e6c[_0x325e88]={'$like':'%'+_0x25c849['query'][_0xfdfd('0x41')]+'%'};return _0x730e6c;})});}_0x4e4057=_[_0xfdfd('0x43')]({},_0x4e4057,_0x25c849[_0xfdfd('0x45')]);return _0x568bca[_0xfdfd('0x12f')](_0x4e4057);}})[_0xfdfd('0x27')](function(_0x2d0840){if(_0x2d0840){_0x827539=_0x2d0840['length'];if(!_0x25c849[_0xfdfd('0x36')]['hasOwnProperty'](_0xfdfd('0x3d'))){_0x4e4057[_0xfdfd('0x23')]=qs[_0xfdfd('0x23')](_0x25c849[_0xfdfd('0x36')][_0xfdfd('0x23')]);_0x4e4057['offset']=qs['offset'](_0x25c849[_0xfdfd('0x36')]['offset']);}return _0x568bca[_0xfdfd('0x12f')](_0x4e4057);}})[_0xfdfd('0x27')](function(_0x269840){if(_0x269840){return _0x269840?{'count':_0x827539,'rows':_0x269840}:null;}})[_0xfdfd('0x27')](respondWithResult(_0x365d5c,null))['catch'](handleError(_0x365d5c,null));};
\ No newline at end of file
+var _0xee46=['first','split','firstName','lastName','x-real-port','version','format','%s\x20%s','browser','unknown','device','model','vendor','%s\x20%s\x20%s','type','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','keys','query','intersection','attributes','fields','length','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','address','body','\x22\x20is\x20not\x20a\x20valid\x20website\x20domain','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','describe','addDisposition','ChatWebsiteId','Disposition','hasOwnProperty','removeDispositions','ids','CannedAnswer','findOne','nolimit','removeAnswers','addLogo','sitepic','filename','addAvatar','file','addCustomerAvatar','systemAvatar','getLogo','join','root','../../config/license/util','custom','isNil','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','agentAvatar','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','timezone','ifTime','notify','chat','from','From\x20is\x20mandatory','mapKey','MapKey\x20is\x20mandatory','isEmpty','Body\x20is\x20mandatory','referer','CmContact','No\x20available\x20attributes','includes','createdAt','ListId','Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','CmList','List','Contacts','updatedAt','DESC','ChatApplication','Applications','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','applications','priority','list','contact','headers','threadId','closed','externalUrl','ChatInteraction','ContactId','interaction','messageId','created','account','autoclose','push','close','unmanaged','*,*,*,*','ChatMessage','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','queueId','waitForTheAssignedQueue','Start','startRouting','EventManager','files','Sequelize','ValidationError','no\x20available\x20attributes','CompanyId','send','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','render','toPairs','offlineMessageBody','fromString','originalname','mimetype','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','bulkCreate','MailServerOut','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','Chat','MailAccountId','NotifyMailAccount','notifyMail','addInteraction','fullname','internal','Tags','tag','getSnippet','getProactiveActions','getLicense','virtual','License','increment','chatLicenseExceeded','server/files/chat/iframe.ejs','3.9.0','origin','replace','testWebsiteWithWildcard','x-real-ip','connection','alignment','color','labelText','textColor','textButtonColor','backgroundColor','addApplications','sequelize','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','stack','finally','getApplications','addProactiveActions','chatProactiveAction','omit','getFields','online','false','offlineForm','items','fromKey','ChatOfflineMessage','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','util','path','ejs','fs-extra','lodash','querystring','ioredis','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','APIBadRequestError','../../errors/api','APINotFoundError','APIOutOfIntervalError','handleError','APIConflictError','./helpers/wildcard-expressions','URL','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','client','http','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatWebsite,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','limit','undefined','count','offset','Content-Range','update','destroy','ChatWebsites','UserProfileResource','name','user-agent-parser','setUA','user-agent','customerIp','x-forwarded-for'];(function(_0x4fe5b5,_0x41efab){var _0x221fbe=function(_0x35fd94){while(--_0x35fd94){_0x4fe5b5['push'](_0x4fe5b5['shift']());}};_0x221fbe(++_0x41efab);}(_0xee46,0xf2));var _0x6ee4=function(_0x246251,_0x5974c0){_0x246251=_0x246251-0x0;var _0x58d5ee=_0xee46[_0x246251];return _0x58d5ee;};'use strict';var Mustache=require('mustache');var util=require(_0x6ee4('0x0'));var path=require(_0x6ee4('0x1'));var ejs=require(_0x6ee4('0x2'));var fs=require('fs');var fs_extra=require(_0x6ee4('0x3'));var _=require(_0x6ee4('0x4'));var querystring=require(_0x6ee4('0x5'));var htmlToText=require('html-to-text');var Redis=require(_0x6ee4('0x6'));var jayson=require(_0x6ee4('0x7'));var qs=require(_0x6ee4('0x8'));var logger=require(_0x6ee4('0x9'))(_0x6ee4('0xa'));var config=require(_0x6ee4('0xb'));var APIBadRequestError=require('../../errors/api')[_0x6ee4('0xc')];var APINotFoundError=require(_0x6ee4('0xd'))[_0x6ee4('0xe')];var APIOutOfIntervalError=require(_0x6ee4('0xd'))[_0x6ee4('0xf')];var APIHandleError=require(_0x6ee4('0xd'))[_0x6ee4('0x10')];var APIConflictError=require(_0x6ee4('0xd'))[_0x6ee4('0x11')];var wildcardUtils=require(_0x6ee4('0x12'));var URL=require('url')[_0x6ee4('0x13')];var db=require('../../mysqldb')['db'];config[_0x6ee4('0x14')]=_[_0x6ee4('0x15')](config['redis'],{'host':_0x6ee4('0x16'),'port':0x18eb});var socket=require(_0x6ee4('0x17'))(new Redis(config['redis']));require(_0x6ee4('0x18'))[_0x6ee4('0x19')](socket);var client=jayson[_0x6ee4('0x1a')]['http']({'port':0x232c});var client9002=jayson['client'][_0x6ee4('0x1b')]({'port':0x232a});var client9003=jayson[_0x6ee4('0x1a')][_0x6ee4('0x1b')]({'port':0x232b});var client9001=jayson[_0x6ee4('0x1a')][_0x6ee4('0x1b')]({'port':0x2329});function respondWithRpcPromise(_0x2eca80,_0x4af711,_0x2af5f8,_0x4ba6dc){return new Promise(function(_0x2886c2,_0x4c1192){var _0x9d4ae8=_0x4ba6dc||client;return _0x9d4ae8['request'](_0x2eca80,_0x2af5f8)[_0x6ee4('0x1c')](function(_0x3cdcae){logger[_0x6ee4('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x4af711,_0x6ee4('0x1e'));logger[_0x6ee4('0x1f')](_0x6ee4('0x20'),_0x4af711,'request\x20sent',JSON[_0x6ee4('0x21')](_0x3cdcae));if(_0x3cdcae[_0x6ee4('0x22')]){if(_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x23')]===0x1f4){logger[_0x6ee4('0x22')](_0x6ee4('0x24'),_0x4af711,_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x25')]);return _0x4c1192(_0x3cdcae[_0x6ee4('0x22')]['message']);}logger[_0x6ee4('0x22')](_0x6ee4('0x24'),_0x4af711,_0x3cdcae[_0x6ee4('0x22')][_0x6ee4('0x25')]);return _0x2886c2(_0x3cdcae[_0x6ee4('0x22')]['message']);}else{logger[_0x6ee4('0x1d')](_0x6ee4('0x24'),_0x4af711,_0x6ee4('0x1e'));_0x2886c2(_0x3cdcae[_0x6ee4('0x26')]['message']);}})[_0x6ee4('0x27')](function(_0x293d0b){logger[_0x6ee4('0x22')]('ChatWebsite,\x20%s,\x20%s',_0x4af711,_0x293d0b);_0x4c1192(_0x293d0b);});});}function respondWithStatusCode(_0x5639e5,_0x520dd2){_0x520dd2=_0x520dd2||0xcc;return function(_0x18efa3){if(_0x18efa3){return _0x5639e5[_0x6ee4('0x28')](_0x520dd2);}return _0x5639e5[_0x6ee4('0x29')](_0x520dd2)[_0x6ee4('0x2a')]();};}function respondWithResult(_0xf76d23,_0x22a43e){_0x22a43e=_0x22a43e||0xc8;return function(_0x5784a0){if(_0x5784a0){return _0xf76d23[_0x6ee4('0x29')](_0x22a43e)[_0x6ee4('0x2b')](_0x5784a0);}};}function respondWithFilteredResult(_0x2eab8a,_0x2fcb80){return function(_0x48b762){if(_0x48b762){var _0x2193b1=typeof _0x2fcb80['offset']==='undefined'&&typeof _0x2fcb80[_0x6ee4('0x2c')]===_0x6ee4('0x2d');var _0x11fafb=_0x48b762[_0x6ee4('0x2e')];var _0x4f1481=_0x2193b1?0x0:_0x2fcb80[_0x6ee4('0x2f')];var _0x1e53f9=_0x2193b1?_0x48b762[_0x6ee4('0x2e')]:_0x2fcb80[_0x6ee4('0x2f')]+_0x2fcb80[_0x6ee4('0x2c')];var _0x4da82d;if(_0x1e53f9>=_0x11fafb){_0x1e53f9=_0x11fafb;_0x4da82d=0xc8;}else{_0x4da82d=0xce;}_0x2eab8a['status'](_0x4da82d);return _0x2eab8a['set'](_0x6ee4('0x30'),_0x4f1481+'-'+_0x1e53f9+'/'+_0x11fafb)[_0x6ee4('0x2b')](_0x48b762);}return null;};}function saveUpdates(_0x33bcb0){return function(_0x132291){if(_0x132291){return _0x132291[_0x6ee4('0x31')](_0x33bcb0)[_0x6ee4('0x1c')](function(_0x19ed72){return _0x19ed72;});}return null;};}function removeEntity(_0x54b88c){return function(_0x5273bc){if(_0x5273bc){return _0x5273bc[_0x6ee4('0x32')]()[_0x6ee4('0x1c')](function(){var _0x2a6d38=_0x5273bc['get']({'plain':!![]});var _0x15d653=_0x6ee4('0x33');return db[_0x6ee4('0x34')][_0x6ee4('0x32')]({'where':{'type':_0x15d653,'resourceId':_0x2a6d38['id']}})[_0x6ee4('0x1c')](function(){return _0x5273bc;});})[_0x6ee4('0x1c')](function(){_0x54b88c['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x258e0f){return function(_0x2ec82f){if(!_0x2ec82f){_0x258e0f[_0x6ee4('0x28')](0x194);}return _0x2ec82f;};}function handleError(_0x5a6e44,_0x1de2b4){_0x1de2b4=_0x1de2b4||0x1f4;return function(_0x26abb0){logger[_0x6ee4('0x22')](_0x26abb0['stack']);if(_0x26abb0[_0x6ee4('0x35')]){delete _0x26abb0[_0x6ee4('0x35')];}_0x5a6e44[_0x6ee4('0x29')](_0x1de2b4)['send'](_0x26abb0);};}function createInteractionObject(_0x1215e5,_0x26e5cb,_0x42399c,_0x5eb568){var _0x5f0e3f=require(_0x6ee4('0x36'));var _0x45b871=new _0x5f0e3f();var _0x575e97=_0x45b871[_0x6ee4('0x37')](_0x42399c[_0x6ee4('0x38')])['getResult']();var _0x3b48e3=_0x26e5cb[_0x6ee4('0x39')];if(_0x42399c['cf-connecting-ip']){_0x3b48e3=_0x42399c['cf-connecting-ip'];}else if(_0x42399c[_0x6ee4('0x3a')]){_0x3b48e3=_[_0x6ee4('0x3b')](_0x42399c['x-forwarded-for'][_0x6ee4('0x3c')](','));}return{'ContactId':_0x5eb568['id'],'ChatWebsiteId':_0x1215e5,'from':(_0x5eb568[_0x6ee4('0x3d')]||'')+'\x20'+(_0x5eb568[_0x6ee4('0x3e')]||''),'customerIp':_0x3b48e3,'customerPort':_0x42399c[_0x6ee4('0x3f')]?_0x42399c[_0x6ee4('0x3f')]:null,'referer':_0x26e5cb['referer'],'browserName':_0x575e97['browser'][_0x6ee4('0x35')]&&_0x575e97['browser'][_0x6ee4('0x40')]?util[_0x6ee4('0x41')](_0x6ee4('0x42'),_0x575e97[_0x6ee4('0x43')][_0x6ee4('0x35')],_0x575e97[_0x6ee4('0x43')][_0x6ee4('0x40')]):_0x6ee4('0x44'),'browserVersion':_0x575e97[_0x6ee4('0x43')]['version']||'unknown','osName':util[_0x6ee4('0x41')](_0x6ee4('0x42'),_0x575e97['os'][_0x6ee4('0x35')],_0x575e97['os'][_0x6ee4('0x40')]),'osVersion':_0x575e97['os'][_0x6ee4('0x40')],'deviceModel':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x46')]&&_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x47')]?util[_0x6ee4('0x41')](_0x6ee4('0x48'),_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x46')],_0x575e97['device'][_0x6ee4('0x47')],_0x575e97['device'][_0x6ee4('0x49')]):null,'deviceVendor':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x47')],'deviceType':_0x575e97[_0x6ee4('0x45')][_0x6ee4('0x49')],'formData':JSON[_0x6ee4('0x21')](_0x26e5cb)};}exports['index']=function(_0x115a29,_0x19443c){var _0x314963={'include':[{'model':db[_0x6ee4('0x4a')],'as':_0x6ee4('0x4b')}]},_0x303510={},_0x5c4880={'count':0x0,'rows':[]};var _0xa5771a=_[_0x6ee4('0x4c')](db[_0x6ee4('0x4d')][_0x6ee4('0x4e')],function(_0x43b31d){return{'name':_0x43b31d[_0x6ee4('0x4f')],'type':_0x43b31d[_0x6ee4('0x49')]['key']};});_0x303510[_0x6ee4('0x46')]=_[_0x6ee4('0x4c')](_0xa5771a,_0x6ee4('0x35'));_0x303510['query']=_[_0x6ee4('0x50')](_0x115a29[_0x6ee4('0x51')]);_0x303510['filters']=_[_0x6ee4('0x52')](_0x303510[_0x6ee4('0x46')],_0x303510[_0x6ee4('0x51')]);_0x314963[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x303510[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x314963[_0x6ee4('0x53')]=_0x314963['attributes'][_0x6ee4('0x55')]?_0x314963['attributes']:_0x303510[_0x6ee4('0x46')];if(!_0x115a29[_0x6ee4('0x51')]['hasOwnProperty']('nolimit')){_0x314963[_0x6ee4('0x2c')]=qs['limit'](_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x314963['offset']=qs['offset'](_0x115a29[_0x6ee4('0x51')]['offset']);}_0x314963[_0x6ee4('0x56')]=qs[_0x6ee4('0x57')](_0x115a29[_0x6ee4('0x51')]['sort']);_0x314963[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x115a29['query'],_0x303510['filters']),_0xa5771a);if(_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x314963[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x314963[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0xa5771a,function(_0x51623b){if(_0x51623b[_0x6ee4('0x49')]!==_0x6ee4('0x5d')){var _0x1dfc51={};_0x1dfc51[_0x51623b[_0x6ee4('0x35')]]={'$like':'%'+_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x1dfc51;}})});}_0x314963=_[_0x6ee4('0x5c')]({},_0x314963,_0x115a29[_0x6ee4('0x5e')]);var _0x2dfbbe={'where':_0x314963[_0x6ee4('0x58')]};return db[_0x6ee4('0x4d')][_0x6ee4('0x2e')](_0x2dfbbe)[_0x6ee4('0x1c')](function(_0x37deb3){_0x5c4880[_0x6ee4('0x2e')]=_0x37deb3;if(_0x115a29[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x314963[_0x6ee4('0x60')]=[{'all':!![]}];}return db['ChatWebsite'][_0x6ee4('0x61')](_0x314963);})['then'](function(_0x413aa2){_0x5c4880[_0x6ee4('0x62')]=_0x413aa2;return _0x5c4880;})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x19443c,_0x314963))[_0x6ee4('0x27')](handleError(_0x19443c,null));};exports[_0x6ee4('0x63')]=function(_0x3f3480,_0x2683f1){var _0x3e6d47={'raw':![],'where':{'id':_0x3f3480[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0x4a')],'as':'mandatoryDispositionPause'}]},_0x3f209c={};_0x3f209c[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x4d')]['rawAttributes']);_0x3f209c[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x3f3480[_0x6ee4('0x51')]);_0x3f209c[_0x6ee4('0x59')]=_[_0x6ee4('0x52')](_0x3f209c[_0x6ee4('0x46')],_0x3f209c[_0x6ee4('0x51')]);_0x3e6d47[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x3f209c[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x3f3480[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3e6d47['attributes']=_0x3e6d47[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x3e6d47[_0x6ee4('0x53')]:_0x3f209c[_0x6ee4('0x46')];if(_0x3f3480[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x3e6d47[_0x6ee4('0x60')]=[{'all':!![]}];}_0x3e6d47=_[_0x6ee4('0x5c')]({},_0x3e6d47,_0x3f3480[_0x6ee4('0x5e')]);return db['ChatWebsite'][_0x6ee4('0x65')](_0x3e6d47)[_0x6ee4('0x1c')](handleEntityNotFound(_0x2683f1,null))[_0x6ee4('0x1c')](respondWithResult(_0x2683f1,null))[_0x6ee4('0x27')](handleError(_0x2683f1,null));};exports[_0x6ee4('0x66')]=function(_0x569bab,_0x16d65c){if(!wildcardUtils['testWildcardValidity'](_0x569bab['body'][_0x6ee4('0x67')])){return handleError(_0x16d65c,null)(new APIBadRequestError('\x22'+_0x569bab[_0x6ee4('0x68')][_0x6ee4('0x67')]+_0x6ee4('0x69')));}return db[_0x6ee4('0x4d')][_0x6ee4('0x66')](_0x569bab['body'],{})[_0x6ee4('0x1c')](function(_0x16dae9){var _0x18fa52=_0x569bab[_0x6ee4('0x6a')][_0x6ee4('0x6b')]({'plain':!![]});if(!_0x18fa52)throw new Error(_0x6ee4('0x6c'));if(_0x18fa52['role']===_0x6ee4('0x6a')){var _0x34d4a7=_0x16dae9[_0x6ee4('0x6b')]({'plain':!![]});var _0x106156='ChatWebsites';return db[_0x6ee4('0x6d')][_0x6ee4('0x65')]({'where':{'name':_0x106156,'userProfileId':_0x18fa52[_0x6ee4('0x6e')]},'raw':!![]})[_0x6ee4('0x1c')](function(_0x3dcb65){if(_0x3dcb65&&_0x3dcb65['autoAssociation']===0x0){return db[_0x6ee4('0x34')][_0x6ee4('0x66')]({'name':_0x34d4a7[_0x6ee4('0x35')],'resourceId':_0x34d4a7['id'],'type':_0x3dcb65[_0x6ee4('0x35')],'sectionId':_0x3dcb65['id']},{})[_0x6ee4('0x1c')](function(){return _0x16dae9;});}else{return _0x16dae9;}})[_0x6ee4('0x27')](function(_0x49498f){logger[_0x6ee4('0x22')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x49498f);throw _0x49498f;});}return _0x16dae9;})[_0x6ee4('0x1c')](respondWithResult(_0x16d65c,0xc9))[_0x6ee4('0x27')](handleError(_0x16d65c,null));};exports[_0x6ee4('0x31')]=function(_0x372986,_0x5a70ba){if(!wildcardUtils['testWildcardValidity'](_0x372986['body'][_0x6ee4('0x67')])){return handleError(_0x5a70ba,null)(new APIBadRequestError('\x22'+_0x372986[_0x6ee4('0x68')]['address']+'\x22\x20is\x20not\x20a\x20valid\x20website\x20domain'));}if(_0x372986['body']['id']){delete _0x372986[_0x6ee4('0x68')]['id'];}return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x372986[_0x6ee4('0x64')]['id']},'include':[{'model':db['Pause'],'as':_0x6ee4('0x4b')}]})['then'](handleEntityNotFound(_0x5a70ba,null))['then'](saveUpdates(_0x372986[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x5a70ba,null))['catch'](handleError(_0x5a70ba,null));};exports[_0x6ee4('0x32')]=function(_0x2d8684,_0x10cae9){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x2d8684[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x10cae9,null))[_0x6ee4('0x1c')](removeEntity(_0x10cae9,null))[_0x6ee4('0x27')](handleError(_0x10cae9,null));};exports[_0x6ee4('0x6f')]=function(_0x102d59,_0x323292){return db[_0x6ee4('0x4d')][_0x6ee4('0x6f')]()[_0x6ee4('0x1c')](respondWithResult(_0x323292,null))[_0x6ee4('0x27')](handleError(_0x323292,null));};exports[_0x6ee4('0x70')]=function(_0x7a3961,_0x5d7b71){if(_0x7a3961[_0x6ee4('0x68')]['id']){delete _0x7a3961['body']['id'];}return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x7a3961['params']['id']}})['then'](handleEntityNotFound(_0x5d7b71,null))['then'](function(_0x723769){if(_0x723769){_0x7a3961['body'][_0x6ee4('0x71')]=_0x723769['id'];return db[_0x6ee4('0x72')][_0x6ee4('0x66')](_0x7a3961[_0x6ee4('0x68')]);}})['then'](respondWithResult(_0x5d7b71,null))[_0x6ee4('0x27')](handleError(_0x5d7b71,null));};exports['getDispositions']=function(_0x58ac9e,_0x5ab1e5){var _0x48ee5f={'raw':![],'where':{}};var _0x12c941={};var _0x257a2a={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x58ac9e[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x5ab1e5,null))[_0x6ee4('0x1c')](function(_0x5c6143){if(_0x5c6143){_0x12c941[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x72')][_0x6ee4('0x4e')]);_0x12c941[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x58ac9e[_0x6ee4('0x51')]);_0x12c941['filters']=_[_0x6ee4('0x52')](_0x12c941[_0x6ee4('0x46')],_0x12c941[_0x6ee4('0x51')]);_0x48ee5f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x12c941[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x58ac9e['query'][_0x6ee4('0x54')]));_0x48ee5f[_0x6ee4('0x53')]=_0x48ee5f['attributes'][_0x6ee4('0x55')]?_0x48ee5f['attributes']:_0x12c941['model'];if(!_0x58ac9e['query'][_0x6ee4('0x73')]('nolimit')){_0x48ee5f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x48ee5f['offset']=qs['offset'](_0x58ac9e['query'][_0x6ee4('0x2f')]);}_0x48ee5f[_0x6ee4('0x56')]=qs['sort'](_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x48ee5f[_0x6ee4('0x58')]=qs['filters'](_['pick'](_0x58ac9e[_0x6ee4('0x51')],_0x12c941[_0x6ee4('0x59')]));_0x48ee5f[_0x6ee4('0x58')][_0x6ee4('0x71')]=_0x5c6143['id'];if(_0x58ac9e[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x48ee5f[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x48ee5f[_0x6ee4('0x58')],{'$or':_['map'](_0x48ee5f[_0x6ee4('0x53')],function(_0x56ff80){var _0x332e43={};_0x332e43[_0x56ff80]={'$like':'%'+_0x58ac9e[_0x6ee4('0x51')]['filter']+'%'};return _0x332e43;})});}_0x48ee5f=_[_0x6ee4('0x5c')]({},_0x48ee5f,_0x58ac9e[_0x6ee4('0x5e')]);return db[_0x6ee4('0x72')][_0x6ee4('0x2e')]({'where':_0x48ee5f['where']})[_0x6ee4('0x1c')](function(_0xcb434d){_0x257a2a[_0x6ee4('0x2e')]=_0xcb434d;if(_0x58ac9e['query'][_0x6ee4('0x5f')]){_0x48ee5f[_0x6ee4('0x60')]=[{'all':!![]}];}return db[_0x6ee4('0x72')]['findAll'](_0x48ee5f);})[_0x6ee4('0x1c')](function(_0x1e9a22){_0x257a2a[_0x6ee4('0x62')]=_0x1e9a22;return _0x257a2a;});}})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x5ab1e5,_0x48ee5f))[_0x6ee4('0x27')](handleError(_0x5ab1e5,null));};exports[_0x6ee4('0x74')]=function(_0x5c4995,_0x386a3e){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x5c4995['params']['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x386a3e,null))[_0x6ee4('0x1c')](function(_0x277498){if(_0x277498){return _0x277498[_0x6ee4('0x74')](_0x5c4995['query'][_0x6ee4('0x75')]);}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x386a3e,null))[_0x6ee4('0x27')](handleError(_0x386a3e,null));};exports['addAnswer']=function(_0x44d112,_0x846410){if(_0x44d112[_0x6ee4('0x68')]['id']){delete _0x44d112['body']['id'];}return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x44d112[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x846410,null))['then'](function(_0x4f3531){if(_0x4f3531){_0x44d112['body']['ChatWebsiteId']=_0x4f3531['id'];return db[_0x6ee4('0x76')][_0x6ee4('0x66')](_0x44d112[_0x6ee4('0x68')]);}})['then'](respondWithResult(_0x846410,null))[_0x6ee4('0x27')](handleError(_0x846410,null));};exports['getAnswers']=function(_0x3afdd7,_0x16c52a){var _0x472665={'raw':![],'where':{}};var _0x1435ba={};var _0x5daf9c={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x3afdd7[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x16c52a,null))[_0x6ee4('0x1c')](function(_0x2b15cb){if(_0x2b15cb){_0x1435ba[_0x6ee4('0x46')]=_['keys'](db[_0x6ee4('0x76')][_0x6ee4('0x4e')]);_0x1435ba[_0x6ee4('0x51')]=_['keys'](_0x3afdd7[_0x6ee4('0x51')]);_0x1435ba[_0x6ee4('0x59')]=_[_0x6ee4('0x52')](_0x1435ba['model'],_0x1435ba[_0x6ee4('0x51')]);_0x472665[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x1435ba[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x472665[_0x6ee4('0x53')]=_0x472665[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x472665[_0x6ee4('0x53')]:_0x1435ba[_0x6ee4('0x46')];if(!_0x3afdd7[_0x6ee4('0x51')]['hasOwnProperty'](_0x6ee4('0x78'))){_0x472665['limit']=qs[_0x6ee4('0x2c')](_0x3afdd7['query'][_0x6ee4('0x2c')]);_0x472665['offset']=qs['offset'](_0x3afdd7[_0x6ee4('0x51')]['offset']);}_0x472665['order']=qs['sort'](_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x472665[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x3afdd7[_0x6ee4('0x51')],_0x1435ba[_0x6ee4('0x59')]));_0x472665[_0x6ee4('0x58')]['ChatWebsiteId']=_0x2b15cb['id'];if(_0x3afdd7[_0x6ee4('0x51')]['filter']){_0x472665[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x472665[_0x6ee4('0x58')],{'$or':_['map'](_0x472665[_0x6ee4('0x53')],function(_0xf66acb){var _0x5218fc={};_0x5218fc[_0xf66acb]={'$like':'%'+_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5218fc;})});}_0x472665=_[_0x6ee4('0x5c')]({},_0x472665,_0x3afdd7[_0x6ee4('0x5e')]);return db[_0x6ee4('0x76')]['count']({'where':_0x472665[_0x6ee4('0x58')]})[_0x6ee4('0x1c')](function(_0x263fa3){_0x5daf9c[_0x6ee4('0x2e')]=_0x263fa3;if(_0x3afdd7[_0x6ee4('0x51')][_0x6ee4('0x5f')]){_0x472665[_0x6ee4('0x60')]=[{'all':!![]}];}return db[_0x6ee4('0x76')][_0x6ee4('0x61')](_0x472665);})[_0x6ee4('0x1c')](function(_0x32b797){_0x5daf9c['rows']=_0x32b797;return _0x5daf9c;});}})['then'](respondWithFilteredResult(_0x16c52a,_0x472665))[_0x6ee4('0x27')](handleError(_0x16c52a,null));};exports[_0x6ee4('0x79')]=function(_0xe4fc98,_0x4328ef){return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0xe4fc98[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x4328ef,null))['then'](function(_0x34b30b){if(_0x34b30b){return _0x34b30b[_0x6ee4('0x79')](_0xe4fc98[_0x6ee4('0x51')]['ids']);}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x4328ef,null))[_0x6ee4('0x27')](handleError(_0x4328ef,null));};exports[_0x6ee4('0x7a')]=function(_0x4c284e,_0x427c09){_0x4c284e[_0x6ee4('0x68')][_0x6ee4('0x7b')]=_0x4c284e['file'][_0x6ee4('0x7c')];return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0x4c284e[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x427c09,null))[_0x6ee4('0x1c')](saveUpdates(_0x4c284e[_0x6ee4('0x68')],null))[_0x6ee4('0x1c')](respondWithResult(_0x427c09,null))[_0x6ee4('0x27')](handleError(_0x427c09,null));};exports[_0x6ee4('0x7d')]=function(_0x33b36b,_0x3e71d4){_0x33b36b[_0x6ee4('0x68')]['agentAvatar']=_0x33b36b[_0x6ee4('0x7e')]['filename'];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x33b36b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x3e71d4,null))[_0x6ee4('0x1c')](saveUpdates(_0x33b36b[_0x6ee4('0x68')],null))[_0x6ee4('0x1c')](respondWithResult(_0x3e71d4,null))[_0x6ee4('0x27')](handleError(_0x3e71d4,null));};exports[_0x6ee4('0x7f')]=function(_0x1f8542,_0x5401bd){_0x1f8542[_0x6ee4('0x68')]['customerAvatar']=_0x1f8542[_0x6ee4('0x7e')]['filename'];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x1f8542['params']['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x5401bd,null))[_0x6ee4('0x1c')](saveUpdates(_0x1f8542[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x5401bd,null))['catch'](handleError(_0x5401bd,null));};exports['addSystemAvatar']=function(_0x44f74b,_0x2d2d47){_0x44f74b[_0x6ee4('0x68')][_0x6ee4('0x80')]=_0x44f74b[_0x6ee4('0x7e')][_0x6ee4('0x7c')];return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x44f74b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x2d2d47,null))[_0x6ee4('0x1c')](saveUpdates(_0x44f74b[_0x6ee4('0x68')],null))['then'](respondWithResult(_0x2d2d47,null))['catch'](handleError(_0x2d2d47,null));};exports[_0x6ee4('0x81')]=function(_0x2c366f,_0x52509d){var _0x2b57da=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server/files/images/logos/default_logo.svg');var _0x2b54b8={'where':{'id':_0x2c366f[_0x6ee4('0x64')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x48ac0b=![];return require(_0x6ee4('0x84'))['getLicense']()[_0x6ee4('0x1c')](function(_0x47725e){if(_0x47725e){_0x48ac0b=_0x47725e[_0x6ee4('0x85')];}})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')](_0x2b54b8);})['then'](handleEntityNotFound(_0x52509d,null))[_0x6ee4('0x1c')](function(_0x2e0cda){if(_0x2e0cda){if(!_[_0x6ee4('0x86')](_0x2e0cda[_0x6ee4('0x7b')])){if(fs['existsSync'](path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x87'),_0x2e0cda[_0x6ee4('0x7b')]))&&_0x48ac0b){_0x2b57da=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x87'),_0x2e0cda['sitepic']);}}return _0x52509d[_0x6ee4('0x88')](_0x2b57da);}})[_0x6ee4('0x27')](handleError(_0x52509d,null));};exports['getAvatar']=function(_0x4390c7,_0x37c866){var _0x434dab=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x89'));var _0x341b73={'where':{'id':_0x4390c7[_0x6ee4('0x64')]['id']},'attributes':['id',_0x6ee4('0x8a')],'raw':!![]};return db[_0x6ee4('0x4d')]['find'](_0x341b73)[_0x6ee4('0x1c')](handleEntityNotFound(_0x37c866,null))['then'](function(_0x5a5852){if(_0x5a5852){if(!_[_0x6ee4('0x86')](_0x5a5852[_0x6ee4('0x8a')])){if(fs[_0x6ee4('0x8b')](path[_0x6ee4('0x82')](config['root'],'server/files/images/avatars/',_0x5a5852[_0x6ee4('0x8a')]))){_0x434dab=path['join'](config[_0x6ee4('0x83')],_0x6ee4('0x8c'),_0x5a5852[_0x6ee4('0x8a')]);}}return _0x37c866[_0x6ee4('0x88')](_0x434dab);}})[_0x6ee4('0x27')](handleError(_0x37c866,null));};exports[_0x6ee4('0x8d')]=function(_0x3a02fa,_0x47c5ec){var _0x42f9f1=path['join'](config[_0x6ee4('0x83')],_0x6ee4('0x8e'));var _0x1bbd7c={'where':{'id':_0x3a02fa[_0x6ee4('0x64')]['id']},'attributes':['id',_0x6ee4('0x8f'),_0x6ee4('0x90')],'raw':!![]};return db[_0x6ee4('0x4d')][_0x6ee4('0x65')](_0x1bbd7c)[_0x6ee4('0x1c')](handleEntityNotFound(_0x47c5ec,null))[_0x6ee4('0x1c')](function(_0xee57a5){if(_0xee57a5){if(!_[_0x6ee4('0x86')](_0xee57a5['customerAvatar'])){if(fs[_0x6ee4('0x8b')](path[_0x6ee4('0x82')](config['root'],'server/files/images/avatars/',_0xee57a5['customerAvatar']))&&_0xee57a5[_0x6ee4('0x90')]){_0x42f9f1=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],_0x6ee4('0x8c'),_0xee57a5[_0x6ee4('0x8f')]);}}return _0x47c5ec[_0x6ee4('0x88')](_0x42f9f1);}})[_0x6ee4('0x27')](handleError(_0x47c5ec,null));};exports[_0x6ee4('0x91')]=function(_0x111c35,_0x5eaa62){var _0x4135d9=path[_0x6ee4('0x82')](config['root'],_0x6ee4('0x92'));var _0x1e4fbf={'where':{'id':_0x111c35[_0x6ee4('0x64')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db['ChatWebsite'][_0x6ee4('0x65')](_0x1e4fbf)[_0x6ee4('0x1c')](handleEntityNotFound(_0x5eaa62,null))[_0x6ee4('0x1c')](function(_0x400c11){if(_0x400c11){if(!_['isNil'](_0x400c11[_0x6ee4('0x80')])){if(fs[_0x6ee4('0x8b')](path['join'](config[_0x6ee4('0x83')],'server/files/images/avatars/',_0x400c11[_0x6ee4('0x80')]))){_0x4135d9=path['join'](config[_0x6ee4('0x83')],'server/files/images/avatars/',_0x400c11[_0x6ee4('0x80')]);}}return _0x5eaa62[_0x6ee4('0x88')](_0x4135d9);}})['catch'](handleError(_0x5eaa62,null));};function checkWebsiteInterval(_0x3acc94){var _0x87f63b=_0x3acc94[_0x6ee4('0x93')];if(!_0x87f63b){return Promise['resolve'](_0x3acc94);}var _0x4c3d02=_0x3acc94[_0x6ee4('0x94')]||undefined;return _0x87f63b[_0x6ee4('0x95')](_0x4c3d02)[_0x6ee4('0x1c')](function(_0x1b65f8){if(!_0x1b65f8){throw new APIOutOfIntervalError();}return _0x3acc94;});}exports[_0x6ee4('0x96')]=function(_0x4e858a,_0x451975){var _0x1dbf0e={'body':_0x4e858a[_0x6ee4('0x68')],'channel':_0x6ee4('0x97')};var _0x2e377c=[];var _0x57a6c4=[];var _0x48df37={};var _0x433eed=![];if(_0x4e858a[_0x6ee4('0x68')]['id']){delete _0x4e858a[_0x6ee4('0x68')]['id'];}if(_[_0x6ee4('0x86')](_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x98')])){throw new APIBadRequestError(_0x6ee4('0x99'));}if(_[_0x6ee4('0x86')](_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')])){throw new APIBadRequestError(_0x6ee4('0x9b'));}if(_[_0x6ee4('0x9c')](_0x4e858a['body']['body'])){throw new APIBadRequestError(_0x6ee4('0x9d'));}var _0x102a15=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x39')]&&_0x4e858a['body'][_0x6ee4('0x9e')];return db[_0x6ee4('0x9f')]['describe']()['then'](function(_0x5abd81){if(!_0x5abd81){throw new Error(_0x6ee4('0xa0'));}_0x2e377c=Object['keys'](_0x5abd81)[_0x6ee4('0x5b')](function(_0x4d4b90){return!['createdAt','updatedAt'][_0x6ee4('0xa1')](_0x4d4b90);});_0x57a6c4=Object[_0x6ee4('0x50')](_0x5abd81)['filter'](function(_0x587b72){return![_0x6ee4('0xa2'),'updatedAt','CompanyId',_0x6ee4('0xa3')][_0x6ee4('0xa1')](_0x587b72);});if(!_[_0x6ee4('0xa1')](_0x57a6c4,_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')])){throw new APIBadRequestError(_0x6ee4('0xa4')+_0x57a6c4[_0x6ee4('0x82')](',\x20'));}_0x48df37[_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')]]=_0x4e858a[_0x6ee4('0x68')]['from'];})['then'](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x4e858a[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0xa5')],'as':_0x6ee4('0xa6'),'include':[{'model':db['CmContact'],'as':_0x6ee4('0xa7'),'where':_0x48df37,'limit':0x1,'order':[[_0x6ee4('0xa8'),_0x6ee4('0xa9')]]}]},{'model':db[_0x6ee4('0xaa')],'as':_0x6ee4('0xab')},{'model':db[_0x6ee4('0x93')],'as':'Interval','include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0x6ee4('0xac')],'raw':!![]}]}]});})[_0x6ee4('0x1c')](function(_0x197ba5){if(!_0x197ba5){throw new APINotFoundError(util[_0x6ee4('0x41')](_0x6ee4('0xad'),_0x4e858a['params']['id']));}if(_0x102a15){return checkWebsiteInterval(_0x197ba5);}return _0x197ba5;})[_0x6ee4('0x1c')](function(_0xe860e6){_0x1dbf0e['account']=_0xe860e6;_0x1dbf0e[_0x6ee4('0xae')]=_['orderBy'](_0xe860e6[_0x6ee4('0xab')],[_0x6ee4('0xaf')],['asc']);if(_0x1dbf0e['account'][_0x6ee4('0xab')]){delete _0x1dbf0e['account'][_0x6ee4('0xab')];}_0x1dbf0e['list']=_0xe860e6['List']||{'id':_0xe860e6[_0x6ee4('0xa3')]};if(_0x1dbf0e[_0x6ee4('0xb0')]&&_0x1dbf0e[_0x6ee4('0xb0')][_0x6ee4('0xa7')][_0x6ee4('0x55')]){return _0x1dbf0e['list'][_0x6ee4('0xa7')][0x0];}var _0x230535=_[_0x6ee4('0x15')](_0x4e858a[_0x6ee4('0x68')],{'firstName':_0x4e858a['body'][_0x6ee4('0x98')],'ListId':_0xe860e6[_0x6ee4('0xa3')]});_0x230535[_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9a')]]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x98')];return db[_0x6ee4('0x9f')]['create'](_0x230535,{'fields':_0x2e377c,'raw':!![]});})['then'](function(_0x110c18){_0x1dbf0e[_0x6ee4('0xb1')]=_0x110c18;var _0x40e45f=createInteractionObject(_0x4e858a[_0x6ee4('0x64')]['id'],_0x4e858a['body'],_0x4e858a[_0x6ee4('0xb2')],_0x110c18);var _0x698ed8={'ChatWebsiteId':_0x4e858a[_0x6ee4('0x64')]['id']};if(_0x4e858a['body'][_0x6ee4('0xb3')]){_0x698ed8['threadId']=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')];_0x698ed8[_0x6ee4('0xb4')]=![];return db['ChatInteraction'][_0x6ee4('0x65')]({'where':_0x698ed8})['then'](function(_0x19d48e){var _0x38d053=_0x4e858a[_0x6ee4('0x68')]['customerIp']&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x9e')];if(_0x19d48e){_0x433eed=!![];return _0x19d48e;}else if(!_0x38d053&&_0x19d48e&&_0x19d48e[_0x6ee4('0xb4')]){throw new APIConflictError('Writing\x20on\x20closed\x20interaction');}_0x40e45f[_0x6ee4('0xb3')]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')];_0x40e45f['externalUrl']=_0x4e858a['body'][_0x6ee4('0xb5')];return db[_0x6ee4('0xb6')]['create'](_0x40e45f);});}_0x698ed8[_0x6ee4('0xb7')]=_0x110c18['id'];if(_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb8')]&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb8')]['id']){_0x698ed8['id']=_0x4e858a[_0x6ee4('0x68')]['interaction']['id'];return db[_0x6ee4('0xb6')][_0x6ee4('0x65')]({'where':_0x698ed8})[_0x6ee4('0x1c')](function(_0x545ea5){var _0x3bd78c=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x39')]&&_0x4e858a['body'][_0x6ee4('0x9e')];if(!_0x3bd78c&&_0x545ea5&&_0x545ea5[_0x6ee4('0xb4')]){throw new APIConflictError('Writing\x20on\x20closed\x20interaction');}else if(_0x545ea5){_0x433eed=!![];return _0x545ea5;}else{return db[_0x6ee4('0xb6')][_0x6ee4('0x66')](_0x40e45f);}});}return db['ChatInteraction'][_0x6ee4('0x66')](_0x40e45f);})[_0x6ee4('0x1c')](function(_0x5844cd){if(!_0x433eed){return _0x5844cd;}var _0x13a5d9={'from':(_0x1dbf0e['contact'][_0x6ee4('0x3d')]||'')+'\x20'+(_0x1dbf0e[_0x6ee4('0xb1')]['lastName']||'')};if(_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb3')]&&_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb9')]&&_0x4e858a['body']['threadId']!=_0x4e858a['body'][_0x6ee4('0xb9')]){_0x13a5d9[_0x6ee4('0xb3')]=_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0xb9')];}return _0x5844cd[_0x6ee4('0x31')](_0x13a5d9);})[_0x6ee4('0x1c')](function(_0x30d491){_0x1dbf0e['interaction']=_0x30d491[_0x6ee4('0x6b')]({'plain':!![]});_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xba')]=!_0x433eed;if(_0x1dbf0e['interaction'][_0x6ee4('0xba')]){if(_0x1dbf0e[_0x6ee4('0xbb')][_0x6ee4('0xbc')]){_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0xbd')]({'id':0x0,'priority':_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0x55')]+0x1,'app':_0x6ee4('0xbe'),'appdata':_0x6ee4('0xbf'),'interval':_0x6ee4('0xc0')});}}return db[_0x6ee4('0xc1')][_0x6ee4('0x66')]({'body':_0x4e858a[_0x6ee4('0x68')][_0x6ee4('0x68')],'ChatWebsiteId':_0x4e858a[_0x6ee4('0x64')]['id'],'ChatInteractionId':_0x30d491['id'],'direction':'in','ContactId':_0x1dbf0e[_0x6ee4('0xb1')]['id'],'AttachmentId':_0x4e858a[_0x6ee4('0x68')]['AttachmentId']});})[_0x6ee4('0x1c')](function(_0x1afa76){_0x1dbf0e['message']=_0x1afa76;if(!_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc2')]){return;}return db[_0x6ee4('0xc3')][_0x6ee4('0x65')]({'attributes':['id',_0x6ee4('0x35')],'where':{'id':_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc2')]}});})[_0x6ee4('0x1c')](function(_0x1bfe88){if(_0x1bfe88){_0x1dbf0e[_0x6ee4('0xae')][_0x6ee4('0xc4')]({'id':0x0,'priority':0x0,'app':_0x6ee4('0xc5'),'appdata':_0x1bfe88[_0x6ee4('0x35')]+','+(_0x1dbf0e[_0x6ee4('0xbb')][_0x6ee4('0xc6')]||0xa),'interval':'*,*,*,*'});_0x1dbf0e[_0x6ee4('0xc7')]=!![];}if(!_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc8')]){return;}return db['ChatQueue'][_0x6ee4('0x65')]({'attributes':['id',_0x6ee4('0x35')],'where':{'id':_0x1dbf0e[_0x6ee4('0xb8')][_0x6ee4('0xc8')]}});})[_0x6ee4('0x1c')](function(_0x5da74e){if(_0x5da74e){_0x1dbf0e[_0x6ee4('0xae')]['unshift']({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x5da74e[_0x6ee4('0x35')]+','+(_0x1dbf0e['account'][_0x6ee4('0xc9')]||0x12c),'interval':_0x6ee4('0xc0')});}return respondWithRpcPromise(_0x6ee4('0xca'),_0x6ee4('0xcb'),_0x1dbf0e);})[_0x6ee4('0x1c')](function(_0x5c40e1){respondWithRpcPromise(_0x6ee4('0xcc'),_0x6ee4('0xcc'),{'event':_0x6ee4('0x96'),'message':_0x5c40e1},client9002);return _0x5c40e1;})['then'](respondWithResult(_0x451975,null))[_0x6ee4('0x27')](APIHandleError(_0x451975));};exports['offline']=function(_0x1b1097,_0x49c69e){var _0x5b7182,_0x545a2c,_0x51e539;var _0x18a528=[];var _0xe34109={};var _0x588f32=_0x1b1097[_0x6ee4('0xcd')]||[];var _0x55d681=[];var _0x15d330;return db[_0x6ee4('0x9f')][_0x6ee4('0x6f')]()[_0x6ee4('0x1c')](function(_0x151773){if(!_0x151773){throw new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd0'));}_0x18a528=_['difference'](_[_0x6ee4('0x50')](_0x151773),[_0x6ee4('0xa2'),_0x6ee4('0xa8'),_0x6ee4('0xd1'),_0x6ee4('0xa3')]);if(_0x1b1097['body']['id']){delete _0x1b1097[_0x6ee4('0x68')]['id'];}if(_[_0x6ee4('0x86')](_0x1b1097['body'][_0x6ee4('0x98')])){throw _0x49c69e['status'](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd3')));}if(_[_0x6ee4('0x86')](_0x1b1097[_0x6ee4('0x68')]['body'])||_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x68')]===''){throw _0x49c69e['status'](0x1f4)['send'](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd4')));}if(_[_0x6ee4('0x86')](_0x1b1097['body'][_0x6ee4('0xd5')])){throw _0x49c69e[_0x6ee4('0x29')](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))](_0x6ee4('0xd6')+_0x18a528));}if(!_['includes'](_0x18a528,_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0xd5')])){throw _0x49c69e[_0x6ee4('0x29')](0x1f4)[_0x6ee4('0xd2')](new db[(_0x6ee4('0xce'))][(_0x6ee4('0xcf'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x18a528));}_0xe34109[_0x1b1097['body'][_0x6ee4('0xd5')]]=_0x1b1097[_0x6ee4('0x68')]['from'];})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x1b1097[_0x6ee4('0x64')]['id']},'include':[{'model':db[_0x6ee4('0xa5')],'as':_0x6ee4('0xa6')},{'model':db[_0x6ee4('0xd7')],'as':_0x6ee4('0xd7')}]});})[_0x6ee4('0x1c')](handleEntityNotFound(_0x49c69e,null))['then'](function(_0x1d06e3){if(_0x1d06e3&&_0x1d06e3['List']){_0x545a2c=_0x1d06e3;var _0x265a0c=_[_0x6ee4('0x15')](_0x1b1097[_0x6ee4('0x68')],{'firstName':_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x98')],'phone':_0x1b1097['body']['from'],'ListId':_0x1d06e3[_0x6ee4('0xa3')]});_0x265a0c[_0x1b1097['body'][_0x6ee4('0xd5')]]=_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x98')];return db[_0x6ee4('0x9f')]['findOrCreate']({'where':_0xe34109,'defaults':_0x265a0c});}})[_0x6ee4('0xd8')](function(_0x521c4b){if(_0x521c4b){_0x51e539=_0x521c4b;var _0x3eef07=fs[_0x6ee4('0xd9')](path['join'](config[_0x6ee4('0x83')],_0x6ee4('0xda')),'utf8');var _0x5d3c6d=ejs[_0x6ee4('0xdb')](_0x3eef07,{'body':_[_0x6ee4('0xdc')](_0x1b1097[_0x6ee4('0x68')][_0x6ee4('0x68')]),'bodyTitle':_0x545a2c[_0x6ee4('0xdd')]});return db['ChatOfflineMessage'][_0x6ee4('0x66')]({'body':_0x5d3c6d,'plainBody':htmlToText[_0x6ee4('0xde')](_0x5d3c6d),'ContactId':_0x521c4b['id'],'ChatWebsiteId':_0x545a2c['id']});}})[_0x6ee4('0x1c')](function(_0x1ac102){_0x15d330=_0x1ac102;if(_0x588f32['length']){var _0x4bafe4=_0x588f32[_0x6ee4('0x4c')](function(_0x517722){return{'name':_0x517722[_0x6ee4('0xdf')],'basename':_0x517722[_0x6ee4('0x7c')],'type':_0x517722[_0x6ee4('0xe0')],'ChatOfflineMessageId':_0x1ac102['id']};});_0x55d681=_0x4bafe4[_0x6ee4('0x4c')](_0x133982=>{var _0xcbcaa7={'filename':_0x133982[_0x6ee4('0x35')],'path':path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server',_0x6ee4('0xcd'),_0x6ee4('0xe1'),_0x6ee4('0xe2'),_0x133982[_0x6ee4('0xe3')])};return _0xcbcaa7;});if(!_0x545a2c[_0x6ee4('0xe4')]){return db['sequelize'][_0x6ee4('0xe5')](function(_0x31b6c6){return db[_0x6ee4('0xe6')][_0x6ee4('0xe7')](_0x4bafe4,{'transaction':_0x31b6c6});});}}})[_0x6ee4('0x1c')](function(){if(_0x15d330){_0x5b7182=_0x15d330;return db[_0x6ee4('0xd7')][_0x6ee4('0x77')]({'where':{'service':!![]},'include':[{'model':db[_0x6ee4('0xe8')],'as':_0x6ee4('0xe9'),'raw':!![],'include':[{'model':db[_0x6ee4('0xea')],'as':'CloudProvider','raw':!![]}]}]});}})['then'](function(_0x566f57){if(_0x566f57&&_0x566f57['Smtp']&&_0x545a2c[_0x6ee4('0xeb')]&&_0x545a2c[_0x6ee4('0xec')]){var _0x59f2cd=_0x566f57[_0x6ee4('0xed')]();return respondWithRpcPromise(_0x6ee4('0xee'),_0x6ee4('0xef'),{'account':_0x59f2cd,'message':{'from':util['format'](_0x6ee4('0xf0'),_0x566f57[_0x6ee4('0x35')],_0x566f57[_0x6ee4('0xf1')]||_0x566f57[_0x6ee4('0xe9')]['user']),'to':_0x545a2c[_0x6ee4('0xec')],'subject':_0x545a2c[_0x6ee4('0xf2')],'html':_0x5b7182[_0x6ee4('0x68')],'attachments':_0x55d681}},client9003)[_0x6ee4('0x1c')](function(){return _0x5b7182;})['catch'](function(_0x100a5b){logger[_0x6ee4('0x22')](_0x100a5b);});}})[_0x6ee4('0x1c')](function(){if(_0x545a2c&&_0x545a2c[_0x6ee4('0xe4')]&&_0x545a2c['MailAccountId']){var _0x4f5c9e=[];if(_0x588f32['length']){_0x4f5c9e=_0x588f32[_0x6ee4('0x4c')](function(_0x43b99f){return{'name':_0x43b99f[_0x6ee4('0xdf')],'basename':_0x43b99f[_0x6ee4('0x7c')],'type':_0x43b99f[_0x6ee4('0xe0')],'ChatOfflineMessageId':_0x15d330['id']};});}var _0x37137e;if(!_[_0x6ee4('0x86')](_0x545a2c[_0x6ee4('0xf3')])){var _0x18cc73=_[_0x6ee4('0x4c')](_0x1b1097[_0x6ee4('0x68')],function(_0x54aec7){return _0x54aec7;});var _0x4580cd=_[_0x6ee4('0xf4')](_0x18cc73)[0x0];var _0x2c5aba=_[_0x6ee4('0xf5')](_0x4580cd,function(_0xbcc979){return _0xbcc979;});_0x37137e=_0x2c5aba[0x1][_0x545a2c[_0x6ee4('0xf3')]];}var _0x19ef93={'from':_0x51e539[_0x6ee4('0xf1')],'firstName':_0x51e539[_0x6ee4('0x3d')],'lastName':_0x51e539['lastName'],'mapKey':_0x6ee4('0xf1'),'message':{'from':_0x51e539['email'],'to':_0x545a2c[_0x6ee4('0xd7')][_0x6ee4('0xf1')],'cc':'','subject':_[_0x6ee4('0x86')](_0x37137e)?_0x545a2c[_0x6ee4('0xf2')]:_0x37137e,'messageId':'','sentAt':new Date(),'attach':_0x4f5c9e[_0x6ee4('0x55')],'attachments':_0x4f5c9e,'originChannel':_0x6ee4('0xf6'),'ChatWebsiteId':_0x545a2c['id'],'ChatOfflineMessageId':_0x5b7182['id'],'originTo':_0x545a2c[_0x6ee4('0xd7')]['email']},'body':_0x5b7182[_0x6ee4('0x68')]};var _0xc8a872={'account':{'id':_0x545a2c[_0x6ee4('0xf7')]},'body':_0x19ef93,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0x6ee4('0xf8'),_0x6ee4('0xf9'),_0xc8a872,client9001)[_0x6ee4('0x1c')](function(){return _0x5b7182;})[_0x6ee4('0x27')](function(_0x321d72){logger[_0x6ee4('0x22')](_0x321d72);});}return;})[_0x6ee4('0x1c')](function(){if(_0x5b7182){return _0x5b7182;}})[_0x6ee4('0x1c')](respondWithResult(_0x49c69e,null))[_0x6ee4('0x27')](function(){for(var _0x4d1406 of _0x588f32){var _0x3cdc9e=path[_0x6ee4('0x82')](config[_0x6ee4('0x83')],'server','files',_0x6ee4('0xe1'),_0x6ee4('0xe2'),_0x4d1406['filename']);fs_extra['remove'](_0x3cdc9e)['catch'](function(_0x4af932){logger[_0x6ee4('0x22')]('Could\x20not\x20remove\x20attachment\x20file',_0x3cdc9e,_0x4af932);});}});};exports[_0x6ee4('0xfa')]=function(_0x1561e8,_0x1200f8){return db[_0x6ee4('0xb6')][_0x6ee4('0x65')]({'where':{'id':_0x1561e8['params']['id']}})['then'](handleEntityNotFound(_0x1200f8,null))[_0x6ee4('0x1c')](function(_0x3d7a6a){if(_0x3d7a6a){return _0x3d7a6a[_0x6ee4('0xfa')](_0x1561e8[_0x6ee4('0x68')][_0x6ee4('0x75')],_['omit'](_0x1561e8[_0x6ee4('0x68')],[_0x6ee4('0x75'),'id'])||{});}})[_0x6ee4('0x1c')](respondWithResult(_0x1200f8,null))[_0x6ee4('0x27')](handleError(_0x1200f8,null));};exports['getInteractions']=function(_0x1ad77b,_0x17f2df){var _0x432ec7={'raw':![],'where':{}};var _0x547298={};var _0x21e7be={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x1ad77b[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x17f2df,null))[_0x6ee4('0x1c')](function(_0x141220){if(_0x141220){_0x547298['model']=_[_0x6ee4('0x50')](db[_0x6ee4('0xb6')][_0x6ee4('0x4e')]);_0x547298[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x1ad77b[_0x6ee4('0x51')]);_0x547298['filters']=_[_0x6ee4('0x52')](_0x547298[_0x6ee4('0x46')],_0x547298[_0x6ee4('0x51')]);_0x432ec7[_0x6ee4('0x53')]=_['intersection'](_0x547298[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x432ec7[_0x6ee4('0x53')]=_0x432ec7[_0x6ee4('0x53')]['length']?_0x432ec7[_0x6ee4('0x53')]:_0x547298[_0x6ee4('0x46')];if(!_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x432ec7[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x432ec7[_0x6ee4('0x2f')]=qs['offset'](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x2f')]);}_0x432ec7['order']=qs[_0x6ee4('0x57')](_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x432ec7[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_['pick'](_0x1ad77b[_0x6ee4('0x51')],_0x547298[_0x6ee4('0x59')]));_0x432ec7[_0x6ee4('0x58')][_0x6ee4('0x71')]=_0x141220['id'];if(_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x432ec7[_0x6ee4('0x58')]=_['merge'](_0x432ec7[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x432ec7[_0x6ee4('0x53')],function(_0x142d8f){var _0x39ddb6={};_0x39ddb6[_0x142d8f]={'$like':'%'+_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x39ddb6;})});}_0x432ec7=_[_0x6ee4('0x5c')]({},_0x432ec7,_0x1ad77b[_0x6ee4('0x5e')]);return db[_0x6ee4('0xb6')]['count']({'where':_0x432ec7['where']})[_0x6ee4('0x1c')](function(_0x3fc60e){_0x21e7be[_0x6ee4('0x2e')]=_0x3fc60e;if(_0x1ad77b[_0x6ee4('0x51')]['includeAll']){_0x432ec7[_0x6ee4('0x60')]=[{'model':db[_0x6ee4('0x9f')],'as':'Contact','required':![]},{'model':db[_0x6ee4('0xc3')],'as':'Owner','attributes':[_0x6ee4('0x35'),_0x6ee4('0xfb'),_0x6ee4('0xfc')],'required':![]},{'model':db['Tag'],'as':_0x6ee4('0xfd'),'attributes':['id',_0x6ee4('0x35'),'color'],'where':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]?{'id':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]}:undefined,'required':_0x1ad77b[_0x6ee4('0x51')][_0x6ee4('0xfe')]?!![]:![]}];}return db[_0x6ee4('0xb6')][_0x6ee4('0x61')](_0x432ec7);})[_0x6ee4('0x1c')](function(_0x17d405){_0x21e7be[_0x6ee4('0x62')]=_0x17d405;return _0x21e7be;});}})[_0x6ee4('0x1c')](respondWithFilteredResult(_0x17f2df,_0x432ec7))['catch'](handleError(_0x17f2df,null));};exports[_0x6ee4('0xff')]=function(_0x588fb3,_0x45d4f0){var _0x415189=0x0;var _0xfce68e=0x0;var _0x4f6186=![];var _0xd20adc;var _0x1b6033;return db['ChatWebsite'][_0x6ee4('0x65')]({'where':{'id':_0x588fb3['params']['id']},'include':[{'model':db['Interval'],'as':'Interval','include':[{'model':db[_0x6ee4('0x93')],'as':'Intervals','attributes':['id',_0x6ee4('0xac')]}]}]})[_0x6ee4('0x1c')](handleEntityNotFound(_0x45d4f0,null))['then'](function(_0x58a21b){if(_0x58a21b){_0xd20adc=_0x58a21b;return _0x58a21b[_0x6ee4('0x100')]({'raw':!![]});}})['then'](function(_0x453fdb){if(_0xd20adc){if(_0x453fdb){_0x1b6033=_0x453fdb;}}return require(_0x6ee4('0x84'))[_0x6ee4('0x101')]();})[_0x6ee4('0x1c')](function(_0x55d59a){if(_0x55d59a){_0xfce68e=_0x55d59a[_0x6ee4('0x102')];_0x4f6186=_0x55d59a['custom'];}})[_0x6ee4('0x1c')](function(){return db[_0x6ee4('0xb6')]['count']({'where':{'closed':![]}});})['then'](function(_0x23a8ab){_0x415189=_0x23a8ab;if(_0xfce68e&&_0x23a8ab>_0xfce68e){return db[_0x6ee4('0x103')]['findOne']({'where':{'id':0x1}})['then'](function(_0x4267c4){if(_0x4267c4){_0x4267c4[_0x6ee4('0x104')](_0x6ee4('0x105'));}});}})[_0x6ee4('0x1c')](function(){var _0x5a5a66=_0xd20adc['Interval'];var _0x16bd8e=_0xd20adc[_0x6ee4('0x94')]||undefined;return _0x5a5a66?_0x5a5a66[_0x6ee4('0x95')](_0x16bd8e):!![];})[_0x6ee4('0x1c')](function(_0x45a2be){var _0x37f43f=fs[_0x6ee4('0xd9')](path[_0x6ee4('0x82')](config['root'],_0x6ee4('0x106')),'utf8');var _0x2b3189=_0x6ee4('0x107');var _0x58b943=![];try{const _0x32ac65=new URL(_0xd20adc['address']);_0xd20adc[_0x6ee4('0x67')]=_0x32ac65[_0x6ee4('0x108')];}catch(_0x40e571){}var _0x2b8971;if(_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]){_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]=_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')][_0x6ee4('0x109')](/\/$/,'');_0x2b8971=wildcardUtils[_0x6ee4('0x10a')](_0xd20adc[_0x6ee4('0x67')],_0x588fb3['headers'][_0x6ee4('0x9e')]);}else{_0x588fb3['headers'][_0x6ee4('0x9e')]=_0xd20adc['address'];_0x2b8971=!![];}var _0x1a1523={'chatVersion':_0x2b3189,'chatWebsiteAddressOrigin':_0x2b8971?_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x9e')]:_0xd20adc['address'],'remote':_0xd20adc['remote'],'query':querystring[_0x6ee4('0x21')](_[_0x6ee4('0x5c')](_0xd20adc['get']({'plain':!![]}),{'customerIp':_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x3a')]||_0x588fb3[_0x6ee4('0xb2')][_0x6ee4('0x10b')]||_0x588fb3[_0x6ee4('0x10c')]['remoteAddress']||_0x588fb3['ip'],'referer':_0x588fb3['headers'][_0x6ee4('0x9e')],'openedInteractions':_0x415189,'maxInteractions':_0xfce68e,'virtual':_0x4f6186['virtual'],'online':_0x45a2be,'custom':_0x4f6186,'address':_0x2b8971?_0x588fb3['headers'][_0x6ee4('0x9e')]:null}))[_0x6ee4('0x109')](/'/g,'\x5c\x27')};_0x45d4f0[_0x6ee4('0xd2')](ejs['render'](Mustache[_0x6ee4('0xdb')](_0x37f43f,_0x1a1523),{'proactiveActions':_0x1b6033,'alignment':_0xd20adc[_0x6ee4('0x10d')],'verticalAlignment':_0xd20adc['verticalAlignment'],'div_color':_0xd20adc[_0x6ee4('0x10e')],'labelText':_0xd20adc[_0x6ee4('0x10f')],'text_color':_0xd20adc[_0x6ee4('0x110')],'text_button_color':_0xd20adc[_0x6ee4('0x111')],'button_color':_0xd20adc['color_button'],'background_color':_0xd20adc[_0x6ee4('0x112')],'hideWhenOffline':_0xd20adc['hideWhenOffline'],'intervalId':_0xd20adc['IntervalId'],'isDevelopment':_0x58b943,'chatVersion':_0x2b3189}));})[_0x6ee4('0x27')](handleError(_0x45d4f0,null));};exports[_0x6ee4('0x113')]=function(_0x2c4419,_0x2857e3){var _0x4eb1a2=_0x2c4419[_0x6ee4('0x64')]['id'];var _0x44be61=_0x2c4419['body'];var _0x384df0=0xc8;var _0x22e51b=null;return db[_0x6ee4('0x114')][_0x6ee4('0xe5')]({'isolationLevel':db[_0x6ee4('0x114')]['Transaction'][_0x6ee4('0x115')][_0x6ee4('0x116')]},function(_0x481021){return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x4eb1a2},'transaction':_0x481021})[_0x6ee4('0x1c')](function(_0x439277){if(_0x439277){return db[_0x6ee4('0xaa')][_0x6ee4('0x32')]({'where':{'ChatWebsiteId':_0x4eb1a2},'transaction':_0x481021})[_0x6ee4('0x1c')](function(){var _0x386398=_['map'](_0x44be61,function(_0x8fdaa3){_0x8fdaa3[_0x6ee4('0x71')]=_0x4eb1a2;return _0x8fdaa3;});return db[_0x6ee4('0xaa')]['bulkCreate'](_0x386398,{'transaction':_0x481021});});}else{_0x384df0=0x194;_0x22e51b=[];}});})[_0x6ee4('0x1c')](function(){if(_0x384df0!==0x194){return db[_0x6ee4('0xaa')][_0x6ee4('0x117')]({'where':{'ChatWebsiteId':_0x4eb1a2},'order':_0x6ee4('0xaf')})[_0x6ee4('0x1c')](function(_0x355c45){_0x22e51b=_0x355c45;});}})[_0x6ee4('0x27')](function(_0x24f4e0){_0x384df0=0x1f4;logger[_0x6ee4('0x22')](_0x24f4e0[_0x6ee4('0x118')]);if(_0x24f4e0[_0x6ee4('0x35')]){delete _0x24f4e0[_0x6ee4('0x35')];}_0x22e51b=_0x24f4e0;})[_0x6ee4('0x119')](function(){if(_0x22e51b===null){_0x2857e3[_0x6ee4('0x28')](_0x384df0);}else{if(_0x384df0===0x1f4){_0x2857e3['status'](_0x384df0)[_0x6ee4('0xd2')](_0x22e51b);}else{_0x2857e3[_0x6ee4('0x29')](_0x384df0)['json'](_0x22e51b);}}});};exports[_0x6ee4('0x11a')]=function(_0x2d1dfa,_0x29b280){var _0x3c029f={};var _0x2a4beb={};var _0x308981;var _0x999e20;return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x2d1dfa[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x29b280,null))[_0x6ee4('0x1c')](function(_0x379cb1){if(_0x379cb1){_0x308981=_0x379cb1;_0x2a4beb['model']=_[_0x6ee4('0x50')](db[_0x6ee4('0xaa')]['rawAttributes']);_0x2a4beb['query']=_['keys'](_0x2d1dfa[_0x6ee4('0x51')]);_0x2a4beb[_0x6ee4('0x59')]=_['intersection'](_0x2a4beb[_0x6ee4('0x46')],_0x2a4beb[_0x6ee4('0x51')]);_0x3c029f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x2a4beb[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3c029f[_0x6ee4('0x53')]=_0x3c029f[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x3c029f[_0x6ee4('0x53')]:_0x2a4beb['model'];_0x3c029f['order']=qs[_0x6ee4('0x57')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x3c029f[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x2d1dfa['query'],_0x2a4beb['filters']));if(_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x3c029f['where']=_[_0x6ee4('0x5c')](_0x3c029f[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x3c029f[_0x6ee4('0x53')],function(_0x4e3df0){var _0x5417c3={};_0x5417c3[_0x4e3df0]={'$like':'%'+_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5417c3;})});}_0x3c029f=_[_0x6ee4('0x5c')]({},_0x3c029f,_0x2d1dfa['options']);return _0x308981['getApplications'](_0x3c029f);}})[_0x6ee4('0x1c')](function(_0x386c43){if(_0x386c43){_0x999e20=_0x386c43[_0x6ee4('0x55')];if(!_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x3c029f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x3c029f[_0x6ee4('0x2f')]=qs[_0x6ee4('0x2f')](_0x2d1dfa[_0x6ee4('0x51')][_0x6ee4('0x2f')]);}return _0x308981[_0x6ee4('0x11a')](_0x3c029f);}})[_0x6ee4('0x1c')](function(_0x59fa6a){if(_0x59fa6a){return _0x59fa6a?{'count':_0x999e20,'rows':_0x59fa6a}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x29b280,null))[_0x6ee4('0x27')](handleError(_0x29b280,null));};exports[_0x6ee4('0x11b')]=function(_0x5b2f95,_0x470cfc){return db[_0x6ee4('0x11c')][_0x6ee4('0x65')]({'where':{'id':_0x5b2f95[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x470cfc,null))[_0x6ee4('0x1c')](function(_0x5bac39){if(_0x5bac39){return _0x5bac39[_0x6ee4('0x11b')](_0x5b2f95[_0x6ee4('0x68')][_0x6ee4('0x75')],_[_0x6ee4('0x11d')](_0x5b2f95['body'],[_0x6ee4('0x75'),'id'])||{});}})[_0x6ee4('0x1c')](respondWithResult(_0x470cfc,null))[_0x6ee4('0x27')](handleError(_0x470cfc,null));};exports[_0x6ee4('0x100')]=function(_0x49528d,_0x482582){var _0x36d87f={};var _0x36b2d={};var _0x4f4455;var _0x337c0f;return db['ChatWebsite'][_0x6ee4('0x77')]({'where':{'id':_0x49528d[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x482582,null))[_0x6ee4('0x1c')](function(_0x51ed20){if(_0x51ed20){_0x4f4455=_0x51ed20;_0x36b2d['model']=_[_0x6ee4('0x50')](db['ChatProactiveAction'][_0x6ee4('0x4e')]);_0x36b2d[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x49528d[_0x6ee4('0x51')]);_0x36b2d['filters']=_['intersection'](_0x36b2d[_0x6ee4('0x46')],_0x36b2d[_0x6ee4('0x51')]);_0x36d87f[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x36b2d[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x36d87f[_0x6ee4('0x53')]=_0x36d87f[_0x6ee4('0x53')][_0x6ee4('0x55')]?_0x36d87f[_0x6ee4('0x53')]:_0x36b2d['model'];_0x36d87f['order']=qs['sort'](_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x36d87f['where']=qs[_0x6ee4('0x59')](_['pick'](_0x49528d[_0x6ee4('0x51')],_0x36b2d['filters']));if(_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x36d87f['where']=_['merge'](_0x36d87f[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x36d87f[_0x6ee4('0x53')],function(_0x2ad2ef){var _0x5111ac={};_0x5111ac[_0x2ad2ef]={'$like':'%'+_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x5111ac;})});}_0x36d87f=_[_0x6ee4('0x5c')]({},_0x36d87f,_0x49528d[_0x6ee4('0x5e')]);return _0x4f4455[_0x6ee4('0x100')](_0x36d87f);}})['then'](function(_0x1e80d1){if(_0x1e80d1){_0x337c0f=_0x1e80d1[_0x6ee4('0x55')];if(!_0x49528d[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x36d87f[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x49528d[_0x6ee4('0x51')]['limit']);_0x36d87f[_0x6ee4('0x2f')]=qs[_0x6ee4('0x2f')](_0x49528d['query'][_0x6ee4('0x2f')]);}return _0x4f4455[_0x6ee4('0x100')](_0x36d87f);}})['then'](function(_0x31683d){if(_0x31683d){return _0x31683d?{'count':_0x337c0f,'rows':_0x31683d}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x482582,null))[_0x6ee4('0x27')](handleError(_0x482582,null));};exports[_0x6ee4('0x11e')]=function(_0x14d9dd,_0x2e6160){var _0x4338d2=_0x14d9dd['query'][_0x6ee4('0x11f')]===_0x6ee4('0x120')?_0x6ee4('0x121'):'onlineForm';return db['ChatWebsite'][_0x6ee4('0x65')]({'attributes':['id',_0x4338d2],'where':{'id':_0x14d9dd[_0x6ee4('0x64')]['id']}})['then'](handleEntityNotFound(_0x2e6160,null))[_0x6ee4('0x1c')](function(_0x8083c7){if(_0x8083c7){var _0x2fe4bb=_0x8083c7[_0x4338d2];var _0x1504da=_0x2fe4bb&&_0x2fe4bb[_0x6ee4('0x122')]?_0x2fe4bb['items']:[];_0x2e6160['send']({'fromKey':_[_0x6ee4('0x86')](_0x2fe4bb[_0x6ee4('0x123')])?undefined:_0x2fe4bb[_0x6ee4('0x123')],'count':_0x1504da[_0x6ee4('0x55')],'rows':_0x1504da});}})[_0x6ee4('0x27')](handleError(_0x2e6160,null));};exports['getOfflineMessages']=function(_0x2a75b3,_0x16c23b){var _0x4ca942={'raw':![],'where':{}};var _0x2e4e99={};var _0x709458={'count':0x0,'rows':[]};return db[_0x6ee4('0x4d')]['findOne']({'where':{'id':_0x2a75b3[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x16c23b,null))[_0x6ee4('0x1c')](function(_0x26a59c){if(_0x26a59c){_0x2e4e99[_0x6ee4('0x46')]=_[_0x6ee4('0x50')](db[_0x6ee4('0x124')][_0x6ee4('0x4e')]);_0x2e4e99[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x2a75b3[_0x6ee4('0x51')]);_0x2e4e99['filters']=_[_0x6ee4('0x52')](_0x2e4e99[_0x6ee4('0x46')],_0x2e4e99[_0x6ee4('0x51')]);_0x4ca942[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x2e4e99[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x4ca942['attributes']=_0x4ca942[_0x6ee4('0x53')]['length']?_0x4ca942[_0x6ee4('0x53')]:_0x2e4e99[_0x6ee4('0x46')];if(!_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x4ca942[_0x6ee4('0x2c')]=qs[_0x6ee4('0x2c')](_0x2a75b3['query'][_0x6ee4('0x2c')]);_0x4ca942[_0x6ee4('0x2f')]=qs['offset'](_0x2a75b3['query']['offset']);}_0x4ca942[_0x6ee4('0x56')]=qs[_0x6ee4('0x57')](_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x4ca942[_0x6ee4('0x58')]=qs[_0x6ee4('0x59')](_[_0x6ee4('0x5a')](_0x2a75b3[_0x6ee4('0x51')],_0x2e4e99[_0x6ee4('0x59')]));_0x4ca942['where']['ChatWebsiteId']=_0x26a59c['id'];if(_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x5b')]){_0x4ca942[_0x6ee4('0x58')]=_[_0x6ee4('0x5c')](_0x4ca942[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x4ca942['attributes'],function(_0x2067ad){var _0x369057={};_0x369057[_0x2067ad]={'$like':'%'+_0x2a75b3[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x369057;})});}_0x4ca942=_[_0x6ee4('0x5c')]({},_0x4ca942,_0x2a75b3['options']);return db[_0x6ee4('0x124')]['count']({'where':_0x4ca942[_0x6ee4('0x58')]})['then'](function(_0x338963){_0x709458['count']=_0x338963;if(_0x2a75b3['query']['includeAll']){_0x4ca942[_0x6ee4('0x60')]=[{'all':!![]}];}else{_0x4ca942[_0x6ee4('0x60')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x6ee4('0xe6')],'as':_0x6ee4('0x125'),'required':![]}];}return db[_0x6ee4('0x124')][_0x6ee4('0x61')](_0x4ca942);})[_0x6ee4('0x1c')](function(_0x23e500){_0x709458[_0x6ee4('0x62')]=_0x23e500;return _0x709458;});}})['then'](respondWithFilteredResult(_0x16c23b,_0x4ca942))[_0x6ee4('0x27')](handleError(_0x16c23b,null));};exports[_0x6ee4('0x126')]=function(_0x5002fe,_0x488e31){return db[_0x6ee4('0x4d')][_0x6ee4('0x65')]({'where':{'id':_0x5002fe[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x488e31,null))[_0x6ee4('0x1c')](function(_0xed8a33){if(_0xed8a33){return _0xed8a33[_0x6ee4('0x126')](_0x5002fe[_0x6ee4('0x68')][_0x6ee4('0x75')],_['omit'](_0x5002fe['body'],[_0x6ee4('0x75'),'id'])||{})[_0x6ee4('0xd8')](function(_0x3d250d){for(var _0xdf9e70=0x0;_0xdf9e70<_0x5002fe[_0x6ee4('0x68')][_0x6ee4('0x75')]['length'];_0xdf9e70+=0x1){socket[_0x6ee4('0x127')](_0x6ee4('0x128'),{'UserId':Number(_0x5002fe['body'][_0x6ee4('0x75')][_0xdf9e70]),'ChatWebsiteId':Number(_0x5002fe[_0x6ee4('0x64')]['id'])});}return _0x3d250d;});}})[_0x6ee4('0x1c')](respondWithResult(_0x488e31,null))['catch'](handleError(_0x488e31,null));};exports[_0x6ee4('0x129')]=function(_0x199807,_0x1bb4a2){return db[_0x6ee4('0x4d')]['find']({'where':{'id':_0x199807[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x1bb4a2,null))[_0x6ee4('0x1c')](function(_0x3fe511){if(_0x3fe511){return _0x3fe511[_0x6ee4('0x129')](_0x199807['query']['ids'])[_0x6ee4('0x1c')](function(){if(_[_0x6ee4('0x12a')](_0x199807[_0x6ee4('0x51')][_0x6ee4('0x75')])){for(var _0x2a01ed=0x0;_0x2a01ed<_0x199807[_0x6ee4('0x51')]['ids'][_0x6ee4('0x55')];_0x2a01ed+=0x1){socket[_0x6ee4('0x127')](_0x6ee4('0x12b'),{'UserId':Number(_0x199807[_0x6ee4('0x51')]['ids'][_0x2a01ed]),'ChatWebsiteId':Number(_0x199807[_0x6ee4('0x64')]['id'])});}}else{socket[_0x6ee4('0x127')](_0x6ee4('0x12b'),{'UserId':Number(_0x199807[_0x6ee4('0x51')][_0x6ee4('0x75')]),'ChatWebsiteId':Number(_0x199807[_0x6ee4('0x64')]['id'])});}});}})[_0x6ee4('0x1c')](respondWithStatusCode(_0x1bb4a2,null))[_0x6ee4('0x27')](handleError(_0x1bb4a2,null));};exports[_0x6ee4('0x12c')]=function(_0x31dfe6,_0x4bce61){var _0x3952e7={};var _0x5012f6={};var _0x2eed44;var _0x5eada9;return db[_0x6ee4('0x4d')][_0x6ee4('0x77')]({'where':{'id':_0x31dfe6[_0x6ee4('0x64')]['id']}})[_0x6ee4('0x1c')](handleEntityNotFound(_0x4bce61,null))[_0x6ee4('0x1c')](function(_0x3a75b1){if(_0x3a75b1){_0x2eed44=_0x3a75b1;_0x5012f6[_0x6ee4('0x46')]=_['keys'](db[_0x6ee4('0xc3')][_0x6ee4('0x4e')]);_0x5012f6[_0x6ee4('0x51')]=_[_0x6ee4('0x50')](_0x31dfe6[_0x6ee4('0x51')]);_0x5012f6['filters']=_[_0x6ee4('0x52')](_0x5012f6[_0x6ee4('0x46')],_0x5012f6[_0x6ee4('0x51')]);_0x3952e7[_0x6ee4('0x53')]=_[_0x6ee4('0x52')](_0x5012f6[_0x6ee4('0x46')],qs[_0x6ee4('0x54')](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x54')]));_0x3952e7[_0x6ee4('0x53')]=_0x3952e7[_0x6ee4('0x53')]['length']?_0x3952e7['attributes']:_0x5012f6['model'];_0x3952e7[_0x6ee4('0x56')]=qs['sort'](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x57')]);_0x3952e7[_0x6ee4('0x58')]=qs['filters'](_[_0x6ee4('0x5a')](_0x31dfe6[_0x6ee4('0x51')],_0x5012f6[_0x6ee4('0x59')]));if(_0x31dfe6[_0x6ee4('0x51')]['filter']){_0x3952e7['where']=_[_0x6ee4('0x5c')](_0x3952e7[_0x6ee4('0x58')],{'$or':_[_0x6ee4('0x4c')](_0x3952e7[_0x6ee4('0x53')],function(_0x288f14){var _0x3309af={};_0x3309af[_0x288f14]={'$like':'%'+_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x5b')]+'%'};return _0x3309af;})});}_0x3952e7=_[_0x6ee4('0x5c')]({},_0x3952e7,_0x31dfe6[_0x6ee4('0x5e')]);return _0x2eed44['getAgents'](_0x3952e7);}})[_0x6ee4('0x1c')](function(_0x15250f){if(_0x15250f){_0x5eada9=_0x15250f[_0x6ee4('0x55')];if(!_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x73')](_0x6ee4('0x78'))){_0x3952e7['limit']=qs[_0x6ee4('0x2c')](_0x31dfe6[_0x6ee4('0x51')][_0x6ee4('0x2c')]);_0x3952e7[_0x6ee4('0x2f')]=qs['offset'](_0x31dfe6['query']['offset']);}return _0x2eed44[_0x6ee4('0x12c')](_0x3952e7);}})[_0x6ee4('0x1c')](function(_0x4d839e){if(_0x4d839e){return _0x4d839e?{'count':_0x5eada9,'rows':_0x4d839e}:null;}})[_0x6ee4('0x1c')](respondWithResult(_0x4bce61,null))[_0x6ee4('0x27')](handleError(_0x4bce61,null));};
\ No newline at end of file