18 var _0x4252=['name','send','map','CmHopperBlack','fieldName','type','query','keys','filters','intersection','model','attributes','fields','length','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','rawAttributes','include','find','catch','body','params','describe','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','path','to-csv','ejs','fs-extra','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/utils','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','update','then','destroy','error'];(function(_0x142ec2,_0x5bb03d){var _0x45ef4e=function(_0x4bc513){while(--_0x4bc513){_0x142ec2['push'](_0x142ec2['shift']());}};_0x45ef4e(++_0x5bb03d);}(_0x4252,0x1b9));var _0x2425=function(_0x185bd0,_0x3b60bf){_0x185bd0=_0x185bd0-0x0;var _0x5ce480=_0x4252[_0x185bd0];return _0x5ce480;};'use strict';var emlformat=require(_0x2425('0x0'));var rimraf=require(_0x2425('0x1'));var zipdir=require(_0x2425('0x2'));var jsonpatch=require(_0x2425('0x3'));var rp=require('request-promise');var moment=require(_0x2425('0x4'));var BPromise=require(_0x2425('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x2425('0x6'));var sox=require('sox');var csv=require(_0x2425('0x7'));var ejs=require(_0x2425('0x8'));var fs=require('fs');var fs_extra=require(_0x2425('0x9'));var _=require('lodash');var squel=require(_0x2425('0xa'));var crypto=require('crypto');var jsforce=require(_0x2425('0xb'));var deskjs=require(_0x2425('0xc'));var toCsv=require(_0x2425('0x7'));var querystring=require(_0x2425('0xd'));var Papa=require('papaparse');var Redis=require(_0x2425('0xe'));var authService=require(_0x2425('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x2425('0x10'));var logger=require(_0x2425('0x11'))('api');var utils=require(_0x2425('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5c4fd4,_0x5b16aa){_0x5b16aa=_0x5b16aa||0xcc;return function(_0x4dca66){if(_0x4dca66){return _0x5c4fd4[_0x2425('0x13')](_0x5b16aa);}return _0x5c4fd4[_0x2425('0x14')](_0x5b16aa)[_0x2425('0x15')]();};}function respondWithResult(_0x5d02ad,_0x3c2ec4){_0x3c2ec4=_0x3c2ec4||0xc8;return function(_0x3dcd75){if(_0x3dcd75){return _0x5d02ad['status'](_0x3c2ec4)[_0x2425('0x16')](_0x3dcd75);}};}function respondWithFilteredResult(_0x2d0088,_0x5e3ea9){return function(_0x2bf897){if(_0x2bf897){var _0x51dca7=typeof _0x5e3ea9['offset']===_0x2425('0x17')&&typeof _0x5e3ea9[_0x2425('0x18')]===_0x2425('0x17');var _0x156315=_0x2bf897[_0x2425('0x19')];var _0x4736c1=_0x51dca7?0x0:_0x5e3ea9[_0x2425('0x1a')];var _0x185b36=_0x51dca7?_0x2bf897['count']:_0x5e3ea9['offset']+_0x5e3ea9[_0x2425('0x18')];var _0x161010;if(_0x185b36>=_0x156315){_0x185b36=_0x156315;_0x161010=0xc8;}else{_0x161010=0xce;}_0x2d0088['status'](_0x161010);return _0x2d0088[_0x2425('0x1b')](_0x2425('0x1c'),_0x4736c1+'-'+_0x185b36+'/'+_0x156315)[_0x2425('0x16')](_0x2bf897);}return null;};}function patchUpdates(_0x423873){return function(_0x38fe87){try{jsonpatch[_0x2425('0x1d')](_0x38fe87,_0x423873,!![]);}catch(_0x49e5e2){return BPromise[_0x2425('0x1e')](_0x49e5e2);}return _0x38fe87['save']();};}function saveUpdates(_0x127253,_0x587c20){return function(_0x430a06){if(_0x430a06){return _0x430a06[_0x2425('0x1f')](_0x127253)[_0x2425('0x20')](function(_0x24daee){return _0x24daee;});}return null;};}function removeEntity(_0x6000d0,_0x78878b){return function(_0xc04bd1){if(_0xc04bd1){return _0xc04bd1[_0x2425('0x21')]()[_0x2425('0x20')](function(){_0x6000d0['status'](0xcc)[_0x2425('0x15')]();});}};}function handleEntityNotFound(_0x11ea40,_0x5ec646){return function(_0x315398){if(!_0x315398){_0x11ea40['sendStatus'](0x194);}return _0x315398;};}function handleError(_0x2235b5,_0x506141){_0x506141=_0x506141||0x1f4;return function(_0x425382){logger[_0x2425('0x22')](_0x425382['stack']);if(_0x425382[_0x2425('0x23')]){delete _0x425382[_0x2425('0x23')];}_0x2235b5[_0x2425('0x14')](_0x506141)[_0x2425('0x24')](_0x425382);};}exports['index']=function(_0x42f07c,_0x294f8a){var _0x395eb6={},_0x1d02f8={},_0x3d4b2b={'count':0x0,'rows':[]};var _0x2b7790=_[_0x2425('0x25')](db[_0x2425('0x26')]['rawAttributes'],function(_0x40d8db){return{'name':_0x40d8db[_0x2425('0x27')],'type':_0x40d8db[_0x2425('0x28')]['key']};});_0x1d02f8['model']=_[_0x2425('0x25')](_0x2b7790,_0x2425('0x23'));_0x1d02f8[_0x2425('0x29')]=_[_0x2425('0x2a')](_0x42f07c['query']);_0x1d02f8[_0x2425('0x2b')]=_[_0x2425('0x2c')](_0x1d02f8[_0x2425('0x2d')],_0x1d02f8[_0x2425('0x29')]);_0x395eb6[_0x2425('0x2e')]=_[_0x2425('0x2c')](_0x1d02f8[_0x2425('0x2d')],qs[_0x2425('0x2f')](_0x42f07c[_0x2425('0x29')][_0x2425('0x2f')]));_0x395eb6[_0x2425('0x2e')]=_0x395eb6[_0x2425('0x2e')][_0x2425('0x30')]?_0x395eb6[_0x2425('0x2e')]:_0x1d02f8[_0x2425('0x2d')];if(!_0x42f07c[_0x2425('0x29')]['hasOwnProperty']('nolimit')){_0x395eb6[_0x2425('0x18')]=qs[_0x2425('0x18')](_0x42f07c[_0x2425('0x29')][_0x2425('0x18')]);_0x395eb6[_0x2425('0x1a')]=qs[_0x2425('0x1a')](_0x42f07c[_0x2425('0x29')]['offset']);}_0x395eb6[_0x2425('0x31')]=qs[_0x2425('0x32')](_0x42f07c['query']['sort']);_0x395eb6[_0x2425('0x33')]=qs[_0x2425('0x2b')](_[_0x2425('0x34')](_0x42f07c[_0x2425('0x29')],_0x1d02f8['filters']),_0x2b7790);if(_0x42f07c[_0x2425('0x29')][_0x2425('0x35')]){_0x395eb6[_0x2425('0x33')]=_[_0x2425('0x36')](_0x395eb6['where'],{'$or':_[_0x2425('0x25')](_0x2b7790,function(_0x3143d6){if(_0x3143d6['type']!==_0x2425('0x37')){var _0x4e8e70={};_0x4e8e70[_0x3143d6[_0x2425('0x23')]]={'$like':'%'+_0x42f07c[_0x2425('0x29')]['filter']+'%'};return _0x4e8e70;}})});}_0x395eb6=_['merge']({},_0x395eb6,_0x42f07c[_0x2425('0x38')]);var _0x173b68={'where':_0x395eb6[_0x2425('0x33')]};return db['CmHopperBlack'][_0x2425('0x19')](_0x173b68)[_0x2425('0x20')](function(_0x4f598b){_0x3d4b2b[_0x2425('0x19')]=_0x4f598b;if(_0x42f07c[_0x2425('0x29')][_0x2425('0x39')]){_0x395eb6['include']=[{'all':!![]}];}return db[_0x2425('0x26')][_0x2425('0x3a')](_0x395eb6);})[_0x2425('0x20')](function(_0x1cbbb5){_0x3d4b2b[_0x2425('0x3b')]=_0x1cbbb5;return _0x3d4b2b;})[_0x2425('0x20')](respondWithFilteredResult(_0x294f8a,_0x395eb6))['catch'](handleError(_0x294f8a,null));};exports[_0x2425('0x3c')]=function(_0x36a4a1,_0x3feb20){var _0x443147={'raw':!![],'where':{'id':_0x36a4a1['params']['id']}},_0x5beb34={};_0x5beb34['model']=_[_0x2425('0x2a')](db[_0x2425('0x26')][_0x2425('0x3d')]);_0x5beb34['query']=_[_0x2425('0x2a')](_0x36a4a1[_0x2425('0x29')]);_0x5beb34[_0x2425('0x2b')]=_[_0x2425('0x2c')](_0x5beb34[_0x2425('0x2d')],_0x5beb34[_0x2425('0x29')]);_0x443147[_0x2425('0x2e')]=_[_0x2425('0x2c')](_0x5beb34[_0x2425('0x2d')],qs[_0x2425('0x2f')](_0x36a4a1[_0x2425('0x29')][_0x2425('0x2f')]));_0x443147['attributes']=_0x443147[_0x2425('0x2e')][_0x2425('0x30')]?_0x443147[_0x2425('0x2e')]:_0x5beb34[_0x2425('0x2d')];if(_0x36a4a1[_0x2425('0x29')][_0x2425('0x39')]){_0x443147[_0x2425('0x3e')]=[{'all':!![]}];}_0x443147=_[_0x2425('0x36')]({},_0x443147,_0x36a4a1[_0x2425('0x38')]);return db[_0x2425('0x26')][_0x2425('0x3f')](_0x443147)['then'](handleEntityNotFound(_0x3feb20,null))[_0x2425('0x20')](respondWithResult(_0x3feb20,null))[_0x2425('0x40')](handleError(_0x3feb20,null));};exports[_0x2425('0x1f')]=function(_0x30b8fb,_0x3033ff){if(_0x30b8fb[_0x2425('0x41')]['id']){delete _0x30b8fb[_0x2425('0x41')]['id'];}return db[_0x2425('0x26')][_0x2425('0x3f')]({'where':{'id':_0x30b8fb[_0x2425('0x42')]['id']}})['then'](handleEntityNotFound(_0x3033ff,null))[_0x2425('0x20')](saveUpdates(_0x30b8fb[_0x2425('0x41')],null))[_0x2425('0x20')](respondWithResult(_0x3033ff,null))[_0x2425('0x40')](handleError(_0x3033ff,null));};exports[_0x2425('0x21')]=function(_0x293c46,_0x2cb332){return db['CmHopperBlack'][_0x2425('0x3f')]({'where':{'id':_0x293c46['params']['id']}})[_0x2425('0x20')](handleEntityNotFound(_0x2cb332,null))[_0x2425('0x20')](removeEntity(_0x2cb332,null))[_0x2425('0x40')](handleError(_0x2cb332,null));};exports[_0x2425('0x43')]=function(_0x36ed0b,_0x4d6ce1){return db['CmHopperBlack'][_0x2425('0x43')]()['then'](respondWithResult(_0x4d6ce1,null))['catch'](handleError(_0x4d6ce1,null));};