Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 2fe42e6..8ec3af5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6d5e=['orderBy','priority','asc','defaults','customerIp','cf-connecting-ip','headers','x-forwarded-for','first','split','firstName','lastName','x-real-port','browser','format','%s\x20%s','version','unknown','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','ContactId','spread','contact','messageId','interaction','created','autoclose','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','startRouting','Start','EventManager','offline','files','mapKeyOffline','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','Attachment','bulkCreate','Smtp','forwardOffline','service','host','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','forwardOfflineAddress','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','internal','Tag','Tags','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','custom','License','increment','chatLicenseExceeded','push','all','remote','x-real-ip','remoteAddress','referer','virtual','replace','verticalAlignment','color','textColor','color_button','backgroundColor','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','getApplications','addProactiveActions','ChatProactiveAction','getFields','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','userChatWebsite:save','removeAgents','emit','userChatWebsite:remove','getAgents','bluebird','mustache','util','ejs','fs-extra','querystring','ioredis','../../config/logger','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','message','ChatWebsite,\x20%s,\x20%s','catch','status','end','json','undefined','limit','count','offset','set','Content-Range','update','destroy','get','ChatWebsites','UserProfileResource','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','sort','where','pick','filter','merge','options','include','rows','show','params','length','includeAll','find','create','body','user','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','nolimit','order','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addLogo','sitepic','filename','addAvatar','file','addCustomerAvatar','customerAvatar','addSystemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','isNil','existsSync','server/files/images/logos/','join','download','getAvatar','server/files/images/avatars/default_avatar.png','agentAvatar','server/files/images/avatars/','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','systemAvatar','notify','setUA','user-agent','getResult','chat','CmContact','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','Sequelize','from\x20is\x20mandatory','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','CmList','List','Contacts','DESC','ChatApplication','Applications','account','applications','list'];(function(_0x5049e1,_0x4ac87a){var _0x37f162=function(_0x2e06cb){while(--_0x2e06cb){_0x5049e1['push'](_0x5049e1['shift']());}};_0x37f162(++_0x4ac87a);}(_0x6d5e,0x1c6));var _0xe6d5=function(_0x1df8cb,_0x53a66c){_0x1df8cb=_0x1df8cb-0x0;var _0x259a5a=_0x6d5e[_0x1df8cb];return _0x259a5a;};'use strict';var BPromise=require(_0xe6d5('0x0'));var Mustache=require(_0xe6d5('0x1'));var util=require(_0xe6d5('0x2'));var path=require('path');var ejs=require(_0xe6d5('0x3'));var fs=require('fs');var fs_extra=require(_0xe6d5('0x4'));var _=require('lodash');var querystring=require(_0xe6d5('0x5'));var Redis=require(_0xe6d5('0x6'));var qs=require('../../components/parsers/qs');var logger=require(_0xe6d5('0x7'))('api');var config=require('../../config/environment');var db=require(_0xe6d5('0x8'))['db'];config[_0xe6d5('0x9')]=_['defaults'](config['redis'],{'host':_0xe6d5('0xa'),'port':0x18eb});var socket=require(_0xe6d5('0xb'))(new Redis(config[_0xe6d5('0x9')]));require(_0xe6d5('0xc'))[_0xe6d5('0xd')](socket);var jayson=require(_0xe6d5('0xe'));var client=jayson[_0xe6d5('0xf')][_0xe6d5('0x10')]({'port':0x232c});var client9002=jayson[_0xe6d5('0xf')][_0xe6d5('0x10')]({'port':0x232a});var client9003=jayson['client'][_0xe6d5('0x10')]({'port':0x232b});var client9001=jayson[_0xe6d5('0xf')]['http']({'port':0x2329});function respondWithRpcPromise(_0x2990c1,_0x3ad387,_0x35c540,_0x12a715){return new BPromise(function(_0xbb2244,_0x597ca8){var _0x2aa3fa=_0x12a715||client;return _0x2aa3fa[_0xe6d5('0x11')](_0x2990c1,_0x35c540)[_0xe6d5('0x12')](function(_0x2608c6){logger[_0xe6d5('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0xe6d5('0x14'));logger[_0xe6d5('0x15')](_0xe6d5('0x16'),_0x3ad387,_0xe6d5('0x14'),JSON[_0xe6d5('0x17')](_0x2608c6));if(_0x2608c6[_0xe6d5('0x18')]){if(_0x2608c6[_0xe6d5('0x18')]['code']===0x1f4){logger[_0xe6d5('0x18')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0x2608c6[_0xe6d5('0x18')][_0xe6d5('0x19')]);return _0x597ca8(_0x2608c6[_0xe6d5('0x18')][_0xe6d5('0x19')]);}logger[_0xe6d5('0x18')](_0xe6d5('0x1a'),_0x3ad387,_0x2608c6[_0xe6d5('0x18')]['message']);return _0xbb2244(_0x2608c6['error']['message']);}else{logger[_0xe6d5('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x3ad387,_0xe6d5('0x14'));_0xbb2244(_0x2608c6['result'][_0xe6d5('0x19')]);}})[_0xe6d5('0x1b')](function(_0x56fc13){logger[_0xe6d5('0x18')](_0xe6d5('0x1a'),_0x3ad387,_0x56fc13);_0x597ca8(_0x56fc13);});});}function respondWithStatusCode(_0x1dc1f9,_0x5994c8){_0x5994c8=_0x5994c8||0xcc;return function(_0x39bfe5){if(_0x39bfe5){return _0x1dc1f9['sendStatus'](_0x5994c8);}return _0x1dc1f9[_0xe6d5('0x1c')](_0x5994c8)[_0xe6d5('0x1d')]();};}function respondWithResult(_0x20b724,_0x252b20){_0x252b20=_0x252b20||0xc8;return function(_0x55ee29){if(_0x55ee29){return _0x20b724[_0xe6d5('0x1c')](_0x252b20)[_0xe6d5('0x1e')](_0x55ee29);}};}function respondWithFilteredResult(_0x4cfee6,_0x4d43eb){return function(_0x22fe3c){if(_0x22fe3c){var _0x5a47d9=typeof _0x4d43eb['offset']===_0xe6d5('0x1f')&&typeof _0x4d43eb[_0xe6d5('0x20')]===_0xe6d5('0x1f');var _0x2dd993=_0x22fe3c[_0xe6d5('0x21')];var _0x959852=_0x5a47d9?0x0:_0x4d43eb[_0xe6d5('0x22')];var _0x1a2545=_0x5a47d9?_0x22fe3c[_0xe6d5('0x21')]:_0x4d43eb[_0xe6d5('0x22')]+_0x4d43eb['limit'];var _0x492059;if(_0x1a2545>=_0x2dd993){_0x1a2545=_0x2dd993;_0x492059=0xc8;}else{_0x492059=0xce;}_0x4cfee6[_0xe6d5('0x1c')](_0x492059);return _0x4cfee6[_0xe6d5('0x23')](_0xe6d5('0x24'),_0x959852+'-'+_0x1a2545+'/'+_0x2dd993)[_0xe6d5('0x1e')](_0x22fe3c);}return null;};}function saveUpdates(_0x3cbb06){return function(_0x420c95){if(_0x420c95){return _0x420c95[_0xe6d5('0x25')](_0x3cbb06)['then'](function(_0x233a7e){return _0x233a7e;});}return null;};}function removeEntity(_0x9e90d2){return function(_0x3f400b){if(_0x3f400b){return _0x3f400b[_0xe6d5('0x26')]()[_0xe6d5('0x12')](function(){var _0x2bbd64=_0x3f400b[_0xe6d5('0x27')]({'plain':!![]});var _0x2ca1f5=_0xe6d5('0x28');return db[_0xe6d5('0x29')][_0xe6d5('0x26')]({'where':{'type':_0x2ca1f5,'resourceId':_0x2bbd64['id']}})['then'](function(){return _0x3f400b;});})['then'](function(){_0x9e90d2[_0xe6d5('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x54eb06){return function(_0x5492f3){if(!_0x5492f3){_0x54eb06[_0xe6d5('0x2a')](0x194);}return _0x5492f3;};}function handleError(_0x56dc77,_0xf39a96){_0xf39a96=_0xf39a96||0x1f4;return function(_0x1385a4){logger['error'](_0x1385a4[_0xe6d5('0x2b')]);if(_0x1385a4[_0xe6d5('0x2c')]){delete _0x1385a4[_0xe6d5('0x2c')];}_0x56dc77[_0xe6d5('0x1c')](_0xf39a96)[_0xe6d5('0x2d')](_0x1385a4);};}exports[_0xe6d5('0x2e')]=function(_0x13b049,_0x3bd880){var _0x428db9={'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]},_0x46bfeb={},_0x4b5a45={'count':0x0,'rows':[]};var _0x165781=_[_0xe6d5('0x31')](db[_0xe6d5('0x32')][_0xe6d5('0x33')],function(_0x29222c){return{'name':_0x29222c[_0xe6d5('0x34')],'type':_0x29222c[_0xe6d5('0x35')][_0xe6d5('0x36')]};});_0x46bfeb[_0xe6d5('0x37')]=_[_0xe6d5('0x31')](_0x165781,'name');_0x46bfeb[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x13b049[_0xe6d5('0x38')]);_0x46bfeb[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x46bfeb[_0xe6d5('0x37')],_0x46bfeb[_0xe6d5('0x38')]);_0x428db9[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x46bfeb[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x428db9[_0xe6d5('0x3c')]=_0x428db9[_0xe6d5('0x3c')]['length']?_0x428db9[_0xe6d5('0x3c')]:_0x46bfeb['model'];if(!_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3e')]('nolimit')){_0x428db9[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x428db9['offset']=qs[_0xe6d5('0x22')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x22')]);}_0x428db9['order']=qs[_0xe6d5('0x3f')](_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x428db9[_0xe6d5('0x40')]=qs['filters'](_[_0xe6d5('0x41')](_0x13b049[_0xe6d5('0x38')],_0x46bfeb[_0xe6d5('0x3a')]),_0x165781);if(_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x428db9[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x428db9[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x165781,function(_0x18cdd9){if(_0x18cdd9[_0xe6d5('0x35')]!=='VIRTUAL'){var _0x263ed6={};_0x263ed6[_0x18cdd9[_0xe6d5('0x2c')]]={'$like':'%'+_0x13b049[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x263ed6;}})});}_0x428db9=_['merge']({},_0x428db9,_0x13b049[_0xe6d5('0x44')]);var _0x484a79={'where':_0x428db9[_0xe6d5('0x40')]};return db[_0xe6d5('0x32')][_0xe6d5('0x21')](_0x484a79)[_0xe6d5('0x12')](function(_0x5eb3a6){_0x4b5a45['count']=_0x5eb3a6;if(_0x13b049['query']['includeAll']){_0x428db9[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x32')]['findAll'](_0x428db9);})[_0xe6d5('0x12')](function(_0x467827){_0x4b5a45[_0xe6d5('0x46')]=_0x467827;return _0x4b5a45;})[_0xe6d5('0x12')](respondWithFilteredResult(_0x3bd880,_0x428db9))[_0xe6d5('0x1b')](handleError(_0x3bd880,null));};exports[_0xe6d5('0x47')]=function(_0x3c09af,_0x5d0fbc){var _0x45e066={'raw':![],'where':{'id':_0x3c09af[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]},_0x2bb27d={};_0x2bb27d[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x32')][_0xe6d5('0x33')]);_0x2bb27d[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x3c09af[_0xe6d5('0x38')]);_0x2bb27d[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x2bb27d[_0xe6d5('0x37')],_0x2bb27d[_0xe6d5('0x38')]);_0x45e066[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x2bb27d['model'],qs[_0xe6d5('0x3d')](_0x3c09af['query'][_0xe6d5('0x3d')]));_0x45e066['attributes']=_0x45e066[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x45e066['attributes']:_0x2bb27d[_0xe6d5('0x37')];if(_0x3c09af[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x45e066[_0xe6d5('0x45')]=[{'all':!![]}];}_0x45e066=_[_0xe6d5('0x43')]({},_0x45e066,_0x3c09af[_0xe6d5('0x44')]);return db['ChatWebsite'][_0xe6d5('0x4b')](_0x45e066)['then'](handleEntityNotFound(_0x5d0fbc,null))[_0xe6d5('0x12')](respondWithResult(_0x5d0fbc,null))[_0xe6d5('0x1b')](handleError(_0x5d0fbc,null));};exports[_0xe6d5('0x4c')]=function(_0x54a916,_0x2af27e){return db[_0xe6d5('0x32')][_0xe6d5('0x4c')](_0x54a916[_0xe6d5('0x4d')],{})['then'](function(_0x4394f0){var _0x27939b=_0x54a916[_0xe6d5('0x4e')][_0xe6d5('0x27')]({'plain':!![]});if(!_0x27939b)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x27939b['role']===_0xe6d5('0x4e')){var _0x4e4391=_0x4394f0[_0xe6d5('0x27')]({'plain':!![]});var _0x28a6cb=_0xe6d5('0x28');return db['UserProfileSection']['find']({'where':{'name':_0x28a6cb,'userProfileId':_0x27939b[_0xe6d5('0x4f')]},'raw':!![]})[_0xe6d5('0x12')](function(_0x23aaba){if(_0x23aaba&&_0x23aaba['autoAssociation']===0x0){return db[_0xe6d5('0x29')][_0xe6d5('0x4c')]({'name':_0x4e4391[_0xe6d5('0x2c')],'resourceId':_0x4e4391['id'],'type':_0x23aaba[_0xe6d5('0x2c')],'sectionId':_0x23aaba['id']},{})[_0xe6d5('0x12')](function(){return _0x4394f0;});}else{return _0x4394f0;}})[_0xe6d5('0x1b')](function(_0xd9052a){logger['error'](_0xe6d5('0x50'),_0xd9052a);throw _0xd9052a;});}return _0x4394f0;})[_0xe6d5('0x12')](respondWithResult(_0x2af27e,0xc9))[_0xe6d5('0x1b')](handleError(_0x2af27e,null));};exports[_0xe6d5('0x25')]=function(_0x2fe88c,_0x1746e3){if(_0x2fe88c[_0xe6d5('0x4d')]['id']){delete _0x2fe88c[_0xe6d5('0x4d')]['id'];}return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x2fe88c[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x2f')],'as':_0xe6d5('0x30')}]})[_0xe6d5('0x12')](handleEntityNotFound(_0x1746e3,null))['then'](saveUpdates(_0x2fe88c[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x1746e3,null))[_0xe6d5('0x1b')](handleError(_0x1746e3,null));};exports['destroy']=function(_0x3f8dd6,_0x775e8c){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x3f8dd6[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x775e8c,null))[_0xe6d5('0x12')](removeEntity(_0x775e8c,null))[_0xe6d5('0x1b')](handleError(_0x775e8c,null));};exports[_0xe6d5('0x51')]=function(_0x229549,_0x2f5934){return db[_0xe6d5('0x32')][_0xe6d5('0x51')]()[_0xe6d5('0x12')](respondWithResult(_0x2f5934,null))['catch'](handleError(_0x2f5934,null));};exports[_0xe6d5('0x52')]=function(_0x4ea32f,_0xc3d5){if(_0x4ea32f[_0xe6d5('0x4d')]['id']){delete _0x4ea32f[_0xe6d5('0x4d')]['id'];}return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x4ea32f[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0xc3d5,null))['then'](function(_0x3dcb7c){if(_0x3dcb7c){_0x4ea32f[_0xe6d5('0x4d')][_0xe6d5('0x53')]=_0x3dcb7c['id'];return db[_0xe6d5('0x54')]['create'](_0x4ea32f['body']);}})[_0xe6d5('0x12')](respondWithResult(_0xc3d5,null))[_0xe6d5('0x1b')](handleError(_0xc3d5,null));};exports[_0xe6d5('0x55')]=function(_0x114e59,_0x41a446){var _0x397cde={'raw':![],'where':{}};var _0x542d41={};var _0x350429={'count':0x0,'rows':[]};return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x114e59['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x41a446,null))['then'](function(_0x187d41){if(_0x187d41){_0x542d41[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['Disposition'][_0xe6d5('0x33')]);_0x542d41['query']=_[_0xe6d5('0x39')](_0x114e59[_0xe6d5('0x38')]);_0x542d41[_0xe6d5('0x3a')]=_['intersection'](_0x542d41['model'],_0x542d41[_0xe6d5('0x38')]);_0x397cde[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x542d41[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x114e59[_0xe6d5('0x38')]['fields']));_0x397cde[_0xe6d5('0x3c')]=_0x397cde[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x397cde['attributes']:_0x542d41['model'];if(!_0x114e59[_0xe6d5('0x38')]['hasOwnProperty'](_0xe6d5('0x57'))){_0x397cde[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x397cde[_0xe6d5('0x22')]=qs[_0xe6d5('0x22')](_0x114e59['query'][_0xe6d5('0x22')]);}_0x397cde[_0xe6d5('0x58')]=qs['sort'](_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x397cde[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x114e59[_0xe6d5('0x38')],_0x542d41[_0xe6d5('0x3a')]));_0x397cde[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x187d41['id'];if(_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x397cde[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x397cde['where'],{'$or':_[_0xe6d5('0x31')](_0x397cde['attributes'],function(_0x537e99){var _0x5760c7={};_0x5760c7[_0x537e99]={'$like':'%'+_0x114e59[_0xe6d5('0x38')]['filter']+'%'};return _0x5760c7;})});}_0x397cde=_[_0xe6d5('0x43')]({},_0x397cde,_0x114e59[_0xe6d5('0x44')]);return db[_0xe6d5('0x54')][_0xe6d5('0x21')]({'where':_0x397cde[_0xe6d5('0x40')]})['then'](function(_0x374875){_0x350429[_0xe6d5('0x21')]=_0x374875;if(_0x114e59[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x397cde[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x54')][_0xe6d5('0x59')](_0x397cde);})[_0xe6d5('0x12')](function(_0x5b1a59){_0x350429['rows']=_0x5b1a59;return _0x350429;});}})['then'](respondWithFilteredResult(_0x41a446,_0x397cde))['catch'](handleError(_0x41a446,null));};exports[_0xe6d5('0x5a')]=function(_0x279350,_0x245f66){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x279350[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x245f66,null))[_0xe6d5('0x12')](function(_0x2231f4){if(_0x2231f4){return _0x2231f4[_0xe6d5('0x5a')](_0x279350['query'][_0xe6d5('0x5b')]);}})[_0xe6d5('0x12')](respondWithStatusCode(_0x245f66,null))[_0xe6d5('0x1b')](handleError(_0x245f66,null));};exports[_0xe6d5('0x5c')]=function(_0x425afc,_0x19ed45){if(_0x425afc[_0xe6d5('0x4d')]['id']){delete _0x425afc['body']['id'];}return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x425afc[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x19ed45,null))[_0xe6d5('0x12')](function(_0x1cac47){if(_0x1cac47){_0x425afc[_0xe6d5('0x4d')][_0xe6d5('0x53')]=_0x1cac47['id'];return db[_0xe6d5('0x5d')][_0xe6d5('0x4c')](_0x425afc[_0xe6d5('0x4d')]);}})['then'](respondWithResult(_0x19ed45,null))[_0xe6d5('0x1b')](handleError(_0x19ed45,null));};exports[_0xe6d5('0x5e')]=function(_0x24f883,_0x1f880b){var _0x172f7d={'raw':![],'where':{}};var _0x544ae5={};var _0x52cb25={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x24f883['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x1f880b,null))[_0xe6d5('0x12')](function(_0x5b5982){if(_0x5b5982){_0x544ae5[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x5d')][_0xe6d5('0x33')]);_0x544ae5[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x24f883[_0xe6d5('0x38')]);_0x544ae5['filters']=_['intersection'](_0x544ae5['model'],_0x544ae5[_0xe6d5('0x38')]);_0x172f7d[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x544ae5['model'],qs[_0xe6d5('0x3d')](_0x24f883['query']['fields']));_0x172f7d[_0xe6d5('0x3c')]=_0x172f7d[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x172f7d[_0xe6d5('0x3c')]:_0x544ae5[_0xe6d5('0x37')];if(!_0x24f883[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x172f7d[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x24f883['query']['limit']);_0x172f7d[_0xe6d5('0x22')]=qs['offset'](_0x24f883['query'][_0xe6d5('0x22')]);}_0x172f7d[_0xe6d5('0x58')]=qs['sort'](_0x24f883[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x172f7d[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x24f883['query'],_0x544ae5[_0xe6d5('0x3a')]));_0x172f7d[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x5b5982['id'];if(_0x24f883['query'][_0xe6d5('0x42')]){_0x172f7d[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x172f7d[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x172f7d[_0xe6d5('0x3c')],function(_0x3136b2){var _0xcdd2d8={};_0xcdd2d8[_0x3136b2]={'$like':'%'+_0x24f883[_0xe6d5('0x38')]['filter']+'%'};return _0xcdd2d8;})});}_0x172f7d=_[_0xe6d5('0x43')]({},_0x172f7d,_0x24f883[_0xe6d5('0x44')]);return db[_0xe6d5('0x5d')][_0xe6d5('0x21')]({'where':_0x172f7d[_0xe6d5('0x40')]})[_0xe6d5('0x12')](function(_0x50bf10){_0x52cb25[_0xe6d5('0x21')]=_0x50bf10;if(_0x24f883['query'][_0xe6d5('0x4a')]){_0x172f7d[_0xe6d5('0x45')]=[{'all':!![]}];}return db[_0xe6d5('0x5d')][_0xe6d5('0x59')](_0x172f7d);})['then'](function(_0x312c41){_0x52cb25['rows']=_0x312c41;return _0x52cb25;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x1f880b,_0x172f7d))[_0xe6d5('0x1b')](handleError(_0x1f880b,null));};exports[_0xe6d5('0x5f')]=function(_0x441dfa,_0xc93e60){return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x441dfa['params']['id']}})['then'](handleEntityNotFound(_0xc93e60,null))[_0xe6d5('0x12')](function(_0x17b6fc){if(_0x17b6fc){return _0x17b6fc[_0xe6d5('0x5f')](_0x441dfa['query'][_0xe6d5('0x5b')]);}})[_0xe6d5('0x12')](respondWithStatusCode(_0xc93e60,null))[_0xe6d5('0x1b')](handleError(_0xc93e60,null));};exports[_0xe6d5('0x60')]=function(_0x163194,_0x247137){_0x163194[_0xe6d5('0x4d')][_0xe6d5('0x61')]=_0x163194['file'][_0xe6d5('0x62')];return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x163194[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x247137,null))[_0xe6d5('0x12')](saveUpdates(_0x163194[_0xe6d5('0x4d')],null))['then'](respondWithResult(_0x247137,null))[_0xe6d5('0x1b')](handleError(_0x247137,null));};exports[_0xe6d5('0x63')]=function(_0x1cb9a6,_0x2a9cdf){_0x1cb9a6['body']['agentAvatar']=_0x1cb9a6[_0xe6d5('0x64')][_0xe6d5('0x62')];return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x1cb9a6['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x2a9cdf,null))['then'](saveUpdates(_0x1cb9a6['body'],null))[_0xe6d5('0x12')](respondWithResult(_0x2a9cdf,null))['catch'](handleError(_0x2a9cdf,null));};exports[_0xe6d5('0x65')]=function(_0x1322df,_0x89959e){_0x1322df[_0xe6d5('0x4d')][_0xe6d5('0x66')]=_0x1322df[_0xe6d5('0x64')][_0xe6d5('0x62')];return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x1322df[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x89959e,null))[_0xe6d5('0x12')](saveUpdates(_0x1322df[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x89959e,null))[_0xe6d5('0x1b')](handleError(_0x89959e,null));};exports[_0xe6d5('0x67')]=function(_0x3563b4,_0x44db10){_0x3563b4[_0xe6d5('0x4d')]['systemAvatar']=_0x3563b4['file'][_0xe6d5('0x62')];return db[_0xe6d5('0x32')]['find']({'where':{'id':_0x3563b4[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x44db10,null))['then'](saveUpdates(_0x3563b4[_0xe6d5('0x4d')],null))[_0xe6d5('0x12')](respondWithResult(_0x44db10,null))[_0xe6d5('0x1b')](handleError(_0x44db10,null));};exports[_0xe6d5('0x68')]=function(_0xb3fd24,_0x4e5a47){var _0x32fc7a=path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x6a'));var _0x3bee53={'where':{'id':_0xb3fd24['params']['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x5a9cf6=![];return require(_0xe6d5('0x6b'))[_0xe6d5('0x6c')]()[_0xe6d5('0x12')](function(_0x30f7ea){if(_0x30f7ea){_0x5a9cf6=_0x30f7ea['custom'];}})['then'](function(){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x3bee53);})[_0xe6d5('0x12')](handleEntityNotFound(_0x4e5a47,null))[_0xe6d5('0x12')](function(_0x5d1ef2){if(_0x5d1ef2){if(!_[_0xe6d5('0x6d')](_0x5d1ef2['sitepic'])){if(fs[_0xe6d5('0x6e')](path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x6f'),_0x5d1ef2[_0xe6d5('0x61')]))&&_0x5a9cf6){_0x32fc7a=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0x6f'),_0x5d1ef2[_0xe6d5('0x61')]);}}return _0x4e5a47[_0xe6d5('0x71')](_0x32fc7a);}})['catch'](handleError(_0x4e5a47,null));};exports[_0xe6d5('0x72')]=function(_0x91575c,_0x21de5e){var _0x25cb74=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0x73'));var _0x542622={'where':{'id':_0x91575c['params']['id']},'attributes':['id',_0xe6d5('0x74')],'raw':!![]};return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x542622)['then'](handleEntityNotFound(_0x21de5e,null))[_0xe6d5('0x12')](function(_0x19b838){if(_0x19b838){if(!_['isNil'](_0x19b838[_0xe6d5('0x74')])){if(fs[_0xe6d5('0x6e')](path['join'](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x19b838[_0xe6d5('0x74')]))){_0x25cb74=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x19b838[_0xe6d5('0x74')]);}}return _0x21de5e[_0xe6d5('0x71')](_0x25cb74);}})[_0xe6d5('0x1b')](handleError(_0x21de5e,null));};exports['getCustomerAvatar']=function(_0x68ce9a,_0x482759){var _0xb8c059=path['join'](config['root'],'server/files/images/avatars/customer_avatar.png');var _0x5ac945={'where':{'id':_0x68ce9a[_0xe6d5('0x48')]['id']},'attributes':['id',_0xe6d5('0x66'),'showCustomerAvatar'],'raw':!![]};return db[_0xe6d5('0x32')]['find'](_0x5ac945)['then'](handleEntityNotFound(_0x482759,null))[_0xe6d5('0x12')](function(_0x50f161){if(_0x50f161){if(!_[_0xe6d5('0x6d')](_0x50f161[_0xe6d5('0x66')])){if(fs['existsSync'](path[_0xe6d5('0x70')](config['root'],_0xe6d5('0x75'),_0x50f161[_0xe6d5('0x66')]))&&_0x50f161[_0xe6d5('0x76')]){_0xb8c059=path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],'server/files/images/avatars/',_0x50f161[_0xe6d5('0x66')]);}}return _0x482759[_0xe6d5('0x71')](_0xb8c059);}})[_0xe6d5('0x1b')](handleError(_0x482759,null));};exports[_0xe6d5('0x77')]=function(_0x2d0e81,_0x1de4c8){var _0x1fd736=path[_0xe6d5('0x70')](config['root'],_0xe6d5('0x78'));var _0x5c4589={'where':{'id':_0x2d0e81[_0xe6d5('0x48')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xe6d5('0x32')][_0xe6d5('0x4b')](_0x5c4589)[_0xe6d5('0x12')](handleEntityNotFound(_0x1de4c8,null))['then'](function(_0x159d06){if(_0x159d06){if(!_['isNil'](_0x159d06[_0xe6d5('0x79')])){if(fs['existsSync'](path['join'](config[_0xe6d5('0x69')],_0xe6d5('0x75'),_0x159d06['systemAvatar']))){_0x1fd736=path['join'](config['root'],_0xe6d5('0x75'),_0x159d06[_0xe6d5('0x79')]);}}return _0x1de4c8[_0xe6d5('0x71')](_0x1fd736);}})['catch'](handleError(_0x1de4c8,null));};exports[_0xe6d5('0x7a')]=function(_0xa459e8,_0x11ed51){var _0x24c259=require('user-agent-parser');var _0xc907f1=new _0x24c259();var _0x1baac1=_0xc907f1[_0xe6d5('0x7b')](_0xa459e8['headers'][_0xe6d5('0x7c')])[_0xe6d5('0x7d')]();var _0x142e0b={'body':_0xa459e8[_0xe6d5('0x4d')],'channel':_0xe6d5('0x7e')};var _0x239e6b=[];var _0x2b98d9=[];var _0x51ba37={};var _0x344051=![];return db[_0xe6d5('0x7f')][_0xe6d5('0x51')]()[_0xe6d5('0x12')](function(_0x46b661){if(!_0x46b661){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x81'));}_0x239e6b=_[_0xe6d5('0x82')](_[_0xe6d5('0x39')](_0x46b661),[_0xe6d5('0x83'),'updatedAt']);_0x2b98d9=_['difference'](_[_0xe6d5('0x39')](_0x46b661),[_0xe6d5('0x83'),_0xe6d5('0x84'),_0xe6d5('0x85'),_0xe6d5('0x86')]);if(_0xa459e8[_0xe6d5('0x4d')]['id']){delete _0xa459e8['body']['id'];}if(_[_0xe6d5('0x6d')](_0xa459e8['body'][_0xe6d5('0x87')])){throw new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))](_0xe6d5('0x89'));}if(_[_0xe6d5('0x6d')](_0xa459e8[_0xe6d5('0x4d')]['body'])||_0xa459e8['body'][_0xe6d5('0x4d')]===''){throw new db[(_0xe6d5('0x88'))]['ValidationError'](_0xe6d5('0x8a'));}if(_['isNil'](_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')])){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x8c')+_0x2b98d9);}if(!_[_0xe6d5('0x8d')](_0x2b98d9,_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')])){throw new db['Sequelize'][(_0xe6d5('0x80'))](_0xe6d5('0x8e')+_0x2b98d9);}_0x51ba37[_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x8b')]]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x87')];})[_0xe6d5('0x12')](function(){return db[_0xe6d5('0x32')]['find']({'where':{'id':_0xa459e8['params']['id']},'include':[{'model':db[_0xe6d5('0x8f')],'as':_0xe6d5('0x90'),'include':[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0x91'),'where':_0x51ba37,'limit':0x1,'order':[['updatedAt',_0xe6d5('0x92')]]}]},{'model':db[_0xe6d5('0x93')],'as':_0xe6d5('0x94')}]});})['then'](handleEntityNotFound(_0x11ed51,null))[_0xe6d5('0x12')](function(_0x2370d0){if(_0x2370d0&&_0x2370d0[_0xe6d5('0x90')]){_0x142e0b[_0xe6d5('0x95')]=_0x2370d0;_0x142e0b[_0xe6d5('0x96')]=_0x2370d0[_0xe6d5('0x94')];_0x142e0b[_0xe6d5('0x97')]=_0x2370d0[_0xe6d5('0x90')];_0x142e0b[_0xe6d5('0x96')]=_[_0xe6d5('0x98')](_0x142e0b[_0xe6d5('0x96')],[_0xe6d5('0x99')],[_0xe6d5('0x9a')]);if(_0x142e0b['account'][_0xe6d5('0x94')]){delete _0x142e0b['account'][_0xe6d5('0x94')];}if(_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')]&&_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')][_0xe6d5('0x91')][_0xe6d5('0x49')]){return _0x142e0b[_0xe6d5('0x95')][_0xe6d5('0x90')][_0xe6d5('0x91')][0x0];}var _0x2ed970=_[_0xe6d5('0x9b')](_0xa459e8[_0xe6d5('0x4d')],{'firstName':_0xa459e8[_0xe6d5('0x4d')]['from'],'ListId':_0x2370d0[_0xe6d5('0x86')]});_0x2ed970[_0xa459e8['body'][_0xe6d5('0x8b')]]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x87')];return db[_0xe6d5('0x7f')][_0xe6d5('0x4c')](_0x2ed970,{'fields':_0x239e6b,'raw':!![]});}})['then'](handleEntityNotFound(_0x11ed51,null))[_0xe6d5('0x12')](function(_0x5225ce){_0x142e0b['contact']=_0x5225ce;var _0x4695d9=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x9c')];if(_0xa459e8['headers']['cf-connecting-ip']){_0x4695d9=_0xa459e8['headers'][_0xe6d5('0x9d')];}else if(_0xa459e8[_0xe6d5('0x9e')][_0xe6d5('0x9f')]){_0x4695d9=_[_0xe6d5('0xa0')](_0xa459e8['headers'][_0xe6d5('0x9f')][_0xe6d5('0xa1')](','));}if(_0x5225ce){var _0x1343ba={'ContactId':_0x5225ce['id'],'ChatWebsiteId':_0xa459e8[_0xe6d5('0x48')]['id'],'from':(_0x5225ce[_0xe6d5('0xa2')]||'')+'\x20'+(_0x5225ce[_0xe6d5('0xa3')]||''),'customerIp':_0x4695d9,'customerPort':_0xa459e8[_0xe6d5('0x9e')][_0xe6d5('0xa4')]?_0xa459e8['headers'][_0xe6d5('0xa4')]:null,'referer':_0xa459e8[_0xe6d5('0x4d')]['referer'],'browserName':_0x1baac1[_0xe6d5('0xa5')][_0xe6d5('0x2c')]&&_0x1baac1[_0xe6d5('0xa5')]['version']?util[_0xe6d5('0xa6')](_0xe6d5('0xa7'),_0x1baac1[_0xe6d5('0xa5')]['name'],_0x1baac1[_0xe6d5('0xa5')]['version']):'unknown','browserVersion':_0x1baac1['browser'][_0xe6d5('0xa8')]||_0xe6d5('0xa9'),'osName':util[_0xe6d5('0xa6')](_0xe6d5('0xa7'),_0x1baac1['os'][_0xe6d5('0x2c')],_0x1baac1['os'][_0xe6d5('0xa8')]),'osVersion':_0x1baac1['os'][_0xe6d5('0xa8')],'deviceModel':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x37')]&&_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')]?util[_0xe6d5('0xa6')](_0xe6d5('0xac'),_0x1baac1['device'][_0xe6d5('0x37')],_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')],_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x35')]):null,'deviceVendor':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0xab')],'deviceType':_0x1baac1[_0xe6d5('0xaa')][_0xe6d5('0x35')],'formData':JSON[_0xe6d5('0x17')](_0xa459e8[_0xe6d5('0x4d')])};var _0x5ab6a2={'ChatWebsiteId':_0xa459e8['params']['id'],'closed':![]};if(_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]){_0x5ab6a2['threadId']=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')];return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':_0x5ab6a2})[_0xe6d5('0x12')](function(_0xc8320f){if(_0xc8320f){return[_0xc8320f,![]];}_0x1343ba[_0xe6d5('0xad')]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')];_0x1343ba['externalUrl']=_0xa459e8[_0xe6d5('0x4d')]['externalUrl'];return db[_0xe6d5('0xae')][_0xe6d5('0x4c')](_0x1343ba)['then'](function(_0x3af1b1){return[_0x3af1b1,!![]];});});}_0x5ab6a2[_0xe6d5('0xaf')]=_0x5225ce['id'];if(_0xa459e8[_0xe6d5('0x4d')]['interaction']&&_0xa459e8['body']['interaction']['id']){_0x5ab6a2['id']=_0xa459e8['body']['interaction']['id'];return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':_0x5ab6a2})['then'](function(_0x3585b5){if(_0x3585b5){return[_0x3585b5,![]];}return db['ChatInteraction']['create'](_0x1343ba)[_0xe6d5('0x12')](function(_0x40edab){return[_0x40edab,!![]];});});}return db['ChatInteraction'][_0xe6d5('0x4c')](_0x1343ba)[_0xe6d5('0x12')](function(_0x3c6248){return[_0x3c6248,!![]];});}})[_0xe6d5('0xb0')](function(_0x3eaa1d,_0x207f02){if(_0x3eaa1d){_0x344051=_0x207f02;if(!_0x207f02){var _0x2c2808={'from':(_0x142e0b[_0xe6d5('0xb1')][_0xe6d5('0xa2')]||'')+'\x20'+(_0x142e0b[_0xe6d5('0xb1')]['lastName']||'')};if(_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]&&_0xa459e8['body'][_0xe6d5('0xb2')]&&_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xad')]!=_0xa459e8['body']['messageId']){_0x2c2808[_0xe6d5('0xad')]=_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xb2')];}return _0x3eaa1d[_0xe6d5('0x25')](_0x2c2808);}else{return _0x3eaa1d;}}})[_0xe6d5('0x12')](function(_0x389229){_0x142e0b[_0xe6d5('0xb3')]=_0x389229[_0xe6d5('0x27')]({'plain':!![]});_0x142e0b[_0xe6d5('0xb3')][_0xe6d5('0xb4')]=_0x344051;if(_0x142e0b['interaction'][_0xe6d5('0xb4')]){if(_0x142e0b['account'][_0xe6d5('0xb5')]){_0x142e0b[_0xe6d5('0x96')]['push']({'id':0x0,'priority':_0x142e0b['applications'][_0xe6d5('0x49')]+0x1,'app':_0xe6d5('0xb6'),'appdata':_0xe6d5('0xb7'),'interval':_0xe6d5('0xb8')});}}return db[_0xe6d5('0xb9')][_0xe6d5('0x4c')]({'body':_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0x4d')],'ChatWebsiteId':_0xa459e8['params']['id'],'ChatInteractionId':_0x389229['id'],'direction':'in','ContactId':_0x142e0b[_0xe6d5('0xb1')]['id'],'AttachmentId':_0xa459e8[_0xe6d5('0x4d')][_0xe6d5('0xba')]});})['then'](function(_0x2f28c8){_0x142e0b[_0xe6d5('0x19')]=_0x2f28c8;if(_0x142e0b[_0xe6d5('0xb3')]['UserId']){return db['User'][_0xe6d5('0x4b')]({'attributes':['id',_0xe6d5('0x2c')],'where':{'id':_0x142e0b[_0xe6d5('0xb3')][_0xe6d5('0xbb')]}})[_0xe6d5('0x12')](function(_0xda9ce){if(_0xda9ce){_0x142e0b[_0xe6d5('0x96')][_0xe6d5('0xbc')]({'id':0x0,'priority':0x0,'app':_0xe6d5('0xbd'),'appdata':_0xda9ce['name']+','+(_0x142e0b[_0xe6d5('0x95')][_0xe6d5('0xbe')]||0xa),'interval':'*,*,*,*'});_0x142e0b[_0xe6d5('0xbf')]=!![];}return respondWithRpcPromise('Start',_0xe6d5('0xc0'),_0x142e0b);});}return respondWithRpcPromise(_0xe6d5('0xc1'),_0xe6d5('0xc0'),_0x142e0b);})[_0xe6d5('0x12')](function(_0x3119a2){respondWithRpcPromise(_0xe6d5('0xc2'),_0xe6d5('0xc2'),{'event':_0xe6d5('0x7a'),'message':_0x3119a2},client9002);return _0x3119a2;})[_0xe6d5('0x12')](respondWithResult(_0x11ed51,null))[_0xe6d5('0x1b')](handleError(_0x11ed51,null));};exports[_0xe6d5('0xc3')]=function(_0x382273,_0x44b2ac){var _0x2afa44,_0x5a0731,_0x3afa7f;var _0x5bbb4c=[];var _0x559317={};var _0x3ec330=_0x382273[_0xe6d5('0xc4')]||[];var _0x53346d=[];var _0x59f592;return db[_0xe6d5('0x7f')][_0xe6d5('0x51')]()['then'](function(_0x21bfb6){if(!_0x21bfb6){throw new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))](_0xe6d5('0x81'));}_0x5bbb4c=_[_0xe6d5('0x82')](_[_0xe6d5('0x39')](_0x21bfb6),[_0xe6d5('0x83'),'updatedAt','CompanyId',_0xe6d5('0x86')]);if(_0x382273[_0xe6d5('0x4d')]['id']){delete _0x382273[_0xe6d5('0x4d')]['id'];}if(_['isNil'](_0x382273[_0xe6d5('0x4d')]['from'])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db[(_0xe6d5('0x88'))][(_0xe6d5('0x80'))]('from\x20is\x20mandatory'));}if(_[_0xe6d5('0x6d')](_0x382273[_0xe6d5('0x4d')]['body'])||_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x4d')]===''){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db[(_0xe6d5('0x88'))]['ValidationError'](_0xe6d5('0x8a')));}if(_[_0xe6d5('0x6d')](_0x382273[_0xe6d5('0x4d')][_0xe6d5('0xc5')])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)['send'](new db[(_0xe6d5('0x88'))]['ValidationError']('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5bbb4c));}if(!_['includes'](_0x5bbb4c,_0x382273[_0xe6d5('0x4d')]['mapKeyOffline'])){throw _0x44b2ac[_0xe6d5('0x1c')](0x1f4)[_0xe6d5('0x2d')](new db['Sequelize'][(_0xe6d5('0x80'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5bbb4c));}_0x559317[_0x382273['body']['mapKeyOffline']]=_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')];})[_0xe6d5('0x12')](function(){return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x382273[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x8f')],'as':'List'},{'model':db[_0xe6d5('0xc6')],'as':_0xe6d5('0xc6')}]});})[_0xe6d5('0x12')](handleEntityNotFound(_0x44b2ac,null))[_0xe6d5('0x12')](function(_0x5a81dc){if(_0x5a81dc&&_0x5a81dc['List']){_0x5a0731=_0x5a81dc;var _0x1222d7=_[_0xe6d5('0x9b')](_0x382273[_0xe6d5('0x4d')],{'firstName':_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')],'phone':_0x382273['body'][_0xe6d5('0x87')],'ListId':_0x5a81dc[_0xe6d5('0x86')]});_0x1222d7[_0x382273['body'][_0xe6d5('0xc5')]]=_0x382273[_0xe6d5('0x4d')][_0xe6d5('0x87')];return db[_0xe6d5('0x7f')][_0xe6d5('0xc7')]({'where':_0x559317,'defaults':_0x1222d7});}})['spread'](function(_0x57efa2){if(_0x57efa2){_0x3afa7f=_0x57efa2;var _0x242cec=fs[_0xe6d5('0xc8')](path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0xc9')),_0xe6d5('0xca'));var _0x3700d4=ejs[_0xe6d5('0xcb')](_0x242cec,{'body':_[_0xe6d5('0xcc')](_0x382273['body'][_0xe6d5('0x4d')]),'bodyTitle':_0x5a0731[_0xe6d5('0xcd')]});return db[_0xe6d5('0xce')][_0xe6d5('0x4c')]({'body':_0x3700d4,'ContactId':_0x57efa2['id'],'ChatWebsiteId':_0x5a0731['id']});}})[_0xe6d5('0x12')](function(_0x4e975e){_0x59f592=_0x4e975e;if(_0x3ec330['length']){var _0x435de7=_0x3ec330[_0xe6d5('0x31')](function(_0x194221){return{'name':_0x194221[_0xe6d5('0xcf')],'basename':_0x194221['filename'],'type':_0x194221[_0xe6d5('0xd0')],'ChatOfflineMessageId':_0x4e975e['id']};});_0x53346d=_0x435de7[_0xe6d5('0x31')](_0x52a2a9=>{var _0x2862ed={'filename':_0x52a2a9[_0xe6d5('0x2c')],'path':path[_0xe6d5('0x70')](config[_0xe6d5('0x69')],_0xe6d5('0xd1'),_0xe6d5('0xc4'),_0xe6d5('0xd2'),_0xe6d5('0xd3'),_0x52a2a9[_0xe6d5('0xd4')])};return _0x2862ed;});if(!_0x5a0731[_0xe6d5('0xd5')]){return db['sequelize']['transaction'](function(_0x119ac8){return db[_0xe6d5('0xd6')][_0xe6d5('0xd7')](_0x435de7,{'transaction':_0x119ac8});});}}})[_0xe6d5('0x12')](function(){if(_0x59f592){_0x2afa44=_0x59f592;return db[_0xe6d5('0xc6')][_0xe6d5('0x56')]({'where':{'active':!![]},'include':[{'model':db['MailServerOut'],'as':_0xe6d5('0xd8'),'raw':!![]}]});}})[_0xe6d5('0x12')](function(_0xc9bd67){if(_0xc9bd67&&_0xc9bd67[_0xe6d5('0xd8')]&&_0x5a0731[_0xe6d5('0xd9')]&&_0x5a0731['forwardOfflineAddress']){var _0x268687={'tls':{'rejectUnauthorized':![]}};if(_0xc9bd67['Smtp']['service']){_0x268687[_0xe6d5('0xda')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xda')];}else{_0x268687[_0xe6d5('0xdb')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdb')];_0x268687['port']=_0xc9bd67[_0xe6d5('0xd8')]['port'];_0x268687[_0xe6d5('0xdc')]=_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdc')];}if(_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdd')]){_0x268687[_0xe6d5('0xde')]={'user':_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0x4e')],'pass':_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0xdf')]};}return respondWithRpcPromise(_0xe6d5('0xe0'),_0xe6d5('0xe1'),{'account':_0x268687,'message':{'from':util[_0xe6d5('0xa6')](_0xe6d5('0xe2'),_0xc9bd67['name'],_0xc9bd67[_0xe6d5('0xe3')]||_0xc9bd67[_0xe6d5('0xd8')][_0xe6d5('0x4e')]),'to':_0x5a0731[_0xe6d5('0xe4')],'subject':_0x5a0731[_0xe6d5('0xe5')],'html':_0x2afa44[_0xe6d5('0x4d')],'attachments':_0x53346d}},client9003)[_0xe6d5('0x12')](function(){return _0x2afa44;})[_0xe6d5('0x1b')](function(_0x1ef33e){console[_0xe6d5('0x18')](_0x1ef33e);});}})[_0xe6d5('0x12')](function(){if(_0x5a0731&&_0x5a0731[_0xe6d5('0xd5')]&&_0x5a0731['MailAccountId']){var _0x189cb7=[];if(_0x3ec330[_0xe6d5('0x49')]){_0x189cb7=_0x3ec330[_0xe6d5('0x31')](function(_0x4c3487){return{'name':_0x4c3487[_0xe6d5('0xcf')],'basename':_0x4c3487[_0xe6d5('0x62')],'type':_0x4c3487[_0xe6d5('0xd0')],'ChatOfflineMessageId':_0x59f592['id']};});}var _0x2f010f;if(!_[_0xe6d5('0x6d')](_0x5a0731[_0xe6d5('0xe6')])){var _0x1bcfa3=_['map'](_0x382273[_0xe6d5('0x4d')],function(_0x1bfa28){return _0x1bfa28;});var _0x52c7ca=_[_0xe6d5('0xe7')](_0x1bcfa3)[0x0];var _0x508b14=_[_0xe6d5('0xe8')](_0x52c7ca,function(_0x5cf3e4){return _0x5cf3e4;});_0x2f010f=_0x508b14[0x1][_0x5a0731[_0xe6d5('0xe6')]];}var _0x28249a={'from':_0x3afa7f[_0xe6d5('0xe3')],'firstName':_0x3afa7f['firstName'],'lastName':_0x3afa7f['lastName'],'mapKey':'email','message':{'from':_0x3afa7f[_0xe6d5('0xe3')],'to':_0x5a0731[_0xe6d5('0xc6')]['email'],'cc':'','subject':_[_0xe6d5('0x6d')](_0x2f010f)?_0x5a0731[_0xe6d5('0xe5')]:_0x2f010f,'messageId':'','sentAt':new Date(),'attach':_0x189cb7['length'],'attachments':_0x189cb7,'originChannel':'Chat','ChatWebsiteId':_0x5a0731['id'],'ChatOfflineMessageId':_0x2afa44['id'],'originTo':_0x5a0731[_0xe6d5('0xc6')][_0xe6d5('0xe3')]},'body':_0x2afa44[_0xe6d5('0x4d')]};var _0x3df306={'account':{'id':_0x5a0731['MailAccountId']},'body':_0x28249a,'log':_0xe6d5('0xe9')};return respondWithRpcPromise(_0xe6d5('0xe9'),_0xe6d5('0xea'),_0x3df306,client9001)[_0xe6d5('0x12')](function(){return _0x2afa44;})[_0xe6d5('0x1b')](function(_0x360de2){console[_0xe6d5('0x18')](_0x360de2);});}return;})[_0xe6d5('0x12')](function(){if(_0x2afa44){return _0x2afa44;}})[_0xe6d5('0x12')](respondWithResult(_0x44b2ac,null))[_0xe6d5('0x1b')](function(_0x3fa56a){console['error'](_0xe6d5('0x1b'),_0x3fa56a);for(var _0x163ea2 of _0x3ec330){var _0x46a7e2=path['join'](config['root'],'server',_0xe6d5('0xc4'),_0xe6d5('0xd2'),_0xe6d5('0xd3'),_0x163ea2['filename']);fs_extra[_0xe6d5('0xeb')](_0x46a7e2)[_0xe6d5('0x1b')](function(_0x412658){console[_0xe6d5('0x18')](_0xe6d5('0xec'),_0x46a7e2,_0x412658);});}});};exports[_0xe6d5('0xed')]=function(_0x287821,_0x1059d8){return db[_0xe6d5('0xae')][_0xe6d5('0x4b')]({'where':{'id':_0x287821['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x1059d8,null))['then'](function(_0xf576c8){if(_0xf576c8){return _0xf576c8['addInteraction'](_0x287821[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x287821['body'],[_0xe6d5('0x5b'),'id'])||{});}})[_0xe6d5('0x12')](respondWithResult(_0x1059d8,null))[_0xe6d5('0x1b')](handleError(_0x1059d8,null));};exports[_0xe6d5('0xef')]=function(_0x4e37f0,_0x4a71a2){var _0xa93669={'raw':![],'where':{}};var _0x167930={};var _0x48e6d1={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x4e37f0['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x4a71a2,null))[_0xe6d5('0x12')](function(_0x5cb442){if(_0x5cb442){_0x167930['model']=_['keys'](db[_0xe6d5('0xae')][_0xe6d5('0x33')]);_0x167930['query']=_['keys'](_0x4e37f0[_0xe6d5('0x38')]);_0x167930[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x167930[_0xe6d5('0x37')],_0x167930[_0xe6d5('0x38')]);_0xa93669[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x167930['model'],qs[_0xe6d5('0x3d')](_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0xa93669[_0xe6d5('0x3c')]=_0xa93669[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0xa93669['attributes']:_0x167930[_0xe6d5('0x37')];if(!_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0xa93669[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0xa93669['offset']=qs['offset'](_0x4e37f0[_0xe6d5('0x38')]['offset']);}_0xa93669[_0xe6d5('0x58')]=qs[_0xe6d5('0x3f')](_0x4e37f0[_0xe6d5('0x38')]['sort']);_0xa93669['where']=qs['filters'](_[_0xe6d5('0x41')](_0x4e37f0[_0xe6d5('0x38')],_0x167930[_0xe6d5('0x3a')]));_0xa93669[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x5cb442['id'];if(_0x4e37f0[_0xe6d5('0x38')]['filter']){_0xa93669[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0xa93669[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0xa93669[_0xe6d5('0x3c')],function(_0x5a90a2){var _0x467de9={};_0x467de9[_0x5a90a2]={'$like':'%'+_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x467de9;})});}_0xa93669=_[_0xe6d5('0x43')]({},_0xa93669,_0x4e37f0[_0xe6d5('0x44')]);return db[_0xe6d5('0xae')]['count']({'where':_0xa93669[_0xe6d5('0x40')]})[_0xe6d5('0x12')](function(_0xabcac7){_0x48e6d1['count']=_0xabcac7;if(_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0xa93669['include']=[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0xf0'),'required':![]},{'model':db[_0xe6d5('0xf1')],'as':_0xe6d5('0xf2'),'attributes':[_0xe6d5('0x2c'),'fullname',_0xe6d5('0xf3')],'required':![]},{'model':db[_0xe6d5('0xf4')],'as':_0xe6d5('0xf5'),'attributes':['id',_0xe6d5('0x2c'),'color'],'where':_0x4e37f0['query']['tag']?{'id':_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0xf6')]}:undefined,'required':_0x4e37f0[_0xe6d5('0x38')][_0xe6d5('0xf6')]?!![]:![]}];}return db[_0xe6d5('0xae')][_0xe6d5('0x59')](_0xa93669);})[_0xe6d5('0x12')](function(_0x36337d){_0x48e6d1['rows']=_0x36337d;return _0x48e6d1;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x4a71a2,_0xa93669))[_0xe6d5('0x1b')](handleError(_0x4a71a2,null));};function iftimePromise(_0x2a501d,_0x48142a){return respondWithRpcPromise(_0xe6d5('0xf7'),_0xe6d5('0xf8'),{'command':_0x48142a[_0xe6d5('0xf9')]?util['format'](_0xe6d5('0xfa'),_0x2a501d[_0xe6d5('0xfb')],_0x48142a[_0xe6d5('0xf9')]):util[_0xe6d5('0xa6')](_0xe6d5('0xfc'),_0x2a501d[_0xe6d5('0xfb')])},client9002)['then'](function(_0x5dd782){var _0x42d4bc=_0x5dd782&&_0x5dd782[_0xe6d5('0xfd')](_0xe6d5('0xfe'))>=0x0?!![]:![];logger['info'](_0xe6d5('0xff'),_0x48142a['id'],_0x2a501d['id'],_0x2a501d[_0xe6d5('0xfb')],_0x42d4bc?_0xe6d5('0x100'):_0xe6d5('0x101'),_0x48142a['timezone']?_0x48142a[_0xe6d5('0xf9')]:_0xe6d5('0x102'));return _0x42d4bc;})[_0xe6d5('0x1b')](function(_0x4bff2c){logger[_0xe6d5('0x18')](_0xe6d5('0xff'),_0x48142a['id'],_0x2a501d['id'],_0x2a501d[_0xe6d5('0xfb')],util[_0xe6d5('0x103')](_0x4bff2c,{'showHidden':![],'depth':null}),_0x48142a[_0xe6d5('0xf9')]?_0x48142a[_0xe6d5('0xf9')]:_0xe6d5('0x102'));return![];});}exports['getSnippet']=function(_0xc134a6,_0xcaac11){var _0x4e6549=0x0;var _0x353942=0x0;var _0x7d2d79=![];var _0x41b535;var _0x53b53a;return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0xc134a6[_0xe6d5('0x48')]['id']},'include':[{'model':db[_0xe6d5('0x104')],'as':_0xe6d5('0x104'),'include':[{'model':db[_0xe6d5('0x104')],'as':_0xe6d5('0x105'),'attributes':['id',_0xe6d5('0xfb')],'raw':!![]}]}]})[_0xe6d5('0x12')](handleEntityNotFound(_0xcaac11,null))[_0xe6d5('0x12')](function(_0xce13d2){if(_0xce13d2){_0x41b535=_0xce13d2;return _0xce13d2[_0xe6d5('0x106')]({'raw':!![]});}})[_0xe6d5('0x12')](function(_0x1c55e4){if(_0x41b535){if(_0x1c55e4){_0x53b53a=_0x1c55e4;}}return require('../../config/license/util')[_0xe6d5('0x6c')]();})['then'](function(_0x2774d7){if(_0x2774d7){_0x353942=_0x2774d7['virtual'];_0x7d2d79=_0x2774d7[_0xe6d5('0x107')];}})[_0xe6d5('0x12')](function(){return db[_0xe6d5('0xae')][_0xe6d5('0x21')]({'where':{'closed':![]}});})['then'](function(_0x1b9376){_0x4e6549=_0x1b9376;if(_0x353942&&_0x1b9376>_0x353942){return db[_0xe6d5('0x108')][_0xe6d5('0x56')]({'where':{'id':0x1}})[_0xe6d5('0x12')](function(_0x48556a){if(_0x48556a){_0x48556a[_0xe6d5('0x109')](_0xe6d5('0x10a'));}});}})[_0xe6d5('0x12')](function(){if(_0x41b535[_0xe6d5('0x104')]&&_0x41b535['Interval'][_0xe6d5('0x105')]){var _0x925f22=[];for(var _0xca2705=0x0;_0xca2705<_0x41b535['Interval']['Intervals']['length'];_0xca2705++){var _0x20e2a1=_0x41b535[_0xe6d5('0x104')][_0xe6d5('0x105')][_0xca2705]['get']({'plain':!![]});_0x925f22[_0xe6d5('0x10b')](iftimePromise(_0x20e2a1,_0x41b535));}return BPromise[_0xe6d5('0x10c')](_0x925f22)['then'](function(_0x83faf){return _['some'](_0x83faf);});}else{return!![];}})[_0xe6d5('0x12')](function(_0x1cf712){var _0x4b426f=fs[_0xe6d5('0xc8')](path['join'](config[_0xe6d5('0x69')],'server/files/chat/iframe.ejs'),_0xe6d5('0xca'));var _0x48cb34={'remote':_0x41b535[_0xe6d5('0x10d')],'query':querystring[_0xe6d5('0x17')](_[_0xe6d5('0x43')](_0x41b535[_0xe6d5('0x27')]({'plain':!![]}),{'customerIp':_0xc134a6[_0xe6d5('0x9e')][_0xe6d5('0x9f')]||_0xc134a6[_0xe6d5('0x9e')][_0xe6d5('0x10e')]||_0xc134a6['connection'][_0xe6d5('0x10f')]||_0xc134a6['ip'],'referer':_0xc134a6['headers'][_0xe6d5('0x110')],'openedInteractions':_0x4e6549,'maxInteractions':_0x353942,'virtual':_0x7d2d79[_0xe6d5('0x111')],'online':_0x1cf712,'custom':_0x7d2d79}))[_0xe6d5('0x112')](/'/g,'\x5c\x27')};_0xcaac11[_0xe6d5('0x2d')](ejs[_0xe6d5('0xcb')](Mustache[_0xe6d5('0xcb')](_0x4b426f,_0x48cb34),{'proactiveActions':_0x53b53a,'alignment':_0x41b535['alignment'],'verticalAlignment':_0x41b535[_0xe6d5('0x113')],'div_color':_0x41b535[_0xe6d5('0x114')],'text_color':_0x41b535[_0xe6d5('0x115')],'button_color':_0x41b535[_0xe6d5('0x116')],'background_color':_0x41b535[_0xe6d5('0x117')]}));})[_0xe6d5('0x1b')](handleError(_0xcaac11,null));};exports['addApplications']=function(_0x314d26,_0x112e36){var _0x3e5a2c=_0x314d26['params']['id'];var _0x1181dd=_0x314d26[_0xe6d5('0x4d')];var _0x37a533=0xc8;var _0x2df312=null;return db[_0xe6d5('0x118')][_0xe6d5('0x119')]({'isolationLevel':db[_0xe6d5('0x118')][_0xe6d5('0x11a')][_0xe6d5('0x11b')][_0xe6d5('0x11c')]},function(_0x4d5071){return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x3e5a2c},'transaction':_0x4d5071})[_0xe6d5('0x12')](function(_0x641d0e){if(_0x641d0e){return db['ChatApplication']['destroy']({'where':{'ChatWebsiteId':_0x3e5a2c},'transaction':_0x4d5071})[_0xe6d5('0x12')](function(){var _0x523010=_[_0xe6d5('0x31')](_0x1181dd,function(_0x4c061e){_0x4c061e['ChatWebsiteId']=_0x3e5a2c;return _0x4c061e;});return db[_0xe6d5('0x93')][_0xe6d5('0xd7')](_0x523010,{'transaction':_0x4d5071});});}else{_0x37a533=0x194;_0x2df312=[];}});})[_0xe6d5('0x12')](function(){if(_0x37a533!==0x194){return db[_0xe6d5('0x93')][_0xe6d5('0x11d')]({'where':{'ChatWebsiteId':_0x3e5a2c},'order':_0xe6d5('0x99')})[_0xe6d5('0x12')](function(_0x10c334){_0x2df312=_0x10c334;});}})[_0xe6d5('0x1b')](function(_0x40b12b){_0x37a533=0x1f4;logger[_0xe6d5('0x18')](_0x40b12b[_0xe6d5('0x2b')]);if(_0x40b12b[_0xe6d5('0x2c')]){delete _0x40b12b[_0xe6d5('0x2c')];}_0x2df312=_0x40b12b;})['finally'](function(){if(_0x2df312===null){_0x112e36[_0xe6d5('0x2a')](_0x37a533);}else{if(_0x37a533===0x1f4){_0x112e36['status'](_0x37a533)[_0xe6d5('0x2d')](_0x2df312);}else{_0x112e36['status'](_0x37a533)[_0xe6d5('0x1e')](_0x2df312);}}});};exports['getApplications']=function(_0x532576,_0x2aeecc){var _0x9d6f43={};var _0x3c00b4={};var _0x37a0c6;var _0x110112;return db['ChatWebsite']['findOne']({'where':{'id':_0x532576['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x2aeecc,null))[_0xe6d5('0x12')](function(_0x5bdcfb){if(_0x5bdcfb){_0x37a0c6=_0x5bdcfb;_0x3c00b4['model']=_[_0xe6d5('0x39')](db['ChatApplication'][_0xe6d5('0x33')]);_0x3c00b4[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x532576['query']);_0x3c00b4['filters']=_[_0xe6d5('0x3b')](_0x3c00b4[_0xe6d5('0x37')],_0x3c00b4[_0xe6d5('0x38')]);_0x9d6f43['attributes']=_[_0xe6d5('0x3b')](_0x3c00b4[_0xe6d5('0x37')],qs['fields'](_0x532576[_0xe6d5('0x38')]['fields']));_0x9d6f43[_0xe6d5('0x3c')]=_0x9d6f43[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x9d6f43['attributes']:_0x3c00b4[_0xe6d5('0x37')];_0x9d6f43[_0xe6d5('0x58')]=qs[_0xe6d5('0x3f')](_0x532576[_0xe6d5('0x38')]['sort']);_0x9d6f43['where']=qs['filters'](_[_0xe6d5('0x41')](_0x532576[_0xe6d5('0x38')],_0x3c00b4[_0xe6d5('0x3a')]));if(_0x532576[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x9d6f43['where']=_[_0xe6d5('0x43')](_0x9d6f43[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x9d6f43[_0xe6d5('0x3c')],function(_0x35e75c){var _0x40008f={};_0x40008f[_0x35e75c]={'$like':'%'+_0x532576['query'][_0xe6d5('0x42')]+'%'};return _0x40008f;})});}_0x9d6f43=_[_0xe6d5('0x43')]({},_0x9d6f43,_0x532576['options']);return _0x37a0c6[_0xe6d5('0x11e')](_0x9d6f43);}})['then'](function(_0x5de5c3){if(_0x5de5c3){_0x110112=_0x5de5c3[_0xe6d5('0x49')];if(!_0x532576['query'][_0xe6d5('0x3e')]('nolimit')){_0x9d6f43[_0xe6d5('0x20')]=qs['limit'](_0x532576[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x9d6f43[_0xe6d5('0x22')]=qs['offset'](_0x532576['query'][_0xe6d5('0x22')]);}return _0x37a0c6[_0xe6d5('0x11e')](_0x9d6f43);}})['then'](function(_0x220ba4){if(_0x220ba4){return _0x220ba4?{'count':_0x110112,'rows':_0x220ba4}:null;}})[_0xe6d5('0x12')](respondWithResult(_0x2aeecc,null))[_0xe6d5('0x1b')](handleError(_0x2aeecc,null));};exports[_0xe6d5('0x11f')]=function(_0x1dc1b9,_0x33f79b){return db['chatProactiveAction'][_0xe6d5('0x4b')]({'where':{'id':_0x1dc1b9['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x33f79b,null))[_0xe6d5('0x12')](function(_0x5aae74){if(_0x5aae74){return _0x5aae74[_0xe6d5('0x11f')](_0x1dc1b9[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x1dc1b9[_0xe6d5('0x4d')],['ids','id'])||{});}})['then'](respondWithResult(_0x33f79b,null))[_0xe6d5('0x1b')](handleError(_0x33f79b,null));};exports[_0xe6d5('0x106')]=function(_0x51e8e0,_0x347941){var _0x44742c={};var _0x565d91={};var _0x1bbb12;var _0x1fb768;return db[_0xe6d5('0x32')][_0xe6d5('0x56')]({'where':{'id':_0x51e8e0[_0xe6d5('0x48')]['id']}})['then'](handleEntityNotFound(_0x347941,null))[_0xe6d5('0x12')](function(_0x16a757){if(_0x16a757){_0x1bbb12=_0x16a757;_0x565d91[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db[_0xe6d5('0x120')][_0xe6d5('0x33')]);_0x565d91[_0xe6d5('0x38')]=_[_0xe6d5('0x39')](_0x51e8e0[_0xe6d5('0x38')]);_0x565d91[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x565d91['model'],_0x565d91[_0xe6d5('0x38')]);_0x44742c[_0xe6d5('0x3c')]=_['intersection'](_0x565d91[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x44742c[_0xe6d5('0x3c')]=_0x44742c[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x44742c[_0xe6d5('0x3c')]:_0x565d91['model'];_0x44742c['order']=qs[_0xe6d5('0x3f')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x44742c[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x51e8e0[_0xe6d5('0x38')],_0x565d91[_0xe6d5('0x3a')]));if(_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x44742c[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x44742c[_0xe6d5('0x40')],{'$or':_[_0xe6d5('0x31')](_0x44742c['attributes'],function(_0x5eb7d2){var _0x1cd8d9={};_0x1cd8d9[_0x5eb7d2]={'$like':'%'+_0x51e8e0[_0xe6d5('0x38')]['filter']+'%'};return _0x1cd8d9;})});}_0x44742c=_[_0xe6d5('0x43')]({},_0x44742c,_0x51e8e0[_0xe6d5('0x44')]);return _0x1bbb12[_0xe6d5('0x106')](_0x44742c);}})[_0xe6d5('0x12')](function(_0x2caac6){if(_0x2caac6){_0x1fb768=_0x2caac6['length'];if(!_0x51e8e0[_0xe6d5('0x38')]['hasOwnProperty'](_0xe6d5('0x57'))){_0x44742c[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x51e8e0['query'][_0xe6d5('0x20')]);_0x44742c['offset']=qs[_0xe6d5('0x22')](_0x51e8e0[_0xe6d5('0x38')][_0xe6d5('0x22')]);}return _0x1bbb12['getProactiveActions'](_0x44742c);}})[_0xe6d5('0x12')](function(_0x457986){if(_0x457986){return _0x457986?{'count':_0x1fb768,'rows':_0x457986}:null;}})['then'](respondWithResult(_0x347941,null))[_0xe6d5('0x1b')](handleError(_0x347941,null));};exports[_0xe6d5('0x121')]=function(_0x3dac80,_0x3e047b){var _0x4af1b7=_0x3dac80[_0xe6d5('0x38')][_0xe6d5('0x122')]==='false'?_0xe6d5('0x123'):_0xe6d5('0x124');return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'attributes':['id',_0x4af1b7],'where':{'id':_0x3dac80['params']['id']}})['then'](handleEntityNotFound(_0x3e047b,null))[_0xe6d5('0x12')](function(_0x2d4387){if(_0x2d4387){var _0x4eef56=_0x2d4387[_0x4af1b7];var _0x2f01bd=_0x4eef56&&_0x4eef56[_0xe6d5('0x125')]?_0x4eef56[_0xe6d5('0x125')]:[];_0x3e047b[_0xe6d5('0x2d')]({'fromKey':_[_0xe6d5('0x6d')](_0x4eef56[_0xe6d5('0x126')])?undefined:_0x4eef56[_0xe6d5('0x126')],'count':_0x2f01bd[_0xe6d5('0x49')],'rows':_0x2f01bd});}})['catch'](handleError(_0x3e047b,null));};exports[_0xe6d5('0x127')]=function(_0x542886,_0x52a4f2){var _0x5032d5={'raw':![],'where':{}};var _0x4cf54b={};var _0x37f332={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xe6d5('0x56')]({'where':{'id':_0x542886['params']['id']}})['then'](handleEntityNotFound(_0x52a4f2,null))[_0xe6d5('0x12')](function(_0x3de61e){if(_0x3de61e){_0x4cf54b[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['ChatOfflineMessage'][_0xe6d5('0x33')]);_0x4cf54b['query']=_['keys'](_0x542886[_0xe6d5('0x38')]);_0x4cf54b['filters']=_[_0xe6d5('0x3b')](_0x4cf54b[_0xe6d5('0x37')],_0x4cf54b[_0xe6d5('0x38')]);_0x5032d5[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x4cf54b[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x542886['query']['fields']));_0x5032d5[_0xe6d5('0x3c')]=_0x5032d5[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x5032d5['attributes']:_0x4cf54b['model'];if(!_0x542886[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x5032d5[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x542886[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x5032d5['offset']=qs[_0xe6d5('0x22')](_0x542886[_0xe6d5('0x38')]['offset']);}_0x5032d5['order']=qs[_0xe6d5('0x3f')](_0x542886[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x5032d5[_0xe6d5('0x40')]=qs['filters'](_['pick'](_0x542886[_0xe6d5('0x38')],_0x4cf54b[_0xe6d5('0x3a')]));_0x5032d5[_0xe6d5('0x40')][_0xe6d5('0x53')]=_0x3de61e['id'];if(_0x542886['query']['filter']){_0x5032d5[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x5032d5[_0xe6d5('0x40')],{'$or':_['map'](_0x5032d5[_0xe6d5('0x3c')],function(_0x4f1884){var _0x5d85b3={};_0x5d85b3[_0x4f1884]={'$like':'%'+_0x542886[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x5d85b3;})});}_0x5032d5=_['merge']({},_0x5032d5,_0x542886[_0xe6d5('0x44')]);return db['ChatOfflineMessage'][_0xe6d5('0x21')]({'where':_0x5032d5[_0xe6d5('0x40')]})['then'](function(_0x59a39e){_0x37f332[_0xe6d5('0x21')]=_0x59a39e;if(_0x542886[_0xe6d5('0x38')][_0xe6d5('0x4a')]){_0x5032d5[_0xe6d5('0x45')]=[{'all':!![]}];}else{_0x5032d5[_0xe6d5('0x45')]=[{'model':db[_0xe6d5('0x7f')],'as':_0xe6d5('0xf0'),'required':![]},{'model':db['Attachment'],'as':_0xe6d5('0x128'),'required':![]}];}return db[_0xe6d5('0xce')]['findAll'](_0x5032d5);})[_0xe6d5('0x12')](function(_0x557c2b){_0x37f332[_0xe6d5('0x46')]=_0x557c2b;return _0x37f332;});}})[_0xe6d5('0x12')](respondWithFilteredResult(_0x52a4f2,_0x5032d5))['catch'](handleError(_0x52a4f2,null));};exports[_0xe6d5('0x129')]=function(_0x3cc878,_0x443401){return db[_0xe6d5('0x32')][_0xe6d5('0x4b')]({'where':{'id':_0x3cc878['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x443401,null))['then'](function(_0x30e12a){if(_0x30e12a){return _0x30e12a[_0xe6d5('0x129')](_0x3cc878[_0xe6d5('0x4d')][_0xe6d5('0x5b')],_[_0xe6d5('0xee')](_0x3cc878[_0xe6d5('0x4d')],['ids','id'])||{})[_0xe6d5('0xb0')](function(_0x5176f5){for(var _0x4a471e=0x0;_0x4a471e<_0x3cc878['body'][_0xe6d5('0x5b')]['length'];_0x4a471e+=0x1){socket['emit'](_0xe6d5('0x12a'),{'UserId':Number(_0x3cc878[_0xe6d5('0x4d')]['ids'][_0x4a471e]),'ChatWebsiteId':Number(_0x3cc878['params']['id'])});}return _0x5176f5;});}})[_0xe6d5('0x12')](respondWithResult(_0x443401,null))[_0xe6d5('0x1b')](handleError(_0x443401,null));};exports[_0xe6d5('0x12b')]=function(_0x2380be,_0x3017ad){return db['ChatWebsite'][_0xe6d5('0x4b')]({'where':{'id':_0x2380be[_0xe6d5('0x48')]['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x3017ad,null))[_0xe6d5('0x12')](function(_0x1d56c9){if(_0x1d56c9){return _0x1d56c9['removeAgents'](_0x2380be[_0xe6d5('0x38')]['ids'])['then'](function(){if(_['isArray'](_0x2380be[_0xe6d5('0x38')][_0xe6d5('0x5b')])){for(var _0x2344a4=0x0;_0x2344a4<_0x2380be[_0xe6d5('0x38')][_0xe6d5('0x5b')][_0xe6d5('0x49')];_0x2344a4+=0x1){socket[_0xe6d5('0x12c')](_0xe6d5('0x12d'),{'UserId':Number(_0x2380be[_0xe6d5('0x38')]['ids'][_0x2344a4]),'ChatWebsiteId':Number(_0x2380be[_0xe6d5('0x48')]['id'])});}}else{socket[_0xe6d5('0x12c')](_0xe6d5('0x12d'),{'UserId':Number(_0x2380be['query'][_0xe6d5('0x5b')]),'ChatWebsiteId':Number(_0x2380be['params']['id'])});}});}})['then'](respondWithStatusCode(_0x3017ad,null))[_0xe6d5('0x1b')](handleError(_0x3017ad,null));};exports['getAgents']=function(_0x142614,_0x364f6c){var _0x49cf06={};var _0x585ea5={};var _0x5558ff;var _0x2fe752;return db['ChatWebsite'][_0xe6d5('0x56')]({'where':{'id':_0x142614['params']['id']}})[_0xe6d5('0x12')](handleEntityNotFound(_0x364f6c,null))['then'](function(_0x577e55){if(_0x577e55){_0x5558ff=_0x577e55;_0x585ea5[_0xe6d5('0x37')]=_[_0xe6d5('0x39')](db['User'][_0xe6d5('0x33')]);_0x585ea5[_0xe6d5('0x38')]=_['keys'](_0x142614[_0xe6d5('0x38')]);_0x585ea5[_0xe6d5('0x3a')]=_[_0xe6d5('0x3b')](_0x585ea5['model'],_0x585ea5[_0xe6d5('0x38')]);_0x49cf06[_0xe6d5('0x3c')]=_[_0xe6d5('0x3b')](_0x585ea5[_0xe6d5('0x37')],qs[_0xe6d5('0x3d')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3d')]));_0x49cf06[_0xe6d5('0x3c')]=_0x49cf06[_0xe6d5('0x3c')][_0xe6d5('0x49')]?_0x49cf06['attributes']:_0x585ea5[_0xe6d5('0x37')];_0x49cf06['order']=qs[_0xe6d5('0x3f')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3f')]);_0x49cf06[_0xe6d5('0x40')]=qs[_0xe6d5('0x3a')](_[_0xe6d5('0x41')](_0x142614['query'],_0x585ea5['filters']));if(_0x142614[_0xe6d5('0x38')][_0xe6d5('0x42')]){_0x49cf06[_0xe6d5('0x40')]=_[_0xe6d5('0x43')](_0x49cf06[_0xe6d5('0x40')],{'$or':_['map'](_0x49cf06[_0xe6d5('0x3c')],function(_0x38fb0a){var _0x355d03={};_0x355d03[_0x38fb0a]={'$like':'%'+_0x142614[_0xe6d5('0x38')][_0xe6d5('0x42')]+'%'};return _0x355d03;})});}_0x49cf06=_['merge']({},_0x49cf06,_0x142614[_0xe6d5('0x44')]);return _0x5558ff[_0xe6d5('0x12e')](_0x49cf06);}})[_0xe6d5('0x12')](function(_0x4d9e8e){if(_0x4d9e8e){_0x2fe752=_0x4d9e8e['length'];if(!_0x142614[_0xe6d5('0x38')][_0xe6d5('0x3e')](_0xe6d5('0x57'))){_0x49cf06[_0xe6d5('0x20')]=qs[_0xe6d5('0x20')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x20')]);_0x49cf06['offset']=qs[_0xe6d5('0x22')](_0x142614[_0xe6d5('0x38')][_0xe6d5('0x22')]);}return _0x5558ff[_0xe6d5('0x12e')](_0x49cf06);}})[_0xe6d5('0x12')](function(_0x22de41){if(_0x22de41){return _0x22de41?{'count':_0x2fe752,'rows':_0x22de41}:null;}})[_0xe6d5('0x12')](respondWithResult(_0x364f6c,null))[_0xe6d5('0x1b')](handleError(_0x364f6c,null));};
\ No newline at end of file
+var _0x984b=['vendor','%s\x20%s\x20%s','type','stringify','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','fieldName','key','query','keys','filters','intersection','attributes','fields','length','nolimit','offset','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','create','address','forEach','testWildcardValidity','trim','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','hasOwnProperty','removeDispositions','addAnswer','CannedAnswer','getAnswers','findOne','removeAnswers','ids','sitepic','file','filename','agentAvatar','addCustomerAvatar','addSystemAvatar','systemAvatar','join','root','server/files/images/logos/default_logo.svg','../../config/license/util','getLicense','custom','server/files/images/logos/','download','getAvatar','isNil','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','customerAvatar','existsSync','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','resolve','timezone','ifTime','notify','chat','mapKey','MapKey\x20is\x20mandatory','createdAt','updatedAt','includes','CompanyId','ListId','Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','List','DESC','ChatApplication','Applications','Intervals','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','account','applications','orderBy','priority','list','Contacts','from','CmContact','threadId','closed','Writing\x20on\x20closed\x20interaction','externalUrl','ChatInteraction','interaction','messageId','created','autoclose','push','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','unshift','agent','queueId','waitForTheAssignedQueue','Start','EventManager','offline','files','Sequelize','ValidationError','no\x20available\x20attributes','difference','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','spread','server/files/templates/chatOfflineMessage.ejs','render','toPairs','fromString','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','MailAccount','Smtp','CloudProvider','SendMail','sendMail','\x22%s\x22\x20<%s>','email','forwardOfflineAddress','offlineMessageSubject','subjectOffline','toPairsIn','mapValues','Chat','MailAccountId','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','User','Owner','fullname','internal','Tag','Tags','tag','getSnippet','getProactiveActions','virtual','License','chatLicenseExceeded','readFileSync','server/files/chat/iframe.ejs','utf8','3.13.0','headers','origin','http://localhost:9000','testWebsiteWithWildcard','remote','connection','remoteAddress','replace','alignment','color','labelText','textColor','textButtonColor','backgroundColor','IntervalId','ISOLATION_LEVELS','findAndCountAll','finally','getApplications','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','getOfflineMessages','ChatOfflineMessage','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','ejs','fs-extra','lodash','ioredis','jayson/promise','api','../../config/environment','APIBadRequestError','../../errors/api','handleError','APIConflictError','./helpers/wildcard-expressions','url','URL','../../mysqldb','redis','defaults','localhost','register','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','end','json','undefined','limit','count','set','update','destroy','get','ChatWebsites','UserProfileResource','stack','name','send','user-agent-parser','setUA','getResult','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','device','model'];(function(_0x40daf9,_0x1beebc){var _0x14446f=function(_0x492fe1){while(--_0x492fe1){_0x40daf9['push'](_0x40daf9['shift']());}};_0x14446f(++_0x1beebc);}(_0x984b,0xee));var _0xb984=function(_0x1cc9f9,_0x6bf4c5){_0x1cc9f9=_0x1cc9f9-0x0;var _0x341e9a=_0x984b[_0x1cc9f9];return _0x341e9a;};'use strict';var Mustache=require('mustache');var util=require('util');var path=require('path');var ejs=require(_0xb984('0x0'));var fs=require('fs');var fs_extra=require(_0xb984('0x1'));var _=require(_0xb984('0x2'));var querystring=require('querystring');var htmlToText=require('html-to-text');var Redis=require(_0xb984('0x3'));var jayson=require(_0xb984('0x4'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0xb984('0x5'));var config=require(_0xb984('0x6'));var APIBadRequestError=require('../../errors/api')[_0xb984('0x7')];var APINotFoundError=require(_0xb984('0x8'))['APINotFoundError'];var APIOutOfIntervalError=require(_0xb984('0x8'))['APIOutOfIntervalError'];var APIHandleError=require(_0xb984('0x8'))[_0xb984('0x9')];var APIConflictError=require(_0xb984('0x8'))[_0xb984('0xa')];var wildcardUtils=require(_0xb984('0xb'));var URL=require(_0xb984('0xc'))[_0xb984('0xd')];var db=require(_0xb984('0xe'))['db'];config[_0xb984('0xf')]=_[_0xb984('0x10')](config[_0xb984('0xf')],{'host':_0xb984('0x11'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb984('0xf')]));require('./chatWebsite.socket')[_0xb984('0x12')](socket);var client=jayson[_0xb984('0x13')]['http']({'port':0x232c});var client9002=jayson[_0xb984('0x13')][_0xb984('0x14')]({'port':0x232a});var client9003=jayson['client'][_0xb984('0x14')]({'port':0x232b});var client9001=jayson[_0xb984('0x13')]['http']({'port':0x2329});function respondWithRpcPromise(_0xede12d,_0x4073cb,_0x57365c,_0x6fae41){return new Promise(function(_0x5cd1aa,_0x3b8241){var _0x1dc4df=_0x6fae41||client;return _0x1dc4df[_0xb984('0x15')](_0xede12d,_0x57365c)[_0xb984('0x16')](function(_0x59dcb7){logger[_0xb984('0x17')](_0xb984('0x18'),_0x4073cb,_0xb984('0x19'));logger[_0xb984('0x1a')](_0xb984('0x1b'),_0x4073cb,_0xb984('0x19'),JSON['stringify'](_0x59dcb7));if(_0x59dcb7[_0xb984('0x1c')]){if(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1d')]===0x1f4){logger[_0xb984('0x1c')](_0xb984('0x18'),_0x4073cb,_0x59dcb7[_0xb984('0x1c')]['message']);return _0x3b8241(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);}logger['error'](_0xb984('0x18'),_0x4073cb,_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);return _0x5cd1aa(_0x59dcb7[_0xb984('0x1c')][_0xb984('0x1e')]);}else{logger[_0xb984('0x17')](_0xb984('0x18'),_0x4073cb,'request\x20sent');_0x5cd1aa(_0x59dcb7[_0xb984('0x1f')][_0xb984('0x1e')]);}})[_0xb984('0x20')](function(_0x5d4d38){logger[_0xb984('0x1c')](_0xb984('0x18'),_0x4073cb,_0x5d4d38);_0x3b8241(_0x5d4d38);});});}function respondWithStatusCode(_0x1cb2c2,_0x2d0450){_0x2d0450=_0x2d0450||0xcc;return function(_0x1f7b62){if(_0x1f7b62){return _0x1cb2c2[_0xb984('0x21')](_0x2d0450);}return _0x1cb2c2[_0xb984('0x22')](_0x2d0450)[_0xb984('0x23')]();};}function respondWithResult(_0x5d93d9,_0x249d47){_0x249d47=_0x249d47||0xc8;return function(_0x469af6){if(_0x469af6){return _0x5d93d9[_0xb984('0x22')](_0x249d47)[_0xb984('0x24')](_0x469af6);}};}function respondWithFilteredResult(_0x4fb896,_0xa44895){return function(_0x67e4d3){if(_0x67e4d3){var _0x476811=typeof _0xa44895['offset']===_0xb984('0x25')&&typeof _0xa44895[_0xb984('0x26')]===_0xb984('0x25');var _0x3d2757=_0x67e4d3['count'];var _0x5b8da1=_0x476811?0x0:_0xa44895['offset'];var _0x10b9ac=_0x476811?_0x67e4d3[_0xb984('0x27')]:_0xa44895['offset']+_0xa44895[_0xb984('0x26')];var _0x2bb03f;if(_0x10b9ac>=_0x3d2757){_0x10b9ac=_0x3d2757;_0x2bb03f=0xc8;}else{_0x2bb03f=0xce;}_0x4fb896[_0xb984('0x22')](_0x2bb03f);return _0x4fb896[_0xb984('0x28')]('Content-Range',_0x5b8da1+'-'+_0x10b9ac+'/'+_0x3d2757)['json'](_0x67e4d3);}return null;};}function saveUpdates(_0x315f70){return function(_0x2daa31){if(_0x2daa31){return _0x2daa31[_0xb984('0x29')](_0x315f70)[_0xb984('0x16')](function(_0x4df9e0){return _0x4df9e0;});}return null;};}function removeEntity(_0x44ef84){return function(_0x35b37f){if(_0x35b37f){return _0x35b37f[_0xb984('0x2a')]()[_0xb984('0x16')](function(){var _0x3d2714=_0x35b37f[_0xb984('0x2b')]({'plain':!![]});var _0x5f4426=_0xb984('0x2c');return db[_0xb984('0x2d')][_0xb984('0x2a')]({'where':{'type':_0x5f4426,'resourceId':_0x3d2714['id']}})[_0xb984('0x16')](function(){return _0x35b37f;});})[_0xb984('0x16')](function(){_0x44ef84[_0xb984('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x31f490){return function(_0x138dc5){if(!_0x138dc5){_0x31f490['sendStatus'](0x194);}return _0x138dc5;};}function handleError(_0x578a80,_0x13a950){_0x13a950=_0x13a950||0x1f4;return function(_0x4a440d){logger[_0xb984('0x1c')](_0x4a440d[_0xb984('0x2e')]);if(_0x4a440d['name']){delete _0x4a440d[_0xb984('0x2f')];}_0x578a80['status'](_0x13a950)[_0xb984('0x30')](_0x4a440d);};}function createInteractionObject(_0x5c25a9,_0x19bd91,_0x557302,_0x52f872){var _0xf6d925=require(_0xb984('0x31'));var _0x4dac3f=new _0xf6d925();var _0x26b36c=_0x4dac3f[_0xb984('0x32')](_0x557302['user-agent'])[_0xb984('0x33')]();var _0x446f45=_0x19bd91[_0xb984('0x34')];if(_0x557302[_0xb984('0x35')]){_0x446f45=_0x557302['cf-connecting-ip'];}else if(_0x557302[_0xb984('0x36')]){_0x446f45=_[_0xb984('0x37')](_0x557302[_0xb984('0x36')][_0xb984('0x38')](','));}return{'ContactId':_0x52f872['id'],'ChatWebsiteId':_0x5c25a9,'from':(_0x52f872[_0xb984('0x39')]||'')+'\x20'+(_0x52f872[_0xb984('0x3a')]||''),'customerIp':_0x446f45,'customerPort':_0x557302[_0xb984('0x3b')]?_0x557302[_0xb984('0x3b')]:null,'referer':_0x19bd91[_0xb984('0x3c')],'browserName':_0x26b36c[_0xb984('0x3d')]['name']&&_0x26b36c[_0xb984('0x3d')][_0xb984('0x3e')]?util[_0xb984('0x3f')](_0xb984('0x40'),_0x26b36c[_0xb984('0x3d')][_0xb984('0x2f')],_0x26b36c[_0xb984('0x3d')][_0xb984('0x3e')]):'unknown','browserVersion':_0x26b36c['browser'][_0xb984('0x3e')]||'unknown','osName':util[_0xb984('0x3f')](_0xb984('0x40'),_0x26b36c['os'][_0xb984('0x2f')],_0x26b36c['os'][_0xb984('0x3e')]),'osVersion':_0x26b36c['os']['version'],'deviceModel':_0x26b36c[_0xb984('0x41')][_0xb984('0x42')]&&_0x26b36c['device'][_0xb984('0x43')]?util[_0xb984('0x3f')](_0xb984('0x44'),_0x26b36c[_0xb984('0x41')][_0xb984('0x42')],_0x26b36c[_0xb984('0x41')][_0xb984('0x43')],_0x26b36c['device'][_0xb984('0x45')]):null,'deviceVendor':_0x26b36c[_0xb984('0x41')]['vendor'],'deviceType':_0x26b36c['device'][_0xb984('0x45')],'formData':JSON[_0xb984('0x46')](_0x19bd91)};}exports[_0xb984('0x47')]=function(_0x248800,_0x1acc7a){var _0x56a3bf={'include':[{'model':db[_0xb984('0x48')],'as':_0xb984('0x49')}]},_0x664cb1={},_0x40666f={'count':0x0,'rows':[]};var _0x460a7e=_[_0xb984('0x4a')](db[_0xb984('0x4b')][_0xb984('0x4c')],function(_0x23b95b){return{'name':_0x23b95b[_0xb984('0x4d')],'type':_0x23b95b['type'][_0xb984('0x4e')]};});_0x664cb1[_0xb984('0x42')]=_['map'](_0x460a7e,_0xb984('0x2f'));_0x664cb1[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x248800[_0xb984('0x4f')]);_0x664cb1[_0xb984('0x51')]=_[_0xb984('0x52')](_0x664cb1[_0xb984('0x42')],_0x664cb1[_0xb984('0x4f')]);_0x56a3bf[_0xb984('0x53')]=_[_0xb984('0x52')](_0x664cb1['model'],qs[_0xb984('0x54')](_0x248800[_0xb984('0x4f')][_0xb984('0x54')]));_0x56a3bf[_0xb984('0x53')]=_0x56a3bf[_0xb984('0x53')][_0xb984('0x55')]?_0x56a3bf[_0xb984('0x53')]:_0x664cb1[_0xb984('0x42')];if(!_0x248800[_0xb984('0x4f')]['hasOwnProperty'](_0xb984('0x56'))){_0x56a3bf[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x248800['query'][_0xb984('0x26')]);_0x56a3bf[_0xb984('0x57')]=qs['offset'](_0x248800[_0xb984('0x4f')]['offset']);}_0x56a3bf[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x248800['query'][_0xb984('0x59')]);_0x56a3bf[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x248800[_0xb984('0x4f')],_0x664cb1[_0xb984('0x51')]),_0x460a7e);if(_0x248800['query'][_0xb984('0x5c')]){_0x56a3bf['where']=_[_0xb984('0x5d')](_0x56a3bf[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x460a7e,function(_0x5cf038){if(_0x5cf038['type']!==_0xb984('0x5e')){var _0x2dfaf8={};_0x2dfaf8[_0x5cf038['name']]={'$like':'%'+_0x248800['query'][_0xb984('0x5c')]+'%'};return _0x2dfaf8;}})});}_0x56a3bf=_[_0xb984('0x5d')]({},_0x56a3bf,_0x248800[_0xb984('0x5f')]);var _0x3daaa0={'where':_0x56a3bf[_0xb984('0x5a')]};return db[_0xb984('0x4b')]['count'](_0x3daaa0)['then'](function(_0x3dcdf1){_0x40666f[_0xb984('0x27')]=_0x3dcdf1;if(_0x248800['query'][_0xb984('0x60')]){_0x56a3bf[_0xb984('0x61')]=[{'all':!![]}];}return db[_0xb984('0x4b')][_0xb984('0x62')](_0x56a3bf);})['then'](function(_0x4d719c){_0x40666f[_0xb984('0x63')]=_0x4d719c;return _0x40666f;})[_0xb984('0x16')](respondWithFilteredResult(_0x1acc7a,_0x56a3bf))[_0xb984('0x20')](handleError(_0x1acc7a,null));};exports[_0xb984('0x64')]=function(_0x3bdadc,_0x3cc2a0){var _0x49ecfd={'raw':![],'where':{'id':_0x3bdadc[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0x48')],'as':_0xb984('0x49')}]},_0x2de42b={};_0x2de42b[_0xb984('0x42')]=_[_0xb984('0x50')](db['ChatWebsite']['rawAttributes']);_0x2de42b['query']=_[_0xb984('0x50')](_0x3bdadc[_0xb984('0x4f')]);_0x2de42b[_0xb984('0x51')]=_[_0xb984('0x52')](_0x2de42b[_0xb984('0x42')],_0x2de42b['query']);_0x49ecfd[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2de42b[_0xb984('0x42')],qs['fields'](_0x3bdadc[_0xb984('0x4f')][_0xb984('0x54')]));_0x49ecfd['attributes']=_0x49ecfd['attributes'][_0xb984('0x55')]?_0x49ecfd['attributes']:_0x2de42b['model'];if(_0x3bdadc[_0xb984('0x4f')]['includeAll']){_0x49ecfd[_0xb984('0x61')]=[{'all':!![]}];}_0x49ecfd=_[_0xb984('0x5d')]({},_0x49ecfd,_0x3bdadc[_0xb984('0x5f')]);return db[_0xb984('0x4b')][_0xb984('0x66')](_0x49ecfd)[_0xb984('0x16')](handleEntityNotFound(_0x3cc2a0,null))[_0xb984('0x16')](respondWithResult(_0x3cc2a0,null))[_0xb984('0x20')](handleError(_0x3cc2a0,null));};exports[_0xb984('0x67')]=function(_0x2b187f,_0x742a0f){var _0x1d9213=null;_0x2b187f['body'][_0xb984('0x68')][_0xb984('0x38')](',')[_0xb984('0x69')](_0x511780=>{if(_0x511780['trim']()!==''&&!wildcardUtils[_0xb984('0x6a')](_0x511780[_0xb984('0x6b')]())){_0x1d9213=new APIBadRequestError('\x22'+_0x511780[_0xb984('0x6b')]()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x1d9213){return handleError(_0x742a0f,null)(_0x1d9213);}return db[_0xb984('0x4b')][_0xb984('0x67')](_0x2b187f[_0xb984('0x6c')],{})[_0xb984('0x16')](function(_0x434c5c){var _0x1793e2=_0x2b187f[_0xb984('0x6d')][_0xb984('0x2b')]({'plain':!![]});if(!_0x1793e2)throw new Error(_0xb984('0x6e'));if(_0x1793e2[_0xb984('0x6f')]===_0xb984('0x6d')){var _0x4c377f=_0x434c5c[_0xb984('0x2b')]({'plain':!![]});var _0x9ea21f='ChatWebsites';return db[_0xb984('0x70')]['find']({'where':{'name':_0x9ea21f,'userProfileId':_0x1793e2[_0xb984('0x71')]},'raw':!![]})['then'](function(_0x3cfd28){if(_0x3cfd28&&_0x3cfd28[_0xb984('0x72')]===0x0){return db[_0xb984('0x2d')][_0xb984('0x67')]({'name':_0x4c377f[_0xb984('0x2f')],'resourceId':_0x4c377f['id'],'type':_0x3cfd28[_0xb984('0x2f')],'sectionId':_0x3cfd28['id']},{})[_0xb984('0x16')](function(){return _0x434c5c;});}else{return _0x434c5c;}})[_0xb984('0x20')](function(_0x3bc1d3){logger[_0xb984('0x1c')](_0xb984('0x73'),_0x3bc1d3);throw _0x3bc1d3;});}return _0x434c5c;})[_0xb984('0x16')](respondWithResult(_0x742a0f,0xc9))[_0xb984('0x20')](handleError(_0x742a0f,null));};exports['update']=function(_0x4886bf,_0x917c53){var _0x441166=null;_0x4886bf[_0xb984('0x6c')]['address'][_0xb984('0x38')](',')[_0xb984('0x69')](_0x50544b=>{if(_0x50544b['trim']()!==''&&!wildcardUtils['testWildcardValidity'](_0x50544b[_0xb984('0x6b')]())){_0x441166=new APIBadRequestError('\x22'+_0x50544b['trim']()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x441166){return handleError(_0x917c53,null)(_0x441166);}if(_0x4886bf['body']['id']){delete _0x4886bf[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x4886bf[_0xb984('0x65')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]})[_0xb984('0x16')](handleEntityNotFound(_0x917c53,null))[_0xb984('0x16')](saveUpdates(_0x4886bf[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x917c53,null))[_0xb984('0x20')](handleError(_0x917c53,null));};exports['destroy']=function(_0x2063cd,_0x3e7ed1){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x2063cd[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x3e7ed1,null))['then'](removeEntity(_0x3e7ed1,null))[_0xb984('0x20')](handleError(_0x3e7ed1,null));};exports['describe']=function(_0x12890c,_0x1d9392){return db[_0xb984('0x4b')][_0xb984('0x74')]()[_0xb984('0x16')](respondWithResult(_0x1d9392,null))['catch'](handleError(_0x1d9392,null));};exports[_0xb984('0x75')]=function(_0x203915,_0x1f0e09){if(_0x203915['body']['id']){delete _0x203915[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x203915[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x1f0e09,null))['then'](function(_0x504d1a){if(_0x504d1a){_0x203915[_0xb984('0x6c')][_0xb984('0x76')]=_0x504d1a['id'];return db[_0xb984('0x77')][_0xb984('0x67')](_0x203915['body']);}})[_0xb984('0x16')](respondWithResult(_0x1f0e09,null))[_0xb984('0x20')](handleError(_0x1f0e09,null));};exports[_0xb984('0x78')]=function(_0x199e48,_0x5e4b1f){var _0x1b0673={'raw':![],'where':{}};var _0x2725eb={};var _0x417526={'count':0x0,'rows':[]};return db[_0xb984('0x4b')]['findOne']({'where':{'id':_0x199e48[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5e4b1f,null))[_0xb984('0x16')](function(_0x2d686e){if(_0x2d686e){_0x2725eb[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x77')][_0xb984('0x4c')]);_0x2725eb[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x199e48[_0xb984('0x4f')]);_0x2725eb['filters']=_[_0xb984('0x52')](_0x2725eb[_0xb984('0x42')],_0x2725eb[_0xb984('0x4f')]);_0x1b0673[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2725eb[_0xb984('0x42')],qs['fields'](_0x199e48[_0xb984('0x4f')][_0xb984('0x54')]));_0x1b0673[_0xb984('0x53')]=_0x1b0673[_0xb984('0x53')]['length']?_0x1b0673[_0xb984('0x53')]:_0x2725eb[_0xb984('0x42')];if(!_0x199e48['query'][_0xb984('0x79')]('nolimit')){_0x1b0673['limit']=qs[_0xb984('0x26')](_0x199e48[_0xb984('0x4f')][_0xb984('0x26')]);_0x1b0673[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x199e48[_0xb984('0x4f')][_0xb984('0x57')]);}_0x1b0673[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x199e48['query']['sort']);_0x1b0673[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x199e48[_0xb984('0x4f')],_0x2725eb['filters']));_0x1b0673[_0xb984('0x5a')][_0xb984('0x76')]=_0x2d686e['id'];if(_0x199e48[_0xb984('0x4f')][_0xb984('0x5c')]){_0x1b0673[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x1b0673['where'],{'$or':_[_0xb984('0x4a')](_0x1b0673['attributes'],function(_0x38b0e6){var _0x56cb5d={};_0x56cb5d[_0x38b0e6]={'$like':'%'+_0x199e48[_0xb984('0x4f')]['filter']+'%'};return _0x56cb5d;})});}_0x1b0673=_['merge']({},_0x1b0673,_0x199e48[_0xb984('0x5f')]);return db[_0xb984('0x77')]['count']({'where':_0x1b0673[_0xb984('0x5a')]})[_0xb984('0x16')](function(_0x1eecfd){_0x417526[_0xb984('0x27')]=_0x1eecfd;if(_0x199e48[_0xb984('0x4f')]['includeAll']){_0x1b0673['include']=[{'all':!![]}];}return db[_0xb984('0x77')][_0xb984('0x62')](_0x1b0673);})['then'](function(_0x42a63d){_0x417526[_0xb984('0x63')]=_0x42a63d;return _0x417526;});}})[_0xb984('0x16')](respondWithFilteredResult(_0x5e4b1f,_0x1b0673))['catch'](handleError(_0x5e4b1f,null));};exports[_0xb984('0x7a')]=function(_0x52c145,_0x15a258){return db[_0xb984('0x4b')]['find']({'where':{'id':_0x52c145[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x15a258,null))[_0xb984('0x16')](function(_0xc39a0){if(_0xc39a0){return _0xc39a0['removeDispositions'](_0x52c145['query']['ids']);}})['then'](respondWithStatusCode(_0x15a258,null))['catch'](handleError(_0x15a258,null));};exports[_0xb984('0x7b')]=function(_0x431b44,_0x50de1){if(_0x431b44[_0xb984('0x6c')]['id']){delete _0x431b44[_0xb984('0x6c')]['id'];}return db[_0xb984('0x4b')]['find']({'where':{'id':_0x431b44[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x50de1,null))['then'](function(_0x45cf65){if(_0x45cf65){_0x431b44['body'][_0xb984('0x76')]=_0x45cf65['id'];return db[_0xb984('0x7c')]['create'](_0x431b44[_0xb984('0x6c')]);}})[_0xb984('0x16')](respondWithResult(_0x50de1,null))[_0xb984('0x20')](handleError(_0x50de1,null));};exports[_0xb984('0x7d')]=function(_0x1e48c5,_0x35c63a){var _0x175683={'raw':![],'where':{}};var _0x1ac7bd={};var _0x2c2750={'count':0x0,'rows':[]};return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x1e48c5[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x35c63a,null))['then'](function(_0x3e2bd0){if(_0x3e2bd0){_0x1ac7bd['model']=_[_0xb984('0x50')](db['CannedAnswer'][_0xb984('0x4c')]);_0x1ac7bd[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x1e48c5[_0xb984('0x4f')]);_0x1ac7bd[_0xb984('0x51')]=_[_0xb984('0x52')](_0x1ac7bd[_0xb984('0x42')],_0x1ac7bd['query']);_0x175683[_0xb984('0x53')]=_[_0xb984('0x52')](_0x1ac7bd[_0xb984('0x42')],qs[_0xb984('0x54')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x54')]));_0x175683[_0xb984('0x53')]=_0x175683[_0xb984('0x53')][_0xb984('0x55')]?_0x175683['attributes']:_0x1ac7bd[_0xb984('0x42')];if(!_0x1e48c5[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x175683[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x26')]);_0x175683[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x1e48c5['query'][_0xb984('0x57')]);}_0x175683['order']=qs[_0xb984('0x59')](_0x1e48c5[_0xb984('0x4f')][_0xb984('0x59')]);_0x175683[_0xb984('0x5a')]=qs[_0xb984('0x51')](_['pick'](_0x1e48c5[_0xb984('0x4f')],_0x1ac7bd[_0xb984('0x51')]));_0x175683['where'][_0xb984('0x76')]=_0x3e2bd0['id'];if(_0x1e48c5[_0xb984('0x4f')][_0xb984('0x5c')]){_0x175683['where']=_[_0xb984('0x5d')](_0x175683[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x175683[_0xb984('0x53')],function(_0xc92c53){var _0x22425e={};_0x22425e[_0xc92c53]={'$like':'%'+_0x1e48c5[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x22425e;})});}_0x175683=_[_0xb984('0x5d')]({},_0x175683,_0x1e48c5[_0xb984('0x5f')]);return db['CannedAnswer']['count']({'where':_0x175683['where']})[_0xb984('0x16')](function(_0xfe3d03){_0x2c2750[_0xb984('0x27')]=_0xfe3d03;if(_0x1e48c5[_0xb984('0x4f')]['includeAll']){_0x175683['include']=[{'all':!![]}];}return db['CannedAnswer'][_0xb984('0x62')](_0x175683);})[_0xb984('0x16')](function(_0x5e9fa1){_0x2c2750[_0xb984('0x63')]=_0x5e9fa1;return _0x2c2750;});}})['then'](respondWithFilteredResult(_0x35c63a,_0x175683))[_0xb984('0x20')](handleError(_0x35c63a,null));};exports['removeAnswers']=function(_0x1ca908,_0x5e2d33){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1ca908['params']['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5e2d33,null))['then'](function(_0x3b0e65){if(_0x3b0e65){return _0x3b0e65[_0xb984('0x7f')](_0x1ca908[_0xb984('0x4f')][_0xb984('0x80')]);}})['then'](respondWithStatusCode(_0x5e2d33,null))[_0xb984('0x20')](handleError(_0x5e2d33,null));};exports['addLogo']=function(_0x272bf0,_0x28c248){_0x272bf0[_0xb984('0x6c')][_0xb984('0x81')]=_0x272bf0[_0xb984('0x82')][_0xb984('0x83')];return db['ChatWebsite'][_0xb984('0x66')]({'where':{'id':_0x272bf0[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x28c248,null))['then'](saveUpdates(_0x272bf0[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x28c248,null))[_0xb984('0x20')](handleError(_0x28c248,null));};exports['addAvatar']=function(_0x26b0bf,_0x3138df){_0x26b0bf[_0xb984('0x6c')][_0xb984('0x84')]=_0x26b0bf[_0xb984('0x82')][_0xb984('0x83')];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x26b0bf[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x3138df,null))[_0xb984('0x16')](saveUpdates(_0x26b0bf[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x3138df,null))[_0xb984('0x20')](handleError(_0x3138df,null));};exports[_0xb984('0x85')]=function(_0x1382d7,_0x5d1e30){_0x1382d7['body']['customerAvatar']=_0x1382d7['file']['filename'];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1382d7[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x5d1e30,null))[_0xb984('0x16')](saveUpdates(_0x1382d7[_0xb984('0x6c')],null))[_0xb984('0x16')](respondWithResult(_0x5d1e30,null))[_0xb984('0x20')](handleError(_0x5d1e30,null));};exports[_0xb984('0x86')]=function(_0x2f3a0e,_0x27ec1e){_0x2f3a0e[_0xb984('0x6c')][_0xb984('0x87')]=_0x2f3a0e[_0xb984('0x82')][_0xb984('0x83')];return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x2f3a0e[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x27ec1e,null))[_0xb984('0x16')](saveUpdates(_0x2f3a0e['body'],null))[_0xb984('0x16')](respondWithResult(_0x27ec1e,null))[_0xb984('0x20')](handleError(_0x27ec1e,null));};exports['getLogo']=function(_0x197038,_0x36ffc1){var _0x428c26=path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x8a'));var _0x444d38={'where':{'id':_0x197038[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x81')],'raw':!![]};var _0x447d61=![];return require(_0xb984('0x8b'))[_0xb984('0x8c')]()[_0xb984('0x16')](function(_0x1a4dc6){if(_0x1a4dc6){_0x447d61=_0x1a4dc6[_0xb984('0x8d')];}})[_0xb984('0x16')](function(){return db[_0xb984('0x4b')][_0xb984('0x66')](_0x444d38);})[_0xb984('0x16')](handleEntityNotFound(_0x36ffc1,null))[_0xb984('0x16')](function(_0x476fdd){if(_0x476fdd){if(!_['isNil'](_0x476fdd[_0xb984('0x81')])){if(fs['existsSync'](path['join'](config[_0xb984('0x89')],_0xb984('0x8e'),_0x476fdd[_0xb984('0x81')]))&&_0x447d61){_0x428c26=path['join'](config[_0xb984('0x89')],_0xb984('0x8e'),_0x476fdd[_0xb984('0x81')]);}}return _0x36ffc1[_0xb984('0x8f')](_0x428c26);}})['catch'](handleError(_0x36ffc1,null));};exports[_0xb984('0x90')]=function(_0x146470,_0x2cb327){var _0x2a4478=path['join'](config[_0xb984('0x89')],'server/files/images/avatars/default_avatar.png');var _0x5569e2={'where':{'id':_0x146470[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x84')],'raw':!![]};return db['ChatWebsite'][_0xb984('0x66')](_0x5569e2)[_0xb984('0x16')](handleEntityNotFound(_0x2cb327,null))[_0xb984('0x16')](function(_0x2975da){if(_0x2975da){if(!_[_0xb984('0x91')](_0x2975da['agentAvatar'])){if(fs['existsSync'](path['join'](config['root'],_0xb984('0x92'),_0x2975da[_0xb984('0x84')]))){_0x2a4478=path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0x2975da[_0xb984('0x84')]);}}return _0x2cb327[_0xb984('0x8f')](_0x2a4478);}})[_0xb984('0x20')](handleError(_0x2cb327,null));};exports['getCustomerAvatar']=function(_0x7a61a3,_0x364971){var _0x15c0d1=path['join'](config[_0xb984('0x89')],_0xb984('0x93'));var _0x126072={'where':{'id':_0x7a61a3[_0xb984('0x65')]['id']},'attributes':['id','customerAvatar',_0xb984('0x94')],'raw':!![]};return db[_0xb984('0x4b')]['find'](_0x126072)[_0xb984('0x16')](handleEntityNotFound(_0x364971,null))['then'](function(_0xa2ae6e){if(_0xa2ae6e){if(!_[_0xb984('0x91')](_0xa2ae6e[_0xb984('0x95')])){if(fs[_0xb984('0x96')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0xa2ae6e[_0xb984('0x95')]))&&_0xa2ae6e[_0xb984('0x94')]){_0x15c0d1=path['join'](config[_0xb984('0x89')],_0xb984('0x92'),_0xa2ae6e[_0xb984('0x95')]);}}return _0x364971[_0xb984('0x8f')](_0x15c0d1);}})['catch'](handleError(_0x364971,null));};exports[_0xb984('0x97')]=function(_0x566cf1,_0x1b9c9b){var _0x178bc5=path['join'](config[_0xb984('0x89')],_0xb984('0x98'));var _0x3ea17b={'where':{'id':_0x566cf1[_0xb984('0x65')]['id']},'attributes':['id',_0xb984('0x87')],'raw':!![]};return db[_0xb984('0x4b')][_0xb984('0x66')](_0x3ea17b)[_0xb984('0x16')](handleEntityNotFound(_0x1b9c9b,null))[_0xb984('0x16')](function(_0x18dda5){if(_0x18dda5){if(!_[_0xb984('0x91')](_0x18dda5['systemAvatar'])){if(fs[_0xb984('0x96')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x92'),_0x18dda5[_0xb984('0x87')]))){_0x178bc5=path[_0xb984('0x88')](config[_0xb984('0x89')],'server/files/images/avatars/',_0x18dda5['systemAvatar']);}}return _0x1b9c9b[_0xb984('0x8f')](_0x178bc5);}})[_0xb984('0x20')](handleError(_0x1b9c9b,null));};function checkWebsiteInterval(_0x1261d7){var _0x7903b8=_0x1261d7[_0xb984('0x99')];if(!_0x7903b8){return Promise[_0xb984('0x9a')](_0x1261d7);}var _0x4d0329=_0x1261d7[_0xb984('0x9b')]||undefined;return _0x7903b8[_0xb984('0x9c')](_0x4d0329)[_0xb984('0x16')](function(_0xe6d4e3){if(!_0xe6d4e3){throw new APIOutOfIntervalError();}return _0x1261d7;});}exports[_0xb984('0x9d')]=function(_0xaf2e56,_0x59ef00){var _0x4964a2={'body':_0xaf2e56[_0xb984('0x6c')],'channel':_0xb984('0x9e')};var _0x40fe08=[];var _0x6df7f6=[];var _0x201dea={};var _0x34a464=![];if(_0xaf2e56[_0xb984('0x6c')]['id']){delete _0xaf2e56[_0xb984('0x6c')]['id'];}if(_[_0xb984('0x91')](_0xaf2e56[_0xb984('0x6c')]['from'])){throw new APIBadRequestError('From\x20is\x20mandatory');}if(_['isNil'](_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')])){throw new APIBadRequestError(_0xb984('0xa0'));}if(_['isEmpty'](_0xaf2e56['body'][_0xb984('0x6c')])){throw new APIBadRequestError('Body\x20is\x20mandatory');}var _0x5408f0=_0xaf2e56[_0xb984('0x6c')][_0xb984('0x34')]&&_0xaf2e56[_0xb984('0x6c')]['referer'];return db['CmContact'][_0xb984('0x74')]()[_0xb984('0x16')](function(_0x21859f){if(!_0x21859f){throw new Error('No\x20available\x20attributes');}_0x40fe08=Object[_0xb984('0x50')](_0x21859f)[_0xb984('0x5c')](function(_0x217025){return![_0xb984('0xa1'),_0xb984('0xa2')][_0xb984('0xa3')](_0x217025);});_0x6df7f6=Object['keys'](_0x21859f)[_0xb984('0x5c')](function(_0x5d0b15){return![_0xb984('0xa1'),_0xb984('0xa2'),_0xb984('0xa4'),_0xb984('0xa5')][_0xb984('0xa3')](_0x5d0b15);});if(!_['includes'](_0x6df7f6,_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')])){throw new APIBadRequestError(_0xb984('0xa6')+_0x6df7f6[_0xb984('0x88')](',\x20'));}_0x201dea[_0xaf2e56['body']['mapKey']]=_0xaf2e56[_0xb984('0x6c')]['from'];})[_0xb984('0x16')](function(){return db[_0xb984('0x4b')]['find']({'where':{'id':_0xaf2e56[_0xb984('0x65')]['id']},'include':[{'model':db['CmList'],'as':_0xb984('0xa7'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x201dea,'limit':0x1,'order':[['updatedAt',_0xb984('0xa8')]]}]},{'model':db[_0xb984('0xa9')],'as':_0xb984('0xaa')},{'model':db['Interval'],'as':_0xb984('0x99'),'include':[{'model':db['Interval'],'as':_0xb984('0xab'),'attributes':['id',_0xb984('0xac')],'raw':!![]}]}]});})[_0xb984('0x16')](function(_0x51a74a){if(!_0x51a74a){throw new APINotFoundError(util[_0xb984('0x3f')](_0xb984('0xad'),_0xaf2e56[_0xb984('0x65')]['id']));}if(_0x5408f0){return checkWebsiteInterval(_0x51a74a);}return _0x51a74a;})[_0xb984('0x16')](function(_0x34f9de){_0x4964a2[_0xb984('0xae')]=_0x34f9de;_0x4964a2[_0xb984('0xaf')]=_[_0xb984('0xb0')](_0x34f9de['Applications'],[_0xb984('0xb1')],['asc']);if(_0x4964a2[_0xb984('0xae')][_0xb984('0xaa')]){delete _0x4964a2[_0xb984('0xae')][_0xb984('0xaa')];}_0x4964a2['list']=_0x34f9de[_0xb984('0xa7')]||{'id':_0x34f9de['ListId']};if(_0x4964a2[_0xb984('0xb2')]&&_0x4964a2[_0xb984('0xb2')]['Contacts'][_0xb984('0x55')]){return _0x4964a2['list'][_0xb984('0xb3')][0x0];}var _0x24dc10=_[_0xb984('0x10')](_0xaf2e56[_0xb984('0x6c')],{'firstName':_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb4')],'ListId':_0x34f9de[_0xb984('0xa5')]});_0x24dc10[_0xaf2e56[_0xb984('0x6c')][_0xb984('0x9f')]]=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb4')];return db[_0xb984('0xb5')][_0xb984('0x67')](_0x24dc10,{'fields':_0x40fe08,'raw':!![]});})['then'](function(_0x3ec9bf){_0x4964a2['contact']=_0x3ec9bf;var _0x1657b9=createInteractionObject(_0xaf2e56[_0xb984('0x65')]['id'],_0xaf2e56['body'],_0xaf2e56['headers'],_0x3ec9bf);var _0x2cce8b={'ChatWebsiteId':_0xaf2e56[_0xb984('0x65')]['id']};if(_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')]){_0x2cce8b['threadId']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')];_0x2cce8b[_0xb984('0xb7')]=![];return db['ChatInteraction'][_0xb984('0x66')]({'where':_0x2cce8b})[_0xb984('0x16')](function(_0x95059b){var _0x41d5cc=_0xaf2e56[_0xb984('0x6c')]['customerIp']&&_0xaf2e56[_0xb984('0x6c')][_0xb984('0x3c')];if(_0x95059b){_0x34a464=!![];return _0x95059b;}else if(!_0x41d5cc&&_0x95059b&&_0x95059b[_0xb984('0xb7')]){throw new APIConflictError(_0xb984('0xb8'));}_0x1657b9[_0xb984('0xb6')]=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')];_0x1657b9[_0xb984('0xb9')]=_0xaf2e56[_0xb984('0x6c')]['externalUrl'];return db[_0xb984('0xba')][_0xb984('0x67')](_0x1657b9);});}_0x2cce8b['ContactId']=_0x3ec9bf['id'];if(_0xaf2e56[_0xb984('0x6c')]['interaction']&&_0xaf2e56['body'][_0xb984('0xbb')]['id']){_0x2cce8b['id']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbb')]['id'];return db[_0xb984('0xba')][_0xb984('0x66')]({'where':_0x2cce8b})[_0xb984('0x16')](function(_0x5bda49){var _0x87fb63=_0xaf2e56['body'][_0xb984('0x34')]&&_0xaf2e56[_0xb984('0x6c')][_0xb984('0x3c')];if(!_0x87fb63&&_0x5bda49&&_0x5bda49[_0xb984('0xb7')]){throw new APIConflictError(_0xb984('0xb8'));}else if(_0x5bda49){_0x34a464=!![];return _0x5bda49;}else{return db[_0xb984('0xba')][_0xb984('0x67')](_0x1657b9);}});}return db[_0xb984('0xba')]['create'](_0x1657b9);})[_0xb984('0x16')](function(_0x2ef68f){if(!_0x34a464){return _0x2ef68f;}var _0x2b2b68={'from':(_0x4964a2['contact'][_0xb984('0x39')]||'')+'\x20'+(_0x4964a2['contact'][_0xb984('0x3a')]||'')};if(_0xaf2e56[_0xb984('0x6c')][_0xb984('0xb6')]&&_0xaf2e56['body']['messageId']&&_0xaf2e56[_0xb984('0x6c')]['threadId']!=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbc')]){_0x2b2b68['threadId']=_0xaf2e56[_0xb984('0x6c')][_0xb984('0xbc')];}return _0x2ef68f[_0xb984('0x29')](_0x2b2b68);})[_0xb984('0x16')](function(_0x391988){_0x4964a2[_0xb984('0xbb')]=_0x391988[_0xb984('0x2b')]({'plain':!![]});_0x4964a2[_0xb984('0xbb')]['created']=!_0x34a464;if(_0x4964a2[_0xb984('0xbb')][_0xb984('0xbd')]){if(_0x4964a2[_0xb984('0xae')][_0xb984('0xbe')]){_0x4964a2[_0xb984('0xaf')][_0xb984('0xbf')]({'id':0x0,'priority':_0x4964a2[_0xb984('0xaf')][_0xb984('0x55')]+0x1,'app':_0xb984('0xc0'),'appdata':_0xb984('0xc1'),'interval':_0xb984('0xc2')});}}return db[_0xb984('0xc3')][_0xb984('0x67')]({'body':_0xaf2e56[_0xb984('0x6c')]['body'],'ChatWebsiteId':_0xaf2e56[_0xb984('0x65')]['id'],'ChatInteractionId':_0x391988['id'],'direction':'in','ContactId':_0x4964a2['contact']['id'],'AttachmentId':_0xaf2e56[_0xb984('0x6c')][_0xb984('0xc4')]});})[_0xb984('0x16')](function(_0xcf9ea6){_0x4964a2[_0xb984('0x1e')]=_0xcf9ea6;if(!_0x4964a2['interaction'][_0xb984('0xc5')]){return;}return db['User'][_0xb984('0x66')]({'attributes':['id',_0xb984('0x2f')],'where':{'id':_0x4964a2['interaction'][_0xb984('0xc5')]}});})[_0xb984('0x16')](function(_0x373d95){if(_0x373d95){_0x4964a2[_0xb984('0xaf')][_0xb984('0xc6')]({'id':0x0,'priority':0x0,'app':_0xb984('0xc7'),'appdata':_0x373d95[_0xb984('0x2f')]+','+(_0x4964a2['account']['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});_0x4964a2['forcedOwnership']=!![];}if(!_0x4964a2[_0xb984('0xbb')]['queueId']){return;}return db['ChatQueue'][_0xb984('0x66')]({'attributes':['id',_0xb984('0x2f')],'where':{'id':_0x4964a2[_0xb984('0xbb')][_0xb984('0xc8')]}});})[_0xb984('0x16')](function(_0x39b639){if(_0x39b639){_0x4964a2[_0xb984('0xaf')][_0xb984('0xc6')]({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x39b639['name']+','+(_0x4964a2[_0xb984('0xae')][_0xb984('0xc9')]||0x12c),'interval':_0xb984('0xc2')});}return respondWithRpcPromise(_0xb984('0xca'),'startRouting',_0x4964a2);})[_0xb984('0x16')](function(_0x1d0780){respondWithRpcPromise(_0xb984('0xcb'),_0xb984('0xcb'),{'event':_0xb984('0x9d'),'message':_0x1d0780},client9002);return _0x1d0780;})['then'](respondWithResult(_0x59ef00,null))[_0xb984('0x20')](APIHandleError(_0x59ef00));};exports[_0xb984('0xcc')]=function(_0x3deb31,_0x3c982a){var _0x4a683e,_0x2d8347,_0x327159;var _0x4d67da=[];var _0x1ea3e2={};var _0x7892c7=_0x3deb31[_0xb984('0xcd')]||[];var _0x564a33=[];var _0x51f9d2;return db[_0xb984('0xb5')]['describe']()[_0xb984('0x16')](function(_0x2b39a9){if(!_0x2b39a9){throw new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd0'));}_0x4d67da=_[_0xb984('0xd1')](_['keys'](_0x2b39a9),['createdAt',_0xb984('0xa2'),_0xb984('0xa4'),_0xb984('0xa5')]);if(_0x3deb31[_0xb984('0x6c')]['id']){delete _0x3deb31[_0xb984('0x6c')]['id'];}if(_[_0xb984('0x91')](_0x3deb31['body'][_0xb984('0xb4')])){throw _0x3c982a['status'](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd2')));}if(_[_0xb984('0x91')](_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')])||_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')]===''){throw _0x3c982a[_0xb984('0x22')](0x1f4)[_0xb984('0x30')](new db['Sequelize'][(_0xb984('0xcf'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xb984('0x91')](_0x3deb31[_0xb984('0x6c')][_0xb984('0xd3')])){throw _0x3c982a[_0xb984('0x22')](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4d67da));}if(!_['includes'](_0x4d67da,_0x3deb31[_0xb984('0x6c')]['mapKeyOffline'])){throw _0x3c982a['status'](0x1f4)[_0xb984('0x30')](new db[(_0xb984('0xce'))][(_0xb984('0xcf'))](_0xb984('0xd4')+_0x4d67da));}_0x1ea3e2[_0x3deb31[_0xb984('0x6c')]['mapKeyOffline']]=_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')];})['then'](function(){return db['ChatWebsite'][_0xb984('0x66')]({'where':{'id':_0x3deb31[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0xd5')],'as':_0xb984('0xa7')},{'model':db['MailAccount'],'as':'MailAccount'}]});})['then'](handleEntityNotFound(_0x3c982a,null))[_0xb984('0x16')](function(_0x30ebd){if(_0x30ebd&&_0x30ebd['List']){_0x2d8347=_0x30ebd;var _0x380f7b=_[_0xb984('0x10')](_0x3deb31[_0xb984('0x6c')],{'firstName':_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')],'phone':_0x3deb31[_0xb984('0x6c')][_0xb984('0xb4')],'ListId':_0x30ebd[_0xb984('0xa5')]});_0x380f7b[_0x3deb31[_0xb984('0x6c')][_0xb984('0xd3')]]=_0x3deb31['body'][_0xb984('0xb4')];return db[_0xb984('0xb5')]['findOrCreate']({'where':_0x1ea3e2,'defaults':_0x380f7b});}})[_0xb984('0xd6')](function(_0x2d960e){if(_0x2d960e){_0x327159=_0x2d960e;var _0xa402d1=fs['readFileSync'](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0xd7')),'utf8');var _0x2b99d9=ejs[_0xb984('0xd8')](_0xa402d1,{'body':_[_0xb984('0xd9')](_0x3deb31[_0xb984('0x6c')][_0xb984('0x6c')]),'bodyTitle':_0x2d8347['offlineMessageBody']});return db['ChatOfflineMessage'][_0xb984('0x67')]({'body':_0x2b99d9,'plainBody':htmlToText[_0xb984('0xda')](_0x2b99d9),'ContactId':_0x2d960e['id'],'ChatWebsiteId':_0x2d8347['id']});}})[_0xb984('0x16')](function(_0x230900){_0x51f9d2=_0x230900;if(_0x7892c7[_0xb984('0x55')]){var _0x3fed67=_0x7892c7['map'](function(_0x17818b){return{'name':_0x17818b[_0xb984('0xdb')],'basename':_0x17818b[_0xb984('0x83')],'type':_0x17818b[_0xb984('0xdc')],'ChatOfflineMessageId':_0x230900['id']};});_0x564a33=_0x3fed67[_0xb984('0x4a')](_0x48db10=>{var _0x1bf129={'filename':_0x48db10[_0xb984('0x2f')],'path':path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0xdd'),_0xb984('0xcd'),_0xb984('0xde'),_0xb984('0xdf'),_0x48db10[_0xb984('0xe0')])};return _0x1bf129;});if(!_0x2d8347[_0xb984('0xe1')]){return db[_0xb984('0xe2')][_0xb984('0xe3')](function(_0x25c025){return db[_0xb984('0xe4')][_0xb984('0xe5')](_0x3fed67,{'transaction':_0x25c025});});}}})[_0xb984('0x16')](function(){if(_0x51f9d2){_0x4a683e=_0x51f9d2;return db[_0xb984('0xe6')][_0xb984('0x7e')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xb984('0xe7'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':_0xb984('0xe8'),'raw':!![]}]}]});}})[_0xb984('0x16')](function(_0x1453de){if(_0x1453de&&_0x1453de[_0xb984('0xe7')]&&_0x2d8347['forwardOffline']&&_0x2d8347['forwardOfflineAddress']){var _0x386213=_0x1453de['getSmtpOptions']();return respondWithRpcPromise(_0xb984('0xe9'),_0xb984('0xea'),{'account':_0x386213,'message':{'from':util[_0xb984('0x3f')](_0xb984('0xeb'),_0x1453de[_0xb984('0x2f')],_0x1453de[_0xb984('0xec')]||_0x1453de[_0xb984('0xe7')]['user']),'to':_0x2d8347[_0xb984('0xed')],'subject':_0x2d8347[_0xb984('0xee')],'html':_0x4a683e['body'],'attachments':_0x564a33}},client9003)[_0xb984('0x16')](function(){return _0x4a683e;})[_0xb984('0x20')](function(_0x2b3973){logger['error'](_0x2b3973);});}})['then'](function(){if(_0x2d8347&&_0x2d8347['openNewInteraction']&&_0x2d8347['MailAccountId']){var _0x5144b9=[];if(_0x7892c7['length']){_0x5144b9=_0x7892c7['map'](function(_0x2da5c1){return{'name':_0x2da5c1[_0xb984('0xdb')],'basename':_0x2da5c1[_0xb984('0x83')],'type':_0x2da5c1[_0xb984('0xdc')],'ChatOfflineMessageId':_0x51f9d2['id']};});}var _0x5351c1;if(!_[_0xb984('0x91')](_0x2d8347[_0xb984('0xef')])){var _0x5e2df9=_[_0xb984('0x4a')](_0x3deb31['body'],function(_0xd91a0b){return _0xd91a0b;});var _0x5944da=_[_0xb984('0xf0')](_0x5e2df9)[0x0];var _0x54c95b=_[_0xb984('0xf1')](_0x5944da,function(_0x4054bc){return _0x4054bc;});_0x5351c1=_0x54c95b[0x1][_0x2d8347[_0xb984('0xef')]];}var _0x1cf6ed={'from':_0x327159[_0xb984('0xec')],'firstName':_0x327159['firstName'],'lastName':_0x327159[_0xb984('0x3a')],'mapKey':'email','message':{'from':_0x327159['email'],'to':_0x2d8347['MailAccount'][_0xb984('0xec')],'cc':'','subject':_[_0xb984('0x91')](_0x5351c1)?_0x2d8347['offlineMessageSubject']:_0x5351c1,'messageId':'','sentAt':new Date(),'attach':_0x5144b9['length'],'attachments':_0x5144b9,'originChannel':_0xb984('0xf2'),'ChatWebsiteId':_0x2d8347['id'],'ChatOfflineMessageId':_0x4a683e['id'],'originTo':_0x2d8347['MailAccount']['email']},'body':_0x4a683e[_0xb984('0x6c')]};var _0x1923e0={'account':{'id':_0x2d8347[_0xb984('0xf3')]},'body':_0x1cf6ed,'log':_0xb984('0xf4')};return respondWithRpcPromise(_0xb984('0xf4'),_0xb984('0xf5'),_0x1923e0,client9001)['then'](function(){return _0x4a683e;})[_0xb984('0x20')](function(_0x21e3cb){logger[_0xb984('0x1c')](_0x21e3cb);});}return;})[_0xb984('0x16')](function(){if(_0x4a683e){return _0x4a683e;}})['then'](respondWithResult(_0x3c982a,null))[_0xb984('0x20')](function(){for(var _0x239446 of _0x7892c7){var _0x560a43=path[_0xb984('0x88')](config['root'],_0xb984('0xdd'),_0xb984('0xcd'),_0xb984('0xde'),_0xb984('0xdf'),_0x239446[_0xb984('0x83')]);fs_extra[_0xb984('0xf6')](_0x560a43)[_0xb984('0x20')](function(_0xf96fed){logger[_0xb984('0x1c')](_0xb984('0xf7'),_0x560a43,_0xf96fed);});}});};exports[_0xb984('0xf8')]=function(_0x470640,_0x484883){return db[_0xb984('0xba')]['find']({'where':{'id':_0x470640[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x484883,null))['then'](function(_0x1dc7cf){if(_0x1dc7cf){return _0x1dc7cf[_0xb984('0xf8')](_0x470640[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x470640[_0xb984('0x6c')],[_0xb984('0x80'),'id'])||{});}})[_0xb984('0x16')](respondWithResult(_0x484883,null))[_0xb984('0x20')](handleError(_0x484883,null));};exports[_0xb984('0xfa')]=function(_0x3eb419,_0x148d95){var _0x21412e={'raw':![],'where':{}};var _0x2dac8e={};var _0x230f60={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x3eb419[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x148d95,null))['then'](function(_0x306d47){if(_0x306d47){_0x2dac8e[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0xba')][_0xb984('0x4c')]);_0x2dac8e['query']=_[_0xb984('0x50')](_0x3eb419[_0xb984('0x4f')]);_0x2dac8e['filters']=_[_0xb984('0x52')](_0x2dac8e['model'],_0x2dac8e[_0xb984('0x4f')]);_0x21412e[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2dac8e[_0xb984('0x42')],qs[_0xb984('0x54')](_0x3eb419[_0xb984('0x4f')]['fields']));_0x21412e[_0xb984('0x53')]=_0x21412e['attributes']['length']?_0x21412e['attributes']:_0x2dac8e[_0xb984('0x42')];if(!_0x3eb419[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x21412e[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x26')]);_0x21412e[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x57')]);}_0x21412e[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x3eb419[_0xb984('0x4f')][_0xb984('0x59')]);_0x21412e[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x3eb419[_0xb984('0x4f')],_0x2dac8e[_0xb984('0x51')]));_0x21412e[_0xb984('0x5a')]['ChatWebsiteId']=_0x306d47['id'];if(_0x3eb419['query']['filter']){_0x21412e[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x21412e[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x21412e[_0xb984('0x53')],function(_0x316390){var _0x441031={};_0x441031[_0x316390]={'$like':'%'+_0x3eb419['query'][_0xb984('0x5c')]+'%'};return _0x441031;})});}_0x21412e=_[_0xb984('0x5d')]({},_0x21412e,_0x3eb419[_0xb984('0x5f')]);return db[_0xb984('0xba')][_0xb984('0x27')]({'where':_0x21412e[_0xb984('0x5a')]})[_0xb984('0x16')](function(_0x86780d){_0x230f60[_0xb984('0x27')]=_0x86780d;if(_0x3eb419[_0xb984('0x4f')][_0xb984('0x60')]){_0x21412e[_0xb984('0x61')]=[{'model':db[_0xb984('0xb5')],'as':_0xb984('0xfb'),'required':![]},{'model':db[_0xb984('0xfc')],'as':_0xb984('0xfd'),'attributes':[_0xb984('0x2f'),_0xb984('0xfe'),_0xb984('0xff')],'required':![]},{'model':db[_0xb984('0x100')],'as':_0xb984('0x101'),'attributes':['id',_0xb984('0x2f'),'color'],'where':_0x3eb419[_0xb984('0x4f')][_0xb984('0x102')]?{'id':_0x3eb419[_0xb984('0x4f')]['tag']}:undefined,'required':_0x3eb419[_0xb984('0x4f')]['tag']?!![]:![]}];}return db['ChatInteraction'][_0xb984('0x62')](_0x21412e);})['then'](function(_0x162eb7){_0x230f60[_0xb984('0x63')]=_0x162eb7;return _0x230f60;});}})['then'](respondWithFilteredResult(_0x148d95,_0x21412e))[_0xb984('0x20')](handleError(_0x148d95,null));};exports[_0xb984('0x103')]=function(_0x1af036,_0x5e7936){var _0x3145f8=0x0;var _0x2e9f8e=0x0;var _0x1029bb=![];var _0x2ad62e;var _0x31c9a1;return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x1af036[_0xb984('0x65')]['id']},'include':[{'model':db[_0xb984('0x99')],'as':_0xb984('0x99'),'include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0xb984('0xac')]}]}]})[_0xb984('0x16')](handleEntityNotFound(_0x5e7936,null))[_0xb984('0x16')](function(_0x4bd400){if(_0x4bd400){_0x2ad62e=_0x4bd400;return _0x4bd400[_0xb984('0x104')]({'raw':!![]});}})[_0xb984('0x16')](function(_0x2dc204){if(_0x2ad62e){if(_0x2dc204){_0x31c9a1=_0x2dc204;}}return require('../../config/license/util')['getLicense']();})[_0xb984('0x16')](function(_0x5ca21e){if(_0x5ca21e){_0x2e9f8e=_0x5ca21e[_0xb984('0x105')];_0x1029bb=_0x5ca21e['custom'];}})[_0xb984('0x16')](function(){return db[_0xb984('0xba')][_0xb984('0x27')]({'where':{'closed':![]}});})[_0xb984('0x16')](function(_0x3f70f2){_0x3145f8=_0x3f70f2;if(_0x2e9f8e&&_0x3f70f2>_0x2e9f8e){return db[_0xb984('0x106')][_0xb984('0x7e')]({'where':{'id':0x1}})['then'](function(_0x2b2d2f){if(_0x2b2d2f){_0x2b2d2f['increment'](_0xb984('0x107'));}});}})['then'](function(){var _0x4c01f7=_0x2ad62e[_0xb984('0x99')];var _0x83aa33=_0x2ad62e[_0xb984('0x9b')]||undefined;return _0x4c01f7?_0x4c01f7[_0xb984('0x9c')](_0x83aa33):!![];})['then'](function(_0x256b3d){var _0x5eee58=fs[_0xb984('0x108')](path[_0xb984('0x88')](config[_0xb984('0x89')],_0xb984('0x109')),_0xb984('0x10a'));var _0xb5c49f=_0xb984('0x10b');var _0x22d584=![];var _0x461ab4,_0x2ba2fc;if(_0x1af036[_0xb984('0x10c')]['referer']){_0x461ab4=new URL(_0x1af036[_0xb984('0x10c')]['referer'])[_0xb984('0x10d')];}else if(_0x1af036[_0xb984('0x10c')][_0xb984('0x10d')]){_0x461ab4=new URL(_0x1af036['headers'][_0xb984('0x10d')])[_0xb984('0x10d')];}else{_0x461ab4=_0xb984('0x10e');}_0x2ba2fc=typeof _0x2ad62e[_0xb984('0x68')]['split'](',')[_0xb984('0x66')](function(_0x2df7bd){return wildcardUtils[_0xb984('0x10f')](_0x2df7bd,_0x461ab4);})!=='undefined';var _0x384873={'chatVersion':_0xb5c49f,'chatWebsiteAddressOrigin':_0x2ba2fc?_0x461ab4:_0x2ad62e[_0xb984('0x68')],'remote':_0x2ad62e[_0xb984('0x110')],'query':querystring['stringify'](_['merge'](_0x2ad62e['get']({'plain':!![]}),{'customerIp':_0x1af036[_0xb984('0x10c')]['x-forwarded-for']||_0x1af036['headers']['x-real-ip']||_0x1af036[_0xb984('0x111')][_0xb984('0x112')]||_0x1af036['ip'],'referer':_0x1af036['headers'][_0xb984('0x3c')],'openedInteractions':_0x3145f8,'maxInteractions':_0x2e9f8e,'virtual':_0x1029bb[_0xb984('0x105')],'online':_0x256b3d,'custom':_0x1029bb,'address':_0x2ba2fc?_0x461ab4:null}))[_0xb984('0x113')](/'/g,'\x5c\x27')};_0x5e7936[_0xb984('0x30')](ejs['render'](Mustache[_0xb984('0xd8')](_0x5eee58,_0x384873),{'proactiveActions':_0x31c9a1,'alignment':_0x2ad62e[_0xb984('0x114')],'verticalAlignment':_0x2ad62e['verticalAlignment'],'div_color':_0x2ad62e[_0xb984('0x115')],'labelText':_0x2ad62e[_0xb984('0x116')],'text_color':_0x2ad62e[_0xb984('0x117')],'text_button_color':_0x2ad62e[_0xb984('0x118')],'button_color':_0x2ad62e['color_button'],'background_color':_0x2ad62e[_0xb984('0x119')],'hideWhenOffline':_0x2ad62e['hideWhenOffline'],'intervalId':_0x2ad62e[_0xb984('0x11a')],'isDevelopment':_0x22d584,'chatVersion':_0xb5c49f}));})['catch'](handleError(_0x5e7936,null));};exports['addApplications']=function(_0x3338a3,_0x4a7169){var _0xce8465=_0x3338a3[_0xb984('0x65')]['id'];var _0x1c3ccd=_0x3338a3['body'];var _0x1a70dc=0xc8;var _0x23fea7=null;return db['sequelize'][_0xb984('0xe3')]({'isolationLevel':db['sequelize']['Transaction'][_0xb984('0x11b')]['READ_COMMITTED']},function(_0x3c82be){return db['ChatWebsite'][_0xb984('0x7e')]({'where':{'id':_0xce8465},'transaction':_0x3c82be})[_0xb984('0x16')](function(_0x464eae){if(_0x464eae){return db['ChatApplication'][_0xb984('0x2a')]({'where':{'ChatWebsiteId':_0xce8465},'transaction':_0x3c82be})['then'](function(){var _0x3cd674=_[_0xb984('0x4a')](_0x1c3ccd,function(_0x3d961f){_0x3d961f['ChatWebsiteId']=_0xce8465;return _0x3d961f;});return db[_0xb984('0xa9')]['bulkCreate'](_0x3cd674,{'transaction':_0x3c82be});});}else{_0x1a70dc=0x194;_0x23fea7=[];}});})[_0xb984('0x16')](function(){if(_0x1a70dc!==0x194){return db[_0xb984('0xa9')][_0xb984('0x11c')]({'where':{'ChatWebsiteId':_0xce8465},'order':_0xb984('0xb1')})['then'](function(_0x1c19a7){_0x23fea7=_0x1c19a7;});}})[_0xb984('0x20')](function(_0x14478c){_0x1a70dc=0x1f4;logger[_0xb984('0x1c')](_0x14478c['stack']);if(_0x14478c[_0xb984('0x2f')]){delete _0x14478c[_0xb984('0x2f')];}_0x23fea7=_0x14478c;})[_0xb984('0x11d')](function(){if(_0x23fea7===null){_0x4a7169[_0xb984('0x21')](_0x1a70dc);}else{if(_0x1a70dc===0x1f4){_0x4a7169[_0xb984('0x22')](_0x1a70dc)[_0xb984('0x30')](_0x23fea7);}else{_0x4a7169[_0xb984('0x22')](_0x1a70dc)[_0xb984('0x24')](_0x23fea7);}}});};exports[_0xb984('0x11e')]=function(_0x5a2758,_0x1ac027){var _0x577d83={};var _0x2699c3={};var _0x4c59eb;var _0x5ea724;return db[_0xb984('0x4b')]['findOne']({'where':{'id':_0x5a2758[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x1ac027,null))[_0xb984('0x16')](function(_0x224023){if(_0x224023){_0x4c59eb=_0x224023;_0x2699c3['model']=_['keys'](db[_0xb984('0xa9')]['rawAttributes']);_0x2699c3[_0xb984('0x4f')]=_['keys'](_0x5a2758[_0xb984('0x4f')]);_0x2699c3['filters']=_[_0xb984('0x52')](_0x2699c3[_0xb984('0x42')],_0x2699c3[_0xb984('0x4f')]);_0x577d83[_0xb984('0x53')]=_[_0xb984('0x52')](_0x2699c3[_0xb984('0x42')],qs[_0xb984('0x54')](_0x5a2758[_0xb984('0x4f')]['fields']));_0x577d83[_0xb984('0x53')]=_0x577d83[_0xb984('0x53')][_0xb984('0x55')]?_0x577d83[_0xb984('0x53')]:_0x2699c3[_0xb984('0x42')];_0x577d83[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x5a2758[_0xb984('0x4f')][_0xb984('0x59')]);_0x577d83[_0xb984('0x5a')]=qs[_0xb984('0x51')](_[_0xb984('0x5b')](_0x5a2758['query'],_0x2699c3['filters']));if(_0x5a2758[_0xb984('0x4f')][_0xb984('0x5c')]){_0x577d83[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x577d83[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x577d83[_0xb984('0x53')],function(_0xbb1af1){var _0x3d6db4={};_0x3d6db4[_0xbb1af1]={'$like':'%'+_0x5a2758['query'][_0xb984('0x5c')]+'%'};return _0x3d6db4;})});}_0x577d83=_[_0xb984('0x5d')]({},_0x577d83,_0x5a2758['options']);return _0x4c59eb[_0xb984('0x11e')](_0x577d83);}})[_0xb984('0x16')](function(_0x1e3555){if(_0x1e3555){_0x5ea724=_0x1e3555[_0xb984('0x55')];if(!_0x5a2758[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x577d83[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x5a2758[_0xb984('0x4f')][_0xb984('0x26')]);_0x577d83[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x5a2758[_0xb984('0x4f')]['offset']);}return _0x4c59eb[_0xb984('0x11e')](_0x577d83);}})['then'](function(_0x45ad9f){if(_0x45ad9f){return _0x45ad9f?{'count':_0x5ea724,'rows':_0x45ad9f}:null;}})[_0xb984('0x16')](respondWithResult(_0x1ac027,null))['catch'](handleError(_0x1ac027,null));};exports['addProactiveActions']=function(_0x10965f,_0x496396){return db[_0xb984('0x11f')]['find']({'where':{'id':_0x10965f[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x496396,null))[_0xb984('0x16')](function(_0x4a498d){if(_0x4a498d){return _0x4a498d['addProactiveActions'](_0x10965f[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x10965f['body'],[_0xb984('0x80'),'id'])||{});}})[_0xb984('0x16')](respondWithResult(_0x496396,null))[_0xb984('0x20')](handleError(_0x496396,null));};exports[_0xb984('0x104')]=function(_0x509927,_0x2f477e){var _0x5efa1e={};var _0x1220f4={};var _0x4ac8a9;var _0x215b05;return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x509927[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x2f477e,null))['then'](function(_0x83930f){if(_0x83930f){_0x4ac8a9=_0x83930f;_0x1220f4[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x120')][_0xb984('0x4c')]);_0x1220f4[_0xb984('0x4f')]=_['keys'](_0x509927[_0xb984('0x4f')]);_0x1220f4[_0xb984('0x51')]=_[_0xb984('0x52')](_0x1220f4['model'],_0x1220f4['query']);_0x5efa1e[_0xb984('0x53')]=_[_0xb984('0x52')](_0x1220f4['model'],qs[_0xb984('0x54')](_0x509927['query'][_0xb984('0x54')]));_0x5efa1e['attributes']=_0x5efa1e[_0xb984('0x53')][_0xb984('0x55')]?_0x5efa1e[_0xb984('0x53')]:_0x1220f4[_0xb984('0x42')];_0x5efa1e[_0xb984('0x58')]=qs['sort'](_0x509927['query'][_0xb984('0x59')]);_0x5efa1e[_0xb984('0x5a')]=qs['filters'](_[_0xb984('0x5b')](_0x509927[_0xb984('0x4f')],_0x1220f4[_0xb984('0x51')]));if(_0x509927[_0xb984('0x4f')]['filter']){_0x5efa1e[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x5efa1e[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x5efa1e[_0xb984('0x53')],function(_0x53dfd7){var _0x2b4b04={};_0x2b4b04[_0x53dfd7]={'$like':'%'+_0x509927[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x2b4b04;})});}_0x5efa1e=_[_0xb984('0x5d')]({},_0x5efa1e,_0x509927[_0xb984('0x5f')]);return _0x4ac8a9[_0xb984('0x104')](_0x5efa1e);}})[_0xb984('0x16')](function(_0x17de2f){if(_0x17de2f){_0x215b05=_0x17de2f[_0xb984('0x55')];if(!_0x509927[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x5efa1e['limit']=qs['limit'](_0x509927[_0xb984('0x4f')]['limit']);_0x5efa1e[_0xb984('0x57')]=qs['offset'](_0x509927['query']['offset']);}return _0x4ac8a9[_0xb984('0x104')](_0x5efa1e);}})[_0xb984('0x16')](function(_0x3fdc7d){if(_0x3fdc7d){return _0x3fdc7d?{'count':_0x215b05,'rows':_0x3fdc7d}:null;}})[_0xb984('0x16')](respondWithResult(_0x2f477e,null))[_0xb984('0x20')](handleError(_0x2f477e,null));};exports[_0xb984('0x121')]=function(_0x2e9d36,_0x3d7ae9){var _0x18b112=_0x2e9d36[_0xb984('0x4f')][_0xb984('0x122')]===_0xb984('0x123')?_0xb984('0x124'):_0xb984('0x125');return db[_0xb984('0x4b')][_0xb984('0x66')]({'attributes':['id',_0x18b112],'where':{'id':_0x2e9d36[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x3d7ae9,null))[_0xb984('0x16')](function(_0x2f4779){if(_0x2f4779){var _0xd81de1=_0x2f4779[_0x18b112];var _0x1f98a1=_0xd81de1&&_0xd81de1[_0xb984('0x126')]?_0xd81de1[_0xb984('0x126')]:[];_0x3d7ae9[_0xb984('0x30')]({'fromKey':_[_0xb984('0x91')](_0xd81de1['fromKey'])?undefined:_0xd81de1['fromKey'],'count':_0x1f98a1['length'],'rows':_0x1f98a1});}})[_0xb984('0x20')](handleError(_0x3d7ae9,null));};exports[_0xb984('0x127')]=function(_0x14a46c,_0x464919){var _0x3e80f5={'raw':![],'where':{}};var _0x20c8c5={};var _0x362f2a={'count':0x0,'rows':[]};return db[_0xb984('0x4b')][_0xb984('0x7e')]({'where':{'id':_0x14a46c[_0xb984('0x65')]['id']}})['then'](handleEntityNotFound(_0x464919,null))['then'](function(_0x427a6e){if(_0x427a6e){_0x20c8c5[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0x128')][_0xb984('0x4c')]);_0x20c8c5['query']=_['keys'](_0x14a46c[_0xb984('0x4f')]);_0x20c8c5[_0xb984('0x51')]=_[_0xb984('0x52')](_0x20c8c5[_0xb984('0x42')],_0x20c8c5[_0xb984('0x4f')]);_0x3e80f5[_0xb984('0x53')]=_[_0xb984('0x52')](_0x20c8c5[_0xb984('0x42')],qs[_0xb984('0x54')](_0x14a46c[_0xb984('0x4f')]['fields']));_0x3e80f5[_0xb984('0x53')]=_0x3e80f5[_0xb984('0x53')][_0xb984('0x55')]?_0x3e80f5[_0xb984('0x53')]:_0x20c8c5[_0xb984('0x42')];if(!_0x14a46c['query'][_0xb984('0x79')]('nolimit')){_0x3e80f5[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x26')]);_0x3e80f5[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x57')]);}_0x3e80f5[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x14a46c[_0xb984('0x4f')][_0xb984('0x59')]);_0x3e80f5[_0xb984('0x5a')]=qs[_0xb984('0x51')](_['pick'](_0x14a46c['query'],_0x20c8c5[_0xb984('0x51')]));_0x3e80f5[_0xb984('0x5a')][_0xb984('0x76')]=_0x427a6e['id'];if(_0x14a46c[_0xb984('0x4f')][_0xb984('0x5c')]){_0x3e80f5[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x3e80f5[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x3e80f5[_0xb984('0x53')],function(_0x501d65){var _0x38f917={};_0x38f917[_0x501d65]={'$like':'%'+_0x14a46c[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x38f917;})});}_0x3e80f5=_[_0xb984('0x5d')]({},_0x3e80f5,_0x14a46c[_0xb984('0x5f')]);return db[_0xb984('0x128')][_0xb984('0x27')]({'where':_0x3e80f5['where']})[_0xb984('0x16')](function(_0x3a1c1c){_0x362f2a[_0xb984('0x27')]=_0x3a1c1c;if(_0x14a46c[_0xb984('0x4f')][_0xb984('0x60')]){_0x3e80f5[_0xb984('0x61')]=[{'all':!![]}];}else{_0x3e80f5[_0xb984('0x61')]=[{'model':db[_0xb984('0xb5')],'as':'Contact','required':![]},{'model':db[_0xb984('0xe4')],'as':_0xb984('0x129'),'required':![]}];}return db[_0xb984('0x128')]['findAll'](_0x3e80f5);})[_0xb984('0x16')](function(_0x5735ed){_0x362f2a[_0xb984('0x63')]=_0x5735ed;return _0x362f2a;});}})[_0xb984('0x16')](respondWithFilteredResult(_0x464919,_0x3e80f5))[_0xb984('0x20')](handleError(_0x464919,null));};exports[_0xb984('0x12a')]=function(_0x108963,_0x294cb9){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0x108963[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x294cb9,null))['then'](function(_0x72bcf8){if(_0x72bcf8){return _0x72bcf8[_0xb984('0x12a')](_0x108963[_0xb984('0x6c')][_0xb984('0x80')],_[_0xb984('0xf9')](_0x108963['body'],['ids','id'])||{})[_0xb984('0xd6')](function(_0x496fbb){for(var _0x7b3434=0x0;_0x7b3434<_0x108963[_0xb984('0x6c')][_0xb984('0x80')][_0xb984('0x55')];_0x7b3434+=0x1){socket[_0xb984('0x12b')](_0xb984('0x12c'),{'UserId':Number(_0x108963['body']['ids'][_0x7b3434]),'ChatWebsiteId':Number(_0x108963[_0xb984('0x65')]['id'])});}return _0x496fbb;});}})[_0xb984('0x16')](respondWithResult(_0x294cb9,null))[_0xb984('0x20')](handleError(_0x294cb9,null));};exports['removeAgents']=function(_0xcc9c8e,_0x24bac4){return db[_0xb984('0x4b')][_0xb984('0x66')]({'where':{'id':_0xcc9c8e['params']['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x24bac4,null))[_0xb984('0x16')](function(_0x16f05e){if(_0x16f05e){return _0x16f05e[_0xb984('0x12d')](_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')])[_0xb984('0x16')](function(){if(_[_0xb984('0x12e')](_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')])){for(var _0x2e99bc=0x0;_0x2e99bc<_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')][_0xb984('0x55')];_0x2e99bc+=0x1){socket[_0xb984('0x12b')]('userChatWebsite:remove',{'UserId':Number(_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')][_0x2e99bc]),'ChatWebsiteId':Number(_0xcc9c8e['params']['id'])});}}else{socket[_0xb984('0x12b')](_0xb984('0x12f'),{'UserId':Number(_0xcc9c8e[_0xb984('0x4f')][_0xb984('0x80')]),'ChatWebsiteId':Number(_0xcc9c8e[_0xb984('0x65')]['id'])});}});}})[_0xb984('0x16')](respondWithStatusCode(_0x24bac4,null))[_0xb984('0x20')](handleError(_0x24bac4,null));};exports['getAgents']=function(_0x314eac,_0x19fcd0){var _0x573a4c={};var _0xbed419={};var _0x24787b;var _0x30484e;return db['ChatWebsite'][_0xb984('0x7e')]({'where':{'id':_0x314eac[_0xb984('0x65')]['id']}})[_0xb984('0x16')](handleEntityNotFound(_0x19fcd0,null))[_0xb984('0x16')](function(_0x5ba451){if(_0x5ba451){_0x24787b=_0x5ba451;_0xbed419[_0xb984('0x42')]=_[_0xb984('0x50')](db[_0xb984('0xfc')][_0xb984('0x4c')]);_0xbed419[_0xb984('0x4f')]=_[_0xb984('0x50')](_0x314eac[_0xb984('0x4f')]);_0xbed419[_0xb984('0x51')]=_[_0xb984('0x52')](_0xbed419[_0xb984('0x42')],_0xbed419['query']);_0x573a4c[_0xb984('0x53')]=_['intersection'](_0xbed419[_0xb984('0x42')],qs[_0xb984('0x54')](_0x314eac[_0xb984('0x4f')][_0xb984('0x54')]));_0x573a4c[_0xb984('0x53')]=_0x573a4c[_0xb984('0x53')][_0xb984('0x55')]?_0x573a4c[_0xb984('0x53')]:_0xbed419[_0xb984('0x42')];_0x573a4c[_0xb984('0x58')]=qs[_0xb984('0x59')](_0x314eac[_0xb984('0x4f')][_0xb984('0x59')]);_0x573a4c['where']=qs[_0xb984('0x51')](_['pick'](_0x314eac[_0xb984('0x4f')],_0xbed419['filters']));if(_0x314eac[_0xb984('0x4f')]['filter']){_0x573a4c[_0xb984('0x5a')]=_[_0xb984('0x5d')](_0x573a4c[_0xb984('0x5a')],{'$or':_[_0xb984('0x4a')](_0x573a4c[_0xb984('0x53')],function(_0x2a212a){var _0x36dfa1={};_0x36dfa1[_0x2a212a]={'$like':'%'+_0x314eac[_0xb984('0x4f')][_0xb984('0x5c')]+'%'};return _0x36dfa1;})});}_0x573a4c=_['merge']({},_0x573a4c,_0x314eac['options']);return _0x24787b[_0xb984('0x130')](_0x573a4c);}})[_0xb984('0x16')](function(_0x4bd4cc){if(_0x4bd4cc){_0x30484e=_0x4bd4cc[_0xb984('0x55')];if(!_0x314eac[_0xb984('0x4f')][_0xb984('0x79')](_0xb984('0x56'))){_0x573a4c[_0xb984('0x26')]=qs[_0xb984('0x26')](_0x314eac['query'][_0xb984('0x26')]);_0x573a4c[_0xb984('0x57')]=qs[_0xb984('0x57')](_0x314eac[_0xb984('0x4f')][_0xb984('0x57')]);}return _0x24787b[_0xb984('0x130')](_0x573a4c);}})['then'](function(_0x54cbef){if(_0x54cbef){return _0x54cbef?{'count':_0x30484e,'rows':_0x54cbef}:null;}})[_0xb984('0x16')](respondWithResult(_0x19fcd0,null))[_0xb984('0x20')](handleError(_0x19fcd0,null));};
\ No newline at end of file