18 var _0xe811=['count','Content-Range','apply','reject','save','update','destroy','then','sendStatus','error','stack','name','send','index','SquareDetailsReport','rawAttributes','type','key','map','query','keys','intersection','model','attributes','fields','length','nolimit','order','sort','filters','pick','where','merge','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','params','find','create','body','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','offset','limit','undefined'];(function(_0x1f4c4f,_0x1d102a){var _0xb0eed7=function(_0x14072d){while(--_0x14072d){_0x1f4c4f['push'](_0x1f4c4f['shift']());}};_0xb0eed7(++_0x1d102a);}(_0xe811,0x7b));var _0x1e81=function(_0x262799,_0x14a591){_0x262799=_0x262799-0x0;var _0x1a7368=_0xe811[_0x262799];return _0x1a7368;};'use strict';var emlformat=require(_0x1e81('0x0'));var rimraf=require(_0x1e81('0x1'));var zipdir=require(_0x1e81('0x2'));var jsonpatch=require(_0x1e81('0x3'));var rp=require(_0x1e81('0x4'));var moment=require(_0x1e81('0x5'));var BPromise=require(_0x1e81('0x6'));var Mustache=require(_0x1e81('0x7'));var util=require(_0x1e81('0x8'));var path=require('path');var sox=require(_0x1e81('0x9'));var csv=require('to-csv');var ejs=require(_0x1e81('0xa'));var fs=require('fs');var fs_extra=require(_0x1e81('0xb'));var _=require(_0x1e81('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x1e81('0xd'));var toCsv=require('to-csv');var querystring=require(_0x1e81('0xe'));var Papa=require(_0x1e81('0xf'));var Redis=require(_0x1e81('0x10'));var authService=require(_0x1e81('0x11'));var qs=require(_0x1e81('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x1e81('0x13'));var config=require(_0x1e81('0x14'));var licenseUtil=require(_0x1e81('0x15'));var db=require(_0x1e81('0x16'))['db'];function respondWithStatusCode(_0x4bb2d4,_0x3ba4f9){_0x3ba4f9=_0x3ba4f9||0xcc;return function(_0x3bb759){if(_0x3bb759){return _0x4bb2d4['sendStatus'](_0x3ba4f9);}return _0x4bb2d4[_0x1e81('0x17')](_0x3ba4f9)[_0x1e81('0x18')]();};}function respondWithResult(_0xc10f2a,_0x4bd6d4){_0x4bd6d4=_0x4bd6d4||0xc8;return function(_0x1916d0){if(_0x1916d0){return _0xc10f2a[_0x1e81('0x17')](_0x4bd6d4)[_0x1e81('0x19')](_0x1916d0);}};}function respondWithFilteredResult(_0x4ff897,_0x5b1379){return function(_0x492670){if(_0x492670){var _0x13c9c2=typeof _0x5b1379[_0x1e81('0x1a')]==='undefined'&&typeof _0x5b1379[_0x1e81('0x1b')]===_0x1e81('0x1c');var _0x45360f=_0x492670[_0x1e81('0x1d')];var _0x55525a=_0x13c9c2?0x0:_0x5b1379[_0x1e81('0x1a')];var _0x4a7035=_0x13c9c2?_0x492670['count']:_0x5b1379[_0x1e81('0x1a')]+_0x5b1379[_0x1e81('0x1b')];var _0x3645e2;if(_0x4a7035>=_0x45360f){_0x4a7035=_0x45360f;_0x3645e2=0xc8;}else{_0x3645e2=0xce;}_0x4ff897[_0x1e81('0x17')](_0x3645e2);return _0x4ff897['set'](_0x1e81('0x1e'),_0x55525a+'-'+_0x4a7035+'/'+_0x45360f)[_0x1e81('0x19')](_0x492670);}return null;};}function patchUpdates(_0x153656){return function(_0x530e5b){try{jsonpatch[_0x1e81('0x1f')](_0x530e5b,_0x153656,!![]);}catch(_0x3cbfcc){return BPromise[_0x1e81('0x20')](_0x3cbfcc);}return _0x530e5b[_0x1e81('0x21')]();};}function saveUpdates(_0x29a6d3,_0x216b8c){return function(_0x29f983){if(_0x29f983){return _0x29f983[_0x1e81('0x22')](_0x29a6d3)['then'](function(_0x1e0c9b){return _0x1e0c9b;});}return null;};}function removeEntity(_0xfd07c6,_0x7c744d){return function(_0x297c9d){if(_0x297c9d){return _0x297c9d[_0x1e81('0x23')]()[_0x1e81('0x24')](function(){_0xfd07c6['status'](0xcc)[_0x1e81('0x18')]();});}};}function handleEntityNotFound(_0x21d3bf,_0x37e69a){return function(_0x25adc4){if(!_0x25adc4){_0x21d3bf[_0x1e81('0x25')](0x194);}return _0x25adc4;};}function handleError(_0x67db0e,_0x5afb54){_0x5afb54=_0x5afb54||0x1f4;return function(_0x220487){logger[_0x1e81('0x26')](_0x220487[_0x1e81('0x27')]);if(_0x220487['name']){delete _0x220487[_0x1e81('0x28')];}_0x67db0e[_0x1e81('0x17')](_0x5afb54)[_0x1e81('0x29')](_0x220487);};}exports[_0x1e81('0x2a')]=function(_0x389d6d,_0x19872d){var _0xe3ebcc={},_0x3f8b6a={},_0x483565={'count':0x0,'rows':[]};var _0xcde53c=_['map'](db[_0x1e81('0x2b')][_0x1e81('0x2c')],function(_0xde1ff4){return{'name':_0xde1ff4['fieldName'],'type':_0xde1ff4[_0x1e81('0x2d')][_0x1e81('0x2e')]};});_0x3f8b6a['model']=_[_0x1e81('0x2f')](_0xcde53c,_0x1e81('0x28'));_0x3f8b6a[_0x1e81('0x30')]=_[_0x1e81('0x31')](_0x389d6d['query']);_0x3f8b6a['filters']=_[_0x1e81('0x32')](_0x3f8b6a[_0x1e81('0x33')],_0x3f8b6a[_0x1e81('0x30')]);_0xe3ebcc[_0x1e81('0x34')]=_[_0x1e81('0x32')](_0x3f8b6a[_0x1e81('0x33')],qs[_0x1e81('0x35')](_0x389d6d[_0x1e81('0x30')][_0x1e81('0x35')]));_0xe3ebcc['attributes']=_0xe3ebcc['attributes'][_0x1e81('0x36')]?_0xe3ebcc[_0x1e81('0x34')]:_0x3f8b6a[_0x1e81('0x33')];if(!_0x389d6d[_0x1e81('0x30')]['hasOwnProperty'](_0x1e81('0x37'))){_0xe3ebcc[_0x1e81('0x1b')]=qs[_0x1e81('0x1b')](_0x389d6d[_0x1e81('0x30')][_0x1e81('0x1b')]);_0xe3ebcc['offset']=qs[_0x1e81('0x1a')](_0x389d6d[_0x1e81('0x30')][_0x1e81('0x1a')]);}_0xe3ebcc[_0x1e81('0x38')]=qs['sort'](_0x389d6d[_0x1e81('0x30')][_0x1e81('0x39')]);_0xe3ebcc['where']=qs[_0x1e81('0x3a')](_[_0x1e81('0x3b')](_0x389d6d['query'],_0x3f8b6a[_0x1e81('0x3a')]),_0xcde53c);if(_0x389d6d['query']['filter']){_0xe3ebcc[_0x1e81('0x3c')]=_[_0x1e81('0x3d')](_0xe3ebcc[_0x1e81('0x3c')],{'$or':_[_0x1e81('0x2f')](_0xcde53c,function(_0x3e127c){if(_0x3e127c[_0x1e81('0x2d')]!==_0x1e81('0x3e')){var _0x3ed38d={};_0x3ed38d[_0x3e127c[_0x1e81('0x28')]]={'$like':'%'+_0x389d6d[_0x1e81('0x30')][_0x1e81('0x3f')]+'%'};return _0x3ed38d;}})});}_0xe3ebcc=_['merge']({},_0xe3ebcc,_0x389d6d[_0x1e81('0x40')]);var _0x271ba1={'where':_0xe3ebcc['where']};return db['SquareDetailsReport'][_0x1e81('0x1d')](_0x271ba1)[_0x1e81('0x24')](function(_0x170531){_0x483565[_0x1e81('0x1d')]=_0x170531;if(_0x389d6d[_0x1e81('0x30')][_0x1e81('0x41')]){_0xe3ebcc[_0x1e81('0x42')]=[{'all':!![]}];}return db[_0x1e81('0x2b')][_0x1e81('0x43')](_0xe3ebcc);})[_0x1e81('0x24')](function(_0x5ae215){_0x483565[_0x1e81('0x44')]=_0x5ae215;return _0x483565;})[_0x1e81('0x24')](respondWithFilteredResult(_0x19872d,_0xe3ebcc))[_0x1e81('0x45')](handleError(_0x19872d,null));};exports[_0x1e81('0x46')]=function(_0x1c8450,_0x5b2f2f){var _0x37cab3={'raw':!![],'where':{'id':_0x1c8450[_0x1e81('0x47')]['id']}},_0x535f17={};_0x535f17['model']=_[_0x1e81('0x31')](db['SquareDetailsReport']['rawAttributes']);_0x535f17['query']=_[_0x1e81('0x31')](_0x1c8450[_0x1e81('0x30')]);_0x535f17['filters']=_[_0x1e81('0x32')](_0x535f17[_0x1e81('0x33')],_0x535f17[_0x1e81('0x30')]);_0x37cab3[_0x1e81('0x34')]=_['intersection'](_0x535f17['model'],qs[_0x1e81('0x35')](_0x1c8450[_0x1e81('0x30')]['fields']));_0x37cab3['attributes']=_0x37cab3['attributes'][_0x1e81('0x36')]?_0x37cab3[_0x1e81('0x34')]:_0x535f17[_0x1e81('0x33')];if(_0x1c8450[_0x1e81('0x30')][_0x1e81('0x41')]){_0x37cab3[_0x1e81('0x42')]=[{'all':!![]}];}_0x37cab3=_[_0x1e81('0x3d')]({},_0x37cab3,_0x1c8450['options']);return db[_0x1e81('0x2b')][_0x1e81('0x48')](_0x37cab3)[_0x1e81('0x24')](handleEntityNotFound(_0x5b2f2f,null))[_0x1e81('0x24')](respondWithResult(_0x5b2f2f,null))[_0x1e81('0x45')](handleError(_0x5b2f2f,null));};exports[_0x1e81('0x49')]=function(_0x16668a,_0xd491aa){return db[_0x1e81('0x2b')]['create'](_0x16668a['body'],{})[_0x1e81('0x24')](respondWithResult(_0xd491aa,0xc9))[_0x1e81('0x45')](handleError(_0xd491aa,null));};exports['update']=function(_0x4896e5,_0x3d1d9d){if(_0x4896e5[_0x1e81('0x4a')]['id']){delete _0x4896e5[_0x1e81('0x4a')]['id'];}return db['SquareDetailsReport'][_0x1e81('0x48')]({'where':{'id':_0x4896e5['params']['id']}})[_0x1e81('0x24')](handleEntityNotFound(_0x3d1d9d,null))[_0x1e81('0x24')](saveUpdates(_0x4896e5['body'],null))['then'](respondWithResult(_0x3d1d9d,null))['catch'](handleError(_0x3d1d9d,null));};exports[_0x1e81('0x23')]=function(_0x2c94cb,_0x33feba){return db[_0x1e81('0x2b')][_0x1e81('0x48')]({'where':{'id':_0x2c94cb['params']['id']}})['then'](handleEntityNotFound(_0x33feba,null))['then'](removeEntity(_0x33feba,null))['catch'](handleError(_0x33feba,null));};exports[_0x1e81('0x4b')]=function(_0x1fb2e2,_0x398b00){return db[_0x1e81('0x2b')]['describe']()[_0x1e81('0x24')](respondWithResult(_0x398b00,null))['catch'](handleError(_0x398b00,null));};