Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@kameleoon/javascript-sdk-core

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kameleoon/javascript-sdk-core - npm Package Compare versions

Comparing version 2.10.1 to 3.0.0

dist/clientConfiguration/clientConfiguration.d.ts

12

dist/cacheManager/cacheManager.js

@@ -1,12 +0,2 @@

"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CacheManager=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* CacheManager - a class for managing cache
*/var CacheManager=/*#__PURE__*/function(){/**
* @param {number} cleanupTimeout - timeout for cleaning cache in seconds
* generic type `T` is a type of data that will be stored in cache
* @example
* ```typescript
* const cacheManager = new CacheManager<number>(60);
* ```
*/function a(b){_classCallCheck(this,a),_defineProperty(this,"cacheMap",new Map),_defineProperty(this,"intervalId",null),_defineProperty(this,"cleanupTimeout",void 0),this.cleanupTimeout=b*_types.Milliseconds.Second}return _createClass(a,[{key:"add",value:function add(a){var b=a.key,c=a.data,d=a.lifetime;null===this.intervalId&&this.activate();var e=d*_types.Milliseconds.Second,f={data:c,expirationTime:Date.now()+e};this.cacheMap.set(b,f)}},{key:"getAliveItem",value:function getAliveItem(a){var b=this.cacheMap.get(a);return b&&b.expirationTime>=Date.now()?b.data:(b&&this.cacheMap.delete(a),null)}},{key:"activate",value:function activate(){var a=this;this.intervalId=setInterval(function(){var b,c=Date.now(),d=_createForOfIteratorHelper(a.cacheMap);try{for(d.s();!(b=d.n()).done;){var e=_slicedToArray(b.value,2),f=e[0],g=e[1];g.expirationTime<c&&a.cacheMap.delete(f)}}catch(a){d.e(a)}finally{d.f()}a.cacheMap.size||a.cleanupInterval()},this.cleanupTimeout)}},{key:"cleanupInterval",value:function cleanupInterval(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}}]),a}();exports.CacheManager=CacheManager;
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CacheManager=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var CacheManager=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"cacheMap",new Map),_defineProperty(this,"intervalId",null),_defineProperty(this,"cleanupTimeout",void 0),this.cleanupTimeout=b*_types.Milliseconds.Second}return _createClass(a,[{key:"add",value:function add(a){var b=a.key,c=a.data,d=a.lifetime;null===this.intervalId&&this.activate();var e=d*_types.Milliseconds.Second,f={data:c,expirationTime:Date.now()+e};this.cacheMap.set(b,f)}},{key:"getAliveItem",value:function getAliveItem(a){var b=this.cacheMap.get(a);return b&&b.expirationTime>=Date.now()?b.data:(b&&this.cacheMap.delete(a),null)}},{key:"activate",value:function activate(){var a=this;this.intervalId=setInterval(function(){var b,c=Date.now(),d=_createForOfIteratorHelper(a.cacheMap);try{for(d.s();!(b=d.n()).done;){var e=_slicedToArray(b.value,2),f=e[0],g=e[1];g.expirationTime<c&&a.cacheMap.delete(f)}}catch(a){d.e(a)}finally{d.f()}a.cacheMap.size||a.cleanupInterval()},this.cleanupTimeout)}},{key:"cleanupInterval",value:function cleanupInterval(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}}]),a}();exports.CacheManager=CacheManager;
//# sourceMappingURL=cacheManager.js.map

@@ -1,2 +0,2 @@

"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ClientSettings=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),_defineProperty(this,"updateInterval",60*_types.Milliseconds.Minute),_defineProperty(this,"environment",void 0),_defineProperty(this,"siteCode",void 0),this.siteCode=b,null!==c&&void 0!==c&&c.environment&&(this.environment=c.environment),null!==c&&void 0!==c&&c.updateInterval&&(1>c.updateInterval&&(this.updateInterval=1*_types.Milliseconds.Minute),this.updateInterval=c.updateInterval*_types.Milliseconds.Minute)}return _createClass(a,[{key:"settings",get:function get(){return{updateInterval:this.updateInterval,environment:this.environment,siteCode:this.siteCode}}}]),a}();exports.ClientSettings=ClientSettings;
"use strict";var _types=require("../types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ClientSettings=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ClientSettings=function(){function a(b,c){_classCallCheck(this,a),_defineProperty(this,"updateInterval",60*_types.Milliseconds.Minute),_defineProperty(this,"environment",void 0),_defineProperty(this,"siteCode",void 0),this.siteCode=b,null!==c&&void 0!==c&&c.environment&&(this.environment=c.environment),null!==c&&void 0!==c&&c.updateInterval&&(1>c.updateInterval&&(this.updateInterval=1*_types.Milliseconds.Minute),this.updateInterval=c.updateInterval*_types.Milliseconds.Minute)}return _createClass(a,[{key:"settings",get:function get(){return{updateInterval:this.updateInterval,environment:this.environment,siteCode:this.siteCode}}}]),a}();exports.ClientSettings=ClientSettings;
//# sourceMappingURL=clientSettings.js.map

@@ -1,2 +0,2 @@

export declare const UNALLOCATED_VARIATION_ID = 0;
import { VisitorDataFiltersType } from './utilities/types';
export declare const OFF_VARIATION_KEY = "off";

@@ -8,3 +8,3 @@ export declare const KAMELEOON_COOKIE_KEY = "kameleoonVisitorCode";

export declare const CACHE_ITEM_LIFETIME = 5;
export declare enum Cookie {
export declare enum CookieParameter {
PairsDelimiter = "; ",

@@ -35,1 +35,2 @@ KeyValueDelimiter = "=",

}
export declare const DEFAULT_VISITOR_DATA_FILTERS: VisitorDataFiltersType;

@@ -1,5 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.UNALLOCATED_VARIATION_ID=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.KAMELEOON_COOKIE_KEY=exports.Cookie=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;var UNALLOCATED_VARIATION_ID=0;exports.UNALLOCATED_VARIATION_ID=0;var OFF_VARIATION_KEY="off";exports.OFF_VARIATION_KEY="off";var KAMELEOON_COOKIE_KEY="kameleoonVisitorCode";exports.KAMELEOON_COOKIE_KEY="kameleoonVisitorCode";var WAREHOUSE_AUDIENCE_KEY="warehouseAudiences";exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences";var VISITOR_CODE_LENGTH=16;exports.VISITOR_CODE_LENGTH=16;var CACHE_CLEANUP_TIMEOUT=10;exports.CACHE_CLEANUP_TIMEOUT=10;var CACHE_ITEM_LIFETIME=5;exports.CACHE_ITEM_LIFETIME=5;var Cookie=/*#__PURE__*/function(a){return a.PairsDelimiter="; ",a.KeyValueDelimiter="=",a.MaxAge="Max-Age",a.Path="Path",a.Domain="Domain",a}({});/**
* @readonly
* @enum {string} an Enum of all the possible Kameleoon SDK types
* */exports.Cookie=Cookie;var SdkLanguageType=/*#__PURE__*/function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});exports.SdkLanguageType=SdkLanguageType;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WAREHOUSE_AUDIENCE_KEY=exports.VISITOR_CODE_LENGTH=exports.SdkLanguageType=exports.OFF_VARIATION_KEY=exports.KAMELEOON_COOKIE_KEY=exports.DEFAULT_VISITOR_DATA_FILTERS=exports.CookieParameter=exports.CACHE_ITEM_LIFETIME=exports.CACHE_CLEANUP_TIMEOUT=void 0;var OFF_VARIATION_KEY="off";exports.OFF_VARIATION_KEY="off";var KAMELEOON_COOKIE_KEY="kameleoonVisitorCode";exports.KAMELEOON_COOKIE_KEY="kameleoonVisitorCode";var WAREHOUSE_AUDIENCE_KEY="warehouseAudiences";exports.WAREHOUSE_AUDIENCE_KEY="warehouseAudiences";var VISITOR_CODE_LENGTH=16;exports.VISITOR_CODE_LENGTH=16;var CACHE_CLEANUP_TIMEOUT=10;exports.CACHE_CLEANUP_TIMEOUT=10;var CACHE_ITEM_LIFETIME=5;exports.CACHE_ITEM_LIFETIME=5;var CookieParameter=function(a){return a.PairsDelimiter="; ",a.KeyValueDelimiter="=",a.MaxAge="Max-Age",a.Path="Path",a.Domain="Domain",a}({});exports.CookieParameter=CookieParameter;var SdkLanguageType=function(a){return a.ANDROID="ANDROID",a.IOS="IOS",a.JAVA="JAVA",a.CSHARP="CSHARP",a.NODEJS="NODEJS",a.PHP="PHP",a.RUBY="RUBY",a.GO="GO",a.FLUTTER="FLUTTER",a.REACT="REACT",a.PYTHON="PYTHON",a.JAVASCRIPT="JAVASCRIPT",a.RUST="RUST",a}({});exports.SdkLanguageType=SdkLanguageType;var DEFAULT_VISITOR_DATA_FILTERS={visitAmount:1,customData:!0,pageViews:!1,geolocation:!1,device:!1,browser:!1,operatingSystem:!1,conversions:!1,experiments:!1};exports.DEFAULT_VISITOR_DATA_FILTERS=DEFAULT_VISITOR_DATA_FILTERS;
//# sourceMappingURL=constants.js.map

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExternalEventSource=void 0;var _requester=require("../requester"),_constants=require("../requester/constants"),_constants2=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ExternalEventSource=/*#__PURE__*/function(){function a(b,c){_classCallCheck(this,a),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"siteCode",void 0);var d=_requester.URL.SERVER_SENT_EVENTS+_constants.UrlQuery.Sse+b,e=c.initialize(d);this.eventSource=e,this.siteCode=b}return _createClass(a,[{key:"open",value:function open(a){this.eventSource.open({onEvent:a,siteCode:this.siteCode,eventType:_constants2.REAL_TIME_EVENT})}},{key:"close",value:function close(){this.eventSource.close()}}]),a}();exports.ExternalEventSource=ExternalEventSource;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExternalEventSource=void 0;var _requester=require("../requester"),_constants=require("../requester/constants"),_constants2=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ExternalEventSource=function(){function a(b,c){_classCallCheck(this,a),_defineProperty(this,"eventSource",void 0),_defineProperty(this,"siteCode",void 0);var d=_requester.URL.SERVER_SENT_EVENTS+_constants.UrlQuery.Sse+b,e=c.initialize(d);this.eventSource=e,this.siteCode=b}return _createClass(a,[{key:"open",value:function open(a){this.eventSource.open({onEvent:a,siteCode:this.siteCode,eventType:_constants2.REAL_TIME_EVENT})}},{key:"close",value:function close(){this.eventSource.close()}}]),a}();exports.ExternalEventSource=ExternalEventSource;
//# sourceMappingURL=externalEventSource.js.map

@@ -1,6 +0,5 @@

import { ObtainExperimentHashDoubleParamsType, ObtainFeatureFlagHashDoubleParamsType } from './types';
import { GetHashDoubleParamsType } from './types';
export declare class Hasher {
static obtainExperimentHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainExperimentHashDoubleParamsType): number;
static obtainFeatureFlagHashDouble({ visitorCode, campaignId, respoolTime, }: ObtainFeatureFlagHashDoubleParamsType): number;
static getHashDouble({ visitorCode, id, respoolTime, }: GetHashDoubleParamsType): number;
static calculateHash(seed: string): number;
}

@@ -1,7 +0,2 @@

"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Hasher=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"obtainExperimentHashDouble",value:function obtainExperimentHashDouble(a){var b=a.visitorCode,c=a.campaignId,d=a.respoolTime,e="";return d.length&&d.forEach(function(a){e+=a.value+""}),this.calculateHash(b+c+e)}},{key:"obtainFeatureFlagHashDouble",value:function obtainFeatureFlagHashDouble(a){var b=a.visitorCode,c=a.campaignId,d=a.respoolTime,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}// --- Note ---
// `hashDouble` is a seeded pseudo-random number between 0 and 1
// used for deciding what variation to assign
// `calculateHash` algorithm is consistent between every SDK
// and will always provide same pseudo-random value for the same input parameters
},{key:"calculateHash",value:function calculateHash(a){var b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}]),a}();exports.Hasher=Hasher;
"use strict";var _sha=_interopRequireDefault(require("crypto-js/sha256"));Object.defineProperty(exports,"__esModule",{value:!0}),exports.Hasher=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Hasher=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"getHashDouble",value:function getHashDouble(a){var b=a.visitorCode,c=a.id,d=a.respoolTime,e="";return d&&(e+=d+""),this.calculateHash(b+c+e)}},{key:"calculateHash",value:function calculateHash(a){var b=(0,_sha.default)(a).toString();return parseInt(b,16)/Math.pow(2,256)}}]),a}();exports.Hasher=Hasher;
//# sourceMappingURL=hasher.js.map

@@ -1,12 +0,5 @@

import { RespoolTimeType } from '../campaignConfiguration/types';
type ObtainHashDoubleParamsType = {
export type GetHashDoubleParamsType = {
respoolTime: number | null;
visitorCode: string;
campaignId: string;
id: string;
};
export type ObtainExperimentHashDoubleParamsType = ObtainHashDoubleParamsType & {
respoolTime: RespoolTimeType[];
};
export type ObtainFeatureFlagHashDoubleParamsType = ObtainHashDoubleParamsType & {
respoolTime: number | null;
};
export {};

@@ -5,9 +5,10 @@ export { Ok, Result, Err } from 'ts-res';

export { KameleoonException, KameleoonError } from './kameleoonError';
export { ExperimentVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, IExternalStorageConstructor, } from './storage';
export { Cookie, VISITOR_CODE_LENGTH, SdkLanguageType } from './constants';
export { CLEANUP_TARGETING_DATA_INTERVAL } from './campaignConfiguration';
export { JSONType } from './campaignConfiguration';
export { Environment, VariableType, ExperimentType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, Milliseconds, } from './types';
export { CustomData, Conversion, Device, Browser, UserAgent, DeviceType, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, } from './kameleoonData';
export { VisitorDataFiltersType } from './utilities';
export { FeatureFlagVariationsType, KameleoonStorageKey, StorageDataType, IExternalStorage, IExternalStorageConstructor, } from './storage';
export { CookieParameter, VISITOR_CODE_LENGTH, SdkLanguageType, } from './constants';
export { JSONType } from './clientConfiguration';
export { Environment, VariableType, FeatureFlagType, SDKCoreParameters, SDKConfigurationType, ExternalPackageInfoType, TrackConversionParamsType, FeatureVariableResultType, RemoteVisitorDataParamsType, InternalSDKConfigurationType, GetFeatureFlagVariableParamsType, GetVisitorWarehouseAudienceParamsType, ServerGetVisitorCodeParametersType, ClientGetVisitorCodeParametersType, MobileGetVisitorCodeParametersType, Milliseconds, } from './types';
export { DEFAULT_CLEANUP_INTERVAL } from './kameleoonData';
export { ApplicationVersion, CustomData, Conversion, Device, Cookie, Browser, UserAgent, DeviceType, CookieType, GeolocationData, GeolocationInfoType, OperatingSystemType, OperatingSystem, BrowserType, PageView, KameleoonData, KameleoonDataType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './kameleoonData';
export { RealTimeEventType, IExternalEventSource, EventSourceOpenParametersType, IExternalEventSourceConstructor, } from './eventSource';
export { Header, HttpMethod, TrackParametersType, IExternalRequestDispatcher, GetClientConfigurationResultType, } from './requester';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"CLEANUP_TARGETING_DATA_INTERVAL",{enumerable:!0,get:function get(){return _campaignConfiguration.CLEANUP_TARGETING_DATA_INTERVAL}}),Object.defineProperty(exports,"ClientGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ClientGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _constants.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function get(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function get(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function get(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExperimentType",{enumerable:!0,get:function get(){return _types.ExperimentType}}),Object.defineProperty(exports,"ExperimentVariationsType",{enumerable:!0,get:function get(){return _storage.ExperimentVariationsType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function get(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function get(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function get(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GetClientConfigurationResultType",{enumerable:!0,get:function get(){return _requester.GetClientConfigurationResultType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function get(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function get(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _requester.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalEventSourceConstructor",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSourceConstructor}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _storage.IExternalStorageConstructor}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.IKameleoonClient}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function get(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function get(){return _campaignConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function get(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function get(){return _types.Milliseconds}}),Object.defineProperty(exports,"MobileGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.MobileGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function get(){return _tsRes.Ok}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function get(){return _eventSource.RealTimeEventType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function get(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function get(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function get(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function get(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"ServerGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ServerGetVisitorCodeParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function get(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function get(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function get(){return _types.VariableType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_storage=require("./storage"),_constants=require("./constants"),_campaignConfiguration=require("./campaignConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function get(){return _kameleoonData.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _kameleoonData.Browser}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _kameleoonData.BrowserType}}),Object.defineProperty(exports,"ClientGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ClientGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _kameleoonData.Conversion}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _kameleoonData.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _kameleoonData.Cookie}}),Object.defineProperty(exports,"CookieParameter",{enumerable:!0,get:function get(){return _constants.CookieParameter}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function get(){return _kameleoonData.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _kameleoonData.CustomData}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function get(){return _kameleoonData.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _kameleoonData.Device}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _kameleoonData.DeviceType}}),Object.defineProperty(exports,"Environment",{enumerable:!0,get:function get(){return _types.Environment}}),Object.defineProperty(exports,"Err",{enumerable:!0,get:function get(){return _tsRes.Err}}),Object.defineProperty(exports,"EventSourceOpenParametersType",{enumerable:!0,get:function get(){return _eventSource.EventSourceOpenParametersType}}),Object.defineProperty(exports,"ExternalPackageInfoType",{enumerable:!0,get:function get(){return _types.ExternalPackageInfoType}}),Object.defineProperty(exports,"FeatureFlagType",{enumerable:!0,get:function get(){return _types.FeatureFlagType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function get(){return _storage.FeatureFlagVariationsType}}),Object.defineProperty(exports,"FeatureVariableResultType",{enumerable:!0,get:function get(){return _types.FeatureVariableResultType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function get(){return _kameleoonData.GeolocationInfoType}}),Object.defineProperty(exports,"GetClientConfigurationResultType",{enumerable:!0,get:function get(){return _requester.GetClientConfigurationResultType}}),Object.defineProperty(exports,"GetFeatureFlagVariableParamsType",{enumerable:!0,get:function get(){return _types.GetFeatureFlagVariableParamsType}}),Object.defineProperty(exports,"GetVisitorWarehouseAudienceParamsType",{enumerable:!0,get:function get(){return _types.GetVisitorWarehouseAudienceParamsType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _requester.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _requester.HttpMethod}}),Object.defineProperty(exports,"IExternalEventSource",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSource}}),Object.defineProperty(exports,"IExternalEventSourceConstructor",{enumerable:!0,get:function get(){return _eventSource.IExternalEventSourceConstructor}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _requester.IExternalRequestDispatcher}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _storage.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _storage.IExternalStorageConstructor}}),Object.defineProperty(exports,"IKameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.IKameleoonClient}}),Object.defineProperty(exports,"InternalSDKConfigurationType",{enumerable:!0,get:function get(){return _types.InternalSDKConfigurationType}}),Object.defineProperty(exports,"JSONType",{enumerable:!0,get:function get(){return _clientConfiguration.JSONType}}),Object.defineProperty(exports,"KameleoonCore",{enumerable:!0,get:function get(){return _kameleoonClient.KameleoonClient}}),Object.defineProperty(exports,"KameleoonCoreUtils",{enumerable:!0,get:function get(){return _kameleoonUtils.KameleoonUtils}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _kameleoonData.KameleoonDataType}}),Object.defineProperty(exports,"KameleoonError",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonError}}),Object.defineProperty(exports,"KameleoonException",{enumerable:!0,get:function get(){return _kameleoonError.KameleoonException}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _storage.KameleoonStorageKey}}),Object.defineProperty(exports,"Milliseconds",{enumerable:!0,get:function get(){return _types.Milliseconds}}),Object.defineProperty(exports,"MobileGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.MobileGetVisitorCodeParametersType}}),Object.defineProperty(exports,"Ok",{enumerable:!0,get:function get(){return _tsRes.Ok}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function get(){return _kameleoonData.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _kameleoonData.PageView}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _kameleoonData.PageViewParametersType}}),Object.defineProperty(exports,"RealTimeEventType",{enumerable:!0,get:function get(){return _eventSource.RealTimeEventType}}),Object.defineProperty(exports,"RemoteVisitorDataParamsType",{enumerable:!0,get:function get(){return _types.RemoteVisitorDataParamsType}}),Object.defineProperty(exports,"Result",{enumerable:!0,get:function get(){return _tsRes.Result}}),Object.defineProperty(exports,"SDKConfigurationType",{enumerable:!0,get:function get(){return _types.SDKConfigurationType}}),Object.defineProperty(exports,"SDKCoreParameters",{enumerable:!0,get:function get(){return _types.SDKCoreParameters}}),Object.defineProperty(exports,"SdkLanguageType",{enumerable:!0,get:function get(){return _constants.SdkLanguageType}}),Object.defineProperty(exports,"ServerGetVisitorCodeParametersType",{enumerable:!0,get:function get(){return _types.ServerGetVisitorCodeParametersType}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _storage.StorageDataType}}),Object.defineProperty(exports,"TrackConversionParamsType",{enumerable:!0,get:function get(){return _types.TrackConversionParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _requester.TrackParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _kameleoonData.UserAgent}}),Object.defineProperty(exports,"VISITOR_CODE_LENGTH",{enumerable:!0,get:function get(){return _constants.VISITOR_CODE_LENGTH}}),Object.defineProperty(exports,"VariableType",{enumerable:!0,get:function get(){return _types.VariableType}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function get(){return _utilities.VisitorDataFiltersType}});var _tsRes=require("ts-res"),_kameleoonClient=require("./kameleoonClient"),_kameleoonUtils=require("./kameleoonUtils"),_kameleoonError=require("./kameleoonError"),_utilities=require("./utilities"),_storage=require("./storage"),_constants=require("./constants"),_clientConfiguration=require("./clientConfiguration"),_types=require("./types"),_kameleoonData=require("./kameleoonData"),_eventSource=require("./eventSource"),_requester=require("./requester");
//# sourceMappingURL=index.js.map

@@ -1,4 +0,4 @@

import { JSONType } from './campaignConfiguration';
import { JSONType } from './clientConfiguration';
import { CustomData, KameleoonDataType } from './kameleoonData';
import { TrackConversionParamsType, ExperimentType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, GetVisitorWarehouseAudienceParamsType } from './types';
import { TrackConversionParamsType, FeatureFlagType, GetFeatureFlagVariableParamsType, FeatureVariableResultType, SDKCoreParameters, RemoteVisitorDataParamsType, GetVisitorWarehouseAudienceParamsType } from './types';
/**

@@ -30,9 +30,8 @@ * @interface an interface of KameleoonClient instance

* - `KameleoonException.StorageWrite` Couldn't update storage data
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
*/
addData: (visitorCode: string, ...data: KameleoonDataType[]) => void;
/**
* @method getRemoteVisitorData - an asynchronous method for retrieving custom data for the latest visit of `visitorCode` from Kameleoon Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
* @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
* @method getRemoteVisitorData - an asynchronous method for retrieving KameleoonData from Data API and optionally adding it to the storage so that other methods could decide whether the current visitor is targeted or not.
* @param {RemoteVisitorDataParamsType} remoteVisitorDataParameters - `visitorCode`, `shouldAddData` and `filters` parameters
* @returns {KameleoonDataType[]} promise resolved to an array of `KameleoonData` instances, only includes custom data

@@ -44,22 +43,7 @@ * @throws `KameleoonError` with one of the following `type` s:

* - `KameleoonException.RemoteData` - Couldn't retrieve data from Kameleoon server
* - `KameleoonException.VisitAmount` - Visit amount must be a number between 1 and 25
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
*/
getRemoteVisitorData: (visitorCode: string, shouldAddData?: boolean) => Promise<KameleoonDataType[]>;
getRemoteVisitorData: ({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType) => Promise<KameleoonDataType[]>;
/**
* @method triggerExperiment - triggers experiment by assigning the variation to the user with `visitorCode`, if the variation is already assigned just returns it's id. Note: returned id `0` indicates default variation. At the same time sends tracking request.
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
* @param {number} experimentId - id of experiment running for the current visitor
* @returns {number} associated variationId which is successfully searched/assigned
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.ExperimentConfigurationNotFound` No configuration found for provided `experimentId`
* - `KameleoonException.VisitorCodeMaxLength` The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.StorageRead` Couldn't find associated experiment by provided `experimentId` and `visitorCode` inside the storage
* - `KameleoonException.NotTargeted` Current visitor is not targeted
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
*/
triggerExperiment: (visitorCode: string, experimentId: number) => number;
/**
* @method trackConversion - creates and adds `Conversion` data to the visitor with specified parameters and executes `flush`. Note: it's a helper method for the quick and convenient conversion tracking, however creating and adding `Conversion` manually allows more flexible `Conversion` with `negative` parameter

@@ -79,3 +63,3 @@ * @param {TrackConversionParamsType} conversionParameters - `visitorCode`, `goalId` and `revenue` parameters for data tracking

* then data for all visitors is sent and removed from `KameleoonClient` instance. Moreover, regardless of visitor code input
* the method first attemps to send all previously failed tracking requests which were stored locally during the offline mode.
* the method first attempts to send all previously failed tracking requests which were stored locally during the offline mode.
* @param {string | undefined} visitorCode - unique visitor identification string, can't exceed 255 characters length

@@ -87,40 +71,6 @@ * @returns {void}

* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
*/
flush: (visitorCode: string) => void;
/**
* @deprecated Use flush method instead.
*/
flushData: (visitorCode: string) => void;
/**
* @method getExperiments - returns a list of experiments stored in the client configuration
* @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
*/
getExperiments: () => ExperimentType[];
/**
* @method getVisitorExperiments - returns a list of experiments that the visitor with `visitorCode` is targeted by and that are *active* for the visitor (visitor will have one of the variations allocated if the experiment will be triggered).
* @param {string} visitorCode - unique visitor identification string, can't exceed 255 characters length
* @param {boolean | undefined} isAllocated - boolean value indicating that only experiments *allocated* for visitor will be returned. Default value is `true`
* @returns {ExperimentType[]} a list of all experiments items with `id` and `name` fields
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
*/
getVisitorExperiments: (visitorCode: string, isAllocated?: boolean) => ExperimentType[];
/**
* @method getExperimentVariationData - returns variation data in JSON format for the variation with `variationId`
* @param {number} variationId - id of variation
* @returns {JSONType} variation data in JSON format
* @throws `KameleoonError` with one of the following `type` s:
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.JSONParse` - Couldn't pass JSON value
* - `KameleoonException.VariationNotFound` - No variation found for provided `variationId`
*/
getExperimentVariationData: (variationId: number) => JSONType | null;
/**
* @method getFeatureFlags - returns a list of feature flags stored in the client configuration

@@ -130,3 +80,3 @@ * @returns {FeatureFlagType[]} a list of all feature flags items with `id` and `key` fields

*
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
*/

@@ -143,2 +93,3 @@ getFeatureFlags: () => FeatureFlagType[];

* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.StorageRead` - Couldn't read storage data
* - `KameleoonException.NotTargeted` - Current visitor is not targeted

@@ -156,4 +107,4 @@ */

* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
* - `KameleoonException.DataInconsistency` - Allocated variation was found but there is no feature flag with according `featureKey`.

@@ -172,4 +123,4 @@ * - `KameleoonException.NotTargeted` - Current visitor is not targeted

* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
* - `KameleoonException.NotTargeted` - Current visitor is not targeted

@@ -181,3 +132,3 @@ */

* @param {GetFeatureFlagVariableParamsType} parameters - an object with parameters of a type `GetFeatureFlagVariableParamsType`, see the type for details.
* @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields, `type` can be checked against `FeatureVariableType` enum, if the `type` is `FeatureVariableType.BOOLEAN` then the `value` type will be `boolean` and so on.
* @returns {FeatureVariableResultType} a variable object containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
* @throws `KameleoonError` with one of the following `type` s:

@@ -187,11 +138,27 @@ *

* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `visitorCode` and `featureKey`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
* - `KameleoonException.FeatureFlagVariableNotFound` - No feature variable was found for provided `visitorCode` and `variableKey`
* - `KameleoonException.NotTargeted` - Current visitor is not targeted
* - `KameleoonException.JSONParse` - Couldn't pass JSON value
* - `KameleoonException.NumberParse` - Couldn't pass Number value
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
* - `KameleoonException.NumberParse` - Couldn't parse Number value
*/
getFeatureFlagVariable: ({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType) => FeatureVariableResultType;
/**
* @method getFeatureFlagVariables - returns a list of variables for the visitor under `visitorCode` in the found feature flag, this method includes targeting check, finding the according variation exposed to the visitor and saving it to storage along with sending tracking request
* @param {string} visitorCode - a unique visitor identifier, shouldn't exceed 255 characters
* @param {string} featureKey - a unique key for feature flag
* @returns {FeatureVariableResultType[]} a list of variable objects containing `type` and `value` fields. You can check the `type` field against `FeatureVariableType` enum. For example, if the `type` is `FeatureVariableType.BOOLEAN` then `value` will be a `boolean` type.
* @throws `KameleoonError` with one of the following `type` s:
*
* - `KameleoonException.VisitorCodeMaxLength` - The visitor code length was exceeded
* - `KameleoonException.VisitorCodeEmpty` The visitor code is empty
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
* - `KameleoonException.FeatureFlagConfigurationNotFound` - No feature flag was found for provided `featureKey`
* - `KameleoonException.FeatureFlagVariationNotFound` - No feature variation was found for provided `visitorCode` and `variationKey`
* - `KameleoonException.JSONParse` - Couldn't parse JSON value
* - `KameleoonException.NumberParse` - Couldn't parse Number value
*/
getFeatureFlagVariables: (visitorCode: string, featureKey: string) => FeatureVariableResultType[];
/**
* @method getRemoteData - returns a data which is stored for specified siteCode on a remote Kameleoon server.

@@ -235,3 +202,3 @@ * @param {string} key - unique key that the data you try to get is associated with.

*
* - `KameleoonException.Initialization` - Method was executed before `initialize` was done for `kameleoonClient`
* - `KameleoonException.Initialization` - Method was executed before the `kameleoonClient` completed it's `initialize` call
*/

@@ -246,5 +213,5 @@ onConfigurationUpdate: (callback: () => void) => void;

export declare class KameleoonClient implements IKameleoonClient {
private variationConfiguration?;
private campaignConfiguration;
private variationDataStorage;
private variationConfiguration;
private clientConfiguration;
private dataManager;
private offlineTrackingStorage;

@@ -255,2 +222,3 @@ private trackingCache;

private isOfflineModeOn?;
private initialized;
/**

@@ -262,10 +230,5 @@ * @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core

addData(visitorCode: string, ...data: KameleoonDataType[]): void;
getRemoteVisitorData(visitorCode: string, shouldAddData?: boolean): Promise<KameleoonDataType[]>;
triggerExperiment(visitorCode: string, experimentId: number): number;
getRemoteVisitorData({ visitorCode, shouldAddData, filters, }: RemoteVisitorDataParamsType): Promise<KameleoonDataType[]>;
trackConversion({ visitorCode, goalId, revenue, }: TrackConversionParamsType): void;
flush(visitorCode?: string): void;
flushData(visitorCode?: string): void;
getExperiments(): ExperimentType[];
getVisitorExperiments(visitorCode: string, isActive?: boolean): ExperimentType[];
getExperimentVariationData(variationId: number): JSONType;
getFeatureFlags(): FeatureFlagType[];

@@ -275,2 +238,3 @@ getVisitorFeatureFlags(visitorCode: string): FeatureFlagType[];

getFeatureFlagVariable({ visitorCode, featureKey, variableKey, }: GetFeatureFlagVariableParamsType): FeatureVariableResultType;
getFeatureFlagVariables(visitorCode: string, featureKey: string): FeatureVariableResultType[];
isFeatureFlagActive(visitorCode: string, featureKey: string): boolean;

@@ -277,0 +241,0 @@ getRemoteData(key: string): Promise<JSONType>;

@@ -1,19 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_campaignConfiguration=require("./campaignConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* KameleoonClient - a class for creating kameleoon client instance
* for communicating with Kameleoon JavaScript SDK Core, when new instance is created
*/var KameleoonClient=/*#__PURE__*/function(){/**
* @param {SDKCoreParameters} sdkCoreParameters - parameters for initializing sdk core
*/function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"campaignConfiguration",void 0),_defineProperty(this,"variationDataStorage",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0);var f=new _clientSettings.ClientSettings(c,d),g=f.settings,h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalRequestDispatcher,l=e.externalClientConfiguration,m=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:k}),n=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),o=h.initialize(_storage.KameleoonStorageKey.ClientData),p=h.initialize(_storage.KameleoonStorageKey.VariationData),q=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),r=new _campaignConfiguration.CampaignConfiguration({settings:g,storage:o,requester:m,externalClientConfiguration:l,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval,offlineTrackingStorage:q,externalEventSource:i});this.requester=m,this.trackingCache=n,this.campaignConfiguration=r,this.variationDataStorage=p,this.externalPackageInfo=j,this.offlineTrackingStorage=q}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.campaignConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),d=new _variationConfiguration.VariationConfiguration(this.campaignConfiguration.experiments,this.variationDataStorage),this.variationConfiguration=d,this.isOfflineModeOn=a,b.abrupt("return",c.ok);case 8:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.campaignConfiguration).addTargetingData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j=arguments;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=!(1<j.length&&void 0!==j[1])||j[1],b.next=3,this.requester.getVisitorData(a);case 3:d=b.sent,e=d.throw(),f=_utilities.Utilities.parseVisitorData(e),g=_createForOfIteratorHelper(f);try{for(g.s();!(h=g.n()).done;)i=h.value,(c||this.campaignConfiguration.isPersistentCustomData(i))&&this.addData(a,i)}catch(a){g.e(a)}finally{g.f()}return b.abrupt("return",f);case 9:case"end":return b.stop();}},b,this)}));return a}()},{key:"triggerExperiment",value:function triggerExperiment(a,b){var c=this;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.campaignConfiguration||!this.variationConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var d=this.campaignConfiguration.experiments.find(function(a){return a.id===b+""});if(!d)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.ExperimentConfigurationNotFound,b,a);var e=this.campaignConfiguration.storedTargetingData[a],f=_constants.UNALLOCATED_VARIATION_ID,g=_utilities.Utilities.checkTargeting({visitorCode:a,experimentId:b,targetingData:e,segment:d.segment,campaignConfiguration:this.campaignConfiguration,variationConfiguration:this.variationConfiguration,packageInfo:this.externalPackageInfo}).throw();if(f=this.variationConfiguration.getAssociatedVariationId(a,b).else(function(d){if(d.type===_kameleoonError.KameleoonException.NotAllocated)return _utilities.Utilities.trackExperiment({requester:c.requester,campaignConfiguration:c.campaignConfiguration,isUnallocated:!0,variationId:f,visitorCode:a,experimentId:b,isOfflineModeOn:c.isOfflineModeOn,offlineTrackingStorage:c.offlineTrackingStorage}),_constants.UNALLOCATED_VARIATION_ID;throw d}),_utilities.Utilities.trackExperiment({requester:this.requester,campaignConfiguration:this.campaignConfiguration,isUnallocated:!1,variationId:f,visitorCode:a,experimentId:b,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage}),!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NotTargeted,a);return _utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:b,variationId:f}),f}},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,campaignConfiguration:this.campaignConfiguration,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage});// --- Note ---
// `Utilities.trackData` executes `Utilities.sendOfflineTracking` asynchronously at first, but
// we need to execute `Utilities.sendOfflineTracking` even if calling `Utilities.trackData` is skipped
// due to lack of unsent data
if(!this.campaignConfiguration.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.campaignConfiguration.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,campaignConfiguration:this.campaignConfiguration,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"flushData",value:function flushData(a){this.flush(a)}},{key:"getExperiments",value:function getExperiments(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.experiments.map(function(a){var b=a.id,c=a.name;return{id:+b,name:c}})}},{key:"getVisitorExperiments",value:function getVisitorExperiments(a){var b=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c,d=this.campaignConfiguration.experiments,e=[],f=this.campaignConfiguration.storedTargetingData[a],g=_createForOfIteratorHelper(d);try{for(g.s();!(c=g.n()).done;){var h=c.value,i=h.id,j=h.name,k=h.segment,l=_utilities.Utilities.checkTargeting({targetingData:f,visitorCode:a,segment:k,variationConfiguration:this.variationConfiguration,campaignConfiguration:this.campaignConfiguration,experimentId:+i,packageInfo:this.externalPackageInfo}).throw();if(l){// -- If `isActive=false` then return every experiment
if(!b){e.push({id:+i,name:j});continue}// -- Else first check if there are saved variations for the experiment
// if there is at least one than it's active
var m=this.variationConfiguration.getAssignedVariations(a);if(m.ok){var n=m.data[h.id];if(n){e.push({id:+i,name:j});continue}}// -- Second check if the experiment will have an allocated variation upon triggering
// if yes than it's active
var o=this.variationConfiguration.getExperimentVariation(a,h);o.ok&&e.push({id:+i,name:j})}}}catch(a){g.e(a)}finally{g.f()}return e}},{key:"getExperimentVariationData",value:function getExperimentVariationData(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.campaignConfiguration.experiments,d=_createForOfIteratorHelper(c);try{for(d.s();!(b=d.n()).done;){var e=b.value,f=e.variations.find(function(b){return b.id===a+""});if(f)try{return JSON.parse(f.customJson)}catch(a){throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a)}}}catch(a){d.e(a)}finally{d.f()}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VariationNotFound)}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.campaignConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.variationConfiguration||!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.campaignConfiguration.featureFlags,d=[],e=this.campaignConfiguration.storedTargetingData[a],f=_createForOfIteratorHelper(c);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=this.variationConfiguration.getFeatureFlagVariation({visitorCode:a,targetingData:e,featureFlag:g,campaignConfiguration:this.campaignConfiguration,packageInfo:this.externalPackageInfo}).throw();if(h.variationKey!==_constants.OFF_VARIATION_KEY){var i=h.featureFlagId,j=h.featureKey;d.push({id:i,key:j})}}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.campaignConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});// --- Note ---
// `_getFeatureFlagVariation` already checks `campaignConfiguration` initialization
if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d,c);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.campaignConfiguration.addTargetingData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.campaignConfiguration)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.campaignConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.variationConfiguration||!this.campaignConfiguration)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.campaignConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b,a));var e=this.campaignConfiguration.storedTargetingData[a],f=this.variationConfiguration.getFeatureFlagVariation({visitorCode:a,featureFlag:d,targetingData:e,withAssignment:!0,campaignConfiguration:this.campaignConfiguration,packageInfo:this.externalPackageInfo}).throw(),g=f.experimentId,h=f.variationId;return"number"==typeof h&&"number"==typeof g&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:g,variationId:h}),_utilities.Utilities.trackRule({visitorCode:a,requester:this.requester,featureFlagVariation:f,campaignConfiguration:this.campaignConfiguration,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(f)}}]),a}();exports.KameleoonClient=KameleoonClient;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonClient=void 0;var _tsRes=require("ts-res"),_cacheManager=require("./cacheManager"),_clientConfiguration=require("./clientConfiguration"),_clientSettings=require("./clientSettings"),_constants=require("./constants"),_kameleoonData=require("./kameleoonData"),_kameleoonError=require("./kameleoonError"),_requester=require("./requester"),_storage=require("./storage"),_utilities=require("./utilities"),_variationConfiguration=require("./variationConfiguration");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonClient=function(){function a(b){var c=b.siteCode,d=b.configuration,e=b.internalConfiguration;_classCallCheck(this,a),_defineProperty(this,"variationConfiguration",void 0),_defineProperty(this,"clientConfiguration",void 0),_defineProperty(this,"dataManager",void 0),_defineProperty(this,"offlineTrackingStorage",void 0),_defineProperty(this,"trackingCache",void 0),_defineProperty(this,"requester",void 0),_defineProperty(this,"externalPackageInfo",void 0),_defineProperty(this,"isOfflineModeOn",void 0),_defineProperty(this,"initialized",!1);var f=new _clientSettings.ClientSettings(c,d),g=f.settings,h=e.externalStorage,i=e.externalEventSource,j=e.externalPackageInfo,k=e.externalRequestDispatcher,l=e.externalClientConfiguration,m=new _requester.Requester({siteCode:c,environment:g.environment,packageInfo:j,requestDispatcher:k}),n=new _cacheManager.CacheManager(_constants.CACHE_CLEANUP_TIMEOUT),o=h.initialize(_storage.KameleoonStorageKey.ClientData),p=h.initialize(_storage.KameleoonStorageKey.TargetingData),q=h.initialize(_storage.KameleoonStorageKey.VariationData),r=h.initialize(_storage.KameleoonStorageKey.OfflineTracking),s=new _kameleoonData.DataManager({storage:p,targetingCleanupInterval:null===d||void 0===d?void 0:d.targetingDataCleanupInterval}),t=new _clientConfiguration.ClientConfiguration({settings:g,storage:o,dataManager:s,requester:m,externalClientConfiguration:l,offlineTrackingStorage:r,externalEventSource:i}),u=new _variationConfiguration.VariationConfiguration(q);this.variationConfiguration=u,this.requester=m,this.trackingCache=n,this.dataManager=s,this.clientConfiguration=t,this.externalPackageInfo=j,this.offlineTrackingStorage=r}return _createClass(a,[{key:"initialize",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.clientConfiguration.initialize(a);case 2:return c=b.sent,c.throw(),this.isOfflineModeOn=a,this.initialized=!0,b.abrupt("return",c.ok);case 7:case"end":return b.stop();}},b,this)}));return a}()},{key:"addData",value:function addData(a){var b;if(_utilities.Utilities.validateVisitorCode(a).throw(),!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];(b=this.dataManager).addData.apply(b,[a].concat(d)).throw()}},{key:"getRemoteVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.visitorCode,d=a.shouldAddData,e=void 0===d||d,f=a.filters,g=void 0===f?_constants.DEFAULT_VISITOR_DATA_FILTERS:f,this.initialized){b.next=3;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);case 3:if(_utilities.Utilities.validateVisitorCode(c).throw(),h=g.visitAmount,!("number"==typeof h&&(1>h||25<h))){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitAmount);case 7:return b.next=9,this.requester.getVisitorData(c,g);case 9:i=b.sent,j=i.throw(),k=_utilities.Utilities.parseVisitorData({data:j,filters:g,visitorCode:c,variationConfiguration:this.variationConfiguration}),l=_createForOfIteratorHelper(k);try{for(l.s();!(m=l.n()).done;)n=m.value,(e||this.dataManager.isPersistentCustomData(n))&&this.addData(c,n)}catch(a){l.e(a)}finally{l.f()}return b.abrupt("return",k);case 15:case"end":return b.stop();}},b,this)}));return a}()},{key:"trackConversion",value:function trackConversion(a){var b=a.visitorCode,c=a.goalId,d=a.revenue;this.addData(b,new _kameleoonData.Conversion({goalId:c,revenue:d})),this.flush(b)}},{key:"flush",value:function flush(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);if("string"==typeof a&&_utilities.Utilities.validateVisitorCode(a).throw(),a)return void _utilities.Utilities.trackData({visitorCode:a,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage});if(!this.dataManager.unsentDataVisitors.length)return void _utilities.Utilities.sendOfflineTracking({requester:this.requester,storage:this.offlineTrackingStorage});var b,c=_createForOfIteratorHelper(this.dataManager.unsentDataVisitors);try{for(c.s();!(b=c.n()).done;){var d=b.value;_utilities.Utilities.trackData({visitorCode:d,dataManager:this.dataManager,requester:this.requester,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage})}}catch(a){c.e(a)}finally{c.f()}}},{key:"getFeatureFlags",value:function getFeatureFlags(){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);return this.clientConfiguration.featureFlags.map(function(a){var b=a.id,c=a.featureKey;return{id:b,key:c}})}},{key:"getVisitorFeatureFlags",value:function getVisitorFeatureFlags(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);var b,c=this.clientConfiguration.featureFlags,d=[],e=this.dataManager.storedTargetingData[a],f=_createForOfIteratorHelper(c);try{for(f.s();!(b=f.n()).done;){var g=b.value,h=this.variationConfiguration.getVariation({visitorCode:a,targetingData:e,featureFlag:g,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw();if(h.variationKey!==_constants.OFF_VARIATION_KEY){var i=h.featureFlagId,j=h.featureKey;d.push({id:i,key:j})}}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"getFeatureFlagVariationKey",value:function getFeatureFlagVariationKey(a,b){_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey;return d}},{key:"getFeatureFlagVariable",value:function getFeatureFlagVariable(a){var b,c=a.visitorCode,d=a.featureKey,e=a.variableKey;_utilities.Utilities.validateVisitorCode(c).throw();var f=this._getFeatureFlagVariation(c,d).throw(),g=f.variationKey,h=this.clientConfiguration.featureFlags,i=h.find(function(a){return a.featureKey===d});if(!i)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,d);var j=null===(b=i.variations.find(function(a){return a.key===g}))||void 0===b?void 0:b.variables.find(function(a){return a.key===e});if(!j)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariableNotFound,e,c);var k=_utilities.Utilities.parseFeatureVariable(j).throw();return k}},{key:"getFeatureFlagVariables",value:function getFeatureFlagVariables(a,b){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);_utilities.Utilities.validateVisitorCode(a).throw();var c=this._getFeatureFlagVariation(a,b).throw(),d=c.variationKey,e=this.clientConfiguration.featureFlags,f=e.find(function(a){return a.featureKey===b});if(!f)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b);var g=f.variations.find(function(a){return a.key===d});if(!g)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagVariationNotFound,d,a);var h,i=[],j=_createForOfIteratorHelper(g.variables);try{for(j.s();!(h=j.n()).done;){var k=h.value,l=_utilities.Utilities.parseFeatureVariable(k).throw();i.push(l)}}catch(a){j.e(a)}finally{j.f()}return i}},{key:"isFeatureFlagActive",value:function isFeatureFlagActive(a,b){var c=this.getFeatureFlagVariationKey(a,b);return c!==_constants.OFF_VARIATION_KEY}},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c;return _regeneratorRuntime().wrap(function d(b){for(;1;)switch(b.prev=b.next){case 0:return b.next=2,this.requester.getRemoteData(a);case 2:return c=b.sent,b.abrupt("return",c.throw());case 4:case"end":return b.stop();}},b,this)}));return a}()},{key:"getVisitorWarehouseAudience",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g;return _regeneratorRuntime().wrap(function h(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.customDataIndex,e=a.warehouseKey,_utilities.Utilities.validateVisitorCode(c).throw(),b.next=4,this.getRemoteData(e||c);case 4:if(f=b.sent,f){b.next=7;break}throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.RemoteData);case 7:if(f[_constants.WAREHOUSE_AUDIENCE_KEY]&&0!==Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY]).length){b.next=9;break}return b.abrupt("return",null);case 9:return g=_construct(_kameleoonData.CustomData,[d].concat(_toConsumableArray(Object.keys(f[_constants.WAREHOUSE_AUDIENCE_KEY])))),this.dataManager.addData(c,g),b.abrupt("return",g);case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"onConfigurationUpdate",value:function onConfigurationUpdate(a){if(!this.initialized)throw new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization);this.clientConfiguration.onConfigurationUpdate(a)}},{key:"getEngineTrackingCode",value:function getEngineTrackingCode(a){return _utilities.Utilities.validateVisitorCode(a).throw(),_utilities.Utilities.getTrackingCode(this.trackingCache,a)}},{key:"_getFeatureFlagVariation",value:function _getFeatureFlagVariation(a,b){if(!this.initialized)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var c=this.clientConfiguration.featureFlags,d=c.find(function(a){return a.featureKey===b});if(!d)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.FeatureFlagConfigurationNotFound,b));var e=this.dataManager.storedTargetingData[a],f=this.variationConfiguration.getVariation({visitorCode:a,featureFlag:d,targetingData:e,withAssignment:!0,clientConfiguration:this.clientConfiguration,dataManager:this.dataManager,packageInfo:this.externalPackageInfo}).throw(),g=f.experimentId,h=f.variationId;return"number"==typeof h&&"number"==typeof g&&_utilities.Utilities.updateCache({cacheManager:this.trackingCache,visitorCode:a,experimentId:g,variationId:h}),_utilities.Utilities.trackFeatureExperiment({visitorCode:a,requester:this.requester,featureFlagVariation:f,dataManager:this.dataManager,isOfflineModeOn:this.isOfflineModeOn,offlineTrackingStorage:this.offlineTrackingStorage}),(0,_tsRes.Ok)(f)}}]),a}();exports.KameleoonClient=KameleoonClient;
//# sourceMappingURL=kameleoonClient.js.map

@@ -0,1 +1,2 @@

import { VisitType } from '../requester';
import { BrowserDataType, BrowserType, IKameleoonData } from './types';

@@ -8,4 +9,4 @@ /**

private browser;
private nonce;
private version?;
private sent;
/**

@@ -15,4 +16,6 @@ * @param {BrowserType} browser - one of the browser types available for data, if browser can not be found in a list, it can be marked as `BrowserType.Other`

* @example
* ```ts
* const browser = new Browser(BrowserType.Chrome, 86);
* const browser = new Browser(BrowserType.Safari, 14.1);
* ```
* */

@@ -28,2 +31,14 @@ constructor(browser: BrowserType, version?: number);

get data(): BrowserDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
/**
* @private
* @method _fromVisits - an internal method for creating an instance of Browser class from a list of visits
* @param {VisitType[]} visits - a list of visits
* @returns {Browser | undefined} an instance of Browser class or undefined if browser can not be found among visits
* */
static _fromVisits(visits: VisitType[]): Browser | undefined;
}

@@ -1,18 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* Browser - a class for creating an instance for browser of a certain type
* */var Browser=/*#__PURE__*/function(){/**
* @param {BrowserType} browser - one of the browser types available for data, if browser can not be found in a list, it can be marked as `BrowserType.Other`
* @param {number | undefined} version - version of the browser, floating point number represents major and minor version of the browser
* @example
* const browser = new Browser(BrowserType.Chrome, 86);
* const browser = new Browser(BrowserType.Safari, 14.1);
* */function a(b,c){_classCallCheck(this,a),_defineProperty(this,"browser",void 0),_defineProperty(this,"nonce",void 0),_defineProperty(this,"version",void 0),this.browser=b,this.version=c,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){// --- Note ---
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
// with no required data, we don't want send anything to tracking in that case
if(!this.browser)return"";var a=this.version?_requester.UrlParameter.BrowserVersion+this.version:"";return _requester.UrlEventType.StaticData+_requester.UrlParameter.BrowserIndex+_types.BrowserIndexMap[this.browser]+a+_requester.UrlParameter.Nonce+this.nonce}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{browser:this.browser,type:_types.KameleoonData.Browser,version:this.version,nonce:this.nonce}}}]),a}();exports.Browser=Browser;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Browser=void 0;var _requester=require("../requester"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Browser=function(){function a(b,c){_classCallCheck(this,a),_defineProperty(this,"browser",void 0),_defineProperty(this,"version",void 0),_defineProperty(this,"sent",void 0),this.browser=b,this.version=c,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){if(!this.browser)return"";var a=this.version?_requester.UrlParameter.BrowserVersion+this.version:"";return _requester.UrlEventType.StaticData+_requester.UrlParameter.Browser+this.browser+_requester.UrlParameter.BrowserIndex+_types.BrowserIndexMap[this.browser]+a}},{key:"data",get:function get(){return{browser:this.browser,type:_types.KameleoonData.Browser,version:this.version,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}}],[{key:"_fromVisits",value:function _fromVisits(b){for(var c,d={},e=b.length-1;0<=e;e--)if(c=b[e],!!c.staticDataEvent){var f=c.staticDataEvent.data,g=f.browser,h=f.browserIndex,j=f.browserVersion;(g||null!==h)&&(d={browserType:g,browserIndex:h,browserVersion:j})}var k=d,l=k.browserType,m=k.browserIndex,n=k.browserVersion;if(l||"number"==typeof m){var o=l?l:_types.BrowserTypeMap[m];return n?new a(o,n):new a(o)}}}]),a}();exports.Browser=Browser;
//# sourceMappingURL=browser.js.map

@@ -0,1 +1,2 @@

import { VisitType } from '../requester';
import { ConversionDataType, ConversionParametersType, IKameleoonData } from './types';

@@ -10,3 +11,3 @@ /**

private negative;
private nonce;
private sent;
/**

@@ -24,2 +25,14 @@ * @param {ConversionParametersType} conversionParameters - an object with conversion parameters

get data(): ConversionDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
/**
* @private
* @method _listFromVisits - an internal method for creating a list of Conversion instances
* @param {VisitType[]} visits - a list of visits
* @returns {Conversion[]} a list of Conversion instances
* */
static _listFromVisits(visits: VisitType[]): Conversion[];
}

@@ -1,14 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* Conversion - a class for creating an instance for conversion tracking
* */var Conversion=/*#__PURE__*/function(){/**
* @param {ConversionParametersType} conversionParameters - an object with conversion parameters
* */function a(b){var c=b.goalId,d=b.revenue,e=void 0===d?0:d,f=b.negative;_classCallCheck(this,a),_defineProperty(this,"goalId",void 0),_defineProperty(this,"revenue",void 0),_defineProperty(this,"negative",void 0),_defineProperty(this,"nonce",void 0),this.goalId=c,this.revenue=e,this.negative=void 0!==f&&f,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){// --- Note ---
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
// with no required data, we don't want send anything to tracking in that case
return this.goalId?_requester.UrlEventType.Conversion+_requester.UrlParameter.GoalId+(this.goalId+"")+_requester.UrlParameter.Revenue+(this.revenue+"")+_requester.UrlParameter.Negative+(this.negative+"")+_requester.UrlParameter.Nonce+this.nonce:""}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{goalId:this.goalId,revenue:this.revenue,negative:this.negative,type:_types.KameleoonData.Conversion,nonce:this.nonce}}}]),a}();exports.Conversion=Conversion;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Conversion=void 0;var _requester=require("../requester"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Conversion=function(){function a(b){var c=b.goalId,d=b.revenue,e=void 0===d?0:d,f=b.negative;_classCallCheck(this,a),_defineProperty(this,"goalId",void 0),_defineProperty(this,"revenue",void 0),_defineProperty(this,"negative",void 0),_defineProperty(this,"sent",void 0),this.goalId=c,this.revenue=e,this.negative=void 0!==f&&f,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){return this.goalId?_requester.UrlEventType.Conversion+_requester.UrlParameter.GoalId+(this.goalId+"")+_requester.UrlParameter.Revenue+(this.revenue+"")+_requester.UrlParameter.Negative+(this.negative+""):""}},{key:"data",get:function get(){return{goalId:this.goalId,revenue:this.revenue,negative:this.negative,type:_types.KameleoonData.Conversion,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}}],[{key:"_listFromVisits",value:function _listFromVisits(b){var c,d=[],e=new Map,f=_createForOfIteratorHelper(b);try{for(f.s();!(c=f.n()).done;){var g=c.value;if(g.conversionEvents){var h,i=g.conversionEvents,j=_createForOfIteratorHelper(i);try{for(j.s();!(h=j.n()).done;){var k=h.value,l=k.data.goalId;if(!e.has(l)){e.set(l,!0);var m=new a({goalId:l});m.isSent=!0,d.push(m)}}}catch(a){j.e(a)}finally{j.f()}}}}catch(a){f.e(a)}finally{f.f()}return d}}]),a}();exports.Conversion=Conversion;
//# sourceMappingURL=conversion.js.map

@@ -0,1 +1,2 @@

import { VisitType } from '../requester';
import { CustomDataType, IKameleoonData } from './types';

@@ -9,3 +10,3 @@ /**

private value;
private nonce;
private sent;
/**

@@ -34,2 +35,14 @@ * @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application

get data(): CustomDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
/**
* @private
* @method _listFromVisits - an internal method for creating a list of custom data from a list of visits
* @param {VisitType[]} visits - a list of visits
* @returns {CustomData[]} a list of custom data
* */
static _listFromVisits(visits: VisitType[]): CustomData[];
}

@@ -1,25 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* CustomData - a class for creating an instance for user's custom data
* */var CustomData=/*#__PURE__*/function(){/**
* @param {number} index - an index of custom data to be stored under in a state, an index of custom data can be specified in `Advanced Tools` section of Kameleoon Application
* @param {string[]} value - custom value to store under the specified id, value can be anything but has to be stringified to match the `string` type. *Note* value is variadic parameter and can be used as follows
* @example
* ```ts
* // - Single value
* const customData = new CustomData(0, 'value_1');
* // - Variadic number of values
* const customData = new CustomData(0, 'value_1', 'value_2', 'value_3');
* // - Array of values
* const values = ['value_1', 'value_2', 'value_3'];
* const customData = new CustomData(0, ...values);
* ```
* */function a(b){_classCallCheck(this,a),_defineProperty(this,"index",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"nonce",void 0),this.index=b;for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];this.value=d,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){// --- Note ---
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
// with no required data, we don't want send anything to tracking in that case
if("number"!=typeof this.index)return"";var a=_toConsumableArray(new Set(this.value)),b={};return a.forEach(function(a){b[a]=1}),Object.keys(b).length?_requester.UrlEventType.CustomData+_requester.UrlParameter.Index+this.index+_requester.UrlParameter.ValuesCountMap+encodeURIComponent(JSON.stringify(b))+_requester.UrlParameter.Overwrite+"true"+_requester.UrlParameter.Nonce+this.nonce:""}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{index:this.index,value:this.value,type:_types.KameleoonData.CustomData,nonce:this.nonce}}}]),a}();exports.CustomData=CustomData;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CustomData=void 0;var _requester=require("../requester"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var CustomData=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"index",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"sent",void 0),this.index=b;for(var c=arguments.length,d=Array(1<c?c-1:0),e=1;e<c;e++)d[e-1]=arguments[e];this.value=d,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){if("number"!=typeof this.index)return"";var a=_toConsumableArray(new Set(this.value)),b={};return a.forEach(function(a){b[a]=1}),Object.keys(b).length?_requester.UrlEventType.CustomData+_requester.UrlParameter.Index+this.index+_requester.UrlParameter.ValuesCountMap+encodeURIComponent(JSON.stringify(b))+_requester.UrlParameter.Overwrite+"true":""}},{key:"data",get:function get(){return{index:this.index,value:this.value,type:_types.KameleoonData.CustomData,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}}],[{key:"_listFromVisits",value:function _listFromVisits(b){for(var c,d=[],e=new Map,f=b.length-1;0<=f;f--)if(c=b[f],!!c.customDataEvents){var g,h=c.customDataEvents,j=_createForOfIteratorHelper(h);try{for(j.s();!(g=j.n()).done;){var k=g.value,l=k.data,m=l.index,n=l.valuesCountMap;e.set(m,Object.keys(n))}}catch(a){j.e(a)}finally{j.f()}}var o,p=_createForOfIteratorHelper(e);try{for(p.s();!(o=p.n()).done;){var q=_slicedToArray(o.value,2),r=q[0],s=q[1];d.push(_construct(a,[r].concat(_toConsumableArray(s))))}}catch(a){p.e(a)}finally{p.f()}return d}}]),a}();exports.CustomData=CustomData;
//# sourceMappingURL=customData.js.map

@@ -0,1 +1,2 @@

import { VisitType } from '../requester';
import { DeviceDataType, DeviceType, IKameleoonData } from './types';

@@ -8,3 +9,3 @@ /**

private device;
private nonce;
private sent;
/**

@@ -22,2 +23,14 @@ * @param {DeviceType} device - one of the available device types from `DeviceType` enum

get data(): DeviceDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
/**
* @private
* @method _fromVisits - an internal method for creating an instance of Device class from a list of visits
* @param {VisitType[]} visits - a list of visits
* @returns {Device | undefined} an instance of Device class or undefined if browser can not be found among visits
* */
static _fromVisits(visits: VisitType[]): Device | undefined;
}

@@ -1,14 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* Device - a class for creating an instance for device of a certain type
* */var Device=/*#__PURE__*/function(){/**
* @param {DeviceType} device - one of the available device types from `DeviceType` enum
* */function a(b){_classCallCheck(this,a),_defineProperty(this,"device",void 0),_defineProperty(this,"nonce",void 0),this.device=b,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){// --- Note ---
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
// with no required data, we don't want send anything to tracking in that case
return this.device?_requester.UrlEventType.StaticData+_requester.UrlParameter.DeviceType+this.device+_requester.UrlParameter.Nonce+this.nonce:""}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{device:this.device,type:_types.KameleoonData.Device,nonce:this.nonce}}}]),a}();exports.Device=Device;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Device=void 0;var _requester=require("../requester"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Device=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"device",void 0),_defineProperty(this,"sent",void 0),this.device=b,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){return this.device?_requester.UrlEventType.StaticData+_requester.UrlParameter.DeviceType+this.device:""}},{key:"data",get:function get(){return{device:this.device,type:_types.KameleoonData.Device,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}}],[{key:"_fromVisits",value:function _fromVisits(b){for(var c,d=void 0,e=b.length-1;0<=e;e--)if(c=b[e],!!c.staticDataEvent){var f=c.staticDataEvent.data.deviceType;f&&(d=f)}if(d)return new a(d)}}]),a}();exports.Device=Device;
//# sourceMappingURL=device.js.map

@@ -1,7 +0,14 @@

export { CustomData } from './customData';
export { Conversion } from './conversion';
export { Device } from './device';
export { Cookie } from './cookie';
export { Browser } from './browser';
export { PageView } from './pageView';
export { UserAgent } from './userAgent';
export { DeviceType, BrowserType, BrowserDataType, BrowserIndexMap, PageViewDataType, DeviceDataType, ConversionDataType, CustomDataType, KameleoonData, KameleoonDataType, KameleoonDataItemType, PageViewParametersType, ConversionParametersType, UserAgentDataType, } from './types';
export { CustomData } from './customData';
export { Conversion } from './conversion';
export { GeolocationData } from './geolocation';
export { OperatingSystem } from './operatingSystem';
export { ApplicationVersion } from './applicationVersion';
export { VisitsData } from './visitsData';
export { DEFAULT_CLEANUP_INTERVAL } from './constants';
export { DeviceType, CookieType, VisitsDataType, BrowserType, KameleoonData, DeviceDataType, CustomDataType, BrowserDataType, BrowserIndexMap, PageViewDataType, KameleoonDataType, UserAgentDataType, ConversionDataType, OperatingSystemType, GeolocationInfoType, KameleoonDataItemType, PageViewParametersType, ConversionParametersType, ApplicationVersionDataType, } from './types';
export { DataManager } from './dataManager';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _browser.Browser}}),Object.defineProperty(exports,"BrowserDataType",{enumerable:!0,get:function get(){return _types.BrowserDataType}}),Object.defineProperty(exports,"BrowserIndexMap",{enumerable:!0,get:function get(){return _types.BrowserIndexMap}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _types.BrowserType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _conversion.Conversion}}),Object.defineProperty(exports,"ConversionDataType",{enumerable:!0,get:function get(){return _types.ConversionDataType}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _types.ConversionParametersType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _customData.CustomData}}),Object.defineProperty(exports,"CustomDataType",{enumerable:!0,get:function get(){return _types.CustomDataType}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _device.Device}}),Object.defineProperty(exports,"DeviceDataType",{enumerable:!0,get:function get(){return _types.DeviceDataType}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _types.DeviceType}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _types.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataItemType",{enumerable:!0,get:function get(){return _types.KameleoonDataItemType}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _types.KameleoonDataType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _pageView.PageView}}),Object.defineProperty(exports,"PageViewDataType",{enumerable:!0,get:function get(){return _types.PageViewDataType}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _types.PageViewParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _userAgent.UserAgent}}),Object.defineProperty(exports,"UserAgentDataType",{enumerable:!0,get:function get(){return _types.UserAgentDataType}});var _customData=require("./customData"),_conversion=require("./conversion"),_device=require("./device"),_browser=require("./browser"),_pageView=require("./pageView"),_userAgent=require("./userAgent"),_types=require("./types");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _applicationVersion.ApplicationVersion}}),Object.defineProperty(exports,"ApplicationVersionDataType",{enumerable:!0,get:function get(){return _types.ApplicationVersionDataType}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _browser.Browser}}),Object.defineProperty(exports,"BrowserDataType",{enumerable:!0,get:function get(){return _types.BrowserDataType}}),Object.defineProperty(exports,"BrowserIndexMap",{enumerable:!0,get:function get(){return _types.BrowserIndexMap}}),Object.defineProperty(exports,"BrowserType",{enumerable:!0,get:function get(){return _types.BrowserType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _conversion.Conversion}}),Object.defineProperty(exports,"ConversionDataType",{enumerable:!0,get:function get(){return _types.ConversionDataType}}),Object.defineProperty(exports,"ConversionParametersType",{enumerable:!0,get:function get(){return _types.ConversionParametersType}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _cookie.Cookie}}),Object.defineProperty(exports,"CookieType",{enumerable:!0,get:function get(){return _types.CookieType}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _customData.CustomData}}),Object.defineProperty(exports,"CustomDataType",{enumerable:!0,get:function get(){return _types.CustomDataType}}),Object.defineProperty(exports,"DEFAULT_CLEANUP_INTERVAL",{enumerable:!0,get:function get(){return _constants.DEFAULT_CLEANUP_INTERVAL}}),Object.defineProperty(exports,"DataManager",{enumerable:!0,get:function get(){return _dataManager.DataManager}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _device.Device}}),Object.defineProperty(exports,"DeviceDataType",{enumerable:!0,get:function get(){return _types.DeviceDataType}}),Object.defineProperty(exports,"DeviceType",{enumerable:!0,get:function get(){return _types.DeviceType}}),Object.defineProperty(exports,"GeolocationData",{enumerable:!0,get:function get(){return _geolocation.GeolocationData}}),Object.defineProperty(exports,"GeolocationInfoType",{enumerable:!0,get:function get(){return _types.GeolocationInfoType}}),Object.defineProperty(exports,"KameleoonData",{enumerable:!0,get:function get(){return _types.KameleoonData}}),Object.defineProperty(exports,"KameleoonDataItemType",{enumerable:!0,get:function get(){return _types.KameleoonDataItemType}}),Object.defineProperty(exports,"KameleoonDataType",{enumerable:!0,get:function get(){return _types.KameleoonDataType}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _operatingSystem.OperatingSystem}}),Object.defineProperty(exports,"OperatingSystemType",{enumerable:!0,get:function get(){return _types.OperatingSystemType}}),Object.defineProperty(exports,"PageView",{enumerable:!0,get:function get(){return _pageView.PageView}}),Object.defineProperty(exports,"PageViewDataType",{enumerable:!0,get:function get(){return _types.PageViewDataType}}),Object.defineProperty(exports,"PageViewParametersType",{enumerable:!0,get:function get(){return _types.PageViewParametersType}}),Object.defineProperty(exports,"UserAgent",{enumerable:!0,get:function get(){return _userAgent.UserAgent}}),Object.defineProperty(exports,"UserAgentDataType",{enumerable:!0,get:function get(){return _types.UserAgentDataType}}),Object.defineProperty(exports,"VisitsData",{enumerable:!0,get:function get(){return _visitsData.VisitsData}}),Object.defineProperty(exports,"VisitsDataType",{enumerable:!0,get:function get(){return _types.VisitsDataType}});var _device=require("./device"),_cookie=require("./cookie"),_browser=require("./browser"),_pageView=require("./pageView"),_userAgent=require("./userAgent"),_customData=require("./customData"),_conversion=require("./conversion"),_geolocation=require("./geolocation"),_operatingSystem=require("./operatingSystem"),_applicationVersion=require("./applicationVersion"),_visitsData=require("./visitsData"),_constants=require("./constants"),_types=require("./types"),_dataManager=require("./dataManager");
//# sourceMappingURL=index.js.map

@@ -0,1 +1,2 @@

import { VisitType } from '../requester';
import { IKameleoonData, PageViewDataType, PageViewParametersType } from './types';

@@ -9,4 +10,5 @@ /**

private title;
private nonce;
private referrers?;
private sent;
private timestampList;
/**

@@ -24,2 +26,19 @@ * @param {PageViewParametersType} pageViewParameters - an object with page view parameters

get data(): PageViewDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
/**
* @property timestamps - a list of timestamps for the current data type
* */
get timestamps(): number[];
set timestamps(value: number[]);
/**
* @private
* @method _listFromVisits - an internal method for creating a list of page view data from a list of visits
* @param {VisitType[]} visits - a list of visits
* @returns {PageView[]} a list of PageView instances
* */
static _listFromVisits(visits: VisitType[]): PageView[];
}

@@ -1,14 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* PageView - a class for creating an instance of a page view data
* */var PageView=/*#__PURE__*/function(){/**
* @param {PageViewParametersType} pageViewParameters - an object with page view parameters
* */function a(b){var c=b.urlAddress,d=b.title,e=b.referrers;_classCallCheck(this,a),_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"nonce",void 0),_defineProperty(this,"referrers",void 0),this.urlAddress=c,this.title=d,this.referrers=e,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){var a;// --- Note ---
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
// with no required data, we don't want send anything to tracking in that case
if(!this.urlAddress)return"";var b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c+_requester.UrlParameter.Nonce+this.nonce}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types.KameleoonData.PageView,nonce:this.nonce}}}]),a}();exports.PageView=PageView;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PageView=void 0;var _requester=require("../requester"),_utilities=require("../utilities"),_types=require("../utilities/types"),_types2=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var PageView=function(){function a(b){var c=b.urlAddress,d=b.title,e=b.referrers;_classCallCheck(this,a),_defineProperty(this,"urlAddress",void 0),_defineProperty(this,"title",void 0),_defineProperty(this,"referrers",void 0),_defineProperty(this,"sent",void 0),_defineProperty(this,"timestampList",[]),this.urlAddress=c,this.title=d,this.referrers=e,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){var a;if(!this.urlAddress)return"";var b=this.title?_requester.UrlParameter.Title+encodeURIComponent(this.title):"",c=null!==(a=this.referrers)&&void 0!==a&&a.length?_requester.UrlParameter.ReferrersIndices+JSON.stringify(this.referrers):"";return _requester.UrlEventType.Page+_requester.UrlParameter.Href+encodeURIComponent(this.urlAddress)+b+c}},{key:"data",get:function get(){return{urlAddress:this.urlAddress,title:this.title,referrers:this.referrers,type:_types2.KameleoonData.PageView,sent:this.sent,timestamps:this.timestampList}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}},{key:"timestamps",get:function get(){return this.timestampList},set:function set(a){var b=this;this.timestampList.length?a.forEach(function(a){_utilities.Utilities.insertInOrderedListMutably({list:b.timestampList,element:a,order:_types.Order.Ascending})}):this.timestampList=a}}],[{key:"_listFromVisits",value:function _listFromVisits(b){for(var c,d=[],e=new Map,f=b.length-1;0<=f;f--)if(c=b[f],!!c.pageEvents){var g,h=c.pageEvents,j=_createForOfIteratorHelper(h);try{for(j.s();!(g=j.n()).done;){var k=g.value,l=[],m=k.time,n=k.data,o=n.href,p=n.title,q=n.referrersIndices;"number"==typeof q[0]&&(l=q);var r=void 0;if(e.has(o)){var s=e.get(o).timestamps;r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[].concat(_toConsumableArray(s),[m])}else r=new a({urlAddress:o,title:p,referrers:l}),r.timestamps=[m];e.set(o,r)}}catch(a){j.e(a)}finally{j.f()}}return e.forEach(function(a){a.isSent=!0,d.push(a)}),d}}]),a}();exports.PageView=PageView;
//# sourceMappingURL=pageView.js.map

@@ -1,3 +0,32 @@

import { Browser, Conversion, CustomData, Device, PageView, UserAgent } from './';
export type KameleoonDataItemType = BrowserDataType | ConversionDataType | CustomDataType | DeviceDataType | PageViewDataType | UserAgentDataType;
import { TargetingDataType } from '../targeting';
import { IExternalStorage } from '../storage';
import { Browser, Conversion, Cookie, CustomData, Device, GeolocationData, OperatingSystem, PageView, UserAgent, ApplicationVersion, VisitsData } from '../kameleoonData';
export type UnsentVisitorTargetingDataType = Map<KameleoonData | number, KameleoonDataType | KameleoonDataType[]>;
export type UnsentTargetingDataType = {
[visitorCode: string]: UnsentVisitorTargetingDataType | undefined;
};
export type FieldParametersType = {
visitorCode: string;
key: KameleoonData;
value: BrowserDataType | CookieDataType | DeviceDataType | GeolocationDataType | OperatingSystemDataType | UserAgentDataType | VisitsDataType;
data: TargetingDataType;
};
export type ArrayFieldParametersType = {
visitorCode: string;
key: KameleoonData;
value: ConversionDataType;
data: TargetingDataType;
};
export type NestedFieldParametersType = {
visitorCode: string;
key: KameleoonData.CustomData | KameleoonData.PageView;
nestedKey: string;
value: CustomDataType | PageViewDataType;
data: TargetingDataType;
};
export type DataManagerParametersType = {
targetingCleanupInterval?: number;
storage: IExternalStorage<TargetingDataType>;
};
export type KameleoonDataItemType = BrowserDataType | ConversionDataType | CustomDataType | DeviceDataType | PageViewDataType | UserAgentDataType | CookieDataType | GeolocationDataType | OperatingSystemDataType | ApplicationVersionDataType | VisitsDataType;
/**

@@ -11,2 +40,3 @@ * @interface an interface of KameleoonData

readonly data: KameleoonDataItemType;
isSent: boolean;
}

@@ -17,3 +47,3 @@ /**

* */
export type KameleoonDataType = Browser | Conversion | CustomData | Device | PageView | UserAgent;
export type KameleoonDataType = Browser | Conversion | CustomData | Device | PageView | UserAgent | VisitsData | GeolocationData | OperatingSystem | Cookie | ApplicationVersion;
export type ActivityTimePropertyType = {

@@ -23,12 +53,24 @@ lastActivityTime: number;

export type ExistingCustomDataType = NonNullable<KameleoonVisitorDataType[KameleoonData.CustomData]>;
export type ExistingPageViewDataType = NonNullable<KameleoonVisitorDataType[KameleoonData.PageView]>;
export type ExistingNestedDataType = ExistingCustomDataType | ExistingPageViewDataType;
export type ExistingArrayDataType = ExistingConversionDataType;
export type ExistingConversionDataType = NonNullable<KameleoonVisitorDataType[KameleoonData.Conversion]>;
export type ExistingVisitsDataType = NonNullable<KameleoonVisitorDataType[KameleoonData.VisitsData]>;
export type ExistingDataType<T extends KameleoonData> = NonNullable<KameleoonVisitorDataType[T]>;
export type KameleoonVisitorDataType<T = ActivityTimePropertyType> = {
[KameleoonData.CustomData]?: {
[index: number]: (CustomDataType & T) | undefined;
[index: string]: (CustomDataType & T) | undefined;
};
[KameleoonData.Conversion]?: ConversionDataType & T;
[KameleoonData.Conversion]?: (ConversionDataType & T)[];
[KameleoonData.GeolocationData]?: GeolocationDataType & T;
[KameleoonData.UserAgent]?: UserAgentDataType & T;
[KameleoonData.PageView]?: PageViewDataType & T;
[KameleoonData.PageView]?: {
[url: string]: PageViewDataType & T;
};
[KameleoonData.Browser]?: BrowserDataType & T;
[KameleoonData.Device]?: DeviceDataType & T;
[KameleoonData.Cookie]?: CookieDataType & T;
[KameleoonData.OperatingSystem]?: OperatingSystemDataType & T;
[KameleoonData.ApplicationVersion]?: ApplicationVersionDataType & T;
[KameleoonData.VisitsData]?: VisitsDataType & T;
};

@@ -38,10 +80,15 @@ export declare enum KameleoonData {

PageView = "pageView",
GeolocationData = "geolocation",
Browser = "browser",
Conversion = "conversion",
Cookie = "cookie",
Device = "device",
UserAgent = "userAgent"
OperatingSystem = "operatingSystem",
UserAgent = "userAgent",
ApplicationVersion = "applicationVersion",
VisitsData = "visitsData"
}
type SharedDataPropertiesType = {
type: KameleoonData;
nonce: string;
sent: boolean;
};

@@ -59,3 +106,3 @@ export type BrowserDataType = {

index: number;
value: string | string[];
value: string[];
} & SharedDataPropertiesType;

@@ -65,2 +112,13 @@ export type DeviceDataType = {

} & SharedDataPropertiesType;
export type VisitsDataType = {
previousVisits: number[];
currentVisit: number | null;
} & SharedDataPropertiesType;
export type OperatingSystemDataType = {
operatingSystem: OperatingSystemType;
} & SharedDataPropertiesType;
export type CookieDataType = {
cookie: CookieType[];
} & SharedDataPropertiesType;
export type GeolocationDataType = GeolocationInfoType & SharedDataPropertiesType;
export type PageViewDataType = {

@@ -70,2 +128,3 @@ urlAddress: string;

referrers?: number[];
timestamps: number[];
} & SharedDataPropertiesType;

@@ -75,2 +134,5 @@ export type UserAgentDataType = {

} & SharedDataPropertiesType;
export type ApplicationVersionDataType = {
version: string;
} & SharedDataPropertiesType;
/**

@@ -107,2 +169,39 @@ * @param {number} goalId - an id of a goal to track

* @readonly
* @enum {string} an Enum containing all possible variants for operating system type
* */
export declare enum OperatingSystemType {
WindowsPhone = "WINDOWS_PHONE",
Windows = "WINDOWS",
Android = "ANDROID",
Linux = "LINUX",
Mac = "MAC",
IOS = "IOS"
}
/**
* @param {string} country - a country of a visitor
* @param {string | undefined} region - an optional parameter containing a region of a visitor, has no default value
* @param {string | undefined} city - an optional parameter containing a city of a visitor, has no default value
* @param {string | undefined} postalCode - an optional parameter containing a postal code of a visitor, has no default value
* @param {[number, number] | undefined} coordinates - an optional parameter containing a pair of coordinates (longitude and latitude) of a visitor, has no default value. Coordinate `number` represents decimal degrees (double that can be negative)
* */
export type GeolocationInfoType = {
country: string;
region?: string;
city?: string;
postalCode?: string;
coordinates?: [number, number];
};
/**
* @param {string} key - a key of a cookie
* @param {string} value - a value of a cookie
* */
export type CookieType = {
key: string;
value: string;
};
export type OptionalCookieType = Omit<CookieType, 'key'> & {
key?: string;
};
/**
* @readonly
* @enum {string} an Enum containing all possible variants for browser type

@@ -118,2 +217,11 @@ * */

}
export declare const OperatingSystemIndexMap: {
readonly WINDOWS: 0;
readonly MAC: 1;
readonly IOS: 2;
readonly LINUX: 3;
readonly ANDROID: 4;
readonly WINDOWS_PHONE: 5;
};
export declare const OperatingSystemTypeMap: Record<number, OperatingSystemType>;
export declare const BrowserIndexMap: {

@@ -127,2 +235,3 @@ readonly CHROME: 0;

};
export declare const BrowserTypeMap: Record<number, BrowserType>;
export {};

@@ -1,15 +0,2 @@

"use strict";var _BrowserIndexMap;Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonData=exports.DeviceType=exports.BrowserType=exports.BrowserIndexMap=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @interface an interface of KameleoonData
* each class instance will have url getter method
* for handling url of different data types
* */ /**
* @type a tuple of each possible type of data for `addData` method
* of KameleoonClient
* */var KameleoonData=/*#__PURE__*/function(a){return a.CustomData="customData",a.PageView="pageView",a.Browser="browser",a.Conversion="conversion",a.Device="device",a.UserAgent="userAgent",a}({});exports.KameleoonData=KameleoonData;/**
* @readonly
* @enum {string} an Enum containing all possible variants for device type
* */var DeviceType=/*#__PURE__*/function(a){return a.Phone="PHONE",a.Tablet="TABLET",a.Desktop="DESKTOP",a}({});/**
* @readonly
* @enum {string} an Enum containing all possible variants for browser type
* */exports.DeviceType=DeviceType;var BrowserType=/*#__PURE__*/function(a){return a.Chrome="CHROME",a.InternetExplorer="IE",a.Firefox="FIREFOX",a.Safari="SAFARI",a.Opera="OPERA",a.Other="OTHER",a}({});exports.BrowserType=BrowserType;var BrowserIndexMap=(_BrowserIndexMap={},_defineProperty(_BrowserIndexMap,BrowserType.Chrome,0),_defineProperty(_BrowserIndexMap,BrowserType.InternetExplorer,1),_defineProperty(_BrowserIndexMap,BrowserType.Firefox,2),_defineProperty(_BrowserIndexMap,BrowserType.Safari,3),_defineProperty(_BrowserIndexMap,BrowserType.Opera,4),_defineProperty(_BrowserIndexMap,BrowserType.Other,5),_BrowserIndexMap);exports.BrowserIndexMap=BrowserIndexMap;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperatingSystemTypeMap=exports.OperatingSystemType=exports.OperatingSystemIndexMap=exports.KameleoonData=exports.DeviceType=exports.BrowserTypeMap=exports.BrowserType=exports.BrowserIndexMap=void 0;var _OperatingSystemIndex,_BrowserIndexMap,_helpers=require("./helpers");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonData=function(a){return a.CustomData="customData",a.PageView="pageView",a.GeolocationData="geolocation",a.Browser="browser",a.Conversion="conversion",a.Cookie="cookie",a.Device="device",a.OperatingSystem="operatingSystem",a.UserAgent="userAgent",a.ApplicationVersion="applicationVersion",a.VisitsData="visitsData",a}({});exports.KameleoonData=KameleoonData;var DeviceType=function(a){return a.Phone="PHONE",a.Tablet="TABLET",a.Desktop="DESKTOP",a}({});exports.DeviceType=DeviceType;var OperatingSystemType=function(a){return a.WindowsPhone="WINDOWS_PHONE",a.Windows="WINDOWS",a.Android="ANDROID",a.Linux="LINUX",a.Mac="MAC",a.IOS="IOS",a}({});exports.OperatingSystemType=OperatingSystemType;var BrowserType=function(a){return a.Chrome="CHROME",a.InternetExplorer="IE",a.Firefox="FIREFOX",a.Safari="SAFARI",a.Opera="OPERA",a.Other="OTHER",a}({});exports.BrowserType=BrowserType;var OperatingSystemIndexMap=(_OperatingSystemIndex={},_defineProperty(_OperatingSystemIndex,OperatingSystemType.Windows,0),_defineProperty(_OperatingSystemIndex,OperatingSystemType.Mac,1),_defineProperty(_OperatingSystemIndex,OperatingSystemType.IOS,2),_defineProperty(_OperatingSystemIndex,OperatingSystemType.Linux,3),_defineProperty(_OperatingSystemIndex,OperatingSystemType.Android,4),_defineProperty(_OperatingSystemIndex,OperatingSystemType.WindowsPhone,5),_OperatingSystemIndex);exports.OperatingSystemIndexMap=OperatingSystemIndexMap;var OperatingSystemTypeMap=(0,_helpers.constructTypeMap)(OperatingSystemIndexMap);exports.OperatingSystemTypeMap=OperatingSystemTypeMap;var BrowserIndexMap=(_BrowserIndexMap={},_defineProperty(_BrowserIndexMap,BrowserType.Chrome,0),_defineProperty(_BrowserIndexMap,BrowserType.InternetExplorer,1),_defineProperty(_BrowserIndexMap,BrowserType.Firefox,2),_defineProperty(_BrowserIndexMap,BrowserType.Safari,3),_defineProperty(_BrowserIndexMap,BrowserType.Opera,4),_defineProperty(_BrowserIndexMap,BrowserType.Other,5),_BrowserIndexMap);exports.BrowserIndexMap=BrowserIndexMap;var BrowserTypeMap=(0,_helpers.constructTypeMap)(BrowserIndexMap);exports.BrowserTypeMap=BrowserTypeMap;
//# sourceMappingURL=types.js.map

@@ -8,3 +8,3 @@ import { UserAgentDataType, IKameleoonData } from './types';

private value;
private nonce;
private sent;
constructor(value: string);

@@ -19,2 +19,7 @@ /**

get data(): UserAgentDataType;
/**
* @property isSent - signifying if the data was sent already tracked
* */
get isSent(): boolean;
set isSent(value: boolean);
}

@@ -1,9 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UserAgent=void 0;var _utilities=require("../utilities"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* UserAgent - a class for creating an instance for user agent
* */var UserAgent=/*#__PURE__*/function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"value",void 0),_defineProperty(this,"nonce",void 0),this.value=b,this.nonce=_utilities.Utilities.getNonce()}/**
* @property url - url for the current data type used for events tracking
* */return _createClass(a,[{key:"url",get:function get(){return""}/**
* @property data - data of the current class instance
* */},{key:"data",get:function get(){return{value:this.value,type:_types.KameleoonData.UserAgent,nonce:this.nonce}}}]),a}();exports.UserAgent=UserAgent;
"use strict";var _types=require("./types");Object.defineProperty(exports,"__esModule",{value:!0}),exports.UserAgent=void 0;function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var UserAgent=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"value",void 0),_defineProperty(this,"sent",void 0),this.value=b,this.sent=!1}return _createClass(a,[{key:"url",get:function get(){return""}},{key:"data",get:function get(){return{value:this.value,type:_types.KameleoonData.UserAgent,sent:this.sent}}},{key:"isSent",get:function get(){return this.sent},set:function set(a){this.sent=a}}]),a}();exports.UserAgent=UserAgent;
//# sourceMappingURL=userAgent.js.map
import { KameleoonStorageKey } from '../storage';
import { TargetingType } from '../targeting';
export declare const ERROR_MESSAGES: {
CookieParse: (reason: string) => string;
JSONParse: (err: unknown) => string;

@@ -9,10 +10,10 @@ NumberParse: (value: string) => string;

Initialization: () => string;
Credentials: () => string;
StorageInitialization: () => string;
EventSourceInitialization: () => string;
VariationNotFound: () => string;
FeatureFlagConfigurationNotFound: (featureKey: string, visitorCode: string) => string;
FeatureFlagConfigurationNotFound: (featureKey: string) => string;
FeatureFlagVariableNotFound: (variableKey: string, visitorCode: string) => string;
ExperimentConfigurationNotFound: (experimentId: number, visitorCode: string) => string;
FeatureFlagVariationNotFound: (variationKey: string, visitorCode: string) => string;
NotTargeted: (visitorCode: string) => string;
NotAllocated: (visitorCode: string) => string;
VisitAmount: () => string;
VisitorCodeMaxLength: () => string;

@@ -19,0 +20,0 @@ VisitorCodeEmpty: () => string;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;var _ERROR_MESSAGES,_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ERROR_MESSAGES=(_ERROR_MESSAGES={},_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.JSONParse,function(a){return"Couldn't parse JSON variable: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NumberParse,function(a){return"It's not possible to parse value ".concat(a," to Number")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.SemanticVersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Initialization,function(){return"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageInitialization,function(){return"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.EventSourceInitialization,function(){return"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VariationNotFound,function(){return"Couldn't find experiment variation"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagConfigurationNotFound,function(a,b){return"No feature flag with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariableNotFound,function(a,b){return"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.ExperimentConfigurationNotFound,function(a,b){return"No experiment with id ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NotTargeted,function(a){return"Visitor code ".concat(a," is not targeted")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NotAllocated,function(a){return"Visitor with visitor code ".concat(a," is in unallocated traffic, there is no variation id to be assigned to the visitor.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeMaxLength,function(){return"Visitor code can not be more than 255 characters long"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeEmpty,function(){return"Visitor code can not be empty"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageWrite,function(a){return"Couldn't update storage for kameleoonClient: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageRead,function(a){return"No data found in storage under ".concat(a," key")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageParse,function(a,b){return"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.ClientConfiguration,function(){return"Couldn't retrieve client configuration from Kameleoon Api"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.TargetingCondition,function(a){return"".concat(a," targeting condition is not yet supported.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.AmongValuesCheck,function(a,b){return"Couldn't parse value \"".concat(b,"\": ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.RemoteData,function(){return"Couldn't retrieve data from Kameleoon server"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.MaximumRetriesReached,function(){return"Maximum retries reached, request failed"}),_ERROR_MESSAGES);exports.ERROR_MESSAGES=ERROR_MESSAGES;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ERROR_MESSAGES=void 0;var _ERROR_MESSAGES,_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ERROR_MESSAGES=(_ERROR_MESSAGES={},_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.CookieParse,function(a){return"Couldn't parse cookie string: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.JSONParse,function(a){return"Couldn't parse JSON variable: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NumberParse,function(a){return"It's not possible to parse value ".concat(a," to Number")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.SemanticVersionParse,function(a){return"It's not possible to parse a version value ".concat(a," to Number, version should be in format x.x.x")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Initialization,function(){return"It seems that the client wasn't properly initialized, make sure to run `initialize` method before invoking other methods"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.Credentials,function(){return"KameleoonClient can not be created without credentials"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageInitialization,function(){return"There was an error while initializing React Native SDK storage, it seems that the storage library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.EventSourceInitialization,function(){return"There was an error while initializing Real Time Update service, it seems that the event source library dependency wasn't installed"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagConfigurationNotFound,function(a){return"No feature flag with key ".concat(a," was found.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariableNotFound,function(a,b){return"No feature flag variable with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.FeatureFlagVariationNotFound,function(a,b){return"No feature flag variation with key ".concat(a," was found for ").concat(b," visitorCode.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.NotTargeted,function(a){return"Visitor code ".concat(a," is not targeted")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitAmount,function(){return"Visit amount must be a number between 1 and 25"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeMaxLength,function(){return"Visitor code can not be more than 255 characters long"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.VisitorCodeEmpty,function(){return"Visitor code can not be empty"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageWrite,function(a){return"Couldn't update storage for kameleoonClient: ".concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageRead,function(a){return"No data found in storage under ".concat(a," key")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.StorageParse,function(a,b){return"Couldn't parse ".concat(b," storage data, the data may be corrupted. Error: ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.ClientConfiguration,function(){return"Couldn't retrieve client configuration from Kameleoon Api"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.TargetingCondition,function(a){return"".concat(a," targeting condition is not yet supported.")}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.AmongValuesCheck,function(a,b){return"Couldn't parse value \"".concat(b,"\": ").concat(a)}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.RemoteData,function(){return"Couldn't retrieve data from Kameleoon server"}),_defineProperty(_ERROR_MESSAGES,_types.KameleoonException.MaximumRetriesReached,function(){return"Maximum retries reached, request failed"}),_ERROR_MESSAGES);exports.ERROR_MESSAGES=ERROR_MESSAGES;
//# sourceMappingURL=constants.js.map

@@ -13,7 +13,8 @@ import { KameleoonStorageKey } from '../storage';

* */
constructor(type: KameleoonException.Initialization | KameleoonException.ClientConfiguration | KameleoonException.VisitorCodeMaxLength | KameleoonException.VisitorCodeEmpty | KameleoonException.StorageInitialization | KameleoonException.EventSourceInitialization | KameleoonException.VariationNotFound | KameleoonException.RemoteData | KameleoonException.MaximumRetriesReached);
constructor(type: KameleoonException.FeatureFlagConfigurationNotFound, featureKey: string, visitorCode: string);
constructor(type: KameleoonException.Initialization | KameleoonException.Credentials | KameleoonException.ClientConfiguration | KameleoonException.VisitorCodeMaxLength | KameleoonException.VisitorCodeEmpty | KameleoonException.VisitAmount | KameleoonException.StorageInitialization | KameleoonException.EventSourceInitialization | KameleoonException.RemoteData | KameleoonException.MaximumRetriesReached);
constructor(type: KameleoonException.FeatureFlagConfigurationNotFound, featureKey: string);
constructor(type: KameleoonException.FeatureFlagVariableNotFound, variableKey: string, visitorCode: string);
constructor(type: KameleoonException.NotTargeted | KameleoonException.NotAllocated, visitorCode: string);
constructor(type: KameleoonException.ExperimentConfigurationNotFound, experimentId: number, visitorCode: string);
constructor(type: KameleoonException.FeatureFlagVariationNotFound, variationKey: string, visitorCode: string);
constructor(type: KameleoonException.NotTargeted, visitorCode: string);
constructor(type: KameleoonException.CookieParse, message: string);
constructor(type: KameleoonException.StorageWrite | KameleoonException.JSONParse, err: unknown);

@@ -20,0 +21,0 @@ constructor(type: KameleoonException.StorageRead, storageKey: string);

@@ -1,5 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @class
* KameleoonError - extends standard `Error` by adding custom `type` property with the type of `KameleoonException`
* */var KameleoonError=/*#__PURE__*/function(a){function b(a,d,e){var f;return _classCallCheck(this,b),f=c.call(this,"Error: ".concat(a)),_defineProperty(_assertThisInitialized(f),"errorType",void 0),f.name="KameleoonError",f.errorType=a,(a===_types.KameleoonException.Initialization||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VariationNotFound||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached?f.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.NotAllocated||a===_types.KameleoonException.NotTargeted?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.ExperimentConfigurationNotFound?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.FeatureFlagVariableNotFound||a===_types.KameleoonException.FeatureFlagConfigurationNotFound?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageRead?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageParse?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.TargetingCondition?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.AmongValuesCheck?f.message=_constants.ERROR_MESSAGES[a](d,e):(0,_helpers.exhaustCheck)(a),f)}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"type",get:function get(){return this.errorType}}]),b}(/*#__PURE__*/_wrapNativeSuper(Error));exports.KameleoonError=KameleoonError;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonError=void 0;var _constants=require("./constants"),_helpers=require("./helpers"),_types=require("./types");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonError=function(a){function b(a,d,e){var f;return _classCallCheck(this,b),f=c.call(this,"Error: ".concat(a)),_defineProperty(_assertThisInitialized(f),"errorType",void 0),f.name="KameleoonError",f.errorType=a,(a===_types.KameleoonException.Initialization||a===_types.KameleoonException.Credentials||a===_types.KameleoonException.ClientConfiguration||a===_types.KameleoonException.VisitorCodeMaxLength||a===_types.KameleoonException.VisitorCodeEmpty||a===_types.KameleoonException.StorageInitialization||a===_types.KameleoonException.VisitAmount||a===_types.KameleoonException.EventSourceInitialization||a===_types.KameleoonException.RemoteData||a===_types.KameleoonException.MaximumRetriesReached?f.message=_constants.ERROR_MESSAGES[a]():a===_types.KameleoonException.CookieParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.NotTargeted?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.FeatureFlagConfigurationNotFound?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.FeatureFlagVariationNotFound||a===_types.KameleoonException.FeatureFlagVariableNotFound?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.StorageWrite||a===_types.KameleoonException.JSONParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageRead?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.StorageParse?f.message=_constants.ERROR_MESSAGES[a](d,e):a===_types.KameleoonException.TargetingCondition?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.NumberParse||a===_types.KameleoonException.VersionParse||a===_types.KameleoonException.SemanticVersionParse?f.message=_constants.ERROR_MESSAGES[a](d):a===_types.KameleoonException.AmongValuesCheck?f.message=_constants.ERROR_MESSAGES[a](d,e):(0,_helpers.exhaustCheck)(a),f)}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"type",get:function get(){return this.errorType}}]),b}(_wrapNativeSuper(Error));exports.KameleoonError=KameleoonError;
//# sourceMappingURL=kameleoonError.js.map

@@ -0,9 +1,13 @@

/**
* @readonly
* @enum {string} an Enum containing all possible variants of exception types `KameleoonError`
* */
export declare enum KameleoonException {
ExperimentConfigurationNotFound = "ExperimentConfigurationNotFound",
Credentials = "Credentials",
EventSourceInitialization = "EventSourceInitialization",
VariationNotFound = "VariationNotFound",
FeatureFlagConfigurationNotFound = "FeatureFlagConfigurationNotFound",
FeatureFlagVariableNotFound = "FeatureFlagVariableNotFound",
FeatureFlagVariationNotFound = "FeatureFlagVariationNotFound",
NotTargeted = "NotTargeted",
NotAllocated = "NotAllocated",
VisitAmount = "VisitAmount",
VisitorCodeMaxLength = "VisitorCodeMaxLength",

@@ -22,2 +26,3 @@ VisitorCodeEmpty = "VisitorCodeEmpty",

VersionParse = "VersionParse",
CookieParse = "CookieParse",
SemanticVersionParse = "SemanticVersionParse",

@@ -24,0 +29,0 @@ RemoteData = "RemoteData",

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;var KameleoonException=/*#__PURE__*/function(a){return a.ExperimentConfigurationNotFound="ExperimentConfigurationNotFound",a.EventSourceInitialization="EventSourceInitialization",a.VariationNotFound="VariationNotFound",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.NotTargeted="NotTargeted",a.NotAllocated="NotAllocated",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});exports.KameleoonException=KameleoonException;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonException=void 0;var KameleoonException=function(a){return a.Credentials="Credentials",a.EventSourceInitialization="EventSourceInitialization",a.FeatureFlagConfigurationNotFound="FeatureFlagConfigurationNotFound",a.FeatureFlagVariableNotFound="FeatureFlagVariableNotFound",a.FeatureFlagVariationNotFound="FeatureFlagVariationNotFound",a.NotTargeted="NotTargeted",a.VisitAmount="VisitAmount",a.VisitorCodeMaxLength="VisitorCodeMaxLength",a.VisitorCodeEmpty="VisitorCodeEmpty",a.StorageInitialization="StorageInitialization",a.StorageWrite="StorageWrite",a.StorageRead="StorageRead",a.StorageParse="StorageParse",a.ClientConfiguration="ClientConfiguration",a.TargetingCondition="TargetingCondition",a.AmongValuesCheck="AmongValuesCheck",a.Initialization="Initialization",a.JSONParse="JSONParse",a.NumberParse="NumberParse",a.VersionParse="VersionParse",a.CookieParse="CookieParse",a.SemanticVersionParse="SemanticVersionParse",a.RemoteData="RemoteData",a.MaximumRetriesReached="MaximumRetriesReached",a}({});exports.KameleoonException=KameleoonException;
//# sourceMappingURL=types.js.map

@@ -1,5 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;var _tsRes=require("ts-res"),_requester=require("./requester"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* @abstract
* KameleoonUtils - an abstract class for extending kameleoon utils with pre-defined method signatures
* */var KameleoonUtils=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"generateRandomString",value:function generateRandomString(a){var b="";if(0>a)return b;for(var c=0;c<a;c++)b+="abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())];return b}},{key:"getCookieVisitorCode",value:function getCookieVisitorCode(a){var b=a.split(_constants.Cookie.PairsDelimiter),c=b.find(function(a){var b=a.split(_constants.Cookie.KeyValueDelimiter),c=_slicedToArray(b,2),d=c[0],e=c[1];return d===_constants.KAMELEOON_COOKIE_KEY});if(c){var d=c.split(_constants.Cookie.KeyValueDelimiter),e=_slicedToArray(d,2),f=e[0],g=e[1];return(0,_tsRes.Ok)(g)}return(0,_tsRes.Err)()}},{key:"getResultCookie",value:function getResultCookie(a){var b=a.domain,c=a.visitorCode,d=[_constants.KAMELEOON_COOKIE_KEY+_constants.Cookie.KeyValueDelimiter+c,_constants.Cookie.MaxAge+_constants.Cookie.KeyValueDelimiter+31536000,_constants.Cookie.Path+_constants.Cookie.KeyValueDelimiter+"/",_constants.Cookie.Domain+_constants.Cookie.KeyValueDelimiter+b];return d.join(_constants.Cookie.PairsDelimiter)}},{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a){return _requester.URL.CLIENT_CONFIGURATION+_requester.UrlQuery.Mobile+a}}]),a}();exports.KameleoonUtils=KameleoonUtils;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonUtils=void 0;var _tsRes=require("ts-res"),_requester=require("./requester"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var KameleoonUtils=function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"generateRandomString",value:function generateRandomString(a){var b="";if(0>a)return b;for(var c=0;c<a;c++)b+="abcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(36*Math.random())];return b}},{key:"getCookieVisitorCode",value:function getCookieVisitorCode(a){var b=a.split(_constants.CookieParameter.PairsDelimiter),c=b.find(function(a){var b=a.split(_constants.CookieParameter.KeyValueDelimiter),c=_slicedToArray(b,2),d=c[0],e=c[1];return d===_constants.KAMELEOON_COOKIE_KEY});if(c){var d=c.split(_constants.CookieParameter.KeyValueDelimiter),e=_slicedToArray(d,2),f=e[0],g=e[1];return(0,_tsRes.Ok)(g)}return(0,_tsRes.Err)()}},{key:"getResultCookie",value:function getResultCookie(a){var b=a.domain,c=a.visitorCode,d=[_constants.KAMELEOON_COOKIE_KEY+_constants.CookieParameter.KeyValueDelimiter+c,_constants.CookieParameter.MaxAge+_constants.CookieParameter.KeyValueDelimiter+31536000,_constants.CookieParameter.Path+_constants.CookieParameter.KeyValueDelimiter+"/",_constants.CookieParameter.Domain+_constants.CookieParameter.KeyValueDelimiter+b];return d.join(_constants.CookieParameter.PairsDelimiter)}},{key:"getClientConfigurationUrl",value:function getClientConfigurationUrl(a){return _requester.URL.CLIENT_CONFIGURATION+_requester.UrlQuery.Mobile+a}}]),a}();exports.KameleoonUtils=KameleoonUtils;
//# sourceMappingURL=kameleoonUtils.js.map

@@ -5,3 +5,4 @@ import { EventType, ParameterType, QueryType, StrictEventTypeRecord, StrictParameterRecord, StrictQueryRecord, StrictTrackingRecord, TrackingType } from './types';

ContentType = "Content-Type",
Authorization = "Authorization"
Authorization = "Authorization",
AcceptEncoding = "Accept-Encoding"
}

@@ -8,0 +9,0 @@ export declare const UrlEventType: StrictEventTypeRecord<EventType>;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlEventType=exports.URL=exports.Header=void 0;var Header=/*#__PURE__*/function(a){return a.UserAgent="User-Agent",a.ContentType="Content-Type",a.Authorization="Authorization",a}({});exports.Header=Header;var topLevelDomain="com",dataTopLevelDomain="io",UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",Environment:"&environment=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"&currentVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits="};exports.UrlParameter=UrlParameter;var UrlQuery={Sse:"sse?siteCode=",Mobile:"mobile?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var URL_DATA_API="https://data.kameleoon.".concat(dataTopLevelDomain),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.".concat("com",":8110/"),CLIENT_CONFIGURATION:"https://client-config.kameleoon.".concat("com","/"),VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UrlTracking=exports.UrlQuery=exports.UrlParameter=exports.UrlEventType=exports.URL=exports.Header=void 0;var Header=function(a){return a.UserAgent="User-Agent",a.ContentType="Content-Type",a.Authorization="Authorization",a.AcceptEncoding="Accept-Encoding",a}({});exports.Header=Header;var topLevelDomain="com",dataTopLevelDomain="io",UrlEventType={CustomData:"eventType=customData",StaticData:"eventType=staticData",Page:"eventType=page",Conversion:"eventType=conversion",Activity:"eventType=activity",Experiment:"eventType=experiment",Geolocation:"eventType=geolocation"};exports.UrlEventType=UrlEventType;var UrlParameter={Title:"&title=",ReferrersIndices:"&referrersIndices=",Negative:"&negative=",Revenue:"&revenue=",Overwrite:"&overwrite=",Index:"&index=",BrowserIndex:"&browserIndex=",BrowserVersion:"&browserVersion=",Href:"&href=",DeviceType:"&deviceType=",SiteCode:"&siteCode=",GoalId:"&goalId=",VisitorCode:"&visitorCode=",Environment:"&environment=",VariationId:"&variationId=",Ts:"&ts=",Key:"&key=",SdkName:"&sdkName=",SdkVersion:"&sdkVersion=",ValuesCountMap:"&valuesCountMap=",Nonce:"&nonce=",Id:"&id=",CustomData:"&customData=",CurrentVisit:"&currentVisit=",MaxNumberPreviousVisits:"&maxNumberPreviousVisits=",Os:"&os=",OsIndex:"&osIndex=",Country:"&country=",City:"&city=",Region:"&region=",Latitude:"&latitude=",Longitude:"&longitude=",PostalCode:"&postalCode=",Conversion:"&conversion=",StaticData:"&staticData=",Geolocation:"&geolocation=",Page:"&page=",Experiment:"&experiment=",Browser:"&browser="};exports.UrlParameter=UrlParameter;var UrlQuery={Sse:"sse?siteCode=",Mobile:"mobile?siteCode=",Map:"map?siteCode=",Events:"events?siteCode=",Visitor:"visitor?siteCode="};exports.UrlQuery=UrlQuery;var UrlTracking={Visit:"visit/",Map:"map/"};exports.UrlTracking=UrlTracking;var URL_DATA_API="https://data.kameleoon.".concat(dataTopLevelDomain),URL={SERVER_SENT_EVENTS:"https://events.kameleoon.".concat("com",":8110/"),CLIENT_CONFIGURATION:"https://client-config.kameleoon.".concat("com","/"),VISIT_EVENT:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Events),VISIT_DATA:"".concat(URL_DATA_API,"/").concat(UrlTracking.Visit+UrlQuery.Visitor),DATA_MAP:"".concat(URL_DATA_API,"/").concat(UrlTracking.Map+UrlQuery.Map)};exports.URL=URL;
//# sourceMappingURL=constants.js.map
export { Requester } from './requester';
export { URL, UrlQuery, UrlEventType, UrlParameter, Header } from './constants';
export { HttpMethod, VisitType, TrackParametersType, TrackExperimentParamsType, TrackDataParamsType, IExternalRequestDispatcher, GetVisitorDataResultType, GetClientConfigurationResultType, } from './types';
export { HttpMethod, VisitType, TrackParametersType, StaticDataEventType, TrackExperimentParamsType, TrackDataParamsType, IExternalRequestDispatcher, GetVisitorDataResultType, GetClientConfigurationResultType, } from './types';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"GetClientConfigurationResultType",{enumerable:!0,get:function get(){return _types.GetClientConfigurationResultType}}),Object.defineProperty(exports,"GetVisitorDataResultType",{enumerable:!0,get:function get(){return _types.GetVisitorDataResultType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _constants.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _types.HttpMethod}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _types.IExternalRequestDispatcher}}),Object.defineProperty(exports,"Requester",{enumerable:!0,get:function get(){return _requester.Requester}}),Object.defineProperty(exports,"TrackDataParamsType",{enumerable:!0,get:function get(){return _types.TrackDataParamsType}}),Object.defineProperty(exports,"TrackExperimentParamsType",{enumerable:!0,get:function get(){return _types.TrackExperimentParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _types.TrackParametersType}}),Object.defineProperty(exports,"URL",{enumerable:!0,get:function get(){return _constants.URL}}),Object.defineProperty(exports,"UrlEventType",{enumerable:!0,get:function get(){return _constants.UrlEventType}}),Object.defineProperty(exports,"UrlParameter",{enumerable:!0,get:function get(){return _constants.UrlParameter}}),Object.defineProperty(exports,"UrlQuery",{enumerable:!0,get:function get(){return _constants.UrlQuery}}),Object.defineProperty(exports,"VisitType",{enumerable:!0,get:function get(){return _types.VisitType}});var _requester=require("./requester"),_constants=require("./constants"),_types=require("./types");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"GetClientConfigurationResultType",{enumerable:!0,get:function get(){return _types.GetClientConfigurationResultType}}),Object.defineProperty(exports,"GetVisitorDataResultType",{enumerable:!0,get:function get(){return _types.GetVisitorDataResultType}}),Object.defineProperty(exports,"Header",{enumerable:!0,get:function get(){return _constants.Header}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function get(){return _types.HttpMethod}}),Object.defineProperty(exports,"IExternalRequestDispatcher",{enumerable:!0,get:function get(){return _types.IExternalRequestDispatcher}}),Object.defineProperty(exports,"Requester",{enumerable:!0,get:function get(){return _requester.Requester}}),Object.defineProperty(exports,"StaticDataEventType",{enumerable:!0,get:function get(){return _types.StaticDataEventType}}),Object.defineProperty(exports,"TrackDataParamsType",{enumerable:!0,get:function get(){return _types.TrackDataParamsType}}),Object.defineProperty(exports,"TrackExperimentParamsType",{enumerable:!0,get:function get(){return _types.TrackExperimentParamsType}}),Object.defineProperty(exports,"TrackParametersType",{enumerable:!0,get:function get(){return _types.TrackParametersType}}),Object.defineProperty(exports,"URL",{enumerable:!0,get:function get(){return _constants.URL}}),Object.defineProperty(exports,"UrlEventType",{enumerable:!0,get:function get(){return _constants.UrlEventType}}),Object.defineProperty(exports,"UrlParameter",{enumerable:!0,get:function get(){return _constants.UrlParameter}}),Object.defineProperty(exports,"UrlQuery",{enumerable:!0,get:function get(){return _constants.UrlQuery}}),Object.defineProperty(exports,"VisitType",{enumerable:!0,get:function get(){return _types.VisitType}});var _requester=require("./requester"),_constants=require("./constants"),_types=require("./types");
//# sourceMappingURL=index.js.map
import { Result } from 'ts-res';
import { KameleoonError } from '../kameleoonError';
import { JSONType } from '../campaignConfiguration';
import { GetClientConfigurationResultType, RequesterParamsType, TrackDataParamsType, TrackExperimentParamsType, GetVisitorDataResultType } from './types';
import { JSONType } from '../clientConfiguration';
import { VisitorDataFiltersType } from '../utilities';
import { GetClientConfigurationResultType, RequesterParamsType, TrackDataParamsType, GetVisitorDataResultType, TrackExperimentParamsType } from './types';
export interface IRequester {
getClientConfiguration: () => Promise<Result<GetClientConfigurationResultType, KameleoonError>>;
getRemoteData: (key: string) => Promise<Result<JSONType, KameleoonError>>;
trackData: ({ visitorCode, body, }: TrackDataParamsType) => Promise<Result<boolean, KameleoonError>>;
trackExperiment: ({ variationId, visitorCode, experimentId, isUnallocated, body, }: TrackExperimentParamsType) => Promise<Result<boolean, KameleoonError>>;
trackData: ({ visitorCode, body, }: TrackDataParamsType) => Promise<Result<boolean, KameleoonError>>;
}

@@ -19,3 +20,3 @@ export declare class Requester implements IRequester {

getRemoteData(key: string): Promise<Result<JSONType, KameleoonError>>;
getVisitorData(visitorCode: string): Promise<Result<GetVisitorDataResultType, KameleoonError>>;
getVisitorData(visitorCode: string, filters: VisitorDataFiltersType): Promise<Result<GetVisitorDataResultType, KameleoonError>>;
trackExperiment({ variationId, visitorCode, experimentId, isUnallocated, body, userAgent, }: TrackExperimentParamsType): Promise<Result<boolean, KameleoonError>>;

@@ -22,0 +23,0 @@ trackData({ visitorCode, body, userAgent, }: TrackDataParamsType): Promise<Result<boolean, KameleoonError>>;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Requester=void 0;var _tsRes=require("ts-res"),_utilities=require("../utilities"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Requester=/*#__PURE__*/function(){function a(b){var c=b.siteCode,d=b.environment,e=b.packageInfo,f=b.requestDispatcher;_classCallCheck(this,a),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"requestDispatcher",void 0),_defineProperty(this,"packageInfo",void 0),this.requestDispatcher=f,this.siteCode=c,this.environment=d,this.packageInfo=e}return _createClass(a,[{key:"getClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:return c=this.environment?_constants.UrlParameter.Environment+this.environment:"",d=a?_constants.UrlParameter.Ts+a:"",e=_constants.URL.CLIENT_CONFIGURATION+_constants.UrlQuery.Mobile+this.siteCode+c+d,b.prev=3,b.next=6,this.requestDispatcher.getClientConfiguration(e);case 6:return f=b.sent,b.abrupt("return",(0,_tsRes.Ok)(f));case 10:return b.prev=10,b.t0=b["catch"](3),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 13:case"end":return b.stop();}},b,this,[[3,10]])}));return a}()},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=_constants.URL.DATA_MAP+this.siteCode+_constants.UrlParameter.Key+encodeURI(a),b.prev=1,b.next=4,this.requestDispatcher.getRemoteData(c);case 4:return d=b.sent,b.abrupt("return",(0,_tsRes.Ok)(d));case 8:return b.prev=8,b.t0=b["catch"](1),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 11:case"end":return b.stop();}},b,this,[[1,8]])}));return a}()},{key:"getVisitorData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=_constants.URL.VISIT_DATA+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.MaxNumberPreviousVisits+1+_constants.UrlParameter.CustomData+!0+_constants.UrlParameter.CurrentVisit+!0,b.prev=1,b.next=4,this.requestDispatcher.getRemoteData(c);case 4:return d=b.sent,b.abrupt("return",(0,_tsRes.Ok)(d));case 8:return b.prev=8,b.t0=b["catch"](1),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 11:case"end":return b.stop();}},b,this,[[1,8]])}));return a}()},{key:"trackExperiment",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.variationId,d=a.visitorCode,e=a.experimentId,f=a.isUnallocated,g=a.body,h=a.userAgent,i=this.getTrackingUrl(d),j=g?"":_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),k=f?j:_constants.UrlEventType.Experiment+_constants.UrlParameter.Id+e+_constants.UrlParameter.VariationId+c+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),l=k?g+"\n"+k:g,m=h?_defineProperty({},_constants.Header.UserAgent,h):void 0,b.prev=6,b.next=9,this.requestDispatcher.track({url:i,headers:m,body:l});case 9:return n=b.sent,b.abrupt("return",(0,_tsRes.Ok)(n));case 13:return b.prev=13,b.t0=b["catch"](6),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 16:case"end":return b.stop();}},b,this,[[6,13]])}));return a}()},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i;return _regeneratorRuntime().wrap(function j(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.body,e=a.userAgent,f=this.getTrackingUrl(c),g=e?_defineProperty({},_constants.Header.UserAgent,e):void 0,h=d||_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),b.prev=4,b.next=7,this.requestDispatcher.track({url:f,headers:g,body:h});case 7:return i=b.sent,b.abrupt("return",(0,_tsRes.Ok)(i));case 11:return b.prev=11,b.t0=b["catch"](4),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 14:case"end":return b.stop();}},b,this,[[4,11]])}));return a}()},{key:"getTrackingUrl",value:function getTrackingUrl(a){var b=this.packageInfo,c=b.type,d=b.version;return _constants.URL.VISIT_EVENT+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.SdkName+c.toLowerCase()+_constants.UrlParameter.SdkVersion+d}}]),a}();exports.Requester=Requester;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Requester=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_constants=require("./constants");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Requester=function(){function a(b){var c=b.siteCode,d=b.environment,e=b.packageInfo,f=b.requestDispatcher;_classCallCheck(this,a),_defineProperty(this,"siteCode",void 0),_defineProperty(this,"environment",void 0),_defineProperty(this,"requestDispatcher",void 0),_defineProperty(this,"packageInfo",void 0),this.requestDispatcher=f,this.siteCode=c,this.environment=d,this.packageInfo=e}return _createClass(a,[{key:"getClientConfiguration",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:return c=this.environment?_constants.UrlParameter.Environment+this.environment:"",d=a?_constants.UrlParameter.Ts+a:"",e=_constants.URL.CLIENT_CONFIGURATION+_constants.UrlQuery.Mobile+this.siteCode+c+d,b.prev=3,b.next=6,this.requestDispatcher.getClientConfiguration(e);case 6:if(f=b.sent,!f){b.next=9;break}return b.abrupt("return",(0,_tsRes.Ok)(f));case 9:return b.abrupt("return",(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.MaximumRetriesReached)));case 12:return b.prev=12,b.t0=b["catch"](3),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 15:case"end":return b.stop();}},b,this,[[3,12]])}));return a}()},{key:"getRemoteData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=_constants.URL.DATA_MAP+this.siteCode+_constants.UrlParameter.Key+encodeURI(a),b.prev=1,b.next=4,this.requestDispatcher.getRemoteData(c);case 4:return d=b.sent,b.abrupt("return",(0,_tsRes.Ok)(d));case 8:return b.prev=8,b.t0=b["catch"](1),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 11:case"end":return b.stop();}},b,this,[[1,8]])}));return a}()},{key:"getVisitorData",value:function(){function a(a,c){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function c(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;return _regeneratorRuntime().wrap(function u(c){for(;1;)switch(c.prev=c.next){case 0:return d=b.customData,e=b.visitAmount,f=b.conversions,g=b.geolocation,h=b.experiments,i=b.pageViews,j=b.device,k=b.browser,l=b.operatingSystem,m=d?_constants.UrlParameter.CustomData+!0:"",n=f?_constants.UrlParameter.Conversion+!0:"",o=g?_constants.UrlParameter.Geolocation+!0:"",p=h?_constants.UrlParameter.Experiment+!0:"",q=i?_constants.UrlParameter.Page+!0:"",r=j||k||l?_constants.UrlParameter.StaticData+!0:"",s=_constants.URL.VISIT_DATA+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.MaxNumberPreviousVisits+e+m+n+o+p+q+r+_constants.UrlParameter.CurrentVisit+!0,c.prev=8,c.next=11,this.requestDispatcher.getRemoteData(s);case 11:return t=c.sent,c.abrupt("return",(0,_tsRes.Ok)(t));case 15:return c.prev=15,c.t0=c["catch"](8),c.abrupt("return",(0,_tsRes.Err)(c.t0));case 18:case"end":return c.stop();}},c,this,[[8,15]])}));return a}()},{key:"trackExperiment",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.variationId,d=a.visitorCode,e=a.experimentId,f=a.isUnallocated,g=a.body,h=a.userAgent,i=this.getTrackingUrl(d),j=g?"":_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),k=f?j:_constants.UrlEventType.Experiment+_constants.UrlParameter.Id+e+_constants.UrlParameter.VariationId+c+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),l=k?g+"\n"+k:g,m=h?_defineProperty({},_constants.Header.UserAgent,h):void 0,b.prev=6,b.next=9,this.requestDispatcher.track({url:i,headers:m,body:l});case 9:return n=b.sent,b.abrupt("return",(0,_tsRes.Ok)(n));case 13:return b.prev=13,b.t0=b["catch"](6),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 16:case"end":return b.stop();}},b,this,[[6,13]])}));return a}()},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i;return _regeneratorRuntime().wrap(function j(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.body,e=a.userAgent,f=this.getTrackingUrl(c),g=e?_defineProperty({},_constants.Header.UserAgent,e):void 0,h=d||_constants.UrlEventType.Activity+_constants.UrlParameter.Nonce+_utilities.Utilities.getNonce(),b.prev=4,b.next=7,this.requestDispatcher.track({url:f,headers:g,body:h});case 7:return i=b.sent,b.abrupt("return",(0,_tsRes.Ok)(i));case 11:return b.prev=11,b.t0=b["catch"](4),b.abrupt("return",(0,_tsRes.Err)(b.t0));case 14:case"end":return b.stop();}},b,this,[[4,11]])}));return a}()},{key:"getTrackingUrl",value:function getTrackingUrl(a){var b=this.packageInfo,c=b.type,d=b.version;return _constants.URL.VISIT_EVENT+this.siteCode+_constants.UrlParameter.VisitorCode+a+_constants.UrlParameter.SdkName+c.toLowerCase()+_constants.UrlParameter.SdkVersion+d}}]),a}();exports.Requester=Requester;
//# sourceMappingURL=requester.js.map

@@ -1,4 +0,6 @@

import { JSONType, FeatureFlagType, ConfigurationDataType } from '../campaignConfiguration';
import { JSONType, FeatureFlagType, ConfigurationDataType } from '../clientConfiguration';
import { Environment, ExternalPackageInfoType } from '../types';
import { BrowserIndexMap, BrowserType, OperatingSystemType } from '../kameleoonData';
import { Header } from './constants';
import { DeviceType, OperatingSystemIndexMap } from '../kameleoonData/types';
export type RequesterParamsType = {

@@ -23,4 +25,4 @@ siteCode: string;

};
type CustomDataEventType = {
sdk: {
type EventDataType = {
sdk?: {
name: string;

@@ -31,2 +33,4 @@ version: string;

time: number;
};
type CustomDataEventType = {
data: {

@@ -40,10 +44,71 @@ index: number;

};
};
} & EventDataType;
type ExperimentEventType = {
data: {
id: number;
variationId: number;
};
} & EventDataType;
type ConversionEventType = {
data: {
goalId: number;
revenue: number;
negative: boolean;
};
} & EventDataType;
type BrowserIndexType = (typeof BrowserIndexMap)[BrowserType];
type OperatingSystemIndexType = (typeof OperatingSystemIndexMap)[OperatingSystemType];
export type PageEventType = {
data: {
href: string;
canonicalHref: string | null;
title: string;
keyPagesIndices: number[] | [null];
referrerHref: string | null;
referrersIndices: number[] | [null];
};
} & EventDataType;
export type GeolocationEventType = {
data: {
country: string;
region: string | null;
city: string | null;
postalCode: string | null;
latitude: number | null;
longitude: number | null;
};
} & EventDataType;
export type StaticDataEventType = {
data: {
visitNumber: number;
timeSincePreviousVisit: number;
firstReferrerHref: string | null;
browser: BrowserType | null;
browserIndex: BrowserIndexType | null;
browserVersion: number | null;
os: OperatingSystemType | null;
osIndex: OperatingSystemIndexType | null;
windowWidth: number | null;
windowHeight: number | null;
screenWidth: number | null;
screenHeight: number | null;
timeZoneId: string | null;
localeLanguageTag: string | null;
deviceType: DeviceType | null;
mappingIdentifier: string | null;
};
} & EventDataType;
export type VisitType = {
siteCode: string;
visitorCode: string;
customDataEvents: CustomDataEventType[];
timeStarted: number;
customDataEvents?: CustomDataEventType[];
experimentEvents?: ExperimentEventType[];
conversionEvents?: ConversionEventType[];
geolocationEvents?: GeolocationEventType[];
staticDataEvent?: StaticDataEventType;
pageEvents?: PageEventType[];
};
export type GetVisitorDataResultType = {
previousVisits?: [VisitType];
previousVisits?: VisitType[];
currentVisit?: VisitType;

@@ -58,4 +123,4 @@ };

}
declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "activity", "experiment"];
declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "environment", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "referrersIndices", "overwrite", "index", "href", "variationId", "deviceType", "goalId", "ts", "key"];
declare const EVENT_TYPE_KEYS: readonly ["customData", "staticData", "page", "conversion", "geolocation", "activity", "experiment"];
declare const PARAMETER_KEYS: readonly ["valuesCountMap", "id", "nonce", "country", "city", "region", "latitude", "geolocation", "longitude", "postalCode", "sdkName", "sdkVersion", "browserIndex", "browserVersion", "siteCode", "environment", "visitorCode", "currentVisit", "maxNumberPreviousVisits", "customData", "negative", "revenue", "title", "os", "conversion", "staticData", "osIndex", "browser", "referrersIndices", "overwrite", "index", "href", "experiment", "page", "variationId", "deviceType", "goalId", "ts", "key"];
declare const TRACKING_KEYS: readonly ["visit", "map"];

@@ -62,0 +127,0 @@ declare const QUERY_KEYS: readonly ["sse", "visitor", "mobile", "map", "events"];

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=/*#__PURE__*/function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","environment","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","referrersIndices","overwrite","index","href","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","mobile","map","events"];
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HttpMethod=void 0;var HttpMethod=function(a){return a.Get="GET",a.Post="POST",a}({});exports.HttpMethod=HttpMethod;var EVENT_TYPE_KEYS=["customData","staticData","page","conversion","geolocation","activity","experiment"],PARAMETER_KEYS=["valuesCountMap","id","nonce","country","city","region","latitude","geolocation","longitude","postalCode","sdkName","sdkVersion","browserIndex","browserVersion","siteCode","environment","visitorCode","currentVisit","maxNumberPreviousVisits","customData","negative","revenue","title","os","conversion","staticData","osIndex","browser","referrersIndices","overwrite","index","href","experiment","page","variationId","deviceType","goalId","ts","key"],TRACKING_KEYS=["visit","map"],QUERY_KEYS=["sse","visitor","mobile","map","events"];
//# sourceMappingURL=types.js.map

@@ -7,2 +7,3 @@ /**

ClientData = "kameleoonClientData",
TargetingData = "kameleoonTargetingData",
VariationData = "kameleoonVariationData",

@@ -9,0 +10,0 @@ VisitorCode = "kameleoonVisitorCode",

@@ -1,5 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonStorageKey=void 0;/**
* @readonly
* @enum {string} an Enum containing keys for Kameleoon SDK related data stored on storage
* */var KameleoonStorageKey=/*#__PURE__*/function(a){return a.ClientData="kameleoonClientData",a.VariationData="kameleoonVariationData",a.VisitorCode="kameleoonVisitorCode",a.OfflineTracking="kameleoonOfflineTracking",a}({});exports.KameleoonStorageKey=KameleoonStorageKey;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KameleoonStorageKey=void 0;var KameleoonStorageKey=function(a){return a.ClientData="kameleoonClientData",a.TargetingData="kameleoonTargetingData",a.VariationData="kameleoonVariationData",a.VisitorCode="kameleoonVisitorCode",a.OfflineTracking="kameleoonOfflineTracking",a}({});exports.KameleoonStorageKey=KameleoonStorageKey;
//# sourceMappingURL=constants.js.map
export { KameleoonStorageKey } from './constants';
export { ClientDataType, IExternalStorage, VariationDataType, StorageDataType, ExperimentVariationsType, IExternalStorageConstructor, } from './types';
export { ClientDataType, IExternalStorage, VariationDataType, StorageDataType, FeatureFlagVariationsType, IExternalStorageConstructor, } from './types';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientDataType",{enumerable:!0,get:function get(){return _types.ClientDataType}}),Object.defineProperty(exports,"ExperimentVariationsType",{enumerable:!0,get:function get(){return _types.ExperimentVariationsType}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _types.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _types.IExternalStorageConstructor}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _constants.KameleoonStorageKey}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _types.StorageDataType}}),Object.defineProperty(exports,"VariationDataType",{enumerable:!0,get:function get(){return _types.VariationDataType}});var _constants=require("./constants"),_types=require("./types");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ClientDataType",{enumerable:!0,get:function get(){return _types.ClientDataType}}),Object.defineProperty(exports,"FeatureFlagVariationsType",{enumerable:!0,get:function get(){return _types.FeatureFlagVariationsType}}),Object.defineProperty(exports,"IExternalStorage",{enumerable:!0,get:function get(){return _types.IExternalStorage}}),Object.defineProperty(exports,"IExternalStorageConstructor",{enumerable:!0,get:function get(){return _types.IExternalStorageConstructor}}),Object.defineProperty(exports,"KameleoonStorageKey",{enumerable:!0,get:function get(){return _constants.KameleoonStorageKey}}),Object.defineProperty(exports,"StorageDataType",{enumerable:!0,get:function get(){return _types.StorageDataType}}),Object.defineProperty(exports,"VariationDataType",{enumerable:!0,get:function get(){return _types.VariationDataType}});var _constants=require("./constants"),_types=require("./types");
//# sourceMappingURL=index.js.map
import { Result } from 'ts-res';
import { ConfigurationDataType } from '../campaignConfiguration';
import { ConfigurationDataType } from '../clientConfiguration';
import { KameleoonError } from '../kameleoonError';
import { VariationType } from '../variationConfiguration';
import { KameleoonStorageKey } from './constants';
import { TargetingDataType } from '../targeting';
import { TrackDataParamsType, TrackExperimentParamsType } from '../requester/types';
export type ClientDataType = {
kameleoonTargetingData: TargetingDataType;
kameleoonConfiguration: ConfigurationDataType;
data: ConfigurationDataType;
lastUpdate: string;
};
export type ExperimentVariationsType = {
[experimentId: string]: VariationType;
export type FeatureFlagVariationsType = {
[experimentId: string]: number;
};
export type VariationDataType = {
[visitorCode: string]: ExperimentVariationsType;
[visitorCode: string]: FeatureFlagVariationsType;
};

@@ -19,0 +16,0 @@ type OfflineTrackingParameters = TrackDataParamsType | TrackExperimentParamsType;

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browserCondition=require("./browserCondition"),_conversionCondition=require("./conversionCondition"),_customDataCondition=require("./customDataCondition"),_deviceCondition=require("./deviceCondition"),_exclusiveExperimentCondition=require("./exclusiveExperimentCondition"),_pageTitleCondition=require("./pageTitleCondition"),_pageUrlCondition=require("./pageUrlCondition"),_sdkLanguageCondition=require("./sdkLanguageCondition"),_targetExperimentCondition=require("./targetExperimentCondition"),_visitorCodeCondition=require("./visitorCodeCondition");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ConditionFactory=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"createCondition",value:function createCondition(a){var b=a.targetingType;return b===_types.TargetingType.CUSTOM_DATUM?(0,_tsRes.Ok)(new _customDataCondition.CustomDataCondition(a)):b===_types.TargetingType.EXCLUSIVE_EXPERIMENT?(0,_tsRes.Ok)(new _exclusiveExperimentCondition.ExclusiveExperimentCondition):b===_types.TargetingType.TARGET_EXPERIMENT?(0,_tsRes.Ok)(new _targetExperimentCondition.TargetExperimentCondition(a)):b===_types.TargetingType.DEVICE_TYPE?(0,_tsRes.Ok)(new _deviceCondition.DeviceCondition(a)):b===_types.TargetingType.BROWSER?(0,_tsRes.Ok)(new _browserCondition.BrowserCondition(a)):b===_types.TargetingType.PAGE_URL?(0,_tsRes.Ok)(new _pageUrlCondition.PageUrlCondition(a)):b===_types.TargetingType.PAGE_TITLE?(0,_tsRes.Ok)(new _pageTitleCondition.PageTitleCondition(a)):b===_types.TargetingType.CONVERSIONS?(0,_tsRes.Ok)(new _conversionCondition.ConversionCondition(a)):b===_types.TargetingType.VISITOR_CODE?(0,_tsRes.Ok)(new _visitorCodeCondition.VisitorCodeCondition(a)):b===_types.TargetingType.SDK_LANGUAGE?(0,_tsRes.Ok)(new _sdkLanguageCondition.SdkLanguageCondition(a)):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.TargetingCondition,b))}}]),a}();exports.ConditionFactory=ConditionFactory;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ConditionFactory=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../../kameleoonError"),_types=require("../types"),_browser=require("./browser"),_conversion=require("./conversion"),_customData=require("./customData"),_device=require("./device"),_exclusiveCampaign=require("./exclusiveCampaign"),_pageTitle=require("./pageTitle"),_pageUrl=require("./pageUrl"),_sdkLanguage=require("./sdkLanguage"),_visitorCode=require("./visitorCode"),_cookie=require("./cookie"),_operatingSystem=require("./operatingSystem"),_geolocation=require("./geolocation"),_segment=require("./segment"),_targetFeatureFlag=require("./targetFeatureFlag"),_previousPage=require("./previousPage"),_visitedPages=require("./visitedPages"),_firstVisit=require("./firstVisit"),_lastVisit=require("./lastVisit"),_sameDayVisits=require("./sameDayVisits"),_visits=require("./visits"),_newVisitor=require("./newVisitor"),_applicationVersion=require("./applicationVersion");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var ConditionFactory=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"createCondition",value:function createCondition(a){var b=a.targetingType;return b===_types.TargetingType.CUSTOM_DATUM?(0,_tsRes.Ok)(new _customData.CustomData(a)):b===_types.TargetingType.EXCLUSIVE_EXPERIMENT||b===_types.TargetingType.EXCLUSIVE_FEATURE_FLAG?(0,_tsRes.Ok)(new _exclusiveCampaign.ExclusiveCampaign):b===_types.TargetingType.TARGET_FEATURE_FLAG?(0,_tsRes.Ok)(new _targetFeatureFlag.TargetFeatureFlag(a)):b===_types.TargetingType.DEVICE_TYPE?(0,_tsRes.Ok)(new _device.Device(a)):b===_types.TargetingType.BROWSER?(0,_tsRes.Ok)(new _browser.Browser(a)):b===_types.TargetingType.PAGE_URL?(0,_tsRes.Ok)(new _pageUrl.PageUrl(a)):b===_types.TargetingType.PAGE_TITLE?(0,_tsRes.Ok)(new _pageTitle.PageTitle(a)):b===_types.TargetingType.CONVERSIONS?(0,_tsRes.Ok)(new _conversion.Conversion(a)):b===_types.TargetingType.VISITOR_CODE?(0,_tsRes.Ok)(new _visitorCode.VisitorCode(a)):b===_types.TargetingType.SDK_LANGUAGE?(0,_tsRes.Ok)(new _sdkLanguage.SdkLanguage(a)):b===_types.TargetingType.COOKIE?(0,_tsRes.Ok)(new _cookie.Cookie(a)):b===_types.TargetingType.OPERATING_SYSTEM?(0,_tsRes.Ok)(new _operatingSystem.OperatingSystem(a)):b===_types.TargetingType.GEOLOCATION?(0,_tsRes.Ok)(new _geolocation.GeolocationCondition(a)):b===_types.TargetingType.SEGMENT?(0,_tsRes.Ok)(new _segment.Segment(a)):b===_types.TargetingType.APPLICATION_VERSION?(0,_tsRes.Ok)(new _applicationVersion.ApplicationVersion(a)):b===_types.TargetingType.PREVIOUS_PAGE?(0,_tsRes.Ok)(new _previousPage.PreviousPage(a)):b===_types.TargetingType.NUMBER_OF_VISITED_PAGES?(0,_tsRes.Ok)(new _visitedPages.VisitedPages(a)):b===_types.TargetingType.LAST_VISIT?(0,_tsRes.Ok)(new _lastVisit.LastVisit(a)):b===_types.TargetingType.FIRST_VISIT?(0,_tsRes.Ok)(new _firstVisit.FirstVisit(a)):b===_types.TargetingType.SAME_DAY_VISITS?(0,_tsRes.Ok)(new _sameDayVisits.SameDayVisits(a)):b===_types.TargetingType.VISITS?(0,_tsRes.Ok)(new _visits.Visits(a)):b===_types.TargetingType.NEW_VISITORS?(0,_tsRes.Ok)(new _newVisitor.NewVisitor(a)):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.TargetingCondition,b))}}]),a}();exports.ConditionFactory=ConditionFactory;
//# sourceMappingURL=conditionFactory.js.map

@@ -1,12 +0,24 @@

export { DeviceCondition } from './deviceCondition';
export { Device } from './device';
export { ConditionFactory } from './conditionFactory';
export { ConditionDataType, ConditionType } from './types';
export { CustomDataCondition } from './customDataCondition';
export { TargetExperimentCondition } from './targetExperimentCondition';
export { ExclusiveExperimentCondition } from './exclusiveExperimentCondition';
export { BrowserCondition } from './browserCondition';
export { PageUrlCondition } from './pageUrlCondition';
export { PageTitleCondition } from './pageTitleCondition';
export { ConversionCondition } from './conversionCondition';
export { VisitorCodeCondition } from './visitorCodeCondition';
export { SdkLanguageCondition } from './sdkLanguageCondition';
export { CustomData } from './customData';
export { ExclusiveCampaign } from './exclusiveCampaign';
export { Browser } from './browser';
export { PageUrl } from './pageUrl';
export { PageTitle } from './pageTitle';
export { Conversion } from './conversion';
export { VisitorCode } from './visitorCode';
export { SdkLanguage } from './sdkLanguage';
export { TargetFeatureFlag } from './targetFeatureFlag';
export { Cookie } from './cookie';
export { OperatingSystem } from './operatingSystem';
export { GeolocationCondition } from './geolocation';
export { Segment } from './segment';
export { PreviousPage } from './previousPage';
export { VisitedPages } from './visitedPages';
export { FirstVisit } from './firstVisit';
export { LastVisit } from './lastVisit';
export { Visits } from './visits';
export { SameDayVisits } from './sameDayVisits';
export { NewVisitor } from './newVisitor';
export { ApplicationVersion } from './applicationVersion';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BrowserCondition",{enumerable:!0,get:function get(){return _browserCondition.BrowserCondition}}),Object.defineProperty(exports,"ConditionDataType",{enumerable:!0,get:function get(){return _types.ConditionDataType}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function get(){return _conditionFactory.ConditionFactory}}),Object.defineProperty(exports,"ConditionType",{enumerable:!0,get:function get(){return _types.ConditionType}}),Object.defineProperty(exports,"ConversionCondition",{enumerable:!0,get:function get(){return _conversionCondition.ConversionCondition}}),Object.defineProperty(exports,"CustomDataCondition",{enumerable:!0,get:function get(){return _customDataCondition.CustomDataCondition}}),Object.defineProperty(exports,"DeviceCondition",{enumerable:!0,get:function get(){return _deviceCondition.DeviceCondition}}),Object.defineProperty(exports,"ExclusiveExperimentCondition",{enumerable:!0,get:function get(){return _exclusiveExperimentCondition.ExclusiveExperimentCondition}}),Object.defineProperty(exports,"PageTitleCondition",{enumerable:!0,get:function get(){return _pageTitleCondition.PageTitleCondition}}),Object.defineProperty(exports,"PageUrlCondition",{enumerable:!0,get:function get(){return _pageUrlCondition.PageUrlCondition}}),Object.defineProperty(exports,"SdkLanguageCondition",{enumerable:!0,get:function get(){return _sdkLanguageCondition.SdkLanguageCondition}}),Object.defineProperty(exports,"TargetExperimentCondition",{enumerable:!0,get:function get(){return _targetExperimentCondition.TargetExperimentCondition}}),Object.defineProperty(exports,"VisitorCodeCondition",{enumerable:!0,get:function get(){return _visitorCodeCondition.VisitorCodeCondition}});var _deviceCondition=require("./deviceCondition"),_conditionFactory=require("./conditionFactory"),_types=require("./types"),_customDataCondition=require("./customDataCondition"),_targetExperimentCondition=require("./targetExperimentCondition"),_exclusiveExperimentCondition=require("./exclusiveExperimentCondition"),_browserCondition=require("./browserCondition"),_pageUrlCondition=require("./pageUrlCondition"),_pageTitleCondition=require("./pageTitleCondition"),_conversionCondition=require("./conversionCondition"),_visitorCodeCondition=require("./visitorCodeCondition"),_sdkLanguageCondition=require("./sdkLanguageCondition");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"ApplicationVersion",{enumerable:!0,get:function get(){return _applicationVersion.ApplicationVersion}}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _browser.Browser}}),Object.defineProperty(exports,"ConditionDataType",{enumerable:!0,get:function get(){return _types.ConditionDataType}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function get(){return _conditionFactory.ConditionFactory}}),Object.defineProperty(exports,"ConditionType",{enumerable:!0,get:function get(){return _types.ConditionType}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _conversion.Conversion}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _cookie.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _customData.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _device.Device}}),Object.defineProperty(exports,"ExclusiveCampaign",{enumerable:!0,get:function get(){return _exclusiveCampaign.ExclusiveCampaign}}),Object.defineProperty(exports,"FirstVisit",{enumerable:!0,get:function get(){return _firstVisit.FirstVisit}}),Object.defineProperty(exports,"GeolocationCondition",{enumerable:!0,get:function get(){return _geolocation.GeolocationCondition}}),Object.defineProperty(exports,"LastVisit",{enumerable:!0,get:function get(){return _lastVisit.LastVisit}}),Object.defineProperty(exports,"NewVisitor",{enumerable:!0,get:function get(){return _newVisitor.NewVisitor}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _operatingSystem.OperatingSystem}}),Object.defineProperty(exports,"PageTitle",{enumerable:!0,get:function get(){return _pageTitle.PageTitle}}),Object.defineProperty(exports,"PageUrl",{enumerable:!0,get:function get(){return _pageUrl.PageUrl}}),Object.defineProperty(exports,"PreviousPage",{enumerable:!0,get:function get(){return _previousPage.PreviousPage}}),Object.defineProperty(exports,"SameDayVisits",{enumerable:!0,get:function get(){return _sameDayVisits.SameDayVisits}}),Object.defineProperty(exports,"SdkLanguage",{enumerable:!0,get:function get(){return _sdkLanguage.SdkLanguage}}),Object.defineProperty(exports,"Segment",{enumerable:!0,get:function get(){return _segment.Segment}}),Object.defineProperty(exports,"TargetFeatureFlag",{enumerable:!0,get:function get(){return _targetFeatureFlag.TargetFeatureFlag}}),Object.defineProperty(exports,"VisitedPages",{enumerable:!0,get:function get(){return _visitedPages.VisitedPages}}),Object.defineProperty(exports,"VisitorCode",{enumerable:!0,get:function get(){return _visitorCode.VisitorCode}}),Object.defineProperty(exports,"Visits",{enumerable:!0,get:function get(){return _visits.Visits}});var _device=require("./device"),_conditionFactory=require("./conditionFactory"),_types=require("./types"),_customData=require("./customData"),_exclusiveCampaign=require("./exclusiveCampaign"),_browser=require("./browser"),_pageUrl=require("./pageUrl"),_pageTitle=require("./pageTitle"),_conversion=require("./conversion"),_visitorCode=require("./visitorCode"),_sdkLanguage=require("./sdkLanguage"),_targetFeatureFlag=require("./targetFeatureFlag"),_cookie=require("./cookie"),_operatingSystem=require("./operatingSystem"),_geolocation=require("./geolocation"),_segment=require("./segment"),_previousPage=require("./previousPage"),_visitedPages=require("./visitedPages"),_firstVisit=require("./firstVisit"),_lastVisit=require("./lastVisit"),_visits=require("./visits"),_sameDayVisits=require("./sameDayVisits"),_newVisitor=require("./newVisitor"),_applicationVersion=require("./applicationVersion");
//# sourceMappingURL=index.js.map

@@ -5,17 +5,9 @@ import { Result } from 'ts-res';

import { KameleoonError } from '../../kameleoonError';
import { EvaluationDataType, MatchType, MatchTypeCustomData, MatchTypeTest, MatchTypeVariation, TargetingType, VersionMatchType } from '../../targeting/types';
import { BrowserCondition } from './browserCondition';
import { ConversionCondition } from './conversionCondition';
import { CustomDataCondition } from './customDataCondition';
import { DeviceCondition } from './deviceCondition';
import { ExclusiveExperimentCondition } from './exclusiveExperimentCondition';
import { PageTitleCondition } from './pageTitleCondition';
import { PageUrlCondition } from './pageUrlCondition';
import { SdkLanguageCondition } from './sdkLanguageCondition';
import { TargetExperimentCondition } from './targetExperimentCondition';
import { VisitorCodeCondition } from './visitorCodeCondition';
import { EvaluationDataType, MatchType, MatchTypeTest, MatchTypeVariation, NameMatchType, TargetingType, ValueMatchType, VersionMatchType, VisitorType } from '../../targeting/types';
import { OperatingSystemType } from '../../kameleoonData/types';
import { TimeUnit } from '../../utilities';
export interface ICondition {
evaluate: (data: EvaluationDataType) => Result<boolean, KameleoonError>;
}
export type ConditionType = CustomDataCondition | ExclusiveExperimentCondition | TargetExperimentCondition | DeviceCondition | BrowserCondition | PageUrlCondition | PageTitleCondition | ConversionCondition | VisitorCodeCondition | SdkLanguageCondition;
export type ConditionType = ICondition;
export type ConditionDataType = {

@@ -27,6 +19,11 @@ id: number;

customDataIndex?: string | null;
pageCount?: number | null;
value?: string | null;
valueMatchType?: MatchTypeCustomData | null;
valueMatchType?: ValueMatchType | null;
experiment?: number | null;
variation?: number | null;
visitCount?: number | null;
variationKey?: string | null;
featureFlagId?: number | null;
ruleId?: number | null;
variationMatchType?: MatchTypeVariation | null;

@@ -37,4 +34,14 @@ testMatchType?: MatchTypeTest | null;

browser?: BrowserType | null;
os?: OperatingSystemType | null;
name?: string | null;
nameMatchType?: NameMatchType | null;
country?: string | null;
region?: string | null;
city?: string | null;
segmentId?: number | null;
version?: string | null;
versionMatchType?: VersionMatchType | null;
visitorType?: VisitorType | null;
count?: number | null;
unitOfTime?: TimeUnit | null;
title?: string | null;

@@ -41,0 +48,0 @@ url?: string | null;

@@ -1,3 +0,3 @@

export { TargetingTree } from './targetingTree';
export { Operator, TargetingType, SegmentType, TargetingDataType, EvaluationDataType, MatchTypeCustomData, MatchTypeVariation, MatchType, VersionMatchType, } from './types';
export { CustomDataCondition, TargetExperimentCondition, ExclusiveExperimentCondition, BrowserCondition, PageUrlCondition, PageTitleCondition, ConversionCondition, VisitorCodeCondition, SdkLanguageCondition, DeviceCondition, ConditionFactory, } from './conditions';
export { Tree } from './tree';
export { Operator, TargetingType, SegmentType, TargetingDataType, EvaluationDataType, ValueMatchType, MatchTypeVariation, MatchType, VersionMatchType, } from './types';
export { CustomData, ExclusiveCampaign, Browser, PageUrl, PageTitle, Conversion, VisitorCode, SdkLanguage, Device, PreviousPage, VisitedPages, ConditionFactory, TargetFeatureFlag, Cookie, GeolocationCondition, OperatingSystem, Segment, FirstVisit, LastVisit, SameDayVisits, Visits, NewVisitor, } from './conditions';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"BrowserCondition",{enumerable:!0,get:function get(){return _conditions.BrowserCondition}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function get(){return _conditions.ConditionFactory}}),Object.defineProperty(exports,"ConversionCondition",{enumerable:!0,get:function get(){return _conditions.ConversionCondition}}),Object.defineProperty(exports,"CustomDataCondition",{enumerable:!0,get:function get(){return _conditions.CustomDataCondition}}),Object.defineProperty(exports,"DeviceCondition",{enumerable:!0,get:function get(){return _conditions.DeviceCondition}}),Object.defineProperty(exports,"EvaluationDataType",{enumerable:!0,get:function get(){return _types.EvaluationDataType}}),Object.defineProperty(exports,"ExclusiveExperimentCondition",{enumerable:!0,get:function get(){return _conditions.ExclusiveExperimentCondition}}),Object.defineProperty(exports,"MatchType",{enumerable:!0,get:function get(){return _types.MatchType}}),Object.defineProperty(exports,"MatchTypeCustomData",{enumerable:!0,get:function get(){return _types.MatchTypeCustomData}}),Object.defineProperty(exports,"MatchTypeVariation",{enumerable:!0,get:function get(){return _types.MatchTypeVariation}}),Object.defineProperty(exports,"Operator",{enumerable:!0,get:function get(){return _types.Operator}}),Object.defineProperty(exports,"PageTitleCondition",{enumerable:!0,get:function get(){return _conditions.PageTitleCondition}}),Object.defineProperty(exports,"PageUrlCondition",{enumerable:!0,get:function get(){return _conditions.PageUrlCondition}}),Object.defineProperty(exports,"SdkLanguageCondition",{enumerable:!0,get:function get(){return _conditions.SdkLanguageCondition}}),Object.defineProperty(exports,"SegmentType",{enumerable:!0,get:function get(){return _types.SegmentType}}),Object.defineProperty(exports,"TargetExperimentCondition",{enumerable:!0,get:function get(){return _conditions.TargetExperimentCondition}}),Object.defineProperty(exports,"TargetingDataType",{enumerable:!0,get:function get(){return _types.TargetingDataType}}),Object.defineProperty(exports,"TargetingTree",{enumerable:!0,get:function get(){return _targetingTree.TargetingTree}}),Object.defineProperty(exports,"TargetingType",{enumerable:!0,get:function get(){return _types.TargetingType}}),Object.defineProperty(exports,"VersionMatchType",{enumerable:!0,get:function get(){return _types.VersionMatchType}}),Object.defineProperty(exports,"VisitorCodeCondition",{enumerable:!0,get:function get(){return _conditions.VisitorCodeCondition}});var _targetingTree=require("./targetingTree"),_types=require("./types"),_conditions=require("./conditions");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Browser",{enumerable:!0,get:function get(){return _conditions.Browser}}),Object.defineProperty(exports,"ConditionFactory",{enumerable:!0,get:function get(){return _conditions.ConditionFactory}}),Object.defineProperty(exports,"Conversion",{enumerable:!0,get:function get(){return _conditions.Conversion}}),Object.defineProperty(exports,"Cookie",{enumerable:!0,get:function get(){return _conditions.Cookie}}),Object.defineProperty(exports,"CustomData",{enumerable:!0,get:function get(){return _conditions.CustomData}}),Object.defineProperty(exports,"Device",{enumerable:!0,get:function get(){return _conditions.Device}}),Object.defineProperty(exports,"EvaluationDataType",{enumerable:!0,get:function get(){return _types.EvaluationDataType}}),Object.defineProperty(exports,"ExclusiveCampaign",{enumerable:!0,get:function get(){return _conditions.ExclusiveCampaign}}),Object.defineProperty(exports,"FirstVisit",{enumerable:!0,get:function get(){return _conditions.FirstVisit}}),Object.defineProperty(exports,"GeolocationCondition",{enumerable:!0,get:function get(){return _conditions.GeolocationCondition}}),Object.defineProperty(exports,"LastVisit",{enumerable:!0,get:function get(){return _conditions.LastVisit}}),Object.defineProperty(exports,"MatchType",{enumerable:!0,get:function get(){return _types.MatchType}}),Object.defineProperty(exports,"MatchTypeVariation",{enumerable:!0,get:function get(){return _types.MatchTypeVariation}}),Object.defineProperty(exports,"NewVisitor",{enumerable:!0,get:function get(){return _conditions.NewVisitor}}),Object.defineProperty(exports,"OperatingSystem",{enumerable:!0,get:function get(){return _conditions.OperatingSystem}}),Object.defineProperty(exports,"Operator",{enumerable:!0,get:function get(){return _types.Operator}}),Object.defineProperty(exports,"PageTitle",{enumerable:!0,get:function get(){return _conditions.PageTitle}}),Object.defineProperty(exports,"PageUrl",{enumerable:!0,get:function get(){return _conditions.PageUrl}}),Object.defineProperty(exports,"PreviousPage",{enumerable:!0,get:function get(){return _conditions.PreviousPage}}),Object.defineProperty(exports,"SameDayVisits",{enumerable:!0,get:function get(){return _conditions.SameDayVisits}}),Object.defineProperty(exports,"SdkLanguage",{enumerable:!0,get:function get(){return _conditions.SdkLanguage}}),Object.defineProperty(exports,"Segment",{enumerable:!0,get:function get(){return _conditions.Segment}}),Object.defineProperty(exports,"SegmentType",{enumerable:!0,get:function get(){return _types.SegmentType}}),Object.defineProperty(exports,"TargetFeatureFlag",{enumerable:!0,get:function get(){return _conditions.TargetFeatureFlag}}),Object.defineProperty(exports,"TargetingDataType",{enumerable:!0,get:function get(){return _types.TargetingDataType}}),Object.defineProperty(exports,"TargetingType",{enumerable:!0,get:function get(){return _types.TargetingType}}),Object.defineProperty(exports,"Tree",{enumerable:!0,get:function get(){return _tree.Tree}}),Object.defineProperty(exports,"ValueMatchType",{enumerable:!0,get:function get(){return _types.ValueMatchType}}),Object.defineProperty(exports,"VersionMatchType",{enumerable:!0,get:function get(){return _types.VersionMatchType}}),Object.defineProperty(exports,"VisitedPages",{enumerable:!0,get:function get(){return _conditions.VisitedPages}}),Object.defineProperty(exports,"VisitorCode",{enumerable:!0,get:function get(){return _conditions.VisitorCode}}),Object.defineProperty(exports,"Visits",{enumerable:!0,get:function get(){return _conditions.Visits}});var _tree=require("./tree"),_types=require("./types"),_conditions=require("./conditions");
//# sourceMappingURL=index.js.map

@@ -0,6 +1,8 @@

import { MappedRuleType } from '../clientConfiguration/types';
import { KameleoonVisitorDataType } from '../kameleoonData/types';
import { ExperimentVariationsType } from '../storage';
import { FeatureFlagVariationsType } from '../storage/types';
import { ExternalPackageInfoType } from '../types';
import { ConditionDataType, ConditionType } from './conditions';
import { TargetingNode } from './targetingNode';
import { Node } from './node';
import { Tree } from './tree';
export declare enum Operator {

@@ -11,4 +13,4 @@ And = "AND",

export type NonLeafNodeType = {
left: TargetingNode;
right: TargetingNode;
left: Node;
right: Node;
value: Operator;

@@ -47,8 +49,11 @@ };

targetingData?: KameleoonVisitorDataType;
variationData: ExperimentVariationsType;
variationData: FeatureFlagVariationsType;
ruleMap?: Map<number, MappedRuleType>;
sdkInfo: ExternalPackageInfoType;
experimentId: number | null;
visitorCode: string;
segments?: Map<string, SegmentType>;
trees?: Map<string, Tree>;
};
export declare enum MatchTypeCustomData {
export declare enum ValueMatchType {
TRUE = "TRUE",

@@ -65,2 +70,6 @@ FALSE = "FALSE",

}
export declare enum VisitorType {
NEW = "NEW",
RETURNING = "RETURNING"
}
export declare enum MatchTypeVariation {

@@ -78,3 +87,6 @@ ANY = "ANY",

CONTAINS = "CONTAINS",
REGULAR_EXPRESSION = "REGULAR_EXPRESSION"
REGULAR_EXPRESSION = "REGULAR_EXPRESSION",
GREATER = "GREATER",
EQUAL = "EQUAL",
LOWER = "LOWER"
}

@@ -86,2 +98,8 @@ export declare enum VersionMatchType {

}
export declare enum NameMatchType {
EXACT = "EXACT",
CONTAINS = "CONTAINS",
REGULAR_EXPRESSION = "REGULAR_EXPRESSION",
OPTIONAL = "OPTIONAL"
}
export declare enum TargetingType {

@@ -134,7 +152,10 @@ PAGE_URL = "PAGE_URL",

TARGET_EXPERIMENT = "TARGET_EXPERIMENT",
TARGET_FEATURE_FLAG = "TARGET_FEATURE_FLAG",
TARGET_PERSONALIZATION = "TARGET_PERSONALIZATION",
EXCLUSIVE_EXPERIMENT = "EXCLUSIVE_EXPERIMENT",
EXCLUSIVE_FEATURE_FLAG = "EXCLUSIVE_FEATURE_FLAG",
CONVERSIONS = "CONVERSIONS",
CUSTOM_DATUM = "CUSTOM_DATUM",
YSANCE_SEGMENT = "YSANCE_SEGMENT",
SEGMENT = "SEGMENT",
YSANCE_ATTRIBUT = "YSANCE_ATTRIBUT",

@@ -147,3 +168,4 @@ TEALIUM_BADGE = "TEALIUM_BADGE",

CUSTOM = "CUSTOM",
EXPLICIT_TRIGGER = "EXPLICIT_TRIGGER"
EXPLICIT_TRIGGER = "EXPLICIT_TRIGGER",
APPLICATION_VERSION = "APPLICATION_VERSION"
}

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VersionMatchType=exports.TargetingType=exports.Operator=exports.MatchTypeVariation=exports.MatchTypeTest=exports.MatchTypeCustomData=exports.MatchType=void 0;var Operator=/*#__PURE__*/function(a){return a.And="AND",a.Or="OR",a}({});exports.Operator=Operator;var MatchTypeCustomData=/*#__PURE__*/function(a){return a.TRUE="TRUE",a.FALSE="FALSE",a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.EQUAL="EQUAL",a.LOWER="LOWER",a.GREATER="GREATER",a.UNDEFINED="UNDEFINED",a.AMONG_VALUES="AMONG_VALUES",a}({});exports.MatchTypeCustomData=MatchTypeCustomData;var MatchTypeVariation=/*#__PURE__*/function(a){return a.ANY="ANY",a.EXACT="EXACT",a}({});exports.MatchTypeVariation=MatchTypeVariation;var MatchTypeTest=/*#__PURE__*/function(a){return a.ALL="ALL",a.TEST="TEST",a.PERSO="PERSO",a}({});exports.MatchTypeTest=MatchTypeTest;var MatchType=/*#__PURE__*/function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a}({});exports.MatchType=MatchType;var VersionMatchType=/*#__PURE__*/function(a){return a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({});exports.VersionMatchType=VersionMatchType;var TargetingType=/*#__PURE__*/function(a){return a.PAGE_URL="PAGE_URL",a.PAGE_TITLE="PAGE_TITLE",a.LANDING_PAGE="LANDING_PAGE",a.ORIGIN="ORIGIN",a.ORIGIN_TYPE="ORIGIN_TYPE",a.REFERRERS="REFERRERS",a.NEW_VISITORS="NEW_VISITORS",a.INTERESTS="INTERESTS",a.BROWSER_LANGUAGE="BROWSER_LANGUAGE",a.GEOLOCATION="GEOLOCATION",a.DEVICE_TYPE="DEVICE_TYPE",a.SCREEN_DIMENSION="SCREEN_DIMENSION",a.VISITOR_IP="VISITOR_IP",a.AD_BLOCKER="AD_BLOCKER",a.PREVIOUS_PAGE="PREVIOUS_PAGE",a.KEY_PAGES="KEY_PAGES",a.PAGE_VIEWS="PAGE_VIEWS",a.FIRST_VISIT="FIRST_VISIT",a.LAST_VISIT="LAST_VISIT",a.ACTIVE_SESSION="ACTIVE_SESSION",a.TIME_SINCE_PAGE_LOAD="TIME_SINCE_PAGE_LOAD",a.SAME_DAY_VISITS="SAME_DAY_VISITS",a.VISITS="VISITS",a.VISITS_BY_PAGE="VISITS_BY_PAGE",a.VISITOR_CODE="VISITOR_CODE",a.SDK_LANGUAGE="SDK_LANGUAGE",a.INTERNAL_SEARCH_KEYWORDS="INTERNAL_SEARCH_KEYWORDS",a.TABS_ON_SITE="TABS_ON_SITE",a.CONVERSION_PROBABILITY="CONVERSION_PROBABILITY",a.HEAT_SLICE="HEAT_SLICE",a.SKY_STATUS="SKY_STATUS",a.TEMPERATURE="TEMPERATURE",a.DAY_NIGHT="DAY_NIGHT",a.FORECAST_SKY_STATUS="FORECAST_SKY_STATUS",a.FORECAST_TEMPERATURE="FORECAST_TEMPERATURE",a.DAY_OF_WEEK="DAY_OF_WEEK",a.TIME_RANGE="TIME_RANGE",a.HOUR_MINUTE_RANGE="HOUR_MINUTE_RANGE",a.JS_CODE="JS_CODE",a.COOKIE="COOKIE",a.EVENT="EVENT",a.BROWSER="BROWSER",a.OPERATING_SYSTEM="OPERATING_SYSTEM",a.DOM_ELEMENT="DOM_ELEMENT",a.MOUSE_OUT="MOUSE_OUT",a.TARGET_EXPERIMENT="TARGET_EXPERIMENT",a.TARGET_PERSONALIZATION="TARGET_PERSONALIZATION",a.EXCLUSIVE_EXPERIMENT="EXCLUSIVE_EXPERIMENT",a.CONVERSIONS="CONVERSIONS",a.CUSTOM_DATUM="CUSTOM_DATUM",a.YSANCE_SEGMENT="YSANCE_SEGMENT",a.YSANCE_ATTRIBUT="YSANCE_ATTRIBUT",a.TEALIUM_BADGE="TEALIUM_BADGE",a.TEALIUM_AUDIENCE="TEALIUM_AUDIENCE",a.PRICE_OF_DISPLAYED_PAGE="PRICE_OF_DISPLAYED_PAGE",a.NUMBER_OF_VISITED_PAGES="NUMBER_OF_VISITED_PAGES",a.VISITED_PAGES="VISITED_PAGES",a.CUSTOM="CUSTOM",a.EXPLICIT_TRIGGER="EXPLICIT_TRIGGER",a}({});exports.TargetingType=TargetingType;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VisitorType=exports.VersionMatchType=exports.ValueMatchType=exports.TargetingType=exports.Operator=exports.NameMatchType=exports.MatchTypeVariation=exports.MatchTypeTest=exports.MatchType=void 0;var Operator=function(a){return a.And="AND",a.Or="OR",a}({});exports.Operator=Operator;var ValueMatchType=function(a){return a.TRUE="TRUE",a.FALSE="FALSE",a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.EQUAL="EQUAL",a.LOWER="LOWER",a.GREATER="GREATER",a.UNDEFINED="UNDEFINED",a.AMONG_VALUES="AMONG_VALUES",a}({});exports.ValueMatchType=ValueMatchType;var VisitorType=function(a){return a.NEW="NEW",a.RETURNING="RETURNING",a}({});exports.VisitorType=VisitorType;var MatchTypeVariation=function(a){return a.ANY="ANY",a.EXACT="EXACT",a}({});exports.MatchTypeVariation=MatchTypeVariation;var MatchTypeTest=function(a){return a.ALL="ALL",a.TEST="TEST",a.PERSO="PERSO",a}({});exports.MatchTypeTest=MatchTypeTest;var MatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({});exports.MatchType=MatchType;var VersionMatchType=function(a){return a.GREATER="GREATER",a.EQUAL="EQUAL",a.LOWER="LOWER",a}({});exports.VersionMatchType=VersionMatchType;var NameMatchType=function(a){return a.EXACT="EXACT",a.CONTAINS="CONTAINS",a.REGULAR_EXPRESSION="REGULAR_EXPRESSION",a.OPTIONAL="OPTIONAL",a}({});exports.NameMatchType=NameMatchType;var TargetingType=function(a){return a.PAGE_URL="PAGE_URL",a.PAGE_TITLE="PAGE_TITLE",a.LANDING_PAGE="LANDING_PAGE",a.ORIGIN="ORIGIN",a.ORIGIN_TYPE="ORIGIN_TYPE",a.REFERRERS="REFERRERS",a.NEW_VISITORS="NEW_VISITORS",a.INTERESTS="INTERESTS",a.BROWSER_LANGUAGE="BROWSER_LANGUAGE",a.GEOLOCATION="GEOLOCATION",a.DEVICE_TYPE="DEVICE_TYPE",a.SCREEN_DIMENSION="SCREEN_DIMENSION",a.VISITOR_IP="VISITOR_IP",a.AD_BLOCKER="AD_BLOCKER",a.PREVIOUS_PAGE="PREVIOUS_PAGE",a.KEY_PAGES="KEY_PAGES",a.PAGE_VIEWS="PAGE_VIEWS",a.FIRST_VISIT="FIRST_VISIT",a.LAST_VISIT="LAST_VISIT",a.ACTIVE_SESSION="ACTIVE_SESSION",a.TIME_SINCE_PAGE_LOAD="TIME_SINCE_PAGE_LOAD",a.SAME_DAY_VISITS="SAME_DAY_VISITS",a.VISITS="VISITS",a.VISITS_BY_PAGE="VISITS_BY_PAGE",a.VISITOR_CODE="VISITOR_CODE",a.SDK_LANGUAGE="SDK_LANGUAGE",a.INTERNAL_SEARCH_KEYWORDS="INTERNAL_SEARCH_KEYWORDS",a.TABS_ON_SITE="TABS_ON_SITE",a.CONVERSION_PROBABILITY="CONVERSION_PROBABILITY",a.HEAT_SLICE="HEAT_SLICE",a.SKY_STATUS="SKY_STATUS",a.TEMPERATURE="TEMPERATURE",a.DAY_NIGHT="DAY_NIGHT",a.FORECAST_SKY_STATUS="FORECAST_SKY_STATUS",a.FORECAST_TEMPERATURE="FORECAST_TEMPERATURE",a.DAY_OF_WEEK="DAY_OF_WEEK",a.TIME_RANGE="TIME_RANGE",a.HOUR_MINUTE_RANGE="HOUR_MINUTE_RANGE",a.JS_CODE="JS_CODE",a.COOKIE="COOKIE",a.EVENT="EVENT",a.BROWSER="BROWSER",a.OPERATING_SYSTEM="OPERATING_SYSTEM",a.DOM_ELEMENT="DOM_ELEMENT",a.MOUSE_OUT="MOUSE_OUT",a.TARGET_EXPERIMENT="TARGET_EXPERIMENT",a.TARGET_FEATURE_FLAG="TARGET_FEATURE_FLAG",a.TARGET_PERSONALIZATION="TARGET_PERSONALIZATION",a.EXCLUSIVE_EXPERIMENT="EXCLUSIVE_EXPERIMENT",a.EXCLUSIVE_FEATURE_FLAG="EXCLUSIVE_FEATURE_FLAG",a.CONVERSIONS="CONVERSIONS",a.CUSTOM_DATUM="CUSTOM_DATUM",a.YSANCE_SEGMENT="YSANCE_SEGMENT",a.SEGMENT="SEGMENT",a.YSANCE_ATTRIBUT="YSANCE_ATTRIBUT",a.TEALIUM_BADGE="TEALIUM_BADGE",a.TEALIUM_AUDIENCE="TEALIUM_AUDIENCE",a.PRICE_OF_DISPLAYED_PAGE="PRICE_OF_DISPLAYED_PAGE",a.NUMBER_OF_VISITED_PAGES="NUMBER_OF_VISITED_PAGES",a.VISITED_PAGES="VISITED_PAGES",a.CUSTOM="CUSTOM",a.EXPLICIT_TRIGGER="EXPLICIT_TRIGGER",a.APPLICATION_VERSION="APPLICATION_VERSION",a}({});exports.TargetingType=TargetingType;
//# sourceMappingURL=types.js.map
/// <reference types="node" />
import { IncomingMessage, ServerResponse } from 'http';
import { JSONType } from './campaignConfiguration/types';
import { JSONType } from './clientConfiguration/types';
import { SdkLanguageType } from './constants';

@@ -8,2 +8,3 @@ import { IExternalEventSourceConstructor } from './eventSource';

import { IExternalRequestDispatcher, GetClientConfigurationResultType } from './requester';
import { VisitorDataFiltersType } from './utilities';
/**

@@ -102,3 +103,4 @@ * @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute

* @readonly
* @enum {number} a helper Enum for getting milliseconds for a second, a minute and an hour.
* @enum {number} a helper Enum for getting milliseconds for a second/minute/hour/day/week/month.
* Month is considered in average of 30 days
* */

@@ -108,3 +110,6 @@ export declare enum Milliseconds {

Minute = 60000,
Hour = 3600000
Hour = 3600000,
Day = 86400000,
Week = 604800000,
Month = 2592000000
}

@@ -121,5 +126,11 @@ /**

};
export type ExperimentType = {
id: number;
name: string;
/**
* @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
* @param {boolean | undefined} shouldAddData - optional parameter for adding retrieved data to the storage like `addData` method does, default value is `true`
* @param {VisitorDataFiltersType | undefined} filters - optional parameter for specifying the filters for which data should be retrieved from what visit, by default only latest `customData` is retrieved
* */
export type RemoteVisitorDataParamsType = {
visitorCode: string;
shouldAddData?: boolean;
filters?: VisitorDataFiltersType;
};

@@ -126,0 +137,0 @@ export type FeatureFlagType = {

@@ -1,42 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.Milliseconds=exports.Environment=void 0;/**
* @param {number} updateInterval - update interval in _minutes_ for sdk configuration, minimum value is 1 minute
* @defaultvalue 60
*
* @param {Environment} environment - feature flag environment
* @defaultvalue Environment.Production
*
* @param {number | undefined} targetingDataCleanupInterval - interval in _minutes_ for cleaning up targeting data, minimum value is 1 minute
* Note: if not specified, default value will be used
* @defaultvalue
* - JavaScript SDK: `undefined` (no cleanup)
* - React/React Native SDK: `undefined` (no cleanup)
* - NodeJS SDK: `30`
* */ /**
* @param {string} siteCode - client's siteCode defined on Kameleoon platform
* @param {Partial<SDKConfigurationType>} configuration - client's configuration
* @param {InternalSDKConfigurationType} internalConfiguration - internal configuration for sdk core to be initialized with certain parameters to certain type of JavaScript SDK
* */ /**
* @param {SdkLanguageType} type - type of the SDK
* @param {string} version - version of the package
* */ /**
* @param {IExternalStorage | undefined} externalStorage - external file system storage implemented outside client initialization
* @param {IExternalEventSourceConstructor | undefined} externalEventSource - constructor for building external event source implementation
* @param {ExternalPackageInfoType} externalPackageInfo - external package info, used to get package version and name
* @param {GetClientConfigurationResultType} externalClientConfiguration - external fetched client configuration
* @param {IExternalRequestDispatcher} externalRequestDispatcher - external request dispatcher, used to track data or get data
* @param {number} targetingDataCleanupInterval - interval in *minutes* for cleaning up targeting data, minimum value is 1 minute
* */ /**
* @readonly
* @enum {string} an Enum containing all possible variants of environment, passed as an argument to KameleoonClient `configuration`s `environment` field
* */var Environment=/*#__PURE__*/function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({});/**
* @readonly
* @enum {string} an Enum containing all possible variants of feature variable types
* */exports.Environment=Environment;var VariableType=/*#__PURE__*/function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a}({});exports.VariableType=VariableType;/**
* @readonly
* @enum {number} a helper Enum for getting milliseconds for a second, a minute and an hour.
* */var Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a}({});/**
* @param {string} visitorCode - unique visitor identifier, shouldn't exceed 255 characters
* @param {number} goalId - an id of a goal to track
* @param {number | undefined} revenue - an optional parameter for revenue, default value is `0`
* */exports.Milliseconds=Milliseconds;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariableType=exports.Milliseconds=exports.Environment=void 0;var Environment=function(a){return a.Production="production",a.Staging="staging",a.Development="development",a}({});exports.Environment=Environment;var VariableType=function(a){return a.BOOLEAN="BOOLEAN",a.NUMBER="NUMBER",a.STRING="STRING",a.JSON="JSON",a}({});exports.VariableType=VariableType;var Milliseconds=function(a){return a[a.Second=1000]="Second",a[a.Minute=60*a.Second]="Minute",a[a.Hour=60*a.Minute]="Hour",a[a.Day=24*a.Hour]="Day",a[a.Week=7*a.Day]="Week",a[a.Month=30*a.Day]="Month",a}({});exports.Milliseconds=Milliseconds;
//# sourceMappingURL=types.js.map
export { Utilities } from './utilities';
export { HEX_CHARACTERS } from './constants';
export { VisitorDataFiltersType, TimeUnit } from './types';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"HEX_CHARACTERS",{enumerable:!0,get:function get(){return _constants.HEX_CHARACTERS}}),Object.defineProperty(exports,"Utilities",{enumerable:!0,get:function get(){return _utilities.Utilities}});var _utilities=require("./utilities"),_constants=require("./constants");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"HEX_CHARACTERS",{enumerable:!0,get:function get(){return _constants.HEX_CHARACTERS}}),Object.defineProperty(exports,"TimeUnit",{enumerable:!0,get:function get(){return _types.TimeUnit}}),Object.defineProperty(exports,"Utilities",{enumerable:!0,get:function get(){return _utilities.Utilities}}),Object.defineProperty(exports,"VisitorDataFiltersType",{enumerable:!0,get:function get(){return _types.VisitorDataFiltersType}});var _utilities=require("./utilities"),_constants=require("./constants"),_types=require("./types");
//# sourceMappingURL=index.js.map
import { CacheManager } from '../cacheManager';
import { CampaignConfiguration } from '../campaignConfiguration';
import { ClientConfiguration } from '../clientConfiguration';
import { DataManager } from '../kameleoonData';
import { KameleoonVisitorDataType } from '../kameleoonData/types';
import { Requester } from '../requester';
import { TrackDataParamsType, TrackExperimentParamsType } from '../requester/types';
import { GetVisitorDataResultType, TrackDataParamsType, TrackExperimentParamsType } from '../requester/types';
import { IExternalStorage, OfflineTracking } from '../storage/types';

@@ -16,8 +17,31 @@ import { SegmentType } from '../targeting';

targetingData: KameleoonVisitorDataType;
campaignConfiguration: CampaignConfiguration;
clientConfiguration: ClientConfiguration;
variationConfiguration?: VariationConfiguration;
dataManager: DataManager;
};
export declare enum TimeUnit {
Minute = "MINUTE",
Hour = "HOUR",
Day = "DAY",
Week = "WEEK",
Month = "MONTH"
}
export declare enum Order {
Ascending = "asc",
Descending = "desc"
}
export type InsertInOrderedListParametersType = {
list: number[];
element: number;
order: Order;
};
export type ParseVisitorDataParametersType = {
data: GetVisitorDataResultType;
filters: VisitorDataFiltersType;
visitorCode: string;
variationConfiguration: VariationConfiguration;
};
export type TrackRuleParametersType = {
featureFlagVariation: FeatureFlagVariationType;
campaignConfiguration: CampaignConfiguration;
dataManager: DataManager;
visitorCode: string;

@@ -37,3 +61,3 @@ requester: Requester;

visitorCode: string;
campaignConfiguration: CampaignConfiguration;
dataManager: DataManager;
requester: Requester;

@@ -44,3 +68,3 @@ isOfflineModeOn?: boolean;

export type TrackExperimentParametersType = {
campaignConfiguration: CampaignConfiguration;
clientConfiguration: ClientConfiguration;
visitorCode: string;

@@ -68,1 +92,32 @@ requester: Requester;

};
/**
* @param {number} visitAmount - Number of visits to retrieve data from. Number between `1` and `25`
* *Default*: `1`.
* @param {boolean} customData - If true, custom data will be retrieved.
* *Default*: `true`.
* @param {boolean} pageViews - If true, page data will be retrieved.
* *Default*: `false`.
* @param {boolean} geolocation - If true, geolocation data will be retrieved.
* *Default*: `false`.
* @param {boolean} device - If true, device data will be retrieved.
* *Default*: `false`.
* @param {boolean} browser - If true, browser data will be retrieved.
* *Default*: `false`.
* @param {boolean} operatingSystem - If true, operating system data will be retrieved.
* *Default*: `false`.
* @param {boolean} conversions - If true, conversion data will be retrieved.
* *Default*: `false`.
* @param {boolean} experiments - If true, experiment data will be retrieved.
* *Default*: `false`.
* */
export type VisitorDataFiltersType = {
visitAmount?: number;
pageViews?: boolean;
geolocation?: boolean;
device?: boolean;
browser?: boolean;
operatingSystem?: boolean;
customData?: boolean;
conversions?: boolean;
experiments?: boolean;
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TimeUnit=exports.Order=void 0;var TimeUnit=function(a){return a.Minute="MINUTE",a.Hour="HOUR",a.Day="DAY",a.Week="WEEK",a.Month="MONTH",a}({});exports.TimeUnit=TimeUnit;var Order=function(a){return a.Ascending="asc",a.Descending="desc",a}({});exports.Order=Order;
//# sourceMappingURL=types.js.map
import { Result } from 'ts-res';
import { KameleoonError } from '../kameleoonError';
import { FeatureVariableResultType, TrackingCacheItemType } from '../types';
import { CampaignConfiguration, FeatureVariableType } from '../campaignConfiguration';
import { CustomData, KameleoonDataType } from '../kameleoonData';
import { FeatureVariableType } from '../clientConfiguration';
import { CustomData, DataManager, KameleoonDataType } from '../kameleoonData';
import { CacheManager } from '../cacheManager';
import { GetVisitorDataResultType } from '../requester';
import { CheckTargetingParametersType, ManageCacheParametersType, TrackDataParametersType, TrackRuleParametersType, SendOfflineTrackingParametersType, TrackExperimentParametersType } from './types';
import { VersionMatchType } from '../targeting';
import { CheckTargetingParametersType, ManageCacheParametersType, TrackDataParametersType, TrackRuleParametersType, SendOfflineTrackingParametersType, ParseVisitorDataParametersType, InsertInOrderedListParametersType, TimeUnit } from './types';
export declare class Utilities {
static checkTargeting({ segment, visitorCode, targetingData, experimentId, variationConfiguration, campaignConfiguration, packageInfo, }: CheckTargetingParametersType): Result<boolean, KameleoonError>;
static checkTargeting({ segment, visitorCode, targetingData, experimentId, variationConfiguration, clientConfiguration, packageInfo, dataManager, }: CheckTargetingParametersType): Result<boolean, KameleoonError>;
static validateVisitorCode(visitorCode: string): Result<void, KameleoonError>;
static getDataUrl(visitorCode: string, campaignConfiguration: CampaignConfiguration): string;
static trackRule({ featureFlagVariation, campaignConfiguration, visitorCode, requester, isOfflineModeOn, offlineTrackingStorage, }: TrackRuleParametersType): Promise<void>;
static getDataUrl(visitorCode: string, dataManager: DataManager): string;
static trackFeatureExperiment({ featureFlagVariation, dataManager, visitorCode, requester, isOfflineModeOn, offlineTrackingStorage, }: TrackRuleParametersType): Promise<void>;
static convertTimeUnit(time: number, timeUnit: TimeUnit): number;
static parseFeatureVariable(variable: FeatureVariableType): Result<FeatureVariableResultType, KameleoonError>;
static parseVisitorData(data: GetVisitorDataResultType): KameleoonDataType[];
static parseVisitorData({ data, filters, visitorCode, variationConfiguration, }: ParseVisitorDataParametersType): KameleoonDataType[];
static parseRegExp(value: string): RegExp;
static getUserAgent(visitorCode: string, campaignConfiguration: CampaignConfiguration): string | undefined;
static getUserAgent(visitorCode: string, dataManager: DataManager): string | undefined;
static isCustomData(dataItem: KameleoonDataType): dataItem is CustomData;
/**
* Insert element in ordered list, if element already exists in list, does nothing
* @param list - list to insert element
* @param element - element to insert
* @param order - order of list
*/
static insertInOrderedListMutably({ list, element, order, }: InsertInOrderedListParametersType): void;
static updateCache({ cacheManager, visitorCode, experimentId, variationId, }: ManageCacheParametersType): void;
static getTrackingCode(trackingCache: CacheManager<TrackingCacheItemType>, visitorCode: string): string;
static trackData({ visitorCode, campaignConfiguration, requester, isOfflineModeOn, offlineTrackingStorage, }: TrackDataParametersType): Promise<void>;
static trackExperiment({ variationId, experimentId, isUnallocated, visitorCode, campaignConfiguration, requester, isOfflineModeOn, offlineTrackingStorage, }: TrackExperimentParametersType): Promise<void>;
static trackData({ visitorCode, dataManager, requester, isOfflineModeOn, offlineTrackingStorage, }: TrackDataParametersType): Promise<void>;
static getNonce(): string;
static sendOfflineTracking({ requester, storage, }: SendOfflineTrackingParametersType): Promise<void>;
static compareSemVer({ version, compareVersion, operator, }: {
version: string;
compareVersion: string;
operator: VersionMatchType;
}): Result<boolean, KameleoonError>;
private static addItemToOfflineTracking;
private static deleteFromOfflineTracking;
private static validateVersion;
}

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_constants2=require("./constants"),_excluded=["timestamp","isExperiment"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _construct(){return _construct=_isNativeReflectConstruct()?Reflect.construct.bind():function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Utilities=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"checkTargeting",value:function checkTargeting(a){var b=a.segment,c=a.visitorCode,d=a.targetingData,e=a.experimentId,f=a.variationConfiguration,g=a.campaignConfiguration,h=a.packageInfo;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var i={},j=f.getAssignedVariations(c);j.ok&&(i=j.data);var k=g.getTargetingTree(b),l=k.evaluate({variationData:i,sdkInfo:h,targetingData:d,experimentId:e,visitorCode:c});return l}},{key:"validateVisitorCode",value:function validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}},{key:"getDataUrl",value:function getDataUrl(a,b){var c=b.getUnsentData(a),d="";if(!c||!c.size)return d;var e,f=_createForOfIteratorHelper(c.values());try{for(f.s();!(e=f.n()).done;){var g=e.value;g.url&&(d+=g.url+"\n")}}catch(a){f.e(a)}finally{f.f()}return d}},{key:"trackRule",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regeneratorRuntime().wrap(function r(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.featureFlagVariation,d=a.campaignConfiguration,e=a.visitorCode,f=a.requester,g=a.isOfflineModeOn,h=a.offlineTrackingStorage,i=c.variationId,j=c.rule,k=this.getUserAgent(e,d),l=this.getDataUrl(e,d),m=i||0,n=null===i,o=j?j.experimentId:0,p={visitorCode:e,isUnallocated:n,body:l,experimentId:o,variationId:m,userAgent:k},b.next=10,f.trackExperiment(p);case 10:q=b.sent,q.ok&&d.clearUnsentData(e),!q.ok&&g&&this.addItemToOfflineTracking({item:p,storage:h,isExperiment:!0});case 13:case"end":return b.stop();}},b,this)}));return a}()},{key:"parseFeatureVariable",value:function parseFeatureVariable(a){var b=a.type,c=a.value;switch(b){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({type:b,value:!!c});case _types.VariableType.STRING:return(0,_tsRes.Ok)({type:b,value:c+""});case _types.VariableType.NUMBER:var d=+c;return Number.isNaN(d)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,c+"")):(0,_tsRes.Ok)({type:b,value:d});case _types.VariableType.JSON:try{var e=JSON.parse(a.value+"");return(0,_tsRes.Ok)({type:b,value:e})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(b);}}},{key:"parseVisitorData",value:function parseVisitorData(a){var b,c=a.currentVisit,d=a.previousVisits;if(c?b=[c]:d&&(b=d),!b)return[];var e=new Map,f=[],g=_toConsumableArray(b[0].customDataEvents);g.sort(function(c,a){return a.time-c.time});var h,i=_createForOfIteratorHelper(g);try{for(i.s();!(h=i.n()).done;){var j=h.value,k=j.data.index;if(!e.has(k)){e.set(k,!0);var l=Object.keys(j.data.valuesCountMap);f.push(_construct(_kameleoonData.CustomData,[k].concat(l)))}}}catch(a){i.e(a)}finally{i.f()}return f}},{key:"parseRegExp",value:function parseRegExp(a){if("/"===a[0]){var b=a.split("/"),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];return new RegExp(e,f)}return new RegExp(a)}},{key:"getUserAgent",value:function getUserAgent(a,b){var c=b.storedTargetingData[a];if(c){var d=c[_kameleoonData.KameleoonData.UserAgent];if(d)return d.value}}},{key:"isCustomData",value:function isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}},{key:"updateCache",value:function updateCache(a){var b=a.cacheManager,c=a.visitorCode,d=a.experimentId,e=a.variationId,f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}},{key:"getTrackingCode",value:function getTrackingCode(a,b){var c="window.kameleoonQueue=window.kameleoonQueue||[];",d=a.getAliveItem(b);if(!d)return c;var e={};return Object.entries(d).forEach(function(a){var b=_slicedToArray(a,2),d=b[0],f=b[1],g=f.variationId,h=f.expirationTime;h>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(d,",").concat(g,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(d,",true]);"),e[+d]={variationId:g,expirationTime:h})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l;return _regeneratorRuntime().wrap(function m(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.campaignConfiguration,e=a.requester,f=a.isOfflineModeOn,g=a.offlineTrackingStorage,b.next=3,this.sendOfflineTracking({requester:e,storage:g});case 3:return h=this.getDataUrl(c,d),i=this.getUserAgent(c,d),j={visitorCode:c,body:h,userAgent:i},b.next=8,e.trackData(j);case 8:k=b.sent,l=function cleanup(){return d.clearUnsentData(c)},k.ok&&l(),!k.ok&&f&&this.addItemToOfflineTracking({item:j,storage:g,isExperiment:!1,onSuccess:l});case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"trackExperiment",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.variationId,d=a.experimentId,e=a.isUnallocated,f=a.visitorCode,g=a.campaignConfiguration,h=a.requester,i=a.isOfflineModeOn,j=a.offlineTrackingStorage,k=this.getDataUrl(f,g),l=this.getUserAgent(f,g),m={body:k,visitorCode:f,isUnallocated:e,variationId:c,userAgent:l,experimentId:d},b.next=6,h.trackExperiment(m);case 6:n=b.sent,!n.ok&&i&&this.addItemToOfflineTracking({item:m,storage:j,isExperiment:!0});case 8:case"end":return b.stop();}},b,this)}));return a}()},{key:"getNonce",value:function getNonce(){for(var a,b=_constants2.HEX_CHARACTERS.length,c="",d=0;d<b;d++)a=Math.floor(Math.random()*b),c+=_constants2.HEX_CHARACTERS.substring(a,a+1);return c}},{key:"sendOfflineTracking",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.requester,d=a.storage,e=d.read(),!(e.ok&&e.data.requestParameters)){b.next=33;break}f=e.data.requestParameters,g=[],h=_createForOfIteratorHelper(f),b.prev=6,h.s();case 8:if((i=h.n()).done){b.next=24;break}if(j=i.value,k=j.timestamp,l=j.isExperiment,m=_objectWithoutProperties(j,_excluded),n=void 0,!l){b.next=18;break}return b.next=15,c.trackExperiment(m);case 15:n=b.sent,b.next=21;break;case 18:return b.next=20,c.trackData(m);case 20:n=b.sent;case 21:n.ok&&n.data&&g.push(k);case 22:b.next=8;break;case 24:b.next=29;break;case 26:b.prev=26,b.t0=b["catch"](6),h.e(b.t0);case 29:return b.prev=29,h.f(),b.finish(29);case 32:this.deleteFromOfflineTracking({storage:d,timestamps:g});case 33:case"end":return b.stop();}},b,this,[[6,26,29,32]])}));return a}()},{key:"addItemToOfflineTracking",value:function addItemToOfflineTracking(a){var b=a.item,c=a.isExperiment,d=a.storage,e=a.onSuccess,f=d.read(),g=f.ok?f.data:{},h=g.requestParameters,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[].concat(_toConsumableArray(h),[i]):[i],k=d.write({requestParameters:j});k.ok&&e&&e()}},{key:"deleteFromOfflineTracking",value:function deleteFromOfflineTracking(a){var b=a.timestamps,c=a.storage,d=c.read();if(d.ok){var e=d.data.requestParameters,f=null===e||void 0===e?void 0:e.filter(function(a){return!b.includes(a.timestamp)});c.write({requestParameters:f})}}}]),a}();exports.Utilities=Utilities;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Utilities=void 0;var _tsRes=require("ts-res"),_kameleoonError=require("../kameleoonError"),_types=require("../types"),_kameleoonData=require("../kameleoonData"),_constants=require("../constants"),_requester=require("../requester"),_targeting=require("../targeting"),_constants2=require("./constants"),_types2=require("./types"),_excluded=["timestamp","isExperiment"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(a,b){var c=null==a?null:"undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(null!=c){var d,e,f,g,h=[],i=!0,j=!1;try{if(f=(c=c.call(a)).next,0===b){if(Object(c)!==c)return;i=!1}else for(;!(i=(d=f.call(c)).done)&&(h.push(d.value),h.length!==b);i=!0);}catch(a){j=!0,e=a}finally{try{if(!i&&null!=c.return&&(g=c.return(),Object(g)!==g))return}finally{if(j)throw e}}return h}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){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 _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _regeneratorRuntime(){"use strict";function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,c,e){var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return s(g,"_invoke",{value:i(a,c,h)}),g}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&r.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;s(this,"_invoke",{value:function value(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}})}function i(a,b,d){var e="suspendedStart";return function(f,g){if("executing"==e)throw new Error("Generator is already running");if("completed"==e){if("throw"===f)throw g;return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"==e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}function j(a,b){var d=b.method,e=a.iterator[d];if(void 0===e)return b.delegate=null,"throw"===d&&a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method)||"return"!==d&&(b.method="throw",b.arg=new TypeError("The iterator does not provide a '"+d+"' method")),x;var f=c(e,a.iterator,b.arg);if("throw"===f.type)return b.method="throw",b.arg=f.arg,b.delegate=null,x;var g=f.arg;return g?g.done?(b[a.resultName]=g.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,x):g:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x)}function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[u];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(r.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:o}}function o(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return p};var p={},q=Object.prototype,r=q.hasOwnProperty,s=Object.defineProperty||function(a,b,c){a[b]=c.value},t="function"==typeof Symbol?Symbol:{},u=t.iterator||"@@iterator",v=t.asyncIterator||"@@asyncIterator",w=t.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}p.wrap=b;var x={},y={};a(y,u,function(){return this});var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==q&&r.call(A,u)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);return e.prototype=f,s(B,"constructor",{value:f,configurable:!0}),s(f,"constructor",{value:e,configurable:!0}),e.displayName=a(f,w,"GeneratorFunction"),p.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},p.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,w,"GeneratorFunction")),b.prototype=Object.create(B),b},p.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,v,function(){return this}),p.AsyncIterator=h,p.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return p.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(B),a(B,w,"Generator"),a(B,u,function(){return this}),a(B,"toString",function(){return"[object Generator]"}),p.keys=function(a){var b=Object(a),c=[];for(var d in b)c.push(d);return c.reverse(),function a(){for(;c.length;){var d=c.pop();if(d in b)return a.value=d,a.done=!1,a}return a.done=!0,a}},p.values=n,m.prototype={constructor:m,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)"t"===b.charAt(0)&&r.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=r.call(e,"catchLoc"),h=r.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&r.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}},p}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var Utilities=function(){function a(){_classCallCheck(this,a)}return _createClass(a,null,[{key:"checkTargeting",value:function checkTargeting(a){var b=a.segment,c=a.visitorCode,d=a.targetingData,e=a.experimentId,f=a.variationConfiguration,g=a.clientConfiguration,h=a.packageInfo,i=a.dataManager;if(!b||!b.conditionsData.firstLevel.length)return(0,_tsRes.Ok)(!0);if(!f)return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.Initialization));var j={},k=f.getStoredVariations(c);k.ok&&(j=k.data);var l=i.getTree(b),m=void 0,n=void 0,o=void 0;l.hasTargetingType(_targeting.TargetingType.SEGMENT)&&(m=i.trees,n=g.segments),l.hasTargetingType(_targeting.TargetingType.TARGET_FEATURE_FLAG)&&(o=g.ruleMap);var p=l.evaluate({variationData:j,sdkInfo:h,segments:n,ruleMap:o,trees:m,targetingData:d,experimentId:e,visitorCode:c});return p}},{key:"validateVisitorCode",value:function validateVisitorCode(a){return 0===a.length?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeEmpty)):a.length>_constants2.VISITOR_CODE_MAX_LENGTH?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.VisitorCodeMaxLength)):(0,_tsRes.Ok)()}},{key:"getDataUrl",value:function getDataUrl(b,c){function d(b){b.url&&(f+=b.url+_requester.UrlParameter.Nonce+a.getNonce()+"\n")}var e=c.getUnsentData(b),f="";if(!e||!e.size)return f;var g,h=_createForOfIteratorHelper(e.values());try{for(h.s();!(g=h.n()).done;){var i=g.value;Array.isArray(i)?i.forEach(function(a){return d(a)}):d(i)}}catch(a){h.e(a)}finally{h.f()}return f}},{key:"trackFeatureExperiment",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regeneratorRuntime().wrap(function r(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.featureFlagVariation,d=a.dataManager,e=a.visitorCode,f=a.requester,g=a.isOfflineModeOn,h=a.offlineTrackingStorage,i=c.variationId,j=c.rule,k=this.getUserAgent(e,d),l=this.getDataUrl(e,d),m=i||0,n=null===i,o=j?j.experimentId:0,p={visitorCode:e,isUnallocated:n,body:l,experimentId:o,variationId:m,userAgent:k},b.next=10,f.trackExperiment(p);case 10:q=b.sent,q.ok&&d.clearUnsentData(e),!q.ok&&g&&this.addItemToOfflineTracking({item:p,storage:h,isExperiment:!0});case 13:case"end":return b.stop();}},b,this)}));return a}()},{key:"convertTimeUnit",value:function convertTimeUnit(a,b){var c,d=(c={},_defineProperty(c,_types2.TimeUnit.Minute,_types.Milliseconds.Minute),_defineProperty(c,_types2.TimeUnit.Hour,_types.Milliseconds.Hour),_defineProperty(c,_types2.TimeUnit.Day,_types.Milliseconds.Day),_defineProperty(c,_types2.TimeUnit.Week,_types.Milliseconds.Week),_defineProperty(c,_types2.TimeUnit.Month,_types.Milliseconds.Month),c);return a/d[b]}},{key:"parseFeatureVariable",value:function parseFeatureVariable(a){var b=a.type,c=a.value;switch(b){case _types.VariableType.BOOLEAN:return(0,_tsRes.Ok)({type:b,value:!!c});case _types.VariableType.STRING:return(0,_tsRes.Ok)({type:b,value:c+""});case _types.VariableType.NUMBER:var d=+c;return Number.isNaN(d)?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NumberParse,c+"")):(0,_tsRes.Ok)({type:b,value:d});case _types.VariableType.JSON:try{var e=JSON.parse(a.value+"");return(0,_tsRes.Ok)({type:b,value:e})}catch(a){return(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.JSONParse,a))}default:(0,_kameleoonError.exhaustCheck)(b);}}},{key:"parseVisitorData",value:function parseVisitorData(a){var b=a.data,c=a.filters,d=a.visitorCode,e=a.variationConfiguration,f=b.currentVisit,g=b.previousVisits,h=c.browser,j=c.customData,k=c.operatingSystem,l=c.conversions,m=c.device,n=c.geolocation,o=c.experiments,p=c.pageViews,q=c.visitAmount,r=[];if(f&&r.push(f),g&&(r.length&&q&&1<q&&r.push.apply(r,_toConsumableArray(g)),!r.length&&r.push.apply(r,_toConsumableArray(g))),!r)return[];var s=[];if(p){var t=_kameleoonData.PageView._listFromVisits(r);t.length&&s.push.apply(s,_toConsumableArray(t))}if(h){var u=_kameleoonData.Browser._fromVisits(r);u&&s.push(u)}if(o){for(var v,w={},x=r.length-1;0<=x;x--)if(v=r[x],!!v.experimentEvents){var y,z=_createForOfIteratorHelper(v.experimentEvents);try{for(z.s();!(y=z.n()).done;){var A=y.value,B=A.data,C=B.id,D=B.variationId;w[C]=D}}catch(a){z.e(a)}finally{z.f()}}e.updateStoredVariations(d,w)}if(m){var E=_kameleoonData.Device._fromVisits(r);E&&s.push(E)}if(n){var F=_kameleoonData.GeolocationData._fromVisits(r);F&&s.push(F)}if(j&&s.push.apply(s,_toConsumableArray(_kameleoonData.CustomData._listFromVisits(r))),k){var G=_kameleoonData.OperatingSystem._fromVisits(r);G&&s.push(G)}l&&s.push.apply(s,_toConsumableArray(_kameleoonData.Conversion._listFromVisits(r)));var H=_kameleoonData.VisitsData._fromRemoteVisits(r,!!f);return H&&s.push(H),s}},{key:"parseRegExp",value:function parseRegExp(a){if("/"===a[0]){var b=a.split("/"),c=_slicedToArray(b,3),d=c[0],e=c[1],f=c[2];return new RegExp(e,f)}return new RegExp(a)}},{key:"getUserAgent",value:function getUserAgent(a,b){var c=b.storedTargetingData,d=c&&c[a];if(d){var e=d[_kameleoonData.KameleoonData.UserAgent];if(e)return e.value}}},{key:"isCustomData",value:function isCustomData(a){return a.data.type===_kameleoonData.KameleoonData.CustomData}},{key:"insertInOrderedListMutably",value:function insertInOrderedListMutably(a){var b=a.list,c=a.element,d=a.order;if(!b.includes(c)){var e=b.findIndex(function(a){return d===_types2.Order.Ascending?a>=c:a<=c});-1===e?b.push(c):b.splice(e,0,c)}}},{key:"updateCache",value:function updateCache(a){var b=a.cacheManager,c=a.visitorCode,d=a.experimentId,e=a.variationId,f=b.getAliveItem(c),g=f?_objectSpread({},f):{};g[d]={variationId:e,expirationTime:Date.now()+_constants.CACHE_ITEM_LIFETIME*_types.Milliseconds.Second},b.add({key:c,data:g,lifetime:_constants.CACHE_ITEM_LIFETIME})}},{key:"getTrackingCode",value:function getTrackingCode(a,b){var c="window.kameleoonQueue=window.kameleoonQueue||[];",d=a.getAliveItem(b);if(!d)return c;var e={};return Object.entries(d).forEach(function(a){var b=_slicedToArray(a,2),d=b[0],f=b[1],g=f.variationId,h=f.expirationTime;h>Date.now()&&(c+="window.kameleoonQueue.push(['Experiments.assignVariation',".concat(d,",").concat(g,"]);"),c+="window.kameleoonQueue.push(['Experiments.trigger',".concat(d,",true]);"),e[+d]={variationId:g,expirationTime:h})}),a.add({key:b,data:e,lifetime:_constants.CACHE_ITEM_LIFETIME}),c}},{key:"trackData",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l;return _regeneratorRuntime().wrap(function m(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.visitorCode,d=a.dataManager,e=a.requester,f=a.isOfflineModeOn,g=a.offlineTrackingStorage,b.next=3,this.sendOfflineTracking({requester:e,storage:g});case 3:return h=this.getDataUrl(c,d),i=this.getUserAgent(c,d),j={visitorCode:c,body:h,userAgent:i},b.next=8,e.trackData(j);case 8:k=b.sent,l=function cleanup(){return d.clearUnsentData(c)},k.ok&&l(),!k.ok&&f&&this.addItemToOfflineTracking({item:j,storage:g,isExperiment:!1,onSuccess:l});case 12:case"end":return b.stop();}},b,this)}));return a}()},{key:"getNonce",value:function getNonce(){for(var a,b=_constants2.HEX_CHARACTERS.length,c="",d=0;d<b;d++)a=Math.floor(Math.random()*b),c+=_constants2.HEX_CHARACTERS.substring(a,a+1);return c}},{key:"sendOfflineTracking",value:function(){function a(a){return b.apply(this,arguments)}var b=_asyncToGenerator(_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k,l,m,n;return _regeneratorRuntime().wrap(function o(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.requester,d=a.storage,e=d.read(),!(e.ok&&e.data.requestParameters)){b.next=33;break}f=e.data.requestParameters,g=[],h=_createForOfIteratorHelper(f),b.prev=6,h.s();case 8:if((i=h.n()).done){b.next=24;break}if(j=i.value,k=j.timestamp,l=j.isExperiment,m=_objectWithoutProperties(j,_excluded),n=void 0,!l){b.next=18;break}return b.next=15,c.trackExperiment(m);case 15:n=b.sent,b.next=21;break;case 18:return b.next=20,c.trackData(m);case 20:n=b.sent;case 21:n.ok&&n.data&&g.push(k);case 22:b.next=8;break;case 24:b.next=29;break;case 26:b.prev=26,b.t0=b["catch"](6),h.e(b.t0);case 29:return b.prev=29,h.f(),b.finish(29);case 32:this.deleteFromOfflineTracking({storage:d,timestamps:g});case 33:case"end":return b.stop();}},b,this,[[6,26,29,32]])}));return a}()},{key:"compareSemVer",value:function compareSemVer(a){var b=a.version,c=a.compareVersion,d=a.operator,e=this.validateVersion(b),f=this.validateVersion(c);if(!e.ok)return(0,_tsRes.Err)(e.error);if(!f.ok)return(0,_tsRes.Err)(f.error);var g=_slicedToArray(e.data,3),h=g[0],i=g[1],j=g[2],k=_slicedToArray(f.data,3),l=k[0],m=k[1],n=k[2],o=h===l,p=i===m,q=j===n;switch(d){case _targeting.VersionMatchType.EQUAL:return(0,_tsRes.Ok)(o&&p&&q);case _targeting.VersionMatchType.GREATER:return(0,_tsRes.Ok)(h>l||o&&i>m||o&&p&&j>n);case _targeting.VersionMatchType.LOWER:return(0,_tsRes.Ok)(h<l||o&&i<m||o&&p&&j<n);default:(0,_kameleoonError.exhaustCheck)(d);}}},{key:"addItemToOfflineTracking",value:function addItemToOfflineTracking(a){var b=a.item,c=a.isExperiment,d=a.storage,e=a.onSuccess,f=d.read(),g=f.ok?f.data:{},h=g.requestParameters,i=_objectSpread(_objectSpread({},b),{},{timestamp:new Date().getTime(),isExperiment:c}),j=h?[].concat(_toConsumableArray(h),[i]):[i],k=d.write({requestParameters:j});k.ok&&e&&e()}},{key:"deleteFromOfflineTracking",value:function deleteFromOfflineTracking(a){var b=a.timestamps,c=a.storage,d=c.read();if(d.ok){var e=d.data.requestParameters,f=null===e||void 0===e?void 0:e.filter(function(a){return!b.includes(a.timestamp)});c.write({requestParameters:f})}}},{key:"validateVersion",value:function validateVersion(a){for(var b=a.split(".").map(function(a){return parseInt(a,10)});3>b.length;)b.push(0);return b.some(function(a){return isNaN(a)})?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.SemanticVersionParse,a)):(0,_tsRes.Ok)(b.slice(0,3))}}]),a}();exports.Utilities=Utilities;
//# sourceMappingURL=utilities.js.map
export { VariationConfiguration } from './variationConfiguration';
export { VariationType, FeatureFlagVariationType } from './types';
export { FeatureFlagVariationType } from './types';

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"FeatureFlagVariationType",{enumerable:!0,get:function get(){return _types.FeatureFlagVariationType}}),Object.defineProperty(exports,"VariationConfiguration",{enumerable:!0,get:function get(){return _variationConfiguration.VariationConfiguration}}),Object.defineProperty(exports,"VariationType",{enumerable:!0,get:function get(){return _types.VariationType}});var _variationConfiguration=require("./variationConfiguration"),_types=require("./types");
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"FeatureFlagVariationType",{enumerable:!0,get:function get(){return _types.FeatureFlagVariationType}}),Object.defineProperty(exports,"VariationConfiguration",{enumerable:!0,get:function get(){return _variationConfiguration.VariationConfiguration}});var _variationConfiguration=require("./variationConfiguration"),_types=require("./types");
//# sourceMappingURL=index.js.map

@@ -1,13 +0,5 @@

import { CampaignConfiguration, FeatureFlagType, RuleItemType } from '../campaignConfiguration';
import { ClientConfiguration, FeatureFlagType, RuleItemType } from '../clientConfiguration';
import { DataManager } from '../kameleoonData';
import { KameleoonVisitorDataType } from '../kameleoonData/types';
import { ExternalPackageInfoType } from '../types';
export type VariationType = {
variationId: number;
assignmentDate: string;
};
export type UpdateStorageParamsType = {
visitorCode: string;
experimentId: string;
variationId: number;
};
export type FeatureFlagVariationType = {

@@ -21,3 +13,3 @@ variationKey: string;

};
export type GetFeatureFlagVariationParametersType = {
export type GetVariationParametersType = {
visitorCode: string;

@@ -28,3 +20,4 @@ featureFlag: FeatureFlagType;

packageInfo: ExternalPackageInfoType;
campaignConfiguration: CampaignConfiguration;
clientConfiguration: ClientConfiguration;
dataManager: DataManager;
};
import { Result } from 'ts-res';
import { ExperimentItemType } from '../campaignConfiguration';
import { KameleoonError } from '../kameleoonError';
import { IExternalStorage, VariationDataType, ExperimentVariationsType } from '../storage';
import { FeatureFlagVariationType, GetFeatureFlagVariationParametersType } from './types';
import { IExternalStorage, VariationDataType } from '../storage';
import { FeatureFlagVariationType, GetVariationParametersType } from './types';
import { FeatureFlagVariationsType } from '../storage/types';
interface IVariationConfiguration {
/**
* @method getAssociatedVariationId - gets the id of a variation assigned to a visitor with `visitorCode` from the storage. If the visitor doesn't have associated variation yet, assigns a new one, stores it and returns it's id.
* @method getStoredVariations - obtains campaigns with according variations that are *already assigned* and *stored* in the `variationStorage`.
*/
getAssociatedVariationId: (visitorCode: string, experimentId: number) => Result<number, KameleoonError>;
getStoredVariations(visitorCode: string): Result<FeatureFlagVariationsType, KameleoonError>;
/**
* @method getAssignedVariations - obtains experiments with according variations that are *already assigned* and *stored* in the `variationStorage`. If `getAssociatedVariationId` had not been called before, there will be no variations to get.
* @method updateStoredVariations - updates stored variations for the visitor
*/
getAssignedVariations(visitorCode: string): Result<ExperimentVariationsType, KameleoonError>;
updateStoredVariations: (visitorCode: string, variationData: FeatureFlagVariationsType) => void;
/**
* @method getFeatureFlagVariation - obtains variation for the rule of the feature flag which is both targeted and has a variation, if no such rule was found, returns empty rule with default `variationKey`, given an option `withAssignment` of `true` will also assign a new variation and save it in the storage
* @method getVariation - obtains variation for the rule of the feature flag which is both targeted and has a variation, if no such rule was found, returns empty rule with default `variationKey`, given an option `withAssignment` of `true` will also assign a new variation and save it in the storage
*/
getFeatureFlagVariation: (params: GetFeatureFlagVariationParametersType) => Result<FeatureFlagVariationType, KameleoonError>;
/**
* @method getExperimentVariation - obtains variation for the experiment by calculating the variation for the visitor *without assigning* it to a visitor
*/
getExperimentVariation: (visitorCode: string, experiment: ExperimentItemType) => Result<number, KameleoonError>;
getVariation: (params: GetVariationParametersType) => Result<FeatureFlagVariationType, KameleoonError>;
}
export declare class VariationConfiguration implements IVariationConfiguration {
private experiments;
private storage;
constructor(experiments: ExperimentItemType[], externalStorage: IExternalStorage<VariationDataType>);
getAssociatedVariationId: (visitorCode: string, experimentId: number) => Result<number, KameleoonError>;
getAssignedVariations(visitorCode: string): Result<ExperimentVariationsType, KameleoonError>;
getFeatureFlagVariation({ visitorCode, featureFlag, targetingData, packageInfo, campaignConfiguration, withAssignment, }: GetFeatureFlagVariationParametersType): Result<FeatureFlagVariationType, KameleoonError>;
getExperimentVariation(visitorCode: string, experiment: ExperimentItemType): Result<number, KameleoonError>;
private assignVariation;
private updateStorageData;
constructor(externalStorage: IExternalStorage<VariationDataType>);
getStoredVariations(visitorCode: string): Result<FeatureFlagVariationsType, KameleoonError>;
getVariation({ visitorCode, featureFlag, targetingData, packageInfo, clientConfiguration, dataManager, withAssignment, }: GetVariationParametersType): Result<FeatureFlagVariationType, KameleoonError>;
updateStoredVariations(visitorCode: string, variationData: FeatureFlagVariationsType): Result<void, KameleoonError>;
}
export {};

@@ -1,66 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariationConfiguration=void 0;var _tsRes=require("ts-res"),_hasher=require("../hasher"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_types=require("../campaignConfiguration/types"),_excluded=["exposition"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var VariationConfiguration=/*#__PURE__*/function(){function a(b,c){var d=this;_classCallCheck(this,a),_defineProperty(this,"experiments",void 0),_defineProperty(this,"storage",void 0),_defineProperty(this,"getAssociatedVariationId",function(a,b){// TODO:
// --- Variation from storage is not checked anymore
// --- If nothing changes the commented code should be deleted
// along with the `Variation` class and according tests/types
// --- Mind `todo` in `getAssociatedVariationId.spec.ts`
//
// let associatedVariation: VariationType | undefined;
// this.storage.read().and((data) => {
// associatedVariation = data?.[visitorCode]?.[experimentId];
// });
var c=d.experiments.find(function(a){return a.id===b+""});return c?d.assignVariation(a,c):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.ExperimentConfigurationNotFound,b,a));// const variation = new Variation(associatedVariation);
// if (variation.isValid(experiment?.respoolTime)) {
// return Ok(variation.id);
// }
}),this.experiments=b,this.storage=c}return _createClass(a,[{key:"getAssignedVariations",value:function getAssignedVariations(a){var b=this.storage.read();if(!b.ok)return b;var c=b.data[a];return c?(0,_tsRes.Ok)(c):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.StorageRead,a))}},{key:"getFeatureFlagVariation",value:function getFeatureFlagVariation(a){var b=a.visitorCode,c=a.featureFlag,d=a.targetingData,e=a.packageInfo,f=a.campaignConfiguration,g=a.withAssignment,h=_utilities.Utilities.validateVisitorCode(b);if(!h.ok)return(0,_tsRes.Err)(h.error);var i,j=c.rules,k=c.featureKey,l=c.id,m=c.defaultVariationKey,n=_createForOfIteratorHelper(j);try{for(n.s();!(i=n.n()).done;){var o=i.value,p=o.segment,q=o.experimentId,r=o.id,s=o.exposition,t=o.respoolTime,u=o.variationByExposition,v=_utilities.Utilities.checkTargeting({segment:p,visitorCode:b,experimentId:q,targetingData:d,packageInfo:e,campaignConfiguration:f,variationConfiguration:this});if(!v.ok)return v;if(v.data){// --- Note ---
// Calculate new variation (and assign it if `withAssignment` is `true`)
// First the the exposed rule is calculated and then the variation inside of it
var w=_hasher.Hasher.obtainFeatureFlagHashDouble({visitorCode:b,respoolTime:t,campaignId:r+""});if(w<=s){var x,y=0,z=_hasher.Hasher.obtainFeatureFlagHashDouble({visitorCode:b,respoolTime:t,campaignId:q+""}),A=_createForOfIteratorHelper(u);try{for(A.s();!(x=A.n()).done;){var B=x.value;if(y+=B.exposition,z<=y){o.type===_types.RuleType.EXPERIMENTATION&&void 0!==g&&g&&this.updateStorageData({visitorCode:b,experimentId:q+"",// --- Note ---
// For `RuleType.EXPERIMENTATION` `variationId` can not be null
variationId:B.variationId});var C=B.exposition,D=_objectWithoutProperties(B,_excluded);return(0,_tsRes.Ok)(_objectSpread(_objectSpread({},D),{},{rule:o,featureFlagId:l,featureKey:k,experimentId:q}))}}}catch(a){A.e(a)}finally{A.f()}}if(o.type===_types.RuleType.TARGETED_DELIVERY)break}}}catch(a){n.e(a)}finally{n.f()}return(0,_tsRes.Ok)({featureKey:k,featureFlagId:l,experimentId:null,variationKey:m,variationId:null,rule:null})}},{key:"getExperimentVariation",value:function getExperimentVariation(a,b){var c,d=b.id,e=b.respoolTime,f=b.deviations,g=_hasher.Hasher.obtainExperimentHashDouble({visitorCode:a,campaignId:d,respoolTime:e}),h=!0,i=0,j=0,k=_createForOfIteratorHelper(f);try{for(k.s();!(c=k.n()).done;){var l=c.value;if(i+=l.value,i>=g){h=!1,"origin"!==l.variationId&&(j=+l.variationId);break}}}catch(a){k.e(a)}finally{k.f()}return h?(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.NotAllocated,a)):(0,_tsRes.Ok)(j)}},{key:"assignVariation",value:function assignVariation(a,b){var c=this.getExperimentVariation(a,b);if(!c.ok)return c;var d=this.updateStorageData({visitorCode:a,experimentId:b.id,variationId:c.data});return d.ok?(0,_tsRes.Ok)(c.data):d}},{key:"updateStorageData",value:function updateStorageData(a){var b=a.visitorCode,c=a.experimentId,d=a.variationId,e=this.storage.read();if(!e.ok&&e.error.type===_kameleoonError.KameleoonException.StorageParse)// --- Note ---
// If there is a parsing error we return error
// But if there is `LocalStorageRead` error it means that
// data was read successfully and it's empty, which is not problem
// cause that might be initial `read`
return e;var f=e.ok?e.data:{},g={variationId:d,assignmentDate:new Date().toString()};return f[b]?f[b][c]=g:f[b]=_defineProperty({},c,g),this.storage.write(f)}// --- TODO: commented out in case of future logic rework ---
// --- Mind: `variationId` could cause the `undefined` issue ---
// --- Reference: https://development.kameleoon.net/sdk/javascript-sdk-packages/-/merge_requests/89 ---
// private getAssignedRuleVariation(
// visitorCode: string,
// rule: RuleItemType,
// ): Result<GetAssignedRuleVariationResultType, KameleoonError> {
// const emptyVariation: Omit<VariationByExpositionType, 'exposition'> = {
// variationId: null,
// variationKey: '',
// };
// const { experimentId, variationByExposition } = rule;
// const variationsResult = this.getAssignedVariations(visitorCode);
// // --- Note ---
// // If there is an error, we just want to skip seeking
// // for variation in the storage, not throw an error
// if (!variationsResult.ok) {
// return Ok(emptyVariation);
// }
// const variations = variationsResult.data;
// if (
// experimentId &&
// typeof variations[experimentId].variationId !== undefined
// ) {
// const id = variations[experimentId].variationId;
// const featureFlagVariation = variationByExposition.find(
// (item) => item.variationId == id,
// );
// if (!featureFlagVariation) {
// // --- Note ---
// // This error is not described for public methods as
// // it serves internal purpose of checking whether
// // the persistent variation has been updated and should be re-allocated
// return Err(new KameleoonError(KameleoonException.DataInconsistency));
// }
// const { exposition, ...restParameters } = featureFlagVariation;
// return Ok({ ...restParameters });
// }
// return Ok(emptyVariation);
// }
}]),a}();exports.VariationConfiguration=VariationConfiguration;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.VariationConfiguration=void 0;var _tsRes=require("ts-res"),_hasher=require("../hasher"),_kameleoonError=require("../kameleoonError"),_utilities=require("../utilities"),_types=require("../clientConfiguration/types"),_excluded=["exposition"];function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _objectWithoutProperties(a,b){if(null==a)return{};var c,d,e=_objectWithoutPropertiesLoose(a,b);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||Object.prototype.propertyIsEnumerable.call(a,c)&&(e[c]=a[c])}return e}function _objectWithoutPropertiesLoose(a,b){if(null==a)return{};var c,d,e={},f=Object.keys(a);for(d=0;d<f.length;d++)c=f[d],0<=b.indexOf(c)||(e[c]=a[c]);return e}function _createForOfIteratorHelper(a,b){var c="undefined"!=typeof Symbol&&a[Symbol.iterator]||a["@@iterator"];if(!c){if(Array.isArray(a)||(c=_unsupportedIterableToArray(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function n(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function e(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function s(){c=c.call(a)},n:function n(){var a=c.next();return g=a.done,a},e:function e(a){h=!0,f=a},f:function f(){try{g||null==c.return||c.return()}finally{if(h)throw f}}}}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return b=_toPropertyKey(b),b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"===_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!==_typeof(a)||null===a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var d=c.call(a,b||"default");if("object"!==_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}var VariationConfiguration=function(){function a(b){_classCallCheck(this,a),_defineProperty(this,"storage",void 0),this.storage=b}return _createClass(a,[{key:"getStoredVariations",value:function getStoredVariations(a){var b=this.storage.read();if(!b.ok)return b;var c=b.data[a];return c?(0,_tsRes.Ok)(c):(0,_tsRes.Err)(new _kameleoonError.KameleoonError(_kameleoonError.KameleoonException.StorageRead,a))}},{key:"getVariation",value:function getVariation(a){var b=a.visitorCode,c=a.featureFlag,d=a.targetingData,e=a.packageInfo,f=a.clientConfiguration,g=a.dataManager,h=a.withAssignment,i=_utilities.Utilities.validateVisitorCode(b);if(!i.ok)return(0,_tsRes.Err)(i.error);var j,k=c.rules,l=c.featureKey,m=c.id,n=c.defaultVariationKey,o=_createForOfIteratorHelper(k);try{for(o.s();!(j=o.n()).done;){var p=j.value,q=p.segment,r=p.experimentId,s=p.id,t=p.exposition,u=p.respoolTime,v=p.variationByExposition,w=_utilities.Utilities.checkTargeting({segment:q,visitorCode:b,experimentId:r,targetingData:d,packageInfo:e,clientConfiguration:f,dataManager:g,variationConfiguration:this});if(!w.ok)return w;if(w.data){var x=_hasher.Hasher.getHashDouble({visitorCode:b,respoolTime:u,id:s+""});if(x<=t){var y,z=0,A=_hasher.Hasher.getHashDouble({visitorCode:b,respoolTime:u,id:r+""}),B=_createForOfIteratorHelper(v);try{for(B.s();!(y=B.n()).done;){var C=y.value;if(z+=C.exposition,A<=z){void 0!==h&&h&&this.updateStoredVariations(b,_defineProperty({},r,C.variationId));var D=C.exposition,E=_objectWithoutProperties(C,_excluded);return(0,_tsRes.Ok)(_objectSpread(_objectSpread({},E),{},{rule:p,featureFlagId:m,featureKey:l,experimentId:r}))}}}catch(a){B.e(a)}finally{B.f()}}if(p.type===_types.RuleType.TARGETED_DELIVERY)break}}}catch(a){o.e(a)}finally{o.f()}return(0,_tsRes.Ok)({featureKey:l,featureFlagId:m,experimentId:null,variationKey:n,variationId:null,rule:null})}},{key:"updateStoredVariations",value:function updateStoredVariations(a,b){var c=this.storage.read();if(!c.ok&&c.error.type===_kameleoonError.KameleoonException.StorageParse)return c;var d=c.ok?c.data:{};return d[a]?d[a]=_objectSpread(_objectSpread({},d[a]),b):d=_objectSpread(_objectSpread({},d),{},_defineProperty({},a,_objectSpread({},b))),this.storage.write(d)}}]),a}();exports.VariationConfiguration=VariationConfiguration;
//# sourceMappingURL=variationConfiguration.js.map
{
"name": "@kameleoon/javascript-sdk-core",
"version": "2.10.1",
"version": "3.0.0",
"description": "Kameleoon JS SDK Core",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc