Built motion from commit 351e7f9c.|2.6.31
[motion2.git] / server / api / userProfile / userProfile.controller.js
index 09d1a39..0863091 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x612f=['includeAll','create','params','find','get','omit','updatedAt','crudPermissions','body','sequelize','transaction','each','autoAssociation','UserProfileResource','createdAt','userProfileId','Resources','UserProfileSection','describe','addSections','sectionId','push','removeSections','ids','enabled','includes','isEmpty','subsections','concat','findOne','Dashboard','forEach','resourceId','bulkCreate','removeResources','getResources','section','No\x20User\x20Profile\x20found\x20for\x20id\x20','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','sox','ejs','fs-extra','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','../../mysqldb','redis','localhost','./userProfile.socket','register','sendStatus','status','end','offset','undefined','count','limit','Content-Range','json','reject','update','destroy','error','stack','name','send','index','map','UserProfile','fieldName','type','key','model','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filters','filter','merge','VIRTUAL','options','then','include','findAll','catch','keys','rawAttributes'];(function(_0x495123,_0x2bf158){var _0x39e1ee=function(_0x226778){while(--_0x226778){_0x495123['push'](_0x495123['shift']());}};_0x39e1ee(++_0x2bf158);}(_0x612f,0x8f));var _0xf612=function(_0x250071,_0x301941){_0x250071=_0x250071-0x0;var _0x34e574=_0x612f[_0x250071];return _0x34e574;};'use strict';var emlformat=require(_0xf612('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf612('0x1'));var rp=require(_0xf612('0x2'));var moment=require('moment');var BPromise=require(_0xf612('0x3'));var Mustache=require(_0xf612('0x4'));var util=require(_0xf612('0x5'));var path=require('path');var sox=require(_0xf612('0x6'));var csv=require('to-csv');var ejs=require(_0xf612('0x7'));var fs=require('fs');var fs_extra=require(_0xf612('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xf612('0x9'));var jsforce=require(_0xf612('0xa'));var deskjs=require(_0xf612('0xb'));var toCsv=require(_0xf612('0xc'));var querystring=require('querystring');var Papa=require(_0xf612('0xd'));var Redis=require(_0xf612('0xe'));var authService=require(_0xf612('0xf'));var qs=require(_0xf612('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xf612('0x11'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xf612('0x12'))['db'];config[_0xf612('0x13')]=_['defaults'](config[_0xf612('0x13')],{'host':_0xf612('0x14'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xf612('0x15'))[_0xf612('0x16')](socket);function respondWithStatusCode(_0x411d8f,_0x398079){_0x398079=_0x398079||0xcc;return function(_0x3981dd){if(_0x3981dd){return _0x411d8f[_0xf612('0x17')](_0x398079);}return _0x411d8f[_0xf612('0x18')](_0x398079)[_0xf612('0x19')]();};}function respondWithResult(_0x1d22a4,_0x226efa){_0x226efa=_0x226efa||0xc8;return function(_0x3bdea9){if(_0x3bdea9){return _0x1d22a4['status'](_0x226efa)['json'](_0x3bdea9);}};}function respondWithFilteredResult(_0x5d91d1,_0xf341d4){return function(_0x186e78){if(_0x186e78){var _0x15bbec=typeof _0xf341d4[_0xf612('0x1a')]===_0xf612('0x1b')&&typeof _0xf341d4['limit']===_0xf612('0x1b');var _0x10580e=_0x186e78['count'];var _0x2b1c02=_0x15bbec?0x0:_0xf341d4['offset'];var _0xfcf17f=_0x15bbec?_0x186e78[_0xf612('0x1c')]:_0xf341d4[_0xf612('0x1a')]+_0xf341d4[_0xf612('0x1d')];var _0x2da965;if(_0xfcf17f>=_0x10580e){_0xfcf17f=_0x10580e;_0x2da965=0xc8;}else{_0x2da965=0xce;}_0x5d91d1[_0xf612('0x18')](_0x2da965);return _0x5d91d1['set'](_0xf612('0x1e'),_0x2b1c02+'-'+_0xfcf17f+'/'+_0x10580e)[_0xf612('0x1f')](_0x186e78);}return null;};}function patchUpdates(_0x957822){return function(_0x457b79){try{jsonpatch['apply'](_0x457b79,_0x957822,!![]);}catch(_0x5db170){return BPromise[_0xf612('0x20')](_0x5db170);}return _0x457b79['save']();};}function saveUpdates(_0x2a28ab,_0x17d39e){return function(_0x57e7ca){if(_0x57e7ca){return _0x57e7ca[_0xf612('0x21')](_0x2a28ab)['then'](function(_0x27a090){return _0x27a090;});}return null;};}function removeEntity(_0x3923af,_0x261d60){return function(_0x1b78fc){if(_0x1b78fc){return _0x1b78fc[_0xf612('0x22')]()['then'](function(){_0x3923af[_0xf612('0x18')](0xcc)[_0xf612('0x19')]();});}};}function handleEntityNotFound(_0x22d561,_0x38ef36){return function(_0x78b39e){if(!_0x78b39e){_0x22d561['sendStatus'](0x194);}return _0x78b39e;};}function handleError(_0x4836ed,_0x58275f){_0x58275f=_0x58275f||0x1f4;return function(_0x20bf28){logger[_0xf612('0x23')](_0x20bf28[_0xf612('0x24')]);if(_0x20bf28[_0xf612('0x25')]){delete _0x20bf28['name'];}_0x4836ed[_0xf612('0x18')](_0x58275f)[_0xf612('0x26')](_0x20bf28);};}exports[_0xf612('0x27')]=function(_0x340aeb,_0x3daee8){var _0x19ba15={},_0x483795={},_0x13942e={'count':0x0,'rows':[]};var _0x595457=_[_0xf612('0x28')](db[_0xf612('0x29')]['rawAttributes'],function(_0x615b1d){return{'name':_0x615b1d[_0xf612('0x2a')],'type':_0x615b1d[_0xf612('0x2b')][_0xf612('0x2c')]};});_0x483795[_0xf612('0x2d')]=_[_0xf612('0x28')](_0x595457,'name');_0x483795['query']=_['keys'](_0x340aeb[_0xf612('0x2e')]);_0x483795['filters']=_[_0xf612('0x2f')](_0x483795[_0xf612('0x2d')],_0x483795['query']);_0x19ba15[_0xf612('0x30')]=_[_0xf612('0x2f')](_0x483795[_0xf612('0x2d')],qs[_0xf612('0x31')](_0x340aeb[_0xf612('0x2e')][_0xf612('0x31')]));_0x19ba15[_0xf612('0x30')]=_0x19ba15[_0xf612('0x30')][_0xf612('0x32')]?_0x19ba15['attributes']:_0x483795['model'];if(!_0x340aeb[_0xf612('0x2e')][_0xf612('0x33')](_0xf612('0x34'))){_0x19ba15[_0xf612('0x1d')]=qs['limit'](_0x340aeb[_0xf612('0x2e')][_0xf612('0x1d')]);_0x19ba15[_0xf612('0x1a')]=qs['offset'](_0x340aeb['query'][_0xf612('0x1a')]);}_0x19ba15['order']=qs[_0xf612('0x35')](_0x340aeb[_0xf612('0x2e')][_0xf612('0x35')]);_0x19ba15[_0xf612('0x36')]=qs['filters'](_[_0xf612('0x37')](_0x340aeb[_0xf612('0x2e')],_0x483795[_0xf612('0x38')]),_0x595457);if(_0x340aeb[_0xf612('0x2e')][_0xf612('0x39')]){_0x19ba15[_0xf612('0x36')]=_[_0xf612('0x3a')](_0x19ba15[_0xf612('0x36')],{'$or':_[_0xf612('0x28')](_0x595457,function(_0x307a00){if(_0x307a00['type']!==_0xf612('0x3b')){var _0x192f28={};_0x192f28[_0x307a00[_0xf612('0x25')]]={'$like':'%'+_0x340aeb[_0xf612('0x2e')][_0xf612('0x39')]+'%'};return _0x192f28;}})});}_0x19ba15=_['merge']({},_0x19ba15,_0x340aeb[_0xf612('0x3c')]);var _0x11282c={'where':_0x19ba15[_0xf612('0x36')]};return db[_0xf612('0x29')][_0xf612('0x1c')](_0x11282c)[_0xf612('0x3d')](function(_0x11071d){_0x13942e['count']=_0x11071d;if(_0x340aeb[_0xf612('0x2e')]['includeAll']){_0x19ba15[_0xf612('0x3e')]=[{'all':!![]}];}return db[_0xf612('0x29')][_0xf612('0x3f')](_0x19ba15);})[_0xf612('0x3d')](function(_0x2f9b5d){_0x13942e['rows']=_0x2f9b5d;return _0x13942e;})['then'](respondWithFilteredResult(_0x3daee8,_0x19ba15))[_0xf612('0x40')](handleError(_0x3daee8,null));};exports['show']=function(_0x478e30,_0x33ae3e){var _0x32aab0={'raw':![],'where':{'id':_0x478e30['params']['id']}},_0xaf020a={};_0xaf020a['model']=_[_0xf612('0x41')](db[_0xf612('0x29')][_0xf612('0x42')]);_0xaf020a[_0xf612('0x2e')]=_[_0xf612('0x41')](_0x478e30[_0xf612('0x2e')]);_0xaf020a[_0xf612('0x38')]=_[_0xf612('0x2f')](_0xaf020a[_0xf612('0x2d')],_0xaf020a[_0xf612('0x2e')]);_0x32aab0['attributes']=_[_0xf612('0x2f')](_0xaf020a[_0xf612('0x2d')],qs['fields'](_0x478e30[_0xf612('0x2e')][_0xf612('0x31')]));_0x32aab0[_0xf612('0x30')]=_0x32aab0[_0xf612('0x30')][_0xf612('0x32')]?_0x32aab0[_0xf612('0x30')]:_0xaf020a[_0xf612('0x2d')];if(_0x478e30['query'][_0xf612('0x43')]){_0x32aab0[_0xf612('0x3e')]=[{'all':!![]}];}_0x32aab0=_[_0xf612('0x3a')]({},_0x32aab0,_0x478e30[_0xf612('0x3c')]);return db[_0xf612('0x29')]['find'](_0x32aab0)['then'](handleEntityNotFound(_0x33ae3e,null))[_0xf612('0x3d')](respondWithResult(_0x33ae3e,null))[_0xf612('0x40')](handleError(_0x33ae3e,null));};exports[_0xf612('0x44')]=function(_0x108d62,_0x5a27e0){return db[_0xf612('0x29')][_0xf612('0x44')](_0x108d62['body'],{})['then'](respondWithResult(_0x5a27e0,0xc9))[_0xf612('0x40')](handleError(_0x5a27e0,null));};exports['clone']=function(_0x319ccf,_0x1d38fb){var _0x38a53f={'where':{'id':_0x319ccf[_0xf612('0x45')]['id']}},_0x37dd7a={};_0x37dd7a[_0xf612('0x2d')]=_[_0xf612('0x41')](db[_0xf612('0x29')]['rawAttributes']);_0x38a53f['attributes']=_[_0xf612('0x2f')](_0x37dd7a[_0xf612('0x2d')],qs[_0xf612('0x31')](_0x319ccf[_0xf612('0x2e')][_0xf612('0x31')]));_0x38a53f[_0xf612('0x30')]=_0x38a53f[_0xf612('0x30')][_0xf612('0x32')]?_0x38a53f['attributes']:_0x37dd7a[_0xf612('0x2d')];if(_0x319ccf[_0xf612('0x2e')][_0xf612('0x43')]){_0x38a53f[_0xf612('0x3e')]=[{'all':!![]}];}_0x38a53f=_[_0xf612('0x3a')]({},_0x38a53f,_0x319ccf['options']);return db[_0xf612('0x29')][_0xf612('0x46')](_0x38a53f)[_0xf612('0x3d')](handleEntityNotFound(_0x1d38fb,null))[_0xf612('0x3d')](function(_0x1ba7e2){if(_0x1ba7e2){var _0x5eff77=_0x1ba7e2[_0xf612('0x47')]({'plain':!![]});_0x5eff77=qs[_0xf612('0x48')](_0x5eff77,['id','createdAt',_0xf612('0x49'),_0xf612('0x4a')]);_0x319ccf[_0xf612('0x4b')]=_[_0xf612('0x48')](_0x319ccf[_0xf612('0x4b')],['id','createdAt',_0xf612('0x49')]);return db[_0xf612('0x4c')][_0xf612('0x4d')](function(_0x1e6978){return db[_0xf612('0x29')][_0xf612('0x44')](_[_0xf612('0x3a')](_0x5eff77,_0x319ccf['body']),{'include':_0x319ccf[_0xf612('0x2e')][_0xf612('0x43')]?[{'all':!![]}]:undefined,'transaction':_0x1e6978})['then'](function(_0x2ebf3b){var _0x4fe9f6=_0x2ebf3b[_0xf612('0x47')]({'plain':!![]});return db['UserProfileSection'][_0xf612('0x3f')]({'where':{'userProfileId':_0x319ccf['params']['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x476562){if(_0x476562){return BPromise[_0xf612('0x4e')](_0x476562,function(_0x249e76){return new BPromise(function(_0x213839,_0x54ee52){if(_0x249e76[_0xf612('0x4f')]===null||_0x249e76[_0xf612('0x4f')]===0x1)_0x213839(null);return db[_0xf612('0x50')][_0xf612('0x3f')]({'where':{'sectionId':_0x249e76['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x54946f){var _0x557805=_[_0xf612('0x28')](_0x54946f,function(_0x197c75){return qs[_0xf612('0x48')](_0x197c75,['id','createdAt',_0xf612('0x49'),'sectionId']);});_0x213839(_0x557805);})[_0xf612('0x40')](function(_0xdd9d90){_0x54ee52(_0xdd9d90);});})[_0xf612('0x3d')](function(_0xbb059d){var _0x46ba11=qs['omit'](_0x249e76,['id',_0xf612('0x51'),_0xf612('0x49')]);_0x46ba11[_0xf612('0x52')]=_0x4fe9f6['id'];if(_0xbb059d)_0x46ba11[_0xf612('0x53')]=_0xbb059d;return _0x46ba11;})[_0xf612('0x3d')](function(_0x44fcde){return db[_0xf612('0x54')]['create'](_0x44fcde,{'include':[{'model':db[_0xf612('0x50')],'as':_0xf612('0x53')}],'raw':!![],'transaction':_0x1e6978});});})[_0xf612('0x3d')](function(){return _0x4fe9f6;});}});});});}})[_0xf612('0x3d')](respondWithResult(_0x1d38fb,0xc9))['catch'](handleError(_0x1d38fb,null));};exports[_0xf612('0x21')]=function(_0x44d7b7,_0x438206){if(_0x44d7b7['body']['id']){delete _0x44d7b7['body']['id'];}return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x44d7b7[_0xf612('0x45')]['id']}})[_0xf612('0x3d')](handleEntityNotFound(_0x438206,null))[_0xf612('0x3d')](saveUpdates(_0x44d7b7[_0xf612('0x4b')],null))[_0xf612('0x3d')](respondWithResult(_0x438206,null))[_0xf612('0x40')](handleError(_0x438206,null));};exports['destroy']=function(_0x132f44,_0xb6064e){return db['UserProfile'][_0xf612('0x46')]({'where':{'id':_0x132f44['params']['id']}})[_0xf612('0x3d')](handleEntityNotFound(_0xb6064e,null))[_0xf612('0x3d')](removeEntity(_0xb6064e,null))[_0xf612('0x40')](handleError(_0xb6064e,null));};exports[_0xf612('0x55')]=function(_0x8c8a23,_0x5ae4bc){return db[_0xf612('0x29')][_0xf612('0x55')]()[_0xf612('0x3d')](respondWithResult(_0x5ae4bc,null))[_0xf612('0x40')](handleError(_0x5ae4bc,null));};exports[_0xf612('0x56')]=function(_0x5f31d4,_0x4ff065){var _0x295555=_0x5f31d4[_0xf612('0x4b')];return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x5f31d4[_0xf612('0x45')]['id']}})[_0xf612('0x3d')](handleEntityNotFound(_0x4ff065,null))[_0xf612('0x3d')](function(_0x3dec8d){if(_0x3dec8d){return db[_0xf612('0x4c')][_0xf612('0x4d')](function(_0x4613ea){return db[_0xf612('0x54')]['destroy']({'where':{'userProfileId':_0x5f31d4[_0xf612('0x45')]['id'],'sectionId':_[_0xf612('0x28')](_0x295555,function(_0x3225b6){return _0x3225b6[_0xf612('0x57')];})},'transaction':_0x4613ea})[_0xf612('0x3d')](function(){var _0x1458ac=_[_0xf612('0x28')](_0x295555,function(_0x1112b7){_0x1112b7[_0xf612('0x52')]=_0x5f31d4[_0xf612('0x45')]['id'];return _0x1112b7;});var _0x3e8abe=[];return BPromise[_0xf612('0x4e')](_0x1458ac,function(_0x47e057){return db[_0xf612('0x54')][_0xf612('0x44')](_0x47e057,{'include':[{'model':db[_0xf612('0x50')],'as':_0xf612('0x53')}],'raw':!![],'transaction':_0x4613ea})[_0xf612('0x3d')](function(_0x3e6b53){_0x3e8abe[_0xf612('0x58')](_0x3e6b53['get']({'plain':!![]}));});})[_0xf612('0x3d')](function(){return _0x3e8abe;});});});}})[_0xf612('0x3d')](function(_0x248847){return _0x248847;})[_0xf612('0x3d')](respondWithResult(_0x4ff065,null))[_0xf612('0x40')](handleError(_0x4ff065,null));};exports[_0xf612('0x59')]=function(_0x3ba566,_0x503f9e){var _0x3ee460;return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x3ba566[_0xf612('0x45')]['id']},'attributes':['id',_0xf612('0x25')]})['then'](handleEntityNotFound(_0x503f9e,null))[_0xf612('0x3d')](function(_0x4a8a00){if(_0x4a8a00){_0x3ee460=_0x4a8a00;return db[_0xf612('0x54')][_0xf612('0x22')]({'where':{'userProfileId':_0x3ba566[_0xf612('0x45')]['id'],'sectionId':_0x3ba566[_0xf612('0x2e')][_0xf612('0x5a')]}});}})[_0xf612('0x3d')](function(){return _0x3ee460;})['then'](respondWithStatusCode(_0x503f9e,null))[_0xf612('0x40')](handleError(_0x503f9e,null));};exports['getSections']=function(_0x22ab65,_0x54ea91){var _0x19e916=[];var _0x28a407=[];return db['UserProfileSection'][_0xf612('0x3f')]({'where':{'userProfileId':_0x22ab65[_0xf612('0x45')]['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x5a066c){_0x19e916=_[_0xf612('0x39')](_0x5a066c,function(_0x10f57f){return _0x10f57f[_0xf612('0x5b')]===0x1||_[_0xf612('0x5c')]([0x3eb,0x709],_0x10f57f[_0xf612('0x57')]);});if(!_[_0xf612('0x5d')](_0x19e916)){return _[_0xf612('0x28')](_0x19e916,function(_0x52b6e8){return _0x52b6e8[_0xf612('0x57')];});}else{return;}})[_0xf612('0x3d')](function(_0x4ff04a){if(_0x4ff04a)_0x28a407=_0x4ff04a;if(_[_0xf612('0x5c')](_0x28a407,0x64)){var _0x1b5c85=_[_0xf612('0x46')](_0x19e916,{'sectionId':0x64});return hasDefaultDashboard(_0x1b5c85)[_0xf612('0x3d')](function(_0x4bbc3b){return _[_0xf612('0x28')](_0x19e916,function(_0x1be4f3){if(_0x1be4f3[_0xf612('0x57')]===0x64){_0x1be4f3[_0xf612('0x5e')]=_0x4bbc3b;}return _0x1be4f3;});});}else{return;}})[_0xf612('0x3d')](function(_0x557dda){if(_0x557dda)_0x19e916=_0x557dda;if(_[_0xf612('0x5c')](_0x28a407,0x3eb)){var _0x2726ac=_[_0xf612('0x46')](_0x19e916,{'sectionId':0x3eb});return getCustomDashboards(_0x2726ac)['then'](function(_0x1afecc){return _['map'](_0x19e916,function(_0x55e96b){if(_0x2726ac[_0xf612('0x5b')]){if(_0x55e96b[_0xf612('0x57')]===0x3eb){_0x55e96b['subsections']=_0x1afecc;}}else{if(_0x55e96b['sectionId']===0x64){if(!_0x55e96b[_0xf612('0x5e')]){_0x55e96b[_0xf612('0x5e')]=[];}_0x55e96b[_0xf612('0x5e')]=_0x55e96b[_0xf612('0x5e')][_0xf612('0x5f')](_0x1afecc);}}return _0x55e96b;});});}else{return;}})['then'](function(_0xba7a0d){if(_0xba7a0d)_0x19e916=_0xba7a0d;if(_['includes'](_0x28a407,0x709)){var _0x11e639=_[_0xf612('0x46')](_0x19e916,{'sectionId':0x709});return getPlugins(_0x11e639)[_0xf612('0x3d')](function(_0x5803ea){if(_0x11e639[_0xf612('0x5b')]){return _[_0xf612('0x28')](_0x19e916,function(_0x16b05b){if(_0x16b05b[_0xf612('0x57')]===0x709){_0x16b05b[_0xf612('0x5e')]=_0x5803ea;}return _0x16b05b;});}else{var _0x3b537d={'sectionId':0x76c,'enabled':0x1,'subsections':_0x5803ea};var _0x575199=_['map'](_0x19e916);_0x575199[_0xf612('0x58')](_0x3b537d);return _0x575199;}});}else{return;}})[_0xf612('0x3d')](function(_0xf3b91c){if(_0xf3b91c)_0x19e916=_0xf3b91c;return _['filter'](_0x19e916,['enabled',0x1]);})[_0xf612('0x3d')](respondWithResult(_0x54ea91,null))[_0xf612('0x40')](handleError(_0x54ea91,null));};function hasDefaultDashboard(_0x1dcae9){var _0x2b76b6=[0x65];return new BPromise(function(_0x3278b3,_0x1e5982){try{if(_0x1dcae9[_0xf612('0x4f')]){_0x3278b3(_0x2b76b6);}else{return db[_0xf612('0x50')][_0xf612('0x60')]({'where':{'sectionId':_0x1dcae9['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x45e0f2){_0x45e0f2?_0x3278b3(_0x2b76b6):_0x3278b3();});}}catch(_0xc03829){_0x1e5982(_0xc03829);}});}function getCustomDashboards(_0x36abd7){var _0x111501=[];return new BPromise(function(_0xdaa63f,_0x339be7){try{if(_0x36abd7[_0xf612('0x4f')]){return db[_0xf612('0x61')][_0xf612('0x3f')]({'raw':!![]})['then'](function(_0x38515a){_0x38515a[_0xf612('0x62')](function(_0x56c789){_0x111501[_0xf612('0x58')](_0x56c789['id']+0x1869f);});_0xdaa63f(_0x111501);});}else{return db['UserProfileResource'][_0xf612('0x3f')]({'where':{'sectionId':_0x36abd7['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x3faf89){_0x3faf89[_0xf612('0x62')](function(_0x1a0618){_0x111501['push'](_0x1a0618[_0xf612('0x63')]+0x1869f);});_0xdaa63f(_0x111501);});}}catch(_0x2df98d){_0x339be7(_0x2df98d);}});}function getPlugins(_0x44893b){var _0x4b36ca=[];return new BPromise(function(_0xbc3edf,_0x372f4c){try{if(_0x44893b['autoAssociation']){return db['Plugin'][_0xf612('0x3f')]({'raw':!![]})['then'](function(_0x25a2b8){_0x25a2b8[_0xf612('0x62')](function(_0x287a0f){_0x4b36ca[_0xf612('0x58')](_0x287a0f['id']+0x15b38);});_0xbc3edf(_0x4b36ca);});}else{return db[_0xf612('0x50')]['findAll']({'where':{'sectionId':_0x44893b['id']},'raw':!![]})[_0xf612('0x3d')](function(_0x7cc9f5){_0x7cc9f5[_0xf612('0x62')](function(_0x3146ea){_0x4b36ca[_0xf612('0x58')](_0x3146ea[_0xf612('0x63')]+0x15b38);});_0xbc3edf(_0x4b36ca);});}}catch(_0x389310){_0x372f4c(_0x389310);}});}exports['addResources']=function(_0x19e019,_0x5793ab){return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x19e019[_0xf612('0x45')]['id']}})['then'](handleEntityNotFound(_0x5793ab,null))[_0xf612('0x3d')](function(_0x368161){if(_0x368161){return db[_0xf612('0x4c')]['transaction'](function(_0x5ae0f6){return db[_0xf612('0x54')][_0xf612('0x3f')]({'where':{'userProfileId':_0x19e019['params']['id']},'attributes':['id'],'raw':!![]})['then'](function(_0x2279c9){if(_0x2279c9){return db[_0xf612('0x54')][_0xf612('0x22')]({'where':{'userProfileId':_0x19e019[_0xf612('0x45')]['id'],'id':_[_0xf612('0x28')](_0x2279c9,function(_0x1f9dfa){return _0x1f9dfa['id'];})},'transaction':_0x5ae0f6});}})[_0xf612('0x3d')](function(_0x116544){var _0x19f696=_[_0xf612('0x28')](_0x19e019['body'],function(_0x1ca111){_0x1ca111[_0xf612('0x52')]=_0x19e019['params']['id'];return _0x1ca111;});return db[_0xf612('0x54')]['bulkCreate'](_0x19f696,{'raw':!![],'transaction':_0x5ae0f6});})['then'](function(_0x1f4013){var _0x2b2d2f=_[_0xf612('0x39')](_['map'](_0x1f4013,function(_0x271875){return _0x271875[_0xf612('0x47')]({'plain':!![]});}),{'includeAll':![]});if(_0x2b2d2f){return db[_0xf612('0x54')][_0xf612('0x3f')]({'where':{'userProfileId':_0x19e019[_0xf612('0x45')]['id'],'sectionId':_[_0xf612('0x28')](_0x2b2d2f,function(_0xbefc03){return _0xbefc03[_0xf612('0x57')];})},'attributes':['id',_0xf612('0x57')],'raw':!![]})[_0xf612('0x3d')](function(_0x4bf6e6){var _0xa35dd1=_[_0xf612('0x28')](_0x19e019[_0xf612('0x4b')],function(_0x2898f9){_0x2898f9['userProfileId']=_0x19e019['params']['id'];return _0x2898f9;});return db[_0xf612('0x50')][_0xf612('0x64')](_0xa35dd1,{'raw':!![],'transaction':_0x5ae0f6});});}})['catch'](handleError(_0x5793ab,null));});}})[_0xf612('0x3d')](function(_0x4a0f3a){var _0x4ef56c=_[_0xf612('0x28')](_0x4a0f3a,function(_0x22b6df){return _0x22b6df[_0xf612('0x47')]({'plain':!![]});});})[_0xf612('0x3d')](respondWithResult(_0x5793ab,null))[_0xf612('0x40')](handleError(_0x5793ab,null));};exports[_0xf612('0x65')]=function(_0x2ab648,_0x586ce6,_0x40a0f3){return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x2ab648['params']['id']}})[_0xf612('0x3d')](handleEntityNotFound(_0x586ce6,null))[_0xf612('0x3d')](function(_0x32f3fe){if(_0x32f3fe){return _0x32f3fe[_0xf612('0x65')](_0x2ab648[_0xf612('0x2e')][_0xf612('0x5a')]);}})[_0xf612('0x3d')](respondWithStatusCode(_0x586ce6,null))[_0xf612('0x40')](handleError(_0x586ce6,null));};exports[_0xf612('0x66')]=function(_0x52f861,_0x40bdd5){var _0x5420b8={};if(!_0x52f861[_0xf612('0x2e')][_0xf612('0x67')])throw new Error('Missing\x20section\x20parameter');if(!_0x52f861[_0xf612('0x2e')]['hasOwnProperty'](_0xf612('0x34'))){_0x5420b8[_0xf612('0x1d')]=qs[_0xf612('0x1d')](_0x52f861[_0xf612('0x2e')]['limit']);_0x5420b8['offset']=qs['offset'](_0x52f861[_0xf612('0x2e')][_0xf612('0x1a')]);}return db[_0xf612('0x29')][_0xf612('0x46')]({'where':{'id':_0x52f861[_0xf612('0x45')]['id']}})[_0xf612('0x3d')](function(_0x25c78c){if(!_0x25c78c)throw new Error(_0xf612('0x68')+_0x52f861['params']['id']);return db['UserProfile']['getResources'](_0x52f861);})[_0xf612('0x3d')](respondWithFilteredResult(_0x40bdd5,_0x5420b8))[_0xf612('0x40')](handleError(_0x40bdd5,null));};
\ No newline at end of file
+var _0x6021=['include','findAll','catch','show','params','includeAll','find','create','body','clone','length','get','createdAt','updatedAt','omit','UserProfileSection','autoAssociation','userProfileId','Resources','UserProfileResource','describe','addSections','transaction','sectionId','each','push','ids','getSections','enabled','includes','isEmpty','subsections','findOne','Dashboard','forEach','resourceId','Plugin','addResources','sequelize','bulkCreate','removeResources','getResources','section','No\x20User\x20Profile\x20found\x20for\x20id\x20','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./userProfile.socket','register','sendStatus','status','end','undefined','count','offset','limit','set','Content-Range','json','apply','reject','update','destroy','error','name','send','index','map','UserProfile','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','pick','where','merge','VIRTUAL','filter','options','then'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x6021,0x18e));var _0x1602=function(_0x6c5a85,_0x1ab31a){_0x6c5a85=_0x6c5a85-0x0;var _0x328686=_0x6021[_0x6c5a85];return _0x328686;};'use strict';var emlformat=require(_0x1602('0x0'));var rimraf=require(_0x1602('0x1'));var zipdir=require(_0x1602('0x2'));var jsonpatch=require(_0x1602('0x3'));var rp=require('request-promise');var moment=require(_0x1602('0x4'));var BPromise=require(_0x1602('0x5'));var Mustache=require(_0x1602('0x6'));var util=require('util');var path=require(_0x1602('0x7'));var sox=require(_0x1602('0x8'));var csv=require(_0x1602('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x1602('0xa'));var _=require(_0x1602('0xb'));var squel=require(_0x1602('0xc'));var crypto=require(_0x1602('0xd'));var jsforce=require(_0x1602('0xe'));var deskjs=require(_0x1602('0xf'));var toCsv=require('to-csv');var querystring=require(_0x1602('0x10'));var Papa=require(_0x1602('0x11'));var Redis=require(_0x1602('0x12'));var authService=require(_0x1602('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x1602('0x14'));var logger=require(_0x1602('0x15'))(_0x1602('0x16'));var utils=require(_0x1602('0x17'));var config=require(_0x1602('0x18'));var licenseUtil=require(_0x1602('0x19'));var db=require(_0x1602('0x1a'))['db'];config[_0x1602('0x1b')]=_[_0x1602('0x1c')](config[_0x1602('0x1b')],{'host':_0x1602('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x1602('0x1e'))[_0x1602('0x1f')](socket);function respondWithStatusCode(_0x16ba1b,_0x4b60f2){_0x4b60f2=_0x4b60f2||0xcc;return function(_0x4f0616){if(_0x4f0616){return _0x16ba1b[_0x1602('0x20')](_0x4b60f2);}return _0x16ba1b[_0x1602('0x21')](_0x4b60f2)[_0x1602('0x22')]();};}function respondWithResult(_0xd7e230,_0x2eef8b){_0x2eef8b=_0x2eef8b||0xc8;return function(_0x307c53){if(_0x307c53){return _0xd7e230[_0x1602('0x21')](_0x2eef8b)['json'](_0x307c53);}};}function respondWithFilteredResult(_0x1d616f,_0x25e832){return function(_0x49aa5e){if(_0x49aa5e){var _0x5e28db=typeof _0x25e832['offset']===_0x1602('0x23')&&typeof _0x25e832['limit']===_0x1602('0x23');var _0x22254c=_0x49aa5e[_0x1602('0x24')];var _0x3033b8=_0x5e28db?0x0:_0x25e832[_0x1602('0x25')];var _0x3b7208=_0x5e28db?_0x49aa5e[_0x1602('0x24')]:_0x25e832[_0x1602('0x25')]+_0x25e832[_0x1602('0x26')];var _0x2df0e4;if(_0x3b7208>=_0x22254c){_0x3b7208=_0x22254c;_0x2df0e4=0xc8;}else{_0x2df0e4=0xce;}_0x1d616f[_0x1602('0x21')](_0x2df0e4);return _0x1d616f[_0x1602('0x27')](_0x1602('0x28'),_0x3033b8+'-'+_0x3b7208+'/'+_0x22254c)[_0x1602('0x29')](_0x49aa5e);}return null;};}function patchUpdates(_0x3f7a61){return function(_0x56682d){try{jsonpatch[_0x1602('0x2a')](_0x56682d,_0x3f7a61,!![]);}catch(_0x48fee3){return BPromise[_0x1602('0x2b')](_0x48fee3);}return _0x56682d['save']();};}function saveUpdates(_0x1e82b1,_0x27ac3e){return function(_0x4d1511){if(_0x4d1511){return _0x4d1511[_0x1602('0x2c')](_0x1e82b1)['then'](function(_0x86e712){return _0x86e712;});}return null;};}function removeEntity(_0x38e79f,_0x4a7865){return function(_0x84ce6a){if(_0x84ce6a){return _0x84ce6a[_0x1602('0x2d')]()['then'](function(){_0x38e79f[_0x1602('0x21')](0xcc)[_0x1602('0x22')]();});}};}function handleEntityNotFound(_0x2ccbbb,_0x42d3f0){return function(_0x515a04){if(!_0x515a04){_0x2ccbbb[_0x1602('0x20')](0x194);}return _0x515a04;};}function handleError(_0x581468,_0xc57864){_0xc57864=_0xc57864||0x1f4;return function(_0x18be3d){logger[_0x1602('0x2e')](_0x18be3d['stack']);if(_0x18be3d[_0x1602('0x2f')]){delete _0x18be3d[_0x1602('0x2f')];}_0x581468[_0x1602('0x21')](_0xc57864)[_0x1602('0x30')](_0x18be3d);};}exports[_0x1602('0x31')]=function(_0x532fd9,_0x4f3a3b){var _0x591f4a={},_0x585f09={},_0x53019f={'count':0x0,'rows':[]};var _0x30032f=_[_0x1602('0x32')](db[_0x1602('0x33')][_0x1602('0x34')],function(_0x42311b){return{'name':_0x42311b[_0x1602('0x35')],'type':_0x42311b[_0x1602('0x36')][_0x1602('0x37')]};});_0x585f09[_0x1602('0x38')]=_['map'](_0x30032f,_0x1602('0x2f'));_0x585f09[_0x1602('0x39')]=_[_0x1602('0x3a')](_0x532fd9['query']);_0x585f09[_0x1602('0x3b')]=_['intersection'](_0x585f09[_0x1602('0x38')],_0x585f09[_0x1602('0x39')]);_0x591f4a['attributes']=_[_0x1602('0x3c')](_0x585f09[_0x1602('0x38')],qs[_0x1602('0x3d')](_0x532fd9[_0x1602('0x39')][_0x1602('0x3d')]));_0x591f4a[_0x1602('0x3e')]=_0x591f4a['attributes']['length']?_0x591f4a[_0x1602('0x3e')]:_0x585f09[_0x1602('0x38')];if(!_0x532fd9['query'][_0x1602('0x3f')](_0x1602('0x40'))){_0x591f4a['limit']=qs[_0x1602('0x26')](_0x532fd9[_0x1602('0x39')]['limit']);_0x591f4a[_0x1602('0x25')]=qs[_0x1602('0x25')](_0x532fd9[_0x1602('0x39')][_0x1602('0x25')]);}_0x591f4a[_0x1602('0x41')]=qs[_0x1602('0x42')](_0x532fd9[_0x1602('0x39')]['sort']);_0x591f4a['where']=qs[_0x1602('0x3b')](_[_0x1602('0x43')](_0x532fd9[_0x1602('0x39')],_0x585f09[_0x1602('0x3b')]),_0x30032f);if(_0x532fd9[_0x1602('0x39')]['filter']){_0x591f4a[_0x1602('0x44')]=_[_0x1602('0x45')](_0x591f4a[_0x1602('0x44')],{'$or':_[_0x1602('0x32')](_0x30032f,function(_0x1e2f1a){if(_0x1e2f1a[_0x1602('0x36')]!==_0x1602('0x46')){var _0x5a3524={};_0x5a3524[_0x1e2f1a[_0x1602('0x2f')]]={'$like':'%'+_0x532fd9['query'][_0x1602('0x47')]+'%'};return _0x5a3524;}})});}_0x591f4a=_[_0x1602('0x45')]({},_0x591f4a,_0x532fd9[_0x1602('0x48')]);var _0x3e9715={'where':_0x591f4a[_0x1602('0x44')]};return db[_0x1602('0x33')][_0x1602('0x24')](_0x3e9715)[_0x1602('0x49')](function(_0x1b5010){_0x53019f['count']=_0x1b5010;if(_0x532fd9[_0x1602('0x39')]['includeAll']){_0x591f4a[_0x1602('0x4a')]=[{'all':!![]}];}return db[_0x1602('0x33')][_0x1602('0x4b')](_0x591f4a);})[_0x1602('0x49')](function(_0x5a13fc){_0x53019f['rows']=_0x5a13fc;return _0x53019f;})['then'](respondWithFilteredResult(_0x4f3a3b,_0x591f4a))[_0x1602('0x4c')](handleError(_0x4f3a3b,null));};exports[_0x1602('0x4d')]=function(_0x4adf33,_0x10205c){var _0xb44961={'raw':![],'where':{'id':_0x4adf33[_0x1602('0x4e')]['id']}},_0x5ce023={};_0x5ce023[_0x1602('0x38')]=_[_0x1602('0x3a')](db[_0x1602('0x33')][_0x1602('0x34')]);_0x5ce023[_0x1602('0x39')]=_['keys'](_0x4adf33['query']);_0x5ce023['filters']=_[_0x1602('0x3c')](_0x5ce023[_0x1602('0x38')],_0x5ce023[_0x1602('0x39')]);_0xb44961[_0x1602('0x3e')]=_[_0x1602('0x3c')](_0x5ce023['model'],qs[_0x1602('0x3d')](_0x4adf33[_0x1602('0x39')]['fields']));_0xb44961['attributes']=_0xb44961[_0x1602('0x3e')]['length']?_0xb44961[_0x1602('0x3e')]:_0x5ce023[_0x1602('0x38')];if(_0x4adf33[_0x1602('0x39')][_0x1602('0x4f')]){_0xb44961['include']=[{'all':!![]}];}_0xb44961=_[_0x1602('0x45')]({},_0xb44961,_0x4adf33['options']);return db[_0x1602('0x33')][_0x1602('0x50')](_0xb44961)[_0x1602('0x49')](handleEntityNotFound(_0x10205c,null))[_0x1602('0x49')](respondWithResult(_0x10205c,null))[_0x1602('0x4c')](handleError(_0x10205c,null));};exports['create']=function(_0xbb733,_0x347a26){return db[_0x1602('0x33')][_0x1602('0x51')](_0xbb733[_0x1602('0x52')],{})[_0x1602('0x49')](respondWithResult(_0x347a26,0xc9))[_0x1602('0x4c')](handleError(_0x347a26,null));};exports[_0x1602('0x53')]=function(_0x5c7e5a,_0x4ae60a){var _0x3021ec={'where':{'id':_0x5c7e5a['params']['id']}},_0x253783={};_0x253783['model']=_[_0x1602('0x3a')](db[_0x1602('0x33')]['rawAttributes']);_0x3021ec[_0x1602('0x3e')]=_[_0x1602('0x3c')](_0x253783[_0x1602('0x38')],qs['fields'](_0x5c7e5a[_0x1602('0x39')][_0x1602('0x3d')]));_0x3021ec[_0x1602('0x3e')]=_0x3021ec[_0x1602('0x3e')][_0x1602('0x54')]?_0x3021ec['attributes']:_0x253783[_0x1602('0x38')];if(_0x5c7e5a[_0x1602('0x39')][_0x1602('0x4f')]){_0x3021ec[_0x1602('0x4a')]=[{'all':!![]}];}_0x3021ec=_['merge']({},_0x3021ec,_0x5c7e5a[_0x1602('0x48')]);return db['UserProfile']['find'](_0x3021ec)[_0x1602('0x49')](handleEntityNotFound(_0x4ae60a,null))[_0x1602('0x49')](function(_0x187838){if(_0x187838){var _0x553323=_0x187838[_0x1602('0x55')]({'plain':!![]});_0x553323=qs['omit'](_0x553323,['id',_0x1602('0x56'),_0x1602('0x57'),'crudPermissions']);_0x5c7e5a[_0x1602('0x52')]=_[_0x1602('0x58')](_0x5c7e5a[_0x1602('0x52')],['id','createdAt','updatedAt']);return db['sequelize']['transaction'](function(_0x42c4e4){return db[_0x1602('0x33')]['create'](_['merge'](_0x553323,_0x5c7e5a[_0x1602('0x52')]),{'include':_0x5c7e5a[_0x1602('0x39')]['includeAll']?[{'all':!![]}]:undefined,'transaction':_0x42c4e4})[_0x1602('0x49')](function(_0x1cd603){var _0x2445ad=_0x1cd603[_0x1602('0x55')]({'plain':!![]});return db[_0x1602('0x59')][_0x1602('0x4b')]({'where':{'userProfileId':_0x5c7e5a['params']['id']},'raw':!![]})[_0x1602('0x49')](function(_0x1daf2a){if(_0x1daf2a){return BPromise['each'](_0x1daf2a,function(_0x5984b9){return new BPromise(function(_0x56ff0a,_0x52d511){if(_0x5984b9[_0x1602('0x5a')]===null||_0x5984b9['autoAssociation']===0x1)_0x56ff0a(null);return db['UserProfileResource']['findAll']({'where':{'sectionId':_0x5984b9['id']},'raw':!![]})[_0x1602('0x49')](function(_0x56ad55){var _0x5e1e35=_[_0x1602('0x32')](_0x56ad55,function(_0x54733c){return qs['omit'](_0x54733c,['id','createdAt',_0x1602('0x57'),'sectionId']);});_0x56ff0a(_0x5e1e35);})[_0x1602('0x4c')](function(_0x42415a){_0x52d511(_0x42415a);});})['then'](function(_0x4cd363){var _0x5e0ade=qs[_0x1602('0x58')](_0x5984b9,['id',_0x1602('0x56'),_0x1602('0x57')]);_0x5e0ade[_0x1602('0x5b')]=_0x2445ad['id'];if(_0x4cd363)_0x5e0ade[_0x1602('0x5c')]=_0x4cd363;return _0x5e0ade;})[_0x1602('0x49')](function(_0x2b549a){return db[_0x1602('0x59')][_0x1602('0x51')](_0x2b549a,{'include':[{'model':db[_0x1602('0x5d')],'as':_0x1602('0x5c')}],'raw':!![],'transaction':_0x42c4e4});});})['then'](function(){return _0x2445ad;});}});});});}})['then'](respondWithResult(_0x4ae60a,0xc9))[_0x1602('0x4c')](handleError(_0x4ae60a,null));};exports[_0x1602('0x2c')]=function(_0x564814,_0x16707b){if(_0x564814[_0x1602('0x52')]['id']){delete _0x564814[_0x1602('0x52')]['id'];}return db[_0x1602('0x33')]['find']({'where':{'id':_0x564814[_0x1602('0x4e')]['id']}})[_0x1602('0x49')](handleEntityNotFound(_0x16707b,null))[_0x1602('0x49')](saveUpdates(_0x564814[_0x1602('0x52')],null))[_0x1602('0x49')](respondWithResult(_0x16707b,null))[_0x1602('0x4c')](handleError(_0x16707b,null));};exports['destroy']=function(_0x10e7ee,_0x71ba66){return db['UserProfile'][_0x1602('0x50')]({'where':{'id':_0x10e7ee['params']['id']}})[_0x1602('0x49')](handleEntityNotFound(_0x71ba66,null))['then'](removeEntity(_0x71ba66,null))[_0x1602('0x4c')](handleError(_0x71ba66,null));};exports[_0x1602('0x5e')]=function(_0x23f1a2,_0x43a7fa){return db[_0x1602('0x33')][_0x1602('0x5e')]()[_0x1602('0x49')](respondWithResult(_0x43a7fa,null))['catch'](handleError(_0x43a7fa,null));};exports[_0x1602('0x5f')]=function(_0x51a53c,_0x2aaa89){var _0x333c36=_0x51a53c[_0x1602('0x52')];return db[_0x1602('0x33')]['find']({'where':{'id':_0x51a53c[_0x1602('0x4e')]['id']}})[_0x1602('0x49')](handleEntityNotFound(_0x2aaa89,null))[_0x1602('0x49')](function(_0xcd9bb6){if(_0xcd9bb6){return db['sequelize'][_0x1602('0x60')](function(_0xb63c09){return db[_0x1602('0x59')][_0x1602('0x2d')]({'where':{'userProfileId':_0x51a53c[_0x1602('0x4e')]['id'],'sectionId':_['map'](_0x333c36,function(_0x235cb9){return _0x235cb9[_0x1602('0x61')];})},'transaction':_0xb63c09})[_0x1602('0x49')](function(){var _0x3cc635=_[_0x1602('0x32')](_0x333c36,function(_0x1e8a72){_0x1e8a72[_0x1602('0x5b')]=_0x51a53c[_0x1602('0x4e')]['id'];return _0x1e8a72;});var _0x1b2146=[];return BPromise[_0x1602('0x62')](_0x3cc635,function(_0x4f9032){return db['UserProfileSection'][_0x1602('0x51')](_0x4f9032,{'include':[{'model':db[_0x1602('0x5d')],'as':_0x1602('0x5c')}],'raw':!![],'transaction':_0xb63c09})[_0x1602('0x49')](function(_0x1ac823){_0x1b2146[_0x1602('0x63')](_0x1ac823[_0x1602('0x55')]({'plain':!![]}));});})[_0x1602('0x49')](function(){return _0x1b2146;});});});}})['then'](function(_0x4265b9){return _0x4265b9;})[_0x1602('0x49')](respondWithResult(_0x2aaa89,null))[_0x1602('0x4c')](handleError(_0x2aaa89,null));};exports['removeSections']=function(_0x13ecf3,_0x3c38d1){var _0x826297;return db[_0x1602('0x33')]['find']({'where':{'id':_0x13ecf3[_0x1602('0x4e')]['id']},'attributes':['id',_0x1602('0x2f')]})[_0x1602('0x49')](handleEntityNotFound(_0x3c38d1,null))[_0x1602('0x49')](function(_0x869b87){if(_0x869b87){_0x826297=_0x869b87;return db[_0x1602('0x59')][_0x1602('0x2d')]({'where':{'userProfileId':_0x13ecf3['params']['id'],'sectionId':_0x13ecf3[_0x1602('0x39')][_0x1602('0x64')]}});}})[_0x1602('0x49')](function(){return _0x826297;})['then'](respondWithStatusCode(_0x3c38d1,null))[_0x1602('0x4c')](handleError(_0x3c38d1,null));};exports[_0x1602('0x65')]=function(_0x31f553,_0x424957){var _0x1ef54a=[];var _0x35e8f2=[];return db[_0x1602('0x59')][_0x1602('0x4b')]({'where':{'userProfileId':_0x31f553[_0x1602('0x4e')]['id']},'raw':!![]})[_0x1602('0x49')](function(_0x3542a2){_0x1ef54a=_['filter'](_0x3542a2,function(_0x2cdc1a){return _0x2cdc1a[_0x1602('0x66')]===0x1||_[_0x1602('0x67')]([0x3eb,0x709],_0x2cdc1a[_0x1602('0x61')]);});if(!_[_0x1602('0x68')](_0x1ef54a)){return _[_0x1602('0x32')](_0x1ef54a,function(_0x1acff4){return _0x1acff4[_0x1602('0x61')];});}else{return;}})[_0x1602('0x49')](function(_0x1461cb){if(_0x1461cb)_0x35e8f2=_0x1461cb;if(_['includes'](_0x35e8f2,0x64)){var _0x33329c=_[_0x1602('0x50')](_0x1ef54a,{'sectionId':0x64});return hasDefaultDashboard(_0x33329c)[_0x1602('0x49')](function(_0x14cc85){return _[_0x1602('0x32')](_0x1ef54a,function(_0x30660b){if(_0x30660b[_0x1602('0x61')]===0x64){_0x30660b[_0x1602('0x69')]=_0x14cc85;}return _0x30660b;});});}else{return;}})['then'](function(_0x32bd88){if(_0x32bd88)_0x1ef54a=_0x32bd88;if(_[_0x1602('0x67')](_0x35e8f2,0x3eb)){var _0xcc10b6=_[_0x1602('0x50')](_0x1ef54a,{'sectionId':0x3eb});return getCustomDashboards(_0xcc10b6)[_0x1602('0x49')](function(_0x386ed7){return _[_0x1602('0x32')](_0x1ef54a,function(_0x3f2ab6){if(_0xcc10b6[_0x1602('0x66')]){if(_0x3f2ab6[_0x1602('0x61')]===0x3eb){_0x3f2ab6['subsections']=_0x386ed7;}}else{if(_0x3f2ab6[_0x1602('0x61')]===0x64){if(!_0x3f2ab6[_0x1602('0x69')]){_0x3f2ab6[_0x1602('0x69')]=[];}_0x3f2ab6[_0x1602('0x69')]=_0x3f2ab6[_0x1602('0x69')]['concat'](_0x386ed7);}}return _0x3f2ab6;});});}else{return;}})[_0x1602('0x49')](function(_0x131c78){if(_0x131c78)_0x1ef54a=_0x131c78;if(_[_0x1602('0x67')](_0x35e8f2,0x709)){var _0x1a9b44=_['find'](_0x1ef54a,{'sectionId':0x709});return getPlugins(_0x1a9b44)[_0x1602('0x49')](function(_0x10c733){if(_0x1a9b44[_0x1602('0x66')]){return _[_0x1602('0x32')](_0x1ef54a,function(_0x42a6e1){if(_0x42a6e1[_0x1602('0x61')]===0x709){_0x42a6e1['subsections']=_0x10c733;}return _0x42a6e1;});}else{var _0x4a008e={'sectionId':0x76c,'enabled':0x1,'subsections':_0x10c733};var _0xa4adbe=_['map'](_0x1ef54a);_0xa4adbe[_0x1602('0x63')](_0x4a008e);return _0xa4adbe;}});}else{return;}})[_0x1602('0x49')](function(_0x5bd047){if(_0x5bd047)_0x1ef54a=_0x5bd047;return _['filter'](_0x1ef54a,[_0x1602('0x66'),0x1]);})[_0x1602('0x49')](respondWithResult(_0x424957,null))[_0x1602('0x4c')](handleError(_0x424957,null));};function hasDefaultDashboard(_0x2de807){var _0x394233=[0x65];return new BPromise(function(_0x5878ce,_0x352663){try{if(_0x2de807[_0x1602('0x5a')]){_0x5878ce(_0x394233);}else{return db['UserProfileResource'][_0x1602('0x6a')]({'where':{'sectionId':_0x2de807['id']},'raw':!![]})[_0x1602('0x49')](function(_0x447b85){_0x447b85?_0x5878ce(_0x394233):_0x5878ce();});}}catch(_0x58e663){_0x352663(_0x58e663);}});}function getCustomDashboards(_0xc63dcb){var _0x3e7a1e=[];return new BPromise(function(_0x14aef3,_0x514286){try{if(_0xc63dcb['autoAssociation']){return db[_0x1602('0x6b')][_0x1602('0x4b')]({'raw':!![]})['then'](function(_0x4f22bb){_0x4f22bb[_0x1602('0x6c')](function(_0x404527){_0x3e7a1e[_0x1602('0x63')](_0x404527['id']+0x1869f);});_0x14aef3(_0x3e7a1e);});}else{return db[_0x1602('0x5d')]['findAll']({'where':{'sectionId':_0xc63dcb['id']},'raw':!![]})['then'](function(_0x1577b8){_0x1577b8[_0x1602('0x6c')](function(_0x21ef8f){_0x3e7a1e[_0x1602('0x63')](_0x21ef8f[_0x1602('0x6d')]+0x1869f);});_0x14aef3(_0x3e7a1e);});}}catch(_0x34aa9d){_0x514286(_0x34aa9d);}});}function getPlugins(_0x375a35){var _0xeb9f10=[];return new BPromise(function(_0x2782e3,_0x356e23){try{if(_0x375a35[_0x1602('0x5a')]){return db[_0x1602('0x6e')][_0x1602('0x4b')]({'raw':!![]})['then'](function(_0x6dc008){_0x6dc008['forEach'](function(_0x4260f6){_0xeb9f10['push'](_0x4260f6['id']+0x15b38);});_0x2782e3(_0xeb9f10);});}else{return db[_0x1602('0x5d')][_0x1602('0x4b')]({'where':{'sectionId':_0x375a35['id']},'raw':!![]})[_0x1602('0x49')](function(_0x51b411){_0x51b411[_0x1602('0x6c')](function(_0x28925f){_0xeb9f10[_0x1602('0x63')](_0x28925f[_0x1602('0x6d')]+0x15b38);});_0x2782e3(_0xeb9f10);});}}catch(_0x42dc71){_0x356e23(_0x42dc71);}});}exports[_0x1602('0x6f')]=function(_0x5c7c83,_0xb11732){return db[_0x1602('0x33')][_0x1602('0x50')]({'where':{'id':_0x5c7c83[_0x1602('0x4e')]['id']}})[_0x1602('0x49')](handleEntityNotFound(_0xb11732,null))[_0x1602('0x49')](function(_0x2bfd7f){if(_0x2bfd7f){return db[_0x1602('0x70')][_0x1602('0x60')](function(_0x34aabe){return db[_0x1602('0x59')][_0x1602('0x4b')]({'where':{'userProfileId':_0x5c7c83[_0x1602('0x4e')]['id']},'attributes':['id'],'raw':!![]})[_0x1602('0x49')](function(_0x1896d5){if(_0x1896d5){return db[_0x1602('0x59')][_0x1602('0x2d')]({'where':{'userProfileId':_0x5c7c83[_0x1602('0x4e')]['id'],'id':_[_0x1602('0x32')](_0x1896d5,function(_0x597899){return _0x597899['id'];})},'transaction':_0x34aabe});}})[_0x1602('0x49')](function(_0x227453){var _0x276641=_[_0x1602('0x32')](_0x5c7c83[_0x1602('0x52')],function(_0x5e7159){_0x5e7159[_0x1602('0x5b')]=_0x5c7c83[_0x1602('0x4e')]['id'];return _0x5e7159;});return db['UserProfileSection'][_0x1602('0x71')](_0x276641,{'raw':!![],'transaction':_0x34aabe});})[_0x1602('0x49')](function(_0x49e17a){var _0x1195f8=_[_0x1602('0x47')](_['map'](_0x49e17a,function(_0x112c33){return _0x112c33[_0x1602('0x55')]({'plain':!![]});}),{'includeAll':![]});if(_0x1195f8){return db[_0x1602('0x59')][_0x1602('0x4b')]({'where':{'userProfileId':_0x5c7c83['params']['id'],'sectionId':_[_0x1602('0x32')](_0x1195f8,function(_0x29e98d){return _0x29e98d[_0x1602('0x61')];})},'attributes':['id','sectionId'],'raw':!![]})[_0x1602('0x49')](function(_0x90ea3f){var _0x44286f=_[_0x1602('0x32')](_0x5c7c83[_0x1602('0x52')],function(_0x4c125e){_0x4c125e[_0x1602('0x5b')]=_0x5c7c83[_0x1602('0x4e')]['id'];return _0x4c125e;});return db['UserProfileResource']['bulkCreate'](_0x44286f,{'raw':!![],'transaction':_0x34aabe});});}})[_0x1602('0x4c')](handleError(_0xb11732,null));});}})[_0x1602('0x49')](function(_0x1a8abb){var _0x4e3a91=_[_0x1602('0x32')](_0x1a8abb,function(_0x526dec){return _0x526dec['get']({'plain':!![]});});})['then'](respondWithResult(_0xb11732,null))[_0x1602('0x4c')](handleError(_0xb11732,null));};exports[_0x1602('0x72')]=function(_0x4e616a,_0x197ba0,_0x15d21f){return db['UserProfile'][_0x1602('0x50')]({'where':{'id':_0x4e616a[_0x1602('0x4e')]['id']}})[_0x1602('0x49')](handleEntityNotFound(_0x197ba0,null))[_0x1602('0x49')](function(_0x5eac43){if(_0x5eac43){return _0x5eac43[_0x1602('0x72')](_0x4e616a[_0x1602('0x39')][_0x1602('0x64')]);}})[_0x1602('0x49')](respondWithStatusCode(_0x197ba0,null))[_0x1602('0x4c')](handleError(_0x197ba0,null));};exports[_0x1602('0x73')]=function(_0x21ee4f,_0x1e1eb9){var _0x1cbc46={};if(!_0x21ee4f[_0x1602('0x39')][_0x1602('0x74')])throw new Error('Missing\x20section\x20parameter');if(!_0x21ee4f[_0x1602('0x39')][_0x1602('0x3f')]('nolimit')){_0x1cbc46['limit']=qs[_0x1602('0x26')](_0x21ee4f['query']['limit']);_0x1cbc46[_0x1602('0x25')]=qs[_0x1602('0x25')](_0x21ee4f[_0x1602('0x39')][_0x1602('0x25')]);}return db['UserProfile'][_0x1602('0x50')]({'where':{'id':_0x21ee4f[_0x1602('0x4e')]['id']}})[_0x1602('0x49')](function(_0x2783da){if(!_0x2783da)throw new Error(_0x1602('0x75')+_0x21ee4f[_0x1602('0x4e')]['id']);return db[_0x1602('0x33')][_0x1602('0x73')](_0x21ee4f);})['then'](respondWithFilteredResult(_0x1e1eb9,_0x1cbc46))[_0x1602('0x4c')](handleError(_0x1e1eb9,null));};
\ No newline at end of file