apxor-qe 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,h(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=h(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function h(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var l=function(t){return void 0!==t&&!function(t){return null===t}(t)},f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function v(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var d=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=f.indexOf(t.charAt(s++))<<18|f.indexOf(t.charAt(s++))<<12|(i=f.indexOf(t.charAt(s++)))<<6|(o=f.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},p=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},q=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},E=window.ApxorLogger,_=a((function e(){var r=this;i(this,e),s(this,"FRto","ALL"),s(this,"XOXE",[]),s(this,"ymoy",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.FRto=t.audience.audience_type,r.XOXE=t.audience.attributes.user,r.ymoy=t.audience.attributes.session,!Array.isArray(r.XOXE)||!Array.isArray(r.ymoy))return E.error("No attributes"),!1}catch(t){return E.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.FRto&&(i=t.getController().getSessionInfo().is_first_session),i&&r.zhwx(e,r.XOXE)&&r.zhwx(n,r.ymoy)})),s(this,"zhwx",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){E.error(t),n=!1}return n}))})),x=window.ApxorLogger,w=a((function t(){var e=this;i(this,t),s(this,"JYXL",0),s(this,"PiGR",0),s(this,"vfjA","SESSION"),s(this,"URsA",0),s(this,"XKEQ",0),s(this,"lzXh",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.JYXL=t.frequency.count,e.lzXh=e.JYXL,e.PiGR=t.frequency.time_interval,e.vfjA=t.frequency.validity,e.XKEQ=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=k.getInstance().getQeState();if(!l(r)||!l(r[t._id]))return!0;if("SESSION"===e.vfjA){if(e.JYXL=parseInt(e.JYXL)-parseInt(r[t._id].SESSION),e.JYXL<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.vfjA)return x.info("Invalid config."),!1;if(e.JYXL=parseInt(e.JYXL)-parseInt(r[t._id].OVERALL),e.JYXL<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return x.error(t),!1}return!0})),s(this,"xUhr",(function(){e.JYXL=e.JYXL-1})),s(this,"getFrequencyCount",(function(){return e.JYXL})),s(this,"ICox",(function(){"SESSION"===e.vfjA&&(e.JYXL=e.lzXh,x.info("Campaign Limit reset"))})),s(this,"nMOr",(function(t){try{if(e.JYXL<=0)return!1;var r=k.getInstance().getQeState();if(!l(r)||!l(r[t]))return!0;if(0!==e.XKEQ)if(parseInt(e.XKEQ)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=q();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){x.error("Error validating the frequency:"+t)}return!0}))})),O=a((function t(){var e=this;i(this,t),s(this,"QyLR",""),s(this,"FRto",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.QyLR=t.meta.name,e.FRto=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(r=t.meta)||void 0===r?void 0:r.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),S=window.ApxorLogger,b=a((function t(){var e=this;i(this,t),s(this,"XfuM",-1),s(this,"ReIZ",-1),s(this,"fQTm",-1),s(this,"gqFc",-1),s(this,"pQjU",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return S.error("Not valid dates"),!1;if(e.XfuM=Date.parse(t.validity.start_date),e.ReIZ=Date.parse(t.validity.end_date),l(t.time_limits_in_day)&&(e.pQjU=t.time_limits_in_day,e.pQjU&&l(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.fQTm=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.gqFc=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.fQTm)||isNaN(e.gqFc))return S.error("Not valid times"),!1}}catch(t){return S.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.XfuM&&t<e.ReIZ&&(!e.pQjU||t>=e.fQTm&&t<=e.gqFc)}))})),A=a((function t(){var e=this;i(this,t),s(this,"QyLR",""),s(this,"zOxG",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.QyLR=t.name,e.zOxG=t.additional_info}catch(t){return!1}return!0}))})),R=a((function t(){var e=this;i(this,t),s(this,"idat",0),s(this,"MrEE",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.idat=Number(t.lower),e.MrEE=Number(t.upper),isNaN(e.idat)||isNaN(e.MrEE))return!1}catch(t){return!1}return!0}))})),X=a((function t(){var e=this;i(this,t),s(this,"VXqH",0),s(this,"HuTQ",""),s(this,"sGNM",""),s(this,"ExmX",new A),s(this,"LkMh",new R),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.HuTQ=t.event_type,e.sGNM=t.activity,e.ExmX.parse(t.details)&&e.LkMh.parse(t.time_bounds)}catch(t){return!1}}))})),Q=window.ApxorLogger,T=a((function t(){var e=this;i(this,t),s(this,"VXqH",0),s(this,"bMHh",-1),s(this,"JYXL",0),s(this,"oSJn",""),s(this,"sGNM",""),s(this,"HuTQ",""),s(this,"LkMh",new R),s(this,"ExmX",new A),s(this,"jgOr",new X),s(this,"uxcR","AND"),s(this,"JOpg",!1),s(this,"FRto",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.bMHh=t.sequence,e.JYXL=t.count_config.count,e.oSJn=t.count_config.operator,e.sGNM=t.activity,e.HuTQ=t.event_type,e.uxcR=t.combine_operator,e.FRto=t.type,e.ExmX.parse(t.details)&&e.jgOr.parse(t.trigger)&&e.LkMh.parse(t.time_bounds)}catch(t){return Q.error(t),!1}}))})),I=window.ApxorLogger,J=function(){function e(){var r=this;i(this,e),s(this,"Jiwq",0),s(this,"JNwh",""),s(this,"qlqc",new T),s(this,"TOIa",!1),s(this,"zrTJ",!1),s(this,"Jghh",0),s(this,"uxcR","AND"),s(this,"AHQD",-1),s(this,"Rrpn",[]),s(this,"opXu",{}),s(this,"MQKj",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];r.JNwh=n,r.Jghh=i,r.Rrpn=a;var s=r.qlqc.parse(e);if(s){if(r.uxcR=r.qlqc.uxcR,r.qlqc.JOpg){var u=r.qlqc.ExmX.QyLR;"APX_PAGE_OPENED"===u&&(u=r.qlqc.ExmX.zOxG.navigation_id,u=l(u)?u:r.qlqc.ExmX.QyLR),r.AHQD=t.getController().getEventCount(u);var c=r.qlqc.JYXL,h=r.qlqc.oSJn;if(r.zrTJ=r.fHEY(r.AHQD-1,c,h,!1),r.TOIa=r.zrTJ,r.zrTJ&&"APX_PAGE_OPENED"===r.qlqc.ExmX.QyLR)return!0}return o&&0!==i||r.QrpR(),!0}return!1})),s(this,"QrpR",(function(){var t=r.qlqc,e=t.jgOr,n=k.getInstance();"app_start"===e.HuTQ?(r.TOIa=!0,n.registerForEvent(g(t.HuTQ)+"___"+t.ExmX.QyLR,r.ZsWU)):n.registerForEvent(g(t.HuTQ)+"___"+e.ExmX.QyLR,r.ZsWU)})),s(this,"oRxW",(function(t,e,n,i){var o,a=(Date.now()-r.opXu[e])/1e3;(null===(o=r.qlqc)||void 0===o||null===(o=o.ExmX)||void 0===o||null===(o=o.zOxG)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"sxFO",(function(t,e,n,i){var o,a;r.MQKj=!0;var s=Date.now(),u=null===(o=r.qlqc)||void 0===o||null===(o=o.jgOr)||void 0===o?void 0:o.ExmX.QyLR,c=(s-r.opXu[u])/1e3,h=null===(a=r.qlqc)||void 0===a||null===(a=a.ExmX)||void 0===a||null===(a=a.zOxG)||void 0===a?void 0:a.time;(h/=1e3)>c&&r._displayCampaign(n)})),s(this,"ZsWU",(function(t,e,n,i){var o=k.getInstance();if(r.TOIa)g(r.qlqc.HuTQ)===t&&r.Kaor(n-r.qlqc.jgOr.VXqH,r.qlqc.LkMh)&&r.qlqc.ExmX.QyLR===e&&r.xWrh(r.qlqc.ExmX.zOxG,i)&&(r.Jiwq+=1,r.zrTJ=r.fHEY(r.Jiwq,r.qlqc.JYXL,r.qlqc.oSJn),r.zrTJ&&(r.qlqc.VXqH=n,o.validate(r.JNwh,r.Jghh)));else if(r.TOIa=r.MKVT(t,e,n,i),r.TOIa){var a=r.qlqc,s=a.jgOr;if(s.VXqH=n,"activity_time"===(null==a?void 0:a.HuTQ)){var u,c,h,l=null==a||null===(u=a.ExmX)||void 0===u||null===(u=u.zOxG)||void 0===u?void 0:u.time;(null==a||null===(c=a.ExmX)||void 0===c||null===(c=c.zOxG)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.MQKj||(r.zrTJ=!0,r.zrTJ&&(r.Jiwq+=1,r.zrTJ=r.fHEY(r.Jiwq,r.qlqc.JYXL,r.qlqc.oSJn),r.zrTJ&&(r.qlqc.VXqH=n,o.validate(r.JNwh,r.Jghh)))),a.ExmX.zOxG.nkpi.map((function(t){o.unregisterFromEvent(p(a.ExmX.zOxG.et)+"___"+t,r)}))}),l),a.ExmX.zOxG.nkpi.map((function(t){o.registerForEvent(p(a.ExmX.zOxG.et)+"___"+t,r.sxFO)}))),(null==a||null===(h=a.ExmX)||void 0===h||null===(h=h.zOxG)||void 0===h?void 0:h.kpi.length)>0&&(setTimeout((function(){a.ExmX.zOxG.kpi.map((function(t){o.unregisterFromEvent(p(a.ExmX.zOxG.et)+"___"+t,r)}))}),l),a.ExmX.zOxG.kpi.map((function(t){t===a.jgOr.ExmX.QyLR?(o.unregisterFromEvent(g(s.HuTQ)+"___"+s.ExmX.QyLR,r),o.registerForEvent(p(a.ExmX.zOxG.et)+"___"+t,r.oRxW)):o.registerForEvent(p(a.ExmX.zOxG.et)+"___"+t,r.sxFO)})))}else o.unregisterFromEvent(g(s.HuTQ)+"___"+s.ExmX.QyLR,r),o.registerForEvent(g(a.HuTQ)+"___"+a.ExmX.QyLR,r);r.opXu[e]=Date.now()}})),s(this,"MKVT",(function(t,e,n,i){var o=r.qlqc.jgOr;return g(o.HuTQ)===t&&o.ExmX.QyLR===e&&r.Kaor(n,o.LkMh)&&r.xWrh(o.ExmX.zOxG,i)})),s(this,"Kaor",(function(t,e){var r=Math.ceil(t);return r>e.idat&&r<e.MrEE})),s(this,"fHEY",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.qlqc.JOpg&&(t+=r.AHQD),n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"xWrh",(function(t,e){var r=!0;try{var i,o=function(){if(!e[a]||!1===r)return{v:!1};if("object"===n(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));r=r&&u}else r=r&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){I.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=k.getInstance();this.zrTJ=!0,this.zrTJ&&(this.Jiwq+=1,this.zrTJ=this.fHEY(this.Jiwq,this.qlqc.JYXL,this.qlqc.oSJn),this.zrTJ&&(this.qlqc.VXqH=t,e.validate(this.JNwh,this.Jghh)))}}]),e}(),L=window.ApxorLogger,z=a((function e(){var r=this;i(this,e),s(this,"oTxK",[]),s(this,"_ret_day",{}),s(this,"GTIY",{}),s(this,"nwjR",!1),s(this,"zbZh",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.oTxK=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.GTIY=t.overall_cfg.session,r.nwjR=t.overall_cfg.toggleRetDay,r.oTxK=t.overall_cfg.events,r.zbZh=t.overall_cfg.toggleSession}catch(t){return L.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.nwjR&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.zbZh&&!isNaN(n)&&!(n>=r.GTIY.from&&n<=r.GTIY.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(d(o,i)),s=0;s<r.oTxK.length;s++){if(a[r.oTxK[s].name.replace("'","").replace("’","")])return!1}}catch(t){L.error("Failed to validate the lt count:"+t)}return!0}))})),N=window.ApxorLogger,F=a((function e(){var n=this;i(this,e),s(this,"dbRq",[]),s(this,"JNwh",""),s(this,"hykq",new O),s(this,"dFka",new _),s(this,"vfjA",new b),s(this,"iacO",new w),s(this,"Yzlu",new z),s(this,"IgFq",!1),s(this,"wFvJ",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!l(t._id))return N.error("No Id"),!1;if(!l(t.enabled)||!t.enabled)return N.error("Not enabled"),!1;if(!(n.hykq.parse(t)&&n.vfjA.parse(t)&&n.iacO.parse(t)&&n.dFka.parse(t)&&n.Yzlu.parse(t)))return!1;if(!l(t.conditions)||!Array.isArray(t.conditions))return N.error("No valid conditions",t.conditions),!1;n.JNwh=t._id,n.IgFq=!!l(t.sequence_enabled)&&t.sequence_enabled,n.IgFq&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,i=0;i<r;i++){n.wFvJ=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.wFvJ=[].concat(u(n.wFvJ),[s])}var c=new J;c.initialize(o,n.JNwh,i,n.IgFq,n.wFvJ)&&n.dbRq.push(c)}return n.dbRq.length>0}catch(t){return N.error(t),!1}})),s(this,"alWS",(function(t){if(!(t<0))if(n.IgFq){var e=n.dbRq[t];if(l(e)&&e.zrTJ){var r=n.dbRq[t-1];if(l(r)&&!r.zrTJ)return;var i=n.dbRq[t+1];l(i)?i.QrpR():n.KUIY()}}else n.KUIY()})),s(this,"KUIY",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.vfjA.validate()&&n.dFka.validate(e,i)&&n.Yzlu.validate()){for(var o=n.dbRq.length,a=o<1,s="",u=0;u<o;u++){var c=n.dbRq[u],h=c.zrTJ;if(""===s.trim())a=h;else switch(s){case"AND":a=a&&h;break;case"OR":a=a||h}s=c.uxcR}if(a){if(console.debug("onCondition satisfied"),!n.iacO.nMOr(n.JNwh))return void console.warn("Maximum limit reached",n.JNwh);console.log("Dispatching event",n.hykq.FRto),!0===n.hykq._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.hykq._attr),{},{message_name:n.hykq.QyLR,id:n.JNwh})),t.getController().dispatchEvent(n.hykq.FRto,{name:n.hykq.FRto,additional_info:{uuid:n.JNwh,name:n.hykq.QyLR}})}}})),s(this,"xUhr",(function(){n.iacO.xUhr()})),s(this,"getFrequencyCount",(function(){return n.iacO.getFrequencyCount()})),s(this,"wiGD",(function(){return n.iacO.ICox()}))})),D=a((function t(){var e=this;i(this,t),s(this,"OhRD",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(l(t)&&l(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort((function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)}));for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new F;a.parse(i)?e.OhRD[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.OhRD[t]&&e.OhRD[t].alWS(r)})),s(this,"xUhr",(function(t){e.OhRD[t].xUhr()})),s(this,"getFrequencyCount",(function(t){return e.OhRD[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.OhRD;for(var r in t)t[r].wiGD()})),s(this,"kbdl",(function(t){try{if(e.OhRD){var r=e.OhRD[t];if(r&&r.hykq)return r.hykq}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),j=window.ApxorLogger,C=a((function e(){var r=this;i(this,e),s(this,"DANR",{}),s(this,"IgIG",[]),s(this,"fAzz",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.Nubw(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.Nubw(t,"CE")}))})),s(this,"YwjZ",(function(){for(var t in r.IgIG)r.LQzS(t.event,t.key,t.type);r.fAzz=!0})),s(this,"McRK",(function(t,e){var n;"function"==typeof e&&((n=r.DANR[t]?r.DANR[t]:[]).push(e),r.DANR[t]=n,j.debug("Listeners list: ",r.DANR))})),s(this,"unregisterFromEvent",(function(t,e){if(r.DANR[t]){for(var n=r.DANR[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.DANR[t]=i}})),s(this,"Nubw",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.LQzS(t,n,e)})),s(this,"LQzS",(function(e,n,i){if(r.fAzz){if(j.debug("Notifying listeners for event: "+e+", "+n,r.DANR),r.DANR[n])for(var o=r.DANR[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.IgIG.push({event:e,key:n,type:i})}))})),G=window.ApxorLogger,k=function(){function e(){var r=this;return i(this,e),s(this,"pXbH",!1),s(this,"ozaq",null),s(this,"sxSa",q()),s(this,"zsjy",new C),s(this,"EGPY",t.getSiteId()),s(this,"QImh",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(r.EGPY,e)):(r.QImh={},r.setQeState())}catch(t){return r.QImh={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.QImh,!0)}catch(n){""===e?r.QImh={}:r.QImh[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.QImh,!0)}return r.QImh})),s(this,"initialize",(function(){r.pXbH||(r.pXbH=!0,r.ozaq=new D,r.zsjy.initialize(),r.QImh=r.getQeState(),G.info("QE Initialized.."))})),s(this,"parse",(function(t){r.rEXU()?(r.ozaq.parse(t),r.zsjy.YwjZ()):G.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.rEXU()&&r.ozaq.validate(t,e)})),s(this,"updateCount",(function(t){try{l(r.QImh[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.ozaq.xUhr(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.ozaq.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.ozaq.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.zsjy.McRK(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.zsjy.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"rEXU",(function(){return r.pXbH})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.ozaq.kbdl(t)})),s(this,"Jiyb",(function(){return r.sxSa})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.QImh=this.getQeState(),l(this.QImh[t])||(this.QImh[t]={SESSION:0,OVERALL:0,DATES:{}},this.sxSa&&(this.QImh[t].DATES[this.sxSa]=0),this.setQeState(t))}catch(t){G.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.QImh=this.getQeState();var e=this.QImh[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=q();r===this.sxSa&&e.DATES&&e.DATES[r]||(this.sxSa=r,e.DATES={},e.DATES[this.sxSa]=0),e.DATES[this.sxSa]=e.DATES[this.sxSa]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(k,"instance",void 0),window.ceVersion=122;try{void 0===exports&&null===exports||(exports.default=k,module.exports=exports.default)}catch(t){}return k}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apxor")):"function"==typeof define&&define.amd?define(["apxor"],e):(t=t||self)["apxor-qe"]=e(t.Apxor)}(this,(function(t){"use strict";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var f=function(t){return void 0!==t&&!function(t){return null===t}(t)},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function v(t,e){return Array.from(e).map((function(e,r){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,r))})).join("")}var d=function(t,e){return v(t,e=function(t){var e,r,n,i,o,a,s=0,u=[];if(!t)return t;t+="";do{e=(a=h.indexOf(t.charAt(s++))<<18|h.indexOf(t.charAt(s++))<<12|(i=h.indexOf(t.charAt(s++)))<<6|(o=h.indexOf(t.charAt(s++))))>>16&255,r=a>>8&255,n=255&a,u.push(e),64!==i&&(u.push(r),64!==o&&u.push(n))}while(s<t.length);return u}(e))},g=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},p=function(t){return t.toUpperCase()},y=function(t,e,r){switch(r){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;case"NEQ":return t!==e;case"R":return m(e).test(t);default:return!1}},m=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var r=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(r,e)},_=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},w=window.ApxorLogger,S=a((function e(){var r=this;i(this,e),s(this,"pSoD","ALL"),s(this,"MNNc",[]),s(this,"AZyK",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(r.pSoD=t.audience.audience_type,r.MNNc=t.audience.attributes.user,r.AZyK=t.audience.attributes.session,!Array.isArray(r.MNNc)||!Array.isArray(r.AZyK))return w.error("No attributes"),!1}catch(t){return w.error(t),!1}return!0})),s(this,"validate",(function(e,n){var i=!0;return"FTU"===r.pSoD&&(i=t.getController().getSessionInfo().is_first_session),i&&r.NqMe(e,r.MNNc)&&r.NqMe(n,r.AZyK)})),s(this,"NqMe",(function(t,e){var r=e.length,n=!0;try{for(var i,o=function(){var r=e[a];if(!t[r.name]||!1===n)return{v:!1};var i=r.operator,o=r.type,s=r.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[r.name])?t[r.name]:[t[r.name]]).some((function(t){return s.some((function(e){return y(t,e,i)}))}));n=n&&u},a=0;a<r;a++)if(i=o())return i.v}catch(t){w.error(t),n=!1}return n}))})),O=window.ApxorLogger,A=a((function t(){var e=this;i(this,t),s(this,"zwQc",0),s(this,"ZPtZ",0),s(this,"WkRn","SESSION"),s(this,"SzTO",0),s(this,"FWAX",0),s(this,"czAG",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.zwQc=t.frequency.count,e.czAG=e.zwQc,e.ZPtZ=t.frequency.time_interval,e.WkRn=t.frequency.validity,e.FWAX=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var r=K.getInstance().getQeState();if(!f(r)||!f(r[t._id]))return!0;if("SESSION"===e.WkRn){if(e.zwQc=parseInt(e.zwQc)-parseInt(r[t._id].SESSION),e.zwQc<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.WkRn)return O.info("Invalid config."),!1;if(e.zwQc=parseInt(e.zwQc)-parseInt(r[t._id].OVERALL),e.zwQc<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return O.error(t),!1}return!0})),s(this,"IwRA",(function(){e.zwQc=e.zwQc-1})),s(this,"getFrequencyCount",(function(){return e.zwQc})),s(this,"UYRW",(function(){"SESSION"===e.WkRn&&(e.zwQc=e.czAG,O.info("Campaign Limit reset"))})),s(this,"FwkM",(function(t){try{if(e.zwQc<=0)return!1;var r=K.getInstance().getQeState();if(!f(r)||!f(r[t]))return!0;if(0!==e.FWAX)if(parseInt(e.FWAX)-parseInt(r[t].SESSION)<=0)return!1;if(0!==e._dayCount){var n,i=_();if(parseInt(e._dayCount)-parseInt((null===(n=r[t])||void 0===n?void 0:n.DATES[i])||0)<=0)return!1}}catch(t){O.error("Error validating the frequency:"+t)}return!0}))})),E=a((function t(){var e=this;i(this,t),s(this,"XiTx",""),s(this,"pSoD",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var r;e.XiTx=t.meta.name,e.pSoD=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(r=t.meta)||void 0===r?void 0:r.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),x=window.ApxorLogger,T=a((function t(){var e=this;i(this,t),s(this,"Dpxa",-1),s(this,"YMiy",-1),s(this,"wPDl",-1),s(this,"SeqK",-1),s(this,"XgJJ",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(isNaN(Date.parse(t.validity.start_date))||isNaN(Date.parse(t.validity.end_date)))return x.error("Not valid dates"),!1;if(e.Dpxa=Date.parse(t.validity.start_date),e.YMiy=Date.parse(t.validity.end_date),f(t.time_limits_in_day)&&(e.XgJJ=t.time_limits_in_day,e.XgJJ&&f(t.time_limits))){var r=(new Date).toISOString().split("T")[0];if(e.wPDl=Date.parse(r+"T"+t.time_limits.start_time+".000Z"),e.SeqK=Date.parse(r+"T"+t.time_limits.end_time+".000Z"),isNaN(e.wPDl)||isNaN(e.SeqK))return x.error("Not valid times"),!1}}catch(t){return x.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.Dpxa&&t<e.YMiy&&(!e.XgJJ||t>=e.wPDl&&t<=e.SeqK)}))})),F=a((function t(){var e=this;i(this,t),s(this,"XiTx",""),s(this,"BKuT",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.XiTx=t.name,e.BKuT=t.additional_info}catch(t){return!1}return!0}))})),N=a((function t(){var e=this;i(this,t),s(this,"EDYb",0),s(this,"qEcy",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.EDYb=Number(t.lower),e.qEcy=Number(t.upper),isNaN(e.EDYb)||isNaN(e.qEcy))return!1}catch(t){return!1}return!0}))})),J=a((function t(){var e=this;i(this,t),s(this,"Psjs",0),s(this,"phws",""),s(this,"nxGv",""),s(this,"UJWO",new F),s(this,"YrXX",new N),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.phws=t.event_type,e.nxGv=t.activity,e.UJWO.parse(t.details)&&e.YrXX.parse(t.time_bounds)}catch(t){return!1}}))})),b=window.ApxorLogger,I=a((function t(){var e=this;i(this,t),s(this,"Psjs",0),s(this,"xJVh",-1),s(this,"zwQc",0),s(this,"kxcj",""),s(this,"nxGv",""),s(this,"phws",""),s(this,"YrXX",new N),s(this,"UJWO",new F),s(this,"pHAk",new J),s(this,"JJoS","AND"),s(this,"VNBK",!1),s(this,"pSoD",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.xJVh=t.sequence,e.zwQc=t.count_config.count,e.kxcj=t.count_config.operator,e.nxGv=t.activity,e.phws=t.event_type,e.JJoS=t.combine_operator,e.pSoD=t.type,e.UJWO.parse(t.details)&&e.pHAk.parse(t.trigger)&&e.YrXX.parse(t.time_bounds)}catch(t){return b.error(t),!1}}))})),U=window.ApxorLogger,D=function(){function e(){var r=this;i(this,e),s(this,"GFNv",0),s(this,"Eusd",""),s(this,"FdIU",new I),s(this,"KoRY",!1),s(this,"gCiS",!1),s(this,"lVAx",0),s(this,"JJoS","AND"),s(this,"Fqrt",-1),s(this,"IoCi",[]),s(this,"bGlk",{}),s(this,"PLjP",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[];r.Eusd=n,r.lVAx=i,r.IoCi=a;var s=r.FdIU.parse(e);if(s){if(r.JJoS=r.FdIU.JJoS,r.FdIU.VNBK){var u=r.FdIU.UJWO.XiTx;"APX_PAGE_OPENED"===u&&(u=r.FdIU.UJWO.BKuT.navigation_id,u=f(u)?u:r.FdIU.UJWO.XiTx),r.Fqrt=t.getController().getEventCount(u);var c=r.FdIU.zwQc,l=r.FdIU.kxcj;if(r.gCiS=r.HAgk(r.Fqrt-1,c,l,!1),r.KoRY=r.gCiS,r.gCiS&&"APX_PAGE_OPENED"===r.FdIU.UJWO.XiTx)return!0}return o&&0!==i||r.alSx(),!0}return!1})),s(this,"alSx",(function(){var t=r.FdIU,e=t.pHAk,n=K.getInstance();"app_start"===e.phws?(r.KoRY=!0,n.registerForEvent(g(t.phws)+"___"+t.UJWO.XiTx,r.HcVn)):n.registerForEvent(g(t.phws)+"___"+e.UJWO.XiTx,r.HcVn)})),s(this,"GNlE",(function(t,e,n,i){var o,a=(Date.now()-r.bGlk[e])/1e3;(null===(o=r.FdIU)||void 0===o||null===(o=o.UJWO)||void 0===o||null===(o=o.BKuT)||void 0===o?void 0:o.time)/1e3>a&&r._displayCampaign(n)})),s(this,"zRAr",(function(t,e,n,i){var o,a;r.PLjP=!0;var s=Date.now(),u=null===(o=r.FdIU)||void 0===o||null===(o=o.pHAk)||void 0===o?void 0:o.UJWO.XiTx,c=(s-r.bGlk[u])/1e3,l=null===(a=r.FdIU)||void 0===a||null===(a=a.UJWO)||void 0===a||null===(a=a.BKuT)||void 0===a?void 0:a.time;(l/=1e3)>c&&r._displayCampaign(n)})),s(this,"HcVn",(function(t,e,n,i){var o=K.getInstance();if(r.KoRY)g(r.FdIU.phws)===t&&r.INmv(n-r.FdIU.pHAk.Psjs,r.FdIU.YrXX)&&r.FdIU.UJWO.XiTx===e&&r.FRhW(r.FdIU.UJWO.BKuT,i)&&(r.GFNv+=1,r.gCiS=r.HAgk(r.GFNv,r.FdIU.zwQc,r.FdIU.kxcj),r.gCiS&&(r.FdIU.Psjs=n,o.validate(r.Eusd,r.lVAx)));else if(r.KoRY=r.mAby(t,e,n,i),r.KoRY){var a=r.FdIU,s=a.pHAk;if(s.Psjs=n,"activity_time"===(null==a?void 0:a.phws)){var u,c,l,f=null==a||null===(u=a.UJWO)||void 0===u||null===(u=u.BKuT)||void 0===u?void 0:u.time;(null==a||null===(c=a.UJWO)||void 0===c||null===(c=c.BKuT)||void 0===c?void 0:c.nkpi.length)>0&&(setTimeout((function(){r.PLjP||(r.gCiS=!0,r.gCiS&&(r.GFNv+=1,r.gCiS=r.HAgk(r.GFNv,r.FdIU.zwQc,r.FdIU.kxcj),r.gCiS&&(r.FdIU.Psjs=n,o.validate(r.Eusd,r.lVAx)))),a.UJWO.BKuT.nkpi.map((function(t){o.unregisterFromEvent(p(a.UJWO.BKuT.et)+"___"+t,r)}))}),f),a.UJWO.BKuT.nkpi.map((function(t){o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.zRAr)}))),(null==a||null===(l=a.UJWO)||void 0===l||null===(l=l.BKuT)||void 0===l?void 0:l.kpi.length)>0&&(setTimeout((function(){a.UJWO.BKuT.kpi.map((function(t){o.unregisterFromEvent(p(a.UJWO.BKuT.et)+"___"+t,r)}))}),f),a.UJWO.BKuT.kpi.map((function(t){t===a.pHAk.UJWO.XiTx?(o.unregisterFromEvent(g(s.phws)+"___"+s.UJWO.XiTx,r),o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.GNlE)):o.registerForEvent(p(a.UJWO.BKuT.et)+"___"+t,r.zRAr)})))}else o.unregisterFromEvent(g(s.phws)+"___"+s.UJWO.XiTx,r),o.registerForEvent(g(a.phws)+"___"+a.UJWO.XiTx,r);r.bGlk[e]=Date.now()}})),s(this,"mAby",(function(t,e,n,i){var o=r.FdIU.pHAk;return g(o.phws)===t&&o.UJWO.XiTx===e&&r.INmv(n,o.YrXX)&&r.FRhW(o.UJWO.BKuT,i)})),s(this,"INmv",(function(t,e){var r=Math.ceil(t);return r>e.EDYb&&r<e.qEcy})),s(this,"HAgk",(function(t,e,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&r.FdIU.VNBK&&(t+=r.Fqrt),n){case"EQ":return t===e;case"GT":return t>e;case"GTE":return t>=e;case"LT":return t<e;case"LTE":return t<=e;default:return!1}})),s(this,"FRhW",(function(t,e){var r=!0;try{var i,o=function(){if(!e[a]||!1===r)return{v:!1};if("object"===n(t[a])){var i,o=t[a].op,s=t[a].t;"s"===s?i=t[a].val:"l"!==s&&"f"!==s||(i=parseFloat(t[a].val));var u=(Array.isArray(e[a])?e[a]:[e[a]]).some((function(t){return y(t,i,o)}));r=r&&u}else r=r&&y(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){U.error(t),r=!1}return r}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=K.getInstance();this.gCiS=!0,this.gCiS&&(this.GFNv+=1,this.gCiS=this.HAgk(this.GFNv,this.FdIU.zwQc,this.FdIU.kxcj),this.gCiS&&(this.FdIU.Psjs=t,e.validate(this.Eusd,this.lVAx)))}}]),e}(),C=window.ApxorLogger,j=a((function e(){var r=this;i(this,e),s(this,"VJYi",[]),s(this,"_ret_day",{}),s(this,"EsoR",{}),s(this,"sVml",!1),s(this,"stSX",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{r.VJYi=t.overall_cfg.events,r._ret_day=t.overall_cfg.ret_day,r.EsoR=t.overall_cfg.session,r.sVml=t.overall_cfg.toggleRetDay,r.VJYi=t.overall_cfg.events,r.stSX=t.overall_cfg.toggleSession}catch(t){return C.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),n=parseInt(t.getController().getFromStorage("apx_retained_session"));if(r.sVml&&!isNaN(e)&&!(e>=r._ret_day.from&&e<=r._ret_day.to))return!1;if(r.stSX&&!isNaN(n)&&!(n>=r.EsoR.from&&n<=r.EsoR.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse(d(o,i)),s=0;s<r.VJYi.length;s++){if(a[r.VJYi[s].name.replace("'","").replace("’","")])return!1}}catch(t){C.error("Failed to validate the lt count:"+t)}return!0}))})),R=window.ApxorLogger,W=a((function e(){var n=this;i(this,e),s(this,"HMDi",[]),s(this,"Eusd",""),s(this,"TZgO",new E),s(this,"ygTF",new S),s(this,"WkRn",new T),s(this,"JOfv",new A),s(this,"OLfY",new j),s(this,"vZax",!1),s(this,"fyZj",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!f(t._id))return R.error("No Id"),!1;if(!f(t.enabled)||!t.enabled)return R.error("Not enabled"),!1;if(!(n.TZgO.parse(t)&&n.WkRn.parse(t)&&n.JOfv.parse(t)&&n.ygTF.parse(t)&&n.OLfY.parse(t)))return!1;if(!f(t.conditions)||!Array.isArray(t.conditions))return R.error("No valid conditions",t.conditions),!1;n.Eusd=t._id,n.vZax=!!f(t.sequence_enabled)&&t.sequence_enabled,n.vZax&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,r=e.length,i=0;i<r;i++){n.fyZj=[];var o=e[i];if("didn't"===o.type){var a,s={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(a=o.details)||void 0===a||null===(a=a.additional_info)||void 0===a?void 0:a.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};n.fyZj=[].concat(u(n.fyZj),[s])}var c=new D;c.initialize(o,n.Eusd,i,n.vZax,n.fyZj)&&n.HMDi.push(c)}return n.HMDi.length>0}catch(t){return R.error(t),!1}})),s(this,"ZsYF",(function(t){if(!(t<0))if(n.vZax){var e=n.HMDi[t];if(f(e)&&e.gCiS){var r=n.HMDi[t-1];if(f(r)&&!r.gCiS)return;var i=n.HMDi[t+1];f(i)?i.alSx():n.wcgW()}}else n.wcgW()})),s(this,"wcgW",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(n.WkRn.validate()&&n.ygTF.validate(e,i)&&n.OLfY.validate()){for(var o=n.HMDi.length,a=o<1,s="",u=0;u<o;u++){var c=n.HMDi[u],l=c.gCiS;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.JJoS}if(a){if(console.debug("onCondition satisfied"),!n.JOfv.FwkM(n.Eusd))return void console.warn("Maximum limit reached",n.Eusd);console.log("Dispatching event",n.TZgO.pSoD),!0===n.TZgO._only_context&&t.logEvent("apx_context_evaluated",r(r({},n.TZgO._attr),{},{message_name:n.TZgO.XiTx,id:n.Eusd})),t.getController().dispatchEvent(n.TZgO.pSoD,{name:n.TZgO.pSoD,additional_info:{uuid:n.Eusd,name:n.TZgO.XiTx}})}}})),s(this,"IwRA",(function(){n.JOfv.IwRA()})),s(this,"getFrequencyCount",(function(){return n.JOfv.getFrequencyCount()})),s(this,"Dith",(function(){return n.JOfv.UYRW()}))})),k=a((function t(){var e=this;i(this,t),s(this,"ooiv",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(f(t)&&f(t.configs)){var r=t.configs;if(!Array.isArray(r))return;r.sort((function(t,e){var r,n;return(null!==(r=t.prio)&&void 0!==r?r:-1)-(null!==(n=e.prio)&&void 0!==n?n:-1)}));for(var n=0;n<r.length;n++){var i=r[n],o=i._id,a=new W;a.parse(i)?e.ooiv[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,r){e.ooiv[t]&&e.ooiv[t].ZsYF(r)})),s(this,"IwRA",(function(t){e.ooiv[t].IwRA()})),s(this,"getFrequencyCount",(function(t){return e.ooiv[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.ooiv;for(var r in t)t[r].Dith()})),s(this,"NrmJ",(function(t){try{if(e.ooiv){var r=e.ooiv[t];if(r&&r.TZgO)return r.TZgO}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),P=window.ApxorLogger,q=a((function e(){var r=this;i(this,e),s(this,"fJga",{}),s(this,"mDlm",[]),s(this,"UAPh",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return r.IjTE(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return r.IjTE(t,"CE")}))})),s(this,"xcoZ",(function(){for(var t in r.mDlm)r.Ywjj(t.event,t.key,t.type);r.UAPh=!0})),s(this,"Pdms",(function(t,e){var n;"function"==typeof e&&((n=r.fJga[t]?r.fJga[t]:[]).push(e),r.fJga[t]=n,P.debug("Listeners list: ",r.fJga))})),s(this,"unregisterFromEvent",(function(t,e){if(r.fJga[t]){for(var n=r.fJga[t],i=[],o=0;o<n.length;o++){var a=n[o];a!==e&&i.push(a)}r.fJga[t]=i}})),s(this,"IjTE",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",n=e+"___"+t.name;r.Ywjj(t,n,e)})),s(this,"Ywjj",(function(e,n,i){if(r.UAPh){if(P.debug("Notifying listeners for event: "+e+", "+n,r.fJga),r.fJga[n])for(var o=r.fJga[n],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else r.mDlm.push({event:e,key:n,type:i})}))})),X=window.ApxorLogger,K=function(){function e(){var r=this;return i(this,e),s(this,"UcJD",!1),s(this,"hvcM",null),s(this,"OfTR",_()),s(this,"pcQK",new q),s(this,"rtEJ",t.getSiteId()),s(this,"cNxd",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(r.rtEJ,e)):(r.cNxd={},r.setQeState())}catch(t){return r.cNxd={},r.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",r.cNxd,!0)}catch(n){""===e?r.cNxd={}:r.cNxd[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",r.cNxd,!0)}return r.cNxd})),s(this,"initialize",(function(){r.UcJD||(r.UcJD=!0,r.hvcM=new k,r.pcQK.initialize(),r.cNxd=r.getQeState(),X.info("QE Initialized.."))})),s(this,"parse",(function(t){r.ZzAy()?(r.hvcM.parse(t),r.pcQK.xcoZ()):X.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){r.ZzAy()&&r.hvcM.validate(t,e)})),s(this,"updateCount",(function(t){try{f(r.cNxd[t])||r.createObjConfig(t),r.incrementFrequencies(t),r.setQeState(t),r.hvcM.IwRA(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){r.hvcM.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return r.hvcM.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){r.pcQK.Pdms(t,e)})),s(this,"unregisterFromEvent",(function(t,e){r.pcQK.unregisterFromEvent(t,e)})),s(this,"fetch",(function(e,r,n,i){t.getController().fetchConfiguration(e,r,n,i)})),s(this,"ZzAy",(function(){return r.UcJD})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return r.hvcM.NrmJ(t)})),s(this,"PSuD",(function(){return r.OfTR})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.cNxd=this.getQeState(),f(this.cNxd[t])||(this.cNxd[t]={SESSION:0,OVERALL:0,DATES:{}},this.OfTR&&(this.cNxd[t].DATES[this.OfTR]=0),this.setQeState(t))}catch(t){X.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.cNxd=this.getQeState();var e=this.cNxd[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var r=_();r===this.OfTR&&e.DATES&&e.DATES[r]||(this.OfTR=r,e.DATES={},e.DATES[this.OfTR]=0),e.DATES[this.OfTR]=e.DATES[this.OfTR]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(K,"instance",void 0),window.ceVersion=123;try{void 0===exports&&null===exports||(exports.default=K,module.exports=exports.default)}catch(t){}return K}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apxor-qe",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "author": "Uma Sankar Yedida <umasankar.yedida@apxor.com> (https://www.apxor.com)",
5
5
  "contributors": [
6
6
  {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "jsdom": "^22.1.0",
55
- "apxor": "2.1.2"
55
+ "apxor": "2.1.3"
56
56
  },
57
57
  "files": [
58
58
  "dist"