3f8c7258cfd70212c3a9fa7f839b2f6ac4de839b
[motion2.git] / server / api / userProfile / userProfile.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x62cc=['chatwebsites','ChatWebsite','faxqueues','FaxQueue','faxaccounts','FaxAccount','inboundroutes','internalroutes','outboundroutes','VoiceExtension','VoiceMail','voicerecordings','VoiceRecording','Agents','role','agent','Telephones','membername','User','telephone','VoiceQueues','VoiceQueue','inbound','QueueCampaigns','outbound','musiconholds','VoiceMusicOnHold','VoiceChanSpy','MailQueue','mailaccounts','mailsubstatuses','MailSubstatus','OpenchannelQueue','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','smsaccounts','SmsAccount','whatsappqueues','WhatsappAccount','teams','Team','voicequeues','queuecampaigns','users','agents','telephones','Users','admin','ZendeskAccount','salesforceaccounts','SalesforceAccount','freshdeskaccounts','sugarcrmaccounts','SugarcrmAccount','DeskAccount','zohoaccounts','ZohoAccount','vtigeraccounts','cannedanswers','Disposition','customdashboards','Dashboard','intervals','Interval','pauses','Pause','sounds','Sound','tags','Tag','templates','Template','triggers','Trigger','trunks','variables','Variable','extractedreports','metrics','charAt','toUpperCase','slice','Sequelize','QueryTypes','SELECT','select','InteractionId','ui.createdAt','from','user_has_','sequelize','query','toString','define','UserProfile','user_profiles','../../components/parsers/qs','mergeResources','Invalid\x20section\x20\x27','length','push','UserProfileSection','find','params','all','isEmpty','union','ignore','autoAssociation','rawAttributes','keys','attributes','intersection','fields','hasOwnProperty','nolimit','limit','offset','order','sort','filters','where','VIRTUAL','foreignKey','merge','options','includeAll','include','reportType','default','reportId','custom','rows','ids','customSorting','extraQueryConditions','count','Tags','tag','ThroughTags','color','openTabs','true','chat','dataValues','sms','fax','openchannel','whatsapp','lodash','./userProfile.attributes','squel','exports','models','filter','field','value','findAll','then','associatedResources','map','catch','model','name','AnalyticExtractedReport','type','resourceId','toLowerCase','squareprojects','childModel','odbc','SquareOdbc','squarerecordings','SquareRecording','parentSections','SquareProjects','JscriptyProject','contacts','CmContact','Lists','ListId','lists','companies','CmCompany','globalcustomfields','CmCustomField'];(function(_0x45f06d,_0x27c585){var _0x465e68=function(_0x1e6e5d){while(--_0x1e6e5d){_0x45f06d['push'](_0x45f06d['shift']());}};_0x465e68(++_0x27c585);}(_0x62cc,0x153));var _0xc62c=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x62cc[_0x3dd15e];return _0x231fd0;};'use strict';var _=require(_0xc62c('0x0'));var attributes=require(_0xc62c('0x1'));var squel=require(_0xc62c('0x2'));module[_0xc62c('0x3')]=function(_0x168558){var _0x20fe75=_0x168558[_0xc62c('0x4')];function _0xc574f3(_0x706df0,_0x4a7c3c){return new Promise(function(_0x3538e8,_0x4a2fe4){if(!_0x4a7c3c)return _0x3538e8(null);var _0x2ce5fa=_0x4a7c3c[_0xc62c('0x5')]?{[_0x4a7c3c[_0xc62c('0x5')][_0xc62c('0x6')]]:_0x4a7c3c['filter'][_0xc62c('0x7')]}:undefined;return _0x20fe75[_0x706df0][_0xc62c('0x8')]({'where':_0x2ce5fa,'raw':!![]})[_0xc62c('0x9')](function(_0x479f8b){_0x4a7c3c[_0xc62c('0xa')]=_[_0xc62c('0xb')](_0x479f8b,'id');_0x3538e8(_0x4a7c3c);})[_0xc62c('0xc')](function(_0xf0fdc2){_0x4a2fe4(_0xf0fdc2);});});}function _0xde6e8d(_0x4e19bb,_0x5b6391){return new Promise(function(_0x3ccdda,_0x34caad){var _0x2abe17=_0x4e19bb[_0xc62c('0x5')]?{[_0x4e19bb[_0xc62c('0x5')][_0xc62c('0x6')]]:_0x4e19bb[_0xc62c('0x5')]['value']}:undefined;return _0x20fe75[_0x4e19bb[_0xc62c('0xd')]][_0xc62c('0x8')]({'where':_0x2abe17,'raw':!![]})[_0xc62c('0x9')](function(_0x552db4){_0x5b6391[_0xc62c('0xa')]=_['map'](_0x552db4,function(_0x2d6ce7){return _0x2d6ce7[_0xc62c('0xe')];});_0x3ccdda(_0x5b6391);})['catch'](function(_0x1fdff3){_0x34caad(_0x1fdff3);});});}function _0x2dfe50(_0xb27184,_0x88525f,_0x33410c){if(!_0x88525f)return Promise['resolve'](null);return new Promise(function(_0x1180a9,_0x2b0a92){return _0x20fe75['UserProfileResource'][_0xc62c('0x8')]({'where':{'sectionId':_0x88525f['id']},'raw':!![]})[_0xc62c('0x9')](function(_0x390d0a){if(_0xb27184[_0xc62c('0x6')]&&_0xb27184[_0xc62c('0x6')]!=='id'){_0x88525f[_0xc62c('0xa')]=_[_0xc62c('0xb')](_0x390d0a,function(_0x370a82){return _0x370a82[_0xb27184[_0xc62c('0x6')]];});}else{if(_0x33410c===_0xc62c('0xf')){_0x88525f['associatedResources']=_[_0xc62c('0xb')](_0x390d0a,function(_0x196c50){return{'id':_0x196c50['resourceId'],'type':_0x196c50[_0xc62c('0x10')]};});}else{_0x88525f[_0xc62c('0xa')]=_['map'](_0x390d0a,function(_0x30e5a2){return _0x30e5a2[_0xc62c('0x11')];});}}_0x1180a9(_0x88525f);})[_0xc62c('0xc')](function(_0xf2810d){_0x2b0a92(_0xf2810d);});});}function _0x42cbcf(_0x4f1ef2,_0x160d2d){var _0x2058f8={'parentSections':[]};switch(_0x4f1ef2[_0xc62c('0x12')]()){case _0xc62c('0x13'):_0x2058f8[_0xc62c('0x14')]='SquareProject';break;case _0xc62c('0x15'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x16');break;case _0xc62c('0x17'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x18');_0x2058f8[_0xc62c('0x19')]=[{'name':_0xc62c('0x1a'),'field':_0xc62c('0xe'),'foreignKey':'projectName'}];break;case'projects':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x1b');break;case _0xc62c('0x1c'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x1d');_0x2058f8[_0xc62c('0x19')]=[{'name':_0xc62c('0x1e'),'field':'id','foreignKey':_0xc62c('0x1f')}];break;case _0xc62c('0x20'):_0x2058f8[_0xc62c('0x14')]='CmList';break;case _0xc62c('0x21'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x22');break;case _0xc62c('0x23'):_0x2058f8['childModel']=_0xc62c('0x24');break;case'chatqueues':_0x2058f8[_0xc62c('0x14')]='ChatQueue';break;case _0xc62c('0x25'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x26');break;case _0xc62c('0x27'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x28');break;case _0xc62c('0x29'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x2a');break;case _0xc62c('0x2b'):case _0xc62c('0x2c'):case _0xc62c('0x2d'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x2e');break;case'contexts':_0x2058f8[_0xc62c('0x14')]='VoiceContext';break;case'voicemails':_0x2058f8['childModel']=_0xc62c('0x2f');break;case _0xc62c('0x30'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x31');_0x2058f8[_0xc62c('0x19')]=[{'name':_0xc62c('0x32'),'field':_0xc62c('0xe'),'foreignKey':'membername','model':'User','filter':{'field':_0xc62c('0x33'),'value':[_0xc62c('0x34')]}},{'name':_0xc62c('0x35'),'field':'name','foreignKey':_0xc62c('0x36'),'model':_0xc62c('0x37'),'filter':{'field':_0xc62c('0x33'),'value':[_0xc62c('0x38')]}},{'name':_0xc62c('0x39'),'field':'name','foreignKey':'queue','model':_0xc62c('0x3a'),'filter':{'field':_0xc62c('0x10'),'value':[_0xc62c('0x3b')]}},{'name':_0xc62c('0x3c'),'field':_0xc62c('0xe'),'foreignKey':'queue','model':_0xc62c('0x3a'),'filter':{'field':'type','value':[_0xc62c('0x3d')]}}];break;case _0xc62c('0x3e'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x3f');break;case'chanspies':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x40');break;case'voiceprefixes':_0x2058f8[_0xc62c('0x14')]='VoicePrefix';break;case'ivrcampaigns':_0x2058f8[_0xc62c('0x14')]='Campaign';break;case'mailqueues':_0x2058f8['childModel']=_0xc62c('0x41');break;case _0xc62c('0x42'):_0x2058f8['childModel']='MailAccount';break;case _0xc62c('0x43'):_0x2058f8['childModel']=_0xc62c('0x44');break;case'openchannelqueues':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x45');break;case _0xc62c('0x46'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x47');break;case _0xc62c('0x48'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x49');break;case _0xc62c('0x4a'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x4b');break;case _0xc62c('0x4c'):_0x2058f8[_0xc62c('0x14')]='WhatsappQueue';break;case'whatsappaccounts':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x4d');break;case _0xc62c('0x4e'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x4f');break;case _0xc62c('0x50'):case _0xc62c('0x51'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x3a');if(_0x160d2d){_0x2058f8[_0xc62c('0x19')]=[{'name':_0xc62c('0x39')},{'name':_0xc62c('0x3c')}];}break;case _0xc62c('0x52'):case _0xc62c('0x53'):case _0xc62c('0x54'):_0x2058f8[_0xc62c('0x14')]='User';if(_0x160d2d){_0x2058f8['parentSections']=[{'name':_0xc62c('0x55'),'filter':{'field':_0xc62c('0x33'),'value':[_0xc62c('0x56'),'user']},'ignore':!![]},{'name':_0xc62c('0x32')},{'name':_0xc62c('0x35')}];}break;case'zendeskaccounts':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x57');break;case _0xc62c('0x58'):_0x2058f8['childModel']=_0xc62c('0x59');break;case _0xc62c('0x5a'):_0x2058f8['childModel']='FreshdeskAccount';break;case _0xc62c('0x5b'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x5c');break;case'deskaccounts':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x5d');break;case _0xc62c('0x5e'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x5f');break;case _0xc62c('0x60'):_0x2058f8['childModel']=_0xc62c('0x37');break;case _0xc62c('0x61'):_0x2058f8[_0xc62c('0x14')]='CannedAnswer';break;case'dispositions':_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x62');break;case _0xc62c('0x63'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x64');break;case _0xc62c('0x65'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x66');break;case _0xc62c('0x67'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x68');break;case'scheduler':_0x2058f8['childModel']='Schedule';break;case _0xc62c('0x69'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x6a');break;case _0xc62c('0x6b'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x6c');break;case _0xc62c('0x6d'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x6e');break;case _0xc62c('0x6f'):_0x2058f8[_0xc62c('0x14')]=_0xc62c('0x70');break;case _0xc62c('0x71'):_0x2058f8['childModel']='Trunk';break;case _0xc62c('0x72'):_0x2058f8['childModel']=_0xc62c('0x73');break;case'plugins':_0x2058f8['childModel']='Plugin';break;case _0xc62c('0x74'):_0x2058f8[_0xc62c('0x14')]='AnalyticExtractedReport';_0x2058f8[_0xc62c('0x19')]=[{'name':'Reports','field':'id','foreignKey':'reportId'}];break;case _0xc62c('0x75'):_0x2058f8[_0xc62c('0x14')]='AnalyticMetric';break;}return _0x2058f8;}function _0x168c74(_0x427aa8,_0x4f14e3){var _0x293c0d=_0x427aa8[_0xc62c('0x76')](0x0)[_0xc62c('0x77')]()+_0x427aa8[_0xc62c('0x78')](0x1);var _0x35b1f8={'type':_0x20fe75[_0xc62c('0x79')][_0xc62c('0x7a')][_0xc62c('0x7b')],'raw':!![]};return new Promise(function(_0x4f6b35,_0x14f15b){var _0xec49ed=squel[_0xc62c('0x7c')]()[_0xc62c('0x6')]('ui.'+_0x293c0d+_0xc62c('0x7d'),'id')[_0xc62c('0x6')](_0xc62c('0x7e'))[_0xc62c('0x7f')](_0xc62c('0x80')+_0x427aa8+'_interactions','ui')['where']('ui.UserId\x20=\x20?',_0x4f14e3['id']);return _0x20fe75[_0xc62c('0x81')][_0xc62c('0x82')](_0xec49ed[_0xc62c('0x83')](),_0x35b1f8)[_0xc62c('0x9')](function(_0x36de65){_0x4f14e3[_0x293c0d+'OpenTabs']=_0x36de65;_0x4f6b35(_0x36de65);})[_0xc62c('0xc')](function(_0x140451){_0x14f15b(_0x140451);});});}return _0x168558[_0xc62c('0x84')](_0xc62c('0x85'),attributes,{'tableName':_0xc62c('0x86'),'paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x55848a){var _0x18d9b7=require(_0xc62c('0x87'));var _0x1e7aab={'raw':_0x55848a[_0xc62c('0x82')]['raw'],'where':{}};var _0x4f3e5b={};var _0x4fc14b={'count':0x0,'rows':[]};var _0x223ba5=_0x55848a[_0xc62c('0x82')]['section'];var _0x5ab561=_0x55848a['query'][_0xc62c('0x88')]||![];var _0xf1731a=_0x42cbcf(_0x223ba5,_0x5ab561);if(!_0xf1731a[_0xc62c('0x14')])throw new Error(_0xc62c('0x89')+_0x223ba5+'\x27');var _0x197899=[{'name':_0x223ba5}];if(!_['isEmpty'](_0xf1731a[_0xc62c('0x19')]))_0x197899=_0xf1731a['parentSections'];var _0x2ccdb7=[];for(var _0x333be2=0x0;_0x333be2<_0x197899[_0xc62c('0x8a')];_0x333be2++){_0x2ccdb7[_0xc62c('0x8b')](_0x20fe75[_0xc62c('0x8c')][_0xc62c('0x8d')]({'where':{'userProfileId':_0x55848a[_0xc62c('0x8e')]['id'],'name':_0x197899[_0x333be2][_0xc62c('0xe')]},'raw':!![]}));}return Promise[_0xc62c('0x8f')](_0x2ccdb7)[_0xc62c('0x9')](function(_0xedcd7){var _0x355eff=_[_0xc62c('0x5')](_0xedcd7,function(_0x1b8d87){return _0x1b8d87?_0x1b8d87:undefined;});var _0x94e30d=_['filter'](_0x197899,['ignore',!![]]);var _0x38f8ef=_['isEmpty'](_0x355eff)&&_[_0xc62c('0x90')](_0x94e30d)?null:_[_0xc62c('0x91')](_0x94e30d,_0x355eff);if(!_0x38f8ef)return null;var _0x50e909=[];for(var _0x4e4a18=0x0;_0x4e4a18<_0x38f8ef[_0xc62c('0x8a')];_0x4e4a18++){var _0x2f2c03=_[_0xc62c('0x8d')](_0x197899,function(_0x20f18e){return _0x38f8ef[_0x4e4a18]?_0x20f18e['name']===_0x38f8ef[_0x4e4a18][_0xc62c('0xe')]:null;});if(_0x2f2c03){if(_0x38f8ef[_0x4e4a18][_0xc62c('0x92')]){_0x50e909[_0xc62c('0x8b')](_0xc574f3(_0xf1731a[_0xc62c('0x14')],_0x38f8ef[_0x4e4a18]));}else{if(!_0x38f8ef[_0x4e4a18][_0xc62c('0x93')]){_0x50e909[_0xc62c('0x8b')](_0x2dfe50(_0x2f2c03,_0x38f8ef[_0x4e4a18],_0xf1731a[_0xc62c('0x14')]));}else{if(_0x2f2c03['model']){_0x50e909[_0xc62c('0x8b')](_0xde6e8d(_0x2f2c03,_0x38f8ef[_0x4e4a18]));}}}}}return Promise[_0xc62c('0x8f')](_0x50e909);})['then'](function(_0x1eada7){var _0x171d9a=_0x1eada7;var _0xb5da86=null;if(_0x171d9a){_0xb5da86=_0x171d9a['length']===0x1?_0x171d9a[0x0]:null;}if(!_0xb5da86&&!_0x171d9a)return _0x4fc14b;var _0x332f4b=_0x20fe75[_0xf1731a[_0xc62c('0x14')]][_0xc62c('0x94')];_0x4f3e5b[_0xc62c('0xd')]=_[_0xc62c('0x95')](_0x332f4b);_0x4f3e5b[_0xc62c('0x82')]=_[_0xc62c('0x95')](_0x55848a['query']);_0x4f3e5b['filters']=_['intersection'](_0x4f3e5b[_0xc62c('0xd')],_0x4f3e5b[_0xc62c('0x82')]);_0x1e7aab[_0xc62c('0x96')]=_[_0xc62c('0x97')](_0x4f3e5b[_0xc62c('0xd')],_0x18d9b7[_0xc62c('0x98')](_0x55848a[_0xc62c('0x82')]['fields']));_0x1e7aab[_0xc62c('0x96')]=_0x1e7aab[_0xc62c('0x96')][_0xc62c('0x8a')]?_0x1e7aab[_0xc62c('0x96')]:_0x4f3e5b[_0xc62c('0xd')];if(!_0x55848a[_0xc62c('0x82')][_0xc62c('0x99')](_0xc62c('0x9a'))){_0x1e7aab[_0xc62c('0x9b')]=_0x18d9b7[_0xc62c('0x9b')](_0x55848a[_0xc62c('0x82')][_0xc62c('0x9b')]);_0x1e7aab[_0xc62c('0x9c')]=_0x18d9b7[_0xc62c('0x9c')](_0x55848a[_0xc62c('0x82')][_0xc62c('0x9c')]);}_0x1e7aab[_0xc62c('0x9d')]=_0x18d9b7[_0xc62c('0x9e')](_0x55848a[_0xc62c('0x82')][_0xc62c('0x9e')]);_0x1e7aab['where']=_0x18d9b7[_0xc62c('0x9f')](_['pick'](_0x55848a[_0xc62c('0x82')],_0x4f3e5b[_0xc62c('0x9f')]));if(_0x55848a[_0xc62c('0x82')][_0xc62c('0x5')]){_0x1e7aab['where']=_['merge'](_0x1e7aab[_0xc62c('0xa0')],{'$or':_[_0xc62c('0xb')](_0x332f4b,function(_0x4e219c){if(_0x4e219c[_0xc62c('0x10')]['key']!==_0xc62c('0xa1')){var _0x4815cc={};_0x4815cc[_0x4e219c[_0xc62c('0x6')]]={'$like':'%'+_0x55848a['query'][_0xc62c('0x5')]+'%'};return _0x4815cc;}})});}var _0x215ccd=[];var _0x2069d1=null;var _0x32bc50={};if(_0xb5da86){_0x2069d1=_[_0xc62c('0x8d')](_0x197899,['name',_0xb5da86[_0xc62c('0xe')]]);if(_0x2069d1[_0xc62c('0x6')]){_0x32bc50={};if(_0xf1731a[_0xc62c('0x14')]===_0xc62c('0xf')){_0x32bc50[_0x2069d1[_0xc62c('0xa2')]]=_['map'](_0xb5da86[_0xc62c('0xa')],'id');}else{_0x32bc50[_0x2069d1['foreignKey']]=_0xb5da86[_0xc62c('0xa')];}_0x215ccd[_0xc62c('0x8b')](_0x32bc50);}else{_0x1e7aab[_0xc62c('0xa0')]['id']=_0xb5da86[_0xc62c('0xa')];}}else{for(var _0x5001d4=0x0;_0x5001d4<_0x171d9a[_0xc62c('0x8a')];_0x5001d4++){_0x2069d1=_[_0xc62c('0x8d')](_0x197899,[_0xc62c('0xe'),_0x171d9a[_0x5001d4]['name']]);if(_0x2069d1[_0xc62c('0x6')]){_0x32bc50={};_0x32bc50[_0x2069d1[_0xc62c('0xa2')]]=_0x171d9a[_0x5001d4][_0xc62c('0xa')];_0x215ccd['push'](_0x32bc50);}else{if(!_0x1e7aab[_0xc62c('0xa0')]['id'])_0x1e7aab[_0xc62c('0xa0')]['id']=[];_0x171d9a[_0x5001d4]['associatedResources']['forEach'](function(_0x113224){_0x1e7aab[_0xc62c('0xa0')]['id'][_0xc62c('0x8b')](_0x113224);});}}}if(!_[_0xc62c('0x90')](_0x215ccd)){_0x1e7aab[_0xc62c('0xa0')]=_[_0xc62c('0xa3')](_0x1e7aab[_0xc62c('0xa0')],{'$and':{'$or':_0x215ccd}});}_0x1e7aab=_[_0xc62c('0xa3')]({},_0x1e7aab,_0x55848a[_0xc62c('0xa4')]);if(_0xb5da86&&!_0xb5da86[_0xc62c('0x93')]&&_0xf1731a[_0xc62c('0x14')]===_0xc62c('0xf')){if(_0x55848a[_0xc62c('0x82')][_0xc62c('0xa5')]){_0x1e7aab[_0xc62c('0xa6')]=[{'all':!![]}];}return _0x20fe75[_0xf1731a['childModel']][_0xc62c('0x8')](_0x1e7aab)[_0xc62c('0x9')](function(_0x3a23e5){var _0x280a96=[];_0x3a23e5['forEach'](function(_0x4e8bb4){var _0x4cbe56;switch(_0x4e8bb4[_0xc62c('0xa7')]){case _0xc62c('0xa8'):_0x4cbe56=_[_0xc62c('0x8d')](_0xb5da86['associatedResources'],function(_0x5d7d67){return _0x5d7d67['id']===_0x4e8bb4[_0xc62c('0xa9')]&&_0x5d7d67['type']==='DefaultReports';});break;case _0xc62c('0xaa'):_0x4cbe56=_['find'](_0xb5da86[_0xc62c('0xa')],function(_0x1a7ab8){return _0x1a7ab8['id']===_0x4e8bb4[_0xc62c('0xa9')]&&_0x1a7ab8[_0xc62c('0x10')]==='CustomReports';});break;}if(_0x4cbe56)_0x280a96[_0xc62c('0x8b')](_0x4e8bb4);});_0x4fc14b['count']=_0x280a96[_0xc62c('0x8a')];_0x4fc14b[_0xc62c('0xab')]=_0x280a96;return _0x4fc14b;});}else{if(!_[_0xc62c('0x90')](_0x55848a[_0xc62c('0x82')][_0xc62c('0xac')])){_0x1e7aab[_0xc62c('0xa0')]['id']=_0x1e7aab[_0xc62c('0xa0')]['id']?_[_0xc62c('0x97')](_0x1e7aab['where']['id'],_0x55848a[_0xc62c('0x82')]['ids']):_0x55848a[_0xc62c('0x82')][_0xc62c('0xac')];if(_0x55848a['query'][_0xc62c('0xad')]){_0x1e7aab['order']=_0x55848a['query']['customSorting'];}}if(_0x55848a[_0xc62c('0x82')][_0xc62c('0xae')]){_0x1e7aab[_0xc62c('0xa0')]=_['merge'](_0x1e7aab[_0xc62c('0xa0')],{'$and':_0x55848a[_0xc62c('0x82')][_0xc62c('0xae')]});}return _0x20fe75[_0xf1731a[_0xc62c('0x14')]][_0xc62c('0xaf')]({'where':_0x1e7aab[_0xc62c('0xa0')]})[_0xc62c('0x9')](function(_0x654382){_0x4fc14b[_0xc62c('0xaf')]=_0x654382;if(_0x55848a['query'][_0xc62c('0xa5')]){if(_0xf1731a[_0xc62c('0x14')]===_0xc62c('0x1d')){_0x1e7aab[_0xc62c('0xa6')]=[{'model':_0x20fe75[_0xc62c('0x6c')],'as':_0xc62c('0xb0'),'attributes':['id','name','color'],'required':_0x55848a[_0xc62c('0x82')][_0xc62c('0xb1')]?!![]:![]},{'model':_0x20fe75[_0xc62c('0x6c')],'as':_0xc62c('0xb2'),'attributes':['id','name',_0xc62c('0xb3')],'through':_0x55848a[_0xc62c('0x82')][_0xc62c('0xb1')]?{'attributes':[],'where':{'TagId':_0x55848a[_0xc62c('0x82')]['tag']||undefined}}:{},'required':_0x55848a[_0xc62c('0x82')][_0xc62c('0xb1')]?!![]:![]}];}else{_0x1e7aab[_0xc62c('0xa6')]=[{'all':!![]}];}}return _0x20fe75[_0xf1731a[_0xc62c('0x14')]]['findAll'](_0x1e7aab);})[_0xc62c('0x9')](function(_0x1e01bf){_0x4fc14b[_0xc62c('0xab')]=_0x1e01bf;if(_0x223ba5===_0xc62c('0x32')&&_0x55848a[_0xc62c('0x82')][_0xc62c('0xb4')]===_0xc62c('0xb5')){var _0x5be7f0=[];for(var _0x2c4a16=0x0;_0x2c4a16<_0x4fc14b[_0xc62c('0xab')]['length'];_0x2c4a16++){_0x5be7f0[_0xc62c('0x8b')](_0x168c74(_0xc62c('0xb6'),_0x4fc14b['rows'][_0x2c4a16][_0xc62c('0xb7')]));_0x5be7f0[_0xc62c('0x8b')](_0x168c74(_0xc62c('0xb8'),_0x4fc14b[_0xc62c('0xab')][_0x2c4a16]['dataValues']));_0x5be7f0['push'](_0x168c74(_0xc62c('0xb9'),_0x4fc14b[_0xc62c('0xab')][_0x2c4a16][_0xc62c('0xb7')]));_0x5be7f0[_0xc62c('0x8b')](_0x168c74('mail',_0x4fc14b[_0xc62c('0xab')][_0x2c4a16][_0xc62c('0xb7')]));_0x5be7f0[_0xc62c('0x8b')](_0x168c74(_0xc62c('0xba'),_0x4fc14b[_0xc62c('0xab')][_0x2c4a16][_0xc62c('0xb7')]));_0x5be7f0[_0xc62c('0x8b')](_0x168c74(_0xc62c('0xbb'),_0x4fc14b[_0xc62c('0xab')][_0x2c4a16][_0xc62c('0xb7')]));}return Promise[_0xc62c('0x8f')](_0x5be7f0)[_0xc62c('0x9')](function(){return _0x4fc14b;});}return _0x4fc14b;});}});}}});};