Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / services / routing / lib / rule-engine.js
index f4fb975..9569367 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1c0c=['rules','activeRules','register','isArray','isObject','push','sync','filter','asc','result','clone','consequence','ruleRef','nextTick','call','next','isEqual','restart','matchPath','findRules','matches','length','prioritize','priority','condition','toString','fromJSON','isString','parse','map','object','exports','lodash','util','events','init','isNil','ignoreFactChanges','prototype'];(function(_0x3b380d,_0x4bf247){var _0x54502b=function(_0x35d207){while(--_0x35d207){_0x3b380d['push'](_0x3b380d['shift']());}};_0x54502b(++_0x4bf247);}(_0x1c0c,0x1a6));var _0xc1c0=function(_0x31cb5f,_0x2df766){_0x31cb5f=_0x31cb5f-0x0;var _0x586042=_0x1c0c[_0x31cb5f];return _0x586042;};'use strict';var _=require(_0xc1c0('0x0'));var util=require(_0xc1c0('0x1'));var EventEmitter=require(_0xc1c0('0x2'))['EventEmitter'];function RuleEngine(_0x5327dc,_0xbf5988){this[_0xc1c0('0x3')]();if(!_[_0xc1c0('0x4')](_0x5327dc)){this['register'](_0x5327dc);}if(_0xbf5988){this[_0xc1c0('0x5')]=_0xbf5988[_0xc1c0('0x5')];}return this;}util['inherits'](RuleEngine,EventEmitter);RuleEngine[_0xc1c0('0x6')][_0xc1c0('0x3')]=function(_0x241882){this[_0xc1c0('0x7')]=[];this[_0xc1c0('0x8')]=[];};RuleEngine[_0xc1c0('0x6')][_0xc1c0('0x9')]=function(_0x2ed32a){if(Array[_0xc1c0('0xa')](_0x2ed32a)){this[_0xc1c0('0x7')]=this['rules']['concat'](_0x2ed32a);}else if(_0x2ed32a!==null&&_[_0xc1c0('0xb')](_0x2ed32a)){this[_0xc1c0('0x7')][_0xc1c0('0xc')](_0x2ed32a);}this['sync']();};RuleEngine['prototype'][_0xc1c0('0xd')]=function(){this[_0xc1c0('0x8')]=this[_0xc1c0('0x7')][_0xc1c0('0xe')](function(_0x5aa480){if(_[_0xc1c0('0x4')](_0x5aa480['on'])){_0x5aa480['on']=!![];}if(_0x5aa480['on']===!![]){return _0x5aa480;}});this[_0xc1c0('0x8')]=_['orderBy'](this[_0xc1c0('0x8')],['p'],[_0xc1c0('0xf')]);};RuleEngine[_0xc1c0('0x6')]['execute']=function(_0x39ae46,_0x2b30a2){var _0x4f557b=![];_0x39ae46[_0xc1c0('0x10')]=!![];var _0x525f8a=_[_0xc1c0('0x11')](_0x39ae46);var _0x41ed2d=_['clone'](_0x39ae46);var _0x471abf=this['activeRules'];var _0x19a6c5=[];var _0x2ac3e1=this[_0xc1c0('0x5')];(function FnRuleLoop(_0x59aa93){var _0x54362e={'rules':function(){return _0x471abf;},'rule':function(){return _0x471abf[_0x59aa93];},'when':function(_0x419d38){if(_0x419d38){var _0x4f5b1c=_0x471abf[_0x59aa93][_0xc1c0('0x12')];_0x4f5b1c[_0xc1c0('0x13')]=_0x471abf[_0x59aa93]['id']||_0x471abf[_0x59aa93]['name']||'index_'+_0x59aa93;process[_0xc1c0('0x14')](function(){_0x19a6c5[_0xc1c0('0xc')](_0x4f5b1c[_0xc1c0('0x13')]);_0x4f5b1c[_0xc1c0('0x15')](_0x525f8a,_0x54362e);});}else{process[_0xc1c0('0x14')](function(){_0x54362e[_0xc1c0('0x16')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x4f557b=!![];return FnRuleLoop(0x0);},'next':function(_0x2f0744){if(!_0x2ac3e1&&!_[_0xc1c0('0x17')](_0x41ed2d,_0x525f8a)){_0x41ed2d=_['clone'](_0x525f8a);process[_0xc1c0('0x14')](function(){_0x54362e[_0xc1c0('0x18')]();});}else{process[_0xc1c0('0x14')](function(){if(_[_0xc1c0('0x4')](_0x2f0744)){return FnRuleLoop(_0x59aa93+0x1);}else{return FnRuleLoop(_0x2f0744);}});}}};if(_0x59aa93<_0x471abf['length']&&_0x4f557b===![]){var _0x43ff44=_0x471abf[_0x59aa93]['condition'];_0x43ff44['call'](_0x525f8a,_0x54362e);}else{process['nextTick'](function(){_0x525f8a[_0xc1c0('0x19')]=_0x19a6c5;return _0x2b30a2?_0x2b30a2(_0x525f8a):_['noop']();});}}(0x0));};RuleEngine[_0xc1c0('0x6')][_0xc1c0('0x1a')]=function(_0x4dc648){if(_[_0xc1c0('0x4')](_0x4dc648)){return this[_0xc1c0('0x7')];}else{var _0x42c77d=_[_0xc1c0('0x1b')](_0x4dc648);return _['filter'](this[_0xc1c0('0x7')],_0x42c77d);}};RuleEngine[_0xc1c0('0x6')]['turn']=function(_0x300e46,_0x25edf2){var _0x300e46=_0x300e46==='on'||_0x300e46==='ON'?!![]:![];var _0x25d3f7=this[_0xc1c0('0x1a')](_0x25edf2);for(var _0x1f9876=0x0,_0x1446df=_0x25d3f7[_0xc1c0('0x1c')];_0x1f9876<_0x1446df;_0x1f9876+=0x1){_0x25d3f7[_0x1f9876]['on']=_0x300e46;}this['sync']();};RuleEngine[_0xc1c0('0x6')][_0xc1c0('0x1d')]=function(_0x1e1b29,_0x11ce63){_0x1e1b29=parseInt(_0x1e1b29,0xa);var _0x54698b=this['findRules'](_0x11ce63);for(var _0x53df00=0x0,_0x561d8b=_0x54698b[_0xc1c0('0x1c')];_0x53df00<_0x561d8b;_0x53df00+=0x1){_0x54698b[_0x53df00][_0xc1c0('0x1e')]=_0x1e1b29;}this[_0xc1c0('0xd')]();};RuleEngine[_0xc1c0('0x6')]['toJSON']=function(){var _0x45e9a0=this[_0xc1c0('0x7')];if(_0x45e9a0 instanceof Array){_0x45e9a0=_0x45e9a0['map'](function(_0x4ba143){_0x4ba143[_0xc1c0('0x1f')]=_0x4ba143[_0xc1c0('0x1f')][_0xc1c0('0x20')]();_0x4ba143[_0xc1c0('0x12')]=_0x4ba143['consequence'][_0xc1c0('0x20')]();return _0x4ba143;});}else if(!_[_0xc1c0('0x4')](_0x45e9a0)){_0x45e9a0[_0xc1c0('0x1f')]=_0x45e9a0[_0xc1c0('0x1f')]['toString']();_0x45e9a0['consequence']=_0x45e9a0[_0xc1c0('0x12')][_0xc1c0('0x20')]();}return _0x45e9a0;};RuleEngine['prototype'][_0xc1c0('0x21')]=function(_0x2e3c3c){this[_0xc1c0('0x3')]();if(_[_0xc1c0('0x22')](_0x2e3c3c)){_0x2e3c3c=JSON[_0xc1c0('0x23')](_0x2e3c3c);}if(_0x2e3c3c instanceof Array){_0x2e3c3c=_0x2e3c3c[_0xc1c0('0x24')](function(_0x25e953){_0x25e953[_0xc1c0('0x1f')]=eval('('+_0x25e953[_0xc1c0('0x1f')]+')');_0x25e953[_0xc1c0('0x12')]=eval('('+_0x25e953[_0xc1c0('0x12')]+')');return _0x25e953;});}else if(_0x2e3c3c!==null&&typeof _0x2e3c3c==_0xc1c0('0x25')){_0x2e3c3c[_0xc1c0('0x1f')]=eval('('+_0x2e3c3c['condition']+')');_0x2e3c3c['consequence']=eval('('+_0x2e3c3c[_0xc1c0('0x12')]+')');}this[_0xc1c0('0x9')](_0x2e3c3c);};module[_0xc1c0('0x26')]=RuleEngine;
\ No newline at end of file
+var _0x1707=['push','sync','filter','execute','result','clone','ruleRef','name','index_','call','nextTick','next','isEqual','restart','length','condition','matchPath','noop','findRules','matches','turn','prioritize','priority','toJSON','map','toString','consequence','isString','exports','lodash','events','isNil','ignoreFactChanges','prototype','init','activeRules','register','isArray','rules','concat'];(function(_0x4565bf,_0x5ad9d6){var _0x5610ba=function(_0x170988){while(--_0x170988){_0x4565bf['push'](_0x4565bf['shift']());}};_0x5610ba(++_0x5ad9d6);}(_0x1707,0xbd));var _0x7170=function(_0x557509,_0x42cc6f){_0x557509=_0x557509-0x0;var _0x1773ba=_0x1707[_0x557509];return _0x1773ba;};'use strict';var _=require(_0x7170('0x0'));var util=require('util');var EventEmitter=require(_0x7170('0x1'))['EventEmitter'];function RuleEngine(_0x547a84,_0x12472b){this['init']();if(!_[_0x7170('0x2')](_0x547a84)){this['register'](_0x547a84);}if(_0x12472b){this[_0x7170('0x3')]=_0x12472b[_0x7170('0x3')];}return this;}util['inherits'](RuleEngine,EventEmitter);RuleEngine[_0x7170('0x4')][_0x7170('0x5')]=function(_0x116448){this['rules']=[];this[_0x7170('0x6')]=[];};RuleEngine[_0x7170('0x4')][_0x7170('0x7')]=function(_0x1429b9){if(Array[_0x7170('0x8')](_0x1429b9)){this[_0x7170('0x9')]=this[_0x7170('0x9')][_0x7170('0xa')](_0x1429b9);}else if(_0x1429b9!==null&&_['isObject'](_0x1429b9)){this[_0x7170('0x9')][_0x7170('0xb')](_0x1429b9);}this[_0x7170('0xc')]();};RuleEngine['prototype']['sync']=function(){this['activeRules']=this[_0x7170('0x9')][_0x7170('0xd')](function(_0x2854cb){if(_[_0x7170('0x2')](_0x2854cb['on'])){_0x2854cb['on']=!![];}if(_0x2854cb['on']===!![]){return _0x2854cb;}});this[_0x7170('0x6')]=_['orderBy'](this[_0x7170('0x6')],['p'],['asc']);};RuleEngine[_0x7170('0x4')][_0x7170('0xe')]=function(_0x1a6409,_0x2e35a6){var _0x20e1c9=![];_0x1a6409[_0x7170('0xf')]=!![];var _0x6c8f07=_[_0x7170('0x10')](_0x1a6409);var _0x36b49c=_[_0x7170('0x10')](_0x1a6409);var _0x4b87e0=this[_0x7170('0x6')];var _0x36a2e0=[];var _0x580855=this['ignoreFactChanges'];(function FnRuleLoop(_0x13edd1){var _0x342ae5={'rules':function(){return _0x4b87e0;},'rule':function(){return _0x4b87e0[_0x13edd1];},'when':function(_0x3275ac){if(_0x3275ac){var _0x442d4e=_0x4b87e0[_0x13edd1]['consequence'];_0x442d4e[_0x7170('0x11')]=_0x4b87e0[_0x13edd1]['id']||_0x4b87e0[_0x13edd1][_0x7170('0x12')]||_0x7170('0x13')+_0x13edd1;process['nextTick'](function(){_0x36a2e0[_0x7170('0xb')](_0x442d4e[_0x7170('0x11')]);_0x442d4e[_0x7170('0x14')](_0x6c8f07,_0x342ae5);});}else{process[_0x7170('0x15')](function(){_0x342ae5[_0x7170('0x16')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x20e1c9=!![];return FnRuleLoop(0x0);},'next':function(_0x1503fe){if(!_0x580855&&!_[_0x7170('0x17')](_0x36b49c,_0x6c8f07)){_0x36b49c=_[_0x7170('0x10')](_0x6c8f07);process['nextTick'](function(){_0x342ae5[_0x7170('0x18')]();});}else{process[_0x7170('0x15')](function(){if(_[_0x7170('0x2')](_0x1503fe)){return FnRuleLoop(_0x13edd1+0x1);}else{return FnRuleLoop(_0x1503fe);}});}}};if(_0x13edd1<_0x4b87e0[_0x7170('0x19')]&&_0x20e1c9===![]){var _0x2c3a9c=_0x4b87e0[_0x13edd1][_0x7170('0x1a')];_0x2c3a9c[_0x7170('0x14')](_0x6c8f07,_0x342ae5);}else{process['nextTick'](function(){_0x6c8f07[_0x7170('0x1b')]=_0x36a2e0;return _0x2e35a6?_0x2e35a6(_0x6c8f07):_[_0x7170('0x1c')]();});}}(0x0));};RuleEngine[_0x7170('0x4')][_0x7170('0x1d')]=function(_0x20cbe4){if(_[_0x7170('0x2')](_0x20cbe4)){return this[_0x7170('0x9')];}else{var _0x11f45d=_[_0x7170('0x1e')](_0x20cbe4);return _[_0x7170('0xd')](this[_0x7170('0x9')],_0x11f45d);}};RuleEngine[_0x7170('0x4')][_0x7170('0x1f')]=function(_0x38b734,_0x583ac3){var _0x38b734=_0x38b734==='on'||_0x38b734==='ON'?!![]:![];var _0x5a5aba=this['findRules'](_0x583ac3);for(var _0x23fa58=0x0,_0x4d8318=_0x5a5aba['length'];_0x23fa58<_0x4d8318;_0x23fa58+=0x1){_0x5a5aba[_0x23fa58]['on']=_0x38b734;}this['sync']();};RuleEngine[_0x7170('0x4')][_0x7170('0x20')]=function(_0x19ed04,_0x137d02){_0x19ed04=parseInt(_0x19ed04,0xa);var _0x5aa06c=this['findRules'](_0x137d02);for(var _0x5ef36c=0x0,_0x10d9fe=_0x5aa06c[_0x7170('0x19')];_0x5ef36c<_0x10d9fe;_0x5ef36c+=0x1){_0x5aa06c[_0x5ef36c][_0x7170('0x21')]=_0x19ed04;}this[_0x7170('0xc')]();};RuleEngine[_0x7170('0x4')][_0x7170('0x22')]=function(){var _0x392109=this[_0x7170('0x9')];if(_0x392109 instanceof Array){_0x392109=_0x392109[_0x7170('0x23')](function(_0x1d1835){_0x1d1835[_0x7170('0x1a')]=_0x1d1835[_0x7170('0x1a')][_0x7170('0x24')]();_0x1d1835[_0x7170('0x25')]=_0x1d1835['consequence'][_0x7170('0x24')]();return _0x1d1835;});}else if(!_['isNil'](_0x392109)){_0x392109['condition']=_0x392109[_0x7170('0x1a')]['toString']();_0x392109[_0x7170('0x25')]=_0x392109[_0x7170('0x25')][_0x7170('0x24')]();}return _0x392109;};RuleEngine[_0x7170('0x4')]['fromJSON']=function(_0x157d8a){this['init']();if(_[_0x7170('0x26')](_0x157d8a)){_0x157d8a=JSON['parse'](_0x157d8a);}if(_0x157d8a instanceof Array){_0x157d8a=_0x157d8a[_0x7170('0x23')](function(_0xfb9048){_0xfb9048[_0x7170('0x1a')]=eval('('+_0xfb9048[_0x7170('0x1a')]+')');_0xfb9048[_0x7170('0x25')]=eval('('+_0xfb9048['consequence']+')');return _0xfb9048;});}else if(_0x157d8a!==null&&typeof _0x157d8a=='object'){_0x157d8a[_0x7170('0x1a')]=eval('('+_0x157d8a[_0x7170('0x1a')]+')');_0x157d8a['consequence']=eval('('+_0x157d8a[_0x7170('0x25')]+')');}this['register'](_0x157d8a);};module[_0x7170('0x27')]=RuleEngine;
\ No newline at end of file