Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 17246ba..43584bd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5f66=['Start','startRouting','EventManager','offline','files','send','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','originalname','mimetype','server','basename','openNewInteraction','sequelize','transaction','Attachment','bulkCreate','findOne','MailServerOut','Smtp','forwardOfflineAddress','service','host','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','toPairsIn','mapValues','subjectOffline','Chat','MailAccountId','NotifyMailAccount','notifyMail','attachments','offline-chat','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','fullname','internal','Tags','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','../../config/license/util','virtual','custom','License','increment','chatLicenseExceeded','all','some','x-real-ip','connection','remoteAddress','replace','alignment','color','labelText','textColor','color_button','backgroundColor','addApplications','Transaction','READ_COMMITTED','priority','getApplications','addProactiveActions','ChatProactiveAction','getFields','false','offlineForm','items','fromKey','Attachments','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','path','ejs','fs-extra','lodash','querystring','../../components/parsers/qs','api','../../config/environment','defaults','redis','localhost','socket.io-emitter','./chatWebsite.socket','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','status','limit','undefined','count','offset','set','Content-Range','json','update','destroy','get','ChatWebsites','UserProfileResource','end','stack','name','index','mandatoryDispositionPause','map','type','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','ChatWebsite','include','rows','show','params','Pause','keys','rawAttributes','includeAll','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','ChatWebsiteId','Disposition','getDispositions','removeDispositions','addAnswer','getAnswers','CannedAnswer','findAll','removeAnswers','ids','sitepic','file','filename','addAvatar','agentAvatar','addCustomerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','isNil','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','existsSync','server/files/images/avatars/','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','setUA','headers','getResult','chat','CmContact','Sequelize','ValidationError','difference','createdAt','updatedAt','CompanyId','ListId','from','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','Contacts','DESC','ChatApplication','Applications','List','account','applications','list','asc','contact','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','lastName','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','vendor','%s\x20%s\x20%s','stringify','ChatInteraction','threadId','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','unmanaged','*,*,*,*','AttachmentId','User','unshift','agent','forcedOwnership'];(function(_0x158a61,_0x4e93a3){var _0x534c81=function(_0x42781d){while(--_0x42781d){_0x158a61['push'](_0x158a61['shift']());}};_0x534c81(++_0x4e93a3);}(_0x5f66,0x1a0));var _0x65f6=function(_0x21a9d9,_0x4d5ac8){_0x21a9d9=_0x21a9d9-0x0;var _0x46adce=_0x5f66[_0x21a9d9];return _0x46adce;};'use strict';var BPromise=require('bluebird');var Mustache=require(_0x65f6('0x0'));var util=require('util');var path=require(_0x65f6('0x1'));var ejs=require(_0x65f6('0x2'));var fs=require('fs');var fs_extra=require(_0x65f6('0x3'));var _=require(_0x65f6('0x4'));var querystring=require(_0x65f6('0x5'));var Redis=require('ioredis');var qs=require(_0x65f6('0x6'));var logger=require('../../config/logger')(_0x65f6('0x7'));var config=require(_0x65f6('0x8'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x65f6('0x9')](config[_0x65f6('0xa')],{'host':_0x65f6('0xb'),'port':0x18eb});var socket=require(_0x65f6('0xc'))(new Redis(config[_0x65f6('0xa')]));require(_0x65f6('0xd'))['register'](socket);var htmlToText=require('html-to-text');var jayson=require(_0x65f6('0xe'));var client=jayson[_0x65f6('0xf')][_0x65f6('0x10')]({'port':0x232c});var client9002=jayson[_0x65f6('0xf')]['http']({'port':0x232a});var client9003=jayson[_0x65f6('0xf')]['http']({'port':0x232b});var client9001=jayson['client'][_0x65f6('0x10')]({'port':0x2329});function respondWithRpcPromise(_0x576875,_0x419819,_0x4862a5,_0x2f964a){return new BPromise(function(_0x186a6a,_0x2c4ee5){var _0x217570=_0x2f964a||client;return _0x217570[_0x65f6('0x11')](_0x576875,_0x4862a5)[_0x65f6('0x12')](function(_0x44144b){logger[_0x65f6('0x13')](_0x65f6('0x14'),_0x419819,_0x65f6('0x15'));logger['debug'](_0x65f6('0x16'),_0x419819,'request\x20sent',JSON['stringify'](_0x44144b));if(_0x44144b[_0x65f6('0x17')]){if(_0x44144b[_0x65f6('0x17')][_0x65f6('0x18')]===0x1f4){logger[_0x65f6('0x17')](_0x65f6('0x14'),_0x419819,_0x44144b[_0x65f6('0x17')][_0x65f6('0x19')]);return _0x2c4ee5(_0x44144b[_0x65f6('0x17')]['message']);}logger['error'](_0x65f6('0x14'),_0x419819,_0x44144b['error']['message']);return _0x186a6a(_0x44144b['error'][_0x65f6('0x19')]);}else{logger[_0x65f6('0x13')]('ChatWebsite,\x20%s,\x20%s',_0x419819,_0x65f6('0x15'));_0x186a6a(_0x44144b[_0x65f6('0x1a')][_0x65f6('0x19')]);}})[_0x65f6('0x1b')](function(_0x219ab2){logger[_0x65f6('0x17')]('ChatWebsite,\x20%s,\x20%s',_0x419819,_0x219ab2);_0x2c4ee5(_0x219ab2);});});}function respondWithStatusCode(_0x197a49,_0x4bb39e){_0x4bb39e=_0x4bb39e||0xcc;return function(_0x5b9e2a){if(_0x5b9e2a){return _0x197a49[_0x65f6('0x1c')](_0x4bb39e);}return _0x197a49[_0x65f6('0x1d')](_0x4bb39e)['end']();};}function respondWithResult(_0x1eeaaa,_0x471a33){_0x471a33=_0x471a33||0xc8;return function(_0x2317ce){if(_0x2317ce){return _0x1eeaaa[_0x65f6('0x1d')](_0x471a33)['json'](_0x2317ce);}};}function respondWithFilteredResult(_0x9d7bb0,_0x59ea32){return function(_0x20a161){if(_0x20a161){var _0x5963e0=typeof _0x59ea32['offset']==='undefined'&&typeof _0x59ea32[_0x65f6('0x1e')]===_0x65f6('0x1f');var _0x4b2292=_0x20a161[_0x65f6('0x20')];var _0x28f710=_0x5963e0?0x0:_0x59ea32['offset'];var _0x325cb4=_0x5963e0?_0x20a161[_0x65f6('0x20')]:_0x59ea32[_0x65f6('0x21')]+_0x59ea32['limit'];var _0x4ac04b;if(_0x325cb4>=_0x4b2292){_0x325cb4=_0x4b2292;_0x4ac04b=0xc8;}else{_0x4ac04b=0xce;}_0x9d7bb0['status'](_0x4ac04b);return _0x9d7bb0[_0x65f6('0x22')](_0x65f6('0x23'),_0x28f710+'-'+_0x325cb4+'/'+_0x4b2292)[_0x65f6('0x24')](_0x20a161);}return null;};}function saveUpdates(_0x408ccc){return function(_0x518cac){if(_0x518cac){return _0x518cac[_0x65f6('0x25')](_0x408ccc)[_0x65f6('0x12')](function(_0x4ace4c){return _0x4ace4c;});}return null;};}function removeEntity(_0x4ea23d){return function(_0x154cbd){if(_0x154cbd){return _0x154cbd[_0x65f6('0x26')]()['then'](function(){var _0x4e50c0=_0x154cbd[_0x65f6('0x27')]({'plain':!![]});var _0x1ce43c=_0x65f6('0x28');return db[_0x65f6('0x29')][_0x65f6('0x26')]({'where':{'type':_0x1ce43c,'resourceId':_0x4e50c0['id']}})[_0x65f6('0x12')](function(){return _0x154cbd;});})['then'](function(){_0x4ea23d[_0x65f6('0x1d')](0xcc)[_0x65f6('0x2a')]();});}};}function handleEntityNotFound(_0x46f03c){return function(_0x4bc037){if(!_0x4bc037){_0x46f03c[_0x65f6('0x1c')](0x194);}return _0x4bc037;};}function handleError(_0x2a7aa8,_0xbaed3c){_0xbaed3c=_0xbaed3c||0x1f4;return function(_0x45510a){logger[_0x65f6('0x17')](_0x45510a[_0x65f6('0x2b')]);if(_0x45510a['name']){delete _0x45510a[_0x65f6('0x2c')];}_0x2a7aa8[_0x65f6('0x1d')](_0xbaed3c)['send'](_0x45510a);};}exports[_0x65f6('0x2d')]=function(_0x5a740a,_0x2b403b){var _0x50494b={'include':[{'model':db['Pause'],'as':_0x65f6('0x2e')}]},_0x2b9fb6={},_0x24f7fd={'count':0x0,'rows':[]};var _0x13e41a=_[_0x65f6('0x2f')](db['ChatWebsite']['rawAttributes'],function(_0x30109d){return{'name':_0x30109d['fieldName'],'type':_0x30109d[_0x65f6('0x30')]['key']};});_0x2b9fb6[_0x65f6('0x31')]=_[_0x65f6('0x2f')](_0x13e41a,'name');_0x2b9fb6[_0x65f6('0x32')]=_['keys'](_0x5a740a['query']);_0x2b9fb6[_0x65f6('0x33')]=_[_0x65f6('0x34')](_0x2b9fb6[_0x65f6('0x31')],_0x2b9fb6[_0x65f6('0x32')]);_0x50494b[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x2b9fb6[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x5a740a['query'][_0x65f6('0x36')]));_0x50494b['attributes']=_0x50494b[_0x65f6('0x35')][_0x65f6('0x37')]?_0x50494b[_0x65f6('0x35')]:_0x2b9fb6[_0x65f6('0x31')];if(!_0x5a740a['query'][_0x65f6('0x38')](_0x65f6('0x39'))){_0x50494b[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x5a740a[_0x65f6('0x32')][_0x65f6('0x1e')]);_0x50494b[_0x65f6('0x21')]=qs[_0x65f6('0x21')](_0x5a740a[_0x65f6('0x32')]['offset']);}_0x50494b[_0x65f6('0x3a')]=qs[_0x65f6('0x3b')](_0x5a740a[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x50494b[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x5a740a[_0x65f6('0x32')],_0x2b9fb6[_0x65f6('0x33')]),_0x13e41a);if(_0x5a740a[_0x65f6('0x32')][_0x65f6('0x3e')]){_0x50494b[_0x65f6('0x3c')]=_[_0x65f6('0x3f')](_0x50494b[_0x65f6('0x3c')],{'$or':_[_0x65f6('0x2f')](_0x13e41a,function(_0x2cb38d){if(_0x2cb38d['type']!==_0x65f6('0x40')){var _0x37cd36={};_0x37cd36[_0x2cb38d[_0x65f6('0x2c')]]={'$like':'%'+_0x5a740a[_0x65f6('0x32')]['filter']+'%'};return _0x37cd36;}})});}_0x50494b=_[_0x65f6('0x3f')]({},_0x50494b,_0x5a740a[_0x65f6('0x41')]);var _0x2b01eb={'where':_0x50494b['where']};return db[_0x65f6('0x42')][_0x65f6('0x20')](_0x2b01eb)[_0x65f6('0x12')](function(_0x2179e5){_0x24f7fd['count']=_0x2179e5;if(_0x5a740a[_0x65f6('0x32')]['includeAll']){_0x50494b[_0x65f6('0x43')]=[{'all':!![]}];}return db[_0x65f6('0x42')]['findAll'](_0x50494b);})[_0x65f6('0x12')](function(_0x5085db){_0x24f7fd[_0x65f6('0x44')]=_0x5085db;return _0x24f7fd;})[_0x65f6('0x12')](respondWithFilteredResult(_0x2b403b,_0x50494b))[_0x65f6('0x1b')](handleError(_0x2b403b,null));};exports[_0x65f6('0x45')]=function(_0x3ec18f,_0x3837b2){var _0x4d30c5={'raw':![],'where':{'id':_0x3ec18f[_0x65f6('0x46')]['id']},'include':[{'model':db[_0x65f6('0x47')],'as':_0x65f6('0x2e')}]},_0x51bf6c={};_0x51bf6c[_0x65f6('0x31')]=_[_0x65f6('0x48')](db[_0x65f6('0x42')][_0x65f6('0x49')]);_0x51bf6c[_0x65f6('0x32')]=_[_0x65f6('0x48')](_0x3ec18f['query']);_0x51bf6c[_0x65f6('0x33')]=_[_0x65f6('0x34')](_0x51bf6c[_0x65f6('0x31')],_0x51bf6c['query']);_0x4d30c5[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x51bf6c['model'],qs[_0x65f6('0x36')](_0x3ec18f[_0x65f6('0x32')]['fields']));_0x4d30c5[_0x65f6('0x35')]=_0x4d30c5['attributes'][_0x65f6('0x37')]?_0x4d30c5[_0x65f6('0x35')]:_0x51bf6c[_0x65f6('0x31')];if(_0x3ec18f['query'][_0x65f6('0x4a')]){_0x4d30c5[_0x65f6('0x43')]=[{'all':!![]}];}_0x4d30c5=_['merge']({},_0x4d30c5,_0x3ec18f[_0x65f6('0x41')]);return db[_0x65f6('0x42')]['find'](_0x4d30c5)[_0x65f6('0x12')](handleEntityNotFound(_0x3837b2,null))[_0x65f6('0x12')](respondWithResult(_0x3837b2,null))[_0x65f6('0x1b')](handleError(_0x3837b2,null));};exports[_0x65f6('0x4b')]=function(_0x234fa7,_0x2350ca){return db[_0x65f6('0x42')][_0x65f6('0x4b')](_0x234fa7['body'],{})['then'](function(_0x5ca62e){var _0x19f40c=_0x234fa7[_0x65f6('0x4c')][_0x65f6('0x27')]({'plain':!![]});if(!_0x19f40c)throw new Error(_0x65f6('0x4d'));if(_0x19f40c['role']===_0x65f6('0x4c')){var _0x2032b9=_0x5ca62e[_0x65f6('0x27')]({'plain':!![]});var _0x50f63a=_0x65f6('0x28');return db[_0x65f6('0x4e')][_0x65f6('0x4f')]({'where':{'name':_0x50f63a,'userProfileId':_0x19f40c['userProfileId']},'raw':!![]})['then'](function(_0x1d337d){if(_0x1d337d&&_0x1d337d[_0x65f6('0x50')]===0x0){return db[_0x65f6('0x29')][_0x65f6('0x4b')]({'name':_0x2032b9[_0x65f6('0x2c')],'resourceId':_0x2032b9['id'],'type':_0x1d337d[_0x65f6('0x2c')],'sectionId':_0x1d337d['id']},{})[_0x65f6('0x12')](function(){return _0x5ca62e;});}else{return _0x5ca62e;}})[_0x65f6('0x1b')](function(_0x2d8b5b){logger[_0x65f6('0x17')](_0x65f6('0x51'),_0x2d8b5b);throw _0x2d8b5b;});}return _0x5ca62e;})[_0x65f6('0x12')](respondWithResult(_0x2350ca,0xc9))[_0x65f6('0x1b')](handleError(_0x2350ca,null));};exports[_0x65f6('0x25')]=function(_0x5ba9c6,_0x47610a){if(_0x5ba9c6[_0x65f6('0x52')]['id']){delete _0x5ba9c6[_0x65f6('0x52')]['id'];}return db['ChatWebsite'][_0x65f6('0x4f')]({'where':{'id':_0x5ba9c6[_0x65f6('0x46')]['id']},'include':[{'model':db[_0x65f6('0x47')],'as':_0x65f6('0x2e')}]})['then'](handleEntityNotFound(_0x47610a,null))[_0x65f6('0x12')](saveUpdates(_0x5ba9c6[_0x65f6('0x52')],null))[_0x65f6('0x12')](respondWithResult(_0x47610a,null))[_0x65f6('0x1b')](handleError(_0x47610a,null));};exports['destroy']=function(_0x2923ff,_0x2fc20f){return db['ChatWebsite'][_0x65f6('0x4f')]({'where':{'id':_0x2923ff[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x2fc20f,null))['then'](removeEntity(_0x2fc20f,null))[_0x65f6('0x1b')](handleError(_0x2fc20f,null));};exports[_0x65f6('0x53')]=function(_0x3974ef,_0x3c23e3){return db[_0x65f6('0x42')][_0x65f6('0x53')]()['then'](respondWithResult(_0x3c23e3,null))['catch'](handleError(_0x3c23e3,null));};exports['addDisposition']=function(_0x336a7d,_0x367d95){if(_0x336a7d[_0x65f6('0x52')]['id']){delete _0x336a7d[_0x65f6('0x52')]['id'];}return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x336a7d['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x367d95,null))[_0x65f6('0x12')](function(_0x54b569){if(_0x54b569){_0x336a7d[_0x65f6('0x52')][_0x65f6('0x54')]=_0x54b569['id'];return db[_0x65f6('0x55')]['create'](_0x336a7d[_0x65f6('0x52')]);}})[_0x65f6('0x12')](respondWithResult(_0x367d95,null))['catch'](handleError(_0x367d95,null));};exports[_0x65f6('0x56')]=function(_0x3edc6b,_0x1301f5){var _0x417b44={'raw':![],'where':{}};var _0x3d55f7={};var _0x2226bf={'count':0x0,'rows':[]};return db[_0x65f6('0x42')]['findOne']({'where':{'id':_0x3edc6b['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x1301f5,null))[_0x65f6('0x12')](function(_0x4a9524){if(_0x4a9524){_0x3d55f7[_0x65f6('0x31')]=_['keys'](db[_0x65f6('0x55')]['rawAttributes']);_0x3d55f7[_0x65f6('0x32')]=_[_0x65f6('0x48')](_0x3edc6b[_0x65f6('0x32')]);_0x3d55f7[_0x65f6('0x33')]=_[_0x65f6('0x34')](_0x3d55f7[_0x65f6('0x31')],_0x3d55f7[_0x65f6('0x32')]);_0x417b44[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x3d55f7['model'],qs['fields'](_0x3edc6b[_0x65f6('0x32')][_0x65f6('0x36')]));_0x417b44[_0x65f6('0x35')]=_0x417b44['attributes']['length']?_0x417b44[_0x65f6('0x35')]:_0x3d55f7[_0x65f6('0x31')];if(!_0x3edc6b[_0x65f6('0x32')][_0x65f6('0x38')](_0x65f6('0x39'))){_0x417b44[_0x65f6('0x1e')]=qs['limit'](_0x3edc6b['query'][_0x65f6('0x1e')]);_0x417b44[_0x65f6('0x21')]=qs['offset'](_0x3edc6b[_0x65f6('0x32')]['offset']);}_0x417b44[_0x65f6('0x3a')]=qs[_0x65f6('0x3b')](_0x3edc6b[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x417b44['where']=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x3edc6b[_0x65f6('0x32')],_0x3d55f7['filters']));_0x417b44['where'][_0x65f6('0x54')]=_0x4a9524['id'];if(_0x3edc6b['query'][_0x65f6('0x3e')]){_0x417b44[_0x65f6('0x3c')]=_[_0x65f6('0x3f')](_0x417b44[_0x65f6('0x3c')],{'$or':_['map'](_0x417b44['attributes'],function(_0x56f7f1){var _0x2e29b4={};_0x2e29b4[_0x56f7f1]={'$like':'%'+_0x3edc6b[_0x65f6('0x32')][_0x65f6('0x3e')]+'%'};return _0x2e29b4;})});}_0x417b44=_['merge']({},_0x417b44,_0x3edc6b[_0x65f6('0x41')]);return db[_0x65f6('0x55')][_0x65f6('0x20')]({'where':_0x417b44['where']})[_0x65f6('0x12')](function(_0x15809e){_0x2226bf['count']=_0x15809e;if(_0x3edc6b[_0x65f6('0x32')][_0x65f6('0x4a')]){_0x417b44['include']=[{'all':!![]}];}return db[_0x65f6('0x55')]['findAll'](_0x417b44);})[_0x65f6('0x12')](function(_0x55ea91){_0x2226bf[_0x65f6('0x44')]=_0x55ea91;return _0x2226bf;});}})[_0x65f6('0x12')](respondWithFilteredResult(_0x1301f5,_0x417b44))['catch'](handleError(_0x1301f5,null));};exports[_0x65f6('0x57')]=function(_0x442e25,_0x2a700b){return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x442e25[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x2a700b,null))[_0x65f6('0x12')](function(_0x31dba0){if(_0x31dba0){return _0x31dba0[_0x65f6('0x57')](_0x442e25[_0x65f6('0x32')]['ids']);}})[_0x65f6('0x12')](respondWithStatusCode(_0x2a700b,null))[_0x65f6('0x1b')](handleError(_0x2a700b,null));};exports[_0x65f6('0x58')]=function(_0x219e42,_0x5694f9){if(_0x219e42[_0x65f6('0x52')]['id']){delete _0x219e42[_0x65f6('0x52')]['id'];}return db['ChatWebsite'][_0x65f6('0x4f')]({'where':{'id':_0x219e42['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x5694f9,null))['then'](function(_0x31f6c1){if(_0x31f6c1){_0x219e42[_0x65f6('0x52')]['ChatWebsiteId']=_0x31f6c1['id'];return db['CannedAnswer'][_0x65f6('0x4b')](_0x219e42[_0x65f6('0x52')]);}})['then'](respondWithResult(_0x5694f9,null))[_0x65f6('0x1b')](handleError(_0x5694f9,null));};exports[_0x65f6('0x59')]=function(_0x73d359,_0x4edba0){var _0x1348ec={'raw':![],'where':{}};var _0x246510={};var _0x5889dc={'count':0x0,'rows':[]};return db[_0x65f6('0x42')]['findOne']({'where':{'id':_0x73d359[_0x65f6('0x46')]['id']}})['then'](handleEntityNotFound(_0x4edba0,null))['then'](function(_0x20687f){if(_0x20687f){_0x246510[_0x65f6('0x31')]=_[_0x65f6('0x48')](db[_0x65f6('0x5a')][_0x65f6('0x49')]);_0x246510[_0x65f6('0x32')]=_[_0x65f6('0x48')](_0x73d359[_0x65f6('0x32')]);_0x246510['filters']=_['intersection'](_0x246510[_0x65f6('0x31')],_0x246510['query']);_0x1348ec[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x246510[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x73d359[_0x65f6('0x32')]['fields']));_0x1348ec[_0x65f6('0x35')]=_0x1348ec[_0x65f6('0x35')][_0x65f6('0x37')]?_0x1348ec['attributes']:_0x246510[_0x65f6('0x31')];if(!_0x73d359[_0x65f6('0x32')][_0x65f6('0x38')](_0x65f6('0x39'))){_0x1348ec[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x73d359['query']['limit']);_0x1348ec[_0x65f6('0x21')]=qs[_0x65f6('0x21')](_0x73d359[_0x65f6('0x32')][_0x65f6('0x21')]);}_0x1348ec['order']=qs['sort'](_0x73d359[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x1348ec[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x73d359[_0x65f6('0x32')],_0x246510['filters']));_0x1348ec['where']['ChatWebsiteId']=_0x20687f['id'];if(_0x73d359[_0x65f6('0x32')][_0x65f6('0x3e')]){_0x1348ec[_0x65f6('0x3c')]=_[_0x65f6('0x3f')](_0x1348ec['where'],{'$or':_['map'](_0x1348ec[_0x65f6('0x35')],function(_0x27e44b){var _0x56077a={};_0x56077a[_0x27e44b]={'$like':'%'+_0x73d359[_0x65f6('0x32')]['filter']+'%'};return _0x56077a;})});}_0x1348ec=_[_0x65f6('0x3f')]({},_0x1348ec,_0x73d359['options']);return db[_0x65f6('0x5a')][_0x65f6('0x20')]({'where':_0x1348ec['where']})[_0x65f6('0x12')](function(_0x330e18){_0x5889dc[_0x65f6('0x20')]=_0x330e18;if(_0x73d359[_0x65f6('0x32')][_0x65f6('0x4a')]){_0x1348ec[_0x65f6('0x43')]=[{'all':!![]}];}return db['CannedAnswer'][_0x65f6('0x5b')](_0x1348ec);})['then'](function(_0x24495c){_0x5889dc['rows']=_0x24495c;return _0x5889dc;});}})[_0x65f6('0x12')](respondWithFilteredResult(_0x4edba0,_0x1348ec))[_0x65f6('0x1b')](handleError(_0x4edba0,null));};exports[_0x65f6('0x5c')]=function(_0x41e59a,_0x535558){return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x41e59a[_0x65f6('0x46')]['id']}})['then'](handleEntityNotFound(_0x535558,null))['then'](function(_0xccd888){if(_0xccd888){return _0xccd888[_0x65f6('0x5c')](_0x41e59a['query'][_0x65f6('0x5d')]);}})[_0x65f6('0x12')](respondWithStatusCode(_0x535558,null))[_0x65f6('0x1b')](handleError(_0x535558,null));};exports['addLogo']=function(_0x2c8938,_0xf1e6a1){_0x2c8938['body'][_0x65f6('0x5e')]=_0x2c8938[_0x65f6('0x5f')][_0x65f6('0x60')];return db['ChatWebsite'][_0x65f6('0x4f')]({'where':{'id':_0x2c8938[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0xf1e6a1,null))['then'](saveUpdates(_0x2c8938[_0x65f6('0x52')],null))['then'](respondWithResult(_0xf1e6a1,null))[_0x65f6('0x1b')](handleError(_0xf1e6a1,null));};exports[_0x65f6('0x61')]=function(_0x31ec61,_0x22be6e){_0x31ec61[_0x65f6('0x52')][_0x65f6('0x62')]=_0x31ec61['file'][_0x65f6('0x60')];return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x31ec61[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x22be6e,null))['then'](saveUpdates(_0x31ec61['body'],null))['then'](respondWithResult(_0x22be6e,null))[_0x65f6('0x1b')](handleError(_0x22be6e,null));};exports[_0x65f6('0x63')]=function(_0xcfc47a,_0x59b715){_0xcfc47a[_0x65f6('0x52')]['customerAvatar']=_0xcfc47a['file'][_0x65f6('0x60')];return db[_0x65f6('0x42')]['find']({'where':{'id':_0xcfc47a[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x59b715,null))[_0x65f6('0x12')](saveUpdates(_0xcfc47a[_0x65f6('0x52')],null))[_0x65f6('0x12')](respondWithResult(_0x59b715,null))[_0x65f6('0x1b')](handleError(_0x59b715,null));};exports[_0x65f6('0x64')]=function(_0x3291ac,_0x477f29){_0x3291ac[_0x65f6('0x52')][_0x65f6('0x65')]=_0x3291ac[_0x65f6('0x5f')]['filename'];return db[_0x65f6('0x42')]['find']({'where':{'id':_0x3291ac['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x477f29,null))[_0x65f6('0x12')](saveUpdates(_0x3291ac[_0x65f6('0x52')],null))[_0x65f6('0x12')](respondWithResult(_0x477f29,null))['catch'](handleError(_0x477f29,null));};exports[_0x65f6('0x66')]=function(_0x565b63,_0x490512){var _0x416ed4=path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x69'));var _0xd893ef={'where':{'id':_0x565b63[_0x65f6('0x46')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x5c8131=![];return require('../../config/license/util')[_0x65f6('0x6a')]()[_0x65f6('0x12')](function(_0x365044){if(_0x365044){_0x5c8131=_0x365044['custom'];}})[_0x65f6('0x12')](function(){return db['ChatWebsite']['find'](_0xd893ef);})[_0x65f6('0x12')](handleEntityNotFound(_0x490512,null))[_0x65f6('0x12')](function(_0x2dbed5){if(_0x2dbed5){if(!_[_0x65f6('0x6b')](_0x2dbed5[_0x65f6('0x5e')])){if(fs['existsSync'](path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x6c'),_0x2dbed5[_0x65f6('0x5e')]))&&_0x5c8131){_0x416ed4=path['join'](config[_0x65f6('0x68')],_0x65f6('0x6c'),_0x2dbed5[_0x65f6('0x5e')]);}}return _0x490512[_0x65f6('0x6d')](_0x416ed4);}})[_0x65f6('0x1b')](handleError(_0x490512,null));};exports[_0x65f6('0x6e')]=function(_0x2f9814,_0x8aab06){var _0x558410=path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x6f'));var _0x8adb47={'where':{'id':_0x2f9814[_0x65f6('0x46')]['id']},'attributes':['id',_0x65f6('0x62')],'raw':!![]};return db['ChatWebsite'][_0x65f6('0x4f')](_0x8adb47)[_0x65f6('0x12')](handleEntityNotFound(_0x8aab06,null))['then'](function(_0x34f1e6){if(_0x34f1e6){if(!_['isNil'](_0x34f1e6[_0x65f6('0x62')])){if(fs[_0x65f6('0x70')](path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x71'),_0x34f1e6['agentAvatar']))){_0x558410=path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x71'),_0x34f1e6[_0x65f6('0x62')]);}}return _0x8aab06[_0x65f6('0x6d')](_0x558410);}})['catch'](handleError(_0x8aab06,null));};exports['getCustomerAvatar']=function(_0x38006c,_0x22a9e7){var _0x2993ee=path[_0x65f6('0x67')](config['root'],'server/files/images/avatars/customer_avatar.png');var _0x534004={'where':{'id':_0x38006c[_0x65f6('0x46')]['id']},'attributes':['id',_0x65f6('0x72'),_0x65f6('0x73')],'raw':!![]};return db['ChatWebsite'][_0x65f6('0x4f')](_0x534004)[_0x65f6('0x12')](handleEntityNotFound(_0x22a9e7,null))[_0x65f6('0x12')](function(_0x18c6a8){if(_0x18c6a8){if(!_[_0x65f6('0x6b')](_0x18c6a8['customerAvatar'])){if(fs[_0x65f6('0x70')](path[_0x65f6('0x67')](config['root'],'server/files/images/avatars/',_0x18c6a8[_0x65f6('0x72')]))&&_0x18c6a8[_0x65f6('0x73')]){_0x2993ee=path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x71'),_0x18c6a8['customerAvatar']);}}return _0x22a9e7[_0x65f6('0x6d')](_0x2993ee);}})['catch'](handleError(_0x22a9e7,null));};exports[_0x65f6('0x74')]=function(_0x5d181a,_0x38fcc9){var _0x5cec52=path[_0x65f6('0x67')](config['root'],_0x65f6('0x75'));var _0x3b9aed={'where':{'id':_0x5d181a['params']['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0x65f6('0x42')][_0x65f6('0x4f')](_0x3b9aed)[_0x65f6('0x12')](handleEntityNotFound(_0x38fcc9,null))[_0x65f6('0x12')](function(_0x861892){if(_0x861892){if(!_[_0x65f6('0x6b')](_0x861892[_0x65f6('0x65')])){if(fs[_0x65f6('0x70')](path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x71'),_0x861892[_0x65f6('0x65')]))){_0x5cec52=path[_0x65f6('0x67')](config[_0x65f6('0x68')],_0x65f6('0x71'),_0x861892[_0x65f6('0x65')]);}}return _0x38fcc9[_0x65f6('0x6d')](_0x5cec52);}})['catch'](handleError(_0x38fcc9,null));};exports[_0x65f6('0x76')]=function(_0x91d7bf,_0x11bdf3){var _0x16e246=require(_0x65f6('0x77'));var _0x1dbf36=new _0x16e246();var _0x849936=_0x1dbf36[_0x65f6('0x78')](_0x91d7bf[_0x65f6('0x79')]['user-agent'])[_0x65f6('0x7a')]();var _0x585e99={'body':_0x91d7bf[_0x65f6('0x52')],'channel':_0x65f6('0x7b')};var _0x5c2f2c=[];var _0x38db52=[];var _0x39dedf={};var _0x5c7462=![];return db[_0x65f6('0x7c')][_0x65f6('0x53')]()[_0x65f6('0x12')](function(_0x207831){if(!_0x207831){throw new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))]('no\x20available\x20attributes');}_0x5c2f2c=_[_0x65f6('0x7f')](_[_0x65f6('0x48')](_0x207831),[_0x65f6('0x80'),_0x65f6('0x81')]);_0x38db52=_['difference'](_['keys'](_0x207831),['createdAt',_0x65f6('0x81'),_0x65f6('0x82'),_0x65f6('0x83')]);if(_0x91d7bf[_0x65f6('0x52')]['id']){delete _0x91d7bf[_0x65f6('0x52')]['id'];}if(_['isNil'](_0x91d7bf['body'][_0x65f6('0x84')])){throw new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))]('from\x20is\x20mandatory');}if(_['isNil'](_0x91d7bf[_0x65f6('0x52')]['body'])||_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x52')]===''){throw new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))](_0x65f6('0x85'));}if(_[_0x65f6('0x6b')](_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x86')])){throw new db[(_0x65f6('0x7d'))]['ValidationError'](_0x65f6('0x87')+_0x38db52);}if(!_[_0x65f6('0x88')](_0x38db52,_0x91d7bf['body'][_0x65f6('0x86')])){throw new db['Sequelize'][(_0x65f6('0x7e'))](_0x65f6('0x89')+_0x38db52);}_0x39dedf[_0x91d7bf[_0x65f6('0x52')]['mapKey']]=_0x91d7bf[_0x65f6('0x52')]['from'];})['then'](function(){return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x91d7bf['params']['id']},'include':[{'model':db[_0x65f6('0x8a')],'as':'List','include':[{'model':db[_0x65f6('0x7c')],'as':_0x65f6('0x8b'),'where':_0x39dedf,'limit':0x1,'order':[[_0x65f6('0x81'),_0x65f6('0x8c')]]}]},{'model':db[_0x65f6('0x8d')],'as':_0x65f6('0x8e')}]});})[_0x65f6('0x12')](handleEntityNotFound(_0x11bdf3,null))[_0x65f6('0x12')](function(_0x5ed6ff){if(_0x5ed6ff&&_0x5ed6ff[_0x65f6('0x8f')]){_0x585e99[_0x65f6('0x90')]=_0x5ed6ff;_0x585e99[_0x65f6('0x91')]=_0x5ed6ff[_0x65f6('0x8e')];_0x585e99[_0x65f6('0x92')]=_0x5ed6ff['List'];_0x585e99[_0x65f6('0x91')]=_['orderBy'](_0x585e99[_0x65f6('0x91')],['priority'],[_0x65f6('0x93')]);if(_0x585e99[_0x65f6('0x90')][_0x65f6('0x8e')]){delete _0x585e99[_0x65f6('0x90')][_0x65f6('0x8e')];}if(_0x585e99[_0x65f6('0x90')][_0x65f6('0x8f')]&&_0x585e99[_0x65f6('0x90')][_0x65f6('0x8f')][_0x65f6('0x8b')][_0x65f6('0x37')]){return _0x585e99[_0x65f6('0x90')][_0x65f6('0x8f')][_0x65f6('0x8b')][0x0];}var _0x37fa08=_[_0x65f6('0x9')](_0x91d7bf[_0x65f6('0x52')],{'firstName':_0x91d7bf['body'][_0x65f6('0x84')],'ListId':_0x5ed6ff['ListId']});_0x37fa08[_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x86')]]=_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x84')];return db[_0x65f6('0x7c')][_0x65f6('0x4b')](_0x37fa08,{'fields':_0x5c2f2c,'raw':!![]});}})['then'](handleEntityNotFound(_0x11bdf3,null))[_0x65f6('0x12')](function(_0x1ac0bd){_0x585e99[_0x65f6('0x94')]=_0x1ac0bd;var _0x359734=_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x95')];if(_0x91d7bf[_0x65f6('0x79')][_0x65f6('0x96')]){_0x359734=_0x91d7bf[_0x65f6('0x79')][_0x65f6('0x96')];}else if(_0x91d7bf[_0x65f6('0x79')]['x-forwarded-for']){_0x359734=_['first'](_0x91d7bf[_0x65f6('0x79')][_0x65f6('0x97')][_0x65f6('0x98')](','));}if(_0x1ac0bd){var _0x179fed={'ContactId':_0x1ac0bd['id'],'ChatWebsiteId':_0x91d7bf[_0x65f6('0x46')]['id'],'from':(_0x1ac0bd[_0x65f6('0x99')]||'')+'\x20'+(_0x1ac0bd[_0x65f6('0x9a')]||''),'customerIp':_0x359734,'customerPort':_0x91d7bf['headers'][_0x65f6('0x9b')]?_0x91d7bf[_0x65f6('0x79')][_0x65f6('0x9b')]:null,'referer':_0x91d7bf[_0x65f6('0x52')][_0x65f6('0x9c')],'browserName':_0x849936[_0x65f6('0x9d')][_0x65f6('0x2c')]&&_0x849936[_0x65f6('0x9d')][_0x65f6('0x9e')]?util[_0x65f6('0x9f')](_0x65f6('0xa0'),_0x849936[_0x65f6('0x9d')][_0x65f6('0x2c')],_0x849936['browser']['version']):'unknown','browserVersion':_0x849936[_0x65f6('0x9d')][_0x65f6('0x9e')]||_0x65f6('0xa1'),'osName':util['format'](_0x65f6('0xa0'),_0x849936['os'][_0x65f6('0x2c')],_0x849936['os'][_0x65f6('0x9e')]),'osVersion':_0x849936['os']['version'],'deviceModel':_0x849936[_0x65f6('0xa2')][_0x65f6('0x31')]&&_0x849936['device'][_0x65f6('0xa3')]?util[_0x65f6('0x9f')](_0x65f6('0xa4'),_0x849936['device'][_0x65f6('0x31')],_0x849936[_0x65f6('0xa2')][_0x65f6('0xa3')],_0x849936[_0x65f6('0xa2')][_0x65f6('0x30')]):null,'deviceVendor':_0x849936[_0x65f6('0xa2')][_0x65f6('0xa3')],'deviceType':_0x849936[_0x65f6('0xa2')][_0x65f6('0x30')],'formData':JSON[_0x65f6('0xa5')](_0x91d7bf['body'])};var _0x43c89e={'ChatWebsiteId':_0x91d7bf[_0x65f6('0x46')]['id'],'closed':![]};if(_0x91d7bf[_0x65f6('0x52')]['threadId']){_0x43c89e['threadId']=_0x91d7bf[_0x65f6('0x52')]['threadId'];return db[_0x65f6('0xa6')][_0x65f6('0x4f')]({'where':_0x43c89e})[_0x65f6('0x12')](function(_0xbf4abe){if(_0xbf4abe){return[_0xbf4abe,![]];}_0x179fed[_0x65f6('0xa7')]=_0x91d7bf['body'][_0x65f6('0xa7')];_0x179fed[_0x65f6('0xa8')]=_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xa8')];return db['ChatInteraction'][_0x65f6('0x4b')](_0x179fed)[_0x65f6('0x12')](function(_0x11d3fb){return[_0x11d3fb,!![]];});});}_0x43c89e[_0x65f6('0xa9')]=_0x1ac0bd['id'];if(_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xaa')]&&_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xaa')]['id']){_0x43c89e['id']=_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xaa')]['id'];return db[_0x65f6('0xa6')][_0x65f6('0x4f')]({'where':_0x43c89e})[_0x65f6('0x12')](function(_0x31e87d){if(_0x31e87d){return[_0x31e87d,![]];}return db[_0x65f6('0xa6')]['create'](_0x179fed)[_0x65f6('0x12')](function(_0x1cca16){return[_0x1cca16,!![]];});});}return db['ChatInteraction']['create'](_0x179fed)[_0x65f6('0x12')](function(_0x7c1efc){return[_0x7c1efc,!![]];});}})[_0x65f6('0xab')](function(_0x2bcdec,_0x21b9ba){if(_0x2bcdec){_0x5c7462=_0x21b9ba;if(!_0x21b9ba){var _0x33e01f={'from':(_0x585e99[_0x65f6('0x94')]['firstName']||'')+'\x20'+(_0x585e99[_0x65f6('0x94')]['lastName']||'')};if(_0x91d7bf['body'][_0x65f6('0xa7')]&&_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xac')]&&_0x91d7bf[_0x65f6('0x52')]['threadId']!=_0x91d7bf['body'][_0x65f6('0xac')]){_0x33e01f[_0x65f6('0xa7')]=_0x91d7bf['body']['messageId'];}return _0x2bcdec['update'](_0x33e01f);}else{return _0x2bcdec;}}})[_0x65f6('0x12')](function(_0x42dc3a){_0x585e99[_0x65f6('0xaa')]=_0x42dc3a[_0x65f6('0x27')]({'plain':!![]});_0x585e99[_0x65f6('0xaa')]['created']=_0x5c7462;if(_0x585e99['interaction'][_0x65f6('0xad')]){if(_0x585e99[_0x65f6('0x90')][_0x65f6('0xae')]){_0x585e99['applications']['push']({'id':0x0,'priority':_0x585e99[_0x65f6('0x91')][_0x65f6('0x37')]+0x1,'app':'close','appdata':_0x65f6('0xaf'),'interval':_0x65f6('0xb0')});}}return db['ChatMessage'][_0x65f6('0x4b')]({'body':_0x91d7bf['body'][_0x65f6('0x52')],'ChatWebsiteId':_0x91d7bf[_0x65f6('0x46')]['id'],'ChatInteractionId':_0x42dc3a['id'],'direction':'in','ContactId':_0x585e99[_0x65f6('0x94')]['id'],'AttachmentId':_0x91d7bf[_0x65f6('0x52')][_0x65f6('0xb1')]});})[_0x65f6('0x12')](function(_0x5ca33e){_0x585e99[_0x65f6('0x19')]=_0x5ca33e;if(_0x585e99[_0x65f6('0xaa')]['UserId']){return db[_0x65f6('0xb2')][_0x65f6('0x4f')]({'attributes':['id',_0x65f6('0x2c')],'where':{'id':_0x585e99['interaction']['UserId']}})[_0x65f6('0x12')](function(_0x2229ae){if(_0x2229ae){_0x585e99[_0x65f6('0x91')][_0x65f6('0xb3')]({'id':0x0,'priority':0x0,'app':_0x65f6('0xb4'),'appdata':_0x2229ae[_0x65f6('0x2c')]+','+(_0x585e99['account']['waitForTheAssignedAgent']||0xa),'interval':_0x65f6('0xb0')});_0x585e99[_0x65f6('0xb5')]=!![];}return respondWithRpcPromise(_0x65f6('0xb6'),_0x65f6('0xb7'),_0x585e99);});}return respondWithRpcPromise(_0x65f6('0xb6'),_0x65f6('0xb7'),_0x585e99);})[_0x65f6('0x12')](function(_0x4146df){respondWithRpcPromise(_0x65f6('0xb8'),_0x65f6('0xb8'),{'event':_0x65f6('0x76'),'message':_0x4146df},client9002);return _0x4146df;})[_0x65f6('0x12')](respondWithResult(_0x11bdf3,null))['catch'](handleError(_0x11bdf3,null));};exports[_0x65f6('0xb9')]=function(_0x3d2328,_0x21a8c9){var _0x101050,_0x3be8bc,_0x385d13;var _0xd00f2f=[];var _0x868a4f={};var _0x2820b3=_0x3d2328[_0x65f6('0xba')]||[];var _0x591fcd=[];var _0x4dfda4;return db[_0x65f6('0x7c')][_0x65f6('0x53')]()['then'](function(_0x1db7e4){if(!_0x1db7e4){throw new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))]('no\x20available\x20attributes');}_0xd00f2f=_['difference'](_[_0x65f6('0x48')](_0x1db7e4),[_0x65f6('0x80'),_0x65f6('0x81'),_0x65f6('0x82'),_0x65f6('0x83')]);if(_0x3d2328[_0x65f6('0x52')]['id']){delete _0x3d2328[_0x65f6('0x52')]['id'];}if(_[_0x65f6('0x6b')](_0x3d2328[_0x65f6('0x52')][_0x65f6('0x84')])){throw _0x21a8c9[_0x65f6('0x1d')](0x1f4)[_0x65f6('0xbb')](new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))](_0x65f6('0xbc')));}if(_[_0x65f6('0x6b')](_0x3d2328[_0x65f6('0x52')][_0x65f6('0x52')])||_0x3d2328['body'][_0x65f6('0x52')]===''){throw _0x21a8c9[_0x65f6('0x1d')](0x1f4)[_0x65f6('0xbb')](new db[(_0x65f6('0x7d'))]['ValidationError'](_0x65f6('0x85')));}if(_['isNil'](_0x3d2328[_0x65f6('0x52')][_0x65f6('0xbd')])){throw _0x21a8c9[_0x65f6('0x1d')](0x1f4)[_0x65f6('0xbb')](new db[(_0x65f6('0x7d'))]['ValidationError'](_0x65f6('0xbe')+_0xd00f2f));}if(!_['includes'](_0xd00f2f,_0x3d2328['body']['mapKeyOffline'])){throw _0x21a8c9[_0x65f6('0x1d')](0x1f4)['send'](new db[(_0x65f6('0x7d'))][(_0x65f6('0x7e'))](_0x65f6('0xbf')+_0xd00f2f));}_0x868a4f[_0x3d2328[_0x65f6('0x52')][_0x65f6('0xbd')]]=_0x3d2328[_0x65f6('0x52')][_0x65f6('0x84')];})[_0x65f6('0x12')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x3d2328[_0x65f6('0x46')]['id']},'include':[{'model':db[_0x65f6('0x8a')],'as':'List'},{'model':db[_0x65f6('0xc0')],'as':'MailAccount'}]});})['then'](handleEntityNotFound(_0x21a8c9,null))[_0x65f6('0x12')](function(_0x74f19d){if(_0x74f19d&&_0x74f19d[_0x65f6('0x8f')]){_0x3be8bc=_0x74f19d;var _0x1050c7=_[_0x65f6('0x9')](_0x3d2328['body'],{'firstName':_0x3d2328[_0x65f6('0x52')]['from'],'phone':_0x3d2328[_0x65f6('0x52')]['from'],'ListId':_0x74f19d['ListId']});_0x1050c7[_0x3d2328[_0x65f6('0x52')][_0x65f6('0xbd')]]=_0x3d2328[_0x65f6('0x52')][_0x65f6('0x84')];return db[_0x65f6('0x7c')][_0x65f6('0xc1')]({'where':_0x868a4f,'defaults':_0x1050c7});}})[_0x65f6('0xab')](function(_0x2ff0f5){if(_0x2ff0f5){_0x385d13=_0x2ff0f5;var _0x504520=fs[_0x65f6('0xc2')](path['join'](config[_0x65f6('0x68')],_0x65f6('0xc3')),_0x65f6('0xc4'));var _0x588b38=ejs[_0x65f6('0xc5')](_0x504520,{'body':_[_0x65f6('0xc6')](_0x3d2328['body'][_0x65f6('0x52')]),'bodyTitle':_0x3be8bc[_0x65f6('0xc7')]});return db[_0x65f6('0xc8')][_0x65f6('0x4b')]({'body':_0x588b38,'plainBody':htmlToText[_0x65f6('0xc9')](_0x588b38),'ContactId':_0x2ff0f5['id'],'ChatWebsiteId':_0x3be8bc['id']});}})['then'](function(_0x428a19){_0x4dfda4=_0x428a19;if(_0x2820b3[_0x65f6('0x37')]){var _0x410442=_0x2820b3['map'](function(_0x4c1149){return{'name':_0x4c1149[_0x65f6('0xca')],'basename':_0x4c1149[_0x65f6('0x60')],'type':_0x4c1149[_0x65f6('0xcb')],'ChatOfflineMessageId':_0x428a19['id']};});_0x591fcd=_0x410442[_0x65f6('0x2f')](_0x3d1df9=>{var _0x5b4033={'filename':_0x3d1df9['name'],'path':path['join'](config[_0x65f6('0x68')],_0x65f6('0xcc'),'files','attachments','offline-chat',_0x3d1df9[_0x65f6('0xcd')])};return _0x5b4033;});if(!_0x3be8bc[_0x65f6('0xce')]){return db[_0x65f6('0xcf')][_0x65f6('0xd0')](function(_0x1be461){return db[_0x65f6('0xd1')][_0x65f6('0xd2')](_0x410442,{'transaction':_0x1be461});});}}})[_0x65f6('0x12')](function(){if(_0x4dfda4){_0x101050=_0x4dfda4;return db[_0x65f6('0xc0')][_0x65f6('0xd3')]({'where':{'active':!![]},'include':[{'model':db[_0x65f6('0xd4')],'as':_0x65f6('0xd5'),'raw':!![]}]});}})[_0x65f6('0x12')](function(_0x62136d){if(_0x62136d&&_0x62136d[_0x65f6('0xd5')]&&_0x3be8bc['forwardOffline']&&_0x3be8bc[_0x65f6('0xd6')]){var _0x1979c2={'tls':{'rejectUnauthorized':![]}};if(_0x62136d[_0x65f6('0xd5')][_0x65f6('0xd7')]){_0x1979c2[_0x65f6('0xd7')]=_0x62136d[_0x65f6('0xd5')]['service'];}else{_0x1979c2[_0x65f6('0xd8')]=_0x62136d[_0x65f6('0xd5')]['host'];_0x1979c2['port']=_0x62136d[_0x65f6('0xd5')]['port'];_0x1979c2['secure']=_0x62136d[_0x65f6('0xd5')][_0x65f6('0xd9')];}if(_0x62136d['Smtp'][_0x65f6('0xda')]){_0x1979c2[_0x65f6('0xdb')]={'user':_0x62136d['Smtp'][_0x65f6('0x4c')],'pass':_0x62136d[_0x65f6('0xd5')][_0x65f6('0xdc')]};}return respondWithRpcPromise(_0x65f6('0xdd'),_0x65f6('0xde'),{'account':_0x1979c2,'message':{'from':util[_0x65f6('0x9f')](_0x65f6('0xdf'),_0x62136d[_0x65f6('0x2c')],_0x62136d[_0x65f6('0xe0')]||_0x62136d['Smtp'][_0x65f6('0x4c')]),'to':_0x3be8bc[_0x65f6('0xd6')],'subject':_0x3be8bc[_0x65f6('0xe1')],'html':_0x101050[_0x65f6('0x52')],'attachments':_0x591fcd}},client9003)[_0x65f6('0x12')](function(){return _0x101050;})[_0x65f6('0x1b')](function(_0x4e4726){console[_0x65f6('0x17')](_0x4e4726);});}})['then'](function(){if(_0x3be8bc&&_0x3be8bc['openNewInteraction']&&_0x3be8bc['MailAccountId']){var _0x3f770a=[];if(_0x2820b3['length']){_0x3f770a=_0x2820b3[_0x65f6('0x2f')](function(_0x408f37){return{'name':_0x408f37[_0x65f6('0xca')],'basename':_0x408f37[_0x65f6('0x60')],'type':_0x408f37[_0x65f6('0xcb')],'ChatOfflineMessageId':_0x4dfda4['id']};});}var _0x355476;if(!_[_0x65f6('0x6b')](_0x3be8bc['subjectOffline'])){var _0x5db63d=_[_0x65f6('0x2f')](_0x3d2328[_0x65f6('0x52')],function(_0x11edd6){return _0x11edd6;});var _0x4bb32e=_[_0x65f6('0xe2')](_0x5db63d)[0x0];var _0x5d8c8e=_[_0x65f6('0xe3')](_0x4bb32e,function(_0x2b1dfc){return _0x2b1dfc;});_0x355476=_0x5d8c8e[0x1][_0x3be8bc[_0x65f6('0xe4')]];}var _0x4b920a={'from':_0x385d13[_0x65f6('0xe0')],'firstName':_0x385d13[_0x65f6('0x99')],'lastName':_0x385d13[_0x65f6('0x9a')],'mapKey':_0x65f6('0xe0'),'message':{'from':_0x385d13['email'],'to':_0x3be8bc['MailAccount'][_0x65f6('0xe0')],'cc':'','subject':_['isNil'](_0x355476)?_0x3be8bc[_0x65f6('0xe1')]:_0x355476,'messageId':'','sentAt':new Date(),'attach':_0x3f770a['length'],'attachments':_0x3f770a,'originChannel':_0x65f6('0xe5'),'ChatWebsiteId':_0x3be8bc['id'],'ChatOfflineMessageId':_0x101050['id'],'originTo':_0x3be8bc[_0x65f6('0xc0')][_0x65f6('0xe0')]},'body':_0x101050['body']};var _0x3225b6={'account':{'id':_0x3be8bc[_0x65f6('0xe6')]},'body':_0x4b920a,'log':_0x65f6('0xe7')};return respondWithRpcPromise(_0x65f6('0xe7'),_0x65f6('0xe8'),_0x3225b6,client9001)[_0x65f6('0x12')](function(){return _0x101050;})[_0x65f6('0x1b')](function(_0x4e40d4){console[_0x65f6('0x17')](_0x4e40d4);});}return;})[_0x65f6('0x12')](function(){if(_0x101050){return _0x101050;}})[_0x65f6('0x12')](respondWithResult(_0x21a8c9,null))[_0x65f6('0x1b')](function(_0x72ac02){console[_0x65f6('0x17')](_0x65f6('0x1b'),_0x72ac02);for(var _0xe52598 of _0x2820b3){var _0x1790e4=path['join'](config[_0x65f6('0x68')],'server',_0x65f6('0xba'),_0x65f6('0xe9'),_0x65f6('0xea'),_0xe52598[_0x65f6('0x60')]);fs_extra[_0x65f6('0xeb')](_0x1790e4)[_0x65f6('0x1b')](function(_0x4684ab){console[_0x65f6('0x17')](_0x65f6('0xec'),_0x1790e4,_0x4684ab);});}});};exports[_0x65f6('0xed')]=function(_0x148993,_0x38e6ff){return db[_0x65f6('0xa6')][_0x65f6('0x4f')]({'where':{'id':_0x148993[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x38e6ff,null))[_0x65f6('0x12')](function(_0x560dbb){if(_0x560dbb){return _0x560dbb[_0x65f6('0xed')](_0x148993[_0x65f6('0x52')]['ids'],_[_0x65f6('0xee')](_0x148993[_0x65f6('0x52')],[_0x65f6('0x5d'),'id'])||{});}})[_0x65f6('0x12')](respondWithResult(_0x38e6ff,null))[_0x65f6('0x1b')](handleError(_0x38e6ff,null));};exports[_0x65f6('0xef')]=function(_0x4adb7a,_0x492c89){var _0x409127={'raw':![],'where':{}};var _0x2c0165={};var _0xd11998={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x65f6('0xd3')]({'where':{'id':_0x4adb7a['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x492c89,null))[_0x65f6('0x12')](function(_0x1c8b2e){if(_0x1c8b2e){_0x2c0165[_0x65f6('0x31')]=_['keys'](db[_0x65f6('0xa6')]['rawAttributes']);_0x2c0165[_0x65f6('0x32')]=_[_0x65f6('0x48')](_0x4adb7a[_0x65f6('0x32')]);_0x2c0165['filters']=_[_0x65f6('0x34')](_0x2c0165['model'],_0x2c0165['query']);_0x409127[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x2c0165[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x4adb7a[_0x65f6('0x32')][_0x65f6('0x36')]));_0x409127[_0x65f6('0x35')]=_0x409127[_0x65f6('0x35')][_0x65f6('0x37')]?_0x409127[_0x65f6('0x35')]:_0x2c0165[_0x65f6('0x31')];if(!_0x4adb7a['query'][_0x65f6('0x38')]('nolimit')){_0x409127[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x4adb7a['query'][_0x65f6('0x1e')]);_0x409127[_0x65f6('0x21')]=qs['offset'](_0x4adb7a['query'][_0x65f6('0x21')]);}_0x409127['order']=qs['sort'](_0x4adb7a[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x409127[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x4adb7a[_0x65f6('0x32')],_0x2c0165[_0x65f6('0x33')]));_0x409127[_0x65f6('0x3c')][_0x65f6('0x54')]=_0x1c8b2e['id'];if(_0x4adb7a['query'][_0x65f6('0x3e')]){_0x409127[_0x65f6('0x3c')]=_['merge'](_0x409127[_0x65f6('0x3c')],{'$or':_[_0x65f6('0x2f')](_0x409127[_0x65f6('0x35')],function(_0xcf934){var _0x73732f={};_0x73732f[_0xcf934]={'$like':'%'+_0x4adb7a[_0x65f6('0x32')]['filter']+'%'};return _0x73732f;})});}_0x409127=_['merge']({},_0x409127,_0x4adb7a[_0x65f6('0x41')]);return db[_0x65f6('0xa6')][_0x65f6('0x20')]({'where':_0x409127[_0x65f6('0x3c')]})[_0x65f6('0x12')](function(_0x4cee07){_0xd11998[_0x65f6('0x20')]=_0x4cee07;if(_0x4adb7a[_0x65f6('0x32')][_0x65f6('0x4a')]){_0x409127[_0x65f6('0x43')]=[{'model':db[_0x65f6('0x7c')],'as':_0x65f6('0xf0'),'required':![]},{'model':db[_0x65f6('0xb2')],'as':_0x65f6('0xf1'),'attributes':[_0x65f6('0x2c'),_0x65f6('0xf2'),_0x65f6('0xf3')],'required':![]},{'model':db['Tag'],'as':_0x65f6('0xf4'),'attributes':['id',_0x65f6('0x2c'),'color'],'where':_0x4adb7a['query'][_0x65f6('0xf5')]?{'id':_0x4adb7a[_0x65f6('0x32')][_0x65f6('0xf5')]}:undefined,'required':_0x4adb7a['query'][_0x65f6('0xf5')]?!![]:![]}];}return db[_0x65f6('0xa6')][_0x65f6('0x5b')](_0x409127);})[_0x65f6('0x12')](function(_0xf29979){_0xd11998[_0x65f6('0x44')]=_0xf29979;return _0xd11998;});}})[_0x65f6('0x12')](respondWithFilteredResult(_0x492c89,_0x409127))['catch'](handleError(_0x492c89,null));};function iftimePromise(_0xacdf06,_0x58f7a8){return respondWithRpcPromise(_0x65f6('0xf6'),_0x65f6('0xf7'),{'command':_0x58f7a8[_0x65f6('0xf8')]?util[_0x65f6('0x9f')](_0x65f6('0xf9'),_0xacdf06[_0x65f6('0xfa')],_0x58f7a8['timezone']):util[_0x65f6('0x9f')]('iftime\x20%s',_0xacdf06[_0x65f6('0xfa')])},client9002)['then'](function(_0x32829e){var _0x5258a4=_0x32829e&&_0x32829e[_0x65f6('0xfb')](_0x65f6('0xfc'))>=0x0?!![]:![];logger[_0x65f6('0x13')](_0x65f6('0xfd'),_0x58f7a8['id'],_0xacdf06['id'],_0xacdf06['interval'],_0x5258a4?_0x65f6('0xfe'):_0x65f6('0xff'),_0x58f7a8[_0x65f6('0xf8')]?_0x58f7a8[_0x65f6('0xf8')]:_0x65f6('0x100'));return _0x5258a4;})[_0x65f6('0x1b')](function(_0xd06566){logger[_0x65f6('0x17')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x58f7a8['id'],_0xacdf06['id'],_0xacdf06['interval'],util[_0x65f6('0x101')](_0xd06566,{'showHidden':![],'depth':null}),_0x58f7a8[_0x65f6('0xf8')]?_0x58f7a8[_0x65f6('0xf8')]:_0x65f6('0x100'));return![];});}exports['getSnippet']=function(_0x1a25ae,_0x1e1498){var _0x4c63f9=0x0;var _0x13f4a5=0x0;var _0x4315c1=![];var _0x141d13;var _0x575f14;return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0x1a25ae['params']['id']},'include':[{'model':db['Interval'],'as':'Interval','include':[{'model':db[_0x65f6('0x102')],'as':_0x65f6('0x103'),'attributes':['id',_0x65f6('0xfa')],'raw':!![]}]}]})[_0x65f6('0x12')](handleEntityNotFound(_0x1e1498,null))[_0x65f6('0x12')](function(_0x39bea9){if(_0x39bea9){_0x141d13=_0x39bea9;return _0x39bea9[_0x65f6('0x104')]({'raw':!![]});}})[_0x65f6('0x12')](function(_0x270944){if(_0x141d13){if(_0x270944){_0x575f14=_0x270944;}}return require(_0x65f6('0x105'))[_0x65f6('0x6a')]();})[_0x65f6('0x12')](function(_0x2a0aab){if(_0x2a0aab){_0x13f4a5=_0x2a0aab[_0x65f6('0x106')];_0x4315c1=_0x2a0aab[_0x65f6('0x107')];}})[_0x65f6('0x12')](function(){return db[_0x65f6('0xa6')][_0x65f6('0x20')]({'where':{'closed':![]}});})['then'](function(_0x4345af){_0x4c63f9=_0x4345af;if(_0x13f4a5&&_0x4345af>_0x13f4a5){return db[_0x65f6('0x108')]['findOne']({'where':{'id':0x1}})['then'](function(_0x23709a){if(_0x23709a){_0x23709a[_0x65f6('0x109')](_0x65f6('0x10a'));}});}})[_0x65f6('0x12')](function(){if(_0x141d13['Interval']&&_0x141d13['Interval'][_0x65f6('0x103')]){var _0x5dc205=[];for(var _0xd2313b=0x0;_0xd2313b<_0x141d13[_0x65f6('0x102')]['Intervals']['length'];_0xd2313b++){var _0x408e74=_0x141d13[_0x65f6('0x102')][_0x65f6('0x103')][_0xd2313b][_0x65f6('0x27')]({'plain':!![]});_0x5dc205['push'](iftimePromise(_0x408e74,_0x141d13));}return BPromise[_0x65f6('0x10b')](_0x5dc205)['then'](function(_0x34542c){return _[_0x65f6('0x10c')](_0x34542c);});}else{return!![];}})[_0x65f6('0x12')](function(_0x2ab4ac){var _0x4bc08e=fs[_0x65f6('0xc2')](path['join'](config[_0x65f6('0x68')],'server/files/chat/iframe.ejs'),'utf8');var _0x38de54={'remote':_0x141d13['remote'],'query':querystring[_0x65f6('0xa5')](_[_0x65f6('0x3f')](_0x141d13[_0x65f6('0x27')]({'plain':!![]}),{'customerIp':_0x1a25ae[_0x65f6('0x79')][_0x65f6('0x97')]||_0x1a25ae[_0x65f6('0x79')][_0x65f6('0x10d')]||_0x1a25ae[_0x65f6('0x10e')][_0x65f6('0x10f')]||_0x1a25ae['ip'],'referer':_0x1a25ae['headers'][_0x65f6('0x9c')],'openedInteractions':_0x4c63f9,'maxInteractions':_0x13f4a5,'virtual':_0x4315c1[_0x65f6('0x106')],'online':_0x2ab4ac,'custom':_0x4315c1}))[_0x65f6('0x110')](/'/g,'\x5c\x27')};_0x1e1498[_0x65f6('0xbb')](ejs['render'](Mustache[_0x65f6('0xc5')](_0x4bc08e,_0x38de54),{'proactiveActions':_0x575f14,'alignment':_0x141d13[_0x65f6('0x111')],'verticalAlignment':_0x141d13['verticalAlignment'],'div_color':_0x141d13[_0x65f6('0x112')],'labelText':_0x141d13[_0x65f6('0x113')],'text_color':_0x141d13[_0x65f6('0x114')],'button_color':_0x141d13[_0x65f6('0x115')],'background_color':_0x141d13[_0x65f6('0x116')]}));})[_0x65f6('0x1b')](handleError(_0x1e1498,null));};exports[_0x65f6('0x117')]=function(_0x112db7,_0x313634){var _0x1779de=_0x112db7[_0x65f6('0x46')]['id'];var _0x4b1ec2=_0x112db7[_0x65f6('0x52')];var _0x533902=0xc8;var _0x3bee71=null;return db['sequelize'][_0x65f6('0xd0')]({'isolationLevel':db[_0x65f6('0xcf')][_0x65f6('0x118')]['ISOLATION_LEVELS'][_0x65f6('0x119')]},function(_0x34ec6b){return db['ChatWebsite'][_0x65f6('0xd3')]({'where':{'id':_0x1779de},'transaction':_0x34ec6b})[_0x65f6('0x12')](function(_0xff9e69){if(_0xff9e69){return db['ChatApplication']['destroy']({'where':{'ChatWebsiteId':_0x1779de},'transaction':_0x34ec6b})['then'](function(){var _0x4eec1f=_[_0x65f6('0x2f')](_0x4b1ec2,function(_0x14417a){_0x14417a[_0x65f6('0x54')]=_0x1779de;return _0x14417a;});return db[_0x65f6('0x8d')][_0x65f6('0xd2')](_0x4eec1f,{'transaction':_0x34ec6b});});}else{_0x533902=0x194;_0x3bee71=[];}});})[_0x65f6('0x12')](function(){if(_0x533902!==0x194){return db[_0x65f6('0x8d')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x1779de},'order':_0x65f6('0x11a')})[_0x65f6('0x12')](function(_0x212333){_0x3bee71=_0x212333;});}})[_0x65f6('0x1b')](function(_0x4dbf35){_0x533902=0x1f4;logger[_0x65f6('0x17')](_0x4dbf35['stack']);if(_0x4dbf35[_0x65f6('0x2c')]){delete _0x4dbf35[_0x65f6('0x2c')];}_0x3bee71=_0x4dbf35;})['finally'](function(){if(_0x3bee71===null){_0x313634['sendStatus'](_0x533902);}else{if(_0x533902===0x1f4){_0x313634[_0x65f6('0x1d')](_0x533902)[_0x65f6('0xbb')](_0x3bee71);}else{_0x313634['status'](_0x533902)['json'](_0x3bee71);}}});};exports[_0x65f6('0x11b')]=function(_0x41ee46,_0xa54e78){var _0x31a57d={};var _0x3177f6={};var _0x142593;var _0x2d8fcc;return db[_0x65f6('0x42')][_0x65f6('0xd3')]({'where':{'id':_0x41ee46[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0xa54e78,null))[_0x65f6('0x12')](function(_0x1556ab){if(_0x1556ab){_0x142593=_0x1556ab;_0x3177f6[_0x65f6('0x31')]=_[_0x65f6('0x48')](db[_0x65f6('0x8d')]['rawAttributes']);_0x3177f6['query']=_[_0x65f6('0x48')](_0x41ee46[_0x65f6('0x32')]);_0x3177f6[_0x65f6('0x33')]=_[_0x65f6('0x34')](_0x3177f6[_0x65f6('0x31')],_0x3177f6[_0x65f6('0x32')]);_0x31a57d[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x3177f6[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x41ee46['query'][_0x65f6('0x36')]));_0x31a57d['attributes']=_0x31a57d['attributes'][_0x65f6('0x37')]?_0x31a57d[_0x65f6('0x35')]:_0x3177f6[_0x65f6('0x31')];_0x31a57d[_0x65f6('0x3a')]=qs['sort'](_0x41ee46[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x31a57d[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x41ee46[_0x65f6('0x32')],_0x3177f6[_0x65f6('0x33')]));if(_0x41ee46[_0x65f6('0x32')][_0x65f6('0x3e')]){_0x31a57d[_0x65f6('0x3c')]=_['merge'](_0x31a57d['where'],{'$or':_[_0x65f6('0x2f')](_0x31a57d[_0x65f6('0x35')],function(_0x457fa8){var _0x15f247={};_0x15f247[_0x457fa8]={'$like':'%'+_0x41ee46[_0x65f6('0x32')][_0x65f6('0x3e')]+'%'};return _0x15f247;})});}_0x31a57d=_[_0x65f6('0x3f')]({},_0x31a57d,_0x41ee46[_0x65f6('0x41')]);return _0x142593['getApplications'](_0x31a57d);}})['then'](function(_0x1ebe7e){if(_0x1ebe7e){_0x2d8fcc=_0x1ebe7e[_0x65f6('0x37')];if(!_0x41ee46['query'][_0x65f6('0x38')](_0x65f6('0x39'))){_0x31a57d[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x41ee46[_0x65f6('0x32')][_0x65f6('0x1e')]);_0x31a57d['offset']=qs[_0x65f6('0x21')](_0x41ee46[_0x65f6('0x32')]['offset']);}return _0x142593['getApplications'](_0x31a57d);}})[_0x65f6('0x12')](function(_0x3743eb){if(_0x3743eb){return _0x3743eb?{'count':_0x2d8fcc,'rows':_0x3743eb}:null;}})[_0x65f6('0x12')](respondWithResult(_0xa54e78,null))[_0x65f6('0x1b')](handleError(_0xa54e78,null));};exports[_0x65f6('0x11c')]=function(_0x3dd349,_0x4c7b0a){return db['chatProactiveAction'][_0x65f6('0x4f')]({'where':{'id':_0x3dd349[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x4c7b0a,null))['then'](function(_0x25684b){if(_0x25684b){return _0x25684b[_0x65f6('0x11c')](_0x3dd349[_0x65f6('0x52')]['ids'],_[_0x65f6('0xee')](_0x3dd349[_0x65f6('0x52')],[_0x65f6('0x5d'),'id'])||{});}})['then'](respondWithResult(_0x4c7b0a,null))[_0x65f6('0x1b')](handleError(_0x4c7b0a,null));};exports[_0x65f6('0x104')]=function(_0x1ad645,_0x3b062b){var _0x2c1a02={};var _0x15bdd2={};var _0x20fbe4;var _0x4316bc;return db[_0x65f6('0x42')][_0x65f6('0xd3')]({'where':{'id':_0x1ad645['params']['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x3b062b,null))['then'](function(_0x2086ce){if(_0x2086ce){_0x20fbe4=_0x2086ce;_0x15bdd2['model']=_['keys'](db[_0x65f6('0x11d')][_0x65f6('0x49')]);_0x15bdd2['query']=_[_0x65f6('0x48')](_0x1ad645[_0x65f6('0x32')]);_0x15bdd2[_0x65f6('0x33')]=_[_0x65f6('0x34')](_0x15bdd2[_0x65f6('0x31')],_0x15bdd2['query']);_0x2c1a02['attributes']=_['intersection'](_0x15bdd2[_0x65f6('0x31')],qs['fields'](_0x1ad645[_0x65f6('0x32')][_0x65f6('0x36')]));_0x2c1a02[_0x65f6('0x35')]=_0x2c1a02[_0x65f6('0x35')][_0x65f6('0x37')]?_0x2c1a02[_0x65f6('0x35')]:_0x15bdd2[_0x65f6('0x31')];_0x2c1a02['order']=qs['sort'](_0x1ad645['query'][_0x65f6('0x3b')]);_0x2c1a02[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x1ad645['query'],_0x15bdd2[_0x65f6('0x33')]));if(_0x1ad645['query']['filter']){_0x2c1a02[_0x65f6('0x3c')]=_[_0x65f6('0x3f')](_0x2c1a02['where'],{'$or':_[_0x65f6('0x2f')](_0x2c1a02[_0x65f6('0x35')],function(_0xb4e1c5){var _0x390553={};_0x390553[_0xb4e1c5]={'$like':'%'+_0x1ad645['query']['filter']+'%'};return _0x390553;})});}_0x2c1a02=_[_0x65f6('0x3f')]({},_0x2c1a02,_0x1ad645[_0x65f6('0x41')]);return _0x20fbe4['getProactiveActions'](_0x2c1a02);}})[_0x65f6('0x12')](function(_0x13ecb8){if(_0x13ecb8){_0x4316bc=_0x13ecb8[_0x65f6('0x37')];if(!_0x1ad645[_0x65f6('0x32')][_0x65f6('0x38')](_0x65f6('0x39'))){_0x2c1a02[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x1ad645[_0x65f6('0x32')]['limit']);_0x2c1a02[_0x65f6('0x21')]=qs[_0x65f6('0x21')](_0x1ad645[_0x65f6('0x32')][_0x65f6('0x21')]);}return _0x20fbe4['getProactiveActions'](_0x2c1a02);}})['then'](function(_0x2c6cca){if(_0x2c6cca){return _0x2c6cca?{'count':_0x4316bc,'rows':_0x2c6cca}:null;}})['then'](respondWithResult(_0x3b062b,null))[_0x65f6('0x1b')](handleError(_0x3b062b,null));};exports[_0x65f6('0x11e')]=function(_0x3d46d4,_0xf51395){var _0x5b3abc=_0x3d46d4[_0x65f6('0x32')]['online']===_0x65f6('0x11f')?_0x65f6('0x120'):'onlineForm';return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'attributes':['id',_0x5b3abc],'where':{'id':_0x3d46d4[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0xf51395,null))[_0x65f6('0x12')](function(_0x9c768){if(_0x9c768){var _0x5b2cc1=_0x9c768[_0x5b3abc];var _0x62830b=_0x5b2cc1&&_0x5b2cc1['items']?_0x5b2cc1[_0x65f6('0x121')]:[];_0xf51395['send']({'fromKey':_[_0x65f6('0x6b')](_0x5b2cc1[_0x65f6('0x122')])?undefined:_0x5b2cc1['fromKey'],'count':_0x62830b[_0x65f6('0x37')],'rows':_0x62830b});}})[_0x65f6('0x1b')](handleError(_0xf51395,null));};exports['getOfflineMessages']=function(_0x42ad46,_0x4dd517){var _0x2dcf79={'raw':![],'where':{}};var _0x333da7={};var _0x10c466={'count':0x0,'rows':[]};return db[_0x65f6('0x42')][_0x65f6('0xd3')]({'where':{'id':_0x42ad46[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x4dd517,null))[_0x65f6('0x12')](function(_0x1c9d56){if(_0x1c9d56){_0x333da7[_0x65f6('0x31')]=_[_0x65f6('0x48')](db[_0x65f6('0xc8')][_0x65f6('0x49')]);_0x333da7[_0x65f6('0x32')]=_[_0x65f6('0x48')](_0x42ad46[_0x65f6('0x32')]);_0x333da7['filters']=_[_0x65f6('0x34')](_0x333da7[_0x65f6('0x31')],_0x333da7['query']);_0x2dcf79[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0x333da7[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x42ad46[_0x65f6('0x32')][_0x65f6('0x36')]));_0x2dcf79[_0x65f6('0x35')]=_0x2dcf79[_0x65f6('0x35')][_0x65f6('0x37')]?_0x2dcf79[_0x65f6('0x35')]:_0x333da7['model'];if(!_0x42ad46['query'][_0x65f6('0x38')](_0x65f6('0x39'))){_0x2dcf79['limit']=qs[_0x65f6('0x1e')](_0x42ad46[_0x65f6('0x32')][_0x65f6('0x1e')]);_0x2dcf79[_0x65f6('0x21')]=qs[_0x65f6('0x21')](_0x42ad46['query']['offset']);}_0x2dcf79['order']=qs[_0x65f6('0x3b')](_0x42ad46[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x2dcf79[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_['pick'](_0x42ad46[_0x65f6('0x32')],_0x333da7['filters']));_0x2dcf79[_0x65f6('0x3c')][_0x65f6('0x54')]=_0x1c9d56['id'];if(_0x42ad46[_0x65f6('0x32')]['filter']){_0x2dcf79[_0x65f6('0x3c')]=_['merge'](_0x2dcf79[_0x65f6('0x3c')],{'$or':_[_0x65f6('0x2f')](_0x2dcf79['attributes'],function(_0x230125){var _0xe75255={};_0xe75255[_0x230125]={'$like':'%'+_0x42ad46['query'][_0x65f6('0x3e')]+'%'};return _0xe75255;})});}_0x2dcf79=_[_0x65f6('0x3f')]({},_0x2dcf79,_0x42ad46[_0x65f6('0x41')]);return db[_0x65f6('0xc8')][_0x65f6('0x20')]({'where':_0x2dcf79['where']})[_0x65f6('0x12')](function(_0x4416b4){_0x10c466['count']=_0x4416b4;if(_0x42ad46[_0x65f6('0x32')][_0x65f6('0x4a')]){_0x2dcf79['include']=[{'all':!![]}];}else{_0x2dcf79['include']=[{'model':db[_0x65f6('0x7c')],'as':'Contact','required':![]},{'model':db[_0x65f6('0xd1')],'as':_0x65f6('0x123'),'required':![]}];}return db[_0x65f6('0xc8')][_0x65f6('0x5b')](_0x2dcf79);})[_0x65f6('0x12')](function(_0x2e36c8){_0x10c466[_0x65f6('0x44')]=_0x2e36c8;return _0x10c466;});}})[_0x65f6('0x12')](respondWithFilteredResult(_0x4dd517,_0x2dcf79))[_0x65f6('0x1b')](handleError(_0x4dd517,null));};exports[_0x65f6('0x124')]=function(_0x52556c,_0x4665ec){return db['ChatWebsite'][_0x65f6('0x4f')]({'where':{'id':_0x52556c[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x4665ec,null))[_0x65f6('0x12')](function(_0x57c109){if(_0x57c109){return _0x57c109['addAgents'](_0x52556c[_0x65f6('0x52')][_0x65f6('0x5d')],_[_0x65f6('0xee')](_0x52556c[_0x65f6('0x52')],[_0x65f6('0x5d'),'id'])||{})[_0x65f6('0xab')](function(_0x5052d0){for(var _0x5dcfb7=0x0;_0x5dcfb7<_0x52556c[_0x65f6('0x52')]['ids'][_0x65f6('0x37')];_0x5dcfb7+=0x1){socket[_0x65f6('0x125')](_0x65f6('0x126'),{'UserId':Number(_0x52556c[_0x65f6('0x52')][_0x65f6('0x5d')][_0x5dcfb7]),'ChatWebsiteId':Number(_0x52556c['params']['id'])});}return _0x5052d0;});}})[_0x65f6('0x12')](respondWithResult(_0x4665ec,null))['catch'](handleError(_0x4665ec,null));};exports[_0x65f6('0x127')]=function(_0xab6058,_0x57d25c){return db[_0x65f6('0x42')][_0x65f6('0x4f')]({'where':{'id':_0xab6058[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x57d25c,null))['then'](function(_0x402a5e){if(_0x402a5e){return _0x402a5e[_0x65f6('0x127')](_0xab6058[_0x65f6('0x32')]['ids'])[_0x65f6('0x12')](function(){if(_[_0x65f6('0x128')](_0xab6058[_0x65f6('0x32')][_0x65f6('0x5d')])){for(var _0x146686=0x0;_0x146686<_0xab6058[_0x65f6('0x32')][_0x65f6('0x5d')][_0x65f6('0x37')];_0x146686+=0x1){socket[_0x65f6('0x125')]('userChatWebsite:remove',{'UserId':Number(_0xab6058[_0x65f6('0x32')][_0x65f6('0x5d')][_0x146686]),'ChatWebsiteId':Number(_0xab6058[_0x65f6('0x46')]['id'])});}}else{socket[_0x65f6('0x125')](_0x65f6('0x129'),{'UserId':Number(_0xab6058[_0x65f6('0x32')][_0x65f6('0x5d')]),'ChatWebsiteId':Number(_0xab6058[_0x65f6('0x46')]['id'])});}});}})[_0x65f6('0x12')](respondWithStatusCode(_0x57d25c,null))[_0x65f6('0x1b')](handleError(_0x57d25c,null));};exports[_0x65f6('0x12a')]=function(_0x9d31a8,_0x56a917){var _0x5bc949={};var _0xcecebe={};var _0xbf5cba;var _0xfbd390;return db[_0x65f6('0x42')]['findOne']({'where':{'id':_0x9d31a8[_0x65f6('0x46')]['id']}})[_0x65f6('0x12')](handleEntityNotFound(_0x56a917,null))[_0x65f6('0x12')](function(_0x5bba5b){if(_0x5bba5b){_0xbf5cba=_0x5bba5b;_0xcecebe[_0x65f6('0x31')]=_[_0x65f6('0x48')](db[_0x65f6('0xb2')][_0x65f6('0x49')]);_0xcecebe[_0x65f6('0x32')]=_['keys'](_0x9d31a8['query']);_0xcecebe['filters']=_[_0x65f6('0x34')](_0xcecebe[_0x65f6('0x31')],_0xcecebe[_0x65f6('0x32')]);_0x5bc949[_0x65f6('0x35')]=_[_0x65f6('0x34')](_0xcecebe[_0x65f6('0x31')],qs[_0x65f6('0x36')](_0x9d31a8[_0x65f6('0x32')][_0x65f6('0x36')]));_0x5bc949['attributes']=_0x5bc949[_0x65f6('0x35')][_0x65f6('0x37')]?_0x5bc949['attributes']:_0xcecebe['model'];_0x5bc949[_0x65f6('0x3a')]=qs['sort'](_0x9d31a8[_0x65f6('0x32')][_0x65f6('0x3b')]);_0x5bc949[_0x65f6('0x3c')]=qs[_0x65f6('0x33')](_[_0x65f6('0x3d')](_0x9d31a8[_0x65f6('0x32')],_0xcecebe[_0x65f6('0x33')]));if(_0x9d31a8[_0x65f6('0x32')][_0x65f6('0x3e')]){_0x5bc949[_0x65f6('0x3c')]=_[_0x65f6('0x3f')](_0x5bc949[_0x65f6('0x3c')],{'$or':_[_0x65f6('0x2f')](_0x5bc949[_0x65f6('0x35')],function(_0x4e5800){var _0x35934d={};_0x35934d[_0x4e5800]={'$like':'%'+_0x9d31a8[_0x65f6('0x32')][_0x65f6('0x3e')]+'%'};return _0x35934d;})});}_0x5bc949=_[_0x65f6('0x3f')]({},_0x5bc949,_0x9d31a8[_0x65f6('0x41')]);return _0xbf5cba[_0x65f6('0x12a')](_0x5bc949);}})['then'](function(_0x309659){if(_0x309659){_0xfbd390=_0x309659['length'];if(!_0x9d31a8[_0x65f6('0x32')][_0x65f6('0x38')](_0x65f6('0x39'))){_0x5bc949[_0x65f6('0x1e')]=qs[_0x65f6('0x1e')](_0x9d31a8[_0x65f6('0x32')]['limit']);_0x5bc949[_0x65f6('0x21')]=qs[_0x65f6('0x21')](_0x9d31a8[_0x65f6('0x32')]['offset']);}return _0xbf5cba[_0x65f6('0x12a')](_0x5bc949);}})[_0x65f6('0x12')](function(_0x227065){if(_0x227065){return _0x227065?{'count':_0xfbd390,'rows':_0x227065}:null;}})['then'](respondWithResult(_0x56a917,null))[_0x65f6('0x1b')](handleError(_0x56a917,null));};
\ No newline at end of file
+var _0x9957=['Invalid\x20MapKey\x20parameter.\x20Allowed\x20values:\x20','CmList','List','DESC','ChatApplication','Applications','Intervals','interval','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','applications','orderBy','priority','asc','account','list','Contacts','contact','threadId','closed','Writing\x20on\x20closed\x20interaction','externalUrl','interaction','ChatInteraction','messageId','created','autoclose','push','unmanaged','*,*,*,*','ChatMessage','AttachmentId','User','unshift','waitForTheAssignedAgent','forcedOwnership','queueId','ChatQueue','queue','waitForTheAssignedQueue','Start','startRouting','EventManager','offline','Sequelize','no\x20available\x20attributes','difference','ValidationError','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','ChatOfflineMessage','fromString','originalname','mimetype','files','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','bulkCreate','MailServerOut','Smtp','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','sendMail','\x22%s\x22\x20<%s>','email','MailAccountId','subjectOffline','toPairsIn','mapValues','offlineMessageSubject','Chat','NotifyMailAccount','notifyMail','server','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','internal','Tags','color','tag','getSnippet','getProactiveActions','getLicense','virtual','License','increment','chatLicenseExceeded','3.13.0','headers','origin','http://localhost:9000','testWebsiteWithWildcard','remote','stringify','x-real-ip','connection','replace','alignment','labelText','textColor','color_button','backgroundColor','hideWhenOffline','IntervalId','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','stack','finally','getApplications','addProactiveActions','false','onlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','spread','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','mustache','util','path','ejs','lodash','querystring','html-to-text','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../errors/api','APIBadRequestError','APINotFoundError','handleError','APIConflictError','./helpers/wildcard-expressions','url','URL','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','sendStatus','status','json','undefined','limit','offset','count','Content-Range','update','destroy','ChatWebsites','end','name','send','user-agent-parser','setUA','user-agent','getResult','customerIp','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','%s\x20%s','version','unknown','format','device','vendor','%s\x20%s\x20%s','model','type','index','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','key','map','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','VIRTUAL','filter','merge','options','include','findAll','show','params','includeAll','find','create','body','address','forEach','trim','testWildcardValidity','\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression','get','user','UserProfileSection','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','Disposition','getDispositions','findOne','rows','removeDispositions','ChatWebsiteId','CannedAnswer','removeAnswers','ids','file','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','sitepic','../../config/license/util','custom','isNil','server/files/images/logos/','getAvatar','server/files/images/avatars/default_avatar.png','existsSync','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/','download','getSystemAvatar','server/files/images/avatars/system_avatar.png','Interval','resolve','timezone','ifTime','notify','chat','from','From\x20is\x20mandatory','mapKey','MapKey\x20is\x20mandatory','isEmpty','Body\x20is\x20mandatory','CmContact','No\x20available\x20attributes','createdAt','updatedAt','CompanyId','ListId','includes'];(function(_0x28fb34,_0x1a1869){var _0x404a15=function(_0x35f155){while(--_0x35f155){_0x28fb34['push'](_0x28fb34['shift']());}};_0x404a15(++_0x1a1869);}(_0x9957,0x93));var _0x7995=function(_0x2dafbe,_0x5d04de){_0x2dafbe=_0x2dafbe-0x0;var _0x58a45a=_0x9957[_0x2dafbe];return _0x58a45a;};'use strict';var Mustache=require(_0x7995('0x0'));var util=require(_0x7995('0x1'));var path=require(_0x7995('0x2'));var ejs=require(_0x7995('0x3'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7995('0x4'));var querystring=require(_0x7995('0x5'));var htmlToText=require(_0x7995('0x6'));var Redis=require(_0x7995('0x7'));var jayson=require('jayson/promise');var qs=require(_0x7995('0x8'));var logger=require(_0x7995('0x9'))(_0x7995('0xa'));var config=require(_0x7995('0xb'));var APIBadRequestError=require(_0x7995('0xc'))[_0x7995('0xd')];var APINotFoundError=require('../../errors/api')[_0x7995('0xe')];var APIOutOfIntervalError=require(_0x7995('0xc'))['APIOutOfIntervalError'];var APIHandleError=require(_0x7995('0xc'))[_0x7995('0xf')];var APIConflictError=require(_0x7995('0xc'))[_0x7995('0x10')];var wildcardUtils=require(_0x7995('0x11'));var URL=require(_0x7995('0x12'))[_0x7995('0x13')];var db=require('../../mysqldb')['db'];config[_0x7995('0x14')]=_[_0x7995('0x15')](config['redis'],{'host':_0x7995('0x16'),'port':0x18eb});var socket=require(_0x7995('0x17'))(new Redis(config[_0x7995('0x14')]));require(_0x7995('0x18'))[_0x7995('0x19')](socket);var client=jayson[_0x7995('0x1a')][_0x7995('0x1b')]({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});var client9003=jayson[_0x7995('0x1a')][_0x7995('0x1b')]({'port':0x232b});var client9001=jayson[_0x7995('0x1a')][_0x7995('0x1b')]({'port':0x2329});function respondWithRpcPromise(_0x3f1d3e,_0x1a5310,_0x2202ce,_0x41cbf0){return new Promise(function(_0x5377e5,_0x2eeacc){var _0x565d97=_0x41cbf0||client;return _0x565d97[_0x7995('0x1c')](_0x3f1d3e,_0x2202ce)[_0x7995('0x1d')](function(_0x43d4b8){logger[_0x7995('0x1e')](_0x7995('0x1f'),_0x1a5310,_0x7995('0x20'));logger['debug']('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x1a5310,_0x7995('0x20'),JSON['stringify'](_0x43d4b8));if(_0x43d4b8['error']){if(_0x43d4b8[_0x7995('0x21')][_0x7995('0x22')]===0x1f4){logger['error'](_0x7995('0x1f'),_0x1a5310,_0x43d4b8['error']['message']);return _0x2eeacc(_0x43d4b8[_0x7995('0x21')][_0x7995('0x23')]);}logger[_0x7995('0x21')](_0x7995('0x1f'),_0x1a5310,_0x43d4b8[_0x7995('0x21')][_0x7995('0x23')]);return _0x5377e5(_0x43d4b8['error'][_0x7995('0x23')]);}else{logger[_0x7995('0x1e')](_0x7995('0x1f'),_0x1a5310,_0x7995('0x20'));_0x5377e5(_0x43d4b8[_0x7995('0x24')][_0x7995('0x23')]);}})[_0x7995('0x25')](function(_0x472195){logger['error'](_0x7995('0x1f'),_0x1a5310,_0x472195);_0x2eeacc(_0x472195);});});}function respondWithStatusCode(_0x34e70c,_0x401dc3){_0x401dc3=_0x401dc3||0xcc;return function(_0x268ce7){if(_0x268ce7){return _0x34e70c[_0x7995('0x26')](_0x401dc3);}return _0x34e70c[_0x7995('0x27')](_0x401dc3)['end']();};}function respondWithResult(_0x47625f,_0x5911c3){_0x5911c3=_0x5911c3||0xc8;return function(_0x229742){if(_0x229742){return _0x47625f[_0x7995('0x27')](_0x5911c3)[_0x7995('0x28')](_0x229742);}};}function respondWithFilteredResult(_0x132a42,_0x11c1eb){return function(_0x4b6f99){if(_0x4b6f99){var _0x9b2a15=typeof _0x11c1eb['offset']===_0x7995('0x29')&&typeof _0x11c1eb[_0x7995('0x2a')]===_0x7995('0x29');var _0x574574=_0x4b6f99['count'];var _0x48e573=_0x9b2a15?0x0:_0x11c1eb[_0x7995('0x2b')];var _0xe6b0b3=_0x9b2a15?_0x4b6f99[_0x7995('0x2c')]:_0x11c1eb[_0x7995('0x2b')]+_0x11c1eb[_0x7995('0x2a')];var _0x1ca460;if(_0xe6b0b3>=_0x574574){_0xe6b0b3=_0x574574;_0x1ca460=0xc8;}else{_0x1ca460=0xce;}_0x132a42['status'](_0x1ca460);return _0x132a42['set'](_0x7995('0x2d'),_0x48e573+'-'+_0xe6b0b3+'/'+_0x574574)['json'](_0x4b6f99);}return null;};}function saveUpdates(_0x553671){return function(_0x3eb566){if(_0x3eb566){return _0x3eb566[_0x7995('0x2e')](_0x553671)[_0x7995('0x1d')](function(_0x1f7d27){return _0x1f7d27;});}return null;};}function removeEntity(_0x510841){return function(_0x44309d){if(_0x44309d){return _0x44309d[_0x7995('0x2f')]()['then'](function(){var _0x48db25=_0x44309d['get']({'plain':!![]});var _0x45bc5e=_0x7995('0x30');return db['UserProfileResource'][_0x7995('0x2f')]({'where':{'type':_0x45bc5e,'resourceId':_0x48db25['id']}})['then'](function(){return _0x44309d;});})[_0x7995('0x1d')](function(){_0x510841[_0x7995('0x27')](0xcc)[_0x7995('0x31')]();});}};}function handleEntityNotFound(_0x5014d2){return function(_0x52d76d){if(!_0x52d76d){_0x5014d2[_0x7995('0x26')](0x194);}return _0x52d76d;};}function handleError(_0x5e67fe,_0x5d2428){_0x5d2428=_0x5d2428||0x1f4;return function(_0x3e99cd){logger[_0x7995('0x21')](_0x3e99cd['stack']);if(_0x3e99cd[_0x7995('0x32')]){delete _0x3e99cd[_0x7995('0x32')];}_0x5e67fe[_0x7995('0x27')](_0x5d2428)[_0x7995('0x33')](_0x3e99cd);};}function createInteractionObject(_0x1e3dbf,_0x53002a,_0x2d4285,_0x242713){var _0xf612e6=require(_0x7995('0x34'));var _0x4b1541=new _0xf612e6();var _0x2be2c0=_0x4b1541[_0x7995('0x35')](_0x2d4285[_0x7995('0x36')])[_0x7995('0x37')]();var _0x1f5bee=_0x53002a[_0x7995('0x38')];if(_0x2d4285['cf-connecting-ip']){_0x1f5bee=_0x2d4285[_0x7995('0x39')];}else if(_0x2d4285[_0x7995('0x3a')]){_0x1f5bee=_[_0x7995('0x3b')](_0x2d4285[_0x7995('0x3a')][_0x7995('0x3c')](','));}return{'ContactId':_0x242713['id'],'ChatWebsiteId':_0x1e3dbf,'from':(_0x242713[_0x7995('0x3d')]||'')+'\x20'+(_0x242713[_0x7995('0x3e')]||''),'customerIp':_0x1f5bee,'customerPort':_0x2d4285[_0x7995('0x3f')]?_0x2d4285[_0x7995('0x3f')]:null,'referer':_0x53002a[_0x7995('0x40')],'browserName':_0x2be2c0[_0x7995('0x41')][_0x7995('0x32')]&&_0x2be2c0[_0x7995('0x41')]['version']?util['format'](_0x7995('0x42'),_0x2be2c0[_0x7995('0x41')]['name'],_0x2be2c0['browser'][_0x7995('0x43')]):'unknown','browserVersion':_0x2be2c0['browser'][_0x7995('0x43')]||_0x7995('0x44'),'osName':util[_0x7995('0x45')]('%s\x20%s',_0x2be2c0['os'][_0x7995('0x32')],_0x2be2c0['os']['version']),'osVersion':_0x2be2c0['os'][_0x7995('0x43')],'deviceModel':_0x2be2c0['device']['model']&&_0x2be2c0[_0x7995('0x46')][_0x7995('0x47')]?util[_0x7995('0x45')](_0x7995('0x48'),_0x2be2c0['device'][_0x7995('0x49')],_0x2be2c0[_0x7995('0x46')][_0x7995('0x47')],_0x2be2c0[_0x7995('0x46')]['type']):null,'deviceVendor':_0x2be2c0['device'][_0x7995('0x47')],'deviceType':_0x2be2c0['device'][_0x7995('0x4a')],'formData':JSON['stringify'](_0x53002a)};}exports[_0x7995('0x4b')]=function(_0x4c1127,_0x1e795e){var _0x1b0373={'include':[{'model':db[_0x7995('0x4c')],'as':_0x7995('0x4d')}]},_0x4d9245={},_0x3e9e62={'count':0x0,'rows':[]};var _0xb70a51=_['map'](db[_0x7995('0x4e')][_0x7995('0x4f')],function(_0x237270){return{'name':_0x237270['fieldName'],'type':_0x237270[_0x7995('0x4a')][_0x7995('0x50')]};});_0x4d9245[_0x7995('0x49')]=_[_0x7995('0x51')](_0xb70a51,_0x7995('0x32'));_0x4d9245['query']=_[_0x7995('0x52')](_0x4c1127[_0x7995('0x53')]);_0x4d9245['filters']=_[_0x7995('0x54')](_0x4d9245['model'],_0x4d9245[_0x7995('0x53')]);_0x1b0373[_0x7995('0x55')]=_[_0x7995('0x54')](_0x4d9245[_0x7995('0x49')],qs[_0x7995('0x56')](_0x4c1127[_0x7995('0x53')][_0x7995('0x56')]));_0x1b0373['attributes']=_0x1b0373[_0x7995('0x55')][_0x7995('0x57')]?_0x1b0373[_0x7995('0x55')]:_0x4d9245['model'];if(!_0x4c1127[_0x7995('0x53')][_0x7995('0x58')](_0x7995('0x59'))){_0x1b0373['limit']=qs['limit'](_0x4c1127['query'][_0x7995('0x2a')]);_0x1b0373[_0x7995('0x2b')]=qs['offset'](_0x4c1127[_0x7995('0x53')][_0x7995('0x2b')]);}_0x1b0373[_0x7995('0x5a')]=qs[_0x7995('0x5b')](_0x4c1127[_0x7995('0x53')]['sort']);_0x1b0373[_0x7995('0x5c')]=qs['filters'](_[_0x7995('0x5d')](_0x4c1127[_0x7995('0x53')],_0x4d9245[_0x7995('0x5e')]),_0xb70a51);if(_0x4c1127['query']['filter']){_0x1b0373['where']=_['merge'](_0x1b0373[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0xb70a51,function(_0x1a861c){if(_0x1a861c[_0x7995('0x4a')]!==_0x7995('0x5f')){var _0x357e60={};_0x357e60[_0x1a861c[_0x7995('0x32')]]={'$like':'%'+_0x4c1127[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x357e60;}})});}_0x1b0373=_[_0x7995('0x61')]({},_0x1b0373,_0x4c1127[_0x7995('0x62')]);var _0x133c63={'where':_0x1b0373[_0x7995('0x5c')]};return db[_0x7995('0x4e')][_0x7995('0x2c')](_0x133c63)[_0x7995('0x1d')](function(_0x447a2b){_0x3e9e62[_0x7995('0x2c')]=_0x447a2b;if(_0x4c1127[_0x7995('0x53')]['includeAll']){_0x1b0373[_0x7995('0x63')]=[{'all':!![]}];}return db[_0x7995('0x4e')][_0x7995('0x64')](_0x1b0373);})[_0x7995('0x1d')](function(_0x5d160d){_0x3e9e62['rows']=_0x5d160d;return _0x3e9e62;})[_0x7995('0x1d')](respondWithFilteredResult(_0x1e795e,_0x1b0373))[_0x7995('0x25')](handleError(_0x1e795e,null));};exports[_0x7995('0x65')]=function(_0x332a85,_0x51c50b){var _0x13cd7b={'raw':![],'where':{'id':_0x332a85[_0x7995('0x66')]['id']},'include':[{'model':db[_0x7995('0x4c')],'as':'mandatoryDispositionPause'}]},_0x74ff38={};_0x74ff38['model']=_[_0x7995('0x52')](db[_0x7995('0x4e')][_0x7995('0x4f')]);_0x74ff38[_0x7995('0x53')]=_[_0x7995('0x52')](_0x332a85[_0x7995('0x53')]);_0x74ff38[_0x7995('0x5e')]=_[_0x7995('0x54')](_0x74ff38[_0x7995('0x49')],_0x74ff38['query']);_0x13cd7b[_0x7995('0x55')]=_[_0x7995('0x54')](_0x74ff38[_0x7995('0x49')],qs[_0x7995('0x56')](_0x332a85['query']['fields']));_0x13cd7b[_0x7995('0x55')]=_0x13cd7b[_0x7995('0x55')]['length']?_0x13cd7b[_0x7995('0x55')]:_0x74ff38[_0x7995('0x49')];if(_0x332a85[_0x7995('0x53')][_0x7995('0x67')]){_0x13cd7b[_0x7995('0x63')]=[{'all':!![]}];}_0x13cd7b=_['merge']({},_0x13cd7b,_0x332a85[_0x7995('0x62')]);return db['ChatWebsite'][_0x7995('0x68')](_0x13cd7b)[_0x7995('0x1d')](handleEntityNotFound(_0x51c50b,null))[_0x7995('0x1d')](respondWithResult(_0x51c50b,null))[_0x7995('0x25')](handleError(_0x51c50b,null));};exports[_0x7995('0x69')]=function(_0xeb8920,_0x2b3c1d){var _0x44372a=null;_0xeb8920[_0x7995('0x6a')][_0x7995('0x6b')][_0x7995('0x3c')](',')[_0x7995('0x6c')](_0x56eb85=>{if(_0x56eb85[_0x7995('0x6d')]()!==''&&!wildcardUtils[_0x7995('0x6e')](_0x56eb85[_0x7995('0x6d')]())){_0x44372a=new APIBadRequestError('\x22'+_0x56eb85[_0x7995('0x6d')]()+_0x7995('0x6f'));}});if(_0x44372a){return handleError(_0x2b3c1d,null)(_0x44372a);}return db['ChatWebsite']['create'](_0xeb8920[_0x7995('0x6a')],{})[_0x7995('0x1d')](function(_0x221542){var _0xae6166=_0xeb8920['user'][_0x7995('0x70')]({'plain':!![]});if(!_0xae6166)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xae6166['role']===_0x7995('0x71')){var _0x36d27d=_0x221542[_0x7995('0x70')]({'plain':!![]});var _0x44bf2b=_0x7995('0x30');return db[_0x7995('0x72')][_0x7995('0x68')]({'where':{'name':_0x44bf2b,'userProfileId':_0xae6166[_0x7995('0x73')]},'raw':!![]})[_0x7995('0x1d')](function(_0x2466df){if(_0x2466df&&_0x2466df['autoAssociation']===0x0){return db[_0x7995('0x74')][_0x7995('0x69')]({'name':_0x36d27d[_0x7995('0x32')],'resourceId':_0x36d27d['id'],'type':_0x2466df['name'],'sectionId':_0x2466df['id']},{})[_0x7995('0x1d')](function(){return _0x221542;});}else{return _0x221542;}})[_0x7995('0x25')](function(_0x705f0){logger[_0x7995('0x21')](_0x7995('0x75'),_0x705f0);throw _0x705f0;});}return _0x221542;})[_0x7995('0x1d')](respondWithResult(_0x2b3c1d,0xc9))[_0x7995('0x25')](handleError(_0x2b3c1d,null));};exports[_0x7995('0x2e')]=function(_0x2f94c4,_0x1fdff6){var _0x435a1b=null;_0x2f94c4['body']['address'][_0x7995('0x3c')](',')[_0x7995('0x6c')](_0x39ebb6=>{if(_0x39ebb6[_0x7995('0x6d')]()!==''&&!wildcardUtils['testWildcardValidity'](_0x39ebb6[_0x7995('0x6d')]())){_0x435a1b=new APIBadRequestError('\x22'+_0x39ebb6[_0x7995('0x6d')]()+'\x22\x20is\x20not\x20a\x20valid\x20wildcard\x20expression');}});if(_0x435a1b){return handleError(_0x1fdff6,null)(_0x435a1b);}if(_0x2f94c4['body']['id']){delete _0x2f94c4[_0x7995('0x6a')]['id'];}return db[_0x7995('0x4e')]['find']({'where':{'id':_0x2f94c4[_0x7995('0x66')]['id']},'include':[{'model':db['Pause'],'as':_0x7995('0x4d')}]})[_0x7995('0x1d')](handleEntityNotFound(_0x1fdff6,null))['then'](saveUpdates(_0x2f94c4['body'],null))[_0x7995('0x1d')](respondWithResult(_0x1fdff6,null))['catch'](handleError(_0x1fdff6,null));};exports[_0x7995('0x2f')]=function(_0xa41fff,_0x3dd197){return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0xa41fff[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x3dd197,null))[_0x7995('0x1d')](removeEntity(_0x3dd197,null))[_0x7995('0x25')](handleError(_0x3dd197,null));};exports[_0x7995('0x76')]=function(_0x1ab590,_0x16108c){return db[_0x7995('0x4e')][_0x7995('0x76')]()[_0x7995('0x1d')](respondWithResult(_0x16108c,null))[_0x7995('0x25')](handleError(_0x16108c,null));};exports[_0x7995('0x77')]=function(_0x251490,_0x2ff7ba){if(_0x251490[_0x7995('0x6a')]['id']){delete _0x251490[_0x7995('0x6a')]['id'];}return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x251490[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x2ff7ba,null))[_0x7995('0x1d')](function(_0x2f7f51){if(_0x2f7f51){_0x251490[_0x7995('0x6a')]['ChatWebsiteId']=_0x2f7f51['id'];return db[_0x7995('0x78')][_0x7995('0x69')](_0x251490['body']);}})['then'](respondWithResult(_0x2ff7ba,null))[_0x7995('0x25')](handleError(_0x2ff7ba,null));};exports[_0x7995('0x79')]=function(_0x2d45d5,_0x38acda){var _0xe1ce4={'raw':![],'where':{}};var _0x2491fe={};var _0x5507a0={'count':0x0,'rows':[]};return db[_0x7995('0x4e')][_0x7995('0x7a')]({'where':{'id':_0x2d45d5[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x38acda,null))[_0x7995('0x1d')](function(_0x3f0bff){if(_0x3f0bff){_0x2491fe[_0x7995('0x49')]=_[_0x7995('0x52')](db['Disposition'][_0x7995('0x4f')]);_0x2491fe[_0x7995('0x53')]=_['keys'](_0x2d45d5['query']);_0x2491fe[_0x7995('0x5e')]=_[_0x7995('0x54')](_0x2491fe[_0x7995('0x49')],_0x2491fe[_0x7995('0x53')]);_0xe1ce4[_0x7995('0x55')]=_['intersection'](_0x2491fe[_0x7995('0x49')],qs[_0x7995('0x56')](_0x2d45d5['query'][_0x7995('0x56')]));_0xe1ce4[_0x7995('0x55')]=_0xe1ce4['attributes'][_0x7995('0x57')]?_0xe1ce4['attributes']:_0x2491fe[_0x7995('0x49')];if(!_0x2d45d5[_0x7995('0x53')][_0x7995('0x58')](_0x7995('0x59'))){_0xe1ce4[_0x7995('0x2a')]=qs['limit'](_0x2d45d5[_0x7995('0x53')][_0x7995('0x2a')]);_0xe1ce4[_0x7995('0x2b')]=qs['offset'](_0x2d45d5[_0x7995('0x53')][_0x7995('0x2b')]);}_0xe1ce4[_0x7995('0x5a')]=qs[_0x7995('0x5b')](_0x2d45d5['query'][_0x7995('0x5b')]);_0xe1ce4[_0x7995('0x5c')]=qs[_0x7995('0x5e')](_['pick'](_0x2d45d5['query'],_0x2491fe[_0x7995('0x5e')]));_0xe1ce4[_0x7995('0x5c')]['ChatWebsiteId']=_0x3f0bff['id'];if(_0x2d45d5['query'][_0x7995('0x60')]){_0xe1ce4[_0x7995('0x5c')]=_[_0x7995('0x61')](_0xe1ce4[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0xe1ce4['attributes'],function(_0x56003d){var _0x393cb7={};_0x393cb7[_0x56003d]={'$like':'%'+_0x2d45d5['query']['filter']+'%'};return _0x393cb7;})});}_0xe1ce4=_[_0x7995('0x61')]({},_0xe1ce4,_0x2d45d5[_0x7995('0x62')]);return db[_0x7995('0x78')]['count']({'where':_0xe1ce4[_0x7995('0x5c')]})[_0x7995('0x1d')](function(_0x2b0b79){_0x5507a0[_0x7995('0x2c')]=_0x2b0b79;if(_0x2d45d5[_0x7995('0x53')]['includeAll']){_0xe1ce4[_0x7995('0x63')]=[{'all':!![]}];}return db[_0x7995('0x78')][_0x7995('0x64')](_0xe1ce4);})[_0x7995('0x1d')](function(_0x50bf9a){_0x5507a0[_0x7995('0x7b')]=_0x50bf9a;return _0x5507a0;});}})[_0x7995('0x1d')](respondWithFilteredResult(_0x38acda,_0xe1ce4))['catch'](handleError(_0x38acda,null));};exports[_0x7995('0x7c')]=function(_0x20683e,_0x5b1528){return db[_0x7995('0x4e')]['find']({'where':{'id':_0x20683e[_0x7995('0x66')]['id']}})['then'](handleEntityNotFound(_0x5b1528,null))[_0x7995('0x1d')](function(_0x4d12fd){if(_0x4d12fd){return _0x4d12fd[_0x7995('0x7c')](_0x20683e[_0x7995('0x53')]['ids']);}})[_0x7995('0x1d')](respondWithStatusCode(_0x5b1528,null))['catch'](handleError(_0x5b1528,null));};exports['addAnswer']=function(_0x7b9e26,_0x14812d){if(_0x7b9e26[_0x7995('0x6a')]['id']){delete _0x7b9e26[_0x7995('0x6a')]['id'];}return db['ChatWebsite'][_0x7995('0x68')]({'where':{'id':_0x7b9e26[_0x7995('0x66')]['id']}})['then'](handleEntityNotFound(_0x14812d,null))['then'](function(_0xc2648d){if(_0xc2648d){_0x7b9e26['body'][_0x7995('0x7d')]=_0xc2648d['id'];return db[_0x7995('0x7e')][_0x7995('0x69')](_0x7b9e26['body']);}})['then'](respondWithResult(_0x14812d,null))[_0x7995('0x25')](handleError(_0x14812d,null));};exports['getAnswers']=function(_0x12e9d9,_0x44891e){var _0x14449c={'raw':![],'where':{}};var _0x38bd35={};var _0x4ff5e7={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x12e9d9[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x44891e,null))[_0x7995('0x1d')](function(_0x2df7d3){if(_0x2df7d3){_0x38bd35[_0x7995('0x49')]=_[_0x7995('0x52')](db['CannedAnswer']['rawAttributes']);_0x38bd35[_0x7995('0x53')]=_['keys'](_0x12e9d9['query']);_0x38bd35[_0x7995('0x5e')]=_['intersection'](_0x38bd35['model'],_0x38bd35[_0x7995('0x53')]);_0x14449c[_0x7995('0x55')]=_[_0x7995('0x54')](_0x38bd35['model'],qs[_0x7995('0x56')](_0x12e9d9[_0x7995('0x53')][_0x7995('0x56')]));_0x14449c[_0x7995('0x55')]=_0x14449c[_0x7995('0x55')][_0x7995('0x57')]?_0x14449c[_0x7995('0x55')]:_0x38bd35[_0x7995('0x49')];if(!_0x12e9d9[_0x7995('0x53')]['hasOwnProperty'](_0x7995('0x59'))){_0x14449c[_0x7995('0x2a')]=qs[_0x7995('0x2a')](_0x12e9d9[_0x7995('0x53')][_0x7995('0x2a')]);_0x14449c['offset']=qs[_0x7995('0x2b')](_0x12e9d9[_0x7995('0x53')][_0x7995('0x2b')]);}_0x14449c['order']=qs['sort'](_0x12e9d9['query'][_0x7995('0x5b')]);_0x14449c[_0x7995('0x5c')]=qs[_0x7995('0x5e')](_[_0x7995('0x5d')](_0x12e9d9[_0x7995('0x53')],_0x38bd35[_0x7995('0x5e')]));_0x14449c['where'][_0x7995('0x7d')]=_0x2df7d3['id'];if(_0x12e9d9['query'][_0x7995('0x60')]){_0x14449c[_0x7995('0x5c')]=_[_0x7995('0x61')](_0x14449c[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0x14449c[_0x7995('0x55')],function(_0x4f929b){var _0x24a0e6={};_0x24a0e6[_0x4f929b]={'$like':'%'+_0x12e9d9[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x24a0e6;})});}_0x14449c=_[_0x7995('0x61')]({},_0x14449c,_0x12e9d9['options']);return db[_0x7995('0x7e')]['count']({'where':_0x14449c[_0x7995('0x5c')]})[_0x7995('0x1d')](function(_0x592ae3){_0x4ff5e7['count']=_0x592ae3;if(_0x12e9d9[_0x7995('0x53')][_0x7995('0x67')]){_0x14449c[_0x7995('0x63')]=[{'all':!![]}];}return db[_0x7995('0x7e')][_0x7995('0x64')](_0x14449c);})[_0x7995('0x1d')](function(_0x281477){_0x4ff5e7[_0x7995('0x7b')]=_0x281477;return _0x4ff5e7;});}})[_0x7995('0x1d')](respondWithFilteredResult(_0x44891e,_0x14449c))[_0x7995('0x25')](handleError(_0x44891e,null));};exports[_0x7995('0x7f')]=function(_0x245ea6,_0x5eb2d9){return db['ChatWebsite'][_0x7995('0x68')]({'where':{'id':_0x245ea6[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x5eb2d9,null))[_0x7995('0x1d')](function(_0x100bde){if(_0x100bde){return _0x100bde['removeAnswers'](_0x245ea6[_0x7995('0x53')][_0x7995('0x80')]);}})['then'](respondWithStatusCode(_0x5eb2d9,null))[_0x7995('0x25')](handleError(_0x5eb2d9,null));};exports['addLogo']=function(_0x37416c,_0x30cda5){_0x37416c[_0x7995('0x6a')]['sitepic']=_0x37416c[_0x7995('0x81')][_0x7995('0x82')];return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x37416c[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x30cda5,null))[_0x7995('0x1d')](saveUpdates(_0x37416c['body'],null))['then'](respondWithResult(_0x30cda5,null))['catch'](handleError(_0x30cda5,null));};exports[_0x7995('0x83')]=function(_0x1b4915,_0x5a78e9){_0x1b4915['body'][_0x7995('0x84')]=_0x1b4915[_0x7995('0x81')]['filename'];return db['ChatWebsite']['find']({'where':{'id':_0x1b4915['params']['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x5a78e9,null))[_0x7995('0x1d')](saveUpdates(_0x1b4915[_0x7995('0x6a')],null))[_0x7995('0x1d')](respondWithResult(_0x5a78e9,null))['catch'](handleError(_0x5a78e9,null));};exports[_0x7995('0x85')]=function(_0x248e7c,_0x58c3e8){_0x248e7c[_0x7995('0x6a')][_0x7995('0x86')]=_0x248e7c[_0x7995('0x81')]['filename'];return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x248e7c['params']['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x58c3e8,null))[_0x7995('0x1d')](saveUpdates(_0x248e7c[_0x7995('0x6a')],null))[_0x7995('0x1d')](respondWithResult(_0x58c3e8,null))[_0x7995('0x25')](handleError(_0x58c3e8,null));};exports[_0x7995('0x87')]=function(_0x8abd9a,_0x114f3c){_0x8abd9a[_0x7995('0x6a')][_0x7995('0x88')]=_0x8abd9a[_0x7995('0x81')][_0x7995('0x82')];return db[_0x7995('0x4e')]['find']({'where':{'id':_0x8abd9a[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x114f3c,null))[_0x7995('0x1d')](saveUpdates(_0x8abd9a[_0x7995('0x6a')],null))['then'](respondWithResult(_0x114f3c,null))[_0x7995('0x25')](handleError(_0x114f3c,null));};exports[_0x7995('0x89')]=function(_0x2bc931,_0x52af9b){var _0x1bcc6b=path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0x8c'));var _0x1dfc40={'where':{'id':_0x2bc931[_0x7995('0x66')]['id']},'attributes':['id',_0x7995('0x8d')],'raw':!![]};var _0x4f9d58=![];return require(_0x7995('0x8e'))['getLicense']()[_0x7995('0x1d')](function(_0x164c61){if(_0x164c61){_0x4f9d58=_0x164c61[_0x7995('0x8f')];}})['then'](function(){return db[_0x7995('0x4e')]['find'](_0x1dfc40);})['then'](handleEntityNotFound(_0x52af9b,null))['then'](function(_0x4b3170){if(_0x4b3170){if(!_[_0x7995('0x90')](_0x4b3170[_0x7995('0x8d')])){if(fs['existsSync'](path[_0x7995('0x8a')](config[_0x7995('0x8b')],'server/files/images/logos/',_0x4b3170[_0x7995('0x8d')]))&&_0x4f9d58){_0x1bcc6b=path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0x91'),_0x4b3170[_0x7995('0x8d')]);}}return _0x52af9b['download'](_0x1bcc6b);}})[_0x7995('0x25')](handleError(_0x52af9b,null));};exports[_0x7995('0x92')]=function(_0x12127d,_0x186ebe){var _0x55387b=path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0x93'));var _0x3ca281={'where':{'id':_0x12127d[_0x7995('0x66')]['id']},'attributes':['id',_0x7995('0x84')],'raw':!![]};return db[_0x7995('0x4e')][_0x7995('0x68')](_0x3ca281)[_0x7995('0x1d')](handleEntityNotFound(_0x186ebe,null))[_0x7995('0x1d')](function(_0x5e08fa){if(_0x5e08fa){if(!_[_0x7995('0x90')](_0x5e08fa['agentAvatar'])){if(fs[_0x7995('0x94')](path[_0x7995('0x8a')](config[_0x7995('0x8b')],'server/files/images/avatars/',_0x5e08fa['agentAvatar']))){_0x55387b=path[_0x7995('0x8a')](config[_0x7995('0x8b')],'server/files/images/avatars/',_0x5e08fa[_0x7995('0x84')]);}}return _0x186ebe['download'](_0x55387b);}})[_0x7995('0x25')](handleError(_0x186ebe,null));};exports[_0x7995('0x95')]=function(_0x27b1c2,_0x4e5667){var _0x5897df=path['join'](config[_0x7995('0x8b')],_0x7995('0x96'));var _0x365318={'where':{'id':_0x27b1c2[_0x7995('0x66')]['id']},'attributes':['id','customerAvatar',_0x7995('0x97')],'raw':!![]};return db[_0x7995('0x4e')][_0x7995('0x68')](_0x365318)[_0x7995('0x1d')](handleEntityNotFound(_0x4e5667,null))[_0x7995('0x1d')](function(_0x5104bf){if(_0x5104bf){if(!_['isNil'](_0x5104bf['customerAvatar'])){if(fs[_0x7995('0x94')](path[_0x7995('0x8a')](config['root'],_0x7995('0x98'),_0x5104bf['customerAvatar']))&&_0x5104bf[_0x7995('0x97')]){_0x5897df=path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0x98'),_0x5104bf['customerAvatar']);}}return _0x4e5667[_0x7995('0x99')](_0x5897df);}})[_0x7995('0x25')](handleError(_0x4e5667,null));};exports[_0x7995('0x9a')]=function(_0x1d7866,_0x2023a7){var _0x197adc=path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0x9b'));var _0x32e5f6={'where':{'id':_0x1d7866[_0x7995('0x66')]['id']},'attributes':['id',_0x7995('0x88')],'raw':!![]};return db[_0x7995('0x4e')][_0x7995('0x68')](_0x32e5f6)['then'](handleEntityNotFound(_0x2023a7,null))[_0x7995('0x1d')](function(_0x58e0c0){if(_0x58e0c0){if(!_[_0x7995('0x90')](_0x58e0c0[_0x7995('0x88')])){if(fs['existsSync'](path[_0x7995('0x8a')](config['root'],_0x7995('0x98'),_0x58e0c0[_0x7995('0x88')]))){_0x197adc=path['join'](config['root'],'server/files/images/avatars/',_0x58e0c0[_0x7995('0x88')]);}}return _0x2023a7[_0x7995('0x99')](_0x197adc);}})[_0x7995('0x25')](handleError(_0x2023a7,null));};function checkWebsiteInterval(_0x2b7bc2){var _0x566b48=_0x2b7bc2[_0x7995('0x9c')];if(!_0x566b48){return Promise[_0x7995('0x9d')](_0x2b7bc2);}var _0xc81297=_0x2b7bc2[_0x7995('0x9e')]||undefined;return _0x566b48[_0x7995('0x9f')](_0xc81297)[_0x7995('0x1d')](function(_0x3e8479){if(!_0x3e8479){throw new APIOutOfIntervalError();}return _0x2b7bc2;});}exports[_0x7995('0xa0')]=function(_0x47f0d9,_0x2e93a9){var _0x5e12c4={'body':_0x47f0d9[_0x7995('0x6a')],'channel':_0x7995('0xa1')};var _0x51ee98=[];var _0x3e90a5=[];var _0x3a2958={};var _0x448faa=![];if(_0x47f0d9[_0x7995('0x6a')]['id']){delete _0x47f0d9[_0x7995('0x6a')]['id'];}if(_[_0x7995('0x90')](_0x47f0d9['body'][_0x7995('0xa2')])){throw new APIBadRequestError(_0x7995('0xa3'));}if(_[_0x7995('0x90')](_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa4')])){throw new APIBadRequestError(_0x7995('0xa5'));}if(_[_0x7995('0xa6')](_0x47f0d9[_0x7995('0x6a')][_0x7995('0x6a')])){throw new APIBadRequestError(_0x7995('0xa7'));}var _0x370e25=_0x47f0d9[_0x7995('0x6a')][_0x7995('0x38')]&&_0x47f0d9[_0x7995('0x6a')][_0x7995('0x40')];return db[_0x7995('0xa8')][_0x7995('0x76')]()[_0x7995('0x1d')](function(_0x40c06b){if(!_0x40c06b){throw new Error(_0x7995('0xa9'));}_0x51ee98=Object[_0x7995('0x52')](_0x40c06b)['filter'](function(_0x4cf7f1){return![_0x7995('0xaa'),_0x7995('0xab')]['includes'](_0x4cf7f1);});_0x3e90a5=Object[_0x7995('0x52')](_0x40c06b)['filter'](function(_0x2ce103){return!['createdAt',_0x7995('0xab'),_0x7995('0xac'),_0x7995('0xad')][_0x7995('0xae')](_0x2ce103);});if(!_[_0x7995('0xae')](_0x3e90a5,_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa4')])){throw new APIBadRequestError(_0x7995('0xaf')+_0x3e90a5[_0x7995('0x8a')](',\x20'));}_0x3a2958[_0x47f0d9[_0x7995('0x6a')]['mapKey']]=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa2')];})[_0x7995('0x1d')](function(){return db[_0x7995('0x4e')]['find']({'where':{'id':_0x47f0d9[_0x7995('0x66')]['id']},'include':[{'model':db[_0x7995('0xb0')],'as':_0x7995('0xb1'),'include':[{'model':db[_0x7995('0xa8')],'as':'Contacts','where':_0x3a2958,'limit':0x1,'order':[[_0x7995('0xab'),_0x7995('0xb2')]]}]},{'model':db[_0x7995('0xb3')],'as':_0x7995('0xb4')},{'model':db[_0x7995('0x9c')],'as':_0x7995('0x9c'),'include':[{'model':db[_0x7995('0x9c')],'as':_0x7995('0xb5'),'attributes':['id',_0x7995('0xb6')],'raw':!![]}]}]});})['then'](function(_0x3c81cc){if(!_0x3c81cc){throw new APINotFoundError(util['format'](_0x7995('0xb7'),_0x47f0d9[_0x7995('0x66')]['id']));}if(_0x370e25){return checkWebsiteInterval(_0x3c81cc);}return _0x3c81cc;})[_0x7995('0x1d')](function(_0x19fa6d){_0x5e12c4['account']=_0x19fa6d;_0x5e12c4[_0x7995('0xb8')]=_[_0x7995('0xb9')](_0x19fa6d[_0x7995('0xb4')],[_0x7995('0xba')],[_0x7995('0xbb')]);if(_0x5e12c4[_0x7995('0xbc')][_0x7995('0xb4')]){delete _0x5e12c4[_0x7995('0xbc')][_0x7995('0xb4')];}_0x5e12c4[_0x7995('0xbd')]=_0x19fa6d[_0x7995('0xb1')]||{'id':_0x19fa6d[_0x7995('0xad')]};if(_0x5e12c4[_0x7995('0xbd')]&&_0x5e12c4[_0x7995('0xbd')]['Contacts']['length']){return _0x5e12c4[_0x7995('0xbd')][_0x7995('0xbe')][0x0];}var _0xceb704=_['defaults'](_0x47f0d9[_0x7995('0x6a')],{'firstName':_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa2')],'ListId':_0x19fa6d['ListId']});_0xceb704[_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa4')]]=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xa2')];return db[_0x7995('0xa8')][_0x7995('0x69')](_0xceb704,{'fields':_0x51ee98,'raw':!![]});})[_0x7995('0x1d')](function(_0x503d2b){_0x5e12c4[_0x7995('0xbf')]=_0x503d2b;var _0x3e28b6=createInteractionObject(_0x47f0d9[_0x7995('0x66')]['id'],_0x47f0d9['body'],_0x47f0d9['headers'],_0x503d2b);var _0x23e2c8={'ChatWebsiteId':_0x47f0d9['params']['id']};if(_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc0')]){_0x23e2c8[_0x7995('0xc0')]=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc0')];_0x23e2c8['closed']=![];return db['ChatInteraction'][_0x7995('0x68')]({'where':_0x23e2c8})[_0x7995('0x1d')](function(_0x1475f8){var _0x1eacbf=_0x47f0d9[_0x7995('0x6a')][_0x7995('0x38')]&&_0x47f0d9[_0x7995('0x6a')][_0x7995('0x40')];if(_0x1475f8){_0x448faa=!![];return _0x1475f8;}else if(!_0x1eacbf&&_0x1475f8&&_0x1475f8[_0x7995('0xc1')]){throw new APIConflictError(_0x7995('0xc2'));}_0x3e28b6['threadId']=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc0')];_0x3e28b6[_0x7995('0xc3')]=_0x47f0d9[_0x7995('0x6a')]['externalUrl'];return db['ChatInteraction']['create'](_0x3e28b6);});}_0x23e2c8['ContactId']=_0x503d2b['id'];if(_0x47f0d9['body'][_0x7995('0xc4')]&&_0x47f0d9['body']['interaction']['id']){_0x23e2c8['id']=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc4')]['id'];return db[_0x7995('0xc5')]['find']({'where':_0x23e2c8})[_0x7995('0x1d')](function(_0x4f008a){var _0x39dff0=_0x47f0d9[_0x7995('0x6a')][_0x7995('0x38')]&&_0x47f0d9['body'][_0x7995('0x40')];if(!_0x39dff0&&_0x4f008a&&_0x4f008a[_0x7995('0xc1')]){throw new APIConflictError(_0x7995('0xc2'));}else if(_0x4f008a){_0x448faa=!![];return _0x4f008a;}else{return db['ChatInteraction'][_0x7995('0x69')](_0x3e28b6);}});}return db[_0x7995('0xc5')][_0x7995('0x69')](_0x3e28b6);})[_0x7995('0x1d')](function(_0x17fbde){if(!_0x448faa){return _0x17fbde;}var _0x574e2a={'from':(_0x5e12c4[_0x7995('0xbf')][_0x7995('0x3d')]||'')+'\x20'+(_0x5e12c4[_0x7995('0xbf')]['lastName']||'')};if(_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc0')]&&_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc6')]&&_0x47f0d9[_0x7995('0x6a')]['threadId']!=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc6')]){_0x574e2a[_0x7995('0xc0')]=_0x47f0d9[_0x7995('0x6a')][_0x7995('0xc6')];}return _0x17fbde[_0x7995('0x2e')](_0x574e2a);})[_0x7995('0x1d')](function(_0x5baca7){_0x5e12c4['interaction']=_0x5baca7[_0x7995('0x70')]({'plain':!![]});_0x5e12c4[_0x7995('0xc4')]['created']=!_0x448faa;if(_0x5e12c4['interaction'][_0x7995('0xc7')]){if(_0x5e12c4[_0x7995('0xbc')][_0x7995('0xc8')]){_0x5e12c4[_0x7995('0xb8')][_0x7995('0xc9')]({'id':0x0,'priority':_0x5e12c4[_0x7995('0xb8')][_0x7995('0x57')]+0x1,'app':'close','appdata':_0x7995('0xca'),'interval':_0x7995('0xcb')});}}return db[_0x7995('0xcc')][_0x7995('0x69')]({'body':_0x47f0d9[_0x7995('0x6a')][_0x7995('0x6a')],'ChatWebsiteId':_0x47f0d9['params']['id'],'ChatInteractionId':_0x5baca7['id'],'direction':'in','ContactId':_0x5e12c4[_0x7995('0xbf')]['id'],'AttachmentId':_0x47f0d9[_0x7995('0x6a')][_0x7995('0xcd')]});})[_0x7995('0x1d')](function(_0x13c918){_0x5e12c4[_0x7995('0x23')]=_0x13c918;if(!_0x5e12c4[_0x7995('0xc4')]['UserId']){return;}return db[_0x7995('0xce')][_0x7995('0x68')]({'attributes':['id',_0x7995('0x32')],'where':{'id':_0x5e12c4[_0x7995('0xc4')]['UserId']}});})[_0x7995('0x1d')](function(_0x5c9894){if(_0x5c9894){_0x5e12c4[_0x7995('0xb8')][_0x7995('0xcf')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x5c9894['name']+','+(_0x5e12c4['account'][_0x7995('0xd0')]||0xa),'interval':_0x7995('0xcb')});_0x5e12c4[_0x7995('0xd1')]=!![];}if(!_0x5e12c4[_0x7995('0xc4')][_0x7995('0xd2')]){return;}return db[_0x7995('0xd3')][_0x7995('0x68')]({'attributes':['id',_0x7995('0x32')],'where':{'id':_0x5e12c4[_0x7995('0xc4')][_0x7995('0xd2')]}});})[_0x7995('0x1d')](function(_0x233f44){if(_0x233f44){_0x5e12c4['applications']['unshift']({'id':0x0,'priority':0x1,'app':_0x7995('0xd4'),'appdata':_0x233f44['name']+','+(_0x5e12c4['account'][_0x7995('0xd5')]||0x12c),'interval':_0x7995('0xcb')});}return respondWithRpcPromise(_0x7995('0xd6'),_0x7995('0xd7'),_0x5e12c4);})[_0x7995('0x1d')](function(_0x29b1cd){respondWithRpcPromise(_0x7995('0xd8'),_0x7995('0xd8'),{'event':_0x7995('0xa0'),'message':_0x29b1cd},client9002);return _0x29b1cd;})[_0x7995('0x1d')](respondWithResult(_0x2e93a9,null))[_0x7995('0x25')](APIHandleError(_0x2e93a9));};exports[_0x7995('0xd9')]=function(_0x511628,_0x3ad9ff){var _0x1a4919,_0x39f3d9,_0x2ec6c9;var _0x2ace90=[];var _0x17570a={};var _0x360022=_0x511628['files']||[];var _0x88334d=[];var _0x234832;return db[_0x7995('0xa8')][_0x7995('0x76')]()[_0x7995('0x1d')](function(_0x53a7a4){if(!_0x53a7a4){throw new db[(_0x7995('0xda'))]['ValidationError'](_0x7995('0xdb'));}_0x2ace90=_[_0x7995('0xdc')](_[_0x7995('0x52')](_0x53a7a4),['createdAt',_0x7995('0xab'),_0x7995('0xac'),_0x7995('0xad')]);if(_0x511628[_0x7995('0x6a')]['id']){delete _0x511628[_0x7995('0x6a')]['id'];}if(_[_0x7995('0x90')](_0x511628[_0x7995('0x6a')]['from'])){throw _0x3ad9ff['status'](0x1f4)[_0x7995('0x33')](new db[(_0x7995('0xda'))][(_0x7995('0xdd'))](_0x7995('0xde')));}if(_[_0x7995('0x90')](_0x511628[_0x7995('0x6a')]['body'])||_0x511628[_0x7995('0x6a')][_0x7995('0x6a')]===''){throw _0x3ad9ff[_0x7995('0x27')](0x1f4)[_0x7995('0x33')](new db['Sequelize']['ValidationError'](_0x7995('0xdf')));}if(_[_0x7995('0x90')](_0x511628['body'][_0x7995('0xe0')])){throw _0x3ad9ff[_0x7995('0x27')](0x1f4)['send'](new db[(_0x7995('0xda'))][(_0x7995('0xdd'))](_0x7995('0xe1')+_0x2ace90));}if(!_[_0x7995('0xae')](_0x2ace90,_0x511628[_0x7995('0x6a')]['mapKeyOffline'])){throw _0x3ad9ff['status'](0x1f4)[_0x7995('0x33')](new db[(_0x7995('0xda'))][(_0x7995('0xdd'))](_0x7995('0xe2')+_0x2ace90));}_0x17570a[_0x511628[_0x7995('0x6a')]['mapKeyOffline']]=_0x511628[_0x7995('0x6a')][_0x7995('0xa2')];})[_0x7995('0x1d')](function(){return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x511628['params']['id']},'include':[{'model':db['CmList'],'as':'List'},{'model':db['MailAccount'],'as':_0x7995('0xe3')}]});})[_0x7995('0x1d')](handleEntityNotFound(_0x3ad9ff,null))['then'](function(_0x382bd9){if(_0x382bd9&&_0x382bd9[_0x7995('0xb1')]){_0x39f3d9=_0x382bd9;var _0x5e8551=_['defaults'](_0x511628[_0x7995('0x6a')],{'firstName':_0x511628[_0x7995('0x6a')][_0x7995('0xa2')],'phone':_0x511628[_0x7995('0x6a')][_0x7995('0xa2')],'ListId':_0x382bd9[_0x7995('0xad')]});_0x5e8551[_0x511628[_0x7995('0x6a')]['mapKeyOffline']]=_0x511628['body'][_0x7995('0xa2')];return db[_0x7995('0xa8')][_0x7995('0xe4')]({'where':_0x17570a,'defaults':_0x5e8551});}})['spread'](function(_0x2f96fd){if(_0x2f96fd){_0x2ec6c9=_0x2f96fd;var _0x39cc1a=fs[_0x7995('0xe5')](path[_0x7995('0x8a')](config[_0x7995('0x8b')],_0x7995('0xe6')),_0x7995('0xe7'));var _0x1b4cab=ejs[_0x7995('0xe8')](_0x39cc1a,{'body':_['toPairs'](_0x511628['body'][_0x7995('0x6a')]),'bodyTitle':_0x39f3d9['offlineMessageBody']});return db[_0x7995('0xe9')]['create']({'body':_0x1b4cab,'plainBody':htmlToText[_0x7995('0xea')](_0x1b4cab),'ContactId':_0x2f96fd['id'],'ChatWebsiteId':_0x39f3d9['id']});}})[_0x7995('0x1d')](function(_0x2ab61c){_0x234832=_0x2ab61c;if(_0x360022['length']){var _0x4c810d=_0x360022[_0x7995('0x51')](function(_0xff0ee8){return{'name':_0xff0ee8[_0x7995('0xeb')],'basename':_0xff0ee8[_0x7995('0x82')],'type':_0xff0ee8[_0x7995('0xec')],'ChatOfflineMessageId':_0x2ab61c['id']};});_0x88334d=_0x4c810d[_0x7995('0x51')](_0xb0164a=>{var _0x294b73={'filename':_0xb0164a[_0x7995('0x32')],'path':path[_0x7995('0x8a')](config[_0x7995('0x8b')],'server',_0x7995('0xed'),_0x7995('0xee'),_0x7995('0xef'),_0xb0164a[_0x7995('0xf0')])};return _0x294b73;});if(!_0x39f3d9[_0x7995('0xf1')]){return db['sequelize'][_0x7995('0xf2')](function(_0x44068f){return db[_0x7995('0xf3')][_0x7995('0xf4')](_0x4c810d,{'transaction':_0x44068f});});}}})[_0x7995('0x1d')](function(){if(_0x234832){_0x1a4919=_0x234832;return db[_0x7995('0xe3')][_0x7995('0x7a')]({'where':{'service':!![]},'include':[{'model':db[_0x7995('0xf5')],'as':_0x7995('0xf6'),'raw':!![],'include':[{'model':db['CloudProvider'],'as':'CloudProvider','raw':!![]}]}]});}})[_0x7995('0x1d')](function(_0x127b80){if(_0x127b80&&_0x127b80[_0x7995('0xf6')]&&_0x39f3d9[_0x7995('0xf7')]&&_0x39f3d9[_0x7995('0xf8')]){var _0x498d7c=_0x127b80[_0x7995('0xf9')]();return respondWithRpcPromise(_0x7995('0xfa'),_0x7995('0xfb'),{'account':_0x498d7c,'message':{'from':util[_0x7995('0x45')](_0x7995('0xfc'),_0x127b80[_0x7995('0x32')],_0x127b80[_0x7995('0xfd')]||_0x127b80[_0x7995('0xf6')][_0x7995('0x71')]),'to':_0x39f3d9['forwardOfflineAddress'],'subject':_0x39f3d9['offlineMessageSubject'],'html':_0x1a4919[_0x7995('0x6a')],'attachments':_0x88334d}},client9003)[_0x7995('0x1d')](function(){return _0x1a4919;})[_0x7995('0x25')](function(_0x296643){logger[_0x7995('0x21')](_0x296643);});}})[_0x7995('0x1d')](function(){if(_0x39f3d9&&_0x39f3d9[_0x7995('0xf1')]&&_0x39f3d9[_0x7995('0xfe')]){var _0x5f100f=[];if(_0x360022['length']){_0x5f100f=_0x360022[_0x7995('0x51')](function(_0x386081){return{'name':_0x386081[_0x7995('0xeb')],'basename':_0x386081[_0x7995('0x82')],'type':_0x386081['mimetype'],'ChatOfflineMessageId':_0x234832['id']};});}var _0x580476;if(!_[_0x7995('0x90')](_0x39f3d9[_0x7995('0xff')])){var _0x2c8cd6=_[_0x7995('0x51')](_0x511628[_0x7995('0x6a')],function(_0x166566){return _0x166566;});var _0x127b5b=_[_0x7995('0x100')](_0x2c8cd6)[0x0];var _0x273283=_[_0x7995('0x101')](_0x127b5b,function(_0x1c2899){return _0x1c2899;});_0x580476=_0x273283[0x1][_0x39f3d9[_0x7995('0xff')]];}var _0x56809d={'from':_0x2ec6c9['email'],'firstName':_0x2ec6c9[_0x7995('0x3d')],'lastName':_0x2ec6c9[_0x7995('0x3e')],'mapKey':_0x7995('0xfd'),'message':{'from':_0x2ec6c9[_0x7995('0xfd')],'to':_0x39f3d9['MailAccount'][_0x7995('0xfd')],'cc':'','subject':_['isNil'](_0x580476)?_0x39f3d9[_0x7995('0x102')]:_0x580476,'messageId':'','sentAt':new Date(),'attach':_0x5f100f[_0x7995('0x57')],'attachments':_0x5f100f,'originChannel':_0x7995('0x103'),'ChatWebsiteId':_0x39f3d9['id'],'ChatOfflineMessageId':_0x1a4919['id'],'originTo':_0x39f3d9[_0x7995('0xe3')][_0x7995('0xfd')]},'body':_0x1a4919[_0x7995('0x6a')]};var _0x570408={'account':{'id':_0x39f3d9[_0x7995('0xfe')]},'body':_0x56809d,'log':_0x7995('0x104')};return respondWithRpcPromise(_0x7995('0x104'),_0x7995('0x105'),_0x570408,client9001)['then'](function(){return _0x1a4919;})['catch'](function(_0x43b9d6){logger[_0x7995('0x21')](_0x43b9d6);});}return;})[_0x7995('0x1d')](function(){if(_0x1a4919){return _0x1a4919;}})[_0x7995('0x1d')](respondWithResult(_0x3ad9ff,null))['catch'](function(){for(var _0x2958e9 of _0x360022){var _0x4e72=path[_0x7995('0x8a')](config['root'],_0x7995('0x106'),_0x7995('0xed'),_0x7995('0xee'),'offline-chat',_0x2958e9[_0x7995('0x82')]);fs_extra[_0x7995('0x107')](_0x4e72)[_0x7995('0x25')](function(_0x36778f){logger[_0x7995('0x21')](_0x7995('0x108'),_0x4e72,_0x36778f);});}});};exports[_0x7995('0x109')]=function(_0x2c8459,_0x3a285b){return db['ChatInteraction'][_0x7995('0x68')]({'where':{'id':_0x2c8459[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x3a285b,null))[_0x7995('0x1d')](function(_0x5eb18f){if(_0x5eb18f){return _0x5eb18f[_0x7995('0x109')](_0x2c8459[_0x7995('0x6a')][_0x7995('0x80')],_[_0x7995('0x10a')](_0x2c8459['body'],[_0x7995('0x80'),'id'])||{});}})[_0x7995('0x1d')](respondWithResult(_0x3a285b,null))[_0x7995('0x25')](handleError(_0x3a285b,null));};exports[_0x7995('0x10b')]=function(_0x3c711e,_0x126d6e){var _0x31dae8={'raw':![],'where':{}};var _0x5e3421={};var _0x1a4089={'count':0x0,'rows':[]};return db[_0x7995('0x4e')][_0x7995('0x7a')]({'where':{'id':_0x3c711e[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x126d6e,null))['then'](function(_0x1f915b){if(_0x1f915b){_0x5e3421['model']=_[_0x7995('0x52')](db[_0x7995('0xc5')][_0x7995('0x4f')]);_0x5e3421['query']=_['keys'](_0x3c711e['query']);_0x5e3421[_0x7995('0x5e')]=_[_0x7995('0x54')](_0x5e3421[_0x7995('0x49')],_0x5e3421[_0x7995('0x53')]);_0x31dae8[_0x7995('0x55')]=_[_0x7995('0x54')](_0x5e3421['model'],qs[_0x7995('0x56')](_0x3c711e[_0x7995('0x53')][_0x7995('0x56')]));_0x31dae8[_0x7995('0x55')]=_0x31dae8['attributes'][_0x7995('0x57')]?_0x31dae8[_0x7995('0x55')]:_0x5e3421['model'];if(!_0x3c711e[_0x7995('0x53')]['hasOwnProperty'](_0x7995('0x59'))){_0x31dae8[_0x7995('0x2a')]=qs[_0x7995('0x2a')](_0x3c711e['query']['limit']);_0x31dae8[_0x7995('0x2b')]=qs[_0x7995('0x2b')](_0x3c711e[_0x7995('0x53')][_0x7995('0x2b')]);}_0x31dae8[_0x7995('0x5a')]=qs[_0x7995('0x5b')](_0x3c711e[_0x7995('0x53')][_0x7995('0x5b')]);_0x31dae8[_0x7995('0x5c')]=qs[_0x7995('0x5e')](_[_0x7995('0x5d')](_0x3c711e['query'],_0x5e3421['filters']));_0x31dae8[_0x7995('0x5c')][_0x7995('0x7d')]=_0x1f915b['id'];if(_0x3c711e[_0x7995('0x53')][_0x7995('0x60')]){_0x31dae8['where']=_['merge'](_0x31dae8[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0x31dae8['attributes'],function(_0x4d0036){var _0x952d6c={};_0x952d6c[_0x4d0036]={'$like':'%'+_0x3c711e[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x952d6c;})});}_0x31dae8=_[_0x7995('0x61')]({},_0x31dae8,_0x3c711e[_0x7995('0x62')]);return db['ChatInteraction'][_0x7995('0x2c')]({'where':_0x31dae8[_0x7995('0x5c')]})['then'](function(_0xf9859c){_0x1a4089[_0x7995('0x2c')]=_0xf9859c;if(_0x3c711e[_0x7995('0x53')]['includeAll']){_0x31dae8[_0x7995('0x63')]=[{'model':db[_0x7995('0xa8')],'as':_0x7995('0x10c'),'required':![]},{'model':db[_0x7995('0xce')],'as':_0x7995('0x10d'),'attributes':['name','fullname',_0x7995('0x10e')],'required':![]},{'model':db['Tag'],'as':_0x7995('0x10f'),'attributes':['id','name',_0x7995('0x110')],'where':_0x3c711e[_0x7995('0x53')][_0x7995('0x111')]?{'id':_0x3c711e['query']['tag']}:undefined,'required':_0x3c711e['query'][_0x7995('0x111')]?!![]:![]}];}return db[_0x7995('0xc5')][_0x7995('0x64')](_0x31dae8);})['then'](function(_0x2a9738){_0x1a4089[_0x7995('0x7b')]=_0x2a9738;return _0x1a4089;});}})['then'](respondWithFilteredResult(_0x126d6e,_0x31dae8))[_0x7995('0x25')](handleError(_0x126d6e,null));};exports[_0x7995('0x112')]=function(_0x34350f,_0x108aeb){var _0x3a9c19=0x0;var _0x4b3aa3=0x0;var _0x5a6bb5=![];var _0x19cdd8;var _0x2d72c2;return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x34350f[_0x7995('0x66')]['id']},'include':[{'model':db[_0x7995('0x9c')],'as':_0x7995('0x9c'),'include':[{'model':db[_0x7995('0x9c')],'as':_0x7995('0xb5'),'attributes':['id',_0x7995('0xb6')]}]}]})['then'](handleEntityNotFound(_0x108aeb,null))[_0x7995('0x1d')](function(_0x1faf9b){if(_0x1faf9b){_0x19cdd8=_0x1faf9b;return _0x1faf9b[_0x7995('0x113')]({'raw':!![]});}})[_0x7995('0x1d')](function(_0x39ee00){if(_0x19cdd8){if(_0x39ee00){_0x2d72c2=_0x39ee00;}}return require(_0x7995('0x8e'))[_0x7995('0x114')]();})['then'](function(_0x5d0fe6){if(_0x5d0fe6){_0x4b3aa3=_0x5d0fe6[_0x7995('0x115')];_0x5a6bb5=_0x5d0fe6[_0x7995('0x8f')];}})[_0x7995('0x1d')](function(){return db[_0x7995('0xc5')]['count']({'where':{'closed':![]}});})['then'](function(_0x4b477a){_0x3a9c19=_0x4b477a;if(_0x4b3aa3&&_0x4b477a>_0x4b3aa3){return db[_0x7995('0x116')][_0x7995('0x7a')]({'where':{'id':0x1}})['then'](function(_0x3f908e){if(_0x3f908e){_0x3f908e[_0x7995('0x117')](_0x7995('0x118'));}});}})[_0x7995('0x1d')](function(){var _0x13fc64=_0x19cdd8[_0x7995('0x9c')];var _0x35229d=_0x19cdd8[_0x7995('0x9e')]||undefined;return _0x13fc64?_0x13fc64['ifTime'](_0x35229d):!![];})[_0x7995('0x1d')](function(_0x13d525){var _0x37b7e7=fs['readFileSync'](path[_0x7995('0x8a')](config['root'],'server/files/chat/iframe.ejs'),'utf8');var _0x507bf3=_0x7995('0x119');var _0x4c64a8=![];var _0x296af1,_0x2e1466;if(_0x34350f['headers'][_0x7995('0x40')]){_0x296af1=new URL(_0x34350f[_0x7995('0x11a')][_0x7995('0x40')])[_0x7995('0x11b')];}else if(_0x34350f['headers'][_0x7995('0x11b')]){_0x296af1=new URL(_0x34350f['headers'][_0x7995('0x11b')])[_0x7995('0x11b')];}else{_0x296af1=_0x7995('0x11c');}_0x2e1466=typeof _0x19cdd8[_0x7995('0x6b')][_0x7995('0x3c')](',')[_0x7995('0x68')](function(_0x30d2af){return wildcardUtils[_0x7995('0x11d')](_0x30d2af,_0x296af1);})!==_0x7995('0x29');var _0x281839={'chatVersion':_0x507bf3,'chatWebsiteAddressOrigin':_0x2e1466?_0x296af1:_0x19cdd8['address'],'remote':_0x19cdd8[_0x7995('0x11e')],'query':querystring[_0x7995('0x11f')](_['merge'](_0x19cdd8[_0x7995('0x70')]({'plain':!![]}),{'customerIp':_0x34350f[_0x7995('0x11a')][_0x7995('0x3a')]||_0x34350f[_0x7995('0x11a')][_0x7995('0x120')]||_0x34350f[_0x7995('0x121')]['remoteAddress']||_0x34350f['ip'],'referer':_0x34350f[_0x7995('0x11a')]['referer'],'openedInteractions':_0x3a9c19,'maxInteractions':_0x4b3aa3,'virtual':_0x5a6bb5[_0x7995('0x115')],'online':_0x13d525,'custom':_0x5a6bb5,'address':_0x2e1466?_0x296af1:null}))[_0x7995('0x122')](/'/g,'\x5c\x27')};_0x108aeb[_0x7995('0x33')](ejs[_0x7995('0xe8')](Mustache[_0x7995('0xe8')](_0x37b7e7,_0x281839),{'proactiveActions':_0x2d72c2,'alignment':_0x19cdd8[_0x7995('0x123')],'verticalAlignment':_0x19cdd8['verticalAlignment'],'div_color':_0x19cdd8[_0x7995('0x110')],'labelText':_0x19cdd8[_0x7995('0x124')],'text_color':_0x19cdd8[_0x7995('0x125')],'text_button_color':_0x19cdd8['textButtonColor'],'button_color':_0x19cdd8[_0x7995('0x126')],'background_color':_0x19cdd8[_0x7995('0x127')],'hideWhenOffline':_0x19cdd8[_0x7995('0x128')],'intervalId':_0x19cdd8[_0x7995('0x129')],'isDevelopment':_0x4c64a8,'chatVersion':_0x507bf3}));})[_0x7995('0x25')](handleError(_0x108aeb,null));};exports[_0x7995('0x12a')]=function(_0x346f52,_0x204974){var _0x2c10fd=_0x346f52[_0x7995('0x66')]['id'];var _0xaafd4=_0x346f52['body'];var _0x125233=0xc8;var _0x131fdc=null;return db['sequelize'][_0x7995('0xf2')]({'isolationLevel':db[_0x7995('0x12b')][_0x7995('0x12c')][_0x7995('0x12d')][_0x7995('0x12e')]},function(_0x5a5cc4){return db[_0x7995('0x4e')][_0x7995('0x7a')]({'where':{'id':_0x2c10fd},'transaction':_0x5a5cc4})[_0x7995('0x1d')](function(_0x2da304){if(_0x2da304){return db[_0x7995('0xb3')][_0x7995('0x2f')]({'where':{'ChatWebsiteId':_0x2c10fd},'transaction':_0x5a5cc4})[_0x7995('0x1d')](function(){var _0x3404a1=_[_0x7995('0x51')](_0xaafd4,function(_0x363e3b){_0x363e3b[_0x7995('0x7d')]=_0x2c10fd;return _0x363e3b;});return db[_0x7995('0xb3')][_0x7995('0xf4')](_0x3404a1,{'transaction':_0x5a5cc4});});}else{_0x125233=0x194;_0x131fdc=[];}});})['then'](function(){if(_0x125233!==0x194){return db[_0x7995('0xb3')][_0x7995('0x12f')]({'where':{'ChatWebsiteId':_0x2c10fd},'order':_0x7995('0xba')})[_0x7995('0x1d')](function(_0x4f9d28){_0x131fdc=_0x4f9d28;});}})[_0x7995('0x25')](function(_0x1d07e2){_0x125233=0x1f4;logger[_0x7995('0x21')](_0x1d07e2[_0x7995('0x130')]);if(_0x1d07e2[_0x7995('0x32')]){delete _0x1d07e2[_0x7995('0x32')];}_0x131fdc=_0x1d07e2;})[_0x7995('0x131')](function(){if(_0x131fdc===null){_0x204974['sendStatus'](_0x125233);}else{if(_0x125233===0x1f4){_0x204974[_0x7995('0x27')](_0x125233)['send'](_0x131fdc);}else{_0x204974[_0x7995('0x27')](_0x125233)[_0x7995('0x28')](_0x131fdc);}}});};exports[_0x7995('0x132')]=function(_0x491694,_0x4d13c0){var _0x26c46c={};var _0x2802cf={};var _0x4071bf;var _0x54a8ac;return db[_0x7995('0x4e')]['findOne']({'where':{'id':_0x491694[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x4d13c0,null))[_0x7995('0x1d')](function(_0x35ee8c){if(_0x35ee8c){_0x4071bf=_0x35ee8c;_0x2802cf[_0x7995('0x49')]=_[_0x7995('0x52')](db['ChatApplication'][_0x7995('0x4f')]);_0x2802cf[_0x7995('0x53')]=_['keys'](_0x491694[_0x7995('0x53')]);_0x2802cf[_0x7995('0x5e')]=_[_0x7995('0x54')](_0x2802cf[_0x7995('0x49')],_0x2802cf[_0x7995('0x53')]);_0x26c46c[_0x7995('0x55')]=_[_0x7995('0x54')](_0x2802cf[_0x7995('0x49')],qs[_0x7995('0x56')](_0x491694[_0x7995('0x53')][_0x7995('0x56')]));_0x26c46c[_0x7995('0x55')]=_0x26c46c[_0x7995('0x55')][_0x7995('0x57')]?_0x26c46c[_0x7995('0x55')]:_0x2802cf[_0x7995('0x49')];_0x26c46c[_0x7995('0x5a')]=qs['sort'](_0x491694['query'][_0x7995('0x5b')]);_0x26c46c[_0x7995('0x5c')]=qs['filters'](_[_0x7995('0x5d')](_0x491694[_0x7995('0x53')],_0x2802cf['filters']));if(_0x491694['query'][_0x7995('0x60')]){_0x26c46c[_0x7995('0x5c')]=_[_0x7995('0x61')](_0x26c46c[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0x26c46c[_0x7995('0x55')],function(_0x1b3920){var _0x3212a3={};_0x3212a3[_0x1b3920]={'$like':'%'+_0x491694[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x3212a3;})});}_0x26c46c=_['merge']({},_0x26c46c,_0x491694[_0x7995('0x62')]);return _0x4071bf[_0x7995('0x132')](_0x26c46c);}})[_0x7995('0x1d')](function(_0x16df00){if(_0x16df00){_0x54a8ac=_0x16df00[_0x7995('0x57')];if(!_0x491694[_0x7995('0x53')][_0x7995('0x58')]('nolimit')){_0x26c46c[_0x7995('0x2a')]=qs[_0x7995('0x2a')](_0x491694[_0x7995('0x53')]['limit']);_0x26c46c[_0x7995('0x2b')]=qs[_0x7995('0x2b')](_0x491694[_0x7995('0x53')][_0x7995('0x2b')]);}return _0x4071bf[_0x7995('0x132')](_0x26c46c);}})[_0x7995('0x1d')](function(_0x5dc448){if(_0x5dc448){return _0x5dc448?{'count':_0x54a8ac,'rows':_0x5dc448}:null;}})[_0x7995('0x1d')](respondWithResult(_0x4d13c0,null))['catch'](handleError(_0x4d13c0,null));};exports[_0x7995('0x133')]=function(_0x226991,_0x36f8a1){return db['chatProactiveAction']['find']({'where':{'id':_0x226991[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x36f8a1,null))[_0x7995('0x1d')](function(_0x586439){if(_0x586439){return _0x586439[_0x7995('0x133')](_0x226991[_0x7995('0x6a')][_0x7995('0x80')],_[_0x7995('0x10a')](_0x226991[_0x7995('0x6a')],['ids','id'])||{});}})[_0x7995('0x1d')](respondWithResult(_0x36f8a1,null))[_0x7995('0x25')](handleError(_0x36f8a1,null));};exports[_0x7995('0x113')]=function(_0x24d374,_0x132c1a){var _0x3366f7={};var _0x3e452b={};var _0x2436d7;var _0x4b9dd3;return db['ChatWebsite'][_0x7995('0x7a')]({'where':{'id':_0x24d374['params']['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x132c1a,null))[_0x7995('0x1d')](function(_0x47659d){if(_0x47659d){_0x2436d7=_0x47659d;_0x3e452b['model']=_['keys'](db['ChatProactiveAction'][_0x7995('0x4f')]);_0x3e452b[_0x7995('0x53')]=_[_0x7995('0x52')](_0x24d374[_0x7995('0x53')]);_0x3e452b[_0x7995('0x5e')]=_[_0x7995('0x54')](_0x3e452b[_0x7995('0x49')],_0x3e452b[_0x7995('0x53')]);_0x3366f7['attributes']=_['intersection'](_0x3e452b['model'],qs[_0x7995('0x56')](_0x24d374['query']['fields']));_0x3366f7['attributes']=_0x3366f7[_0x7995('0x55')][_0x7995('0x57')]?_0x3366f7[_0x7995('0x55')]:_0x3e452b[_0x7995('0x49')];_0x3366f7[_0x7995('0x5a')]=qs['sort'](_0x24d374[_0x7995('0x53')]['sort']);_0x3366f7[_0x7995('0x5c')]=qs[_0x7995('0x5e')](_[_0x7995('0x5d')](_0x24d374[_0x7995('0x53')],_0x3e452b[_0x7995('0x5e')]));if(_0x24d374[_0x7995('0x53')][_0x7995('0x60')]){_0x3366f7[_0x7995('0x5c')]=_['merge'](_0x3366f7[_0x7995('0x5c')],{'$or':_[_0x7995('0x51')](_0x3366f7['attributes'],function(_0x198ba5){var _0x328677={};_0x328677[_0x198ba5]={'$like':'%'+_0x24d374[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x328677;})});}_0x3366f7=_[_0x7995('0x61')]({},_0x3366f7,_0x24d374[_0x7995('0x62')]);return _0x2436d7[_0x7995('0x113')](_0x3366f7);}})[_0x7995('0x1d')](function(_0x423751){if(_0x423751){_0x4b9dd3=_0x423751['length'];if(!_0x24d374['query']['hasOwnProperty'](_0x7995('0x59'))){_0x3366f7[_0x7995('0x2a')]=qs['limit'](_0x24d374['query']['limit']);_0x3366f7[_0x7995('0x2b')]=qs[_0x7995('0x2b')](_0x24d374['query'][_0x7995('0x2b')]);}return _0x2436d7[_0x7995('0x113')](_0x3366f7);}})[_0x7995('0x1d')](function(_0x349351){if(_0x349351){return _0x349351?{'count':_0x4b9dd3,'rows':_0x349351}:null;}})['then'](respondWithResult(_0x132c1a,null))[_0x7995('0x25')](handleError(_0x132c1a,null));};exports['getFields']=function(_0x463f2c,_0x47ecf5){var _0x2ea80c=_0x463f2c[_0x7995('0x53')]['online']===_0x7995('0x134')?'offlineForm':_0x7995('0x135');return db[_0x7995('0x4e')][_0x7995('0x68')]({'attributes':['id',_0x2ea80c],'where':{'id':_0x463f2c[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x47ecf5,null))[_0x7995('0x1d')](function(_0x4a27e7){if(_0x4a27e7){var _0x58aa57=_0x4a27e7[_0x2ea80c];var _0x5b4201=_0x58aa57&&_0x58aa57['items']?_0x58aa57[_0x7995('0x136')]:[];_0x47ecf5['send']({'fromKey':_[_0x7995('0x90')](_0x58aa57[_0x7995('0x137')])?undefined:_0x58aa57['fromKey'],'count':_0x5b4201[_0x7995('0x57')],'rows':_0x5b4201});}})['catch'](handleError(_0x47ecf5,null));};exports[_0x7995('0x138')]=function(_0x5a0510,_0x3d9091){var _0x385396={'raw':![],'where':{}};var _0x3e86a9={};var _0x219fa6={'count':0x0,'rows':[]};return db[_0x7995('0x4e')][_0x7995('0x7a')]({'where':{'id':_0x5a0510[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x3d9091,null))[_0x7995('0x1d')](function(_0x4092e2){if(_0x4092e2){_0x3e86a9[_0x7995('0x49')]=_[_0x7995('0x52')](db[_0x7995('0xe9')][_0x7995('0x4f')]);_0x3e86a9[_0x7995('0x53')]=_[_0x7995('0x52')](_0x5a0510[_0x7995('0x53')]);_0x3e86a9['filters']=_[_0x7995('0x54')](_0x3e86a9[_0x7995('0x49')],_0x3e86a9[_0x7995('0x53')]);_0x385396['attributes']=_[_0x7995('0x54')](_0x3e86a9['model'],qs[_0x7995('0x56')](_0x5a0510[_0x7995('0x53')][_0x7995('0x56')]));_0x385396[_0x7995('0x55')]=_0x385396['attributes'][_0x7995('0x57')]?_0x385396[_0x7995('0x55')]:_0x3e86a9['model'];if(!_0x5a0510['query']['hasOwnProperty'](_0x7995('0x59'))){_0x385396[_0x7995('0x2a')]=qs['limit'](_0x5a0510[_0x7995('0x53')]['limit']);_0x385396[_0x7995('0x2b')]=qs['offset'](_0x5a0510[_0x7995('0x53')][_0x7995('0x2b')]);}_0x385396['order']=qs['sort'](_0x5a0510[_0x7995('0x53')][_0x7995('0x5b')]);_0x385396[_0x7995('0x5c')]=qs['filters'](_[_0x7995('0x5d')](_0x5a0510[_0x7995('0x53')],_0x3e86a9[_0x7995('0x5e')]));_0x385396[_0x7995('0x5c')][_0x7995('0x7d')]=_0x4092e2['id'];if(_0x5a0510[_0x7995('0x53')][_0x7995('0x60')]){_0x385396[_0x7995('0x5c')]=_[_0x7995('0x61')](_0x385396['where'],{'$or':_[_0x7995('0x51')](_0x385396[_0x7995('0x55')],function(_0x1ca931){var _0x4fb2af={};_0x4fb2af[_0x1ca931]={'$like':'%'+_0x5a0510[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x4fb2af;})});}_0x385396=_['merge']({},_0x385396,_0x5a0510['options']);return db[_0x7995('0xe9')][_0x7995('0x2c')]({'where':_0x385396['where']})[_0x7995('0x1d')](function(_0x23b296){_0x219fa6['count']=_0x23b296;if(_0x5a0510[_0x7995('0x53')][_0x7995('0x67')]){_0x385396['include']=[{'all':!![]}];}else{_0x385396[_0x7995('0x63')]=[{'model':db[_0x7995('0xa8')],'as':_0x7995('0x10c'),'required':![]},{'model':db[_0x7995('0xf3')],'as':_0x7995('0x139'),'required':![]}];}return db[_0x7995('0xe9')][_0x7995('0x64')](_0x385396);})[_0x7995('0x1d')](function(_0x3ea53f){_0x219fa6[_0x7995('0x7b')]=_0x3ea53f;return _0x219fa6;});}})[_0x7995('0x1d')](respondWithFilteredResult(_0x3d9091,_0x385396))['catch'](handleError(_0x3d9091,null));};exports[_0x7995('0x13a')]=function(_0x318bf0,_0x80caf9){return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0x318bf0[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x80caf9,null))[_0x7995('0x1d')](function(_0x3f3d05){if(_0x3f3d05){return _0x3f3d05[_0x7995('0x13a')](_0x318bf0[_0x7995('0x6a')]['ids'],_[_0x7995('0x10a')](_0x318bf0['body'],['ids','id'])||{})[_0x7995('0x13b')](function(_0x39394e){for(var _0x256c33=0x0;_0x256c33<_0x318bf0['body'][_0x7995('0x80')]['length'];_0x256c33+=0x1){socket[_0x7995('0x13c')](_0x7995('0x13d'),{'UserId':Number(_0x318bf0[_0x7995('0x6a')]['ids'][_0x256c33]),'ChatWebsiteId':Number(_0x318bf0[_0x7995('0x66')]['id'])});}return _0x39394e;});}})[_0x7995('0x1d')](respondWithResult(_0x80caf9,null))['catch'](handleError(_0x80caf9,null));};exports['removeAgents']=function(_0xfae12b,_0x22750a){return db[_0x7995('0x4e')][_0x7995('0x68')]({'where':{'id':_0xfae12b[_0x7995('0x66')]['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x22750a,null))[_0x7995('0x1d')](function(_0x456dc7){if(_0x456dc7){return _0x456dc7[_0x7995('0x13e')](_0xfae12b['query']['ids'])['then'](function(){if(_[_0x7995('0x13f')](_0xfae12b[_0x7995('0x53')]['ids'])){for(var _0x3a5d1f=0x0;_0x3a5d1f<_0xfae12b[_0x7995('0x53')][_0x7995('0x80')][_0x7995('0x57')];_0x3a5d1f+=0x1){socket[_0x7995('0x13c')](_0x7995('0x140'),{'UserId':Number(_0xfae12b[_0x7995('0x53')][_0x7995('0x80')][_0x3a5d1f]),'ChatWebsiteId':Number(_0xfae12b[_0x7995('0x66')]['id'])});}}else{socket[_0x7995('0x13c')](_0x7995('0x140'),{'UserId':Number(_0xfae12b[_0x7995('0x53')][_0x7995('0x80')]),'ChatWebsiteId':Number(_0xfae12b['params']['id'])});}});}})['then'](respondWithStatusCode(_0x22750a,null))[_0x7995('0x25')](handleError(_0x22750a,null));};exports['getAgents']=function(_0x5d1bbe,_0x4d2868){var _0x465147={};var _0x3aced8={};var _0x52c6ce;var _0x440306;return db[_0x7995('0x4e')][_0x7995('0x7a')]({'where':{'id':_0x5d1bbe['params']['id']}})[_0x7995('0x1d')](handleEntityNotFound(_0x4d2868,null))[_0x7995('0x1d')](function(_0x4a53f8){if(_0x4a53f8){_0x52c6ce=_0x4a53f8;_0x3aced8['model']=_[_0x7995('0x52')](db[_0x7995('0xce')]['rawAttributes']);_0x3aced8[_0x7995('0x53')]=_[_0x7995('0x52')](_0x5d1bbe[_0x7995('0x53')]);_0x3aced8[_0x7995('0x5e')]=_['intersection'](_0x3aced8[_0x7995('0x49')],_0x3aced8[_0x7995('0x53')]);_0x465147['attributes']=_[_0x7995('0x54')](_0x3aced8[_0x7995('0x49')],qs['fields'](_0x5d1bbe[_0x7995('0x53')][_0x7995('0x56')]));_0x465147[_0x7995('0x55')]=_0x465147[_0x7995('0x55')][_0x7995('0x57')]?_0x465147[_0x7995('0x55')]:_0x3aced8['model'];_0x465147[_0x7995('0x5a')]=qs['sort'](_0x5d1bbe[_0x7995('0x53')][_0x7995('0x5b')]);_0x465147[_0x7995('0x5c')]=qs[_0x7995('0x5e')](_[_0x7995('0x5d')](_0x5d1bbe[_0x7995('0x53')],_0x3aced8['filters']));if(_0x5d1bbe[_0x7995('0x53')][_0x7995('0x60')]){_0x465147[_0x7995('0x5c')]=_[_0x7995('0x61')](_0x465147['where'],{'$or':_[_0x7995('0x51')](_0x465147[_0x7995('0x55')],function(_0x21a1e0){var _0x319cf9={};_0x319cf9[_0x21a1e0]={'$like':'%'+_0x5d1bbe[_0x7995('0x53')][_0x7995('0x60')]+'%'};return _0x319cf9;})});}_0x465147=_[_0x7995('0x61')]({},_0x465147,_0x5d1bbe[_0x7995('0x62')]);return _0x52c6ce[_0x7995('0x141')](_0x465147);}})[_0x7995('0x1d')](function(_0x5dc2aa){if(_0x5dc2aa){_0x440306=_0x5dc2aa[_0x7995('0x57')];if(!_0x5d1bbe[_0x7995('0x53')]['hasOwnProperty'](_0x7995('0x59'))){_0x465147[_0x7995('0x2a')]=qs[_0x7995('0x2a')](_0x5d1bbe[_0x7995('0x53')][_0x7995('0x2a')]);_0x465147[_0x7995('0x2b')]=qs[_0x7995('0x2b')](_0x5d1bbe['query']['offset']);}return _0x52c6ce[_0x7995('0x141')](_0x465147);}})[_0x7995('0x1d')](function(_0x2097f0){if(_0x2097f0){return _0x2097f0?{'count':_0x440306,'rows':_0x2097f0}:null;}})[_0x7995('0x1d')](respondWithResult(_0x4d2868,null))[_0x7995('0x25')](handleError(_0x4d2868,null));};
\ No newline at end of file