2fd6ac1353d05424952467fe4018e3eb3bb76c75
[motion-next.git] / server / components / import / cm / csv.js
1 const a830_0x2dde=['SIGINT','info','query','parse','Missing\x20filepath\x20parameter!','birthDate','deletedAt\x20IS\x20NULL','scheduledAt','email','zipObject','keys','cm_contacts','Error\x20while\x20creating\x20contact:\x20','Missing\x20ListId\x20parameter!','data','split','str','phone\x20IS\x20NOT\x20NULL','finally','outbound','firstName\x20not\x20specified!','onlyIfOpen','test','lodash','../../../config/logger','cmContact','Error\x20executing\x20contact\x20csv\x20import:','ListId','from','VoiceQueue','CampaignId','index','Lists','phone','CSV\x20import\x20process\x20stopped!','argv','phone\x20not\x20specified!','fromQuery','duplicate','ContactId','VoiceQueueId','email\x20format\x20is\x20not\x20valid!','join','firstName','ListId\x20=\x20?','catch','moment','create','CSV\x20parsed\x20correctly!','pick','id\x20IN\x20?','then','calleridnum','Missing\x20binding\x20parameters!','birthDate\x20format\x20is\x20invalid,\x20YYYY-MM-DD\x20format\x20is\x20supported!','The\x20row\x20is\x20empty\x20or\x20the\x20number\x20of\x20parameters\x20does\x20not\x20match\x20the\x20columns!','unlinkSync','CSV\x20parse\x20error','map','null','where','updatedAt','phone\x20NOT\x20IN\x20(?)','select','CmList','Campaign','Duplicate\x20Contact','createdAt','BlackLists','toString','contact','exit','sequelize','all','CmContact','contact:csv_','always','papaparse','util','cm_hopper_black','squel','findAll','errors','Missing\x20socket_timestamp\x20parameter!','insert','length','Unable\x20to\x20delete\x20temp\x20file:','pause','stringify','field','undefined','dialCheckDuplicateType','NOW()','YYYY-MM-DD','error','resolve','register','../../../mysqldb','get','createReadStream','cm_hopper','into','push','\x20=\x20?'];(function(_0x124ee3,_0x2dde54){const _0x509253=function(_0x64b214){while(--_0x64b214){_0x124ee3['push'](_0x124ee3['shift']());}};_0x509253(++_0x2dde54);}(a830_0x2dde,0x11f));const a830_0x5092=function(_0x124ee3,_0x2dde54){_0x124ee3=_0x124ee3-0x0;let _0x509253=a830_0x2dde[_0x124ee3];return _0x509253;};const _0x48731f=a830_0x5092;'use strict';const util=require(_0x48731f('0x67')),_=require(_0x48731f('0x30')),fs=require('fs'),squel=require(_0x48731f('0x1')),Papa=require(_0x48731f('0x66')),moment=require(_0x48731f('0x47')),db=require(_0x48731f('0x12'))['db'],logger=require(_0x48731f('0x31'))('api'),{getSocket}=require('../../../rediscache'),socket=getSocket();require('../../../api/cmContact/cmContact.socket')[_0x48731f('0x11')](socket);let FILEPATH,FIELDS,LISTID,COMPANYID,DUPLICATES,SOCKET_TIMESTAMP;try{if(!process['argv'][0x2]||process['argv'][0x2]===_0x48731f('0xb')||process[_0x48731f('0x3c')][0x2]===_0x48731f('0x54'))throw new Error(_0x48731f('0x1d'));FILEPATH=process['argv'][0x2];if(!process[_0x48731f('0x3c')][0x3]||process[_0x48731f('0x3c')][0x3]===_0x48731f('0xb')||process['argv'][0x3]===_0x48731f('0x54')||!process[_0x48731f('0x3c')][0x4]||process[_0x48731f('0x3c')][0x4]===_0x48731f('0xb')||process[_0x48731f('0x3c')][0x4]===_0x48731f('0x54'))throw new Error(_0x48731f('0x4e'));FIELDS=_[_0x48731f('0x22')](process[_0x48731f('0x3c')][0x3][_0x48731f('0x28')](','),process['argv'][0x4][_0x48731f('0x28')](','));if(!process[_0x48731f('0x3c')][0x5]||process[_0x48731f('0x3c')][0x5]===_0x48731f('0xb')||process[_0x48731f('0x3c')][0x5]===_0x48731f('0x54'))throw new Error(_0x48731f('0x26'));LISTID=process[_0x48731f('0x3c')][0x5],COMPANYID=process[_0x48731f('0x3c')][0x6]&&process[_0x48731f('0x3c')][0x6]!==_0x48731f('0xb')&&process[_0x48731f('0x3c')][0x6]!==_0x48731f('0x54')?process[_0x48731f('0x3c')][0x6]:null,DUPLICATES=process[_0x48731f('0x3c')][0x7]&&process[_0x48731f('0x3c')][0x7]!=='undefined'&&process[_0x48731f('0x3c')][0x7]!==_0x48731f('0x54')?process[_0x48731f('0x3c')][0x7]:null;if(!process['argv'][0x8]||process[_0x48731f('0x3c')][0x8]==='undefined'||process[_0x48731f('0x3c')][0x8]===_0x48731f('0x54'))throw new Error(_0x48731f('0x4'));SOCKET_TIMESTAMP=process['argv'][0x8];}catch(a830_0x64b214){logger['error'](a830_0x64b214),endCsv();}let total=0x0,success=0x0,errors=0x0,duplicates=0x0,rows=[],hopperContacts='',promises=[];function handleCheckRowError(_0x12e089,_0xa1af50,_0x16dc96,_0x435492){const _0x50a567=_0x48731f,_0x775376={'message':_0xa1af50};return _0x775376[_0x12e089]=!![],_0x16dc96&&(_0x775376[_0x50a567('0x5f')]=_0x16dc96),_0x435492&&(_0x775376[_0x50a567('0x38')]=_0x435492),_0x775376;}function isEmail(_0x4a8685){const _0xe3154f=_0x48731f;return/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/[_0xe3154f('0x2f')](_0x4a8685);}function checkRow(_0x413e55,_0x586149,_0x58b8d6){return new Promise(function(_0x45c615,_0x5aa109){const _0x9ff258=a830_0x5092;if(_['isNil'](_0x413e55))return _0x5aa109(handleCheckRowError(_0x9ff258('0xf'),_0x9ff258('0x50'),null,_0x58b8d6));if(_0x413e55['errors']&&_0x413e55['errors'][_0x9ff258('0x6')]){const _0x12a752=_[_0x9ff258('0x53')](_0x413e55[_0x9ff258('0x3')],'message')[_0x9ff258('0x43')](';');return _0x5aa109(handleCheckRowError(_0x9ff258('0xf'),_0x12a752,null,_0x58b8d6));}const _0x3fc511={};for(const _0x29d85b in FIELDS){typeof FIELDS[_0x29d85b]!==_0x9ff258('0xb')&&FIELDS[_0x29d85b]&&(_0x3fc511[_0x29d85b]=_0x413e55[_0x9ff258('0x27')][0x0][FIELDS[_0x29d85b]]||_0x413e55[_0x9ff258('0x27')][0x0]['\ufeff'+FIELDS[_0x29d85b]]);}if(!_0x3fc511[_0x9ff258('0x44')])return _0x5aa109(handleCheckRowError('error',_0x9ff258('0x2d'),null,_0x58b8d6));if(!_0x3fc511['phone'])return _0x5aa109(handleCheckRowError(_0x9ff258('0xf'),_0x9ff258('0x3d'),null,_0x58b8d6));if(_0x3fc511[_0x9ff258('0x1e')]){const _0x24d656=moment(_0x3fc511['birthDate'],_0x9ff258('0xe'));if(!_0x24d656['isValid']())return _0x5aa109(handleCheckRowError('error',_0x9ff258('0x4f'),null,_0x58b8d6));}if(_0x3fc511[_0x9ff258('0x21')]){if(!isEmail(_0x3fc511[_0x9ff258('0x21')]))return _0x5aa109(handleCheckRowError(_0x9ff258('0xf'),_0x9ff258('0x42'),null,_0x58b8d6));}_0x3fc511[_0x9ff258('0x34')]=LISTID,_0x3fc511['CompanyId']=COMPANYID||undefined;if(DUPLICATES&&DUPLICATES[_0x9ff258('0x6')]&&_0x586149){const _0x47a5cd={};for(let _0x392745=0x0,_0x566e49=DUPLICATES[_0x9ff258('0x6')];_0x392745<_0x566e49;_0x392745+=0x1){_0x47a5cd[DUPLICATES[_0x392745]]=_0x3fc511[DUPLICATES[_0x392745]];}const _0x5f212d=_['find'](_0x586149,_0x47a5cd);if(_0x5f212d)return _0x5aa109(handleCheckRowError(_0x9ff258('0x3f'),_0x9ff258('0x5b'),_0x5f212d,_0x58b8d6));}return db[_0x9ff258('0x63')][_0x9ff258('0x48')](_0x3fc511,{'raw':!![],'hooks':![],'fields':_[_0x9ff258('0x23')](_0x3fc511)})['then'](function(_0x3d01d4){const _0x2f279f=_0x9ff258;return DUPLICATES&&DUPLICATES[_0x2f279f('0x6')]&&_0x586149&&_0x586149[_0x2f279f('0x17')](_[_0x2f279f('0x4a')](_0x3fc511,DUPLICATES)),hopperContacts+=(hopperContacts?',':'')+_0x3d01d4['id'],_0x45c615();})[_0x9ff258('0x46')](function(_0x1a2215){const _0x3caa8f=_0x9ff258;return _0x5aa109(handleCheckRowError(_0x3caa8f('0xf'),_0x3caa8f('0x25')+(_0x1a2215['message']||JSON['stringify'](_0x1a2215)),null,_0x58b8d6));});});}function checkHopper(){const _0x2160f0=_0x48731f;function _0x546c90(){return function(_0x47bcaf){const _0x3012fa=a830_0x5092;logger[_0x3012fa('0xf')](_0x3012fa('0x32'),'checkHopper',util['inspect'](_0x47bcaf,{'showHidden':![],'depth':null}));};}const _0x1ef6f5=function(_0x5e5a7e,_0x45ade5){const _0x45b444=a830_0x5092,_0x55c41f=squel['insert']()[_0x45b444('0x16')](_0x45b444('0x15'))['fromQuery']([_0x45b444('0x3a'),'scheduledAt',_0x45b444('0x40'),_0x45b444('0x34'),_0x45ade5,_0x45b444('0x5c'),_0x45b444('0x56')],squel['select']()[_0x45b444('0xa')](_0x45b444('0x3a'),'phone')[_0x45b444('0xa')]('NOW()',_0x45b444('0x20'))[_0x45b444('0xa')]('id','ContactId')[_0x45b444('0xa')](LISTID[_0x45b444('0x5e')](),_0x45b444('0x34'))[_0x45b444('0xa')](_0x5e5a7e['id'][_0x45b444('0x5e')](),_0x45ade5)[_0x45b444('0xa')](_0x45b444('0xd'),_0x45b444('0x5c'))[_0x45b444('0xa')](_0x45b444('0xd'),_0x45b444('0x56'))[_0x45b444('0x35')](_0x45b444('0x24'))[_0x45b444('0x55')](_0x45b444('0x1f'))[_0x45b444('0x55')](_0x45b444('0x45'),LISTID[_0x45b444('0x5e')]())[_0x45b444('0x55')](_0x45b444('0x2a'))['where']('phone\x20NOT\x20IN\x20(?)',squel[_0x45b444('0x58')]()[_0x45b444('0xa')]('phone')[_0x45b444('0x35')](_0x45b444('0x15'))[_0x45b444('0x55')](_0x45ade5+_0x45b444('0x18'),_0x5e5a7e['id'][_0x45b444('0x5e')]())))[_0x45b444('0x5e')]();return _0x55c41f;},_0x46f2f5=function(_0xc942e1,_0x5c1f78){const _0x5265cc=a830_0x5092,_0x1377a2=squel[_0x5265cc('0x5')]()['into'](_0x5265cc('0x15'))[_0x5265cc('0x3e')](['phone',_0x5265cc('0x20'),_0x5265cc('0x40'),_0x5265cc('0x34'),_0x5c1f78,_0x5265cc('0x5c'),'updatedAt'],squel[_0x5265cc('0x58')]()['field'](_0x5265cc('0x3a'),_0x5265cc('0x3a'))[_0x5265cc('0xa')](_0x5265cc('0xd'),_0x5265cc('0x20'))[_0x5265cc('0xa')]('id','ContactId')[_0x5265cc('0xa')](LISTID[_0x5265cc('0x5e')](),_0x5265cc('0x34'))[_0x5265cc('0xa')](_0xc942e1['id'][_0x5265cc('0x5e')](),_0x5c1f78)['field'](_0x5265cc('0xd'),_0x5265cc('0x5c'))[_0x5265cc('0xa')](_0x5265cc('0xd'),_0x5265cc('0x56'))[_0x5265cc('0x35')](_0x5265cc('0x24'))[_0x5265cc('0x55')](_0x5265cc('0x1f'))[_0x5265cc('0x55')](_0x5265cc('0x45'),LISTID[_0x5265cc('0x5e')]())[_0x5265cc('0x55')](_0x5265cc('0x4b'),squel[_0x5265cc('0x29')](hopperContacts))[_0x5265cc('0x55')](_0x5265cc('0x2a'))['where'](_0x5265cc('0x57'),squel[_0x5265cc('0x58')]()[_0x5265cc('0xa')](_0x5265cc('0x4d'))['from']('cm_hopper_final')[_0x5265cc('0x55')](_0x5c1f78+_0x5265cc('0x18'),_0xc942e1['id'][_0x5265cc('0x5e')]()))[_0x5265cc('0x55')](_0x5265cc('0x57'),squel[_0x5265cc('0x58')]()[_0x5265cc('0xa')](_0x5265cc('0x3a'))[_0x5265cc('0x35')](_0x5265cc('0x15'))['where'](_0x5c1f78+'\x20=\x20?',_0xc942e1['id'][_0x5265cc('0x5e')]())))[_0x5265cc('0x5e')]();return _0x1377a2;};function _0x40b4dc(_0x2bb68e,_0x4d4850){const _0x174e96=a830_0x5092,_0x4da70c=squel[_0x174e96('0x5')]()['into'](_0x174e96('0x15'))['fromQuery']([_0x174e96('0x3a'),_0x174e96('0x20'),_0x174e96('0x40'),_0x174e96('0x34'),_0x4d4850,'createdAt','updatedAt'],squel['select']()['field']('phone',_0x174e96('0x3a'))[_0x174e96('0xa')](_0x174e96('0xd'),_0x174e96('0x20'))[_0x174e96('0xa')]('id',_0x174e96('0x40'))['field'](LISTID['toString'](),_0x174e96('0x34'))[_0x174e96('0xa')](_0x2bb68e['id']['toString'](),_0x4d4850)['field'](_0x174e96('0xd'),_0x174e96('0x5c'))[_0x174e96('0xa')](_0x174e96('0xd'),_0x174e96('0x56'))[_0x174e96('0x35')](_0x174e96('0x24'))[_0x174e96('0x55')](_0x174e96('0x1f'))[_0x174e96('0x55')](_0x174e96('0x45'),LISTID['toString']())[_0x174e96('0x55')](_0x174e96('0x4b'),squel[_0x174e96('0x29')](hopperContacts))[_0x174e96('0x55')](_0x174e96('0x2a')))[_0x174e96('0x5e')]();return _0x4da70c;}function _0x5c4708(_0x44c7c8,_0x4646c2){const _0x542dcb=a830_0x5092,_0x4edf18=squel[_0x542dcb('0x5')]()[_0x542dcb('0x16')](_0x542dcb('0x0'))[_0x542dcb('0x3e')]([_0x542dcb('0x3a'),_0x542dcb('0x40'),_0x542dcb('0x34'),_0x4646c2,_0x542dcb('0x5c'),'updatedAt'],squel[_0x542dcb('0x58')]()[_0x542dcb('0xa')](_0x542dcb('0x3a'),_0x542dcb('0x3a'))['field']('id',_0x542dcb('0x40'))[_0x542dcb('0xa')](LISTID['toString'](),_0x542dcb('0x34'))['field'](_0x44c7c8['id'][_0x542dcb('0x5e')](),_0x4646c2)['field']('NOW()',_0x542dcb('0x5c'))[_0x542dcb('0xa')]('NOW()','updatedAt')['from'](_0x542dcb('0x24'))['where']('deletedAt\x20IS\x20NULL')[_0x542dcb('0x55')]('ListId\x20=\x20?',LISTID[_0x542dcb('0x5e')]())[_0x542dcb('0x55')](_0x542dcb('0x4b'),squel['str'](hopperContacts))[_0x542dcb('0x55')](_0x542dcb('0x2a')))['toString']();return _0x4edf18;}return db[_0x2160f0('0x36')]['findAll']({'where':{'type':_0x2160f0('0x2c')},'attributes':['id','dialCheckDuplicateType'],'include':[{'model':db['CmList'],'as':_0x2160f0('0x39'),'where':{'id':LISTID}}]})[_0x2160f0('0x4c')](function(_0x20166b){const _0x2266b7=_0x2160f0,_0x3b319e=[];if(_0x20166b)for(let _0x1f3241=0x0,_0x47a0fd;_0x1f3241<_0x20166b['length'];_0x1f3241+=0x1){_0x47a0fd=_0x20166b[_0x1f3241]['get']({'plain':!![]});switch(_0x47a0fd[_0x2266b7('0xc')]){case _0x2266b7('0x65'):_0x3b319e[_0x2266b7('0x17')](db[_0x2266b7('0x61')][_0x2266b7('0x1b')](_0x46f2f5(_0x47a0fd,_0x2266b7('0x41')))[_0x2266b7('0x4c')](function(){})[_0x2266b7('0x46')](_0x546c90()));break;case'onlyIfOpen':_0x3b319e[_0x2266b7('0x17')](db[_0x2266b7('0x61')][_0x2266b7('0x1b')](_0x1ef6f5(_0x47a0fd,_0x2266b7('0x41')))[_0x2266b7('0x4c')](function(){})['catch'](_0x546c90()));break;default:_0x3b319e[_0x2266b7('0x17')](db[_0x2266b7('0x61')][_0x2266b7('0x1b')](_0x40b4dc(_0x47a0fd,_0x2266b7('0x41')))['then'](function(){})[_0x2266b7('0x46')](_0x546c90()));}}return _0x3b319e;})[_0x2160f0('0x62')]()[_0x2160f0('0x4c')](function(){const _0x5667e5=_0x2160f0;return db['VoiceQueue']['findAll']({'where':{'type':_0x5667e5('0x2c')},'attributes':['id'],'include':[{'model':db[_0x5667e5('0x59')],'as':_0x5667e5('0x5d'),'where':{'id':LISTID}}]})[_0x5667e5('0x4c')](function(_0x1f713b){const _0x4eb697=_0x5667e5,_0x1f91d7=[];if(_0x1f713b)for(let _0x1ca910=0x0,_0x3c716c;_0x1ca910<_0x1f713b[_0x4eb697('0x6')];_0x1ca910+=0x1){_0x3c716c=_0x1f713b[_0x1ca910][_0x4eb697('0x13')]({'plain':!![]}),_0x1f91d7['push'](db[_0x4eb697('0x61')][_0x4eb697('0x1b')](_0x5c4708(_0x3c716c,_0x4eb697('0x41')))['then'](function(){})[_0x4eb697('0x46')](_0x546c90()));}return _0x1f91d7;})[_0x5667e5('0x62')]();})[_0x2160f0('0x4c')](function(){const _0x518356=_0x2160f0;return db[_0x518356('0x5a')][_0x518356('0x2')]({'attributes':['id',_0x518356('0xc')],'include':[{'model':db[_0x518356('0x59')],'as':_0x518356('0x39'),'where':{'id':LISTID}}]})[_0x518356('0x4c')](function(_0x642ab7){const _0x1bd957=_0x518356,_0x4c3a25=[];if(_0x642ab7)for(let _0x44dcd1=0x0,_0x1eaaec;_0x44dcd1<_0x642ab7['length'];_0x44dcd1+=0x1){_0x1eaaec=_0x642ab7[_0x44dcd1][_0x1bd957('0x13')]({'plain':!![]});switch(_0x1eaaec[_0x1bd957('0xc')]){case _0x1bd957('0x65'):_0x4c3a25[_0x1bd957('0x17')](db['sequelize'][_0x1bd957('0x1b')](_0x46f2f5(_0x1eaaec,_0x1bd957('0x37')))['then'](function(){})['catch'](_0x546c90()));break;case _0x1bd957('0x2e'):_0x4c3a25['push'](db[_0x1bd957('0x61')][_0x1bd957('0x1b')](_0x1ef6f5(_0x1eaaec,'CampaignId'))[_0x1bd957('0x4c')](function(){})[_0x1bd957('0x46')](_0x546c90()));break;default:_0x4c3a25[_0x1bd957('0x17')](db['sequelize'][_0x1bd957('0x1b')](_0x40b4dc(_0x1eaaec,_0x1bd957('0x37')))[_0x1bd957('0x4c')](function(){})[_0x1bd957('0x46')](_0x546c90()));}}return _0x4c3a25;})[_0x518356('0x62')]();})[_0x2160f0('0x4c')](function(){const _0x5f12a4=_0x2160f0;return db['Campaign']['findAll']({'attributes':['id'],'include':[{'model':db[_0x5f12a4('0x59')],'as':_0x5f12a4('0x5d'),'where':{'id':LISTID}}]})[_0x5f12a4('0x4c')](function(_0x4137c1){const _0x44dfd6=_0x5f12a4,_0x59a92a=[];if(_0x4137c1)for(let _0x551932=0x0,_0x1d4bc3;_0x551932<_0x4137c1[_0x44dfd6('0x6')];_0x551932+=0x1){_0x1d4bc3=_0x4137c1[_0x551932]['get']({'plain':!![]}),_0x59a92a[_0x44dfd6('0x17')](db['sequelize'][_0x44dfd6('0x1b')](_0x5c4708(_0x1d4bc3,_0x44dfd6('0x37')))['then'](function(){})[_0x44dfd6('0x46')](_0x546c90()));}return _0x59a92a;})[_0x5f12a4('0x62')]();})['catch'](function(_0x5179fe){logger['error']('cmContact,\x20%s,\x20%s','generalCheckHopper',_0x5179fe['message']);});}const processPromises=function(_0x246d36){const _0x5de198=_0x48731f;return Promise[_0x5de198('0x62')](promises)[_0x5de198('0x46')](function(_0x407201){const _0xdbfcef=_0x5de198;logger[_0xdbfcef('0xf')]('Error\x20processing\x20rows\x20block:',JSON[_0xdbfcef('0x9')](_0x407201));})[_0x5de198('0x2b')](function(){socket['emit']('contact:csv_'+SOCKET_TIMESTAMP,{'success':success,'errors':errors,'duplicates':duplicates,'rows':rows}),promises=[],success=0x0,errors=0x0,duplicates=0x0,rows=[];if(_0x246d36)return _0x246d36['resume']();});},endCsv=function(){const _0x21a975=_0x48731f;return Promise[_0x21a975('0x10')]()[_0x21a975('0x4c')](function(){if(hopperContacts)return checkHopper();})[_0x21a975('0x4c')](function(){const _0x310edf=_0x21a975;socket['emit'](_0x310edf('0x64')+SOCKET_TIMESTAMP,{'finished':!![],'success':success,'errors':errors,'duplicates':duplicates,'rows':rows});try{fs[_0x310edf('0x51')](FILEPATH);}catch(_0x13e473){logger[_0x310edf('0xf')](_0x310edf('0x7'),JSON[_0x310edf('0x9')](_0x13e473));}finally{process[_0x310edf('0x60')](0x0);}});};process['on'](_0x48731f('0x19'),function(){const _0x44567c=_0x48731f;logger['info'](_0x44567c('0x3b')),endCsv();});function main(){const _0x5afb0e=_0x48731f;return Promise[_0x5afb0e('0x10')]()[_0x5afb0e('0x4c')](function(){const _0x458058=_0x5afb0e;if(DUPLICATES)return DUPLICATES=DUPLICATES[_0x458058('0x28')](','),db[_0x458058('0x63')]['findAll']({'where':{'ListId':LISTID},'attributes':DUPLICATES,'raw':!![]});})[_0x5afb0e('0x4c')](function(_0x797343){const _0x5c35ea=_0x5afb0e,_0x8b115d=fs[_0x5c35ea('0x14')](FILEPATH,{'highWaterMark':0xf*0x400*0x400});Papa[_0x5c35ea('0x1c')](_0x8b115d,{'header':!![],'skipEmptyLines':!![],'step':function(_0x5d623b,_0x2e4e71){const _0x3fdafe=_0x5c35ea;total+=0x1;const _0x20922e=total;promises[_0x3fdafe('0x17')](checkRow(_0x5d623b,_0x797343,_0x20922e)[_0x3fdafe('0x4c')](function(){success+=0x1;})[_0x3fdafe('0x46')](function(_0x1a6008){const _0x224eaa=_0x3fdafe;if(_0x1a6008[_0x224eaa('0xf')])errors+=0x1,delete _0x1a6008[_0x224eaa('0xf')];else _0x1a6008[_0x224eaa('0x3f')]&&(duplicates+=0x1,delete _0x1a6008[_0x224eaa('0x3f')]);rows['push'](_0x1a6008);}));if(total%0xc8===0x0)return _0x2e4e71[_0x3fdafe('0x8')](),processPromises(_0x2e4e71);},'complete':function(){const _0x9cb9fb=_0x5c35ea;return processPromises()[_0x9cb9fb('0x4c')](function(){const _0x19375f=_0x9cb9fb;logger[_0x19375f('0x1a')](_0x19375f('0x49')),endCsv();});},'error':function(_0x92e949){const _0x438441=_0x5c35ea;logger[_0x438441('0x1a')](_0x438441('0x52'),JSON[_0x438441('0x9')](_0x92e949)),endCsv();}});})[_0x5afb0e('0x46')](function(_0x3990c4){const _0x2efb31=_0x5afb0e;logger[_0x2efb31('0xf')](_0x2efb31('0x33'),JSON[_0x2efb31('0x9')](_0x3990c4));});}main();