e4932fec1052c9499a201047e0956f0a594f8509
[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 _0x59bb=['size','relations','getVertex','traverseBFS','info','stop\x20traverse','length','no\x20edge/s\x20available','condition','split','vswitch','target','agicommand','invalid','includes','max\x20retry\x20reach','condition\x20not\x20found','exports','lodash','../../../config/logger','agi','menu','getdigits','getsecretdigits','vertices','numberOfEdges','prototype','edges','addEdge','push'];(function(_0x5d053d,_0x27b8f0){var _0x39d534=function(_0x29de7d){while(--_0x29de7d){_0x5d053d['push'](_0x5d053d['shift']());}};_0x39d534(++_0x27b8f0);}(_0x59bb,0x6c));var _0xb59b=function(_0x13d07a,_0x41efc3){_0x13d07a=_0x13d07a-0x0;var _0x5ee0ee=_0x59bb[_0x13d07a];return _0x5ee0ee;};'use strict';var _=require(_0xb59b('0x0'));var logger=require(_0xb59b('0x1'))(_0xb59b('0x2'));var verticesWithRetry=[_0xb59b('0x3'),_0xb59b('0x4'),_0xb59b('0x5')];var Graph=function(){this[_0xb59b('0x6')]={};this['edges']={};this[_0xb59b('0x7')]=0x0;};Graph[_0xb59b('0x8')]['addVertex']=function(_0xca8d90){this[_0xb59b('0x6')][_0xca8d90['id']]=_0xca8d90;this[_0xb59b('0x9')][_0xca8d90['id']]=[];};Graph['prototype'][_0xb59b('0xa')]=function(_0x2bbcbf,_0xb6fb69,_0x153431){this['edges'][_0x2bbcbf][_0xb59b('0xb')]({'target':_0xb6fb69,'condition':_0x153431});this['numberOfEdges']+=0x1;};Graph[_0xb59b('0x8')][_0xb59b('0xc')]=function(){return _[_0xb59b('0xc')](this[_0xb59b('0x6')]);};Graph[_0xb59b('0x8')][_0xb59b('0xd')]=function(){return this[_0xb59b('0x7')];};Graph['prototype'][_0xb59b('0xe')]=function(_0x151e43){return this[_0xb59b('0x6')][_0x151e43];};Graph[_0xb59b('0x8')][_0xb59b('0xf')]=function(_0x4da39b,_0x1d37c0){if(!this[_0xb59b('0x6')][_0x4da39b]){return logger[_0xb59b('0x10')]('no\x20vertex\x20found');}var _0xc3f9c7=_0x1d37c0(this[_0xb59b('0x6')][_0x4da39b]);if(!_0xc3f9c7){return logger[_0xb59b('0x10')](_0xb59b('0x11'));}if(this[_0xb59b('0x9')][_0x4da39b][_0xb59b('0x12')]===0x0){return logger[_0xb59b('0x10')](_0xb59b('0x13'));}for(var _0x45adcf=0x0,_0x108afd=[],_0x29a959=![];_0x45adcf<this[_0xb59b('0x9')][_0x4da39b][_0xb59b('0x12')];_0x45adcf+=0x1){if(this[_0xb59b('0x9')][_0x4da39b][_0x45adcf][_0xb59b('0x14')]){_0x108afd=this['edges'][_0x4da39b][_0x45adcf][_0xb59b('0x14')][_0xb59b('0x15')](',');for(var _0x273585=0x0;_0x273585<_0x108afd[_0xb59b('0x12')];_0x273585+=0x1){if(this[_0xb59b('0x6')][_0x4da39b]['agicommand']===_0xb59b('0x16')&&_0x108afd[_0x273585]==='-'){_0x29a959=this[_0xb59b('0x9')][_0x4da39b][_0x45adcf][_0xb59b('0x17')];logger[_0xb59b('0x10')]('default',_0x108afd[_0x273585],this['edges'][_0x4da39b][_0x45adcf][_0xb59b('0x17')]);}else if(this[_0xb59b('0x6')][_0x4da39b][_0xb59b('0x18')]===_0xb59b('0x3')&&_0x108afd[_0x273585]==='i'){_0x29a959=this['edges'][_0x4da39b][_0x45adcf][_0xb59b('0x17')];logger[_0xb59b('0x10')](_0xb59b('0x19'),_0x108afd[_0x273585],this[_0xb59b('0x9')][_0x4da39b][_0x45adcf][_0xb59b('0x17')]);}if(_0x108afd[_0x273585]===_0xc3f9c7){return this['traverseBFS'](this[_0xb59b('0x9')][_0x4da39b][_0x45adcf][_0xb59b('0x17')],_0x1d37c0);}}}else{return this[_0xb59b('0xf')](this[_0xb59b('0x9')][_0x4da39b][_0x45adcf][_0xb59b('0x17')],_0x1d37c0);}}if(_0x108afd['length']){if(this[_0xb59b('0x6')][_0x4da39b][_0xb59b('0x18')]==='vswitch'){if(_0x29a959){return this[_0xb59b('0xf')](_0x29a959,_0x1d37c0);}return logger['info']('default\x20on\x20switch\x20not\x20found');}else if(_[_0xb59b('0x1a')](verticesWithRetry,this[_0xb59b('0x6')][_0x4da39b][_0xb59b('0x18')])){if(_0xc3f9c7==='-'){return logger['info'](_0xb59b('0x1b'));}if(_0x29a959&&_0xc3f9c7!=='t'){return this[_0xb59b('0xf')](_0x29a959,_0x1d37c0);}return this[_0xb59b('0xf')](_0x4da39b,_0x1d37c0);}return logger[_0xb59b('0x10')](_0xb59b('0x1c'));}};module[_0xb59b('0x1d')]=Graph;