Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 138616c..039a415 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x019c=['create','body','user','role','ChatWebsites','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','Disposition','findOne','pick','removeDispositions','getAnswers','CannedAnswer','removeAnswers','ids','addLogo','sitepic','file','filename','addAvatar','agentAvatar','customerAvatar','addSystemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','existsSync','server/files/images/logos/','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','download','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','systemAvatar','notify','setUA','headers','user-agent','getResult','chat','CmContact','Sequelize','ValidationError','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','DESC','ChatApplication','Applications','account','applications','orderBy','priority','asc','Contacts','contact','customerIp','cf-connecting-ip','first','x-forwarded-for','firstName','lastName','x-real-port','referer','browser','format','%s\x20%s','version','unknown','device','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','push','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User','unshift','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','no\x20available\x20attributes','difference','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailServerOut','Smtp','forwardOffline','service','host','port','secure','authentication','pass','sendMail','\x22%s\x22\x20<%s>','forwardOfflineAddress','offlineMessageSubject','MailAccountId','email','Chat','NotifyMailAccount','notifyMail','addInteraction','omit','getInteractions','Contact','fullname','internal','Tag','color','tag','Command','timezone','iftime\x20%s,%s','interval','iftime\x20%s','true','ONLINE','OFFLINE','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','inspect','No\x20timezone','getSnippet','Interval','getProactiveActions','virtual','License','increment','chatLicenseExceeded','Intervals','all','some','server/files/chat/iframe.js','connection','replace','textColor','addApplications','sequelize','bulkCreate','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','offlineForm','items','fromKey','getOfflineMessages','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','reject','save','update','destroy','get','UserProfileResource','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','type','key','query','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','filter','merge','options','includeAll','include','findAll','rows','show','params','keys','rawAttributes','find'];(function(_0x15c6e1,_0x3555a2){var _0x597590=function(_0x707f04){while(--_0x707f04){_0x15c6e1['push'](_0x15c6e1['shift']());}};_0x597590(++_0x3555a2);}(_0x019c,0xca));var _0xc019=function(_0x28fca4,_0x11e78b){_0x28fca4=_0x28fca4-0x0;var _0x42fd01=_0x019c[_0x28fca4];return _0x42fd01;};'use strict';var pdf=require(_0xc019('0x0'));var emlformat=require(_0xc019('0x1'));var rimraf=require(_0xc019('0x2'));var zipdir=require(_0xc019('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc019('0x4'));var moment=require(_0xc019('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xc019('0x6'));var util=require(_0xc019('0x7'));var path=require(_0xc019('0x8'));var sox=require(_0xc019('0x9'));var csv=require(_0xc019('0xa'));var ejs=require(_0xc019('0xb'));var fs=require('fs');var _=require(_0xc019('0xc'));var squel=require(_0xc019('0xd'));var crypto=require(_0xc019('0xe'));var jsforce=require(_0xc019('0xf'));var deskjs=require(_0xc019('0x10'));var toCsv=require(_0xc019('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xc019('0x11'));var authService=require(_0xc019('0x12'));var qs=require(_0xc019('0x13'));var as=require(_0xc019('0x14'));var hardwareService=require(_0xc019('0x15'));var logger=require(_0xc019('0x16'))(_0xc019('0x17'));var utils=require(_0xc019('0x18'));var config=require(_0xc019('0x19'));var licenseUtil=require(_0xc019('0x1a'));var db=require(_0xc019('0x1b'))['db'];config[_0xc019('0x1c')]=_[_0xc019('0x1d')](config[_0xc019('0x1c')],{'host':'localhost','port':0x18eb});var socket=require(_0xc019('0x1e'))(new Redis(config[_0xc019('0x1c')]));require(_0xc019('0x1f'))[_0xc019('0x20')](socket);var jayson=require(_0xc019('0x21'));var client=jayson[_0xc019('0x22')][_0xc019('0x23')]({'port':0x232c});var client9002=jayson[_0xc019('0x22')][_0xc019('0x23')]({'port':0x232a});var client9003=jayson[_0xc019('0x22')][_0xc019('0x23')]({'port':0x232b});var client9001=jayson[_0xc019('0x22')][_0xc019('0x23')]({'port':0x2329});function respondWithRpcPromise(_0x26a46f,_0x3d9735,_0xa61d5f,_0x1a1785){return new BPromise(function(_0x4bef04,_0x1ae943){var _0x33a8eb=_0x1a1785||client;return _0x33a8eb[_0xc019('0x24')](_0x26a46f,_0xa61d5f)[_0xc019('0x25')](function(_0x4e550f){logger[_0xc019('0x26')](_0xc019('0x27'),_0x3d9735,_0xc019('0x28'));logger[_0xc019('0x29')](_0xc019('0x2a'),_0x3d9735,_0xc019('0x28'),JSON[_0xc019('0x2b')](_0x4e550f));if(_0x4e550f[_0xc019('0x2c')]){if(_0x4e550f[_0xc019('0x2c')][_0xc019('0x2d')]===0x1f4){logger[_0xc019('0x2c')](_0xc019('0x27'),_0x3d9735,_0x4e550f[_0xc019('0x2c')][_0xc019('0x2e')]);return _0x1ae943(_0x4e550f[_0xc019('0x2c')][_0xc019('0x2e')]);}logger['error'](_0xc019('0x27'),_0x3d9735,_0x4e550f[_0xc019('0x2c')]['message']);return _0x4bef04(_0x4e550f[_0xc019('0x2c')][_0xc019('0x2e')]);}else{logger[_0xc019('0x26')](_0xc019('0x27'),_0x3d9735,_0xc019('0x28'));_0x4bef04(_0x4e550f[_0xc019('0x2f')][_0xc019('0x2e')]);}})[_0xc019('0x30')](function(_0x31ea8e){logger[_0xc019('0x2c')]('ChatWebsite,\x20%s,\x20%s',_0x3d9735,_0x31ea8e);_0x1ae943(_0x31ea8e);});});}function respondWithStatusCode(_0x32e0ce,_0x1d0be5){_0x1d0be5=_0x1d0be5||0xcc;return function(_0x5bb04f){if(_0x5bb04f){return _0x32e0ce[_0xc019('0x31')](_0x1d0be5);}return _0x32e0ce[_0xc019('0x32')](_0x1d0be5)[_0xc019('0x33')]();};}function respondWithResult(_0x109538,_0x2019c6){_0x2019c6=_0x2019c6||0xc8;return function(_0x4aa159){if(_0x4aa159){return _0x109538['status'](_0x2019c6)[_0xc019('0x34')](_0x4aa159);}};}function respondWithFilteredResult(_0xc1f2f9,_0x292089){return function(_0x5c3c8f){if(_0x5c3c8f){var _0x1a93be=_0x5c3c8f[_0xc019('0x35')],_0x69e63c=_0x292089['offset'],_0x4f38f8=_0x292089[_0xc019('0x36')]+_0x292089[_0xc019('0x37')],_0x4caa29;if(_0x4f38f8>=_0x1a93be){_0x4f38f8=_0x1a93be;_0x4caa29=0xc8;}else{_0x4caa29=0xce;}_0xc1f2f9[_0xc019('0x32')](_0x4caa29);return _0xc1f2f9['set']('Content-Range',_0x69e63c+'-'+_0x4f38f8+'/'+_0x1a93be)[_0xc019('0x34')](_0x5c3c8f);}return null;};}function patchUpdates(_0x20a24a){return function(_0x1c440a){try{jsonpatch['apply'](_0x1c440a,_0x20a24a,!![]);}catch(_0x6aeca1){return BPromise[_0xc019('0x38')](_0x6aeca1);}return _0x1c440a[_0xc019('0x39')]();};}function saveUpdates(_0x1f8eb7,_0x5791dc){return function(_0x3a3ac6){if(_0x3a3ac6){return _0x3a3ac6[_0xc019('0x3a')](_0x1f8eb7)[_0xc019('0x25')](function(_0xe8f559){return _0xe8f559;});}return null;};}function removeEntity(_0x56494b,_0x27fd33){return function(_0x1f8164){if(_0x1f8164){return _0x1f8164[_0xc019('0x3b')]()[_0xc019('0x25')](function(){var _0x374fe4=_0x1f8164[_0xc019('0x3c')]({'plain':!![]});var _0x4ea239='ChatWebsites';return db[_0xc019('0x3d')][_0xc019('0x3b')]({'where':{'type':_0x4ea239,'resourceId':_0x374fe4['id']}})[_0xc019('0x25')](function(){return _0x1f8164;});})[_0xc019('0x25')](function(){_0x56494b['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x32a36e,_0x1cae60){return function(_0xa25bbe){if(!_0xa25bbe){_0x32a36e[_0xc019('0x31')](0x194);}return _0xa25bbe;};}function handleError(_0x5aa3a0,_0x4a7daa){_0x4a7daa=_0x4a7daa||0x1f4;return function(_0x27aa5c){logger[_0xc019('0x2c')](_0x27aa5c[_0xc019('0x3e')]);if(_0x27aa5c[_0xc019('0x3f')]){delete _0x27aa5c[_0xc019('0x3f')];}_0x5aa3a0[_0xc019('0x32')](_0x4a7daa)[_0xc019('0x40')](_0x27aa5c);};}exports[_0xc019('0x41')]=function(_0x2e60a8,_0x166f5f){var _0x3c10ae={'include':[{'model':db[_0xc019('0x42')],'as':_0xc019('0x43')}]},_0x4b99a4={},_0x3f36b1={'count':0x0,'rows':[]};var _0x31c5d7=_[_0xc019('0x44')](db[_0xc019('0x45')]['rawAttributes'],function(_0x3e63ac){return{'name':_0x3e63ac['fieldName'],'type':_0x3e63ac[_0xc019('0x46')][_0xc019('0x47')]};});_0x4b99a4['model']=_['map'](_0x31c5d7,_0xc019('0x3f'));_0x4b99a4[_0xc019('0x48')]=_['keys'](_0x2e60a8[_0xc019('0x48')]);_0x4b99a4['filters']=_[_0xc019('0x49')](_0x4b99a4[_0xc019('0x4a')],_0x4b99a4[_0xc019('0x48')]);_0x3c10ae[_0xc019('0x4b')]=_[_0xc019('0x49')](_0x4b99a4[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0x2e60a8[_0xc019('0x48')]['fields']));_0x3c10ae[_0xc019('0x4b')]=_0x3c10ae['attributes'][_0xc019('0x4d')]?_0x3c10ae[_0xc019('0x4b')]:_0x4b99a4[_0xc019('0x4a')];if(!_0x2e60a8[_0xc019('0x48')][_0xc019('0x4e')](_0xc019('0x4f'))){_0x3c10ae[_0xc019('0x37')]=qs[_0xc019('0x37')](_0x2e60a8[_0xc019('0x48')][_0xc019('0x37')]);_0x3c10ae['offset']=qs['offset'](_0x2e60a8['query'][_0xc019('0x36')]);}_0x3c10ae[_0xc019('0x50')]=qs['sort'](_0x2e60a8['query'][_0xc019('0x51')]);_0x3c10ae[_0xc019('0x52')]=qs[_0xc019('0x53')](_['pick'](_0x2e60a8['query'],_0x4b99a4[_0xc019('0x53')]),_0x31c5d7);if(_0x2e60a8['query'][_0xc019('0x54')]){_0x3c10ae['where']=_[_0xc019('0x55')](_0x3c10ae[_0xc019('0x52')],{'$or':_['map'](_0x31c5d7,function(_0x5a9af7){if(_0x5a9af7[_0xc019('0x46')]!=='VIRTUAL'){var _0x11c78f={};_0x11c78f[_0x5a9af7['name']]={'$like':'%'+_0x2e60a8[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x11c78f;}})});}_0x3c10ae=_[_0xc019('0x55')]({},_0x3c10ae,_0x2e60a8[_0xc019('0x56')]);var _0x46e72c={'where':_0x3c10ae['where']};return db['ChatWebsite'][_0xc019('0x35')](_0x46e72c)[_0xc019('0x25')](function(_0x1a792a){_0x3f36b1[_0xc019('0x35')]=_0x1a792a;if(_0x2e60a8[_0xc019('0x48')][_0xc019('0x57')]){_0x3c10ae[_0xc019('0x58')]=[{'all':!![]}];}return db[_0xc019('0x45')][_0xc019('0x59')](_0x3c10ae);})[_0xc019('0x25')](function(_0x41378d){_0x3f36b1[_0xc019('0x5a')]=_0x41378d;return _0x3f36b1;})['then'](respondWithFilteredResult(_0x166f5f,_0x3c10ae))[_0xc019('0x30')](handleError(_0x166f5f,null));};exports[_0xc019('0x5b')]=function(_0x34feaf,_0x129d3a){var _0x407e6d={'raw':![],'where':{'id':_0x34feaf[_0xc019('0x5c')]['id']},'include':[{'model':db[_0xc019('0x42')],'as':_0xc019('0x43')}]},_0x55b022={};_0x55b022['model']=_[_0xc019('0x5d')](db[_0xc019('0x45')][_0xc019('0x5e')]);_0x55b022[_0xc019('0x48')]=_[_0xc019('0x5d')](_0x34feaf[_0xc019('0x48')]);_0x55b022[_0xc019('0x53')]=_[_0xc019('0x49')](_0x55b022[_0xc019('0x4a')],_0x55b022[_0xc019('0x48')]);_0x407e6d[_0xc019('0x4b')]=_['intersection'](_0x55b022[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0x34feaf[_0xc019('0x48')]['fields']));_0x407e6d[_0xc019('0x4b')]=_0x407e6d['attributes'][_0xc019('0x4d')]?_0x407e6d[_0xc019('0x4b')]:_0x55b022[_0xc019('0x4a')];if(_0x34feaf[_0xc019('0x48')][_0xc019('0x57')]){_0x407e6d[_0xc019('0x58')]=[{'all':!![]}];}_0x407e6d=_[_0xc019('0x55')]({},_0x407e6d,_0x34feaf[_0xc019('0x56')]);return db[_0xc019('0x45')][_0xc019('0x5f')](_0x407e6d)[_0xc019('0x25')](handleEntityNotFound(_0x129d3a,null))[_0xc019('0x25')](respondWithResult(_0x129d3a,null))['catch'](handleError(_0x129d3a,null));};exports[_0xc019('0x60')]=function(_0x1b8381,_0x4d2f3c){return db[_0xc019('0x45')][_0xc019('0x60')](_0x1b8381[_0xc019('0x61')],{})['then'](function(_0x6a6409){var _0x1b5359=_0x1b8381[_0xc019('0x62')]['get']({'plain':!![]});if(!_0x1b5359)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1b5359[_0xc019('0x63')]==='user'){var _0x139f64=_0x6a6409[_0xc019('0x3c')]({'plain':!![]});var _0x5895e4=_0xc019('0x64');return db[_0xc019('0x65')][_0xc019('0x5f')]({'where':{'name':_0x5895e4,'userProfileId':_0x1b5359[_0xc019('0x66')]},'raw':!![]})['then'](function(_0x7adb08){if(_0x7adb08&&_0x7adb08[_0xc019('0x67')]===0x0){return db[_0xc019('0x3d')]['create']({'name':_0x139f64[_0xc019('0x3f')],'resourceId':_0x139f64['id'],'type':_0x7adb08[_0xc019('0x3f')],'sectionId':_0x7adb08['id']},{})['then'](function(){return _0x6a6409;});}else{return _0x6a6409;}})[_0xc019('0x30')](function(_0x266771){logger['error'](_0xc019('0x68'),_0x266771);throw _0x266771;});}return _0x6a6409;})[_0xc019('0x25')](respondWithResult(_0x4d2f3c,0xc9))[_0xc019('0x30')](handleError(_0x4d2f3c,null));};exports[_0xc019('0x3a')]=function(_0x54ed28,_0x1e22cf){if(_0x54ed28[_0xc019('0x61')]['id']){delete _0x54ed28[_0xc019('0x61')]['id'];}return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x54ed28[_0xc019('0x5c')]['id']},'include':[{'model':db[_0xc019('0x42')],'as':_0xc019('0x43')}]})[_0xc019('0x25')](handleEntityNotFound(_0x1e22cf,null))['then'](saveUpdates(_0x54ed28[_0xc019('0x61')],null))[_0xc019('0x25')](respondWithResult(_0x1e22cf,null))[_0xc019('0x30')](handleError(_0x1e22cf,null));};exports[_0xc019('0x3b')]=function(_0x502936,_0x1996ea){return db[_0xc019('0x45')]['find']({'where':{'id':_0x502936[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x1996ea,null))[_0xc019('0x25')](removeEntity(_0x1996ea,null))[_0xc019('0x30')](handleError(_0x1996ea,null));};exports[_0xc019('0x69')]=function(_0x364f53,_0x377055){return db[_0xc019('0x45')]['describe']()[_0xc019('0x25')](respondWithResult(_0x377055,null))[_0xc019('0x30')](handleError(_0x377055,null));};exports['addDisposition']=function(_0x35e416,_0x5e303a,_0x31f661){if(_0x35e416[_0xc019('0x61')]['id']){delete _0x35e416[_0xc019('0x61')]['id'];}return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x35e416['params']['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x5e303a,null))[_0xc019('0x25')](function(_0x5d036d){if(_0x5d036d){_0x35e416[_0xc019('0x61')][_0xc019('0x6a')]=_0x5d036d['id'];return db[_0xc019('0x6b')][_0xc019('0x60')](_0x35e416[_0xc019('0x61')]);}})[_0xc019('0x25')](respondWithResult(_0x5e303a,null))[_0xc019('0x30')](handleError(_0x5e303a,null));};exports['getDispositions']=function(_0x4997e8,_0x3233d7,_0x1f160f){var _0x1916c5={'raw':![],'where':{}};var _0x2d5042={};var _0x3af8ac={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xc019('0x6c')]({'where':{'id':_0x4997e8[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x3233d7,null))['then'](function(_0x21bbb1){if(_0x21bbb1){_0x2d5042['model']=_[_0xc019('0x5d')](db[_0xc019('0x6b')]['rawAttributes']);_0x2d5042['query']=_[_0xc019('0x5d')](_0x4997e8['query']);_0x2d5042[_0xc019('0x53')]=_[_0xc019('0x49')](_0x2d5042[_0xc019('0x4a')],_0x2d5042[_0xc019('0x48')]);_0x1916c5[_0xc019('0x4b')]=_['intersection'](_0x2d5042[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0x4997e8['query']['fields']));_0x1916c5['attributes']=_0x1916c5[_0xc019('0x4b')][_0xc019('0x4d')]?_0x1916c5[_0xc019('0x4b')]:_0x2d5042[_0xc019('0x4a')];if(!_0x4997e8[_0xc019('0x48')][_0xc019('0x4e')](_0xc019('0x4f'))){_0x1916c5[_0xc019('0x37')]=qs[_0xc019('0x37')](_0x4997e8['query'][_0xc019('0x37')]);_0x1916c5[_0xc019('0x36')]=qs[_0xc019('0x36')](_0x4997e8['query'][_0xc019('0x36')]);}_0x1916c5[_0xc019('0x50')]=qs[_0xc019('0x51')](_0x4997e8[_0xc019('0x48')][_0xc019('0x51')]);_0x1916c5['where']=qs['filters'](_[_0xc019('0x6d')](_0x4997e8[_0xc019('0x48')],_0x2d5042[_0xc019('0x53')]));_0x1916c5[_0xc019('0x52')][_0xc019('0x6a')]=_0x21bbb1['id'];if(_0x4997e8[_0xc019('0x48')][_0xc019('0x54')]){_0x1916c5['where']=_[_0xc019('0x55')](_0x1916c5[_0xc019('0x52')],{'$or':_[_0xc019('0x44')](_0x1916c5[_0xc019('0x4b')],function(_0x5dc300){var _0x31e0d9={};_0x31e0d9[_0x5dc300]={'$like':'%'+_0x4997e8[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x31e0d9;})});}_0x1916c5=_[_0xc019('0x55')]({},_0x1916c5,_0x4997e8['options']);return db[_0xc019('0x6b')][_0xc019('0x35')]({'where':_0x1916c5[_0xc019('0x52')]})[_0xc019('0x25')](function(_0x55a7b3){_0x3af8ac[_0xc019('0x35')]=_0x55a7b3;if(_0x4997e8[_0xc019('0x48')]['includeAll']){_0x1916c5[_0xc019('0x58')]=[{'all':!![]}];}return db[_0xc019('0x6b')]['findAll'](_0x1916c5);})[_0xc019('0x25')](function(_0x33c95a){_0x3af8ac[_0xc019('0x5a')]=_0x33c95a;return _0x3af8ac;});}})[_0xc019('0x25')](respondWithFilteredResult(_0x3233d7,_0x1916c5))[_0xc019('0x30')](handleError(_0x3233d7,null));};exports[_0xc019('0x6e')]=function(_0x43775e,_0x1c39dc,_0x36064c){return db['ChatWebsite']['find']({'where':{'id':_0x43775e[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x1c39dc,null))['then'](function(_0x3352fc){if(_0x3352fc){return _0x3352fc[_0xc019('0x6e')](_0x43775e[_0xc019('0x48')]['ids']);}})[_0xc019('0x25')](respondWithStatusCode(_0x1c39dc,null))[_0xc019('0x30')](handleError(_0x1c39dc,null));};exports['addAnswer']=function(_0x1ae226,_0x476438,_0x8e6c99){if(_0x1ae226[_0xc019('0x61')]['id']){delete _0x1ae226[_0xc019('0x61')]['id'];}return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x1ae226[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x476438,null))[_0xc019('0x25')](function(_0x4d9ab7){if(_0x4d9ab7){_0x1ae226[_0xc019('0x61')][_0xc019('0x6a')]=_0x4d9ab7['id'];return db['CannedAnswer']['create'](_0x1ae226[_0xc019('0x61')]);}})[_0xc019('0x25')](respondWithResult(_0x476438,null))[_0xc019('0x30')](handleError(_0x476438,null));};exports[_0xc019('0x6f')]=function(_0x4e82d7,_0x52112f,_0x27402f){var _0x4c1abe={'raw':![],'where':{}};var _0x22e99d={};var _0x390c7e={'count':0x0,'rows':[]};return db[_0xc019('0x45')][_0xc019('0x6c')]({'where':{'id':_0x4e82d7[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x52112f,null))[_0xc019('0x25')](function(_0x476f65){if(_0x476f65){_0x22e99d[_0xc019('0x4a')]=_['keys'](db[_0xc019('0x70')]['rawAttributes']);_0x22e99d[_0xc019('0x48')]=_[_0xc019('0x5d')](_0x4e82d7['query']);_0x22e99d[_0xc019('0x53')]=_[_0xc019('0x49')](_0x22e99d[_0xc019('0x4a')],_0x22e99d[_0xc019('0x48')]);_0x4c1abe[_0xc019('0x4b')]=_['intersection'](_0x22e99d[_0xc019('0x4a')],qs['fields'](_0x4e82d7['query'][_0xc019('0x4c')]));_0x4c1abe['attributes']=_0x4c1abe[_0xc019('0x4b')]['length']?_0x4c1abe[_0xc019('0x4b')]:_0x22e99d['model'];if(!_0x4e82d7['query'][_0xc019('0x4e')](_0xc019('0x4f'))){_0x4c1abe['limit']=qs[_0xc019('0x37')](_0x4e82d7['query'][_0xc019('0x37')]);_0x4c1abe[_0xc019('0x36')]=qs['offset'](_0x4e82d7[_0xc019('0x48')][_0xc019('0x36')]);}_0x4c1abe[_0xc019('0x50')]=qs['sort'](_0x4e82d7['query'][_0xc019('0x51')]);_0x4c1abe[_0xc019('0x52')]=qs[_0xc019('0x53')](_[_0xc019('0x6d')](_0x4e82d7[_0xc019('0x48')],_0x22e99d[_0xc019('0x53')]));_0x4c1abe[_0xc019('0x52')][_0xc019('0x6a')]=_0x476f65['id'];if(_0x4e82d7[_0xc019('0x48')][_0xc019('0x54')]){_0x4c1abe[_0xc019('0x52')]=_[_0xc019('0x55')](_0x4c1abe[_0xc019('0x52')],{'$or':_[_0xc019('0x44')](_0x4c1abe[_0xc019('0x4b')],function(_0x4f9cce){var _0x404641={};_0x404641[_0x4f9cce]={'$like':'%'+_0x4e82d7[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x404641;})});}_0x4c1abe=_['merge']({},_0x4c1abe,_0x4e82d7[_0xc019('0x56')]);return db[_0xc019('0x70')][_0xc019('0x35')]({'where':_0x4c1abe[_0xc019('0x52')]})[_0xc019('0x25')](function(_0x263f2d){_0x390c7e[_0xc019('0x35')]=_0x263f2d;if(_0x4e82d7[_0xc019('0x48')][_0xc019('0x57')]){_0x4c1abe[_0xc019('0x58')]=[{'all':!![]}];}return db[_0xc019('0x70')]['findAll'](_0x4c1abe);})[_0xc019('0x25')](function(_0x27b6c1){_0x390c7e['rows']=_0x27b6c1;return _0x390c7e;});}})[_0xc019('0x25')](respondWithFilteredResult(_0x52112f,_0x4c1abe))[_0xc019('0x30')](handleError(_0x52112f,null));};exports[_0xc019('0x71')]=function(_0x4c5163,_0x5c364a,_0x5284aa){return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x4c5163[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x5c364a,null))[_0xc019('0x25')](function(_0x113ead){if(_0x113ead){return _0x113ead[_0xc019('0x71')](_0x4c5163[_0xc019('0x48')][_0xc019('0x72')]);}})[_0xc019('0x25')](respondWithStatusCode(_0x5c364a,null))[_0xc019('0x30')](handleError(_0x5c364a,null));};exports[_0xc019('0x73')]=function(_0x5f1616,_0x3d6323,_0x11a0a2){_0x5f1616['body'][_0xc019('0x74')]=_0x5f1616[_0xc019('0x75')][_0xc019('0x76')];return db['ChatWebsite'][_0xc019('0x5f')]({'where':{'id':_0x5f1616[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x3d6323,null))[_0xc019('0x25')](saveUpdates(_0x5f1616[_0xc019('0x61')],null))[_0xc019('0x25')](respondWithResult(_0x3d6323,null))[_0xc019('0x30')](handleError(_0x3d6323,null));};exports[_0xc019('0x77')]=function(_0x567255,_0x437a8f,_0x9449d7){_0x567255[_0xc019('0x61')][_0xc019('0x78')]=_0x567255[_0xc019('0x75')][_0xc019('0x76')];return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x567255[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x437a8f,null))['then'](saveUpdates(_0x567255[_0xc019('0x61')],null))[_0xc019('0x25')](respondWithResult(_0x437a8f,null))[_0xc019('0x30')](handleError(_0x437a8f,null));};exports['addCustomerAvatar']=function(_0x275ceb,_0x7b8aa9,_0x11ae2d){_0x275ceb['body'][_0xc019('0x79')]=_0x275ceb['file'][_0xc019('0x76')];return db[_0xc019('0x45')]['find']({'where':{'id':_0x275ceb[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x7b8aa9,null))[_0xc019('0x25')](saveUpdates(_0x275ceb[_0xc019('0x61')],null))[_0xc019('0x25')](respondWithResult(_0x7b8aa9,null))['catch'](handleError(_0x7b8aa9,null));};exports[_0xc019('0x7a')]=function(_0x1aa4be,_0x2ee9bb,_0x387fd4){_0x1aa4be[_0xc019('0x61')]['systemAvatar']=_0x1aa4be[_0xc019('0x75')][_0xc019('0x76')];return db['ChatWebsite'][_0xc019('0x5f')]({'where':{'id':_0x1aa4be[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x2ee9bb,null))['then'](saveUpdates(_0x1aa4be[_0xc019('0x61')],null))[_0xc019('0x25')](respondWithResult(_0x2ee9bb,null))['catch'](handleError(_0x2ee9bb,null));};exports[_0xc019('0x7b')]=function(_0x38f75a,_0xfd7723,_0x2e5669){var _0x5a4119=path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x7e'));var _0x15d463={'where':{'id':_0x38f75a['params']['id']},'attributes':['id',_0xc019('0x74')],'raw':!![]};var _0x1141d4=![];return require(_0xc019('0x1a'))[_0xc019('0x7f')]()[_0xc019('0x25')](function(_0x4f3f4b){if(_0x4f3f4b){_0x1141d4=_0x4f3f4b[_0xc019('0x80')];}})[_0xc019('0x25')](function(){return db['ChatWebsite'][_0xc019('0x5f')](_0x15d463);})[_0xc019('0x25')](handleEntityNotFound(_0xfd7723,null))[_0xc019('0x25')](function(_0x4a294d){if(_0x4a294d){if(!_[_0xc019('0x81')](_0x4a294d[_0xc019('0x74')])){if(fs[_0xc019('0x82')](path['join'](config[_0xc019('0x7d')],_0xc019('0x83'),_0x4a294d[_0xc019('0x74')]))&&_0x1141d4){_0x5a4119=path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x83'),_0x4a294d['sitepic']);}}return _0xfd7723['download'](_0x5a4119);}})[_0xc019('0x30')](handleError(_0xfd7723,null));};exports[_0xc019('0x84')]=function(_0x114f3f,_0x5a376b,_0x46ce58){var _0x5ac3ea=path[_0xc019('0x7c')](config['root'],_0xc019('0x85'));var _0x4362f3={'where':{'id':_0x114f3f[_0xc019('0x5c')]['id']},'attributes':['id',_0xc019('0x78')],'raw':!![]};return db[_0xc019('0x45')][_0xc019('0x5f')](_0x4362f3)['then'](handleEntityNotFound(_0x5a376b,null))[_0xc019('0x25')](function(_0x99085a){if(_0x99085a){if(!_[_0xc019('0x81')](_0x99085a[_0xc019('0x78')])){if(fs[_0xc019('0x82')](path['join'](config[_0xc019('0x7d')],_0xc019('0x86'),_0x99085a[_0xc019('0x78')]))){_0x5ac3ea=path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x86'),_0x99085a[_0xc019('0x78')]);}}return _0x5a376b[_0xc019('0x87')](_0x5ac3ea);}})[_0xc019('0x30')](handleError(_0x5a376b,null));};exports['getCustomerAvatar']=function(_0x2e1efe,_0xd122a0,_0x5cc63b){var _0x1d9420=path[_0xc019('0x7c')](config['root'],_0xc019('0x88'));var _0x34690a={'where':{'id':_0x2e1efe[_0xc019('0x5c')]['id']},'attributes':['id',_0xc019('0x79'),_0xc019('0x89')],'raw':!![]};return db['ChatWebsite'][_0xc019('0x5f')](_0x34690a)[_0xc019('0x25')](handleEntityNotFound(_0xd122a0,null))[_0xc019('0x25')](function(_0x98c0d){if(_0x98c0d){if(!_[_0xc019('0x81')](_0x98c0d[_0xc019('0x79')])){if(fs[_0xc019('0x82')](path[_0xc019('0x7c')](config[_0xc019('0x7d')],'server/files/images/avatars/',_0x98c0d[_0xc019('0x79')]))&&_0x98c0d[_0xc019('0x89')]){_0x1d9420=path['join'](config['root'],_0xc019('0x86'),_0x98c0d[_0xc019('0x79')]);}}return _0xd122a0['download'](_0x1d9420);}})['catch'](handleError(_0xd122a0,null));};exports[_0xc019('0x8a')]=function(_0x1f3bce,_0x3368a0,_0x59e7f8){var _0x9dfd44=path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x8b'));var _0x32a19e={'where':{'id':_0x1f3bce[_0xc019('0x5c')]['id']},'attributes':['id',_0xc019('0x8c')],'raw':!![]};return db['ChatWebsite'][_0xc019('0x5f')](_0x32a19e)[_0xc019('0x25')](handleEntityNotFound(_0x3368a0,null))[_0xc019('0x25')](function(_0x358452){if(_0x358452){if(!_[_0xc019('0x81')](_0x358452[_0xc019('0x8c')])){if(fs[_0xc019('0x82')](path[_0xc019('0x7c')](config[_0xc019('0x7d')],'server/files/images/avatars/',_0x358452[_0xc019('0x8c')]))){_0x9dfd44=path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x86'),_0x358452[_0xc019('0x8c')]);}}return _0x3368a0['download'](_0x9dfd44);}})[_0xc019('0x30')](handleError(_0x3368a0,null));};exports[_0xc019('0x8d')]=function(_0xb40300,_0x3b09b2,_0xe4fdca){var _0x1ac3c8=require('user-agent-parser');var _0x2f78c6=new _0x1ac3c8();var _0x263def=_0x2f78c6[_0xc019('0x8e')](_0xb40300[_0xc019('0x8f')][_0xc019('0x90')])[_0xc019('0x91')]();var _0x1b2a0d={'body':_0xb40300['body'],'channel':_0xc019('0x92')};var _0x1940b6=[];var _0x5da332=[];var _0x90ca2={};var _0xc1c01b=![];return db[_0xc019('0x93')]['describe']()[_0xc019('0x25')](function(_0x386f80){if(!_0x386f80){throw new db[(_0xc019('0x94'))][(_0xc019('0x95'))]('no\x20available\x20attributes');}_0x1940b6=_['difference'](_['keys'](_0x386f80),[_0xc019('0x96'),_0xc019('0x97')]);_0x5da332=_['difference'](_[_0xc019('0x5d')](_0x386f80),[_0xc019('0x96'),_0xc019('0x97'),_0xc019('0x98'),_0xc019('0x99')]);if(_0xb40300[_0xc019('0x61')]['id']){delete _0xb40300[_0xc019('0x61')]['id'];}if(_['isNil'](_0xb40300[_0xc019('0x61')][_0xc019('0x9a')])){throw new db['Sequelize'][(_0xc019('0x95'))](_0xc019('0x9b'));}if(_[_0xc019('0x81')](_0xb40300[_0xc019('0x61')][_0xc019('0x61')])||_0xb40300[_0xc019('0x61')][_0xc019('0x61')]===''){throw new db['Sequelize']['ValidationError'](_0xc019('0x9c'));}if(_[_0xc019('0x81')](_0xb40300[_0xc019('0x61')][_0xc019('0x9d')])){throw new db[(_0xc019('0x94'))][(_0xc019('0x95'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x5da332);}if(!_['includes'](_0x5da332,_0xb40300[_0xc019('0x61')]['mapKey'])){throw new db[(_0xc019('0x94'))][(_0xc019('0x95'))](_0xc019('0x9e')+_0x5da332);}_0x90ca2[_0xb40300[_0xc019('0x61')][_0xc019('0x9d')]]=_0xb40300['body'][_0xc019('0x9a')];})[_0xc019('0x25')](function(){return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0xb40300[_0xc019('0x5c')]['id']},'include':[{'model':db[_0xc019('0x9f')],'as':_0xc019('0xa0'),'include':[{'model':db[_0xc019('0x93')],'as':'Contacts','where':_0x90ca2,'limit':0x1,'order':[[_0xc019('0x97'),_0xc019('0xa1')]]}]},{'model':db[_0xc019('0xa2')],'as':_0xc019('0xa3')}]});})[_0xc019('0x25')](handleEntityNotFound(_0x3b09b2,null))[_0xc019('0x25')](function(_0x51ca83){if(_0x51ca83&&_0x51ca83['List']){_0x1b2a0d[_0xc019('0xa4')]=_0x51ca83;_0x1b2a0d[_0xc019('0xa5')]=_0x51ca83[_0xc019('0xa3')];_0x1b2a0d['list']=_0x51ca83['List'];_0x1b2a0d['applications']=_[_0xc019('0xa6')](_0x1b2a0d[_0xc019('0xa5')],[_0xc019('0xa7')],[_0xc019('0xa8')]);if(_0x1b2a0d[_0xc019('0xa4')]['Applications']){delete _0x1b2a0d[_0xc019('0xa4')][_0xc019('0xa3')];}if(_0x1b2a0d[_0xc019('0xa4')][_0xc019('0xa0')]&&_0x1b2a0d[_0xc019('0xa4')][_0xc019('0xa0')][_0xc019('0xa9')][_0xc019('0x4d')]){return _0x1b2a0d[_0xc019('0xa4')]['List'][_0xc019('0xa9')][0x0];}var _0x20c267=_[_0xc019('0x1d')](_0xb40300[_0xc019('0x61')],{'firstName':_0xb40300[_0xc019('0x61')][_0xc019('0x9a')],'ListId':_0x51ca83[_0xc019('0x99')]});_0x20c267[_0xb40300[_0xc019('0x61')][_0xc019('0x9d')]]=_0xb40300[_0xc019('0x61')][_0xc019('0x9a')];return db[_0xc019('0x93')]['create'](_0x20c267,{'fields':_0x1940b6,'raw':!![]});}})['then'](handleEntityNotFound(_0x3b09b2,null))[_0xc019('0x25')](function(_0x5a68fa){_0x1b2a0d[_0xc019('0xaa')]=_0x5a68fa;var _0x479a06=_0xb40300['body'][_0xc019('0xab')];if(_0xb40300[_0xc019('0x8f')]['cf-connecting-ip']){_0x479a06=_0xb40300['headers'][_0xc019('0xac')];}else if(_0xb40300[_0xc019('0x8f')]['x-forwarded-for']){_0x479a06=_[_0xc019('0xad')](_0xb40300[_0xc019('0x8f')][_0xc019('0xae')]['split'](','));}if(_0x5a68fa){var _0x10c5ca={'ContactId':_0x5a68fa['id'],'ChatWebsiteId':_0xb40300[_0xc019('0x5c')]['id'],'from':(_0x5a68fa[_0xc019('0xaf')]||'')+'\x20'+(_0x5a68fa[_0xc019('0xb0')]||''),'customerIp':_0x479a06,'customerPort':_0xb40300['headers'][_0xc019('0xb1')]?_0xb40300[_0xc019('0x8f')][_0xc019('0xb1')]:null,'referer':_0xb40300[_0xc019('0x61')][_0xc019('0xb2')],'browserName':_0x263def[_0xc019('0xb3')]['name']&&_0x263def[_0xc019('0xb3')]['version']?util[_0xc019('0xb4')](_0xc019('0xb5'),_0x263def['browser'][_0xc019('0x3f')],_0x263def['browser'][_0xc019('0xb6')]):_0xc019('0xb7'),'browserVersion':_0x263def[_0xc019('0xb3')][_0xc019('0xb6')]||'unknown','osName':util[_0xc019('0xb4')](_0xc019('0xb5'),_0x263def['os'][_0xc019('0x3f')],_0x263def['os'][_0xc019('0xb6')]),'osVersion':_0x263def['os'][_0xc019('0xb6')],'deviceModel':_0x263def['device'][_0xc019('0x4a')]&&_0x263def[_0xc019('0xb8')][_0xc019('0xb9')]?util[_0xc019('0xb4')]('%s\x20%s\x20%s',_0x263def[_0xc019('0xb8')]['model'],_0x263def[_0xc019('0xb8')][_0xc019('0xb9')],_0x263def['device'][_0xc019('0x46')]):null,'deviceVendor':_0x263def[_0xc019('0xb8')][_0xc019('0xb9')],'deviceType':_0x263def[_0xc019('0xb8')][_0xc019('0x46')],'formData':JSON[_0xc019('0x2b')](_0xb40300[_0xc019('0x61')])};var _0x52952c={'ChatWebsiteId':_0xb40300[_0xc019('0x5c')]['id'],'closed':![]};if(_0xb40300[_0xc019('0x61')]['threadId']){_0x52952c[_0xc019('0xba')]=_0xb40300[_0xc019('0x61')][_0xc019('0xba')];return db[_0xc019('0xbb')]['find']({'where':_0x52952c})[_0xc019('0x25')](function(_0x1b352a){if(_0x1b352a){return[_0x1b352a,![]];}_0x10c5ca['threadId']=_0xb40300[_0xc019('0x61')][_0xc019('0xba')];_0x10c5ca[_0xc019('0xbc')]=_0xb40300['body'][_0xc019('0xbc')];return db['ChatInteraction'][_0xc019('0x60')](_0x10c5ca)[_0xc019('0x25')](function(_0x44d8cf){return[_0x44d8cf,!![]];});});}_0x52952c[_0xc019('0xbd')]=_0x5a68fa['id'];if(_0xb40300[_0xc019('0x61')][_0xc019('0xbe')]&&_0xb40300[_0xc019('0x61')]['interaction']['id']){_0x52952c['id']=_0xb40300[_0xc019('0x61')][_0xc019('0xbe')]['id'];return db[_0xc019('0xbb')]['find']({'where':_0x52952c})['then'](function(_0x140d2c){if(_0x140d2c){return[_0x140d2c,![]];}return db[_0xc019('0xbb')][_0xc019('0x60')](_0x10c5ca)[_0xc019('0x25')](function(_0x57421e){return[_0x57421e,!![]];});});}return db[_0xc019('0xbb')][_0xc019('0x60')](_0x10c5ca)[_0xc019('0x25')](function(_0x1fb5b3){return[_0x1fb5b3,!![]];});}})[_0xc019('0xbf')](function(_0x92b9e2,_0x256d68){if(_0x92b9e2){_0xc1c01b=_0x256d68;if(!_0x256d68){var _0x5345a1={'from':(_0x1b2a0d[_0xc019('0xaa')][_0xc019('0xaf')]||'')+'\x20'+(_0x1b2a0d[_0xc019('0xaa')][_0xc019('0xb0')]||'')};if(_0xb40300[_0xc019('0x61')]['threadId']&&_0xb40300[_0xc019('0x61')][_0xc019('0xc0')]&&_0xb40300[_0xc019('0x61')][_0xc019('0xba')]!=_0xb40300[_0xc019('0x61')]['messageId']){_0x5345a1['threadId']=_0xb40300[_0xc019('0x61')][_0xc019('0xc0')];}return _0x92b9e2['update'](_0x5345a1);}else{return _0x92b9e2;}}})['then'](function(_0x5b5d85){_0x1b2a0d['interaction']=_0x5b5d85['get']({'plain':!![]});_0x1b2a0d[_0xc019('0xbe')][_0xc019('0xc1')]=_0xc1c01b;if(_0x1b2a0d['interaction'][_0xc019('0xc1')]){if(_0x1b2a0d['account'][_0xc019('0xc2')]){_0x1b2a0d[_0xc019('0xa5')][_0xc019('0xc3')]({'id':0x0,'priority':_0x1b2a0d[_0xc019('0xa5')]['length']+0x1,'app':_0xc019('0xc4'),'appdata':_0xc019('0xc5'),'interval':_0xc019('0xc6')});}}return db[_0xc019('0xc7')][_0xc019('0x60')]({'body':_0xb40300[_0xc019('0x61')]['body'],'ChatWebsiteId':_0xb40300['params']['id'],'ChatInteractionId':_0x5b5d85['id'],'direction':'in','ContactId':_0x1b2a0d[_0xc019('0xaa')]['id'],'AttachmentId':_0xb40300['body'][_0xc019('0xc8')]});})[_0xc019('0x25')](function(_0x2fa668){_0x1b2a0d[_0xc019('0x2e')]=_0x2fa668;if(_0x1b2a0d[_0xc019('0xbe')][_0xc019('0xc9')]){return db[_0xc019('0xca')][_0xc019('0x5f')]({'attributes':['id',_0xc019('0x3f')],'where':{'id':_0x1b2a0d[_0xc019('0xbe')][_0xc019('0xc9')]}})[_0xc019('0x25')](function(_0x15d843){if(_0x15d843){_0x1b2a0d[_0xc019('0xa5')][_0xc019('0xcb')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x15d843['name']+','+(_0x1b2a0d[_0xc019('0xa4')][_0xc019('0xcc')]||0xa),'interval':'*,*,*,*'});_0x1b2a0d[_0xc019('0xcd')]=!![];}return respondWithRpcPromise('Start','startRouting',_0x1b2a0d);});}return respondWithRpcPromise(_0xc019('0xce'),_0xc019('0xcf'),_0x1b2a0d);})[_0xc019('0x25')](function(_0x2a0583){respondWithRpcPromise(_0xc019('0xd0'),_0xc019('0xd0'),{'event':_0xc019('0x8d'),'message':_0x2a0583},client9002);return _0x2a0583;})['then'](respondWithResult(_0x3b09b2,null))['catch'](handleError(_0x3b09b2,null));};exports[_0xc019('0xd1')]=function(_0x21ef7b,_0x409412,_0x196d3f){var _0xd2888f,_0xafd9b1,_0x18cfdb;var _0x57ecaa=[];var _0x2a124c=[];var _0x38ad02={};return db[_0xc019('0x93')][_0xc019('0x69')]()[_0xc019('0x25')](function(_0x149a25){if(!_0x149a25){throw new db[(_0xc019('0x94'))][(_0xc019('0x95'))](_0xc019('0xd2'));}_0x2a124c=_[_0xc019('0xd3')](_[_0xc019('0x5d')](_0x149a25),[_0xc019('0x96'),_0xc019('0x97')]);_0x57ecaa=_[_0xc019('0xd3')](_['keys'](_0x149a25),[_0xc019('0x96'),'updatedAt','CompanyId','ListId']);if(_0x21ef7b[_0xc019('0x61')]['id']){delete _0x21ef7b[_0xc019('0x61')]['id'];}if(_[_0xc019('0x81')](_0x21ef7b[_0xc019('0x61')][_0xc019('0x9a')])){throw _0x409412[_0xc019('0x32')](0x1f4)[_0xc019('0x40')](new db['Sequelize'][(_0xc019('0x95'))](_0xc019('0x9b')));}if(_[_0xc019('0x81')](_0x21ef7b[_0xc019('0x61')]['body'])||_0x21ef7b[_0xc019('0x61')]['body']===''){throw _0x409412['status'](0x1f4)[_0xc019('0x40')](new db['Sequelize'][(_0xc019('0x95'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xc019('0x81')](_0x21ef7b[_0xc019('0x61')][_0xc019('0xd4')])){throw _0x409412[_0xc019('0x32')](0x1f4)['send'](new db[(_0xc019('0x94'))][(_0xc019('0x95'))](_0xc019('0xd5')+_0x57ecaa));}if(!_[_0xc019('0xd6')](_0x57ecaa,_0x21ef7b[_0xc019('0x61')]['mapKeyOffline'])){throw _0x409412['status'](0x1f4)['send'](new db['Sequelize'][(_0xc019('0x95'))](_0xc019('0xd7')+_0x57ecaa));}_0x38ad02[_0x21ef7b[_0xc019('0x61')][_0xc019('0xd4')]]=_0x21ef7b[_0xc019('0x61')][_0xc019('0x9a')];})[_0xc019('0x25')](function(){return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x21ef7b['params']['id']},'include':[{'model':db[_0xc019('0x9f')],'as':'List'},{'model':db[_0xc019('0xd8')],'as':'MailAccount'}]});})[_0xc019('0x25')](handleEntityNotFound(_0x409412,null))[_0xc019('0x25')](function(_0xff38c4){if(_0xff38c4&&_0xff38c4[_0xc019('0xa0')]){_0xafd9b1=_0xff38c4;var _0x1d198a=_['defaults'](_0x21ef7b[_0xc019('0x61')],{'firstName':_0x21ef7b[_0xc019('0x61')][_0xc019('0x9a')],'phone':_0x21ef7b['body'][_0xc019('0x9a')],'ListId':_0xff38c4[_0xc019('0x99')]});_0x1d198a[_0x21ef7b['body'][_0xc019('0xd4')]]=_0x21ef7b[_0xc019('0x61')][_0xc019('0x9a')];return db[_0xc019('0x93')][_0xc019('0xd9')]({'where':_0x38ad02,'defaults':_0x1d198a});}})[_0xc019('0xbf')](function(_0x15adb7){if(_0x15adb7){_0x18cfdb=_0x15adb7;var _0x11af8f=fs[_0xc019('0xda')](path[_0xc019('0x7c')](config[_0xc019('0x7d')],'server/files/templates/chatOfflineMessage.ejs'),_0xc019('0xdb'));var _0xcdd891=ejs[_0xc019('0xdc')](_0x11af8f,{'body':_[_0xc019('0xdd')](_0x21ef7b['body'][_0xc019('0x61')]),'bodyTitle':_0xafd9b1[_0xc019('0xde')]});return db[_0xc019('0xdf')][_0xc019('0x60')]({'body':_0xcdd891,'ContactId':_0x15adb7['id'],'ChatWebsiteId':_0xafd9b1['id']});}})[_0xc019('0x25')](function(_0x5f16d0){if(_0x5f16d0){_0xd2888f=_0x5f16d0;return db[_0xc019('0xd8')][_0xc019('0x6c')]({'where':{'service':!![]},'include':[{'model':db[_0xc019('0xe0')],'as':_0xc019('0xe1'),'raw':!![]}]});}})[_0xc019('0x25')](function(_0x3d319c){if(_0x3d319c&&_0x3d319c[_0xc019('0xe1')]&&_0xafd9b1[_0xc019('0xe2')]&&_0xafd9b1['forwardOfflineAddress']){var _0x3632dc={'tls':{'rejectUnauthorized':![]}};if(_0x3d319c[_0xc019('0xe1')]['service']){_0x3632dc[_0xc019('0xe3')]=_0x3d319c['Smtp'][_0xc019('0xe3')];}else{_0x3632dc[_0xc019('0xe4')]=_0x3d319c[_0xc019('0xe1')][_0xc019('0xe4')];_0x3632dc['port']=_0x3d319c[_0xc019('0xe1')][_0xc019('0xe5')];_0x3632dc[_0xc019('0xe6')]=_0x3d319c[_0xc019('0xe1')][_0xc019('0xe6')];}if(_0x3d319c['Smtp'][_0xc019('0xe7')]){_0x3632dc['auth']={'user':_0x3d319c[_0xc019('0xe1')][_0xc019('0x62')],'pass':_0x3d319c[_0xc019('0xe1')][_0xc019('0xe8')]};}return respondWithRpcPromise('SendMail',_0xc019('0xe9'),{'account':_0x3632dc,'message':{'from':util[_0xc019('0xb4')](_0xc019('0xea'),_0x3d319c[_0xc019('0x3f')],_0x3d319c['email']||_0x3d319c[_0xc019('0xe1')][_0xc019('0x62')]),'to':_0xafd9b1[_0xc019('0xeb')],'subject':_0xafd9b1[_0xc019('0xec')],'text':_0xd2888f[_0xc019('0x61')]}},client9003)['then'](function(){return _0xd2888f;})[_0xc019('0x30')](function(_0x4fa6de){console[_0xc019('0x2c')](_0x4fa6de);});}})['then'](function(){if(_0xafd9b1&&_0xafd9b1['openNewInteraction']&&_0xafd9b1[_0xc019('0xed')]){var _0xe27d54={'from':_0x18cfdb['email'],'firstName':_0x18cfdb['firstName'],'lastName':_0x18cfdb[_0xc019('0xb0')],'mapKey':_0xc019('0xee'),'message':{'from':_0x18cfdb[_0xc019('0xee')],'to':_0xafd9b1['MailAccount'][_0xc019('0xee')],'cc':'','subject':_0xafd9b1[_0xc019('0xec')],'messageId':'','sentAt':new Date(),'attach':![],'attachments':[],'originChannel':_0xc019('0xef'),'ChatWebsiteId':_0xafd9b1['id'],'ChatOfflineMessageId':_0xd2888f['id'],'originTo':_0xafd9b1['MailAccount'][_0xc019('0xee')]},'body':_0xd2888f[_0xc019('0x61')]};var _0x4192a4={'account':{'id':_0xafd9b1['MailAccountId']},'body':_0xe27d54,'log':_0xc019('0xf0')};return respondWithRpcPromise('NotifyMailAccount',_0xc019('0xf1'),_0x4192a4,client9001)[_0xc019('0x25')](function(){return _0xd2888f;})[_0xc019('0x30')](function(_0x392d6c){console['error'](_0x392d6c);});}return;})[_0xc019('0x25')](function(){if(_0xd2888f){return _0xd2888f;}})['then'](respondWithResult(_0x409412,null))[_0xc019('0x30')](handleError(_0x409412,null));};exports[_0xc019('0xf2')]=function(_0x500a51,_0x5cd836,_0x171fe5){return db[_0xc019('0xbb')][_0xc019('0x5f')]({'where':{'id':_0x500a51[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x5cd836,null))[_0xc019('0x25')](function(_0x4c9e32){if(_0x4c9e32){return _0x4c9e32[_0xc019('0xf2')](_0x500a51['body'][_0xc019('0x72')],_[_0xc019('0xf3')](_0x500a51[_0xc019('0x61')],[_0xc019('0x72'),'id'])||{});}})[_0xc019('0x25')](respondWithResult(_0x5cd836,null))[_0xc019('0x30')](handleError(_0x5cd836,null));};exports[_0xc019('0xf4')]=function(_0x366066,_0x4b9b84,_0x4db3f0){var _0x4545aa={'raw':![],'where':{}};var _0x28ae50={};var _0x35582c={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xc019('0x6c')]({'where':{'id':_0x366066[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x4b9b84,null))[_0xc019('0x25')](function(_0x525acf){if(_0x525acf){_0x28ae50[_0xc019('0x4a')]=_[_0xc019('0x5d')](db[_0xc019('0xbb')][_0xc019('0x5e')]);_0x28ae50[_0xc019('0x48')]=_[_0xc019('0x5d')](_0x366066['query']);_0x28ae50['filters']=_[_0xc019('0x49')](_0x28ae50['model'],_0x28ae50['query']);_0x4545aa['attributes']=_[_0xc019('0x49')](_0x28ae50[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0x366066[_0xc019('0x48')]['fields']));_0x4545aa[_0xc019('0x4b')]=_0x4545aa[_0xc019('0x4b')][_0xc019('0x4d')]?_0x4545aa[_0xc019('0x4b')]:_0x28ae50['model'];if(!_0x366066[_0xc019('0x48')][_0xc019('0x4e')](_0xc019('0x4f'))){_0x4545aa['limit']=qs[_0xc019('0x37')](_0x366066[_0xc019('0x48')]['limit']);_0x4545aa[_0xc019('0x36')]=qs['offset'](_0x366066['query'][_0xc019('0x36')]);}_0x4545aa[_0xc019('0x50')]=qs[_0xc019('0x51')](_0x366066[_0xc019('0x48')]['sort']);_0x4545aa[_0xc019('0x52')]=qs[_0xc019('0x53')](_[_0xc019('0x6d')](_0x366066[_0xc019('0x48')],_0x28ae50[_0xc019('0x53')]));_0x4545aa[_0xc019('0x52')]['ChatWebsiteId']=_0x525acf['id'];if(_0x366066[_0xc019('0x48')][_0xc019('0x54')]){_0x4545aa['where']=_[_0xc019('0x55')](_0x4545aa[_0xc019('0x52')],{'$or':_['map'](_0x4545aa[_0xc019('0x4b')],function(_0x526880){var _0x38fe0d={};_0x38fe0d[_0x526880]={'$like':'%'+_0x366066[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x38fe0d;})});}_0x4545aa=_[_0xc019('0x55')]({},_0x4545aa,_0x366066[_0xc019('0x56')]);return db[_0xc019('0xbb')][_0xc019('0x35')]({'where':_0x4545aa[_0xc019('0x52')]})[_0xc019('0x25')](function(_0x14bd2d){_0x35582c[_0xc019('0x35')]=_0x14bd2d;if(_0x366066[_0xc019('0x48')]['includeAll']){_0x4545aa[_0xc019('0x58')]=[{'model':db[_0xc019('0x93')],'as':_0xc019('0xf5'),'required':![]},{'model':db[_0xc019('0xca')],'as':'Owner','attributes':[_0xc019('0x3f'),_0xc019('0xf6'),_0xc019('0xf7')],'required':![]},{'model':db[_0xc019('0xf8')],'as':'Tags','attributes':['id',_0xc019('0x3f'),_0xc019('0xf9')],'where':_0x366066[_0xc019('0x48')][_0xc019('0xfa')]?{'id':_0x366066[_0xc019('0x48')][_0xc019('0xfa')]}:undefined,'required':_0x366066['query'][_0xc019('0xfa')]?!![]:![]}];}return db[_0xc019('0xbb')][_0xc019('0x59')](_0x4545aa);})[_0xc019('0x25')](function(_0x132ea4){_0x35582c['rows']=_0x132ea4;return _0x35582c;});}})[_0xc019('0x25')](respondWithFilteredResult(_0x4b9b84,_0x4545aa))[_0xc019('0x30')](handleError(_0x4b9b84,null));};function iftimePromise(_0x34cd9b,_0x3bcd09){return respondWithRpcPromise(_0xc019('0xfb'),'getSnippet',{'command':_0x3bcd09[_0xc019('0xfc')]?util['format'](_0xc019('0xfd'),_0x34cd9b[_0xc019('0xfe')],_0x3bcd09[_0xc019('0xfc')]):util[_0xc019('0xb4')](_0xc019('0xff'),_0x34cd9b[_0xc019('0xfe')])},client9002)[_0xc019('0x25')](function(_0x31f081){var _0x378eb1=_0x31f081&&_0x31f081['indexOf'](_0xc019('0x100'))>=0x0?!![]:![];logger['info']('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x3bcd09['id'],_0x34cd9b['id'],_0x34cd9b[_0xc019('0xfe')],_0x378eb1?_0xc019('0x101'):_0xc019('0x102'),_0x3bcd09[_0xc019('0xfc')]?_0x3bcd09[_0xc019('0xfc')]:'No\x20timezone');return _0x378eb1;})[_0xc019('0x30')](function(_0x5e6df0){logger['error'](_0xc019('0x103'),_0x3bcd09['id'],_0x34cd9b['id'],_0x34cd9b[_0xc019('0xfe')],util[_0xc019('0x104')](_0x5e6df0,{'showHidden':![],'depth':null}),_0x3bcd09['timezone']?_0x3bcd09[_0xc019('0xfc')]:_0xc019('0x105'));return![];});}exports[_0xc019('0x106')]=function(_0x39a12d,_0x168ddf,_0x49ccee){var _0x583b82=0x0;var _0xe8185=0x0;var _0x2cea66=![];var _0x46156e;var _0x1a9be2;return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x39a12d[_0xc019('0x5c')]['id']},'include':[{'model':db['Interval'],'as':_0xc019('0x107'),'include':[{'model':db[_0xc019('0x107')],'as':'Intervals','attributes':['id',_0xc019('0xfe')],'raw':!![]}]}]})[_0xc019('0x25')](handleEntityNotFound(_0x168ddf,null))['then'](function(_0x5ce5e5){if(_0x5ce5e5){_0x46156e=_0x5ce5e5;return _0x5ce5e5[_0xc019('0x108')]({'raw':!![]});}})[_0xc019('0x25')](function(_0x2a65d9){if(_0x46156e){if(_0x2a65d9){_0x1a9be2=_0x2a65d9;}}return require(_0xc019('0x1a'))[_0xc019('0x7f')]();})[_0xc019('0x25')](function(_0x1198a2){if(_0x1198a2){_0xe8185=_0x1198a2[_0xc019('0x109')];_0x2cea66=_0x1198a2[_0xc019('0x80')];}})[_0xc019('0x25')](function(){return db[_0xc019('0xbb')][_0xc019('0x35')]({'where':{'closed':![]}});})[_0xc019('0x25')](function(_0x348871){_0x583b82=_0x348871;if(_0xe8185&&_0x348871>_0xe8185){return db[_0xc019('0x10a')][_0xc019('0x6c')]({'where':{'id':0x1}})[_0xc019('0x25')](function(_0x27ec6f){if(_0x27ec6f){_0x27ec6f[_0xc019('0x10b')](_0xc019('0x10c'));}});}})[_0xc019('0x25')](function(){if(_0x46156e[_0xc019('0x107')]&&_0x46156e[_0xc019('0x107')][_0xc019('0x10d')]){var _0x2cec9c=[];for(var _0x28e9ae=0x0;_0x28e9ae<_0x46156e[_0xc019('0x107')][_0xc019('0x10d')][_0xc019('0x4d')];_0x28e9ae++){var _0x191e9b=_0x46156e[_0xc019('0x107')][_0xc019('0x10d')][_0x28e9ae]['get']({'plain':!![]});_0x2cec9c[_0xc019('0xc3')](iftimePromise(_0x191e9b,_0x46156e));}return BPromise[_0xc019('0x10e')](_0x2cec9c)[_0xc019('0x25')](function(_0x4d624d){return _[_0xc019('0x10f')](_0x4d624d);});}else{return!![];}})[_0xc019('0x25')](function(_0x5c85ac){var _0x28a9ee=fs[_0xc019('0xda')](path[_0xc019('0x7c')](config[_0xc019('0x7d')],_0xc019('0x110')),_0xc019('0xdb'));var _0x4c152c={'remote':_0x46156e['remote'],'query':querystring[_0xc019('0x2b')](_[_0xc019('0x55')](_0x46156e['get']({'plain':!![]}),{'customerIp':_0x39a12d[_0xc019('0x8f')]['x-forwarded-for']||_0x39a12d[_0xc019('0x8f')]['x-real-ip']||_0x39a12d[_0xc019('0x111')]['remoteAddress']||_0x39a12d['ip'],'referer':_0x39a12d[_0xc019('0x8f')]['referer'],'openedInteractions':_0x583b82,'maxInteractions':_0xe8185,'virtual':_0x2cea66[_0xc019('0x109')],'online':_0x5c85ac,'custom':_0x2cea66}))[_0xc019('0x112')](/'/g,'\x5c\x27')};_0x168ddf[_0xc019('0x40')](ejs[_0xc019('0xdc')](Mustache['render'](_0x28a9ee,_0x4c152c),{'proactiveActions':_0x1a9be2,'alignment':_0x46156e['alignment'],'verticalAlignment':_0x46156e['verticalAlignment'],'div_color':_0x46156e[_0xc019('0xf9')],'text_color':_0x46156e[_0xc019('0x113')]}));})[_0xc019('0x30')](handleError(_0x168ddf,null));};exports[_0xc019('0x114')]=function(_0x10b48e,_0x334426,_0x1d594b){return db['ChatWebsite'][_0xc019('0x6c')]({'where':{'id':_0x10b48e[_0xc019('0x5c')]['id']}})['then'](handleEntityNotFound(_0x334426,null))[_0xc019('0x25')](function(_0x5d6008){if(_0x5d6008){return db[_0xc019('0x115')]['transaction'](function(_0x52cde3){return db[_0xc019('0xa2')][_0xc019('0x3b')]({'where':{'ChatWebsiteId':_0x10b48e[_0xc019('0x5c')]['id']},'transaction':_0x52cde3})['then'](function(_0x24ce15){var _0x480c64=_[_0xc019('0x44')](_0x10b48e['body'],function(_0x33d1fb){_0x33d1fb['ChatWebsiteId']=_0x10b48e['params']['id'];return _0x33d1fb;});return db[_0xc019('0xa2')][_0xc019('0x116')](_0x480c64,{'transaction':_0x52cde3});});})['then'](function(){return db[_0xc019('0xa2')][_0xc019('0x117')]({'where':{'ChatWebsiteId':_0x10b48e[_0xc019('0x5c')]['id']},'order':_0xc019('0xa7')});});}})[_0xc019('0x25')](respondWithResult(_0x334426,null))[_0xc019('0x30')](handleError(_0x334426,null));};exports['getApplications']=function(_0xcd012c,_0x3f665f,_0x385e4a){var _0x4b4bfb={};var _0x523d9f={};var _0x38e30f;var _0x40d7b2;return db[_0xc019('0x45')][_0xc019('0x6c')]({'where':{'id':_0xcd012c['params']['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x3f665f,null))[_0xc019('0x25')](function(_0x3900f7){if(_0x3900f7){_0x38e30f=_0x3900f7;_0x523d9f[_0xc019('0x4a')]=_['keys'](db[_0xc019('0xa2')][_0xc019('0x5e')]);_0x523d9f[_0xc019('0x48')]=_[_0xc019('0x5d')](_0xcd012c[_0xc019('0x48')]);_0x523d9f[_0xc019('0x53')]=_[_0xc019('0x49')](_0x523d9f[_0xc019('0x4a')],_0x523d9f['query']);_0x4b4bfb[_0xc019('0x4b')]=_[_0xc019('0x49')](_0x523d9f[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0xcd012c[_0xc019('0x48')]['fields']));_0x4b4bfb['attributes']=_0x4b4bfb['attributes'][_0xc019('0x4d')]?_0x4b4bfb[_0xc019('0x4b')]:_0x523d9f[_0xc019('0x4a')];_0x4b4bfb[_0xc019('0x50')]=qs['sort'](_0xcd012c[_0xc019('0x48')][_0xc019('0x51')]);_0x4b4bfb[_0xc019('0x52')]=qs[_0xc019('0x53')](_[_0xc019('0x6d')](_0xcd012c[_0xc019('0x48')],_0x523d9f[_0xc019('0x53')]));if(_0xcd012c[_0xc019('0x48')][_0xc019('0x54')]){_0x4b4bfb[_0xc019('0x52')]=_[_0xc019('0x55')](_0x4b4bfb[_0xc019('0x52')],{'$or':_['map'](_0x4b4bfb['attributes'],function(_0x44c9f9){var _0x17dcf1={};_0x17dcf1[_0x44c9f9]={'$like':'%'+_0xcd012c[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x17dcf1;})});}_0x4b4bfb=_['merge']({},_0x4b4bfb,_0xcd012c[_0xc019('0x56')]);return _0x38e30f[_0xc019('0x118')](_0x4b4bfb);}})[_0xc019('0x25')](function(_0xd61e5f){if(_0xd61e5f){_0x40d7b2=_0xd61e5f[_0xc019('0x4d')];if(!_0xcd012c[_0xc019('0x48')][_0xc019('0x4e')](_0xc019('0x4f'))){_0x4b4bfb['limit']=qs['limit'](_0xcd012c['query'][_0xc019('0x37')]);_0x4b4bfb[_0xc019('0x36')]=qs[_0xc019('0x36')](_0xcd012c[_0xc019('0x48')][_0xc019('0x36')]);}return _0x38e30f[_0xc019('0x118')](_0x4b4bfb);}})[_0xc019('0x25')](function(_0x419bcc){if(_0x419bcc){return _0x419bcc?{'count':_0x40d7b2,'rows':_0x419bcc}:null;}})[_0xc019('0x25')](respondWithResult(_0x3f665f,null))[_0xc019('0x30')](handleError(_0x3f665f,null));};exports[_0xc019('0x119')]=function(_0x48dcbf,_0x3dbf46,_0x36220d){return db[_0xc019('0x11a')][_0xc019('0x5f')]({'where':{'id':_0x48dcbf[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x3dbf46,null))['then'](function(_0x25c999){if(_0x25c999){return _0x25c999[_0xc019('0x119')](_0x48dcbf[_0xc019('0x61')]['ids'],_[_0xc019('0xf3')](_0x48dcbf[_0xc019('0x61')],['ids','id'])||{});}})['then'](respondWithResult(_0x3dbf46,null))[_0xc019('0x30')](handleError(_0x3dbf46,null));};exports['getProactiveActions']=function(_0x5c237f,_0xce6152,_0x10bcac){var _0xe69d0b={};var _0x45e003={};var _0x1cd762;var _0x7b6d5c;return db['ChatWebsite'][_0xc019('0x6c')]({'where':{'id':_0x5c237f['params']['id']}})[_0xc019('0x25')](handleEntityNotFound(_0xce6152,null))['then'](function(_0xe083cf){if(_0xe083cf){_0x1cd762=_0xe083cf;_0x45e003[_0xc019('0x4a')]=_[_0xc019('0x5d')](db[_0xc019('0x11b')][_0xc019('0x5e')]);_0x45e003[_0xc019('0x48')]=_['keys'](_0x5c237f['query']);_0x45e003['filters']=_[_0xc019('0x49')](_0x45e003['model'],_0x45e003[_0xc019('0x48')]);_0xe69d0b['attributes']=_[_0xc019('0x49')](_0x45e003['model'],qs['fields'](_0x5c237f[_0xc019('0x48')]['fields']));_0xe69d0b[_0xc019('0x4b')]=_0xe69d0b[_0xc019('0x4b')][_0xc019('0x4d')]?_0xe69d0b[_0xc019('0x4b')]:_0x45e003[_0xc019('0x4a')];_0xe69d0b[_0xc019('0x50')]=qs[_0xc019('0x51')](_0x5c237f['query'][_0xc019('0x51')]);_0xe69d0b[_0xc019('0x52')]=qs[_0xc019('0x53')](_[_0xc019('0x6d')](_0x5c237f[_0xc019('0x48')],_0x45e003[_0xc019('0x53')]));if(_0x5c237f['query']['filter']){_0xe69d0b['where']=_[_0xc019('0x55')](_0xe69d0b[_0xc019('0x52')],{'$or':_['map'](_0xe69d0b[_0xc019('0x4b')],function(_0xfce466){var _0x3e9e44={};_0x3e9e44[_0xfce466]={'$like':'%'+_0x5c237f[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0x3e9e44;})});}_0xe69d0b=_[_0xc019('0x55')]({},_0xe69d0b,_0x5c237f['options']);return _0x1cd762[_0xc019('0x108')](_0xe69d0b);}})[_0xc019('0x25')](function(_0x26f5cb){if(_0x26f5cb){_0x7b6d5c=_0x26f5cb[_0xc019('0x4d')];if(!_0x5c237f['query'][_0xc019('0x4e')](_0xc019('0x4f'))){_0xe69d0b[_0xc019('0x37')]=qs[_0xc019('0x37')](_0x5c237f[_0xc019('0x48')][_0xc019('0x37')]);_0xe69d0b['offset']=qs[_0xc019('0x36')](_0x5c237f[_0xc019('0x48')][_0xc019('0x36')]);}return _0x1cd762[_0xc019('0x108')](_0xe69d0b);}})['then'](function(_0x358d03){if(_0x358d03){return _0x358d03?{'count':_0x7b6d5c,'rows':_0x358d03}:null;}})[_0xc019('0x25')](respondWithResult(_0xce6152,null))['catch'](handleError(_0xce6152,null));};exports[_0xc019('0x11c')]=function(_0x45a30a,_0x45f43f,_0x12fdd4){var _0x54d106=_0x45a30a[_0xc019('0x48')][_0xc019('0x11d')]===_0xc019('0x11e')?_0xc019('0x11f'):'onlineForm';return db['ChatWebsite']['find']({'attributes':['id',_0x54d106],'where':{'id':_0x45a30a['params']['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x45f43f,null))[_0xc019('0x25')](function(_0x3fca8a){if(_0x3fca8a){var _0x2ca8e6=_0x3fca8a[_0x54d106];var _0x253e60=_0x2ca8e6&&_0x2ca8e6['items']?_0x2ca8e6[_0xc019('0x120')]:[];_0x45f43f[_0xc019('0x40')]({'fromKey':_[_0xc019('0x81')](_0x2ca8e6[_0xc019('0x121')])?undefined:_0x2ca8e6[_0xc019('0x121')],'count':_0x253e60[_0xc019('0x4d')],'rows':_0x253e60});}})[_0xc019('0x30')](handleError(_0x45f43f,null));};exports[_0xc019('0x122')]=function(_0x266a80,_0x28f4e5,_0x39d10a){var _0x3e1427={'raw':![],'where':{}};var _0x36918d={};var _0x59793a={'count':0x0,'rows':[]};return db[_0xc019('0x45')][_0xc019('0x6c')]({'where':{'id':_0x266a80[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x28f4e5,null))[_0xc019('0x25')](function(_0x2bf0e6){if(_0x2bf0e6){_0x36918d['model']=_[_0xc019('0x5d')](db[_0xc019('0xdf')][_0xc019('0x5e')]);_0x36918d[_0xc019('0x48')]=_[_0xc019('0x5d')](_0x266a80[_0xc019('0x48')]);_0x36918d[_0xc019('0x53')]=_[_0xc019('0x49')](_0x36918d[_0xc019('0x4a')],_0x36918d[_0xc019('0x48')]);_0x3e1427[_0xc019('0x4b')]=_['intersection'](_0x36918d[_0xc019('0x4a')],qs[_0xc019('0x4c')](_0x266a80[_0xc019('0x48')][_0xc019('0x4c')]));_0x3e1427[_0xc019('0x4b')]=_0x3e1427[_0xc019('0x4b')][_0xc019('0x4d')]?_0x3e1427[_0xc019('0x4b')]:_0x36918d[_0xc019('0x4a')];if(!_0x266a80['query'][_0xc019('0x4e')](_0xc019('0x4f'))){_0x3e1427['limit']=qs['limit'](_0x266a80[_0xc019('0x48')][_0xc019('0x37')]);_0x3e1427[_0xc019('0x36')]=qs['offset'](_0x266a80['query']['offset']);}_0x3e1427[_0xc019('0x50')]=qs[_0xc019('0x51')](_0x266a80[_0xc019('0x48')][_0xc019('0x51')]);_0x3e1427[_0xc019('0x52')]=qs[_0xc019('0x53')](_['pick'](_0x266a80[_0xc019('0x48')],_0x36918d['filters']));_0x3e1427['where'][_0xc019('0x6a')]=_0x2bf0e6['id'];if(_0x266a80[_0xc019('0x48')][_0xc019('0x54')]){_0x3e1427[_0xc019('0x52')]=_[_0xc019('0x55')](_0x3e1427[_0xc019('0x52')],{'$or':_['map'](_0x3e1427[_0xc019('0x4b')],function(_0x4e4d21){var _0x56046b={};_0x56046b[_0x4e4d21]={'$like':'%'+_0x266a80['query'][_0xc019('0x54')]+'%'};return _0x56046b;})});}_0x3e1427=_[_0xc019('0x55')]({},_0x3e1427,_0x266a80[_0xc019('0x56')]);return db[_0xc019('0xdf')][_0xc019('0x35')]({'where':_0x3e1427['where']})[_0xc019('0x25')](function(_0x3574cb){_0x59793a['count']=_0x3574cb;if(_0x266a80[_0xc019('0x48')]['includeAll']){_0x3e1427[_0xc019('0x58')]=[{'all':!![]}];}else{_0x3e1427[_0xc019('0x58')]=[{'model':db['CmContact'],'as':_0xc019('0xf5'),'required':![]}];}return db[_0xc019('0xdf')]['findAll'](_0x3e1427);})['then'](function(_0x505408){_0x59793a[_0xc019('0x5a')]=_0x505408;return _0x59793a;});}})[_0xc019('0x25')](respondWithFilteredResult(_0x28f4e5,_0x3e1427))[_0xc019('0x30')](handleError(_0x28f4e5,null));};exports[_0xc019('0x123')]=function(_0x4a5ecf,_0x2ea695,_0x457d9d){return db[_0xc019('0x45')][_0xc019('0x5f')]({'where':{'id':_0x4a5ecf[_0xc019('0x5c')]['id']}})['then'](handleEntityNotFound(_0x2ea695,null))[_0xc019('0x25')](function(_0x1d88db){if(_0x1d88db){return _0x1d88db[_0xc019('0x123')](_0x4a5ecf['body'][_0xc019('0x72')],_[_0xc019('0xf3')](_0x4a5ecf[_0xc019('0x61')],[_0xc019('0x72'),'id'])||{})[_0xc019('0xbf')](function(_0x5518c8){for(var _0x39af49=0x0;_0x39af49<_0x4a5ecf[_0xc019('0x61')][_0xc019('0x72')][_0xc019('0x4d')];_0x39af49+=0x1){socket[_0xc019('0x124')](_0xc019('0x125'),{'UserId':_0x4a5ecf[_0xc019('0x61')]['ids'][_0x39af49],'ChatWebsiteId':_0x4a5ecf[_0xc019('0x5c')]['id']});}return _0x5518c8;});}})[_0xc019('0x25')](respondWithResult(_0x2ea695,null))[_0xc019('0x30')](handleError(_0x2ea695,null));};exports[_0xc019('0x126')]=function(_0x29d95e,_0x303d0b,_0x3dbc73){return db['ChatWebsite'][_0xc019('0x5f')]({'where':{'id':_0x29d95e[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x303d0b,null))[_0xc019('0x25')](function(_0x409b19){if(_0x409b19){return _0x409b19[_0xc019('0x126')](_0x29d95e['query'][_0xc019('0x72')])['then'](function(){if(_[_0xc019('0x127')](_0x29d95e['query'][_0xc019('0x72')])){for(var _0x47df90=0x0;_0x47df90<_0x29d95e['query'][_0xc019('0x72')][_0xc019('0x4d')];_0x47df90+=0x1){socket[_0xc019('0x124')](_0xc019('0x128'),{'UserId':Number(_0x29d95e[_0xc019('0x48')][_0xc019('0x72')][_0x47df90]),'ChatWebsiteId':Number(_0x29d95e[_0xc019('0x5c')]['id'])});}}else{socket[_0xc019('0x124')](_0xc019('0x128'),{'UserId':Number(_0x29d95e[_0xc019('0x48')][_0xc019('0x72')]),'ChatWebsiteId':Number(_0x29d95e['params']['id'])});}});}})['then'](respondWithStatusCode(_0x303d0b,null))['catch'](handleError(_0x303d0b,null));};exports['getAgents']=function(_0x552813,_0x3fdafb,_0x24c0e3){var _0x5c83f3={};var _0x5cbf57={};var _0x49f300;var _0x4aca19;return db[_0xc019('0x45')][_0xc019('0x6c')]({'where':{'id':_0x552813[_0xc019('0x5c')]['id']}})[_0xc019('0x25')](handleEntityNotFound(_0x3fdafb,null))[_0xc019('0x25')](function(_0x3ba073){if(_0x3ba073){_0x49f300=_0x3ba073;_0x5cbf57[_0xc019('0x4a')]=_[_0xc019('0x5d')](db[_0xc019('0xca')][_0xc019('0x5e')]);_0x5cbf57['query']=_[_0xc019('0x5d')](_0x552813['query']);_0x5cbf57[_0xc019('0x53')]=_[_0xc019('0x49')](_0x5cbf57[_0xc019('0x4a')],_0x5cbf57[_0xc019('0x48')]);_0x5c83f3[_0xc019('0x4b')]=_[_0xc019('0x49')](_0x5cbf57['model'],qs[_0xc019('0x4c')](_0x552813['query'][_0xc019('0x4c')]));_0x5c83f3[_0xc019('0x4b')]=_0x5c83f3[_0xc019('0x4b')][_0xc019('0x4d')]?_0x5c83f3[_0xc019('0x4b')]:_0x5cbf57['model'];_0x5c83f3[_0xc019('0x50')]=qs['sort'](_0x552813[_0xc019('0x48')][_0xc019('0x51')]);_0x5c83f3[_0xc019('0x52')]=qs[_0xc019('0x53')](_[_0xc019('0x6d')](_0x552813[_0xc019('0x48')],_0x5cbf57[_0xc019('0x53')]));if(_0x552813[_0xc019('0x48')][_0xc019('0x54')]){_0x5c83f3['where']=_['merge'](_0x5c83f3['where'],{'$or':_[_0xc019('0x44')](_0x5c83f3[_0xc019('0x4b')],function(_0x2c2421){var _0xe00de2={};_0xe00de2[_0x2c2421]={'$like':'%'+_0x552813[_0xc019('0x48')][_0xc019('0x54')]+'%'};return _0xe00de2;})});}_0x5c83f3=_['merge']({},_0x5c83f3,_0x552813[_0xc019('0x56')]);return _0x49f300[_0xc019('0x129')](_0x5c83f3);}})[_0xc019('0x25')](function(_0x30c8b8){if(_0x30c8b8){_0x4aca19=_0x30c8b8[_0xc019('0x4d')];if(!_0x552813[_0xc019('0x48')][_0xc019('0x4e')](_0xc019('0x4f'))){_0x5c83f3['limit']=qs[_0xc019('0x37')](_0x552813[_0xc019('0x48')][_0xc019('0x37')]);_0x5c83f3['offset']=qs[_0xc019('0x36')](_0x552813[_0xc019('0x48')]['offset']);}return _0x49f300[_0xc019('0x129')](_0x5c83f3);}})['then'](function(_0x16b02a){if(_0x16b02a){return _0x16b02a?{'count':_0x4aca19,'rows':_0x16b02a}:null;}})['then'](respondWithResult(_0x3fdafb,null))[_0xc019('0x30')](handleError(_0x3fdafb,null));};
\ No newline at end of file
+var _0xc158=['unshift','forcedOwnership','startRouting','Start','EventManager','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailServerOut','forwardOffline','forwardOfflineAddress','service','Smtp','host','port','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','openNewInteraction','MailAccountId','firstName','Chat','NotifyMailAccount','notifyMail','addInteraction','getInteractions','Contact','Owner','internal','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','chatLicenseExceeded','push','all','server/files/chat/iframe.js','x-real-ip','connection','remoteAddress','referer','replace','verticalAlignment','addApplications','sequelize','transaction','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','online','offlineForm','items','getOfflineMessages','addAgents','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','debug','request\x20sent','stringify','error','ChatWebsite,\x20%s,\x20%s','message','info','result','catch','status','count','offset','limit','set','Content-Range','json','apply','reject','save','destroy','get','ChatWebsites','UserProfileResource','end','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','type','key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','removeDispositions','ids','addAnswer','getAnswers','findOne','CannedAnswer','removeAnswers','addLogo','sitepic','addAvatar','agentAvatar','file','addCustomerAvatar','customerAvatar','filename','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','existsSync','server/files/images/logos/','download','getAvatar','isNil','server/files/images/avatars/','getCustomerAvatar','showCustomerAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','headers','user-agent','getResult','Sequelize','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','ValidationError','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmContact','Contacts','ChatApplication','Applications','List','account','applications','list','orderBy','priority','contact','customerIp','cf-connecting-ip','first','x-forwarded-for','split','lastName','x-real-port','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xc158,0x187));var _0x8c15=function(_0x42bd0c,_0x5a1889){_0x42bd0c=_0x42bd0c-0x0;var _0x193468=_0xc158[_0x42bd0c];return _0x193468;};'use strict';var pdf=require(_0x8c15('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x8c15('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8c15('0x2'));var rp=require(_0x8c15('0x3'));var moment=require(_0x8c15('0x4'));var BPromise=require(_0x8c15('0x5'));var Mustache=require('mustache');var util=require(_0x8c15('0x6'));var path=require(_0x8c15('0x7'));var sox=require('sox');var csv=require(_0x8c15('0x8'));var ejs=require(_0x8c15('0x9'));var fs=require('fs');var _=require(_0x8c15('0xa'));var squel=require(_0x8c15('0xb'));var crypto=require(_0x8c15('0xc'));var jsforce=require(_0x8c15('0xd'));var deskjs=require(_0x8c15('0xe'));var toCsv=require(_0x8c15('0x8'));var querystring=require(_0x8c15('0xf'));var Papa=require(_0x8c15('0x10'));var Redis=require('ioredis');var authService=require(_0x8c15('0x11'));var qs=require(_0x8c15('0x12'));var as=require(_0x8c15('0x13'));var hardwareService=require(_0x8c15('0x14'));var logger=require(_0x8c15('0x15'))(_0x8c15('0x16'));var utils=require('../../config/utils');var config=require(_0x8c15('0x17'));var licenseUtil=require(_0x8c15('0x18'));var db=require(_0x8c15('0x19'))['db'];config[_0x8c15('0x1a')]=_[_0x8c15('0x1b')](config[_0x8c15('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x8c15('0x1c'))(new Redis(config[_0x8c15('0x1a')]));require(_0x8c15('0x1d'))[_0x8c15('0x1e')](socket);var jayson=require(_0x8c15('0x1f'));var client=jayson[_0x8c15('0x20')][_0x8c15('0x21')]({'port':0x232c});var client9002=jayson[_0x8c15('0x20')][_0x8c15('0x21')]({'port':0x232a});var client9003=jayson[_0x8c15('0x20')]['http']({'port':0x232b});var client9001=jayson[_0x8c15('0x20')]['http']({'port':0x2329});function respondWithRpcPromise(_0x20c01e,_0x52f4c4,_0x5c6db8,_0x4223a1){return new BPromise(function(_0x5cffcb,_0x14f5a3){var _0x429ce4=_0x4223a1||client;return _0x429ce4[_0x8c15('0x22')](_0x20c01e,_0x5c6db8)[_0x8c15('0x23')](function(_0x4c53c8){logger['info']('ChatWebsite,\x20%s,\x20%s',_0x52f4c4,'request\x20sent');logger[_0x8c15('0x24')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x52f4c4,_0x8c15('0x25'),JSON[_0x8c15('0x26')](_0x4c53c8));if(_0x4c53c8[_0x8c15('0x27')]){if(_0x4c53c8[_0x8c15('0x27')]['code']===0x1f4){logger['error'](_0x8c15('0x28'),_0x52f4c4,_0x4c53c8['error']['message']);return _0x14f5a3(_0x4c53c8[_0x8c15('0x27')][_0x8c15('0x29')]);}logger[_0x8c15('0x27')]('ChatWebsite,\x20%s,\x20%s',_0x52f4c4,_0x4c53c8['error'][_0x8c15('0x29')]);return _0x5cffcb(_0x4c53c8[_0x8c15('0x27')]['message']);}else{logger[_0x8c15('0x2a')](_0x8c15('0x28'),_0x52f4c4,_0x8c15('0x25'));_0x5cffcb(_0x4c53c8[_0x8c15('0x2b')][_0x8c15('0x29')]);}})[_0x8c15('0x2c')](function(_0x5dad9f){logger['error'](_0x8c15('0x28'),_0x52f4c4,_0x5dad9f);_0x14f5a3(_0x5dad9f);});});}function respondWithStatusCode(_0x2071e3,_0x54ac12){_0x54ac12=_0x54ac12||0xcc;return function(_0x2f351d){if(_0x2f351d){return _0x2071e3['sendStatus'](_0x54ac12);}return _0x2071e3[_0x8c15('0x2d')](_0x54ac12)['end']();};}function respondWithResult(_0x4889eb,_0xf61b){_0xf61b=_0xf61b||0xc8;return function(_0xf2a193){if(_0xf2a193){return _0x4889eb[_0x8c15('0x2d')](_0xf61b)['json'](_0xf2a193);}};}function respondWithFilteredResult(_0xaccce7,_0x1322b9){return function(_0x28cfa9){if(_0x28cfa9){var _0x3ebc3a=_0x28cfa9[_0x8c15('0x2e')],_0x194cd9=_0x1322b9[_0x8c15('0x2f')],_0x39e882=_0x1322b9[_0x8c15('0x2f')]+_0x1322b9[_0x8c15('0x30')],_0x30702e;if(_0x39e882>=_0x3ebc3a){_0x39e882=_0x3ebc3a;_0x30702e=0xc8;}else{_0x30702e=0xce;}_0xaccce7[_0x8c15('0x2d')](_0x30702e);return _0xaccce7[_0x8c15('0x31')](_0x8c15('0x32'),_0x194cd9+'-'+_0x39e882+'/'+_0x3ebc3a)[_0x8c15('0x33')](_0x28cfa9);}return null;};}function patchUpdates(_0x1421f4){return function(_0x8c1433){try{jsonpatch[_0x8c15('0x34')](_0x8c1433,_0x1421f4,!![]);}catch(_0x44eed5){return BPromise[_0x8c15('0x35')](_0x44eed5);}return _0x8c1433[_0x8c15('0x36')]();};}function saveUpdates(_0x43f99f,_0x1b815a){return function(_0x1f633e){if(_0x1f633e){return _0x1f633e['update'](_0x43f99f)[_0x8c15('0x23')](function(_0x4ff21c){return _0x4ff21c;});}return null;};}function removeEntity(_0x2d7039,_0xa301cb){return function(_0x1f131b){if(_0x1f131b){return _0x1f131b[_0x8c15('0x37')]()[_0x8c15('0x23')](function(){var _0x53f836=_0x1f131b[_0x8c15('0x38')]({'plain':!![]});var _0x2c6397=_0x8c15('0x39');return db[_0x8c15('0x3a')][_0x8c15('0x37')]({'where':{'type':_0x2c6397,'resourceId':_0x53f836['id']}})[_0x8c15('0x23')](function(){return _0x1f131b;});})[_0x8c15('0x23')](function(){_0x2d7039[_0x8c15('0x2d')](0xcc)[_0x8c15('0x3b')]();});}};}function handleEntityNotFound(_0x27a97b,_0x1dbc5a){return function(_0x4cd889){if(!_0x4cd889){_0x27a97b[_0x8c15('0x3c')](0x194);}return _0x4cd889;};}function handleError(_0x5eddd0,_0x4c708d){_0x4c708d=_0x4c708d||0x1f4;return function(_0x41f345){logger[_0x8c15('0x27')](_0x41f345[_0x8c15('0x3d')]);if(_0x41f345[_0x8c15('0x3e')]){delete _0x41f345[_0x8c15('0x3e')];}_0x5eddd0[_0x8c15('0x2d')](_0x4c708d)[_0x8c15('0x3f')](_0x41f345);};}exports[_0x8c15('0x40')]=function(_0x74ca31,_0x256ca5){var _0x39aefe={'include':[{'model':db[_0x8c15('0x41')],'as':_0x8c15('0x42')}]},_0x1d3326={},_0x8655a4={'count':0x0,'rows':[]};var _0x1f123c=_[_0x8c15('0x43')](db[_0x8c15('0x44')][_0x8c15('0x45')],function(_0x34ce82){return{'name':_0x34ce82['fieldName'],'type':_0x34ce82[_0x8c15('0x46')][_0x8c15('0x47')]};});_0x1d3326[_0x8c15('0x48')]=_[_0x8c15('0x43')](_0x1f123c,'name');_0x1d3326[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x74ca31['query']);_0x1d3326['filters']=_['intersection'](_0x1d3326['model'],_0x1d3326['query']);_0x39aefe[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x1d3326['model'],qs[_0x8c15('0x4d')](_0x74ca31['query'][_0x8c15('0x4d')]));_0x39aefe[_0x8c15('0x4b')]=_0x39aefe[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x39aefe[_0x8c15('0x4b')]:_0x1d3326['model'];if(!_0x74ca31[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x39aefe[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x30')]);_0x39aefe[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x39aefe[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x52')]);_0x39aefe[_0x8c15('0x53')]=qs['filters'](_[_0x8c15('0x54')](_0x74ca31[_0x8c15('0x49')],_0x1d3326[_0x8c15('0x55')]),_0x1f123c);if(_0x74ca31[_0x8c15('0x49')][_0x8c15('0x56')]){_0x39aefe[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x39aefe[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x1f123c,function(_0x5e5f33){if(_0x5e5f33[_0x8c15('0x46')]!==_0x8c15('0x58')){var _0x322a01={};_0x322a01[_0x5e5f33[_0x8c15('0x3e')]]={'$like':'%'+_0x74ca31[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x322a01;}})});}_0x39aefe=_[_0x8c15('0x57')]({},_0x39aefe,_0x74ca31[_0x8c15('0x59')]);var _0x51d746={'where':_0x39aefe[_0x8c15('0x53')]};return db['ChatWebsite'][_0x8c15('0x2e')](_0x51d746)[_0x8c15('0x23')](function(_0x547ca7){_0x8655a4['count']=_0x547ca7;if(_0x74ca31[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x39aefe['include']=[{'all':!![]}];}return db[_0x8c15('0x44')][_0x8c15('0x5b')](_0x39aefe);})[_0x8c15('0x23')](function(_0x47d269){_0x8655a4[_0x8c15('0x5c')]=_0x47d269;return _0x8655a4;})[_0x8c15('0x23')](respondWithFilteredResult(_0x256ca5,_0x39aefe))[_0x8c15('0x2c')](handleError(_0x256ca5,null));};exports[_0x8c15('0x5d')]=function(_0x54ad21,_0x202c44){var _0x193328={'raw':![],'where':{'id':_0x54ad21[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x41')],'as':'mandatoryDispositionPause'}]},_0x5ad8f6={};_0x5ad8f6['model']=_[_0x8c15('0x4a')](db[_0x8c15('0x44')][_0x8c15('0x45')]);_0x5ad8f6['query']=_[_0x8c15('0x4a')](_0x54ad21[_0x8c15('0x49')]);_0x5ad8f6['filters']=_[_0x8c15('0x4c')](_0x5ad8f6[_0x8c15('0x48')],_0x5ad8f6[_0x8c15('0x49')]);_0x193328['attributes']=_[_0x8c15('0x4c')](_0x5ad8f6[_0x8c15('0x48')],qs['fields'](_0x54ad21[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x193328[_0x8c15('0x4b')]=_0x193328[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x193328[_0x8c15('0x4b')]:_0x5ad8f6[_0x8c15('0x48')];if(_0x54ad21[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x193328[_0x8c15('0x5f')]=[{'all':!![]}];}_0x193328=_['merge']({},_0x193328,_0x54ad21[_0x8c15('0x59')]);return db['ChatWebsite']['find'](_0x193328)[_0x8c15('0x23')](handleEntityNotFound(_0x202c44,null))['then'](respondWithResult(_0x202c44,null))[_0x8c15('0x2c')](handleError(_0x202c44,null));};exports[_0x8c15('0x60')]=function(_0x3d1c13,_0x457020){return db[_0x8c15('0x44')][_0x8c15('0x60')](_0x3d1c13[_0x8c15('0x61')],{})[_0x8c15('0x23')](function(_0x172d0d){var _0x5db1ce=_0x3d1c13[_0x8c15('0x62')][_0x8c15('0x38')]({'plain':!![]});if(!_0x5db1ce)throw new Error(_0x8c15('0x63'));if(_0x5db1ce[_0x8c15('0x64')]===_0x8c15('0x62')){var _0x3892e9=_0x172d0d[_0x8c15('0x38')]({'plain':!![]});var _0x3a0464=_0x8c15('0x39');return db['UserProfileSection']['find']({'where':{'name':_0x3a0464,'userProfileId':_0x5db1ce[_0x8c15('0x65')]},'raw':!![]})['then'](function(_0x55a0dc){if(_0x55a0dc&&_0x55a0dc[_0x8c15('0x66')]===0x0){return db[_0x8c15('0x3a')][_0x8c15('0x60')]({'name':_0x3892e9[_0x8c15('0x3e')],'resourceId':_0x3892e9['id'],'type':_0x55a0dc[_0x8c15('0x3e')],'sectionId':_0x55a0dc['id']},{})['then'](function(){return _0x172d0d;});}else{return _0x172d0d;}})[_0x8c15('0x2c')](function(_0x117eac){logger['error'](_0x8c15('0x67'),_0x117eac);throw _0x117eac;});}return _0x172d0d;})[_0x8c15('0x23')](respondWithResult(_0x457020,0xc9))[_0x8c15('0x2c')](handleError(_0x457020,null));};exports[_0x8c15('0x68')]=function(_0x1359b9,_0x456f5d){if(_0x1359b9['body']['id']){delete _0x1359b9[_0x8c15('0x61')]['id'];}return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x1359b9[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x41')],'as':_0x8c15('0x42')}]})[_0x8c15('0x23')](handleEntityNotFound(_0x456f5d,null))[_0x8c15('0x23')](saveUpdates(_0x1359b9[_0x8c15('0x61')],null))['then'](respondWithResult(_0x456f5d,null))[_0x8c15('0x2c')](handleError(_0x456f5d,null));};exports[_0x8c15('0x37')]=function(_0x1ca577,_0x3d8388){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x1ca577[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3d8388,null))[_0x8c15('0x23')](removeEntity(_0x3d8388,null))[_0x8c15('0x2c')](handleError(_0x3d8388,null));};exports[_0x8c15('0x6a')]=function(_0x1d2718,_0x28ae74){return db[_0x8c15('0x44')][_0x8c15('0x6a')]()[_0x8c15('0x23')](respondWithResult(_0x28ae74,null))[_0x8c15('0x2c')](handleError(_0x28ae74,null));};exports[_0x8c15('0x6b')]=function(_0x112a4b,_0x155212,_0x2dbc6b){if(_0x112a4b[_0x8c15('0x61')]['id']){delete _0x112a4b[_0x8c15('0x61')]['id'];}return db['ChatWebsite'][_0x8c15('0x69')]({'where':{'id':_0x112a4b[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x155212,null))[_0x8c15('0x23')](function(_0x350d38){if(_0x350d38){_0x112a4b['body'][_0x8c15('0x6c')]=_0x350d38['id'];return db[_0x8c15('0x6d')][_0x8c15('0x60')](_0x112a4b[_0x8c15('0x61')]);}})['then'](respondWithResult(_0x155212,null))['catch'](handleError(_0x155212,null));};exports[_0x8c15('0x6e')]=function(_0x490d1d,_0x2ef35b,_0x1b3cc4){var _0x39b739={'raw':![],'where':{}};var _0x42cc3f={};var _0x200082={'count':0x0,'rows':[]};return db[_0x8c15('0x44')]['findOne']({'where':{'id':_0x490d1d['params']['id']}})['then'](handleEntityNotFound(_0x2ef35b,null))[_0x8c15('0x23')](function(_0x578d92){if(_0x578d92){_0x42cc3f['model']=_[_0x8c15('0x4a')](db[_0x8c15('0x6d')][_0x8c15('0x45')]);_0x42cc3f[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x490d1d[_0x8c15('0x49')]);_0x42cc3f['filters']=_[_0x8c15('0x4c')](_0x42cc3f[_0x8c15('0x48')],_0x42cc3f[_0x8c15('0x49')]);_0x39b739[_0x8c15('0x4b')]=_['intersection'](_0x42cc3f[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x490d1d[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x39b739[_0x8c15('0x4b')]=_0x39b739[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x39b739[_0x8c15('0x4b')]:_0x42cc3f[_0x8c15('0x48')];if(!_0x490d1d[_0x8c15('0x49')][_0x8c15('0x4f')]('nolimit')){_0x39b739[_0x8c15('0x30')]=qs['limit'](_0x490d1d[_0x8c15('0x49')][_0x8c15('0x30')]);_0x39b739[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x490d1d[_0x8c15('0x49')]['offset']);}_0x39b739['order']=qs[_0x8c15('0x52')](_0x490d1d['query'][_0x8c15('0x52')]);_0x39b739[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x490d1d['query'],_0x42cc3f[_0x8c15('0x55')]));_0x39b739[_0x8c15('0x53')][_0x8c15('0x6c')]=_0x578d92['id'];if(_0x490d1d[_0x8c15('0x49')][_0x8c15('0x56')]){_0x39b739[_0x8c15('0x53')]=_['merge'](_0x39b739[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x39b739[_0x8c15('0x4b')],function(_0x1e4df1){var _0x5b3693={};_0x5b3693[_0x1e4df1]={'$like':'%'+_0x490d1d['query'][_0x8c15('0x56')]+'%'};return _0x5b3693;})});}_0x39b739=_['merge']({},_0x39b739,_0x490d1d[_0x8c15('0x59')]);return db[_0x8c15('0x6d')][_0x8c15('0x2e')]({'where':_0x39b739['where']})[_0x8c15('0x23')](function(_0x9ca1b6){_0x200082[_0x8c15('0x2e')]=_0x9ca1b6;if(_0x490d1d[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x39b739[_0x8c15('0x5f')]=[{'all':!![]}];}return db[_0x8c15('0x6d')][_0x8c15('0x5b')](_0x39b739);})[_0x8c15('0x23')](function(_0x84f66d){_0x200082[_0x8c15('0x5c')]=_0x84f66d;return _0x200082;});}})['then'](respondWithFilteredResult(_0x2ef35b,_0x39b739))[_0x8c15('0x2c')](handleError(_0x2ef35b,null));};exports[_0x8c15('0x6f')]=function(_0x649164,_0x3083a1,_0x409ae0){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x649164[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3083a1,null))[_0x8c15('0x23')](function(_0x328079){if(_0x328079){return _0x328079['removeDispositions'](_0x649164['query'][_0x8c15('0x70')]);}})[_0x8c15('0x23')](respondWithStatusCode(_0x3083a1,null))['catch'](handleError(_0x3083a1,null));};exports[_0x8c15('0x71')]=function(_0x45398b,_0x1c9eb9,_0x5a4783){if(_0x45398b[_0x8c15('0x61')]['id']){delete _0x45398b[_0x8c15('0x61')]['id'];}return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x45398b[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1c9eb9,null))[_0x8c15('0x23')](function(_0x1d2539){if(_0x1d2539){_0x45398b[_0x8c15('0x61')][_0x8c15('0x6c')]=_0x1d2539['id'];return db['CannedAnswer'][_0x8c15('0x60')](_0x45398b['body']);}})['then'](respondWithResult(_0x1c9eb9,null))['catch'](handleError(_0x1c9eb9,null));};exports[_0x8c15('0x72')]=function(_0xe3f980,_0x32924e,_0x45d14b){var _0x143835={'raw':![],'where':{}};var _0xf0e694={};var _0x2169df={'count':0x0,'rows':[]};return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0xe3f980['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x32924e,null))[_0x8c15('0x23')](function(_0x545f69){if(_0x545f69){_0xf0e694[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0x74')]['rawAttributes']);_0xf0e694[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0xe3f980[_0x8c15('0x49')]);_0xf0e694['filters']=_[_0x8c15('0x4c')](_0xf0e694[_0x8c15('0x48')],_0xf0e694[_0x8c15('0x49')]);_0x143835[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0xf0e694['model'],qs['fields'](_0xe3f980[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x143835['attributes']=_0x143835[_0x8c15('0x4b')]['length']?_0x143835[_0x8c15('0x4b')]:_0xf0e694['model'];if(!_0xe3f980[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x143835[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0xe3f980[_0x8c15('0x49')]['limit']);_0x143835[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0xe3f980[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x143835[_0x8c15('0x51')]=qs['sort'](_0xe3f980['query'][_0x8c15('0x52')]);_0x143835[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0xe3f980[_0x8c15('0x49')],_0xf0e694[_0x8c15('0x55')]));_0x143835[_0x8c15('0x53')][_0x8c15('0x6c')]=_0x545f69['id'];if(_0xe3f980[_0x8c15('0x49')][_0x8c15('0x56')]){_0x143835['where']=_[_0x8c15('0x57')](_0x143835[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x143835[_0x8c15('0x4b')],function(_0x551cdf){var _0xff2044={};_0xff2044[_0x551cdf]={'$like':'%'+_0xe3f980[_0x8c15('0x49')]['filter']+'%'};return _0xff2044;})});}_0x143835=_[_0x8c15('0x57')]({},_0x143835,_0xe3f980[_0x8c15('0x59')]);return db[_0x8c15('0x74')][_0x8c15('0x2e')]({'where':_0x143835[_0x8c15('0x53')]})['then'](function(_0x2c03cf){_0x2169df[_0x8c15('0x2e')]=_0x2c03cf;if(_0xe3f980['query'][_0x8c15('0x5a')]){_0x143835[_0x8c15('0x5f')]=[{'all':!![]}];}return db[_0x8c15('0x74')]['findAll'](_0x143835);})['then'](function(_0x24f347){_0x2169df['rows']=_0x24f347;return _0x2169df;});}})['then'](respondWithFilteredResult(_0x32924e,_0x143835))[_0x8c15('0x2c')](handleError(_0x32924e,null));};exports[_0x8c15('0x75')]=function(_0x4a7cda,_0x5ab0db,_0x9159b6){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x4a7cda[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x5ab0db,null))[_0x8c15('0x23')](function(_0x26f180){if(_0x26f180){return _0x26f180['removeAnswers'](_0x4a7cda[_0x8c15('0x49')][_0x8c15('0x70')]);}})[_0x8c15('0x23')](respondWithStatusCode(_0x5ab0db,null))[_0x8c15('0x2c')](handleError(_0x5ab0db,null));};exports[_0x8c15('0x76')]=function(_0x2958c0,_0x2113d3,_0xbff0fe){_0x2958c0[_0x8c15('0x61')][_0x8c15('0x77')]=_0x2958c0['file']['filename'];return db[_0x8c15('0x44')]['find']({'where':{'id':_0x2958c0[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x2113d3,null))['then'](saveUpdates(_0x2958c0[_0x8c15('0x61')],null))['then'](respondWithResult(_0x2113d3,null))[_0x8c15('0x2c')](handleError(_0x2113d3,null));};exports[_0x8c15('0x78')]=function(_0x24d36f,_0x57e628,_0xa8d4e0){_0x24d36f['body'][_0x8c15('0x79')]=_0x24d36f[_0x8c15('0x7a')]['filename'];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x24d36f['params']['id']}})['then'](handleEntityNotFound(_0x57e628,null))[_0x8c15('0x23')](saveUpdates(_0x24d36f['body'],null))[_0x8c15('0x23')](respondWithResult(_0x57e628,null))['catch'](handleError(_0x57e628,null));};exports[_0x8c15('0x7b')]=function(_0x5ad5d6,_0x1e07a3,_0x49dc35){_0x5ad5d6['body'][_0x8c15('0x7c')]=_0x5ad5d6[_0x8c15('0x7a')][_0x8c15('0x7d')];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x5ad5d6[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1e07a3,null))[_0x8c15('0x23')](saveUpdates(_0x5ad5d6['body'],null))[_0x8c15('0x23')](respondWithResult(_0x1e07a3,null))[_0x8c15('0x2c')](handleError(_0x1e07a3,null));};exports[_0x8c15('0x7e')]=function(_0x507353,_0x2ebe2d,_0x2742ea){_0x507353[_0x8c15('0x61')][_0x8c15('0x7f')]=_0x507353['file']['filename'];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x507353[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x2ebe2d,null))[_0x8c15('0x23')](saveUpdates(_0x507353[_0x8c15('0x61')],null))[_0x8c15('0x23')](respondWithResult(_0x2ebe2d,null))[_0x8c15('0x2c')](handleError(_0x2ebe2d,null));};exports[_0x8c15('0x80')]=function(_0x1da958,_0x14f03e,_0x66c270){var _0x41aa01=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x83'));var _0x14d2a6={'where':{'id':_0x1da958[_0x8c15('0x5e')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x6f3461=![];return require('../../config/license/util')[_0x8c15('0x84')]()[_0x8c15('0x23')](function(_0xabba75){if(_0xabba75){_0x6f3461=_0xabba75[_0x8c15('0x85')];}})['then'](function(){return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x14d2a6);})[_0x8c15('0x23')](handleEntityNotFound(_0x14f03e,null))[_0x8c15('0x23')](function(_0x3e9995){if(_0x3e9995){if(!_['isNil'](_0x3e9995[_0x8c15('0x77')])){if(fs[_0x8c15('0x86')](path[_0x8c15('0x81')](config['root'],_0x8c15('0x87'),_0x3e9995[_0x8c15('0x77')]))&&_0x6f3461){_0x41aa01=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x87'),_0x3e9995[_0x8c15('0x77')]);}}return _0x14f03e[_0x8c15('0x88')](_0x41aa01);}})[_0x8c15('0x2c')](handleError(_0x14f03e,null));};exports[_0x8c15('0x89')]=function(_0x2e45d2,_0x1480a3,_0x33e600){var _0x5a6b00=path['join'](config['root'],'server/files/images/avatars/default_avatar.png');var _0xbdc379={'where':{'id':_0x2e45d2['params']['id']},'attributes':['id',_0x8c15('0x79')],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0xbdc379)[_0x8c15('0x23')](handleEntityNotFound(_0x1480a3,null))[_0x8c15('0x23')](function(_0x1cddce){if(_0x1cddce){if(!_[_0x8c15('0x8a')](_0x1cddce['agentAvatar'])){if(fs[_0x8c15('0x86')](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x1cddce[_0x8c15('0x79')]))){_0x5a6b00=path[_0x8c15('0x81')](config['root'],_0x8c15('0x8b'),_0x1cddce['agentAvatar']);}}return _0x1480a3[_0x8c15('0x88')](_0x5a6b00);}})[_0x8c15('0x2c')](handleError(_0x1480a3,null));};exports[_0x8c15('0x8c')]=function(_0x1e3c7f,_0x32a36a,_0x7a9049){var _0xc342eb=path[_0x8c15('0x81')](config[_0x8c15('0x82')],'server/files/images/avatars/customer_avatar.png');var _0x3fe3d5={'where':{'id':_0x1e3c7f[_0x8c15('0x5e')]['id']},'attributes':['id',_0x8c15('0x7c'),'showCustomerAvatar'],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x3fe3d5)[_0x8c15('0x23')](handleEntityNotFound(_0x32a36a,null))['then'](function(_0x5281ef){if(_0x5281ef){if(!_[_0x8c15('0x8a')](_0x5281ef[_0x8c15('0x7c')])){if(fs['existsSync'](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x5281ef[_0x8c15('0x7c')]))&&_0x5281ef[_0x8c15('0x8d')]){_0xc342eb=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x5281ef[_0x8c15('0x7c')]);}}return _0x32a36a['download'](_0xc342eb);}})['catch'](handleError(_0x32a36a,null));};exports['getSystemAvatar']=function(_0x580af7,_0x439e7f,_0x32dc86){var _0x50063c=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8e'));var _0x10def5={'where':{'id':_0x580af7[_0x8c15('0x5e')]['id']},'attributes':['id',_0x8c15('0x7f')],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x10def5)[_0x8c15('0x23')](handleEntityNotFound(_0x439e7f,null))[_0x8c15('0x23')](function(_0x346a30){if(_0x346a30){if(!_[_0x8c15('0x8a')](_0x346a30[_0x8c15('0x7f')])){if(fs['existsSync'](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x346a30[_0x8c15('0x7f')]))){_0x50063c=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x346a30['systemAvatar']);}}return _0x439e7f[_0x8c15('0x88')](_0x50063c);}})[_0x8c15('0x2c')](handleError(_0x439e7f,null));};exports['notify']=function(_0x25832e,_0x414f6f,_0x4e2fc8){var _0xe066ee=require(_0x8c15('0x8f'));var _0x591822=new _0xe066ee();var _0x41bba5=_0x591822[_0x8c15('0x90')](_0x25832e[_0x8c15('0x91')][_0x8c15('0x92')])[_0x8c15('0x93')]();var _0x1f1f81={'body':_0x25832e[_0x8c15('0x61')],'channel':'chat'};var _0x322639=[];var _0x53aace=[];var _0x3436ce={};var _0x17a856=![];return db['CmContact']['describe']()[_0x8c15('0x23')](function(_0x2fa2d3){if(!_0x2fa2d3){throw new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0x95'));}_0x322639=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x2fa2d3),[_0x8c15('0x97'),_0x8c15('0x98')]);_0x53aace=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x2fa2d3),['createdAt',_0x8c15('0x98'),_0x8c15('0x99'),_0x8c15('0x9a')]);if(_0x25832e[_0x8c15('0x61')]['id']){delete _0x25832e[_0x8c15('0x61')]['id'];}if(_[_0x8c15('0x8a')](_0x25832e['body'][_0x8c15('0x9b')])){throw new db['Sequelize'][(_0x8c15('0x9c'))]('from\x20is\x20mandatory');}if(_[_0x8c15('0x8a')](_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')])||_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')]===''){throw new db[(_0x8c15('0x94'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x8c15('0x8a')](_0x25832e[_0x8c15('0x61')][_0x8c15('0x9d')])){throw new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0x9e')+_0x53aace);}if(!_[_0x8c15('0x9f')](_0x53aace,_0x25832e[_0x8c15('0x61')][_0x8c15('0x9d')])){throw new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xa0')+_0x53aace);}_0x3436ce[_0x25832e[_0x8c15('0x61')]['mapKey']]=_0x25832e['body']['from'];})[_0x8c15('0x23')](function(){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x25832e[_0x8c15('0x5e')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0x8c15('0xa1')],'as':_0x8c15('0xa2'),'where':_0x3436ce,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x8c15('0xa3')],'as':_0x8c15('0xa4')}]});})['then'](handleEntityNotFound(_0x414f6f,null))['then'](function(_0x58d6be){if(_0x58d6be&&_0x58d6be[_0x8c15('0xa5')]){_0x1f1f81[_0x8c15('0xa6')]=_0x58d6be;_0x1f1f81[_0x8c15('0xa7')]=_0x58d6be[_0x8c15('0xa4')];_0x1f1f81[_0x8c15('0xa8')]=_0x58d6be[_0x8c15('0xa5')];_0x1f1f81['applications']=_[_0x8c15('0xa9')](_0x1f1f81[_0x8c15('0xa7')],[_0x8c15('0xaa')],['asc']);if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa4')]){delete _0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa4')];}if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')]&&_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')][_0x8c15('0xa2')][_0x8c15('0x4e')]){return _0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')][_0x8c15('0xa2')][0x0];}var _0x38028d=_[_0x8c15('0x1b')](_0x25832e['body'],{'firstName':_0x25832e['body'][_0x8c15('0x9b')],'ListId':_0x58d6be[_0x8c15('0x9a')]});_0x38028d[_0x25832e['body'][_0x8c15('0x9d')]]=_0x25832e[_0x8c15('0x61')][_0x8c15('0x9b')];return db['CmContact'][_0x8c15('0x60')](_0x38028d,{'fields':_0x322639,'raw':!![]});}})['then'](handleEntityNotFound(_0x414f6f,null))[_0x8c15('0x23')](function(_0x5ecb89){_0x1f1f81[_0x8c15('0xab')]=_0x5ecb89;var _0x23cce9=_0x25832e[_0x8c15('0x61')][_0x8c15('0xac')];if(_0x25832e[_0x8c15('0x91')][_0x8c15('0xad')]){_0x23cce9=_0x25832e[_0x8c15('0x91')][_0x8c15('0xad')];}else if(_0x25832e[_0x8c15('0x91')]['x-forwarded-for']){_0x23cce9=_[_0x8c15('0xae')](_0x25832e['headers'][_0x8c15('0xaf')][_0x8c15('0xb0')](','));}if(_0x5ecb89){var _0x234307={'ContactId':_0x5ecb89['id'],'ChatWebsiteId':_0x25832e[_0x8c15('0x5e')]['id'],'from':(_0x5ecb89['firstName']||'')+'\x20'+(_0x5ecb89[_0x8c15('0xb1')]||''),'customerIp':_0x23cce9,'customerPort':_0x25832e['headers'][_0x8c15('0xb2')]?_0x25832e[_0x8c15('0x91')]['x-real-port']:null,'referer':_0x25832e[_0x8c15('0x61')]['referer'],'browserName':_0x41bba5[_0x8c15('0xb3')][_0x8c15('0x3e')]&&_0x41bba5['browser'][_0x8c15('0xb4')]?util[_0x8c15('0xb5')](_0x8c15('0xb6'),_0x41bba5['browser']['name'],_0x41bba5['browser'][_0x8c15('0xb4')]):_0x8c15('0xb7'),'browserVersion':_0x41bba5['browser'][_0x8c15('0xb4')]||'unknown','osName':util[_0x8c15('0xb5')](_0x8c15('0xb6'),_0x41bba5['os'][_0x8c15('0x3e')],_0x41bba5['os'][_0x8c15('0xb4')]),'osVersion':_0x41bba5['os']['version'],'deviceModel':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x48')]&&_0x41bba5[_0x8c15('0xb8')]['vendor']?util[_0x8c15('0xb5')](_0x8c15('0xb9'),_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x48')],_0x41bba5[_0x8c15('0xb8')][_0x8c15('0xba')],_0x41bba5[_0x8c15('0xb8')]['type']):null,'deviceVendor':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0xba')],'deviceType':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x46')],'formData':JSON[_0x8c15('0x26')](_0x25832e[_0x8c15('0x61')])};var _0x51b3f7={'ChatWebsiteId':_0x25832e['params']['id'],'closed':![]};if(_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')]){_0x51b3f7[_0x8c15('0xbb')]=_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')];return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':_0x51b3f7})['then'](function(_0x2645d9){if(_0x2645d9){return[_0x2645d9,![]];}_0x234307['threadId']=_0x25832e['body'][_0x8c15('0xbb')];_0x234307[_0x8c15('0xbd')]=_0x25832e['body']['externalUrl'];return db[_0x8c15('0xbc')][_0x8c15('0x60')](_0x234307)[_0x8c15('0x23')](function(_0x1b7725){return[_0x1b7725,!![]];});});}_0x51b3f7[_0x8c15('0xbe')]=_0x5ecb89['id'];if(_0x25832e['body'][_0x8c15('0xbf')]&&_0x25832e[_0x8c15('0x61')][_0x8c15('0xbf')]['id']){_0x51b3f7['id']=_0x25832e[_0x8c15('0x61')][_0x8c15('0xbf')]['id'];return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':_0x51b3f7})[_0x8c15('0x23')](function(_0x2c1793){if(_0x2c1793){return[_0x2c1793,![]];}return db[_0x8c15('0xbc')][_0x8c15('0x60')](_0x234307)[_0x8c15('0x23')](function(_0x52d027){return[_0x52d027,!![]];});});}return db['ChatInteraction']['create'](_0x234307)['then'](function(_0x179431){return[_0x179431,!![]];});}})[_0x8c15('0xc0')](function(_0x5b2f3d,_0x71829a){if(_0x5b2f3d){_0x17a856=_0x71829a;if(!_0x71829a){var _0x4a0b3e={'from':(_0x1f1f81['contact']['firstName']||'')+'\x20'+(_0x1f1f81[_0x8c15('0xab')]['lastName']||'')};if(_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')]&&_0x25832e[_0x8c15('0x61')][_0x8c15('0xc1')]&&_0x25832e['body'][_0x8c15('0xbb')]!=_0x25832e['body'][_0x8c15('0xc1')]){_0x4a0b3e[_0x8c15('0xbb')]=_0x25832e[_0x8c15('0x61')]['messageId'];}return _0x5b2f3d[_0x8c15('0x68')](_0x4a0b3e);}else{return _0x5b2f3d;}}})[_0x8c15('0x23')](function(_0x1d29f9){_0x1f1f81[_0x8c15('0xbf')]=_0x1d29f9[_0x8c15('0x38')]({'plain':!![]});_0x1f1f81['interaction'][_0x8c15('0xc2')]=_0x17a856;if(_0x1f1f81[_0x8c15('0xbf')][_0x8c15('0xc2')]){if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xc3')]){_0x1f1f81[_0x8c15('0xa7')]['push']({'id':0x0,'priority':_0x1f1f81[_0x8c15('0xa7')][_0x8c15('0x4e')]+0x1,'app':_0x8c15('0xc4'),'appdata':_0x8c15('0xc5'),'interval':_0x8c15('0xc6')});}}return db[_0x8c15('0xc7')]['create']({'body':_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')],'ChatWebsiteId':_0x25832e['params']['id'],'ChatInteractionId':_0x1d29f9['id'],'direction':'in','ContactId':_0x1f1f81['contact']['id'],'AttachmentId':_0x25832e[_0x8c15('0x61')][_0x8c15('0xc8')]});})['then'](function(_0x2aabec){_0x1f1f81[_0x8c15('0x29')]=_0x2aabec;if(_0x1f1f81['interaction'][_0x8c15('0xc9')]){return db[_0x8c15('0xca')][_0x8c15('0x69')]({'attributes':['id',_0x8c15('0x3e')],'where':{'id':_0x1f1f81['interaction'][_0x8c15('0xc9')]}})[_0x8c15('0x23')](function(_0x42db2d){if(_0x42db2d){_0x1f1f81[_0x8c15('0xa7')][_0x8c15('0xcb')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x42db2d[_0x8c15('0x3e')]+','+(_0x1f1f81[_0x8c15('0xa6')]['waitForTheAssignedAgent']||0xa),'interval':_0x8c15('0xc6')});_0x1f1f81[_0x8c15('0xcc')]=!![];}return respondWithRpcPromise('Start',_0x8c15('0xcd'),_0x1f1f81);});}return respondWithRpcPromise(_0x8c15('0xce'),_0x8c15('0xcd'),_0x1f1f81);})['then'](function(_0x3ad7c7){respondWithRpcPromise(_0x8c15('0xcf'),_0x8c15('0xcf'),{'event':'notify','message':_0x3ad7c7},client9002);return _0x3ad7c7;})[_0x8c15('0x23')](respondWithResult(_0x414f6f,null))[_0x8c15('0x2c')](handleError(_0x414f6f,null));};exports['offline']=function(_0x2f92e2,_0x4793de,_0xa94d82){var _0x53f4a0,_0x34bfe1,_0x1fa117;var _0x2c1974=[];var _0xe93cd0=[];var _0x588127={};return db[_0x8c15('0xa1')][_0x8c15('0x6a')]()[_0x8c15('0x23')](function(_0x205f0f){if(!_0x205f0f){throw new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0x95'));}_0xe93cd0=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x205f0f),[_0x8c15('0x97'),'updatedAt']);_0x2c1974=_['difference'](_['keys'](_0x205f0f),[_0x8c15('0x97'),_0x8c15('0x98'),_0x8c15('0x99'),_0x8c15('0x9a')]);if(_0x2f92e2[_0x8c15('0x61')]['id']){delete _0x2f92e2[_0x8c15('0x61')]['id'];}if(_[_0x8c15('0x8a')](_0x2f92e2[_0x8c15('0x61')][_0x8c15('0x9b')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)['send'](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd0')));}if(_[_0x8c15('0x8a')](_0x2f92e2['body'][_0x8c15('0x61')])||_0x2f92e2['body'][_0x8c15('0x61')]===''){throw _0x4793de[_0x8c15('0x2d')](0x1f4)['send'](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd1')));}if(_['isNil'](_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)[_0x8c15('0x3f')](new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0xd3')+_0x2c1974));}if(!_['includes'](_0x2c1974,_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)[_0x8c15('0x3f')](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd4')+_0x2c1974));}_0x588127[_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')]]=_0x2f92e2[_0x8c15('0x61')]['from'];})['then'](function(){return db['ChatWebsite'][_0x8c15('0x69')]({'where':{'id':_0x2f92e2[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0xd5')],'as':_0x8c15('0xa5')},{'model':db[_0x8c15('0xd6')],'as':_0x8c15('0xd6')}]});})[_0x8c15('0x23')](handleEntityNotFound(_0x4793de,null))[_0x8c15('0x23')](function(_0x5c04b2){if(_0x5c04b2&&_0x5c04b2[_0x8c15('0xa5')]){_0x34bfe1=_0x5c04b2;var _0x4cc1ac=_['defaults'](_0x2f92e2[_0x8c15('0x61')],{'firstName':_0x2f92e2[_0x8c15('0x61')][_0x8c15('0x9b')],'phone':_0x2f92e2[_0x8c15('0x61')]['from'],'ListId':_0x5c04b2[_0x8c15('0x9a')]});_0x4cc1ac[_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')]]=_0x2f92e2['body']['from'];return db[_0x8c15('0xa1')][_0x8c15('0xd7')]({'where':_0x588127,'defaults':_0x4cc1ac});}})[_0x8c15('0xc0')](function(_0x405080){if(_0x405080){_0x1fa117=_0x405080;var _0xb011f0=fs[_0x8c15('0xd8')](path['join'](config['root'],_0x8c15('0xd9')),_0x8c15('0xda'));var _0x2eacb1=ejs[_0x8c15('0xdb')](_0xb011f0,{'body':_[_0x8c15('0xdc')](_0x2f92e2['body'][_0x8c15('0x61')]),'bodyTitle':_0x34bfe1[_0x8c15('0xdd')]});return db[_0x8c15('0xde')][_0x8c15('0x60')]({'body':_0x2eacb1,'ContactId':_0x405080['id'],'ChatWebsiteId':_0x34bfe1['id']});}})['then'](function(_0x2ff6b3){if(_0x2ff6b3){_0x53f4a0=_0x2ff6b3;return db[_0x8c15('0xd6')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x8c15('0xdf')],'as':'Smtp','raw':!![]}]});}})[_0x8c15('0x23')](function(_0x375380){if(_0x375380&&_0x375380['Smtp']&&_0x34bfe1[_0x8c15('0xe0')]&&_0x34bfe1[_0x8c15('0xe1')]){var _0x8897df={'tls':{'rejectUnauthorized':![]}};if(_0x375380['Smtp'][_0x8c15('0xe2')]){_0x8897df[_0x8c15('0xe2')]=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe2')];}else{_0x8897df[_0x8c15('0xe4')]=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe4')];_0x8897df['port']=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe5')];_0x8897df[_0x8c15('0xe6')]=_0x375380[_0x8c15('0xe3')]['secure'];}if(_0x375380['Smtp'][_0x8c15('0xe7')]){_0x8897df[_0x8c15('0xe8')]={'user':_0x375380[_0x8c15('0xe3')]['user'],'pass':_0x375380[_0x8c15('0xe3')][_0x8c15('0xe9')]};}return respondWithRpcPromise(_0x8c15('0xea'),_0x8c15('0xeb'),{'account':_0x8897df,'message':{'from':util['format'](_0x8c15('0xec'),_0x375380[_0x8c15('0x3e')],_0x375380[_0x8c15('0xed')]||_0x375380[_0x8c15('0xe3')][_0x8c15('0x62')]),'to':_0x34bfe1[_0x8c15('0xe1')],'subject':_0x34bfe1[_0x8c15('0xee')],'text':_0x53f4a0[_0x8c15('0x61')]}},client9003)[_0x8c15('0x23')](function(){return _0x53f4a0;})['catch'](function(_0x2f1da4){console[_0x8c15('0x27')](_0x2f1da4);});}})[_0x8c15('0x23')](function(){if(_0x34bfe1&&_0x34bfe1[_0x8c15('0xef')]&&_0x34bfe1[_0x8c15('0xf0')]){var _0x550c80={'from':_0x1fa117['email'],'firstName':_0x1fa117[_0x8c15('0xf1')],'lastName':_0x1fa117[_0x8c15('0xb1')],'mapKey':_0x8c15('0xed'),'message':{'from':_0x1fa117[_0x8c15('0xed')],'to':_0x34bfe1[_0x8c15('0xd6')]['email'],'cc':'','subject':_0x34bfe1[_0x8c15('0xee')],'messageId':'','sentAt':new Date(),'attach':![],'attachments':[],'originChannel':_0x8c15('0xf2'),'ChatWebsiteId':_0x34bfe1['id'],'ChatOfflineMessageId':_0x53f4a0['id'],'originTo':_0x34bfe1[_0x8c15('0xd6')][_0x8c15('0xed')]},'body':_0x53f4a0[_0x8c15('0x61')]};var _0xe82550={'account':{'id':_0x34bfe1[_0x8c15('0xf0')]},'body':_0x550c80,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0x8c15('0xf3'),_0x8c15('0xf4'),_0xe82550,client9001)[_0x8c15('0x23')](function(){return _0x53f4a0;})[_0x8c15('0x2c')](function(_0x8d42dc){console[_0x8c15('0x27')](_0x8d42dc);});}return;})['then'](function(){if(_0x53f4a0){return _0x53f4a0;}})[_0x8c15('0x23')](respondWithResult(_0x4793de,null))[_0x8c15('0x2c')](handleError(_0x4793de,null));};exports[_0x8c15('0xf5')]=function(_0x35e490,_0x1c1bb4,_0x298b92){return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':{'id':_0x35e490[_0x8c15('0x5e')]['id']}})['then'](handleEntityNotFound(_0x1c1bb4,null))[_0x8c15('0x23')](function(_0x1791a5){if(_0x1791a5){return _0x1791a5[_0x8c15('0xf5')](_0x35e490[_0x8c15('0x61')][_0x8c15('0x70')],_['omit'](_0x35e490[_0x8c15('0x61')],['ids','id'])||{});}})[_0x8c15('0x23')](respondWithResult(_0x1c1bb4,null))[_0x8c15('0x2c')](handleError(_0x1c1bb4,null));};exports[_0x8c15('0xf6')]=function(_0x10042d,_0x418718,_0x4e1e49){var _0x30b631={'raw':![],'where':{}};var _0x5aaceb={};var _0x184801={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x10042d[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x418718,null))[_0x8c15('0x23')](function(_0x1b91c6){if(_0x1b91c6){_0x5aaceb['model']=_['keys'](db['ChatInteraction'][_0x8c15('0x45')]);_0x5aaceb[_0x8c15('0x49')]=_['keys'](_0x10042d[_0x8c15('0x49')]);_0x5aaceb[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x5aaceb[_0x8c15('0x48')],_0x5aaceb[_0x8c15('0x49')]);_0x30b631['attributes']=_[_0x8c15('0x4c')](_0x5aaceb[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x10042d[_0x8c15('0x49')]['fields']));_0x30b631[_0x8c15('0x4b')]=_0x30b631[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x30b631[_0x8c15('0x4b')]:_0x5aaceb['model'];if(!_0x10042d['query'][_0x8c15('0x4f')]('nolimit')){_0x30b631[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x10042d[_0x8c15('0x49')][_0x8c15('0x30')]);_0x30b631[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x10042d[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x30b631[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x10042d['query'][_0x8c15('0x52')]);_0x30b631[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x10042d['query'],_0x5aaceb[_0x8c15('0x55')]));_0x30b631['where'][_0x8c15('0x6c')]=_0x1b91c6['id'];if(_0x10042d[_0x8c15('0x49')][_0x8c15('0x56')]){_0x30b631[_0x8c15('0x53')]=_['merge'](_0x30b631[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x30b631[_0x8c15('0x4b')],function(_0x245995){var _0x5b0170={};_0x5b0170[_0x245995]={'$like':'%'+_0x10042d[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x5b0170;})});}_0x30b631=_[_0x8c15('0x57')]({},_0x30b631,_0x10042d[_0x8c15('0x59')]);return db[_0x8c15('0xbc')]['count']({'where':_0x30b631['where']})[_0x8c15('0x23')](function(_0x3c9ad0){_0x184801[_0x8c15('0x2e')]=_0x3c9ad0;if(_0x10042d[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x30b631[_0x8c15('0x5f')]=[{'model':db['CmContact'],'as':_0x8c15('0xf7'),'required':![]},{'model':db[_0x8c15('0xca')],'as':_0x8c15('0xf8'),'attributes':[_0x8c15('0x3e'),'fullname',_0x8c15('0xf9')],'required':![]},{'model':db['Tag'],'as':_0x8c15('0xfa'),'attributes':['id',_0x8c15('0x3e'),_0x8c15('0xfb')],'where':_0x10042d['query']['tag']?{'id':_0x10042d[_0x8c15('0x49')][_0x8c15('0xfc')]}:undefined,'required':_0x10042d['query'][_0x8c15('0xfc')]?!![]:![]}];}return db[_0x8c15('0xbc')]['findAll'](_0x30b631);})[_0x8c15('0x23')](function(_0x32cbc2){_0x184801[_0x8c15('0x5c')]=_0x32cbc2;return _0x184801;});}})[_0x8c15('0x23')](respondWithFilteredResult(_0x418718,_0x30b631))[_0x8c15('0x2c')](handleError(_0x418718,null));};function iftimePromise(_0x50d2d1,_0x258212){return respondWithRpcPromise(_0x8c15('0xfd'),_0x8c15('0xfe'),{'command':_0x258212[_0x8c15('0xff')]?util['format'](_0x8c15('0x100'),_0x50d2d1[_0x8c15('0x101')],_0x258212['timezone']):util[_0x8c15('0xb5')](_0x8c15('0x102'),_0x50d2d1[_0x8c15('0x101')])},client9002)['then'](function(_0x169384){var _0xf9cbd7=_0x169384&&_0x169384[_0x8c15('0x103')](_0x8c15('0x104'))>=0x0?!![]:![];logger['info'](_0x8c15('0x105'),_0x258212['id'],_0x50d2d1['id'],_0x50d2d1[_0x8c15('0x101')],_0xf9cbd7?_0x8c15('0x106'):_0x8c15('0x107'),_0x258212['timezone']?_0x258212['timezone']:_0x8c15('0x108'));return _0xf9cbd7;})['catch'](function(_0x26a9a1){logger[_0x8c15('0x27')](_0x8c15('0x105'),_0x258212['id'],_0x50d2d1['id'],_0x50d2d1[_0x8c15('0x101')],util[_0x8c15('0x109')](_0x26a9a1,{'showHidden':![],'depth':null}),_0x258212[_0x8c15('0xff')]?_0x258212['timezone']:'No\x20timezone');return![];});}exports[_0x8c15('0xfe')]=function(_0x437738,_0x13509c,_0x3a96f8){var _0x175a71=0x0;var _0x37521d=0x0;var _0x4117fd=![];var _0xf9e44b;var _0x219619;return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x437738[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x10a')],'as':_0x8c15('0x10a'),'include':[{'model':db['Interval'],'as':_0x8c15('0x10b'),'attributes':['id',_0x8c15('0x101')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x13509c,null))[_0x8c15('0x23')](function(_0x527a45){if(_0x527a45){_0xf9e44b=_0x527a45;return _0x527a45[_0x8c15('0x10c')]({'raw':!![]});}})[_0x8c15('0x23')](function(_0x172cab){if(_0xf9e44b){if(_0x172cab){_0x219619=_0x172cab;}}return require(_0x8c15('0x18'))[_0x8c15('0x84')]();})[_0x8c15('0x23')](function(_0x340809){if(_0x340809){_0x37521d=_0x340809[_0x8c15('0x10d')];_0x4117fd=_0x340809[_0x8c15('0x85')];}})[_0x8c15('0x23')](function(){return db[_0x8c15('0xbc')][_0x8c15('0x2e')]({'where':{'closed':![]}});})[_0x8c15('0x23')](function(_0xadbc94){_0x175a71=_0xadbc94;if(_0x37521d&&_0xadbc94>_0x37521d){return db['License'][_0x8c15('0x73')]({'where':{'id':0x1}})[_0x8c15('0x23')](function(_0x19a81b){if(_0x19a81b){_0x19a81b['increment'](_0x8c15('0x10e'));}});}})[_0x8c15('0x23')](function(){if(_0xf9e44b['Interval']&&_0xf9e44b[_0x8c15('0x10a')]['Intervals']){var _0x235ce6=[];for(var _0x3070f7=0x0;_0x3070f7<_0xf9e44b['Interval'][_0x8c15('0x10b')][_0x8c15('0x4e')];_0x3070f7++){var _0x1e99d9=_0xf9e44b[_0x8c15('0x10a')][_0x8c15('0x10b')][_0x3070f7][_0x8c15('0x38')]({'plain':!![]});_0x235ce6[_0x8c15('0x10f')](iftimePromise(_0x1e99d9,_0xf9e44b));}return BPromise[_0x8c15('0x110')](_0x235ce6)[_0x8c15('0x23')](function(_0x15d34f){return _['some'](_0x15d34f);});}else{return!![];}})['then'](function(_0x42e4b6){var _0x1e02f6=fs[_0x8c15('0xd8')](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x111')),_0x8c15('0xda'));var _0x39eec7={'remote':_0xf9e44b['remote'],'query':querystring[_0x8c15('0x26')](_[_0x8c15('0x57')](_0xf9e44b[_0x8c15('0x38')]({'plain':!![]}),{'customerIp':_0x437738[_0x8c15('0x91')][_0x8c15('0xaf')]||_0x437738['headers'][_0x8c15('0x112')]||_0x437738[_0x8c15('0x113')][_0x8c15('0x114')]||_0x437738['ip'],'referer':_0x437738[_0x8c15('0x91')][_0x8c15('0x115')],'openedInteractions':_0x175a71,'maxInteractions':_0x37521d,'virtual':_0x4117fd[_0x8c15('0x10d')],'online':_0x42e4b6,'custom':_0x4117fd}))[_0x8c15('0x116')](/'/g,'\x5c\x27')};_0x13509c[_0x8c15('0x3f')](ejs[_0x8c15('0xdb')](Mustache[_0x8c15('0xdb')](_0x1e02f6,_0x39eec7),{'proactiveActions':_0x219619,'alignment':_0xf9e44b['alignment'],'verticalAlignment':_0xf9e44b[_0x8c15('0x117')],'div_color':_0xf9e44b[_0x8c15('0xfb')],'text_color':_0xf9e44b['textColor']}));})[_0x8c15('0x2c')](handleError(_0x13509c,null));};exports[_0x8c15('0x118')]=function(_0x55925d,_0x3e5de6,_0x20c1ff){return db['ChatWebsite'][_0x8c15('0x73')]({'where':{'id':_0x55925d['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3e5de6,null))[_0x8c15('0x23')](function(_0x1c6f2f){if(_0x1c6f2f){return db[_0x8c15('0x119')][_0x8c15('0x11a')](function(_0x8600ed){return db[_0x8c15('0xa3')][_0x8c15('0x37')]({'where':{'ChatWebsiteId':_0x55925d[_0x8c15('0x5e')]['id']},'transaction':_0x8600ed})['then'](function(_0xe314bc){var _0x357025=_[_0x8c15('0x43')](_0x55925d[_0x8c15('0x61')],function(_0x1d63cb){_0x1d63cb[_0x8c15('0x6c')]=_0x55925d[_0x8c15('0x5e')]['id'];return _0x1d63cb;});return db[_0x8c15('0xa3')]['bulkCreate'](_0x357025,{'transaction':_0x8600ed});});})[_0x8c15('0x23')](function(){return db[_0x8c15('0xa3')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x55925d['params']['id']},'order':_0x8c15('0xaa')});});}})[_0x8c15('0x23')](respondWithResult(_0x3e5de6,null))[_0x8c15('0x2c')](handleError(_0x3e5de6,null));};exports['getApplications']=function(_0x3fff75,_0x47a795,_0x42e143){var _0x22474a={};var _0x3de1dc={};var _0x1f0063;var _0x39a7c1;return db[_0x8c15('0x44')]['findOne']({'where':{'id':_0x3fff75[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x47a795,null))[_0x8c15('0x23')](function(_0x3b8a90){if(_0x3b8a90){_0x1f0063=_0x3b8a90;_0x3de1dc[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db['ChatApplication'][_0x8c15('0x45')]);_0x3de1dc[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x3fff75[_0x8c15('0x49')]);_0x3de1dc['filters']=_[_0x8c15('0x4c')](_0x3de1dc['model'],_0x3de1dc[_0x8c15('0x49')]);_0x22474a[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x3de1dc['model'],qs[_0x8c15('0x4d')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x22474a['attributes']=_0x22474a[_0x8c15('0x4b')]['length']?_0x22474a[_0x8c15('0x4b')]:_0x3de1dc['model'];_0x22474a[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x52')]);_0x22474a[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x3fff75[_0x8c15('0x49')],_0x3de1dc[_0x8c15('0x55')]));if(_0x3fff75[_0x8c15('0x49')][_0x8c15('0x56')]){_0x22474a[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x22474a['where'],{'$or':_['map'](_0x22474a[_0x8c15('0x4b')],function(_0x566258){var _0x26742b={};_0x26742b[_0x566258]={'$like':'%'+_0x3fff75[_0x8c15('0x49')]['filter']+'%'};return _0x26742b;})});}_0x22474a=_['merge']({},_0x22474a,_0x3fff75[_0x8c15('0x59')]);return _0x1f0063[_0x8c15('0x11b')](_0x22474a);}})[_0x8c15('0x23')](function(_0x33014f){if(_0x33014f){_0x39a7c1=_0x33014f[_0x8c15('0x4e')];if(!_0x3fff75['query']['hasOwnProperty'](_0x8c15('0x50'))){_0x22474a['limit']=qs[_0x8c15('0x30')](_0x3fff75['query']['limit']);_0x22474a[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x2f')]);}return _0x1f0063[_0x8c15('0x11b')](_0x22474a);}})['then'](function(_0x2777b7){if(_0x2777b7){return _0x2777b7?{'count':_0x39a7c1,'rows':_0x2777b7}:null;}})['then'](respondWithResult(_0x47a795,null))[_0x8c15('0x2c')](handleError(_0x47a795,null));};exports[_0x8c15('0x11c')]=function(_0x3c2df0,_0xf33775,_0x37a4e2){return db[_0x8c15('0x11d')]['find']({'where':{'id':_0x3c2df0[_0x8c15('0x5e')]['id']}})['then'](handleEntityNotFound(_0xf33775,null))[_0x8c15('0x23')](function(_0x84e09f){if(_0x84e09f){return _0x84e09f[_0x8c15('0x11c')](_0x3c2df0[_0x8c15('0x61')][_0x8c15('0x70')],_[_0x8c15('0x11e')](_0x3c2df0[_0x8c15('0x61')],[_0x8c15('0x70'),'id'])||{});}})[_0x8c15('0x23')](respondWithResult(_0xf33775,null))[_0x8c15('0x2c')](handleError(_0xf33775,null));};exports[_0x8c15('0x10c')]=function(_0x1b18b8,_0x161557,_0x2a3a5b){var _0x127d6f={};var _0x587c14={};var _0x422aaa;var _0xd71248;return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0x1b18b8['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x161557,null))['then'](function(_0x2ea789){if(_0x2ea789){_0x422aaa=_0x2ea789;_0x587c14[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0x11f')][_0x8c15('0x45')]);_0x587c14['query']=_['keys'](_0x1b18b8['query']);_0x587c14[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x587c14['model'],_0x587c14[_0x8c15('0x49')]);_0x127d6f[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x587c14[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x1b18b8[_0x8c15('0x49')]['fields']));_0x127d6f[_0x8c15('0x4b')]=_0x127d6f[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x127d6f[_0x8c15('0x4b')]:_0x587c14['model'];_0x127d6f['order']=qs['sort'](_0x1b18b8['query'][_0x8c15('0x52')]);_0x127d6f[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_['pick'](_0x1b18b8[_0x8c15('0x49')],_0x587c14[_0x8c15('0x55')]));if(_0x1b18b8['query']['filter']){_0x127d6f[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x127d6f[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x127d6f[_0x8c15('0x4b')],function(_0x588083){var _0x579f1c={};_0x579f1c[_0x588083]={'$like':'%'+_0x1b18b8[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x579f1c;})});}_0x127d6f=_[_0x8c15('0x57')]({},_0x127d6f,_0x1b18b8[_0x8c15('0x59')]);return _0x422aaa['getProactiveActions'](_0x127d6f);}})[_0x8c15('0x23')](function(_0x5d863a){if(_0x5d863a){_0xd71248=_0x5d863a['length'];if(!_0x1b18b8['query'][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x127d6f['limit']=qs[_0x8c15('0x30')](_0x1b18b8['query'][_0x8c15('0x30')]);_0x127d6f[_0x8c15('0x2f')]=qs['offset'](_0x1b18b8[_0x8c15('0x49')][_0x8c15('0x2f')]);}return _0x422aaa['getProactiveActions'](_0x127d6f);}})[_0x8c15('0x23')](function(_0x444527){if(_0x444527){return _0x444527?{'count':_0xd71248,'rows':_0x444527}:null;}})[_0x8c15('0x23')](respondWithResult(_0x161557,null))['catch'](handleError(_0x161557,null));};exports['getFields']=function(_0x3b0618,_0x1b1d43,_0x594c79){var _0x22f5d4=_0x3b0618[_0x8c15('0x49')][_0x8c15('0x120')]==='false'?_0x8c15('0x121'):'onlineForm';return db[_0x8c15('0x44')][_0x8c15('0x69')]({'attributes':['id',_0x22f5d4],'where':{'id':_0x3b0618[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1b1d43,null))['then'](function(_0x201298){if(_0x201298){var _0x26dc73=_0x201298[_0x22f5d4];var _0x6a6cb2=_0x26dc73&&_0x26dc73[_0x8c15('0x122')]?_0x26dc73['items']:[];_0x1b1d43['send']({'fromKey':_[_0x8c15('0x8a')](_0x26dc73['fromKey'])?undefined:_0x26dc73['fromKey'],'count':_0x6a6cb2[_0x8c15('0x4e')],'rows':_0x6a6cb2});}})['catch'](handleError(_0x1b1d43,null));};exports[_0x8c15('0x123')]=function(_0x1e9edf,_0x13df9f,_0x3f5b14){var _0x23dd70={'raw':![],'where':{}};var _0x4c1937={};var _0x23ec32={'count':0x0,'rows':[]};return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0x1e9edf[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x13df9f,null))['then'](function(_0x88fef8){if(_0x88fef8){_0x4c1937[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0xde')]['rawAttributes']);_0x4c1937[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x1e9edf[_0x8c15('0x49')]);_0x4c1937[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x4c1937[_0x8c15('0x48')],_0x4c1937[_0x8c15('0x49')]);_0x23dd70[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x4c1937[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x23dd70[_0x8c15('0x4b')]=_0x23dd70[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x23dd70[_0x8c15('0x4b')]:_0x4c1937[_0x8c15('0x48')];if(!_0x1e9edf[_0x8c15('0x49')]['hasOwnProperty'](_0x8c15('0x50'))){_0x23dd70[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x30')]);_0x23dd70[_0x8c15('0x2f')]=qs['offset'](_0x1e9edf[_0x8c15('0x49')]['offset']);}_0x23dd70[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x52')]);_0x23dd70[_0x8c15('0x53')]=qs['filters'](_[_0x8c15('0x54')](_0x1e9edf[_0x8c15('0x49')],_0x4c1937[_0x8c15('0x55')]));_0x23dd70['where'][_0x8c15('0x6c')]=_0x88fef8['id'];if(_0x1e9edf[_0x8c15('0x49')]['filter']){_0x23dd70[_0x8c15('0x53')]=_['merge'](_0x23dd70[_0x8c15('0x53')],{'$or':_['map'](_0x23dd70[_0x8c15('0x4b')],function(_0x472bcd){var _0xae5e74={};_0xae5e74[_0x472bcd]={'$like':'%'+_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0xae5e74;})});}_0x23dd70=_['merge']({},_0x23dd70,_0x1e9edf['options']);return db[_0x8c15('0xde')][_0x8c15('0x2e')]({'where':_0x23dd70[_0x8c15('0x53')]})[_0x8c15('0x23')](function(_0x18f6ae){_0x23ec32[_0x8c15('0x2e')]=_0x18f6ae;if(_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x23dd70[_0x8c15('0x5f')]=[{'all':!![]}];}else{_0x23dd70['include']=[{'model':db[_0x8c15('0xa1')],'as':_0x8c15('0xf7'),'required':![]}];}return db[_0x8c15('0xde')][_0x8c15('0x5b')](_0x23dd70);})['then'](function(_0x4759ab){_0x23ec32[_0x8c15('0x5c')]=_0x4759ab;return _0x23ec32;});}})['then'](respondWithFilteredResult(_0x13df9f,_0x23dd70))[_0x8c15('0x2c')](handleError(_0x13df9f,null));};exports['addAgents']=function(_0x390e74,_0x227bc1,_0x52733b){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x390e74[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x227bc1,null))[_0x8c15('0x23')](function(_0x239125){if(_0x239125){return _0x239125[_0x8c15('0x124')](_0x390e74['body'][_0x8c15('0x70')],_[_0x8c15('0x11e')](_0x390e74[_0x8c15('0x61')],[_0x8c15('0x70'),'id'])||{})[_0x8c15('0xc0')](function(_0x59d18a){for(var _0x4296c6=0x0;_0x4296c6<_0x390e74[_0x8c15('0x61')][_0x8c15('0x70')][_0x8c15('0x4e')];_0x4296c6+=0x1){socket['emit']('userChatWebsite:save',{'UserId':_0x390e74[_0x8c15('0x61')]['ids'][_0x4296c6],'ChatWebsiteId':_0x390e74[_0x8c15('0x5e')]['id']});}return _0x59d18a;});}})[_0x8c15('0x23')](respondWithResult(_0x227bc1,null))[_0x8c15('0x2c')](handleError(_0x227bc1,null));};exports[_0x8c15('0x125')]=function(_0x50af8a,_0x22c40c,_0x40fa93){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x50af8a[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x22c40c,null))[_0x8c15('0x23')](function(_0xb45048){if(_0xb45048){return _0xb45048[_0x8c15('0x125')](_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')])['then'](function(){if(_[_0x8c15('0x126')](_0x50af8a['query']['ids'])){for(var _0x13f464=0x0;_0x13f464<_0x50af8a[_0x8c15('0x49')]['ids'][_0x8c15('0x4e')];_0x13f464+=0x1){socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')][_0x13f464]),'ChatWebsiteId':Number(_0x50af8a[_0x8c15('0x5e')]['id'])});}}else{socket['emit'](_0x8c15('0x127'),{'UserId':Number(_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')]),'ChatWebsiteId':Number(_0x50af8a['params']['id'])});}});}})[_0x8c15('0x23')](respondWithStatusCode(_0x22c40c,null))[_0x8c15('0x2c')](handleError(_0x22c40c,null));};exports[_0x8c15('0x128')]=function(_0xf2aec1,_0x33c63b,_0xa69415){var _0xb32708={};var _0x5c68cf={};var _0x2eb72a;var _0x1a71c2;return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0xf2aec1['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x33c63b,null))['then'](function(_0xa331df){if(_0xa331df){_0x2eb72a=_0xa331df;_0x5c68cf[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0xca')][_0x8c15('0x45')]);_0x5c68cf['query']=_[_0x8c15('0x4a')](_0xf2aec1[_0x8c15('0x49')]);_0x5c68cf[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x5c68cf[_0x8c15('0x48')],_0x5c68cf[_0x8c15('0x49')]);_0xb32708[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x5c68cf[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0xf2aec1[_0x8c15('0x49')][_0x8c15('0x4d')]));_0xb32708[_0x8c15('0x4b')]=_0xb32708['attributes'][_0x8c15('0x4e')]?_0xb32708[_0x8c15('0x4b')]:_0x5c68cf['model'];_0xb32708[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0xf2aec1[_0x8c15('0x49')]['sort']);_0xb32708[_0x8c15('0x53')]=qs['filters'](_['pick'](_0xf2aec1[_0x8c15('0x49')],_0x5c68cf[_0x8c15('0x55')]));if(_0xf2aec1[_0x8c15('0x49')]['filter']){_0xb32708[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0xb32708[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0xb32708['attributes'],function(_0x40676a){var _0x5f12c2={};_0x5f12c2[_0x40676a]={'$like':'%'+_0xf2aec1['query'][_0x8c15('0x56')]+'%'};return _0x5f12c2;})});}_0xb32708=_[_0x8c15('0x57')]({},_0xb32708,_0xf2aec1[_0x8c15('0x59')]);return _0x2eb72a[_0x8c15('0x128')](_0xb32708);}})[_0x8c15('0x23')](function(_0x54f897){if(_0x54f897){_0x1a71c2=_0x54f897['length'];if(!_0xf2aec1[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0xb32708[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0xf2aec1['query']['limit']);_0xb32708[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0xf2aec1['query'][_0x8c15('0x2f')]);}return _0x2eb72a[_0x8c15('0x128')](_0xb32708);}})[_0x8c15('0x23')](function(_0x43ee4a){if(_0x43ee4a){return _0x43ee4a?{'count':_0x1a71c2,'rows':_0x43ee4a}:null;}})[_0x8c15('0x23')](respondWithResult(_0x33c63b,null))[_0x8c15('0x2c')](handleError(_0x33c63b,null));};
\ No newline at end of file