@absmartly/sdk-plugins 1.3.7 → 1.3.8
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.
- package/dist/absmartly-cookie.min.js +1 -1
- package/dist/absmartly-dom-changes-core.min.js +1 -1
- package/dist/absmartly-dom-changes-lite.min.js +1 -1
- package/dist/absmartly-overrides-full.min.js +1 -1
- package/dist/absmartly-overrides-lite.min.js +1 -1
- package/dist/absmartly-sdk-plugins.min.js +1 -1
- package/dist/absmartly-vitals.min.js +1 -1
- package/es/core/DOMManipulatorLite.js +15 -14
- package/es/core/DOMManipulatorLite.js.map +1 -1
- package/es/generated/buildInfo.js +1 -1
- package/es/parsers/VariantExtractor.js +22 -1
- package/es/parsers/VariantExtractor.js.map +1 -1
- package/es/utils/URLMatcher.js +86 -6
- package/es/utils/URLMatcher.js.map +1 -1
- package/lib/core/DOMManipulatorLite.js +15 -14
- package/lib/core/DOMManipulatorLite.js.map +1 -1
- package/lib/generated/buildInfo.d.ts +1 -1
- package/lib/generated/buildInfo.js +1 -1
- package/lib/parsers/VariantExtractor.d.ts +5 -0
- package/lib/parsers/VariantExtractor.js +22 -1
- package/lib/parsers/VariantExtractor.js.map +1 -1
- package/lib/types/index.d.ts +8 -0
- package/lib/utils/URLMatcher.d.ts +15 -0
- package/lib/utils/URLMatcher.js +86 -6
- package/lib/utils/URLMatcher.js.map +1 -1
- package/package.json +1 -1
- package/types/generated/buildInfo.d.ts +1 -1
- package/types/parsers/VariantExtractor.d.ts +5 -0
- package/types/types/index.d.ts +8 -0
- package/types/utils/URLMatcher.d.ts +15 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ABsmartlyCookie=t():e.ABsmartlyCookie=t()}(this,()=>(()=>{"use strict";var e={91:function(e,t,o){var i=this&&this.__awaiter||function(e,t,o,i){return new(o||(o=Promise))(function(r,n){function a(e){try{c(i.next(e))}catch(e){n(e)}}function s(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var o,i,r,n={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(o=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(!(r=n.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){n=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){n.label=s[1];break}if(6===s[0]&&n.label<r[1]){n.label=r[1],r=s;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(s);break}r[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{o=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},n=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,r,n=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}return a},a=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],i=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.CookiePlugin=void 0;var c=o(609),l=o(319),u=function(){function e(e){void 0===e&&(e={}),this.context=e.context,this.debug=e.debug||!1,this.cookieDomain=e.cookieDomain||".absmartly.com",this.cookiePath=e.cookiePath||"/",this.sameSite=e.sameSite||"Lax",this.secure=e.secure||!1,this.cookieExpiryDays=e.cookieExpiryDays||730,this.unitIdCookieName=e.unitIdCookieName||"abs",this.publicIdCookieName=e.publicIdCookieName||"abs_public",this.expiryCookieName=e.expiryCookieName||"abs_expiry",this.utmCookieName=e.utmCookieName||"abs_utm_params",this.utmParams=e.utmParamsList||["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],this.autoUpdateExpiry=!1!==e.autoUpdateExpiry,this.expiryCheckInterval=e.expiryCheckInterval||30}return e.prototype.debugLog=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.debug&&c.logDebug.apply(void 0,a(["[CookiePlugin]"],n(e),!1))},e.prototype.setCookie=function(e,t,o){var i=void 0!==o?o:this.cookieExpiryDays,r=(0,l.setCookie)(e,t,i,{domain:this.cookieDomain,path:this.cookiePath,sameSite:this.sameSite,secure:this.secure});return r&&this.debugLog("Set cookie ".concat(e,":"),t),r},e.prototype.deleteCookie=function(e){(0,l.deleteCookie)(e,{domain:this.cookieDomain,path:this.cookiePath})},e.prototype.getUnitId=function(){if(this.unitId)return this.unitId;var e=navigator.cookieEnabled,t=(0,l.isLocalStorageAvailable)(),o=null;return e&&(o=(0,l.getCookie)(this.unitIdCookieName)||(0,l.getCookie)(this.publicIdCookieName)),!o&&t&&(o=localStorage.getItem("abs_id")),o&&(this.unitId=o),o},e.prototype.setUnitId=function(e){this.unitId=e;var t=navigator.cookieEnabled,o=(0,l.isLocalStorageAvailable)();t&&(this.setCookie(this.unitIdCookieName,e),this.setCookie(this.publicIdCookieName,e),this.autoUpdateExpiry&&this.updateExpiryTimestamp()),o&&localStorage.setItem("abs_id",e),this.debugLog("Unit ID set:",e)},e.prototype.generateAndSetUnitId=function(){var e=(0,l.generateUniqueId)();return this.setUnitId(e),e},e.prototype.updateExpiryTimestamp=function(){if(navigator.cookieEnabled){var e=Date.now();this.setCookie(this.expiryCookieName,e.toString()),this.debugLog("Updated expiry timestamp:",e)}},e.prototype.isExpiryFresh=function(){if(!navigator.cookieEnabled)return!1;var e=(0,l.getCookie)(this.expiryCookieName);if(!e)return!1;try{var t=parseInt(e,10),o=(Date.now()-t)/864e5,i=o<=this.expiryCheckInterval;return this.debugLog("Expiry check:",{daysSinceSet:o,isFresh:i}),i}catch(e){return this.debugLog("Error parsing expiry cookie:",e),!1}},e.prototype.getUtmParams=function(){var e,t,o,i,r={},n=new URLSearchParams(window.location.search);try{for(var a=s(this.utmParams),c=a.next();!c.done;c=a.next()){var l=c.value;(p=n.get(l))&&(r[l]=p)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}if(0===Object.keys(r).length&&document.referrer)try{var u=new URL(document.referrer);try{for(var g=s(this.utmParams),d=g.next();!d.done;d=g.next()){var p;l=d.value;(p=u.searchParams.get(l))&&(r[l]=p)}}catch(e){o={error:e}}finally{try{d&&!d.done&&(i=g.return)&&i.call(g)}finally{if(o)throw o.error}}}catch(e){this.debugLog("Error parsing referrer URL:",e)}if(0===Object.keys(r).length){var h=this.getStoredUtmParams();if(h)return h}return r},e.prototype.storeUtmParams=function(e){if(0!==Object.keys(e).length){var t={params:e,timestamp:Date.now()},o=navigator.cookieEnabled;if((0,l.isLocalStorageAvailable)())try{localStorage.setItem(this.utmCookieName,JSON.stringify(t)),this.debugLog("Stored UTM params in localStorage:",e)}catch(e){this.debugLog("Failed to store UTM params in localStorage:",e)}o&&(this.setCookie(this.utmCookieName,JSON.stringify(t),30),this.debugLog("Stored UTM params in cookie:",e))}},e.prototype.getStoredUtmParams=function(){var e=null,t=(0,l.isLocalStorageAvailable)(),o=navigator.cookieEnabled;if(t)try{e=localStorage.getItem(this.utmCookieName)}catch(e){this.debugLog("Failed to get UTM params from localStorage:",e)}if(!e&&o&&(e=(0,l.getCookie)(this.utmCookieName)),e)try{var i=JSON.parse(e);if(Date.now()-i.timestamp<2592e6)return i.params}catch(e){this.debugLog("Failed to parse stored UTM params:",e)}return null},e.prototype.applyUtmAttributesToContext=function(e){var t,o,i=e||this.context;if(i){var r=this.getUtmParams();Object.keys(r).length>0&&this.storeUtmParams(r);try{for(var a=s(Object.entries(r)),l=a.next();!l.done;l=a.next()){var u=n(l.value,2),g=u[0],d=u[1],p=g.slice(4);i.attribute(p,d),this.debugLog("Set attribute ".concat(p,":"),d)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}}else(0,c.logDebug)("[CookiePlugin] No context available to apply UTM attributes")},e.prototype.clearAllCookies=function(){this.deleteCookie(this.unitIdCookieName),this.deleteCookie(this.publicIdCookieName),this.deleteCookie(this.expiryCookieName),this.deleteCookie(this.utmCookieName),(0,l.isLocalStorageAvailable)()&&(localStorage.removeItem("abs_id"),localStorage.removeItem(this.utmCookieName)),this.unitId=void 0,this.debugLog("All cookies and storage cleared")},e.prototype.ready=function(){return i(this,void 0,void 0,function(){var e;return r(this,function(t){return this.debugLog("Initializing CookiePlugin"),(e=this.getUnitId())?(this.debugLog("Using existing unit ID:",e),this.autoUpdateExpiry&&!this.isExpiryFresh()&&this.updateExpiryTimestamp()):(e=this.generateAndSetUnitId(),this.debugLog("Generated new unit ID:",e)),this.context&&this.applyUtmAttributesToContext(),this.debugLog("CookiePlugin initialized successfully"),[2]})})},e.prototype.initialize=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return[2,this.ready()]})})},e.prototype.setContext=function(e){this.context=e,this.debugLog("Context set for CookiePlugin")},e.prototype.needsServerSideCookie=function(){var e=this.getUnitId(),t=navigator.cookieEnabled,o=(0,l.isLocalStorageAvailable)();if(e){if(t&&!this.isExpiryFresh())return this.debugLog("Existing ID present but expiry not fresh - need worker call"),!0}else if(t||o){var i=(0,l.getCookie)(this.expiryCookieName);return this.debugLog(i?"No existing ID but expiry cookie exists - need worker call":"No existing ID and no expiry cookie - need worker call"),!0}return!1},e.prototype.trackLanding=function(e){var t=e||this.context;if(t){var o=new URLSearchParams(window.location.search),i=this.utmParams.some(function(e){return o.get(e)}),r=document.referrer,n=r&&!r.includes(this.cookieDomain.replace(".","")),a=navigator.cookieEnabled||(0,l.isLocalStorageAvailable)(),s=!!((0,l.getCookie)(this.unitIdCookieName)||(0,l.getCookie)(this.publicIdCookieName)||(0,l.getCookie)(this.expiryCookieName)||(0,l.isLocalStorageAvailable)()&&localStorage.getItem("abs_id"));if(i||n||a&&!s){var u={referrer_url:r||"",landing_url:window.location.href,accepts_cookies:navigator.cookieEnabled,accepts_storage:(0,l.isLocalStorageAvailable)(),has_utm:i};this.debugLog("Tracking landing:",u),t.track("landing",u)}}else(0,c.logDebug)("[CookiePlugin] No context available for tracking landing")},e}();t.CookiePlugin=u},319:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getCookie=function(e){var t,o="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===o.length){return(null===(t=o.pop())||void 0===t?void 0:t.split(";").shift())||null}return null},t.setCookie=r,t.deleteCookie=function(e,t){void 0===t&&(t={});r(e,"",-1,t)},t.generateUniqueId=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2)},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},t.isLocalStorageAvailable=function(){try{var e="__localStorage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}};var i=o(609);function r(e,t,o,r){void 0===r&&(r={});try{var n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3);var a="expires=".concat(n.toUTCString()),s=r.path||"/",c="".concat(e,"=").concat(t,";").concat(a,";path=").concat(s);r.domain&&"localhost"!==r.domain&&(c+=";domain=".concat(r.domain));var l=r.sameSite||"Lax";return c+=";SameSite=".concat(l),r.secure&&(c+=";Secure"),document.cookie=c,!0}catch(t){return(0,i.logDebug)("Unable to set cookie ".concat(e,":"),t),!1}}},609:function(e,t,o){var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},r=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,r,n=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}return a},n=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.DEBUG=void 0,t.logDebug=s,t.logChangeApplication=function(e,o,i,r,n){if(t.DEBUG){s("".concat(n?"✓":"✗"," Applied ").concat(i," change to ").concat(r," element(s)"),{experimentName:e,selector:o,changeType:i,elementsCount:r,success:n})}},t.logChangeRemoval=function(e,o,i,r){if(t.DEBUG){s("Restored ".concat(r," element(s) to original state"),{experimentName:e,selector:o,changeType:i,elementsCount:r,action:"restore"})}},t.logExperimentSummary=function(e,o,i,r){if(t.DEBUG){s('Experiment "'.concat(e,'" summary'),{experimentName:e,totalChanges:o,successfulChanges:i,pendingChanges:r,successRate:o>0?"".concat(Math.round(i/o*100),"%"):"N/A"})}},t.logStateOperation=function(e,o,i,r){if(t.DEBUG){s("State ".concat(e," operation"),{operation:e,selector:o,changeType:i,experimentName:r})}},t.logVisibilityEvent=function(e,o,i){if(t.DEBUG){s(i?"Element became visible - experiment triggered":"Element visibility changed",{experimentName:e,selector:o.className||o.id||o.tagName,triggered:i,action:"visibility"})}},t.logMessage=function(e,o,i){if(t.DEBUG){s("Message ".concat(e,": ").concat(o),{direction:e,messageType:o,payload:i,bridge:"extension"})}},t.logPerformance=function(e,o,r){if(t.DEBUG){s("Performance: ".concat(e," took ").concat(o,"ms"),i({operation:e,duration:o,performance:!0},r))}},t.logProductionWarn=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];console.warn.apply(console,n([e],r(t),!1))};var a=o(834);function s(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(t.DEBUG)if(2===e.length&&"string"==typeof e[0]&&"object"==typeof e[1]){var i=r(e,2),a=i[0],s=i[1];if(a.includes("Original state already stored"))return;if(a.includes("State store operation"))return;if(a.includes("Performance:")&&(null==s?void 0:s.duration)&&s.duration<5)return;if(a.includes("Message sent:")||a.includes("Message received:"))return;var c=(new Date).toISOString(),l="[ABsmartly Debug]";console.log("".concat(l," [").concat(c,"] ").concat(a),s)}else if(1===e.length&&"string"==typeof e[0]){if((a=e[0]).includes("Original state already stored"))return;if(a.includes("State store operation"))return;if(a.includes("Message sent:")||a.includes("Message received:"))return;c=(new Date).toISOString(),l="[ABsmartly Debug]";console.log("".concat(l," [").concat(c,"] ").concat(a))}else console.log.apply(console,n([],r(e),!1))}t.DEBUG=a.BUILD_DEBUG},834:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BUILD_DEBUG=t.BUILD_VERSION=void 0,t.BUILD_VERSION="1.3.7",t.BUILD_DEBUG=!1}},t={};function o(i){var r=t[i];if(void 0!==r)return r.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,o),n.exports}var i={};return(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.CookiePlugin=void 0;var t=o(91);Object.defineProperty(e,"CookiePlugin",{enumerable:!0,get:function(){return t.CookiePlugin}}),e.default=t.CookiePlugin})(),i})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ABsmartlyCookie=t():e.ABsmartlyCookie=t()}(this,()=>(()=>{"use strict";var e={91:function(e,t,o){var i=this&&this.__awaiter||function(e,t,o,i){return new(o||(o=Promise))(function(r,n){function a(e){try{c(i.next(e))}catch(e){n(e)}}function s(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var o,i,r,n={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(n=0)),n;)try{if(o=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(!(r=n.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){n=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){n.label=s[1];break}if(6===s[0]&&n.label<r[1]){n.label=r[1],r=s;break}if(r&&n.label<r[2]){n.label=r[2],n.ops.push(s);break}r[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{o=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},n=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,r,n=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}return a},a=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],i=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.CookiePlugin=void 0;var c=o(609),l=o(319),u=function(){function e(e){void 0===e&&(e={}),this.context=e.context,this.debug=e.debug||!1,this.cookieDomain=e.cookieDomain||".absmartly.com",this.cookiePath=e.cookiePath||"/",this.sameSite=e.sameSite||"Lax",this.secure=e.secure||!1,this.cookieExpiryDays=e.cookieExpiryDays||730,this.unitIdCookieName=e.unitIdCookieName||"abs",this.publicIdCookieName=e.publicIdCookieName||"abs_public",this.expiryCookieName=e.expiryCookieName||"abs_expiry",this.utmCookieName=e.utmCookieName||"abs_utm_params",this.utmParams=e.utmParamsList||["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],this.autoUpdateExpiry=!1!==e.autoUpdateExpiry,this.expiryCheckInterval=e.expiryCheckInterval||30}return e.prototype.debugLog=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.debug&&c.logDebug.apply(void 0,a(["[CookiePlugin]"],n(e),!1))},e.prototype.setCookie=function(e,t,o){var i=void 0!==o?o:this.cookieExpiryDays,r=(0,l.setCookie)(e,t,i,{domain:this.cookieDomain,path:this.cookiePath,sameSite:this.sameSite,secure:this.secure});return r&&this.debugLog("Set cookie ".concat(e,":"),t),r},e.prototype.deleteCookie=function(e){(0,l.deleteCookie)(e,{domain:this.cookieDomain,path:this.cookiePath})},e.prototype.getUnitId=function(){if(this.unitId)return this.unitId;var e=navigator.cookieEnabled,t=(0,l.isLocalStorageAvailable)(),o=null;return e&&(o=(0,l.getCookie)(this.unitIdCookieName)||(0,l.getCookie)(this.publicIdCookieName)),!o&&t&&(o=localStorage.getItem("abs_id")),o&&(this.unitId=o),o},e.prototype.setUnitId=function(e){this.unitId=e;var t=navigator.cookieEnabled,o=(0,l.isLocalStorageAvailable)();t&&(this.setCookie(this.unitIdCookieName,e),this.setCookie(this.publicIdCookieName,e),this.autoUpdateExpiry&&this.updateExpiryTimestamp()),o&&localStorage.setItem("abs_id",e),this.debugLog("Unit ID set:",e)},e.prototype.generateAndSetUnitId=function(){var e=(0,l.generateUniqueId)();return this.setUnitId(e),e},e.prototype.updateExpiryTimestamp=function(){if(navigator.cookieEnabled){var e=Date.now();this.setCookie(this.expiryCookieName,e.toString()),this.debugLog("Updated expiry timestamp:",e)}},e.prototype.isExpiryFresh=function(){if(!navigator.cookieEnabled)return!1;var e=(0,l.getCookie)(this.expiryCookieName);if(!e)return!1;try{var t=parseInt(e,10),o=(Date.now()-t)/864e5,i=o<=this.expiryCheckInterval;return this.debugLog("Expiry check:",{daysSinceSet:o,isFresh:i}),i}catch(e){return this.debugLog("Error parsing expiry cookie:",e),!1}},e.prototype.getUtmParams=function(){var e,t,o,i,r={},n=new URLSearchParams(window.location.search);try{for(var a=s(this.utmParams),c=a.next();!c.done;c=a.next()){var l=c.value;(p=n.get(l))&&(r[l]=p)}}catch(t){e={error:t}}finally{try{c&&!c.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}if(0===Object.keys(r).length&&document.referrer)try{var u=new URL(document.referrer);try{for(var g=s(this.utmParams),d=g.next();!d.done;d=g.next()){var p;l=d.value;(p=u.searchParams.get(l))&&(r[l]=p)}}catch(e){o={error:e}}finally{try{d&&!d.done&&(i=g.return)&&i.call(g)}finally{if(o)throw o.error}}}catch(e){this.debugLog("Error parsing referrer URL:",e)}if(0===Object.keys(r).length){var h=this.getStoredUtmParams();if(h)return h}return r},e.prototype.storeUtmParams=function(e){if(0!==Object.keys(e).length){var t={params:e,timestamp:Date.now()},o=navigator.cookieEnabled;if((0,l.isLocalStorageAvailable)())try{localStorage.setItem(this.utmCookieName,JSON.stringify(t)),this.debugLog("Stored UTM params in localStorage:",e)}catch(e){this.debugLog("Failed to store UTM params in localStorage:",e)}o&&(this.setCookie(this.utmCookieName,JSON.stringify(t),30),this.debugLog("Stored UTM params in cookie:",e))}},e.prototype.getStoredUtmParams=function(){var e=null,t=(0,l.isLocalStorageAvailable)(),o=navigator.cookieEnabled;if(t)try{e=localStorage.getItem(this.utmCookieName)}catch(e){this.debugLog("Failed to get UTM params from localStorage:",e)}if(!e&&o&&(e=(0,l.getCookie)(this.utmCookieName)),e)try{var i=JSON.parse(e);if(Date.now()-i.timestamp<2592e6)return i.params}catch(e){this.debugLog("Failed to parse stored UTM params:",e)}return null},e.prototype.applyUtmAttributesToContext=function(e){var t,o,i=e||this.context;if(i){var r=this.getUtmParams();Object.keys(r).length>0&&this.storeUtmParams(r);try{for(var a=s(Object.entries(r)),l=a.next();!l.done;l=a.next()){var u=n(l.value,2),g=u[0],d=u[1],p=g.slice(4);i.attribute(p,d),this.debugLog("Set attribute ".concat(p,":"),d)}}catch(e){t={error:e}}finally{try{l&&!l.done&&(o=a.return)&&o.call(a)}finally{if(t)throw t.error}}}else(0,c.logDebug)("[CookiePlugin] No context available to apply UTM attributes")},e.prototype.clearAllCookies=function(){this.deleteCookie(this.unitIdCookieName),this.deleteCookie(this.publicIdCookieName),this.deleteCookie(this.expiryCookieName),this.deleteCookie(this.utmCookieName),(0,l.isLocalStorageAvailable)()&&(localStorage.removeItem("abs_id"),localStorage.removeItem(this.utmCookieName)),this.unitId=void 0,this.debugLog("All cookies and storage cleared")},e.prototype.ready=function(){return i(this,void 0,void 0,function(){var e;return r(this,function(t){return this.debugLog("Initializing CookiePlugin"),(e=this.getUnitId())?(this.debugLog("Using existing unit ID:",e),this.autoUpdateExpiry&&!this.isExpiryFresh()&&this.updateExpiryTimestamp()):(e=this.generateAndSetUnitId(),this.debugLog("Generated new unit ID:",e)),this.context&&this.applyUtmAttributesToContext(),this.debugLog("CookiePlugin initialized successfully"),[2]})})},e.prototype.initialize=function(){return i(this,void 0,void 0,function(){return r(this,function(e){return[2,this.ready()]})})},e.prototype.setContext=function(e){this.context=e,this.debugLog("Context set for CookiePlugin")},e.prototype.needsServerSideCookie=function(){var e=this.getUnitId(),t=navigator.cookieEnabled,o=(0,l.isLocalStorageAvailable)();if(e){if(t&&!this.isExpiryFresh())return this.debugLog("Existing ID present but expiry not fresh - need worker call"),!0}else if(t||o){var i=(0,l.getCookie)(this.expiryCookieName);return this.debugLog(i?"No existing ID but expiry cookie exists - need worker call":"No existing ID and no expiry cookie - need worker call"),!0}return!1},e.prototype.trackLanding=function(e){var t=e||this.context;if(t){var o=new URLSearchParams(window.location.search),i=this.utmParams.some(function(e){return o.get(e)}),r=document.referrer,n=r&&!r.includes(this.cookieDomain.replace(".","")),a=navigator.cookieEnabled||(0,l.isLocalStorageAvailable)(),s=!!((0,l.getCookie)(this.unitIdCookieName)||(0,l.getCookie)(this.publicIdCookieName)||(0,l.getCookie)(this.expiryCookieName)||(0,l.isLocalStorageAvailable)()&&localStorage.getItem("abs_id"));if(i||n||a&&!s){var u={referrer_url:r||"",landing_url:window.location.href,accepts_cookies:navigator.cookieEnabled,accepts_storage:(0,l.isLocalStorageAvailable)(),has_utm:i};this.debugLog("Tracking landing:",u),t.track("landing",u)}}else(0,c.logDebug)("[CookiePlugin] No context available for tracking landing")},e}();t.CookiePlugin=u},319:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getCookie=function(e){var t,o="; ".concat(document.cookie).split("; ".concat(e,"="));if(2===o.length){return(null===(t=o.pop())||void 0===t?void 0:t.split(";").shift())||null}return null},t.setCookie=r,t.deleteCookie=function(e,t){void 0===t&&(t={});r(e,"",-1,t)},t.generateUniqueId=function(){return Date.now().toString(36)+Math.random().toString(36).substring(2)},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},t.isLocalStorageAvailable=function(){try{var e="__localStorage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}};var i=o(609);function r(e,t,o,r){void 0===r&&(r={});try{var n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3);var a="expires=".concat(n.toUTCString()),s=r.path||"/",c="".concat(e,"=").concat(t,";").concat(a,";path=").concat(s);r.domain&&"localhost"!==r.domain&&(c+=";domain=".concat(r.domain));var l=r.sameSite||"Lax";return c+=";SameSite=".concat(l),r.secure&&(c+=";Secure"),document.cookie=c,!0}catch(t){return(0,i.logDebug)("Unable to set cookie ".concat(e,":"),t),!1}}},609:function(e,t,o){var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,o=1,i=arguments.length;o<i;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},r=this&&this.__read||function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,r,n=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}return a},n=this&&this.__spreadArray||function(e,t,o){if(o||2===arguments.length)for(var i,r=0,n=t.length;r<n;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.DEBUG=void 0,t.logDebug=s,t.logChangeApplication=function(e,o,i,r,n){if(t.DEBUG){s("".concat(n?"✓":"✗"," Applied ").concat(i," change to ").concat(r," element(s)"),{experimentName:e,selector:o,changeType:i,elementsCount:r,success:n})}},t.logChangeRemoval=function(e,o,i,r){if(t.DEBUG){s("Restored ".concat(r," element(s) to original state"),{experimentName:e,selector:o,changeType:i,elementsCount:r,action:"restore"})}},t.logExperimentSummary=function(e,o,i,r){if(t.DEBUG){s('Experiment "'.concat(e,'" summary'),{experimentName:e,totalChanges:o,successfulChanges:i,pendingChanges:r,successRate:o>0?"".concat(Math.round(i/o*100),"%"):"N/A"})}},t.logStateOperation=function(e,o,i,r){if(t.DEBUG){s("State ".concat(e," operation"),{operation:e,selector:o,changeType:i,experimentName:r})}},t.logVisibilityEvent=function(e,o,i){if(t.DEBUG){s(i?"Element became visible - experiment triggered":"Element visibility changed",{experimentName:e,selector:o.className||o.id||o.tagName,triggered:i,action:"visibility"})}},t.logMessage=function(e,o,i){if(t.DEBUG){s("Message ".concat(e,": ").concat(o),{direction:e,messageType:o,payload:i,bridge:"extension"})}},t.logPerformance=function(e,o,r){if(t.DEBUG){s("Performance: ".concat(e," took ").concat(o,"ms"),i({operation:e,duration:o,performance:!0},r))}},t.logProductionWarn=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];console.warn.apply(console,n([e],r(t),!1))};var a=o(834);function s(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];if(t.DEBUG)if(2===e.length&&"string"==typeof e[0]&&"object"==typeof e[1]){var i=r(e,2),a=i[0],s=i[1];if(a.includes("Original state already stored"))return;if(a.includes("State store operation"))return;if(a.includes("Performance:")&&(null==s?void 0:s.duration)&&s.duration<5)return;if(a.includes("Message sent:")||a.includes("Message received:"))return;var c=(new Date).toISOString(),l="[ABsmartly Debug]";console.log("".concat(l," [").concat(c,"] ").concat(a),s)}else if(1===e.length&&"string"==typeof e[0]){if((a=e[0]).includes("Original state already stored"))return;if(a.includes("State store operation"))return;if(a.includes("Message sent:")||a.includes("Message received:"))return;c=(new Date).toISOString(),l="[ABsmartly Debug]";console.log("".concat(l," [").concat(c,"] ").concat(a))}else console.log.apply(console,n([],r(e),!1))}t.DEBUG=a.BUILD_DEBUG},834:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BUILD_DEBUG=t.BUILD_VERSION=void 0,t.BUILD_VERSION="1.3.8",t.BUILD_DEBUG=!1}},t={};function o(i){var r=t[i];if(void 0!==r)return r.exports;var n=t[i]={exports:{}};return e[i].call(n.exports,n,n.exports,o),n.exports}var i={};return(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:!0}),e.CookiePlugin=void 0;var t=o(91);Object.defineProperty(e,"CookiePlugin",{enumerable:!0,get:function(){return t.CookiePlugin}}),e.default=t.CookiePlugin})(),i})());
|