apxor-qe 1.4.2 → 1.5.0

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 n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(t){return(r="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 n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function a(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))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 n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;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,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var d=function(t,e){return v(t,e=function(t){var e,n,r,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,n=a>>8&255,r=255&a,u.push(e),64!==i&&(u.push(n),64!==o&&u.push(r))}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()},_=function(t,e,n){switch(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;case"NEQ":return t!==e;case"R":return y(e).test(t);default:return!1}},y=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var n=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(n,e)},m=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},b=window.ApxorLogger,w=a((function e(){var n=this;i(this,e),s(this,"KSOj","ALL"),s(this,"MSCc",[]),s(this,"HuDN",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.KSOj=t.audience.audience_type,n.MSCc=t.audience.attributes.user,n.HuDN=t.audience.attributes.session,!Array.isArray(n.MSCc)||!Array.isArray(n.HuDN))return b.error("No attributes"),!1}catch(t){return b.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;return"FTU"===n.KSOj&&(i=t.getController().getSessionInfo().is_first_session),i&&n.zQwl(e,n.MSCc)&&n.zQwl(r,n.HuDN)})),s(this,"zQwl",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return _(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){b.error(t),r=!1}return r}))})),S=window.ApxorLogger,N=a((function t(){var e=this;i(this,t),s(this,"oKkN",0),s(this,"uzZi",0),s(this,"Avzx","SESSION"),s(this,"CqAl",0),s(this,"ivKN",0),s(this,"cOKY",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.oKkN=t.frequency.count,-1===e.oKkN&&(e.oKkN=1e3),e.cOKY=e.oKkN,e.uzZi=t.frequency.time_interval,e.Avzx=t.frequency.validity,e.ivKN=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=V.getInstance().getQeState();if(!f(n)||!f(n[t._id]))return!0;if("SESSION"===e.Avzx){if(e.oKkN=parseInt(e.oKkN)-parseInt(n[t._id].SESSION),e.oKkN<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.Avzx)return S.info("Invalid config."),!1;if(e.oKkN=parseInt(e.oKkN)-parseInt(n[t._id].OVERALL),e.oKkN<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return S.error(t),!1}return!0})),s(this,"ErGD",(function(){e.oKkN=e.oKkN-1})),s(this,"getFrequencyCount",(function(){return e.oKkN})),s(this,"Kbwh",(function(){"SESSION"===e.Avzx&&(e.oKkN=e.cOKY,S.info("Campaign Limit reset"))})),s(this,"TzLe",(function(t){try{if(e.oKkN<=0)return!1;var n=V.getInstance().getQeState();if(!f(n)||!f(n[t]))return!0;if(0!==e.ivKN)if(parseInt(e.ivKN)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){var r,i=m();if(parseInt(e._dayCount)-parseInt((null===(r=n[t])||void 0===r?void 0:r.DATES[i])||0)<=0)return!1}}catch(t){S.error("Error validating the frequency:"+t)}return!0}))})),A=a((function t(){var e=this;i(this,t),s(this,"lKfZ",""),s(this,"KSOj",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n;e.lKfZ=t.meta.name,e.KSOj=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(n=t.meta)||void 0===n?void 0:n.attr)||{}}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),O=window.ApxorLogger,k=a((function t(){var e=this;i(this,t),s(this,"TVeC",-1),s(this,"AsSy",-1),s(this,"Hztt",-1),s(this,"ZTNT",-1),s(this,"eGYo",!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 O.error("Not valid dates"),!1;if(e.TVeC=Date.parse(t.validity.start_date),e.AsSy=Date.parse(t.validity.end_date),f(t.time_limits_in_day)&&(e.eGYo=t.time_limits_in_day,e.eGYo&&f(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.Hztt=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.ZTNT=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.Hztt)||isNaN(e.ZTNT))return O.error("Not valid times"),!1}}catch(t){return O.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.TVeC&&t<e.AsSy&&(!e.eGYo||t>=e.Hztt&&t<=e.ZTNT)}))})),T=a((function t(){var e=this;i(this,t),s(this,"lKfZ",""),s(this,"xDaw",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.lKfZ=t.name,e.xDaw=t.additional_info}catch(t){return!1}return!0}))})),D=a((function t(){var e=this;i(this,t),s(this,"MZxZ",0),s(this,"gheX",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.MZxZ=Number(t.lower),e.gheX=Number(t.upper),isNaN(e.MZxZ)||isNaN(e.gheX))return!1}catch(t){return!1}return!0}))})),x=a((function t(){var e=this;i(this,t),s(this,"SHrN",0),s(this,"rXTM",""),s(this,"bgoZ",""),s(this,"kuZn",new T),s(this,"tzep",new D),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.rXTM=t.event_type,e.bgoZ=t.activity,e.kuZn.parse(t.details)&&e.tzep.parse(t.time_bounds)}catch(t){return!1}}))})),E=window.ApxorLogger,C=a((function t(){var e=this;i(this,t),s(this,"SHrN",0),s(this,"eGRJ",-1),s(this,"oKkN",0),s(this,"CKgT",""),s(this,"bgoZ",""),s(this,"rXTM",""),s(this,"tzep",new D),s(this,"kuZn",new T),s(this,"xiSw",new x),s(this,"LNgq","AND"),s(this,"dWSg",!1),s(this,"KSOj",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.eGRJ=t.sequence,e.oKkN=t.count_config.count,e.CKgT=t.count_config.operator,e.bgoZ=t.activity,e.rXTM=t.event_type,e.LNgq=t.combine_operator,e.KSOj=t.type,e.kuZn.parse(t.details)&&e.xiSw.parse(t.trigger)&&e.tzep.parse(t.time_bounds)}catch(t){return E.error(t),!1}}))})),F=window.ApxorLogger,Z=a((function t(){var e=this;i(this,t),s(this,"oKkN",0),s(this,"CKgT",""),s(this,"rXTM",""),s(this,"tzep",new D),s(this,"kuZn",new T),s(this,"LNgq","AND"),s(this,"parse",(function(t){try{return e.oKkN=t.count_config.count,e.CKgT=t.count_config.operator,e.rXTM=t.event_type,e.LNgq=t.combine_operator,e.kuZn.parse(t.details)&&e.tzep.parse(t.time_bounds)}catch(t){return F.error(t),!1}}))})),K=window.ApxorLogger,X=function(){function e(){var n=this;i(this,e),s(this,"akXD",0),s(this,"FqJf",""),s(this,"ehaO",new C),s(this,"rkRi",new Z),s(this,"RlJN",!1),s(this,"GJsb",!1),s(this,"WLVW",0),s(this,"LNgq","AND"),s(this,"WFrp","OR"),s(this,"sVTX",-1),s(this,"GzsF",[]),s(this,"HATm",{}),s(this,"bqgA",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=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]:[],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";if(n.FqJf=r,n.WLVW=i,n.GzsF=a,"termination"===s&&""!==s){n.rkRi.parse(e);return n.WFrp=n.rkRi.LNgq,n.FoZP(),!0}var u=n.ehaO.parse(e);if(u){if(n.LNgq=n.ehaO.LNgq,n.ehaO.dWSg){var c=n.ehaO.kuZn.lKfZ;"APX_PAGE_OPENED"===c&&(c=n.ehaO.kuZn.xDaw.navigation_id,c=f(c)?c:n.ehaO.kuZn.lKfZ),n.sVTX=t.getController().getEventCount(c);var l=n.ehaO.oKkN,h=n.ehaO.CKgT;if(n.GJsb=n.BcDf(n.sVTX-1,l,h,!1),n.RlJN=n.GJsb,n.GJsb&&"APX_PAGE_OPENED"===n.ehaO.kuZn.lKfZ)return!0}return o&&0!==i||n.hian(),!0}return!1})),s(this,"hian",(function(){var t,e=n.ehaO,r=e.xiSw,i=V.getInstance();"app_start"===r.rXTM?(n.RlJN=!0,i.registerForEvent(g(e.rXTM)+"___"+e.kuZn.lKfZ,n.LkAU)):i.registerForEvent(g(e.rXTM)+"___"+r.kuZn.lKfZ,n.LkAU),null!==(t=window.ApxorRTM)&&void 0!==t&&t.badgesLists.includes(n.FqJf)&&i.registerForEvent(g(e.rXTM)+"___"+"apxor-badge-container-".concat("-".concat(n.FqJf).replaceAll(" ","").replace(/[^\w\s]/gi,"")),n.LkAU)})),s(this,"FoZP",(function(){var t=n.rkRi,e=V.getInstance();n.RlJN=!0,e.registerForEvent(g(t.rXTM)+"___"+t.kuZn.lKfZ,n.xsmN)})),s(this,"JTwT",(function(t,e,r,i){var o,a=(Date.now()-n.HATm[e])/1e3;(null===(o=n.ehaO)||void 0===o||null===(o=o.kuZn)||void 0===o||null===(o=o.xDaw)||void 0===o?void 0:o.time)/1e3>a&&n._displayCampaign(r)})),s(this,"sSky",(function(t,e,r,i){var o,a;n.bqgA=!0;var s=Date.now(),u=null===(o=n.ehaO)||void 0===o||null===(o=o.xiSw)||void 0===o?void 0:o.kuZn.lKfZ,c=(s-n.HATm[u])/1e3,l=null===(a=n.ehaO)||void 0===a||null===(a=a.kuZn)||void 0===a||null===(a=a.xDaw)||void 0===a?void 0:a.time;(l/=1e3)>c&&n._displayCampaign(r)})),s(this,"LkAU",(function(e,r,i,o){var a,s=V.getInstance();if(n.RlJN){if(null!==(a=window.ApxorRTM)&&void 0!==a&&a.isBadgePresent&&t.getController().isBadgeTriggerSatisfied(n.FqJf))return n.GJsb=!0,n.ehaO.SHrN=i,void s.validate(n.FqJf,n.WLVW);g(n.ehaO.rXTM)===e&&n.IHQA(i-n.ehaO.xiSw.SHrN,n.ehaO.tzep)&&n.ehaO.kuZn.lKfZ===r&&n.YnRU(n.ehaO.kuZn.xDaw,o)&&(n.akXD+=1,n.GJsb=n.BcDf(n.akXD,n.ehaO.oKkN,n.ehaO.CKgT),n.GJsb&&(n.ehaO.SHrN=i,s.validate(n.FqJf,n.WLVW)))}else if(n.RlJN=n.PCkN(e,r,i,o),n.RlJN){var u=n.ehaO,c=u.xiSw;if(c.SHrN=i,"activity_time"===(null==u?void 0:u.rXTM)){var l,f,h,v=null==u||null===(l=u.kuZn)||void 0===l||null===(l=l.xDaw)||void 0===l?void 0:l.time;(null==u||null===(f=u.kuZn)||void 0===f||null===(f=f.xDaw)||void 0===f?void 0:f.nkpi.length)>0&&(setTimeout((function(){n.bqgA||(n.GJsb=!0,n.GJsb&&(n.akXD+=1,n.GJsb=n.BcDf(n.akXD,n.ehaO.oKkN,n.ehaO.CKgT),n.GJsb&&(n.ehaO.SHrN=i,s.validate(n.FqJf,n.WLVW)))),u.kuZn.xDaw.nkpi.map((function(t){s.unregisterFromEvent(p(u.kuZn.xDaw.et)+"___"+t,n)}))}),v),u.kuZn.xDaw.nkpi.map((function(t){s.registerForEvent(p(u.kuZn.xDaw.et)+"___"+t,n.sSky)}))),(null==u||null===(h=u.kuZn)||void 0===h||null===(h=h.xDaw)||void 0===h?void 0:h.kpi.length)>0&&(setTimeout((function(){u.kuZn.xDaw.kpi.map((function(t){s.unregisterFromEvent(p(u.kuZn.xDaw.et)+"___"+t,n)}))}),v),u.kuZn.xDaw.kpi.map((function(t){t===u.xiSw.kuZn.lKfZ?(s.unregisterFromEvent(g(c.rXTM)+"___"+c.kuZn.lKfZ,n),s.registerForEvent(p(u.kuZn.xDaw.et)+"___"+t,n.JTwT)):s.registerForEvent(p(u.kuZn.xDaw.et)+"___"+t,n.sSky)})))}else s.unregisterFromEvent(g(c.rXTM)+"___"+c.kuZn.lKfZ,n),s.registerForEvent(g(u.rXTM)+"___"+u.kuZn.lKfZ,n);n.HATm[r]=Date.now()}})),s(this,"xsmN",(function(t,e,r,i){var o=V.getInstance();g(n.rkRi.rXTM)===t&&n.IHQA(r,n.rkRi.tzep)&&n.rkRi.kuZn.lKfZ===e&&n.YnRU(n.rkRi.kuZn.xDaw,i)&&(n.akXD+=1,n.GJsb=n.BcDf(n.akXD,n.rkRi.oKkN,n.rkRi.CKgT),n.GJsb&&(n.rkRi.SHrN=r,o.validateForTermination(n.FqJf,n.WLVW)))})),s(this,"PCkN",(function(t,e,r,i){var o=n.ehaO.xiSw;return g(o.rXTM)===t&&o.kuZn.lKfZ===e&&n.IHQA(r,o.tzep)&&n.YnRU(o.kuZn.xDaw,i)})),s(this,"IHQA",(function(t,e){var n=Math.ceil(t);return n>e.MZxZ&&n<e.gheX})),s(this,"BcDf",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.ehaO.dWSg&&(t+=n.sVTX),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;default:return!1}})),s(this,"YnRU",(function(t,e){var n=!0;try{var i,o=function(){if(!e[a]||!1===n)return{v:!1};if("object"===r(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 _(t,i,o)}));n=n&&u}else n=n&&_(e[a],t[a],"EQ")};for(var a in t)if(i=o())return i.v}catch(t){K.error(t),n=!1}return n}))}return a(e,[{key:"_displayCampaign",value:function(t){var e=V.getInstance();this.GJsb=!0,this.GJsb&&(this.akXD+=1,this.GJsb=this.BcDf(this.akXD,this.ehaO.oKkN,this.ehaO.CKgT),this.GJsb&&(this.ehaO.SHrN=t,e.validate(this.FqJf,this.WLVW)))}}]),e}(),J=window.ApxorLogger,L=a((function e(){var n=this;i(this,e),s(this,"NpXz",[]),s(this,"_ret_day",{}),s(this,"MiYE",{}),s(this,"FLiS",!1),s(this,"DdTA",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.NpXz=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.MiYE=t.overall_cfg.session,n.FLiS=t.overall_cfg.toggleRetDay,n.NpXz=t.overall_cfg.events,n.DdTA=t.overall_cfg.toggleSession}catch(t){return J.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),r=parseInt(t.getController().getFromStorage("apx_retained_session"));if(n.FLiS&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return!1;if(n.DdTA&&!isNaN(r)&&!(r>=n.MiYE.from&&r<=n.MiYE.to))return!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),o=t.getSiteId(),a=JSON.parse((new TextDecoder).decode(function(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return e}(d(o,i)))),s=0;s<n.NpXz.length;s++){if(a[n.NpXz[s].name.replace("'","").replace("’","")])return!1}}catch(t){J.error("Failed to validate the lt count:"+t)}return!0}))})),z=window.ApxorLogger,q=a((function t(){var e=this;i(this,t),s(this,"MSCc",[]),s(this,"HuDN",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.MSCc=t.attributes.user,e.HuDN=t.attributes.session,!Array.isArray(e.MSCc)||!Array.isArray(e.HuDN))return z.error("No attributes"),!1}catch(t){return z.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.zQwl(t,e.MSCc)&&e.zQwl(n,e.HuDN)})),s(this,"zQwl",(function(t,e){var n=e.length,r=!0;try{for(var i,o=function(){var n=e[a];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,o=n.type,s=n.value.map((function(t){return"s"===o?t:"l"===o?parseInt(t):"f"===o?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return _(t,e,i)}))}));r=r&&u},a=0;a<n;a++)if(i=o())return i.v}catch(t){z.error(t),r=!1}return r}))})),M=a((function e(){var n=this;i(this,e),s(this,"OCNT",t.getController()),s(this,"type",""),s(this,"_duration_seconds",0),s(this,"dXMg",1),s(this,"parse",(function(t){try{var e,r,i;if(n.KSOj=null===(e=t.terminate_info.time_based)||void 0===e?void 0:e.type,n._duration_seconds=null===(r=t.terminate_info)||void 0===r?void 0:r.time_based.duration_seconds,n.dXMg=null===(i=t.terminate_info.time_based)||void 0===i?void 0:i.days,n.OjHn(t._id))return n.OCNT.persistTerminationInfoLocally(t._id),!1}catch(t){return!1}return!0})),s(this,"OjHn",(function(t){var e,r=JSON.parse(n.OCNT.getFromStorage("apx_termination_ID"));if(!r[t]||null===(e=r[t])||void 0===e||!e.startDate)return!1;var i,o=new Date(r[t].startDate),a=new Date((i=new Date).getMonth()+"/"+i.getDate()+"/"+i.getFullYear()),s=parseInt((a-o)/864e5,10),u=function(){var t=new Date;return{hours:t.getHours(),mins:t.getMinutes()}}(),c=r[t].Hztt;return s===n.dXMg&&u.hours>=c.hours||s>n.dXMg||r[t].goalAcheived}))})),G=a((function t(){var e=this;i(this,t),s(this,"enable_goal_events",!1),s(this,"attributes",{}),s(this,"hQNV",new q),s(this,"NQJh",new M),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n,r,i;if(e.enable_time_based=null==t||null===(n=t.terminate_info)||void 0===n?void 0:n.enable_time_based,e.enable_time_based&&!e.NQJh.parse(t))return!1;if(e.enable_goal_events=null==t||null===(r=t.terminate_info)||void 0===r?void 0:r.enable_goal_events,e.enable_attributes=null==t||null===(i=t.terminate_info)||void 0===i?void 0:i.enable_attributes,e.enable_attributes&&!e.hQNV.parse(t.terminate_info))return!1}catch(t){return window.ApxorLogger.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.hQNV.validate(t,n)}))})),H=window.ApxorLogger,j=a((function e(){var r=this;i(this,e),s(this,"xJBM",[]),s(this,"vlff",[]),s(this,"FqJf",""),s(this,"nWdU",new A),s(this,"NGHV",new w),s(this,"Avzx",new k),s(this,"znWc",new N),s(this,"TaRN",new L),s(this,"QowM",new G),s(this,"sajn",!1),s(this,"pzra",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(!f(t._id))return H.error("No Id"),!1;if(!f(t.enabled)||!t.enabled)return H.error("Not enabled"),!1;if(!(r.nWdU.parse(t)&&r.Avzx.parse(t)&&r.znWc.parse(t)&&r.NGHV.parse(t)&&r.TaRN.parse(t)&&r.QowM.parse(t)))return!1;if(!f(t.conditions)||!Array.isArray(t.conditions))return H.error("No valid conditions",t.conditions),!1;r.FqJf=t._id,r.sajn=!!f(t.sequence_enabled)&&t.sequence_enabled,r.sajn&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var e=t.conditions,n=e.length,i=0;i<n;i++){r.pzra=[];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};r.pzra=[].concat(u(r.pzra),[s])}var c=new X;c.initialize(o,r.FqJf,i,r.sajn,r.pzra)&&r.xJBM.push(c)}if(r.QowM.enable_goal_events)for(var l=t.terminate_info.goal_events.events,h=l.length,v=0;v<h;v++){var d=new X;d.initialize(l[v],r.FqJf,v,!0,[],"termination")&&r.vlff.push(d)}return r.xJBM.length>0}catch(t){return H.error(t),!1}})),s(this,"GjfG",(function(t){if(!(t<0))if(r.sajn){var e=r.xJBM[t];if(f(e)&&e.GJsb){var n=r.xJBM[t-1];if(f(n)&&!n.GJsb)return;var i=r.xJBM[t+1];f(i)?i.hian():r.FnDf()}}else r.FnDf()})),s(this,"pYOs",(function(t){t<0||r.YpOv()})),s(this,"FnDf",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(r.Avzx.validate()&&r.NGHV.validate(e,i)&&r.TaRN.validate()){for(var o=r.xJBM.length,a=o<1,s="",u=0;u<o;u++){var c=r.xJBM[u],l=c.GJsb;if(""===s.trim())a=l;else switch(s){case"AND":a=a&&l;break;case"OR":a=a||l}s=c.LNgq}if(a){if(console.debug("onCondition satisfied"),!r.znWc.TzLe(r.FqJf))return void console.warn("Maximum limit reached",r.FqJf);console.log("Dispatching event",r.nWdU.KSOj),!0===r.nWdU._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.nWdU._attr),{},{message_name:r.nWdU.lKfZ,id:r.FqJf})),t.getController().dispatchEvent(r.nWdU.KSOj,{name:r.nWdU.KSOj,additional_info:{uuid:r.FqJf,name:r.nWdU.lKfZ}})}}})),s(this,"YpOv",(function(){for(var e=r.vlff.length,i=e<1,o="",a=0;a<e;a++){var s=r.vlff[a],u=s.GJsb;if(""===o.trim())i=u;else switch(o){case"AND":i=i&&u;break;case"OR":i=i||u}o=s.WFrp}i&&(console.log("Dispatching event",r.nWdU.KSOj),t.getController().persistTerminationInfoLocally(r.FqJf),!0===r.nWdU._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.nWdU._attr),{},{message_name:r.nWdU.lKfZ,id:r.FqJf})),t.getController().dispatchEvent(r.nWdU.KSOj,{name:r.nWdU.KSOj,additional_info:{uuid:r.FqJf,name:r.nWdU.lKfZ}}))})),s(this,"validateForTerminationAttributes",(function(){var e=t.getController().getUserAttributes(),n=t.getController().getSessionAttributes();return r.QowM.validate(e,n)})),s(this,"ErGD",(function(){r.znWc.ErGD()})),s(this,"getFrequencyCount",(function(){return r.znWc.getFrequencyCount()})),s(this,"KnFr",(function(){return r.znWc.Kbwh()}))})),I=a((function t(){var e=this;i(this,t),s(this,"XvSv",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(f(t)&&f(t.configs)){var n=t.configs;if(!Array.isArray(n))return;n.sort((function(t,e){var n,r;return(null!==(n=t.prio)&&void 0!==n?n:-1)-(null!==(r=e.prio)&&void 0!==r?r:-1)}));for(var r=0;r<n.length;r++){var i=n[r],o=i._id,a=new j;a.parse(i)?e.XvSv[o]=a:console.warn("Failed to parse cfg",o)}}})),s(this,"validate",(function(t,n){e.XvSv[t]&&e.XvSv[t].GjfG(n)})),s(this,"validateForTermination",(function(t,n){e.XvSv[t]&&e.XvSv[t].pYOs(n)})),s(this,"validateForTerminationAttributes",(function(t){return!!e.XvSv[t]&&e.XvSv[t].validateForTerminationAttributes()})),s(this,"ErGD",(function(t){e.XvSv[t].ErGD()})),s(this,"getFrequencyCount",(function(t){return e.XvSv[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.XvSv;for(var n in t)t[n].KnFr()})),s(this,"Asov",(function(t){try{if(e.XvSv){var n=e.XvSv[t];if(n&&n.nWdU)return n.nWdU}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),R=window.ApxorLogger,W=a((function e(){var n=this;i(this,e),s(this,"AZee",{}),s(this,"GHrG",[]),s(this,"HJfd",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.gFEv(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.gFEv(t,"CE")}))})),s(this,"KqaR",(function(){for(var t in n.GHrG)n.wTap(t.event,t.key,t.type);n.HJfd=!0})),s(this,"HaQv",(function(t,e){var r;"function"==typeof e&&((r=n.AZee[t]?n.AZee[t]:[]).push(e),n.AZee[t]=r,R.debug("Listeners list: ",n.AZee))})),s(this,"unregisterFromEvent",(function(t,e){if(n.AZee[t]){for(var r=n.AZee[t],i=[],o=0;o<r.length;o++){var a=r[o];a!==e&&i.push(a)}n.AZee[t]=i}})),s(this,"gFEv",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.wTap(t,r,e)})),s(this,"wTap",(function(e,r,i){if(n.HJfd){if(R.debug("Notifying listeners for event: "+e+", "+r,n.AZee),n.AZee[r])for(var o=n.AZee[r],a=t.getController().getSDKRunningTimeInSec(),s=0;s<o.length;s++){(0,o[s])(i,e.name,a,e.additional_info)}}else n.GHrG.push({event:e,key:r,type:i})}))})),Q=window.ApxorLogger,V=function(){function e(){var n=this;return i(this,e),s(this,"RNCW",!1),s(this,"vozs",null),s(this,"OpCt",m()),s(this,"HLag",new W),s(this,"mhlV",t.getSiteId()),s(this,"Xhbc",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(d(n.mhlV,e)):(n.Xhbc={},n.setQeState())}catch(t){return n.Xhbc={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.Xhbc,!0)}catch(r){""===e?n.Xhbc={}:n.Xhbc[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.Xhbc,!0)}return n.Xhbc})),s(this,"initialize",(function(){n.RNCW||(n.RNCW=!0,n.vozs=new I,n.HLag.initialize(),n.Xhbc=n.getQeState(),Q.info("QE Initialized.."))})),s(this,"parse",(function(t){n.wVJP()?(n.vozs.parse(t),n.HLag.KqaR()):Q.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.wVJP()&&n.vozs.validate(t,e)})),s(this,"validateForTermination",(function(t,e){n.wVJP()&&n.vozs.validateForTermination(t,e)})),s(this,"validateForTerminationAttributes",(function(t,e){return n.vozs.validateForTerminationAttributes(t,e)})),s(this,"updateCount",(function(t){try{f(n.Xhbc[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.vozs.ErGD(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.vozs.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.vozs.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.HLag.HaQv(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.HLag.unregisterFromEvent(t,e)})),s(this,"notifyEventListener",(function(t){n.HLag.gFEv(t)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"wVJP",(function(){return n.RNCW})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.vozs.Asov(t)})),s(this,"CmBi",(function(){return n.OpCt})),e.instance||(e.instance=this),e.instance}return a(e,[{key:"createObjConfig",value:function(t){try{this.Xhbc=this.getQeState(),f(this.Xhbc[t])||(this.Xhbc[t]={SESSION:0,OVERALL:0,DATES:{}},this.OpCt&&(this.Xhbc[t].DATES[this.OpCt]=0),this.setQeState(t))}catch(t){Q.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.Xhbc=this.getQeState();var e=this.Xhbc[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=m();n===this.OpCt&&e.DATES&&e.DATES[n]||(this.OpCt=n,e.DATES={},e.DATES[this.OpCt]=0),e.DATES[this.OpCt]=e.DATES[this.OpCt]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(V,"instance",void 0),window.ceVersion=142;try{void 0===exports&&null===exports||(exports.default=V,module.exports=exports.default)}catch(t){}return V}));
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 n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function n(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function r(t){return(r="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 a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,c(r.key),r)}}function o(t,e,n){return e&&a(t.prototype,e),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,n){return(e=c(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t){return function(t){if(Array.isArray(t))return l(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 l(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(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 l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function c(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;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 d=function(t){return void 0!==t&&!function(t){return null===t}(t)},v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function f(t,e){return Array.from(e).map((function(e,n){return String.fromCharCode(e^function(t,e){return t.charCodeAt(Math.floor(e%t.length))}(t,n))})).join("")}var p=function(t,e){return f(t,e=function(t){var e,n,r,i,a,o,s=0,u=[];if(!t)return t;t+="";do{e=(o=v.indexOf(t.charAt(s++))<<18|v.indexOf(t.charAt(s++))<<12|(i=v.indexOf(t.charAt(s++)))<<6|(a=v.indexOf(t.charAt(s++))))>>16&255,n=o>>8&255,r=255&o,u.push(e),64!==i&&(u.push(n),64!==a&&u.push(r))}while(s<t.length);return u}(e))},_=function(t){switch(t){case"app_event":return"AE";case"client_event":return"CE";case"activity_time":case"activity_event":return"AE"}return"Unknown"},h=function(t){return t.toUpperCase()},g=function(t,e,n){switch(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;case"NEQ":return t!==e;case"R":return y(e).test(t);default:return!1}},y=function(t){var e=t.replace(/.*\/([gimuy]*)$/,"$1");e===t&&(e="");var n=e?t.replace(new RegExp("^/(.*?)/"+e+"$"),"$1"):t;return new RegExp(n,e)},m=function(){var t=new Date;return t.getDate()+"/"+t.getMonth()+"/"+t.getFullYear()},w=window.ApxorLogger,T=o((function e(){var n=this;i(this,e),s(this,"owVv","ALL"),s(this,"ZfAX",[]),s(this,"kLZG",[]),s(this,"userAttributesValidated",!0),s(this,"sessionAttributeValidated",!0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(n.owVv=t.audience.audience_type,n.ZfAX=t.audience.attributes.user,n.kLZG=t.audience.attributes.session,!Array.isArray(n.ZfAX)||!Array.isArray(n.kLZG))return w.error("No attributes"),!1}catch(t){return w.error(t),!1}return!0})),s(this,"validate",(function(e,r){var i=!0;"FTU"===n.owVv&&(i=t.getController().getSessionInfo().is_first_session);var a=n.KPjz(e,n.ZfAX),o=n.KPjz(r,n.kLZG);return a||(n.userAttributesValidated=!1),o||(n.sessionAttributeValidated=!1),i&&a&&o})),s(this,"KPjz",(function(t,e){var n=e.length,r=!0;try{for(var i,a=function(){var n=e[o];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,a=n.type,s=n.value.map((function(t){return"s"===a?t:"l"===a?parseInt(t):"f"===a?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return g(t,e,i)}))}));r=r&&u},o=0;o<n;o++)if(i=a())return i.v}catch(t){w.error(t),r=!1}return r}))})),x=window.ApxorLogger,K=o((function t(){var e=this;i(this,t),s(this,"YpuZ",0),s(this,"CaWP",0),s(this,"HdbP","SESSION"),s(this,"QrLx",0),s(this,"WUjI",0),s(this,"Gnyd",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.YpuZ=t.frequency.count,-1===e.YpuZ&&(e.YpuZ=1e3),e.Gnyd=e.YpuZ,e.CaWP=t.frequency.time_interval,e.HdbP=t.frequency.validity,e.WUjI=t.frequency.ses_lmt,e._dayCount=t.frequency.day_lmt;var n=R.getInstance().getQeState();if(!d(n)||!d(n[t._id]))return!0;if("SESSION"===e.HdbP){if(e.YpuZ=parseInt(e.YpuZ)-parseInt(n[t._id].SESSION),e.YpuZ<=0)return console.warn("Max count limit reached for session:"+t._id),!1}else{if("OVERALL"!==e.HdbP)return x.info("Invalid config."),!1;if(e.YpuZ=parseInt(e.YpuZ)-parseInt(n[t._id].OVERALL),e.YpuZ<=0)return console.warn("Max count limit reached for overall:"+t._id),!1}}catch(t){return x.error(t),!1}return!0})),s(this,"aokP",(function(){e.YpuZ=e.YpuZ-1})),s(this,"getFrequencyCount",(function(){return e.YpuZ})),s(this,"mtuI",(function(){"SESSION"===e.HdbP&&(e.YpuZ=e.Gnyd,x.info("Campaign Limit reset"))})),s(this,"XinH",(function(t){try{if(e.YpuZ<=0)return!1;var n=R.getInstance().getQeState();if(!d(n)||!d(n[t]))return!0;if(0!==e.WUjI)if(parseInt(e.WUjI)-parseInt(n[t].SESSION)<=0)return!1;if(0!==e._dayCount){var r,i=m();if(parseInt(e._dayCount)-parseInt((null===(r=n[t])||void 0===r?void 0:r.DATES[i])||0)<=0)return!1}}catch(t){x.error("Error validating the frequency:"+t)}return!0}))})),b=o((function t(){var e=this;i(this,t),s(this,"CTVX",""),s(this,"owVv",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n,r;e.CTVX=t.meta.name,e.owVv=t.meta.type,e._only_context=t.meta.only_context,e._attr=(null===(n=t.meta)||void 0===n?void 0:n.attr)||{},e._isExperiment=null===(r=t.meta)||void 0===r?void 0:r.isExperiment}catch(t){return window.ApxorLogger.error(t),!1}return!0}))})),E=window.ApxorLogger,C=o((function t(){var e=this;i(this,t),s(this,"zmJs",-1),s(this,"kepU",-1),s(this,"ysVa",-1),s(this,"ocLU",-1),s(this,"hxyS",!1),s(this,"_nudge_expired",!1),s(this,"_not_yet_active",!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 E.error("Not valid dates"),!1;if(e.zmJs=Date.parse(t.validity.start_date),e.kepU=Date.parse(t.validity.end_date),d(t.time_limits_in_day)&&(e.hxyS=t.time_limits_in_day,e.hxyS&&d(t.time_limits))){var n=(new Date).toISOString().split("T")[0];if(e.ysVa=Date.parse(n+"T"+t.time_limits.start_time+".000Z"),e.ocLU=Date.parse(n+"T"+t.time_limits.end_time+".000Z"),isNaN(e.ysVa)||isNaN(e.ocLU))return E.error("Not valid times"),!1}}catch(t){return E.error(t),!1}return!0})),s(this,"validate",(function(){var t=Date.now();return t>e.zmJs&&t<e.kepU?!e.hxyS||t>=e.ysVa&&t<=e.ocLU:(t<e.zmJs?e._not_yet_active=!0:t>e.kepU&&(e._nudge_expired=!0),!1)}))})),S=o((function t(){var e=this;i(this,t),s(this,"CTVX",""),s(this,"orON",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e.CTVX=t.name,e.orON=t.additional_info}catch(t){return!1}return!0}))})),A=o((function t(){var e=this;i(this,t),s(this,"oxbV",0),s(this,"QyjH",0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.oxbV=Number(t.lower),e.QyjH=Number(t.upper),isNaN(e.oxbV)||isNaN(e.QyjH))return!1}catch(t){return!1}return!0}))})),N=o((function t(){var e=this;i(this,t),s(this,"VAxM",0),s(this,"KJQk",""),s(this,"Nckt",""),s(this,"KdUl",new S),s(this,"Bfpr",new A),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.KJQk=t.event_type,e.Nckt=t.activity,e.KdUl.parse(t.details)&&e.Bfpr.parse(t.time_bounds)}catch(t){return!1}}))})),Y=window.ApxorLogger,V=o((function t(){var e=this;i(this,t),s(this,"VAxM",0),s(this,"mCnB",-1),s(this,"YpuZ",0),s(this,"SvML",""),s(this,"Nckt",""),s(this,"KJQk",""),s(this,"Bfpr",new A),s(this,"KdUl",new S),s(this,"rFlu",new N),s(this,"ndXU","AND"),s(this,"cmkQ",!1),s(this,"owVv",void 0),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return e.mCnB=t.sequence,e.YpuZ=t.count_config.count,e.SvML=t.count_config.operator,e.Nckt=t.activity,e.KJQk=t.event_type,e.ndXU=t.combine_operator,e.owVv=t.type,e.KdUl.parse(t.details)&&e.rFlu.parse(t.trigger)&&e.Bfpr.parse(t.time_bounds)}catch(t){return Y.error(t),!1}}))})),O=window.ApxorLogger,L=o((function t(){var e=this;i(this,t),s(this,"YpuZ",0),s(this,"SvML",""),s(this,"KJQk",""),s(this,"Bfpr",new A),s(this,"KdUl",new S),s(this,"ndXU","AND"),s(this,"parse",(function(t){try{return e.YpuZ=t.count_config.count,e.SvML=t.count_config.operator,e.KJQk=t.event_type,e.ndXU=t.combine_operator,e.KdUl.parse(t.details)&&e.Bfpr.parse(t.time_bounds)}catch(t){return O.error(t),!1}}))})),P=window.ApxorLogger,q=function(){function e(){var n=this;i(this,e),s(this,"iqYa",0),s(this,"tTqB",""),s(this,"Pwgu",new V),s(this,"PACz",new L),s(this,"LpHt",!1),s(this,"HLiN",!1),s(this,"nODh",0),s(this,"ndXU","AND"),s(this,"Pxjw","OR"),s(this,"BNbu",-1),s(this,"rjRg",[]),s(this,"vBOh",{}),s(this,"WFwv",!1),s(this,"initialize",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";if(n.tTqB=r,n.nODh=i,n.rjRg=o,"termination"===s&&""!==s){n.PACz.parse(e);return n.Pxjw=n.PACz.ndXU,n.vfXG(),!0}var u=n.Pwgu.parse(e);if(u){if(n.ndXU=n.Pwgu.ndXU,n.Pwgu.cmkQ){var l=n.Pwgu.KdUl.CTVX;"APX_PAGE_OPENED"===l&&(l=n.Pwgu.KdUl.orON.navigation_id,l=d(l)?l:n.Pwgu.KdUl.CTVX),n.BNbu=t.getController().getEventCount(l);var c=n.Pwgu.YpuZ,v=n.Pwgu.SvML;if(n.HLiN=n.tKdV(n.BNbu-1,c,v,!1),n.LpHt=n.HLiN,n.HLiN&&"APX_PAGE_OPENED"===n.Pwgu.KdUl.CTVX)return!0}return a&&0!==i||n.zSnG(),!0}return!1})),s(this,"zSnG",(function(){var t,e=n.Pwgu,r=e.rFlu,i=R.getInstance();"app_start"===r.KJQk?(n.LpHt=!0,i.registerForEvent(_(e.KJQk)+"___"+e.KdUl.CTVX,n.hjRG)):i.registerForEvent(_(e.KJQk)+"___"+r.KdUl.CTVX,n.hjRG),null!==(t=window.ApxorRTM)&&void 0!==t&&t.badgesLists.includes(n.tTqB)&&i.registerForEvent(_(e.KJQk)+"___"+"apxor-badge-container-".concat("-".concat(n.tTqB).replaceAll(" ","").replace(/[^\w\s]/gi,"")),n.hjRG)})),s(this,"vfXG",(function(){var t=n.PACz,e=R.getInstance();n.LpHt=!0,e.registerForEvent(_(t.KJQk)+"___"+t.KdUl.CTVX,n.oueL)})),s(this,"RlTL",(function(t,e,r,i){var a,o=(Date.now()-n.vBOh[e])/1e3;(null===(a=n.Pwgu)||void 0===a||null===(a=a.KdUl)||void 0===a||null===(a=a.orON)||void 0===a?void 0:a.time)/1e3>o&&n._displayCampaign(r)})),s(this,"lwFR",(function(t,e,r,i){var a,o;n.WFwv=!0;var s=Date.now(),u=null===(a=n.Pwgu)||void 0===a||null===(a=a.rFlu)||void 0===a?void 0:a.KdUl.CTVX,l=(s-n.vBOh[u])/1e3,c=null===(o=n.Pwgu)||void 0===o||null===(o=o.KdUl)||void 0===o||null===(o=o.orON)||void 0===o?void 0:o.time;(c/=1e3)>l&&n._displayCampaign(r)})),s(this,"hjRG",(function(e,r,i,a){var o,s,u=R.getInstance();if(n.LpHt){if(null!==(o=window.ApxorRTM)&&void 0!==o&&o.isBadgePresent&&null!==(s=window.ApxorRTM)&&void 0!==s&&s.badgesLists.includes(n.tTqB)&&t.getController().isBadgeTriggerSatisfied(n.tTqB))return n.HLiN=!0,n.Pwgu.VAxM=i,void u.validate(n.tTqB,n.nODh);_(n.Pwgu.KJQk)===e&&n.CFTa(i-n.Pwgu.rFlu.VAxM,n.Pwgu.Bfpr)&&n.Pwgu.KdUl.CTVX===r&&n.iGQO(n.Pwgu.KdUl.orON,a)&&(n.iqYa+=1,n.HLiN=n.tKdV(n.iqYa,n.Pwgu.YpuZ,n.Pwgu.SvML),n.HLiN&&(n.Pwgu.VAxM=i,u.validate(n.tTqB,n.nODh)))}else if(n.LpHt=n.gwDR(e,r,i,a),n.LpHt){var l=n.Pwgu,c=l.rFlu;if(c.VAxM=i,"activity_time"===(null==l?void 0:l.KJQk)){var d,v,f,p=null==l||null===(d=l.KdUl)||void 0===d||null===(d=d.orON)||void 0===d?void 0:d.time;(null==l||null===(v=l.KdUl)||void 0===v||null===(v=v.orON)||void 0===v?void 0:v.nkpi.length)>0&&(setTimeout((function(){n.WFwv||(n.HLiN=!0,n.HLiN&&(n.iqYa+=1,n.HLiN=n.tKdV(n.iqYa,n.Pwgu.YpuZ,n.Pwgu.SvML),n.HLiN&&(n.Pwgu.VAxM=i,u.validate(n.tTqB,n.nODh)))),l.KdUl.orON.nkpi.map((function(t){u.unregisterFromEvent(h(l.KdUl.orON.et)+"___"+t,n)}))}),p),l.KdUl.orON.nkpi.map((function(t){u.registerForEvent(h(l.KdUl.orON.et)+"___"+t,n.lwFR)}))),(null==l||null===(f=l.KdUl)||void 0===f||null===(f=f.orON)||void 0===f?void 0:f.kpi.length)>0&&(setTimeout((function(){l.KdUl.orON.kpi.map((function(t){u.unregisterFromEvent(h(l.KdUl.orON.et)+"___"+t,n)}))}),p),l.KdUl.orON.kpi.map((function(t){t===l.rFlu.KdUl.CTVX?(u.unregisterFromEvent(_(c.KJQk)+"___"+c.KdUl.CTVX,n),u.registerForEvent(h(l.KdUl.orON.et)+"___"+t,n.RlTL)):u.registerForEvent(h(l.KdUl.orON.et)+"___"+t,n.lwFR)})))}else u.unregisterFromEvent(_(c.KJQk)+"___"+c.KdUl.CTVX,n),u.registerForEvent(_(l.KJQk)+"___"+l.KdUl.CTVX,n);n.vBOh[r]=Date.now()}})),s(this,"oueL",(function(t,e,r,i){var a=R.getInstance();_(n.PACz.KJQk)===t&&n.CFTa(r,n.PACz.Bfpr)&&n.PACz.KdUl.CTVX===e&&n.iGQO(n.PACz.KdUl.orON,i)&&(n.iqYa+=1,n.HLiN=n.tKdV(n.iqYa,n.PACz.YpuZ,n.PACz.SvML),n.HLiN&&(n.PACz.VAxM=r,a.validateForTermination(n.tTqB,n.nODh)))})),s(this,"gwDR",(function(t,e,r,i){var a=n.Pwgu.rFlu;return _(a.KJQk)===t&&a.KdUl.CTVX===e&&n.CFTa(r,a.Bfpr)&&n.iGQO(a.KdUl.orON,i)})),s(this,"CFTa",(function(t,e){var n=Math.ceil(t);return n>e.oxbV&&n<e.QyjH})),s(this,"tKdV",(function(t,e,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];switch(i&&n.Pwgu.cmkQ&&(t+=n.BNbu),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;default:return!1}})),s(this,"iGQO",(function(t,e){var n=!0;try{var i,a=function(){if(!e[o]||!1===n)return{v:!1};if("object"===r(t[o])){var i,a=t[o].op,s=t[o].t;"s"===s?i=t[o].val:"l"!==s&&"f"!==s||(i=parseFloat(t[o].val));var u=(Array.isArray(e[o])?e[o]:[e[o]]).some((function(t){return g(t,i,a)}));n=n&&u}else n=n&&g(e[o],t[o],"EQ")};for(var o in t)if(i=a())return i.v}catch(t){P.error(t),n=!1}return n}))}return o(e,[{key:"_displayCampaign",value:function(t){var e=R.getInstance();this.HLiN=!0,this.HLiN&&(this.iqYa+=1,this.HLiN=this.tKdV(this.iqYa,this.Pwgu.YpuZ,this.Pwgu.SvML),this.HLiN&&(this.Pwgu.VAxM=t,e.validate(this.tTqB,this.nODh)))}}]),e}(),U=window.ApxorLogger,F=o((function e(){var n=this;i(this,e),s(this,"OuRa",[]),s(this,"_ret_day",{}),s(this,"ErWu",{}),s(this,"dqnh",!1),s(this,"rpSj",!1),s(this,"retainedDaysValidated",!0),s(this,"retainedSessionValidated",!0),s(this,"eventDoneInLT",!1),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{n.OuRa=t.overall_cfg.events,n._ret_day=t.overall_cfg.ret_day,n.ErWu=t.overall_cfg.session,n.dqnh=t.overall_cfg.toggleRetDay,n.rpSj=t.overall_cfg.toggleSession}catch(t){return U.error(t),!1}return!0})),s(this,"validate",(function(){var e=parseInt(t.getController().getFromStorage("apx_retained_days")),r=parseInt(t.getController().getFromStorage("apx_retained_session"));if(n.dqnh&&!isNaN(e)&&!(e>=n._ret_day.from&&e<=n._ret_day.to))return n.retainedDaysValidated=!1,!1;if(n.rpSj&&!isNaN(r)&&!(r>=n.ErWu.from&&r<=n.ErWu.to))return n.retainedSessionValidated=!1,!1;try{for(var i=t.getController().getFromStorage("_apx_lt_count"),a=t.getSiteId(),o=JSON.parse((new TextDecoder).decode(function(t){for(var e=new ArrayBuffer(t.length),n=new Uint8Array(e),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return e}(p(a,i)))),s=0;s<n.OuRa.length;s++){if(o[n.OuRa[s].name.replace("'","").replace("’","")])return n.eventDoneInLT=!0,!1}}catch(t){U.error("Failed to validate the lt count:"+t)}return!0}))})),X=window.ApxorLogger,B=o((function t(){var e=this;i(this,t),s(this,"ZfAX",[]),s(this,"kLZG",[]),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{if(e.ZfAX=t.attributes.user,e.kLZG=t.attributes.session,!Array.isArray(e.ZfAX)||!Array.isArray(e.kLZG))return X.error("No attributes"),!1}catch(t){return X.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.KPjz(t,e.ZfAX)&&e.KPjz(n,e.kLZG)})),s(this,"KPjz",(function(t,e){var n=e.length,r=!0;try{for(var i,a=function(){var n=e[o];if(!t[n.name]||!1===r)return{v:!1};var i=n.operator,a=n.type,s=n.value.map((function(t){return"s"===a?t:"l"===a?parseInt(t):"f"===a?parseFloat(t):void 0})),u=(Array.isArray(t[n.name])?t[n.name]:[t[n.name]]).some((function(t){return s.some((function(e){return g(t,e,i)}))}));r=r&&u},o=0;o<n;o++)if(i=a())return i.v}catch(t){X.error(t),r=!1}return r}))})),D=o((function e(){var n=this;i(this,e),s(this,"FOrk",t.getController()),s(this,"type",""),s(this,"_duration_seconds",0),s(this,"qKfs",1),s(this,"parse",(function(t){try{var e,r,i;if(n.owVv=null===(e=t.terminate_info.time_based)||void 0===e?void 0:e.type,n._duration_seconds=null===(r=t.terminate_info)||void 0===r?void 0:r.time_based.duration_seconds,n.qKfs=null===(i=t.terminate_info.time_based)||void 0===i?void 0:i.days,n.cJes(t._id))return n.FOrk.persistTerminationInfoLocally(t._id),!1}catch(t){return!1}return!0})),s(this,"cJes",(function(t){var e,r=JSON.parse(n.FOrk.getFromStorage("apx_termination_ID"));if(!r[t]||null===(e=r[t])||void 0===e||!e.startDate)return!1;var i,a=new Date(r[t].startDate),o=new Date((i=new Date).getMonth()+"/"+i.getDate()+"/"+i.getFullYear()),s=parseInt((o-a)/864e5,10),u=function(){var t=new Date;return{hours:t.getHours(),mins:t.getMinutes()}}(),l=r[t].ysVa;return s===n.qKfs&&u.hours>=l.hours||s>n.qKfs||r[t].goalAcheived}))})),k=o((function t(){var e=this;i(this,t),s(this,"enable_goal_events",!1),s(this,"attributes",{}),s(this,"NYIx",new B),s(this,"yGMZ",new D),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var n,r,i;if(e.enable_time_based=null==t||null===(n=t.terminate_info)||void 0===n?void 0:n.enable_time_based,e.enable_time_based&&!e.yGMZ.parse(t))return!1;if(e.enable_goal_events=null==t||null===(r=t.terminate_info)||void 0===r?void 0:r.enable_goal_events,e.enable_attributes=null==t||null===(i=t.terminate_info)||void 0===i?void 0:i.enable_attributes,e.enable_attributes&&!e.NYIx.parse(t.terminate_info))return!1}catch(t){return window.ApxorLogger.error(t),!1}return!0})),s(this,"validate",(function(t,n){return e.NYIx.validate(t,n)}))})),Z=window.ApxorLogger,j=o((function e(){var r=this;i(this,e),s(this,"Qyfu",[]),s(this,"BCZU",[]),s(this,"tTqB",""),s(this,"YTKa",new b),s(this,"EHOf",new T),s(this,"HdbP",new C),s(this,"wXgl",new K),s(this,"qUBE",new F),s(this,"OyjG",new k),s(this,"scuX",!1),s(this,"KHpv",[]),s(this,"_variant_code",""),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var e;if(!d(t._id))return Z.error("No Id"),!1;if(!d(t.enabled)||!t.enabled)return Z.error("Not enabled"),!1;if(!(r.YTKa.parse(t)&&r.HdbP.parse(t)&&r.wXgl.parse(t)&&r.EHOf.parse(t)&&r.qUBE.parse(t)&&r.OyjG.parse(t)))return!1;if(r._variant_code=r.YTKa._isExperiment||r.YTKa._only_context?null===(e=r.YTKa._attr)||void 0===e?void 0:e.apx_variant_code:"TG",!d(t.conditions)||!Array.isArray(t.conditions))return Z.error("No valid conditions",t.conditions),!1;r.tTqB=t._id,r.scuX=!!d(t.sequence_enabled)&&t.sequence_enabled,r.scuX&&t.conditions.sort((function(t,e){return t.sequence<e.sequence}));for(var n=t.conditions,i=n.length,a=0;a<i;a++){r.KHpv=[];var o=n[a];if("didn't"===o.type){var s,l={trigger_key:o.trigger.details.name,no_kpi_array:null==o||null===(s=o.details)||void 0===s||null===(s=s.additional_info)||void 0===s?void 0:s.nkpi,condition_id:null==o?void 0:o._id,time_bounds:o.time_bounds.upper};r.KHpv=[].concat(u(r.KHpv),[l])}var c=new q;c.initialize(o,r.tTqB,a,r.scuX,r.KHpv)&&r.Qyfu.push(c)}if(r.OyjG.enable_goal_events)for(var v=t.terminate_info.goal_events.events,f=v.length,p=0;p<f;p++){var _=new q;_.initialize(v[p],r.tTqB,p,!0,[],"termination")&&r.BCZU.push(_)}return r.Qyfu.length>0}catch(t){return Z.error(t),!1}})),s(this,"jKQM",(function(t){if(!(t<0))if(r.scuX){var e=r.Qyfu[t];if(d(e)&&e.HLiN){var n=r.Qyfu[t-1];if(d(n)&&!n.HLiN)return;var i=r.Qyfu[t+1];d(i)?i.zSnG():r.zWDC()}}else r.zWDC()})),s(this,"VcYO",(function(t){t<0||r.srDl()})),s(this,"zWDC",(function(){var e=t.getController().getUserAttributes(),i=t.getController().getSessionAttributes();if(!r.HdbP.validate()||!r.EHOf.validate(e,i)||!r.qUBE.validate())return r.qUBE.retainedDaysValidated||null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"Retained day criteria not met"}),r.qUBE.retainedSessionValidated||null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"User session criteria not met"}),r.qUBE.eventDoneInLT&&(null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"Event done in life time"})),r.EHOf.userAttributesValidated||null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"User property filter not met"}),r.EHOf.sessionAttributeValidated||null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"Session property filter not met"}),r.HdbP._not_yet_active&&(null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"nudge not yet active"})),void(r.HdbP._nudge_expired&&(null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"nudge expired"})));for(var a=r.Qyfu.length,o=a<1,s="",u=0;u<a;u++){var l=r.Qyfu[u],c=l.HLiN;if(""===s.trim())o=c;else switch(s){case"AND":o=o&&c;break;case"OR":o=o||c}s=l.ndXU}if(o){var d,v;if(console.debug("onCondition satisfied"),!r.wXgl.XinH(r.tTqB))return console.warn("Maximum limit reached",r.tTqB),void(null==t||t.logEvent("apx_non_eligible_user",{apx_nudge_type:"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG",apx_failure_type:"warn",apx_reason:"Campaign limit reached"}));null!==(d=window.ApxorRTM)&&void 0!==d&&d.isBadgePresent&&null!==(v=window.ApxorRTM)&&void 0!==v&&v.badgesLists.includes(r.tTqB)&&t.getController().isBadgeTriggerSatisfied(r.tTqB)||null==t||t.logEvent("apx_trigger_satisfied",{apx_nudge_type:"SURVEY"===r.YTKa.owVv?"survey":"campaign",apx_nudge_id:r.tTqB,apx_nudge_name:r.YTKa.CTVX,apx_variant_code:r.YTKa._isExperiment||r.YTKa._only_context?r.YTKa._attr.apx_variant_code:"TG"}),console.log("Dispatching event",r.YTKa.owVv),!0===r.YTKa._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.YTKa._attr),{},{message_name:r.YTKa.CTVX,id:r.tTqB})),t.getController().dispatchEvent(r.YTKa.owVv,{name:r.YTKa.owVv,additional_info:{uuid:r.tTqB,name:r.YTKa.CTVX}})}})),s(this,"srDl",(function(){for(var e=r.BCZU.length,i=e<1,a="",o=0;o<e;o++){var s=r.BCZU[o],u=s.HLiN;if(""===a.trim())i=u;else switch(a){case"AND":i=i&&u;break;case"OR":i=i||u}a=s.Pxjw}i&&(console.log("Dispatching event",r.YTKa.owVv),t.getController().persistTerminationInfoLocally(r.tTqB),!0===r.YTKa._only_context&&t.logEvent("apx_context_evaluated",n(n({},r.YTKa._attr),{},{message_name:r.YTKa.CTVX,id:r.tTqB})),t.getController().dispatchEvent(r.YTKa.owVv,{name:r.YTKa.owVv,additional_info:{uuid:r.tTqB,name:r.YTKa.CTVX}}))})),s(this,"validateForTerminationAttributes",(function(){var e=t.getController().getUserAttributes(),n=t.getController().getSessionAttributes();return r.OyjG.validate(e,n)})),s(this,"aokP",(function(){r.wXgl.aokP()})),s(this,"getFrequencyCount",(function(){return r.wXgl.getFrequencyCount()})),s(this,"unSR",(function(){return r.wXgl.mtuI()}))})),I=o((function t(){var e=this;i(this,t),s(this,"Nxlp",{}),s(this,"parse",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{configs:[]};if(d(t)&&d(t.configs)){var n=t.configs;if(!Array.isArray(n))return;n.sort((function(t,e){var n,r;return(null!==(n=t.prio)&&void 0!==n?n:-1)-(null!==(r=e.prio)&&void 0!==r?r:-1)}));for(var r=0;r<n.length;r++){var i=n[r],a=i._id,o=new j;o.parse(i)?e.Nxlp[a]=o:console.warn("Failed to parse cfg",a)}}})),s(this,"validate",(function(t,n){e.Nxlp[t]&&e.Nxlp[t].jKQM(n)})),s(this,"getVariantCode",(function(t){return e.Nxlp[t]?e.Nxlp[t]._variant_code:""})),s(this,"validateForTermination",(function(t,n){e.Nxlp[t]&&e.Nxlp[t].VcYO(n)})),s(this,"validateForTerminationAttributes",(function(t){return!!e.Nxlp[t]&&e.Nxlp[t].validateForTerminationAttributes()})),s(this,"aokP",(function(t){e.Nxlp[t].aokP()})),s(this,"getFrequencyCount",(function(t){return e.Nxlp[t].getFrequencyCount()})),s(this,"resetFrequencyCounts",(function(){var t=e.Nxlp;for(var n in t)t[n].unSR()})),s(this,"MRwp",(function(t){try{if(e.Nxlp){var n=e.Nxlp[t];if(n&&n.YTKa)return n.YTKa}}catch(t){console.log("Error in getting the campaign meta ".concat(t))}return{}}))})),Q=window.ApxorLogger,H=o((function e(){var n=this;i(this,e),s(this,"Cwvl",{}),s(this,"LCmY",[]),s(this,"TBZE",!1),s(this,"initialize",(function(){var e=t.getController();e.registerForEvent("APP_EVENT",(function(t){return n.uTFw(t,"AE")})),e.registerForEvent("CLIENT_EVENT",(function(t){return n.uTFw(t,"CE")}))})),s(this,"PseG",(function(){for(var t in n.LCmY)n.AqCu(t.event,t.key,t.type);n.TBZE=!0})),s(this,"OVFP",(function(t,e){var r;"function"==typeof e&&((r=n.Cwvl[t]?n.Cwvl[t]:[]).push(e),n.Cwvl[t]=r,Q.debug("Listeners list: ",n.Cwvl))})),s(this,"unregisterFromEvent",(function(t,e){if(n.Cwvl[t]){for(var r=n.Cwvl[t],i=[],a=0;a<r.length;a++){var o=r[a];o!==e&&i.push(o)}n.Cwvl[t]=i}})),s(this,"uTFw",(function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"AE",r=e+"___"+t.name;n.AqCu(t,r,e)})),s(this,"AqCu",(function(e,r,i){if(n.TBZE){if(Q.debug("Notifying listeners for event: "+e+", "+r,n.Cwvl),n.Cwvl[r])for(var a=n.Cwvl[r],o=t.getController().getSDKRunningTimeInSec(),s=0;s<a.length;s++){(0,a[s])(i,e.name,o,e.additional_info)}}else n.LCmY.push({event:e,key:r,type:i})}))})),z=window.ApxorLogger,R=function(){function e(){var n=this;return i(this,e),s(this,"jnoF",!1),s(this,"dXeZ",null),s(this,"yqdw",m()),s(this,"mBNE",new H),s(this,"DtLZ",t.getSiteId()),s(this,"zSlf",{}),s(this,"getQeState",(function(){try{var e=t.getController().getFromStorage("qe_state");return e?JSON.parse(p(n.DtLZ,e)):(n.zSlf={},n.setQeState())}catch(t){return n.zSlf={},n.setQeState()}})),s(this,"setQeState",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{t.getController().persistToStorage("qe_state",n.zSlf,!0)}catch(r){""===e?n.zSlf={}:n.zSlf[e]={SESSION:0,OVERALL:0,DATES:{}},t.getController().persistToStorage("qe_state",n.zSlf,!0)}return n.zSlf})),s(this,"initialize",(function(){n.jnoF||(n.jnoF=!0,n.dXeZ=new I,n.mBNE.initialize(),n.zSlf=n.getQeState(),z.info("QE Initialized.."))})),s(this,"parse",(function(t){n.JpIa()?(n.dXeZ.parse(t),n.mBNE.PseG()):z.warn("Must call init first. Unable to proceed")})),s(this,"validate",(function(t,e){n.JpIa()&&n.dXeZ.validate(t,e)})),s(this,"getVariantCode",(function(t){return n.dXeZ.getVariantCode(t)})),s(this,"validateForTermination",(function(t,e){n.JpIa()&&n.dXeZ.validateForTermination(t,e)})),s(this,"validateForTerminationAttributes",(function(t,e){return n.dXeZ.validateForTerminationAttributes(t,e)})),s(this,"updateCount",(function(t){try{d(n.zSlf[t])||n.createObjConfig(t),n.incrementFrequencies(t),n.setQeState(t),n.dXeZ.aokP(t)}catch(t){console.log("Could not update the count config:".concat(t))}})),s(this,"resetFrequencyCounts",(function(){n.dXeZ.resetFrequencyCounts()})),s(this,"getFrequencyCount",(function(t){return n.dXeZ.getFrequencyCount(t)})),s(this,"registerForEvent",(function(t,e){n.mBNE.OVFP(t,e)})),s(this,"unregisterFromEvent",(function(t,e){n.mBNE.unregisterFromEvent(t,e)})),s(this,"notifyEventListener",(function(t){n.mBNE.uTFw(t)})),s(this,"fetch",(function(e,n,r,i){t.getController().fetchConfiguration(e,n,r,i)})),s(this,"JpIa",(function(){return n.jnoF})),s(this,"getCampaignMetaFromQueryEngine",(function(t){return n.dXeZ.MRwp(t)})),s(this,"lXby",(function(){return n.yqdw})),e.instance||(e.instance=this),e.instance}return o(e,[{key:"createObjConfig",value:function(t){try{this.zSlf=this.getQeState(),d(this.zSlf[t])||(this.zSlf[t]={SESSION:0,OVERALL:0,DATES:{}},this.yqdw&&(this.zSlf[t].DATES[this.yqdw]=0),this.setQeState(t))}catch(t){z.error("Can not create the frequency count object:"+t)}}},{key:"incrementFrequencies",value:function(t){this.zSlf=this.getQeState();var e=this.zSlf[t];e.SESSION=e.SESSION+1,e.OVERALL=e.OVERALL+1;var n=m();n===this.yqdw&&e.DATES&&e.DATES[n]||(this.yqdw=n,e.DATES={},e.DATES[this.yqdw]=0),e.DATES[this.yqdw]=e.DATES[this.yqdw]+1}}],[{key:"getInstance",value:function(){return e.instance||(e.instance=new e),e.instance}}]),e}();s(R,"instance",void 0),window.ceVersion=150;try{void 0===exports&&null===exports||(exports.default=R,module.exports=exports.default)}catch(t){}return R}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apxor-qe",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
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.3.2"
55
+ "apxor": "2.4.0"
56
56
  },
57
57
  "files": [
58
58
  "dist"