Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 1f3189c..21d6efb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0cfa=['cf-connecting-ip','split','firstName','format','unknown','browser','version','%s\x20%s','device','vendor','threadId','ChatInteraction','externalUrl','interaction','lastName','messageId','autoclose','applications','push','close','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','agent','Start','startRouting','EventManager','offline','difference','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','toPairs','offlineMessageBody','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','service','host','secure','authentication','auth','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','omit','getInteractions','Contact','Owner','Tag','Tags','color','tag','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','License','chatLicenseExceeded','some','remote','x-forwarded-for','x-real-ip','remoteAddress','referer','virtual','replace','render','alignment','verticalAlignment','textColor','addApplications','sequelize','transaction','ChatApplication','bulkCreate','findAndCountAll','priority','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','offlineForm','items','fromKey','getOfflineMessages','addAgents','emit','removeAgents','userChatWebsite:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','http','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','end','status','count','offset','limit','set','json','apply','reject','destroy','ChatWebsites','sendStatus','stack','name','send','index','ChatWebsite','type','key','map','keys','filters','intersection','model','query','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','VIRTUAL','options','includeAll','include','findAll','show','params','Pause','mandatoryDispositionPause','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','get','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','rawAttributes','pick','rows','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','nolimit','removeAnswers','addLogo','file','addAvatar','filename','addCustomerAvatar','addSystemAvatar','systemAvatar','join','server/files/images/logos/default_logo.svg','sitepic','getLicense','custom','isNil','existsSync','server/files/images/logos/','root','download','getAvatar','server/files/images/avatars/default_avatar.png','agentAvatar','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','setUA','headers','user-agent','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','createdAt','updatedAt','CompanyId','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','List','Contacts','Applications','account','list','orderBy','asc','ListId','contact','customerIp'];(function(_0x420b24,_0x382adc){var _0x4da552=function(_0x4e1623){while(--_0x4e1623){_0x420b24['push'](_0x420b24['shift']());}};_0x4da552(++_0x382adc);}(_0x0cfa,0x73));var _0xa0cf=function(_0x573fce,_0x27266e){_0x573fce=_0x573fce-0x0;var _0x59b45e=_0x0cfa[_0x573fce];return _0x59b45e;};'use strict';var pdf=require(_0xa0cf('0x0'));var emlformat=require(_0xa0cf('0x1'));var rimraf=require(_0xa0cf('0x2'));var zipdir=require(_0xa0cf('0x3'));var jsonpatch=require(_0xa0cf('0x4'));var rp=require(_0xa0cf('0x5'));var moment=require('moment');var BPromise=require(_0xa0cf('0x6'));var Mustache=require('mustache');var util=require(_0xa0cf('0x7'));var path=require(_0xa0cf('0x8'));var sox=require(_0xa0cf('0x9'));var csv=require(_0xa0cf('0xa'));var ejs=require(_0xa0cf('0xb'));var fs=require('fs');var _=require(_0xa0cf('0xc'));var squel=require(_0xa0cf('0xd'));var crypto=require(_0xa0cf('0xe'));var jsforce=require(_0xa0cf('0xf'));var deskjs=require(_0xa0cf('0x10'));var toCsv=require(_0xa0cf('0xa'));var querystring=require(_0xa0cf('0x11'));var Papa=require(_0xa0cf('0x12'));var Redis=require(_0xa0cf('0x13'));var authService=require(_0xa0cf('0x14'));var qs=require('../../components/parsers/qs');var as=require(_0xa0cf('0x15'));var hardwareService=require(_0xa0cf('0x16'));var logger=require('../../config/logger')(_0xa0cf('0x17'));var utils=require(_0xa0cf('0x18'));var config=require(_0xa0cf('0x19'));var licenseUtil=require(_0xa0cf('0x1a'));var db=require(_0xa0cf('0x1b'))['db'];config[_0xa0cf('0x1c')]=_[_0xa0cf('0x1d')](config[_0xa0cf('0x1c')],{'host':_0xa0cf('0x1e'),'port':0x18eb});var socket=require(_0xa0cf('0x1f'))(new Redis(config['redis']));require('./chatWebsite.socket')[_0xa0cf('0x20')](socket);var jayson=require(_0xa0cf('0x21'));var client=jayson[_0xa0cf('0x22')][_0xa0cf('0x23')]({'port':0x232c});var client9002=jayson[_0xa0cf('0x22')][_0xa0cf('0x23')]({'port':0x232a});var client9003=jayson[_0xa0cf('0x22')][_0xa0cf('0x23')]({'port':0x232b});function respondWithRpcPromise(_0x4bb3d8,_0x3072cd,_0x594304,_0x4b7638){return new BPromise(function(_0x2fe7e6,_0x3b95ff){var _0x39b6cc=_0x4b7638||client;return _0x39b6cc['request'](_0x4bb3d8,_0x594304)[_0xa0cf('0x24')](function(_0x50c7d7){logger[_0xa0cf('0x25')](_0xa0cf('0x26'),_0x3072cd,_0xa0cf('0x27'));logger[_0xa0cf('0x28')](_0xa0cf('0x29'),_0x3072cd,_0xa0cf('0x27'),JSON[_0xa0cf('0x2a')](_0x50c7d7));if(_0x50c7d7[_0xa0cf('0x2b')]){if(_0x50c7d7['error'][_0xa0cf('0x2c')]===0x1f4){logger['error'](_0xa0cf('0x26'),_0x3072cd,_0x50c7d7[_0xa0cf('0x2b')][_0xa0cf('0x2d')]);return _0x3b95ff(_0x50c7d7[_0xa0cf('0x2b')][_0xa0cf('0x2d')]);}logger[_0xa0cf('0x2b')]('ChatWebsite,\x20%s,\x20%s',_0x3072cd,_0x50c7d7[_0xa0cf('0x2b')][_0xa0cf('0x2d')]);return _0x2fe7e6(_0x50c7d7['error'][_0xa0cf('0x2d')]);}else{logger[_0xa0cf('0x25')](_0xa0cf('0x26'),_0x3072cd,_0xa0cf('0x27'));_0x2fe7e6(_0x50c7d7[_0xa0cf('0x2e')]['message']);}})[_0xa0cf('0x2f')](function(_0x5dc98c){logger['error'](_0xa0cf('0x26'),_0x3072cd,_0x5dc98c);_0x3b95ff(_0x5dc98c);});});}function respondWithStatusCode(_0xc62e20,_0x352657){_0x352657=_0x352657||0xcc;return function(_0x5c574f){if(_0x5c574f){return _0xc62e20['sendStatus'](_0x352657);}return _0xc62e20['status'](_0x352657)[_0xa0cf('0x30')]();};}function respondWithResult(_0x4dd7af,_0x55283a){_0x55283a=_0x55283a||0xc8;return function(_0x17ca69){if(_0x17ca69){return _0x4dd7af[_0xa0cf('0x31')](_0x55283a)['json'](_0x17ca69);}};}function respondWithFilteredResult(_0x53f84a,_0xb9f1e6){return function(_0x5d837d){if(_0x5d837d){var _0x2b51b4=_0x5d837d[_0xa0cf('0x32')],_0x54179b=_0xb9f1e6[_0xa0cf('0x33')],_0x567d40=_0xb9f1e6[_0xa0cf('0x33')]+_0xb9f1e6[_0xa0cf('0x34')],_0x41fd7b;if(_0x567d40>=_0x2b51b4){_0x567d40=_0x2b51b4;_0x41fd7b=0xc8;}else{_0x41fd7b=0xce;}_0x53f84a[_0xa0cf('0x31')](_0x41fd7b);return _0x53f84a[_0xa0cf('0x35')]('Content-Range',_0x54179b+'-'+_0x567d40+'/'+_0x2b51b4)[_0xa0cf('0x36')](_0x5d837d);}return null;};}function patchUpdates(_0x49b23b){return function(_0x40764f){try{jsonpatch[_0xa0cf('0x37')](_0x40764f,_0x49b23b,!![]);}catch(_0x493768){return BPromise[_0xa0cf('0x38')](_0x493768);}return _0x40764f['save']();};}function saveUpdates(_0x49c2b5,_0x6c0810){return function(_0x3105b1){if(_0x3105b1){return _0x3105b1['update'](_0x49c2b5)[_0xa0cf('0x24')](function(_0x30f1fd){return _0x30f1fd;});}return null;};}function removeEntity(_0x550fdb,_0x52a046){return function(_0x182159){if(_0x182159){return _0x182159[_0xa0cf('0x39')]()[_0xa0cf('0x24')](function(){var _0x40a99e=_0x182159['get']({'plain':!![]});var _0xd3a94=_0xa0cf('0x3a');return db['UserProfileResource']['destroy']({'where':{'type':_0xd3a94,'resourceId':_0x40a99e['id']}})[_0xa0cf('0x24')](function(){return _0x182159;});})[_0xa0cf('0x24')](function(){_0x550fdb[_0xa0cf('0x31')](0xcc)[_0xa0cf('0x30')]();});}};}function handleEntityNotFound(_0x2fe5e8,_0x1bc4e9){return function(_0x41c28e){if(!_0x41c28e){_0x2fe5e8[_0xa0cf('0x3b')](0x194);}return _0x41c28e;};}function handleError(_0x3917c5,_0x125939){_0x125939=_0x125939||0x1f4;return function(_0x3ab5d5){logger['error'](_0x3ab5d5[_0xa0cf('0x3c')]);if(_0x3ab5d5['name']){delete _0x3ab5d5[_0xa0cf('0x3d')];}_0x3917c5[_0xa0cf('0x31')](_0x125939)[_0xa0cf('0x3e')](_0x3ab5d5);};}exports[_0xa0cf('0x3f')]=function(_0x33b9a1,_0x358686){var _0x117bc3={'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x445565={},_0x42e51={'count':0x0,'rows':[]};var _0x164b13=_['map'](db[_0xa0cf('0x40')]['rawAttributes'],function(_0x54330d){return{'name':_0x54330d['fieldName'],'type':_0x54330d[_0xa0cf('0x41')][_0xa0cf('0x42')]};});_0x445565['model']=_[_0xa0cf('0x43')](_0x164b13,'name');_0x445565['query']=_[_0xa0cf('0x44')](_0x33b9a1['query']);_0x445565[_0xa0cf('0x45')]=_[_0xa0cf('0x46')](_0x445565[_0xa0cf('0x47')],_0x445565[_0xa0cf('0x48')]);_0x117bc3[_0xa0cf('0x49')]=_['intersection'](_0x445565[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x4a')]));_0x117bc3[_0xa0cf('0x49')]=_0x117bc3[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x117bc3[_0xa0cf('0x49')]:_0x445565['model'];if(!_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x4c')]('nolimit')){_0x117bc3['limit']=qs[_0xa0cf('0x34')](_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x117bc3['offset']=qs[_0xa0cf('0x33')](_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x33')]);}_0x117bc3[_0xa0cf('0x4d')]=qs[_0xa0cf('0x4e')](_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x117bc3[_0xa0cf('0x4f')]=qs[_0xa0cf('0x45')](_['pick'](_0x33b9a1[_0xa0cf('0x48')],_0x445565[_0xa0cf('0x45')]),_0x164b13);if(_0x33b9a1['query'][_0xa0cf('0x50')]){_0x117bc3[_0xa0cf('0x4f')]=_[_0xa0cf('0x51')](_0x117bc3[_0xa0cf('0x4f')],{'$or':_[_0xa0cf('0x43')](_0x164b13,function(_0x21488f){if(_0x21488f[_0xa0cf('0x41')]!==_0xa0cf('0x52')){var _0x2a8fdc={};_0x2a8fdc[_0x21488f[_0xa0cf('0x3d')]]={'$like':'%'+_0x33b9a1['query'][_0xa0cf('0x50')]+'%'};return _0x2a8fdc;}})});}_0x117bc3=_[_0xa0cf('0x51')]({},_0x117bc3,_0x33b9a1[_0xa0cf('0x53')]);var _0x487a2c={'where':_0x117bc3[_0xa0cf('0x4f')]};return db[_0xa0cf('0x40')][_0xa0cf('0x32')](_0x487a2c)[_0xa0cf('0x24')](function(_0x54a4f2){_0x42e51[_0xa0cf('0x32')]=_0x54a4f2;if(_0x33b9a1[_0xa0cf('0x48')][_0xa0cf('0x54')]){_0x117bc3[_0xa0cf('0x55')]=[{'all':!![]}];}return db[_0xa0cf('0x40')][_0xa0cf('0x56')](_0x117bc3);})[_0xa0cf('0x24')](function(_0x1eb172){_0x42e51['rows']=_0x1eb172;return _0x42e51;})[_0xa0cf('0x24')](respondWithFilteredResult(_0x358686,_0x117bc3))[_0xa0cf('0x2f')](handleError(_0x358686,null));};exports[_0xa0cf('0x57')]=function(_0x11d147,_0x40c555){var _0x396081={'raw':![],'where':{'id':_0x11d147[_0xa0cf('0x58')]['id']},'include':[{'model':db[_0xa0cf('0x59')],'as':_0xa0cf('0x5a')}]},_0x1508dd={};_0x1508dd['model']=_['keys'](db[_0xa0cf('0x40')]['rawAttributes']);_0x1508dd[_0xa0cf('0x48')]=_[_0xa0cf('0x44')](_0x11d147[_0xa0cf('0x48')]);_0x1508dd[_0xa0cf('0x45')]=_['intersection'](_0x1508dd[_0xa0cf('0x47')],_0x1508dd[_0xa0cf('0x48')]);_0x396081[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x1508dd[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x11d147[_0xa0cf('0x48')][_0xa0cf('0x4a')]));_0x396081['attributes']=_0x396081[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x396081[_0xa0cf('0x49')]:_0x1508dd[_0xa0cf('0x47')];if(_0x11d147[_0xa0cf('0x48')][_0xa0cf('0x54')]){_0x396081[_0xa0cf('0x55')]=[{'all':!![]}];}_0x396081=_[_0xa0cf('0x51')]({},_0x396081,_0x11d147[_0xa0cf('0x53')]);return db[_0xa0cf('0x40')][_0xa0cf('0x5b')](_0x396081)[_0xa0cf('0x24')](handleEntityNotFound(_0x40c555,null))[_0xa0cf('0x24')](respondWithResult(_0x40c555,null))[_0xa0cf('0x2f')](handleError(_0x40c555,null));};exports[_0xa0cf('0x5c')]=function(_0x29a6f5,_0x22f1e2){return db[_0xa0cf('0x40')]['create'](_0x29a6f5['body'],{})[_0xa0cf('0x24')](function(_0x2daa1d){var _0x3091ec=_0x29a6f5[_0xa0cf('0x5d')]['get']({'plain':!![]});if(!_0x3091ec)throw new Error(_0xa0cf('0x5e'));if(_0x3091ec['role']===_0xa0cf('0x5d')){var _0x439182=_0x2daa1d[_0xa0cf('0x5f')]({'plain':!![]});var _0x48a7ee=_0xa0cf('0x3a');return db[_0xa0cf('0x60')][_0xa0cf('0x5b')]({'where':{'name':_0x48a7ee,'userProfileId':_0x3091ec[_0xa0cf('0x61')]},'raw':!![]})['then'](function(_0xb02ca2){if(_0xb02ca2&&_0xb02ca2[_0xa0cf('0x62')]===0x0){return db['UserProfileResource'][_0xa0cf('0x5c')]({'name':_0x439182['name'],'resourceId':_0x439182['id'],'type':_0xb02ca2[_0xa0cf('0x3d')],'sectionId':_0xb02ca2['id']},{})[_0xa0cf('0x24')](function(){return _0x2daa1d;});}else{return _0x2daa1d;}})[_0xa0cf('0x2f')](function(_0x5152c1){logger[_0xa0cf('0x2b')](_0xa0cf('0x63'),_0x5152c1);throw _0x5152c1;});}return _0x2daa1d;})[_0xa0cf('0x24')](respondWithResult(_0x22f1e2,0xc9))[_0xa0cf('0x2f')](handleError(_0x22f1e2,null));};exports[_0xa0cf('0x64')]=function(_0x563da9,_0xf6a1ea){if(_0x563da9[_0xa0cf('0x65')]['id']){delete _0x563da9[_0xa0cf('0x65')]['id'];}return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x563da9[_0xa0cf('0x58')]['id']},'include':[{'model':db[_0xa0cf('0x59')],'as':_0xa0cf('0x5a')}]})[_0xa0cf('0x24')](handleEntityNotFound(_0xf6a1ea,null))[_0xa0cf('0x24')](saveUpdates(_0x563da9[_0xa0cf('0x65')],null))[_0xa0cf('0x24')](respondWithResult(_0xf6a1ea,null))[_0xa0cf('0x2f')](handleError(_0xf6a1ea,null));};exports[_0xa0cf('0x39')]=function(_0x518ea0,_0x1f2a9f){return db[_0xa0cf('0x40')]['find']({'where':{'id':_0x518ea0['params']['id']}})['then'](handleEntityNotFound(_0x1f2a9f,null))[_0xa0cf('0x24')](removeEntity(_0x1f2a9f,null))[_0xa0cf('0x2f')](handleError(_0x1f2a9f,null));};exports[_0xa0cf('0x66')]=function(_0x351ccf,_0x3f6633){return db[_0xa0cf('0x40')]['describe']()[_0xa0cf('0x24')](respondWithResult(_0x3f6633,null))['catch'](handleError(_0x3f6633,null));};exports[_0xa0cf('0x67')]=function(_0x144ba2,_0x1830f1,_0x4c3868){if(_0x144ba2[_0xa0cf('0x65')]['id']){delete _0x144ba2[_0xa0cf('0x65')]['id'];}return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x144ba2[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x1830f1,null))[_0xa0cf('0x24')](function(_0x113c1f){if(_0x113c1f){_0x144ba2['body'][_0xa0cf('0x68')]=_0x113c1f['id'];return db[_0xa0cf('0x69')][_0xa0cf('0x5c')](_0x144ba2[_0xa0cf('0x65')]);}})[_0xa0cf('0x24')](respondWithResult(_0x1830f1,null))[_0xa0cf('0x2f')](handleError(_0x1830f1,null));};exports[_0xa0cf('0x6a')]=function(_0x7a89cb,_0x11afbd,_0x1d6f88){var _0x1d13b9={'raw':![],'where':{}};var _0x5166b4={};var _0x30eafa={'count':0x0,'rows':[]};return db[_0xa0cf('0x40')]['findOne']({'where':{'id':_0x7a89cb[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x11afbd,null))['then'](function(_0x59e1f0){if(_0x59e1f0){_0x5166b4[_0xa0cf('0x47')]=_[_0xa0cf('0x44')](db[_0xa0cf('0x69')][_0xa0cf('0x6b')]);_0x5166b4['query']=_[_0xa0cf('0x44')](_0x7a89cb[_0xa0cf('0x48')]);_0x5166b4[_0xa0cf('0x45')]=_[_0xa0cf('0x46')](_0x5166b4[_0xa0cf('0x47')],_0x5166b4[_0xa0cf('0x48')]);_0x1d13b9[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x5166b4[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x7a89cb[_0xa0cf('0x48')]['fields']));_0x1d13b9[_0xa0cf('0x49')]=_0x1d13b9['attributes'][_0xa0cf('0x4b')]?_0x1d13b9[_0xa0cf('0x49')]:_0x5166b4[_0xa0cf('0x47')];if(!_0x7a89cb['query'][_0xa0cf('0x4c')]('nolimit')){_0x1d13b9[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x7a89cb[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x1d13b9[_0xa0cf('0x33')]=qs[_0xa0cf('0x33')](_0x7a89cb['query']['offset']);}_0x1d13b9[_0xa0cf('0x4d')]=qs['sort'](_0x7a89cb[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x1d13b9[_0xa0cf('0x4f')]=qs['filters'](_[_0xa0cf('0x6c')](_0x7a89cb['query'],_0x5166b4[_0xa0cf('0x45')]));_0x1d13b9[_0xa0cf('0x4f')][_0xa0cf('0x68')]=_0x59e1f0['id'];if(_0x7a89cb[_0xa0cf('0x48')][_0xa0cf('0x50')]){_0x1d13b9[_0xa0cf('0x4f')]=_[_0xa0cf('0x51')](_0x1d13b9[_0xa0cf('0x4f')],{'$or':_[_0xa0cf('0x43')](_0x1d13b9[_0xa0cf('0x49')],function(_0x3bff5f){var _0x27a7d7={};_0x27a7d7[_0x3bff5f]={'$like':'%'+_0x7a89cb[_0xa0cf('0x48')][_0xa0cf('0x50')]+'%'};return _0x27a7d7;})});}_0x1d13b9=_['merge']({},_0x1d13b9,_0x7a89cb[_0xa0cf('0x53')]);return db[_0xa0cf('0x69')][_0xa0cf('0x32')]({'where':_0x1d13b9['where']})[_0xa0cf('0x24')](function(_0x481e78){_0x30eafa[_0xa0cf('0x32')]=_0x481e78;if(_0x7a89cb['query'][_0xa0cf('0x54')]){_0x1d13b9[_0xa0cf('0x55')]=[{'all':!![]}];}return db[_0xa0cf('0x69')][_0xa0cf('0x56')](_0x1d13b9);})[_0xa0cf('0x24')](function(_0x5dddc5){_0x30eafa[_0xa0cf('0x6d')]=_0x5dddc5;return _0x30eafa;});}})[_0xa0cf('0x24')](respondWithFilteredResult(_0x11afbd,_0x1d13b9))[_0xa0cf('0x2f')](handleError(_0x11afbd,null));};exports[_0xa0cf('0x6e')]=function(_0x4e4a2e,_0x3ceb0d,_0xbc0d05){return db['ChatWebsite']['find']({'where':{'id':_0x4e4a2e[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x3ceb0d,null))[_0xa0cf('0x24')](function(_0xda7d41){if(_0xda7d41){return _0xda7d41[_0xa0cf('0x6e')](_0x4e4a2e[_0xa0cf('0x48')][_0xa0cf('0x6f')]);}})[_0xa0cf('0x24')](respondWithStatusCode(_0x3ceb0d,null))[_0xa0cf('0x2f')](handleError(_0x3ceb0d,null));};exports[_0xa0cf('0x70')]=function(_0x5c831e,_0xe71578,_0x185632){if(_0x5c831e[_0xa0cf('0x65')]['id']){delete _0x5c831e[_0xa0cf('0x65')]['id'];}return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x5c831e['params']['id']}})['then'](handleEntityNotFound(_0xe71578,null))[_0xa0cf('0x24')](function(_0x3d8217){if(_0x3d8217){_0x5c831e['body'][_0xa0cf('0x68')]=_0x3d8217['id'];return db[_0xa0cf('0x71')][_0xa0cf('0x5c')](_0x5c831e[_0xa0cf('0x65')]);}})[_0xa0cf('0x24')](respondWithResult(_0xe71578,null))[_0xa0cf('0x2f')](handleError(_0xe71578,null));};exports[_0xa0cf('0x72')]=function(_0x36a596,_0x5b83ec,_0x1e6d9e){var _0x16ba8d={'raw':![],'where':{}};var _0x309214={};var _0x4c864f={'count':0x0,'rows':[]};return db[_0xa0cf('0x40')][_0xa0cf('0x73')]({'where':{'id':_0x36a596[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x5b83ec,null))['then'](function(_0x3ec490){if(_0x3ec490){_0x309214['model']=_[_0xa0cf('0x44')](db['CannedAnswer']['rawAttributes']);_0x309214[_0xa0cf('0x48')]=_[_0xa0cf('0x44')](_0x36a596[_0xa0cf('0x48')]);_0x309214['filters']=_[_0xa0cf('0x46')](_0x309214['model'],_0x309214[_0xa0cf('0x48')]);_0x16ba8d[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x309214[_0xa0cf('0x47')],qs['fields'](_0x36a596['query'][_0xa0cf('0x4a')]));_0x16ba8d['attributes']=_0x16ba8d['attributes']['length']?_0x16ba8d[_0xa0cf('0x49')]:_0x309214['model'];if(!_0x36a596[_0xa0cf('0x48')][_0xa0cf('0x4c')](_0xa0cf('0x74'))){_0x16ba8d[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x36a596[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x16ba8d['offset']=qs['offset'](_0x36a596[_0xa0cf('0x48')][_0xa0cf('0x33')]);}_0x16ba8d[_0xa0cf('0x4d')]=qs['sort'](_0x36a596[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x16ba8d['where']=qs[_0xa0cf('0x45')](_[_0xa0cf('0x6c')](_0x36a596[_0xa0cf('0x48')],_0x309214[_0xa0cf('0x45')]));_0x16ba8d['where'][_0xa0cf('0x68')]=_0x3ec490['id'];if(_0x36a596['query']['filter']){_0x16ba8d[_0xa0cf('0x4f')]=_['merge'](_0x16ba8d[_0xa0cf('0x4f')],{'$or':_[_0xa0cf('0x43')](_0x16ba8d[_0xa0cf('0x49')],function(_0x582868){var _0x48a5d2={};_0x48a5d2[_0x582868]={'$like':'%'+_0x36a596['query'][_0xa0cf('0x50')]+'%'};return _0x48a5d2;})});}_0x16ba8d=_[_0xa0cf('0x51')]({},_0x16ba8d,_0x36a596[_0xa0cf('0x53')]);return db[_0xa0cf('0x71')][_0xa0cf('0x32')]({'where':_0x16ba8d[_0xa0cf('0x4f')]})[_0xa0cf('0x24')](function(_0x2ffb05){_0x4c864f['count']=_0x2ffb05;if(_0x36a596[_0xa0cf('0x48')]['includeAll']){_0x16ba8d[_0xa0cf('0x55')]=[{'all':!![]}];}return db[_0xa0cf('0x71')]['findAll'](_0x16ba8d);})[_0xa0cf('0x24')](function(_0x2ea0b5){_0x4c864f[_0xa0cf('0x6d')]=_0x2ea0b5;return _0x4c864f;});}})[_0xa0cf('0x24')](respondWithFilteredResult(_0x5b83ec,_0x16ba8d))[_0xa0cf('0x2f')](handleError(_0x5b83ec,null));};exports['removeAnswers']=function(_0x4e5e26,_0x191ed3,_0x33e7ff){return db[_0xa0cf('0x40')]['find']({'where':{'id':_0x4e5e26[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x191ed3,null))[_0xa0cf('0x24')](function(_0x1987aa){if(_0x1987aa){return _0x1987aa[_0xa0cf('0x75')](_0x4e5e26[_0xa0cf('0x48')][_0xa0cf('0x6f')]);}})[_0xa0cf('0x24')](respondWithStatusCode(_0x191ed3,null))[_0xa0cf('0x2f')](handleError(_0x191ed3,null));};exports[_0xa0cf('0x76')]=function(_0x4be699,_0x54db87,_0xead598){_0x4be699[_0xa0cf('0x65')]['sitepic']=_0x4be699[_0xa0cf('0x77')]['filename'];return db['ChatWebsite'][_0xa0cf('0x5b')]({'where':{'id':_0x4be699['params']['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x54db87,null))['then'](saveUpdates(_0x4be699[_0xa0cf('0x65')],null))[_0xa0cf('0x24')](respondWithResult(_0x54db87,null))[_0xa0cf('0x2f')](handleError(_0x54db87,null));};exports[_0xa0cf('0x78')]=function(_0x3e7870,_0x21e87a,_0x16866c){_0x3e7870[_0xa0cf('0x65')]['agentAvatar']=_0x3e7870[_0xa0cf('0x77')][_0xa0cf('0x79')];return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x3e7870[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x21e87a,null))[_0xa0cf('0x24')](saveUpdates(_0x3e7870[_0xa0cf('0x65')],null))[_0xa0cf('0x24')](respondWithResult(_0x21e87a,null))[_0xa0cf('0x2f')](handleError(_0x21e87a,null));};exports[_0xa0cf('0x7a')]=function(_0x523e0b,_0x28df98,_0x45d60e){_0x523e0b['body']['customerAvatar']=_0x523e0b[_0xa0cf('0x77')][_0xa0cf('0x79')];return db[_0xa0cf('0x40')]['find']({'where':{'id':_0x523e0b[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x28df98,null))['then'](saveUpdates(_0x523e0b['body'],null))[_0xa0cf('0x24')](respondWithResult(_0x28df98,null))['catch'](handleError(_0x28df98,null));};exports[_0xa0cf('0x7b')]=function(_0x17a72b,_0x5849bc,_0xafaf1e){_0x17a72b[_0xa0cf('0x65')][_0xa0cf('0x7c')]=_0x17a72b[_0xa0cf('0x77')][_0xa0cf('0x79')];return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x17a72b[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x5849bc,null))[_0xa0cf('0x24')](saveUpdates(_0x17a72b['body'],null))[_0xa0cf('0x24')](respondWithResult(_0x5849bc,null))[_0xa0cf('0x2f')](handleError(_0x5849bc,null));};exports['getLogo']=function(_0x728fda,_0x12215a,_0x48e0ca){var _0x599267=path[_0xa0cf('0x7d')](config['root'],_0xa0cf('0x7e'));var _0x3cb230={'where':{'id':_0x728fda[_0xa0cf('0x58')]['id']},'attributes':['id',_0xa0cf('0x7f')],'raw':!![]};var _0x3e8fec=![];return require(_0xa0cf('0x1a'))[_0xa0cf('0x80')]()['then'](function(_0x1fc19c){if(_0x1fc19c){_0x3e8fec=_0x1fc19c[_0xa0cf('0x81')];}})['then'](function(){return db[_0xa0cf('0x40')][_0xa0cf('0x5b')](_0x3cb230);})['then'](handleEntityNotFound(_0x12215a,null))[_0xa0cf('0x24')](function(_0x533a8b){if(_0x533a8b){if(!_[_0xa0cf('0x82')](_0x533a8b[_0xa0cf('0x7f')])){if(fs[_0xa0cf('0x83')](path[_0xa0cf('0x7d')](config['root'],_0xa0cf('0x84'),_0x533a8b['sitepic']))&&_0x3e8fec){_0x599267=path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],'server/files/images/logos/',_0x533a8b[_0xa0cf('0x7f')]);}}return _0x12215a[_0xa0cf('0x86')](_0x599267);}})[_0xa0cf('0x2f')](handleError(_0x12215a,null));};exports[_0xa0cf('0x87')]=function(_0x54a730,_0x31c9bf,_0xbd0e55){var _0x23ffd3=path['join'](config['root'],_0xa0cf('0x88'));var _0x53eabb={'where':{'id':_0x54a730[_0xa0cf('0x58')]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0xa0cf('0x40')][_0xa0cf('0x5b')](_0x53eabb)['then'](handleEntityNotFound(_0x31c9bf,null))[_0xa0cf('0x24')](function(_0xf7a5c1){if(_0xf7a5c1){if(!_[_0xa0cf('0x82')](_0xf7a5c1[_0xa0cf('0x89')])){if(fs[_0xa0cf('0x83')](path['join'](config[_0xa0cf('0x85')],_0xa0cf('0x8a'),_0xf7a5c1[_0xa0cf('0x89')]))){_0x23ffd3=path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],_0xa0cf('0x8a'),_0xf7a5c1[_0xa0cf('0x89')]);}}return _0x31c9bf['download'](_0x23ffd3);}})[_0xa0cf('0x2f')](handleError(_0x31c9bf,null));};exports[_0xa0cf('0x8b')]=function(_0x31ec7a,_0x53abaf,_0x3ca21d){var _0x425f20=path[_0xa0cf('0x7d')](config['root'],_0xa0cf('0x8c'));var _0x21afb2={'where':{'id':_0x31ec7a[_0xa0cf('0x58')]['id']},'attributes':['id',_0xa0cf('0x8d'),_0xa0cf('0x8e')],'raw':!![]};return db['ChatWebsite'][_0xa0cf('0x5b')](_0x21afb2)[_0xa0cf('0x24')](handleEntityNotFound(_0x53abaf,null))[_0xa0cf('0x24')](function(_0x1188fc){if(_0x1188fc){if(!_['isNil'](_0x1188fc[_0xa0cf('0x8d')])){if(fs['existsSync'](path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],'server/files/images/avatars/',_0x1188fc[_0xa0cf('0x8d')]))&&_0x1188fc[_0xa0cf('0x8e')]){_0x425f20=path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],'server/files/images/avatars/',_0x1188fc[_0xa0cf('0x8d')]);}}return _0x53abaf[_0xa0cf('0x86')](_0x425f20);}})['catch'](handleError(_0x53abaf,null));};exports[_0xa0cf('0x8f')]=function(_0x5da71d,_0x12e428,_0x3974ab){var _0x40bd67=path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],_0xa0cf('0x90'));var _0x5de5ea={'where':{'id':_0x5da71d[_0xa0cf('0x58')]['id']},'attributes':['id',_0xa0cf('0x7c')],'raw':!![]};return db['ChatWebsite'][_0xa0cf('0x5b')](_0x5de5ea)['then'](handleEntityNotFound(_0x12e428,null))['then'](function(_0x48ab5b){if(_0x48ab5b){if(!_[_0xa0cf('0x82')](_0x48ab5b['systemAvatar'])){if(fs[_0xa0cf('0x83')](path[_0xa0cf('0x7d')](config['root'],'server/files/images/avatars/',_0x48ab5b['systemAvatar']))){_0x40bd67=path['join'](config[_0xa0cf('0x85')],_0xa0cf('0x8a'),_0x48ab5b[_0xa0cf('0x7c')]);}}return _0x12e428['download'](_0x40bd67);}})[_0xa0cf('0x2f')](handleError(_0x12e428,null));};exports[_0xa0cf('0x91')]=function(_0x5a91be,_0x217f37,_0x200576){var _0x3a7dbf=require(_0xa0cf('0x92'));var _0x32d7ad=new _0x3a7dbf();var _0x2d9d3c=_0x32d7ad[_0xa0cf('0x93')](_0x5a91be[_0xa0cf('0x94')][_0xa0cf('0x95')])[_0xa0cf('0x96')]();var _0x3fa0ad={'body':_0x5a91be[_0xa0cf('0x65')],'channel':_0xa0cf('0x97')};var _0x40d210=[];var _0x142f53=[];var _0x4c4116={};var _0x3a2471=![];return db[_0xa0cf('0x98')]['describe']()[_0xa0cf('0x24')](function(_0x4e2a45){if(!_0x4e2a45){throw new db[(_0xa0cf('0x99'))][(_0xa0cf('0x9a'))](_0xa0cf('0x9b'));}_0x40d210=_['difference'](_['keys'](_0x4e2a45),[_0xa0cf('0x9c'),_0xa0cf('0x9d')]);_0x142f53=_['difference'](_[_0xa0cf('0x44')](_0x4e2a45),[_0xa0cf('0x9c'),_0xa0cf('0x9d'),_0xa0cf('0x9e'),'ListId']);if(_0x5a91be[_0xa0cf('0x65')]['id']){delete _0x5a91be[_0xa0cf('0x65')]['id'];}if(_[_0xa0cf('0x82')](_0x5a91be['body']['from'])){throw new db[(_0xa0cf('0x99'))][(_0xa0cf('0x9a'))](_0xa0cf('0x9f'));}if(_[_0xa0cf('0x82')](_0x5a91be[_0xa0cf('0x65')]['body'])||_0x5a91be['body'][_0xa0cf('0x65')]===''){throw new db[(_0xa0cf('0x99'))][(_0xa0cf('0x9a'))](_0xa0cf('0xa0'));}if(_['isNil'](_0x5a91be['body']['mapKey'])){throw new db['Sequelize'][(_0xa0cf('0x9a'))](_0xa0cf('0xa1')+_0x142f53);}if(!_[_0xa0cf('0xa2')](_0x142f53,_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xa3')])){throw new db['Sequelize'][(_0xa0cf('0x9a'))](_0xa0cf('0xa4')+_0x142f53);}_0x4c4116[_0x5a91be[_0xa0cf('0x65')]['mapKey']]=_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xa5')];})[_0xa0cf('0x24')](function(){return db[_0xa0cf('0x40')]['find']({'where':{'id':_0x5a91be[_0xa0cf('0x58')]['id']},'include':[{'model':db['CmList'],'as':_0xa0cf('0xa6'),'include':[{'model':db[_0xa0cf('0x98')],'as':_0xa0cf('0xa7'),'where':_0x4c4116,'limit':0x1,'order':[[_0xa0cf('0x9d'),'DESC']]}]},{'model':db['ChatApplication'],'as':_0xa0cf('0xa8')}]});})['then'](handleEntityNotFound(_0x217f37,null))[_0xa0cf('0x24')](function(_0x3cad4c){if(_0x3cad4c&&_0x3cad4c[_0xa0cf('0xa6')]){_0x3fa0ad[_0xa0cf('0xa9')]=_0x3cad4c;_0x3fa0ad['applications']=_0x3cad4c[_0xa0cf('0xa8')];_0x3fa0ad[_0xa0cf('0xaa')]=_0x3cad4c[_0xa0cf('0xa6')];_0x3fa0ad['applications']=_[_0xa0cf('0xab')](_0x3fa0ad['applications'],['priority'],[_0xa0cf('0xac')]);if(_0x3fa0ad[_0xa0cf('0xa9')]['Applications']){delete _0x3fa0ad[_0xa0cf('0xa9')]['Applications'];}if(_0x3fa0ad[_0xa0cf('0xa9')][_0xa0cf('0xa6')]&&_0x3fa0ad[_0xa0cf('0xa9')][_0xa0cf('0xa6')][_0xa0cf('0xa7')][_0xa0cf('0x4b')]){return _0x3fa0ad[_0xa0cf('0xa9')]['List'][_0xa0cf('0xa7')][0x0];}var _0x4c6548=_[_0xa0cf('0x1d')](_0x5a91be[_0xa0cf('0x65')],{'firstName':_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xa5')],'ListId':_0x3cad4c[_0xa0cf('0xad')]});_0x4c6548[_0x5a91be[_0xa0cf('0x65')]['mapKey']]=_0x5a91be[_0xa0cf('0x65')]['from'];return db[_0xa0cf('0x98')][_0xa0cf('0x5c')](_0x4c6548,{'fields':_0x40d210,'raw':!![]});}})[_0xa0cf('0x24')](handleEntityNotFound(_0x217f37,null))[_0xa0cf('0x24')](function(_0x4a5e50){_0x3fa0ad[_0xa0cf('0xae')]=_0x4a5e50;var _0x25dc79=_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xaf')];if(_0x5a91be[_0xa0cf('0x94')][_0xa0cf('0xb0')]){_0x25dc79=_0x5a91be[_0xa0cf('0x94')][_0xa0cf('0xb0')];}else if(_0x5a91be[_0xa0cf('0x94')]['x-forwarded-for']){_0x25dc79=_['first'](_0x5a91be['headers']['x-forwarded-for'][_0xa0cf('0xb1')](','));}if(_0x4a5e50){var _0x16b7d4={'ContactId':_0x4a5e50['id'],'ChatWebsiteId':_0x5a91be[_0xa0cf('0x58')]['id'],'from':(_0x4a5e50[_0xa0cf('0xb2')]||'')+'\x20'+(_0x4a5e50['lastName']||''),'customerIp':_0x25dc79,'customerPort':_0x5a91be[_0xa0cf('0x94')]['x-real-port']?_0x5a91be[_0xa0cf('0x94')]['x-real-port']:null,'referer':_0x5a91be[_0xa0cf('0x65')]['referer'],'browserName':_0x2d9d3c['browser'][_0xa0cf('0x3d')]&&_0x2d9d3c['browser']['version']?util[_0xa0cf('0xb3')]('%s\x20%s',_0x2d9d3c['browser']['name'],_0x2d9d3c['browser']['version']):_0xa0cf('0xb4'),'browserVersion':_0x2d9d3c[_0xa0cf('0xb5')][_0xa0cf('0xb6')]||_0xa0cf('0xb4'),'osName':util[_0xa0cf('0xb3')](_0xa0cf('0xb7'),_0x2d9d3c['os'][_0xa0cf('0x3d')],_0x2d9d3c['os']['version']),'osVersion':_0x2d9d3c['os'][_0xa0cf('0xb6')],'deviceModel':_0x2d9d3c[_0xa0cf('0xb8')][_0xa0cf('0x47')]&&_0x2d9d3c[_0xa0cf('0xb8')][_0xa0cf('0xb9')]?util[_0xa0cf('0xb3')]('%s\x20%s\x20%s',_0x2d9d3c['device']['model'],_0x2d9d3c['device'][_0xa0cf('0xb9')],_0x2d9d3c[_0xa0cf('0xb8')]['type']):null,'deviceVendor':_0x2d9d3c['device'][_0xa0cf('0xb9')],'deviceType':_0x2d9d3c['device'][_0xa0cf('0x41')],'formData':JSON['stringify'](_0x5a91be['body'])};var _0x5208e6={'ChatWebsiteId':_0x5a91be[_0xa0cf('0x58')]['id'],'closed':![]};if(_0x5a91be['body']['threadId']){_0x5208e6[_0xa0cf('0xba')]=_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xba')];return db[_0xa0cf('0xbb')][_0xa0cf('0x5b')]({'where':_0x5208e6})['then'](function(_0x1e0499){if(_0x1e0499){return[_0x1e0499,![]];}_0x16b7d4[_0xa0cf('0xba')]=_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xba')];_0x16b7d4[_0xa0cf('0xbc')]=_0x5a91be['body'][_0xa0cf('0xbc')];return db[_0xa0cf('0xbb')][_0xa0cf('0x5c')](_0x16b7d4)['then'](function(_0x1f0cfc){return[_0x1f0cfc,!![]];});});}_0x5208e6['ContactId']=_0x4a5e50['id'];if(_0x5a91be[_0xa0cf('0x65')]['interaction']&&_0x5a91be[_0xa0cf('0x65')]['interaction']['id']){_0x5208e6['id']=_0x5a91be['body'][_0xa0cf('0xbd')]['id'];return db[_0xa0cf('0xbb')]['find']({'where':_0x5208e6})[_0xa0cf('0x24')](function(_0x12c3d6){if(_0x12c3d6){return[_0x12c3d6,![]];}return db[_0xa0cf('0xbb')][_0xa0cf('0x5c')](_0x16b7d4)['then'](function(_0x291e35){return[_0x291e35,!![]];});});}return db[_0xa0cf('0xbb')][_0xa0cf('0x5c')](_0x16b7d4)[_0xa0cf('0x24')](function(_0x4b13e6){return[_0x4b13e6,!![]];});}})['spread'](function(_0x76486a,_0x4b8f87){if(_0x76486a){_0x3a2471=_0x4b8f87;if(!_0x4b8f87){var _0x11b483={'from':(_0x3fa0ad[_0xa0cf('0xae')][_0xa0cf('0xb2')]||'')+'\x20'+(_0x3fa0ad[_0xa0cf('0xae')][_0xa0cf('0xbe')]||'')};if(_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xba')]&&_0x5a91be['body'][_0xa0cf('0xbf')]&&_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xba')]!=_0x5a91be[_0xa0cf('0x65')]['messageId']){_0x11b483[_0xa0cf('0xba')]=_0x5a91be['body']['messageId'];}return _0x76486a[_0xa0cf('0x64')](_0x11b483);}else{return _0x76486a;}}})[_0xa0cf('0x24')](function(_0x23b1d4){_0x3fa0ad['interaction']=_0x23b1d4[_0xa0cf('0x5f')]({'plain':!![]});_0x3fa0ad['interaction']['created']=_0x3a2471;if(_0x3fa0ad[_0xa0cf('0xbd')]['created']){if(_0x3fa0ad[_0xa0cf('0xa9')][_0xa0cf('0xc0')]){_0x3fa0ad[_0xa0cf('0xc1')][_0xa0cf('0xc2')]({'id':0x0,'priority':_0x3fa0ad[_0xa0cf('0xc1')][_0xa0cf('0x4b')]+0x1,'app':_0xa0cf('0xc3'),'appdata':'unmanaged','interval':_0xa0cf('0xc4')});}}return db[_0xa0cf('0xc5')][_0xa0cf('0x5c')]({'body':_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0x65')],'ChatWebsiteId':_0x5a91be[_0xa0cf('0x58')]['id'],'ChatInteractionId':_0x23b1d4['id'],'direction':'in','ContactId':_0x3fa0ad[_0xa0cf('0xae')]['id'],'AttachmentId':_0x5a91be[_0xa0cf('0x65')][_0xa0cf('0xc6')]});})[_0xa0cf('0x24')](function(_0x386b13){_0x3fa0ad[_0xa0cf('0x2d')]=_0x386b13;if(_0x3fa0ad[_0xa0cf('0xbd')][_0xa0cf('0xc7')]){return db[_0xa0cf('0xc8')][_0xa0cf('0x5b')]({'attributes':['id',_0xa0cf('0x3d')],'where':{'id':_0x3fa0ad['interaction'][_0xa0cf('0xc7')]}})['then'](function(_0x3b745a){if(_0x3b745a){_0x3fa0ad[_0xa0cf('0xc1')][_0xa0cf('0xc9')]({'id':0x0,'priority':0x0,'app':_0xa0cf('0xca'),'appdata':_0x3b745a[_0xa0cf('0x3d')]+','+(_0x3fa0ad['account']['waitForTheAssignedAgent']||0xa),'interval':_0xa0cf('0xc4')});_0x3fa0ad['forcedOwnership']=!![];}return respondWithRpcPromise(_0xa0cf('0xcb'),'startRouting',_0x3fa0ad);});}return respondWithRpcPromise(_0xa0cf('0xcb'),_0xa0cf('0xcc'),_0x3fa0ad);})[_0xa0cf('0x24')](function(_0x5ad5fc){respondWithRpcPromise(_0xa0cf('0xcd'),'EventManager',{'event':_0xa0cf('0x91'),'message':_0x5ad5fc},client9002);return _0x5ad5fc;})[_0xa0cf('0x24')](respondWithResult(_0x217f37,null))[_0xa0cf('0x2f')](handleError(_0x217f37,null));};exports[_0xa0cf('0xce')]=function(_0x5358b6,_0x3a2ee3,_0x3af154){var _0x5a044a,_0xd33c7d,_0x3b56b7;var _0x56fb68=[];var _0x3928ba=[];var _0x505456={};return db['CmContact']['describe']()[_0xa0cf('0x24')](function(_0x32066e){if(!_0x32066e){throw new db[(_0xa0cf('0x99'))]['ValidationError'](_0xa0cf('0x9b'));}_0x3928ba=_[_0xa0cf('0xcf')](_[_0xa0cf('0x44')](_0x32066e),[_0xa0cf('0x9c'),_0xa0cf('0x9d')]);_0x56fb68=_[_0xa0cf('0xcf')](_[_0xa0cf('0x44')](_0x32066e),[_0xa0cf('0x9c'),_0xa0cf('0x9d'),'CompanyId','ListId']);if(_0x5358b6[_0xa0cf('0x65')]['id']){delete _0x5358b6['body']['id'];}if(_['isNil'](_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0xa5')])){throw _0x3a2ee3['status'](0x1f4)['send'](new db['Sequelize'][(_0xa0cf('0x9a'))]('from\x20is\x20mandatory'));}if(_['isNil'](_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0x65')])||_0x5358b6['body'][_0xa0cf('0x65')]===''){throw _0x3a2ee3[_0xa0cf('0x31')](0x1f4)[_0xa0cf('0x3e')](new db[(_0xa0cf('0x99'))][(_0xa0cf('0x9a'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xa0cf('0x82')](_0x5358b6['body'][_0xa0cf('0xd0')])){throw _0x3a2ee3['status'](0x1f4)[_0xa0cf('0x3e')](new db[(_0xa0cf('0x99'))][(_0xa0cf('0x9a'))](_0xa0cf('0xd1')+_0x56fb68));}if(!_[_0xa0cf('0xa2')](_0x56fb68,_0x5358b6['body'][_0xa0cf('0xd0')])){throw _0x3a2ee3[_0xa0cf('0x31')](0x1f4)[_0xa0cf('0x3e')](new db[(_0xa0cf('0x99'))]['ValidationError'](_0xa0cf('0xd2')+_0x56fb68));}_0x505456[_0x5358b6[_0xa0cf('0x65')]['mapKeyOffline']]=_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0xa5')];})[_0xa0cf('0x24')](function(){return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x5358b6[_0xa0cf('0x58')]['id']},'include':[{'model':db['CmList'],'as':_0xa0cf('0xa6')}]});})[_0xa0cf('0x24')](handleEntityNotFound(_0x3a2ee3,null))[_0xa0cf('0x24')](function(_0x340ffd){if(_0x340ffd&&_0x340ffd['List']){_0xd33c7d=_0x340ffd;var _0x50db1b=_[_0xa0cf('0x1d')](_0x5358b6[_0xa0cf('0x65')],{'firstName':_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0xa5')],'phone':_0x5358b6['body'][_0xa0cf('0xa5')],'ListId':_0x340ffd[_0xa0cf('0xad')]});_0x50db1b[_0x5358b6[_0xa0cf('0x65')]['mapKeyOffline']]=_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0xa5')];return db['CmContact'][_0xa0cf('0xd3')]({'where':_0x505456,'defaults':_0x50db1b});}})[_0xa0cf('0xd4')](function(_0x2533e9){if(_0x2533e9){_0x3b56b7=_0x2533e9;var _0x22bae0=fs[_0xa0cf('0xd5')](path[_0xa0cf('0x7d')](config[_0xa0cf('0x85')],_0xa0cf('0xd6')),_0xa0cf('0xd7'));var _0x2ab1f8=ejs['render'](_0x22bae0,{'body':_[_0xa0cf('0xd8')](_0x5358b6[_0xa0cf('0x65')][_0xa0cf('0x65')]),'bodyTitle':_0xd33c7d[_0xa0cf('0xd9')]});return db[_0xa0cf('0xda')][_0xa0cf('0x5c')]({'body':_0x2ab1f8,'ContactId':_0x2533e9['id'],'ChatWebsiteId':_0xd33c7d['id']});}})[_0xa0cf('0x24')](function(_0x4bea45){if(_0x4bea45){_0x5a044a=_0x4bea45;return db[_0xa0cf('0xdb')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0xa0cf('0xdc')],'as':_0xa0cf('0xdd'),'raw':!![]}]});}})['then'](function(_0x232ee2){if(_0x232ee2&&_0x232ee2[_0xa0cf('0xdd')]&&_0xd33c7d['forwardOfflineAddress']){var _0x5595ad={'tls':{'rejectUnauthorized':![]}};if(_0x232ee2['Smtp'][_0xa0cf('0xde')]){_0x5595ad[_0xa0cf('0xde')]=_0x232ee2[_0xa0cf('0xdd')][_0xa0cf('0xde')];}else{_0x5595ad[_0xa0cf('0xdf')]=_0x232ee2['Smtp'][_0xa0cf('0xdf')];_0x5595ad['port']=_0x232ee2['Smtp']['port'];_0x5595ad[_0xa0cf('0xe0')]=_0x232ee2[_0xa0cf('0xdd')][_0xa0cf('0xe0')];}if(_0x232ee2[_0xa0cf('0xdd')][_0xa0cf('0xe1')]){_0x5595ad[_0xa0cf('0xe2')]={'user':_0x232ee2[_0xa0cf('0xdd')][_0xa0cf('0x5d')],'pass':_0x232ee2['Smtp']['pass']};}return respondWithRpcPromise(_0xa0cf('0xe3'),_0xa0cf('0xe4'),{'account':_0x5595ad,'message':{'from':util[_0xa0cf('0xb3')](_0xa0cf('0xe5'),_0x232ee2[_0xa0cf('0x3d')],_0x232ee2[_0xa0cf('0xe6')]||_0x232ee2[_0xa0cf('0xdd')][_0xa0cf('0x5d')]),'to':_0xd33c7d['forwardOfflineAddress'],'subject':_0xd33c7d[_0xa0cf('0xe7')],'text':_0x5a044a[_0xa0cf('0x65')]}},client9003)[_0xa0cf('0x24')](function(){return _0x5a044a;})['catch'](function(_0x3f88a2){console[_0xa0cf('0x2b')](_0x3f88a2);});}})[_0xa0cf('0x24')](function(){if(_0x5a044a){return _0x5a044a;}})['then'](respondWithResult(_0x3a2ee3,null))[_0xa0cf('0x2f')](handleError(_0x3a2ee3,null));};exports[_0xa0cf('0xe8')]=function(_0x20a0ba,_0xcecb49,_0x2d1b11){return db['ChatInteraction'][_0xa0cf('0x5b')]({'where':{'id':_0x20a0ba[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0xcecb49,null))['then'](function(_0x96f6d5){if(_0x96f6d5){return _0x96f6d5[_0xa0cf('0xe8')](_0x20a0ba[_0xa0cf('0x65')]['ids'],_[_0xa0cf('0xe9')](_0x20a0ba[_0xa0cf('0x65')],[_0xa0cf('0x6f'),'id'])||{});}})['then'](respondWithResult(_0xcecb49,null))[_0xa0cf('0x2f')](handleError(_0xcecb49,null));};exports[_0xa0cf('0xea')]=function(_0x249496,_0x5028b8,_0x37b5f1){var _0x3cd3eb={'raw':![],'where':{}};var _0x1377c6={};var _0x17075d={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x249496[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x5028b8,null))[_0xa0cf('0x24')](function(_0x22e758){if(_0x22e758){_0x1377c6[_0xa0cf('0x47')]=_[_0xa0cf('0x44')](db[_0xa0cf('0xbb')][_0xa0cf('0x6b')]);_0x1377c6[_0xa0cf('0x48')]=_['keys'](_0x249496[_0xa0cf('0x48')]);_0x1377c6[_0xa0cf('0x45')]=_['intersection'](_0x1377c6[_0xa0cf('0x47')],_0x1377c6[_0xa0cf('0x48')]);_0x3cd3eb[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x1377c6[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x249496[_0xa0cf('0x48')]['fields']));_0x3cd3eb['attributes']=_0x3cd3eb[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x3cd3eb[_0xa0cf('0x49')]:_0x1377c6[_0xa0cf('0x47')];if(!_0x249496['query'][_0xa0cf('0x4c')]('nolimit')){_0x3cd3eb[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x249496[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x3cd3eb[_0xa0cf('0x33')]=qs[_0xa0cf('0x33')](_0x249496[_0xa0cf('0x48')][_0xa0cf('0x33')]);}_0x3cd3eb[_0xa0cf('0x4d')]=qs[_0xa0cf('0x4e')](_0x249496[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x3cd3eb[_0xa0cf('0x4f')]=qs[_0xa0cf('0x45')](_['pick'](_0x249496[_0xa0cf('0x48')],_0x1377c6[_0xa0cf('0x45')]));_0x3cd3eb[_0xa0cf('0x4f')][_0xa0cf('0x68')]=_0x22e758['id'];if(_0x249496['query'][_0xa0cf('0x50')]){_0x3cd3eb[_0xa0cf('0x4f')]=_[_0xa0cf('0x51')](_0x3cd3eb[_0xa0cf('0x4f')],{'$or':_[_0xa0cf('0x43')](_0x3cd3eb[_0xa0cf('0x49')],function(_0xe04daa){var _0x2325b6={};_0x2325b6[_0xe04daa]={'$like':'%'+_0x249496[_0xa0cf('0x48')][_0xa0cf('0x50')]+'%'};return _0x2325b6;})});}_0x3cd3eb=_[_0xa0cf('0x51')]({},_0x3cd3eb,_0x249496['options']);return db['ChatInteraction']['count']({'where':_0x3cd3eb['where']})[_0xa0cf('0x24')](function(_0xb0cc52){_0x17075d['count']=_0xb0cc52;if(_0x249496[_0xa0cf('0x48')][_0xa0cf('0x54')]){_0x3cd3eb[_0xa0cf('0x55')]=[{'model':db[_0xa0cf('0x98')],'as':_0xa0cf('0xeb'),'required':![]},{'model':db[_0xa0cf('0xc8')],'as':_0xa0cf('0xec'),'attributes':[_0xa0cf('0x3d'),'fullname','internal'],'required':![]},{'model':db[_0xa0cf('0xed')],'as':_0xa0cf('0xee'),'attributes':['id',_0xa0cf('0x3d'),_0xa0cf('0xef')],'where':_0x249496[_0xa0cf('0x48')]['tag']?{'id':_0x249496[_0xa0cf('0x48')][_0xa0cf('0xf0')]}:undefined,'required':_0x249496[_0xa0cf('0x48')][_0xa0cf('0xf0')]?!![]:![]}];}return db[_0xa0cf('0xbb')][_0xa0cf('0x56')](_0x3cd3eb);})[_0xa0cf('0x24')](function(_0x1c24a8){_0x17075d[_0xa0cf('0x6d')]=_0x1c24a8;return _0x17075d;});}})['then'](respondWithFilteredResult(_0x5028b8,_0x3cd3eb))[_0xa0cf('0x2f')](handleError(_0x5028b8,null));};function iftimePromise(_0x4f8664,_0x562505){return respondWithRpcPromise('Command',_0xa0cf('0xf1'),{'command':_0x562505[_0xa0cf('0xf2')]?util[_0xa0cf('0xb3')](_0xa0cf('0xf3'),_0x4f8664[_0xa0cf('0xf4')],_0x562505[_0xa0cf('0xf2')]):util['format'](_0xa0cf('0xf5'),_0x4f8664['interval'])},client9002)['then'](function(_0x17bbd1){var _0x9ddead=_0x17bbd1&&_0x17bbd1[_0xa0cf('0xf6')](_0xa0cf('0xf7'))>=0x0?!![]:![];logger['info'](_0xa0cf('0xf8'),_0x562505['id'],_0x4f8664['id'],_0x4f8664[_0xa0cf('0xf4')],_0x9ddead?_0xa0cf('0xf9'):'OFFLINE',_0x562505[_0xa0cf('0xf2')]?_0x562505[_0xa0cf('0xf2')]:_0xa0cf('0xfa'));return _0x9ddead;})[_0xa0cf('0x2f')](function(_0x1471a4){logger[_0xa0cf('0x2b')](_0xa0cf('0xf8'),_0x562505['id'],_0x4f8664['id'],_0x4f8664[_0xa0cf('0xf4')],util[_0xa0cf('0xfb')](_0x1471a4,{'showHidden':![],'depth':null}),_0x562505[_0xa0cf('0xf2')]?_0x562505[_0xa0cf('0xf2')]:_0xa0cf('0xfa'));return![];});}exports[_0xa0cf('0xf1')]=function(_0x22a5f4,_0x25e3be,_0x7ed0d2){var _0x2470b6=0x0;var _0x13be66=0x0;var _0x174e17=![];var _0x32d279;var _0x399638;return db['ChatWebsite']['find']({'where':{'id':_0x22a5f4[_0xa0cf('0x58')]['id']},'include':[{'model':db[_0xa0cf('0xfc')],'as':_0xa0cf('0xfc'),'include':[{'model':db[_0xa0cf('0xfc')],'as':_0xa0cf('0xfd'),'attributes':['id',_0xa0cf('0xf4')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x25e3be,null))[_0xa0cf('0x24')](function(_0x58b7ce){if(_0x58b7ce){_0x32d279=_0x58b7ce;return _0x58b7ce[_0xa0cf('0xfe')]({'raw':!![]});}})[_0xa0cf('0x24')](function(_0x4fe245){if(_0x32d279){if(_0x4fe245){_0x399638=_0x4fe245;}}return require('../../config/license/util')[_0xa0cf('0x80')]();})[_0xa0cf('0x24')](function(_0x47f779){if(_0x47f779){_0x13be66=_0x47f779['virtual'];_0x174e17=_0x47f779[_0xa0cf('0x81')];}})[_0xa0cf('0x24')](function(){return db['ChatInteraction'][_0xa0cf('0x32')]({'where':{'closed':![]}});})[_0xa0cf('0x24')](function(_0x219f13){_0x2470b6=_0x219f13;if(_0x13be66&&_0x219f13>_0x13be66){return db[_0xa0cf('0xff')][_0xa0cf('0x73')]({'where':{'id':0x1}})[_0xa0cf('0x24')](function(_0x232c8e){if(_0x232c8e){_0x232c8e['increment'](_0xa0cf('0x100'));}});}})[_0xa0cf('0x24')](function(){if(_0x32d279[_0xa0cf('0xfc')]&&_0x32d279[_0xa0cf('0xfc')][_0xa0cf('0xfd')]){var _0x4623aa=[];for(var _0x4dec9f=0x0;_0x4dec9f<_0x32d279[_0xa0cf('0xfc')][_0xa0cf('0xfd')][_0xa0cf('0x4b')];_0x4dec9f++){var _0x5f5543=_0x32d279[_0xa0cf('0xfc')][_0xa0cf('0xfd')][_0x4dec9f][_0xa0cf('0x5f')]({'plain':!![]});_0x4623aa[_0xa0cf('0xc2')](iftimePromise(_0x5f5543,_0x32d279));}return BPromise['all'](_0x4623aa)['then'](function(_0x3d6928){return _[_0xa0cf('0x101')](_0x3d6928);});}else{return!![];}})[_0xa0cf('0x24')](function(_0x497f7d){var _0x4b3b88=fs[_0xa0cf('0xd5')](path['join'](config[_0xa0cf('0x85')],'server/files/chat/iframe.js'),_0xa0cf('0xd7'));var _0x5ef6e5={'remote':_0x32d279[_0xa0cf('0x102')],'query':querystring[_0xa0cf('0x2a')](_['merge'](_0x32d279[_0xa0cf('0x5f')]({'plain':!![]}),{'customerIp':_0x22a5f4[_0xa0cf('0x94')][_0xa0cf('0x103')]||_0x22a5f4['headers'][_0xa0cf('0x104')]||_0x22a5f4['connection'][_0xa0cf('0x105')]||_0x22a5f4['ip'],'referer':_0x22a5f4[_0xa0cf('0x94')][_0xa0cf('0x106')],'openedInteractions':_0x2470b6,'maxInteractions':_0x13be66,'virtual':_0x174e17[_0xa0cf('0x107')],'online':_0x497f7d,'custom':_0x174e17}))[_0xa0cf('0x108')](/'/g,'\x5c\x27')};_0x25e3be[_0xa0cf('0x3e')](ejs['render'](Mustache[_0xa0cf('0x109')](_0x4b3b88,_0x5ef6e5),{'proactiveActions':_0x399638,'alignment':_0x32d279[_0xa0cf('0x10a')],'verticalAlignment':_0x32d279[_0xa0cf('0x10b')],'div_color':_0x32d279[_0xa0cf('0xef')],'text_color':_0x32d279[_0xa0cf('0x10c')]}));})[_0xa0cf('0x2f')](handleError(_0x25e3be,null));};exports[_0xa0cf('0x10d')]=function(_0x208d38,_0x42e3b4,_0x3f3d73){return db[_0xa0cf('0x40')][_0xa0cf('0x73')]({'where':{'id':_0x208d38[_0xa0cf('0x58')]['id']}})['then'](handleEntityNotFound(_0x42e3b4,null))['then'](function(_0x2197d3){if(_0x2197d3){return db[_0xa0cf('0x10e')][_0xa0cf('0x10f')](function(_0x5a29b5){return db[_0xa0cf('0x110')][_0xa0cf('0x39')]({'where':{'ChatWebsiteId':_0x208d38['params']['id']},'transaction':_0x5a29b5})[_0xa0cf('0x24')](function(_0x4899b0){var _0x49b2e9=_[_0xa0cf('0x43')](_0x208d38['body'],function(_0x57ae6e){_0x57ae6e[_0xa0cf('0x68')]=_0x208d38[_0xa0cf('0x58')]['id'];return _0x57ae6e;});return db[_0xa0cf('0x110')][_0xa0cf('0x111')](_0x49b2e9,{'transaction':_0x5a29b5});});})[_0xa0cf('0x24')](function(){return db[_0xa0cf('0x110')][_0xa0cf('0x112')]({'where':{'ChatWebsiteId':_0x208d38[_0xa0cf('0x58')]['id']},'order':_0xa0cf('0x113')});});}})[_0xa0cf('0x24')](respondWithResult(_0x42e3b4,null))[_0xa0cf('0x2f')](handleError(_0x42e3b4,null));};exports[_0xa0cf('0x114')]=function(_0x10f4de,_0x4f880a,_0x312a5c){var _0x1f70d3={};var _0x3f5938={};var _0x242670;var _0x1eedbc;return db[_0xa0cf('0x40')]['findOne']({'where':{'id':_0x10f4de['params']['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x4f880a,null))[_0xa0cf('0x24')](function(_0x40e5f3){if(_0x40e5f3){_0x242670=_0x40e5f3;_0x3f5938['model']=_[_0xa0cf('0x44')](db[_0xa0cf('0x110')][_0xa0cf('0x6b')]);_0x3f5938[_0xa0cf('0x48')]=_[_0xa0cf('0x44')](_0x10f4de['query']);_0x3f5938[_0xa0cf('0x45')]=_[_0xa0cf('0x46')](_0x3f5938[_0xa0cf('0x47')],_0x3f5938[_0xa0cf('0x48')]);_0x1f70d3['attributes']=_['intersection'](_0x3f5938[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x10f4de[_0xa0cf('0x48')][_0xa0cf('0x4a')]));_0x1f70d3[_0xa0cf('0x49')]=_0x1f70d3[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x1f70d3[_0xa0cf('0x49')]:_0x3f5938[_0xa0cf('0x47')];_0x1f70d3['order']=qs[_0xa0cf('0x4e')](_0x10f4de[_0xa0cf('0x48')]['sort']);_0x1f70d3[_0xa0cf('0x4f')]=qs[_0xa0cf('0x45')](_[_0xa0cf('0x6c')](_0x10f4de[_0xa0cf('0x48')],_0x3f5938[_0xa0cf('0x45')]));if(_0x10f4de[_0xa0cf('0x48')][_0xa0cf('0x50')]){_0x1f70d3['where']=_[_0xa0cf('0x51')](_0x1f70d3[_0xa0cf('0x4f')],{'$or':_[_0xa0cf('0x43')](_0x1f70d3['attributes'],function(_0x19f120){var _0x9a78b2={};_0x9a78b2[_0x19f120]={'$like':'%'+_0x10f4de['query']['filter']+'%'};return _0x9a78b2;})});}_0x1f70d3=_[_0xa0cf('0x51')]({},_0x1f70d3,_0x10f4de[_0xa0cf('0x53')]);return _0x242670[_0xa0cf('0x114')](_0x1f70d3);}})[_0xa0cf('0x24')](function(_0x140cb7){if(_0x140cb7){_0x1eedbc=_0x140cb7[_0xa0cf('0x4b')];if(!_0x10f4de[_0xa0cf('0x48')][_0xa0cf('0x4c')](_0xa0cf('0x74'))){_0x1f70d3[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x10f4de[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x1f70d3[_0xa0cf('0x33')]=qs[_0xa0cf('0x33')](_0x10f4de[_0xa0cf('0x48')][_0xa0cf('0x33')]);}return _0x242670['getApplications'](_0x1f70d3);}})[_0xa0cf('0x24')](function(_0x2a7323){if(_0x2a7323){return _0x2a7323?{'count':_0x1eedbc,'rows':_0x2a7323}:null;}})[_0xa0cf('0x24')](respondWithResult(_0x4f880a,null))[_0xa0cf('0x2f')](handleError(_0x4f880a,null));};exports[_0xa0cf('0x115')]=function(_0x1c4ce9,_0x24d661,_0x5096c1){return db[_0xa0cf('0x116')]['find']({'where':{'id':_0x1c4ce9[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x24d661,null))['then'](function(_0x5c110b){if(_0x5c110b){return _0x5c110b[_0xa0cf('0x115')](_0x1c4ce9[_0xa0cf('0x65')][_0xa0cf('0x6f')],_[_0xa0cf('0xe9')](_0x1c4ce9[_0xa0cf('0x65')],[_0xa0cf('0x6f'),'id'])||{});}})['then'](respondWithResult(_0x24d661,null))[_0xa0cf('0x2f')](handleError(_0x24d661,null));};exports[_0xa0cf('0xfe')]=function(_0x54be38,_0x3cefc9,_0x15d9e6){var _0x170a81={};var _0xdbbdc2={};var _0x2f1dc5;var _0x589fc4;return db[_0xa0cf('0x40')][_0xa0cf('0x73')]({'where':{'id':_0x54be38[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x3cefc9,null))[_0xa0cf('0x24')](function(_0x358e88){if(_0x358e88){_0x2f1dc5=_0x358e88;_0xdbbdc2['model']=_[_0xa0cf('0x44')](db[_0xa0cf('0x117')][_0xa0cf('0x6b')]);_0xdbbdc2['query']=_[_0xa0cf('0x44')](_0x54be38[_0xa0cf('0x48')]);_0xdbbdc2[_0xa0cf('0x45')]=_[_0xa0cf('0x46')](_0xdbbdc2[_0xa0cf('0x47')],_0xdbbdc2[_0xa0cf('0x48')]);_0x170a81[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0xdbbdc2['model'],qs['fields'](_0x54be38[_0xa0cf('0x48')][_0xa0cf('0x4a')]));_0x170a81[_0xa0cf('0x49')]=_0x170a81[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x170a81['attributes']:_0xdbbdc2[_0xa0cf('0x47')];_0x170a81[_0xa0cf('0x4d')]=qs['sort'](_0x54be38[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x170a81['where']=qs['filters'](_['pick'](_0x54be38['query'],_0xdbbdc2[_0xa0cf('0x45')]));if(_0x54be38[_0xa0cf('0x48')][_0xa0cf('0x50')]){_0x170a81['where']=_['merge'](_0x170a81[_0xa0cf('0x4f')],{'$or':_['map'](_0x170a81[_0xa0cf('0x49')],function(_0x268e5e){var _0x384254={};_0x384254[_0x268e5e]={'$like':'%'+_0x54be38[_0xa0cf('0x48')]['filter']+'%'};return _0x384254;})});}_0x170a81=_[_0xa0cf('0x51')]({},_0x170a81,_0x54be38[_0xa0cf('0x53')]);return _0x2f1dc5[_0xa0cf('0xfe')](_0x170a81);}})[_0xa0cf('0x24')](function(_0x150e7d){if(_0x150e7d){_0x589fc4=_0x150e7d[_0xa0cf('0x4b')];if(!_0x54be38['query']['hasOwnProperty'](_0xa0cf('0x74'))){_0x170a81[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x54be38[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x170a81[_0xa0cf('0x33')]=qs[_0xa0cf('0x33')](_0x54be38[_0xa0cf('0x48')]['offset']);}return _0x2f1dc5[_0xa0cf('0xfe')](_0x170a81);}})['then'](function(_0x4da107){if(_0x4da107){return _0x4da107?{'count':_0x589fc4,'rows':_0x4da107}:null;}})['then'](respondWithResult(_0x3cefc9,null))[_0xa0cf('0x2f')](handleError(_0x3cefc9,null));};exports[_0xa0cf('0x118')]=function(_0x32c5f4,_0x2a2111,_0x3c5489){var _0x5c9b9e=_0x32c5f4[_0xa0cf('0x48')][_0xa0cf('0x119')]==='false'?_0xa0cf('0x11a'):'onlineForm';return db['ChatWebsite'][_0xa0cf('0x5b')]({'attributes':['id',_0x5c9b9e],'where':{'id':_0x32c5f4[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x2a2111,null))['then'](function(_0x2b6ff1){if(_0x2b6ff1){var _0x4ed570=_0x2b6ff1[_0x5c9b9e];var _0x54b796=_0x4ed570&&_0x4ed570[_0xa0cf('0x11b')]?_0x4ed570[_0xa0cf('0x11b')]:[];_0x2a2111['send']({'fromKey':_['isNil'](_0x4ed570['fromKey'])?undefined:_0x4ed570[_0xa0cf('0x11c')],'count':_0x54b796[_0xa0cf('0x4b')],'rows':_0x54b796});}})[_0xa0cf('0x2f')](handleError(_0x2a2111,null));};exports[_0xa0cf('0x11d')]=function(_0x21b182,_0x22494d,_0x1f6bc4){var _0x2fb85d={'raw':![],'where':{}};var _0x552084={};var _0x51ba40={'count':0x0,'rows':[]};return db[_0xa0cf('0x40')][_0xa0cf('0x73')]({'where':{'id':_0x21b182['params']['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x22494d,null))[_0xa0cf('0x24')](function(_0x21ee2a){if(_0x21ee2a){_0x552084['model']=_[_0xa0cf('0x44')](db[_0xa0cf('0xda')][_0xa0cf('0x6b')]);_0x552084[_0xa0cf('0x48')]=_['keys'](_0x21b182['query']);_0x552084['filters']=_[_0xa0cf('0x46')](_0x552084[_0xa0cf('0x47')],_0x552084[_0xa0cf('0x48')]);_0x2fb85d[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x552084[_0xa0cf('0x47')],qs['fields'](_0x21b182[_0xa0cf('0x48')]['fields']));_0x2fb85d[_0xa0cf('0x49')]=_0x2fb85d[_0xa0cf('0x49')]['length']?_0x2fb85d[_0xa0cf('0x49')]:_0x552084[_0xa0cf('0x47')];if(!_0x21b182[_0xa0cf('0x48')][_0xa0cf('0x4c')]('nolimit')){_0x2fb85d[_0xa0cf('0x34')]=qs[_0xa0cf('0x34')](_0x21b182[_0xa0cf('0x48')][_0xa0cf('0x34')]);_0x2fb85d[_0xa0cf('0x33')]=qs[_0xa0cf('0x33')](_0x21b182[_0xa0cf('0x48')]['offset']);}_0x2fb85d[_0xa0cf('0x4d')]=qs[_0xa0cf('0x4e')](_0x21b182[_0xa0cf('0x48')][_0xa0cf('0x4e')]);_0x2fb85d[_0xa0cf('0x4f')]=qs[_0xa0cf('0x45')](_[_0xa0cf('0x6c')](_0x21b182['query'],_0x552084[_0xa0cf('0x45')]));_0x2fb85d[_0xa0cf('0x4f')][_0xa0cf('0x68')]=_0x21ee2a['id'];if(_0x21b182['query']['filter']){_0x2fb85d[_0xa0cf('0x4f')]=_[_0xa0cf('0x51')](_0x2fb85d['where'],{'$or':_[_0xa0cf('0x43')](_0x2fb85d['attributes'],function(_0x170da7){var _0x38528c={};_0x38528c[_0x170da7]={'$like':'%'+_0x21b182[_0xa0cf('0x48')][_0xa0cf('0x50')]+'%'};return _0x38528c;})});}_0x2fb85d=_[_0xa0cf('0x51')]({},_0x2fb85d,_0x21b182[_0xa0cf('0x53')]);return db[_0xa0cf('0xda')][_0xa0cf('0x32')]({'where':_0x2fb85d['where']})[_0xa0cf('0x24')](function(_0x52a96b){_0x51ba40['count']=_0x52a96b;if(_0x21b182[_0xa0cf('0x48')][_0xa0cf('0x54')]){_0x2fb85d['include']=[{'all':!![]}];}else{_0x2fb85d['include']=[{'model':db[_0xa0cf('0x98')],'as':'Contact','required':![]}];}return db[_0xa0cf('0xda')][_0xa0cf('0x56')](_0x2fb85d);})['then'](function(_0x301f8b){_0x51ba40['rows']=_0x301f8b;return _0x51ba40;});}})[_0xa0cf('0x24')](respondWithFilteredResult(_0x22494d,_0x2fb85d))[_0xa0cf('0x2f')](handleError(_0x22494d,null));};exports[_0xa0cf('0x11e')]=function(_0x4c8d92,_0x5c96f1,_0x361431){return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x4c8d92[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x5c96f1,null))['then'](function(_0x4f6f1e){if(_0x4f6f1e){return _0x4f6f1e[_0xa0cf('0x11e')](_0x4c8d92[_0xa0cf('0x65')][_0xa0cf('0x6f')],_[_0xa0cf('0xe9')](_0x4c8d92[_0xa0cf('0x65')],['ids','id'])||{})[_0xa0cf('0xd4')](function(_0xbfeada){for(var _0xf8ddfe=0x0;_0xf8ddfe<_0x4c8d92['body'][_0xa0cf('0x6f')][_0xa0cf('0x4b')];_0xf8ddfe+=0x1){socket[_0xa0cf('0x11f')]('userChatWebsite:save',{'UserId':_0x4c8d92['body']['ids'][_0xf8ddfe],'ChatWebsiteId':_0x4c8d92['params']['id']});}return _0xbfeada;});}})['then'](respondWithResult(_0x5c96f1,null))[_0xa0cf('0x2f')](handleError(_0x5c96f1,null));};exports['removeAgents']=function(_0x3d97fb,_0x3a92a0,_0x91c7b4){return db[_0xa0cf('0x40')][_0xa0cf('0x5b')]({'where':{'id':_0x3d97fb[_0xa0cf('0x58')]['id']}})['then'](handleEntityNotFound(_0x3a92a0,null))['then'](function(_0x107f09){if(_0x107f09){return _0x107f09[_0xa0cf('0x120')](_0x3d97fb['query']['ids'])[_0xa0cf('0x24')](function(){if(_['isArray'](_0x3d97fb[_0xa0cf('0x48')]['ids'])){for(var _0x2e8441=0x0;_0x2e8441<_0x3d97fb['query'][_0xa0cf('0x6f')][_0xa0cf('0x4b')];_0x2e8441+=0x1){socket[_0xa0cf('0x11f')](_0xa0cf('0x121'),{'UserId':Number(_0x3d97fb['query'][_0xa0cf('0x6f')][_0x2e8441]),'ChatWebsiteId':Number(_0x3d97fb[_0xa0cf('0x58')]['id'])});}}else{socket[_0xa0cf('0x11f')]('userChatWebsite:remove',{'UserId':Number(_0x3d97fb['query'][_0xa0cf('0x6f')]),'ChatWebsiteId':Number(_0x3d97fb[_0xa0cf('0x58')]['id'])});}});}})['then'](respondWithStatusCode(_0x3a92a0,null))[_0xa0cf('0x2f')](handleError(_0x3a92a0,null));};exports[_0xa0cf('0x122')]=function(_0x9e08e9,_0x41f2b0,_0x77dd5a){var _0x5db4ca={};var _0x4fef94={};var _0x322769;var _0x43604a;return db[_0xa0cf('0x40')][_0xa0cf('0x73')]({'where':{'id':_0x9e08e9[_0xa0cf('0x58')]['id']}})[_0xa0cf('0x24')](handleEntityNotFound(_0x41f2b0,null))[_0xa0cf('0x24')](function(_0x3de80c){if(_0x3de80c){_0x322769=_0x3de80c;_0x4fef94['model']=_[_0xa0cf('0x44')](db['User'][_0xa0cf('0x6b')]);_0x4fef94[_0xa0cf('0x48')]=_['keys'](_0x9e08e9['query']);_0x4fef94[_0xa0cf('0x45')]=_[_0xa0cf('0x46')](_0x4fef94[_0xa0cf('0x47')],_0x4fef94['query']);_0x5db4ca[_0xa0cf('0x49')]=_[_0xa0cf('0x46')](_0x4fef94[_0xa0cf('0x47')],qs[_0xa0cf('0x4a')](_0x9e08e9['query'][_0xa0cf('0x4a')]));_0x5db4ca[_0xa0cf('0x49')]=_0x5db4ca[_0xa0cf('0x49')][_0xa0cf('0x4b')]?_0x5db4ca[_0xa0cf('0x49')]:_0x4fef94[_0xa0cf('0x47')];_0x5db4ca[_0xa0cf('0x4d')]=qs[_0xa0cf('0x4e')](_0x9e08e9['query'][_0xa0cf('0x4e')]);_0x5db4ca[_0xa0cf('0x4f')]=qs[_0xa0cf('0x45')](_[_0xa0cf('0x6c')](_0x9e08e9['query'],_0x4fef94[_0xa0cf('0x45')]));if(_0x9e08e9['query']['filter']){_0x5db4ca[_0xa0cf('0x4f')]=_[_0xa0cf('0x51')](_0x5db4ca['where'],{'$or':_[_0xa0cf('0x43')](_0x5db4ca['attributes'],function(_0x350d79){var _0x50e3ca={};_0x50e3ca[_0x350d79]={'$like':'%'+_0x9e08e9['query']['filter']+'%'};return _0x50e3ca;})});}_0x5db4ca=_['merge']({},_0x5db4ca,_0x9e08e9[_0xa0cf('0x53')]);return _0x322769[_0xa0cf('0x122')](_0x5db4ca);}})['then'](function(_0x257ca6){if(_0x257ca6){_0x43604a=_0x257ca6[_0xa0cf('0x4b')];if(!_0x9e08e9[_0xa0cf('0x48')][_0xa0cf('0x4c')]('nolimit')){_0x5db4ca['limit']=qs[_0xa0cf('0x34')](_0x9e08e9['query'][_0xa0cf('0x34')]);_0x5db4ca['offset']=qs[_0xa0cf('0x33')](_0x9e08e9[_0xa0cf('0x48')][_0xa0cf('0x33')]);}return _0x322769[_0xa0cf('0x122')](_0x5db4ca);}})[_0xa0cf('0x24')](function(_0x5afee7){if(_0x5afee7){return _0x5afee7?{'count':_0x43604a,'rows':_0x5afee7}:null;}})['then'](respondWithResult(_0x41f2b0,null))[_0xa0cf('0x2f')](handleError(_0x41f2b0,null));};
\ No newline at end of file
+var _0x9a9f=['mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','readFileSync','utf8','toPairs','findOne','forwardOfflineAddress','Smtp','service','host','port','secure','authentication','auth','SendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','getInteractions','Owner','fullname','internal','Tag','Tags','color','tag','Command','timezone','interval','iftime\x20%s','indexOf','true','ONLINE','OFFLINE','No\x20timezone','getSnippet','Interval','getProactiveActions','virtual','License','increment','chatLicenseExceeded','Intervals','all','some','server/files/chat/iframe.js','x-real-ip','connection','remoteAddress','render','alignment','verticalAlignment','addApplications','sequelize','transaction','bulkCreate','getApplications','addProactiveActions','chatProactiveAction','omit','getFields','online','offlineForm','onlineForm','items','fromKey','Contact','ChatOfflineMessage','addAgents','userChatWebsite:save','removeAgents','emit','getAgents','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','path','sox','to-csv','lodash','crypto','jsforce','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','reject','save','update','get','ChatWebsites','UserProfileResource','destroy','stack','name','Pause','mandatoryDispositionPause','rawAttributes','fieldName','type','key','model','map','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','ChatWebsite','includeAll','include','findAll','rows','show','keys','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','Disposition','getDispositions','ChatWebsiteId','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','pick','sitepic','file','filename','addAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','custom','isNil','server/files/images/logos/','getAvatar','server/files/images/avatars/default_avatar.png','agentAvatar','existsSync','server/files/images/avatars/','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','download','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','setUA','headers','user-agent','getResult','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','CmContact','DESC','ChatApplication','Applications','account','applications','orderBy','priority','asc','Contacts','contact','customerIp','cf-connecting-ip','x-forwarded-for','firstName','lastName','x-real-port','referer','browser','version','unknown','format','%s\x20%s','device','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','push','close','*,*,*,*','ChatMessage','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','ListId','send','mapKeyOffline'];(function(_0x4856bb,_0x28071a){var _0xdd03df=function(_0x53a971){while(--_0x53a971){_0x4856bb['push'](_0x4856bb['shift']());}};_0xdd03df(++_0x28071a);}(_0x9a9f,0x163));var _0xf9a9=function(_0x6484f4,_0x508902){_0x6484f4=_0x6484f4-0x0;var _0x52bfc9=_0x9a9f[_0x6484f4];return _0x52bfc9;};'use strict';var pdf=require(_0xf9a9('0x0'));var emlformat=require(_0xf9a9('0x1'));var rimraf=require(_0xf9a9('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf9a9('0x3'));var rp=require(_0xf9a9('0x4'));var moment=require(_0xf9a9('0x5'));var BPromise=require(_0xf9a9('0x6'));var Mustache=require('mustache');var util=require('util');var path=require(_0xf9a9('0x7'));var sox=require(_0xf9a9('0x8'));var csv=require(_0xf9a9('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xf9a9('0xa'));var squel=require('squel');var crypto=require(_0xf9a9('0xb'));var jsforce=require(_0xf9a9('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf9a9('0xd'));var Redis=require(_0xf9a9('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xf9a9('0xf'));var as=require(_0xf9a9('0x10'));var hardwareService=require(_0xf9a9('0x11'));var logger=require(_0xf9a9('0x12'))(_0xf9a9('0x13'));var utils=require('../../config/utils');var config=require(_0xf9a9('0x14'));var licenseUtil=require(_0xf9a9('0x15'));var db=require(_0xf9a9('0x16'))['db'];config[_0xf9a9('0x17')]=_[_0xf9a9('0x18')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf9a9('0x17')]));require(_0xf9a9('0x19'))[_0xf9a9('0x1a')](socket);var jayson=require(_0xf9a9('0x1b'));var client=jayson[_0xf9a9('0x1c')][_0xf9a9('0x1d')]({'port':0x232c});var client9002=jayson[_0xf9a9('0x1c')][_0xf9a9('0x1d')]({'port':0x232a});var client9003=jayson[_0xf9a9('0x1c')]['http']({'port':0x232b});function respondWithRpcPromise(_0x2ddf70,_0x2b8c0c,_0x12ffce,_0x1c6bd7){return new BPromise(function(_0xcaffb5,_0x552fc0){var _0x531dd2=_0x1c6bd7||client;return _0x531dd2[_0xf9a9('0x1e')](_0x2ddf70,_0x12ffce)[_0xf9a9('0x1f')](function(_0x3edf46){logger[_0xf9a9('0x20')](_0xf9a9('0x21'),_0x2b8c0c,_0xf9a9('0x22'));logger[_0xf9a9('0x23')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x2b8c0c,_0xf9a9('0x22'),JSON['stringify'](_0x3edf46));if(_0x3edf46[_0xf9a9('0x24')]){if(_0x3edf46['error'][_0xf9a9('0x25')]===0x1f4){logger[_0xf9a9('0x24')](_0xf9a9('0x21'),_0x2b8c0c,_0x3edf46[_0xf9a9('0x24')][_0xf9a9('0x26')]);return _0x552fc0(_0x3edf46['error']['message']);}logger[_0xf9a9('0x24')](_0xf9a9('0x21'),_0x2b8c0c,_0x3edf46[_0xf9a9('0x24')]['message']);return _0xcaffb5(_0x3edf46[_0xf9a9('0x24')]['message']);}else{logger[_0xf9a9('0x20')]('ChatWebsite,\x20%s,\x20%s',_0x2b8c0c,'request\x20sent');_0xcaffb5(_0x3edf46['result'][_0xf9a9('0x26')]);}})[_0xf9a9('0x27')](function(_0x5b0053){logger[_0xf9a9('0x24')]('ChatWebsite,\x20%s,\x20%s',_0x2b8c0c,_0x5b0053);_0x552fc0(_0x5b0053);});});}function respondWithStatusCode(_0x20732f,_0x35de14){_0x35de14=_0x35de14||0xcc;return function(_0x482756){if(_0x482756){return _0x20732f[_0xf9a9('0x28')](_0x35de14);}return _0x20732f[_0xf9a9('0x29')](_0x35de14)[_0xf9a9('0x2a')]();};}function respondWithResult(_0x40724a,_0x445b6d){_0x445b6d=_0x445b6d||0xc8;return function(_0x5e93b5){if(_0x5e93b5){return _0x40724a[_0xf9a9('0x29')](_0x445b6d)['json'](_0x5e93b5);}};}function respondWithFilteredResult(_0x34bd0c,_0x370ea9){return function(_0x5a3d0a){if(_0x5a3d0a){var _0x4b2bca=_0x5a3d0a[_0xf9a9('0x2b')],_0x398492=_0x370ea9[_0xf9a9('0x2c')],_0x417a6e=_0x370ea9[_0xf9a9('0x2c')]+_0x370ea9[_0xf9a9('0x2d')],_0xfc520b;if(_0x417a6e>=_0x4b2bca){_0x417a6e=_0x4b2bca;_0xfc520b=0xc8;}else{_0xfc520b=0xce;}_0x34bd0c[_0xf9a9('0x29')](_0xfc520b);return _0x34bd0c[_0xf9a9('0x2e')](_0xf9a9('0x2f'),_0x398492+'-'+_0x417a6e+'/'+_0x4b2bca)[_0xf9a9('0x30')](_0x5a3d0a);}return null;};}function patchUpdates(_0x154446){return function(_0x22dbe0){try{jsonpatch[_0xf9a9('0x31')](_0x22dbe0,_0x154446,!![]);}catch(_0x156255){return BPromise[_0xf9a9('0x32')](_0x156255);}return _0x22dbe0[_0xf9a9('0x33')]();};}function saveUpdates(_0x203c6a,_0x495c1f){return function(_0x2a43c3){if(_0x2a43c3){return _0x2a43c3[_0xf9a9('0x34')](_0x203c6a)[_0xf9a9('0x1f')](function(_0x31a14a){return _0x31a14a;});}return null;};}function removeEntity(_0x7d7731,_0x4d52d8){return function(_0x52b1c7){if(_0x52b1c7){return _0x52b1c7['destroy']()[_0xf9a9('0x1f')](function(){var _0x38c05d=_0x52b1c7[_0xf9a9('0x35')]({'plain':!![]});var _0x3aa1d3=_0xf9a9('0x36');return db[_0xf9a9('0x37')][_0xf9a9('0x38')]({'where':{'type':_0x3aa1d3,'resourceId':_0x38c05d['id']}})[_0xf9a9('0x1f')](function(){return _0x52b1c7;});})[_0xf9a9('0x1f')](function(){_0x7d7731[_0xf9a9('0x29')](0xcc)[_0xf9a9('0x2a')]();});}};}function handleEntityNotFound(_0x2beba3,_0x16b25e){return function(_0xa0fb30){if(!_0xa0fb30){_0x2beba3[_0xf9a9('0x28')](0x194);}return _0xa0fb30;};}function handleError(_0x270a59,_0x24460b){_0x24460b=_0x24460b||0x1f4;return function(_0xe4c2a1){logger[_0xf9a9('0x24')](_0xe4c2a1[_0xf9a9('0x39')]);if(_0xe4c2a1[_0xf9a9('0x3a')]){delete _0xe4c2a1[_0xf9a9('0x3a')];}_0x270a59[_0xf9a9('0x29')](_0x24460b)['send'](_0xe4c2a1);};}exports['index']=function(_0x4c4cad,_0x2c3be3){var _0x49fc53={'include':[{'model':db[_0xf9a9('0x3b')],'as':_0xf9a9('0x3c')}]},_0x3a3f59={},_0x14589e={'count':0x0,'rows':[]};var _0x5058c0=_['map'](db['ChatWebsite'][_0xf9a9('0x3d')],function(_0x2fabed){return{'name':_0x2fabed[_0xf9a9('0x3e')],'type':_0x2fabed[_0xf9a9('0x3f')][_0xf9a9('0x40')]};});_0x3a3f59[_0xf9a9('0x41')]=_[_0xf9a9('0x42')](_0x5058c0,'name');_0x3a3f59[_0xf9a9('0x43')]=_['keys'](_0x4c4cad[_0xf9a9('0x43')]);_0x3a3f59[_0xf9a9('0x44')]=_[_0xf9a9('0x45')](_0x3a3f59[_0xf9a9('0x41')],_0x3a3f59[_0xf9a9('0x43')]);_0x49fc53[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0x3a3f59[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x4c4cad[_0xf9a9('0x43')]['fields']));_0x49fc53[_0xf9a9('0x46')]=_0x49fc53[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x49fc53[_0xf9a9('0x46')]:_0x3a3f59[_0xf9a9('0x41')];if(!_0x4c4cad['query'][_0xf9a9('0x49')](_0xf9a9('0x4a'))){_0x49fc53[_0xf9a9('0x2d')]=qs[_0xf9a9('0x2d')](_0x4c4cad['query'][_0xf9a9('0x2d')]);_0x49fc53['offset']=qs[_0xf9a9('0x2c')](_0x4c4cad[_0xf9a9('0x43')][_0xf9a9('0x2c')]);}_0x49fc53[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x4c4cad[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x49fc53[_0xf9a9('0x4d')]=qs['filters'](_['pick'](_0x4c4cad[_0xf9a9('0x43')],_0x3a3f59[_0xf9a9('0x44')]),_0x5058c0);if(_0x4c4cad[_0xf9a9('0x43')][_0xf9a9('0x4e')]){_0x49fc53[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x49fc53['where'],{'$or':_[_0xf9a9('0x42')](_0x5058c0,function(_0x480cda){if(_0x480cda[_0xf9a9('0x3f')]!==_0xf9a9('0x50')){var _0x1d1a96={};_0x1d1a96[_0x480cda[_0xf9a9('0x3a')]]={'$like':'%'+_0x4c4cad[_0xf9a9('0x43')]['filter']+'%'};return _0x1d1a96;}})});}_0x49fc53=_[_0xf9a9('0x4f')]({},_0x49fc53,_0x4c4cad[_0xf9a9('0x51')]);var _0x3ecff1={'where':_0x49fc53[_0xf9a9('0x4d')]};return db[_0xf9a9('0x52')][_0xf9a9('0x2b')](_0x3ecff1)['then'](function(_0x4e0859){_0x14589e['count']=_0x4e0859;if(_0x4c4cad['query'][_0xf9a9('0x53')]){_0x49fc53[_0xf9a9('0x54')]=[{'all':!![]}];}return db[_0xf9a9('0x52')][_0xf9a9('0x55')](_0x49fc53);})[_0xf9a9('0x1f')](function(_0x29196a){_0x14589e[_0xf9a9('0x56')]=_0x29196a;return _0x14589e;})[_0xf9a9('0x1f')](respondWithFilteredResult(_0x2c3be3,_0x49fc53))[_0xf9a9('0x27')](handleError(_0x2c3be3,null));};exports[_0xf9a9('0x57')]=function(_0x442cdc,_0x1f0978){var _0x440248={'raw':![],'where':{'id':_0x442cdc['params']['id']},'include':[{'model':db[_0xf9a9('0x3b')],'as':_0xf9a9('0x3c')}]},_0x135a4a={};_0x135a4a['model']=_[_0xf9a9('0x58')](db[_0xf9a9('0x52')][_0xf9a9('0x3d')]);_0x135a4a[_0xf9a9('0x43')]=_['keys'](_0x442cdc[_0xf9a9('0x43')]);_0x135a4a['filters']=_[_0xf9a9('0x45')](_0x135a4a['model'],_0x135a4a[_0xf9a9('0x43')]);_0x440248[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0x135a4a[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x442cdc['query'][_0xf9a9('0x47')]));_0x440248[_0xf9a9('0x46')]=_0x440248['attributes'][_0xf9a9('0x48')]?_0x440248[_0xf9a9('0x46')]:_0x135a4a[_0xf9a9('0x41')];if(_0x442cdc[_0xf9a9('0x43')][_0xf9a9('0x53')]){_0x440248[_0xf9a9('0x54')]=[{'all':!![]}];}_0x440248=_['merge']({},_0x440248,_0x442cdc[_0xf9a9('0x51')]);return db[_0xf9a9('0x52')][_0xf9a9('0x59')](_0x440248)[_0xf9a9('0x1f')](handleEntityNotFound(_0x1f0978,null))['then'](respondWithResult(_0x1f0978,null))['catch'](handleError(_0x1f0978,null));};exports[_0xf9a9('0x5a')]=function(_0x540154,_0x1531f1){return db[_0xf9a9('0x52')]['create'](_0x540154[_0xf9a9('0x5b')],{})[_0xf9a9('0x1f')](function(_0x45aa59){var _0x1c69d5=_0x540154['user'][_0xf9a9('0x35')]({'plain':!![]});if(!_0x1c69d5)throw new Error(_0xf9a9('0x5c'));if(_0x1c69d5[_0xf9a9('0x5d')]===_0xf9a9('0x5e')){var _0x56e7bd=_0x45aa59[_0xf9a9('0x35')]({'plain':!![]});var _0x2949f4='ChatWebsites';return db[_0xf9a9('0x5f')][_0xf9a9('0x59')]({'where':{'name':_0x2949f4,'userProfileId':_0x1c69d5[_0xf9a9('0x60')]},'raw':!![]})[_0xf9a9('0x1f')](function(_0x47bd53){if(_0x47bd53&&_0x47bd53['autoAssociation']===0x0){return db['UserProfileResource'][_0xf9a9('0x5a')]({'name':_0x56e7bd['name'],'resourceId':_0x56e7bd['id'],'type':_0x47bd53['name'],'sectionId':_0x47bd53['id']},{})[_0xf9a9('0x1f')](function(){return _0x45aa59;});}else{return _0x45aa59;}})[_0xf9a9('0x27')](function(_0x1c985f){logger[_0xf9a9('0x24')](_0xf9a9('0x61'),_0x1c985f);throw _0x1c985f;});}return _0x45aa59;})[_0xf9a9('0x1f')](respondWithResult(_0x1531f1,0xc9))[_0xf9a9('0x27')](handleError(_0x1531f1,null));};exports[_0xf9a9('0x34')]=function(_0x40e38b,_0x2b8846){if(_0x40e38b[_0xf9a9('0x5b')]['id']){delete _0x40e38b[_0xf9a9('0x5b')]['id'];}return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x40e38b[_0xf9a9('0x62')]['id']},'include':[{'model':db[_0xf9a9('0x3b')],'as':_0xf9a9('0x3c')}]})[_0xf9a9('0x1f')](handleEntityNotFound(_0x2b8846,null))[_0xf9a9('0x1f')](saveUpdates(_0x40e38b['body'],null))[_0xf9a9('0x1f')](respondWithResult(_0x2b8846,null))['catch'](handleError(_0x2b8846,null));};exports['destroy']=function(_0x4ad057,_0x4b2cb8){return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x4ad057[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x4b2cb8,null))[_0xf9a9('0x1f')](removeEntity(_0x4b2cb8,null))[_0xf9a9('0x27')](handleError(_0x4b2cb8,null));};exports[_0xf9a9('0x63')]=function(_0x81fc9d,_0x2349ba){return db[_0xf9a9('0x52')][_0xf9a9('0x63')]()[_0xf9a9('0x1f')](respondWithResult(_0x2349ba,null))[_0xf9a9('0x27')](handleError(_0x2349ba,null));};exports[_0xf9a9('0x64')]=function(_0x45990c,_0x2feb80,_0x56dbb5){if(_0x45990c[_0xf9a9('0x5b')]['id']){delete _0x45990c[_0xf9a9('0x5b')]['id'];}return db[_0xf9a9('0x52')]['find']({'where':{'id':_0x45990c[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x2feb80,null))['then'](function(_0x3d1c84){if(_0x3d1c84){_0x45990c[_0xf9a9('0x5b')]['ChatWebsiteId']=_0x3d1c84['id'];return db[_0xf9a9('0x65')]['create'](_0x45990c[_0xf9a9('0x5b')]);}})[_0xf9a9('0x1f')](respondWithResult(_0x2feb80,null))[_0xf9a9('0x27')](handleError(_0x2feb80,null));};exports[_0xf9a9('0x66')]=function(_0x285f78,_0x597c71,_0x57db57){var _0x4b0a3c={'raw':![],'where':{}};var _0x1f1a19={};var _0x3e8dee={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x285f78[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x597c71,null))[_0xf9a9('0x1f')](function(_0xc428a2){if(_0xc428a2){_0x1f1a19[_0xf9a9('0x41')]=_[_0xf9a9('0x58')](db[_0xf9a9('0x65')][_0xf9a9('0x3d')]);_0x1f1a19['query']=_['keys'](_0x285f78[_0xf9a9('0x43')]);_0x1f1a19['filters']=_[_0xf9a9('0x45')](_0x1f1a19[_0xf9a9('0x41')],_0x1f1a19[_0xf9a9('0x43')]);_0x4b0a3c['attributes']=_[_0xf9a9('0x45')](_0x1f1a19[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x47')]));_0x4b0a3c[_0xf9a9('0x46')]=_0x4b0a3c['attributes'][_0xf9a9('0x48')]?_0x4b0a3c[_0xf9a9('0x46')]:_0x1f1a19['model'];if(!_0x285f78[_0xf9a9('0x43')]['hasOwnProperty'](_0xf9a9('0x4a'))){_0x4b0a3c[_0xf9a9('0x2d')]=qs[_0xf9a9('0x2d')](_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x4b0a3c[_0xf9a9('0x2c')]=qs[_0xf9a9('0x2c')](_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x2c')]);}_0x4b0a3c[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x4b0a3c['where']=qs['filters'](_['pick'](_0x285f78['query'],_0x1f1a19[_0xf9a9('0x44')]));_0x4b0a3c[_0xf9a9('0x4d')][_0xf9a9('0x67')]=_0xc428a2['id'];if(_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x4e')]){_0x4b0a3c[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x4b0a3c[_0xf9a9('0x4d')],{'$or':_[_0xf9a9('0x42')](_0x4b0a3c[_0xf9a9('0x46')],function(_0x357d84){var _0x5dd53a={};_0x5dd53a[_0x357d84]={'$like':'%'+_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x4e')]+'%'};return _0x5dd53a;})});}_0x4b0a3c=_[_0xf9a9('0x4f')]({},_0x4b0a3c,_0x285f78[_0xf9a9('0x51')]);return db[_0xf9a9('0x65')][_0xf9a9('0x2b')]({'where':_0x4b0a3c[_0xf9a9('0x4d')]})[_0xf9a9('0x1f')](function(_0x2015eb){_0x3e8dee[_0xf9a9('0x2b')]=_0x2015eb;if(_0x285f78[_0xf9a9('0x43')][_0xf9a9('0x53')]){_0x4b0a3c['include']=[{'all':!![]}];}return db[_0xf9a9('0x65')][_0xf9a9('0x55')](_0x4b0a3c);})[_0xf9a9('0x1f')](function(_0x2132f9){_0x3e8dee[_0xf9a9('0x56')]=_0x2132f9;return _0x3e8dee;});}})[_0xf9a9('0x1f')](respondWithFilteredResult(_0x597c71,_0x4b0a3c))['catch'](handleError(_0x597c71,null));};exports[_0xf9a9('0x68')]=function(_0x5526af,_0xda2277,_0x3921b8){return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x5526af[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0xda2277,null))['then'](function(_0x186d23){if(_0x186d23){return _0x186d23[_0xf9a9('0x68')](_0x5526af['query'][_0xf9a9('0x69')]);}})[_0xf9a9('0x1f')](respondWithStatusCode(_0xda2277,null))[_0xf9a9('0x27')](handleError(_0xda2277,null));};exports[_0xf9a9('0x6a')]=function(_0x248bb2,_0x1f3661,_0x392a78){if(_0x248bb2[_0xf9a9('0x5b')]['id']){delete _0x248bb2[_0xf9a9('0x5b')]['id'];}return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x248bb2['params']['id']}})['then'](handleEntityNotFound(_0x1f3661,null))[_0xf9a9('0x1f')](function(_0x222062){if(_0x222062){_0x248bb2[_0xf9a9('0x5b')][_0xf9a9('0x67')]=_0x222062['id'];return db[_0xf9a9('0x6b')]['create'](_0x248bb2[_0xf9a9('0x5b')]);}})[_0xf9a9('0x1f')](respondWithResult(_0x1f3661,null))[_0xf9a9('0x27')](handleError(_0x1f3661,null));};exports[_0xf9a9('0x6c')]=function(_0x17f4e4,_0x2a042e,_0x216f00){var _0x3931e5={'raw':![],'where':{}};var _0x2501ca={};var _0x410045={'count':0x0,'rows':[]};return db[_0xf9a9('0x52')]['findOne']({'where':{'id':_0x17f4e4[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x2a042e,null))['then'](function(_0x5dc71c){if(_0x5dc71c){_0x2501ca[_0xf9a9('0x41')]=_['keys'](db[_0xf9a9('0x6b')][_0xf9a9('0x3d')]);_0x2501ca[_0xf9a9('0x43')]=_[_0xf9a9('0x58')](_0x17f4e4['query']);_0x2501ca[_0xf9a9('0x44')]=_['intersection'](_0x2501ca[_0xf9a9('0x41')],_0x2501ca[_0xf9a9('0x43')]);_0x3931e5['attributes']=_[_0xf9a9('0x45')](_0x2501ca['model'],qs['fields'](_0x17f4e4[_0xf9a9('0x43')]['fields']));_0x3931e5[_0xf9a9('0x46')]=_0x3931e5[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x3931e5[_0xf9a9('0x46')]:_0x2501ca[_0xf9a9('0x41')];if(!_0x17f4e4[_0xf9a9('0x43')][_0xf9a9('0x49')](_0xf9a9('0x4a'))){_0x3931e5[_0xf9a9('0x2d')]=qs['limit'](_0x17f4e4['query'][_0xf9a9('0x2d')]);_0x3931e5[_0xf9a9('0x2c')]=qs[_0xf9a9('0x2c')](_0x17f4e4['query'][_0xf9a9('0x2c')]);}_0x3931e5[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x17f4e4[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x3931e5[_0xf9a9('0x4d')]=qs[_0xf9a9('0x44')](_[_0xf9a9('0x6d')](_0x17f4e4['query'],_0x2501ca['filters']));_0x3931e5[_0xf9a9('0x4d')][_0xf9a9('0x67')]=_0x5dc71c['id'];if(_0x17f4e4[_0xf9a9('0x43')]['filter']){_0x3931e5['where']=_[_0xf9a9('0x4f')](_0x3931e5['where'],{'$or':_[_0xf9a9('0x42')](_0x3931e5['attributes'],function(_0x446d3d){var _0x4599b4={};_0x4599b4[_0x446d3d]={'$like':'%'+_0x17f4e4[_0xf9a9('0x43')]['filter']+'%'};return _0x4599b4;})});}_0x3931e5=_[_0xf9a9('0x4f')]({},_0x3931e5,_0x17f4e4[_0xf9a9('0x51')]);return db[_0xf9a9('0x6b')][_0xf9a9('0x2b')]({'where':_0x3931e5[_0xf9a9('0x4d')]})[_0xf9a9('0x1f')](function(_0x254a2d){_0x410045[_0xf9a9('0x2b')]=_0x254a2d;if(_0x17f4e4[_0xf9a9('0x43')][_0xf9a9('0x53')]){_0x3931e5[_0xf9a9('0x54')]=[{'all':!![]}];}return db['CannedAnswer'][_0xf9a9('0x55')](_0x3931e5);})[_0xf9a9('0x1f')](function(_0x5dd1fb){_0x410045['rows']=_0x5dd1fb;return _0x410045;});}})['then'](respondWithFilteredResult(_0x2a042e,_0x3931e5))[_0xf9a9('0x27')](handleError(_0x2a042e,null));};exports['removeAnswers']=function(_0x1afcc6,_0x540af7,_0x241535){return db[_0xf9a9('0x52')]['find']({'where':{'id':_0x1afcc6['params']['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x540af7,null))[_0xf9a9('0x1f')](function(_0x3dd520){if(_0x3dd520){return _0x3dd520['removeAnswers'](_0x1afcc6['query'][_0xf9a9('0x69')]);}})[_0xf9a9('0x1f')](respondWithStatusCode(_0x540af7,null))[_0xf9a9('0x27')](handleError(_0x540af7,null));};exports['addLogo']=function(_0x394fe1,_0x1da637,_0x3dec71){_0x394fe1[_0xf9a9('0x5b')][_0xf9a9('0x6e')]=_0x394fe1[_0xf9a9('0x6f')][_0xf9a9('0x70')];return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x394fe1['params']['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x1da637,null))[_0xf9a9('0x1f')](saveUpdates(_0x394fe1[_0xf9a9('0x5b')],null))[_0xf9a9('0x1f')](respondWithResult(_0x1da637,null))[_0xf9a9('0x27')](handleError(_0x1da637,null));};exports[_0xf9a9('0x71')]=function(_0x12388e,_0x1517c6,_0x2f4caf){_0x12388e[_0xf9a9('0x5b')]['agentAvatar']=_0x12388e[_0xf9a9('0x6f')][_0xf9a9('0x70')];return db['ChatWebsite'][_0xf9a9('0x59')]({'where':{'id':_0x12388e[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x1517c6,null))[_0xf9a9('0x1f')](saveUpdates(_0x12388e['body'],null))[_0xf9a9('0x1f')](respondWithResult(_0x1517c6,null))[_0xf9a9('0x27')](handleError(_0x1517c6,null));};exports[_0xf9a9('0x72')]=function(_0x2a0ea2,_0x3bf90d,_0x367fa6){_0x2a0ea2[_0xf9a9('0x5b')][_0xf9a9('0x73')]=_0x2a0ea2[_0xf9a9('0x6f')][_0xf9a9('0x70')];return db['ChatWebsite'][_0xf9a9('0x59')]({'where':{'id':_0x2a0ea2[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x3bf90d,null))[_0xf9a9('0x1f')](saveUpdates(_0x2a0ea2[_0xf9a9('0x5b')],null))[_0xf9a9('0x1f')](respondWithResult(_0x3bf90d,null))[_0xf9a9('0x27')](handleError(_0x3bf90d,null));};exports[_0xf9a9('0x74')]=function(_0x14f063,_0x2d9ca0,_0x584ca4){_0x14f063[_0xf9a9('0x5b')][_0xf9a9('0x75')]=_0x14f063[_0xf9a9('0x6f')][_0xf9a9('0x70')];return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x14f063[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x2d9ca0,null))[_0xf9a9('0x1f')](saveUpdates(_0x14f063[_0xf9a9('0x5b')],null))[_0xf9a9('0x1f')](respondWithResult(_0x2d9ca0,null))[_0xf9a9('0x27')](handleError(_0x2d9ca0,null));};exports[_0xf9a9('0x76')]=function(_0x5dcc07,_0x1eaded,_0x43b566){var _0x119f7b=path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x79'));var _0x43cd42={'where':{'id':_0x5dcc07[_0xf9a9('0x62')]['id']},'attributes':['id',_0xf9a9('0x6e')],'raw':!![]};var _0x698b5a=![];return require('../../config/license/util')['getLicense']()['then'](function(_0x53859d){if(_0x53859d){_0x698b5a=_0x53859d[_0xf9a9('0x7a')];}})[_0xf9a9('0x1f')](function(){return db[_0xf9a9('0x52')][_0xf9a9('0x59')](_0x43cd42);})['then'](handleEntityNotFound(_0x1eaded,null))[_0xf9a9('0x1f')](function(_0x216385){if(_0x216385){if(!_[_0xf9a9('0x7b')](_0x216385[_0xf9a9('0x6e')])){if(fs['existsSync'](path[_0xf9a9('0x77')](config['root'],_0xf9a9('0x7c'),_0x216385[_0xf9a9('0x6e')]))&&_0x698b5a){_0x119f7b=path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x7c'),_0x216385['sitepic']);}}return _0x1eaded['download'](_0x119f7b);}})[_0xf9a9('0x27')](handleError(_0x1eaded,null));};exports[_0xf9a9('0x7d')]=function(_0x452644,_0x182fa1,_0x22a7ae){var _0x59ec0a=path['join'](config[_0xf9a9('0x78')],_0xf9a9('0x7e'));var _0x4ace6b={'where':{'id':_0x452644[_0xf9a9('0x62')]['id']},'attributes':['id',_0xf9a9('0x7f')],'raw':!![]};return db[_0xf9a9('0x52')]['find'](_0x4ace6b)['then'](handleEntityNotFound(_0x182fa1,null))[_0xf9a9('0x1f')](function(_0x53501b){if(_0x53501b){if(!_[_0xf9a9('0x7b')](_0x53501b['agentAvatar'])){if(fs[_0xf9a9('0x80')](path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x81'),_0x53501b[_0xf9a9('0x7f')]))){_0x59ec0a=path['join'](config[_0xf9a9('0x78')],_0xf9a9('0x81'),_0x53501b[_0xf9a9('0x7f')]);}}return _0x182fa1['download'](_0x59ec0a);}})[_0xf9a9('0x27')](handleError(_0x182fa1,null));};exports['getCustomerAvatar']=function(_0x6b38,_0x565927,_0x43f160){var _0x5e4132=path['join'](config['root'],_0xf9a9('0x82'));var _0x147982={'where':{'id':_0x6b38['params']['id']},'attributes':['id','customerAvatar',_0xf9a9('0x83')],'raw':!![]};return db[_0xf9a9('0x52')][_0xf9a9('0x59')](_0x147982)['then'](handleEntityNotFound(_0x565927,null))[_0xf9a9('0x1f')](function(_0x1bb38d){if(_0x1bb38d){if(!_[_0xf9a9('0x7b')](_0x1bb38d[_0xf9a9('0x73')])){if(fs['existsSync'](path['join'](config[_0xf9a9('0x78')],'server/files/images/avatars/',_0x1bb38d[_0xf9a9('0x73')]))&&_0x1bb38d[_0xf9a9('0x83')]){_0x5e4132=path['join'](config[_0xf9a9('0x78')],_0xf9a9('0x81'),_0x1bb38d[_0xf9a9('0x73')]);}}return _0x565927[_0xf9a9('0x84')](_0x5e4132);}})[_0xf9a9('0x27')](handleError(_0x565927,null));};exports[_0xf9a9('0x85')]=function(_0x27af76,_0x2ca054,_0x1db874){var _0x213e00=path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x86'));var _0x5b32bf={'where':{'id':_0x27af76[_0xf9a9('0x62')]['id']},'attributes':['id',_0xf9a9('0x75')],'raw':!![]};return db[_0xf9a9('0x52')][_0xf9a9('0x59')](_0x5b32bf)[_0xf9a9('0x1f')](handleEntityNotFound(_0x2ca054,null))[_0xf9a9('0x1f')](function(_0x31b2ba){if(_0x31b2ba){if(!_['isNil'](_0x31b2ba['systemAvatar'])){if(fs['existsSync'](path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x81'),_0x31b2ba['systemAvatar']))){_0x213e00=path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0x81'),_0x31b2ba['systemAvatar']);}}return _0x2ca054[_0xf9a9('0x84')](_0x213e00);}})['catch'](handleError(_0x2ca054,null));};exports[_0xf9a9('0x87')]=function(_0x11ec7d,_0x45c123,_0x539c4e){var _0x551cec=require(_0xf9a9('0x88'));var _0x328439=new _0x551cec();var _0x5239b5=_0x328439[_0xf9a9('0x89')](_0x11ec7d[_0xf9a9('0x8a')][_0xf9a9('0x8b')])[_0xf9a9('0x8c')]();var _0x2d1e9b={'body':_0x11ec7d['body'],'channel':'chat'};var _0x908060=[];var _0x39d8cc=[];var _0x3f8adc={};var _0x550e64=![];return db['CmContact']['describe']()[_0xf9a9('0x1f')](function(_0xf60fc4){if(!_0xf60fc4){throw new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))](_0xf9a9('0x8f'));}_0x908060=_[_0xf9a9('0x90')](_[_0xf9a9('0x58')](_0xf60fc4),[_0xf9a9('0x91'),_0xf9a9('0x92')]);_0x39d8cc=_[_0xf9a9('0x90')](_[_0xf9a9('0x58')](_0xf60fc4),[_0xf9a9('0x91'),_0xf9a9('0x92'),_0xf9a9('0x93'),'ListId']);if(_0x11ec7d['body']['id']){delete _0x11ec7d[_0xf9a9('0x5b')]['id'];}if(_[_0xf9a9('0x7b')](_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x94')])){throw new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))](_0xf9a9('0x95'));}if(_['isNil'](_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x5b')])||_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x5b')]===''){throw new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))](_0xf9a9('0x96'));}if(_[_0xf9a9('0x7b')](_0x11ec7d[_0xf9a9('0x5b')]['mapKey'])){throw new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39d8cc);}if(!_[_0xf9a9('0x97')](_0x39d8cc,_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x98')])){throw new db[(_0xf9a9('0x8d'))]['ValidationError'](_0xf9a9('0x99')+_0x39d8cc);}_0x3f8adc[_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x98')]]=_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x94')];})[_0xf9a9('0x1f')](function(){return db['ChatWebsite'][_0xf9a9('0x59')]({'where':{'id':_0x11ec7d[_0xf9a9('0x62')]['id']},'include':[{'model':db[_0xf9a9('0x9a')],'as':_0xf9a9('0x9b'),'include':[{'model':db[_0xf9a9('0x9c')],'as':'Contacts','where':_0x3f8adc,'limit':0x1,'order':[[_0xf9a9('0x92'),_0xf9a9('0x9d')]]}]},{'model':db[_0xf9a9('0x9e')],'as':_0xf9a9('0x9f')}]});})[_0xf9a9('0x1f')](handleEntityNotFound(_0x45c123,null))[_0xf9a9('0x1f')](function(_0x4c5e01){if(_0x4c5e01&&_0x4c5e01[_0xf9a9('0x9b')]){_0x2d1e9b[_0xf9a9('0xa0')]=_0x4c5e01;_0x2d1e9b[_0xf9a9('0xa1')]=_0x4c5e01[_0xf9a9('0x9f')];_0x2d1e9b['list']=_0x4c5e01[_0xf9a9('0x9b')];_0x2d1e9b[_0xf9a9('0xa1')]=_[_0xf9a9('0xa2')](_0x2d1e9b[_0xf9a9('0xa1')],[_0xf9a9('0xa3')],[_0xf9a9('0xa4')]);if(_0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0x9f')]){delete _0x2d1e9b['account'][_0xf9a9('0x9f')];}if(_0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0x9b')]&&_0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0x9b')][_0xf9a9('0xa5')][_0xf9a9('0x48')]){return _0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0x9b')][_0xf9a9('0xa5')][0x0];}var _0x60e583=_[_0xf9a9('0x18')](_0x11ec7d[_0xf9a9('0x5b')],{'firstName':_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x94')],'ListId':_0x4c5e01['ListId']});_0x60e583[_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0x98')]]=_0x11ec7d['body']['from'];return db[_0xf9a9('0x9c')]['create'](_0x60e583,{'fields':_0x908060,'raw':!![]});}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x45c123,null))['then'](function(_0x1ab0a3){_0x2d1e9b[_0xf9a9('0xa6')]=_0x1ab0a3;var _0x42faf7=_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xa7')];if(_0x11ec7d['headers'][_0xf9a9('0xa8')]){_0x42faf7=_0x11ec7d[_0xf9a9('0x8a')][_0xf9a9('0xa8')];}else if(_0x11ec7d[_0xf9a9('0x8a')]['x-forwarded-for']){_0x42faf7=_['first'](_0x11ec7d['headers'][_0xf9a9('0xa9')]['split'](','));}if(_0x1ab0a3){var _0x358dd7={'ContactId':_0x1ab0a3['id'],'ChatWebsiteId':_0x11ec7d[_0xf9a9('0x62')]['id'],'from':(_0x1ab0a3[_0xf9a9('0xaa')]||'')+'\x20'+(_0x1ab0a3[_0xf9a9('0xab')]||''),'customerIp':_0x42faf7,'customerPort':_0x11ec7d[_0xf9a9('0x8a')][_0xf9a9('0xac')]?_0x11ec7d[_0xf9a9('0x8a')][_0xf9a9('0xac')]:null,'referer':_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xad')],'browserName':_0x5239b5['browser'][_0xf9a9('0x3a')]&&_0x5239b5[_0xf9a9('0xae')][_0xf9a9('0xaf')]?util['format']('%s\x20%s',_0x5239b5[_0xf9a9('0xae')][_0xf9a9('0x3a')],_0x5239b5[_0xf9a9('0xae')][_0xf9a9('0xaf')]):_0xf9a9('0xb0'),'browserVersion':_0x5239b5['browser'][_0xf9a9('0xaf')]||_0xf9a9('0xb0'),'osName':util[_0xf9a9('0xb1')](_0xf9a9('0xb2'),_0x5239b5['os'][_0xf9a9('0x3a')],_0x5239b5['os'][_0xf9a9('0xaf')]),'osVersion':_0x5239b5['os']['version'],'deviceModel':_0x5239b5[_0xf9a9('0xb3')][_0xf9a9('0x41')]&&_0x5239b5[_0xf9a9('0xb3')]['vendor']?util[_0xf9a9('0xb1')]('%s\x20%s\x20%s',_0x5239b5[_0xf9a9('0xb3')][_0xf9a9('0x41')],_0x5239b5[_0xf9a9('0xb3')]['vendor'],_0x5239b5['device'][_0xf9a9('0x3f')]):null,'deviceVendor':_0x5239b5[_0xf9a9('0xb3')]['vendor'],'deviceType':_0x5239b5[_0xf9a9('0xb3')]['type'],'formData':JSON[_0xf9a9('0xb4')](_0x11ec7d[_0xf9a9('0x5b')])};var _0x528bd4={'ChatWebsiteId':_0x11ec7d[_0xf9a9('0x62')]['id'],'closed':![]};if(_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb5')]){_0x528bd4[_0xf9a9('0xb5')]=_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb5')];return db[_0xf9a9('0xb6')][_0xf9a9('0x59')]({'where':_0x528bd4})[_0xf9a9('0x1f')](function(_0x3a55e3){if(_0x3a55e3){return[_0x3a55e3,![]];}_0x358dd7[_0xf9a9('0xb5')]=_0x11ec7d['body']['threadId'];_0x358dd7[_0xf9a9('0xb7')]=_0x11ec7d[_0xf9a9('0x5b')]['externalUrl'];return db[_0xf9a9('0xb6')]['create'](_0x358dd7)[_0xf9a9('0x1f')](function(_0x3d3179){return[_0x3d3179,!![]];});});}_0x528bd4[_0xf9a9('0xb8')]=_0x1ab0a3['id'];if(_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb9')]&&_0x11ec7d['body'][_0xf9a9('0xb9')]['id']){_0x528bd4['id']=_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb9')]['id'];return db[_0xf9a9('0xb6')]['find']({'where':_0x528bd4})['then'](function(_0x3191c2){if(_0x3191c2){return[_0x3191c2,![]];}return db[_0xf9a9('0xb6')][_0xf9a9('0x5a')](_0x358dd7)[_0xf9a9('0x1f')](function(_0x2ee1ed){return[_0x2ee1ed,!![]];});});}return db[_0xf9a9('0xb6')]['create'](_0x358dd7)[_0xf9a9('0x1f')](function(_0x3fc155){return[_0x3fc155,!![]];});}})[_0xf9a9('0xba')](function(_0x189c5f,_0x27eabd){if(_0x189c5f){_0x550e64=_0x27eabd;if(!_0x27eabd){var _0x127eb5={'from':(_0x2d1e9b[_0xf9a9('0xa6')]['firstName']||'')+'\x20'+(_0x2d1e9b[_0xf9a9('0xa6')][_0xf9a9('0xab')]||'')};if(_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb5')]&&_0x11ec7d['body'][_0xf9a9('0xbb')]&&_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xb5')]!=_0x11ec7d['body'][_0xf9a9('0xbb')]){_0x127eb5[_0xf9a9('0xb5')]=_0x11ec7d[_0xf9a9('0x5b')][_0xf9a9('0xbb')];}return _0x189c5f[_0xf9a9('0x34')](_0x127eb5);}else{return _0x189c5f;}}})[_0xf9a9('0x1f')](function(_0x4a6a05){_0x2d1e9b['interaction']=_0x4a6a05[_0xf9a9('0x35')]({'plain':!![]});_0x2d1e9b[_0xf9a9('0xb9')][_0xf9a9('0xbc')]=_0x550e64;if(_0x2d1e9b[_0xf9a9('0xb9')]['created']){if(_0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0xbd')]){_0x2d1e9b[_0xf9a9('0xa1')][_0xf9a9('0xbe')]({'id':0x0,'priority':_0x2d1e9b['applications'][_0xf9a9('0x48')]+0x1,'app':_0xf9a9('0xbf'),'appdata':'unmanaged','interval':_0xf9a9('0xc0')});}}return db[_0xf9a9('0xc1')]['create']({'body':_0x11ec7d['body'][_0xf9a9('0x5b')],'ChatWebsiteId':_0x11ec7d[_0xf9a9('0x62')]['id'],'ChatInteractionId':_0x4a6a05['id'],'direction':'in','ContactId':_0x2d1e9b[_0xf9a9('0xa6')]['id'],'AttachmentId':_0x11ec7d[_0xf9a9('0x5b')]['AttachmentId']});})['then'](function(_0x154c01){_0x2d1e9b[_0xf9a9('0x26')]=_0x154c01;if(_0x2d1e9b[_0xf9a9('0xb9')][_0xf9a9('0xc2')]){return db[_0xf9a9('0xc3')][_0xf9a9('0x59')]({'attributes':['id','name'],'where':{'id':_0x2d1e9b[_0xf9a9('0xb9')][_0xf9a9('0xc2')]}})['then'](function(_0x6384b1){if(_0x6384b1){_0x2d1e9b['applications'][_0xf9a9('0xc4')]({'id':0x0,'priority':0x0,'app':_0xf9a9('0xc5'),'appdata':_0x6384b1['name']+','+(_0x2d1e9b[_0xf9a9('0xa0')][_0xf9a9('0xc6')]||0xa),'interval':_0xf9a9('0xc0')});_0x2d1e9b[_0xf9a9('0xc7')]=!![];}return respondWithRpcPromise(_0xf9a9('0xc8'),_0xf9a9('0xc9'),_0x2d1e9b);});}return respondWithRpcPromise(_0xf9a9('0xc8'),'startRouting',_0x2d1e9b);})[_0xf9a9('0x1f')](function(_0x4a2a4a){respondWithRpcPromise(_0xf9a9('0xca'),_0xf9a9('0xca'),{'event':_0xf9a9('0x87'),'message':_0x4a2a4a},client9002);return _0x4a2a4a;})[_0xf9a9('0x1f')](respondWithResult(_0x45c123,null))[_0xf9a9('0x27')](handleError(_0x45c123,null));};exports[_0xf9a9('0xcb')]=function(_0x502c10,_0x5bcfcb,_0x520149){var _0x42b6d1,_0x5d67d8,_0x4cd331;var _0x28380d=[];var _0x10cbf7=[];var _0x570cf3={};return db[_0xf9a9('0x9c')][_0xf9a9('0x63')]()[_0xf9a9('0x1f')](function(_0x2ddd09){if(!_0x2ddd09){throw new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))]('no\x20available\x20attributes');}_0x10cbf7=_[_0xf9a9('0x90')](_['keys'](_0x2ddd09),[_0xf9a9('0x91'),_0xf9a9('0x92')]);_0x28380d=_[_0xf9a9('0x90')](_[_0xf9a9('0x58')](_0x2ddd09),['createdAt',_0xf9a9('0x92'),_0xf9a9('0x93'),_0xf9a9('0xcc')]);if(_0x502c10[_0xf9a9('0x5b')]['id']){delete _0x502c10['body']['id'];}if(_[_0xf9a9('0x7b')](_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x94')])){throw _0x5bcfcb['status'](0x1f4)['send'](new db['Sequelize'][(_0xf9a9('0x8e'))]('from\x20is\x20mandatory'));}if(_[_0xf9a9('0x7b')](_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x5b')])||_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x5b')]===''){throw _0x5bcfcb[_0xf9a9('0x29')](0x1f4)[_0xf9a9('0xcd')](new db['Sequelize'][(_0xf9a9('0x8e'))](_0xf9a9('0x96')));}if(_[_0xf9a9('0x7b')](_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0xce')])){throw _0x5bcfcb[_0xf9a9('0x29')](0x1f4)[_0xf9a9('0xcd')](new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))](_0xf9a9('0xcf')+_0x28380d));}if(!_['includes'](_0x28380d,_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0xce')])){throw _0x5bcfcb[_0xf9a9('0x29')](0x1f4)['send'](new db[(_0xf9a9('0x8d'))][(_0xf9a9('0x8e'))]('mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x28380d));}_0x570cf3[_0x502c10[_0xf9a9('0x5b')]['mapKeyOffline']]=_0x502c10['body']['from'];})['then'](function(){return db['ChatWebsite'][_0xf9a9('0x59')]({'where':{'id':_0x502c10[_0xf9a9('0x62')]['id']},'include':[{'model':db['CmList'],'as':_0xf9a9('0x9b')}]});})['then'](handleEntityNotFound(_0x5bcfcb,null))['then'](function(_0x16ab23){if(_0x16ab23&&_0x16ab23[_0xf9a9('0x9b')]){_0x5d67d8=_0x16ab23;var _0x276e56=_[_0xf9a9('0x18')](_0x502c10[_0xf9a9('0x5b')],{'firstName':_0x502c10[_0xf9a9('0x5b')]['from'],'phone':_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x94')],'ListId':_0x16ab23[_0xf9a9('0xcc')]});_0x276e56[_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0xce')]]=_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x94')];return db[_0xf9a9('0x9c')][_0xf9a9('0xd0')]({'where':_0x570cf3,'defaults':_0x276e56});}})[_0xf9a9('0xba')](function(_0x4551c5){if(_0x4551c5){_0x4cd331=_0x4551c5;var _0x35d5d1=fs[_0xf9a9('0xd1')](path['join'](config[_0xf9a9('0x78')],'server/files/templates/chatOfflineMessage.ejs'),_0xf9a9('0xd2'));var _0x2c87a9=ejs['render'](_0x35d5d1,{'body':_[_0xf9a9('0xd3')](_0x502c10[_0xf9a9('0x5b')][_0xf9a9('0x5b')]),'bodyTitle':_0x5d67d8['offlineMessageBody']});return db['ChatOfflineMessage'][_0xf9a9('0x5a')]({'body':_0x2c87a9,'ContactId':_0x4551c5['id'],'ChatWebsiteId':_0x5d67d8['id']});}})[_0xf9a9('0x1f')](function(_0x2e3b18){if(_0x2e3b18){_0x42b6d1=_0x2e3b18;return db['MailAccount'][_0xf9a9('0xd4')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':'Smtp','raw':!![]}]});}})[_0xf9a9('0x1f')](function(_0x44789b){if(_0x44789b&&_0x44789b['Smtp']&&_0x5d67d8[_0xf9a9('0xd5')]){var _0x4b356c={'tls':{'rejectUnauthorized':![]}};if(_0x44789b[_0xf9a9('0xd6')][_0xf9a9('0xd7')]){_0x4b356c['service']=_0x44789b[_0xf9a9('0xd6')]['service'];}else{_0x4b356c[_0xf9a9('0xd8')]=_0x44789b[_0xf9a9('0xd6')][_0xf9a9('0xd8')];_0x4b356c[_0xf9a9('0xd9')]=_0x44789b[_0xf9a9('0xd6')][_0xf9a9('0xd9')];_0x4b356c[_0xf9a9('0xda')]=_0x44789b[_0xf9a9('0xd6')]['secure'];}if(_0x44789b[_0xf9a9('0xd6')][_0xf9a9('0xdb')]){_0x4b356c[_0xf9a9('0xdc')]={'user':_0x44789b[_0xf9a9('0xd6')][_0xf9a9('0x5e')],'pass':_0x44789b[_0xf9a9('0xd6')]['pass']};}return respondWithRpcPromise(_0xf9a9('0xdd'),'sendMail',{'account':_0x4b356c,'message':{'from':util[_0xf9a9('0xb1')](_0xf9a9('0xde'),_0x44789b[_0xf9a9('0x3a')],_0x44789b[_0xf9a9('0xdf')]||_0x44789b['Smtp'][_0xf9a9('0x5e')]),'to':_0x5d67d8[_0xf9a9('0xd5')],'subject':_0x5d67d8[_0xf9a9('0xe0')],'text':_0x42b6d1[_0xf9a9('0x5b')]}},client9003)[_0xf9a9('0x1f')](function(){return _0x42b6d1;})['catch'](function(_0x2f3520){console[_0xf9a9('0x24')](_0x2f3520);});}})['then'](function(){if(_0x42b6d1){return _0x42b6d1;}})[_0xf9a9('0x1f')](respondWithResult(_0x5bcfcb,null))[_0xf9a9('0x27')](handleError(_0x5bcfcb,null));};exports[_0xf9a9('0xe1')]=function(_0x18d609,_0x367d65,_0x5412af){return db[_0xf9a9('0xb6')][_0xf9a9('0x59')]({'where':{'id':_0x18d609['params']['id']}})['then'](handleEntityNotFound(_0x367d65,null))[_0xf9a9('0x1f')](function(_0x38e4c1){if(_0x38e4c1){return _0x38e4c1[_0xf9a9('0xe1')](_0x18d609[_0xf9a9('0x5b')]['ids'],_['omit'](_0x18d609['body'],['ids','id'])||{});}})[_0xf9a9('0x1f')](respondWithResult(_0x367d65,null))[_0xf9a9('0x27')](handleError(_0x367d65,null));};exports[_0xf9a9('0xe2')]=function(_0x2cb0a0,_0x2c64b7,_0x21fee2){var _0x33ea1e={'raw':![],'where':{}};var _0x551e19={};var _0x26420f={'count':0x0,'rows':[]};return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x2cb0a0[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x2c64b7,null))[_0xf9a9('0x1f')](function(_0x29c92a){if(_0x29c92a){_0x551e19[_0xf9a9('0x41')]=_['keys'](db[_0xf9a9('0xb6')][_0xf9a9('0x3d')]);_0x551e19[_0xf9a9('0x43')]=_['keys'](_0x2cb0a0[_0xf9a9('0x43')]);_0x551e19[_0xf9a9('0x44')]=_['intersection'](_0x551e19[_0xf9a9('0x41')],_0x551e19[_0xf9a9('0x43')]);_0x33ea1e[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0x551e19[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0x47')]));_0x33ea1e['attributes']=_0x33ea1e[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x33ea1e[_0xf9a9('0x46')]:_0x551e19['model'];if(!_0x2cb0a0[_0xf9a9('0x43')]['hasOwnProperty'](_0xf9a9('0x4a'))){_0x33ea1e[_0xf9a9('0x2d')]=qs[_0xf9a9('0x2d')](_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x33ea1e[_0xf9a9('0x2c')]=qs[_0xf9a9('0x2c')](_0x2cb0a0['query'][_0xf9a9('0x2c')]);}_0x33ea1e[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x2cb0a0[_0xf9a9('0x43')]['sort']);_0x33ea1e[_0xf9a9('0x4d')]=qs[_0xf9a9('0x44')](_['pick'](_0x2cb0a0[_0xf9a9('0x43')],_0x551e19[_0xf9a9('0x44')]));_0x33ea1e[_0xf9a9('0x4d')]['ChatWebsiteId']=_0x29c92a['id'];if(_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0x4e')]){_0x33ea1e[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x33ea1e[_0xf9a9('0x4d')],{'$or':_[_0xf9a9('0x42')](_0x33ea1e[_0xf9a9('0x46')],function(_0x1fb5a1){var _0x5796f0={};_0x5796f0[_0x1fb5a1]={'$like':'%'+_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0x4e')]+'%'};return _0x5796f0;})});}_0x33ea1e=_[_0xf9a9('0x4f')]({},_0x33ea1e,_0x2cb0a0[_0xf9a9('0x51')]);return db[_0xf9a9('0xb6')][_0xf9a9('0x2b')]({'where':_0x33ea1e[_0xf9a9('0x4d')]})[_0xf9a9('0x1f')](function(_0x41b4ea){_0x26420f[_0xf9a9('0x2b')]=_0x41b4ea;if(_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0x53')]){_0x33ea1e['include']=[{'model':db[_0xf9a9('0x9c')],'as':'Contact','required':![]},{'model':db[_0xf9a9('0xc3')],'as':_0xf9a9('0xe3'),'attributes':[_0xf9a9('0x3a'),_0xf9a9('0xe4'),_0xf9a9('0xe5')],'required':![]},{'model':db[_0xf9a9('0xe6')],'as':_0xf9a9('0xe7'),'attributes':['id',_0xf9a9('0x3a'),_0xf9a9('0xe8')],'where':_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0xe9')]?{'id':_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0xe9')]}:undefined,'required':_0x2cb0a0[_0xf9a9('0x43')][_0xf9a9('0xe9')]?!![]:![]}];}return db[_0xf9a9('0xb6')][_0xf9a9('0x55')](_0x33ea1e);})[_0xf9a9('0x1f')](function(_0x5a33a0){_0x26420f[_0xf9a9('0x56')]=_0x5a33a0;return _0x26420f;});}})[_0xf9a9('0x1f')](respondWithFilteredResult(_0x2c64b7,_0x33ea1e))['catch'](handleError(_0x2c64b7,null));};function iftimePromise(_0x2f94e8,_0x4420f2){return respondWithRpcPromise(_0xf9a9('0xea'),'getSnippet',{'command':_0x4420f2[_0xf9a9('0xeb')]?util[_0xf9a9('0xb1')]('iftime\x20%s,%s',_0x2f94e8[_0xf9a9('0xec')],_0x4420f2[_0xf9a9('0xeb')]):util[_0xf9a9('0xb1')](_0xf9a9('0xed'),_0x2f94e8[_0xf9a9('0xec')])},client9002)['then'](function(_0x1ce7b1){var _0x52571b=_0x1ce7b1&&_0x1ce7b1[_0xf9a9('0xee')](_0xf9a9('0xef'))>=0x0?!![]:![];logger[_0xf9a9('0x20')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x4420f2['id'],_0x2f94e8['id'],_0x2f94e8['interval'],_0x52571b?_0xf9a9('0xf0'):_0xf9a9('0xf1'),_0x4420f2[_0xf9a9('0xeb')]?_0x4420f2[_0xf9a9('0xeb')]:'No\x20timezone');return _0x52571b;})[_0xf9a9('0x27')](function(_0x12c55f){logger[_0xf9a9('0x24')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x4420f2['id'],_0x2f94e8['id'],_0x2f94e8['interval'],util['inspect'](_0x12c55f,{'showHidden':![],'depth':null}),_0x4420f2['timezone']?_0x4420f2[_0xf9a9('0xeb')]:_0xf9a9('0xf2'));return![];});}exports[_0xf9a9('0xf3')]=function(_0x270a2c,_0x58619e,_0x3637cd){var _0x26b553=0x0;var _0x3a8f26=0x0;var _0x54fb7a=![];var _0x4d77d4;var _0x3aab21;return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x270a2c[_0xf9a9('0x62')]['id']},'include':[{'model':db[_0xf9a9('0xf4')],'as':'Interval','include':[{'model':db['Interval'],'as':'Intervals','attributes':['id',_0xf9a9('0xec')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x58619e,null))[_0xf9a9('0x1f')](function(_0x3886f1){if(_0x3886f1){_0x4d77d4=_0x3886f1;return _0x3886f1[_0xf9a9('0xf5')]({'raw':!![]});}})['then'](function(_0x368f2c){if(_0x4d77d4){if(_0x368f2c){_0x3aab21=_0x368f2c;}}return require('../../config/license/util')['getLicense']();})[_0xf9a9('0x1f')](function(_0x319519){if(_0x319519){_0x3a8f26=_0x319519[_0xf9a9('0xf6')];_0x54fb7a=_0x319519['custom'];}})[_0xf9a9('0x1f')](function(){return db['ChatInteraction'][_0xf9a9('0x2b')]({'where':{'closed':![]}});})['then'](function(_0x17a37c){_0x26b553=_0x17a37c;if(_0x3a8f26&&_0x17a37c>_0x3a8f26){return db[_0xf9a9('0xf7')][_0xf9a9('0xd4')]({'where':{'id':0x1}})['then'](function(_0x563e76){if(_0x563e76){_0x563e76[_0xf9a9('0xf8')](_0xf9a9('0xf9'));}});}})['then'](function(){if(_0x4d77d4[_0xf9a9('0xf4')]&&_0x4d77d4[_0xf9a9('0xf4')]['Intervals']){var _0x5b19ab=[];for(var _0x5ce5da=0x0;_0x5ce5da<_0x4d77d4['Interval'][_0xf9a9('0xfa')][_0xf9a9('0x48')];_0x5ce5da++){var _0x401379=_0x4d77d4['Interval'][_0xf9a9('0xfa')][_0x5ce5da][_0xf9a9('0x35')]({'plain':!![]});_0x5b19ab[_0xf9a9('0xbe')](iftimePromise(_0x401379,_0x4d77d4));}return BPromise[_0xf9a9('0xfb')](_0x5b19ab)[_0xf9a9('0x1f')](function(_0x344bbe){return _[_0xf9a9('0xfc')](_0x344bbe);});}else{return!![];}})[_0xf9a9('0x1f')](function(_0x486926){var _0x43f718=fs[_0xf9a9('0xd1')](path[_0xf9a9('0x77')](config[_0xf9a9('0x78')],_0xf9a9('0xfd')),_0xf9a9('0xd2'));var _0x284980={'remote':_0x4d77d4['remote'],'query':querystring[_0xf9a9('0xb4')](_[_0xf9a9('0x4f')](_0x4d77d4[_0xf9a9('0x35')]({'plain':!![]}),{'customerIp':_0x270a2c[_0xf9a9('0x8a')][_0xf9a9('0xa9')]||_0x270a2c['headers'][_0xf9a9('0xfe')]||_0x270a2c[_0xf9a9('0xff')][_0xf9a9('0x100')]||_0x270a2c['ip'],'referer':_0x270a2c[_0xf9a9('0x8a')][_0xf9a9('0xad')],'openedInteractions':_0x26b553,'maxInteractions':_0x3a8f26,'virtual':_0x54fb7a['virtual'],'online':_0x486926,'custom':_0x54fb7a}))['replace'](/'/g,'\x5c\x27')};_0x58619e['send'](ejs[_0xf9a9('0x101')](Mustache[_0xf9a9('0x101')](_0x43f718,_0x284980),{'proactiveActions':_0x3aab21,'alignment':_0x4d77d4[_0xf9a9('0x102')],'verticalAlignment':_0x4d77d4[_0xf9a9('0x103')],'div_color':_0x4d77d4[_0xf9a9('0xe8')],'text_color':_0x4d77d4['textColor']}));})[_0xf9a9('0x27')](handleError(_0x58619e,null));};exports[_0xf9a9('0x104')]=function(_0x37aadb,_0x54e280,_0x3bcc99){return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x37aadb[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x54e280,null))[_0xf9a9('0x1f')](function(_0x12bfeb){if(_0x12bfeb){return db[_0xf9a9('0x105')][_0xf9a9('0x106')](function(_0x54ad9a){return db[_0xf9a9('0x9e')][_0xf9a9('0x38')]({'where':{'ChatWebsiteId':_0x37aadb['params']['id']},'transaction':_0x54ad9a})[_0xf9a9('0x1f')](function(_0x6370cf){var _0x14b31a=_[_0xf9a9('0x42')](_0x37aadb[_0xf9a9('0x5b')],function(_0x49a6bf){_0x49a6bf['ChatWebsiteId']=_0x37aadb[_0xf9a9('0x62')]['id'];return _0x49a6bf;});return db[_0xf9a9('0x9e')][_0xf9a9('0x107')](_0x14b31a,{'transaction':_0x54ad9a});});})[_0xf9a9('0x1f')](function(){return db[_0xf9a9('0x9e')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x37aadb[_0xf9a9('0x62')]['id']},'order':_0xf9a9('0xa3')});});}})[_0xf9a9('0x1f')](respondWithResult(_0x54e280,null))[_0xf9a9('0x27')](handleError(_0x54e280,null));};exports[_0xf9a9('0x108')]=function(_0x4f8dbd,_0x1cc95b,_0x4eab9f){var _0x4bd74f={};var _0x6cee3a={};var _0x2989b2;var _0x3171a0;return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x4f8dbd[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x1cc95b,null))['then'](function(_0x1d3861){if(_0x1d3861){_0x2989b2=_0x1d3861;_0x6cee3a[_0xf9a9('0x41')]=_[_0xf9a9('0x58')](db['ChatApplication'][_0xf9a9('0x3d')]);_0x6cee3a[_0xf9a9('0x43')]=_[_0xf9a9('0x58')](_0x4f8dbd[_0xf9a9('0x43')]);_0x6cee3a[_0xf9a9('0x44')]=_[_0xf9a9('0x45')](_0x6cee3a[_0xf9a9('0x41')],_0x6cee3a[_0xf9a9('0x43')]);_0x4bd74f[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0x6cee3a['model'],qs[_0xf9a9('0x47')](_0x4f8dbd[_0xf9a9('0x43')][_0xf9a9('0x47')]));_0x4bd74f[_0xf9a9('0x46')]=_0x4bd74f[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x4bd74f[_0xf9a9('0x46')]:_0x6cee3a[_0xf9a9('0x41')];_0x4bd74f[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x4f8dbd[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x4bd74f[_0xf9a9('0x4d')]=qs['filters'](_[_0xf9a9('0x6d')](_0x4f8dbd[_0xf9a9('0x43')],_0x6cee3a[_0xf9a9('0x44')]));if(_0x4f8dbd[_0xf9a9('0x43')]['filter']){_0x4bd74f[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x4bd74f[_0xf9a9('0x4d')],{'$or':_['map'](_0x4bd74f[_0xf9a9('0x46')],function(_0xcd0344){var _0x33820f={};_0x33820f[_0xcd0344]={'$like':'%'+_0x4f8dbd[_0xf9a9('0x43')][_0xf9a9('0x4e')]+'%'};return _0x33820f;})});}_0x4bd74f=_['merge']({},_0x4bd74f,_0x4f8dbd['options']);return _0x2989b2['getApplications'](_0x4bd74f);}})['then'](function(_0x403b55){if(_0x403b55){_0x3171a0=_0x403b55[_0xf9a9('0x48')];if(!_0x4f8dbd[_0xf9a9('0x43')][_0xf9a9('0x49')](_0xf9a9('0x4a'))){_0x4bd74f[_0xf9a9('0x2d')]=qs[_0xf9a9('0x2d')](_0x4f8dbd[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x4bd74f['offset']=qs['offset'](_0x4f8dbd['query'][_0xf9a9('0x2c')]);}return _0x2989b2[_0xf9a9('0x108')](_0x4bd74f);}})[_0xf9a9('0x1f')](function(_0x35cbfb){if(_0x35cbfb){return _0x35cbfb?{'count':_0x3171a0,'rows':_0x35cbfb}:null;}})[_0xf9a9('0x1f')](respondWithResult(_0x1cc95b,null))[_0xf9a9('0x27')](handleError(_0x1cc95b,null));};exports[_0xf9a9('0x109')]=function(_0x217ad1,_0x5f33de,_0x495271){return db[_0xf9a9('0x10a')]['find']({'where':{'id':_0x217ad1['params']['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x5f33de,null))[_0xf9a9('0x1f')](function(_0x447c86){if(_0x447c86){return _0x447c86['addProactiveActions'](_0x217ad1[_0xf9a9('0x5b')][_0xf9a9('0x69')],_[_0xf9a9('0x10b')](_0x217ad1['body'],['ids','id'])||{});}})[_0xf9a9('0x1f')](respondWithResult(_0x5f33de,null))[_0xf9a9('0x27')](handleError(_0x5f33de,null));};exports[_0xf9a9('0xf5')]=function(_0x33f123,_0x26dadf,_0x482f92){var _0x68c8c2={};var _0x3ad9be={};var _0x21bed1;var _0x3a62c7;return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x33f123[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x26dadf,null))[_0xf9a9('0x1f')](function(_0xff1f15){if(_0xff1f15){_0x21bed1=_0xff1f15;_0x3ad9be['model']=_[_0xf9a9('0x58')](db['ChatProactiveAction'][_0xf9a9('0x3d')]);_0x3ad9be['query']=_[_0xf9a9('0x58')](_0x33f123[_0xf9a9('0x43')]);_0x3ad9be[_0xf9a9('0x44')]=_[_0xf9a9('0x45')](_0x3ad9be[_0xf9a9('0x41')],_0x3ad9be['query']);_0x68c8c2[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0x3ad9be[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x47')]));_0x68c8c2[_0xf9a9('0x46')]=_0x68c8c2[_0xf9a9('0x46')]['length']?_0x68c8c2[_0xf9a9('0x46')]:_0x3ad9be['model'];_0x68c8c2[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x68c8c2[_0xf9a9('0x4d')]=qs[_0xf9a9('0x44')](_[_0xf9a9('0x6d')](_0x33f123[_0xf9a9('0x43')],_0x3ad9be[_0xf9a9('0x44')]));if(_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x4e')]){_0x68c8c2[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x68c8c2[_0xf9a9('0x4d')],{'$or':_[_0xf9a9('0x42')](_0x68c8c2[_0xf9a9('0x46')],function(_0x297b00){var _0x38f66c={};_0x38f66c[_0x297b00]={'$like':'%'+_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x4e')]+'%'};return _0x38f66c;})});}_0x68c8c2=_[_0xf9a9('0x4f')]({},_0x68c8c2,_0x33f123[_0xf9a9('0x51')]);return _0x21bed1[_0xf9a9('0xf5')](_0x68c8c2);}})[_0xf9a9('0x1f')](function(_0x13a79f){if(_0x13a79f){_0x3a62c7=_0x13a79f[_0xf9a9('0x48')];if(!_0x33f123['query'][_0xf9a9('0x49')](_0xf9a9('0x4a'))){_0x68c8c2[_0xf9a9('0x2d')]=qs[_0xf9a9('0x2d')](_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x68c8c2[_0xf9a9('0x2c')]=qs[_0xf9a9('0x2c')](_0x33f123[_0xf9a9('0x43')][_0xf9a9('0x2c')]);}return _0x21bed1[_0xf9a9('0xf5')](_0x68c8c2);}})[_0xf9a9('0x1f')](function(_0x2b8f43){if(_0x2b8f43){return _0x2b8f43?{'count':_0x3a62c7,'rows':_0x2b8f43}:null;}})[_0xf9a9('0x1f')](respondWithResult(_0x26dadf,null))[_0xf9a9('0x27')](handleError(_0x26dadf,null));};exports[_0xf9a9('0x10c')]=function(_0x1cea12,_0x5c1883,_0x37a8a8){var _0x2889a7=_0x1cea12['query'][_0xf9a9('0x10d')]==='false'?_0xf9a9('0x10e'):_0xf9a9('0x10f');return db[_0xf9a9('0x52')]['find']({'attributes':['id',_0x2889a7],'where':{'id':_0x1cea12[_0xf9a9('0x62')]['id']}})['then'](handleEntityNotFound(_0x5c1883,null))[_0xf9a9('0x1f')](function(_0x1e4745){if(_0x1e4745){var _0x431677=_0x1e4745[_0x2889a7];var _0x64a51e=_0x431677&&_0x431677[_0xf9a9('0x110')]?_0x431677['items']:[];_0x5c1883[_0xf9a9('0xcd')]({'fromKey':_[_0xf9a9('0x7b')](_0x431677[_0xf9a9('0x111')])?undefined:_0x431677[_0xf9a9('0x111')],'count':_0x64a51e[_0xf9a9('0x48')],'rows':_0x64a51e});}})[_0xf9a9('0x27')](handleError(_0x5c1883,null));};exports['getOfflineMessages']=function(_0x3411ce,_0x46911c,_0x5737af){var _0x31a715={'raw':![],'where':{}};var _0xba9475={};var _0x2999bb={'count':0x0,'rows':[]};return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x3411ce['params']['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0x46911c,null))[_0xf9a9('0x1f')](function(_0x8fd684){if(_0x8fd684){_0xba9475[_0xf9a9('0x41')]=_[_0xf9a9('0x58')](db['ChatOfflineMessage'][_0xf9a9('0x3d')]);_0xba9475['query']=_[_0xf9a9('0x58')](_0x3411ce[_0xf9a9('0x43')]);_0xba9475[_0xf9a9('0x44')]=_['intersection'](_0xba9475[_0xf9a9('0x41')],_0xba9475[_0xf9a9('0x43')]);_0x31a715[_0xf9a9('0x46')]=_[_0xf9a9('0x45')](_0xba9475[_0xf9a9('0x41')],qs[_0xf9a9('0x47')](_0x3411ce['query'][_0xf9a9('0x47')]));_0x31a715[_0xf9a9('0x46')]=_0x31a715[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x31a715['attributes']:_0xba9475['model'];if(!_0x3411ce['query'][_0xf9a9('0x49')](_0xf9a9('0x4a'))){_0x31a715[_0xf9a9('0x2d')]=qs['limit'](_0x3411ce[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x31a715[_0xf9a9('0x2c')]=qs[_0xf9a9('0x2c')](_0x3411ce[_0xf9a9('0x43')][_0xf9a9('0x2c')]);}_0x31a715[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x3411ce['query'][_0xf9a9('0x4c')]);_0x31a715['where']=qs['filters'](_[_0xf9a9('0x6d')](_0x3411ce[_0xf9a9('0x43')],_0xba9475[_0xf9a9('0x44')]));_0x31a715['where'][_0xf9a9('0x67')]=_0x8fd684['id'];if(_0x3411ce[_0xf9a9('0x43')]['filter']){_0x31a715[_0xf9a9('0x4d')]=_[_0xf9a9('0x4f')](_0x31a715[_0xf9a9('0x4d')],{'$or':_[_0xf9a9('0x42')](_0x31a715['attributes'],function(_0x8bca55){var _0x32c8cd={};_0x32c8cd[_0x8bca55]={'$like':'%'+_0x3411ce[_0xf9a9('0x43')]['filter']+'%'};return _0x32c8cd;})});}_0x31a715=_[_0xf9a9('0x4f')]({},_0x31a715,_0x3411ce[_0xf9a9('0x51')]);return db['ChatOfflineMessage']['count']({'where':_0x31a715[_0xf9a9('0x4d')]})[_0xf9a9('0x1f')](function(_0x528f6f){_0x2999bb['count']=_0x528f6f;if(_0x3411ce['query'][_0xf9a9('0x53')]){_0x31a715[_0xf9a9('0x54')]=[{'all':!![]}];}else{_0x31a715['include']=[{'model':db[_0xf9a9('0x9c')],'as':_0xf9a9('0x112'),'required':![]}];}return db[_0xf9a9('0x113')][_0xf9a9('0x55')](_0x31a715);})[_0xf9a9('0x1f')](function(_0x492d24){_0x2999bb['rows']=_0x492d24;return _0x2999bb;});}})[_0xf9a9('0x1f')](respondWithFilteredResult(_0x46911c,_0x31a715))[_0xf9a9('0x27')](handleError(_0x46911c,null));};exports[_0xf9a9('0x114')]=function(_0x3baa8f,_0xb89710,_0x5e1261){return db['ChatWebsite'][_0xf9a9('0x59')]({'where':{'id':_0x3baa8f[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0xb89710,null))['then'](function(_0x334800){if(_0x334800){return _0x334800[_0xf9a9('0x114')](_0x3baa8f[_0xf9a9('0x5b')][_0xf9a9('0x69')],_[_0xf9a9('0x10b')](_0x3baa8f[_0xf9a9('0x5b')],[_0xf9a9('0x69'),'id'])||{})[_0xf9a9('0xba')](function(_0x2505f1){for(var _0x36bf2e=0x0;_0x36bf2e<_0x3baa8f[_0xf9a9('0x5b')][_0xf9a9('0x69')][_0xf9a9('0x48')];_0x36bf2e+=0x1){socket['emit'](_0xf9a9('0x115'),{'UserId':_0x3baa8f[_0xf9a9('0x5b')]['ids'][_0x36bf2e],'ChatWebsiteId':_0x3baa8f[_0xf9a9('0x62')]['id']});}return _0x2505f1;});}})[_0xf9a9('0x1f')](respondWithResult(_0xb89710,null))[_0xf9a9('0x27')](handleError(_0xb89710,null));};exports[_0xf9a9('0x116')]=function(_0x1500eb,_0xb7c1a8,_0x28fbdd){return db[_0xf9a9('0x52')][_0xf9a9('0x59')]({'where':{'id':_0x1500eb[_0xf9a9('0x62')]['id']}})[_0xf9a9('0x1f')](handleEntityNotFound(_0xb7c1a8,null))['then'](function(_0x288760){if(_0x288760){return _0x288760[_0xf9a9('0x116')](_0x1500eb[_0xf9a9('0x43')]['ids'])[_0xf9a9('0x1f')](function(){if(_['isArray'](_0x1500eb[_0xf9a9('0x43')]['ids'])){for(var _0x4c948f=0x0;_0x4c948f<_0x1500eb['query'][_0xf9a9('0x69')][_0xf9a9('0x48')];_0x4c948f+=0x1){socket[_0xf9a9('0x117')]('userChatWebsite:remove',{'UserId':Number(_0x1500eb[_0xf9a9('0x43')][_0xf9a9('0x69')][_0x4c948f]),'ChatWebsiteId':Number(_0x1500eb[_0xf9a9('0x62')]['id'])});}}else{socket[_0xf9a9('0x117')]('userChatWebsite:remove',{'UserId':Number(_0x1500eb[_0xf9a9('0x43')][_0xf9a9('0x69')]),'ChatWebsiteId':Number(_0x1500eb[_0xf9a9('0x62')]['id'])});}});}})[_0xf9a9('0x1f')](respondWithStatusCode(_0xb7c1a8,null))[_0xf9a9('0x27')](handleError(_0xb7c1a8,null));};exports['getAgents']=function(_0x28b88d,_0x10cf31,_0x2440c0){var _0x22f80a={};var _0x3c92d7={};var _0x5b5854;var _0x286593;return db[_0xf9a9('0x52')][_0xf9a9('0xd4')]({'where':{'id':_0x28b88d['params']['id']}})['then'](handleEntityNotFound(_0x10cf31,null))[_0xf9a9('0x1f')](function(_0x164343){if(_0x164343){_0x5b5854=_0x164343;_0x3c92d7[_0xf9a9('0x41')]=_[_0xf9a9('0x58')](db['User']['rawAttributes']);_0x3c92d7[_0xf9a9('0x43')]=_[_0xf9a9('0x58')](_0x28b88d[_0xf9a9('0x43')]);_0x3c92d7[_0xf9a9('0x44')]=_[_0xf9a9('0x45')](_0x3c92d7[_0xf9a9('0x41')],_0x3c92d7[_0xf9a9('0x43')]);_0x22f80a[_0xf9a9('0x46')]=_['intersection'](_0x3c92d7[_0xf9a9('0x41')],qs['fields'](_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x47')]));_0x22f80a[_0xf9a9('0x46')]=_0x22f80a[_0xf9a9('0x46')][_0xf9a9('0x48')]?_0x22f80a['attributes']:_0x3c92d7[_0xf9a9('0x41')];_0x22f80a[_0xf9a9('0x4b')]=qs[_0xf9a9('0x4c')](_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x4c')]);_0x22f80a['where']=qs[_0xf9a9('0x44')](_['pick'](_0x28b88d[_0xf9a9('0x43')],_0x3c92d7[_0xf9a9('0x44')]));if(_0x28b88d['query']['filter']){_0x22f80a['where']=_['merge'](_0x22f80a[_0xf9a9('0x4d')],{'$or':_[_0xf9a9('0x42')](_0x22f80a['attributes'],function(_0x189e7b){var _0x49e65f={};_0x49e65f[_0x189e7b]={'$like':'%'+_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x4e')]+'%'};return _0x49e65f;})});}_0x22f80a=_[_0xf9a9('0x4f')]({},_0x22f80a,_0x28b88d[_0xf9a9('0x51')]);return _0x5b5854[_0xf9a9('0x118')](_0x22f80a);}})['then'](function(_0x3f19e0){if(_0x3f19e0){_0x286593=_0x3f19e0[_0xf9a9('0x48')];if(!_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x49')]('nolimit')){_0x22f80a['limit']=qs[_0xf9a9('0x2d')](_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x2d')]);_0x22f80a['offset']=qs[_0xf9a9('0x2c')](_0x28b88d[_0xf9a9('0x43')][_0xf9a9('0x2c')]);}return _0x5b5854[_0xf9a9('0x118')](_0x22f80a);}})[_0xf9a9('0x1f')](function(_0x2eab0e){if(_0x2eab0e){return _0x2eab0e?{'count':_0x286593,'rows':_0x2eab0e}:null;}})[_0xf9a9('0x1f')](respondWithResult(_0x10cf31,null))[_0xf9a9('0x27')](handleError(_0x10cf31,null));};
\ No newline at end of file