a5485c6ee6a414cda65e300d638c36dc25d0b863
[motion-next.git] / server / services / routing / lib / rule-engine.js
1 const a1162_0x41c5=['clone','next','length','register','inherits','isObject','util','asc','toString','prototype','restart','init','fromJSON','rules','call','filter','isString','ruleRef','matches','concat','object','map','lodash','ignoreFactChanges','result','condition','nextTick','toJSON','prioritize','consequence','findRules','isNil','name','isArray','execute','matchPath','index_','sync','push','turn','activeRules','priority'];(function(_0x4bfc87,_0x41c5ff){const _0x3b61a6=function(_0x2ec65d){while(--_0x2ec65d){_0x4bfc87['push'](_0x4bfc87['shift']());}};_0x3b61a6(++_0x41c5ff);}(a1162_0x41c5,0x19e));const a1162_0x3b61=function(_0x4bfc87,_0x41c5ff){_0x4bfc87=_0x4bfc87-0x0;let _0x3b61a6=a1162_0x41c5[_0x4bfc87];return _0x3b61a6;};const _0x785471=a1162_0x3b61;'use strict';const _=require(_0x785471('0x1c')),util=require(_0x785471('0xc')),EventEmitter=require('events')['EventEmitter'];function RuleEngine(_0x2ec65d,_0xd3be9a){const _0x23e49c=_0x785471;return this[_0x23e49c('0x11')](),!_['isNil'](_0x2ec65d)&&this[_0x23e49c('0x9')](_0x2ec65d),_0xd3be9a&&(this[_0x23e49c('0x1d')]=_0xd3be9a[_0x23e49c('0x1d')]),this;}util[_0x785471('0xa')](RuleEngine,EventEmitter),RuleEngine[_0x785471('0xf')][_0x785471('0x11')]=function(){const _0x4acc83=_0x785471;this[_0x4acc83('0x13')]=[],this[_0x4acc83('0x4')]=[];},RuleEngine[_0x785471('0xf')][_0x785471('0x9')]=function(_0x1fa967){const _0x260c01=_0x785471;if(Array[_0x260c01('0x27')](_0x1fa967))this['rules']=this['rules'][_0x260c01('0x19')](_0x1fa967);else _0x1fa967!==null&&_[_0x260c01('0xb')](_0x1fa967)&&this['rules'][_0x260c01('0x2')](_0x1fa967);this[_0x260c01('0x1')]();},RuleEngine[_0x785471('0xf')][_0x785471('0x1')]=function(){const _0x437e60=_0x785471;this[_0x437e60('0x4')]=this[_0x437e60('0x13')]['filter'](function(_0x26cdb1){const _0x2c9f84=_0x437e60;_[_0x2c9f84('0x25')](_0x26cdb1['on'])&&(_0x26cdb1['on']=!![]);if(_0x26cdb1['on']===!![])return _0x26cdb1;}),this['activeRules']=_['orderBy'](this['activeRules'],['p'],[_0x437e60('0xd')]);},RuleEngine['prototype'][_0x785471('0x28')]=function(_0x442b58,_0x1212ce){const _0x39cb10=_0x785471;let _0x5993cc=![];_0x442b58[_0x39cb10('0x1e')]=!![];const _0x59bfbf=_[_0x39cb10('0x6')](_0x442b58);let _0x1aa9bd=_[_0x39cb10('0x6')](_0x442b58);const _0x5deff1=this[_0x39cb10('0x4')],_0x174826=[],_0x35c361=this['ignoreFactChanges'];(function _0x3f16fb(_0x4c248b){const _0x207254={'rules':function(){return _0x5deff1;},'rule':function(){return _0x5deff1[_0x4c248b];},'when':function(_0x4acd20){const _0x3d9900=a1162_0x3b61;if(_0x4acd20){const _0x2cb31b=_0x5deff1[_0x4c248b][_0x3d9900('0x23')];_0x2cb31b[_0x3d9900('0x17')]=_0x5deff1[_0x4c248b]['id']||_0x5deff1[_0x4c248b][_0x3d9900('0x26')]||_0x3d9900('0x0')+_0x4c248b,process[_0x3d9900('0x20')](function(){const _0x50cc11=_0x3d9900;_0x174826[_0x50cc11('0x2')](_0x2cb31b[_0x50cc11('0x17')]),_0x2cb31b[_0x50cc11('0x14')](_0x59bfbf,_0x207254);});}else process[_0x3d9900('0x20')](function(){const _0x493539=_0x3d9900;_0x207254[_0x493539('0x7')]();});},'restart':function(){return _0x3f16fb(0x0);},'stop':function(){return _0x5993cc=!![],_0x3f16fb(0x0);},'next':function(_0x3493f2){const _0x37ea49=a1162_0x3b61;!_0x35c361&&!_['isEqual'](_0x1aa9bd,_0x59bfbf)?(_0x1aa9bd=_[_0x37ea49('0x6')](_0x59bfbf),process[_0x37ea49('0x20')](function(){const _0x103328=_0x37ea49;_0x207254[_0x103328('0x10')]();})):process[_0x37ea49('0x20')](function(){const _0x5767f1=_0x37ea49;return _[_0x5767f1('0x25')](_0x3493f2)?_0x3f16fb(_0x4c248b+0x1):_0x3f16fb(_0x3493f2);});}};if(_0x4c248b<_0x5deff1['length']&&_0x5993cc===![]){const _0x377f07=_0x5deff1[_0x4c248b]['condition'];_0x377f07['call'](_0x59bfbf,_0x207254);}else process['nextTick'](function(){const _0x38df2c=a1162_0x3b61;return _0x59bfbf[_0x38df2c('0x29')]=_0x174826,_0x1212ce?_0x1212ce(_0x59bfbf):_['noop']();});}(0x0));},RuleEngine['prototype'][_0x785471('0x24')]=function(_0x415e49){const _0x2133bd=_0x785471;if(_[_0x2133bd('0x25')](_0x415e49))return this[_0x2133bd('0x13')];else{const _0x2f0fc1=_[_0x2133bd('0x18')](_0x415e49);return _[_0x2133bd('0x15')](this[_0x2133bd('0x13')],_0x2f0fc1);}},RuleEngine[_0x785471('0xf')][_0x785471('0x3')]=function(_0x12d7ec,_0x44c0aa){const _0x20668b=_0x785471,_0x1160c9=_0x12d7ec==='on'||_0x12d7ec==='ON'?!![]:![],_0x4bd2fd=this[_0x20668b('0x24')](_0x44c0aa);for(let _0x208433=0x0,_0xb3e715=_0x4bd2fd[_0x20668b('0x8')];_0x208433<_0xb3e715;_0x208433+=0x1){_0x4bd2fd[_0x208433]['on']=_0x1160c9;}this['sync']();},RuleEngine[_0x785471('0xf')][_0x785471('0x22')]=function(_0x1b5e29,_0x5a776f){const _0x36bf32=_0x785471;_0x1b5e29=parseInt(_0x1b5e29,0xa);const _0x2f180a=this['findRules'](_0x5a776f);for(let _0x208770=0x0,_0x55da31=_0x2f180a[_0x36bf32('0x8')];_0x208770<_0x55da31;_0x208770+=0x1){_0x2f180a[_0x208770][_0x36bf32('0x5')]=_0x1b5e29;}this['sync']();},RuleEngine[_0x785471('0xf')][_0x785471('0x21')]=function(){const _0x501b28=_0x785471;let _0x3316e7=this['rules'];if(_0x3316e7 instanceof Array)_0x3316e7=_0x3316e7[_0x501b28('0x1b')](function(_0x52cebf){const _0x13fa66=_0x501b28;return _0x52cebf[_0x13fa66('0x1f')]=_0x52cebf[_0x13fa66('0x1f')][_0x13fa66('0xe')](),_0x52cebf['consequence']=_0x52cebf[_0x13fa66('0x23')][_0x13fa66('0xe')](),_0x52cebf;});else!_[_0x501b28('0x25')](_0x3316e7)&&(_0x3316e7[_0x501b28('0x1f')]=_0x3316e7[_0x501b28('0x1f')]['toString'](),_0x3316e7['consequence']=_0x3316e7[_0x501b28('0x23')][_0x501b28('0xe')]());return _0x3316e7;},RuleEngine[_0x785471('0xf')][_0x785471('0x12')]=function(_0x5c3c44){const _0x2efd91=_0x785471;this[_0x2efd91('0x11')]();_[_0x2efd91('0x16')](_0x5c3c44)&&(_0x5c3c44=JSON['parse'](_0x5c3c44));if(_0x5c3c44 instanceof Array)_0x5c3c44=_0x5c3c44[_0x2efd91('0x1b')](function(_0x1b219c){const _0xe0436c=_0x2efd91;return _0x1b219c[_0xe0436c('0x1f')]=eval('('+_0x1b219c[_0xe0436c('0x1f')]+')'),_0x1b219c[_0xe0436c('0x23')]=eval('('+_0x1b219c[_0xe0436c('0x23')]+')'),_0x1b219c;});else _0x5c3c44!==null&&typeof _0x5c3c44==_0x2efd91('0x1a')&&(_0x5c3c44[_0x2efd91('0x1f')]=eval('('+_0x5c3c44[_0x2efd91('0x1f')]+')'),_0x5c3c44[_0x2efd91('0x23')]=eval('('+_0x5c3c44['consequence']+')'));this[_0x2efd91('0x9')](_0x5c3c44);},module['exports']=RuleEngine;