Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / routing / server / applications / gotoif.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 _0xcd39=['findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','[%s][GOTOIF]\x20priority\x20%s\x20not\x20found','stop','validate','lodash','html-to-text','./utils','../../../../config/logger','routing','string','condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','fromString','length','error','map','message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next'];(function(_0x3461ac,_0x2490dc){var _0x13e98d=function(_0x3d6e7e){while(--_0x3d6e7e){_0x3461ac['push'](_0x3461ac['shift']());}};_0x13e98d(++_0x2490dc);}(_0xcd39,0x161));var _0x9cd3=function(_0x2be8c2,_0x14a4b5){_0x2be8c2=_0x2be8c2-0x0;var _0x97f531=_0xcd39[_0x2be8c2];return _0x97f531;};'use strict';var schema=require(_0x9cd3('0x0'));var _=require(_0x9cd3('0x1'));var htmlToText=require(_0x9cd3('0x2'));var utils=require(_0x9cd3('0x3'));var logger=require(_0x9cd3('0x4'))(_0x9cd3('0x5'));var gotoif=schema({'condition':{'type':_0x9cd3('0x6'),'required':!![],'message':_0x9cd3('0x7')},'priorityTrue':{'type':_0x9cd3('0x8'),'message':_0x9cd3('0x9')},'priorityFalse':{'type':_0x9cd3('0x8'),'message':_0x9cd3('0xa')}});exports[_0x9cd3('0xb')]=function(_0x4eab24,_0x1b179e){return function(_0x547566){try{var _0x55ef9f={'condition':htmlToText[_0x9cd3('0xc')](utils['getMustacheRender'](_0x1b179e[0x0],this),{'wordwrap':![]})['replace'](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1b179e[0x1],'priorityFalse':_0x1b179e[0x2]};var _0x10ad06=gotoif['validate'](_0x55ef9f,{'typecast':!![]});if(_0x10ad06[_0x9cd3('0xd')]){logger[_0x9cd3('0xe')]('[%s][GOTOIF]\x20%s',_0x4eab24,_[_0x9cd3('0xf')](_0x10ad06,_0x9cd3('0x10'))[_0x9cd3('0x11')](',\x20'));_0x547566['stop']();}else{try{var _0x4d7880=eval('('+_0x55ef9f[_0x9cd3('0x12')]+')');var _0x378c8a=_0x4d7880?_0x55ef9f[_0x9cd3('0x13')]:_0x55ef9f[_0x9cd3('0x14')];logger[_0x9cd3('0x15')](_0x9cd3('0x16'),_0x4eab24,_0x55ef9f[_0x9cd3('0x12')],_0x4d7880,_0x378c8a||_0x9cd3('0x17'));if(_0x378c8a){var _0x264ddb=_[_0x9cd3('0x18')](_0x547566[_0x9cd3('0x19')](),{'p':_0x378c8a});if(_0x264ddb>=0x0){logger[_0x9cd3('0x15')](_0x9cd3('0x1a'),_0x4eab24,_0x378c8a||_0x9cd3('0x17'),_0x264ddb);_0x547566[_0x9cd3('0x17')](_0x264ddb);}else{logger[_0x9cd3('0x15')](_0x9cd3('0x1b'),_0x4eab24,_0x378c8a||_0x9cd3('0x17'));_0x547566[_0x9cd3('0x1c')]();}}else{_0x547566[_0x9cd3('0x17')]();}}catch(_0x30d8c8){logger[_0x9cd3('0xe')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x4eab24,_0x30d8c8[_0x9cd3('0x10')]);_0x547566[_0x9cd3('0x1c')]();}}}catch(_0x4b83e6){logger[_0x9cd3('0xe')]('[%s][GOTOIF]\x20%s',_0x4eab24,JSON['stringify'](_0x4b83e6));_0x547566['stop']();}};};