Built motion from commit da617fac.|2.6.6
[motion2.git] / server / services / agi / graph / index.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 _0x19fd=['no\x20vertex\x20found','stop\x20traverse','length','no\x20edge/s\x20available','condition','vswitch','default','target','agicommand','menu','traverseBFS','condition\x20not\x20found','lodash','../../../config/logger','agi','getsecretdigits','vertices','numberOfEdges','addVertex','edges','prototype','push','size','relations','getVertex','info'];(function(_0x30f346,_0x5cc51f){var _0x3a0d0f=function(_0x31cb55){while(--_0x31cb55){_0x30f346['push'](_0x30f346['shift']());}};_0x3a0d0f(++_0x5cc51f);}(_0x19fd,0xc2));var _0xd19f=function(_0x30d782,_0x9a6d45){_0x30d782=_0x30d782-0x0;var _0x5753f5=_0x19fd[_0x30d782];return _0x5753f5;};'use strict';var _=require(_0xd19f('0x0'));var logger=require(_0xd19f('0x1'))(_0xd19f('0x2'));var verticesWithRetry=['menu','getdigits',_0xd19f('0x3')];var Graph=function(){this[_0xd19f('0x4')]={};this['edges']={};this[_0xd19f('0x5')]=0x0;};Graph['prototype'][_0xd19f('0x6')]=function(_0x432fd8){this[_0xd19f('0x4')][_0x432fd8['id']]=_0x432fd8;this[_0xd19f('0x7')][_0x432fd8['id']]=[];};Graph[_0xd19f('0x8')]['addEdge']=function(_0x2c6960,_0x19e9dc,_0x2d7393){this[_0xd19f('0x7')][_0x2c6960][_0xd19f('0x9')]({'target':_0x19e9dc,'condition':_0x2d7393});this[_0xd19f('0x5')]+=0x1;};Graph[_0xd19f('0x8')][_0xd19f('0xa')]=function(){return _['size'](this[_0xd19f('0x4')]);};Graph['prototype'][_0xd19f('0xb')]=function(){return this['numberOfEdges'];};Graph[_0xd19f('0x8')][_0xd19f('0xc')]=function(_0x18f394){return this['vertices'][_0x18f394];};Graph[_0xd19f('0x8')]['traverseBFS']=function(_0x21fab5,_0x32929d){if(!this[_0xd19f('0x4')][_0x21fab5]){return logger[_0xd19f('0xd')](_0xd19f('0xe'));}var _0x54f74c=_0x32929d(this[_0xd19f('0x4')][_0x21fab5]);if(!_0x54f74c){return logger['info'](_0xd19f('0xf'));}if(this[_0xd19f('0x7')][_0x21fab5][_0xd19f('0x10')]===0x0){return logger['info'](_0xd19f('0x11'));}for(var _0x48c8c8=0x0,_0x42a0be=[],_0x8c9a82=![];_0x48c8c8<this[_0xd19f('0x7')][_0x21fab5]['length'];_0x48c8c8+=0x1){if(this['edges'][_0x21fab5][_0x48c8c8][_0xd19f('0x12')]){_0x42a0be=this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8][_0xd19f('0x12')]['split'](',');for(var _0x2e7d6a=0x0;_0x2e7d6a<_0x42a0be[_0xd19f('0x10')];_0x2e7d6a+=0x1){if(this['vertices'][_0x21fab5]['agicommand']===_0xd19f('0x13')&&_0x42a0be[_0x2e7d6a]==='-'){_0x8c9a82=this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8]['target'];logger['info'](_0xd19f('0x14'),_0x42a0be[_0x2e7d6a],this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8][_0xd19f('0x15')]);}else if(this[_0xd19f('0x4')][_0x21fab5][_0xd19f('0x16')]===_0xd19f('0x17')&&_0x42a0be[_0x2e7d6a]==='i'){_0x8c9a82=this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8][_0xd19f('0x15')];logger['info']('invalid',_0x42a0be[_0x2e7d6a],this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8][_0xd19f('0x15')]);}if(_0x42a0be[_0x2e7d6a]===_0x54f74c){return this['traverseBFS'](this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8][_0xd19f('0x15')],_0x32929d);}}}else{return this['traverseBFS'](this[_0xd19f('0x7')][_0x21fab5][_0x48c8c8]['target'],_0x32929d);}}if(_0x42a0be[_0xd19f('0x10')]){if(this[_0xd19f('0x4')][_0x21fab5][_0xd19f('0x16')]===_0xd19f('0x13')){if(_0x8c9a82){return this[_0xd19f('0x18')](_0x8c9a82,_0x32929d);}return logger[_0xd19f('0xd')]('default\x20on\x20switch\x20not\x20found');}else if(_['includes'](verticesWithRetry,this[_0xd19f('0x4')][_0x21fab5][_0xd19f('0x16')])){if(_0x54f74c==='-'){return logger[_0xd19f('0xd')]('max\x20retry\x20reach');}if(_0x8c9a82&&_0x54f74c!=='t'){return this[_0xd19f('0x18')](_0x8c9a82,_0x32929d);}return this[_0xd19f('0x18')](_0x21fab5,_0x32929d);}return logger[_0xd19f('0xd')](_0xd19f('0x19'));}};module['exports']=Graph;