Built motion from commit (unavailable).|2.4.17
[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 _0x6ae2=['no\x20vertex\x20found','stop\x20traverse','length','condition','split','agicommand','vswitch','target','default','invalid','includes','max\x20retry\x20reach','exports','lodash','../../../config/logger','agi','menu','getdigits','getsecretdigits','vertices','edges','numberOfEdges','addVertex','prototype','addEdge','push','size','relations','traverseBFS','info'];(function(_0x4744b1,_0x1f53ed){var _0xa1e07=function(_0x3a1e89){while(--_0x3a1e89){_0x4744b1['push'](_0x4744b1['shift']());}};_0xa1e07(++_0x1f53ed);}(_0x6ae2,0x1ed));var _0x26ae=function(_0x4673eb,_0x2defb1){_0x4673eb=_0x4673eb-0x0;var _0x10a792=_0x6ae2[_0x4673eb];return _0x10a792;};'use strict';var _=require(_0x26ae('0x0'));var logger=require(_0x26ae('0x1'))(_0x26ae('0x2'));var verticesWithRetry=[_0x26ae('0x3'),_0x26ae('0x4'),_0x26ae('0x5')];var Graph=function(){this[_0x26ae('0x6')]={};this[_0x26ae('0x7')]={};this[_0x26ae('0x8')]=0x0;};Graph['prototype'][_0x26ae('0x9')]=function(_0x408677){this['vertices'][_0x408677['id']]=_0x408677;this['edges'][_0x408677['id']]=[];};Graph[_0x26ae('0xa')][_0x26ae('0xb')]=function(_0x473907,_0x151de3,_0x3bc9de){this[_0x26ae('0x7')][_0x473907][_0x26ae('0xc')]({'target':_0x151de3,'condition':_0x3bc9de});this[_0x26ae('0x8')]+=0x1;};Graph[_0x26ae('0xa')][_0x26ae('0xd')]=function(){return _[_0x26ae('0xd')](this[_0x26ae('0x6')]);};Graph['prototype'][_0x26ae('0xe')]=function(){return this['numberOfEdges'];};Graph[_0x26ae('0xa')]['getVertex']=function(_0x4cb715){return this[_0x26ae('0x6')][_0x4cb715];};Graph[_0x26ae('0xa')][_0x26ae('0xf')]=function(_0x17f9a6,_0x286b7e){if(!this[_0x26ae('0x6')][_0x17f9a6]){return logger[_0x26ae('0x10')](_0x26ae('0x11'));}var _0x2390a7=_0x286b7e(this[_0x26ae('0x6')][_0x17f9a6]);if(!_0x2390a7){return logger[_0x26ae('0x10')](_0x26ae('0x12'));}if(this['edges'][_0x17f9a6][_0x26ae('0x13')]===0x0){return logger[_0x26ae('0x10')]('no\x20edge/s\x20available');}for(var _0x444397=0x0,_0x3426d8=[],_0x4f71d8=![];_0x444397<this[_0x26ae('0x7')][_0x17f9a6][_0x26ae('0x13')];_0x444397+=0x1){if(this[_0x26ae('0x7')][_0x17f9a6][_0x444397][_0x26ae('0x14')]){_0x3426d8=this[_0x26ae('0x7')][_0x17f9a6][_0x444397][_0x26ae('0x14')][_0x26ae('0x15')](',');for(var _0x1e5cf5=0x0;_0x1e5cf5<_0x3426d8[_0x26ae('0x13')];_0x1e5cf5+=0x1){if(this[_0x26ae('0x6')][_0x17f9a6][_0x26ae('0x16')]===_0x26ae('0x17')&&_0x3426d8[_0x1e5cf5]==='-'){_0x4f71d8=this[_0x26ae('0x7')][_0x17f9a6][_0x444397][_0x26ae('0x18')];logger[_0x26ae('0x10')](_0x26ae('0x19'),_0x3426d8[_0x1e5cf5],this[_0x26ae('0x7')][_0x17f9a6][_0x444397][_0x26ae('0x18')]);}else if(this['vertices'][_0x17f9a6]['agicommand']===_0x26ae('0x3')&&_0x3426d8[_0x1e5cf5]==='i'){_0x4f71d8=this['edges'][_0x17f9a6][_0x444397][_0x26ae('0x18')];logger['info'](_0x26ae('0x1a'),_0x3426d8[_0x1e5cf5],this[_0x26ae('0x7')][_0x17f9a6][_0x444397][_0x26ae('0x18')]);}if(_0x3426d8[_0x1e5cf5]===_0x2390a7){return this['traverseBFS'](this['edges'][_0x17f9a6][_0x444397][_0x26ae('0x18')],_0x286b7e);}}}else{return this[_0x26ae('0xf')](this[_0x26ae('0x7')][_0x17f9a6][_0x444397]['target'],_0x286b7e);}}if(_0x3426d8[_0x26ae('0x13')]){if(this[_0x26ae('0x6')][_0x17f9a6]['agicommand']===_0x26ae('0x17')){if(_0x4f71d8){return this[_0x26ae('0xf')](_0x4f71d8,_0x286b7e);}return logger[_0x26ae('0x10')]('default\x20on\x20switch\x20not\x20found');}else if(_[_0x26ae('0x1b')](verticesWithRetry,this['vertices'][_0x17f9a6][_0x26ae('0x16')])){if(_0x2390a7==='-'){return logger[_0x26ae('0x10')](_0x26ae('0x1c'));}if(_0x4f71d8&&_0x2390a7!=='t'){return this['traverseBFS'](_0x4f71d8,_0x286b7e);}return this[_0x26ae('0xf')](_0x17f9a6,_0x286b7e);}return logger['info']('condition\x20not\x20found');}};module[_0x26ae('0x1d')]=Graph;