Built motion from commit (unavailable).|2.0.79
[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 _0x9265=['lodash','html-to-text','./utils','../../../../config/logger','routing','string','number','priority\x20true\x20is\x20a\x20number','priority\x20false\x20is\x20a\x20number','consequence','getMustacheRender','replace','validate','length','error','[%s][GOTOIF]\x20%s','message','join','condition','priorityTrue','priorityFalse','info','[%s][GOTOIF]\x20condition\x20%s\x20is\x20%s\x20try\x20goto\x20priority\x20%s','next','findIndex','rules','[%s][GOTOIF]\x20priority\x20%s\x20found\x20at\x20index:\x20%s','stop','stringify'];(function(_0xd19a37,_0x54e158){var _0x50123d=function(_0x7b266d){while(--_0x7b266d){_0xd19a37['push'](_0xd19a37['shift']());}};_0x50123d(++_0x54e158);}(_0x9265,0x179));var _0x5926=function(_0x88594,_0x55596d){_0x88594=_0x88594-0x0;var _0x475227=_0x9265[_0x88594];return _0x475227;};'use strict';var schema=require('validate');var _=require(_0x5926('0x0'));var htmlToText=require(_0x5926('0x1'));var utils=require(_0x5926('0x2'));var logger=require(_0x5926('0x3'))(_0x5926('0x4'));var gotoif=schema({'condition':{'type':_0x5926('0x5'),'required':!![],'message':'condition\x20is\x20a\x20string\x20and\x20it\x20is\x20required'},'priorityTrue':{'type':_0x5926('0x6'),'message':_0x5926('0x7')},'priorityFalse':{'type':_0x5926('0x6'),'message':_0x5926('0x8')}});exports[_0x5926('0x9')]=function(_0x3c55af,_0x1eeac8){return function(_0x581135){try{var _0xa541e0={'condition':htmlToText['fromString'](utils[_0x5926('0xa')](_0x1eeac8[0x0],this),{'wordwrap':![]})[_0x5926('0xb')](/<\/?[^>]+(>|$)/g,''),'priorityTrue':_0x1eeac8[0x1],'priorityFalse':_0x1eeac8[0x2]};var _0x2938be=gotoif[_0x5926('0xc')](_0xa541e0,{'typecast':!![]});if(_0x2938be[_0x5926('0xd')]){logger[_0x5926('0xe')](_0x5926('0xf'),_0x3c55af,_['map'](_0x2938be,_0x5926('0x10'))[_0x5926('0x11')](',\x20'));_0x581135['stop']();}else{try{var _0x413080=eval('('+_0xa541e0[_0x5926('0x12')]+')');var _0x2d0bc1=_0x413080?_0xa541e0[_0x5926('0x13')]:_0xa541e0[_0x5926('0x14')];logger[_0x5926('0x15')](_0x5926('0x16'),_0x3c55af,_0xa541e0[_0x5926('0x12')],_0x413080,_0x2d0bc1||_0x5926('0x17'));if(_0x2d0bc1){var _0xb824d1=_[_0x5926('0x18')](_0x581135[_0x5926('0x19')](),{'p':_0x2d0bc1});if(_0xb824d1>=0x0){logger[_0x5926('0x15')](_0x5926('0x1a'),_0x3c55af,_0x2d0bc1||_0x5926('0x17'),_0xb824d1);_0x581135[_0x5926('0x17')](_0xb824d1);}else{logger[_0x5926('0x15')]('[%s][GOTOIF]\x20priority\x20%s\x20not\x20found',_0x3c55af,_0x2d0bc1||_0x5926('0x17'));_0x581135['stop']();}}else{_0x581135[_0x5926('0x17')]();}}catch(_0x29763d){logger[_0x5926('0xe')]('[%s][GOTOIF]\x20eval\x20error:\x20%s',_0x3c55af,_0x29763d[_0x5926('0x10')]);_0x581135[_0x5926('0x1b')]();}}}catch(_0x48f9ab){logger[_0x5926('0xe')](_0x5926('0xf'),_0x3c55af,JSON[_0x5926('0x1c')](_0x48f9ab));_0x581135[_0x5926('0x1b')]();}};};