Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / userProfile / userProfile.controller.js
index 17dbe3a..6ac2ad3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9884=['name','send','map','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','hasOwnProperty','limit','order','sort','where','filter','merge','VIRTUAL','UserProfile','then','includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','body','clone','options','get','omit','createdAt','updatedAt','crudPermissions','sequelize','UserProfileSection','each','autoAssociation','userProfileId','Resources','UserProfileResource','destroy','describe','addSections','sectionId','push','enabled','isEmpty','includes','subsections','concat','findOne','Dashboard','forEach','resourceId','Plugin','addResources','transaction','bulkCreate','removeResources','ids','getResources','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','zip-dir','fast-json-patch','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./userProfile.socket','end','status','json','offset','undefined','count','set','Content-Range','apply','reject','update','sendStatus','error','stack'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x9884,0x12c));var _0x4988=function(_0x38209d,_0x282138){_0x38209d=_0x38209d-0x0;var _0x578b0d=_0x9884[_0x38209d];return _0x578b0d;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x4988('0x0'));var zipdir=require(_0x4988('0x1'));var jsonpatch=require(_0x4988('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x4988('0x3'));var Mustache=require(_0x4988('0x4'));var util=require('util');var path=require('path');var sox=require(_0x4988('0x5'));var csv=require(_0x4988('0x6'));var ejs=require(_0x4988('0x7'));var fs=require('fs');var fs_extra=require(_0x4988('0x8'));var _=require(_0x4988('0x9'));var squel=require(_0x4988('0xa'));var crypto=require(_0x4988('0xb'));var jsforce=require(_0x4988('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x4988('0x6'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x4988('0xd'));var authService=require(_0x4988('0xe'));var qs=require(_0x4988('0xf'));var as=require(_0x4988('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x4988('0x11'))(_0x4988('0x12'));var utils=require(_0x4988('0x13'));var config=require(_0x4988('0x14'));var licenseUtil=require(_0x4988('0x15'));var db=require(_0x4988('0x16'))['db'];config[_0x4988('0x17')]=_[_0x4988('0x18')](config[_0x4988('0x17')],{'host':_0x4988('0x19'),'port':0x18eb});var socket=require(_0x4988('0x1a'))(new Redis(config['redis']));require(_0x4988('0x1b'))['register'](socket);function respondWithStatusCode(_0x364ad2,_0x3a35d2){_0x3a35d2=_0x3a35d2||0xcc;return function(_0x4d55ee){if(_0x4d55ee){return _0x364ad2['sendStatus'](_0x3a35d2);}return _0x364ad2['status'](_0x3a35d2)[_0x4988('0x1c')]();};}function respondWithResult(_0x568068,_0x26bc3e){_0x26bc3e=_0x26bc3e||0xc8;return function(_0x313f42){if(_0x313f42){return _0x568068[_0x4988('0x1d')](_0x26bc3e)[_0x4988('0x1e')](_0x313f42);}};}function respondWithFilteredResult(_0x1fe9ed,_0x31845b){return function(_0xfba2d3){if(_0xfba2d3){var _0x5de256=typeof _0x31845b[_0x4988('0x1f')]===_0x4988('0x20')&&typeof _0x31845b['limit']===_0x4988('0x20');var _0x5167eb=_0xfba2d3[_0x4988('0x21')];var _0x199cab=_0x5de256?0x0:_0x31845b[_0x4988('0x1f')];var _0xc3712=_0x5de256?_0xfba2d3['count']:_0x31845b[_0x4988('0x1f')]+_0x31845b['limit'];var _0x39c98d;if(_0xc3712>=_0x5167eb){_0xc3712=_0x5167eb;_0x39c98d=0xc8;}else{_0x39c98d=0xce;}_0x1fe9ed[_0x4988('0x1d')](_0x39c98d);return _0x1fe9ed[_0x4988('0x22')](_0x4988('0x23'),_0x199cab+'-'+_0xc3712+'/'+_0x5167eb)[_0x4988('0x1e')](_0xfba2d3);}return null;};}function patchUpdates(_0x10f945){return function(_0x36399b){try{jsonpatch[_0x4988('0x24')](_0x36399b,_0x10f945,!![]);}catch(_0x53901b){return BPromise[_0x4988('0x25')](_0x53901b);}return _0x36399b['save']();};}function saveUpdates(_0x24d636,_0x5e212e){return function(_0x1b5ec7){if(_0x1b5ec7){return _0x1b5ec7[_0x4988('0x26')](_0x24d636)['then'](function(_0x4a79b9){return _0x4a79b9;});}return null;};}function removeEntity(_0x5b05cd,_0x521846){return function(_0x49a0f0){if(_0x49a0f0){return _0x49a0f0['destroy']()['then'](function(){_0x5b05cd[_0x4988('0x1d')](0xcc)[_0x4988('0x1c')]();});}};}function handleEntityNotFound(_0x43034e,_0x14b0a5){return function(_0x5715b9){if(!_0x5715b9){_0x43034e[_0x4988('0x27')](0x194);}return _0x5715b9;};}function handleError(_0x951945,_0x568a29){_0x568a29=_0x568a29||0x1f4;return function(_0x1bf6b2){logger[_0x4988('0x28')](_0x1bf6b2[_0x4988('0x29')]);if(_0x1bf6b2[_0x4988('0x2a')]){delete _0x1bf6b2[_0x4988('0x2a')];}_0x951945[_0x4988('0x1d')](_0x568a29)[_0x4988('0x2b')](_0x1bf6b2);};}exports['index']=function(_0x55346e,_0x55a135){var _0x3dec26={},_0x49888f={},_0x10a05c={'count':0x0,'rows':[]};var _0x2e5c63=_[_0x4988('0x2c')](db['UserProfile'][_0x4988('0x2d')],function(_0x454fa3){return{'name':_0x454fa3[_0x4988('0x2e')],'type':_0x454fa3[_0x4988('0x2f')][_0x4988('0x30')]};});_0x49888f['model']=_[_0x4988('0x2c')](_0x2e5c63,_0x4988('0x2a'));_0x49888f[_0x4988('0x31')]=_['keys'](_0x55346e[_0x4988('0x31')]);_0x49888f[_0x4988('0x32')]=_[_0x4988('0x33')](_0x49888f[_0x4988('0x34')],_0x49888f['query']);_0x3dec26[_0x4988('0x35')]=_[_0x4988('0x33')](_0x49888f[_0x4988('0x34')],qs[_0x4988('0x36')](_0x55346e[_0x4988('0x31')][_0x4988('0x36')]));_0x3dec26[_0x4988('0x35')]=_0x3dec26['attributes']['length']?_0x3dec26['attributes']:_0x49888f[_0x4988('0x34')];if(!_0x55346e['query'][_0x4988('0x37')]('nolimit')){_0x3dec26[_0x4988('0x38')]=qs[_0x4988('0x38')](_0x55346e[_0x4988('0x31')]['limit']);_0x3dec26[_0x4988('0x1f')]=qs['offset'](_0x55346e[_0x4988('0x31')][_0x4988('0x1f')]);}_0x3dec26[_0x4988('0x39')]=qs[_0x4988('0x3a')](_0x55346e[_0x4988('0x31')][_0x4988('0x3a')]);_0x3dec26[_0x4988('0x3b')]=qs['filters'](_['pick'](_0x55346e[_0x4988('0x31')],_0x49888f[_0x4988('0x32')]),_0x2e5c63);if(_0x55346e[_0x4988('0x31')][_0x4988('0x3c')]){_0x3dec26['where']=_[_0x4988('0x3d')](_0x3dec26['where'],{'$or':_[_0x4988('0x2c')](_0x2e5c63,function(_0xc31f09){if(_0xc31f09['type']!==_0x4988('0x3e')){var _0x458da5={};_0x458da5[_0xc31f09[_0x4988('0x2a')]]={'$like':'%'+_0x55346e[_0x4988('0x31')][_0x4988('0x3c')]+'%'};return _0x458da5;}})});}_0x3dec26=_['merge']({},_0x3dec26,_0x55346e['options']);var _0x4216be={'where':_0x3dec26['where']};return db[_0x4988('0x3f')]['count'](_0x4216be)[_0x4988('0x40')](function(_0x46889b){_0x10a05c['count']=_0x46889b;if(_0x55346e[_0x4988('0x31')][_0x4988('0x41')]){_0x3dec26[_0x4988('0x42')]=[{'all':!![]}];}return db[_0x4988('0x3f')][_0x4988('0x43')](_0x3dec26);})['then'](function(_0x394b3b){_0x10a05c[_0x4988('0x44')]=_0x394b3b;return _0x10a05c;})['then'](respondWithFilteredResult(_0x55a135,_0x3dec26))[_0x4988('0x45')](handleError(_0x55a135,null));};exports[_0x4988('0x46')]=function(_0x30bd42,_0x47d43d){var _0x736fff={'raw':![],'where':{'id':_0x30bd42[_0x4988('0x47')]['id']}},_0x427d7b={};_0x427d7b[_0x4988('0x34')]=_[_0x4988('0x48')](db['UserProfile'][_0x4988('0x2d')]);_0x427d7b[_0x4988('0x31')]=_['keys'](_0x30bd42[_0x4988('0x31')]);_0x427d7b[_0x4988('0x32')]=_[_0x4988('0x33')](_0x427d7b[_0x4988('0x34')],_0x427d7b['query']);_0x736fff[_0x4988('0x35')]=_['intersection'](_0x427d7b[_0x4988('0x34')],qs['fields'](_0x30bd42[_0x4988('0x31')][_0x4988('0x36')]));_0x736fff[_0x4988('0x35')]=_0x736fff[_0x4988('0x35')][_0x4988('0x49')]?_0x736fff[_0x4988('0x35')]:_0x427d7b['model'];if(_0x30bd42[_0x4988('0x31')][_0x4988('0x41')]){_0x736fff[_0x4988('0x42')]=[{'all':!![]}];}_0x736fff=_[_0x4988('0x3d')]({},_0x736fff,_0x30bd42['options']);return db[_0x4988('0x3f')][_0x4988('0x4a')](_0x736fff)['then'](handleEntityNotFound(_0x47d43d,null))[_0x4988('0x40')](respondWithResult(_0x47d43d,null))[_0x4988('0x45')](handleError(_0x47d43d,null));};exports['create']=function(_0x3bf9b1,_0x46f74d){return db['UserProfile'][_0x4988('0x4b')](_0x3bf9b1[_0x4988('0x4c')],{})['then'](respondWithResult(_0x46f74d,0xc9))[_0x4988('0x45')](handleError(_0x46f74d,null));};exports[_0x4988('0x4d')]=function(_0x9a81ec,_0x23c05b){var _0x2a0928={'where':{'id':_0x9a81ec['params']['id']}},_0x24ec5d={};_0x24ec5d[_0x4988('0x34')]=_[_0x4988('0x48')](db[_0x4988('0x3f')][_0x4988('0x2d')]);_0x2a0928[_0x4988('0x35')]=_['intersection'](_0x24ec5d[_0x4988('0x34')],qs[_0x4988('0x36')](_0x9a81ec[_0x4988('0x31')]['fields']));_0x2a0928[_0x4988('0x35')]=_0x2a0928['attributes'][_0x4988('0x49')]?_0x2a0928[_0x4988('0x35')]:_0x24ec5d[_0x4988('0x34')];if(_0x9a81ec[_0x4988('0x31')][_0x4988('0x41')]){_0x2a0928[_0x4988('0x42')]=[{'all':!![]}];}_0x2a0928=_['merge']({},_0x2a0928,_0x9a81ec[_0x4988('0x4e')]);return db[_0x4988('0x3f')]['find'](_0x2a0928)[_0x4988('0x40')](handleEntityNotFound(_0x23c05b,null))[_0x4988('0x40')](function(_0x55454a){if(_0x55454a){var _0x40750c=_0x55454a[_0x4988('0x4f')]({'plain':!![]});_0x40750c=qs[_0x4988('0x50')](_0x40750c,['id',_0x4988('0x51'),_0x4988('0x52'),_0x4988('0x53')]);_0x9a81ec[_0x4988('0x4c')]=_['omit'](_0x9a81ec['body'],['id',_0x4988('0x51'),'updatedAt']);return db[_0x4988('0x54')]['transaction'](function(_0x167dee){return db[_0x4988('0x3f')][_0x4988('0x4b')](_[_0x4988('0x3d')](_0x40750c,_0x9a81ec[_0x4988('0x4c')]),{'include':_0x9a81ec['query'][_0x4988('0x41')]?[{'all':!![]}]:undefined,'transaction':_0x167dee})['then'](function(_0xb3e11c){var _0xbb3552=_0xb3e11c[_0x4988('0x4f')]({'plain':!![]});return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x9a81ec['params']['id']},'raw':!![]})[_0x4988('0x40')](function(_0x267e29){if(_0x267e29){return BPromise[_0x4988('0x56')](_0x267e29,function(_0x459ac7){return new BPromise(function(_0x4f6f1e,_0x5b8f9f){if(_0x459ac7[_0x4988('0x57')]===null||_0x459ac7[_0x4988('0x57')]===0x1)_0x4f6f1e(null);return db['UserProfileResource'][_0x4988('0x43')]({'where':{'sectionId':_0x459ac7['id']},'raw':!![]})[_0x4988('0x40')](function(_0x514a94){var _0x3012cc=_[_0x4988('0x2c')](_0x514a94,function(_0x31bdcc){return qs['omit'](_0x31bdcc,['id','createdAt','updatedAt','sectionId']);});_0x4f6f1e(_0x3012cc);})[_0x4988('0x45')](function(_0x2a9d3f){_0x5b8f9f(_0x2a9d3f);});})[_0x4988('0x40')](function(_0x312100){var _0x497a78=qs[_0x4988('0x50')](_0x459ac7,['id',_0x4988('0x51'),_0x4988('0x52')]);_0x497a78[_0x4988('0x58')]=_0xbb3552['id'];if(_0x312100)_0x497a78[_0x4988('0x59')]=_0x312100;return _0x497a78;})['then'](function(_0x5a7f6f){return db['UserProfileSection'][_0x4988('0x4b')](_0x5a7f6f,{'include':[{'model':db[_0x4988('0x5a')],'as':_0x4988('0x59')}],'raw':!![],'transaction':_0x167dee});});})[_0x4988('0x40')](function(){return _0xbb3552;});}});});});}})[_0x4988('0x40')](respondWithResult(_0x23c05b,0xc9))[_0x4988('0x45')](handleError(_0x23c05b,null));};exports[_0x4988('0x26')]=function(_0x19c378,_0x153804){if(_0x19c378[_0x4988('0x4c')]['id']){delete _0x19c378[_0x4988('0x4c')]['id'];}return db['UserProfile']['find']({'where':{'id':_0x19c378[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x153804,null))['then'](saveUpdates(_0x19c378[_0x4988('0x4c')],null))[_0x4988('0x40')](respondWithResult(_0x153804,null))[_0x4988('0x45')](handleError(_0x153804,null));};exports[_0x4988('0x5b')]=function(_0x5ed3e0,_0x35fdb6){return db[_0x4988('0x3f')]['find']({'where':{'id':_0x5ed3e0[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x35fdb6,null))[_0x4988('0x40')](removeEntity(_0x35fdb6,null))['catch'](handleError(_0x35fdb6,null));};exports['describe']=function(_0x463db9,_0x2b8cf8){return db[_0x4988('0x3f')][_0x4988('0x5c')]()['then'](respondWithResult(_0x2b8cf8,null))[_0x4988('0x45')](handleError(_0x2b8cf8,null));};exports[_0x4988('0x5d')]=function(_0x12b0e8,_0x26ce38){var _0x3d793a=_0x12b0e8[_0x4988('0x4c')];return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x12b0e8[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x26ce38,null))[_0x4988('0x40')](function(_0x58db84){if(_0x58db84){return db['sequelize']['transaction'](function(_0x6db8f4){return db[_0x4988('0x55')][_0x4988('0x5b')]({'where':{'userProfileId':_0x12b0e8['params']['id'],'sectionId':_['map'](_0x3d793a,function(_0x2dfef9){return _0x2dfef9[_0x4988('0x5e')];})},'transaction':_0x6db8f4})['then'](function(){var _0x556722=_['map'](_0x3d793a,function(_0x352e9d){_0x352e9d[_0x4988('0x58')]=_0x12b0e8[_0x4988('0x47')]['id'];return _0x352e9d;});var _0x23d3e1=[];return BPromise['each'](_0x556722,function(_0x269a73){return db['UserProfileSection'][_0x4988('0x4b')](_0x269a73,{'include':[{'model':db[_0x4988('0x5a')],'as':'Resources'}],'raw':!![],'transaction':_0x6db8f4})[_0x4988('0x40')](function(_0x447156){_0x23d3e1[_0x4988('0x5f')](_0x447156[_0x4988('0x4f')]({'plain':!![]}));});})[_0x4988('0x40')](function(){return _0x23d3e1;});});});}})[_0x4988('0x40')](function(_0xa036f4){return _0xa036f4;})[_0x4988('0x40')](respondWithResult(_0x26ce38,null))[_0x4988('0x45')](handleError(_0x26ce38,null));};exports['removeSections']=function(_0x40ed1e,_0x26bd3b){var _0x2611b7;return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x40ed1e[_0x4988('0x47')]['id']},'attributes':['id',_0x4988('0x2a')]})[_0x4988('0x40')](handleEntityNotFound(_0x26bd3b,null))[_0x4988('0x40')](function(_0x239248){if(_0x239248){_0x2611b7=_0x239248;return db[_0x4988('0x55')][_0x4988('0x5b')]({'where':{'userProfileId':_0x40ed1e['params']['id'],'sectionId':_0x40ed1e[_0x4988('0x31')]['ids']}});}})[_0x4988('0x40')](function(){return _0x2611b7;})[_0x4988('0x40')](respondWithStatusCode(_0x26bd3b,null))[_0x4988('0x45')](handleError(_0x26bd3b,null));};exports['getSections']=function(_0x441277,_0x118b39){var _0x361218=[];var _0x31f7b1=[];return db['UserProfileSection'][_0x4988('0x43')]({'where':{'userProfileId':_0x441277[_0x4988('0x47')]['id']},'raw':!![]})['then'](function(_0x3bd5a9){_0x361218=_[_0x4988('0x3c')](_0x3bd5a9,function(_0x4967ee){return _0x4967ee[_0x4988('0x60')]===0x1||_['includes']([0x3eb,0x709],_0x4967ee[_0x4988('0x5e')]);});if(!_[_0x4988('0x61')](_0x361218)){return _[_0x4988('0x2c')](_0x361218,function(_0x22100b){return _0x22100b['sectionId'];});}else{return;}})[_0x4988('0x40')](function(_0xe4fdf9){if(_0xe4fdf9)_0x31f7b1=_0xe4fdf9;if(_[_0x4988('0x62')](_0x31f7b1,0x64)){var _0x4e05c3=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x64});return hasDefaultDashboard(_0x4e05c3)[_0x4988('0x40')](function(_0x3ede66){return _[_0x4988('0x2c')](_0x361218,function(_0x45870e){if(_0x45870e[_0x4988('0x5e')]===0x64){_0x45870e[_0x4988('0x63')]=_0x3ede66;}return _0x45870e;});});}else{return;}})[_0x4988('0x40')](function(_0x4c7010){if(_0x4c7010)_0x361218=_0x4c7010;if(_[_0x4988('0x62')](_0x31f7b1,0x3eb)){var _0x3863b0=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x3eb});return getCustomDashboards(_0x3863b0)[_0x4988('0x40')](function(_0x2913a6){return _[_0x4988('0x2c')](_0x361218,function(_0x63cdcb){if(_0x3863b0[_0x4988('0x60')]){if(_0x63cdcb[_0x4988('0x5e')]===0x3eb){_0x63cdcb[_0x4988('0x63')]=_0x2913a6;}}else{if(_0x63cdcb[_0x4988('0x5e')]===0x64){if(!_0x63cdcb[_0x4988('0x63')]){_0x63cdcb[_0x4988('0x63')]=[];}_0x63cdcb[_0x4988('0x63')]=_0x63cdcb[_0x4988('0x63')][_0x4988('0x64')](_0x2913a6);}}return _0x63cdcb;});});}else{return;}})[_0x4988('0x40')](function(_0x42e06a){if(_0x42e06a)_0x361218=_0x42e06a;if(_['includes'](_0x31f7b1,0x709)){var _0x4a112f=_[_0x4988('0x4a')](_0x361218,{'sectionId':0x709});return getPlugins(_0x4a112f)[_0x4988('0x40')](function(_0x39e87){if(_0x4a112f['enabled']){return _[_0x4988('0x2c')](_0x361218,function(_0x5bb1da){if(_0x5bb1da[_0x4988('0x5e')]===0x709){_0x5bb1da['subsections']=_0x39e87;}return _0x5bb1da;});}else{var _0x5b6a9c={'sectionId':0x76c,'enabled':0x1,'subsections':_0x39e87};var _0x2b904d=_[_0x4988('0x2c')](_0x361218);_0x2b904d[_0x4988('0x5f')](_0x5b6a9c);return _0x2b904d;}});}else{return;}})[_0x4988('0x40')](function(_0x535714){if(_0x535714)_0x361218=_0x535714;return _[_0x4988('0x3c')](_0x361218,[_0x4988('0x60'),0x1]);})[_0x4988('0x40')](respondWithResult(_0x118b39,null))[_0x4988('0x45')](handleError(_0x118b39,null));};function hasDefaultDashboard(_0x4ba4ed){var _0x4c41f7=[0x65];return new BPromise(function(_0x4f7668,_0x56d28f){try{if(_0x4ba4ed[_0x4988('0x57')]){_0x4f7668(_0x4c41f7);}else{return db[_0x4988('0x5a')][_0x4988('0x65')]({'where':{'sectionId':_0x4ba4ed['id']},'raw':!![]})[_0x4988('0x40')](function(_0x4bdf37){_0x4bdf37?_0x4f7668(_0x4c41f7):_0x4f7668();});}}catch(_0x2a0a93){_0x56d28f(_0x2a0a93);}});}function getCustomDashboards(_0x75d20d){var _0x3790ab=[];return new BPromise(function(_0x45a212,_0x1a3819){try{if(_0x75d20d[_0x4988('0x57')]){return db[_0x4988('0x66')][_0x4988('0x43')]({'raw':!![]})[_0x4988('0x40')](function(_0x2d1773){_0x2d1773[_0x4988('0x67')](function(_0x3d482e){_0x3790ab[_0x4988('0x5f')](_0x3d482e['id']+0x1869f);});_0x45a212(_0x3790ab);});}else{return db[_0x4988('0x5a')][_0x4988('0x43')]({'where':{'sectionId':_0x75d20d['id']},'raw':!![]})[_0x4988('0x40')](function(_0x199459){_0x199459[_0x4988('0x67')](function(_0x37734a){_0x3790ab['push'](_0x37734a[_0x4988('0x68')]+0x1869f);});_0x45a212(_0x3790ab);});}}catch(_0x5e7651){_0x1a3819(_0x5e7651);}});}function getPlugins(_0x3bd70b){var _0x19f278=[];return new BPromise(function(_0x29edf9,_0x2507df){try{if(_0x3bd70b['autoAssociation']){return db[_0x4988('0x69')]['findAll']({'raw':!![]})['then'](function(_0x4e7be3){_0x4e7be3[_0x4988('0x67')](function(_0x837db3){_0x19f278[_0x4988('0x5f')](_0x837db3['id']+0x15b38);});_0x29edf9(_0x19f278);});}else{return db[_0x4988('0x5a')][_0x4988('0x43')]({'where':{'sectionId':_0x3bd70b['id']},'raw':!![]})[_0x4988('0x40')](function(_0x54298e){_0x54298e[_0x4988('0x67')](function(_0x1ad655){_0x19f278[_0x4988('0x5f')](_0x1ad655[_0x4988('0x68')]+0x15b38);});_0x29edf9(_0x19f278);});}}catch(_0x1bee3f){_0x2507df(_0x1bee3f);}});}exports[_0x4988('0x6a')]=function(_0x2e4879,_0x3f3898){return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x2e4879[_0x4988('0x47')]['id']}})[_0x4988('0x40')](handleEntityNotFound(_0x3f3898,null))['then'](function(_0x5ef26d){if(_0x5ef26d){return db[_0x4988('0x54')][_0x4988('0x6b')](function(_0x437123){return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x2e4879[_0x4988('0x47')]['id']},'attributes':['id'],'raw':!![]})[_0x4988('0x40')](function(_0x2ba21c){if(_0x2ba21c){return db['UserProfileSection'][_0x4988('0x5b')]({'where':{'userProfileId':_0x2e4879[_0x4988('0x47')]['id'],'id':_[_0x4988('0x2c')](_0x2ba21c,function(_0x38c4e4){return _0x38c4e4['id'];})},'transaction':_0x437123});}})['then'](function(_0xa8d16a){var _0xccbfa4=_[_0x4988('0x2c')](_0x2e4879[_0x4988('0x4c')],function(_0xc0256c){_0xc0256c[_0x4988('0x58')]=_0x2e4879[_0x4988('0x47')]['id'];return _0xc0256c;});return db[_0x4988('0x55')][_0x4988('0x6c')](_0xccbfa4,{'raw':!![],'transaction':_0x437123});})[_0x4988('0x40')](function(_0x499ba8){var _0xd78998=_[_0x4988('0x3c')](_['map'](_0x499ba8,function(_0x2718f5){return _0x2718f5['get']({'plain':!![]});}),{'includeAll':![]});if(_0xd78998){return db[_0x4988('0x55')][_0x4988('0x43')]({'where':{'userProfileId':_0x2e4879['params']['id'],'sectionId':_[_0x4988('0x2c')](_0xd78998,function(_0x2c02d7){return _0x2c02d7[_0x4988('0x5e')];})},'attributes':['id','sectionId'],'raw':!![]})[_0x4988('0x40')](function(_0x2fb910){var _0x4b60a5=_[_0x4988('0x2c')](_0x2e4879[_0x4988('0x4c')],function(_0x5990ca){_0x5990ca[_0x4988('0x58')]=_0x2e4879[_0x4988('0x47')]['id'];return _0x5990ca;});return db[_0x4988('0x5a')][_0x4988('0x6c')](_0x4b60a5,{'raw':!![],'transaction':_0x437123});});}})['catch'](handleError(_0x3f3898,null));});}})[_0x4988('0x40')](function(_0x5d0af7){var _0x44a7de=_[_0x4988('0x2c')](_0x5d0af7,function(_0x34a101){return _0x34a101[_0x4988('0x4f')]({'plain':!![]});});})[_0x4988('0x40')](respondWithResult(_0x3f3898,null))[_0x4988('0x45')](handleError(_0x3f3898,null));};exports[_0x4988('0x6d')]=function(_0x3d44bc,_0x357ba0,_0x2e49da){return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x3d44bc[_0x4988('0x47')]['id']}})['then'](handleEntityNotFound(_0x357ba0,null))['then'](function(_0x6b37ad){if(_0x6b37ad){return _0x6b37ad['removeResources'](_0x3d44bc['query'][_0x4988('0x6e')]);}})[_0x4988('0x40')](respondWithStatusCode(_0x357ba0,null))[_0x4988('0x45')](handleError(_0x357ba0,null));};exports[_0x4988('0x6f')]=function(_0x2d7d56,_0x12d897){var _0x418ab4={};if(!_0x2d7d56[_0x4988('0x31')]['section'])throw new Error(_0x4988('0x70'));if(!_0x2d7d56[_0x4988('0x31')][_0x4988('0x37')]('nolimit')){_0x418ab4[_0x4988('0x38')]=qs['limit'](_0x2d7d56[_0x4988('0x31')]['limit']);_0x418ab4[_0x4988('0x1f')]=qs[_0x4988('0x1f')](_0x2d7d56[_0x4988('0x31')][_0x4988('0x1f')]);}return db[_0x4988('0x3f')][_0x4988('0x4a')]({'where':{'id':_0x2d7d56[_0x4988('0x47')]['id']}})[_0x4988('0x40')](function(_0x207351){if(!_0x207351)throw new Error(_0x4988('0x71')+_0x2d7d56[_0x4988('0x47')]['id']);return db[_0x4988('0x3f')]['getResources'](_0x2d7d56);})[_0x4988('0x40')](respondWithFilteredResult(_0x12d897,_0x418ab4))[_0x4988('0x45')](handleError(_0x12d897,null));};
\ No newline at end of file
+var _0x8c93=['error','stack','name','send','index','map','UserProfile','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','include','findAll','rows','catch','show','params','keys','includeAll','options','find','create','clone','omit','createdAt','updatedAt','crudPermissions','sequelize','transaction','body','get','UserProfileSection','each','autoAssociation','UserProfileResource','sectionId','userProfileId','Resources','describe','addSections','push','removeSections','ids','getSections','enabled','includes','isEmpty','subsections','concat','forEach','resourceId','Plugin','addResources','bulkCreate','removeResources','getResources','section','Missing\x20section\x20parameter','No\x20User\x20Profile\x20found\x20for\x20id\x20','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','save','update','then','destroy'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x8c93,0x1aa));var _0x38c9=function(_0x2ba8b5,_0x4cfc1d){_0x2ba8b5=_0x2ba8b5-0x0;var _0x1f1da9=_0x8c93[_0x2ba8b5];return _0x1f1da9;};'use strict';var emlformat=require(_0x38c9('0x0'));var rimraf=require(_0x38c9('0x1'));var zipdir=require(_0x38c9('0x2'));var jsonpatch=require(_0x38c9('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x38c9('0x4'));var Mustache=require(_0x38c9('0x5'));var util=require('util');var path=require(_0x38c9('0x6'));var sox=require(_0x38c9('0x7'));var csv=require(_0x38c9('0x8'));var ejs=require(_0x38c9('0x9'));var fs=require('fs');var fs_extra=require(_0x38c9('0xa'));var _=require('lodash');var squel=require(_0x38c9('0xb'));var crypto=require(_0x38c9('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x38c9('0x8'));var querystring=require(_0x38c9('0xd'));var Papa=require(_0x38c9('0xe'));var Redis=require(_0x38c9('0xf'));var authService=require(_0x38c9('0x10'));var qs=require(_0x38c9('0x11'));var as=require(_0x38c9('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x38c9('0x13'))('api');var utils=require(_0x38c9('0x14'));var config=require(_0x38c9('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0x38c9('0x16'))['db'];config[_0x38c9('0x17')]=_[_0x38c9('0x18')](config[_0x38c9('0x17')],{'host':_0x38c9('0x19'),'port':0x18eb});var socket=require(_0x38c9('0x1a'))(new Redis(config[_0x38c9('0x17')]));require('./userProfile.socket')[_0x38c9('0x1b')](socket);function respondWithStatusCode(_0x426f3a,_0x4e89b2){_0x4e89b2=_0x4e89b2||0xcc;return function(_0x9f63af){if(_0x9f63af){return _0x426f3a[_0x38c9('0x1c')](_0x4e89b2);}return _0x426f3a[_0x38c9('0x1d')](_0x4e89b2)[_0x38c9('0x1e')]();};}function respondWithResult(_0x136ecf,_0x38db17){_0x38db17=_0x38db17||0xc8;return function(_0x40e61e){if(_0x40e61e){return _0x136ecf[_0x38c9('0x1d')](_0x38db17)[_0x38c9('0x1f')](_0x40e61e);}};}function respondWithFilteredResult(_0x26e28c,_0xf2c472){return function(_0x10b2dd){if(_0x10b2dd){var _0xc4a474=typeof _0xf2c472[_0x38c9('0x20')]==='undefined'&&typeof _0xf2c472[_0x38c9('0x21')]===_0x38c9('0x22');var _0x4302b3=_0x10b2dd['count'];var _0x178cbd=_0xc4a474?0x0:_0xf2c472[_0x38c9('0x20')];var _0x569933=_0xc4a474?_0x10b2dd[_0x38c9('0x23')]:_0xf2c472[_0x38c9('0x20')]+_0xf2c472[_0x38c9('0x21')];var _0x4cc196;if(_0x569933>=_0x4302b3){_0x569933=_0x4302b3;_0x4cc196=0xc8;}else{_0x4cc196=0xce;}_0x26e28c[_0x38c9('0x1d')](_0x4cc196);return _0x26e28c[_0x38c9('0x24')](_0x38c9('0x25'),_0x178cbd+'-'+_0x569933+'/'+_0x4302b3)[_0x38c9('0x1f')](_0x10b2dd);}return null;};}function patchUpdates(_0x1a6dbb){return function(_0x54fe2d){try{jsonpatch['apply'](_0x54fe2d,_0x1a6dbb,!![]);}catch(_0x4e8bbd){return BPromise['reject'](_0x4e8bbd);}return _0x54fe2d[_0x38c9('0x26')]();};}function saveUpdates(_0x824920,_0xbd589c){return function(_0x178f3c){if(_0x178f3c){return _0x178f3c[_0x38c9('0x27')](_0x824920)[_0x38c9('0x28')](function(_0x295683){return _0x295683;});}return null;};}function removeEntity(_0x49e7fa,_0xbaad99){return function(_0x58b880){if(_0x58b880){return _0x58b880[_0x38c9('0x29')]()['then'](function(){_0x49e7fa[_0x38c9('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x498588,_0x56a31c){return function(_0x27cd34){if(!_0x27cd34){_0x498588[_0x38c9('0x1c')](0x194);}return _0x27cd34;};}function handleError(_0x1edd86,_0x3a8cc6){_0x3a8cc6=_0x3a8cc6||0x1f4;return function(_0x51f816){logger[_0x38c9('0x2a')](_0x51f816[_0x38c9('0x2b')]);if(_0x51f816['name']){delete _0x51f816[_0x38c9('0x2c')];}_0x1edd86[_0x38c9('0x1d')](_0x3a8cc6)[_0x38c9('0x2d')](_0x51f816);};}exports[_0x38c9('0x2e')]=function(_0x1b3d40,_0x8ece55){var _0x868412={},_0xbd5c47={},_0x10a307={'count':0x0,'rows':[]};var _0x590e81=_[_0x38c9('0x2f')](db[_0x38c9('0x30')][_0x38c9('0x31')],function(_0xc412a9){return{'name':_0xc412a9[_0x38c9('0x32')],'type':_0xc412a9[_0x38c9('0x33')][_0x38c9('0x34')]};});_0xbd5c47['model']=_[_0x38c9('0x2f')](_0x590e81,_0x38c9('0x2c'));_0xbd5c47[_0x38c9('0x35')]=_['keys'](_0x1b3d40[_0x38c9('0x35')]);_0xbd5c47[_0x38c9('0x36')]=_[_0x38c9('0x37')](_0xbd5c47[_0x38c9('0x38')],_0xbd5c47[_0x38c9('0x35')]);_0x868412[_0x38c9('0x39')]=_[_0x38c9('0x37')](_0xbd5c47['model'],qs[_0x38c9('0x3a')](_0x1b3d40[_0x38c9('0x35')]['fields']));_0x868412[_0x38c9('0x39')]=_0x868412['attributes'][_0x38c9('0x3b')]?_0x868412['attributes']:_0xbd5c47[_0x38c9('0x38')];if(!_0x1b3d40[_0x38c9('0x35')][_0x38c9('0x3c')](_0x38c9('0x3d'))){_0x868412[_0x38c9('0x21')]=qs['limit'](_0x1b3d40['query'][_0x38c9('0x21')]);_0x868412[_0x38c9('0x20')]=qs[_0x38c9('0x20')](_0x1b3d40['query'][_0x38c9('0x20')]);}_0x868412[_0x38c9('0x3e')]=qs[_0x38c9('0x3f')](_0x1b3d40['query'][_0x38c9('0x3f')]);_0x868412['where']=qs[_0x38c9('0x36')](_[_0x38c9('0x40')](_0x1b3d40[_0x38c9('0x35')],_0xbd5c47[_0x38c9('0x36')]),_0x590e81);if(_0x1b3d40[_0x38c9('0x35')][_0x38c9('0x41')]){_0x868412[_0x38c9('0x42')]=_[_0x38c9('0x43')](_0x868412['where'],{'$or':_['map'](_0x590e81,function(_0x37c833){if(_0x37c833[_0x38c9('0x33')]!==_0x38c9('0x44')){var _0x28a3ed={};_0x28a3ed[_0x37c833['name']]={'$like':'%'+_0x1b3d40[_0x38c9('0x35')][_0x38c9('0x41')]+'%'};return _0x28a3ed;}})});}_0x868412=_[_0x38c9('0x43')]({},_0x868412,_0x1b3d40['options']);var _0x590f9f={'where':_0x868412[_0x38c9('0x42')]};return db[_0x38c9('0x30')][_0x38c9('0x23')](_0x590f9f)[_0x38c9('0x28')](function(_0x37fa22){_0x10a307['count']=_0x37fa22;if(_0x1b3d40['query']['includeAll']){_0x868412[_0x38c9('0x45')]=[{'all':!![]}];}return db[_0x38c9('0x30')][_0x38c9('0x46')](_0x868412);})['then'](function(_0x2b4331){_0x10a307[_0x38c9('0x47')]=_0x2b4331;return _0x10a307;})[_0x38c9('0x28')](respondWithFilteredResult(_0x8ece55,_0x868412))[_0x38c9('0x48')](handleError(_0x8ece55,null));};exports[_0x38c9('0x49')]=function(_0x4a0074,_0x746bb0){var _0x476bf1={'raw':![],'where':{'id':_0x4a0074[_0x38c9('0x4a')]['id']}},_0x48844d={};_0x48844d[_0x38c9('0x38')]=_[_0x38c9('0x4b')](db['UserProfile']['rawAttributes']);_0x48844d[_0x38c9('0x35')]=_[_0x38c9('0x4b')](_0x4a0074['query']);_0x48844d[_0x38c9('0x36')]=_[_0x38c9('0x37')](_0x48844d['model'],_0x48844d[_0x38c9('0x35')]);_0x476bf1[_0x38c9('0x39')]=_['intersection'](_0x48844d['model'],qs[_0x38c9('0x3a')](_0x4a0074[_0x38c9('0x35')]['fields']));_0x476bf1[_0x38c9('0x39')]=_0x476bf1[_0x38c9('0x39')][_0x38c9('0x3b')]?_0x476bf1['attributes']:_0x48844d['model'];if(_0x4a0074[_0x38c9('0x35')][_0x38c9('0x4c')]){_0x476bf1[_0x38c9('0x45')]=[{'all':!![]}];}_0x476bf1=_[_0x38c9('0x43')]({},_0x476bf1,_0x4a0074[_0x38c9('0x4d')]);return db['UserProfile'][_0x38c9('0x4e')](_0x476bf1)[_0x38c9('0x28')](handleEntityNotFound(_0x746bb0,null))[_0x38c9('0x28')](respondWithResult(_0x746bb0,null))['catch'](handleError(_0x746bb0,null));};exports['create']=function(_0x57f064,_0x3a2eab){return db['UserProfile'][_0x38c9('0x4f')](_0x57f064['body'],{})[_0x38c9('0x28')](respondWithResult(_0x3a2eab,0xc9))[_0x38c9('0x48')](handleError(_0x3a2eab,null));};exports[_0x38c9('0x50')]=function(_0x27af13,_0x471e3e){var _0x66887={'where':{'id':_0x27af13[_0x38c9('0x4a')]['id']}},_0x4b924c={};_0x4b924c[_0x38c9('0x38')]=_[_0x38c9('0x4b')](db[_0x38c9('0x30')]['rawAttributes']);_0x66887[_0x38c9('0x39')]=_['intersection'](_0x4b924c[_0x38c9('0x38')],qs[_0x38c9('0x3a')](_0x27af13['query'][_0x38c9('0x3a')]));_0x66887[_0x38c9('0x39')]=_0x66887[_0x38c9('0x39')]['length']?_0x66887[_0x38c9('0x39')]:_0x4b924c[_0x38c9('0x38')];if(_0x27af13[_0x38c9('0x35')][_0x38c9('0x4c')]){_0x66887[_0x38c9('0x45')]=[{'all':!![]}];}_0x66887=_['merge']({},_0x66887,_0x27af13[_0x38c9('0x4d')]);return db[_0x38c9('0x30')]['find'](_0x66887)[_0x38c9('0x28')](handleEntityNotFound(_0x471e3e,null))[_0x38c9('0x28')](function(_0x2fcb8e){if(_0x2fcb8e){var _0x3b62f3=_0x2fcb8e['get']({'plain':!![]});_0x3b62f3=qs[_0x38c9('0x51')](_0x3b62f3,['id',_0x38c9('0x52'),_0x38c9('0x53'),_0x38c9('0x54')]);_0x27af13['body']=_[_0x38c9('0x51')](_0x27af13['body'],['id',_0x38c9('0x52'),_0x38c9('0x53')]);return db[_0x38c9('0x55')][_0x38c9('0x56')](function(_0x4e6616){return db['UserProfile'][_0x38c9('0x4f')](_[_0x38c9('0x43')](_0x3b62f3,_0x27af13[_0x38c9('0x57')]),{'include':_0x27af13[_0x38c9('0x35')][_0x38c9('0x4c')]?[{'all':!![]}]:undefined,'transaction':_0x4e6616})[_0x38c9('0x28')](function(_0xd2a578){var _0x25804a=_0xd2a578[_0x38c9('0x58')]({'plain':!![]});return db[_0x38c9('0x59')][_0x38c9('0x46')]({'where':{'userProfileId':_0x27af13[_0x38c9('0x4a')]['id']},'raw':!![]})[_0x38c9('0x28')](function(_0x59430c){if(_0x59430c){return BPromise[_0x38c9('0x5a')](_0x59430c,function(_0xfa64ce){return new BPromise(function(_0x2db550,_0x58438a){if(_0xfa64ce['autoAssociation']===null||_0xfa64ce[_0x38c9('0x5b')]===0x1)_0x2db550(null);return db[_0x38c9('0x5c')][_0x38c9('0x46')]({'where':{'sectionId':_0xfa64ce['id']},'raw':!![]})[_0x38c9('0x28')](function(_0x3182c3){var _0x550e33=_[_0x38c9('0x2f')](_0x3182c3,function(_0x1f6f21){return qs[_0x38c9('0x51')](_0x1f6f21,['id',_0x38c9('0x52'),_0x38c9('0x53'),_0x38c9('0x5d')]);});_0x2db550(_0x550e33);})[_0x38c9('0x48')](function(_0x2b0f98){_0x58438a(_0x2b0f98);});})[_0x38c9('0x28')](function(_0x21ce4f){var _0x447aba=qs[_0x38c9('0x51')](_0xfa64ce,['id',_0x38c9('0x52'),_0x38c9('0x53')]);_0x447aba[_0x38c9('0x5e')]=_0x25804a['id'];if(_0x21ce4f)_0x447aba['Resources']=_0x21ce4f;return _0x447aba;})[_0x38c9('0x28')](function(_0x492984){return db['UserProfileSection'][_0x38c9('0x4f')](_0x492984,{'include':[{'model':db[_0x38c9('0x5c')],'as':_0x38c9('0x5f')}],'raw':!![],'transaction':_0x4e6616});});})['then'](function(){return _0x25804a;});}});});});}})[_0x38c9('0x28')](respondWithResult(_0x471e3e,0xc9))[_0x38c9('0x48')](handleError(_0x471e3e,null));};exports[_0x38c9('0x27')]=function(_0x18d3dc,_0x25b704){if(_0x18d3dc['body']['id']){delete _0x18d3dc[_0x38c9('0x57')]['id'];}return db['UserProfile'][_0x38c9('0x4e')]({'where':{'id':_0x18d3dc[_0x38c9('0x4a')]['id']}})[_0x38c9('0x28')](handleEntityNotFound(_0x25b704,null))[_0x38c9('0x28')](saveUpdates(_0x18d3dc[_0x38c9('0x57')],null))[_0x38c9('0x28')](respondWithResult(_0x25b704,null))[_0x38c9('0x48')](handleError(_0x25b704,null));};exports[_0x38c9('0x29')]=function(_0x116d2b,_0x1fbd31){return db[_0x38c9('0x30')][_0x38c9('0x4e')]({'where':{'id':_0x116d2b['params']['id']}})['then'](handleEntityNotFound(_0x1fbd31,null))['then'](removeEntity(_0x1fbd31,null))['catch'](handleError(_0x1fbd31,null));};exports[_0x38c9('0x60')]=function(_0x4e81ad,_0x1dc205){return db[_0x38c9('0x30')][_0x38c9('0x60')]()[_0x38c9('0x28')](respondWithResult(_0x1dc205,null))[_0x38c9('0x48')](handleError(_0x1dc205,null));};exports[_0x38c9('0x61')]=function(_0x515e61,_0xb34527){var _0x36b917=_0x515e61[_0x38c9('0x57')];return db[_0x38c9('0x30')][_0x38c9('0x4e')]({'where':{'id':_0x515e61['params']['id']}})[_0x38c9('0x28')](handleEntityNotFound(_0xb34527,null))[_0x38c9('0x28')](function(_0x2cb19b){if(_0x2cb19b){return db['sequelize'][_0x38c9('0x56')](function(_0x1d5c00){return db[_0x38c9('0x59')][_0x38c9('0x29')]({'where':{'userProfileId':_0x515e61[_0x38c9('0x4a')]['id'],'sectionId':_[_0x38c9('0x2f')](_0x36b917,function(_0x45e34c){return _0x45e34c[_0x38c9('0x5d')];})},'transaction':_0x1d5c00})[_0x38c9('0x28')](function(){var _0x47092e=_[_0x38c9('0x2f')](_0x36b917,function(_0x4d689c){_0x4d689c[_0x38c9('0x5e')]=_0x515e61[_0x38c9('0x4a')]['id'];return _0x4d689c;});var _0x119ff7=[];return BPromise['each'](_0x47092e,function(_0x598a9f){return db[_0x38c9('0x59')][_0x38c9('0x4f')](_0x598a9f,{'include':[{'model':db[_0x38c9('0x5c')],'as':_0x38c9('0x5f')}],'raw':!![],'transaction':_0x1d5c00})[_0x38c9('0x28')](function(_0x269ac5){_0x119ff7[_0x38c9('0x62')](_0x269ac5['get']({'plain':!![]}));});})[_0x38c9('0x28')](function(){return _0x119ff7;});});});}})['then'](function(_0x491621){return _0x491621;})[_0x38c9('0x28')](respondWithResult(_0xb34527,null))[_0x38c9('0x48')](handleError(_0xb34527,null));};exports[_0x38c9('0x63')]=function(_0x4b6937,_0x1855ea){var _0xa41920;return db[_0x38c9('0x30')][_0x38c9('0x4e')]({'where':{'id':_0x4b6937[_0x38c9('0x4a')]['id']},'attributes':['id','name']})['then'](handleEntityNotFound(_0x1855ea,null))[_0x38c9('0x28')](function(_0x3d49b8){if(_0x3d49b8){_0xa41920=_0x3d49b8;return db[_0x38c9('0x59')]['destroy']({'where':{'userProfileId':_0x4b6937[_0x38c9('0x4a')]['id'],'sectionId':_0x4b6937[_0x38c9('0x35')][_0x38c9('0x64')]}});}})['then'](function(){return _0xa41920;})[_0x38c9('0x28')](respondWithStatusCode(_0x1855ea,null))['catch'](handleError(_0x1855ea,null));};exports[_0x38c9('0x65')]=function(_0x350b28,_0x52b405){var _0x209f72=[];var _0x5ebf0b=[];return db[_0x38c9('0x59')][_0x38c9('0x46')]({'where':{'userProfileId':_0x350b28[_0x38c9('0x4a')]['id']},'raw':!![]})[_0x38c9('0x28')](function(_0x1d3223){_0x209f72=_[_0x38c9('0x41')](_0x1d3223,function(_0x255382){return _0x255382[_0x38c9('0x66')]===0x1||_[_0x38c9('0x67')]([0x3eb,0x709],_0x255382['sectionId']);});if(!_[_0x38c9('0x68')](_0x209f72)){return _[_0x38c9('0x2f')](_0x209f72,function(_0x6a0efe){return _0x6a0efe[_0x38c9('0x5d')];});}else{return;}})[_0x38c9('0x28')](function(_0x417700){if(_0x417700)_0x5ebf0b=_0x417700;if(_['includes'](_0x5ebf0b,0x64)){var _0x54bd9c=_['find'](_0x209f72,{'sectionId':0x64});return hasDefaultDashboard(_0x54bd9c)[_0x38c9('0x28')](function(_0x56afb8){return _[_0x38c9('0x2f')](_0x209f72,function(_0x3c4472){if(_0x3c4472['sectionId']===0x64){_0x3c4472[_0x38c9('0x69')]=_0x56afb8;}return _0x3c4472;});});}else{return;}})[_0x38c9('0x28')](function(_0x216756){if(_0x216756)_0x209f72=_0x216756;if(_[_0x38c9('0x67')](_0x5ebf0b,0x3eb)){var _0x91b594=_['find'](_0x209f72,{'sectionId':0x3eb});return getCustomDashboards(_0x91b594)[_0x38c9('0x28')](function(_0x5a5c11){return _[_0x38c9('0x2f')](_0x209f72,function(_0x5a2e30){if(_0x91b594[_0x38c9('0x66')]){if(_0x5a2e30[_0x38c9('0x5d')]===0x3eb){_0x5a2e30[_0x38c9('0x69')]=_0x5a5c11;}}else{if(_0x5a2e30[_0x38c9('0x5d')]===0x64){if(!_0x5a2e30[_0x38c9('0x69')]){_0x5a2e30['subsections']=[];}_0x5a2e30[_0x38c9('0x69')]=_0x5a2e30['subsections'][_0x38c9('0x6a')](_0x5a5c11);}}return _0x5a2e30;});});}else{return;}})[_0x38c9('0x28')](function(_0x89bd9c){if(_0x89bd9c)_0x209f72=_0x89bd9c;if(_[_0x38c9('0x67')](_0x5ebf0b,0x709)){var _0x136e70=_[_0x38c9('0x4e')](_0x209f72,{'sectionId':0x709});return getPlugins(_0x136e70)[_0x38c9('0x28')](function(_0x170c84){if(_0x136e70['enabled']){return _[_0x38c9('0x2f')](_0x209f72,function(_0x2b3035){if(_0x2b3035['sectionId']===0x709){_0x2b3035[_0x38c9('0x69')]=_0x170c84;}return _0x2b3035;});}else{var _0x4c6619={'sectionId':0x76c,'enabled':0x1,'subsections':_0x170c84};var _0x28ecc3=_[_0x38c9('0x2f')](_0x209f72);_0x28ecc3['push'](_0x4c6619);return _0x28ecc3;}});}else{return;}})[_0x38c9('0x28')](function(_0x3dcc5e){if(_0x3dcc5e)_0x209f72=_0x3dcc5e;return _[_0x38c9('0x41')](_0x209f72,[_0x38c9('0x66'),0x1]);})['then'](respondWithResult(_0x52b405,null))[_0x38c9('0x48')](handleError(_0x52b405,null));};function hasDefaultDashboard(_0x434e04){var _0x5e3aa1=[0x65];return new BPromise(function(_0x193d67,_0x5e8868){try{if(_0x434e04[_0x38c9('0x5b')]){_0x193d67(_0x5e3aa1);}else{return db[_0x38c9('0x5c')]['findOne']({'where':{'sectionId':_0x434e04['id']},'raw':!![]})['then'](function(_0x22313b){_0x22313b?_0x193d67(_0x5e3aa1):_0x193d67();});}}catch(_0x32991d){_0x5e8868(_0x32991d);}});}function getCustomDashboards(_0x3b96c9){var _0x19ba23=[];return new BPromise(function(_0x4b7bd6,_0x464f3d){try{if(_0x3b96c9['autoAssociation']){return db['Dashboard'][_0x38c9('0x46')]({'raw':!![]})[_0x38c9('0x28')](function(_0x40767c){_0x40767c[_0x38c9('0x6b')](function(_0x489347){_0x19ba23[_0x38c9('0x62')](_0x489347['id']+0x1869f);});_0x4b7bd6(_0x19ba23);});}else{return db['UserProfileResource'][_0x38c9('0x46')]({'where':{'sectionId':_0x3b96c9['id']},'raw':!![]})[_0x38c9('0x28')](function(_0x5d9d29){_0x5d9d29[_0x38c9('0x6b')](function(_0x27946b){_0x19ba23[_0x38c9('0x62')](_0x27946b[_0x38c9('0x6c')]+0x1869f);});_0x4b7bd6(_0x19ba23);});}}catch(_0x4cb7d0){_0x464f3d(_0x4cb7d0);}});}function getPlugins(_0x370a86){var _0x16c381=[];return new BPromise(function(_0x197fa5,_0x439c86){try{if(_0x370a86['autoAssociation']){return db[_0x38c9('0x6d')][_0x38c9('0x46')]({'raw':!![]})[_0x38c9('0x28')](function(_0x5de5fc){_0x5de5fc[_0x38c9('0x6b')](function(_0x2e23e3){_0x16c381[_0x38c9('0x62')](_0x2e23e3['id']+0x15b38);});_0x197fa5(_0x16c381);});}else{return db[_0x38c9('0x5c')][_0x38c9('0x46')]({'where':{'sectionId':_0x370a86['id']},'raw':!![]})[_0x38c9('0x28')](function(_0x3df47b){_0x3df47b['forEach'](function(_0x4c08b0){_0x16c381[_0x38c9('0x62')](_0x4c08b0['resourceId']+0x15b38);});_0x197fa5(_0x16c381);});}}catch(_0x558859){_0x439c86(_0x558859);}});}exports[_0x38c9('0x6e')]=function(_0x512926,_0x5ea58d){return db[_0x38c9('0x30')][_0x38c9('0x4e')]({'where':{'id':_0x512926[_0x38c9('0x4a')]['id']}})[_0x38c9('0x28')](handleEntityNotFound(_0x5ea58d,null))[_0x38c9('0x28')](function(_0x36a4a8){if(_0x36a4a8){return db[_0x38c9('0x55')][_0x38c9('0x56')](function(_0x27dd5d){return db['UserProfileSection'][_0x38c9('0x46')]({'where':{'userProfileId':_0x512926['params']['id']},'attributes':['id'],'raw':!![]})[_0x38c9('0x28')](function(_0x338672){if(_0x338672){return db['UserProfileSection'][_0x38c9('0x29')]({'where':{'userProfileId':_0x512926[_0x38c9('0x4a')]['id'],'id':_[_0x38c9('0x2f')](_0x338672,function(_0x236686){return _0x236686['id'];})},'transaction':_0x27dd5d});}})['then'](function(_0x2a610a){var _0x14afad=_['map'](_0x512926[_0x38c9('0x57')],function(_0x46398f){_0x46398f[_0x38c9('0x5e')]=_0x512926[_0x38c9('0x4a')]['id'];return _0x46398f;});return db['UserProfileSection'][_0x38c9('0x6f')](_0x14afad,{'raw':!![],'transaction':_0x27dd5d});})['then'](function(_0x326318){var _0x2d33bf=_[_0x38c9('0x41')](_['map'](_0x326318,function(_0x16f2c1){return _0x16f2c1[_0x38c9('0x58')]({'plain':!![]});}),{'includeAll':![]});if(_0x2d33bf){return db[_0x38c9('0x59')]['findAll']({'where':{'userProfileId':_0x512926[_0x38c9('0x4a')]['id'],'sectionId':_[_0x38c9('0x2f')](_0x2d33bf,function(_0x1d3e19){return _0x1d3e19[_0x38c9('0x5d')];})},'attributes':['id',_0x38c9('0x5d')],'raw':!![]})[_0x38c9('0x28')](function(_0x4c8ce7){var _0x454b81=_['map'](_0x512926[_0x38c9('0x57')],function(_0x4bbe49){_0x4bbe49[_0x38c9('0x5e')]=_0x512926[_0x38c9('0x4a')]['id'];return _0x4bbe49;});return db[_0x38c9('0x5c')]['bulkCreate'](_0x454b81,{'raw':!![],'transaction':_0x27dd5d});});}})[_0x38c9('0x48')](handleError(_0x5ea58d,null));});}})['then'](function(_0x2d7cd7){var _0x12cd0a=_[_0x38c9('0x2f')](_0x2d7cd7,function(_0x2839eb){return _0x2839eb[_0x38c9('0x58')]({'plain':!![]});});})[_0x38c9('0x28')](respondWithResult(_0x5ea58d,null))[_0x38c9('0x48')](handleError(_0x5ea58d,null));};exports['removeResources']=function(_0x268bf9,_0x19e802,_0x130e5c){return db['UserProfile']['find']({'where':{'id':_0x268bf9[_0x38c9('0x4a')]['id']}})['then'](handleEntityNotFound(_0x19e802,null))[_0x38c9('0x28')](function(_0x1d37ac){if(_0x1d37ac){return _0x1d37ac[_0x38c9('0x70')](_0x268bf9[_0x38c9('0x35')][_0x38c9('0x64')]);}})[_0x38c9('0x28')](respondWithStatusCode(_0x19e802,null))[_0x38c9('0x48')](handleError(_0x19e802,null));};exports[_0x38c9('0x71')]=function(_0x151c4c,_0x309c88){var _0x30edd6={};if(!_0x151c4c[_0x38c9('0x35')][_0x38c9('0x72')])throw new Error(_0x38c9('0x73'));if(!_0x151c4c[_0x38c9('0x35')]['hasOwnProperty'](_0x38c9('0x3d'))){_0x30edd6[_0x38c9('0x21')]=qs[_0x38c9('0x21')](_0x151c4c[_0x38c9('0x35')][_0x38c9('0x21')]);_0x30edd6[_0x38c9('0x20')]=qs[_0x38c9('0x20')](_0x151c4c[_0x38c9('0x35')][_0x38c9('0x20')]);}return db[_0x38c9('0x30')][_0x38c9('0x4e')]({'where':{'id':_0x151c4c['params']['id']}})['then'](function(_0x45605f){if(!_0x45605f)throw new Error(_0x38c9('0x74')+_0x151c4c[_0x38c9('0x4a')]['id']);return db[_0x38c9('0x30')]['getResources'](_0x151c4c);})[_0x38c9('0x28')](respondWithFilteredResult(_0x309c88,_0x30edd6))[_0x38c9('0x48')](handleError(_0x309c88,null));};
\ No newline at end of file