0c1dce02c62da0b76234d0688b826ae8fde887bc
[motion-next.git] / server / services / routing / lib / rule-engine.js
1 const a1162_0x36dc=['consequence','EventEmitter','register','noop','length','toString','fromJSON','activeRules','toJSON','filter','isArray','restart','condition','asc','sync','util','matchPath','ruleRef','prototype','ignoreFactChanges','execute','isEqual','parse','push','orderBy','result','matches','index_','findRules','turn','nextTick','clone','init','priority','isNil','concat','isString','rules','isObject','next','map','lodash'];(function(_0x2e2bc9,_0x36dcb8){const _0x2f95ff=function(_0x566675){while(--_0x566675){_0x2e2bc9['push'](_0x2e2bc9['shift']());}};_0x2f95ff(++_0x36dcb8);}(a1162_0x36dc,0xf0));const a1162_0x2f95=function(_0x2e2bc9,_0x36dcb8){_0x2e2bc9=_0x2e2bc9-0x0;let _0x2f95ff=a1162_0x36dc[_0x2e2bc9];return _0x2f95ff;};const _0x357e48=a1162_0x2f95;'use strict';const _=require(_0x357e48('0xb')),util=require(_0x357e48('0x1b')),EventEmitter=require('events')[_0x357e48('0xd')];function RuleEngine(_0x566675,_0x40bac7){const _0x246425=_0x357e48;return this[_0x246425('0x2')](),!_[_0x246425('0x4')](_0x566675)&&this[_0x246425('0xe')](_0x566675),_0x40bac7&&(this[_0x246425('0x1f')]=_0x40bac7[_0x246425('0x1f')]),this;}util['inherits'](RuleEngine,EventEmitter),RuleEngine[_0x357e48('0x1e')]['init']=function(){const _0x285cbf=_0x357e48;this[_0x285cbf('0x7')]=[],this[_0x285cbf('0x13')]=[];},RuleEngine['prototype'][_0x357e48('0xe')]=function(_0x47f303){const _0x32c41d=_0x357e48;if(Array[_0x32c41d('0x16')](_0x47f303))this[_0x32c41d('0x7')]=this[_0x32c41d('0x7')][_0x32c41d('0x5')](_0x47f303);else _0x47f303!==null&&_[_0x32c41d('0x8')](_0x47f303)&&this[_0x32c41d('0x7')][_0x32c41d('0x23')](_0x47f303);this['sync']();},RuleEngine[_0x357e48('0x1e')][_0x357e48('0x1a')]=function(){const _0x31fa8c=_0x357e48;this[_0x31fa8c('0x13')]=this['rules'][_0x31fa8c('0x15')](function(_0x46c169){const _0x34e0aa=_0x31fa8c;_[_0x34e0aa('0x4')](_0x46c169['on'])&&(_0x46c169['on']=!![]);if(_0x46c169['on']===!![])return _0x46c169;}),this['activeRules']=_[_0x31fa8c('0x24')](this[_0x31fa8c('0x13')],['p'],[_0x31fa8c('0x19')]);},RuleEngine[_0x357e48('0x1e')][_0x357e48('0x20')]=function(_0x3e2084,_0x480ef5){const _0x1508e5=_0x357e48;let _0x5633fb=![];_0x3e2084[_0x1508e5('0x25')]=!![];const _0x4f43b8=_[_0x1508e5('0x1')](_0x3e2084);let _0x212eeb=_[_0x1508e5('0x1')](_0x3e2084);const _0x414baf=this['activeRules'],_0x488d40=[],_0x54ba5c=this[_0x1508e5('0x1f')];(function _0x55456d(_0x8e8834){const _0x1cb174=_0x1508e5,_0x15c07f={'rules':function(){return _0x414baf;},'rule':function(){return _0x414baf[_0x8e8834];},'when':function(_0x3e77e6){const _0x18ce37=a1162_0x2f95;if(_0x3e77e6){const _0x2d5626=_0x414baf[_0x8e8834][_0x18ce37('0xc')];_0x2d5626[_0x18ce37('0x1d')]=_0x414baf[_0x8e8834]['id']||_0x414baf[_0x8e8834]['name']||_0x18ce37('0x27')+_0x8e8834,process[_0x18ce37('0x0')](function(){const _0x1c087e=_0x18ce37;_0x488d40[_0x1c087e('0x23')](_0x2d5626[_0x1c087e('0x1d')]),_0x2d5626['call'](_0x4f43b8,_0x15c07f);});}else process['nextTick'](function(){const _0x6a1a8a=_0x18ce37;_0x15c07f[_0x6a1a8a('0x9')]();});},'restart':function(){return _0x55456d(0x0);},'stop':function(){return _0x5633fb=!![],_0x55456d(0x0);},'next':function(_0x286705){const _0x1218ca=a1162_0x2f95;!_0x54ba5c&&!_[_0x1218ca('0x21')](_0x212eeb,_0x4f43b8)?(_0x212eeb=_[_0x1218ca('0x1')](_0x4f43b8),process[_0x1218ca('0x0')](function(){const _0x339091=_0x1218ca;_0x15c07f[_0x339091('0x17')]();})):process[_0x1218ca('0x0')](function(){return _['isNil'](_0x286705)?_0x55456d(_0x8e8834+0x1):_0x55456d(_0x286705);});}};if(_0x8e8834<_0x414baf['length']&&_0x5633fb===![]){const _0x341472=_0x414baf[_0x8e8834][_0x1cb174('0x18')];_0x341472['call'](_0x4f43b8,_0x15c07f);}else process[_0x1cb174('0x0')](function(){const _0x1e4a80=_0x1cb174;return _0x4f43b8[_0x1e4a80('0x1c')]=_0x488d40,_0x480ef5?_0x480ef5(_0x4f43b8):_[_0x1e4a80('0xf')]();});}(0x0));},RuleEngine[_0x357e48('0x1e')]['findRules']=function(_0x56aace){const _0x11c7b7=_0x357e48;if(_[_0x11c7b7('0x4')](_0x56aace))return this[_0x11c7b7('0x7')];else{const _0x2ffad7=_[_0x11c7b7('0x26')](_0x56aace);return _[_0x11c7b7('0x15')](this[_0x11c7b7('0x7')],_0x2ffad7);}},RuleEngine[_0x357e48('0x1e')][_0x357e48('0x29')]=function(_0x45900f,_0x176727){const _0x50799d=_0x357e48,_0x1cf6d1=_0x45900f==='on'||_0x45900f==='ON'?!![]:![],_0x58678e=this[_0x50799d('0x28')](_0x176727);for(let _0x3f18ce=0x0,_0x45aac4=_0x58678e[_0x50799d('0x10')];_0x3f18ce<_0x45aac4;_0x3f18ce+=0x1){_0x58678e[_0x3f18ce]['on']=_0x1cf6d1;}this[_0x50799d('0x1a')]();},RuleEngine[_0x357e48('0x1e')]['prioritize']=function(_0x261e1f,_0x4e229c){const _0x41219c=_0x357e48;_0x261e1f=parseInt(_0x261e1f,0xa);const _0x111fe0=this[_0x41219c('0x28')](_0x4e229c);for(let _0x26e471=0x0,_0x559aa8=_0x111fe0[_0x41219c('0x10')];_0x26e471<_0x559aa8;_0x26e471+=0x1){_0x111fe0[_0x26e471][_0x41219c('0x3')]=_0x261e1f;}this[_0x41219c('0x1a')]();},RuleEngine[_0x357e48('0x1e')][_0x357e48('0x14')]=function(){const _0x1afbbb=_0x357e48;let _0x24b91e=this['rules'];if(_0x24b91e instanceof Array)_0x24b91e=_0x24b91e[_0x1afbbb('0xa')](function(_0x4336ee){const _0x3ce3b5=_0x1afbbb;return _0x4336ee[_0x3ce3b5('0x18')]=_0x4336ee[_0x3ce3b5('0x18')][_0x3ce3b5('0x11')](),_0x4336ee['consequence']=_0x4336ee['consequence'][_0x3ce3b5('0x11')](),_0x4336ee;});else!_[_0x1afbbb('0x4')](_0x24b91e)&&(_0x24b91e['condition']=_0x24b91e[_0x1afbbb('0x18')][_0x1afbbb('0x11')](),_0x24b91e[_0x1afbbb('0xc')]=_0x24b91e['consequence'][_0x1afbbb('0x11')]());return _0x24b91e;},RuleEngine['prototype'][_0x357e48('0x12')]=function(_0x2b7b61){const _0x3f57df=_0x357e48;this[_0x3f57df('0x2')]();_[_0x3f57df('0x6')](_0x2b7b61)&&(_0x2b7b61=JSON[_0x3f57df('0x22')](_0x2b7b61));if(_0x2b7b61 instanceof Array)_0x2b7b61=_0x2b7b61[_0x3f57df('0xa')](function(_0x1c6c82){const _0x443f4c=_0x3f57df;return _0x1c6c82[_0x443f4c('0x18')]=eval('('+_0x1c6c82['condition']+')'),_0x1c6c82[_0x443f4c('0xc')]=eval('('+_0x1c6c82[_0x443f4c('0xc')]+')'),_0x1c6c82;});else _0x2b7b61!==null&&typeof _0x2b7b61=='object'&&(_0x2b7b61[_0x3f57df('0x18')]=eval('('+_0x2b7b61[_0x3f57df('0x18')]+')'),_0x2b7b61['consequence']=eval('('+_0x2b7b61['consequence']+')'));this[_0x3f57df('0xe')](_0x2b7b61);},module['exports']=RuleEngine;