b92e00700ec7299a3259eef5f083709994e92b41
[motion-next.git] / server / services / routing / lib / rule-engine.js
1 const a1163_0x8aea=['isString','call','activeRules','matchPath','events','findRules','map','sync','init','fromJSON','clone','push','ignoreFactChanges','prototype','isArray','orderBy','matches','noop','restart','toString','isEqual','consequence','next','result','object','filter','concat','priority','index_','execute','EventEmitter','lodash','isNil','condition','util','length','register','rules','turn','nextTick','exports'];(function(_0x4351b3,_0x8aea76){const _0x5435fd=function(_0x31494d){while(--_0x31494d){_0x4351b3['push'](_0x4351b3['shift']());}};_0x5435fd(++_0x8aea76);}(a1163_0x8aea,0xcc));const a1163_0x5435=function(_0x4351b3,_0x8aea76){_0x4351b3=_0x4351b3-0x0;let _0x5435fd=a1163_0x8aea[_0x4351b3];return _0x5435fd;};const _0x4b4d4f=a1163_0x5435;'use strict';const _=require(_0x4b4d4f('0x20')),util=require(_0x4b4d4f('0x23')),EventEmitter=require(_0x4b4d4f('0x5'))[_0x4b4d4f('0x1f')];function RuleEngine(_0x31494d,_0x2b0999){const _0x3b1581=_0x4b4d4f;return this[_0x3b1581('0x9')](),!_[_0x3b1581('0x21')](_0x31494d)&&this[_0x3b1581('0x25')](_0x31494d),_0x2b0999&&(this[_0x3b1581('0xd')]=_0x2b0999[_0x3b1581('0xd')]),this;}util['inherits'](RuleEngine,EventEmitter),RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0x9')]=function(){const _0x212772=_0x4b4d4f;this[_0x212772('0x26')]=[],this[_0x212772('0x3')]=[];},RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0x25')]=function(_0xdcc48d){const _0x4596f5=_0x4b4d4f;if(Array[_0x4596f5('0xf')](_0xdcc48d))this['rules']=this[_0x4596f5('0x26')][_0x4596f5('0x1b')](_0xdcc48d);else _0xdcc48d!==null&&_['isObject'](_0xdcc48d)&&this['rules'][_0x4596f5('0xc')](_0xdcc48d);this['sync']();},RuleEngine[_0x4b4d4f('0xe')]['sync']=function(){const _0x4e0f1d=_0x4b4d4f;this['activeRules']=this[_0x4e0f1d('0x26')][_0x4e0f1d('0x1a')](function(_0x3244dc){const _0x29beeb=_0x4e0f1d;_[_0x29beeb('0x21')](_0x3244dc['on'])&&(_0x3244dc['on']=!![]);if(_0x3244dc['on']===!![])return _0x3244dc;}),this[_0x4e0f1d('0x3')]=_[_0x4e0f1d('0x10')](this[_0x4e0f1d('0x3')],['p'],['asc']);},RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0x1e')]=function(_0x265df8,_0x1759d4){const _0x381c27=_0x4b4d4f;let _0x372b80=![];_0x265df8[_0x381c27('0x18')]=!![];const _0x305aec=_[_0x381c27('0xb')](_0x265df8);let _0x54b78a=_['clone'](_0x265df8);const _0x167c8b=this['activeRules'],_0x11a8a0=[],_0x155d88=this['ignoreFactChanges'];(function _0x204f3c(_0x1f1db5){const _0x759ee0=_0x381c27,_0x53fed5={'rules':function(){return _0x167c8b;},'rule':function(){return _0x167c8b[_0x1f1db5];},'when':function(_0x3d3f14){const _0x4d2bf8=a1163_0x5435;if(_0x3d3f14){const _0x3681d8=_0x167c8b[_0x1f1db5]['consequence'];_0x3681d8['ruleRef']=_0x167c8b[_0x1f1db5]['id']||_0x167c8b[_0x1f1db5]['name']||_0x4d2bf8('0x1d')+_0x1f1db5,process[_0x4d2bf8('0x28')](function(){_0x11a8a0['push'](_0x3681d8['ruleRef']),_0x3681d8['call'](_0x305aec,_0x53fed5);});}else process[_0x4d2bf8('0x28')](function(){const _0x2449d7=_0x4d2bf8;_0x53fed5[_0x2449d7('0x17')]();});},'restart':function(){return _0x204f3c(0x0);},'stop':function(){return _0x372b80=!![],_0x204f3c(0x0);},'next':function(_0x2319ec){const _0x283b95=a1163_0x5435;!_0x155d88&&!_[_0x283b95('0x15')](_0x54b78a,_0x305aec)?(_0x54b78a=_[_0x283b95('0xb')](_0x305aec),process[_0x283b95('0x28')](function(){const _0x3a80ea=_0x283b95;_0x53fed5[_0x3a80ea('0x13')]();})):process[_0x283b95('0x28')](function(){const _0x18c26d=_0x283b95;return _[_0x18c26d('0x21')](_0x2319ec)?_0x204f3c(_0x1f1db5+0x1):_0x204f3c(_0x2319ec);});}};if(_0x1f1db5<_0x167c8b['length']&&_0x372b80===![]){const _0x5dae08=_0x167c8b[_0x1f1db5]['condition'];_0x5dae08[_0x759ee0('0x2')](_0x305aec,_0x53fed5);}else process[_0x759ee0('0x28')](function(){const _0xfff834=_0x759ee0;return _0x305aec[_0xfff834('0x4')]=_0x11a8a0,_0x1759d4?_0x1759d4(_0x305aec):_[_0xfff834('0x12')]();});}(0x0));},RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0x6')]=function(_0x51dfe3){const _0x47fa24=_0x4b4d4f;if(_[_0x47fa24('0x21')](_0x51dfe3))return this['rules'];else{const _0x2df6c1=_[_0x47fa24('0x11')](_0x51dfe3);return _[_0x47fa24('0x1a')](this[_0x47fa24('0x26')],_0x2df6c1);}},RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0x27')]=function(_0x2c11a0,_0x5ea43c){const _0x262442=_0x4b4d4f,_0x340998=_0x2c11a0==='on'||_0x2c11a0==='ON'?!![]:![],_0x38f3ef=this[_0x262442('0x6')](_0x5ea43c);for(let _0x89cb70=0x0,_0x6da736=_0x38f3ef[_0x262442('0x24')];_0x89cb70<_0x6da736;_0x89cb70+=0x1){_0x38f3ef[_0x89cb70]['on']=_0x340998;}this[_0x262442('0x8')]();},RuleEngine['prototype']['prioritize']=function(_0x515c4f,_0x1b0695){const _0x44c02d=_0x4b4d4f;_0x515c4f=parseInt(_0x515c4f,0xa);const _0x4b6d66=this[_0x44c02d('0x6')](_0x1b0695);for(let _0x1786af=0x0,_0x7b8507=_0x4b6d66[_0x44c02d('0x24')];_0x1786af<_0x7b8507;_0x1786af+=0x1){_0x4b6d66[_0x1786af][_0x44c02d('0x1c')]=_0x515c4f;}this[_0x44c02d('0x8')]();},RuleEngine[_0x4b4d4f('0xe')]['toJSON']=function(){const _0x7618bc=_0x4b4d4f;let _0x52c8b3=this['rules'];if(_0x52c8b3 instanceof Array)_0x52c8b3=_0x52c8b3['map'](function(_0x4b6f8a){const _0xe073d4=a1163_0x5435;return _0x4b6f8a[_0xe073d4('0x22')]=_0x4b6f8a[_0xe073d4('0x22')][_0xe073d4('0x14')](),_0x4b6f8a[_0xe073d4('0x16')]=_0x4b6f8a['consequence'][_0xe073d4('0x14')](),_0x4b6f8a;});else!_[_0x7618bc('0x21')](_0x52c8b3)&&(_0x52c8b3[_0x7618bc('0x22')]=_0x52c8b3[_0x7618bc('0x22')][_0x7618bc('0x14')](),_0x52c8b3[_0x7618bc('0x16')]=_0x52c8b3['consequence']['toString']());return _0x52c8b3;},RuleEngine[_0x4b4d4f('0xe')][_0x4b4d4f('0xa')]=function(_0xdd7ad1){const _0x42b9d0=_0x4b4d4f;this['init']();_[_0x42b9d0('0x1')](_0xdd7ad1)&&(_0xdd7ad1=JSON['parse'](_0xdd7ad1));if(_0xdd7ad1 instanceof Array)_0xdd7ad1=_0xdd7ad1[_0x42b9d0('0x7')](function(_0x3744cc){const _0xb8c88f=_0x42b9d0;return _0x3744cc[_0xb8c88f('0x22')]=eval('('+_0x3744cc[_0xb8c88f('0x22')]+')'),_0x3744cc[_0xb8c88f('0x16')]=eval('('+_0x3744cc[_0xb8c88f('0x16')]+')'),_0x3744cc;});else _0xdd7ad1!==null&&typeof _0xdd7ad1==_0x42b9d0('0x19')&&(_0xdd7ad1['condition']=eval('('+_0xdd7ad1[_0x42b9d0('0x22')]+')'),_0xdd7ad1[_0x42b9d0('0x16')]=eval('('+_0xdd7ad1[_0x42b9d0('0x16')]+')'));this[_0x42b9d0('0x25')](_0xdd7ad1);},module[_0x4b4d4f('0x0')]=RuleEngine;